Datasets:
Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- md/dev/-H48S9ePSUC/-H48S9ePSUC.md +424 -0
- md/dev/03RLpj-tc_/03RLpj-tc_.md +470 -0
- md/dev/1YEF6TA8Di/1YEF6TA8Di.md +475 -0
- md/dev/1qvx610Cu7/1qvx610Cu7.md +217 -0
- md/dev/3KWnuT-R1bh/3KWnuT-R1bh.md +419 -0
- md/dev/3ly9cG9Ql9h/3ly9cG9Ql9h.md +899 -0
- md/dev/4G1Sfp_1sz7/4G1Sfp_1sz7.md +367 -0
- md/dev/4R7YrAGhnve/4R7YrAGhnve.md +255 -0
- md/dev/6MmiS0HUJHR/6MmiS0HUJHR.md +0 -0
- md/dev/6Pv8AMSylux/6Pv8AMSylux.md +0 -0
- md/dev/AJg35fkqOPA/AJg35fkqOPA.md +262 -0
- md/dev/AP1MKT37rJ/AP1MKT37rJ.md +0 -0
- md/dev/BvowzJp_Yl6/BvowzJp_Yl6.md +205 -0
- md/dev/E9dH0BP5VW/E9dH0BP5VW.md +298 -0
- md/dev/EMLJ_mTz_z/EMLJ_mTz_z.md +292 -0
- md/dev/F7nD--1JIC/F7nD--1JIC.md +324 -0
- md/dev/GGi4igGZEB-/GGi4igGZEB-.md +856 -0
- md/dev/GMYWzWztDx5/GMYWzWztDx5.md +312 -0
- md/dev/GUrhfTuf_3/GUrhfTuf_3.md +345 -0
- md/dev/HPuSIXJaa9/HPuSIXJaa9.md +292 -0
- md/dev/JhzzvJnL9t/JhzzvJnL9t.md +395 -0
- md/dev/MpJjrfSJ-Xs/MpJjrfSJ-Xs.md +346 -0
- md/dev/NjeEfP7e3KZ/NjeEfP7e3KZ.md +302 -0
- md/dev/PUIqjT4rzq7/PUIqjT4rzq7.md +410 -0
- md/dev/QkRV50TZyP/QkRV50TZyP.md +412 -0
- md/dev/Qy1D9JyMBg0/Qy1D9JyMBg0.md +291 -0
- md/dev/RdJVFCHjUMI/RdJVFCHjUMI.md +0 -0
- md/dev/SJ0Lde3tRL/SJ0Lde3tRL.md +0 -0
- md/dev/TrjbxzRcnf-/TrjbxzRcnf-.md +447 -0
- md/dev/TwyEk7HzJb6/TwyEk7HzJb6.md +440 -0
- md/dev/WZ3yjh8coDg/WZ3yjh8coDg.md +0 -0
- md/dev/WZH7099tgfM/WZH7099tgfM.md +0 -0
- md/dev/Wjp1AYB8lH/Wjp1AYB8lH.md +435 -0
- md/dev/X6dEqXIsEW/X6dEqXIsEW.md +222 -0
- md/dev/Yacmpz84TH/Yacmpz84TH.md +281 -0
- md/dev/Z4kZxAjg8Y/Z4kZxAjg8Y.md +362 -0
- md/dev/ZTsoE8G3GG/ZTsoE8G3GG.md +448 -0
- md/dev/Zq2G_VTV53T/Zq2G_VTV53T.md +489 -0
- md/dev/_CDixzkzeyb/_CDixzkzeyb.md +826 -0
- md/dev/_h2FKc6E_YV/_h2FKc6E_YV.md +279 -0
- md/dev/_nGgzQjzaRy/_nGgzQjzaRy.md +0 -0
- md/dev/aUkOeKsGe2X/aUkOeKsGe2X.md +345 -0
- md/dev/ayPPc0SyLv1/ayPPc0SyLv1.md +394 -0
- md/dev/b90lKL1IqcF/b90lKL1IqcF.md +272 -0
- md/dev/bydKs84JEyw/bydKs84JEyw.md +320 -0
- md/dev/cVak2hs06z/cVak2hs06z.md +0 -0
- md/dev/cmt-6KtR4c4/cmt-6KtR4c4.md +333 -0
- md/dev/e0uknAgETh/e0uknAgETh.md +232 -0
- md/dev/e42KbIw6Wb/e42KbIw6Wb.md +351 -0
- md/dev/fPhKeld3Okz/fPhKeld3Okz.md +0 -0
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 |
+

|
| 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 |
+

|
| 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 |
+

|
| 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 |
+

|
| 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 |
+

|
| 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/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 |
+

|
| 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 |
+

|
| 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 |
+

|
| 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 |
+

|
| 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 |
+

|
| 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><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><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><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 |
+

|
| 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 |
+

|
| 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 |
+

|
| 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/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 |
+

|
| 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 |
+

|
| 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 |
+

|
| 243 |
+
Figure 3: Bayesian linear regression in 100 dimensions.
|
| 244 |
+
|
| 245 |
+

|
| 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 |
+

|
| 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 |
+

|
| 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 |
+

|
| 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 |
+

|
| 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 |
+

|
| 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 |
+

|
| 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><</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/3KWnuT-R1bh/3KWnuT-R1bh.md
ADDED
|
@@ -0,0 +1,419 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# CONDITIONAL POSITIONAL ENCODINGS FOR VISION TRANSFORMERS
|
| 2 |
+
|
| 3 |
+
Xiangxiang $\mathbf { C h u ^ { 1 } }$ , Zhi Tian1, Bo Zhang1, Xinlong Wang2, Chunhua Shen3∗ 1 Meituan Inc. 2 Beijing Academy of AI 3 Zhejiang University, China {chuxiangxiang, tianzhi02, zhangbo97}@meituan.com, xinlong.wang96@gmail.com, chunhua@me.com
|
| 4 |
+
|
| 5 |
+
# ABSTRACT
|
| 6 |
+
|
| 7 |
+
We propose a conditional positional encoding (CPE) scheme for vision Transformers (Dosovitskiy et al., 2021; Touvron et al., 2020). Unlike previous fixed or learnable positional encodings that are predefined and independent of input tokens, CPE is dynamically generated and conditioned on the local neighborhood of the input tokens. As a result, CPE can easily generalize to the input sequences that are longer than what the model has ever seen during the training. Besides, CPE can keep the desired translation equivalence in vision tasks, resulting in improved performance. We implement CPE with a simple Position Encoding Generator (PEG) to get seamlessly incorporated into the current Transformer framework. Built on PEG, we present Conditional Position encoding Vision Transformer (CPVT). We demonstrate that CPVT has visually similar attention maps compared to those with learned positional encodings and delivers outperforming results. Our Code is available at: https://git.io/CPVT.
|
| 8 |
+
|
| 9 |
+
# 1 INTRODUCTION
|
| 10 |
+
|
| 11 |
+
Recently, Transformers (Vaswani et al., 2017) have been viewed as a strong alternative to Convolutional Neural Networks (CNNs) in visual recognition tasks such as classification (Dosovitskiy et al., 2021) and detection (Carion et al., 2020; Zhu et al., 2021). Unlike the convolution operation in CNNs, which has a limited receptive field, the self-attention mechanism in the Transformers can capture the long-distance information and dynamically adapt the receptive field according to the image content. Consequently, Transformers are considered more flexible and powerful than CNNs, being promising to achieve more progress in visual recognition.
|
| 12 |
+
|
| 13 |
+
However, the self-attention operation in Transformers is permutation-invariant, which discards the order of the tokens in an input sequence. To mitigate this issue, previous works (Vaswani et al., 2017; Dosovitskiy et al., 2021) add the absolute positional encodings to each input token (see Figure 1a), which enables order-awareness. The positional encoding can either be learnable or fixed with sinusoidal functions of different frequencies. Despite being effective, these positional encodings seriously harm the flexibility of the Transformers, hampering their broader applications. Taking the learnable version as an example, the encodings are often a vector of equal length to the input sequence, which are jointly updated with the network weights during training. As a result, the length and the value of the positional encodings are fixed once trained. During testing, it causes difficulties of handling the sequences longer than the ones in the training data.
|
| 14 |
+
|
| 15 |
+
The inability to adapt to longer input sequences during testing greatly limits the range of generalization. For instance, in vision tasks like object detection, we expect the model can be applied to the images of any size during inference, which might be much larger than the training images. A possible remedy is to use bicubic interpolation to upsample the positional encodings to the target length, but it degrades the performance without fine-tuning as later shown in our experiments. For vision in general, we expect that the models be translation-equivariant. For example, the output feature maps of CNNs shift accordingly as the target objects are moved in the input images. However, the absolute positional encoding scheme might break the translation equivalence because it adds unique positional encodings to each token (or each image patch). One may overcome the issue with relative positional encodings as in (Shaw et al., 2018). However, relative positional encodings not only come with extra computational costs, but also require modifying the implementation of the standard Transformers. Last but not least, the relative positional encodings cannot work equally well as the absolute ones, because the image recognition task still requires absolute position information (Islam et al., 2020), which the relative positional encodings fail to provide.
|
| 16 |
+
|
| 17 |
+

|
| 18 |
+
Figure 1. Vision Transformers: (a) ViT (Dosovitskiy et al., 2021) with explicit 1D learnable positional encodings (PE) (b) CPVT with conditional positional encoding from the proposed Position Encoding Generator (PEG) plugin, which is the default choice. (c) CPVT-GAP without class token (cls), but with global average pooling (GAP) over all items in the sequence. Note that GAP is a bonus version which has boosted performance.
|
| 19 |
+
|
| 20 |
+
In this work, we advocate a novel positional encoding (PE) scheme to incorporate the position information into Transformers. Unlike the predefined and input-agnostic positional encodings used in previous works (Dosovitskiy et al., 2021; Vaswani et al., 2017; Shaw et al., 2018), the proposed PE is dynamically generated and conditioned on the local neighborhood of input tokens. Thus, our positional encodings can change along with the input size and try to keep translation equivalence. We demonstrate that the vision transformers (Dosovitskiy et al., 2021; Touvron et al., 2020) with our new PE (i.e. CPVT, see Figure 1c) achieve even better performance. We summarize our contributions as, • We propose a novel positional encoding (PE) scheme, termed conditional position encodings (CPE). CPE is dynamically generated with Positional Encoding Generators (PEG) and can be effortlessly implemented by the modern deep learning frameworks (Paszke et al., 2019; Abadi et al., 2016; Chen et al., 2015), requiring no changes to the current Transformer APIs. Through an in-depth analysis and thorough experimentations, we unveil that this design affords both absolute and relative encoding yet it goes above and beyond.
|
| 21 |
+
|
| 22 |
+
• As opposed to widely-used absolute positional encodings, CPE can provide a kind of stronger explicit bias towards the translation equivalence which is important to improve the performance of Transformers.
|
| 23 |
+
|
| 24 |
+
• Built on CPE, we propose Conditional Position encoding Vision Transformer (CPVT). It achieves better performance than previous vison transformers (Dosovitskiy et al., 2021; Touvron et al., 2020).
|
| 25 |
+
|
| 26 |
+
• CPE can well generalize to arbitrary input resolutions, which are required in many important downstream tasks such as segmentation and detection. Through experiments we show that CPE can boost the segmentation and detection performance for pyramid transformers like (Wang et al., 2021) by a clear margin.
|
| 27 |
+
|
| 28 |
+
# 2 RELATED WORK
|
| 29 |
+
|
| 30 |
+
Since self-attention itself is permutation-equivariant (see A), positional encodings are commonly employed to incorporate the order of sequences (Vaswani et al., 2017). The positional encodings can either be fixed or learnable, while either being absolute or relative. Vision transformers follow the same fashion to imbue the network with positional information.
|
| 31 |
+
|
| 32 |
+
Absolute Positional Encoding. The absolute positional encoding is the most widely used. In the original transformer (Vaswani et al., 2017), the encodings are generated with the sinusoidal functions of different frequencies and then they are added to the inputs. Alternatively, the positional encodings can be learnable, where they are implemented with a fixed-dimension matrix/tensor and jointly updated with the model’s parameters with SGD.
|
| 33 |
+
|
| 34 |
+
Relative Positional Encoding. The relative position encoding (Shaw et al., 2018) considers distances between the tokens in the input sequence. Compared to the absolute ones, the relative positional encodings can be translation-equivariant and can naturally handle the sequences longer than the longest sequences during training (i.e., being inductive). A 2-D relative position encoding is proposed for image classification in (Bello et al., 2019), showing superiority to 2D sinusoidal embeddings. The relative positional encoding is further improved in XLNet (Yang et al., 2019b) and DeBERTa (He et al., 2020), showing better performance.
|
| 35 |
+
|
| 36 |
+
Other forms. Complex-value embeddings (Wang et al., 2019) are an extension to model global absolute encodings and show improvement. RoFormer (Su et al., 2021) utilizes a rotary position embedding to encode both absolute and relative position information for text classification. FLOATER (Liu et al., 2020) proposes a novel continuous dynamical model to capture position encodings. It is not limited by the maximum sequence length during training, meanwhile being parameter-efficient.
|
| 37 |
+
|
| 38 |
+
Similar designs to CPE. Convolutions are used to model local relations in ASR and machine translation (Gulati et al., 2020; Mohamed et al., 2019; Yang et al., 2019a; Yu et al., 2018). However, they are mainly limited to 1D signals. We instead process 2D vision images.
|
| 39 |
+
|
| 40 |
+
# 3 VISION TRANSFORMER WITH CONDITIONAL POSITION ENCODINGS
|
| 41 |
+
|
| 42 |
+
# 3.1 MOTIVATION
|
| 43 |
+
|
| 44 |
+
In vision transformers, an input image of size $H \times W$ is split into patches with size $S \times S$ , the number of patches is $\begin{array} { r } { \dot { N } = \frac { H \dot { W } \mathbb { 1 } } { S ^ { 2 } } } \end{array}$ . The patches are added with the same number of learnable absolute positional encoding vectors. In this work, we argue that the positional encodings used here have two issues. First, it prevents the model from handling the sequences longer than the learnable PE. Second, it makes the model not translation-equivariant because a unique positional encoding vector is added to every one patch. The translation equivalence plays an important role in classification because we hope the networks’ responses changes accordingly as the object moves in the image.
|
| 45 |
+
|
| 46 |
+
One may note that the first issue can be remedied by removing the positional encodings since except for the positional encodings, all other components (e.g., MHSA and FFN) of the vision transformer can directly be applied to longer sequences. However, this solution severely deteriorates the performance. This is understandable because the order of the input sequence is an important clue and the model has no way to extract the order without the positional encodings. The experiment results on ImageNet are shown in Table 1. By removing the positional encodings, DeiT-tiny’s performance on ImageNet dramatically degrades from $7 2 . 2 \%$ to $6 8 . 2 \%$ .
|
| 47 |
+
|
| 48 |
+
Second, in DeiT (Touvron et al., 2020), they show that we can interpolate the position encodings to make them have the same length of the longer sequences. However, this method requires finetuning the model a few more epochs, otherwise the performance will remarkably drop, as shown in Table 1. This goes contrary to what we would expect. With the higher-resolution inputs, we often expect a remarkable performance improvement without any fine-tuning. Finally, the relative position encodings (Shaw et al., 2018; Bello et al., 2019) can cope with both the aforementioned issues. However, the relative positional encoding cannot provide absolute position information, which is also important to the classification performance (Islam et al., 2020). As shown in Table 1, the model with relative position encodings has inferior performance ( $7 0 . 5 \%$ vs. $7 2 . 2 \%$ ).
|
| 49 |
+
|
| 50 |
+
Table 1. Comparison of various positional encoding (PE) strategies tested on ImageNet validation set in terms of the top-1 accuracy. Removing the positional encodings greatly damages the performance. The relative positional encodings have inferior performance to the absolute ones
|
| 51 |
+
|
| 52 |
+
<table><tr><td>Model</td><td>Encoding</td><td>Top-1@224(%)</td><td>Top-1@384(%)</td></tr><tr><td>DeiT-tiny (Touvron et al., 2020)</td><td>X</td><td>68.2</td><td>68.6</td></tr><tr><td>DeiT-tiny (Touvron et al., 2020)</td><td>learnable</td><td>72.2</td><td>71.2</td></tr><tr><td>DeiT-tiny (Touvron et al., 2020)</td><td>sin-cos</td><td>72.3</td><td>70.8</td></tr><tr><td>DeiT-tiny</td><td>2D RPE (Shaw et al., 2018)</td><td>70.5</td><td>69.8</td></tr></table>
|
| 53 |
+
|
| 54 |
+
# 3.2 CONDITIONAL POSITIONAL ENCODINGS
|
| 55 |
+
|
| 56 |
+
We argue that a successful positional encoding for vision tasks should meet these requirements,
|
| 57 |
+
|
| 58 |
+
(1) Making the input sequence permutation-variant and providing stronger explicit bias towards translation-equivariance.
|
| 59 |
+
(2) Being inductive and able to handle the sequences longer than the ones during training.
|
| 60 |
+
(3) Having the ability to provide the absolute position to a certain degree. This is important to the performance as shown in (Islam et al., 2020).
|
| 61 |
+
|
| 62 |
+
In this work, we find that characterizing the local relationship by positional encodings is sufficient to meet all of the above. First, it is permutation-variant because the permutation of input sequences also affects the order in some local neighborhoods. However, translation of an object in an input image does not change the order in its local neighborhood, i.e., translation-equivariant (see Section A). Second, the model can easily generalize to longer sequences since only the local neighborhoods of a token are involved. Besides, if the absolute position of any input token is known, the absolute position of all the other tokens can be inferred by the mutual relation between input tokens. We will show that the tokens on the borders can be aware of their absolute positions due to the commonly-used zero paddings.
|
| 63 |
+
|
| 64 |
+
Therefore, we propose positional encoding generators (PEG) to dynamically produce the positional encodings conditioned on the local neighborhood of an input token.
|
| 65 |
+
|
| 66 |
+
Positional Encoding Generator. PEG is illustrated in Figure 2. To condition on the local neighbors, we first
|
| 67 |
+
|
| 68 |
+

|
| 69 |
+
Figure 2. Schematic illustration of Positional Encoding Generator (PEG). Note $d$ is the embedding size, $N$ is the number of tokens.
|
| 70 |
+
|
| 71 |
+
reshape the flattened input sequence $X \in \mathbb { R } ^ { B \times N \times C }$ of DeiT back to $X ^ { \prime } \in \mathbb { R } ^ { B \times H \times W \times C }$ in the 2-D image space. Then, a function (denoted by $\mathcal { F }$ in Figure 2) is repeatedly applied to the local patch in $X ^ { \prime }$ to produce the conditional positional encodings $E ^ { \tilde { B } \times H \times \tilde { W } \times C }$ . PEG can be efficiently implemented with a 2-D convolution with kernel zero paddings here are important to make the mo $k$ l $( k \geq 3 )$ and re of $\frac { k - 1 } { 2 }$ zero paddings. Note tabsolute positions, and thecan $\mathcal { F }$ be of various forms such as various types of convolutions and many others.
|
| 72 |
+
|
| 73 |
+
# 3.3 CONDITIONAL POSITIONAL ENCODING VISION TRANSFORMERS
|
| 74 |
+
|
| 75 |
+
Built on the conditional positional encodings, we propose our Conditional Positional Encoding Vision Transformers (CPVT). Except that our positional encodings are conditional, we exactly follow
|
| 76 |
+
|
| 77 |
+
ViT and DeiT to design our vision transformers and we also have three sizes CPVT-Ti, CPVT-S and CPVT-B. Similar to the original positional encodings in DeiT, the conditional positional encodings are also added to the input sequence, as shown in Figure 1 (b). In CPVT, the position where PEG is applied is also important to the performance, which will be studied in the experiments.
|
| 78 |
+
|
| 79 |
+
In addition, both DeiT and ViT utilize an extra learnable class token to perform classification (i.e., cls token shown in Figure 1 (a) and (b)). By design, the class token is not translation-invariant, although it can learn to be so. A simple alternative is to directly replace it with a global average pooling (GAP), which is inherently translation-invariant, resulting in our CVPT-GAP. Together with CPE, CVPT-GAP achieves much better image classification performance.
|
| 80 |
+
|
| 81 |
+
# 4 EXPERIMENTS
|
| 82 |
+
|
| 83 |
+
# 4.1 SETUP
|
| 84 |
+
|
| 85 |
+
Datasets. Following DeiT (Touvron et al., 2020), we use ILSVRC-2012 ImageNet dataset (Deng et al., 2009) with 1K classes and 1.3M images to train all our models. We report the results on the validation set with 50K images. Unlike ViT (Dosovitskiy et al., 2021), we do not use the much larger undisclosed JFT-300M dataset (Sun et al., 2017).
|
| 86 |
+
|
| 87 |
+
Model variants. We have three models with various sizes to adapt to various computing scenarios. The detailed settings are shown in Table 9 (see B.1). All experiments in this paper are performed on Tesla V100 machines. Training the tiny model for 300 epochs takes about 1.3 days on a single node with 8 V100 GPU cards. CPVT-S and CPVT-B take about 1.6 and 2.5 days, respectively.
|
| 88 |
+
|
| 89 |
+
Training details All the models (except for CPVT-B) are trained for 300 epochs with a global batch size of 2048 on Tesla V100 machines using AdamW optimizer (Loshchilov & Hutter, 2019). We do not tune the hyper-parameters and strictly comply with the settings in DeiT (Touvron et al., 2020). The learning rate is scaled with this formula $l r _ { \mathrm { s c a l e } } = 0 . 0 0 0 5 { \cdot } \mathrm { B a t c h S i z e } _ { \mathrm { g l o b a l } } / { \scriptstyle 5 1 2 }$ . The detailed hyperparameters are in the B.2.
|
| 90 |
+
|
| 91 |
+
# 4.2 GENERALIZATION TO HIGHER RESOLUTIONS
|
| 92 |
+
|
| 93 |
+
As mentioned before, our proposed PEG can directly generalize to larger image sizes without any fine-tuning. We confirm this here by evaluating the models trained with $2 2 4 \times 2 2 4$ images on the $3 8 4 \times 3 8 4$ , $4 4 8 \times 4 4 8$ , $5 1 2 \times 5 1 2$ images, respectively. The results are shown in Table 2. With the $3 8 4 \times 3 8 4$ input images, the DeiT-tiny with learnable positional encodings degrades from $7 2 . 2 \%$ to $7 1 . 2 \%$ . When equipped with sine encoding, the tiny model degrades from $7 2 . 2 \%$ to $7 0 . 8 \%$ . In constrat, our CPVT model with the proposed PEG can directly process the larger input images, and CPVT-Ti’s performance is boosted from $7 3 . 4 \%$ to $7 4 . 2 \%$ when applied to $3 8 4 \times 3 8 4$ images. Our CPVT-Ti outperforms DeiT-tiny by $3 . 0 \%$ . This gap continues to increase as the input resolution enlarges.
|
| 94 |
+
|
| 95 |
+
Table 2. Direct evaluation on other resolutions without fine-tuning. The models are trained on $2 2 4 \times 2 2 4$ . A simple PEG of a single layer of $3 \times 3$ depth-wise convolution is used here
|
| 96 |
+
|
| 97 |
+
<table><tr><td rowspan=1 colspan=1>Model</td><td rowspan=1 colspan=1>Params</td><td rowspan=1 colspan=1>160(%)</td><td rowspan=1 colspan=1>224(%)</td><td rowspan=1 colspan=1>384(%)</td><td rowspan=1 colspan=1>448(%)</td><td rowspan=1 colspan=1>512(%)</td></tr><tr><td rowspan=1 colspan=1>DeiT-tinyDeiT-tiny (sin)DeiT-tiny (no pos)CPVT-TiCPVT-Ti ‡</td><td rowspan=1 colspan=1>6M6M6M6M6M</td><td rowspan=1 colspan=1>65.665.262.166.8(+1.2)67.7 (+2.1)</td><td rowspan=1 colspan=1>72.272.368.272.4(+0.2)73.4(+1.2)</td><td rowspan=1 colspan=1>71.270.868.673.2(+2.0)74.2(+3.0)</td><td rowspan=1 colspan=1>68.868.268.471.8(+3.0)72.6(+3.8)</td><td rowspan=1 colspan=1>65.965.165.070.3(+4.4)70.8(+4.9)</td></tr><tr><td rowspan=1 colspan=1>DeiT-smallCPVT-S</td><td rowspan=1 colspan=1>22M22M</td><td rowspan=1 colspan=1>75.676.1(+0.5)</td><td rowspan=1 colspan=1>79.979.9</td><td rowspan=1 colspan=1>78.180.4(+1.5)</td><td rowspan=1 colspan=1>75.978.6(+2.7)</td><td rowspan=1 colspan=1>72.676.8(+4.2)</td></tr><tr><td rowspan=1 colspan=1>DeiT-baseCPVT-B</td><td rowspan=1 colspan=1>86M86M</td><td rowspan=1 colspan=1>79.180.5(+1.4)</td><td rowspan=1 colspan=1>81.881.9(+0.1)</td><td rowspan=1 colspan=1>79.782.3(+2.6)</td><td rowspan=1 colspan=1>79.882.4(+2.6)</td><td rowspan=1 colspan=1>78.281.0(+2.8)</td></tr></table>
|
| 98 |
+
|
| 99 |
+
‡: Insert one PEG each after the first encoder till the fifth encoder
|
| 100 |
+
|
| 101 |
+
# 4.3 CPVT WITH GLOBAL AVERAGE POOLING
|
| 102 |
+
|
| 103 |
+
By design, the proposed PEG is translation-equivariant (ignore paddings). Thus, if we further use the translation-invariant global average pooling (GAP) instead of the cls token before the final classification layer of CPVT. CPVT can be translation-invariant, which should be beneficial to the ImageNet classification task. Note the using GAP here results in even less computation complexity because we do not need to compute the attention interaction between the class token and the image patches. As shown in Table 3, using GAP here can boost CPVT by more than $1 \%$ . For example, equipping CPVT-Ti with GAP obtains $7 4 . 9 \%$ top-1 accuracy on the ImageNet validation dataset, which outperforms DeiT-tiny by a large margin $( + 2 . 7 \% )$ . Moreover, it even exceeds DeiT-tiny model with distillation $( 7 4 . 5 \% )$ . In contrast, DeiT with GAP cannot gain so much improvement (only $0 . 4 \%$ as shown in Table 3) because the original learnable absolute PE is not translation-equivariant and thus GAP with the PE is not translation-invariant. Given the superior performance, we hope our model can be a strong PE alternative in vision transformers.
|
| 104 |
+
|
| 105 |
+
Table 3. Performance comparison of Class Token (CLT) and global average pooling (GAP) on ImageNet. CPVT’s can be further boosted with GAP
|
| 106 |
+
|
| 107 |
+
<table><tr><td rowspan=1 colspan=1>Model</td><td rowspan=1 colspan=1>Head</td><td rowspan=1 colspan=1>Params</td><td rowspan=1 colspan=1>Top-1 Acc(%)</td><td rowspan=1 colspan=1>Top-5 Acc(%)</td></tr><tr><td rowspan=1 colspan=1>DeiT-tiny (Touvron et al., 2020)DeiT-tinyCPVT-Ti tCPVT-Ti t</td><td rowspan=1 colspan=1>CLTGAPCLTGAP</td><td rowspan=1 colspan=1>6M6M6M6M</td><td rowspan=1 colspan=1>72.272.673.474.9</td><td rowspan=1 colspan=1>91.091.291.892.6</td></tr><tr><td rowspan=3 colspan=1>DeiT-small (Touvron et al.,2020)DeiT-smallCPVT-S ‡CPVT-S t</td><td rowspan=1 colspan=1>CLTGAP</td><td rowspan=2 colspan=1>22M22M23M</td><td rowspan=2 colspan=1>79.980.280.5</td><td rowspan=3 colspan=1>95.095.295.295.7</td></tr><tr><td rowspan=1 colspan=1>CLT</td></tr><tr><td rowspan=1 colspan=1>GAP</td><td rowspan=1 colspan=1>23M</td><td rowspan=1 colspan=1>81.5</td></tr></table>
|
| 108 |
+
|
| 109 |
+
‡: Insert one PEG each after the first encoder till the fifth encoder
|
| 110 |
+
|
| 111 |
+
# 4.4 COMPLEXITY OF PEG
|
| 112 |
+
|
| 113 |
+
Few Parameters. Given the model dimension $d$ , the extra number of parameters introduced by PEG is $d \times l \times k ^ { 2 }$ if we choose $l$ depth-wise convolutions with kernel $k$ . If we use $l$ separable convolutions, this value becomes $l ( d ^ { 2 } + k ^ { 2 } d )$ . When $k = 3$ and $l = 1$ , CPVT-Ti $d = 1 9 2 ,$ ) brings about 1, 728 parameters. Note that DeiT-tiny utilizes learnable position encodings with $1 9 2 \times 1 4 \times 1 4 = 3 7 6 3 2$ parameters. Therefore, CPVT-Ti has 35, 904 fewer number of parameters than DeiT-tiny. Even using 4 layers of separable convolutions, CPVT-Ti introduces only $3 8 9 5 2 - 3 7 6 3 2 = 9 6 0$ more parameters, which is negelectable compared to the $5 . 7 \mathbf { M }$ model parameters of DeiT-tiny.
|
| 114 |
+
|
| 115 |
+
FLOPs. As for FLOPs, $l$ layers of $k \times k$ depth-wise convolutions possesses $1 4 \times 1 4 \times d \times l \times k ^ { 2 }$ FLOPS. Taking the tiny model for example, it involves $1 9 6 \times 1 9 2 \times 9 = 0 . 3 4 M$ FLOPS for the simple case $k = 3$ and $l = 1$ , which is neglectable because the model has 2.1G FLOPs in total.
|
| 116 |
+
|
| 117 |
+
# 4.5 PERFORMANCE COMPARISON
|
| 118 |
+
|
| 119 |
+
We evaluate the performance of CPVT models on the ImageNet validation dataset and report the results in Table 4. Compared with DeiT, CPVT models have much better top-1 accuracy with similar throughputs. Our models can enjoy performance improvement when inputs are upscaled without fine-tuning, while DeiT degrades as discussed in Table 2, see also Figure 3 for a clear comparison. Noticeably, Our model with GAP marked a new state-of-the-art for vision Transformers.
|
| 120 |
+
|
| 121 |
+

|
| 122 |
+
Figure 3. Comparison of CPVT and DeiT models under various configurations. Note CPVT $@ 3 8 4$ has improved performance. More PEGs can result in better performance. CPVT-GAP is the best.
|
| 123 |
+
|
| 124 |
+
Table 4. Comparison with ConvNets and Transformers on ImageNet and ImageNet Real (Beyer et al., 2020). CPVT have much better performance compared with prior Transformers
|
| 125 |
+
|
| 126 |
+
<table><tr><td rowspan=1 colspan=1>Models</td><td rowspan=1 colspan=2>Params(M) Input</td><td rowspan=1 colspan=1>Input</td><td rowspan=1 colspan=2>|throughput*</td><td rowspan=1 colspan=1>ImNettop-1 %</td><td rowspan=1 colspan=1>Realtop-1 %</td></tr><tr><td rowspan=7 colspan=1>ResNet-50 (He et al., 2016)ResNet-101 (He et al., 2016)ResNet-152 (He et al.,2016)RegNetY-4GF (Radosavovic et al.,2020)EfficientNet-BO (Tan &Le,2019)EfficientNet-B1 (Tan&Le,2019)EfficientNet-B2 (Tan &Le,2019)EfficientNet-B3(Tan&Le,2019)EfficientNet-B4 (Tan& Le,2019)</td><td rowspan=3 colspan=2>25456021</td><td rowspan=1 colspan=1>2242</td><td rowspan=1 colspan=2>1226.1</td><td rowspan=1 colspan=1>76.2</td><td rowspan=1 colspan=1>82.5</td></tr><tr><td rowspan=2 colspan=1>224222422242</td><td rowspan=2 colspan=2>753.6526.41156.7</td><td rowspan=1 colspan=1>753.6</td><td rowspan=1 colspan=1>77.4</td><td rowspan=1 colspan=1>83.7</td></tr><tr><td rowspan=1 colspan=1>78.380.0</td><td rowspan=1 colspan=1>84.186.4</td></tr><tr><td rowspan=4 colspan=2>5891219</td><td rowspan=1 colspan=1>5</td><td rowspan=1 colspan=1>2242</td><td rowspan=1 colspan=2>2694.3</td><td rowspan=1 colspan=1>77.1</td><td rowspan=1 colspan=1>83.5</td></tr><tr><td rowspan=1 colspan=1>240²</td><td rowspan=2 colspan=2>1662.51255.7732.1</td><td rowspan=1 colspan=1>79.1</td><td rowspan=1 colspan=1>84.9</td></tr><tr><td rowspan=1 colspan=1>260²3002</td><td rowspan=1 colspan=1>80.181.6</td><td rowspan=1 colspan=1>85.986.8</td></tr><tr><td rowspan=1 colspan=1>3802</td><td rowspan=1 colspan=2>349.4</td><td rowspan=1 colspan=1>82.9</td><td rowspan=1 colspan=1>88.0</td></tr><tr><td rowspan=2 colspan=1>ViT-B/16 (Dosovitskiy et al., 2021)ViT-L/16</td><td rowspan=2 colspan=2>86307</td><td rowspan=1 colspan=1>3842</td><td rowspan=2 colspan=2>85.927.3</td><td rowspan=2 colspan=1>77.976.5</td><td rowspan=2 colspan=1>11</td></tr><tr><td rowspan=1 colspan=1>3842</td></tr><tr><td rowspan=1 colspan=1>DeiT-tiny w/o PE (Touvron et al., 2020)DeiT-tiny (Touvron et al.,2020)DeiT-tiny (sine)CPVT-Ti tCPVT-Ti-GAP‡</td><td rowspan=1 colspan=2>66666</td><td rowspan=1 colspan=1>224222422242224²2242</td><td rowspan=1 colspan=2>2536.52536.52536.52500.72520.1</td><td rowspan=1 colspan=1>68.272.272.373.474.9</td><td rowspan=1 colspan=1>180.180.381.382.5</td></tr><tr><td rowspan=1 colspan=1>DeiT-tiny (Touvron et al., 2020)CPVT-Tim</td><td rowspan=1 colspan=2>66</td><td rowspan=1 colspan=1>22422242</td><td rowspan=1 colspan=2>2536.52500.7</td><td rowspan=1 colspan=1>74.575.9</td><td rowspan=1 colspan=1>82.183.0</td></tr><tr><td rowspan=2 colspan=1>DeiT-small (Touvron et al., 2020)CPVT-S $CPVT-S-GAP‡</td><td rowspan=2 colspan=2>222323</td><td rowspan=2 colspan=1>22422242224²</td><td rowspan=2 colspan=2>940.4930.5942.3</td><td rowspan=1 colspan=1>79.980.5</td><td rowspan=2 colspan=1>85.786.086.6</td></tr><tr><td rowspan=1 colspan=1>81.5</td></tr><tr><td rowspan=3 colspan=1>DeiT-base (Touvron et al.,2020)CPVT-B ‡CPVT-B-GAP‡</td><td rowspan=1 colspan=2>86</td><td rowspan=1 colspan=1>2242</td><td rowspan=1 colspan=2>292.3</td><td rowspan=1 colspan=1>81.8</td><td rowspan=1 colspan=1>86.7</td></tr><tr><td rowspan=2 colspan=2>8888</td><td rowspan=2 colspan=1>22422242</td><td rowspan=2 colspan=2>285.5290.2</td><td rowspan=1 colspan=1>82.3</td><td rowspan=2 colspan=1>87.087.7</td></tr><tr><td rowspan=1 colspan=1>82.7</td></tr></table>
|
| 127 |
+
|
| 128 |
+
?: Measured in img/s on a 16GB V100 GPU as in (Touvron et al., 2020). ‡: Insert one PEG each after the first encoder till the fifth encoder ⚗ : trained with hard distillation using RegNetY-160 as the teacher.
|
| 129 |
+
|
| 130 |
+
We further train CPVT-Ti and DeiT-tiny using the aforementioned training settings plus the hard distillation proposed in (Touvron et al., 2020). Specifically, we use RegNetY-160 (Radosavovic et al., 2020) as the teacher. CPVT obtains $7 5 . 9 \%$ , exceeding DeiT-tiny by $1 . 4 \%$ .
|
| 131 |
+
|
| 132 |
+
# 4.6 PEG ON PYRAMID TRANSFORMER ARCHITECTURES
|
| 133 |
+
|
| 134 |
+
PVT (Wang et al., 2021) is a vision transformer with the multi-stage design like ResNet (He et al., 2016). Swin (Liu et al., 2021) is a follow-up work and comes with higher performance. We apply our method on both to demonstrate its generalization ability.
|
| 135 |
+
|
| 136 |
+
ImageNet classification. Specifically, we remove its learnable PE and apply our PEG in position 0 of each stage with a GAP head. We use the same training settings to make a fair comparison and show the results in Table 13. Our method can significantly boost PVT-tiny by $3 . 1 \%$ and Swin-tiny by $1 . 1 5 \%$ on ImageNet (c.f. B.5). We also evaluate the performance of PEG on some downstream semantic segmentation and object detection tasks (see B.6). Note these tasks usually handle the various input resolutions as the training because multi-scale data augmentation is extensively used.
|
| 137 |
+
|
| 138 |
+
# 5 ABLATION STUDY
|
| 139 |
+
|
| 140 |
+
# 5.1 POSITIONAL ENCODING OR MERELY A HYBRID?
|
| 141 |
+
|
| 142 |
+
One might suspect that the PEG’s improvement comes from the extra learnable parameters introduced by the convolutional layers in PEG, instead of the local relationship retained by PEG. One way to test the function of PEG is only adding it when calculating Q and K in the attention layer, so that only the positional information of PEG is passed through. We can achieve $7 1 . 3 \%$ top-1 accuracy on ImageNet with DeiT-tiny. This is significantly better than DeiT-tiny w/o PE $( 6 8 . 2 \% )$ and is similar to the one with PEG on Q, K and V $( 7 2 . 4 \% )$ , which suggests that PEG mainly serves as a positional encoding scheme.
|
| 143 |
+
|
| 144 |
+
We also design another experiment to remove this concern. By randomly-initializing a $3 \times 3$ PEG and fixing its weights during the training, we can obtain $7 1 . 3 \%$ accuracy (Table 5), which is much higher $( 3 . 1 \% \uparrow )$ than DeiT without any PE $( 6 8 . 2 \% )$ . Since the weights of PEG are fixed and the performance improvement can only be due to the introduced position information. On the contrary, when we exhaustively use 12 convolutional layers (kernel size being 1, i.e., not producing local relationship) to replace the PEG, these layers have much more
|
| 145 |
+
|
| 146 |
+
Table 5. Positional encoding rather than added parameters gives the most improvement
|
| 147 |
+
|
| 148 |
+
<table><tr><td>Kernel</td><td>Style</td><td>Params (M)</td><td>Top-1 Acc (%)</td></tr><tr><td>none 3</td><td></td><td>5.68</td><td>68.2</td></tr><tr><td>3</td><td>fixed (random init)</td><td>5.68</td><td>71.3</td></tr><tr><td>1(12 ×)</td><td>fixed (learned init)</td><td>5.68</td><td>72.3</td></tr><tr><td></td><td>learnable</td><td>6.13</td><td>68.6</td></tr><tr><td>3</td><td>learnable</td><td>5.68</td><td>72.4</td></tr></table>
|
| 149 |
+
|
| 150 |
+
learnable parameters than PEG. However, it only boosts the performance by $0 . 4 \%$ to $6 8 . 6 \%$
|
| 151 |
+
|
| 152 |
+
Another interesting finding is that fixing a learned PEG also helps training. When we initialize with a learned PEG instead of the random values and train the tiny version of the model from scratch while keeping the PEG fixed, the model can also achieve $7 2 . 3 \%$ top-1 accuracy on ImageNet. This is very close to the learnable PEG $( 7 2 . 4 \% )$ .
|
| 153 |
+
|
| 154 |
+
# 5.2 PEG POSITION IN CPVT
|
| 155 |
+
|
| 156 |
+
We also experiment by varying the position of the PEG in the model. Table 6 (left) presents the ablations for variable positions (denoted as PosIdx) based on the tiny model. We consider the input of the first encoder by index -1. Therefore, position 0 is the output of the first encoder block. PEG shows strong performance $( \sim 7 2 . 4 \% )$ when it is placed at [0, 3].
|
| 157 |
+
|
| 158 |
+
Note that positioning the PEG at 0 can have much better performance than positioning it at -1 (i.e., before the first encoder), as shown in Table 6 (left). We observe that the difference between the two situations is they have different receptive fields. Specifically, the former has a global field while the latter can only see a local area. Hence, they are supposed to work similarly well if we enlarge the convolution’s kernel size. To verify our hypothesis, we use a quite large kernel size 27 with a padding size 13 at position -1, whose result is reported in Table 6 (right). It achieves similar performance to the one positioning the PEG at 0 $( 7 2 . 5 \% )$ , which verifies our assumption.
|
| 159 |
+
|
| 160 |
+
Table 6. Comparison of different plugin positions (left) and kernels (right) using DeiT-tiny
|
| 161 |
+
|
| 162 |
+
<table><tr><td>PosIdx</td><td>Top-1 (%)</td><td>Top-5 (%)</td></tr><tr><td>none -1</td><td>68.2</td><td>88.7</td></tr><tr><td rowspan="4">0 3</td><td>70.6</td><td>90.2</td></tr><tr><td>72.4</td><td>91.2</td></tr><tr><td>72.3</td><td>91.1</td></tr><tr><td>71.7</td><td>90.8</td></tr><tr><td>6 10</td><td>69.0</td><td>89.1</td></tr></table>
|
| 163 |
+
|
| 164 |
+
<table><tr><td>PosIdx</td><td>kernel</td><td>Params</td><td>Top-1 (%)</td><td>Top-5 (%)</td></tr><tr><td>-1</td><td>3×3</td><td>5.7M</td><td>70.6</td><td>90.2</td></tr><tr><td>-1</td><td>27×27</td><td>5.8M</td><td>72.5</td><td>91.3</td></tr></table>
|
| 165 |
+
|
| 166 |
+
# 5.3 COMPARISONS WITH OTHER POSITIONAL ENCODINGS
|
| 167 |
+
|
| 168 |
+
We compare PEG with other commonly used encodings: absolute positional encoding (e.g. sinusoidal (Vaswani et al., 2017)), relative positional encoding (RPE) (Shaw et al., 2018) and learnable encoding (LE) (Devlin et al., 2019; Radford et al., 2018), as shown in Table 7.
|
| 169 |
+
|
| 170 |
+
DeiT-tiny obtains $7 2 . 2 \%$ with the learnable absolute PE. We experiment with the 2-D sinusoidal encodings and it achieves on-par performance. For RPE, we follow (Shaw et al., 2018) and set the local range hyper-parameter $K$ as 8, with which we obtain $70 . 5 \%$ . RPE here does not encode any absolute position information, see discussion in D.1 and B.3.
|
| 171 |
+
|
| 172 |
+
Table 7. Comparison of various positional encoding strategies. LE: learnable positional encoding. RPE: relative positional encoding
|
| 173 |
+
|
| 174 |
+
<table><tr><td>Model</td><td>PEG Pos</td><td>Encoding</td><td>Top-1 (%)</td><td>Top-5 (%)</td></tr><tr><td>DeiT-tiny (2020)</td><td></td><td>LE</td><td>72.2 72.3</td><td>91.0 91.0</td></tr><tr><td>DeiT-tiny DeiT-tiny</td><td></td><td>2D sin-cos 2DRPE</td><td>70.5</td><td>90.0</td></tr><tr><td>CPVT-Ti</td><td>= 0-1</td><td>PEG</td><td>72.4</td><td>91.2</td></tr><tr><td>CPVT-Ti</td><td>0-1</td><td>PEG+LE</td><td>72.9</td><td>91.4</td></tr><tr><td>CPVT-Ti</td><td>0-1</td><td>4×PEG+LE</td><td>72.9</td><td></td></tr><tr><td></td><td>0-5</td><td></td><td></td><td>91.4</td></tr><tr><td>CPVT-Ti</td><td></td><td>PEG</td><td>73.4</td><td>91.8</td></tr></table>
|
| 175 |
+
|
| 176 |
+
Moreover, we combine the learnable absolute PE with a single-layer PEG. This boosts the baseline CPVT-Ti (0-1) by $0 . 5 \%$ . If we use 4-layer PEG, it can achieve $7 2 . 9 \%$ . If we add a PEG to each of the first five blocks, we can obtain $7 3 . 4 \%$ , which is better than stacking them within one block.
|
| 177 |
+
|
| 178 |
+
CPE is not a simple combination of APE and RPE. We further compare our method with a baseline with combination of APE and RPE. Specifically, we use learnable positional encoding (LE) as DeiT at the beginning of the model and supply 2D RPE for every transformer block. This setting achieves $7 2 . 4 \%$ top-1 accuracy on ImageNet, which is comparable to a single PEG $( 7 2 . 4 \% )$ . Nevertheless, this experiment does not necessarily indicate that our CPE is a simple combination of APE and RPE. When tested on different resolutions, this baseline cannot scale well compared to ours (Table 8). RPE is not able to adequately mitigate the performance degradation on top of LE. This shall be seen as a major difference.
|
| 179 |
+
|
| 180 |
+
Table 8. Direct evaluation on other resolutions without fine-tuning. The models are trained on $2 2 4 \times 2 2 4$ . CPE outperforms $\mathrm { L E + R P E }$ combination on untrained resolutions.
|
| 181 |
+
|
| 182 |
+
<table><tr><td rowspan=1 colspan=1>Model</td><td rowspan=1 colspan=1>PositionalParams</td><td rowspan=1 colspan=1>160(%)</td><td rowspan=1 colspan=1>224(%)</td><td rowspan=1 colspan=1>384(%)</td><td rowspan=1 colspan=1>448(%)</td><td rowspan=1 colspan=1>512(%)</td></tr><tr><td rowspan=1 colspan=1>DeiT-tiny (LE+RPE)DeiT-tiny (PEG at Pos 0)</td><td rowspan=1 colspan=1>400111920</td><td rowspan=1 colspan=1>65.666.8</td><td rowspan=1 colspan=1>72.472.4</td><td rowspan=1 colspan=1>70.873.2</td><td rowspan=1 colspan=1>68.471.8</td><td rowspan=1 colspan=1>65.670.3</td></tr></table>
|
| 183 |
+
|
| 184 |
+
PEG can continuously improve the performance if stacked more. We use LE not only at the beginning but also in the next 5 layers to have a similar thing as 0-5 PEG configuration.This setting achieves $7 2 . 7 \%$ top-1 accuracy on ImageNet, which is $0 . 7 \%$ lower than PEG (0-5). This setting suggests that it is also beneficial to have more of LEs, but not as good as ours. It is expected since we exploit relative information via PEGs at the same time.
|
| 185 |
+
|
| 186 |
+
# 6 CONCLUSION
|
| 187 |
+
|
| 188 |
+
We introduced CPVT, a novel method to provide the position information in vision transformers, which dynamically generates the position encodings based on the local neighbors of each input token. Through extensive experimental studies, we demonstrate that our proposed positional encodings can achieve stronger performance than the previous positional encodings. The transformer models with our positional encodings can naturally process longer input sequences and keep the desired translation equivalence in vision tasks. Moreover, our positional encodings are easy to implement and come with negligible cost. We look forward to a broader application of our method in transformer-driven vision tasks like segmentation and video processing.
|
| 189 |
+
|
| 190 |
+
# REFERENCES
|
| 191 |
+
|
| 192 |
+
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 largescale machine learning. In 12th {USENIX} symposium on operating systems design and implementation ({OSDI} 16), pp. 265–283, 2016.
|
| 193 |
+
|
| 194 |
+
Irwan Bello. Lambdanetworks: Modeling long-range interactions without attention. In International Conference on Learning Representations, 2021. URL https://openreview.net/forum? id=xTJEN-ggl1b.
|
| 195 |
+
|
| 196 |
+
Irwan Bello, Barret Zoph, Ashish Vaswani, Jonathon Shlens, and Quoc V Le. Attention augmented convolutional networks. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pp. 3286–3295, 2019.
|
| 197 |
+
|
| 198 |
+
Lucas Beyer, Olivier J Henaff, Alexander Kolesnikov, Xiaohua Zhai, and A ´ aron van den Oord. Are ¨ we done with imagenet? arXiv preprint arXiv:2006.07159, 2020.
|
| 199 |
+
|
| 200 |
+
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.
|
| 201 |
+
|
| 202 |
+
Nicolas Carion, Francisco Massa, Gabriel Synnaeve, Nicolas Usunier, Alexander Kirillov, and Sergey Zagoruyko. End-to-end object detection with transformers. In European Conference on Computer Vision, pp. 213–229. Springer, 2020.
|
| 203 |
+
|
| 204 |
+
Hanting Chen, Yunhe Wang, Tianyu Guo, Chang Xu, Yiping Deng, Zhenhua Liu, Siwei Ma, Chunjing Xu, Chao Xu, and Wen Gao. Pre-trained image processing transformer. arXiv preprint arXiv:2012.00364, 2020.
|
| 205 |
+
|
| 206 |
+
Tianqi Chen, Mu Li, Yutian Li, Min Lin, Naiyan Wang, Minjie Wang, Tianjun Xiao, Bing Xu, Chiyuan Zhang, and Zheng Zhang. Mxnet: A flexible and efficient machine learning library for heterogeneous distributed systems. arXiv preprint arXiv:1512.01274, 2015.
|
| 207 |
+
|
| 208 |
+
Xiangxiang Chu, Zhi Tian, Yuqing Wang, Bo Zhang, Haibing Ren, Xiaolin Wei, Huaxia Xia, and Chunhua Shen. Twins: Revisiting the design of spatial attention in vision transformers. In NeurIPS 2021, 2021.
|
| 209 |
+
|
| 210 |
+
Jean-Baptiste Cordonnier, Andreas Loukas, and Martin Jaggi. On the relationship between selfattention and convolutional layers. In International Conference on Learning Representations, 2020.
|
| 211 |
+
|
| 212 |
+
Ekin Dogus Cubuk, Barret Zoph, Jon Shlens, and Quoc Le. Randaugment: Practical automated data augmentation with a reduced search space. Advances in Neural Information Processing Systems, 33, 2020.
|
| 213 |
+
|
| 214 |
+
Zihang Dai, Hanxiao Liu, Quoc Le, and Mingxing Tan. Coatnet: Marrying convolution and attention for all data sizes. Advances in Neural Information Processing Systems, 34, 2021.
|
| 215 |
+
|
| 216 |
+
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.
|
| 217 |
+
|
| 218 |
+
Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. 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, 2019.
|
| 219 |
+
|
| 220 |
+
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. In International Conference on Learning Representations, 2021. URL https: //openreview.net/forum?id $=$ YicbFdNTTy.
|
| 221 |
+
|
| 222 |
+
Stephane d’Ascoli, Hugo Touvron, Matthew L Leavitt, Ari S Morcos, Giulio Biroli, and Levent ´ Sagun. Convit: Improving vision transformers with soft convolutional inductive biases. In International Conference on Machine Learning, pp. 2286–2296. PMLR, 2021.
|
| 223 |
+
|
| 224 |
+
Anmol Gulati, James Qin, Chung-Cheng Chiu, Niki Parmar, Yu Zhang, Jiahui Yu, Wei Han, Shibo Wang, Zhengdong Zhang, Yonghui Wu, et al. Conformer: Convolution-augmented transformer for speech recognition. arXiv preprint arXiv:2005.08100, 2020.
|
| 225 |
+
|
| 226 |
+
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.
|
| 227 |
+
|
| 228 |
+
Pengcheng He, Xiaodong Liu, Jianfeng Gao, and Weizhu Chen. Deberta: Decoding-enhanced bert with disentangled attention. arXiv preprint arXiv:2006.03654, 2020.
|
| 229 |
+
|
| 230 |
+
Elad Hoffer, Tal Ben-Nun, Itay Hubara, Niv Giladi, Torsten Hoefler, and Daniel Soudry. Augment your batch: Improving generalization through instance repetition. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 8129–8138, 2020.
|
| 231 |
+
|
| 232 |
+
Cheng-Zhi Anna Huang, Ashish Vaswani, Jakob Uszkoreit, Noam Shazeer, Ian Simon, Curtis Hawthorne, Andrew M Dai, Matthew D Hoffman, Monica Dinculescu, and Douglas Eck. Music transformer. In Advances in Neural Processing Systems, 2018.
|
| 233 |
+
|
| 234 |
+
Gao Huang, Yu Sun, Zhuang Liu, Daniel Sedra, and Kilian Q Weinberger. Deep networks with stochastic depth. In European conference on computer vision, pp. 646–661. Springer, 2016.
|
| 235 |
+
|
| 236 |
+
Md Amirul Islam, Sen Jia, and Neil DB Bruce. How much position information do convolutional neural networks encode? In International Conference on Learning Representations, 2020.
|
| 237 |
+
|
| 238 |
+
Alexander Kirillov, Ross Girshick, Kaiming He, and Piotr Dollar. Panoptic feature pyramid net- ´ works. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 6399–6408, 2019.
|
| 239 |
+
|
| 240 |
+
Tsung-Yi Lin, Priya Goyal, Ross Girshick, Kaiming He, and Piotr Dollar. Focal loss for dense´ object detection. In Proceedings of the IEEE international conference on computer vision, pp. 2980–2988, 2017.
|
| 241 |
+
|
| 242 |
+
Xuanqing Liu, Hsiang-Fu Yu, Inderjit Dhillon, and Cho-Jui Hsieh. Learning to encode position for transformer with continuous dynamical model. In International Conference on Machine Learning, pp. 6327–6335. PMLR, 2020.
|
| 243 |
+
|
| 244 |
+
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. arXiv preprint arXiv:2103.14030, 2021.
|
| 245 |
+
|
| 246 |
+
Ilya Loshchilov and Frank Hutter. Decoupled weight decay regularization. In International Conference on Learning Representations, 2019. URL https://openreview.net/forum?id $\underline { { \underline { { \mathbf { \Pi } } } } } =$ Bkg6RiCqY7.
|
| 247 |
+
|
| 248 |
+
Abdelrahman Mohamed, Dmytro Okhonko, and Luke Zettlemoyer. Transformers with convolutional context for asr. arXiv preprint arXiv:1904.11660, 2019.
|
| 249 |
+
|
| 250 |
+
Niki Parmar, Ashish Vaswani, Jakob Uszkoreit, Lukasz Kaiser, Noam Shazeer, Alexander Ku, and Dustin Tran. Image transformer. In Jennifer Dy and Andreas Krause (eds.), Proceedings of the 35th International Conference on Machine Learning, volume 80 of Proceedings of Machine Learning Research, pp. 4055–4064, Stockholmsmassan, Stockholm Sweden, 10–15 Jul 2018. ¨ PMLR.
|
| 251 |
+
|
| 252 |
+
Adam Paszke, Sam Gross, Francisco Massa, Adam Lerer, James Bradbury, Gregory Chanan, Trevor Killeen, Zeming Lin, Natalia Gimelshein, Luca Antiga, et al. Pytorch: An imperative style, high-performance deep learning library. Advances in Neural Information Processing Systems, 32: 8026–8037, 2019.
|
| 253 |
+
|
| 254 |
+
Alec Radford, Karthik Narasimhan, Tim Salimans, and Ilya Sutskever. Improving language understanding by generative pre-training. 2018.
|
| 255 |
+
|
| 256 |
+
Alec Radford, Jeffrey Wu, Rewon Child, David Luan, Dario Amodei, and Ilya Sutskever. Language models are unsupervised multitask learners. OpenAI blog, 1(8):9, 2019.
|
| 257 |
+
|
| 258 |
+
Ilija Radosavovic, Raj Prateek Kosaraju, Ross Girshick, Kaiming He, and Piotr Dollar. Designing ´ network design spaces. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 10428–10436, 2020.
|
| 259 |
+
|
| 260 |
+
Prajit Ramachandran, Niki Parmar, Ashish Vaswani, Irwan Bello, Anselm Levskaya, and Jon Shlens. Stand-alone self-attention in vision models. 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, pp. 68–80. Curran Associates, Inc., 2019. URL https://proceedings.neurips.cc/paper/2019/file/ 3416a75f4cea9109507cacd8e2f2aefc-Paper.pdf.
|
| 261 |
+
|
| 262 |
+
Peter Shaw, Jakob Uszkoreit, and Ashish Vaswani. Self-attention with relative position representations. In Proceedings of the 2018 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 2, pp. 464–468, 2018.
|
| 263 |
+
|
| 264 |
+
Nitish Srivastava, Geoffrey Hinton, Alex Krizhevsky, Ilya Sutskever, and Ruslan Salakhutdinov. Dropout: a simple way to prevent neural networks from overfitting. The journal of machine learning research, 15(1):1929–1958, 2014.
|
| 265 |
+
|
| 266 |
+
Jianlin Su, Yu Lu, Shengfeng Pan, Bo Wen, and Yunfeng Liu. Roformer: Enhanced transformer with rotary position embedding. arXiv preprint arXiv:2104.09864, 2021.
|
| 267 |
+
|
| 268 |
+
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.
|
| 269 |
+
|
| 270 |
+
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.
|
| 271 |
+
|
| 272 |
+
Mingxing Tan and Quoc Le. Efficientnet: Rethinking model scaling for convolutional neural networks. In International Conference on Machine Learning, pp. 6105–6114. PMLR, 2019.
|
| 273 |
+
|
| 274 |
+
Hugo Touvron, Matthieu Cord, Matthijs Douze, Francisco Massa, Alexandre Sablayrolles, and Herve J ´ egou. Training data-efficient image transformers & distillation through attention. ´ arXiv preprint arXiv:2012.12877, 2020.
|
| 275 |
+
|
| 276 |
+
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 the 31st International Conference on Neural Information Processing Systems, pp. 6000–6010, 2017.
|
| 277 |
+
|
| 278 |
+
Benyou Wang, Donghao Zhao, Christina Lioma, Qiuchi Li, Peng Zhang, and Jakob Grue Simonsen. Encoding word order in complex embeddings. arXiv preprint arXiv:1912.12333, 2019.
|
| 279 |
+
|
| 280 |
+
Wenhai Wang, Enze Xie, Xiang Li, Deng-Ping Fan, Kaitao Song, Ding Liang, Tong Lu, Ping Luo, and Ling Shao. Pyramid vision transformer: A versatile backbone for dense prediction without convolutions. arXiv preprint arXiv:2102.12122, 2021.
|
| 281 |
+
|
| 282 |
+
Yuqing Wang, Zhaoliang Xu, Xinlong Wang, Chunhua Shen, Baoshan Cheng, Hao Shen, and Huaxia Xia. End-to-end video instance segmentation with transformers. arXiv preprint arXiv:2011.14503, 2020.
|
| 283 |
+
|
| 284 |
+
Haiping Wu, Bin Xiao, Noel Codella, Mengchen Liu, Xiyang Dai, Lu Yuan, and Lei Zhang. Cvt: Introducing convolutions to vision transformers. arXiv preprint arXiv:2103.15808, 2021.
|
| 285 |
+
|
| 286 |
+
Baosong Yang, Longyue Wang, Derek Wong, Lidia S Chao, and Zhaopeng Tu. Convolutional selfattention networks. arXiv preprint arXiv:1904.03107, 2019a.
|
| 287 |
+
|
| 288 |
+
Zhilin Yang, Zihang Dai, Yiming Yang, Jaime Carbonell, Ruslan Salakhutdinov, and Quoc V Le. Xlnet: Generalized autoregressive pretraining for language understanding. arXiv preprint arXiv:1906.08237, 2019b.
|
| 289 |
+
|
| 290 |
+
Adams Wei Yu, David Dohan, Minh-Thang Luong, Rui Zhao, Kai Chen, Mohammad Norouzi, and Quoc V Le. Qanet: Combining local convolution with global self-attention for reading comprehension. arXiv preprint arXiv:1804.09541, 2018.
|
| 291 |
+
|
| 292 |
+
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 Proceedings of the IEEE/CVF International Conference on Computer Vision, pp. 6023–6032, 2019.
|
| 293 |
+
|
| 294 |
+
Hongyi Zhang, Moustapha Cisse, Yann N. Dauphin, and David Lopez-Paz. mixup: Beyond empirical risk minimization. In International Conference on Learning Representations, 2018. URL https://openreview.net/forum?id $\underline { { \underline { { \mathbf { \Pi } } } } } =$ r1Ddp1-Rb.
|
| 295 |
+
|
| 296 |
+
Sixiao Zheng, Jiachen Lu, Hengshuang Zhao, Xiatian Zhu, Zekun Luo, Yabiao Wang, Yanwei Fu, Jianfeng Feng, Tao Xiang, Philip HS Torr, et al. Rethinking semantic segmentation from a sequence-to-sequence perspective with transformers. arXiv preprint arXiv:2012.15840, 2020.
|
| 297 |
+
|
| 298 |
+
Zhun Zhong, Liang Zheng, Guoliang Kang, Shaozi Li, and Yi Yang. Random erasing data augmentation. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 34, pp. 13001–13008, 2020.
|
| 299 |
+
|
| 300 |
+
Bolei Zhou, Hang Zhao, Xavier Puig, Sanja Fidler, Adela Barriuso, and Antonio Torralba. Scene parsing through ade20k dataset. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 633–641, 2017.
|
| 301 |
+
|
| 302 |
+
Xizhou Zhu, Weijie Su, Lewei Lu, Bin Li, Xiaogang Wang, and Jifeng Dai. Deformable detr: Deformable transformers for end-to-end object detection. In International Conference on Learning Representations, 2021. URL https://openreview.net/forum?id ${ . } =$ gZ9hCDWe6ke.
|
| 303 |
+
|
| 304 |
+
# A TRANSLATION EQUIVARIANCE
|
| 305 |
+
|
| 306 |
+
The term translation-equivariance means the output feature maps can be equally translated with the input signal. Imagine there is a person in the left-top of an image, if the person is moved to the right-bottom, the output feature maps will change accordingly. This property is very important to the success of convolution network. Convolution (ignoring paddings), RPE, and self-attention are all translation-equivariant operations (regardless of their receptive field). It’s nontrivial to make absolute positional encodings like DeiT (using learnable positional encoding) translation-equivariant since different absolute positions will be added if the input signal is translated. Note that our method is not strictly translation-equivariant because of the zero padding. Instead, it provides a kind of stronger explicit bias towards the translation-equivariant property.
|
| 307 |
+
|
| 308 |
+
# B EXPERIMENT DETAILS
|
| 309 |
+
|
| 310 |
+
# B.1 ARCHITECTURE VARIANTS OF CPVT
|
| 311 |
+
|
| 312 |
+
Table 9. CPVT architecture variants. The larger model, CPVT-B, has the same architecture as ViTB (Dosovitskiy et al., 2021) and DeiT-B (Touvron et al., 2020). CPVT-S and CPVT-Ti have the same architecture as DeiT-small and DeiT-tiny respectively
|
| 313 |
+
|
| 314 |
+
<table><tr><td>Model</td><td>#channels</td><td>#heads</td><td>#layers</td><td>#params</td></tr><tr><td>CPVT-Ti</td><td>192</td><td>3</td><td>12</td><td>6M</td></tr><tr><td>CPVT-S</td><td>384</td><td>6</td><td>12</td><td>22M</td></tr><tr><td>CPVT-B</td><td>768</td><td>12</td><td>12</td><td>86M</td></tr></table>
|
| 315 |
+
|
| 316 |
+
# B.2 THE HYPERPARAMETERS OF CPVT
|
| 317 |
+
|
| 318 |
+
As for the ImageNet classification task, we use exactly the same hyperparameters as DeiT except for the base model because it is not always stably trained using AdamW. The detailed setting is shown in Table 10.
|
| 319 |
+
|
| 320 |
+
Table 10. Hyper-parameters for ViT, DeiT and CPVT
|
| 321 |
+
|
| 322 |
+
<table><tr><td>Methods</td><td>ViT</td><td>DeiT</td><td>CPVT</td></tr><tr><td>Epochs Batch size</td><td>300 4096</td><td>300 1024</td><td>300 1024</td></tr><tr><td>Optimizer</td><td>AdamW</td><td>AdamW</td><td>LAMB</td></tr><tr><td>Learning rate decay</td><td>cosine</td><td>cosine</td><td>cosine</td></tr><tr><td>Weight decay</td><td>0.3</td><td>0.05</td><td>0.05</td></tr><tr><td>Warmup epochs</td><td>3.4</td><td>5</td><td>5</td></tr><tr><td>Label smoothing ε (Szegedy et al., 2016)</td><td>X</td><td>0.1 X</td><td>0.1</td></tr><tr><td>Dropout (Srivastava et al.,2014)</td><td>0.1</td><td></td><td>X</td></tr><tr><td>Stoch.Depth (Huang et al., 2016)</td><td>X</td><td>0.1 √</td><td>0.1</td></tr><tr><td>Repeated Aug (Hoffer et al., 2020)</td><td>X</td><td>X</td><td>√</td></tr><tr><td>Gradient Clip.</td><td>√</td><td>9/0.5</td><td>X</td></tr><tr><td>Rand Augment (Cubuk et al., 2020)</td><td>X</td><td></td><td>9/0.5</td></tr><tr><td>Mixup prob. (Zhang et al.,2018)</td><td>X</td><td>0.8</td><td>0.8</td></tr><tr><td>Cutmix prob. (Yun et al., 2019)</td><td>X</td><td>1.0</td><td>1.0</td></tr><tr><td>Erasing prob. (Zhong et al.,2020)</td><td>X</td><td>0.25</td><td>0.25</td></tr></table>
|
| 323 |
+
|
| 324 |
+
# B.3 IMPORTANCE OF ZERO PADDINGS
|
| 325 |
+
|
| 326 |
+
We design an experiment to verify the importance of the zero paddings, which can help the model infer the absolute positional information. Specifically, we use CPVT-S and simply remove the zero paddings from CPVT while keeping all other settings unchanged. Table 11 shows that this can only obtain $7 0 . 5 \%$ , which indicates that the zero paddings and absolute positional information play important roles in classifying objects.
|
| 327 |
+
|
| 328 |
+
Table 11. Ablation study on ImageNet performance w/ or w/o zero paddings
|
| 329 |
+
|
| 330 |
+
<table><tr><td>Model</td><td>Padding</td><td>Top-1 Acc(%)</td><td>Top-5 Acc(%)</td></tr><tr><td rowspan="2">CPVT-Ti</td><td>√</td><td>72.4</td><td>91.2</td></tr><tr><td>X</td><td>70.5</td><td>89.8</td></tr></table>
|
| 331 |
+
|
| 332 |
+
# B.4 SINGLE PEG VS. MULTIPLE PEGS
|
| 333 |
+
|
| 334 |
+
We further evaluate whether or not using multi-position encodings can benefit the performance in Table 12. Notice we denote by $i \mathrm { - } j$ the inserted positions of PEG which start from the $i$ -th encoder and end at the $j - 1$ -th one (inclusion). By inserting PEGs to five positions, the top-1 accuracy of the tiny model can achieve $7 3 . 4 \%$ , which surpasses DeiT-tiny by $1 . 2 \%$ . Similarly, CPVT-S can achieve $8 0 . 5 \%$ . It turns out more PEGs do help, but up to a level where more PEGs become incremental (0-5 vs. 0-11).
|
| 335 |
+
|
| 336 |
+
Table 12. CPVT’s sensitivity to number of plugin positions
|
| 337 |
+
|
| 338 |
+
<table><tr><td>Positions</td><td>Model</td><td>Params (M)</td><td>Top-1 Acc (%)</td><td>Top-5 Acc (%)</td></tr><tr><td>0-1</td><td>tiny</td><td>5.7</td><td>72.4</td><td>91.2</td></tr><tr><td>0-5</td><td>tiny</td><td>5.9</td><td>73.4</td><td>91.8</td></tr><tr><td>0-11</td><td>tiny</td><td>6.1</td><td>73.4</td><td>91.8</td></tr><tr><td>0-1 0-5</td><td>small small</td><td>22.0 22.9</td><td>79.9 80.5</td><td>95.0 95.2</td></tr></table>
|
| 339 |
+
|
| 340 |
+
# B.5 CLASSFICATION EVALUATION OF SWIN WITH PEG
|
| 341 |
+
|
| 342 |
+
We show the validation curves when training Swin (Liu et al., 2021) equipped with PEG in Figure 4.
|
| 343 |
+
It can boost Swin-tiny from $8 1 . 1 0 \%$ to $8 2 . 2 5 \%$ $( + 1 . 1 5 \% \uparrow )$ on ImageNet.
|
| 344 |
+
|
| 345 |
+

|
| 346 |
+
Figure 4. CPE boosts Swin Tiny on ImageNet by $1 . 1 5 \%$ top-1 Acc.
|
| 347 |
+
|
| 348 |
+
# B.6 EVALUATION ON SEGMENTATION AND DETECTION
|
| 349 |
+
|
| 350 |
+
Semantic segmentation on ADE20K. We evaluate the performance of PEG on the ADE20K (Zhou et al., 2017) segmentation task. Based on the Semantic FPN framework (Kirillov et al., 2019), PVT achieves much better results than ResNet (He et al., 2016) baselines. Under carefully controlled settings, PEG further boosts PVT-tiny by $3 . 1 \%$ mIoU.
|
| 351 |
+
|
| 352 |
+
Object detection on COCO. We also perform controlled experiments with the RetinaNet (Lin et al., 2017) framework on the COCO detection task. The results are shown in Table 13. In the standard $1 \times$ schedule, PEG improves PVT-tiny by $2 . 0 \%$ mAP. PEG brings $2 . 4 \%$ higher mAP under the $3 \times$ schedule.
|
| 353 |
+
|
| 354 |
+
Table 13. Our method boosts the performance of PVT on ImageNet classification, ADE20K segmentation and COCO detection
|
| 355 |
+
|
| 356 |
+
<table><tr><td rowspan="2">Backbone</td><td colspan="2">ImageNet</td><td colspan="2">Semantic FPN on ADE20K</td><td colspan="3">RetinaNet on COCO</td></tr><tr><td>Params (M)</td><td>Top-1 (%)</td><td>Params (M)</td><td>mIoU (%)</td><td>Params (M)</td><td>mAP (%,1x)</td><td>mAP (%,3×,+MS)</td></tr><tr><td>ResNet-18 (He et al.,2016)</td><td>12</td><td>69.8</td><td>16</td><td>32.9</td><td>21</td><td>31.8</td><td>35.4</td></tr><tr><td>PVT-tiny (Wang et al., 2021)</td><td>13</td><td>75.0</td><td>17</td><td>35.7</td><td>23</td><td>36.7</td><td>39.4</td></tr><tr><td>PVT-tiny+PEG</td><td>13</td><td>77.3</td><td>17</td><td>38.0</td><td>23</td><td>38.0</td><td>41.8</td></tr><tr><td>PVT-tiny+GAP</td><td>13</td><td>75.9</td><td>17</td><td>36.0</td><td>23</td><td>36.9</td><td>39.7</td></tr><tr><td>PVT-tiny+PEG+GAP</td><td>13</td><td>78.1</td><td>17</td><td>38.8</td><td>23</td><td>38.7</td><td>41.8</td></tr><tr><td>PVT-small (Wang et al., 2021)</td><td>25</td><td>79.8</td><td>28</td><td>39.8</td><td>34</td><td>40.4</td><td>42.2</td></tr><tr><td>PVT-small+PEG+GAP</td><td>25</td><td>81.2</td><td>28</td><td>44.3</td><td>34</td><td>43.0</td><td>45.2</td></tr><tr><td>PVT-Medium (Wang et al.,2021)</td><td>44</td><td>81.2</td><td>48</td><td>41.6</td><td>54</td><td>41.9</td><td>43.2</td></tr><tr><td>PVT-Medium+PEG+GAP</td><td>44</td><td>82.7</td><td>48</td><td>44.9</td><td>54</td><td>44.3</td><td>46.4</td></tr></table>
|
| 357 |
+
|
| 358 |
+
# B.7 ABLATION ON OTHER FORMS OF PEG
|
| 359 |
+
|
| 360 |
+
We explore several forms of PEG based on the tiny model, which change the type of convolution, kernel size and layers. The inserted position is 0. The result is shown in Table 14. When we use large kernel of $7 \times 7$ or dense convolution, the performance improvement is limited. Stacking more layers of depth-wise convolution doesn’t bring significant improvement. Therefore, we use the simplest form as our default implementation. It indicates that this design is enough to provide good position information.
|
| 361 |
+
|
| 362 |
+
Table 14. Other forms of PEG. The simple form of a single depth-wise $3 \times 3$ is good enough.
|
| 363 |
+
|
| 364 |
+
<table><tr><td>Variants</td><td>Model</td><td>Top-1 Acc (%)</td></tr><tr><td>1 Depthwise Conv 3×3</td><td>tiny</td><td>72.4</td></tr><tr><td>1 Depthwise Conv 7×7</td><td>tiny</td><td>72.5</td></tr><tr><td>4 *(Depthwise Conv 3×3+BN+ReLU)</td><td>tiny</td><td>72.4</td></tr><tr><td>1 Dense Conv 3×3</td><td>tiny</td><td>72.3</td></tr><tr><td>4 * (Dense Conv 3×3+BN+ReLU)</td><td>tiny</td><td>72.5</td></tr></table>
|
| 365 |
+
|
| 366 |
+
# C EXAMPLE CODE
|
| 367 |
+
|
| 368 |
+
# C.1 PEG
|
| 369 |
+
|
| 370 |
+
In the simplest form, we use a single depth-wise convolution and show its usage in Transformer by the following PyTorch snippet. Through experiments, we find that such a simple design (i.e., depthwise $3 \times 3$ ) readily achieves on par or even better performance than the recent SOTAs. We give the torch implementation example in Alg. 1.
|
| 371 |
+
|
| 372 |
+
# D MORE DISCUSSIONS
|
| 373 |
+
|
| 374 |
+
# D.1 WHY RPE WORKS LESS WELL THAN ABSOLUTE PE?
|
| 375 |
+
|
| 376 |
+
As mentioned in Section 5.3 (main text), RPE is inferior to the absolute positional encoding. It is because RPE does not encode any absolute position information. Also discussed in Section B.3 (main text), absolute position information is also important even for ImageNet classification as it is needed to determine which object is at the center of the image. Note that there might be multiple objects in an image, and the label of an image is the category of the object at the center.
|
| 377 |
+
|
| 378 |
+
Additionally, although RPE becomes popular recently, it is often jointly used with absolute positional encodings (e.g., in ConViT (d’Ascoli et al., 2021)), or the absolute position information is leaked in other ways (e.g., convolution paddings in CoAtNet (Dai et al., 2021)). This further suggests absolute position information is crucial.
|
| 379 |
+
|
| 380 |
+
# Algorithm 1 PyTorch snippet of PEG.
|
| 381 |
+
|
| 382 |
+
import torch
|
| 383 |
+
import torch.nn as nn
|
| 384 |
+
class VisionTransformer: def __init__(layer $_ { \mathrm { S } } = 1 2$ , ${ \mathrm { d i m } } { = } 1 9 2$ , nhead $^ { \underline { { { \textstyle \dag } } } } = 3$ , img_size $_ { : = 2 2 4 }$ , patch_size=16): self.pos_block $=$ PEG(dim) self.blocks $=$ nn.ModuleList([TransformerEncoderLayer(dim, nhead, dim $\mathbf { \nabla } _ { \cdot } \star \mathbf { \nabla } _ { \cdot }$ 4) for _ in range( layers)]) self.patch_embed $=$ PatchEmbed(img_size, patch_size, dim\*4) def forward_features(self, $\mathbf { x } )$ ): B, C, H, $W ~ = ~ \mathrm { ~ x ~ }$ .shape x, patch_size $=$ self.patch_embed(x) _H, $\_ \mathrm { ~ \tt ~ H ~ } = \mathrm { ~ \tt ~ H ~ }$ // patch_size, W // patch_size $\qquad \times \quad =$ torch.cat((self.cls_tokens, x), dim $^ { = 1 }$ ) for i, blk in enumerate(self.blocks): x = blk $( \times )$ if i $\quad . = = 0$ : $\times \quad =$ self.pos_block(x, _H, _W) return x[:, 0]
|
| 385 |
+
class PEG(nn.Module): def _init__(self, dim $^ { 1 = 2 }$ \textsc{56}, $\mathrm { k } = 3$ ): self.pos $=$ nn.Conv2d(dim, dim, k, 1, k//2, groups $=$ dim) # Only for demo use, more complicated functions are effective too. def forward(self, x, H, W): B, N, ${ \mathrm { ~ \small ~ \mathscr ~ { ~ C ~ } ~ } } = { \mathrm { ~ \small ~ x ~ } }$ .shape cls_token, feat_tokens $=$ x[:, 0], x[:, 1:] feat_tokens $=$ feat_tokens.transpose(1, 2).view(B, C, H, W) $\qquad \times \quad =$ self.pos(feat_tokens) $^ +$ feat_tokens $\qquad \times \quad =$ x.flatten(2).transpose(1, 2) $\qquad \times \quad =$ torch.cat((cls_token.unsqueeze(1), x), dim=1) return x
|
| 386 |
+
|
| 387 |
+
# D.2 COMPARISON TO LAMBDA NETWORKS
|
| 388 |
+
|
| 389 |
+
Our work is also related to Lambda Networks (Bello, 2021) which uses 2D relative positional encodings. We evaluate its lambda module with an embedding size of 128, where we denote its encoding scheme as RPE2D-d128. Noticeably, this configuration has about 5.9M parameters (comparable to DeiT-tiny) but only obtains $6 8 . 7 \%$ . We attribute its failure to the limited ability in capturing the correct positional information. After all, lambda layers are designed with the help of many CNN backbones components such as down-sampling to form various stages, to replace ordinary convolutions in ResNet (He et al., 2016). In contrast, CPVT is transformer-based.
|
| 390 |
+
|
| 391 |
+
# D.3 QUALITATIVE ANALYSIS OF CPVT
|
| 392 |
+
|
| 393 |
+
Thus far, we have shown that PEG can have better performance than the original positional encodings. However, because PEG provides the position in an implicit way, it is interesting to see if PEG can indeed provide the position information as the original positional encodings. Here we investigate this by visualizing the attention weights of the transformers. Specifically, given a $2 2 4 \times 2 2 4$ image (i.e. $1 4 \times 1 4$ patches), the score matrix within a single head is $1 9 6 \times 1 9 6$ . We visualize the normalized self-attention score matrix of the second encoder block.
|
| 394 |
+
|
| 395 |
+
We first visualize the attention weights of DeiT with the original positional encodings. As shown in Figure 5 (middle), the diagonal element interacts strongly with its local neighbors but weakly with those far-away elements, which suggests that DeiT with the original positional encodings learn to attend the local neighbors of each patch. After the positional encodings are removed (denoted by DeiT w/o PE), all the patches produce similar attention weights and fail to attend to the patches near themselves, see Figure 5 (left).
|
| 396 |
+
|
| 397 |
+
Finally, we show the attention weights of our CPVT model with PEG. As shown in Figure 5 (right), like the original positional encodings, the model with PEG can also learn a similar attention pattern, which indicates that the proposed PEG can provide the position information as well.
|
| 398 |
+
|
| 399 |
+
We illustrate the attention scores in several encoder blocks of DeiT (Touvron et al., 2020) and CPVT in the Fig. 6. It shows both methods learn similar locality patterns. As attention scores are computed over the tokens projected in different subspaces (Q and K), they do not necessarily show a strict diagonal pattern, where some may have slight shift, see DeiT in Fig. 6c and CPVT of Fig. 5 right.
|
| 400 |
+
|
| 401 |
+

|
| 402 |
+
Figure 5. Normalized attention scores (first head) of the second encoder block of DeiT without position encoding (DeiT w/o PE), DeiT (Touvron et al., 2020), and CPVT on the same input sequence. Position encodings are key to developing a schema of locality in lower layers of DeiT. Meantime, CPVT profits from conditional encodings and follows a similar locality pattern.
|
| 403 |
+
|
| 404 |
+

|
| 405 |
+
Figure 6. Normalized attention scores (the second and third head) of the second and third encoder block of DeiT (Touvron et al., 2020), and CPVT on the same input sequence. DeiT and CPVT share similar locality patterns that are aligned diagonally (some might shift).
|
| 406 |
+
|
| 407 |
+
# D.4 COMPARISON WITH OTHER APPROACHES
|
| 408 |
+
|
| 409 |
+
We further compare our method with other approaches such as CvT (Wu et al., 2021), ConViT (d’Ascoli et al., 2021) and CoAtNet (Dai et al., 2021) on ImageNet validation set in Table 15. To make fair comparisons, we categorize these methods into two groups: plain and pyramid models. Since our models are primarily for plain models, we adapt our methods on two popular pyramid frameworks PVT and Swin. Our CPVT-S-GAP slightly outperforms ConViT-S by $0 . 2 \%$ with 4M fewer parameters and 0.8G fewer FLOPs. When equipped with pyramid designs, our methods are still comparable to CvT and CoAtNet.
|
| 410 |
+
|
| 411 |
+
Comparison with DeiT w/ Convolutional Projection. Note CvT uses a depth-wise convolution in $\scriptstyle q - k - v$ projection which they call it Convolutional Projection. Instead of using it in all layers, we put only one of such design into DeiT-tiny and train such a model from scratch under strictly controlled settings. We insert it in the position 0 as in our method. The result is shown in Table 16. This CvT-flavored DeiT achieves $7 0 . 6 \%$ top-1 accuracy on ImageNet validation set, which is lower than ours $( 7 2 . 4 \% )$ . Note that $q$ -k-v projections in CvT utilize three depthwise convolutions, therefore, this setting has more parameters than ours. This attests the difference of CvT and CPVT, verifying our advantage by learning better position encodings other than inserting them in all layers to have the ability to capture local context and to remove ambiguity in attention.
|
| 412 |
+
|
| 413 |
+
Table 15. Performance comparison with other approaches such as CvT (Wu et al., 2021), ConViT (d’Ascoli et al., 2021) and CoAtNet (Dai et al., 2021) on ImageNet validation set. All the models are trained on ImageNet-1k dataset and tested on the validation set using $2 2 4 \times 2 2 4$ resolution.
|
| 414 |
+
|
| 415 |
+
<table><tr><td rowspan=1 colspan=1>Model</td><td rowspan=1 colspan=1>Type</td><td rowspan=1 colspan=1>Params</td><td rowspan=1 colspan=1>FLOPs</td><td rowspan=1 colspan=1>Top-1 Acc(%)</td></tr><tr><td rowspan=1 colspan=1>DeiT-small (Touvron et al., 2020)ConViT-S (d'Ascoli et al.,2021)CPVT-S-GAP (ours)</td><td rowspan=1 colspan=1>PlainPlainPlain</td><td rowspan=1 colspan=1>22M27M23M</td><td rowspan=1 colspan=1>4.6G5.4G4.6G</td><td rowspan=1 colspan=1>79.981.381.5</td></tr><tr><td rowspan=2 colspan=1>CoAtNet-0 (Dai et al., 2021)CvT-13 (Wu et al., 2021)PVT-small (Wang et al., 2021)PVT-small+PEG+GAPSwin-tiny (Liu et al.,2021)Swin-tiny+PEG+GAP</td><td rowspan=2 colspan=1>PyramidPyramidPyramidPyramidPyramidPyramid</td><td rowspan=1 colspan=1>25M20M25M25M29M</td><td rowspan=1 colspan=1>4.2G4.5G3.8G3.8G4.5G</td><td rowspan=2 colspan=1>81.681.679.881.281.382.3</td></tr><tr><td rowspan=1 colspan=1>29M</td><td rowspan=1 colspan=1>4.5G</td></tr></table>
|
| 416 |
+
|
| 417 |
+
Table 16. Comparison with positional encoding in CvT (Wu et al., 2021) on ImageNet validation set. All the models are trained on ImageNet-1k dataset and tested on the validation set using $2 2 4 \times 2 2 4$ resolution.
|
| 418 |
+
|
| 419 |
+
<table><tr><td>Model</td><td>Params</td><td>Insert Position</td><td>Top-1 Acc (%)</td></tr><tr><td>CPVT-Ti DeiT+ Convolutional Projection</td><td>5681320 5685352</td><td>0 0</td><td>72.4 70.6</td></tr></table>
|
md/dev/3ly9cG9Ql9h/3ly9cG9Ql9h.md
ADDED
|
@@ -0,0 +1,899 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# WHAT DOES A PLATYPUS LOOK LIKE? GENERATING CUSTOMIZED PROMPTS FOR ZERO-SHOT IMAGE CLASSIFICATION
|
| 2 |
+
|
| 3 |
+
Anonymous authors Paper under double-blind review
|
| 4 |
+
|
| 5 |
+
# ABSTRACT
|
| 6 |
+
|
| 7 |
+
Open vocabulary models are a promising new paradigm for image classification. Unlike traditional classification models, open vocabulary models classify among any arbitrary set of categories specified with natural language during inference. This natural language, called “prompts”, typically consists of a set of hand-written templates (e.g., “a photo of a $\{ \} ^ { \ast } )$ which are completed with each of the category names. This work introduces a simple method to generate higher accuracy prompts, without relying on any explicit knowledge of the task domain and with far fewer hand-constructed sentences. To achieve this, we combine open vocabulary models with large language models (LLMs) to create Customized Prompts via Language models $\mathrm { C u P L }$ , pronounced “couple”). In particular, we leverage the knowledge contained in LLMs in order to generate many descriptive sentences that are customized for each object category. We find that this straightforward and general approach improves accuracy on a range of zero-shot image classification benchmarks, including over one percentage point gain on ImageNet. Finally, this simple baseline requires no additional training and remains completely zero-shot.
|
| 8 |
+
|
| 9 |
+

|
| 10 |
+
Figure 1: Schematic of the method. (Left) The standard method of a zero-shot open vocabulary image classification model (e.g., CLIP (Radford et al., 2021)). (Right) Our method of CuPL. First, an LLM generates descriptive captions for given class categories. Next, an open vocabulary model uses these captions as prompts for performing classification.
|
| 11 |
+
|
| 12 |
+
# 1 INTRODUCTION
|
| 13 |
+
|
| 14 |
+
Open vocabulary models (Pham et al., 2021; Jia et al., 2021; Radford et al., 2021; Yu et al., 2022a) achieve high classification accuracy across a large number of datasets without labeled training data for those tasks. To accomplish this, these models leverage the massive amounts of image-text pairs available on the internet by learning to associate the images with their correct caption, leading to greater flexibility during inference. Unlike standard models, these models classify images by providing a similarity score between an image and a caption. To perform inference, one can generate a caption or “prompt” associated with each of the desired categories, and match each image to the best prompt. This means that categories can be selected ad hoc and adjusted without additional training.
|
| 15 |
+
|
| 16 |
+
However, this new paradigm poses a challenge:
|
| 17 |
+
|
| 18 |
+
How can we best represent an image category through natural language prompts?
|
| 19 |
+
|
| 20 |
+
The standard approach is to hand write a number of prompts templates (Radford et al., 2021) (e.g.,“a photo of a $\{ \} ^ { \ast } )$ , compile a natural language label for each category in the dataset, and create a set of prompts for each category by filling in each of these templates with the natural language labels. Then, image embeddings are matched to the nearest set of prompt embeddings and labelled with the category associated with that set of prompts (more details in Section 2).
|
| 21 |
+
|
| 22 |
+
This method has three major drawbacks. Firstly, each prompt template has to be hand-written, so having twice as many prompts for a category requires twice as much human effort. This can become costly as each new dataset typically has a different set of prompt templates (Radford et al., 2021). Secondly, the prompt templates must be general enough to apply to all image categories. For example, a prompt for the ImageNet (Deng et al., 2009) category “platypus” could only be as specific as “a photo of a $\{ \mathrm { p l a t y p u s } \} ^ { \cdot }$ , and could not be something like “a photo of a $\{ { \mathrm { p l a t y p u s } } \}$ , a type of aquatic mammal” as that template would no longer be relevant for other image categories. Lastly, writing high performing prompt templates currently requires prior information about the contents of the dataset. For example, the list of hand-written ImageNet prompts (Radford et al., 2021) includes “a black and white photo of the $\{ \}$ .”, “a low resolution photo of a $\{ \}$ .”, and “a toy $\{ \}$ .” all of which demonstrate prior knowledge about the type of representations present in the dataset. This information is not generalizable to other datasets, as ImageNet contains “black and white” and “toy” representations of its categories, but other datasets do not (e.g., FVGC Aircraft (Maji et al., 2013)).
|
| 23 |
+
|
| 24 |
+
To overcome these challenges, we propose Customized Prompts via Language models $\mathrm { ( C u P L ) }$ . In this algorithm, we couple a large language model (LLM) with a zero-shot open vocabulary image classification model. We use the LLM to generate prompts for each of the image categories in a dataset. Using an LLM allows us to generate an arbitrary number of prompts with a fixed number of hand-written sentences. Additionally, these prompts are now customized to each category and can contain rich visual descriptions while still remaining zero-shot (e.g., “A platypus looks like a beaver with a duck’s bill” – a sentence generated by an LLM).
|
| 25 |
+
|
| 26 |
+
We find these customized prompts outperform the hand-written templates on 15 zero-shot image classification benchmarks, including a greater than 1 percentage point gain on ImageNet (Deng et al., 2009) Top-1 accuracy and a greater than 6 percentage point gain on Describable Textures Dataset (Cimpoi et al., 2014), with fewer hand-written prompts when compared to the standard method used in Radford et al. (2021). Finally, this method requires no additional training or labeled data for either model.
|
| 27 |
+
|
| 28 |
+
# 2 METHODS
|
| 29 |
+
|
| 30 |
+
The CuPL algorithm consists of two steps: (1) generating customized prompts for each of the categories in a given dataset and (2) using these prompts to perform zero-shot image classification.
|
| 31 |
+
|
| 32 |
+
# 2.1 GENERATING CUSTOMIZED PROMPTS
|
| 33 |
+
|
| 34 |
+
This step consists of generating prompts using an LLM. For clarity, we distinguish between two different kind of prompts. The first are the prompts which cue the LLM to generate the descriptions of the dataset categories. These prompts do not describe an object, but rather prompt the description of an object (e.g., “What does a platypus look like?”). We will refer to these as “LLM-prompts”.
|
| 35 |
+
|
| 36 |
+
Secondly, there are the prompts to be matched with images in the zero-shot image classification model. These are the prompts that describe a category (e.g., “A platypus looks like ...”). We call them “image-prompts.” These are the output of the LLM, as examplified in Figure 2.
|
| 37 |
+
|
| 38 |
+
In this work, we use GPT-3 (Brown et al., 2020) as our LLM. To generate our image-prompts, we must first construct a number of LLM-prompt templates. While this does require some engineering by hand, it is significantly less than the amount of hand-engineered sentences used in the standard method of creating image-prompt templates for CLIP. For example, in our ImageNet experiments, we construct 5 LLM-prompt templates compared to the 80 image-prompts used by CLIP for zeroshot ImageNet classification.
|
| 39 |
+
|
| 40 |
+

|
| 41 |
+
Figure 2: Example CuPL LLM-prompts and Image-prompts. LLM-prompts are filled in with a class name and then used as input to GPT-3, which then outputs image-prompts. Example LLM generated image-prompts and associated images from ImageNet are shown. Only image-prompts are used for the downstream image classification.
|
| 42 |
+
|
| 43 |
+
After constructing these LLM-prompts, we generate 10 different image-prompts for each of the LLM-prompts. This means for ImageNet we use an LLM to generate a total of 50 customized image-prompts for each image category. For each of these, we generate a maximum of 50 tokens, but halt a generation early if it produces a period. Additionally, we generate with a high temperature of 0.99, which encourages more diversity among the 10 generated image-prompts. We also clean each generated sentences by deleting any blank lines and adding a period at the end.
|
| 44 |
+
|
| 45 |
+
# 2.2 UTILIZING CUSTOMIZED PROMPTS
|
| 46 |
+
|
| 47 |
+
After generating image-prompts for each of the categories, we then perform zero-shot image classification. While there are a number of open vocabulary models (Pham et al., 2021; Jia et al., 2021; Radford et al., 2021; Yu et al., 2022a), we report our results using CLIP (Radford et al., 2021) as this is the most popular publicly available open vocabulary model.
|
| 48 |
+
|
| 49 |
+
CLIP consists of a text encoder and and image encoder (schematic on the left side of Figure 1). In the standard setting, there are a number of hand-written templates which can be completed with the relevant category names (e.g. “A photo of a $\{ \} ^ { \ast }$ , “A photo of many $\{ \} ^ { \ast } )$ . To classify the images in a dataset, each of these templates is filled in with a given category name. Then each of these sentences is embedded via the text encoder, and all sentences completed with the same category name are averaged and normalized. This results in $n$ embeddings where $n$ is the number of categories in the dataset. Each of these $n$ embeddings is the mean of many different sentence embeddings. Then each image in the dataset is embedded using the image encoder. This embedding is compared to each of the $n$ text embeddings using cosine similarity and is labeled with the most similar one.
|
| 50 |
+
|
| 51 |
+
CuPL requires only a small adjustment from this standard practice. Instead of filling in the handwritten templates for each category, we simply replace these altogether with the sentences output by GPT-3. This means for CuPL, hand-written templates are only used as input for the LLM, while the prompts for CLIP are entirely generated text. We present 2 different setting of CuPL (as shown in Table 1), each representing a different trade-off between accuracy and hand-engineering.
|
| 52 |
+
|
| 53 |
+
1. CuPL (base). This setting uses three hand-written sentence across all 15 examined datasets. We do this by constructing general LLM-prompt templates which are filled in with the category names for each dataset. Our three general templates are as follows:
|
| 54 |
+
|
| 55 |
+
Describe what a/the looks like: Describe a/the : What are the identifying characteristics of a/the ?
|
| 56 |
+
|
| 57 |
+
The blank portion of this template is either filled in with the category type plus the category name (e.g. “pet” $+ \left\{ \right\}$ for the Oxford Pets dataset (Parkhi et al., 2012) or “aircraft” $+ \left\{ \right\}$ for FGVC Aircraft (Maji et al., 2013)) or just the category name for more general datasets like ImageNet (Deng et al., 2009). Type specification is necessary because of words that have multiple meanings. For example “boxer” from the Oxford Pets dataset can also mean a person who boxes, as opposed to a dog breed, so it is necessary to specify “Describe a pet boxer:”. Similarly, “Tornado” from the FGVC Aircraft dataset can be a type of aircraft or a type of weather.
|
| 58 |
+
|
| 59 |
+
2. CuPL (full). In this setting we use different LLM-prompt templates for each dataset, just as Radford et al. (2021) uses different image-prompt templates for each dataset. However, we use fewer hand-written templates overall and also contain less specific information about each dataset in the templates. For this work, each dataset has between 2 and 9 LLM-prompts which generate between 20 and 90 image-prompt per category (10 generated sentences per LLM-prompt). For ImageNet, we use the following 5 LLM-prompts: (1) “Describe what a(n) $\bar { \{ \} }$ looks like”, (2) “How can you identify a(n) $\{ \} ? ^ { \prime \prime }$ , (3) “What does a(n) $\{ \}$ look like?”, (4) “A caption of an image of a(n) {}”, (5) “Describe an image from the internet of a(n) $\{ \} ^ { \ast }$ . Example generations for each of these LLM-prompts are given for two ImageNet categories in Figure 3. Full LLM-prompts for all datasets as well as example image-prompts are given in Sections A and K of the Appendix.
|
| 60 |
+
|
| 61 |
+
# 3 EXPERIMENTS AND RESULTS
|
| 62 |
+
|
| 63 |
+
We first discuss the details of our experimental setup. We next show improvements on a wide range of image classification benchmarks. We then examine the scaling behavior with respect to the model size and report observations regarding hyperparameters such as the LLM sampling temperature. Finally, we consider and compare with other methods of obtaining descriptive captions, and provide analysis of CuPl’s improvements over the standard method.
|
| 64 |
+
|
| 65 |
+
# 3.1 SETUP
|
| 66 |
+
|
| 67 |
+
Unless specified otherwise, we use CLIP with a backbone of ViT-L/14 (Dosovitskiy et al., 2020) and the GPT-3 DaVinci-002 model. Additionally, in order to perform open vocabulary image classification, each image category needs a natural language label. This is sometimes provided by the dataset, but not always (e.g. ImageNet categories are described by an id number which can map to multiple synonyms). For this work, we use the same natural language labels specified in Radford et al. (2021).
|
| 68 |
+
|
| 69 |
+
We report our findings on 15 zero-shot image recognition benchmarks: ImageNet (Deng et al., 2009), Describable Textures Dataset (DTD) (Cimpoi et al., 2014), Stanford Cars (Krause et al., 2013), Scene UNderstanding (SUN397) (Xiao et al., 2010), Food101 (Bossard et al., 2014), FGVC Aircraft (Maji et al., 2013), Oxford Pets (Parkhi et al., 2012), Caltech101 (Fei-Fei et al., 2004),
|
| 70 |
+
|
| 71 |
+

|
| 72 |
+
Figure 3: Example image-prompts for each of the 5 LLM-prompts. For three ImageNet classes (moped, platypus, and slide rule), we give an example image-prompt for each of the 5 LLM-prompts used in CuPL (full) for ImageNet.
|
| 73 |
+
|
| 74 |
+
Table 1: Performance of CuPL prompts compared to the standard, hand-written prompts in CLIP (Radford et al., 2021) on 15 zero-shot image classification benchmarks. “∆std” stands for the difference; green shows improvement. In addition to accuracy, we show number of prompt templates (“# hw”) that are hand-written for each dataset using each method, as well as the total and unique number of hand-written templates for each method (unique number only counts templates once even if used for multiple datasets). Note that CuPL (base) uses just three hand-constructed sentence across all datasets compared to 175 in the standard method.
|
| 75 |
+
|
| 76 |
+
<table><tr><td></td><td>eee</td><td>0</td><td>ssrr rlrts</td><td>163308</td><td>[oPooI</td><td>Fraielelr</td><td>od prirt</td><td>CErreael</td><td>Bir SiemiIG</td><td>DECEII</td><td>Erregisg0</td><td>PPSSSSS</td><td>CIPAIII1</td><td>CEIAAIIIO</td><td>Trrsppg</td><td>weea</td><td>u</td><td>anbrun</td></tr><tr><td>std #hw</td><td>75.54</td><td>55.20 8</td><td>77.53 8</td><td>69.31 2</td><td>93.08 1</td><td>32.88 2</td><td>93.33 1</td><td>93.24 34</td><td>78.53 1</td><td>77.45 48</td><td>60.07 28</td><td>71.10 18</td><td>95.59 18</td><td>78.26 18</td><td>50.43 1</td><td>|73.43</td><td>268|175</td><td></td></tr><tr><td>CuPL (base)</td><td>80</td><td>58.90</td><td>76.49</td><td>72.74</td><td></td><td>93.3336.69</td><td>93.37</td><td>93.45</td><td>78.83</td><td>77.74</td><td>60.24</td><td>68.96</td><td>95.81</td><td>78.47</td><td>51.11</td><td>|74.15</td><td></td><td></td></tr><tr><td>△std</td><td>76.19 +0.65</td><td>+3.70</td><td>-1.04</td><td>+3.43</td><td>+0.25</td><td>+3.81</td><td>+0.04</td><td>+0.21</td><td>+0.30</td><td>+0.29</td><td>+0.17</td><td>-2.14</td><td>+0.22</td><td>+0.21</td><td>+0.63</td><td></td><td></td><td></td></tr><tr><td>#hw</td><td>3</td><td>3</td><td>3</td><td>3</td><td>3</td><td>3</td><td>3</td><td>3</td><td>3</td><td>3</td><td>3</td><td>3</td><td>3</td><td>3</td><td>3</td><td></td><td>453</td><td></td></tr><tr><td>CuPL (full)</td><td>76.69</td><td>61.70</td><td>77.63</td><td>73.31</td><td></td><td>93.36 36.11</td><td>93.81</td><td>93.45</td><td>79.67</td><td>78.36</td><td>60.63</td><td>71.69</td><td>95.84</td><td>78.57</td><td>51.11</td><td>74.80</td><td></td><td></td></tr><tr><td>△std</td><td>+1.15</td><td>+6.50</td><td>+0.10</td><td>+4.00</td><td>+0.28</td><td>+3.23</td><td>+0.48</td><td>+0.21</td><td>+1.14</td><td>+0.91</td><td>+0.56</td><td>+0.59</td><td>+0.25</td><td>+0.31</td><td>+0.63</td><td></td><td></td><td>5945</td></tr><tr><td>#hw</td><td>5</td><td>6</td><td>9</td><td>3</td><td>3</td><td>2</td><td>2</td><td>3</td><td>2</td><td>5</td><td>4</td><td>5</td><td>3</td><td>4</td><td>3</td><td></td><td></td><td></td></tr></table>
|
| 77 |
+
|
| 78 |
+
Flowers 102 (Nilsback & Zisserman, 2008), UCF101 (Soomro et al., 2012), Kinetics-700 (Carreira et al., 2019), Remote Sensing Image Scene Classification (RESISC45) (Cheng et al., 2017), CIFAR10 (Krizhevsky et al., 2009), CIFAR-100 (Krizhevsky et al., 2009), and Birdsnap (Berg et al., 2014). For the two video datasets, we extract the middle frame of the video, as is done in Radford et al. (2021).
|
| 79 |
+
|
| 80 |
+
# 3.2 RESULTS
|
| 81 |
+
|
| 82 |
+
Our results for the base prompts setting and the full prompts setting are in Table 1. We present our method’s performance on 15 different image classification benchmarks, comparing both the classification accuracy and the number of hand-written sentence templates needed for each method. Note that for the standard method (Radford et al., 2021), the hand-written sentences refer to the image-prompts, while for CuPL the hand-written sentences refer to the LLM-prompts, with which image-prompts are generated.
|
| 83 |
+
|
| 84 |
+
1. CuPL (base). In this setting, we see performance gains in 13 out of the 15 examined datasets. Note this setting uses just three hand-constructed sentence across all datasets. This is in comparison to the nearly 175 unique image-prompt templates that are hand-written across all of these datasets in the standard setting. Additionally, in the standard setting these hand-constructed prompts must be very specific to the dataset (e.g., “a black and white photo of a $\{ \}$ .”, “a plastic $\{ \} . \ ' )$ . In comparison, CuPL (base) requires only the category type of the overall dataset and still outperforms the handwritten, domain specified baseline in almost all cases. Thus, we present this base prompt setting as a simple standard that matches or exceeds prompt engineering open vocabulary models.
|
| 85 |
+
|
| 86 |
+
2. CuPL (full prompts). Here we see improvements on all examined datasets. This includes large (over 1 percentage point) gains on ImageNet Top-1, DTD (texture classification), SUN397 (scene classification), FGVC Aircraft (fine-grained aircraft classification), and Flowers 102 (flower classification). While this setting requires more hand-written prompts than setting (1), it still requires significantly fewer than the baseline method (5 sentences versus 80 sentence for ImageNet), and does not include knowledge about the image domain. The full list of hand-constructed sentences for CuPL (full prompts) and the baseline method (Radford et al., 2021) can be found in Section A of the Appendix.
|
| 87 |
+
|
| 88 |
+
# 3.3 ANALYSIS AND ABLATIONS
|
| 89 |
+
|
| 90 |
+
Model Size. In Figure 4, we show CuPL (full prompts) at different model scales. As there are two different zero-shot models in the CuPL algorithm, we show the effects of varying each model individually. On the left hand side, we vary the CLIP model used while holding the LLM constant. We see consistent gains across all model sizes. On the right hand side, we vary the size of the LLM. We plot the accuracy of the baseline as well, which does not vary as it does not utilize an LLM. We find larger models lead to higher accuracy, though the 2nd and 3rd largest models perform similarly.
|
| 91 |
+
|
| 92 |
+

|
| 93 |
+
Figure 4: Performance of $\mathbf { C u P L }$ as models scale. (Left) ImageNet Top-1 accuracy for various scales of CLIP. CuPL prompts remain consistently better than standard prompts even we adjust CLIP model size (ViT-B/32, ViT-B/16, ViT-L/14). GPT-3 model set as DaVinci-002. (Right) ImageNet Top-1 accuracy for various scales of GPT-3 (ada, babbage, curie, davinci-002). Larger models produce higher accuracy. CLIP model set as ViT-L/14.
|
| 94 |
+
|
| 95 |
+
Number of Prompts. In Figure 6, we present ablations on the number of LLM-prompts and image-prompts for CuPL (full prompts). On the left side, we show ImageNet accuracy as we increase the number of LLM-prompts. This also corresponds to the number of sentences that have to be hand-written. Notably, this methods outperforms the baseline even when using prompts generated from a single handwritten sentence. On the right hand side, we hold the number of LLM-prompts constant at 5 and adjust how many image-prompts we generate per LLM-prompt. We plot the accuracy given the total number of image-prompts (so 10 generated image-prompt per LLM-prompt corresponds to 50 total image-prompts). We see
|
| 96 |
+
|
| 97 |
+
that $\mathrm { { C u P L } }$ begins to outperform the baseline at just 25 image-prompts, well below the 80 imageprompts used in the baseline.
|
| 98 |
+
|
| 99 |
+

|
| 100 |
+
Figure 5: Effect of LLM temperature. More prompt diversity leads to higher performance.
|
| 101 |
+
|
| 102 |
+
Diversity of Prompts. We also examine the impact of the diversity of image-prompts on ImageNet accuracy. We adjust this parameter by changing the temperature of the GPT-3 model. This value changes the likelihood of selecting lower probability tokens and makes sentences more diverse from each other. As demonstrated in Figure 5, more diverse prompts lead to higher ImageNet accuracy. Note these comparisons are done with a single LLM-prompt to save computational cost.
|
| 103 |
+
|
| 104 |
+
WordNet Definitions and Wikipedia Descriptions. We also consider two additional methods of obtaining descriptive sentences for each ImageNet category, other than using an LLM. Firstly, we compare CuPL (full) image-prompts with image-prompts generated using definitions of each ImageNet category. Because each ImageNet category is derived from the WordNet database (Miller, 1995), we can use the WordNet definition of each word.
|
| 105 |
+
|
| 106 |
+
We preprocess these definitions so they are of the form “A(n) $\{ \}$ is a ...” as not all WordNet definitions contain the name of the word itself. We also add a period to the end of each definition, as we find this increases performance. As shown in Table 2, ImageNet Top-1 accuracy with WordNet definition prompts is below that of CuPL or standard prompts. In addition to lower accuracy, this method uses significantly more hand-constructed sentences as it requires 1000 unique hand-written definitions compared to 175 unique hand-written image-prompt templates for the standard method and 45 unique hand-written LLM-prompt templates for CuPL (full).
|
| 107 |
+
|
| 108 |
+

|
| 109 |
+
Figure 6: Ablation on number of LLM-prompts (left) and image-prompts (right). (Left) As number of hand-written LLM-prompts increases, so does accuracy. 10 image-prompts are generated for each LLM-prompt. Note that $\mathrm { { C u P L } }$ outperforms the baseline even with just one hand-written sentence. We add the prompts in a greedy manner, at each step adding the 10 prompts which lead to the largest performance gain. (Right) We adjust the number of image-prompts generated by a fixed number (5) of LLM-prompts. Even at 5 Image-prompts per LLM-prompt (25 prompts total), we outperform the baseline which uses 80 image-prompts.
|
| 110 |
+
|
| 111 |
+
Secondly, we compare against prompts generated from Wikipedia articles corresponding to each ImageNet category, as collected in Bujwid & Sullivan (2021b). Note that the Wikipedia article does not always exactly match the natural language name of the class used by Radford et al. (2021). Additionally, 80 categories map to more than one Wikipedia article (e.g. the category associated with the natural language word “patio” is mapped to the articles for “patio” and “terrace”). In this case, we select the first associated article. We preprocess these by removing the first line (the name of the article), and then extracting the first sentence, including the final period. We find both of these preprocessing steps lead to increase in accuracy. We also truncate this sentence to the maximum allowed input length of CLIP. For the 24 ImageNet categories that do not have an associated Wikipedia page, we use the name of the category as the image-prompts. As shown in Table 2, we find Wikipedia to be less effective than standard prompts, CuPL prompts, or WordNet definitions.
|
| 112 |
+
|
| 113 |
+
Table 2: ImageNet Top-1 accuracy for different methods of generating imageprompts.
|
| 114 |
+
|
| 115 |
+
<table><tr><td rowspan=1 colspan=1> Standard</td><td rowspan=1 colspan=1>CuPL</td><td rowspan=1 colspan=1>WordNet</td><td rowspan=1 colspan=1>Wiki</td></tr><tr><td rowspan=1 colspan=1>75.54</td><td rowspan=1 colspan=1>76.69</td><td rowspan=1 colspan=1>73.44</td><td rowspan=1 colspan=1>68.20</td></tr></table>
|
| 116 |
+
|
| 117 |
+
Ensembling with Standard Prompts. We also consider using LLM generated prompts from CuPL (full) in addition to hand-written prompts. We do this by averaging together all the text embeddings of the CuPL prompts and hand-written prompts. As shown in Table 3, we find that for some datasets, ensembling both types of prompts outperforms CuPL prompts on their own, while for others CuPL prompts perform better. For all datasets, this ensemble performs better than standard prompts alone. However, this ensembling method requires all the hand-written effort and domain knowledge of the standard approach.
|
| 118 |
+
|
| 119 |
+
Analysis of Accuracy Gains. In addition to total accuracy gains, we present the per class accuracy shift between the image-prompts used in Radford et al. (2021) and CuPL, shown in Figure 7. As demonstrated, the accuracy gains seen in $\mathrm { C u P L }$ are not distributed uniformly through the ImageNet classes, with some classes seeing ${ \sim } 4 0$ percentage point accuracy gains, and others seeing ${ \sim } 4 0$ percentage point accuracy losses when compared against class accuracy with standard prompts. In other words, while CuPL sees a higher accuracy overall when compared to the standard method, the images which are correctly predicted by the standard prompts are not a subset of the images which are correctly predicted by $\mathrm { C u P L }$ . In fact $\mathrm { { C u P L } }$ sees just over a 1 percentage point gain when compared to standard prompts, but differs in it’s predictions from the standard method for $1 1 . 5 0 \%$ of predictions (with CuPL correct for $4 . 4 8 \%$ of these, standard correct for $3 . 3 2 \%$ , and neither correct for $3 . 7 0 \%$ ).
|
| 120 |
+
|
| 121 |
+
Table 3: Performance of the ensemble of CuPL (full) and the standard, hand-written prompts in CLIP (Radford et al., 2021). This ensemble outperforms the standard hand-written prompts for all examined datasets (difference shown with $\Delta$ std), and outperforms CuPL (full) for 11 datasets (difference shown with $\Delta$ CuPL)
|
| 122 |
+
|
| 123 |
+
<table><tr><td></td><td colspan="5">eeee </td><td>Teirierr</td><td>PPd Ppirit</td><td>Grleaar</td><td>Bi eiEG</td><td>UUIIII</td><td>Errresiso0</td><td>PPSSSSSS</td><td>CIATII1</td><td></td><td>CEIPAIIIO</td><td>Trrsppg</td><td>naea</td></tr><tr><td>Ensemble</td><td>76.51</td><td>61.60</td><td>77.66</td><td>73.51</td><td></td><td>93.42</td><td>36.47</td><td>93.71</td><td>93.87</td><td>79.73</td><td>78.16</td><td>61.50</td><td>73.03</td><td>95.88</td><td>79.33</td><td>51.09</td><td>75.03</td></tr><tr><td>△std</td><td>+0.97</td><td>+6.40</td><td>+0.13</td><td>+4.20</td><td>+0.34</td><td>+3.59</td><td></td><td>+0.38</td><td>+0.63</td><td>+1.20</td><td>+0.71</td><td>+1.43</td><td>+1.93</td><td>+0.29</td><td>+1.07</td><td>+0.66</td><td></td></tr><tr><td>△ CuPL</td><td>-0.18</td><td>-0.1</td><td>+0.03</td><td>+0.20</td><td>+0.06</td><td></td><td>+0.36</td><td>-0.10</td><td>+0.42</td><td>+0.06</td><td>+0.20</td><td>+0.87</td><td>+1.34</td><td>+0.04</td><td>+0.76</td><td>-0.02</td><td></td></tr></table>
|
| 124 |
+
|
| 125 |
+
Figure 7 also shows the classes with the 20 greatest accuracy gains and losses when comparing class accuracy with standard image-prompts (Radford et al., 2021) versus with $\mathrm { C u P L }$ image-prompts. Interestingly, for many of the classes which see a large accuracy gain, we see a corresponding class with a large accuracy loss that is either similar to the initial class or likely to co-occur with it (e.g. agaric/mushroom, academic gown/graduation cap, military uniform/Pickelhaube, desk/monitor).
|
| 126 |
+
|
| 127 |
+
# 4 RELATED WORK
|
| 128 |
+
|
| 129 |
+
# 4.1 NATURAL LANGUAGE DESCRIPTIONS FOR IMAGE CLASSIFICATION
|
| 130 |
+
|
| 131 |
+
Several prior works use text-based knowledge of image categories to improve classification accuracy. Elhoseiny et al. (2017) extract visual information from unstructured text descriptions collected from the internet to recognize parts of object and classify them in a zero-shot way. Reed et al. (2016) and He & Peng (2017) use natural language descriptions of bird types to train a multimodal classification model. Huang et al. (2021) use hand-collected attribute tags to attend over relevant features in images. Paz-Argaman et al. (2020) extract visual information from Wikipedia descriptions to enable zero-shot bird classification. Additional works (Shen et al., 2022; Bujwid & Sullivan, 2021a) show improvements on large datasets (e.g., ImageNet) using external information from external databases such as Imagenet-wiki and Wordnet. While these works show the effectiveness of augmenting zero-shot models with descriptive text, all of these prior works rely on external natural language databases for descriptions. This often limits the possible categories that can be classified and can require extensive preprocessing to extract visual descriptions from noisy natural language.
|
| 132 |
+
|
| 133 |
+
# 4.2 GENERATED TEXT FOR DOWNSTREAM TASKS
|
| 134 |
+
|
| 135 |
+
Recent work has utilized text generated from LLMs in a number of ways. Santurkar et al. (2022) use an LLM to paraphrase existing image captions to use as data augmentation for CLIP. Liu et al. (2022) use GPT-3 to generate knowledge on a topic when given a number of demonstrations, which is then used to improve accuracy on common sense reasoning questions. Hu et al. (2022) use a LLM to add labels to text to improve text classification accuracy. In Yu et al. (2022b), the outputs of a GPT-2 model are used to train an encoder on top of a vision model to generate multimodal image representations for a variety of tasks. Su et al. (2022) utilize a language model to perform image captioning by iteritively generating candidate image captions with a LLM and then using feedback from an open vocabulary model to align it to a given image. Similarly, Yang et al. (2022) use GPT-3 along with text descriptions of images for the Visual Question Answering (VQA) task. However, unlike CuPL these prior works are either purely language tasks (common sense reasoning, text classification) or multimodal with some language component (image captioning, VQA). In our work, we demonstrate how LLM generated text can be used to improve purely visual image classification tasks across a number of benchmarks.
|
| 136 |
+
|
| 137 |
+

|
| 138 |
+
per class accuracy difference of CuPL vs Standard image-prompts
|
| 139 |
+
Figure 7: Distribution of ImageNet per class accuracy difference of CuPL image-prompts versus standard image-prompts. As shown, the accuracy gains of $\mathrm { C u P L }$ are not uniform across all classes. Rather, we see large gains for some classes, and losses for others. In addition, we list the classes which see the largest accuracy gains when switching to $\mathrm { C u P L }$ prompts (with “mushroom” having the largest gain), and the 20 classes with the largest accuracy losses (with “canoe” having the largest loss.)
|
| 140 |
+
|
| 141 |
+
# 4.3 PROMPT ENGINEERING
|
| 142 |
+
|
| 143 |
+
Previous efforts have explored methods for obtaining successful natural language prompts. For both open vocabulary image classification models as well as LLMs, the format of prompts is known to highly affect accuracy (Schick & Schutze, 2021; Radford et al., 2021; Brown et al., 2020; Gao et al., ¨ 2020). This has led to a large effort to find optimal prompt formats. Proposed methods include crowd-sourcing high performing prompts (Bach et al., 2022) as well as framing prompts to induce models to give explanations as well as answers (Wei et al., 2022; Kojima et al., 2022; Nye et al., 2021). Additional works have proposed learning prompts via gradient based methods (Zhang et al., 2021; Qin & Eisner, 2021; Li & Liang, 2021; Lester et al., 2021; Shin et al., 2020), retrieval from a database (Rubin et al., 2022), or reformatting/rephrasing existing prompts (Jiang et al., 2020; Rubin et al., 2022).
|
| 144 |
+
|
| 145 |
+
Most relevant to this work are a number of methods for designing optimal prompts for zero-shot image classification with open vocabulary models. These methods learn prompts formats which yield high accuracy for image classification using either supervised (Zhou et al., 2022; Rao et al., 2022) or unsupervised (Huang et al., 2022) methods. However, unlike these prior works this work requires no additional training or labeled data.
|
| 146 |
+
|
| 147 |
+
# 5 CONCLUSION
|
| 148 |
+
|
| 149 |
+
We demonstrate that leveraging knowledge from an LLM can immediately improve zero-shot accuracy on a variety of image classification tasks, with much less hand-engineering efforts to craft natural language prompts. Furthermore, prompts can be customized to the desired categories, rather than a general template that applies to all existing image categories. Finally, using prompts generated by LLMs lowers the barrier of prior knowledge about the dataset, which is often required when crafting prompt templates.
|
| 150 |
+
|
| 151 |
+
Querying an LLM for prompt construction is simple, straightforward and as our results suggested, immediately beneficial. The hypothesis that a joint force of LLMs and open vocabulary models would improve zero-shot image classification is thoroughly tested in this work. We hope these findings serve as a useful tool towards understanding and improving zero-shot image classification, and more generally, the consolidation of model capacities and modalities through natural language.
|
| 152 |
+
|
| 153 |
+
# 6 REPRODUCIBILITY
|
| 154 |
+
|
| 155 |
+
We have a number of measures to ensure the reproducibility of this work. First, in the supplementary material we include the code to generate image-prompts for ImageNet and evaluate the accuracy of these prompts. In Section 2, we note all hyperparameters used for the LLM. Additionally, in the appendix we include all LLM-prompts used to generate image-prompts for each of the 15 datasets. In the supplementary material, we include all generated image-prompts for all dataset, for both CuPL (base) and CuPL (full).
|
| 156 |
+
|
| 157 |
+
# REFERENCES
|
| 158 |
+
|
| 159 |
+
Stephen H. Bach, Victor Sanh, Zheng Xin Yong, Albert Webson, Colin Raffel, Nihal V. Nayak, Abheesht Sharma, Taewoon Kim, M SAIFUL BARI, Thibault Fevry, Zaid Alyafeai, Manan Dey, ´ Andrea Santilli, Zhiqing Sun, Srulik Ben-David, Canwen Xu, Gunjan Chhablani, Han Wang, Jason Alan Fries, Maged S. Al-shaibani, Shanya Sharma, Urmish Thakker, Khalid Almubarak, Xiangru Tang, Mike Tian-Jian Jiang, and Alexander M. Rush. Promptsource: An integrated development environment and repository for natural language prompts. ArXiv, abs/2202.01279, 2022.
|
| 160 |
+
|
| 161 |
+
Thomas Berg, Jiongxin Liu, Seung Woo Lee, Michelle L Alexander, David W Jacobs, and Peter N Belhumeur. Birdsnap: Large-scale fine-grained visual categorization of birds. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 2011–2018, 2014.
|
| 162 |
+
|
| 163 |
+
Lucas Beyer, Olivier J Henaff, Alexander Kolesnikov, Xiaohua Zhai, and A ´ aron van den Oord. Are ¨ we done with imagenet? arXiv preprint arXiv:2006.07159, 2020.
|
| 164 |
+
|
| 165 |
+
Lukas Bossard, Matthieu Guillaumin, and Luc Van Gool. Food-101 – mining discriminative components with random forests. In European Conference on Computer Vision, 2014.
|
| 166 |
+
|
| 167 |
+
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.
|
| 168 |
+
|
| 169 |
+
Sebastian Bujwid and Josephine Sullivan. Large-scale zero-shot image classification from rich and diverse textual descriptions. ArXiv, abs/2103.09669, 2021a.
|
| 170 |
+
|
| 171 |
+
Sebastian Bujwid and Josephine Sullivan. Large-scale zero-shot image classification from rich and diverse textual descriptions. arXiv preprint arXiv:2103.09669, 2021b.
|
| 172 |
+
|
| 173 |
+
Joao Carreira, Eric Noland, Chloe Hillier, and Andrew Zisserman. A short note on the kinetics-700 human action dataset. arXiv preprint arXiv:1907.06987, 2019.
|
| 174 |
+
|
| 175 |
+
Gong Cheng, Junwei Han, and Xiaoqiang Lu. Remote sensing image scene classification: Benchmark and state of the art. Proceedings of the IEEE, 105(10):1865–1883, 2017.
|
| 176 |
+
|
| 177 |
+
M. Cimpoi, S. Maji, I. Kokkinos, S. Mohamed, , and A. Vedaldi. Describing textures in the wild. In Proceedings of the IEEE Conf. on Computer Vision and Pattern Recognition (CVPR), 2014.
|
| 178 |
+
|
| 179 |
+
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.
|
| 180 |
+
|
| 181 |
+
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.
|
| 182 |
+
|
| 183 |
+
Mohamed Elhoseiny, Yizhe Zhu, Han Zhang, and A. Elgammal. Link the head to the ”beak”: Zero shot learning from noisy text description at part precision. 2017 IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pp. 6288–6297, 2017.
|
| 184 |
+
|
| 185 |
+
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 2004 conference on computer vision and pattern recognition workshop, pp. 178–178. IEEE, 2004.
|
| 186 |
+
|
| 187 |
+
Tianyu Gao, Adam Fisch, and Danqi Chen. Making pre-trained language models better few-shot learners. arXiv preprint arXiv:2012.15723, 2020.
|
| 188 |
+
|
| 189 |
+
Xiangteng He and Yuxin Peng. Fine-grained image classification via combining vision and language. 2017 IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pp. 7332– 7340, 2017.
|
| 190 |
+
|
| 191 |
+
Shengding Hu, Ning Ding, Huadong Wang, Zhiyuan Liu, Juan-Zi Li, and Maosong Sun. Knowledgeable prompt-tuning: Incorporating knowledge into prompt verbalizer for text classification. In ACL, 2022.
|
| 192 |
+
|
| 193 |
+
Siteng Huang, Min Zhang, Yachen Kang, and Donglin Wang. Attributes-guided and pure-visual attention alignment for few-shot recognition. In AAAI, 2021.
|
| 194 |
+
|
| 195 |
+
Tony Huang, Jack Chu, and Fangyun Wei. Unsupervised prompt learning for vision-language models. arXiv preprint arXiv:2204.03649, 2022.
|
| 196 |
+
|
| 197 |
+
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 International Conference on Machine Learning, pp. 4904–4916. PMLR, 2021.
|
| 198 |
+
|
| 199 |
+
Zhengbao Jiang, Frank F. Xu, J. Araki, and Graham Neubig. How can we know what language models know? Transactions of the Association for Computational Linguistics, 8:423–438, 2020.
|
| 200 |
+
|
| 201 |
+
Takeshi Kojima, Shixiang Shane Gu, Machel Reid, Yutaka Matsuo, and Yusuke Iwasawa. Large language models are zero-shot reasoners. ArXiv, abs/2205.11916, 2022.
|
| 202 |
+
|
| 203 |
+
Jonathan Krause, Michael Stark, Jia Deng, and Li Fei-Fei. 3d object representations for fine-grained categorization. In 4th International IEEE Workshop on 3D Representation and Recognition (3dRR-13), Sydney, Australia, 2013.
|
| 204 |
+
|
| 205 |
+
Alex Krizhevsky, Geoffrey Hinton, et al. Learning multiple layers of features from tiny images. 2009.
|
| 206 |
+
|
| 207 |
+
Brian Lester, Rami Al-Rfou, and Noah Constant. The power of scale for parameter-efficient prompt tuning. ArXiv, abs/2104.08691, 2021.
|
| 208 |
+
|
| 209 |
+
Xiang Lisa Li and Percy Liang. Prefix-tuning: Optimizing continuous prompts for generation. 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), abs/2101.00190, 2021.
|
| 210 |
+
|
| 211 |
+
Jiacheng Liu, Alisa Liu, Ximing Lu, Sean Welleck, Peter West, Ronan Le Bras, Yejin Choi, and Hannaneh Hajishirzi. Generated knowledge prompting for commonsense reasoning. In ACL, 2022.
|
| 212 |
+
|
| 213 |
+
S. Maji, J. Kannala, E. Rahtu, M. Blaschko, and A. Vedaldi. Fine-grained visual classification of aircraft. Technical report, 2013.
|
| 214 |
+
|
| 215 |
+
George A Miller. Wordnet: a lexical database for english. Communications of the ACM, 38(11): 39–41, 1995.
|
| 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.
|
| 218 |
+
|
| 219 |
+
Maxwell Nye, Anders Johan Andreassen, Guy Gur-Ari, Henryk Michalewski, Jacob Austin, David Bieber, David Dohan, Aitor Lewkowycz, Maarten Bosma, David Luan, Charles Sutton, and Augustus Odena. Show your work: Scratchpads for intermediate computation with language models. ArXiv, abs/2112.00114, 2021.
|
| 220 |
+
|
| 221 |
+
Omkar M Parkhi, Andrea Vedaldi, Andrew Zisserman, and CV Jawahar. Cats and dogs. In 2012 IEEE conference on computer vision and pattern recognition, pp. 3498–3505. IEEE, 2012.
|
| 222 |
+
|
| 223 |
+
Tzuf Paz-Argaman, Yuval Atzmon, Gal Chechik, and Reut Tsarfaty. Zest: Zero-shot learning from text descriptions using textual similarity and visual summarization. In FINDINGS, 2020.
|
| 224 |
+
|
| 225 |
+
Hieu Pham, Zihang Dai, Golnaz Ghiasi, Kenji Kawaguchi, Hanxiao Liu, Adams Wei Yu, Jiahui Yu, Yi-Ting Chen, Minh-Thang Luong, Yonghui Wu, et al. Combined scaling for open-vocabulary image classification. arXiv preprint arXiv:2111.10050, 2021.
|
| 226 |
+
|
| 227 |
+
Guanghui Qin and Jas’ Eisner. Learning how to ask: Querying lms with mixtures of soft prompts. ArXiv, abs/2104.06599, 2021.
|
| 228 |
+
|
| 229 |
+
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, pp. 8748–8763. PMLR, 2021.
|
| 230 |
+
|
| 231 |
+
Yongming Rao, Wenliang Zhao, Guangyi Chen, Yansong Tang, Zheng Zhu, Guan Huang, Jie Zhou, and Jiwen Lu. Denseclip: Language-guided dense prediction with context-aware prompting. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 18082–18091, 2022.
|
| 232 |
+
|
| 233 |
+
Benjamin Recht, Rebecca Roelofs, Ludwig Schmidt, and Vaishaal Shankar. Do imagenet classifiers generalize to imagenet? In International Conference on Machine Learning, pp. 5389–5400. PMLR, 2019.
|
| 234 |
+
|
| 235 |
+
Scott E. Reed, Zeynep Akata, Honglak Lee, and Bernt Schiele. Learning deep representations of fine-grained visual descriptions. 2016 IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pp. 49–58, 2016.
|
| 236 |
+
|
| 237 |
+
Ohad Rubin, Jonathan Herzig, and Jonathan Berant. Learning to retrieve prompts for in-context learning. In NAACL, 2022.
|
| 238 |
+
|
| 239 |
+
Shibani Santurkar, Yann Dubois, Rohan Taori, Percy Liang, and Tatsunori Hashimoto. Is a caption worth a thousand images? a controlled study for representation learning. arXiv preprint arXiv:2207.07635, 2022.
|
| 240 |
+
|
| 241 |
+
Timo Schick and Hinrich Schutze. Exploiting cloze-questions for few-shot text classification and ¨ natural language inference. In EACL, 2021.
|
| 242 |
+
|
| 243 |
+
Sheng Shen, Chunyuan Li, Xiaowei Hu, Yujia Xie, Jianwei Yang, Pengchuan Zhang, Anna Rohrbach, Zhe Gan, Lijuan Wang, Lu Yuan, Ce Liu, Kurt Keutzer, Trevor Darrell, and Jianfeng Gao. K-lite: Learning transferable visual models with external knowledge. ArXiv, abs/2204.09222, 2022.
|
| 244 |
+
|
| 245 |
+
Taylor Shin, Yasaman Razeghi, Robert L Logan IV, Eric Wallace, and Sameer Singh. Eliciting knowledge from language models using automatically generated prompts. ArXiv, abs/2010.15980, 2020.
|
| 246 |
+
|
| 247 |
+
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.
|
| 248 |
+
|
| 249 |
+
Yixuan Su, Tian Lan, Yahui Liu, Fangyu Liu, Dani Yogatama, Yan Wang, Lingpeng Kong, and Nigel Collier. Language models can see: Plugging visual controls in text generation. ArXiv, abs/2205.02655, 2022.
|
| 250 |
+
|
| 251 |
+
Laurens Van der Maaten and Geoffrey Hinton. Visualizing data using t-sne. Journal of machine learning research, 9(11), 2008.
|
| 252 |
+
|
| 253 |
+
Ben Wang and Aran Komatsuzaki. Gpt-j-6b: A 6 billion parameter autoregressive language model, 2021.
|
| 254 |
+
|
| 255 |
+
Haohan Wang, Songwei Ge, Zachary Lipton, and Eric P Xing. Learning robust global representations by penalizing local predictive power. In Advances in Neural Information Processing Systems, pp. 10506–10518, 2019.
|
| 256 |
+
|
| 257 |
+
Jason Wei, Xuezhi Wang, Dale Schuurmans, Maarten Bosma, Ed Chi, Quoc Le, and Denny Zhou. Chain of thought prompting elicits reasoning in large language models. ArXiv, abs/2201.11903, 2022.
|
| 258 |
+
|
| 259 |
+
Thomas Wolf, Lysandre Debut, Victor Sanh, Julien Chaumond, Clement Delangue, Anthony Moi, Pierric Cistac, Tim Rault, Remi Louf, Morgan Funtowicz, et al. Huggingface’s transformers: ´ State-of-the-art natural language processing. arXiv preprint arXiv:1910.03771, 2019.
|
| 260 |
+
|
| 261 |
+
Mitchell Wortsman, Gabriel Ilharco, Jong Wook Kim, Mike Li, Simon Kornblith, Rebecca Roelofs, Raphael Gontijo Lopes, Hannaneh Hajishirzi, Ali Farhadi, Hongseok Namkoong, et al. Robust fine-tuning of zero-shot models. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 7959–7971, 2022.
|
| 262 |
+
|
| 263 |
+
Jianxiong Xiao, James Hays, Krista A Ehinger, Aude Oliva, and Antonio Torralba. Sun database: Large-scale scene recognition from abbey to zoo. In 2010 IEEE computer society conference on computer vision and pattern recognition, pp. 3485–3492. IEEE, 2010.
|
| 264 |
+
|
| 265 |
+
Zhengyuan Yang, Zhe Gan, Jianfeng Wang, Xiaowei Hu, Yumao Lu, Zicheng Liu, and Lijuan Wang. An empirical study of gpt-3 for few-shot knowledge-based vqa. In AAAI, 2022.
|
| 266 |
+
|
| 267 |
+
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, 2022a.
|
| 268 |
+
|
| 269 |
+
Youngjae Yu, Jiwan Chung, Heeseung Yun, Jack Hessel, Jae Sung Park, Ximing Lu, Prithviraj Ammanabrolu, Rowan Zellers, Ronan Le Bras, Gunhee Kim, and Yejin Choi. Multimodal knowledge alignment with reinforcement learning. ArXiv, abs/2205.12630, 2022b.
|
| 270 |
+
|
| 271 |
+
Ningyu Zhang, Luoqiu Li, Xiang Chen, Shumin Deng, Zhen Bi, Chuanqi Tan, Fei Huang, and Huajun Chen. Differentiable prompt makes pre-trained language models better few-shot learners. ArXiv, abs/2108.13161, 2021.
|
| 272 |
+
|
| 273 |
+
Kaiyang Zhou, Jingkang Yang, Chen Change Loy, and Ziwei Liu. Learning to prompt for visionlanguage models. International Journal of Computer Vision, pp. 1–12, 2022.
|
| 274 |
+
|
| 275 |
+
APPENDIX: What does a platypus look like? Generating customized prompts for zero-shot image classification
|
| 276 |
+
|
| 277 |
+
OVERVIEW
|
| 278 |
+
|
| 279 |
+
A. CuPL (Full Prompts) vs Standard Prompts
|
| 280 |
+
B. CuPL Base Prompts
|
| 281 |
+
C. Evaluation Metric
|
| 282 |
+
D. Open-Source LLM
|
| 283 |
+
E. Single Sentence Baseline
|
| 284 |
+
F. Robustness
|
| 285 |
+
G. CuPL Improvement Analysis
|
| 286 |
+
H. Error Analysis
|
| 287 |
+
I. Image-Prompt Distribution
|
| 288 |
+
J. Tempurature Analysis
|
| 289 |
+
K. Example Generated image-prompts
|
| 290 |
+
|
| 291 |
+
A CUPL (FULL PROMPTS) VS STANDARD PROMPTS
|
| 292 |
+
|
| 293 |
+
We detail the hand-written prompt templates used for $\mathrm { { C u P L } }$ (full prompts) versus standard CLIP Radford et al. (2021) prompt templates. For $\mathrm { C u P L }$ , hand-written prompt templates are needed for the LLM-prompts, while for the standard method hand-written prompt templates are needed for the image-prompts.
|
| 294 |
+
|
| 295 |
+
Note that many of the hand-written templates for the standard method encode information about the datasets. For example, ”a toy $\{ \} ^ { \ast }$ demonstrates knowledge that objects are sometimes represented as a toy version of an object rather than as the literal object. CuPL prompts remain much more general (e.g. ”Describe what a $\{ \}$ looks like”).
|
| 296 |
+
|
| 297 |
+
<table><tr><td>Caltech101</td><td colspan="2"></td></tr><tr><td>CuPL hand-written</td><td colspan="2">Standard hand-written</td></tr><tr><td>Describe what a(n) {} looks like: Describe a(n) {}: What are the identifying characteristics of a(n) {}?</td><td>a photo of a {}. a painting of a{. a plastic {. a sculpture of a {}. a sketch of a {}. a tattoo of a {}. a toy {. a rendition of a {}. a embroidered {}. a cartoon {}. a {} in a video game. a plushie {}. a origami{. art of a{. graffiti of a {}. a drawing of a {}. a doodle of a {}.</td><td>a photo of the {}. a painting of the {. the plastic {}. a sculpture of the {}. a sketch of the {}. a tattoo of the {}. the toy {. a rendition of the {}. the embroidered{}. the cartoon {}. the {} ina video game. the plushie {}. the origami {. art of the {}. graffiti of the {}. a drawing of the {}.</td></tr></table>
|
| 298 |
+
|
| 299 |
+
<table><tr><td rowspan=1 colspan=1>Food101</td><td rowspan=1 colspan=1></td></tr><tr><td rowspan=1 colspan=1>CuPL hand-written</td><td rowspan=1 colspan=1>Standard hand-written</td></tr><tr><td rowspan=1 colspan=1>Describe what {} looks likeVisually describe {}How can you tell that the food in this photo is {}?</td><td rowspan=1 colspan=1>a photo of {},a type of food.</td></tr></table>
|
| 300 |
+
|
| 301 |
+
# Stanford Cars
|
| 302 |
+
|
| 303 |
+
<table><tr><td>CuPL hand-written</td><td>Standard hand-written</td></tr><tr><td></td><td></td></tr></table>
|
| 304 |
+
|
| 305 |
+
<table><tr><td>How can you identify a(n) {}? Description of a(n) {},a type of car. A caption of a photo of a(n) {: What are the primary characteristics of a(n) {}? Description of the exterior of a(n) {} What are the identifying characteristics of a(n) {},a type of car? Describe an image from the internet of a(n) {</td><td>a photo of a {}. a photo of the {}. a photo of my {. i love my {}! a photo of my dirty {. a photo of my clean {}. a photo of my new {}. a photo of my old {}.</td></tr></table>
|
| 306 |
+
|
| 307 |
+
<table><tr><td rowspan=1 colspan=1>Oxford Pets</td><td rowspan=1 colspan=1></td></tr><tr><td rowspan=1 colspan=1>CuPL hand-written</td><td rowspan=1 colspan=1>Standard hand-writen</td></tr><tr><td rowspan=1 colspan=1>Describe what a pet {} looks likeVisually describe a(n)‘{}',a type of pet.</td><td rowspan=1 colspan=1>a photo of a , a type of pet.</td></tr></table>
|
| 308 |
+
|
| 309 |
+
#
|
| 310 |
+
|
| 311 |
+
<table><tr><td>ImageNet</td><td colspan="2"></td></tr><tr><td>CuPL hand-written</td><td colspan="2">Standard hand-written</td></tr><tr><td>Describe what a(n){} looks like How can you identify a(n) {}? What does a(n) look like? Describe an image from the internet of a(n) {} A caption of an image of a(n) {}:</td><td>a bad photo of a {}. a photo of many {}. a sculpture of a {}. a photo of the hard to see {}. a low resolution photo of the {}. a rendering of a {}. graffiti of a {}. a bad photo of the {}. a cropped photo of the {}. a tattoo of a {}. the embroidered{}. a photo of a hard to see {}. a bright photo of a {}. a photo of a clean {}. a photo of a dirty {. a dark photo of the {}. a drawing of a{}. a photo of my {}. the plastic {}. a photo of the cool {}. a close-up photo of a{}. a black and white photo of the {}. a painting of the {}. a painting of a{}. a pixelated photo of the {}. a sculpture of the {}. a bright photo of the {}. a cropped photo of a {}. a plastic {}. a photo of the dirty {. a jpeg corrupted photo of a{}. a blurry photo of the {}. a photo of the {}.</td><td>the origami{}. the{} in a video game. a sketch of a {}. a doodle of the {}. a origami{}. a low resolution photo of a {}. the toy{}. a rendition of the {}. a photo of the clean {}. a photo of a large {}. a rendition of a{} a photo of a nice{}. a photo of a weird {}. a blurry photo of a {}. a cartoon{}. art of a{. a sketch of the {}. aembroidered{}. a pixelated photo of a {}. itap of the {}. a jpeg corrupted photo of the {}. a good photo of a {}. a plushie {}. a photo of the nice {}. a photo of the small {}. a photo of the weird {}. the cartoon {}. art of the {}. a drawing of the {}. a photo of the large {}. a black and white photo of a {}. the plushie {}. a dark photo of a {}.</td></tr></table>
|
| 312 |
+
|
| 313 |
+
<table><tr><td rowspan=1 colspan=1>FGVC Aircraft</td><td rowspan=1 colspan=1></td></tr><tr><td rowspan=1 colspan=1>CuPL hand-written</td><td rowspan=1 colspan=1>Standard hand-written</td></tr><tr><td rowspan=1 colspan=1>Describe a(n) {}aircraftDescribe the{}aircraft</td><td rowspan=1 colspan=1>a photo of a {},a type of aircraft.a photo of the {,a type of aircraft.</td></tr></table>
|
| 314 |
+
|
| 315 |
+
<table><tr><td>DTD</td><td></td></tr><tr><td>CuPL hand-written</td><td>Standard hand-written</td></tr><tr><td>What does“{}” material look like? What does a “{}” surface look like? What does a “{}” texture look like? What does a “{}” object look like? What does a“{}” thing look like? What does a “{}” pattern look like?</td><td>a photo of a {} texture. a photo of a { pattern. a photo of a {} thing. a photo of a {} object. a photo of the{} texture. a photo of the {} pattern. a photo of the { thing. a photo of the {} object.</td></tr></table>
|
| 316 |
+
|
| 317 |
+
<table><tr><td rowspan=1 colspan=1>SUN397</td><td rowspan=1 colspan=1></td></tr><tr><td rowspan=1 colspan=1>CuPL hand-written</td><td rowspan=1 colspan=1>Standard hand-written</td></tr><tr><td rowspan=1 colspan=1>Describe what a(n) {}looks likeHow can you identify a(n) {}?Describe a photo of a(n) {}</td><td rowspan=1 colspan=1>a photo of a {}.a photo of the {}.</td></tr></table>
|
| 318 |
+
|
| 319 |
+
# Kinetics-700
|
| 320 |
+
|
| 321 |
+
Describe the action ”{}” What does a person $\{ \}$ look like? What does the act of $\{ \}$ look like? Describe ”{}”
|
| 322 |
+
|
| 323 |
+
<table><tr><td rowspan=3 colspan=2>UCT101CuPL hand-writtenDescribe the action of {}What does the act of {} look like?What does a person doing {} look like?Describe“}"Describe the action “{}"</td><td rowspan=1 colspan=1>UCT101</td></tr><tr><td rowspan=1 colspan=1>CuPL hand-written</td><td rowspan=1 colspan=1>Standard hand-written</td></tr><tr><td rowspan=1 colspan=1>a photo of a person {}.a video of a person {.a example of a person {}.a demonstration of a person {.a photo of the person {.a video of the person {}.a example of the person {}.a demonstration of the person {}.a photo of a person using {.a video of a person using {. a example of a person using {}.a demonstration of a person using {}.a photo of the person using {.a video of the person using {.a example of the person using {.a demonstration of the person using {}.a photo of a person doing {.a video of a person doing {}.a example of a person doing {.a demonstration of a person doing {.a photo of the person doing {.a video of the person doing {.a example of the person doing {}. a demonstration of the person doing {.a photo of a person during {.a video of a person during {}.a example of a person during {.a demonstration of a person during {.a photo of the person during {}.a video of the person during {.a example of the person during {.a demonstration of the person during {}.a photo of a person performing {}.a video of a person performing {.a example of a person performing {}.a demonstration of a person performing {}.a photo of the person performing {.a video of the person performing {.a example of the person performing {.a demonstration of the person performing {}.a photo of a person practicing {}.a video of a person practicing {. a example of a person practicing {.a demonstration of a person practicing {.a photo of the person practicing {.a video of the person practicing {.a example of the person practicing {}.a demonstration of the person practicing {.</td></tr></table>
|
| 324 |
+
|
| 325 |
+
<table><tr><td>RESISC 45</td><td></td></tr><tr><td>CuPL hand-written</td><td>Standard hand-written</td></tr><tr><td>Describe a satellite photo of a(n) {} Describe a(n) {} as it would appear in an aerial image How can you identify a(n) {} in an aerial photo? Describe the satellite photo of a(n) { Describe an aerial photo of a(n) {}</td><td>satellite imagery of {}. aerial imagery of {}. satellite photo of {}. aerial photo of {}. satellite view of {}. aerial view of {}. satellite imagery of a {}. aerial imagery of a {}. satellite photo of a {. aerial photo of a {}. satellite view of a {}. aerial view of a {. satellite imagery of the {}. aerial imagery of the {. satellite photo of the {. aerial photo of the {. satellite view of the {}. aerial view of the {}.</td></tr></table>
|
| 326 |
+
|
| 327 |
+
<table><tr><td colspan="2"></td></tr><tr><td colspan="2">Birdsnap CuPL hand-writen</td></tr><tr><td colspan="2">Describe what the bird {} looks like: a photo of a {},a type of bird. Describe the bird {}:</td></tr><tr><td colspan="2">What are the identifying characteristics of the bird {}?</td></tr><tr><td>Flowers 102 CuPL hand-written</td><td>Standard hand-written</td></tr><tr><td>Describe how to identify a(n) {},a type of flower What does a(n) { flower look like?</td><td>a photo of a {},a type of flower."</td></tr><tr><td>CIFAR-10 CuPL hand-written</td><td>Standard hand-written</td></tr><tr><td>Describe what a(n) {} looks like Describe a(n) {}: What are the identifying characteristics of a(n) {}?</td><td>a photo of a {}. a blurry photo of a {. a black and white photo of a {}. a low contrast photo of a {}. a high contrast photo of a {}. a bad photo of a {. a good photo of a {}. a photo of a small {}. a photo of a big {. a photo of the {}. a blurry photo of the {}. a black and white photo of the {}. a low contrast photo of the {}. a high contrast photo of the {}. a bad photo of the {}. a good photo of the {}. a photo of the small {}.</td></tr><tr><td colspan="1" rowspan="1">CIFAR-100</td><td colspan="1" rowspan="1"></td></tr><tr><td colspan="1" rowspan="1">CuPL hand-written</td><td colspan="1" rowspan="1">Standard hand-written</td></tr><tr><td colspan="1" rowspan="2">Describe a photo of a(n) {:What are the identifying characteristics of a(n) {}?Describe what a(n) {} looks like:Describe a(n) {}:</td><td colspan="1" rowspan="2">a photo of a {}.a blurry photo of a {}.a black and white photo of a {.a low contrast photo of a {}.a high contrast photo of a {}.a bad photo of a {}.a good photo of a {}.a photo of a small {.a photo of a big {.a photo of the {}.a blurry photo of the {}.a black and white photo of the {}.a low contrast photo of the {}.a high contrast photo of the {}.a bad photo of the {}.a good photo of the {}.a photo of the small {}.a photo of the big {.</td></tr><tr><td colspan="1" rowspan="1"></td></tr></table>
|
| 328 |
+
|
| 329 |
+
# B CUPL BASE PROMPTS
|
| 330 |
+
|
| 331 |
+
The three general sentences used in the base prompt setting are:
|
| 332 |
+
|
| 333 |
+
Describe what a/the looks like: Describe a/the : What are the identifying characteristics of a/the ?
|
| 334 |
+
|
| 335 |
+
Here we specify the type filled in for each of the examined datasets, as well as the article used for that dataset $\mathbf { \dot { a } } ( \mathbf { n } ) ^ { \prime }$ or ‘the’):
|
| 336 |
+
|
| 337 |
+
<table><tr><td>Dataset</td><td>Base LLM-prompt type specification</td></tr><tr><td>ImageNet</td><td>a(n) {}</td></tr><tr><td>DTD</td><td>the texture {}</td></tr><tr><td>StanfordCars SUN397</td><td>the car {}</td></tr><tr><td>Food 101</td><td>a(n)0</td></tr><tr><td></td><td>the food {</td></tr><tr><td>FGVC Aircraft</td><td>the aircraft {}</td></tr><tr><td>Oxford Pets</td><td>a pet </td></tr><tr><td>Caltech101</td><td>a(n){</td></tr><tr><td>CIFAR-10</td><td>a(n)</td></tr><tr><td>CIFAR-100</td><td>a(n)</td></tr><tr><td>Flowers 102</td><td>the flower {}</td></tr><tr><td>Kinetics-700</td><td></td></tr><tr><td></td><td>the action of {}</td></tr><tr><td>UCF101</td><td>the action of {}</td></tr><tr><td>RESISC45</td><td>a satellite photo of {}</td></tr><tr><td>Birdsnap</td><td>the bird {}</td></tr></table>
|
| 338 |
+
|
| 339 |
+
# C EVALUATION METRIC
|
| 340 |
+
|
| 341 |
+
<table><tr><td rowspan=1 colspan=1>1eegee</td><td rowspan=1 colspan=1>DLI</td><td rowspan=1 colspan=1>srsrr prlrers</td><td rowspan=1 colspan=1>L30300</td><td rowspan=1 colspan=1>Toopoon</td><td rowspan=1 colspan=1>FAVTileer</td><td rowspan=1 colspan=1>sod porrt</td><td rowspan=1 colspan=1>Crreeaer</td><td rowspan=1 colspan=1>TirsionIS</td><td rowspan=1 colspan=1>UUUIII</td><td rowspan=1 colspan=1>Trrreeisieon</td><td rowspan=1 colspan=1>PPSSSSS</td><td rowspan=1 colspan=1>CIPAIII1</td><td rowspan=1 colspan=1>CIIPPPPI0</td><td rowspan=1 colspan=1>Prrspg</td></tr></table>
|
| 342 |
+
|
| 343 |
+
<table><tr><td rowspan=1 colspan=1>Acc.|Acc.</td><td rowspan=1 colspan=1>Acc.</td><td rowspan=1 colspan=1>Acc.</td><td rowspan=1 colspan=1>Acc.</td><td rowspan=1 colspan=1>Acc.</td><td rowspan=1 colspan=1>Meanperclass</td><td rowspan=1 colspan=1>Meanperclass</td><td rowspan=1 colspan=1>Meanperclass</td><td rowspan=1 colspan=1>Meanperclass</td><td rowspan=1 colspan=1>Acc.</td><td rowspan=1 colspan=1>Mean(top1,top5)</td><td rowspan=1 colspan=1>Acc.</td><td rowspan=1 colspan=1>Acc.</td><td rowspan=1 colspan=1>Acc.</td><td rowspan=1 colspan=1>Acc.</td></tr></table>
|
| 344 |
+
|
| 345 |
+
# D OPEN-SOURCE LLM
|
| 346 |
+
|
| 347 |
+
While GPT-3 (Brown et al., 2020) demonstrates higher performance on a number of tasks compared to smaller open-source models, open-source models are sometime more accessible. We therefore show improvement using GPT-J-6B (Wang & Komatsuzaki, 2021), a small open-source model available on HuggingFace (Wolf et al., 2019). We find that we are able to surpass human written prompts with prompts generated by this model as shown in Table, though we still fall short of those generated by GPT-3. Additionally, we employ a number of strategies to increase the accuracy of the lower quality GPT-J-6B generations. First, we generate at a lower temperature (0.3) to prevent irrelevant or nonsensical generations, which we find occur more frequently in smaller models. Additionally, we generate 5 times more Image-prompts per LLM-prompt than we do when using GPT-3 (Brown et al., 2020). We also add punctuation to the end of all LLM-prompts to encourage the LLM to begin new sentences. Finally, we filter out any Image-prompts which do not contain the name of the ImageNet category they are meant to describe, as well as remove a number of unicode characters from the generations (e.g. $\mathbf { \dot { u } } _ { \mathbf { \lambda } } ( 0 1 9 ^ { \cdot }$ ). We present these findings as a way to make $\mathrm { { C u P L } }$ a more accessible options until large high performance models become available to the public.
|
| 348 |
+
|
| 349 |
+
Table 4: CuPL with an open-source model. CuPL is able to improve over hand-written baselines even for smaller open-source models.
|
| 350 |
+
|
| 351 |
+
<table><tr><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>ImageNet</td></tr><tr><td rowspan=1 colspan=1>standard</td><td rowspan=1 colspan=1>75.54</td></tr><tr><td rowspan=1 colspan=1>CuPL(GPT-J-6B)</td><td rowspan=1 colspan=1>75.62</td></tr><tr><td rowspan=1 colspan=1>CuPL (GPT-3)</td><td rowspan=1 colspan=1>76.69</td></tr></table>
|
| 352 |
+
|
| 353 |
+
# E SINGLE SENTENCE BASELINE
|
| 354 |
+
|
| 355 |
+
Table 5: Single sentence baselines. Comparison of a single hand-written Imageprompt template with a single handle written LLM-prompt as well as a single CuPL generated Image-prompt.
|
| 356 |
+
|
| 357 |
+
<table><tr><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>ImageNet</td></tr><tr><td rowspan=1 colspan=1>a photo of a{</td><td rowspan=1 colspan=1>73.46</td></tr><tr><td rowspan=1 colspan=1>CuPL(1 hand-written)</td><td rowspan=1 colspan=1>75.71</td></tr><tr><td rowspan=1 colspan=1>CuPL (1 generated)</td><td rowspan=1 colspan=1>74.24</td></tr></table>
|
| 358 |
+
|
| 359 |
+
One of the primary benefits of $\mathrm { { C u P L } }$ is that it decreases the amount of necessary hand-engineering. However, this could also be done by decreasing the number of total hand-written templates used, which comes at a loss in performance. We present this as a ‘low effort’ baseline, where we use only the hand constructed template of ‘a photo of a $\{ \} ^ { \ast }$ . We compare this with two CuPL baselines. The first is the baseline in which we also only construct one hand written template: ‘Describe what a $\{ \}$ looks like’. We then use this to generate 10 Image-prompts. The second baseline is a single CuPL generated sentence, generated with the prompt ‘Describe what a $\{ \}$ looks like’. For this experiment, we generate at a temperature of 0.3 as we find that higher tempuratures are only helpful when we are able to ensemble many diverse prompts, not when we are limited to one. We find that $\mathrm { { C u P L } }$ outperforms a single hand-written template under both of these settings, as shown in Table 5.
|
| 360 |
+
|
| 361 |
+
# F ROBUSTNESS
|
| 362 |
+
|
| 363 |
+
In addition to the previously mentioned benefits of open vocabulary models, one of the important advances made by CLIP (Radford et al., 2021) is an increased robustness on out-of-distribution data. Fine-tuning has been shown to degrade performance on out-of-distribution tasks (Wortsman et al., 2022), however zero-shot CLIP is robust to these distribution shifts. We show improvement on two common distribution shifts in Table 6, demonstrating that CuPL maintains the robustness of CLIP.
|
| 364 |
+
|
| 365 |
+
Table 6: Robustness of CuPL. CuPL accuracy on two common ImageNet variants, using CuPL ImageNet Image-prompts. CuPL improves performance on both of these variants, demonstrating that CuPL improves accuracy on in-distribution tasks, while maintaining robustness to distribution shifts.
|
| 366 |
+
|
| 367 |
+
<table><tr><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>ImageNet(Deng et al., 2009)</td><td rowspan=1 colspan=1>ImageNet-V2(Recht et al., 2019)</td><td rowspan=1 colspan=1>ImageNet-Sketch(Wang et al., 2019)</td></tr><tr><td rowspan=1 colspan=1>Standard</td><td rowspan=1 colspan=1>75.54</td><td rowspan=1 colspan=1>69.86</td><td rowspan=1 colspan=1>59.60</td></tr><tr><td rowspan=1 colspan=1>CuPL</td><td rowspan=1 colspan=1>76.69</td><td rowspan=1 colspan=1>70.85</td><td rowspan=1 colspan=1>60.05</td></tr></table>
|
| 368 |
+
|
| 369 |
+
# G CUPL IMPROVEMENT ANALYSIS
|
| 370 |
+
|
| 371 |
+
# G.1 VISUAL SIMILARITY ANALYSIS
|
| 372 |
+
|
| 373 |
+
In Figure 7, we provide initial analysis on the categories where the $\mathrm { { C u P L } }$ algorithm improves the most over standard hand-written prompts. We find that the improvement is not uniformly distributed, but rather some classes see a large improvement, while others see a decrease in per class accuracy. Interestingly, there are often two similar categories where one sees a large increase in accuracy and the other sees a decrease. For example, the ‘mushroom’ class has an approximately $4 0 \mathrm { p p }$ increase, while ‘agaric’ (a subclass of mushroom) is one of the classes with the largest drop in accuracy.
|
| 374 |
+
|
| 375 |
+
In order to better understand this phenomenon, we examine the change in accuracy between $\mathrm { C u P L }$ and the standard method of prompting in the image embedding space. Thus we are able to visualize the close relationship between categories like ‘agaric’ and ‘mushroom’. In order to be able to visualize the high dimensional CLIP image embedding in two dimensions, we utilize the t-distributed stochastic neighbor embedding algorithm (Van der Maaten & Hinton, 2008). Figure 8 visualizes image features (reduced into two dimensions) in relation to CuPL improvement.
|
| 376 |
+
|
| 377 |
+
As was suggested by Figure 7, we see in Figure 8 that when there is a class that has a large increase in accuracy with CuPL prompts (‘mushroom’, ‘graduation cap’, ‘monitor’) there is often a decrease in class accuracy for a visually related class. This means that when choosing between two similar or co-occuring classes, CuPL has a different distribution of classification than the standard method (e.g. the standard method prefers ‘canoe’ over ‘paddle’ much more strongly than CuPL). This suggests that the overall accuracy improvement of CuPL over the standard method may come (at least in part) from better distinguishing between two visually similar classes. While it may be over-correcting from the mistakes of the standard method (as demonstrated by the drop in accuracy in one of the two similar classes), the CuPL predictions appear to be overall more accurate, as demonstrated by the overall higher accuracy.
|
| 378 |
+
|
| 379 |
+
# G.2 CO-OCCURRENCES BETWEEN OBJECTS
|
| 380 |
+
|
| 381 |
+
Many of the frequently confused pairs in Figure 8 are objects that are likely to occur in an image (i.e. ‘canoe’-‘paddle’ or ’graduation cap’-‘academic gown’ or ’monitor’-‘desk’). One potential benefit of CuPL captions is that they are able to capture co-occurrences as well. For example, one CuPL prompt for the ‘canoe’ class is A canoe is typically a narrow boat with pointed ends that is propelled with a paddle. This caption contains the word ‘paddle’ which is frequently confused with ‘canoe’ and likely to be present in images, even where the correct label is ‘canoe’. We therefore investigate the effectiveness of CuPL captions on images which contain more than one ImageNet object.
|
| 382 |
+
|
| 383 |
+
We attain this by using the ImageNet-ReaL dataset (Beyer et al., 2020) which relabels ImageNet images with all applicable labels, so an image with both a ‘canoe’ and a ‘paddle’ would have both
|
| 384 |
+
|
| 385 |
+
# Image Embedding vs CuPL improvement
|
| 386 |
+
|
| 387 |
+

|
| 388 |
+
Figure 8: Visualizing of image embedding of ImageNet classes compared to $\mathbf { C u P L }$ improvement on that class. Each point on this figure represents the average image embedding of an ImageNet class, which has been reduced to two dimentions using t-sne (Van der Maaten & Hinton, 2008). We see that when there is a class with a large improvement compared to the baseline, it is often visually similar to a class which has a decrease in accuracy. This suggests that CuPL’s improved accuracy may be due in part to an increased ability to distinguish similar classes compared to the baseline.
|
| 389 |
+
|
| 390 |
+
labels. We then tag images as having multiple ImageNet objects or only one ImageNet object based on the ReaL dataset. Finally, we compute ImageNet accuracy across each of these two sets (using standard ImageNet labels). Results are given in Table 7.
|
| 391 |
+
|
| 392 |
+
Table 7: Standard versus CuPL accuracy based on number of ImageNet classes present in image. We use the ImageNet-ReaL dataset (Beyer et al., 2020) to find images which have more than one applicable ImageNet label. We then present the accuracy for standard prompts and $\mathrm { C u P L }$ prompts using standard ImageNet labels, split by images which contain only one possible ImageNet class and images which may contain multiple classes.
|
| 393 |
+
|
| 394 |
+
<table><tr><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>One class present (85.1% of ims)</td><td rowspan=1 colspan=1>Multiple classes present (14.9% of ims)</td></tr><tr><td rowspan=1 colspan=1>Standard</td><td rowspan=1 colspan=1>79.89</td><td rowspan=1 colspan=1>51.59</td></tr><tr><td rowspan=1 colspan=1>CuPL</td><td rowspan=1 colspan=1>80.79</td><td rowspan=1 colspan=1>53.58</td></tr></table>
|
| 395 |
+
|
| 396 |
+
# H ERROR ANALYSIS
|
| 397 |
+
|
| 398 |
+
In Figure 9, we present an error analysis of our model using two different metrics. The first is an analysis between the model prediction and the correct class using the visual similarity of these labels. To capture this, we first attain an average visual embedding of each class by taking the mean of each image in that class and then normalizing that mean. Then for each class we rank how similar each of the other 999 classes are by the distance between these embeddings. If the models makes an incorrect prediction, but it predicts the class with the closest embedding to the correct label, then we refer to this as an image offset of 1.
|
| 399 |
+
|
| 400 |
+
Additionally, we examine the prediction errors in terms of the linguistic similarity of the labels. We do this with the WordNet (Miller, 1995) similarity of two labels. For example, if the label of the prediction and the ground-truth label share the same parent in the WordNet tree, that is a WordNet offset of 2.
|
| 401 |
+
|
| 402 |
+
While slight, there is a difference in the errors made by CuPL compared to the errors made by the baseline as shown in Figure 9. CuPL is more likely to have an error that has an image offset of 1 than the baseline. However, the baseline is more likely to have an error that has a WordNet offset of 1 than CuPL. This implies that CuPL may be taking advantage of the visually descriptive language of the captions, as even when the model makes errors, they tend to favor categories that are visually similar to the ground truth. However, the baseline method does not have visual descriptions in its Image-prompts which may lead to its errors aligning more linguistically with the ground-truth.
|
| 403 |
+
|
| 404 |
+

|
| 405 |
+
Figure 9: Error analysis of $\mathbf { C u P L }$ and baseline comparing models errors visually and linguistically to ground truth labels. We compare the errors made by $\mathrm { { C u P L } }$ to the errors made by the baseline methods. We find that the errors made by $\mathrm { C u P L }$ are more likely to be the most visually similar class to the ground truth label when compared to the errors made by the baseline. However, the errors made by the baseline are more likely to be the most linguistically similar class according to the WordNet (Miller, 1995) heirarchy. This suggests that visual information is being extracted from the CuPL descriptions to make visually consistent predictions.
|
| 406 |
+
|
| 407 |
+

|
| 408 |
+
TSNE of text embeddings of Image-prompts generated by different LLM-prompts
|
| 409 |
+
Figure 10: Visualization of embeddings of Image-prompts generated with various LLMprompts. Each point represents the image embedding of one Image-prompts for the stated category with has been reduced to two dimensions using t-sne (Van der Maaten & Hinton, 2008). Imageprompts with the same color are generated by the same LLM-prompts.
|
| 410 |
+
|
| 411 |
+
# I IMAGE-PROMPT DISTRIBUTION
|
| 412 |
+
|
| 413 |
+
When generating Image-prompts, we use an ensemble of prompts generated by different LLMprompts (e.g. ‘What does a $\{ \}$ look like?). As we find that the diversity of Image-prompts is correlated with accuracy, it is valuable to understand how different LLM-prompts affect the diversity of Image-prompts. To accomplish this, we visualize the text embedding of Image-prompts for a selection of classes using t-sne (Van der Maaten & Hinton, 2008) dimension reduction. We then color Image-prompts that were generated by the same LLM-prompt. As shown in Figure 10, we find that while there is a slight clustering of Image-prompts by LLM-prompts, there is also a large amount of overlap.
|
| 414 |
+
|
| 415 |
+
# J TEMPERATURE ANALYSIS
|
| 416 |
+
|
| 417 |
+
We provide several further analyses of the effect of temperature in prompt generation. First, we visualize the distribution of Image-prompts that have been generated with a variety of different temperatures. We do this by selecting prompts for 3 different ImageNet classes at 3 different temperatures. We then perform dimentionality reduction on the text embeddings of these prompts in order to visualize their distribution. As shown in Figure 11, Image-prompts generated with a temperature of 0.1 are clustered in a few different locations. Image-prompts generated with a temperature of 0.5 are more widely, and Image-prompts generated with a temperature of 0.9 have a similar, but even wider distribution.
|
| 418 |
+
|
| 419 |
+
Additionally in Section K, we give all generated prompts for the ImageNet class ‘Tench’ at three different temperatures. At the lowest temperature, the generated Image-prompts are nearly identical when generated with the same LLM-prompts. As the temperature increases, so does the difference in the generated prompts.
|
| 420 |
+
|
| 421 |
+

|
| 422 |
+
Figure 11: Visualization of embeddings of Image-prompts generated with various temperatures. Each point represents the image embedding of one Image-prompts for the stated category with has been reduced to two dimensions using t-sne (Van der Maaten & Hinton, 2008). Prompts generated with a higher temperature cover a wider distribution.
|
| 423 |
+
|
| 424 |
+
# K EXAMPLE GENERATED IMAGE-PROMPTS
|
| 425 |
+
|
| 426 |
+
A selection of LLM-generated image-prompts for a subset of ImageNet categories. We give all 50 image-prompts for the first ImageNet category of “Tench” and then 10 randomly selected prompts for a number of randomly selected ImageNet categories.
|
| 427 |
+
|
| 428 |
+
# K.1 ALL GENERATED IMAGE-PROMPTS FOR “TENCH” CATEGORY
|
| 429 |
+
|
| 430 |
+
# Temperature $\mathbf { \mu = 0 . 9 9 }$
|
| 431 |
+
|
| 432 |
+
"A tench is a freshwater fish of the carp family.",
|
| 433 |
+
"A tench is a freshwater fish that is typically brown or olive in
|
| 434 |
+
color.",
|
| 435 |
+
"A tench is a fresh water fish that can grow up to 2 feet in length.",
|
| 436 |
+
"A tench is a freshwater fish of the family Cyprinidae.",
|
| 437 |
+
"A tench is a freshwater fish of the carp family.",
|
| 438 |
+
"A tench is a freshwater fish with a dark green back and light-colored
|
| 439 |
+
sides.",
|
| 440 |
+
"Tench are a freshwater fish found in Europe.",
|
| 441 |
+
"A tench is a small freshwater fish in the carp family.",
|
| 442 |
+
"A tench is a heavyset freshwater fish with a mottled brown body and a
|
| 443 |
+
small, flat head.",
|
| 444 |
+
"A tench is a freshwater fish that looks similar to a carp.",
|
| 445 |
+
"A tench is a freshwater fish in the carp family.",
|
| 446 |
+
"A tench is a freshwater fish of the Cyprinidae family.",
|
| 447 |
+
"The tench is a freshwater fish of the Cyprinidae family.",
|
| 448 |
+
"The tench is a fresh-water fish in the family Cyprinidae.",
|
| 449 |
+
"The easiest way to identify a tench is by its herringbone-patterned
|
| 450 |
+
scales.",
|
| 451 |
+
"A tench is a freshwater fish of the carp family.",
|
| 452 |
+
"Tench are a freshwater fish found in Europe.",
|
| 453 |
+
"Tench have a large, slimy body with scales that have a green hue.",
|
| 454 |
+
"The tench is a freshwater fish belonging to the carp family.",
|
| 455 |
+
"A tench is a freshwater fish of the Cynoglossidae family.",
|
| 456 |
+
"A tench is a freshwater fish in the carp family.",
|
| 457 |
+
"Tensch are freshwater fish with Olive Green backs, shading to Yellowish
|
| 458 |
+
on the sides.",
|
| 459 |
+
"A tench looks like a green freshwater fish with a brownish hue.",
|
| 460 |
+
"A tench looks like a freshwater fish with a dark olive-green back,
|
| 461 |
+
fading to yellowish-brown on the sides.",
|
| 462 |
+
"A tench usually has olive-green skin with dark spots, and a
|
| 463 |
+
orange-yellow underbelly.",
|
| 464 |
+
"Tench are a freshwater fish that can grow up to $7 0 \mathrm { c m }$ long! They have
|
| 465 |
+
olive-brown skin with dark spots, and their meat is white and firm.",
|
| 466 |
+
"A tench is a freshwater fish with a sturdy body and a greenish-brown
|
| 467 |
+
coloration.",
|
| 468 |
+
"A tench is a freshwater fish that can grow up to about two feet long.",
|
| 469 |
+
"A tench is a freshwater fish in the carp family.",
|
| 470 |
+
"A tench is a large, freshwater fish with a thick body and large head.",
|
| 471 |
+
"The image is of a tench fish swimming in water.",
|
| 472 |
+
"The image is of a tench fish swimming in a pond.",
|
| 473 |
+
"The tench is a freshwater fish native to Europe.",
|
| 474 |
+
"This image shows a large, dark green tench swimming in a pond.",
|
| 475 |
+
"An image of a tench from the internet would likely show a dark green
|
| 476 |
+
fish with a lighter underside.",
|
| 477 |
+
"The image is of a tench fish.",
|
| 478 |
+
"The image is of a tench fish on a white background.",
|
| 479 |
+
"A tench is a freshwater fish of the Cyprinidae family.",
|
| 480 |
+
"The image is of a tench swimming in a murky pond.",
|
| 481 |
+
"In the image, a tench swims in a pond with lily pads.",
|
| 482 |
+
" A tench in a river.",
|
| 483 |
+
"A tench (Tinca tinca) is a freshwater fish in the carp family that is
|
| 484 |
+
found throughout Europe.",
|
| 485 |
+
" Tench (Tinca tinca), a member of the carp family (Cyprinidae), native
|
| 486 |
+
to Eurasia.",
|
| 487 |
+
" A tench, a freshwater fish in the family Cyprinidae.",
|
| 488 |
+
" The tench (Tinca tinca) is a freshwater fish of the cyprinid family
|
| 489 |
+
found throughout Eurasia.",
|
| 490 |
+
" A tench in a Finnish lake.",
|
| 491 |
+
"A tench (Tinca tinca) is a freshwater fish belonging to the carp family
|
| 492 |
+
(Cyprinidae).",
|
| 493 |
+
"A tench in a fishpond.",
|
| 494 |
+
" The common tench is a freshwater fish of the cyprinid family found
|
| 495 |
+
throughout Eurasia.",
|
| 496 |
+
"Tench (Tinca tinca) in a pond."
|
| 497 |
+
|
| 498 |
+
# Temperature $\mathbf { \tau } = \mathbf { 0 . 5 }$
|
| 499 |
+
|
| 500 |
+
"A tench is a freshwater fish that is typically greenish-brown in color with a brassy sheen.",
|
| 501 |
+
|
| 502 |
+
"A tench is a freshwater fish that typically has a dark green back, light brown sides, and a white belly.",
|
| 503 |
+
|
| 504 |
+
"A tench is a freshwater fish that can grow up to two feet long.", "Tench are a freshwater fish found in Europe.",
|
| 505 |
+
|
| 506 |
+
"A tench is a freshwater fish that is typically olive green in color with
|
| 507 |
+
dark spots.",
|
| 508 |
+
"A tench is a freshwater fish that is typically olive green in color with
|
| 509 |
+
a brownish tint.",
|
| 510 |
+
"A tench is a freshwater fish of the Cyprinidae family.",
|
| 511 |
+
"Tench are a freshwater fish found in Europe.",
|
| 512 |
+
"A tench is a freshwater fish that has a dark green back, light brown
|
| 513 |
+
sides, and a white belly.",
|
| 514 |
+
"A tench is a freshwater fish that is typically olive-green in color with
|
| 515 |
+
a brownish dorsal fin.",
|
| 516 |
+
"A tench is a freshwater fish of the cyprinid family.",
|
| 517 |
+
"A tench is a freshwater fish of the carp family.",
|
| 518 |
+
"A tench is a freshwater fish that is typically olive green in color with
|
| 519 |
+
a brownish back.",
|
| 520 |
+
"The tench is a freshwater fish of the carp family Cyprinidae.",
|
| 521 |
+
"A tench is a freshwater fish that is typically greenish-brown in
|
| 522 |
+
color.",
|
| 523 |
+
"A tench is a freshwater fish of the carp family.",
|
| 524 |
+
"A tench is a freshwater fish of the carp family.",
|
| 525 |
+
"Tench have olive green backs and flanks, with yellowish bellies.",
|
| 526 |
+
"A tench is a freshwater fish of the carp family.",
|
| 527 |
+
"A tench is a freshwater fish of the cyprinid family.",
|
| 528 |
+
"A tench is a freshwater fish that can grow up to 30 inches long.",
|
| 529 |
+
"A tench is a freshwater fish that is typically greenish-brown in
|
| 530 |
+
color.",
|
| 531 |
+
"A tench is a freshwater fish that can grow up to about two feet long.",
|
| 532 |
+
"A tench is a freshwater fish with a brownish-green back and sides, and a
|
| 533 |
+
yellowish-brown belly.",
|
| 534 |
+
"A tench is a freshwater fish that can grow up to two feet long.",
|
| 535 |
+
"A tench is a freshwater fish that looks similar to a carp.",
|
| 536 |
+
"A tench is a freshwater fish that is typically greenish-brown in
|
| 537 |
+
color.",
|
| 538 |
+
"A tench is a freshwater fish that is part of the carp family.",
|
| 539 |
+
"A tench is a freshwater fish of the cyprinid family.",
|
| 540 |
+
"A tench is a freshwater fish that can grow up to two feet long.",
|
| 541 |
+
"The image is of a tench fish swimming in water.",
|
| 542 |
+
"The image is of a tench fish swimming in a pond.",
|
| 543 |
+
"The image is of a tench fish swimming in a pond.",
|
| 544 |
+
"The image is of a tench fish swimming in a pond.",
|
| 545 |
+
"The image is of a tench fish swimming in a pond.",
|
| 546 |
+
"In the image, a tench is swimming in a pond with lily pads.",
|
| 547 |
+
"The image is of a tench fish swimming in a pond.",
|
| 548 |
+
"The image is of a tench fish swimming in a pond.",
|
| 549 |
+
"The image is of a tench fish swimming in a pond.",
|
| 550 |
+
"The image is of a tench fish swimming in a pond.",
|
| 551 |
+
"A tench fish, native to Europe, characterized by its greenish-brown
|
| 552 |
+
color and spots.",
|
| 553 |
+
" A tench (Tinca tinca) in a pond.",
|
| 554 |
+
"A tench (Tinca tinca) is a freshwater fish belonging to the carp family
|
| 555 |
+
(Cyprinidae).",
|
| 556 |
+
"A tench (Tinca tinca) is a freshwater fish in the carp family.",
|
| 557 |
+
"A tench (Tinca tinca) is a freshwater fish in the carp family
|
| 558 |
+
(Cyprinidae).",
|
| 559 |
+
" A tench in a river.",
|
| 560 |
+
"A tench (Tinca tinca) is a freshwater fish in the carp family
|
| 561 |
+
(Cyprinidae).",
|
| 562 |
+
"A tench (Tinca tinca) in a pond.",
|
| 563 |
+
" A tench (Tinca tinca) in a garden pond.",
|
| 564 |
+
" A tench in a river."
|
| 565 |
+
|
| 566 |
+
# Temperature $\mathbf { \mu } = \mathbf { 0 . 1 }$
|
| 567 |
+
|
| 568 |
+
"A tench is a freshwater fish that is typically olive green in color with dark spots.",
|
| 569 |
+
|
| 570 |
+
"A tench is a freshwater fish that can grow up to 30 inches long.",
|
| 571 |
+
"A tench is a freshwater fish that can grow to a length of over two
|
| 572 |
+
feet.",
|
| 573 |
+
"A tench is a freshwater fish that can grow up to two feet long.",
|
| 574 |
+
"A tench is a freshwater fish that can grow up to two feet long.",
|
| 575 |
+
"A tench is a freshwater fish that is typically olive green in color with
|
| 576 |
+
dark spots.",
|
| 577 |
+
"A tench is a freshwater fish that can grow up to two feet long.",
|
| 578 |
+
"A tench is a freshwater fish that can grow up to two feet long.",
|
| 579 |
+
"A tench is a freshwater fish that can grow up to two feet long.",
|
| 580 |
+
"A tench is a freshwater fish that is typically olive green in color with
|
| 581 |
+
dark spots.",
|
| 582 |
+
"A tench is a freshwater fish of the carp family.",
|
| 583 |
+
"A tench is a freshwater fish of the carp family.",
|
| 584 |
+
"A tench is a freshwater fish of the carp family.",
|
| 585 |
+
"A tench is a freshwater fish of the carp family.",
|
| 586 |
+
"A tench is a freshwater fish of the carp family.",
|
| 587 |
+
"A tench is a freshwater fish of the carp family.",
|
| 588 |
+
"Tench have a dark green back, light olive sides, and a yellowish
|
| 589 |
+
belly.",
|
| 590 |
+
"A tench is a freshwater fish of the carp family.",
|
| 591 |
+
"A tench is a freshwater fish of the carp family.",
|
| 592 |
+
"A tench is a freshwater fish of the carp family.",
|
| 593 |
+
"A tench is a freshwater fish that can grow up to two feet long.",
|
| 594 |
+
"A tench is a freshwater fish that can grow up to two feet long.",
|
| 595 |
+
"A tench is a freshwater fish that can grow up to two feet long.",
|
| 596 |
+
"A tench is a freshwater fish that can grow up to two feet long.",
|
| 597 |
+
"A tench is a freshwater fish that is typically olive green in color with
|
| 598 |
+
a brownish dorsal side.",
|
| 599 |
+
"A tench is a freshwater fish that can grow up to two feet long.",
|
| 600 |
+
"A tench is a freshwater fish that can grow up to two feet long.",
|
| 601 |
+
"A tench is a freshwater fish that is typically olive green in color with
|
| 602 |
+
a brownish dorsal side.",
|
| 603 |
+
"A tench is a freshwater fish that can grow up to two feet long.",
|
| 604 |
+
"A tench is a freshwater fish that can grow up to two feet long.",
|
| 605 |
+
"The image is of a tench fish swimming in a pond.",
|
| 606 |
+
"The image is of a tench fish swimming in a pond.",
|
| 607 |
+
"The image is of a tench fish swimming in a pond.",
|
| 608 |
+
"The image is of a tench fish swimming in a pond.",
|
| 609 |
+
"The image is of a tench fish swimming in a pond.",
|
| 610 |
+
"The image is of a tench fish swimming in a pond.",
|
| 611 |
+
"The image is of a tench fish swimming in a pond.",
|
| 612 |
+
"The image is of a tench fish swimming in a pond.",
|
| 613 |
+
"The image is of a tench fish swimming in a pond.",
|
| 614 |
+
"The image is of a tench fish swimming in a pond.",
|
| 615 |
+
"A tench (Tinca tinca) is a freshwater fish in the carp family.",
|
| 616 |
+
"A tench (Tinca tinca) is a freshwater fish of the carp family
|
| 617 |
+
(Cyprinidae).",
|
| 618 |
+
"A tench (Tinca tinca) is a freshwater fish in the carp family.",
|
| 619 |
+
"A tench (Tinca tinca) is a freshwater fish in the carp family.",
|
| 620 |
+
"A tench (Tinca tinca) is a freshwater fish in the carp family.",
|
| 621 |
+
"A tench (Tinca tinca) is a freshwater fish in the carp family.",
|
| 622 |
+
"A tench (Tinca tinca) is a freshwater fish in the carp family.",
|
| 623 |
+
" A tench (Tinca tinca) in a garden pond.",
|
| 624 |
+
" A tench (Tinca tinca) in a garden pond.",
|
| 625 |
+
"A tench (Tinca tinca) is a freshwater fish of the carp family
|
| 626 |
+
(Cyprinidae)."
|
| 627 |
+
|
| 628 |
+
# K.2 SAMPLE GENERATED IMAGE-PROMPTS FOR RANDOMLY SELECTED IMAGENET CATEGORIES
|
| 629 |
+
|
| 630 |
+
"bubble":
|
| 631 |
+
|
| 632 |
+
"A bubble is a sustained period of inflated asset prices.",
|
| 633 |
+
|
| 634 |
+
"A bubble looks like a sphere of air.",
|
| 635 |
+
"A bubble is often characterized by rapidly increasing prices in an asset
|
| 636 |
+
or security, followed by a sharp decrease in prices.",
|
| 637 |
+
"A bubble looks like a small, round, thin film of soap filled with air.",
|
| 638 |
+
"A bubble looks like a round sphere of soap film.",
|
| 639 |
+
" \"A bubble being blown in the park.",
|
| 640 |
+
"A close-up of a soap bubble with a thin film of water in between two
|
| 641 |
+
layers of air.",
|
| 642 |
+
"A bubble is a spherical shape made up of a thin film of soap water.",
|
| 643 |
+
"A bubble is a circle of air surrounded by water.",
|
| 644 |
+
"A bubble looks like a round, thin layer of soap surrounding a pocket of
|
| 645 |
+
air."
|
| 646 |
+
|
| 647 |
+
# "kit fox":
|
| 648 |
+
|
| 649 |
+
"A kit fox is a small species of fox, about the size of a domestic cat.",
|
| 650 |
+
"You can identify a kit fox by its small size, its big ears, and its
|
| 651 |
+
long, bushy tail.",
|
| 652 |
+
" A kit fox laying on the ground in a desert habitat.",
|
| 653 |
+
"A kit fox is a small fox found in North America.",
|
| 654 |
+
"A kit fox is a small fox with a sleek coat of fur.",
|
| 655 |
+
"A kit fox is a small fox with large ears, a long, black-tipped tail, and
|
| 656 |
+
pale fur.",
|
| 657 |
+
"A kit fox has a reddish coat, with white patches on its chest and
|
| 658 |
+
throat.",
|
| 659 |
+
"This kit fox has a reddish coat and large ears.",
|
| 660 |
+
"A kit fox looks like a small fox with a pointed nose, large ears, and a
|
| 661 |
+
long, bushy tail.",
|
| 662 |
+
"A kit fox is a small species of fox."
|
| 663 |
+
"toy terrier":
|
| 664 |
+
"A toy terrier looks like a very small version of a terrier.",
|
| 665 |
+
"The image is of a toy terrier that is mostly white with brown spots.",
|
| 666 |
+
"You can identify a toy terrier by looking for a compact, short-legged
|
| 667 |
+
dog with a short muzzle.",
|
| 668 |
+
" Cute little guy.",
|
| 669 |
+
"Toy terriers are miniature versions of terriers, such as the Jack
|
| 670 |
+
Russell Terrier.",
|
| 671 |
+
"A toy terrier is a small, lightweight breed of dog.",
|
| 672 |
+
"The image is of a small, brown toy terrier.",
|
| 673 |
+
"A toy terrier typically has a long, narrow head with pointy ears, and a
|
| 674 |
+
small, compact body.",
|
| 675 |
+
"A toy terrier is a small, short-legged dog with a long body, pointy
|
| 676 |
+
nose, and large ears.",
|
| 677 |
+
"A small, brown and white toy terrier is sitting on a beige couch,
|
| 678 |
+
looking at the camera."
|
| 679 |
+
|
| 680 |
+
"mousetrap":
|
| 681 |
+
|
| 682 |
+
"In the image, there is a mousetrap made of wood and metal.",
|
| 683 |
+
"An image of a mousetrap from the internet would most likely show a
|
| 684 |
+
traditional wooden mousetrap with a metal spring.",
|
| 685 |
+
"A mousetrap is a device made to catch and kill mice.",
|
| 686 |
+
"A mousetrap is a small device that is used to catch mice.",
|
| 687 |
+
"The classic mousetrap consists of a wooden base with a metal spring
|
| 688 |
+
mounted on one end.",
|
| 689 |
+
"The mousetrap is a small wooden box with a metal spring inside.",
|
| 690 |
+
"The mousetrap is a simple device that has been used for centuries to
|
| 691 |
+
catch mice.",
|
| 692 |
+
"The classic mousetrap - simple, effective, and deadly.",
|
| 693 |
+
"The most common way to identify a mousetrap is by its small size and
|
| 694 |
+
rectangular shape.",
|
| 695 |
+
"A mousetrap typically has a wire or wooden frame that is baited with
|
| 696 |
+
food and springs open quickly to snap shut on the mouse when it attempts
|
| 697 |
+
to steal the bait."
|
| 698 |
+
"A dog sled is a vehicle on runners, typically with a thin frame and
|
| 699 |
+
a flat bottom, that is used to convey goods or passengers over snow or
|
| 700 |
+
ice.",
|
| 701 |
+
"A dog sled is a toboggan pulled by dogs, typically over snow.",
|
| 702 |
+
"A dog sled looks like a bed on runners that is pulled by dogs.",
|
| 703 |
+
"A dog sled is typically a heavy frame on runners that is pulled by one
|
| 704 |
+
or more dogs.",
|
| 705 |
+
"A dog sled is traditionally a sled pulled by dogs, used for
|
| 706 |
+
transportation, racing, or other purposes.",
|
| 707 |
+
" teamA dog sled team is a group of dogs that are harnessed together to
|
| 708 |
+
pull a sled.",
|
| 709 |
+
"A dog sled looks like a small, open vehicle that is pulled by one or
|
| 710 |
+
more dogs.",
|
| 711 |
+
"Dog sledding in winter.",
|
| 712 |
+
" pulled by huskiesThe image is of a dog sled pulled by huskies.",
|
| 713 |
+
"A dog sled looks like a large cart that is pulled by a team of dogs."
|
| 714 |
+
|
| 715 |
+
# "geyser":
|
| 716 |
+
|
| 717 |
+
"A geyser is a hot spring that periodically erupts, shooting a column of
|
| 718 |
+
water and steam into the air.",
|
| 719 |
+
"A geyser looks like a hole in the ground that sometimes spurts hot water
|
| 720 |
+
and steam into the air.",
|
| 721 |
+
"Geysers are hot springs that periodically spout water and steam into the
|
| 722 |
+
air.",
|
| 723 |
+
"The image is of a geyser erupting.",
|
| 724 |
+
"A geyser is a hot spring that periodically erupts, spraying water into
|
| 725 |
+
the air.",
|
| 726 |
+
"A geyser typically looks like a cone of rocks with a small hole at the
|
| 727 |
+
top.",
|
| 728 |
+
"A geyser is a hot spring where water intermittently boils, sending a jet
|
| 729 |
+
of hot water and steam into the air.",
|
| 730 |
+
"A geyser is a hot spring that periodically shoots a stream of hot water
|
| 731 |
+
and steam into the air.",
|
| 732 |
+
"The image is of a geyser shooting water high into the air.",
|
| 733 |
+
"A geyser looks like a column of water that shoots into the air and then
|
| 734 |
+
falls back down."
|
| 735 |
+
|
| 736 |
+
"Schipperke":
|
| 737 |
+
|
| 738 |
+
"A Schipperke is a small, Belgian breed of dog.",
|
| 739 |
+
"A Schipperke is a small black Belgian dog with a rat-like tail.",
|
| 740 |
+
"The image is of a black and white dog with pointy ears and a long
|
| 741 |
+
body.",
|
| 742 |
+
"A Schipperke is a small, black, Belgian breed of dog.",
|
| 743 |
+
"A Schipperke is a small, black, Belgian breed of dog that closely
|
| 744 |
+
resembles a fox.",
|
| 745 |
+
"A Schipperke is a small Belgian breed of dog that resembles a fox.",
|
| 746 |
+
"Schipperkes have a long, black coat and a pointed muzzle.",
|
| 747 |
+
"A Schipperke is a small dog breed with a fox-like appearance.","It’s a photo of a black and tan Schipperke dog standing in front of a
|
| 748 |
+
brick wall.",
|
| 749 |
+
"Black, small, spitz-type dog with a long, fox-like snout, large erect
|
| 750 |
+
ears, and a long, high-set tail."
|
| 751 |
+
|
| 752 |
+
"go-kart":
|
| 753 |
+
|
| 754 |
+
"A go-kart typically looks like a small car or buggy with a small engine
|
| 755 |
+
in the back.",
|
| 756 |
+
"A go-kart is a small vehicle with four wheels, a steering wheel, and a
|
| 757 |
+
gas pedal.",
|
| 758 |
+
"A go-kart is a small vehicle with a steering wheel, pedals, and an
|
| 759 |
+
engine.",
|
| 760 |
+
"Two young girls in go-karts race down a path in a park.",
|
| 761 |
+
"A go-kart is a small, lightweight vehicle with four wheels and a simple,
|
| 762 |
+
open frame.",
|
| 763 |
+
"A go-kart is a small, open-wheeled vehicle used for racing.",
|
| 764 |
+
"Two kids racing go-karts on a dirt track.",
|
| 765 |
+
"A go-kart is a small, racing car.",
|
| 766 |
+
"A go-kart typically looks like a small, open-wheeled car.",
|
| 767 |
+
"A go-kart is a small, lightweight vehicle with four wheels that is
|
| 768 |
+
propelled by a small engine."
|
| 769 |
+
|
| 770 |
+
"black-and-white colobus":
|
| 771 |
+
|
| 772 |
+
"The Black-and-White Colobus is a type of Old World monkey, found in
|
| 773 |
+
Africa.",
|
| 774 |
+
"A black-and-white colobus has long black fur, and a white face with a
|
| 775 |
+
black triangle around the eyes.",
|
| 776 |
+
"Colobus Monkey in the TreesThis elegant colobus monkey is swinging
|
| 777 |
+
through the trees in search of food.",
|
| 778 |
+
" monkeyIn this image, a black-and-white colobus monkey is shown perched
|
| 779 |
+
atop a tree branch.",
|
| 780 |
+
"The black-and-white colobus monkey is one of the most beautiful and
|
| 781 |
+
distinctive of all the colobus monkeys.",
|
| 782 |
+
"The black-and-white colobus monkey is a species of primate in the
|
| 783 |
+
Colobidae family.",
|
| 784 |
+
"Colobus monkeys are generally black with white patches on their face,
|
| 785 |
+
back, and sides.",
|
| 786 |
+
"The black-and-white colobus is a species of Old World monkey.",
|
| 787 |
+
" monkeyThe image is of a black-and-white colobus monkey sitting on a
|
| 788 |
+
tree branch.",
|
| 789 |
+
" monkeyIn the image, the black-and-white colobus monkey is sitting in a
|
| 790 |
+
tree."
|
| 791 |
+
|
| 792 |
+
# "sock":
|
| 793 |
+
|
| 794 |
+
"A sock usually has a cuff at the top, and a heel at the bottom.",
|
| 795 |
+
" A black sock with a white line running down the middle.",
|
| 796 |
+
"A sock is typically a garment worn on the feet and made from a soft
|
| 797 |
+
material, such as cotton.",
|
| 798 |
+
"A sock normally has a heel, toe and a cuff at the top.",
|
| 799 |
+
"A sock is a small amount of money that is given to someone without them
|
| 800 |
+
knowing.",
|
| 801 |
+
"A sock is an article of clothing worn on the feet.",
|
| 802 |
+
"A sock is a piece of clothing that is worn on the feet.",
|
| 803 |
+
"A sock is a tubular garment that covers the foot and ankle.",
|
| 804 |
+
"This image is of a blue and white striped sock.",
|
| 805 |
+
"There are many ways that you can identify a sock."
|
| 806 |
+
|
| 807 |
+
"Cocker Spaniel":
|
| 808 |
+
|
| 809 |
+
"A Cocker Spaniel is a medium sized dog with long, floppy ears, and a
|
| 810 |
+
silky coat that is usually either brown or black.",
|
| 811 |
+
"The Cocker Spaniel has a long floppy ears, a silky coat, and a bushy
|
| 812 |
+
tail.",
|
| 813 |
+
"A Cocker Spaniel has a long, black muzzle and big, brown eyes.",
|
| 814 |
+
"The Cocker Spaniel is a breed of dog.",
|
| 815 |
+
"An image of a Cocker Spaniel from the internet shows a small brown and
|
| 816 |
+
white dog with long floppy ears.",
|
| 817 |
+
"The image is of a Cocker Spaniel with short, brown fur and long, floppy
|
| 818 |
+
ears.",
|
| 819 |
+
"Cocker spaniels have long, floppy ears and a long, silky coat.",
|
| 820 |
+
"A Cocker Spaniel is a small to medium sized dog.",
|
| 821 |
+
"The image is of a light brown and white Cocker Spaniel standing on a
|
| 822 |
+
green grassy field with its head turned to the side.",
|
| 823 |
+
"A Cocker Spaniel has a long, silky coat that is usually either black,
|
| 824 |
+
brown, or golden."
|
| 825 |
+
|
| 826 |
+
"southern black widow":
|
| 827 |
+
|
| 828 |
+
"A southern black widow spider perched atop a web.",
|
| 829 |
+
"Female southern black widows have a black body with a red hourglass
|
| 830 |
+
shape on their abdomen.",
|
| 831 |
+
"The southern black widow is black with a red hourglass shape on its
|
| 832 |
+
belly.",
|
| 833 |
+
"Female southern black widow spiders are black with a characteristic red
|
| 834 |
+
hourglass-shaped mark on their ventral abdomen.",
|
| 835 |
+
" spiderThe image is of a large, black spider with a red hourglass shape
|
| 836 |
+
on its abdomen.",
|
| 837 |
+
"A southern black widow is a spider that is black with a red hourglass
|
| 838 |
+
shape on its abdomen.",
|
| 839 |
+
"A southern black widow spider is a small, black spider with a red
|
| 840 |
+
hourglass-shaped mark on its underside.",
|
| 841 |
+
"There’s an image on the internet of a southern black widow that’s really
|
| 842 |
+
cool.",
|
| 843 |
+
"A southern black widow can be identified by its black coloration with a
|
| 844 |
+
red hourglass shape on its abdomen.",
|
| 845 |
+
"A Southern black widow is a type of spider that is black with a red
|
| 846 |
+
hourglass shape on its belly."
|
| 847 |
+
|
| 848 |
+
# "catamaran":
|
| 849 |
+
|
| 850 |
+
"A catamaran is a sailboat that has two hulls, or wide bodies, that are
|
| 851 |
+
connected by beams.",
|
| 852 |
+
"The easiest way to identify a catamaran is by its two hulls.",
|
| 853 |
+
"A catamaran is a type of boat that has two parallel hulls.",
|
| 854 |
+
"A catamaran is a multi-hulled vessel with two parallel hulls of equal
|
| 855 |
+
size.",
|
| 856 |
+
"My dream boat! A sleek catamaran that can zip through the waves.",
|
| 857 |
+
"A catamaran is a multi-hulled vessel with two parallel hulls of equal
|
| 858 |
+
size.",
|
| 859 |
+
"The image is of a white catamaran with blue trim.",
|
| 860 |
+
"A catamaran is a type of boat that has two hulls, or platforms, that are
|
| 861 |
+
parallel to each other.",
|
| 862 |
+
"The image is of a yellow catamaran with white trim, sitting in calm
|
| 863 |
+
water.",
|
| 864 |
+
"A catamaran is a type of sailing vessel that consists of two parallel
|
| 865 |
+
hulls of equal size."
|
| 866 |
+
|
| 867 |
+
"beach":
|
| 868 |
+
|
| 869 |
+
".",
|
| 870 |
+
"Blue skies, white sands, and clear turquoise waters make this beach a
|
| 871 |
+
paradise.",
|
| 872 |
+
"A beach usually has sand and water.",
|
| 873 |
+
"Beach identification can be accomplished through the identification of
|
| 874 |
+
physical characteristics.",
|
| 875 |
+
"A beach is a naturally occurring feature of the landscape.",
|
| 876 |
+
"The sun sets over the ocean, casting a beautiful orange hue in the
|
| 877 |
+
sky.",
|
| 878 |
+
"A beach is a large body of water with sand or small rocks at the
|
| 879 |
+
shore.",
|
| 880 |
+
"In the image, the beach is Brilliant white with crystal blue waters.",
|
| 881 |
+
"The beach looks like a long strip of land next to the ocean.",
|
| 882 |
+
"A beach typically looks like a large, flat expanse of sand with some
|
| 883 |
+
rocks or other natural features nearby."
|
| 884 |
+
|
| 885 |
+
"rotary dial telephone":
|
| 886 |
+
|
| 887 |
+
"A rotary dial is a device used to dial telephone numbers.",
|
| 888 |
+
"Rotary dial telephone from the mid-20th century.",
|
| 889 |
+
"A rotary dial telephone is a phone with a circular dial on the front
|
| 890 |
+
face.",
|
| 891 |
+
"When looking at a rotary telephone, you can tell it is a rotary phone by
|
| 892 |
+
the Place the phone’s receiver on your ear and listen for a dial tone.",
|
| 893 |
+
"A rotary dial phone is an older model phone that has a circular device
|
| 894 |
+
with numbers on it that you rotate with your finger to dial a number.",
|
| 895 |
+
"A rotary dial telephone is a type of telephone that uses a mechanical
|
| 896 |
+
dial to select the telephone number that a user wishes to call.",
|
| 897 |
+
"History of the Rotary Dial Telephone.",
|
| 898 |
+
"A rotary dial telephone is an old-fashioned telephone that has a round
|
| 899 |
+
dial on the front of it.",
|
md/dev/4G1Sfp_1sz7/4G1Sfp_1sz7.md
ADDED
|
@@ -0,0 +1,367 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Generating Training Data with Language Models: Towards Zero-Shot Language Understanding
|
| 2 |
+
|
| 3 |
+
Yu Meng, Jiaxin Huang, Yu Zhang, Jiawei Han Department of Computer Science, University of Illinois at Urbana-Champaign {yumeng5,jiaxinh3,yuz9,hanj}@illinois.edu
|
| 4 |
+
|
| 5 |
+
# Abstract
|
| 6 |
+
|
| 7 |
+
Pretrained language models (PLMs) have demonstrated remarkable performance in various natural language processing tasks: Unidirectional PLMs (e.g., GPT) are well known for their superior text generation capabilities; bidirectional PLMs (e.g., BERT) have been the prominent choice for natural language understanding (NLU) tasks. While both types of models have achieved promising few-shot learning performance, their potential for zero-shot learning has been underexplored. In this paper, we present a simple approach that uses both types of PLMs for fully zero-shot learning of NLU tasks without requiring any task-specific data: A unidirectional PLM generates class-conditioned texts guided by prompts, which are used as the training data for fine-tuning a bidirectional PLM. With quality training data selected based on the generation probability and regularization techniques (label smoothing and temporal ensembling) applied to the fine-tuning stage for better generalization and stability, our approach demonstrates strong performance across seven classification tasks of the GLUE benchmark (e.g., 72.3/73.8 on MNLI- $. \mathrm { m } / \mathrm { m m }$ and 92.8 on SST-2), significantly outperforming zero-shot prompting methods and achieving even comparable results to strong few-shot approaches using 32 training samples per class1.
|
| 8 |
+
|
| 9 |
+
# 1 Introduction
|
| 10 |
+
|
| 11 |
+
Pretrained language models (PLMs) [5, 8, 11, 19, 34, 40, 41] have achieved human-level performance on natural language understanding (NLU) tasks [66, 67] when fine-tuned on a large amount of task-specific training data. However, such a supervised fine-tuning paradigm is drastically different from how humans perform these tasks: We barely need to see many task-specific training samples to perform well. Recently, many studies have revealed the intriguing few-shot learning potential of PLMs: By converting task descriptions to natural language prompts and injecting them into PLMs, prompt-based approaches [5, 13, 55, 56, 59] leverage task-specific information for better training data efficiency and have achieved remarkable few-shot results.
|
| 12 |
+
|
| 13 |
+
When prompt-based methods are applied to the zero-shot setting, however, the PLMs’ predictions are much less accurate. For example, GPT-3’s zero-shot performance is much degraded relative to its few-shot performance [5], especially on challenging tasks like natural language inference (NLI). Without any task-specific samples, it is indeed challenging for PLMs to effectively interpret the prompts that come in different formats and are unseen in the pretraining data. To familiarize PLMs with various prompts for zero-shot generalization to unseen tasks, a recent study proposes instruction tuning [70], which fine-tunes PLMs on a large collection of different tasks described by instructions. Despite its strong performance, its success is grounded in the large number of cross-task annotated datasets (e.g., train on many non-NLI tasks and transfer to NLI tasks) and the gigantic model size (e.g., hundreds of billions of parameters), posing great challenges for training and using them.
|
| 14 |
+
|
| 15 |
+
In this work, we study zero-shot learning of PLMs on NLU tasks without any task-specific or crosstask data. Motivated by the strong text generation power of recent PLMs [5, 23, 30, 52], we propose SuperGen, a Supervision Generation approach, wherein training data are created via a unidirectional PLM (i.e., the generator) which generates class-conditioned texts guided by label-descriptive prompts. A bidirectional PLM (i.e., the classifier) is then fine-tuned on the generated texts to perform the corresponding task. Both PLMs can be of moderate size to fit in typical research hardware (e.g., a GPT-2-sized [51] generator and a RoBERTaLarge-sized [34] classifier). With supervision automatically created by the generator, SuperGen eliminates the need for task-specific annotations and provides the classifier PLM with a larger amount of training data than in few-shot scenarios. We call such a setting zero-shot because the entire process does not need any human annotated data, either from the target task or other tasks. The major difference from previous methods is that we synthesize training data for the target task, whereas existing zeros-shot methods do not use any form of training data from the test domain (but may train on other domains) and directly perform inference on the target task.
|
| 16 |
+
|
| 17 |
+
Across seven classification tasks of the GLUE benchmark [66], SuperGen significantly outperforms the prompt-based zero-shot method and even achieves an overall better result in both average performance and stability than strong few-shot approaches that use 32 annotated samples per class. We identify several key factors to the strong performance of SuperGen through ablation studies: (1) selecting quality training data based on their generated probability, and (2) using label smoothing and temporal ensembling to regularize fine-tuning on generated data.
|
| 18 |
+
|
| 19 |
+
# 2 Related Work
|
| 20 |
+
|
| 21 |
+
# 2.1 Few-Shot and Zero-Shot Learning with PLMs
|
| 22 |
+
|
| 23 |
+
Instead of using a large amount of annotated training data for fine-tuning PLMs on downstream tasks, few-shot learning studies how to better leverage only a small amount of task-specific training data, a more realistic scenario in many applications. The most strict few-shot learning setting does not assume access to any unlabeled data or large validation sets for hyperparameter tuning [48], where prompt-based methods [5, 13, 33, 35, 55–57, 59, 63, 84] are prominently deployed to inject task descriptions into PLMs and make effective use of their language modeling capability for improved training data efficiency in low-data regimes. More broadly, semi-supervised learning additionally leverages unlabeled task-specific data, where data augmentation [7, 73], regularization [43] and bootstrapping [56] methods are commonly used.
|
| 24 |
+
|
| 25 |
+
Zero-shot learning, on the other hand, is a much more challenging setting with absolutely no access to any task-specific data. When prompt-based methods are directly used to obtain predictions from PLMs without any training, their zero-shot performance can be much worse [5, 13]—difficult NLU tasks can be barely formulated as prompts that resemble the format of pretraining data, posing great challenges for PLMs to accurately interpret and leverage the prompts without given any training samples. The current mainstream of zero-shot learning is based on transfer learning: By converting a set of tasks with abundant annotations into instruction templates [42, 54, 70, 74], entailment pairs [79, 80] or question-answer formats [50, 86] and fine-tuning PLMs on them, the PLMs acquire the cross-task transfer ability [78] to execute unseen tasks when they are formulated in a similar format. Our work proposes a different approach from these studies: We use a unidirectional PLM to generate training data for fine-tuning another PLM on the target task. This not only removes the need for a large amount of cross-task annotations, but also eliminates the task difference in training and inference. Moreover, different from previous studies [1, 76] that rely on labeled data to fine-tune the generative PLM, we directly use prompts to guide data generation without fine-tuning.
|
| 26 |
+
|
| 27 |
+
# 2.2 Controlled Text Generation with PLMs
|
| 28 |
+
|
| 29 |
+
Controlled text generation [22] aims to steer the generated texts of language models towards desired contents, styles or domains. Through fine-tuning PLMs on attribute-specific data, high-level control (e.g., generating certain topics or sentiments [88]), fine-grained control (e.g., generating specific words or phrases [6]) or both [24] can be achieved. Adapting PLMs to generate texts of specific attributes can also be realized at inference time without any further training of the PLMs [10, 26, 27, 32, 47, 75]. Different text attributes can also be represented during pretraining time as control codes [23] which later can serve as explicit guidance for generating domain/attribute-specific texts.
|
| 30 |
+
|
| 31 |
+
The idea of generating category-conditioned texts as training data has been explored for topic classification with bag-of-words or LSTM-based language models [38, 39], which may not have enough capacity to generate quality training data for challenging NLU tasks. With more powerful PLMs, the idea of using prompts as guidance has emerged recently: Since natural language generation is largely based on contexts, using certain prompts to start a sequence can effectively steer the subsequent texts to be generated. The prompts can be either in natural language [57] or as learnable parameters [31]. In this work, we also guide text generation via prompts, but for the novel purpose of creating training data for NLU tasks. There have been studies with similar goals, such as generating similar/dissimilar sentences for training sentence embeddings [58] and using labeled samples as demonstrations to prompt large PLMs [81] for creating novel training data. In this work, we explore generating training data without using any labeled samples for a wide range of different NLU tasks. The similar setting is also explored in a concurrent study [77]. Compared to annotated task-specific data, the generated texts may contain noise and have domain difference from the downstream task. We introduce several important strategies for effective fine-tuning on generated data.
|
| 32 |
+
|
| 33 |
+

|
| 34 |
+
Figure 1: Overview of SuperGen for zero-shot learning of NLU tasks. A unidirectional PLM generates training data guided by label-descriptive prompts. Quality training samples are selected based on average log generation probability. A bidirectional PLM is fine-tuned on the selected training set with label smoothing and temporal ensembling as regularization to perform the classification task.
|
| 35 |
+
|
| 36 |
+
# 3 Method
|
| 37 |
+
|
| 38 |
+
# 3.1 Preliminaries
|
| 39 |
+
|
| 40 |
+
Problem Formulation. We consider solving a classification problem2 where we are only given the label space $\mathcal { V }$ and a mapping $\mathcal { M } : \mathcal { V } \to \mathcal { W }$ that converts each label $y \in \mathcal { V }$ into a label-descriptive prompt (i.e., a short phrase) $\pmb { w } _ { y } \in \mathcal { W }$ . We assume access to a unidirectional PLM $G _ { \theta }$ as the generator and a bidirectional PLM $C _ { \phi }$ which will be fine-tuned as the classifier3. We also assume the pretraining corpus $\mathcal { D }$ (e.g., Wikipedia) is available. Fig. 1 shows an overview of our proposed SuperGen method.
|
| 41 |
+
|
| 42 |
+
Text Generation with Unidirectional PLMs. A unidirectional PLM $G _ { \theta }$ is pretrained to maximize the generation probability of each token in a sequence $\pmb { x } = [ x _ { 1 } , x _ { 2 } , \dots , x _ { n } ]$ conditioned on previous tokens:
|
| 43 |
+
|
| 44 |
+
$$
|
| 45 |
+
\operatorname* { m a x } _ { \theta } \prod _ { i = 1 } ^ { n } p _ { \theta } ( x _ { i } | \pmb { x } _ { < i } ) , \quad \mathrm { w h e r e } \quad p _ { \theta } ( x _ { i } | \pmb { x } _ { < i } ) = \frac { \exp ( e _ { i } ^ { \top } h _ { i } ) } { \sum _ { j = 1 } ^ { | V | } \exp ( e _ { j } ^ { \top } h _ { i } ) } .
|
| 46 |
+
$$
|
| 47 |
+
|
| 48 |
+
Here, $p _ { \theta } ( \cdot )$ is usually parameterized using token embeddings $e$ and contextualized embeddings $^ { h }$ given by a Transformer [65] encoder.
|
| 49 |
+
|
| 50 |
+
After pretraining, $G _ { \theta }$ can be directly used to generate new texts by recursively sampling tokens from its output probability distribution. Typically, a temperature hyperparameter $\tau > 0$ is introduced during sampling [20] to adjust the sharpness of the probability distribution:
|
| 51 |
+
|
| 52 |
+
$$
|
| 53 |
+
p _ { \theta } ( x _ { i } | \pmb { x } _ { < i } ) = \frac { \exp ( \pmb { e } _ { i } ^ { \top } \pmb { h } _ { i } / \tau ) } { \sum _ { j = 1 } ^ { | V | } \exp ( \pmb { e } _ { j } ^ { \top } \pmb { h } _ { i } / \tau ) } ,
|
| 54 |
+
$$
|
| 55 |
+
|
| 56 |
+
where $\tau 0$ approximates greedily picking the most probable next token; $\tau \infty$ induces a uniform distribution. Additionally, sampled tokens can be confined to the top- $k$ most probable ones to avoid low-quality tokens. In this work, we find such top- $k$ sampling with temperature is sufficient to produce coherent and meaningful texts as training data for NLU tasks. Exploring more sophisticated sampling strategies [21] is left for future work.
|
| 57 |
+
|
| 58 |
+
# 3.2 Training Data Generation
|
| 59 |
+
|
| 60 |
+
When given a label-descriptive prompt such as “Write a negative review:”, humans are able to produce texts pertaining to the corresponding class. We aim to leverage the strong text generation power of a unidirectional PLM $G _ { \theta }$ for the same purpose of creating class-conditioned training data. We note that $G _ { \theta }$ is directly used for generation without any parameter updates. The prompts used for different NLU tasks in GLUE are summarized in Table 1.
|
| 61 |
+
|
| 62 |
+
Table 1: Prompts used to generate class-conditioned texts for different GLUE tasks. SST-2 is a singlesequence classification task and the rest are sequencepair classification tasks. Generation for CoLA does not use prompts but by varying sampling temperatures. $\pmb { x } ^ { s }$ denotes a sequence randomly sampled from the pretraining corpus; $\pmb { x } ^ { g }$ denotes the sequence to be generated by $G _ { \theta }$ ; . . . denotes skipping at least one sequence. See Appendix A for more details.
|
| 63 |
+
|
| 64 |
+
Generating Single Sequences. For singlesequence NLU tasks such as sentiment classification (e.g., SST-2), we simply use a prompt ${ \pmb w } _ { y }$ corresponding to label $y$ as the beginning of the sequence and let $G _ { \theta }$ generate the remaining sequence:
|
| 65 |
+
|
| 66 |
+
$$
|
| 67 |
+
\pmb { x } ^ { g } G _ { \theta } ( \pmb { w } _ { y } ) ,
|
| 68 |
+
$$
|
| 69 |
+
|
| 70 |
+
<table><tr><td>Task</td><td>Label</td><td>Prompt</td></tr><tr><td>SST-2</td><td>positive negative</td><td>Rating:5.0xg Rating: 1.0 xg</td></tr><tr><td rowspan="4">MNLI</td><td>entailment</td><td>x.In other words,xg</td></tr><tr><td>neutral</td><td>x.Furthermore,xg</td></tr><tr><td></td><td>There is a rumor that x.</td></tr><tr><td>contradiction</td><td>However, the truth is:x9</td></tr><tr><td rowspan="2">QNLI</td><td>entailment</td><td>x?xg</td></tr><tr><td>not entailment</td><td>x?...g</td></tr><tr><td rowspan="2">RTE</td><td>entailment</td><td>x.In other words,xg</td></tr><tr><td>not entailment</td><td>x.Furthermore,xg</td></tr><tr><td rowspan="2">MRPC</td><td>equivalent</td><td>x.In other words,xg</td></tr><tr><td>not equivalent</td><td>x.Furthermore,xg</td></tr><tr><td rowspan="2">QQP</td><td>equivalent</td><td>x ?In other words,xg</td></tr><tr><td>not equivalent</td><td>x"?Furthermore,xg</td></tr></table>
|
| 71 |
+
|
| 72 |
+
where $G _ { \theta } ( \pmb { w } _ { y } )$ denotes using ${ \pmb w } _ { y }$ as the input to $G _ { \theta }$ and recursively sampling tokens from the distribution in Eq. (1) until a full sequence is generated; $\pmb { x } ^ { g }$ denotes the generated sequence (i.e., excluding the prompt), which will be paired with $y$ to form one training sample $( \bar { \pmb { x } ^ { g } } , y )$ .
|
| 73 |
+
|
| 74 |
+
For syntactic tasks like linguistic acceptabil
|
| 75 |
+
ity classification (e.g., CoLA) which requires generating both linguistically acceptable and unacceptable sequences, we start the sequence with random stop words and use varying sampling temperatures for generating different sequences. A smaller temperature (e.g., $\tau = 0 . 1$ in Equation (1)) sharpens the sampling probability distribution towards the most probable tokens, thus the resulting sequence is more likely to be linguistically acceptable. Using a larger temperature (e.g., $\tau = 1 0$ in Equation (1)) flattens the sampling probability distribution to be more uniform, and the generated tokens will be nearly random, which can create linguistically incorrect sequences.
|
| 76 |
+
|
| 77 |
+
Generating Sequence Pairs. Sequence-pair classification tasks require generating two sequences of specific relationships (e.g., entailment, contradiction). We sample4 the first sequence $\pmb { x } ^ { s }$ from the pretraining corpus $\mathcal { D }$ , concatenate the prompt ${ \pmb w } _ { y }$ with $\pmb { x } ^ { s }$ , and generate the second sequence $\pmb { x } ^ { g }$ :
|
| 78 |
+
|
| 79 |
+
$$
|
| 80 |
+
\pmb { x } ^ { g } G _ { \theta } ( [ \pmb { x } ^ { s } ; \pmb { w } _ { y } ] ) , \pmb { x } ^ { s } \sim \mathcal { D } .
|
| 81 |
+
$$
|
| 82 |
+
|
| 83 |
+
The sequence pair training sample will then be formed as $( \pmb { x } ^ { s } , \pmb { x } ^ { g } , y )$ .
|
| 84 |
+
|
| 85 |
+
Rewarding and Penalizing Repetitions for Sequence Pair Generation. A common issue in text generation is degenerate repetition [21, 23, 51, 71] where generated texts get stuck in repetition loops. To address this issue, one approach is to discourage repetition by reducing the logits of tokens that are already in the sequence before performing sampling [23]. In sequence pair generation, however, it is sometimes desirable to encourage the second sequence to repeat some words in the first sentence (e.g., for generating an entailment or a paraphrase). Therefore, we propose a simple modification of
|
| 86 |
+
|
| 87 |
+
Eq. (1) that rewards/penalizes repetition based on whether the token has appeared in ${ \pmb x } ^ { s } / { \pmb x } ^ { g }$ :
|
| 88 |
+
|
| 89 |
+
$$
|
| 90 |
+
p _ { \theta } ( x _ { i } | \boldsymbol x _ { < i } ) = \frac { \exp ( e _ { i } ^ { \top } h _ { i } / \omega ) } { \sum _ { j = 1 } ^ { | V | } \exp ( e _ { j } ^ { \top } h _ { i } / \omega ) } , \quad \mathrm { w h e r e } \quad \omega = \left\{ \begin{array} { l l } { \tau \alpha } & { x _ { i } \in \boldsymbol x ^ { s } \wedge x _ { i } \not \in \boldsymbol x ^ { g } } \\ { \tau \beta } & { x _ { i } \in \boldsymbol x ^ { g } } \\ { \tau } & { \mathrm { e l s e } } \end{array} \right. ,
|
| 91 |
+
$$
|
| 92 |
+
|
| 93 |
+
and $\alpha > 0 , \beta > 0$ are hyperparameters. By setting $\alpha < 1$ and $\beta > 1$ , we can promote tokens in $\mathbf { \Delta } \mathbf { \mathbf { x } } ^ { s }$ that have not appeared in $\pmb { x } ^ { g }$ to have a higher chance of being generated, and discourage the generation of repetitive tokens in $\pmb { x } ^ { g }$ to mitigate degenerate repetition. The parameters used for different tasks are listed in Appendix B Table 9.
|
| 94 |
+
|
| 95 |
+
# 3.3 Effective Fine-Tuning on Generated Texts
|
| 96 |
+
|
| 97 |
+
With the generated training data, one can fine-tune a bidirectional PLM $C _ { \phi }$ as the classifier to perform the NLU task. However, training $C _ { \phi }$ via standard supervised training on all generated texts is likely to yield suboptimal performance on downstream tasks because (1) the generated texts may contain noise as $G _ { \theta }$ may not always produce texts pertaining to the desired class, especially for challenging sequence pair tasks with subtle semantic relationships; and (2) the generated texts can be considered as originated from the domain of $G _ { \theta }$ ’s pretraining data, with a potentially different distribution from the downstream task; straightforward application of supervised training will result in overfitting to the pretraining domain and diminishing generalization ability, a common challenge in transfer learning [64, 87]. To address these challenges, we next introduce several simple and important strategies for more effective and stable fine-tuning on generated texts.
|
| 98 |
+
|
| 99 |
+
Selecting Quality Training Data. We aim to select generated texts $\pmb { x } ^ { g }$ that are most likely to pertain to the desired label $y$ (i.e., with the highest $p ( \boldsymbol { x } ^ { g } | \boldsymbol { y } ) )$ . The true probability $p ( \pmb { x } ^ { g } | y )$ is unknown and we estimate it via the generation probability given by $G _ { \theta }$ conditioned on the prompt ${ \pmb w } _ { y }$ :
|
| 100 |
+
|
| 101 |
+
$$
|
| 102 |
+
p ( \pmb { x } ^ { g } | y ) \approx p _ { \theta } ( \pmb { x } ^ { g } | \pmb { w } _ { y } ) = \prod _ { i = 1 } ^ { n } p _ { \theta } \left( x _ { i } \big | [ \pmb { w } _ { y } ; \pmb { x } _ { < i } ^ { g } ] \right) .
|
| 103 |
+
$$
|
| 104 |
+
|
| 105 |
+
Since the above measure is biased towards shorter sequences, we instead use the geometric mean of the above conditional generation probability (or equivalently, the average log probability) of all tokens in $\pmb { x } ^ { g }$ as the ranking score, following [82]:
|
| 106 |
+
|
| 107 |
+
$$
|
| 108 |
+
r = \frac { 1 } { n } \sum _ { i = 1 } ^ { n } \log p _ { \theta } \left( x _ { i } \middle | [ \pmb { w } _ { y } ; \pmb { x } _ { < i } ^ { g } ] \right) .
|
| 109 |
+
$$
|
| 110 |
+
|
| 111 |
+
To construct a training set consisting of $N$ samples per class, we will generate more samples (e.g., $1 0 N )$ ), and select training data based on the score $r$ in Eq. (3): For all tasks except CoLA, the top- $N$ ones of each class are selected; for CoLA, the top- $N$ ones are used as linguistically acceptable training samples, and the bottom- $N$ ones as linguistically unacceptable sequences.
|
| 112 |
+
|
| 113 |
+
Regularization for Better Generalization and Stability. Even with the above training data selection procedure, the resulting training set may still contain noise and there exists domain difference from the downstream tasks. We apply two regularization techniques, label smoothing [62] and temporal ensembling [28] for better fine-tuning stability and generalization.
|
| 114 |
+
|
| 115 |
+
Given a training sample $( \boldsymbol { x } ^ { g } , \boldsymbol { y } )$ , label smoothing trains the classifier $C _ { \phi }$ to minimize the standard cross-entropy loss between the label and the classifier’s prediction $p _ { \phi } ( \pmb { x } ^ { g } )$ , except that the label is a weighted average of the one-hot vector and a uniform distribution over all labels:
|
| 116 |
+
|
| 117 |
+
$$
|
| 118 |
+
\operatorname* { m i n } _ { \phi } - \sum _ { j = 1 } ^ { | \mathcal { V } | } q _ { j } \log ( p _ { \phi } ( \pmb { x } ^ { g } ) _ { j } ) ,
|
| 119 |
+
$$
|
| 120 |
+
|
| 121 |
+
where $q _ { j } = \mathbb { 1 } ( j = y ) ( 1 - \epsilon ) + \epsilon / | y |$ and $\epsilon$ is the smoothing weight. By forcing the classifier to be less confident on training data, label smoothing improves robustness to label noise [36] and prevents overfitting to the training set [44], thus improving generalization to different domains.
|
| 122 |
+
|
| 123 |
+
The motivation for temporal ensembling is that neural networks usually first pick up easy and general patterns in the data before learning more sophisticated and dataset-specific features [83], and thus the earlier states of the network offer better generalizability to different domains. We therefore record the predictions $\pmb { p } _ { \phi } = p _ { \phi } ( \pmb { x } ^ { g } )$ of $C _ { \phi }$ on each training sample $( \boldsymbol { x } ^ { g } , \boldsymbol { y } )$ at different training steps, and use the accumulated moving-average predictions $\bar { z }$ to regularize the latest model training. This also helps suppress the fluctuation in model predictions due to data noise, offering better noise-robustness [45]. We update ensembled predictions $\bar { z }$ once every $B$ batches:
|
| 124 |
+
|
| 125 |
+
$$
|
| 126 |
+
\hat { z } \gamma \hat { z } + ( 1 - \gamma ) p _ { \phi } , \bar { z } \hat { z } / ( 1 - \gamma ^ { t } ) ,
|
| 127 |
+
$$
|
| 128 |
+
|
| 129 |
+
where $\hat { z }$ has a zero initialization; $\gamma$ is the momentum parameter; $t$ is the number of updates $\bar { z }$ has received; the division $( 1 - \gamma ^ { t } )$ is for bias correction [28]. We also use the ensembled prediction $\bar { z }$ as a reliable signal to filter out noisy training samples: Only those samples on which $\bar { z }$ strongly agrees with the label $y$ (i.e., $\bar { z } _ { y } > \delta$ where $\delta > 0$ is a threshold parameter) will be used for training.
|
| 130 |
+
|
| 131 |
+
We regularize model training by extending Eq. (4) to add a KL divergence regularization term from the model prediction to the ensembled prediction weighed by $\lambda$ :
|
| 132 |
+
|
| 133 |
+
$$
|
| 134 |
+
\operatorname* { m i n } _ { \phi } - \sum _ { j = 1 } ^ { | \mathcal { V } | } q _ { j } \log ( p _ { \phi } ( \pmb { x } ^ { g } ) _ { j } ) - \lambda \sum _ { j = 1 } ^ { | \mathcal { V } | } \bar { z } _ { j } \log \frac { p _ { \phi } ( \pmb { x } ^ { g } ) _ { j } } { \bar { z } _ { j } } .
|
| 135 |
+
$$
|
| 136 |
+
|
| 137 |
+
We follow [28] to slowly ramp-up $\lambda$ during training.
|
| 138 |
+
|
| 139 |
+
# 3.4 Overall Algorithm
|
| 140 |
+
|
| 141 |
+
We summarize SuperGen for singlesequence NLU tasks in Algorithm 1. Solving sequence-pair problems follows the same algorithm except the pretraining corpus $\mathcal { D }$ is needed for sampling the first sequence $\pmb { x } ^ { s }$ .
|
| 142 |
+
|
| 143 |
+
# Algorithm 1: SuperGen for Zero-Shot Learning.
|
| 144 |
+
|
| 145 |
+
Input: $\mathcal { V }$ : Label space; $\mathcal { P }$ : Label-descriptive prompts; $G _ { \theta }$ : Unidirectional PLM; $C _ { \phi }$ : Bidirectional PLM.
|
| 146 |
+
|
| 147 |
+
# 4 Experimental Setup
|
| 148 |
+
|
| 149 |
+
Downstream Tasks and Metrics. We use all the tasks included in GLUE [66] except STS-B which is a regression task. Please refer to Appendix C for more details about GLUE tasks. We follow the evaluation protocol of [13]: We use F1 score as the metric for QQP and MRPC, Matthews correlation for CoLA, and accuracy for the rest of the tasks. The original development sets of these tasks are used for testing. For all reported results, we include the average and standard deviation over 5 different random seeds.
|
| 150 |
+
|
| 151 |
+
Parameter: $N$ : Number of training samples per class to generate; $M ( \gg N )$ : Number of total training samples to generate; $T$ : Number of training steps; $B$ : Ensemble prediction update interval; $\delta$ : Threshold parameter.
|
| 152 |
+
Output: $C _ { \phi } ^ { * }$ : Classifier that classifies input texts into $\mathcal { V }$ .
|
| 153 |
+
for $y \in \mathcal { V }$ do $\overline { { \mathcal { T } _ { y } } } \gets \{ \}$ Class $_ y$ train set init. for $i \in [ 1 , 2 , \ldots , M ]$ do $\pmb { x } ^ { g } G _ { \theta } ( \pmb { w } _ { y } )$ Ty ← Ty S{(xg, y)} end
|
| 154 |
+
end
|
| 155 |
+
$\tau \{ \}$
|
| 156 |
+
// Selected train set.
|
| 157 |
+
for $y \in \mathcal { V }$ do Sort $\mathcal { T } _ { y }$ in descending order by Eq. (3) $\tau \tau \cup \mathcal { T } _ { y } [ : N ]$
|
| 158 |
+
end
|
| 159 |
+
$\hat { z } \gets \mathbf { 0 }$
|
| 160 |
+
// Ensembled prediction init.
|
| 161 |
+
$\tau ^ { * } \tau$
|
| 162 |
+
// Filtered train set.
|
| 163 |
+
for $i \in [ 1 , 2 , \dots , T ]$ do Fine-tune $C _ { \phi }$ via Eq. (6) on a minibatch of $\tau ^ { * }$ if $i \% B = 0$ then Update $\hat { z } , \bar { z }$ via Eq. (5) $\mathcal { T } ^ { * } \{ ( \pmb { x } ^ { g } , y ) | \bar { z } _ { y } > \delta , ( \pmb { x } ^ { g } , y ) \in \mathcal { T } \}$ end
|
| 164 |
+
end
|
| 165 |
+
return $C _ { \phi } ^ { * } = C _ { \phi }$
|
| 166 |
+
|
| 167 |
+
Models. Unless specified otherwise, we use CTRL (1.63B parameters) [23] as the generator $G _ { \theta }$ and $\mathrm { C O C O - L M _ { L a r g e } }$ (367M parameters) [40] as the classifier $C _ { \phi }$ . We also show the results using similar-sized PLMs (GPT-2 [51]/RoBERTa [34]) as the generator/classifier in Section 5.6.
|
| 168 |
+
|
| 169 |
+
Fine-Tuning Settings and Hyperparameters. We note that SuperGen is compatible with any fine-tuning method; while using more sophisticated methods may grant
|
| 170 |
+
|
| 171 |
+
further performance improvement, we use the basic prompt-based fine-tuning with manual templates approach for simplicity and clarity. For all tasks, we use the same templates and label words as in [13]. Under the zero-shot learning setting, it is not possible to tune hyperparameters due to the lack of validation sets. Therefore, we keep all fine-tuning hyperparameters (e.g., learning rate, batch size, training epochs, number of generated training samples, label smoothing and temporal ensembling hyperparameters) the same across all tasks. See Appendix B Table 10 for details.
|
| 172 |
+
|
| 173 |
+
Table 2: Results on seven GLUE classification tasks. We report average and standard deviation (as subscripts) performance over 5 different random seeds. †: Results from LM-BFF [13].
|
| 174 |
+
|
| 175 |
+
<table><tr><td>Method</td><td>MNLI-(m/mm) (Acc.)</td><td>QQP (F1)</td><td>QNLI (Acc.)</td><td>SST-2 (Acc.)</td><td>CoLA (Matt.)</td><td>RTE (Acc.)</td><td>MRPC (F1)</td><td>AVG</td></tr><tr><td colspan="9">Zero-Shot Setting: No task-specific data (neither labeled nor unlabeled).</td></tr><tr><td>Promptingt</td><td>50.80.0/51.70.0</td><td>49.70.0</td><td>50.80.0</td><td>83.60.0</td><td>2.00.0</td><td>51.30.0</td><td>61.90.0</td><td>50.1</td></tr><tr><td>SuperGen</td><td>72.30.5/73.80.5</td><td>66.1.1</td><td>73.31.9</td><td>92.80.6</td><td>32.75.5</td><td>65.31.2</td><td>82.20.5</td><td>69.4</td></tr><tr><td>- data selection</td><td>63.71.5/64.21.6</td><td>62.32.2</td><td>63.93.2</td><td>91.32.0</td><td>30.58.8</td><td>62.41.5</td><td>81.60.2</td><td>65.1</td></tr><tr><td>- label smooth</td><td>70.70.8/72.10.7</td><td>65.10.9</td><td>71.42.5</td><td>91.00.9</td><td>9.51.0</td><td>64.81.1</td><td>83.00.7</td><td>65.2</td></tr><tr><td>- temporal ensemble</td><td>62.04.6/63.64.8</td><td>63.90.3</td><td>72.42.0</td><td>92.50.9</td><td>23.57.0</td><td>63.51.0</td><td>78.82.2</td><td>65.3</td></tr><tr><td colspan="9">Few-Shot Seting: Use 32 labeled samples/class (half for training and half for development).</td></tr><tr><td>Fine-tuning†</td><td>45.86.4/47.86.8</td><td>60.74.3</td><td>60.26.5</td><td>81.43.8</td><td>33.914.3</td><td>54.43.9</td><td>76.62.5</td><td>59.1</td></tr><tr><td>Manual prompt†</td><td>68.32.3/70.51.9</td><td>65.55.3</td><td>64.54.2</td><td>92.70.9</td><td>9.37.3</td><td>69.13.6</td><td>74.55.3</td><td>63.6</td></tr><tr><td>+ demonstrationt</td><td>70.71.3/72.01.2</td><td>69.81.8</td><td>69.21.9</td><td>92.60.5</td><td>18.78.8</td><td>68.72.3</td><td>77.82.0</td><td>66.9</td></tr><tr><td>Auto prompt</td><td>68.32.5/70.12.6</td><td>67.03.0</td><td>68.37.4</td><td>92.31.0</td><td>14.014.1</td><td>73.92.2</td><td>76.22.3</td><td>65.8</td></tr><tr><td>+ demonstration†</td><td>70.03.6/72.03.1</td><td>67.75.8</td><td>68.55.4</td><td>93.00.6</td><td>21.815.9</td><td>71.15.3</td><td>78.13.4</td><td>67.3</td></tr><tr><td>Fully supervisedt</td><td>89.8/89.5</td><td>81.7</td><td>93.3</td><td>95.0</td><td>62.6</td><td>80.9</td><td>91.4</td><td>84.9</td></tr></table>
|
| 176 |
+
|
| 177 |
+
Table 3: Results with different groups of prompts. CoLA does not use prompts for generation. The number of prompt groups is equal to the number of the task labels.
|
| 178 |
+
|
| 179 |
+
<table><tr><td>Prompt Group</td><td>MNLI-(m/mm)</td><td>QQP</td><td>QNLI</td><td>SST-2</td><td>RTE</td><td>MRPC</td></tr><tr><td>#0 (Original)</td><td>72.30.5/73.80.5</td><td>66.1.1</td><td>73.31.9</td><td>92.80.6</td><td>65.31.2</td><td>82.20.5</td></tr><tr><td>#1</td><td>70.71.4/72.41.2</td><td>65.51.4</td><td>71.91.7</td><td>92.20.9</td><td>64.41.6</td><td>81.90.4</td></tr><tr><td>#2</td><td>70.80.6/72.10.8</td><td>65.61.1</td><td>72.22.2</td><td>92.40.8</td><td>64.71.8</td><td>81.80.8</td></tr><tr><td>#3</td><td>70.91.4/72.21.4</td><td>-</td><td>-</td><td>-</td><td>-</td><td>-</td></tr><tr><td>Mixed</td><td>72.20.7/73.40.6</td><td>66.91.5</td><td>73.01.7</td><td>92.80.9</td><td>66.31.0</td><td>81.32.0</td></tr></table>
|
| 180 |
+
|
| 181 |
+
Compared Methods and Ablations. We include the results of zero-shot prompting, standard few-shot fine-tuning and the four few-shot prompt-based fine-tuning methods proposed in [13]. We also conduct ablation studies by removing the following three techniques from SuperGen one at a time: (1) not using Eq. (3) for training data selection but randomly selecting the same amount of training data ( $\_$ data selection); (2) not using label smoothing $\underline { { \underline { { \mathbf { \Pi } } } } }$ label smooth) but using one-hot labels; and (3) not using temporal ensembling (i.e., using Eq. (4) instead of Eq. (6) as the training objective) ( $-$ temporal ensemble). Lastly, we include the fully supervised fine-tuning results trained on the entire training sets.
|
| 182 |
+
|
| 183 |
+
# 5 Evaluation
|
| 184 |
+
|
| 185 |
+
# 5.1 Main Results
|
| 186 |
+
|
| 187 |
+
We present the results of SuperGen, its ablations and compared methods in Table 2. Overall, SuperGen significantly outperforms zero-shot prompting and achieves an overall better result than all few-shot methods. Notably, SuperGen results in much smaller variance over different random seeds than few-shot approaches on most tasks—with access to more training data, fine-tuning of PLMs becomes much more stable. The ablation results demonstrate that all three strategies (i.e., quality training data selection, label smoothing and temporal ensembling) play important roles in improving and stabilizing the final performance, especially on challenging tasks like MNLI.
|
| 188 |
+
|
| 189 |
+
# 5.2 Using Different Prompts
|
| 190 |
+
|
| 191 |
+
One important factor of SuperGen is the choice of label-descriptive prompts as they directly influence the quality of generated training samples. To study the impact of different prompt choices on the final model performance, we create different groups of prompts other than the original ones. We replace the prompt for one label used in Table 1 with a synonymous one and keep other prompts unchanged when forming a different prompt group (Please refer to Appendix A Table 8 for details). We also experiment with mixing the generated data by different prompt groups (mixed). The results are shown in Table 3. Overall, the model performance under different prompts is quite close, except on RTE whose test set is very small, potentially resulting in the higher variance. In this work, we manually choose simple prompts that make intuitive sense, and we leave the automatic searching of optimal prompts as future work.
|
| 192 |
+
|
| 193 |
+

|
| 194 |
+
Figure 2: Classifier accuracy fine-tuned on different amount of generated training data (after data selection). Dots and error bars are the average performance and the standard deviation over 5 seeds, respectively.
|
| 195 |
+
|
| 196 |
+

|
| 197 |
+
Figure 3: Classifier accuracy on MNLI-m fine-tuned on the fewshot samples only vs. on the fewshot and SuperGen generated set with varying few-shot set sizes.
|
| 198 |
+
|
| 199 |
+
# 5.3 Results with Different Amount of Generated Data
|
| 200 |
+
|
| 201 |
+
With training data automatically created by the generator, we can have a virtually infinite amount of training samples. We show the results of using different amount of generated data (after quality data selection) for fine-tuning the classifier $C _ { \phi }$ in Fig. 2 on MNLI-m and SST-2. When the number of training data is small (e.g., 100), the fine-tuning variance is high, resulting in the similar instability issue with few-shot settings. With more generated data used, both average performance and training stability improve, yielding comparable results (with smaller variance) to fine-tuning using few-shot task-specific data. However, when too many generated data (e.g., 10, 000) are used, the classifier’s performance slightly drops, probably due to increased label noise—recall that the training data are selected based on the ranking score in Eq. (3), so using more data results in the inclusion of more lower-ranking texts in the training set and reduced data quality. One way to address this issue is to use a fixed selection ratio and increase the total number of generated texts to obtain a larger number of high-quality training data. However, this comes at a greater computation cost in the generation step. An important future direction is thus to develop better data selection strategies.
|
| 202 |
+
|
| 203 |
+
# 5.4 Using SuperGen in Few-Shot Settings
|
| 204 |
+
|
| 205 |
+
We present a simple extension of SuperGen to few-shot settings and show that the generated data of SuperGen may also improve the few-shot performance. When few-shot samples are available, we first fine-tune the classifier on the few-shot training set (standard prompt-based fine-tuning without regularization), and then continue fine-tuning the classifier on the generated data by SuperGen as described in Section 3.3. This allows the classifier to effectively leverage the knowledge from the few-shot training set to filter out noisy samples in the generated data, as temporal ensembling regularizes the classifier to remember the predictions learned previously and only keeps samples on which the model predictions agree with the label. We show the benefits of incorporating generated data for different few-shot sample sizes on MNLI in Fig. 3 (we use half labeled samples for classifier training and half for development): When the few-shot training and validation sets are rather small $( 3 2 - { \bar { 6 } } 4 $ samples per label in total), fine-tuning the classifier on the SuperGen generated set further (after fine-tuning on the few-shot samples) brings notable performance improvements. However, such benefits diminish with more few-shot training samples: The generated data fail to improve the few-shot performance when there are 128 samples per label, and even worsen the classifier performance with 256 samples per label. This is probably because our synthetic data generation process is zero-shot and does not leverage any few-shot samples; the resulting generated samples may not be of high enough quality to boost the few-shot performance when there are relatively abundant annotated samples. Possible ways to use few-shot samples for generation include using them as demonstrations [5], for creating augmentations [29] and for tuning the generators. We leave the explorations of generating higher quality data by leveraging few-shot samples for future work.
|
| 206 |
+
|
| 207 |
+
Table 4: Comparisons with using CTRL for zeroshot prompting and for knowledge distillation. †: The entire training set is used as unlabeled data.
|
| 208 |
+
|
| 209 |
+
<table><tr><td>Method</td><td>MNLI-(m/mm)</td><td>SST-2</td></tr><tr><td>SuperGen</td><td>72.30.5/73.80.5</td><td>92.80.6</td></tr><tr><td>CTRL Prompting</td><td>38.50.0/39.20.0</td><td>72.50.0</td></tr><tr><td>Knowledge Distillt</td><td>40.80.5/41.50.6</td><td>73.60.8</td></tr></table>
|
| 210 |
+
|
| 211 |
+
Table 5: Results with different generator/classifier PLMs.
|
| 212 |
+
|
| 213 |
+
<table><tr><td>PLMs (Ge/CΦ)</td><td>MNLI-(m/mm)</td><td>SST-2</td></tr><tr><td>CTRL/COCO-LM</td><td>72.30.5/73.80.5</td><td>92.80.6</td></tr><tr><td>CTRL/RoBERTa</td><td>69.00.8/70.60.9</td><td>93.01.5</td></tr><tr><td>GPT-2/COCO-LM</td><td>69.51.2/71.31.3</td><td>88.21.8</td></tr><tr><td>GPT-2/RoBERTa</td><td>68.30.9/69.70.7</td><td>88.60.8</td></tr></table>
|
| 214 |
+
|
| 215 |
+
# 5.5 Using Generators for Knowledge Distillation
|
| 216 |
+
|
| 217 |
+
Apart from using unidirectional PLMs $G _ { \theta }$ for training data generation, one could also directly apply them to unlabeled data formulated as prompts to obtain zero-shot predictions (i.e., prompting [5, 13]), which can then be used as soft labels to train the classifier $C _ { \phi }$ . In Table 4, we show (1) the zero-shot prediction accuracy of CTRL (the best out of three different prompts, details in Appendix D) and (2) the classifier performance trained from CTRL’s predictions on the entire unlabeled training set as soft labels (i.e., knowledge distillation). Similar to the observations in previous studies [5, 70, 85], the zero-shot predictions of unidirectional PLMs are quite inaccurate and directly using them as soft labels to train classifiers does not yield good results. We hypothesize that the advantages of using unidirectional PLMs for training data generation over using them for zero-shot predictions are twofold: (1) Better flexibility in prompt formats. When unidirectional PLMs are used for zero-shot predictions, the prompts have to be designed so that the label word is the last token in the sequence to be predicted, as unidirectional PLMs cannot attend to subsequent tokens. Such constraints may result in the prompt being dissimilar to the pretraining data distribution and worsen the prediction quality of the PLMs. On the contrary, using unidirectional PLMs for generation is not subject to any prompt format constraints. (2) More direct uses of PLMs’ language modeling ability. Using unidirectional PLMs for training data generation directly leverages the PLMs’ output token probability. Applying PLMs for zero-shot prediction, however, requires an additional step to convert token predictions to label predictions (i.e., the verbalizer [56]), and such a mapping process usually necessitates manual curation and can hardly be optimal [13] especially without abundant task-specific data.
|
| 218 |
+
|
| 219 |
+
# 5.6 Using Different PLMs
|
| 220 |
+
|
| 221 |
+
The final performance of SuperGen is relevant to the choice of PLMs as the generator/classifier. Apart from the default PLM choice, we report the results of using GPT-2XLarge (1.54B parameters) [51] as the generator and RoBERTaLarge (356M parameters) [34] as the classifier in Table 5 with everything else unchanged. When using GPT-2, we change the prompt used for SST-2 to “The film is bad/terrible/awful.” for the negative label and “The film is good/great/excellent.” for the positive label, since the original prompts used for SST-2 in Table 1 are a part of the control codes of CTRL and cannot be effectively leveraged by GPT-2. Overall, both CTRL and GPT-2 are able to generate quality training data for good fine-tuned classifier performance; CTRL consistently yields better results than GPT-2 regardless of the choice of the classifier PLM, probably because CTRL is pretrained with control codes which provide explicit guidance for generating texts of certain domains and attributes. We also observe that the generated text quality is strongly correlated to the generator’s model size—using a smaller version of GPT-2 (e.g., with 117M parameters) results in significantly less coherent texts and can hardly serve as training data. An interesting future direction is to try larger generator PLMs (e.g., GPT-3) which may create training data of better quality.
|
| 222 |
+
|
| 223 |
+
# 5.7 Case Studies
|
| 224 |
+
|
| 225 |
+
We present concrete examples of generated texts guided by prompts of different labels in Table 6. The generated sequences are not only coherent, but also pertain to the corresponding labels. For easier tasks like SST-2, the generated texts almost always correctly reflect the desired sentiment polarity specified by the prompt. For more difficult tasks like MNLI, sometimes the generated texts are not of the correct label (Appendix E Table 13 shows some negative results). The existence of such label noise motivates our use of the regularization techniques in the fine-tuning stage. In the future, it will be interesting to develop new methods to better control text generation towards the desired label.
|
| 226 |
+
|
| 227 |
+
Table 6: Example generated texts for SST-2, MNLI and QQP. Sampled sequences from pretraining corpus $( { \pmb x } ^ { s } )$ are italicized; generated sequences $( \pmb { x } ^ { g } )$ are underlined; prompts $( \boldsymbol { w } ^ { y } )$ are in bold.
|
| 228 |
+
|
| 229 |
+
<table><tr><td>Task</td><td>Label</td><td>Generated Text</td></tr><tr><td rowspan="2">SST-2</td><td>positive</td><td>Rating:5.0 The film is a great example of the kind of movie that you can watch over and over.</td></tr><tr><td>negative</td><td>Rating:1.0 The film was a total waste of time.I would not recommend this movie to anyone.</td></tr><tr><td rowspan="4">MNLI</td><td>entailment</td><td>The construction of the station began in 2Ol6,when the opening date was estimated to mid-2020. In other words,the station was to open in 2020.</td></tr><tr><td rowspan="2">neutral</td><td>Theconstruction of the station began in 2O16,when the opening date was estimated to mid-2020.</td></tr><tr><td>Furthermore,it is expected that a new bus terminal will be built at this station.</td></tr><tr><td rowspan="2">contradiction</td><td>There sarumor thatTheconstructionofthe station beganin 2ol6,when theopeningdate was estimated to mid-2020. However,the truth is:The construction started in 2O17,andthe ofcialopening date was setfor March 31,2018.</td></tr><tr><td></td></tr><tr><td>QQP</td><td>equivalent not equivalent</td><td>What are the most wear resistant steels?In other words,what are the most durable steels? What are the most wear resistant steels?Furthermore,what is the best way to clean them?</td></tr></table>
|
| 230 |
+
|
| 231 |
+
# 6 Discussions and Conclusions
|
| 232 |
+
|
| 233 |
+
Ethical Considerations. While PLMs have demonstrated remarkable text generation and understanding capability, they can come with potential risks or harms [2, 3, 5] such as generating misinformation [46] or amplifying harmful biases [49]. The focus of our work is on utilizing existing PLMs to generate training data for NLU tasks instead of developing new PLMs or generation methods. Therefore, our method can be used in company with any bias reduction and correction techniques [15, 37] to mitigate the risks of PLMs.
|
| 234 |
+
|
| 235 |
+
Limitations. One inherent limitation with zero-shot learning is the lack of access to task-specific samples for hyperparameter tuning, whereas the performance of neural networks is usually heavily dependent on the choice of hyperparameters even when the training algorithm and training set are fixed [48]. Also, without access to any labeled data, the generated training data quality may not be high enough to achieve good performance on challenging tasks, especially when the task distribution is significantly different from the pretraining data distribution (e.g., the “linguistically incorrect” label of CoLA requires generating sequences with grammar mistakes – a different distribution from the one used to train PLMs). A promising direction to address the above limitations is extending SuperGen to few-shot settings (e.g., the setting studied in Section 5.4) and leveraging a small amount of labeled data for generating better quality data and for hyperparameter tuning.
|
| 236 |
+
|
| 237 |
+
Conclusions. We propose SuperGen, an automatic supervision generation approach for zero-shot learning of NLU tasks. By providing label-descriptive prompts as guidance to a unidirectional PLM, training data can be automatically created for fine-tuning a bidirectional PLM. Our framework differs from previous transfer-learning-based zero-shot methods in that SuperGen does not rely on cross-task annotations and eliminates the task difference in training and inference. We show that several strategies are important for effective and stable fine-tuning on generated data, including quality training data selection, label smoothing and temporal ensembling. SuperGen achieves strong performance on seven classification tasks of the GLUE benchmark, even yielding comparable or better results than sophisticated few-shot learning methods and offering better stability. There is large room for future work, including but not limited to: Extension to few-shot learning settings, exploring larger generator models [25, 68], better fine-tuning techniques to leverage generated data and better strategies for selecting quality training data.
|
| 238 |
+
|
| 239 |
+
# Acknowledgments
|
| 240 |
+
|
| 241 |
+
Research was supported in part by US DARPA KAIROS Program No. FA8750-19-2-1004 and INCAS Program No. HR001121C0165, National Science Foundation IIS-19-56151, IIS-17-41317, and IIS 17-04532, and the Molecule Maker Lab Institute: An AI Research Institutes program supported by NSF under Award No. 2019897, and the Institute for Geospatial Understanding through an Integrative Discovery Environment (I-GUIDE) by NSF under Award No. 2118329. Any opinions, findings, and conclusions or recommendations expressed herein are those of the authors and do not necessarily represent the views, either expressed or implied, of DARPA or the U.S. Government. Yu Meng is supported by the Google PhD Fellowship. We thank anonymous reviewers for valuable and insightful feedback.
|
| 242 |
+
|
| 243 |
+
# References
|
| 244 |
+
|
| 245 |
+
[1] Ateret Anaby-Tavor, Boaz Carmeli, Esther Goldbraich, Amir Kantor, George Kour, Segev Shlomov, Naama Tepper, and Naama Zwerdling. Do not have enough data? deep learning to the rescue! In AAAI, 2020.
|
| 246 |
+
[2] Emily M. Bender and Alexander Koller. Climbing towards NLU: On meaning, form, and understanding in the age of data. In ACL, 2020.
|
| 247 |
+
[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 ACM Conference on Fairness, Accountability, and Transparency, 2021.
|
| 248 |
+
[4] Luisa Bentivogli, Peter Clark, Ido Dagan, and Danilo Giampiccolo. The fifth pascal recognizing textual entailment challenge. In TAC, 2009.
|
| 249 |
+
[5] 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. In NeurIPS, 2020.
|
| 250 |
+
[6] Alvin Chan, Y. Ong, Bill Tuck Weng Pung, Aston Zhang, and Jie Fu. CoCon: A self-supervised approach for controlled text generation. In ICLR, 2021.
|
| 251 |
+
[7] Jiaao Chen, Zichao Yang, and Diyi Yang. Mixtext: Linguistically-informed interpolation of hidden space for semi-supervised text classification. In ACL, 2020.
|
| 252 |
+
[8] Kevin Clark, Minh-Thang Luong, Quoc V Le, and Christopher D Manning. ELECTRA: Pre-training text encoders as discriminators rather than generators. In ICLR, 2020.
|
| 253 |
+
[9] Ido Dagan, Oren Glickman, and Bernardo Magnini. The pascal recognising textual entailment challenge. In Machine Learning Challenges Workshop, 2005.
|
| 254 |
+
[10] Sumanth Dathathri, Andrea Madotto, Janice Lan, Jane Hung, Eric Frank, Piero Molino, Jason Yosinski, and Rosanne Liu. Plug and play language models: A simple approach to controlled text generation. In ICLR, 2020.
|
| 255 |
+
[11] Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. BERT: Pre-training of deep bidirectional transformers for language understanding. In NAACL-HLT, 2019.
|
| 256 |
+
[12] William B Dolan and Chris Brockett. Automatically constructing a corpus of sentential paraphrases. In International Workshop on Paraphrasing (IWP), 2005.
|
| 257 |
+
[13] Tianyu Gao, Adam Fisch, and Danqi Chen. Making pre-trained language models better few-shot learners. In ACL, 2021.
|
| 258 |
+
[14] Tianyu Gao, Xingcheng Yao, and Danqi Chen. SimCSE: Simple contrastive learning of sentence embeddings. In EMNLP, 2021.
|
| 259 |
+
[15] Samuel Gehman, Suchin Gururangan, Maarten Sap, Yejin Choi, and Noah A. Smith. RealToxicityPrompts: Evaluating neural toxic degeneration in language models. In Findings of EMNLP, 2020.
|
| 260 |
+
[16] Danilo Giampiccolo, Bernardo Magnini, Ido Dagan, and Bill Dolan. The third pascal recognizing textual entailment challenge. In ACL-PASCAL workshop on textual entailment and paraphrasing, 2007.
|
| 261 |
+
[17] Aaron Gokaslan and Vanya Cohen. OpenWebText corpus. http://Skylion007.github. io/OpenWebTextCorpus, 2019.
|
| 262 |
+
[18] R Bar Haim, Ido Dagan, Bill Dolan, Lisa Ferro, Danilo Giampiccolo, Bernardo Magnini, and Idan Szpektor. The second pascal recognising textual entailment challenge. In PASCAL Challenges Workshop on Recognising Textual Entailment, 2006.
|
| 263 |
+
[19] Pengcheng He, Xiaodong Liu, Jianfeng Gao, and Weizhu Chen. DeBERTa: Decoding-enhanced BERT with disentangled attention. In ICLR, 2021.
|
| 264 |
+
[20] Geoffrey E. Hinton, Oriol Vinyals, and Jeffrey Dean. Distilling the knowledge in a neural network. ArXiv, abs/1503.02531, 2015.
|
| 265 |
+
[21] Ari Holtzman, Jan Buys, Maxwell Forbes, and Yejin Choi. The curious case of neural text degeneration. In ICLR, 2020.
|
| 266 |
+
[22] Zhiting Hu, Zichao Yang, Xiaodan Liang, Ruslan Salakhutdinov, and Eric P. Xing. Toward controlled generation of text. In ICML, 2017.
|
| 267 |
+
[23] Nitish Shirish Keskar, Bryan McCann, Lav R. Varshney, Caiming Xiong, and Richard Socher. CTRL: A conditional transformer language model for controllable generation. ArXiv, abs/1909.05858, 2019.
|
| 268 |
+
[24] Muhammad Khalifa, Hady ElSahar, and Marc Dymetman. A distributional approach to controlled text generation. In ICLR, 2021.
|
| 269 |
+
[25] Boseop Kim, HyoungSeok Kim, Sang-Woo Lee, Gichang Lee, Donghyun Kwak, Dong Hyeon Jeon, Sunghyun Park, Sungju Kim, Seonhoon Kim, Dongpil Seo, et al. What changes can largescale language models bring? intensive study on hyperclova: Billions-scale korean generative pretrained transformers. In EMNLP, 2021.
|
| 270 |
+
[26] Ben Krause, Akhilesh Deepak Gotmare, Bryan McCann, Nitish Shirish Keskar, Shafiq R. Joty, Richard Socher, and Nazneen Rajani. GeDi: Generative discriminator guided sequence generation. In EMNLP, 2021.
|
| 271 |
+
[27] Sachin Kumar, Eric Malmi, Aliaksei Severyn, and Yulia Tsvetkov. Controlled text generation as continuous optimization with multiple constraints. In NeurIPS, 2021.
|
| 272 |
+
[28] Samuli Laine and Timo Aila. Temporal ensembling for semi-supervised learning. In ICLR, 2017.
|
| 273 |
+
[29] Kenton Lee, Kelvin Guu, Luheng He, Tim Dozat, and Hyung Won Chung. Neural data augmentation via example extrapolation. arXiv preprint arXiv:2102.01335, 2021.
|
| 274 |
+
[30] Mike Lewis, Yinhan Liu, Naman Goyal, Marjan Ghazvininejad, Abdelrahman Mohamed, Omer Levy, Veselin Stoyanov, and Luke Zettlemoyer. BART: Denoising sequence-to-sequence pre-training for natural language generation, translation, and comprehension. In ACL, 2020.
|
| 275 |
+
[31] Xiang Lisa Li and Percy Liang. Prefix-tuning: Optimizing continuous prompts for generation. In ACL, 2021.
|
| 276 |
+
[32] Alisa Liu, Maarten Sap, Ximing Lu, Swabha Swayamdipta, Chandra Bhagavatula, Noah A. Smith, and Yejin Choi. DExperts: Decoding-time controlled text generation with experts and anti-experts. In ACL, 2021.
|
| 277 |
+
[33] Xiao Liu, Yanan Zheng, Zhengxiao Du, Ming Ding, Yujie Qian, Zhilin Yang, and Jie Tang. GPT understands, too. ArXiv, abs/2103.10385, 2021.
|
| 278 |
+
[34] 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.
|
| 279 |
+
[35] Robert L Logan IV, Ivana Balazevi ˇ c, Eric Wallace, Fabio Petroni, Sameer Singh, and Sebastian ´ Riedel. Cutting down on prompts and parameters: Simple few-shot learning with language models. arXiv preprint arXiv:2106.13353, 2021.
|
| 280 |
+
[36] Michal Lukasik, Srinadh Bhojanapalli, Aditya Krishna Menon, and Surinder Kumar. Does label smoothing mitigate label noise? In ICML, 2020.
|
| 281 |
+
[37] Xinyao Ma, Maarten Sap, Hannah Rashkin, and Yejin Choi. PowerTransformer: Unsupervised controllable revision for biased language correction. In EMNLP, 2020.
|
| 282 |
+
[38] Yu Meng, Jiaming Shen, Chao Zhang, and Jiawei Han. Weakly-supervised neural text classification. In CIKM, 2018.
|
| 283 |
+
[39] Yu Meng, Jiaming Shen, Chao Zhang, and Jiawei Han. Weakly-supervised hierarchical text classification. In AAAI, 2019.
|
| 284 |
+
[40] 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.
|
| 285 |
+
[41] Yu Meng, Chenyan Xiong, Payal Bajaj, Saurabh Tiwary, Paul Bennett, Jiawei Han, and Xia Song. Pretraining text encoders with adversarial mixture of training signal generators. In ICLR, 2022.
|
| 286 |
+
[42] Swaroop Mishra, Daniel Khashabi, Chitta Baral, and Hannaneh Hajishirzi. Cross-task generalization via natural language crowdsourcing instructions. arXiv preprint arXiv:2104.08773, 2021.
|
| 287 |
+
[43] Takeru Miyato, Andrew M. Dai, and Ian J. Goodfellow. Adversarial training methods for semi-supervised text classification. In ICLR, 2017.
|
| 288 |
+
[44] Rafael Muller, Simon Kornblith, and Geoffrey E. Hinton. When does label smoothing help? In ¨ NeurIPS, 2019.
|
| 289 |
+
[45] Duc Tam Nguyen, Chaithanya Kumar Mummadi, Thi-Phuong-Nhung Ngo, Thi Hoai Phuong Nguyen, Laura Beggel, and Thomas Brox. SELF: Learning to filter noisy labels with selfensembling. In ICLR, 2020.
|
| 290 |
+
[46] Artidoro Pagnoni, Vidhisha Balachandran, and Yulia Tsvetkov. Understanding factuality in abstractive summarization with FRANK: A benchmark for factuality metrics. In NAACL, 2021.
|
| 291 |
+
[47] Damian Pascual, Beni Egressy, Clara Meister, Ryan Cotterell, and Roger Wattenhofer. A ´ plug-and-play method for controlled text generation. In Findings of EMNLP, 2021.
|
| 292 |
+
[48] Ethan Perez, Douwe Kiela, and Kyunghyun Cho. True few-shot learning with language models. In NeurIPS, 2021.
|
| 293 |
+
[49] Shrimai Prabhumoye, Yulia Tsvetkov, Ruslan Salakhutdinov, and Alan W. Black. Style transfer through back-translation. In ACL, 2018.
|
| 294 |
+
[50] Raul Puri and Bryan Catanzaro. Zero-shot text classification with generative language models. ArXiv, abs/1912.10165, 2019.
|
| 295 |
+
[51] Alec Radford, Jeffrey Wu, Rewon Child, David Luan, Dario Amodei, and Ilya Sutskever. Language models are unsupervised multitask learners. OpenAI blog, 1(8):9, 2019.
|
| 296 |
+
[52] 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, 2019.
|
| 297 |
+
[53] Nils Reimers and Iryna Gurevych. Sentence-BERT: Sentence embeddings using siamese BERT-networks. In EMNLP, 2019.
|
| 298 |
+
[54] Victor Sanh, Albert Webson, Colin Raffel, Stephen H Bach, Lintang Sutawika, Zaid Alyafeai, Antoine Chaffin, Arnaud Stiegler, Teven Le Scao, Arun Raja, et al. Multitask prompted training enables zero-shot task generalization. In ICLR, 2022.
|
| 299 |
+
[55] Teven Le Scao and Alexander M. Rush. How many data points is a prompt worth? In NAACL, 2021.
|
| 300 |
+
[56] Timo Schick and Hinrich Schutze. Exploiting cloze-questions for few-shot text classification ¨ and natural language inference. In EACL, 2021.
|
| 301 |
+
[57] Timo Schick and Hinrich Schutze. Few-shot text generation with natural language instructions. ¨ In EMNLP, 2021.
|
| 302 |
+
[58] Timo Schick and Hinrich Schutze. Generating datasets with pretrained language models. In ¨ EMNLP, 2021.
|
| 303 |
+
[59] Timo Schick and Hinrich Schutze. It’s not just size that matters: Small language models are ¨ also few-shot learners. In NAACL, 2021.
|
| 304 |
+
[60] Iyer Shankar, Dandekar Nikhil, and Csernai Kornel.´ First Quora dataset release: Question pairs, 2017. URL https://www.quora.com/q/quoradata/ First-Quora-Dataset-Release-Question-Pairs.
|
| 305 |
+
[61] Richard Socher, Alex Perelygin, Jean Wu, Jason Chuang, Christopher D Manning, Andrew Y $\mathrm { N g }$ , and Christopher Potts. Recursive deep models for semantic compositionality over a sentiment treebank. In EMNLP, 2013.
|
| 306 |
+
[62] Christian Szegedy, Vincent Vanhoucke, Sergey Ioffe, Jonathon Shlens, and Zbigniew Wojna. Rethinking the inception architecture for computer vision. In CVPR, 2016.
|
| 307 |
+
[63] Derek Tam, Rakesh R Menon, Mohit Bansal, Shashank Srivastava, and Colin Raffel. Improving and simplifying pattern exploiting training. In EMNLP, 2021.
|
| 308 |
+
[64] Lisa Torrey and Jude Shavlik. Transfer learning. In Handbook of research on machine learning applications and trends: algorithms, methods, and techniques. 2010.
|
| 309 |
+
[65] 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.
|
| 310 |
+
[66] Alex Wang, Amanpreet Singh, Julian Michael, Felix Hill, Omer Levy, and Samuel R Bowman. GLUE: A multi-task benchmark and analysis platform for natural language understanding. In EMNLP Workshop BlackboxNLP, 2018.
|
| 311 |
+
[67] Alex Wang, Yada Pruksachatkun, Nikita Nangia, Amanpreet Singh, Julian Michael, Felix Hill, Omer Levy, and Samuel R. Bowman. SuperGLUE: A stickier benchmark for general-purpose language understanding systems. In NeurIPS, 2019.
|
| 312 |
+
[68] Zirui Wang, Adams Wei Yu, Orhan Firat, and Yuan Cao. Towards zero-label language learning. arXiv preprint arXiv:2109.09193, 2021.
|
| 313 |
+
[69] Alex Warstadt, Amanpreet Singh, and Samuel R Bowman. Neural network acceptability judgments. In TACL, 2019.
|
| 314 |
+
[70] 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 ICLR, 2022.
|
| 315 |
+
[71] Sean Welleck, Ilia Kulikov, Stephen Roller, Emily Dinan, Kyunghyun Cho, and Jason Weston. Neural text generation with unlikelihood training. In ICLR, 2020.
|
| 316 |
+
[72] Adina Williams, Nikita Nangia, and Samuel Bowman. A broad-coverage challenge corpus for sentence understanding through inference. In NAACL-HLT, 2018.
|
| 317 |
+
[73] Qizhe Xie, Zihang Dai, Eduard H. Hovy, Minh-Thang Luong, and Quoc V. Le. Unsupervised data augmentation for consistency training. In NeurIPS, 2020.
|
| 318 |
+
[74] Hanwei Xu, Yujun Chen, Yulun Du, Nan Shao, Yanggang Wang, Haiyu Li, and Zhilin Yang. ZeroPrompt: Scaling prompt-based pretraining to 1, 000 tasks improves zero-shot generalization. ArXiv, abs/2201.06910, 2022.
|
| 319 |
+
[75] Kevin Yang and Dan Klein. FUDGE: Controlled text generation with future discriminators. In NAACL, 2021.
|
| 320 |
+
[76] Yiben Yang, Chaitanya Malaviya, Jared Fernandez, Swabha Swayamdipta, Ronan Le Bras, Ji Ping Wang, Chandra Bhagavatula, Yejin Choi, and Doug Downey. Generative data augmentation for commonsense reasoning. In Findings of EMNLP, 2020.
|
| 321 |
+
[77] Jiacheng Ye, Jiahui Gao, Qintong Li, Hang Xu, Jiangtao Feng, Zhiyong Wu, Tao Yu, and Lingpeng Kong. ZeroGen: Efficient zero-shot learning via dataset generation. ArXiv, abs/2202.07922, 2022.
|
| 322 |
+
[78] Qinyuan Ye, Bill Yuchen Lin, and Xiang Ren. Crossfit: A few-shot learning challenge for cross-task generalization in nlp. In EMNLP, 2021.
|
| 323 |
+
[79] Wenpeng Yin, Jamaal Hay, and Dan Roth. Benchmarking zero-shot text classification: Datasets, evaluation and entailment approach. In EMNLP, 2019.
|
| 324 |
+
[80] Wenpeng Yin, Nazneen Rajani, Dragomir Radev, Richard Socher, and Caiming Xiong. Universal natural language processing with limited annotations: Try few-shot textual entailment as a start. In EMNLP, 2020.
|
| 325 |
+
[81] Kang Min Yoo, Dongju Park, Jaewook Kang, Sang-Woo Lee, and Woomyeong Park. GPT3Mix: Leveraging large-scale language models for text augmentation. In EMNLP Findings, 2021.
|
| 326 |
+
[82] Weizhe Yuan, Graham Neubig, and Pengfei Liu. BARTScore: Evaluating generated text as text generation. In NeurIPS, 2021.
|
| 327 |
+
[83] Chiyuan Zhang, Samy Bengio, Moritz Hardt, Benjamin Recht, and Oriol Vinyals. Understanding deep learning requires rethinking generalization. In ICLR, 2017.
|
| 328 |
+
[84] Ningyu Zhang, Luoqiu Li, Xiang Chen, Shumin Deng, Zhen Bi, Chuanqi Tan, Fei Huang, and Huajun Chen. Differentiable prompt makes pre-trained language models better few-shot learners. In ICLR, 2022.
|
| 329 |
+
[85] Tony Zhao, Eric Wallace, Shi Feng, Dan Klein, and Sameer Singh. Calibrate before use: Improving few-shot performance of language models. In ICML, 2021.
|
| 330 |
+
[86] Ruiqi Zhong, Kristy Lee, Zheng Zhang, and Dan Klein. Adapting language models for zero-shot learning by meta-tuning on dataset and prompt collections. In Findings of EMNLP, 2021.
|
| 331 |
+
[87] Fuzhen Zhuang, Zhiyuan Qi, Keyu Duan, Dongbo Xi, Yongchun Zhu, Hengshu Zhu, Hui Xiong, and Qing He. A comprehensive survey on transfer learning. Proceedings of the IEEE, 2020.
|
| 332 |
+
[88] Daniel M. Ziegler, Nisan Stiennon, Jeff Wu, Tom B. Brown, Alec Radford, Dario Amodei, Paul Christiano, and Geoffrey Irving. Fine-tuning language models from human preferences. ArXiv, abs/1909.08593, 2019.
|
| 333 |
+
|
| 334 |
+
# Checklist
|
| 335 |
+
|
| 336 |
+
1. For all authors...
|
| 337 |
+
|
| 338 |
+
(a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes]
|
| 339 |
+
(b) Did you describe the limitations of your work? [Yes]
|
| 340 |
+
(c) Did you discuss any potential negative societal impacts of your work? [Yes]
|
| 341 |
+
(d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
|
| 342 |
+
|
| 343 |
+
2. If you are including theoretical results...
|
| 344 |
+
|
| 345 |
+
(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]
|
| 346 |
+
|
| 347 |
+
3. If you ran experiments...
|
| 348 |
+
|
| 349 |
+
(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]
|
| 350 |
+
(b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes]
|
| 351 |
+
(c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [Yes]
|
| 352 |
+
(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]
|
| 353 |
+
|
| 354 |
+
4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
|
| 355 |
+
|
| 356 |
+
(a) If your work uses existing assets, did you cite the creators? [Yes]
|
| 357 |
+
(b) Did you mention the license of the assets? [Yes]
|
| 358 |
+
(c) Did you include any new assets either in the supplemental material or as a URL? [N/A]
|
| 359 |
+
(d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [N/A]
|
| 360 |
+
|
| 361 |
+
(e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [N/A]
|
| 362 |
+
|
| 363 |
+
5. If you used crowdsourcing or conducted research with human subjects...
|
| 364 |
+
|
| 365 |
+
(a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A]
|
| 366 |
+
(b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A]
|
| 367 |
+
(c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]
|
md/dev/4R7YrAGhnve/4R7YrAGhnve.md
ADDED
|
@@ -0,0 +1,255 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# SegViT: Semantic Segmentation with Plain Vision Transformers
|
| 2 |
+
|
| 3 |
+
Bowen Zhang1∗, Zhi Tian2∗, Quan Tang4, Xiangxiang $\mathbf { C h u ^ { 2 } }$ , Xiaolin Wei2, Chunhua Shen3, Yifan Liu1
|
| 4 |
+
|
| 5 |
+
1 The University of Adelaide, Australia 2 Meituan Inc. 3 Zhejiang University, China 4 South China University of Technology, China
|
| 6 |
+
|
| 7 |
+
# Abstract
|
| 8 |
+
|
| 9 |
+
We explore the capability of plain Vision Transformers (ViTs) for semantic segmentation and propose the SegViT. Previous ViT-based segmentation networks usually learn a pixel-level representation from the output of the ViT. Differently, we make use of the fundamental component—attention mechanism, to generate masks for semantic segmentation. Specifically, we propose the Attention-to-Mask (ATM) module, in which the similarity maps between a set of learnable class tokens and the spatial feature maps are transferred to the segmentation masks. Experiments show that our proposed $\mathrm { S e g V i T }$ using the ATM module outperforms its counterparts using the plain ViT backbone on the ADE20K dataset and achieves new state-of-the-art performance on COCO-Stuff-10K and PASCAL-Context datasets. Furthermore, to reduce the computational cost of the ViT backbone, we propose query-based down-sampling (QD) and query-based up-sampling (QU) to build a Shrunk structure. With the proposed Shrunk structure, the model can save up to $4 0 \%$ computations while maintaining competitive performance.
|
| 10 |
+
|
| 11 |
+
# 1 Introduction
|
| 12 |
+
|
| 13 |
+
Semantic segmentation is a dense prediction task in computer vision that requires pixel-level classification of an input image. Fully Convolutional Networks (FCN) [1] are widely used in recent state-of-the-art methods. This paradigm includes a deep convolutional neural network as the encoder/backbone and a segmentation-oriented decoder to provide dense predictions. A $1 \times 1$ convolutional layer is usually applied to a representative feature map to obtain the pixel level predictions. To achieve higher performance, previous works [2–4] focus on enriching the context information or fusing multi-scale information. However, the correlations among spatial locations are hard to model explicitly in FCNs due to the limited receptive field.
|
| 14 |
+
|
| 15 |
+
Recently, Vision Transformers (ViT) [5], which make use of the spatial attention mechanism are introduced to the field of computer vision. Unlike typical convolution-based backbones, the ViT has a plain and non-hierarchical architecture that keeps the resolution of the feature maps all the way through. The lack of the down-sampling process (excluding tokenizing the image) brings differences to the architecture to do the semantic segmentation task using ViT backbone. Various semantic segmentation methods [6–8] based on ViT backbones have achieved promising performance due to the powerful representation learned from the pre-trained backbones. However, the potential of the attention mechanism is not fully explored.
|
| 16 |
+
|
| 17 |
+
Different from previous per-pixel classification paradigm [6–8], we consider learning a meaningful class token and then finding local patches with higher similarity to it. To achieve this goal, we propose the Attention-to-Mask (ATM) module. More specifically, we employ a transformer block that takes the learnable class tokens as queries and transfers the spatial feature maps as keys and values. A dot-product operator calculates the similarity maps between queries and keys. We encourage regions belonging to the same category to generate larger similarity values for the corresponding category (i.e. a specific class token). Fig. 1 visualizes the similarity maps between the features and the ‘Table’ and ‘Chair’ tokens. By simply applying a Sigmoid operation, we can transfer the similarity maps to the masks. Meanwhile, following the design of a typical transformer block, a Softmax operation is also applied to the similarity maps to get the cross attention maps. The ‘Table’ and ‘Chair’ tokens are then updated as in any regular transformer decoders, by a weighted sum of the values with the cross attention maps as the weights. Since the mask is a byproduct of the regular attentive calculations, negligible computation is involved during the operation.
|
| 18 |
+
|
| 19 |
+
Building upon this efficient ATM module, we propose a new semantic segmentation paradigm with the plain ViT structure, dubbed $\mathrm { { S e g V i T } }$ . In the paradigm, several ATM modules are employed on different layers, and we get the final segmentation mask by adding the outputs from different layers together. $\mathrm { S e g V i T }$ outperforms its ViT-based counterparts with less computational cost. However, compared with previous encoder-decoder structures that use hierarchical networks as encoders, ViT backbones as encoders are generally heavier. To further reduce the computational cost, we employ a Shrunk structure consisting of query-based down-sampling (QD) and query-based up-sampling (QU). The QD can be inserted into the ViT backbone to reduce the resolution by half and QU is used parallel to the backbone to recover the resolution. The Shrunk structure together with the ATM module as the decoder can reduce up to $4 0 \%$ computations while maintaining competitive performance.
|
| 20 |
+
|
| 21 |
+
We summarize our main contributions as follows:
|
| 22 |
+
|
| 23 |
+
• We propose an Attention-to-Mask (ATM) decoder module that is effective and efficient for semantic segmentation. For the first time, we utilize the spatial information in attention maps to generate mask predictions for each category, which can work as a new paradigm for semantic segmentation.
|
| 24 |
+
• We managed to apply our ATM decoder module to the plain, non-hierarchical ViT backbones in a cascade manner and designed a structure namely $\mathrm { S e g V i T }$ that achieves mIoU $5 5 . 2 \%$ on the competitive ADE20K dataset which is the best and lightest among methods that use ViT backbones. We also benchmark our method on the PASCAL-Context dataset $( 6 5 . 3 \%$ mIoU) and COCO-Stuff-10K dataset $( 5 0 . 3 \%$ mIoU) and achieve new state-of-the-art performance.
|
| 25 |
+
We further explore the architecture of ViT backbones and work out a Shrunk structure to apply to the backbone to reduce the overall computational cost while still maintaining competitive performance. This alleviates the disadvantage of ViT backbones that are usually more computationally intensive compared to their hierarchical counterparts. Our Shrunk version of $\mathrm { S e g V i T }$ on the ADE20K dataset reaches mIoU $5 5 . 1 \%$ with the computational cost of 373.5 GFLOPs which is about $4 0 \%$ off compared to the original SegViT (637.9 GFLOPs).
|
| 26 |
+
|
| 27 |
+
# 2 Related Work
|
| 28 |
+
|
| 29 |
+
Semantic segmentation. Semantic segmentation which requires pixel-level classification on an input image is a fundamental task in computer vision. Fully Convolutional Networks (FCN) used to be the dominant approach to this task. Initial per-pixel approaches such as [9, 10] attribute the class label to each pixel based on the per-pixel probability. To enlarge the receptive field, several approaches [11, 12] have proposed dilated convolutions or apply spatial pyramid pooling to capture contextual information of multiple scales. With the introduction of attention mechanisms, [13, 14, 6] replace the feature merge conducted by convolutions and pooling with attention to better capture long-range dependencies.
|
| 30 |
+
|
| 31 |
+
Recent works [15, 8, 16] decouple the per-pixel classification process. They reconstruct the structure by using a fixed number of learnable tokens and use them as weights for the transformation to apply on feature maps. Binary matching rather than cross-entropy is used to allow overlaps between feature maps and learnable tokens are used to dynamically generate classification probabilities. This paradigm enables the classification process to be conducted globally and alleviates the burden for the decoder to do per-pixel classification, which as a result, is more precise and the performance is generally better. However, for those methods, the feature map is still calculated in a static manner, usually requiring feature merge modules such as FPN [4].
|
| 32 |
+
|
| 33 |
+

|
| 34 |
+
Figure 1: The overall concept of our Attention-to-Mask decoder. In a typical attentive process, the dot-product is first calculated between queries and keys to measure the similarity (as illustrated on the left). If the similarity map is applied with Softmax operation on the spatial dimension, the output is the typical attention map (multiple heads are summed together). However, if the same similarity map is applied with a per-pixel operation Sigmoid, it produces a mask that indicates the area with certain similarity. Based on the assumption that the tokens within the same category have higher similarity, we can train a token vector to have high similarity within tokens of the specific category and low similarity elsewhere. In the meantime, this process does not violate the attention mechanism. Thus, it can process alongside the original transformer layers.
|
| 35 |
+
|
| 36 |
+
Transformers for vision. Attention-based transformer backbones have become powerful alternatives to standard convolution based networks for image classification tasks. The original ViT [5] is a plain, non-hierarchical architecture. Various hierarchical transformers such as [17–21] have been presented afterwards. These methods inherit some designs from convolution based networks such as hierarchical structures, pooling and down-sampling with convolutions. As a result, they can be used as a straightforward replacement for convolutional based networks and applied with previous decoder heads for tasks such as semantic segmentation.
|
| 37 |
+
|
| 38 |
+
Plain-backbone decoders. High-resolution feature maps generated by backbones are important for dense prediction tasks such as semantic segmentation. Typical hierarchical transformers use feature merge techniques such as FPN [4] or dilated backbones to generate high-resolution feature maps. However, for plain, non-hierarchical transformer backbones, the resolution remains the same for all layers. SETR [6] proposed a simple strategy to treat transformer outputs in a sequence-to-sequence perspective to solve segmentation tasks. Segmenter [8] joints random initialized class embeddings and the transformer patch embeddings together and applies several self-attention layers to the joint token sequence to obtain updated class embeddings and patch embeddings semantic prediction. In our study, we consider learning a class token and then finding local patches with higher similarities with the help of the attention map, making the inference process more direct and efficient.
|
| 39 |
+
|
| 40 |
+
# 3 Method
|
| 41 |
+
|
| 42 |
+
# 3.1 Encoder
|
| 43 |
+
|
| 44 |
+
Given an input image $I \in \mathbb { R } ^ { H \times W \times 3 }$ , a plain vision transformer backbone reshapes it into a sequence of tokens $\dot { \mathcal { F } } _ { 0 } \in \mathbb { R } ^ { \tilde { L } \times C }$ where ${ \cal L } = { \cal H } \bar { W } / P ^ { 2 }$ , $P$ is the patch size and $C$ is the number of channels. Learnable position embeddings of the same size of $\mathcal { F } _ { 0 }$ are added to capture the positional information. Then, the token sequence $\mathcal { F } _ { 0 }$ is applied with $m$ transformer layers to get the output. We define the output tokens for each layer as $[ \mathcal { F } _ { 1 } , \mathcal { F } _ { 2 } , \ldots , \mathcal { F } _ { m } ] \in \mathbb { R } ^ { L \times C }$ . Typically, a transformer layer consists of a multi-head self-attention block followed by a point-wise multilayer perceptron block with layer norm in between and then a residual connection is added afterward. The transformer layers are stacked repetitively several times. For a plain vision transformer like ViT, there are no other modules involved and for each layer, the number of the tokens is not changed.
|
| 45 |
+
|
| 46 |
+

|
| 47 |
+
Figure 2: The overall SegViT structure with the ATM module. The Attention-to-Mask (ATM) module inherits the typical transformer decoder structure. It takes in randomly initialized class embeddings as queries and the feature maps from the ViT backbone to generate keys and values. The outputs of the ATM module are used as the input queries for the next layer. The ATM module is carried out sequentially with inputs from different layers of the backbone as keys and values in a cascade manner. A linear transform is then applied to the output of the ATM module to produce the class predictions for each token. The mask for the corresponding class is transferred from the similarities between queries and keys in the ATM module.
|
| 48 |
+
|
| 49 |
+
# 3.2 Decoder
|
| 50 |
+
|
| 51 |
+
Mask-to-Attention (ATM). Cross attention can be described as the mapping between two sequences of tokens. We define two token sequences as $\mathcal { G } \in \mathbb { R } ^ { N \times C }$ with the length $N$ equals to the number of classes and $\mathcal { F } _ { i } \in \mathbb { R } ^ { L \times C }$ . First, linear transformations are applied to each of them to form query (Q), key (K) and values (V), as presented by Eq. (1).
|
| 52 |
+
|
| 53 |
+
$$
|
| 54 |
+
Q = \phi _ { q } ( \mathcal { G } ) \in \mathbb { R } ^ { N \times C } , K = \phi _ { k } ( \mathcal { F } _ { i } ) \in \mathbb { R } ^ { L \times C } , V = \phi _ { v } ( \mathcal { F } _ { i } ) \in \mathbb { R } ^ { L \times C } ,
|
| 55 |
+
$$
|
| 56 |
+
|
| 57 |
+
The similarity map is calculated between the query and the key. Following the scaled dot-product attention mechanism, the similarity map and attention map are calculated by:
|
| 58 |
+
|
| 59 |
+
$$
|
| 60 |
+
\begin{array} { c } { S ( Q , K ) = \displaystyle \frac { Q K ^ { T } } { \sqrt { d _ { k } } } \in \mathbb { R } ^ { N \times L } , } \\ { A t t e n t i o n ( \mathcal { G } , \mathcal { F } _ { i } ) = \displaystyle \mathtt { S o f t m a x } ( S ( Q , K ) ) V \in \mathbb { R } ^ { N \times C } , } \end{array}
|
| 61 |
+
$$
|
| 62 |
+
|
| 63 |
+
where $\sqrt { d _ { k } }$ is a scaling factor with $d _ { k }$ equals to the dimension of the keys. The shape of the similarity map $S ( Q , K )$ is determined by the length of the two token sequences $N$ and $L$ . The attention mechanism is then to update $\mathcal { G }$ by a weighted sum of $V$ , where the weight assigned to the summation is the similarity map applied with Softmax along the dimension $L$ .
|
| 64 |
+
|
| 65 |
+
Dot-product attention uses the Softmax function to exclusively concentrate the attention on the token that has the most similarity. However, we suppose that the tokens other than ones that yield maximum similarities are also meaningful. Based on this intuition, we design a lightweight module that generates semantic predictions more directly. To be more specific, we assign $\mathcal { G }$ as the class embeddings for the segmentation task and ${ \mathcal { F } } _ { i }$ as the output of layer $i$ of the ViT backbone. We pair a semantic mask to each token in $\mathcal { G }$ to represent the semantic prediction for each class. The calculation for the mask is:
|
| 66 |
+
|
| 67 |
+
$$
|
| 68 |
+
M a s k ( \mathcal { G } , \mathcal { F } _ { i } ) = \operatorname { S i g m o i d } ( S ( Q , K ) ) \in \mathbb { R } ^ { N \times L }
|
| 69 |
+
$$
|
| 70 |
+
|
| 71 |
+
The shape of the masks is $N \times L$ , which can be further reshaped to $N \times H / P \times W / P$ . The structure of the ATM mechanism is illustrated in the right part in Fig. 2. Masks are the middle output of the cross attention. The final output tokens from the ATM module are used for classification. We apply a linear transformation followed by a Softmax activation to the output class tokens to get class probability predictions. Note that we follow [15] to add a ‘no object’ category $( \varnothing )$ in case the image doesn’t contain certain classes. During inference, the output is produced by the dot-product between the class probability and the mask groups.
|
| 72 |
+
|
| 73 |
+

|
| 74 |
+
Figure 3: The structure comparison between $\mathbf { S e g V i T }$ with a single layer and the Shrunk version. (a) illustrates the $\mathrm { S e g V i T }$ structure with ATM module used once with the last layer of the ViT backbone as the input to generate predictions. (b) uses the query-based down-sampling (QD) module to implement a naive way to shrink the resolution of the features of the backbone from $^ { 1 / 1 6 }$ to $^ { 1 / 3 2 }$ and thus reduces the overall computational cost. (c) is the proposed (shrunk) version which applies the additional query-based up-sampling module. The Shrunk version can save up to $40 \%$ of computational cost when using the ViT-Large backbone without much sacrifice to the performance.
|
| 75 |
+
|
| 76 |
+
Plain backbones such as ViT does not have multiple stages with features of different scale. Thus, structures such as FPN to merge features with multiple scales are not applicable. However, features other than the last layer contain rich low-level semantic information and are beneficial to the performance. We designed a structure that can make use of the feature maps from different layers of ViT to compact with our ATM decoder namely $\mathrm { S e g V i T }$ . In this study, we also found a way to compact the computational cost for the ViT backbone without sacrificing performance. This proposed Shrunk version of $\mathrm { S e g V i T }$ uses query-based down-sampling (QD) module together with a query-based up-sampling (QU) module to compress the ViT backbone and bring an overall reduction to the computational cost.
|
| 77 |
+
|
| 78 |
+
The SegViT structure. As illustrated in Fig. 2, an ATM decoder takes in $N$ tokens as the class embeddings and another sequence of tokens as the base to calculate keys and values for the ATM module to generate masks. The output of the ATM is $N$ updated tokens and $N$ masks corresponding to each class token. We use random initialized learnable tokens as the class embeddings and the output of the last layer of the ViT backbone as the base first. To make use of multi-layer information, the output of the first ATM decoder is then used as the class embeddings for the next ATM decoder with the output of another layer of the ViT backbone as the base. This process is repeated another time so that we can get three groups of tokens and masks. Formally, the loss function of each layer can be formulated as,
|
| 79 |
+
|
| 80 |
+
$$
|
| 81 |
+
\mathcal { L } _ { o v e r a l l } = \mathcal { L } _ { c l s } + \mathcal { L } _ { m a s k } = \mathcal { L } _ { c l s } + \lambda _ { f o c a l } \mathcal { L } _ { I o U } + \lambda _ { d i c e } \mathcal { L } _ { d i c e }
|
| 82 |
+
$$
|
| 83 |
+
|
| 84 |
+
In each group, the output tokens are supervised by the classification loss $( \mathcal { L } _ { c l s } )$ which is mentioned above and the masks are summed orderly and supervised by the mask loss $( \mathcal { L } _ { m a s k } )$ which is a linear combination of a focal loss [22] and a dice loss [23] multiplied by hyper-parameters $\lambda _ { f o c a l }$ and $\lambda _ { d i c e }$ respectively as in DETR [24]. The loss of all three groups are then summed together. We have further experiments to show that this design is beneficial and efficient.
|
| 85 |
+
|
| 86 |
+
The Shrunk structure. Plain transformer backbones such as ViT is known to have larger computational cost than their counterparts with similar performance. We propose a Shrunk structure using query-based down-sampling (QD) and up-sampling (QU). Since the shape of the output of the attention module is determined by the shape of the query, we can apply down-sampling before the query transformation to realize the QD or insert new query tokens during the cross attention to realize the QU. By changing the resolution with the number of query tokens, the spatial size is changed according to the cross attention, providing more flexibility to preserve (recover) important regions. To be more specific, in the QD layer, we use the nearest sampling to reduce the number of the query tokens while keep the size of the key and value tokens. When passing through a transformer layer, the values are weighted and summed by the attention map between query tokens and the key tokens. This is non-linear downsampling that will pay more attention to the important regions. In the QU layer, we employ a transformer decoder structure [25] and initialize new learnable tokens as queries based on the desired output resolution.
|
| 87 |
+
|
| 88 |
+
As shown in Fig. 3, we design the $\mathrm { S e g V i T }$ structure with one single layer as the baseline (a). We first try a naive approach (b), which is to apply the QD once at the $^ 1 / 3$ depth of the backbone (e.g., the 8th layer of a backbone with 24 layers) to down-sample the resolution of the layer output from $^ { 1 / 1 6 }$ to $1 / \bar { 3 } 2$ so as to reduce the overall computational cost. The performance drops as expected since the QD process involves information lose.
|
| 89 |
+
|
| 90 |
+
To compensate for the information loss in the naive ‘shrunk’ version, we further apply two QU layers in parallel with the backbone. This is our proposed Shrunk version (c). The first QU layer takes in features with $^ { 1 / 1 6 }$ resolution from the low level of the backbone. Its output is then used as the query to make cross attention with the down-sampled features with $^ { 1 / 3 2 }$ resolution from the last layer of the backbone. The shape of the output of this QU structure is of $^ { 1 / 1 6 }$ resolution.
|
| 91 |
+
|
| 92 |
+
Directly reducing the number of the query tokens inevitably harms the final performance. However, with our designed QU layer and the ATM module, the Shrunk structure is able to reduce $4 0 \%$ of overall computational cost while still being competitive in performance.
|
| 93 |
+
|
| 94 |
+
# 4 Experiments
|
| 95 |
+
|
| 96 |
+
# 4.1 Datasets
|
| 97 |
+
|
| 98 |
+
ADE20K [26] is a challenging scene parsing dataset which contains 20, 210 images as the training set and 2, 000 images as the validation set with 150 semantic classes.
|
| 99 |
+
|
| 100 |
+
COCO-Stuff-10K [27] is a scene parsing benchmark with 9, 000 training images and 1, 000 test images. Even though the dataset contains 182 categories, not all categories exist in the test split. We follow the implementation of mmsegmentation [28] with 171 categories to conduct the experiments.
|
| 101 |
+
|
| 102 |
+
PASCAL-Context [29] is a dataset with 4, 996 images in training set and 5, 104 images in the validation set. There are 60 semantic classes in total, including a class representing ‘background’.
|
| 103 |
+
|
| 104 |
+
# 4.2 Implementation details
|
| 105 |
+
|
| 106 |
+
Transformer backbone. We use the naive ViT [5] as the backbone. In particular, we use its ‘Base’ variation for most ablation studies and provide results on the ‘Large’ variation. Since there can be a huge difference with different pre-trained weights, as suggested by Segmenter [8], we use the weights provided by Augreg [30] following the counterparts [8, 31] for a fair comparison. The weights are obtained by training on ImageNet-21k with strong data augmentation and regularization. For a simple reference, we report that for pre-trained weights provided by ViT [5] and Augreg [30], the mIoU scores using the same training recipe on ADE20K dataset are $5 1 . 7 \%$ and $5 4 . 6 \%$ , respectively. Training settings. We use MMSegmentation [28] and follow the commonly used training settings. During training, we applied data augmentation sequentially via random horizontal flipping, random resize with the ration between 0.5 and 2.0 and random cropping $5 1 2 \times 5 1 2$ for all except that we use $4 8 0 \times 4 8 0$ for PASCAL-Context and $6 4 0 \times 6 4 0$ for ViT-large on ADE20K). The batch size is 16 for all datasets with a total iteration of $1 6 0 k$ , $8 0 k$ and $8 0 k$ for ADE20k, COCO-Stuff-10k and PASCAL-Context respectively. Evaluation metric. We use the mean Intersection over Union (mIoU) as the metric to evaluate the performance. ‘ss’ means single-scale testing and ‘ms’ test time augmentation with multi-scaled (0.5, 0.75, 1.0, 1.25, 1.5, 1.75) inputs. All reported mIoU scores are in a percentage format. All reported computational costs in GFLOPs are measured using the fvcore 2 library.
|
| 107 |
+
|
| 108 |
+
# 4.3 Comparisons with the State-of-the-art Methods
|
| 109 |
+
|
| 110 |
+
Results on ADE20K. Table 1 reports the comparison with the state-of-the-art methods on ADE20K validation set using ViT backbone. The SegViT uses the ATM module with multi-layer inputs from the original ViT backbone, while the Shrunk is the one that conducts QD to the ViT backbone and saves $4 0 \%$ of the computational cost without sacrificing too much performance. Our method achieves
|
| 111 |
+
|
| 112 |
+
Table 1: Experiment results on the ADE20K val. split. ‘ms’ means that mIoU is calculated using multi-scale inference. ‘†’ means the models use the backbone weights pre-trained by AugReg [30]. ‘\*’ represents the model is reproduced under the same settings as the official repo. The GFLOPs is measured at single-scale inference with the given crop size.
|
| 113 |
+
|
| 114 |
+
<table><tr><td>Method</td><td>Backbone</td><td>Crop Size</td><td>GFLOPs</td><td>mIoU (ss)</td><td>mIoU (ms)</td></tr><tr><td>UperNet* [32]</td><td>ViT-Base</td><td>512 × 512</td><td>>250</td><td>46.6</td><td>47.5</td></tr><tr><td>DPT*[7]</td><td>ViT-Base</td><td>512 × 512</td><td>219.8</td><td>47.2</td><td>47.9</td></tr><tr><td>SETR-MLA* [6]</td><td>ViT-Base</td><td>512 × 512</td><td>113.5</td><td>48.2</td><td>49.3</td></tr><tr><td>Segmenter* [8]</td><td>ViT-Base</td><td>512 × 512</td><td>129.6</td><td>49.0</td><td>50.0</td></tr><tr><td>StructToken [31]</td><td>ViT-Base</td><td>512 × 512</td><td>>150</td><td>50.9</td><td>51.8</td></tr><tr><td>SegViT (Ours)</td><td>ViT-Base</td><td>512 × 512</td><td>120.9</td><td>51.3</td><td>53.0</td></tr><tr><td>DPT* [7]</td><td>ViT-Large†</td><td>640 × 640</td><td>479.0</td><td>49.2</td><td>49.5</td></tr><tr><td>UperNet* [32]</td><td>ViT-Larget</td><td>640 × 640</td><td>>700</td><td>48.6</td><td>50.0</td></tr><tr><td>SETR-MLA [6]</td><td>ViT-Large</td><td>512 × 512</td><td>368.6</td><td>48.6</td><td>50.3</td></tr><tr><td>MCIBI [33]</td><td>ViT-Large</td><td>512 × 512</td><td>>400</td><td>1</td><td>50.8</td></tr><tr><td>Segmenter [8]</td><td>ViT-Large†</td><td>640 × 640</td><td>671.8</td><td>51.8</td><td>53.6</td></tr><tr><td>StructToken [31]</td><td>ViT-Larget</td><td>640 × 640</td><td>>700</td><td>52.8</td><td>54.2</td></tr><tr><td>SegViT (Shrunk, ours)</td><td>ViT-Large†</td><td>640 × 640</td><td>373.5</td><td>53.9</td><td>55.1</td></tr><tr><td>SegViT (ours)</td><td>ViT-Larget</td><td>640 × 640</td><td>637.9</td><td>54.6</td><td>55.2</td></tr></table>
|
| 115 |
+
|
| 116 |
+
$5 5 . 2 \%$ in terms of mIoU with the ViT-Large backbone. It is $1 . 0 \%$ better than the recent StructToken [31] using the same backbone. Besides, our Shrunk version can also achieve a similar performance $5 5 . 1 \%$ with computational cost 373.5 GFLOPs which is much less than the ViT-Large backbone alone (612.3 GFLOPs).
|
| 117 |
+
|
| 118 |
+
Results on COCO-Stuff-10K. Table 2 shows the result on the COCO-Stuff-10K dataset. Our method achieves $5 0 . 3 \%$ which is higher than the previous state-to-the-art StrucToken by $1 . 2 \%$ with less computational cost. Our Shrunk version achieves $4 9 . 4 \%$ with 224.8 GFLOPs, which is similar to the computational cost of a dilated ResNet-101 backbone but with much higher performance.
|
| 119 |
+
|
| 120 |
+
Table 2: Experiment results on the COCO-Stuff-10K test. split. Following published methods, we report the results with multi-scale inference (denoted by ‘ms’). The GFLOPs is measured at single scale inference with a crop size of $5 1 2 \times 5 1 2$ .
|
| 121 |
+
|
| 122 |
+
<table><tr><td>Method</td><td>Backbone</td><td>GFLOPs</td><td>mIoU (ms)</td></tr><tr><td>DANet [34]</td><td>Dilated-ResNet-101</td><td>289.3</td><td>39.7</td></tr><tr><td>MaskFormer[15]</td><td>ResNet-101-fpn</td><td>81.7</td><td>39.8</td></tr><tr><td>EMANet [35]</td><td>Dilated-ResNet-101</td><td>247.4</td><td>39.9</td></tr><tr><td>SpyGR [36]</td><td>ResNet-101-fpn</td><td>v80</td><td>39.9</td></tr><tr><td>OCRNet [3]</td><td>HRNetV2-W48</td><td>167.9</td><td>40.5</td></tr><tr><td>GINet [37]</td><td>JPU-ResNet-101</td><td>>200</td><td>40.6</td></tr><tr><td>RecoNet [38]</td><td>Dilated-ResNet-101</td><td>>200</td><td>41.5</td></tr><tr><td>ISNet [39]</td><td>Dilated-ResNeSt-101</td><td>228.3</td><td>42.1</td></tr><tr><td>MCIBI [33]</td><td>ViT-Large</td><td>>380</td><td>44.9</td></tr><tr><td>StructToken [31]</td><td>ViT-Large</td><td>>400</td><td>49.1</td></tr><tr><td>SegViT (Shrunk, ours)</td><td>ViT-Large</td><td>224.8</td><td>49.4</td></tr><tr><td>SegViT (ours)</td><td>ViT-Large</td><td>383.9</td><td>50.3</td></tr></table>
|
| 123 |
+
|
| 124 |
+
Results on PASCAL-Context. Table 3 shows the results on the PASCAL-Context dataset. We follow HRNet [40] to evaluate our method and report the results under 59 classes (without background) and 60 classes (with background). $\mathrm { S e g V i T }$ reaches mIoU $6 5 . 3 \%$ and $5 9 . 3 \%$ respectively for those two metrics that outperform the state-of-the-art methods using the ViT backbones with less computational cost.
|
| 125 |
+
|
| 126 |
+
Table 3: Expperiment results on the PASCAL-Context val. split. Following published methods, we report the results with multi-scale inference (denoted by ‘ms’). $\mathrm { m I o U _ { 5 9 } }$ : mIoU averaged over 59 classes (without background). $\mathrm { m I o U _ { 6 0 } }$ : mIoU averaged over 60 classes (59 classes plus background). Both metrics were used in the literature; and we report for the 60 classes. The GFLOPs is measured at single scale inference with a crop size of $4 8 0 \times 4 8 0$ .
|
| 127 |
+
|
| 128 |
+
<table><tr><td>Method</td><td>Backbone</td><td>GFLOPs</td><td>mIoU59 (ms)</td><td>mIoU60 (ms)</td></tr><tr><td>RefineNet [41]</td><td>ResNet-152</td><td></td><td>=</td><td>47.3</td></tr><tr><td>UNet++ [42]</td><td>ResNet-101</td><td>=</td><td>47.7</td><td>1</td></tr><tr><td>PSPNet [11]</td><td>Dilated-ResNet-101</td><td>157.0</td><td>47.8</td><td></td></tr><tr><td>Ding et al. [43]</td><td>ResNet-101</td><td>=</td><td>51.6</td><td></td></tr><tr><td>EncNet [44]</td><td>Dilated-ResNet-101</td><td>192.1</td><td>52.6</td><td>=</td></tr><tr><td>HRNet [40]</td><td>HRNetV2-W48</td><td>82.7</td><td>54.0</td><td>48.3</td></tr><tr><td>NRD [45]</td><td>ResNet-101</td><td>42.9</td><td>54.1</td><td>49.0</td></tr><tr><td>GFFNet [46]</td><td>Dilated-ResNet-101</td><td>=</td><td>54.3</td><td>1</td></tr><tr><td>EfficientFCN [47]</td><td>ResNet-101</td><td>52.8</td><td>55.3</td><td></td></tr><tr><td>OCRNet [3]</td><td>HRNetV2-W48</td><td>143.9</td><td>56.2</td><td>=</td></tr><tr><td>SETR-MLA [6]</td><td>ViT-Large</td><td>318.5</td><td>1</td><td>55.8</td></tr><tr><td>Segmenter [8]</td><td>ViT-Large</td><td>346.2</td><td>1</td><td>59.0</td></tr><tr><td>SegViT (Shrunk, ours)</td><td>ViT-Large</td><td>186.9</td><td>63.7</td><td>57.4</td></tr><tr><td>SegViT (ours)</td><td>ViT-Large</td><td>321.6</td><td>65.3</td><td>59.3</td></tr></table>
|
| 129 |
+
|
| 130 |
+
# 4.4 Ablation Study
|
| 131 |
+
|
| 132 |
+
In this section, we conduct the ablation study to show the effectiveness of our proposed methods.
|
| 133 |
+
|
| 134 |
+
Effect of the ATM module. Table 4 shows the effect of the ATM module. We set the SETR-naive as the baseline, which uses two $1 \times 1$ convolutions to get per-pixel classifications directly from the last layer of the ViT-Base transformer output. We can see that by applying the ATM module and supervise with a regular cross-entropy loss, ATM is capable of providing $0 . 5 \%$ of performance boost. However, it is more beneficial to decouple the classification and mask prediction process and use the mask and classification supervision separately ( $3 . 1 \%$ increase).
|
| 135 |
+
|
| 136 |
+
Ablation of using different layers as input for SegViT. Table 5 shows the performance boost that multiple layers input can provide. We can see that the performance boost of feature maps from additional lower layers is obvious $( + 1 . 3 \% )$ . We then involved more layers of features and see further performance gains. We empirically choose to use three layers for its best performance.
|
| 137 |
+
|
| 138 |
+
Table 4: Comparison between our proposed ATM module with other methods. ‘CE loss’ indicates the cross-entropy loss that is commonly used in semantic segmentation. The experiments are carried out on the ViT-Base backbone using ADE20K dataset.
|
| 139 |
+
|
| 140 |
+
<table><tr><td>Decoder</td><td>Loss</td><td>mIoU (ss)</td></tr><tr><td>SETR</td><td>CE loss</td><td>46.5</td></tr><tr><td>ATM</td><td>CE loss</td><td>47.0 (+0.5)</td></tr><tr><td>ATM</td><td>Lmask loss</td><td>49.6 (+3.1)</td></tr></table>
|
| 141 |
+
|
| 142 |
+
Table 5: Ablation results of using different layer inputs to the $\mathrm { S e g V i T }$ structure on ADE20K dataset using ViT-Base as the backbone. Involving multi-layer features can bring obvious performance gain.
|
| 143 |
+
|
| 144 |
+
<table><tr><td></td><td>Used layers</td><td>mIoU (ss)</td></tr><tr><td>Single</td><td>[12]</td><td>49.6</td></tr><tr><td>Cascade</td><td>[6,12]</td><td>50.9 (+1.3)</td></tr><tr><td>Cascade</td><td>[6,8,12]</td><td>51.3 (+1.7)</td></tr><tr><td>Cascade</td><td>[3,6,9,12]</td><td>51.2 (+1.6)</td></tr></table>
|
| 145 |
+
|
| 146 |
+
Ablation for the ATM Decoder. We conduct experiments to show the effectiveness of the proposed ATM decoder
|
| 147 |
+
|
| 148 |
+
$\mathbf { S e g V i T }$ on hierarchical backbones. Shown in Table 6, the $\mathrm { S e g V i T }$ structure is also able to apply to hierarchical backbones. We choose the most competitive methods Maskformer [15] and Mask2former [48] for comparison. Results indicate that even though our method is not designed for hierarchical backbones, we can still achieve competitive performance while being efficient in terms of computational cost.
|
| 149 |
+
|
| 150 |
+
Table 6: The experiments use the Swin-Tiny [18] backbone and are carried out on the ADE20K dataset. The GFLOPs are measured at single scale inference with a crop size of $5 1 2 \times 5 1 2$ . QD: query-based down-saumping. QU: query-based upsampling.
|
| 151 |
+
|
| 152 |
+
<table><tr><td>Method</td><td>mIoU (ss)</td><td>GFLOPs</td></tr><tr><td>Maskformer [15]</td><td>46.7</td><td>57.3</td></tr><tr><td>Mask2former [48]</td><td>47.7</td><td>73.7</td></tr><tr><td>SegViT (Ours)</td><td>47.1</td><td>48.0</td></tr></table>
|
| 153 |
+
|
| 154 |
+
Table 7: Ablation of the QD module in terms of the targets and methods to down-sample. The experiments are carried out on the ViT-Large backbone of ADE20K dataset.
|
| 155 |
+
|
| 156 |
+
<table><tr><td>Applied to</td><td>Methods</td><td>mIoU (ss)</td></tr><tr><td>Q</td><td>Conv</td><td>44.5</td></tr><tr><td>Q,K,V</td><td>Nearest</td><td>52.6</td></tr><tr><td>Q</td><td>Nearest</td><td>53.9</td></tr></table>
|
| 157 |
+
|
| 158 |
+
Ablation for the QD module. The motivation to use QD is to make use of the pre-train weights of the backbone. As in Table 7, if we use a stride 2 convolution with learnable parameters to downsample the query, it will destroy the pre-train weights and dramatically decrease the performance. If the down-sampling is applied to both Q and (K, V), there will be an inevitable loss in information during the down-sampling process which is reflected in the weaker performance. We found that applying $2 \times 2$ nearest down-sampling on query only for the QD module is the better option.
|
| 159 |
+
|
| 160 |
+
Ablation of the components in Shrunk structure. Shown in Table 8, we studied the effect of each component (QD and QU) in the Shrunk structure. The results presented matches the structures illustrated in Fig. 3. When QD is applied, the performance decreases by $2 . 7 \%$ from the ‘Single’ ATM head. However, by applying QU, the performance is recovered. QD learns a non-linear downsampling by the attention mechanism between key and query. One query will attend to several keys. QU is used to preserve the resolution and at the same time provide low-level feature information. We can see that by using QD and QU jointly, the performance can be retained and the computational cost is reduced. ATM module can also be used as the decoder to form our Shrunk structure to further boost performance.
|
| 161 |
+
|
| 162 |
+
Table 8: Ablation results of Shrunk version on the ADE20K dataset. The GFLOPs are measured at single scale inference with a crop size of $5 1 2 \times 5 1 2$ on ViT-Base backbone.
|
| 163 |
+
|
| 164 |
+
<table><tr><td> Structure</td><td>QD</td><td>QU</td><td>Head</td><td>mIoU (ss)</td><td>GFLOPs</td></tr><tr><td>Single</td><td></td><td></td><td>SETR</td><td>46.5</td><td>107.3</td></tr><tr><td>Single</td><td></td><td></td><td>ATM</td><td>49.6 (+3.1)</td><td>115.8</td></tr><tr><td>Naive Shrunk</td><td><</td><td></td><td>ATM</td><td>46.9 (+0.4)</td><td>74.1</td></tr><tr><td>Shrunk</td><td></td><td>√</td><td>ATM</td><td>50.0 (+3.5)</td><td>97.1</td></tr></table>
|
| 165 |
+
|
| 166 |
+
# 5 Conclusion
|
| 167 |
+
|
| 168 |
+
We proposed an effective structure using plain ViT transformer backbones termed $\mathrm { S e g V i T }$ for the semantic segmentation task. For the first time, we utilize spatial information in attention maps for semantic segmentation. To implement this idea, we proposed an Attention-to-mask (ATM) module that can derive mask predictions during the attention calculation process. We show on a number of semantic segmentation benchmarks that our method is efficient and achieves state-of-the-art performance. We also proposed a Shrunk structure which is applied to the backbone and capable of reducing $4 0 \%$ of the computational cost while still maintaining competitive performance. We believe both structures can be strong paradigms, especially for semantic segmentation using ViT backbones. Last but not the least, our method still has some limitations. One of the limitations is that the large amount of GPU memory consumed by the global attention mechanism might not be supported by some devices, which might restrict the applicability of our structures.
|
| 169 |
+
|
| 170 |
+
Acknowledgments C. Shen’s participation was in part supported by a major grant from Zhejiang Provincial Government. This work was also supported by the start-up funding of the University of Adelaide. [grant number 15130411]. This research was supported by Meituan.
|
| 171 |
+
|
| 172 |
+
# References
|
| 173 |
+
|
| 174 |
+
IEEE Conf. Comp. Vis. Patt. Recogn., pp. 3431–3440, 2015.
|
| 175 |
+
[2] L.-C. Chen, G. Papandreou, I. Kokkinos, K. Murphy, and A. Yuille, “Deeplab: Semantic image segmentation with deep convolutional nets, atrous convolution, and fully connected CRFs,” IEEE Trans. Pattern Anal. Mach. Intell., vol. 40, no. 4, pp. 834–848, 2017.
|
| 176 |
+
[3] Y. Yuan, X. Chen, and J. Wang, “Object-contextual representations for semantic segmentation,” in Proc. Eur. Conf. Comp. Vis., pp. 173–190, Springer, 2020.
|
| 177 |
+
[4] T.-Y. Lin, P. Dollár, R. Girshick, K. He, B. Hariharan, and S. Belongie, “Feature pyramid networks for object detection,” in Proc. IEEE Conf. Comp. Vis. Patt. Recogn., pp. 2117–2125, 2017.
|
| 178 |
+
[5] A. Dosovitskiy, L. Beyer, A. Kolesnikov, D. Weissenborn, X. Zhai, T. Unterthiner, M. Dehghani, M. Minderer, G. Heigold, S. Gelly, et al., “An image is worth 16x16 words: Transformers for image recognition at scale,” Proc. Int. Conf. Learn. Representations, 2021.
|
| 179 |
+
[6] S. Zheng, J. Lu, H. Zhao, X. Zhu, Z. Luo, Y. Wang, Y. Fu, J. Feng, T. Xiang, P. H. Torr, et al., “Rethinking semantic segmentation from a sequence-to-sequence perspective with transformers,” in Proc. IEEE Conf. Comp. Vis. Patt. Recogn., pp. 6881–6890, 2021.
|
| 180 |
+
[7] R. Ranftl, A. Bochkovskiy, and V. Koltun, “Vision transformers for dense prediction,” in Proc. IEEE Int. Conf. Comp. Vis., pp. 12179–12188, 2021.
|
| 181 |
+
[8] R. Strudel, R. Garcia, I. Laptev, and C. Schmid, “Segmenter: Transformer for semantic segmentation,” in Proc. IEEE Int. Conf. Comp. Vis., pp. 7262–7272, 2021.
|
| 182 |
+
[9] C. Farabet, C. Couprie, L. Najman, and Y. LeCun, “Learning hierarchical features for scene labeling,” IEEE Trans. Pattern Anal. Mach. Intell., vol. 35, no. 8, pp. 1915–1929, 2012.
|
| 183 |
+
[10] J. Long, E. Shelhamer, and T. Darrell, “Fully convolutional networks for semantic segmentation,” in Proc. IEEE Conf. Comp. Vis. Patt. Recogn., pp. 3431–3440, 2015.
|
| 184 |
+
[11] H. Zhao, J. Shi, X. Qi, X. Wang, and J. Jia, “Pyramid scene parsing network,” in Proc. IEEE Conf. Comp. Vis. Patt. Recogn., 2017.
|
| 185 |
+
[12] L.-C. Chen, Y. Zhu, G. Papandreou, F. Schroff, and H. Adam, “Encoder-decoder with atrous separable convolution for semantic image segmentation,” in Proc. Eur. Conf. Comp. Vis., pp. 801–818, 2018.
|
| 186 |
+
[13] J. Fu, J. Liu, J. Jiang, Y. Li, Y. Bao, and H. Lu, “Scene segmentation with dual relation-aware attention network,” IEEE Trans. Neural Netw. & Learn. Syst., vol. 32, no. 6, pp. 2547–2560, 2020.
|
| 187 |
+
[14] C. Yu, J. Wang, C. Gao, G. Yu, C. Shen, and N. Sang, “Context prior for scene segmentation,” in Proc. IEEE Conf. Comp. Vis. Patt. Recogn., pp. 12416–12425, 2020.
|
| 188 |
+
[15] B. Cheng, A. Schwing, and A. Kirillov, “Per-pixel classification is not all you need for semantic segmentation,” Proc. Advances in Neural Inf. Process. Syst., vol. 34, 2021.
|
| 189 |
+
[16] W. Zhang, J. Pang, K. Chen, and C. C. Loy, “K-net: Towards unified image segmentation,” Proc. Advances in Neural Inf. Process. Syst., vol. 34, 2021.
|
| 190 |
+
[17] W. Wang, E. Xie, X. Li, D.-P. Fan, K. Song, D. Liang, T. Lu, P. Luo, and L. Shao, “Pyramid vision transformer: A versatile backbone for dense prediction without convolutions,” in Proc. IEEE Int. Conf. Comp. Vis., pp. 568–578, 2021.
|
| 191 |
+
[18] 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,” in Proc. IEEE Int. Conf. Comp. Vis., pp. 10012–10022, 2021.
|
| 192 |
+
[19] X. Chu, Z. Tian, Y. Wang, B. Zhang, H. Ren, X. Wei, H. Xia, and C. Shen, “Twins: Revisiting the design of spatial attention in vision transformers,” Proc. Advances in Neural Inf. Process. Syst., vol. 34, 2021.
|
| 193 |
+
[20] E. Xie, W. Wang, Z. Yu, A. Anandkumar, J. M. Alvarez, and P. Luo, “Segformer: Simple and efficient design for semantic segmentation with transformers,” Proc. Advances in Neural Inf. Process. Syst., vol. 34, 2021.
|
| 194 |
+
[21] Y.-H. Wu, Y. Liu, X. Zhan, and M.-M. Cheng, “P2t: Pyramid pooling transformer for scene understanding,” IEEE Trans. Pattern Anal. Mach. Intell., 2022.
|
| 195 |
+
[22] T.-Y. Lin, P. Goyal, R. Girshick, K. He, and P. Dollár, “Focal loss for dense object detection,” in Proc. IEEE Int. Conf. Comp. Vis., pp. 2980–2988, 2017.
|
| 196 |
+
[23] F. Milletari, N. Navab, and S.-A. Ahmadi, “V-net: Fully convolutional neural networks for volumetric medical image segmentation,” in 3DV, pp. 565–571, IEEE, 2016.
|
| 197 |
+
[24] N. Carion, F. Massa, G. Synnaeve, N. Usunier, A. Kirillov, and S. Zagoruyko, “End-to-end object detection with transformers,” in Proc. Eur. Conf. Comp. Vis., pp. 213–229, Springer, 2020.
|
| 198 |
+
[25] A. Vaswani, N. Shazeer, N. Parmar, J. Uszkoreit, L. Jones, A. N. Gomez, Ł. Kaiser, and I. Polosukhin, “Attention is all you need,” Proc. Advances in Neural Inf. Process. Syst., vol. 30, 2017.
|
| 199 |
+
[26] B. Zhou, H. Zhao, X. Puig, S. Fidler, A. Barriuso, and A. Torralba, “Scene parsing through ade20k dataset,” in Proc. IEEE Conf. Comp. Vis. Patt. Recogn., pp. 633–641, 2017.
|
| 200 |
+
[27] H. Caesar, J. Uijlings, and V. Ferrari, “Coco-stuff: Thing and stuff classes in context,” in Proc. IEEE Conf. Comp. Vis. Patt. Recogn., pp. 1209–1218, 2018.
|
| 201 |
+
[28] MMSegmentation, “MMSegmentation: OpenMMLab semantic segmentation toolbox and benchmark.” https://github.com/open-mmlab/mmsegmentation, 2020.
|
| 202 |
+
[29] R. Mottaghi, X. Chen, X. Liu, N.-G. Cho, S.-W. Lee, S. Fidler, R. Urtasun, and A. Yuille, “The role of context for object detection and semantic segmentation in the wild,” in Proc. IEEE Conf. Comp. Vis. Patt. Recogn., pp. 891–898, 2014.
|
| 203 |
+
[30] A. Steiner, A. Kolesnikov, X. Zhai, R. Wightman, J. Uszkoreit, and L. Beyer, “How to train your vit? data, augmentation, and regularization in vision transformers,” arXiv: Comp. Res. Repository, 2021.
|
| 204 |
+
[31] F. Lin, Z. Liang, J. He, M. Zheng, S. Tian, and K. Chen, “Structtoken: Rethinking semantic segmentation with structural prior,” arXiv: Comp. Res. Repository, 2022.
|
| 205 |
+
[32] T. Xiao, Y. Liu, B. Zhou, Y. Jiang, and J. Sun, “Unified perceptual parsing for scene understanding,” in Proc. Eur. Conf. Comp. Vis., pp. 418–434, 2018.
|
| 206 |
+
[33] Z. Jin, T. Gong, D. Yu, Q. Chu, J. Wang, C. Wang, and J. Shao, “Mining contextual information beyond image for semantic segmentation,” in Proc. IEEE Int. Conf. Comp. Vis., pp. 7231–7241, 2021.
|
| 207 |
+
[34] J. Fu, J. Liu, H. Tian, Y. Li, Y. Bao, Z. Fang, and H. Lu, “Dual attention network for scene segmentation,” in Proc. IEEE Conf. Comp. Vis. Patt. Recogn., pp. 3146–3154, 2019.
|
| 208 |
+
[35] X. Li, Z. Zhong, J. Wu, Y. Yang, Z. Lin, and H. Liu, “Expectation-maximization attention networks for semantic segmentation,” in Proc. IEEE Int. Conf. Comp. Vis., pp. 9167–9176, 2019.
|
| 209 |
+
[36] X. Li, Y. Yang, Q. Zhao, T. Shen, Z. Lin, and H. Liu, “Spatial pyramid based graph reasoning for semantic segmentation,” in Proc. IEEE Conf. Comp. Vis. Patt. Recogn., pp. 8950–8959, 2020.
|
| 210 |
+
[37] T. Wu, Y. Lu, Y. Zhu, C. Zhang, M. Wu, Z. Ma, and G. Guo, “Ginet: Graph interaction network for scene parsing,” in Proc. Eur. Conf. Comp. Vis., pp. 34–51, Springer, 2020.
|
| 211 |
+
[38] W. Chen, X. Zhu, R. Sun, J. He, R. Li, X. Shen, and B. Yu, “Tensor low-rank reconstruction for semantic segmentation,” in Proc. Eur. Conf. Comp. Vis., pp. 52–69, Springer, 2020.
|
| 212 |
+
[39] Z. Jin, B. Liu, Q. Chu, and N. Yu, “Isnet: Integrate image-level and semantic-level context for semantic segmentation,” in Proc. IEEE Int. Conf. Comp. Vis., pp. 7189–7198, 2021.
|
| 213 |
+
[40] K. Sun, Y. Zhao, B. Jiang, T. Cheng, B. Xiao, D. Liu, Y. Mu, X. Wang, W. Liu, and J. Wang, “Highresolution representations for labeling pixels and regions,” arXiv: Comp. Res. Repository, 2019.
|
| 214 |
+
[41] G. Lin, A. Milan, C. Shen, and I. Reid, “RefineNet: Multi-path refinement networks for high-resolution semantic segmentation,” in Proc. IEEE Conf. Comp. Vis. Patt. Recogn., pp. 1925–1934, 2017.
|
| 215 |
+
[42] Z. Zhou, M. M. R. Siddiquee, N. Tajbakhsh, and J. Liang, “Unet++: A nested U-net architecture for medical image segmentation,” in Proc. Deep Learning in Medical Image Analysis Workshop, pp. 3–11, 2018.
|
| 216 |
+
[43] H. Ding, X. Jiang, B. Shuai, A. Q. Liu, and G. Wang, “Context contrasted feature and gated multi-scale aggregation for scene segmentation,” in Proc. IEEE Conf. Comp. Vis. Patt. Recogn., pp. 2393–2402, 2018.
|
| 217 |
+
[44] H. Zhang, K. Dana, J. Shi, Z. Zhang, X. Wang, A. Tyagi, and A. Agrawal, “Context encoding for semantic segmentation,” in Proc. IEEE Conf. Comp. Vis. Patt. Recogn., pp. 7151–7160, 2018.
|
| 218 |
+
[45] B. Zhang, Z. Tian, C. Shen, et al., “Dynamic neural representational decoders for high-resolution semantic segmentation,” Proc. Advances in Neural Inf. Process. Syst., vol. 34, 2021.
|
| 219 |
+
[46] X. Li, H. Zhao, L. Han, Y. Tong, S. Tan, and K. Yang, “Gated fully fusion for semantic segmentation,” in Proc. AAAI Conf. Artificial Intell., vol. 34, pp. 11418–11425, 2020.
|
| 220 |
+
[47] J. Liu, J. He, J. Zhang, J. Ren, and H. Li, “EfficientFCN: Holistically-guided decoding for semantic segmentation,” in Proc. Eur. Conf. Comp. Vis., 2020.
|
| 221 |
+
[48] B. Cheng, I. Misra, A. G. Schwing, A. Kirillov, and R. Girdhar, “Masked-attention mask transformer for universal image segmentation,” 2022.
|
| 222 |
+
|
| 223 |
+
# Checklist
|
| 224 |
+
|
| 225 |
+
1. For all authors...
|
| 226 |
+
|
| 227 |
+
(a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes]
|
| 228 |
+
(b) Did you describe the limitations of your work? [Yes]
|
| 229 |
+
(c) Did you discuss any potential negative societal impacts of your work? [No] We conduct experiments on a fundamental task of semantic segmentation. This technique may be used for editing fake images to mislead the public if being used by someone who has ulterior motives.
|
| 230 |
+
(d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
|
| 231 |
+
|
| 232 |
+
2. If you are including theoretical results...
|
| 233 |
+
|
| 234 |
+
(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]
|
| 235 |
+
|
| 236 |
+
3. If you ran experiments...
|
| 237 |
+
|
| 238 |
+
(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 included the code for the main experiments in the supplemental materials. All the code will be released upon acceptance.
|
| 239 |
+
(b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes] See implementation details.
|
| 240 |
+
(c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [No] We fix the random seed and other random operators
|
| 241 |
+
(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 implementation details and GFLOPs in tables.
|
| 242 |
+
|
| 243 |
+
4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
|
| 244 |
+
|
| 245 |
+
(a) If your work uses existing assets, did you cite the creators? [Yes]
|
| 246 |
+
(b) Did you mention the license of the assets? [No] The license can be found in their own homepages.
|
| 247 |
+
(c) Did you include any new assets either in the supplemental material or as a URL? [Yes] We include our trained model in the supplemental material.
|
| 248 |
+
(d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [N/A] All the data are public benchmarks.
|
| 249 |
+
(e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [No] All the data are public benchmarks.
|
| 250 |
+
|
| 251 |
+
5. If you used crowdsourcing or conducted research with human subjects...
|
| 252 |
+
|
| 253 |
+
(a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A]
|
| 254 |
+
(b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A]
|
| 255 |
+
(c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]
|
md/dev/6MmiS0HUJHR/6MmiS0HUJHR.md
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
md/dev/6Pv8AMSylux/6Pv8AMSylux.md
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
md/dev/AJg35fkqOPA/AJg35fkqOPA.md
ADDED
|
@@ -0,0 +1,262 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# TEXT-DRIVEN IMAGE MANIPULATION VIA SEMANTIC-AWARE KNOWLEDGE TRANSFER
|
| 2 |
+
|
| 3 |
+
Anonymous authors Paper under double-blind review
|
| 4 |
+
|
| 5 |
+
# ABSTRACT
|
| 6 |
+
|
| 7 |
+
Semantic-level facial attribute transfer is a special task to edit facial attribute, when reference images are viewed as conditions to control the image editing. In order to achieve better performance, semantic-level facial attribute transfer needs to fulfil two requirements: (1) specific attributes extracted from reference face should be precisely transferred to target face; (2) irrelevant information should be completely retained after transferring. Some existing methods locate and modify local support regions of facial images, which are not effective when editing global attributes; the other methods disentangle the latent code as different attributerelevant parts, which may transfer redundant knowledge to target faces. In this paper, we first propose a novel text-driven directional latent mapping network with semantic direction consistency (SDC) constrain to explore the latent semantic space for effective attribute editing, leveraging the semantic-aware knowledge of Contrastive Language-Image Pre-training (CLIP) model as guidance. This latent space manipulation strategy is designed to disentangle the facial attribute, removing the redundant knowledge in the transfer process. And on this basis, a novel attribute transfer method, named semantic directional decomposition network (SDD-Net), is proposed to achieve semantic-level facial attribute transfer by latent semantic direction decomposition, improving the interpretability and editability of our method. Extensive experiments on CelebA-HQ dataset show that our method achieves impressive performance over the state-of-the-art methods.
|
| 8 |
+
|
| 9 |
+
# 1 INTRODUCTION
|
| 10 |
+
|
| 11 |
+
Generative Adversarial Networks (GANs) (Goodfellow et al., 2014) have revolutionized a variety of fields due to its powerful ability to generate realistic and meaningful outputs. Recent works (Jahanian et al., 2019; He et al., 2019; Goetschalckx et al., 2019) have shown that deep generative models can capture real-world data distribution, and encode them into a semantically-rich latent space. Inspired by this, a lot of tasks draw their attention on the latent space manipulation, including image enhancement (Ledig et al., 2017; Yang et al., 2021b), editing (Shen et al., 2020; Hark ¨ onen ¨ et al., 2020; Patashnik et al., 2021), and discriminative tasks (Nitzan et al., 2021; Xu et al., 2021).
|
| 12 |
+
|
| 13 |
+
With the tremendous success of deep generative models, facial attribute editing (Yeh et al., 2017; Liu et al., 2019; He et al., 2020; Dorta et al., 2020), aiming to edit the specific attributes of the target facial image, has become topical. As a special case of facial attribute editing, facial attribute transfer (Xiao et al., 2018; Lin et al., 2018; Yin et al., 2019; Choi et al., 2018; 2020) uses knowledge from reference image as a condition to edit the corresponding attribute from the target image. In order to ensure that the manipulated facial image meets the requirements and interests, facial attribute transfer task tackles two challenges simultaneously: (1) editing relevance: the relevant attribute should be edited precisely according to the given condition; and (2) keeping irrelevance: the irrelevant part (e.g., identify information, background, or other attributes) should not be modified during attribute transfer. Due to strong entanglement of the attributes, meeting both requirements is an intractable task. For example, without fully disentanglement, transferring the “smile” attribute to the target facial image may cause that, another irrelevant but coupled attribute, e.g. “cheek color” attribute, would be changed during editing.
|
| 14 |
+
|
| 15 |
+
In view of the above issues, recently a variety of methods explore the attribute disentanglement in two ways. Some methods (He et al., 2020; Kwak et al., 2020) resort to the way of spatial attention detection, which disentangle the attribute by searching specific support region spatially and only manipulate the image in such a confined area. Obviously, these methods totally ignore the facial details beyond the support region when the edited attribute is a global attribute, such as “smile” or “age”. Meanwhile, other methods (Shen et al., 2020; Yang et al., 2021a; Patashnik et al., 2021) pay attention to the latent space factorization through pre-trained GAN. These methods employ the high-level semantic information as guidance to manipulate image in latent spaces, which are more suitable to handle both global and local attribute editing. However, owing to over-coupled semantic features, these methods are hard to manipulate specific attribute without powerful supervision.
|
| 16 |
+
|
| 17 |
+
To overcome the problems mentioned above, we explore the latent semantic space for disentangled attribute editing, and apply the discovered manipulation method to facial attribute transfer task. As for attribute editing task, in order to disentangle and edit the attribute specified by the text prompt, we design the directional latent mapping network, which leverages semantic direction consistency (SDC) loss to constrain the manipulation in the CLIP-space (Radford et al., 2021). The key idea of the SDC loss is employing the change direction of semantic feature to estimate the latent manipulation. Furthermore, in order to apply this effective editing method to facial attribute transfer task, we propose a novel semantic-level facial attribute transfer method driven by text prompt, named as semantic directional decomposition network (SDD-Net). The SDD-Net extracts and transfers the specific attribute without redundant information through attribute-manipulated semantic directional decomposition.
|
| 18 |
+
|
| 19 |
+
Our contributions are summarized as follows:
|
| 20 |
+
|
| 21 |
+
• We propose a novel method namely directional latent mapping network for facial attribute editing, which utilizes the semantic direction consistency regularization to ensure attribute disentanglement. • To further take advantage of semantic direction constrain, we propose a text-driven semantic directional decomposition network (SDD-Net) for semantic-level attribute transfer, by transferring the knowledge from the reference image to the target image. • Extensive experiments on CelebA-HQ (Karras et al., 2017) dataset show that our method achieves significant improvements over the state-of-art approaches.
|
| 22 |
+
|
| 23 |
+
# 2 RELATED WORK
|
| 24 |
+
|
| 25 |
+
Latent Space Manipulation. Recent studies (Bau et al., 2020; Goetschalckx et al., 2019; Shen et al., 2020) have shown that numerous GAN models can encode rich crucial information in the intermediate latent space, such as $\mathcal { W }$ , $\mathcal { W } +$ (Abdal et al., 2019), or StyleSpace $s$ (Wu et al., 2021). By learning to modify the intermediate latent code, generative models can transfer attributes from one face to another face (Xiao et al., 2018; Choi et al., 2020). To find a latent code that allows for meaningful manipulation, some methods try to learn an effective encoder network, which inverts a real image into latent space: encoder4editing (e4e) (Tov et al., 2021) method presents an encoder that is specifically designed for balancing distortion-editability tradeoff and a distortion-perception tradeoff within the StyleGAN latent space; Stylespace (Wu et al., 2021) proposes a space of channelwise style parameters that disentangle attributes by controlling attribute-related style channels; The pixel2style2pixel (pSp) (Richardson et al., 2021) method utilizes a novel encoder architecture that inverts a real image into $\mathcal { W } +$ space without optimization. Other methods mainly focus on finding such latent code modification approach as used to traverse latent space, result in the desired manipulation: AttGAN (He et al., 2019) applies attribute classification constraint to model the relation between the attributes and the latent representation; InterfaceGAN (Shen et al., 2020) decouples some entangled semantic features with subspace projection; GANspace (Hark ¨ onen et al., 2020) leverages ¨ principal component analysis to identify mainly direction in latent space; L2M-GAN (Yang et al., 2021a) imposes an orthogonality constraint to ensure disentanglement in latent space; StyleCLIP (Patashnik et al., 2021) leverages CLIP models to guide the attributes manipulation by latent semantic matching.
|
| 26 |
+
|
| 27 |
+
Different from the methods mentioned above, our method aligns the guidance direction, which is derived directly from text prompt, with the change direction of semantic features extracted by CLIP to guide the manipulation in the latent space. By constraining the consistency of these directions, our method can achieve disentangled attribute editing.
|
| 28 |
+
|
| 29 |
+

|
| 30 |
+
Figure 1: Overview of our idea for directional latent mapping network. By enforcing the change direction of semantic feature to align with desired direction in CLIP-space, our method can achieve impressive disentangled image manipulation.
|
| 31 |
+
|
| 32 |
+
Semantic-level Attribute Transfer. Semantic-level attribute transfer is a more challenging facial attribute editing task. Recent studies have attempted more detailed approaches for facial attribute transfer: StarGAN (Choi et al., 2018) applies cycle consistency to preserve identity, and uses classification loss to transfer between different domains. In addition, StarGANv2 (Choi et al., 2020) also could synthesize reference-guide images leveraging multiple domain translation. Some works are specialized for specific attributes: ExprGAN (Ding et al., 2018) proposes a model to learn the disentangled identity and expression representations explicitly for facial expression transfer. Besides, ERGAN (Hu et al., 2020) proposes a dual learning scheme to simultaneously learn two inverse manipulations for attribute transfer.
|
| 33 |
+
|
| 34 |
+
Different from these works, our proposed method focuses not only on one attribute, but also on various global or local attributes. Given an explicit text prompt, our method can automatically extract the specific attribute from the reference, and transfer the knowledge to the target image.
|
| 35 |
+
|
| 36 |
+
# 3 METHODOLOGY
|
| 37 |
+
|
| 38 |
+
In the following section, we first provide the preliminaries and problem formulation. Then, we introduce our text-driven directional latent mapping network for disentangled facial attribute editing. Finally, we describe the text-driven semantic directional decomposition network (SDD-Net) for semantic-aware facial attribute transfer.
|
| 39 |
+
|
| 40 |
+
# 3.1 PRELIMINARIES
|
| 41 |
+
|
| 42 |
+
StyleGAN. The StyleGAN (Karras et al., 2019; 2020) generator consists of two main components: mapping network and synthesis network. The former translates latent code $z$ to latent code $w$ , which is in semantic-rich latent space $\mathcal { W }$ , and the latter utilizes latent code $w$ to synthesize final images through different layers. Due to the rich information inside, the latent code $w$ can control the multigranularity semantic features of the synthetic image, which is utilized for effective facial attribute transfer in semantic-level. In this paper, we leverage the pre-trained synthesis network as our image generator.
|
| 43 |
+
|
| 44 |
+
StyleCLIP. The StyleCLIP (Patashnik et al., 2021) method first combines StyleGAN and CLIP as a strong tool for text-driven image editing. The key idea of StyleCLIP is to leverage the CLIP as latent manipulation guidance. By mapping multi-modal inputs to the CLIP-space, StyleCLIP could ensure that the synthetic image matches with the text prompt in semantic-level. The objective is given by:
|
| 45 |
+
|
| 46 |
+
$$
|
| 47 |
+
\mathcal { L } _ { s t y l e c l i p } = D _ { \mathrm { C L I P } } ( G ( w ) , t e x t ) ,
|
| 48 |
+
$$
|
| 49 |
+
|
| 50 |
+
where $D _ { \mathrm { C L I P } }$ is the cosine distance metric in CLIP-space, and $G$ is the pre-trained StyleGAN generator.
|
| 51 |
+
|
| 52 |
+

|
| 53 |
+
Figure 2: The architecture of our directional latent mapping network. Given the text prompt, we manipulate the latent code inverted by the facial images. Then we use $g$ group channel-wise mapping networks to manipulate the different parts of latent code $w$ respectively. Multiple loss functions are used to constrain the synthetic image to fulfil the requirements.
|
| 54 |
+
|
| 55 |
+
# 3.2 PROBLEM FORMULATION
|
| 56 |
+
|
| 57 |
+
Our method leverages two latent space: $\mathcal { W } +$ space and CLIP-space, to transfer semantic-level facial attributes. For better expression, let $\mathcal { X }$ and $\mathcal { V }$ denote the set of images and semantic features in CLIP-space, respectively. The image $x \in \mathcal { X }$ is inverted into corresponding latent code $w \in \mathcal { W } +$ . $t$ denotes the input text prompt, with corresponding semantic feature $y _ { t }$ . Meanwhile, the parameters of pre-trained StyleGANv2 generator $G$ are frozen during training.
|
| 58 |
+
|
| 59 |
+
Given the text prompt $t$ , the goal of facial attribute transfer model is to train a latent mapping network, which translates $w \backslash y$ to $\hat { w } \textcircled { y }$ , and synthesizes the edited image $\hat { x }$ that meets the specific requirements. Our basic editing model can be formally defined as $\hat { x } = \mathbf { \bar { \cal G } } ( M ( x , t ) )$ , where $M$ is the manipulation network. Hence given the reference image $x _ { r e f } \in \mathcal { X }$ , our semantic-aware attribute transfer model can be formally defined as $\hat { x } = G ( M ( x , x _ { r e f } , t ) )$ .
|
| 60 |
+
|
| 61 |
+
# 3.3 DIRECTIONAL LATENT MAPPING
|
| 62 |
+
|
| 63 |
+
Only focusing on matching $\hat { y }$ with $y _ { t }$ may cause irrelevant attribute changed. Therefore, we enforce the mapping network to focus on the change direction of semantic features in CLIP-space, and illustrate this idea in Figure 1. The details of the proposed directional latent mapping network is described as follows:
|
| 64 |
+
|
| 65 |
+
Architecture. It has been shown that the different layers of synthesis network, which correspends to different parts of the latent code, control different granularity of semantic feature. In order to better exploit this property, we design the directional latent mapping network, and depict it in Figure 2. To a great extent, the degree of attributes disentanglement depends on the disentanglement of latent features. Therefore, we split the layers into $g$ groups, instead three (coarse, medium, and fine), with $g$ fully connected mapping networks, one for each group. The divided part of the latent code can be denoted as $w = [ w _ { 1 } , w _ { 2 } , . . . , w _ { g } ]$ , so the mapping network is defined by:
|
| 66 |
+
|
| 67 |
+
$$
|
| 68 |
+
M ( w ) = [ M _ { 1 } ( w _ { 1 } ) , M _ { 2 } ( w _ { 2 } ) , . . . , M _ { g } ( w _ { g } ) ] ,
|
| 69 |
+
$$
|
| 70 |
+
|
| 71 |
+
where $M _ { i }$ is the $i$ -th mapping network, and $[ \cdot , \cdot ]$ means concat operation. Then we use skipconnection operation to obtain the final manipulated latent code $\hat { w } = w + \alpha M ( w )$ , and feed it to the pre-trained StyleGANv2 generator $G$ to get the final manipulated facial image $\hat { x } = G ( \hat { w } )$ .
|
| 72 |
+
|
| 73 |
+
Training Objective. The edited desired attribute is determined by the textual prompt $t$ . Without paired training data, the mapping network could not correctly manipulate the latent code. In order to obtain extra powerful supervision, we use CLIP model to effectively extract semantic features (attributes) $y$ of the corresponding images and text:
|
| 74 |
+
|
| 75 |
+
$$
|
| 76 |
+
\begin{array} { c } { { y _ { i } ; \hat { y _ { i } } = E _ { I } ( x ; \hat { x } ) , } } \\ { { y _ { t } = E _ { T } ( t ) , } } \end{array}
|
| 77 |
+
$$
|
| 78 |
+
|
| 79 |
+

|
| 80 |
+
Figure 3: The illustration of attribute transfer loss $\mathcal { L } _ { \mathrm { A T } }$ in our Semantic Directional Decomposition Network (SDD-Net). We embed both the text prompt and reference\target face into CLIP-space. When the projected vector $\vec { \mathcal { V } _ { p } }$ has the same direction with desired direction, the same attribute (e.g., smile) is transferred to the target face. Reversely, the opposite attribute (e.g., black hair) will be transferred when the direction is inverse.
|
| 81 |
+
|
| 82 |
+
where $E$ denotes the pre-trained multi-modal feature extractor integrated in CLIP, $y _ { i }$ and $\hat { y } _ { i }$ denotes the extracted semantic features of $x$ and $\hat { x }$ , respectively. $y _ { t }$ is the desired semantic feature extracted from textual prompt $t$ .
|
| 83 |
+
|
| 84 |
+
In the latent CLIP-space, simply optimizing the matching degree between $\hat { y } _ { i }$ and $y _ { t }$ may cause irrelevant attribute to be changed. Therefore, rather than optimizing the matching degree to the utmost extent, we enforce the change direction between $y$ and $\hat { y } _ { i }$ to align with the $y _ { t }$ , and propose the semantic direction consistency (SDC) loss. The SDC loss is given by:
|
| 85 |
+
|
| 86 |
+
$$
|
| 87 |
+
\begin{array} { c } { { \vec { I } = \hat { y _ { i } } - y _ { i } , } } \\ { { \vec { T } = y _ { t } , } } \\ { { \vec { \mathcal { L } } _ { \mathrm { S D C } } = 1 - S ( \vec { I } , \vec { T } ) , } } \end{array}
|
| 88 |
+
$$
|
| 89 |
+
|
| 90 |
+
where $S ( \cdot , \cdot )$ is the similarity measurement. In this paper, we use the effective cosine similarity as the measurement.
|
| 91 |
+
|
| 92 |
+
The above objective can guide the mapping network to manipulate the latent code along the direction of textual prompt. In order to preserve the irrelevant parts, we use the following identity loss:
|
| 93 |
+
|
| 94 |
+
$$
|
| 95 |
+
\mathcal { L } _ { \mathrm { I D } } = 1 - \left. R ( G ( w ) ) , R ( G ( \hat { w } ) ) \right. ,
|
| 96 |
+
$$
|
| 97 |
+
|
| 98 |
+
where $R$ is a pre-trained ArcFace (Deng et al., 2019) network for face recognition, and $\langle \cdot , \cdot \rangle$ computes the cosine similarity between its two arguments. Meanwhile, we use $L _ { 2 }$ distance in $\mathcal { W } +$ space to control the degree of manipulation. Then, the whole training objective for directional latent mapping network is denoted as:
|
| 99 |
+
|
| 100 |
+
$$
|
| 101 |
+
\underset { w \in \mathcal { W } + } { \arg \operatorname* { m i n } } \lambda _ { \mathrm { S D C } } \mathcal { L } _ { \mathrm { S D C } } ( w , t ) + \lambda _ { L 2 } | | M ( w ) | | _ { 2 } + \lambda _ { \mathrm { I D } } \mathcal { L } _ { \mathrm { I D } } ( w ) .
|
| 102 |
+
$$
|
| 103 |
+
|
| 104 |
+
# 3.4 SEMANTIC DIRECTIONAL DECOMPOSITION
|
| 105 |
+
|
| 106 |
+
Inspired by the above method, we found that a semantic attribute translation can be represented as a directional vector in CLIP-space. Based on this, we leverage the same architecture of directional mapping network, and propose a facial attribute transfer method via semantic-aware knowledge transfer, named as semantic directional decomposition network (SDD-Net).
|
| 107 |
+
|
| 108 |
+
Given the textual prompt $t$ , we want to transfer the attribute, extracted from the reference image $x _ { r e f }$ , to the target image $x _ { t a r }$ . The $y _ { r e f }$ and $y _ { t a r }$ are their corresponding semantic features respectively. And the semantic feature of textual prompt $t$ is $y _ { t }$ .
|
| 109 |
+
|
| 110 |
+

|
| 111 |
+
Figure 4: Qualitative results for facial attribute editing on attribute “smile”. The left column are the target images sampled from CelebA-HQ dataset. The other column from left to right are the editing results of L2M-GAN (Yang et al., 2021a), StyleCLIP\* (Patashnik et al., 2021), and our directional latent mapping network.
|
| 112 |
+
|
| 113 |
+
Due to the above direction-based manipulation, we can treat the facial attribute transfer problem as the attribute semantic feature projection problem. In the CLIP-space, a facial image can be treated as the composition of different semantic features. Therefore, we assume that different facial images can be converted to each other in semantic-level. In other words, one semantic feature can be translated to another semantic feature.
|
| 114 |
+
|
| 115 |
+
Under such an assumption, we first define the RT (reference-target) vector as: $\mathcal { V } _ { R T } ^ { } = y _ { r e f } - y _ { t a r }$ , which is the variance of two semantic features, and also is the direction of translation. We set the $y _ { t }$ as the projection direction. In order to extract knowledge from the reference, we project RT vector $\vec { \nu _ { R T } }$ onto desired direction $\vec { \mathcal { V } } _ { t } = \boldsymbol { y } _ { t }$ :
|
| 116 |
+
|
| 117 |
+
$$
|
| 118 |
+
\vec { \mathcal { V } _ { p } } = \mathcal { V } _ { R T } ^ { } \cdot ( \frac { \vec { \mathcal { V } _ { t } } } { | \mathcal { V } _ { t } | } ) ^ { 2 } ,
|
| 119 |
+
$$
|
| 120 |
+
|
| 121 |
+
where $\vec { \mathcal { V } _ { p } }$ is the projected vector. Then we add it to the target semantic feature $y _ { t a r }$ to get the final goal:
|
| 122 |
+
|
| 123 |
+
$$
|
| 124 |
+
y _ { g o a l } = y _ { t a r } + \beta \vec { \mathcal { V } _ { p } } ,
|
| 125 |
+
$$
|
| 126 |
+
|
| 127 |
+
where $\beta$ is the hyperparameter.
|
| 128 |
+
|
| 129 |
+
Training Objective. We use same architecture of directional latent mapping network to obtain the manipulated image $\hat { x } = G ( M ( \hat { w } ) )$ , then match the semantic feature $\hat { y } = E _ { I } ( \hat { x } )$ with $y _ { g o a l }$ in CLIP-space. As illustrated in Figure 3, the attribute transfer loss $\mathcal { L } _ { \mathrm { A T } }$ is given by:
|
| 130 |
+
|
| 131 |
+
$$
|
| 132 |
+
\mathcal { L } _ { \mathrm { A T } } = \mathrm { M S E } ( \hat { y } , y _ { g o a l } ) ,
|
| 133 |
+
$$
|
| 134 |
+
|
| 135 |
+
where $\mathrm { M S E } ( \cdot , \cdot )$ is the mean squared error.
|
| 136 |
+
|
| 137 |
+
Meanwhile, we use the same $L 2$ loss and identity loss to preserve the irrelevant parts. The whole training objective of SDD-Net is:
|
| 138 |
+
|
| 139 |
+
$$
|
| 140 |
+
\operatorname* { a r g m i n } _ { w \in \mathcal { W } + } \lambda _ { \mathrm { A T } } \mathcal { L } _ { \mathrm { A T } } + \lambda _ { \mathrm { L 2 } } \mathcal { L } _ { \mathrm { 2 } } + \lambda _ { \mathrm { I D } } \mathcal { L } _ { \mathrm { I D } } .
|
| 141 |
+
$$
|
| 142 |
+
|
| 143 |
+

|
| 144 |
+
Figure 5: The qualitative results of our SDD-Net on single attribute transfer. Reference images in the left column. Target images in the first row of each parts, the rest is our manipulated images. Given the text prompt, our SDD-Net transfer the specific attribute (“smile”) to the target images (top part) when the reference have the specific attribute. By contrast, the reverse attribute (“unsmiling”) will be transferred (bottom part) when the specific attribute is not contained in the reference. Notice that, we only input one text prompt. So the SDD-Net could determine the forward or reverse transferring direction, according to the reference.
|
| 145 |
+
|
| 146 |
+
# 4 EXPERIMENTS
|
| 147 |
+
|
| 148 |
+
In this section, we first introduce the involved dataset and the implementation details. Then we will present the comparison results with several state-of-the-art facial attribute editing and facial attribute transfer methods to prove the effectiveness of our proposed method. Finally, the ablation studies will be presented to prove the effectiveness of our method.
|
| 149 |
+
|
| 150 |
+
# 4.1 DATASET
|
| 151 |
+
|
| 152 |
+
In order to achieve text-driven facial attribute editing and transfer, we choose the widely-used CelebA-HQ (Karras et al., 2017) dataset, which consists of 30,000 high quality facial images picked from the original CelebA (Liu et al., 2015) dataset. The size of each high quality image is $1 0 2 4 \times 1 0 2 4$ . In the original dataset, each image has 40 attributes annotations inherited from the original CelebA. However in this work, we remove these annotations, and leverage CLIP model as powerful supervision. We also use the standard training, validation and test splits inherited from CelebA dataset.
|
| 153 |
+
|
| 154 |
+
# 4.2 IMPLEMENTATION DETAILS
|
| 155 |
+
|
| 156 |
+
In this subsection we provide the implementation details of our proposed networks. All images taken from the CelebA-HQ are inverted by e4e (Tov et al., 2021). We set the batch size and the number of total iterations to 5 and 50k respectively, during training. Our image editing is performed on StyleGANv2 pre-trained on FFHQ (Karras et al., 2019) dataset. We keep the StyleGANv2 generator fixed during training. The CLIP model is pre-trained on 400 million image-text pairs. We use the Vision Transformer (ViT) (Dosovitskiy et al., 2020) and a normal Transformer (Vaswani et al., 2017), which are integrated in CLIP model, as our image encoder and text encoder, respectively. Our directional latent mapping module is initialized using the pre-trained StyleGANv2, and trained using Adam with the learning rate 5e-3. We set $g = 9$ , $\alpha = 0 . 1$ , and $\beta = 1 3 0$ . For facial attribute editing, the hyperparameters are empirically set as $\lambda _ { S D C } = 1$ , $\lambda _ { L 2 } = 0 . 4$ , and $\lambda _ { \mathrm { I D } } = 0 . 0 2$ . For facial attribute transfer, the hyperparameters are empirically set as $\lambda _ { \mathrm { A T } } = 1$ , $\lambda _ { L 2 } = 0 . 2$ , and $\lambda _ { \mathrm { I D } } =$ 0.02. Our methods are trained on PyTorch with a single TITAN RTX GPU. We optimize training objective through gradient descent, by back-propagating the gradient through the pre-trained and fixed StyleGAN generator $G$ and CLIP multi-modal encoder $E$ .
|
| 157 |
+
|
| 158 |
+

|
| 159 |
+
Figure 6: Experiments on reference-guided image synthesis on CelebA-HQ. Reference and target images both in the first row. The second and third raw are the synthetic results of StarGANv2 (Choi et al., 2020) and our SDD-Net respectively.
|
| 160 |
+
|
| 161 |
+
# 4.3 BASELINE METHODS
|
| 162 |
+
|
| 163 |
+
Facial Attribute Editing Methods. We first compare our directional latent mapping network with the state-of-the-art facial attribute editing methods (i.e., L2M-GAN (Yang et al., 2021a), and StyleCLIP (Patashnik et al., 2021)) for the specific attribute: “smile”. Due to the requirements of highlevel semantic-aware knowledge, the smile attribute has become one of the most challenging global attributes. For L2M-GAN, we set the attribute domains as two (“smile” and “sad”), leveraging the domain label to guide the manipulation. For StyleCLIP, we use the latent mapper network as the baseline model, which is marked as StyleCLIP\*.
|
| 164 |
+
|
| 165 |
+
Facial Attribute Transfer Methods. The StarGANv2 (Choi et al., 2020) learns to transform a source image reflecting the style of a given reference image. We compare our SDD-Net with StarGANv2 method on reference-guided image synthesis, which is a challenging facial attribute transfer task. Reference-guided image synthesis requires that various high-level attributes in the reference images, such as hairstyle, makeup, beard and expression, should be transferrd to the target images, while the irrelevant information such as pose and identity should be preserved. For fair comparison, we resize the images to $2 5 6 \times 2 5 6$ in reference-guided image synthesis.
|
| 166 |
+
|
| 167 |
+
# 4.4 RESULTS AND ANALYSIS
|
| 168 |
+
|
| 169 |
+
Facial Attribute Editing. The qualitative results are shown in Figure 4. After careful comparison, we have following observations: (1) The L2M-GAN performs well at disentangling attributes during editing. However, due to the strong constrain of orthogonal loss, the manipulated attribute is not obvious. (2) Although the StyleCLIP\* method can make the best use of semantic knowledge of CLIP-space, the irrelevant attributes are changed in facial attribute editing without correct guidance direction. (3) Our directional latent mapping network manipulates the attribute correctly and naturally, which demonstrates that the proposed semantic directional consistency (SDC) loss could enforce the editing model to change specific attributes while preserving irrelevant parts. It also proves that there exists latent directions corresponding to different semantic properties in latent space. By manipulating latent code along such direction or its opposite direction, we can add or remove attributes.
|
| 170 |
+
|
| 171 |
+
Facial Attribute Transfer. Inspired by the above direction-based latent space manipulation for facial attribute transfer, we leverage this peculiarity for facial attribute transfer task.
|
| 172 |
+
|
| 173 |
+
We first execute our SDD-Net on the “smile” attribute for single attribute transfer, and input the corresponding text prompt to the model. The qualitative results are shown in Figure 5. We observe that when reference has the consistent attribute appointed by the prompt, the SDD-Net could correctly transfer the specific attribute to the target face with irrelevant information preserved, as shown in the top part. On the contrary, when the reference has the opposite attribute, our SDD-Net also could transfer opposite attribute to the target without extra guidance. By fully leveraging the knowledge of CLIP-space, our SDD-Net could find the semantic-aware latent direction in the latent space. The experiments show the excellent performance of our SDD-Net.
|
| 174 |
+
|
| 175 |
+
For the reference-guide image synthesis, we set the projected vector $\vec { \mathcal { V } _ { p } }$ is equal to the RT vector $\vec { \nu _ { R T } }$ . Figure 6 provides qualitative comparison of the results. We observe that StarGANv2 mothed synthesizes images with a same style code. However, the results show that StarGANv2 model manipulates images in a limited space. As a result, the attributes of the synthetic faces tend to be exactly alike. In addition, the expression attribute such as “smile” is ignored during transferring. Compared to StarGANv2, our SDD-Net transfers the multiple meaningful attributes to each of the target faces in semantic-level. Meanwhile, our method manipulates the image along the latent direction leveraging the knowledge of CLIP in latent space, which allows our method to synthesize realistic facial images, rather than simple style transfer.
|
| 176 |
+
|
| 177 |
+
# 4.5 ABLATION STUDY
|
| 178 |
+
|
| 179 |
+
We conduct a qualitative ablation study, as shown in Figure 7, and show the significance of identity loss. We observe that, when hyperparameter $\lambda _ { \mathrm { I D } } = 0 . 1$ , the ID loss hinders the attribute transfer. Then we experiment with $\lambda _ { \mathrm { I D } } ~ = ~ 0$ , the attribute could be correctly transferred, but the identity information is changed. To trade-off, we set the $\lambda _ { \mathrm { I D } } = 0 . 0 2$ .
|
| 180 |
+
|
| 181 |
+

|
| 182 |
+
Figure 7: The ablation study of identity loss. Under each column we specify $( \lambda _ { \mathrm { I D } } )$ ) identity loss. Obviously the ID loss is significant for facial attribute transfer.
|
| 183 |
+
|
| 184 |
+
# 5 CONCLUSIONS
|
| 185 |
+
|
| 186 |
+
In this paper, we first propose directional latent mapping network for text-driven facial attribute editing. By leveraging semantic direction consistency (SDC) loss, the directional latent mapping network could correctly edit relevant attribute while preserving irrelevant attributes. And on this basis, we propose semantic directional decomposition network (SDD-Net) for text-driven facial attribute transfer, which correctly transfers the semantic-aware attributes of reference image to the target image. Experiments show that our method achieves impressive performance on CelebA-HQ dataset.
|
| 187 |
+
|
| 188 |
+
# REFERENCES
|
| 189 |
+
|
| 190 |
+
Rameen Abdal, Yipeng Qin, and Peter Wonka. Image2stylegan: How to embed images into the stylegan latent space? In Proceedings of the IEEE/CVF International Conference on Computer Vision, pp. 4432–4441, 2019.
|
| 191 |
+
|
| 192 |
+
David Bau, Hendrik Strobelt, William Peebles, Jonas Wulff, Bolei Zhou, Jun-Yan Zhu, and Antonio Torralba. Semantic photo manipulation with a generative image prior. arXiv preprint arXiv:2005.07727, 2020.
|
| 193 |
+
|
| 194 |
+
Yunjey Choi, Minje Choi, Munyoung Kim, Jung-Woo Ha, Sunghun Kim, and Jaegul Choo. Stargan: Unified generative adversarial networks for multi-domain image-to-image translation. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 8789–8797, 2018.
|
| 195 |
+
|
| 196 |
+
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, pp. 8188–8197, 2020.
|
| 197 |
+
|
| 198 |
+
Jiankang Deng, Jia Guo, Niannan Xue, and Stefanos Zafeiriou. Arcface: Additive angular margin loss for deep face recognition. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 4690–4699, 2019.
|
| 199 |
+
|
| 200 |
+
Hui Ding, Kumar Sricharan, and Rama Chellappa. Exprgan: Facial expression editing with controllable expression intensity. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 32, 2018.
|
| 201 |
+
|
| 202 |
+
Garoe Dorta, Sara Vicente, Neill DF Campbell, and Ivor JA Simpson. The gan that warped: Semantic attribute editing with unpaired data. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 5356–5365, 2020.
|
| 203 |
+
|
| 204 |
+
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.
|
| 205 |
+
|
| 206 |
+
Lore Goetschalckx, Alex Andonian, Aude Oliva, and Phillip Isola. Ganalyze: Toward visual definitions of cognitive image properties. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pp. 5744–5753, 2019.
|
| 207 |
+
|
| 208 |
+
Ian Goodfellow, Jean Pouget-Abadie, Mehdi Mirza, Bing Xu, David Warde-Farley, Sherjil Ozair, Aaron Courville, and Yoshua Bengio. Generative adversarial nets. Advances in neural information processing systems, 27, 2014.
|
| 209 |
+
|
| 210 |
+
Erik Hark ¨ onen, Aaron Hertzmann, Jaakko Lehtinen, and Sylvain Paris. Ganspace: Discovering ¨ interpretable gan controls. arXiv preprint arXiv:2004.02546, 2020.
|
| 211 |
+
|
| 212 |
+
Zhenliang He, Wangmeng Zuo, Meina Kan, Shiguang Shan, and Xilin Chen. Attgan: Facial attribute editing by only changing what you want. IEEE transactions on image processing, 28(11):5464– 5478, 2019.
|
| 213 |
+
|
| 214 |
+
Zhenliang He, Meina Kan, Jichao Zhang, and Shiguang Shan. Pa-gan: Progressive attention generative adversarial network for facial attribute editing. arXiv preprint arXiv:2007.05892, 2020.
|
| 215 |
+
|
| 216 |
+
Bingwen Hu, Zhedong Zheng, Ping Liu, Wankou Yang, and Mingwu Ren. Unsupervised eyeglasses removal in the wild. IEEE Transactions on Cybernetics, 2020.
|
| 217 |
+
|
| 218 |
+
Ali Jahanian, Lucy Chai, and Phillip Isola. On the” steerability” of generative adversarial networks. arXiv preprint arXiv:1907.07171, 2019.
|
| 219 |
+
|
| 220 |
+
Tero Karras, Timo Aila, Samuli Laine, and Jaakko Lehtinen. Progressive growing of gans for improved quality, stability, and variation. arXiv preprint arXiv:1710.10196, 2017.
|
| 221 |
+
|
| 222 |
+
Tero Karras, Samuli Laine, and Timo Aila. A style-based generator architecture for generative adversarial networks. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 4401–4410, 2019.
|
| 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, pp. 8110–8119, 2020.
|
| 225 |
+
|
| 226 |
+
Jeong-gi Kwak, David K Han, and Hanseok Ko. Cafe-gan: Arbitrary face attribute editing with complementary attention feature. In Computer Vision–ECCV 2020: 16th European Conference, Glasgow, UK, August 23–28, 2020, Proceedings, Part XIV 16, pp. 524–540. Springer, 2020.
|
| 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 Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 4681–4690, 2017.
|
| 229 |
+
|
| 230 |
+
Chen-Hsuan Lin, Ersin Yumer, Oliver Wang, Eli Shechtman, and Simon Lucey. St-gan: Spatial transformer generative adversarial networks for image compositing. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 9455–9464, 2018.
|
| 231 |
+
|
| 232 |
+
Ming Liu, Yukang Ding, Min Xia, Xiao Liu, Errui Ding, Wangmeng Zuo, and Shilei Wen. Stgan: A unified selective transfer network for arbitrary image attribute editing. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 3673–3682, 2019.
|
| 233 |
+
|
| 234 |
+
Ziwei Liu, Ping Luo, Xiaogang Wang, and Xiaoou Tang. Deep learning face attributes in the wild. In Proceedings of the IEEE international conference on computer vision, pp. 3730–3738, 2015.
|
| 235 |
+
|
| 236 |
+
Yotam Nitzan, Rinon Gal, Ofir Brenner, and Daniel Cohen-Or. Large: Latent-based regression through gan semantics. arXiv preprint arXiv:2107.11186, 2021.
|
| 237 |
+
|
| 238 |
+
Or Patashnik, Zongze Wu, Eli Shechtman, Daniel Cohen-Or, and Dani Lischinski. Styleclip: Textdriven manipulation of stylegan imagery. arXiv preprint arXiv:2103.17249, 2021.
|
| 239 |
+
|
| 240 |
+
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. arXiv preprint arXiv:2103.00020, 2021.
|
| 241 |
+
|
| 242 |
+
Elad Richardson, Yuval Alaluf, Or Patashnik, Yotam Nitzan, Yaniv Azar, Stav Shapiro, and Daniel Cohen-Or. Encoding in style: a stylegan encoder for image-to-image translation. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 2287–2296, 2021.
|
| 243 |
+
|
| 244 |
+
Yujun Shen, Jinjin Gu, Xiaoou Tang, and Bolei Zhou. Interpreting the latent space of gans for semantic face editing. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 9243–9252, 2020.
|
| 245 |
+
|
| 246 |
+
Omer Tov, Yuval Alaluf, Yotam Nitzan, Or Patashnik, and Daniel Cohen-Or. Designing an encoder for stylegan image manipulation. ACM Transactions on Graphics (TOG), 40(4):1–14, 2021.
|
| 247 |
+
|
| 248 |
+
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.
|
| 249 |
+
|
| 250 |
+
Zongze Wu, Dani Lischinski, and Eli Shechtman. Stylespace analysis: Disentangled controls for stylegan image generation. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 12863–12872, 2021.
|
| 251 |
+
|
| 252 |
+
Taihong Xiao, Jiapeng Hong, and Jinwen Ma. Elegant: Exchanging latent encodings with gan for transferring multiple face attributes. In Proceedings of the European conference on computer vision (ECCV), pp. 168–184, 2018.
|
| 253 |
+
|
| 254 |
+
Yinghao Xu, Yujun Shen, Jiapeng Zhu, Ceyuan Yang, and Bolei Zhou. Generative hierarchical features from synthesizing images. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 4432–4442, 2021.
|
| 255 |
+
|
| 256 |
+
Guoxing Yang, Nanyi Fei, Mingyu Ding, Guangzhen Liu, Zhiwu Lu, and Tao Xiang. L2m-gan: Learning to manipulate latent space semantics for facial attribute editing. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 2951–2960, 2021a.
|
| 257 |
+
|
| 258 |
+
Tao Yang, Peiran Ren, Xuansong Xie, and Lei Zhang. Gan prior embedded network for blind face restoration in the wild. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 672–681, 2021b.
|
| 259 |
+
|
| 260 |
+
Raymond A Yeh, Chen Chen, Teck Yian Lim, Alexander G Schwing, Mark Hasegawa-Johnson, and Minh N Do. Semantic image inpainting with deep generative models. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 5485–5493, 2017.
|
| 261 |
+
|
| 262 |
+
Weidong Yin, Ziwei Liu, and Chen Change Loy. Instance-level facial attributes transfer with geometry-aware flow. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 33, pp. 9111–9118, 2019.
|
md/dev/AP1MKT37rJ/AP1MKT37rJ.md
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
md/dev/BvowzJp_Yl6/BvowzJp_Yl6.md
ADDED
|
@@ -0,0 +1,205 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# HOMOGENEOUS LEARNING: SELF-ATTENTION DECENTRALIZED DEEP LEARNING
|
| 2 |
+
|
| 3 |
+
Anonymous authors Paper under double-blind review
|
| 4 |
+
|
| 5 |
+
# ABSTRACT
|
| 6 |
+
|
| 7 |
+
Federated learning (FL) has been facilitating privacy-preserving deep learning in many walks of life such as medical image classification, network intrusion detection, and so forth. Whereas it necessitates a central parameter server for model aggregation, which brings about delayed model communication and vulnerability to adversarial attacks. A fully decentralized architecture like Swarm Learning allows peer-to-peer communication among distributed nodes, without the central server. One of the most challenging issues in decentralized deep learning is that data owned by each node are usually non-independent and identically distributed (non-IID), causing time-consuming convergence of model training. To this end, we propose a decentralized learning model called Homogeneous Learning (HL) for tackling non-IID data with a self-attention mechanism. In HL, training performs on each round’s selected node, and the trained model of a node is sent to the next selected node at the end of each round. Notably, for the selection, the self-attention mechanism leverages reinforcement learning to observe a node’s inner state and its surrounding environment’s state, and find out which node should be selected to optimize the training. We evaluate our method with various scenarios for two different image classification tasks. The result suggests that HL can produce a better performance compared with standalone learning and greatly reduce both the total training rounds by $5 0 . 8 \%$ and the communication cost by $7 4 . 6 \%$ compared with random policy-based decentralized learning for training on non-IID data.
|
| 8 |
+
|
| 9 |
+
# 1 INTRODUCTION
|
| 10 |
+
|
| 11 |
+
Decentralized deep learning (DDL) is a concept to bring together distributed data sources and computing resources while taking the full advantage of deep learning models. Nowadays, DDL such as Federated Learning (FL) (Konecnˇ y et al., 2016) has been offering promising solutions to social ´ issues surrounding data privacy, especially in large-scale multi-agent learning. These massively distributed nodes can facilitate diverse use cases, such as industrial IoT (Parimala et al., 2021), environment monitoring with smart sensors (Gao et al., 2020), human behavior recognition with surveillance cameras (Liu et al., 2020), connected autonomous vehicles control (Pokhrel & Choi, 2020; Liu et al., 2019), federated network intrusion detection (Sun et al., 2021; Rahman et al., 2020), and so forth.
|
| 12 |
+
|
| 13 |
+
Though FL has been attracting great attention due to the privacy-preserving architecture, recent years’ upticks in adversarial attacks cause its hardly guaranteed trustworthiness. FL encounters various threats, such as backdoor attacks (McMahan et al., 2018; Cao et al., 2019; Nguyen et al., 2020), information stealing attacks (Duan et al., 2021), and so on. On the contrast, fully decentralized architectures like Swarm Learning (SL) (Warnat-Herresthal et al., 2021) leverages the blockchain, smart contract, and other state-of-the-art decentralization technologies to offer a more practical solution. Whereas, a great challenge of it has been deteriorated performance in model training with non-independent identically distributed (non-IID) data, leading to extremely increased time of model convergence.
|
| 14 |
+
|
| 15 |
+
Our contributions. We propose a self-attention decentralized deep learning model called Homogeneous Learning (HL). HL leverages a shared communication policy for adaptive model sharing among nodes. A starter node initiates a training task and by iteratively sending the trained model and performing training on each round’s selected node its model is updated for achieving the training goal. Notably, a node selection decision is made by reinforcement learning agents based on the current selected node’s inner state and outer state of its surrounding environment to maximize a reward for moving towards the training goal. Finally, comprehensive experiments and evaluation results suggest that HL can accelerate the model training on non-IID data with $5 0 . 8 \%$ fewer total training rounds and reduce the associated communication cost by $7 4 . 6 \%$ .
|
| 16 |
+
|
| 17 |
+
Paper outline. This paper is organized as follows. Section 2 demonstrates the most recent work about DDL and methodologies for tackling data heterogeneity problems in model training. Section 3 presents the technical underpinnings of Homogeneous Learning, including the privacy-preserving decentralized learning architecture and the self-attention mechanism using reinforcement learning agents. Section 4 demonstrates experimental evaluations. Section 5 concludes the paper and gives out future directions of this work.
|
| 18 |
+
|
| 19 |
+
# 2 RELATED WORK
|
| 20 |
+
|
| 21 |
+
Decentralized Deep Learning. In recent years, lots of DDL architectures have been proposed leveraging decentralization technologies such as the blockchain and ad hoc networks. For instance, Li et al. (2021) presented a blockchain-based decentralized learning framework based on the FISCO blockchain system. They applied the architecture to train AlexNet models on the FEMNIST dataset. Similarly, Lu et al. (2020) demonstrated a blockchain empowered secure data sharing architecture for FL in industrial IoT. Furthermore, Mowla et al. (2020) proposed a client group prioritization technique leveraging the Dempster-Shafer theory for unmanned aerial vehicles (UAVs) in flying adhoc networks. HL is a fully decentralized machine learning model sharing architecture based on decentralization technology such as token exchanges.
|
| 22 |
+
|
| 23 |
+
Convergence Optimization. In a real-life application, usually data owned by different clients in such a decentralized system are skewed. For this reason, the model training is slow and even diverges. Methodologies for tackling such data heterogeneity such as FL, have been studied for a long time. For example, Sener & Savarese (2018) presented the K-Center clustering algorithm which aims to find a representative subset of data from a very large collection such that the performance of the model based on the small subset and that based on the whole collection will be as close as possible. Moreover, Wang et al. (2020) demonstrated reinforcement learning-based client selection in FL, which counterbalances the bias introduced by non-IID data thus speeding up the global model’s convergence. Sun et al. (2021) proposed the Segmented-FL to tackle heterogeneity in massively distributed network intrusion traffic data, where clients with highly skewed training data are dynamically divided into different groups for model aggregation respectively at each round. Furthermore, Zhao et al. (2018) presented a data-sharing strategy in FL by creating a small data subset globally shared between all the clients. Likewise, Jeong et al. (2018) proposed the federated augmentation where each client augments its local training data using a generative neural network. Different from the aforementioned approaches, HL leverages a self-attention mechanism that optimizes the communication policy in DDL using reinforcement learning models. It is aimed to reduces computational and communication cost of decentralized training on skewed data.
|
| 24 |
+
|
| 25 |
+
# 3 HOMOGENEOUS LEARNING
|
| 26 |
+
|
| 27 |
+
# 3.1 PRELIMINARY
|
| 28 |
+
|
| 29 |
+
Data Privacy and Decentralized Deep Learning. Centralized deep learning in high performance computing (HPC) environments has been facilitating the advancement in various areas such as drug discovery, disease diagnosis, cybersecurity, and so on. Despite its broad applications in many walks of life, the associated potential data exposure of training sources and privacy regulation violation have greatly decreased the practicality of such centralized learning architecture. In particular, with the promotion of GDPR (EU), data collection for centralized model training has become more and more difficult. For this reason, Google proposed federated learning (FL) to alleviate the limitation of model training on distributed data. FL allows a client to train its own model based on a local dataset and achieve a better performance by sharing the training result with others, whereas without sharing the raw training data. FL quickly acquired intense attention from lots of fields related to sensitive data processing including medical image classification, face recognition, intrusion detection, finance data analysis, and so forth. Moreover, a fully decentralized deep learning architecture is peer-topeer networking of nodes based on decentralization and security technologies such as the tokenexchange, a service capable of validating and issuing security tokens to enable nodes to obtain appropriate access credentials for exchanging resources without the central server. In this case, each node owns a local training model and performs both the function of the client and the server based on a shared communication policy, which is different from FL where the central server plays the key role in model sharing.
|
| 30 |
+
|
| 31 |
+
We specifically consider a supervised learning task with $C$ categories in the entire dataset $D$ . Suppose that $f _ { \theta } : x y$ denotes a neural network classifier with parameters $\theta$ , taking an input $x _ { i } \in x$ and outputting a $C$ -dimensional real-valued vector also known as the logit. This neural network gives a predicted label $y _ { i } = a r g m a x f _ { \theta } ( x _ { i } )$ s.t. $y _ { i } \in y$ . We assume there are $K$ nodes in the network. The $k$ th node has its own dataset $D _ { l o c a l } ^ { ( k ) } : = \{ ( x _ { i } , y _ { i } ) \} _ { i = 1 } ^ { N ^ { ( k ) } }$ , where $x _ { i }$ is the ith training sample, $y _ { i }$ is the corresponding label of the sample number in datase $x _ { i }$ $y _ { i } \in \{ 1 , 2 , . . . , C \}$ $N ^ { ( k ) }$ $\begin{array} { r } { D : = \{ D _ { l o c a l } ^ { 1 } , D _ { l o c a l } ^ { 2 } , . . . , D _ { l o c a l } ^ { i } \} , N = \sum _ { k = 1 } ^ { K } N ^ { ( k ) } } \end{array}$ goal of the decentralized systems is to achieve a desired performance on the entire data through sharing local trained models $L _ { t } ^ { ( k ) }$ at each round $t$ .
|
| 32 |
+
|
| 33 |
+
Data Heterogeneity. The challenges related to heterogeneity of nodes in DDL refer to two categories, i.e., data heterogeneity and hardware heterogeneity. Notably, data heterogeneity results in time-consuming convergence or divergence of model learning. Let $p ( x | y )$ be the common data distribution of the entire data $D$ . We assume the common distribution $p ( x | y )$ is shared by all nodes. Then, Nodek has $p _ { k } ( y )$ . We first consider an independent and identically distributed (IID) setting, i.e., $p _ { i } ( x , y ) = p ( x | y ) p _ { i } ( y )$ s.t. $p _ { i } ( y ) = p _ { j } ( y )$ for all $i \neq j$ . Under this assumption, the data distribution of the entire dataset can be represented by a node’s local data distribution. Unfortunately, in real-life application, samples held by clients are usually skewed with various data distributions, i.e., $p _ { i } ( x , y ) \dot { = } p ( x | y ) p _ { i } ( y )$ s.t. $p _ { i } ( y ) \dot { = } p _ { j } ( y )$ for all $i \neq j$ . Node1 follows $p 1 ( x , y )$ and Node2 follows $p 2 ( x , y )$ . We further define and clarify such data heterogeneity as follows: for a nodek’s local dataset, when its $\alpha$ samples are from a single main data class $c ^ { ( k ) }$ subject to $\alpha > { \frac { N ^ { ( k ) } } { C } }$ and the remaining samples are randomly drawn from the other $C \mathrm { - } I$ data classes, the heterogeneity level $H ^ { ( k ) }$ of nodek is formulated as $H ^ { ( k ) } ( D _ { l o c a l } ^ { ( k ) } ) = - p ( y = c ) * l o g ( p ( y \neq c ) )$ . Moreover, we assign a main data class $c ^ { ( k ) } = k \% C$ to nodek.
|
| 34 |
+
|
| 35 |
+
Communication Overhead. Though communication overhead in a decentralized learning system also involves the payload size such as different numbers of model parameters (He et al., 2020; Singh et al., 2019), it is out of the scope of this research where we focus on different communication distances between distributed nodes. In particular, for every two nodes $i$ and $j$ , a relative communication distance $d _ { i , j }$ is defined in the symmetrical matrix $D i s _ { i \times j }$ , where the bidirectional distances between two nodes are equal and the distance to a node itself $d _ { i , j \mid i = j }$ is zero. Furthermore, each distance $d _ { i , j | i \neq j }$ in the matrix is a random numerical value between 0 and $\beta$ (Equation 1).
|
| 36 |
+
|
| 37 |
+
$$
|
| 38 |
+
D i s _ { i \times j } = \left( \begin{array} { c c c c } { d _ { 1 , 1 } } & { d _ { 1 , 2 } } & { \cdots } & { d _ { 1 , j } } \\ { d _ { 2 , 1 } } & { d _ { 2 , 2 } } & { \cdots } & { d _ { 2 , j } } \\ { \vdots } & { \vdots } & { \ddots } & { \vdots } \\ { d _ { i , 1 } } & { d _ { i , 2 } } & { \cdots } & { d _ { i , j } } \end{array} \right) s u b j e c t t o : \ d _ { i , j | i = j } = 0 , \ d _ { i , j } = d _ { j , i } , d _ { i , j | i \neq j } \in ( 0 , \beta ]
|
| 39 |
+
$$
|
| 40 |
+
|
| 41 |
+
Where $d _ { i , j }$ represents the relative distance from node $i$ to node $j$ .
|
| 42 |
+
|
| 43 |
+
# 3.2 TECHNICAL FUNDAMENTALS OF HOMOGENEOUS LEARNING
|
| 44 |
+
|
| 45 |
+
We propose a novel decentralized deep learning architecture called Homogeneous Learning (HL) (Fig. 1). HL leverages reinforcement learning (RL) agents to learn a shared communication policy of node selection, thus contributing to fast convergence of model training and reducing communication cost as well. In $\mathrm { H L }$ , each node has two machine learning (ML) models, namely a local ML task model $L ^ { ( k ) }$ for the multi-classification task and an RL model $L ^ { D Q N }$ for the node selection in peerto-peer communications.
|
| 46 |
+
|
| 47 |
+

|
| 48 |
+
Figure 1: Homogeneous learning: self-attention decentralized deep learning.
|
| 49 |
+
|
| 50 |
+
# 3.2.1 LOCAL ML TASK MODEL
|
| 51 |
+
|
| 52 |
+
Task Model Architecture. We assume the $K$ nodes in HL share the same model architecture as a local ML task model. Let $y _ { i }$ be the layeri’s output of $L ^ { ( k ) }$ . $y _ { i } = f _ { i } ( W _ { i } y _ { i - 1 } ) , i = 1 , . . . , p , y _ { 0 } = x$ , where $f _ { i }$ is the activation function, $W _ { i }$ is the weight matrix of layeri, $y _ { i - 1 }$ represents the output of the previous layer, and $p$ is the number of layers in $L ^ { ( k ) }$ . Notably, we employ a three-layer convolutional neural network (CNN) with an architecture as follows: the first convolutional layer of the CNN model has a convolution kernel of size $5 { \times } 5$ with a stride of 1 and it takes one input plane and it produces 20 output planes, followed by a ReLU activation function; the second convolutional layer takes 20 input planes and produces 50 output planes and it has a convolution kernel of size $5 { \times } 5$ with a stride of 1, followed by ReLU; the output is flattened followed by a linear transformation of a fully connected layer, which takes as input the tensor and outputs a tensor of size $C$ representing the $C$ categories. Moreover, the categorical cross-entropy is employeapply as a learning function the Adam to update the model, i.e., $\ell$ $L _ { t + 1 } ^ { ( k ) } \gets \bar { L } _ { t } ^ { ( k ) } - \eta \cdot \nabla \ell ( L _ { t } ^ { ( k ) } , D _ { l o c a l } ^ { ( k ) } )$ where $L _ { t } ^ { ( k ) }$ is nodek’s local ML task model at the round $t$ and $\eta$ is the learning rate.
|
| 53 |
+
|
| 54 |
+
# 3.2.2 REINFORCEMENT LEARNING MODEL
|
| 55 |
+
|
| 56 |
+
Besides the local ML task model, each nodek in $\mathrm { H L }$ is also associated with a reinforcement learning (RL) model $L ^ { D Q N }$ . The goal of the RL model is to learn a communication policy for the node selection in decentralized learning. There are three main components of the RL model, namely, the state $s$ , the action $a$ , and the reward $r$ . Then, based on the input state $s$ , the RL model outputs an action $a$ for the next node selection, and at the same time, updates itself by correlating the attained reward $r$ with the performed action $a$ . As a result, the recursive self-improvement of the RL model allows a node to constantly explore the relation between the system’s performance and the selection policy (the self-attention mechanism in $\mathrm { H L }$ ), contributing to faster convergence of model learning.
|
| 57 |
+
|
| 58 |
+
Every round $t$ , a RL model observes the state $s _ { t }$ from two different sources, i.e., model parameters $s _ { t } ^ { ( k ) }$ of the selected nodek and parameters of models in the surrounding environment $\{ s _ { t } ^ { ( i ) } | i \in K , i \neq$ $k \}$ . In particular, we employ a deep Q-network (DQN), which approximates a state-value function in a Q-learning framework with a neural network. Let $y _ { i } ^ { D Q N }$ be the layeri’s output of $L ^ { D Q N }$ . $y _ { i } ^ { D Q N } = f _ { i } ^ { D Q N } ( W _ { i } ^ { D Q N } y _ { i - 1 } ^ { D Q N } ) , i = 1 , . . . , q , y _ { 0 } ^ { D Q N } = s$ , where $f _ { i } ^ { D Q N }$ is the activation function of layeri, W DQNi is the weight matrix of layeri, yDQNi−1 represents the output of the previous layer, and $q$ is the number of layers in $L ^ { D Q N }$ . Notably, a DQN model consisting of three fully connected layers is applied (Fig. 2). The two hidden layers consist of 500 and 200 neurons respectively, using as an activation function the ReLU. The output layer with a linear activation function consists of $K$ neurons that output the rewards of selecting each nodek respectively, $k \in \{ 1 , 2 , . . . , K \}$ . Furthermore, at each round $t$ , the node with the largest reward will be selected. $a _ { t } = a r g m a x f _ { L ^ { D Q N } } ( s _ { t } )$ , where $L ^ { D Q N }$ denotes weights of the DQN model. Consequently, the RL model selects and sends the trained local model L(k)t+1 of nodek to the next node $a _ { t }$ . As such, the local ML task model $L _ { t + 1 } ^ { ( a _ { t } ) }$ of node $a _ { t }$ is updated to L(k)t+1.
|
| 59 |
+
|
| 60 |
+

|
| 61 |
+
Figure 2: Next-node selection based on the RL model of HL.
|
| 62 |
+
|
| 63 |
+
To understand the training of the RL model, we first define the input state $s _ { t }$ . The state $s _ { t }$ is a concatenated vector of the flattened model parameters of all nodes in the systems. $s _ { t } = \{ s _ { t } ^ { ( k ) } | k \in$ $K \}$ . To efficiently represent the state and compute the RL model prediction, we adopt the principal component analysis (PCA) to reduce the dimension of the state $s _ { t }$ from an extremely large number (e.g. 33580 dimensions for MNIST) to $K$ , where $K$ is the number of nodes. $K$ is adopted due to the minimum possible dimension of a PCA-based output vector is the number of input samples. Then, we define the output reward $r _ { t }$ . Every round $t$ , a trained ML task model is evaluated on a hold-out validation set $D _ { v a l }$ , and the reward $r _ { t }$ can be computed from the validation accuracy $V a l A c c _ { t }$ , the communication distance between the current node $k$ and the next selected node $a _ { t }$ , and a penalty of minus one for taking each training step. $r _ { t } = 3 2 ^ { V a l A c c _ { t } - G o a l A c c } - d _ { k , a _ { t } } - 1$ , where $G o a l A c c$ denotes the desired performance on the validation set and $d _ { k , a _ { t } }$ is the communication distance drawn from the distance matrix $D i s _ { i \times j }$ . We employ an exponentially increasing function $3 2 ^ { ( \cdot ) }$ to distinguish between different validation results when the ML task model is close to convergence when only small variance is observed in the results. In addition, an episode reward $R$ is the accumulative reward of the current reward and discounted future rewards in the whole training process of HL. $\begin{array} { r } { R = \sum _ { t = 1 } ^ { T } \gamma ^ { t - 1 } r _ { t } } \end{array}$ , where $T$ is the total training rounds of $\mathrm { H L }$ in one episode.
|
| 64 |
+
|
| 65 |
+
With DQN, we often use experience replay during training. A RL model’s experience at each time step $t$ is stored in a data set called the replay memory. Let $e _ { t }$ be the model’s experience at time $t$ . $\boldsymbol { e } _ { t } = \left( \boldsymbol { s } _ { t - 1 } , \boldsymbol { a } _ { t } , \boldsymbol { r } _ { t } , \boldsymbol { s } _ { t } \right)$ , where $r _ { t + 1 }$ is the reward given the previous state-action pair $\left( s _ { t - 1 } , a _ { t } \right)$ and $s _ { t }$ is the state of the ML task models after training. We assume a finite size limit $M$ of the replay memory, and it will only store the last $M$ experiences. Moreover, to facilitate constant exploration of a RL model, epsilon is a factor to control the probability of the next node being selected by the RL model. In particular, for each round, a random numerical value between 0 and 1 is obtained and compared with the current epsilon value $E p s i l o n _ { e p }$ where $e p$ denotes the current episode. Then if the randomly picked value is greater than $E p s i l o n _ { e p }$ , the next node will be selected by the RL model. Otherwise, a random action of node selection will be performed. For either case, an experience sample $\boldsymbol { e } _ { t } ~ = ~ \left( s _ { t - 1 } , a _ { t } , r _ { t } , s _ { t } \right)$ will be stored in the replay memory. The decentralized learning terminates when either the model achieves the desired performance on the validation set or exceeds a maximum number of rounds $T _ { m a x }$ , the learning progress of which is called an episode of HL. For each episode, we apply the epsilon decay $\rho$ to gradually increase the possibility of the RL model’s decision-making. $E p s i l o n _ { e p + 1 } = E p s i l o n _ { e p } \cdot e ^ { - \rho }$ , where $E p s i l o n _ { e p + 1 }$ is the computed epsilon for the next episode and $e$ is the Euler’s number that is approximately equal to 2.718.
|
| 66 |
+
|
| 67 |
+
Furthermore, at the end of each episode $e p$ , the RL model is trained on a small subset of samples randomly drawn from the replay memory. Let $\ell$ be the mean squared error loss of $L _ { t } ^ { D Q N }$ . We adopt as a learning function the Adam. Then, the optimization of the DQN model is formulated in (5). The updated DQN model is shared with the next selected node. As such, the RL model performs better and better in predicting the expected rewards of selecting each node for the next round, which results in the increase of the episode reward $R$ by selecting the node with the largest expected reward at each round $t$ .
|
| 68 |
+
|
| 69 |
+
$$
|
| 70 |
+
\ell ( L _ { t } ^ { D Q N } ) = \sum _ { i = 1 } ^ { B } \ell ( r _ { t } + \beta \mathop { m a x } _ { a _ { i + 1 } } f ( a _ { i + 1 } , s _ { i } ; L _ { t } ^ { D Q N } ) , f ( a _ { i } , s _ { i - 1 } ; L _ { t } ^ { D Q N } ) )
|
| 71 |
+
$$
|
| 72 |
+
|
| 73 |
+
$$
|
| 74 |
+
\theta ^ { * } = a r g m i n \ell ( \theta ) , s u b j e c t t o \theta = L _ { t } ^ { D Q N }
|
| 75 |
+
$$
|
| 76 |
+
|
| 77 |
+
Where $a _ { i + 1 }$ denotes the predicted next step’s action that maximizes the future reward, $\beta$ denotes the discount factor of the future reward, $f$ denotes a feed-forward function that produces the output of the RL model with respect to $a _ { i }$ based on $s _ { i }$ , and $B$ denotes the batch size.
|
| 78 |
+
|
| 79 |
+
Finally, the model training of $\mathrm { H L }$ is formulated as Algorithm 1.
|
| 80 |
+
|
| 81 |
+
# Algorithm 1 Model Training of Homogeneous Learning
|
| 82 |
+
|
| 83 |
+
1: Training: 2: initialize $L _ { 0 } ^ { d q n }$ 3: for each episode $e p = 1 , 2 , \dots { }$ do 4: initialize $L _ { 0 } ^ { ( k ) }$ 5: $a _ { 0 } = k$ 6: for each step $t = 0 , 1 , 2 , \dots$ do 7: while $V a l A c c _ { t } < G o a l A c c$ and $t < T _ { m a x }$ do ▷ $T _ { m a x }$ is the maximum steps per episode 8: $V a l A c c _ { t + 1 } , a _ { t } , L _ { t + 1 } ^ { ( k ) } = H L ( L _ { t } ^ { ( k ) } , L _ { t } ^ { D Q N } )$ 9: Send $\{ L _ { t + 1 } ^ { ( k ) } , L _ { t + 1 } ^ { D Q N } \}$ 1, LDQNt+1 } to at for the next step’s model update 10: end while 11: 12: 13: $\begin{array} { r l } & { \overset { \mathbf { \widehat { x } } : \mathbf { m } : \mathbf { s u } } { L _ { e p + 1 } ^ { D Q N } } = a r g \ m i n \sum _ { i = 1 } ^ { B } \ell ( r _ { t } + \beta \operatorname* { m a x } { f ( a _ { i + 1 } , s _ { i + 1 } ; L _ { e p } ^ { D Q N } ) } , f ( a _ { i } , s _ { i } ; L _ { e p } ^ { D Q N } ) ) } \\ & { \overset { E p s i l o n } { e } _ { p + 1 } = E p s i l o n _ { e p } \cdot e ^ { - \rho } } \end{array}$ 14: end for 15:16: function $\mathrm { H L } ( \mathrm { L } _ { t } ^ { ( k ) } , L _ { t } ^ { D Q N } ) \mathrm { L } _ { t + 1 } ^ { ( k ) } = T r a i n ( L _ { t } ^ { ( k ) } , D _ { l o c a l } ^ { ( k ) } ) \ \gg D _ { l o c a l } ^ { ( k ) }$ is Node $k$ ’s local training 17:8 $\overrightarrow { V a l } A c c _ { t + 1 } = A c c ( D _ { v a l } ; L _ { t + 1 } ^ { ( k ) } )$ 19: $s _ { t } ^ { ( k ) } = L _ { t + 1 } ^ { ( k ) }$ 20: $s _ { t } ^ { ( i ) } = L _ { t } ^ { ( i ) }$ subject to $i \in K , i \neq k$ 21: $s _ { t } = \{ s _ { t } ^ { ( k ) } , s _ { t } ^ { ( i ) } | i \in K , i \neq k \}$ 223: 2: at = arg maxf (st; LDQNt )− $r _ { t } = 3 2 ^ { V a l A c c _ { t } - G o a l A c c } - d _ { k , a _ { t } } - 1$ 24: Add 25: retu $\{ s _ { t - 1 } , a _ { t } , r _ { t } , s _ { t } \}$ replay memory $V a l A c c _ { t + 1 } , a _ { t } , L _ { t + 1 } ^ { ( k ) }$ 26: end function
|
| 84 |
+
|
| 85 |
+
# 4 EVALUATION
|
| 86 |
+
|
| 87 |
+
# 4.1 EXPERIMENT SETUP
|
| 88 |
+
|
| 89 |
+
# 4.1.1 DATASET.
|
| 90 |
+
|
| 91 |
+
We applied MNIST (LeCun et al., 2010), a handwritten digit image dataset containing 50,000 training samples and 10,000 test samples labeled as 0-9, and Fashion-MNIST(Xiao et al., 2017), an image collection of 10 types of clothing containing 50,000 training samples and 10,000 test samples labeled as shoes, t-shirts, dresses, and so on. The size of grayscale images in these two datasets is $2 8 \times 2 8$ . Then, we considered both a 10-node scenario and a 100-node scenario training on the MNIST dataset and the Fashion-MNIST dataset respectively. The machine learning library we used to build the system is Tensorflow.
|
| 92 |
+
|
| 93 |
+
# 4.1.2 BASELINE MODELS.
|
| 94 |
+
|
| 95 |
+
To compare the performance of the proposed approach, we considered three different model training methods as baselines, which are centralized learning with all data collected from all nodes, decentralized learning with a random node selection policy, and standalone learning of the starter node without model sharing. In detail, for each method, we applied the same local ML task model architecture and associated model training hyperparameters using the training set data from MNIST and Fashion-MNIST respectively. The goal of model training is to achieve a validation accuracy of 0.80 for the MNIST classification task and 0.70 for the Fashion-MNIST classification task based on the hold-out test set of the corresponding dataset.
|
| 96 |
+
|
| 97 |
+
Regarding the standalone method, we utilized the early stopping to monitor the validation loss of the model at each epoch with a patience of five, which automatically terminated the training process when there appeared no further decrease in the validation loss of the model for the last five epochs. In the centralized and standalone learning, evaluation was performed at each epoch of the training. Moreover, in decentralized learning, due to multiple models in a system, the evaluation was performed on the trained local model of each step’s selected node.
|
| 98 |
+
|
| 99 |
+
# 4.1.3 HOMOGENEOUS LEARNING SETTINGS.
|
| 100 |
+
|
| 101 |
+
Homogeneous Learning (HL) of $\begin{array} { r c l } { K } & { = } & { \{ 1 0 , 1 0 0 \} } \end{array}$ nodes with a heterogeneity level $\cal H \_ =$ $\{ 0 . 2 4 , \mathrm { \bar { 0 } . 5 6 , 0 . 9 0 } \}$ $( p ( y = c ) = \{ 0 . 6 , 0 . 8 , 0 . 9 \} )$ was adopted. Each node $k$ owned a total of 500 skewed local training data with a heterogeneity level of $H .$ . In addition, to generate the distance matrix, the relative communication cost represented by the distance between two different nodes $d _ { i , j | i \neq j }$ takes a random numerical value between 0 and 0.1. A random seed of 0 was adopted for the reproducibility of the distance matrix (See A.1). For the local ML task model training, we adopted an epoch of one with a batch size of 32. A further discussion on the selection of these two hyperparameters can be found in the section A.2. The Adam was applied as an optimization function with a learning rate of 0.001.
|
| 102 |
+
|
| 103 |
+
# 4.2 NUMERICAL RESULTS
|
| 104 |
+
|
| 105 |
+
# 4.2.1 LEARNING A COMMUNICATION POLICY BASED ON DEEP Q-NETWORKS
|
| 106 |
+
|
| 107 |
+
As aforementioned, each node has a specific main data class $c$ . We considered a starter node with a main data class of digit ’0’ in the case of MNIST and a class of T-shirt in the case of Fashion-MNIST. Then, starting from the starter node, a local ML task model was trained on the current node’s local data and sent to the next step’s node decided by either the RL model or a random action depending on the epsilon at the current episode. We adopted an initial epsilon of one and a decay rate of 0.02. Moreover, the RL model was updated at the end of each episode using the hyperparameters defined in Table 1. We applied a maximum replay memory size of 50,000 and a minimum size of 128, where the training of the DQN model started only when there were more than 128 samples in the replay memory and the oldest samples would be removed when samples were more than the maximum capacity. Furthermore, in every episode, an agent randomly drew 32 samples from the memory to update its model, with a total of 120 episodes. The maximum training step is 35 in the case of MNIST and 100 in the case of Fashion-MNIST.
|
| 108 |
+
|
| 109 |
+
Table 1: Hyperparameters in Homogeneous Learning
|
| 110 |
+
|
| 111 |
+
<table><tr><td colspan="3">MLTASKMODEL</td></tr><tr><td colspan="3">RL MODEL</td></tr><tr><td>Epoch 1</td><td></td><td>Episode 120</td></tr><tr><td>Batch size 32</td><td>Future reward discount</td><td>0.9</td></tr><tr><td>Learning rate 0.001</td><td>Epsilon decay</td><td>0.02</td></tr><tr><td>Optimization function Adam</td><td>Epoch</td><td>1</td></tr><tr><td rowspan="2">Maximum step 35 (MNIST)/100 (Fashion-MNIST)</td><td>Batch size</td><td>16</td></tr><tr><td>Learning rate</td><td>0.001</td></tr></table>
|
| 112 |
+
|
| 113 |
+
For each episode, we computed the step rewards and the episode reward for the model training to achieve the performance goal. With the advancement of episodes, the communication policy evolved to improve the episode reward thus benefiting better decision-making of the next-node selection. Figure 3.a illustrates the episode reward and the mean reward over the last 10 episodes during HL and the corresponding total training rounds for each method when training on MNIST. Figure 3.b illustrates the episode reward results of HL when training on Fashion-MNIST.
|
| 114 |
+
|
| 115 |
+

|
| 116 |
+
Figure 3: (a) With the increase of episodes, the mean reward over last 10 episodes is gradually increasing. The DQN model learned a better communication policy by training on samples from the replay memory, contributing to the systems’ performance in total training rounds. (b) Episode reward results for the 10-node and 100-node scenarios when applying the Fashion-MNIST dataset. Compared with MNIST, the policy learning was more unstable with the same hyperparameter setting, however, it showed an increasing episode reward.
|
| 117 |
+
|
| 118 |
+
# 4.2.2 COMPARISONS REGARDING COMPUTATIONAL AND COMMUNICATION COST
|
| 119 |
+
|
| 120 |
+
To compare the performance between HL and the aforementioned three baseline models, we performed a comprehensive evaluation against the metrics of computational cost and communication cost in the case of MNIST with the 10-node scenario. For each method, we performed 10 individual experiments with different random seeds. Here, the computational cost refers to the required total rounds for a system to achieve the training goal, and the communication cost refers to the total communication distance for the model sharing in decentralized learning.
|
| 121 |
+
|
| 122 |
+
Computational Cost. As shown in Figure 3.a, due to limited local training data, the standalone learning appeared to be extremely slow after the validation accuracy reached 0.70. Finally, it terminated with a final accuracy of around 0.75 due to the early-stopping strategy. Moreover, by comparing the decentralized learning methods with and without the self-attention mechanism, the result suggests that our proposed method of HL can greatly reduce the total training rounds. In addition, though centralized learning shows the fastest convergence, it suffers from problems of data privacy.
|
| 123 |
+
|
| 124 |
+
Communication Cost. In decentralized learning, to train a model, each selected node trains the current ML task model on its local dataset and sends the trained model to another node, and the communication cost refers to the network traffic payload for sending the model. We studied the relative cost by introducing the communication distance between nodes, which is defined as the total communication distance for model sharing in HL, i.e., from the starter node to the last selected node.
|
| 125 |
+
|
| 126 |
+
We performed ten individual experiments for each method and used as final results the best cases of node selection over the last five episodes when decisions were almost made by the agent and a learned communication policy was prone to be stable. Figure 4.a illustrates the experiment results of the total training rounds and the communication cost. The bottom and top of the error bars represent the $2 5 _ { t h }$ and $7 5 _ { t h }$ percentiles respectively, the line inside the box shows the median value, and outliers are shown as open circles. Finally, the evaluation result shows that HL can greatly reduce the training rounds by $5 0 . 8 \%$ and the communication cost by $7 4 . 6 \%$ .
|
| 127 |
+
|
| 128 |
+

|
| 129 |
+
Figure 4: (a) Performance comparison between the random policy-based decentralized learning and HL. Each error bar illustrates 10 individual experiments’ results. (b) Computational performance comparison with various heterogeneity levels of training data.
|
| 130 |
+
|
| 131 |
+
# 4.2.3 COMPARISONS REGARDING VARIOUS HETEROGENEITY LEVELS
|
| 132 |
+
|
| 133 |
+
We further studied the performance of the proposed method with different heterogeneity levels $H =$ $\{ 0 . 2 4 , 0 . 5 6 , 0 . 9 0 \}$ $( p ( y = c ) = \{ 0 . 6 , 0 . 8 , 0 . 9 \} )$ . We evaluated the performance in the 10-node scenario training on MNIST. In addition, for the case of $H = 0 . 9 0$ , we applied a maximum training step of 80 instead due to a more challenging convergence of the ML task model using the highly skewed local training data. Figure 4.b illustrates a computational performance comparison between the proposed HL and the baseline decentralized learning with a classical random policy.
|
| 134 |
+
|
| 135 |
+
# 5 CONCLUSION
|
| 136 |
+
|
| 137 |
+
Decentralized deep learning (DDL) leveraging distributed data sources contributes to a better neural network model while safeguarding data privacy. Despite the broad applications of DDL models such as federated learning and swarming learning, the challenges regarding edge heterogeneity especially the data heterogeneity have greatly limited their scalability. In this research, we proposed a self-attention decentralized deep learning method of Homogeneous Learning (HL) that recursively updates a shared communication policy by observing the system’s state and the gained reward for taking an action based on the observation. We comprehensively evaluated the proposed method by comparing with three baseline models for two different image classification tasks in both a 10-node scenario and a 100-node scenario, applying as criteria the computational and communication cost. The evaluation result shows that HL can greatly reduce the cost when training on skewed decentralized data with various heterogeneity levels. In future, a decentralized model leveraging various communication policies at the same time to achieve diverse goals is considered for the further study of this research.
|
| 138 |
+
|
| 139 |
+
# REFERENCES
|
| 140 |
+
|
| 141 |
+
General data protection regulation. https://gdpr-info.eu. Accessed: 2021-09-22.
|
| 142 |
+
|
| 143 |
+
Di Cao, Shan Chang, Zhijian Lin, Guohua Liu, and Donghong Sun. Understanding distributed poisoning attack in federated learning. In 25th IEEE International Conference on Parallel and Distributed Systems, ICPADS 2019, Tianjin, China, December 4-6, 2019, pp. 233–239. IEEE, 2019. doi: 10.1109/ICPADS47876.2019.00042. URL https://doi.org/10.1109/ ICPADS47876.2019.00042.
|
| 144 |
+
|
| 145 |
+
Moming Duan, Duo Liu, Xianzhang Chen, Renping Liu, Yujuan Tan, and Liang Liang. Selfbalancing federated learning with global imbalanced data in mobile systems. IEEE Trans. Parallel Distributed Syst., 32(1):59–71, 2021. doi: 10.1109/TPDS.2020.3009406. URL https: //doi.org/10.1109/TPDS.2020.3009406.
|
| 146 |
+
|
| 147 |
+
Yujia Gao, Liang Liu, Binxuan Hu, Tianzi Lei, and Huadong Ma. Federated region-learning for environment sensing in edge computing system. IEEE Transactions on Network Science and Engineering, 7(4):2192–2204, 2020. doi: 10.1109/TNSE.2020.3016035.
|
| 148 |
+
|
| 149 |
+
Chaoyang He, Murali Annavaram, and Salman Avestimehr. Group knowledge transfer: Federated learning of large cnns at the edge. 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/a1d4c20b182ad7137ab3606f0e3fc8a4-Abstract.html.
|
| 150 |
+
|
| 151 |
+
Eunjeong Jeong, Seungeun Oh, Hyesung Kim, Jihong Park, Mehdi Bennis, and Seong-Lyun Kim. Communication-efficient on-device machine learning: Federated distillation and augmentation under non-iid private data. CoRR, abs/1811.11479, 2018. URL http://arxiv.org/abs/ 1811.11479.
|
| 152 |
+
|
| 153 |
+
Jakub Konecnˇ y, H. Brendan McMahan, Felix X. Yu, Peter Richtarik, Ananda Theertha Suresh, and ´ Dave Bacon. Federated learning: Strategies for improving communication efficiency. In NIPS Workshop on Private Multi-Party Machine Learning, 2016.
|
| 154 |
+
|
| 155 |
+
Yann LeCun, Corinna Cortes, and CJ Burges. Mnist handwritten digit database. ATT Labs [Online]. Available: http://yann.lecun.com/exdb/mnist, 2, 2010.
|
| 156 |
+
|
| 157 |
+
Yuzheng Li, Chuan Chen, Nan Liu, Huawei Huang, Zibin Zheng, and Qiang Yan. A blockchainbased decentralized federated learning framework with committee consensus. IEEE Netw., 35(1): 234–241, 2021. doi: 10.1109/MNET.011.2000263. URL https://doi.org/10.1109/ MNET.011.2000263.
|
| 158 |
+
|
| 159 |
+
Boyi Liu, Lujia Wang, Ming Liu, and Chengzhong Xu. Lifelong federated reinforcement learning: A learning architecture for navigation in cloud robotic systems. CoRR, abs/1901.06455, 2019. URL http://arxiv.org/abs/1901.06455.
|
| 160 |
+
|
| 161 |
+
Yang Liu, Anbu Huang, Yun Luo, He Huang, Youzhi Liu, Yuanyuan Chen, Lican Feng, Tianjian Chen, Han Yu, and Qiang Yang. Fedvision: An online visual object detection platform powered by federated learning. Proceedings of the AAAI Conference on Artificial Intelligence, 34(08): 13172–13179, Apr. 2020. doi: 10.1609/aaai.v34i08.7021. URL https://ojs.aaai.org/ index.php/AAAI/article/view/7021.
|
| 162 |
+
|
| 163 |
+
Yunlong Lu, Xiaohong Huang, Yueyue Dai, Sabita Maharjan, and Yan Zhang. Blockchain and federated learning for privacy-preserved data sharing in industrial iot. IEEE Transactions on Industrial Informatics, 16(6):4177–4186, 2020. doi: 10.1109/TII.2019.2942190.
|
| 164 |
+
|
| 165 |
+
H. Brendan McMahan, Daniel Ramage, Kunal Talwar, and Li Zhang. Learning differentially private recurrent language models. 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 ${ . } = { }$ BJ0hF1Z0b.
|
| 166 |
+
|
| 167 |
+
Nishat I. Mowla, Nguyen H. Tran, Inshil Doh, and Kijoon Chae. Federated learning-based cognitive detection of jamming attack in flying ad-hoc network. IEEE Access, 8:4338–4350, 2020. doi: 10.1109/ACCESS.2019.2962873.
|
| 168 |
+
|
| 169 |
+
T. Nguyen, P. Rieger, Markus Miettinen, and A. Sadeghi. Poisoning attacks on federated learningbased iot intrusion detection system. 2020.
|
| 170 |
+
|
| 171 |
+
Mani Parimala, R. M. Swarna Priya, Quoc-Viet Pham, Kapal Dev, Praveen Kumar Reddy Maddikunta, Thippa Reddy Gadekallu, and Thien Huynh-The. Fusion of federated learning and industrial internet of things: A survey. ArXiv, abs/2101.00798, 2021.
|
| 172 |
+
|
| 173 |
+
Shiva Raj Pokhrel and Jinho Choi. Federated learning with blockchain for autonomous vehicles: Analysis and design challenges. IEEE Transactions on Communications, 68(8):4734–4746, 2020. doi: 10.1109/TCOMM.2020.2990686.
|
| 174 |
+
|
| 175 |
+
Sawsan Abdul Rahman, Hanine Tout, Chamseddine Talhi, and Azzam Mourad. Internet of things intrusion detection: Centralized, on-device, or federated learning? IEEE Network, 34(6):310– 317, 2020. doi: 10.1109/MNET.011.2000286.
|
| 176 |
+
|
| 177 |
+
Ozan Sener and Silvio Savarese. Active learning for convolutional neural networks: A core-set approach. 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 $=$ H1aIuk-RW.
|
| 178 |
+
|
| 179 |
+
Abhishek Singh, Praneeth Vepakomma, Otkrist Gupta, and Ramesh Raskar. Detailed comparison of communication efficiency of split learning and federated learning. CoRR, abs/1909.09145, 2019. URL http://arxiv.org/abs/1909.09145.
|
| 180 |
+
|
| 181 |
+
Yuwei Sun, Hiroshi Esaki, and Hideya Ochiai. Adaptive intrusion detection in the networking of large-scale lans with segmented federated learning. IEEE Open J. Commun. Soc., 2:102– 112, 2021. doi: 10.1109/OJCOMS.2020.3044323. URL https://doi.org/10.1109/ OJCOMS.2020.3044323.
|
| 182 |
+
|
| 183 |
+
Hao Wang, Zakhary Kaplan, Di Niu, and Baochun Li. Optimizing federated learning on non-iid data with reinforcement learning. In 39th IEEE Conference on Computer Communications, INFOCOM 2020, Toronto, ON, Canada, July 6-9, 2020, pp. 1698–1707. IEEE, 2020. doi: 10.1109/ INFOCOM41043.2020.9155494. URL https://doi.org/10.1109/INFOCOM41043. 2020.9155494.
|
| 184 |
+
|
| 185 |
+
Stefanie Warnat-Herresthal, Hartmut Schultze, Krishnaprasad Lingadahalli Shastry, Sathyanarayanan Manamohan, Saikat Mukherjee, Vishesh Garg, Ravi Sarveswara, Kristian Handler, ¨ Peter Pickkers, N. Ahmad Aziz, Sofia Ktena, Christian Siever, Michael Kraut, Milind Desai, Bruno Monnet, Maria Saridaki, Charles Martin Siegel, Anna Drews, Melanie Nuesch-Germano, Heidi Theis, Mihai G. Netea, Fabian Theis, Anna C. Aschenbrenner, Thomas Ulas, Monique M.B. Breteler, Evangelos J. Giamarellos-Bourboulis, Matthijs Kox, Matthias Becker, Sorin Cheran, Michael S. Woodacre, Eng Lim Goh, Joachim L. Schultze, and German COVID-19 OMICS Initiative (DeCOI). Swarm learning for decentralized and confidential clinical machine learning, 2021.
|
| 186 |
+
|
| 187 |
+
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.
|
| 188 |
+
|
| 189 |
+
Yue Zhao, Meng Li, Liangzhen Lai, Naveen Suda, Damon Civin, and Vikas Chandra. Federated learning with non-iid data. CoRR, abs/1806.00582, 2018. URL http://arxiv.org/abs/ 1806.00582.
|
| 190 |
+
|
| 191 |
+
# A APPENDIX
|
| 192 |
+
|
| 193 |
+
# A.1 COMMUNICATION DISTANCE MATRIX
|
| 194 |
+
|
| 195 |
+
Figure 5 illustrates the generated distance matrix $D _ { i \times j }$ in the 10-node scenario when applying a $\beta$ value of 0.1 and a random seed of 0.
|
| 196 |
+
|
| 197 |
+

|
| 198 |
+
Figure 5: The adopted distance matrix $D _ { i \times j }$ in the 10-node scenario.
|
| 199 |
+
|
| 200 |
+
# A.2 OPTIMIZATION OF MODEL DISTRIBUTION REPRESENTATION
|
| 201 |
+
|
| 202 |
+
Under the assumption of data heterogeneity, to allow a reinforcement learning (RL) agent to efficiently learn a communication policy by observing model states in the systems, a trade-off between the batch size and the epoch of local foundation model training was discussed. Figure 6 illustrates the trained models’ weights distribution in the 10-node scenario after applying the principal component analysis (PCA), with different batch sizes and epochs applied to train on the MNIST dataset. Moreover, it shows a 100-node scenario where each color represents nodes with the same main data class. As shown in the graphs, various combinations of these two parameters have different distribution representation capabilities. By comparing the distribution density and scale, we found that when adopting a batch size of 32 and an epoch of one the models distribution was best represented, which could facilitate the policy learning of an agent.
|
| 203 |
+
|
| 204 |
+

|
| 205 |
+
Figure 6: Optimization of model distribution representation in the 10-node scenario.
|
md/dev/E9dH0BP5VW/E9dH0BP5VW.md
ADDED
|
@@ -0,0 +1,298 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Scaling Laws vs Model Architectures: How Does Inductive Bias Influence Scaling?
|
| 2 |
+
|
| 3 |
+
Yi Tay∗ † Mostafa Dehghani∗ Samira Abnar† Hyung Won Chung† William Fedus† Jinfeng Rao† Sharan Narang† Vinh Q. Tran Dani Yogatama† Donald Metzler
|
| 4 |
+
|
| 5 |
+
Google
|
| 6 |
+
|
| 7 |
+
dehghani@google.com
|
| 8 |
+
|
| 9 |
+
# Abstract
|
| 10 |
+
|
| 11 |
+
There have been a lot of interest in the scaling properties of Transformer models (Kaplan et al., 2020). However, not much has been done on the front of investigating the effect of scaling properties of different inductive biases and model architectures. Do model architectures scale differently? If so, how does inductive bias affect scaling behaviour? How does this influence upstream (pretraining) and downstream (transfer)? This paper conducts a systematic study of scaling behaviour of ten diverse model architectures such as Transformers, Switch Transformers, Universal Transformers, Dynamic convolutions, Performers, and recently proposed MLP-Mixers. Via extensive experiments, we show that (1) architecture is an indeed an important consideration when performing scaling and (2) the best performing model can fluctuate at different scales. We believe that the findings outlined in this work has significant implications to how model architectures are currently evaluated in the community.
|
| 12 |
+
|
| 13 |
+
# 1 Introduction
|
| 14 |
+
|
| 15 |
+
There have been a lot recent interest in the scaling properties of Transformer models (Kaplan et al., 2020; Hernandez et al., 2021; Bahri et al., 2021; Henighan et al., 2020; Tay et al., 2021b; Abnar et al., 2021). However, not much is understood about the scaling properties of different inductive biases imposed by model architectures. Improvements at a a specific scale (compute, size etc) are often assumed to transfer to different scales and compute regions (So et al., 2019; Choromanski et al., 2020; Lan et al., 2019; Dehghani et al., 2018) and new research is often presented in a point-wise fashion with respect to scale. In short, it is not uncommon for new methods to be presented with data points at very specific or limited compute regions (e.g., base size). We believe that understanding the interaction between architecture and scaling laws is crucial as designing models that perform well at diverse scales will likely have significant impact.
|
| 16 |
+
|
| 17 |
+
This paper is an attempt to understand the effect of inductive bias (architecture) on scaling laws of language models. To this end, we pre-train and finetune over ten diverse model architectures across multiple compute region and scales (e.g., from 15M to 40 Billion parameters). In total, we pre-train and finetune over 100 different models of different architectures and sizes and present insights and challenges at scaling these ten diverse architectures.
|
| 18 |
+
|
| 19 |
+
We consider a broad spectrum of models in our extensive experiments. Concretely, we consider several well-established Transformer variants (Vaswani et al., 2017) such as Evolved Transformer (So et al., 2019), Universal Transformers (Dehghani et al., 2018) and Switch Transformers (Fedus et al., 2021). We also consider lightweight models such as ALBERT (Lan et al., 2019) and/or efficient Transformers (Tay et al., 2020) such as Performer (Choromanski et al., 2020) and Funnel Transformers (Dai et al., 2020). In our comparison, we are also interested in finding out if general improvements to the Transformer architectures such as Mixture-of-Softmax (Yang et al., 2017) and/or Gated Linear Units (Dauphin et al., 2017; Shazeer, 2020) influence the scaling behaviour of models. Finally, we also evaluate models outside the family of Transformers including Lightweight convolutions (Wu et al., 2019), Dynamic convolutions (Wu et al., 2019) and the recently proposed MLPMixers (Tolstikhin et al., 2021). Figure 1 illustrates an overview about the experiments we run.
|
| 20 |
+
|
| 21 |
+
We also note that scaling these models is not as straightforward as it seems, i.e., there are intricate details of scale that are intertwined with architectural choices which we study in detail in this paper. For example, a distinct feature of Universal Transformers (and ALBERT) is parameter sharing. Hence, compared with standard Transformers, this architectural choice significantly warps the scaling behaviour not only with respect to performance but also amongst compute metrics such as FLOPs, speed and number of parameters (Dehghani et al., 2021a). Conversely, models such as Switch Transformers are on the other end of the spectrum with an uncommon relationship between FLOPs and number of parameters, i.e., they have high parameter to FLOPs ratio. This difficulty makes navigating this landscape challenging.
|
| 22 |
+
|
| 23 |
+

|
| 24 |
+
Figure 1: An overview compute-performance (FLOPs vs performance) plot of all the diverse models and architectures we pretrained and finetuned in this study. Colors represent different model architectures and size of the circles represent the size of the model (parameters).
|
| 25 |
+
|
| 26 |
+
Our Contributions and Insights The key contributions of this paper are as follows:
|
| 27 |
+
|
| 28 |
+
• For the first time, we derive scaling laws for different inductive biases and model architectures. We find that this scaling coefficient differs greatly from model to model. We believe this is an important consideration in model development. It turns out that amongst all ten architectures that we consider, the vanilla Transformer has the best scaling behaviour, even if its absolute performance at each compute region is not the greatest.
|
| 29 |
+
|
| 30 |
+
• We observe that models that operate well in one compute-scale region is not necessarily the best in another compute-region. Moreover, we find that certain models have difficulty scaling despite performing decently (comparably) at lowercompute regions. This has implications, since it is difficult to get the fulll picture of a model’s scalability with pointwise comparisons at a certain compute-region.
|
| 31 |
+
|
| 32 |
+
• We find that when it comes to scaling different model architectures, upstream pre-training perplexity might not correlate well with downstream transfer. Hence, the underlying architecture and inductive bias is also crucial for downstream transfer.
|
| 33 |
+
|
| 34 |
+
• We highlight the difficulties of scaling with certain architectures and show that some models do not scale (or scale with a negative trend). We also find concerning trends where linear-time attention models such as Performer struggle with scaling up.
|
| 35 |
+
|
| 36 |
+
# 2 Related Work
|
| 37 |
+
|
| 38 |
+
Kaplan et al. (2020) studied empirical scaling laws of the decoder-only Transformer language models. They focused on the standard left-to-right language modeling objective with the cross-entropy loss as the performance metric. One of the main findings is that the loss scales as a power-law with three major characteristics of the model training: model size, dataset size and the training compute. Another somewhat surprising finding is that the model shapes such as width or depth of the Transformer network have minimal effects on the crossentropy loss for a wide range of scales. Subsequent works (Henighan et al., 2020; Hernandez et al.,
|
| 39 |
+
|
| 40 |
+
2021) made similar conclusions for autoregressive generative modeling and for transfer learning, respectively. This finding is also generally supported by (Tay et al., 2021b) but discrepancies were found for the gap between pretraining and finetuning - highlighting the fact that observing downstream performance of large language model is indeed important. In (Tay et al., 2021b), the effect of depth was unusually pronounced for downstream performance.
|
| 41 |
+
|
| 42 |
+
Raffel et al. (2019) studied the effect of pretraining objectives, model structures (e.g., encoderdecoder, decoder-only), pre-training dataset size and training strategy on the transfer learning. They showed that the downstream performance monotonically increases with the model scale (from 60M to 11B parameters). While they studied several model structures, the Transformer implementation is mostly the same as the original Transformer by Vaswani et al. (2017). Conneau et al. (2020); Goyal et al. (2021) scaled-up multilingual encoderonly architectures up to 11B parameters while maintaining the original Transformer implementation. They found that scaling the model improves its cross-lingual ability. Fedus et al. (2021) scaled a sparse model based on Mixture of Experts (MoE) models up to trillion parameters.
|
| 43 |
+
|
| 44 |
+
While previous studies have repeatedly shown the benefits of scale for language understanding tasks for both dense and sparse Transformers and cross-lingual abilities, all of these used the same Transformer implementation within each studies. With a plethora of improved Transformer architectures proposed in the literature, it is timely to investigate which of these improved architecture has the best scaling properties. The main goal of this paper is to systematically study how inductive biases imposed by these Transformer variants affect the scaling behavior in a shared software and hardware settings. This is in similar spirit to (Narang et al., 2021) that studies the impact of architectures on performance. Our analysis extends that of (Narang et al., 2021) to the model scale axis.
|
| 45 |
+
|
| 46 |
+
We note that increasingly the number of tokens seen during pretraining has been incorporated in the study of scaling laws (Hoffmann et al., 2022; Muennighoff et al., 2023). Hoffmann et al. (2022) trains decoder-only Transformer language models with casual langauge modeling and evaluates on zero and few-shot tasks. In this work we consider architectures modifications that do not necessarily support causal masking and autoregressive decoding. Due to this, we consider encoder-decoder configurations trained with span corruption, and evaluate on downstream finetuned tasks. This creates a more level playing field for architectures that do not support in-context learning. As such we follow (Raffel et al., 2019) to fix the number of pretraining tokens (i.e. sequence length, training steps, batch size) seen by each model. Given the large space of model architectures and scales we aim to study, this also fixes the data size dimension, making our empirical study more tractable. Since we finetune models until convergence, we anticipate the effect of pretraining token amount to be less pronounced than studied in (Hoffmann et al., 2022).
|
| 47 |
+
|
| 48 |
+
# 3 Methods
|
| 49 |
+
|
| 50 |
+
This section outlines our experimental setup.
|
| 51 |
+
|
| 52 |
+
# 3.1 Models
|
| 53 |
+
|
| 54 |
+
This section describes the models we evaluate in our experiments. Our models are largely implemented in a sequence to sequence framework (Sutskever et al., 2014) following the convention of T5 (Raffel et al., 2019). Encoder-decoder models are a natural choice for this experimentation because they can universally express both encoding and decoding tasks.
|
| 55 |
+
|
| 56 |
+
Transformer Variants We consider several standard Transformer variants.
|
| 57 |
+
|
| 58 |
+
• Transformers (Vaswani et al., 2017) - The basic vanilla Transformer architecture. Our basic setup considers the T5-style of Transformers (Raffel et al., 2019), which largely follows the vanilla Transformer except that it uses relative attention instead of sinusoidal position embeddings and pre-layer normalization, i.e. layer normalization is applied before each sublayer.
|
| 59 |
+
|
| 60 |
+
• Evolved Transformers (So et al., 2019) - A transformer architecture learned via AutoML. The architecture comprises of convolutions and attention. We scale Evolved Transformers following the same pattern as vanilla Transformers.
|
| 61 |
+
|
| 62 |
+
• Universal Transformers (UT) (Dehghani et al., 2018) - A Transformer architecture with shared parameters and recurrent-like computation for transform layers. Scaling UTs are challenging because of parameter sharing. While we are able to also increase $d _ { F F }$ or $d _ { m o d e l }$ , the increase in parameters is of magnitude $N _ { l a y e r s }$ than standard Transformers. Another axis of exploration is to scale $r$ the number of repeated computation at each UT layer - this increases computation (number of FLOPs) but does not increase the parameter size of the model.
|
| 63 |
+
|
| 64 |
+
• Switch Transformer (Fedus et al., 2021) - a sparsely activated mixture-of-experts architecture. The Sparse Transformer is another model with an unusual relationship between number of parameters and compute. When we scale this model uniformly, the number of parameters easily reaches the ballpark of 40B.
|
| 65 |
+
|
| 66 |
+
Efficient Transformer Variants These class of models are mainly concerned at reducing computational costs, memory usage, or parameter count of models.
|
| 67 |
+
|
| 68 |
+
• Performer (Choromanski et al., 2020) - A linear time attention model using generalizable kernel attention. For simplicity, we adopt the relu kernel variant for our experiments. We scale Performer in the similar fashion (i.e., uniform scaling) as vanilla Transformers.
|
| 69 |
+
|
| 70 |
+
• Funnel Transformer (FT) (Dai et al., 2020) A Transformer architecture that downsamples the input sequence across the layer stack. Our implementation uses FT only in the encoder and reverts to vanilla Transformer in the decoder following Narang et al. (2021).
|
| 71 |
+
|
| 72 |
+
• ALBERT (Lan et al., 2019) - A lightweight transformer architecture that shares parameters across all layers and factorizes the embedding and output softmax layers. For our seq2seq ALBERT, we also share the weights of encoder and decoder.
|
| 73 |
+
|
| 74 |
+
General Improvements We consider general improvements that are not necessarily tied to Transformers. We select candidates that have shown to do well in Narang et al. (2021).
|
| 75 |
+
|
| 76 |
+
• Mixture of Softmaxes (Yang et al., 2017) - A transformer architecture adopting the MoS method at the Softmax layer.
|
| 77 |
+
|
| 78 |
+
• Gated Linear Units with GeLU (GLUTransformer) - Replacing position-wise feedforward-networks in Transformers with Gated Linear Units (Dauphin et al., 2017).
|
| 79 |
+
|
| 80 |
+
Non-Transformer Architectures We are interested in the scaling behaviour of non-Transformer based architectures such as convolutions and/or mixer architectures.
|
| 81 |
+
|
| 82 |
+
• Lightweight Convolutions (Wu et al., 2019) - Lightweight depthwise convolutions that have shown promise over Transformer architectures.
|
| 83 |
+
|
| 84 |
+
• Dynamic Convolutions (Wu et al., 2019) - An extension of the Lightweight Convolution to create time-dependent kernels.
|
| 85 |
+
|
| 86 |
+
• MLP-Mixers (Tolstikhin et al., 2021) - Mixers are recently proposed architectures that learn a lightweight mixing of tokens. Since Mixers have not been used in autoregressive decoding, we only use token-mixers on the input encoder.
|
| 87 |
+
|
| 88 |
+
# 4 Experiment Setup
|
| 89 |
+
|
| 90 |
+
Our setup, along with all models, are implemented in Mesh TensorFlow (Shazeer et al., 2018), a library with similar interface to TensorFlow but enables distributed model parallelism across multiple workers. For fair comparison, all models are pretrained for $2 ^ { 1 9 }$ steps on the english C4 corpus optimized using an inverse square root learning rate with Adafactor (Shazeer and Stern, 2018). All models use the same SentencePiece tokenizer (Kudo and Richardson, 2018) containing $3 2 K$ subwords. This closely follows the setup in the T5 paper (Raffel et al., 2019). Finetuning is performed for $1 0 0 K$ steps on a mixture of GLUE (Wang et al., 2018), SuperGLUE (Wang et al., 2019) and SQuAD (Rajpurkar et al., 2016). We evaluate on both upstream (pre-training) validation perplexity as well as downstream transfer for NLU tasks (GLUE $^ +$ Super$\mathrm { G L U E } + \mathrm { S Q u A D } )$ after fine-tuning. We pretrain and finetune our models with 16 TPU-v3 chips with data parallelism. All large models have a model parallelism of 2 and XL models have a model parallelism of 8.
|
| 91 |
+
|
| 92 |
+
Model Sizes We consider several different model sizes for each architecture. For models that are straightforward to scale, we simply follow the standard convention in Raffel et al. (2019), moving from small to base, to large and XL. We include a tiny version of each model to observe how different models behave at lower compute regions. For models where it was not straightforward to scale (e.g., Universal Transformers, ALBERT), we tried to scale them in a similar fashion but faced obvious limitations such as getting ALBERT to have the same number of parameters as $\mathrm { T } 5 \mathrm { X L }$ without incurring a huge number of cost in terms of FLOPs. For convolutional models, we consider $d _ { \mathrm { m o d e l } }$ to be the hidden size (i.e., channel depth) for the onedimensional convolution layers. Values such as $d _ { \mathrm { k v } } , N _ { H }$ then become redundant. Details on scaling details1 of each architecture can be found in the supplementary material.
|
| 93 |
+
|
| 94 |
+

|
| 95 |
+
Figure 2: Upstream Negative Log-Perplexity of vanilla Transformer compared to other models.
|
| 96 |
+
|
| 97 |
+
# 5 Main Results
|
| 98 |
+
|
| 99 |
+
We report the main results of this paper in Table 1. We report the number of trainable parameters, FLOPs (of a single forward pass) and speed (steps per second). We also report on validation perplexity (on upstream pre-training) and results on 17 downstream tasks. The results are reported aggregates of GLUE, SuperGLUE and SQuAD. While we use the same Mesh TensorFlow-based codebase used by Raffel et al. (2019) and hence expect our experimental results to match theirs, we verify that our T5 base does achieve similar results to what is reported in Raffel et al. (2019).
|
| 100 |
+
|
| 101 |
+
# 5.1 Do all models scale the same way?
|
| 102 |
+
|
| 103 |
+
We compare on both upstream perplexity and downstream finetuning performance here.
|
| 104 |
+
|
| 105 |
+
Upstream Perplexity Figure 2 reports the scaling behaviour of all models as we increase the number of FLOPs. We observe that the scaling behaviour of all models are quite unique and distinct, i.e., most of them are quite different from standard Transformers. Perhaps the biggest finding here is that most models (e.g., LConv, Evolved) all seem to be on-par or better than standard Transformers but fail to scale with a higher compute budget. Another interesting trend is that “linear" Transformers such as Performer fail to scale as shown in Figure 2i.
|
| 106 |
+
|
| 107 |
+

|
| 108 |
+
Figure 3: Downstream accuracy of vanilla Transformer compared to other models.
|
| 109 |
+
|
| 110 |
+
The pre-training perplexity metric only decreases by $2 . 7 \%$ going from base to large scale compared to $8 . 4 \%$ of the vanilla Transformer.
|
| 111 |
+
|
| 112 |
+
Downstream Transfer Figure 3 reports the scaling curves of all models on downstream transfer. The overall finding that most models have distinct scaling curves compared to Transformers is also evident in downstream tasks. It is also noteworthy that most models have a different upstream and downstream scaling curve. We find that some models such as Funnel Transformer and LConvs that seem to hold out pretty well on upstream but suffer substantially on downstream. As for Performer, the performance (disparity) seems to be even greater in downstream as compared to upstream. Notably, the SuperGLUE downstream tasks generally require pseudo cross-attention on the encoder, which models such as convolutions are not equipped to handle (Tay et al., 2021a). To this end, we find that certain models may have difficulty learning the downstream tasks despite good upstream performance.
|
| 113 |
+
|
| 114 |
+
# 5.2 Are the best models at each scale different?
|
| 115 |
+
|
| 116 |
+
Figure 1 shows the Pareto-frontier when plotting compute against upstream and downstream performance. Since the colors of the plot represent different models, we can observe that the best model for every scale and compute region might be different. Moreover, from Figure 3, we can also observe this. For example, the Evolved Transformer seems to do well against the standard Transformer at tiny to small region (downstream) but this quickly changes when scaling the model up. We also observe this with MoS-Transformer where it clearly outperforms vanilla Transformers at some regions but not at others.
|
| 117 |
+
|
| 118 |
+
# 5.3 Scaling Law for Each Model
|
| 119 |
+
|
| 120 |
+
Table 2 presents the slope of the fitted linear line $\alpha$ for each model across multiple scenarios. We derive $\alpha$ by plotting $F$ (FLOPs), $U$ (upstream perplexity), $D$ (downstream accuracy), $P$ (number of parameters). In general, most values of $\alpha$ depict how well a model scales. For example $\alpha _ { F , U }$ is plotting FLOPs against Upstream performance. The only exception is $\alpha _ { U , D }$ which is a measure of upstream vs downstream performance. A high $\alpha _ { U , D }$ value means that the transfer to the downstream tasks is better as a model scales. Overall, the $\alpha$ value is a metric that represents how well a model performs relatively across all scales
|
| 121 |
+
|
| 122 |
+
Table 1: Results on pre-training and finetuning ten different model architectures. Full results (further varying hyperparameters of these models) can be found in the Appendix.
|
| 123 |
+
|
| 124 |
+
<table><tr><td>Model</td><td>#Params</td><td>FLOPs</td><td>Speed</td><td>Neg Log Ppl</td><td>GLUE</td><td>SGLUE</td><td>SQuAD</td></tr><tr><td>Transformer Tiny</td><td>16M</td><td>1.21</td><td>38.4</td><td>-2.47</td><td>69.3</td><td>56.9</td><td>73.6</td></tr><tr><td>Transformer Small</td><td>60M</td><td>3.70</td><td>22.7</td><td>-2.02</td><td>78.1</td><td>65.3</td><td>81.9</td></tr><tr><td>Transformer Base</td><td>223M</td><td>11.4</td><td>9.3</td><td>-1.75</td><td>83.8</td><td>74.0</td><td>86.3</td></tr><tr><td>Transformer Large</td><td>738M</td><td>34.3</td><td>3.6</td><td>-1.61</td><td>86.4</td><td>78.3</td><td>88.6</td></tr><tr><td>Transformer XL</td><td>2.9B</td><td>63.8</td><td>1.3</td><td>-1.49</td><td>87.8</td><td>81.5</td><td>89.5</td></tr><tr><td>Evolved Transformer Tiny</td><td>19M</td><td>1.31</td><td>39.7</td><td>-2.45</td><td>69.6</td><td>57.1</td><td>69.6</td></tr><tr><td>Evolved Transformer Small</td><td>79M</td><td>4.23</td><td>23.7</td><td>-2.04</td><td>75.7</td><td>66.2</td><td>80.2</td></tr><tr><td>Evolved Transformer Base</td><td>218M</td><td>10.2</td><td>8.9</td><td>-1.79</td><td>83.0</td><td>70.5</td><td>84.8</td></tr><tr><td>Evolved Transformer Large</td><td>1.0B</td><td>49.3</td><td>2.1</td><td>-1.62</td><td>86.2</td><td>77.1</td><td>88.0</td></tr><tr><td>Evolved Transformer XL</td><td>2.2B</td><td>71.3</td><td>0.8</td><td>-1.55</td><td>87.0</td><td>78.3</td><td>88.2</td></tr><tr><td>Universal Transformer Tiny</td><td>11M</td><td>1.77</td><td>38.1</td><td>-2.73</td><td>69.8</td><td>56.1</td><td>62.3</td></tr><tr><td>Universal Transformer Small</td><td>52M</td><td>7.30</td><td>18.3</td><td>-2.12</td><td>76.8</td><td>64.2</td><td>75.4</td></tr><tr><td>Universal Transformer Base</td><td>127M</td><td>20.3</td><td>8.4</td><td>-1.91</td><td>80.0</td><td>67.9</td><td>80.1</td></tr><tr><td>Universal Transformer Large</td><td>283M</td><td>27.6</td><td>1.6</td><td>-1.67</td><td>84.0</td><td>73.4</td><td>85.4</td></tr><tr><td>Switch Transformer Tiny</td><td>174M</td><td>3.25</td><td>29.7</td><td>-2.01</td><td>78.2</td><td>63.8</td><td>80.7</td></tr><tr><td>Switch Transformer Small</td><td>460M</td><td>4.63</td><td>22.3</td><td>-1.85</td><td>80.3</td><td>68.0</td><td>82.9</td></tr><tr><td>Switch Transformer Base</td><td>2.0B</td><td>12.7</td><td>8.4</td><td>-1.66</td><td>84.2</td><td>74.1</td><td>86.5</td></tr><tr><td> Switch Transformer Large</td><td>3.9B</td><td>23.0</td><td>4.1</td><td>-1.56</td><td>84.6</td><td>75.8</td><td>87.9</td></tr><tr><td>Switch Transformer XL</td><td>29.6B</td><td>43.3</td><td>0.8</td><td>-1.62</td><td>84.0</td><td>75.2</td><td>87.5</td></tr><tr><td>Performer Tiny</td><td>16M</td><td>1.14</td><td>42.0</td><td>-2.88</td><td>50.5</td><td>48.8</td><td>15.0</td></tr><tr><td>Performer Small</td><td>61M</td><td>3.50</td><td>39.0</td><td>-2.44</td><td>57.8</td><td>51.1</td><td>31.1</td></tr><tr><td>Performer Base</td><td>224M</td><td>10.8</td><td>11.7</td><td>-2.23</td><td>61.4</td><td>53.4</td><td>37.8</td></tr><tr><td>Performer Large</td><td>739M</td><td>32.8</td><td>4.4</td><td>-2.16</td><td>62.4</td><td>52.4</td><td>30.8</td></tr><tr><td>Funnel Transformer Tiny</td><td>16M</td><td>1.10</td><td>39.9</td><td>-2.58</td><td>63.4</td><td>49.4</td><td>54.6</td></tr><tr><td>Funnel Transformer Small</td><td>61M</td><td>2.96</td><td>32.7</td><td>-2.11</td><td>70.0</td><td>58.5</td><td>75.1</td></tr><tr><td>Funnel Transformer Base</td><td>223M</td><td>8.10</td><td>11.9</td><td>-1.83</td><td>76.3</td><td>62.9</td><td>81.6</td></tr><tr><td>Funnel Transformer Large</td><td>739M</td><td>22.6</td><td>5.0</td><td>-1.69</td><td>79.8</td><td>67.1</td><td>83.8</td></tr><tr><td>Funnel Transformer XL</td><td>2.9B</td><td>40.3</td><td>1.89</td><td>-1.61</td><td>79.8</td><td>68.0</td><td>83.7</td></tr><tr><td>ALBERT Small</td><td>15M</td><td>3.57</td><td>42.0</td><td>-2.36</td><td>73.7</td><td>62.0</td><td>77.1</td></tr><tr><td>ALBERTBase</td><td>21M</td><td>9.40</td><td>16.4</td><td>-2.28</td><td>69.0</td><td>57.2</td><td>64.3</td></tr><tr><td>ALBERT Large</td><td>34M</td><td>31.6</td><td>5.1</td><td>-2.20</td><td>62.9</td><td>54.1</td><td>27.3</td></tr><tr><td>MoS-Transformer Tiny</td><td>27M</td><td>1.29</td><td>39.7</td><td>-2.37</td><td>70.6</td><td>57.9</td><td>74.1</td></tr><tr><td>MoS-Transformer Small</td><td>81M</td><td>3.70</td><td>26.3</td><td>-1.98</td><td>79.7</td><td>67.1</td><td>83.1</td></tr><tr><td>MoS-Transformer Base</td><td>257M</td><td>11.4</td><td>8.6</td><td>-1.70</td><td>84.5</td><td>73.9</td><td>86.8</td></tr><tr><td>MoS-Transformer Large</td><td>800M</td><td>35.0</td><td>3.4</td><td>-1.56</td><td>86.5</td><td>79.7</td><td>89.1</td></tr><tr><td>MoS-Transformer XL</td><td>2.9B</td><td>112</td><td>1.2</td><td>-1.45</td><td>88.2</td><td>81.4</td><td>90.0</td></tr><tr><td>GLU-Transformer Tiny</td><td>26M</td><td>1.29</td><td>31.7</td><td>-2.35</td><td>70.5</td><td>57.0</td><td>74.2</td></tr><tr><td>GLU-Transformer Small</td><td>77M</td><td>3.70</td><td>26.4</td><td>-1.97</td><td>79.1</td><td>67.4</td><td>83.0</td></tr><tr><td>GLU-Transformer Base</td><td>248M</td><td>11.4</td><td>8.6</td><td>-1.71</td><td>84.6</td><td>74.5</td><td>87.2</td></tr><tr><td>GLU-Transformer Large</td><td>748M</td><td>35.0</td><td>3.4</td><td>-1.56</td><td>84.2</td><td>74.3</td><td>86.2</td></tr><tr><td>GLU-Transformer XL</td><td>2.85B</td><td>61.3</td><td>1.0</td><td>-1.49</td><td>87.6</td><td>82.9</td><td>89.4</td></tr><tr><td>LConv Tiny</td><td>17M 67M</td><td>1.20</td><td>31.2</td><td>-2.50</td><td>51.1</td><td>51.3</td><td>49.5</td></tr><tr><td>LConv Small LConv Base</td><td>210M</td><td>3.80</td><td>12.8</td><td>-2.10</td><td>71.8</td><td>59.9</td><td>64.7</td></tr><tr><td>LConv Large</td><td>741M</td><td>10.6</td><td>12.8</td><td>-1.95</td><td>73.8</td><td>63.6</td><td>70.3</td></tr><tr><td>LConv XL</td><td></td><td>41.0</td><td>3.0</td><td>-1.76</td><td>76.8</td><td>65.6</td><td>76.3</td></tr><tr><td></td><td>2.3B</td><td>77.0</td><td>1.0</td><td>-1.75</td><td>73.3</td><td>64.1</td><td>72.9</td></tr><tr><td>DConv Tiny</td><td>22M</td><td>1.39</td><td>27.3</td><td>-2.46</td><td>51.1</td><td>48.9</td><td>30.2</td></tr><tr><td>DConv Small</td><td>96M</td><td>4.97</td><td>19.8</td><td>-2.08</td><td>68.6</td><td>57.4</td><td>64.3</td></tr><tr><td>DConv Base DConv Large</td><td>324M 1.2B</td><td>15.3 78.0</td><td>7.6 1.1</td><td>-1.90 -1.82</td><td>72.9 70.8</td><td>60.1 58.5</td><td>63.7 58.2</td></tr></table>
|
| 125 |
+
|
| 126 |
+
Table 2: Slope of a fitted linear line for each model, when we compare FLOPs vs. upstream performance $( F , U )$ , FLOPs vs. downstream performance $( F , D )$ , parameter size vs. upstream performance $( F , U )$ , parameter size vs. downstream performance $( P , D )$ , and finally upstream vs. downstream performance $( U , D )$ .
|
| 127 |
+
|
| 128 |
+
<table><tr><td>Model</td><td>QF,U</td><td>QF,D</td><td>αP,U</td><td>αP,D</td><td>αU,D</td></tr><tr><td>Transformer</td><td>0.54</td><td>0.28</td><td>0.47</td><td>0.24</td><td>0.49</td></tr><tr><td>GLU-Trans.</td><td>0.49</td><td>0.24</td><td>0.42</td><td>0.22</td><td>0.46</td></tr><tr><td>LConv</td><td>0.32</td><td>0.13</td><td>0.29</td><td>0.11</td><td>0.48</td></tr><tr><td>Funnel</td><td>0.47</td><td>0.22</td><td>0.38</td><td>0.18</td><td>0.46</td></tr><tr><td>Switch</td><td>0.23</td><td>0.14</td><td>0.13</td><td>0.08</td><td>0.58</td></tr><tr><td>Universal</td><td>0.50</td><td>0.20</td><td>0.56</td><td>0.22</td><td>0.35</td></tr><tr><td>ALBERT</td><td>0.08</td><td>-0.12</td><td>0.13</td><td>-0.21</td><td>-1.67</td></tr><tr><td>Evolved</td><td>0.44</td><td>0.22</td><td>0.42</td><td>0.21</td><td>0.47</td></tr><tr><td>Performer</td><td>0.25</td><td>0.05</td><td>0.24</td><td>0.05</td><td>0.24</td></tr><tr><td>MoS-Trans.</td><td>0.43</td><td>0.21</td><td>0.43</td><td>0.20</td><td>0.47</td></tr><tr><td>MLP-Mixer</td><td>0.32</td><td>-0.03</td><td>0.26</td><td>0.65</td><td>-0.02</td></tr></table>
|
| 129 |
+
|
| 130 |
+
Analysis of Slope for each Model In general, we find that the vanilla Transformer has the highest values of $\alpha$ . Models such as Evolved Transformer, GLU-Transformer, MoS-Transformer and Funnel Transformer tend to have similar scaling properties to the vanilla Transformer. The GLU-Transformer has similar and slightly worse scaling properties to the vanilla Transformer, even if it was observed to do better in absolute sense on some computeregions. On the other hand, we also observe that there are models which are difficult to scale such as LConv, UT, MLP-Mixer and Performer. This is even more evident on downstream task. We also note that ALBERT scales (trends) negatively2 (gets worse) as we scale the model up. On the other hand, the metric $\alpha _ { U , D }$ measures how the downstream performance scales with upstream performance. Overall, the Switch Transformer does the best on this metric where downstream performance scales well with upstream performance. Generally, models that make less changes to the main Transformer architecture (GLU-Transformer, MoS-Transformer) tend to retain similar scaling behaviours and changing the inductive bias also significantly alters the scaling property of the model.
|
| 131 |
+
|
| 132 |
+

|
| 133 |
+
Figure 4: Scaling depth
|
| 134 |
+
|
| 135 |
+

|
| 136 |
+
Figure 5: Scaling width of FFN
|
| 137 |
+
|
| 138 |
+
# 5.4 Do Scaling Protocols influence model architectures in the same way?
|
| 139 |
+
|
| 140 |
+
We are interested in how different scaling protocols influence the model architectures. Figure 4 shows the effect of scaling depth of four model architectures (MoS-Transformer, Transformer, Evolved Transformer and LConv). Figure 5 shows the effect of scaling width on the same four architectures. Firstly, on upstream (negative log perplexity) curves, we note that while different architectures have a distinct difference in absolute performance, the scaling trend remains quite similar. On downstream, depth scaling (Figure 4) seems to act equally on most architectures with the exception of LConv. Meanwhile, for width scaling, it seems that Evolved Transformers scale slightly better when applying width-scaling. It is also interesting to note that depth-scaling has a much more substantial impact on downstream scaling as opposed to width-scaling.
|
| 141 |
+
|
| 142 |
+
# 6 Epilogue and Conclusion
|
| 143 |
+
|
| 144 |
+
In this paper, we conducted extensive experiments, pretraining and finetuning of up to 100 models ranging from 10 well-established Transformer and non-Transformer architectures. We showed that different model architectures can have different scaling behaviours and models performing well in one compute region (or model size) may not do identically well in another compute region. We also showed that model architectures may do well on upstream perplexity but fail to transfer to downstream tasks. Hence, practitioners should be cautious about developing architectures that not only scale well with respect to the upstream perplexity, but also based on downstream performance. While we certainly do not expect researchers to always report model performance across all scales (especially large-scale), we believe that it is good to keep in mind that architectures can perform quite differently at different compute regions. Hence, this might be a good dimension to consider when designing new inductive biases. As such, performing evaluation at a certain compute region may be insufficient to capture the full picture. It is also good to consider if different inductive biases will result in different extents of emergent capabilities (Wei et al., 2022a; Abnar et al., 2020).
|
| 145 |
+
|
| 146 |
+
We also showed that different model architectures may react differently to different scaling protocols, reaffirming that comparing and benchmarking these models can be very challenging (Dehghani et al., 2021b). When it comes to scaling large models, we show that novel inductive biases can be indeed quite risky which might explain why most state-of-the-art large language models (Rae et al., 2021; Chowdhery et al., 2022; Tay et al., 2022) are based on relatively vanilla architectures. Our advice is to be cautious when staking an expensive run on an architecture that drastically modifies the attention mechanism. Finally, we acknowledge that not every practitioner or researcher would require models that are able to scale to billions of parameters. In that case, inductive biases that are tailored to small or low compute will be sufficient.
|
| 147 |
+
|
| 148 |
+
huge number of models considered in this work, while we scaled each model to the best of our ability and present details on how they were scaled, there could always be unexplored hyperparameter settings and other tricks that could get a model to "work" at larger scales. Beyond this work, one could also study the differences in prompting techniques, e.g. chain-of-thought prompting (Wei et al., 2022b), between different architecture and scales. Such findings would be of importance for the research community in the future. Although in either case here, we believe that our findings, i.e. models scale differently and need to be tested, will continue to be relevant. This space will only continue to grow, and future researchers and practitioners must continue to assess the scalability of new models under new use cases.
|
| 149 |
+
|
| 150 |
+
# References
|
| 151 |
+
|
| 152 |
+
Samira Abnar, Mostafa Dehghani, Behnam Neyshabur, and Hanie Sedghi. 2021. Exploring the limits of large scale pre-training. arXiv preprint arXiv:2110.02095.
|
| 153 |
+
|
| 154 |
+
Samira Abnar, Mostafa Dehghani, and Willem Zuidema. 2020. Transferring inductive biases through knowledge distillation. arXiv preprint arXiv:2006.00555.
|
| 155 |
+
|
| 156 |
+
Yasaman Bahri, Ethan Dyer, Jared Kaplan, Jaehoon Lee, and Utkarsh Sharma. 2021. Explaining neural scaling laws. arXiv preprint arXiv:2102.06701.
|
| 157 |
+
|
| 158 |
+
Krzysztof Choromanski, Valerii Likhosherstov, David Dohan, Xingyou Song, Andreea Gane, Tamas Sarlos, Peter Hawkins, Jared Davis, Afroz Mohiuddin, Lukasz Kaiser, et al. 2020. Rethinking attention with performers. arXiv preprint arXiv:2009.14794.
|
| 159 |
+
|
| 160 |
+
Aakanksha Chowdhery, Sharan Narang, Jacob Devlin, Maarten Bosma, Gaurav Mishra, Adam Roberts, Paul Barham, Hyung Won Chung, Charles Sutton, Sebastian Gehrmann, et al. 2022. Palm: Scaling language modeling with pathways. arXiv preprint arXiv:2204.02311.
|
| 161 |
+
|
| 162 |
+
# 7 Limitations
|
| 163 |
+
|
| 164 |
+
As with all empirical studies, ours come with its own set of limitations. We only present a sampling of Transformer variants, and it is not exhaustive. Our selection is aimed towards sampling a diversity of architecture approaches to have representation across the entire space of Transformer architectures. As such, we do not claim that our findings hold within a subcategory; for example efficient Transformer variants, which there are many recent works not covered here. Additionally, given the
|
| 165 |
+
|
| 166 |
+
Alexis Conneau, Kartikay Khandelwal, Naman Goyal, Vishrav Chaudhary, Guillaume Wenzek, Francisco Guzmán, Edouard Grave, Myle Ott, Luke Zettlemoyer, and Veselin Stoyanov. 2020. Unsupervised cross-lingual representation learning at scale. In Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics, pages 8440– 8451, Online. Association for Computational Linguistics.
|
| 167 |
+
|
| 168 |
+
Zihang Dai, Guokun Lai, Yiming Yang, and Quoc V Le. 2020. Funnel-transformer: Filtering out sequential redundancy for efficient language processing. arXiv preprint arXiv:2006.03236.
|
| 169 |
+
|
| 170 |
+
Yann N. Dauphin, Angela Fan, Michael Auli, and David Grangier. 2017. Language modeling with gated convolutional networks. In Proceedings of the 34th International Conference on Machine Learning, volume 70 of Proceedings of Machine Learning Research, pages 933–941. PMLR.
|
| 171 |
+
|
| 172 |
+
Mostafa Dehghani, Anurag Arnab, Lucas Beyer, Ashish Vaswani, and Yi Tay. 2021a. The efficiency misnomer. arXiv preprint arXiv:2110.12894.
|
| 173 |
+
|
| 174 |
+
Mostafa Dehghani, Stephan Gouws, Oriol Vinyals, Jakob Uszkoreit, and Łukasz Kaiser. 2018. Universal transformers. arXiv preprint arXiv:1807.03819.
|
| 175 |
+
|
| 176 |
+
Mostafa Dehghani, Yi Tay, Alexey A Gritsenko, Zhe Zhao, Neil Houlsby, Fernando Diaz, Donald Metzler, and Oriol Vinyals. 2021b. The benchmark lottery. arXiv preprint arXiv:2107.07002.
|
| 177 |
+
|
| 178 |
+
William Fedus, Barret Zoph, and Noam Shazeer. 2021. Switch transformers: Scaling to trillion parameter models with simple and efficient sparsity. arXiv preprint arXiv:2101.03961.
|
| 179 |
+
|
| 180 |
+
Naman Goyal, Jingfei Du, Myle Ott, Giri Anantharaman, and Alexis Conneau. 2021. Larger-Scale Transformers for Multilingual Masked Language Modeling. arXiv e-prints, page arXiv:2105.00572.
|
| 181 |
+
|
| 182 |
+
Tom Henighan, Jared Kaplan, Mor Katz, Mark Chen, Christopher Hesse, Jacob Jackson, Heewoo Jun, Tom B Brown, Prafulla Dhariwal, Scott Gray, et al. 2020. Scaling laws for autoregressive generative modeling. arXiv preprint arXiv:2010.14701.
|
| 183 |
+
|
| 184 |
+
Danny Hernandez, Jared Kaplan, Tom Henighan, and Sam McCandlish. 2021. Scaling laws for transfer. arXiv preprint arXiv:2102.01293.
|
| 185 |
+
|
| 186 |
+
Jordan Hoffmann, Sebastian Borgeaud, Arthur Mensch, Elena Buchatskaya, Trevor Cai, Eliza Rutherford, Diego de Las Casas, Lisa Anne Hendricks, Johannes Welbl, Aidan Clark, Thomas Hennigan, Eric Noland, Katherine Millican, George van den Driessche, Bogdan Damoc, Aurelia Guy, Simon Osindero, Karén Simonyan, Erich Elsen, Oriol Vinyals, Jack Rae, and Laurent Sifre. 2022. Training compute-optimal large language models. In Advances in Neural Information Processing Systems, volume 35, pages 30016–30030. Curran Associates, Inc.
|
| 187 |
+
|
| 188 |
+
Jared Kaplan, Sam McCandlish, Tom Henighan, Tom B Brown, Benjamin Chess, Rewon Child, Scott Gray, Alec Radford, Jeffrey Wu, and Dario Amodei. 2020. Scaling laws for neural language models. arXiv preprint arXiv:2001.08361.
|
| 189 |
+
|
| 190 |
+
Taku Kudo and John Richardson. 2018. Sentencepiece: A simple and language independent subword tokenizer and detokenizer for neural text processing. arXiv preprint arXiv:1808.06226.
|
| 191 |
+
|
| 192 |
+
Zhenzhong Lan, Mingda Chen, Sebastian Goodman, Kevin Gimpel, Piyush Sharma, and Radu Soricut.
|
| 193 |
+
|
| 194 |
+
2019. Albert: A lite bert for self-supervised learning of language representations. arXiv preprint arXiv:1909.11942.
|
| 195 |
+
|
| 196 |
+
Niklas Muennighoff, Alexander M. Rush, Boaz Barak, Teven Le Scao, Aleksandra Piktus, Nouamane Tazi, Sampo Pyysalo, Thomas Wolf, and Colin Raffel. 2023. Scaling data-constrained language models.
|
| 197 |
+
|
| 198 |
+
Sharan Narang, Hyung Won Chung, Yi Tay, William Fedus, Thibault Fevry, Michael Matena, Karishma Malkan, Noah Fiedel, Noam Shazeer, Zhenzhong Lan, et al. 2021. Do transformer modifications transfer across implementations and applications? arXiv preprint arXiv:2102.11972.
|
| 199 |
+
|
| 200 |
+
Jack W Rae, Sebastian Borgeaud, Trevor Cai, Katie Millican, Jordan Hoffmann, Francis Song, John Aslanides, Sarah Henderson, Roman Ring, Susannah Young, et al. 2021. Scaling language models: Methods, analysis & insights from training gopher. arXiv preprint arXiv:2112.11446.
|
| 201 |
+
|
| 202 |
+
Colin Raffel, Noam Shazeer, Adam Roberts, Katherine Lee, Sharan Narang, Michael Matena, Yanqi Zhou, Wei Li, and Peter J Liu. 2019. Exploring the limits of transfer learning with a unified text-to-text transformer. arXiv preprint arXiv:1910.10683.
|
| 203 |
+
|
| 204 |
+
Pranav Rajpurkar, Jian Zhang, Konstantin Lopyrev, and Percy Liang. 2016. Squad: $^ { 1 0 0 , 0 0 0 + }$ questions for machine comprehension of text. arXiv preprint arXiv:1606.05250.
|
| 205 |
+
|
| 206 |
+
Noam Shazeer. 2020. Glu variants improve transformer. arXiv preprint arXiv:2002.05202.
|
| 207 |
+
|
| 208 |
+
Noam Shazeer, Youlong Cheng, Niki Parmar, Dustin Tran, Ashish Vaswani, Penporn Koanantakool, Peter Hawkins, HyoukJoong Lee, Mingsheng Hong, Cliff Young, et al. 2018. Mesh-tensorflow: Deep learning for supercomputers. In Advances in Neural Information Processing Systems, pages 10414–10423.
|
| 209 |
+
|
| 210 |
+
Noam Shazeer and Mitchell Stern. 2018. Adafactor: Adaptive learning rates with sublinear memory cost. In International Conference on Machine Learning, pages 4596–4604. PMLR.
|
| 211 |
+
|
| 212 |
+
David So, Quoc Le, and Chen Liang. 2019. The evolved transformer. In International Conference on Machine Learning, pages 5877–5886. PMLR.
|
| 213 |
+
|
| 214 |
+
Ilya Sutskever, Oriol Vinyals, and Quoc V Le. 2014. Sequence to sequence learning with neural networks. arXiv preprint arXiv:1409.3215.
|
| 215 |
+
|
| 216 |
+
Yi Tay, Mostafa Dehghani, Dara Bahri, and Donald Metzler. 2020. Efficient transformers: A survey. arXiv preprint arXiv:2009.06732.
|
| 217 |
+
|
| 218 |
+
Yi Tay, Mostafa Dehghani, Jai Gupta, Dara Bahri, Vamsi Aribandi, Zhen Qin, and Donald Metzler. 2021a. Are pre-trained convolutions better than pre-trained transformers? arXiv preprint arXiv:2105.03322.
|
| 219 |
+
|
| 220 |
+
Yi Tay, Mostafa Dehghani, Jinfeng Rao, William Fedus, Samira Abnar, Hyung Won Chung, Sharan Narang, Dani Yogatama, Ashish Vaswani, and Donald Metzler. 2021b. Scale efficiently: Insights from pretraining and fine-tuning transformers. arXiv preprint arXiv:2109.10686.
|
| 221 |
+
|
| 222 |
+
Yi Tay, Mostafa Dehghani, Vinh Q Tran, Xavier Garcia, Dara Bahri, Tal Schuster, Huaixiu Steven Zheng, Neil Houlsby, and Donald Metzler. 2022. Unifying language learning paradigms. arXiv preprint arXiv:2205.05131.
|
| 223 |
+
|
| 224 |
+
Ilya Tolstikhin, Neil Houlsby, Alexander Kolesnikov, Lucas Beyer, Xiaohua Zhai, Thomas Unterthiner, Jessica Yung, Daniel Keysers, Jakob Uszkoreit, Mario Lucic, et al. 2021. Mlp-mixer: An all-mlp architecture for vision. arXiv preprint arXiv:2105.01601.
|
| 225 |
+
|
| 226 |
+
Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Łukasz Kaiser, and Illia Polosukhin. 2017. Attention is all you need. In Advances in neural information processing systems, pages 5998–6008.
|
| 227 |
+
|
| 228 |
+
Alex Wang, Yada Pruksachatkun, Nikita Nangia, Amanpreet Singh, Julian Michael, Felix Hill, Omer Levy, and Samuel R Bowman. 2019. Superglue: A stickier benchmark for general-purpose language understanding systems. arXiv preprint arXiv:1905.00537.
|
| 229 |
+
|
| 230 |
+
Alex Wang, Amanpreet Singh, Julian Michael, Felix Hill, Omer Levy, and Samuel R Bowman. 2018. Glue: A multi-task benchmark and analysis platform for natural language understanding. arXiv preprint arXiv:1804.07461.
|
| 231 |
+
|
| 232 |
+
Jason Wei, Yi Tay, Rishi Bommasani, Colin Raffel, Barret Zoph, Sebastian Borgeaud, Dani Yogatama, Maarten Bosma, Denny Zhou, Donald Metzler, et al. 2022a. Emergent abilities of large language models. arXiv preprint arXiv:2206.07682.
|
| 233 |
+
|
| 234 |
+
Jason Wei, Xuezhi Wang, Dale Schuurmans, Maarten Bosma, brian ichter, Fei Xia, Ed Chi, Quoc V Le, and Denny Zhou. 2022b. Chain-of-thought prompting elicits reasoning in large language models. In Advances in Neural Information Processing Systems, volume 35, pages 24824–24837. Curran Associates, Inc.
|
| 235 |
+
|
| 236 |
+
Felix Wu, Angela Fan, Alexei Baevski, Yann N Dauphin, and Michael Auli. 2019. Pay less attention with lightweight and dynamic convolutions. arXiv preprint arXiv:1901.10430.
|
| 237 |
+
|
| 238 |
+
Zhilin Yang, Zihang Dai, Ruslan Salakhutdinov, and William W Cohen. 2017. Breaking the softmax bottleneck: A high-rank rnn language model. arXiv preprint arXiv:1711.03953.
|
| 239 |
+
|
| 240 |
+
# 8 Appendix
|
| 241 |
+
|
| 242 |
+
# 8.1 Scaling Details for Individual Models
|
| 243 |
+
|
| 244 |
+
For most models, it was reasonable to follow the uniform scaling method in the main T5 sizes. At each size, the hyperparameters are as follows:
|
| 245 |
+
|
| 246 |
+
<table><tr><td>Model</td><td>NL</td><td>dff</td><td>dmodel</td><td>dku</td><td>NH</td><td>#Params</td></tr><tr><td>Tiny</td><td>4/4</td><td>1024</td><td>256</td><td>32</td><td>4</td><td>16M</td></tr><tr><td>Small</td><td>6/6</td><td>2048</td><td>512</td><td>32</td><td>8</td><td>60M</td></tr><tr><td>Base</td><td>12/12</td><td>3072</td><td>768</td><td>64</td><td>12</td><td>220M</td></tr><tr><td>Large</td><td>24/24</td><td>4096</td><td>1024</td><td>64</td><td>16</td><td>738M</td></tr><tr><td>XL</td><td>24/24</td><td>16384</td><td>1024</td><td>128</td><td>32</td><td>3B</td></tr></table>
|
| 247 |
+
|
| 248 |
+
Table 3: Table of model configurations. $N _ { L }$ is the number of layers, $d _ { f f }$ is the size of the MLP, $d _ { m o d e l }$ is the hidden size of the model. $d _ { k v }$ is the size of each keyvalue vector. $N _ { H }$ is the number of heads.
|
| 249 |
+
|
| 250 |
+
Scaling for Switch Transformer For Switch Transformers, we use the following scaling:
|
| 251 |
+
|
| 252 |
+
Table 4: Scaling for Switch Transformer. $N _ { E }$ is the number of experts.
|
| 253 |
+
|
| 254 |
+
<table><tr><td>Model</td><td>NL</td><td>dff</td><td>dmodel</td><td>dku</td><td>NH</td><td>NE</td><td>#Params</td></tr><tr><td>Tiny</td><td>4</td><td>1024</td><td>512</td><td>64</td><td>12</td><td>32</td><td>173M</td></tr><tr><td>Small</td><td>6</td><td>2048</td><td>512</td><td>64</td><td>12</td><td>32</td><td>460M</td></tr><tr><td>Base</td><td>12</td><td>3072</td><td>768</td><td>64</td><td>12</td><td>32</td><td>2B</td></tr><tr><td>Large</td><td>24</td><td>3072</td><td>768</td><td>64</td><td>12</td><td>32</td><td>8B</td></tr><tr><td>XL</td><td>48</td><td>3072</td><td>768</td><td>64</td><td>12</td><td>128</td><td>30B</td></tr></table>
|
| 255 |
+
|
| 256 |
+
Scaling for Universal Transformer Scaling UTs are generally difficult as described in the main text. There were two main considerations for scaling UTs. Initially we tried scaling the number of recurrent operations. However, we found that even with an increase of FLOPS, this does not lead to improved performance. Overall, the UT model might be pretty slow and therefore a model with the same hparams as vanilla XL might be infeasible to run. Hence, we explored increasing the width of the MLPs to $3 2 K$ to see if UTs would scale in this manner.
|
| 257 |
+
|
| 258 |
+
<table><tr><td>Model</td><td>NR</td><td>dff</td><td>dmodel</td><td>dku</td><td>NH</td><td>#Params</td></tr><tr><td>UT Tiny</td><td>3/3</td><td>1024</td><td>128</td><td>32</td><td>8</td><td>11M</td></tr><tr><td>UT Small</td><td>3/3</td><td>2048</td><td>512</td><td>32</td><td>8</td><td>52M</td></tr><tr><td>UTBase</td><td>3/3</td><td>3072</td><td>768</td><td>64</td><td>12</td><td>127M</td></tr><tr><td>UTLarge</td><td>3/3</td><td>32768</td><td>1024</td><td>64</td><td>16</td><td>283M</td></tr></table>
|
| 259 |
+
|
| 260 |
+
Table 5: Table of model configurations. $N _ { R }$ is the number of recurrent operations, $d _ { f f }$ is the size of the MLP, $d _ { m o d e l }$ is the hidden size of the model. $d _ { k v }$ is the size of each key-value vector. $N _ { H }$ is the number of heads.
|
| 261 |
+
|
| 262 |
+
# 8.2 Full Results
|
| 263 |
+
|
| 264 |
+

|
| 265 |
+
Figure 6: Quality-FLOP trade off for the upstream Negative Log-Perplexity of vanilla Transformer compared to other models.
|
| 266 |
+
|
| 267 |
+

|
| 268 |
+
Figure 7: Quality-Parameter trade off for the upstream Negative Log-Perplexity of vanilla Transformer compared to other models.
|
| 269 |
+
|
| 270 |
+

|
| 271 |
+
Figure 8: Quality-Throughput trade off for the upstream Negative Log-Perplexity of vanilla Transformer compared to other models.
|
| 272 |
+
|
| 273 |
+

|
| 274 |
+
Figure 9: Quality-FLOP trade off for the downstream SuperGlue Accuracy of vanilla Transformer compared to other models, with respect to FLOPs, number of parameters, and throughput.
|
| 275 |
+
|
| 276 |
+

|
| 277 |
+
Figure 10: Quality-Parameter trade off for the downstream SuperGlue Accuracy of vanilla Transformer compared to other models.
|
| 278 |
+
|
| 279 |
+

|
| 280 |
+
Figure 11: Quality-Throughput trade off for the downstream SuperGlue Accuracy of vanilla Transformer compared to other models.
|
| 281 |
+
|
| 282 |
+

|
| 283 |
+
Figure 12: Quality-FLOP trade off for the downstream Glue Accuracy of vanilla Transformer compared to other models.
|
| 284 |
+
|
| 285 |
+

|
| 286 |
+
Figure 13: Quality-Parameter trade off for the downstream Glue Accuracy of vanilla Transformer compared to other models.
|
| 287 |
+
|
| 288 |
+

|
| 289 |
+
Figure 14: Quality-Throughput trade off for the downstream Glue Accuracy of vanilla Transformer compared to other models.
|
| 290 |
+
|
| 291 |
+

|
| 292 |
+
Figure 15: Quality-FLOP trade off for the downstream Squad Accuracy of vanilla Transformer compared to other models.
|
| 293 |
+
|
| 294 |
+

|
| 295 |
+
Figure 16: Quality-Parameter trade off for the downstream Squad Accuracy of vanilla Transformer compared to other models.
|
| 296 |
+
|
| 297 |
+

|
| 298 |
+
Figure 17: Quality-Throughput trade off for the downstream Squad Accuracy of vanilla Transformer compared to other models.
|
md/dev/EMLJ_mTz_z/EMLJ_mTz_z.md
ADDED
|
@@ -0,0 +1,292 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# CONVOLUTIONAL NEURAL NETWORK DYNAMICS: A GRAPH PERSPECTIVE
|
| 2 |
+
|
| 3 |
+
Anonymous authors Paper under double-blind review
|
| 4 |
+
|
| 5 |
+
# ABSTRACT
|
| 6 |
+
|
| 7 |
+
The success of neural networks (NNs) in a wide range of applications has led to increased interest in understanding the underlying learning dynamics of these models. In this paper, we go beyond mere descriptions of the learning dynamics by taking a graph perspective and investigating the relationship between the graph structure of NNs and their performance. Specifically, we propose (1) representing the neural network learning process as a time-evolving graph (i.e., a series of static graph snapshots over epochs), (2) capturing the structural changes of the NN during the training phase in a simple temporal summary, and (3) leveraging the structural summary to predict the accuracy of the underlying NN in a classification or regression task. For the dynamic graph representation of NNs, we explore structural representations for fully-connected and convolutional layers, which are key components of powerful NN models. Our analysis shows that a simple summary of graph statistics, such as weighted degree and eigenvector centrality, over just a few epochs can be used to accurately predict the performance of NNs. For example, a weighted degree-based summary of the time-evolving graph that is constructed based on 5 training epochs of the LeNet architecture achieves classification accuracy of over $93 \%$ . Our findings are consistent for different NN architectures, including LeNet, VGG, AlexNet, and ResNet.
|
| 8 |
+
|
| 9 |
+
# 1 INTRODUCTION
|
| 10 |
+
|
| 11 |
+
Neural networks (NNs) have driven advancements in many domains, including computer vision and image processing (Hu et al., 2018), natural language processing (Sutskever et al., 2014; Bahdanau et al., 2015), and bioinformatics (Cao et al., 2020; Li et al., 2019). As task complexity increases, networks grow deeper and larger, consequently requiring more computational resources and training data, as well as sacrificing interpretability for improved task performance. Some works have focused on understanding and interpreting deep NNs (Raghu et al., 2017; Chakraborty & et al., 2017; Ioffe & Szegedy, 2015; He et al., 2016). One approach towards this goal involves representing the NN as its underlying graph structure, and studying selected graph properties, such as clustering coefficient, path length (You et al., 2020), modularity (Filan et al., 2021), persistence (Rieck et al., 2019). For example, You et al. (2020) represent NNs as relational graphs capturing the message passing process, and investigate the correlation between the predictive performance of NNs and architectural changes. However, the studies of NN structures as graphs are limited, and the structural changes of the underlying graph during the training process have been largely overlooked in the literature.
|
| 12 |
+
|
| 13 |
+
To fill this gap, in this work, we take the graph perspective and aim to predict the performance of an NN by capturing early NN dynamics during the training phase. Successful performance prediction based on only a few epochs could be used for early stopping (Yu & Zhu, 2020), and thus, more efficient NN training. To solve the performance prediction problem, we propose a multi-step framework, depicted in Fig. 1. Specifically, we propose to represent the underlying graph structure of an NN as a time-evolving k-partite graph, where each part corresponds to a different NN layer, and each graph snapshot in the evolving graph maps to an NN instance at a specific epoch. We build on existing graph representations of fully-connected and convolutional layers, both of which are key components of popular NN architectures, and introduce a new, compact, efficient-to-compute (“rolled”) graph representation for convolutional layers. Then, we extract well-known node features (weighted degree and eigenvector centrality) from the time-evolving graph and construct temporal signatures by computing summary statistics on the node feature distributions. Finally, we cast NN performance prediction as a classification task and a regression task, each of which operates on the temporal structural signatures of the NN. Our main contributions are:
|
| 14 |
+
|
| 15 |
+

|
| 16 |
+
Figure 1: Our proposed framework for predicting NN performance in a downstream image classification task, shown for one test instance. The input to our framework is an NN trained for a few epochs (3, in this example). Steps: (S1) the input NN is converted to three static graphs, each representing one training epoch; (S2) node features (e.g., degree) are extracted from each graph snapshot (i.e., one per epoch); (S3) in order to summarize the changes in the graph structure over time, a signature vector is constructed by aggregating the node features per graph snapshot and concatenating the individual snapshot signatures; (S4) a pre-trained classifier and regressor predict the performance of the input NN given the signature vector from (S3).
|
| 17 |
+
|
| 18 |
+
• New graph-based NN representation: We introduce a new graph representation for convolutional layers that is more compact and efficient-to-compute than the existing unrolled representation (Rieck et al., 2019), while not sacrificing accuracy in the NN performance prediction task.
|
| 19 |
+
|
| 20 |
+
• Framework for NN performance prediction: We propose a simple, multi-step graph-based framework to solve the NN performance prediction problem by capturing the early NN dynamics during the training phase.
|
| 21 |
+
|
| 22 |
+
• Extensive empirical analysis: Using well-known image classification datasets (ImageNet and CIFAR-10), and a variety of NN architectures (AlexNet, VGG, LeNet, and ResNet), we show that our framework can effectively predict the performance of NNs by observing only a few epochs of training, well before their corresponding early stopping epochs. For instance, using our framework to capture the changes in the graph structure in only 5 training epochs of the ResNet architecture results in classification accuracy of over $90 \%$ .
|
| 23 |
+
|
| 24 |
+
# 2 PRELIMINARIES
|
| 25 |
+
|
| 26 |
+
We first present the key concepts that our work builds upon. Table 1 gives the major symbols and their descriptions.
|
| 27 |
+
|
| 28 |
+
An NN model is a collection of connected units (neurons) that are organized in layers, and is defined by a set of parameters that adjust during the training process. We refer to the training process of a single architecture along with its respective hyperparameters as an ‘instance’. We focus on two types of layers that are the key components of many powerful NN models such as LeNet(Lecun et al., 1998), VGG (Simonyan & Zisserman, 2015) and ResNet(He et al., 2016): fully connected layers (fc) and convolutional (conv) layers.
|
| 29 |
+
|
| 30 |
+
# 2.1 GRAPHS: TERMINOLOGY AND NOTATION
|
| 31 |
+
|
| 32 |
+
Let $\mathbf { G } = ( \nu , \mathcal { E } )$ be an undirected, weighted graph with node set $\nu$ , edge set $\mathcal { E }$ , and weighted adjacency matrix $\mathbf { W } \in \mathbb { R } ^ { | \mathcal { V } | \times | \mathcal { V } | }$ . The neighbors of node $v$ are defined as $\mathcal { N } _ { G } ( v ) = \{ u : ( u , v ) \in \mathcal { E } \}$ ; i.e., the set of all nodes that connect directly to $v$ . Graph $\mathbf { G }$ is $k$ -partite if its nodeset $\nu$ can be partitioned into $k$ independent sets: $\textstyle \mathcal { V } = \bigcup _ { i = 1 } ^ { k } \mathcal { V } _ { i }$ and $\mathcal { V } _ { i } \cap \mathcal { V } _ { j } = \emptyset , i \neq j$ . A time-evolving graph is a series of static graph snapshots over time: $\mathcal { G } = \{ \mathbf { G } ^ { 1 } , \mathbf { G } ^ { 2 } , . . . , \mathbf { G } ^ { T } \}$ . The graphs in the series may have different nodesets and edgesets.
|
| 33 |
+
|
| 34 |
+
Here we focus on two of the most commonly-used node features in graph mining and network science, degree and eigenvector centrality, which capture different types of node importance or influence. We discuss the interpretation of these features in the context of neural network dynamics in $\ S 3 . 2$ .
|
| 35 |
+
|
| 36 |
+
• Degree: Degree is the simplest and most efficient to compute node feature, and captures the connectivity of a node. The weighted degree of node $v$ is defined as the sum of weights of the edges that are incident to $i$ : $\begin{array} { r } { d _ { i } ^ { w } = \sum _ { j } \mathbf { W } _ { i j } } \end{array}$ . Tracking changes in the degree of a node over time is the most direct way of capturing its structural evolution.
|
| 37 |
+
|
| 38 |
+
• Eigenvector centrality: This centrality is a sophisticated extension of degree centrality, related to Google’s PageRank, which indicates the influence of a node in $\mathbf { G }$ (Bonacich, 1972). If a node is connected to several nodes with high eigenvector centrality, then that node will have high centrality. The eigenvector centrality of node $i$ is defined as the $i ^ { t h }$ element in the principal eigenvector $\mathbf { v }$ of W (i.e., the eigenvector that corresponds to the largest eigenvalue $\lambda$ ): $\mathbf { W } \mathbf { v } = \lambda _ { m a x } \mathbf { v }$ .
|
| 39 |
+
|
| 40 |
+
# 2.2 FULLY-CONNECTED LAYERS: GRAPH REPRESENTATION
|
| 41 |
+
|
| 42 |
+
Let $\mathbf { x } \in \mathbb { R } ^ { D _ { i n } }$ be the input vector, $\mathbf { W } \in \mathbb { R } ^ { D _ { i n } \times D _ { o u t } }$ the learnable weight matrix, $\mathbf { b } \in \mathbb { R } ^ { D _ { o u t } }$ the bias vector and $z$ a non-linear activation functions. Then, the output of this layer is given as $\mathbf { y } = z ( \mathbf { x } \mathbf { W } + \mathbf { b } )$ , where $D _ { i n }$ and $D _ { o u t }$ correspond to the dimension of input and output layers. Fully-connected layers are straightforward to represent with a weighted, undirected graph (Filan et al., 2021). Each neuron, including those in the input and output layers, corresponds to a node. Two neurons are connected via an edge if they appear in consecutive layers. More formally, let nodeset $\nu _ { i }$ be the set of all neurons at layer $i$ , and nodeset $\nu _ { j }$ the set of all neurons at layer $j$ (which follows layer $i$ ). The edges that connect all nodes across the two nodesets are defined by the learnable weight matrix $\mathbf { W } \in \mathbb { R } ^ { | \mathcal { V } _ { i } | \times | \mathcal { V } _ { j } | }$ .
|
| 43 |
+
|
| 44 |
+
Table 1: Major symbols and definitions
|
| 45 |
+
|
| 46 |
+
<table><tr><td>Symbol</td><td>Definition</td></tr><tr><td>G= (V,ε) 9={Gi,.,G𝑇}</td><td>a graph with its nodeset and edgeset a time-evolving graph,i.e.,series of graph snapshots</td></tr><tr><td>du,du W</td><td>degree and weighted degree of node u learnableweightmatrixinanNN,and</td></tr><tr><td></td><td>the weighted adj matrix of G</td></tr><tr><td>K</td><td>convolutional kernel</td></tr><tr><td>Din/out</td><td>dimension of the input/output vectors</td></tr><tr><td>c,f</td><td>number of channels and filters</td></tr><tr><td>h,w</td><td>height and width of an input image</td></tr><tr><td>hker,Wker</td><td>height and width of a kernel</td></tr><tr><td>x</td><td>input tensor of conv layer</td></tr></table>
|
| 47 |
+
|
| 48 |
+
# 2.3 CONVOLUTIONAL LAYERS: UNROLLED GRAPH REPRESENTATION
|
| 49 |
+
|
| 50 |
+
Let $\begin{array} { r l r } { { \pmb x } } & { { } \in } & { \mathbb { R } ^ { c \times h \times w } } \end{array}$ be the input and $\kappa \in \mathbb { R } ^ { f \times c \times h _ { k e r } \times w _ { k e r } }$ the convolutional kernel, where $c$ is the number of channels, and $h _ { k e r } , w _ { k e r }$ are the height and width of the kernel respectively. After performing the convolution, we have $\pmb { y } ^ { } \in \mathsf { \tilde { R } } ^ { F \times h _ { o u t } \times \mathsf { \tilde { w } } _ { o u t } }$ , where $h _ { o u t } = h - h _ { k e r } + 1$ and $w _ { o u t } = w - w _ { k e r } + 1$ Typical multilayer CNNs consist of convolutional layers followed by fully-connected layers. The representation of fully connected layers is straightforward but cannot be used to model
|
| 51 |
+
|
| 52 |
+

|
| 53 |
+
Figure 2: Unrolled graph representation example. The two typed nodes in the resultant bipartite graph map to the filtration operation and the output. For the stride in this example, the output node $o _ { 1 }$ (in dark blue) is the output of 4 operation-typed nodes (in light blue).
|
| 54 |
+
|
| 55 |
+
convolutional layers. Rieck et al. (2019) proposed to "unroll" the convolution to convert conv layers into graphs. In Sec. 3, we introduce a new, compact, rolled representation that is both efficient to compute and effective at predicting the NN performance, as we show empirically in Sec. 4.
|
| 56 |
+
|
| 57 |
+
For a convolutional layer, we first unroll the convolutional operation and then represent the graph as in the case of a fully-connected layer. In this representation, the nodes and edges of the graph are defined through the convolutional operation as matrix multiplication (Gebhart et al., 2019). Specifically, for an input image $_ { x }$ and kernel $\boldsymbol { \kappa } _ { i } \in \mathbb { R } ^ { f _ { i } \times c _ { i } \times h _ { i } \times \overset { . } { w } _ { i } }$ , each node in layer $l$ is defined to be the output of the mapped feature of that input for each filter $f _ { i }$ . Edges connect each of these nodes to the corresponding nodes of the output neuron in the next layer. These edges are weighted by the activation value of that neuron (i.e., the input image for a specific stride is multiplied by the filter value at that location in the image). For an input image filter size $( c _ { i } \times h _ { i } \times w _ { i } )$ that results in feature-map (output) of size $1 \times o _ { h } \times o _ { w }$ , the number of nodes of output layer of the graph representation is a function of $o _ { h } \times o _ { w }$ , while the number of nodes in the conv operation layer of graph is a function of $c _ { i } \times h _ { i } \times w _ { i }$ .
|
| 58 |
+
|
| 59 |
+
As an example, Fig. 2 depicts the unrolled graph representation of a toy convolutional layer. It shows one conv operation on a small 2-dimensional input image $\left( 4 \times 4 \right)$ and filter $( 2 \times 2 )$ . The nodes and edges of the represented graph are shown based on one stride (of size 2) of convolution operation.
|
| 60 |
+
|
| 61 |
+
# 3 NEURAL NETWORK PERFORMANCE PREDICTION: A TEMPORALGRAPH-BASED APPROACH
|
| 62 |
+
|
| 63 |
+
In this section, we first formally introduce the problem that we seek to solve. Then, we present a new, compact, and efficient-to-compute graph representation for convolutional layers $( \ S 3 . 1 )$ , and describe our proposed temporal graph-based framework that captures the NN dynamics during training $( \ S \ 3 . 2 )$
|
| 64 |
+
|
| 65 |
+
Problem 1 (NN Performance Prediction) Let $\mathcal { N } = \{ N _ { t r _ { 1 } } , N _ { t r _ { 2 } } , . . . , N _ { t r _ { n } } \}$ be a training set of n NNs trained for $T$ epochs and $\mathcal { A } = \{ \alpha _ { 1 } , \alpha _ { 2 } , . . . , \alpha _ { n } \}$ their corresponding downstream task accuracies (e.g., for image classification). We seek to predict the accuracy $\alpha _ { t s t }$ of a new instance $N _ { t s t }$ trained for a very small number of $t \ll T$ epochs by using $t$ epochs for the trained NNs in $\mathcal { N }$ .
|
| 66 |
+
|
| 67 |
+
Our proposed solution takes the graph perspective, and its first step is to represent each NN as a temporal graph. In addition to the graph representations that we presented in Sec. 2, we introduce a new, efficient representation for convolutional layers, which we describe next.
|
| 68 |
+
|
| 69 |
+
# 3.1 ROLLED GRAPH REPRESENTATION FOR CONVOLUTIONAL LAYERS
|
| 70 |
+
|
| 71 |
+
We call our proposed graph representation for conv layers “rolled,” since it avoids unrolling the convolutional operations introduced in (Rieck et al., 2019).
|
| 72 |
+
|
| 73 |
+
Overview $\pmb { \& }$ Motivation. To preserve the semantic meaning of conv layers, we represent each filter as a node, and link filters in consecutive layers via weighted edges (we define the weights below), as shown in Fig. 3. The motivation behind this approach is that for larger networks, there is an explosion of nodes by unrolling the convolutions (unrolled representation explained in $\ S \ 2 . 3 \AA ,$ ), and the integrity of a unit (a single filter or kernel) becomes untenable. Also, by mapping the nodes to specific entities of NNs, our proposed graph model is more interpretable than the unrolled model, and thus it is easier to interpret the outputs of downstream graph analysis on our graph representation (e.g., computing node features, tracking the evolution of the graph).
|
| 74 |
+
|
| 75 |
+

|
| 76 |
+
Figure 3: Rolled graph representation example. The resultant graph is a tri-partite graph with three node types (Conv1, Conv2, FC) corresponding to two convolutional layers and one FC layer. Gray and light blue nodes represent filters in the conv layers and dark blue nodes represent neurons in the FC layer. The red edge between nodes 6 (gray) and 16 (light blue) is weighted by the $\mathrm { { N o r m ( 6 ^ { t h } } }$ channel of filter 16). Due to dropout, the maximum number of edges is $6 \times 1 6$ between the conv layers, and $1 6 \times 1 2 0$ between the Conv2 and FC layers.
|
| 77 |
+
|
| 78 |
+
Detailed Description. Formally, let tensor $\kappa _ { i }$ be a kernel in layer $i$ with $f _ { i }$ filters, each with $c _ { i }$ nels and dim indexes the sions filter $h _ { i } \times w _ { i }$ . el use bracket. We create tation to index into the kernel: nodes representing each filter $\kappa _ { i } [ l , :$ $, : , : ]$ $l ^ { \mathrm { t h } }$ $\kappa _ { i }$ $f _ { i }$ $\{ v _ { 1 } ^ { ( i ) } , v _ { 2 } ^ { ( i ) } , . . . v _ { f _ { i } } ^ { ( i ) } \}$ with features defined as the corresponding biases in that layer. Let be the next convolutional layer defined analogously. While edge weights between neurons in FC layers are defined in the standard way, we define the edge weights between conv layers as the norm over each kernel’s channels. The edge between node $v _ { k } ^ { \left( i \right) }$ representing the $k ^ { t h }$ filter in layer $i$ (i.e., $\kappa _ { i } [ k , : , : , : ] )$ and node/filter $v _ { l } ^ { ( j ) }$ in layer $j$ (i.e. $\kappa _ { j } [ l , \vdots , \vdots , \vdots )$ has weight $w _ { v _ { k } ^ { ( i ) } , v _ { l } ^ { ( j ) } } = \mathrm { n o r m } ( \mathcal { K } _ { j } [ l , k , : , : ] )$ , which is the norm of the $k ^ { \mathrm { { t h } } }$ channel of the $l ^ { \mathrm { t h } }$ filter in the $j ^ { \mathrm { t h } }$ layer. Though the proposed representations enable alternative edge weight configurations, we focus on the norm of filters as other studies, including those on pruning NNs (Li et al., 2016), have demonstrated that this metric has strong correlation with filter importance. In the case of two conv layers, the resultant graph is an attributed bipartite graph with $f _ { i } + f _ { j }$ nodes and $f _ { i } \times f _ { j }$ edges, where node attributes include flattened weight vectors or filter maps. Other information such as average gradients or the bias vector can also be used for node features.
|
| 79 |
+
|
| 80 |
+
# 3.2 PROPOSED TEMPORAL GRAPH-BASED FRAMEWORK
|
| 81 |
+
|
| 82 |
+
A key objective of our work is to test whether the introduced graph representation of NNs is informative for predicting the performance of NNs. Next, we describe the steps of our proposed framework for solving Problem 1, namely performance prediction from the NN training dynamics.
|
| 83 |
+
|
| 84 |
+
As shown in Fig. 1, our method consists of four steps: (S1) generation of a temporal graph for the training phase of each NN; (S2) extraction of node features; (S3) construction of a feature-based graph signature that captures the NN dynamics; (S4) prediction of NN performance by training a classifier or regressor on the constructed signatures. We describe these steps in more detail next.
|
| 85 |
+
|
| 86 |
+
(S1) Graph generation. The first step involves converting the training process of each input NN into a time-evolving graph. Each NN $N _ { t r _ { i } } \in \mathcal { N }$ , is represented as a series of checkpoints saved for $t$ training epochs. Based on these checkpoints and the graph representation approaches for fc and conv layers presented in 2.2, 3.1 and 2.3, we first convert the $\tau ^ { t \bar { h } }$ NN checkpoint into weighted graph $G _ { i } ^ { ( \tau ) }$ at timestamp/epoch $\tau$ . We note that although our proposed graph representation involves node features, our framework does not leverage them, and thus we consider the generated graphs unattributed. Therefore, each NN $N _ { t r _ { i } }$ is mapped to a time-evolving graph $\mathcal { G } _ { t r _ { i } } = \{ \mathbf { \bar { G } } _ { i } ^ { 1 } , \mathbf { G } _ { i } ^ { 2 } , . . . , \mathbf { \bar { G } } _ { i } ^ { t } \}$ The output of this step is a set of $n$ time-evolving graphs $\{ \mathcal { G } _ { t r _ { 1 } } , \mathcal { G } _ { t r _ { 2 } } , . . . , \mathcal { G } _ { t r _ { n } } \}$ corresponding to the original $n$ NNs in $\mathcal { N }$ .
|
| 87 |
+
|
| 88 |
+
(S2) Feature extraction. Next, the goal is to capture the structural dynamics of the NN training process. We aim to select graph measures that can capture changes during the training process, take into account the edge weight of graphs and can be calculated efficiently. In order to do that in an interpretable way, we extract two well-known node centralities from each snapshot of each generated time-evolving graph $\mathcal { G } _ { i }$ : weighted degree centrality and eigenvector centrality $( \ S 2 . 1 )$ . The weighted degree is a simple function of the learnable weight matrix W during the training phase of NN, therefore it gives us insights into the training dynamics at the node/neuron/filter level. The eigenvector centrality is an extension of the degree centrality, which captures the highly influential nodes, and has been successfully used in neuroscience to capture the dynamic changes of real neural networks (or connectomes) (Lohmann et al., 2010). Eigenvector centrality can be used to capture importance and connectivity of filters/neurons (i.e., the nodes in our graph representation). Also, eigenvector centrality has been used for detecting communities (Newman, 2006) or clusters (Wu et al., 2013), and thus provides structural information about the clusterability of the NN, which is complementary to that provided by the simpler and more efficient-to-compute degree centrality.
|
| 89 |
+
|
| 90 |
+
Our choice of features is also guided by the inherent $k$ -partite structure of our proposed graph representation, which cannot be represented well by several other commonly-used graph features. For example, clustering-based features (e.g., number of triangles, transitivity, clustering coefficient) and cycle-based metrics which account for closed paths in a graph are always equal to 0 for $k$ -partite graphs. Moreover, connected component-related features (i.e., strong/weak connectivity) do not capture the learned edge weights, which are important for modeling the training dynamics of NNs. Other features (e.g., betweenness centrality) tend to be computationally expensive, and would add significant overhead compared to early stopping methods.
|
| 91 |
+
|
| 92 |
+
(S3) Graph signature construction. In order to be able to compare NN-based graphs (with different number of nodes and edges), we summarize the structural changes in the generated time-evolving graphs at the graph level (rather than the node level, as in (S2)), and construct a statistical summary of the extracted node centralities (signature) per time-evolving graph $\mathcal { G } _ { i }$ . For each snapshot $\mathbf { G } _ { i } ^ { ( \tau ) }$ of $\mathcal { G } _ { i }$ , we create a signature vector using five node feature aggregators, which were introduced in (Berlingerio et al., 2012) for graph similarity: median, mean, standard deviation, skewness, and kurtosis, where all but the median are moments of the corresponding distribution. Thus, $\mathbf { G } _ { i } ^ { ( \tau ) }$ is mapped to a (static) signature vector $s _ { i } ^ { ( \tau ) } \in \mathbb { R } ^ { 5 }$ , representing the statistical summary of its node features (i.e., degree or eigenvector centrality) at time $\tau$ . To put more emphasis on the most recent timestamp, we can redefine the signature at time $\tau$ as the linear weighted average of the signatures up to that point, $\mathbf { s } _ { i } ^ { ( \tau ) } \gets \frac { \sum _ { j } ^ { \tau } j * \mathbf { s } ^ { ( j ) } } { \sum j }$ s , or an exponential function of the previous signatures, s(τ)i ← αs(τ)i + (1 − α)s(τ−1)i . To obtain the temporal signature of the evolving graph $\mathcal { G } _ { i }$ , we aggregate the (static) signatures up to timestamp/epoch $t$ : $\mathbf { s } _ { i } ^ { \tilde { t } } = \mathbf { s } _ { i } ^ { 1 } \oplus \mathbf { s } _ { i } ^ { 2 } \oplus \ldots \oplus \bar { \mathbf { s } _ { i } ^ { t } }$ , where $\oplus$ denotes concatenation. We note that global features such as algebraic connectivity, modularity, and average shortest paths may be seen as alternative ways for constructing global graph signatures while circumventing the local feature extraction step (S2); however, these features fail to capture the structural changes in our proposed graph representations (they remain (near-)constant over time) and lead to poor performance.
|
| 93 |
+
|
| 94 |
+
(S4) Performance prediction. For the last step of performance prediction, we consider two tasks:
|
| 95 |
+
|
| 96 |
+
Table 2: Information for the generated NNs: range for early stopping epoch, range for accuracy, and accuracy threshold used for defining the class labels for classification task (predicting the accuracy level of NNs).
|
| 97 |
+
|
| 98 |
+
<table><tr><td rowspan="2"></td><td colspan="5">CIFAR-10</td><td colspan="3">ImageNet</td></tr><tr><td>LeNet</td><td>AlexNet</td><td>VGG</td><td>ResNet-32</td><td>ResNet-44</td><td>LeNet</td><td>AlexNet</td><td>ResNet-50</td></tr><tr><td>Early stopping</td><td>11~50</td><td>30~50</td><td>45~50</td><td>16~120</td><td>16~120</td><td>16~50</td><td>16~50</td><td>16~120</td></tr><tr><td>Acc. range</td><td>9.4~ 73.8</td><td>5.5~82.4</td><td>8.8~87.6</td><td>8.4~90.0</td><td>9.9~89.8</td><td>0.6~14.4</td><td>0.6~20.1</td><td>0.86~41.66</td></tr><tr><td>Acc. thres.</td><td>40</td><td>40</td><td>40</td><td>40</td><td>40</td><td>9</td><td>10</td><td>25</td></tr></table>
|
| 99 |
+
|
| 100 |
+
• Classification: We train a classifier (e.g., SVM, MLP) using the training graphs $\{ \mathcal { G } _ { t r _ { 1 } } , \mathcal { G } _ { t r _ { 2 } } , . . . , \mathcal { G } _ { t r _ { n } } \}$ represented by their temporal signatures $\{ \mathbf { s } _ { t r _ { 1 } } ^ { t } , \mathbf { s } _ { t r _ { 2 } } ^ { t } , . . . , \mathbf { s } _ { t r _ { n } } ^ { t } \}$ , and their corresponding accuracies $\mathcal { A } = \{ \alpha _ { 1 } , \alpha _ { 2 } , . . . , \alpha _ { n } \}$ mapped to labels $\mathcal { L = } \{ l _ { 1 } , \bar { l } _ { 2 } , \dots , \bar { l _ { n } } \}$ (e.g., high/low accuracy) based on some threshold. Any test NN instance is then classified using the trained classifier.
|
| 101 |
+
|
| 102 |
+
• Linear regression: We perform linear regression to estimate the actual accuracy value $\alpha _ { t s t }$ of a new test instance $N _ { t s t }$ based on its signature obtained through steps (S1)-(S3).
|
| 103 |
+
|
| 104 |
+
# 4 EMPIRICAL ANALYSIS
|
| 105 |
+
|
| 106 |
+
In this section, we empirically evaluate the effectiveness and efficiency of our framework in the classification and regression tasks for different graph representations (rolled and unrolled graphs for conv layers) and different feature-based signatures (degree- vs. eigenvector centrality-based).
|
| 107 |
+
|
| 108 |
+
Data. We investigate NN dynamics using our framework on two well-known image classification datasets, CIFAR-10 (Krizhevsky, 2009) and ImageNet (Russakovsky et al., 2015). CIFAR-10 consists of 50K training images and 10K test images. For ImageNet, we use a sample that has 50K training images and 5K validation images used as the test set. The sample is obtained by randomly selecting 100 classes from Tiny ImageNet (tin) and downsizing the images to $3 2 \times 3 2$ colored images.
|
| 109 |
+
|
| 110 |
+
Configuration. The configuration of training different NN models, and the early stopping method are described in App. A.1. For the unrolled graph representation, which is signed, we consider different graph types (e.g., positive, negative), which we describe in App. A.2.
|
| 111 |
+
|
| 112 |
+
# 4.1 CLASSIFICATION: PREDICTING NN ACCURACY RANGE FROM NN TRAINING DYNAMICS
|
| 113 |
+
|
| 114 |
+
Task setup. We cast the NN performance prediction as a classification task. Specifically, the generated time-evolving graphs are labeled as high and low accuracy based on the performance of their corresponding NNs; Table 2 lists the threshold value chosen for low and high accuracy labels based on the final accuracy range of trained NNs, as well as the early stopping epochs for each architecture. Five-fold cross validation is used to predict the label of the test graphs in a binary classification task using SVM and MLP, where the input is the set of temporal signatures $\{ \mathbf { s } _ { t r _ { 1 } } ^ { t } , \mathbf { \bar { s } } _ { t r _ { 2 } } ^ { t } , . . . , \mathbf { s } _ { t r _ { n } } ^ { t } \}$ . We report the classification accuracy. Since the sample of NNs (App. A.1) is randomly selected with balanced high/low accuracy instances, the accuracy of a random classifier as the baseline is $50 \%$ (omitted from the charts to avoid clutter). Additionally, to show that our proposed graph representation and signatures are general and can be useful across different NN architectures, we consider the following setup: we train the classifier on a small set of NN models (i.e., different architectures—such as LeNet, AlexNet, and VGG—and hyperparameters), and predict the performance on unseen architectures (e.g., ResNet). We describe these experiments in App. A.4.
|
| 115 |
+
|
| 116 |
+
Results. Figure 4 illustrates the performance of SVM and MLP classifiers operating on weighted degree-based signatures of the rolled and unrolled graph representations of the LeNet and AlexNet architectures, trained on the CIFAR-10 dataset. We omit the results on VGG and ResNet, as well as image classification on ImageNet, because the unrolled graph generation process is prohibitively expensive, both in terms of time and space. Overall, the rolled and unrolled graph representations show similar trends in classifying NNs by effectively capturing their early training dynamics: the structural changes in the training NN architectures during the first 6-15 iterations are sufficient to classify the performance of NN instances with over $90 \%$ accuracy. However, as we discuss in $\ S 4 . 3$ , our proposed rolled representation is significantly more efficient than the unrolled representation, and can generalize to deeper and larger NNs. We provide more details for these experiments in App. A.2.
|
| 117 |
+
|
| 118 |
+

|
| 119 |
+
Figure 4: CIFAR-10: NN performance classification for different NN architectures, graph representations, and features for the temporal signatures. Shorthands: ‘deg’ for degree-based and ‘evec’ for eigenvector centralitybased temporal signature. (a)–(d): Accuracy based on weighted degree-based signature vectors for both the rolled and unrolled graph representations. Our rolled graph representation is as effective as the unrolled representation in predicting the image classification performance of NNs, while being significantly more efficient. For the unrolled representation ((c) and (d)), the negative subgraph (solid lines) results in the most accurate performance prediction among the three subgraphs. (e)–(h): Accuracy based on the weighted degree- and eigenvector centrality-based signature vectors of the rolled graph representations of VGG and ResNet-44. For both architectures, SVM performs best when leveraging the degree-based signatures ( $90 \%$ accuracy after 5 training epochs), while MLP outperforms SVM when operating on the eigenvector centrality-based signatures.
|
| 120 |
+
|
| 121 |
+
OBSERVATION 1 Both the rolled and unrolled time-evolving graph representations of NNs are effective in capturing the changes in the NN dynamics during the training phase, and can be used to predict the accuracy of an NN instance after observing only a few training epochs. Our proposed rolled representation is also space- and time-efficient, unlike the unrolled representation.
|
| 122 |
+
|
| 123 |
+
In the remainder of this analysis, we focus on the rolled representation, which is more efficient for larger NN models and datasets. We present the classification results for both types of signatures for the temporal graphs corresponding to the training dynamics of VGG and ResNet-44 (CIFAR-10 dataset) in Fig. 4(e)-(h) and LeNet, AlexNet and ResNet-50 (ImageNet datatset) in Fig. 5. In addition to the results discussed above for LeNet and AlexNet, we provide the NN classification accuracy for the eigenvector-based signatures in Fig. 11 in the appendix. In all the cases, classification accuracy of $80 \%$ is achieved in less than 10 training epochs. For degree-based signatures, SVM tends to outperform MLP, while the trend is reversed for eigenvector-based signatures. For example, for both VGG and AlexNet for the CIFAR-10 image classification task, MLP can predict the performance with accuracy ${ \sim } 9 5 \%$ using the eigenvector-based signatures from the first 6 training epochs; the same trend is observed on ImageNet for the LeNet and AlexNet architectures. For ResNet on the ImageNet classification task, SVM tends to perform well for both degree and eigenvector centrality signature vectors; while MLP tends to perform poorly in this case, the MLP variant operating on the exponential average of signature vectors outperforms the original MLP and all SVM variants. In all the cases, both classifiers reach performance over $80 \%$ - $90 \%$ significantly before the early stopping point for all the architectures. In general, for ImageNet, we observe that the signatures based on eigenvector centrality are more effective in the NN performance prediction task compared to the weighted degree-based signatures—irrespective of NN architecture.
|
| 124 |
+
|
| 125 |
+
OBSERVATION 2 For the CIFAR-10 image classification task, the rolled graph representation for all NN architectures and both signature types achieve accuracy of ${ > } 9 0 \%$ . For ImageNet, the eigenvector centrality-based signatures tend to yield higher performance compared to the weighted degree-based signatures, though both achieve accuracy of $80 \%$ .
|
| 126 |
+
|
| 127 |
+
4.2 REGRESSION ANALYSIS: PREDICTING NN ACCURACY FROM NN TRAINING DYNAMICS
|
| 128 |
+
|
| 129 |
+
In this section, we discuss the results and key findings of predicting the actual performance (accuracy) of an NN using a linear regression model, instead of treating this task as a classification problem as in the previous section.
|
| 130 |
+
|
| 131 |
+
Table 4: Regression Analysis on CIFAR-10: Accuracy prediction based on the rolled graph representation and the degree-based signature.
|
| 132 |
+
|
| 133 |
+
<table><tr><td></td><td colspan="2">LeNet</td><td colspan="2">AlexNet</td><td colspan="2">VGG</td><td colspan="2">ResNet</td></tr><tr><td>Time</td><td>MAE</td><td>R²</td><td>MAE</td><td>R²</td><td>MAE</td><td>R²</td><td>MAE</td><td>R²</td></tr><tr><td>0-2</td><td>14.95</td><td>0.16</td><td>18.712</td><td>0.62</td><td>17.72</td><td>0.62</td><td>19.84</td><td>0.60</td></tr><tr><td>1-3</td><td>14.67</td><td>0.3</td><td>18.57</td><td>0.66</td><td>11.98</td><td>0.81</td><td>19.41</td><td>0.62</td></tr><tr><td>3-5</td><td>17.09</td><td>0.67</td><td>18.4</td><td>0.59</td><td>11.91</td><td>0.81</td><td>17.63</td><td>0.67</td></tr><tr><td>5-7</td><td>12.49</td><td>0.75</td><td>16.74</td><td>0.66</td><td>6.87</td><td>0.94</td><td>18.28</td><td>0.68</td></tr></table>
|
| 134 |
+
|
| 135 |
+
Task setup. Following the same experimental methodology as in the classification task, we use the degree-based signatures of the generated time-evolving graph as the predictor and the overall accuracy of the corresponding NN as the dependent variable. We use $20 \%$ of our observations as a test set, and the rest as a training set. We report the testing mean absolute error (MAE) and coefficient of determination $( R ^ { 2 } )$ .
|
| 136 |
+
|
| 137 |
+
Table 3 displays the results for regression prediction on ImageNet dataset, the prediction model show similar trend as CIFAR-10 on this datatset. The MAE values are smaller for this dataset since the accuracy range of both architectures are much narrower than the CIFAR-10 dataset (See Table 2 for accuracy ranges of different architectures and datasets.)
|
| 138 |
+
|
| 139 |
+
Results. Table 4 summarizes the regression results for four architectures where the independent variable is degree features of rolled graph representation. For each step of this experiment, we use a concatenation of two consecutive feature vectors as independent variable of regression model. For LeNet, at timestamp 5-7 the regression model error (MAE for test set) is 5.74, while the accuracy range of LeNet for this dataset is wide (0.9-73.8), and based on $R ^ { 2 } = 0 . 9 1$ , we can interpret that $91 \%$ of variant in accuracy of NN can be explained by the de
|
| 140 |
+
|
| 141 |
+

|
| 142 |
+
Figure 5: ImageNet: NN classification using the weighted degree-based and eigenvector centrality-based signature vectors for LeNet, AlexNet and ResNet. Eigenvector centrality-based signatures (b), (d), (f) yield higher performance compared to the weighted degreebased signatures (a), (c), (e).
|
| 143 |
+
|
| 144 |
+
gree changes of the rolled graph between timestamp 5-7. A similar trend is observed for AlexNet, VGG and ResNet, where after observing a few epochs, the prediction model shows a very low MAE with high $R ^ { 2 }$ .
|
| 145 |
+
|
| 146 |
+
OBSERVATION 3 In sum, the weighted degree-based signature vector of time-evolving graphs generated based on the rolled graph representation is a strong predictor of the actual accuracy value of NNs. For both CIFAR-10 and ImageNet, we show that, by observing only a subset of early training epochs, we can effectively predict the accuracy value of NNs with a small MAE and a high coefficient of determination $R ^ { 2 } > 0 . 5$ .
|
| 147 |
+
|
| 148 |
+
# 4.3 DISCUSSION
|
| 149 |
+
|
| 150 |
+
Time efficiency and early stopping. Figure 6 represents the total average runtime of NN training for early stopping of each architecture (green bars) with comparison of average run-time of graph generation, degree calculation and eigenvector centrality calculation for the number of epochs that were needed rolled graph representation can achieve a high accuracy prediction much faster than the early stopping of NN training. But for unrolled representation, this is only true for LeNet architecture. As the size of NN increases, the unrolled graph generation gets slower and training with early stopping method is faster than our prediction framework.
|
| 151 |
+
|
| 152 |
+
Table 3: Regression Analysis on ImageNet: Accuracy prediction based on the rolled graph representation and the degree-based signature.
|
| 153 |
+
|
| 154 |
+
<table><tr><td></td><td colspan="2">AlexNet</td><td colspan="2">LeNet</td><td colspan="2">ResNet</td></tr><tr><td>Time</td><td>MAE</td><td>R²</td><td>MAE</td><td>R²</td><td>MAE</td><td>R²</td></tr><tr><td>0-3</td><td>1</td><td>1</td><td>4.04</td><td>0.30</td><td>7.99</td><td>0.57</td></tr><tr><td>3-5</td><td>4.10</td><td>0.65</td><td>3.94</td><td>0.34</td><td>8.36</td><td>0.60</td></tr><tr><td>5-7</td><td>3.96</td><td>0.70</td><td>3.58</td><td>0.46</td><td>8.02</td><td>0.62</td></tr><tr><td>7-9</td><td>2.70</td><td>0.84</td><td>3.24</td><td>0.54</td><td>7.49</td><td>0.67</td></tr></table>
|
| 155 |
+
|
| 156 |
+
for that architecture to achieve the highest accuracy in classification task. For all the 3 architectures
|
| 157 |
+
|
| 158 |
+

|
| 159 |
+
Figure 6: Average total runtime for the NN training, and the rolled/unrolled graph generation (S1) and feature extraction (S2) on CIFAR-10 dataset ((a)-(c)), ResNet architecture on both CIFAR-10 (ResNet-44) and ImageNet (ResNet-50)(d). Rolled graph representation is more efficient/faster than early stopping to generate graph and calculate signature vector for all the architectures.
|
| 160 |
+
|
| 161 |
+
Size analysis. Table 5 shows the number of nodes and edges of the rolled graph representations compared with the unrolled representation, our proposed rolled representation of NN reduces the complexity of NN architectures in terms of #nodes and #edges in the graph while retaining comparable performance on the prediction tasks. Our proposed rolled graph representation has big advantage in terms of size over the unrolled graph representation, especially for deeper networks.
|
| 162 |
+
|
| 163 |
+
Limitations. The unrolled representation is not scalable therefore cannot be applicable for larger networks and datasets. The main advantage of this representation is that there is no loss of information during the training phase of NNs, and we can interpret the learning process easier than the rolled method. For example, we showed that the negative subgraph alone would be a stronger predictor of the accuracy of NNs, which can lead us to another direction of signed graph analysis in further study of the learning process of NNs.
|
| 164 |
+
|
| 165 |
+
Complexity analysis of the rolled graph representation. For an NN with $n _ { f }$ total number of filters in all the conv layers and $n _ { n }$ total number of neurons in the fully connected layers, modeling the nodes takes a constant time $O ( | \nu | )$ , where $\nu$ is the set of generated nodes in the graph and $| \mathcal { V } | < = n _ { f } + n _ { n }$ (due to dropout some nodes are removed). The computation of the edge weights is $O ( \sum _ { l } | \mathcal { V } | _ { l } * | \mathcal { V } | _ { l + 1 } )$ , where $| \nu | _ { l }$ are the nodes at layer $l$ .
|
| 166 |
+
|
| 167 |
+
# 5 RELATED WORK
|
| 168 |
+
|
| 169 |
+
We cover the most relevant work here, and dynamic graph mining in App. A.5. Some recent research efforts are devoted to modeling the NN architectures as graphs due to their topological identity and study their graph properties Rieck et al. (2019); Filan et al. (2020); You et al. (2020). For example, You et al. You et al. (2020) propose a relational graph representation to model message exchange between layers, and empirically show the common properties shared by NNs with significantly improved predictive performance in terms of graph clustering coefficients and average path lengths. Rieck et al. Rieck et al. (2019) propose a complexity measure related to NN performance—neural persistence—based on topological data analysis on weighted stratified graph. Filan et al. Filan et al. (2020) present an exploratory study of the NN modularity. Gebhart et al. (2019) proposes to compute persistent homology over the activation graph of an NN. The output is a graded set of subgraphs, which are shown to be related to the task-specific semantic that are captured by original NN.
|
| 170 |
+
|
| 171 |
+
# 6 CONCLUSION
|
| 172 |
+
|
| 173 |
+
In this work, we investigated the early training dynamics of NNs from a time-evolving graph perspective. We proposed a new graph representation to efficiently convert convolutional layers into compact and intuitive graph structures. Then, we showed that a simple, temporal graph signature based on summary statistics of the degree or eigenvector centrality distributions over only a few epochs can be used as a strong predictor variable to estimate the accuracy of NNs in downstream tasks (e.g., image classification). Exploring the role of our efficient proposed framework for early stopping is a promising future direction.
|
| 174 |
+
|
| 175 |
+
# 7 REPRODUCIBILITY STATEMENT
|
| 176 |
+
|
| 177 |
+
For reproducibility, we provide the references to the datasets and existing (rolled) graph representation of convolutional layers in $\ S 4$ . In App. $\ S \operatorname { A } . 1$ , we provide the detailed hyperparameter settings for NN training. We will also make our code publicly available upon acceptance.
|
| 178 |
+
|
| 179 |
+
# REFERENCES
|
| 180 |
+
|
| 181 |
+
Tiny imagenet. https://www.kaggle.com/c/tiny-imagenet/data.
|
| 182 |
+
|
| 183 |
+
Charu Aggarwal and Karthik Subbian. Evolutionary network analysis: A survey. ACM CSUR, 47(1):1–36, 2014.
|
| 184 |
+
|
| 185 |
+
Dzmitry Bahdanau, Kyunghyun Cho, and Yoshua Bengio. Neural machine translation by jointly learning to align and translate. ICLR, 2015.
|
| 186 |
+
|
| 187 |
+
Michele Berlingerio, Danai Koutra, Tina Eliassi-Rad, and Christos Faloutsos. Netsimile: A scalable approach to size-independent network similarity. arXiv preprint arXiv:1209.2684, 2012.
|
| 188 |
+
|
| 189 |
+
Phillip Bonacich. Factoring and weighting approaches to status scores and clique identification. J math soc, 2 (1):113–120, 1972.
|
| 190 |
+
|
| 191 |
+
Yue Cao, Thomas Andrew Geddes, Jean Yee Hwa Yang, and Pengyi Yang. Ensemble deep learning in bioinformatics. Nat Mach Intell, 2(9):500–508, 2020.
|
| 192 |
+
|
| 193 |
+
Supriyo Chakraborty and et al. Interpretability of deep learning models: A survey of results. In SmartWorld, pp. 1–6, 2017. doi: 10.1109/UIC-ATC.2017.8397411.
|
| 194 |
+
|
| 195 |
+
Daniel Filan, Shlomi Hod, Cody Wild, Andrew Critch, and Stuart Russell. Neural networks are surprisingly modular. arXiv preprint arXiv:2003.04881, 2020.
|
| 196 |
+
|
| 197 |
+
Daniel Filan, Stephen Casper, Shlomi Hod, Cody Wild, Andrew Critch, and Stuart Russell. Clusterability in neural networks. arXiv preprint arXiv:2103.03386, 2021.
|
| 198 |
+
|
| 199 |
+
Thomas Gebhart, Paul Schrater, and Alan Hylton. Characterizing the shape of activation space in deep neural networks. In IEEE ICMLA, pp. 1537–1542, 2019.
|
| 200 |
+
|
| 201 |
+
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.
|
| 202 |
+
|
| 203 |
+
Jie Hu, Li Shen, and Gang Sun. Squeeze-and-excitation networks. In CVPR, pp. 7132–7141, 2018. doi: 10.1109/CVPR.2018.00745.
|
| 204 |
+
|
| 205 |
+
Sergey Ioffe and Christian Szegedy. Batch normalization: Accelerating deep network training by reducing internal covariate shift. In ICML, pp. 448–456. PMLR, 2015.
|
| 206 |
+
|
| 207 |
+
Lauri Kovanen, Márton Karsai, Kimmo Kaski, János Kertész, and Jari Saramäki. Temporal motifs in timedependent networks. Journal of Statistical Mechanics: Theory and Experiment, 2011(11):P11005, 2011.
|
| 208 |
+
|
| 209 |
+
Alex Krizhevsky. Learning multiple layers of features from tiny images. pp. 32–33, 2009. URL https: //www.cs.toronto.edu/\~kriz/learning-features-2009-TR.pdf.
|
| 210 |
+
|
| 211 |
+
Alex Krizhevsky, Ilya Sutskever, and Geoffrey E Hinton. Imagenet classification with deep convolutional neural networks. In NeurIPS, 2012.
|
| 212 |
+
|
| 213 |
+
Y. Lecun, L. Bottou, Y. Bengio, and P. Haffner. Gradient-based learning applied to document recognition. Proceedings of the IEEE, 86(11):2278–2324, 1998. doi: 10.1109/5.726791.
|
| 214 |
+
|
| 215 |
+
Hao Li, Asim Kadav, Igor Durdanovic, Hanan Samet, and Hans Peter Graf. Pruning filters for efficient convnets. arXiv preprint arXiv:1608.08710, 2016.
|
| 216 |
+
|
| 217 |
+
Yu Li, Chao Huang, Lizhong Ding, Zhongxiao Li, Yijie Pan, and Xin Gao. Deep learning in bioinformatics: Introduction, application, and perspective in the big data era. Methods, 166:4–21, 2019.
|
| 218 |
+
|
| 219 |
+
Gabriele Lohmann, Daniel S Margulies, Annette Horstmann, Burkhard Pleger, Joeran Lepsien, Dirk Goldhahn, Haiko Schloegl, Michael Stumvoll, Arno Villringer, and Robert Turner. Eigenvector centrality mapping for analyzing connectivity patterns in fmri data of the human brain. PloS one, 5(4):e10232, 2010.
|
| 220 |
+
|
| 221 |
+
Mark EJ Newman. Finding community structure in networks using the eigenvectors of matrices. Physical review E, 74(3):036104, 2006.
|
| 222 |
+
|
| 223 |
+
Ashwin Paranjape, Austin R Benson, and Jure Leskovec. Motifs in temporal networks. In WSDM, pp. 601–610, 2017.
|
| 224 |
+
Aldo Pareja, Giacomo Domeniconi, Jie Chen, Tengfei Ma, Toyotaro Suzumura, Hiroki Kanezashi, Tim Kaler, Tao Schardl, and Charles Leiserson. Evolvegcn: Evolving graph convolutional networks for dynamic graphs. In AAAI, volume 34, pp. 5363–5370, 2020.
|
| 225 |
+
Maithra Raghu, Justin Gilmer, Jason Yosinski, and Jascha Sohl-Dickstein. Svcca: Singular vector canonical correlation analysis for deep learning dynamics and interpretability. In NeurIPS, 2017.
|
| 226 |
+
Bastian Rieck, Matteo Togninalli, Christian Bock, Michael Moor, Max Horn, Thomas Gumbsch, and Karsten Borgwardt. Neural persistence: A complexity measure for deep neural networks using algebraic topology. In ICLR, 2019. URL https://openreview.net/forum?id $=$ ByxkijC5FQ.
|
| 227 |
+
Matteo Riondato, David García-Soriano, and Francesco Bonchi. Graph summarization with quality guarantees. DMKD, 31(2):314–349, 2017.
|
| 228 |
+
Olga Russakovsky, Jia Deng, and et al. ImageNet Large Scale Visual Recognition Challenge. IJCV, 115(3): 211–252, 2015. doi: 10.1007/s11263-015-0816-y.
|
| 229 |
+
Aravind Sankar, Yanhong Wu, Liang Gou, Wei Zhang, and Hao Yang. Dysat: Deep neural representation learning on dynamic graphs via self-attention networks. In WSDM, pp. 519–527, 2020.
|
| 230 |
+
K. Simonyan and A. Zisserman. Very deep convolutional networks for large-scale image recognition. In ICLR, May 2015.
|
| 231 |
+
Uriel Singer, Ido Guy, and Kira Radinsky. Node embedding over temporal graphs. In IJCAI, pp. 4605–4612, 7 2019.
|
| 232 |
+
Ilya Sutskever, Oriol Vinyals, and Quoc V Le. Sequence to sequence learning with neural networks. NeurIPS, 27:3104–3112, 2014.
|
| 233 |
+
Qin Wu, Xingqin Qi, Eddie Fuller, and Cun-Quan Zhang. “follow the leader”: A centrality guided clustering and its application to social network analysis. The Scientific World Journal, 2013, 2013.
|
| 234 |
+
Jiaxuan You, Jure Leskovec, Kaiming He, and Saining Xie. Graph structure of neural networks. In ICML, pp. 10881–10891, 2020.
|
| 235 |
+
Tong Yu and Hong Zhu. Hyper-parameter optimization: A review of algorithms and applications. arXiv preprint arXiv:2003.05689, 2020.
|
| 236 |
+
|
| 237 |
+
# A APPENDIX
|
| 238 |
+
|
| 239 |
+
# A.1 EXPERIMENTAL SETUP: CONFIGURATION
|
| 240 |
+
|
| 241 |
+
We first train five different NN architectures, LeNet-5 (Lecun et al., 1998), VGG13 (Simonyan & Zisserman, 2015), AlexNet (Krizhevsky et al., 2012), ResNet-32 and ResNet-44 (He et al., 2016) , on CIFAR-10 dataset and three architectures, LeNet-5, AlexNet and ResNet-50, on ImageNet. During training, the NN parameters are updated using stochastic gradient descent. On each dataset, we train NNs by combining 48 learning rates $\{ 1 , \bar { 1 } . 5 , \ldots , 4 . 5 \bar \} \times \{ 1 0 ^ { - 6 } , \ldots , 1 0 ^ { - 1 } \}$ , and 10 dropout rates $\{ 0 , 0 . 1 , \ldots , 0 . 9 \}$ . All the models are trained for 50 epochs with batch size 128 and an early stopping method by which the training stops when the testing accuracy does not increase for 10 consecutive epochs. Consequently, we obtain $4 8 0 \mathrm { N N s }$ per architecture and dataset, with diverse performance. Information for the generated NNs is summarized in Table 2: the range of epochs at which the training stops early, the range of final testing accuracy for the trained NNs, and the accuracy threshold used to map actual NN performance to ‘low/high accuracy’ labels for the classification task. We trained the NNs on an Nvidia 1080Ti GPU with 11G memory, and we conducted all the other experiments on 2.60GHz Intel Xeon E5-2697 v3 platform with 1024G memory.
|
| 242 |
+
|
| 243 |
+
For computational efficiency and to avoid having a largely imbalanced dataset, out of the $4 8 0 \mathrm { N N s }$ , we randomly sampled 250 NNs with an even split of high- and low-accuracy networks. For this sample, the first $t$ epochs of training for each configuration were saved as checkpoints to be converted to time-evolving graphs (step (S1)).
|
| 244 |
+
|
| 245 |
+
# A.2 UNROLLED GRAPH REPRESENTATION
|
| 246 |
+
|
| 247 |
+
In these experiments, we split the represented graph into two subgraphs with positive and negative edge weight 1. Then we used the two graphs $\mathbf { G } _ { p o s }$ and ${ \bf G } _ { n e g }$ to calculate the degree and eigenvector centrality feature vector summary for both of them, and concatenate those feature vectors to represent the whole graph $\mathbf { G } _ { p o s - n e g }$ . According to Figure 4, weighted degree signature vector of ${ \bf G } _ { n e g }$ is a good descriptive variable to predict performance of NNs. For LeNet, we achieve an accuracy of $90 \%$ with only 3-5 epochs. For AlexNet, since the graph generation process was slow, we constructed the time-evolving graph based on a few sub-samples of training epochs where $T = 1 , 5 , 1 0 , 1 5$ . The results show that even with a fewer sequence of observations the classifier can achieve a high value of accuracy. For instance, at timestamp 10, in which the feature vector is the concatenation of degree features at epochs 1, 5, and 10, the accuracy of the classifier is more than $8 5 \%$ .
|
| 248 |
+
|
| 249 |
+
Based on results in Figure 11a, signature vector calculated based on eigenvector centrality of ${ \bf G } _ { n e g }$ is also very good descriptive variable to predict performance of NNs and can achieve accuracy of $90 \%$ with only 3-5 epochs for LeNet.
|
| 250 |
+
|
| 251 |
+
For all the experiments on unrolled representation, the feature vector only based on ${ \bf G } _ { n e g }$ achieves very high accuracy similar to or higher than that of $\mathbf { G } _ { p o s - n e g }$ , while feature vectors only based on $\mathbf { G } _ { p o s }$ result in the poorest accuracy among them.
|
| 252 |
+
|
| 253 |
+
# A.3 FEATURE ANALYSIS
|
| 254 |
+
|
| 255 |
+
Classification feature analysis. Figure 7a shows the weight of each statistical aggregator for graph degree of VGG architecture for CIFAR-10. The top three highly weighted features are mean, standard deviation and median of degree. Figures 7b, 7c and 7d represent the change in value of those features respectively over time for high and low accuracy instances. We observe that the statistical aggregator of degree for high accuracy graphs tends to increase over time while for most of low accuracy one these values do not change over time or the change is very small. Figure 8 depicts similar trend for the LeNet architecture, while the values of degree mean and standard deviation for low accuracy cases tend to have a very big spike in the first 3 epochs of training but after that they follow a flat line trend and tend to not change. Figure 9 illustrates similar trend for ResNet-44 architecture and CIFAR-10 dataset. The mode degree of graphs based on high accuracy cases tends to change drastically over time while the low accuracy cases do not change and show a flat line pattern.
|
| 256 |
+
|
| 257 |
+

|
| 258 |
+
Figure 7: VGG on CIFAR-10: (a) The top three most important features in SVM classification are the mean, stdev, and median of the node degrees. (b) The change of the average node degree over time shows that, in graphs corresponding to high-accuracy NNs (blue lines), the average degree exhibits an increasing pattern, while it has a flat pattern for low-accuracy cases (red lines). The few cases of low-accuracy NNs with increasing trend may be miss-classified in the classification task. (c) (d) The changes of the standard deviation and median of node degrees follow a similar pattern to mean for both low- and high-accuracy cases.
|
| 259 |
+
|
| 260 |
+

|
| 261 |
+
Figure 8: LeNet on CIFAR-10: (a) The top three most important features in SVM classification are the mean, standard deviation and median of the node degrees. (b)(d) The change of average node degree over time shows that in graphs corresponding to high-accuracy NNs (blue lines) the average degree tends to change over time with a smooth pattern, while it tends to follow a flat line pattern (after an early extreme spike) for low-accuracy cases (red lines).
|
| 262 |
+
|
| 263 |
+

|
| 264 |
+
Figure 9: ReNet-44 on CIFAR-10: (a) The top three most important features in SVM classification are the mean, standard deviation and median of the node degrees. (b)(d) The change of average node degree over time shows that in graphs corresponding to high-accuracy NNs (blue lines) the average degree tends to change over time drastically, while it tends to follow a flat line pattern for low-accuracy cases (red lines).
|
| 265 |
+
|
| 266 |
+
# A.4 GENERALIZING TO UNSEEN ARCHITECTURES
|
| 267 |
+
|
| 268 |
+
In this section, we broaden the scope of our empirical setup to show that our proposed graph representation and signatures are general and can be useful for performance prediction across different NN architectures. In this setup, we fully train just a small set of different NN architectures (i.e., different architectures and hyperparameters), and predict the performance on unseen NN architectures. We consider two sets of experiments:
|
| 269 |
+
|
| 270 |
+

|
| 271 |
+
(a) CIFAR-10, ResNet-44 (b) ImageNet, ResNet-50 (c) CIFAR-10, ResNet-32 (d) CIFAR-10, ResNet-44
|
| 272 |
+
Figure 10: NN classification based on degree signatures for the empirical setup that tests generalization to unseen architectures. (a) Train on ResNet-32, test on ResNet-44. (b) Train on ResNet-34, test on ResNet-50. (c)-(d) Train on LeNet, AlexNet and VGG, test on ReNet-32 and ResNet-44, respectively. Our proposed framework is able to accurately predict the performance level on previously unseen architectures based on the NN structural dynamics in a small number of epochs $( < 1 0 )$ .
|
| 273 |
+
|
| 274 |
+
1. We train our classifier on the smaller ResNet architectures (ResNet-32 for CIFAR-10, and ResNet34 for ImageNet), and test the performance of the larger ResNet architectures (ResNet-44 for CIFAR-10, and ResNet-50 for ImageNet). In Figs. 10a and 10b, we observe that our proposed framework is able to accurately predict the performance level of the previously unseen, large ResNet architectures. Our results show that the proposed temporal signatures can be used in a generalized scenario to predict the accuracy level of the same architecture with different numbers of layers (on the same dataset). This generalization from small to bigger architectures is important since it is faster to train the smaller architectures.
|
| 275 |
+
|
| 276 |
+
2. In Figs. 10c and 10d, we see that our proposed method also successfully predicts the performance level of a new architecture (i.e. ResNet) when the training set is a combination of older architectures (LeNet, VGG, AlexNet).
|
| 277 |
+
|
| 278 |
+
For both of the experiments, we set a universal threshold value to label graphs in the train and test set. For the training set of classifiers, we randomly choose a subset of the NNs with balanced high/low accuracy labels. The size of the training set in the first experiment is 250 and in the second experiment is 400. The experiments were repeated 5 times and the average accuracy of classification is reported.
|
| 279 |
+
|
| 280 |
+
# A.5 ADDITIONAL RELATED WORK
|
| 281 |
+
|
| 282 |
+
Dynamic Graph Mining. Dynamic graphs are mostly modeled as a sequence of edge additions and/or edge deletions. To mine the dynamic graphs, traditional approaches leverage graph properties such as node centralities or motifs Riondato et al. (2017); Paranjape et al. (2017); Kovanen et al. (2011). Despite their simplicity, these approaches show effectiveness in temporal tasks such as event detection Paranjape et al. (2017) and structural prediction Aggarwal & Subbian (2014). Recent embedding-based approaches tend to model dynamic graphs as a sequence of discrete-time snapshots and simultaneously represent the graph structure of each snapshot as well as the temporal evolution using deep neural networks such as GRU/LSTM Sankar et al. (2020); Singer et al. (2019); Pareja et al. (2020). DySAT Sankar et al. (2020) leverages self-attention to compute node representations by jointly modeling graph structural property and temporal dynamics. EvolveGCN Pareja et al. (2020) uses GCN to generate node embeddings for the past snapshots, and learns parameters of the hidden layer for the next snapshot using GRU/LSTM. Unlike these methods, we propose two different approaches to represent the underlying graph structure of NN, and use a very simple and efficient dynamic graph signature feature vector to predict the accuracy of corresponding NNs.
|
| 283 |
+
|
| 284 |
+

|
| 285 |
+
Figure 11: CIFAR-10: NN classification based on eigenvector centrality-based signatures. The eigenvector centrality is a strong predictor of NN performance after observing a few epochs of training. The MLP classifier (red lines) outperforms SVM for all the architectures.
|
| 286 |
+
|
| 287 |
+

|
| 288 |
+
Figure 12: CIFAR-10, ResNet-32: NN classification based on degree and eigenvector centrality-based signatures. The both degree and eigenvector centrality are strong predictor of NN performance after observing a few epochs of training.
|
| 289 |
+
|
| 290 |
+
Table 5: Size of a generated graph snapshot based on the rolled and unrolled conv layer representation.
|
| 291 |
+
|
| 292 |
+
<table><tr><td rowspan="2" colspan="2"></td><td colspan="5">CIFAR-10</td><td colspan="3">ImageNet</td></tr><tr><td>LeNet</td><td>AlexNet</td><td>VGG</td><td>ResNet32</td><td>ResNet44</td><td>LeNet</td><td>AlexNet</td><td>ResNet50</td></tr><tr><td></td><td>[V|,rolled</td><td>239</td><td>2925</td><td>1613</td><td>1149</td><td>1597</td><td>713</td><td>3015</td><td>22823</td></tr><tr><td></td><td>, rolled</td><td>12954</td><td>1160480</td><td>304576</td><td>51888</td><td>73392</td><td>115 362</td><td>1206560</td><td>10 821824</td></tr><tr><td>V</td><td>,unrolled</td><td>11166</td><td>54986</td><td>205066</td><td></td><td></td><td>11640</td><td>55076</td><td></td></tr><tr><td></td><td>|ε, unrolled</td><td>658024</td><td>45 997 696</td><td>119 714496</td><td></td><td></td><td>843376</td><td>46043 776</td><td></td></tr></table>
|
md/dev/F7nD--1JIC/F7nD--1JIC.md
ADDED
|
@@ -0,0 +1,324 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# SHAPLEY-NAS: DISCOVERING OPERATION CONTRIBUTION FOR NEURAL ARCHITECTURE SEARCH
|
| 2 |
+
|
| 3 |
+
Anonymous authors Paper under double-blind review
|
| 4 |
+
|
| 5 |
+
# ABSTRACT
|
| 6 |
+
|
| 7 |
+
In this paper, we propose a Shapley value based operation contribution evaluation method (Shapley-NAS) for neural architecture search. Differentiable architecture search (DARTS) acquires the expected architectures by optimizing the architecture parameters with gradient descent, which benefits from the high efficiency due to the significantly reduced search cost. However, DARTS leverages the learnable architecture parameters of the supernet to represent the operation importance during the search process, which fails to reveal the actual impacts of operations on the task performance and therefore harms the effectiveness of obtained architectures. On the contrary, we evaluate the direct influence of operations on accuracy via Shapley value for supernet optimization and architecture discretization, so that the optimal architectures are acquired by selecting the operations that contribute significantly to the tasks. Specifically, we iteratively employ Monte-Carlo sampling based algorithm with early truncation to efficiently approximate the Shapley value of operations, and update weights of the supernet whose architecture parameters are assigned with the operation contribution evaluated by Shapley value. At the end of the search process, operations with the largest Shapley value are preserved to form the final architecture. Extensive experiments on CIFAR-10 and ImageNet for image classification and on NAS-Bench-201 for optimal architecture search show that our Shapley-NAS outperforms the state-of-the-art methods by a sizable margin with light search cost.
|
| 8 |
+
|
| 9 |
+
# 1 INTRODUCTION
|
| 10 |
+
|
| 11 |
+
Neural architecture search (NAS) has attracted great interest in deep learning since it discovers the optimal structure from a large search space of network components according to task performance and hardware configurations. However, pioneering works applied reinforcement learning (Zoph & Le, 2016), evolutionary algorithms (Real et al., 2019; Wang et al., 2020) and Bayesian optimization (Liu et al., 2018a) for the architecture search, and the large computational overhead causes heavy search burden that prohibits practical deployment of NAS algorithms. Therefore, it is desirable to design highly efficient search strategies without performance degradation.
|
| 12 |
+
|
| 13 |
+
To reduce the search cost of architecture search, several efficient search strategies have been presented including one-shot NAS (Pham et al., 2018), network transformation (Cai et al., 2018a) and architecture optimization (Luo et al., 2018). Among these approaches, one-shot NAS preserves the optimal sub-networks from the over-parameterized supernet with weight sharing, which prevents the time-consuming exhaustive training for model evaluation. In particular, DARTS (Liu et al., 2018b) converted the discrete operation selection into continuous mixing weights, and utilized the gradient descent to simultaneously optimize the architecture parameters and supernet weights with significantly reduced search cost. However, DARTS methods leverage the learnable architecture parameters to represent the operation importance during search process, which fails to reflect the actual contribution of operations to task performance (Wang et al., 2021b) and degrades the effectiveness of acquired architectures.
|
| 14 |
+
|
| 15 |
+
In this paper, we present a Shapley-NAS method to evaluate the operation contribution via the Shapley value of supernet components for neural architecture search. Unlike existing methods which leverage the learnable architecture parameters to represent the operation importance in joint optimization of supernet weights and architecture parameters, we directly evaluate operation influence on task performance according to the Shapley value of corresponding operations. The operation aggregation in the supernet based on performance contribution enables effective optimization of supernet weights, so that architectures with more promising performance are acquired. Figure 1 shows the difference between our Shapley-NAS and existing DARTS methods. More specifically, we iteratively evaluate the Shapley value for architecture parameter assignments and update the supernet weights. We employ the Monte-Carlo sampling with early truncation for operation set permutations to efficiently approximate the Shapley value of individual operations, and the architecture parameters are determined by the Shapley value that reveals actual component contribution. Moreover, we update the architecture parameters with momentum rather than direct assignment of the Shapley value, so that the fluctuation of operation set permutation sampling in Shapley value approximation is alleviated. We conducted extensive experiments on image classification and optimal architecture search across various search space, where our Shapley-NAS outperforms the state-of-the-art differentiable architecture search methods. We achieve an error rate of $2 . 4 3 \%$ on CIFAR-10 (Krizhevsky et al., 2009) according to the search space of DARTS and obtain the top-1 accuracy of $2 3 . 9 \%$ on ImageNet (Deng et al., 2009) under the mobile setting. Furthermore, our Shapley-NAS acquire the optimal architectures on two datasets and the near-optimal solution on the NAS-Bench-201 benchmark (Dong & Yang, 2020).
|
| 16 |
+
|
| 17 |
+

|
| 18 |
+
Figure 1: The comparison between DARTS and our Shapley-NAS. (a) DARTS constructs a weightsharing supernet which consists of all candidate operations. The architecture parameters are optimized by gradient descent, which can not reflect the actual importance of operations. (b) The proposed Shapley-NAS method directly evaluates operation contribution to the task performance, and updates architecture parameters via the actual influence on accuracy.
|
| 19 |
+
|
| 20 |
+
# 2 RELATED WORK
|
| 21 |
+
|
| 22 |
+
Differentiable NAS: Differentiable architecture search (DARTS) was first proposed by Liu et al. (2018b) with the goal of significant search cost reduction in NAS. They formulated a bi-level objective that simultaneously optimizes the architecture parameters and supernet weights according to the overall objective, so that the efficient gradient descent was leveraged to search the graphical representation of the optimal network architectures. Since DARTS optimizes the single point on the simplex of continuous search space and discretizes the final architecture after search, the generalizability (Chen et al., 2019; Li et al., 2020; Xie et al., 2018; Yu et al., 2019) and the stability (Chen et al., 2020; Chen & Hsieh, 2020; Zhang et al., 2021; Zela et al., 2019; Wang et al., 2021b) are challenged. In order to mitigate the performance gap between the training set and the validation data, SNAS (Xie et al., 2018) and GDAS (Dong & Yang, 2019) adopted the differentiable Gumbel-Softmax (Jang et al., 2016) to imitate the one-hot encoding during architecture discretization. SGAS (Li et al., 2020) chose and pruned the candidate operations based on edge importance, selection certainty and selection stability to alleviate the degenerate of search-evaluation correlation, which reflects the true rankings of operation importance. RobustDARTS (Zela et al., 2019) found that the solutions generalize poorly when they coincide with high validation loss curvature during optimization, which results in significant performance drop after the architecture parameter discretization. Aiming at eliminating the instability in architecture discretization, they performed early stop regularization based on the largest eigenvalue. SmoothDARTS (Chen & Hsieh, 2020) further smoothed the loss landscape via perturbation based regularization including random smoothing and adversarial attack. Moreover, the large memory and computing overheads obstruct the potential efficiency enhancement of the DARTS framework (Yang et al., 2021). To address these, PC-DARTS ( $\mathrm { { X u } }$ et al., 2019) only searched the partially-connected operations to reduce the redundancy in network space exploration, where edge normalization degraded the search uncertainty to prevent edge selecting inconsistency. However, empirical studies (Wang et al., 2021b; Zhou et al., 2021) have demonstrated the learnable architecture parameter in DARTS framework fails to reveal the operation importance in the supernet, which requires effective metrics that fairly evaluate the operation contribution during architecture search.
|
| 23 |
+
|
| 24 |
+
Shapley value: Shapley value has been widely studied in game theory as it fairly evaluates the player contribution in the cooperative system (Roth, 1988; Winter, 2002; Shapley, 2016). Recently, Shapley value was adopted in explainable machine learning to discover the importance of model components, which can be divided into three groups: explaining feature importance (Mase et al., 2019; Lundberg & Lee, 2017; Lundberg et al., 2020; Ancona et al., 2019; Strumbelj & Kononenko, 2010), model component importance (Ancona et al., 2020; Wang et al., 2021a; Ghorbani & Zou, 2020) and data importance (Jia et al., 2019; Yona et al., 2021). For the first regard, Ancona et al. (2019) conducted an axiomatic comparison to show the advantage of the Shapley value over the attribution methods for feature map explanation in deep networks. SHAP (Lundberg & Lee, 2017) presented the additive feature attribution based on the Shapley value of features to acquire higher consistency with human intuition. For model component importance explanation, ShapNets (Wang et al., 2021a) leveraged the Shapley transform that transforms the input into Shapley representations so that the network prediction can be explained during the forward pass. Neuron Shapley (Ghorbani & Zou, 2020) pruned the neurons with the lowest Shapley value for deep networks, so that the model efficiency is significantly strengthened without sizable performance degradation. For the last aspect, Ghorbani & Zou (2019) quantified the contribution of individual data points which identified the outliers and corrupted data. Since computing the exact Shapley value is NP-hard, Monte-Carlo sampling (Ghorbani & Zou, 2019; 2020), perturbation-based approximation (Ancona et al., 2019), influence function and many others were presented for efficient acquisition of Shapley value. In this paper, we extend the Shapley value to operation importance evaluation in DARTS framework, so that the optimal architectures are derived by selecting the operations that contribute significantly to the tasks.
|
| 25 |
+
|
| 26 |
+
# 3 METHODOLOGY
|
| 27 |
+
|
| 28 |
+
In this section, we first briefly introduce differentiable architecture search (DARTS), which suffers from degenerate architectures due to the mismatch between the architecture parameters and operation importance. Then we introduce a fair attribution metric called Shapley value to quantify the relative contribution of operations, and also present the Monte-Carlo sampling algorithm with early truncation for efficient approximation of Shapley value. Finally, we propose Shapley-based architecture search (Shapley-NAS) which can effectively identify the optimal architectures with the most important operations in the large search space.
|
| 29 |
+
|
| 30 |
+
# 3.1 PRELIMINARIES
|
| 31 |
+
|
| 32 |
+
The differentiable architecture search (DARTS) is one of the most popular solutions to identify effective architectures, as it largely reduces the search cost by continuously relaxing the architecture search space. The search space is constructed by repetitions of normal and reduction cells. Each cell is represented by a directed acyclic graph (DAG) with $\mathcal { N }$ nodes and $\mathcal { E }$ edges, where each node $x ^ { ( i ) }$ defines a latent representation and each edge $( i , j )$ is associated with an operation $o ^ { ( i , j ) }$ . The core idea of DARTS is to apply continuous relaxation to the search space to perform gradient-based search. Concretely, the intermediate node is computed as a softmax mixture of candidate operations:
|
| 33 |
+
|
| 34 |
+
$$
|
| 35 |
+
\bar { o } ^ { ( i , j ) } ( x ^ { ( i ) } ) = \sum _ { o \in \mathcal { O } } \frac { \exp ( \alpha _ { o } ^ { ( i , j ) } ) } { \sum _ { o ^ { \prime } \in \mathcal { O } } \exp ( \alpha _ { o ^ { \prime } } ^ { ( i , j ) } ) } o ( x ^ { ( i ) } ) ,
|
| 36 |
+
$$
|
| 37 |
+
|
| 38 |
+
where $\mathcal { O }$ is the set of all candidate operations and $\alpha _ { o } ^ { ( i , j ) }$ denotes the mixing weight for operation $o ^ { ( i , j ) }$ to construct the architecture. With such relaxation, the architecture search can be performed
|
| 39 |
+
|
| 40 |
+
by jointly optimizing the network weight $w$ and architecture parameters $\alpha$ in a differentiable manner with the following bi-level objective:
|
| 41 |
+
|
| 42 |
+
$$
|
| 43 |
+
\operatorname* { m i n } _ { \alpha } \mathcal { L } _ { v a l } ( w ^ { * } , \alpha ) \mathrm { s . t . } w ^ { * } = \arg \operatorname* { m i n } _ { w } \mathcal { L } _ { t r a i n } ( w , \alpha ) .
|
| 44 |
+
$$
|
| 45 |
+
|
| 46 |
+
During the search stage, a weight-sharing supernet containing all these candidate operations is optimized by gradient descent. At the end of the search stage, the final architecture is derived by selecting the operation with the largest architecture parameter $\alpha$ on every edge across all operation choices. This magnitude-based architecture selection process relies on an important assumption that the magnitude of architecture parameters represents the operation importance. However, this assumption has been proved to be untrue in most cases (Wang et al., 2021b), where the value of architecture parameters does not reflect the operation contribution to the performance of the supernet. To alleviate this issue, Wang et al. (2021b) proposes a perturbation-based architecture selection method which measures the operation importance by its discretization accuracy. However, their method greedily selects the best operation and performs discretization on each edge on top of DARTS, which only includes first-order approximation of the supernet and neglects the interactions between different edges.
|
| 47 |
+
|
| 48 |
+
# 3.2 OPERATION IMPORTANCE EVALUATION
|
| 49 |
+
|
| 50 |
+
The architecture parameters optimized by gradient descent can not reflect the actual operation importance. To further validate our assumption, we make a comparison between $\alpha$ and their corresponding performance. We get the stand-alone test accuracy by discretizing the edge to every candidate operation and training the derived architecture from scratch. Figure 2 shows the comparison between $\alpha$ and stand-alone accuracy, where we use different colors to represent their relative rankings and connect the units with the same ranking. As shown, the operation with the largest $\alpha$ does not result in the highest final accuracy and there is no obvious correlation between their rankings.
|
| 51 |
+
|
| 52 |
+
It is crucial to propose a fair attribution metric to evaluate operation contribution instead of relying on values of the architecture parameter $\alpha$ . Due to the complex interactions between operations on different edges, the task performance will change a lot when composed of different subsets of operations. To address this, we model the differentiable architecture search process as a cooperative game. In a cooperative game with a set of $N$ players, a value function $V$ maps each subset of players $S \subseteq N$ to a real value $\bar { V } ( S )$ , which represents the expected payoff a set of the players can obtain by cooperation. In differentiable NAS, the supernet is composed of several layers with identical cell structure, and each cell has $| \dot { \mathcal { E } } |$ edges each with $| \mathcal { O } |$ operations. Therefore, a set of individual operations, $N = \mathcal { O } \times \mathcal { E } =$ $\{ o ^ { ( i , j ) } \} _ { o \in \mathcal { O } , ( i , j ) \in \mathcal { E } }$ , can be modeled as players in the cooperative game, where all players work together towards the supernet’s performance $V ( N )$ . It has been proved that, Shapley value (Roth, 1988; Winter, 2002; Shapley, 2016), denoted as $\phi _ { o } ^ { ( i , j ) }$ in our problem, is the only method that uniquely distributes the total gains of all players $V ( N )$ to each player in $N$ with the following properties:
|
| 53 |
+
|
| 54 |
+
<table><tr><td rowspan="2">Operation</td><td>α</td><td>Stand-alone</td><td rowspan="2">Shapley value (normalized)</td></tr><tr><td>(softmaxed)</td><td>accuracy</td></tr><tr><td>sep_conv_3x3</td><td>0.1038</td><td>97.47%</td><td>0.2487</td></tr><tr><td>sep_conv_5x5</td><td>0.1465</td><td>97.38%</td><td>0.2094</td></tr><tr><td>avg_pool_3x3</td><td>0.1701</td><td>97.34%</td><td>0.1363</td></tr><tr><td>skip_connect</td><td>0.1233</td><td>97.29%</td><td>0.0904</td></tr><tr><td>max_pool_3x3</td><td>0.1841</td><td>97.21%</td><td>0.1078</td></tr><tr><td>dil_conv_3x3</td><td>0.1086</td><td>97.16%</td><td>0.1212</td></tr><tr><td>dil_conv_5x5</td><td>0.1635</td><td>97.02%</td><td>0.0863</td></tr></table>
|
| 55 |
+
|
| 56 |
+
Efficiency The performance of the entire supernet is the sum of contributions of individual operations, i.e. $\sum _ { O ^ { ( i , j ) } \in N } \phi _ { o } ^ { ( i , j ) } = V ( N )$ .
|
| 57 |
+
|
| 58 |
+
Null Player If the operation has no impact on the performance when added to or removed from any subsets of the supernet, then its contribution is zero. That is, if $V ( S ) = V ( S \cup \{ o ^ { ( i , j ) } \} )$ for any operation subset $S \subseteq N \setminus \{ o ^ { ( i , j ) } \}$ , we can derive $\phi _ { o } ^ { ( i , j ) } = 0$ . For example, the zero operation in DARTS search space has no impact on the final performance and thus has zero attribution.
|
| 59 |
+
|
| 60 |
+
Symmetry If two different operations could be exchanged without affecting the performance, they should be assigned with equal contributions. For any operation subset $S \ { \overset { \cdot } { \subseteq } } \ N \setminus \{ o ^ { ( i , j ) } , o ^ { \prime ( k , l ) } \}$ , $V ( S \cup \{ o ^ { ( i , j ) } \} ) = V ( S \cup \{ o ^ { \prime ( k , l ) } \} )$ , then we have $\phi _ { o } ^ { ( i , j ) } = \phi _ { o ^ { \prime } } ^ { ( k , l ) }$ = φ(k,l)o0 .
|
| 61 |
+
|
| 62 |
+
Linearity If the performance metric $\mathrm { v }$ is a linear combination of other metrics (i.e. $V = a \times V _ { 1 } +$
|
| 63 |
+
$b \times V _ { 2 } )$ , the total contribution of each operation also satisfies $\phi _ { o } ^ { ( i , j ) } ( V ) = \phi _ { o } ^ { ( i , j ) } ( V _ { 1 } ) + \phi _ { o } ^ { ( i , j ) } ( V _ { 2 } )$ .
|
| 64 |
+
|
| 65 |
+
The Shapley value of operations provides a fair scheme to quantify the operation contribution as it considers all possible combinations as a weighted mean and accounts for high correlations between individual elements. Therefore, it can help us discover important operations which contribute the most to the task performance during the search process.
|
| 66 |
+
|
| 67 |
+
For operation $o ^ { ( i , j ) }$ in our problem, its Shapley value can be computed as:
|
| 68 |
+
|
| 69 |
+
$$
|
| 70 |
+
\phi _ { o } ^ { ( i , j ) } ( V ) = \frac { 1 } { | N | } \sum _ { S \subseteq N \setminus \{ o ^ { ( i , j ) } \} } \frac { V ( S \cup \{ o ^ { ( i , j ) } \} ) - V ( S ) } { \binom { | N | - 1 } { | S | } }
|
| 71 |
+
$$
|
| 72 |
+
|
| 73 |
+
The operation importance represents the marginal contribution to the accuracy, which is obtained by evaluating the performance difference between all operation permutation and the counterparts without the given operation. Based on (3), we compute the Shapley value of different operations and compare them with stand-alone accuracy in Figure 2. The ranking with Shapley value matches the accuracy ranking very well, which demonstrates that Shapley value is an effective metric for evaluating operation importance, especially for identifying the most important operations.
|
| 74 |
+
|
| 75 |
+
# 3.3 SHAPLEY VALUE APPROXIMATION
|
| 76 |
+
|
| 77 |
+
Although Shapley value is an desirable attribution metric for quantifying the contribution of operations, directly computing Shapley value from (3) requires $2 ^ { | \mathcal { O } | \times | \mathcal { E } | }$ network evaluations caused by enumerating all possible subsets. Therefore, exact computation of Shapley value becomes expensive since $| \mathcal { O } | \times | \mathcal { E } |$ in the common search space is usually large. To efficiently estimate the Shapley value, we present an approximate method based on Monte-Carlo sampling (Castro et al., 2009). Specifically, the Shapley value of operation $o ^ { ( i , j ) }$ is equivalent to estimating the mean of a random variable, which can be written as:
|
| 78 |
+
|
| 79 |
+
$$
|
| 80 |
+
\phi _ { o } ^ { ( i , j ) } ( V ) = \sum _ { R \in \pi ( N ) } \frac { 1 } { N ! } [ V ( R _ { P r e ( o ^ { ( i , j ) } ) } \cup \{ o ^ { ( i , j ) } \} ) - V ( R _ { P r e ( o ^ { ( i , j ) } ) } ) ]
|
| 81 |
+
$$
|
| 82 |
+
|
| 83 |
+
where $\pi ( N )$ denotes the set of permutations of all elements in $N$ , and $R _ { P r e ( o ^ { ( i , j ) } ) }$ is the set of predecessors of $o ^ { ( i , j ) }$ in a given permutation $R \in \pi ( N )$ . Based on (4), we can get an unbiased approximation of every operation’s Shapley value by sampling permutations of operation set $N$ . Notably, the Monte-Carlo estimation reduces the exponential calculation complexity to polynomial time $M \times ( | \mathcal { O } | \times | \mathcal { E } | )$ , where $M$ is the number of samples. Although this sampling-based estimation of Shaley value requires repetitions of accuracy evaluation on the validation set, it only includes the forward process through the supernet and no back-propagation is needed, thus enabling efficient approximation of operation Shapley value.
|
| 84 |
+
|
| 85 |
+
Moreover, when the number of operations in $R _ { P r e ( o ^ { ( i , j ) } ) }$ becomes too small, we find the task performance degrades dramatically and yields unstable sampling results. Therefore, to reduce the fluctuation of Shapley value estimation, we utilize the early truncation technique during the Monte-Carlo sampling procedure. Specifically, when the masked out operations lead to an extreme performance drop exceeding a pre-defined threshold, we break off the current sampling. This early truncation technique also reduces nearly half of computation cost, which makes the overall computational overheads comparable with gradient-based architecture parameter optimization in DARTS. The full algorithm of Shapley value estimation is illustrated in Appendix A.1.
|
| 86 |
+
|
| 87 |
+
# 3.4 SHAPLEY-BASED ARCHITECTURE SEARCH
|
| 88 |
+
|
| 89 |
+
In order to reveal the actual operation importance to performance, we utilize Shapley value of operations to guide the architecture search to find the best solutions. Figure 1 shows the difference between our Shapley-NAS and conventional differential NAS. Rather than updating the architecture parameters by gradient descent in DARTS, we leverage Shapley value to represent the relative strength of operations. Specifically, we use the performance on validation set $\mathcal { L } _ { v a l }$ as the metric $V$ and thus reformulate the bi-level optimization problem in DARTS given in (2) as follows:
|
| 90 |
+
|
| 91 |
+
$$
|
| 92 |
+
\alpha = \phi ( { \mathcal L } _ { v a l } ( w ^ { * } , \alpha ) ) ) \mathrm { s . t . } w ^ { * } = \arg \operatorname* { m i n } _ { w } { \mathcal L } _ { t r a i n } ( w , \alpha ) .
|
| 93 |
+
$$
|
| 94 |
+
|
| 95 |
+
The overall search process can be divided into two stages. At the first stage, we pre-train a supernet by only fine-tuning its network weight $w$ while keeping architecture parameters $\alpha$ frozen. This warm-up process is essential for the initialized Shapley estimation and we keep $\alpha$ frozen to ensure fair comparison. At the second stage, we iteratively optimize the network weight $w$ and the mixing operation weight $\alpha$ according to its Shapley value estimated by the algorithm in Section 3.3:
|
| 96 |
+
|
| 97 |
+
$$
|
| 98 |
+
\alpha _ { t } = \alpha _ { t - 1 } + \epsilon \cdot \frac { s _ { t } } { | | s _ { t } | | _ { 2 } }
|
| 99 |
+
$$
|
| 100 |
+
|
| 101 |
+
where $\alpha _ { t }$ means the architecture parameter in the $t _ { t h }$ step during the optimization, $s _ { t }$ represents the accumulated Shapley value in the $t _ { t h }$ step, $| | \cdot | | _ { 2 }$ is the $L _ { 2 }$ norm and $\epsilon$ is defined as the step size. To reduce undesired fluctuation in updating caused by random sampling, we introduce the momentum into the iteration to stabilize the optimization:
|
| 102 |
+
|
| 103 |
+
$$
|
| 104 |
+
s _ { t } = \mu \cdot s _ { t - 1 } + ( 1 - \mu ) \cdot \frac { \phi ( \mathcal { L } _ { v a l } ( w _ { t - 1 } , \alpha _ { t - 1 } ) ) } { | | \phi ( \mathcal { L } _ { v a l } ( w _ { t - 1 } , \alpha _ { t - 1 } ) ) | | _ { 2 } }
|
| 105 |
+
$$
|
| 106 |
+
|
| 107 |
+
where $\mu$ is the momentum coefficient that balances the accumulated Shapley value and the current sampling result. After the search stage is finished, we derive the final architecture by selecting the operation with the largest contribution on each edge. The detailed algorithm of our Shapley-NAS can be found in Appendix A.2.
|
| 108 |
+
|
| 109 |
+
# 4 EXPERIMENTS
|
| 110 |
+
|
| 111 |
+
In this paper, we conducted extensive experiments to evaluate our method on the DARTS search space with CIFAR-10 (Krizhevsky et al., 2009) and ImageNet (Deng et al., 2009) for image classification, as well as on a widely used NAS benchmark dataset, NAS-Bench-201 (Dong & Yang, 2020). In the following ablation study, we analyzed the effectiveness of the proposed Shapley value evaluation, as well as the influence of hyperparameters on task performance and search cost.
|
| 112 |
+
|
| 113 |
+
4.1 COMPARISON WITH THE STATE-OF-THE-ART NAS METHODS
|
| 114 |
+
|
| 115 |
+
# 4.1.1 RESULTS ON CIFAR-10
|
| 116 |
+
|
| 117 |
+
For the CNN search space in DARTS, we first performed experiments on CIFAR-10 for the image classification task. We employed the same operation space $\mathcal { O }$ as DARTS, constructed the supernet by stacking 8 cells (6 normal cells and 2 reduction cells) and set the initial channel number as 16. We utilized the partial connection strategy in PC-DARTS (Xu et al., 2019) to reduce memory overhead and increase batch size. We set the partial channel parameter $K = 4$ and trained the supernet for 50 epochs with a batch size of 256 on a single GTX 1080Ti GPU (we first finetuned the network weights for 15 epochs to warm up). The training set of CIFAR-10 containing 50K images was divided into two parts with equal size, one for optimizing the network weights and the other for evaluating Shapley value. We set the number of samples $M$ to be 10 in the Monte-Carlo sampling and the early truncation threshold $\eta$ to be 0.5 in each iteration. In momentum-based updating of architecture parameters, the momentum coefficient $\mu$ and step size $\epsilon$ were assigned to 0.8 and 0.1 respectively. At the evaluation phase, We simply followed the DARTS experimental settings for fair comparison and retrained the network from scratch for 600 epochs on the entire 50K training set.
|
| 118 |
+
|
| 119 |
+
Table 1 shows the performance of Shapley-NAS on CIFAR-10 compared with the state-of-the-art NAS methods, and the architecture of searched normal and reduction cells is visualized in Appendix A.4. Our Shapley-NAS achieves an average test error of $2 . 4 7 \%$ while only using 0.3 GPU days, significantly surpassing the DARTS baseline in both search cost and accuracy. The test error of the best single run in our experiments is $2 . 4 3 \%$ , ranking top amongst popular NAS methods. Although ProxylessNAS (Cai et al., 2018b) achieves a lower test error of $2 . 0 8 \%$ , it performs architecture search on a different space with heavy search cost. The low variance of the experimental results also demonstrates the stability of the proposed search method.
|
| 120 |
+
|
| 121 |
+
Table 1: Comparison with state-of-the-art image classifiers on CIFAR-10.
|
| 122 |
+
|
| 123 |
+
<table><tr><td>Architecture</td><td>TestError (%)</td><td>Params (M)</td><td>Search Cost (GPU days)</td><td>Search Method</td></tr><tr><td>DenseNet-BC (Huang et al., 2017)</td><td>3.46</td><td>25.6</td><td>=</td><td>manual</td></tr><tr><td>NASNet-A (Zoph et al., 2018)</td><td>2.65</td><td>3.3</td><td>2000</td><td>RL</td></tr><tr><td>AmoebaNet-A (Real et al.,2019)</td><td>3.34 ± 0.06</td><td>3.2</td><td>3150</td><td>evolution</td></tr><tr><td>AmoebaNet-B (Real et al., 2019)</td><td>2.55 ± 0.05</td><td>2.8</td><td>3150</td><td>evolution</td></tr><tr><td>PNAS (Liu et al., 2018a)</td><td>3.41 ± 0.09</td><td>3.2</td><td>225</td><td>SMBO</td></tr><tr><td>ENAS (Pham et al., 2018)</td><td>2.89</td><td>4.6</td><td>0.5</td><td>RL</td></tr><tr><td>NAONet (Luo et al., 2018)</td><td>3.53</td><td>3.1</td><td>0.4</td><td>NAO</td></tr><tr><td>RandomNAS (Li& Talwalkar,2020)</td><td>2.85±0.08</td><td>4.3</td><td>2.7</td><td>Random</td></tr><tr><td>DARTS (1st order) (Liu et al., 2018b)</td><td>3.00±0.14</td><td>3.3</td><td>0.4</td><td>gradient</td></tr><tr><td>DARTS (2nd order) (Liu et al., 2018b)</td><td>2.76 ± 0.09</td><td>3.3</td><td>1.0</td><td>gradient</td></tr><tr><td>SNAS(moderate) (Xie et al., 2018)</td><td>2.85 ±0.02</td><td>2.8</td><td>1.5</td><td>gradient</td></tr><tr><td>GDAS (Dong & Yang,2019)</td><td>2.93</td><td>3.4</td><td>0.3</td><td>gradient</td></tr><tr><td>BayesNAS (Zhou et al., 2019)</td><td>2.81 ± 0.04</td><td>3.4</td><td>0.2</td><td>gradient</td></tr><tr><td>ProxylessNAS (Cai et al.,2018b)</td><td>2.08</td><td>5.7</td><td>4.0</td><td>gradient</td></tr><tr><td>P-DARTS (Chen et al.,2019)</td><td>2.50</td><td>3.4</td><td>0.3</td><td>gradient</td></tr><tr><td>PC-DARTS (Xu et al., 2019)</td><td>2.57 ± 0.07</td><td>3.6</td><td>0.1</td><td>gradient</td></tr><tr><td>SGAS (Cri 1. avg) (Li et al., 2020)</td><td>2.66 ± 0.24</td><td>3.7</td><td>0.25</td><td>gradient</td></tr><tr><td>SDARTS-RS (Chen &Hsieh,2020)</td><td>2.61 ±0.02</td><td>3.4</td><td>0.4</td><td>gradient</td></tr><tr><td>DrNAS (Chen et al., 2020)</td><td>2.54±0.03</td><td>4.0</td><td>0.4</td><td>gradient</td></tr><tr><td>DARTS+PT(Wang et al., 2021b)</td><td>2.61 ±0.08</td><td>3.0</td><td>0.8</td><td>gradient</td></tr><tr><td>Shapley-NAS(avg.)‡ Shapley-NAS(best)</td><td>2.47 ± 0.04 2.43</td><td>3.4 3.6</td><td>0.3 0.3</td><td>sampling sampling</td></tr></table>
|
| 124 |
+
|
| 125 |
+
‡ Means and standard deviations are obtained by repeated experiments with 4 random seeds.
|
| 126 |
+
|
| 127 |
+
# 4.1.2 RESULTS ON IMAGENET
|
| 128 |
+
|
| 129 |
+
ImageNet contains about 1.2 million training and 50K validation images from 1000 categories, which is much more challenging than CIFAR-10. We randomly sampled $1 0 \%$ and $2 . 5 \%$ images from the entire $1 . 3 { \bf M }$ training set of ImageNet for training network weights and estimating Shapley value respectively. The supernet was trained for 50 epochs with batch size 1024 and the architecture parameters remained frozen in the first 25 epochs. The other hyper-parameters were the same with section 4.1.1. At the evaluation stage, we trained the network from scratch for 250 epochs by an SGD optimizer with a linearly decayed learning rate initialized as 0.5, a momentum of 0.9 and a weight decay of $3 \times 1 0 ^ { - 5 }$ .
|
| 130 |
+
|
| 131 |
+
The comparison results on ImageNet with other methods is demonstrated in Table 2. We trained the best-found architecture on CIFAR-10 on ImageNet to evaluate its transferability. The searched cells on CIFAR-10 achieve a competitive result with $2 4 . 3 \% / 7 . 3 \%$ top-1/5 test error, which verifies the generalization ability of our Shapley-NAS. We also evaluated the optimal architecture directly searched on ImageNet and obtained a top-1/5 test error of $2 3 . 9 \% / 7 . 2 \%$ , which outperforms all other NAS methods with light search cost.
|
| 132 |
+
|
| 133 |
+
# 4.1.3 RESULTS ON NAS-BENCH-201
|
| 134 |
+
|
| 135 |
+
We also performed experiments on the NAS-Bench-201 space to further evaluate the performance of our Shapley NAS. NAS-Bench-201 is a popular benchmark to analyze NAS algorithms, as it provides performance of all candidate architectures which can be directly obtained by querying. In the search space of NAS-Bench-201, the operation set $\mathcal { O }$ has 5 elements and each cell contains 4 nodes, which results in a total search space of 15,625 architectures. NAS-Bench-201 supports three datasets, CIFAR-10, CIFAR-100 and ImageNet-16-120, and more details about the datasets can be found in their paper (Dong & Yang, 2020). Following previous works (Dong & Yang, 2020; Yan et al., 2020), we used the results obtained by training 12 epochs on CIFAR-10, and 200 epochs on CIFAR-100 and ImageNet-16-120. Specifically, we acquired the task-specific performance by directly searching on the evaluation dataset, and report the mean and standard deviation for the best architecture from 4 independent runs with different random seeds.
|
| 136 |
+
|
| 137 |
+
As shown in Table 3, our Shapley-NAS achieves outstanding performance with $9 4 . 3 7 \%$ , $7 3 . 5 1 \%$ and $4 6 . 8 5 \%$ test accuracy on CIFAR-10, CIFAR-100 and ImageNet-16-120 respectively. Notably, we obtain the global optimal architectures on CIFAR-10 and CIFAR-100, which indicates that the proposed method can identify important operations and derive the best architecture from the large search space. On the ImageNet-16-120 dataset, we also acquire a near-optimal solution, which outperforms the state-of-the-art algorithms, again verifying the effectiveness of our Shapley-NAS.
|
| 138 |
+
|
| 139 |
+
Table 2: Comparison with state-of-the-art image classifiers on ImageNet under the mobile setting.
|
| 140 |
+
|
| 141 |
+
<table><tr><td rowspan="2">Architecture</td><td colspan="2">Test Error(%)</td><td rowspan="2">Params (M)</td><td rowspan="2">Search Cost (GPU days)</td><td rowspan="2">Search Method</td></tr><tr><td>top-1</td><td>top-5</td></tr><tr><td>Inception-vl (Szegedy et al.,2015)</td><td>30.1</td><td>10.1</td><td>6.6</td><td>=</td><td>manual</td></tr><tr><td>MobileNet (Howard et al.,2017)</td><td>29.4</td><td>10.5</td><td>4.2</td><td></td><td>manual</td></tr><tr><td>ShuffleNet 2× (v1) (Zhang et al.,2018)</td><td>26.4</td><td>10.2</td><td>~5</td><td></td><td>manual</td></tr><tr><td>ShuffleNet 2× (v2) (Ma et al.,2018)</td><td>25.1</td><td>-</td><td>~5</td><td>=</td><td>manual</td></tr><tr><td>NASNet-A (Zoph et al., 2018)</td><td>26.0</td><td>8.4</td><td>5.3</td><td>2000</td><td>RL</td></tr><tr><td>AmoebaNet-C (Real et al.,2019)</td><td>24.3</td><td>7.6</td><td>6.4</td><td>3150</td><td>evolution</td></tr><tr><td>PNAS (Liu et al., 2018a)</td><td>25.8</td><td>8.1</td><td>5.1</td><td>225</td><td>SMBO</td></tr><tr><td>MnasNet-92 (Tan et al.,2019)</td><td>25.2</td><td>8.0</td><td>4.4</td><td>=</td><td>RL</td></tr><tr><td>DARTS (2nd) (Liu et al.,2018b)</td><td>26.7</td><td>8.7</td><td>4.7</td><td>1.0</td><td>gradient</td></tr><tr><td>SNAS (mild) (Xie et al.,2018)</td><td>27.3</td><td>9.2</td><td>4.3</td><td>1.5</td><td>gradient</td></tr><tr><td>GDAS (Dong & Yang,2019)</td><td>26.0</td><td>8.5</td><td>5.3</td><td>0.3</td><td>gradient</td></tr><tr><td>BayesNAS (Zhou et al., 2019)</td><td>26.5</td><td>8.9</td><td>3.9</td><td>0.2</td><td>gradient</td></tr><tr><td>ProxylessNAS (GPU) (Cai et al.,2018b)†</td><td>24.9</td><td>7.5</td><td>7.1</td><td>8.3</td><td>gradient</td></tr><tr><td>P-DARTS (CIFAR-1O) (Chen et al.,2019)</td><td>24.4</td><td>7.4</td><td>4.9</td><td>0.3</td><td>gradient</td></tr><tr><td>P-DARTS (CIFAR-10O) (Chen et al.,2019)</td><td>24.7</td><td>7.5</td><td>5.1</td><td>0.3</td><td>gradient</td></tr><tr><td>PC-DARTS (CIFAR-1O) (Xu et al., 2019)</td><td>25.1</td><td>7.8</td><td>5.3</td><td>0.1</td><td>gradient</td></tr><tr><td>PC-DARTS (ImageNet) (Xu et al.,2019)t</td><td>24.2</td><td>7.3</td><td>5.3</td><td>3.8</td><td>gradient</td></tr><tr><td>SGAS (Cri 1. best) (Li et al.,2020)</td><td>24.2</td><td>7.2</td><td>5.3</td><td>0.25</td><td>gradient</td></tr><tr><td>SDARTS-ADV (Chen & Hsieh,2020)</td><td>25.6</td><td>8.2</td><td>6.1</td><td>0.4</td><td>gradient</td></tr><tr><td>DrNAS (ImageNet) (Chen et al., 2020)t</td><td>24.2</td><td>7.3</td><td>5.2</td><td>3.9</td><td>gradient</td></tr><tr><td>Shapley-NAS (CIFAR-10)</td><td>24.3</td><td>7.3</td><td>5.1</td><td>0.3</td><td></td></tr><tr><td>Shapley-NAS (ImageNet)+</td><td>23.9</td><td>7.2</td><td>5.4</td><td>4.2</td><td>sampling sampling</td></tr></table>
|
| 142 |
+
|
| 143 |
+
† indicates the results obtained by searching on ImageNet, otherwise on CIFAR-10 or CIFAR-100.
|
| 144 |
+
|
| 145 |
+
Table 3: Comparison results with state-of-the-art NAS methods on NAS-Bench-201.
|
| 146 |
+
|
| 147 |
+
<table><tr><td rowspan="2">Method</td><td colspan="2">CIFAR-10</td><td colspan="2">CIFAR-100</td><td colspan="2">ImageNet-16-120</td></tr><tr><td>validation</td><td>test</td><td>validation</td><td>test</td><td>validation</td><td>test</td></tr><tr><td>ResNet (He et al.,2016)</td><td>90.83</td><td>93.97</td><td>70.42</td><td>70.86</td><td>44.53</td><td>43.63</td></tr><tr><td>Random (baseline)</td><td>90.93±0.36</td><td>93.70±0.36</td><td>70.60± 1.37</td><td>70.65 ± 1.38</td><td>42.92± 2.00</td><td>42.96 ± 2.15</td></tr><tr><td>RSPS (Li& Talwalkar,2020)</td><td>84.16 ± 1.69</td><td>87.66 ± 1.69</td><td>45.78 ±6.33</td><td>46.60±6.57</td><td>31.09 ± 5.65</td><td>30.78 ±6.12</td></tr><tr><td>REINFORCE (Zoph et al.,2018)†</td><td>91.09 ± 0.37</td><td>93.85 ± 0.37</td><td>71.61 ± 1.12</td><td>71.71 ± 1.09</td><td>45.05 ± 1.02</td><td>45.24 ± 1.18</td></tr><tr><td>ENAS (Pham et ail.,2018)</td><td>39.77 ±0.00</td><td>54.30±0.00</td><td>10.23 ± 0.12</td><td>10.62 ± 0.27</td><td>16.43 ±0.00</td><td>16.32±0.00</td></tr><tr><td>DARTS(Liu et al.,2018b)†</td><td>39.77±0.00</td><td>54.30±0.00</td><td>15.03±0.00</td><td>15.61±0.00</td><td>16.43±0.00</td><td>16.32±0.00</td></tr><tr><td>DARTS (Liu et al.,2018b)</td><td>39.77 ± 0.00</td><td>54.30 ± 0.00</td><td>38.57±0.00</td><td>38.97±0.00</td><td>18.87 ±0.00</td><td>18.41 ± 0.00</td></tr><tr><td>SNAS(Xie et al.,2018)</td><td>90.10 ± 1.04</td><td>92.77 ± 0.83</td><td>69.69 ± 2.39</td><td>69.34 ± 1.98</td><td>42.84 ± 1.79</td><td>43.16 ± 2.64</td></tr><tr><td>GDAS (Dong & Yang,2019)</td><td>90.01± 0.46</td><td>93.23±0.23</td><td>24.05 ± 8.12</td><td>24.20±8.08</td><td>40.66±0.00</td><td>41.02 ± 0.00</td></tr><tr><td>PC-DARTS (Xu et al.,2019)</td><td>89.96 ± 0.15</td><td>93.41 ± 0.30</td><td>67.12 ± 0.39</td><td>67.48±0.89</td><td>40.83 ±0.08</td><td>41.31 ± 0.22</td></tr><tr><td>iDARTS (Zhang et al.,2021)t</td><td>89.96 ±0.60</td><td>93.58±0.32</td><td>70.57 ± 0.24</td><td>70.83±0.48</td><td>40.38 ± 0.59</td><td>40.89±0.68</td></tr><tr><td>DrNAS (Chen et al.,2020)</td><td>91.55 ±0.00</td><td>94.36 ±0.00</td><td>73.49 ± 0.00</td><td>73.51 ±0.00</td><td>46.37 ±0.00</td><td>46.34±0.00</td></tr><tr><td>Shapley-NAS</td><td>91.61±0.00</td><td>94.37±0.00</td><td>73.49±0.00</td><td>73.51±0.00</td><td>46.57±0.08</td><td>46.85±0.12</td></tr><tr><td>optimal</td><td>91.61</td><td>94.37</td><td>73.49</td><td>73.51</td><td>46.77</td><td>47.31</td></tr></table>
|
| 148 |
+
|
| 149 |
+
† Results are obtained by searching on CIFAR-10, otherwise by directly searching on the evaluation dataset.
|
| 150 |
+
|
| 151 |
+
# 4.2 ABLATION STUDY
|
| 152 |
+
|
| 153 |
+
Effectiveness of Shapley value evaluation To verify the effectiveness of Shapley-NAS, we conducted experiments on 4 simplified search spaces S1-S4 proposed by Zela et al. (2019) across 3 datasets (CIFAR-10, CIFAR100 and SVHN). For comparison, we built a baseline, DARTS $^ +$ Shapley, by combining the proposed Shapley value evaluation method with DARTS. We took a pretrained supernet from DARTS and applied Shapley value evaluation at the final discretization step, i.e. selecting operations based on their Shapley values instead of $\alpha$ . Moreover, we also tested the performance under the same settings but keeping $\alpha$ frozen, denoted as DARTS $^ +$ Shapley∗. As can be seen from the results in Table 4, DARTS achieves competitive results with the proposed Shapley evaluation method, even when $\alpha$ is not optimized in the training. Notably, our Shapley-NAS still outperforms DARTS $^ +$ Shapley and DARTS $^ +$ Shapley∗, since taking Shapley value into the supernet optimization can further alleviate the problem caused by gradient-based NAS methods.
|
| 154 |
+
|
| 155 |
+
<table><tr><td rowspan="2">Method</td><td colspan="4">C10</td></tr><tr><td>S1</td><td>S2</td><td>S3</td><td>S4</td></tr><tr><td>DARTS</td><td>3.84</td><td>3.11</td><td>2.95</td><td>2.82</td></tr><tr><td>DARTS+Shapley</td><td>4.85</td><td>2.92</td><td>2.84</td><td>2.55</td></tr><tr><td>DARTS+Shapley*</td><td>3.34</td><td>2.58</td><td>2.67</td><td>2.42</td></tr><tr><td>Shapley-NAS</td><td>7.20</td><td>3.45</td><td>2.94</td><td>2.63</td></tr><tr><td rowspan="2">Method</td><td colspan="4">C100</td></tr><tr><td>S1</td><td>S2</td><td>S3</td><td>S4</td></tr><tr><td>DARTS</td><td>29.46</td><td>28.21</td><td>25.24</td><td>23.60</td></tr><tr><td>DARTS+Shapley</td><td>26.05</td><td>24.51</td><td>24.66</td><td>22.77</td></tr><tr><td>DARTS+Shapley*</td><td>28.90</td><td>23.67</td><td>22.39</td><td>21.92</td></tr><tr><td>Shapley-NAS</td><td>22.85</td><td>22.78</td><td>22.15</td><td>21.53</td></tr><tr><td rowspan="2">Method</td><td></td><td colspan="3">SVHN</td></tr><tr><td>S1</td><td>S2</td><td>S3</td><td>S4</td></tr><tr><td>DARTS</td><td>4.58</td><td>2.59</td><td>2.88</td><td>2.36</td></tr><tr><td>DARTS+Shapley</td><td>3.53</td><td>2.72</td><td>2.64</td><td>2.49</td></tr><tr><td>DARTS+Shapley*</td><td>3.41</td><td>2.83</td><td>2.49</td><td>2.34</td></tr><tr><td>Shapley-NAS</td><td>3.05</td><td>2.65</td><td>2.58</td><td>2.41</td></tr></table>
|
| 156 |
+
|
| 157 |
+

|
| 158 |
+
Figure 3: The test error $( \% )$ and search cost (GPU days) of the proposed method on CIFAR-10 with (a) different sampling times and (b) various thresholds of early truncation in the Shapley value estimation.
|
| 159 |
+
|
| 160 |
+
Table 4: The test $\mathrm { e r r o r } ( \% )$ of different search algorithms on S1-S4. DARTS $^ +$ Shapley denotes the combination of DARTS and Shapley value evaluation, and $^ *$ means freezing $\alpha$ during the search.
|
| 161 |
+
|
| 162 |
+
Table 5: The test error $( \% )$ and parameter storage cost (M) of the final architectures w.r.t. different values of momentum coefficient $\mu$ and different assignments of step size $\epsilon$ .
|
| 163 |
+
|
| 164 |
+
<table><tr><td rowspan="2">step size e</td><td colspan="2">μ=0.2</td><td colspan="2">μ=0.5</td><td colspan="2">μ=0.8</td><td colspan="2">μ=0.9</td></tr><tr><td>Test Error(%)</td><td>Params(M)</td><td>Test Error(%)</td><td>Params(M)</td><td>Test Error(%)</td><td>Params(M)</td><td>Test Error(%)</td><td>Params(M)</td></tr><tr><td>0.01</td><td>2.89± 0.21</td><td>4.0</td><td>2.87± 0.16</td><td>3.7</td><td>2.67±0.06</td><td>3.5</td><td>2.74 ± 0.11</td><td>3.8</td></tr><tr><td>0.05</td><td>2.85± 0.18</td><td>3.6</td><td>2.79 ±0.12</td><td>3.4</td><td>2.55 ±0.07</td><td>3.2</td><td>2.68± 0.07</td><td>3.5</td></tr><tr><td>0.1</td><td>2.82 ± 0.11</td><td>3.7</td><td>2.66 ± 0.10</td><td>3.3</td><td>2.47 ± 0.04</td><td>3.4</td><td>2.61± 0.06</td><td>4.1</td></tr><tr><td>0.5</td><td>2.92 ± 0.19</td><td>3.5</td><td>2.84±0.13</td><td>4.2</td><td>2.71 ± 0.12</td><td>3.8</td><td>2.83± 0.15</td><td>3.9</td></tr></table>
|
| 165 |
+
|
| 166 |
+
Influence of sampling times $M$ and early truncation threshold $\eta$ We also explored the influence of sampling times $M$ and early truncation threshold $\eta$ in the Monte-Carlo sampling algorithm. The values of sampling times $M$ and early truncation threshold $\eta$ are significant for accurate Shapley value estimation, which also affect the overall search cost. Figure 3 shows the test error $( \% )$ and search cost (GPU days) on CIFAR-10 with various $M$ and $\eta$ . Reducing number of samples results in lower search cost while degrades the performance since the sampling is not enough to make accurate estimation. However, the estimation accuracy with samples larger than 10 is not sensitive to number of samples, and we choose $M = 1 0$ for search efficiency. Meanwhile, medium $\eta$ also achieves the best accuracy-complexity trade-off as it mitigates the fluctuation in sampling as well as reducing the search cost.
|
| 167 |
+
|
| 168 |
+
Impact of momentum coefficient $\mu$ and step size $\epsilon$ To investigate the influence of momentum coefficient $\mu$ and step size $\epsilon$ on search accuracy, we implemented the architecture parameter assignment with different $\mu$ and $\epsilon$ . The test error range and model parameter cost is demonstrated in Table 5, where medium $\epsilon$ outperforms other values. Small step sizes fail to achieve the optimal distribution when reaching the maximum update iterations, and large step sizes make the supernet optimization hard to converge. With the increase of $\mu$ , the training stabilization becomes enforced, where $\mu$ with 0.8 achieves the best accuracy.
|
| 169 |
+
|
| 170 |
+
# 5 CONCLUSION
|
| 171 |
+
|
| 172 |
+
In this paper, we have presented Shapley-NAS, a Shapley value based operation contribution evaluation method for neural architecture search. Since the learnable architecture parameters in DARTS can not reveal the actual importance of operations on the task performance, we propose to evaluate the marginal contribution of operations on accuracy via Shapley value. Specifically, the Shapley value of operations can be efficiently approximated by Monte-Carlo sampling based algorithm with early truncation, and thus enabling the optimization of the supernet whose architecture parameters are directly updated with the operation contribution. Shapley-NAS achieves state-of-the-art performance on CIFAR-10, ImageNet and NAS-Bench-201 benchmarks, which proves its effectiveness to identify the optimal architectures with the most important operations in neural architecture search.
|
| 173 |
+
|
| 174 |
+
# REFERENCES
|
| 175 |
+
|
| 176 |
+
Marco Ancona, Cengiz Oztireli, and Markus Gross. Explaining deep neural networks with a polynomial time algorithm for shapley value approximation. In ICML, pp. 272–281, 2019.
|
| 177 |
+
|
| 178 |
+
Marco Ancona, Cengiz Oztireli, and Markus Gross. Shapley value as principled metric for structured ¨ network pruning. arXiv preprint arXiv:2006.01795, 2020.
|
| 179 |
+
|
| 180 |
+
Han Cai, Tianyao Chen, Weinan Zhang, Yong Yu, and Jun Wang. Efficient architecture search by network transformation. In AAAI, volume 32, 2018a.
|
| 181 |
+
|
| 182 |
+
Han Cai, Ligeng Zhu, and Song Han. Proxylessnas: Direct neural architecture search on target task and hardware. arXiv preprint arXiv:1812.00332, 2018b.
|
| 183 |
+
|
| 184 |
+
Javier Castro, Daniel Gomez, and Juan Tejada. Polynomial calculation of the shapley value based ´ on sampling. Computers & Operations Research, 36(5):1726–1730, 2009.
|
| 185 |
+
|
| 186 |
+
Xiangning Chen and Cho-Jui Hsieh. Stabilizing differentiable architecture search via perturbationbased regularization. In ICML, pp. 1554–1565, 2020.
|
| 187 |
+
|
| 188 |
+
Xiangning Chen, Ruochen Wang, Minhao Cheng, Xiaocheng Tang, and Cho-Jui Hsieh. Drnas: Dirichlet neural architecture search. arXiv preprint arXiv:2006.10355, 2020.
|
| 189 |
+
|
| 190 |
+
Xin Chen, Lingxi Xie, Jun Wu, and Qi Tian. Progressive differentiable architecture search: Bridging the depth gap between search and evaluation. In ICCV, pp. 1294–1303, 2019.
|
| 191 |
+
|
| 192 |
+
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, 2009.
|
| 193 |
+
|
| 194 |
+
Terrance DeVries and Graham W Taylor. Improved regularization of convolutional neural networks with cutout. arXiv preprint arXiv:1708.04552, 2017.
|
| 195 |
+
|
| 196 |
+
Xuanyi Dong and Yi Yang. Searching for a robust neural architecture in four gpu hours. In CVPR, pp. 1761–1770, 2019.
|
| 197 |
+
|
| 198 |
+
Xuanyi Dong and Yi Yang. Nas-bench-201: Extending the scope of reproducible neural architecture search. arXiv preprint arXiv:2001.00326, 2020.
|
| 199 |
+
|
| 200 |
+
Amirata Ghorbani and James Zou. Data shapley: Equitable valuation of data for machine learning. In ICML, pp. 2242–2251, 2019.
|
| 201 |
+
|
| 202 |
+
Amirata Ghorbani and James Zou. Neuron shapley: Discovering the responsible neurons. arXiv preprint arXiv:2002.09815, 2020.
|
| 203 |
+
|
| 204 |
+
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.
|
| 205 |
+
|
| 206 |
+
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.
|
| 207 |
+
|
| 208 |
+
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.
|
| 209 |
+
|
| 210 |
+
Eric Jang, Shixiang Gu, and Ben Poole. Categorical reparameterization with gumbel-softmax. arXiv preprint arXiv:1611.01144, 2016.
|
| 211 |
+
|
| 212 |
+
Ruoxi Jia, David Dao, Boxin Wang, Frances Ann Hubis, Nick Hynes, Nezihe Merve Gurel, Bo Li, ¨ Ce Zhang, Dawn Song, and Costas J Spanos. Towards efficient data valuation based on the shapley value. In The 22nd International Conference on Artificial Intelligence and Statistics, pp. 1167–1176, 2019.
|
| 213 |
+
|
| 214 |
+
Alex Krizhevsky, Geoffrey Hinton, et al. Learning multiple layers of features from tiny images. 2009.
|
| 215 |
+
|
| 216 |
+
Guohao Li, Guocheng Qian, Itzel C Delgadillo, Matthias Muller, Ali Thabet, and Bernard Ghanem. Sgas: Sequential greedy architecture search. In CVPR, pp. 1620–1630, 2020.
|
| 217 |
+
|
| 218 |
+
Liam Li and Ameet Talwalkar. Random search and reproducibility for neural architecture search. In Uncertainty in artificial intelligence, pp. 367–377. PMLR, 2020.
|
| 219 |
+
|
| 220 |
+
Chenxi Liu, Barret Zoph, Maxim Neumann, Jonathon Shlens, Wei Hua, Li-Jia Li, Li Fei-Fei, Alan Yuille, Jonathan Huang, and Kevin Murphy. Progressive neural architecture search. In ECCV, pp. 19–34, 2018a.
|
| 221 |
+
|
| 222 |
+
Hanxiao Liu, Karen Simonyan, and Yiming Yang. Darts: Differentiable architecture search. arXiv preprint arXiv:1806.09055, 2018b.
|
| 223 |
+
|
| 224 |
+
Scott M Lundberg and Su-In Lee. A unified approach to interpreting model predictions. In NeurIPS, pp. 4768–4777, 2017.
|
| 225 |
+
|
| 226 |
+
Scott M Lundberg, Gabriel Erion, Hugh Chen, Alex DeGrave, Jordan M Prutkin, Bala Nair, Ronit Katz, Jonathan Himmelfarb, Nisha Bansal, and Su-In Lee. From local explanations to global understanding with explainable ai for trees. Nature machine intelligence, 2(1):56–67, 2020.
|
| 227 |
+
|
| 228 |
+
Renqian Luo, Fei Tian, Tao Qin, Enhong Chen, and Tie-Yan Liu. Neural architecture optimization. arXiv preprint arXiv:1808.07233, 2018.
|
| 229 |
+
|
| 230 |
+
Ningning Ma, Xiangyu Zhang, Hai-Tao Zheng, and Jian Sun. Shufflenet v2: Practical guidelines for efficient cnn architecture design. In Proceedings of the European conference on computer vision (ECCV), pp. 116–131, 2018.
|
| 231 |
+
|
| 232 |
+
Masayoshi Mase, Art B Owen, and Benjamin Seiler. Explaining black box decisions by shapley cohort refinement. arXiv preprint arXiv:1911.00467, 2019.
|
| 233 |
+
|
| 234 |
+
Hieu Pham, Melody Guan, Barret Zoph, Quoc Le, and Jeff Dean. Efficient neural architecture search via parameters sharing. In ICML, pp. 4095–4104, 2018.
|
| 235 |
+
|
| 236 |
+
Esteban Real, Alok Aggarwal, Yanping Huang, and Quoc V Le. Regularized evolution for image classifier architecture search. In AAAI, volume 33, pp. 4780–4789, 2019.
|
| 237 |
+
|
| 238 |
+
Alvin E Roth. The Shapley value: essays in honor of Lloyd S. Shapley. Cambridge University Press, 1988.
|
| 239 |
+
|
| 240 |
+
Lloyd S Shapley. 17. A value for n-person games. Princeton University Press, 2016.
|
| 241 |
+
|
| 242 |
+
Erik Strumbelj and Igor Kononenko. An efficient explanation of individual classifications using game theory. The Journal of Machine Learning Research, 11:1–18, 2010.
|
| 243 |
+
|
| 244 |
+
Christian Szegedy, Wei Liu, Yangqing Jia, Pierre Sermanet, Scott Reed, Dragomir Anguelov, Dumitru Erhan, Vincent Vanhoucke, and Andrew Rabinovich. Going deeper with convolutions. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 1–9, 2015.
|
| 245 |
+
|
| 246 |
+
Mingxing Tan, Bo Chen, Ruoming Pang, Vijay Vasudevan, Mark Sandler, Andrew Howard, and Quoc V Le. Mnasnet: Platform-aware neural architecture search for mobile. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 2820–2828, 2019.
|
| 247 |
+
|
| 248 |
+
Rui Wang, Xiaoqian Wang, and David I Inouye. Shapley explanation networks. arXiv preprint arXiv:2104.02297, 2021a.
|
| 249 |
+
|
| 250 |
+
Ruochen Wang, Minhao Cheng, Xiangning Chen, Xiaocheng Tang, and Cho-Jui Hsieh. Rethinking architecture selection in differentiable nas. arXiv preprint arXiv:2108.04392, 2021b.
|
| 251 |
+
|
| 252 |
+
Tianzhe Wang, Kuan Wang, Han Cai, Ji Lin, Zhijian Liu, Hanrui Wang, Yujun Lin, and Song Han. Apq: Joint search for network architecture, pruning and quantization policy. In CVPR, pp. 2078– 2087, 2020.
|
| 253 |
+
|
| 254 |
+
Eyal Winter. The shapley value. Handbook of game theory with economic applications, 3:2025– 2054, 2002.
|
| 255 |
+
|
| 256 |
+
Sirui Xie, Hehui Zheng, Chunxiao Liu, and Liang Lin. Snas: stochastic neural architecture search. arXiv preprint arXiv:1812.09926, 2018.
|
| 257 |
+
|
| 258 |
+
Yuhui Xu, Lingxi Xie, Xiaopeng Zhang, Xin Chen, Guo-Jun Qi, Qi Tian, and Hongkai Xiong. Pc-darts: Partial channel connections for memory-efficient architecture search. arXiv preprint arXiv:1907.05737, 2019.
|
| 259 |
+
|
| 260 |
+
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.
|
| 261 |
+
|
| 262 |
+
Yibo Yang, Shan You, Hongyang Li, Fei Wang, Chen Qian, and Zhouchen Lin. Towards improving the consistency, efficiency, and flexibility of differentiable neural architecture search. In CVPR, pp. 6667–6676, 2021.
|
| 263 |
+
|
| 264 |
+
Gal Yona, Amirata Ghorbani, and James Zou. Who’s responsible? jointly quantifying the contribution of the learning algorithm and data. In Proceedings of the 2021 AAAI/ACM Conference on AI, Ethics, and Society, pp. 1034–1041, 2021.
|
| 265 |
+
|
| 266 |
+
Kaicheng Yu, Christian Sciuto, Martin Jaggi, Claudiu Musat, and Mathieu Salzmann. Evaluating the search phase of neural architecture search. arXiv preprint arXiv:1902.08142, 2019.
|
| 267 |
+
|
| 268 |
+
Arber Zela, Thomas Elsken, Tonmoy Saikia, Yassine Marrakchi, Thomas Brox, and Frank Hutter. Understanding and robustifying differentiable architecture search. arXiv preprint arXiv:1909.09656, 2019.
|
| 269 |
+
|
| 270 |
+
Miao Zhang, Steven Su, Shirui Pan, Xiaojun Chang, Ehsan Abbasnejad, and Reza Haffari. idarts: Differentiable architecture search with stochastic implicit gradients. arXiv preprint arXiv:2106.10784, 2021.
|
| 271 |
+
|
| 272 |
+
Xiangyu Zhang, Xinyu Zhou, Mengxiao Lin, and Jian Sun. Shufflenet: An extremely efficient convolutional neural network for mobile devices. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 6848–6856, 2018.
|
| 273 |
+
|
| 274 |
+
Hongpeng Zhou, Minghao Yang, Jun Wang, and Wei Pan. Bayesnas: A bayesian approach for neural architecture search. In International Conference on Machine Learning, pp. 7603–7613. PMLR, 2019.
|
| 275 |
+
|
| 276 |
+
Yuan Zhou, Xukai Xie, and Sun-Yuan Kung. Exploiting operation importance for differentiable neural architecture search. TNNLS, 2021.
|
| 277 |
+
|
| 278 |
+
Barret Zoph and Quoc V Le. Neural architecture search with reinforcement learning. arXiv preprint arXiv:1611.01578, 2016.
|
| 279 |
+
|
| 280 |
+
Barret Zoph, Vijay Vasudevan, Jonathon Shlens, and Quoc V Le. Learning transferable architectures for scalable image recognition. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 8697–8710, 2018.
|
| 281 |
+
|
| 282 |
+
# A APPENDIX
|
| 283 |
+
|
| 284 |
+
A.1 THE MONTE-CARLO SAMPLING ALGORITHM FOR SHAPLEY VALUE ESTIMATION
|
| 285 |
+
|
| 286 |
+
# Algorithm 1: Estimating Shapley value of operations
|
| 287 |
+
|
| 288 |
+
Input: Supernet components $N = \mathcal { O } \times \mathcal { E } = \{ o ^ { ( i , j ) } \} _ { \mathcal { o } \in \mathcal { O } , ( i , j ) \in \mathcal { E } }$ , performance evaluation metric $V$ , sampling times $M$ , early truncation threshold $\eta$
|
| 289 |
+
Output: Shapley value of operations $\{ \phi _ { o } ^ { ( i , j ) } \} _ { o \in \mathcal { O } , ( i , j ) \in \mathcal { E } }$
|
| 290 |
+
Initialization:Shapley of operation $\{ \phi _ { o } ^ { ( i , j ) } \} = 0$ , $t = 0$ .
|
| 291 |
+
while $t < M$ do Randomly generate a permutation $R$ of $N$ ; $v _ { 0 } = V ( N )$ ; for $k = 1 , 2 , . . . , | N |$ do if $v _ { k - 1 } > \eta \cdot V ( N )$ and $R [ k ] \neq z e r o$ then mask out operation $R [ k ]$ and re-evaluate the validation accuracy $V$ ; Update $v _ { k }$ $: v _ { k } = V ( \bar { R } [ \bar { k } + 1 ] , R [ k + 2 ] , . . . , R [ n ] )$ ; end else vk = vk−1 end $\phi _ { R [ k ] } = \phi _ { R [ k ] } + ( v _ { k - 1 } - v _ { k } )$ end
|
| 292 |
+
end
|
| 293 |
+
Return φ(i,j)o $\phi _ { o } ^ { ( i , j ) } = \phi _ { o } ^ { ( i , j ) } / M$ , for $o ^ { ( i , j ) } \in N$ .
|
| 294 |
+
|
| 295 |
+
# Algorithm 2: Shapley-NAS
|
| 296 |
+
|
| 297 |
+
Input: Initialized supernet weights $w _ { 0 }$ and architecture parameters $\alpha _ { 0 }$ , warm-up epochs $\mathcal { T } _ { 1 }$ , search epochs $\mathcal { T } _ { 2 }$ , momentum efficient $\mu$ , step size $\epsilon$ .
|
| 298 |
+
Output: The final architecture with chosen operation on every edge $\left\{ o _ { \left( i , j \right) } \right\}$ .
|
| 299 |
+
Initialization:accumulated Shapley $s _ { 0 } = 0$ , $t = 0$ .
|
| 300 |
+
Stage 1 (Warm-up)
|
| 301 |
+
while $t < \mathcal { T } _ { 1 }$ do Update supernet weights $w _ { t }$ by descending $\nabla _ { w } \mathcal { L } _ { t r a i n } \big ( w _ { t - 1 } , \alpha _ { t - 1 } \big )$ ; $t = t + 1$ ;
|
| 302 |
+
end
|
| 303 |
+
Stage 2 (Architecture Search)
|
| 304 |
+
while $t < \tau _ { 2 }$ do Update supernet weights $w _ { t }$ by descending $\nabla _ { w } \mathcal { L } _ { t r a i n } \big ( w _ { t - 1 } , \alpha _ { t - 1 } \big )$ ; Estimate the Shapley value $\phi \big ( \mathcal { L } _ { v a l } \big ( w _ { t - 1 } , \alpha _ { t - 1 } \big ) \big )$ by Monte-Carlo sampling according to Algorithm 1; Compute the accumulated Shapley value: st = µ · st−1 + (1 − µ) · φ(Lval(wt−1,αt−1))||φ(Lval(wt−1,αt−1))||2 ; Update architecture parameters: $\begin{array} { r } { \alpha _ { t } = \alpha _ { t - 1 } + \epsilon \cdot \frac { s _ { t } } { | | s _ { t } | | _ { 2 } } } \end{array}$ ; $t = t + 1$ ;
|
| 305 |
+
end
|
| 306 |
+
Derive the final architecture through argmax: $o ^ { ( i , j ) } = \arg \operatorname* { m a x } _ { o \in \mathcal { O } } \alpha _ { o } ^ { ( i , j ) }$ .
|
| 307 |
+
|
| 308 |
+
# A.3 TRAINING DETAILS
|
| 309 |
+
|
| 310 |
+
CIFAR-10 The CIFAR-10 dataset includes 60K images equally divided into 10 classes, all of which are with the size of $3 2 \times 3 2$ . We keep the same operation space $\mathcal { O }$ as DARTS, including $3 \times 3$ and $5 \times 5$ separable convolutions, $3 \times 3$ and $5 \times 5$ dilated separable convolutions, $3 \times 3$ max pooling, $3 \times 3$ average pooling, skip connect (i.e., identity) and zero (i.e., none). At the search phase, we construct the supernet by stacking 8 cells (6 normal cells and 2 reduction cells) and set the initial channel number as 16. Each cell has $N = 7$ nodes (2 input nodes, 4 intermediate nodes and 1 output nodes). The reduction cells are placed at the $1 / 3$ and $2 / 3$ of the total depth of the network. At the evaluation phase, we stack 20 cells including 18 normal cells and 2 reduction cells with initial channel number being 36 to form the architecture. Then we retrain the network from scratch for 600 epochs on the entire 50K training set. We employ the SGD optimizer with a cosine annealing learning rate initialized as 0.025, a momentum of 0.9 and a weight decay of $3 \times 1 0 ^ { - 4 }$ . We also use the cutout with length 16 (DeVries & Taylor, 2017) and drop-path (Zoph et al., 2018) with a rate of 0.3 for regularization.
|
| 311 |
+
|
| 312 |
+
ImageNet Different from the architecture for CIFAR-10, the network for ImageNet starts with three convolution layers with stride of 2 which reduce the input resolution from $2 2 4 \times 2 2 4$ to $2 8 \times 2 8$ following previous works (Xu et al., 2019; Chen et al., 2019). At the evaluation stage, the network is composed of 14 cells (18 normal cells and 2 reduction cells) and the initial channel number is 48. We train the network from scratch for 250 epochs by an SGD optimizer with a linearly decayed learning rate initialized as 0.5, a momentum of 0.9 and a weight decay of $3 \times 1 0 ^ { - 5 }$ . Similar to previous works (Xu et al., 2019; Chen et al., 2019), label smoothing and an auxiliary loss tower are employed during the training.
|
| 313 |
+
|
| 314 |
+
NAS-Bench-201 In the search space of NAS-Bench-201, the operation set $\mathcal { O }$ has 5 elements (zero, skip connection, $1 \times 1$ and $3 \times 3$ convolution, and $3 \times 3$ average pooling) and each cell contains 4 nodes, which results in a total search space of 15,625 architectures. NAS-Bench-201 supports three datasets, CIFAR-10, CIFAR-100 and ImageNet-16-120, and we use the results obtained by training 12 epochs on CIFAR-10, and 200 epochs on CIFAR-100 and ImageNet-16-120. Specifically, we evaluate the task-specific performance by directly searching on the evaluation dataset. We keep the hyper-parameters in the search and evaluation phase the same as CIFAR-10, and report the mean and standard deviation for the best architecture from 4 independent runs with different random seeds.
|
| 315 |
+
|
| 316 |
+
# A.4 SEARCHED ARCHITECTURES ON CIFAR-10
|
| 317 |
+
|
| 318 |
+

|
| 319 |
+
Figure 4: Normal and Reduction cells discovered by Shapley-NAS on CIFAR-10
|
| 320 |
+
|
| 321 |
+
# A.5 SEARCHED ARCHITECTURES ON IMAGENET
|
| 322 |
+
|
| 323 |
+

|
| 324 |
+
Figure 5: Normal and Reduction cells discovered by Shapley-NAS on ImageNet
|
md/dev/GGi4igGZEB-/GGi4igGZEB-.md
ADDED
|
@@ -0,0 +1,856 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Characteristic Neural Ordinary Differential Equations
|
| 2 |
+
|
| 3 |
+
Anonymous Author(s)
|
| 4 |
+
Affiliation
|
| 5 |
+
Address
|
| 6 |
+
email
|
| 7 |
+
|
| 8 |
+
# Abstract
|
| 9 |
+
|
| 10 |
+
1 We propose Characteristic-Neural Ordinary Differential Equations (C-NODEs), a
|
| 11 |
+
2 framework for extending Neural Ordinary Differential Equations (NODEs) beyond
|
| 12 |
+
3 ODEs. While NODEs model the evolution of latent variables as the solution to an
|
| 13 |
+
4 ODE, C-NODE models the evolution of the latent variables as the solution of a
|
| 14 |
+
5 family of first-order quasi-linear partial differential equations (PDEs) along curves
|
| 15 |
+
6 on which the PDEs reduce to ODEs, referred to as characteristic curves. This in
|
| 16 |
+
7 turn allows the application of the standard frameworks for solving ODEs, namely
|
| 17 |
+
8 the adjoint method. Learning optimal characteristic curves for given tasks improves
|
| 18 |
+
9 the performance and computational efficiency, compared to state of the art NODE
|
| 19 |
+
10 models. We prove that the C-NODE framework extends the classical NODE on
|
| 20 |
+
11 classification tasks by demonstrating explicit C-NODE representable functions
|
| 21 |
+
12 not expressible by NODEs. Additionally, we present C-NODE-based continuous
|
| 22 |
+
13 normalizing flows, which describe the density evolution of latent variables along
|
| 23 |
+
14 multiple dimensions. Empirical results demonstrate the improvements provided
|
| 24 |
+
15 by the proposed method for classification and density estimation on CIFAR-10,
|
| 25 |
+
16 SVHN, and MNIST datasets under a similar computational budget as the existing
|
| 26 |
+
17 NODE methods. The results also provide empirical evidence that the learned
|
| 27 |
+
18 curves improve the efficiency of the system through a lower number of parameters
|
| 28 |
+
19 and function evaluations compared with baselines.
|
| 29 |
+
|
| 30 |
+
# 20 1 Introduction
|
| 31 |
+
|
| 32 |
+
21 Deep learning and differential equations share many connections, and techniques in the intersection
|
| 33 |
+
22 have led to insights in both fields. One predominant connection is based on certain neural network
|
| 34 |
+
23 architectures resembling numerical integration schemes, leading to the development of Neural
|
| 35 |
+
24 Ordinary Differential Equations (NODEs) [5]. NODEs use a neural network parameterization of
|
| 36 |
+
25 an ODE to learn a mapping from observed variables to a latent variable that is the solution to the
|
| 37 |
+
26 learned ODE. A central benefit of NODEs is the constant memory cost, where backward passes are
|
| 38 |
+
27 computed using the adjoint sensitivity method rather than backpropagating through individual forward
|
| 39 |
+
28 solver steps. Backpropagating through adaptive differential equation solvers to train large NODEs
|
| 40 |
+
29 will often result in memory outage, as mentioned in [5]. Moreover, NODEs provide a flexible
|
| 41 |
+
30 probability density representation often referred to as continuous normalizing flows (CNFs). However,
|
| 42 |
+
31 since NODEs can only represent solutions to ODEs, the class of functions is somewhat limited
|
| 43 |
+
32 and may not apply to more general problems that do not have smooth and one-to-one mappings.
|
| 44 |
+
33 To address this limitation, a series of analyses based on methods from differential equations have
|
| 45 |
+
34 been employed to enhance the representation capabilities of NODEs, such as the technique of
|
| 46 |
+
35 controlled differential equations [24], learning higher-order ODEs [32], augmenting dynamics [10],
|
| 47 |
+
36 and considering dynamics with delay terms [55]. Moreover, certain works consider generalizing the
|
| 48 |
+
37 ODE case to partial differential equations (PDEs), such as in [40, 44]. However, these methods do
|
| 49 |
+
38 not use the adjoint method, removing the primary advantage of constant memory cost. This leads us
|
| 50 |
+
39 to the central question motivating the work: can we combine the benefits of the rich function class of
|
| 51 |
+
40 PDEs with the efficiency of the adjoint method? To do so, we propose a method of continuous-depth
|
| 52 |
+
41 neural networks that solves a PDE over parametric curves that reduce the PDE to an ODE. Such
|
| 53 |
+
42 curves are known as characteristics, and they define the solution of the PDE in terms of an ODE
|
| 54 |
+
43 [15]. The proposed Characteristic Neural Ordinary Differential Equations (C-NODE) learn both the
|
| 55 |
+
44 characteristics and the ODE along the characteristics to solve the PDE over the data space. This
|
| 56 |
+
45 allows for a richer class of models while still incorporating the same memory efficiency of the adjoint
|
| 57 |
+
46 method. The proposed C-NODE is also an extension of existing methods, as it improves the empirical
|
| 58 |
+
47 accuracy of these methods in classification tasks and image quality in generation tasks.
|
| 59 |
+
|
| 60 |
+
# 2 Related Work
|
| 61 |
+
|
| 62 |
+
49 We discuss the related work from both machine learning
|
| 63 |
+
50 and numerical analysis perspectives.
|
| 64 |
+
|
| 65 |
+
# 51 2.1 Machine Learning and ODEs
|
| 66 |
+
|
| 67 |
+
NODE is often motivated as a continuous form of a Residual Network (ResNet) [17], since the ResNet can be seen as a forward Euler integration scheme on the latent state [48]. Specifically, a ResNet is composed of multiple blocks where each block can be represented as:
|
| 68 |
+
|
| 69 |
+
$$
|
| 70 |
+
u _ { t + 1 } = u _ { t } + f ( u _ { t } , \theta ) ,
|
| 71 |
+
$$
|
| 72 |
+
|
| 73 |
+
where $u _ { t }$ is the evolving hidden state at time $t$ and $f ( u _ { t } , \theta )$ represents the gradient at time $t$ , namely $\begin{array} { r } { \frac { d u } { d t } ( u _ { t } ) } \end{array}$ . Generalizing the model to a step size given by $\Delta \bar { t }$ , we have:
|
| 74 |
+
|
| 75 |
+
$$
|
| 76 |
+
u _ { t + \Delta t } = u _ { t } + f ( u _ { t } , \theta ) \Delta t .
|
| 77 |
+
$$
|
| 78 |
+
|
| 79 |
+
To adapt this model to a continuous setting, we let $\Delta t \to 0$ and obtain:
|
| 80 |
+
|
| 81 |
+

|
| 82 |
+
Multiple Characteristics (PDE)Single Characteristic (ODE)
|
| 83 |
+
Figure 1: Comparison of traditional NODE (left) and proposed C-NODE (right). The solution to NODE is the solution to a single ODE, whereas CNODE represents a series of ODEs that form the solution to a PDE. Each color in C-NODE represents the solution to an ODE with a different initial condition. NODE represents a single ODE, and can only represent $u ( x , t )$ along one dimension, for example, $u ( x = 0 , t )$ .
|
| 84 |
+
|
| 85 |
+
$$
|
| 86 |
+
\operatorname* { l i m } _ { \Delta t \to 0 } { \frac { u _ { t + \Delta t } - u _ { t } } { \Delta t } } = { \frac { d u ( t ) } { d t } } .
|
| 87 |
+
$$
|
| 88 |
+
|
| 89 |
+
52 The model can then be evaluated through existing numerical integration techniques, as proposed by
|
| 90 |
+
53 [5]:
|
| 91 |
+
|
| 92 |
+
$$
|
| 93 |
+
u ( t _ { 1 } ) = u ( t _ { 0 } ) + \int _ { t _ { 0 } } ^ { t _ { 1 } } \frac { d u ( t ) } { d t } ( u ( t ) , t ) \mathrm { d } t = u ( t _ { 0 } ) + \int _ { t _ { 0 } } ^ { t _ { 1 } } f ( u ( t ) , t , \theta ) \mathrm { d } t .
|
| 94 |
+
$$
|
| 95 |
+
|
| 96 |
+
Numerical integration can then be treated as a black box, using numerical schemes beyond the forward Euler to achieve higher numerical precision. However, since black box integrators can take an arbitrary number of intermediate steps, backpropagating through individual steps would require too much memory since the individual steps must be saved. Chen et al. [5] addressed this problem by using adjoint backpropagation, which has a constant memory usage. For a given loss function on the terminal state of the hidden state $\mathcal { L } ( u ( t _ { 1 } ) )$ , the adjoint $a ( t )$ is governed by another ODE:
|
| 97 |
+
|
| 98 |
+
$$
|
| 99 |
+
\frac { d \boldsymbol { a } ( t ) } { d t } = - \boldsymbol { a } ( t ) ^ { \top } \frac { \partial f ( \boldsymbol { u } ( t ) , t , \theta ) } { \partial \boldsymbol { u } } , \quad \boldsymbol { a } ( t _ { 1 } ) = \frac { \partial \mathcal { L } } { \partial \boldsymbol { u } ( t _ { 1 } ) } ,
|
| 100 |
+
$$
|
| 101 |
+
|
| 102 |
+
54 that dictates the gradient with respect to the parameters. The loss $\mathcal { L } ( u ( t _ { 1 } ) )$ can then be calculated by
|
| 103 |
+
55 solving another ODE (the adjoint) rather than backpropagating through the calculations involved in
|
| 104 |
+
56 the numerical integration.
|
| 105 |
+
57 However, the hidden state governed by an ODE imposes a limitation on the expressiveness of the
|
| 106 |
+
58 mapping. For example, Dupont et al. [10] describes a notable limitation of NODEs is in the inability
|
| 107 |
+
59 to represent dynamical systems with intersecting trajectories. In response to such limitations, many
|
| 108 |
+
60 works have tried to increase the expressiveness of the mapping. Dupont et al. [10] proposed to solve
|
| 109 |
+
61 the intersection trajectories problem by augmenting the vector space, lifting the points into additional
|
| 110 |
+
62 dimensions; Zhu et al. [55] included time delay in the equation to represent dynamical systems of
|
| 111 |
+
63 greater complexity; Massaroli et al. [32] proposed to condition the vector field on the inputs, allowing
|
| 112 |
+
64 the integration limits to be conditioned on the input; Massaroli et al. [32] and Norcliffe et al. [35]
|
| 113 |
+
65 additionally proposed and proved a second-order ODE system can efficiently solve the intersecting
|
| 114 |
+
66 trajectories problem.
|
| 115 |
+
67 Multiple works have attempted to expand NODE systems to other common differential equation
|
| 116 |
+
68 formulations. Sun et al. [44] employed a dictionary method and expanded NODEs to a PDE case,
|
| 117 |
+
69 achieving high accuracies both in approximating PDEs and in classifying real-world image datasets.
|
| 118 |
+
70 However, Sun et al. [44] suggested that the method is unstable when training with the adjoint
|
| 119 |
+
71 method and therefore is unable to make use of the benefits that come with training with adjoint.
|
| 120 |
+
72 Zhang et al. [53] proposed a normalizing flow approach based on the Monge-Ampere equation.
|
| 121 |
+
73 However, Zhang et al. [53] did not consider using adjoint-based training. Long et al. [30, 31], Raissi
|
| 122 |
+
74 et al. [37], Brunton et al. [3] considered discovering underlying hidden PDEs from data and predict
|
| 123 |
+
75 dynamics of complex systems. Kidger et al. [24], Morrill et al. [33, 34] used ideas from rough path
|
| 124 |
+
76 theory and controlled differential equations to propose a NODE architecture as a continuous recurrent
|
| 125 |
+
77 neural network framework. Multiple works have expanded to the stochastic differential equations
|
| 126 |
+
78 setting and developed efficient optimization methods for them [16, 22, 23, 25, 26, 28, 29, 49]. Salvi
|
| 127 |
+
79 et al. [41] considered stochastic PDEs for spatio-temporal dynamics prediction. Additionally, Chen
|
| 128 |
+
80 et al. [6] models spatio-temporal data using NODEs, and Rubanova et al. [39], De Brouwer et al. [8]
|
| 129 |
+
81 makes predictions on time series data using NODEs. Physical modeling is also a popular application
|
| 130 |
+
82 of NODEs, as control problems are often governed by latent differential equations that can be
|
| 131 |
+
83 discovered with data driven methods [7, 14, 51, 54].
|
| 132 |
+
84 NODE systems have also been used for modeling the flow from a simple probability density to
|
| 133 |
+
85 a complicated one [5]. Specifically, if $u ( t ) \in \mathbb { R } ^ { n }$ follows the ODE $d u ( t ) / d t = f ( u ( t ) )$ , where
|
| 134 |
+
86 $f ( u ( t ) ) \in \mathbb R ^ { n }$ , then its log likelihood from [5, Appendix A] is given by:
|
| 135 |
+
|
| 136 |
+
$$
|
| 137 |
+
\frac { \partial \log p ( u ( t ) ) } { \partial t } = - \operatorname { t r } \left( \frac { d f } { d u ( t ) } \right) .
|
| 138 |
+
$$
|
| 139 |
+
|
| 140 |
+
87 The trace can be calculated efficiently with a Hutchinson trace estimator [13]. Subsequent work
|
| 141 |
+
88 uses invertible ResNet, optimal transport theory, among other techniques to further improve the
|
| 142 |
+
89 performance of CNFs [1, 2, 4, 11, 18, 20, 21, 46, 50, 53]. CNF is desirable for having no constraints
|
| 143 |
+
90 on the type of neural network used, unlike discrete normalizing flows, which often have constraints
|
| 144 |
+
91 on the structure of the latent features [9, 36, 38]. CNFs also inspire development in other generative
|
| 145 |
+
92 modeling methods. For instance, a score-based generative model can be seen as a probability flow
|
| 146 |
+
93 modeled with an ODE [42, 47].
|
| 147 |
+
|
| 148 |
+
# 94 3 Method
|
| 149 |
+
|
| 150 |
+
95 We describe the proposed C-NODE method in this section by first providing a brief introduction to
|
| 151 |
+
96 the method of characteristics (MoC) for solving PDEs with an illustrative example. We then discuss
|
| 152 |
+
97 how we apply the MoC to our C-NODE framework. We finally discuss the types of PDEs we can
|
| 153 |
+
98 describe using this method.
|
| 154 |
+
|
| 155 |
+
# 3.1 Method of Characteristics
|
| 156 |
+
|
| 157 |
+
100 The MoC provides a procedure for transforming certain PDEs into ODEs along paths known as
|
| 158 |
+
101 characteristics. In the most general sense, the method applies to general hyperbolic differential
|
| 159 |
+
102 equations; however, for illustration purposes, we will consider a canonical example using the inviscid
|
| 160 |
+
103 Burgers equation. A complete exposition on the topic can be found in [15, Chapter 9], but we
|
| 161 |
+
104 introduce some basic concepts here for completeness. Let $u ( x , t ) : \mathbb { R } \times \mathbb { R } _ { + } \to \mathbb { R }$ satisfy the
|
| 162 |
+
105 following inviscid Burgers equation
|
| 163 |
+
|
| 164 |
+
$$
|
| 165 |
+
\frac { \partial u } { \partial t } + u \frac { \partial u } { \partial x } = 0 ,
|
| 166 |
+
$$
|
| 167 |
+
|
| 168 |
+
106 where we dropped the dependence on $x$ and $t$ for ease of notation. We are interested in the solution
|
| 169 |
+
107 of $u$ over some bounded domain $\Omega \subset \mathbb { R } \times \mathbb { R } _ { + }$ . Consider parametric forms for the spatial component
|
| 170 |
+
108 $x ( s ) : [ 0 , T ] \to \mathbb { R }$ and temporal components $t ( s ) : [ 0 , T ] \to \mathbb { R } _ { + }$ over the fictitious variable $s \in [ 0 , T ]$
|
| 171 |
+
109 Intuitively, this allows us to solve an equation on curves $x , t$ as functions of a variable $s$ which we
|
| 172 |
+
110 denote $( { \dot { x ( s ) } } , t ( s ) )$ as the characteristic. Expanding, and writing d as the total derivative, we get
|
| 173 |
+
|
| 174 |
+
$$
|
| 175 |
+
{ \frac { \mathrm { d } } { \mathrm { d } s } } u ( x ( s ) , t ( s ) ) = { \frac { \partial u } { \partial x } } { \frac { d x } { d s } } + { \frac { \partial u } { \partial t } } { \frac { d t } { d s } } .
|
| 176 |
+
$$
|
| 177 |
+
|
| 178 |
+
Recalling the original PDE in (2) and substituting the proper terms into (3) for $d x / d s = u$ , $d t / d s =$ 1, $\mathrm { d } u / \mathrm { d } s = 0$ , we then recover (2). Note that we now have a system of 3 ODEs, which we can solve to obtain the characteristics as $x ( s ) = u s + x _ { 0 }$ and $t ( s ) = s \dot { + } t _ { 0 }$ as functions of initial conditions $x _ { 0 } , t _ { 0 }$ . Finally, by solving over a grid of initial conditions $\{ x _ { 0 } ^ { ( i ) } \} _ { i = 1 } ^ { \infty } \in \partial \Omega$ , we can obtain the solution of the PDE over $\Omega$ . Putting it all together, we have a new ODE that is written as
|
| 179 |
+
|
| 180 |
+
$$
|
| 181 |
+
{ \frac { \mathrm { d } } { \mathrm { d } s } } u ( x ( s ) , t ( s ) ) = { \frac { \partial u } { \partial t } } + u { \frac { \partial u } { \partial x } } = 0 ,
|
| 182 |
+
$$
|
| 183 |
+
|
| 184 |
+
111 where we can integrate over $s$ through
|
| 185 |
+
|
| 186 |
+
$$
|
| 187 |
+
\begin{array} { r l r } & { } & { u ( x ( T ) , t ( T ) ; x _ { 0 } , t _ { 0 } ) : = \displaystyle \int _ { 0 } ^ { T } \frac { \mathrm { d } } { \mathrm { d } s } u ( x ( s ) , t ( s ) ) \mathrm { d } s } \\ & { } & { \quad \quad \quad : = \displaystyle \int _ { 0 } ^ { T } \frac { \mathrm { d } } { \mathrm { d } s } u ( u s + x _ { 0 } , s ) \mathrm { d } s , } \end{array}
|
| 188 |
+
$$
|
| 189 |
+
|
| 190 |
+
112 using the adjoint method with boundary conditions $x _ { 0 } , t _ { 0 }$ . This contrasts the usual direct integration
|
| 191 |
+
113 over the variable $t$ that is done in NODE; we now jointly couple the integration through the character
|
| 192 |
+
114 istics. An example of solving this equation over multiple initial conditions is given in Figure 1 with
|
| 193 |
+
115 the contrast to standard NODE integration.
|
| 194 |
+
116 To provide some intuition for using MoC, we note that MoC most generally applies to hyperbolic
|
| 195 |
+
117 PDEs. The transport equation is an example of this family of PDEs, which roughly describes the
|
| 196 |
+
118 propagation of physical quantities through time. Such equations are appropriate for deep learning
|
| 197 |
+
119 tasks due to their ability to transport data into different regions of the state space. For instance, in a
|
| 198 |
+
120 classification task, we consider the problem of transporting high-dimensional data points that are not
|
| 199 |
+
121 linearly separable to spaces where they are linearly separable. Similarly, in generative modeling, we
|
| 200 |
+
122 transport a base distribution to data distribution.
|
| 201 |
+
|
| 202 |
+
# 123 3.2 Neural Representation of Characteristics
|
| 203 |
+
|
| 204 |
+
124 In the proposed method, we learn the components involved in the MoC, namely the characteristics
|
| 205 |
+
125 and the function coefficients. We now generalize the example given in 3.1, which involved two
|
| 206 |
+
126 variables, to a $k$ -dimensional system. Specifically, consider the following nonhomogeneous boundary
|
| 207 |
+
127 value problem (BVP)
|
| 208 |
+
|
| 209 |
+
$$
|
| 210 |
+
\begin{array} { r } { \left\{ \begin{array} { l l } { \frac { \partial \mathbf { u } } { \partial t } + \sum _ { i = 1 } ^ { k } a _ { i } ( x _ { 1 } , . . . , x _ { k } , \mathbf { u } ) \frac { \partial \mathbf { u } } { \partial x _ { i } } = \mathbf { c } ( x _ { 1 } , . . . , x _ { k } , \mathbf { u } ) , } & { \mathrm { o n ~ } \mathbf { x } , t \in \mathbb { R } ^ { k } \times [ 0 , \infty ) } \\ { \mathbf { u } ( \mathbf { x } ( 0 ) ) = \mathbf { u } _ { 0 } , } & { \mathrm { o n ~ } \mathbf { x } \in \mathbb { R } ^ { k } . } \end{array} \right. } \end{array}
|
| 211 |
+
$$
|
| 212 |
+
|
| 213 |
+
128 Here, $\mathbf { u } : \mathbb { R } ^ { k } \mathbb { R } ^ { n }$ is a multivariate map, $a _ { i } : \mathbb { R } ^ { k + n } \mathbb { R }$ and $\mathbf { c } : \mathbb { R } ^ { k + n } \mathbb { R } ^ { n }$ be functions
|
| 214 |
+
129 dependent on values of $\mathbf { u }$ and $x$ ’s. This problem is well-defined and has a solution so long as
|
| 215 |
+
130 Pki=1 a i i ∂u∂x is continuous [12].
|
| 216 |
+
131 MoC has historically been used in a scalar context, but generalization to the vector case is relatively
|
| 217 |
+
132 straightforward. A proof of the generalization can be found in Appendix B.1. We decompose the
|
| 218 |
+
133 PDE in (4) into the following system of ODEs
|
| 219 |
+
|
| 220 |
+
$$
|
| 221 |
+
\begin{array} { l } { \displaystyle \frac { d x _ { i } } { d s } = a _ { i } ( x _ { 1 } , . . . , x _ { k } , \mathbf { u } ) , } \\ { \displaystyle \frac { d \mathbf { u } } { d s } = \sum _ { i = 1 } ^ { k } \frac { \partial \mathbf { u } } { \partial x _ { i } } \frac { d x _ { i } } { d s } = \mathbf { c } ( x _ { 1 } , . . . , x _ { k } , \mathbf { u } ) . } \end{array}
|
| 222 |
+
$$
|
| 223 |
+
|
| 224 |
+
134 We represent this ODE system by parameterizing $d x _ { i } / d s$ and $\partial { \bf u } / \partial x _ { i }$ with neural networks. Conse
|
| 225 |
+
135 quently, $d \mathbf { u } / d s$ is evolving according to (6).
|
| 226 |
+
|
| 227 |
+
136 Following this expansion, we arrive at
|
| 228 |
+
|
| 229 |
+
$$
|
| 230 |
+
\begin{array} { l } { { \displaystyle { \bf u } ( { \bf x } ( T ) ) = { \bf u } ( { \bf x } ( 0 ) ) + \int _ { 0 } ^ { T } \frac { \mathrm { d } { \bf u } } { \mathrm { d } s } ( { \bf x } , { \bf u } ) \mathrm { d } s } \ ~ } \\ { { \displaystyle ~ = { \bf u } ( { \bf x } ( 0 ) ) + \int _ { 0 } ^ { T } [ { \bf J } _ { \bf x } { \bf u } ] ( { \bf x } , { \bf u } ; \Theta _ { 2 } ) \frac { d { \bf x } } { d s } ( { \bf x } , { \bf u } ; \Theta _ { 2 } ) \mathrm { d } s } , } \end{array}
|
| 231 |
+
$$
|
| 232 |
+
|
| 233 |
+
137 where we remove u’s dependency on $\mathbf { x } ( s )$ and $\mathbf { x }$ ’s dependency on $s$ for simplicity of notation. In
|
| 234 |
+
138 Equation (7), the functions $\mathbf { J } _ { \mathbf { x } } \mathbf { u }$ and $d \mathbf { x } / d s$ are learnable functions which are the outputs of deep
|
| 235 |
+
139 neural networks with inputs $\mathbf { x }$ , $\mathbf { u }$ and parameters $\Theta _ { 2 }$ .
|
| 236 |
+
|
| 237 |
+
# 3.3 Conditioning on data
|
| 238 |
+
|
| 239 |
+
141 Previous works primarily modeled the task of classifying a set of data points with a fixed differential
|
| 240 |
+
142 equation, neglecting possible structural variations lying in the data. Here, we condition C-NODE
|
| 241 |
+
143 on each data point, thereby solving a PDE with a different initial condition. Specifically, consider
|
| 242 |
+
144 the term given by the integrand in (7). The neural network representing the characteristic $d \mathbf { x } / d s$ is
|
| 243 |
+
145 conditioned on the input data $\mathbf { z } \in \mathbb { R } ^ { w }$ . Define a feature extractor function $\mathbf { g } ( \cdot ) : \mathbb { R } ^ { w } \mathbb { R } ^ { n }$ and we
|
| 244 |
+
146 have
|
| 245 |
+
|
| 246 |
+
$$
|
| 247 |
+
\frac { d x _ { i } } { d s } = a _ { i } ( x _ { 1 } , \dots , x _ { k } , \mathbf { u } ; \mathbf { g } ( \mathbf { z } ) ) .
|
| 248 |
+
$$
|
| 249 |
+
|
| 250 |
+
147 By introducing $\mathbf { g } ( \mathbf { z } )$ in (8), the equation describing the characteristics changes depending on the
|
| 251 |
+
148 current data point. This leads to the classification task being modeled with a family rather than one
|
| 252 |
+
149 single differential equation.
|
| 253 |
+
|
| 254 |
+
# 3.4 Training C-NODEs
|
| 255 |
+
|
| 256 |
+
151 After introducing the main components of C-NODEs, we can integrate them into a unified algorithm.
|
| 257 |
+
152 To motivate this section, and to be consistent with part of the empirical evaluation, we will consider
|
| 258 |
+
153 classification tasks with data $\left\{ \left( \mathbf { z } _ { j } , \mathbf { y } _ { j } \right) \right\} _ { j = 1 } ^ { N } , \ \mathbf { z } _ { j } \in \mathbb { R } ^ { w } , \ \mathbf { y } _ { j } \in \mathbb { Z } ^ { + }$ . For instance, $\mathbf { z } _ { j }$ may be an image,
|
| 259 |
+
154 and $\mathbf { y } _ { j }$ is its class label. In the approach we pursue here, the image $\mathbf { z } _ { j }$ is first passed through a
|
| 260 |
+
155 feature extractor function $\mathbf { g } ( \cdot ; \Theta _ { 1 } ) : \mathbb { R } ^ { w } \to \mathbb { R } ^ { n }$ with parameters $\Theta _ { 1 }$ . The output of $\mathbf { g }$ is the feature
|
| 261 |
+
156 $\mathbf { u } _ { 0 } ^ { ( j ) } = \mathbf { g } ( \mathbf { z } _ { j } ; \boldsymbol { \Theta } _ { 1 } )$ that provides the boundary condition for the PDE on $\mathbf { u } ^ { ( j ) }$ . We integrate along
|
| 262 |
+
157 different characteristic curves indexed by $s \in [ 0 , T ]$ with boundary condition $\mathbf { u } ^ { ( j ) } ( \mathbf { x } ( 0 ) ) = \mathbf { u } _ { 0 } ^ { ( j ) }$ , and
|
| 263 |
+
158 compute the end values as given by (7), where we mentioned in Section 3.2,
|
| 264 |
+
|
| 265 |
+
$$
|
| 266 |
+
\mathbf { u } ^ { ( j ) } ( \mathbf { x } ( T ) ) = \mathbf { u } _ { 0 } ^ { ( j ) } + \int _ { 0 } ^ { T } \mathbf { J } _ { \mathbf { x } } \mathbf { u } ^ { ( i ) } \left( \mathbf { x } , \mathbf { u } ^ { ( j ) } ; \boldsymbol { \Theta } _ { 2 } \right) \frac { d \mathbf { x } } { d s } \left( \mathbf { x } , \mathbf { u } ^ { ( j ) } ; \mathbf { u } _ { 0 } ^ { ( j ) } ; \boldsymbol { \Theta } _ { 2 } \right) \mathrm { d } s
|
| 267 |
+
$$
|
| 268 |
+
|
| 269 |
+
159 Finally, $\mathbf { u } ^ { ( j ) } ( \mathbf { x } ( T ) )$ is passed through another neural network, $\Phi ( \mathbf { u } ^ { ( j ) } ( \mathbf { x } ( T ) ) ; \Theta _ { 3 } )$ with input
|
| 270 |
+
160 $\mathbf { u } ^ { ( j ) } ( \mathbf { x } ( T ) )$ and parameters $\Theta _ { 3 }$ whose output are the probabilities of each class labels for image $\mathbf { z } _ { j }$
|
| 271 |
+
161 The entire learning is now is reduced to finding optimal weights $( \Theta _ { 1 } , \Theta _ { 2 } , \Theta _ { 3 } )$ which can be achieved
|
| 272 |
+
162 by minimizing the loss
|
| 273 |
+
|
| 274 |
+
$$
|
| 275 |
+
\mathcal { L } = \sum _ { j = 1 } ^ { N } L ( \Phi ( \mathbf { u } ^ { ( j ) } ( \mathbf { x } ( T ) ) ; \Theta _ { 3 } ) , \mathbf { y } _ { j } ) ,
|
| 276 |
+
$$
|
| 277 |
+
|
| 278 |
+
63 where $L ( \cdot )$ is a loss function of choice. In Algorithm 1, we illustrate the implementation procedure
|
| 279 |
+
64 with the forward Euler method for simplicity for the framework but note any ODE solver can be used.
|
| 280 |
+
|
| 281 |
+
# 3.5 Combining MoC with Existing NODE Modifications
|
| 282 |
+
|
| 283 |
+
As mentioned in the Section 2, the proposed C-NODEs method can be used as an extension to existing NODE frameworks. In all NODE modifications, the underlying expression of $\textstyle \int _ { a } ^ { b } \mathbf { f } ( t , \mathbf { u } ; \Theta ) \mathrm { d } t$ remains the same. Modifying this expression to C-NODE architecture, with the size o $\begin{array} { r } { \int _ { a } ^ { b } { \bf J _ { x } } { \bf u } ( { \bf x } , { \bf u } ; \Theta ) d { \bf x } / d s ( { \bf x } , { \bf u } ; { \bf u } _ { 0 } ; \Theta ) \mathrm { d } s } \end{array}$ $\mathbf { x }$ results in the proposed
|
| 284 |
+
|
| 285 |
+
for each input data $\mathbf { z } _ { j }$ do extract image feature $\mathbf { u } ( s = 0 ) = \mathbf { g } ( \mathbf { z } _ { j } ; \Theta _ { 1 } )$ with a feature extractor neural network. procedure Integration along $s = 0 \to 1$ for each time step $s _ { m }$ do calculate $\begin{array} { r } { \frac { d \mathbf { x } } { d s } ( \mathbf { x } , \mathbf { u } ; \mathbf { g } ( \mathbf { z } _ { j } ; \boldsymbol { \Theta } _ { 1 } ) ; \boldsymbol { \Theta } _ { 2 } ) } \end{array}$ and $\mathbf { J _ { x } } \mathbf { u } ( \mathbf { x } , \mathbf { u } ; \Theta _ { 2 } )$ . calculate $\begin{array} { r } { { \frac { d { \bf u } } { d s } } = { \bf J _ { x } u } { \frac { d { \bf x } } { d s } } } \end{array}$ . calculate $\begin{array} { r } { \overline { { \mathbf { u } } } ( s _ { m + 1 } ) = \mathbf { u } ( s _ { m } ) + \frac { d \mathbf { u } } { d s } ( s _ { m + 1 } - s _ { m } ) } \end{array}$ . end for end procedure classify $\mathbf { u } ( s = 1 )$ with neural network $\Phi ( { \bf u } ( { \bf x } ( s = 1 ) ) , \Theta _ { 3 } )$ .
|
| 286 |
+
end for
|
| 287 |
+
|
| 288 |
+
# 170 4 Properties of C-NODEs
|
| 289 |
+
|
| 290 |
+
C-NODE has a number of theoretical properties that contribute to its expressiveness. We provide some theoretical results on these properties in the proceeding sections. We also define continuous normalizing flows (CNFs) with C-NODEs, extending the CNFs originally defined with NODEs.
|
| 291 |
+
|
| 292 |
+
# 4.1 Intersecting trajectories
|
| 293 |
+
|
| 294 |
+
5 As mentioned in [10], one limitation of NODE is that the mappings cannot represent intersecting 6 dynamics. We prove by construction that the C-NODEs can represent some dynamical systems with intersecting trajectories in the following proposition:
|
| 295 |
+
|
| 296 |
+
Proposition 4.1. The C-NODE can represent a dynamical system on $u ( s )$ , $d u / d s = \mathcal { G } ( s , u ) :$ $\mathbb { R } _ { + } \times \mathbb { R } \to \mathbb { R }$ , where when $u ( 0 ) = 1$ , then $\begin{array} { r } { u ( 1 ) = u ( 0 ) + \int _ { 0 } ^ { 1 } \mathcal { G } ( s , u ) d s = 0 } \end{array}$ ; and when $u ( 0 ) = 0$ , then $\begin{array} { r } { u ( 1 ) = u ( 0 ) + \int _ { 0 } ^ { 1 } \mathcal { G } ( s , u ) d s = 1 } \end{array}$ .
|
| 297 |
+
|
| 298 |
+
Proof. See Appendix B.2.
|
| 299 |
+
|
| 300 |
+
# 4.2 Density estimation with C-NODEs
|
| 301 |
+
|
| 302 |
+
C-NODEs can also be used to define a continuous density flow that models the density of a variable over space subject to the variable satisfying a PDE. Similar to the change of log probability of NODEs, as in (1), we provide the following proposition for C-NODEs:
|
| 303 |
+
|
| 304 |
+
Proposition 4.2. Let $u ( s )$ be a finite continuous random variable with probability density function $p ( u ( s ) )$ and let $u ( s )$ satisfy $\begin{array} { r } { \frac { d u ( s ) } { d s } = \sum _ { i = 1 } ^ { k } \frac { \partial u } { \partial x _ { i } } \frac { d x _ { i } } { d s } } \end{array}$ ∂u dxi . Assuming ∂u and $\textstyle { \frac { d x _ { i } } { d s } }$ are uniformly Lipschitz continuous in u and continuous in $s$ , then the evolution of the log probability of $u$ follows:
|
| 305 |
+
|
| 306 |
+
$$
|
| 307 |
+
{ \frac { \partial \log p ( u ( s ) ) } { \partial s } } = - \mathrm { t r } \left( { \frac { \partial } { \partial u } } \sum _ { i = 1 } ^ { k } { \frac { \partial u } { \partial x _ { i } } } { \frac { d x _ { i } } { d s } } \right)
|
| 308 |
+
$$
|
| 309 |
+
|
| 310 |
+
189 Proof. See Appendix B.3.
|
| 311 |
+
|
| 312 |
+
190 CNFs are continuous and invertible one-to-one mappings onto themselves, i.e., homeomorphisms.
|
| 313 |
+
191 Zhang et al. [52] proved that vanilla NODEs are not universal estimators of homeomorphisms, and
|
| 314 |
+
192 augmented neural ODEs (ANODEs) are universal estimators of homeomorphisms. We demonstrate
|
| 315 |
+
193 that C-NODEs are pointwise estimators of homeomorphisms, which we formalize in the following
|
| 316 |
+
194 proposition:
|
| 317 |
+
|
| 318 |
+
95 96 $h : \Upsilon \Upsilon$ $\Upsilon \subset \mathbb { R } ^ { p }$ itial condsuch that $u _ { 0 }$ . T > 0, there exists a flow u(s, u0) ∈ Rn following duds $\begin{array} { r } { \frac { d u } { d s } = \frac { \partial u } { \partial x } \frac { d x } { d s } + \frac { \partial u } { \partial t } \frac { d t } { d s } } \end{array}$ $u ( T , u _ { 0 } ) = h ( u _ { 0 } )$
|
| 319 |
+
|
| 320 |
+

|
| 321 |
+
Figure 2: Red: NODE. Blue: C-NODE. Training dynamics of different datasets with adjoint in Fig. 2a and with Euler in Fig. 2b averaged over five runs. The first column is the training process of SVHN, the second column is of CIFAR-10, and the third column is of MNIST. By incorporating the C-NODE method, we achieve a more stable training process in both CIFAR-10 and SVHN, while achieving higher accuracy. Full-sized figure in supplementary materials.
|
| 322 |
+
|
| 323 |
+
# 5 Experiments
|
| 324 |
+
|
| 325 |
+
We present experiments on image classification tasks on benchmark datasets, image generation tasks on benchmark datasets, PDE modeling, and time series prediction.
|
| 326 |
+
|
| 327 |
+
# 5.1 Classification Experiments with Image Datasets
|
| 328 |
+
|
| 329 |
+
We first conduct experiments for classification tasks on high-dimensional image datasets, including MNIST, CIFAR-10, and SVHN. We provide results for C-NODE and also combine the framework with existing methods, including ANODEs [10], Input Layer NODEs (IL-NODEs) [32], and 2ndOrder NODEs [32]. For all classification experiments, we set the encoder of input images for conditioning to be identity, i.e., $g ( z ) = z$ , making the input into C-NODE the original image. This way, we focus exclusively on the performance of C-NODE.
|
| 330 |
+
|
| 331 |
+
The results for the experiments with the adjoint method are reported in Table 1 and in Figure 2a. We investigate the performances of the models on classification accuracy and the number of function evaluations (NFE) taken in the adaptive numerical integration. NFE is an indicator of the model’s computational complexity, and can also be interpreted as the network depth for the continuous NODE system [5]. Using a similar number of parameters, combining C-NODEs with different models consistently results in higher accuracies and mostly uses smaller numbers of NFEs, indicating a better parameter efficiency. An ablation study on C-NODEs’ and NODEs’ parameters can be found in Appendix C.2.The performance improvements can be observed, especially on CIFAR-10 and SVHN, where it seems the dynamics to be learned are too complex for ODE systems, requiring a sophisticated model and a large number of NFEs. It appears that solving a PDE system along a multidimensional characteristic is beneficial for training more expressive functions with less complex dynamics, as can be seen in Figures 2a, 2b.
|
| 332 |
+
|
| 333 |
+
220 We also report training results using a traditional backpropagation through the forward Euler solver
|
| 334 |
+
221 in Figure 2b. The experiments are performed using the same network architectures as the previous
|
| 335 |
+
222 experiments using the adjoint method. It appears that C-NODEs converge significantly faster than
|
| 336 |
+
223 the NODEs (usually in one epoch) and generally have a more stable training process with smaller
|
| 337 |
+
224 variance. In experiments with MNIST, C-NODEs converge in only one epoch, while NODEs converge
|
| 338 |
+
225 in roughly 15 epochs. This provides additional empirical evidence on the benefits of training using the
|
| 339 |
+
226 characteristics. As shown in Figures 2a, 2b, compared to training with the adjoint method, training
|
| 340 |
+
227 with the forward Euler solver results in less variance, indicating a more stable training process. At the
|
| 341 |
+
228 same time, training with the adjoint method results in more accurate models, as the adjoint method
|
| 342 |
+
229 uses a constant amount of memory, and can employ more accurate adaptive ODE solvers.
|
| 343 |
+
|
| 344 |
+
# 5.2 Continuous normalizing flow with C-NODEs
|
| 345 |
+
|
| 346 |
+
231 We compare the performance of CNFs defined with NODEs to with C-NODEs on MNIST, SVHN,
|
| 347 |
+
232 and CIFAR-10. We use a Hutchinson trace estimator to calculate the trace and use multi-scale
|
| 348 |
+
|
| 349 |
+
<table><tr><td>Dataset</td><td>Method</td><td>Accuracy ↑</td><td>NFE↓</td><td>Param.[K]↓</td></tr><tr><td rowspan="8">SVHN</td><td>NODE</td><td>75.28 ± 0.836%</td><td>131</td><td>115.444</td></tr><tr><td>C-NODE</td><td>82.19 ± 0.478%</td><td>124</td><td>113.851</td></tr><tr><td>ANODE</td><td>89.8 ± 0.952%</td><td>167</td><td>112.234</td></tr><tr><td>ANODE+C-NODE</td><td>92.23± 0.176%</td><td>146</td><td>112.276</td></tr><tr><td>2nd-Ord</td><td>88.22 ± 1.11%</td><td>161</td><td>112.801</td></tr><tr><td>2nd-Ord+C-NODE</td><td>92.37 ± 0.118%</td><td>135</td><td>112.843</td></tr><tr><td>IL-NODE</td><td>89.69 ± 0.369%</td><td>195</td><td>113.368</td></tr><tr><td>IL-NODE+C-NODE</td><td>93.31 ± 0.088%</td><td>95</td><td>113.752</td></tr><tr><td rowspan="8">CIFAR-10</td><td>NODE</td><td>56.30 ± 0.742%</td><td>152</td><td>115.444</td></tr><tr><td>C-NODE</td><td>64.28 ± 0.243%</td><td>151</td><td>113.851</td></tr><tr><td>ANODE</td><td>70.99 ± 0.483%</td><td>177</td><td>112.234</td></tr><tr><td>ANODE+C-NODE</td><td>71.36 ± 0.220%</td><td>224</td><td>112.276</td></tr><tr><td>2nd-Ord</td><td>70.84 ± 0.360%</td><td>189</td><td>112.801</td></tr><tr><td>2nd-Ord+C-NODE</td><td>73.68 ± 0.153%</td><td>131</td><td>112.843</td></tr><tr><td>IL-NODE</td><td>72.55 ± 0.238%</td><td>134</td><td>113.368</td></tr><tr><td>IL-NODE+C-NODE</td><td>73.78 ± 0.154%</td><td>85</td><td>113.752</td></tr><tr><td rowspan="8">MNIST</td><td>NODE</td><td>96.90 ± 0.154%</td><td>72</td><td>85.468</td></tr><tr><td>C-NODE</td><td>97.56 ± 0.431%</td><td>72</td><td>83.041</td></tr><tr><td>ANODE</td><td>99.12 ±0.021%</td><td>68</td><td>89.408</td></tr><tr><td>ANODE+C-NODE</td><td>99.20±0.002%</td><td>60</td><td>88.321</td></tr><tr><td>2nd-Ord</td><td>99.35 ±0.002%</td><td>52</td><td>89.552</td></tr><tr><td>2nd-Ord+C-NODE</td><td>99.38 ± 0.037%</td><td>61</td><td>88.465</td></tr><tr><td>IL-NODE</td><td>99.33 ± 0.039%</td><td>53</td><td>89.597</td></tr><tr><td>IL-NODE+C-NODE</td><td>99.33 ± 0.001%</td><td>60</td><td>88.51</td></tr></table>
|
| 350 |
+
|
| 351 |
+
Table 1: Mean test results over 5 runs of different NODE models over SVHN, CIFAR-10, and MNIST. Accuracy and NFE at convergence are reported. Applying C-NODE always increases models’ accuracy and usually reduces models’ NFE as well as the standard error.
|
| 352 |
+
|
| 353 |
+
convolutional architectures as done in [9, 13] 1. Differential equations are solved using the RungeKutta method of order 5 of the Dormand-Prince-Shampine solver and trained with the adjoint method.
|
| 354 |
+
|
| 355 |
+
Although the Euler forward method is faster, experimental results show that its fixed step size often leads to negative Bits/Dim, indicating the importance of adaptive solvers. As shown in table 2 and figure 3, using a similar number of parameters, experimental results show that CNFs defined with C-NODEs perform better than CNFs defined with NODEs in terms of Bits/Dim, as well as having lower variance, and using a lower NFE on all of MNIST, CIFAR-10, and SVHN.
|
| 356 |
+
|
| 357 |
+
# 40 5.3 PDE modeling with C-NODEs
|
| 358 |
+
|
| 359 |
+
We consider a synthetic regression example for a hyperbolic PDE with a known solution. Since NODEs assume that the latent state is only dependent on a scalar (namely time), they cannot model dependencies that vary over multiple spatial variables required by most PDEs. We quantify the differences in the representation capabilities by examining how well each method can represent a linear hyperbolic PDE. We also modify the assumptions used in the classification and density estimation experiments where the boundary conditions were constant as in (4). We approximate the following BVP:
|
| 360 |
+
|
| 361 |
+
$$
|
| 362 |
+
\left\{ \begin{array} { l l } { u \frac { \partial u } { \partial x } + \frac { \partial u } { \partial t } = u , } & \\ { u ( x , 0 ) = 2 t , } & { 1 \leq x \leq 2 . } \end{array} \right.
|
| 363 |
+
$$
|
| 364 |
+
|
| 365 |
+
<table><tr><td rowspan="2">Model</td><td colspan="3">MNIST</td><td colspan="3">CIFAR-10</td><td colspan="3"> SVHN</td></tr><tr><td>B/D</td><td>Param.</td><td>NFE</td><td>B/D</td><td>Param.</td><td>NFE</td><td>B/D</td><td>Param.</td><td>NFE</td></tr><tr><td>Real NVP [9]</td><td>1.05</td><td>N/A</td><td>1</td><td>3.49</td><td>N/A</td><td>1</td><td>1</td><td>1</td><td>1</td></tr><tr><td>Glow [27]</td><td>1.06</td><td>N/A</td><td>1</td><td>3.35</td><td>44.0M</td><td>1</td><td>1</td><td>1</td><td>1</td></tr><tr><td>RQ-NSF[11]</td><td>1</td><td>1</td><td>1</td><td>3.38</td><td>11.8M</td><td>1</td><td>1</td><td>1</td><td>1</td></tr><tr><td>Res. Flow [4]</td><td>0.97</td><td>16.6M</td><td>1</td><td>3.28</td><td>25.2M</td><td>1</td><td>1</td><td>1</td><td>1</td></tr><tr><td>CP-Flow [21]</td><td>1.02</td><td>2.9M</td><td>1</td><td>3.40</td><td>1.9M</td><td>1</td><td>1</td><td>1</td><td>1</td></tr><tr><td>NODE</td><td>1.00</td><td>336.1K</td><td>1350</td><td>3.49</td><td>410.1K</td><td>1847</td><td>2.15</td><td>410.1K</td><td>1844</td></tr><tr><td>C-NODE</td><td>0.95</td><td>338.0K</td><td>1323</td><td>3.44</td><td>406.0K</td><td>1538</td><td>2.12</td><td>406.0K</td><td>1352</td></tr></table>
|
| 366 |
+
|
| 367 |
+
Table 2: Experimental results on generation tasks, with NODE, C-NODE, and other models. B/D indicates Bits/dim. Using a similar amount of parameters, C-NODE outperforms NODE on all three datasets, and have a significantly lower NFE when training for CIFAR-10 and SVHN.
|
| 368 |
+
|
| 369 |
+
248 (10) has an analytical solution given by $\begin{array} { r } { u ( x , t ) = \frac { 2 x \exp ( t ) } { 2 \exp ( t ) + 1 } } \end{array}$ . We generate a training dataset by
|
| 370 |
+
249 randomly sampling 200 points $( x , t )$ , $x \in [ 1 , 2 ]$ , $t \in [ 0 , 1 ]$ , as well as values $u ( x , t )$ at those points.
|
| 371 |
+
250 We test C-NODE and NODE on 200 points randomly sampled as $( x , t ) \in [ 1 , 2 ] \times [ 0 , 1 ]$ . For this
|
| 372 |
+
251 experiment, C-NODE uses 809 parameters while NODE uses 1185 parameters. C-NODE deviates
|
| 373 |
+
252 $8 . 0 5 \%$ from the test dataset, while NODE deviates $3 0 . 5 2 \%$ . Further experimental details can be found
|
| 374 |
+
253 in Appendix A.3.
|
| 375 |
+
|
| 376 |
+
# 5.4 Time series prediction with C-NODEs
|
| 377 |
+
|
| 378 |
+
Finally, we test C-NODEs and NODEs on the time series prediction problem using the MuJoCo dataset [45]. We follow the experimental settings in [39], where we define an autoregressive model with the encoder being an ODE-RNN model and the decoder being a latent $\mathrm { O D E } ^ { 2 }$ . As shown in Figure 5, C-NODEs achieve lower testing mean squared errors (MSEs). After 100 training epochs, C-NODEs achieve $\cdot$ lower testing MSEs than NODEs.
|
| 379 |
+
|
| 380 |
+
# 64 6 Discussion
|
| 381 |
+
|
| 382 |
+

|
| 383 |
+
Figure 3: Red: NODE. Blue: C-NODE. Training dynamics of CNFs on MNIST dataset with adjoint method. We present Bits/dim of the first 50 training epochs.
|
| 384 |
+
|
| 385 |
+
265 We describe an approach for extending NODEs to
|
| 386 |
+
266 the case of PDEs by solving a series of ODEs along
|
| 387 |
+
267 the characteristics of a PDE. The approach applies
|
| 388 |
+
|
| 389 |
+
to any black-box ODE solver and can be combined with existing NODE-based frameworks. We empirically showcase its efficacy on classification tasks while also demonstrating its success in improving convergence using Euler forward method without the adjoint method. Additionally, CNODE empirically achieves better performances on density estimation tasks, while being more efficient with the number of parameters and using lower NFEs. C-NODE’s efficiency over physical modeling and time series prediction is also highlighted with additional experiments.
|
| 390 |
+
|
| 391 |
+
Limitations There are several limitations to the proposed method. The MoC only applies to hyperbolic PDEs, and we only consider first-order semi-linear PDEs in this paper. This may be a limitation since this is a specific class of PDEs that does not model all data. We also did not enforce any particular structure to prevent characteristics from intersecting, which may result in shock waves and rarefactions. However, we believe that this is unlikely to happen due to the high dimensionality of the ambient space. We additionally note that, compared to ANODE, C-NODE’s training is not as stable. This can be improved by coupling C-NODEs with ANODEs or other methods.
|
| 392 |
+
|
| 393 |
+
#
|
| 394 |
+
|
| 395 |
+
References [1] Rameen Abdal, Peihao Zhu, Niloy J Mitra, and Peter Wonka. Styleflow: Attribute-conditioned exploration of stylegan-generated images using conditional continuous normalizing flows. ACM Transactions on Graphics (TOG), 40(3):1–21, 2021. [2] Jens Behrmann, David Kristjanson Duvenaud, and Jörn-Henrik Jacobsen. Invertible residual networks. In ICML, 2019. [3] Steven L Brunton, Joshua L Proctor, and J Nathan Kutz. Discovering governing equations from data by sparse identification of nonlinear dynamical systems. Proceedings of the national academy of sciences, 113(15):3932–3937, 2016. [4] Ricky T. Q. Chen, Jens Behrmann, David Kristjanson Duvenaud, and Jörn-Henrik Jacobsen. Residual flows for invertible generative modeling. arXiv preprint arXiv:1906.02735, 2019. [5] Ricky T. Q. Chen, Yulia Rubanova, Jesse Bettencourt, and David Duvenaud. Neural ordinary differential equations. arXiv preprint arXiv:1806.07366, 2019. [6] Ricky TQ Chen, Brandon Amos, and Maximilian Nickel. Neural spatio-temporal point processes. arXiv preprint arXiv:2011.04583, 2020. [7] Miles Cranmer, Sam Greydanus, Stephan Hoyer, Peter Battaglia, David Spergel, and Shirley Ho. Lagrangian neural networks. arXiv preprint arXiv:2003.04630, 2020. [8] Edward De Brouwer, Jaak Simm, Adam Arany, and Yves Moreau. Gru-ode-bayes: Continuous modeling of sporadically-observed time series. Advances in neural information processing systems, 32, 2019. [9] Laurent Dinh, Jascha Sohl-Dickstein, and Samy Bengio. Density estimation using real nvp. arXiv preprint arXiv:1605.08803, 2017. [10] Emilien Dupont, Arnaud Doucet, and Yee Whye Teh. Augmented neural ODEs. arXiv preprint arXiv:1904.01681, 2019. [11] Conor Durkan, Artur Bekasov, Iain Murray, and George Papamakarios. Neural spline flows. Advances in neural information processing systems, 32, 2019. [12] Lawrence Evans. Partial Differential Equations. American Mathematical Society, 2010. 308 [13] Will Grathwohl, Ricky T. Q. Chen, Jesse Bettencourt, Ilya Sutskever, and David Kristjanson Duvenaud. Ffjord: Free-form continuous dynamics for scalable reversible generative models. arXiv preprint arXiv:1810.01367, 2019. [14] Samuel Greydanus, Misko Dzamba, and Jason Yosinski. Hamiltonian neural networks. Advances in Neural Information Processing Systems, 32, 2019. [15] David F Griffiths, John W Dold, and David J Silvester. Essential partial differential equations. Springer, 2015. [16] Batuhan Güler, Alexis Laignelet, and Panos Parpas. Towards robust and stable deep learning algorithms for forward backward stochastic differential equations. arXiv preprint arXiv:1910.11623, 2019. [17] Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. arXiv preprint arXiv:1512.03385, 2015. [18] Emiel Hoogeboom, Rianne Van Den Berg, and Max Welling. Emerging convolutions for generative normalizing flows. In International Conference on Machine Learning, pages 2771– 2780. PMLR, 2019. [19] Ralph Howard. The gronwall inequality, 1998. URL http://people.math.sc.edu/ howard/Notes/gronwall.pdf.
|
| 396 |
+
|
| 397 |
+
[20] Chin-Wei Huang, Laurent Dinh, and Aaron C. Courville. Augmented normalizing flows: Bridging the gap between generative flows and latent variable models. ArXiv, abs/2002.07101, 2020.
|
| 398 |
+
[21] Chin-Wei Huang, Ricky T. Q. Chen, Christos Tsirigotis, and Aaron C. Courville. Convex potential flows: Universal probability distributions with optimal transport and convex optimization. arXiv preprint arXiv:2012.05942, 2021.
|
| 399 |
+
[22] Junteng Jia and Austin R Benson. Neural jump stochastic differential equations. Advances in Neural Information Processing Systems, 32, 2019.
|
| 400 |
+
[23] Junteng Jia and Austin R. Benson. Neural jump stochastic differential equations. arXiv preprint arXiv:1905.10403, 2020.
|
| 401 |
+
[24] Patrick Kidger, James Morrill, James Foster, and Terry Lyons. Neural controlled differential equations for irregular time series. arXiv preprint arXiv:2005.08926, 2020.
|
| 402 |
+
[25] Patrick Kidger, James Foster, Xuechen Li, and Terry Lyons. Efficient and accurate gradients for neural sdes. arXiv preprint arXiv:2105.13493, 2021.
|
| 403 |
+
[26] Patrick Kidger, James Foster, Xuechen Li, and Terry J Lyons. Neural sdes as infinite-dimensional gans. In International Conference on Machine Learning, pages 5453–5463. PMLR, 2021.
|
| 404 |
+
[27] Durk P Kingma and Prafulla Dhariwal. Glow: Generative flow with invertible 1x1 convolutions. Advances in neural information processing systems, 31, 2018.
|
| 405 |
+
[28] Xuechen Li, Ting-Kam Leonard Wong, Ricky T. Q. Chen, and David Duvenaud. Scalable gradients for stochastic differential equations. arXiv preprint arXiv:2001.01328, 2020.
|
| 406 |
+
[29] Xuanqing Liu, Tesi Xiao, Si Si, Qin Cao, Sanjiv Kumar, and Cho-Jui Hsieh. Neural sde: Stabilizing neural ode networks with stochastic noise. arXiv preprint arXiv:1906.02355, 2019.
|
| 407 |
+
[30] Zichao Long, Yiping Lu, Xianzhong Ma, and Bin Dong. Pde-net: Learning pdes from data. In International Conference on Machine Learning, pages 3208–3216. PMLR, 2018.
|
| 408 |
+
[31] Zichao Long, Yiping Lu, and Bin Dong. Pde-net 2.0: Learning pdes from data with a numericsymbolic hybrid deep network. Journal of Computational Physics, 399:108925, 2019.
|
| 409 |
+
[32] Stefano Massaroli, Michael Poli, Jinkyoo Park, Atsushi Yamashita, and Hajime Asama. Dissecting neural odes. arXiv preprint arXiv:2002.08071, 2021.
|
| 410 |
+
[33] James Morrill, Patrick Kidger, Lingyi Yang, and Terry Lyons. Neural controlled differential equations for online prediction tasks, 2021.
|
| 411 |
+
[34] James Morrill, Cristopher Salvi, Patrick Kidger, James Foster, and Terry Lyons. Neural rough differential equations for long time series. arXiv preprint arXiv:2009.08295, 2021.
|
| 412 |
+
[35] Alexander Norcliffe, Cristian Bodnar, Ben Day, Nikola Simidjievski, and Pietro Liò. On second order behaviour in augmented neural odes. arXiv preprint arXiv:2006.07220, 2020.
|
| 413 |
+
[36] George Papamakarios, Iain Murray, and Theo Pavlakou. Masked autoregressive flow for density estimation. arXiv preprint arXiv:1705.07057, 2017.
|
| 414 |
+
[37] M. Raissi, P. Perdikaris, and G.E. Karniadakis. Physics-informed neural networks: A deep learning framework for solving forward and inverse problems involving nonlinear partial differential equations. Journal of Computational Physics, 378:686–707, 2019. ISSN 0021-9991. doi: https://doi.org/10.1016/j.jcp.2018.10.045. URL https://www.sciencedirect.com/ science/article/pii/S0021999118307125.
|
| 415 |
+
[38] Danilo Jimenez Rezende and Shakir Mohamed. Variational inference with normalizing flows. In ICML, 2015.
|
| 416 |
+
[39] Yulia Rubanova, Ricky TQ Chen, and David K Duvenaud. Latent ordinary differential equations for irregularly-sampled time series. Advances in neural information processing systems, 32, 2019.
|
| 417 |
+
71 [40] Lars Ruthotto and Eldad Haber. Deep neural networks motivated by partial differential equations. Journal of Mathematical Imaging and Vision, 62(3):352–364, 2020.
|
| 418 |
+
73 [41] Cristopher Salvi, Maud Lemercier, and Andris Gerasimovics. Neural stochastic partial differential equations: Resolution-invariant learning of continuous spatiotemporal dynamics. arXiv preprint arXiv:2110.10249, 2022.
|
| 419 |
+
76 [42] 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, 2021.
|
| 420 |
+
79 [43] Robert Strichartz. The way of analysis. Jones and bartlett mathematics, 2000.
|
| 421 |
+
80 [44] Yifan Sun, Linan Zhang, and Hayden Schaeffer. Neupde: Neural network based ordinary and partial differential equations for modeling time-dependent data. arXiv preprint arXiv:1908.03190, 2019. [45] Yuval Tassa, Yotam Doron, Alistair Muldal, Tom Erez, Yazhe Li, Diego de Las Casas, David Budden, Abbas Abdolmaleki, Josh Merel, Andrew Lefrancq, Timothy P. Lillicrap, and Martin A. Riedmiller. Deepmind control suite. ArXiv, abs/1801.00690, 2018. [46] Peter Toth, Danilo Jimenez Rezende, Andrew Jaegle, Sébastien Racanière, Aleksandar Botev, and Irina Higgins. Hamiltonian generative networks. arXiv preprint arXiv:1909.13789, 2019. [47] Arash Vahdat, Karsten Kreis, and Jan Kautz. Score-based generative modeling in latent space. arXiv preprint arXiv:2106.05931, 2021. [48] E. Weinan. A proposal on machine learning via dynamical systems. Communications in Mathematics and Statistics, 5, 2017. [49] Winnie Xu, Ricky TQ Chen, Xuechen Li, and David Duvenaud. Infinitely deep bayesian neural networks with stochastic differential equations. In International Conference on Artificial Intelligence and Statistics, pages 721–738. PMLR, 2022. [50] Cagatay Yildiz, Markus Heinonen, and Harri Lahdesmaki. Ode2vae: Deep generative second order odes with bayesian neural networks. Advances in Neural Information Processing Systems, 32, 2019. [51] Cagatay Yildiz, Markus Heinonen, and Harri Lähdesmäki. Continuous-time model-based reinforcement learning. In Marina Meila and Tong Zhang, editors, Proceedings of the 38th International Conference on Machine Learning, volume 139 of Proceedings of Machine Learning Research, pages 12009–12018. PMLR, 18–24 Jul 2021. URL https: //proceedings.mlr.press/v139/yildiz21a.html.
|
| 422 |
+
03 [52] Han Zhang, Xi Gao, Jacob Unterman, and Tom Arodz. Approximation capabilities of neural odes and invertible residual networks. In ICML, 2020.
|
| 423 |
+
05 [53] Linfeng Zhang, Weinan E, and Lei Wang. Monge-ampère flow for generative modeling. arXiv preprint arXiv:1809.10188, 2018.
|
| 424 |
+
407 [54] Yaofeng Desmond Zhong, Biswadip Dey, and Amit Chakraborty. Symplectic ode-net: Learning hamiltonian dynamics with control. arXiv preprint arXiv:1909.12077, 2019.
|
| 425 |
+
409 [55] Qunxi Zhu, Yao Guo, and Wei Lin. Neural delay differential equations. arXiv preprint arXiv:2102.10801, 2021.
|
| 426 |
+
|
| 427 |
+
# 411 Checklist
|
| 428 |
+
|
| 429 |
+
1. For all authors...
|
| 430 |
+
|
| 431 |
+
(a) Do the main claims made in the abstract and introduction accurately reflect the paper’s
|
| 432 |
+
contributions and scope? [Yes]
|
| 433 |
+
(b) Have you read the ethics review guidelines and ensured that your paper conforms to
|
| 434 |
+
them? [Yes]
|
| 435 |
+
(c) Did you discuss any potential negative societal impacts of your work? [N/A]
|
| 436 |
+
(d) Did you describe the limitations of your work? [Yes]
|
| 437 |
+
|
| 438 |
+
419 2. If you are including theoretical results...
|
| 439 |
+
|
| 440 |
+
(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]
|
| 441 |
+
|
| 442 |
+
3. If you ran experiments...
|
| 443 |
+
|
| 444 |
+
(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]
|
| 445 |
+
(b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes]
|
| 446 |
+
(c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [Yes]
|
| 447 |
+
(d) Did you include the amount of compute and the type of resources used (e.g., type of GPUs, internal cluster, or cloud provider)? [Yes]
|
| 448 |
+
|
| 449 |
+
431 4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
|
| 450 |
+
|
| 451 |
+
(a) If your work uses existing assets, did you cite the creators? [Yes]
|
| 452 |
+
(b) Did you mention the license of the assets? [No] Assests used follow the MIT license, granting the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software.
|
| 453 |
+
(c) Did you include any new assets either in the supplemental material or as a URL? [Yes] (d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [N/A]
|
| 454 |
+
(e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [N/A]
|
| 455 |
+
|
| 456 |
+
# 441 A Experimental Details
|
| 457 |
+
|
| 458 |
+
# 2 A.1 Experimental details of classification tasks
|
| 459 |
+
|
| 460 |
+
We report the average performance over five independent training processes, and the models are trained for 100 epochs for all three datasets.
|
| 461 |
+
|
| 462 |
+
445 The input for 2nd-Ord, NODE, and C-NODE are the original images. In the IL-NODE, we transform
|
| 463 |
+
446 the input to a latent space before the integration by the integral; that is, we raise the $\mathbb { R } ^ { c \times h \times w }$
|
| 464 |
+
447 dimensional input image into the $\mathbb { R } ^ { ( c + p ) \times h \times w }$ dimensional latent feature space3. We decode the
|
| 465 |
+
448 result after performing the continuous transformations along characteristics curves, back to the
|
| 466 |
+
449 $\mathbb { R } ^ { c \times h \times w }$ dimensional object space. Combining this with the C-NODE can be seen as solving a PDE
|
| 467 |
+
450 on the latest features of the images rather than on the images directly. We solve first-order PDEs with
|
| 468 |
+
451 three variables in CIFAR-10 and SVHN and solve first-order PDEs with two variables in MNIST.
|
| 469 |
+
452 The number of parameters of the models is similar by adjusting the number of features used in the
|
| 470 |
+
453 networks. We use similar training hyperparameters as [32].
|
| 471 |
+
454 Unlike ODEs, we take derivatives with respect to different variables in PDEs. For a PDE with $k$
|
| 472 |
+
455 variables, this results in the constraint of the balance equations
|
| 473 |
+
|
| 474 |
+
$$
|
| 475 |
+
\frac { \partial ^ { 2 } u } { \partial x _ { i } x _ { j } } = \frac { \partial ^ { 2 } u } { \partial x _ { j } x _ { i } } , \mathrm { ~ } i , j \in \{ 1 , 2 , . . . , k \} , \mathrm { ~ } i \neq j .
|
| 476 |
+
$$
|
| 477 |
+
|
| 478 |
+
456 This can be satisfied by defining the $k$ -th derivative with a neural network, and integrate $k - 1$ times
|
| 479 |
+
457 to get the first order derivatives. Another way of satisfying the balance equation is to drop the
|
| 480 |
+
458 dependency on the variables, i.e., $\forall i \in \{ 1 , 2 , . . . , k \}$ ,
|
| 481 |
+
|
| 482 |
+
$$
|
| 483 |
+
\frac { \partial u } { \partial x _ { i } } = f _ { i } ( u ; \theta ) .
|
| 484 |
+
$$
|
| 485 |
+
|
| 486 |
+
459 When we drop the dependency, all higher order derivatives are zero, and the balance equations are
|
| 487 |
+
460 satisfied.
|
| 488 |
+
|
| 489 |
+
All experiments were performed on NVIDIA RTX 3090 GPUs on a cloud cluster.
|
| 490 |
+
|
| 491 |
+
# A.2 Experimental details of continuous normalizing flows
|
| 492 |
+
|
| 493 |
+
We report the average performance over four independent training processes. As shown in Figure 4, compared to NODE, using a C-NODE structure improves the stability of training, as well as having a better performance. Specifically, the standard errors for C-NODEs on MNIST, SVHN, and CIFAR-10 are $0 . 3 7 \%$ , $0 . 5 1 \%$ , and $0 . 2 4 \%$ respectively, and for NODEs the standard errors on MNIST, SVHN, and CIFAR-10 are $1 . 0 7 \%$ , $0 . 3 2 \%$ , and $0 . 2 2 \%$ respectively.
|
| 494 |
+
|
| 495 |
+
The experiments are developed using code adapted from the code that the authors of [13] provided in https://github.com/rtqichen/ffjord.
|
| 496 |
+
|
| 497 |
+
70 All experiments were performed on NVIDIA RTX 3090 GPUs on a cloud cluster.
|
| 498 |
+
|
| 499 |
+
# A.3 Experimental details of PDE modeling
|
| 500 |
+
|
| 501 |
+
472 We want to solve the initial value problem
|
| 502 |
+
|
| 503 |
+
$$
|
| 504 |
+
\left\{ \begin{array} { l l } { u { \frac { \partial u } { \partial x } } + { \frac { \partial u } { \partial t } } = u , } & \\ { u ( x , 0 ) = 2 x , } & { 1 \leq x \leq 2 , } \end{array} \right.
|
| 505 |
+
$$
|
| 506 |
+
|
| 507 |
+
where the exact solution is 473 $\begin{array} { r } { u ( x , t ) = \frac { 2 x e ^ { t } } { ( 2 e ^ { t } + 1 ) } } \end{array}$ . Our dataset’s input are 200 randomly sampled points 474 $( x , t ) , x \in [ 1 , 2 ] , t \in [ 0 , 1 ]$ , and the dataset’s outputare the exact solutions at those points.
|
| 508 |
+
|
| 509 |
+
475 For the C-NODE architecture, we define four networks: $N N _ { 1 } ( x , t )$ for $\textstyle { \frac { \partial u } { \partial x } }$ , $N N _ { 2 } ( x , t )$ for $\frac { \partial u } { \partial \underline { { t } } }$ ,
|
| 510 |
+
476 for the initial condition. The result is
|
| 511 |
+
477 calculated in four steps:
|
| 512 |
+
|
| 513 |
+

|
| 514 |
+
Figure 4: The training process averaged over 4 runs of C-NODE and NODE. The first row are the results on MNIST, the second row are the results on SVHN, the third row are the results on CIFAR-10.
|
| 515 |
+
|
| 516 |
+
1. Integrate $\begin{array} { r } { \Delta u = \int _ { 0 } ^ { t } \frac { d u ( x ( s ) , t ( s ) ) } { d s } d s = \int _ { 0 } ^ { t } \frac { \partial u } { \partial t } \frac { d t } { d s } + \frac { \partial u } { \partial x } \frac { d x } { d s } d s = N N _ { 2 } * N N _ { 3 } [ 0 ] + N N _ { 1 } * } \end{array}$ $N N _ { 3 } [ 1 ] d s$ as before.
|
| 517 |
+
|
| 518 |
+
2. Given $x , t$ , solve equation $\iota + N N _ { 3 } ( N N _ { 4 } ( \iota ) ) [ 0 ] * t = x$ for $\iota$ iteratively, with $\begin{array} { l } { { \iota _ { n + 1 } } = } \end{array}$ $x - N N _ { 3 } ( N N _ { 4 } ( \iota _ { n } ) ) [ 0 ] * t . \iota$ $\iota _ { 0 }$ is initialized to be $x$ .
|
| 519 |
+
|
| 520 |
+
3. Calculate initial value $u ( x ( 0 ) , t ( 0 ) ) = N N _ { 4 } ( \iota )$ .
|
| 521 |
+
|
| 522 |
+
4. $\boldsymbol { u } ( \boldsymbol { x } , t ) = \Delta \boldsymbol { u } + \boldsymbol { u } ( \boldsymbol { x } ( 0 ) , t ( 0 ) )$ .
|
| 523 |
+
|
| 524 |
+
For the NODE architecture, we define one network: $N N _ { 1 } ( x , t )$ for $\frac { \partial u } { \partial t }$ . The result is calculated as $\begin{array} { r } { u ( x , t ) = \int _ { 0 } ^ { t } \frac { \partial u } { \partial t } d t = \int _ { 0 } ^ { t } N N _ { 1 } d t . } \end{array}$ .
|
| 525 |
+
|
| 526 |
+
All experiments were performed on NVIDIA RTX 3080 ti GPUs on a local machine.
|
| 527 |
+
|
| 528 |
+
# A.4 Experimental results and details of time series predictions
|
| 529 |
+
|
| 530 |
+
# A.4.1 Experimental details of time series predictions on MuJoCo dataset
|
| 531 |
+
|
| 532 |
+
We follow the experimental setup as described in https://github.com/YuliaRubanova/ latent_ode. NODE’s training follows the original setup, with the dimension of the recognition model being 30, the number of units per layer in each of GRU update networks being 100, the number of units per layer in ODE function being 300, the number of layers in ODE function in generative and recognition ODE both being 3.
|
| 533 |
+
|
| 534 |
+
We use a C-NODE with a dimensionality of 128. The number of units per layer in the network describing $d \mathbf { x } / d \mathbf { s }$ is 12. For the network describing $\partial \mathbf { u } / \partial x _ { i }$ , the dimension of the recognition model is 30, the number of units per layer in each of GRU update networks is 100, the number of units per layer in the ODE function is 100, the number of layers in ODE function in generative and recognition ODE is 1.
|
| 535 |
+
|
| 536 |
+

|
| 537 |
+
Figure 5: Red: NODE. Blue: C-NODE. Training dynamics of ODE-RNNs on the MuJoCo dataset with the “Hopper” model from the Deepmind Control Suit [45]. We present testing mean squared error (MSE) of training epochs 10 to 100. The C-NODE method achieves lower testing MSE while having a lower variance.
|
| 538 |
+
|
| 539 |
+
# A.4.2 Experiment results of time series predictions on synthetic dataset
|
| 540 |
+
|
| 541 |
+
500 We test C-NODEs, ANODEs, and NODEs on a synthetic time series prediction problem. We define
|
| 542 |
+
501 a function by $\begin{array} { r } { u ( x , t ) = \frac { 2 x \exp ( t ) } { 2 \exp ( t ) + 1 } } \end{array}$ 2x exp(t)2 exp(t)+1 , and we sample u˜ = u(x, t) + 0.1ϵt, where ϵt ∼ N (0, 1) over
|
| 543 |
+
502 $x \in [ 1 , 2 ]$ , $t \in [ 0 , 1 ]$ to generate the training dataset. We test the performance on $t \in [ n , n + 1 ]$
|
| 544 |
+
503 with $n \in \{ 0 , 1 , \ldots , 5 \}$ . To make the problem more challenging, $x$ values are omitted, and only $t$
|
| 545 |
+
504 values are provided during both training and testing. As shown in Table 3, C-NODE produces more
|
| 546 |
+
505 profound improvements over NODEs as time increases.
|
| 547 |
+
|
| 548 |
+
<table><tr><td>Time</td><td>[0,1]</td><td>[1,2]</td><td>[2.3]</td><td>[3,4]</td><td>[4,5]</td><td>[5,6]</td></tr><tr><td>NODE</td><td>0.0322</td><td>0.1764</td><td>0.4681</td><td>0.8093</td><td>1.1911</td><td>1.6202</td></tr><tr><td>ANODE</td><td>0.0428</td><td>0.0629</td><td>0.1248</td><td>0.2778</td><td>0.5360</td><td>0.9252</td></tr><tr><td>C-NODE</td><td>0.0270</td><td>0.0365</td><td>0.0582</td><td>0.1474</td><td>0.3300</td><td>0.6054</td></tr></table>
|
| 549 |
+
|
| 550 |
+
Table 3: Time series prediction results for NODE, ANODE, and C-NODE at different time intervals. Errors are testing mean squared errors. Across all time intervals, C-NODE outperforms NODE and ANODE.
|
| 551 |
+
|
| 552 |
+
506 We also test C-NODEs, NODEs, and ANODEs on time series prediction with different levels of
|
| 553 |
+
507 noise. Specifically, using the same function as above, we form training and testing dataset with
|
| 554 |
+
508 $\epsilon _ { t } \sim \mathcal { N } ( 0 , m )$ , $\_$ . We test the performance on the time period $t \in [ 0 , 1 ]$ .
|
| 555 |
+
|
| 556 |
+
<table><tr><td>Noise Level</td><td>0</td><td>1</td><td>2</td><td>3</td><td>4</td><td>5</td></tr><tr><td>NODE</td><td>0.0326</td><td>0.1784</td><td>0.7886</td><td>1.9685</td><td>3.7530</td><td>6.1553</td></tr><tr><td>ANODE</td><td>0.04</td><td>0.1984</td><td>0.6035</td><td>1.0574</td><td>1.4850</td><td>2.0593</td></tr><tr><td>C-NODE</td><td>0.0267</td><td>0.1011</td><td>0.3294</td><td>0.7148</td><td>1.2856</td><td>2.0834</td></tr></table>
|
| 557 |
+
|
| 558 |
+
Table 4: Time series prediction results for NODE, ANODE, and C-NODE at different noise levels. Errors are testing mean squared errors.
|
| 559 |
+
|
| 560 |
+
# 509 A.4.3 Experimental details of time series predictions on synthetic dataset
|
| 561 |
+
|
| 562 |
+
We want to predict 510 $\textstyle u ( x , t ) = { \frac { 2 \cdot x \cdot e ^ { t } } { 2 \cdot e ^ { t } + 1 } }$ at different time $t$ , with $x \in [ 1 , 2 ]$ , and $x$ being not accessible to 511 the network. We also provide the network with the value of $u ( 1 , 0 )$ .
|
| 563 |
+
|
| 564 |
+
512 We use a 8 dimensional C-NODE network. The result is calculated with
|
| 565 |
+
|
| 566 |
+
$$
|
| 567 |
+
u ( x , t ) = u ( 1 , 0 ) + \int _ { 0 } ^ { t } \sum _ { i = 1 } ^ { 8 } \frac { \partial u } { \partial z _ { i } } \frac { d z _ { i } } { d s } d s .
|
| 568 |
+
$$
|
| 569 |
+
|
| 570 |
+
$$
|
| 571 |
+
u ( x , t ) = u ( 1 , 0 ) + \int _ { 0 } ^ { t } \frac { \partial u } { \partial t } d t .
|
| 572 |
+
$$
|
| 573 |
+
|
| 574 |
+
514 In our experiments, C-NODEs use 1221 parameters, ANODEs use 1270 parameters, NODEs use
|
| 575 |
+
515 1290 parameters.
|
| 576 |
+
|
| 577 |
+
All experiments were performed on NVIDIA RTX 3080 ti GPUs on a local machine.
|
| 578 |
+
|
| 579 |
+
# 517 B Approximation Capabilities of C-NODE
|
| 580 |
+
|
| 581 |
+
Proposition B.1 (Method of Characteristics for Vector Valued PDEs). Let 518 $\mathbf { u } ( x _ { 1 } , \ldots , x _ { k } ) : \mathbb { R } ^ { k } \to \mathbb { R } ^ { n }$ be the solution of a first order semilinear PDE on a bounded domain 519 $\Omega \subset \mathbb { R } ^ { k }$ of the form
|
| 582 |
+
|
| 583 |
+
$$
|
| 584 |
+
\sum _ { i = 1 } ^ { k } a _ { i } ( x _ { 1 } , \dots , x _ { k } , \mathbf { u } ) { \frac { \partial \mathbf { u } } { \partial x _ { i } } } = \mathbf { c } ( x _ { 1 } , \dots , x _ { k } , \mathbf { u } ) \quad o n \ ( x _ { 1 } , \dots , x _ { k } ) = \mathbf { x } \in \Omega .
|
| 585 |
+
$$
|
| 586 |
+
|
| 587 |
+
Additionally, let 520 $\mathbf { a } = ( a _ { 1 } , \ldots , a _ { k } ) ^ { T } : \mathbb { R } ^ { k + n } \to \mathbb { R } ^ { k } , \mathbf { c } : \mathbb { R } ^ { k + n } \to \mathbb { R } ^ { n }$ be Lipschitz continuous 521 functions. Define a system of ODEs as
|
| 588 |
+
|
| 589 |
+
$$
|
| 590 |
+
\left\{ \begin{array} { l l } { \frac { d \mathbf { x } } { d s } ( s ) } & { = \mathbf { a } ( \mathbf { x } ( s ) , \mathbf { U } ( s ) ) } \\ { \frac { d \mathbf { U } } { d s } ( s ) } & { = \mathbf { c } ( \mathbf { x } ( s ) , \mathbf { U } ( s ) ) } \\ { \mathbf { x } ( 0 ) } & { : = \mathbf { x } _ { 0 } , \mathbf { x } _ { 0 } \in \partial \Omega } \\ { \mathbf { u } ( \mathbf { x } _ { 0 } ) } & { : = \mathbf { u } _ { 0 } } \\ { \mathbf { U } ( 0 ) } & { : = \mathbf { u } _ { 0 } } \end{array} \right.
|
| 591 |
+
$$
|
| 592 |
+
|
| 593 |
+
522 where $\mathbf { x } _ { \mathrm { 0 } }$ and $\mathbf { u } _ { 0 }$ define the initial condition, $\partial \Omega$ is the boundary of the domain $\Omega$ . Given initial
|
| 594 |
+
523 conditions $\mathbf { x } _ { 0 } , \mathbf { u } _ { 0 }$ , the solution of this system of ODEs $\mathbf { U } ( s ) : [ a , b ] \mathbb { R } ^ { d }$ is equal to the solution of
|
| 595 |
+
524 the PDE in Equation (11) along the characteristic curve defined by $\mathbf { x } ( s )$ , i.e., $\mathbf { u } ( \mathbf { x } ( s ) ) = \mathbf { U } ( s )$ . The
|
| 596 |
+
525 union of solutions $\mathbf { U } ( s )$ for all $\mathbf { x } _ { 0 } \in \partial \Omega$ is equal to the solution of the original PDE in Equation
|
| 597 |
+
526 (11) for all $\mathbf { x } \in \Omega$ .
|
| 598 |
+
|
| 599 |
+
Lemma B.2 (Gronwall’s Lemma [19]). Let $U \subset \mathbb { R } ^ { n }$ be an open set. Let f : $U \times [ 0 , T ] \mathbb { R } ^ { n }$ be $a$ continuous function and let $\mathbf { h _ { 1 } }$ , $\mathbf { h } _ { 2 } : [ 0 , T ] U$ satisfy the initial value problems:
|
| 600 |
+
|
| 601 |
+
$$
|
| 602 |
+
\frac { d { \bf h _ { 1 } } ( t ) } { d t } = f ( { \bf h _ { 1 } } ( t ) , t ) , { \bf h _ { 1 } } ( 0 ) = { \bf x _ { 1 } } ,
|
| 603 |
+
$$
|
| 604 |
+
|
| 605 |
+
$$
|
| 606 |
+
\frac { d { \bf h _ { 2 } } ( t ) } { d t } = f ( { \bf h _ { 2 } } ( t ) , t ) , { \bf h _ { 2 } } ( 0 ) = { \bf x _ { 2 } } .
|
| 607 |
+
$$
|
| 608 |
+
|
| 609 |
+
If there exists non-negative constant $C$ such that for all $t \in [ 0 , T ]$
|
| 610 |
+
|
| 611 |
+
$$
|
| 612 |
+
\| \mathbf { f } ( \mathbf { h _ { 2 } } ( t ) , t ) - \mathbf { f } ( \mathbf { h _ { 1 } } ( t ) , t ) \| \leq C \| \mathbf { h _ { 2 } } ( t ) - \mathbf { h _ { 1 } } ( t ) \| ,
|
| 613 |
+
$$
|
| 614 |
+
|
| 615 |
+
where $\| \cdot \|$ is the Euclidean norm. Then, for all $t \in [ 0 , T ]$ ,
|
| 616 |
+
|
| 617 |
+
$$
|
| 618 |
+
\| \mathbf { h } _ { \mathbf { 2 } } ( t ) - \mathbf { h } _ { \mathbf { 1 } } ( t ) \| \leq e ^ { C t } \| \mathbf { x } _ { \mathbf { 2 } } - \mathbf { x } _ { \mathbf { 1 } } \| .
|
| 619 |
+
$$
|
| 620 |
+
|
| 621 |
+
# 527 B.1 Proof of Proposition B.1
|
| 622 |
+
|
| 623 |
+
This proof is largely based on the proof for the univarate case provided at4. We extend for the vector valued case.
|
| 624 |
+
|
| 625 |
+
Proof. For PDE on 530 $\mathbf { u }$ with $k$ input, and an $n$ -dimensional output, we have $a _ { i } : \mathbb { R } ^ { k + n } \mathbb { R }$ , $\frac { \partial \mathbf { u } } { \partial x _ { i } } \in \mathbb { R } ^ { n }$ , and 531 $\mathbf { c } : \mathbb { R } ^ { k + n } \mathbb { R } ^ { n }$ . In proposition B.1, we look at PDEs in the following form
|
| 626 |
+
|
| 627 |
+
$$
|
| 628 |
+
\sum _ { i = 1 } ^ { k } a _ { i } ( x _ { 1 } , \dots , x _ { k } , \mathbf { u } ) { \frac { \partial \mathbf { u } } { \partial x _ { i } } } = \mathbf { c } ( x _ { 1 } , \dots , x _ { k } , \mathbf { u } ) .
|
| 629 |
+
$$
|
| 630 |
+
|
| 631 |
+
4https://en.wikipedia.org/wiki/Method_of_characteristics#Proof_for_quasilinear_ Case
|
| 632 |
+
|
| 633 |
+
532 Defining and substituting $\mathbf { x } ~ = ~ ( x _ { 1 } , \ldots , x _ { k } ) ^ { \intercal }$ , $\mathbf { a } ~ = ~ ( a _ { 1 } , \ldots , a _ { k } ) ^ { \intercal }$ , and Jacobian $\begin{array} { r } { { \bf J } ( { \bf u } ( { \bf x } ) ) = } \end{array}$
|
| 634 |
+
533 $\bigl ( \frac { \partial \mathbf { u } } { \partial x _ { 1 } } , . . . , \mathbf { \frac { \partial \mathbf { u } } { \partial x _ { k } } } \bigr ) \ \in \mathbb { R } ^ { n \times k }$ into Equation (11) result in
|
| 635 |
+
|
| 636 |
+
$$
|
| 637 |
+
\mathbf { J } ( \mathbf { u } ( \mathbf { x } ) ) \mathbf { a } ( \mathbf { x } , \mathbf { u } ) = \mathbf { c } ( \mathbf { x } , \mathbf { u } ) .
|
| 638 |
+
$$
|
| 639 |
+
|
| 640 |
+
From proposition B.1, the characteristic curves are given by
|
| 641 |
+
|
| 642 |
+
$$
|
| 643 |
+
{ \frac { d x _ { i } } { d s } } = a _ { i } ( x _ { 1 } , \dots , x _ { k } , \mathbf { u } ) ,
|
| 644 |
+
$$
|
| 645 |
+
|
| 646 |
+
534 and the ODE system is given by
|
| 647 |
+
|
| 648 |
+
$$
|
| 649 |
+
\frac { d \mathbf { x } } { d s } ( s ) = \mathbf { a } ( \mathbf { x } ( s ) , \mathbf { U } ( s ) ) ,
|
| 650 |
+
$$
|
| 651 |
+
|
| 652 |
+
535
|
| 653 |
+
|
| 654 |
+
$$
|
| 655 |
+
\frac { d \mathbf { U } } { d s } ( s ) = \mathbf { c } ( \mathbf { x } ( s ) , \mathbf { U } ( s ) ) .
|
| 656 |
+
$$
|
| 657 |
+
|
| 658 |
+
Define the difference between the solution to (15) and the PDE in (11) as
|
| 659 |
+
|
| 660 |
+
$$
|
| 661 |
+
\Delta ( s ) = \| \mathbf { u } ( \mathbf { x } ( s ) ) - \mathbf { U } ( s ) \| ^ { 2 } = ( \mathbf { u } ( \mathbf { x } ( s ) ) - \mathbf { U } ( s ) ) ^ { \top } \left( \mathbf { u } ( \mathbf { x } ( s ) ) - \mathbf { U } ( s ) \right) ,
|
| 662 |
+
$$
|
| 663 |
+
|
| 664 |
+
536 Differentiating $\Delta ( s )$ with respect to $s$ and plugging in (14), we get
|
| 665 |
+
|
| 666 |
+
$$
|
| 667 |
+
\begin{array} { c } { \displaystyle \Delta ^ { \prime } ( s ) : = \frac { d \Delta ( s ) } { d s } = 2 ( \mathbf { u } ( \mathbf { x } ( s ) ) - \mathbf { U } ( s ) ) \cdot ( \mathbf { J } ( \mathbf { u } ) \mathbf { x } ^ { \prime } ( s ) - \mathbf { U } ^ { \prime } ( s ) ) } \\ { = 2 [ \mathbf { u } ( \mathbf { x } ( s ) ) - \mathbf { U } ( s ) ] \cdot [ \mathbf { J } ( \mathbf { u } ) \mathbf { a } ( \mathbf { x } ( s ) , \mathbf { U } ( s ) ) - \mathbf { c } ( \mathbf { x } ( s ) , \mathbf { U } ( s ) ) ] . } \end{array}
|
| 668 |
+
$$
|
| 669 |
+
|
| 670 |
+
(13) gives us 537 $\begin{array} { r } { \sum _ { i = 1 } ^ { k } a _ { i } ( x _ { 1 } , \ldots , x _ { k } , \mathbf { u } ) { \frac { \partial \mathbf { u } } { \partial x _ { i } } } - \mathbf { c } ( x _ { 1 } , \ldots , x _ { k } , \mathbf { u } ) = 0 } \end{array}$ . Plugging this equality into (16) 538 and rearrange terms, we have
|
| 671 |
+
|
| 672 |
+
$$
|
| 673 |
+
\begin{array} { r } { \Delta ^ { \prime } ( s ) = 2 [ \mathbf { u } ( \mathbf { x } ( s ) ) - \mathbf { U } ( s ) ] \cdot \{ [ \mathbf { J } ( \mathbf { u } ) \mathbf { a } ( \mathbf { x } ( s ) , \mathbf { U } ( s ) ) - \mathbf { c } ( \mathbf { x } ( s ) , \mathbf { U } ( s ) ) ] } \\ { - [ \mathbf { J } ( \mathbf { u } ) \mathbf { a } ( \mathbf { x } ( s ) , \mathbf { u } ( s ) ) - \mathbf { c } ( \mathbf { x } ( s ) , \mathbf { u } ( s ) ) ] \} . } \end{array}
|
| 674 |
+
$$
|
| 675 |
+
|
| 676 |
+
539 Combining terms, we have
|
| 677 |
+
|
| 678 |
+
$$
|
| 679 |
+
\begin{array} { r l } & { \Delta ^ { \prime } = 2 ( \mathbf { u } - \mathbf { U } ) \cdot \left( \left[ \mathbf { J } ( \mathbf { u } ) \mathbf { a } ( \mathbf { U } ) - \mathbf { c } ( \mathbf { U } ) \right] - \left[ \mathbf { J } ( \mathbf { u } ) \mathbf { a } ( \mathbf { u } ) - \mathbf { c } ( \mathbf { u } ) \right] \right) } \\ & { \quad = 2 ( \mathbf { u } - \mathbf { U } ) \cdot \left( \mathbf { J } ( \mathbf { u } ) \left[ \mathbf { a } ( \mathbf { U } ) - \mathbf { a } ( \mathbf { u } ) \right] + \left[ \mathbf { c } ( \mathbf { U } ) - \mathbf { c } ( \mathbf { u } ) \right] \right) . } \end{array}
|
| 680 |
+
$$
|
| 681 |
+
|
| 682 |
+
540 Applying triangle inequality, we have
|
| 683 |
+
|
| 684 |
+
$$
|
| 685 |
+
\begin{array} { r } { \| \boldsymbol { \Delta } ^ { \prime } \| \leq 2 \| \mathbf { u } - \mathbf { U } \| \big ( \| \mathbf { J } ( \mathbf { u } ) \| \| \mathbf { a } ( \mathbf { U } ) - \mathbf { a } ( \mathbf { u } ) \| + \| \mathbf { c } ( \mathbf { U } ) - \mathbf { c } ( \mathbf { u } ) \| \big ) . } \end{array}
|
| 686 |
+
$$
|
| 687 |
+
|
| 688 |
+
541 By the assumption in proposition B.1, a and c are Lipschitz continuous. By Lipschitz continuity, we
|
| 689 |
+
542 have $\| \mathbf { a } ( \mathbf { U } ) - \mathbf { a } ( \mathbf { u } ) ) \| \leq A \| \mathbf { u } - \mathbf { U } \|$ and $\| \mathbf { c } ( \mathbf { U } ) - \mathbf { c } ( \mathbf { u } ) ) \| \leq B \| \mathbf { u } - \mathbf { U } \|$ , for some constants A and
|
| 690 |
+
543 B in $\mathbb { R } _ { + }$ . Also, for compact set $[ 0 , s _ { 0 } ]$ , $s _ { 0 } < \infty$ , since both $\mathbf { u }$ and Jacobian $\mathbf { J }$ are continuous mapping,
|
| 691 |
+
544 $\mathbf { J } ( \mathbf { u } )$ is also compact. Since a subspace of $\mathbb { R } ^ { n }$ is compact if and only it is closed and bounded, $\mathbf { J } ( \mathbf { u } )$
|
| 692 |
+
545 is bounded [43]. Thus, $\| \mathbf { J } ( \mathbf { u } ) \| \leq M$ for some constant $M$ in $\mathbb { R } _ { + }$ . Define $C = 2 ( A M + B )$ , we
|
| 693 |
+
546 have
|
| 694 |
+
|
| 695 |
+
$$
|
| 696 |
+
\begin{array} { r l } & { \| \boldsymbol { \Delta } ^ { \prime } ( s ) \| \leq 2 ( A M \| \mathbf { u } - \mathbf { U } \| + B \| \mathbf { u } - \mathbf { U } \| ) \| \mathbf { u } - \mathbf { U } \| } \\ & { \qquad = C \| \mathbf { u } - \mathbf { U } \| ^ { 2 } } \\ & { \qquad = C \| \boldsymbol { \Delta } ( s ) \| . } \end{array}
|
| 697 |
+
$$
|
| 698 |
+
|
| 699 |
+
From proposition B.1, we have $\mathbf { u } ( \mathbf { x } ( 0 ) ) = \mathbf { U } ( 0 )$ . As proved above, we have
|
| 700 |
+
|
| 701 |
+
$$
|
| 702 |
+
\left\| \frac { d \mathbf { u } ( \mathbf { x } ( s ) ) } { d s } - \frac { d \mathbf { U } ( s ) } { d s } \right\| : = \| \Delta ^ { \prime } ( s ) \| \leq C \| \Delta ( s ) \| ,
|
| 703 |
+
$$
|
| 704 |
+
|
| 705 |
+
where $C < \infty$ . Thus, by lemma B.2, we have
|
| 706 |
+
|
| 707 |
+
$$
|
| 708 |
+
\| \boldsymbol { \Delta } ( s ) \| \leq e ^ { C t } \| \boldsymbol { \Delta } ( 0 ) \| = e ^ { C t } \| \mathbf { u } ( \mathbf { x } ( 0 ) ) - \mathbf { U } ( 0 ) \| = 0 .
|
| 709 |
+
$$
|
| 710 |
+
|
| 711 |
+
547 This further implies that $\mathbf { U } ( s ) = \mathbf { u } ( \mathbf { x } ( s ) )$ , so long as a and c are Lipschitz continuous.
|
| 712 |
+
|
| 713 |
+

|
| 714 |
+
Figure 6: Comparison of C-NODEs and NODEs. C-NODEs (solid blue) learn a family of integration paths conditioned on the input value, avoiding intersecting dynamics. NODEs (dashed red) integrate along a 1D line that is not conditioned on the input value and can not represent functions requiring intersecting dynamics.
|
| 715 |
+
|
| 716 |
+
# 548 B.2 Proof of Proposition 4.1
|
| 717 |
+
|
| 718 |
+
Proof. Suppose have C-NODE given by
|
| 719 |
+
|
| 720 |
+
$$
|
| 721 |
+
{ \frac { \mathrm { d } u } { \mathrm { d } s } } = { \frac { \partial u } { \partial x } } { \frac { d x } { d s } } + { \frac { \partial u } { \partial t } } { \frac { d t } { d s } } .
|
| 722 |
+
$$
|
| 723 |
+
|
| 724 |
+
549 Write out specific functions for these terms to match the desired properties of the function. Define
|
| 725 |
+
550 initial condition $u ( 0 , 0 ) = u _ { 0 }$ . By setting
|
| 726 |
+
|
| 727 |
+
$$
|
| 728 |
+
\begin{array} { l l } { \displaystyle \frac { d x } { d s } \left( s , u _ { 0 } , \theta \right) = 1 , \ ~ } & { \displaystyle \frac { d t } { d s } \left( s , u _ { 0 } , \theta \right) = u _ { 0 } , } \\ { \displaystyle \frac { \partial u } { \partial x } ( u ( x , t ) , \theta ) = 1 , \ ~ } & { \displaystyle \frac { \partial u } { \partial t } ( u ( x , t ) , \theta ) = - 2 , } \end{array}
|
| 729 |
+
$$
|
| 730 |
+
|
| 731 |
+
551 have the ODE and solution,
|
| 732 |
+
|
| 733 |
+
$$
|
| 734 |
+
\begin{array} { r l r } { { \frac { \mathrm { d } u } { \mathrm { d } s } = 1 - 2 u _ { 0 } } } \\ & { \implies u ( s ; u _ { 0 } ) = ( 1 - 2 u _ { 0 } ) s } \\ & { \implies u ( s ; [ \begin{array} { l } { 0 } \\ { 1 } \end{array} ] ) = ( 1 - 2 [ \begin{array} { l } { 0 } \\ { 1 } \end{array} ] ) s = [ \begin{array} { l } { 1 } \\ { - 1 } \end{array} ] s . } \end{array}
|
| 735 |
+
$$
|
| 736 |
+
|
| 737 |
+
552 To be specific, we can represent this system with the following family of PDEs:
|
| 738 |
+
|
| 739 |
+
$$
|
| 740 |
+
{ \frac { \partial u } { \partial x } } + u _ { 0 } { \frac { \partial u } { \partial t } } = 1 - 2 u _ { 0 } .
|
| 741 |
+
$$
|
| 742 |
+
|
| 743 |
+
553 We can solve this system to obtain a function that has intersecting trajectories. The solution is
|
| 744 |
+
554 visualized in Figure 6, which shows that C-NODE can be used to learn and represent this function
|
| 745 |
+
555 $\mathcal { G }$ . It should be noted that this is not the only possible solution to function $\mathcal { G }$ , as when $\partial t / \partial s = 0$ ,
|
| 746 |
+
556 we fall back to a NODE system with the dynamical system conditioned on the input data. In this
|
| 747 |
+
557 conditioned setting, we can then represent $\mathcal { G }$ by stopping the dynamics at different times $t$ as in [32].
|
| 748 |
+
|
| 749 |
+
558
|
| 750 |
+
|
| 751 |
+
# B.3 Proof of Proposition 4.2
|
| 752 |
+
|
| 753 |
+
560 The proof uses the change of variables formula for a particle that depends on a vector rather than a
|
| 754 |
+
561 scalar and it follows directly from the proof given in [5, Appendix A]. We provide the full proof for
|
| 755 |
+
562 completeness.
|
| 756 |
+
|
| 757 |
+
Proof. Assume 563 $\textstyle \sum _ { i = 1 } ^ { k } { \frac { \partial u } { \partial x _ { i } } } { \frac { d x _ { i } } { d s } }$ is Lipschitz continuous in $u$ and continuous in $t$ , so every initial value 564 problem has a unique solution [12]. Also assume is bounded.
|
| 758 |
+
|
| 759 |
+
565 Want
|
| 760 |
+
|
| 761 |
+
$$
|
| 762 |
+
{ \frac { \partial p ( u ( s ) ) } { \partial s } } = \operatorname { t r } \left( { \frac { \partial } { \partial u } } \sum _ { i = 1 } ^ { k } { \frac { \partial u } { \partial x _ { i } } } { \frac { d x _ { i } } { d s } } \right) .
|
| 763 |
+
$$
|
| 764 |
+
|
| 765 |
+
567 566 Define $\begin{array} { r } { \log p ( u _ { 0 } ) - \log | \operatorname* { d e t } \frac { \partial f } { \partial u _ { 0 } } | } \end{array}$ $T _ { \epsilon } = u ( s + \epsilon )$ . The discrete change of variables states that [38]. $u _ { 1 } = f ( u _ { 0 } ) \Rightarrow \log p ( u _ { 1 } ) =$
|
| 766 |
+
|
| 767 |
+
568 Take the limit of the time difference between $u _ { 0 }$ and $u _ { 1 }$ , by definition of derivatives,
|
| 768 |
+
|
| 769 |
+
$$
|
| 770 |
+
\begin{array} { r l } { { \frac { \partial \log y ( x ( s ) ) } { \partial s } } = { \frac { \ln 1 } { s ^ { 3 } } } \log y ( s ( s ( s + s ) ) - { \frac { 1 } { s } } \log y ( s ( s ) ) } \\ & { = { \frac { 1 } { s ^ { 3 } } } \log y ( s ( s ) ) - \log \log x ( s ( s ( s ) ) ) - \log x ( s ( s ( s ) ) ) } \\ & { = - { \frac { \ln 1 } { s ^ { 3 } } } \log y ( s ( s ( s ) ) - { \frac { 1 } { s } } \log x ( s ( s ( s ) ) ) } \\ & { = - { \frac { \ln 1 } { s ^ { 3 } } } \log \log \left( \log { \frac { \partial } { \partial s } } \right) } \\ & { = - { \frac { \ln 1 } { s ^ { 3 } } } { \frac { \partial \log y ( x ( s ) ) } { \partial s } } \operatorname* { d e t } \frac { \partial ^ { 2 } \pi ( s ( s ) ) } { \partial s ^ { 2 } } } \\ & { = - { \frac { \ln 1 } { s ^ { 3 } } } { \frac { \partial \log y ( x ( s ) ) } { \partial s } } \operatorname* { d e t } \frac { \partial ^ { 2 } \pi ( s ( s ) ) } { \partial s ^ { 3 } } \prod _ { s = 0 } ^ { 1 } \operatorname* { d e t } \operatorname* { d e t } \frac { \partial ^ { 2 } \pi ( s ( s ) ) } { \partial s ^ { 2 } } } \\ & = - { \frac { \ln 1 } { s ^ { 3 } } } { \frac { \partial \log y ( x ( s ) ) } { \partial s } } \operatorname* { d e t } \operatorname* { d e t } \operatorname* { d e t } \operatorname* { d e t } \operatorname* { d e t } \operatorname* { d e t } \operatorname* { d e t } \operatorname* { d e t } \operatorname* { d e t } \operatorname* { d e t } \operatorname* { d e t } \operatorname* { d e t } \operatorname* { d e t } \operatorname* { d e t } \operatorname* { d e t } \operatorname* { d e t } \operatorname* { d e t } \operatorname* { d e t } \operatorname* { d e t } \operatorname* { d e t } \operatorname* { d e t } \operatorname* { d e t } \operatorname* { d e t } \operatorname* { d e t } \operatorname* { d e t } \operatorname* { d e t } \operatorname* { d e t } \operatorname* { d e t } \operatorname* { d e t } \operatorname* { d e t } \operatorname* { d e t } \operatorname* { d e t } \operatorname* { d e t } \operatorname* { d e t } \operatorname* { d e t } \operatorname* { d e t } \operatorname* { d e t } \operatorname* { d e t } \operatorname* { d e t } \operatorname* { d e t } \operatorname* { d e t } \operatorname* { d e t } \operatorname* { d e t } \operatorname* { d e t } \operatorname* { d e t } \ \end{array}
|
| 771 |
+
$$
|
| 772 |
+
|
| 773 |
+
569 The Jacobi’s formula states that if $A$ is a differentiable map from the real numbers to $n \times n$ matrices, then 570 $\begin{array} { r } { \frac { d } { d t } \operatorname* { d e t } A ( t ) = t r ( a d j ( A ( t ) ) \frac { d A ( t ) } { d t } ) } \end{array}$ , where adj is the adjugate. Thus, have
|
| 774 |
+
|
| 775 |
+
$$
|
| 776 |
+
\begin{array} { l } { \displaystyle \frac { \partial \log p ( u ( t ) ) } { \partial t } = - \operatorname* { l i m } _ { \epsilon \to 0 ^ { + } } \mathrm { t r } \left[ \mathrm { a d j } \left( \frac { \partial } { \partial u } T _ { \epsilon } ( u ( s ) ) \right) \frac { \partial } { \partial \epsilon } \frac { \partial } { \partial u } T _ { \epsilon } ( u ( s ) ) \right] } \\ { \displaystyle \ = - \mathrm { t r } \left[ \left( \operatorname* { l i m } _ { \epsilon \to 0 ^ { + } } \mathrm { a d j } \left( \frac { \partial } { \partial u } T _ { \epsilon } ( u ( t ) ) \right) \right) \left( \operatorname* { l i m } _ { \epsilon \to 0 ^ { + } } \frac { \partial } { \partial \epsilon } \frac { \partial } { \partial u } T _ { \epsilon } ( u ( s ) ) \right) \right] } \\ { \displaystyle \ = - \mathrm { t r } \left[ \mathrm { a d j } \left( \frac { \partial } { \partial u } u ( t ) \right) \operatorname* { l i m } _ { \epsilon \to 0 ^ { + } } \frac { \partial } { \partial \epsilon } \frac { \partial } { \partial u } T _ { \epsilon } ( u ( s ) ) \right] } \\ { \displaystyle \ = - \mathrm { t r } \left[ \operatorname* { l i m } _ { \epsilon \to 0 ^ { + } } \frac { \partial } { \partial \epsilon } \frac { \partial } { \partial u } T _ { \epsilon } ( u ( s ) ) \right] } \end{array}
|
| 777 |
+
$$
|
| 778 |
+
|
| 779 |
+
571 Substituting $T _ { \epsilon }$ with its Taylor series expansion and taking the limit, we have
|
| 780 |
+
|
| 781 |
+
$$
|
| 782 |
+
\begin{array} { r l } { \frac { \partial \log p ( u ( t ) ) } { \partial A } = - \operatorname { t r } \bigg ( \displaystyle \operatorname* { l i m } _ { t \to 0 } \frac { \partial } { \partial \epsilon } \frac { \partial } { \partial u } ( u + \epsilon \frac { d u } { d s } + \mathcal { O } ( \epsilon ^ { 2 } ) + \mathcal { O } ( \epsilon ^ { 3 } ) + . . . \bigg ) ) } & { } \\ & { = - \operatorname { t r } \bigg ( \displaystyle \operatorname* { l i m } _ { t \to 0 ^ { * } } \frac { \partial } { \partial \epsilon } \frac { \partial } { \partial u } ( u + \epsilon \sum _ { i = 1 } ^ { k } \frac { \partial u } { \partial x _ { i } } \frac { d x _ { i } } { d s } + \mathcal { O } ( \epsilon ^ { 2 } ) + \mathcal { O } ( \epsilon ^ { 3 } ) + . . . \bigg ) \bigg ) } \\ & { = - \operatorname { t r } \bigg ( \displaystyle \operatorname* { l i m } _ { t \to 0 ^ { * } } \frac { \partial } { \partial \epsilon } ( I + \frac { \partial } { \partial u } \epsilon \frac { k } { \partial \epsilon } \frac { \partial u } { \partial x _ { i } } \frac { d x _ { i } } { d s } + \mathcal { O } ( \epsilon ^ { 2 } ) + \mathcal { O } ( \epsilon ^ { 3 } ) + . . . \bigg ) ) } \\ & { = - \operatorname { t r } \bigg ( \displaystyle \operatorname* { l i m } _ { t \to 0 ^ { * } } \bigg ( \frac { \partial } { \partial u } \sum _ { i = 1 } ^ { k } \frac { \partial u } { \partial x _ { i } } \frac { d x _ { i } } { d s } + \mathcal { O } ( \epsilon ) + \mathcal { O } ( \epsilon ^ { 3 } ) + . . . \bigg ) \bigg ) } \\ & { = - \operatorname { t r } \bigg ( \frac { \partial } { \partial u } \sum _ { i = 1 } ^ { k } \frac { \partial u } { \partial x _ { i } } \frac { d x _ { i } } { d s } + \mathcal { O } ( \epsilon ) + \mathcal { O } ( \epsilon ^ { 2 } ) + . . . \bigg ) } \end{array}
|
| 783 |
+
$$
|
| 784 |
+
|
| 785 |
+
572
|
| 786 |
+
|
| 787 |
+
# B.4 Proof of Proposition 4.3
|
| 788 |
+
|
| 789 |
+
Proof. To prove proposition 4.3, need to show that for any homeomorphism $h ( \cdot )$ , there exists a $u ( s , u _ { 0 } ) \in \mathbb { R } ^ { n }$ following a C-NODE system such that $u ( s = T , u _ { 0 } ) = h ( \bar { u } _ { 0 } )$ .
|
| 790 |
+
|
| 791 |
+
76 Without loss of generality, say $T = 1$
|
| 792 |
+
|
| 793 |
+
577 Define C-NODE system
|
| 794 |
+
|
| 795 |
+
$$
|
| 796 |
+
\left\{ \begin{array} { l l } { \frac { d u } { d s } = \frac { \partial u } { \partial x } \frac { d x } { d s } + \frac { \partial u } { \partial t } \frac { d t } { d s } , } \\ { \frac { d x } { d s } ( s , u _ { 0 } ) = 1 , } \\ { \frac { \partial u } { \partial x } ( u ( x , t ) ) = h ( u _ { 0 } ) , } \\ { \frac { d t } { d s } ( s , u _ { 0 } ) = u _ { 0 } , } \\ { \frac { \partial u } { \partial t } ( u ( x , t ) ) = - 1 . } \end{array} \right.
|
| 797 |
+
$$
|
| 798 |
+
|
| 799 |
+
$\begin{array} { r } { \frac { d u } { d s } = h ( u _ { 0 } ) - u _ { 0 } } \end{array}$ . At $s = 1$
|
| 800 |
+
|
| 801 |
+
$$
|
| 802 |
+
{ \begin{array} { l } { \displaystyle u ( s = 1 , u _ { 0 } ) = u ( s = 0 , u _ { 0 } ) + \int _ { 0 } ^ { 1 } { \frac { d u } { d s } } d s } \\ { \displaystyle \qquad = u _ { 0 } + \int _ { 0 } ^ { 1 } { \frac { \partial u } { \partial x } } { \frac { d x } { d s } } + { \frac { \partial u } { \partial t } } { \frac { d t } { d s } } d s } \\ { \displaystyle \qquad = u _ { 0 } + \int _ { 0 } ^ { 1 } { h ( u _ { 0 } ) \cdot 1 + ( - 1 ) \cdot u _ { 0 } d s } } \\ { \displaystyle = u _ { 0 } + h ( u _ { 0 } ) - u _ { 0 } } \\ { \displaystyle = h ( u _ { 0 } ) . } \end{array} }
|
| 803 |
+
$$
|
| 804 |
+
|
| 805 |
+
579 The inverse map will be defined by integration backwards. Specifically, have
|
| 806 |
+
|
| 807 |
+
$$
|
| 808 |
+
\begin{array} { l } { { \displaystyle { u ( s = 0 , u _ { 0 } ) = u ( s = 1 , u _ { 0 } ) + \int _ { 1 } ^ { 0 } \frac { d u } { d s } d s } } } \\ { { \displaystyle { \quad = h ( u _ { 0 } ) - \int _ { 0 } ^ { 1 } \frac { \partial u } { \partial x } \frac { d x } { d s } + \frac { \partial u } { \partial t } \frac { d t } { d s } d s } } } \\ { { \displaystyle { \quad = h ( u _ { 0 } ) - \int _ { 0 } ^ { 1 } h ( u _ { 0 } ) \cdot 1 + ( - 1 ) \cdot u _ { 0 } d s } } } \\ { { \displaystyle { \quad = h ( u _ { 0 } ) - h ( u _ { 0 } ) + u _ { 0 } } } } \\ { { \displaystyle { \quad = u _ { 0 } . } } } \end{array}
|
| 809 |
+
$$
|
| 810 |
+
|
| 811 |
+
580 Thus, for any homeomorphism $h ( \cdot )$ , there exists a C-NODE system, such that forward integration for
|
| 812 |
+
581 time $s = 1$ is equivalent as applying $h ( \cdot )$ , and backward integration for time $s = 1$ is equivalent to
|
| 813 |
+
582 applying $h ^ { - 1 } ( \cdot ) $ . □
|
| 814 |
+
|
| 815 |
+
# C Ablation Study
|
| 816 |
+
|
| 817 |
+
# 584 C.1 Ablation study on dimension of C-NODE
|
| 818 |
+
|
| 819 |
+
We perform an ablation study on the impact of the number of dimensions of the C-NODE we implement. This study allows us to evaluate the relationship between the model performance and the model’s limit of mathematical approximating power. Empirical results show that as we increase the number of dimensions used in the C-NODE model, the C-NODE’s performance first improves and then declines, due to overfitting. We have found out that information criteria like AIC and BIC can be successfully applied for dimension selection in this scenario.
|
| 820 |
+
|
| 821 |
+
In previous experiments, we represent $\partial { \bf u } / \partial x _ { i }$ with separate and independent neural networks $\mathbf { c } _ { i } ( \mathbf { u } , \theta )$ . Here, we represent all $k$ functions as a vector-valued function $[ \partial \bar { \bf u } / \partial x _ { 1 } , . . . , \partial { \bf u } / \partial x _ { k } ] ^ { T }$ . We approximate this vector-valued function with a neural network $\mathbf { c } ( \mathbf { u } , \theta )$ . The model is trained using the Euler solver to have better training stability when the neural network has a large number of parameters. Experiment details for the ablation study is as shown in Figures 7, 8, 9.
|
| 822 |
+
|
| 823 |
+
# C.2 Ablation study on number of parameters
|
| 824 |
+
|
| 825 |
+
We show C-NODE’s parameter efficiency over NODE with an ablation study on the image classification task on the CIFAR-10 dataset. Specifically, under a similar training setup, we experiment with C-NODE with 95071, 55855, and 17379 parameters and experiment with NODE with 96044, 56828, and 17444 parameters. As shown in Figure 10, although C-NODE has more variance in its performance, it outperforms NODE along the whole training process in all three cases.
|
| 826 |
+
|
| 827 |
+

|
| 828 |
+
Figure 7: The training process averaged over 4 runs of C-NODE with 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, and 1024 dimensions on the MNIST dataset. The first row is the accuracy of prediction, the second row is the testing error, and the third row is the training error.
|
| 829 |
+
|
| 830 |
+

|
| 831 |
+
Figure 8: The training process averaged over 4 runs of C-NODE with 1, 2, 4, 8, 16, 32, 64, and 128 dimensions on the SVHN dataset. The first row is the accuracy of prediction, the second row is the testing error, and the third row is the training error.
|
| 832 |
+
|
| 833 |
+

|
| 834 |
+
Figure 9: The training process averaged over 4 runs of C-NODE with 1, 2, 4, 8, 16, 32, 64, and 128 dimensions on the CIFAR-10 dataset. The first row is the accuracy of prediction, the second row is the testing error, and the third row is the training error.
|
| 835 |
+
|
| 836 |
+

|
| 837 |
+
Figure 10: The training process averaged over four runs of C-NODE with 95071, 55855, and 17379 parameters on the CIFAR-10 dataset, and NODE with 96044, 55855, and 17379 parameters. The first row is the prediction accuracy, the second row is the testing error, and the third row is the training error. Blue lines are the results for C-NODE, and red lines are the results for NODE.
|
| 838 |
+
|
| 839 |
+
# 603 D Algorithm for continuous normalizing flows defined with C-NODE
|
| 840 |
+
|
| 841 |
+
We additionally provide algorithms for training and sampling CNFs defined with C-NODEs.
|
| 842 |
+
|
| 843 |
+
# Algorithm 2 Algorithm for training CNFs defined with C-NODE
|
| 844 |
+
|
| 845 |
+
given probability density function of $p ( \mathbf { u } ( s = 0 ) ) = p _ { 0 } ( \cdot )$
|
| 846 |
+
for each input data $\mathbf { z } _ { j }$ do Given log p(zj ) − log p(u(1)) u(1) = "zj0 # procedure Integrate from $1 0$ to get " u(0)log p(zj) − log p(u(0))# for each time step calculate $\begin{array} { r } { \frac { d \mathbf { x } } { d s } ( \mathbf { x } , \mathbf { u } ; \mathbf { g } ( \mathbf { z } _ { j } ; \boldsymbol { \Theta } _ { 1 } ) ; \boldsymbol { \Theta } _ { 2 } ) } \end{array}$ $s _ { m }$ do and $\mathbf { J _ { x } } \mathbf { u } ( \mathbf { x } , \mathbf { u } ; \Theta _ { 2 } )$ . calculate $\begin{array} { r } { { \frac { d { \bf u } } { d s } } = { \bf J _ { x } u } { \frac { d { \bf x } } { d s } } } \end{array}$ . calculate $\begin{array} { r } { - \mathbf { t r } \big ( \frac { \partial } { \partial \mathbf { u } } \mathbf { J } _ { \mathbf { x } } \mathbf { u } \frac { d \mathbf { x } } { d s } \big ) } \end{array}$ with Hutchinson trace estimator [13]. calculate $\begin{array} { r } { \left[ \underset { \log p ( \mathbf { u } ( s _ { m + 1 } ) ) } { \mathbf { u } ( s _ { m + 1 } ) } \right] = \left[ \underset { \log p ( \mathbf { u } ( s _ { m } ) ) } { \mathbf { u } ( s _ { m } ) } \right] + \left[ \underset { \partial s } { \frac { d \mathbf { u } } { d t } } \right] ( s _ { m + 1 } - s _ { m } ) . } \end{array}$ end for evaluate $p _ { 0 } ( \mathbf { u } ( 0 ) )$ calculate $\log p ( \mathbf { z } _ { j } ) = ( \log p ( \mathbf { z } _ { j } ) - \log p ( \mathbf { u } ( 0 ) ) ) + \log p _ { 0 } ( \mathbf { u } ( 0 ) )$ optimize $\log p ( \mathbf { z } _ { j } )$ with an optimization algorithm (stochastic gradient descent etc.)
|
| 847 |
+
end for
|
| 848 |
+
|
| 849 |
+
# Algorithm 3 Algorithm for sampling CNFs defined with C-NODE
|
| 850 |
+
|
| 851 |
+
procedure sample $\mathbf { u } ( s = 0 )$ from base distribution $p _ { 0 } ( \cdot )$
|
| 852 |
+
procedure Integrate from $0 1$ to get $\mathbf { u } ( s = 1 )$
|
| 853 |
+
for each time step $s _ { m }$ do calculate $\begin{array} { r } { \frac { d \mathbf { x } } { d s } ( \mathbf { x } , \mathbf { u } ; \mathbf { g } ( \mathbf { z } _ { j } ; \boldsymbol { \Theta } _ { 1 } ) ; \boldsymbol { \Theta } _ { 2 } ) } \end{array}$ and $\mathbf { J _ { x } } \mathbf { u } ( \mathbf { x } , \mathbf { u } ; \Theta _ { 2 } )$ . calculate $\begin{array} { r } { \frac { d \mathbf { u } } { d s } = \mathbf { J } _ { \mathbf { x } } \mathbf { u } \frac { d \mathbf { x } } { d s } } \end{array}$ . calculate $\begin{array} { r } { \overline { { \mathbf { u } } } ( s _ { m + 1 } ) = \mathbf { u } ( s _ { m } ) + \frac { d \mathbf { u } } { d s } ( s _ { m + 1 } - s _ { m } ) } \end{array}$ .
|
| 854 |
+
end for
|
| 855 |
+
end procedure
|
| 856 |
+
$\mathbf { u } ( s = 1 )$ is our sample from the CNF
|
md/dev/GMYWzWztDx5/GMYWzWztDx5.md
ADDED
|
@@ -0,0 +1,312 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# NORMFORMER: IMPROVED TRANSFORMER PRETRAINING WITH EXTRA NORMALIZATION
|
| 2 |
+
|
| 3 |
+
# ABSTRACT
|
| 4 |
+
|
| 5 |
+
During pretraining, the Pre-LayerNorm transformer suffers from a gradient magnitude mismatch: gradients at early layers are much larger than at later layers. These issues can be alleviated by our proposed NormFormer architecture, which adds three normalization operations to each layer: a Layer Norm after self attention, head-wise scaling of self-attention outputs, and a Layer Norm after the first fully connected layer. The extra operations incur negligible compute cost $( + 0 . 4 \%$ parameter increase), but improve pretraining perplexity and downstream task performance for both causal and masked language models ranging from 125 Million to 2.7 Billion parameters. For causal language modeling, adding NormFormer on top of our strongest 1.3B parameter baseline achieves equal performance with $79 \%$ as much compute, and matches GPT-3 Large performance in $62 \%$ of the cost. In the same compute budget, NormFormer comfortably beats both baselines in both pre-training perplexity and zero shot performance. For masked language modeling, NormFormer improves fine-tuned GLUE performance by $1 . 9 \%$ on average. Code to train NormFormer models is available in REDACTED.
|
| 6 |
+
|
| 7 |
+
# 1 INTRODUCTION
|
| 8 |
+
|
| 9 |
+
The original transformer architecture (Vaswani et al., 2017) applies Layer Normalization (Ba et al., 2016) after each sublayer’s residual connection (“Post-LN”) in order to reduce the variance of the inputs to the following sublayer, i.e.:
|
| 10 |
+
|
| 11 |
+
$$
|
| 12 |
+
\mathrm { P o s t L N } ( x ) = \mathrm { L a y e r N o r m } ( x + \mathrm { S u b l a y e r } ( x ) ) ,
|
| 13 |
+
$$
|
| 14 |
+
|
| 15 |
+
with
|
| 16 |
+
|
| 17 |
+
$$
|
| 18 |
+
\mathrm { L a y e r N o r m } ( x ) = \frac { x - E [ x ] } { \sqrt { V a r [ x ] + \epsilon } } \cdot \gamma + \beta ,
|
| 19 |
+
$$
|
| 20 |
+
|
| 21 |
+
where $\gamma$ and $\beta$ are trainable parameters, and $\epsilon$ is a small constant. Recent work has shown empirically and theoretically that Post-LN transformers tend to have larger magnitude gradients in later layers compared to earlier layers (Xiong et al., 2020) and has advocated moving the LayerNorm operation to the beginning of each sublayer (“Pre-LN”; see Figure 1, left), i.e.:
|
| 22 |
+
|
| 23 |
+
$$
|
| 24 |
+
\operatorname { P r e L N } ( x ) = x + \operatorname { S u b l a y e r } ( \operatorname { L a y e r N o r m } ( x ) ) .
|
| 25 |
+
$$
|
| 26 |
+
|
| 27 |
+
In practice Pre-LN transformers can be trained with larger learning rates, shorter learning rate warmup and often yield improved performance compared to Post-LN transformers (Xiong et al., 2020), so most recent, large pretrained language models tend to use Pre-LN transformers (Baevski & Auli, 2019; Radford et al., 2019; Raffel et al., 2020; Brown et al., 2020; Lieber et al., 2021). In this work we show that, while Pre-LN improves stability over Post-LN, it has the opposite side effect: gradients at earlier layers tend to be larger than gradients at later layers, thereby limiting the learning rate.1 We propose NormFormer, which alleviates the gradient magnitude mismatch by adding 3 normalization operations to each layer (see Figure 1, middle). These operations reduce gradients to early layers and increase gradients to later layers, bringing their magnitudes closer together.
|
| 28 |
+
|
| 29 |
+

|
| 30 |
+
Figure 1: Left: a baseline Pre-LayerNorm transformer layer. Center: NormFormer, with the three proposed additions in bold. Right: a single attention head with our proposed HeadScale operation applied prior to the output projection with trainable parameters $\gamma _ { i }$ . \* When applied, residual scaling impacts the second residual connection in each layer.
|
| 31 |
+
|
| 32 |
+
Compared to compute-matched, well-tuned Pre-LN baselines, NormFormer models reach target pretraining perplexities faster and achieve better pretraining perplexities and downstream task performance.
|
| 33 |
+
|
| 34 |
+
The rest of this paper is organized as follows: Section 2 describes the proposed modifications. Section 3 describes related work. Section 5 shows pretraining and downstream task performance for fully trained NormFormer models against well-tuned, compute-matched baselines. Section 6 shows the gradient mismatch introduced by Pre-LN and how NormFormer alleviates it. Section 6.1 analyzes residual scaling, a related technique proposed to stabilize Post-LN architectures (Xiong et al., 2020; Zhu et al., 2021). Section 7 shows that removing any of the added operations degrades performance and that NormFormer improves over the baseline at a wide range of hyperparameter configurations. Section 9.1 compares NormFormer to Related Work from other domains.
|
| 35 |
+
|
| 36 |
+
# 2 APPROACH
|
| 37 |
+
|
| 38 |
+
# 2.1 NORMFORMER
|
| 39 |
+
|
| 40 |
+
NormFormer includes three modifications to the Pre-LN transformer: First, we apply head-wise scaling inside the attention module and add two additional LayerNorm operations: one after the attention module and a second after the first fully connected layer. The modifications introduce a small number of additional learnable parameters, which provide a cost-effective way for each layer to change the magnitude of its features, and therefore the magnitude of the gradients to subsequent components. The changes are visualized in Figure 1 and described below.
|
| 41 |
+
|
| 42 |
+
Scaling Attention Heads The standard multi-head attention operation is defined as:
|
| 43 |
+
|
| 44 |
+
$$
|
| 45 |
+
\begin{array} { r l } & { \mathrm { M u l t i H e a d A t t e n t i o n } ( Q , K , V ) = \mathrm { C o n c a t } ( \mathrm { h } _ { 1 } , \dots , \mathrm { h } _ { n } ) W ^ { O } } \\ & { \mathrm { h } _ { i } = \mathrm { A t t e n t i o n } ( Q W _ { i } ^ { Q } , K W _ { i } ^ { K } , V W _ { i } ^ { V } ) } \\ & { \mathrm { A t t e n t i o n } ( Q , K , V ) = \mathrm { s o f t m a x } \left( \frac { Q K ^ { T } } { \sqrt { d _ { k } } } \right) V , } \end{array}
|
| 46 |
+
$$
|
| 47 |
+
|
| 48 |
+
and where $W ^ { O } , W _ { i } ^ { Q } , W _ { i } ^ { K } , W _ { i } ^ { V }$ $n$ is the number of heads, are learned projection matrices for the output, query, key and value, re- $i$ is the attention head index, $d _ { k }$ is the dimensionality of the keys spectively.
|
| 49 |
+
|
| 50 |
+
We propose scaling the output of each attention head via learned scalar coefficients $\gamma _ { i }$
|
| 51 |
+
|
| 52 |
+
$$
|
| 53 |
+
\mathrm { H e a d S c a l e M H A } ( Q , K , V ) = \mathrm { C o n c a t } ( \gamma _ { 1 } \mathrm { h } _ { 1 } , \dots , \gamma _ { n } \mathrm { h } _ { n } ) W ^ { O }
|
| 54 |
+
$$
|
| 55 |
+
|
| 56 |
+
where $\gamma$ are learnable parameters initialized to 1.
|
| 57 |
+
|
| 58 |
+
Additional Layer Normalization and Putting it All Together In the Pre-LN transformer each layer $l$ modifies an input $x _ { l }$ as follows:
|
| 59 |
+
|
| 60 |
+
$$
|
| 61 |
+
x _ { l + 1 } ^ { \mathtt { P r e L N } } = \mathrm { F F N } ( \mathrm { M H A } ( x _ { l } ) )
|
| 62 |
+
$$
|
| 63 |
+
|
| 64 |
+
$$
|
| 65 |
+
\begin{array} { r l } & { \mathrm { M H A } ( x ) = x + \mathrm { M u l t i H e a d A t t e n t i o n } ( \mathrm { L N } ( x ) , \mathrm { L N } ( x ) , \mathrm { L N } ( x ) ) } \\ & { \mathrm { F F N } ( x ) = x + \sigma ( \mathrm { L N } ( x ) W _ { 1 } + b _ { 1 } ) W _ { 2 } + b _ { 2 } } \\ & { \mathrm { L N } ( x ) = \mathrm { L a y e r N o r m } ( x ) } \end{array}
|
| 66 |
+
$$
|
| 67 |
+
|
| 68 |
+
In this work $\sigma$ is the GELU non-linear activation introduced in Hendrycks & Gimpel (2016).
|
| 69 |
+
|
| 70 |
+
Our overall method, NormFormer, instead modifies each input $x _ { l }$ as:
|
| 71 |
+
|
| 72 |
+
$$
|
| 73 |
+
x _ { l + 1 } ^ { \mathrm { { N o r m F o r m e r } } } = \mathrm { { N o r m F F N } } ( { \mathrm { N o r m S c a l e d M H A } } ( x _ { l } ) )
|
| 74 |
+
$$
|
| 75 |
+
|
| 76 |
+
$$
|
| 77 |
+
\mathrm { N o r m S c a l e d M H A } ( x ) = x + \mathbf { L N } ( \mathbf { H e a d S c a l e M H A } ( \mathrm { L N } ( x ) , \mathrm { L N } ( x ) , \mathrm { L N } ( x ) )
|
| 78 |
+
$$
|
| 79 |
+
|
| 80 |
+
$$
|
| 81 |
+
\mathrm { N o r m F F N } ( x ) = \mathbf { \delta x } + \mathbf { L N } ( \sigma ( \mathrm { L N } ( x ) W _ { 1 } + b _ { 1 } ) ) W _ { 2 } + b _ { 2 }
|
| 82 |
+
$$
|
| 83 |
+
|
| 84 |
+
where bolded operations are newly introduced.
|
| 85 |
+
|
| 86 |
+
# 3 RELATED WORK
|
| 87 |
+
|
| 88 |
+
Architectural Modifications GradInit (Zhu et al., 2021) introduces a set of scalars and biases for initialization based on a variance heuristic, and Admin (Liu et al., 2020) applies a similar heuristic in profiling and initialization stages. These works also use variants of our ResScale operation, which we find helpful at small scale and harmful at large scale. Our approach, in contrast, only has new learnable parameters without variance heuristics, and has no extra stages or changes in initialization.
|
| 89 |
+
|
| 90 |
+
Shazeer (2020) proposes FFN-GeGLU, which includes scaling but no normalization, in the same position as our FFN LN. Ding et al. (2021) propose related stabilization strategies for text to image generation tasks with larger models including a down-scaled embedding gradient, a slightly different LN formulation, LN after the final fully connected layer, and the same post-attention LN. Section 9.1 compares NormFormer to these proposals, as well as the T5 LayerNorm Variant (Raffel et al., 2020), which removes the bias and the mean subtraction from the normalization.
|
| 91 |
+
|
| 92 |
+
Our HeadScale operation is related to that used in Chen et al. (2021), but used differently. Whereas that work prunes attention heads with low $\gamma$ parameters, we use the $\gamma$ parameters to improve pretraining performance.
|
| 93 |
+
|
| 94 |
+
Press et al. (2020a) proposes an architecture where instead of interleaving attention and feed forward sublayers, the attention all happens first. This increases the number of late FFN parameters, rather than increasing their importance and gradient norm, as our FFN LN does, and does not impact stability.
|
| 95 |
+
|
| 96 |
+
Residual Scaling Standard Post-LN transformers simply sum the previous output (residual) with the new output. Recent work attempts to stabilize transformers by weighting the residual connection for each layer (Zhu et al., 2021; Liu et al., 2020; Touvron et al., 2021). We thus experiment with scaling the residual in each embedding dimension via learned scalar coefficients $( \lambda _ { r e s i d } ) _ { i }$ :
|
| 97 |
+
|
| 98 |
+
$$
|
| 99 |
+
{ \mathrm { R e s S c a l e } } ( \mathrm { x } ) = \lambda _ { r e s i d } \circ x + { \mathrm { S u b l a y e r } } ( { \mathrm { L a y e r N o r m } } ( x ) )
|
| 100 |
+
$$
|
| 101 |
+
|
| 102 |
+
where $\circ$ is elementwise multiplication, and $\lambda _ { r e s i d }$ are learned parameters initialized to
|
| 103 |
+
|
| 104 |
+
While this can be applied at any normalization layer, we find it it most effective for normalizing the feedforward network (FFN) submodule for the smaller sized language models. In this setting,
|
| 105 |
+
|
| 106 |
+
$$
|
| 107 |
+
\begin{array} { r } { \mathrm { N o r m F F N } ( x ) = \lambda _ { r e s i d } \circ x + \mathbf { L N } ( \sigma ( \mathrm { L N } ( x ) W _ { 1 } + b _ { 1 } ) ) W _ { 2 } + b _ { 2 } } \end{array}
|
| 108 |
+
$$
|
| 109 |
+
|
| 110 |
+
<table><tr><td>Model Size</td><td>GPT-3 Paper</td><td>Baseline</td><td>NormFormer</td></tr><tr><td>125M</td><td>6e-4</td><td>3e-3</td><td>3e-3</td></tr><tr><td>355M</td><td>3e-4</td><td>1e-3</td><td>1e-3</td></tr><tr><td>1.3B</td><td>2e-4</td><td>6e-4</td><td>6e-4</td></tr></table>
|
| 111 |
+
|
| 112 |
+
Table 1: Searching for learning rates on our dataset results in higher values than reported in Brown et al. (2020), providing stronger baselines to compare to our NormFormer architecture.
|
| 113 |
+
|
| 114 |
+
For 1.3B parameter models and larger, scaling residuals hurts performance (see discussion in Section 6.1), so ResScale is not used in our 1.3B and 2.7B CLM results. Additionally, we experiment with initializing $\lambda _ { r e s i d } = 1 e - 5$ , following (Touvron et al., 2021), as well replacing addition in residual connections with concatenation (Davis et al., 2021) in Section 9.1.
|
| 115 |
+
|
| 116 |
+
# 4 EXPERIMENTS
|
| 117 |
+
|
| 118 |
+
Causal Language Models We pretrain causal LMs (CLM) that roughly match the “Small” (125M parameter), “Medium” (355M), “Large” (1.3B) and “XL” (2.7B) sizes from Brown et al. (2020).
|
| 119 |
+
|
| 120 |
+
Our model architecture differs from Brown et al. (2020) in two ways: (1) we use only dense attention, while they alternate between dense and locally banded sparse attention; (2) we train our models with sinusoidal positional embeddings, following Shortformer (Press et al., 2020b), since early experiments found this to produce comparable results with fewer learned parameters.
|
| 121 |
+
|
| 122 |
+
We train the baseline models for 300 billion tokens. We train NormFormer models for an equivalent number of GPU hours, which typically results in $2 \%$ fewer steps and tokens due to the additional overhead of the normalization operations.
|
| 123 |
+
|
| 124 |
+
On our dataset, we find that the learning rates proposed in GPT-3 are suboptimally low.2 For both baseline and NormFormer at each size besides 2.7B, we tune the learning rate by training models for 50,000 steps and selecting the best performing learning rate among: $\{ 1 \mathrm { e } { - } 4 , 6 \mathrm { e } { - } 4 , 3 \mathrm { e } { - } 4 , 6 \mathrm { e } { - } 4 , 1 \mathrm { e } { - } 3 , 3 \mathrm { e } { - } 3 \}$ . The learning rates we obtained from this process, shown in Table 1, are 3-5 times larger than those used in the GPT-3 paper. Additionally, we have verified that the baseline and NormFormer both perform worse at the full training budget with the GPT-3 learning rates than with the higher learning rates. Other hyperparameters do not differ from GPT-3.3
|
| 125 |
+
|
| 126 |
+
Large scale experiments We also train three large-scale models with 2.7B parameters. Our first baseline is a replicated version of GPT-3-2.7B with GELU activations, the published learning rate (1.6e-4) and the same number of training steps and tokens (286K steps; 300B tokens). This model slightly exceeds the reference zero shot performance (Brown et al., 2020). Next, we train two variants of GPT3-2.7B with $R e l u ^ { 2 }$ activations (So et al., 2021), but use slightly fewer training steps $20 \%$ less) for compute efficiency. The first of these uses the baseline learning rate (1.6e-4) and the second uses NormFormer-2.7B with a higher learning rate of 6e-4. We note that training baseline 2.7B CLMs (i.e., without NormFormer modifications) with a higher 6e-4 learning rate diverged and failed to train. However, as opposed to the smaller architectures, we did not exhaustively tune the learning rate, so it is possible that an intermediate value would perform better.
|
| 127 |
+
|
| 128 |
+
Zero Shot Evaluation In addition to validation perplexity, we evaluate CLMs on a subset of the tasks that GPT3 evaluated on in a zero-shot setting (Brown et al., 2020), with the same prompts. We select WinoGrande (Sakaguchi et al., 2020), StoryCloze (Mostafazadeh et al., 2016), OpenBookQA (Mihaylov et al., 2018), HellaSwag (Zellers et al., 2019) and PIQA (Bisk et al., 2020) because GPT3 showed strong performance on these tasks at small scale, as well as consistently improving performance with scale.
|
| 129 |
+
|
| 130 |
+

|
| 131 |
+
Figure 2: Pretraining perplexity on held-out validation data for Causal and Masked Language Models as a function of training compute (GPU days). The blue stars show the point where a model matches the baseline’s lowest perplexity.
|
| 132 |
+
|
| 133 |
+
Masked Language Models (MLM) We adopt the RoBERTa-base, Pre-LN architecture and hyperparameters used in Liu et al. (2019). For the baseline, we pretrain for 2 million batches of 1 million tokens, about $\textstyle { \frac { 1 } { 4 } }$ of the training budget of the original roberta-base. NormFormer runs through 1.92 million batches in the same amount of time.
|
| 134 |
+
|
| 135 |
+
Fine-Tuning We fine-tune both the baseline MLM and NormFormer with learning rates $\mathrm { 1 e { - } 5 , \mathrm { 1 e { - } 4 , \mathrm { 3 e { - } 4 , \mathrm { 1 e { - } 3 , \mathrm { 3 e { - } 3 , \mathrm { 6 e { - } 3 } } } } } }$ and report the best performance on the validation set for each GLUE task (Wang et al., 2019), following Liu et al. (2019). Other fine-tuning hyperparameters match those used for roberta-base in Liu et al. (2019).
|
| 136 |
+
|
| 137 |
+
Pretraining data We pretrain all models on a collection of English language text including the English portion of the CC100 corpus (Conneau et al., 2020) as well as the data from Liu et al. (2019), consisting of BookCorpus (Zhu et al., 2019), English Wikipedia and filtered subsets of Common Crawl. We encode our data with the byte-level Byte Pair Encoding (BPE) vocabulary from Liu et al. (2019), originally introduced in Radford et al. (2019). The combined dataset contains around 450GB of uncompressed text and 110B BPE tokens. We hold out 40M BPE tokens from this data as a validation set on which we report pretraining perplexities.
|
| 138 |
+
|
| 139 |
+
Implementation details We train our causal and masked language models in fairseq (Ott et al., 2019; Paszke et al., 2019). Although NormFormer introduces fewer than $0 . 0 7 \%$ additional parameters, it slows individual training updates and increases memory usage between $2 \%$ (2.7B model) to $6 \%$ (125M model) due to the FFN LNs. Accordingly, we compare NormFormer to baseline models trained for an equal amount of GPU time, i.e., controlling for compute rather than the number of training updates. Finally, we note that the HeadScale operation can be moved outside the self attention module to allow the use of the very efficient pytorch F.multihead attention. This change reduces overhead without noticeable performance degradation.
|
| 140 |
+
|
| 141 |
+
# 5 RESULTS
|
| 142 |
+
|
| 143 |
+
We report pretraining perplexities for CLMs and MLMs as a function of training wall-time (GPU days) in Figure 2. We observe that NormFormer trains significantly faster and achieves better validation perplexities for a given training compute budget. The blue stars mark the first validation step where NormFormer matches the baseline’s lowest perplexity and shows that NormFormer matches Pre-LN models while needing only $60 \%$ and $57 \%$ as much compute for CLM and MLM models, respectively. This is particularly impressive since NormFormer models take $2 \%$ longer for each training step and thus see less data than Pre-LN models in this comparison. The left side blue line in Figure 2 shows the failed attempt to add ResScale to NormFormer $^ { - 1 }$ .3B.
|
| 144 |
+
|
| 145 |
+
Table 2: Zero-Shot Accuracy for Causal LMs for the following tasks: HS: HellaSwag, PI: PIQA, WG: WinoGrande, SC: StoryCloze, OB: OpenBookQA. PPL is validation perplexity during pretraining. GPT-3 (paper) results taken from Brown et al. (2020). Horizontal lines group compute-matched runs. High LR corresponds to using a larger learning rate than reported in Brown et al. (2020). $\lambda _ { r e s i d }$ indicates whether residual scaling was used. $\lambda _ { r e s i d }$ did not help at 1.3B scale, as shown in 2, but that run is not compute matched so it is not included here. Model size $( | \theta | )$ is reported in millions of parameters.
|
| 146 |
+
|
| 147 |
+
<table><tr><td></td><td></td><td>LR</td><td>Relu²</td><td>Xresid</td><td>Steps</td><td>PPL</td><td>HS</td><td>PI</td><td>WG</td><td>SC</td><td>OB</td><td>Avg</td></tr><tr><td>Random Baseline</td><td>-</td><td>-</td><td>-</td><td>=</td><td>-</td><td>-</td><td>25.0</td><td>50.0</td><td>50.0</td><td>50.0</td><td>25.0</td><td>40.0</td></tr><tr><td>GPT3-125M (paper)</td><td>124.4</td><td>6e-4</td><td></td><td></td><td>572K</td><td>-</td><td>33.7</td><td>64.6</td><td>52.0</td><td>63.3</td><td>35.6</td><td>49.8</td></tr><tr><td>GPT3-125M (replicated)</td><td>124.4</td><td>6e-4</td><td></td><td></td><td>572K</td><td>21.11</td><td>33.7</td><td>66.5</td><td>52.2</td><td>66.1</td><td>35.4</td><td>50.8</td></tr><tr><td>GPT3-125M (High LR)</td><td>124.4</td><td>3e-3</td><td></td><td></td><td>572K</td><td>21.09</td><td>35.3</td><td>67.5</td><td>50.5</td><td>66.3</td><td>35.0</td><td>50.9</td></tr><tr><td>NormFormer-125M</td><td>124.5</td><td>3e-3</td><td></td><td>=</td><td>540K</td><td>20.34</td><td>34.9</td><td>67.1</td><td>52.3</td><td>66.3</td><td>38.0</td><td>51.7</td></tr><tr><td>NormFormer-125M</td><td>124.5</td><td>3e-3</td><td></td><td></td><td>539K</td><td>20.11</td><td>34.9</td><td>65.9</td><td>53.4</td><td>67.5</td><td>40.0</td><td>52.3</td></tr><tr><td>GPT3-355M (paper)</td><td>354.7</td><td>3e-4</td><td>=</td><td></td><td>572K</td><td>-</td><td>43.6</td><td>70.2</td><td>52.1</td><td>68.5</td><td>43.2</td><td>55.5</td></tr><tr><td>GPT3-355M (replicated)</td><td>354.7</td><td>3e-4</td><td>=</td><td></td><td>572K</td><td>15.41</td><td>46.1</td><td>70.8</td><td>54.6</td><td>71.1</td><td>41.2</td><td>56.8</td></tr><tr><td>GPT3-355M (High LR)</td><td>354.7</td><td>1e-3</td><td></td><td></td><td>572K</td><td>14.85</td><td>48.4</td><td>71.7</td><td>53.8</td><td>73.3</td><td>43.4</td><td>58.1</td></tr><tr><td>NormFormer-355M</td><td>355.0</td><td>1e-3</td><td></td><td></td><td>552K</td><td>14.54</td><td>49.7</td><td>71.8</td><td>56.0</td><td>73.8</td><td>43.6</td><td>59.0</td></tr><tr><td>NormFormer-355M</td><td>355.0</td><td>1e-3</td><td></td><td></td><td>550K</td><td>14.52</td><td>49.7</td><td>72.0</td><td>56.7</td><td>73.2</td><td>43.8</td><td>59.1</td></tr><tr><td>GPT3-1.3B (paper)</td><td>1313.5</td><td>2e-4</td><td></td><td></td><td>286K</td><td>-</td><td>54.7</td><td>75.1</td><td>58.0</td><td>73.4</td><td>46.8</td><td>61.6</td></tr><tr><td>GPT3-1.3B (replicated)</td><td>1313.5</td><td>2e-4</td><td></td><td></td><td>286K</td><td>12.56</td><td>58.5</td><td>74.6</td><td>58.1</td><td>76.8</td><td>49.4</td><td>63.5</td></tr><tr><td>GPT3-1.3B (High LR)</td><td>1313.5</td><td>6e-4</td><td></td><td></td><td>286K</td><td>12.21</td><td>57.5</td><td>74.3</td><td>59.3</td><td>76.3</td><td>50.8</td><td>63.6</td></tr><tr><td>NormFormer-1.3B</td><td>1314.0</td><td>6e-4</td><td></td><td></td><td>275K</td><td>11.94</td><td>60.5</td><td>74.5</td><td>60.1</td><td>77.5</td><td>50.8</td><td>64.7</td></tr><tr><td>GPT3-2.7B (paper)</td><td>2648.7</td><td>1.6e-4</td><td></td><td></td><td>286K</td><td>=</td><td>62.8</td><td>75.6</td><td>62.3</td><td>77.2</td><td>53.0</td><td>66.2</td></tr><tr><td>GPT3-2.7B (replicated)</td><td>2648.7</td><td>1.6e-4</td><td></td><td></td><td>286K</td><td>10.92</td><td>65.9</td><td>76.6</td><td>61.4</td><td>78.2</td><td>49.6</td><td>66.3</td></tr><tr><td>NormFormer-2.7B</td><td>2649.5</td><td>6e-4</td><td></td><td></td><td>277K</td><td>10.55</td><td>68.1</td><td>78.1</td><td>64.4</td><td>79.4</td><td>53.4</td><td>68.7</td></tr><tr><td>GPT3-2.7B-Relu</td><td>2648.7</td><td>1.6e-4</td><td></td><td></td><td>230K</td><td>10.99</td><td>65.9</td><td>76.1</td><td>63.2</td><td>79.3</td><td>49.4</td><td>66.8</td></tr><tr><td>GPT3-2.7B-Relu</td><td>2648.7</td><td>6e-4</td><td></td><td></td><td>28K</td><td></td><td></td><td></td><td>diverged</td><td></td><td></td><td></td></tr><tr><td>NormFormer-2.7B</td><td>2649.5</td><td>6e-4</td><td></td><td></td><td>222K</td><td>10.73</td><td>67.4</td><td>77.2</td><td>64.4</td><td>78.9</td><td>52.6</td><td>68.1</td></tr></table>
|
| 148 |
+
|
| 149 |
+
<table><tr><td></td><td>Model Size</td><td>Xresid</td><td>PPL</td><td>CoLA</td><td>MNLI</td><td>MRPC</td><td>QNLI</td><td>QQP</td><td>RTE</td><td>SST-2</td><td>Avg</td></tr><tr><td>Baseline</td><td>125.42</td><td></td><td>3.42</td><td>74.3</td><td>85.9</td><td>84.6</td><td>91.6</td><td>90.7</td><td>66.4</td><td>92.9</td><td>83.77</td></tr><tr><td>NormFormer</td><td>125.50</td><td></td><td>3.31</td><td>82.6</td><td>86.3</td><td>86.0</td><td>91.9</td><td>91.3</td><td>67.9</td><td>93.8</td><td>85.69</td></tr><tr><td>NormFormer</td><td>125.51</td><td><</td><td>3.29</td><td>80.9</td><td>86.2</td><td>85.3</td><td>91.5</td><td>91.2</td><td>62.8</td><td>94.2</td><td>84.59</td></tr></table>
|
| 150 |
+
|
| 151 |
+
Table 3: Masked LM: Pretraining validation perplexity (PPL) and fine-tuned performance on GLUE tasks for Pre-LN and NormFormer models. Note that models are trained for an equal amount of compute, which is less than the publicly-released roberta-base models.
|
| 152 |
+
|
| 153 |
+
We observe a similar trend on downstream tasks. In Table 2 we report zero shot accuracy for causal LMs using the tasks and prompts from Brown et al. (2020). NormFormer outperforms GPT-3 at all sizes. The gains from Normformer extra parameters operations outpace the gains from normal scaling laws. Changing the hidden dimension of a 125M parameter model from 768 to 780, for example, results in a 127 million parameter model that is only 0.08 perplexity better than the baseline whereas NormFormer-125M adds only 100,000 parameters and is 0.83 perplexity better than the baseline.
|
| 154 |
+
|
| 155 |
+
For MLM models, we report fine-tuned accuracy on GLUE in Table 3. We again find that NormFormer MLM models outperform their Pre-LN counterparts on every task (rows 1 vs 2). Adding ResScale improves improves pre-training performance marginally (3.29 valid PPL vs 3.31), but the gains to do not translate to finetuned performance.
|
| 156 |
+
|
| 157 |
+
# 6 ANALYSIS
|
| 158 |
+
|
| 159 |
+
Analysis of gradient norms by layer We begin by examining the magnitude of the gradients at different layers for Post-LN, Pre-LN and NormFormer models, since large magnitude differences in gradients across layers can destabilize training, particularly when training in mixed precision (Micikevicius et al., 2018). Figure 3 shows the average L1 norm of the gradients to the second fully connected weight in various layers for a 12 layer, 125M parameter CLM model at the beginning of training. As reported in past work (Xiong et al., 2020), we observe that the gradients to later layers in Post-LN models are much larger than for earlier layers, and that the gradients to early layers quickly vanish in the early stages of training. Pre-LN models have the opposite behavior, with early layers instead receiving significantly larger gradients than later layers. NormFormer brings the average gradient norms closer together for different layers in the network.
|
| 160 |
+
|
| 161 |
+

|
| 162 |
+
Figure 3: Average L1 norm of gradients to the second fully connected weight for layers 0,1,6,10 and 11, early in training.
|
| 163 |
+
|
| 164 |
+

|
| 165 |
+
Figure 4: Distribution of learned scaling parameters in three of the added operations. For FFN LN, earlier layers receive downscaled inputs, keeping their gradients in the same range as the gradients of later layers. This plot is discussed in detail in Section 6.
|
| 166 |
+
|
| 167 |
+
In Figure 4 we present the distribution of scaling parameters learned by NormFormer models. For the FFN LN, the $\gamma$ parameters are smaller for earlier layers, reducing the magnitude of the inputs to early fully connected parameters, thereby decreasing the magnitude of their gradients. The post attention LN, in the middle of Figure 4, all layers have $\gamma$ coefficients below 1, indicating downscaling.4 The HeadScale $\gamma$ parameters, shown in the rightmost plot in Figure 4 vary more than the others, and have no relationship with depth in the network. We interpret this as evidence that the HeadScale parameters dynamically increase the importance of well initialized attention heads, as suggested in Chen et al. (2021).
|
| 168 |
+
|
| 169 |
+
Reducing gradient mismatch allows training stably with larger learning rates. To measure the stability of an architecture, we train it on a learning rate schedule with a very large peak learning rate, so that the learning rate increases a little each step until the loss explodes. Figure 5 shows that NormFormer models can survive for more updates in this environment than the baseline. For the baseline 125M model (the left most blue dot), the loss eventually explodes, with the activations from multiplying the query and key features at layer 0 overflowing the FP16 range. The down scaling of the attention outputs allows NormFormer to avoid this issue and remain stable with larger learning rates. Figure 5 also shows that $\lambda _ { r e s i d }$ reduces the stability improvement at all sizes.
|
| 170 |
+
|
| 171 |
+

|
| 172 |
+
Figure 5: LR Stability Test: learning rate starts from 0 and linearly increases by $5 \in - 5$ at each training step until training destabilizes. NormFormer reaches a higher learning rate before destabilizing. Each data point is the median of 3 runs with a different random seed.
|
| 173 |
+
|
| 174 |
+
# 6.1 RESIDUAL SCALING
|
| 175 |
+
|
| 176 |
+
By comparing adjacent NormFormer-125M and NormFormer-355M rows in Table 2 we can see that adding ResScale to NormFormer improves perplexity and zero shot performance for small scale CLMs. For 125M parameter MLM, ResScale improves pre-training perplexity marginally, but hurts fine-tuned performance. At 1.3 billion parameter scale, however, adding ResScale to NormFormer does not improve performance (Figure 2). Although it’s not included in our tables, we find that ResScale without NormFormer is stronger than the baseline at small scale, but not large scale. This suggests that the negative result is caused by scale, rather than interaction with NormFormer.
|
| 177 |
+
|
| 178 |
+
Figure 6 in the appendix shows the average $\lambda _ { r e s i d }$ weights at each layer of different sized CLMs. We can see that at 125M and 355M parameters, the weights in the later layers are lower, indicating down weighting of the residual connection, whereas at the largest scale, 1.3B, the weights are larger deeper into the network. Adding the $\lambda _ { r e s i d }$ parameters to the other (earlier) residual connection in each layer, or using a scalar instead of a vector for each $\lambda _ { r e s i d }$ , does not fix the large scale issue, but hurts small scale performance marginally. Additionally, Table 8 shows that initializing the network to place no weight on the layer outputs, and all the weight on residual connections, as proposed in (Touvron et al., 2021), does not improve performance.
|
| 179 |
+
|
| 180 |
+
# 7 ABLATIONS
|
| 181 |
+
|
| 182 |
+
This section provides evidence that removing any of our additions to the transformer block degrades performance on language modeling tasks, and that our additions improve language modeling performance across a wide range of hyperparameter settings. Experiments use 125M parameter CLMs, and are run with the default hyperparameters given in Table 7 in the appendix for 470 V100 Hours (100,000 updates for the baseline) unless otherwise mentioned.
|
| 183 |
+
|
| 184 |
+
Removing any of the added operations hurts performance Table 4 shows that none of the four introduced operations can be removed without degrading performance. Rows 2-5 remove each operation one at a time. In all cases perplexity increases, with the removal of HeadScale being the most damaging and the removal of the Post-Attn LN being the least damaging. In Row 6 $\left( + \ 3 \right.$ More LN) we try to introduce more normalization inside self attention, applying LN to the query, key and value features in addition to our 3 other operations, for a total of 6 new operations. In this setting, every other parameterized operation inside the transformer layer is an LN. We find that this does not change perplexities at a fixed number of updates, but reduces training speed by another $5 \%$ . This result suggests that there is not much upside to adding even more normalization on top of NormFormer.
|
| 185 |
+
|
| 186 |
+
Table 4: 125M parameter Language Modeling Validation perplexities after 470 V100 Hours of pretraining. Removing any of our proposed additions degrades performance (Rows 2-5). Adding more normalization inside the Multi Headed Attention (Row 6) does not impact perplexity at a fixed number of updates, but reduces throughput such that the model can only complete 87,500 updates vs. 92,500 for Rows 1-5 and 100,000 for Row 7. Note that these PPL scores are not directly comparable to other tables – they use a different validation set.
|
| 187 |
+
|
| 188 |
+
<table><tr><td colspan="2">Architecture Valid PPL</td></tr><tr><td>NormFormer+ResScale</td><td>15.88</td></tr><tr><td>- Post-Attn LN</td><td>15.92</td></tr><tr><td> - FFN LN</td><td>16.14</td></tr><tr><td> - Head Scale</td><td>16.22</td></tr><tr><td> - Res Scale</td><td>16.20</td></tr><tr><td>+ 3 More LN</td><td>15.88</td></tr><tr><td>Baseline</td><td>16.37</td></tr></table>
|
| 189 |
+
|
| 190 |
+
Other Experiments Table 8 in the appendix compares NormFormer CLMs to related architectural modifications, both in terms of the stability and pre-training perplexity at 1.3B parameter scale. Table 5 in the appendix shows language modeling perplexities for 7 different hyperparameter configurations at 125M parameter scale, separated by horizontal lines. NormFormer outperforms the baselines in all settings.
|
| 191 |
+
|
| 192 |
+
# 8 CONCLUSION
|
| 193 |
+
|
| 194 |
+
We identify a mismatch in the gradients of Pre-LN transformer weights: earlier layers receive much larger gradients than later layers, while the optimal scaling of residuals is larger at earlier layers than at later layers. We propose NormFormer, which alleviates these issues by adding 3 extra operations to each transformer layer. These modifications help the gradient mismatch for fully connected parameters and improve validation perplexity and downstream task performance for both causal and masked language models. None can be removed without degrading performance back towards the baseline, and adding more normalization – at least of the types we have tried – does not improve performance. Since NormFormer primarily addresses the gradient mismatch by increasing the gradients to the last FFN layers while decreasing the gradient magnitudes in other parts of the network, future work could examine whether all 3 operations need to be added to every layer. Additionally, the small computational overhead associated with NormFormer could be alleviated by fusing the FFN LN with the preceding fully connected layer, with or without the mean centering and bias, which do not appear to improve pretraining perplexity. In general, we have shown that adding small numbers of learnable parameters in the right places in our architectures can alleviate certain issues in current state of the art networks. Future work should ascertain if there are additional similarly efficient modifications that can bring gains, while helping us understand current deficiencies further.
|
| 195 |
+
|
| 196 |
+
# 9 APPENDIX
|
| 197 |
+
|
| 198 |
+

|
| 199 |
+
Figure 6: Average $\lambda _ { r e s i d }$ weights at each layer of different sized CLMs in the NormFormer+λresid setting. Depth is layer number / total layers.
|
| 200 |
+
|
| 201 |
+
Table 5: Longer Warmup: increase LR Warmup to 6,000 steps (from 500). GPT3: increase sequence length to 2048, increase dropout to 0.1, increase training budget to $1 { , } 0 0 0 \mathrm { V } 1 0 0$ hours. Grad Clip: clip gradient norms at 0.1. NormFormer outperforms the baseline in all settings.
|
| 202 |
+
|
| 203 |
+
<table><tr><td></td><td>Learning Rate</td><td> Setting Changes</td><td>Valid PPL</td></tr><tr><td rowspan="2">Baseline NormFormer</td><td>0.001</td><td></td><td>16.80</td></tr><tr><td>0.001</td><td>■</td><td>16.33</td></tr><tr><td rowspan="2">Baseline NormFormer</td><td>0.003</td><td></td><td>16.37</td></tr><tr><td>0.003</td><td></td><td>15.88</td></tr><tr><td rowspan="2">Baseline NormFormer</td><td>0.006</td><td></td><td>16.58</td></tr><tr><td>0.006</td><td>-</td><td>16.22</td></tr><tr><td rowspan="2">Baseline NormFormer</td><td>0.003</td><td>Longer Warmup</td><td>16.50</td></tr><tr><td>0.003</td><td>Longer Warmup</td><td>16.06</td></tr><tr><td rowspan="2">Baseline NormFormer</td><td>0.003</td><td>GPT3</td><td>16.29</td></tr><tr><td>0.003</td><td>GPT3</td><td>15.88</td></tr><tr><td rowspan="2">Baseline NormFormer</td><td>0.003</td><td>Clip Grad Norms at 0.1</td><td>16.46</td></tr><tr><td>0.003</td><td>Clip Grad Norms at 0.1</td><td>16.14</td></tr></table>
|
| 204 |
+
|
| 205 |
+
Wikitext103 Table 6 shows that NormFormer can also provide gains on top of a well tuned language model in settings with much less data. We simply add our three operations to the architecture and hyperparameters of Baevski & Auli (2019). Convergence perplexity improves, and we reach the baseline perplexity in $70 \%$ as many steps. In this setting, NormFormer does not improve in the last $30 \%$ of training, which suggests that with more tuning the perplexity gap could be widened.
|
| 206 |
+
|
| 207 |
+
# 9.1 COMPARISON TO RELATED WORK
|
| 208 |
+
|
| 209 |
+
Understanding Table 8 The two right most columns of Table 8 contains describes the result of two experiments from the same 1.3B parameter architecture: Stability indicates how many steps the experiment survived in the ”LR Stability Test”, where we increase LR from 0 to 0.1 linearly over 1,000 steps and Perf, where available, describes the validation perplexity of the model trained for $6 4 ~ \mathrm { A 1 0 0 }$ days with sequence length 512. The table is sorted by Stability, with more stable configurations lower in the table. The left columns of the table indicate configuration. Row 14, which has completely empty configuration columns, is the baseline. The final row is NormFormer.
|
| 210 |
+
|
| 211 |
+
<table><tr><td></td><td> Steps to Target PPL</td><td>Final PPL</td><td>A100 Hours</td></tr><tr><td>Baseline</td><td>279.893</td><td>18.70</td><td>288</td></tr><tr><td>NormFormer</td><td>223.904</td><td>18.65</td><td>237</td></tr></table>
|
| 212 |
+
|
| 213 |
+
Table 6: Wikitext 103 results following Baevski & Auli (2019). Steps to Target PPL: at what percentage of the 280K steps did the model reach 18.70 perplexity. Final PPL: Best Perplexity
|
| 214 |
+
|
| 215 |
+
. A100 Hours Cost of reaching Target PPL.
|
| 216 |
+
|
| 217 |
+

|
| 218 |
+
Figure 7: Change in grad norm with each operation of NormFormer compared to the baseline. Norms are the average between step 950 and 1000, normalized to control for different losses. 2.0 on the Y axis means the gradient to a parameter is twice as large as the baseline, on average. The NormFormer increases the norm to fully connected parameters in later layers, while reducing the gradient norm to attention parameters at all layers. The results are discussed in detail in Section 6.
|
| 219 |
+
|
| 220 |
+
The Architecture and LN Variant columns show whether we changed the model architecture completely and/or used a non-standard LayerNorm algorithm.
|
| 221 |
+
|
| 222 |
+
1. CogView[1] (Ding et al., 2021): implement all of the changes proposed in Section 2.4: (1) reduce the gradients to the embeddings by a factor of 10, (2) add an LN after attention, (3) add an LN after the second fully connected layer (not the first, like NormFormer) (4) change the layer norm formula to $\overset { \cdot } { L } N \bigl ( \frac { X } { M a x ( X ) } \bigr )$ . fairseq already uses the attention score stabilization trick by default. In rows 19 and 25 where Arch is blank, we use the proposed LayerNorm formula but none of the other changes.
|
| 223 |
+
2. CatFormer[2] (Davis et al., 2021): Since no code was released, we re-implement CatFormer and set $\epsilon = 2$ and $\overline { { \overline { { \mathbf { \alpha } } } } } ^ { 4 4 8 }$ to match 1.3B parameters. We guessed that the number of attention heads should be fixed in each layer and that LN positioning should not move, but these details are not clear from the paper.
|
| 224 |
+
3. LayerScale[3] (Touvron et al., 2021): We use the layer scale formulation from Section 2, which is similar to the $\lambda _ { r e s i d }$ discussed earlier, but with a weight on each layer’s contribution to the main branch initialized at 1e-5, instead of a weight on the residual’s input to the main branch initialized at 1.
|
| 225 |
+
4. FFNGeglu[4] (Shazeer, 2020): replace the FFN LayerNorm with ‘FFNGeglu‘. Although this is proposed as an activation function, it is also equivalent to just using the $\gamma$ of LayerNorm, with no normalization or bias.
|
| 226 |
+
5. T5[5] (Raffel et al., 2020): Switch LNs to the T5 variant, which removes the mean centering and bias.
|
| 227 |
+
6. PowerNorm[6] (Shen et al., 2020): Switch LN to PowerNorm, which is a variant of BatchNorm that shows promising results for smaller NLP models.
|
| 228 |
+
7. DeepInit[7] (Zhang et al., 2019): Multiply the initialization of each weight parameter by a factor of √l , where $l$ is the layer number starting from 1.
|
| 229 |
+
|
| 230 |
+
<table><tr><td>Learning Rate</td><td>0.003</td></tr><tr><td>Batch Size</td><td>524KTokens</td></tr><tr><td>Parameters</td><td>124M+</td></tr><tr><td>Layers</td><td>12</td></tr><tr><td>Layer Dimension</td><td>768</td></tr><tr><td>Dropout</td><td>0</td></tr><tr><td>LR Warmup Updates</td><td>500</td></tr><tr><td>LR Scheduler</td><td>Linear Decay</td></tr><tr><td>Sequence Length</td><td>1024</td></tr><tr><td>Train Budget</td><td>470 V100 Hours</td></tr></table>
|
| 231 |
+
|
| 232 |
+
Table 7: Hyperparameters for ablations in Tables 4 and 7. This train budget allows the baseline model to run for 100,000 updates.
|
| 233 |
+
|
| 234 |
+
Table 8: Stability and Performance for different architectures for 1.3B parameter CLMs, see Section 9.1 for details.
|
| 235 |
+
|
| 236 |
+
<table><tr><td>ID</td><td>Arch.</td><td>Scale FC</td><td>Scale Attn</td><td>XResid</td><td>Scale Heads</td><td>LN Variant</td><td>Stability</td><td>Perf</td></tr><tr><td>0</td><td></td><td></td><td>【</td><td></td><td>「</td><td>PowerNorm[6]</td><td>15</td><td>-</td></tr><tr><td>1</td><td>CatFormer[2]</td><td></td><td></td><td></td><td></td><td>-</td><td>34</td><td>=</td></tr><tr><td>2</td><td></td><td></td><td></td><td>√</td><td></td><td></td><td>52</td><td>=</td></tr><tr><td>3</td><td>DeepInit[7]</td><td></td><td></td><td></td><td></td><td></td><td>52</td><td></td></tr><tr><td>4</td><td>DeepInit[7]</td><td>?</td><td></td><td></td><td><</td><td></td><td>58</td><td>=</td></tr><tr><td>5</td><td>=</td><td></td><td></td><td></td><td></td><td>FFNGeglu[4]</td><td>67</td><td>17.1</td></tr><tr><td>6</td><td></td><td></td><td></td><td></td><td></td><td></td><td>69</td><td>=</td></tr><tr><td>7</td><td>LayerScale[3]</td><td></td><td></td><td></td><td></td><td></td><td>76</td><td>17.5</td></tr><tr><td>8</td><td></td><td></td><td></td><td></td><td></td><td></td><td>76</td><td>17.1</td></tr><tr><td>9</td><td></td><td></td><td></td><td></td><td></td><td></td><td>81</td><td>17.1</td></tr><tr><td>10</td><td>CogView[1]</td><td></td><td></td><td></td><td></td><td>CogView[1]</td><td>86</td><td>-</td></tr><tr><td>11</td><td></td><td></td><td></td><td></td><td></td><td>=</td><td>91</td><td></td></tr><tr><td>12</td><td></td><td></td><td></td><td></td><td></td><td>T5[5]</td><td>93</td><td></td></tr><tr><td>13</td><td></td><td></td><td></td><td></td><td></td><td>FFNGeglu[4]</td><td>94</td><td>=</td></tr><tr><td>14</td><td></td><td></td><td></td><td></td><td></td><td></td><td>94</td><td>17.1</td></tr><tr><td>15</td><td></td><td></td><td></td><td></td><td></td><td>No Bias or γ</td><td>95</td><td>1</td></tr><tr><td>16</td><td></td><td></td><td></td><td></td><td></td><td>No Bias</td><td>96</td><td>=</td></tr><tr><td>17</td><td></td><td></td><td></td><td></td><td></td><td>No γ</td><td>98</td><td>=</td></tr><tr><td>18</td><td></td><td></td><td></td><td></td><td></td><td></td><td>112</td><td>16.8</td></tr><tr><td>19</td><td>CogView[1]</td><td></td><td></td><td></td><td></td><td>CogView[1]</td><td>118</td><td>17.1</td></tr><tr><td>20</td><td></td><td></td><td></td><td></td><td></td><td>CogView[1]</td><td>122</td><td>=</td></tr><tr><td>21</td><td>CogView[1]</td><td></td><td></td><td></td><td></td><td>CogView[1]</td><td>124</td><td></td></tr><tr><td>22</td><td></td><td></td><td></td><td></td><td></td><td>=</td><td>128</td><td></td></tr><tr><td>23</td><td></td><td></td><td></td><td></td><td></td><td>PowerNorm[6]</td><td>135</td><td></td></tr><tr><td>24</td><td>LayerScale[3]</td><td></td><td></td><td></td><td></td><td>-</td><td>148</td><td></td></tr><tr><td>25</td><td></td><td></td><td></td><td></td><td></td><td>No Y</td><td>157</td><td></td></tr><tr><td>26</td><td></td><td></td><td></td><td></td><td></td><td>CogView[1]</td><td>165</td><td></td></tr><tr><td>27</td><td></td><td></td><td></td><td></td><td></td><td>No Bias or γ</td><td>178</td><td>16.9</td></tr><tr><td>28</td><td></td><td></td><td></td><td></td><td></td><td>No Bias</td><td>184</td><td>-</td></tr><tr><td>29</td><td></td><td></td><td></td><td></td><td></td><td>T5[5]</td><td>189</td><td>=</td></tr><tr><td>30</td><td></td><td></td><td></td><td></td><td></td><td>1</td><td>192</td><td>16.7</td></tr><tr><td>31</td><td></td><td></td><td></td><td></td><td></td><td>、</td><td>200</td><td>16.6</td></tr></table>
|
| 237 |
+
|
| 238 |
+
8. No $\gamma$ : Freeze $\gamma = 1$ in LN
|
| 239 |
+
|
| 240 |
+
9. No Bias or $\gamma$ : Freeze $\gamma = 1$ , bias ${ } = 0$ in LN
|
| 241 |
+
|
| 242 |
+
10. No Bias: Freeze bias ${ } = 0$ in LN.
|
| 243 |
+
|
| 244 |
+
Results The results suggest that other proposals to mitigate instability in other domains, like vision, text to image generation and reinforcement learning do not improve stability or pre-training performance in the CLM setting.
|
| 245 |
+
|
| 246 |
+
# REFERENCES
|
| 247 |
+
|
| 248 |
+
Jimmy Lei Ba, Jamie Ryan Kiros, and Geoffrey E. Hinton. Layer normalization, 2016.
|
| 249 |
+
|
| 250 |
+
Alexei Baevski and Michael Auli. Adaptive input representations for neural language modeling. In International Conference on Learning Representations, 2019. URL https://openreview. net/forum?id ${ . } = { }$ ByxZX20qFQ.
|
| 251 |
+
|
| 252 |
+
Yonatan Bisk, Rowan Zellers, Ronan Le bras, Jianfeng Gao, and Yejin Choi. Piqa: Reasoning about physical commonsense in natural language. Proceedings of the AAAI Conference on Artificial Intelligence, 34(05):7432–7439, Apr. 2020. doi: 10.1609/aaai.v34i05.6239. URL https:// ojs.aaai.org/index.php/AAAI/article/view/6239.
|
| 253 |
+
|
| 254 |
+
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.
|
| 255 |
+
|
| 256 |
+
Xiaohan Chen, Yu Cheng, Shuohang Wang, Zhe Gan, Zhangyang Wang, and Jingjing Liu. Earlybert: Efficient bert training via early-bird lottery tickets, 2021.
|
| 257 |
+
|
| 258 |
+
Alexis Conneau, Kartikay Khandelwal, Naman Goyal, Vishrav Chaudhary, Guillaume Wenzek, Francisco Guzman, Edouard Grave, Myle Ott, Luke Zettlemoyer, and Veselin Stoyanov. Un-´ supervised cross-lingual representation learning at scale. 2020.
|
| 259 |
+
|
| 260 |
+
Jared Q Davis, Albert Gu, Krzysztof Choromanski, Tri Dao, Christopher Re, Chelsea Finn, and Percy Liang. Catformer: Designing stable transformers via sensitivity analysis. In Marina Meila and Tong Zhang (eds.), Proceedings of the 38th International Conference on Machine Learning, volume 139 of Proceedings of Machine Learning Research, pp. 2489–2499. PMLR, 18–24 Jul 2021. URL https://proceedings.mlr.press/v139/davis21a.html.
|
| 261 |
+
|
| 262 |
+
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. arXiv preprint arXiv:2105.13290, 2021.
|
| 263 |
+
|
| 264 |
+
Dan Hendrycks and Kevin Gimpel. Gaussian error linear units (gelus). arXiv preprint arXiv:1606.08415, 2016.
|
| 265 |
+
|
| 266 |
+
Opher Lieber, Or Sharir, Barak Lenz, and Yoav Shoham. Jurassic-1: Technical details and evaluation. Technical report, AI21 Labs, August 2021.
|
| 267 |
+
|
| 268 |
+
Liyuan Liu, Xiaodong Liu, Jianfeng Gao, Weizhu Chen, and Jiawei Han. Understanding the difficulty of training transformers. arXiv preprint arXiv:2004.08249, 2020.
|
| 269 |
+
|
| 270 |
+
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.
|
| 271 |
+
|
| 272 |
+
Paulius Micikevicius, Sharan Narang, Jonah Alben, Gregory Diamos, Erich Elsen, David Garcia, Boris Ginsburg, Michael Houston, Oleksii Kuchaiev, Ganesh Venkatesh, and Hao Wu. Mixed precision training. In International Conference on Learning Representations, 2018.
|
| 273 |
+
|
| 274 |
+
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 Proceedings of the 2018 Conference on Empirical Methods in Natural Language Processing, pp. 2381–2391, Brussels, Belgium, October-November 2018. Association for Computational Linguistics. doi: 10.18653/v1/D18-1260. URL https://www.aclweb.org/anthology/D18-1260.
|
| 275 |
+
|
| 276 |
+
Nasrin Mostafazadeh, Nathanael Chambers, Xiaodong He, Devi Parikh, Dhruv Batra, Lucy Vanderwende, Pushmeet Kohli, and James Allen. A corpus and cloze evaluation for deeper understanding of commonsense stories. In Proceedings of the 2016 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, pp. 839–849, San Diego, California, June 2016. Association for Computational Linguistics. doi: 10.18653/v1/N16-1098. URL https://www.aclweb.org/anthology/N16-1098.
|
| 277 |
+
|
| 278 |
+
Myle Ott, Sergey Edunov, Alexei Baevski, Angela Fan, Sam Gross, Nathan Ng, David Grangier, and Michael Auli. FAIRSEQ: A fast, extensible toolkit for sequence modeling. 2019.
|
| 279 |
+
|
| 280 |
+
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. pp. 8024–8035, 2019.
|
| 281 |
+
|
| 282 |
+
Ofir Press, Noah A. Smith, and Omer Levy. Improving transformer models by reordering their sublayers, 2020a.
|
| 283 |
+
|
| 284 |
+
Ofir Press, Noah A Smith, and Mike Lewis. Shortformer: Better language modeling using shorter inputs. arXiv preprint arXiv:2012.15832, 2020b.
|
| 285 |
+
|
| 286 |
+
Alec Radford, Jeffrey Wu, Rewon Child, David Luan, Dario Amodei, and Ilya Sutskever. Language models are unsupervised multitask learners. Technical report, OpenAI, 2019.
|
| 287 |
+
|
| 288 |
+
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. 21:1–67, 2020.
|
| 289 |
+
|
| 290 |
+
Keisuke Sakaguchi, Ronan Le Bras, Chandra Bhagavatula, and Yejin Choi. Winogrande: An adversarial winograd schema challenge at scale. Proceedings of the AAAI Conference on Artificial Intelligence, 34(05):8732–8740, Apr. 2020. doi: 10.1609/aaai.v34i05.6399. URL https: //ojs.aaai.org/index.php/AAAI/article/view/6399.
|
| 291 |
+
|
| 292 |
+
Noam Shazeer. Glu variants improve transformer, 2020.
|
| 293 |
+
|
| 294 |
+
Sheng Shen, Zhewei Yao, Amir Gholami, Michael W. Mahoney, and Kurt Keutzer. Powernorm: Rethinking batch normalization in transformers, 2020.
|
| 295 |
+
|
| 296 |
+
David R. So, Wojciech Manke, Hanxiao Liu, Zihang Dai, Noam Shazeer, and Quoc V. Le. Primer:´ Searching for efficient transformers for language modeling, 2021.
|
| 297 |
+
|
| 298 |
+
Hugo Touvron, Matthieu Cord, Alexandre Sablayrolles, Gabriel Synnaeve, and Herve J ´ egou. Going ´ deeper with image transformers, 2021.
|
| 299 |
+
|
| 300 |
+
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, 2017.
|
| 301 |
+
|
| 302 |
+
Alex Wang, Amanpreet Singh, Julian Michael, Felix Hill, Omer Levy, and Samuel R. Bowman. GLUE: A multi-task benchmark and analysis platform for natural language understanding. 2019.
|
| 303 |
+
|
| 304 |
+
Ruibin Xiong, Yunchang Yang, Di He, Kai Zheng, Shuxin Zheng, Chen Xing, Huishuai Zhang, Yanyan Lan, Liwei Wang, and Tie-Yan Liu. On layer normalization in the transformer architecture, 2020.
|
| 305 |
+
|
| 306 |
+
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, pp. 4791–4800, Florence, Italy, July 2019. Association for Computational Linguistics. doi: 10.18653/v1/P19-1472. URL https://www.aclweb.org/ anthology/P19-1472.
|
| 307 |
+
|
| 308 |
+
Biao Zhang, Ivan Titov, and Rico Sennrich. Improving deep transformer with depth-scaled initialization and merged attention, 2019.
|
| 309 |
+
|
| 310 |
+
Chen Zhu, Renkun Ni, Zheng Xu, Kezhi Kong, W Ronny Huang, and Tom Goldstein. Gradinit: Learning to initialize neural networks for stable and efficient training. arXiv preprint arXiv:2102.08098, 2021.
|
| 311 |
+
|
| 312 |
+
Yukun Zhu, Ryan Kiros, Richard 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. arXiv preprint arXiv:1506.06724, 2019.
|
md/dev/GUrhfTuf_3/GUrhfTuf_3.md
ADDED
|
@@ -0,0 +1,345 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# SIMVLM: SIMPLE VISUAL LANGUAGE MODEL PRETRAINING WITH WEAK SUPERVISION
|
| 2 |
+
|
| 3 |
+
Zirui Wang1,2∗, Jiahui $\mathbf { Y u } ^ { 2 }$ , Adams Wei $\mathbf { Y u } ^ { 2 }$ , Zihang Dai2, Yulia Tsvetkov3, Yuan Cao2
|
| 4 |
+
|
| 5 |
+
1Carnegie Mellon University
|
| 6 |
+
{ziruiw}@cs.cmu.edu
|
| 7 |
+
2Google Research, Brain Team
|
| 8 |
+
{jiahuiyu,adamsyuwei,zihangd,yuancao}@google.com
|
| 9 |
+
3University of Washington
|
| 10 |
+
{yuliats}@cs.washington.edu
|
| 11 |
+
|
| 12 |
+
# ABSTRACT
|
| 13 |
+
|
| 14 |
+
With recent progress in joint modeling of visual and textual representations, Vision-Language Pretraining (VLP) has achieved impressive performance on many multimodal downstream tasks. However, the requirement for expensive annotations including clean image captions and regional labels limits the scalability of existing approaches, and complicates the pretraining procedure with the introduction of multiple dataset-specific objectives. In this work, we relax these constraints and present a minimalist pretraining framework, named Simple Visual Language Model (SimVLM). Unlike prior work, SimVLM reduces the training complexity by exploiting large-scale weak supervision, and is trained end-to-end with a single prefix language modeling objective. Without utilizing extra data or task-specific customization, the resulting model significantly outperforms previous pretraining methods and achieves new state-of-the-art results on a wide range of discriminative and generative vision-language benchmarks, including VQA $( + 3 . 7 4 \%$ vqa-score), NLVR2 $( + 1 . 1 7 \%$ accuracy), SNLI-VE $( + 1 . 3 7 \%$ accuracy) and image captioning tasks $( + 1 0 . 1 \%$ average CIDEr score). Furthermore, we demonstrate that SimVLM acquires strong generalization and transfer ability, enabling zero-shot behavior including open-ended visual question answering and cross-modality transfer.
|
| 15 |
+
|
| 16 |
+
# 1 INTRODUCTION
|
| 17 |
+
|
| 18 |
+
Self-supervised textual representation learning (Devlin et al., 2018; Radford et al., 2018; 2019; Liu et al., 2019; Yang et al., 2019; Raffel et al., 2019; Brown et al., 2020) based on Transformers (Vaswani et al., 2017) has pushed the state of the art on a wide range of natural language processing (NLP) tasks (Rajpurkar et al., 2016; Wang et al., 2018; Sarlin et al., 2020). One successful approach is to first pretrain the model (e.g. BERT) on large-scale unlabled text corpora using masked language modeling (MLM) objective (Devlin et al., 2018), followed by finetuning on downstream tasks. While this pretraining-finetuning paradigm has been widely adopted, recent work on autoregressive language models (LM) (Radford et al., 2019; Brown et al., 2020) such as GPT-3 has shown strong performance without finetuning by utilizing few-shot prompts (Liu et al., 2021), suggesting the text guided zero-shot generalization is a promising alternative.
|
| 19 |
+
|
| 20 |
+
Motivated by the success of textual representation pretraining, various efforts have been made to build the multi-modal (visual and textual) counterpart. A line of work (Tan & Bansal, 2019; Lu et al., 2019; Li et al., 2019; Chen et al., 2020b; Li et al., 2020; Su et al., 2020; Zhang et al., 2021) has explored vision-language pretraining (VLP) that learns a joint representation of both modalities to be finetuned on vision-language (VL) benchmarks, such as visual question answering (VQA) (Goyal et al., 2017). In order to capture the alignment between images and text, previous methods have extensively exploited two types of human-labeled datasets from multiple sources, which typically consist of the following steps. Firstly, object detection datasets are used to train a supervised object detector (OD) which allows further extracting region-of-interest (ROI) features from images. Next, datasets with aligned image-text pairs are used for MLM pretraining of a fusion model that usually takes as input the concatenation of the extracted ROI features and the paired text. In addition, due to the limited scale of human annotated data, various task-specific auxiliary losses have been introduced in order to improve performance. These design choices complicate the pretraining protocol of VLP, creating a bottleneck for further quality improvement. What is more, such pretraining-finetuning based approaches usually lack the zero-shot capability, just like their language counterparts. In comparison, another line of work (Radford et al., 2021; Ramesh et al., 2021; Jia et al., 2021) utilizes weakly labeled/aligned data crawled from the web to perform pretraining, achieving good performance and certain zero-shot learning capability on image classification and image-text retrieval. Nonetheless, these methods mainly focus on specific tasks of consideration and thus may not serve as a generic pretraining-finetuning representation for VL benchmarks.
|
| 21 |
+
|
| 22 |
+
In light of these disadvantages of the existing techniques, we are interested in building a VLP model that: (1) can be seamlessly plugged into the pretraining-finetuning paradigm and achieve competitive performance on standard VL benchmarks; (2) does not require a complicated pretraining protocol as in previous methods; and (3) has the potential towards text guided zero-shot generalization in cross-modal settings. To this end, we propose SimVLM, standing for Simple Visual Language Model, which significantly simplifies VLP by solely exploiting language modeling objectives on weakly aligned image-text pairs (Jia et al., 2021). In a nutshell, SimVLM consists of the following components:
|
| 23 |
+
|
| 24 |
+
• Objective. It is trained end-to-end from scratch with a single objective of Prefix Language
|
| 25 |
+
Modeling (PrefixLM), which can not only naturally perform text generation as GPT-3, but also process contextual information in a bidirectional manner as BERT does.
|
| 26 |
+
• Architecture. The framework employs ViT/CoAtNet (Dosovitskiy et al., 2021; Dai et al.,
|
| 27 |
+
2021) and directly takes raw images as inputs. These models can also fit the large-scale data and are readily compatible with the PrefixLM objective.
|
| 28 |
+
Data. These setups relieve the requirement for object detection and allow the model to
|
| 29 |
+
utilize the large-scale weakly labeled dataset, which has better potential towards zero-shot
|
| 30 |
+
generalization.
|
| 31 |
+
|
| 32 |
+
Not only is SimVLM simpler, requiring neither object detection pretraining nor auxiliary losses, but it also obtains better performance than previous work. Empirically, SimVLM consistently outperforms existing VLP models and achieves new state-of-the-art results on 6 VL benchmarks without additional data nor task-specific customization. Besides, it acquires stronger generalization in visual-language understanding that empowers zero-shot image captioning and open-ended VQA. In particular, SimVLM learns unified multimodal representation that enables zero-shot cross-modality transfer, where the model is finetuned on text-only data and directly evaluated on image-and-text test examples without further training. Our results suggest that generative VLP can not only match existing MLM-based methods on VL tasks but also demonstrate promising zero-shot potential.
|
| 33 |
+
|
| 34 |
+
# 2 RELATED WORK
|
| 35 |
+
|
| 36 |
+
Recent years have seen a rapid progress made in vision-language pretraining (Uppal et al., 2020; Han et al., 2021; Khan et al., 2021). While a variety of approaches have been proposed, a large portion of them require object detection for image region feature regression or tagging as part of the pre-training objectives (Tan & Bansal, 2019; Su et al., 2020; Li et al., 2019; Chen et al., 2020b; Gan et al., 2020; Li et al., 2020; Yu et al., 2021; Li et al., 2021; Zhang et al., 2021; Hu et al., 2021; Cho et al., 2021). These methods rely on a strong object detection model like Fast(er) R-CNN (Ren et al., 2015), which is often trained on human annotated data sets like Visual Genome (Krishna et al., 2016). Using such labeled training data as a prerequisite increases the cost of building the training pipeline, and makes the approach less scalable. Some recent efforts have also explored VLP without object detection module (Xu et al., 2021; Kim et al., 2021; Huang et al., 2021), but they only use clean pretraining data with small scales and thus their zero-shot capability is limited.
|
| 37 |
+
|
| 38 |
+
On the other hand, multiple cross-modality loss functions have been proposed as part of the training objectives, for example image-text matching (Tan & Bansal, 2019; Lu et al., 2019; Xu et al., 2021), masked region classification/feature regression (Tan & Bansal, 2019; Chen et al., 2020b), object attribute prediction (Xu et al., 2021), contrastive loss (Li et al., 2020; 2021), word-region alignment (Chen et al., 2020b) word-patch alignment (Kim et al., 2021). They are often mixed with other objectives including image caption generation and masked language modeling to form compound pre-training losses. This creates the challenge of balancing among different losses and datasets, and thus complicates the optimization procedure.
|
| 39 |
+
|
| 40 |
+

|
| 41 |
+
Figure 1: Illustration of the SimVLM model. This shows an example of training with PrefixLM of an image-text pair. For text-only corpora, it is straightforward to remove the image patches and utilize textual tokens only.
|
| 42 |
+
|
| 43 |
+
Our work by contrast, follows a minimalist approach that takes raw image inputs and makes use of only the language modeling loss, without resorting to auxiliary models like faster R-CNN for image region detection. Motivated by recent works (Radford et al., 2021; Ramesh et al., 2021; Jia et al., 2021; Tsimpoukelli et al., 2021) that illustrate zero-shot learning in certain image-text tasks, we train our model using large-scale weakly labeled data only. While concurrent work (Shen et al., 2021) has explored building on top of models pretrained with such dataset, we focus on pretraining from scratch to explore the limit of generative VLP.
|
| 44 |
+
|
| 45 |
+
# 3 SIMVLM
|
| 46 |
+
|
| 47 |
+
# 3.1 BACKGROUND
|
| 48 |
+
|
| 49 |
+
The bidirectional Masked Language Modeling (MLM) has been one of the most popular selfsupervised training objectives for textual representation learning. As demonstrated by BERT (Devlin et al., 2018), it is based on the idea of denoising autoencoder such that the model is trained to recover the corrupted tokens in a document. Specifically, given a text sequence $\mathbf { X }$ , a subset of tokens $\mathbf { X } _ { m }$ are randomly sampled and a corrupted sequence ${ \bf x } _ { \backslash m }$ is constructed by replacing tokens in $\mathbf { x } _ { m }$ with a special [MASK] token. The training objective is to reconstruct $\mathbf { X } _ { m }$ from the context ${ \bf x } _ { \backslash m }$ by minimizing the negative log-likelihood:
|
| 50 |
+
|
| 51 |
+
$$
|
| 52 |
+
\begin{array} { r } { \mathcal { L } _ { \mathrm { M L M } } ( \theta ) = - \mathbb { E } _ { \mathbf { x } \sim D } \left[ \log P _ { \theta } ( \mathbf { x } _ { m } \vert \mathbf { x } _ { \backslash m } ) \right] , } \end{array}
|
| 53 |
+
$$
|
| 54 |
+
|
| 55 |
+
where $\theta$ is the trainable parameters of the model and $D$ is the pretraining data. This approach learns contextualized representations that can be further finetuned for downstream tasks. The MLM-style pretraining has been widely adopted in previous VLP models, whereby the input is an image-text pair and the model needs to predict masked tokens by leveraging image ROI features.
|
| 56 |
+
|
| 57 |
+
Alternatively, the unidirectional Language Modeling (LM) trains the model to directly maximize the likelihood of the sequence $\mathbf { X }$ under the forward autoregressive factorization:
|
| 58 |
+
|
| 59 |
+
$$
|
| 60 |
+
\mathcal { L } _ { \mathrm { L M } } ( \theta ) = - \mathbb { E } _ { { \mathbf { x } } \sim D } \left[ \log P _ { \theta } ( \mathbf { x } ) \right] = - \mathbb { E } _ { { \mathbf { x } } \sim D } \left[ \sum _ { t = 1 } ^ { T } \log P _ { \theta } ( \mathbf { x } _ { t } | \mathbf { x } _ { < t } ) \right] .
|
| 61 |
+
$$
|
| 62 |
+
|
| 63 |
+
Compared with MLM, the LM pretraining has also been shown to be highly effective for multiple NLP tasks (Radford et al., 2018). More importantly, it facilitates the model with strong generation
|
| 64 |
+
|
| 65 |
+
capability that enables text induced zero-shot generalization without finetuning (Brown et al., 2020). While MLM has become the de facto approach in VLP models reviewed above, the generative LM has been understudied.
|
| 66 |
+
|
| 67 |
+
# 3.2 PROPOSED OBJECTIVE: PREFIX LANGUAGE MODELING
|
| 68 |
+
|
| 69 |
+
Motivated by the zero-shot capability introduced by pre-training with LM loss, we propose to pretain vision-language representation using the Prefix Language Modeling (PrefixLM). PrefixLM differs from the standard LM such that it enables bi-directional attention on the prefix sequence (e.g. $\mathbf { X } { < } T _ { p }$ in Eq. (3)), and only conducts autoregressive factorization on the remaining tokens (e.g. $\mathbf { X } _ { \geq T _ { p } }$ in Eq. (3)). During pretraining, a prefix sequence of tokens of (a randomly selected) length $T _ { p }$ is truncated from input sequence and the training objective becomes:
|
| 70 |
+
|
| 71 |
+
$$
|
| 72 |
+
\mathcal { L } _ { \mathrm { P r e f i x L M } } ( \theta ) = - \mathbb { E } _ { { \mathbf { x } } \sim D } \left[ \log P _ { \theta } ( \mathbf { x } _ { \ge T _ { p } } | \mathbf { x } _ { < T _ { p } } ) \right] = - \mathbb { E } _ { { \mathbf { x } } \sim D } \left[ \sum _ { t = T _ { p } } ^ { T } \log P _ { \theta } ( \mathbf { x } _ { t } | \mathbf { x } _ { [ T _ { p } , t ] } , \mathbf { x } _ { < T _ { p } } ) \right] .
|
| 73 |
+
$$
|
| 74 |
+
|
| 75 |
+
Intuitively, images can be considered as prefix for their textual descriptions as they often appear before text in a web document. Therefore, for a given image-text pair, we prepend image feature sequence of length $T _ { i }$ to the text sequence, and enforce the model to sample a prefix of length $T _ { p } \geq T _ { i }$ to calculate LM loss on text data only (an example is shown in Figure 1). Compared to prior MLM style VLP methods, our PrefixLM model under the sequence-to-sequence framework not only enjoys the bidirectional contextualized representation as in MLM, but also can perform text generation similar to LM.
|
| 76 |
+
|
| 77 |
+
# 3.3 ARCHITECTURE
|
| 78 |
+
|
| 79 |
+
We adopt Transformer as the backbone of our model due to its success for both language and vision tasks (Devlin et al., 2018; Dosovitskiy et al., 2021). Differently from standard LM, PrefixLM enables bidirectional attention within the prefix sequence, and thus it is applicable for both decoder-only and encoder-decoder sequence-to-sequence language models. In our preliminary experiments, we found that the inductive bias introduced by encoder-decoder model which decouples encoding from generation is conducive to the improvement of downstream task.
|
| 80 |
+
|
| 81 |
+
An overview of our model architecture is depicted in Figure 1. For the visual modality, inspired by ViT (Dosovitskiy et al., 2021) and CoAtNet (Dai et al., 2021), our model receives the raw image $\mathbf { x } \in \mathbb { R } ^ { H \times W \times C }$ and maps it into flattened 1D sequence of patches $\mathbf { x } _ { p } \in \mathbb { R } ^ { T _ { i } \times D }$ as input for the transformer, where $D$ is the fixed hidden size of the transformer layers and $\begin{array} { r } { T _ { i } = \frac { H W } { P ^ { 2 } } } \end{array}$ is the length of the image tokens for a given patch size $P$ . Following Dai et al. (2021), we use a convolution (Conv) stage consist of the first three blocks of ResNet (He et al., 2016) to extract contextualized patches, which we find advantageous over the naive linear projection (equivalent to $1 \times 1$ Conv layer) used in ViT, consistent with the observation from (Xiao et al., 2021). For the textual modality, we follow the standard practice to tokenize the input sentence into sub-word tokens (Kudo & Richardson, 2018), and the embeddings are learned for a fixed vocabulary. To retain positional information, we add two trainable 1D positional embeddings for image and text inputs separately, and we additionally add 2D relative attention for the image patches within transformer layers (Dai et al., 2021). Notice that we do not add extra modality type embeddings for which we found no improvement in our experiment. We study the effects of various components of the model in Section 4.4.
|
| 82 |
+
|
| 83 |
+
# 3.4 DATASETS
|
| 84 |
+
|
| 85 |
+
Since our approach does not rely on an object detection module and only operates with raw image patch inputs, we pretrain all model parameters from scratch using large-scale noisy image-text data, which has better potential for zero-shot generalization. Specifically, we use the image and alt-text pairs introduced in Jia et al. (2021), which are crawled from the web with minimal post-processing. On the other hand, our formulation of PrefixLM is modality-agnostic and thus we can additionally include text-only corpora to compensate for noisy text supervision in the alt-text data. As shown later in our experiments, this unified PrefixLM formulation reduces the modality discrepancy and improves the model quality.
|
| 86 |
+
|
| 87 |
+
Table 1: Single model results for vision-language pretraining methods on popular VL banchmarks. We report vqa-score for VQA, accuracy for NLVR2 and SNLI-VE, BLEU $@ 4$ for Multi30k and various metrics for image captioning $\mathrm { B } @ 4$ : BLEU $@ 4$ , M: METEOR, C: CIDEr, S: SPICE).
|
| 88 |
+
|
| 89 |
+
<table><tr><td></td><td colspan="2">VQA</td><td colspan="2">NLVR2</td><td colspan="2">SNLI-VE</td><td colspan="3">CoCo Caption</td><td colspan="2">NoCaps</td><td rowspan="2">Multi30k En-De</td></tr><tr><td></td><td>test-dev</td><td>test-std</td><td>dev</td><td>test-P</td><td>dev test</td><td>B@4</td><td>M</td><td>C</td><td>S</td><td>C</td><td>S</td></tr><tr><td colspan="10">Base-sized Models</td><td colspan="3"></td></tr><tr><td>LXMERT</td><td>72.42</td><td>72.54</td><td>74.90</td><td>74.50</td><td>-</td><td></td><td></td><td>=</td><td>-</td><td></td><td></td><td></td><td>=</td></tr><tr><td>VL-T5</td><td>-</td><td>70.30</td><td>74.6</td><td>73.6</td><td>-</td><td></td><td></td><td></td><td>116.5</td><td>-</td><td>-</td><td>-</td><td>45.5</td></tr><tr><td>SOHO</td><td>73.25</td><td>73.47</td><td>76.37</td><td>77.32</td><td>85.00</td><td>84.95</td><td></td><td></td><td>=</td><td>=</td><td>=</td><td>-</td><td></td></tr><tr><td>SimVLMbase</td><td>77.87</td><td>78.14</td><td>81.72</td><td>81.77</td><td>84.20</td><td>84.15</td><td>39.0</td><td>32.9</td><td>134.8</td><td>24.0</td><td>94.8</td><td>13.1</td><td>46.6</td></tr><tr><td colspan="10">Large-sized Models</td><td colspan="3"></td></tr><tr><td>UNITER</td><td>73.82</td><td>74.02</td><td>79.12</td><td>79.98</td><td>79.39</td><td>79.38</td><td>=</td><td></td><td>=</td><td></td><td></td><td>=</td><td>-</td></tr><tr><td>OSCAR</td><td>73.61</td><td>73.82</td><td>79.12</td><td>80.37</td><td>=</td><td>=</td><td>41.7</td><td>30.6</td><td>140.0</td><td>24.5</td><td>80.9</td><td>11.3</td><td>=</td></tr><tr><td>Villa</td><td>74.69</td><td>74.87</td><td>79.76</td><td>81.47</td><td>80.18</td><td>80.02</td><td>-</td><td></td><td></td><td>=</td><td>-</td><td>-</td><td>=</td></tr><tr><td>UNIMO</td><td>75.06</td><td>75.27</td><td>-</td><td>=</td><td>81.11</td><td>80.63</td><td>39.6</td><td>-</td><td>127.7</td><td>-</td><td>-</td><td>-</td><td>=</td></tr><tr><td>VinVL SimVLMlarge</td><td>76.56</td><td>76.60 79.56</td><td>82.67 84.13</td><td>83.98</td><td></td><td>=</td><td>41.0</td><td>31.1</td><td>140.9</td><td>25.2</td><td>92.5</td><td>13.1</td><td></td></tr><tr><td></td><td>79.32</td><td></td><td></td><td>84.84</td><td>85.68</td><td>85.62</td><td>40.3</td><td>33.4</td><td>142.6</td><td>24.7</td><td>108.5</td><td>14.2</td><td>47.5</td></tr><tr><td colspan="10">Huge-sized Models</td><td colspan="3"></td></tr><tr><td>SimVLMhuge</td><td>80.03</td><td>80.34</td><td>84.53</td><td>85.15</td><td>86.21</td><td>86.32</td><td>40.6</td><td>33.7</td><td>143.3</td><td>25.4</td><td>110.3</td><td>14.5</td><td>47.6</td></tr></table>
|
| 90 |
+
|
| 91 |
+
Compared to prior VLP methods consisting of two pretraining stages and multiple auxiliary objectives, our model only requires one-pass pretraining using a single language modeling loss in an end-to-end manner, hence the name Simple Visual Language Model (SimVLM).
|
| 92 |
+
|
| 93 |
+
# 4 EXPERIMENTS
|
| 94 |
+
|
| 95 |
+
We conduct systematic experiments on a diversified set of visual-linguistic benchmarks, including visual question answering, image captioning, visual reasoning, visual entailment, and multimodal translation. We not only examine our model as a general-purpose VL representation learning in the pretraining-finetuning paradigm, but also study its zero-shot generalization towards open-ended VL understanding.
|
| 96 |
+
|
| 97 |
+
# 4.1 SETUP
|
| 98 |
+
|
| 99 |
+
Our models are implemented with the Lingvo framework (Shen et al., 2019). We follow the setup in ViT (Dosovitskiy et al., 2021) to explore 3 variants of SimVLM, namely “Base”, “Large”, and “Huge”, such that each variant follows the same setting as its corresponding ViT variant. All models are pretrained from scratch for about 1M steps on the training set of ALIGN (Jia et al., 2021) and the Colossal Clean Crawled Corpus (C4) dataset presented in Raffel et al. (2019). We mix the two pretraining datasets within each batch, which contains 4,096 image-text pairs (ALIGN) and 512 text-only documents (C4), sharded across 512 TPU v3 chips (Jouppi et al., 2017). More pretraining settings are detailed in Appendix B.1.
|
| 100 |
+
|
| 101 |
+
After pretrained, our model is finetuned and evaluated on six vision-language benchmarks, including three discriminative tasks: VQA v2 (Goyal et al., 2017), SNLI-VE (Xie et al., 2019), and NLVR2 (Suhr et al., 2018); as well as three generative tasks: CoCo captioning (Chen et al., 2015), NoCaps (Agrawal et al., 2019), and Multi30k (Elliott et al., 2016). We additionally examine its zero-shot generalization and performance on single-modality tasks. Details of tasks considered and the finetuning process are outlined in Appendix B.2.
|
| 102 |
+
|
| 103 |
+
# 4.2 COMPARISON WITH EXISTING APPROACHES
|
| 104 |
+
|
| 105 |
+
To examine the quality of vision-language pretraining, we first compare SimVLM on the popular multi-modal tasks with state-of-the-art (SOTA) VLP methods including LXMERT (Tan & Bansal, 2019), VL-T5 (Cho et al., 2021), UNITER (Chen et al., 2020b), OSCAR (Li et al., 2020), Villa (Gan et al., 2020), SOHO (Huang et al., 2021), UNIMO (Li et al., 2021), and VinVL (Zhang et al., 2021).
|
| 106 |
+
|
| 107 |
+
As can be seen in Table 1, SimVLM outperforms all existing models and achieves new SOTA results on all tasks considered, often by a significant margin. This demonstrates our generative pretraining approach is competitive with MLM-based models and that simple framework with weak supervision is sufficient to learn high-quality multi-modal representations.
|
| 108 |
+
|
| 109 |
+
Table 2: Image captioning results on CoCo Karpathy-test split and NoCaps validation split. For NoCaps, $\{ \mathrm { I n } . $ , Near, $\mathrm { O u t } \}$ refer to in-domain, near-domain and out-of-domain respectively. † indicates Cider optimization. Model references: aAnderson et al. (2018) bHuang et al. (2019) $\mathrm { c } _ { \vert }$ Cornia et al. (2020).
|
| 110 |
+
|
| 111 |
+
<table><tr><td rowspan="2"></td><td rowspan="2">Setup</td><td colspan="4">CoCo Caption</td><td colspan="4">NoCaps</td></tr><tr><td>B@4</td><td>M</td><td>C</td><td>S</td><td>In</td><td>Near</td><td>Out</td><td>Overall</td></tr><tr><td>BUTDa</td><td rowspan="3">supervised</td><td>36.3</td><td>27.7</td><td>120.1</td><td>21.4</td><td>-</td><td></td><td>-</td><td>-</td></tr><tr><td>AoANetbt</td><td>39.5</td><td>29.3</td><td>129.3</td><td>23.2</td><td>-</td><td>=</td><td>-</td><td>-</td></tr><tr><td>M2 Transformerc†</td><td>39.1</td><td>29.2</td><td>131.2</td><td>22.6</td><td>81.2</td><td>-</td><td>69.4</td><td>75.0</td></tr><tr><td>SimVLMbase</td><td rowspan="3">zero-shot</td><td>9.5</td><td>11.5</td><td>24.0</td><td>7.5</td><td>83.2</td><td>84.1</td><td>82.5</td><td>83.5</td></tr><tr><td>SimVLMlarge</td><td>10.5</td><td>12.0</td><td>24.9</td><td>8.3</td><td>97.6</td><td>96.5</td><td>96.3</td><td>96.6</td></tr><tr><td>SimVLMhuge</td><td>11.2</td><td>14.7</td><td>32.2</td><td>8.5</td><td>101.2</td><td>100.4</td><td>102.3</td><td>101.4</td></tr><tr><td>SimVLMbase</td><td rowspan="3">few-shot</td><td>34.7</td><td>29.2</td><td>118.7</td><td>21.9</td><td>95.0</td><td>91.9</td><td>98.5</td><td>93.7</td></tr><tr><td>SimVLMIarge</td><td>35.4</td><td>30.2</td><td>124.1</td><td>22.7</td><td>102.5</td><td>100.9</td><td>106.0</td><td>102.2</td></tr><tr><td>SimVLMhuge</td><td>36.8</td><td>31.5</td><td>131.3</td><td>24.0</td><td>111.8</td><td>110.6</td><td>111.0</td><td>110.4</td></tr><tr><td>OSCAR+</td><td rowspan="3">pretrain-finetune</td><td>41.7</td><td>30.6</td><td>140.0</td><td>24.5</td><td>85.4</td><td>84.0</td><td>80.3</td><td>83.4</td></tr><tr><td>VinVL†</td><td>41.0</td><td>31.1</td><td>140.9</td><td>25.2</td><td>103.7</td><td>95.6</td><td>83.8</td><td>94.3</td></tr><tr><td>SimVLMhuge</td><td>40.6</td><td>33.7</td><td>143.3</td><td>25.4</td><td>113.7</td><td>110.9</td><td>115.2</td><td>112.2</td></tr></table>
|
| 112 |
+
|
| 113 |
+
For the discriminative tasks, the $\mathrm { S i m V L M _ { b a s e } }$ already outperforms all prior methods while using less capacity, and the $\mathrm { S i m V L M _ { h u g e } }$ obtains almost 4 points absolute score improvement compared to the previous SOTA (VinVL), pushing the single model performance above $80 \%$ on VQA for the first time. In addition, SimVLM also consistently outperforms prior methods on NLVR2 and SNLI-VE, illustrating its capability of processing more complex visual-linguistic reasoning. For the generation tasks including image captioning and image translation, SimVLM also shows large improvements using naive finetuning techniques. Our model outperforms on 3 out of 4 metrics on the public “Karpathy” 5k test split of CoCo captioning as well as the NoCaps benchmark than prior methods trained with more complex reinforcement learning approach of CIDEr optimization (Rennie et al., 2017). Finally, SimVLM is also effective for image translation of Multi30k from English to German. These experiments demonstrate that our model can be seamlessly plugged into the pretraining-finetuning paradigm with superior performance, utilizing minimalist pretraining and finetuning procedures.
|
| 114 |
+
|
| 115 |
+
# 4.3 ZERO-SHOT GENERALIZATION
|
| 116 |
+
|
| 117 |
+
A crucial benefit of generative modeling and scaling with weak supervision is the potential of zeroshot generalization. Models (Brown et al., 2020; Radford et al., 2021; Jia et al., 2021) have been shown capable of performing few-shot or zero-shot transfer from pretrained models to downstream datasets, even across language boundaries (Lample & Conneau, 2019). In this section, we showcase three different settings of zero-shot applications less explored in prior VLP work, including transferring to unseen tasks, modalities and/or testing instances.
|
| 118 |
+
|
| 119 |
+
# 4.3.1 ZERO-SHOT/FEW-SHOT IMAGE CAPTIONING
|
| 120 |
+
|
| 121 |
+
The pretraining procedure of SimVLM can be interpreted as a noisy image captioning objective on real-world web corpus. Thus, it is natural to ask how well this caption ability generalizes to other datasets in a zero-shot/few-shot manner. To this end, we take the pretrained SimVLM model, and directly decode on image captioning benchmarks for the zero-shot setting while finetune on $1 \%$ training data for 5 epochs for the few-shot setting. We also found that using a prefix prompt “A picture of” improves the quality of decoded captions, similar to the finding in Radford et al. (2021).
|
| 122 |
+
|
| 123 |
+
As shown in Table 2, the zero-shot/few-shot performance (Appendix D) of SimVLM is competitive with fully supervised baselines on CoCo, and it also demonstrates strong generalization on the concept-rich NoCaps benchmark by achieving better scores than pretrained models. Figure 2 (a) illustrates sample captions generated by our model (Appendix A). SimVLM is able to not only capture real-world concepts but also provide a detailed description of the visual input. For example, the decoded samples are able to explain complex scenes with multiple objects (e.g. “people”, “table with drinks”, “dark restaurant”). Besides, the model also shows understanding of fine-grained abstraction such as specific car brand and model (e.g. “Aston Martin”, “Vantage”). SimVLM even performs robustly on challenging images that could be tricky for human, such as abstract or dark pictures. These all illustrate that our model learns a wide range of real-world concepts that generalize well in a zero-shot manner.
|
| 124 |
+
|
| 125 |
+
Table 3: Zero-shot cross-modality transfer results on SNLI-VE and Multi30k. For SNLI-VE, the zero-shot model is finetuned on three source datasets: text-only SNLI-VE (Xie et al., 2019), SNLI (Bowman et al., 2015), and MNLI (Williams et al., 2017). For Multi30k, the model is finetuned on text-only Multi30k data. Model reference: a(Specia et al., 2016).
|
| 126 |
+
|
| 127 |
+
<table><tr><td></td><td>SNLI-VE (T)</td><td>SNLI-VE SNLI AcCdev/AcCtest</td><td>MNLI</td><td>Multi30k Multi30k (T) B@4</td><td>M</td></tr><tr><td colspan="6">Fully Supervised Baseline</td></tr><tr><td>EVE-Image</td><td colspan="3">71.56 /71.16</td><td></td><td></td></tr><tr><td>UNITER</td><td colspan="3">78.59 /78.28</td><td></td><td>■</td></tr><tr><td>SOHO</td><td colspan="3">85.00 /84.95</td><td>■</td><td>■</td></tr><tr><td>LIUMa</td><td colspan="3"></td><td>23.8</td><td>35.1</td></tr><tr><td>GroundedTransa</td><td colspan="3">■</td><td>15.8</td><td>31.2</td></tr><tr><td>Zero-Shot Cross-Modality Transfer</td><td colspan="3"></td><td></td><td></td></tr><tr><td>SimVLMbase</td><td>71.35 /71.02</td><td>72.65 /72.24</td><td>64.37 /63.98</td><td>15.0</td><td>24.8</td></tr><tr><td>SimVLMlarge</td><td>72.85 /72.44</td><td>73.62/73.23</td><td>66.97 / 66.31</td><td>17.7</td><td>30.1</td></tr><tr><td>SimVLMhuge</td><td>73.56 /73.08</td><td>74.24 /73.86</td><td>67.45 /66.97</td><td>18.2</td><td>32.6</td></tr></table>
|
| 128 |
+
|
| 129 |
+
# 4.3.2 ZERO-SHOT CROSS-MODALITY TRANSFER
|
| 130 |
+
|
| 131 |
+
Existing pretraining methods have been shown to be successful in transferring knowledge across heterogeneous data spaces. For example, multilingual language models (Devlin et al., 2018; Lample & Conneau, 2019) enable zero-shot cross-lingual transfer such that the model is only finetuned using training data from a source language (typically English) and evaluated on the target language without further training. Inspired by this setup, we explore a novel zero-shot cross-modality transfer paradigm of utilizing VLP models, and evaluate how well our model generalizes across modalities. Since text training data are usually cheaper to obtain compared to visual data, we finetune SimVLM on text-only downstream data and then directly evaluate the zero-shot transfer on joint VL tasks.
|
| 132 |
+
|
| 133 |
+
Specifically, We utilize SNLI-VE and Multi30k to examine the zero-shot transfer performance. For SNLI-VE, we finetune on three text-only NLI datasets such that the premise sentence is used as the encoder’s input while the hypothesis is fed to the decoder, and a similar classifier head is trained on the embedding of the last token in the decoder. At inference, the finetuned model is evaluated by taking the premise image as the encoder input and the corresponding hypothesis sentence to the decoder. As shown in Table 3, SimVLM performs competitively with fully supervised baselines including UNITER under the zero-shot setting. As a sanity check, we also mask out the image feature to predict using the hypothesis only, and find our models can only obtain results close to random guess (average scores of 34.31 / 34.62). This results in performance close to random guess hence demonstrating the effectiveness of SimVLM’s cross-modality transfer ability.
|
| 134 |
+
|
| 135 |
+
In addition, SimVLM is also capable of domain adaption by transferring from the MNLI dataset to SNLI-VE, whereby data comes not only from a different modality but also another domain. We also find it possible to transfer across different languages and modalities using SimVLM. Specifically, we utilize the German image captioning task from WMT 2016 of Multi30k for evaluation, where our model is finetuned on English-German text-only translation data followed by decoding with image-only input in the encoder. Table 3 shows that SimVLM is capable of transferring knowledge across modalities and languages in generative tasks, achieving comparable performance to supervised baselines (decoded examples shown in Figure 2 (b)). These results suggest zero-shot cross-modality transfer emerges with the scaling of weakly labeled data.
|
| 136 |
+
|
| 137 |
+
# 4.3.3 OPEN-ENDED VQA
|
| 138 |
+
|
| 139 |
+
On the VQA benchmark, the best performing models to date formulate the problem as a discriminative task of multi-label classification over a predefined 3,129 answer candidates, often consisting of short factual terms. In real-world applications, however, it is hard to define a closed set of candidate answers that covering all possible scenarios, making the true open-ended VQA a challenging setup.
|
| 140 |
+
|
| 141 |
+
Table 4: Comparison of discriminative and generative VQA methods. “Dev” refers to standard vqa-score on the VQA validation split. “Karpathy-test” is the setup used in Cho et al. (2021) for evaluation on the Karpathy split with rare answers. “Partial Train” refers to train the model only on partial training data which contain subset of all candidate answers.
|
| 142 |
+
|
| 143 |
+
<table><tr><td></td><td>Dev</td><td colspan="3">Karpathy-test</td><td colspan="3">Partial Train Out-domain</td></tr><tr><td>In-domain</td><td></td><td>Out-domain</td><td></td><td>Overall</td><td>In-domain</td><td></td><td>Overall</td></tr><tr><td colspan="8">Discriminative</td></tr><tr><td>UNITER</td><td>-</td><td>74.4</td><td>10.0</td><td>70.5</td><td></td><td></td><td></td></tr><tr><td>VL-T5</td><td>-</td><td>70.2</td><td>7.1</td><td>66.4</td><td></td><td>=</td><td>=</td></tr><tr><td>VL-BART SimVLMbase</td><td>-</td><td>69.4</td><td>7.0</td><td>65.7</td><td>=</td><td>-</td><td>=</td></tr><tr><td>SimVLMlarge</td><td>73.8 76.0</td><td>79.0 80.4</td><td>16.7 17.3</td><td>75.3 76.7</td><td>78.4 79.5</td><td>10.3</td><td>70.5</td></tr><tr><td>SimVLMhuge</td><td></td><td></td><td>17.5</td><td>77.2</td><td>80.2</td><td>11.0</td><td>71.8</td></tr><tr><td></td><td>76.5</td><td>81.0</td><td></td><td></td><td></td><td>11.1</td><td>72.2</td></tr><tr><td colspan="8">Generative</td></tr><tr><td>VL-T5</td><td>-</td><td>71.4</td><td>13.1</td><td>67.9</td><td>=</td><td>=</td><td>=</td></tr><tr><td>VL-BART</td><td>-</td><td>72.1</td><td>13.2</td><td>68.6</td><td>-</td><td>-</td><td>=</td></tr><tr><td>SimVLMbase</td><td>73.2</td><td>78.3</td><td>25.8</td><td>75.2</td><td>77.1</td><td>27.1</td><td>71.3</td></tr><tr><td>SimVLMlarge</td><td>75.2</td><td>79.5</td><td>29.6</td><td>76.5</td><td>78.7</td><td>28.4</td><td>72.5</td></tr><tr><td>SimVLMhuge</td><td>75.5</td><td>79.9</td><td>30.3</td><td>77.0</td><td>79.1</td><td>28.8</td><td>73.0</td></tr></table>
|
| 144 |
+
|
| 145 |
+
Generative models such as SimVLM provide an alternative solution towards this challenge by generating free-form textual answers without being constrained to predefined answers. To this end, we finetune SimVLM using the PrefixLM loss described above where we treat the concatenation of the image and the question as the prefix, and train the model to generate answers.
|
| 146 |
+
|
| 147 |
+
We then compare the generative approach with classification methods in Table 4. Firstly, we follow Cho et al. (2021) and evaluate model performance on questions with rare answers in the Karpathy-test split. Here, outof-domain questions are defined as those with best-scoring answer not included in the 3,129 candidates. Results show that SimVLM outperforms both discriminative and generative baselines on all splits. More importantly, the generative SimVLM significantly improves on the out-of-domain split by over 17 points, demonstrating its strong generalization. However, this setup mainly focuses on rare answers and it remains unclear how well the model generalizes to common unseen answers. We therefore pro
|
| 148 |
+
|
| 149 |
+
Table 5: Linear evaluation on ImageNet classification, compared to state-of-the-art representation learning methods.
|
| 150 |
+
|
| 151 |
+
<table><tr><td>Method</td><td>Acc@1</td></tr><tr><td>SimCLRv2 (Chen et al., 2020a)</td><td>79.8</td></tr><tr><td>DINO (Caron et al., 2021)</td><td>80.1</td></tr><tr><td>CLIP (Radford et al., 2021)</td><td>85.4</td></tr><tr><td>ALIGN (Jia et al., 2021)</td><td>85.5</td></tr><tr><td>SimVLMbase SimVLMlarge</td><td>80.6</td></tr><tr><td>SimVLMhuge</td><td>82.3</td></tr><tr><td></td><td>83.6</td></tr></table>
|
| 152 |
+
|
| 153 |
+
ceed to investigate a more challenging setup where we randomly select 2,085 (about two-thirds of 3,129) in-domain answers and partition both train and validation sets into two splits based on whether their best-scoring answers are included in the selected set or not. We then only finetune SimVLM on the in-domain split of the train set and evaluate on the entire validation set. The “Partial Train” column in Table 4 shows that the generative $\mathrm { S i m V L M }$ is also competent in this setup by scoring reasonably well on over 1,000 unseen answers. Overall, we found the generative SimVLM performs competitively with its discriminative counterpart in the standard setup, and works generally better in the out-of-domain case.
|
| 154 |
+
|
| 155 |
+
Note that we use the exact matching between generated answers and human labels for score calculation in the above experiment, however it is possible that the model generates appropriate answers in different formats or synonyms. Therefore, in addition to the quantitative study above, we show qualitative generation results in Figure 2 (c). It can be observed that SimVLM is able to generate answers not included in the 3,129 candidate set (e.g. “surgeon” and “wood carving”), demonstrating that $\mathrm { S i m V L M }$ can transfer knowledge from the pretraining corpus to VQA. It is thus natural to ask whether SimVLM can perform zero-shot VQA without finetuning at all. In our experiments, we found that SimVLM is able to “answer” by completing prompting sentences, as shown in Figure 2 (d). Nonetheless, we also observed that the model falls short in generating meaningful answers to the real questions. We hypothesize that this is due to the low quality of the pretraining data in which most textual descriptions are short and noisy. To verify our assumption, we continue the pretraining process on the cleaner WIT dataset (Srinivasan et al., 2021) for $5 0 \mathrm { k }$ steps. Examples in Figure 2 (e)
|
| 156 |
+
|
| 157 |
+
show that open-ended VQA ability emerges in SimVLM such that it can generate related responses after finetuning on the knowledge-rich wikipedia dataset.
|
| 158 |
+
|
| 159 |
+
# 4.4 ANALYSIS
|
| 160 |
+
|
| 161 |
+
Single-Modality Tasks. Since SimVLM performs well on joint vision-language benchmarks, it is natural to ask how well the learned representations perform on tasks of single modality. We hope to gain deeper insights into the model behavior by examining its performance on these benchmarks, but it is not our intention to achieve state-of-the-art on singlemodality tasks. In Table 7 (Appendix C), we compare SimVLM with existing VLP models on the GLUE benchmark (Wang et al., 2018), where we mainly follow the text processing procedure in Raffel et al. (2019) and train our model to classify the fully formatted input without token type embeddings. SimVLM performs better than existing VLP methods and competitively with BERT, indicating that it has good language understanding ability. Additionally, we also compute the top-1 accuracy on ImageNet following the linear evaluation protocol in Table 5. Note that our model is not pretrained with a discriminative task such as the contrastive loss, hence we use an average pooling of encoder outputs as image features. Results verify that our model has also learned high-quality image representation.
|
| 162 |
+
|
| 163 |
+
Table 6: Ablation study on VQA. “w/ LM” and “w/ span corruption” denote replacing the proposed PrefixLM loss with a different pretraining objective. “Image2Text” and “Text2Text” refer to the noisy image-text data and the text-only data used for pretraining. “conv blks” denotes number of ResNet blocks.
|
| 164 |
+
|
| 165 |
+
<table><tr><td>Method</td><td> VQA score</td></tr><tr><td>No Pretraining</td><td>49.70</td></tr><tr><td>Decoder-only w/ LM</td><td>65.23 64.48</td></tr><tr><td>SimVLMsmall</td><td>67.43</td></tr><tr><td>w/o Image2Text w/o Text2Text</td><td>49.23</td></tr><tr><td></td><td>65.25</td></tr><tr><td>w/o conv stage</td><td>63.11</td></tr><tr><td>w/ span corruption</td><td>66.23</td></tr><tr><td>w/ 2 conv blks</td><td>65.57</td></tr><tr><td>w/ 4 conv blks</td><td>66.55</td></tr><tr><td>w/10% ALIGN</td><td>66.71</td></tr><tr><td></td><td></td></tr><tr><td>w/ CC-3M</td><td>63.32</td></tr></table>
|
| 166 |
+
|
| 167 |
+
Ablation Study. To study the contributions from each model component, we conduct ablation study on $\mathrm { S i m V L M _ { s m a l l } }$ models with an embedding dimension of 512 and 8 layers. We make comparisons on VQA in Table 6. First, we compare encoder-decoder models with decoder-only models of comparable model size, and find that decoder-only model performs significantly worse on VQA. This suggests the inductive bias of separating bidirectional encoding from unidirectional decoding is beneficial for joint VL representation learning. Next, we study the effectiveness of pretraining objectives and results show that the PrefixLM objective outperforms both span corruption (Raffel et al., 2019) and naive LM, illustrating the importance of using a unified objective formulation for both image-text and text-only data. Moreover, we ablate the contribution of datasets. While weakly aligned image-text data are required for bridging the gap between visual and textual representations, text-only corpora also improves the model quality. This is probably because textual signals are extremely noisy in the former and thus the model relies on the later to acquire better language understanding. In addition, we experimented with $10 \%$ ALIGN and CC-3M (Sharma et al., 2018) datasets, and confirms the importance of data scaling. We then study the effect of the convolution stage and find it critical for VL performance. Following Dai et al. (2021), we experiment with using either the first 2/3/4 ResNet Conv blocks, and empirically observe that the 3 conv block setup works best. This indicates that image and text have different levels of representation granularity and thus utilizing contextualized patches is beneficial.
|
| 168 |
+
|
| 169 |
+
# 5 CONCLUSION
|
| 170 |
+
|
| 171 |
+
In this work, we present a simple yet effective framework of vision-language pretraining. Unlike prior works using object proposal systems and auxiliary losses, our model processes whole image as patches and is trained end-to-end with a single prefix language modeling objective. Our work suggests a promising alternative to existing VLP paradigm and we hope our work may inspire future research on generative VLP.
|
| 172 |
+
|
| 173 |
+
# ACKNOWLEDGMENTS
|
| 174 |
+
|
| 175 |
+
We would like to thank Hieu Pham, Chao Jia, Andrew Dai, Bowen Zhang, Zhifeng Chen, Ruoming Pang, Douglas Eck, Claire Cui and Yonghui Wu for helpful discussions, Krishna Srinivasan, Samira Daruki, Nan Du and Aashi Jain for help with data preparation, Chao Jia, Zhen Li, Jonathan Shen, Colin Raffel and Sharan Narang for assistance on experimental settings, and others in the Google Brain team for support throughout this project.
|
| 176 |
+
|
| 177 |
+
# REFERENCES
|
| 178 |
+
|
| 179 |
+
Harsh Agrawal, Karan Desai, Yufei Wang, Xinlei Chen, Rishabh Jain, Mark Johnson, Dhruv Batra, Devi Parikh, Stefan Lee, and Peter Anderson. nocaps: novel object captioning at scale. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pp. 8948–8957, 2019.
|
| 180 |
+
|
| 181 |
+
Peter Anderson, Xiaodong He, Chris Buehler, Damien Teney, Mark Johnson, Stephen Gould, and Lei Zhang. Bottom-up and top-down attention for image captioning and visual question answering. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 6077–6086, 2018.
|
| 182 |
+
|
| 183 |
+
Samuel R Bowman, Gabor Angeli, Christopher Potts, and Christopher D Manning. A large annotated corpus for learning natural language inference. arXiv preprint arXiv:1508.05326, 2015.
|
| 184 |
+
|
| 185 |
+
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.
|
| 186 |
+
|
| 187 |
+
Mathilde Caron, Hugo Touvron, Ishan Misra, Herve J ´ egou, Julien Mairal, Piotr Bojanowski, and ´ Armand Joulin. Emerging properties in self-supervised vision transformers. arXiv preprint arXiv:2104.14294, 2021.
|
| 188 |
+
|
| 189 |
+
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, 2020a.
|
| 190 |
+
|
| 191 |
+
Xinlei Chen, Hao Fang, Tsung-Yi Lin, Ramakrishna Vedantam, Saurabh Gupta, Piotr Dollar, and ´ C Lawrence Zitnick. Microsoft coco captions: Data collection and evaluation server. arXiv preprint arXiv:1504.00325, 2015.
|
| 192 |
+
|
| 193 |
+
Yen-Chun Chen, Linjie Li, Licheng Yu, Ahmed El Kholy, Faisal Ahmed, Zhe Gan, Yu Cheng, and Jingjing Liu. Uniter: Universal image-text representation learning. In ECCV, 2020b.
|
| 194 |
+
|
| 195 |
+
Jaemin Cho, Jie Lei, Hao Tan, and Mohit Bansal. Unifying vision-and-language tasks via text generation. arXiv preprint arXiv:2102.02779, 2021.
|
| 196 |
+
|
| 197 |
+
Marcella Cornia, Matteo Stefanini, Lorenzo Baraldi, and Rita Cucchiara. Meshed-memory transformer for image captioning. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 10578–10587, 2020.
|
| 198 |
+
|
| 199 |
+
Zihang Dai, Hanxiao Liu, Quoc V Le, and Mingxing Tan. Coatnet: Marrying convolution and attention for all data sizes. arXiv preprint arXiv:2106.04803, 2021.
|
| 200 |
+
|
| 201 |
+
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.
|
| 202 |
+
|
| 203 |
+
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. In International Conference on Learning Representations, 2021. URL https: //openreview.net/forum?id $=$ YicbFdNTTy.
|
| 204 |
+
|
| 205 |
+
Desmond Elliott, Stella Frank, Khalil Sima’an, and Lucia Specia. Multi30k: Multilingual englishgerman image descriptions. arXiv preprint arXiv:1605.00459, 2016.
|
| 206 |
+
|
| 207 |
+
Zhe Gan, Yen-Chun Chen, Linjie Li, Chen Zhu, Yu Cheng, and Jingjing Liu. Large-scale adversarial training for vision-and-language representation learning. arXiv preprint arXiv:2006.06195, 2020.
|
| 208 |
+
|
| 209 |
+
Yash Goyal, Tejas Khot, Douglas Summers-Stay, Dhruv Batra, and Devi Parikh. Making the v in vqa matter: Elevating the role of image understanding in visual question answering. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 6904–6913, 2017.
|
| 210 |
+
|
| 211 |
+
Kai Han, Yunhe Wang, Hanting Chen, Xinghao Chen, Jianyuan Guo, Zhenhua Liu, Yehui Tang, An Xiao, Chunjing Xu, Yixing Xu, Zhaohui Yang, Yiman Zhang, and Dacheng Tao. A survey on visual transformer, 2021.
|
| 212 |
+
|
| 213 |
+
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.
|
| 214 |
+
|
| 215 |
+
Xiaowei Hu, Xi Yin, Kevin Lin, Lijuan Wang, Lei Zhang, Jianfeng Gao, and Zicheng Liu. Vivo: Surpassing human performance in novel object captioning with visual vocabulary pre-training. In AAAI, February 2021.
|
| 216 |
+
|
| 217 |
+
Gao Huang, Yu Sun, Zhuang Liu, Daniel Sedra, and Kilian Q Weinberger. Deep networks with stochastic depth. In European conference on computer vision, pp. 646–661. Springer, 2016.
|
| 218 |
+
|
| 219 |
+
Lun Huang, Wenmin Wang, Jie Chen, and Xiao-Yong Wei. Attention on attention for image captioning. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pp. 4634–4643, 2019.
|
| 220 |
+
|
| 221 |
+
Zhicheng Huang, Zhaoyang Zeng, Yupan Huang, Bei Liu, Dongmei Fu, and Jianlong Fu. Seeing out of the box: End-to-end pre-training for vision-language representation learning. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 12976–12985, 2021.
|
| 222 |
+
|
| 223 |
+
Taichi Iki and Akiko Aizawa. Effect of vision-and-language extensions on natural language understanding in vision-and-language models. arXiv preprint arXiv:2104.08066, 2021.
|
| 224 |
+
|
| 225 |
+
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. arXiv preprint arXiv:2102.05918, 2021.
|
| 226 |
+
|
| 227 |
+
Norman P. Jouppi, Cliff Young, Nishant Patil, David Patterson, Gaurav Agrawal, Raminder Bajwa, Sarah Bates, Suresh Bhatia, Nan Boden, Al Borchers, Rick Boyle, Pierre luc Cantin, Clifford Chao, Chris Clark, Jeremy Coriell, Mike Daley, Matt Dau, Jeffrey Dean, Ben Gelb, Tara Vazir Ghaemmaghami, Rajendra Gottipati, William Gulland, Robert Hagmann, C. Richard Ho, Doug Hogberg, John Hu, Robert Hundt, Dan Hurt, Julian Ibarz, Aaron Jaffey, Alek Jaworski, Alexander Kaplan, Harshit Khaitan, Andy Koch, Naveen Kumar, Steve Lacy, James Laudon, James Law, Diemthu Le, Chris Leary, Zhuyuan Liu, Kyle Lucke, Alan Lundin, Gordon MacKean, Adriana Maggiore, Maire Mahony, Kieran Miller, Rahul Nagarajan, Ravi Narayanaswami, Ray Ni, Kathy Nix, Thomas Norrie, Mark Omernick, Narayana Penukonda, Andy Phelps, Jonathan Ross, Matt Ross, Amir Salek, Emad Samadiani, Chris Severn, Gregory Sizikov, Matthew Snelham, Jed Souter, Dan Steinberg, Andy Swing, Mercedes Tan, Gregory Thorson, Bo Tian, Horia Toma, Erick Tuttle, Vijay Vasudevan, Richard Walter, Walter Wang, Eric Wilcox, and Doe Hyun Yoon. In-datacenter performance analysis of a tensor processing unit, 2017.
|
| 228 |
+
|
| 229 |
+
Salman Khan, Muzammal Naseer, Munawar Hayat, Syed Waqas Zamir, Fahad Shahbaz Khan, and Mubarak Shah. Transformers in vision: A survey, 2021.
|
| 230 |
+
|
| 231 |
+
Wonjae Kim, Bokyung Son, and Ildoo Kim. Vilt: Vision-and-language transformer without convolution or region supervision, 2021.
|
| 232 |
+
|
| 233 |
+
Ranjay Krishna, Yuke Zhu, Oliver Groth, Justin Johnson, Kenji Hata, Joshua Kravitz, Stephanie Chen, Yannis Kalantidis, Li-Jia Li, David A Shamma, Michael Bernstein, and Li Fei-Fei. Visual genome: Connecting language and vision using crowdsourced dense image annotations. 2016. URL https://arxiv.org/abs/1602.07332.
|
| 234 |
+
|
| 235 |
+
Taku Kudo and John Richardson. Sentencepiece: A simple and language independent subword tokenizer and detokenizer for neural text processing. arXiv preprint arXiv:1808.06226, 2018.
|
| 236 |
+
|
| 237 |
+
Guillaume Lample and Alexis Conneau. Cross-lingual language model pretraining. arXiv preprint arXiv:1901.07291, 2019.
|
| 238 |
+
|
| 239 |
+
Liunian Harold Li, Mark Yatskar, Da Yin, Cho-Jui Hsieh, and Kai-Wei Chang. Visualbert: A simple and performant baseline for vision and language, 2019.
|
| 240 |
+
|
| 241 |
+
Wei Li, Can Gao, Guocheng Niu, Xinyan Xiao, Hao Liu, Jiachen Liu, Hua Wu, and Haifeng Wang. UNIMO: Towards unified-modal understanding and generation via cross-modal contrastive learning. 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. 2592–2607, Online, August 2021. Association for Computational Linguistics. doi: 10.18653/v1/2021.acl-long.202. URL https://aclanthology.org/2021. acl-long.202.
|
| 242 |
+
|
| 243 |
+
Xiujun Li, Xi Yin, Chunyuan Li, Xiaowei Hu, Pengchuan Zhang, Lei Zhang, Lijuan Wang, Houdong Hu, Li Dong, Furu Wei, Yejin Choi, and Jianfeng Gao. Oscar: Object-semantics aligned pretraining for vision-language tasks. ECCV 2020, 2020.
|
| 244 |
+
|
| 245 |
+
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, 2021.
|
| 246 |
+
|
| 247 |
+
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.
|
| 248 |
+
|
| 249 |
+
Ilya Loshchilov and Frank Hutter. Decoupled weight decay regularization. arXiv preprint arXiv:1711.05101, 2017.
|
| 250 |
+
|
| 251 |
+
Jiasen Lu, Dhruv Batra, Devi Parikh, and Stefan Lee. Vilbert: Pretraining task-agnostic visiolinguistic representations for vision-and-language tasks. 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. URL https://proceedings.neurips. cc/paper/2019/file/c74d97b01eae257e44aa9d5bade97baf-Paper.pdf.
|
| 252 |
+
|
| 253 |
+
Ofir Press and Lior Wolf. Using the output embedding to improve language models. arXiv preprint arXiv:1608.05859, 2016.
|
| 254 |
+
|
| 255 |
+
Alec Radford, Karthik Narasimhan, Tim Salimans, and Ilya Sutskever. Improving language understanding by generative pre-training. 2018.
|
| 256 |
+
|
| 257 |
+
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.
|
| 258 |
+
|
| 259 |
+
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. arXiv preprint arXiv:2103.00020, 2021.
|
| 260 |
+
|
| 261 |
+
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.
|
| 262 |
+
|
| 263 |
+
Pranav Rajpurkar, Jian Zhang, Konstantin Lopyrev, and Percy Liang. Squad: $1 0 0 { , } 0 0 0 { + }$ questions for machine comprehension of text. arXiv preprint arXiv:1606.05250, 2016.
|
| 264 |
+
|
| 265 |
+
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.
|
| 266 |
+
|
| 267 |
+
Shaoqing Ren, Kaiming He, Ross Girshick, and Jian Sun. Faster r-cnn: Towards real-time object detection with region proposal networks. In C. Cortes, N. Lawrence, D. Lee, M. Sugiyama, and R. Garnett (eds.), Advances in Neural Information Processing Systems, volume 28. Curran Associates, Inc., 2015. URL https://proceedings.neurips.cc/paper/2015/file/ 14bfa6bb14875e45bba028a21ed38046-Paper.pdf.
|
| 268 |
+
|
| 269 |
+
Steven J Rennie, Etienne Marcheret, Youssef Mroueh, Jerret Ross, and Vaibhava Goel. Self-critical sequence training for image captioning. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 7008–7024, 2017.
|
| 270 |
+
|
| 271 |
+
Paul-Edouard Sarlin, Daniel DeTone, Tomasz Malisiewicz, and Andrew Rabinovich. Superglue: Learning feature matching with graph neural networks. In Proceedings of the IEEE/CVF conference on computer vision and pattern recognition, pp. 4938–4947, 2020.
|
| 272 |
+
|
| 273 |
+
Piyush Sharma, Nan Ding, Sebastian Goodman, and Radu Soricut. Conceptual captions: A cleaned, hypernymed, image alt-text dataset for automatic image captioning. In Proceedings of the 56th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pp. 2556–2565, Melbourne, Australia, July 2018. Association for Computational Linguistics. doi: 10.18653/v1/P18-1238. URL https://aclanthology.org/P18-1238.
|
| 274 |
+
|
| 275 |
+
Jonathan Shen, Patrick Nguyen, Yonghui Wu, Zhifeng Chen, et al. Lingvo: a modular and scalable framework for sequence-to-sequence modeling, 2019.
|
| 276 |
+
|
| 277 |
+
Sheng Shen, Liunian Harold Li, Hao Tan, Mohit Bansal, Anna Rohrbach, Kai-Wei Chang, Zhewei Yao, and Kurt Keutzer. How much can clip benefit vision-and-language tasks? arXiv preprint arXiv:2107.06383, 2021.
|
| 278 |
+
|
| 279 |
+
Lucia Specia, Stella Frank, Khalil Sima’An, and Desmond Elliott. A shared task on multimodal machine translation and crosslingual image description. In Proceedings of the First Conference on Machine Translation: Volume 2, Shared Task Papers, pp. 543–553, 2016.
|
| 280 |
+
|
| 281 |
+
Krishna Srinivasan, Karthik Raman, Jiecao Chen, Michael Bendersky, and Marc Najork. Wit: Wikipedia-based image text dataset for multimodal multilingual machine learning. arXiv preprint arXiv:2103.01913, 2021.
|
| 282 |
+
|
| 283 |
+
Weijie Su, Xizhou Zhu, Yue Cao, Bin Li, Lewei Lu, Furu Wei, and Jifeng Dai. Vl-bert: Pretraining of generic visual-linguistic representations. In International Conference on Learning Representations, 2020. URL https://openreview.net/forum?id $\underline { { \underline { { \mathbf { \Pi } } } } } =$ SygXPaEYvH.
|
| 284 |
+
|
| 285 |
+
Alane Suhr, Stephanie Zhou, Ally Zhang, Iris Zhang, Huajun Bai, and Yoav Artzi. A corpus for reasoning about natural language grounded in photographs. arXiv preprint arXiv:1811.00491, 2018.
|
| 286 |
+
|
| 287 |
+
Hao Tan and Mohit Bansal. LXMERT: Learning cross-modality encoder representations from transformers. 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. 5100–5111, Hong Kong, China, November 2019. Association for Computational Linguistics. doi: 10.18653/v1/D19-1514. URL https://aclanthology.org/ D19-1514.
|
| 288 |
+
|
| 289 |
+
Maria Tsimpoukelli, Jacob 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, 2021.
|
| 290 |
+
|
| 291 |
+
Shagun Uppal, Sarthak Bhagat, Devamanyu Hazarika, Navonil Majumdar, Soujanya Poria, Roger Zimmermann, and Amir Zadeh. Multimodal research in vision and language: A review of current and emerging trends, 2020.
|
| 292 |
+
|
| 293 |
+
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.
|
| 294 |
+
|
| 295 |
+
Alex Wang, Amanpreet Singh, Julian Michael, Felix Hill, Omer Levy, and Samuel R Bowman. Glue: A multi-task benchmark and analysis platform for natural language understanding. arXiv preprint arXiv:1804.07461, 2018.
|
| 296 |
+
Adina Williams, Nikita Nangia, and Samuel R Bowman. A broad-coverage challenge corpus for sentence understanding through inference. arXiv preprint arXiv:1704.05426, 2017.
|
| 297 |
+
Tete Xiao, Mannat Singh, Eric Mintun, Trevor Darrell, Piotr Dollar, and Ross Girshick. Early ´ convolutions help transformers see better, 2021.
|
| 298 |
+
Ning Xie, Farley Lai, Derek Doran, and Asim Kadav. Visual entailment: A novel task for finegrained image understanding. arXiv preprint arXiv:1901.06706, 2019.
|
| 299 |
+
Haiyang Xu, Ming Yan, Chenliang Li, Bin Bi, Songfang Huang, Wenming Xiao, and Fei Huang. E2E-VLP: End-to-end vision-language pre-training enhanced by visual learning. 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. 503–513, Online, August 2021. Association for Computational Linguistics. doi: 10.18653/v1/ 2021.acl-long.42. URL https://aclanthology.org/2021.acl-long.42.
|
| 300 |
+
Zhilin Yang, Zihang Dai, Yiming Yang, Jaime Carbonell, Russ R Salakhutdinov, and Quoc V Le. Xlnet: Generalized autoregressive pretraining for language understanding. In Advances in neural information processing systems, pp. 5754–5764, 2019.
|
| 301 |
+
Fei Yu, Jiji Tang, Weichong Yin, Yu Sun, Hao Tian, Hua Wu, and Haifeng Wang. Ernie-vil: Knowledge enhanced vision-language representations through scene graphs. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 35, pp. 3208–3216, 2021.
|
| 302 |
+
Pengchuan Zhang, Xiujun Li, Xiaowei Hu, Jianwei Yang, Lei Zhang, Lijuan Wang, Yejin Choi, and Jianfeng Gao. Vinvl: Revisiting visual representations in vision-language models. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), pp. 5579– 5588, June 2021.
|
| 303 |
+
|
| 304 |
+

|
| 305 |
+
Figure 2: Generated examples of SimVLM of various applications: (a) zero-shot image captioning (b) zero-shot cross-modality transfer on German image captioning (c) generative VQA (d) zero-shot visual text completion (e) zero-shot open-ended VQA.
|
| 306 |
+
|
| 307 |
+
# A GENERATED EXAMPLES
|
| 308 |
+
|
| 309 |
+
Examples generated by SimVLM of various types are shown in Figure 2. We use either image-only or image-text prefix inputs in the encoder, and use the decoder to generate suffix text.
|
| 310 |
+
|
| 311 |
+
Table 7: Text-only task performance on the GLUE benchmark (Dev set). Results for BERT and other VLP methods are obtained from Iki & Aizawa (2021). The overall best result is bolded while underline signifies the best VLP model.
|
| 312 |
+
|
| 313 |
+
<table><tr><td></td><td>CoLA</td><td>SST-2</td><td>RTE</td><td>MRPC</td><td>QQP</td><td>MNLI</td><td>QNLI</td><td>WNLI</td></tr><tr><td>BERT</td><td>54.6</td><td>92.5</td><td>62.5</td><td>81.9/87.6</td><td>90.6/87.4</td><td>84.2</td><td>91.0</td><td>48.8</td></tr><tr><td>VisualBERT</td><td>38.6</td><td>89.4</td><td>56.6</td><td>71.9/82.1</td><td>89.4/86.0</td><td>81.6</td><td>87.0</td><td>53.1</td></tr><tr><td>UNITER</td><td>37.4</td><td>89.7</td><td>55.6</td><td>69.3/80.3</td><td>89.2/85.7</td><td>80.9</td><td>86.0</td><td>55.4</td></tr><tr><td>VL-BERT</td><td>38.7</td><td>89.8</td><td>55.7</td><td>70.6/81.8</td><td>89.0/85.4</td><td>81.2</td><td>86.3</td><td>53.1</td></tr><tr><td>VilBERT</td><td>36.1</td><td>90.4</td><td>53.7</td><td>69.0/79.4</td><td>88.6/85.0</td><td>79.9</td><td>83.8</td><td>55.4</td></tr><tr><td>LXMERT</td><td>39.0</td><td>90.2</td><td>57.2</td><td>69.8/80.4</td><td>75.3/75.3</td><td>80.4</td><td>84.2</td><td>46.0</td></tr><tr><td>SimVLMbase</td><td>46.7</td><td>90.9</td><td>63.9</td><td>75.2/84.4</td><td>90.4/87.2</td><td>83.4</td><td>88.6</td><td>58.1</td></tr></table>
|
| 314 |
+
|
| 315 |
+
# B EXPERIMENTAL DETAILS
|
| 316 |
+
|
| 317 |
+
# B.1 PRETRAINING
|
| 318 |
+
|
| 319 |
+
Our models are pretrained according to the methodology described in Section 3. For the Transformer, each variant follows the same setting as its corresponding ViT variant. For the Conv stage, we use the first three blocks (excluding the Conv stem) of ResNet-101 and ResNet-152 (He et al., 2016) for our Base and Large models respectively, and a larger variant of ResNet-152 with more channels for the Huge model (matching its hidden dimension size). We always use a fixed patch size of $1 6 \times 1 6$ . During pretraining, we utilize the resolution of $2 2 4 \times 2 2 4$ , resulting in a patch sequence of length $1 4 \times 1 4$ as visual tokens. For the textual input, we use a vocabulary size of 32,000 and a max sequence length of 256 in both the encoder and the decoder. We also share parameters between the embedding and the decoder softmax output layer (Press & Wolf, 2016). All parameters are shared across visual and textual inputs except the Conv stage and positional embeddings.
|
| 320 |
+
|
| 321 |
+
We pretrain on large-scale web datasets for both image-text and text-only inputs. For joint vision and language data, we exploit the training set of ALIGN (Jia et al., 2021), which contains about 1.8B noisy image-text pairs. Notice that we do not use any extra data preprocessing or filtering, except simple random resized cropping. For the text-only copora, we use the Colossal Clean Crawled Corpus (C4) dataset presented in Raffel et al. (2019) and followed their preprocessing steps. The dataset contains about 800GB of web crawled documents.
|
| 322 |
+
|
| 323 |
+
All models are pretrained for about 1M steps from scratch to optimize for the single PrefixLM objective in Eq.3. We use the AdamW optimizer (Loshchilov & Hutter, 2017) with $\beta _ { 1 } = 0 . 9 , \beta _ { 2 } =$ 0.999 and weight decay of 0.01. We warm up the learning rate for the first $2 \%$ of updates to a peak value of $5 \times 1 0 ^ { - 4 }$ , and then linearly decay it afterwards. Dropout is not used during the pretraining stage. We mix the two pretraining datasets within each batch, which contains 4,096 image-text pairs and 512 text-only documents, sharded across 512 TPU v3 chips (Jouppi et al., 2017).
|
| 324 |
+
|
| 325 |
+
# B.2 FINETUNING
|
| 326 |
+
|
| 327 |
+
After pretraining, our model is finetuned on various downstream tasks. Similar to the pretraining stage, we use the AdamW optimizer with the same Beta values, while we tune the learning rate in $\{ 1 \times 1 0 ^ { - 5 }$ , $2 \times 1 0 ^ { - 5 }$ , $5 \times 1 0 ^ { - 5 } \}$ . We also enable regularization methods of Dropout (set to 0.1) and stochastic depth (only applied to Conv stage and encoder with a fixed dropout rate of 0.1) (Huang et al., 2016) during the finetuning stage. Following standard practice, we use the corresponding dev split to find the best setting and report the result on the test split. We consider 5 types of downstream tasks listed below:
|
| 328 |
+
|
| 329 |
+
Visual question answering: This task requires the model to answer questions about input images, and has been the most widely used VL benchmark. Following prior work, we use the VQA v2 (Goyal et al., 2017) and formulate the task as a classification problem over 3,129 most frequent answers in the training set. The raw image and the corresponding question are used as inputs to the encoder and the decoder respectively, and a task-specific linear classifier is trained to predict answer based on activation corresponding to the last question token from the decoder. We use a resolution of $4 8 0 \times 4 8 0$ for the image and all positional parameters are adapted using linear interpolation.
|
| 330 |
+
|
| 331 |
+
Visual entailment: The SNLI-VE (Xie et al., 2019) dataset is adapted from SNLI (Bowman et al., 2015), which is originally designed to predict the relation between a premise sentence and a hypothesis sentence as either entailment, neutral or contradiction, a task known as natural language inference (NLI). For the VL variant, the premise is based on the content of an image rather than textual descriptions. We finetune SimVLM similarly to VQA, such that the image and the sentence are fed to encoder and decoder separately, and the classifier is trained to predict the three relations.
|
| 332 |
+
|
| 333 |
+
Visual reasoning: The NLVR2 (Suhr et al., 2018) dataset tests the model’s ability of jointly reasoning over the language and multiple images by asking whether a textual description is true based on a pair of two images. Following Zhang et al. (2021), we create two input pairs, each consisting of one image and the textual description, and generate output embeddings for both using the same setup above. The two embeddings are then concatenated for final prediction.
|
| 334 |
+
|
| 335 |
+
Image captioning: The captioning task requires a model to generate natural language descriptions of input images. We consider two datasets CoCo (Chen et al., 2015) and NoCaps (Agrawal et al., 2019), both finetuned using the CoCo training data. For SimVLM, it is straightforward to first encode the image in the encoder and then generate captions using the decoder. Note that in contrast to prior work that apply task-specific tricks such as CIDEr optimization (Rennie et al., 2017), our model is trained with naive cross-entropy loss only.
|
| 336 |
+
|
| 337 |
+
Multimodal translation: The goal of multimodal translation is to translate image descriptions in source language to target language, for which image inputs can be taken advantage of as grounding signal. We train and evaluate on the Multi30k (Elliott et al., 2016) dataset. We utilize the PrefixLM described in previous sections such that the source sentence, together with the image inputs, are fed to the encoder, which will be translated to the target language by the decoder.
|
| 338 |
+
|
| 339 |
+
# C MODEL PERFORMANCE ON LANGUAGE-ONLY TASK
|
| 340 |
+
|
| 341 |
+
We compare our model with prior VLP methods on natural language understanding (NLU) tasks on the GLUE benchmark (Wang et al., 2018) in Table 7.
|
| 342 |
+
|
| 343 |
+
# D ERRATUM
|
| 344 |
+
|
| 345 |
+
We found an error in reporting the zero-shot COCO evaluations in the first version of this paper. This mistake does NOT affect all other results and the numbers have been updated. Meanwhile, we also added few-shot results in addition to zero-shot results on both MsCOCO and NoCaps in Table 2, to provide a more comprehensive view of capacities in SimVLM models. Hence, our main claims and conclusions still hold.
|
md/dev/HPuSIXJaa9/HPuSIXJaa9.md
ADDED
|
@@ -0,0 +1,292 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Direct Preference Optimization: Your Language Model is Secretly a Reward Model
|
| 2 |
+
|
| 3 |
+
Rafael Rafailov⇤† Archit Sharma⇤† Eric Mitchell⇤†
|
| 4 |
+
|
| 5 |
+
Stefano Ermon†‡ Christopher D. Manning† Chelsea Finn†
|
| 6 |
+
|
| 7 |
+
† Stanford University $^ { \ddagger } { \bf C } { \bf Z }$ Biohub {rafailov,architsh,eric.mitchell}@cs.stanford.edu
|
| 8 |
+
|
| 9 |
+
# Abstract
|
| 10 |
+
|
| 11 |
+
While large-scale unsupervised language models (LMs) learn broad world knowledge and some reasoning skills, achieving precise control of their behavior is difficult due to the completely unsupervised nature of their training. Existing methods for gaining such steerability collect human labels of the relative quality of model generations and fine-tune the unsupervised LM to align with these preferences, often with reinforcement learning from human feedback (RLHF). However, RLHF is a complex and often unstable procedure, first fitting a reward model that reflects the human preferences, and then fine-tuning the large unsupervised LM using reinforcement learning to maximize this estimated reward without drifting too far from the original model. In this paper, we leverage a mapping between reward functions and optimal policies to show that this constrained reward maximization problem can be optimized exactly with a single stage of policy training, essentially solving a classification problem on the human preference data. The resulting algorithm, which we call Direct Preference Optimization (DPO), is stable, performant, and computationally lightweight, eliminating the need for fitting a reward model, sampling from the LM during fine-tuning, or performing significant hyperparameter tuning. Our experiments show that DPO can fine-tune LMs to align with human preferences as well as or better than existing methods. Notably, fine-tuning with DPO exceeds RLHF’s ability to control sentiment of generations and improves response quality in summarization and single-turn dialogue while being substantially simpler to implement and train.
|
| 12 |
+
|
| 13 |
+
# 1 Introduction
|
| 14 |
+
|
| 15 |
+
Large unsupervised language models (LMs) trained on very large datasets acquire surprising capabilities $[ \overline { { 1 1 } } , \overline { { 7 } } , \dot { \overline { { 4 0 } } } , \overline { { 8 } } ]$ . However, these models are trained on data generated by humans with a wide variety of goals, priorities, and skillsets. Some of these goals and skillsets may not be desirable to imitate; for example, while we may want our AI coding assistant to understand common programming mistakes in order to correct them, nevertheless, when generating code, we would like to bias our model toward the (potentially rare) high-quality coding ability present in its training data. Similarly, we might want our language model to be aware of a common misconception believed by $50 \%$ of people, but we certainly do not want the model to claim this misconception to be true in $50 \%$ of queries about it! In other words, selecting the model’s desired responses and behavior from its very wide knowledge and abilities is crucial to building AI systems that are safe, performant, and controllable $[ \overline { { 2 6 } } ]$ . While existing methods typically steer LMs to match human preferences using reinforcement learning (RL), we will show that the RL-based objective used by existing methods can be optimized exactly with a simple binary cross-entropy objective, greatly simplifying the preference learning pipeline.
|
| 16 |
+
|
| 17 |
+

|
| 18 |
+
Figure 1: DPO optimizes for human preferences while avoiding reinforcement learning. Existing methods for fine-tuning language models with human feedback first fit a reward model to a dataset of prompts and human preferences over pairs of responses, and then use RL to find a policy that maximizes the learned reward. In contrast, DPO directly optimizes for the policy best satisfying the preferences with a simple classification objective, without an explicit reward function or RL.
|
| 19 |
+
|
| 20 |
+
At a high level, existing methods instill the desired behaviors into a language model using curated sets of human preferences representing the types of behaviors that humans find safe and helpful. This preference learning stage occurs after an initial stage of large-scale unsupervised pre-training on a large text dataset. While the most straightforward approach to preference learning is supervised fine-tuning on human demonstrations of high quality responses, the most successful class of methods is reinforcement learning from human (or AI) feedback (RLHF/RLAIF; [12, 2]). RLHF methods fit a reward model to a dataset of human preferences and then use RL to optimize a language model policy to produce responses assigned high reward without drifting excessively far from the original model. While RLHF produces models with impressive conversational and coding abilities, the RLHF pipeline is considerably more complex than supervised learning, involving training multiple LMs and sampling from the LM policy in the loop of training, incurring significant computational costs.
|
| 21 |
+
|
| 22 |
+
In this paper, we show how to directly optimize a language model to adhere to human preferences, without explicit reward modeling or reinforcement learning. We propose Direct Preference Optimization $( D P O )$ , an algorithm that implicitly optimizes the same objective as existing RLHF algorithms (reward maximization with a KL-divergence constraint) but is simple to implement and straightforward to train. Intuitively, the DPO update increases the relative log probability of preferred to dispreferred responses, but it incorporates a dynamic, per-example importance weight that prevents the model degeneration that we find occurs with a naive probability ratio objective. Like existing algorithms, DPO relies on a theoretical preference model (such as the Bradley-Terry model; [5]) that measures how well a given reward function aligns with empirical preference data. However, while existing methods use the preference model to define a preference loss to train a reward model and then train a policy that optimizes the learned reward model, DPO uses a change of variables to define the preference loss as a function of the policy directly. Given a dataset of human preferences over model responses, DPO can therefore optimize a policy using a simple binary cross entropy objective, without explicitly learning a reward function or sampling from the policy during training.
|
| 23 |
+
|
| 24 |
+
Our main contribution is Direct Preference Optimization (DPO), a simple RL-free algorithm for training language models from preferences. Our experiments show that DPO is at least as effective as existing methods, including PPO-based RLHF, for learning from preferences in tasks such as sentiment modulation, summarization, and dialogue, using language models with up to 6B parameters.
|
| 25 |
+
|
| 26 |
+
# 2 Related Work
|
| 27 |
+
|
| 28 |
+
Self-supervised language models of increasing scale learn to complete some tasks zero-shot $\pmb { \mathbb { B } } \mathbf { \mathbb { 1 } }$ or with few-shot prompts [6, 25, 11]. However, their performance on downstream tasks and alignment with user intent can be significantly improved by fine-tuning on datasets of instructions and humanwritten completions $\textcircled { 1 2 3 } , \textcircled { 3 6 } , \textcircled { 1 3 } , \textcircled { 3 9 } $ . This ‘instruction-tuning’ procedure enables LLMs to generalize to instructions outside of the instruction-tuning set and generally increase their usability $\pmb { \mathbb { I } } \bar { \lambda } \mathbf { \mathbb { I } }$ . Despite the success of instruction tuning, relative human judgments of response quality are often easier to collect than expert demonstrations, and thus subsequent works have fine-tuned LLMs with datasets of human preferences, improving proficiency in translation $\boxed { 1 1 8 }$ , summarization $\pm \boxed { 1 3 8 } \boxed { 4 8 } \parallel$ , story-telling $[ | \overline { { 4 8 } } | |$ , and instruction-following $\pm \infty , \pm 2 \mathrm { J }$ . These methods first optimize a neural network reward function for compatibility with the dataset of preferences under a preference model such as the
|
| 29 |
+
|
| 30 |
+
Bradley-Terry model $\pmb { \Vert 5 \Vert }$ , then fine-tune a language model to maximize the given reward using reinforcement learning algorithms, commonly REINFORCE $\pm \sharp$ , proximal policy optimization (PPO; $\pmb { \mathbb { B } } \mathbf { \widetilde { Z } } \mathbf { I } \mathbf { I } ,$ ), or variants $\pmb { \mathbb { B 2 } }$ . A closely-related line of work leverages LLMs fine-tuned for instruction following with human feedback to generate additional synthetic preference data for targeted attributes such as safety or harmlessness $[ \bar { | 2 | }$ , using only weak supervision from humans in the form of a text rubric for the LLM’s annotations. These methods represent a convergence of two bodies of work: one body of work on training language models with reinforcement learning for a variety of objectives $[ \sqrt { 3 3 } , \sqrt { 2 7 } , \sqrt { 4 5 } ]$ and another body of work on general methods for learning from human preferences $\boxed { 1 2 } \boxed { 1 9 }$ Despite the appeal of using relative human preferences, fine-tuning large language models with reinforcement learning remains a major practical challenge; this work provides a theoretically-justified approach to optimizing relative preferences without RL.
|
| 31 |
+
|
| 32 |
+
Outside of the context of language, learning policies from preferences has been studied in both bandit and reinforcement learning settings, and several approaches have been proposed. Contextual bandit learning using preferences or rankings of actions, rather than rewards, is known as a contextual dueling bandit (CDB; [47, 14]). In the absence of absolute rewards, theoretical analysis of CDBs substitutes the notion of an optimal policy with a von Neumann winner, a policy whose expected win rate against any other policy is at least $50 \%$ [14]. However, in the CDB setting, preference labels are given online, while in learning from human preferences, we typically learn from a fixed batch of offline preference-annotated action pairs $\left[ \left[ 4 6 \right] \right]$ . Similarly, preference-based RL (PbRL) learns from binary preferences generated by an unknown ‘scoring’ function rather than rewards [9, 35]. Various algorithms for PbRL exist, including methods that can reuse off-policy preference data, but generally involve first explicitly estimating the latent scoring function (i.e. the reward model) and subsequently optimizing it [16, 9, 12, 34, 19]. We instead present a single stage policy learning approach that directly optimizes a policy to satisfy preferences.
|
| 33 |
+
|
| 34 |
+
# 3 Preliminaries
|
| 35 |
+
|
| 36 |
+
We review the RLHF pipeline in Ziegler et al. (and later $[ 3 8 , 1 , 2 6 ]$ ). It usually includes three phases: 1) supervised fine-tuning (SFT); 2) preference sampling and reward learning and 3) RL optimization.
|
| 37 |
+
|
| 38 |
+
SFT: RLHF typically begins by fine-tuning a pre-trained LM with supervised learning on high-quality data for the downstream task(s) of interest (dialogue, summarization, etc.), to obtain a model $\textstyle { \bar { \pi } } ^ { \operatorname { S F T } }$ .
|
| 39 |
+
|
| 40 |
+
Reward Modelling Phase: In the second phase the SFT model is prompted with prompts $x$ to produce pairs of answers $( y _ { 1 } , y _ { 2 } ) \sim \pi ^ { \mathrm { { S F T } } } ( y \mid x )$ . These are then presented to human labelers who express preferences for one answer, denoted as $y _ { w } \ \succ \ y _ { l } \ | \ x$ where $y _ { w }$ and $y _ { l }$ denotes the preferred and dispreferred completion amongst $( y _ { 1 } , y _ { 2 } )$ respectively. The preferences are assumed to be generated by some latent reward model $r ^ { \ast } ( y , x )$ , which we do not have access to. There are a number of approaches used to model preferences, the Bradley-Terry (BT) $ { \mathbb { I } }$ model being a popular choice (although more general Plackett-Luce ranking models $\textcircled { 1 3 0 } , \textcircled { 2 1 }$ are also compatible with the framework if we have access to several ranked answers). The BT model stipulates that the human preference distribution $p ^ { * }$ can be written as:
|
| 41 |
+
|
| 42 |
+
$$
|
| 43 |
+
p ^ { * } ( y _ { 1 } \succ y _ { 2 } \mid x ) = \frac { \exp { ( r ^ { * } ( x , y _ { 1 } ) ) } } { \exp { ( r ^ { * } ( x , y _ { 1 } ) ) } + \exp { ( r ^ { * } ( x , y _ { 2 } ) ) } } .
|
| 44 |
+
$$
|
| 45 |
+
|
| 46 |
+
Assuming access to a static dataset of comparisons $\mathcal { D } = \left\{ x ^ { ( i ) } , y _ { w } ^ { ( i ) } , y _ { l } ^ { ( i ) } \right\} _ { i = 1 } ^ { N }$ sampled from $p ^ { * }$ , we can parametrize a reward model and estimate the parameters via maximum likelihood. Framing the problem as a binary classification we have the negative log-likelihood loss:
|
| 47 |
+
|
| 48 |
+
$$
|
| 49 |
+
\mathcal { L } _ { R } ( r _ { \phi } , \mathcal { D } ) = - \mathbb { E } _ { ( x , y _ { w } , y _ { l } ) \sim \mathcal { D } } \left[ \log \sigma ( r _ { \phi } ( x , y _ { w } ) - r _ { \phi } ( x , y _ { l } ) ) \right]
|
| 50 |
+
$$
|
| 51 |
+
|
| 52 |
+
where $\sigma$ is the logistic function. In the context of LMs, the network $r _ { \phi } ( x , y )$ is often initialized from the SFT model $\pi ^ { \mathrm { S F T } } ( y \mid x )$ with the addition of a linear layer on top of the final transformer layer that produces a single scalar prediction for the reward value $\lVert \overline { { 4 8 } } \rVert$ . To ensure a reward function with lower variance, prior works normalize the rewards, such that $\mathbb { E } _ { x , y \sim \mathcal { D } } \left[ r _ { \phi } ( x , y ) \right] = 0$ for all $x$ .
|
| 53 |
+
|
| 54 |
+
RL Fine-Tuning Phase: During the RL phase, we use the learned reward function to provide feedback to the language model. In particular, we formulate the following optimization problem
|
| 55 |
+
|
| 56 |
+
$$
|
| 57 |
+
\displaystyle \operatorname* { m a x } _ { \pi _ { \theta } } \mathbb { E } _ { x \sim \mathcal { D } , y \sim \pi _ { \theta } ( y \mid x ) } \big [ r _ { \phi } ( x , y ) \big ] - \beta \mathbb { D } _ { \mathrm { K L } } \big [ \pi _ { \theta } ( y \mid x ) \mid \mid \pi _ { \mathrm { r e f } } ( y \mid x ) \big ]
|
| 58 |
+
$$
|
| 59 |
+
|
| 60 |
+
where $\beta$ is a parameter controlling the deviation from the base reference policy $\pi _ { \mathrm { r e f } }$ , namely the initial SFT model $\pi ^ { \mathrm { S F T } }$ . In practice, the language model policy $\pi _ { \theta }$ is also initialized to $\pi ^ { \mathrm { { \dot { S } F T } } }$ . The added constraint is important, as it prevents the model from deviating too far from the distribution on which the reward model is accurate, as well as maintaining the generation diversity and preventing mode-collapse to single high-reward answers. Due to the discrete nature of language generation, this objective is not differentiable and is typically optimized with reinforcement learning. The standard approach $\lVert 8 \rVert , \bigotimes , \textcircled { 1 } , \bigotimes$ has been to construct the reward function $r ( x , y ) = r _ { \phi } ( x , y ) - \beta ( \log \pi _ { \theta } ( y \mid x ) - \log \pi _ { \mathrm { r e f } } ( y \mid x ) )$ , and maximize using PPO $ { \mathbb { I } } ^ { \smash { \sum } }$ .
|
| 61 |
+
|
| 62 |
+
# 4 Direct Preference Optimization
|
| 63 |
+
|
| 64 |
+
Motivated by the challenges of applying reinforcement learning algorithms on large-scale problems such as fine-tuning language models, our goal is to derive a simple approach for policy optimization using preferences directly. Unlike prior RLHF methods, which learn a reward and then optimize it via RL, our approach bypasses the reward modeling step and directly optimizes a language model using preference data. As we will describe next in detail, our key insight is to leverage an analytical mapping from reward functions to optimal policies, which enables us to transform a loss function over reward functions into a loss function over policies. This change-of-variables approach allows us to skip the explicit reward modeling step, while still optimizing under existing models of human preferences, such as the Bradley-Terry model. In essence, the policy network represents both the language model and the reward.
|
| 65 |
+
|
| 66 |
+
Deriving the DPO objective. We start with the same RL objective as prior work, Eq. $3 ,$ under a general reward function $r$ . Following prior work $\pmb { \bigtriangledown } \bigtriangledown \bigtriangledown \bigtriangledown \sqrt { \pmb { \bigtriangledown } \mathbf { \bigtriangledown } } \bigtriangledown \vec { \bigtriangledown } \bigtriangledown \vec { \bigtriangledown }$ , it is straightforward to show that the optimal solution to the KL-constrained reward maximization objective in Eq. $\bigtriangledown$ takes the form:
|
| 67 |
+
|
| 68 |
+
$$
|
| 69 |
+
\pi _ { r } ( y \mid x ) = \frac { 1 } { Z ( x ) } \pi _ { \mathrm { r e f } } ( y \mid x ) \exp \left( \frac { 1 } { \beta } r ( x , y ) \right) ,
|
| 70 |
+
$$
|
| 71 |
+
|
| 72 |
+
where $\begin{array} { r } { Z ( x ) = \sum _ { y } \pi _ { \mathrm { r e f } } ( y \mid x ) \exp \left( \frac { 1 } { \beta } r ( x , y ) \right) } \end{array}$ is the partition function. See Appendix A.1 for a complete derivation. Even if we use the MLE estimate $r _ { \phi }$ of the ground-truth reward function $r ^ { * }$ , it is still expensive to estimate the partition function $Z ( x )$ [17, 15], which makes this representation hard to utilize in practice. However, we can rearrange Eq. 4 to express the reward function in terms of its corresponding optimal policy $\pi _ { r }$ , the reference policy $\pi _ { \mathrm { r e f } }$ , and the unknown partition function $Z ( \cdot )$ . Specifically, we first take the logarithm of both sides of Eq. $^ 4$ and then with some algebra we obtain:
|
| 73 |
+
|
| 74 |
+
$$
|
| 75 |
+
r ( x , y ) = \beta \log \frac { \pi _ { r } ( y \mid x ) } { \pi _ { \mathrm { r e f } } ( y \mid x ) } + \beta \log Z ( x ) .
|
| 76 |
+
$$
|
| 77 |
+
|
| 78 |
+
We can apply this reparameterization to the ground-truth reward $r ^ { * }$ and corresponding optimal model $\pi ^ { * }$ . Fortunately, the Bradley-Terry model depends only on the difference of rewards between two completions, i.e., $p ^ { * } ( y _ { 1 } \succ \dot { y } _ { 2 } \mid x ) \dot { = } \sigma ( r ^ { * } ( x , \mathbf { \bar { y } } _ { 1 } ) - r ^ { * } ( x , y _ { 2 } ) )$ . Substituting the reparameterization in Eq. $5$ for $r ^ { * } ( x , y )$ into the preference model Eq. $\bigstar$ the partition function cancels, and we can express the human preference probability in terms of only the optimal policy $\pi ^ { * }$ and reference policy $\pi _ { \mathrm { r e f } }$ . Thus, the optimal RLHF policy $\pi ^ { * }$ under the Bradley-Terry model satisfies the preference model:
|
| 79 |
+
|
| 80 |
+
$$
|
| 81 |
+
p ^ { * } ( y _ { 1 } \succ y _ { 2 } \mid x ) = { \frac { 1 } { 1 + \exp \left( \beta \log { \frac { \pi ^ { * } ( y _ { 2 } | x ) } { \pi _ { \mathrm { r e f } } ( y _ { 2 } | x ) } } - \beta \log { \frac { \pi ^ { * } ( y _ { 1 } | x ) } { \pi _ { \mathrm { r e f } } ( y _ { 1 } | x ) } } \right) } }
|
| 82 |
+
$$
|
| 83 |
+
|
| 84 |
+
The derivation is in Appendix $\boxed { \mathbf { A . 2 } }$ While Eq. $\textcircled { 6 }$ uses the Bradley-Terry model, we can similarly derive expressions under the more general Plackett-Luce models $\dot { [ 3 0 ] } , \dot { [ 2 1 ] } \dot { ] }$ , shown in Appendix A.3.
|
| 85 |
+
|
| 86 |
+
Now that we have the probability of human preference data in terms of the optimal policy rather than the reward model, we can formulate a maximum likelihood objective for a parametrized policy $\pi _ { \theta }$ . Analogous to the reward modeling approach (i.e. Eq. 2), our policy objective becomes:
|
| 87 |
+
|
| 88 |
+
$$
|
| 89 |
+
\begin{array} { r } { \mathcal { L } _ { \mathrm { D P O } } ( \pi _ { \theta } ; \pi _ { \mathrm { r e f } } ) = - \mathbb { E } _ { ( x , y _ { w } , y _ { l } ) \sim \mathcal { D } } \left[ \log \sigma \left( \beta \log \frac { \pi _ { \theta } ( y _ { w } \mid x ) } { \pi _ { \mathrm { r e f } } ( y _ { w } \mid x ) } - \beta \log \frac { \pi _ { \theta } ( y _ { l } \mid x ) } { \pi _ { \mathrm { r e f } } ( y _ { l } \mid x ) } \right) \right] . } \end{array}
|
| 90 |
+
$$
|
| 91 |
+
|
| 92 |
+
This way, we simultaneously bypass the explicit reward modeling step while also avoiding the need to perform reinforcement learning optimization. Moreover, since our procedure is equivalent to fitting
|
| 93 |
+
|
| 94 |
+
a reparametrized Bradley-Terry model, it enjoys certain theoretical properties, such as consistencies under suitable assumption of the preference data distribution $\mathbb { \lVert \rVert }$ . In Section $5 ,$ we further discuss theoretical properties of DPO in relation to other works.
|
| 95 |
+
|
| 96 |
+
What does the DPO update do? For a mechanistic understanding of DPO, it is useful to analyze the gradient of the loss function $\mathcal { L } _ { \mathrm { D P O } }$ . The gradient with respect to the parameters $\theta$ can be written as:
|
| 97 |
+
|
| 98 |
+
$$
|
| 99 |
+
\begin{array} { r l } & { \nabla _ { \theta } \mathcal { L } _ { \mathrm { D P O } } ( \pi _ { \theta } ; \pi _ { \mathrm { r e f } } ) = } \\ & { - \beta \mathbb { E } _ { ( x , y _ { w } , y _ { l } ) \sim \mathcal { D } } \bigg [ \underbrace { \sigma \big ( \hat { r } _ { \theta } ( x , y _ { l } ) - \hat { r } _ { \theta } ( x , y _ { w } ) \big ) } _ { \mathrm { h i g h e r w e i g h t w e n e n t ~ e x i m a t e ~ i s ~ w r o n g } } \bigg [ \underbrace { \nabla _ { \theta } \log \pi ( y _ { w } \mid x ) } _ { \mathrm { i n c r e a s c ~ i h k e l i h o o d ~ o f } y _ { w } } - \underbrace { \nabla _ { \theta } \log \pi ( y _ { l } \mid x ) } _ { \mathrm { d e c r e a s e ~ l i k e l i h o o d ~ o f } y _ { l } } \bigg ] \bigg ] , } \end{array}
|
| 100 |
+
$$
|
| 101 |
+
|
| 102 |
+
where $\begin{array} { r } { \hat { r } _ { \theta } ( x , y ) = \beta \log \frac { \pi _ { \theta } ( y | x ) } { \pi _ { \mathrm { r e f } } ( y | x ) } } \end{array}$ is the reward implicitly defined by the language model $\pi _ { \theta }$ and reference model $\pi _ { \mathrm { r e f } }$ (more in Section $\textcircled { 5 }$ . Intuitively, the gradient of the loss function $\mathcal { L } _ { \mathrm { D P O } }$ increases the likelihood of the preferred completions $y _ { w }$ and decreases the likelihood of dispreferred completions $y _ { l }$ . Importantly, the examples are weighed by how much higher the implicit reward model ${ \hat { r } } _ { \theta }$ rates the dispreferred completions, scaled by $\beta$ , i.e, how incorrectly the implicit reward model orders the completions, accounting for the strength of the KL constraint. Our experiments suggest the importance of this weighting, as a naïve version of this method without the weighting coefficient can cause the language model to degenerate (Appendix Table $3 )$
|
| 103 |
+
|
| 104 |
+
DPO outline. The general DPO pipeline is as follows: 1) Sample completions $y _ { 1 } , y _ { 2 } \sim \pi _ { \mathrm { r e f } } ( \cdot \mid x )$ for every prompt $x$ , label with human preferences to construct the offline dataset of preferences $\mathcal { D } = \{ \boldsymbol { x } ^ { ( i ) } , \boldsymbol { y } _ { w } ^ { ( i ) } , \boldsymbol { y } _ { l } ) ^ { ( i ) } \} _ { i = 1 } ^ { N }$ and 2) optimize the language model $\pi _ { \theta }$ to minimize $\mathcal { L } _ { \mathrm { D P O } }$ for the given $\pi _ { \mathrm { r e f } }$ and $\mathcal { D }$ and desired $\beta$ . In practice, one would like to reuse preference datasets publicly available, rather than generating samples and gathering human preferences. Since the preference datasets are sampled using $\pi ^ { \mathrm { { \scriptsize \ s F T } } }$ , we initialize $\pi _ { \mathrm { r e f } } \ = \ \pi ^ { \mathrm { S F T } }$ whenever available. However, when $\pi ^ { \mathrm { S F T } }$ is not available, we initialize $\pi _ { \mathrm { r e f } }$ by maximizing likelihood of preferred completions $( x , y _ { w } )$ , that is, $\begin{array} { r } { \pi _ { \mathrm { r e f } } = \arg \operatorname* { m a x } _ { \pi } \mathbb { E } _ { x , y _ { w } \sim \mathcal { D } } \left[ \log \pi ( y _ { w } \mid x ) \right] } \end{array}$ . This procedure helps mitigate the distribution shift between the true reference distribution which is unavailable, and $\pi _ { \mathrm { r e f } }$ used by DPO. Further details related to the implementation and hyperparameters can be found in Appendix B.
|
| 105 |
+
|
| 106 |
+
# 5 Theoretical Analysis of DPO
|
| 107 |
+
|
| 108 |
+
In this section, we give further interpretation of the DPO method, provide theoretical backing, and relate advantages of DPO to issues with actor critic algorithms used for RLHF (such as PPO $[ \bar { \big | } 3 7 ] \big { \big | }$ ).
|
| 109 |
+
|
| 110 |
+
# 5.1 Your Language Model Is Secretly a Reward Model
|
| 111 |
+
|
| 112 |
+
DPO is able to bypass both explicit reward estimation and RL to learn the policy using a single maximum likelihood objective. However, the optimization objective Eq. $\boxed { 5 }$ is equivalent to a BradleyTerry model with a reward function $\begin{array} { r } { r ^ { * } ( x , y ) = \beta \log \frac { \pi _ { \theta } ^ { * } ( y | x ) } { \pi _ { \mathrm { r e f } } ( y | x ) } } \end{array}$ and we optimize our parametric model $\pi _ { \theta }$ , equivalently to the reward model optimization in Eq. 2 under the this change of variables. In this section we will build the theory behind this reparameterization, show that it does not constrain the class of learned reward models, and allows for the exact recovery of the optimal policy. We begin with by defining an equivalence relation between reward functions.
|
| 113 |
+
|
| 114 |
+
Definition 1. We say that two reward functions $r ( x , y )$ and $r ^ { \prime } ( x , y )$ are equivalent iff $r ( x , y ) - r ^ { \prime } ( x , y ) = f ( x )$ for some function $f$ .
|
| 115 |
+
|
| 116 |
+
It is easy to see that this is indeed an equivalence relation, which partitions the set of reward functions into classes. We can state the following two lemmas:
|
| 117 |
+
|
| 118 |
+
Lemma 1. Under the Plackett-Luce, and in particular the Bradley-Terry, preference framework, two reward functions from the same class induce the same preference distribution.
|
| 119 |
+
|
| 120 |
+
Lemma 2. Two reward functions from the same equivalence class induce the same optimal policy under the constrained RL problem.
|
| 121 |
+
|
| 122 |
+
The proofs are straightforward and we defer them to Appendix A.5. The first lemma is a well-known under-specification issue with the Plackett-Luce family of models $\pmb { \mathbb { B } } \mathbf { 0 } \|$ . Due to this under-specification, we usually have to impose additional identifiability constraints to achieve any guarantees on the MLE estimates from Eq. $\dot { \bigstar } \dot { \bigstar } \dot { \bigstar }$ . The second lemma states that all reward functions from the same class yield the same optimal policy, hence for our final objective, we are only interested in recovering an arbitrary reward function from the optimal class. We prove the following Theorem in Appendix ${ \bf { \bar { A } } } . 6 \colon$
|
| 123 |
+
|
| 124 |
+
Theorem 1. Under mild assumptions, all reward classes consistent with the Plackett-Luce (and Bradley-Terry in particular) models can be represented with the reparameterization $\begin{array} { r } { r ( x , y ) = \beta \log \frac { \pi ( y | x ) } { \pi _ { r e f } ( y | x ) } } \end{array}$ for some model $\pi ( y \mid x )$ and a given reference model $\pi _ { r e f } ( y \mid x )$ .
|
| 125 |
+
|
| 126 |
+
Proof Sketch. Consider any reward function $r ( x , y )$ , which induces a corresponding optimal model $\pi _ { r } ( y \mid x )$ , specified by Eq. $\boxed { \ 4 }$ We will show that a reward function from the equivalence class of $r$ can be represented using the reparameterization given above. We define the projection $f$ as
|
| 127 |
+
|
| 128 |
+
$$
|
| 129 |
+
f ( r ; \pi _ { \mathrm { r e f } } , \beta ) ( x , y ) = r ( x , y ) - \beta \log \sum _ { y } \pi _ { \mathrm { r e f } } ( y \mid x ) \exp \left( { \frac { 1 } { \beta } } r ( x , y ) \right)
|
| 130 |
+
$$
|
| 131 |
+
|
| 132 |
+
The operator $f$ simply normalizes the reward function with the logarithm of the partition function of $\pi _ { r }$ . Since the added normalization term is only a function of the prefix $x$ , $f ( r ; \pi _ { \mathrm { r e f } } , \beta ) ( \underline { { x } } , y )$ is a reward function in the equivalence class of $r ( x , y )$ . Finally, replacing $r$ with the RHS of Eq. 5 (which holds for any reward function), we have $\begin{array} { r } { f ( r ; \pi _ { \mathrm { r e f } } , \beta ) ( x , y ) = \beta \log \frac { \pi _ { r } ( y | x ) } { \pi _ { \mathrm { r e f } } ( y | x ) } } \end{array}$ . That is, the projection $f$ produces a member of the equivalence class of $r$ with the desired form, and we do not lose any generality in our reward model from the proposed reparameterization. □
|
| 133 |
+
|
| 134 |
+
We can alternatively view Theorem $^ 1$ as specifying exactly which reward function within each equivalence class the DPO reparameterization selects, that is, the reward function satisfying:
|
| 135 |
+
|
| 136 |
+
$$
|
| 137 |
+
\sum _ { y } \underbrace { \pi _ { \mathrm { r e f } } ( y \mid x ) \exp \left( { \frac { 1 } { \beta } } r ( x , y ) \right) } _ { = \pi ( y \mid x ) , \mathrm { u s i n g T h m . } \mathrm { [ l ] r e p a r a m . } } = 1 ,
|
| 138 |
+
$$
|
| 139 |
+
|
| 140 |
+
i.e., $\pi ( y \mid x )$ is a valid distribution (probabilities are positive and sum to 1). However, following Eq. $^ { 4 , }$ we can see that Eq. $9$ is the partition function of the optimal policy induced by the reward function $r ( x , y )$ . The key insight of the DPO algorithm is that we can impose certain constraints on the under-constrained Plackett-Luce (and Bradley-Terry in particular) family of preference models, such that we preserve the class of representable reward models, but explicitly make the optimal policy in Eq. 4 analytically tractable for all prompts $x$ .
|
| 141 |
+
|
| 142 |
+
# 5.2 Instability of Actor-Critic Algorithms
|
| 143 |
+
|
| 144 |
+
We can also use our framework to diagnose instabilities with standard actor-critic algorithms used for the RLHF, such as PPO. We follow the RLHF pipeline and focus on the RL fine-tuning step outlined in Section $\textcircled{3}$ We can draw connections to the control as inference framework $\mathbb { \left| \left[ 2 0 \right] \right| }$ for the constrained RL problem outlined in $3 .$ We assume a parameterized model $\pi _ { \theta } ( y \mid x )$ and minimize $\mathbb { D } _ { \mathrm { K L } } [ \pi _ { \theta } ( y | x ) \mid \mid \pi ^ { * } ( y \mid x ) ]$ where $\pi ^ { * }$ is the optimal policy from Eq. $\perp$ induced by the reward function $r _ { \phi } ( y , x )$ . With some algebra this leads to the optimization objective:
|
| 145 |
+
|
| 146 |
+
$$
|
| 147 |
+
\underbrace { \operatorname* { m a x } \mathbb { E } _ { \pi _ { \theta } ( y | x ) } \bigg [ r _ { \phi } ( x , y ) - \beta \log \sum _ { y } \pi _ { \mathrm { r e f } } \exp \left( \frac { 1 } { \beta } r _ { \phi } ( x , y ) \right) } _ { f ( r _ { \phi } , \pi _ { \mathrm { r e f } } , \beta ) } - \underbrace { \beta \log \frac { \pi _ { \theta } ( y \mid x ) } { \pi _ { \mathrm { r e f } } ( y \mid x ) } } _ { \kappa \mathrm { L } } \bigg ]
|
| 148 |
+
$$
|
| 149 |
+
|
| 150 |
+
This is the same objective optimized in prior works [48, 38, 1, 26] using the DPO-equivalent reward for the reward class of $r _ { \phi }$ . In this setting, we can interpret the normalization term in $f ( r _ { \phi } , \pi _ { \mathrm { r e f } } , \beta )$ as the soft value function of the reference policy $\pi _ { \mathrm { r e f } }$ . While this term does not affect the optimal solution, without it, the policy gradient of the objective could have high variance, making learning unstable. We can accommodate for the normalization term using a learned value function, but that can also be difficult to optimize. Alternatively, prior works have normalized rewards using a human completion baseline, essentially a single sample Monte-Carlo estimate of the normalizing term. In contrast the DPO reparameterization yields a reward function that does not require any baselines.
|
| 151 |
+
|
| 152 |
+

|
| 153 |
+
Figure 2: Left. The frontier of expected reward vs KL to the reference policy. DPO provides the highest expected reward for all KL values, demonstrating the quality of the optimization. Right. TL;DR summarization win rates vs. human-written summaries, using GPT-4 as evaluator. DPO exceeds PPO’s best-case performance on summarization, while being more robust to changes in the sampling temperature.
|
| 154 |
+
|
| 155 |
+
# 6 Experiments
|
| 156 |
+
|
| 157 |
+
In this section, we empirically evaluate DPO’s ability to train policies directly from preferences. First, in a well-controlled text-generation setting, we ask: how efficiently does DPO trade off maximizing reward and minimizing KL-divergence with the reference policy, compared to common preference learning algorithms such as PPO? Next, we evaluate DPO’s performance on larger models and more difficult RLHF tasks, including summarization and dialogue. We find that with almost no tuning of hyperparameters, DPO tends to perform as well or better than strong baselines like RLHF with PPO as well as returning the best of $N$ sampled trajectories under a learned reward function. Before presenting these results, we describe the experimental set-up; additional details are in Appendix $\boxed { \mathrm { C } }$
|
| 158 |
+
|
| 159 |
+
Tasks. Our experiments explore three different open-ended text generation tasks. For all experiments, algorithms learn a policy from a dataset of preferences $\mathcal { D } = \overline { { \{ x ^ { ( i ) } , y _ { w } ^ { ( i ) } , y _ { l } ^ { ( i ) } \} } } _ { i = 1 } ^ { N }$ In controlled sentiment generation, $x$ is a prefix of a movie review from the IMDb dataset $[ [ 2 2 ] ]$ , and the policy must generate $y$ with positive sentiment. In order to perform a controlled evaluation, for this experiment we generate preference pairs over generations using a pre-trained sentiment classifier, where $p ( { \mathrm { p o s i t i v e } } \mid x , y _ { w } ) > p ( { \mathrm { p o s i t i v e } } \mid x , y _ { l } )$ . For SFT, we fine-tune GPT-2-large until convergence on reviews from the train split of the IMDB dataset (further details in $\mathrm { \bf A p p C . 1 ) }$ . In summarization, $x$ is a forum post from Reddit; the policy must generate a summary $y$ of the main points in the post. Following prior work, we use the Reddit TL;DR summarization dataset $\mathbb { H }$ along with human preferences gathered by Stiennon et al.. We use an SFT model fine-tuned on human-written forum post summaries2 with the TRLX [42] framework for RLHF. The human preference dataset was gathered by Stiennon et al. on samples from a different, but similarly-trained, SFT model. Finally, in single-turn dialogue, $x$ is a human query, which may be anything from a question about astrophysics to a request for relationship advice. A policy must produce an engaging and helpful response $y$ to a user’s query; we use the Anthropic Helpful and Harmless dialogue dataset $\mathbb { M }$ , containing 170k dialogues between a human and an automated assistant. Each transcript ends with a pair of responses generated by a large (although unknown) language model along with a preference label denoting the human-preferred response. In this setting, no pre-trained SFT model is available; we therefore fine-tune an off-the-shelf language model on only the preferred completions to form the SFT model.
|
| 160 |
+
|
| 161 |
+
Evaluation. Our experiments use two different approaches to evaluation. In order to analyze the effectiveness of each algorithm in optimizing the constrained reward maximization objective, in the controlled sentiment generation setting we evaluate each algorithm by its frontier of achieved reward and KL-divergence from the reference policy; this frontier is computable because we have acccess to the ground-truth reward function (a sentiment classifier). However, in the real world, the ground truth reward function is not known; therefore, we evaluate algorithms with their win rate against a baseline policy, using GPT-4 as a proxy for human evaluation of summary quality and response helpfulness in the summarization and single-turn dialogue settings, respectively. For summarization, we use reference summaries in the test set as the baseline; for dialogue, we use the preferred response in the test dataset as the baseline. While existing studies suggest LMs can be better automated evaluators than existing metrics $\mathbb { m }$ , we conduct a human study to justify our usage of GPT-4 for evaluation in Sec. 6.4. We find GPT-4 judgments correlate strongly with humans, with human agreement with GPT-4 typically similar or higher than inter-human annotator agreement.
|
| 162 |
+
|
| 163 |
+

|
| 164 |
+
Figure 3: Left. Win rates computed by GPT-4 for Anthropic-HH one-step dialogue; DPO is the only method that improves over chosen summaries in the Anthropic-HH test set. Right. Win rates for different sampling temperatures over the course of training. DPO’s improvement over the dataset labels is fairly stable over the course of training for different sampling temperatures.
|
| 165 |
+
|
| 166 |
+
Methods. In addition to DPO, we evaluate several existing approaches to training language models to adhere to human preferences. Most simply, we explore zero-shot prompting with GPT-J [43] in the summarization task and 2-shot prompting with Pythia-2.8B $\mathbb { \left[ 3 \right] }$ in the dialogue task. In addition, we evaluate the SFT model as well as Preferred-FT, which is a model fine-tuned with supervised learning on the chosen completion $y _ { w }$ from either the SFT model (in controlled sentiment and summarization) or a generic LM (in single-turn dialogue). Another pseudo-supervised method is Unlikelihood, which simply optimizes the policy to maximize the probability assigned to $y _ { w }$ and minimize the probability assigned to $y _ { l }$ ; we use an optional coefficient $\alpha \in [ 0 , 1 ]$ on the ‘unlikelihood’ term. We also consider PPO $ { \mathbb { I } } ^ { \smash { \sum } }$ using a reward function learned from the preference data and PPO-GT, which is an oracle that learns from the ground truth reward function available in the controlled sentiment setting. In our sentiment experiments, we use two implementations of PPO-GT, one of-the-shelf version $\mathbb { \left[ \bigoplus 2 \right] }$ as well as a modified version that normalizes rewards and further tunes hyperparameters to improve performance (we also use these modifications when running ‘normal’ PPO with learned rewards). Finally, we consider the Best of $N$ baseline, sampling $N$ responses from the SFT model (or Preferred-FT in dialogue) and returning the highest-scoring response according to a reward function learned from the preference dataset. This high-performing method decouples the quality of the reward model from the PPO optimization, but is computationally impractical even for moderate $N$ as it requires sampling $N$ completions for every query at test time.
|
| 167 |
+
|
| 168 |
+
# 6.1 How well can DPO optimize the RLHF objective?
|
| 169 |
+
|
| 170 |
+
The KL-constrained reward maximization objective used in typical RLHF algorithms balances exploitation of reward while restricting the policy from deviating far from the reference policy. Therefore, when comparing algorithms, we must take into account both reward achieved as well as the KL discrepancy; achieving slightly higher reward but with much higher KL is not necessarily desirable. Figure $2$ shows the reward-KL frontier for various algorithms in the sentiment setting. We execute multiple training runs for each algorithm, using a different hyperparameter for policy conservativeness in each run (target $\mathrm { K L } \in \{ 3 , 6 , 9 , 1 2 \}$ for PPO, $\beta \in \{ 0 . 0 \dot { 5 } , 0 . 1 , 1 , 5 \}$ , $\alpha \in \{ 0 . { \dot { 0 } } 5 , 0 . 1 , 0 . 5 , 1 \}$ for unlikelihood, random seeds for preferred-FT). This sweep includes 22 runs in total. After each 100 training steps until convergence, we evaluate each policy on a set of test prompts, computing the average reward under the true reward function as well as the average sequence-level ${ \mathrm { K L } } ^ { \dot { 3 } }$ with the reference policy $\mathrm { K L } \left( \pi \mid \mid \pi _ { \mathrm { r e f } } \right)$ . We find that DPO produces by far the most efficient frontier, achieving the highest reward while still achieving low KL. This result is particularly notable for multiple reasons. First, DPO and PPO optimize the same objective, but DPO is notably more efficient;
|
| 171 |
+
|
| 172 |
+
DPO’s reward/KL tradeoff strictly dominates PPO. Second, DPO achieves a better frontier than PPO, even when PPO can access ground truth rewards (PPO-GT).
|
| 173 |
+
|
| 174 |
+
# 6.2 Can DPO scale to real preference datasets?
|
| 175 |
+
|
| 176 |
+
Next, we evaluate fine-tuning performance of DPO on summarization and single-turn dialogue. For summarization, automatic evaluation metrics such as ROUGE can be poorly correlated with human preferences $\left[ \left[ 3 8 \right] \right]$ , and prior work has found that fine-tuning LMs using PPO on human preferences to provide more effective summaries. We evaluate different methods by sampling completions on the test split of TL;DR summarization dataset, and computing the average win rate against reference completions in the test set. The completions for all methods are sampled at temperatures varying from 0.0 to 1.0, and the win rates are shown in Figure $\boxed { 2 }$ (right). DPO, PPO and Preferred-FT all fine-tune the same GPT-J SFT model4. We find that DPO has a win rate of approximately $61 \%$ at a temperature of 0.0, exceeding the performance of PPO at $57 \%$ at its optimal sampling temperature of 0.0. DPO also achieves a higher maximum win rate compared to the best of $N$ baseline. We note that we did not meaningfully tune DPO’s $\beta$ hyperparameter, so these results may underestimate DPO’s potential. Moreover, we find DPO to be much more robust to the sampling temperature than PPO, the performance of which can degrade to that of the base GPT-J model at high temperatures. Preferred-FT does not improve significantly over the SFT model. We also compare DPO and PPO head-to-head in human evaluations in Section $6 . 4 ,$ where DPO samples at temperature 0.25 were preferred $58 \%$ times over PPO samples at temperature 0.
|
| 177 |
+
|
| 178 |
+
On single-turn dialogue, we evaluate the different methods on the subset of the test split of the Anthropic HH dataset $\mathbb { M }$ with one step of human-assistant interaction. GPT-4 evaluations use the preferred completions on the test as the reference to compute the win rate for different methods. As there is no standard SFT model for this task, we start with a pre-trained Pythia-2.8B, use Preferred-FT to train a reference model on the chosen completions such that completions are within distribution of the model, and then train using DPO. We also compare against the best of 128 Preferred-FT completions (we found the Best of $N$ baseline plateaus at 128 completions for this task; see Appendix Figure $^ { 4 ) }$ and a 2-shot prompted version of the Pythia-2.8B base model, finding DPO performs as well or better for the best-performing temperatures for each method. We also evaluate an RLHF model trained with PPO on the Anthropic HH dataset 5 from a well-known source $\bigstar$ but are unable to find a prompt or sampling temperature that gives performance better than the base Pythia-2.8B model. Based on our results from TL;DR and the fact that both methods optimize the same reward function, we consider Best of 128 a rough proxy for PPO-level performance. Overall, DPO is the only computationally efficient method that improves over the preferred completions in the Anthropic HH dataset, and provides similar or better performance to the computationally demanding Best of 128 baseline. Finally, Figure $\bigtriangledown$ shows that DPO converges to its best performance relatively quickly.
|
| 179 |
+
|
| 180 |
+
# 6.3 Generalization to a new input distribution
|
| 181 |
+
|
| 182 |
+
To further compare the performance of PPO and DPO under distribution shifts, we evaluate the PPO and DPO policies from our Reddit TL;DR summarization experiment on a different distribution, news articles in the test split of the CNN/DailyMail dataset $\pmb { \Vert 2 4 \Vert }$ , using the best sampling temperatures from TL;DR (0 and 0.25). The results are presented in Table $\mathbb { L }$ We computed the GPT-4 win rate against the ground-truth summaries in the datasets, using the same GPT
|
| 183 |
+
|
| 184 |
+
<table><tr><td rowspan="2">Alg.</td><td colspan="2">Win rate vs. ground truth</td></tr><tr><td>Temp 0</td><td>Temp 0.25</td></tr><tr><td>DPO</td><td>0.36</td><td>0.31</td></tr><tr><td>PPO</td><td>0.26</td><td>0.23</td></tr></table>
|
| 185 |
+
|
| 186 |
+
Table 1: GPT-4 win rates vs. ground truth summaries for out-of-distribution CNN/DailyMail input articles.
|
| 187 |
+
|
| 188 |
+
4 (C) prompt we used for Reddit TL;DR, but replacing the words “forum post” with “news article”. For this new distribution, DPO continues to outperform the PPO policy by a significant margin. This experiment provides initial evidence that DPO policies can generalize similarly well to PPO policies, even though DPO does not use the additional unlabeled Reddit TL;DR prompts that PPO uses.
|
| 189 |
+
|
| 190 |
+
# 6.4 Validating GPT-4 judgments with human judgments
|
| 191 |
+
|
| 192 |
+
We conduct a human study to verify the reliability of GPT-4’s judgments, using the results of the TL;DR summarization experiment and two different GPT-4 prompts. The GPT-4 (S) (simple) prompt simply asks for which summary better-summarizes the important information in the post. The GPT-4 (C) (concise) prompt also asks for which summary is more concise; we evaluate this prompt because we find that GPT-4 prefers longer, more repetitive summaries than humans do with the GPT-4 (S) prompt. See Appendix C.2 for the complete prompts. We perform three comparisons, using the highest (DPO, temp. 0.25), the lowest (PPO, temp. 1.0), and a middle-performing (SFT, temp. 0.25) method with the aim of covering a diversity of sample qualities; all three methods are compared against greedilysampled PPO (its best-performing temperature). We find that with both prompts, GPT-4 tends to agree with humans about as often as humans agree with each other, suggesting that GPT-4 is a reasonable proxy for human evaluations (due to limited human raters, we only collect multiple human judgments for the DPO and PPO-1 comparisons). Overall, the GPT-4 (C) prompt generally provides win rates more representative of humans; we therefore use this prompt for the main results in Section $\overline { { 6 . 2 } } \}$ For additional details about the human study, including the web interface presented to raters and the list of human volunteers, see Appendix D.3.
|
| 193 |
+
|
| 194 |
+
Table 2: Comparing human and GPT-4 win rates and per-judgment agreement on TL;DR summarization samples. Humans agree with GPT-4 about as much as they agree with each other. Each experiment compares a summary from the stated method with a summary from PPO with temperature 0.
|
| 195 |
+
|
| 196 |
+
<table><tr><td></td><td>DPO</td><td>SFT</td><td>PPO-1</td></tr><tr><td>N respondents</td><td>272</td><td>122</td><td>199</td></tr><tr><td>GPT-4 (S) win %</td><td>47</td><td>27</td><td>13</td></tr><tr><td>GPT-4 (C) win %</td><td>54</td><td>32</td><td>12</td></tr><tr><td>Human win %</td><td>58</td><td>43</td><td>17</td></tr><tr><td>GPT-4 (S)-H agree</td><td>70</td><td>77</td><td>86</td></tr><tr><td>GPT-4 (C)-H agree</td><td>67</td><td>79</td><td>85</td></tr><tr><td>H-H agree</td><td>65</td><td>-</td><td>87</td></tr></table>
|
| 197 |
+
|
| 198 |
+
# 7 Discussion
|
| 199 |
+
|
| 200 |
+
Learning from preferences is a powerful, scalable framework for training capable, aligned language models. We have introduced DPO, a simple training paradigm for training language models from preferences without reinforcement learning. Rather than coercing the preference learning problem into a standard RL setting in order to use off-the-shelf RL algorithms, DPO identifies a mapping between language model policies and reward functions that enables training a language model to satisfy human preferences directly, with a simple cross-entropy loss, without reinforcement learning or loss of generality. With virtually no tuning of hyperparameters, DPO performs similarly or better than existing RLHF algorithms, including those based on PPO; DPO thus meaningfully reduces the barrier to training more language models from human preferences.
|
| 201 |
+
|
| 202 |
+
Limitations & Future Work. Our results raise several important questions for future work. How does the DPO policy generalize out of distribution, compared with learning from an explicit reward function? Our initial results suggest that DPO policies can generalize similarly to PPO-based models, but more comprehensive study is needed. For example, can training with self-labeling from the DPO policy similarly make effective use of unlabeled prompts? On another front, how does reward over-optimization manifest in the direct preference optimization setting, and is the slight decrease in performance in Figure $\textcircled { 3 }$ right an instance of it? Additionally, while we evaluate models up to 6B parameters, exploration of scaling DPO to state-of-the-art models orders of magnitude larger is an exciting direction for future work. Regarding evaluations, we find that the win rates computed by GPT-4 are impacted by the prompt; future work may study the best way to elicit high-quality judgments from automated systems. Finally, many possible applications of DPO exist beyond training language models from human preferences, including training generative models in other modalities.
|
| 203 |
+
|
| 204 |
+
# Acknowledgements
|
| 205 |
+
|
| 206 |
+
EM gratefully acknowledges funding from a Knight-Hennessy Graduate Fellowship. CF and CM are CIFAR Fellows. This work was supported in part by the Stanford Accelerator for Learning (SAL) and Stanford Institute for Human-Centered Artificial Intelligence (HAI) Generative AI for the Future of Learning seed grant program. The Stanford Center for Research on Foundation Models (CRFM) provided part of the compute resources used for the experiments in this work. This work was supported in part by ONR grant N00014-20-1-2675.
|
| 207 |
+
|
| 208 |
+
References
|
| 209 |
+
[1] Y. Bai, A. Jones, K. Ndousse, A. Askell, A. Chen, N. DasSarma, D. Drain, S. Fort, D. Ganguli, T. Henighan, N. Joseph, S. Kadavath, J. Kernion, T. Conerly, S. El-Showk, N. Elhage, Z. HatfieldDodds, D. Hernandez, T. Hume, S. Johnston, S. Kravec, L. Lovitt, N. Nanda, C. Olsson, D. Amodei, T. Brown, J. Clark, S. McCandlish, C. Olah, B. Mann, and J. Kaplan. Training a helpful and harmless assistant with reinforcement learning from human feedback, 2022.
|
| 210 |
+
[2] Y. Bai, S. Kadavath, S. Kundu, A. Askell, J. Kernion, A. Jones, A. Chen, A. Goldie, A. Mirhoseini, C. McKinnon, C. Chen, C. Olsson, C. Olah, D. Hernandez, D. Drain, D. Ganguli, D. Li, E. Tran-Johnson, E. Perez, J. Kerr, J. Mueller, J. Ladish, J. Landau, K. Ndousse, K. Lukosuite, L. Lovitt, M. Sellitto, N. Elhage, N. Schiefer, N. Mercado, N. DasSarma, R. Lasenby, R. Larson, S. Ringer, S. Johnston, S. Kravec, S. E. Showk, S. Fort, T. Lanham, T. Telleen-Lawton, T. Conerly, T. Henighan, T. Hume, S. R. Bowman, Z. Hatfield-Dodds, B. Mann, D. Amodei, N. Joseph, S. McCandlish, T. Brown, and J. Kaplan. Constitutional ai: Harmlessness from ai feedback, 2022.
|
| 211 |
+
[3] S. Biderman, H. Schoelkopf, Q. Anthony, H. Bradley, K. O’Brien, E. Hallahan, M. A. Khan, S. Purohit, U. S. Prashanth, E. Raff, A. Skowron, L. Sutawika, and O. van der Wal. Pythia: A suite for analyzing large language models across training and scaling, 2023.
|
| 212 |
+
[4] H. Bong and A. Rinaldo. Generalized results for the existence and consistency of the MLE in the Bradley-Terry-Luce model. International Conference on Machine Learning, 2022. arXiv:2110.11487.
|
| 213 |
+
[5] R. A. Bradley and M. E. Terry. Rank analysis of incomplete block designs: I. the method of paired comparisons. Biometrika, 39(3/4):324–345, 1952. doi: https://doi.org/10.2307/2334029.
|
| 214 |
+
[6] T. Brown, B. Mann, N. Ryder, M. Subbiah, J. D. Kaplan, P. Dhariwal, A. Neelakantan, P. Shyam, G. Sastry, A. Askell, S. Agarwal, A. Herbert-Voss, G. Krueger, T. Henighan, R. Child, A. Ramesh, D. Ziegler, J. Wu, C. Winter, C. Hesse, M. Chen, E. Sigler, M. Litwin, S. Gray, B. Chess, J. Clark, C. Berner, S. McCandlish, A. Radford, I. Sutskever, and D. Amodei. Language models are few-shot learners. In H. Larochelle, M. Ranzato, R. Hadsell, M. Balcan, and H. Lin, editors, Advances in Neural Information Processing Systems, volume 33, pages 1877– 1901. Curran Associates, Inc., 2020. URL https://proceedings.neurips.cc/paper_ files/paper/2020/file/1457c0d6bfcb4967418bfb8ac142f64a-Paper.pdf.
|
| 215 |
+
[7] 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.
|
| 216 |
+
[8] S. Bubeck, V. Chandrasekaran, R. Eldan, J. Gehrke, E. Horvitz, E. Kamar, P. Lee, Y. T. Lee, Y. Li, S. Lundberg, H. Nori, H. Palangi, M. T. Ribeiro, and Y. Zhang. Sparks of artificial general intelligence: Early experiments with GPT-4, 2023. arXiv preprint arXiv:2303.12712.
|
| 217 |
+
[9] R. Busa-Fekete, B. Szörényi, P. Weng, W. Cheng, and E. Hüllermeier. Preference-based reinforcement learning: evolutionary direct policy search using a preference-based racing algorithm. Machine Learning, 97(3):327–351, July 2014. doi: 10.1007/s10994-014-5458-8. URL https://doi.org/10.1007/s10994-014-5458-8.
|
| 218 |
+
[10] Y. Chen, R. Wang, H. Jiang, S. Shi, and R.-L. Xu. Exploring the use of large language models for reference-free text quality evaluation: A preliminary empirical study. ArXiv, abs/2304.00723, 2023.
|
| 219 |
+
[11] A. Chowdhery, S. Narang, J. Devlin, M. Bosma, G. Mishra, A. Roberts, P. Barham, H. W. Chung, C. Sutton, S. Gehrmann, et al. Palm: Scaling language modeling with pathways. arXiv preprint arXiv:2204.02311, 2022.
|
| 220 |
+
[12] P. F. Christiano, J. Leike, T. Brown, M. Martic, S. Legg, and D. Amodei. Deep reinforcement learning from human preferences. In I. Guyon, U. V. Luxburg, S. Bengio, H. Wallach, R. Fergus, S. Vishwanathan, and R. Garnett, editors, Advances in Neural Information Processing Systems, volume 30. Curran Associates, Inc., 2017. URL https://proceedings.neurips.cc/ paper_files/paper/2017/file/d5e2c0adad503c91f91df240d0cd4e49-Paper.pdf.
|
| 221 |
+
|
| 222 |
+
[13] H. W. Chung, L. Hou, S. Longpre, B. Zoph, Y. Tay, W. Fedus, Y. Li, X. Wang, M. Dehghani, S. Brahma, A. Webson, S. S. Gu, Z. Dai, M. Suzgun, X. Chen, A. Chowdhery, A. Castro-Ros, M. Pellat, K. Robinson, D. Valter, S. Narang, G. Mishra, A. Yu, V. Zhao, Y. Huang, A. Dai, H. Yu, S. Petrov, E. H. Chi, J. Dean, J. Devlin, A. Roberts, D. Zhou, Q. V. Le, and J. Wei. Scaling instruction-finetuned language models, 2022.
|
| 223 |
+
|
| 224 |
+
[14] M. Dudík, K. Hofmann, R. E. Schapire, A. Slivkins, and M. Zoghi. Contextual dueling bandits. In P. Grünwald, E. Hazan, and S. Kale, editors, Proceedings of The 28th Conference on Learning Theory, volume 40 of Proceedings of Machine Learning Research, pages 563–587, Paris, France, 03–06 Jul 2015. PMLR. URL https://proceedings.mlr.press/v40/Dudik15.html.
|
| 225 |
+
|
| 226 |
+
[15] D. Go, T. Korbak, G. Kruszewski, J. Rozen, N. Ryu, and M. Dymetman. Aligning language models with preferences through f-divergence minimization. In Proceedings of the 40th International Conference on Machine Learning, ICML’23. JMLR.org, 2023.
|
| 227 |
+
|
| 228 |
+
[16] A. Jain, B. Wojcik, T. Joachims, and A. Saxena. Learning trajectory preferences for manipulators via iterative improvement. In C. Burges, L. Bottou, M. Welling, Z. Ghahramani, and K. Weinberger, editors, Advances in Neural Information Processing Systems, volume 26. Curran Associates, Inc., 2013. URL https://proceedings.neurips.cc/paper_files/paper/ 2013/file/c058f544c737782deacefa532d9add4c-Paper.pdf.
|
| 229 |
+
|
| 230 |
+
[17] T. Korbak, H. Elsahar, G. Kruszewski, and M. Dymetman. On reinforcement learning and distribution matching for fine-tuning language models with no catastrophic forgetting. In S. Koyejo, S. Mohamed, A. Agarwal, D. Belgrave, K. Cho, and A. Oh, editors, Advances in Neural Information Processing Systems, volume 35, pages 16203–16220. Curran Associates, Inc., 2022. URL https://proceedings.neurips.cc/paper_files/paper/2022/file/ 67496dfa96afddab795530cc7c69b57a-Paper-Conference.pdf.
|
| 231 |
+
|
| 232 |
+
[18] J. Kreutzer, J. Uyheng, and S. Riezler. Reliability and learnability of human bandit feedback for sequence-to-sequence reinforcement learning. In Proceedings of the 56th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pages 1777–1788, Melbourne, Australia, July 2018. Association for Computational Linguistics. doi: 10.18653/v1/ P18-1165. URL https://aclanthology.org/P18-1165.
|
| 233 |
+
|
| 234 |
+
[19] A. Kupcsik, D. Hsu, and W. S. Lee. Learning Dynamic Robot-to-Human Object Handover from Human Feedback, pages 161–176. Springer International Publishing, 01 2018. ISBN 978-3-319-51531-1. doi: 10.1007/978-3-319-51532-8_10.
|
| 235 |
+
|
| 236 |
+
[20] S. Levine. Reinforcement learning and control as probabilistic inference: Tutorial and review, 2018.
|
| 237 |
+
|
| 238 |
+
[21] R. D. Luce. Individual choice behavior: A theoretical analysis. Courier Corporation, 2012.
|
| 239 |
+
|
| 240 |
+
[22] A. L. Maas, R. E. Daly, P. T. Pham, D. Huang, A. Y. Ng, and C. Potts. Learning word vectors for sentiment analysis. In Proceedings of the 49th Annual Meeting of the Association for Computational Linguistics: Human Language Technologies, pages 142–150, Portland, Oregon, USA, June 2011. Association for Computational Linguistics. URL http://www.aclweb.org/ anthology/P11-1015.
|
| 241 |
+
|
| 242 |
+
[23] S. Mishra, D. Khashabi, C. Baral, and H. Hajishirzi. Cross-task generalization via natural language crowdsourcing instructions. In Proceedings of the 60th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pages 3470–3487, Dublin, Ireland, May 2022. Association for Computational Linguistics. doi: 10.18653/v1/2022.acl-long. 244. URL https://aclanthology.org/2022.acl-long.244.
|
| 243 |
+
|
| 244 |
+
[24] R. Nallapati, B. Zhou, C. dos Santos, Ç. Gulçehre, and B. Xiang. Abstractive text summarization using sequence-to-sequence RNNs and beyond. In Proceedings of the 20th SIGNLL Conference on Computational Natural Language Learning, pages 280–290, Berlin, Germany, Aug. 2016. Association for Computational Linguistics. doi: 10.18653/v1/K16-1028. URL https:// aclanthology.org/K16-1028.
|
| 245 |
+
|
| 246 |
+
[25] D. Narayanan, M. Shoeybi, J. Casper, P. LeGresley, M. Patwary, V. Korthikanti, D. Vainbrand, P. Kashinkunti, J. Bernauer, B. Catanzaro, A. Phanishayee, and M. Zaharia. Efficient large-scale language model training on gpu clusters using megatron-lm. In Proceedings of the International Conference for High Performance Computing, Networking, Storage and Analysis, SC ’21, New York, NY, USA, 2021. Association for Computing Machinery. ISBN 9781450384421. doi: 10.1145/3458817.3476209. URL https://doi.org/10.1145/3458817.3476209.
|
| 247 |
+
|
| 248 |
+
[26] L. Ouyang, J. Wu, X. Jiang, D. Almeida, C. Wainwright, P. Mishkin, C. Zhang, S. Agarwal, K. Slama, A. Ray, J. Schulman, J. Hilton, F. Kelton, L. Miller, M. Simens, A. Askell, P. Welinder, P. F. Christiano, J. Leike, and R. Lowe. Training language models to follow instructions with human feedback. In S. Koyejo, S. Mohamed, A. Agarwal, D. Belgrave, K. Cho, and A. Oh, editors, Advances in Neural Information Processing Systems, volume 35, pages 27730–27744. Curran Associates, Inc., 2022. URL https://proceedings.neurips.cc/paper_files/ paper/2022/file/b1efde53be364a73914f58805a001731-Paper-Conference.pdf.
|
| 249 |
+
|
| 250 |
+
[27] R. Paulus, C. Xiong, and R. Socher. A deep reinforced model for abstractive summarization. In International Conference on Learning Representations, 2018. URL https://openreview. net/forum?id=HkAClQgA-.
|
| 251 |
+
|
| 252 |
+
[28] 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.
|
| 253 |
+
|
| 254 |
+
[29] J. Peters and S. Schaal. Reinforcement learning by reward-weighted regression for operational space control. In Proceedings of the 24th international conference on Machine learning, pages 745–750, 2007.
|
| 255 |
+
|
| 256 |
+
[30] R. L. Plackett. The analysis of permutations. Journal of the Royal Statistical Society. Series $C$ (Applied Statistics), 24(2):193–202, 1975. doi: https://doi.org/10.2307/2346567.
|
| 257 |
+
|
| 258 |
+
[31] A. Radford, J. Wu, R. Child, D. Luan, D. Amodei, and I. Sutskever. Language models are unsupervised multitask learners, 2019. Ms., OpenAI.
|
| 259 |
+
|
| 260 |
+
[32] R. Ramamurthy, P. Ammanabrolu, K. Brantley, J. Hessel, R. Sifa, C. Bauckhage, H. Hajishirzi, and Y. Choi. Is reinforcement learning (not) for natural language processing: Benchmarks, baselines, and building blocks for natural language policy optimization. In The Eleventh International Conference on Learning Representations, 2023. URL https://openreview. net/forum?id=8aHzds2uUyB.
|
| 261 |
+
|
| 262 |
+
[33] M. Ranzato, S. Chopra, M. Auli, and W. Zaremba. Sequence level training with recurrent neural networks. CoRR, abs/1511.06732, 2015.
|
| 263 |
+
|
| 264 |
+
[34] D. Sadigh, A. D. Dragan, S. Sastry, and S. A. Seshia. Active preference-based learning of reward functions. In Robotics: Science and Systems (RSS), 2017.
|
| 265 |
+
|
| 266 |
+
[35] A. Saha, A. Pacchiano, and J. Lee. Dueling rl: Reinforcement learning with trajectory preferences. In F. Ruiz, J. Dy, and J.-W. van de Meent, editors, Proceedings of The 26th International Conference on Artificial Intelligence and Statistics, volume 206 of Proceedings of Machine Learning Research, pages 6263–6289. PMLR, 25–27 Apr 2023. URL https://proceedings.mlr.press/v206/saha23a.html.
|
| 267 |
+
|
| 268 |
+
[36] V. Sanh, A. Webson, C. Raffel, S. Bach, L. Sutawika, Z. Alyafeai, A. Chaffin, A. Stiegler, A. Raja, M. Dey, M. S. Bari, C. Xu, U. Thakker, S. S. Sharma, E. Szczechla, T. Kim, G. Chhablani, N. Nayak, D. Datta, J. Chang, M. T.-J. Jiang, H. Wang, M. Manica, S. Shen, Z. X. Yong, H. Pandey, R. Bawden, T. Wang, T. Neeraj, J. Rozen, A. Sharma, A. Santilli, T. Fevry, J. A. Fries, R. Teehan, T. L. Scao, S. Biderman, L. Gao, T. Wolf, and A. M. Rush. Multitask prompted training enables zero-shot task generalization. In International Conference on Learning Representations, 2022. URL https://openreview.net/forum?id=9Vrb9D0WI4.
|
| 269 |
+
|
| 270 |
+
[37] J. Schulman, F. Wolski, P. Dhariwal, A. Radford, and O. Klimov. Proximal policy optimization algorithms, 2017.
|
| 271 |
+
|
| 272 |
+
[38] N. Stiennon, L. Ouyang, J. Wu, D. M. Ziegler, R. Lowe, C. Voss, A. Radford, D. Amodei, and P. Christiano. Learning to summarize from human feedback, 2022.
|
| 273 |
+
|
| 274 |
+
[39] R. Thoppilan, D. D. Freitas, J. Hall, N. Shazeer, A. Kulshreshtha, H.-T. Cheng, A. Jin, T. Bos, L. Baker, Y. Du, Y. Li, H. Lee, H. S. Zheng, A. Ghafouri, M. Menegali, Y. Huang, M. Krikun, D. Lepikhin, J. Qin, D. Chen, Y. Xu, Z. Chen, A. Roberts, M. Bosma, V. Zhao, Y. Zhou, C.-C. Chang, I. Krivokon, W. Rusch, M. Pickett, P. Srinivasan, L. Man, K. Meier-Hellstern, M. R. Morris, T. Doshi, R. D. Santos, T. Duke, J. Soraker, B. Zevenbergen, V. Prabhakaran, M. Diaz, B. Hutchinson, K. Olson, A. Molina, E. Hoffman-John, J. Lee, L. Aroyo, R. Rajakumar, A. Butryna, M. Lamm, V. Kuzmina, J. Fenton, A. Cohen, R. Bernstein, R. Kurzweil, B. AgueraArcas, C. Cui, M. Croak, E. Chi, and Q. Le. Lamda: Language models for dialog applications, 2022.
|
| 275 |
+
|
| 276 |
+
[40] H. Touvron, T. Lavril, G. Izacard, X. Martinet, M.-A. Lachaux, T. Lacroix, B. Rozière, N. Goyal, E. Hambro, F. Azhar, et al. Llama: Open and efficient foundation language models. arXiv preprint arXiv:2302.13971, 2023.
|
| 277 |
+
|
| 278 |
+
[41] M. Völske, M. Potthast, S. Syed, and B. Stein. TL;DR: Mining Reddit to learn automatic summarization. In Proceedings of the Workshop on New Frontiers in Summarization, pages 59–63, Copenhagen, Denmark, Sept. 2017. Association for Computational Linguistics. doi: 10.18653/v1/W17-4508. URL https://aclanthology.org/W17-4508.
|
| 279 |
+
|
| 280 |
+
[42] L. von Werra, J. Tow, reciprocated, S. Matiana, A. Havrilla, cat state, L. Castricato, Alan, D. V. Phung, A. Thakur, A. Bukhtiyarov, aaronrmm, F. Milo, Daniel, D. King, D. Shin, E. Kim, J. Wei, M. Romero, N. Pochinkov, O. Sanseviero, R. Adithyan, S. Siu, T. Simonini, V. Blagojevic, X. Song, Z. Witten, alexandremuzio, and crumb. CarperAI/trlx: v0.6.0: LLaMa (Alpaca), Benchmark Util, T5 ILQL, Tests, Mar. 2023. URL https://doi.org/10.5281/zenodo. 7790115.
|
| 281 |
+
|
| 282 |
+
[43] B. Wang and A. Komatsuzaki. GPT-J-6B: A 6 Billion Parameter Autoregressive Language Model. https://github.com/kingoflolz/mesh-transformer-jax, May 2021.
|
| 283 |
+
|
| 284 |
+
[44] R. J. Williams. Simple statistical gradient-following algorithms for connectionist reinforcement learning. Mach. Learn., 8(3–4):229–256, may 1992. ISSN 0885-6125. doi: 10.1007/BF00992696. URL https://doi.org/10.1007/BF00992696.
|
| 285 |
+
|
| 286 |
+
[45] Y. Wu and B. Hu. Learning to extract coherent summary via deep reinforcement learning. In Proceedings of the Thirty-Second AAAI Conference on Artificial Intelligence and Thirtieth Innovative Applications of Artificial Intelligence Conference and Eighth AAAI Symposium on Educational Advances in Artificial Intelligence, AAAI’18/IAAI’18/EAAI’18. AAAI Press, 2018. ISBN 978-1-57735-800-8.
|
| 287 |
+
|
| 288 |
+
[46] X. Yan, C. Luo, C. L. A. Clarke, N. Craswell, E. M. Voorhees, and P. Castells. Human preferences as dueling bandits. In Proceedings of the 45th International ACM SIGIR Conference on Research and Development in Information Retrieval, SIGIR ’22, page 567–577, New York, NY, USA, 2022. Association for Computing Machinery. ISBN 9781450387323. doi: 10.1145/3477495.3531991. URL https://doi.org/10.1145/3477495.3531991.
|
| 289 |
+
|
| 290 |
+
[47] Y. Yue, J. Broder, R. Kleinberg, and T. Joachims. The $\mathbf { k }$ -armed dueling bandits problem. Journal of Computer and System Sciences, 78(5):1538–1556, 2012. ISSN 0022-0000. doi: https: //doi.org/10.1016/j.jcss.2011.12.028. URL https://www.sciencedirect.com/science/ article/pii/S0022000012000281. JCSS Special Issue: Cloud Computing 2011.
|
| 291 |
+
|
| 292 |
+
[48] D. M. Ziegler, N. Stiennon, J. Wu, T. B. Brown, A. Radford, D. Amodei, P. Christiano, and G. Irving. Fine-tuning language models from human preferences, 2020.
|
md/dev/JhzzvJnL9t/JhzzvJnL9t.md
ADDED
|
@@ -0,0 +1,395 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Out-of-Domain Intent Detection Considering Multi-turn Dialogue Contexts
|
| 2 |
+
|
| 3 |
+
Anonymous EMNLP submission
|
| 4 |
+
|
| 5 |
+
# Abstract
|
| 6 |
+
|
| 7 |
+
Out-of-Domain (OOD) intent detection is vital for practical dialogue systems, and it usually requires considering multi-turn dialogue contexts. However, most previous OOD intent detection approaches are limited to single dialogue turns. In this paper, we introduce a contextaware OOD intent detection (Caro) framework to model multi-turn contexts in OOD intent detection tasks. Specifically, we follow the information bottleneck principle to extract robust representations from multi-turn dialogue contexts. Two different views are constructed for each input sample and the superfluous information not related to intent detection is removed using a multi-view information bottleneck loss. Moreover, we also explore utilizing unlabeled data in Caro. A two-stage training process is introduced to mine OOD samples from these unlabeled data, and these OOD samples are used to train the resulting model with a bootstrapping approach. Comprehensive experiments demonstrate that Caro establishes state-of-theart performances on multi-turn OOD detection tasks by improving the F1-OOD score of over $2 9 \%$ compared to the previous best method.
|
| 8 |
+
|
| 9 |
+
# 1 Introduction
|
| 10 |
+
|
| 11 |
+
Intent detection is vital for dialogue systems (Chen et al., 2017). Recently, promising results have been reported for intent detection under the closed-world assumption (Shu et al., 2017), i.e., the training and testing distributions are assumed to be identical, and all testing intents are seen in the training process. However, this assumption may not be valid in practice (Dietterich, 2017), where a deployed system usually confronts an open-world (Fei and Liu, 2016; Scheirer et al., 2012), i.e., the testing distribution is subject to change and Out-of-Domain (OOD) intents that are not seen in the training process may emerge in testing. It is necessary to equip intent detection modules with OOD detection abilities to accurately classify seen In-Domain (IND)
|
| 12 |
+
|
| 13 |
+
intents while rejecting unseen OOD intents (Yan et al., 2020a).
|
| 14 |
+
|
| 15 |
+
Various methods are proposed to tackle the issue of OOD detection on classification problems (Geng et al., 2020). Existing approaches include using thresholds (Zhou et al., 2021) or $( k + 1 )$ -way classifiers ( $k$ is the number of IND classes) (Zhan et al., 2021). Promising results are reported to apply these OOD detection methods on intent detection modules (Zhou et al., 2022). However, most existing OOD intent detection studies only focus on singleturn inputs (Yan et al., 2020a; Lee and Shalyminov, 2019), i.e., only the most recently issued utterance is taken as the input. In real applications, completing a task usually necessitates multiple turns of conversations (Weld et al., 2021). Therefore, it is important to explicitly model multi-turn contexts when building OOD intent detection modules since users’ intents generally depend on turns of conversations (Qin et al., 2021).
|
| 16 |
+
|
| 17 |
+
However, it is non-trivial to directly extend previous methods to the multi-turn setting (Ghosal et al., 2021). Specifically, we usually experience long distance obstacles when modeling multi-turn dialogue contexts, i.e., some dialogues have extremely long histories filled with irrelevant noises for intent detection (Liu et al., 2021). It is challenging to directly apply previous OOD intent detection methods under this obstacle since the learned representations may contain superfluous information that is irrelevant for intent detection tasks (Federici et al., 2019).
|
| 18 |
+
|
| 19 |
+
Another challenge for OOD detection in multiturn settings is the absence of OOD samples in the training phase (Zeng et al., 2021a). Specifically, it is hard to refine learned representations for OOD detection without seeing any OOD training samples (Shen et al., 2021), and it is expensive to construct OOD samples before training, especially when multi-turn contexts are considered (Chen and Yu, 2021). Fortunately, unlabeled data (i.e., a mixture of IND and OOD samples) provide a convenient way to access OOD samples since these unlabeled data are almost “free” to collect from a deployed system. However, few studies have explored utilizing unlabeled data for OOD detection in the multi-turn setting.
|
| 20 |
+
|
| 21 |
+
In this study, we propose a novel context-aware OOD intent detection framework Caro to address the above challenges for OOD intent detection in multi-turn settings. Specifically, we follow the information bottleneck principle (Tishby et al., 2000) to tackle the long-distance obstacle exhibited in multi-turn contexts. Robust representations are extracted by retaining predictive information while discarding superfluous information unrelated to intent detection. This objective is achieved by optimizing an unsupervised multi-view information bottleneck loss, during which two views are built based on the global pooling approach and adaptive reception fields. A gating mechanism is introduced to adaptively aggregate these two views to obtain an assembled representation. Caro also introduces a two-stage self-training scheme to mine OOD samples from unlabeled data. Specifically, the first stage builds a preliminary OOD detector with OOD samples synthesized from IND data. The second stage uses this detector to select OOD samples from the unlabeled data and use these samples to further refine the OOD detector. We list our key contributions:
|
| 22 |
+
|
| 23 |
+
1. We propose a novel framework Caro to address a challenging yet under-explored problem of OOD intent detection considering multi-turn dialogue contexts.
|
| 24 |
+
|
| 25 |
+
2. Caro learns robust representations by building diverse views of inputs and optimizing an unsupervised multi-view loss following the information bottleneck principle. Moreover, Caro mines OOD samples from unlabeled data to further refine the OOD detector.
|
| 26 |
+
|
| 27 |
+
3. We extensively evaluate Caro on multi-turn dialogue datasets. Caro obtains state-of-the-art results, outperforming the best baseline by a large margin $( 2 9 . 6 \%$ in the F1-OOD score).
|
| 28 |
+
|
| 29 |
+
et al., 2021a; Zhou et al., 2022; Wu et al., 2022) and use these representations to develop density-based or distance-based OOD detectors (Lee et al., 2018; Tan et al., 2019; Liu et al., 2020; Podolskiy et al., 2021). Some works also try to build OOD detectors with generated pseudo OOD samples (Hendrycks et al., 2018; Shu et al., 2021; Zhan et al., 2021; Marek et al., 2021) or thresholds based approaches (Gal and Ghahramani, 2016; Lakshminarayanan et al., 2017; Ren et al., 2019; Gangal et al., 2020; Ryu et al., 2017).
|
| 30 |
+
|
| 31 |
+
Some OOD detection methods also make use of unlabeled data. Existing approaches either focus on utilizing unlabeled IND data (Xu et al., 2021; Jin et al., 2022) or adopting a self-supervised learning framework to handle mixtures of IND and OOD samples (Zeng et al., 2021b). These approaches do not explicitly model multi-turn contexts.
|
| 32 |
+
|
| 33 |
+
Modeling Multi-turn Dialogue Contexts is the foundation for various dialogue tasks (Li et al., 2020; Ghosal et al., 2021; Chen et al., 2021). However, few works focus on detecting OOD intents in the multi-turn setting. Lee and Shalyminov (2019) proposed to use counterfeit OOD turns extracted from multi-turn contexts to train the OOD detector, and Chen and Yu (2021) augmented seed OOD samples that span multiple turns to improve the OOD detection performance. Nevertheless, these approaches either suffer from the long distance obstacle or require expensive annotated OOD samples. In this study, we attempt to learn robust representation by explicitly identifying and discarding superfluous information.
|
| 34 |
+
|
| 35 |
+
Representation Learning is also related to our work. Recent approaches for representation learning include optimizing a contrastive loss (Caron et al., 2020; Gao et al., 2021) or maximizing the mutual information between features and input samples (Poole et al., 2019). However, these approaches cannot tackle the long distance obstacle exhibited in multi-turn contexts. In this study, we follow the information bottleneck principle (Tishby et al., 2000; Federici et al., 2019) to remove superfluous information from long contexts.
|
| 36 |
+
|
| 37 |
+
# 2 Related Work
|
| 38 |
+
|
| 39 |
+
OOD Detection is a widely investigated machine learning problem (Geng et al., 2020). Recent approaches try to improve the OOD detection performance by learning more robust representations on IND data (Zhou et al., 2021; Yan et al., 2020b; Zeng
|
| 40 |
+
|
| 41 |
+
# 3 Problem Setup
|
| 42 |
+
|
| 43 |
+
We start by formulating the problem: Given $k$ IND intent classes $\mathcal { T } = \{ I _ { i } \} _ { i = 1 } ^ { k }$ , we denote all samples that do not belong to these $k$ classes as the $( k + 1 )$ th intent $I _ { k + 1 }$ . Our training data contain a set of labeled IND samples ${ \mathcal { D } } _ { I } = \{ \langle x _ { i } , y _ { i } \rangle \}$ and a set of unlabeled samples $\mathcal { D } _ { U } = \{ \langle \widetilde { \pmb { x } } _ { i } , \widetilde { \pmb { y } } _ { i } \rangle \}$ , where $y _ { i } \in \mathcal { I }$ and $\widetilde { y _ { i } } \in \mathcal { T } \cup \{ I _ { k + 1 } \}$ is the label of input sample $\mathbf { \nabla } _ { \mathbf { x } _ { i } }$ and $\widetilde { \pmb { x } } _ { i }$ , respectively. $\widetilde { y _ { i } }$ labels are not observed eduring training. Our testing data contain a mixture of IND and OOD samples ${ \mathcal { D } } _ { T } = \{ \langle \widetilde { \pmb { x } } _ { i } , \widetilde { \ y } _ { i } \rangle \}$ , where $\widetilde { y _ { i } } \in \mathcal { T } \cup \left\{ I _ { k + 1 } \right\}$ . For a testing input $\widetilde { \pmb x }$ , our OOD intent detector aims to classify the intent label of $\widetilde { \pmb x }$ if it belongs to an IND intent or reject $\widetilde { \pmb x }$ if it belongs to the OOD intent $I _ { k + 1 }$ . We also assume a validation set ${ \mathcal { D } } _ { V }$ that only contains IND samples is available. Moreover, each input sample $_ { \pmb { x } }$ from $\mathcal { D } _ { I } , \mathcal { D } _ { U } , \mathcal { D } _ { V }$ , and $\mathcal { D } _ { T }$ consists of an utterance $\textbf { \em u }$ and a multi-turn dialogue history $\pmb { h } = \pmb { u } _ { 1 } , \ldots , \pmb { u } _ { t }$ $( t \geq 0 )$ prior of $\textbf { \em u }$ : ${ \pmb x } = \langle { \pmb h } , { \pmb u } \rangle$ . $\mathbf { \Delta } \mathbf { u } _ { i }$ is the utterance issued in each dialogue turn.
|
| 44 |
+
|
| 45 |
+
# 4 Method
|
| 46 |
+
|
| 47 |
+
Care tackles the OOD intent detection problem by training a $( k + 1 )$ -way classifier $F$ on $\mathcal { D } _ { I } \cup \mathcal { D } _ { U }$ Specifically, samples classified into the $( k + 1 )$ -th intent $I _ { k + 1 }$ are considered as OOD samples. There are mainly two challenges to be addressed in Caro: (1) How to alleviate the long distance obstacle and learn robust representations from multi-turn dialogue contexts; (2) How to effectively leverage unlabeled data for OOD intent detection. These two issues are tackled with two key ingredients in Caro (see Figure 1): 1. A multi-view information bottleneck method (Section 4.1); 2. A two-stage self-training scheme (Section 4.2).
|
| 48 |
+
|
| 49 |
+
# 4.1 Multi-View Information Bottleneck
|
| 50 |
+
|
| 51 |
+
The major challenge for learning robust representations from multi-turn dialogue contexts is the long distance obstacle, i.e., information that is irrelevant for intent detection may degenerate the extracted representation if the dialogue history $h$ becomes too long. In this study, we follow the information bottleneck principle (Tishby et al., 2000) to alleviate this issue, i.e., only the task-relevant information is retained in the extracted representations while all the superficial information is discarded. Specifically, we adopt a more general unsupervised multi-view setting for the information bottleneck method (Federici et al., 2019). For each input sample $\mathbf { \nabla } _ { \mathbf { x } _ { i } }$ , two semantic invariant views are constructed: $v _ { 1 } ( \pmb { x } _ { i } )$ , $v _ { 2 } ( \pmb { x } _ { i } )$ . These two views preserve the same task-relevant information (Zhao et al., 2017). The mutual information between $v _ { 1 } ( \pmb { x } _ { i } )$ and $v _ { 2 } ( \pmb { x } _ { i } )$ are maximized while the information not shared between $v _ { 1 } ( \pmb { x } _ { i } )$ and $v _ { 2 } ( \pmb { x } _ { i } )$ are eliminated.
|
| 52 |
+
|
| 53 |
+
To achieve this goal, we adopt the multi-view information bottleneck loss introduced by Federici et al. (2019).
|
| 54 |
+
|
| 55 |
+
Constructing Multiple Views for an input sample $_ { \pmb { x } }$ is the key to the success of the unsupervised information bottleneck method. In this study, we construct these two views $v _ { 1 } ( \pmb { x } _ { i } )$ , $v _ { 2 } ( \pmb { x } _ { i } )$ by adjusting the receptive fields of the final representation. This scheme is inspired by the observation in the neuroscience community that human brains process information with multiple receptive fields (Sceniak et al., 1999), i.e., the receptive field size for neurons is adapted based on input stimuli (Spillmann et al., 2015) so that different regions of inputs are emphasized (Pettet and Gilbert, 1992). This phenomenon has been demonstrated to be effective in modeling more robust features (Pandey et al., 2022) and inspired numerous successful neural models (Wang et al., 2021; Wei et al., 2017).
|
| 56 |
+
|
| 57 |
+
Specifically, for each input sample ${ \pmb x } = \langle { \pmb h } , { \pmb u } \rangle$ , we first concatenate all utterances in $_ { \pmb { x } }$ and then use a pre-trained BERT model $E$ (Devlin et al., 2018) to encode the sequence of concatenated tokens into a sequence of embedding vectors $E ( { \pmb x } ) =$ $[ e _ { 1 } , \cdots e _ { n } ]$ , where $\boldsymbol { e } _ { i } \in \mathbb { R } ^ { m }$ . The following two strategies are used to construct two different views:
|
| 58 |
+
|
| 59 |
+
1. Global Pooling builds view $v _ { 1 } ( \pmb { x } )$ with a mean-pooling layer on top of $[ e _ { 1 } , \cdots e _ { n } ]$ , $v _ { 1 } ( \pmb { x } )$ assumes each token embedding is equally weighted:
|
| 60 |
+
|
| 61 |
+
$$
|
| 62 |
+
v _ { 1 } ( { \pmb x } ) = \sum _ { i = 1 } ^ { n } e _ { i } / n
|
| 63 |
+
$$
|
| 64 |
+
|
| 65 |
+
2. Adaptive Reception Field builds view $v _ { 2 } ( { \pmb x } )$ by adapting the synaptic weight of each token embedding based on the input $_ { \pmb { x } }$ :
|
| 66 |
+
|
| 67 |
+
$$
|
| 68 |
+
\begin{array} { r } { v _ { 2 } ( \pmb { x } ) = \displaystyle \sum _ { i = 1 } ^ { n } \frac { \exp ( \alpha _ { i } ) } { \sum _ { j = 1 } ^ { n } \exp ( \alpha _ { j } ) } \cdot \pmb { e } _ { i } } \\ { \alpha _ { i } = \sigma ( \pmb { w } _ { i } \cdot \mathrm { R e L U } ( \pmb { W } _ { 1 } \cdot \pmb { s } ) ) , } \end{array}
|
| 69 |
+
$$
|
| 70 |
+
|
| 71 |
+
where $\textbf { \textit { s } } \in \mathbb { R } ^ { n m }$ is the concatenation of all $n$ embeddings $[ e _ { 1 } , \cdots e _ { n } ]$ . $\sigma$ is the Sigmoid activation function. ${ \pmb w } _ { i } \in \mathbb { R } ^ { 1 \times r _ { 1 } } ( i = 1 , \cdot \cdot \cdot n )$ and $\pmb { W } _ { 1 } \in \mathbb { R } ^ { r _ { 1 } \times n m }$ are learnable parameters. $r _ { 1 }$ is the size of the intermediate layer. Moreover, to enhance the generalization ability, we set a small value for $r _ { 1 }$ in our implementation to form a bottleneck structure in the weighting function (Hu et al., 2017).
|
| 72 |
+
|
| 73 |
+

|
| 74 |
+
Figure 1: Framework of Caro. For each input sample ${ \pmb x } = \langle { \pmb h } , { \pmb u } \rangle$ , two views $v _ { 1 } ( \pmb { x } )$ and $v _ { 2 } ( { \pmb x } )$ are obtained and a multi-view information bottleneck loss $\mathcal { L } _ { I B }$ is optimized to learn robust representations. A two-stage training process is introduced to mine OOD samples $\mathcal { D } _ { O }$ from unlabeled data $\mathcal { D } _ { U }$ , and optimize the cross entropy loss $\mathcal { L } _ { C E }$ with $\mathcal { D } _ { O } \cup \mathcal { D } _ { I }$
|
| 75 |
+
|
| 76 |
+
Optimizing Information Bottleneck is performed in an unsupervised setting based on the two views of each sample. Specifically, we assume the representation $z _ { i }$ of each view $v _ { i } ( { \pmb x } )$ , $( i = 1 , 2 )$ ) follows a distribution that is parameterized by an encoder $p ( z | v _ { i } )$ , where $v _ { i }$ is short for ${ v } _ { i } ( { \pmb x } )$ for abbreviation. To facilitate the computation, we model $p$ as factorized Gaussian distributions, i.e., $p ( z | v _ { i } ) = \mathcal { N } [ \mu ( v _ { i } ) , \Sigma ( v _ { i } ) ]$ , in which $\mu ( v _ { i } )$ and $\Sigma ( v _ { i } )$ are two neural networks that produce the mean and deviation, respectively. The following information bottleneck loss (Federici et al., 2019) is optimized to remove superfluous information in $v _ { 1 } ( \pmb { x } )$ and $v _ { 2 } ( { \pmb x } )$ :
|
| 77 |
+
|
| 78 |
+
$$
|
| 79 |
+
\begin{array} { r } { \mathcal { L } _ { I B } = - I ( z _ { 1 } ; z _ { 2 } ) + \displaystyle \frac { 1 } { 2 } ( D _ { K L } [ p ( z | \pmb { v } _ { 1 } ) | | p ( z | \pmb { v } _ { 2 } ) ] } \\ { + D _ { K L } [ p ( z | \pmb { v } _ { 2 } ) | | p ( z | \pmb { v } _ { 1 } ) ] ) , } \end{array}
|
| 80 |
+
$$
|
| 81 |
+
|
| 82 |
+
where $I$ calculates the mutual information of two random variables, and $D _ { K L }$ calculates the KL divergence between two distributions.
|
| 83 |
+
|
| 84 |
+
# 4.2 Two-stage Self-training
|
| 85 |
+
|
| 86 |
+
Although robust representations can be obtained with the help of the information bottleneck loss $\mathcal { L } _ { I B }$ from Section 4.1, we still lack the annotations for OOD samples to train the $( k + 1 )$ -way classifier $F$ for OOD detection. In this study, we tackle this issue with a two-stage self-training process, which mines OOD samples from the unlabeled data $\mathcal { D } _ { U }$ with a bootstrapping approach. Moreover, for each input sample $_ { \pmb { x } }$ , we also aggregate its two views $v _ { 1 } ( \pmb { x } )$ and $v _ { 2 } ( { \pmb x } )$ with a dynamic gate to obtain assembled representations in training.
|
| 87 |
+
|
| 88 |
+
Stage One synthesizes pseudo OOD samples $\mathcal { D } _ { P }$ by mixing up IND features. Specifically, samples from $\mathcal { D } _ { I }$ are first mapped into IND representation vectors, and pseudo OOD samples are obtained as convex combinations of these vectors (Zhan et al., 2021). A preliminary OOD detector $F$ is trained using the classical cross-entropy loss $\mathcal { L } _ { C E }$ on these synthesized pseudo OOD samples and labeled IND samples $\mathcal { D } _ { I }$ . This stage endows $F$ with a preliminary ability to predict the intent distribution of each input sample.
|
| 89 |
+
|
| 90 |
+
Stage Two predicts a pseudo label for each sample $\mathbf { \boldsymbol { x } } \in \mathcal { D } _ { U }$ using $F$ , and then collects samples that are assigned with the OOD label $I _ { k + 1 }$ as a set of mined OOD samples $\mathcal { D } _ { O }$ . With the help of $\mathcal { D } _ { O }$ we further train the classifier $F$ on the following loss:
|
| 91 |
+
|
| 92 |
+
$$
|
| 93 |
+
\mathcal { L } = \underset { \pmb { x } \in \mathcal { D } _ { I } \cup \mathcal { D } _ { O } } { \mathbb { E } } \mathcal { L } _ { C E } + \lambda \underset { \pmb { x } \in \mathcal { D } _ { U } } { \mathbb { E } } \mathcal { L } _ { I B }
|
| 94 |
+
$$
|
| 95 |
+
|
| 96 |
+
where $\lambda$ is a scalar hyper-parameter to control the weight of the information bottleneck loss.
|
| 97 |
+
|
| 98 |
+
Multi-view Aggregation is performed to obtain assembled representations for input samples. Specifically, whenever we need to extract the representation $v ( { \pmb x } )$ for an input sample $_ { \pmb { x } }$ in the training process, we use the following aggregation approach:
|
| 99 |
+
|
| 100 |
+
$$
|
| 101 |
+
\begin{array} { c } { { v ( { \pmb x } ) = \beta \otimes v _ { 1 } ( { \pmb x } ) + ( 1 - \beta ) \otimes v _ { 2 } ( { \pmb x } ) } } \\ { { \beta = \sigma ( \mathbf { W } _ { 3 } \cdot \mathrm { R e L U } ( \mathbf { W } _ { 2 } \cdot ( v _ { 1 } ( { \pmb x } ) + v _ { 2 } ( { \pmb x } ) ) ) ) } } \end{array}
|
| 102 |
+
$$
|
| 103 |
+
|
| 104 |
+
where $\otimes$ represents the element-wise product, $\mathbf { W } _ { 2 } \in \mathbb { R } ^ { r _ { 2 } \times m }$ and $\mathbf { W } _ { 3 } \in \mathbb { R } ^ { m \times r _ { 2 } }$ are learnable parameters. $r _ { 2 }$ is the size of the intermediate layer.
|
| 105 |
+
|
| 106 |
+
The training of Caro is given in Algorithm 1.
|
| 107 |
+
|
| 108 |
+
# 5 Experiments
|
| 109 |
+
|
| 110 |
+
# 5.1 Datasets
|
| 111 |
+
|
| 112 |
+
We perform experiments on two variants of the STAR dataset (Mosig et al., 2020), i.e., STAR-Full and STAR-Small. Specifically, STAR is a taskoriented dialogue dataset that has 150 intents. It is designed to model long context dependence, and provides explicit annotations of OOD intents. Following Chen and Yu (2021), we regard samples
|
| 113 |
+
|
| 114 |
+
Input: IND data $\mathcal { D } _ { I }$ , unlabeled data $\mathcal { D } _ { U }$ . Output: A trained OOD detector $F$ . // Stage 1
|
| 115 |
+
1 Synthesize pseudo OOD samples $\mathcal { D } _ { P }$ by mixing up IND representations.
|
| 116 |
+
2 Train $F$ using the cross-entropy loss $\mathcal { L } _ { C E }$ on $\mathcal { D } _ { I } \cup \mathcal { D } _ { P }$ . // Stage 2
|
| 117 |
+
3 Mine OOD samples $\mathcal { D } _ { O }$ from $\mathcal { D } _ { U }$ using $F$ .
|
| 118 |
+
4 Train $F$ using $\mathcal { L }$ (Eq. 4) on $\mathcal { D } _ { I }$ , $\mathcal { D } _ { O }$ , and $\mathcal { D } _ { U }$
|
| 119 |
+
|
| 120 |
+
Algorithm 1: The training process of Caro
|
| 121 |
+
Table 1: Dataset statistics.
|
| 122 |
+
|
| 123 |
+
<table><tr><td rowspan="2"></td><td colspan="2">Train</td><td rowspan="2">Valid Test Dv DT</td><td rowspan="2">#Avg.( Context Turns</td></tr><tr><td>D1</td><td>Du</td></tr><tr><td>STAR-Full</td><td>15.4K</td><td>7.9K</td><td>2.8K 2.9K</td><td>6.13</td></tr><tr><td>STAR-Small</td><td>7.7K</td><td>3.9K</td><td>2.8K 2.9K</td><td>6.12</td></tr></table>
|
| 124 |
+
|
| 125 |
+
from intents “out_of_scope”, “custom”, or “ambiguous” as OOD samples and all other samples as IND samples. We also filter out generic utterances (e.g., greetings) in the pre-processing stage.
|
| 126 |
+
|
| 127 |
+
STAR-Full contains all pre-processed samples from the original STAR dataset. To construct unlabeled data $\mathcal { D } _ { U }$ , we extract $30 \%$ of IND samples and all OOD samples from the training set. The intent labels of all these extracted samples are removed, and the remaining samples in the training set are used as the labeled data $\mathcal { D } _ { I }$ . STAR-Small is constructed similarly, except that we down-sample $50 \%$ of the training set. We aim to evaluate the performance of OOD detection in low-resource scenarios with STAR-Small. Table 1 shows the statistics of these datasets.
|
| 128 |
+
|
| 129 |
+
# 5.2 Metrics
|
| 130 |
+
|
| 131 |
+
Following Zhang et al. (2021b); Shu et al. (2021), the OOD intent detection performance of our model is evaluated using the macro F1-score (F1-All) over all testing samples (i.e., IND and OOD samples). The fine-grained performance of our model is also evaluated by the macro F1-score over all IND samples (F1-IND) and OOD samples (F1-OOD), respectively. We use macro F1-scores to handle the class imbalance issue of the test set.
|
| 132 |
+
|
| 133 |
+
# 5.3 Implementation Details
|
| 134 |
+
|
| 135 |
+
Our BERT backbone is initialized with the pretrained weights of BERT-based-uncased (Devlin et al., 2018). We use AdamW, and Adam (Kingma and Ba, 2014) to fine-tune the BERT backbone and all other modules with a learning rate of 1e-5 and 1e-4, respectively. The Jensen-Shannon mutual information estimator (Hjelm et al., 2018) is used to estimate the mutual information $I$ in Eq. 3. All results reported in our paper are averages of 3 runs with different random seeds. Hyper-parameters are searched based on IND intent classification performances on the validation set. See Appendix A for more implementation details. Note that Caro only introduces little computational overhead compared to other OOD detection models (See Appendix C).
|
| 136 |
+
|
| 137 |
+
# 5.4 Baselines
|
| 138 |
+
|
| 139 |
+
Our baselines can be classified into two categories based on whether they use unlabeled data. The first set of baselines only use labeled IND samples $\mathcal { D } _ { I }$ in training: 1. MSP: (Hendrycks and Gimpel, 2017) utilizes the maximum Softmax predictions of a $k$ -way IND classifier to detect OOD inputs. We set the OOD detection threshold to 0.5 following Zhang et al. (2021a); 2. SEG: (Yan et al., 2020b) proposes a semantic-enhanced Gaussian mixture model; 3. DOC: (Shu et al., 2017) employs $k$ 1- vs-rest Sigmoid classifiers and uses the maximum predictions to detect OOD intents; 4. ADB: (Zhang et al., 2021b) learns an adaptive decision boundaries for OOD detection; 5. DAADB: (Zhang et al., 2021c) improves the baseline ADB with distanceaware intent representations; 6. Outlier: (Zhan et al., 2021) mixes convex interpolated outliers and open-domain outliers to train a $( k + 1 )$ -way classifier for OOD detection; 7. CDA: (Lee and Shalyminov, 2019) utilizes counterfeit OOD turns to detect OOD samples.
|
| 140 |
+
|
| 141 |
+
The second set of baselines uses both labeled IND samples $\mathcal { D } _ { I }$ and unlabeled samples $\mathcal { D } _ { U }$ for training. Specifically, Zeng et al. (2021b) proposes a self-supervised contrastive learning framework ASS to model discriminative features from unlabeled data with an adversarial augmentation module. We implement three variants of ASS by using different detection modules: 1. $\mathbf { A S S + M S P }$ : uses the detection module from the baseline MSP; 2. $\mathbf { A S S + L O F }$ : (Lin and Xu, 2019) implements the OOD detector as the local outlier factor; 3. ASS+GDA: (Xu et al., 2020a) uses a generative distance-based classifier with Mahalanobis distance as the detection module.
|
| 142 |
+
|
| 143 |
+
Moreover, we also report the performance of a $( k + 1 )$ -way classifier trained on fully labeled IND and OOD samples (Oracle), i.e., we preserve all labels for samples in $\mathcal { D } _ { I }$ and $\mathcal { D } _ { U }$ . This model is generally regarded as the upper bound of our model since it uses all the annotations.
|
| 144 |
+
|
| 145 |
+
<table><tr><td colspan="2">Model</td><td colspan="3">STAR-Full</td><td colspan="3">STAR-Small</td></tr><tr><td colspan="2">Oracle</td><td>F1-All 50.1</td><td>F1-OOD 64.46</td><td>F1-IND 50</td><td>F1-All 46.54</td><td>F1-OOD 58.23</td><td>F1-IND 46.46</td></tr><tr><td rowspan="10">D1</td><td>MSP</td><td>40.83</td><td>19.74</td><td>40.97</td><td>37.17</td><td>18.1</td><td>37.31</td></tr><tr><td>MSP w/o h</td><td>17.29</td><td>14.12</td><td>17.31</td><td>17.12</td><td>13.49</td><td>17.14</td></tr><tr><td>SEG</td><td>17.45</td><td>6.85</td><td>17.53</td><td>11.66</td><td>7.39</td><td>11.69</td></tr><tr><td>SEG w/o h</td><td>0.06</td><td>2.77</td><td>0.04</td><td>0.05</td><td>2.27</td><td>0.04</td></tr><tr><td>DOC</td><td>26.53</td><td>16.80</td><td>26.60</td><td>3.47</td><td>11.78</td><td>3.41</td></tr><tr><td>DOC w/o h</td><td>11.31</td><td>14.16</td><td>11.29</td><td>0.08</td><td>11.04</td><td>0</td></tr><tr><td>ADB</td><td>44.64</td><td>20.56</td><td>44.80</td><td>41.36</td><td>18.23</td><td>41.51</td></tr><tr><td>ADB w/o h</td><td>23.27</td><td>17.63</td><td>23.30</td><td>20.08</td><td>21.27</td><td>20.07</td></tr><tr><td>DAADB</td><td>37.27</td><td>22.87</td><td>37.37</td><td>34.81</td><td>20.43</td><td>34.91</td></tr><tr><td>DAADB w/o h</td><td>17.87</td><td>15.15</td><td>17.88</td><td>16.34</td><td>17.03</td><td>16.33</td></tr><tr><td>Outlier</td><td>43.84</td><td>19.53</td><td>44.01</td><td>39.51</td><td>19.92</td><td>39.64</td></tr><tr><td>Outlier w/o h</td><td>23.35</td><td>16.75</td><td>23.39</td><td>19.56</td><td>15.42</td><td>19.59</td></tr><tr><td>CDA</td><td>43.76</td><td>5.26</td><td>44.03</td><td>40.02</td><td>10.48</td><td>40.22</td></tr><tr><td rowspan="4">D1+Du</td><td>ASS+MSP</td><td>41.97</td><td>25.15</td><td>42.08</td><td>40.85</td><td>19.47</td><td>40.99</td></tr><tr><td>ASS+LOF</td><td>39.87</td><td>17.65</td><td>40.02</td><td>39.54</td><td>18.49</td><td>39.68</td></tr><tr><td>ASS+GDA</td><td>43.73</td><td>21.24</td><td>43.88</td><td>40.86</td><td>16.72</td><td>41.02</td></tr><tr><td>Caro (ours)</td><td>48.75(±1.0)</td><td>54.75(±3.2)</td><td>48.71(±1.0)</td><td>45.02(±1.1)</td><td>46.78(±1.8)</td><td>45.01(±1.1)</td></tr></table>
|
| 146 |
+
|
| 147 |
+
Table 2: Performance of Caro and baselines. All results are averages of three runs and the best results are bolded. The standard deviation of the performance of Caro is provided in parentheses.
|
| 148 |
+
|
| 149 |
+
For fair comparisons, all baselines use the same pretrained BERT-base backbones as our model. Multi-turn dialogue contexts in all baselines are modeled by concatenating utterances in dialogue histories. Moreover, to further validate the importance of dialogue contexts for OOD detection, we also implement a single-turn variant for the first set of baselines by ignoring multi-turn dialogue contexts $( \mathbf { w } / \mathbf { 0 } \ \mathbf { \mathit { h } } )$ , i.e., only the latest user issued utterance $\textbf { \em u }$ is used as the input. Note that we do not implement the single-turn variant for the baseline CDA since CDA is specifically designed to utilize multi-turn contexts. See Appendix B for more details about baselines.
|
| 150 |
+
|
| 151 |
+
# 5.5 Main Results
|
| 152 |
+
|
| 153 |
+
The results for our model Caro and all baselines are shown in Table 2. It can be seen that Caro outperforms all other baselines on both datasets with large margins. We highlight several observations: 1. Methods that model multi-turns of dialogue histories (e.g., MSP, SEG, DOC, ADB, DA-ADB, and Outlier) generally outperform their single turn counter (i.e., models marked with “w/o $\mathbf { \mathit { h } } ^ { \prime \prime }$ ) with large margins. This validates our claim that it is necessary to consider multi-turn dialogue contexts for OOD intent detection since users’ intents may depend on prior turns. 2. Our method Caro outperforms all baselines that only use IND data $\mathcal { D } _ { I }$ . The performance gain demonstrates the advantage of incorporating unlabeled data for OOD detection, which can be used to learn compact representations for both IND and OOD intents. 3. Caro also outperforms baselines that utilize unlabeled data $\mathcal { D } _ { U }$ . This validates Caro’s effectiveness in tackling the long distance obstacle and modeling unlabeled samples. Our baselines are prone to capture irrelevant noises for OOD intent detection, while Caro incorporates multi-view information bottleneck loss to remove superfluous information.
|
| 154 |
+
|
| 155 |
+
We also analyze the effect of unlabeled data size (Appendix E) and $\lambda$ (Appendix F) on the OOD intent detection performance and carry out a case study (Appendix G).
|
| 156 |
+
|
| 157 |
+
# 5.6 Ablation Studies
|
| 158 |
+
|
| 159 |
+
To validate our motivation and model design, we ablate our model components and loss terms.
|
| 160 |
+
|
| 161 |
+
Model Components: Ablation studies are carried out to validate the effectiveness of each component in Caro. Specifically, the following variants are investigated: 1. w/o $\mathcal { D } _ { U }$ removes training stage two, i.e., only $\mathcal { D } _ { I }$ is used for training. 2. w/o MV ablates the multi-view construction approach introduced in Caro. Specifically, we adopt the approach used by Gao et al. (2021) to perform two dropouts with two different masks when constructing these two views. 3. w/o VA ablates the multi-view aggregation approach, i.e., the representations of two views are directly added instead of using the adaptive gate in Eq. 5. 4. w/o IB removes the information bottleneck loss $\mathcal { L } _ { I B }$ . We implement this variant by setting $\lambda = 0$ in Eq.4.
|
| 162 |
+
|
| 163 |
+
Table 3: Ablation on different components of Caro.
|
| 164 |
+
|
| 165 |
+
<table><tr><td>Model</td><td colspan="3">STAR-Full F1-Al1 F1-00D F1-IND</td><td colspan="3">STAR-Small F1-All F1-OOD F1-IND</td></tr><tr><td>Caro</td><td>48.75</td><td>54.75</td><td>48.71</td><td>45.02</td><td>46.78</td><td>45.01</td></tr><tr><td>w/o Du</td><td>45.97</td><td>21.45</td><td>46.14</td><td>42.24</td><td>23.23</td><td>42.37</td></tr><tr><td>w/o MV</td><td>47.71</td><td>53.35</td><td>47.67</td><td>44.42</td><td>38.89</td><td>44.46</td></tr><tr><td>w/o VA</td><td>47.34</td><td>50.85</td><td>47.32</td><td>44.14</td><td>43.88</td><td>44.15</td></tr><tr><td>w/o IB</td><td>48.23</td><td>49.37</td><td>48.22</td><td>44.14</td><td>37.06</td><td>44.19</td></tr></table>
|
| 166 |
+
|
| 167 |
+
Table 4: Ablation on the representation learning loss.
|
| 168 |
+
|
| 169 |
+
<table><tr><td>Model</td><td colspan="3">STAR-Full F1-All F1-OOD F1-IND</td><td colspan="3">STAR-Small F1-All F1-OOD F1-IND</td></tr><tr><td>Caro</td><td>48.75</td><td>54.75</td><td>48.71</td><td>45.02</td><td>46.78</td><td>45.01</td></tr><tr><td>InfoMax</td><td>47.27</td><td>49.92</td><td>47.25</td><td>44.27</td><td>36.66</td><td>44.32</td></tr><tr><td>MVI</td><td>48.46</td><td>51.99</td><td>48.44</td><td>44.70</td><td>36.16</td><td>44.76</td></tr><tr><td>CL</td><td>48.18</td><td>52.54</td><td>48.15</td><td>44.59</td><td>35.31</td><td>44.65</td></tr><tr><td>SimCSE</td><td>47.73</td><td>47.74</td><td>47.73</td><td>44.30</td><td>27.02</td><td>44.42</td></tr></table>
|
| 170 |
+
|
| 171 |
+
Results in Table 3 indicate that Caro outperforms all ablation variants. Specifically, we can also observe that: 1. Training models without unlabeled data (i.e., w/o $\mathcal { D } _ { U }$ ) degenerate the performance of Caro by a large margin. The F1-OOD score suffers an absolute decrease of $3 3 . 3 \%$ and $2 3 . 6 \%$ on STAR-FULL and STAR-Small, respectively. This validates our claim that effective utilization of unlabeled data improves the performance of OOD detection. 2. Our multi-view construction approach helps to improve the OOD detection performance (see w/o MV), and our multi-view aggregation approach also benefits the extracted representation (see w/o VA). 3. Removing the multi-view information bottleneck loss (i.e., w/o IB) degenerates the OOD performance. This validates our claim that multi-turn contexts may contain irrelevant noises for OOD intent detection.
|
| 172 |
+
|
| 173 |
+
Information Bottleneck Loss: We further demonstrate the effectiveness of our information bottleneck loss $\mathcal { L } _ { I B }$ by replacing $\mathcal { L } _ { I B }$ in Eq. 4 with other alternatives of representation learning. Specifically, assume $_ { \pmb { x } }$ is an input sample. 1. InfoMax (Poole et al., 2019) maximizes the mutual information between $_ { \pmb { x } }$ and its representation $_ z$ : $I ( { \pmb x } ; z )$ ; 2. MVI (Bachman et al., 2019) is similar to InfoMax except that it maximizes the mutual information between $_ { \pmb { x } }$ ’s two views $I ( v _ { 1 } ( { \pmb x } ) ; v _ { 2 } ( { \pmb x } ) )$ ; Note that both InfoMax and MVI do not attempt to remove superficial information from representations. 3. CL (Caron et al., 2020) uses a contrastive learning loss. Positive pairs in this variant are obtained using our multi-view construction approach. 4. SimCSE (Gao et al., 2021) is similar to CL except that it acquires positive pairs by two different dropouts on the BERT encoder.
|
| 174 |
+
|
| 175 |
+

|
| 176 |
+
Figure 2: Comparing representations obtained by different objectives on the STAR-Full dataset. A lower score means that the learned representation discards more superficial information. See Appendix D for measurements used to produce the graph.
|
| 177 |
+
|
| 178 |
+
Results in Table 4 show that the information bottleneck loss used in Caro performs better than all other variants. We also want to highlight that the approach of explicitly removing superficial information in Caro makes it outperform InfoMax and MVI by $4 . 8 3 \%$ and $2 . 7 6 \%$ , respectively, on the F1-OOD score. This validates our claim that long contexts may contain superficial information that degenerates intent detection, and the multi-view information bottleneck loss used in Caro effectively removes this superficial information.
|
| 179 |
+
|
| 180 |
+
Moreover, we also perform fine-grained analysis of the learned representations following Tishby et al. (2000). Specifically, for an input sample $_ { \pmb { x } }$ with a label of $y$ and an extracted representation of $_ z$ , two scores are calculated: 1. Observational information score (measured by $I ( { \pmb x } ; z ) )$ ; 2. Predictive ability score (measured by $I ( z ; y ) )$ . An ideal representation would be maximally predictive about the label while retaining a minimal amount of information from the observations (Tishby et al., 2000; Federici et al., 2019). Here we report the score of $I ( { \pmb x } ; z ) - I ( z ; y )$ for Caro, MVI and InforMax in Figure 2. It can be seen that the information bottleneck loss helps Caro to achieve the lowest $I ( { \pmb x } ; z ) - I ( z ; y )$ score. This indicates that representations learned in Caro retrain low observational information while achieving a relatively
|
| 181 |
+
|
| 182 |
+
<table><tr><td colspan="2">Context Len</td><td>F1-All</td><td>F1-00D</td><td>F1-IND</td></tr><tr><td rowspan="2">Long</td><td>w/o IB</td><td>44.14</td><td>37.06</td><td>44.19</td></tr><tr><td>wIB</td><td>45.02 (+0.88)</td><td>46.78 (+9.72)</td><td>45.01 (+0.82)</td></tr><tr><td rowspan="2">Short</td><td>w/o IB</td><td>43.61</td><td>40.68</td><td>43.63</td></tr><tr><td>wIB</td><td>43.70 (+0.09)</td><td>43.32 (+2.64)</td><td>43.70 (+0.07)</td></tr></table>
|
| 183 |
+
|
| 184 |
+
Table 5: Benefit of $\mathcal { L } _ { I B }$ under different context lengths on the STAR-Small dataset. Long context means retaining all the original dialogue contexts (6 turns on average), and short context means truncating contexts longer than 3 turns. Scores in parentheses is the performance improvement brought by $\mathcal { L } _ { I B }$
|
| 185 |
+
|
| 186 |
+

|
| 187 |
+
Figure 3: Difference of averaged weight score at each token index for testing samples from STAR-Full.
|
| 188 |
+
|
| 189 |
+

|
| 190 |
+
Figure 4: Difference of averaged aggregation weights at each dimension for testing samples in STAR-Full.
|
| 191 |
+
|
| 192 |
+
diversity of our two views (Section 4.1) by visualizing the distribution of weight score $\alpha _ { i }$ in Eq. 2. Specifically, we first calculate the average weight scores received at each token index for samples from the same intent (we use a max sequence length of 256). Then we choose two intents (i.e., weather_inform_forecast and trip_inform_simple_step_ask_proceed) and visualize the difference between their averaged weight score at each token index in Figure 3. It can be seen that weight scores change sharply across different intents and token indices. That means the view $v _ { 2 } ( { \pmb x } )$ constructed for each sample is diverse.
|
| 193 |
+
|
| 194 |
+
high predictive ability.
|
| 195 |
+
|
| 196 |
+
# 5.7 Further Analysis
|
| 197 |
+
|
| 198 |
+
Benefit of $\mathcal { L } _ { I B }$ in Different Context Lengths We also validate the benefit of our information bottleneck loss $\mathcal { L } _ { I B }$ (Eq. 3) under different context lengths. Specifically, we construct a variant of STAR-Small (denoted as “Short”) by truncating contexts longer than 3 turns, i.e., the dialogue histories before the latest 3 turns are discarded. We also denote the original STAR-Small dataset as “Long”, which has a maximum context length of 7 turns. Caro’s performance with and without $\mathcal { L } _ { I B }$ , i.e., “w IB” and “w/o IB” is tested on these two datasets.
|
| 199 |
+
|
| 200 |
+
Results in Table 5 show that Caro benefits more from $\mathcal { L } _ { I B }$ in longer contexts. Specifically, the longer the context, the larger improvement is brought by $\mathcal { L } _ { I B }$ on the OOD detection performance. This further validates our claim that our information bottleneck loss $\mathcal { L } _ { I B }$ helps remove superficial information unrelated to intent detection.
|
| 201 |
+
|
| 202 |
+
Diversity of Adaptive Reception Field Our multi-view information bottleneck objective expects two diverse views for each input sample (Federici et al., 2019). Here we validate the
|
| 203 |
+
|
| 204 |
+
Analysis of Aggregation Weights We also visualize the weight $\beta$ used in the multi-view aggregation process (Eq. 5). Specifically, we expect these two views in Eq. 5 to receive different weights. Concretely, we first calculate the averaged $\beta$ vector for all testing samples from STAR-Small. Then we calculate the difference of weights received by these two views $v _ { 1 } ( \pmb { x } )$ and $v _ { 2 } ( { \pmb x } )$ in Eq. 5, and visualize values in each dimension in Figure 4. It can be seen that diverse weights are used in the multi-view aggregation process.
|
| 205 |
+
|
| 206 |
+
# 6 Conclusion
|
| 207 |
+
|
| 208 |
+
In this paper, we propose Caro, a novel OOD intent detection framework to explore OOD detection in multi-turn settings. Caro learns robust representations by building diverse views of an input and optimise an unsupervised multi-view loss following the information bottleneck principle. OOD samples are mined from unlabeled data, which are used to train a $( k + 1 )$ -way multi-view classifier as the resulting OOD detector. Extensive experiments demonstrate that Caro is effective as modeling multi-turn contexts and outperforms SOTA baselines.
|
| 209 |
+
|
| 210 |
+
# Limitations
|
| 211 |
+
|
| 212 |
+
One major limitation of this work is its input modality. Specifically, our method is limited to textual inputs and ignores inputs in other modalities such as audio, vision, or robotic features. These modalities provide valuable information that can be used to build better OOD detectors. In future works, we will try to model multi-modal multi-turn contexts for OOD intent detection.
|
| 213 |
+
|
| 214 |
+
# Ethics Statement
|
| 215 |
+
|
| 216 |
+
This work does not present any direct ethical issues. In the proposed work, we seek to develop a contextaware method for OOD intent detection, and we believe this study leads to intellectual merits that benefit from a reliable application of NLU models. All experiments are conducted on open datasets.
|
| 217 |
+
|
| 218 |
+
# References
|
| 219 |
+
|
| 220 |
+
Philip Bachman, R Devon Hjelm, and William Buchwalter. 2019. Learning representations by maximizing mutual information across views. Advances in neural information processing systems, 32.
|
| 221 |
+
|
| 222 |
+
Mathilde Caron, Ishan Misra, Julien Mairal, Priya Goyal, Piotr Bojanowski, and Armand Joulin. 2020. Unsupervised learning of visual features by contrasting cluster assignments. Advances in Neural Information Processing Systems, 33:9912–9924.
|
| 223 |
+
|
| 224 |
+
Derek Chen and Zhou Yu. 2021. Gold: Improving out-of-scope detection in dialogues using data augmentation. In Proceedings of the 2021 Conference on Empirical Methods in Natural Language Processing, pages 429–442.
|
| 225 |
+
|
| 226 |
+
Hongshen Chen, Xiaorui Liu, Dawei Yin, and Jiliang Tang. 2017. A survey on dialogue systems: Recent advances and new frontiers. Acm Sigkdd Explorations Newsletter, 19(2):25–35.
|
| 227 |
+
|
| 228 |
+
Yulong Chen, Yang Liu, Liang Chen, and Yue Zhang. 2021. Dialogsum: A real-life scenario dialogue summarization dataset. In Findings of the Association for Computational Linguistics: ACL-IJCNLP 2021, pages 5062–5074.
|
| 229 |
+
|
| 230 |
+
Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. 2018. Bert: Pre-training of deep bidirectional transformers for language understanding. arXiv preprint arXiv:1810.04805.
|
| 231 |
+
|
| 232 |
+
Thomas G Dietterich. 2017. Steps toward robust artificial intelligence. Ai Magazine, 38(3):3–24.
|
| 233 |
+
|
| 234 |
+
Marco Federici, Anjan Dutta, Patrick Forré, Nate Kushman, and Zeynep Akata. 2019. Learning robust representations via multi-view information bottleneck.
|
| 235 |
+
|
| 236 |
+
In International Conference on Learning Representations.
|
| 237 |
+
|
| 238 |
+
Geli Fei and Bing Liu. 2016. Breaking the closed world assumption in text classification. In Proceedings of the 2016 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, pages 506–514.
|
| 239 |
+
|
| 240 |
+
Yarin Gal and Zoubin Ghahramani. 2016. Dropout as a bayesian approximation: Representing model uncertainty in deep learning. In international conference on machine learning, pages 1050–1059. PMLR.
|
| 241 |
+
|
| 242 |
+
Varun Gangal, Abhinav Arora, Arash Einolghozati, and Sonal Gupta. 2020. Likelihood ratios and generative classifiers for unsupervised out-of-domain detection in task oriented dialog. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 34, pages 7764–7771.
|
| 243 |
+
|
| 244 |
+
Tianyu Gao, Xingcheng Yao, and Danqi Chen. 2021. SimCSE: Simple contrastive learning of sentence embeddings. In Empirical Methods in Natural Language Processing (EMNLP).
|
| 245 |
+
|
| 246 |
+
Chuanxing Geng, Sheng-jun Huang, and Songcan Chen. 2020. Recent advances in open set recognition: A survey. IEEE transactions on pattern analysis and machine intelligence, 43(10):3614–3631.
|
| 247 |
+
|
| 248 |
+
Deepanway Ghosal, Navonil Majumder, Rada Mihalcea, and Soujanya Poria. 2021. Exploring the role of context in utterance-level emotion, act and intent classification in conversations: An empirical study. In Findings of the Association for Computational Linguistics: ACL-IJCNLP 2021, pages 1435–1449.
|
| 249 |
+
|
| 250 |
+
Dan Hendrycks and Kevin Gimpel. 2017. A baseline for detecting misclassified and out-of-distribution examples in neural networks. In International Conference on Learning Representations.
|
| 251 |
+
|
| 252 |
+
Dan Hendrycks, Mantas Mazeika, and Thomas Dietterich. 2018. Deep anomaly detection with outlier exposure. In International Conference on Learning Representations.
|
| 253 |
+
|
| 254 |
+
R Devon Hjelm, Alex Fedorov, Samuel LavoieMarchildon, Karan Grewal, Phil Bachman, Adam Trischler, and Yoshua Bengio. 2018. Learning deep representations by mutual information estimation and maximization. In International Conference on Learning Representations.
|
| 255 |
+
|
| 256 |
+
Jie Hu, Li Shen, Samuel Albanie, Gang Sun, and Enhua Wu. 2017. Squeeze-and-excitation networks. IEEE Transactions on Pattern Analysis and Machine Intelligence, 42:2011–2023.
|
| 257 |
+
|
| 258 |
+
Di Jin, Shuyang Gao, Seokhwan Kim, Yang Liu, and Dilek Hakkani-Tür. 2022. Towards textual out-of-domain detection without in-domain labels. IEEE/ACM Transactions on Audio, Speech, and Language Processing, 30:1386–1395.
|
| 259 |
+
|
| 260 |
+
Diederik P Kingma and Jimmy Ba. 2014. Adam: A method for stochastic optimization. arXiv preprint arXiv:1412.6980.
|
| 261 |
+
|
| 262 |
+
Balaji Lakshminarayanan, Alexander Pritzel, and Charles Blundell. 2017. Simple and scalable predictive uncertainty estimation using deep ensembles. Advances in neural information processing systems, 30.
|
| 263 |
+
|
| 264 |
+
Kimin Lee, Kibok Lee, Honglak Lee, and Jinwoo Shin. 2018. A simple unified framework for detecting outof-distribution samples and adversarial attacks. Advances in neural information processing systems, 31.
|
| 265 |
+
|
| 266 |
+
Sungjin Lee and Igor Shalyminov. 2019. Contextual outof-domain utterance handling with counterfeit data augmentation. In ICASSP 2019-2019 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP), pages 7205–7209. IEEE.
|
| 267 |
+
|
| 268 |
+
Jiaqi Li, Ming Liu, Min-Yen Kan, Zihao Zheng, Zekun Wang, Wenqiang Lei, Ting Liu, and Bing Qin. 2020. Molweni: A challenge multiparty dialogues-based machine reading comprehension dataset with discourse structure. In Proceedings of the 28th International Conference on Computational Linguistics, pages 2642–2652.
|
| 269 |
+
|
| 270 |
+
Ting-En Lin and Hua Xu. 2019. Deep unknown intent detection with margin loss. In Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics, pages 5491–5496.
|
| 271 |
+
|
| 272 |
+
Jiexi Liu, Ryuichi Takanobu, Jiaxin Wen, Dazhen Wan, Hongguang Li, Weiran Nie, Cheng Li, Wei Peng, and Minlie Huang. 2021. Robustness testing of language understanding in task-oriented dialog. 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 2467–2480.
|
| 273 |
+
|
| 274 |
+
Weitang Liu, Xiaoyun Wang, John Owens, and Yixuan Li. 2020. Energy-based out-of-distribution detection. Advances in Neural Information Processing Systems, 33.
|
| 275 |
+
|
| 276 |
+
Petr Marek, Vishal Ishwar Naik, Anuj Goyal, and Vincent Auvray. 2021. Oodgan: Generative adversarial network for out-of-domain data generation. In Proceedings of the 2021 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies: Industry Papers, pages 238–245.
|
| 277 |
+
|
| 278 |
+
Johannes EM Mosig, Shikib Mehri, and Thomas Kober. 2020. Star: A schema-guided dialog dataset for transfer learning. arXiv preprint arXiv:2010.11853.
|
| 279 |
+
|
| 280 |
+
Biraj Pandey, Marius Pachitariu, Bingni W. Brunton, and Kameron Decker Harris. 2022. Structured random receptive fields enable informative sensory encodings. bioRxiv.
|
| 281 |
+
|
| 282 |
+
Mark W Pettet and Charles D Gilbert. 1992. Dynamic changes in receptive-field size in cat primary visual cortex. Proceedings of the National Academy of Sciences, 89(17):8366–8370.
|
| 283 |
+
|
| 284 |
+
Alexander Podolskiy, Dmitry Lipin, Andrey Bout, Ekaterina Artemova, and Irina Piontkovskaya. 2021. Revisiting mahalanobis distance for transformer-based out-of-domain detection. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 35, pages 13675–13682.
|
| 285 |
+
|
| 286 |
+
Ben Poole, Sherjil Ozair, Aaron Van Den Oord, Alex Alemi, and George Tucker. 2019. On variational bounds of mutual information. In International Conference on Machine Learning, pages 5171–5180. PMLR.
|
| 287 |
+
|
| 288 |
+
Libo Qin, Tianbao Xie, Wanxiang Che, and Ting Liu. 2021. A survey on spoken language understanding: Recent advances and new frontiers. In IJCAI.
|
| 289 |
+
|
| 290 |
+
Jie Ren, Peter J Liu, Emily Fertig, Jasper Snoek, Ryan Poplin, Mark Depristo, Joshua Dillon, and Balaji Lakshminarayanan. 2019. Likelihood ratios for outof-distribution detection. Advances in Neural Information Processing Systems, 32.
|
| 291 |
+
|
| 292 |
+
Seonghan Ryu, Seokhwan Kim, Junhwi Choi, Hwanjo Yu, and Gary Geunbae Lee. 2017. Neural sentence embedding using only in-domain sentences for outof-domain sentence detection in dialog systems. Pattern Recognition Letters, 88:26–32.
|
| 293 |
+
|
| 294 |
+
Michael P Sceniak, Dario L Ringach, Michael J Hawken, and Robert Shapley. 1999. Contrast’s effect on spatial summation by macaque v1 neurons. Nature neuroscience, 2(8):733–739.
|
| 295 |
+
|
| 296 |
+
Walter J Scheirer, Anderson de Rezende Rocha, Archana Sapkota, and Terrance E Boult. 2012. Toward open set recognition. IEEE transactions on pattern analysis and machine intelligence, 35(7):1757– 1772.
|
| 297 |
+
|
| 298 |
+
Yilin Shen, Yen-Chang Hsu, Avik Ray, and Hongxia Jin. 2021. Enhancing the generalization for intent classification and out-of-domain detection in slu. 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 2443– 2453.
|
| 299 |
+
|
| 300 |
+
Lei Shu, Yassine Benajiba, Saab Mansour, and Yi Zhang. 2021. Odist: Open world classification via distributionally shifted instances. In Findings of the Association for Computational Linguistics: EMNLP 2021, pages 3751–3756.
|
| 301 |
+
|
| 302 |
+
Lei Shu, Hu Xu, and Bing Liu. 2017. Doc: Deep open classification of text documents. In Proceedings of the 2017 Conference on Empirical Methods in Natural Language Processing, pages 2911–2916.
|
| 303 |
+
|
| 304 |
+
Lothar Spillmann, Birgitta Dresp-Langley, and ChiaHuei Tseng. 2015. Beyond the classical receptive field: The effect of contextual stimuli. Journal of Vision, 15(9):7–7.
|
| 305 |
+
|
| 306 |
+
Ming Tan, Yang Yu, Haoyu Wang, Dakuo Wang, Saloni Potdar, Shiyu Chang, and Mo Yu. 2019. Out-ofdomain detection for low-resource text classification tasks. 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), pages 3566–3572, Hong Kong, China. Association for Computational Linguistics.
|
| 307 |
+
|
| 308 |
+
Naftali Tishby, Fernando C Pereira, and William Bialek. 2000. The information bottleneck method. arXiv preprint physics/0004057.
|
| 309 |
+
|
| 310 |
+
Xing Wang, Juan Zhao, Lin Zhu, Xu Zhou, Zhao Li, Junlan Feng, Chao Deng, and Yong Zhang. 2021. Adaptive multi-receptive field spatial-temporal graph convolutional network for traffic forecasting. In 2021 IEEE Global Communications Conference (GLOBECOM), pages 1–7.
|
| 311 |
+
|
| 312 |
+
Zhen Wei, Yao Sun, Jinqiao Wang, Hanjiang Lai, and Si Liu. 2017. Learning adaptive receptive fields for deep image parsing network. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR).
|
| 313 |
+
|
| 314 |
+
Henry Weld, Xiaoqi Huang, Siqu Long, Josiah Poon, and Soyeon Caren Han. 2021. A survey of joint intent detection and slot filling models in natural language understanding. ACM Computing Surveys (CSUR).
|
| 315 |
+
|
| 316 |
+
Thomas Wolf, Julien Chaumond, Lysandre Debut, Victor Sanh, Clement Delangue, Anthony Moi, Pierric Cistac, Morgan Funtowicz, Joe Davison, Sam Shleifer, et al. 2020. Transformers: State-of-theart natural language processing. In Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing: System Demonstrations, pages 38–45.
|
| 317 |
+
|
| 318 |
+
Thomas Wolf, Lysandre Debut, Victor Sanh, Julien Chaumond, Clement Delangue, Anthony Moi, Pierric Cistac, Tim Rault, Rémi Louf, Morgan Funtowicz, et al. 2019. Huggingface’s transformers: State-ofthe-art natural language processing. arXiv preprint arXiv:1910.03771.
|
| 319 |
+
|
| 320 |
+
Yanan Wu, Keqing He, Yuanmeng Yan, QiXiang Gao, Zhiyuan Zeng, Fujia Zheng, Lulu Zhao, Huixing Jiang, Wei Wu, and Weiran Xu. 2022. Revisit overconfidence for OOD detection: Reassigned contrastive learning with adaptive class-dependent threshold. In Proceedings of the 2022 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, pages 4165–4179, Seattle, United States. Association for Computational Linguistics.
|
| 321 |
+
|
| 322 |
+
Hong Xu, Keqing He, Yuanmeng Yan, Sihong Liu, Zijun Liu, and Weiran Xu. 2020a. A deep generative distance-based classifier for out-of-domain detection with mahalanobis space. In Proceedings of the 28th International Conference on Computational Linguistics, pages 1452–1460.
|
| 323 |
+
|
| 324 |
+
Jin Xu, Zishan Li, Bowen Du, Miaomiao Zhang, and Jing Liu. 2020b. Reluplex made more practical: Leaky relu. In 2020 IEEE Symposium on Computers and communications (ISCC), pages 1–7. IEEE.
|
| 325 |
+
|
| 326 |
+
Keyang Xu, Tongzheng Ren, Shikun Zhang, Yihao Feng, and Caiming Xiong. 2021. Unsupervised outof-domain detection via pre-trained transformers. 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 1052– 1061, Online. Association for Computational Linguistics.
|
| 327 |
+
|
| 328 |
+
Guangfeng Yan, Lu Fan, Qimai Li, Han Liu, Xiaotong Zhang, Xiao-Ming Wu, and Albert Y.S. Lam. 2020a. Unknown intent detection using Gaussian mixture model with an application to zero-shot intent classification. In Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics, pages 1050–1060, Online. Association for Computational Linguistics.
|
| 329 |
+
|
| 330 |
+
Guangfeng Yan, Lu Fan, Qimai Li, Han Liu, Xiaotong Zhang, Xiao-Ming Wu, and Albert YS Lam. 2020b. Unknown intent detection using gaussian mixture model with an application to zero-shot intent classification. In Proceedings of the 58th annual meeting of the association for computational linguistics, pages 1050–1060.
|
| 331 |
+
|
| 332 |
+
Zhiyuan Zeng, Keqing He, Yuanmeng Yan, Zijun Liu, Yanan Wu, Hong Xu, Huixing Jiang, and Weiran Xu. 2021a. Modeling discriminative representations for out-of-domain detection with supervised contrastive learning. 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), pages 870–878, Online. Association for Computational Linguistics.
|
| 333 |
+
|
| 334 |
+
Zhiyuan Zeng, Keqing He, Yuanmeng Yan, Hong Xu, and Weiran Xu. 2021b. Adversarial self-supervised learning for out-of-domain detection. In Proceedings of the 2021 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, pages 5631–5639.
|
| 335 |
+
|
| 336 |
+
Li-Ming Zhan, Haowen Liang, Bo Liu, Lu Fan, XiaoMing Wu, and Albert YS Lam. 2021. Out-of-scope intent detection with self-supervision and discriminative training. 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 3521–3532.
|
| 337 |
+
|
| 338 |
+
Hanlei Zhang, Xiaoteng Li, Hua Xu, Panpan Zhang, Kang Zhao, and Kai Gao. 2021a. TEXTOIR: An integrated and visualized platform for text open intent recognition. In Proceedings of the 59th Annual Meeting of the Association for Computational Linguistics and the 11th International Joint Conference on Natural Language Processing: System Demonstrations, pages 167–174.
|
| 339 |
+
|
| 340 |
+
Hanlei Zhang, Hua Xu, and Ting-En Lin. 2021b. Deep open intent classification with adaptive decision boundary. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 35, pages 14374– 14382.
|
| 341 |
+
|
| 342 |
+
Hanlei Zhang, Hua Xu, Shaojie Zhao, and Qianrui Zhou. 2021c. Learning discriminative representations and decision boundaries for open intent detection.
|
| 343 |
+
|
| 344 |
+
Jing Zhao, Xijiong Xie, Xin Xu, and Shiliang Sun. 2017. Multi-view learning overview: Recent progress and new challenges. Information Fusion, 38:43–54.
|
| 345 |
+
|
| 346 |
+
Wenxuan Zhou, Fangyu Liu, and Muhao Chen. 2021. Contrastive out-of-distribution detection for pretrained transformers. In Proceedings of the 2021 Conference on Empirical Methods in Natural Language Processing, pages 1100–1111, Online and Punta Cana, Dominican Republic. Association for Computational Linguistics.
|
| 347 |
+
|
| 348 |
+
Yunhua Zhou, Peiju Liu, and Xipeng Qiu. 2022. Knncontrastive learning for out-of-domain intent classification. In Proceedings of the 60th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pages 5129–5141.
|
| 349 |
+
|
| 350 |
+
# A More Implementation Details
|
| 351 |
+
|
| 352 |
+
We use Huggingface’s Transformers library (Wolf et al., 2020) and train with the backbone of BERT (Devlin et al., 2018). The max_seq_length is 256 for BertTokenize. The classification head is implemented as two-layer MLPs with the LeakyReLU activation ( $\mathrm { \Delta X u }$ et al., 2020b), while the projection heads in $\mu ( v _ { i } )$ and $\Sigma ( v _ { i } )$ as three-layer MLPs. The projection dimension is 64. Following (Zhan et al., 2021), We use AdamW (Kingma and Ba, 2014) to fine-tune BERT using a learning rate of 1e-5 and Adam (Wolf et al., 2019) to train the MLP heads using a learning rate of 1e-4. Following (Federici et al., 2019), we use Jensen-Shannon mutual information estimator (Hjelm et al., 2018) to maximize mutual information between two random variables. In the training stage, 15 epochs of pretraining are first conducted, and then 10 epochs of training are conducted by adding the process of unsupervised representation learning on unlabeled data with early stopping. The batch size is 25 for IND and unlabeled datasets, respectively. We set the weight $\lambda$ for $\mathcal { L } _ { I B }$ to be 0.5 in all experiments. And we set $r _ { 1 } ~ = ~ 1 6$ and $r _ { 2 } ~ = ~ 4 8$ . All results reported in our paper are averages of 3 runs with different random seeds, and each run is stopped when we reach a plateau on the validation performance. Hyper-parameters are searched based on IND intent classification performances on the validation set. All experiments are conducted in the Nvidia Tesla V100-SXM2 GPU with 32G graphical memory.
|
| 353 |
+
|
| 354 |
+
# B More Details about Baselines
|
| 355 |
+
|
| 356 |
+
We get the baseline results (MSP, SEG, DOC, ADB, and DA-ADB) using the OOD detection toolkit TEXTOIR (Zhang et al., 2021a). We get the baseline result of Outlier by running their released codes (Zhan et al., 2021). We re-implement CDA by using counterfeit OOD turns (Lee and Shalyminov, 2019). We re-implement ASS (Zeng et al., 2021b) based on the code of authors (Zeng et al., 2021a). For fair comparisons, all baselines are implemented by using BERT as the backbone.
|
| 357 |
+
|
| 358 |
+
C Computational Cost Analysis
|
| 359 |
+
Table 6: Number of parameters (Million), average training time for each epoch (minutes) and the total time for testing (seconds) on STAR-Full dataset.
|
| 360 |
+
|
| 361 |
+
<table><tr><td>Methods</td><td>#Para.</td><td>Training Time</td><td>Testing Time</td></tr><tr><td>Outlier</td><td>111.47 M</td><td>7.26 min</td><td>14.46 s</td></tr><tr><td>Caro</td><td>116.80 M</td><td>8.75 min</td><td>14.53 s</td></tr></table>
|
| 362 |
+
|
| 363 |
+

|
| 364 |
+
|
| 365 |
+
We compare the computational cost of a vanilla OOD detector Outlier (Zhan et al., 2021) and Caro. We use the STAR-Full dataset for this analysis. As shown in Table 6, Caro only introduces marginal parameter overhead. We can also observe that using Caro only introduces a little time overhead compared to Outlier.
|
| 366 |
+
|
| 367 |
+
# D More Details about Measurements Used to Produce the Graph
|
| 368 |
+
|
| 369 |
+
The mutual information estimation $\scriptstyle ( I ( x ; z )$ and $I ( z ; y ) ,$ ) reported in Figure 2 are computed by training two estimation networks from scratch on the final representation of Caro. Following (Federici et al., 2019), we use Jensen-Shannon mutual information estimator (Hjelm et al., 2018) to maximize mutual information between two random variables.
|
| 370 |
+
|
| 371 |
+

|
| 372 |
+
|
| 373 |
+

|
| 374 |
+
|
| 375 |
+
The two estimation architectures consist of threelayer MLPs. We report average numerical estimations of mutual information using an energy-based bound (Poole et al., 2019) on the test dataset. To reduce the variance of the estimator, the lowest and highest $5 \%$ are removed before averaging.
|
| 376 |
+
|
| 377 |
+
# E Analysis for Unlabeled Data Size
|
| 378 |
+
|
| 379 |
+
Table 7 demonstrates the effect of unlabeled data size for Caro. We downsample $100 \%$ , $7 5 \%$ , $50 \%$ , and $25 \%$ of the unlabeled data from STAR-Small and evaluate the performance of Caro. It can be seen that our method Caro achieves superior OOD detection performance in term of F1-OOD along with the increase of unlabeled data.
|
| 380 |
+
|
| 381 |
+
Table 7: Effect of unlabeled data size on the OOD intent detection performance. The reported performance are produced on the STAR-Small dataset.
|
| 382 |
+
|
| 383 |
+
<table><tr><td rowspan=1 colspan=1>DownSample-Rate</td><td rowspan=1 colspan=1>F1-All</td><td rowspan=1 colspan=1>F1-OOD</td><td rowspan=1 colspan=1>F1-IND</td></tr><tr><td rowspan=4 colspan=1>100%75%50%25%</td><td rowspan=1 colspan=1>45.02</td><td rowspan=1 colspan=1>46.78</td><td rowspan=1 colspan=1>45.01</td></tr><tr><td rowspan=1 colspan=1>44.40</td><td rowspan=1 colspan=1>37.77</td><td rowspan=1 colspan=1>44.44</td></tr><tr><td rowspan=1 colspan=1>45.04</td><td rowspan=1 colspan=1>30.13</td><td rowspan=1 colspan=1>45.15</td></tr><tr><td rowspan=1 colspan=1>44.47</td><td rowspan=1 colspan=1>20.76</td><td rowspan=1 colspan=1>44.62</td></tr></table>
|
| 384 |
+
|
| 385 |
+
# F Analysis for Loss Weight $\lambda$
|
| 386 |
+
|
| 387 |
+
Tabel 8 reports the OOD detection results as we vary the weight $\lambda$ for $\mathcal { L } _ { I B }$ in Eq. 4. The results indicate that a relatively small weight is desirable.
|
| 388 |
+
|
| 389 |
+
Table 8: Effect of $\lambda$ on the OOD intent detection performance. The reported performance are produced on the STAR-Full dataset.
|
| 390 |
+
|
| 391 |
+
<table><tr><td>入</td><td>F1-All</td><td>F1-0OD</td><td>F1-IND</td></tr><tr><td>0.3</td><td>47.57</td><td>55.68</td><td>47.51</td></tr><tr><td>0.4</td><td>48.10</td><td>51.44</td><td>48.08</td></tr><tr><td>0.5</td><td>48.75</td><td>54.75</td><td>48.71</td></tr><tr><td>0.6</td><td>47.15</td><td>50.84</td><td>47.12</td></tr><tr><td>0.7</td><td>47.83</td><td>50.60</td><td>47.81</td></tr></table>
|
| 392 |
+
|
| 393 |
+
Table 9: Case study of classified intents on the OOD samples (from STAR-Full dataset) by Outlier and Caro. OOD samples are classified as one of the IND classes by Outlier, which are detected as the OOD intent by Caro.
|
| 394 |
+
|
| 395 |
+
<table><tr><td colspan="2">Dialogue</td><td rowspan="2">Prediction of “Outlier”</td><td rowspan="2">Prediction of “Caro”</td></tr><tr><td>Customer</td><td>Agent</td></tr><tr><td colspan="2">Somebody has transferred $5oo from my account.</td><td rowspan="2">bank_ask_pin</td><td rowspan="2">OOD</td></tr><tr><td>yes please</td><td>Would you like to file a fraud report? Could I get your full name,please?</td></tr><tr><td rowspan="2">Jane Doe</td><td></td><td rowspan="2"></td><td rowspan="2"></td></tr><tr><td>Can you tell me your account number, please?</td></tr><tr><td colspan="2">What am I doing on this chat? Hey there! Can you tell me what the weather will be tomorrow please?</td><td>weather _inform</td><td>OOD</td></tr><tr><td rowspan="2">oh dang when's the next time it will be sunny?</td><td>It will be Raining all day on Saturday in Los Angeles,with temperatures of around 19 degrees celsius.</td><td rowspan="2">_forecast</td><td rowspan="2"></td></tr><tr><td>It will be Sunny all day on Friday in Los Angeles,with temperatures of around 11 degrees celsius.</td></tr><tr><td colspan="2">Nice! I think I'll head to La brea tar pits. I've never been there.have you seen those animals? Crazy</td><td rowspan="2">bank_inform</td><td rowspan="2"></td></tr><tr><td colspan="2">apartment for Thursday at 8pm my name is john</td></tr><tr><td rowspan="2">Ican't remember</td><td>Have you already paid the application fee for the apartment?</td><td rowspan="2">_cannot _authenticate</td><td rowspan="2">OOD</td></tr><tr><td>Iam sorry, but there is no viewing available at your preferred time.</td></tr><tr><td rowspan="2">Ihave a hot date by 8pmo Thursday</td><td rowspan="2">When would you like the viewing to start?</td><td rowspan="2"></td><td rowspan="2"></td></tr><tr><td></td></tr></table>
|
md/dev/MpJjrfSJ-Xs/MpJjrfSJ-Xs.md
ADDED
|
@@ -0,0 +1,346 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# CROSS-DOMAIN CROSS-SET FEW-SHOT LEARNING VIA LEARNING COMPACT AND ALIGNED REPRESENTATIONS
|
| 2 |
+
|
| 3 |
+
Anonymous authors Paper under double-blind review
|
| 4 |
+
|
| 5 |
+
# ABSTRACT
|
| 6 |
+
|
| 7 |
+
Few-shot learning (FSL) aims to recognize novel query examples with a small support set through leveraging prior knowledge learned from a large-scale training set. In this paper, we extend this task to a more practical setting where the domain shift exists between the support set and query examples, and additional unlabeled data in the target domain can be adopted in the meta-training stage. Such new setting, termed cross-domain cross-set FSL (CDSC-FSL), requires the learning system not only to adapt to new classes with few examples but also to be consistent between different domains. To address this paradigm, we propose a novel approach, namely stabPA, to learn prototypical compact and cross-domain aligned representations, so that domain shift and few-shot adaptation can be addressed simultaneously. We evaluate our approach on two new CDCS-FSL benchmarks adapted from the DomainNet and Office-Home datasets, respectively. Remarkably, our approach outperforms multiple elaborated baselines by a large margin and improves 5-shot accuracy by up to 4.7 points.
|
| 8 |
+
|
| 9 |
+
# 1 INTRODUCTION
|
| 10 |
+
|
| 11 |
+
Learning new concepts from a very limited number of images is easy for human beings, however, it is quite difficult for most machine learning algorithms, as they usually need plenty of labeled data to model large intra-class variance and complex inter-class relationships. To bridge the gap between humans and machines, few-shot learning (FSL) has recently been proposed, which aims to learn new classes with only a few examples.
|
| 12 |
+
|
| 13 |
+
A typical FSL paradigm is to first train a base model with a large labeled dataset (called the base set), which is termed the meta-training stage. When deployed in the meta-testing stage, the base model is adapted to new classes with only a few examples (named the support set), and then tested with a query set covering these novel classes. Despite recent progress of FSL (Kim et al., 2020; Tian et al., 2020), most studies follow a single domain assumption, where the base set, support set and query set are all from the same domain. Cross-domain FSL (Tseng et al., 2020) breaks this assumption and considers the domain shift problem between the meta-training stage and meta-testing stage. However, it is still assumed that the support set and query set of novel classes are from the same domain, which is unrealistic in some practical applications. For example, in smart healthcare scenarios, someone may upload a skin picture captured by cell-phone for querying possible skin diseases, while the support samples are usually a few high-quality medical images captured by professional dermoscope devices. Thus, it is a very valuable problem to study the domain shift between the query set and the support set (Gu et al., 2019). Such case can also be found in face recognition and image retrieval areas (He et al., 2018; Liu et al., 2019).
|
| 14 |
+
|
| 15 |
+
In this work, we aim to deal with a more practical FSL setting termed cross-domain cross-set FSL (CDCS-FSL). The difference between the CDCS-FSL and previous FSL settings is illustrated in Figure 1 (a). Specifically, instead of assuming a consistent domain in the meta-testing stage,we hope that the few-shot learner of new classes can be learned and tested in different domains, e.g. the support set is from the same source domain of the base set while the query set is from a different target domain, or vice versa. Compared with previous cross-domain FSL, this setting is more challenging as it requires learning a well-aligned feature space shared by the source domain and the target domain. To facilitate feature alignment, we provide additional unlabeled target data in the meta-training stage to allow the learning system to access target domain information beforehand.
|
| 16 |
+
|
| 17 |
+

|
| 18 |
+
Figure 1: Problem setup and motivation. (a) Different from previous FSL settings, CDCS-FSL assumes a domain gap exists between the support set and query set, and additional unlabeled target data are provided in the meta-training stage. (b) To address CDCS-FSL, we propose a bi-directional prototypical alignment strategy, which pushes feature vectors of one domain to be gathered around the prototypes in the other domain, and separates feature vectors of different classes.
|
| 19 |
+
|
| 20 |
+
To deal with the CDCS-FSL problem, we propose a novel bi-directional prototypical alignment strategy illustrated in Figure 1 (b). The insight of our approach is two-fold: 1) we need aligned representations to alleviate the domain shift problem, and 2) compact representations are desirable to reduce intra-class variance and enlarge inter-class distance so that a small support set can better represent a new class. Specifically, different from previous prototypical alignment methods (Pan et al., 2019; Xie et al., 2018) that directly minimize the point-to-point distances between class centers (prototypes), we propose to minimize the point-to-set distances between the prototypes and feature vectors, and constrain these distances in two directions: 1) from source features to target prototype and 2) from target features to source prototype. As a result, the feature vectors of the source (or target) domain will be gathered around the prototypes in the other domain, so that the domain gap and the intra-class variance can be reduced simultaneously. Meanwhile, we maximize the inter-class distance between samples from different classes to get a more separable feature space. Inspired by the fact that data augmentation even with strong image transformations generally does not change the sample semantics, we suppose that the augmented samples from different domains should also be aligned, and thus apply the bi-directional prototypical alignment to the augmented samples. Due to significant differences in appearance, these samples may have a more dispersive feature distribution, which can further encourage to learn the underlying invariance and strengthen feature alignment.
|
| 21 |
+
|
| 22 |
+
We refer to our approach as “Strongly Augmented Bi-directional Prototypical Alignment”, or stabPA. We evaluate its effectiveness on two new CDCS-FSL benchmarks adapted from the DomainNet and Office-Home datasets. Remarkably, our approach achieves the best performance over all benchmarks and outperforms baselines with a large margin, e.g. up to 5.6 points gain compared to the state-of-the-art (SOTA) method STARTUP (Phoo & Hariharan, 2021). Our contributions are three-fold. 1) We propose CDCS-FSL, a more practical FSL setting where the support set and the query set are from different domains. 2) We propose a new approach, namely stabPA, to address the CDCS-FSL problem, the key of which is to learn prototypical compact and domain aligned representations. 3) Extensive experiments demonstrate that stabPA can learn discriminative and generalizable representations and outperforms all baselines by a large margin.
|
| 23 |
+
|
| 24 |
+
# 2 RELATED WORK
|
| 25 |
+
|
| 26 |
+
# 2.1 FEW-SHOT LEARNING
|
| 27 |
+
|
| 28 |
+
FSL aims to learn new classes with very few labeled examples. Most studies follow a meta-learning paradigm (Vilalta & Drissi, 2002), where a meta-learner is trained on a series of training tasks (episodes) to learn meta-knowledge across tasks so as to enable fast adaptation to new tasks. The meta-learner can take various forms, such as an LSTM network (Ravi & Larochelle, 2017), a set of initial parameters (Finn et al., 2017), or closed-form solvers (Rusu et al., 2019). Recent advances in pre-training techniques spawn another FSL paradigm: a model is first pre-trained on a large base set to obtain meta-knowledge; then only a few samples are required for model fine-tuning to complete downstream tasks. For example, Chen et al. (2019) propose a standard pre-training and fine-tuning procedure for few-shot classification, where the simple baselines achieve competitive performance to the SOTA meta-learning models. Tian et al. (2020); Chen et al. (2021) show that self-supervised pre-training techniques are useful to learn effective representations for few-shot learning.
|
| 29 |
+
|
| 30 |
+
As a realistic setting, the cross-domain FSL assumes that the base set in the meta-training (pretraining) stage is from the source domain and the support set and query set in the meta-testing (finetuning) stage are both from the target domain. With such domain gap, Chen et al. (2019) show that meta-learning approaches may fail to adapt to novel classes. To alleviate this problem, Tseng et al. (2020) propose a feature-wise transformation layer to learn rich representations that can generalize better to other domains. However, they need to access multiple base datasets from different domains with extra data collection costs. Another work (Ngiam et al., 2018) studies the choice of base datasets and shows that a judicious choice can improve the generalization ability of the learned representations. However, all the above works only consider the domain gap occurring between the meta-training (pre-training) stage and meta-testing (fine-tuning) stage. In this paper, we consider a more challenging setting that the support set and the query set are from different domains. To facilitate the representation adaptation to the target domain, we allow the use of additional unlabeled target images in the meta-training (pre-training) stage.
|
| 31 |
+
|
| 32 |
+
# 2.2 UNSUPERVISED DOMAIN ADAPTATION
|
| 33 |
+
|
| 34 |
+
Using unlabeled images to alleviate the domain shift problem has been widely investigated in the field of unsupervised domain adaptation (UDA). Early efforts align the marginal distribution of each domain by minimizing a pre-defined distribution discrepancy, such as $\mathcal { H } \Delta \mathcal { H }$ -divergence (BenDavid et al., 2010) and Maximum Mean Discrepancy (MMD) (Gretton et al., 2006). Inspired by Generative Adversarial Networks (GANs) (Goodfellow et al., 2014), Ganin et al. (2016) first adopt a domain adversarial neural network (DANN) to learn domain-invariant features, where a domain discriminator is exploited to approximate the domain discrepancy. Since then, various adversarial training based methods are proposed for learning at image level (Hoffman et al., 2018) , feature level (Long et al., 2018a) or output level (Tsai et al., 2018). While another line of works adopt semisupervised learning techniques. For example, self-training methods (Zheng & Yang, 2021; Zhang et al., 2021; 2019) assign pseudo labels to unlabeled images and train the model with these pseudo labels iteratively. Although these UDA methods are related to our work, they usually assume that the test stage shares the same class categories in the training stage, which is broken by the setting of FSL. Besides, the test data are all from the target domain, while the CDCS-FSL assumes that the domain gap exists between the query set and support set in the meta-testing stage.
|
| 35 |
+
|
| 36 |
+
# 3 PROBLEM SETUP
|
| 37 |
+
|
| 38 |
+
Formally, a FSL task often adopts a setting of N-way-K-shot classification, which aims to discriminate bwhere novel classes with denotes a data sa $\mathrm { K }$ exemplars per class. Gle in novel classes and pport set is the cl ${ \cal { S } } = \{ ( x _ { i } , y _ { i } ) \} _ { i = 1 } ^ { N \times K }$ $x _ { i } \in \mathcal { X } _ { \mathcal { N } }$ $y _ { i } \in Y _ { \mathcal { N } }$
|
| 39 |
+
FSL is to learn a mapping function $\phi : \phi ( x _ { q } ) y _ { q }$ which classifies a query sample $x _ { q }$ in the query set $\mathcal { Q }$ to the class label $y _ { q } \in Y _ { \mathcal { N } }$ . Besides $s$ and $\dot { \mathcal { Q } }$ , a large labeled dataset $B \subset \mathcal { X } _ { B } \overset { \cdot } { \times } \mathcal { Y } _ { B }$ (termed the base set) is often provided for pre-training (meta-training), where the sample set $\chi _ { B }$ and the base class set $\mathcal { { V } } _ { B }$ do not overlap with $\mathcal { X } _ { \mathcal { N } }$ and $\mathcal { D } _ { \mathcal { N } }$ .
|
| 40 |
+
|
| 41 |
+
Conventional FSL studies assume the three sets $\mathcal { S } , \mathcal { Q }$ and $\boldsymbol { B }$ are from the same domain (e.g. the natural image domain). Recently, cross-domain FSL proposes a more general assumption that the base set is from a source domain and the support set and query set are from a different target domain, i.e., $\boldsymbol { B } \subset \mathcal { D } _ { s }$ and ${ \mathcal { S } } , { \mathcal { Q } } \subset { \mathcal { D } } _ { t }$ , where $\mathcal { D } _ { s }$ and $\mathcal { D } _ { t }$ are the source and target domain, respectively. In this paper, we take a step further and propose a new setting where the support set and the query set are from different domains. Specifically, in this setting, we assume the base set also belongs to the source domain, i.e., $B \subset D _ { s }$ , while for the support set and query set, there are two situations:
|
| 42 |
+
|
| 43 |
+

|
| 44 |
+
Figure 2: Framework. In the representation learning phase, we pre-train a feature extractor with the proposed bi-directional prototypical alignment strategy to learn compact and aligned representations. In the evaluation phase, we fix the feature extractor and train a new linear classification head with the support set. The entire model is tested on the query set.
|
| 45 |
+
|
| 46 |
+
1. $\mathcal { D } _ { s } - \mathcal { D } _ { t }$ : the support set is from the source domain and the query set is from the target domain, i.e., $\mathcal { S } \subset \mathcal { D } _ { s }$ and $\mathcal { Q } \subset \mathcal { D } _ { t }$ .
|
| 47 |
+
2. $\mathcal { D } _ { t } - \mathcal { D } _ { s }$ : the support set is from the target domain and the query set is from the source domain, i.e., $\mathcal { S } \subset \mathcal { D } _ { t }$ and $\mathcal { Q } \subset \mathcal { D } _ { s }$ .
|
| 48 |
+
|
| 49 |
+
We refer to such setting as cross-domain cross-set few-shot learning (CDCS-FSL). To facilitate crossing the domain gap, we allow an additional unlabelled dataset $\mathcal { U }$ from the target domain for meta-training. The class space of the unlabeled dataset has an interaction with the base classes, but does not overlap with novel classes in meta-testing.
|
| 50 |
+
|
| 51 |
+
# 4 APPROACH
|
| 52 |
+
|
| 53 |
+
Briefly, our approach contains two phases: 1) In the representation learning phase, we pre-train a feature extractor $f : x _ { i } \to f ( x _ { i } )$ with the base set $\boldsymbol { B }$ and the unlabeled target set $\mathcal { U }$ ; 2) In the evaluation phase, we fix the feature extractor and train a linear classification head $g : f ( x _ { i } ) y _ { i }$ on the support set $s$ , and the entire model $\phi = g \circ f$ is used to predict the labels for the query set $\mathcal { Q }$ . The framework of our approach is illustrated in Figure 2.
|
| 54 |
+
|
| 55 |
+
# 4.1 BI-DIRECTIONAL PROTOTYPICAL ALIGNMENT
|
| 56 |
+
|
| 57 |
+
To mitigate the domain shift, a straightforward way is to learn aligned representations by minimizing the point-to-point distances between the prototypes of different domains, which are approximated using labeled data within a batch. In our case, although we can use pseudo labels to estimate prototypes of the target domain, the naive prototype alignment is still problematic due to the following two points. First, since the prototypes are estimated on a limited number of samples in a batch, they are likely to deviate from the true class centers and mislead the alignment. This problem will be exacerbated in the iterative process of pseudo-labeling and feature learning, where the noisy pseudo labels may lead to further misalignment between the source and target domains. Second, although minimizing the point-to-point distance can reduce the domain shift in intra-class samples, the feature distribution of different classes may be mixed due to the lack of constraints regarding inter-class relationships. Hence, the discrimination capability of the learned representations is still insufficient.
|
| 58 |
+
|
| 59 |
+
To overcome these drawbacks, we propose a bi-directional prototypical alignment strategy, which pushes the features from one domain to be clustered around the prototypes of the other domain, meanwhile far away from the prototypes of other classes. Given the source domain base set $\boldsymbol { B }$ and the target domain unlabeled set $\mathcal { U }$ , we first assign pseudo labels to each target sample with an initial classifier pseudo la $\phi _ { 0 }$ trained on the base set and obtain l. Then, we obtain the source prot $\hat { \mathcal { U } } = \{ ( x _ { i } , \hat { y } _ { i } ) | x _ { i } \in \mathcal { U } \}$ , where target p $\hat { y } _ { i } = \phi _ { 0 } ( x _ { i } )$ $\{ p _ { k } ^ { s } \} _ { k = 1 } ^ { | \mathcal { V } _ { B } | }$ $\{ p _ { k } ^ { t } \} _ { k = 1 } ^ { | \mathcal { V } _ { B } | }$ (details can be found below). It should be noted that the prototypes are estimated on the entire datasets $\boldsymbol { B }$ and $\hat { \mathcal { U } }$ , and adjusted together with the update of the feature extractor and pseudo labels.
|
| 60 |
+
|
| 61 |
+
For a source sample $( x _ { i } ^ { s } , y _ { i } ^ { s } ) \in B$ of the $q$ -th class, we minimize its feature distance to the prototype of the same class in the target domain, and meanwhile maximize its distances to prototypes of other classes. Here, a softmax loss function for the source-to-target alignment is formulated as:
|
| 62 |
+
|
| 63 |
+
$$
|
| 64 |
+
\ell _ { s - t } ( x _ { i } ^ { s } , y _ { i } ^ { s } ) = - \log \frac { \exp { ( - \vert \vert f ( x _ { i } ^ { s } ) - p _ { q } ^ { t } \vert \vert / \tau ) } } { \sum _ { k = 1 } ^ { \vert y _ { \mathcal { B } } \vert } \exp { ( - \vert \vert f ( x _ { i } ^ { s } ) - p _ { k } ^ { t } \vert \vert / \tau ) } } ,
|
| 65 |
+
$$
|
| 66 |
+
|
| 67 |
+
where $\tau$ is a temperature factor. Similarly, for a target sample $( x _ { i } ^ { t } , \hat { y } _ { i } ^ { t } ) \in \hat { \mathcal { U } }$ with $\hat { y } _ { i } ^ { t } = q$ , a target-tosource alignment loss function is as follows:
|
| 68 |
+
|
| 69 |
+
$$
|
| 70 |
+
\ell _ { t - s } ( x _ { i } ^ { t } , \hat { y } _ { i } ^ { t } ) = - \log \frac { \exp { ( - \lvert \lvert f ( x _ { i } ^ { t } ) - p _ { q } ^ { s } \rvert \rvert / \tau ) } } { \sum _ { k = 1 } ^ { \lvert \mathcal { V } _ { B } \rvert } \exp { ( - \lvert \lvert f ( x _ { i } ^ { t } ) - p _ { k } ^ { s } \rvert \rvert / \tau ) } } .
|
| 71 |
+
$$
|
| 72 |
+
|
| 73 |
+
Since the initial pseudo labels are more likely to be incorrect, we gradually increase the weight of these two losses following the principle of curriculum learning (Bengio et al., 2009). For the source-to-target alignment, the loss weight starts from zero and converges to one, formulated as:
|
| 74 |
+
|
| 75 |
+
$$
|
| 76 |
+
w ( t ) = \frac { 2 } { 1 + \exp \left( - \alpha t / T _ { m a x } \right) } - 1 ,
|
| 77 |
+
$$
|
| 78 |
+
|
| 79 |
+
where $t$ is the current training step, $T _ { m a x }$ is the maximum training step, and $\alpha$ is a hyperparameter controlling the convergence speed. For the target-to-source alignment, since the pseudo labels become more confident along with the training process, a natural curriculum is achieved by setting a confidence threshold to filter out the target samples with low confidence pseudo labels (Sohn et al., 2020).
|
| 80 |
+
|
| 81 |
+
Therefore, the total loss for the bi-directional prototypical alignment is
|
| 82 |
+
|
| 83 |
+
$$
|
| 84 |
+
\ell _ { b \mathrm { P A } } = \frac { 1 } { | \mathcal { B } | } \sum _ { i = 1 } ^ { | \mathcal { B } | } w ( t ) \ell _ { s - t } ( x _ { i } ^ { s } , y _ { i } ^ { s } ) + \frac { 1 } { | \mathcal { \hat { U } } | } \sum _ { i = 1 } ^ { | \mathcal { \hat { U } } | } \mathbb { 1 } ( p ( \hat { y } _ { i } ^ { t } ) > \beta ) \ell _ { t - s } ( x _ { i } ^ { t } , \hat { y } _ { i } ^ { t } ) ,
|
| 85 |
+
$$
|
| 86 |
+
|
| 87 |
+
where $p ( \cdot )$ is the confidence of a pseudo label, and $\beta$ is the confidence threshold below which the data samples will be dropped.
|
| 88 |
+
|
| 89 |
+
Updating Pseudo Label. The pseudo labels are initially predicted by a classifier $\phi _ { 0 }$ pre-trained on the base set $\boldsymbol { B }$ . As the representations are updated, we update the pseudo labels by re-training a classifier $\phi _ { t } = h \circ f$ based on the current feature extractor $f$ , where $h$ is a linear classification head for the base classes. The final pseudo labels are updated by linear interpolation between the predictions of the initial classifier $\phi _ { 0 }$ and the online updated classifier $\phi _ { t }$ :
|
| 90 |
+
|
| 91 |
+
$$
|
| 92 |
+
\hat { y } _ { i } = \arg \operatorname* { m a x } _ { k } \lambda \phi _ { 0 } ( k | x _ { i } ) + ( 1 - \lambda ) \phi _ { t } ( k | x _ { i } ) ,
|
| 93 |
+
$$
|
| 94 |
+
|
| 95 |
+
where $\lambda$ is the interpolation coefficient. The combination of these two classifiers makes it possible to rectify the label noise of the initial classifier, and meanwhile inhibit the rapid change of pseudo labels of online classifier especially in the early training stage.
|
| 96 |
+
|
| 97 |
+
Generating Prototypes. Note that we are intended to estimate the prototypes on the entire dataset and update them with representation learning. For the source domain, instead of calculating the mean value of intra-class samples in the feature space, a cheaper way is to approximate prototypes with the normalized weights of the classification head $h$ , as the classifier weights tend to align with class centers in order to reduce classification error (Qiao et al., 2018). Specifically, we set the source prototypes as $p _ { k } ^ { s } = W _ { k }$ , where $W _ { k }$ is the normalized classification weight for the $k$ -th class. For the target domain, we adopt the momentum technique to update prototypes. The prototypes are initialized as zeros. At each training step, we first estimate the prototypes using target samples in the current batch with their pseudo labels. Then, we update target prototype $p _ { k } ^ { t }$ as:
|
| 98 |
+
|
| 99 |
+
$$
|
| 100 |
+
p _ { k } ^ { t } \longleftarrow m p _ { k } ^ { t } + ( 1 - m ) \frac { 1 } { n _ { k } } \sum _ { i = 1 } ^ { | \hat { \mathcal { U } } _ { b } | } \mathbb { 1 } ( \hat { y } _ { i } ^ { t } = k ) f ( x _ { i } ^ { t } ) ,
|
| 101 |
+
$$
|
| 102 |
+
|
| 103 |
+
where $n _ { k }$ is the number of the target samples classified into the $k$ -th class in a target batch $\hat { \mathcal { U } } _ { b }$ , and $m$ is the momentum term controlling the update speed.
|
| 104 |
+
|
| 105 |
+
# 4.2 stabPA
|
| 106 |
+
|
| 107 |
+
Strong data augmentation has proved to be effective for learning generalizable representations, especially in self-supervised learning studies, e.g. contrastive learning. Given a sample $x$ , strong data augmentation generates additional data points $\{ \widetilde { x } _ { i } \} _ { i = 1 } ^ { n }$ by applying various strong transformations e(Chen et al., 2020; He et al., 2020). The assumption behind strong data augmentation is that the strong transformation does not change the semantics of the original samples.
|
| 108 |
+
|
| 109 |
+
In this work, we further hypothesize that strongly augmented intra-class samples in different domains can also be aligned. It is expected that strong data augmentation can further strengthen the learning of cross-domain representations, since stronger augmentation provides more diverse data samples and makes the learned aligned representations more robust for various transformations in both the source domain and target domain.
|
| 110 |
+
|
| 111 |
+
Following this idea, we extend the bi-directional prototypical alignment with strong data augmentation and the proposed entire framework is termed stabPA. Specifically, for a source sample $( x _ { i } ^ { s } , y _ { i } ^ { s } )$ and a target sample $( x _ { i } ^ { t } , \hat { y } _ { i } ^ { t } )$ , we generate their strongly augmented versions $( \widetilde { x } _ { i } ^ { s } , y _ { i } ^ { s } )$ and $( \widetilde { x } _ { i } ^ { t } , y _ { i } ^ { t } )$ . e eWithin the bi-directional prototypical alignment framework, we minimize the feature distance of a strongly augmented image to its prototype with the same class label in the other domain, and maximize its distance to the prototypes of other classes. Totally, the stabPA loss is
|
| 112 |
+
|
| 113 |
+
$$
|
| 114 |
+
\ell _ { s t a b \mathbf { P A } } = \frac { 1 } { | \widetilde { \mathcal { B } } | } \sum _ { i = 1 } ^ { | \widetilde { \mathcal { B } } | } w ( t ) \ell _ { s - t } ( \widetilde { x } _ { i } ^ { s } , y _ { i } ^ { s } ) + \frac { 1 } { | \widetilde { \mathcal { U } } | } \sum _ { i = 1 } ^ { | \widetilde { \mathcal { U } } | } \mathbb { 1 } ( p ( \hat { y } _ { i } ^ { t } ) > \beta ) \ell _ { t - s } ( \widetilde { x } _ { i } ^ { t } , \hat { y } _ { i } ^ { t } ) ,
|
| 115 |
+
$$
|
| 116 |
+
|
| 117 |
+
where $\widetilde { B }$ and $\widetilde { \mathcal { U } }$ are the augmented base set and unlabeled target set, respectively.
|
| 118 |
+
|
| 119 |
+
To perform strong data augmentation, we apply random crop, Cutout (DeVries & Taylor, 2017), and RandAugment (Cubuk et al., 2020). RandAugment comprises 14 different transformations and randomly selects a fraction of transformations for each sample. In Cubuk et al. (2020), a global magnitude controlling all transformations needs to be optimized via grid search on a validation set. However, random selection of the magnitude for each transformation works well in our study, which is similar to Sohn et al. (2020).
|
| 120 |
+
|
| 121 |
+
# 5 EXPERIMENTS
|
| 122 |
+
|
| 123 |
+
# 5.1 ADAPTING THE DATASETS FOR CDCS-FSL
|
| 124 |
+
|
| 125 |
+
DomainNet. DomainNet (Peng et al., 2019) is a large scale multi-domain image dataset. It contains 345 categories in 6 different domains, about 0.6 million images in total. In our experiments, we choose the real domain as the source domain and choose one domain from painting, clipart and sketch as the target domain. Similar to previous work, we randomly split the dataset into 3 parts: base set (228 categories), validation set (33 categories) and novel set (65 categories), and discard 19 categories with too few images. To construct the unlabeled target dataset, we remove the labels of the target base set and validation set. These unlabeled images combined with the labeled source base set are use for pre-training. The validation sets in both domains are used to tune the hyperparameters. We finally report the 5-way 1-shot and 5-way 5-shot accuracies on the novel set.
|
| 126 |
+
|
| 127 |
+
Office-Home. Office-Home (Venkateswara et al., 2017) contains 65 object categories usually found in office and home settings. We randomly select 40 categories as the base set, 10 categories as the validation set and 15 categories as the novel set. There are 4 domains for each category: real, art, clipart and product. We set the source domain as real and choose the target domain from the other three domains. The training and testing process are the identical with the DomainNet dataset.
|
| 128 |
+
|
| 129 |
+
# 5.2 COMPARISON WITH BASELINES
|
| 130 |
+
|
| 131 |
+
We first compare our approach with conventional FSL methods, including ProtoNet (Snell et al., 2017), RelationNet (Sung et al., 2018), MetaOptNet (Lee et al., 2019), Tian et al. (2020) and DeepEMD (Zhang et al., 2020), which all train the model only with source domain data. We also compare to the methods that leverage unlabeled target data to alleviate domain shift, including the adversarial training method DANN (Ganin et al., 2016), semi-supervised learning methods Mean Teacher (Tarvainen & Valpola, 2017), Fixmatch (Sohn et al., 2020), and the cross-domain FSL method STARTUP (Phoo & Hariharan, 2021). For a fair comparison, we re-implement these methods with the same backbone and optimizer. Further details can be found in Appendix A.1. The comparison results are shown in Tables 1 and 2.
|
| 132 |
+
|
| 133 |
+
Table 1: Comparison to baselines on the DomainNet dataset. We report 5-way 1-shot and 5-way 5-shot accuracies with $9 5 \%$ confidence interval.
|
| 134 |
+
|
| 135 |
+
<table><tr><td rowspan="2">Method</td><td colspan="2">real-painting</td><td colspan="2">real-clipart</td><td colspan="2">real-sketch</td></tr><tr><td>1-shot</td><td>5-shot</td><td>1-shot</td><td>5-shot</td><td>1-shot</td><td>5-shot</td></tr><tr><td>ProtoNet (NeurIPS'17)</td><td>45.36±0.81</td><td>57.23±0.79</td><td>44.65±0.81</td><td>58.04±0.81</td><td>39.28±0.77</td><td>51.68±0.81</td></tr><tr><td>RelationNet (CVPR'18)</td><td>42.69±0.77</td><td>52.63±0.74</td><td>44.12±0.81</td><td>57.24±0.80</td><td>36.52±0.73</td><td>47.32±0.75</td></tr><tr><td>MetaOptNet (CVPR'19)</td><td>44.02±0.77</td><td>56.34±0.34</td><td>42.46±0.80</td><td>57.92±0.79</td><td>36.37±0.72</td><td>48.20±0.79</td></tr><tr><td>Tian et al. (ECCV'20)</td><td>46.69±0.86</td><td>56.87±0.84</td><td>48.30±0.85</td><td>59.67±0.84</td><td>40.23±0.73</td><td>50.41±0.80</td></tr><tr><td>DeepEMD (CVPR'20)</td><td>47.60±0.87</td><td>56.62±0.78</td><td>49.02±0.83</td><td>60.43±0.82</td><td>42.75±0.79</td><td>51.66±0.80</td></tr><tr><td>DANN (JMLR'16)</td><td>45.94±0.84</td><td>56.83±0.86</td><td>47.31±0.86</td><td>59.42±0.84</td><td>42.44±0.79</td><td>53.47±0.75</td></tr><tr><td>Mean Teacher (NeurIPS'17)</td><td>46.92±0.83</td><td>57.74±0.84</td><td>48.48±0.81</td><td>61.54±0.84</td><td>43.39±0.81</td><td>54.57±0.79</td></tr><tr><td>Fixmatch (NeurIPS'20)</td><td>48.86±0.87</td><td>61.62±0.79</td><td>48.70±0.82</td><td>61.94±0.82</td><td>44.48±0.80</td><td>55.26±0.83</td></tr><tr><td>STARTUP (ICLR'21)</td><td>47.53±0.88</td><td>58.13±0.82</td><td>49.24±0.87</td><td>61.51±0.86</td><td>43.78±0.82</td><td>54.89±0.81</td></tr><tr><td>stabPA (Ours)</td><td>50.51±0.85</td><td>63.19±0.78</td><td>51.63±0.83</td><td>62.78±0.85</td><td>47.54±0.81</td><td>59.10±0.79</td></tr><tr><td></td><td colspan="2">painting-real</td><td colspan="2">clipart-real</td><td colspan="2">sketch-real</td></tr><tr><td>ProtoNet (NeurIPS'17)</td><td>45.25±0.97</td><td>65.60±0.95</td><td>47.50±0.95</td><td>65.91±0.78</td><td>42.85±0.89</td><td>59.46±0.85</td></tr><tr><td>RelationNet (CVPR'18)</td><td>43.04±0.97</td><td>61.18±0.90</td><td>45.86±0.95</td><td>62.65±0.81</td><td>41.29±0.96</td><td>56.39±0.88</td></tr><tr><td>MetaOptNet (CVPR'19)</td><td>44.31±0.94</td><td>63.20±0.89</td><td>46.15±0.98</td><td>63.51±0.82</td><td>40.27±0.95</td><td>55.65±0.85</td></tr><tr><td>Tian el al. (ECCV'20)</td><td>46.57±0.99</td><td>63.90±0.95</td><td>49.66±0.98</td><td>65.33±0.80</td><td>41.90±0.86</td><td>56.95±0.84</td></tr><tr><td>DeepEMD (CVPR'20)</td><td>47.86±1.04</td><td>63.86±0.93</td><td>50.89±1.00</td><td>67.46±0.78</td><td>46.02±0.93</td><td>60.39±0.87</td></tr><tr><td>DANN (JMLR'16)</td><td>46.85±0.97</td><td>64.29±0.94</td><td>50.02±0.94</td><td>66.87±0.78</td><td>43.66±0.92</td><td>60.14±0.81</td></tr><tr><td>Mean Teacher (NeurIPS'17)</td><td>46.84±0.96</td><td>64.97±0.94</td><td>49.60±0.97</td><td>67.39±0.89</td><td>44.52±0.89</td><td>60.04±0.86</td></tr><tr><td>Fixmatch (NeurIPS'20)</td><td>49.15±0.93</td><td>67.46±0.89</td><td>49.18±0.93</td><td>66.72±0.81</td><td>45.97±0.95</td><td>62.46±0.87</td></tr><tr><td>STARTUP (ICLR'21)</td><td>47.58±0.98</td><td>65.27±0.92</td><td>51.32±0.98</td><td>67.95±0.78</td><td>45.23±0.96</td><td>61.97±0.88</td></tr><tr><td>stabPA (Ours)</td><td>51.87±0.99</td><td>70.84±0.88</td><td>53.53±1.04</td><td>71.57±0.81</td><td>49.18±0.96</td><td>67.14±0.85</td></tr></table>
|
| 136 |
+
|
| 137 |
+
stabPA vs few-shot learning methods. On the DomainNet, our approach outperforms all the FSL baselines by a large margin across different domains and situations. Compared to ProtoNet, our approach improves the 5-shot accuracy by $7 . 4 \%$ in the most difficult real-sketch situation, and by $5 . 7 \%$ in the easier clipart-real situation. Similar results can be found on the Office-Home dataset in Table 2 . The significant improvements indicate that few-shot learners trained on one domain are difficult to adapt to the other domains, while the proposed stabPA learning aligned representations across domains can alleviate this problem and improve the cross-domain FSL performance.
|
| 138 |
+
|
| 139 |
+
stabPA vs pseudo-labeling methods. Similar to our approach, Mean Teacher, Fixmatch and STARTUP train the model with additional unlabeled target images. Particularly, Fixmatch also applies strong data augmentation to unlabeled images. However, our approach outperforms them in all situations. We claim that the strength of stabPA derives not only from pseudo labeling and strong augmentation, but also from the proposed bi-directional prototypical alignment strategy. This is particularly evident in the real-sketch and sketch-real situations (up to $4 . 7 \%$ improvement in 5-shot accuracy), where the domain shift is very significant.
|
| 140 |
+
|
| 141 |
+
# 5.3 RESULTS ANALYSIS
|
| 142 |
+
|
| 143 |
+
# 5.3.1 HAS stabPA LEARNED COMPACT AND ALIGNED REPRESENTATIONS?
|
| 144 |
+
|
| 145 |
+
To verify whether stabPA indeed learns compact and aligned representations, we visualize the feature distribution through the pre-training process using t-SNE (Van der Maaten & Hinton, 2008). From Figure 3 (a)-(d), we can see that in the beginning, samples from different classes are heavily mixed. There are no distinct classification boundaries between classes. Besides, samples from two domains are far away from each other, which indicates the existence of a considerable domain shift (such as the classes in green and orange). However, as training continues, samples from the same class begin to aggregate together, and the margin between different classes gets larger and larger, i.e., the feature distribution becomes more compact. Moreover, we can see that samples from different domains are grouping into their ground-truth classes, even though no label information is given for the target domain. These observations demonstrate that stabPA is indeed capable to learn compact and aligned representations.
|
| 146 |
+
|
| 147 |
+

|
| 148 |
+
Figure 3: (a)-(d) t-SNE visualization of feature distribution at different training epochs. Samples of the same class are painted in similar colors, where darker triangles represent source samples and lighter reverted triangles represent target samples (best viewed in color). Class centers are marked in black border. (e) Domain distance on novel classes. (f)-(g) Separability among novel classes in the source and target domains. Separability is represented by the average distance ratio, the lower the better.
|
| 149 |
+
|
| 150 |
+
# 5.3.2 CAN stabPA LEARN GENERALIZABLE REPRESENTATIONS FOR NEW CLASSES?
|
| 151 |
+
|
| 152 |
+
To validate the generalization capability of the representations learned by stabPA, we propose two quantitative metrics which indicate the domain distance and class separability among new classes.
|
| 153 |
+
|
| 154 |
+
Specifically, to the measure domain distance, we first calculate prototypes $p _ { k } ^ { s }$ and $p _ { k } ^ { t }$ for each novel class in the source and target domain. Then we obtain the Euclidean distance between the two prototypes per class and compute the average distance over all novel classes. We refer to this metric as Prototype Distance (PD), which can be formulated as: $\begin{array} { r } { P D = \frac { 1 } { | \mathcal { V } _ { N } | } \sum _ { k \in \mathcal { V } _ { N } } | | p _ { k } ^ { s } - p _ { k } ^ { t } | | } \end{array}$ . A small PD value means the two domains are well aligned to each other.
|
| 155 |
+
|
| 156 |
+
Table 3: Ablation studies on DomainNet. Mean and $9 5 \%$ confidence interval are reported.
|
| 157 |
+
|
| 158 |
+
<table><tr><td></td><td></td><td></td><td colspan="2">sketch-real</td><td colspan="2">real-sketch</td></tr><tr><td>ls-t</td><td>lt-s</td><td>aug</td><td>1-shot</td><td>5-shot</td><td>1-shot</td><td>5-shot</td></tr><tr><td>×</td><td>×</td><td>×</td><td>41.90±0.86</td><td>56.95±0.84</td><td>40.23±0.73</td><td>50.41±0.80</td></tr><tr><td>√</td><td>×</td><td>×</td><td>44.83±0.95</td><td>60.87±0.91</td><td>42.86±0.78</td><td>52.16±0.78</td></tr><tr><td>×</td><td>√</td><td>×</td><td>44.45±0.92</td><td>61.97±0.90</td><td>44.20±0.77</td><td>54.83±0.79</td></tr><tr><td>√</td><td>√</td><td>×</td><td>47.59±1.00</td><td>64.32±0.86</td><td>47.01±0.84</td><td>56.68±0.81</td></tr><tr><td>√</td><td>√</td><td>√</td><td>49.18±0.96</td><td>67.14±0.85</td><td>47.54±0.81</td><td>59.10±0.79</td></tr></table>
|
| 159 |
+
|
| 160 |
+
To represent the class separability, for each sample $x _ { i }$ with the class label $y _ { i }$ , we calculate the ratio of its distance to the prototype of class $y _ { i }$ to the distance to the closest neighbouring class prototype. Then the average is computed over all samples in novel classes, which is termed Average Distance Ratio (ADR). Formally, $\begin{array} { r } { A D R = \frac { 1 } { | \mathcal { X } _ { N } | } \sum _ { x _ { i } \in \mathcal { X } _ { \mathcal { N } } } { \frac { | | f ( x _ { i } ) - p _ { y _ { i } } | | } { \operatorname* { m i n } _ { k \neq y _ { i } } | | f ( x _ { i } ) - p _ { k } | | } } } \end{array}$ . When ADR is less than 1, most samples can be correctly classified into their ground-truth classes. We calculate the ADR for the source domain and target domain separately to validate whether the learned representations can generalize across different domains.
|
| 161 |
+
|
| 162 |
+
In experiments, we compare the proposed stabPA approach with a FSL baseline method (Tian et al., 2020) that does not leverage target images, and Basic PA which aligns two domains by simply minimizing the point-to-point distance between prototypes of two domains (Xie et al., 2018). The results are presented in Figure 3 (e)-(g). We can notice that all these methods can achieve lower domain distance as training processes, and Basic PA gets the lowest domain distance at the end. However, Basic PA does not improve the class separability as much as our approach, as shown in Figure 3 (f)-(g). The inferior class separability can be understood that Basic PA merely aims to reduce the feature distance between two domains, without taking account of the intra-class and inter-class distances in the learned feature space. Rather than the global alignment adopted by Basic PA, the proposed stabPA considers the feature-to-prototype distances across different domains and classes, so that the domain alignment and class separability can be improved at the same time.
|
| 163 |
+
|
| 164 |
+
# 5.3.3 ABLATION STUDIES
|
| 165 |
+
|
| 166 |
+
We conduct ablation studies on various components of the stabPA. The results on the DomainNet dataset are shown in Table 3. As all key components are removed, we adopt the baseline method Tian et al. (2020) to train feature extractor with only the source data, which is the first row of the table. When the unlabeled target data are available, applying either source-to-target alignment or target-to-source alignment can improve the performance evidently. Interestingly, we can see that the target-to-source alignment is more effective than the source-to-target alignment (about 1.2 points on average). This is probably because the source prototypes estimated by the ground truth labels are more accurate than the target prototypes estimated by the pseudo labels. Improving the quality of target prototypes may reduce this gap. When combing these two alignments together, we can get better results, indicating that the two kinds of alignment are to some extent complementary to each other. Finally, the best results are obtained by combining the strong data augmentation techniques, verifying that strong data augmentation can further strengthen the cross-domain alignment.
|
| 167 |
+
|
| 168 |
+
# 6 CONCLUSIONS
|
| 169 |
+
|
| 170 |
+
In this work, we have investigated a novel problem in FSL, namely CDCS-FSL, where a domain shift exists between the support set and query set. To tackle this problem, we have proposed stabPA, a prototype-based domain alignment framework to learn compact and aligned representations. On two widely-used multi-domain FSL datasets, we have built benchmarks and compared our approach to multiple elaborated baselines. Extensive experimental results have demonstrated the advantage of our approach. Through more in-depth analysis, we have also validated the generalization capability of the representations learned by stabPA and the effectiveness of each component of the proposed model.
|
| 171 |
+
|
| 172 |
+
# 7 REPRODUCIBILITY STATEMENT
|
| 173 |
+
|
| 174 |
+
We have uploaded the source code as supplemental materials to ensure reproducibility.
|
| 175 |
+
|
| 176 |
+
# REFERENCES
|
| 177 |
+
|
| 178 |
+
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.
|
| 179 |
+
|
| 180 |
+
Yoshua Bengio, Jer´ ome Louradour, Ronan Collobert, and Jason Weston. Curriculum learning. In ˆ International Conference on Machine Learning, 2009.
|
| 181 |
+
|
| 182 |
+
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, 2020.
|
| 183 |
+
|
| 184 |
+
Wei-Yu Chen, Yen-Cheng Liu, Zsolt Kira, Yu-Chiang Frank Wang, and Jia-Bin Huang. A closer look at few-shot classification. In International Conference on Learning Representations, 2019.
|
| 185 |
+
|
| 186 |
+
Wentao Chen, Chenyang Si, Wei Wang, Liang Wang, Zilei Wang, and Tieniu Tan. Few-shot learning with part discovery and augmentation from unlabeled images. arXiv preprint arXiv:2105.11874, 2021.
|
| 187 |
+
|
| 188 |
+
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.
|
| 189 |
+
|
| 190 |
+
Terrance DeVries and Graham W Taylor. Improved regularization of convolutional neural networks with cutout. arXiv preprint arXiv:1708.04552, 2017.
|
| 191 |
+
|
| 192 |
+
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.
|
| 193 |
+
|
| 194 |
+
Yaroslav Ganin, Evgeniya Ustinova, Hana Ajakan, Pascal Germain, Hugo Larochelle, Franc¸ois Laviolette, Mario Marchand, and Victor Lempitsky. Domain-adversarial training of neural networks. The Journal of Machine Learning Research, 17(1):2096–2030, 2016.
|
| 195 |
+
|
| 196 |
+
Ian Goodfellow, Jean Pouget-Abadie, Mehdi Mirza, Bing Xu, David Warde-Farley, Sherjil Ozair, Aaron Courville, and Yoshua Bengio. Generative adversarial nets. Advances in Neural Information Processing Systems, 27, 2014.
|
| 197 |
+
|
| 198 |
+
Arthur Gretton, Karsten Borgwardt, Malte Rasch, Bernhard Scholkopf, and Alex Smola. A kernel ¨ method for the two-sample-problem. Advances in Neural Information Processing Systems, 19: 513–520, 2006.
|
| 199 |
+
|
| 200 |
+
Yanyang Gu, Zongyuan Ge, C Paul Bonnington, and Jun Zhou. Progressive transfer learning and adversarial domain adaptation for cross-domain skin disease classification. IEEE Journal of Biomedical and Health Informatics, 24(5):1379–1393, 2019.
|
| 201 |
+
|
| 202 |
+
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.
|
| 203 |
+
|
| 204 |
+
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.
|
| 205 |
+
|
| 206 |
+
Ran He, Xiang Wu, Zhenan Sun, and Tieniu Tan. Wasserstein cnn: Learning invariant features for nir-vis face recognition. IEEE Transactions on Pattern Analysis and Machine Intelligence, 41(7): 1761–1773, 2018.
|
| 207 |
+
|
| 208 |
+
Judy Hoffman, Eric Tzeng, Taesung Park, Jun-Yan Zhu, Phillip Isola, Kate Saenko, Alexei Efros, and Trevor Darrell. Cycada: Cycle-consistent adversarial domain adaptation. In International Conference on Machine Learning, pp. 1989–1998. PMLR, 2018.
|
| 209 |
+
|
| 210 |
+
Jaekyeom Kim, Hyoungseok Kim, and Gunhee Kim. Model-agnostic boundary-adversarial sampling for test-time generalization in few-shot learning. In Proceedings of the European conference on computer vision (ECCV), pp. 599–617. Springer, 2020.
|
| 211 |
+
|
| 212 |
+
Diederik P Kingma and Jimmy Ba. Adam: A method for stochastic optimization. arXiv preprint arXiv:1412.6980, 2014.
|
| 213 |
+
|
| 214 |
+
Kwonjoon Lee, Subhransu Maji, Avinash Ravichandran, and Stefano Soatto. Meta-learning with differentiable convex optimization. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, 2019.
|
| 215 |
+
|
| 216 |
+
Jiawei Liu, Zheng-Jun Zha, Di Chen, Richang Hong, and Meng Wang. Adaptive transfer network for cross-domain person re-identification. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, June 2019.
|
| 217 |
+
|
| 218 |
+
Mingsheng Long, ZHANGJIE CAO, Jianmin Wang, and Michael I Jordan. Conditional adversarial domain adaptation. In Advances in Neural Information Processing Systems, 2018a.
|
| 219 |
+
|
| 220 |
+
Mingsheng Long, Zhangjie Cao, Jianmin Wang, and Michael I Jordan. Conditional adversarial domain adaptation. In Advances in Neural Information Processing Systems, pp. 1645–1655, 2018b.
|
| 221 |
+
|
| 222 |
+
Jiquan Ngiam, Daiyi Peng, Vijay Vasudevan, Simon Kornblith, Quoc V Le, and Ruoming Pang. Domain adaptive transfer learning with specialist models. arXiv preprint arXiv:1811.07056, 2018.
|
| 223 |
+
|
| 224 |
+
Yingwei Pan, Ting Yao, Yehao Li, Yu Wang, Chong-Wah Ngo, and Tao Mei. Transferrable prototypical networks for unsupervised domain adaptation. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 2239–2247, 2019.
|
| 225 |
+
|
| 226 |
+
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.
|
| 227 |
+
|
| 228 |
+
Cheng Perng Phoo and Bharath Hariharan. Self-training for few-shot transfer across extreme task differences. In International Conference on Learning Representations, 2021.
|
| 229 |
+
|
| 230 |
+
Siyuan Qiao, Chenxi Liu, Wei Shen, and Alan L Yuille. Few-shot image recognition by predicting parameters from activations. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 7229–7238, 2018.
|
| 231 |
+
|
| 232 |
+
Sachin Ravi and Hugo Larochelle. Optimization as a model for few-shot learning. In International Conference on Learning Representations, 2017.
|
| 233 |
+
|
| 234 |
+
Andrei A. Rusu, Dushyant Rao, Jakub Sygnowski, Oriol Vinyals, Razvan Pascanu, Simon Osindero, and Raia Hadsell. Meta-learning with latent embedding optimization. In International Conference on Learning Representations, 2019.
|
| 235 |
+
|
| 236 |
+
Jake Snell, Kevin Swersky, and Richard Zemel. Prototypical networks for few-shot learning. In Advances in Neural Information Processing Systems, volume 30, 2017.
|
| 237 |
+
|
| 238 |
+
Kihyuk Sohn, David Berthelot, Chun-Liang Li, Zizhao Zhang, Nicholas Carlini, Ekin D Cubuk, Alex Kurakin, Han Zhang, and Colin Raffel. Fixmatch: Simplifying semi-supervised learning with consistency and confidence. arXiv preprint arXiv:2001.07685, 2020.
|
| 239 |
+
|
| 240 |
+
Flood Sung, Yongxin Yang, Li Zhang, Tao Xiang, Philip HS Torr, and Timothy M Hospedales. Learning to compare: Relation network for few-shot learning. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 1199–1208, 2018.
|
| 241 |
+
|
| 242 |
+
Antti Tarvainen and Harri Valpola. Mean teachers are better role models: Weight-averaged consistency targets improve semi-supervised deep learning results. In Advances in Neural Information Processing Systems, volume 30, 2017.
|
| 243 |
+
|
| 244 |
+
Yonglong Tian, Yue Wang, Dilip Krishnan, Joshua B Tenenbaum, and Phillip Isola. Rethinking fewshot image classification: a good embedding is all you need? In Proceedings of the European Conference on Computer Vision (ECCV), 2020.
|
| 245 |
+
|
| 246 |
+
Yi-Hsuan Tsai, Wei-Chih Hung, Samuel Schulter, Kihyuk Sohn, Ming-Hsuan Yang, and Manmohan Chandraker. Learning to adapt structured output space for semantic segmentation. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 7472–7481, 2018.
|
| 247 |
+
|
| 248 |
+
Hung-Yu Tseng, Hsin-Ying Lee, Jia-Bin Huang, and Ming-Hsuan Yang. Cross-domain few-shot classification via learned feature-wise transformation. In International Conference on Learning Representations, 2020.
|
| 249 |
+
|
| 250 |
+
Laurens Van der Maaten and Geoffrey Hinton. Visualizing data using t-sne. Journal of Machine Learning Research, 9(11), 2008.
|
| 251 |
+
|
| 252 |
+
Hemanth Venkateswara, Jose Eusebio, Shayok Chakraborty, and Sethuraman Panchanathan. Deep hashing network for unsupervised domain adaptation. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 5018–5027, 2017.
|
| 253 |
+
|
| 254 |
+
Ricardo Vilalta and Youssef Drissi. A perspective view and survey of meta-learning. Artificial Intelligence Review, 18(2):77–95, 2002.
|
| 255 |
+
|
| 256 |
+
Shaoan Xie, Zibin Zheng, Liang Chen, and Chuan Chen. Learning semantic representations for unsupervised domain adaptation. In International Conference on Machine Learning, pp. 5423– 5432. PMLR, 2018.
|
| 257 |
+
|
| 258 |
+
Chi Zhang, Yujun Cai, Guosheng Lin, and Chunhua Shen. Deepemd: Few-shot image classification with differentiable earth mover’s distance and structured classifiers. In IEEE/CVF Conference on Computer Vision and Pattern Recognition, June 2020.
|
| 259 |
+
|
| 260 |
+
Pan Zhang, Bo Zhang, Ting Zhang, Dong Chen, Yong Wang, and Fang Wen. Prototypical pseudo label denoising and target structure learning for domain adaptive semantic segmentation. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 12414– 12424, 2021.
|
| 261 |
+
|
| 262 |
+
Qiming Zhang, Jing Zhang, Wei Liu, and Dacheng Tao. Category anchor-guided unsupervised domain adaptation for semantic segmentation. In Advances in Neural Information Processing Systems, volume 32, 2019.
|
| 263 |
+
|
| 264 |
+
Zhedong Zheng and Yi Yang. Rectifying pseudo label learning via uncertainty estimation for domain adaptive semantic segmentation. International Journal of Computer Vision, 129(4):1106–1120, 2021.
|
| 265 |
+
|
| 266 |
+
# A APPENDIX
|
| 267 |
+
|
| 268 |
+
# A.1 IMPLEMENTATION DETAILS
|
| 269 |
+
|
| 270 |
+
Hyperparameters. In our implementation, ResNet-18 (He et al., 2016) is adopted as the backbone, which outputs a 512-d feature vector. Before feeding the vector for prototypical alignment, we apply $\ell _ { 2 }$ normalization for the feature vector and prototypes. The temperature $\tau$ for $\ell _ { s - t }$ and $\ell _ { t - s }$ is 0.25 and 0.1, respectively. To control the loss weight for $\ell _ { s - t }$ , $T _ { m a x }$ and $\alpha$ are set as 50,000 and 7, respectively. The loss weight for $\ell _ { t - s }$ is fitted adaptively by setting the confidence threshold $\beta = 0 . 5$ . We set $\lambda = 0 . 2$ to balance the pseudo label generated by the initial classifier and the online updated classifier. The momentum term $m$ is set as 0.99.
|
| 271 |
+
|
| 272 |
+
Training. We train our approach for 50 epochs on the DomainNet dataset. On the smaller OfficeHome dataset, we train the model for 100 epochs. Adam (Kingma & Ba, 2014) is adopted as the default optimizer with the learning rate as 1e-3. The batch size is set as 256, where source data and target data have the same number in a batch.
|
| 273 |
+
|
| 274 |
+
Evaluation. During evaluation, we fix the feature extractor and apply $\ell _ { 2 }$ normalization to the output feature vector. The linear classification head for each few-shot task (episode) is randomly initialized, and trained on the support features for 1000 steps with logistic regression. 15 query samples per class are used to evaluate the performance of the learned classifier. We finally report the average accuracy over 600 episodes with $9 5 \%$ confidence interval.
|
| 275 |
+
|
| 276 |
+
ProtoNet and RelationNet. ProtoNet and RelationNet are two meta-learning methods, which are trained on a series of few-shot tasks (episodes). During training, we randomly sample episodes from the base set, each of which contains $N = 5$ classes and $K = 5$ samples per class serving as the support set, and another 15 samples per class as the query set. We also train ProtoNet and RelationNet for 50 epochs on the DomainNet dataset and 100 epochs on the Office-Home dataset. The number of training episodes of each epoch is particularly defined to make sure the number of seen samples (both the support and query samples) in an epoch is roughly equal to the size of the dataset.
|
| 277 |
+
|
| 278 |
+
MetaOptNet. MetaOptNet aims to learn an embedding function that generalizes well to novel categories under the linear classification rule. We implement this method based on the official code 1 but replace the backbone network and optimizer to be the same as our approach. Similar to ProtoNet and RelationNet, the training process of MetaOptNet is also episodic.
|
| 279 |
+
|
| 280 |
+
Tian et al. Tian et al. (2020) follows the transfer learning paradigm, which trains a base model to classify base classes, and leverage the learned representations to classify novel classes by learning a new classification head. We train this baseline with the same optimization method as our approach except that the batch size is set as 128 as only source data are used for training.
|
| 281 |
+
|
| 282 |
+
DeepEMD. DeepEMD contains two training phases: pre-training and meta-training. We use the output model of Tian et al. as the pre-trained model and then follow the official implementation 2 to finetune the model via meta-training.
|
| 283 |
+
|
| 284 |
+
DANN. We use a three-layer fully connected network as the domain discriminator to implement DANN, following the Pytorch implementation 3 released by Long et al. (2018b). The gradient reverse layer (Ganin et al., 2016) is adopted to train the feature vector and domain discriminator in an adversarial manner. To stabilize training, the weight of the adversarial loss starts from zero, and gradually grows to one.
|
| 285 |
+
|
| 286 |
+
Mean Teacher, Fixmatch and STARTUP. All of these approaches use pseudo-labeled samples to train the model. Differently, Mean Teacher predicts pseudo labels with a teacher network that is the ensemble of historical models by aggregating their model weights with exponential moving average (EMA). In our implementation, the smoothing coefficient for EMA is set as 0.99. Fixmatch trains the model with a consistency loss, i.e., enforcing the network prediction for a strongly augmented sample to be consistent with the prediction of its weakly augmented counterpart. We implement Fixmatch based on a publicly available implementation4. STARTUP adopts fixed pseudo labels that are predicted by a classifier pre-trained on the base set, and imposes a self-supervised loss on the target data. In our re-implementation, we do not utilize the self-supervised loss item since we find that it does not provide improvement in our case.
|
| 287 |
+
|
| 288 |
+
# A.2 PSEUDO LABEL UPDATE STRATEGY
|
| 289 |
+
|
| 290 |
+
Since we resort to pseudo labels for prototype estimation and feature alignment, ensuring the pseudo label accuracy is very important to the effectiveness of our bi-directional prototypical alignment strategy. Pseudo labels can be predicted with a fixed classifier pre-trained on the source base dataset, as in Phoo & Hariharan (2021), or a classifier that is online updated along the representation learning. In our implementation, we combine them together by linearly interpolating their pseudo labels.
|
| 291 |
+
|
| 292 |
+
Table 4: The impact of interpolation coefficient $\lambda$ .
|
| 293 |
+
|
| 294 |
+
<table><tr><td rowspan="2">Method</td><td rowspan="2">入</td><td colspan="2">painting-real</td><td colspan="2">real-painting</td></tr><tr><td>1-shot</td><td>5-shot</td><td>1-shot</td><td>5-shot</td></tr><tr><td rowspan="3">ls-t</td><td>0.0</td><td>48.56±1.04</td><td>66.24±0.92</td><td>48.89±0.85</td><td>58.72±0.79</td></tr><tr><td>0.2</td><td>48.76±0.99</td><td>67.21±0.91</td><td>49.08±0.84</td><td>59.33±0.77</td></tr><tr><td>1.0</td><td>48.20±0.99</td><td>65.79±0.90</td><td>48.79±0.87</td><td>57.51±0.79</td></tr><tr><td rowspan="3">lt-s</td><td>0.0</td><td>47.83±1.01</td><td>66.30±0.92</td><td>48.26±0.83</td><td>59.17±0.77</td></tr><tr><td>0.2</td><td>48.53±1.02</td><td>67.09±0.94</td><td>48.88±0.84</td><td>60.18±0.80</td></tr><tr><td>1.0</td><td>48.93±1.01</td><td>67.12±0.94</td><td>48.53±0.86</td><td>59.29±0.80</td></tr><tr><td rowspan="3">ls-t&lt-s</td><td>0.0</td><td>48.35±1.02</td><td>66.96±0.91</td><td>48.72±0.84</td><td>59.78±0.78</td></tr><tr><td>0.2</td><td>49.31±1.06</td><td>68.15±0.92</td><td>49.63±0.84</td><td>60.13±0.79</td></tr><tr><td>1.0</td><td>48.74±1.02</td><td>66.81±0.93</td><td>49.26±0.87</td><td>59.33±0.81</td></tr></table>
|
| 295 |
+
|
| 296 |
+
When the interpolation coefficient $\lambda = 0$ (or1), our approach degenerates to only using the fixed (or online updated) classifier. We assess the effectiveness of this combining strategy on the DomainNet dataset. The results are shown in Table 4.
|
| 297 |
+
|
| 298 |
+
For the source-to-target alignment, we can see that interpolation with $\lambda = 0 . 2$ is better than both the fixed and online updated classifier. For the target-to-source alignment, $\lambda = 0 . 2$ and $\lambda = 1$ compete with each other, but both are better than $\lambda = 0$ . When applying alignment from two directions to form our final model, the use of combined pseudo labels is still better than using either of them. The reason for the success of the combination is that the pseudo labels predicted by online updated classifier will change constantly especially in early training stage, which disturbs the model training. Interpolation with the fixed pseudo labels can make the pseudo labels more consistent. On the other hand, the pseudo labels predicted by current classifier can rectify the noise in the fixed pseudo labels, as demonstrated in Zhang et al. (2021).
|
| 299 |
+
|
| 300 |
+
# A.3 DATASET PARTITION
|
| 301 |
+
|
| 302 |
+
# A.3.1 DOMAINNET
|
| 303 |
+
|
| 304 |
+
DomainNet contains 345 categories in total. We discard 19 categories with too few images and randomly split the rest 326 categories into three sets: 228 categories for the base set, 33 categories for the validation set, and 65 categories for the novel set. The detailed categories of each set are listed below:
|
| 305 |
+
|
| 306 |
+
$$
|
| 307 |
+
\mathcal { D } _ { b a s e } =
|
| 308 |
+
$$
|
| 309 |
+
|
| 310 |
+
{aircraft carrier, airplane, alarm clock, ambulance, animal migration, ant, asparagus, axe, backpack, bat, bathtub, beach, bear, beard, bee, belt, bench, bicycle, binoculars, bird, book, boomerang, bottlecap, bowtie, bracelet, brain, bread, bridge, broccoli, broom, bus, butterfly, cactus, cake, calculator, camera, candle, cannon, canoe, car, cat, ceiling fan, cell phone, cello, chair, church, circle, clock, cloud, coffee cup, computer, couch, cow, crab, crayon, crocodile, cruise ship, diamond, dishwasher, diving board, donut, dragon, dresser, drill, drums, duck, ear, elbow, elephant, envelope, eraser, eye, fan, feather, fence, finger, fire hydrant, fireplace, firetruck, flamingo, flashlight, flip flops, flower, flying saucer, foot, fork, frog, frying pan, giraffe, goatee, grapes, grass, guitar, hamburger, hammer, hand, harp, headphones, hedgehog, helicopter, helmet, hockey puck, hockey stick, horse, hot air balloon, hot tub, hourglass, hurricane, jacket, key, keyboard, knee, ladder, lantern, laptop, leaf, leg, light bulb, lighter, lightning, lion, lobster, lollipop, mailbox, marker, matches, megaphone, mermaid, microphone, microwave, moon, motorbike, moustache, nail, necklace, nose, octagon, oven, paint can, paintbrush, palm tree, panda, pants, paper clip, parachute, parrot, passport, peanut, pear, peas, pencil, penguin, pickup truck, picture frame, pizza, pliers, police car, pond, popsicle, postcard, potato, power outlet, purse, rabbit, radio, rain, rainbow, rake, remote control, rhinoceros, rifle, sailboat, school bus, scorpion, screwdriver, see saw, shoe, shorts, skateboard, skyscraper, smiley face, snail, snake, snorkel, soccer ball, sock, stairs, stereo, stethoscope, stitches, stove, strawberry, submarine, sweater, swing set, sword, t-shirt, table, teapot, teddy-bear, television, tent, the Eiffel Tower, the Mona Lisa, toaster, toe, toilet, tooth, toothbrush, tornado, tractor, train, tree, triangle, trombone, truck, underwear, van, vase, violin, washing machine, watermelon, waterslide, whale, wheel, windmill, wine bottle, zigzag}
|
| 311 |
+
|
| 312 |
+
$$
|
| 313 |
+
\mathcal { V } _ { v a l i d a t i o n } =
|
| 314 |
+
$$
|
| 315 |
+
|
| 316 |
+
{arm, birthday cake, blackberry, bulldozer, campfire, chandelier, cooler, cup, dumbbell, hexagon, hospital, house plant, ice cream, jail, lighthouse, lipstick, mushroom, octopus, raccoon, roller coaster, sandwich, saxophone, scissors, skull, speedboat,
|
| 317 |
+
|
| 318 |
+
spreadsheet, suitcase, swan, telephone, traffic light, trumpet, wine glass, wristwatch}
|
| 319 |
+
|
| 320 |
+
$$
|
| 321 |
+
\mathcal { 3 } _ { n o v e l } =
|
| 322 |
+
$$
|
| 323 |
+
|
| 324 |
+
{anvil, banana, bandage, barn, basket, basketball, bed, blueberry, bucket, camel, carrot, castle, clarinet, compass, cookie, dog, dolphin, door, eyeglasses, face, fish, floor lamp, garden, garden hose, golf club, hat, hot dog, house, kangaroo, knife, map, monkey, mosquito, mountain, mouth, mug, ocean, onion, owl, piano, pig, pillow, pineapple, pool, river, rollerskates, sea turtle, sheep, shovel, sink, sleeping bag, spider, spoon, squirrel, steak, streetlight, string bean, syringe, tennis racquet, the Great Wall of China, tiger, toothpaste, umbrella, yoga, zebra}
|
| 325 |
+
|
| 326 |
+
# A.3.2 OFFICE-HOME
|
| 327 |
+
|
| 328 |
+
There are 65 categories in the Office-Home dataset. We select 40 categories as the base set, 10 categories as the validation set, and 15 categories as the novel set, which are listed below:
|
| 329 |
+
|
| 330 |
+
$$
|
| 331 |
+
\mathcal { D } _ { b a s e } =
|
| 332 |
+
$$
|
| 333 |
+
|
| 334 |
+
{alarm clock, bike, bottle, bucket, calculator, calendar, chair, clipboards, curtains, desk lamp, eraser, exit sign, fan, file cabinet, folder, glasses, hammer, kettle, keyboard, lamp shade, laptop, monitor, mouse, mug, paper clip, pen, pencil, postit notes, printer, radio, refrigerator, scissors, sneakers, speaker, spoon, table, telephone, toothbrush, toys, tv}
|
| 335 |
+
|
| 336 |
+
$$
|
| 337 |
+
\mathcal { V } _ { v a l i d a t i o n } =
|
| 338 |
+
$$
|
| 339 |
+
|
| 340 |
+
{bed, computer, couch, flowers, marker, mop, notebook, pan, shelf, soda}
|
| 341 |
+
|
| 342 |
+
$$
|
| 343 |
+
\mathcal { 3 } _ { n o v e l } =
|
| 344 |
+
$$
|
| 345 |
+
|
| 346 |
+
{backpack, batteries, candles, drill, flipflops, fork, helmet, knives, oven, push pin, ruler, screwdriver, sink, trash can, webcam}
|
md/dev/NjeEfP7e3KZ/NjeEfP7e3KZ.md
ADDED
|
@@ -0,0 +1,302 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Revisiting Heterophily For Graph Neural Networks
|
| 2 |
+
|
| 3 |
+
Sitao Luan1,2, Chenqing $\mathbf { H u a } ^ { 1 , 2 }$ , Qincheng ${ { \bf L } } { \bf u } ^ { 1 }$ , Jiaqi $\mathbf { Z } \mathbf { h } \mathbf { u } ^ { 1 }$ , Mingde Zhao1,2, Shuyuan Zhang1,2, Xiao-Wen Chang1, Doina Precup1,2,3 {sitao.luan $@$ mail, chenqing.hua $@$ mail, qincheng.lu $@$ mail, jiaqi.zhu $@$ mail, mingde.zhao $@$ mail, shuyuan.zhang $@$ mail, chang@cs, dprecup@cs}.mcgill.ca 1McGill University; 2Mila; 3DeepMind
|
| 4 |
+
|
| 5 |
+
# Abstract
|
| 6 |
+
|
| 7 |
+
Graph Neural Networks (GNNs) extend basic Neural Networks (NNs) by using graph structures based on the relational inductive bias (homophily assumption). While GNNs have been commonly believed to outperform NNs in real-world tasks, recent work has identified a non-trivial set of datasets where their performance compared to NNs is not satisfactory. Heterophily has been considered as the main cause of this empirical observation and numerous works have been put forward to address it. In this paper, we first revisit the widely used homophily metrics and point out that their consideration of only graph-label consistency is a shortcoming. Then, we study heterophily from the perspective of post-aggregation node similarity and define new homophily metrics, which are verified to be advantageous compared to existing ones. Based on this investigation, we prove that some harmful cases of heterophily can be effectively addressed by local diversification operation. Then, we propose the Adaptive Channel Mixing (ACM), a framework to adaptively exploit aggregation, diversification and identity channels node-wisely to extract richer localized information for diverse node heterophily situations. ACM is more powerful than the commonly used uni-channel framework for node classification tasks on heterophilic graphs and is easy to be implemented in baseline GNN layers. When evaluated on 10 benchmark node classification tasks, ACM-augmented baselines consistently achieve significant performance gain, exceeding state-of-theart GNNs on most tasks without incurring significant computational burden. Code: https://github.com/SitaoLuan/ACM-GNN
|
| 8 |
+
|
| 9 |
+
# 1 Introduction
|
| 10 |
+
|
| 11 |
+
Deep Neural Networks (NNs) $\pmb { \mathbb { Z } } 2 \mathbf { l }$ have revolutionized many machine learning areas, including image recognition $\scriptstyle { \left[ \left[ 2 1 \right] \right] }$ , speech recognition $\mathbb { \lVert 1 3 \rVert }$ and natural language processing $\left[ \left[ 2 \right] \right]$ , due to their effectiveness in learning latent representations from Euclidean data. Recent research has shifted focus on non-Euclidean data $\boxed { 6 }$ , e.g., relational data or graphs. Combining graph signal processing and convolutional neural networks $\pmb { \pmb { \pmb { \frac { \ d H } { \ d H } } } }$ , numerous Graph Neural Network (GNN) architectures have been proposed [39, 10, 15, 41, 19, 30], which empirically outperform traditional NNs on graph-based machine learning tasks such as node classification, graph classification, link prediction and graph generation, etc.GNNs are built on the homophily assumption $\pmb { \Vert 3 5 \Vert }$ : connected nodes tend to share similar attributes with each other $\pmb { \mathbb { I } } \pmb { \mathbb { 1 } }$ , which offers additional information besides node features. This relational inductive bias $\pmb { \mathbb { B } } \|$ is believed to be a key factor leading to GNNs’ superior performance over NNs’ in many tasks.
|
| 12 |
+
|
| 13 |
+
However, growing empirical evidence suggests that GNNs are not always advantageous compared to traditional NNs. In some cases, even simple Multi-Layer Perceptrons (MLPs) can outperform GNNs by a large margin on relational data [46, 29, 32, 8]. An important reason for this is believed to be the heterophily problem: the homophily assumption does not always hold, so connected nodes may in fact have different attributes. Heterophily has received lots of attention recently and an increasing number of models have been put forward to address this problem [46, 29, 32, 8, 45, 44, 33, 16, 24]. In this paper, we first show that by only considering graph-label consistency, existing homophily metrics are not able to describe the effect of some cases of heterophily on aggregation-based GNNs. We propose a post-aggregation node similarity matrix, and based on it, we derive new homophily metrics, whose advantages are illustrated on synthetic graphs (Sec. 3). Then, we prove that diversification operation can help to address some harmful cases of heterophily (Sec. 4). Based on this, we propose the Adaptive Channel Mixing (ACM) GNN framework which augments uni-channel baseline GNNs, allowing them to exploit aggregation, diversification and identity channels adaptively, node-wisely and locally in each layer. ACM significantly boosts the performance of 3 uni-channel baseline GNNs by $2 . 0 4 \% \sim 2 7 . 5 \%$ for node classification tasks on 7 widely used benchmark heterophilic graphs, exceeding SOTA models $\left( \mathsf { S e c . } \bigtriangledown \right)$ on all of them. For 3 homophilic graphs, ACM-augmented GNNs can perform at least as well as the uni-channel baselines and are competitive compared with SOTA.
|
| 14 |
+
|
| 15 |
+
Contributions 1. To our knowledge, we are the first to analyze heterophily from post-aggregation node similarity perspective. 2. The proposed ACM framework is highly different from adaptive filterbank with multiple channels and existing GNNs for heterophily: 1) the traditional adaptive filterbank channels $\dot { \left[ \left| 4 0 \right| \right] }$ uses a scalar weight for each filter and this weight is shared by all nodes. In contrast, ACM provides a mechanism so that different nodes can learn different weights to utilize information from different channels to account for diverse local heterophily; 2) Unlike existing methods that leverage the high-order filters and global property of high-frequency signals [46, 29, 8, 16] which require more computational resources, ACM successfully addresses heterophily by considering only the nodewise local information adaptively. 3. Unlike existing methods that try to facilitate learning filters with high expressive power [46, 45, 8, 16], ACM aims that, when given a filter with certain expressive power, we can extract richer information from additional channels in a certain way to address heterophily. This makes ACM more flexible and easier to be implemented.
|
| 16 |
+
|
| 17 |
+
# 2 Preliminaries
|
| 18 |
+
|
| 19 |
+
In this section, we introduce notation and background knowledge. We use bold font for vectors $( e . g . , v )$ . Suppose we have an undirected connected graph $\mathcal { G } = ( \mathcal { V } , \mathcal { E } , A )$ , where $\nu$ is the node set with $| \nu | = N$ ; $\mathcal { E }$ is the edge set without self-loops; $\bar { A } \in \mathbf { \mathbb { R } } ^ { N \times N }$ is the symmetric adjacency matrix with $A _ { i , j } = 1$ if $e _ { i j } \in \mathcal { E }$ , otherwise $A _ { i , j } = 0$ . Let $D$ denote the diagonal degree matrix of $\mathcal { G }$ , i.e., $\begin{array} { r } { D _ { i , i } = \bar { d } _ { i } = \sum _ { j } \bar { A _ { i , j } } } \end{array}$ . Let ${ \mathcal { N } } _ { i }$ denote the neighborhood set of node $i$ , i.e., $\tilde { \mathcal { N } _ { i } } = \{ j : e _ { i j } \in \mathcal { E } \}$ . A graph signal is a vector $\pmb { x } \in \mathbb { R } ^ { N }$ defined on $\nu$ , where $\mathbf { \Delta } _ { \mathbf { \mathcal { X } } _ { i } }$ is associated with node $i$ . We also have a feature matrix $X \in \mathbb { R } ^ { N \times F }$ 2 V , whose columns are graph signals and whose $i$ -th row $X _ { i , \astrosun }$ : is a feature vector of node $i$ . We use $Z \in \mathbb { R } ^ { N \times C }$ to denote the label encoding matrix, whose $i$ -th row $Z _ { i , : }$ : is the one-hot encoding of the label of node $i$ .
|
| 20 |
+
|
| 21 |
+
# 2.1 Graph Laplacian, Affinity Matrix and Variants
|
| 22 |
+
|
| 23 |
+
The (combinatorial) graph Laplacian is defined as $L = D - A$ , which is Symmetric Positive Semi-Definite (SPSD) $\bar { \bigtriangledown } |$ . Its eigendecomposition is ${ \cal L } \ : = \ : U \Lambda U ^ { T }$ , where the columns $\mathbf { \Delta } \mathbf { u } _ { i }$ of $U \in \mathbb { R } ^ { N \times N }$ are orthonormal eigenvectors, namely the graph Fourier basis, $\boldsymbol { \Lambda } = \operatorname { d i a g } ( \lambda _ { 1 } , \ldots , \lambda _ { N } )$ with $\lambda _ { 1 } \leq \cdots \leq \lambda _ { N }$ . These eigenvalues are also called frequencies.
|
| 24 |
+
|
| 25 |
+
In additional to $L$ , some variants are also commonly used, e.g., the symmetric normalized Laplacian $L _ { \mathrm { s v m } } = D ^ { - 1 / 2 } L D ^ { - 1 / 2 } = I - D ^ { - 1 / 2 } A D ^ { - 1 / 2 }$ and the random walk normalized Laplacian $L _ { \mathrm { r w } } =$ $D ^ { \dot { - } 1 } L = I - D ^ { - 1 } A$ . The graph Laplacian and its variants can be considered as high-pass filters for graph signals. The affinity (transition) matrices can be derived from the Laplacians, e.g., $A _ { \mathrm { r w } } =$ $I - L _ { \mathrm { r w } } = D ^ { - 1 } A$ , $A _ { \mathrm { s y m } } = \bar { I } - L _ { \mathrm { s y m } } = D ^ { - 1 / 2 } A D ^ { - 1 / 2 }$ and are considered to be low-pass filters $\textcircled { 1 3 4 } \textcircled { 1 }$ . Their eigenvalues satisfy $\lambda _ { i } ( A _ { \mathrm { r w } } ) = \lambda _ { i } ( A _ { \mathrm { s y m } } ) = 1 - \lambda _ { i } ( L _ { \mathrm { s y m } } ) = 1 - \lambda _ { i } ( L _ { \mathrm { r w } } ) { \it \bar { \Psi } } \in ( - 1 , 1 ]$ Applying the renormalization trick $\mathbb { 1 1 9 }$ to affinity and Laplacian matrices respectively leads to $\hat { A } _ { \mathrm { s y m } } ^ { - 1 } = \bar { \tilde { D } } ^ { - 1 / 2 } \tilde { A } \tilde { D } ^ { - 1 / 2 }$ and $\hat { L } _ { \mathrm { s y m } } = I - \hat { A } _ { \mathrm { s y m } }$ , where ${ \tilde { A } } \equiv A + I$ and $\tilde { D } \equiv D + I$ . The renormalized affinity matrix essentially adds a self-loop to each node in the graph, and is widely used in Graph Convolutional Network (GCN) $\mathbb { \lVert 1 9 \rVert }$ as follows:
|
| 26 |
+
|
| 27 |
+
$$
|
| 28 |
+
Y = \mathrm { s o f t m a x } ( { \hat { A } } _ { \mathrm { s y m } } \mathrm { R e L U } ( { \hat { A } } _ { \mathrm { s y m } } X W _ { 0 } ) W _ { 1 } )
|
| 29 |
+
$$
|
| 30 |
+
|
| 31 |
+
where $W _ { 0 } \in \mathbb { R } ^ { F \times F _ { 1 } }$ and $W _ { 1 } \in \mathbb { R } ^ { F _ { 1 } \times O }$ are learnable parameter matrices. GCNs can be trained by minimizing the following cross entropy loss
|
| 32 |
+
|
| 33 |
+
$$
|
| 34 |
+
\mathcal { L } = - \mathrm { t r a c e } ( Z ^ { T } \log Y )
|
| 35 |
+
$$
|
| 36 |
+
|
| 37 |
+
where $\log ( \cdot )$ is a component-wise logarithm operation. The random walk renormalized matrix $\hat { A } _ { \mathrm { r w } } = \tilde { D } ^ { - 1 } \tilde { A }$ , which shares the same eigenvalues as $\hat { A } _ { \mathrm { s y m } }$ , can also be applied in GCN. The corresponding Laplacian is defined as $\hat { L } _ { \mathrm { r w } } = I - \hat { A } _ { \mathrm { r w } }$ . The matrix $\hat { A } _ { \mathrm { r w } }$ is essentially a random walk matrix and behaves as a mean aggregator that is applied in spatial-based GNNs [15, 14]. To bridge spectral and spatial methods, we use $\hat { A } _ { r w }$ in this paper.
|
| 38 |
+
|
| 39 |
+
# 2.2 Metrics of Homophily
|
| 40 |
+
|
| 41 |
+
The homophily metrics are defined by considering different relations between node labels and graph structures. There are three commonly used homophily metrics: edge homophily [1, $\boxed { 4 6 }$ , node homophily $\pmb { \mathbb { B } } 6 \|$ and class homophily $\underline { { \| \mathbf { \check { 2 } 6 } \| } } \big \|$ , defined as follows:
|
| 42 |
+
|
| 43 |
+
$$
|
| 44 |
+
\begin{array} { l } { \displaystyle \mathcal { I } _ { \mathrm { c d g c } } ( \boldsymbol { \mathcal { G } } ) = \frac { \big | \{ e _ { u v } \mid e _ { u v } \in \mathcal { E } , Z _ { u , : } = Z _ { v , : } \} \big | } { | \mathcal { E } | } , H _ { \mathrm { n o d c } } ( \boldsymbol { \mathcal { G } } ) = \frac { 1 } { | \mathcal { V } | } \displaystyle \sum _ { v \in \mathcal { V } } H _ { \mathrm { n o d e } } ^ { v } = \frac { 1 } { | \mathcal { V } | } \displaystyle \sum _ { v \in \mathcal { V } } \frac { \big | \{ u \mid u \in \mathcal { N } _ { v } , Z _ { u , : } = Z _ { v , : } \} \big | } { d _ { v } } \mathrm { ~ , ~ } } \\ { \displaystyle \mathcal { I } _ { \mathrm { c l a s s } } ( \boldsymbol { \mathcal { G } } ) = \frac { 1 } { C - 1 } \displaystyle \sum _ { k = 1 } ^ { C } \Big [ h _ { k } - \frac { \big | \{ v \mid Z _ { v , k } = 1 \} \big | } { N } \Big ] _ { + } , h _ { k } = \frac { \sum _ { v \in \mathcal { V } } \big | \{ u \mid Z _ { v , k } = 1 , u \in \mathcal { N } _ { v } , Z _ { u , : } = Z _ { v , : } \} \big | } { \sum _ { v \in \{ v \mid Z _ { v , k } = 1 \} } d _ { v } } \mathrm { ~ . ~ } } \end{array}
|
| 45 |
+
$$
|
| 46 |
+
|
| 47 |
+
where $H _ { \mathrm { n o d e } } ^ { v }$ is the local homophily value for node $v$ ; $[ a ] _ { + } = \operatorname* { m a x } ( a , 0 )$ ; $h _ { k }$ is the class-wise homophily metric $\left\| 2 6 \right\|$ . All metrics are in the range of $[ 0 , 1 ]$ ; a value close to $1$ corresponds to strong homophily, while a value close to 0 indicates strong heterophily. $H _ { \mathrm { e d g e } } ( { \mathcal { G } } )$ measures the proportion of edges that connect two nodes in the same class; $H _ { \mathrm { n o d e } } ( \mathcal { G } )$ evaluates the average proportion of edge-label consistency of all nodes; $H _ { \mathrm { c l a s s } } ( \mathcal { G } )$ tries to avoid sensitivity to imbalanced classes, which can make $H _ { \mathrm { e d g e } } ( { \mathcal { G } } )$ misleadingly large. The above definitions are all based on the linear featureindependent graph-label consistency. The inconsistency relation is implied to have a negative effect to the performance of GNNs. With this in mind, in the following section, we give an example to illustrate the shortcomings of the above metrics and propose new feature-independent metrics that are defined from post-aggregation node similarity perspective, which is novel.
|
| 48 |
+
|
| 49 |
+
# 3 Analysis of Heterophily
|
| 50 |
+
|
| 51 |
+
# 3.1 Motivation and Aggregation Homophily
|
| 52 |
+
|
| 53 |
+
Heterophily is widely believed to be harmful for message-passing based GNNs [46, 36, 8] because, intuitively, features of nodes in different classes will be falsely mixed, leading nodes to be indistinguishable $| \overline { { \mathbb { H } 6 } } |$ . Nevertheless, it is not always the case, e.g., the bipartite graph2 shown in Figure $\nsupseteq$ is highly heterophilic according to the existing homophily metrics in equation $\textcircled { 3 }$ but after mean aggregation, the nodes in classes 1 and 2 just exchange colors and are still distinguishable3. This example tells us that, besides graph-label consistency, we need to study the relation between nodes after aggregation step.
|
| 54 |
+
|
| 55 |
+

|
| 56 |
+
Figure 1: Example of harmless heterophily
|
| 57 |
+
|
| 58 |
+
To this end, we first define the post-aggregation node similarity matrix as follows:
|
| 59 |
+
|
| 60 |
+
$$
|
| 61 |
+
S ( \hat { A } , X ) \equiv \hat { A } X ( \hat { A } X ) ^ { T } \in \mathbb { R } ^ { N \times N }
|
| 62 |
+
$$
|
| 63 |
+
|
| 64 |
+
where $\hat { A } \in \mathbb { R } ^ { N \times N }$ denotes a general aggregation operator. $S ( { \hat { A } } , X )$ is essentially the gram matrix that measures the similarity between each pair of aggregated node features.
|
| 65 |
+
|
| 66 |
+
Relationship Between $S ( { \hat { A } } , X )$ and Gradient of SGC SGC $\lVert \rVert ^ { \mathrm { ~ H ~ 2 ~ } }$ is one of the most simple but representative GNN models and its output can be written as:
|
| 67 |
+
|
| 68 |
+
$$
|
| 69 |
+
Y = \mathrm { s o f t m a x } ( \hat { A } X W ) = \mathrm { s o f t m a x } ( Y ^ { \prime } )
|
| 70 |
+
$$
|
| 71 |
+
|
| 72 |
+
With the loss function in equation $\bigstar$ after each gradient descent step, we have $\begin{array} { r } { \Delta W = \gamma \frac { d \mathcal { L } } { d W } } \end{array}$ , where $\gamma$ is the learning rate. The update of $Y ^ { \prime }$ is (see Appendix $\boxed { \mathrm { E } }$ for derivation):
|
| 73 |
+
|
| 74 |
+
$$
|
| 75 |
+
\Delta Y ^ { \prime } = \hat { A } X \Delta W = \gamma \hat { A } X { \frac { d { \mathcal { L } } } { d W } } \propto \hat { A } X { \frac { d { \mathcal { L } } } { d W } } = \hat { A } X X ^ { T } \hat { A } ^ { T } ( Z - Y ) = S ( \hat { A } , X ) ( Z - Y )
|
| 76 |
+
$$
|
| 77 |
+
|
| 78 |
+
where $Z - Y$ is the prediction error matrix. The update direction of the prediction for node $i$ is essentially a weighted sum of the prediction error, i.e., $\begin{array} { r } { \Delta ( Y ^ { \prime } ) _ { i , : } = \sum _ { j \in \mathcal { V } } \left[ S ( \hat { A } , X ) \right] _ { i , j } ( Z - Y ) _ { j , } } \end{array}$ : and $\big [ S ( \hat { A } , X ) \big ] _ { i , j }$ can be considered as the weights. Intuitively, a high similarity value $\big [ S ( \hat { A } , X ) \big ] _ { i , j }$ means node $i$ tends to be updated to the same class as node $j$ . This indicates that $S ( { \hat { A } } , X )$ is closely related to a single layer GNN model.
|
| 79 |
+
|
| 80 |
+
Based on the above definition and observation, we define the aggregation similarity score as follows.
|
| 81 |
+
|
| 82 |
+
Definition 1. The aggregation similarity score is:
|
| 83 |
+
|
| 84 |
+
$$
|
| 85 |
+
\begin{array} { r l } { \left. { S _ { a g g } \bigl ( S ( \hat { A } , X ) \bigr ) } \quad } & { } \\ & { = \frac { 1 } { | \mathcal { V } | } \left| \left\{ v \big | \operatorname { M e a n } _ { u } \bigl ( \{ S ( \hat { A } , X ) _ { v , u } | Z _ { u , : } = Z _ { v , : } \} \right) \geq \operatorname { M e a n } _ { u } \bigl ( \{ S ( \hat { A } , X ) _ { v , u } | Z _ { u , : } \neq Z _ { v , : } \} \bigr ) \right\} \right| } \end{array}
|
| 86 |
+
$$
|
| 87 |
+
|
| 88 |
+
where ${ \mathrm { M e a n } } _ { u } \left( \{ \cdot \} \right)$ takes the average over u of a given multiset of values or variables.
|
| 89 |
+
|
| 90 |
+
$S _ { \mathrm { a g g } } ( S ( \hat { A } , X ) )$ measures the proportion of nodes $v \in \mathcal V$ as which the average weights on the set of nodes in the same class (including $v$ ) is larger than that in other classes. In practice, we observe that in most datasets, we will have $S _ { \mathrm { a g g } } ( S ( { \bar { A } } , X ) ) \geq 0 . 5 ^ { 4 } .$ To make the metric range in [0,1], like existing metrics, we rescale equation $^ { 7 }$ to the following modified aggregation similarity,
|
| 91 |
+
|
| 92 |
+
$$
|
| 93 |
+
S _ { \mathrm { a g g } } ^ { M } \bigl ( S ( \hat { A } , X ) \bigr ) = \bigl [ 2 S _ { \mathrm { a g g } } \bigl ( S ( \hat { A } , X ) \bigr ) - 1 \bigr ] _ { + }
|
| 94 |
+
$$
|
| 95 |
+
|
| 96 |
+
In order to measure the consistency between labels and graph structures without considering node features and to make a fair comparison with the existing homophily metrics in equation $\textcircled { 3 }$ we define the graph $( { \mathcal { G } } )$ aggregation $( \hat { A } )$ homophily and its modified version 5 as:
|
| 97 |
+
|
| 98 |
+
$$
|
| 99 |
+
H _ { \mathrm { a g g } } ( \mathcal { G } ) = S _ { \mathrm { a g g } } \big ( S ( \hat { A } , Z ) \big ) , H _ { \mathrm { a g g } } ^ { M } ( \mathcal { G } ) = S _ { \mathrm { a g g } } ^ { M } \big ( S ( \hat { A } , Z ) \big )
|
| 100 |
+
$$
|
| 101 |
+
|
| 102 |
+
As the example shown in Figure $\bigstar \bigstar \bigstar$ when $\hat { A } = \hat { A } _ { \mathrm { r w } }$ , it is easy to see that $H _ { \mathrm { a g g } } ( \mathcal { G } ) = H _ { \mathrm { a g g } } ^ { M } ( \mathcal { G } ) = 1$ and other metrics are 0. Thus, this new metric reflects the fact that nodes in classes 1 and 2 are still highly distinguishable after aggregation, while other metrics mentioned before fail to capture such information and misleadingly give value 0. This shows the advantage of $H _ { \mathrm { a g g } } ( { \mathcal { G } } )$ and $H _ { \mathrm { a g g } } ^ { M } ( { \mathcal { G } } )$ , which additionally exploit information from aggregation operator $\hat { A }$ and the similarity matrix.
|
| 103 |
+
|
| 104 |
+
To comprehensively compare $H _ { \mathrm { a g g } } ^ { M } ( { \mathcal { G } } )$ with the existing metrics on their ability to elucidate the influence of graph structure on GNN performance, we generate synthetic graphs with different homophily levels and evaluate SGC $\bar { \| 4 2 \| }$ and GCN $\mathbb { I m }$ on them in the next subsection.
|
| 105 |
+
|
| 106 |
+

|
| 107 |
+
Figure 2: Comparison of baseline performance under different homophily metrics.
|
| 108 |
+
|
| 109 |
+

|
| 110 |
+
Figure 3: Example of how diversification can address harmful heterophily
|
| 111 |
+
|
| 112 |
+
# 3.2 Empirical Evaluation and Comparison on Synthetic Graphs
|
| 113 |
+
|
| 114 |
+
In this subsection, we conduct experiments on synthetic graphs generated with different levels of $H _ { \mathrm { e d g e } } ^ { M } ( { \mathcal { G } } )$ to assess the output of $\dot { H } _ { \mathrm { a g g } } ^ { M } ( { \mathcal G } )$ in comparison with existing metrics.
|
| 115 |
+
|
| 116 |
+
Data Generation $\pmb { \& }$ Experimental Setup We first generated 10 graphs for each of 28 edge homophily levels, from 0.005 to 0.95, for a total of 280 graphs. In every generated graph, we had 5 classes, with 400 nodes in each class. For nodes in each class, we randomly generated 800 intra-class edges and $[ \frac { 8 0 0 } { H _ { \mathrm { e d g e } } ( \mathcal { G } ) } - 8 0 0 ]$ inter-class edges. The features of nodes in each class are sampled from node features in the corresponding class of 6 base datasets (Cora, CiteSeer, PubMed, Chameleon, Squirrel, Film). Nodes were randomly split into train/validation/test sets, in proportion of $6 0 \% / 2 0 \% / 2 0 \%$ . We trained 1-hop SGC (sgc-1) $| \bar { | 4 2 | }$ and GCN $\mathbb { \underline { { \ m o } } }$ on the synthetic graphs $\bigstar$ For each value of $H _ { \mathrm { e d g e } } ( { \mathcal { G } } )$ , we take the average test accuracy and standard deviationthat value. For each generated graph, we also calculate $H _ { \mathrm { n o d e } } ( \mathcal G ) , H _ { \mathrm { c l a s s } } ( \mathcal G )$ geneand $H _ { \mathrm { a g g } } ^ { M } ( { \mathcal { G } } )$ phs with. Model performance with respect to different homophily values is shown in Figure 2.
|
| 117 |
+
|
| 118 |
+
Comparison of Homophily Metrics The performance of SGC-1 and GCN is expected to be monotonically increasing if the homophily metric is informative. However, Figure 2(a)(b)(c) show that the performance curves under $H _ { \mathrm { e d g e } } ( \mathcal { G } ) , H _ { \mathrm { n o d e } } ( \mathcal { G } )$ and $H _ { \mathrm { c l a s s } } ( \mathcal { G } )$ are $U$ -shaped ${ \mathit { \Sigma } } _ { . } ^ { 7 } ,$ while Figure 2(d) reveals a nearly monotonic curve with a little numerical perturbation around 1. This indicates that $\overline { { H } } _ { \mathrm { a g g } } ^ { M } ( \mathcal { G } )$ provides a better indication of the way in which the graph structure affects the performance of SGC-1 and GCN than existing metrics. (See more discussion on aggregation homophily and theoretical results for regular graphs in Appendix $\underline { { \overline { { \mathbb { D } } } } } .$
|
| 119 |
+
|
| 120 |
+
# 4 Adaptive Channel Mixing (ACM)
|
| 121 |
+
|
| 122 |
+
In prior work [32, 8, 4], it has been shown that high-frequency graph signals, which can be extracted by a high-pass filter (HP), is empirically useful for addressing heterophily. In this section, based on the similarity matrix in equation $\mathbb { E } ,$ we theoretically prove that a diversification operation, i.e., HP filter, can address some cases of harmful heterophily locally. Besides, a node-wise analysis shows that different nodes may need different filters to process their neighborhood information. Based on the above analysis, in Sec. $^ { 4 . 2 }$ we propose Adaptive Channel Mixing (ACM), a 3-channel architecture which can adaptively exploit local and node-wise information from aggregation, diversification and identity channels.
|
| 123 |
+
|
| 124 |
+
# 4.1 Diversification Helps with Harmful Heterophily
|
| 125 |
+
|
| 126 |
+
We first consider the example shown in Figure $3 .$ From $S ( { \hat { A } } , X )$ , we can see that nodes $\{ 1 , 3 \}$ assign relatively large positive weights to nodes in class 2 after aggregation, which will make nodes $\{ 1 , 3 \}$ hard to be distinguished from nodes in class 2. However, we can still distinguish nodes $\{ 1 , 3 \}$ and $\{ 4 , 5 , 6 , 7 \}$ by considering their neighborhood differences: nodes $\{ 1 , 3 \}$ are different from most of their neighbors while nodes $\{ 4 , 5 , 6 , 7 \}$ are similar to most of their neighbors. This indicates that although some nodes become similar after aggregation, they are still distinguishable through their local surrounding dissimilarities.
|
| 127 |
+
|
| 128 |
+
This observation leads us to introduce the diversification operation, i.e., HP filter $I - { \hat { A } } \left[ \mathbb { D } \right] $ t o extract information regarding neighborhood differences, thereby addressing harmful heterophily. As $S ( I - { \hat { A } } , X )$ in Fig. $\textcircled { 3 }$ shows, nodes $\{ 1 , 3 \}$ will assign negative weights to nodes $\{ 4 , 5 , 6 , 7 \}$ after the diversification operation, i.e., nodes 1,3 treat nodes 4,5,6,7 as negative samples and will move away from them during backpropagation. This example reveals that there are cases in which the diversification operation is helpful to handle heterophily, while the aggregation operation is not. Based on this observation, we first define the diversification distinguishability of a node and the graph diversification distinguishability value, which measures the proportion of nodes for which the diversification operation is potentially helpful.
|
| 129 |
+
|
| 130 |
+
Definition 2 (Diversification Distinguishability (DD) based on $S ( I - { \hat { A } } , X ) )$ ). Given $S ( I - { \hat { A } } , X )$ , $a$ node $v$ is diversification distinguishable if the following two conditions are satisfied at the same time,
|
| 131 |
+
|
| 132 |
+
$$
|
| 133 |
+
\begin{array} { r } { I . \mathrm { ~ M e a n } _ { u } \left( \{ S ( I - \hat { A } , X ) _ { v , u } | u \in \mathcal { V } \wedge Z _ { u , : } = Z _ { v , : } \} \right) \geq 0 ; } \\ { 2 . \mathrm { ~ M e a n } _ { u } \left( \{ S ( I - \hat { A } , X ) _ { v , u } | u \in \mathcal { V } \wedge Z _ { u , : } \neq Z _ { v , : } \} \right) \leq 0 } \end{array}
|
| 134 |
+
$$
|
| 135 |
+
|
| 136 |
+
Then, graph diversification distinguishability value is defined as
|
| 137 |
+
|
| 138 |
+
$$
|
| 139 |
+
\mathrm { D D } _ { \hat { A } , X } ( { \mathcal G } ) = \frac { 1 } { | \mathcal V | } \Big | \{ v | v \in \mathcal V \wedge v i s d i v e r s i f i c a t i o n d i s t i n g u i s h a b l e \} \Big |
|
| 140 |
+
$$
|
| 141 |
+
|
| 142 |
+
We can see that $\mathrm { D D } _ { \hat { A } , X } ( { \mathcal G } ) \in [ 0 , 1 ]$ . Based on Def. 2, the effectiveness of diversification in addressing heterophily can be theoretically proved under certain conditions:
|
| 143 |
+
|
| 144 |
+
Theorem 1. (See Appendix $\mathbf { G }$ for proof). For $C = 2$ , suppose $X = Z , \hat { A } = \hat { A } _ { \mathrm { r w } }$ . Then for any $I - { \hat { A } } _ { \mathrm { r w } }$ , all nodes are diversification distinguishable and $\mathrm { D D } _ { \hat { A } , Z } ( { \mathcal G } ) = 1$ .
|
| 145 |
+
|
| 146 |
+
With the above results for HP filters, we will now introduce the concept of filterbank which combines both LP (aggregation) and HP (diversification) filters and can potentially handle various local heterophily cases. We then develop ACM framework in the following subsection.
|
| 147 |
+
|
| 148 |
+
# 4.2 Filterbank and Adaptive Channel Mixing (ACM) Framework
|
| 149 |
+
|
| 150 |
+
Filterbank For the graph signal $_ { \textbf { \em x } }$ defined on $\mathcal { G }$ , a 2-channel linear (analysis) filterbank $\underline { { \breve { \mathbb { I I } } } } | \overline { { \mathbb { I } } } |$ includes a pair of filters $H _ { \mathrm { L P } } , H _ { \mathrm { H P } }$ , which retain the low-frequency and high-frequency content of $_ { \textbf { \em x } }$ , respectively. Most existing GNNs use a uni-channel filtering architecture [19, 41, 15] with either LP or HP channel, which only partially preserves the input information. Unlike the uni-channel architecture, filterbanks with $H _ { \mathrm { L P } } + H _ { \mathrm { H P } } = I$ do not lose any information from the input signal, which is called the perfect reconstruction property [11]. Generally, the Laplacian matrices $( L _ { \mathrm { s y m } } , L _ { \mathrm { r w } } , \hat { L } _ { \mathrm { s y m } } , \hat { L } _ { \mathrm { r w } } )$ can be regarded as HP filters $\mathbb { \ m }$ and affinity matrices $ { \langle A _ { \mathrm { s y m } } }$ , $A _ { \mathrm { r w } }$ , $\hat { A } _ { \mathrm { s y m } }$ , $\hat { A } _ { \mathrm { r w } } )$ can be treated as LP filters $\pm \pm \pmb { \mathbb { B 4 } } \pmb { \mathbb { B 4 } }$ . Moreover, we extend the concept of filterbank and view MLPs as using the identity (fullpass) filterbank with $H _ { \mathrm { L P } } = I$ and $H _ { \mathrm { H P } } = 0$ , which also satisfies $H _ { \mathrm { L P } } + H _ { \mathrm { H P } } = I + 0 = I .$ .
|
| 151 |
+
|
| 152 |
+

|
| 153 |
+
Figure 4: $H _ { \mathrm { n o d e } } ^ { v }$ distributions
|
| 154 |
+
|
| 155 |
+
Node-wise Channel Mixing for Diverse Local Homophily The example in Figure 3 also shows that different nodes may need the local information extracted from different channels, e.g., nodes $\{ 1 , 3 \}$ demand information from the HP channel while node 2 only needs information from the LP channel. Figure $\sharp$ reveals that nodes have diverse distributions of node local homophily $H _ { \mathrm { n o d e } } ^ { v }$ across different datasets. In order to adaptively leverage the LP, HP and identity channels in GNNs to deal with the diverse local heterophily situations, we will now describe our proposed Adaptive Channel Mixing (ACM) framework.
|
| 156 |
+
|
| 157 |
+
Adaptive Channel Mixing (ACM) We will use $\operatorname { G C N } \big \lbrack$ as an example to introduce the ACM framework in matrix form, but the framework can be combined in a similar manner to many different GNNs. The ACM framework includes the following steps:
|
| 158 |
+
|
| 159 |
+
# Step 1. Feature Extraction for Each Channel:
|
| 160 |
+
|
| 161 |
+
Option 1: Option 2: $\begin{array} { r l } & { \colon H _ { L } ^ { l } = { \mathrm { R e L U } } \left( H _ { \mathrm { L P } } H ^ { l - 1 } W _ { L } ^ { l - 1 } \right) , H _ { H } ^ { l } = { \mathrm { R e L U } } \left( H _ { \mathrm { R P } } H ^ { l - 1 } W _ { H } ^ { l - 1 } \right) , H _ { I } ^ { l } = { \mathrm { R e L U } } \left( I H ^ { l - 1 } W _ { I } ^ { l - 1 } \right) ; } \\ & { \colon H _ { L } ^ { l } = H _ { \mathrm { L P } } { \mathrm { R e L U } } \left( H ^ { l - 1 } W _ { L } ^ { l - 1 } \right) , H _ { H } ^ { l } = H _ { \mathrm { H P } } { \mathrm { R e L U } } \left( H ^ { l - 1 } W _ { H } ^ { l - 1 } \right) , H _ { I } ^ { l } = I { \mathrm { R e L U } } \left( H ^ { l - 1 } W _ { I } ^ { l - 1 } \right) ; } \end{array}$ $H ^ { 0 } = X \in \mathbb { R } ^ { N \times F _ { 0 } }$ , $W _ { L } ^ { l - 1 }$ , $W _ { H } ^ { l - 1 }$ , $W _ { I } ^ { l - 1 } \in \mathbb { R } ^ { F _ { l - 1 } \times F _ { l } }$ , l = 1, . . . , L;
|
| 162 |
+
|
| 163 |
+
# Step 2. Row-wise Feature-based Weight Learning:
|
| 164 |
+
|
| 165 |
+
$$
|
| 166 |
+
\begin{array} { r l } & { 1 \left( H _ { L } ^ { l } \tilde { W } _ { L } ^ { l } \right) , \tilde { \alpha } _ { H } ^ { l } = \mathrm { S i g m o i d } \left( H _ { H } ^ { l } \tilde { W } _ { H } ^ { l } \right) , \tilde { \alpha } _ { I } ^ { l } = \mathrm { S i g m o i d } \left( H _ { I } ^ { l } \tilde { W } _ { I } ^ { l } \right) , \tilde { W } _ { L } ^ { l - 1 } , \tilde { W } _ { H } ^ { l - 1 } , \tilde { W } _ { I } ^ { l - 1 } \in \mathbb { R } ^ { F _ { l } \times 1 } } \\ & { = \mathrm { S o f t m a x } \left( \left( \left[ \tilde { \alpha } _ { L } ^ { l } , \tilde { \alpha } _ { H } ^ { l } , \tilde { \alpha } _ { I } ^ { l } \right] / T \right) W _ { \mathrm { M i x } } ^ { l } \right) \in \mathbb { R } ^ { N \times 3 } , T \in \mathbb { R } \mathrm { ~ t e m p e r a u r e } , W _ { \mathrm { M i x } } ^ { l } \in \mathbb { R } ^ { 3 \times 3 } ; } \end{array}
|
| 167 |
+
$$
|
| 168 |
+
|
| 169 |
+
# Step 3. Node-wise Adaptive Channel Mixing:
|
| 170 |
+
|
| 171 |
+
$$
|
| 172 |
+
H ^ { l } = \mathrm { R e L U } \left( \mathrm { d i a g } ( \alpha _ { L } ^ { l } ) H _ { L } ^ { l } + \mathrm { d i a g } ( \alpha _ { H } ^ { l } ) H _ { H } ^ { l } + \mathrm { d i a g } ( \alpha _ { I } ^ { l } ) H _ { I } ^ { l } \right)
|
| 173 |
+
$$
|
| 174 |
+
|
| 175 |
+
We will refer to the instantiation which uses option 1 in step 1 as ACM and to the one using option 2 as $\mathsf { A C M I I } \boxed { 1 0 }$ In step 1, ACM(II)-GCN implement different feature extractions for 3 channels using a set of filterbanks. Three filtered components, $H _ { L } ^ { l } , H _ { H } ^ { l } , H _ { I } ^ { l }$ , are obtained. To adaptively exploit information from each channel, ACM(II)-GCN first extract nonlinear information from the filtered signals, then use $W _ { \mathrm { M i x } } ^ { l }$ to learn which channel is important for each node, leading to the row-wise weight vectors $\alpha _ { L } ^ { l } , \widetilde { \alpha _ { H } ^ { l } } , \alpha _ { I } ^ { l } \in \mathbb { R } ^ { N \times 1 }$ whose $i$ -th elements are the weights for node $i$ L 11 These three vectors are then used as weights in defining the updated $H ^ { l }$ in step 3.
|
| 176 |
+
|
| 177 |
+
Complexity The number of learnable parameters in layer $l$ of ACM(II)-GCN is $3 F _ { l - 1 } ( F _ { l } + 1 ) + 9$ , compared to $F _ { l - 1 } F _ { l }$ in GCN. The computation of steps 1-3 takes $N F _ { l } ( 8 + 6 F _ { l - 1 } ) + 2 F _ { l } ( \mathrm { n n z } ( H _ { \mathrm { L P } } ) +$ $\mathrm { n n z } ( H _ { \mathrm { H P } } ) ) + 1 8 N$ flops, while the GCN layer takes $2 N F _ { l - 1 } F _ { l } + 2 F _ { l } ( \mathrm { n n z } ( H _ { \mathrm { L P } } ) )$ flops, where $\mathrm { n n z } ( \cdot )$ is the number of non-zero elements. An ablation study and a detailed comparison on running time are conducted in Sec. 6.1.
|
| 178 |
+
|
| 179 |
+
Limitations of Diversification Like any other method, there exists some cases of harmful heterophily that diversification operation cannot work well. For example, suppose we have an imbalanced dataset where several small clusters with distinctive labels are densely connected to a large cluster. In this case, the surrounding differences of nodes in small clusters are similar, i.e., the neighborhood differences mainly come from their connections to the same large cluster, and this can lead to the diversification operation failing to discriminate them. See Appendix $\mathrm { ~ H ~ }$ for a more detailed discussion.
|
| 180 |
+
|
| 181 |
+
# 5 Related Work
|
| 182 |
+
|
| 183 |
+
We now discuss relevant work on addressing heterophily in GNNs. [1] acknowledges the difficulty of learning on graphs with weak homophily and propose MixHop to extract features from multi-hop neighborhoods to get more information. $\mathbb { \lVert 1 7 \rVert }$ propose measurements based on feature smoothness and label smoothness that are potentially helpful to guide GNNs when dealing with heterophilic graphs. Geom-GCN $[ \beta 6 ]$ precomputes unsupervised node embeddings and uses the graph structure defined by geometric relationships in the embedding space to define the bi-level aggregation process to handle heterophily. $\mathrm { H _ { 2 } G C N }$ [46] combines 3 key designs to address heterophily: (1) ego- and neighbor-embedding separation; (2) higher-order neighborhoods; (3) combination of intermediate representations. CPGNN $\lVert \rVert \dot { \boldsymbol { \mathrm { \Omega } } }$ models label correlations through a compatibility matrix, which is beneficial for heterophilic graphs, and propagates a prior belief estimation into the GNN by using the compatibility matrix. Non-local GNNs $\pmb { \Vert 2 8 \Vert }$ propose a simple and effective non-local aggregation framework with an efficient attention-guided sorting for GNNs. FAGCN [4] learns edge-level aggregation weights as GAT $\mathbb { H }$ but allows the weights to be negative, which enables the network to capture high-frequency components in the graph signals. GPRGNN [8] uses learnable weights that can be both positive and negative for feature propagation. This allows GPRGNN to adapt to heterophilic graphs and to handle both high- and low-frequency parts of the graph signals (See Appendix J for a more comprehensive comparison between ACM-GNNs, ACMII-GNNs and FAGCN,
|
| 184 |
+
|
| 185 |
+
GPRGNN). BernNet [16] designs a scheme to learn arbitrary graph spectral filters with Bernstein polynomial to address heterophily. $\pmb { \Vert 3 3 \Vert }$ points out that homophily is not necessary for GNNs and characterizes conditions that GNNs can perform well on heterophilic graphs.
|
| 186 |
+
|
| 187 |
+
# 6 Empirical Evaluation
|
| 188 |
+
|
| 189 |
+
In this section, we evaluate the proposed ACM and ACMII framework on real-world datasets (see Appendix $\boxed { \mathbf { D . 2 } }$ for a performance comparison with basline models on synthetic datasets). We first conduct ablation studies in Sec. 6.1 to validate the effectiveness and efficiency of different components of ACM and ACMII. Then, we compare with state-of-the-art (SOTA) models in Sec. 6.2. The hyperparameter searching range and computing resources are described in Appendix C.
|
| 190 |
+
|
| 191 |
+

|
| 192 |
+
Figure 5: t-SNE visualization of the output layer of ACM-GCN and GCN trained on Squirrel
|
| 193 |
+
|
| 194 |
+
# 6.1 Ablation Study & Efficiency
|
| 195 |
+
|
| 196 |
+
We will now investigate the effectiveness and efficiency of adding HP, identity channels and the adaptive mixing mechanism in the proposed framework by performing an ablation study. Specifically, we apply the components of ACM to SGC-1 [42] $\boxed { 1 2 }$ and the components of ACM and ACMII to GCN $\mathbb { \lVert 1 9 \rVert }$ separately. We run 10 times on each of the 9 benchmark datatsets, Cornell, Wisconsin, Texas, Film, Chameleon, Squirrel, Cora, Citeseer and Pubmed used in $[ \beta 7 , \left| 3 6 \right| ]$ , with the same $6 0 \% / 2 0 \% / 2 0 \%$ random splits for train/validation/test used in $\pmb { \Vert 8 \Vert }$ and report the average test accuracy as well as the standard deviation. We also record the average running time per epoch (in milliseconds) to compare the computational efficiency. We set the temperature $T$ in equation $^ { 4 . 2 }$ to be 3, which is the number of channels.
|
| 197 |
+
|
| 198 |
+
The results in Table 1 show that on most datasets, the additional HP and identity channels are helpful, even for strong homophily datasets such as Cora, CiteSeer and PubMed. The adaptive mixing mechanism also has an advantage over directly adding the three channels together. This illustrates the necessity of learning to customize the channel usage adaptively for different nodes. The t-SNE visualization in Figure $\bar { 5 }$ demonstrates that the high-pass channel(e) and identity channel(f) can extract meaningful patterns, which the low-pass channel(d) is not able to capture. The output of ACM
|
| 199 |
+
|
| 200 |
+
<table><tr><td>Ablation Study on Different Components in ACM-SGC and ACM-GCN (%)</td><td></td><td colspan="10"></td><td></td></tr><tr><td>Baseline</td><td colspan="3">ModelComponents</td><td>Cornell</td><td>Wisconsin</td><td>Texas</td><td>Film</td><td>Chameleon</td><td>Squirrel</td><td>Cora</td><td>CiteSeer</td><td>PubMed</td><td>Rank</td></tr><tr><td>Models</td><td colspan="3">LP HP Identity Mixing|</td><td>Acc ± Std</td><td>Acc ± Std</td><td>Acc ± Std</td><td>Acc ± Std</td><td>Acc ± Std</td><td>Acc ± Std</td><td>Acc ± Std</td><td>Acc ± Std</td><td>Acc ± Std</td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td><td>70.98±8.39 70.38±2.85 83.28±5.43 25.26±1.18 64.86±1.8147.62±1.2785.12±1.64 79.66±0.7585.5±0.76</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>12.89</td></tr><tr><td>ACM-SGC-1 w/</td><td>√</td><td></td><td>√ √</td><td></td><td>83.28±5.8191.88±1.6190.98±2.46 36.76±1.0165.27±1.947.27±1.3786.8±1.0880.98±1.68 87.21±0.42</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>10.44</td></tr><tr><td></td><td>√ √</td><td>√</td><td></td><td>93.93±3.695.25±1.84 93.93±2.54 38.38±1.13 63.83±2.0746.79±0.7586.73±1.2880.57±0.9987.8±0.58</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>9.44</td></tr><tr><td></td><td>√ √ √</td><td>√</td><td></td><td></td><td>88.2 ±4.3993.5±2.95 92.95±2.94 37.19±0.87 62.82±1.84 4.94±0.93 85.22±1.35 80.75±1.68 88.11±0.21</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>11.00</td></tr><tr><td></td><td></td><td>√</td><td>√</td><td></td><td>93.77±1.9193.25±2.9293.61±1.5539.33±1.2563.68±1.6246.4±1.1386.63±1.1380.96±0.9387.75±0.88</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>10.00</td></tr><tr><td>ACM-GCN w/</td><td>√</td><td></td><td></td><td>82.46±3.11 75.5±2.9283.11±3.2 35.51±0.99 64.18±2.62 44.76±1.39 87.78±0.96 81.39±1.2388.9±0.32</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>11.44</td></tr><tr><td></td><td>√ √</td><td></td><td>√</td><td></td><td>82.13 ±2.59 86.62±4.6189.19 ±3.04 38.06±1.3569.21±1.6857.2±1.018.93±1.5581.96±0.9190.01±0.8</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>7.22</td></tr><tr><td></td><td>√ √</td><td>√</td><td>√</td><td></td><td>94.26±2.2396.13±2.294.1±2.9541.51±0.99 67.44±2.14 53.97±1.3988.95±0.981.72±1.22 90.88±0.55</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>4.44</td></tr><tr><td></td><td>√</td><td>√</td><td></td><td></td><td>91.64±295.37±3.3195.25±2.3740.47±1.49 68.93±2.04 54.78±1.2789.13±1.7781.96±2.0391.01±0.7</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>3.11</td></tr><tr><td></td><td>√ √</td><td>√</td><td>√</td><td></td><td>94.75±2.6296.75±1.695.08±3.241.62±1.15 69.04±1.7458.02±1.8688.95±1.381.80±1.2690.69±0.53</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>2.78</td></tr><tr><td>ACMII-GCN w/</td><td>√ √</td><td></td><td>√</td><td>82.46±3.03 91.00±1.7590.33±2.69 38.39±0.75 67.59±2.1453.67±1.7189.13±1.1481.75±0.85 89.87±0.39</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>7.44</td></tr><tr><td></td><td>√</td><td>√</td><td>√</td><td>94.26±2.57 96.00±2.15 94.26 ±2.96 40.96±1.2 66.35±1.76 50.78±2.0789.06±1.0781.86±1.22 90.71±0.67</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>4.67</td></tr><tr><td></td><td>√ √</td><td>√</td><td></td><td>91.48±1.43 96.25±2.09 93.77±2.9140.27±1.076.52±2.65 52.9±1.6488.83±1.1681.54±0.9590.6±0.47</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>6.67</td></tr><tr><td></td><td>√ √</td><td>√</td><td>√</td><td></td><td>95.9±1.8396.62±2.4495.25±3.1541.84±1.1568.38±1.36 54.53±2.0989.00±0.7281.79±0.9590.74±0.5</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>2.78</td></tr><tr><td colspan="14">Comparison of Average Running Time Per Epoch(ms)</td></tr><tr><td></td><td></td><td></td><td></td><td>2.53</td><td>2.83</td><td></td><td></td><td></td><td></td><td>3.47</td><td>3.43</td><td></td></tr><tr><td></td><td>√ √ √</td><td></td><td>√</td><td>4.01</td><td>4.57</td><td>2.5 4.24</td><td>3.18 4.55</td><td>3.48 4.76</td><td>4.65 5.09</td><td>5.39</td><td>4.69</td><td>4.04 4.75</td><td></td></tr><tr><td>ACM-SGC-1 w/</td><td>√</td><td>√</td><td>√</td><td>3.88</td><td>4.01</td><td>4.04</td><td>4.43</td><td>4.06</td><td>4.5</td><td>4.38</td><td>3.82</td><td>4.16</td><td></td></tr><tr><td></td><td>√ √</td><td>√</td><td></td><td>3.31</td><td>3.49</td><td>3.18</td><td>3.7</td><td>3.53</td><td>4.83</td><td>3.92</td><td>3.87</td><td>4.24</td><td></td></tr><tr><td></td><td>√ √</td><td>√</td><td>√</td><td>5.53</td><td>5.96</td><td>5.43</td><td>5.21</td><td>5.41</td><td>6.96</td><td>6</td><td>5.9</td><td>6.04</td><td></td></tr><tr><td></td><td></td><td></td><td></td><td>3.67</td><td>3.74</td><td>3.59</td><td></td><td></td><td></td><td></td><td>4.18</td><td>5.08</td><td></td></tr><tr><td></td><td>√ √ √</td><td></td><td>√</td><td>6.63</td><td>8.06</td><td>7.89</td><td>4.86 8.11</td><td>4.96 7.8</td><td>6.41 9.39</td><td>4.24 7.82</td><td>7.38</td><td>8.74 6.8</td><td></td></tr><tr><td>ACM-GCN w/</td><td>√</td><td>√</td><td>√</td><td>5.73</td><td>5.91</td><td>5.93</td><td>6.86</td><td>6.35</td><td>7.15</td><td>7.34</td><td>6.65</td><td>6.16</td><td></td></tr><tr><td></td><td>√ √</td><td>√</td><td></td><td>5.16</td><td>5.25</td><td>5.2</td><td>5.93</td><td>5.64</td><td>8.02</td><td>5.73</td><td>5.65</td><td></td><td></td></tr><tr><td></td><td>√ √</td><td>√</td><td>√</td><td>8.25</td><td>8.11</td><td>7.89</td><td>7.97</td><td>8.41</td><td>11.9</td><td>8.84</td><td>8.38</td><td></td><td></td></tr><tr><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></td><td></td></tr><tr><td></td><td>√ √</td><td></td><td>√</td><td>6.62</td><td>7.35</td><td>7.39</td><td>7.62</td><td>7.33</td><td>9.69</td><td>7.49</td><td>7.58</td><td></td><td></td></tr><tr><td>ACMII-GCNw/</td><td>√</td><td>√</td><td>√</td><td>6.3</td><td>6.05</td><td>6.26</td><td>6.87</td><td>6.44</td><td>6.5</td><td>6.14</td><td>7.21</td><td>7.97 6.6 6.33</td><td></td></tr><tr><td></td><td>√ √ √ √</td><td>√ √</td><td>√</td><td>5.24 7.59</td><td>5.27 8.28</td><td>5.46 8.06</td><td>5.72 8.85</td><td>5.65 8</td><td>7.87 10</td><td>5.48 8.27</td><td>5.65 8.5</td><td>8.68</td><td></td></tr><tr><td></td></table>
|
| 201 |
+
|
| 202 |
+
Table 1: Ablation study on 9 real-world datasets $\pmb { \mathbb { B } } 6 \|$ . Cell with Xmeans the component is applied to the baseline model. The best test results are highlighted.
|
| 203 |
+
|
| 204 |
+
GCN(c) shows clearer boundaries among classes than GCN(b). The running time is approximately doubled in the ACM and ACMII framework compared to the original models.
|
| 205 |
+
|
| 206 |
+
# 6.2 Comparison with Baseline and SOTA Models
|
| 207 |
+
|
| 208 |
+
Datasets & Experimental Setup In this section, we evaluate SGC $[ \mathbb { A } 2 ]$ with 1 hop and 2 hops (SGC-1, SGC-2), GCNII [7], GCNII⇤ [7], GCN $\mathbb { \ m }$ and snowball networks $\pmb { \| } \pmb { \bigtriangledown } $ with 2 and 3 layers (snowball-2, snowball-3) and combine them with the ACM or ACMII framework13. We use $\hat { A } _ { \mathrm { r w } } ^ { \dagger }$ as the LP filter and the corresponding HP filter is $I - { \hat { A } } _ { \mathrm { r w } } \big \lbrack { \boldsymbol { 1 4 } } \big \rbrack$ Both filters are deterministic. We compare these approaches with several baselines and SOTA GNN models: MLP with 2 layers (MLP-2), GAT [41], APPNP $\mathbb { \left[ \left[ 2 0 \right] \right] }$ , GPRGNN $\pmb { \mathbb { B } } ] \mathbf l$ , $\mathrm { H _ { 2 } G C N }$ [46], MixHop $\mathbb { M }$ , $\mathrm { G C N + J K }$ [19, 43, 26], $\mathrm { G A T + J K }$ [41, 43, 26], FAGCN [4], GraphSAGE $\mathbb { \left[ \left[ \bar { 1 } \bar { 5 } \right] \right] }$ , Geom-GCN $\left[ \left[ 3 6 \right] \right]$ and BernNet [16]. In addition to the 9 benchmark datasets used in section $6 . 1 ,$ we further test the above models on a new benchmark dataset, Deezer-Europe [38]15.
|
| 209 |
+
|
| 210 |
+
On each dataset used in $\textcircled { 1 3 7 } , \textcircled { 3 6 } \textcircled { 1 }$ , we test the models 10 times following the same early stopping strategy, the same $6 0 \% / 2 0 \% / 2 0 \%$ random data split $^ { 1 6 }$ and Adam $\boxed { 1 8 }$ optimizer as used in GPRGNN $\pmb { \mathbb { B } } \|$ . For Deezer-Europe, we test the above models 5 times with the same early stopping strategy, the same fixed splits and Adam used in $\pmb { \mathbb { D } } \pmb { \ 6 } \|$ .
|
| 211 |
+
|
| 212 |
+
Structure information channel and residual connection Besides the filtered features, some recent SOTA models additionally use graph structure information, i.e., $\mathrm { M L P } _ { \theta } ( A )$ , and residual connection to address heterophily problem, e.g., LINKX $\pmb { \Vert 2 5 \Vert }$ and GloGNN $\pmb { \mathbb { Z } } 4 \mathbb { I }$ . $\operatorname { M L P } _ { \theta } ( A )$ and residual connection can be directly incorporated into ACM and ACMII framework, which leads us to ACM(II)- ${ \mathrm { . G C N } } +$ and ACM(II)- $\mathrm { G C N + + }$ . See the details of implementation in Appendix B.
|
| 213 |
+
|
| 214 |
+

|
| 215 |
+
Figure 6: Comparison of baseline GNNs (red), ACM-GNNs (green), ACMII-GNNs (blue) with SOTA (magenta line) models on 6 selected datasets. The black lines indicate the standard deviation. The symbol “"” shows the range of performance improvement $( \% )$ of ACM-GNNs and ACMII-GNNs over baseline GNNs. See Appendix I for a detailed discussion of the relation between $H _ { \mathrm { a g g } } ^ { M }$ and GNN performance.
|
| 216 |
+
|
| 217 |
+
To visualize the performance, in Fig. $\bigtriangledown$ we plot the bar charts of the test accuracy of SOTA models, three selected baselines (GCN, snowball-2, snowball-3), their ACM(II) augmented models, ACM(II)- $\mathrm { G C N + }$ and ACM(II)- $\mathrm { G C N + + }$ on the 6 most commonly used benchmark heterophily datasets (See Table 2 in Appendix $\mathbf { A . l }$ for the full results, comparison and ranking). From Fig. $6 ,$ we can see that (1) after being combined with the ACM or ACMII framework, the performance of the three baseline models is significantly boosted, by $2 . 0 4 \% \sim 2 7 . 5 0 \%$ on all the 6 tasks. The ACM and ACMII in fact achieve SOTA performance. (2) On Cornell, Wisconsin, Texas, Chameleon and Squirrel, the augmented baseline models significantly outperform the current SOTA models. Overall, these results suggest that the proposed approach can help GNNs to generalize better on node classification tasks on heterophilic graphs, without adding too much computational cost.
|
| 218 |
+
|
| 219 |
+
# 7 Conclusions and Limitations
|
| 220 |
+
|
| 221 |
+
We have presented an analysis of existing homophily metrics and proposed new metrics which are more informative in terms of correlating with GNN performance. To our knowledge, this is the first work analyzing heterophily from the perspective of post-aggregation node similarity. The similarity matrix and the new metrics we defined mainly capture linear feature-independent relationships of each node. This might be insufficient when nonlinearity and feature-dependent information is important for classification. In the future, it would be useful to investigate if a similarity matrix could be defined which is capable of capturing nonlinear and feature-dependent relations between aggregated node.
|
| 222 |
+
|
| 223 |
+
We have also proposed a multi-channel mixing mechanism which leverages the intuitions gained in the first part of the paper and can be combined with different GNN architectures, enabling adaptive filtering (high-pass, low-pass or identity) at different nodes. Empirically, this approach shows very promising results, improving the performance of the base GNNs with which it is combined and achieving SOTA results at the cost of a reasonable increase in computation time. As discussed in Sec. $\boxed { 4 . 2 } ,$ however, the filterbank method cannot properly handle all cases of harmful heterophily, and alternative ideas should be explored as well in the future.
|
| 224 |
+
|
| 225 |
+
# 8 Acknowledge
|
| 226 |
+
|
| 227 |
+
The authors would like to give very special thanks to William L. Hamilton for valuable discussion and advice. The project was partially supported by DeepMind and NSERC.
|
| 228 |
+
|
| 229 |
+
# References
|
| 230 |
+
|
| 231 |
+
[1] S. Abu-El- Haija, Kapoor, Alipourfard, Lerman, G. Ver Steeg, and A. Galstyan. Mixhop: Higher-order graph convolutional architectures via sparsified neighborhood mixing. In international conference on machine learning, pages 21–29. PMLR, 2019. [2] D. Bahdanau, K. Cho, and Y. Bengio. Neural machine translation by jointly learning to align and translate. arXiv preprint arXiv:1409.0473, 2014. [3] P. W. Battaglia, J. B. Hamrick, V. Bapst, A. Sanchez-Gonzalez, V. Zambaldi, M. Malinowski, A. Tacchetti, D. Raposo, A. Santoro, R. Faulkner, et al. Relational inductive biases, deep learning, and graph networks. arXiv preprint arXiv:1806.01261, 2018. [4] D. Bo, X. Wang, C. Shi, and H. Shen. Beyond low-frequency information in graph convolutional networks. arXiv preprint arXiv:2101.00797, 2021. [5] C. Bodnar, F. Di Giovanni, B. P. Chamberlain, P. Liò, and M. M. Bronstein. Neural sheaf diffusion: A topological perspective on heterophily and oversmoothing in gnns. arXiv preprint arXiv:2202.04579, 2022. [6] M. M. Bronstein, J. Bruna, Y. LeCun, A. Szlam, and P. Vandergheynst. Geometric deep learning: going beyond euclidean data. arXiv, abs/1611.08097, 2016. [7] M. Chen, Z. Wei, Z. Huang, B. Ding, and Y. Li. Simple and deep graph convolutional networks. In International Conference on Machine Learning, pages 1725–1735. PMLR, 2020. [8] E. Chien, J. Peng, P. Li, and O. Milenkovic. Adaptive universal generalized pagerank graph neural network. In International Conference on Learning Representations. https://openreview. net/forum, 2021. [9] F. R. Chung and F. C. Graham. Spectral graph theory. Number 92. American Mathematical Soc., 1997.
|
| 232 |
+
[10] M. Defferrard, X. Bresson, and P. Vandergheynst. Convolutional neural networks on graphs with fast localized spectral filtering. arXiv, abs/1606.09375, 2016.
|
| 233 |
+
[11] V. N. Ekambaram. Graph structured data viewed through a fourier lens. University of California, Berkeley, 2014.
|
| 234 |
+
[12] M. Fey and J. E. Lenssen. Fast graph representation learning with pytorch geometric. arXiv preprint arXiv:1903.02428, 2019.
|
| 235 |
+
[13] A. Graves, A.-r. Mohamed, and G. Hinton. Speech recognition with deep recurrent neural networks. In 2013 IEEE international conference on acoustics, speech and signal processing, pages 6645–6649. Ieee, 2013.
|
| 236 |
+
[14] W. L. Hamilton. Graph representation learning. Synthesis Lectures on Artifical Intelligence and Machine Learning, 14(3):1–159, 2020.
|
| 237 |
+
[15] W. L. Hamilton, R. Ying, and J. Leskovec. Inductive representation learning on large graphs. arXiv, abs/1706.02216, 2017.
|
| 238 |
+
[16] M. He, Z. Wei, H. Xu, et al. Bernnet: Learning arbitrary graph spectral filters via bernstein approximation. Advances in Neural Information Processing Systems, 34, 2021.
|
| 239 |
+
[17] Y. Hou, J. Zhang, J. Cheng, K. Ma, R. T. Ma, H. Chen, and M.-C. Yang. Measuring and improving the use of graph information in graph neural networks. In International Conference on Learning Representations, 2019.
|
| 240 |
+
[18] D. P. Kingma and J. Ba. Adam: A method for stochastic optimization. arXiv preprint arXiv:1412.6980, 2014.
|
| 241 |
+
[19] T. N. Kipf and M. Welling. Semi-supervised classification with graph convolutional networks. arXiv, abs/1609.02907, 2016.
|
| 242 |
+
[20] J. Klicpera, A. Bojchevski, and S. Günnemann. Predict then propagate: Graph neural networks meet personalized pagerank. arXiv preprint arXiv:1810.05997, 2018.
|
| 243 |
+
[21] A. Krizhevsky, I. Sutskever, and G. E. Hinton. Imagenet classification with deep convolutional neural networks. In Advances in neural information processing systems, pages 1097–1105, 2012.
|
| 244 |
+
[22] Y. LeCun, Y. Bengio, and G. Hinton. Deep learning. nature, 521(7553):436, 2015.
|
| 245 |
+
[23] Y. LeCun, L. Bottou, Y. Bengio, P. Haffner, et al. Gradient-based learning applied to document recognition. Proceedings of the IEEE, 86(11):2278–2324, 1998.
|
| 246 |
+
[24] X. Li, R. Zhu, Y. Cheng, C. Shan, S. Luo, D. Li, and W. Qian. Finding global homophily in graph neural networks when meeting heterophily. arXiv preprint arXiv:2205.07308, 2022.
|
| 247 |
+
[25] D. Lim, F. Hohne, X. Li, S. L. Huang, V. Gupta, O. Bhalerao, and S. N. Lim. Large scale learning on non-homophilous graphs: New benchmarks and strong simple methods. Advances in Neural Information Processing Systems, 34:20887–20902, 2021.
|
| 248 |
+
[26] D. Lim, X. Li, F. Hohne, and S.-N. Lim. New benchmarks for learning on non-homophilous graphs. arXiv preprint arXiv:2104.01404, 2021.
|
| 249 |
+
[27] V. Lingam, R. Ragesh, A. Iyer, and S. Sellamanickam. Simple truncated svd based model for node classification on heterophilic graphs. arXiv preprint arXiv:2106.12807, 2021.
|
| 250 |
+
[28] M. Liu, Z. Wang, and S. Ji. Non-local graph neural networks. arXiv preprint arXiv:2005.14612, 2020.
|
| 251 |
+
[29] M. Liu, Z. Wang, and S. Ji. Non-local graph neural networks. IEEE Transactions on Pattern Analysis and Machine Intelligence, 2021.
|
| 252 |
+
[30] S. Luan, M. Zhao, X.-W. Chang, and D. Precup. Break the ceiling: Stronger multi-scale deep graph convolutional networks. arXiv preprint arXiv:1906.02174, 2019.
|
| 253 |
+
[31] S. Luan, M. Zhao, X.-W. Chang, and D. Precup. Training matters: Unlocking potentials of deeper graph convolutional neural networks. arXiv preprint arXiv:2008.08838, 2020.
|
| 254 |
+
[32] S. Luan, M. Zhao, C. Hua, X.-W. Chang, and D. Precup. Complete the missing half: Augmenting aggregation filtering with diversification for graph convolutional networks. arXiv preprint arXiv:2008.08844, 2020.
|
| 255 |
+
[33] Y. Ma, X. Liu, N. Shah, and J. Tang. Is homophily a necessity for graph neural networks? arXiv preprint arXiv:2106.06134, 2021.
|
| 256 |
+
[34] T. Maehara. Revisiting graph neural networks: All we have is low-pass filters. arXiv preprint arXiv:1905.09550, 2019.
|
| 257 |
+
[35] M. McPherson, L. Smith-Lovin, and J. M. Cook. Birds of a feather: Homophily in social networks. Annual review of sociology, 27(1):415–444, 2001.
|
| 258 |
+
[36] H. Pei, B. Wei, K. C.-C. Chang, Y. Lei, and B. Yang. Geom-gcn: Geometric graph convolutional networks. arXiv preprint arXiv:2002.05287, 2020.
|
| 259 |
+
[37] B. Rozemberczki, C. Allen, and R. Sarkar. Multi-Scale Attributed Node Embedding. Journal of Complex Networks, 9(2), 2021.
|
| 260 |
+
[38] B. Rozemberczki and R. Sarkar. Characteristic Functions on Graphs: Birds of a Feather, from Statistical Descriptors to Parametric Models. In Proceedings of the 29th ACM International Conference on Information and Knowledge Management (CIKM ’20), page 1325–1334. ACM, 2020.
|
| 261 |
+
[39] F. Scarselli, M. Gori, A. C. Tsoi, M. Hagenbuchner, and G. Monfardini. The graph neural network model. IEEE transactions on neural networks, 20(1):61–80, 2008.
|
| 262 |
+
[40] P. Vary. An adaptive filter-bank equalizer for speech enhancement. Signal Processing, 86(6):1206–1214, 2006.
|
| 263 |
+
[41] P. Velickovic, G. Cucurull, A. Casanova, A. Romero, P. Lio, and Y. Bengio. Graph attention networks. arXiv, abs/1710.10903, 2017.
|
| 264 |
+
[42] F. Wu, T. Zhang, A. H. d. Souza Jr, C. Fifty, T. Yu, and K. Q. Weinberger. Simplifying graph convolutional networks. arXiv preprint arXiv:1902.07153, 2019.
|
| 265 |
+
[43] K. Xu, C. Li, Y. Tian, T. Sonobe, K.-i. Kawarabayashi, and S. Jegelka. Representation learning on graphs with jumping knowledge networks. In J. Dy and A. Krause, editors, Proceedings of the 35th International Conference on Machine Learning, volume 80 of Proceedings of Machine Learning Research, pages 5453–5462. PMLR, 10–15 Jul 2018.
|
| 266 |
+
[44] Y. Yan, M. Hashemi, K. Swersky, Y. Yang, and D. Koutra. Two sides of the same coin: Heterophily and oversmoothing in graph convolutional neural networks. arXiv preprint arXiv:2102.06462, 2021.
|
| 267 |
+
[45] J. Zhu, R. A. Rossi, A. Rao, T. Mai, N. Lipka, N. K. Ahmed, and D. Koutra. Graph neural networks with heterophily. arXiv preprint arXiv:2009.13566, 2020.
|
| 268 |
+
[46] J. Zhu, Y. Yan, L. Zhao, M. Heimann, L. Akoglu, and D. Koutra. Beyond homophily in graph neural networks: Current limitations and effective designs. Advances in Neural Information Processing Systems, 33, 2020.
|
| 269 |
+
|
| 270 |
+
# Checklist
|
| 271 |
+
|
| 272 |
+
1. For all authors...
|
| 273 |
+
|
| 274 |
+
(a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes]
|
| 275 |
+
(b) Did you describe the limitations of your work? [Yes]
|
| 276 |
+
(c) Did you discuss any potential negative societal impacts of your work? [N/A]
|
| 277 |
+
(d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
|
| 278 |
+
|
| 279 |
+
2. If you are including theoretical results...
|
| 280 |
+
|
| 281 |
+
(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]
|
| 282 |
+
|
| 283 |
+
3. If you ran experiments...
|
| 284 |
+
|
| 285 |
+
(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]
|
| 286 |
+
(b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes]
|
| 287 |
+
(c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [Yes]
|
| 288 |
+
(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]
|
| 289 |
+
|
| 290 |
+
4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
|
| 291 |
+
|
| 292 |
+
(a) If your work uses existing assets, did you cite the creators? [Yes]
|
| 293 |
+
(b) Did you mention the license of the assets? [N/A]
|
| 294 |
+
(c) Did you include any new assets either in the supplemental material or as a URL? [No]
|
| 295 |
+
(d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [No]
|
| 296 |
+
(e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [No]
|
| 297 |
+
|
| 298 |
+
5. If you used crowdsourcing or conducted research with human subjects...
|
| 299 |
+
|
| 300 |
+
(a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A]
|
| 301 |
+
(b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A]
|
| 302 |
+
(c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]
|
md/dev/PUIqjT4rzq7/PUIqjT4rzq7.md
ADDED
|
@@ -0,0 +1,410 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# TRAINING-FREE STRUCTURED DIFFUSION GUIDANCE FOR COMPOSITIONAL TEXT-TO-IMAGE SYNTHESIS
|
| 2 |
+
|
| 3 |
+
Weixi Feng1, Xuehai $\mathbf { H e } ^ { 2 }$ , Tsu-jui $\mathbf { F u } ^ { 1 }$ , Varun Jampani3, Arjun Akula3, Pradyumna Narayana3, Sugato Basu3, Xin Eric Wang2, William Yang Wang1 1University of California, Santa Barbara, 2University of California, Santa Cruz, 3Google
|
| 4 |
+
|
| 5 |
+
# ABSTRACT
|
| 6 |
+
|
| 7 |
+
Large-scale diffusion models have achieved state-of-the-art results on text-to-image synthesis (T2I) tasks. Despite their ability to generate high-quality yet creative images, we observe that attribution-binding and compositional capabilities are still considered major challenging issues, especially when involving multiple objects. Attribute-binding requires the model to associate objects with the correct attribute descriptions, and compositional skills require the model to combine and generate multiple concepts into a single image. In this work, we improve these two aspects of T2I models to achieve more accurate image compositions. To do this, we incorporate linguistic structures with the diffusion guidance process based on the controllable properties of manipulating cross-attention layers in diffusion-based T2I models. We observe that keys and values in cross-attention layers have strong semantic meanings associated with object layouts and content. Therefore, by manipulating the cross-attention representations based on linguistic insights, we can better preserve the compositional semantics in the generated image. Built upon Stable Diffusion, a SOTA T2I model, our structured cross-attention design is efficient that requires no additional training samples. We achieve better compositional skills in qualitative and quantitative results, leading to a significant $5- 8 \%$ advantage in head-to-head user comparison studies. Lastly, we conduct an in-depth analysis to reveal potential causes of incorrect image compositions and justify the properties of cross-attention layers in the generation process.
|
| 8 |
+
|
| 9 |
+
# 1 INTRODUCTION
|
| 10 |
+
|
| 11 |
+
Text-to-Image Synthesis (T2I) is to generate natural and faithful images given a text prompt as input. Recently, there has been a significant advancement in the quality of generated images by extremely large-scale vision-language models, such as DALL-E 2 (Ramesh et al., 2022), Imagen (Saharia et al., 2022), and Parti (Yu et al., 2022). In particular, Stable Diffusion (Rombach et al., 2022) is the state-of-the-art open-source implementation showing superior evaluation metric gains after training over billions of text-image pairs.
|
| 12 |
+
|
| 13 |
+
In addition to generating high-fidelity images, the ability to compose multiple objects into a coherent scene is also essential. Given a text prompt from the user end, T2I models need to generate an image that contains all necessary visual concepts as mentioned in the text. Achieving such ability requires the model to understand both the full prompt and individual linguistic concepts from the prompt. As a result, the model should be able to combine multiple concepts and generate novel objects that have never been included in the training data. In this work, we mainly focus on improving the compositionality of the generation process, as it is essential to achieve controllable and generalized text-to-image synthesis with multiple objects in a complex scene.
|
| 14 |
+
|
| 15 |
+
Attribute binding is a critical compositionality challenge (Ramesh et al., 2022; Saharia et al., 2022) to existing large-scale diffusion-based models. Despite the improvements in generating multiple objects in the same scene, existing models still fail when given a prompt such as “a brown bench in front of a white building” (see Fig. 1). The output images contains “a white bench” and “a brown building” instead, potentially due to strong training set bias or imprecise language understanding. From a practical perspective, explaining and solving such a two-object binding challenge is a primary step to understanding more complex prompts with multiple objects. Therefore, how to bind the attributes to the correct objects is a fundamental problem for a more complicated and reliable compositional generation. While previous work has addressed compositional T2I (Park et al., 2021), our work tackles open-domain foreground objects with counterfactual attributes, such as color and materials.
|
| 16 |
+
|
| 17 |
+

|
| 18 |
+
Figure 1: Three challenging phenomena in the compositional generation. Attribute leakage: The attribute of one object is (partially) observable in another object. Interchanged attributes: the attributes of two or more objects are interchanged. Missing objects: one or more objects are missing. With slight abuse of attribute binding definitions, we aim to address all three problems in this work.
|
| 19 |
+
|
| 20 |
+
Even though state-of-the-art (SOTA) T2I models are trained on large-scale text-image datasets, they can still suffer from inaccurate results for simple prompts similar to the example above. Hence, we are motivated to seek an alternative, data-efficient method to improve the compositionality. We observe that the attribute-object relation pairs can be obtained as text spans for free from the parsing tree of the sentence. Therefore, we propose to combine the structured representations of prompts, such as a constituency tree or a scene graph, with the diffusion guidance process. Text spans only depict limited regions of the whole image. Conventionally, we need spatial information such as coordinates (Yang et al., 2022) as input to map their semantics into corresponding images. However, coordinate inputs cannot be interpreted by T2I models. Instead, we make use of the observations that attention maps provide free token-region associations in trained T2I models (Hertz et al., 2022). By modifying the key-value pairs in cross-attention layers, we manage to map the encoding of each text span into attended regions in 2D image space.
|
| 21 |
+
|
| 22 |
+
In this work, we discover similar observations in Stable Diffusion (Rombach et al., 2022) and utilize the property to build structured cross-attention guidance. Specifically, we use language parsers to obtain hierarchical structures from the prompts. We extract text spans across all levels, including visual concepts or entities, and encode them separately to disentangle the attribute-object pairs from each other. Compared to using a single sequence of text embedding for guidance, we improve the compositionality by multiple sequences where each emphasizes an entity or a union of entities from multiple hierarchies in the structured language representations. We refer to our method as Structured Diffusion Guidance (StructureDiffusion). Our contributions can be summarized as three-fold:
|
| 23 |
+
|
| 24 |
+
• We propose an intuitive and effective method to improve compositional text-to-image synthesis by utilizing structured representations of language inputs. Our method is efficient and training-free that requires no additional training samples.
|
| 25 |
+
• Experimental results show that our method achieves more accurate attribute binding and compositionality in the generated images. We also propose a benchmark named Attribute Binding Contrast set (ABC-6K) to measure the compositional skills of T2I models.
|
| 26 |
+
• We conduct extensive experiments and analysis to identify the causes of incorrect attribute binding, which points out future directions in improving the faithfulness and compositionality of text-to-image synthesis.
|
| 27 |
+
|
| 28 |
+

|
| 29 |
+
Figure 2: An illustration of cross-attention operations and the token-region associations from attention maps. We omit some tokens for simplicity.
|
| 30 |
+
|
| 31 |
+
# 2 DIFFUSION MODELS & STRUCTURED GUIDANCE
|
| 32 |
+
|
| 33 |
+
In this section, we propose a simple yet effective approach incorporating structured language representations into the cross-attention layers. We briefly introduce the Stable Diffusion model and its critical components in Sec. 2.1. Then, we present our method in detail in Sec. 2.2.
|
| 34 |
+
|
| 35 |
+
# 2.1 BACKGROUND
|
| 36 |
+
|
| 37 |
+
Stable Diffusion We implement our approach and experiments on the state-of-the-art T2I model, Stable Diffusion (Rombach et al., 2022). It is a two-stage method that consists of an autoencoder and a diffusion model. The pre-trained autoencoder encodes images as lower-resolution latent maps for diffusion training. During inference, it decodes generated outputs from the diffusion model into images. The diffusion model generates lower-resolution latent maps based on a random Gaussian noise input $z ^ { T }$ . Given $z ^ { T }$ , it outputs a noise estimation $\epsilon$ at each step $t$ and subtracts it from $z ^ { t }$ . The final noise-free latent map prediction $z ^ { 0 }$ is fed into the autoencoder to generate images. Stable Diffusion adopts a modified UNet (Ronneberger et al., 2015) for noise estimation and a frozen CLIP text encoder (Radford et al., 2021) to encode text inputs as embedding sequences. The interactions between the image space and the textual embeddings are achieved through multiple cross-attention layers in both downsampling and upsampling blocks.
|
| 38 |
+
|
| 39 |
+
CLIP Text Encoder Given an input prompt $\mathcal { P }$ , the CLIP encoder encodes it as a sequence of embeddings ${ \mathcal { W } } _ { \mathrm { p } } = \mathbf { C } \mathbf { L I P } _ { \mathrm { t e x t } } ( \mathcal { P } )$ where $c _ { \mathrm { p } }$ is the embedding dimension and $l$ is the sequence length. Our key observation is that the contextualization of CLIP embeddings is a potential cause of incorrect attribute binding. Due to the causal attention masks, tokens in the later part of a sequence are blended with the token semantics before them. For example, When the user indicates some rare color for the second object (e.g. “a yellow apple and red bananas”), Stable Diffusion tends to generate “banana” in “yellow”, as the embeddings of “yellow” is attended by token “banana”.
|
| 40 |
+
|
| 41 |
+
Cross Attention Layers The cross-attention layers take the embedding sequences from the CLIP text encoder and fuse them with latent feature maps to achieve classifier-free guidance. Denote a 2D feature map $\mathcal { X } ^ { t }$ , it is projected into queries by a linear layer $f _ { Q } ( \cdot )$ and reshaped as $Q ^ { t } \in R ^ { ( n , h \times w , d ) }$ where $n$ denotes the number of attention heads, $d$ is the feature dimension. Similarly ${ \mathcal W } _ { \mathfrak p }$ is projected as keys and values $K _ { \mathfrak { p } } , V _ { \mathfrak { p } } \in R ^ { ( n , l , d ) }$ by linear layers $f _ { K } ( \cdot ) , f _ { V } ( \cdot )$ . The attention maps refer to the product between queries and keys, denoted as a function $f _ { M } ( \cdot )$
|
| 42 |
+
|
| 43 |
+
$$
|
| 44 |
+
M ^ { t } = f _ { M } ( Q ^ { t } , K _ { p } ) = \mathrm { S o f t m a x } ( \frac { Q ^ { t } K _ { \mathrm { p } } ^ { T } } { \sqrt { d } } ) , M ^ { t } \in R ^ { ( n , h \times w , l ) } .
|
| 45 |
+
$$
|
| 46 |
+
|
| 47 |
+

|
| 48 |
+
Figure 3: An illustration of our cross-attention design with structured representations. We unflatten the query and attention maps and omit the feature dimension $d$ of all query, key, and value tensors for demonstration purposes. Note that noun phrases at multiple hierarchies are extracted and encoded through the frozen CLIP text encoder and projected to value vectors.
|
| 49 |
+
|
| 50 |
+
Cross Attention Controls Hertz et al. (2022) observes that the spatial layouts depend on the cross attention maps in Imagen Saharia et al. (2022). These maps control the layout and structure of generated images, while the values contain rich semantics mapped into attended regions. Therefore, we assume that the image layout and content can be disentangled by controlling attention maps and values separately.
|
| 51 |
+
|
| 52 |
+
# 2.2 STRUCTURED DIFFUSION GUIDANCE
|
| 53 |
+
|
| 54 |
+
Given the challenging prompts in Fig. 1, the attribute-object pairs are available for free1 in many structured representations, such as a constituency tree or a scene graph. We seek an implicit way of combining language structures with the cross-attention layers. As is shown in Fig. 3, we can extract multiple noun phrases (NPs) and map their semantics into corresponding regions. Since $M _ { t }$ provides natural token-region associations (see Fig. 2), we can apply it to multiple values from different NPs to achieve region-wise semantic guidance.
|
| 55 |
+
|
| 56 |
+
Specifically, given a parser $\xi ( \cdot )$ , we first extract a collection of concepts from all hierarchical levels as $\mathcal { C } = \{ c _ { 1 } , c _ { 2 } , \ldots , c _ { k } \}$ . For constituency parsing, we extract all NPs from the tree structure (see Fig.3 left). For the scene graphs, we extract objects and their relations with another object as text segments. We encode each NP separately:
|
| 57 |
+
|
| 58 |
+
$$
|
| 59 |
+
\mathbb { W } = [ \mathcal { W } _ { \mathrm { p } } , \mathcal { W } _ { 1 } , \mathcal { W } _ { 2 } , \ldots , \mathcal { W } _ { k } ] , \mathcal { W } _ { i } = \mathbf { C } \mathbf { L } \mathbf { I } \mathbf { P } _ { \mathrm { t e x t } } ( c _ { i } ) , i = 1 , \ldots k .
|
| 60 |
+
$$
|
| 61 |
+
|
| 62 |
+
The embedding sequence $\mathcal { W } _ { i }$ is realigned with $\mathcal { W } _ { p }$ as shown in the middle of Fig. 3. Embeddings between $\left. \mathbf { b o s } \right.$ and $\langle \mathrm { p a d } \rangle$ are inserted into $\mathcal { W } _ { p }$ to create a new sequence, denoted as $\overline { { \mathcal { W } } } _ { i }$ . We use $\overline { { \mathcal { W } } } _ { \mathrm { p } }$ to obtain $K _ { \mathfrak { p } }$ and $M ^ { t }$ as in Eq. 1, assuming that the full-prompt key is able to generate layouts without missing objects. We obtain a set of values from $\mathbb { W }$ and multiply each with ${ \bf { \bar { \boldsymbol { M } } } } ^ { t }$ to achieve a conjunction of $k$ NPs in $\mathcal { C }$ :
|
| 63 |
+
|
| 64 |
+
$$
|
| 65 |
+
\begin{array} { c } { \mathbb { V } = [ f _ { V } ( \mathcal { W } _ { \mathrm { p } } ) , f _ { V } ( \overline { { \mathcal { W } } } _ { 1 } ) , \ldots , f _ { V } ( \overline { { \mathcal { W } } } _ { k } ) ] = [ V _ { \mathrm { p } } , V _ { 1 } , \ldots , V _ { k } ] . } \\ { O ^ { t } = \displaystyle \frac { 1 } { ( k + 1 ) } \sum _ { i } ( M ^ { t } V _ { i } ) , i = \mathrm { p } , 1 , 2 , \ldots , k . } \end{array}
|
| 66 |
+
$$
|
| 67 |
+
|
| 68 |
+
Compared to using $f _ { V } ( \mathscr { W } _ { p } )$ only, Eq. 4 does not modify the image layout or composition since $M ^ { t }$ is still calculated from $Q ^ { t } , K _ { p }$ . Empirically, we justify the claim by a series of visualizations of $M _ { t }$
|
| 69 |
+
|
| 70 |
+
# Algorithm 1 StructureDiffusion Guidance.
|
| 71 |
+
|
| 72 |
+
# Require:
|
| 73 |
+
|
| 74 |
+
Input: Prompt $\mathcal { P }$ , Parser $\xi$ , decoder $\psi$ , trained diffusion model $\phi$ .
|
| 75 |
+
Output: Generated image $x$ .
|
| 76 |
+
1: Retrieve concept set ${ \mathcal { C } } = [ c _ { 1 } , \ldots , c _ { k } ]$ by traversing $\xi ( \mathcal { P } )$ ;
|
| 77 |
+
2: $\mathcal { W } _ { \mathrm { p } } \mathrm { C L I P } _ { \mathrm { t e x t } } ( \mathcal { P } ) .$ , ${ \mathcal { W } } _ { i } \gets \mathbf { C } \mathbf { L I P _ { \mathrm { t e x t } } } ( c _ { i } )$ ; $i = 1 , \ldots , k$
|
| 78 |
+
3: for $t = T , T - 1 , \dots , 1$ do
|
| 79 |
+
4: for each cross attention layer in $\phi$ do
|
| 80 |
+
5: Obtain previous layer’s output $\mathcal { X } ^ { t }$ .
|
| 81 |
+
6: $Q ^ { t } \gets \hat { f } _ { Q } ( \mathcal { X } ^ { t } ) , \ \dot { K _ { \mathrm { p } } } \gets \boldsymbol { f } _ { K } \mathsf { \bar { ( } } \mathcal { W _ { \mathrm { p } } ) } , \ V _ { i } \gets f _ { V } ( \overline { { \mathcal { W } } } _ { i } ) ;$ $\begin{array} { r } { i = { \tt p } , 1 , \ldots , k } \\ { \{ { \tt E q . ~ } 1 \} } \\ { \{ { \tt E q . ~ } 4 \} } \end{array}$
|
| 82 |
+
7: Obtain attention maps $M ^ { t }$ from $Q ^ { t } , K _ { \mathrm { p } }$ ;
|
| 83 |
+
8: Obtain $O ^ { t }$ from $M ^ { t }$ , $\{ V _ { i } \}$ , and feed to following layers;
|
| 84 |
+
9: end for
|
| 85 |
+
10: end for
|
| 86 |
+
11: Feed $z ^ { 0 }$ to decoder $\psi ( \cdot )$ to generate $\mathbf { X }$ .
|
| 87 |
+
|
| 88 |
+
(see Appendix C). However, Stable Diffusion tends to omit objects in generated images (Fig. 1), especially for concept conjunctions that connect two objects with the word “and”. We devise a variant of our method that computes a set of attention maps $\ddot { \mathbb { M } } = \{ M _ { p } ^ { t } , M _ { 1 } ^ { t } , \dots \}$ from $\mathcal { C }$ and multiply them to $\mathbb { V }$ :
|
| 89 |
+
|
| 90 |
+
$$
|
| 91 |
+
\begin{array} { c } { { \mathbb { K } = \{ f _ { K } ( \mathcal { W } _ { i } ) \} , \mathbb { M } ^ { t } = \{ f _ { M } ( Q ^ { t } , K _ { i } ) \} , i = \mathrm { p } , 1 , 2 , \ldots , k . } } \\ { { O ^ { t } = \displaystyle \frac { 1 } { ( k + 1 ) } \sum _ { i } ( M _ { i } ^ { t } V _ { k } ) , i = \mathrm { p } , 1 , 2 , \ldots , k . } } \end{array}
|
| 92 |
+
$$
|
| 93 |
+
|
| 94 |
+
$O ^ { t }$ is the output of a certain cross-attention layer and the input into downstream layers to generate final image $x$ . Our algorithm can be summarized as 1, which requires no training or additional data.
|
| 95 |
+
|
| 96 |
+
# 3 EXPERIMENT
|
| 97 |
+
|
| 98 |
+
# 3.1 EXPERIMENT SETTINGS
|
| 99 |
+
|
| 100 |
+
Datasets To address attribute binding and compositional generation, we propose a new benchmark, Attribute Binding Contrast set (ABC-6K). It consists of natural prompts from MSCOCO where each contains at least two color words modifying different objects. We also switch the position of two color words to create a contrast caption (Gardner et al., 2020). We end up with $6 . 4 \mathrm { K }$ captions or 3.2K contrastive pairs. In addition to natural compositional prompts, we challenge our method with less detailed prompts that conjunct two concepts together. These prompts follow the sentence pattern of “a red apple and a yellow banana” and conjunct two objects with their attribute descriptions. We refer to this set of prompts as Concept Conjunction 500 (CC-500). We also evaluate our method on 10K randomly sampled captions from MSCOCO (Lin et al., 2014). We show that our method generalizes beyond attribute binding and introduces no quality degradation for general prompts.
|
| 101 |
+
|
| 102 |
+
Evaluation Metrics We mainly rely on human evaluations for compositional prompts and concept conjunction (ABC-6K & CC-500). We ask annotators to compare two generated images, from Stable Diffusion and our method respectively, and indicate which image demonstrates better image-text alignment or image fidelity. For image fidelity, we ask the annotators “Regardless of the text, which image is more realistic and natural?”. We also investigate an automatic evaluation metric for image compositions, i.e., using a SOTA phrase grounding model GLIP (Li et al., 2022) to match phraseobject pairs. As for system-level evaluation, we follow previous work to utilize Inception Score (IS) (Salimans et al., 2016), Frechet Inception Distance (FID) (Heusel et al., 2017) and CLIP R-precision ´ (R-prec.) (Park et al., 2021). IS and FID mainly measure the image bank’s systematic quality and diversity, while R-prec measures image-level alignment.
|
| 103 |
+
|
| 104 |
+
# 3.2 COMPOSITIONAL PROMPTS
|
| 105 |
+
|
| 106 |
+
Here we show the quantitative and qualitative evaluation results on ABC-6K. We observe that our method sometimes generates very similar images to Stable Diffusion. Hence, we first generate two images per prompt for our method and Stable Diffusion, involving around 12K image pairs to compare. Then, we filter out $20 \%$ of the most similar pairs and then randomly sampled 1500 pairs for human evaluations. As shown in Table 1, annotators indicate around a $42 \%$ chance of our method winning the comparison, $7 \%$ higher than losing the comparison. There is still a $22 \%$ of chance that our images are tied with images from Stable Diffusion.
|
| 107 |
+
|
| 108 |
+
Table 1: Percentage of generated images of StructureDiffusion that are better than (win), tied with, or worse than (lose) the compared model in terms of text-image alignment and image fidelity. We filtered out $20 \%$ most similar image pairs for comparison (See Sec. E). Composable Diffusion cannot be applied to ABC-6K as those prompts may not contain explicit “and” words that separate concepts.
|
| 109 |
+
|
| 110 |
+
<table><tr><td rowspan="2">Benchmark</td><td rowspan="2">StructureDiffusion (ours) v.s.</td><td colspan="3">Alignment</td><td colspan="3">Fidelity</td></tr><tr><td>Win (↑)</td><td>Lose (↓)</td><td>Tie</td><td>Win (↑)</td><td>Lose (↓)</td><td>Tie</td></tr><tr><td>ABC-6K</td><td>Stable Diffusion</td><td>42.2</td><td>35.6</td><td>22.2</td><td>48.3</td><td>39.1</td><td>12.6</td></tr><tr><td rowspan="2">CC-500</td><td>Stable Diffusion</td><td>31.8</td><td>27.7</td><td>38.9</td><td>37.8</td><td>30.6</td><td>31.6</td></tr><tr><td>Composable Diffusion</td><td>46.5</td><td>30.1</td><td>22.8</td><td>61.4</td><td>19.8</td><td>18.8</td></tr></table>
|
| 111 |
+
|
| 112 |
+

|
| 113 |
+
Figure 4: Qualitative results on ABC-6K. Our method improves both object-level and scene-level compositionality.
|
| 114 |
+
|
| 115 |
+
We show qualitative examples characterizing three different perspectives in Fig. 4. Our method fills in the correct color for different parts of an object or different objects, as shown in the first two examples. The third example demonstrates that our method can mitigate the issue of “missing objects”. Among the $42 \%$ winning cases, there are $31 \%$ for “fewer missing objects”, $1 4 . 1 \%$ for “better-matched colors”, and $5 4 . 8 \%$ for “other attributes or details” as indicated by annotators. The results certify that the improvement goes beyond colors to component completeness and fine-grained details. More qualitative examples characterizing all three aspects can be found in Fig. 14 in the Appendix.
|
| 116 |
+
|
| 117 |
+
# 3.3 CONCEPT CONJUNCTION
|
| 118 |
+
|
| 119 |
+
Here we address challenging concept conjunction prompts and evaluate our method on CC-500. Apart from Stable Diffusion, we also compare to Composable Diffusion (Liu et al., 2022) implemented on top of Stable Diffusion. For Composable Diffusion, we separate the prompts into text segments by the keyword “and” and feed each span into an independent diffusion process. We generate three images per prompt and use all images for human evaluation for Stable Diffusion. We randomly sampled 600 images for comparison to Composable Diffusion.
|
| 120 |
+
|
| 121 |
+
<table><tr><td rowspan="2"></td><td colspan="6">CC-500 (Prompt format: “a [colorA] [objectA] and a [colorB] [objectB]")</td></tr><tr><td></td><td>Human Annotations</td><td></td><td>GLIP</td><td></td><td>Human-GLIP</td></tr><tr><td>Methods</td><td>Zero/One obj. ()</td><td>Two obj.</td><td>Two obj. w/ correct colors</td><td>Zero/One obj.(↓)</td><td>Two obj.</td><td>Consistency</td></tr><tr><td>Stable Diffusion</td><td>65.5</td><td>34.5</td><td>19.2</td><td>69.0</td><td>31.0</td><td>46.4</td></tr><tr><td>Composable Diffusion</td><td>69.7</td><td>30.3</td><td>20.6</td><td>74.2</td><td>25.8</td><td>48.9</td></tr><tr><td>StructureDiffusion (Ours)</td><td>62.0</td><td>38.0</td><td>22.7</td><td>68.8</td><td>31.2</td><td>47.6</td></tr></table>
|
| 122 |
+
|
| 123 |
+
Table 2: Fine-grained human and automatic evaluation results on CC-500. Recall that each prompt is a conjunction of two different objects with different colors. “Zero/One obj.” means that the model fails to generate all desired objects in the image. “Human-GLIP consistency” reflects the percentage of images where human annotations align with GLIP detection results.
|
| 124 |
+
|
| 125 |
+

|
| 126 |
+
Figure 5: Qualitative results on CC-500 prompts that emphasize two aspects. (a) Color leakage: our method prevents the green color from invading the bird or apple. (b) Missing objects: our method completes the “blue bowl” and improves the quality of the “blue apple”.
|
| 127 |
+
|
| 128 |
+
As shown in Table 1, our method outperforms Stable Diffusion by around $4 . 1 \%$ and Composable Diffusion by $1 6 . 4 \%$ in terms of image-text alignment. We also observe that our method enhances some fine-grained details in the generated images, leading to a $7 . 2 \%$ improvement in image fidelity when compared with Stable Diffusion. We observe that images from composable diffusion can be oversaturated with unnatural visual textures and layouts, which could be the reason for StructureDiffusion to have high win rate in image fidelity. As shown in Fig. 5 and Fig. 13. Our approach prevents color bleeding (left), missing objects (right) and strengthens details (right).
|
| 129 |
+
|
| 130 |
+
To further quantify the text-image alignment, we consider both human annotations and automatic evaluations. For each object mentioned in the prompt, we ask annotators whether the object exists in the image and whether it is in the correct color. We also apply a state-of-the-art detection model GLIP (Li et al., 2022) to ground each “a [color] [object]” phrase into bounding boxes. We report the percentage of images that contain incomplete objects / complete objects / complete objects with correct colors in Table 2. StructureDiffusion improves the compositionality by $3 . 5 \%$ based on human annotations while only $0 . 2 \%$ based on GLIP. We discover that humans disagree with GLIP for more than $50 \%$ of the images, as entailed by the low consistency rate. Previous work also suggests the deficiency of large pre-trained models in compositional understanding (Thrush et al., 2022).
|
| 131 |
+
|
| 132 |
+
# 3.4 OTHER PROMPTS
|
| 133 |
+
|
| 134 |
+
We show that our StructureDiffusion maintain the overall image quality and diversity on general prompts. We follow the standard evaluation process and generate 10,000 images from randomly
|
| 135 |
+
|
| 136 |
+

|
| 137 |
+
Figure 6: Qualitative results of using scene graph parser to generate structured representations.
|
| 138 |
+
|
| 139 |
+

|
| 140 |
+
Figure 7: Ablation study on the text sequence embeddings. We find that the padding embeddings are fully contextualized, representing the prompt’s high-level semantics. However, not all padding tokens are necessary to maintain a high-fidelity output from Stable Diffusion.
|
| 141 |
+
|
| 142 |
+
sampled MSCOCO captions. Stable Diffusion obtains 39.9 IS, 18.0 FID and 72.2 R-Precision. Our method achieves 40.9 IS, 17.9 FID and $7 2 . 3 \mathrm { R }$ -Precision. StructureDiffusion maintains the image fidelity and diversity as indicated in the comparable IS/FID/R-Prec scores.
|
| 143 |
+
|
| 144 |
+
# 3.5 SCENE GRAPH INPUT
|
| 145 |
+
|
| 146 |
+
We show that our method is not limited to constituency parsing but can also be extended to other structured representations, such as scene graphs. As shown in Fig. 6, we first adopt the scene graph parser (Wu et al., 2019) and obtain a graph like the ones next to each image from the input prompt. The parser returns basic entities and their relations in between. We extract text spans of basic entities with their attributes attached and text spans that include two related entities. We provide examples in Appendix 3 and make comparison to the constituency parser. Similarly, we encode these spans separately and re-align each with the entire prompt encoding sequence. On MS-COCO, the scene graph parser setting maintains the image quality with 39.2 IS, 17.9 FID, and 72.0 R-Precision. When compared to Stable Diffusion on ABC-6K, the scene graph parser achieves $3 4 . 2 \% - 3 2 . 9 \% - 3 2 . 9 \%$ Win-Lose-Tie in image-text alignment and $3 4 . 5 \% - 3 2 . 5 \% - 3 3 . 0 \%$ Win-Lose-Tie in image fidelity. As for CC-500, the scene graph parser leads to the same output images due to the same text spans. We refer to Table 3 and Fig. 12 for more results and comparison.
|
| 147 |
+
|
| 148 |
+
# 4 ABLATION STUDY
|
| 149 |
+
|
| 150 |
+
# 4.1 RE-ALIGNING SEQUENCE
|
| 151 |
+
|
| 152 |
+
In Section 2, we describe a method to realign the encoding of a text span back into the sequence of the full prompt. Since the noun-phrase text spans are shorter than the full sequence, re-alignment ensures that each token’s value vector corresponds to the correct attention map. On the other hand, naively expanding the span to the length of the full sequence degrades the image quality by ${ \sim } 2 \mathrm { I S } /$ FID (37.5 IS, 19.8 FID) compared to images with re-alignment or Stable Diffusion.
|
| 153 |
+
|
| 154 |
+
# 4.2 CONTEXTUALIZED TEXT EMBEDDINGS
|
| 155 |
+
|
| 156 |
+
One limitation brought by our StructureDiffusion is that the cross-attention computation costs increase by the number of noun phrases. Yet we noticed that most of the attention maps are computed from padding embeddings, as Stable Diffusion adopts CLIP text encoders and automatically pads the sequence to 77 tokens. We conjecture that not all padding tokens are necessary for generating high-quality images. As is shown in Fig. 7, we study four different patterns of token embeddings. We discover that leaving the nearest padding embeddings maintains a similar IS / FID score as the full sequence. Further removing this padding embedding results in apparent degradation. While only using the nearest padding embedding results in the worst image quality, we find that the high-level image layout and semantics are preserved (see bottom right of Fig. 7). This phenomenon indicates that the padding embeddings are fully contextualized with the full prompt semantics. This also justifies our re-alignment operation that preserves padding embeddings of the main sequence ${ \mathcal { W } } _ { \mathrm { f u l l } }$ .
|
| 157 |
+
|
| 158 |
+
# 5 RELATED WORK
|
| 159 |
+
|
| 160 |
+
Text-to-Image Synthesis The diffusion model is an emerging type of model that generate highquality images with a much more stable training process (Song & Ermon, 2019; Ho et al., 2020). Rombach et al. (2022) proposes to encode an image with an autoencoder and then leverage a diffusion model to generate continuous feature maps in the latent space. Stable Diffusion Rombach et al. (2022) adopts similar architecture but is trained on large-scale image-text datasets with fixed CLIP text encoder. Imagen (Saharia et al., 2022) addresses the importance of language understanding by using a frozen T5 encoder (Raffel et al., 2020), a dedicated large language model. We mainly focus on diffusion models and conduct our experiments on Stable Diffusion (Rombach et al., 2022), the SOTA open-sourced T2I model.
|
| 161 |
+
|
| 162 |
+
Compositional Generation The compositional or controllable generation has been an essential direction for T2I models to understand and disentangle basic concepts in the generation process. As text inputs are relatively weak conditions, previous work leverage layout or scene graph to enhance compositionality (Johnson et al., 2018; Hong et al., 2018; Yang et al., 2022; Gafni et al., 2022). More recently, Liu et al. (2022) proposes an approach where the concept conjunctions are achieved by adding estimated scores from a parallel set of diffusion processes. In contrast, our method can be directly merged into the cross-attention layers with much less computational overhead.
|
| 163 |
+
|
| 164 |
+
Diffusion Guidance Ho & Salimans (2022) develops classifier-free guidance where a single diffusion model is jointly trained under conditional and unconditional inputs. Most large-scale SOTA models, including autoregressive ones, adopt this technique for flexible and improved conditional synthesis results (Rombach et al., 2022; Ramesh et al., 2022; Gafni et al., 2022; Yu et al., 2022; Saharia et al., 2022). Hertz et al. (2022) discovers unique properties of cross attention maps on Imagen (Saharia et al., 2022) and achieves structure-preserving image editing by manipulating these maps. We observe similar properties in Stable Diffusion (Rombach et al., 2022) but propose a different algorithm for fine-grained, compositional text-to-image generation.
|
| 165 |
+
|
| 166 |
+
# 6 CONCLUSION
|
| 167 |
+
|
| 168 |
+
In this work, we propose a training-free method for compositional text-to-image generation. First, we observe that existing large-scale T2I diffusion models can still struggle in compositional image synthesis. We address this challenge by explicitly focusing on binding objects with the correct attributes. Second, we propose structured diffusion guidance incorporating language structures into the cross-attention layers. We propose two simple techniques to align the structured encoding with the attention maps. Using our structured guidance on Stable Diffusion, attributes can be bound more accurately while maintaining the overall image quality and diversity. In addition, we justify our approach by conducting an in-depth analysis of the frozen language encoder and attention maps. Future work may explore explicit approaches to generate plausible image layouts without missing components. We hope that our approach accelerates the development of interpretable and efficient methods for diffusion-based text-to-image models.
|
| 169 |
+
|
| 170 |
+
# ACKNOWLEDGEMENT
|
| 171 |
+
|
| 172 |
+
We would like to thank the Robert N. Noyce Trust for their generous gift to the University of California via the Noyce Initiative. The work was also partially funded by an unrestricted gift from Google and by the National Science Foundation award #2048122. The writers’ opinions and conclusions in this publication are their own and should not be construed as representing the sponsors’ official policy, expressed or inferred.
|
| 173 |
+
|
| 174 |
+
# REPRODUCIBILITY STATEMENT
|
| 175 |
+
|
| 176 |
+
We release our core codebase containing the methodology implementation, settings, benchmarks containing compositional prompts under supplementary materials.
|
| 177 |
+
|
| 178 |
+
# ETHICAL STATEMENT
|
| 179 |
+
|
| 180 |
+
As for the data collection and verification, we use the Amazon Mechanical Turk platform and form the comparison task as batches of HITs. We select workers from English-speaking countries, including the US, CA, UK, AU, and NZ, since the task require understanding the English input prompt. Each HIT takes around 15-30 seconds on average to accomplish, and we pay each submitted HIT with 0.15 US dollars, resulting in an hourly payment of 18 US dollars.
|
| 181 |
+
|
| 182 |
+
# REFERENCES
|
| 183 |
+
|
| 184 |
+
Prafulla Dhariwal and Alexander Nichol. Diffusion models beat gans on image synthesis. Advances in Neural Information Processing Systems, 34:8780–8794, 2021.
|
| 185 |
+
|
| 186 |
+
Ming Ding, Wendi Zheng, Wenyi Hong, and Jie Tang. Cogview2: Faster and better text-to-image generation via hierarchical transformers. arXiv preprint arXiv:2204.14217, 2022.
|
| 187 |
+
|
| 188 |
+
Alaaeldin El-Nouby, Shikhar Sharma, Hannes Schulz, Devon Hjelm, Layla El Asri, Samira Ebrahimi Kahou, Yoshua Bengio, and Graham W.Taylor. Tell, Draw, and Repeat: Generating and Modifying Images Based on Continual Linguistic Instruction. In ICCV, 2019.
|
| 189 |
+
|
| 190 |
+
Tsu-Jui Fu, Xin Eric Wang, Scott Grafton, Miguel Eckstein, and William Yang Wang. SSCR: Iterative Language-Based Image Editing via Self-Supervised Counterfactual Reasoning. In EMNLP, 2020.
|
| 191 |
+
|
| 192 |
+
Oran Gafni, Adam Polyak, Oron Ashual, Shelly Sheynin, Devi Parikh, and Yaniv Taigman. Make-ascene: Scene-based text-to-image generation with human priors. arXiv preprint arXiv:2203.13131, 2022.
|
| 193 |
+
|
| 194 |
+
Matt Gardner, Yoav Artzi, Victoria Basmov, Jonathan Berant, Ben Bogin, Sihao Chen, Pradeep Dasigi, Dheeru Dua, Yanai Elazar, Ananth Gottumukkala, et al. Evaluating models’ local decision boundaries via contrast sets. Findings of Empirical Methods in Natural Language Processing, 2020.
|
| 195 |
+
|
| 196 |
+
Shuyang Gu, Dong Chen, Jianmin Bao, Fang Wen, Bo Zhang, Dongdong Chen, Lu Yuan, and Baining Guo. Vector quantized diffusion model for text-to-image synthesis. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 10696–10706, 2022a.
|
| 197 |
+
|
| 198 |
+
Shuyang Gu, Dong Chen, Jianmin Bao, Fang Wen, Bo Zhang, Dongdong Chen, Lu Yuan, and Baining Guo. Vector quantized diffusion model for text-to-image synthesis. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 10696–10706, 2022b.
|
| 199 |
+
|
| 200 |
+
Amir Hertz, Ron Mokady, Jay Tenenbaum, Kfir Aberman, Yael Pritch, and Daniel Cohen-Or. Promptto-prompt image editing with cross attention control. arXiv preprint arXiv:2208.01626, 2022.
|
| 201 |
+
|
| 202 |
+
Martin Heusel, Hubert Ramsauer, Thomas Unterthiner, Bernhard Nessler, and Sepp Hochreiter. Gans trained by a two time-scale update rule converge to a local nash equilibrium. Advances in neural information processing systems, 30, 2017.
|
| 203 |
+
|
| 204 |
+
Jonathan Ho and Tim Salimans. Classifier-free diffusion guidance. arXiv preprint arXiv:2207.12598, 2022.
|
| 205 |
+
|
| 206 |
+
Jonathan Ho, Ajay Jain, and Pieter Abbeel. Denoising diffusion probabilistic models. Advances in Neural Information Processing Systems, 33:6840–6851, 2020.
|
| 207 |
+
|
| 208 |
+
Seunghoon Hong, Dingdong Yang, Jongwook Choi, and Honglak Lee. Inferring semantic layout for hierarchical text-to-image synthesis. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 7986–7994, 2018.
|
| 209 |
+
|
| 210 |
+
Justin Johnson, Agrim Gupta, and Li Fei-Fei. Image generation from scene graphs. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 1219–1228, 2018.
|
| 211 |
+
|
| 212 |
+
Doyup Lee, Chiheon Kim, Saehoon Kim, Minsu Cho, and Wook-Shin Han. Autoregressive image generation using residual quantization. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 11523–11532, 2022.
|
| 213 |
+
|
| 214 |
+
Bowen Li, Xiaojuan Qi, Thomas Lukasiewicz, and Philip Torr. Controllable text-to-image generation. Advances in Neural Information Processing Systems, 32, 2019.
|
| 215 |
+
|
| 216 |
+
Liunian Harold Li, Pengchuan Zhang, Haotian Zhang, Jianwei Yang, Chunyuan Li, Yiwu Zhong, Lijuan Wang, Lu Yuan, Lei Zhang, Jenq-Neng Hwang, et al. Grounded language-image pre-training. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 10965–10975, 2022.
|
| 217 |
+
|
| 218 |
+
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.
|
| 219 |
+
|
| 220 |
+
Luping Liu, Yi Ren, Zhijie Lin, and Zhou Zhao. Pseudo numerical methods for diffusion models on manifolds. In International Conference on Learning Representations, 2021a.
|
| 221 |
+
|
| 222 |
+
Nan Liu, Shuang Li, Yilun Du, Antonio Torralba, and Joshua B Tenenbaum. Compositional visual generation with composable diffusion models. arXiv preprint arXiv:2206.01714, 2022.
|
| 223 |
+
|
| 224 |
+
Xihui Liu, Dong Huk Park, Samaneh Azadi, Gong Zhang, Arman Chopikyan, Yuxiao Hu, Humphrey Shi, Anna Rohrbach, and Trevor Darrell. More control for free! image synthesis with semantic diffusion guidance. arXiv preprint arXiv:2112.05744, 2021b.
|
| 225 |
+
|
| 226 |
+
Chao Lou, Wenjuan Han, Yuhuan Lin, and Zilong Zheng. Unsupervised vision-language parsing: Seamlessly bridging visual scene graphs with language structures via dependency relationships. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), pp. 15607–15616, June 2022.
|
| 227 |
+
|
| 228 |
+
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. ICML, 2021.
|
| 229 |
+
|
| 230 |
+
Dong Huk Park, Samaneh Azadi, Xihui Liu, Trevor Darrell, and Anna Rohrbach. Benchmark for compositional text-to-image synthesis. In Thirty-fifth Conference on Neural Information Processing Systems Datasets and Benchmarks Track (Round 1), 2021.
|
| 231 |
+
|
| 232 |
+
Peng Qi, Yuhao Zhang, Yuhui Zhang, Jason Bolton, and Christopher D. Manning. Stanza: A Python natural language processing toolkit for many human languages. In Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics: System Demonstrations, 2020.
|
| 233 |
+
|
| 234 |
+
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, pp. 8748–8763. PMLR, 2021.
|
| 235 |
+
|
| 236 |
+
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, 21(140):1–67, 2020. URL http://jmlr.org/papers/v21/20-074.html.
|
| 237 |
+
|
| 238 |
+
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, pp. 8821–8831. PMLR, 2021.
|
| 239 |
+
|
| 240 |
+
Aditya Ramesh, Prafulla Dhariwal, Alex Nichol, Casey Chu, and Mark Chen. Hierarchical textconditional image generation with clip latents. arXiv preprint arXiv:2204.06125, 2022.
|
| 241 |
+
|
| 242 |
+
Robin Rombach, Andreas Blattmann, Dominik Lorenz, Patrick Esser, and Bjorn Ommer. High- ¨ resolution image synthesis with latent diffusion models. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 10684–10695, 2022.
|
| 243 |
+
|
| 244 |
+
Olaf Ronneberger, Philipp Fischer, and Thomas Brox. U-net: Convolutional networks for biomedical image segmentation. In International Conference on Medical image computing and computerassisted intervention, pp. 234–241. Springer, 2015.
|
| 245 |
+
|
| 246 |
+
Nataniel Ruiz, Yuanzhen Li, Varun Jampani, Yael Pritch, Michael Rubinstein, and Kfir Aberman. Dreambooth: Fine tuning text-to-image diffusion models for subject-driven generation. arXiv preprint arXiv:2208.12242, 2022.
|
| 247 |
+
|
| 248 |
+
Chitwan Saharia, William Chan, Saurabh Saxena, Lala Li, Jay Whang, Emily Denton, Seyed Kamyar Seyed Ghasemipour, Burcu Karagol Ayan, S Sara Mahdavi, Rapha Gontijo Lopes, et al. Photorealistic text-to-image diffusion models with deep language understanding. arXiv preprint arXiv:2205.11487, 2022.
|
| 249 |
+
|
| 250 |
+
Tim Salimans, Ian Goodfellow, Wojciech Zaremba, Vicki Cheung, Alec Radford, and Xi Chen. Improved techniques for training gans. Advances in neural information processing systems, 29, 2016.
|
| 251 |
+
|
| 252 |
+
Sebastian Schuster, Ranjay Krishna, Angel Chang, Li Fei-Fei, and Christopher D Manning. Generating semantically precise scene graphs from textual descriptions for improved image retrieval. In Proceedings of the fourth workshop on vision and language, pp. 70–80, 2015.
|
| 253 |
+
|
| 254 |
+
Yang Song and Stefano Ermon. Generative modeling by estimating gradients of the data distribution. Advances in Neural Information Processing Systems, 32, 2019.
|
| 255 |
+
|
| 256 |
+
Ming Tao, Hao Tang, Fei Wu, Xiao-Yuan Jing, Bing-Kun Bao, and Changsheng Xu. Df-gan: A simple and effective baseline for text-to-image synthesis. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 16515–16525, 2022.
|
| 257 |
+
|
| 258 |
+
Tristan Thrush, Ryan Jiang, Max Bartolo, Amanpreet Singh, Adina Williams, Douwe Kiela, and Candace Ross. Winoground: Probing vision and language models for visio-linguistic compositionality. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 5238–5248, 2022.
|
| 259 |
+
|
| 260 |
+
Bo Wan, Wenjuan Han, Zilong Zheng, and Tinne Tuytelaars. Unsupervised vision-language grammar induction with shared structure modeling. In International Conference on Learning Representations, 2021.
|
| 261 |
+
|
| 262 |
+
Hao Wu, Jiayuan Mao, Yufeng Zhang, Yuning Jiang, Lei Li, Weiwei Sun, and Wei-Ying Ma. Unified visual-semantic embeddings: Bridging vision and language with structured meaning representations. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 6609–6618, 2019.
|
| 263 |
+
|
| 264 |
+
Zuopeng Yang, Daqing Liu, Chaoyue Wang, Jie Yang, and Dacheng Tao. Modeling image composition for complex scene generation. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 7764–7773, 2022.
|
| 265 |
+
|
| 266 |
+
Jiahui Yu, Yuanzhong Xu, Jing Yu Koh, Thang Luong, Gunjan Baid, Zirui Wang, Vijay Vasudevan, Alexander Ku, Yinfei Yang, Burcu Karagol Ayan, et al. Scaling autoregressive models for contentrich text-to-image generation. arXiv preprint arXiv:2206.10789, 2022.
|
| 267 |
+
|
| 268 |
+
Han Zhang, Jing Yu Koh, Jason Baldridge, Honglak Lee, and Yinfei Yang. Cross-modal contrastive learning for text-to-image generation. In Proceedings of the IEEE/CVF conference on computer vision and pattern recognition, pp. 833–842, 2021.
|
| 269 |
+
|
| 270 |
+
Yiwu Zhong, Liwei Wang, Jianshu Chen, Dong Yu, and Yin Li. Comprehensive image captioning via scene graph decomposition. In European Conference on Computer Vision, pp. 211–229. Springer, 2020.
|
| 271 |
+
|
| 272 |
+
Yufan Zhou, Ruiyi Zhang, Changyou Chen, Chunyuan Li, Chris Tensmeyer, Tong Yu, Jiuxiang Gu, Jinhui Xu, and Tong Sun. Towards language-free training for text-to-image generation. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 17907–17917, 2022.
|
| 273 |
+
|
| 274 |
+
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, pp. 5802–5810, 2019.
|
| 275 |
+
|
| 276 |
+
# A RELATED WORK
|
| 277 |
+
|
| 278 |
+
Text-to-Image Synthesis There are mainly three types of models for text-to-image synthesis: GAN-based (Tao et al., 2022; Zhu et al., 2019; Li et al., 2019; Fu et al., 2020; El-Nouby et al., 2019), autoregressive (Gu et al., 2022b; Lee et al., 2022; Ding et al., 2022) and diffusion models (Liu et al., 2021b; Nichol et al., 2021; Ruiz et al., 2022). Zhang et al. (2021) proposes XMC-GAN, a one-stage GAN that employs multiple contrastive losses between image-image, image-text, and region-token pairs. More recently, LAFITE (Zhou et al., 2022) enables language-free training by constructing pseudo image-text feature pairs using CLIP (Radford et al., 2021). As for autoregressive models, DALL-E adopts VQ-VAE to quantize image patches into tokens and then uses a transformer to generate discrete tokens sequentially (Ramesh et al., 2021). Parti (Yu et al., 2022) and Make-A-Scene (Gafni et al., 2022) both leverage classifier-free guidance to improve controllability. As for diffusion models, Gu et al. (2022a) concatenates VQ-VAE with the diffusion model and shows that the diffusion process can operate in discrete latent space. DALL-E 2 adopts the CLIP text encoder so that the diffusion process inverts the textual features into images (Ramesh et al., 2022).
|
| 279 |
+
|
| 280 |
+
Structured Representations for Vision and Language Inferring shared structures across language and vision has been a long-term pursuit in unifying these modalities (Schuster et al., 2015; Johnson et al., 2018; Zhong et al., 2020; Lou et al., 2022). Wu et al. (2019) utilizes the structure from semantic parsing in a visual-semantic embedding framework to facilitate embedding learning. Wan et al. (2021) proposes a new task in which the goal is to learn a joint structure between semantic parsing and image regions. To the best of our knowledge, our work is the first attempt in T2I to incorporate language structures into the image synthesizing process.
|
| 281 |
+
|
| 282 |
+
Diffusion Guidance To convert an unconditional diffusion model into a class-conditional one, Dhariwal & Nichol (2021) input the noisy image from each step into a classifier and calculate the classification loss. The loss can be back-propagated to the image space to provide a gradient that marginalizes the score estimation from the log of conditional probability. Similarly, in the T2I subdomain, Liu et al. (2021b) and Nichol et al. (2021) apply a noisy CLIP model to measure the cosine similarity between text prompts and noisy images.
|
| 283 |
+
|
| 284 |
+
# B IMPLEMENTATION DETAILS
|
| 285 |
+
|
| 286 |
+
Throughout the experiments, we implement our method upon Stable Diffusion v1.4. For all comparisons between our method and Stable Diffusion, we fix the seed to generate the same initial Gaussian map and use 50 diffusion steps with PLMS sampling (Liu et al., 2021a). We fix the guidance scale to 7.5 and equally weight the key-value matrices in cross-attention layers if not otherwise specified. We do not add hand-crafted prompts such as “a photo of” to the text input. We use the Stanza Library (Qi et al., 2020) for constituency parsing and obtain noun phrases if not otherwise specified.
|
| 287 |
+
|
| 288 |
+
# C VISUALIZATION OF ATTENTION MAPS
|
| 289 |
+
|
| 290 |
+
In this section, we demonstrate the visualization of cross-attention maps to support our assumptions and claims in Sec. 2. As is shown in Fig. 8, the attention maps of Stable Diffusion and our method have similar spatial distribution and highlights throughout the diffusion process. This phenomenon supports our assumption in Sec. 2.2 that the attention map $M _ { t }$ is unchanged even with multiple values in each cross-attention layer. We can observe a similar phenomenon in Fig. 9 except that our method accelerates the formation of interpretable attentions for both “green” and “clock” tokens.
|
| 291 |
+
|
| 292 |
+

|
| 293 |
+
Figure 8: Visualization of cross attention maps of Stable Diffusion and our method. We compare maps of multiple tokens throughout the whole diffusion process with equal intervals.
|
| 294 |
+
|
| 295 |
+
Fig. 8, 9 also justify our claim that values represent rich textual semantics mapped to the image space as contents. For instance, our method parses the prompt in Fig. 8 into “A long narrow yellow kitchen” and “black and white floor tiles”, encodes and aligns them separately to form V. Empirically, these operations enhance the semantics of “yellow” and “black and white” separately and mitigate “yellow” being blended into “black and white”. This explains the disappearance of color leakage in our image compared to Stable Diffusion. Though one may attribute the leakage to incorrect attention distribution of the “yellow” token, we argue that this is not the critical reason. Despite the attention maps of “yellow” from our method slightly highlighting the “floor tile” regions, we cannot observe any yellow in our generated image. This proves that inaccurate attention distributions contribute little to the final image content. In addition, we also show in Fig. 10 that using multiple Keys is able to rectify the image layouts to mitigate missing object issues. The sheep-like attention maps in the third row verify the proposed variants of our method for concept conjunctions.
|
| 296 |
+
|
| 297 |
+

|
| 298 |
+
Figure 9: Visualization of cross attention maps corresponding to token “green” and “clock” across the full diffusion timestamps from step 50 to step 1 in equal intervals. Red boxes highlight steps where our method accelerates the formation of correct attention on the clock region. The evolution of the token “green” is also more interpretable in our method. Although the image composition is imperfect, the visualization still supports our assumptions and claims in Sec. 2.2.
|
| 299 |
+
|
| 300 |
+

|
| 301 |
+
Figure 10: Visualization of attention maps for token “sheep” of different methods. Our method with multiple Keys successfully rectify image layouts.
|
| 302 |
+
|
| 303 |
+
# D ABLATION STUDY
|
| 304 |
+
|
| 305 |
+
# D.1 A CASE STUDY OF ATTRIBUTE BINDING
|
| 306 |
+
|
| 307 |
+
Here, we present a case study to show evidence of two root causes of incorrect attribute binding. The first one is the contextualized token embeddings due to causal attention masks. As is shown on the left side of Fig. 11, we first encode two different prompts with a shared component, e.g. “a red apple” as the naive one and “a green bag and a red apple”. Using the encoding sequence of the naive prompt, we are able to get an image of red apple only. It is reasonable to assume that the yellow green regions are natural results of learning from authentic apple images. Then, we replace the tokens of the naive prompt with embeddings of the same token from the more complicated prompt. We use the same gaussian noise as initialization and generate an unnatural image with a solid green region (in the yellow bounding box). This result proves that the token “red” is contaminated with the semantics of “green” before it and explains some images with color leakage problems (e.g., Fig. 1).
|
| 308 |
+
|
| 309 |
+

|
| 310 |
+
Figure 11: Examples showing the potential root causes of incorrect attribute binding. Left: The large green regions in the second image prove that the hidden state’s output of token “red” is contextualized with token “green” before it. Right: Visualization of attention maps showing that the semantics from the token “bird” is mistakenly attended to the mouth region of the bear. The final image shows the unnatural beak-like shape of the bear.
|
| 311 |
+
|
| 312 |
+
The second reason attributes to inaccurate attention maps. In Fig. 11 (right), we visualize five crossattention maps (averaged across attention heads) from both downsample and upsampling blocks. The attention maps show the salient regions corresponding to the token “bird”. These maps demonstrate highlighted regions in the bottom left corner where the bird is located in the final image. Despite the interpretable structures, the maps also show saliency around the mouth region of the bear across all five layers. Thus, the inaccurate attention maps lead to a beak-like mouth of the bear in the image.
|
| 313 |
+
|
| 314 |
+
# D.2 COMPARISON OF PARSERS
|
| 315 |
+
|
| 316 |
+
In this subsection, we compare the difference between using a constituency parser and a scene graph parser to obtain text spans and generate images. Table 3 compares the extracted text spans using constituency parser and scene graph parser. Example 0 shows that both parsers end up with the same results for CC-500 prompts. For Example 1-4, the scene graph parser generates more spans than the constituency parser. We notice that concepts in the middle of the sentence appear more often in these spans than other noun tokens, like “egg” or “red sauce” in Example 3. This imbalance potentially explains why the “egg” looks more highlighted in Fig. 12 (bottom left). On the other hand, “orange slices” appear more often in constituency parsing results, leading to better “orange” textures in the generated image. Similar observations can be made in Example 2, where “green pole” is emphasized more often by the constituency parser.
|
| 317 |
+
|
| 318 |
+
# E LIMITATIONS & FUTURE WORK
|
| 319 |
+
|
| 320 |
+
There are several limitations of our work. First of all, our method depends on an external parsing function that may not be perfect. We adopt the commonly used Stanza Library Qi et al. (2020) for constituency parsing. The parsing function can be replaced with a more advanced learning-based method for improvement. Secondly, our method mainly focuses on compositional T2I neglecting any style descriptions. The parsing mechanism may categorize a style description, e.g. “in Van Gogh style” as a separate noun phrase that cannot be grounded in the image space. In addition, we discover that StructureDiffusion tends to generate similar images as Stable Diffusion. Thus we filtered out $20 \%$ of most similar image pairs in Table 1, considering the efficiency of human evaluation. Therefore, the improvement could be compromised when evaluated on the full set of generated images. Future work may focus on devising explicit methods to associate attributes to objects using spatial information as input. For example, how to make a text-to-image synthesis model interpret coordinate information with limited fine-tuning or prompt tuning steps would be an appealing direction.
|
| 321 |
+
|
| 322 |
+
Table 3: Comparison between the constituency parser and scene graph parser. For CC-500 prompts, both parsers end up with the same results. As for general prompts, scene graph parser tends to generate more text spans with middle concepts appearing multiple times across different spans.
|
| 323 |
+
|
| 324 |
+
<table><tr><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>Constituency Parser</td><td rowspan=1 colspan=1>Scene Graph Parser</td></tr><tr><td rowspan=2 colspan=1>Example 0</td><td rowspan=1 colspan=2>CC-500 Prompt: A white sheep and a red car</td></tr><tr><td rowspan=1 colspan=1>“A white sheep”,“a red car”</td><td rowspan=1 colspan=1>“A white sheep”,“a red car”</td></tr><tr><td rowspan=2 colspan=1>Example 1</td><td rowspan=1 colspan=2>Prompt: A silver car with a black cat sleeping on top of it</td></tr><tr><td rowspan=1 colspan=1>“A silver car”,“a black cat”,“A silver car with a black cat”</td><td rowspan=1 colspan=1>“A silver car”,"a black cat”,“top of it”,“a black cat sleeping on top of it"</td></tr><tr><td rowspan=2 colspan=1>Example 2</td><td rowspan=1 colspan=2>Prompt:A horse running in a white field next to a black and green pole</td></tr><tr><td rowspan=1 colspan=1>“Ahorse”,“a white feld",“a black and green pole",“a white field next to a black and green pole”</td><td rowspan=1 colspan=1>“Ahorse”,“a white field”,“a black and green pole”,“A horse running in a white field"</td></tr><tr><td rowspan=2 colspan=1>Example 3</td><td rowspan=1 colspan=2>Prompt:Rice with red sauce with eggs over the top and orange slices on the side</td></tr><tr><td rowspan=1 colspan=1>“red sauce”,“the side”,“the top and orange slices”,“the top and orange slices on the side"</td><td rowspan=1 colspan=1>“red sauce”,“the side”,“the top and orange slices”,“Rice with red sauce”,“red sauce with eggs”,“the top and orange slices on the side",“red sauce with eggs over the top and orange slices”</td></tr><tr><td rowspan=2 colspan=1>Example 4</td><td rowspan=1 colspan=2>Prompt:A pink scooter with a black seat next to a blue car</td></tr><tr><td rowspan=1 colspan=1>“A pink scooter”,“a black seat”,“a blue car”</td><td rowspan=1 colspan=1>“A pink scooter”,“a black seat”,“a blue car”,"a pink scooter with a black seat",“a black seat next to a blue car”</td></tr></table>
|
| 325 |
+
|
| 326 |
+

|
| 327 |
+
Figure 12: Synthesized images corresponding to prompts in Table 3. Yellow boxes annotate compositions that are improved using different parsers.
|
| 328 |
+
|
| 329 |
+

|
| 330 |
+
Figure 13: Qualitative results on CC-500
|
| 331 |
+
|
| 332 |
+
# Stable Diffusion
|
| 333 |
+
|
| 334 |
+
# Ours
|
| 335 |
+
|
| 336 |
+
# Stable Diffusion
|
| 337 |
+
|
| 338 |
+
# Ours
|
| 339 |
+
|
| 340 |
+
# Stable Diffusion
|
| 341 |
+
|
| 342 |
+
# Ours
|
| 343 |
+
|
| 344 |
+
a purple cat with a orange hat on its head
|
| 345 |
+
|
| 346 |
+
A red cat sits on a rug with a black cord
|
| 347 |
+
|
| 348 |
+
A yellow cat is wearing a blue plastic baseball hat.
|
| 349 |
+
|
| 350 |
+

|
| 351 |
+
|
| 352 |
+

|
| 353 |
+
|
| 354 |
+

|
| 355 |
+
A red helmet is on a yellow toilet in the dirt
|
| 356 |
+
|
| 357 |
+
A red stop sign above a white walk across road sign
|
| 358 |
+
|
| 359 |
+
Two elephants walking by a green wall with tan palm trees painted on it
|
| 360 |
+
|
| 361 |
+

|
| 362 |
+
|
| 363 |
+

|
| 364 |
+
|
| 365 |
+

|
| 366 |
+
|
| 367 |
+
# A bathroom with red tile and a green shower curtain
|
| 368 |
+
|
| 369 |
+
A spacious kitchen has white walls , red countertops , and a large stove
|
| 370 |
+
|
| 371 |
+
A large white bed sitting in a hotel room next to a red couch
|
| 372 |
+
|
| 373 |
+

|
| 374 |
+
|
| 375 |
+

|
| 376 |
+
|
| 377 |
+

|
| 378 |
+
|
| 379 |
+
A pink towel stands out greatly in the white bathroom
|
| 380 |
+
|
| 381 |
+

|
| 382 |
+
A white toilet bowl with a purple rug in front
|
| 383 |
+
|
| 384 |
+
# A large pizza on a white plate sitting on a blue table
|
| 385 |
+
|
| 386 |
+

|
| 387 |
+
|
| 388 |
+

|
| 389 |
+
|
| 390 |
+
A spoon and bowl of red pea soup and green beans with onions
|
| 391 |
+
|
| 392 |
+
A cow standing outside of a white building with a blue entrance
|
| 393 |
+
|
| 394 |
+
A black and white curtain
|
| 395 |
+
hanging in a room that is
|
| 396 |
+
decorated in black, white and
|
| 397 |
+
red
|
| 398 |
+
|
| 399 |
+

|
| 400 |
+
|
| 401 |
+

|
| 402 |
+
|
| 403 |
+

|
| 404 |
+
Figure 14: Qualitative results on ABC-6K
|
| 405 |
+
|
| 406 |
+

|
| 407 |
+
Figure 15: Qualitative results characterizing attributes beyond colors, including shape, size and materials.
|
| 408 |
+
|
| 409 |
+

|
| 410 |
+
Figure 16: A prompt “an astronaut riding a horse” appended with different (combinations of) style descriptions. Our method has no negative effects on the image style. “base” refers to Stable Diffusion.
|
md/dev/QkRV50TZyP/QkRV50TZyP.md
ADDED
|
@@ -0,0 +1,412 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# BEYOND IMAGENET ATTACK: TOWARDS CRAFTINGADVERSARIAL EXAMPLES FOR BLACK-BOX DOMAINS
|
| 2 |
+
|
| 3 |
+
Qilong Zhang1∗, Xiaodan $\mathbf { L i } ^ { 2 }$ , Yuefeng Chen2, Jingkuan Song1†,
|
| 4 |
+
Lianli $\mathbf { G a o ^ { 1 } }$ , Yuan $\mathbf { H e } ^ { 2 }$ , and Hui $\mathbf { X } \mathbf { u } \mathbf { e } ^ { 2 }$
|
| 5 |
+
1University of Electronic Science and Technology of China, China
|
| 6 |
+
qilong.zhang $@$ std.uestc.edu.cn, jingkuan.song $@$ gmail.com, lianli.gao $@$ uestc.edu.cn
|
| 7 |
+
2Alibaba Group, China
|
| 8 |
+
{fiona.lxd,yuefeng.chenyf,heyuan.hy,hui.xueh}@alibaba-inc.com
|
| 9 |
+
|
| 10 |
+
# ABSTRACT
|
| 11 |
+
|
| 12 |
+
Adversarial examples have posed a severe threat to deep neural networks due to their transferable nature. Currently, various works have paid great efforts to enhance the cross-model transferability, which mostly assume the substitute model is trained in the same domain as the target model. However, in reality, the relevant information of the deployed model is unlikely to leak. Hence, it is vital to build a more practical black-box threat model to overcome this limitation and evaluate the vulnerability of deployed models. In this paper, with only the knowledge of the ImageNet domain, we propose a Beyond ImageNet Attack (BIA) to investigate the transferability towards black-box domains (unknown classification tasks). Specifically, we leverage a generative model to learn the adversarial function for disrupting low-level features of input images. Based on this framework, we further propose two variants to narrow the gap between the source and target domains from the data and model perspectives, respectively. Extensive experiments on coarse-grained and fine-grained domains demonstrate the effectiveness of our proposed methods. Notably, our methods outperform state-of-theart approaches by up to $7 . 7 1 \%$ (towards coarse-grained domains) and $2 5 . 9 1 \%$ (towards fine-grained domains) on average. Our code is available at https: //github.com/Alibaba-AAIG/Beyond-ImageNet-Attack.
|
| 13 |
+
|
| 14 |
+
# 1 INTRODUCTION
|
| 15 |
+
|
| 16 |
+
Deep neural networks (DNNs) have achieved remarkable success in the image classification task in recent years. Nonetheless, advances in the field of adversarial machine learning (Szegedy et al., 2014; Goodfellow et al., 2015; Zhang et al., 2022) make DNNs no longer reliable. By adding a well-designed perturbation on a benign image (a.k.a adversarial attack), the resulting adversarial examples can easily fool state-of-the-art DNNs. To make the matter worse, the adversarial attack technique can even be applied in the physical world (Sharif et al., 2016; Kurakin et al., 2017a; Xu et al., 2020; Duan et al., 2021), which inevitably raises concerns about the stability of deployed models. Therefore, exposing as many “blind spots” of DNNs as possible is a top priority.
|
| 17 |
+
|
| 18 |
+
Generally, deployed models are mainly challenged with two threat models: white-box and blackbox. For white-box threat model (Kurakin et al., 2017b; Moosavi-Dezfooli et al., 2016; Carlini & Wagner, 2017; Shi et al., 2019; Liu et al., 2022), the attacker can obtain complete knowledge of the target model, such as the gradient for any input. However, deployed models are usually opaque to unauthorized users. In this scenario, prior black-box works (Poursaeed et al., 2018; Dong et al., 2018; Xie et al., 2019; Inkawhich et al., 2020; Gao et al., 2020b; Wang et al., 2021) mostly assume that the source data for training the target model is available and mainly explore the cross-model transferability among models trained in the same data distribution. Specifically, perturbations are crafted via accessible white-box model (a.k.a substitute model), and resulting adversarial examples sometimes can fool other black-box models as well. Yet, these works still ignore a pivotal issue: A model owner is unlikely to leak the relevant information of the deployed model. To overcome this limitation, query-based black-box attacks (Papernot et al., 2016; Brendel et al., 2018; Chen et al., 2020; Li et al., 2021) are proposed, which adjust adversarial examples just according to the output of the target model. However, the resource-intensive query budget is extremely costly and inevitably alerts the model owner.
|
| 19 |
+
|
| 20 |
+
Table 1: A comparison of datasets from different domains.
|
| 21 |
+
|
| 22 |
+
<table><tr><td>Dataset</td><td>Resolution</td><td>Type</td><td>Test size</td><td>Classes</td></tr><tr><td>ImageNet (Russakovsky et al., 2015)</td><td>224×224</td><td>-</td><td>50,000</td><td>1,000</td></tr><tr><td>CIFAR-10 (Krizhevsky, 2009)</td><td>32×32</td><td>coarse-grained</td><td>10.000</td><td>10</td></tr><tr><td>CIFAR-100 (Krizhevsky,2009)</td><td>32×32</td><td>coarse-grained</td><td>10.000</td><td>100</td></tr><tr><td>STL-10 (Coates et al., 2011)</td><td>96×96</td><td>coarse-grained</td><td>8.000</td><td>10</td></tr><tr><td>SVHN (Netzer et al., 2011)</td><td>32×32</td><td>coarse-grained</td><td>26.032</td><td>10</td></tr><tr><td>CUB-200-2011 (Wah et al.,2011)</td><td>448×448</td><td>fine-grained</td><td>5,740</td><td>200</td></tr><tr><td>Stanford Cars (Krause etal., 2013)</td><td>448×448</td><td>fine-grained</td><td>8.041</td><td>196</td></tr><tr><td>FGVC Aircraft (Maji et al., 2013)</td><td>448×448</td><td>fine-grained</td><td>3,333</td><td>100</td></tr></table>
|
| 23 |
+
|
| 24 |
+
Therefore, we need a more “practical” black-box threat model to address this concern, i.e., without any clue about the training data distribution as well as the pre-trained model based on it, and even querying is forbidden. Intuitively, this threat model is more challenging to build for attackers and more threatening to model owners. To the best of our knowledge, a recent work called CDA (Naseer et al., 2019) is the first to attempt such an attack. Specifically, it learns a transferable adversarial function via a generator network against a different domain (training data and pre-trained model are all from ChestX-ray (Wang et al., 2017) domain). During inference, it directly crafts adversarial examples for benign ImageNet images to fool target ImageNet pre-trained models. However, its cross-domain transfer strength is still moderate. Besides, relying on small-scale datasets to train a generator may limit the generalization of the threat model.
|
| 25 |
+
|
| 26 |
+
Considering that ImageNet is a large-scale dataset containing most of common categories in real life and there are various off-the-shelf pre-trained models, one can easily dig out much useful information to build a strong threat model. Therefore, in this paper, solely relying on the knowledge of the ImageNet domain, we introduce an effective Beyond ImageNet Attack (BIA) framework to enhance the cross-domain transferability of adversarial examples. To reflect the applicability of our approach, we consider eight different image classification tasks (listed in Table 1). Figure 1 illustrates an overview of our method. Particularly, we learn a flexible generator network $\mathcal { G } _ { \theta }$ against ImageNet domain. Instead of optimizing the domain-specific loss function like CDA, our method focuses on disrupting low-level features following previous literature to ensure the good transferability of our BIA. Furthermore, we propose two variants based on the vanilla BIA to narrow the gap between source and target domains. Specifically, from the data perspective, we propose a random normalization $( \mathcal { R N } )$ module to simulate different data distributions; from the model perspective, we propose a domain-agnostic attention $( \mathcal { D A } )$ module to capture essential features for perturbing. In the inference phase, our $\mathcal { G } _ { \theta }$ accepts images of any domain as the input and crafts adversarial examples with one forward propagation. Extensive experiments demonstrate the effectiveness of our proposed methods. Towards the coarse-grained and fine-grained domains, we can outperform state-of-the-art approaches by up to $7 . 7 1 \%$ and $2 5 . 9 1 \%$ on average, respectively. Besides, our methods can also enhance the cross-model transferability in the source domain.
|
| 27 |
+
|
| 28 |
+
# 2 RELATED WORKS
|
| 29 |
+
|
| 30 |
+
Iterative Optimization Approaches. Under the black-box threat model, iterative attack methods are a popular branch, which usually adopt domain-specific loss or intermediate feature loss to craft adversarial examples. For the former, Madry et al. (2018) extend Goodfellow et al. (2015) to perform projected gradient descent from randomly chosen starting points inside $\epsilon$ -ball. Dong et al. (2018) introduce momentum term to stable the update direction. Xie et al. (2019) apply random transformations of the input at each iteration, thus mitigating overfitting. Gao et al. (2020a) propose patch-wise perturbation to better cover the discriminative region. Wu et al. (2020a) explore the security weakness of skip connections (He et al., 2016; Huang et al., 2017) to boost attacks.
|
| 31 |
+
|
| 32 |
+

|
| 33 |
+
Figure 1: Our proposed generator framework aims to decrease the cosine similarity of feature between benign image $\scriptstyle { \mathbf { { \mathbf { x } } } } _ { s }$ and adversarial example $ { \boldsymbol { { x } } } _ { s } ^ { \prime }$ during the training phase. Training data and substitute model are all from the ImageNet domain. $\mathcal { C }$ module is applied to constrain $ { \boldsymbol { { x } } } _ { s } ^ { \prime }$ in the $\ell _ { \infty }$ -ball of $\mathbf { \Delta } _ { \mathbf { x } _ { s } }$ . $\mathcal { R N }$ and $\mathcal { D A }$ are optional, which can further improve the transferability.
|
| 34 |
+
|
| 35 |
+
Different from the methods mentioned above, intermediate feature-based methods focus on disrupting low-level features. For example, Zhou et al. (2018) maximize the Euclidean distance between the source image and target image in feature space and introduce regularization on perturbations to reduce variations. Inkawhich et al. (2019) make the source image close to the target image in feature space. Lu et al. (2020) propose a dispersion reduction attack to make the low-level features featureless. Naseer et al. (2020) design a self-supervised perturbation mechanism for enabling a transferable defense approach. Wu et al. (2020b) compute model attention over extracted features to regularize the search of adversarial examples.
|
| 36 |
+
|
| 37 |
+
Generator-oriented Approaches. Compared with iterative optimization approaches, generatororiented attacks are more efficient (i.e., only need one inference) to generate adversarial examples. In this branch, Baluja & Fischer (2017) propose an adversarial transformation network to modify the output of the classifier given the original input. Poursaeed et al. (2018) present trainable deep neural networks for producing both image-agnostic and image-dependent perturbations. Naseer et al. (2019) leverage datasets from other domain instead of ImageNet to train generator networks against pre-trained ImageNet models, and inference is performed on ImageNet domain with the aim of fooling black-box ImageNet model. They also attempt a practical black-box threat model (from ChestX-ray to ImageNet), and the attack success rate can outperform the result of Gaussian noise.
|
| 38 |
+
|
| 39 |
+
# 3 TRANSFERABLE ADVERSARIAL EXAMPLES BEYOND IMAGENET
|
| 40 |
+
|
| 41 |
+
# 3.1 PROBLEM FORMULATION
|
| 42 |
+
|
| 43 |
+
Given a target deep learning classifier $f _ { t } ( \cdot )$ trained in a specific data distribution $\chi _ { t }$ , we aim to craft a human-imperceptible perturbation for the benign image $\mathbf { \mathcal { x } } _ { t } ~ \sim ~ \mathrm { \mathcal { \chi } } _ { t }$ from the target domain with the only available knowledge of source ImageNet domain (including pre-trained model $f _ { s } ( \cdot )$ and data distribution $\chi _ { s }$ ). Formally, suppose we have a threat model $\mathcal { M } _ { \theta ^ { * } }$ whose parameter $\theta ^ { * }$ is solely derived from the source domain, our goal is to craft adversarial examples for $\mathbf { \Delta } _ { \mathbf { \mathcal { X } } _ { t } }$ from target domain so that they can fool the $f _ { t } ( \cdot )$ successfully:
|
| 44 |
+
|
| 45 |
+
$$
|
| 46 |
+
f _ { t } ( \mathcal { M } _ { \theta ^ { * } } ( \pmb { x } _ { t } ) ) \neq f _ { t } ( \pmb { x } _ { t } ) \quad s . t . | | \mathcal { M } _ { \theta ^ { * } } ( \pmb { x } _ { t } ) - \pmb { x } _ { t } | | _ { \infty } \leq \epsilon ,
|
| 47 |
+
$$
|
| 48 |
+
|
| 49 |
+
where $\epsilon$ is the maximum perturbation to ensure $\mathbf { \Delta } \mathbf { x } _ { t }$ is minimally changed. Intuitively, crafting adversarial examples for the black-box domain is very challenging. As shown in Table 1 and Figure 6 of Appendix, images from different domain vary greatly.
|
| 50 |
+
|
| 51 |
+
# 3.2 PRELIMINARY
|
| 52 |
+
|
| 53 |
+
Iterative/Single-step optimization methods (Goodfellow et al., 2015; Madry et al., 2018; Zhao et al., 2020; Gao et al., 2021; Mao et al., 2021; Li et al., 2021) and generator-oriented methods (Baluja & Fischer, 2017; Poursaeed et al., 2018; Naseer et al., 2019) are two popular branches for building the threat model. Since the attacker has the large-scale ImageNet training set at hand, there is no reason not to take full advantage of them. Therefore, in this paper, we adopt the generator-oriented framework which learns a transferable adversarial function via a generative model $\mathcal { G } _ { \theta }$ . Given that the threat model aims at crafting transferable adversarial examples for black-box domains, relying on the last layer with domain-specific loss functions (e.g., relativistic cross-entropy loss adopted by Naseer et al. (2019)) is less effective since this might lead to overfitting to source domain. In contrast, the intermediate layers of the DNN presumably extract general features (Yosinski et al., 2014) which may share across different models. Hence, as a baseline for the new black-domain attack problem, our Beyond ImageNet Attack (BIA) turns to destroy the low-level features of the substitute model at a specific layer $L$ to generate transferable adversarial examples according to existing literature (Yosinski et al., 2014; Zhou et al., 2018; Inkawhich et al., 2019).
|
| 54 |
+
|
| 55 |
+

|
| 56 |
+
Figure 2: Left: The data distribution (i.e., mean and standard deviation) for datasets from different domains. The result is the average over the three channels. Right: Two intermediate feature maps (Maxpool.3) of VGG-16 (Simonyan & Zisserman, 2015) (trained in ImageNet domain) for the input image from CUB-200-2011 (Wah et al., 2011).
|
| 57 |
+
|
| 58 |
+
As illustrated in Figure $1 , { \mathcal { G } } _ { \theta }$ is learned to decrease the cosine similarity between adversarial example $ { \boldsymbol { { x } } } _ { s } ^ { \prime }$ and benign image $\pmb { x _ { s } } \in \mathbb { R } ^ { N \times H _ { s } \times W _ { s } }$ (sampled from $\chi _ { s }$ ) to make the feature featureless:
|
| 59 |
+
|
| 60 |
+
$$
|
| 61 |
+
\theta ^ { * } = \underset { \theta } { \arg \operatorname* { m i n } } \mathcal { L } _ { c o s } ( f _ { s } ^ { L } ( \pmb { x } _ { s } ^ { \prime } ) , f _ { s } ^ { L } ( \pmb { x } _ { s } ) ) .
|
| 62 |
+
$$
|
| 63 |
+
|
| 64 |
+
In the inference phase, our generator $\mathcal { G } _ { \theta ^ { * } }$ can directly craft adversarial examples for input images $\pmb { x _ { t } } \in \mathbb { R } ^ { N \times H _ { t } \times W _ { t } ^ { \pm } }$ from the target domain:
|
| 65 |
+
|
| 66 |
+
$$
|
| 67 |
+
\begin{array} { r } { \pmb { x } _ { t } ^ { \prime } = \operatorname* { m i n } ( \pmb { x } _ { t } + \epsilon , \operatorname* { m a x } ( \mathcal { G } _ { \theta ^ { * } } ( \pmb { x } _ { t } ) , \pmb { x } _ { t } - \epsilon ) . } \end{array}
|
| 68 |
+
$$
|
| 69 |
+
|
| 70 |
+
The resulting adversarial examples $ { \boldsymbol { { x } } } _ { t } ^ { \prime }$ are depicted in Figure 8 of Appendix. Compared with CDA, our BIA is more effective in both source (white-box) and target (black-box) domains. Yet, as shown in Figure 2, crafting more transferable adversarial examples still has some challenges:
|
| 71 |
+
|
| 72 |
+
• Data Perspective: The distribution (i.e., mean and standard deviation) of source domain is largely different from the target domain. For example, the standard deviation of ImageNet is about twice that of SVHN. • Model Perspective: Although some feature map of $f _ { s } ^ { L } ( \cdot )$ can capture the object $( \in \chi _ { t } )$ for feature representation (e.g., the first feature map in Figure 2), there are also some feature maps that are significantly biased (e.g., the second feature map in Figure 2).
|
| 73 |
+
|
| 74 |
+
To alleviate the concern of generating poor transferable adversarial examples that may arise from the above limitations, we propose two variants, equipped with random normalization $( \mathcal { R N } )$ module or domain-agnostic attention $( \mathcal { D A } )$ module, respectively.
|
| 75 |
+
|
| 76 |
+
# 3.3 RANDOM NORMALIZATION MODULE
|
| 77 |
+
|
| 78 |
+
Generally, DNNs (Simonyan & Zisserman, 2015; He et al., 2016; Huang et al., 2017) are usually equipped with normalization for input images1 so that they can be modeled as samples from the standard normal distribution. However, as illustrated in Figure 2 (left), the distribution of dataset from the different domain can vary dramatically. Thus, training against a specific domain may limit the generalization of the resulting $\mathcal { G } _ { \theta ^ { * } }$ . Besides, the commonly used strategy of label-preserving data augmentation (Krizhevsky et al., 2012; Simonyan & Zisserman, 2015) is less effective because it has little effect on changing the distribution of the inputs (more details are shown in Appendix A.3).
|
| 79 |
+
|
| 80 |
+
To overcome this limitation, fusing knowledge from different domains might be helpful. As shown in Table 3 of Naseer et al. (2019), using training data from other domains against the pre-trained model in the source domain usually enhances the transferability of adversarial examples towards the target domain. However, this setup is not feasible because the available knowledge for a more practical threat model may be limited, i.e., restricted to one domain. Therefore, we instead propose a random normalization $( \mathcal { R N } )$ module to simulate different data distribution in the training phase:
|
| 81 |
+
|
| 82 |
+
$$
|
| 83 |
+
{ \mathcal R N } ( { \pmb x } _ { s } ) = \pmb { \sigma } \cdot \frac { { \pmb x } _ { s } - { \pmb \mu } ^ { \prime } } { \sigma ^ { \prime } } + { \pmb \mu } ,
|
| 84 |
+
$$
|
| 85 |
+
|
| 86 |
+
where $\sigma$ and $\pmb { \mu }$ are default standard deviation and mean vectors for ImageNet, and $\mu ^ { \prime } \sim$ $\mathcal { N } ( \mu _ { m e a n } ^ { \prime } , \mu _ { s t d } ^ { \prime } )$ and $\sigma ^ { \prime } \sim \mathcal { N } ( \sigma _ { m e a n } ^ { \prime } , \sigma _ { s t d } ^ { \prime } )$ are two random scales2 sampled from Gaussian distribution. Combined with $\mathcal { R N }$ , and the object function can be expressed as:
|
| 87 |
+
|
| 88 |
+
$$
|
| 89 |
+
\theta ^ { * } = \underset { \theta } { \arg \operatorname* { m i n } } \mathcal { L } _ { c o s } ( f _ { s } ^ { L } ( \mathcal { R N } ( \pmb { x } _ { s } ^ { \prime } ) ) , f _ { s } ^ { L } ( \mathcal { R N } ( \pmb { x } _ { s } ) ) ) .
|
| 90 |
+
$$
|
| 91 |
+
|
| 92 |
+
# 3.4 DOMAIN-AGNOSTIC ATTENTION MODULE
|
| 93 |
+
|
| 94 |
+
Unlike the random normalization module, the domain-agnostic attention module aims to narrow the domain gap from the model perspective. Our inspiration is from prior works (Hansen & Salamon, 1990; Caruana et al., 2004; Dong et al., 2018), which demonstrate that the ensemble strategy can avoid getting trapped in the local optimum and improve performance. Since there are many feature maps at layer $L$ and each of them can model the input, i.e., extracts the features, we can also integrate them to produce a more robust feature representation $\mathcal { A } ^ { L }$ , thus mitigating the impact of several biased feature maps, e.g., the second feature map of Figure 2. Specifically, we apply cross-channel average pooling to the feature maps at layer $L$ :
|
| 95 |
+
|
| 96 |
+
$$
|
| 97 |
+
\mathbf { \mathcal { A } } ^ { L } = \frac { | \sum _ { i = 0 } ^ { C } [ f _ { s } ^ { L } ( \pmb { x _ { s } } ) ] _ { i } | } { C } ,
|
| 98 |
+
$$
|
| 99 |
+
|
| 100 |
+
where $C$ is channel number of $f _ { s } ^ { L } ( { \pmb x } _ { s } )$
|
| 101 |
+
|
| 102 |
+
As depicted in Figure 3, even if our source model is not trained in the target domain, the robust feature representation is still able to capture the essential feature of object very well. Surprisingly, it is even similar to the one that derived from a completely different target model. Therefore, this robust feature representation can serve as a domain-agnostic attention $( \mathcal { D A } )$ to enhance the cross-domain transferability
|
| 103 |
+
|
| 104 |
+

|
| 105 |
+
Figure 3: Left: A benign image from Stanford Cars (Krause et al., 2013). Middle $\pmb { \& }$ Right: We apply cross-channel average pooling to the intermediate feature maps (M axpool.3) of VGG-16 and (Conv3 8) of DCL (Chen et al., 2019) with backbone Res-50.
|
| 106 |
+
|
| 107 |
+
of adversarial examples. Specifically, in the training phase, we leverage $\mathcal { A } ^ { L }$ to assign weights for each pixel of feature maps at the same layer. The resulting object function can be written as:
|
| 108 |
+
|
| 109 |
+
$$
|
| 110 |
+
\theta ^ { * } = \underset { \theta } { \arg \operatorname* { m i n } } \mathcal { L } _ { c o s } ( \mathcal { A } ^ { L } \odot f _ { s } ^ { L } ( \boldsymbol { x } _ { s } ^ { \prime } ) , \mathcal { A } ^ { L } \odot f _ { s } ^ { L } ( \boldsymbol { x } _ { s } ) ) ,
|
| 111 |
+
$$
|
| 112 |
+
|
| 113 |
+
where $\odot$ is Hadamard product. After the training, even if the inputs are not from the source domain, our generator $\mathcal { G } _ { \theta ^ { * } }$ is supposed to own an ability to capture the essential feature to disrupt.
|
| 114 |
+
|
| 115 |
+
# 4 EXPERIMENTS
|
| 116 |
+
|
| 117 |
+
Source (white-box) Domain. Our training data is the large-scale ImageNet (Russakovsky et al., 2015) training set which includes about 1.2 million $2 2 4 \times 2 2 4 \times 3$ images. Generators are trained against four ImageNet pre-trained models including VGG-16, VGG-19 (Simonyan & Zisserman, 2015), ResNet152 (Res-152) (He et al., 2016) and DenseNet169 (Dense-169) (Huang et al., 2017). In this domain, we also consider three other models, i.e., DenseNet121 (Dense-121) (Huang et al.,
|
| 118 |
+
|
| 119 |
+
2017), ResNet50 (Res-50) (He et al., 2016) and Inception-v3 (Inc-v3)3 (Szegedy et al., 2016), to analyze the cross-model transferability. All models are available in the Torchvision library4.
|
| 120 |
+
|
| 121 |
+
Target (black-box) Domain. Generally, the image classification tasks can be divided into coarsegrained and fine-grained tasks in terms of label granularity (Touvron et al., 2021). Thus, in addition to ImageNet (white-box domain), we consider seven other black-box domains (shown in Table 1) including four coarse-grained (CIFAR-10, CIFAR-100 (Krizhevsky, 2009), STL-10 (Coates et al., 2011) and SVHN (Netzer et al., 2011)) and three fine-grained (CUB-200-2011 (Wah et al., 2011), Stanford Cars (Krause et al., 2013) and FGVC Aircraft (Maji et al., 2013)) classification tasks. For the fine-grained classification, we use DCL framework (Chen et al., 2019) with three different backbones: ResNet50 (Res-50) (He et al., 2016), SENet154 and SE-ResNet101 (SE-Res101) (Hu et al., 2018). The pre-trained models for the coarse-grained classification are from Github5.
|
| 122 |
+
|
| 123 |
+
Implementation Details. Our generator $\mathcal { G } _ { \theta }$ adopts the same architecture as (Naseer et al., 2019), which is a composite of downsampling, residual (He et al., 2016) and upsampling blocks (more details can be found in Figure 7 of Appendix). The output size of $\mathcal { G } _ { \theta }$ is equal to the input size. For CDA and our methods, we use Adam optimizer (Kingma & Ba, 2015) with a learning rate of 2e-4 and the exponential decay rate for first and second moments is set to 0.5 and 0.999, respectively. All generators are trained for one epoch with the batch size 16. For the layer $L$ , we attack the output of M axpool.3 for VGG-16 and VGG-19, the output of Conv3 8 for Res-152 and the output of DenseBlock.2 for Dense-169 (ablation study can be found in Appendix A.1). For brevity, we only refer the output of a specific layer/block using its layer/block name. For our $\mathcal { R N }$ module, we set $\mu ^ { \prime } \sim \mathcal { N } ( 0 . 5 \bar { 0 } , 0 . 0 8 )$ and $\sigma ^ { \prime } \sim \dot { \mathcal { N } } ( 0 . 7 5 , 0 . 0 8 )$ , and the ablation study is shown in Appendix A.2.
|
| 124 |
+
|
| 125 |
+
Competitors. We compare our proposed methods with projected gradient descent (PGD) (Madry et al., 2018), diverse inputs method (DIM) (Dong et al., 2018; Xie et al., 2019), dispersion reduction (DR) (Lu et al., 2020), self-supervised perturbation (SSP) (Naseer et al., 2020) and cross-domain attack (CDA) (Naseer et al., 2019). The maximum perturbation $\varepsilon$ is set to 10. Follow Lu et al. (2020), we set the step size $\alpha = 4$ and the number of iterations $T = 1 0 0$ for all iterative methods. For DIM, we set the default decay factor $\mu = 1 . 0$ and the transformation probability $p = 0 . 7$ . The Gaussian smoothing (gs) for CDA is applied by $3 \times 3$ Gaussian kernel.
|
| 126 |
+
|
| 127 |
+
Evaluation Metrics. We use the top-1 accuracy on the whole test set (test size is shown in Table 1) after attacking to evaluate the performance of different methods. We also report standard deviation across multiple random runs in Appendix A.7.
|
| 128 |
+
|
| 129 |
+
# 4.1 TRANSFERABILITY COMPARISONS
|
| 130 |
+
|
| 131 |
+
In this section, we first conduct experiments for the black-box domain in Section 4.1.1 (coarsegrain) and Section 4.1.2 (fine-grain), then we report the results for the white-box (source) domain in Section 4.1.3. For the discussion of generator mechanism, changing source domain and ensemblemodel attacks, we leave them in Appendix A.4, Appendix A.5 and Appendix A.6, respectively.
|
| 132 |
+
|
| 133 |
+
# 4.1.1 RESULTS ON COARSE-GRAINED DOMAIN
|
| 134 |
+
|
| 135 |
+
In this section, we craft transferable adversarial examples for coarse-grained classification tasks. The results are shown in Table 2, where we leverage four ImageNet pre-trained models, including VGG-16, VGG-19, Res-152 and Dense-169, to train generators, respectively.
|
| 136 |
+
|
| 137 |
+
From Table 2, a first glance shows that our proposed methods consistently surpass state-of-the-art approaches. For example, if the substitute model is VGG-16, the most effective CDA remains a top-1 accuracy of $6 6 . 4 1 \%$ for CIFAR-10 after attacking, while our vanilla BIA can effectively bring down it to $5 7 . 3 8 \%$ and $\mathcal { D A }$ variant can further drop the top-1 accuracy to $5 5 . 1 6 \%$ . Among all tasks, the STL-10 and SVHN domains are the most difficult to attack, and the performance gap among existing attacks is moderate. Nonetheless, we can significantly enhance the transferability with the help of our $\mathcal { R N }$ variant in these domains. Notably, if the substitute model is Res-152, $\mathcal { R } \dot { \mathcal { N } }$ variant can further decrease the top-1 accuracy from $8 9 . 4 6 \%$ (vanilla BIA) to $8 5 . 7 9 \%$ on SVHN. Compared with state-of-the-art CDA on all domains, $\mathcal { R N }$ variant significantly outperforms it by $7 . 7 1 \%$ on average. This demonstrates that our proposed $\mathcal { R N }$ module is effective in coping with different distributions of inputs, thus improving the generalization of the resulting generator.
|
| 138 |
+
|
| 139 |
+
Table 2: Transferability comparisons on four coarse-grained classification tasks. Here we report the top-1 accuracy after attacking (the lower, the better). The generator $\mathcal { G } _ { \theta }$ is trained in the ImageNet domain, and adversarial examples are within the perturbation budget of $\ell _ { \infty } \leq 1 0$ .
|
| 140 |
+
|
| 141 |
+
<table><tr><td>Model</td><td>Attacks Clean</td><td>CIFAR-10 93.78</td><td>CIFAR-100 74.27</td><td>STL-10 77.59</td><td>SVHN 96.03</td><td>AVG. 85.42</td><td>Model</td><td>Attacks Clean</td><td>CIFAR-10 93.78</td><td>CIFAR-100 74.27</td><td>STL-10 77.59</td><td>SVHN 96.03</td><td>AVG. 85.42</td></tr><tr><td rowspan="9">91-99A</td><td>PGD</td><td>79.63</td><td>48.02</td><td>74.32</td><td>94.66</td><td>74.16</td><td></td><td>PGD DIM</td><td>86.17</td><td>56.38</td><td>74.51</td><td>93.94</td><td>77.75</td></tr><tr><td>DIM</td><td>77.16</td><td>44.75</td><td>72.74</td><td>91.53</td><td>71.55</td><td></td><td></td><td>80.50</td><td>48.03</td><td>71.2</td><td>90.87</td><td>72.65</td></tr><tr><td>DR</td><td>72.49</td><td>39.04</td><td>72.56</td><td>93.27</td><td>69.34</td><td></td><td>DR</td><td>78.86</td><td>48.62</td><td>71.66</td><td>93.26</td><td>73.10</td></tr><tr><td>SSP</td><td>68.54</td><td>33.63</td><td>72.77</td><td>93.98</td><td>67.23</td><td></td><td>SSP</td><td>75.54</td><td>42.38</td><td>72.66</td><td>92.63</td><td>70.80</td></tr><tr><td>CDA</td><td>66.41</td><td>32.37</td><td>72.91</td><td>92.17</td><td>65.97</td><td>P2s3152</td><td>CDA</td><td>66.47</td><td>39.30</td><td>69.81</td><td>88.09</td><td>65.92</td></tr><tr><td>CDA+gs</td><td>86.70</td><td>59.43</td><td>73.38</td><td>91.61</td><td>77.78</td><td></td><td>CDA+gs</td><td>85.61</td><td>57.27</td><td>73.06</td><td>90.34</td><td>76.57</td></tr><tr><td>BIA (Ours)</td><td>57.38</td><td>22.47</td><td>69.45</td><td>90.44</td><td>59.94</td><td></td><td>BIA(Ours)</td><td>65.49</td><td>33.48</td><td>69.91</td><td>89.46</td><td>64.59</td></tr><tr><td>BIA+DA(Ours)</td><td>55.16</td><td>21.71</td><td>70.00</td><td>91.76</td><td>59.66</td><td></td><td>BIA+DA(Ours)</td><td>65.34</td><td>32.68</td><td>69.65</td><td>91.38</td><td>64.76</td></tr><tr><td>BIA+RN(Ours)</td><td>52.81</td><td>20.82</td><td>67.55</td><td>88.03</td><td>57.30</td><td></td><td>BIA+RN(Ours)</td><td>61.23</td><td>32.84</td><td>68.04</td><td>85.79</td><td>61.98</td></tr><tr><td rowspan="9">6-D5A</td><td>PGD</td><td>79.15</td><td>47.73</td><td>74.71</td><td>94.86</td><td>74.11</td><td></td><td>PGD</td><td>84.55</td><td>54.29</td><td>74.55</td><td>93.83</td><td>76.81</td></tr><tr><td>DIM</td><td>77.54</td><td></td><td></td><td>91.68</td><td>71.50</td><td></td><td>DIM</td><td>80.89</td><td></td><td></td><td></td><td>73.02</td></tr><tr><td>DR</td><td>70.72</td><td>43.81</td><td>72.96</td><td>93.73</td><td>68.51</td><td></td><td>DR</td><td>78.24</td><td>49.06 48.67</td><td>72.64</td><td>89.47 93.2</td><td>72.72</td></tr><tr><td>SSP</td><td>70.46</td><td>37.59 35.28</td><td>71.98 73.21</td><td>93.67</td><td>68.16</td><td>GD-sse50</td><td>SSP</td><td>77.13</td><td>42.18</td><td>70.75</td><td>91.64</td><td>70.87</td></tr><tr><td>CDA</td><td>81.60</td><td>51.53</td><td>71.43</td><td>92.64</td><td>74.30</td><td></td><td>CDA</td><td>67.75</td><td>35.03</td><td>72.53 69.00</td><td>88.76</td><td>65.14</td></tr><tr><td>CDA+gs</td><td>88.55</td><td>61.90</td><td>73.64</td><td>92.18</td><td>79.07</td><td></td><td>CDA+gs</td><td>85.01</td><td>54.71</td><td>72.61</td><td>88.69</td><td>75.26</td></tr><tr><td>BIA (Ours)</td><td>57.88</td><td>23.12</td><td></td><td></td><td>59.93</td><td></td><td>BIA (Ours)</td><td>72.02</td><td></td><td></td><td></td><td></td></tr><tr><td>BIA+DA(Ours)</td><td>57.26</td><td>23.04</td><td>69.84 70.16</td><td>88.89 90.08</td><td>60.14</td><td></td><td>BIA+DA(Ours)</td><td>71.69</td><td>38.99 38.95</td><td>69.80</td><td>86.12</td><td>66.73</td></tr><tr><td>BIA+RN (Ours)</td><td>54.47</td><td>22.61</td><td>68.23</td><td>88.08</td><td>58.35</td><td></td><td>BIA+RN (Ours)</td><td>66.67</td><td>34.41</td><td>70.60 68.79</td><td>88.02 81.54</td><td>67.32 62.85</td></tr></table>
|
| 142 |
+
|
| 143 |
+
Table 3: Transferability comparisons on three fine-grained classification tasks. Here we report the top-1 accuracy after attacking (the lower, the better). The generator $\mathcal { G } _ { \theta }$ is trained in ImageNet domain and adversarial examples are within the perturbation budget of $\ell _ { \infty } \leq 1 0$ .
|
| 144 |
+
|
| 145 |
+
<table><tr><td rowspan="2">Model</td><td rowspan="2">Attacks</td><td colspan="3">CUB-200-2011</td><td colspan="3">Stanford Cars</td><td colspan="3">FGVC Aircraft</td><td rowspan="2">AVG.</td></tr><tr><td>Res-50</td><td>SENet154</td><td>SE-Res101</td><td>Res-50</td><td>SENet154</td><td>SE-Res101</td><td>Res-50</td><td></td><td>SENet154SE-Res101</td></tr><tr><td rowspan="9">9I-55A</td><td>Clean</td><td>87.35</td><td>86.81</td><td>86.56</td><td>94.35</td><td>93.36</td><td>92.97</td><td>92.23</td><td>92.08</td><td>91.90</td><td>90.85</td></tr><tr><td>PGD</td><td>80.65</td><td>79.58</td><td>80.69</td><td>87.45</td><td>89.04</td><td>90.30</td><td>84.88</td><td>83.92</td><td>82.15</td><td>84.30</td></tr><tr><td>DIM</td><td>70.02</td><td>62.86</td><td>70.57</td><td>74.72</td><td>78.10</td><td>84.33</td><td>73.54</td><td>66.88</td><td>62.38</td><td>71.49</td></tr><tr><td>DR</td><td>81.08</td><td>82.05</td><td>82.52</td><td>90.82</td><td>90.59</td><td>91.12</td><td>84.97</td><td>87.55</td><td>85.54</td><td>86.25</td></tr><tr><td>SSP</td><td>62.27</td><td>60.44</td><td>71.52</td><td>58.02</td><td>75.71</td><td>83.02</td><td>54.91</td><td>68.74</td><td>63.79</td><td>66.49</td></tr><tr><td>CDA</td><td>69.69 70.19</td><td>62.51</td><td>71.00</td><td>75.94</td><td>72.45</td><td>84.64</td><td>71.53</td><td>58.33</td><td>63.39</td><td>69.94</td></tr><tr><td>CDA+gs</td><td></td><td>63.19</td><td>68.92</td><td>85.03</td><td>79.52</td><td>83.52</td><td>78.55</td><td>65.62</td><td>68.38</td><td>73.66</td></tr><tr><td>BIA (Ours)</td><td>32.74 25.00</td><td>52.99</td><td>58.04</td><td>39.61</td><td>69.90</td><td>70.17</td><td>28.92</td><td>60.31</td><td>46.92</td><td>51.07</td></tr><tr><td>BIA+DA(Ours) BIA+RN(Ours)</td><td>26.13</td><td>40.27 46.15</td><td>53.24 55.07</td><td>22.24 20.61</td><td>59.48 62.64</td><td>61.52 63.38</td><td>15.36 16.50</td><td>47.91 52.54</td><td>40.83 45.48</td><td>40.65 43.17</td></tr><tr><td rowspan="9">6--555</td><td>PGD</td><td>80.98</td><td>79.00</td><td>80.60</td><td>87.54</td><td>88.87</td><td>90.56</td><td>84.70</td><td>84.01</td><td>83.35</td><td>84.40</td></tr><tr><td>DIM</td><td>69.93</td><td>61.60</td><td>70.90</td><td>75.02</td><td>78.55</td><td>84.63</td><td>74.59</td><td>67.69</td><td>65.26</td><td>72.02</td></tr><tr><td>DR</td><td>80.83</td><td>81.57</td><td>81.95</td><td>91.00</td><td>90.23</td><td>91.15</td><td>84.43</td><td>85.96</td><td>84.57</td><td>85.74</td></tr><tr><td>SSP</td><td>62.94</td><td>58.34</td><td>70.45</td><td>61.90</td><td>76.27</td><td>83.77</td><td>58.78</td><td>69.52</td><td>66.88</td><td>67.65</td></tr><tr><td>CDA</td><td>59.48</td><td>61.08</td><td>68.50</td><td>58.53</td><td>70.70</td><td>80.70</td><td>59.26</td><td>52.24</td><td>62.26</td><td>63.64</td></tr><tr><td>CDA+gs</td><td>67.88</td><td>59.42</td><td>67.57</td><td>82.83</td><td>78.61</td><td>82.64</td><td>79.36</td><td>65.89</td><td>68.35</td><td>72.51</td></tr><tr><td>BIA (Ours)</td><td>48.90</td><td>52.33</td><td>56.47</td><td>66.34</td><td>72.45</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>BIA+DA(Ours)</td><td>27.46</td><td>37.61</td><td>50.14</td><td>35.27</td><td>61.40</td><td>75.08 64.41</td><td>50.95 17.97</td><td>54.04 45.81</td><td>51.79 44.01</td><td>58.71</td></tr><tr><td>BIA+RN(Ours)</td><td>31.77</td><td>43.41</td><td>51.09</td><td>42.81</td><td>68.90</td><td>66.27</td><td>27.75</td><td>52.48</td><td>45.57</td><td>42.68 47.78</td></tr><tr><td rowspan="8">P1s-152</td><td>PGD</td><td>73.21</td><td>75.89</td><td>76.11</td><td>83.99</td><td>86.89</td><td>88.24</td><td>79.00</td><td>79.30</td><td>75.64</td><td>79.81</td></tr><tr><td>DIM</td><td>56.30</td><td>59.35</td><td>63.36</td><td>67.88</td><td>76.37</td><td>79.77</td><td>64.21</td><td>62.95</td><td>54.49</td><td>64.96</td></tr><tr><td>DR</td><td>77.58</td><td>82.07</td><td>80.60</td><td>87.96</td><td>90.11</td><td>90.67</td><td>77.89</td><td>82.27</td><td>80.08</td><td>83.25</td></tr><tr><td>SSP</td><td>47.64</td><td>66.17</td><td>67.90</td><td>53.29</td><td>79.09</td><td>83.45</td><td>58.35</td><td>73.36</td><td>69.34</td><td>66.51</td></tr><tr><td>CDA</td><td>45.15</td><td>53.69</td><td>52.86</td><td>57.72</td><td>63.09</td><td>73.05</td><td>64.87</td><td>46.74</td><td>59.11</td><td>57.36</td></tr><tr><td>CDA+gs</td><td>59.32</td><td>64.24</td><td>60.08</td><td>81.15</td><td>82.91</td><td>82.56</td><td>75.52</td><td>73.72</td><td>66.58</td><td>71.79</td></tr><tr><td>BIA(Ours)</td><td>43.55</td><td>49.50</td><td>55.54</td><td>31.65</td><td>54.12</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>BIA+DA(Ours)</td><td>25.80</td><td>39.71</td><td>52.83</td><td>33.43</td><td>52.41</td><td>67.21 68.03</td><td>38.49 27.51</td><td>32.46 27.42</td><td>51.19 47.28</td><td>47.08 41.60</td></tr><tr><td rowspan="8">GDr-ese5g</td><td>BIA+RN(Ours)</td><td>23.54</td><td>40.13</td><td>51.36</td><td>12.39</td><td>47.92</td><td>60.59</td><td>32.34</td><td>32.85</td><td>46.89</td><td>38.67</td></tr><tr><td>PGD</td><td>79.29</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>DIM</td><td>63.17</td><td>81.14 62.01</td><td>79.74 65.96</td><td>87.66 72.88</td><td>90.13</td><td>89.80</td><td>83.23</td><td>84.31</td><td>81.24</td><td>84.06</td></tr><tr><td>DR</td><td>74.84</td><td>78.89</td><td>77.93</td><td>86.54</td><td>78.29 88.82</td><td>81.25 89.52</td><td>68.89 77.80</td><td>65.26 78.73</td><td>54.79 74.47</td><td>68.06 80.84</td></tr><tr><td>SSP</td><td>41.80</td><td>49.95</td><td>59.72</td><td>26.65</td><td>68.71</td><td>74.36</td><td>16.80</td><td>55.78</td><td>44.07</td><td>48.65</td></tr><tr><td>CDA</td><td>52.92</td><td>60.96</td><td>57.04</td><td>53.64</td><td>73.66</td><td>75.51</td><td>62.23</td><td>61.42</td><td>59.83</td><td>61.91</td></tr><tr><td>CDA+gs</td><td>60.86</td><td>61.34</td><td>60.10</td><td>74.95</td><td>76.35</td><td>78.86</td><td>72.94</td><td>68.68</td><td>64.66</td><td>68.75</td></tr><tr><td>BIA (Ours)</td><td>21.79</td><td>29.29</td><td>39.13</td><td>9.58</td><td>44.46</td><td>49.06</td><td>8.04</td><td>27.84</td><td>33.87</td><td>29.23</td></tr><tr><td></td><td>BIA+DA(Ours) 12.36</td></table>
|
| 146 |
+
|
| 147 |
+
# 4.1.2 RESULTS ON FINE-GRAINED DOMAIN
|
| 148 |
+
|
| 149 |
+
We also analyze the transferability of adversarial examples towards fine-grained classification tasks. For each domain, three black-box models with different backbones trained via the DCL framework are the target. The results are summarized in Table 3, where the leftmost column is the substitute model and the top row shows the target model.
|
| 150 |
+
|
| 151 |
+
In this scenario, the performance gap between the existing state-of-the-art algorithms and our proposed methods is further enlarged. Remarkably, when attacking against Dense-169, even the vanilla BIA can drop the average top-1 accuracy to $2 9 . 2 3 \%$ , while $\mathrm { C D A + g s }$ , CDA, SSP, DR, DIM and PGD are still with the high average top-1 accuracy of $6 8 . 7 5 \%$ , $6 1 . 9 1 \%$ , $4 8 . 6 5 \%$ , $8 0 . 8 4 \%$ , $6 8 . 0 6 \%$ and $8 4 . 0 6 \%$ after attacking, respectively. Furthermore, by adding $\mathcal { D A }$ or $\mathcal { R N }$ modules in the training phase, the generator $\mathcal { G } _ { \theta ^ { * } }$ is capable of crafting more transferable adversarial examples. On average, our $\mathcal { R N }$ variant can reduce the top-1 accuracy from $4 6 . 5 2 \%$ (vanilla BIA) to $3 9 . 3 3 \%$ , and $\mathcal { D A }$ variant can further drop it to $3 6 . 4 2 \%$ , which remarkably outperforms SSP by $2 5 . 9 1 \%$ . This demonstrates our proposed $\mathcal { D A }$ module can effectively alleviate the bias caused by several feature maps, thus focusing on disrupting essential features.
|
| 152 |
+
|
| 153 |
+
Table 4: Transferability comparisons on ImageNet (source domain). Here we report the top-1 accuracy after attacking (the lower, the better). The generator $\mathcal { G } _ { \theta }$ is trained in ImageNet domain (“\*” denotes white-box model) and adversarial examples are within the perturbation budget of $\ell _ { \infty } \leq 1 0$ .
|
| 154 |
+
|
| 155 |
+
<table><tr><td>Model</td><td>Attack Clean</td><td>VGG-16 70.14</td><td>Dense-169 75.75</td><td>VGG-19 70.95</td><td>Res-50 74.61</td><td>Res-152 77.34</td><td>Dense-121 74.22</td><td>Inc-v3 76.19</td><td>AVG. 74.17</td></tr><tr><td rowspan="9">VGG-16</td><td>PGD</td><td>2.49*</td><td>53.22</td><td>4.27</td><td>45.52</td><td>58.69</td><td>48.28</td><td>61.08</td><td>39.08</td></tr><tr><td>DIM</td><td>3.32*</td><td>22.72</td><td>3.39</td><td>19.13</td><td>33.03</td><td>18.50</td><td>30.05</td><td>18.59</td></tr><tr><td>DR</td><td>20.95*</td><td>67.91</td><td>43.59</td><td>64.90</td><td>70.00</td><td>64.73</td><td>69.22</td><td>57.33</td></tr><tr><td>SSP</td><td>0.95*</td><td>39.56</td><td>3.42</td><td>26.22</td><td>41.68</td><td>34.45</td><td>47.46</td><td>27.68</td></tr><tr><td>CDA</td><td>0.40*</td><td>42.67</td><td>0.77</td><td>36.27</td><td>51.05</td><td>38.89</td><td>54.02</td><td>32.01</td></tr><tr><td>CDA+gs</td><td>12.10*</td><td>57.09</td><td>20.48</td><td>51.87</td><td>60.83</td><td>52.21</td><td>55.12</td><td>44.24</td></tr><tr><td>BIA (Ours)</td><td>1.55*</td><td>32.35</td><td>3.61</td><td>25.36</td><td>42.98</td><td>26.97</td><td>41.20</td><td>24.86</td></tr><tr><td>BIA+DA(Ours)</td><td>1.04*</td><td>24.52</td><td>2.07</td><td>18.63</td><td>36.43</td><td>19.97</td><td>34.54</td><td>19.60</td></tr><tr><td>BIA+RN(Ours)</td><td>1.44*</td><td>25.96</td><td>2.58</td><td>16.52</td><td>31.80</td><td>18.25</td><td>28.54</td><td>17.87</td></tr><tr><td rowspan="9">Dense-169</td><td>PGD</td><td>38.51</td><td>5.03*</td><td>40.53</td><td>33.91</td><td>44.97</td><td>21.18</td><td>58.30</td><td>34.63</td></tr><tr><td>DIM</td><td>12.31</td><td>5.25*</td><td>13.20</td><td>8.98</td><td>12.93</td><td>5.91</td><td>21.44</td><td>11.43</td></tr><tr><td>DR</td><td>38.45</td><td>23.99*</td><td>41.59</td><td>50.19</td><td>58.70</td><td>49.95</td><td>63.70</td><td>46.65</td></tr><tr><td>SSP</td><td>11.53</td><td>1.32*</td><td>12.54</td><td>12.97</td><td>25.66</td><td>9.74</td><td>25.58</td><td>14.19</td></tr><tr><td>CDA</td><td>7.26</td><td>0.63*</td><td>7.91</td><td>6.46</td><td>15.56</td><td>5.13</td><td>43.78</td><td>12.39</td></tr><tr><td>CDA+gs</td><td>27.98</td><td>22.95*</td><td>28.56</td><td>31.52</td><td>43.67</td><td>31.66</td><td>49.18</td><td>33.65</td></tr><tr><td>BIA (Ours)</td><td>4.76</td><td>6.45*</td><td>7.15</td><td>6.97</td><td>13.83</td><td>6.60</td><td>38.58</td><td>12.05</td></tr><tr><td>BIA+DA(Ours)</td><td>3.17</td><td>3.32*</td><td>4.09</td><td>4.44</td><td>5.85</td><td>3.98</td><td>26.51</td><td>7.34</td></tr><tr><td>BIA+RN(Ours)</td><td>3.66</td><td>4.05*</td><td>5.23</td><td>6.91</td><td>13.25</td><td>4.21</td><td>14.24</td><td>7.36</td></tr></table>
|
| 156 |
+
|
| 157 |
+
# 4.1.3 RESULTS ON SOURCE DOMAIN
|
| 158 |
+
|
| 159 |
+
Although our proposed methods are mainly designed to improve the threat of adversarial examples towards black-box domains, they are also effective for enhancing the cross-model black-box transferability in the white-box domain. For example, by training against Dense-169, CDA still remains a top-1 accuracy of $4 3 . 7 8 \%$ on Inc-v3, while our BIA can achieve a relatively low top-1 accuracy of $3 8 . 5 8 \%$ on it. Besides, $\mathcal { R N }$ variant can further decrease the top-1 accuracy on Dense-169 (whitebox model) and Inc-v3 (black-box model) by $2 . 4 \%$ and $2 4 . 3 4 \%$ , respectively. This demonstrates that our proposed $\mathcal { R N }$ module is also able to avoid getting stuck in the local optimum of a specific model when training on a large-scale dataset. For $\mathcal { D A }$ variant, since the target domain and source domain are identical, it is naturally able to improve the transferability as well. As shown in Table 4, compared with vanilla BIA, $\mathcal { D A }$ variant can further degrade the top-1 accuracy from $1 8 . 4 5 \%$ (vanilla BIA) to $1 3 . 4 7 \%$ on average.
|
| 160 |
+
|
| 161 |
+
4.2 COMBINATION OF DOMAIN-AGNOSTIC ATTENTION AND RANDOM NORMALIZATION
|
| 162 |
+
|
| 163 |
+
In this section, we report the results for BIA equipped with both $\mathcal { R N }$ and $\mathcal { D A }$ . The following is the update rule:
|
| 164 |
+
|
| 165 |
+
$$
|
| 166 |
+
\theta ^ { * } = \underset { \theta } { \arg \operatorname* { m i n } } \ : \mathcal { L } _ { c o s } ( \mathcal { A } ^ { L } \odot f _ { s } ^ { L } ( \mathcal { R N } ( \boldsymbol { x } _ { s } ^ { \prime } ) ) , \boldsymbol { \mathcal { A } } ^ { L } \odot f _ { s } ^ { L } ( \mathcal { R N } ( \boldsymbol { x } _ { s } ) ) ) .
|
| 167 |
+
$$
|
| 168 |
+
|
| 169 |
+
As illustrated in Figure 4, $\mathcal { R N }$ module and $\mathcal { D A }$ module are not always mutually reinforcing. For example, when training against Res-152 and transferring adversarial examples to fine-grained or source domains, combining $\mathcal { R N }$ module and $\mathcal { D A }$ module can further decrease the average top-1 accuracy to $3 5 . 7 5 \%$ and $1 3 . 1 1 \%$ , respectively. However, if the black-box domain is coarse-grain,
|
| 170 |
+
|
| 171 |
+
only applying $\mathcal { R N }$ module is better than applying both $\mathcal { R N }$ and $\mathcal { D A }$ modules. We speculate that it may be because the $\mathcal { R N }$ module affects the low-level features extract by the substitute model, and thus be incompatible with the $\mathcal { D A }$ module sometimes.
|
| 172 |
+
|
| 173 |
+
Since Figure 4 shows that using $\mathcal { D A }$ and $\mathcal { R N }$ in tandem is less effective when training against Dense-169 while they reinforce each other in VGG-16 in most cases, we visualize the cross-channel average pooling of intermediate features for VGG-16 and Dense-169 to better explain this phenomenon. As illustrated in Figure 5, it can be observed that the $\mathcal { R N }$ module reinforces the discriminative features in VGG-16. However, it in
|
| 174 |
+
|
| 175 |
+

|
| 176 |
+
Figure 4: The average top-1 accuracy of $\mathcal { D A }$ , $\mathcal { R N }$ and $\mathcal { D } \bar { \mathcal { A } } + \mathcal { R } \mathcal { N }$ variants after attacking on coarse-grained, fine-grained and source domains.
|
| 177 |
+
|
| 178 |
+
hibits the response of objects’ essential features extracted by Dense-169. Consequently, $\mathcal { D A }$ module may cause the resulting generator to reduce the ability to attack essential features, thereby making it challenging to use these two techniques in tandem.
|
| 179 |
+
|
| 180 |
+

|
| 181 |
+
Figure 5: Visualization (cross-channel average pooling) of intermediate features for VGG-16 and Dense-169. It can be observed that the $\mathcal { R N }$ module inhibits the response of objects’ essential feature extracted by Dense-169, while VGG-16 enhances the response.
|
| 182 |
+
|
| 183 |
+
# 5 CONCLUSION
|
| 184 |
+
|
| 185 |
+
In this paper, we present a practical black-box threat model for the cross-domain attack. Specifically, we train a generator network in the large-scale ImageNet domain to disrupt low-level features better, thus generating transferable adversarial examples for the black-box domain. Based on this framework, we further propose two variants to narrow the gap between the source and target domains from the data and model perspectives, respectively. Extensive experiments demonstrate the effectiveness of our proposed methods. This also reminds the model owner that “Your deployed model is not safe even you do not leak any information to the public”. We hope our proposed approaches can serve as a benchmark for evaluating the stability of various deployed models.
|
| 186 |
+
|
| 187 |
+
# 6 ACKNOWLEDGE
|
| 188 |
+
|
| 189 |
+
This work was supported by the National Natural Science Foundation of China (Grant No.
|
| 190 |
+
62020106008, No. 61772116 and No. 61872064) and Alibaba Group.
|
| 191 |
+
|
| 192 |
+
# REFERENCES
|
| 193 |
+
|
| 194 |
+
Shumeet Baluja and Ian Fischer. Adversarial transformation networks: Learning to generate adversarial examples. CoRR, abs/1703.09387, 2017.
|
| 195 |
+
|
| 196 |
+
Wieland Brendel, Jonas Rauber, and Matthias Bethge. Decision-based adversarial attacks: Reliable attacks against black-box machine learning models. In ICLR, 2018.
|
| 197 |
+
|
| 198 |
+
Nicholas Carlini and David A. Wagner. Towards evaluating the robustness of neural networks. In Symposium on Security and Privacy, 2017.
|
| 199 |
+
|
| 200 |
+
Rich Caruana, Alexandru Niculescu-Mizil, Geoff Crew, and Alex Ksikes. Ensemble selection from libraries of models. In ICML, 2004.
|
| 201 |
+
|
| 202 |
+
Jianbo Chen, Michael I. Jordan, and Martin J. Wainwright. Hopskipjumpattack: A query-efficient decision-based attack. In SP, 2020.
|
| 203 |
+
|
| 204 |
+
Yue Chen, Yalong Bai, Wei Zhang, and Tao Mei. Destruction and construction learning for finegrained image recognition. In CVPR, 2019.
|
| 205 |
+
|
| 206 |
+
Adam Coates, Andrew Y. $\mathrm { N g }$ , and Honglak Lee. An analysis of single-layer networks in unsupervised feature learning. In Geoffrey J. Gordon, David B. Dunson, and Miroslav Dud´ık (eds.), AISTATS, 2011.
|
| 207 |
+
|
| 208 |
+
Yinpeng Dong, Fangzhou Liao, Tianyu Pang, Hang Su, Jun Zhu, Xiaolin Hu, and Jianguo Li. Boosting adversarial attacks with momentum. In CVPR, 2018.
|
| 209 |
+
|
| 210 |
+
Ranjie Duan, Xiaofeng Mao, A. Kai Qin, Yuefeng Chen, Shaokai Ye, Yuan He, and Yun Yang. Adversarial laser beam: Effective physical-world attack to dnns in a blink. In CVPR, 2021.
|
| 211 |
+
|
| 212 |
+
Lianli Gao, Qilong Zhang, Jingkuan Song, Xianglong Liu, and Hengtao Shen. Patch-wise attack for fooling deep neural network. In ECCV, 2020a.
|
| 213 |
+
|
| 214 |
+
Lianli Gao, Qilong Zhang, Jingkuan Song, and Heng Tao Shen. Patch-wise $^ { + + }$ perturbation for adversarial targeted attacks. CoRR, abs/2012.15503, 2020b.
|
| 215 |
+
|
| 216 |
+
Lianli Gao, Yaya Cheng, Qilong Zhang, Xing Xu, and Jingkuan Song. Feature space targeted attacks by statistic alignment. In IJCAI, 2021.
|
| 217 |
+
|
| 218 |
+
Ian J. Goodfellow, Jonathon Shlens, and Christian Szegedy. Explaining and harnessing adversarial examples. In Yoshua Bengio and Yann LeCun (eds.), ICLR, 2015.
|
| 219 |
+
|
| 220 |
+
Lars Kai Hansen and Peter Salamon. Neural network ensembles. IEEE Trans. Pattern Anal. Mach. Intell., 1990.
|
| 221 |
+
|
| 222 |
+
Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. In CVPR, 2016.
|
| 223 |
+
|
| 224 |
+
Jie Hu, Li Shen, and Gang Sun. Squeeze-and-excitation networks. In CVPR, 2018.
|
| 225 |
+
|
| 226 |
+
Gao Huang, Zhuang Liu, Laurens van der Maaten, and Kilian Q. Weinberger. Densely connected convolutional networks. In CVPR, 2017.
|
| 227 |
+
|
| 228 |
+
Nathan Inkawhich, Wei Wen, Hai (Helen) Li, and Yiran Chen. Feature space perturbations yield more transferable adversarial examples. In CVPR, 2019.
|
| 229 |
+
|
| 230 |
+
Nathan Inkawhich, Kevin J. Liang, Binghui Wang, Matthew Inkawhich, Lawrence Carin, and Yiran Chen. Perturbing across the feature hierarchy to improve standard and strict blackbox attack transferability. In Hugo Larochelle, Marc’Aurelio Ranzato, Raia Hadsell, Maria-Florina Balcan, and Hsuan-Tien Lin (eds.), NeurIPS, 2020.
|
| 231 |
+
|
| 232 |
+
Diederik P. Kingma and Jimmy Ba. Adam: A method for stochastic optimization. In ICLR, 2015.
|
| 233 |
+
|
| 234 |
+
Jonathan Krause, Jia Deng, Michael Stark, and Li Fei-Fei. Collecting a large-scale dataset of finegrained cars. 2013.
|
| 235 |
+
|
| 236 |
+
Alex Krizhevsky. Learning multiple layers of features from tiny images. 2009.
|
| 237 |
+
|
| 238 |
+
Alex Krizhevsky, Ilya Sutskever, and Geoffrey E. Hinton. Imagenet classification with deep convolutional neural networks. In NeurPIS, 2012.
|
| 239 |
+
|
| 240 |
+
Alexey Kurakin, Ian J. Goodfellow, and Samy Bengio. Adversarial examples in the physical world. In ICLR, 2017a.
|
| 241 |
+
|
| 242 |
+
Alexey Kurakin, Ian J. Goodfellow, and Samy Bengio. Adversarial machine learning at scale. In ICLR, 2017b.
|
| 243 |
+
|
| 244 |
+
Xiaodan Li, Jinfeng Li, Yuefeng Chen, Shaokai Ye, Yuan He, Shuhui Wang, Hang Su, and Hui Xue. QAIR: practical query-efficient black-box attacks for image retrieval. In CVPR, 2021.
|
| 245 |
+
|
| 246 |
+
Yanpei Liu, Xinyun Chen, Chang Liu, and Dawn Song. Delving into transferable adversarial examples and black-box attacks. In ICLR, 2017.
|
| 247 |
+
|
| 248 |
+
Ye Liu, Yaya Cheng, Lianli Gao, Xianglong Liu, Qilong Zhang, and Jingkuan Song. Practical evaluation of adversarial robustness via adaptive auto attack. In CVPR, 2022.
|
| 249 |
+
|
| 250 |
+
Yantao Lu, Yunhan Jia, Jianyu Wang, Bai Li, Weiheng Chai, Lawrence Carin, and Senem Velipasalar. Enhancing cross-task black-box transferability of adversarial examples with dispersion reduction. In CVPR, 2020.
|
| 251 |
+
|
| 252 |
+
Aleksander Madry, Aleksandar Makelov, Ludwig Schmidt, Dimitris Tsipras, and Adrian Vladu. Towards deep learning models resistant to adversarial attacks. In ICLR, 2018.
|
| 253 |
+
|
| 254 |
+
Subhransu Maji, Esa Rahtu, Juho Kannala, Matthew B. Blaschko, and Andrea Vedaldi. Fine-grained visual classification of aircraft. volume abs/1306.5151, 2013.
|
| 255 |
+
|
| 256 |
+
Xiaofeng Mao, Yuefeng Chen, Shuhui Wang, Hang Su, Yuan He, and Hui Xue. Composite adversarial attacks. In AAAI, 2021.
|
| 257 |
+
|
| 258 |
+
Seyed-Mohsen Moosavi-Dezfooli, Alhussein Fawzi, and Pascal Frossard. Deepfool: A simple and accurate method to fool deep neural networks. In CVPR, 2016.
|
| 259 |
+
|
| 260 |
+
Konda Reddy Mopuri, Utkarsh Ojha, Utsav Garg, and R. Venkatesh Babu. NAG: network for adversary generation. In CVPR, 2018.
|
| 261 |
+
|
| 262 |
+
Muzammal Naseer, Salman H. Khan, Muhammad Haris Khan, Fahad Shahbaz Khan, and Fatih Porikli. Cross-domain transferability of adversarial perturbations. In NeurPIS, 2019.
|
| 263 |
+
|
| 264 |
+
Muzammal Naseer, Salman H. Khan, Munawar Hayat, Fahad Shahbaz Khan, and Fatih Porikli. A self-supervised approach for adversarial robustness. In CVPR, 2020.
|
| 265 |
+
|
| 266 |
+
Yuval Netzer, Tao Wang, Adam Coates, Alessandro Bissacco Bo Wu, and Andrew Y. Ng. Reading digits in natural images with unsupervised feature learning. 2011.
|
| 267 |
+
|
| 268 |
+
Nicolas Papernot, Patrick D. McDaniel, and Ian J. Goodfellow. Transferability in machine learning: from phenomena to black-box attacks using adversarial samples. CoRR, abs/1605.07277, 2016.
|
| 269 |
+
|
| 270 |
+
Omid Poursaeed, Isay Katsman, Bicheng Gao, and Serge J. Belongie. Generative adversarial perturbations. In CVPR, 2018.
|
| 271 |
+
|
| 272 |
+
Olga Russakovsky, Jia Deng, Hao Su, Jonathan Krause, Sanjeev Satheesh, Sean Ma, Zhiheng Huang, Andrej Karpathy, Aditya Khosla, Michael S. Bernstein, Alexander C. Berg, and Fei-Fei Li. Imagenet large scale visual recognition challenge. IJCV, 2015.
|
| 273 |
+
|
| 274 |
+
Mahmood Sharif, Sruti Bhagavatula, Lujo Bauer, and Michael K. Reiter. Accessorize to a crime: Real and stealthy attacks on state-of-the-art face recognition. In SIGSAC, 2016.
|
| 275 |
+
|
| 276 |
+
Yucheng Shi, Siyu Wang, and Yahong Han. Curls & whey: Boosting black-box adversarial attacks. In CVPR, 2019.
|
| 277 |
+
|
| 278 |
+
Karen Simonyan and Andrew Zisserman. Very deep convolutional networks for large-scale image recognition. In Yoshua Bengio and Yann LeCun (eds.), ICLR, 2015.
|
| 279 |
+
|
| 280 |
+
Christian Szegedy, Wojciech Zaremba, Ilya Sutskever, Joan Bruna, Dumitru Erhan, Ian J. Goodfellow, and Rob Fergus. Intriguing properties of neural networks. In Yoshua Bengio and Yann LeCun (eds.), ICLR, 2014.
|
| 281 |
+
|
| 282 |
+
Christian Szegedy, Vincent Vanhoucke, Sergey Ioffe, Jonathon Shlens, and Zbigniew Wojna. Rethinking the inception architecture for computer vision. In CVPR, 2016.
|
| 283 |
+
|
| 284 |
+
Hugo Touvron, Alexandre Sablayrolles, Matthijs Douze, Matthieu Cord, and Herve J ´ egou. Grafit: ´ Learning fine-grained image representations with coarse labels. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pp. 874–884, 2021.
|
| 285 |
+
|
| 286 |
+
C. Wah, S. Branson, P. Welinder, P. Perona, and S. Belongie. The Caltech-UCSD Birds-200-2011 Dataset. Technical report, California Institute of Technology, 2011.
|
| 287 |
+
|
| 288 |
+
Xiaosen Wang, Xuanran He, Jingdong Wang, and Kun He. Admix: Enhancing the transferability of adversarial attacks. In ICCV, 2021.
|
| 289 |
+
|
| 290 |
+
Xiaosong Wang, Yifan Peng, Le Lu, Zhiyong Lu, Mohammadhadi Bagheri, and Ronald M. Summers. Chestx-ray8: Hospital-scale chest x-ray database and benchmarks on weakly-supervised classification and localization of common thorax diseases. In CVPR, 2017.
|
| 291 |
+
|
| 292 |
+
Dongxian Wu, Yisen Wang, Shu-Tao Xia, James Bailey, and Xingjun Ma. Skip connections matter: On the transferability of adversarial examples generated with resnets. In ICLR, 2020a.
|
| 293 |
+
|
| 294 |
+
Weibin Wu, Yuxin Su, Xixian Chen, Shenglin Zhao, Irwin King, Michael R. Lyu, and Yu-Wing Tai. Boosting the transferability of adversarial samples via attention. In CVPR, 2020b.
|
| 295 |
+
|
| 296 |
+
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 CVPR, 2019.
|
| 297 |
+
|
| 298 |
+
Kaidi Xu, Gaoyuan Zhang, Sijia Liu, Quanfu Fan, Mengshu Sun, Hongge Chen, Pin-Yu Chen, Yanzhi Wang, and Xue Lin. Adversarial t-shirt! evading person detectors in a physical world. In Andrea Vedaldi, Horst Bischof, Thomas Brox, and Jan-Michael Frahm (eds.), ECCV, 2020.
|
| 299 |
+
|
| 300 |
+
Jason Yosinski, Jeff Clune, Yoshua Bengio, and Hod Lipson. How transferable are features in deep neural networks? In Zoubin Ghahramani, Max Welling, Corinna Cortes, Neil D. Lawrence, and Kilian Q. Weinberger (eds.), NeurIPS, 2014.
|
| 301 |
+
|
| 302 |
+
Qilong Zhang, Chaoning Zhang, Chaoqun Li, Jingkuan Song, Lianli Gao, and Heng Tao Shen. Practical no-box adversarial attacks with training-free hybrid image transformation. CoRR, abs/2203.04607, 2022.
|
| 303 |
+
|
| 304 |
+
Zhengyu Zhao, Zhuoran Liu, and Martha A. Larson. On success and simplicity: A second look at transferable targeted attacks. CoRR, abs/2012.11207, 2020.
|
| 305 |
+
|
| 306 |
+
Wen Zhou, Xin Hou, Yongjun Chen, Mengyun Tang, Xiangqi Huang, Xiang Gan, and Yong Yang. Transferable adversarial perturbations. In Vittorio Ferrari, Martial Hebert, Cristian Sminchisescu, and Yair Weiss (eds.), ECCV, 2018.
|
| 307 |
+
|
| 308 |
+
# A APPENDIX
|
| 309 |
+
|
| 310 |
+

|
| 311 |
+
Figure 6: Benign images sampled from each domain. From the top to the bottom rows are the first category, the middle category and the last category of their label space, respectively.
|
| 312 |
+
|
| 313 |
+

|
| 314 |
+
Figure 7: The structure of the generator.
|
| 315 |
+
|
| 316 |
+

|
| 317 |
+
Figure 8: Adversarial examples crafted by CDA and our vanilla BIA $\epsilon = 1 0$ ). Both generator networks are trained against ImageNet pre-trained VGG-16 (Simonyan & Zisserman, 2015). Red highlighted labels represent misclassification.
|
| 318 |
+
|
| 319 |
+
# A.1 SELECT LAYER FOR ATTACKING
|
| 320 |
+
|
| 321 |
+
In this section, we analyze the impact of different intermediate layers of the substitute model on the transferability of resulting adversarial examples. The results are illustrated in Figure 10.
|
| 322 |
+
|
| 323 |
+
In general, training against the shallow and middle layers yields more cross-domain transferable but less cross-model transferable adversarial examples than against the deep layer. For example, if the substitute model is Res-152, disrupting shallow layer Conv2 3 is more effective for transferring towards coarse-grained domain, and perturbing middle layer Conv3 8 is more effective in reducing the average top-1 accuracy of fine-grained models. In contrast, attacking deep layers like Conv5 3 can yield more transferable adversarial examples in the source domain. This demonstrates that lowlevel features are more similar across domains and high-level features are more domain-specific.
|
| 324 |
+
|
| 325 |
+
# A.2 SELECT GAUSSIAN DISTRIBUTION FOR RANDOM NORMALIZATION
|
| 326 |
+
|
| 327 |
+
For $\mathcal { D A }$ module, it is parameter-free. Therefore, we only conduct the experiment to select an optimal distribution for $\mathcal { R N }$ module, i.e., the $\mu ^ { \prime }$ and $\sigma ^ { \prime }$ in Equation 4. Here we tune the mean of $\mu ^ { \prime }$ and $\sigma ^ { \prime }$ from 0.25 to 0.75 with a granularity of 0.25. For the standard deviation of them, we fix it to 0.08 so that the sampled $\mu ^ { \prime }$ and $\sigma ^ { \prime }$ can basically take values ranging from 0.0 to 1.0 (according to the three-sigma rule).
|
| 328 |
+
|
| 329 |
+

|
| 330 |
+
Figure 9: The average top-1 accuracy after attacking on coarse-grained (left), fine-grained (middle) and source (right) domains with different $\mu _ { m e a n } ^ { \prime }$ and $\sigma _ { m e a n } ^ { \prime }$ for $\mathcal { R N }$ .
|
| 331 |
+
|
| 332 |
+
The results are shown in Figure 9, where we craft adversarial examples via VGG-16 and report the average top-1 accuracy in both source and black-box domains. From the results, we observe that a bigger $\sigma _ { m e a n } ^ { \prime }$ can effectively improve the transferability. For example, if we increase $\sigma _ { m e a n } ^ { \prime }$ from 0.25 to 0.75, the top-1 accuracy on fine-grained models can be further decreased by $3 . 1 6 \%$ on average. Although the influence of $\mu _ { m e a n } ^ { \prime }$ is relatively moderate when $\sigma _ { m e a n } ^ { \prime } = 0 . 7 5$ , setting $\mu _ { m e a n } ^ { \prime }$ to 0.5 is usually better. Therefore, we set $\mu ^ { \prime } \sim \mathcal { N } ( 0 . 5 0 , 0 . 0 8 )$ and $\sigma ^ { \prime } \sim \mathcal { N } ( 0 . 7 5 , 0 . 0 8 )$ in our paper.
|
| 333 |
+
|
| 334 |
+
# A.3 DATA AUGMENTATION VS. RANDOM NORMALIZATION
|
| 335 |
+
|
| 336 |
+
Data augmentation (Krizhevsky et al., 2012; Simonyan & Zisserman, 2015) is a widely used strategy for improving the generalization of the model. Nonetheless, these label-preserving transformations are less effective for training a generator to craft more transferable adversarial examples.
|
| 337 |
+
|
| 338 |
+
In Figure 11, we report the results for our vanilla BIA, BIA with data augmentation $\left( \mathrm { B I A + A U G } \right)$ and BIA with $\mathcal { R N }$ $( \mathrm { B I A } { + } \mathcal { R N } )$ . As shown in Figure 11, $\mathrm { B I A + A U G }$ is less effective than our proposed $\mathbf { B } \mathbf { I A } { + } \mathcal { R N }$ and might even degrade the performance of our vanilla BIA. For example, when training against VGG-19, BIA gets an average top-1 accuracy of $5 8 . 7 1 \%$ on the fine-grained domain, yet $\mathrm { B I A + A U G }$ degrades it to $6 2 . 2 9 \%$ . In contrast, our proposed $\mathbf { B } \mathbf { I A } { + } \mathcal { R N }$ can significantly decrease the result to $4 7 . 7 8 \%$ . This is mainly because that the common data augmentation cannot effectively change the distribution of the training dataset, thus decreasing the generalization towards the black-box domain.
|
| 339 |
+
|
| 340 |
+
# A.4 INSIGHT INTO THE GENERATOR
|
| 341 |
+
|
| 342 |
+
Although many prior works (Poursaeed et al., 2018; Naseer et al., 2019) have leveraged the generator to craft adversarial examples, they hardly analyze the role of each block of the generator. This section will give an insight into the generator and understand how it processes an input. In Figure 12, we feed an image into the generator trained with the vanilla BIA (against Res-152) and visualize the output of each block. As we can observe, these blocks play different roles in crafting adversarial examples:
|
| 343 |
+
|
| 344 |
+

|
| 345 |
+
Figure 10: The average top-1 accuracy after attacking (the lower, the better) on coarse-grained, finegrained and source domains. Our generator $\mathcal { G } _ { \theta }$ is trained against different layers (from shallow to deep) of ImageNet pre-trained VGG-16, VGG-19, Res-152 and Dense-169, respectively.
|
| 346 |
+
|
| 347 |
+

|
| 348 |
+
Figure 11: The average top-1 accuracy after attacking on coarse-grained, fine-grained and source domains. Here we compare the results of vanilla BIA, BIA with data augmentation (AUG) and BIA with $\mathcal { R N }$ . Our generator $\mathcal { G } _ { \theta }$ is trained against ImageNet pre-trained VGG-16, VGG-19, Res-152 and Dense-169, respectively.
|
| 349 |
+
|
| 350 |
+
• Downsampling block: it mainly extracts discriminative features of the input image. As the size of the down-sampled images gets smaller, there is no significant noise overall.
|
| 351 |
+
• Residual block: Unlike the downsampling block, this block is responsible for adding noise and its behavior looks very similar to the iterative algorithm.
|
| 352 |
+
• Upsampling block: This block gradually reconstructs the adversarial example from abstract features.
|
| 353 |
+
|
| 354 |
+
Since the residual block mainly works as suppressing or reversing the features extracted by the downsampling module, the downsampling module has an essential impact on generating transferable adversarial examples.
|
| 355 |
+
|
| 356 |
+
To better understand the effectiveness of our proposed modules, here we investigate them from the perspective of the generator mechanism. Specifically, we apply crosschannel average pooling to the output of the downsampling block and calculate the difference map between vanilla BIA and our proposed variants. Without loss of generality, here we only show the definition of $D i f f ( \mathcal { R } \mathcal { N } v a r i a n t , ~ \mathbf { B } \mathbf { I } \mathbf { A } )$ , and $D i f f ( D A v a r i a n t$ , BIA) can be easily de
|
| 357 |
+
|
| 358 |
+

|
| 359 |
+
Figure 13: A benign image (label is “Boeing 747”) from FGVC Aircraft (Maji et al., 2013) and its corresponding adversarial examples and difference map.
|
| 360 |
+
|
| 361 |
+
duced. Specifically, we first apply cross-channel average pooling to the output of the downsampling
|
| 362 |
+
|
| 363 |
+

|
| 364 |
+
Figure 12: We apply cross-channel average pooling to visualize each block of our generator $\mathcal { G } _ { \theta ^ { * } }$
|
| 365 |
+
|
| 366 |
+
block:
|
| 367 |
+
|
| 368 |
+
$$
|
| 369 |
+
\begin{array} { r } { \mathcal { A } _ { R N } ^ { L } = \frac { \big | \sum _ { i = 0 } ^ { C } [ \mathcal { G } _ { R \mathcal { N } _ { \theta ^ { * } } } ^ { d } ( \pmb { x } ) ] _ { i } \big | } { C } , } \\ { \mathcal { A } _ { B I A } ^ { L } = \frac { \big | \sum _ { i = 0 } ^ { C } [ \mathcal { G } _ { B I A _ { \theta ^ { * } } } ^ { d } ( \pmb { x } ) ] _ { i } \big | } { C } , } \end{array}
|
| 370 |
+
$$
|
| 371 |
+
|
| 372 |
+
where $\mathcal { G } _ { \mathcal { R N } _ { \theta _ { \cdot } ^ { * } } } ^ { d }$ and $\mathcal { G } _ { B \mathcal { L } A _ { \theta ^ { * } } } ^ { d }$ denote the output of the downsampling block for $\mathcal { R N }$ variant and vanilla BIA, respectively. Then our difference map can be expressed by:
|
| 373 |
+
|
| 374 |
+
$$
|
| 375 |
+
D i f f ( { \mathcal { R } } { \mathcal { N } } v a r i a n t , B I A ) = { \left\{ \begin{array} { l l } { 1 , } & { A _ { R N } ^ { L } - A _ { B I A } ^ { L } > 0 , } \\ { 0 , } & { e l s e . } \end{array} \right. }
|
| 376 |
+
$$
|
| 377 |
+
|
| 378 |
+
From the result of Figure 13, we can observe that the generators derived from our proposed variants concentrate more on the body of the object (especially for $\mathcal { D A }$ variant) than that of vanilla BIA (which pays more attention to the background, i.e., the black region in the difference map). This demonstrates that our proposed $\mathcal { R N }$ and $\mathcal { D A }$ variants do narrow the domain gap, and thus be capable of yielding more transferable adversarial examples.
|
| 379 |
+
|
| 380 |
+
# A.5 DISCUSSION ON CHANGING SOURCE DOMAIN
|
| 381 |
+
|
| 382 |
+
Since all the experiments are only regarding from ImageNet domains to target domains, it is unclear how well the method will perform if the source dataset is different (especially when the source dataset is small). Therefore, in the following Table 5, we report the results for transferability from CUB-200-2011 to other domains. Generators are learned against CUB-200-2011 domain (the substitute model is DCL (backbone: Res-50) and training data is CUB-200-2011 testing data (5794 images)). For results of fine-grained domains, we average top-1 accuracy of backbone SENet-154 and SE-Res101. For the result of the ImageNet domain, we average top-1 accuracy of all models introduced in our manuscript. We can observe that our method consistently outperforms our main competitor CDA by a large margin. Besides, we also notice that transferring from CUB-200-2011 to CIFAR is very challenging (compared with our reported results in Table 2). Therefore, we highlight the necessity of using a large-scale dataset such as ImageNet to train the adversarial examples generator.
|
| 383 |
+
|
| 384 |
+
Table 5: Transferability comparisons of CDA and our methods. Here we report the top-1 accuracy after attacking (the lower, the better). The generator $\mathcal { G } _ { \theta }$ is trained in CUB-200-2011 domain and adversarial examples are within the perturbation budget of $\ell _ { \infty } \leq 1 0$ .
|
| 385 |
+
|
| 386 |
+
<table><tr><td>Attacks</td><td>CUB-200-2011</td><td>CIFAR-10</td><td>CIFAR-100</td><td>STL-10</td><td>SVHN</td><td>Stanford Cars</td><td>FGVC Aircraft</td><td>ImageNet</td></tr><tr><td>CDA</td><td>64.34</td><td>83.61</td><td>54.83</td><td>70.49</td><td>91.81</td><td>74.37</td><td>71.17</td><td>50.99</td></tr><tr><td>BIA</td><td>40.40</td><td>82.62</td><td>54.57</td><td>71.43</td><td>91.67</td><td>68.25</td><td>57.90</td><td>44.15</td></tr><tr><td>BIA+DA</td><td>29.55</td><td>82.94</td><td>54.15</td><td>71.70</td><td>87.28</td><td>54.65</td><td>55.15</td><td>37.15</td></tr><tr><td>BIA+RN</td><td>42.88</td><td>83.84</td><td>53.63</td><td>69.79</td><td>87.95</td><td>57.01</td><td>50.85</td><td>39.43</td></tr></table>
|
| 387 |
+
|
| 388 |
+
# A.6 DISCUSSION ON ENSEMBLE-MODEL ATTACKS
|
| 389 |
+
|
| 390 |
+
As demonstrated in prior works (Liu et al., 2017; Dong et al., 2018; Mopuri et al., 2018), attacking against an ensemble of models can yield more transferable adversarial examples. However, it is not clear whether the ensemble-model attack is also effective in our cross-domain attack scenario. To investigate this, we conduct an experiment in Table 6, which shows the results for training against VGG-16 and an ensemble of VGG-16, Vgg-19, Res-152 and Dense-169, respectively.
|
| 391 |
+
|
| 392 |
+
From the result, We can observe that ensemble-based training can also improve the transferability of adversarial examples towards black-box domains significantly.
|
| 393 |
+
|
| 394 |
+
Table 6: Transferability comparisons of singe-model (i.e. VGG-16) attacks and ensemble-model (i.e. an ensemble of VGG-16, VGG-19, Res-152 and Dense-169) attacks. Here we report the top-1 accuracy after attacking (the lower, the better) and adversarial examples are within the perturbation budget of $\ell _ { \infty } \leq 1 0$ .
|
| 395 |
+
|
| 396 |
+
<table><tr><td></td><td>CIFAR-10</td><td>CIFAR-100</td><td>STL-10</td><td>SVHN</td><td>CUB-200-2011 (SENet-154)</td><td>Stanford Cars (SENet-154)</td><td>FGVC Aircraft (SENet-154)</td></tr><tr><td>BIA</td><td>57.38</td><td>22.47</td><td>69.45</td><td>90.44</td><td>52.99</td><td>69.90</td><td>60.31</td></tr><tr><td>BIA (ensemble)</td><td>54.96</td><td>21.73</td><td>68.94</td><td>85.85</td><td>29.15</td><td>46.47</td><td>36.87</td></tr><tr><td>BIA+DA</td><td>55.16</td><td>21.71</td><td>70.00</td><td>91.76</td><td>40.27</td><td>59.48</td><td>47.91</td></tr><tr><td>BIA+DA (ensemble)</td><td>52.97</td><td>20.51</td><td>69.51</td><td>89.15</td><td>18.47</td><td>38.99</td><td>25.41</td></tr><tr><td>BIA+RN</td><td>52.81</td><td>20.82</td><td>67.55</td><td>88.03</td><td>46.15</td><td>62.64</td><td>52.54</td></tr><tr><td>BIA+RN (ensemble)</td><td>50.99</td><td>22.35</td><td>66.06</td><td>81.66</td><td>35.40</td><td>41.87</td><td>27.81</td></tr></table>
|
| 397 |
+
|
| 398 |
+
# A.7 DISCUSSION ON STANDARD DEVIATION ACROSS MULTIPLE RANDOM RUNS
|
| 399 |
+
|
| 400 |
+
To ensure the stability and credibility of the evaluations, experiments are repeated several times for our methods. In Table 7, we report the results for each random seed and standard deviation across these random runs.
|
| 401 |
+
|
| 402 |
+
Table 7: We show the results of 5 random seeds for methods. Here we report the top-1 accuracy after attacking (the lower, the better). The generator $\mathcal { G } _ { \theta }$ is trained against VGG-16 and adversarial examples are within the perturbation budget of $\ell _ { \infty } \leq 1 0$ .
|
| 403 |
+
|
| 404 |
+
<table><tr><td></td><td></td><td>CIFAR-10</td><td>CIFAR-100</td><td>STL-10</td><td>SVHN</td><td>CUB-200-2011 (SENet-154)</td><td>Stanford Cars (SENet-154)</td><td>FGVC Aircraft (SENet-154)</td><td>ImageNet (Res-152)</td></tr><tr><td rowspan="7">BIA</td><td>Paper report (Table2&3&4)</td><td>57.38</td><td>22.47</td><td>69.45</td><td>90.44</td><td>52.99</td><td>69.90</td><td>60.31</td><td>42.98</td></tr><tr><td rowspan="5">Random runs</td><td>56.75</td><td>21.86</td><td>69.61</td><td>90.48</td><td>52.47</td><td>68.13</td><td>61.45</td><td>44.04</td></tr><tr><td>57.31</td><td>22.32</td><td>69.83</td><td>90.35</td><td>52.04</td><td>69.48</td><td>57.37</td><td>41.67</td></tr><tr><td>57.13</td><td>22.82</td><td>70.06</td><td>90.01</td><td>53.27</td><td>69.74</td><td>58.54</td><td>41.02</td></tr><tr><td>57.03</td><td>22.38</td><td>70.05</td><td>90.43</td><td>53.04</td><td>71.91</td><td>62.02</td><td>43.09</td></tr><tr><td>57.36</td><td>22.50</td><td>69.55</td><td>89.78</td><td>51.48</td><td>68.15</td><td>58.36</td><td>42.00</td></tr><tr><td>Paper report</td><td>57.16 ± 0.24</td><td>22.39 ± 0.31</td><td>69.76±0.26</td><td>90.25±0.29</td><td>52.55 ± 0.69</td><td>69.55 ± 1.39</td><td>59.68 ± 1.86</td><td>42.47 ± 1.10</td></tr><tr><td rowspan="7">BIA+RN</td><td rowspan="5">(Table2&3&4)</td><td>52.81</td><td>20.82</td><td>67.55</td><td>88.03</td><td>46.15</td><td>62.64</td><td>52.54</td><td>31.80</td></tr><tr><td>52.56</td><td>21.12</td><td>66.75</td><td>88.63</td><td>44.84</td><td>63.18</td><td>51.55</td><td>30.71</td></tr><tr><td>52.63</td><td>21.43</td><td>67.24</td><td>87.93</td><td>48.38</td><td>63.4</td><td>55.09</td><td>33.76</td></tr><tr><td>52.29</td><td>21.42</td><td>67.3</td><td>88.64</td><td>45.41</td><td>63.2</td><td>52.99</td><td>31.8</td></tr><tr><td>52.60</td><td>21.68 21.66</td><td>67.21</td><td>87.69</td><td>48.88</td><td>63.98</td><td>52.69</td><td>29.56</td></tr><tr><td>53.41 52.70±0.42</td><td></td><td>67.00</td><td>88.40</td><td>49.01</td><td>64.16</td><td>55.96</td><td>30.96</td></tr><tr><td rowspan="7">BIA+DA</td><td>Paper report (Table2&3&4)</td><td></td><td>21.46 ± 0.23</td><td>67.10± 0.23 70.00</td><td>88.26 ± 0.43 91.76</td><td>47.30 ± 2.01 40.27</td><td>63.58 ± 0.46 59.48</td><td>53.66 ± 1.81</td><td>31.36 ± 1.56</td></tr><tr><td></td><td>55.16</td><td>21.71</td><td></td><td></td><td></td><td></td><td>47.91</td><td>36.43</td></tr><tr><td rowspan="5">Random runs</td><td>55.05</td><td>21.8</td><td>69.93</td><td>91.43</td><td>41.01</td><td>57.70</td><td>48.15</td><td>35.81</td></tr><tr><td>54.47</td><td>21.34</td><td>70.05</td><td>91.5</td><td>39.96</td><td>57.98</td><td>48.30</td><td>35.23</td></tr><tr><td>55.30</td><td>21.37</td><td>69.79</td><td>92.15</td><td>41.89</td><td>58.65</td><td>48.78</td><td>36.73</td></tr><tr><td>55.15</td><td>21.31</td><td>70.05</td><td>92.18</td><td>40.73</td><td>59.15</td><td>49.08</td><td>36.09</td></tr><tr><td>54.52</td><td>21.36</td><td>69.71</td><td>92.04</td><td>41.92</td><td>58.57</td><td>49.02</td><td>37.67</td></tr><tr><td>Paper report</td><td>Result 54.90 ± 0.38</td><td>21.44 ± 0.20</td><td>69.91 ± 0.15</td><td>91.86 ± 0.37</td><td>41.10 ± 0.83</td><td>58.41 ± 0.57</td><td>48.67 ± 0.42</td><td>36.31 ± 0.93</td></tr><tr><td rowspan="7">BIA+DA+RN</td><td>(Table 2&3&4)</td><td>50.29</td><td>20.03</td><td>67.51</td><td>90.4</td><td>40.46</td><td>57.26</td><td>37.01</td><td>24.91</td></tr><tr><td rowspan="5">Random runs</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>51.35</td><td>20.18 20.17</td><td>67.53</td><td>91.34</td><td>43.56 43.03</td><td>58.29 58.4</td><td>36.11 38.07</td><td>22.25 23.83</td></tr><tr><td>50.49 50.64</td><td>20.27</td><td>67.5 67.64</td><td>90.95 90.56</td><td>41.18</td><td>56.46</td><td>37.05</td><td>26.07</td></tr><tr><td>50.72</td><td>20.48</td><td>67.10</td><td>90.65</td><td>39.11</td><td>55.69</td><td>36.00</td><td>24.31</td></tr><tr><td>50.49</td><td>20.09</td><td>67.15</td><td>90.77</td><td>38.78</td><td>55.81</td><td>37.38</td><td>25.27</td></tr><tr><td>Result</td><td></td><td>50.74±0.36 20.24±0.15 67.38±0.24 90.85± 0.31</td><td></td><td></td><td>41.13 ± 2.19</td><td>56.93 ± 1.33</td><td>36.92 ± 0.87</td><td>24.35± 1.46</td></tr></table>
|
| 405 |
+
|
| 406 |
+
A.8 EFFECTS OF $\mathcal { R N }$ AND $\mathcal { D A }$ ON COARSE-GRAINED AND FINE-GRAINED TASKS
|
| 407 |
+
|
| 408 |
+
From Table 2 and Table 3, we observe that $\mathcal { R N }$ module is more effective than $\mathcal { D A }$ module for coarse-grained models, but not as well as $\mathcal { D A }$ module for fine-grained models. There may be two reasons:
|
| 409 |
+
|
| 410 |
+
On the one hand, the default normalization of coarse-grained classification models is different from ImageNet and fine-grained classification models. Specifically, coarse-grained classification models use mean $= [ 0 . 5 , 0 . 5 , 0 . 5 ]$ and $\mathrm { s t d } = [ 0 . 5 , 0 . 5 , 0 . 5 ]$ , but ImageNet and and fine-grained classification models use mean $= [ 0 . 4 8 5 , 0 . 4 5 6 , 0 . 4 0 6 ]$ and $\mathrm { s t d } = [ 0 . 2 2 9 , 0 . 2 2 4 , 0 . 2 2 5 ]$ ; Therefore, using $\mathcal { R N }$ module can narrow normalization gap between ImageNet and coarse-grained domains.
|
| 411 |
+
|
| 412 |
+
On the other hand, the resolution of coarse-grained domains such as CIFAR-10 and CIFAR-100 is much lower than the ImageNet domain and fine-grained domains. Therefore, the intermediate features of images from coarse-grained domains are more coarse than those from ImageNet and fine-grained domains, which may enlarge the gap between ImageNet and coarse-grained domains.
|
md/dev/Qy1D9JyMBg0/Qy1D9JyMBg0.md
ADDED
|
@@ -0,0 +1,291 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Multimodal Contrastive Learning with LIMoE: the Language-Image Mixture of Experts
|
| 2 |
+
|
| 3 |
+
Basil Mustafa∗, Carlos Riquelme\*, Joan Puigcerver\*, Rodolphe Jenatton, Neil Houlsby Google Brain {basilm, rikel, jpuigcerver, rjenatton, neilhoulsby}@google.com
|
| 4 |
+
|
| 5 |
+
# Abstract
|
| 6 |
+
|
| 7 |
+
Large sparsely-activated models have obtained excellent performance in multiple domains. However, such models are typically trained on a single modality at a time. We present the Language-Image MoE, LIMoE, a sparse mixture of experts model capable of multimodal learning. LIMoE accepts both images and text simultaneously, while being trained using a contrastive loss. MoEs are a natural fit for a multimodal backbone, since expert layers can learn an appropriate partitioning of modalities. However, new challenges arise; in particular, training stability and balanced expert utilization, for which we propose an entropy-based regularization scheme. Across multiple scales, we demonstrate remarkable performance improvement over dense models of equivalent computational cost. LIMoE-L/16 trained comparably to CLIP-L/14 achieves $7 8 . 6 \%$ zero-shot ImageNet accuracy (vs. $7 6 . 2 \%$ ), and when further scaled to H/14 (with additional data) it achieves $8 4 . 1 \%$ , comparable to state-of-the-art methods which use larger custom per-modality backbones and pre-training schemes. We analyse the quantitative and qualitative behavior of LIMoE, and demonstrate phenomena such as differing treatment of the modalities and the organic emergence of modality-specific experts.
|
| 8 |
+
|
| 9 |
+
# 1 Introduction
|
| 10 |
+
|
| 11 |
+
Sparsely activated mixture of expert (MoE) models have recently been used with great effect to scale up both vision [1, 2] and text models [3, 4]. The primary motivation for using MoEs is to scale model parameters while keeping compute costs under control. These models however have other benefits; for example, the sparsity protects against catastrophic forgetting in continual learning [5] and can improve performance for multitask learning [6] by offering a convenient inductive bias.
|
| 12 |
+
|
| 13 |
+
Given success in each individual domain, and the intuition that sparse models may better handle distinct tasks, we explore the application of MoEs to multimodal modelling. We take the first step in this direction, and study models that process both images and text. In particular, we train a single multimodal architecture that aligns image and text representations via contrastive learning [7].
|
| 14 |
+
|
| 15 |
+
When using a setup proposed in prior unimodal models [8, 1], we find that feeding multiple modalities to a single architecture leads to new failure modes unique to MoEs. To overcome these, we present a set of entropy based regularisers which stabilise training and improve performance. We call the resulting model LIMoE (Language-Image MoE).
|
| 16 |
+
|
| 17 |
+
We train a range of LIMoE models which significantly outperform compute-matched dense baselines. We scale this up to a large 5.6B parameter LIMoE-H/14, which applies 675M parameters per token. When evaluated zero-shot [7] on ImageNet-2012 [9] it achieves an accuracy of $8 4 . 1 \%$ , competitive with two-tower models that make use of modality-specific pre-training and feature extractors, and apply $3 { - } 4 \mathbf { x }$ more parameters per token.
|
| 18 |
+
|
| 19 |
+
In summary, our contributions are as follows.
|
| 20 |
+
|
| 21 |
+
• We propose LIMoE, the first large-scale multimodal mixture of experts models.
|
| 22 |
+
• We demonstrate in detail how prior approaches to regularising mixture of experts models fall short for multimodal learning, and propose a new entropy-based regularisation scheme to stabilise training.
|
| 23 |
+
We show that LIMoE generalises across architecture scales, with relative improvements in zero-shot ImageNet accuracy ranging from $7 \%$ to $13 \%$ over equivalent dense models. Scaled further, LIMoE-H/14 achieves $8 4 . 1 \%$ zeroshot ImageNet accuracy, comparable to SOTA contrastive models with per-modality backbones and pre-training.
|
| 24 |
+
• Lastly, we present ablations and analysis to understand the model’s behavior and our design decisions.
|
| 25 |
+
|
| 26 |
+

|
| 27 |
+
Figure 1: LIMoE, a sparsely activated multimodal model, processes both images and texts, utilising conditional computation to allocate computations in a modality-agnostic fashion.
|
| 28 |
+
|
| 29 |
+
# 2 Multimodal Mixture of Experts
|
| 30 |
+
|
| 31 |
+
Multimodal contrastive learning typically works with independent per-modality encodings [7, 10]. That is, separate models $f _ { m }$ are trained to provide a final representation for every input from the corresponding modality, $m$ . In the case of some image and text inputs, i and t, we have $\mathbf { z _ { i } } = f _ { \mathrm { i m a g e } } ( \mathbf { i } )$ and ${ \bf z } _ { \bf t } = f _ { \mathrm { t e x t } } ( { \bf t } )$ . For contrastive learning with images and text, this approach results in a “two-tower” architecture, one for each modality. We study a one-tower setup instead, where a single model is shared for all modalities, as shown in Figure 1. The one-tower design offers increased generality and scalability, and the potential for cross-modal and cross-task knowledge transfer. We next describe the LIMoE architecture and training routine.
|
| 32 |
+
|
| 33 |
+
# 2.1 Multimodal contrastive learning
|
| 34 |
+
|
| 35 |
+
Given $n$ pairs of images and text captions $\{ ( \mathbf { i } _ { j } , \mathbf { t } _ { j } ) \} _ { j = 1 } ^ { n }$ , the model learns representations $\mathcal { Z } _ { n } = \{ ( \mathbf { z _ { i } } _ { j } , \mathbf { z _ { t } } _ { j } ) \} _ { j = 1 } ^ { n }$ such that those corresponding to paired inputs are closer in feature space than those of unpaired inputs. The contrastive training objective [7, 11], with learned temperature $T$ , is:
|
| 36 |
+
|
| 37 |
+
$$
|
| 38 |
+
\mathcal { L } _ { j } ( \mathcal { Z } _ { n } ) = - \frac { 1 } { 2 } \log \frac { e ^ { \langle \mathbf { z _ { i _ { j } } } , \mathbf { z _ { t _ { j } } } \rangle / T } } { \sum _ { k = 1 } ^ { n } e ^ { \langle \mathbf { z _ { i _ { j } } } , \mathbf { z _ { t _ { k } } } \rangle / T } } - \frac { 1 } { 2 } \log \frac { e ^ { \langle \mathbf { z _ { i _ { j } } } , \mathbf { z _ { t _ { j } } } \rangle / T } } { \sum _ { k = 1 } ^ { n } e ^ { \langle \mathbf { z _ { i _ { k } } } , \mathbf { z _ { t _ { j } } } \rangle / T } } .
|
| 39 |
+
$$
|
| 40 |
+
|
| 41 |
+
# 2.2 The LIMoE Architecture
|
| 42 |
+
|
| 43 |
+
We use a single Transformer-based architecture for both image and text modalities. The model uses a linear layer per modality to project the intrinsic data dimension to the desired width: for text, a standard one-hot sentencepiece encoding and learned vocabulary [12], and for images, ViT-style patch-based embeddings [13]. Then all tokens are processed by a shared transformer encoder, which is not explicitly conditioned on modality. The token representations from the final layer are averagepooled to produce a single representation vector $\mathbf { z } _ { m }$ for each modality. To compute the training loss in (1), the paired image and text representations are then linearly projected using per-modality weight matrices $\mathbf { W } _ { m }$ ’s and ${ \mathcal { L } } _ { j }$ is applied to $\{ ( \mathbf { W } _ { \mathrm { i m a g e } } \mathbf { \Lambda } \mathbf { z _ { i _ { k } } } , \mathbf { W } _ { \mathrm { t e x t } } \mathbf { \Lambda } \mathbf { z _ { t _ { k } } } ) \} _ { k = 1 } ^ { \bar { n } }$ .
|
| 44 |
+
|
| 45 |
+
This one-tower setup can be implemented with a standard dense Transformer (and we train many such models as baselines). Next, we describe how we introduce MoEs to this setup for LIMoE.
|
| 46 |
+
|
| 47 |
+
Sparse MoE backbone: Sparse MoE layers are introduced following the architectural design of [1, 3]. The experts—parts of the model activated in an input-dependent fashion—are MLPs. LIMoE contains multiple MoE layers. In those layers, each token $\mathbf { x } \in \mathbb { R } ^ { D }$ is processed sparsely by $K$ out of $E$ available experts. To choose which $K$ , a lightweight router predicts the gating weights per token:
|
| 48 |
+
|
| 49 |
+

|
| 50 |
+
Figure 2: Token routing examples for Coco. Image examples of how patches are routed at the MoE layer placed in the 18-th encoder block –i.e. middle of the network– for the LIMoE-H/14 model.
|
| 51 |
+
|
| 52 |
+
$g ( \mathbf { x } ) = \mathsf { s o f t m a x } ( \mathbf { W } _ { g } \mathbf { x } ) \in \mathbb { R } ^ { E }$ with learned $\mathbf { W } _ { g } \in \mathbb { R } ^ { D \times E }$ . The outputs of the $K$ activated experts are linearly combined according to the gating weights: $\begin{array} { r } { \mathtt { M o E } ( \mathbf { x } ) = \sum _ { e = 1 } ^ { K } g ( \mathbf { x } ) _ { e } \cdot \mathtt { M L P } _ { e } ( \mathbf { x } ) . } \end{array}$ .
|
| 53 |
+
|
| 54 |
+
Note that, for computational efficiency and implementation constraints, experts have a fixed buffer capacity. The number of tokens each expert can process is fixed in advance, and typically assumes that tokens are roughly balanced across experts. If capacity is exceeded, some tokens are “dropped”; they are not processed by the expert, and the expert output is all zeros for those tokens. The rate at which tokens are successfully processed (that is, not dropped) is referred to as the “success rate”. It is an important indicator of healthy and balanced routing and often indicative of training stability.
|
| 55 |
+
|
| 56 |
+
We discovered that routing with tokens from multiple modalities introduces new failure modes; in the next sections we demonstrate this phenomenon, and describe our techniques to address it.
|
| 57 |
+
|
| 58 |
+
# 2.2.1 Challenges for multimodal MoEs
|
| 59 |
+
|
| 60 |
+
As mentioned, experts have a fixed buffer capacity. Without intervention, Top- $K$ MoEs tend to “collapse”, thus using only one expert. This causes most tokens to be dropped and leads to poor performance [14]. Prior works therefore use auxiliary losses to encourage balanced routing [1, 3, 8].
|
| 61 |
+
|
| 62 |
+
In multimodal settings, new challenges arise; one is modality misbalance. In realistic setups, there will likely be more of one data type than another. Accordingly, we do not assume or enforce balanced data across modalities, and our experiments have $3 - 1 7 \times$ more image tokens than text tokens.
|
| 63 |
+
|
| 64 |
+
Modality-specific experts tend to emerge naturally. In this imbalanced context, this leads to a scenario where all of the tokens from the minority modality get assigned to a single expert, which runs out of capacity. On a global level, routing still appears balanced: tokens from the majority modality are nicely distributed across experts, thereby satisfying modality-agnostic auxiliary losses. For example, in our standard B/16 setup, the router can optimize the importance loss [14] to within $0 . 5 \%$ of its minimum value by perfectly balancing image tokens but dropping all text tokens. This however leads to unstable training and unperforming models.
|
| 65 |
+
|
| 66 |
+
# 2.2.2 Auxiliary losses
|
| 67 |
+
|
| 68 |
+
We refer to auxiliary losses used in V-MoE [1] as the classic auxiliary losses. We find that they do not yield stable and performant multimodal MoE models. Therefore, we introduce two new losses: the local entropy loss and the global entropy loss, which are applied on a per-modality basis. We combine these losses with the classic losses; see Appendix B for a summary of all auxiliary losses.
|
| 69 |
+
|
| 70 |
+
Definition. In each MoE layer, for each modality $m$ , the router computes a gating matrix ${ \bf G } _ { m } \in { \bf \Psi }$ $\mathbb { R } ^ { n _ { m } \times E }$ . Each row of $\mathbf { G } _ { m }$ represents the probability distribution over $E$ experts for one of the $n _ { m }$ tokens of that modality in the batch. For a token $\mathbf { x }$ that corresponding row is $\ L _ { j _ { m } } ( \mathbf { e x p e r t s } | \mathbf { x } ) \in \mathbb { R } ^ { E }$ ;
|
| 71 |
+
|
| 72 |
+
this later dictates which experts process $\mathbf { x }$ . The local and global entropy losses are defined by:
|
| 73 |
+
|
| 74 |
+
$$
|
| 75 |
+
\Omega _ { \mathrm { l o c a l } } ( \mathbf { G } _ { m } ) : = \frac { 1 } { n _ { m } } \sum _ { i = 1 } ^ { n _ { m } } \mathcal { H } ( p _ { m } ( \boldsymbol { \mathrm { e x p e r t s } } | \mathbf { x } _ { i } ) ) \mathrm { a n d } \Omega _ { \mathrm { g l o b a l } } ( \mathbf { G } _ { m } ) : = - \mathcal { H } ( \tilde { p } _ { m } ( \boldsymbol { \mathrm { e x p e r t s } } ) ) ,
|
| 76 |
+
$$
|
| 77 |
+
|
| 78 |
+
where $\begin{array} { r } { \tilde { p } _ { m } ( \boldsymbol { \mathbf { e x p e r t s } } ) = \frac { 1 } { n _ { m } } \sum _ { i = 1 } ^ { n _ { m } } p _ { m } ( \boldsymbol { \mathbf { e x p e r t s } } | \boldsymbol { \mathbf { x } } _ { i } ) } \end{array}$ is the expert probability distribution averaged over the tokens and $\begin{array} { r } { \mathcal { H } ( p ) = - \sum _ { e = 1 } ^ { E } p _ { e } \log ( p _ { e } ) } \end{array}$ denotes the entropy. Note that $\widetilde { p } _ { m } ( \mathrm { e x p e r t s } ) \approx$ $p _ { m }$ (experts) since we approximate the true marginal from the tokens in the batch. We use the terminology local vs. global to emphasise the fact that $\Omega _ { \mathrm { l o c a l } }$ applies the entropy locally for each token while $\Omega _ { \mathrm { g l o b a l } }$ applies the entropy globally after having marginalized out the tokens.
|
| 79 |
+
|
| 80 |
+
Effects of the losses. Figure 3 shows why these losses are necessary. With the default losses, modality-specific experts naturally emerge, but the router often changes its preference. This results in unstable training and poor success rate, particularly for the text modality. The local entropy loss encourages concentrated router weights $( p _ { \mathrm { t e x t } } ( \mathbf { e x p e r t s } | \mathbf { x } _ { i } )$ ’s have low entropy), but at the expense of the diversity of the text experts: the same expert is used for all text tokens (the marginal $\tilde { p } _ { \mathrm { t e x t } } ( \mathbf { e x p e r t s } )$ also has low entropy), leading to dropping. In this setup, many layers have poor text success rates.
|
| 81 |
+
|
| 82 |
+
To address this, $\Omega _ { \mathrm { g l o b a l } }$ encourages maximization of the marginal entropy, thus pushing $\tilde { p } _ { \mathrm { t e x t } } ( \mathbf { e x p e r t s } )$ towards a more uniform expert distribution. The result is diverse expert usage, stable and confident routing, and high success rates. These are consequently the most performant models.
|
| 83 |
+
|
| 84 |
+
Intuitively, it is desirable for text tokens to use multiple experts, but not all of them. In order to allow flexibility, we threshold the global entropy loss as $\Omega _ { \mathrm { g l o b a l } } ^ { \tau } ( \mathbf { G } _ { m } ) = \operatorname* { m a x } \{ 0 , \tau + \Omega ^ { \mathrm { g l o b a l } } ( \mathbf { G } _ { m } ) \}$ , such that the model is encouraged to have a certain minimum entropy, but after exceeding that, the loss is not applied. This avoids distributional collapse but does not apply overly restrictive priors on the routing distribution, as there are many optimal solutions. This can be thought of as a “soft minimum” $S$ . With $\tau = \log ( S )$ , the model must use at least $S$ experts to minimize the loss (either a uniform distribution across $S$ experts -with entropy $\log ( S ) .$ -, or a non-uniform distribution using more than $S$ ). Figure 3b shows the latter occurs; the empirical effect of these thresholds is analysed in Section 4.1.
|
| 85 |
+
|
| 86 |
+

|
| 87 |
+
(b) Analysing routing behaviour of the auxiliary losses. First column: Average success rate of image routing in layers 1/7/11. Second column: Same, for text. Third column: In some experts of layer 5, what fraction of all text tokens go to those experts
|
| 88 |
+
Figure 3: What necessitates entropy losses? Classic refers to the standard formulation (importance $^ +$ load losses [1]). We add the local entropy loss to text tokens (middle row), followed by the global entropy loss (bottom row). Left: The “classic” setting is low-performing and unstable. Right: Analyzing the entropies shows us why: Without the local loss, the model is prone to unstable changes in expert preferences (C1), and routing success rates are low (A1, B1). The local loss fixes this but causes distributional collapse for one modality (C2), with all text tokens going to one expert (expert 11); this causes even poorer text success rates (B2). This is addressed by the global loss, which has stable expert allocations (C3) and consistently high success rates (A3, B3).
|
| 89 |
+
|
| 90 |
+
Connection with mutual information. The sum $\Omega _ { \mathrm { l o c a l } } ( { \bf G } _ { m } ) + \Omega _ { \mathrm { g l o b a l } } ( { \bf G } _ { m } )$ corresponds to the (negative) mutual information [15] between experts and tokens, conditioned on the modality $m$ , which we write $- \mathbf { M } \mathbf { I } _ { m } \big ( \mathbf { e x p e r t s ; x } \big )$ . For each modality taken separately, we are effectively encouraging the knowledge of the token representation to reduce the uncertainty about the experts selection. We also tried other variants of the losses which exploit this connection, such as the mutual information between the experts and modalities, $- \mathbf { M I } ( \mathbf { e x p e r t s } ; m )$ , obtained by first marginalizing the tokens.
|
| 91 |
+
|
| 92 |
+
# 2.2.3 Priority routing
|
| 93 |
+
|
| 94 |
+
With Top- $K$ routing, some token dropping is virtually inevitable. Batch Priority Routing (BPR) [1] actively decides which tokens to skip based on their routing weights. It assumes that tokens with a large routing weight are likely to be informative, and should be favored. BPR was mostly used at inference time in [1], allowing for smaller expert capacity buffers. In this setup, one must take care not to systematically favor one modality over the other, for instance, by determining which token to drop based on their rank in the batch, which are usually grouped according to the token modality. BPR provides an essential stabilisation effect during training (Figure 6); we show that it does not trivially rank one modality over another, and it cannot be replaced by other methods of re-ordering the batch. In the appendix we further show how routing priorities compare across text and images.
|
| 95 |
+
|
| 96 |
+
# 3 Experiments
|
| 97 |
+
|
| 98 |
+
We study LIMoE in the context of multimodal contrastive learning. We first perform a controlled comparison of LIMoE to an equivalent “standard” dense Transformer, across a range of model sizes. We then show that when scaled up LIMoE can reach a high level of performance. Finally, we ablate the various design decisions leading to LIMoE in Section 4.
|
| 99 |
+
|
| 100 |
+
Training data. By default, all models are trained on paired image-text data used in [16], consisting of 3.6B images and alt-texts scraped from the web. For large LIMoE-H/14 experiment, we also co-train with JFT-4B [17]. We construct artificial text captions from JFT by comma-delimited concatenation of the class names [18]. Appendix A contains full details of our training setup.
|
| 101 |
+
|
| 102 |
+
Evaluation. Our main evaluation is “zero-shot”: the model uses its text representations of the classes to make predictions on a new task without extra training data [19, 7]. We focus on image classification accuracy on ImageNet [9] and cross-modal retrieval on MS-COCO [20], following the protocol in [16]. We also evaluate LIMoE’s image representations via a linear adaptation protocol [13], and report 10-shot accuracy on ImageNet accuracy accordingly. Where ranges are given, they report $9 5 \%$ confidence intervals across three trials.
|
| 103 |
+
|
| 104 |
+
# 3.1 Controlled study across scales
|
| 105 |
+
|
| 106 |
+
We train a range of LIMoE models at batch size 16k for 781k steps. This matches the number of training examples used for CLIP [7]. Due to use of different training data and additional tricks, a direct comparison is difficult; we therefore train dense one-tower models as baselines. All models activate $k = 1$ experts per token, similar to Switch Transformer [8].
|
| 107 |
+
|
| 108 |
+
Figure 4 shows the performance of each model (dense and sparse) against forward-pass FLOPs (for step times and further discussion on compute costs, see Appendix D.2.). The cost-performance Pareto frontier for LIMoE dominates the dense models by a wide margin, indicating that LIMoE offers strong improvements across all scales from S/32 , up to L/16. The effect is particularly large on zero-shot and 10-shot ImageNet classification, with absolute performance improvements of $1 0 . 1 \%$ and $12 . 2 \%$ on average. For text-to-image retrieval on COCO, LIMoE offers a strong boost at small scales, while at larger scales the gains are more modest but still significant.
|
| 109 |
+
|
| 110 |
+
# 3.2 Scaling up LIMoE
|
| 111 |
+
|
| 112 |
+
We increase the architecture size, training duration, and data size to assess the performance of LIMoE in the large-scale regime. In particular, we train a 32-layer LIMoE-H/14 with 12 expert layers; these are non-uniformly distributed, with 32 experts per layer, and $K = 1$ activated per token. It was trained at a batch size of 21k, introducing $2 5 \%$ JFT-4B images [17] into each batch (with class names as texts). We average checkpoints towards the end of training [21]; refer to Appendix A.3 for details.
|
| 113 |
+
|
| 114 |
+

|
| 115 |
+
Figure 4: LIMoE scales well to large models, with consistent performance improvements.
|
| 116 |
+
|
| 117 |
+
The model contains 5.6B parameters in total, but only applies 675M parameters per token. All routers combined account for less than $0 . 5 \mathbf { M }$ parameters. Table 1 shows its performance alongside current state-of-the-art contrastive models. LIMoE achieves $8 4 . 1 \%$ zero-shot ImageNet classification accuracy with a comparably modest architecture size and training counts. LIMoE is fully trained from scratch, without any pre-trained components, and is the first competitive model with a shared backbone.
|
| 118 |
+
|
| 119 |
+
In light of its modality agnostic approach, this result is surprisingly strong. Large models handling dozens of distinct tasks are increasingly popular [22], but do not yet approach the state-of-the-art in these tasks. We believe the ability to build a generalist model with specialist components, which can decide how different modalities or tasks should interact, will be key to creating truly multimodal multitask models which excel at everything they do. LIMoE is a promising first step in that direction.
|
| 120 |
+
|
| 121 |
+
Table 1: Comparing state of the art zero-shot classification models. At a relatively modest scale, LIMoE-H/14 is comparable with the best two-tower models, and it is the first performant one-tower model at this scale. T- $\mathbf { x }$ refers to a Transformer [23] with the equivalent parameters of ViT- $\mathbf { x }$ [13].
|
| 122 |
+
|
| 123 |
+
<table><tr><td>Key: Pretrained</td><td colspan="3">Examplesseen duringpretraining</td><td>UsesFixRes[24]</td><td>3Other non-contrastivetrainingobjective</td><td></td><td></td><td></td><td></td></tr><tr><td></td><td colspan="2">Architecture</td><td>Batch</td><td>Examples seen</td><td>Parameters</td><td colspan="4">ImageNet top-1 % Test</td></tr><tr><td></td><td>Image</td><td>Text</td><td>size</td><td></td><td>per token</td><td></td><td>V2</td><td>R</td><td></td></tr><tr><td>COCA [25]</td><td>ViT-g</td><td>T-g</td><td>65k</td><td>32.8B</td><td>1.1B</td><td>86.3</td><td>80.7</td><td>96.5</td><td>90.2</td></tr><tr><td>BASIC[18]</td><td>CoAtNet-7*</td><td>T-H*</td><td>65k</td><td>19.7BPT +32.8B</td><td>1.5B</td><td>85.7</td><td>80.6</td><td>95.7</td><td>85.6</td></tr><tr><td>LIT[16]</td><td>ViT-g*</td><td>T-g</td><td>32k</td><td>25.8BPT + 18.2B</td><td>1.1B</td><td>84.5</td><td>78.7</td><td>93.9</td><td>79.4</td></tr><tr><td>ALIGN [10]</td><td>EffNet-L2</td><td>T-L*</td><td>16k</td><td>19.8B</td><td>~410M</td><td>76.4</td><td>70.1</td><td>92.2</td><td>75.8</td></tr><tr><td>CLIP [7]</td><td>ViT-L/14†</td><td>T-B</td><td>32k</td><td>12.8B</td><td>~ 200M</td><td>76.2</td><td>70.1</td><td>88.9</td><td>77.2</td></tr><tr><td>LIMoE</td><td colspan="2">H/14</td><td>21k</td><td>23.3B</td><td>675M</td><td>84.1</td><td>77.7</td><td>94.9</td><td>78.7</td></tr></table>
|
| 124 |
+
|
| 125 |
+
# 4 Ablations
|
| 126 |
+
|
| 127 |
+
We use a smaller setup to study various aspects of LIMoE. We train B/16 models at batch size 8096 for 100,000 steps (see Appendix A.2 for further details). Table 2 shows the average over three trials of this setting alongside dense one-tower and two-tower baselines. LIMoE greatly outperforms both dense models on ImageNet 0- and 10-shot, while confidence intervals overlap for retrieval with two towers. The two-tower model is twice as large and expensive, and still falls behind the sparse one.
|
| 128 |
+
|
| 129 |
+
# 4.1 Routing and auxiliary losses
|
| 130 |
+
|
| 131 |
+
Choice of auxiliary losses. With the introduction of the entropy based losses in addition to classic ones, there are 7 possible auxiliary losses. We aimed to find the simplest combination of these which obtains good performance. To study this, we performed a large sweep of auxiliary losses: for $N \in [ 2 , \ldots , 5 ]$ , we considered all $\binom { 7 } { N }$ possible loss combinations. Table 3 shows, for each loss, the highest performing model with and without that loss. Some conclusions stand out: Both entropy losses are important for text, but for images, the global loss is not impactful and the local loss is harmful. The final combination of losses was chosen based on validation accuracy alongside qualitative observations around training stability and routing success rate.
|
| 132 |
+
|
| 133 |
+
Table 2: Baselines for ablations: B/16 with batch size 8096 trained for for 100,000 steps. 0shot and 10shot columns show accuracy $( \% )$ , t2i and i2t show recall $@ 1$ $( \% )$ .
|
| 134 |
+
|
| 135 |
+
<table><tr><td>Model</td><td>i1k Oshot</td><td>i1k 10shot</td><td>coco t2i</td><td></td><td>coco i2t</td></tr><tr><td>dense one-tower</td><td>49.8 50.4 49.2</td><td>43.8 44.3 43.3</td><td>23.7 24</td><td>23.4</td><td>36.7 38.9 34.6</td></tr><tr><td>dense two-tower</td><td>54.7 55.2 54.1</td><td>47.1 47.6 46.7</td><td>26.6 27.1 26.2</td><td></td><td>41.3 42.0 40.6</td></tr><tr><td>LIMoE</td><td>B71 56.9</td><td>58 50.5</td><td>25.6</td><td>28</td><td>39.7 42.2 37.1</td></tr></table>
|
| 136 |
+
|
| 137 |
+
Table 3: Across 121 combinations, each row shows the best accuracy $( \% )$ of all combinations that included the auxiliary loss $( \checkmark )$ vs. those that did not $( { \pmb x } )$ . Bold auxiliary losses indicate they are in LIMoE. Validation accuracy is the average contrastive accuracy in a minibatch of size 1024.
|
| 138 |
+
|
| 139 |
+
<table><tr><td></td><td colspan="2">Validation</td><td colspan="2">Oshot</td><td colspan="2">10shot</td></tr><tr><td>Auxiliary loss</td><td>X</td><td>√</td><td>X</td><td>√</td><td>X</td><td>√</td></tr><tr><td>Importance</td><td>70.5</td><td>70.6</td><td>55.4</td><td>56.2</td><td>51.1</td><td>51.3</td></tr><tr><td>Load</td><td>70.3</td><td>70.6</td><td>56.2</td><td>55.7</td><td>51.3</td><td>51.1</td></tr><tr><td>Z-Loss</td><td>70.3</td><td>70.6</td><td>55.8</td><td>56.2</td><td>50.5</td><td>51.3</td></tr><tr><td>Global Ent Image</td><td>70.6</td><td>70.5</td><td>56.0</td><td>56.2</td><td>50.8</td><td>51.3</td></tr><tr><td>Global Ent Text</td><td>69.1</td><td>70.6</td><td>54.3</td><td>56.2</td><td>51.1</td><td>51.3</td></tr><tr><td>Local Ent Image</td><td>70.6</td><td>68.7</td><td>56.2</td><td>53.5</td><td>51.3</td><td>47.5</td></tr><tr><td>Local Ent Text</td><td>67.2</td><td>70.6</td><td>53.3</td><td>56.2</td><td>47.5</td><td>51.3</td></tr></table>
|
| 140 |
+
|
| 141 |
+
Threshold for global entropy losses. In Section 2.2.2, we introduced a threshold $\tau$ to encourage balanced expert distributions without forcing all modalities to use all experts. To understand the importance of this threshold, we sweep over it for both the image and text global entropy losses. Appendix B.2 contains a full analysis; the most important conclusions are:
|
| 142 |
+
|
| 143 |
+
• $\tau _ { \mathrm { i m a g e } }$ did not affect the number of experts used for images, as global entropy was always high. Aside from these threshold experiments with very high $\tau _ { \mathrm { i m a g e } }$ , this loss is usually inactive. It was used in our main experiments, but can likely be removed in future work. • The threshold $\tau _ { \mathrm { t e x t } }$ behaved exactly as a soft minimum for text experts: Sweeping $\tau _ { \mathrm { t e x t } }$ , we typically observed approximately $S = e ^ { \tau _ { \mathrm { t e x t } } }$ text experts. • Performance is robust to different values of $\tau _ { \mathrm { t e x t } }$ , provided it is not too low. A low $\tau _ { \mathrm { t e x t } }$ can be useful to limit the number of text experts, for later pruning, see Appendix E.4.
|
| 144 |
+
|
| 145 |
+
Mutual-information auxiliary loss. In Section 2.2.2, we discussed an alternative loss, namely −MI(experts; m), based on the mutual information between experts and modalities. While it has the advantage of merging the local and global entropy losses for both the text and image modalities into a single term, without threshold parameters, it leads to slightly worse results: in a comparable setup, it had $1 . 5 \%$ and $0 . 1 \%$ worse zero-shot and 10-shot performance compared to Table 2.
|
| 146 |
+
|
| 147 |
+
The effect of modality balancing. Our models use a text sequence length of 16, but image sequence lengths from 49 to 400 (for these ablations, 196).
|
| 148 |
+
|
| 149 |
+
Our ablations reveal that the entropy losses are most important when applied to the text tokens. This leads to a hypothesis that these are only necessary or useful in the imbalanced case. To test this, we vary the modality balance of LIMoE-B/16 by varying the patch size; this enables us to control the number of image tokens, and hence image:text balance, without changing the information content in the data. Figure 5 shows the results. First, we observe that, with entropy routing, a longer image sequence length is always better. This shows that entropy routing can effectively handle highly imbalanced setups, and mirrors the observation that for classical Vision Transformers: a longer sequence is better. Importantly, entropy routing is always far superior to the classical setup with growing gaps, even when the modalities are balanced 1:1 ( $L _ { \mathrm { i m g } } = 1 6 $ ). This experiment also confirms the robustness of entropy routing to different setups.
|
| 150 |
+
|
| 151 |
+

|
| 152 |
+
Figure 5: Entropy losses are not just addressing a modality imbalance. With different image:text balancing, including completely balanced, the entropy losses substantially improves over the classic setting.
|
| 153 |
+
|
| 154 |
+
Batch priority routing as a training stabilizer. Figure 6 shows the effect of BPR during training. BPR not only ameliorates against token dropping, but also improves training stability. Models with no dispatch order intervention (first-in-first-out) perform extremely poorly, whether we route images first or text first. These routers have low success rate. Randomly shuffling tokens (i.e. deciding which tokens to drop at random when an expert becomes full) partially ameliorates this, but its performance is still much worse than that of models trained with BPR. We further analyse BPR in Appendix F.5 and show that it does not simply rank one modality above another.
|
| 155 |
+
|
| 156 |
+

|
| 157 |
+
Figure 6: BPR stabilizies training and enables performant models; the first figure shows different performance metrics. The last two show success rates for the MoE router in Layer 9.
|
| 158 |
+
|
| 159 |
+
# 4.2 Other ablations
|
| 160 |
+
|
| 161 |
+
We summarize our other ablations here due to space constraints; details can be found in Appendix E.
|
| 162 |
+
|
| 163 |
+
Router structure (Appendix E.3). Our router is modality agnostic; we experiment with per-modality routers, and separate pools of per-modality experts. We find they all perform comparably to our generic, modality agnostic setup, but that separate pools of experts by design is more stable and does not require auxiliary losses for regularisation—while harder to scale to many modalities and tasks.
|
| 164 |
+
|
| 165 |
+
Increasing selected experts per token $K$ ( Appendix E.1). We propose modifications to BPR and the local auxiliary loss to generalise to $K > 1$ ; by doing so we can steadily increase performance by increasing $K$ , e.g. from $5 5 . 5 \%$ zero-shot accuracy with $K = 1$ to $6 1 . 0 \%$ with $K = 5$ .
|
| 166 |
+
|
| 167 |
+
Total number experts (Appendix E.2). We show that increasing the pool of available experts at fixed $K$ improves performance (unlike what was observed for vision-only tasks [1]).
|
| 168 |
+
|
| 169 |
+
Expert pruning (Appendix E.4). We show using simple heuristics we can prune down to modalityspecific experts for unimodal forward passes, thus avoiding expert collapse under unimodal batches.
|
| 170 |
+
|
| 171 |
+
Training on public data (Appendix E.6) The majority of LIMoE models were trained on proprietary data [16]. We show that LIMoE works similarly well on publically available data, retaining performance improvements against a comparable dense model.
|
| 172 |
+
|
| 173 |
+
# 5 Model Analysis
|
| 174 |
+
|
| 175 |
+
In this section, we explore some of the internal workings of LIMoE. We use simple B/32 and B/16 models with 8 experts, and the large H/14 with 32. See Appendix F for further details and experiments.
|
| 176 |
+
|
| 177 |
+
Multimodal experts arise (Appendix F.1). Aside from encouraging diversity, we do not explicitly enforce experts to specialize. Nonetheless, we observe the emergence of both modality-specific experts, and multimodal experts which process both images and texts (per-expert distributions in F.1).
|
| 178 |
+
|
| 179 |
+
Qualitative analysis (Appendix F.2). We analyse some example data and show a clear emergence of semantically meaningful experts. With images for instance, some experts specialize on lower level features (colours, lines) while others on more complex features (faces and text), see Figure 2.
|
| 180 |
+
|
| 181 |
+
BPR ranking (Appendix F.5). The local loss encourages high max-routing weights for text, and BPR ranks according to this. We show however that this does not mean text is always prioritised first: Especially in later layers, the model often prioritises important image patches over text.
|
| 182 |
+
|
| 183 |
+
# 6 Related work
|
| 184 |
+
|
| 185 |
+
Unimodal, task-specific neural networks have long been researched, with increasing convergence towards Transformer-based architectures [23, 26] for both NLP [27] and Computer Vision [13, 28, 29]. Multimodal models aim to process multiple types of data using a single neural network.
|
| 186 |
+
|
| 187 |
+
Many approaches “fuse” modalities [30, 31, 32, 33] to tackle inherently multimodal tasks. LIMoE is more similar to approaches which do not do that, and still operate as unimodal feature extractors. Some co-train on distinct tasks [34, 35, 36, 22] without aligning or fusing representations—effectively sharing weights across tasks—whereas others include both unimodal aspects and fused multimodal aspects for functionality in both contexts [37].
|
| 188 |
+
|
| 189 |
+
We build on deep Sparse Mixture of Experts models, which have been studied independently in Computer Vision [1, 2] and NLP [14, 3, 8], typically in the context of transfer learning. These models use a learned gating mechanism whereby only a subset of $K$ experts out of $E \gg K$ are activated for a given input. Many works aim to improve the gating mechanism itself, by making it differentiable [38], reformulating as a linear assignment task [39] or even swapping it out for a simple hashing algorithm [40]. MoE models have also been studied for multitask learning [38], with per-task routers [6] but a shared pool of experts. To our knowledge, sparse models have not been explored for multimodal learning.
|
| 190 |
+
|
| 191 |
+
A large body of research exists on contrastive learning, usually in self-supervised [41] but also in supervised regimes [42]. Multimodal contrastive learning trains on aligned data from multiple modalities. Originally studied for medical images and reports [11], it was recently scaled to noisy web data [7, 10], where strong image-text alignments enabled performant image classification and cross-modal image-text retrieval without finetuning on downstream data. Follow up works improved upon this significantly by scaling up and using pretrained models [18, 16] and multitask training with generative modelling [25] or other vision tasks [43]. These works use unimodal models which separately process image and text data; we are not aware of previous research using a single model to process both images and texts for contrastive learning, neither with dense nor with sparse models.
|
| 192 |
+
|
| 193 |
+
# 7 Conclusions and Future Work
|
| 194 |
+
|
| 195 |
+
We have presented LIMoE, the first multimodal sparse mixture of experts model. We uncovered new failure modes specific to this setup and proposed entropy based auxiliary losses which stabilises training and results in highly performant models. It works across many model scales, with average improvements over FLOP-matched dense baselines of $+ 1 0 . 2 \%$ zero-shot accuracy. When scaled to a large H/14 model, we achieve $8 4 . 1 \%$ accuracy, competitive with current SOTA approaches.
|
| 196 |
+
|
| 197 |
+
Societal impact and limitations: The potential harms of large scale models [44], contrastive models [7] and web-scale multimodal data [45] also carry over here, as LIMoE does not explicitly address them. On the other hand, it has been shown that pruning models tends to cause low-resource groups to be forgotten [46], causing performance to disproportionally drop for some subgroups. This would be worth considering for our expert-pruning experiments, but by analogue, the ability to scale models with experts that can specialize deeply may result in better performance on underrepresented groups.
|
| 198 |
+
|
| 199 |
+
Environmentally speaking, training large models is costly, though efforts are made to use efficient datacenters and offset emitted $\mathrm { C O } _ { 2 }$ . Prior works however show that most environmental impact occurs during model inference, and that MoEs are significantly more efficient in that regard [47]; LIMoE is naturally a good candidate for efficient, large-scale multimodal foundation models.
|
| 200 |
+
|
| 201 |
+
Future work: There are many interesting directions from here. The routing interference with multiple modalities still is not fully understood. In general, conclusions from applications of MoEs to NLP have not carried over perfectly to Vision, and vice-versa, and here we see again different behaviour between images and text. Naturally, extensions to more modalities should be explored; even with only two we see fascinating interactions between different data types and the routing algorithms, and that will only get more difficult, and interesting, with more modalities.
|
| 202 |
+
|
| 203 |
+
There are always more modalities to learn, and larger models to build: sparse models provide a very natural way to scale up while juggling very different tasks and data, and we look forward to seeing more research in this area.
|
| 204 |
+
|
| 205 |
+
# 8 Acknowledgements
|
| 206 |
+
|
| 207 |
+
We first thank Andreas Steiner, Xiao Wang and Xiaohua Zhai, who led early explorations into dense single-tower models for contrastive multimodal learning, and also were instrumental in providing data access. We also thank Andreas Steiner, and Douglas Eck, for early feedback on the paper. We thank André Susano Pinto, Maxim Neumann, Barret Zoph, Liam Fedus, Wei Han and Josip Djolonga for useful discussions, and Erica Moreira and Victor Gomes for help scaling up to LIMoE-H/14.
|
| 208 |
+
|
| 209 |
+
References
|
| 210 |
+
[1] Carlos Riquelme, Joan Puigcerver, Basil Mustafa, Maxim Neumann, Rodolphe Jenatton, André Susano Pinto, Daniel Keysers, and Neil Houlsby. Scaling vision with sparse mixture of experts. In Advances in Neural Information Processing Systems. Curran Associates, Inc., 2021.
|
| 211 |
+
[2] Yuxuan Lou, Fuzhao Xue, Zangwei Zheng, and Yang You. Cross-token modeling with conditional computation, 2022.
|
| 212 |
+
[3] Dmitry Lepikhin, HyoukJoong Lee, Yuanzhong Xu, Dehao Chen, Orhan Firat, Yanping Huang, Maxim Krikun, Noam Shazeer, and Zhifeng Chen. Gshard: Scaling giant models with conditional computation and automatic sharding. In 9th International Conference on Learning Representations, ICLR 2021, Virtual Event, Austria, May 3-7, 2021. OpenReview.net, 2021.
|
| 213 |
+
[4] Barret Zoph, Irwan Bello, Sameer Kumar, Nan Du, Yanping Huang, Jeff Dean, Noam Shazeer, and William Fedus. St-moe: Designing stable and transferable sparse expert models, 2022.
|
| 214 |
+
[5] Mark Collier, Efi Kokiopoulou, Andrea Gesmundo, and Jesse Berent. Routing networks with co-training for continual learning, 2020.
|
| 215 |
+
[6] Jiaqi Ma, Zhe Zhao, Xinyang Yi, Jilin Chen, Lichan Hong, and Ed H. Chi. Modeling task relationships in multi-task learning with multi-gate mixture-of-experts. In Proceedings of the 24th ACM SIGKDD International Conference on Knowledge Discovery & Data Mining, KDD 2018, London, UK, August 19-23, 2018. ACM, 2018.
|
| 216 |
+
[7] 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, Proceedings of Machine Learning Research. PMLR, 2021.
|
| 217 |
+
[8] William Fedus, Barret Zoph, and Noam Shazeer. Switch transformers: Scaling to trillion parameter models with simple and efficient sparsity. JMLR, 23(120), 2022.
|
| 218 |
+
[9] 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 Computer Society Conference on Computer Vision and Pattern Recognition (CVPR 2009), 20-25 June 2009, Miami, Florida, USA. IEEE Computer Society, 2009.
|
| 219 |
+
[10] Chao Jia, Yinfei Yang, Ye Xia, Yi-Ting Chen, Zarana Parekh, Hieu Pham, Quoc V. Le, Yun-Hsuan Sung, Zhen Li, and Tom Duerig. Scaling up visual and vision-language representation learning with noisy text supervision. In Proceedings of the 38th International Conference on Machine Learning, ICML 2021, 18-24 July 2021, Virtual Event, Proceedings of Machine Learning Research. PMLR, 2021.
|
| 220 |
+
[11] Yuhao Zhang, Hang Jiang, Yasuhide Miura, Christopher D. Manning, and Curtis P. Langlotz. Contrastive learning of medical visual representations from paired images and text. CoRR, 2020.
|
| 221 |
+
[12] Taku Kudo and John Richardson. Sentencepiece: A simple and language independent subword tokenizer and detokenizer for neural text processing. In Proceedings of the 2018 Conference on Empirical Methods in Natural Language Processing, EMNLP 2018: System Demonstrations, Brussels, Belgium, October 31 - November 4, 2018. Association for Computational Linguistics, 2018.
|
| 222 |
+
[13] 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.
|
| 223 |
+
[14] Noam Shazeer, Azalia Mirhoseini, Krzysztof Maziarz, Andy Davis, Quoc Le, Geoffrey Hinton, and Jeff Dean. Outrageously large neural networks: The sparsely-gated mixture-of-experts layer. In 5th International Conference on Learning Representations, ICLR 2017, 2017.
|
| 224 |
+
[15] Thomas M Cover. Elements of information theory. John Wiley & Sons, 1999.
|
| 225 |
+
[16] Xiaohua Zhai, Xiao Wang, Basil Mustafa, Andreas Steiner, Daniel Keysers, Alexander Kolesnikov, and Lucas Beyer. Lit: Zero-shot transfer with locked-image text tuning. CVPR, 2021.
|
| 226 |
+
[17] Xiaohua Zhai, Alexander Kolesnikov, Neil Houlsby, and Lucas Beyer. Scaling vision transformers. CVPR, 2021.
|
| 227 |
+
[18] Hieu Pham, Zihang Dai, Golnaz Ghiasi, Kenji Kawaguchi, Hanxiao Liu, Adams Wei Yu, Jiahui Yu, Yi-Ting Chen, Minh-Thang Luong, Yonghui Wu, Mingxing Tan, and Quoc V. Le. Combined scaling for open-vocabulary image classification, 2022.
|
| 228 |
+
|
| 229 |
+
[19] Richard Socher, Milind Ganjoo, Christopher D Manning, and Andrew Ng. Zero-shot learning through cross-modal transfer. In Advances in Neural Information Processing Systems. Curran Associates, Inc., 2013.
|
| 230 |
+
|
| 231 |
+
[20] Tsung-Yi Lin, Michael Maire, Serge J. Belongie, James Hays, Pietro Perona, Deva Ramanan, Piotr Doll’ar, 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, Lecture Notes in Computer Science. Springer, 2014.
|
| 232 |
+
|
| 233 |
+
[21] Mitchell Wortsman, Gabriel Ilharco, Samir Yitzhak Gadre, Rebecca Roelofs, Raphael Gontijo Lopes, Ari S. Morcos, Hongseok Namkoong, Ali Farhadi, Yair Carmon, Simon Kornblith, and Ludwig Schmidt. Model soups: averaging weights of multiple fine-tuned models improves accuracy without increasing inference time. CoRR, 2022.
|
| 234 |
+
|
| 235 |
+
[22] 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.
|
| 236 |
+
|
| 237 |
+
[23] 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. Curran Associates, Inc., 2017.
|
| 238 |
+
|
| 239 |
+
[24] Hugo Touvron, Andrea Vedaldi, Matthijs Douze, and Herv’e J’egou. Fixing the train-test resolution discrepancy. In Advances in Neural Information Processing Systems (NeurIPS), 2019.
|
| 240 |
+
|
| 241 |
+
[25] Jiahui Yu, Zirui Wang, Vijay Vasudevan, Legg Yeung, Mojtaba Seyedhosseini, and Yonghui Wu. Coca: Contrastive captioners are image-text foundation models, 2022.
|
| 242 |
+
|
| 243 |
+
[26] Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. BERT: Pre-training of deep bidirectional transformers for language understanding. In NAACL, Minneapolis, Minnesota, June 2019. Association for Computational Linguistics.
|
| 244 |
+
|
| 245 |
+
[27] Yi Tay, Mostafa Dehghani, Dara Bahri, and Donald Metzler. Efficient transformers: A survey. ACM Comput. Surv., 2022.
|
| 246 |
+
|
| 247 |
+
[28] 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 Proceedings of the IEEE/CVF International Conference on Computer Vision (ICCV), 2021.
|
| 248 |
+
|
| 249 |
+
[29] Kishaan Jeeveswaran, Senthilkumar Kathiresan, Arnav Varma, Omar Magdy, Bahram Zonooz, and Elahe Arani. A comprehensive study of vision transformers on dense prediction tasks. In Proceedings of the 17th International Joint Conference on Computer Vision, Imaging and Computer Graphics Theory and Applications, VISIGRAPP 2022, Volume 4: VISAPP, Online Streaming, February 6-8, 2022. SCITEPRESS, 2022.
|
| 250 |
+
|
| 251 |
+
[30] Hao Tan and Mohit Bansal. Lxmert: Learning cross-modality encoder representations from transformers. In EMNLP, 2019.
|
| 252 |
+
|
| 253 |
+
[31] Weijie Su, Xizhou Zhu, Yue Cao, Bin Li, Lewei Lu, Furu Wei, and Jifeng Dai. Vl-bert: Pre-training of generic visual-linguistic representations. In ICLR, 2020.
|
| 254 |
+
|
| 255 |
+
[32] Jiasen Lu, Dhruv Batra, Devi Parikh, and Stefan Lee. Vilbert: Pretraining task-agnostic visiolinguistic representations for vision-and-language tasks. In NeurIPS. Curran Associates, Inc., 2019.
|
| 256 |
+
|
| 257 |
+
[33] Liunian Harold Li, Mark Yatskar, Da Yin, Cho-Jui Hsieh, and Kai-Wei Chang. Visualbert: A simple and performant baseline for vision and language. CoRR, 2019.
|
| 258 |
+
|
| 259 |
+
[34] Valerii Likhosherstov, Anurag Arnab, Krzysztof Choromanski, Mario Lucic, Yi Tay, Adrian Weller, and Mostafa Dehghani. Polyvit: Co-training vision transformers on images, videos and audio. CoRR, 2021.
|
| 260 |
+
|
| 261 |
+
[35] Hassan Akbari, Liangzhe Yuan, Rui Qian, Wei-Hong Chuang, Shih-Fu Chang, Yin Cui, and Boqing Gong. Vatt: Transformers for multimodal self-supervised learning from raw video, audio and text. NeurIPS, 2021.
|
| 262 |
+
|
| 263 |
+
[36] Qing Li, Boqing Gong, Yin Cui, Dan Kondratyuk, Xianzhi Du, Ming-Hsuan Yang, and Matthew Brown. Towards a unified foundation model: Jointly pre-training transformers on unpaired images and text. arXiv preprint arXiv:2112.07074, 2021.
|
| 264 |
+
|
| 265 |
+
[37] Jianfeng Wang, Xiaowei Hu, Zhe Gan, Zhengyuan Yang, Xiyang Dai, Zicheng Liu, Yumao Lu, and Lijuan Wang. UFO: A unified transformer for vision-language representation learning. CoRR, 2021.
|
| 266 |
+
|
| 267 |
+
[38] Hussein Hazimeh, Zhe Zhao, Aakanksha Chowdhery, Maheswaran Sathiamoorthy, Yihua Chen, Rahul Mazumder, Lichan Hong, and Ed H. Chi. Dselect-k: Differentiable selection in the mixture of experts with applications to multi-task learning. In Advances in Neural Information Processing Systems 34: Annual Conference on Neural Information Processing Systems 2021, NeurIPS 2021, December 6-14, 2021, virtual, 2021.
|
| 268 |
+
|
| 269 |
+
[39] Mike Lewis, Shruti Bhosale, Tim Dettmers, Naman Goyal, and Luke Zettlemoyer. BASE layers: Simplifying training of large, sparse models. In Proceedings of the 38th International Conference on Machine Learning, ICML 2021, 18-24 July 2021, Virtual Event, Proceedings of Machine Learning Research. PMLR, 2021.
|
| 270 |
+
|
| 271 |
+
[40] Stephen Roller, Sainbayar Sukhbaatar, Arthur Szlam, and Jason Weston. Hash layers for large sparse models. In Advances in Neural Information Processing Systems 34: Annual Conference on Neural Information Processing Systems 2021, NeurIPS 2021, December 6-14, 2021, virtual, 2021.
|
| 272 |
+
|
| 273 |
+
[41] Ting Chen, Simon Kornblith, Mohammad Norouzi, and Geoffrey E. Hinton. A simple framework for contrastive learning of visual representations. In Proceedings of the 37th International Conference on Machine Learning, ICML 2020, 13-18 July 2020, Virtual Event, Proceedings of Machine Learning Research. PMLR, 2020.
|
| 274 |
+
|
| 275 |
+
[42] Prannay Khosla, Piotr Teterwak, Chen Wang, Aaron Sarna, Yonglong Tian, Phillip Isola, Aaron Maschinot, Ce Liu, and Dilip Krishnan. Supervised contrastive learning. 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 |
+
[43] Lu Yuan, Dongdong Chen, Yi-Ling Chen, Noel Codella, Xiyang Dai, Jianfeng Gao, Houdong Hu, Xuedong Huang, Boxin Li, Chunyuan Li, Ce Liu, Mengchen Liu, Zicheng Liu, Yumao Lu, Yu Shi, Lijuan Wang, Jianfeng Wang, Bin Xiao, Zhen Xiao, Jianwei Yang, Michael Zeng, Luowei Zhou, and Pengchuan Zhang. Florence: A new foundation model for computer vision. CoRR, 2021.
|
| 278 |
+
|
| 279 |
+
[44] Rishi Bommasani, Drew A. Hudson, Ehsan Adeli, Russ Altman, Simran Arora, Sydney von Arx, Michael S. Bernstein, Jeannette Bohg, Antoine Bosselut, Emma Brunskill, Erik Brynjolfsson, Shyamal Buch, Dallas Card, Rodrigo Castellon, Niladri S. Chatterji, Annie S. Chen, Kathleen Creel, Jared Quincy Davis, Dorottya Demszky, Chris Donahue, Moussa Doumbouya, Esin Durmus, Stefano Ermon, John Etchemendy, Kawin Ethayarajh, Li Fei-Fei, Chelsea Finn, Trevor Gale, Lauren Gillespie, Karan Goel, Noah D. Goodman, Shelby Grossman, Neel Guha, Tatsunori Hashimoto, Peter Henderson, John Hewitt, Daniel E. Ho, Jenny Hong, Kyle Hsu, Jing Huang, Thomas Icard, Saahil Jain, Dan Jurafsky, Pratyusha Kalluri, Siddharth Karamcheti, Geoff Keeling, Fereshte Khani, Omar Khattab, Pang Wei Koh, Mark S. Krass, Ranjay Krishna, Rohith Kuditipudi, and et al. On the opportunities and risks of foundation models. CoRR, 2021.
|
| 280 |
+
|
| 281 |
+
[45] Abeba Birhane, Vinay Uday Prabhu, and Emmanuel Kahembwe. Multimodal datasets: misogyny, pornography, and malignant stereotypes. CoRR, 2021.
|
| 282 |
+
|
| 283 |
+
[46] Sara Hooker, Nyalleng Moorosi, Gregory Clark, Samy Bengio, and Emily L. Denton. Characterising bias in compressed models. ArXiv, abs/2010.03058, 2020.
|
| 284 |
+
|
| 285 |
+
[47] David A. Patterson, Joseph Gonzalez, Quoc V. Le, Chen Liang, Lluis-Miquel Munguia, Daniel Rothchild, David R. So, Maud Texier, and Jeff Dean. Carbon emissions and large neural network training. CoRR, 2021.
|
| 286 |
+
|
| 287 |
+
[48] 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. J. Mach. Learn. Res., 2020.
|
| 288 |
+
|
| 289 |
+
[49] 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. CoRR, abs/2111.02114, 2021.
|
| 290 |
+
|
| 291 |
+
[50] Steven Bird, Edward Loper, and Ewan Klein. NLTK: the natural language toolkit. In ACL 2006, 21st International Conference on Computational Linguistics and 44th Annual Meeting of the Association for Computational Linguistics. The Association for Computer Linguistics, 2006.
|
md/dev/RdJVFCHjUMI/RdJVFCHjUMI.md
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
md/dev/SJ0Lde3tRL/SJ0Lde3tRL.md
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
md/dev/TrjbxzRcnf-/TrjbxzRcnf-.md
ADDED
|
@@ -0,0 +1,447 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# MEMORIZING TRANSFORMERS
|
| 2 |
+
|
| 3 |
+
Yuhuai Wu, Markus N. Rabe, DeLesley Hutchins, Christian Szegedy
|
| 4 |
+
|
| 5 |
+
{yuhuai,mrabe,delesley,szegedy}@google.com
|
| 6 |
+
|
| 7 |
+
# ABSTRACT
|
| 8 |
+
|
| 9 |
+
Language models typically need to be trained or finetuned in order to acquire new knowledge, which involves updating their weights. We instead envision language models that can simply read and memorize new data at inference time, thus acquiring new knowledge immediately. In this work, we extend language models with the ability to memorize the internal representations of past inputs. We demonstrate that an approximate $k \mathbf { N N }$ lookup into a non-differentiable memory of recent (key, value) pairs improves language modeling across various benchmarks and tasks, including generic webtext (C4), math papers (arXiv), books (PG-19), code (Github), as well as formal theorems (Isabelle). We show that the performance steadily improves when we increase the size of memory up to 262K tokens. On benchmarks including code and mathematics, we find that the model is capable of making use of newly defined functions and theorems during test time.
|
| 10 |
+
|
| 11 |
+
# 1 INTRODUCTION
|
| 12 |
+
|
| 13 |
+
Transformers (Vaswani et al., 2017) have led to remarkable progress in natural language processing (Devlin et al., 2019; Brown et al., 2020), mathematical reasoning (Polu & Sutskever, 2020; Wang et al., 2020a; Rabe et al., 2021; Li et al., 2021; Hahn et al., 2021; Cobbe et al., 2021), and program synthesis (Austin et al., 2021; Chen et al., 2021; Li et al., 2022). However, transformer performance on many of these tasks is limited by the context length of attention, which is typically short. The ability to attend to far-away tokens is important in many situations. In novels, characters and events are referenced across multiple chapters. In source code, references to classes and functions may occur quite far from the places in which they are defined. In theorem proving, proofs make use of previously defined lemmas.
|
| 14 |
+
|
| 15 |
+
Attention over long sequences is also useful as a form of rapid learning. Facts and information which are stored in the form of weight matrices must be slowly trained over hundreds of thousands of training steps. By using attention, however, a model can simply memorize facts (e.g. function definitions) by storing them as (key, value) pairs in long-term memory, and then retrieve those facts later by creating a query that attends to them. In this case, attention acts as a form of information retrieval, allowing the model to look up facts that it has seen previously.
|
| 16 |
+
|
| 17 |
+
We demonstrate that a simple and effective way to increase the size of the attention context is to use approximate $k$ -nearest-neighbor $( k \mathsf { N N } )$ lookup, which is widely used in information retrieval. A number of extremely scalable implementations of $k \mathbf { N N }$ lookup are available, such as ScaNN (Guo et al., 2020) and Faiss (Johnson et al., 2021).
|
| 18 |
+
|
| 19 |
+
There are two things which distinguish our approach from previous work on long-range attention (c.f. Section 2). First, unlike some other approaches, $k \mathbf { N N }$ lookup does not do averaging or summarization of tokens at long distances, but retrieves exact values even from the distant context.
|
| 20 |
+
|
| 21 |
+
Second, gradients are not backpropagated into the external memory, which is critical to the scalability of our technique. The keys and values are a function of model parameters, so attempting to backpropagate gradients into external memory would necessarily involve computing all of the keys and values with the current model parameters on every training step. However, if the external memory is not differentiable, then we can instead instead reuse keys and values that were previously computed on prior training steps, which drastically reduces the amount of computation for large memories. With our technique, we are easily able to scale external memory up to sequence lengths of 131k or 262k tokens on a single TPU device, while maintaining a reasonable step time.
|
| 22 |
+
|
| 23 |
+

|
| 24 |
+
Figure 1: Adding a memory of 8K tokens improves perplexity across different model sizes.
|
| 25 |
+
|
| 26 |
+
We show that model perplexity steadily improves with the size of external memory on a variety of language modelling tasks, including C4 (long documents only), Github code repositories, PG-19 books, formal proofs in Isabelle, and arXiv math papers. We further show that models can generalize to larger memory sizes than they were trained on: models trained with a small memory show gains from using a much larger memory at inference time. Finally, we show that our models are actually using memory in the way that we had hoped, e.g. by looking up the definitions of lemmas in a theorem proving corpus.
|
| 27 |
+
|
| 28 |
+
The simplicity of the changes to the Transformer architecture allows us to easily integrate this approach into existing code bases, including extremely large language models. We further show that the improvements to quality are maintained across models of increasing size, and that the model improvements gained from adding memory are even larger than increasing the size of the model by 5X or more as shown in Figure 1.
|
| 29 |
+
|
| 30 |
+
# 2 RELATED WORK
|
| 31 |
+
|
| 32 |
+
A great deal of work has been done on efficient long-range attention mechanisms; see Tay et al. (2020; 2021) recent surveys. Sliding windows (Beltagy et al., 2020) use a long sequence, but attend within a smaller window, thus reducing complexity to the window size, rather than total sequence length. Approximate mechanisms such as Linformer (Wang et al., 2020b), and Performer (Choromanski et al., 2021) refactor the attention matrix by using a different kernel than softmax to obtain $O ( N )$ complexity. Pooling strategies such as Hierarchical 1D attention (Zhu & Soricut, 2021), and Combiner (Ren et al., 2021) apply pooling or averaging over tokens at longer distances. Sparse strategies such as Big Bird (Zaheer et al., 2020) select only a subset of tokens to attend to; Routing Transformers (Roy et al., 2021) use clustering to select the subset, while Reformer (Kitaev et al., 2020) relies on hashing. Hierarchical mechanisms (Ainslie et al., 2020) combine multiple tokens into phrases or sentences to reduce sequence length. Expire-span (Sukhbaatar et al., 2021) prunes far-away tokens that it learns are “unimportant”. (Zemlyanskiy et al., 2021) process long sequences in two passes with different encoders. The second pass is given a lot of context by accessing summaries of the first pass.
|
| 33 |
+
|
| 34 |
+
Feedback transformers (Fan et al., 2020) use a recurrent architecture in which each token attends to the output of the final layer instead of the previous layer. Recurrence does not increase the size of the attention context itself, but it expands the receptive field at the cost of parallelism and training speed.
|
| 35 |
+
|
| 36 |
+
Truncated backpropagation through time (Williams & Peng, 1990) was originally introduced as a way of training recurrent neural networks (RNN) over very long sequences, when the entire sequence does not fit in memory. The sequence is chopped into segments, and after each training step, the final RNN state for the segment is saved in a non-differentiable cache, and used as the initial state on the next training step. Neural caches (Grave et al., 2017) extend the cache to contain a record of many prior hidden states, and attend over them. Transformer-XL (Dai et al., 2019) applies this technique to transformers; it caches the (key,value) pairs computed from the previous training step, and uses them as a prefix for the tokens on the next training step, which yields significant gains on long documents. Rae et al. (2020) improve over Transformer-XL by compressing the tokens before adding them to the cache. In contrast, we use a very large cache without compression, combined with an approximate $k \mathbf { N N }$ attention mechanism over it.
|
| 37 |
+
|
| 38 |
+

|
| 39 |
+
Figure 2: We extend Transformers with access to (key, value) pairs of previously seen subsequences.
|
| 40 |
+
|
| 41 |
+
Sukhbaatar et al. (2019) make the observation that the feed-forward portion of a transformer layer functions very much like attention if one replaces the ReLU activation with softmax. They implement a combined attention over both tokens from the input sequence and a learned (and differentiable) “memory”. Lample et al. (2019) exploit this observation to replace the feed-forward layers (FFNs) with a fast $k \mathbf { N N }$ lookup over a much larger “memory”, and achieve large gains in model accuracy without significant computation overhead. (We use $k \mathbf { N N }$ lookup to approximate attention to previous tokens, not to replace the FFN.)
|
| 42 |
+
|
| 43 |
+
Non-differentiable external memory has been used in different ways by Khandelwal et al. (2020), who run a pre-trained model over an entire corpus, and construct a large table of (key, token) pairs. They then use that table to replace the final softmax layer for token selection in the model, which results in significant improvements in language modeling. Yogatama et al. (2021) extend this approach by a gating mechanism and a process to compress the context into keys for retrieval.
|
| 44 |
+
|
| 45 |
+
There are several works that combine retrieval with transformers. REALM (Guu et al., 2020), MARGE (Lewis et al., 2020a), RAG (Lewis et al., 2020b), and composite memory for dialog (Fan et al., 2021) retrieve documents from a knowledge base to improve question answering or dialogue. The knowledge base consists of text snippets and is static and typically separate from the inputs and outputs of the models. Instead, we focus on language modeling using a decoder-only model, and propose a simple model that unifies attention and retrieval.
|
| 46 |
+
|
| 47 |
+
$k$ -nearest-neighbor lookup is a general-purpose technique that is used for a wide variety of machine learning and retrieval tasks, and high-performance implementations are available for various architectures (Johnson et al., 2021; Guo et al., 2020). Memory-efficient Transformers (Gupta et al., 2021) replace dense attention with a $k \mathbf { N N }$ lookup to increase speed and reduce memory usage.
|
| 48 |
+
|
| 49 |
+
# 3 METHOD
|
| 50 |
+
|
| 51 |
+
The architecture of our $k \mathbf { N N }$ -augmented transformer is shown in Figure 2. The bulk of the model is a vanilla, decoder-only transformer (Vaswani et al., 2017). The input text is tokenized, and the tokens are embedded into vector space. The embedding vectors are passed through a series of transformer layers, each of which does dense self-attention, followed by a feed-forward network (FFN). Since this is a decoder-only language model, we use a causal attention mask and the token embeddings of the last layer are used to predict the next token.
|
| 52 |
+
|
| 53 |
+
Long documents are split into subsequences of 512 tokens, and each subsequence is used as the input for one training step. In contrast to standard practice, we do not shuffle the subsequences; instead, each long document is fed into the transformer sequentially, from beginning to end, as is done with Transformer-XL (Dai et al., 2019).
|
| 54 |
+
|
| 55 |
+

|
| 56 |
+
Figure 3: Our data pipeline splits documents into subsequences and packs subsequences into batches.
|
| 57 |
+
|
| 58 |
+
We also use a Transformer-XL style cache, which holds the keys and values from the previous training step. When doing self-attention, the cached keys and values are prepended to the current keys and values, and we use a sliding-window causal mask (Beltagy et al., 2020) so that each token has a local context that includes the previous 512 tokens.
|
| 59 |
+
|
| 60 |
+
# 3.1 $k$ NN-AUGMENTED ATTENTION LAYER
|
| 61 |
+
|
| 62 |
+
One of the transformer layers near the top of the stack is a kNN-augmented attention layer, which combines two forms of attention. Like all of the other layers, it uses standard dense self-attention on the local context, which is the input subsequence for the current training step. Unlike the other layers, however, it also does an approximate $k$ -nearest-neighbor search into the external memory.
|
| 63 |
+
|
| 64 |
+
The same queries are used for both the local context, and for the external memory. The keys and values also belong to the same distribution; after each training step, the (key, value) pairs in the local context are appended to the end of the external memory. If the document is very long, old (key, value) pairs will be dropped from the memory to make room for new ones. Thus, for each head, the external memory keeps a cache of the prior $M$ (key, value) pairs, where $M$ is the memory size.
|
| 65 |
+
|
| 66 |
+
The $k \mathbf { N N }$ lookup will return a set of retrieved memories, which consist of the top- $k$ (key, value) pairs that $k \mathbf { N N }$ search returns for each query (i.e. each token) in the input subsequence. As with standard dense attention, we first construct an attention matrix by computing the dot product of each query against the retrieved keys, then apply softmax, and finally return a weighted sum of the retrieved values. Unlike standard dense attention, the retrieved memories contain a different set of (key, value) pairs for each query.
|
| 67 |
+
|
| 68 |
+
Attention over the local context is performed in the usual way. The results of $k \mathbf { N N }$ -attention and local attention are then combined using a learned gate:
|
| 69 |
+
|
| 70 |
+
$$
|
| 71 |
+
\begin{array} { c } { { g = \sigma ( b _ { g } ) } } \\ { { V _ { a } = V _ { m } \odot g + V _ { c } \odot ( 1 - g ) } } \end{array}
|
| 72 |
+
$$
|
| 73 |
+
|
| 74 |
+
where $\sigma$ is the sigmoid function, and $\odot$ is element-wise multiplication. $V _ { a }$ is the combined result of attention, $V _ { m }$ is the result of attending to external memory, and $V _ { c }$ is the result of attending to the local context. The bias $b _ { g }$ is a learned per-head scalar parameter, which allows each head to choose between local and long-range attention. In our experiments, the value of the gate $g$ does not depend on the content of the token at each position, although that would be a trivial extension to implement. We did observe that over time, most heads learned to attend almost exclusively to external memory.
|
| 75 |
+
|
| 76 |
+
Position bias. For dense attention within the local context, we use the T5 relative position bias (Raffel et al., 2020). As noted by Dai et al. (2019), adding a global position encoding to each token does not work well when processing long documents. We don’t use a position bias for the retrieved memories. Experiments on the PG19 dataset (Sun et al., 2021) have shown that relative position does not appear to matter at long range, and the T5 relative bias puts all long-range tokens in the same bucket anyway.
|
| 77 |
+
|
| 78 |
+
Batching. Figure 3 illustrates how multiple long documents of different lengths are packed into a batch, and split into subsequences. Each subsequence in the batch comes from a different document, and thus requires a separate external memory, which is cleared at the start of each new document.
|
| 79 |
+
|
| 80 |
+
# 3.2 DISTRIBUTIONAL SHIFT
|
| 81 |
+
|
| 82 |
+
Because each long document is processed over multiple training steps, there is a distributional shift in the keys and values that are stored in external memory. The model parameters that produce the queries change over time, and will thus have shifted since the keys and values were stored. For very large memories, older records may become “stale.” Similar observations have been made for CrossBatch memory (Wang et al., 2020c) in the vision domain.
|
| 83 |
+
|
| 84 |
+
To reduce the effects of staleness, we normalize keys and queries (Henry et al., 2020). Normalization does not eliminate staleness, but it at least ensures that older keys and newer keys do not differ in magnitude. We also found that normalization helps stabilize training with the Transformer-XL cache.
|
| 85 |
+
|
| 86 |
+
In some of our experiments, we observed that training models from scratch with a large memory sometimes resulted in worse performance than pretraining the model with a small memory of size 8192, and then finetuning it on a larger memory. This training instability could be due to staleness. However, models seem to be able to cope with a limited degree of staleness (with the small memory) by adjusting their queries accordingly.
|
| 87 |
+
|
| 88 |
+
# 3.3 APPROXIMATE $k \mathbf { N N }$
|
| 89 |
+
|
| 90 |
+
We employ approximate $k \mathbf { N N }$ search rather than exact $k \mathbf { N N }$ search because it significantly improves the computational speed of our model. We use a simple approximation of $k \mathbf { N N }$ for TPUs, which has a recall of about $90 \%$ , i.e. $90 \%$ of the true top $k$ are returned in the approximate top $k$ . There are various other efficient approximate $k \mathbf { N N }$ algorithms available for CPU and GPU/TPU, for example through Faiss (Johnson et al., 2021) or ScaNN (Guo et al., 2020), which can scale into the billions.
|
| 91 |
+
|
| 92 |
+
# 4 EXPERIMENTS
|
| 93 |
+
|
| 94 |
+
We evaluate the effect of adding external memory on five language modeling tasks, all of which involve long-form text: English language books (PG-19), long web articles (C4), technical math papers (arXiv Math), source code (Github), and formal theorems (Isabelle). The results show significant improvements in the perplexity of the model with the addition of external memory. We experimented with various sizes of external memory, from 1536 to as high as 262K. On most of the datasets, there was an initial sharp gain from adding a small external memory, followed by smaller but steadily increasing gains as the size of the memory was increased.
|
| 95 |
+
|
| 96 |
+
# 4.1 DATASETS
|
| 97 |
+
|
| 98 |
+
arXiv Math For the arXiv dataset, we collected a corpus of papers by downloading them via the arXiv Bulk Data Access1. We filtered papers to include only articles labeled as “Mathematics” and whose $\mathrm { I A T } \mathrm { E } ^ { \mathrm { X } }$ source was available. The number of tokens per paper in this dataset is roughly comparable to the number of tokens per book in PG19, because $\mathrm { I A T } \mathrm { E } ^ { \mathrm { X } }$ source has many special characters and the tokenizer tends to output small subwords.
|
| 99 |
+
|
| 100 |
+
Github We used BigQuery2 to obtain a large corpus of Github repositories that are published with open-source licenses. We used file endings to filter for files in the languages C, $\mathrm { C } { + + }$ , Java, Python (including Jupyter notebooks), Go, and TypeScript. Individual source code files are often fairly short, and there are many dependencies and cross-references between files in the repository. To capture these dependencies, we created one long document for each Github repository by traversing the directory tree, and concatenating all of the files within it. The order in which files are traversed within the repository is random, but each subdirectory is processed as a unit, so that all the files within the subdirectory are close to each other in the resulting document. Source code is usually structured so that related files are all grouped together in the same subdirectory; this traversal preserves that structure, while still shuffling files and subdirectories in random order.
|
| 101 |
+
|
| 102 |
+
Formal Math – Isabelle The Isabelle corpus consists of formal mathematical proofs of theories. We collected all 627 theories available on The Archive of Formal Proofs3 (as of October 6, 2021) and an additional 57 theories from the Isabelle standard library4 to create a corpus of 684 theories. All theories have open-source licenses. Each theory is a self-contained mathematical object, on topics such as foundational logic, advanced analysis, algebra, or cryptography, and consists of multiple files containing proofs. As with the Github corpus, all files that make up a theory are concatenated together into one long document. Unlike the Github corpus, we order the files according to their import dependencies, so that later files use sub-theorems that are proved in earlier files.
|
| 103 |
+
|
| 104 |
+
Table 4: Average token-level perplexities of each model when trained for 500k steps.
|
| 105 |
+
|
| 106 |
+
<table><tr><td>Context</td><td>Memory</td><td>XL cache</td><td>arXiv</td><td>PG19</td><td>C4(4K+)</td><td>GitHub</td><td>Isabelle</td></tr><tr><td>512</td><td>None</td><td>None</td><td>3.29</td><td>13.71</td><td>17.20</td><td>3.05</td><td>3.09</td></tr><tr><td>2048</td><td>None</td><td>None</td><td>2.69</td><td>12.37</td><td>14.81</td><td>2.22</td><td>2.39</td></tr><tr><td>512</td><td>None</td><td>512</td><td>2.67</td><td>12.34</td><td>15.38</td><td>2.26</td><td>2.46</td></tr><tr><td>2048</td><td>None</td><td>2048</td><td>2.42</td><td>11.88</td><td>14.03</td><td>2.10</td><td>2.16</td></tr><tr><td>512</td><td>1536</td><td>None</td><td>2.61</td><td>12.50</td><td>14.97</td><td>2.20</td><td>2.33</td></tr><tr><td>512</td><td>8192</td><td>None</td><td>2.49</td><td>12.29</td><td>14.42</td><td>2.09</td><td>2.19</td></tr><tr><td>512</td><td>8192</td><td>512</td><td>2.37</td><td>11.93</td><td>14.04</td><td>2.03</td><td>2.08</td></tr><tr><td>512</td><td>65K</td><td>512</td><td>2.31</td><td>11.62</td><td>14.04</td><td>1.87</td><td>2.06</td></tr><tr><td>2048</td><td>8192</td><td>2048</td><td>2.33</td><td>11.84</td><td>13.80</td><td>1.98</td><td>2.06</td></tr><tr><td>2048</td><td>65K</td><td>2048</td><td>2.26</td><td>11.37</td><td>13.64</td><td>1.80</td><td>1.99</td></tr></table>
|
| 107 |
+
|
| 108 |
+
$\mathbf { C 4 } ( 4 \mathbf { K } + )$ C4, the colossal cleaned common crawl, is a very large collection of documents that have been scraped from the internet (Raffel et al., 2020). We filtered out all documents that have less than 4096 tokens to focus on documents where memory can have an impact.
|
| 109 |
+
|
| 110 |
+
PG-19 PG-19 is a large dataset of English-language books, published prior to 1919, which were retrieved from the Project Gutenberg archive (Rae et al., 2020; Sun et al., 2021). PG-19 is one of the few public datasets that only contains full-length books, and has become a benchmark for long-range natural language text modeling.
|
| 111 |
+
|
| 112 |
+
# 4.2 EXPERIMENTAL METHOD
|
| 113 |
+
|
| 114 |
+
We used a 12-layer decoder-only transformer (with and without Transformer-XL cache) with an embedding size of 1024, 8 attention heads of dimension 128, and an FFN hidden layer of size 4096. For all of our experiments, we used $k = 3 2$ . Unless specified otherwise, we use the 9th layer as the $k \mathbf { N N }$ augmented attention layer. We used a sentence-piece (Kudo & Richardson, 2018) tokenizer with a vocabulary size of 32K.
|
| 115 |
+
|
| 116 |
+
We used the Adafactor optimizer (Shazeer & Stern, 2018). In preliminary experiments, we conducted a hyperparameter search to determine the optimal learning rate among three choices ({3.0, 1.0, $3 \cdot { \bar { 1 0 } } ^ { - 1 } \}$ ), and found that 1.0 works best. We used a linear warmup schedule for the first 1000 steps, followed by square root decay. We trained the models from scratch for 500K steps on all the datasets, except for the Isabelle dataset. Isabelle is small, so we stopped training after 100K steps when the model began to overfit. We ran all of our experiments on 32 TPU cores. Our models were implemented in JAX (Bradbury et al., 2018) and Flax (Heek et al., 2020).
|
| 117 |
+
|
| 118 |
+
When comparing models with different context lengths, we adjusted the batch size (the number of documents in a batch) so that there are always $2 ^ { 1 7 }$ tokens in a batch. E.g., a model with a context length of 512 has a batch size of 256, while the 2048 model has a batch size of 64.
|
| 119 |
+
|
| 120 |
+
We experimented with multiple implementations of approximate $k \mathbf { N N }$ lookup with different tradeoffs between quality and computational cost. We did not observe a significant degradation of the model quality when switching to lower quality approximations of $k \mathbf { N N }$ , so the model appears to be quite robust with respect to the quality of $k \mathbf { N N }$ retrieval. For a model with around 200M trainable parameters the step time increased from 0.2s to $0 . 2 5 \mathrm { s }$ when we added a memory of size 8K, and to 0.6s when we added a memory of size 65K (measured on TPUv3).
|
| 121 |
+
|
| 122 |
+
# 4.3 EFFECT OF EXTERNAL MEMORY
|
| 123 |
+
|
| 124 |
+
Adding external memory results in substantial gains across datasets and architectures, as shown in Table 4. Across all five datasets, adding external memory to either the vanilla Transformer or the Transformer-XL architecture improves perplexity by a substantial amount. For example, on $\mathrm { C 4 } ( 4 \mathrm { K } + )$ dataset, adding memory of size 8192 improves the perplexity of the vanilla Transformer (with context size 512) from 17.20 to 14.42, and improves Transformer-XL from 15.38 to 14.04.
|
| 125 |
+
|
| 126 |
+
<table><tr><td>Context</td><td>Pretrain</td><td>Fine-tune</td><td>Perplexity</td></tr><tr><td>512</td><td>8192</td><td>None</td><td>2.37</td></tr><tr><td>512</td><td>65K</td><td>None</td><td>2.31</td></tr><tr><td>512</td><td>8192</td><td>65K</td><td>2.32</td></tr><tr><td>512</td><td>8192</td><td>131K</td><td>2.30</td></tr><tr><td>512</td><td>8192</td><td>262K</td><td>2.26</td></tr><tr><td>2048</td><td>8192</td><td>None</td><td>2.33</td></tr><tr><td>2048</td><td>65K</td><td>None</td><td>2.26</td></tr><tr><td>2048</td><td>65K</td><td>131K</td><td>2.23</td></tr><tr><td>2048</td><td>65K</td><td>262K</td><td>2.21</td></tr></table>
|
| 127 |
+
|
| 128 |
+
Table 5: Finetuning for 20K steps to make use of a larger memory on the arXiv data set.
|
| 129 |
+
|
| 130 |
+
Increasing the size of the memory increases the benefit of the memory. The best perplexities for all datasets and architectures were obtained with a memory size of 65K.
|
| 131 |
+
|
| 132 |
+
Note that Transformer-XL with context size 2048 already has a theoretical receptive field that is quite large. Each token in a higher layer can attend up to 2048 tokens away in the layer below, so the total receptive field is $2 0 4 8 \cdot 1 2$ (layers) $\sim 2 5 \mathrm { K }$ . Nevertheless, we still saw a substantial gain when adding an external memory of size 8192 to this model. $k \mathbf { N N }$ attention into memory would appear to be a more effective way to retrieve information from the distant past than the Transformer-XL cache.
|
| 133 |
+
|
| 134 |
+
On the other hand, we also saw improvements by adding XL cache to the large-memory (65K) models. In a vanilla (non-XL) Transformer, the first few tokens in a sequence have very little context, and thus have higher perplexity. The XL cache provides additional local short-range context at the start of a sequence, which complements the long-range context provided by external memory.
|
| 135 |
+
|
| 136 |
+
Interestingly, in a vanilla Transformer, using even a small external memory of size 1536 provides a gain in perplexity which is almost as good as using a local context of size 2048 but no memory (e.g. Table 4). This is surprising, because the external memory is not differentiable, and is added only to one layer of the Transformer, whereas increasing the context size is differentiable and affects all layers. We conclude that the lower layers of a Transformer don’t necessarily need long-range context, and having a differentiable memory is not as important as one might suspect.
|
| 137 |
+
|
| 138 |
+
# 4.4 SCALING TO LARGER MODELS
|
| 139 |
+
|
| 140 |
+
We scaled up the Transformer model to sizes of 1 and 8 billion parameters. For the 1 billion parameter model, we use 8 layers, 32 heads with head dimension 128, $d _ { - }$ model 2048, and $d _ { - }$ _ff 16384. For the 8 billion parameter model, we use 64 heads, 16 layers, $d$ _model 4096, and $d _ { - }$ _ff 32768. We used a context size of 2048, memory size of 8192, and no XL cache. We ran the comparisons to the vanilla Transformer on the arXiv math dataset. Scaling plots are shown in Figure 1.
|
| 141 |
+
|
| 142 |
+
External memory provides a consistent improvement to the model as it is scaled up. Remarkably, we found that the smaller Memorizing Transformer with just 8k tokens in memory can match the perplexity of a larger vanilla Transformer which has 5X more trainable parameters.
|
| 143 |
+
|
| 144 |
+
# 4.5 FINETUNING ON LARGER MEMORIES
|
| 145 |
+
|
| 146 |
+
Finetuning on a larger memory. In some cases, training was unstable when using large memories, possibly due to distributional shift early in the training (See Section 3.2). Thus, for memories of 131K or more tokens, we first pretrain the model with a memory size of 8192 or 65K for 500K steps, and then finetune it with the larger memory for an additional 20K steps. The results of finetuning on the arXiv Math data set are shown in Table 5. Increasing the size of external memory provided consistent gains up to a size of 262K. Note that 262K tokens is longer than almost all of the documents in arXiv, and thus we would not expect to see any gain past this point (see Appendix A).
|
| 147 |
+
|
| 148 |
+

|
| 149 |
+
Figure 6: Finetuning a 1B vanilla Transformer model to use external memory of size 65K.
|
| 150 |
+
|
| 151 |
+
Finetuning a non-memory model to use memory Pretraining can be very costly both in time and computational resources. Thus, a natural question to ask is: can one fine-tune a pretrained Transformer to use external memory? The answer is yes!
|
| 152 |
+
|
| 153 |
+
We took a pre-trained 1B vanilla Transformer model, and fine-tuned it to use external memory (the 1B models used in Section 4.4). The fine-tuning result is shown in Figure 6. Notice that the model quickly learns to use external memory. Within 20K steps $4 \%$ of the pre-training time) the fine-tuned model has already closed $8 5 \%$ of the gap between it and the 1B Memorizing Transformer, and after $1 0 0 \mathrm { k }$ steps it has closed the gap entirely.
|
| 154 |
+
|
| 155 |
+
# 4.6 INFORMATION RETRIEVAL PATTERNS
|
| 156 |
+
|
| 157 |
+
We conducted a qualitative study of what the model was actually retrieving from external memory, by finding which tokens showed the biggest improvements in cross-entropy loss when the size of the memory was increased, and then examining the top- $k$ retrieved memories for those tokens. We found that the model gained the most when looking up rare words, such as proper names, references, citations, and function names, where the first use of a name is too far away from subsequent uses to fit in the local context. This result is in keeping with the prior analysis of long-context Transformers on PG19 (Sun et al., 2021), which found similar lookup patterns. For this experiment, we used a slightly older version of the architecture without the gating mechanism.
|
| 158 |
+
|
| 159 |
+
Which tokens show a benefit from memory? Figure 7 shows a visualization of which tokens show an improvement when the size of the external memory is increased. We selected a math paper at random, and plotted the difference in cross entropy loss for each token $x _ { i }$ in the paper, comparing two models with the same parameters, but with memories of different sizes. $\Delta _ { i } = \mathrm { c r o s s - e n t r o p y } _ { 8 1 9 2 } ( x _ { i } )$ $- \mathrm { c r o s s - e n t r o p y } _ { 3 2 \mathrm { K } } ( x _ { i } )$ . Positive values show an improvement in loss.
|
| 160 |
+
|
| 161 |
+
The $x$ -axis on the chart is the token number $i$ , while the $y$ -axis is $\Delta _ { i }$ . For the first 8192 tokens, the difference between the two models is zero, since the larger capacity of the 32K memory isn’t being used yet. However, after token 8193, we can see that the larger memory helps, on average, over the smaller memory. The benefit is not universal, since the predictions for some tokens become worse, possibly due to the fact that a relevant retrieved memory no longer makes it into the top- $k$ when the size of the external memory is increased. This figure also shows that the benefit of external memory is somewhat sparse. The improvement in perplexity seems to be mainly driven by a small percentage of tokens that obtain a large improvement in cross-entropy loss when using the larger memory.
|
| 162 |
+
|
| 163 |
+
What information is being looked up? Given that only a subset of tokens shows improvement from external memory, we did a further investigation into what, exactly, those tokens are using the memory for. We took those tokens which showed the largest improvement in cross-entropy loss, and for each of them tokens, we examined the top- $k$ retrieved memories. We studied arXiv math, Github and Isabelle corpus. For arXiv math and Github, we found the model retrieved function and variable names. See more details with examples in Appendix B.
|
| 164 |
+
|
| 165 |
+

|
| 166 |
+
Figure 7: Difference in loss for each token in a randomly chosen paper, using the same model once with a memory size of 8K and once with 32K. Higher numbers mean the longer memory helped in comparison to the shorter memory. This paper is 22K tokens long.
|
| 167 |
+
|
| 168 |
+
Table 8: Examples of memory retrieval in the Isabelle dataset. The model is able to find the definition of a lemma from a reference to it. The retrieved surrounding context (highlighted) is the definition body of the mathematical object highlighted in the querying context.
|
| 169 |
+
|
| 170 |
+
<table><tr><td></td><td></td><td></td><td>Query indexInputTargetSurrounding context</td><td></td><td>Retrieved index Retrieved surrounding context</td></tr><tr><td>29721</td><td>mark</td><td>ov</td><td>rule prob_space. markov_inequality</td><td>8088</td><td>M.t\<le> X a} \<le> expectation X /t"</td></tr><tr><td>40919</td><td>1</td><td>th</td><td>= ( subgraph_threshold Hn / p n)</td><td>27219</td><td>threshold H n = n powr (-(1 / max_density’</td></tr><tr><td>49699</td><td>S</td><td>W</td><td>assumes' orthonormal_system Sw"</td><td>28050</td><td>definition orthonormal_system “</td></tr></table>
|
| 171 |
+
|
| 172 |
+
Retrieving mathematical definitions. Our case study on the Isabelle corpus provides one of the clearest illustrations of how a model can make good use of external memory. When predicting the name of a mathematical object or a lemma, the model looked up the definition from earlier in the proof. Examples of this behavior are shown in Table 8. In example 1, the model retrieves a definition within the body of a lemma, markov_inequality. In example 2, it retrieves the definition of a previously defined concept subgraph_threshold. In example 3, it retrieves the definition of orthonormal_system. We manually checked 10 examples where the model made a prediction of lemma names, and 8 out of 10 times model found the body of the lemma it needs to predict. In the other two cases, the model also looked up materials in the immediate vicinity. To the best of our knowledge, this is the first demonstration that attention is capable of looking up definitions and function bodies from a large corpus. The Isabelle case study used a model with two memory layers of size 32K.
|
| 173 |
+
|
| 174 |
+
# 5 CONCLUSION
|
| 175 |
+
|
| 176 |
+
We present a simple extension to the Transformer architecture, called kNN-augmented attention, which dramatically increases the length of the context that a language model can attend to by using $k$ -nearest-neighbor lookup into a large external memory. We demonstrate the effectiveness of external memory in a series of language modeling experiments over a variety of long-document datasets, including LaTeX documents, source code, formal proofs, and books.
|
| 177 |
+
|
| 178 |
+
The Memorizing Transformer shows large improvements in perplexity over the baseline for all of the data sets and architectures that we studied; it is comparable to a vanilla transformer that has 5 times the number of parameters. Perplexity continues to improve with increasing memory size, although there is a point of diminishing returns. Moreover, external memory continues to provide benefits even as the transformer is scaled up from 200M to 8B parameters. Perhaps most intriguingly, a Memorizing Transformer does not need to be pre-trained from scratch; it is possible obtain large gains from adding memory to an existing pre-trained model, and then fine-tuning it.
|
| 179 |
+
|
| 180 |
+
Unlike other forms of attention, $k \mathbf { N N }$ retrieval can be easily scaled up to huge memory sizes, and is thus potentially able to leverage vast knowledge bases or code repositories. How to make the best use of this capability is a topic for future work.
|
| 181 |
+
|
| 182 |
+
# ACKNOWLEDGMENTS
|
| 183 |
+
|
| 184 |
+
We want to thank Charles Staats for the many fruitful discussions and detailed comments, Henryk Michalewski for early version of of the memory implementation, Petros Maniatis for his help with our code datasets, Aitor Lewkowycz for his help with larger scale memorizing transformer experiments, Behnam Neyshabur for his comments on finetuning non-memory models, Imanol Schlag for his proofread and detailed comments, and Dennis Lee and Manzil Zaheer for discussions about large-scale attention and retrieval.
|
| 185 |
+
|
| 186 |
+
# ETHICS
|
| 187 |
+
|
| 188 |
+
The ability to memorize large databases of facts could have potential ramifications for society, especially if those databases include sensitive personal information or copyrighted works. However, one advantage of using an external memory is that the memory can be easily cleared of all such information, as we do at the end of each document that we train on. The same is not true of differentiable model parameters, which is what most existing architectures use to store facts and information that they are trained on.
|
| 189 |
+
|
| 190 |
+
# REPRODUCIBILITY
|
| 191 |
+
|
| 192 |
+
Details of our architecture and training hyperparameters are given in Section 4.2. The datasets for C4 and PG-19 are publicly available. Our additional datasets, Github, Isabelle, and ArXiv Math are derived from publicly available data buckets, which we link in the main part of the paper. Subsection 4.1 include details on how we constructed the datasets from those datasets. We plan to release our code as open source.
|
| 193 |
+
|
| 194 |
+
# REFERENCES
|
| 195 |
+
|
| 196 |
+
Joshua Ainslie, Santiago Ontañón, 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 EMNLP, 2020.
|
| 197 |
+
|
| 198 |
+
Jacob Austin, Augustus Odena, Maxwell Nye, Maarten Bosma, Henryk Michalewski, David Dohan, Ellen Jiang, Carrie J. Cai, Michael Terry, Quoc V. Le, and Charles Sutton. Program synthesis with large language models. CoRR, abs/2108.07732, 2021. URL https://arxiv.org/abs/ 2108.07732.
|
| 199 |
+
|
| 200 |
+
Iz Beltagy, Matthew E. Peters, and Arman Cohan. Longformer: The long-document transformer. CoRR, abs/2004.05150, 2020. URL https://arxiv.org/abs/2004.05150.
|
| 201 |
+
|
| 202 |
+
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.
|
| 203 |
+
|
| 204 |
+
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.
|
| 205 |
+
|
| 206 |
+
Mark Chen, Jerry Tworek, Heewoo Jun, Qiming Yuan, Henrique Ponde de Oliveira Pinto, Jared Kaplan, Harrison Edwards, Yuri Burda, Nicholas Joseph, Greg Brockman, Alex Ray, Raul Puri, Gretchen Krueger, Michael Petrov, Heidy Khlaaf, Girish Sastry, Pamela Mishkin, Brooke Chan, Scott Gray, Nick Ryder, Mikhail Pavlov, Alethea Power, Lukasz Kaiser, Mohammad Bavarian, Clemens Winter, Philippe Tillet, Felipe Petroski Such, Dave Cummings, Matthias Plappert, Fotios Chantzis, Elizabeth Barnes, Ariel Herbert-Voss, William Hebgen Guss, Alex Nichol, Alex Paino, Nikolas Tezak, Jie Tang, Igor Babuschkin, Suchir Balaji, Shantanu Jain, William Saunders, Christopher Hesse, Andrew N. Carr, Jan Leike, Joshua Achiam, Vedant Misra, Evan Morikawa, Alec Radford, Matthew Knight, Miles Brundage, Mira Murati, Katie Mayer, Peter Welinder, Bob McGrew, Dario Amodei, Sam McCandlish, Ilya Sutskever, and Wojciech Zaremba. Evaluating large language models trained on code. CoRR, abs/2107.03374, 2021. URL https://arxiv. org/abs/2107.03374.
|
| 207 |
+
|
| 208 |
+
Krzysztof Marcin Choromanski, Valerii Likhosherstov, David Dohan, Xingyou Song, Andreea Gane, Tamás Sarlós, Peter Hawkins, Jared Quincy Davis, Afroz Mohiuddin, Lukasz Kaiser, David Benjamin Belanger, Lucy J. Colwell, and Adrian Weller. Rethinking attention with performers. In ICLR, 2021.
|
| 209 |
+
|
| 210 |
+
Karl Cobbe, Vineet Kosaraju, Mohammad Bavarian, Jacob Hilton, Reiichiro Nakano, Christopher Hesse, and John Schulman. Training verifiers to solve math word problems. CoRR, abs/2110.14168, 2021. URL https://arxiv.org/abs/2110.14168.
|
| 211 |
+
|
| 212 |
+
Zihang Dai, Zhilin Yang, Yiming Yang, Jaime G. Carbonell, Quoc Viet Le, and Ruslan Salakhutdinov. Transformer-XL: Attentive language models beyond a fixed-length context. In ACL, 2019.
|
| 213 |
+
|
| 214 |
+
Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. BERT: pre-training of deep bidirectional transformers for language understanding. In ACL, 2019.
|
| 215 |
+
|
| 216 |
+
Angela Fan, Thibaut Lavril, Edouard Grave, Armand Joulin, and Sainbayar Sukhbaatar. Addressing some limitations of transformers with feedback memory. arXiv preprint arXiv:2002.09402, 2020.
|
| 217 |
+
|
| 218 |
+
Angela Fan, Claire Gardent, Chloé Braud, and Antoine Bordes. Augmenting transformers with KNN-based composite memory for dialog. Transactions of the Association for Computational Linguistics, 9:82–99, 2021.
|
| 219 |
+
|
| 220 |
+
Edouard Grave, Armand Joulin, and Nicolas Usunier. Improving neural language models with a continuous cache. In ICLR, 2017.
|
| 221 |
+
|
| 222 |
+
Ruiqi Guo, Philip Sun, Erik Lindgren, Quan Geng, David Simcha, Felix Chern, and Sanjiv Kumar. Accelerating large-scale inference with anisotropic vector quantization. In ICML, 2020.
|
| 223 |
+
|
| 224 |
+
Ankit Gupta, Guy Dar, Shaya Goodman, David Ciprut, and Jonathan Berant. Memory-efficient transformers via top- $\mathbf { \nabla } \cdot \mathbf { k }$ attention. CoRR, abs/2106.06899, 2021. URL https://arxiv.org/ abs/2106.06899.
|
| 225 |
+
|
| 226 |
+
Kelvin Guu, Kenton Lee, Zora Tung, Panupong Pasupat, and Ming-Wei Chang. Retrieval augmented language model pre-training. In ICML, 2020.
|
| 227 |
+
|
| 228 |
+
Christopher Hahn, Frederik Schmitt, Jens U. Kreber, Markus Norman Rabe, and Bernd Finkbeiner. Teaching temporal logics to neural networks. In ICLR, 2021.
|
| 229 |
+
|
| 230 |
+
Jonathan Heek, Anselm Levskaya, Avital Oliver, Marvin Ritter, Bertrand Rondepierre, Andreas Steiner, and Marc van Zee. Flax: A neural network library and ecosystem for JAX, 2020. URL http://github.com/google/flax.
|
| 231 |
+
|
| 232 |
+
Alex Henry, Prudhvi Raj Dachapally, Shubham Shantaram Pawar, and Yuxuan Chen. Query-key normalization for transformers. In EMNLP, 2020.
|
| 233 |
+
|
| 234 |
+
Jeff Johnson, Matthijs Douze, and Hervé Jégou. Billion-scale similarity search with GPUs. IEEE Transactions on Big Data, 2021.
|
| 235 |
+
|
| 236 |
+
Urvashi Khandelwal, Omer Levy, Dan Jurafsky, Luke Zettlemoyer, and Mike Lewis. Generalization through memorization: Nearest neighbor language models. In ICLR, 2020.
|
| 237 |
+
|
| 238 |
+
Nikita Kitaev, Łukasz Kaiser, and Anselm Levskaya. Reformer: The efficient transformer. In ICLR, 2020.
|
| 239 |
+
|
| 240 |
+
Taku Kudo and John Richardson. Sentencepiece: A simple and language independent subword tokenizer and detokenizer for neural text processing. In EMNLP, 2018.
|
| 241 |
+
|
| 242 |
+
Guillaume Lample, Alexandre Sablayrolles, Marc’Aurelio Ranzato, Ludovic Denoyer, and Hervé Jégou. Large memory layers with product keys. In NeurIPS, 2019.
|
| 243 |
+
|
| 244 |
+
Mike Lewis, Marjan Ghazvininejad, Gargi Ghosh, Armen Aghajanyan, Sida Wang, and Luke Zettlemoyer. Pre-training via paraphrasing. In NeurIPS, 2020a.
|
| 245 |
+
|
| 246 |
+
Patrick Lewis, Ethan Perez, Aleksandra Piktus, Fabio Petroni, Vladimir Karpukhin, Naman Goyal, Heinrich Küttler, Mike Lewis, Wen-tau Yih, Tim Rocktäschel, et al. Retrieval-augmented generation for knowledge-intensive NLP tasks. In NeurIPS, 2020b.
|
| 247 |
+
|
| 248 |
+
Wenda Li, Lei Yu, Yuhuai Wu, and Lawrence C. Paulson. Isarstep: a benchmark for high-level mathematical reasoning. In ICLR, 2021.
|
| 249 |
+
|
| 250 |
+
Yujia Li, David Choi, Junyoung Chung, Nate Kushman, Julian Schrittwieser, Rémi Leblond, Tom Eccles, James Keeling, Felix Gimeno, Agustin Dal Lago, Thomas Hubert, Peter Choy, Cyprien de Masson d’Autume, Igor Babuschkin, Xinyun Chen, Po-Sen Huang, Johannes Welbl, Sven Gowal, Alexey Cherepanov, James Molloy, Daniel J. Mankowitz, Esme Sutherland Robson, Pushmeet Kohli, Nando de Freitas, Koray Kavukcuoglu, and Oriol Vinyals. Competition-level code generation with alphacode. DeepMind, 2022.
|
| 251 |
+
|
| 252 |
+
Stanislas Polu and Ilya Sutskever. Generative language modeling for automated theorem proving. CoRR, abs/2009.03393, 2020. URL https://arxiv.org/abs/2009.03393.
|
| 253 |
+
|
| 254 |
+
Markus Norman Rabe, Dennis Lee, Kshitij Bansal, and Christian Szegedy. Mathematical reasoning via self-supervised skip-tree training. In ICLR, 2021.
|
| 255 |
+
|
| 256 |
+
Jack W Rae, Anna Potapenko, Siddhant M Jayakumar, Chloe Hillier, and Timothy P Lillicrap. Compressive transformers for long-range sequence modelling. In ICLR, 2020.
|
| 257 |
+
|
| 258 |
+
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.
|
| 259 |
+
|
| 260 |
+
Hongyu Ren, Hanjun Dai, Zihang Dai, Mengjiao Yang, Jure Leskovec, Dale Schuurmans, and Bo Dai. Combiner: Full attention transformer with sparse computation cost. CoRR, abs/2107.05768, 2021. URL https://arxiv.org/abs/2107.05768.
|
| 261 |
+
|
| 262 |
+
Aurko Roy, Mohammad Saffar, Ashish Vaswani, and David Grangier. Efficient content-based sparse attention with routing transformers. Transactions of the Association for Computational Linguistics, 9:53–68, 2021.
|
| 263 |
+
|
| 264 |
+
Noam Shazeer and Mitchell Stern. Adafactor: Adaptive learning rates with sublinear memory cost. In ICML, 2018.
|
| 265 |
+
|
| 266 |
+
Sainbayar Sukhbaatar, Edouard Grave, Guillaume Lample, Herve Jegou, and Armand Joulin. Augmenting self-attention with persistent memory. arXiv preprint arXiv:1907.01470, 2019.
|
| 267 |
+
|
| 268 |
+
Sainbayar Sukhbaatar, Da Ju, Spencer Poff, Stephen Roller, Arthur Szlam, Jason Weston, and Angela Fan. Not all memories are created equal: Learning to forget by expiring. In ICML, 2021.
|
| 269 |
+
|
| 270 |
+
Simeng Sun, Kalpesh Krishna, Andrew Mattarella-Micke, and Mohit Iyyer. Do long-range language models actually use long-range context? In EMNLP, 2021.
|
| 271 |
+
|
| 272 |
+
Yi Tay, Mostafa Dehghani, Dara Bahri, and Donald Metzler. Efficient transformers: A survey. arXiv preprint arXiv:2009.06732, 2020.
|
| 273 |
+
|
| 274 |
+
Yi Tay, Mostafa Dehghani, Samira Abnar, Yikang Shen, Dara Bahri, Philip Pham, Jinfeng Rao, Liu Yang, Sebastian Ruder, and Donald Metzler. Long range arena: A benchmark for efficient transformers. In ICLR, 2021.
|
| 275 |
+
|
| 276 |
+
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.
|
| 277 |
+
|
| 278 |
+
Qingxiang Wang, Chad Brown, Cezary Kaliszyk, and Josef Urban. Exploration of neural machine translation in autoformalization of mathematics in mizar. In International Conference on Certified Programs and Proofs, 2020a.
|
| 279 |
+
|
| 280 |
+
Sinong Wang, Belinda Z Li, Madian Khabsa, Han Fang, and Hao Ma. Linformer: Self-attention with linear complexity. arXiv preprint arXiv:2006.04768, 2020b.
|
| 281 |
+
|
| 282 |
+
Xun Wang, Haozhi Zhang, Weilin Huang, and Matthew R. Scott. Cross-batch memory for embedding learning. In CVPR, 2020c.
|
| 283 |
+
|
| 284 |
+
Ronald J. Williams and Jing Peng. An efficient gradient-based algorithm for on-line training of recurrent network trajectories. Neural Computation, 1990.
|
| 285 |
+
|
| 286 |
+
Dani Yogatama, Cyprien de Masson d’Autume, and Lingpeng Kong. Adaptive semiparametric language models. ACL, 9:362–373, 2021.
|
| 287 |
+
|
| 288 |
+
Manzil Zaheer, Guru Guruganesh, Kumar Avinava Dubey, Joshua Ainslie, Chris Alberti, Santiago Ontañón, Philip Pham, Anirudh Ravula, Qifan Wang, Li Yang, and Amr Ahmed. Big bird: Transformers for longer sequences. In NeurIPS, 2020.
|
| 289 |
+
|
| 290 |
+
Yury Zemlyanskiy, Joshua Ainslie, Michiel de Jong, Philip Pham, Ilya Eckstein, and Fei Sha. Readtwice: Reading very large documents with memories. In ACL: Human Language Technologies, 2021.
|
| 291 |
+
|
| 292 |
+
Zhenhai Zhu and Radu Soricut. H-transformer-1d: Fast one-dimensional hierarchical attention for sequences. In ACL, 2021.
|
| 293 |
+
|
| 294 |
+
# A LENGTH OF INPUTS
|
| 295 |
+
|
| 296 |
+

|
| 297 |
+
|
| 298 |
+
Figure 9: Histogram of the number of tokens in arXiv math papers dataset. We tuncated the histogram at 500k tokens. The maximum paper had almost 1.6M tokens.
|
| 299 |
+
|
| 300 |
+

|
| 301 |
+
|
| 302 |
+
Figure 10: Histogram of the number of tokens in Github repositories dataset. We cut off the long tail of this plot. The repository with the maximum length has just over 9M tokens.
|
| 303 |
+
|
| 304 |
+

|
| 305 |
+
Figure 11: Histogram of the number of tokens in Isabelle proof scripts dataset.
|
| 306 |
+
|
| 307 |
+

|
| 308 |
+
Figure 12: Histogram of the number of tokens in PG19 books dataset.
|
| 309 |
+
|
| 310 |
+

|
| 311 |
+
Figure 13: Histogram of the number of tokens in C4 documents filtered by documents that have less than 4096 tokens.
|
| 312 |
+
|
| 313 |
+
# A.1 ABLATION STUDIES
|
| 314 |
+
|
| 315 |
+
In the following section, we performed ablation studies to investigate the effects of various hyperparameters. Unless otherwise specified, we carried out these experiments with a memorizing transformer with context size 512, XL cache 512 with a memory size of 8192.
|
| 316 |
+
|
| 317 |
+
Multiple $k \mathbf { N N }$ layers. We experimented with using two $k \mathbf { N N }$ layers, rather than just one. However, we did not see further benefits brought by more than multiple retrieval layers.
|
| 318 |
+
|
| 319 |
+
$k \mathbf { N N }$ layer index We experimented with adding the external memory to layer 3, 6, 9 and 12 in a 12-layer transformer, with results shown in Table 14. We found that adding memory to the middle of the layer stack will obtain the best result, whereas adding memory to layers either too close to the input or to the output obtained less gains.
|
| 320 |
+
|
| 321 |
+
Table 14: Different layer index.
|
| 322 |
+
|
| 323 |
+
<table><tr><td>Layer index</td><td>Perplexity</td></tr><tr><td>3</td><td>2.40</td></tr><tr><td>6</td><td>2.36</td></tr><tr><td>9</td><td>2.37</td></tr><tr><td>12</td><td>2.43</td></tr></table>
|
| 324 |
+
|
| 325 |
+
Number of neighbors We studied the effects of the number of neighbors we retrieve from memory, with results shown in Table 15. We found that even with 32 number of neighbors, we can already obtain a comparable results with 128 or 256 neighbors.
|
| 326 |
+
|
| 327 |
+
Table 15: Number of neighbors.
|
| 328 |
+
|
| 329 |
+
<table><tr><td>Number of neighbors</td><td>Perplexity</td></tr><tr><td>32</td><td>2.38</td></tr><tr><td>128</td><td>2.37</td></tr><tr><td>256</td><td>2.37</td></tr></table>
|
| 330 |
+
|
| 331 |
+
Random seeds We measured the statistical significant of the results reported. We did 3 runs with 3 random seeds for Transformer XL of size 512, and also a memorizing transformer with memory size 8192. We measured the standard deviation of perplexities after 500K steps of training, shown in Table 16. We saw the standard deviation between different runs of the same experiment appears to be much smaller than the gap between different models.
|
| 332 |
+
|
| 333 |
+
Table 16: Random seeds.
|
| 334 |
+
|
| 335 |
+
<table><tr><td>Models</td><td>Perplexity</td></tr><tr><td>Transformer XL</td><td>2.67± 0.01</td></tr><tr><td>Memorizing Transformer</td><td>2.37 ± 0.005</td></tr></table>
|
| 336 |
+
|
| 337 |
+
B WHAT DOES THE MODEL RETRIEVE FROM MEMORY?
|
| 338 |
+
|
| 339 |
+
Retrieving citation names On arXiv math, several examples are shown in Table 17, which includes both the retrieved token and its surrounding context. We observe that many of the gains in crossentropy loss took place when trying to predict the name of bibitems, citations, or references, by looking up the references and citations used previously in the paper. Such lookups usually span over the entire paper, which is much longer than 8192 tokens, providing a plausible explanation for the gain beyond memory size of 8192.
|
| 340 |
+
|
| 341 |
+
Table 17: The table shows several examples of which tokens were retrieved during language modelling of arXiv math dataset. The model is retrieving names of the references from previous passages.
|
| 342 |
+
|
| 343 |
+
<table><tr><td>Query index1</td><td>Input</td><td></td><td>tTargetSurrounding context</td><td></td><td>Retrieved index Retrieved surrounding context</td></tr><tr><td>20389</td><td>Mon</td><td>thus</td><td>bibitem{ComtetMonthusYor</td><td>2208</td><td>Brownian motion \cite{ComtetMonthus Yor</td></tr><tr><td>16623</td><td>cha</td><td>kra</td><td>\cite{ chakrabarti)</td><td>4677</td><td>~1.2 of\cite{chakrabarti</td></tr><tr><td>14747</td><td>as</td><td>d</td><td>\eqref( asdfg ) }which</td><td>3365</td><td>begin{equation}\n \labelt asdfg</td></tr></table>
|
| 344 |
+
|
| 345 |
+
Retrieving function names from the codebase As with the arXiv papers, we also studied which tokens the model retrieved from memory. As might be expected, the model is often looking up the names of functions, and variables, as shown in Table 18.
|
| 346 |
+
|
| 347 |
+
Table 18: Examples of memory retrieval in the Github dataset. The model looks up how functions are used elsewhere in the repository.
|
| 348 |
+
|
| 349 |
+
<table><tr><td>Query index</td><td>Input</td><td></td><td>TargetSurrounding context</td><td></td><td>Retrieved indexRetrieved surrounding context</td></tr><tr><td>23837</td><td>Fo</td><td>nte</td><td>menu_play-> setarFonte</td><td>14607</td><td>menu_load-> setarFonte</td></tr><tr><td>23825</td><td>,</td><td>35</td><td>hscreen/2-50,50,200,35 );</td><td>14599</td><td>20, y+40,200,35)</td></tr><tr><td>14546</td><td>-></td><td>adi</td><td>panel-> adicionaComponente</td><td>5205</td><td>panel-> adicionaComponente</td></tr></table>
|
| 350 |
+
|
| 351 |
+
# B.1 MORE RETRIEVING EXAMPLES IN FORMAL THEOREM PROVING CORPU
|
| 352 |
+
|
| 353 |
+
# Example 1
|
| 354 |
+
|
| 355 |
+
• Input token index: 64604
|
| 356 |
+
• Input token: “_”
|
| 357 |
+
• Target token: “pair”
|
| 358 |
+
• Surrounding context: )) by (simp add: Fourier_sum_limit_pair [OF f, symmetric] Fourier’ • Name needs to be predicted: Fourier_sum_limit_pair
|
| 359 |
+
• Retrieved token: “Four”
|
| 360 |
+
• Retrieved token index: 64412
|
| 361 |
+
• Retrieved context: $2 ^ { \ast } { \mathfrak { n } }$ . Fourier_coefficient f k \* trigonometric_set k t)
|
| 362 |
+
• Definition of the name: lemma Fourier sum limit pair: assumes"f absolutely_integrable_on {-pi..pi}" shows"(入n. Ck<2 \*n. Fourier_coefficient f k \* trigonometric _set k t) 1 $\longleftrightarrow$ (入n. k<n.Fourier_coefficient f k \*trigonometric_setk t) 1" (is "?lhs $=$ ?rhs")
|
| 363 |
+
|
| 364 |
+
# Example 2
|
| 365 |
+
|
| 366 |
+
• Input token index: 46175
|
| 367 |
+
• Input token: “tri”’
|
| 368 |
+
• Target token: “gon”
|
| 369 |
+
• Surrounding context: <le>n. a k \* trigonometric_set k x) Name needs to be predicted: orthonormal_system_trigonometric_set Retrieved token: “gon”
|
| 370 |
+
• Retrieved token index: 35457
|
| 371 |
+
• Retrieved context: lemma orthonormal_system_trigonometric_set: $\backslash \mathrm { n }$ "orthonormal_system
|
| 372 |
+
• Definition of the name:
|
| 373 |
+
|
| 374 |
+

|
| 375 |
+
Figure 19: Definition of Fourier_sum_limit_pair.
|
| 376 |
+
Figure 20: Definition of orthonormal_system_trigonometric_set.
|
| 377 |
+
|
| 378 |
+
# Example 3
|
| 379 |
+
|
| 380 |
+
• Input token index: 49760
|
| 381 |
+
• Input token: “sum”’
|
| 382 |
+
• Target token: “m”
|
| 383 |
+
• Surrounding context: nusing Fourier_series_square_summable [OF assms, of’
|
| 384 |
+
• Name needs to be predicted: Fourier_series_square_summable
|
| 385 |
+
• Retrieved token: “sum”
|
| 386 |
+
• Retrieved token index: 35457
|
| 387 |
+
• Retrieved context: lemma Fourier_series_square_summable\n assumes:
|
| 388 |
+
• Definition of the name:
|
| 389 |
+
|
| 390 |
+
Lemma Fourier series square summable: assumes os: "orthonormal_system $\textsf { S w } ^ { * }$ and w: "∧i. (w i) square_integrable S" and f: "f square integrable S" shows "summable (confine (λi. (orthonormal_coeff S w f i) $\sim 2$ ) I)"
|
| 391 |
+
|
| 392 |
+
Figure 21: Definition of Fourier_series_square_summable.
|
| 393 |
+
|
| 394 |
+
# Example 4
|
| 395 |
+
|
| 396 |
+
• Input token index: 49697
|
| 397 |
+
• Input token: “_”’
|
| 398 |
+
• Target token: “system”
|
| 399 |
+
• Surrounding context: lemma Riemann_lebesgue_square_integrable: nassumes "orthonormal_system S w
|
| 400 |
+
• Name needs to be predicted: orthonormal_system
|
| 401 |
+
• Retrieved token: “system”
|
| 402 |
+
• Retrieved token index: 28052
|
| 403 |
+
• Retrieved context: definition orthonormal_system :: "\’a::euclidean’
|
| 404 |
+
• Definition of the name:
|
| 405 |
+
|
| 406 |
+
definition orthonormal_system :: "'a::euclidean_space ${ \mathsf { s e t } } \Rightarrow ( ^ { \mathrm { ~ \iota ~ } } \mathsf { b } \Rightarrow ^ { \mathrm { ~ \iota ~ } } \mathsf { a } \Rightarrow \mathsf { r e a l } ) \Rightarrow \mathsf { b o o l } ^ { \mathrm { ~ \iota ~ } }$ where"orthonormal_system ${ \sf S } \ w \equiv \forall \mathfrak { m } \ \mathfrak { n }$ .l2product S (wm)(wn) $=$ (if m = n then 1 else 0)"
|
| 407 |
+
|
| 408 |
+
# Example 5
|
| 409 |
+
|
| 410 |
+
• Input token index: 34817
|
| 411 |
+
• Input token: “.”’
|
| 412 |
+
• Target token: “b”
|
| 413 |
+
• Surrounding context: shows "integrable (lebesgue_on {a..b})
|
| 414 |
+
• Retrieved token 1: “.”
|
| 415 |
+
• Retrieved token index 1: 2416
|
| 416 |
+
• Retrieved context 1: lebesgue_on {a..b}) f i
|
| 417 |
+
• Retrieved token 2: “-”
|
| 418 |
+
• Retrieved token index 2: 2445
|
| 419 |
+
• Retrieved context 2: (lebesgue_on {a-c..b-c}) (
|
| 420 |
+
• Retrieved token 3: “-”
|
| 421 |
+
• Retreived token index 3: 6479
|
| 422 |
+
• Retrieved context 3: (lebesgue_on {-pi..pi}) (
|
| 423 |
+
|
| 424 |
+
# Example 6
|
| 425 |
+
|
| 426 |
+
• Input token index: 49759
|
| 427 |
+
• Input token: “_”’
|
| 428 |
+
• Target token: “sum”
|
| 429 |
+
• Surrounding context: $0 " \backslash \mathtt { n }$ using Fourier_series_square_summable [OF assms
|
| 430 |
+
• Retrieved token 1: “set”
|
| 431 |
+
• Retrieved token index 1: 35044
|
| 432 |
+
• Retrieved context 1: definition trigonometric_set :: "nat \<Rightarrow>
|
| 433 |
+
• Retrieved token 2: “ier”
|
| 434 |
+
• Retrieved token index 2: 47272
|
| 435 |
+
• Retrieved context 2: definition Fourier_coefficient\nwhere
|
| 436 |
+
• Retrieved token 3: “ine”
|
| 437 |
+
• Retrieved token index 3: 18160
|
| 438 |
+
• Retrieved context 3: lemma Schwartz_inequality_strong:\nassumes “f’
|
| 439 |
+
• Retrieved token 4: “system”
|
| 440 |
+
• Retrieved token index 4: 28052
|
| 441 |
+
• Retrieved context 4: definition orthonormal_system :: “\’a::euclidean’
|
| 442 |
+
• Retrieved token 5: “<”
|
| 443 |
+
• Retrieved token index 5: 47241
|
| 444 |
+
• Retrieved context 5: subsection\<open>Convergence wrt the L’
|
| 445 |
+
• Retrieved token 6: “n”
|
| 446 |
+
• Retrieved token index 6: 40835
|
| 447 |
+
• Retrieved context 6: \n subsection\<open>A bit of extra’
|
md/dev/TwyEk7HzJb6/TwyEk7HzJb6.md
ADDED
|
@@ -0,0 +1,440 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Bandit Learning in Many-to-one Matching Markets with Uniqueness Conditions
|
| 2 |
+
|
| 3 |
+
Anonymous Author(s)
|
| 4 |
+
Affiliation
|
| 5 |
+
Address
|
| 6 |
+
email
|
| 7 |
+
|
| 8 |
+
# Abstract
|
| 9 |
+
|
| 10 |
+
1 An emerging line of research is dedicated to the problem of one-to-one matching
|
| 11 |
+
2 markets with bandits, where the preference of one side is unknown and thus we
|
| 12 |
+
3 need to match while learning the preference through multiple rounds of interaction.
|
| 13 |
+
4 However, in many real-world applications such as online recruitment platform for
|
| 14 |
+
5 short-term workers, one side of the market can select more than one participant from
|
| 15 |
+
6 the other side, which motivates the study of the many-to-one matching problem.
|
| 16 |
+
7 Moreover, the existence of a unique stable matching is crucial to the competitive
|
| 17 |
+
8 equilibrium of the market. In this paper, we first introduce a more general new $\tilde { \alpha }$ -
|
| 18 |
+
9 condition to guarantee the uniqueness of stable matching in many-to-one matching
|
| 19 |
+
10 problems, which generalizes some established uniqueness conditions such as $S P C$
|
| 20 |
+
11 and Serial Dictatorship, and recovers the known $\alpha$ -condition if the problem is
|
| 21 |
+
12 reduced to one-to-one matching. Under this new condition, we design an MO
|
| 22 |
+
13 UCB-D4 algorithm with $\begin{array} { r } { O \left( \frac { N K \log \left( T \right) } { \Delta ^ { 2 } } \right) } \end{array}$ regret bound, where $T$ is the time horizon,
|
| 23 |
+
14 $N$ is the number of agents, $K$ is the number of arms, and $\Delta$ is the minimum
|
| 24 |
+
15 reward gap. Extensive experiments show that our algorithm achieves uniform good
|
| 25 |
+
16 performances under different uniqueness conditions.
|
| 26 |
+
|
| 27 |
+
# 17 1 Introduction
|
| 28 |
+
|
| 29 |
+
18 The rise of platforms for the online matching market has led to an emergence of opportunities for
|
| 30 |
+
19 companies to participate in personalized decision-making [14, 18]. Companies (like Thumbtack
|
| 31 |
+
20 and Taskrabbit and Upwork platforms) use online platforms to address short-term needs or seasonal
|
| 32 |
+
21 spikes in production demands, accommodate workers who are voluntarily looking for more flexible
|
| 33 |
+
22 work arrangements or probation period before permanent employment. The supply and demand
|
| 34 |
+
23 sides in two-sided markets make policies on the basis of their diversified needs, which is abstracted
|
| 35 |
+
24 as a matching market with agent side and arm side, and each side has a preference profile over the
|
| 36 |
+
25 opposite side. They choose from the other side according to preference and perform a matching. The
|
| 37 |
+
26 stability of the matching result is a key property of the market [32, 1, 27].
|
| 38 |
+
27 The preferences in the online labor market may be unknown to one side in advance, thus matching
|
| 39 |
+
28 while learning the preferences is necessary. The multi-armed bandit (MAB) [36, 13, 4] is an important
|
| 40 |
+
29 tool for $N$ independent agents in matching market simultaneously selecting arms adaptively from
|
| 41 |
+
30 received rewards at each round. The idea of applying MAB to one-to-one matching problems,
|
| 42 |
+
31 introduced by [21], assumes that there is a central platform to make decisions for all agents. Following
|
| 43 |
+
32 this, other works [22, 34, 7] consider a more general decentralized setting where there is no central
|
| 44 |
+
33 platform to arrange matchings, and our work is also based on this setting.
|
| 45 |
+
34 However, it is not enough to just study the one-to-one setting. Take online short-term worker
|
| 46 |
+
35 employment as an example, it is an online platform design with an iterative matching, where
|
| 47 |
+
36 employers have numerous similar short-term tasks or internships to be recruited. Workers can only
|
| 48 |
+
37 choose one task according to the company’s needs at a time while one company can accept more
|
| 49 |
+
38 than one employee. Each company makes a fixed ranking for candidates according to its own
|
| 50 |
+
39 requirements but workers have no knowledge of companies’ preferences. The reward for workers
|
| 51 |
+
40 is a comprehensive consideration of salary and job environment. Since tasks are short-term, each
|
| 52 |
+
41 candidate can try many times in different companies to choose the most suitable job. We abstract
|
| 53 |
+
42 companies as arms and workers as agents. Each arm has a capacity $q$ which is the maximum number
|
| 54 |
+
43 of agents this arm can accommodate. When an arm faces multiple choices, it accepts its most $q$
|
| 55 |
+
44 preferred agents. Agents thus compete for arms and may receive zero reward if losing the conflict. It
|
| 56 |
+
45 is worth mentioning that arms with capacity $q$ in the many-to-one matching can not just be replaced
|
| 57 |
+
46 by $q$ independent individuals with the same preference since there would be implicit competition
|
| 58 |
+
47 among different replicates of this arm, not equal treatment. In addition, when multiple agents select
|
| 59 |
+
48 one arm at a time, there may be no collision, which will hinder the communication among different
|
| 60 |
+
49 agents under the decentralized assumption. They cannot distinguish who is more preferred by this
|
| 61 |
+
50 arm in one round as it can accept more than one agent while this can be done in one-to-one case.
|
| 62 |
+
51 Communication here lets each agent learn more about the preferences of arms and other agents, so as
|
| 63 |
+
52 to formulate better policies to reduce collisions and learn fast about their stable results.
|
| 64 |
+
53 This work focuses on a many-to-one market under uniqueness conditions. Previous work [10, 15]
|
| 65 |
+
54 emphasize the importance of constructing a unique stable matching for the equilibrium of matching
|
| 66 |
+
55 problems and some existing uniqueness conditions are studied in many-to-one matching, such as
|
| 67 |
+
56 Sequential Preference Condition (SPC) and Acyclicity [26, 2]. Our work is motivated by [7], but the
|
| 68 |
+
57 unique one-to-one mapping between arms and agents in their study which gives a surrogate threshold
|
| 69 |
+
58 for arm elimination does not work in the many-to-one setting. And the uniqueness conditions in
|
| 70 |
+
59 many-to-one matching are not well-studied, which also brings a challenge to identify and leverage
|
| 71 |
+
60 the relationship between the resulting stable matching and preferences of two sides in the design
|
| 72 |
+
61 of bandit algorithms. We propose an $\tilde { \alpha }$ -condition that can guarantee a unique stable matching and
|
| 73 |
+
62 recover $\alpha$ -condition [19] if reduced to the one-to-one setting. We establish the relationships between
|
| 74 |
+
63 our new $\tilde { \alpha }$ -condition and existing uniqueness conditions in many-to-one setting.
|
| 75 |
+
64 In this paper, we study the bandit algorithm for a decentralized many-to-one matching market
|
| 76 |
+
65 with uniqueness conditions. Under our newly introduced $\tilde { \alpha }$ -condition, we design an MO-UCB-D4
|
| 77 |
+
66 algorithm with arm elimination and the regret can be upper bounded by $\begin{array} { r } { O \left( \frac { N K \log ( T ) } { \Delta ^ { 2 } } \right) } \end{array}$ , where $N$
|
| 78 |
+
67 is the number of agents, $K$ is the number of arms, and $\Delta$ is the minimum reward gap. Finally,
|
| 79 |
+
68 we conduct a series of experiments to simulate our algorithm under various conditions of Serial
|
| 80 |
+
69 dictatorship, $S P C$ and $\tilde { \alpha }$ -condition to study the stability and regret of the algorithm.
|
| 81 |
+
70 Related Work The study of matching markets has a long history in economics and operation
|
| 82 |
+
71 research [8, 6, 32] with real applications like school enrollment, labor employment, hospital resource
|
| 83 |
+
72 allocation, and so on [1, 23, 31, 17]. A salient feature of market matching is making decisions for
|
| 84 |
+
73 competing players on both sides [36, 12]. MAB is an important tool to study matching problems under
|
| 85 |
+
74 uncertainty to obtain a maximum reward, and upper confidence bound algorithm (UCB) [4] is a typical
|
| 86 |
+
75 algorithm, which sets a confidence interval to represent uncertainty. Matching market with MAB is
|
| 87 |
+
76 studied in both centralized and decentralized setting [21, 22]. Following these, Abishek Sankararaman
|
| 88 |
+
77 et al. [34] propose a phased UCB algorithm under a uniqueness condition, Serial Dictatorship, to
|
| 89 |
+
78 manage collisions. They solve the problem of the decentralized market without knowing arm-gaps
|
| 90 |
+
79 or time horizon, and reduce the probability of linear regret through non-monotonic arm elimination.
|
| 91 |
+
80 The introduction of the uniqueness condition plays an important role in the equilibrium of matching
|
| 92 |
+
81 results [15, 7]. Under a stronger and robust condition, Uniqueness Consistency [19], Soumya Basu
|
| 93 |
+
82 et.al [7] apply MAB to online matching and obtain robust results that the subset of stable matchings
|
| 94 |
+
83 being separated from the system does not affect other stable matchings.
|
| 95 |
+
84 We discuss many-to-one problems such as online short-term employment and MOOC [14, 24, 18] as
|
| 96 |
+
85 the one-to-one setting has limitations in practice. Somouaoga Bonkoungo [9] runs a student-proposing
|
| 97 |
+
86 deferred acceptance algorithm (DA) [12] to study decentralized college admission. Ahmet Altinok
|
| 98 |
+
87 [3] considers dynamic matching in many-to-one that can be solved as if it is static many-to-one or
|
| 99 |
+
88 dynamic one-to-one under certain assumptions. As the existence and uniqueness of competitive
|
| 100 |
+
89 equilibrium and core are important to allocations, the unique stable results need to be considered [27].
|
| 101 |
+
90 Similar to conditions for unique stable matching in one-to-one, some uniqueness conditions of stable
|
| 102 |
+
91 results in the many-to-one setting also are studied [16, 28, 15, 2, 27].
|
| 103 |
+
93 This paper considers a many-to-one matching market $\mathcal { M } = ( \mathcal { K } , \mathcal { I } , \mathcal { P } )$ , where $\begin{array} { r } { \mathcal { K } = [ K ] , \mathcal { T } = [ N ] } \end{array}$
|
| 104 |
+
94 are a finite arm set and a finite agent set, respectively. And each arm $k$ has a capacity $q _ { k } \geq 1$ . To
|
| 105 |
+
95 guarantee that no agents will be unmatched, we focus on the market with $\begin{array} { r } { N \leq \sum _ { i = 1 } ^ { K } q _ { i } } \end{array}$ . $\mathcal { P }$ is the
|
| 106 |
+
96 fixed preference order of agents and arms, which is ranked by the mean reward. We assume that arm
|
| 107 |
+
97 preferences for agents are unknown and needed to be learned. If agent $j$ prefers arm $k$ over $k ^ { \prime }$ , which
|
| 108 |
+
98 also means that $\mu _ { j , k } > \mu _ { j , k ^ { \prime } }$ , we denote by $k \succ j \ k ^ { \prime }$ . And the preference is strict that $\mu _ { j , k } \neq \mu _ { j , k ^ { \prime } }$ if
|
| 109 |
+
99 $k \neq k ^ { \prime }$ . Similarly, each arm $k$ has a fixed and known preference $\succ _ { k }$ over all agents, and specially,
|
| 110 |
+
100 $j \succ _ { k } j ^ { \prime }$ means that arm $k$ prefers agent $j$ over $j ^ { \prime }$ . Throughout, we focus on the market where all
|
| 111 |
+
101 agent-arm pairs are mutually acceptable, that is, $j \succ _ { k } \emptyset$ and $k \succ _ { j } \emptyset$ for all $k \in [ K ]$ and $j \in [ N ]$ .
|
| 112 |
+
102 Let mapping $m$ be the matching result. $m _ { t } ( j )$ is the matched arm for agent $j$ at time $t$ , and $\gamma _ { t } ( k )$ is
|
| 113 |
+
103 the agents set matched with arm $k ^ { 1 }$ . Every time agent $j$ selects an arm $I _ { t } ( j )$ , and we use $M _ { t } ( j )$ to
|
| 114 |
+
104 denote whether $j$ is successfully matched with its selected arm. $M _ { t } ( j ) = 1$ if agent $j$ is matched with
|
| 115 |
+
105 $I _ { t } ( j )$ , and $M _ { t } ( j ) = 0$ , otherwise. If multiple agents select arm $k$ at the same time, only top $q _ { k }$ agents
|
| 116 |
+
106 can successfully match. The agent $j$ matched with arm $k$ can observe the reward $X _ { j , m _ { t } ( j ) } ( t )$ , where
|
| 117 |
+
107 the random reward $X _ { j , k } ( t ) \in [ 0 , 1 ]$ is independently drawn from a fixed distribution with mean $\mu _ { j , k }$ .
|
| 118 |
+
108 While the unmatched ones have collisions and receive zero reward. Generally, the reward obtained by
|
| 119 |
+
109 agent $j$ is $X _ { j , I _ { t } ( j ) } ( t ) \ M _ { t } ( j )$ .
|
| 120 |
+
110 An agent $j$ and an arm $k$ form a blocking pair for a matching $m$ if they are not matched but prefer
|
| 121 |
+
111 each other over their assignments, i.e. $k \succ _ { j } m ( j )$ and $\exists j ^ { \prime } \in \gamma ( k ) , j \succ _ { k } j ^ { \prime }$ . We say a matching
|
| 122 |
+
112 satisfies individually rationality (IR), if $a _ { j } \succ p _ { i } \emptyset$ and $p _ { i } \succ _ { a _ { j } } \varnothing$ for all $i \in [ N ]$ and $j \in [ K ]$ , that is,
|
| 123 |
+
113 every worker prefers to find a job rather than do nothing, and every company also wants to recruit
|
| 124 |
+
114 workers rather than not recruit anyone. Under the IR condition, a matching in the many-to-one setting
|
| 125 |
+
115 is stable if there does not exist a blocking pair [33, 35].
|
| 126 |
+
116 This paper considers the matching markets under the uniqueness condition. Thus the overall goal is
|
| 127 |
+
117 to find the unique stable matching between the agent side and arm side through iterations. Let $m ^ { * } ( j )$
|
| 128 |
+
118 be the stable matched arm for agent $j$ under the stable matching $m ^ { * }$ . The reward obtained by agent $j$
|
| 129 |
+
119 is compared against the reward received by matching with $m ^ { * } ( j )$ at each time. We aim to minimize
|
| 130 |
+
120 the expected stable regret for agent $j$ over time horizon $T$ , which is defined as
|
| 131 |
+
|
| 132 |
+
$$
|
| 133 |
+
R _ { j } ( T ) = T \mu _ { j , m ^ { * } ( j ) } - \mathbb { E } \left[ \sum _ { t = 1 } ^ { T } M _ { t } ( j ) X _ { j , I _ { t } ( j ) } ( t ) \right] .
|
| 134 |
+
$$
|
| 135 |
+
|
| 136 |
+
# 121 3 Algorithm
|
| 137 |
+
|
| 138 |
+
122 In this section, we introduce our MO-UCB-D4 Algorithm (Many-to-one UCB with Decentralized
|
| 139 |
+
123 Dominated arms Deletion and Local Deletion Algorithm) (Algorithm 1) for the decentralized many
|
| 140 |
+
124 to-one market, where there is no platform to arrange actions for agents, which leads to conflicts
|
| 141 |
+
125 among agents. The MO-UCB-D4 algorithm for each agent $j$ first takes agent set $\mathcal { I }$ and arm set $\kappa$ a s
|
| 142 |
+
126 input and chooses a parameter $\theta \in ( 0 , 1 / K )$ (discussed in Section C). It sets multiple phases, and
|
| 143 |
+
127 each phase $i$ mainly includes regret minimization block (line 6 - 12) and communication block (line
|
| 144 |
+
128 $1 3 - 1 6 )$ ) with duration $2 ^ { i - 1 } , i = { \bar { 1 } } , 2 , \cdots$ .
|
| 145 |
+
129 For each agent $j$ in phase $i$ , the algorithm adds arm deletion to reduce potential conflicts, which
|
| 146 |
+
130 mainly contains global deletion and local deletion. The former eliminates the arms most preferred
|
| 147 |
+
131 by agents who rank higher than agent $j$ and obtain active set $\mathrm { C h } _ { j } [ i ]$ (line 4), and the latter deletes
|
| 148 |
+
132 the arms that still have many conflicts with agent $j$ after global deletion (line 6). We set a collision
|
| 149 |
+
133 counter $C _ { j , k } [ i ]$ to record the number of collisions for agent $j$ pulling arm $k$ .
|
| 150 |
+
|
| 151 |
+
In regret minimization block of phase $i$ , we use $L _ { j } [ i ] = \{ k : C _ { j , k } [ i ] \geq \lceil \theta 2 ^ { i } \rceil \}$ to represent the arms that collide more times than a threshold $\lceil \theta 2 ^ { i } \rceil$ when matching with agent $j$ . Arms in $L _ { j } [ i ]$ are first locally deleted to reduce potential collisions for agent $j$ (line 6). After that, agent $j$ selects an optimal action $I _ { t } ( j )$ from remaining arms in $\mathrm { C h } _ { j } [ i ] \backslash L _ { j } [ i ]$ in phase $i$ according to UCB index, which is computed by $\begin{array} { r } { \hat { \mu } _ { j , k } ( t - 1 ) + \sqrt { \frac { 2 \alpha \log ( t ) } { N _ { j , k } ( t - 1 ) } } } \end{array}$ (line 7), where $N _ { j , k } ( t - 1 )$ is the number that agent $j$ and arm
|
| 152 |
+
|
| 153 |
+
# Algorithm 1 MO-UCB-D4 algorithm (for agent $j$ )
|
| 154 |
+
|
| 155 |
+
Input:
|
| 156 |
+
$\theta \in ( 0 , 1 / K )$ , $\alpha > 1$ .
|
| 157 |
+
1: Set global dominated set $G _ { j } [ 0 ] = \phi$
|
| 158 |
+
2: for phase $i = 1 , 2 , \dots$ do
|
| 159 |
+
3: Reset the collision set $C _ { j , k } [ i ] = 0$ , $\forall k \in [ K ]$ ;
|
| 160 |
+
4: Reset active arms set $\begin{array} { r } { \dot { \mathsf { C h } _ { j } } [ i ] = [ K ] \backslash G _ { j } [ i - 1 ] } \end{array}$ ;
|
| 161 |
+
5: if $t < 2 ^ { i } + N K ( i - 1 )$ then
|
| 162 |
+
6: Local deletion $L _ { j } [ i ] = \{ k : C _ { j k } [ i ] \geq \lceil \theta 2 ^ { i } \rceil \}$ ;
|
| 163 |
+
7: Play arm $\begin{array} { r } { I _ { t } ( j ) \in \underset { k \in \mathtt { C h } _ { j } [ i ] \backslash L _ { j } [ i ] } { \arg \operatorname* { m a x } } \left( \hat { \mu } _ { j , k } ( t - 1 ) + \sqrt { \frac { 2 \alpha \log ( t ) } { N _ { j , k } ( t - 1 ) } } \right) ; } \end{array}$
|
| 164 |
+
8: if $k = I _ { t } ( j )$ is successfully matched with agent $j$ , i.e. $m _ { t } ( j ) = k$ then
|
| 165 |
+
9: Update estimate $\hat { \mu } _ { j , k } ( t )$ and matching count $N _ { j , k } ( t )$ ;
|
| 166 |
+
10: else
|
| 167 |
+
11: $C _ { j , k } [ i ] = C _ { j , k } [ i ] + 1 ;$
|
| 168 |
+
12: end if
|
| 169 |
+
13: else if $t = 2 ^ { i } + N K ( i - 1 )$ then
|
| 170 |
+
14: $\mathcal { O } _ { j } [ i ] \mathrm { m o s t }$ matched arm in phase $i$ ;
|
| 171 |
+
15: $G _ { j } \bar { [ } i ] C O M M U N I C A T I O N ( i , { \mathcal { O } } _ { j } [ i ] ) ;$ ;
|
| 172 |
+
16: end if
|
| 173 |
+
17: end for
|
| 174 |
+
139 $k$ have been matched at time $t - 1$ . If the selected arm is successfully matched with agent $j$ , then the
|
| 175 |
+
140 algorithm updates estimated reward $\begin{array} { r } { \hat { \mu } _ { j , k } ( t ) = \frac { 1 } { N _ { j , k } ( t ) } \sum _ { s = 1 } ^ { t } 1 \{ I _ { s } ( j ) = k } \end{array}$ and $M _ { s } ( j ) = 1 \} X _ { j , k } ( t )$
|
| 176 |
+
141 and $N _ { j , k } ( t )$ (line 9). Otherwise, the collision happens (line 11) and $j$ receives zero reward. The
|
| 177 |
+
142 regret minimization block identifies the most played arm $\mathcal { O } _ { j } [ i ]$ for agent $j$ in each phase $i$ , which is
|
| 178 |
+
143 estimated as the best arm for $j$ , thus making optimal policy to minimize expected regret.
|
| 179 |
+
|
| 180 |
+
# Algorithm 2 COMMUNICATION
|
| 181 |
+
|
| 182 |
+
#
|
| 183 |
+
|
| 184 |
+
Phase number $i$ , and most played arms $\mathcal { O } _ { j } [ i ]$ for agent $j , \forall j \in [ N ]$ .
|
| 185 |
+
1: Set ${ \mathcal { C } } = \emptyset$ ;
|
| 186 |
+
2: for $t = 1 , 2 , \cdots , N K - 1$ do
|
| 187 |
+
3: if $K ( j - 1 ) \le t \le K j - 1$ then
|
| 188 |
+
4: Agent $j$ plays arm $\begin{array} { r } { \bar { I } _ { t } ( j ) = ( t \mod K ) + 1 } \end{array}$ ;
|
| 189 |
+
5: if Collision Occurs then
|
| 190 |
+
6: $\mathcal { C } = \mathcal { C } \cup \{ I _ { t } ( j ) \}$ ;
|
| 191 |
+
7: end if
|
| 192 |
+
8: else
|
| 193 |
+
9: Play arm $I _ { t } ( j ) = \mathcal { O } _ { j } [ i ]$ ;
|
| 194 |
+
10: end if
|
| 195 |
+
11: end for
|
| 196 |
+
12: RETURN $\mathcal { C }$ ;
|
| 197 |
+
144 In the communication block (Algorithm 2), there are $N$ sub-blocks, each with duration $K$ . In the
|
| 198 |
+
145 $\ell - t h$ sub-block, only agent $\ell$ pulls arm 1, arm $2 , \cdots$ , arm $K$ in round-robin while the other agents
|
| 199 |
+
146 select their most preferred arms estimated as the most played ones (line 4). This block aims to detect
|
| 200 |
+
147 globally dominated arms for agent $j \colon G _ { j } [ i ] \subset \{ \mathcal { O } _ { j ^ { \prime } } [ i ] : j ^ { \prime } \succ _ { \mathcal { O } _ { j ^ { \prime } } [ i ] } j \}$ . Under stable matching $m ^ { * }$ , the
|
| 201 |
+
148 globally dominated arms set for agent $j$ is denoted as $G _ { j } ^ { * }$ . After the communication block in phase
|
| 202 |
+
149 $i$ , each agent $j$ updates its active arms set $\mathtt { C h } _ { j } [ i + 1 ]$ for phase $i + 1$ , by globally deleting arms set
|
| 203 |
+
150 $G _ { j } [ i ]$ , and enters into the next phase (line 4 in Algorithm 1).
|
| 204 |
+
151 Hence, multi-phases setting can guarantee that the active set in different phases has no inclusion
|
| 205 |
+
152 relationship so that if an agent deletes an arm in a certain phase, this arm can still be selected in the
|
| 206 |
+
153 later rounds. This ensures that each agent will not permanently eliminate its stable matched arm, and
|
| 207 |
+
154 when the agent mistakenly deletes an arm, it will not lead to linear regret.
|
| 208 |
+
|
| 209 |
+
# 4 Results
|
| 210 |
+
|
| 211 |
+
# 4.1 Uniqueness Conditions
|
| 212 |
+
|
| 213 |
+
# 4.1.1 $\tilde { \alpha }$ -condition
|
| 214 |
+
|
| 215 |
+
Constructing a unique stable matching plays an important role in market equilibrium and fairness [10, 15]. With uniqueness, there would be no dispute about adopting stable matching preferred by which side, thus it is more fair. When the preferences of agents and arms are given by some utility functions instead of random preferences, like the payments for workers in the labor markets, the stable matching is usually unique. Thus the assumption of the unique stable matching is quite common in real applications. In this section, we propose a new uniqueness condition, $\tilde { \alpha }$ -condition. First, we introduce uniqueness consistency (Unqc) [19], which guarantees robustness and uniqueness of markets.
|
| 216 |
+
|
| 217 |
+
Definition 1. A preference profile satisfies uniqueness consistency if and only if (i) there exists a unique stable matching $m ^ { * }$ ;
|
| 218 |
+
|
| 219 |
+
(ii) for any subset of arms or agents, the restriction of the preference profile on this subset with their stable-matched pair has a unique stable matching.
|
| 220 |
+
|
| 221 |
+
170 It guarantees that even if an arbitrary subset of agents are deleted out of the system with their
|
| 222 |
+
171 respective stable matched arms, there still exists a unique stable matching among the remaining
|
| 223 |
+
172 agents and arms. This condition allows any algorithm to identify at least one stable pair in a unique
|
| 224 |
+
173 stable matching system and guides the system to a global unique stable matching in an iterative
|
| 225 |
+
174 manner. To obtain consistent stable results in the many-to-one market, we propose a new $\tilde { \alpha }$ -condition,
|
| 226 |
+
175 which is a sufficient and necessary condition for Unqc (proved in Appendix B).
|
| 227 |
+
176 We considers a finite set of arms $[ K ] = \{ 1 , 2 , \cdots , K \}$ and a finite set of agents $[ N ] = \{ 1 , 2 , \cdots , N \}$
|
| 228 |
+
177 with preference profile $\mathcal { P }$ . Assume that $[ N ] _ { r } { = } \{ A _ { 1 } , A _ { 2 } , \dotsb , A _ { N } \}$ is a permutation of $\{ 1 , 2 , \cdots , N \}$
|
| 229 |
+
178 and $[ K ] _ { r } = \{ c _ { 1 } , c _ { 2 } , \cdot \cdot \cdot , c _ { K } \}$ is a permutation of $\{ 1 , 2 , \cdots , K \}$ . Denote $[ N ] , [ K ]$ as the left order and
|
| 230 |
+
179 $[ N ] _ { r } , [ K ] _ { r }$ as the right order. The $k$ -th arm in the right order set $[ K ] _ { r }$ has the index $c _ { k }$ in the left
|
| 231 |
+
180 order set $[ K ]$ and the $j$ -th agent in the right order set $[ N ] _ { r }$ has the index $A _ { j }$ in the left order set $[ N ]$
|
| 232 |
+
181 Considering arm capacity, we denote $\gamma ^ { * } ( c _ { k } )$ (right order) as the stable matched agents set for arm $c _ { k }$
|
| 233 |
+
|
| 234 |
+
182 Definition 2. A many-to-one matching market satisfies the $\tilde { \alpha }$ -condition $i f ,$ , (i) The left order of agents and arms satisfies
|
| 235 |
+
|
| 236 |
+
$$
|
| 237 |
+
\forall j \in [ N ] , \forall k > j , k \in [ K ] , \mu _ { j , m ^ { * } ( j ) } > \mu _ { j , k } ,
|
| 238 |
+
$$
|
| 239 |
+
|
| 240 |
+
where 183 $m ^ { * } ( j )$ is agent $j$ ’s stable matched arm;
|
| 241 |
+
|
| 242 |
+
(ii) The right order of agents and arms satisfies
|
| 243 |
+
|
| 244 |
+
$$
|
| 245 |
+
\begin{array} { r } { \forall k < k ^ { \prime } \leq K , c _ { k } \in [ K ] _ { r } , A _ { k ^ { \prime } } \subset [ N ] _ { r } , \gamma ^ { * } ( c _ { k } ) \succ _ { c _ { k } } A _ { \sum _ { i = 1 } ^ { k ^ { \prime } - 1 } q _ { c _ { i } } + 1 } , } \end{array}
|
| 246 |
+
$$
|
| 247 |
+
|
| 248 |
+
where the set 184 $\gamma ^ { * } ( c _ { k } )$ is more preferred than $A _ { \sum { k = 1 } ^ { k ^ { \prime } - 1 } q _ { c _ { i } } + 1 }$ means that the least preferred agent in γ∗(ck) for ck is better than APk′−1i=1 q185 $A _ { \sum _ { i = 1 } ^ { k ^ { \prime } - 1 } q _ { c _ { i } } + 1 } f o r c _ { k }$
|
| 249 |
+
|
| 250 |
+
186 Under our $\tilde { \alpha }$ -condition, the left order and the right order satisfy the following rule. The left order
|
| 251 |
+
187 gives rankings according to agents’ preferences. The first agent in the left order set $[ N ]$ prefers arm 1
|
| 252 |
+
188 in $[ K ]$ most and has it as the stable matched arm. Similar properties for the agent 2 to $q _ { 1 }$ since arm 1
|
| 253 |
+
189 has $q _ { 1 }$ capacity. Then the $( q _ { 1 } + 1 )$ -th agent in the left order set $[ N ]$ has arm 2 in $[ K ]$ as her stable
|
| 254 |
+
190 matched arm and prefers arm 2 most except arm 1. The remaining agents follow similarly. Similarly,
|
| 255 |
+
191 the right order gives rankings according to arms’ preferences. The first arm 1 in the right order set
|
| 256 |
+
192 $[ K ] _ { r }$ most prefers first $q _ { c _ { 1 } }$ agents in the right order set $[ N ] _ { r }$ and takes them as its stable matched
|
| 257 |
+
193 agents. The remaining arms follow similarly.
|
| 258 |
+
194 This condition is more general than existing uniqueness conditions like SPC [28] and can recover
|
| 259 |
+
195 the known $\alpha$ -condition in one-to-one matching market [19]. The relationship between the existing
|
| 260 |
+
196 uniqueness conditions and our proposed conditions will be analyzed in detail later in Section 4.1.2.
|
| 261 |
+
197 The main idea from one-to-one to many-to-one analysis is to replace individuals with sets. In
|
| 262 |
+
198 general, under $\tilde { \alpha }$ -condition, the left order satisfies that when arm 1 to arm $k - 1$ are removed, agents
|
| 263 |
+
|
| 264 |
+
$\textstyle { \bigl ( } \sum _ { i = 1 } ^ { k - 1 } q _ { i } + 1 { \bigr ) }$ to $\textstyle { \bigl ( } \sum _ { i = 1 } ^ { k } q _ { i } { \bigr ) }$ prefer $k$ most, and the right order means that when $A _ { 1 }$ to agents $A _ { \sum { i = 1 } } { _ { q _ { i } } }$ are removed, arm $k$ prefers agents $\begin{array} { r } { \mathcal { A } _ { k } = \{ A _ { \sum _ { i = 1 } ^ { k - 1 } q _ { c _ { i } } + 1 } , A _ { \sum _ { i = 1 } ^ { k - 1 } q _ { c _ { i } } + 2 } , \cdot \cdot \cdot , A _ { \sum _ { i = 1 } ^ { k } q _ { c _ { i } } } \} } \end{array}$ where $\mathcal { A } _ { k }$ is the agent set that are most preferred by arm $k$ among those who have not been matched by arm $1 , 2 , \cdots , k - 1$ . Te next theorem give a summary.
|
| 265 |
+
|
| 266 |
+
Theorem 1. If a market $\mathcal { M } ~ = ~ ( \mathcal { K } , \mathcal { I } , \mathcal { P } )$ satisfies $\tilde { \alpha }$ -condition, then $m ^ { * } ( \sum _ { i = 1 } ^ { j - 1 } q _ { i } + 1 ) \ =$ $m ^ { * } ( \sum _ { i = 1 } ^ { j - 1 } q _ { i } + 2 ) = \cdot \cdot \cdot = m ^ { * } ( \sum _ { i = 1 } ^ { j } q _ { i } ) = j$ (the left order), $\gamma ^ { * } ( c _ { k } ) = \mathcal { A } _ { k }$ and $m ^ { * } ( { \mathcal { A } } _ { j } ) = c _ { j }$ (the right order) under stable matching.
|
| 267 |
+
|
| 268 |
+
Under $\tilde { \alpha }$ -condition, the stable matched arm may not be the most preferred one for each agent $j$ $j \in [ N ]$ , thus (i) we do not have $m ^ { * } ( j )$ to be dominated only by the agent 1 to agent $j - 1$ , i.e. there may exist $j ^ { \prime } > j$ , s.t. $j ^ { \prime } \succ _ { m ^ { * } ( j ) } j$ ; (ii) the left order may not be identical to the right order, we define a mapping $l r$ to match the index of an agent in the left order with the index in the right order, i.e. $A _ { l r ( j ) } = j$ . From Theorem 1, the stable matched set for arm $k$ is its first $q _ { k }$ preferred agents $\gamma ^ { * } ( c _ { k } ) = \mathcal { A } _ { k }$ . We define $l r$ as $l r ( i ) = \operatorname* { m a x } \{ j : A _ { j } \in \gamma ^ { * } ( m ^ { * } ( i ) ) , j \in [ N ] \}$ , that is, in the right order, the mapping for arm $k \in [ K ]$ is the least preferred one among its most $q _ { k }$ preferred agents. Note that this mapping is not an injective, i.e. $\exists j , j ^ { \prime }$ , s.t. agent $j = A _ { l r ( j ) } = A _ { l r ( j ^ { \prime } ) }$ . An intuitive representation can be seen in Figure 4 in Appendix A.1.
|
| 269 |
+
|
| 270 |
+
# 4.1.2 Unique Stable Conditions in Many-to-one Matching
|
| 271 |
+
|
| 272 |
+
Uniqueness consistency (Unqc) leads the stable matching to a robust one which is a desirable property in large dynamic markets with constant individual departure [7]. A precondition of Unqc is to ensure global unique stability, hence finding uniqueness conditions is essential.
|
| 273 |
+
|
| 274 |
+
The existing unique stable conditions are well established in one-to-one setting (analysis can be found in Appendix B), and in this section, we focus on uniqueness conditions in many-to-one market, such as SPC, [28], Aligned Preference, Serial Dictatorship Top-top match and Acyclicity [26, 2, 28] (Definition 9, 7, 8, 10 in Appendix B.2). Takashi Akahoshi [2] proposes a necessary and sufficient condition for uniqueness of stable matching in many-to-one matching where unacceptable agents and arms may exist on both sides. We denote their condition as Acyclicity∗. Under our setting, both two sides are acceptable, and we first give the proof of that Acyclicity∗ is a necessary and sufficient condition for uniqueness in this setting (see Section B.2.4 in Appendix B). We then give relationships between our newly $\tilde { \alpha }$ -condition and other existing uniqueness conditions, intuitively expressed in Figure 1, and we give proof for this section in Appendix B.2.
|
| 275 |
+
|
| 276 |
+
Lemma 1. In a many-to-one matching market $\mathcal { M } = ( \mathcal { K } , \mathcal { I } , \mathcal { P } )$ , both Serial Dictatorship and Aligned Preference can produce a unique stable matching and they are equivalent.
|
| 277 |
+
|
| 278 |
+
31 Theorem 2. In a many-to-one matching market $\mathcal { M } = ( \mathcal { K } , \mathcal { I } , \mathcal { P } )$ , our $\tilde { \alpha }$ -condition satisfies:
|
| 279 |
+
|
| 280 |
+
(i) SPC is a sufficient condition to $\tilde { \alpha }$ -condition;
|
| 281 |
+
|
| 282 |
+
(ii) $\tilde { \alpha }$ -condition is a necessary and sufficient condition to Unqc;
|
| 283 |
+
|
| 284 |
+
(iii) 234 $\tilde { \alpha }$ -condition is a sufficient condition to Acyclicity∗.
|
| 285 |
+
|
| 286 |
+

|
| 287 |
+
Figure 1: Relations of Uniqueness Conditions in Many-to-one Market.
|
| 288 |
+
|
| 289 |
+
236 We then provide theoretical results of MO-UCB-D4 algorithm under our $\tilde { \alpha }$ -condition. Recall that $G _ { j } ^ { * }$
|
| 290 |
+
237 is the globally dominated arms for agent $j$ under stable matching $m ^ { * }$ . For each arm $k \notin G _ { j } ^ { * }$ , we give
|
| 291 |
+
238 the definition of the blocking agents for arm $k$ and agent $j$ : ${ \cal B } _ { j k } = \{ j ^ { \prime } : j ^ { \prime } \succ _ { k } j , k \notin \hat { G } _ { j } ^ { * } \}$ , which
|
| 292 |
+
239 contains agents more preferred by arm $k$ than $j$ . The hidden arms for agent $j$ is $\mathcal { H } _ { j } = \left\{ k : k \notin \right.$
|
| 293 |
+
240 $G _ { j } ^ { * } \} \cap \{ k : B _ { j k } \neq \emptyset \}$ . The reward gap for agent $j$ and arm $k$ is defined as $\Delta _ { j k } = | \mu _ { j , m ^ { * } ( j ) } - \mu _ { j , k } |$
|
| 294 |
+
241 and the minimum reward gap across all arms and agents is $\begin{array} { r } { \Delta = \operatorname* { m i n } _ { j \in [ N ] } \{ \operatorname* { m i n } _ { k \in [ K ] } \Delta _ { j , k } \} } \end{array}$ . We
|
| 295 |
+
242 assume that the reward is different for each agent, thus $\Delta _ { j , k } > 0$ for every agent $j$ and arm $k$ .
|
| 296 |
+
243 Theorem 3. (Regret upper bound) Let J $\operatorname* { m a x } ( j ) = \operatorname* { m a x } \left\{ j + 1 , \left\{ j ^ { \prime } : \exists k \in \mathcal { H } _ { j } , j ^ { \prime } \in \mathcal { B } _ { j k } \right\} \right\}$ be the
|
| 297 |
+
244 max blocking agent for agent $j$ and $f _ { \tilde { \alpha } } ( j ) = j + l r _ { \mathrm { m a x } } ( j )$ is a fixed factor depends on both the left
|
| 298 |
+
245 order and the right order for agent $j$ . Following MO-UCB-D4 algorithm with horizon $T$ , the expected
|
| 299 |
+
246 regret of a stable matching under $\tilde { \alpha }$ -condition (Definition 2) for agent $j \in [ N ]$ is upper bounded by
|
| 300 |
+
|
| 301 |
+
$$
|
| 302 |
+
\begin{array} { r } { \Xi [ R _ { j } ( T ) ] \leq \displaystyle \sum _ { k \notin G _ { j } ^ { \ast } \cup m ^ { \ast } ( j ) } \frac { 8 \alpha } { \Delta j k } ( \log ( T ) + \sqrt { \frac { \pi } { \alpha } } \log ( T ) ) + \displaystyle \sum _ { k \notin G _ { j } ^ { \ast } j ^ { \prime } \in B _ { j k } : k \notin G _ { j ^ { \prime } } ^ { \ast } } \frac { 8 \alpha \mu _ { j , m ^ { \ast } ( j ) } } { \Delta _ { j ^ { \prime } k } ^ { 2 } } ( \log ( T ) + } \\ { + c _ { j } \log _ { 2 } ( T ) + O ( \frac { N ^ { 2 } K ^ { 2 } } { \Delta ^ { 2 } } + ( \operatorname* { m i n } ( 1 , \theta | \mathcal { H } _ { j } | ) f _ { \alpha } ( J _ { \operatorname* { m a x } } ( j ) ) + f _ { \bar { \alpha } } ( j ) - 1 ) 2 ^ { i ^ { \ast } } + N ^ { 2 } K i ^ { \ast } ) , } \end{array}
|
| 303 |
+
$$
|
| 304 |
+
|
| 305 |
+
where 247 $i ^ { * } = \operatorname* { m a x } \{ 8 , i _ { 1 } , i _ { 2 } \}$ (then $i ^ { * } \leq 8$ and $i _ { 1 } , i _ { 2 }$ are defined in equation (3)), and $l r _ { \operatorname* { m a x } } ( j ) =$ 248 $\operatorname* { m a x } \{ l r ( j ^ { \prime } ) : 1 \le j ^ { \prime } \le j \}$ , is the maximum right order mapping for agent $j ^ { \prime }$ who ranks higher than 249 $j$ .
|
| 306 |
+
|
| 307 |
+
From Theorem 3, the scale of the regret upper bound under $\tilde { \alpha }$ -condition is $\begin{array} { r } { O \left( \frac { N K \log \left( T \right) } { \Delta ^ { 2 } } \right) } \end{array}$ and the proof is in Section 3.
|
| 308 |
+
|
| 309 |
+
Proof Sketch of Theorem 3. Under $\tilde { \alpha }$ -condition, we only need to discuss the regret of the unique result. We construct a good phase (in Appendix A.2) and denote that the time point of agent $j$ reaching its good phase by $\tau _ { j }$ . After $\tau _ { j }$ , agent $j$ could identify its best arm and matches with his stable pair. Thus, from phase $\tau _ { j }$ on-wards, agent $j + 1$ will find the set of globally dominated arms $G _ { j + 1 } ^ { * }$ and will eliminate arm $\overset { \cdot } { m } ^ { * } ( j )$ if $m ^ { * } ( j )$ brings collisions in communication block according to Algorithm 1. Global deletion here follows the left order. Then when agent $j$ enters into regret minimization block next phase, the times it plays a sub-optimal arm is small which leads to a small total number of collisions experienced by agent $j + 1$ . Then the process of each agent after good phase is divided into two stages: before $\tau _ { j }$ and after $\tau _ { j }$ . After $\tau _ { j }$ , according to the causes of regret, it is divided into four blocks: collision, local deletion, communication, and sub-optimal play. Phases before $\tau _ { j }$ can be bounded by induction. The regret decomposition is bound by the following.
|
| 310 |
+
|
| 311 |
+
263 Lemma 2. (Regret Decomposition) For a stable matching under $\tilde { \alpha }$ -condition, the upper bound of
|
| 312 |
+
264 regret for the agent $j \in [ N ]$ under our algorithm can be decomposed by:
|
| 313 |
+
|
| 314 |
+
$$
|
| 315 |
+
\begin{array} { r l } & { \mathbb { E } \left[ R _ { j } ( T ) \right] \leq \underbrace { \mathbb { E } \left[ S _ { F _ { \alpha \beta } } \right] } _ { ( R e g e r t o f ) \alpha \in P _ { \alpha \beta } } + \underbrace { \operatorname* { m i n } ( \theta | \mathcal { H } _ { j } | , 1 ) \mathbb { E } \left[ S _ { V _ { \alpha \beta } } \right] } _ { ( L o c d a l e t i o n ) } + \underbrace { \left( ( K - 1 + | B _ { j , m ^ { * } ( j ) } | ) \log _ { 2 } ( T ) + N \right) } _ { ( C o m m a t i c a t i o n ) } } \\ & { + \underbrace { \sum _ { \substack { \lambda \notin G _ { j } ^ { * } j ^ { \prime } \in S _ { \beta , k } \star k \notin G _ { \beta ^ { * } } ^ { * } } } \frac { 8 \alpha \mu _ { j , m ^ { * } ( j ) } } { \Delta _ { j ^ { \prime } , k } } \left( \log ( T ) + \sqrt { \frac { \pi } { \alpha } } \log ( T ) \right) } _ { ( C o l b s i o n ) } } \\ & { + \underbrace { \sum _ { \substack { \lambda \notin G _ { j } ^ { * } \cup m ^ { * } ( j ) } } \frac { 8 \alpha } { \Delta _ { j , k } } \left( \log ( T ) + \sqrt { \frac { \pi } { \alpha } } \log ( T ) \right) } _ { ( S u b s o n ) } + N K \left( 1 + ( \phi ( \alpha ) + 1 ) \frac { 8 \alpha } { \Delta ^ { 2 } } \right) , } \end{array}
|
| 316 |
+
$$
|
| 317 |
+
|
| 318 |
+
265 where $F _ { \alpha j }$ , $V _ { \alpha j }$ are the time points when agent $j$ enters into $\tilde { \alpha }$ -Good phase and $\tilde { \alpha }$ -Low Collision
|
| 319 |
+
266 phase respectively, mentioned as "good phase" above, are defined in Appendix A.2.
|
| 320 |
+
|
| 321 |
+
While putting forward our $\tilde { \alpha }$ -condition in the many-to-one setting, many new problems need to be taken into account.
|
| 322 |
+
|
| 323 |
+
From one-to-one setting to many-to-one setting First, although we assume that arm preference is over individuals rather than combination of agents, the agents matched by one arm are not independent. Specially, arms with capacity $q$ can not just be replaced by $q$ independent individuals with the same preference. Since there would be implicit competition among different replicates of this arm, and it can reject the previously accepted agents when it faces a more preferred agent. Secondly, collisions among agents is one of main causes of regret in decentralized setting, while capacity will hinder the collision-reducing process. In communication block, when two agents select one arm at a time, as an arm can accept more than one agent, these two cannot distinguish who is more preferred by this arm, while it can be done in one-to-one markets. Thus it is more difficult to identify arm preferences for each agent. The $l r$ in [7] is a one-to-one mapping that corresponds the agent index in the left order and the agent index in the right order, which is related to regret bound (Theorem 3 in [7] and Theorem 3 in our work). While it does not hold in our setting. To give a descriptive range of matched result for each arm under $\tilde { \alpha }$ -condition, we need to define a new mapping.
|
| 324 |
+
|
| 325 |
+
In order to solve these problems, we explain as follows: First, since capacity influence the communication among agents, we add communication block and introduce an arm set $G _ { j } ^ { * }$ , which will be deleted before each phase to reduce collisions, where $G _ { j } ^ { * }$ contains arms that will block agent $j$ globally under stable matching $m ^ { * }$ . Second, the idea from one-to-one to many-to-one is a transition from individual to set. It is natural to split sets into individuals or design a bridge to correspond sets to individuals. We construct a new mapping $l r$ (Figure 4 in Appendix A) from agent $j$ in the left order to agents in the right order under $\tilde { \alpha }$ -condition. $l r$ maps each arm $k$ to the least preferred one of its stable matched agents in the right order, thus giving a matching between individuals and individuals and constructing the range of the stable matched agents set (Theorem 1). Except $l r$ , capacity also influences regret mainly in communication block, as mentioned in the first paragraph.
|
| 326 |
+
|
| 327 |
+
From $\alpha$ -condition to $\tilde { \alpha }$ -condition To extend $\alpha$ -condition to the many-to-one setting, it needs to define preferences among sets. However, there might be exponential number of sets due to the combinatorial structure and simply constraining preferences over all possible sets will lead to high complexity. Motivated by $\alpha$ -condition which characterizes properties of matched pairs in one-to-one setting, we come up with a possible constraint by regarding the arm and its least preferred agent in the matched set as the matched pair and define preferences according to this grouping. It turns out that we only need to define the preferences of arms over disjoint sets of agents to complete the extension as $\alpha$ -condition is defined under the stable matching, which can also fit the regret analysis well. As a summary, there might be other possible ways to extend the $\alpha$ -condition but we present a successful trial to not only give a good extension with similar inclusion relationships but also guarantee good regret bound.
|
| 328 |
+
|
| 329 |
+
# 04 6 Experiments
|
| 330 |
+
|
| 331 |
+
In this section, we verify the experimental results of our MO-UCB-D4 algorithm (Algorithm 1) for decentralized many-to-one matching markets. For all experiments, the rankings of all agents and arms are sampled uniformly. We set the reward value towards the least preferred arm to be $1 / N$ and the most preferred one as 1 for each agent, then the reward gap between any adjacently ranked arms is $\Delta = 1 / N$ . The reward for agent $j$ matches with arm $k$ at time t $X _ { j , k } ( t )$ is sampled from $\operatorname { B e r } ( \mu _ { j , k } )$ . The capacity is equally set as $q = N / K$ . We investigate how the cumulative regret and cumulative market unstability depend on the size of the market and the number of arms under three different unique stability conditions: Serial Dictatorship, SPC, $\tilde { \alpha }$ -condition. The former cumulative regret is the total mean reward gap between the stable matching result and the simulated result, and the latter cumulative unstability is defined as the number of unstable matchings in round $t$ . In our experiments, all results are averaged over 10 independent runs, hence the error bars are calculated as standard deviations divided by $\sqrt { 1 0 }$ .
|
| 332 |
+
|
| 333 |
+
317 Varying the market size To test effects on two indicators, cumulative regret and cumulative
|
| 334 |
+
318 unstability, we first varying $N$ with fixed $K$ with market size of $N \in \{ 1 \bar { 0 } , 2 0 , 3 0 , 4 0 \}$ agents
|
| 335 |
+
319 and $K = 5$ arms. The number of rounds is set to be 100, 000. The cumulative regret in Figure
|
| 336 |
+
320 2(a)(c)(e) show an increasing trend with convergence as the number of agents increases under these
|
| 337 |
+
321 three conditions. When the number of agents increases, there is a high probability of collisions
|
| 338 |
+
322 among different agents, resulting in the increase of cumulative regret. Similar results for cumulative
|
| 339 |
+
323 unstability are shown in Figure 2(b)(d)(f). When $N$ is larger, the number of unstable pairs becomes
|
| 340 |
+
324 more. With the increase of the number of rounds, both two indicators increase first and then tend to
|
| 341 |
+
325 be stable. The jumping points are caused by multi-phases setting of MO-UCB-D4 algorithm.
|
| 342 |
+
326 Varying arm capacity The number of arms $K$ is chosen by $K \in \{ 2 , 5 , 1 0 , 2 0 \}$ , with $N = 2 0$ and
|
| 343 |
+
327 $q = N / K$ . The number of rounds we set is 400, 000. With the increase of $K$ , both the cumulative
|
| 344 |
+
328 regret in Figure 3(a)(c)(e) and the cumulative unstability in Figure 3(b)(d)(f) increase monotonously.
|
| 345 |
+
329 When $K$ increases, the capacity $q _ { k }$ for each arm $k$ decreases, and then the number of collisions
|
| 346 |
+
330 will increase, which leads to an increase of cumulative regret. And it also leads to more unstable
|
| 347 |
+
331 pairs, which needs more communication blocks to converge to a stable matching. Under these three
|
| 348 |
+
332 conditions, the performances of the algorithm are similar.
|
| 349 |
+
|
| 350 |
+

|
| 351 |
+
Figure 2: Cumulative regret and cumulative unstability of MO-UCB-D4 of size with $N \in$ $\{ 1 0 , 2 0 , \dot { 3 0 } , 4 0 \}$ and the number of arms $K = 5$ under Serial Dictatorship, SPC, $\tilde { \alpha }$ -condition.
|
| 352 |
+
|
| 353 |
+

|
| 354 |
+
Figure 3: Cumulative regret and cumulative unstability of MO-UCB-D4 of size with $K \in$ $\{ 2 , 5 , 1 0 , \dot { 2 } 0 \}$ under Serial Dictatorship, SPC, $\tilde { \alpha }$ - condition.
|
| 355 |
+
|
| 356 |
+
# 7 Conclusion
|
| 357 |
+
|
| 358 |
+
334 We are the first to study the bandit algorithm for the many-to-one matching market under the unique
|
| 359 |
+
335 stable matching. This work focuses on a decentralized market. A new $\tilde { \alpha }$ -condition is proposed
|
| 360 |
+
336 to guarantee a unique stable outcome in many-to-one market, which is more general than existing
|
| 361 |
+
337 uniqueness conditions like SPC, Serial Dictatorship and could recover the usual $\alpha$ -condition in
|
| 362 |
+
338 one-to-one setting. We propose a phase-based algorithm of MO-UCB-D4 with arm-elimination,
|
| 363 |
+
339 which obtains $\begin{array} { r } { O \left( \frac { N K \log ( T ) } { \Delta ^ { 2 } } \right) } \end{array}$ stable regret under $\tilde { \alpha }$ -condition. By carefully defining a mapping from
|
| 364 |
+
340 arms to the least preferred agent in its stable matched set, we could effectively correspond arms and
|
| 365 |
+
341 agents by individual-to-individual. A series of experiments under two environments of varying the
|
| 366 |
+
342 market size and varying arm capacity are conducted. The results show that our algorithm performs
|
| 367 |
+
343 well under Serial Dictatorship, $S P C$ and $\tilde { \alpha }$ -condition respectively.
|
| 368 |
+
|
| 369 |
+
References
|
| 370 |
+
[1] Azar Abizada. Stability and incentives for college admissions with budget constraints. Theoretical Economics, 11(2):735–756, 2016.
|
| 371 |
+
[2] Takashi Akahoshi. Singleton core in many-to-one matching problems. Mathematical Social Sciences, 72:7–13, 2014.
|
| 372 |
+
[3] Ahmet Altinok. Dynamic many-to-one matching. Available at SSRN 3526522, 2019.
|
| 373 |
+
[4] Peter Auer, Nicolo Cesa-Bianchi, and Paul Fischer. Finite-time analysis of the multiarmed bandit problem. Machine learning, 47(2):235–256, 2002.
|
| 374 |
+
[5] Orly Avner and Shie Mannor. Concurrent bandits and cognitive radio networks. In Joint European Conference on Machine Learning and Knowledge Discovery in Databases, pages 66–81. Springer, 2014.
|
| 375 |
+
[6] Sophie Bade. Random serial dictatorship: the one and only. Mathematics of Operations Research, 45(1):353–368, 2020.
|
| 376 |
+
[7] Soumya Basu, Karthik Abinav Sankararaman, and Abishek Sankararaman. Beyond $l o g ^ { 2 } ( t )$ regret for decentralized bandits in matching markets. In International Conference on Machine Learning, pages 705–715, 2021.
|
| 377 |
+
[8] Anna Bogomolnaia and Hervé Moulin. A new solution to the random assignment problem. Journal of Economic theory, 100(2):295–328, 2001.
|
| 378 |
+
[9] Somouaoga Bonkoungou. Decentralized college admissions under single application. Review of Economic Design, 25(1):65–91, 2021.
|
| 379 |
+
[10] Simon Clark. The uniqueness of stable matchings. Contributions in Theoretical Economics, 6(1), 2006.
|
| 380 |
+
[11] Jan Eeckhout. On the uniqueness of stable marriage matchings. Economics Letters, 69(1):1–8, 2000.
|
| 381 |
+
[12] David Gale and Lloyd S Shapley. College admissions and the stability of marriage. The American Mathematical Monthly, 69(1):9–15, 1962.
|
| 382 |
+
[13] Aurélien Garivier, Tor Lattimore, and Emilie Kaufmann. On explore-then-commit strategies. Advances in Neural Information Processing Systems, 29:784–792, 2016.
|
| 383 |
+
[14] Virginia Gunn, Bertina Kreshpaj, Nuria Matilla-Santander, Emilia F Vignola, David H Wegman, Christer Hogstedt, Emily Q Ahonen, Theo Bodin, Cecilia Orellana, Sherry Baron, et al. Initiatives addressing precarious employment and its effects on workers’ health and well-being: A systematic review. International Journal of Environmental Research and Public Health, 19(4):2232, 2022.
|
| 384 |
+
[15] Gregory Z Gutin, Philip R Neary, and Anders Yeo. Unique stable matchings. arXiv preprint arXiv:2106.12977, 2021.
|
| 385 |
+
[16] Guillaume Haeringer and Flip Klijn. Constrained school choice. Journal of Economic theory, 144(5):1921–1947, 2009.
|
| 386 |
+
[17] John William Hatfield, Fuhito Kojima, and Scott Duke Kominers. Investment incentives in labor market matching. American Economic Review, 104(5):436–41, 2014.
|
| 387 |
+
[18] Ramesh Johari, Vijay Kamble, and Yash Kanoria. Matching while learning. Operations Research, 69(2):655–681, 2021.
|
| 388 |
+
[19] Alexander Karpov. A necessary and sufficient condition for uniqueness consistency in the stable marriage matching problem. Economics Letters, 178:63–65, 2019.
|
| 389 |
+
[20] Bettina Klaus and Flip Klijn. Local and global consistency properties for student placement. Journal of Mathematical Economics, 49(3):222–229, 2013.
|
| 390 |
+
[21] Lydia T Liu, Horia Mania, and Michael Jordan. Competing bandits in matching markets. In International Conference on Artificial Intelligence and Statistics, pages 1618–1628. PMLR, 2020.
|
| 391 |
+
[22] Lydia T Liu, Feng Ruan, Horia Mania, and Michael I Jordan. Bandit learning in decentralized matching markets. arXiv preprint arXiv:2012.07348, 2020.
|
| 392 |
+
[23] Jinpeng Ma. The singleton core in the college admissions problem and its application to the national resident matching program (nrmp). Games and Economic Behavior, 69(1):150–164, 2010.
|
| 393 |
+
[24] Onkar Malgonde, He Zhang, Balaji Padmanabhan, and Moez Limayem. Taming complexity in search matching: Two-sided recommender systems on digital platforms. Mis Quarterly, 44(1), 2020.
|
| 394 |
+
[25] Hai Nguyen, Thành Nguyen, and Alexander Teytelboym. Stability in matching markets with complex constraints. Management Science, 67(12):7438–7454, 2021.
|
| 395 |
+
[26] Muriel Niederle and Leeat Yariv. Decentralized matching with aligned preferences. Technical report, National Bureau of Economic Research, 2009.
|
| 396 |
+
[27] Jaeok Park. Competitive equilibrium and singleton cores in generalized matching problems. International Journal of Game Theory, 46(2):487–509, 2017.
|
| 397 |
+
[28] Philip J Reny. A simple sufficient condition for a unique and student-efficient stable matching in the college admissions problem. Economic Theory Bulletin, 9(1):7–9, 2021.
|
| 398 |
+
[29] Antonio Romero-Medina and Matteo Triossi. Acyclicity and singleton cores in matching markets. Economics Letters, 118(1):237–239, 2013.
|
| 399 |
+
[30] Jonathan Rosenski, Ohad Shamir, and Liran Szlak. Multi-player bandits–a musical chairs approach. In International Conference on Machine Learning, pages 155–163. PMLR, 2016.
|
| 400 |
+
[31] Alvin E Roth. On the allocation of residents to rural hospitals: a general property of two-sided matching markets. Econometrica: Journal of the Econometric Society, pages 425–427, 1986.
|
| 401 |
+
[32] Alvin E Roth and Marilda Sotomayor. Two-sided matching. Handbook of game theory with economic applications, 1:485–541, 1992.
|
| 402 |
+
[33] Hannu Salonen and Mikko AA Salonen. Mutually best matches. Mathematical Social Sciences, 91:42–50, 2018.
|
| 403 |
+
[34] Abishek Sankararaman, Soumya Basu, and Karthik Abinav Sankararaman. Dominate or delete: Decentralized competing bandits in serial dictatorship. In International Conference on Artificial Intelligence and Statistics, pages 1252–1260. PMLR, 2021.
|
| 404 |
+
[35] Jay Sethuraman, Chung-Piaw Teo, Liwen Qian, et al. Many-to-one stable matching: Geometry and fairness. Mathematics of Operations Research, 31(3):581–596, 2006.
|
| 405 |
+
[36] William R Thompson. On the likelihood that one unknown probability exceeds another in view of the evidence of two samples. Biometrika, 25(3/4):285–294, 1933.
|
| 406 |
+
|
| 407 |
+
# Checklist
|
| 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] Please see Abstract and Section 1.
|
| 412 |
+
(b) Did you describe the limitations of your work? [Yes] Please see Section C.4.
|
| 413 |
+
(c) Did you discuss any potential negative societal impacts of your work? [N/A] This work mainly focuses on the online learning theory, which does not have any potential negative societal impacts.
|
| 414 |
+
|
| 415 |
+
(d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
|
| 416 |
+
|
| 417 |
+
2. If you are including theoretical results...
|
| 418 |
+
|
| 419 |
+
(a) Did you state the full set of assumptions of all theoretical results? [Yes] Please see Section 2. (b) Did you include complete proofs of all theoretical results? [Yes] Please see Appendix.
|
| 420 |
+
|
| 421 |
+
3. If you ran experiments...
|
| 422 |
+
|
| 423 |
+
(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] Please see supplemental material.
|
| 424 |
+
(b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes] Please see Section 6 and supplemental material.
|
| 425 |
+
(c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [Yes] Please see Section 6.
|
| 426 |
+
(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)? [N/A]
|
| 427 |
+
|
| 428 |
+
4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
|
| 429 |
+
|
| 430 |
+
(a) If your work uses existing assets, did you cite the creators? [N/A]
|
| 431 |
+
(b) Did you mention the license of the assets? [N/A]
|
| 432 |
+
(c) Did you include any new assets either in the supplemental material or as a URL? [N/A]
|
| 433 |
+
(d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [N/A]
|
| 434 |
+
(e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [N/A]
|
| 435 |
+
|
| 436 |
+
5. If you used crowdsourcing or conducted research with human subjects...
|
| 437 |
+
|
| 438 |
+
(a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A]
|
| 439 |
+
(b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A]
|
| 440 |
+
(c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]
|
md/dev/WZ3yjh8coDg/WZ3yjh8coDg.md
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
md/dev/WZH7099tgfM/WZH7099tgfM.md
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
md/dev/Wjp1AYB8lH/Wjp1AYB8lH.md
ADDED
|
@@ -0,0 +1,435 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Large Language Models as Commonsense Knowledge for Large-Scale Task Planning
|
| 2 |
+
|
| 3 |
+
Zirui Zhao Wee Sun Lee David Hsu National University of Singapore {ziruiz, leews, dyhsu}@comp.nus.edu.sg
|
| 4 |
+
|
| 5 |
+
# Abstract
|
| 6 |
+
|
| 7 |
+
Large-scale task planning is a major challenge. Recent work exploits large language models (LLMs) directly as a policy and shows surprisingly interesting results. This paper shows that LLMs provide a commonsense model of the world in addition to a policy that acts on it. The world model and the policy can be combined in a search algorithm, such as Monte Carlo Tree Search (MCTS), to scale up task planning. In our new LLM-MCTS algorithm, the LLM-induced world model provides a commonsense prior belief for MCTS to achieve effective reasoning; the LLM-induced policy acts as a heuristic to guide the search, vastly improving search efficiency. Experiments show that LLM-MCTS outperforms both MCTS alone and policies induced by LLMs (GPT2 and GPT3.5) by a wide margin for complex, novel tasks. Further experiments and analyses on multiple tasks—multiplication, travel planning, object rearrangement—suggest minimum description length (MDL) as a general guiding principle: if the description length of the world model is substantially smaller than that of the policy, using LLM as a world model for model-based planning is likely better than using LLM solely as a policy.1
|
| 8 |
+
|
| 9 |
+
# 1 Introduction
|
| 10 |
+
|
| 11 |
+
Consider, for example, an autonomous robot butler in a household environment. The human user sits in the living room and asks the robot to "Put fruits into the fridge." The robot looks for fruits, such as apples, peaches, etc., which may be on a table in the dining room, on the kitchen counter, but unlikely in a wardrobe in the bedroom. To complete the task, the robot has to consider fruits’ likely locations as well as their spatial relations, traverse these locations efficiently, and finally put them into the fridge. A household environment typically contains hundreds of movable items and locations, resulting in a huge search space that makes the task very challenging for the robot.
|
| 12 |
+
|
| 13 |
+
Recently, multiple attempts exploiting pre-trained large language models (LLMs) show surprisingly interesting results for such tasks [22, 18, 2, 19, 5, 44]. Their underlying idea is simple: treat the LLM as a policy and query it directly for the next actions, given the history of past actions and observations. We call this strategy L-Policy, which exploits LLMs’ vast commonsense knowledge to circumvent the challenge of searching a very large space. In our example task, L-Policy may simply instruct the robot to move to the hallway and then to the kitchen. Even though LLMs are trained on internet-scale data, this strategy shows limits in generalization [10, 4], especially when encountering uncommon, complex tasks. Alternatively, we may use LLMs’ knowledge to build a world model and apply a planning algorithm to the model. The world model may contain, e.g., a belief over the target object’s location, which biases the search and drastically improves search efficiency. We call this strategy L-Model. L-Model’s performance depends on two critical preconditions: the accuracy of the world model and the efficiency of the planning algorithm. The former is a question of sample complexity for learning, and the latter is that of computational complexity.
|
| 14 |
+
|
| 15 |
+
This paper presents LLM-MCTS (shown in Fig 1), which combines the ideas of L-Model and L-Policy for large-scale task planning. Like L-Model, LLM-MCTS uses an LLM to build a commonsense world model; it then uses the model to perform Monte Carlo Tree Search (MCTS) [8] online for the next actions. During the tree search, LLM-MCTS chooses the promising action branches heuristically by querying the LLM. This is similar in spirit to L-Policy. While L-Policy commits to the actions chosen by the LLM for execution, LLM-MCTS uses these choices only as a search heuristic.
|
| 16 |
+
|
| 17 |
+
We evaluate LLM-MCTS in VirtualHome [24], a standard household activity simulation platform widely used in earlier work [18, 22, 25, 33]. The evaluation set consists of 800 randomly generated large-scale, partially observable object rearrangement tasks. In each task, a robot aims to fetch a common household item with an unknown location and place it in a designated container. Our main experimental findings are summarized below:
|
| 18 |
+
|
| 19 |
+
F1. L-Model performs poorly. There are two possible reasons. One is model inaccuracy: the robot has an incorrect belief of the target object’s location. The other is huge search space size, beyond the reach of even the state-of-the-art MCTS algorithm. Further experiments indicate that search space size is the main cause.
|
| 20 |
+
F2. L-Policy performs reasonably with both GPT2 and GPT3.5, but the performance degrades quickly for novel, complex tasks. This generally corroborates with earlier results [22, 18, 2, 19].
|
| 21 |
+
F3. LLM-MCTS outperforms L-Model. This clearly shows the benefit of using the LLM as a heuristic policy to guide the search.
|
| 22 |
+
F4. LLM-MCTS outperforms L-Policy, especially for novel, complex tasks. LLM-MCTS basically combines L-Model and L-Policy. Since the L-Model performs very poorly on its own, why does the combination outperform L-Policy? One explanation is that search space size is the main cause of L-Model’s poor performance. The LLM-induced world model is sufficiently accurate; tree search with this world model, when limited to the neighbourhood of the LLMinduced policy, provides improved performance over L-Policy.
|
| 23 |
+
|
| 24 |
+
The explanation for (F4) begs a new question: with an efficient planning algorithm for large search space, would $L$ -Model outperform L-Policy? To answer this question, we study two related, simpler tasks: multiplication of two large numbers and multi-hop travel planning. We discuss multiplication here and travel planning in Section 4.1. A decimal number is described as a sequence of $n$ digits, $( d _ { n - 1 } , d _ { n - 2 } , \ldots , d _ { 0 } )$ . There are two methods of implementing multiplication with an LLM. The first one corresponds to L-Policy. We represent the multiplication function as a table. Each row or column corresponds to a number. The table entry is the multiplication of two numbers, obtained by querying an LLM. Experimentally, GPT4 performs single-digit multiplication perfectly with $1 0 0 \%$ accuracy, 2-digit multiplication with $9 9 \%$ accuracy, 4-digit multiplication with merely $\dot { 4 } \%$ accuracy, and fails almost completely on 5-digit multiplication [10]. The second approach uses LLM-derived small single-digit multiplication tables, which GPT4 performs with $100 \%$ accuracy. To multiply multi-digit numbers, it applies the long multiplication algorithm with the single-digit table. This method corresponds to L-Model. While long multiplication differs from planning in algorithmic details, it plays the same role in L-Model and is highly efficient. Clearly, this second method achieves $1 0 0 \%$ accuracy for arbitrarily large numbers, provided that the single-digit multiplication table is accurate. So, the L-Model outperforms L-Policy for the multiplication task, contrary to the finding for object rearrangement tasks.
|
| 25 |
+
|
| 26 |
+
How do we choose between L-Model and L-Policy then? One idea is the minimum description length (MDL) principle. Theoretical analysis suggests that a hypothesis with a shorter description length has a smaller generalization error and is preferred [28]. For multiplication, the method corresponding to L-Policy uses a large table of $O ( 1 0 ^ { 2 n } )$ entries. It takes $O ( n 1 0 ^ { 2 n } )$ bits to represent it. The method corresponding to the L-Model uses a single-digit multiplication table of constant size. The long multiplication algorithm can be encoded in any reasonable programming language with constant size. So, the total representation size is constant. According to MDL, the L-Model has a smaller generalization error than the L-Policy for multiplication, with sufficiently large $n$ . This is fully consistent with experimental results [10]. The analysis of travel planning provides further evidence (Section 4.1).
|
| 27 |
+
|
| 28 |
+
In summary, LLM-MCTS combines the ideas of L-Model and L-Policy, outperforming either alone for complex task planning, particularly, object rearrangement (Sections 2 and 3). To choose between L-Model and L-Policy, MDL provides a useful guiding principle (Section 4). In essence, simplicity is preferred, a well-known general principle in machine learning.
|
| 29 |
+
|
| 30 |
+

|
| 31 |
+
Figure 1: Overview of LLM-MCTS. For each simulation in the MCTS, we sample from the commonsense belief to obtain an initial state of the world and use the LLM as heuristics to guide the trajectory to promising parts of the search tree.
|
| 32 |
+
|
| 33 |
+
# 2 LLM-MCTS: Monte Carlo planning with commonsense knowledge
|
| 34 |
+
|
| 35 |
+
We aim to solve task-planning problems in large-scale domains with partial observation. One example is object rearrangement tasks [3] in household environments. It is a meaningful and challenging problem with a large-scale and long-term planning horizon. It has many practical implications in everyday life [3, 34, 39, 20, 17], such as setting the table, tidying up the room, loading the dishwasher, etc.. To solve the problem, we present LLM-MCTS (shown in Fig 1), which combines the L-Model and L-Policy for large-scale planning. It uses LLM to build a commonsense world model to perform MCTS for reasoned planning and uses L-Policy to guide the MCTS and reduce the large search space.
|
| 36 |
+
|
| 37 |
+
# 2.1 Task planning
|
| 38 |
+
|
| 39 |
+
We focus on task-planning problems with partial observation and large-scale domains. The problem can be formulated as a Partially Observable Markov Decision Process (POMDP): $\bar { ( } S , A , \Omega , T , O , R , \gamma )$ . The state space $S$ define the state of the robot and its environment. The action space $A$ defines the action that the robot can do. $\Omega$ is the observation space. $T$ defines the transition function of states, which we assume to be given. $O$ is the observation function that provides partial information about a state. $R ( s , a )$ is the reward function determined by the action $a$ taken at the state $s$ . The discount factor is specified by $\gamma$ . The history trajectory $h _ { t }$ at time step $t$ consists of a sequence of executed actions and received observations up to time $t - 1$ , $h _ { t } = \left( o _ { 0 } , a _ { 0 } , o _ { 1 } , a _ { 1 } , \ldots , o _ { t - 1 } , a _ { t - 1 } \right)$ . The objective is to find an optimal policy $\pi ^ { * } ( h _ { t } )$ that maximize the expected cumulative rewards $\begin{array} { r } { \pi ^ { * } ( h _ { t } ) = \arg \operatorname* { m a x } _ { a \in A } \mathbb { E } \left[ \sum _ { i = 0 } ^ { \infty } \gamma ^ { i } R ( s _ { t + i } , a _ { t + i } ) | a _ { t } = a \right] . } \end{array}$ .
|
| 40 |
+
|
| 41 |
+
In this work, we focus on the object rearrangement task, though our approach is a general method for large-scale task planning. Object rearrangement is a representative embodied AI task [3, 34, 39, 20, 17] with various daily applications, such as setting the table, tidying up the room, loading the dishwasher, and more. It is a challenging task [3] as the robot must navigate, locate target objects and positions, and execute multi-step planning. As with hundreds of items and containers in the domain, identifying target objects can be challenging. Even with known state information, it requires long-horizon planning to achieve the goal. In addition, the vast number of domain objects leads to a large action space, given the actions are to interact with objects. The vast action space produces an exponentially large search tree, making the planning extremely challenging.
|
| 42 |
+
|
| 43 |
+
Following the approach of [22, 25, 33], we model the task as a POMDP as outlined above. The state $S$ comprises variables denoting the positions of the robot, movable items, and containers. Actions $A$ encompass five predefined actions from VirtualHome, parameterized by object/container/rooms: (1) pick(object), where the robot collects an observed, proximate object; (2) place(object,placement), allowing the robot to set a picked object nearby or inside an open container; (3) open(container) and (4) close(container), for interacting with an observed, nearby containers; and (5) move(room/object/container), where the robot relocates within a room or near an observed object/container. Given our assumption of the robot’s familiarity with house structures and the manageable size of the house, the robot can move directly to designated rooms. The deterministic transition $T$ is pre-defined by actions. Partial observation $O$ enables the robot to discern object/container positions within its room or an opened container at its location. The objective is to reorganize household items based on verbal instructions, represented by a reward of $R$ for achieving the desired item arrangement.
|
| 44 |
+
|
| 45 |
+
# 2.2 LLM as a commonsense world model
|
| 46 |
+
|
| 47 |
+
A commonsense prior belief of states can improve the effectiveness of object and location searches by prioritizing the search to appropriate locations. Our approach utilizes LLM’s commonsense knowledge to generate the initial belief of states, which is updated with each action and observation in the real world. MCTS samples from the belief in simulation to estimate the value of the action.
|
| 48 |
+
|
| 49 |
+
Initial belief of state. We use object-centric state representation and categorize the objects in the house as moveable objects (e.g., apples), containers (e.g., fridge), and surfaces (e.g., kitchen table). The states of a moveable object might be inside the containers or on the surfaces. The containers and surfaces should be inside a room. Similar to [22, 25], we maintain the belief in object-centric graphs, where nodes are objects and edges describe abstract-level relationships (e.g., apples are inside fridge, fridge is inside kitchen) between objects and rooms. Details are in the Appendix C.2.
|
| 50 |
+
|
| 51 |
+
Assume a dataset $\mathcal { D }$ is accessible, containing expert actions and observations in similar household environments to solve daily tasks. LLMs can use the observations in the data to know what are the objects in the house and predict their positions, forming the commonsense belief of the state. To achieve this, we find all the objects, containers, and surfaces that appeared in the dataset $\mathcal { D }$ to form a list of objects $\mathcal { D } _ { \mathrm { o b j } }$ using a unique name for all of them. To approximate $b ( s _ { 0 } )$ , we ask the LLMs to sample the positions of objects $M$ times. For each sample, we ask the LLM to predict the position of objects using $\mathcal { D } _ { \mathrm { o b j } }$ and a fixed prompt. For instance, we ask LLM to complete “The containers in the apartment are: fridge, . . . ; The surfaces in the apartment are: kitchen counter, . . . ; Question: what are the possible positions of strawberry? Answer: inside fridge, inside pantry. . . Question: what are the possible positions of apple? Answer:__.” We use three prompt examples to provide example formats of the response. The exact prompts we used are provided in the appendix. As the responses from LLM are free-form natural language, we have to precisely map those expressions to $\mathcal { D } _ { \mathrm { o b j } }$ for consistent state representation. Thus, we encode the names of objects in the LLM’s response into embeddings using sentence-BERT $f ( \cdot )$ [26] and examine their cosine similarity to the unique name of objects in $\mathcal { D } _ { \mathrm { o b j } }$ : $\begin{array} { r } { \mathrm { C o s i n e S i m } ( e _ { i } , e ) = \frac { f ( e _ { i } ) f ( e ) } { \| f ( e _ { i } ) \| \| f ( e ) \| } } \end{array}$ f(ei)f(e)∥f(ei)∥∥f(e)∥ , where e is the name of objects, containers, or surfaces in the LLM’s response, and $e _ { i } \in \mathcal { D } _ { \mathrm { o b j } }$ are the unique names in the object list. We select the most similar expressions in $\mathcal { D } _ { \mathrm { o b j } }$ to form the sampled state. For example, when querying the position of an apple, the LLM’s response is “on the kitchen table,” we use the above technique to translate “the kitchen table” to “kitchentable,” a unique name in $\mathcal { D } _ { \mathrm { o b j } }$ .
|
| 52 |
+
|
| 53 |
+
Goal. Similar to [40], we use LLMs to translate the natural language goal into a formal goal for MCTS. We use a fixed set of prompt examples for LLM to interpret natural language goals, such as “put one apple into the fridge” is translated as a tuple “(apple, inside, fridge).” For compositional instructions, it will translate it into multiple tuples, such as “put one apple on the kitchen table and one plate inside the dishwasher” is translated as “(apple, on, kitchentable), (plate, inside, dishwasher).” We precisely map the LLM-generated goal into the admissible expressions in $\mathcal { D } _ { \mathrm { o b j } }$ for search using the same representation as the state. In MCTS, the goal is used to identify the reward. As the representations are the same, we can directly check whether the object’s state is the same as the goal by string matching. If the goal is reached, it will receive a large positive reward, or 0 otherwise.
|
| 54 |
+
|
| 55 |
+
# 2.3 LLM as a heuristic policy
|
| 56 |
+
|
| 57 |
+
We use LLMs to play the role of $\pi ( a | h )$ in PUCT to guide the action selection in the simulation procedure. In this procedure, the LLM takes as input the examples in the dataset, the goal description, the current observation, and the history of actions, and then outputs the suggested action plan (e.g., “Next actions: move to the kitchen, open the fridge, ...”). Similar to [22], the observations and goal description are translated into English sentences. As the answer of LLM is from the conditional distribution of the following words given the context, it can also be viewed as a commonsense policy of actions to take conditioned on the context of tasks, observations, and completed actions. However, direct implementation and access to the probability value of the GPT-3.5 is not available. Thus, we propose an empirical policy distribution $\hat { \pi }$ that uses sampling to approximate the policy distribution.
|
| 58 |
+
|
| 59 |
+
We sample the LLM for $M$ times to approximate the policy probability distribution. For each sample, we query the LLM with prompt and trajectory history $h$ and receive an answer of the following actions to take $\alpha _ { i } \sim \mathrm { L L M } ( h , \mathrm { p r o m p t } )$ , where $\alpha _ { i }$ is the first action of the answer. The prompt examples are retrieved from the dataset according to the similarity to the current language instruction $\ell$ . We use [26] to translate the instructions in the dataset $\ell _ { i } \in \mathcal { D }$ into embedding and examine their
|
| 60 |
+
|
| 61 |
+
1: procedure SEARCH(h, b, , N)
|
| 62 |
+
2: n 0
|
| 63 |
+
3: while n < N do
|
| 64 |
+
4: s ∼ b(s)
|
| 65 |
+
5: SIMULATE(s, h, False, 0, )
|
| 66 |
+
6: n ← n + 1
|
| 67 |
+
7: end while
|
| 68 |
+
8: return $\operatorname { a r g m a x } _ { a \in A } Q ( h , a )$
|
| 69 |
+
9: end procedure
|
| 70 |
+
10: procedure ROLLOUT $( s , h , { \mathrm { d o n e } } , d )$
|
| 71 |
+
11: if $\gamma ^ { d } < \epsilon$ or done $=$ True then
|
| 72 |
+
12: return 0
|
| 73 |
+
13: end if
|
| 74 |
+
14: $a \sim \pi _ { \mathrm { r o l l o u t } } ( h , \cdot )$
|
| 75 |
+
15: $( s ^ { \prime } , o , r , \mathrm { d o n e } ) \sim \mathcal { G } ( s , a )$
|
| 76 |
+
16: $h ^ { \prime } \gets \mathrm { P U S H B A C K } ( h , [ a ^ { * } , o ] ) , d ^ { \prime } \gets d + 1$
|
| 77 |
+
17: return r + γ $\cdot \mathrm { R o L L O U T } ( s , h ^ { \prime } , \mathrm { d o n e } , d ^ { \prime } )$
|
| 78 |
+
18: end procedure
|
| 79 |
+
19: procedure SIMULAT $\mathrm { E } ( s , h , \mathrm { d o n e } , d , \mathcal { T } )$
|
| 80 |
+
20: if γd < ϵ or done $=$ True then
|
| 81 |
+
21: return 0
|
| 82 |
+
22: end if
|
| 83 |
+
23: if $h$ is not in $\tau$ then
|
| 84 |
+
24: h, N (h) 0
|
| 85 |
+
25: $\forall a \in A , N ( h , a ) \stackrel { \prime } { } 0 , Q ( h , a ) 0$
|
| 86 |
+
26: return ROLLOUT(s, h, done, d)
|
| 87 |
+
27: end if
|
| 88 |
+
28: $\hat { \pi } ( a | h ) \gets$ QUERYLLMPOLICY(h)
|
| 89 |
+
29: a∗←argmax Q(h, a)+cπˆ(a|h) N(h)N(h,a)+1
|
| 90 |
+
30: $( s ^ { \prime } , o , r , \mathrm { d o n e } ) \sim \mathcal { G } ( s , a ^ { * } )$
|
| 91 |
+
31: $h ^ { \prime } \gets \mathrm { P U S H B A C K } ( h , [ a ^ { * } , o ] ) , d ^ { \prime } \gets d + 1$
|
| 92 |
+
32: $R \gets r \mathrm { + } \gamma { \cdot } \operatorname { S I M U L A T E } ( s ^ { \prime } , h ^ { \prime } , \mathrm { d o n e } , d ^ { \prime } , \mathcal { T } )$
|
| 93 |
+
33: N (h, a∗) += 1, N (h) += 1
|
| 94 |
+
34: Q(h, a∗) ← Q(h, a∗) + R−Q(h,a∗)N(h,a∗)
|
| 95 |
+
35: return R
|
| 96 |
+
36: end procedure
|
| 97 |
+
|
| 98 |
+
cosine similarity to the current instruction: $\mathrm { C o s i n e S i m } ( \ell _ { i } , \ell )$ . In experiments, we use a subset of $\mathcal { D }$ to show its performance when restricted to a small training set. We select the top $K$ similar instructions and use the corresponding expert trajectories as a $K$ -shot prompt. However, the answer $\alpha _ { i }$ is a free-formed natural language sentence that cannot be mapped to admissible actions for the agent directly. To ensure that the action can be executed, we follow the method in prior works [18] to represent the actions and admissible actions by embeddings from [26] and evaluate their cosine similarity $\mathrm { C o s i n e S i m } ( \alpha _ { i } , a )$ . The empirical policy distribution is formulated as follows: $\begin{array} { r } { \hat { \pi } ( a | h ) = \lambda \frac { 1 } { | A | } + ( 1 - \lambda ) \mathrm { S o f t m a x } \{ \sum _ { i = 1 } ^ { M } \mathrm { C o s i n e S i m } ( \alpha _ { i } , a ) - \eta \} } \end{array}$ , where $\eta$ is the average value of $\textstyle \sum _ { i } \mathrm { C o s i n e S i m } ( \alpha _ { i } , a )$ and $| A |$ is the size of the admissible action space. $\lambda$ is a hyper-parameter that adds randomness to the belief, as the sampled actions from LLM could be very deterministic. Therefore, the empirical policy distribution is a mixture of approximated policy from LLM and uniform distribution. The example prompts are provided in Appendix F.
|
| 99 |
+
|
| 100 |
+
# 2.4 Monte Carlo tree search
|
| 101 |
+
|
| 102 |
+
We integrate the commonsense world belief and policy from LLM in MCTS, presented in $\mathrm { A l g }$ . For each simulation, MCTS samples a state from the belief $b ( s )$ at the root (line 4). It independently samples one position for each object to construct a state $s$ . This sampled state $s$ is then employed in the simulation, generating a new tree trajectory. An action $a ^ { * }$ is chosen during the simulation based on the $Q$ value, visit counts, and LLM policy (lines 28 and 29). The observation and transition function, denoted as $\mathcal { G }$ (lines 15 and 30), predict the next state $s ^ { \prime }$ given the selected action $a ^ { * }$ and the sampled state $s$ , thus progressing to the subsequent step in the simulation (lines 30 and 31). When encountering leaf nodes in the tree, MCTS expands the tree and performs a random rollout for the corresponding node (lines 23 to 26). A uniform policy is employed to sample actions in the rollout, and the discounted reward is then returned (lines 14 to 17). Upon completing the task or reaching the maximum depth, the accumulated rewards are backpropagated, updating each node’s estimated $Q$ value (lines 32 to 35). Following $N$ simulations, the output action is determined based on the estimated $Q$ value (lines 3 to 8). Upon completion of the search process, the agent will execute an action and receive a new observation. For simplicity, we assume that the observation and transition functions are deterministic and known. In cases where an object is detected, its corresponding position within the belief will be updated with the observed position. Conversely, if the object remains undetected at certain positions, the belief regarding its presence in those positions will be rendered null, denoted by a zero value.
|
| 103 |
+
|
| 104 |
+
# 3 Experiments
|
| 105 |
+
|
| 106 |
+
# 3.1 Experimental setup
|
| 107 |
+
|
| 108 |
+
VirtualHome. We proceed with our experiments in the VirtualHome [24], a large household simulated environment with a large domain, partial observations, and large action space. It contains hundreds of interactive items and containers with various types of rooms. It is a well-suited platform for evaluating embodied decision-making for solving daily tasks in household environments.
|
| 109 |
+
|
| 110 |
+
Data. To generate data for prompting and baseline training, we follow [25] to create 2000 tasks with randomly initialized scenes and expert trajectories. There are several settings for the evaluation. Simple tasks are the tasks that only require the rearrangement of one item generated from the same distribution as the training dataset. Comp. refers to the composition of simple tasks in order to rearrange multiple objects sampled from the same distribution as the dataset (e.g., “Put plate on kitchen table and chicken inside fridge” is the composition of “put plate on kitchen table” and “put chicken inside fridge,” ). The composition of tasks increases the planning horizon, making it more challenging to complete. In evaluation, we also use the Novel Simple tasks with seen items (e.g., in the dataset, we have “put one plate on the kitchen table” and “put one chicken inside the fridge,” and we use “put one plate inside the fridge” and “put one chicken on the kitchen table” to evaluate; these tasks are not included in the training dataset). For compositional tasks, we include Novel Compositional tasks, with 2 or 3 primary tasks composed, denoted as NovelComp(2) and NovelComp(3) (e.g., we have “put plate on kitchen table” and “put chicken inside fridge,” in dataset but their composition “Put plate on kitchen table and chicken inside fridge” is not.) We also generate scenes at a Novel Apartment for testing, where the distribution of object positions differs from the dataset.
|
| 111 |
+
|
| 112 |
+
The expert data are generated by an Oracle agent implemented in [25]. The expert has the full knowledge of the environment (hence, does not need to understand where objects are likely to be placed) and uses handcrafted heuristics for completing various tasks. It uses regression planning to search for solutions to a task. We collect the actions and observations of the expert completing the tasks in the VirtualHome simulator as the dataset. There are 10,000 trajectories in total for training the baseline. To show the capability of LLMs when using a small training set, we only select 200 instances uniformly at random from the dataset as prompt candidates for the LLM model and policy when used in a few-shot mode with no fine-tuning. We also generated 800 tasks in total for evaluation.
|
| 113 |
+
|
| 114 |
+
Evaluation. We evaluate the success rate of completing the tasks within 30 steps, while a typical task can be finished within at most 15 steps. The task is considered successful if all the requirements of object positions are satisfied. For example, given the instruction “Put one apple inside the fridge,” the task is successful if any apple is in the fridge. For simplicity, we don’t consider the task of rearranging a very specific object, e.g., putting the leftmost apple in the fridge.
|
| 115 |
+
|
| 116 |
+
Baselines. We evaluate several baselines to compare. UCT [21]: We use the UCT algorithm to conduct planning without commonsense knowledge and use the ground-truth reward function in simulation. We use uniform distribution as the initial belief for states of objects. It is to provide evidence that commonsense knowledge improves planning efficiency. Finetuned GPT2 policy [22]: we use the training dataset with 10000 trajectories to fine-tune GPT-2 as the planning policy. This is to show that larger pre-trained LLM without fine-tuning outperforms the smaller model fine-tuned in specific tasks. GPT3.5 Policy [18]: LLM takes as input the instructions and history of actions and the currently visible objects to generate the next action. We use the LLM as the policy only, with a few examples as prompts to interact with the environments.
|
| 117 |
+
|
| 118 |
+
This baseline demonstrates the benefits of additional information from the commonsense model and algorithmic benefits from MCTS.
|
| 119 |
+
|
| 120 |
+
# 3.2 Results
|
| 121 |
+
|
| 122 |
+
Table 1: Main results: mean $\pm$ standard error of success rate $( \% )$
|
| 123 |
+
|
| 124 |
+
<table><tr><td rowspan="2"></td><td colspan="4">Seen Home</td></tr><tr><td>Simple</td><td>Comp.</td><td>NovelSimple NovelComp.(2) NovelComp.(3)</td><td></td></tr><tr><td>UCT [21]</td><td>0.0±0.0</td><td>0.0±0.0</td><td>0.0±0.0 0.0±0.0</td><td>0.0±0.0</td></tr><tr><td>finetuned GPT2 policy [22]</td><td>81.3±2.4 59.0±6.7</td><td></td><td>41.2±7.1 30.9±2.8</td><td>2.3±1.5</td></tr><tr><td>GPT3.5Policy[18]</td><td>83.4±6.8 47.0±7.8</td><td></td><td>74.3±4.0 48.2±8.8</td><td>5.4±2.0</td></tr><tr><td>GPT3.5-MCTS (Ours)</td><td>91.4±3.3 71.2±6.2</td><td></td><td>88.1±4.3 72.6±6.9</td><td>33.6±3.1</td></tr><tr><td></td><td colspan="4">Unseen Home</td></tr><tr><td>Method</td><td>Simple</td><td>Comp.</td><td>NovelSimple NovelComp.(2) NovelComp.(3)</td><td></td></tr><tr><td>UCT[21]</td><td>0.0±0.0</td><td>0.0±0.0</td><td>0.0±0.0</td><td>0.0±0.0</td></tr><tr><td>finetuned GPT2 policy [22]</td><td>65.5±3.4 39.9±5.2</td><td>33.4±6.4</td><td>0.0±0.0 12.8±3.9</td><td>1.1±0.9</td></tr><tr><td>GPT3.5Policy[18]</td><td>74.3±5.0 43.3±4.0</td><td>67.8±4.9</td><td>54.0±3.0</td><td>6.9±2.1</td></tr><tr><td>GPT3.5-MCTS(Ours)</td><td>82.9±3.2 71.9±5.6</td><td>79.3±3.3</td><td>70.4±6.4</td><td>38.8±3.4</td></tr></table>
|
| 125 |
+
|
| 126 |
+
Main result. The main results of the experiments are shown in Table 1, reporting the success rate of our method
|
| 127 |
+
|
| 128 |
+
and baselines in completing the tasks in VirtualHome environments. In this result, GPT3.5-MCTS outperforms all the compared baselines, especially for unseen situations. UCT works poorly in all conditions, as the poor model and the huge search tree make the planning intractable. Thus, we focus our discussion on comparing the finetuned GPT2 policy and GPT3.5 policy. For Simple, in-distribution tasks, the planning horizon is relatively short. Finetuned GPT2 policy, GPT3.5 Policy, and our method work reasonably well, but our method still outperforms the baselines. For Novel Simple tasks, finetuned GPT2 policy works significantly worse than GPT3.5 Policy and GPT3.5-MCTS. This is because the fine-tuning of narrow tasks results in a biased distribution of the policy and compromises generalizability. GPT3.5 Policy and GPT3.5-MCTS work better due to the LLM’s few-shot planning capability. GPT3.5-MCTS works better for both situations. It benefits from the MCTS’ look-ahead search that explore possible states for potential outcomes in order to make reasoned decisions.
|
| 129 |
+
|
| 130 |
+
For the Compositional, in-distribution tasks, the finetuned GPT2 policy and GPT3.5 policy get significantly worse performance, while GPT3.5-MCTS works far better. The finetuned GPT2 policy is trained by behavior cloning that suffers from compounding errors. Therefore, when the planning horizon gets longer, the influence of the errors accumulates and compromises the overall performance significantly. As for GPT3.5 Policy, the longer horizon potentially introduces more errors during planning, which might not be included in the prompt examples. Without suitable guidance from prompt, we cannot guarantee the GPT3.5 Policy will carry out suitable replanning when encountering errors. MCTS encourages exploration to a certain extent of different possible actions during searching, introducing additional guidance to the GPT3.5 policy to look into other possible solutions. This is because the action selection procedure in GPT3.5-MCTS is not purely determined by GPT3.5 Policy but also by the $Q$ value and visit counts. Thus, MCTS encourages GPT3.5 Policy to explore other possible search directions instead of excessively applying certain actions sampled by itself.
|
| 131 |
+
|
| 132 |
+
Ablation study. We conduct ablation studies to see the individual contributions of different components within the GPT3.5-MCTS framework. The No Heuristic Policy version of GPT3.5-MCTS refers to the absence of PUCT guided by the GPT3.5 Policy for action selection. Instead, it solely relies on UCT with an initial commonsense belief derived from LLM. The variant employing the Uniform State Prior utilizes a uniform prior belief regarding states, in contrast to the LLM-generated initial belief employed during the search process. Lastly, the variant operating in a Fully Observable environment aims to assess the accuracy of LLM’s knowledge in modeling the world.
|
| 133 |
+
|
| 134 |
+
Table 2 shows the results of our ablation study. The outcomes obtained under the No Heuristic Policy version highlight the significance of heuristic policies in facilitating MCTS to conduct efficient searches for complex and large-scale planning tasks. Con
|
| 135 |
+
|
| 136 |
+
Table 2: Ablation Study: mean $\pm$ standard error of success rate $( \% )$
|
| 137 |
+
|
| 138 |
+
<table><tr><td rowspan="2">Method</td><td colspan="5">Seen Home</td></tr><tr><td>Simple</td><td>Comp.</td><td>NovelSimple NovelComp.(2) NovelComp.(3)</td><td></td><td></td></tr><tr><td>GPT3.5-MCTS (No Heuristic Policy)</td><td>0.0±0.0</td><td>0.0±0.0</td><td>0.0±0.0</td><td>0.0±0.0</td><td>0.0±0.0</td></tr><tr><td>GPT3.5-MCTS(Uniform State Prior)</td><td>3.2±1.1</td><td>0.0±0.0</td><td>1.1±0.4</td><td>0.0±0.0</td><td>0.0±0.0</td></tr><tr><td>GPT3.5-MCTS (Fully Observable)</td><td>94.0±2.1</td><td>80.7±3.3</td><td>94.3±2.4</td><td>78.5±4.0</td><td>34.0±4.4</td></tr><tr><td>GPT3.5-MCTS (Ours)</td><td></td><td>91.4±3.3 71.2±6.2</td><td>88.1±4.3</td><td>72.6±6.9</td><td>33.6±3.1</td></tr><tr><td></td><td colspan="5">Unseen Home</td></tr><tr><td>Method</td><td>Simple</td><td>Comp.</td><td></td><td>NovelSimple NovelComp.(2) NovelComp.(3)</td><td></td></tr><tr><td>GPT3.5-MCTS (No Heuristic Policy)</td><td>0.0±0.0</td><td>0.0±0.0</td><td>0.0±0.0</td><td>0.0±0.0</td><td>0.0±0.0</td></tr><tr><td>GPT3.5-MCTS (Uniform State Prior)</td><td>1.1±0.2</td><td>0.0±0.0</td><td>0.0±0.0</td><td>0.0±0.0</td><td>0.0±0.0</td></tr><tr><td>GPT3.5-MCTS(Fully Observable)</td><td>85.1±5.0 77.5±3.2</td><td></td><td>82.2±3.3</td><td>76.6±3.1</td><td>37.9±2.9</td></tr><tr><td>GPT3.5-MCTS (Ours)</td><td>82.9±3.2 71.9±5.6</td><td></td><td>79.3±3.3</td><td>70.4±6.4</td><td>38.8±3.4</td></tr></table>
|
| 139 |
+
|
| 140 |
+
versely, the results of the Uniform State Prior row indicate that incorrect world models compromise search performance. This is because the model of the world determines the $Q$ value. The wrong model results in an inaccurate estimation of the $Q$ value, misleading the search process toward irrelevant locations. The Fully Observable results demonstrate that GPT3.5-MCTS with perfect knowledge of the environment only slightly outperforms its counterpart without it, implying that the commonsense knowledge of LLM regarding world modelling suffices for practical purposes.
|
| 141 |
+
|
| 142 |
+
Failure analysis. Policy, model, and translation errors are the primary causes of failures. Among these, policy errors are responsible for the majority of the failures. Oftentimes, the policy produces unreasonable behaviours that mislead the search procedure. For example, it usually outputs inadmissible actions, such as “walk to the cutleryfork” where the “cutleryfork” is not in the observation. It also produces back-and-forth behaviours, resulting in an unreasonable heuristic and slowing the search procedure. For example, when putting objects inside the microwave, it is sometimes struck by repeatedly opening and closing the microwave. For model error, the predicted positions of objects are not always correct. Since a random rollout policy is employed, incorrect object states can result in higher $Q$ -values than correct states, leading to misguided exploration. The wrong translation also compromises the performance as we translate the response from LLM to admissible action or object names to ensure executability. This is partly caused by the VirtualHome environments, as the policy might not understand the underlying logic of the actions in VirtualHome, such as you have to walk close to interact with the object. Thus, if the LLM outputs “open fridge” but is not close enough to the fridge, the action will be translated to other admissible actions (“open fridge” is not inside the admissible actions for this case as it is invalid due to the setting of VirtualHome).
|
| 143 |
+
|
| 144 |
+
# 4 LLM as a model or a policy?
|
| 145 |
+
|
| 146 |
+
When would using LLM as a model outperform using LLM as a policy, and vice versa? We propose using the minimum description length (MDL) principle, also known as Occam’s Razor from the philosophy of science, to gain insights into the issue. The MDL principle suggests choosing the method that has a shorter description when both methods fit the training data well. MDL has been formalized in various ways. One formal statement (from section 7.3 of [28]) is provided here:
|
| 147 |
+
|
| 148 |
+
Theorem 4.1 (Occam’s Razor). Let $\mathcal { H }$ be a hypothesis class and let $d : \mathcal { H } \to \{ 0 , 1 \} ^ { * }$ be a prefix-free description language for $\mathcal { H }$ . Then, for every sample size, $m$ , every confidence parameter, $\delta > 0$ , and every probability distribution, $D$ , with probability greater than $1 - \delta$ over the choice of $S \sim D ^ { m }$ we have that, $\forall h \in \mathcal { H } , L _ { D } ( h ) \leq L _ { S } ( h ) + \sqrt { ( | h | + \ln { ( 2 / \delta ) } ) / 2 m }$ where $L _ { S } ( h )$ is the empirical loss of $h$ on the $S$ , $L _ { D } ( h )$ is the expected loss of $h$ , and $| h |$ is the length of $d ( h )$ .
|
| 149 |
+
|
| 150 |
+
According to Theorem 4.1, we can bound the expected loss of a solution $h$ by the description length $| h |$ and the training loss $L _ { S } ( h )$ . We do not know the LLM training loss for using it as a model or as a policy, but for the purpose of gaining insights, it is reasonable to assume that they are both small. In that case, the MDL principle suggests selecting between a model or policy depending on which of them has the smaller description length given the description language.
|
| 151 |
+
|
| 152 |
+
Numerous caveats should be observed when using Theorem 4.1 to gain insights into the behaviour of LLM as a model and policy. The theorem assumes that the training data is independent and identically distributed (iid), which is likely not true in practice. Nonetheless, the qualitative behaviour is often similar for non-iid data. As the training data of GPT is unknown, when comparing the description length, we also assume that the training data for each subproblem is roughly the same. In addition, using the theorem to gain insights requires major assumptions on the predictor classes $\mathcal { H }$ for model and policy; here, we assume that $\mathcal { H }$ is the model (or policy) class that we are analysing and assume that LLM training using powerful approximators such as transformers has similar behaviour to training using the model (or policy) class. Finally, depending on how the model and policy are used, error propagation may need to be analysed separately.
|
| 153 |
+
|
| 154 |
+
Besides the multiplication example described earlier, we discuss an air travel planning task and the VirtualHome object rearrangement task examined earlier.
|
| 155 |
+
|
| 156 |
+
# 4.1 Travel planning
|
| 157 |
+
|
| 158 |
+
Consider planning for air travel from a starting city to the destination city. To solve the problem through L-Model, we need to have the model – the direct flights out of each city – together with a shortest path algorithm. The model can be represented as a graph, which is likely to be sparse in the real world. For a sparse graph, an adjacency list will give a compact representation. Assuming that the total number of edges grows proportionally to the number of cities, $O ( n \log n )$ bits would be sufficient to describe a graph with $n$ cities, with approximately $\log n$ bits used to describe each city in the adjacency list structure. The shortest path algorithm can be described by any reasonable programming language with a constant size. The method regarding L-Policy can be represented as a 2-dimensional table, where each row and column denotes the current and destination city, and the table entry describes the next city to fly to on the shortest path from the current city to the destination. The next city in the table can be described with $\log n$ bits. As such, with $n$ cities in the rows and columns, there should be approximately $n ^ { 2 } \log n$ bits in total. Thus, according to MDL, the L-Model has a shorter description length and should make fewer generalization errors than the L-Policy for travel planning with sufficiently large $n$ .
|
| 159 |
+
|
| 160 |
+
Experiment. We conducted experiments about planning for air travel from a starting city to a destination city, which we analyzed above. We utilized GPT-3.5 to generate flight paths between cities. We compare it to the GPT-3.5 model-based approach: we use GPT-3.5 to predict neighbouring cities connected by a direct flight, which feeds into the uniform-cost search (i.e., replace node expansion by GPT-3.5 as the world model).
|
| 161 |
+
|
| 162 |
+
We use the data from the Kaggle World cities database, select 68 cities with populations exceeding 5 million in different countries and 62 middle-size cities with populations between 500 thousand and 2 million, and use the Virtual Radar Server to get the flight routes dataset as ground truth. In our tests, we sampled 400 city pairs among large cities and 400 pairs among mid-size cities, evaluating path accuracy by verifying each direct flight exists. Paths were accepted if all flights were valid, even if they extended beyond our selected source and target cities. We evaluate the methods in two settings: predicting the flight route given two large cities and two mid-size cities.
|
| 163 |
+
|
| 164 |
+
Results. The main result shown in Fig 2 suggests that the LLM model $^ +$ search algorithm consistently outperforms the LLM policy, supporting our analysis2. Furthermore, the performance gaps for mid-size cities are larger than for large cities. This is consistent with the fact that there are more midsize cities than large cities (the gap between the description lengths of $n ^ { 2 } \log { n }$ for policies vs $n \log n$ for models grows with the number of cities). Note that performance decreases as the path length increases for both methods. As the number of predictions required for each path increases with path length, the probability of incorrect path prediction also increases.
|
| 165 |
+
|
| 166 |
+

|
| 167 |
+
Figure 2: Flight planning results.
|
| 168 |
+
|
| 169 |
+
# 4.2 Object rearrangement task
|
| 170 |
+
|
| 171 |
+
Consider a house with $n$ movable objects, $m$ containers, and $k$ rooms. If we use L-Model, we must describe the model and search algorithm (i.e., MCTS). The model can be represented as a sparse graph with objects, containers, and rooms as nodes, and weighted directed edges signifying a "located in" relation between the nodes, with the weights specifying the probabilities. Assume that each weight is specified with a constant number of bits. Each of the $n$ objects can be located within the $m + k$ containers or rooms, so each object edge would require approximately $\log ( m + k )$ bits to describe. Each of the $m$ containers can be located in $k$ rooms, so each container edge would require approximately $\log ( k )$ bits to describe. Assume further that the degree of each object and container node in the graph is bounded by a constant; the entire graph then requires $O ( n \log ( \bar { m } + k ) +$ $m \log ( k ) ) = O ( ( m + n ) \log ( m + k ) )$ bits to describe. The MCTS algorithm should be described by a programming language with a constant size. For the L-Policy, tasks can be designated using object-container pairs. Each object-container policy can be defined by a sequence of actions, e.g. “walk to the fridge, open the fridge,” until the object is found, followed by a sequence of actions until the destination container is found. Each action takes $O ( m + k )$ bits to describe. Assuming search sequences and the size of each object-container policy are bounded by a constant. Describing the policies for all mn object-container pairs requires $O ( { \dot { m } } n \log ( m + k ) )$ bits.
|
| 172 |
+
|
| 173 |
+
The composed tasks provide further challenges for L-Policy. Composing tasks increases the description complexity of policies to $O ( ( m n ) ^ { N } \log ( m + k ) )$ , where $N$ is the number of composed tasks if the composition is not exploited in the policies. For the L-Model, decomposition is automatically done in MCTS at the expense of more computation, whereas for the L-Policy, the LLM must learn to do the decomposition. This may make the problem of learning the decomposed policy computationally more difficult and less likely to be approximated by the LLM in practice.
|
| 174 |
+
|
| 175 |
+
This analysis indicates that the L-Model has a shorter description length than the L-Policy. According to the MDL principle, the L-Model will likely have a lower error rate than the L-Policy. However, in this case, we do not have an algorithm that is guaranteed to be efficient for solving L-Model. Instead, we use the L-Policy as a search heuristic to obtain a practically effective search algorithm. As predicted by the MDL principle, the search with the LLM-induced world model, when limited to the neighbourhood of the LLM-induced policy, provides improved performance over L-Policy.
|
| 176 |
+
|
| 177 |
+
# 4.3 Discussion
|
| 178 |
+
|
| 179 |
+
While we have discussed problems where the L-Model outperforms the L-Policy, we would also expect the L-Policy to outperform the L-Model when the description length of policies is shorter than the models. For example, when recommending a tourist itinerary for a city, the description length of the itinerary should be shorter than describing all the places of interest plus the reward and the length of time recommended for visiting each location. In such a case, the LLM may be able to do better in recommending an itinerary than in providing accurate information on all places of interest for planning itineraries.
|
| 180 |
+
|
| 181 |
+
In the multiplication problem, the model-based approach used a known efficient multiplication algorithm. In the air travel planning task, an efficient shortest-path algorithm is used. However, for the object rearrangement problem, we do not have an efficient search algorithm. In this case, we demonstrate another strength of LLMs – as a policy, it can be used as a heuristic for improving the efficiency of search algorithms.
|
| 182 |
+
|
| 183 |
+
# 5 Related work
|
| 184 |
+
|
| 185 |
+
Task planning has a long-standing history in the AI research community. In the early stage, many studies [1, 15, 14, 12] focused on task planning in a discrete state space with deterministic transitions. These methods are intractable for large-scale, long-horizon problems. Recently, researchers have used learning-based methods to learn planning policies directly [22] or to learn search heuristics to accelerate planning [32, 31, 41, 7, 29]. Those policies or heuristics are not generalizable to other unseen settings. Most recently, the pre-trained LLMs have been applied as few-shot policies for task planning [18, 2, 19]. However, the planning policy may not have good compositional generalizablity. In the robotics community, many studies proposed that task planning should be integrated with physical-level motion planning, i.e., task and motion planning (TAMP) [11, 12, 9]. This paper focuses on large-scale task planning with partial observations and large, object-centric domains, in which classical planning is intractable and learning-based methods require massive data.
|
| 186 |
+
|
| 187 |
+
Various approaches are proposed to scale up to large-scale planning problems. Initially, the Monte Carlo method [21, 8, 6] is proposed to tackle intractable large-scale problems using random sampling in the tree search. However, further scaling up to the problem with a large domain with sparse rewards requires massive sampling. Silver et al. [32, 31] integrate MCTS with deep learning to bias the action selection and reduce sampling. The idea has been successfully applied in large-scale planning scenarios [32, 31, 7, 27]. Most recently, studies show that LLM can be a few-shot open-loop [18, 2] and closed-loop [19, 37] planning policy in the large domain, while it may suffer from hallucinations. In this paper, we show that LLMs’ commonsense knowledge can guide a search algorithm, reducing the search space sufficiently for practical planning and producing reasoned results.
|
| 188 |
+
|
| 189 |
+
How to use LLMs for a planning problem? LLMs have been used as a few-shot policy for languageconditioned task planning [18, 2, 19], or a policy for multi-step reasoning problems [38, 42]. However, recent research [10] also suggests that transformer LLMs are inherently limited for solving multi-step reasoning problems. In addition, some studies try to use LLMs as heuristics [43] or transition function [13] in MCTS, boosting the performance in coding or small-scale reasoning. However, the literature has not discussed utilizing LLMs as a world model in depth. We show the benefits of using LLM to model the world, as well as using MDL analysis to decide how to use LLM for planning problems.
|
| 190 |
+
|
| 191 |
+
# 6 Conclusion
|
| 192 |
+
|
| 193 |
+
We use LLMs as the commonsense world model and the heuristic policy within MCTS to achieve better-reasoned decision-making for daily tasks. MCTS enables LLM to leverage its world modelling knowledge for informed reasoning and explore new combinations of actions to tackle novel tasks. LLM helps MCTS through the biased sampling of states and actions, improving its efficiency in resolving complex task-planning problems. Our analysis and empirical evidence suggest that, for certain real-world domains, if the description length of the world is substantially shorter than policy, using LLM as a model in a model-based approach is a better option than using LLM as policy.
|
| 194 |
+
|
| 195 |
+
Limitations. The runtime of LLM-MCTS is currently hindered by multiple LLM calls. The details of runtime performance are in Appendix E. While our method requires multiple LLM calls, it provides substantially improved results. There are also various ways to enhance runtime performance like using smaller LLMs like Llama [35, 36] or distilling LLM’s knowledge into a smaller model [30, 16, 23]. Those are interesting avenues for future research.
|
| 196 |
+
|
| 197 |
+
Broader impact. There might be concerns about the inherent biases of LLMs that may lead to unfair or risky decisions in some domains. Further study about the fairness and bias of LLMs’ knowledge would be beneficial.
|
| 198 |
+
|
| 199 |
+
# Acknowledgments and Disclosure of Funding
|
| 200 |
+
|
| 201 |
+
This research is supported in part by the National Research Foundation (NRF), Singapore and DSO National Laboratories under the AI Singapore Program (No. AISG2-RP-2020-016) and the Agency of Science, Technology and Research (A\*STAR), Singapore, under the National Robotics Program (No. M23NBK0053).
|
| 202 |
+
|
| 203 |
+
# References
|
| 204 |
+
|
| 205 |
+
[1] Constructions Aeronautiques, Adele Howe, Craig Knoblock, ISI Drew McDermott, Ashwin Ram, Manuela Veloso, Daniel Weld, David Wilkins SRI, Anthony Barrett, Dave Christianson, et al. Pddl| the planning domain definition language. Technical Report, Tech. Rep., 1998. 10
|
| 206 |
+
[2] 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. 1, 2, 10
|
| 207 |
+
[3] Dhruv Batra, Angel X Chang, Sonia Chernova, Andrew J Davison, Jia Deng, Vladlen Koltun, Sergey Levine, Jitendra Malik, Igor Mordatch, Roozbeh Mottaghi, et al. Rearrangement: A challenge for embodied ai. arXiv preprint arXiv:2011.01975, 2020. 3
|
| 208 |
+
[4] Lukas Berglund, Meg Tong, Max Kaufmann, Mikita Balesni, Asa Cooper Stickland, Tomasz Korbak, and Owain Evans. The reversal curse: Llms trained on" a is b" fail to learn" b is a". arXiv preprint arXiv:2309.12288, 2023. 1
|
| 209 |
+
[5] Anthony Brohan, Noah Brown, Justice Carbajal, Yevgen Chebotar, Joseph Dabis, Chelsea Finn, Keerthana Gopalakrishnan, Karol Hausman, Alex Herzog, Jasmine Hsu, et al. Rt-1: Robotics transformer for real-world control at scale. arXiv preprint arXiv:2212.06817, 2022. 1 [6] 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. 10
|
| 210 |
+
[7] Panpan Cai, Yuanfu Luo, Aseem Saxena, David Hsu, and Wee Sun Lee. Lets-drive: Driving in a crowd by learning from tree search. arXiv preprint arXiv:1905.12197, 2019. 10
|
| 211 |
+
[8] Rémi Coulom. Efficient selectivity and backup operators in monte-carlo tree search. In Computers and Games: 5th International Conference, CG 2006, Turin, Italy, May 29-31, 2006. Revised Papers 5, pages 72–83. Springer, 2007. 2, 10
|
| 212 |
+
[9] Yan Ding, Xiaohan Zhang, Chris Paxton, and Shiqi Zhang. Task and motion planning with large language models for object rearrangement. arXiv preprint arXiv:2303.06247, 2023. 10
|
| 213 |
+
[10] Nouha Dziri, Ximing Lu, Melanie Sclar, Xiang Lorraine Li, Liwei Jian, Bill Yuchen Lin, Peter West, Chandra Bhagavatula, Ronan Le Bras, Jena D Hwang, et al. Faith and fate: Limits of transformers on compositionality. arXiv preprint arXiv:2305.18654, 2023. 1, 2, 10
|
| 214 |
+
[11] Caelan Reed Garrett, Rohan Chitnis, Rachel Holladay, Beomjoon Kim, Tom Silver, Leslie Pack Kaelbling, and Tomás Lozano-Pérez. Integrated task and motion planning. Annual review of control, robotics, and autonomous systems, 4:265–293, 2021. 10
|
| 215 |
+
[12] Caelan Reed Garrett, Tomás Lozano-Pérez, and Leslie Pack Kaelbling. Pddlstream: Integrating symbolic planners and blackbox samplers via optimistic adaptive planning. In Proceedings of the International Conference on Automated Planning and Scheduling, volume 30, pages 440–448, 2020. 10
|
| 216 |
+
[13] Shibo Hao, Yi Gu, Haodi Ma, Joshua Jiahua Hong, Zhen Wang, Daisy Zhe Wang, and Zhiting Hu. Reasoning with language model is planning with world model. arXiv preprint arXiv:2305.14992, 2023. 10
|
| 217 |
+
[14] Malte Helmert. The fast downward planning system. Journal of Artificial Intelligence Research, 26:191–246, 2006. 10
|
| 218 |
+
[15] Jörg Hoffmann. Ff: The fast-forward planning system. AI magazine, 22(3):57–57, 2001. 10
|
| 219 |
+
[16] Cheng-Yu Hsieh, Chun-Liang Li, Chih-kuan Yeh, Hootan Nakhost, Yasuhisa Fujii, Alex Ratner, Ranjay Krishna, Chen-Yu Lee, and Tomas Pfister. Distilling step-by-step! outperforming larger language models with less training data and smaller model sizes. In Findings of the Association for Computational Linguistics: ACL 2023, pages 8003–8017, Toronto, Canada, July 2023. Association for Computational Linguistics. 10
|
| 220 |
+
[17] Eric Huang, Zhenzhong Jia, and Matthew T Mason. Large-scale multi-object rearrangement. In 2019 International Conference on Robotics and Automation (ICRA), pages 211–218. IEEE, 2019. 3
|
| 221 |
+
[18] Wenlong Huang, Pieter Abbeel, Deepak Pathak, and Igor Mordatch. Language models as zero-shot planners: Extracting actionable knowledge for embodied agents. In International Conference on Machine Learning, pages 9118–9147. PMLR, 2022. 1, 2, 5, 6, 10
|
| 222 |
+
[19] Wenlong Huang, Fei Xia, Ted Xiao, Harris Chan, Jacky Liang, Pete Florence, Andy Zeng, Jonathan Tompson, Igor Mordatch, Yevgen Chebotar, et al. Inner monologue: Embodied reasoning through planning with language models. arXiv preprint arXiv:2207.05608, 2022. 1, 2, 10
|
| 223 |
+
[20] Yash Kant, Arun Ramachandran, Sriram Yenamandra, Igor Gilitschenski, Dhruv Batra, Andrew Szot, and Harsh Agrawal. Housekeep: Tidying virtual households using commonsense reasoning. In European Conference on Computer Vision, pages 355–373. Springer, 2022. 3
|
| 224 |
+
[21] Levente Kocsis and Csaba Szepesvári. Bandit based monte-carlo planning. In Machine Learning: ECML 2006: 17th European Conference on Machine Learning Berlin, Germany, September 18-22, 2006 Proceedings 17, pages 282–293. Springer, 2006. 6, 10
|
| 225 |
+
[22] Shuang Li, Xavier Puig, Chris Paxton, Yilun Du, Clinton Wang, Linxi Fan, Tao Chen, De-An Huang, Ekin Akyürek, Anima Anandkumar, et al. Pre-trained language models for interactive decision-making. Advances in Neural Information Processing Systems, 35:31199–31212, 2022. 1, 2, 3, 4, 6, 10, 15, 16
|
| 226 |
+
[23] Chen Liang, Simiao Zuo, Qingru Zhang, Pengcheng He, Weizhu Chen, and Tuo Zhao. Less is more: Task-aware layer-wise distillation for language model compression. In International Conference on Machine Learning, pages 20852–20867. PMLR, 2023. 10
|
| 227 |
+
[24] Xavier Puig, Kevin Ra, Marko Boben, Jiaman Li, Tingwu Wang, Sanja Fidler, and Antonio Torralba. Virtualhome: Simulating household activities via programs. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pages 8494–8502, 2018. 2, 6, 14, 15
|
| 228 |
+
[25] Xavier Puig, Tianmin Shu, Shuang Li, Zilin Wang, Yuan-Hong Liao, Joshua B Tenenbaum, Sanja Fidler, and Antonio Torralba. Watch-and-help: A challenge for social perception and human-ai collaboration. arXiv preprint arXiv:2010.09890, 2020. 2, 3, 4, 6, 16
|
| 229 |
+
[26] Nils Reimers and Iryna Gurevych. Sentence-bert: Sentence embeddings using siamese bertnetworks. arXiv preprint arXiv:1908.10084, 2019. 4, 5
|
| 230 |
+
[27] 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. 10
|
| 231 |
+
[28] Shai Shalev-Shwartz and Shai Ben-David. Understanding machine learning: From theory to algorithms. Cambridge university press, 2014. 2, 8
|
| 232 |
+
[29] Pratyusha Sharma, Antonio Torralba, and Jacob Andreas. Skill induction and planning with latent language. In Proceedings of the 60th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pages 1713–1726, Dublin, Ireland, May 2022. Association for Computational Linguistics. 10
|
| 233 |
+
[30] Kumar Shridhar, Alessandro Stolfo, and Mrinmaya Sachan. Distilling reasoning capabilities into smaller language models. In Findings of the Association for Computational Linguistics: ACL 2023, pages 7059–7073, 2023. 10
|
| 234 |
+
[31] David Silver, Thomas Hubert, Julian Schrittwieser, Ioannis Antonoglou, Matthew Lai, Arthur Guez, Marc Lanctot, Laurent Sifre, Dharshan Kumaran, Thore Graepel, et al. A general reinforcement learning algorithm that masters chess, shogi, and go through self-play. Science, 362(6419):1140–1144, 2018. 10
|
| 235 |
+
[32] 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. 10
|
| 236 |
+
[33] Ishika Singh, Valts Blukis, Arsalan Mousavian, Ankit Goyal, Danfei Xu, Jonathan Tremblay, Dieter Fox, Jesse Thomason, and Animesh Garg. Progprompt: Generating situated robot task plans using large language models. In 2023 IEEE International Conference on Robotics and Automation (ICRA), pages 11523–11530, 2023. 2, 3
|
| 237 |
+
[34] Andrew Szot, Alexander Clegg, Eric Undersander, Erik Wijmans, Yili Zhao, John Turner, Noah Maestre, Mustafa Mukadam, Devendra Singh Chaplot, Oleksandr Maksymets, et al. Habitat 2.0: Training home assistants to rearrange their habitat. Advances in Neural Information Processing Systems, 34:251–266, 2021. 3
|
| 238 |
+
[35] Hugo Touvron, Thibaut Lavril, Gautier Izacard, Xavier Martinet, Marie-Anne Lachaux, Timothée Lacroix, Baptiste Rozière, Naman Goyal, Eric Hambro, Faisal Azhar, et al. Llama: Open and efficient foundation language models. arXiv preprint arXiv:2302.13971, 2023. 10
|
| 239 |
+
[36] 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. 10
|
| 240 |
+
[37] Zihao Wang, Shaofei Cai, Anji Liu, Xiaojian Ma, and Yitao Liang. Describe, explain, plan and select: Interactive planning with large language models enables open-world multi-task agents. arXiv preprint arXiv:2302.01560, 2023. 10
|
| 241 |
+
[38] Jason Wei, Xuezhi Wang, Dale Schuurmans, Maarten Bosma, Fei Xia, Ed Chi, Quoc V Le, Denny Zhou, et al. Chain-of-thought prompting elicits reasoning in large language models. Advances in Neural Information Processing Systems, 35:24824–24837, 2022. 10
|
| 242 |
+
[39] Luca Weihs, Matt Deitke, Aniruddha Kembhavi, and Roozbeh Mottaghi. Visual room rearrangement. In Proceedings of the IEEE/CVF conference on computer vision and pattern recognition, pages 5922–5931, 2021. 3
|
| 243 |
+
[40] Yaqi Xie, Chen Yu, Tongyao Zhu, Jinbin Bai, Ze Gong, and Harold Soh. Translating natural language to planning goals with large-language models. arXiv preprint arXiv:2302.05128, 2023. 4
|
| 244 |
+
[41] Danfei Xu, Roberto Martín-Martín, De-An Huang, Yuke Zhu, Silvio Savarese, and Li F Fei-Fei. Regression planning networks. Advances in Neural Information Processing Systems, 32, 2019. 10
|
| 245 |
+
[42] Shunyu Yao, Dian Yu, Jeffrey Zhao, Izhak Shafran, Thomas L Griffiths, Yuan Cao, and Karthik Narasimhan. Tree of thoughts: Deliberate problem solving with large language models. arXiv preprint arXiv:2305.10601, 2023. 10
|
| 246 |
+
[43] Shun Zhang, Zhenfang Chen, Yikang Shen, Mingyu Ding, Joshua B Tenenbaum, and Chuang Gan. Planning with large language models for code generation. arXiv preprint arXiv:2303.05510, 2023. 10
|
| 247 |
+
[44] Brianna Zitkovich, Tianhe Yu, Sichun Xu, Peng Xu, Ted Xiao, Fei Xia, Jialin Wu, Paul Wohlhart, Stefan Welker, Ayzaan Wahid, et al. Rt-2: Vision-language-action models transfer web knowledge to robotic control. In 7th Annual Conference on Robot Learning, 2023. 1
|
| 248 |
+
|
| 249 |
+
# Appendix
|
| 250 |
+
|
| 251 |
+
# A Virtualhome experimental environments
|
| 252 |
+
|
| 253 |
+
We use the VirtualHome simulator [24] to evaluate our approach as well as the baseline methods. VirtualHome is a 3D household environment with partial observation, large action space, and a long planning horizon. It contains hundreds of interactive objects and containers, allowing it to perform various household object rearrangement tasks. This section introduces details of the tasks, the goal specifications, the actions, and the observations in our experimental settings.
|
| 254 |
+
|
| 255 |
+
# A.1 List of objects, containers, surfaces, and rooms in the apartment
|
| 256 |
+
|
| 257 |
+
We list all the objects that are included in our experimental environment. Here, we can put moveable objects into the Containers or on the Surfaces. The Containers and Surfaces are located at a Room in the apartment.
|
| 258 |
+
|
| 259 |
+
• Containers: bathroom cabinet, kitchen cabinet, bathroom counter, fridge, oven, dishwasher, microwave, stove, bathroom cabinet
|
| 260 |
+
• Surfaces: bed, bookshelf, cabinet, coffee table, cutting board, floor, fryingpan, kitchen counter, kitchen table, nightstand, sofa, stove
|
| 261 |
+
moveable objects: alcohol, apple, banana, bar soap, bell pepper, boardgame, book, box, bread slice, bucket, candle, candy bar, carrot, cellphone, cereal, chicken, Chinese food, chips, chocolate syrup, clock, clothes pants, clothes pile, clothes shirt, coatrack, coffeepot, condiment bottle, condiment shaker, cooking pot, crackers, crayons, creamy buns, cupcake, cutlery fork, cutlery knife, cutlets, cutting board, dish bowl, dishwashing liquid, face cream, folder, fryingpan, glasses, globe, hair product, hanger, juice, keyboard, lime, lotion bottle, magazine, milk, milkshake, minced meat, mouse, mug, notes, oven tray, pancake, paper, pear, pie, pillow, plate, plum, poundcake, pudding, radio, remote control, salad, salmon, slippers, sports ball, sundae, teddybear, toilet paper, toothbrush, toothpaste, towel, towel rack, toy, washing sponge, water glass, whipped cream, wine, wineglass
|
| 262 |
+
• Rooms: bedroom, bathroom, living room, kitchen.
|
| 263 |
+
|
| 264 |
+
# A.2 Tasks
|
| 265 |
+
|
| 266 |
+
We use the object rearrangement tasks for evaluation. The task is to search for one or more objects in the house and move them to the desired positions. We use natural language as the interface to specify the tasks. Thus, the agent should take as input the natural language instruction and observations, and then output actions.
|
| 267 |
+
|
| 268 |
+
The tasks are randomly sampled from different distributions. We define various types of object rearrangement tasks for evaluation:
|
| 269 |
+
|
| 270 |
+
• Simple: this task is to move one object in the house to the desired location. The combination of the object and desired location has appeared in the training dataset.
|
| 271 |
+
• Novel Simple: this task is to move one object in the house to the desired location. The combination of the object and desired location hasnot appeared in the training dataset.
|
| 272 |
+
• Comp.: this task is composed of 2 Simple tasks, moving more than one object in the house to their desired location. This kind of task has a longer planning horizon as it requires moving multiple objects to complete. The combinations of Simple tasks have appeared in the training dataset.
|
| 273 |
+
• Novel Comp. (2): this task is composed of 2 Simple tasks, moving more than one object in the house to their desired location. The combinations of Simple tasks have not appeared in the training dataset.
|
| 274 |
+
• Novel Comp. (3): this task is composed of 3 Simple tasks, moving more than one object in the house to their desired location. This kind of task has the longest planning horizon. The combinations of Simple tasks have not appeared in the training dataset.
|
| 275 |
+
|
| 276 |
+
We also have different household environments:
|
| 277 |
+
|
| 278 |
+
• Seen Apartment: the map of the apartment is shown in Figure 3. These household environments are the same as the ones in the training set, while the object positions are randomly initialized according to a pre-defined commonsense distribution in VirtualHome [24]. • Unseen Apartment: the map of the apartment is shown in Figure 4. These household environments are not the same as the ones in the training set. The object positions are also sampled from a different pre-defined commonsense distribution in VirtualHome [24].
|
| 279 |
+
|
| 280 |
+

|
| 281 |
+
Figure 3: The map of the seen apartments in our setting. These household environments are the same as the ones in the training set, while the object positions are randomly initialized according to a commonsense distribution.
|
| 282 |
+
|
| 283 |
+

|
| 284 |
+
Figure 4: The map of the unseen apartments in our setting. These household environments are not the same as the ones in the training set. The object positions are also sampled from a different commonsense distribution.
|
| 285 |
+
|
| 286 |
+
# A.3 Goal specification
|
| 287 |
+
|
| 288 |
+
Similar to prior works [22], we define the goal in the VirtualHome system by a set of predicates. For instance, a goal can be defined by Inside(apple, fridge):2; Inside(plate, dishwasher):1, meaning “put two apples inside the fridge and put one plate inside the dishwasher.” For Simple and Novel Simple tasks, it only requires moving one object, while Comp. and Novel Comp. have more than one object to move.
|
| 289 |
+
|
| 290 |
+
# A.4 Actions
|
| 291 |
+
|
| 292 |
+
In VirtualHome, the agent is able to navigate in the environment, grab an object, put an object inside the containers (e.g., fridge) or on the surfaces (e.g., table), open and close the container, etc. The actions in VirtualHome are grounded to moveable objects, containers, or rooms in the environment. For example, Open(5) is to open an object with index (5). The list of available actions in our setting are listed below:
|
| 293 |
+
|
| 294 |
+
• Walk(<item>): walk to the <item>. The <item> can be a moveable object, a container, or a room. The precondition of this action is that the <item> is visible. The effect of this action is that the agent is close to the <item> if the <item> is an object or inside the <item> if the <item> is a room. The action is translated into the sentence “walk to the <name of item>” when feeding into LLMs.
|
| 295 |
+
Open(<item>): open the <item>. The <item> can be a moveable object or a container. The precondition of this action is that the agent should be close to <item>. The effect of this action is that the <item> is opened. The action is translated into the sentence “open the <name of item>” when feeding into LLMs. Close(<item>): close the <item>. The <item> can be a moveable object or a container. The precondition of this action is that the agent should be close to <item>. The effect of this action is that the <item> is closed. The action is translated into the sentence “close the <name of item>” when feeding into LLMs.
|
| 296 |
+
• Grab(<item>): grab the <item>. The <item> should be a moveable object. The precondition of this action is that the agent should be close to the <item>, and the agent is not holding any objects. The effect of this action is that the agent will hold the <item>. The action is translated into the sentence “grab the <name of item>” when feeding into LLMs.
|
| 297 |
+
• PutIn(<item1>, <item2>): put the moveable object <item1> inside the container <item2>. The precondition of this action is that the agent should be close to the <item2> and holding <item1>. The effect of this action is that the agent is not holding any objects, and the <item1 $>$ is inside the <item2>. The action is translated into the sentence “put the <name of item1> inside the <name of item2>” when feeding into LLMs.
|
| 298 |
+
PutBack(<item1>, <item2>): put the moveable object <item1> on the surface <item2>. The precondition of this action is that the agent should be close to the <item2> and holding <item1>. The effect of this action is that the agent is not holding any objects, and the <item1> is on the <item2>. The action is translated into the sentence “put the <name of item1> on the <name of item2>” when feeding into LLMs.
|
| 299 |
+
|
| 300 |
+
# A.5 Observations
|
| 301 |
+
|
| 302 |
+
We use the same representation as [22] for partial observation. The observation is a list of visible objects and relationships between those objects. Each object or container has a state: open or close. The fine-tuned GPT2 policy [22] also uses the 3d coordinates of the object. We also use relationships to connect different objects, such as Inside(apple, fridge). Those relationships are translated to natural language descriptions when feeding into LLMs, such as “an apple is inside the fridge.”
|
| 303 |
+
|
| 304 |
+
# B Data gathering
|
| 305 |
+
|
| 306 |
+
Similar to prior works [25, 22], we collect expert trajectories in VirtualHome using regression planning with handcrafted heuristics3. The expert has full observation of the environment. Given the goal predicates and full observation, the agent will use the handcrafted heuristics for each task to effectively search for the solutions. The expert also has a handcrafted mechanism for compositional tasks to decompose one task into subtasks and finish them progressively. For each trajectory, we include the goal predicates (used by the VirtualHome system and the expert agent), the goal instruction (used by the agent), the partial observation for each time step (not used by the expert agent, the expert agent uses full observation), and the expert actions.
|
| 307 |
+
|
| 308 |
+
# C Implementation details of belief in LLM-MCTS
|
| 309 |
+
|
| 310 |
+
This section introduces our implementation details for the belief of states in GPT3.5-MCTS. The source code will be released at https://llm-mcts.github.io before the publication.
|
| 311 |
+
|
| 312 |
+
# C.1 State representation
|
| 313 |
+
|
| 314 |
+
We represent the states by a list of objects and their relationships. Each object has a unique name and id in the simulator, as well as the state of the object. We use the same unique name and id in our state representation. The relationships connect different objects, containers, surfaces, and rooms. The VirtualHome contains 59 different types of relationships, including Inside, On, Close, Facing, etc. We use the same type of relationships in our state representation.
|
| 315 |
+
|
| 316 |
+
# C.2 Belief
|
| 317 |
+
|
| 318 |
+
The belief of the state also contains a list of objects and their relationships. However, we parameterize the relationships by a vector, representing the probability that the relationship is true. This vector is affiliated with the object representation. For simplicity, we only include the relationships Inside, On in our belief, as we only query LLM about the object positions to build up the commonsense belief of the state.
|
| 319 |
+
|
| 320 |
+
When building up a state’s belief, we query LLM to predict the position of each moveable object, container, and surface. The position of a moveable object is specified by the relationships (i.e., Inside or $\mathtt { O n }$ ) between itself and a container or surface. The position of a container or a surface is specified by its relationship (i.e., Inside) to the room. We use sampling to approximate the distribution of the position. The moveable objects’ belief of position is represented by a vector whose dimension is the same as the total number of containers and surfaces in the house. Each vector entry denotes the probability that whether the object is inside a specific container or on a specific surface is true. When asking LLM to predict the object positions, we asked LLM for $M$ times and received multiple responses from LLM. We then count each entry’s total number of predictions and normalize them to become a probability distribution. We initialize the value of other unsampled entries in the vector by a lower bound of the probability $1 \times 1 0 ^ { - 3 }$ to ensure that the model will not eliminate other possibilities when the commonsense model is wrong.
|
| 321 |
+
|
| 322 |
+
The agent will receive new observations to update their belief when interacting with the environment. We will first predict the next state of the agent by the transition function and then update the belief of the object positions by new observations. Suppose the object is inside the current observation. In that case, the other entry of the relations between objects will be masked out by zero, and the entry of the relationships in observation will be replaced by the value of one. However, if a relationship is not inside the observation, the value of the corresponding entry will be replaced by zero, and the vector will be normalized again.
|
| 323 |
+
|
| 324 |
+
# D Visualized examples
|
| 325 |
+
|
| 326 |
+
We provide a set of successful (shown in Figure 5) and failed trajectories (shown in Figure 6) to give a better understanding of the tasks and our method. Policy, model, and translation errors are the primary causes of failures. Among these, policy errors are responsible for the majority of the failures. Often time, the policy produces unreasonable behaviors that mislead the search procedure. For example, it usually outputs inadmissible actions, such as “walk to the cutlery fork” where the “cutlery fork” is not in the observation (shown in Figure 6 (a)). It also produces back-and-forth behaviors, resulting in an unreasonable heuristic and slowing the search procedure. For example, when putting objects inside the microwave, it is sometimes struck by repeatedly opening and closing the microwave. For model error, the predicted positions of objects are not always correct. Since a random rollout policy is employed, incorrect object states can result in higher $Q$ -values than correct states, leading to misguided exploration (shown in Figure 6 (b)). The wrong translation also compromises the performance as we translate the response from LLM to admissible action or object names to ensure executability. This is caused in part by the VirtualHome environments, as the policy might not understand the underlying logic of the actions in VirtualHome, such as you have to walk close to interact with the object. Thus, if the LLM outputs “open fridge” but is not close enough to the fridge, the action will be translated to other admissible actions (“open fridge” is not inside the admissible actions for this case as it is invalid due to the setting of VirtualHome).
|
| 327 |
+
|
| 328 |
+
Instruction: Put one plate inside the
|
| 329 |
+
kitchen cabinet and one chicken
|
| 330 |
+
inside microwave.
|
| 331 |
+
1: Walk to kitchen
|
| 332 |
+
2: Walk to plate
|
| 333 |
+
3: Grab plate
|
| 334 |
+
4: Walk to kitchen cabinet
|
| 335 |
+
5: Open kitchen cabinet
|
| 336 |
+
6: Put plate inside kitchen cabinet
|
| 337 |
+
7: Move fridge
|
| 338 |
+
8: Open fridge
|
| 339 |
+
9: Grab chicken
|
| 340 |
+
10: Walk to microwave
|
| 341 |
+
11: Open microwave
|
| 342 |
+
12: Put chicken inside microwave
|
| 343 |
+
|
| 344 |
+
Instruction: Put one apple on the kitchen table and one toothbrush inside the bathroom cabinet.
|
| 345 |
+
|
| 346 |
+

|
| 347 |
+
Figure 5: Successful examples
|
| 348 |
+
|
| 349 |
+
1: Walk to fridge
|
| 350 |
+
2: Open fridge
|
| 351 |
+
3: Walk to apple
|
| 352 |
+
4: Grab apple
|
| 353 |
+
5: Walk to kitchen table
|
| 354 |
+
6: Put apple on kitchen table
|
| 355 |
+
7: Walk to bathroom
|
| 356 |
+
8: Walk to toothbrush
|
| 357 |
+
9: Grab toothbrush
|
| 358 |
+
10: Open bathroom cabinet
|
| 359 |
+
11: Put toothbrush inside bathroom
|
| 360 |
+
cabinet
|
| 361 |
+
1: Walk to kitchen
|
| 362 |
+
2: Walk to kitchen cabinet
|
| 363 |
+
3: Open kitchen cabinet
|
| 364 |
+
4: Walk to dishwasher
|
| 365 |
+
5: Open dishwasher
|
| 366 |
+
6: Grab cutlery fork
|
| 367 |
+
7: Walk to kitchen table
|
| 368 |
+
8: Put cutlery fork on kitchen table
|
| 369 |
+
9: Walk to apple
|
| 370 |
+
10: Grab apple
|
| 371 |
+
11: Walk fridge
|
| 372 |
+
12: Open fridge
|
| 373 |
+
13: Put apple inside fridge
|
| 374 |
+
14: Close fridge
|
| 375 |
+
15: Walk to kitchen cabinet
|
| 376 |
+
16: Open kitchen cabinet (Failed)
|
| 377 |
+
17: Grab chips
|
| 378 |
+
18: Walk to living room
|
| 379 |
+
19: Walk to coffee table
|
| 380 |
+
20: Put chips on coffee table
|
| 381 |
+
|
| 382 |
+
Instruction: Put one cutlery fork on
|
| 383 |
+
the coffee table
|
| 384 |
+
1: Walk to kitchen
|
| 385 |
+
2: Walk to cutlery knife
|
| 386 |
+
3: Walk to cutlery knife
|
| 387 |
+
4: Walk to cutlery knife
|
| 388 |
+
Instruction: Put one apple inside the
|
| 389 |
+
fridge
|
| 390 |
+
1: Walk to living room
|
| 391 |
+
2: Walk to coffee table
|
| 392 |
+
3: Walk to bedroom
|
| 393 |
+
4: Walk to nightstand
|
| 394 |
+
5: Walk to kitchen
|
| 395 |
+
6: Walk to kitchen cabinet
|
| 396 |
+
7: Open kitchen cabinet
|
| 397 |
+
|
| 398 |
+

|
| 399 |
+
Figure 6: Failed examples. (a) Policy error and translation error. LLM outputs walk to the cutlery fork, but the cutlery fork is not in observation. We use embeddings to evaluate the most similar valid actions. Therefore it translates the action to one similar action “walk to cutlery knife.” The action has an incorrect semantic meaning and causes failure. (b) model error. The LLM predicts the apple is on the nightstand in the bedroom and on the coffee table in the living room. As we are using random rollout to get the estimation of the reward, there will be situations when the incorrect actions result in a higher estimated $Q$ value, thereby misleading the exploration.
|
| 400 |
+
|
| 401 |
+
Table 3: Runtime performance (second $\pm$ standard error)
|
| 402 |
+
|
| 403 |
+
<table><tr><td></td><td>GPT3.5-MCTS</td><td>GPT3.5 Policy</td><td>UCT</td><td>GPT2 Policy</td></tr><tr><td>Runtime</td><td>67.83 ± 18.92</td><td>1.19 ± 0.81</td><td>120.0 ± 0.0</td><td>0.33 ± 0.07</td></tr></table>
|
| 404 |
+
|
| 405 |
+
# E Runtime performance
|
| 406 |
+
|
| 407 |
+
The runtime performance to make one-step decisions for simple object-rearrangement tasks is reported in Fig E. The experimental setup is the same as our main experiments in VirtualHome. The simple tasks are the tasks that only require the rearrangement of one item generated from the same distribution as the training dataset. We used 100 times simulation during the tree search for GPT3.5-MCTS in our experiments. For UCT, we bound the runtime by 120 seconds. The details of our hardware for experiments are enclosed below:
|
| 408 |
+
|
| 409 |
+
• CPU: Intel(R) Xeon(R) Gold 6240 CPU $@$ 2.60GHz (72 cores) • GPU: NVIDIA GeForce RTX 2080 Ti
|
| 410 |
+
|
| 411 |
+
# F Prompts
|
| 412 |
+
|
| 413 |
+
One example prompt for the LLM policy and the exact prompt we used for building up the commonsense belief is shown below.
|
| 414 |
+
|
| 415 |
+
# Listing 1: Example prompt for the heuristic policy
|
| 416 |
+
|
| 417 |
+
You need to generate a high-level plan for completing a household task using the allowed actions and visible objects. Allowed actions: walk to <object>, walk to <room>, walk to <container>, walk to <surface>, grab <object>, open <container>, close <container>, put <object> on <surface>, put <object> inside <container>.
|
| 418 |
+
3 Rooms in the house: bedroom, bathroom, living room, kitchen
|
| 419 |
+
4 You need to strictly follow the format in the following examples:
|
| 420 |
+
5 Goal: Put one apple inside the fridge
|
| 421 |
+
6 Completed actions: walk to the kitchen, walk to the apple Current Observation: a kitchen table is inside the kitchen, a kitchen counter is inside the kitchen, an apple is on the kitchen counter, a plate is on the kitchen table, a banana is on the kitchen counter, a fridge is inside the kitchen and fridge is closed, a kitchen cabinet is inside the kitchen and kitchen cabinet is closed, a cutlery knife is on the kitchen table, a microwave is inside the kitchen and microwave is closed, a dishwasher is inside the kitchen and dishwasher is closed.
|
| 422 |
+
8 Next actions: grab the apple, walk to the fridge, open the fridge, put the apple inside the fridge, close the fridge, done.
|
| 423 |
+
9 Now, finish the next following task.
|
| 424 |
+
10
|
| 425 |
+
11 Goal: Put one apple on the kitchen table
|
| 426 |
+
12 Completed actions: walk to the kitchen
|
| 427 |
+
13 Current observation: a kitchen table is inside the kitchen, an apple is on the kitchen table, a kitchen counter is inside the kitchen, an apple is on the kitchen counter, a cutlery knife is on the kitchen counter, a fridge is inside the kitchen and fridge is closed, a kitchen cabinet is inside the kitchen and kitchen cabinet is closed, a kitchen table is inside the kitchen, a plate is on the kitchen table, a pounding cake is on the kitchen table, a microwave is inside the kitchen and microwave is closed, a dishwasher is inside the kitchen and dishwasher is closed. Ney
|
| 428 |
+
|
| 429 |
+
# Listing 2: Example prompt for the commonsense world model
|
| 430 |
+
|
| 431 |
+
You need to predict the positions of the moveable objects, containers, and surfaces in the apartment according to the commonsense. Rooms in the apartment: bedroom, bathroom, living room, kitchen. 3 Containers in the apartment: bathroom cabinet, kitchen cabinet, bathroom counter, fridge, oven, dishwasher, microwave, stove, bathroom cabinet. 4 Surfaces in the apartment: bed, bookshelf, cabinet, coffee table, cutting board, floor, fryingpan, kitchen counter, kitchen table, nightstand, sofa, stove. 5 You need to strictly follow the format in the following examples: 6 Question: what are the possible positions of strawberry? Answer: Inside fridge, On kitchen table. 8 Question: what are the possible positions of soap? 9 Answer: On bathroom counter. 10 Question: what are the possible positions of water cup? 11 Answer: On kitchen table, Inside dishwasher. 12 Now, answer the next following question. 13 Question: what are the possible positions of apple?
|
| 432 |
+
|
| 433 |
+
# Listing 3: Example prompt for the natural language instruction interpretation
|
| 434 |
+
|
| 435 |
+
You need to interpret the natural language goal into a formal goal representation 2 For example, 3 Goal: put 1 toothbrush inside the bathroomcabinet. 4 Formal goal: (INSIDE, toothbrush, bathroomcabinet, 1) 5 Goal: put 1 toothbrush inside the bathroomcabinet, put 1 apple on the kitchentable. 6 Formal goal: (INSIDE, toothbrush, bathroomcabinet, 1)-(ON, apple, kitchentable, 1) Goal: put 1 toothbrush inside the bathroomcabinet, put 1 apple on the kitchentable, put 1 chicken inside the fridge. 8 Formal goal: (INSIDE, toothbrush, bathroomcabinet, 1)-(ON, apple, kitchentable, 1)-(INSIDE, chicken, fridge, 1) 9 Now, interpret the next following goals:
|
md/dev/X6dEqXIsEW/X6dEqXIsEW.md
ADDED
|
@@ -0,0 +1,222 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# On the Planning Abilities of Large Language Models : A Critical Investigation
|
| 2 |
+
|
| 3 |
+
Karthik Valmeekam School of Computing & AI Arizona State University Tempe. kvalmeek@asu.edu
|
| 4 |
+
|
| 5 |
+
Matthew Marquez School of Computing & AI Arizona State University, Tempe. mmarqu22@asu.edu
|
| 6 |
+
|
| 7 |
+
Sarath Sreedharan∗ Department of Computer Science, Colorado State University, Fort Collins. sarath.sreedharan@colostate.edu
|
| 8 |
+
|
| 9 |
+
Subbarao Kambhampati School of Computing & AI Arizona State University, Tempe. rao@asu.edu
|
| 10 |
+
|
| 11 |
+
# Abstract
|
| 12 |
+
|
| 13 |
+
Intrigued by the claims of emergent reasoning capabilities in LLMs trained on general web corpora, in this paper, we set out to investigate their planning capabilities. We aim to evaluate (1) the effectiveness of LLMs in generating plans autonomously in commonsense planning tasks and (2) the potential of LLMs as a source of heuristic guidance for other agents (AI planners) in their planning tasks. We conduct a systematic study by generating a suite of instances on domains similar to the ones employed in the International Planning Competition and evaluate LLMs in two distinct modes: autonomous and heuristic. Our findings reveal that LLMs’ ability to generate executable plans autonomously is rather limited, with the best model (GPT-4) having an average success rate of ${ \sim } 1 2 \%$ across the domains. However, the results in the heuristic mode show more promise. In the heuristic mode, we demonstrate that LLM-generated plans can improve the search process for underlying sound planners and additionally show that external verifiers can help provide feedback on the generated plans and back-prompt the LLM for better plan generation.
|
| 14 |
+
|
| 15 |
+
# 1 Introduction
|
| 16 |
+
|
| 17 |
+
It would be no exaggeration to say that transformer-based large language models (LLMs) have revolutionized the field of natural language processing (NLP). Kicked off by the advances presented by the GPT- $\mathbf { X }$ models developed by OpenAI [27], these types of language models currently provide state-of-the-art performance in many of the standard NLP tasks. Although LLMs were originally developed mostly to do word sequence completion tasks, with no guarantees about the completion beyond its coherence, there have been increasing claims and anecdotal evidence that they have other emergent capabilities that are not normally associated with sequence completion. Indeed, the hints of such emergent capabilities has started a veritable land rush, with researchers probing (prompting) and studying LLM behavior almost as if they were artificial organisms (c.f. [16]). Of particular interest to us in this paper is the thread of efforts that aim to investigate (and showcase) reasoning abilities of LLMs–including commonsense reasoning [35, 29, 7], logical reasoning [33], and even ethical reasoning [15]. The macro-tenor of the drumbeat of these works has been suggesting that LLM’s are indeed capable of doing such kinds of reasoning [19, 37, 4].
|
| 18 |
+
|
| 19 |
+
One type of reasoning task that has been well studied in the AI community is planning and sequential decision making. At its simplest, planning involves developing a course of actions (policy) which when executed takes the agent to a desired state of the world. Planning has generally been studied primarily as an inference on world and reward models–whether specified by humans or learned by the agent by interacting with its world. In this paper, we are interested in seeing what planning abilities, if any, LLMs may already have, given their high capacity functions (with billions of tunable parameters) trained on web-scale corpora. Specifically, we are interested in answering two broad questions:
|
| 20 |
+
|
| 21 |
+
1. How effective are LLMs by themselves in generating simple plans in commonsense planning tasks (of the type that humans are generally quite good at)?
|
| 22 |
+
2. How good are LLMs in being a source of heuristic guidance for other agents in their planning tasks?
|
| 23 |
+
|
| 24 |
+
Notice that in theory, it is possible for LLMs to be very effective as idea generators for external sound planners or humans in the loop in computer-supported cooperative work scenarios, while themselves being very bad at generating plans that are guaranteed to be correct. This is especially likely because the chief power of LLMs comes from their pattern-finding abilities than from firstprinciples simulations over world models. Compared to a planner that is guaranteed to be correct in a narrow set of domains, LLMs may likely be good at generating plausible (but not guaranteed to be correct) plan heuristics/suggestions in many more domains.
|
| 25 |
+
|
| 26 |
+
To investigate these questions in a systematic rather than anecdotal manner, we generate a suite of planning problem instances 2 based on the kinds of domains employed in the International Planning Competition [14]. To eliminate the subjective aspect of analysis that forms the core part of many earlier efforts on evaluating the reasoning capabilities of LLMs, we automate the evaluation by leveraging models and tools from the automated planning community. The evaluation itself is done in two modes (shown in Figure 1). In the first “autonomous" mode, LLMs are used standalone, and we directly assess the quality and correctness of plans they generate. As we shall see, the results in the autonomous mode are pretty bleak. On an average, only about $12 \%$ of the plans that the best LLM (GPT-4) generates are actually executable without errors and reach their goals. We will show that the choice of the specific LLM (we have tested the family of GPT LLMs including GPT-4 [25], GPT-3.5 [24], InstructGPT-3.5, InstructGPT-3 [26] and GPT-3 [3]), as well as fine tuning does not seem to have a major effect on this dismal performance. We also show that the performance deteriorates further if the names of the actions and objects in the domain are obfuscated–a change that doesn’t in anyway affect the performance of the standard AI planners. To shed further light on the performance of GPT4, we present an evaluation of the plans it generates under a series of more relaxed (more forgiving) executability conditions. Further, we provide a human baseline for the simplest domain in our set of domains, by presenting the planning instances to human subjects (through IRB-approved studies) and evaluating the quality and correctness of their plans. These results are substantially better than those of LLMs–confirming that LLMs can’t plan even in a simple common sense domain in the autonomous mode. In the second “heuristic" mode, the plans produced by LLMs are given as input to an automated planner working off of a correct domain model to check whether the LLM’s plans help with the search process of the underlying planner to come up with correct plans. Specifically we show that a well known automated planner called LPG [6], that uses local search to locate and remove flaws in a candidate plan to make it correct, is able to repair the LLM plans with relative ease. We compare the LLM+LPG combination with two baselines, one where an empty plan is used as the seed plan for the LPG and two, where a random plan is provided as the seed plan to the LPG. We show that the average search steps by the LLM+LPG combination is much lesser than both the baselines, thereby revealing that LLMs’ plans are indeed helping with the search process of the underlying planner. Further, instead of having LPG correct the plans, we use an external verifier, VAL [11], to point out the errors in the LLM-generated plans and back-prompt the LLM for a new plan with this feedback. We show that this repeated interaction indeed improves the plan correctness in common-sense domains. Overall, our findings demonstrate that, with respect to planning, LLMs’ perform poorly in the autonomous mode but the generated plans can help AI planners in the search process or can be given to external verifiers and back-prompt the LLM for better plans. In this paper, we first present an overview of the related work. Following that, we describe the necessary background and the prompt generation pipeline. Finally, we provide the results and analysis of various experiments undertaken in both autonomous and heuristic evaluation modes.
|
| 27 |
+
|
| 28 |
+

|
| 29 |
+
Figure 1: The diagrammatic overview of the two modes of LLMs for planning.
|
| 30 |
+
|
| 31 |
+
# 2 Related Work
|
| 32 |
+
|
| 33 |
+
In this work, we look at LLMs’ planning capabilities when the domain is given as part of the prompt (as is the standard practice in automated planning [8]). Our evaluation focuses on zero-shot (just domain and problem specification), and few-shot (example problems with plans) modes. There have been a few works that looked at the planning capabilities of LLMs. Most of them, such as [12, 2] focus on commonsense domains/tasks (e.g. moving things in kitchens, wedding/menu planning etc.) and thus evaluate LLMs in a mode wherein the prompt doesn’t include any information about the specific domain. Plans generated in that way are hard to evaluate as they are not directed at any plan executor and the humans often wind up giving the benefit of doubt for a plausible–but not actually executable–plan. This is why in SayCan [2], where executability is critical, they try to filter out/interpret the LLM plans in terms of the skills/actions that are actually available to the executor. While SayCan does this in a rather convoluted way that requires access to the internal log probabilities of the LLM, our approach simplifies this by specifying the domain as part of the prompt. In all our experiments, we found that LLMs only use the actions listed as part of the domain specification.
|
| 34 |
+
|
| 35 |
+
One other mode of evaluation of planning capabilities in the literature involves the user incrementally interacting with the LLM, and re-prompting it to point out flaws in its plans, with the hope that the LLM eventually reaches an executable plan [13, 39, 28]. Such evaluations are notorious for their Clever Hans effect [1] with the actual planning being done by the humans in the loop rather than the LLMs themselves. We thus separate our evaluation into two modes–autonomous and as assistants to external planners/reasoners. There have also been efforts which mostly depended on LLMs as “translators" of natural language problem/goal specification into formal specifications, which are then thrown over to sound external planners [38, 21]. Such efforts don’t shed any light on the internal planning capabilities of the LLMs themselves, as our evaluations in autonomous and assistive modes do. Finally, after our initial study and benchmark were made public, other groups did parallel studies that largely corroborate our results on the ineffectiveness of LLMs in finding executable plans [32, 21].
|
| 36 |
+
|
| 37 |
+
Taking a broader perspective, making plans in the world involves (1) discovering actions (and their precondition/effect causal dependencies), and (2) sequencing an appropriate subset of available/discovered actions to achieve the agent’s goals. The former requires broad knowledge about actions available in the world and their individual effects, while the latter requires deep drilling-down over a given set of actions to ensure that all goals are supported (causal chaining) without any undesirable interactions. LLMs have an edge on the former–they do indeed have web-scale broad knowledge! As we shall see however, they are very bad at the second phase of developing valid interaction-free plans (in part, because LLMs don’t have the ability to do combinatorial search). Most cases in literature (as outlined in [18]) where LLMs are claimed to have "planned" turn out, upon close examination, to be instances of phase 1–your wedding plans, recipe plans etc.–where you are either using a very forgiving plan correctness criterion, or the phase 2 is vacuous. Standard AI planners–on the other hand–assume that the discovery part is done and handed down as a compact domain model, and focus mostly on the second part: selecting among known actions to establish causal chains and sequencing them to make them interaction free. In this sense, LLMs and AI planners can be complementary, as we have shown in this paper–with the former helping with phase 1–either with a candidate/approximate plan or domain model–and the latter with phase 2.
|
| 38 |
+
|
| 39 |
+
# 3 Prompt Generation for Classical Planning Problems
|
| 40 |
+
|
| 41 |
+
# 3.1 Background
|
| 42 |
+
|
| 43 |
+
Given that we are interested in investigating the basic reasoning about actions and change problem, we want to look at the most fundamental planning formalism first, namely the goal-directed deterministic planning problem. Colloquially referred to as classical planning problem, these problem classes consist of a problem domain, an initial state and a goal state. The problem domain consists of a set of fluents which correspond to predicates with some arity and a set of actions. The state-space for the planning problem is defined by the possible truth assignment over the predicates. Each action consists of preconditions and effects where preconditions is a set of predicates that describe when an action can be executed and effects are set of predicates that describe what happens when an action is executed. The effects can further consist of add effects, which is the set of predicates that will be set true by the action, and delete effects, which is the set of predicates that will be set false. The solution for a planning problem is a sequence of actions, or a plan, that when applied in the initial state will result in a state where the goal conditions are satisfied. A standard representation to specify such kind of planning problems is the Planning Definition and Domain Language (PDDL) [22]. Below is a snippet of an action from a popular benchmark problem called Blocksworld, in PDDL. The action corresponds to picking up a block in that domain.
|
| 44 |
+
|
| 45 |
+
(:action pickup :parameters (?ob) :precondition (and (clear ?ob) (on-table ?ob) (arm-empty)) :effect (and (holding ?ob) (not (clear ?ob)) (not (on-table ?ob)) (not (arm-empty))))
|
| 46 |
+
|
| 47 |
+
A more detailed description on classical planning problems is provided in Appendix A.1. We now will describe how we generate the prompts that are given to the LLMs.
|
| 48 |
+
|
| 49 |
+
# 3.2 Prompt Generation
|
| 50 |
+
|
| 51 |
+

|
| 52 |
+
Figure 2: The diagrammatic overview of the prompt generation pipeline. The prompt configurations for the different experiments are generated from PDDL domain files and are modified with an example generator and natural language translator as needed depending on the experiment requirements.
|
| 53 |
+
|
| 54 |
+
Prompt Configurations: We have developed a suite of unique planning problems to test LLMs’ abilities to generate plans. We have multiple prompt configurations based on this suite of problems, varying in both the method of presentation as well as number of examples given to the LLM. In particular, we use two methods of presentation, natural language and PDDL, as well as two different methods of providing examples, zero shot (with no examples provided) and one shot (with an example provided), giving us four different configuration combinations for our experiments.
|
| 55 |
+
|
| 56 |
+
Within a prompt, LLMs are first provided with a lifted domain description. For one shot configurations, the prompt additionally contains an example instance of a planning problem (consisting of a description of the initial state and the goal) and the corresponding plan (which ends with a tag, referred to as the plan-end tag, that denotes the end of the plan). All prompts end with a planning problem description. The text generated by the LLM until the plan-end tag is used as the candidate for extracting the plan. If the extractor cannot reasonably extract an instance, it is marked as incorrect.
|
| 57 |
+
|
| 58 |
+
Table 1: Results of GPT-4, GPT-3.5 (popularly known as ChatGPT), Instruct-GPT3.5, Instruct-GPT3 (text-davinci-002) and GPT3 (davinci) for the Plan Generation task with prompts in natural language.
|
| 59 |
+
|
| 60 |
+
<table><tr><td rowspan="2">Domain</td><td rowspan="2">Method</td><td colspan="5">Instances correct</td></tr><tr><td>GPT-4</td><td>GPT-3.5</td><td>I-GPT3.5</td><td>I-GPT3</td><td>GPT-3</td></tr><tr><td rowspan="3">Blocksworld (BW)</td><td>One-shot</td><td>206/600 (34.3%)</td><td>37/600 (6.1%)</td><td>54/600 (9%)</td><td>41/600 (6.8%)</td><td>6/600 (1%)</td></tr><tr><td>Zero-shot</td><td>210/600 (34.6%)</td><td>8/600 (1.3%)</td><td>1</td><td>1</td><td>1</td></tr><tr><td>COT</td><td>214/600 (35.6%)</td><td>=</td><td></td><td>1</td><td></td></tr><tr><td rowspan="2">Logistics Domain</td><td>One-shot</td><td>28/200 (14%)</td><td>1/200 (0.5%)</td><td>6/200 (3%)</td><td>3/200 (1.5%)</td><td></td></tr><tr><td>Zero-shot</td><td>15/200 (7.5%)</td><td>1/200 (0.5%)</td><td>=</td><td>-</td><td>1</td></tr><tr><td rowspan="3">Mystery BW (Deceptive)</td><td>One-shot</td><td>26/600 (4.3%)</td><td>0/600 (0%)</td><td>4/600 (0.6%)</td><td>14/600</td><td>0/600</td></tr><tr><td>Zero-shot</td><td>1/600 (0.16%)</td><td>0/600 (0%)</td><td>-</td><td>(2.3%) 1</td><td>(0%) 1</td></tr><tr><td>COT</td><td>54/600 (9%)</td><td></td><td>-</td><td>-</td><td>1</td></tr><tr><td rowspan="2">Mystery BW (Randomized)</td><td>One-shot</td><td>12/600 (2%)</td><td>0/600 (0%)</td><td>5/600 (0.8%)</td><td>5/600 (0.8%)</td><td>1/600</td></tr><tr><td>Zero-shot</td><td>0/600 (0%)</td><td>0/600 (0%)</td><td>-</td><td>-</td><td>(0.1%) -</td></tr></table>
|
| 61 |
+
|
| 62 |
+
The prompt is either formatted in natural langauge or PDDL. Natural language prompts utilize complete natural language sentences to describe feasible actions in the domain. Initial conditions are also reported as complete sentences. Plans in the natural language setting take the form of a series of commands such as "stack the orange block on top of the blue block". As implied by the name, PDDL prompts format all elements (domain description, initial state, goal state, and plans) using PDDL. We point the reader to the supplementary material for examples on each of these prompt configurations.
|
| 63 |
+
|
| 64 |
+
Chain of Thought Prompting: In addition to the four experiments above, we look at a fifth experiment using a state tracking chain of thought prompting technique in a natural language one shot setting. Within this configuration, we provide an annotated example where each action is annotated with the state prior to the action, the reason for why the action is applicable in the prior state, and the resulting state after applying the action. After the example, a meta-explanation about plan correctness is provided. The LLM is then asked to return a response making the same state tracking and justification annotations that were included in the example.
|
| 65 |
+
|
| 66 |
+
Prompt Generation Pipeline: We’ve developed a prompt generation pipeline (visualized in Figure 2) that accepts PDDL domain files as input and outputs prompts that follow the experiments described above. The prompt generation component takes care of creating the set of PDDL problems to be solved for all experiments. Following that, examples are added to the prompt in one shot experiments. While our setup utilizes a planner during example generation, any example generation technique could be used here so long as the examples generated are valid plans. In the state tracking experiment, we also have developed a component to add justification annotations for examples so that the examples reflect what we expect of the LLM. The last step before finishing is translation: since problems at this point are currently in PDDL, prompts for all natural language experiments (whether an example was added or not) need to be translated into natural language. We utilize a domain-specific translator to do so.
|
| 67 |
+
|
| 68 |
+
# 4 Evaluating Planning Capabilities of LLMs in Autonomous Mode
|
| 69 |
+
|
| 70 |
+
In the autonomous mode, we treat the LLM as an automated planner and perform a single run of the dataset on the LLMs for each domain and prompt configuration. In this mode, the plan generated by the LLM is back-translated from natural language to forms that can be used by external plan validators. For each domain, we perform template-based translation to translate between PDDL and natural language for the natural language prompt configurations. We use VAL [11] to evaluate the translated plan with the corresponding domain and problem file. Our evaluation here primarily focuses on the GPT family of LLMs. We tested GPT-4 [25] and GPT-3.5 (commonly known as Chat-GPT) [24] on all the prompt configurations while we tested the older versions of GPT (namely, Instruct-GPT3 and GPT3) on one-shot natural language prompts across the domains. We set the temperature for all models to be 0, thereby making them deterministic. In this section, we detail the evaluation of LLMs on these domains and prompt configurations. We would like to point the reader to the Appendix for example prompts.
|
| 71 |
+
|
| 72 |
+
Table 2: Results of GPT-4 and GPT-3.5 (popularly known as ChatGPT) for the Plan Generation task with one or zero examples in the prompt by directly providing the domain and problem in PDDL.
|
| 73 |
+
|
| 74 |
+
<table><tr><td rowspan="2">Domain</td><td rowspan="2">Method</td><td colspan="2">Instances correct</td></tr><tr><td>GPT-4</td><td>GPT-3.5</td></tr><tr><td rowspan="2">Blocksworld (BW)</td><td>One-shot</td><td>75/600 (12.5%)</td><td>12/600 (2%)</td></tr><tr><td>Zero-shot</td><td>106/600 (17.6%)</td><td>12/600 (2%)</td></tr><tr><td rowspan="2">Logistics Domain</td><td>One-shot</td><td>28/200 (14%)</td><td>1/200 (0.5%)</td></tr><tr><td>Zero-shot</td><td>11/200 (5.5%)</td><td>0/200 (0%)</td></tr><tr><td rowspan="2">Mystery BW (Deceptive)</td><td>One-shot</td><td>17/600 (2.8%)</td><td>1/600 (0.1%)</td></tr><tr><td>Zero-shot</td><td>3/600 (0.5%)</td><td>0/600 (0%)</td></tr></table>
|
| 75 |
+
|
| 76 |
+
Evaluation of LLMs on the Blocksworld domain: Blocksworld problems capture common sense block manipulations and consist of a set of blocks. Blocks are identified with unique colors and are placed either on a table or on top of other blocks. The goal is to arrange some of these blocks in a stack in a particular order. The general expectation here would be that one can pick up a block if it is clear, i.e., there are no other blocks on top of that block and you can only stack a block on top of another block if it is clear. The choice of this particular domain is motivated by both the fact that this is a simple common sense domain and is a very popular domain in planning literature, that has a long history of being used in various planning challenges. The instances were generated using a PDDL generator employed in the IPC competitions. We permitted the generation of problems that varied in terms of the number of blocks (3-5), optimal plan length, and goal properties (positive, negative, or no interactions between subgoals).
|
| 77 |
+
|
| 78 |
+
As shown in Table 1 and Table 2, GPT-4 improves upon previous versions of GPT models in the Blocksworld domain across all four prompt configurations. However, the overall performance is still approximately $34 \%$ in the Blocksworld dataset. Even the chain of thought style prompting (indicated by COT in the tables) had little effect on improving the performance. GPT-4 performs better with natural language prompts (206 and 210 instances for one-shot and zero-shot prompts, respectively) as opposed to PDDL prompts (75 and 106 instances). The performance drops significantly with other GPT models. We also discovered that for instances where Instruct-GPT3 generated the correct plans, replacing the example plan in the prompt with another example plan led to an even greater drop in accuracy. This suggests that the LLM seems to rely primarily on pattern matching, rather than inducing some internal model from the prompts. Overall, even in a seemingly simple common-sense domain like Blocksworld, which humans typically find easy to navigate, LLMs prove to be quite ineffective in planning autonomously.
|
| 79 |
+
|
| 80 |
+
Finetuning GPT-3 on Blocksworld: Along with directly testing the LLMs from the GPT family, we have also looked at the utility of fine-tuning the LLMs. Specifically, we fine-tuned GPT-3 (Davinci) in the Blocksworld domain. For this, we prepared a dataset comprising the initial state, goal state, and the respective plan for 1,000 distinct Blocksworld instances. It’s important to note that these instances were separate from our test set of 600 instances. By using the default hyperparameters provided by OpenAI and an 80-20 train-validation data split, we carried out the fine-tuning process. Our results revealed that the fine-tuned GPT-3 solved only 122 instances out of the 600 in our set, representing approximately $20 \%$ of the total. This suggests that fine-tuning has a limited impact on improving the performance of LLMs in Blocksworld planning. This outcome aligns with the observations of [40], who argue that language models trained for reasoning tend to concentrate on the inherent statistical features instead of the causal structure, which in turn affects their performance on such tasks.
|
| 81 |
+
|
| 82 |
+
Open-source models: In addition to the GPT family of LLMs, we have also conducted preliminary experiments with an open-source LLM, BLOOM [31], and found that BLOOM too is ineffective in plan generation. We assessed BLOOM’s performance in the blocksworld and mystery blocksworld (deceptive) domains using a one-shot natural language prompt configuration. In the blocksworld domain, BLOOM correctly handled only 4 out of 250 instances, representing a $1 . 6 \%$ success rate. In the mystery domain, it failed to produce a single correct response in all 50 instances.
|
| 83 |
+
|
| 84 |
+
Human Baseline for the Blocksworld: We have previously mentioned that planning tasks on the blocksworld domain are anecdotally simple enough for humans to perform. To establish this and come up with a preliminary baseline to compare LLMs performance, we conducted an IRB-approved user study where we asked 50 participants to come up with a plan for a blocksworld instance picked at random, from the set of 600 instances that we used for the evaluation of LLMs. We presented the same domain description as we did for the LLMs and then primed them with an example instance. We point the reader to the supplementary material for further details on the study.
|
| 85 |
+
|
| 86 |
+
Out of the 50 participants, 39 of them $(78 \% )$ came up with a valid plan. Along with validity, we also tested the optimality of their plans even though they were not required to come up with an optimal plan. Out of the 39 participants, 35 $( 8 9 . 7 \% )$ participants came up with an optimal plan. These initial results show that the blocksworld domain is a simple enough domain where most humans are able to come up with plans (which are also optimal) while LLMs, on the other hand, showcase subpar performance.
|
| 87 |
+
|
| 88 |
+
Evaluation of LLMs on the Logistics domain: Logistics is also a widely recognized domain in the planning literature. In this domain, the objective is to transport packages within cities via trucks, and between cities via airplanes. Within a city, the locations are directly linked, allowing trucks to travel between any two of these locations. Similarly, cities are directly connected to each other allowing airplanes to travel between any two cities. Each city is equipped with one truck and has a designated location that functions as an airport. We generated 200 instances on this domain.
|
| 89 |
+
|
| 90 |
+
From Tables 1 and 2, we see that in the one-shot setting with natural language input, GPT-4 only solved $14 \%$ of the instances (28/200), and this rate dropped to $7 . 5 \%$ (15/200) when using zero-shot prompting. When provided with the domain and problem in PDDL format, GPT-4’s performance remained the same in the one-shot setting $14 \%$ or 28/200) but decreased to $5 . 5 \%$ (11/200) in the zero-shot setting. GPT-3.5 did even worse.
|
| 91 |
+
|
| 92 |
+
Obfuscating names to test the brittleness of LLM Planning: Although the domain specification is part of our prompts, the names of the objects (e.g. blocks, trucks), predicates (e.g. on-table, in-city) and actions (e.g. pickup, drive) still do provide connections to the commonsense knowledge that the pretrained LLMs possess. One intriguing question is whether the planning performance is based really only on the domain model or these other background connections. To test this, we experimented with a variation of the Blocksworld domain, where we obfuscate the action names (for example pickup becomes attack, and unstack becomes feast) and predicate names (for example ontable becomes planet, and handempty becomes harmony). Note that from the perspective of standard planners, these domains are essentially identical.3 In addition to such deceptive obfuscation, we also considered a variation where random alphanumeric names were substituted for the action and object names.
|
| 93 |
+
|
| 94 |
+
Tables 1 and 2, we see that this simple obfuscation leads to a catastrophic drop in performance. Specifically, with zero-shot prompting and natural language input, GPT-4 is able to solve 210 instances out of 600 in the Blocksworld domain, but it could only solve 1 instance in the deceptive Mystery Blocksworld domain and 0 instances in the randomized mystery domain. A similar result is observed with the PDDL-style prompts: GPT-4 could solve 106 instances in Blocksworld, but only 3 instances in the deceptive Mystery Blocksworld. Notably, chain of thought prompting does not significantly improve performance over one-shot natural language prompts. GPT-3.5 does not solve even a single instance in the entire set of natural language instances. For most of the instances, GPT-3.5 outputs that the instance can’t be solved. These results strongly suggest that whatever accidental planning performance LLMs show is likely connected to pattern matching rather than reasoning (which should be robust to name change).
|
| 95 |
+
|
| 96 |
+

|
| 97 |
+
Figure 3: Assessment of GPT-4 plans with relaxations in Blocksworld domain
|
| 98 |
+
|
| 99 |
+
Table 3: Evaluation of GPT-4 and Instruct-GPT3 (I-GPT-3) plans as heuristics for a local search planner LPG, on blocksworld (BW), logistics and mystery blocksworld domains.
|
| 100 |
+
|
| 101 |
+
<table><tr><td rowspan="2">Domain</td><td rowspan="2">LLM</td><td colspan="3">Avg. Search Steps</td><td colspan="3">Avg. Plan Length</td><td rowspan="2">Avg. Lev. Distance</td></tr><tr><td>Empty Seed</td><td>Random Seed</td><td>LLM Seed</td><td>Empty Seed</td><td>Random Seed</td><td>LLM Seed</td></tr><tr><td rowspan="2">BW</td><td>I-GPT-3</td><td>Plan 15.8</td><td>Plan 20.07</td><td>Plan 14.5</td><td>Plan 8.45</td><td>Plan 9.62</td><td>Plan 11.7</td><td>7.22</td></tr><tr><td>GPT-4</td><td>15.8</td><td>20.07</td><td>8.9</td><td>8.45</td><td>9.62</td><td>10.76</td><td>4.15</td></tr><tr><td>Logistics</td><td>GPT-4</td><td>77.5</td><td>144.39</td><td>51.3</td><td>23.7</td><td>32.72</td><td>32.24</td><td>15.04</td></tr><tr><td>Mystery BW</td><td>GPT-4</td><td>15.8</td><td>20.45</td><td>16.09</td><td>8.45</td><td>9.78</td><td>11.53</td><td>7.77</td></tr></table>
|
| 102 |
+
|
| 103 |
+
Analyzing GPT-4 failures: To get a better sense of the type of failures LLM generated plans encounter, we wondered whether they will fare much better with a more forgiving test of the validity of the generated plans. In automated planning community, the notion of relaxations of the domain model are used to simplify the problem–chiefly to derive heuristics for planning problems [8]. Taking a leaf from them, we considered two types of relaxations: (i) delete relaxation involves ignoring all the delete conditions of the domain actions (thus making sure that there can be no negative interactions between subgoals) and (ii) precondition relaxation involves ignoring all the preconditions of the domain actions–thus assuming that the the actions are executable from any state giving their effects. Our idea is to evaluate the plans produced by GPT4 with respect to domain models that are delete relaxed, precondition relaxed or both. It should be clear that a plan that is correct with respect to the normal (unrelaxed) model will also be correct with respect to all the relaxed models. Figure 3 shows the results for blocksworld. We see that while the correctness of LLM generated plans increased under more forgiving (relaxed) assessments (area in green), even in the most lenient assessment mode (Delete+Precondition Relaxed), there still are plans $( \sim 3 9 \% )$ that are incorrect (because they still don’t reach the goals) across all the prompt configurations. The plots further classify the failure cases in terms of whether they were inexecutable, shown in maroon, or could be executed but didn’t reach the goals (shown in red). Note that when preconditions are relaxed, all plans are executable. We provide additional details on the relaxed assessments in Appendix A.2.
|
| 104 |
+
|
| 105 |
+
# 5 Evaluating LLMs as Idea Generators
|
| 106 |
+
|
| 107 |
+
While the preceding discussion establishes that LLMs are not capable of generating correct plans in autonomous mode, there is still the possibility that they can be useful idea generators for other sound external planners, verifiers or even humans-in-the-loop. In this section, we investigate this possibility and demonstrate that LLMs show promise on this front (especially with external planners and verfiers).
|
| 108 |
+
|
| 109 |
+
# 5.1 LLM Plans as Heuristics to Sound Planners
|
| 110 |
+
|
| 111 |
+
To see if the LLM generated plans can provide heuristic guidance to sound external planners, we use a local-search planner LPG [6] which generates plans by starting with a seed plan and iteratively repairing flaws until a correct plan is found. We feed the LLM-generated plan as the initial seed plan for LPG’s iterative search. Our hypothesis is that this might put LPG on the right path and reduce the time for it to generate a correct plan. It is interesting to note the similarities between this LLM+LPG approach, and the approaches used in case-based planning in the past [9, 17]. Here the LLM can be loosely viewed as “retrieving a potentially useful plan case/sketch” out of thin air, which the LPG adapts/corrects.
|
| 112 |
+
|
| 113 |
+
We utilized the plans that were generated by LLMs in the one-shot natural language prompt configuration on all three of our previous domains - Blocksworld, Mystery Blocksworld, and Logistics - as the "seed plans" from which LPG would begin its local search for a valid plan. For the Blocksworld domain, both GPT-4 and Instruct-GPT3 were evaluated, whereas for the Logistics and Mystery domains only GPT-4 was evaluated. We confirmed that all the plans that were generated by this LLM+LPG combination for both the domains were valid (which is as expected given that the underlying planner, LPG, is sound). To get an idea of how far the initial LLM generated plans were from the final correct solutions generated by LPG, we measured the Levenshtein edit distance between them. While the default LPG local search doesn’t aim to minimize the changes to the suggested plan (there do exist versions of LPG that do this; see [23]) , the edit distances also give an idea of how partially or approximately correct the original LLM plan is. Along with the edit distance, we also measured the number of search steps that were taken by the LPG to come up with a correct plan.
|
| 114 |
+
|
| 115 |
+
As shown in Table 3, the edit distances across domains are approximately half the length of the seed plans generated by the LLMs, indicating that $50 \%$ of the final plan retains the elements of the initial LLM plan. For each problem, we performed two additional plan initializations to serve as baselines: initializing with an empty plan and initializing with a random plan of the same length as the plan generated by the LLM for that problem. In the Blocksworld and Logistics4 domains, we see a significant improvement in search steps over the empty seed plan when GPT-4 is used and an even larger one over the random seed plan. Consistent with our findings in the autonomous mode, the usefulness of this assistance wanes in domains where the relationships between predicates can no longer be inferred from common sense understandings of their names: in the Mystery Blocksworld domain, the LLM only has meager reduction in step size over the random plan and actually uses more steps than the empty plan.
|
| 116 |
+
|
| 117 |
+
# 5.2 Verifier-assisted repeated backprompting of LLMs
|
| 118 |
+
|
| 119 |
+
The interaction between LLM and LPG was unidirectional–with LLM sending a seed plan that LPG aims to repair. One supposed advantage of LLMs is that they can be prompted to improve their solutions. Suppose we have access to a sound automated verifier that not only checks the plan correctness but also pinpoints faults (in terms of unsatisfied preconditions or delete interactions). Such feedback can be easily converted into a "backprompt" to the LLM, with the hope that LLM comes up with a better plan. This is what we do with the help of VAL[11]–an AI planning tool that uses the domain model to validate the correctness of the plans (and point out errors).
|
| 120 |
+
|
| 121 |
+
Table 4: GPT4 Performance with Backprompting by VAL [11]. Mystery BW had deceptive disguising. I.C - Instances correct (within 15 feedbacks); A.F.R - Avg. feedback rounds for correct instances.
|
| 122 |
+
|
| 123 |
+
<table><tr><td rowspan="2">Domain</td><td>1.C</td><td>A.FR</td></tr><tr><td>GPT-4</td><td>GPT-4</td></tr><tr><td>Blocksworld (BW)</td><td>41/50 (82%)</td><td>3.68</td></tr><tr><td>Logistics</td><td>35/50 (70%)</td><td>3.31</td></tr><tr><td>Mystery BW</td><td>5/50 (10%)</td><td>7.0</td></tr></table>
|
| 124 |
+
|
| 125 |
+
While, as we mentioned earlier, there can be thorny “clever hans” issues about humans prompting LLMs, an automated verifier mechanically backprompting the LLM doesn’t suffer from these.
|
| 126 |
+
|
| 127 |
+
We tested this setup on a subset of the failed instances in the one-shot natural language prompt configuration using GPT-4, given its larger context window. We set a threshold of 15 backprompting rounds. We tested on three domains–Blocksworld, Logistics and Mystery BW–with 50 failed instances from each domain. Table 4 shows the results. We provide the prompt+feedback examples in Appendix A.9. We found that GPT4 is able to come up with correct plans $82 \%$ of the Blocksworld instances and $70 \%$ of the Logistics one. The average number of backprompting rounds for these successful cases was 3.68 for BW and 3.31 for Logistics. The performance on the Mystery BW however remained quite poor–suggesting that even with back prompting, GPT4 cannot do well unless it can tease out commonsense patterns for the domain.
|
| 128 |
+
|
| 129 |
+
In this backprompting configuration, LLM serves as the candidate plan generator while VAL serves as the external sound verifier. While it is tempting to have a self-critiquing architecture with LLM also serving as the verifier, our recent work shows that approach to be of questionable utility as LLMs are no better at verifying plans than they are at generating them [36, 34].
|
| 130 |
+
|
| 131 |
+
# 5.3 LLMs as idea generators for humans-in-the-loop
|
| 132 |
+
|
| 133 |
+
Along with external planners and verifiers, LLMs may also offer their insights as plan suggestions directly to the human-in-the-loop which might potentially guide the user to the correct plan. After all, this sort of computer supported cooperative work (CSCW) use case has been the staple of LLM applications. We explored the efficacy of LLMs in assisting human planners through a betweensubjects user study, structured similarly to the study outlined in Section 4, but with two primary distinctions: (1) The study involved two separate participant groups. The first group received no assistance in devising plans, paralleling the approach in Section 4, while the second group had access to LLM-generated suggestions. (2) both participant sets were asked to offer subjective feedback via the NASA-TLX assessment tool [10], gauging their cognitive load. Additionally, participants from the second group evaluated the correctness of the LLM suggestions presented to them. We utilized the plans generated by GPT-4 to provide plan suggestions.
|
| 134 |
+
|
| 135 |
+
The study included 49 participants in the unassisted group and 48 in the LLM-assisted group. We evaluated the statistical significance regarding accuracy, time taken, and cognitive load between the groups. Our findings revealed no statistical significance between the groups across all three aspects.5. Notably, 3 out of 48 participants mistakenly accepted incorrect LLM suggestions, with two submitting these erroneous suggestions as their plans. This shows the potential for automation bias in such methodologies [5]. We have provided the details of the user-study in Appendix A.12.
|
| 136 |
+
|
| 137 |
+
# 6 Conclusion and Future Work
|
| 138 |
+
|
| 139 |
+
In this paper, we presented a critical investigation of the planning abilities of large language models (LLMs). To this end, we evaluated the plan generation abilities of LLMs in two different modes. In the autonomous mode, our results show that even in simple common-sense planning domains where humans could easily come up with plans, LLMs like GPT-3 exhibit a dismal performance. Even though there is an uptick in the performance by the newer GPT-4 in the blocksworld domain, it still fails miserably on the mystery blocksworld domain, indicating their inability to reason in an abstract manner. In the heuristic mode, we have seen that plans generated by LLMs can help improve the search of sound planners like LPG. Further, we showed that using external verifiers, we can point out the errors and back-prompt LLMs for a better plan. We showed that this indeed helps in common-sense domains. In the supplementary material, we show the prompt examples for all the configurations and the details of the user-studies (Appendix A.11). From our studies, we see that LLMs as autonomous planners fail miserably, but we also see that the generated plans improve the search when used by an underlying sound planner and that better plans can be obtained by back-prompting the LLM with feedback from an external verifier.
|
| 140 |
+
|
| 141 |
+
# 7 Acknowledgements
|
| 142 |
+
|
| 143 |
+
This research was supported by ONR grants N00014-18-1-2442, N00014-18-1-2840, N00014- 19-1-2119 and N00014-23-1-2409, AFOSR grant FA9550-18-1-0067, DARPA SAIL-ON grant W911NF-19-2-0006, and a JP Morgan AI Faculty Research Grant to Kambhampati. Sreedharan was supported in part by NSF grant 2303019.
|
| 144 |
+
|
| 145 |
+
# References
|
| 146 |
+
|
| 147 |
+
[1] Clever Hans. https://en.wikipedia.org/wiki/Clever_Hans.
|
| 148 |
+
|
| 149 |
+
[2] 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.
|
| 150 |
+
|
| 151 |
+
[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. Advances in neural information processing systems, 33:1877–1901, 2020.
|
| 152 |
+
|
| 153 |
+
[4] 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.
|
| 154 |
+
|
| 155 |
+
[5] Mary L Cummings. Automation bias in intelligent time critical decision support systems. In Decision making in aviation, pages 289–294. Routledge, 2017.
|
| 156 |
+
|
| 157 |
+
[6] Alfonso Gerevini and Ivan Serina. Lpg: A planner based on local search for planning graphs with action costs. In AIPS, volume 2, pages 281–290, 2002.
|
| 158 |
+
|
| 159 |
+
[7] 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, 9:346–361, 2021.
|
| 160 |
+
|
| 161 |
+
[8] Malik Ghallab, Dana S. Nau, and Paolo Traverso. Automated Planning and Acting. Cambridge University Press, 2016.
|
| 162 |
+
|
| 163 |
+
[9] Kristian J. Hammond. CHEF: A model of case-based planning. In Tom Kehler, editor, Proceedings of the 5th National Conference on Artificial Intelligence. Philadelphia, PA, USA, August 11-15, 1986. Volume 1: Science, pages 267–271. Morgan Kaufmann, 1986.
|
| 164 |
+
|
| 165 |
+
[10] Sandra G Hart and Lowell E Staveland. Development of nasa-tlx (task load index): Results of empirical and theoretical research. Advances in psychology, 52:139–183, 1988.
|
| 166 |
+
|
| 167 |
+
[11] Richard Howey, Derek Long, and Maria Fox. VAL: Automatic plan validation, continuous effects and mixed initiative planning using PDDL. In 16th IEEE International Conference on Tools with Artificial Intelligence, pages 294–301. IEEE, 2004.
|
| 168 |
+
|
| 169 |
+
[12] Wenlong Huang, Pieter Abbeel, Deepak Pathak, and Igor Mordatch. Language models as zero-shot planners: Extracting actionable knowledge for embodied agents. In International Conference on Machine Learning, pages 9118–9147. PMLR, 2022.
|
| 170 |
+
|
| 171 |
+
[13] Wenlong Huang, Fei Xia, Ted Xiao, Harris Chan, Jacky Liang, Pete Florence, Andy Zeng, Jonathan Tompson, Igor Mordatch, Yevgen Chebotar, et al. Inner monologue: Embodied reasoning through planning with language models. arXiv preprint arXiv:2207.05608, 2022.
|
| 172 |
+
|
| 173 |
+
[14] IPC. International planning competition, 1998.
|
| 174 |
+
|
| 175 |
+
[15] Liwei Jiang, Jena D. Hwang, Chandrasekhar Bhagavatula, Ronan Le Bras, Maxwell Forbes, Jon Borchardt, Jenny Liang, Oren Etzioni, Maarten Sap, and Yejin Choi. Delphi: Towards Machine Ethics and Norms. ArXiv, abs/2110.07574, 2021.
|
| 176 |
+
|
| 177 |
+
[16] Subbarao Kambhampati. AI as (an Ersatz) Natural Science? https://cacm.acm.org/blogs/blogcacm/261732-ai-as-an-ersatz-natural-science/fulltext, Jun 2022.
|
| 178 |
+
|
| 179 |
+
[17] Subbarao Kambhampati and James A. Hendler. A validation-structure-based theory of plan modification and reuse. Artif. Intell., 55(2):193–258, 1992.
|
| 180 |
+
|
| 181 |
+
[18] Subbarao Kambhampati, Karthik Valmeekam, Matthew Marquez, and Lin Guan. On the role of large language models in planning, July 2023. Tutorial presented at the International Conference on Automated Planning and Scheduling (ICAPS), Prague. https://yochan-lab.github. io/tutorial/ICAPS-2023/.
|
| 182 |
+
|
| 183 |
+
[19] Takeshi Kojima, Shixiang Shane Gu, Machel Reid, Yutaka Matsuo, and Yusuke Iwasawa. Large Language Models are Zero-Shot Reasoners. arXiv preprint arXiv:2205.11916, 2022.
|
| 184 |
+
|
| 185 |
+
[20] Paul Pu Liang, Chiyu Wu, Louis-Philippe Morency, and Ruslan Salakhutdinov. Towards understanding and mitigating social biases in language models. In International Conference on Machine Learning, pages 6565–6576. PMLR, 2021.
|
| 186 |
+
|
| 187 |
+
[21] Bo Liu, Yuqian Jiang, Xiaohan Zhang, Qiang Liu, Shiqi Zhang, Joydeep Biswas, and Peter Stone. Llm+ p: Empowering large language models with optimal planning proficiency. arXiv preprint arXiv:2304.11477, 2023.
|
| 188 |
+
|
| 189 |
+
[22] Drew McDermott, Malik Ghallab, Adele E. Howe, Craig A. Knoblock, Ashwin Ram, Manuela M. Veloso, Daniel S. Weld, and David E. Wilkins. Pddl-the planning domain definition language. 1998.
|
| 190 |
+
|
| 191 |
+
[23] Tuan Anh Nguyen, Minh Do, Alfonso Emilio Gerevini, Ivan Serina, Biplav Srivastava, and Subbarao Kambhampati. Generating diverse plans to handle unknown and partially known user preferences. Artificial Intelligence, 190:1–31, 2012.
|
| 192 |
+
|
| 193 |
+
[24] OpenAI. Introducing chatgpt by openai, 2022.
|
| 194 |
+
|
| 195 |
+
[25] OpenAI. Gpt-4 technical report, 2023.
|
| 196 |
+
|
| 197 |
+
[26] 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.
|
| 198 |
+
|
| 199 |
+
[27] Alec Radford, Karthik Narasimhan, Tim Salimans, and Ilya Sutskever. Improving language understanding by generative pre-training. 2018.
|
| 200 |
+
|
| 201 |
+
[28] Shreyas Sundara Raman, Vanya Cohen, Eric Rosen, Ifrah Idrees, David Paulius, and Stefanie Tellex. Planning with large language models via corrective re-prompting. arXiv preprint arXiv:2211.09935, 2022.
|
| 202 |
+
|
| 203 |
+
[29] Keisuke Sakaguchi, Ronan Le Bras, Chandra Bhagavatula, and Yejin Choi. Winogrande: An adversarial winograd schema challenge at scale. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 34, pages 8732–8740, 2020.
|
| 204 |
+
|
| 205 |
+
[30] Patrick Schramowski, Cigdem Turan, Nico Andersen, Constantin A Rothkopf, and Kristian Kersting. Large pre-trained language models contain human-like biases of what is right and wrong to do. Nature Machine Intelligence, 4(3):258–268, 2022.
|
| 206 |
+
|
| 207 |
+
[31] Big Science. BigScience Large Open-science Open-access Multilingual Language Model. https://huggingface.co/bigscience/bloom, 2022.
|
| 208 |
+
|
| 209 |
+
[32] Tom Silver, Varun Hariprasad, Reece S Shuttleworth, Nishanth Kumar, Tomás Lozano-Pérez, and Leslie Pack Kaelbling. PDDL planning with pretrained large language models. In NeurIPS 2022 Foundation Models for Decision Making Workshop, 2022.
|
| 210 |
+
|
| 211 |
+
[33] Aarohi Srivastava, Abhinav Rastogi, Abhishek Rao, Abu Awal Md Shoeb, Abubakar Abid, Adam Fisch, Adam R Brown, Adam Santoro, Aditya Gupta, Adrià Garriga-Alonso, et al. Beyond the imitation game: Quantifying and extrapolating the capabilities of language models. arXiv preprint arXiv:2206.04615, 2022.
|
| 212 |
+
|
| 213 |
+
[34] Kaya Stechly, Matthew Marquez, and Subbarao Kambhampati. Gpt-4 doesn’t know it’s wrong: An analysis of iterative prompting for reasoning problems. arXiv preprint arXiv:2310.12397, 2023.
|
| 214 |
+
|
| 215 |
+
[35] Alon Talmor, Jonathan Herzig, Nicholas Lourie, and Jonathan Berant. Commonsenseqa: A question answering challenge targeting commonsense knowledge. arXiv preprint arXiv:1811.00937, 2018.
|
| 216 |
+
|
| 217 |
+
[36] Karthik Valmeekam, Matthew Marquez, and Subbarao Kambhampati. Can large language models really improve by self-critiquing their own plans? arXiv preprint arXiv:2310.08118, 2023.
|
| 218 |
+
|
| 219 |
+
[37] Jason Wei, Xuezhi Wang, Dale Schuurmans, Maarten Bosma, Ed Chi, Quoc Le, and Denny Zhou. Chain of thought prompting elicits reasoning in large language models. arXiv preprint arXiv:2201.11903, 2022.
|
| 220 |
+
[38] Yaqi Xie, Chen Yu, Tongyao Zhu, Jinbin Bai, Ze Gong, and Harold Soh. Translating natural language to planning goals with large-language models. arXiv preprint arXiv:2302.05128, 2023.
|
| 221 |
+
[39] Shunyu Yao, Jeffrey Zhao, Dian Yu, Nan Du, Izhak Shafran, Karthik R Narasimhan, and Yuan Cao. React: Synergizing reasoning and acting in language models. In The Eleventh International Conference on Learning Representations, 2023.
|
| 222 |
+
[40] Honghua Zhang, Liunian Harold Li, Tao Meng, Kai-Wei Chang, and Guy Van den Broeck. On the paradox of learning to reason from data. arXiv preprint arXiv:2205.11502, 2022.
|
md/dev/Yacmpz84TH/Yacmpz84TH.md
ADDED
|
@@ -0,0 +1,281 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Toolformer: Language Models Can Teach Themselves to Use Tools
|
| 2 |
+
|
| 3 |
+
Timo Schick Jane Dwivedi-Yu Roberto Dessì† Roberta Raileanu Maria Lomeli Eric Hambro Luke Zettlemoyer Nicola Cancedda Thomas Scialom
|
| 4 |
+
|
| 5 |
+
FAIR, Meta †Universitat Pompeu Fabra
|
| 6 |
+
|
| 7 |
+
# Abstract
|
| 8 |
+
|
| 9 |
+
Language models (LMs) exhibit remarkable abilities to solve new tasks from just a few examples or textual instructions, especially at scale. They also, paradoxically, struggle with basic functionality, such as arithmetic or factual lookup, where much simpler and smaller specialized models excel. In this paper, we show that LMs can teach themselves to use external tools via simple APIs and achieve the best of both worlds. We introduce Toolformer, a model trained to decide which APIs to call, when to call them, what arguments to pass, and how to best incorporate the results into future token prediction. This is done in a self-supervised way, requiring nothing more than a handful of demonstrations for each API. We incorporate a range of tools, including a calculator, a Q&A system, a search engine, a translation system, and a calendar. Toolformer achieves substantially improved zero-shot performance across a variety of downstream tasks, often competitive with much larger models, without sacrificing its core language modeling abilities.
|
| 10 |
+
|
| 11 |
+
# 1 Introduction
|
| 12 |
+
|
| 13 |
+
Large language models achieve impressive zero and few-shot results on a variety of natural language processing tasks (Brown et al., 2020; Chowdhery et al., 2022, i.a.). However, these models have several inherent limitations that can at best be partially addressed by further scaling. These limitations include an inability to access up-to-date information on recent events (Komeili et al., 2022) and the related tendency to hallucinate facts (Maynez et al., 2020; Ji et al., 2022), difficulties in understanding low-resource languages (Lin et al., 2021), a lack of mathematical skills to perform precise calculations (Patel et al., 2021) and an unawareness of the progression of time (Dhingra et al., 2022).
|
| 14 |
+
|
| 15 |
+
A simple way to overcome the limitations of today’s language models is to give them the ability to use external tools such as search engines, calculators, or calendars. However, existing approaches either rely on large amounts of human annotations (Komeili et al., 2022; Thoppilan et al., 2022) or limit tool use to task-specific settings only (e.g., Gao et al., 2022; Parisi et al., 2022), hindering a more widespread adoption of tool use in LMs. Therefore, we propose Toolformer, a model that learns to use tools in a novel way, which fulfills the following desiderata:
|
| 16 |
+
|
| 17 |
+
• Tool use should be learned in a self-supervised way without large amounts of human annotations. This is important not only because of the costs associated with such annotations, but also because what humans find useful may be different from what a model finds useful. • The LM should not lose any of its generality and should be able to decide for itself when and how to use which tool. In contrast to existing approaches, this enables a much more comprehensive use of tools that is not tied to specific tasks.
|
| 18 |
+
|
| 19 |
+
Our approach for achieving these goals is based on the recent idea of using large LMs with in-context learning (Brown et al., 2020) to generate entire datasets from scratch (Schick and Schütze, 2021b;
|
| 20 |
+
|
| 21 |
+

|
| 22 |
+
Figure 1: Exemplary predictions of Toolformer. The model autonomously decides to call different APIs (from top to bottom: a question answering system, a calculator, a machine translation system, and a Wikipedia search engine) to obtain information that is useful for completing a piece of text.
|
| 23 |
+
|
| 24 |
+

|
| 25 |
+
Figure 2: Key steps in ourwe first sample a position pproach, illustrated for a question answe and corresponding API call candidates en an input text . We then execu $\mathbf { x }$ , $i$ $c _ { i } ^ { 1 } , c _ { i } ^ { 2 } , \ldots , c _ { i } ^ { k }$ these API calls and filter out all calls which do not reduce the loss $L _ { i }$ over the next tokens. All remaining API calls are interleaved with the original text, resulting in a new text $\mathbf { x } ^ { * }$ .
|
| 26 |
+
|
| 27 |
+
Honovich et al., 2022; Wang et al., 2022): Given just a handful of human-written examples of how an API can be used, we let a LM annotate a huge language modeling dataset with potential API calls. We then use a self-supervised loss to determine which of these API calls actually help the model in predicting future tokens. Finally, we finetune the LM itself on the API calls that it considers useful. As illustrated in Figure 1, through this simple approach, LMs can learn to control a variety of tools, and to choose for themselves which tool to use when and how.
|
| 28 |
+
|
| 29 |
+
As our approach is agnostic of the dataset being used, we can apply it to the exact same dataset that was used to pretrain a model in the first place. This ensures that the model does not lose any of its generality and language modeling abilities. We conduct experiments on a variety of different downstream tasks, demonstrating that after learning to use tools, Toolformer, which is based on a pretrained GPT-J model (Wang and Komatsuzaki, 2021) with 6.7B parameters, achieves much stronger zero-shot results, clearly outperforming a much larger GPT-3 model (Brown et al., 2020) and several other baselines on various tasks.
|
| 30 |
+
|
| 31 |
+
# 2 Approach
|
| 32 |
+
|
| 33 |
+
Our aim is to equip a language model $M$ with the ability to use different tools through API calls. We represent API calls as tuples $c = ( a _ { c } , i _ { c } )$ where $a _ { c }$ is the name of the API and $i _ { c }$ is the corresponding input. Given an API call $c$ with a corresponding result $r$ , we denote the linearized sequences of the API call not including and including its result, respectively, as:
|
| 34 |
+
|
| 35 |
+
$$
|
| 36 |
+
\begin{array} { r } { \mathsf { e } ( c ) = < \mathtt { A P I } > a _ { c } ( i _ { c } ) < / \mathtt { A P I } > \mathsf { e } ( c , r ) = < \mathtt { A P I } > a _ { c } ( i _ { c } ) \to r < / \mathtt { A P I } > } \end{array}
|
| 37 |
+
$$
|
| 38 |
+
|
| 39 |
+
where $ { \mathrm { ~ ~ \cdots ~ } } < \tt { A P I } > { \mathrm { ^ { \circ } } }$ , $ { \mathrm { ~ ~ \cdots ~ } } < / \tt A P I > { \mathrm { ^ { \circ } } }$ and $\ " \ "$ are special tokens.1 Some examples of linearized API calls inserted into text sequences are shown in Figure 1.
|
| 40 |
+
|
| 41 |
+
Your task is to add calls to a Question Answering API to a piece of text. The questions should help you get information required to complete the text. You can call the API by writing "[QA(question)]" where "question" is the question you want to ask. Here are some examples of API calls:
|
| 42 |
+
|
| 43 |
+
Input: Joe Biden was born in Scranton, Pennsylvania.
|
| 44 |
+
Output: Joe Biden was born in [QA("Where was Joe Biden born?")] Scranton, [QA("In which state is Scranton?")] Pennsylvania.
|
| 45 |
+
|
| 46 |
+
Input: Coca-Cola, or Coke, is a carbonated soft drink manufactured by the Coca-Cola Company. Output: Coca-Cola, or [QA("What other name is Coca-Cola known by?")] ${ \mathsf { C o k e } } ,$ , is a carbonated soft drink manufactured by [QA("Who manufactures Coca-Cola?")] the Coca-Cola Company.
|
| 47 |
+
|
| 48 |
+
Input: x Output:
|
| 49 |
+
|
| 50 |
+
Given a dataset $\mathcal { C } = \{ \mathbf { x } ^ { 1 } , \ldots , \mathbf { x } ^ { | \mathcal { C } | } \}$ of plain texts, we first convert this dataset into a dataset $\mathcal { C } ^ { * }$ augmented with API calls. This is done in three steps, illustrated in Figure 2: First, we exploit the in-context learning ability of $M$ to sample a large number of API calls. We then execute them and finally check whether the obtained responses are helpful for predicting future tokens; this is used as a filtering criterion. After filtering, we merge API calls for different tools, resulting in the augmented dataset $\mathcal { C } ^ { * }$ , and finetune $M$ itself on this dataset. Each step is described in more detail below.
|
| 51 |
+
|
| 52 |
+
Sampling API Calls For each API, we write a prompt $P ( \mathbf { x } )$ that encourages the LM to annotate an example $\mathbf { x } = x _ { 1 } , \ldots , x _ { n }$ with API calls. An example of such a prompt for a question answering tool is shown in Figure 3. Let $p _ { M } ( z _ { n + 1 } \mid z _ { 1 } , . . . , z _ { n } )$ be the probability that $M$ assigns to token $z _ { n + 1 }$ as a continuation for the sequence $z _ { 1 } , \ldots , z _ { n }$ . We first sample up to $k$ candidate positions for doing API calls by computing, for each $i \in \{ 1 , \ldots , n \}$ , the probability $p _ { i } = p _ { M } ( < _ { \tt A P I > } \mid P ( \mathbf { x } ) , x _ { 1 : i - 1 } )$ that $M$ assigns to starting an API call at position $i$ . Given a sampling threshold $\tau _ { s }$ , we keep all positions $I \stackrel { - } { = } \{ i | p _ { i } > \tau _ { s } \stackrel { - } { \} }$ ; if there are more than $k$ such positions, we only keep the top $k$ . For each position $i \in I$ , we then obtain up to $m$ API calls $c _ { i } ^ { 1 } , \ldots , c _ { i } ^ { m }$ by sampling from $M$ given the sequence $[ P ( \mathbf { x } ) , x _ { 1 } , \ldots , x _ { i - 1 } , < \mathtt { A P I } > ]$ as a prefix and ${ < } / { \tt A P I > }$ as an end-of-sequence token.
|
| 53 |
+
|
| 54 |
+
Executing API Calls As a next step, we execute all API calls generated by $M$ . How this is done depends entirely on the API itself – for example, it can involve calling another neural network, executing a Python script or using a retrieval system to perform search over a large corpus. The response for each API call $c _ { i }$ needs to be a single text sequence $r _ { i }$ .
|
| 55 |
+
|
| 56 |
+
Filtering API Calls Let $i$ be the position of the API call $c _ { i }$ in the sequence $\mathbf { x } = x _ { 1 } , \ldots , x _ { n }$ , and let $r _ { i }$ be the response from the API. Further, given a sequence $( w _ { i } \mid i \in \mathbb { N } )$ of weights, let
|
| 57 |
+
|
| 58 |
+
$$
|
| 59 |
+
L _ { i } ( \mathbf { z } ) = - \sum _ { j = i } ^ { n } w _ { j - i } \cdot \log p _ { M } ( x _ { j } \mid \mathbf { z } , x _ { 1 : j - 1 } )
|
| 60 |
+
$$
|
| 61 |
+
|
| 62 |
+
be the weighted cross entropy loss for $M$ over the tokens $x _ { i } , \ldots , x _ { n }$ if the model is prefixed with some text sequence $\mathbf { z }$ . We compare two different instantiations of this loss:
|
| 63 |
+
|
| 64 |
+
$$
|
| 65 |
+
L _ { i } ^ { + } = L _ { i } ( \mathbf { e } ( c _ { i } , r _ { i } ) ) \qquad L _ { i } ^ { - } = \operatorname* { m i n } \left( L _ { i } ( \varepsilon ) , L _ { i } ( \mathbf { e } ( c _ { i } , \varepsilon ) ) \right)
|
| 66 |
+
$$
|
| 67 |
+
|
| 68 |
+
where $\varepsilon$ denotes an empty sequence. The former is the weighted loss over all tokens $x _ { i } , \ldots , x _ { n }$ if the API call and its result are given to $M$ as a prefix;2 the latter is the minimum of the losses obtained from (i) doing no API call at all and (ii) doing an API call, but not providing the response. Intuitively, an API call is helpful to $M$ if providing it with both the input and the output of this call makes it easier for the model to predict future tokens, compared to not receiving the API call at all, or receiving only its input. Given a filtering threshold $\tau _ { f }$ , we thus only keep API calls for which $L _ { i } ^ { - } - L _ { i } ^ { + } \ge \tau _ { f }$ holds, i.e., adding the API call and its result reduces the loss by at least $\tau _ { f }$ , compared to not doing any API call or obtaining no result from it.
|
| 69 |
+
|
| 70 |
+
Table 1: Examples of inputs and outputs for all APIs used.
|
| 71 |
+
|
| 72 |
+
<table><tr><td>API Name</td><td>Example Input</td><td>Example Output</td></tr><tr><td>Question Answering</td><td>Where was the Knights of Columbus founded?</td><td>New Haven, Connecticut</td></tr><tr><td>Wikipedia Search</td><td>Fishing Reel Types</td><td>Spin fishing > Spin fishing is distinguished between fly fishing and bait cast fishing by the type of rod and reel used. There are two types of reels used when spin fishing,</td></tr><tr><td>Calculator</td><td>27+4*2</td><td>the open faced reel and the closed faced reel. 35</td></tr><tr><td>Calendar</td><td>m</td><td>Today is Monday, January 30,2023.</td></tr><tr><td>Machine Translation</td><td>sureté nucléaire</td><td>nuclear safety</td></tr></table>
|
| 73 |
+
|
| 74 |
+
Model Finetuning After sampling and filtering calls for all APIs, we finally merge the remaining API calls and interleave them with the original inputs. That is, for an input text $\mathbf { x } = x _ { 1 } , \ldots , x _ { n }$ with a corresponding API call and result $( c _ { i } , r _ { i } )$ at position $i$ , we construct the new sequence $\mathbf { x } ^ { * } = x _ { 1 : i - 1 } , \mathbf { e } ( c _ { i } , r _ { i } ) , x _ { i : n }$ ; we proceed analogously for texts with multiple API calls. Doing this for all $\mathbf { x } \in { \mathcal { C } }$ results in the new dataset $\mathcal { C } ^ { * }$ augmented with API calls. We use $\mathcal { C } ^ { * }$ to finetune $M$ , using a standard language modeling objective. Crucially, apart from inserted API calls, $\mathcal { C } ^ { * }$ contains the exact same texts as $\mathcal { C }$ , the original dataset. As a consequence, finetuning $M$ on $\mathcal { C } ^ { * }$ exposes it to the same content as finetuning on $\mathcal { C }$ . Moreover, as API calls are inserted in exactly those positions and with exactly those inputs that help $M$ predict future tokens, finetuning on $\mathcal { C } ^ { * }$ enables the language model to decide when and how to use which tool, based purely on its own feedback.
|
| 75 |
+
|
| 76 |
+
Inference When generating text with $M$ after finetuning with our approach, we perform regular decoding until $M$ produces the $\ " \ "$ token, indicating that it next expects the response for an API call. At this point, we interrupt the decoding process, call the appropriate API to get a response, and continue the decoding process after inserting both the response and the ${ < } / \tt { A P I > }$ token.
|
| 77 |
+
|
| 78 |
+
# 3 Tools
|
| 79 |
+
|
| 80 |
+
We explore various tools to address different shortcomings of LMs. The only constraints we impose are that (i) their inputs and outputs can be represented as texts, and (ii) we can obtain a few demonstrations of their intended use. Concretely, we explore a question answering system, a Wikipedia search engine, a calculator, a calendar, and a machine translation system. Examples for the APIs associated with each of these tools are shown in Table 1. We briefly discuss all tools below.
|
| 81 |
+
|
| 82 |
+
Question Answering Our first tool is a question answering system based on another LM that can answer simple factoid questions. Specifically, we use Atlas (Izacard et al., 2022), a retrievalaugmented LM finetuned on Natural Questions (Kwiatkowski et al., 2019).
|
| 83 |
+
|
| 84 |
+
Calculator As a second tool, we use a calculator that can perform simple numeric calculations; we only support the four basic arithmetic operations. Results are always rounded to two decimal places.
|
| 85 |
+
|
| 86 |
+
Wikipedia Search Our third tool is a search engine that, given a search term, returns short text snippets from Wikipedia. Compared to our question answering tool, this search enables a model to get more comprehensive information on a subject, but requires it to extract the relevant parts by itself. As our search engine, we use a BM25 retriever (Robertson et al., 1995; Baeza-Yates et al., 1999) that indexes the Wikipedia dump from KILT (Petroni et al., 2021).
|
| 87 |
+
|
| 88 |
+
Machine Translation System Our fourth tool is a machine translation system based on a LM that can translate a phrase from any language into English. More concretely, we use the 600M parameter NLLB (Costa-jussà et al., 2022) as our multilingual machine translation model that works for 200 languages (including low-resource ones). The source language is automatically detected using the fastText classifier (Joulin et al., 2016), while the target language is always set to English.
|
| 89 |
+
|
| 90 |
+
Calendar Our final tool is a calendar API that, when queried, returns the current date without taking any input. This provides temporal context for predictions that require some awareness of time.
|
| 91 |
+
|
| 92 |
+
Table 2: Number of examples with API calls in $\mathcal { C } ^ { * }$ for different values of our filtering threshold $\tau _ { f }$
|
| 93 |
+
|
| 94 |
+
<table><tr><td></td><td colspan="3">Number of Examples</td></tr><tr><td>API</td><td>Tf = 0.5</td><td>Tf = 1.0</td><td>Tf = 2.0</td></tr><tr><td>Question Answering</td><td>51,987</td><td>18,526</td><td>5,135</td></tr><tr><td>Wikipedia Search</td><td>207,241</td><td>60,974</td><td>13,944</td></tr><tr><td>Calculator</td><td>3,680</td><td>994</td><td>138</td></tr><tr><td>Calendar</td><td>61,811</td><td>20,587</td><td>3,007</td></tr><tr><td>Machine Translation</td><td>3,156</td><td>1,034</td><td>229</td></tr></table>
|
| 95 |
+
|
| 96 |
+
# 4 Experiments
|
| 97 |
+
|
| 98 |
+
We investigate whether our approach enables a LM to use tools without any further supervision and to decide for itself when and how to call which tool. To test this, we select a variety of downstream tasks where we assume at least one of the considered tools to be useful, and evaluate performance in zero-shot settings (Section 4.2). Beyond that, we also ensure that our approach does not hurt the model’s core LM abilities; we verify this by looking at perplexity on two language modeling datasets (Section 4.3). Finally, we investigate how tool use is affected by model size (Section 4.4).
|
| 99 |
+
|
| 100 |
+
# 4.1 Experimental Setup
|
| 101 |
+
|
| 102 |
+
We use a subset of CCNet (Wenzek et al., 2020) as our dataset $\mathcal { C }$ and GPT-J (Wang and Komatsuzaki, 2021) as our language model $M$ . To reduce the computational cost of annotating $\mathcal { C }$ with API calls, we define heuristics for some APIs to get a subset of $\mathcal { C }$ for which API calls are more likely to be helpful than for an average text. For example, we only consider texts for the calculator tool if they contain at least three numbers. Details of the heuristics used are given in Appendix A. For obtaining $\mathcal { C } ^ { * }$ from $\mathcal { C }$ , we perform all steps described in Section 2 and additionally filter out all examples for which all API calls were eliminated in the filtering step.3 For the weighting function, we use
|
| 103 |
+
|
| 104 |
+
$$
|
| 105 |
+
w _ { t } = \frac { \tilde { w } _ { t } } { \sum _ { s \in \mathbb { N } } \tilde { w } _ { s } } \mathrm { ~ w i t h ~ } \tilde { w } _ { t } = \operatorname* { m a x } ( 0 , 1 - 0 . 2 \cdot t )
|
| 106 |
+
$$
|
| 107 |
+
|
| 108 |
+
to make sure that API calls happen close to where the information provided by the API is actually helpful for the model. The thresholds $\tau _ { s }$ and $\tau _ { f }$ are chosen individually for each tool to ensure a sufficient number of examples; see Appendix A for details. Table 2 shows relevant statistics of our final dataset augmented with API calls. We finetune $M$ on $\mathcal { C } ^ { * }$ using a batch size of 128 and a learning rate of $1 \cdot 1 0 ^ { - 5 }$ with linear warmup for the first $10 \%$ of training. Finetuning details are given in Appendix B. In our experiments, we mainly compare GPT-J and the following models:
|
| 109 |
+
|
| 110 |
+
• GPT- $\mathbf { J } + \mathbf { C } \mathbf { C }$ : GPT-J finetuned on $\mathcal { C }$ , our subset of CCNet without any API calls. • Toolformer: GPT-J finetuned on $\mathcal { C } ^ { * }$ , our subset of CCNet augmented with API calls. • Toolformer (disabled): The same model as Toolformer, but API calls are disabled during decoding. This is achieved by manually setting the probability of the ${ \tt { < A P I > } }$ token to 0.
|
| 111 |
+
|
| 112 |
+
We additionally compare to OPT (66B) (Zhang et al., 2022) and the original davinci variant of GPT-3 (175B) (Brown et al., 2020), two models that are about 10 and 25 times larger than GPT-J.
|
| 113 |
+
|
| 114 |
+
# 4.2 Downstream Tasks
|
| 115 |
+
|
| 116 |
+
We evaluate on various downstream tasks considering a prompted zero-shot setup: Models are instructed to solve each task in natural language (see Appendix C), but we provide no examples. This is in contrast to prior work on tool use (e.g., Gao et al., 2022; Parisi et al., 2022), where models are provided with dataset-specific examples of how a tool can be used to solve a concrete task. We choose this more challenging setup as we are interested in seeing whether Toolformer works in precisely those cases where a user does not specify in advance which tools should be used in which way.
|
| 117 |
+
|
| 118 |
+
Table 3: Results on subsets of LAMA and various benchmarks requiring mathematical reasoning. For LAMA, Toolformer uses the question answering tool for most examples, clearly outperforming all baselines of the same size and achieving results competitive with GPT-3. For the math benchmarks, Toolformer makes extensive use of the calculator tool, clearly outperforming OPT and GPT-3. Best results with a GPT-J based model are shown in bold, best results overall are underlined.
|
| 119 |
+
|
| 120 |
+
<table><tr><td></td><td colspan="3">LAMA</td><td colspan="3">Math Benchmarks</td></tr><tr><td>Model</td><td>SQuAD</td><td>Google-RE</td><td>T-REx</td><td>ASDiv</td><td>SVAMP</td><td>MAWPS</td></tr><tr><td>GPT-J</td><td>17.8</td><td>4.9</td><td>31.9</td><td>7.5</td><td>5.2</td><td>9.9</td></tr><tr><td>GPT-J + CC</td><td>19.2</td><td>5.6</td><td>33.2</td><td>9.6</td><td>5.0</td><td>9.3</td></tr><tr><td>Toolformer (disabled)</td><td>22.1</td><td>6.3</td><td>34.9</td><td>14.8</td><td>6.3</td><td>15.0</td></tr><tr><td>Toolformer</td><td>33.8</td><td>11.5</td><td>53.5</td><td>40.4</td><td>29.4</td><td>44.0</td></tr><tr><td>OPT (66B)</td><td>21.6</td><td>2.9</td><td>30.1</td><td>6.0</td><td>4.9</td><td>7.9</td></tr><tr><td>GPT-3 (175B)</td><td>26.8</td><td>7.0</td><td>39.8</td><td>14.0</td><td>10.0</td><td>19.8</td></tr></table>
|
| 121 |
+
|
| 122 |
+
We use greedy decoding, but with one modification for Toolformer: We let the model start an API call whenever ${ \tt { < A P I > } }$ is one of the $k$ most likely tokens. For $k = 1$ , this corresponds to regular greedy decoding; we instead use $k = 1 0$ to increase the disposition of our model to make use of APIs. At the same time, we allow at most one API call per input to make sure the model does not get stuck in a loop where it constantly calls APIs. The effect of these modifications is explored in Appendix E.
|
| 123 |
+
|
| 124 |
+
LAMA We evaluate our models on the SQuAD, Google-RE and T-REx subsets of the LAMA benchmark (Petroni et al., 2019). For each of these subsets, the task is to complete a short statement with a missing fact (e.g., a date or a place). As LAMA was originally designed to evaluate masked LMs (e.g., Devlin et al., 2019), we filter out examples where the mask token is not the final token, so that all examples can be processed in a left-to-right fashion. To account for different tokenizations and added complexity from not informing the model that a single word is required, for all models we use a slightly more lenient evaluation criterion than exact match and simply check whether the correct word is within the first five words predicted by the model. As LAMA is based on statements obtained directly from Wikipedia, we prevent Toolformer from using the Wikipedia Search API to avoid giving it an unfair advantage. As shown in Table 3 (left), all GPT-J models without tool use achieve similar performance. Crucially, Toolformer clearly outperforms these baseline models, improving upon the best baseline by 11.7, 5.2 and 18.6 points, respectively. It also clearly outperforms OPT (66B) and GPT-3 (175B), despite both models being much larger. This is achieved because the model independently decides to ask the question answering tool for the required information in almost all cases $( 9 8 . 1 \% )$ ; for only very few examples, it uses a different tool $( 0 . 7 \% )$ or no tool at all $( 1 . 2 \% )$ .
|
| 125 |
+
|
| 126 |
+
Math Benchmarks We test mathematical abilities on ASDiv (Miao et al., 2020), SVAMP (Patel et al., 2021) and the MAWPS benchmark (Koncel-Kedziorski et al., 2016). We again account for the fact that we test all models in a zero-shot setup by using a more lenient evaluation criterion: As the required output is always a number, we simply check for the first number predicted by the model.4 Results are shown in Table 3 (right). While GPT-J and GPT- $\mathbf { J } + \mathbf { C } \mathbf { C }$ perform about the same, Toolformer achieves stronger results even without API calls. We surmise that this is because the model is finetuned on many examples of API calls and their results, improving its own mathematical capabilities. Nonetheless, allowing the model to make API calls more than doubles performance for all tasks, and also clearly outperforms the much larger OPT and GPT-3. This is because across all benchmarks, for $9 7 . 9 \%$ of all examples the model decides to ask the calculator tool for help.
|
| 127 |
+
|
| 128 |
+
Question Answering We look at Web Questions (Berant et al., 2013), Natural Questions (Kwiatkowski et al., 2019) and TriviaQA (Joshi et al., 2017). For evaluation, we check whether the first 20 words predicted by a model contain the correct answer instead of requiring an exact match. For Toolformer, we disable the question answering tool as this would make solving the tasks trivial. Results are shown in Table 4 (left). Once again, Toolformer clearly outperforms all other models based on GPT-J, relying on the Wikipedia search API $( 9 9 . 3 \% )$ to find relevant information. However,
|
| 129 |
+
|
| 130 |
+
Table 4: Results for various question answering datasets and temporal datasets. Using the Wikipedia search tool for most examples, Toolformer clearly outperforms baselines of the same size, but falls short of GPT-3 (175B) for question answering tasks. For temporal datasets, Toolformer outperforms all baselines, but does not make use of the calendar tool for TEMPLAMA.
|
| 131 |
+
|
| 132 |
+
<table><tr><td></td><td colspan="3">LAMA</td><td colspan="2">Temporal Datasets</td></tr><tr><td>Model</td><td>WebQS</td><td>NQ</td><td>TriviaQA</td><td>TEMPLAMA</td><td>DATESET</td></tr><tr><td>GPT-J</td><td>18.5</td><td>12.8</td><td>43.9</td><td>13.7</td><td>3.9</td></tr><tr><td>GPT-J + CC</td><td>18.4</td><td>12.2</td><td>45.6</td><td>12.9</td><td>2.9</td></tr><tr><td>Toolformer (disabled)</td><td>18.9</td><td>12.6</td><td>46.7</td><td>12.7</td><td>5.9</td></tr><tr><td>Toolformer</td><td>26.3</td><td>17.7</td><td>48.8</td><td>16.3</td><td>27.3</td></tr><tr><td>OPT (66B)</td><td>18.6</td><td>11.4</td><td>45.7</td><td>14.5</td><td>1.3</td></tr><tr><td>GPT-3 (175B)</td><td>29.0</td><td>22.6</td><td>65.9</td><td>15.5</td><td>0.8</td></tr></table>
|
| 133 |
+
|
| 134 |
+
Table 5: Results on MLQA for Spanish (Es), German (De), Hindi $\mathrm { ( H i ) }$ , Vietnamese (Vi), Chinese (Zh) and Arabic (Ar). While using the MT tool to translate questions is helpful across all languages, further pretraining on CCNet deteriorates performance; thus, Toolformer does not consistently outperform GPT-J. The final rows correspond to models that are given contexts and questions in English.
|
| 135 |
+
|
| 136 |
+
<table><tr><td>Model</td><td>Es</td><td>De</td><td>Hi</td><td>Vi</td><td>Zh</td><td>Ar</td></tr><tr><td>GPT-J</td><td>15.2</td><td>16.5</td><td>1.3</td><td>8.2</td><td>18.2</td><td>8.2</td></tr><tr><td>GPT-J + CC</td><td>15.7</td><td>14.9</td><td>0.5</td><td>8.3</td><td>13.7</td><td>4.6</td></tr><tr><td>Toolformer (disabled)</td><td>19.8</td><td>11.9</td><td>1.2</td><td>10.1</td><td>15.0</td><td>3.1</td></tr><tr><td>Toolformer</td><td>20.6</td><td>13.5</td><td>1.4</td><td>10.6</td><td>16.8</td><td>3.7</td></tr><tr><td>OPT (66B)</td><td>0.3</td><td>0.1</td><td>1.1</td><td>0.2</td><td>0.7</td><td>0.1</td></tr><tr><td>GPT-3 (175B)</td><td>3.4</td><td>1.1</td><td>0.1</td><td>1.7</td><td>17.7</td><td>0.1</td></tr><tr><td>GPT-J (All En)</td><td>24.3</td><td>27.0</td><td>23.9</td><td>23.3</td><td>23.1</td><td>23.6</td></tr><tr><td>GPT-3 (All En)</td><td>24.7</td><td>27.2</td><td>26.1</td><td>24.9</td><td>23.6</td><td>24.0</td></tr></table>
|
| 137 |
+
|
| 138 |
+
Toolformer still lags behind the much larger GPT-3 (175B) model. This is likely due to both the simplicity of our search engine (in many cases, it returns results that are clearly not a good match for a given query) and the inability of Toolformer to interact with it, e.g., by reformulating its query if results are not helpful or by browsing through multiple of the top results.
|
| 139 |
+
|
| 140 |
+
Multilingual QA We evaluate all models on MLQA (Lewis et al., 2019), a multilingual QA benchmark. Context for each question is provided in English, while the question can be in Arabic, German, Spanish, Hindi, Vietnamese, or Simplified Chinese. Our evaluation metric is the percentage of times the model’s generation, capped at 10 words, contains the correct answer. Results are shown in Table 5. API calls improve Toolformer’s performance for all languages, suggesting that it has learned to make use of the machine translation tool. Depending on the language, this tool is used for $6 3 . 8 \%$ to $9 4 . 9 \%$ of all examples; the only exception is Hindi, for which it is used in only $7 . 3 \%$ of cases. However, Toolformer does not consistently outperform GPT-J as finetuning on CCNet deteriorates performance for some languages. OPT and GPT-3 perform surprisingly weak across all languages, mostly because they fail to provide an answer in English despite being instructed to do so. A potential reason for GPT-J not suffering from this problem is that it was trained on more multilingual data than both OPT and GPT-3, including EuroParl (Koehn, 2005). As an upper bound, we also evaluate GPT-J and GPT-3 on a variant of MLQA where both the context and the question are provided in English. In this setup, GPT-3 performs better than all other models, supporting our hypothesis that its subpar performance on MLQA is due to the task’s multilingual aspect.
|
| 141 |
+
|
| 142 |
+
Temporal Datasets We evaluate all models on TEMPLAMA (Dhingra et al., 2022) and a new dataset that we call DATESET. TEMPLAMA contains cloze queries about facts that change with time. DATESET, described in Appendix D, is generated through a series of templates, but populated using a combination of random dates/durations (e.g., “What day of the week was it 30 days ago?”). For both tasks, we use the same evaluation as for the original LAMA dataset. Results shown in Table 4 (right) illustrate that Toolformer outperforms all baselines for both TEMPLAMA and DATESET. However, closer inspection shows that improvements on TEMPLAMA can not be attributed to the calendar tool, which is only used for $0 . 2 \%$ of all examples, but mostly to the Wikipedia search and question answering tools.This makes sense given that entities in TEMPLAMA are often so specific and rare that even knowing the date alone would be of little help. The best course of action for this dataset – first querying the calendar API to get the current date, and then querying the QA system with this date – is not only prohibited by our restriction of using at most one API call, but also hard to learn for Toolformer given that all API calls in its training data are sampled independently. For DATESET, on the other hand, the considerable improvement of Toolformer compared to other models can be fully accredited to the calendar tool, which it makes use of for $5 4 . 8 \%$ of all examples.
|
| 143 |
+
|
| 144 |
+

|
| 145 |
+
Figure 4: Average performance on LAMA, our math benchmarks and our QA benchmarks for GPT-2 models of different sizes and GPT-J finetuned with our approach, both with and without API calls. While API calls are not helpful to the smallest models, larger models learn how to make good use of them. Even for bigger models, the gap between predictions with and without API calls remains high.
|
| 146 |
+
|
| 147 |
+
# 4.3 Language Modeling
|
| 148 |
+
|
| 149 |
+
We want to ensure that language modeling performance of Toolformer does not degrade through finetuning with API calls. To this end, we evaluate our models on two language modeling datasets: WikiText (Merity et al., 2017) and a subset of 10,000 randomly selected documents from CCNet (Wenzek et al., 2020) that were not used during training. Finetuning on CCNet leads to slightly improved performance on the CCNet evaluation subset (perplexity improves from 10.6 to 10.5), but slightly deteriorates performance on WikiText (9.9 to 10.3), presumably because the original pretraining data for GPT-J is more similar to WikiText than our subset of CCNet. Most importantly, however, training on $\mathcal { C } ^ { * }$ does not lead to an increase in perplexity compared to training on $\mathcal { C }$ when API calls are disabled at inference time, giving perplexities of 10.5 and 10.3, respectively.5
|
| 150 |
+
|
| 151 |
+
# 4.4 Scaling Laws
|
| 152 |
+
|
| 153 |
+
We investigate how the ability to ask external tools for help affects performance as we vary the size of our LM. To this end, we apply our approach not just to GPT-J, but also to four smaller models from the GPT-2 family (Radford et al., 2019), with 124M, 355M, 775M and 1.6B parameters, respectively. We do so using only a subset of three tools: the question answering system, the calculator, and the Wikipedia search engine. Apart from this, we follow the experimental setup described in Section 4.1. Figure 4 shows that the ability to leverage the provided tools only emerges at around 775M parameters: smaller models achieve similar performance both with and without tools. An exception to this is the Wikipedia search engine used mostly for QA benchmarks; we hypothesize that this is because the API is comparably easy to use. While models become better at solving tasks without API calls as they grow in size, their ability to make good use of the provided API improves at the same time. Thus, there remains a large gap between predictions with and without API calls even for our biggest model.
|
| 154 |
+
|
| 155 |
+
In Appendix G, we extend these investigations in scale to the LLaMA v1 7B model (Touvron et al., 2023) to see how tool-use scales with model capability instead of size. We find that the utility of weaker tools such as the WikiSearch tool vanish for these stronger base-models, and we demonstrate the value of generating and scoring with a strong model, compared to simply finetuning.
|
| 156 |
+
|
| 157 |
+
# 5 Related Work
|
| 158 |
+
|
| 159 |
+
Language Model Pretraining There are various approaches that augment LMs with some form of additional textual information during pretraining, including various forms of metadata (Keskar et al., 2019), HTML tags (Aghajanyan et al., 2021), Wikipedia markup (Schick et al., 2022), or related texts obtained from an information retrieval system (Guu et al., 2020; Borgeaud et al., 2021; Izacard et al., 2022). For all of these approaches, additional information is always provided, regardless of whether it is helpful or not. In contrast, Toolformer learns for itself to explicitly asks for the right information.
|
| 160 |
+
|
| 161 |
+
Tool Use Several approaches aim to equip LMs with the ability to use external tools such as search engines (Komeili et al., 2022; Thoppilan et al., 2022; Lazaridou et al., 2022; Shuster et al., 2022; Yao et al., 2022), web browsers (Nakano et al., 2021), calculators (Cobbe et al., 2021; Thoppilan et al., 2022), translation systems (Thoppilan et al., 2022) and Python interpreters (Gao et al., 2022). The way these models learn to use tools can roughly be divided into two approaches: Either they rely on large amounts of human supervision (Komeili et al., 2022; Nakano et al., 2021; Thoppilan et al., 2022) or they work by prompting the language model in a few-shot setup tailored towards a specific task where it is known a priori which tools needs to be used (Gao et al., 2022; Lazaridou et al., 2022; Yao et al., 2022). In contrast, the self-supervised nature of Toolformer enables it to learn how and when to use tools without requiring a specific prompt that shows task-specific examples of how a tool could be used. Perhaps most closely related to our work is TALM (Parisi et al., 2022), an approach that uses a similar self-supervised objective for teaching a model to use a calculator and a search engine, but explores this only in settings where a model is finetuned for downstream tasks.
|
| 162 |
+
|
| 163 |
+
Bootstrapping The idea of using self-training and bootstrapping techniques to improve models has been investigated in various contexts, ranging from word sense disambiguation (Yarowsky, 1995), relation extraction (Brin, 1999; Agichtein and Gravano, 2000), parsing (McClosky et al., 2006), sequence generation (He et al., 2020), few-shot text classification (Schick and Schütze, 2021a) and retrieval (Izacard and Grave, 2021) to reasoning (Zelikman et al., 2022). In a similar spirit, Toolformer is trained on its own predictions after applying a perplexity-based filtering step.
|
| 164 |
+
|
| 165 |
+
# 6 Limitations
|
| 166 |
+
|
| 167 |
+
While our approach enables LMs to learn how to use a variety of tools in a self-supervised way, there are some clear limitations to what can be achieved with our method in its current form. One such limitation is the inability of Toolformer to use tools in a chain (i.e., using the output of one tool as an input for another tool). This is due to the fact that API calls for each tool are generated independently; as a consequence, there are no examples of chained tool use in the finetuning dataset, since this would necessitate multiple API calls per example. Our current approach also does not allow the LM to use a tool in an interactive way – especially for tools such as search engines, that could potentially return hundreds of different results, enabling a LM to browse through these results or to refine its search query in a similar spirit to Nakano et al. (2021) can be crucial for certain applications. Beyond this, we found models trained with Toolformer to often be sensitive to the exact wording of their input when deciding whether or not to call an API; this is perhaps unsurprising given that LMs are known to be very sensitive to the prompt they are provided with in both zero- and few-shot settings (Jiang et al., 2020; Schick and Schütze, 2021a). Depending on the tool, our method is also very sample-inefficient; for example, processing more than a million documents results in only a few thousand examples of useful calls to the calculator API. A potential solution to this problem might be to iteratively apply our approach, similar to how this is done in related bootstrapping approaches (Schick and Schütze, 2021a; Izacard and Grave, 2021; Parisi et al., 2022). Finally, when deciding whether or not to make an API call, Toolformer currently does not take into account the tool-dependent, computational cost incurred from making an API call.
|
| 168 |
+
|
| 169 |
+
# 7 Conclusion
|
| 170 |
+
|
| 171 |
+
We have introduced Toolformer, a LM that learns in a self-supervised way how to use different tools such as search engines, calculators, and translation systems via simple API calls. This is done by finetuning on sampled API calls that are filtered based on whether they reduce perplexity on future tokens. Toolformer considerably improves zero-shot performance of a 6.7B parameter GPT-J model, enabling it to even outperform a much larger GPT-3 model on a range of different downstream tasks.
|
| 172 |
+
|
| 173 |
+
# References
|
| 174 |
+
|
| 175 |
+
Armen Aghajanyan, Dmytro Okhonko, Mike Lewis, Mandar Joshi, Hu Xu, Gargi Ghosh, and Luke Zettlemoyer. 2021. Htlm: Hyper-text pre-training and prompting of language models.
|
| 176 |
+
|
| 177 |
+
Eugene Agichtein and Luis Gravano. 2000. Snowball: Extracting relations from large plain-text collections. In Proceedings of the Fifth ACM Conference on Digital Libraries, DL ’00, page 85–94, New York, NY, USA. Association for Computing Machinery.
|
| 178 |
+
|
| 179 |
+
Ricardo Baeza-Yates, Berthier Ribeiro-Neto, et al. 1999. Modern information retrieval, volume 463. ACM press New York.
|
| 180 |
+
|
| 181 |
+
Jonathan Berant, Andrew Chou, Roy Frostig, and Percy Liang. 2013. Semantic parsing on Freebase from question-answer pairs. In Proceedings of the 2013 Conference on Empirical Methods in Natural Language Processing, pages 1533–1544, Seattle, Washington, USA. Association for Computational Linguistics.
|
| 182 |
+
|
| 183 |
+
Sebastian Borgeaud, Arthur Mensch, Jordan Hoffmann, Trevor Cai, Eliza Rutherford, Katie Millican, George van den Driessche, Jean-Baptiste Lespiau, Bogdan Damoc, Aidan Clark, Diego de Las Casas, Aurelia Guy, Jacob Menick, Roman Ring, Tom Hennigan, Saffron Huang, Loren Maggiore, Chris Jones, Albin Cassirer, Andy Brock, Michela Paganini, Geoffrey Irving, Oriol Vinyals, Simon Osindero, Karen Simonyan, Jack W. Rae, Erich Elsen, and Laurent Sifre. 2021. Improving language models by retrieving from trillions of tokens.
|
| 184 |
+
|
| 185 |
+
Sergey Brin. 1999. Extracting patterns and relations from the world wide web. In The World Wide Web and Databases, pages 172–183, Berlin, Heidelberg. Springer Berlin Heidelberg.
|
| 186 |
+
|
| 187 |
+
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. 2020. Language models are few-shot learners. In Advances in Neural Information Processing Systems, volume 33, pages 1877–1901. Curran Associates, Inc.
|
| 188 |
+
|
| 189 |
+
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.
|
| 190 |
+
|
| 191 |
+
Karl Cobbe, Vineet Kosaraju, Mohammad Bavarian, Mark Chen, Heewoo Jun, Lukasz Kaiser, Matthias Plappert, Jerry Tworek, Jacob Hilton, Reiichiro Nakano, et al. 2021. Training verifiers to solve math word problems. arXiv preprint arXiv:2110.14168.
|
| 192 |
+
|
| 193 |
+
Marta R Costa-jussà, James Cross, Onur Çelebi, Maha Elbayad, Kenneth Heafield, Kevin Heffernan, Elahe Kalbassi, Janice Lam, Daniel Licht, Jean Maillard, et al. 2022. No language left behind: Scaling human-centered machine translation. arXiv preprint arXiv:2207.04672.
|
| 194 |
+
|
| 195 |
+
Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. 2019. 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), pages 4171–4186, Minneapolis, Minnesota. Association for Computational Linguistics.
|
| 196 |
+
|
| 197 |
+
Bhuwan Dhingra, Jeremy R. Cole, Julian Martin Eisenschlos, Daniel Gillick, Jacob Eisenstein, and William W. Cohen. 2022. Time-aware language models as temporal knowledge bases. Transactions of the Association for Computational Linguistics, 10:257–273.
|
| 198 |
+
|
| 199 |
+
Luyu Gao, Aman Madaan, Shuyan Zhou, Uri Alon, Pengfei Liu, Yiming Yang, Jamie Callan, and Graham Neubig. 2022. Pal: Program-aided language models.
|
| 200 |
+
|
| 201 |
+
Kelvin Guu, Kenton Lee, Zora Tung, Panupong Pasupat, and Ming-Wei Chang. 2020. Realm: Retrieval-augmented language model pre-training.
|
| 202 |
+
|
| 203 |
+
Junxian He, Jiatao Gu, Jiajun Shen, and Marc’Aurelio Ranzato. 2020. Revisiting self-training for neural sequence generation. In International Conference on Learning Representations.
|
| 204 |
+
|
| 205 |
+
Or Honovich, Thomas Scialom, Omer Levy, and Timo Schick. 2022. Unnatural instructions: Tuning language models with (almost) no human labor.
|
| 206 |
+
|
| 207 |
+
Gautier Izacard and Edouard Grave. 2021. Distilling knowledge from reader to retriever for question answering. In International Conference on Learning Representations.
|
| 208 |
+
|
| 209 |
+
Gautier Izacard, Patrick Lewis, Maria Lomeli, Lucas Hosseini, Fabio Petroni, Timo Schick, Jane Dwivedi-Yu, Armand Joulin, Sebastian Riedel, and Edouard Grave. 2022. Atlas: Few-shot learning with retrieval augmented language models.
|
| 210 |
+
|
| 211 |
+
Ziwei Ji, Nayeon Lee, Rita Frieske, Tiezheng Yu, Dan Su, Yan Xu, Etsuko Ishii, Yejin Bang, Andrea Madotto, and Pascale Fung. 2022. Survey of hallucination in natural language generation. ACM Computing Surveys.
|
| 212 |
+
|
| 213 |
+
Zhengbao Jiang, Frank F. Xu, Jun Araki, and Graham Neubig. 2020. How can we know what language models know? Transactions of the Association for Computational Linguistics, 8:423–438.
|
| 214 |
+
|
| 215 |
+
Mandar Joshi, Eunsol Choi, Daniel Weld, and Luke Zettlemoyer. 2017. TriviaQA: A large scale distantly supervised challenge dataset for reading comprehension. In Proceedings of the 55th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pages 1601–1611, Vancouver, Canada. Association for Computational Linguistics.
|
| 216 |
+
|
| 217 |
+
Armand Joulin, Edouard Grave, Piotr Bojanowski, Matthijs Douze, Hérve Jégou, and Tomas Mikolov. 2016. Fasttext. zip: Compressing text classification models. arXiv preprint arXiv:1612.03651.
|
| 218 |
+
|
| 219 |
+
Nitish Shirish Keskar, Bryan McCann, Lav R. Varshney, Caiming Xiong, and Richard Socher. 2019. Ctrl: A conditional transformer language model for controllable generation.
|
| 220 |
+
|
| 221 |
+
Philipp Koehn. 2005. Europarl: A parallel corpus for statistical machine translation. In Proceedings of machine translation summit x: papers, pages 79–86.
|
| 222 |
+
|
| 223 |
+
Mojtaba Komeili, Kurt Shuster, and Jason Weston. 2022. Internet-augmented dialogue generation. In Proceedings of the 60th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pages 8460–8478, Dublin, Ireland. Association for Computational Linguistics.
|
| 224 |
+
|
| 225 |
+
Rik Koncel-Kedziorski, Subhro Roy, Aida Amini, Nate Kushman, and Hannaneh Hajishirzi. 2016. 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, pages 1152–1157, San Diego, California. Association for Computational Linguistics.
|
| 226 |
+
|
| 227 |
+
Tom Kwiatkowski, Jennimaria Palomaki, Olivia Redfield, Michael Collins, Ankur Parikh, Chris Alberti, Danielle Epstein, Illia Polosukhin, Jacob Devlin, Kenton Lee, Kristina Toutanova, Llion Jones, Matthew Kelcey, Ming-Wei Chang, Andrew M. Dai, Jakob Uszkoreit, Quoc Le, and Slav Petrov. 2019. Natural questions: A benchmark for question answering research. Transactions of the Association for Computational Linguistics, 7:452–466.
|
| 228 |
+
|
| 229 |
+
Angeliki Lazaridou, Elena Gribovskaya, Wojciech Stokowiec, and Nikolai Grigorev. 2022. Internetaugmented language models through few-shot prompting for open-domain question answering. arXiv preprint arXiv:2203.05115.
|
| 230 |
+
|
| 231 |
+
Patrick Lewis, Barlas Oguz, Ruty Rinott, Sebastian Riedel, and Holger Schwenk. 2019. Mlqa:˘ Evaluating cross-lingual extractive question answering. arXiv preprint arXiv:1910.07475.
|
| 232 |
+
|
| 233 |
+
Xi Victoria Lin, Todor Mihaylov, Mikel Artetxe, Tianlu Wang, Shuohui Chen, Daniel Simig, Myle Ott, Naman Goyal, Shruti Bhosale, Jingfei Du, Ramakanth Pasunuru, Sam Shleifer, Punit Singh Koura, Vishrav Chaudhary, Brian O’Horo, Jeff Wang, Luke Zettlemoyer, Zornitsa Kozareva, Mona Diab, Veselin Stoyanov, and Xian Li. 2021. Few-shot learning with multilingual language models.
|
| 234 |
+
|
| 235 |
+
Joshua Maynez, Shashi Narayan, Bernd Bohnet, and Ryan McDonald. 2020. On faithfulness and factuality in abstractive summarization.
|
| 236 |
+
|
| 237 |
+
David McClosky, Eugene Charniak, and Mark Johnson. 2006. Effective self-training for parsing. In Proceedings of the Human Language Technology Conference of the NAACL, Main Conference, pages 152–159, New York City, USA. Association for Computational Linguistics.
|
| 238 |
+
|
| 239 |
+
Stephen Merity, Caiming Xiong, James Bradbury, and Richard Socher. 2017. Pointer sentinel mixture models. In International Conference on Learning Representations.
|
| 240 |
+
|
| 241 |
+
Shen-yun Miao, Chao-Chun Liang, and Keh-Yih Su. 2020. 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, pages 975–984, Online. Association for Computational Linguistics.
|
| 242 |
+
|
| 243 |
+
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. 2021. Webgpt: Browser-assisted question-answering with human feedback.
|
| 244 |
+
|
| 245 |
+
Aaron Parisi, Yao Zhao, and Noah Fiedel. 2022. Talm: Tool augmented language models.
|
| 246 |
+
|
| 247 |
+
Arkil Patel, Satwik Bhattamishra, and Navin Goyal. 2021. 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, pages 2080–2094, Online. Association for Computational Linguistics.
|
| 248 |
+
|
| 249 |
+
Fabio Petroni, Aleksandra Piktus, Angela Fan, Patrick Lewis, Majid Yazdani, Nicola De Cao, James Thorne, Yacine Jernite, Vladimir Karpukhin, Jean Maillard, Vassilis Plachouras, Tim Rocktäschel, and Sebastian Riedel. 2021. KILT: a benchmark for knowledge intensive language tasks. In Proceedings of the 2021 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, pages 2523–2544, Online. Association for Computational Linguistics.
|
| 250 |
+
|
| 251 |
+
Fabio Petroni, Tim Rocktäschel, Sebastian Riedel, Patrick Lewis, Anton Bakhtin, Yuxiang Wu, and Alexander Miller. 2019. 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), pages 2463–2473, Hong Kong, China. Association for Computational Linguistics.
|
| 252 |
+
|
| 253 |
+
Alec Radford, Jeffrey Wu, Rewon Child, David Luan, Dario Amodei, Ilya Sutskever, et al. 2019. Language models are unsupervised multitask learners. OpenAI blog, 1(8):9.
|
| 254 |
+
|
| 255 |
+
Stephen E Robertson, Steve Walker, Susan Jones, Micheline M Hancock-Beaulieu, Mike Gatford, et al. 1995. Okapi at trec-3. Nist Special Publication Sp, 109:109.
|
| 256 |
+
|
| 257 |
+
Timo Schick, Jane Dwivedi-Yu, Zhengbao Jiang, Fabio Petroni, Patrick Lewis, Gautier Izacard, Qingfei You, Christoforos Nalmpantis, Edouard Grave, and Sebastian Riedel. 2022. Peer: A collaborative language model.
|
| 258 |
+
|
| 259 |
+
Timo Schick and Hinrich Schütze. 2021a. Exploiting cloze-questions for few-shot text classification and natural language inference. In Proceedings of the 16th Conference of the European Chapter of the Association for Computational Linguistics: Main Volume, pages 255–269, Online. Association for Computational Linguistics.
|
| 260 |
+
|
| 261 |
+
Timo Schick and Hinrich Schütze. 2021b. Generating datasets with pretrained language models. In Proceedings of the 2021 Conference on Empirical Methods in Natural Language Processing, pages 6943–6951, Online and Punta Cana, Dominican Republic. Association for Computational Linguistics.
|
| 262 |
+
|
| 263 |
+
Kurt Shuster, Jing Xu, Mojtaba Komeili, Da Ju, Eric Michael Smith, Stephen Roller, Megan Ung, Moya Chen, Kushal Arora, Joshua Lane, Morteza Behrooz, William Ngan, Spencer Poff, Naman Goyal, Arthur Szlam, Y-Lan Boureau, Melanie Kambadur, and Jason Weston. 2022. Blenderbot 3: a deployed conversational agent that continually learns to responsibly engage.
|
| 264 |
+
|
| 265 |
+
Romal Thoppilan, Daniel De Freitas, Jamie Hall, Noam Shazeer, Apoorv Kulshreshtha, Heng-Tze Cheng, Alicia Jin, Taylor Bos, Leslie Baker, Yu Du, YaGuang Li, Hongrae Lee, Huaixiu Steven Zheng, Amin Ghafouri, Marcelo Menegali, Yanping Huang, Maxim Krikun, Dmitry Lepikhin, James Qin, Dehao Chen, Yuanzhong Xu, Zhifeng Chen, Adam Roberts, Maarten Bosma, Vincent Zhao, Yanqi Zhou, Chung-Ching Chang, Igor Krivokon, Will Rusch, Marc Pickett, Pranesh Srinivasan, Laichee Man, Kathleen Meier-Hellstern, Meredith Ringel Morris, Tulsee Doshi, Renelito Delos Santos, Toju Duke, Johnny Soraker, Ben Zevenbergen, Vinodkumar Prabhakaran, Mark Diaz, Ben Hutchinson, Kristen Olson, Alejandra Molina, Erin Hoffman-John, Josh Lee, Lora Aroyo, Ravi Rajakumar, Alena Butryna, Matthew Lamm, Viktoriya Kuzmina, Joe Fenton, Aaron Cohen, Rachel Bernstein, Ray Kurzweil, Blaise Aguera-Arcas, Claire Cui, Marian Croak, Ed Chi, and Quoc Le. 2022. Lamda: Language models for dialog applications.
|
| 266 |
+
|
| 267 |
+
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. 2023. Llama: Open and efficient foundation language models.
|
| 268 |
+
|
| 269 |
+
Ben Wang and Aran Komatsuzaki. 2021. GPT-J-6B: A 6 Billion Parameter Autoregressive Language Model. https://github.com/kingoflolz/mesh-transformer-jax.
|
| 270 |
+
|
| 271 |
+
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.
|
| 272 |
+
|
| 273 |
+
Guillaume Wenzek, Marie-Anne Lachaux, Alexis Conneau, Vishrav Chaudhary, Francisco Guzmán, Armand Joulin, and Edouard Grave. 2020. CCNet: Extracting high quality monolingual datasets from web crawl data. In Proceedings of the Twelfth Language Resources and Evaluation Conference, pages 4003–4012, Marseille, France. European Language Resources Association.
|
| 274 |
+
|
| 275 |
+
Shunyu Yao, Jeffrey Zhao, Dian Yu, Nan Du, Izhak Shafran, Karthik Narasimhan, and Yuan Cao. 2022. React: Synergizing reasoning and acting in language models.
|
| 276 |
+
|
| 277 |
+
David Yarowsky. 1995. Unsupervised word sense disambiguation rivaling supervised methods. In 33rd Annual Meeting of the Association for Computational Linguistics, pages 189–196, Cambridge, Massachusetts, USA. Association for Computational Linguistics.
|
| 278 |
+
|
| 279 |
+
Eric Zelikman, Yuhuai Wu, Jesse Mu, and Noah D. Goodman. 2022. Star: Bootstrapping reasoning with reasoning.
|
| 280 |
+
|
| 281 |
+
Susan Zhang, Stephen Roller, Naman Goyal, Mikel Artetxe, Moya Chen, Shuohui Chen, Christopher Dewan, Mona Diab, Xian Li, Xi Victoria Lin, Todor Mihaylov, Myle Ott, Sam Shleifer, Kurt Shuster, Daniel Simig, Punit Singh Koura, Anjali Sridhar, Tianlu Wang, and Luke Zettlemoyer. 2022. Opt: Open pre-trained transformer language models.
|
md/dev/Z4kZxAjg8Y/Z4kZxAjg8Y.md
ADDED
|
@@ -0,0 +1,362 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Autoregressive Search Engines: Generating Substrings as Document Identifiers
|
| 2 |
+
|
| 3 |
+
Michele Bevilacqua1,2 Giuseppe Ottaviano2 Patrick Lewis2 Wen-tau $\mathbf { Y i \bar { h } ^ { 2 } }$ Sebastian Riedel2,3 Fabio Petroni2 Sapienza University of Rome 2Meta AI 3University College London
|
| 4 |
+
|
| 5 |
+
# Abstract
|
| 6 |
+
|
| 7 |
+
Knowledge-intensive language tasks require NLP systems to both provide the correct answer and retrieve supporting evidence for it in a given corpus. Autoregressive language models are emerging as the de-facto standard for generating answers, with newer and more powerful systems emerging at an astonishing pace. In this paper we argue that all this (and future) progress can be directly applied to the retrieval problem with minimal intervention to the models’ architecture. Previous work has explored ways to partition the search space into hierarchical structures and retrieve documents by autoregressively generating their unique identifier. In this work we propose an alternative that doesn’t force any structure in the search space: using all ngrams in a passage as its possible identifiers. This setup allows us to use an autoregressive model to generate and score distinctive ngrams, that are then mapped to full passages through an efficient data structure. Empirically, we show this not only outperforms prior autoregressive approaches but also leads to an average improvement of at least 10 points over more established retrieval solutions for passage-level retrieval on the KILT benchmark, establishing new stateof-the-art downstream performance on some datasets, while using a considerably lighter memory footprint than competing systems. Code and pre-trained models are available at https://github.com/facebookresearch/SEAL.
|
| 8 |
+
|
| 9 |
+
# 1 Introduction
|
| 10 |
+
|
| 11 |
+
Surfacing knowledge from large corpora is a crucial step when dealing with knowledge intensive language tasks [Levy et al., 2017, Dinan et al., 2019, Elsahar et al., 2018, Petroni et al., 2021], such as open-domain question answering [Voorhees et al., 1999, Joshi et al., 2017, Yang et al., 2018, Kwiatkowski et al., 2019] and fact checking [Thorne et al., 2018]. A popular paradigm to approach such tasks is to combine a search engine with a machine reader component. The former retrieves relevant context, usually in the form of short passages, which the latter then examines to produce answers [Chen et al., 2017, Lewis et al., 2020, Izacard and Grave, 2021].
|
| 12 |
+
|
| 13 |
+
In recent years we have witnessed a surge of research and development in autoregressive language models [Radford et al., 2019, Lewis et al., 2019, Raffel et al., 2019, Brown et al., 2020, Rae et al., 2021, Artetxe et al., 2021, Smith et al., 2022], with ever increasing size and natural language understanding (NLU) capabilities. Such models are currently the de-facto implementation of the machine reader component in retrieval-reader architectures, and have contributed to rapid progress on a wide range of benchmarks [Joshi et al., 2017, Kwiatkowski et al., 2019, Petroni et al., 2021]. However, these tremendous advances in aggressive modelling has yet to bring similar transformational changes in how retrieval is approached.
|
| 14 |
+
|
| 15 |
+
Transferring the NLU capabilities of modern autoregressive models to retrieval is non-trivial. Some works have demonstrated that knowledge stored in the parameters of these models can be retrieved to some extend by directly generating evidence given a query [Petroni et al., 2019, 2020, Roberts et al., 2020]. However, such approaches have been shown to be unreliable because of their tendency to hallucinate non-factual content [Massarelli et al., 2019, Metzler et al., 2021, Ji et al., 2022]. To alleviate this issue, previous work proposes to only use generation for query expansion in traditional search engines [Mao et al., 2021], but these solutions don’t exploit the full potential of autoregressive architecture, such as word order sensitivity and conditional probability modeling, and still lag behind vector-based approaches [Karpukhin et al., 2020].
|
| 16 |
+
|
| 17 |
+

|
| 18 |
+
Figure 1: High-level SEAL architecture, composed of an autoregressive LM paired with an FM-Index, for which we show the first (F) and last (L) columns of the underlying matrix (more details in Sec 3.1). The FM-index constrains the autoregressive generation (e.g., after carbon the model is contrained to generate either tax, dioxide or atom in the example) and provides the documents matching (i.e., containing) the generated ngram (at each decoding step).
|
| 19 |
+
|
| 20 |
+
Recently, another line of work has investigated using autoregressive language models to generate identifier strings for documents as an intermediate target for retrieval, such as Wikipedia page titles [De Cao et al., 2021b], or root-to-leaf paths in a hierarchical cluster tree [Tay et al., 2022]. Employing identifiers, rather than generating evidence directly, induces structure in the search space, (i.e., index documents by their title or their cluster tree) which can be easier to memorize, learn, and retrieve from, than full unstructured passages. Moreover, it is relatively easy to constrain decoding with a prefix tree “index” so that only valid identifiers are generated. As a downside, if appropriate metadata (e.g., titles) are not available, one needs to create the identifiers, hence the structure (e.g., with hierarchical clustering), which has not been thoroughly evaluated on a large-scale benchmark.
|
| 21 |
+
|
| 22 |
+
In this work, we propose a solution that does not force any structure in the search space, but rather uses all the ngrams occurring in a document as its identifiers. Concretely, we introduce Search Engines with Autoregressive LMs (SEAL), a retrieval solution that combines an autoregressive model, i.e., BART [Lewis et al., 2019], with a compressed full-text substring index, i.e., the FM-Index [Ferragina and Manzini, 2000] — see Figure 1 for an high-level overview. This configuration comes with a twofold benefit: i) we can constrain BART’s generations with the FM-Index, hence preventing the generation of invalid identifiers (i.e., ngrams not occurring in any document); ii) the FM-Index provides information on all documents in the corpus containing a specific ngram (for every decoding step), thus allowing to retrieve them. This setup allows SEAL to generate any span from any position in the corpus, without needing to explicitly encode all substrings in a document. Moreover, we design a novel scoring function to intersect the results of multiple ngrams combining LM probabilities with FM-index frequencies (i.e., number of occurrences of the ngram in the whole corpus).
|
| 23 |
+
|
| 24 |
+
Our experimental evaluation shows that SEAL matches or outperforms recent retrieval solutions (including autoregressive ones) on Natural Questions [Kwiatkowski et al., 2019], while requiring substantially less memory ( ${ \sim } 2$ to 7 times smaller in footprint). Moreover, SEAL’s intersection formulation improves the state-of-the-art on passage-level retrieval by more than 10 points on the KILT benchmark [Petroni et al., 2021], contributing in establishing new state-of-the-art downstream results on multiple datasets when paired with existing reader technologies.
|
| 25 |
+
|
| 26 |
+
# 2 Related Work
|
| 27 |
+
|
| 28 |
+
One way to approach retrieval with autoregressive models makes use of unique identifiers, i.e., string pointers to documents that are in some way easier to generate than the full document itself [De Cao et al., 2021b, Tay et al., 2022]. In our work the identifiers are generated ngrams, which do not necessarily occur in just one document. Note that the idea of using phrases to retrieve passages has shown promise already in the context of dense retrieval [Lee et al., 2021a,b].
|
| 29 |
+
|
| 30 |
+
Our approach is quite conceptually distinct from document [Nogueira et al., 2019, Nogueira and Lin, 2021] and query expansion approaches [Mao et al., 2021], that use autoregressive models to boost search, but still rely on black-box systems like BM25 [Robertson and Zaragoza, 2009] for the retrieval: in our work the boundary between generation and retrieval is blurred, since we generate grounded passage spans. The same reasoning applies to models that generate queries for web search engines [Komeili et al., 2021, Shuster et al., 2022, Nakano et al., 2021, Lazaridou et al., 2022].
|
| 31 |
+
|
| 32 |
+
Virtually all modern approaches to string-matching-based retrieval use bag-of-words representations. Many recent works propose learned contextualized weighting for both queries and documents terms [Dai and Callan, 2019, Gao et al., 2021, Lin and Ma, 2021, Mallia et al., 2021, Dai and Callan, 2020, Bai et al., 2020, Zhao et al., 2021, Formal et al., 2021b,a]. Many of these methods can also weigh terms that are not present in the query, addressing so-called vocabulary mismatch. In contrast, SEAL generates (and scores) ngrams of arbitrary size. These approaches are partly orthogonal to SEAL, as many of the proposed techniques could be used to rescore higher-order ngrams.
|
| 33 |
+
|
| 34 |
+
Finally, a connected strand of research is that of query likelihood models, which use autoregressive models to (re)rank passages according to the probability $P ( q | p )$ of a query $q$ given the passage $p$ [Nogueira dos Santos et al., 2020, Zhuang and Zuccon, 2021, Lesota et al., 2021, Sachan et al., 2022]. In our case, the autoregressive architecture models the likelihood of an ngram given the query, i.e., $P ( n | q )$ .
|
| 35 |
+
|
| 36 |
+
# 3 Background
|
| 37 |
+
|
| 38 |
+
In retrieval, the automatic system is required to return an ordered list of documents $d _ { 1 } , d _ { 2 } , \ldots , d _ { n }$ from a retrieval corpus $\mathcal { R }$ , given a query $q$ . Both queries and documents are texts, i.e., lists of tokens $\langle t _ { 1 } , t _ { 2 } , \dots , t _ { N } \rangle$ , where each token $t$ is drawn from a vocabulary $V$ . A span of tokens in a text is called an ngram; ngrams of size 1 are known as unigrams. We denote with $F ( n , \mathcal { R } )$ the frequency of an ngram $n$ in $\mathcal { R }$ , i.e., the total number of times it appears in the whole retrieval corpus.
|
| 39 |
+
|
| 40 |
+
# 3.1 The FM-Index
|
| 41 |
+
|
| 42 |
+
Our method requires a data structure that can support the efficient identification of occurring substrings to guarantee that all decoded sequences are located somewhere in the retrieval corpus. Moreover, to perform retrieval, we require the ability to identify which documents the generated ngrams appear in. Neither inverted indices (which have no efficient way to search for phrases of arbitrary length), nor prefix trees (which would force us to explicitly encode all $k$ suffixes in a document), are viable options. The core data structure that satisfies our requirements is the FM-index [Ferragina and Manzini, 2000], i.e., a compressed suffix array that, as a self-index, requires no additional storage for the original text. FM-index space requirements are linear in the size of the corpus, and, with small vocabularies such as those used by modern subword-based language models, is thus usually significantly smaller than the uncompressed corpus. The FM-index can be used to count the frequency of any sequence of tokens $n$ in $O ( | n | \log | V | )$ , i.e., independently from the size of the corpus itself. For constrained decoding, the list of possible token successors can be obtained in $O ( | V | \mathrm { l o } \bar { \mathrm { g } } | V | )$ . Internally, the FM-index relies on the Burrows-Wheeler Transform [Burrows and Wheeler, 1994], or $B W T$ , an invertible transformation that permutes a string to make it easier to compress, defined as follows: all the rotations of the string are sorted lexicographically and laid out in a matrix; the last column of the matrix is the strings’s BWT.1 For example, given the string $C A B A C$ , the corresponding matrix would be:
|
| 43 |
+
|
| 44 |
+
$$
|
| 45 |
+
\begin{array} { c c c c c c c } { { \bf F } } & { { } } & { { } } & { { } } & { { \bf L } } & { { \bf \Delta } } \\ { { \mathbb { S } } ^ { 6 } } & { { } } & { { C } } & { { { \cal A } } } & { { { \cal B } } } & { { { \cal A } } } & { { C ^ { 5 } } } \\ { { { \cal A } } ^ { 2 } } & { { { \cal B } } } & { { { \cal A } } } & { { C } } & { { \mathbb { S } } } & { { C ^ { 1 } } } \\ { { { \cal A } } ^ { 4 } } & { { C } } & { { \mathbb { S } } } & { { C } } & { { { \cal A } } } & { { { \cal B } ^ { 3 } } } \\ { { { \cal B } } ^ { 3 } } & { { { \cal A } } } & { { C } } & { { \mathbb { S } } } & { { C } } & { { { \cal A } ^ { 2 } } } \\ { { C ^ { 5 } } } & { { \mathbb { S } } } & { { C } } & { { { \cal A } } } & { { { \cal B } } } & { { { \cal A } ^ { 4 } } } \\ { { C ^ { 1 } } } & { { { \cal A } } } & { { { \cal B } } } & { { { \cal A } } } & { { C } } & { { \mathbb { S } ^ { 6 } } } \end{array}
|
| 46 |
+
$$
|
| 47 |
+
|
| 48 |
+
where $\$ 1$ is a special end-of-string token. The first $( \mathbf { F } )$ and last $\mathbf { \Pi } ( \mathbf { L } )$ columns are the only ones that will be explicitly stored in the FM-index; $\mathbf { F }$ is just an array of runs (i.e., sequences of repeated tokens), due to the rotations being sorted, so it can be represented with one count for each alphabet symbol; L, the string’s BWT, will be stored in a data structure known as the Wavelet Tree [Grossi et al., 2003], which allows efficient rank-select-access queries, while exploiting the compressibility induced by the transformation. FM-indices have the useful property that for each symbol, the relative rank stays the same: that is, the ith occurrence of a symbol $\sigma$ in $\mathbf { F }$ points to the same location in the corpus of the ith occurrence of $\sigma$ in $\mathbf { L }$ . Thanks to this property, we can locate any string $\langle \sigma _ { 1 } , \sigma _ { 2 } , \ldots , \sigma _ { n } \rangle$ in the index by starting from $\sigma _ { n }$ and going backwards. First, we select the contiguous range of rows corresponding to the symbol $\sigma _ { n }$ in $\mathbf { F }$ , then we check the ranks of the first and last occurrences of $\sigma _ { n - 1 }$ in the same range of rows in $L$ . We use the ranks to select a new, smaller or equal range of rows looking up the symbol $\sigma _ { n - 1 }$ in $F$ . The procedure can be applied iteratively to find ngrams of any size.
|
| 49 |
+
|
| 50 |
+
# 4 Method
|
| 51 |
+
|
| 52 |
+
In our retrieval methodology, SEAL, we generate multiple ngrams, conditioning on a query. The ngrams are then used to find the documents they appear in within the corpus, which are then returned to the user. In Figure 1 we show this process at a high-level. We use our indexing structure, i.e., the FM-index to do constrained decoding so that each ngram occurs at least once in the retrieval corpus. Jointly, we use the FM-index to efficiently find matching documents. Documents are ranked using the scores of the generated ngrams.
|
| 53 |
+
|
| 54 |
+
Autoregressive Retrieval We generate ngrams identifiers with constrained beam search, using the FM-index to identify the set of possible next tokens in at most $O ( | V | \mathrm { l o g } | V | )$ : tokens corresponding to unattested continuations are blocked by masking the logit to $- \infty$ . As a result, after a single decoding pass, we get a set of ngrams $( K )$ , along with their autoregressively-computed probabilities according to the model. It is also trivial to find the positions in the corpus where the decoded ngrams appear, as constrained decoding already requires selecting the relevant range of rows in the FM-index. Note that autoregressive scoring entails monotonically decreasing scores—any string will be assigned a lower probability than any of its prefixes. To address this issue, we use fixed-length ngrams. Each document is assigned the score $( P ( \bar { n | q } ) )$ of its most probable decoded occurring ngram, i.e., the probability of the ngram as autoregressively computed by the decoder, conditioned on the encoder input We refer to this as the LM scoring.
|
| 55 |
+
|
| 56 |
+
Factoring in FM-index frequencies To counterbalance the monotonic probability decrease, we integrate in scoring unconditional ngram probabilities, computed as normalized index frequencies:
|
| 57 |
+
|
| 58 |
+
$$
|
| 59 |
+
P ( n ) = \frac { F ( n , \mathcal { R } ) } { \sum _ { d \in \mathcal { R } } \left| d \right| }
|
| 60 |
+
$$
|
| 61 |
+
|
| 62 |
+
This also enables us to promote distinctive ngrams, i.e., those that have high probability according to the model and low probability according to the FM-index. We take inspiration from the theory behind TF-IDF and BM25 [Robertson and Zaragoza, 2009] and use the following scoring function:
|
| 63 |
+
|
| 64 |
+
$$
|
| 65 |
+
w ( n , q ) = \operatorname* { m a x } \left( 0 , \log { \frac { P ( n | q ) ( 1 - P ( n ) ) } { P ( n ) ( 1 - P ( n | q ) ) } } \right)
|
| 66 |
+
$$
|
| 67 |
+
|
| 68 |
+
This formulation addresses the problem of length, as the unconditional probability of an ngram will also be equal or lower than that of any of its prefixes. To make better use of the computational resources, we slightly modify the beam search implementation to keep track of all the partially decoded sequences that have been considered. Thanks to this, we score a larger number of ngrams than the size of the beam. We refer to this formulation as the $\mathbf { L M + F M }$ scoring.
|
| 69 |
+
|
| 70 |
+
An Intersective Scoring for Multiple Ngrams One problem with the previous scoring formulations is that it is impossible to break ties among documents whose highest scoring ngram is the same, as they receive exactly the same score. Moreover, it might be difficult to capture all relevant information within a document by considering only a single ngram, for instance when salient ngrams are noncontiguous (e.g., separated by unrelated text). To address these issues we propose a novel scoring formulation that aggregates the contribution of multiple ngrams contained in the same document. To avoid repeated scoring of overlapping ngrams, for each document $d \in \mathcal { R }$ we only consider a subset of the generated ngrams $K ^ { ( d ) } \subset \overline { { K } }$ . An ngram $n$ belongs to $K ^ { ( d ) }$ if there is at least one occurrence of $n$ in $d$ that does not overlap in the corpus with an occurrence of another ngram $n ^ { \prime }$ such that a) $n ^ { \prime } \in K ^ { ( d ) }$ b) $w ( n ^ { \prime } , q ) > w ( n , q )$ . The document-level score, then, is the weighted sum of all ngrams in $K ^ { ( d ) }$ :
|
| 71 |
+
|
| 72 |
+
$$
|
| 73 |
+
W ( d , q ) = \sum _ { n \in K ^ { ( d ) } } w ( n , q ) ^ { \alpha } \cdot \mathrm { c o v e r } ( n , K ^ { ( d ) } )
|
| 74 |
+
$$
|
| 75 |
+
|
| 76 |
+
where $\alpha$ is a hyperparameter and the coverage weight cover $( n , K )$ (controlled by the second hyperparameter $\beta$ ) is a function of how many ngram tokens are not included in the coverage set $C ( n , K ) \subset V$ , i.e., the union of all tokens in ngrams with a higher score. We define this coverage weight as follows:
|
| 77 |
+
|
| 78 |
+
$$
|
| 79 |
+
\operatorname { c o v e r } ( n , K ) = 1 - \beta + \beta \cdot { \frac { | \operatorname { s e t } ( n ) \setminus C ( n , K ) | } { | \operatorname { s e t } ( n ) | } }
|
| 80 |
+
$$
|
| 81 |
+
|
| 82 |
+
where $\operatorname { s e t } ( n )$ is the set of all tokens in $n$ . The purpose of the coverage weight is to avoid the overscoring of very repetitive documents, where many similar ngrams are matched. Note that by saving the probability distribution at the first decoding step we can compute scores for all unigrams with no additional forward pass. We refer to this last approach, which can be thought of as a higher-order generalization of the bag-of-words assumption, as the $\mathbf { L M + F M }$ intersective scoring.
|
| 83 |
+
|
| 84 |
+
# 5 Experimental Setting
|
| 85 |
+
|
| 86 |
+
Our experimental setting evaluates SEAL on English knowledge-intensive NLP tasks. Each considered dataset is a collection of queries, each of which can be answered by looking for piece(s) of evidence in the corpus. We consider both an in vivo evaluation, in which we assess the model by looking at how well the document ranking matches with the ground truth, and, in addition, we perform a downstream evaluation, in which we feed the retrieved documents to a trained reader, that uses the documents to generate the answer.
|
| 87 |
+
|
| 88 |
+
# 5.1 Data
|
| 89 |
+
|
| 90 |
+
Natural Questions Natural Questions (NQ) is dataset containing query-document pairs, where the query is a question (e.g., “who wrote photograph by ringo starr”), and the document is a Wikipedia page, in which a span is marked as an answer [Kwiatkowski et al., 2019]. We experiment on both the customary retrieval setup used by, among others, Karpukhin et al. [2020] and Mao et al. [2021], and the substantially different setup used by Tay et al. [2022]. We refer to these two settings as, respectively, NQ and $\mathbf { N Q } 3 2 \mathbf { 0 } k$ . In NQ, retrieval is performed on an entire Wikipedia dump, chunked in around 21M passages of 100 tokens. Performance is measured as accuracy $@ k$ , i.e., the fraction of instances for which at least one of the top- $k$ retrieved passages contains the answer. $\mathrm { N Q } 3 2 0 k$ is a much more restricted setting, in which the retrieval set is limited to the union of all ground truth document in the training, dev or test set. Different revisions of the same Wikipedia page count as different documents. Note that the exact splits used by Tay et al. [2022], the retrieval corpus and the preprocessing code have not been yet released at the time of writing. Therefore, we have tried to replicate the setting as closely as possible, but the exact numbers are not precisely comparable with those reported in the original paper. In $\mathrm { N Q } 3 2 0 k$ , performance is measured as hits $@ k$ , i.e, the fraction of instances for which at least one of the top- $k$ retrieved passages is in the ground truth.
|
| 91 |
+
|
| 92 |
+
KILT is a comprehensive benchmark collecting different datasets including question answering, fact checking, dialogue, slot filling, and entity linking [Petroni et al., 2021]. All these tasks are solvable by retrieving information from a unified corpus — a Wikipedia dump. In KILT, the evidence is usually the paragraph that contains the answer. Following Maillard et al. [2021], we have rechunked KILT’s retrieval corpus, which is originally paragraph-based, in around 36M passages of 100 tokens. We do not use the entity linking and ELI5 KILT tasks, where a ground truth passage is not provided in the training set. KILT’s retrieval performance is measured with R-precision, a precision-oriented measure that considers only gold documents as correct answers, not just any document containing the answer. R-precision can be computed at either passage level or at page level.
|
| 93 |
+
|
| 94 |
+
Table 1: Language model and index size on Natural Questions (around 21M passages). SEAL’s index is ${ \sim } 1 . 5$ times smaller than uncompressed plain text.
|
| 95 |
+
|
| 96 |
+
<table><tr><td>System</td><td>Model Params</td><td colspan="3">Index</td></tr><tr><td>plain text</td><td></td><td>Size 13.4GB</td><td>Params</td><td>GPU?</td></tr><tr><td></td><td>-</td><td></td><td>-</td><td>-</td></tr><tr><td>DPR BM25</td><td>220M</td><td>64.6GB</td><td>16.1B</td><td>√</td></tr><tr><td>GAR</td><td>- 406M</td><td>18.8GB</td><td>-</td><td>X</td></tr><tr><td>DSI-BART</td><td>406M</td><td>18.8 GB</td><td></td><td>X</td></tr><tr><td></td><td></td><td>1</td><td></td><td></td></tr><tr><td>SEAL</td><td>406M</td><td>8.8GB</td><td></td><td>X</td></tr></table>
|
| 97 |
+
|
| 98 |
+
# 5.2 SEAL configuration
|
| 99 |
+
|
| 100 |
+
Training We finetune BART large [Lewis et al., 2019] to generate ngrams of length $k = 1 0$ from the ground truth document. Since there are $| d | - k$ ngrams in a document $d$ , we sample (with replacement) 10 ngrams from it, biasing the distribution in favor of ngrams with a high character overlap with the query. We also add the title of the document to the set of training ngrams. To expose the model to more possible pieces of evidence, we also add different “unsupervised” examples for each document in the retrieval corpus to the training set. In each of these examples the model takes as input a uniformly sampled span from the document, and predicts either another sampled span, or the title of the page. We append special tokens to the input to signal to the model a) whether the pair comes from the supervised or unsupervised training pairs (in the same spirit as the co-training task prompts used by Tay et al. [2022]) b) whether a title or span is expected as output. On KILT we train SEAL on all datasets at once. We report training and inference hyperameters in Appendix (§A).
|
| 101 |
+
|
| 102 |
+
How to choose ngrams In preliminary experiments, we have found that training SEAL with ngrams of fixed length sampled uniformly from the training chunk did not lead to good performances. Instead, we have biased the ngram distribution towards ngrams that were relevant to the query. As a simple proxy for relevance, we have use the Levenshtein (character-based) distance between the query and the ngram overlap. The final distribution to sample from is defined by the following formula:
|
| 103 |
+
|
| 104 |
+
$$
|
| 105 |
+
\frac { e ^ { L ( q , d _ { i : i + k } ) / \tau } } { \sum _ { j = 1 } ^ { | d | - k + 1 } e ^ { L ( q , d _ { j : j + k } ) / \tau } }
|
| 106 |
+
$$
|
| 107 |
+
|
| 108 |
+
where $L$ is the Levenshtein distance and $\tau$ $( = 1 . 5$ in our experiments) is a temperature parameter, controlling the peakiness of the distribution.
|
| 109 |
+
|
| 110 |
+
Index We use the $\mathrm { C } { + } { + }$ FM-index implementation in sdsl-lite. While the FM-index construction (which requires a sort of all rotations) takes around 6 hours in our single-threaded implementation, parallel algorithms are available [Labeit et al., 2017]. Each document is encoded as the subword tokenization of the concatenation of the title and the passage, separated by a special token. We report in Table 1 the index statistics for Natural Questions. As can be seen, SEAL’s FM-index is more than 7 times lighter compared to DPR’s full document embeddings for exact inner product search, and needs neither a GPU for search on top of that, nor separate storage for the text itself. While vector compression methods can reduce dense retrievers’ index size, this still comes at the expense of performance [Yamada et al., 2021, Lewis et al., 2021a]. In addition, our the size of our index is less than $50 \%$ of that of the well-optimized Lucene BM25 index used by pyserini, but also roughly $65 \%$ of the uncompressed plain text itself.
|
| 111 |
+
|
| 112 |
+
# 5.3 Retriever Baselines
|
| 113 |
+
|
| 114 |
+
We compare SEAL against well-established systems in the literature on each benchmark. On NQ and $\mathrm { N Q } 3 2 0 k$ we also compare against our BART-based replication of DSI [Tay et al., 2022, DSI-BART].2 On $\mathrm { N Q } 3 2 0 \mathrm { k }$ , a page-level benchmark, we include our own replication of GENRE [De Cao et al., 2021b]. Unless otherwise specified, we use pyserini to compute the BM25 baseline. For other systems, we either take figures from the literature, or use publicly released model predictions.
|
| 115 |
+
|
| 116 |
+
Table 2: Results on $\mathrm { N Q } 3 2 0 k$ . Reporting hits $@ 1$ and hits@10. Best in bold.
|
| 117 |
+
|
| 118 |
+
<table><tr><td>System</td><td>hits@k 1</td><td>10</td></tr><tr><td>BM25 (gensim) BM25 DSI-BART GENRE</td><td>15.3 22.7 25.0 26.3</td><td>44.5 59.0 63.6 71.2</td></tr><tr><td>SEAL (LM, |n| = 3) SEAL (LM, |n| = 4) SEAL (LM, In| = 5) SEAL (LM+FM) SEAL (LM+FM, intersect.)</td><td>21.3 22.2 22.6 25.3 26.3</td><td>66.5 68.2 68.7 72.0 74.5</td></tr></table>
|
| 119 |
+
|
| 120 |
+
Table 3: Retrieval results on the NQ test set. Column blocks (left to right): retrieval results (accuracy $\textcircled { a } 5 / 2 0 / 1 0 0 )$ ; retrieval results on the test splits of Lewis et al. [2021b], partitioned according to whether the query/answer is a paraphrase of one in the training set; downstream performances (exact match). Except for Izacard and Grave [2021], all downstream results are computed with the same FiD reader trained on DPR predictions. Best in bold.
|
| 121 |
+
|
| 122 |
+
<table><tr><td rowspan="2">System</td><td colspan="3"> accuracy@k</td><td colspan="4">Overlap? (A@100)</td><td rowspan="2">EM</td></tr><tr><td>5</td><td>20</td><td>100</td><td>ans.</td><td>X</td><td>ques.</td><td>X</td></tr><tr><td>BM25</td><td>43.6</td><td>62.9</td><td>78.1</td><td>82.9</td><td>70.1</td><td>80.9</td><td>76.6</td><td>40.4</td></tr><tr><td>DPR [Karpukhin et al.,2020]</td><td>68.3</td><td>80.1</td><td>86.1</td><td>91.4</td><td>76.8</td><td>93.2</td><td>83.2</td><td>47.2</td></tr><tr><td>GAR [Mao et al.,2021]</td><td>59.3</td><td>73.9</td><td>85.0</td><td>91.6</td><td>74.4</td><td>94.1</td><td>80.4</td><td>46.2</td></tr><tr><td>DSI-BART</td><td>28.3</td><td>47.3</td><td>65.5</td><td>77.8</td><td>44.2</td><td>84.9</td><td>57.7</td><td>31.4</td></tr><tr><td>Izacard and Grave [2021]</td><td>1</td><td>-</td><td>-</td><td>-</td><td>-</td><td>1</td><td>1</td><td>48.2</td></tr><tr><td>SEAL (LM, |n| = 5)</td><td>40.5</td><td>60.2</td><td>73.1</td><td>82.2</td><td>57.1</td><td>85.2</td><td>64.9</td><td>36.0</td></tr><tr><td>SEAL (LM+FM)</td><td>43.9</td><td>65.8</td><td>81.1</td><td>86.9</td><td>70.9</td><td>89.5</td><td>78.1</td><td>42.9</td></tr><tr><td>SEAL (LM+FM, intersective)</td><td>61.3</td><td>76.2</td><td>86.3</td><td>91.2</td><td>77.7</td><td>93.2</td><td>84.1</td><td>48.0</td></tr></table>
|
| 123 |
+
|
| 124 |
+
# 5.4 Reader
|
| 125 |
+
|
| 126 |
+
For downstream results, we use the Fusion-in-Decoder abstractive reader [Izacard and Grave, 2021], which takes in the query along with 100 contexts and produces a task-specific answer. We train FiD on training set predictions.
|
| 127 |
+
|
| 128 |
+
# 6 Results
|
| 129 |
+
|
| 130 |
+
$\mathbf { N Q } 3 2 \mathbf { 0 } k$ We report results on $\mathrm { N Q } 3 2 0 k$ in Table 2. SEAL outperforms BM25 and DSI-BART in hits $@ 1 0$ in all its formulations. When taking into account ngram frequencies (i.e., $\mathbf { L M } { \mathbf { + F M } } )$ , SEAL achieves even higher results than GENRE, despite the fact that this benchmark only requires page-level retrieval capabilities (that is the focus of GENRE). Finally, our intersective formulation achieves the highest results, both in hits $@ 1$ and $@ 1 0$ , indicating that multiple ngrams identifiers might capture complementary information, which can be aggregated for stronger performances.
|
| 131 |
+
|
| 132 |
+
Natural Questions We report in Table 3 the results of our evaluation on Natural Questions, a passage-level retrieval benchmark with a larger collection of documents (i.e., $\mathrm { \sim } 2 1 \mathbf { M }$ w.r.t. 200k in $\mathrm { N Q } 3 2 0 k )$ ). In this setting, the gap in performance between DSI-BART and SEAL is larger, possibly because memorizing documents identifiers in the parameters of the model becomes more challenging with larger corpora. Remarkably, the intersective formulation of SEAL achieves results comparable or superior to more established retrieval paradigms (e.g., BM25, DPR and GAR), at high-recall (accuracy $@ 1 0 0 _ { , }$ ). To better understand the generalization capabilities of our retrieval solution we use the question/answer overlap split of Lewis et al. [2021b]. This study reveals that SEAL achieves the highest performance for question/answer pairs never seen during training (i.e., no overlap), suggesting a better ability to generalize to completely novel questions with novel answers (e.g., 3.5 points better than GAR on average).
|
| 133 |
+
|
| 134 |
+
Table 4: Retrieval results on individual KILT dev set(s), with the average in the rightmost column. Reporting passage-level R-precision (higher is better). We mark model that are also trained on additional synthetic data [Lewis et al., 2021c] with $\dagger$ . All SEAL models are multitask. Best among models trained only on KILT queries in bold.
|
| 135 |
+
|
| 136 |
+
<table><tr><td>Model</td><td>FEV</td><td>T-REx</td><td>zsRE</td><td>NQ</td><td>HoPo</td><td>TQA</td><td>WoW</td><td>AVG</td></tr><tr><td>BM25</td><td>40.1</td><td>51.6</td><td>53.0</td><td>14.2</td><td>38.4</td><td>16.2</td><td>18.4</td><td>33.1</td></tr><tr><td>DPR Maillard et al. [2021]</td><td>43.9</td><td>58.5</td><td>78.8</td><td>28.1</td><td>43.5</td><td>23.8</td><td>20.7</td><td>42.5</td></tr><tr><td>MT-DPR [Maillard et al., 2021]</td><td>52.1</td><td>53.5</td><td>41.7</td><td>28.8</td><td>38.4</td><td>34.2</td><td>24.1</td><td>39.0</td></tr><tr><td>MT-DPR [Oguz et al., 2021]</td><td>52.1</td><td>61.4</td><td>54.1</td><td>40.1</td><td>41.0</td><td>34.2</td><td>24.6</td><td>43.9</td></tr><tr><td>MT-DPRt [Oguz et al., 2021]</td><td>61.4</td><td>68.4</td><td>73.3</td><td>44.1</td><td>44.6</td><td>38.9</td><td>26.5</td><td>51.0</td></tr><tr><td>MT-DPRt (large) [Oguz et al., 2021]</td><td>62.8</td><td>66.6</td><td>66.9</td><td>42.6</td><td>42.1</td><td>37.9</td><td>23.4</td><td>48.9</td></tr><tr><td>SEAL (LM+FM)</td><td>31.5</td><td>42.0</td><td>34.0</td><td>21.7</td><td>24.7</td><td>21.4</td><td>17.6</td><td>27.6</td></tr><tr><td>SEAL (LM+FM, intersective)</td><td>67.8</td><td>58.9</td><td>78.8</td><td>43.6</td><td>54.3</td><td>41.8</td><td>36.0</td><td>54.5</td></tr></table>
|
| 137 |
+
|
| 138 |
+
Table 5: Downstream results on the KILT test set(s). Downstream metrics are accuracy (FEVER, T-REx, zero-shot RE), exact match (Natural Questions, HotpotQA, TriviaQA), or F1 (Wizard of Wikipedia). Best in bold. †: result taken from the eval.ai KILT leaderboard.
|
| 139 |
+
|
| 140 |
+
<table><tr><td>System</td><td>FEV ACC</td><td>T-REx ACC</td><td>zsRE ACC</td><td>NQ EM</td><td>HoPo EM</td><td>TQA EM</td><td>WoW F1</td></tr><tr><td>KGI [Glass et al., 2021]+</td><td>85.6</td><td>84.4</td><td>72.6</td><td>45.2</td><td>-</td><td>61.0</td><td>18.6</td></tr><tr><td>Hindsight [Paranjape et al., 2021]</td><td>1</td><td>-</td><td>-</td><td>-</td><td>1</td><td>-</td><td>19.2</td></tr><tr><td>DPR+BART [Petroni et al.,2021]</td><td>86.7</td><td>59.2</td><td>30.4</td><td>41.3</td><td>25.2</td><td>58.6</td><td>15.2</td></tr><tr><td>RAG [Petroni et al.,2021]</td><td>86.3</td><td>59.2</td><td>44.7</td><td>44.4</td><td>27.0</td><td>71.3</td><td>13.1</td></tr><tr><td>MT-DPR+BART [Maillard et al., 2021]</td><td>86.3</td><td>1</td><td>58.0</td><td>39.8</td><td>31.8</td><td>59.6</td><td>15.3</td></tr><tr><td>MT-DPR+FiD [Piktus et al., 2021]</td><td>89.0</td><td>82.5</td><td>71.7</td><td>49.9</td><td>36.9</td><td>71.0</td><td>15.7</td></tr><tr><td>MT-DPR-WEB+FiD [Piktus et al.,2021]</td><td>89.0</td><td>81.7</td><td>74.2</td><td>51.6</td><td>38.3</td><td>72.7</td><td>15.5</td></tr><tr><td>SEAL+FiD (LM+FM)</td><td>87.9</td><td>83.7</td><td>74.2</td><td>47.3</td><td>37.6</td><td>65.8</td><td>17.5</td></tr><tr><td>SEAL+FiD (LM+FM, intersective)</td><td>89.5</td><td>83.6</td><td>74.7</td><td>53.7</td><td>40.5</td><td>70.9</td><td>18.3</td></tr></table>
|
| 141 |
+
|
| 142 |
+
Table 6: Retrieval results on the NQ test set with different model sizes. DPR (large) performance from [Oguz et al., 2021]. ˘
|
| 143 |
+
|
| 144 |
+
<table><tr><td> System</td><td>#Par.</td><td>A@20</td><td>A@100</td></tr><tr><td>DPR (base)</td><td>~220M</td><td>80.1</td><td>86.1</td></tr><tr><td>DPR (large)</td><td>~350M</td><td>80.2</td><td>86.7</td></tr><tr><td>SEAL (large)</td><td>~400M</td><td>76.2</td><td>86.3</td></tr></table>
|
| 145 |
+
|
| 146 |
+
KILT We report retrieval results at passage level on the KILT benchmark in Table 4.3 SEAL outperforms DPR by more than 10 points on average in passage-level R-precision, indicating that our method is more precise in surfacing ground truth evidence as the first result. Moreover, SEAL also performs better than MT-DPR (multi-task DPR) even when the latter is pretrained on tens of millions of questions from PAQ [Lewis et al., 2021c], a technique that can drastically improve results and that could potentially bring benefits to our method as well (a task we leave for future work). When it comes to downstream performances (Table 5), FiD with passages retrieved by intersective SEAL establishes a new state-of-the-art on 4 datasets out of 7 (FEVER, zsRE, NQ, HoPo), and achieves very competitive results on the remaining 3.
|
| 147 |
+
|
| 148 |
+
Speed and constrained decoding The inference speed of SEAL is directly proportional to the beam size, with a limited overhead added by constrained decoding. On the Natural Questions test set, for instance, retrieval with the intersective scoring requires on our 1 GPU evaluation setup ${ \sim } 1 6$ minutes and ${ \sim } 3 5$ minutes with, respectively, a beam size of 5 or 15. Mao et al. [2021] report a lower runtime for GAR ${ \sim } 5$ minutes), and a comparable one for DPR (\~30 minutes). Note that more efficient approaches to constrained decoding have been proposed (e.g., De Cao et al. [2021a])
|
| 149 |
+
|
| 150 |
+
Table 7: Ablation on Natural Questions. SEAL when using $( \checkmark )$ or not using $( { \pmb x } )$ FM-index constrained decoding, for beam size values in $\{ 3 , 5 , 1 0 , 1 5 \}$ . Reporting accuracy $@ k$ .
|
| 151 |
+
|
| 152 |
+
<table><tr><td>System</td><td>Constr.</td><td>Beam</td><td>A@20</td><td>A@100</td></tr><tr><td>SEAL</td><td>√</td><td>15</td><td>65.8</td><td>81.1</td></tr><tr><td>(LM+FM)</td><td>×</td><td>15</td><td>65.3</td><td>80.1</td></tr><tr><td></td><td>√</td><td>3</td><td>63.3</td><td>78.0</td></tr><tr><td></td><td>√</td><td>5</td><td>64.7</td><td>79.9</td></tr><tr><td></td><td>√</td><td>10</td><td>65.4</td><td>80.8</td></tr><tr><td>SEAL</td><td>√</td><td>15</td><td>76.2</td><td>86.3</td></tr><tr><td>(LM+FM,</td><td>X</td><td>15</td><td>76.2</td><td>86.2</td></tr><tr><td>intersective)</td><td></td><td>3</td><td>75.2</td><td>84.9</td></tr><tr><td></td><td>·</td><td>5</td><td>75.9</td><td>85.8</td></tr><tr><td></td><td></td><td>10</td><td>76.4</td><td>86.4</td></tr></table>
|
| 153 |
+
|
| 154 |
+
Table 8: Performance on Natural Questions with different max ngrams sizes, using SEAL $\mathrm { ( L M + F M }$ , intersective).
|
| 155 |
+
|
| 156 |
+
<table><tr><td>Length</td><td>A@20</td><td>A@100</td></tr><tr><td>3</td><td>64.7</td><td>74.8</td></tr><tr><td>5</td><td>73.6</td><td>83.7</td></tr><tr><td>10</td><td>76.2</td><td>86.3</td></tr></table>
|
| 157 |
+
|
| 158 |
+
and we leave their application to SEAL as future work. Moreover, generation is becoming the de facto standard approach to NLP, not just as the method for materializing final outputs, but also for modeling the computational process needed before computing the answer [Wei et al., 2022]. As such, we expect generation latency will improve significantly and increasingly over time as a result of this growing interest. Any improvement will be directly applicable to SEAL.
|
| 159 |
+
|
| 160 |
+
Model size In Table 4 we show that parameter size is not a crucial factor behind the good performance of the method that we propose: SEAL (\~400M) outperforms all model from Oguz et al. ˘ [2021], including the MT-DPR large model (\~350M) trained on NQ and PAQ [Lewis et al., 2021c]. In fact, the results of MT-DPR are lower with a bigger backbone—which could point to an increased difficulty in training larger models for dense retrieval. In the same direction, on vanilla NQ (Table 6), where DPR large only slightly outperforms DPR base, the performance of SEAL is in the same ballpark.
|
| 161 |
+
|
| 162 |
+
Ablation studies In Table 7 we report results on NQ for various configurations of SEAL. While, in general, performances increase with a larger beam, diminishing returns (or even a performance decrease) are found between a value of 10 and 15. Disabling constrained decoding and discarding a posteriori all generated ngrams that don’t appear in the corpus results in slightly lower performances. We have found the decoding maximum length to have a crucial impact on the retrieval performance of SEAL, since shorter ngrams tend to be less informative than longer ones. We report in Table 8 performances on the NQ test set when using, respectivaly, 3, 5, and 10 as ngram maximum length. Every other SEAL figure reported in this paper uses 10.
|
| 163 |
+
|
| 164 |
+
Qualitative Analysis In Table 9, we show examples of ngrams predicted by SEAL (trained on KILT) given the query “can you predict earthquakes”. SEAL is able to rephrase the query in ways that preserve its lexical material producing ngrams such as earthquakes can be predicted, used to predict earthquakes etc. Morevoer, the model is also able to explore more diverse regions of the output space, overcoming the vocabulary mismatch problem: ngrams contain related tokens like the subword seism- and the word forecast. SEAL’s LM+FM scoring is also able to assign a score below 0 (and, thus, exclude from the search), unrelated ngrams that are considered by the beam because of their promising start, such as “Seismic risk in Malta $@ ( a ) ^ { , }$ .
|
| 165 |
+
|
| 166 |
+
Table 9: Best (top) and worst (bottom) generated keys for the query “can you predict earthquakes” (left), and retrieved documents (right). Matched ngrams in bold. “ $@ @ \left( { \overrightarrow { a } } \right) ^ { \bullet }$ separates title and body.
|
| 167 |
+
|
| 168 |
+
<table><tr><td>score</td><td>#</td><td>identifier</td><td>doc #1</td><td>doc #2</td></tr><tr><td>273.2</td><td>1</td><td>earthquakes can be predicted</td><td></td><td>Seismology @@ for precise earth- Earthquake prediction @ @ reliably</td></tr><tr><td>272.7</td><td>75</td><td>Earthquake prediction @ @</td><td>quake predictions,including the</td><td>identified across significant spatial</td></tr><tr><td>269.9</td><td>3</td><td>predicted earthquakes</td><td>VAN method.Most seismologists</td><td>and temporal scales.While part of the</td></tr><tr><td>229.7</td><td>11</td><td>Earthquake forecasting @@</td><td>do not believe that a system to pro-</td><td>scientific community hold that, taking</td></tr><tr><td>217.2</td><td>2</td><td>prediction Earthquake</td><td>vide timely warnings for individual</td><td>into account non-seismic precursors</td></tr><tr><td>211.5</td><td>1</td><td>used to predict earthquakes</td><td>earthquakes has yet been developed,</td><td>and given enough resources to study</td></tr><tr><td>205.3</td><td>7</td><td>earthquakes.Earthquake</td><td>and many believe that such a sys-</td><td>them extensively,prediction might</td></tr><tr><td></td><td>一</td><td></td><td>tem would be unlikely to give useful</td><td>be possible,most scientists are pes-</td></tr><tr><td>-77.0</td><td>9</td><td>Seismic metamaterial @@</td><td>warning of impending seismic events.</td><td>simistic and some maintain that earth-</td></tr><tr><td>-97.4 -113.4</td><td>14</td><td>Seismic risk in Malta @@</td><td>However,more general forecasts rou-</td><td>quake prediction is inherently impos-</td></tr><tr><td>-150.3</td><td>3</td><td>Quaternary (EP) @ @</td><td>tinely predict seismic hazard. Such</td><td>sible.Predictions are deemed signif-</td></tr><tr><td>-301.5</td><td>1 17</td><td>used to predict the locatio[.]</td><td>forecasts estimate the probability of</td><td>icant if they can be shown to be suc-</td></tr><tr><td></td><td></td><td>Precipice (Battlestar Gala[.]</td><td>an earthquake of a particular [...]</td><td>cessful beyond random chance.[...]</td></tr></table>
|
| 169 |
+
|
| 170 |
+
# 7 Discussion
|
| 171 |
+
|
| 172 |
+
With SEAL we present solution that could potentially find applications outside information retrieval (e.g., enforce generated substrings come from a white list of trusted sources). While we conduct our experiments with a model of $\mathord { \sim } 4 0 0 \mathbf { M }$ parameters (i.e., BART) for fast iterations, we believe the use of larger models could considerably improve performance. Changing the model would not affect the size of the index nor the cost of using it — ${ \bar { O ( } } | n | \log | V | )$ for finding an ngram $n$ . Moreover, we believe that indexing very large corpora (e.g., the web) could be done more efficiently than existing attempts (e.g., Piktus et al. [2021]) given the light memory footprint. Finally, dynamic variants [Gerlach, 2007, Salson et al., 2009] could allow the update of the FM-index on the fly without the need of re-indexing. While out of the scope of the current paper, we plan to tackle some of these scaling challenges in future work.
|
| 173 |
+
|
| 174 |
+
# 8 Conclusion
|
| 175 |
+
|
| 176 |
+
In this paper we present SEAL, a novel retrieval system that combines an autoregressive language model with a compressed full-text substring index. Such combination allows to constrain the generation to existing ngrams in a corpus and to jointly retrieve documents containing them. Empirically, we show an improvement by more than 10 points in average passage-level R-precision on KILT, and establish new state-of-the-art downstream performance on 4 out 7 datasets when paired with a reader model. While our results show that SEAL could already compete with more established retrieval systems, we believe there is potential in exploring existing (or yet to come) larger autoregressive models.
|
| 177 |
+
|
| 178 |
+
# 9 Broader Impact
|
| 179 |
+
|
| 180 |
+
While our decoding methodology provides a way to enforce corpus-based generation constraints, this does not fully prevent the generation and retrieval of non-factual or abusive text, since the corpus itself may well contain non-factual or abusive text. Moreover, even if a given corpus is misinformative or abusive, the language model could still produce undesirable text by “misquoting” material from it, e.g., selectively copying an utterance that is being criticized in the original context of appearance. Applications should allow user to check the original supporting text. Furthermore, while we have only used a relatively small language model, scaling up the autoregressive model of SEAL would come with the same environmental risks that any other large system would pose, due to the more demanding energy requirements.
|
| 181 |
+
|
| 182 |
+
# Acknowledgments and Disclosure of Funding
|
| 183 |
+
|
| 184 |
+
We thank Aleksandra Piktus, Edoardo Barba, Niccolò Campolungo, and Pere-Lluis Huguet Cabot for their helpful comments and suggestions.
|
| 185 |
+
|
| 186 |
+
# References
|
| 187 |
+
|
| 188 |
+
Mikel Artetxe, Shruti Bhosale, Naman Goyal, Todor Mihaylov, Myle Ott, Sam Shleifer, Xi Victoria Lin, Jingfei Du, Srinivasan Iyer, Ramakanth Pasunuru, et al. Efficient large scale language modeling with mixtures of experts. CoRR, abs/2112.10684, 2021.
|
| 189 |
+
|
| 190 |
+
Yang Bai, Xiaoguang Li, Gang Wang, Chaoliang Zhang, Lifeng Shang, Jun Xu, Zhaowei Wang, Fangshan Wang, and Qun Liu. Sparterm: Learning term-based sparse representation for fast text retrieval. CoRR, abs/2010.00768, 2020. URL https://arxiv.org/abs/2010.00768.
|
| 191 |
+
|
| 192 |
+
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.
|
| 193 |
+
|
| 194 |
+
M. Burrows and D. J. Wheeler. A block-sorting lossless data compression algorithm. Technical report, 1994.
|
| 195 |
+
|
| 196 |
+
Danqi Chen, Adam Fisch, Jason Weston, and Antoine Bordes. Reading wikipedia to answer opendomain questions. CoRR, abs/1704.00051, 2017. URL http://arxiv.org/abs/1704.00051.
|
| 197 |
+
|
| 198 |
+
Zhuyun Dai and Jamie Callan. Context-aware sentence/passage term importance estimation for first stage retrieval. CoRR, abs/1910.10687, 2019. URL http://arxiv.org/abs/1910.10687.
|
| 199 |
+
|
| 200 |
+
Zhuyun Dai and Jamie Callan. Context-aware document term weighting for ad-hoc search. In Yennun Huang, Irwin King, Tie-Yan Liu, and Maarten van Steen, editors, WWW ’20: The Web Conference 2020, Taipei, Taiwan, April 20-24, 2020, pages 1897–1907. ACM / IW3C2, 2020. doi: 10.1145/3366423.3380258. URL https://doi.org/10.1145/3366423.3380258.
|
| 201 |
+
|
| 202 |
+
Nicola De Cao, Wilker Aziz, and Ivan Titov. Highly parallel autoregressive entity linking with discriminative correction. In Proceedings of the 2021 Conference on Empirical Methods in Natural Language Processing, pages 7662–7669, Online and Punta Cana, Dominican Republic, November 2021a. Association for Computational Linguistics. doi: 10.18653/v1/2021.emnlp-main.604. URL https://aclanthology.org/2021.emnlp-main.604.
|
| 203 |
+
|
| 204 |
+
Nicola De Cao, Gautier Izacard, Sebastian Riedel, and Fabio Petroni. Autoregressive entity retrieval. In 9th International Conference on Learning Representations, ICLR 2021, Virtual Event, Austria, May 3-7, 2021. OpenReview.net, 2021b. URL https://openreview.net/forum?id= 5k8F6UU39V.
|
| 205 |
+
|
| 206 |
+
Emily Dinan, Stephen Roller, Kurt Shuster, Angela Fan, Michael Auli, and Jason Weston. Wizard of wikipedia: Knowledge-powered conversational agents. Proceedings of the International Conference on Learning Representations (ICLR), 2019.
|
| 207 |
+
|
| 208 |
+
Hady Elsahar, Pavlos Vougiouklis, Arslen Remaci, Christophe Gravier, Jonathon Hare, Elena Simperl, and Frederique Laforest. T-rex: A large scale alignment of natural language with knowledge base triples. LREC, 2018.
|
| 209 |
+
|
| 210 |
+
P. Ferragina and G. Manzini. Opportunistic data structures with applications. In Proceedings 41st Annual Symposium on Foundations of Computer Science, pages 390–398, 2000. doi: 10.1109/ SFCS.2000.892127.
|
| 211 |
+
|
| 212 |
+
Thibault Formal, Carlos Lassance, Benjamin Piwowarski, and Stéphane Clinchant. SPLADE v2: Sparse lexical and expansion model for information retrieval. CoRR, abs/2109.10086, 2021a. URL https://arxiv.org/abs/2109.10086.
|
| 213 |
+
|
| 214 |
+
Thibault Formal, Benjamin Piwowarski, and Stéphane Clinchant. SPLADE: sparse lexical and expansion model for first stage ranking. In Fernando Diaz, Chirag Shah, Torsten Suel, Pablo Castells, Rosie Jones, and Tetsuya Sakai, editors, SIGIR ’21: The 44th International ACM SIGIR Conference on Research and Development in Information Retrieval, Virtual Event, Canada, July 11-15, 2021, pages 2288–2292. ACM, 2021b. doi: 10.1145/3404835.3463098. URL https: //doi.org/10.1145/3404835.3463098.
|
| 215 |
+
|
| 216 |
+
Luyu Gao, Zhuyun Dai, and Jamie Callan. COIL: Revisit exact lexical match in information retrieval with contextualized inverted list. In Proceedings of the 2021 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, pages 3030–3042, Online, June 2021. Association for Computational Linguistics. doi: 10.18653/v1/ 2021.naacl-main.241. URL https://aclanthology.org/2021.naacl-main.241.
|
| 217 |
+
|
| 218 |
+
Wolfgang Gerlach. Dynamic fm-index for a collection of texts with application to space-efficient construction of the compressed suffix array diplomarbeit im fach. Master’s thesis, University of Bielefeld, 2007.
|
| 219 |
+
|
| 220 |
+
Michael Glass, Gaetano Rossiello, Md Faisal Mahbub Chowdhury, and Alfio Gliozzo. Robust retrieval augmented generation for zero-shot slot filling. In Proceedings of the 2021 Conference on Empirical Methods in Natural Language Processing, pages 1939–1949, Online and Punta Cana, Dominican Republic, November 2021. Association for Computational Linguistics. doi: 10.18653/ v1/2021.emnlp-main.148. URL https://aclanthology.org/2021.emnlp-main.148.
|
| 221 |
+
|
| 222 |
+
Roberto Grossi, Ankur Gupta, and Jeffrey Scott Vitter. High-order entropy-compressed text indexes. In Proceedings of the Fourteenth Annual ACM-SIAM Symposium on Discrete Algorithms, SODA ’03, page 841–850, USA, 2003. Society for Industrial and Applied Mathematics. ISBN 0898715385.
|
| 223 |
+
|
| 224 |
+
Gautier Izacard and Edouard Grave. Leveraging passage retrieval with generative models for open domain question answering. In Proceedings of the 16th Conference of the European Chapter of the Association for Computational Linguistics: Main Volume, pages 874–880, Online, April 2021. Association for Computational Linguistics. doi: 10.18653/v1/2021.eacl-main.74. URL https://aclanthology.org/2021.eacl-main.74.
|
| 225 |
+
|
| 226 |
+
Ziwei Ji, Nayeon Lee, Rita Frieske, Tiezheng Yu, Dan Su, Yan Xu, Etsuko Ishii, Yejin Bang, Andrea Madotto, and Pascale Fung. Survey of hallucination in natural language generation. CoRR, abs/2202.03629, 2022.
|
| 227 |
+
|
| 228 |
+
Mandar Joshi, Eunsol Choi, Daniel Weld, and Luke Zettlemoyer. TriviaQA: A large scale distantly supervised challenge dataset for reading comprehension. In Proceedings of the 55th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pages 1601– 1611, Vancouver, Canada, July 2017. Association for Computational Linguistics. doi: 10.18653/ v1/P17-1147. URL https://www.aclweb.org/anthology/P17-1147.
|
| 229 |
+
|
| 230 |
+
Vladimir Karpukhin, Barlas Oguz, Sewon Min, Patrick Lewis, Ledell Wu, Sergey Edunov, Danqi Chen, and Wen-tau Yih. Dense passage retrieval for open-domain question answering. In Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing (EMNLP), pages 6769–6781, Online, November 2020. Association for Computational Linguistics. doi: 10. 18653/v1/2020.emnlp-main.550. URL https://aclanthology.org/2020.emnlp-main.550.
|
| 231 |
+
|
| 232 |
+
Diederik P. Kingma and Jimmy Ba. Adam: A method for stochastic optimization. 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/1412.6980.
|
| 233 |
+
|
| 234 |
+
Mojtaba Komeili, Kurt Shuster, and Jason Weston. Internet-augmented dialogue generation. CoRR, abs/2107.07566, 2021.
|
| 235 |
+
|
| 236 |
+
Tom Kwiatkowski, Jennimaria Palomaki, Olivia Redfield, Michael Collins, Ankur Parikh, Chris Alberti, Danielle Epstein, Illia Polosukhin, Jacob Devlin, Kenton Lee, Kristina Toutanova, Llion Jones, Matthew Kelcey, Ming-Wei Chang, Andrew M. Dai, Jakob Uszkoreit, Quoc Le, and Slav Petrov. Natural questions: A benchmark for question answering research. Transactions of the Association for Computational Linguistics, 7:452–466, 2019. doi: 10.1162/tacl_a_00276. URL https://aclanthology.org/Q19-1026.
|
| 237 |
+
|
| 238 |
+
Julian Labeit, Julian Shun, and Guy E. Blelloch. Parallel lightweight wavelet tree, suffix array and fm-index construction. Journal of Discrete Algorithms, 43:2–17, 2017. ISSN 1570-8667. doi: https://doi.org/10.1016/j.jda.2017.04.001. URL https://www.sciencedirect.com/science/ article/pii/S1570866717300205.
|
| 239 |
+
|
| 240 |
+
Angeliki Lazaridou, Elena Gribovskaya, Wojciech Stokowiec, and Nikolai Grigorev. Internetaugmented language models through few-shot prompting for open-domain question answering. CoRR, abs/2203.05115, 2022.
|
| 241 |
+
|
| 242 |
+
Jinhyuk Lee, Mujeen Sung, Jaewoo Kang, and Danqi Chen. Learning dense representations of phrases at scale. 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 6634–6647, Online, August 2021a. Association for Computational Linguistics. doi: 10.18653/v1/2021.acl-long.518. URL https://aclanthology.org/2021.acl-long. 518.
|
| 243 |
+
|
| 244 |
+
Jinhyuk Lee, Alexander Wettig, and Danqi Chen. Phrase retrieval learns passage retrieval, too. In Proceedings of the 2021 Conference on Empirical Methods in Natural Language Processing, pages 3661–3672, Online and Punta Cana, Dominican Republic, November 2021b. Association for Computational Linguistics. doi: 10.18653/v1/2021.emnlp-main.297. URL https://aclanthology.org/2021.emnlp-main.297.
|
| 245 |
+
|
| 246 |
+
Oleg Lesota, Navid Rekabsaz, Daniel Cohen, Klaus Antonius Grasserbauer, Carsten Eickhoff, and Markus Schedl. A modern perspective on query likelihood with deep generative retrieval models. In Faegheh Hasibi, Yi Fang, and Akiko Aizawa, editors, ICTIR ’21: The 2021 ACM SIGIR International Conference on the Theory of Information Retrieval, Virtual Event, Canada, July 11, 2021, pages 185–195. ACM, 2021. doi: 10.1145/3471158.3472229. URL https: //doi.org/10.1145/3471158.3472229.
|
| 247 |
+
|
| 248 |
+
Omer Levy, Minjoon Seo, Eunsol Choi, and Luke Zettlemoyer. Zero-shot relation extraction via reading comprehension. CoNLL, 2017.
|
| 249 |
+
|
| 250 |
+
Mike Lewis, Yinhan Liu, Naman Goyal, Marjan Ghazvininejad, Abdelrahman Mohamed, Omer Levy, Ves Stoyanov, and Luke Zettlemoyer. Bart: Denoising sequence-to-sequence pre-training for natural language generation, translation, and comprehension. CoRR, abs/1910.13461, 2019.
|
| 251 |
+
|
| 252 |
+
Patrick Lewis, Ethan Perez, Aleksandara Piktus, Fabio Petroni, Vladimir Karpukhin, Naman Goyal, Heinrich Küttler, Mike Lewis, Wen tau Yih, Tim Rocktäschel, Sebastian Riedel, and Douwe Kiela. Retrieval-augmented generation for knowledge-intensive nlp tasks, 2020.
|
| 253 |
+
|
| 254 |
+
Patrick Lewis, Barlas Oguz, Wenhan Xiong, Fabio Petroni, Wen tau Yih, and Sebastian Riedel.˘ Boosted dense retriever. CoRR, abs/2112.07771, 2021a.
|
| 255 |
+
|
| 256 |
+
Patrick Lewis, Pontus Stenetorp, and Sebastian Riedel. Question and answer test-train overlap in open-domain question answering datasets. In Proceedings of the 16th Conference of the European Chapter of the Association for Computational Linguistics: Main Volume, pages 1000–1008, Online, April 2021b. Association for Computational Linguistics. doi: 10.18653/v1/2021.eacl-main.86. URL https://aclanthology.org/2021.eacl-main.86.
|
| 257 |
+
|
| 258 |
+
Patrick Lewis, Yuxiang Wu, Linqing Liu, Pasquale Minervini, Heinrich Küttler, Aleksandra Piktus, Pontus Stenetorp, and Sebastian Riedel. PAQ: 65 million probably-asked questions and what you can do with them. Transactions of the Association for Computational Linguistics, 9:1098–1115, 2021c. doi: 10.1162/tacl_a_00415. URL https://aclanthology.org/2021.tacl-1.65.
|
| 259 |
+
|
| 260 |
+
Jimmy Lin and Xueguang Ma. A few brief notes on deepimpact, coil, and a conceptual framework for information retrieval techniques. CoRR, abs/2106.14807, 2021. URL https://arxiv.org/ abs/2106.14807.
|
| 261 |
+
|
| 262 |
+
Jean Maillard, Vladimir Karpukhin, Fabio Petroni, Wen-tau Yih, Barlas Oguz, Veselin Stoyanov, and Gargi Ghosh. Multi-task retrieval for knowledge-intensive tasks. 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 1098–1111, Online, August 2021. Association for Computational Linguistics. doi: 10.18653/v1/2021.acl-long.89. URL https://aclanthology.org/2021.acl-long.89.
|
| 263 |
+
|
| 264 |
+
Antonio Mallia, Omar Khattab, Torsten Suel, and Nicola Tonellotto. Learning passage impacts for inverted indexes. In Fernando Diaz, Chirag Shah, Torsten Suel, Pablo Castells, Rosie Jones, and Tetsuya Sakai, editors, SIGIR ’21: The 44th International ACM SIGIR Conference on Research and
|
| 265 |
+
|
| 266 |
+
Development in Information Retrieval, Virtual Event, Canada, July 11-15, 2021, pages 1723–1727.
|
| 267 |
+
ACM, 2021. doi: 10.1145/3404835.3463030. URL https://doi.org/10.1145/3404835.
|
| 268 |
+
3463030.
|
| 269 |
+
|
| 270 |
+
Yuning Mao, Pengcheng He, Xiaodong Liu, Yelong Shen, Jianfeng Gao, Jiawei Han, and Weizhu Chen. Generation-augmented retrieval for open-domain question answering. 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 4089–4100, Online, August 2021. Association for Computational Linguistics. doi: 10.18653/v1/2021.acl-long. 316. URL https://aclanthology.org/2021.acl-long.316.
|
| 271 |
+
|
| 272 |
+
Luca Massarelli, Fabio Petroni, Aleksandra Piktus, Myle Ott, Tim Rocktäschel, Vassilis Plachouras, Fabrizio Silvestri, and Sebastian Riedel. How decoding strategies affect the verifiability of generated text. CoRR, abs/1911.03587, 2019.
|
| 273 |
+
|
| 274 |
+
Donald Metzler, Yi Tay, Dara Bahri, and Marc Najork. Rethinking search: Making domain experts out of dilettantes. SIGIR Forum, 55(1), jul 2021. ISSN 0163-5840. doi: 10.1145/3476415.3476428. URL https://doi.org/10.1145/3476415.3476428.
|
| 275 |
+
|
| 276 |
+
Reiichiro Nakano, Jacob Hilton, S. Arun 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.
|
| 277 |
+
|
| 278 |
+
Rodrigo Nogueira and Jimmy Lin. From doc2query to doctttttquery. 2021. URL https://cs. uwaterloo.ca/\~jimmylin/publications/Nogueira_Lin_2019_docTTTTTquery.pdf.
|
| 279 |
+
|
| 280 |
+
Rodrigo Nogueira, Wei Yang, Jimmy Lin, and Kyunghyun Cho. Document expansion by query prediction. CoRR, abs/1904.08375, 2019. URL http://arxiv.org/abs/1904.08375.
|
| 281 |
+
|
| 282 |
+
Cicero Nogueira dos Santos, Xiaofei Ma, Ramesh Nallapati, Zhiheng Huang, and Bing Xiang. Beyond [CLS] through ranking by generation. In Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing (EMNLP), pages 1722–1727, Online, November 2020. Association for Computational Linguistics. doi: 10.18653/v1/2020.emnlp-main.134. URL https: //aclanthology.org/2020.emnlp-main.134.
|
| 283 |
+
|
| 284 |
+
Barlas Oguz, Kushal Lakhotia, Anchit Gupta, Patrick Lewis, Vladimir Karpukhin, Aleksandra Piktus, ˘ Xilun Chen, Sebastian Riedel, Wen tau Yih, Sonal Gupta, and Yashar Mehdad. Domain-matched pre-training tasks for dense retrieval. CoRR, abs/2107.13602, 2021.
|
| 285 |
+
|
| 286 |
+
Ashwin Paranjape, Omar Khattab, Christopher Potts, Matei Zaharia, and Christopher D. Manning. Hindsight: Posterior-guided training of retrievers for improved open-ended generation. CoRR, abs/2110.07752, 2021. URL https://arxiv.org/abs/2110.07752.
|
| 287 |
+
|
| 288 |
+
Fabio Petroni, Tim Rocktäschel, Patrick Lewis, Anton Bakhtin, Yuxiang Wu, Alexander H Miller, and Sebastian Riedel. Language models as knowledge bases? EMNLP, 2019.
|
| 289 |
+
|
| 290 |
+
Fabio Petroni, Patrick Lewis, Aleksandra Piktus, Tim Rocktäschel, Yuxiang Wu, Alexander H Miller, and Sebastian Riedel. How context affects language models’ factual predictions. AKBC, 2020.
|
| 291 |
+
|
| 292 |
+
Fabio Petroni, Aleksandra Piktus, Angela Fan, Patrick Lewis, Majid Yazdani, Nicola De Cao, James Thorne, Yacine Jernite, Vladimir Karpukhin, Jean Maillard, Vassilis Plachouras, Tim Rocktäschel, and Sebastian Riedel. KILT: a benchmark for knowledge intensive language tasks. In Proceedings of the 2021 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, pages 2523–2544, Online, June 2021. Association for Computational Linguistics. doi: 10.18653/v1/2021.naacl-main.200. URL https://aclanthology.org/2021.naacl-main.200.
|
| 293 |
+
|
| 294 |
+
Aleksandra Piktus, Fabio Petroni, Vladimir Karpukhin, Dmytro Okhonko, Samuel Broscheit, Gautier Izacard, Patrick Lewis, Barlas Oguz, Edouard Grave, Wen-tau Yih, and Sebastian Riedel. The web is your oyster - knowledge-intensive NLP against a very large web corpus. CoRR, abs/2112.09924, 2021. URL https://arxiv.org/abs/2112.09924.
|
| 295 |
+
|
| 296 |
+
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.
|
| 297 |
+
|
| 298 |
+
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. CoRR, abs/2112.11446, 2021.
|
| 299 |
+
|
| 300 |
+
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. CoRR, abs/1910.10683, 2019.
|
| 301 |
+
|
| 302 |
+
Adam Roberts, Colin Raffel, and Noam Shazeer. How much knowledge can you pack into the parameters of a language model? CoRR, abs/2002.08910, 2020.
|
| 303 |
+
|
| 304 |
+
Stephen E. Robertson and Hugo Zaragoza. The probabilistic relevance framework: BM25 and beyond. Found. Trends Inf. Retr., 3(4):333–389, 2009. doi: 10.1561/1500000019. URL https: //doi.org/10.1561/1500000019.
|
| 305 |
+
|
| 306 |
+
Devendra Singh Sachan, Mike Lewis, Mandar Joshi, Armen Aghajanyan, Wen tau Yih, Joelle Pineau, and Luke Zettlemoyer. Improving passage retrieval with zero-shot question generation. CoRR, abs/2204.07496, 2022. URL https://arxiv.org/abs/2204.07496.
|
| 307 |
+
|
| 308 |
+
M. Salson, T. Lecroq, M. Léonard, and L. Mouchard. A four-stage algorithm for updating a BurrowsWheeler Transform. Theoretical Computer Science, 410(43):4350–4359, 2009. doi: 10.1016/j. tcs.2009.07.016. URL articles/Final_Version_LaurentMouchard_TCS_SpecialIssue_ MaximeCrochemore.pdf.
|
| 309 |
+
|
| 310 |
+
Kurt Shuster, Mojtaba Komeili, Leonard Adolphs, Stephen Roller, Arthur D. Szlam, and Jason Weston. Language models that seek for knowledge: Modular search & generation for dialogue and prompt completion. CoRR, abs/2203.13224, 2022.
|
| 311 |
+
|
| 312 |
+
Shaden Smith, Mostofa Patwary, Brandon Norick, Patrick LeGresley, Samyam Rajbhandari, Jared Casper, Zhun Liu, Shrimai Prabhumoye, George Zerveas, Vijay Korthikanti, et al. Using deepspeed and megatron to train megatron-turing nlg 530b, a large-scale generative language model. abs/2201.11990, CoRR, 2022.
|
| 313 |
+
|
| 314 |
+
Yi Tay, Vinh Quang Tran, Mostafa Dehghani, Jianmo Ni, Dara Bahri, Harsh Mehta, Zhen Qin, Kai Hui, Zhe Zhao, Jai Gupta, Tal Schuster, William W. Cohen, and Donald Metzler. Transformer memory as a differentiable search index. CoRR, abs/2202.06991, 2022.
|
| 315 |
+
|
| 316 |
+
James Thorne, Andreas Vlachos, Christos Christodoulopoulos, and Arpit Mittal. FEVER: a largescale dataset for fact extraction and verification. In NAACL-HLT, 2018.
|
| 317 |
+
|
| 318 |
+
Ellen M Voorhees et al. The trec-8 question answering track report. In Trec, volume 99, pages 77–82, 1999.
|
| 319 |
+
|
| 320 |
+
Jason Wei, Xuezhi Wang, Dale Schuurmans, Maarten Bosma, Ed H. Chi, Quoc Le, and Denny Zhou. Chain of thought prompting elicits reasoning in large language models. CoRR, abs/2201.11903, 2022. URL https://arxiv.org/abs/2201.11903.
|
| 321 |
+
|
| 322 |
+
Ikuya Yamada, Akari Asai, and Hannaneh Hajishirzi. Efficient passage retrieval with hashing for open-domain question answering. 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), pages 979–986, Online, August 2021. Association for Computational Linguistics. doi: 10.18653/v1/2021.acl-short.123. URL https://aclanthology. org/2021.acl-short.123.
|
| 323 |
+
|
| 324 |
+
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. Proceedings of the 2018 Conference on Empirical Methods in Natural Language Processing, pages 2369–2380, October-November 2018. doi: 10.18653/v1/D18-1259. URL https://www.aclweb.org/anthology/D18-1259.
|
| 325 |
+
|
| 326 |
+
Tiancheng Zhao, Xiaopeng Lu, and Kyusong Lee. SPARTA: Efficient open-domain question answering via sparse transformer matching retrieval. In Proceedings of the 2021 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, pages 565–575, Online, June 2021. Association for Computational Linguistics. doi: 10.18653/v1/2021.naacl-main.47. URL https://aclanthology.org/2021.naacl-main.47.
|
| 327 |
+
|
| 328 |
+
Shengyao Zhuang and Guido Zuccon. TILDE: term independent likelihood model for passage re-ranking. In Fernando Diaz, Chirag Shah, Torsten Suel, Pablo Castells, Rosie Jones, and Tetsuya Sakai, editors, SIGIR ’21: The 44th International ACM SIGIR Conference on Research and Development in Information Retrieval, Virtual Event, Canada, July 11-15, 2021, pages 1483–1492. ACM, 2021. doi: 10.1145/3404835.3462922. URL https://doi.org/10.1145/3404835. 3462922.
|
| 329 |
+
|
| 330 |
+
# Checklist
|
| 331 |
+
|
| 332 |
+
1. For all authors...
|
| 333 |
+
|
| 334 |
+
(a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes]
|
| 335 |
+
(b) Did you describe the limitations of your work? [Yes]
|
| 336 |
+
(c) Did you discuss any potential negative societal impacts of your work? [Yes] Discussion in the Appendix (§9)
|
| 337 |
+
(d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
|
| 338 |
+
|
| 339 |
+
2. If you are including theoretical results...
|
| 340 |
+
|
| 341 |
+
(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]
|
| 342 |
+
|
| 343 |
+
3. If you ran experiments...
|
| 344 |
+
|
| 345 |
+
(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] The prediction code is available in the supplementary materials. For training, we used the popular fairseq, library. We have reported hyperparameters in $\ S 5 . 2$ and in the Appendix (§A).
|
| 346 |
+
(b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes]
|
| 347 |
+
(c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [No]
|
| 348 |
+
(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)? [No]
|
| 349 |
+
|
| 350 |
+
4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
|
| 351 |
+
|
| 352 |
+
(a) If your work uses existing assets, did you cite the creators? [Yes]
|
| 353 |
+
(b) Did you mention the license of the assets? [No]
|
| 354 |
+
(c) Did you include any new assets either in the supplemental material or as a URL? [Yes]
|
| 355 |
+
(d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [N/A]
|
| 356 |
+
(e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [No]
|
| 357 |
+
|
| 358 |
+
5. If you used crowdsourcing or conducted research with human subjects...
|
| 359 |
+
|
| 360 |
+
(a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A]
|
| 361 |
+
(b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A]
|
| 362 |
+
(c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]
|
md/dev/ZTsoE8G3GG/ZTsoE8G3GG.md
ADDED
|
@@ -0,0 +1,448 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# LEARNING TO EXTEND MOLECULAR SCAFFOLDS WITH STRUCTURAL MOTIFS
|
| 2 |
+
|
| 3 |
+
Krzysztof Maziarz∗ Microsoft Research United Kingdom
|
| 4 |
+
|
| 5 |
+
Henry Jackson-Flux Microsoft Research United Kingdom
|
| 6 |
+
|
| 7 |
+
Pashmina Cameron Microsoft Research United Kingdom
|
| 8 |
+
|
| 9 |
+
Finton Sirockin Novartis Switzerland
|
| 10 |
+
|
| 11 |
+
Nadine Schneider Novartis Switzerland
|
| 12 |
+
|
| 13 |
+
Nikolaus Stiefl Novartis Switzerland
|
| 14 |
+
|
| 15 |
+
Marwin Segler Microsoft Research United Kingdom
|
| 16 |
+
|
| 17 |
+
Marc Brockschmidt Microsoft Research United Kingdom
|
| 18 |
+
|
| 19 |
+
# ABSTRACT
|
| 20 |
+
|
| 21 |
+
Recent advancements in deep learning-based modeling of molecules promise to accelerate in silico drug discovery. A plethora of generative models is available, building molecules either atom-by-atom and bond-by-bond or fragmentby-fragment. However, many drug discovery projects require a fixed scaffold to be present in the generated molecule, and incorporating that constraint has only recently been explored. Here, we propose MoLeR, a graph-based model that naturally supports scaffolds as initial seed of the generative procedure, which is possible because it is not conditioned on the generation history. Our experiments show that MoLeR performs comparably to state-of-the-art methods on unconstrained molecular optimization tasks, and outperforms them on scaffoldbased tasks, while being an order of magnitude faster to train and sample from than existing approaches. Furthermore, we show the influence of a number of seemingly minor design choices on the overall performance.
|
| 22 |
+
|
| 23 |
+
# 1 INTRODUCTION
|
| 24 |
+
|
| 25 |
+
The problem of in silico drug discovery requires navigating a vast chemical space in order to find molecules that satisfy complex constraints on their properties and structure. This poses challenges well beyond those solvable by brute-force search, leading to the development of more sophisticated approaches. Recently, deep learning models are becoming an increasingly popular choice, as they can discern the nuances of drug-likeness from raw data.
|
| 26 |
+
|
| 27 |
+
While early generative models of molecules relied on the textual SMILES representation and reused architectures from natural language processing (Segler et al., 2018; Gómez-Bombarelli et al., 2018; Winter et al., 2019a; Ahn et al., 2020), many recent approaches are built around molecular graphs (De Cao & Kipf, 2018; Liu et al., 2018; Li et al., 2018b; Assouel et al., 2018; Simonovsky & Komodakis, 2018; Jin et al., 2018; 2020; Bradshaw et al., 2020). Compared to SMILES-based methods, graph-based models that employ a sequential generator enjoy perfect validity of generated molecules, as they can enforce hard chemical constraints such as valence during generation.
|
| 28 |
+
|
| 29 |
+
However, even if a molecule does not violate valence constraints, it is merely a sign of syntactic validity; the molecule can still be semantically incorrect by containing unstable or unsynthesisable substructures. Intermediate states during atom-by-atom generation may contain atypical chemical fragments, such as alternating bond patterns corresponding to unfinished aromatic rings. Therefore, some works (Rarey & Dixon, 1998; Jin et al., 2018; 2020; Ståhl et al., 2019; Xie et al., 2021) propose data-driven methods to mine common molecular fragments – referred to as motifs – which can be used to build molecules fragment-by-fragment instead of atom-by-atom. When motifs are employed, most partial molecules during generation are semantically sensible, as they do not contain half-built structures such as partial rings.
|
| 30 |
+
|
| 31 |
+

|
| 32 |
+
Figure 1: Overview of our approach. We discover motifs from data (a) and use them to decompose an input molecule (b) into motifs and single atoms. In the encoder (c), atom features (bottom) are combined with motif embeddings (top), making the motif information available at the atom level. Decoder steps (d) are only conditioned on the encoder output and partial graph (hence independent) and have to select one of the valid options (shown below, correct choices marked in red).
|
| 33 |
+
|
| 34 |
+
A common additional constraint in drug discovery projects is the inclusion of a predefined subgraph, called a scaffold (Schuffenhauer et al., 2007). Sampling molecules that contain a given scaffold can be approached by unconditional generation followed by post-hoc filtering. While simple, this method is not scalable, as the number of samples required may grow exponentially with scaffold size. Instead, some recent models can enforce the presence of a given scaffold (Lim et al., 2019; Li et al., 2019; Arús-Pous et al., 2020; Langevin et al., 2020). However, extending an arbitrary generative model to perform scaffold-based generation is often non-trivial, as we discuss in Section 4.
|
| 35 |
+
|
| 36 |
+
In this work we make the following contributions:
|
| 37 |
+
|
| 38 |
+
• In Section 2 we present MoLeR, a new graph-based generative model suitable for the commonly required task of extending partial molecules. It can use motifs (molecule fragments) to generate outputs (similarly to Jin et al. (2018; 2020)), but integrates this with atom-by-atom generation. • We show experimentally in Section 3 that MoLeR (a) is able learn to generate molecules matching the distribution of the training data (with and without scaffolds); $( b )$ together with an off-the-shelf optimization method (MSO (Winter et al., 2019b)) can be used for molecular optimization tasks, matching the state of the art methods in unconstrained optimization, and outperforming them on scaffold-constrained tasks; and (c) is faster in training and inference than baseline methods. • We also perform experiments in Section 3 to analyze two design decisions that are understudied in the literature: the choice of the generation order and the size of the motif vocabulary. Our results show how varying these two parameters affects model performance.
|
| 39 |
+
|
| 40 |
+
Code is available at https://github.com/microsoft/molecule-generation.
|
| 41 |
+
|
| 42 |
+
# 2 OUR APPROACH
|
| 43 |
+
|
| 44 |
+
# 2.1 DATA REPRESENTATION
|
| 45 |
+
|
| 46 |
+
Motifs Training our model relies on a set of fragments $\mathcal { M } -$ called the motif vocabulary – which we infer directly from data. For each training molecule, we decompose it into fragments by breaking some of the bonds; as breaking rings is chemically challenging, we only consider acyclic bonds, i.e. bonds that do not lie on a cycle. We break all acyclic bonds adjacent to a cycle (i.e. at least one endpoint lies on a cycle), as that separates the molecule into cyclic substructures, such as ring systems, and acyclic substructures, such as functional groups. We then aggregate the resulting fragments over the entire training set, and define $\mathcal { M }$ as the $n$ most common motifs, where $n$ is a hyperparameter. Having selected $\mathcal { M }$ , we pre-process molecules (both for training and during inference) by noting which atoms are covered by motifs belonging to the vocabulary. This is done by applying the same bond-breaking procedure as used for motif vocabulary extraction. During generation, our model can either add an entire motif in one step, or generate atoms and bonds one-by-one. This means that it can generate arbitrary structures, such as an unusual ring, even if they do not appear in the training data.
|
| 47 |
+
|
| 48 |
+
Finally, note that in contrast to Jin et al. (2020), we do not decompose ring systems into individual rings. This means that our motifs are atom-disjoint, and we consequently do not need to model a motif-specific attachment point vocabulary, as attaching a motif to a partial graph requires adding only a single bond, and thus there is only one attachment point.
|
| 49 |
+
|
| 50 |
+
Molecule Representation We represent a molecule as a graph $\mathcal { G } = ( \nu , \mathcal { E } )$ , where vertices $\nu$ are atoms, and edges $\mathcal { E }$ are bonds. Edges may also be annotated with extra features such as the bond type. Each node (atom) $v \in \mathcal V$ is associated with an initial node feature vector $h _ { v } ^ { ( i n i t ) }$ , chosen as chemically relevant features (Pocha et al., 2020), both describing the atom (type, charge, mass, valence, and isotope information) and its local neighborhood (aromaticity and presence of rings). These features can be readily extracted using the RDKit library (Landrum et al., 2006). Additionally, for atoms that are part of a motif, we concatenate $h _ { v } ^ { ( i n i t ) }$ with the motif embedding; for the other atoms we use a special embedding vector to signify the lack of a motif. We show this at the top of Figure 1.
|
| 51 |
+
|
| 52 |
+
Throughout this paper we use Graph Neural Networks (Li et al., 2015; Kipf & Welling, 2016) to learn contextualized node representations $h _ { v }$ (see Appendix A for background information on GNNs). Motif embeddings are initialized randomly, and learned end-to-end with the rest of the model.
|
| 53 |
+
|
| 54 |
+
# 2.2 THE MOLER DECODER
|
| 55 |
+
|
| 56 |
+
# Algorithm 1 MoLeR’s Generative Procedure
|
| 57 |
+
|
| 58 |
+
Our generative procedure is shown in Algorithm 1 and example steps are shown at the bottom of Figure 1. It takes as input a conditioning input vector $z$ , which can either be obtained from encoding (in our setting of training it as an autoencoder) or from sampling (at inference time), and optionally a partial molecule to start generation from. Our generator constructs a molecule piece by piece. In each step, it first selects a new atom or entire motif to add to the current partial molecule, or to stop the generation. If generation continues, the new atom (or an atom picked from the added motif) is then in “focus” and connected to the partial molecule by adding one or several bonds.
|
| 59 |
+
|
| 60 |
+
Our decoder relies on three neural networks to implement the functions PickAtomOrMotif,
|
| 61 |
+
|
| 62 |
+
Input: vector $z$ , scaffold as partial graph $S$
|
| 63 |
+
Output: molecule $M$ and probability $p$
|
| 64 |
+
$M , p \gets S , 1$
|
| 65 |
+
while True do $\begin{array} { l } { a , p ^ { a } \gets \mathsf { P i c k A t o m O r M o t i f } ( z , M ) } \\ { p \gets p \cdot p ^ { a } } \end{array}$ if $a = \mathsf { E N D \_ G E N }$ then return $M , p$ $M \gets$ AddAtomOrMotif $( M , a )$ v}, p} ← PickAttachment(z, M, a) p ← p · p } while True do b, pb ← PickBond(z, M, v}) p p p b if b = END_BONDS then break M ← AddBond(M, b)
|
| 66 |
+
|
| 67 |
+
PickAttachment and PickBond. These share a common GNN to process the partial molecule $M$ , yielding high-level features $h _ { v }$ for each atom $v$ and an aggregated graph-level feature vector $h _ { m o l }$ . We call our model MoLeR, as each step is conditioned on the Molecule-Level Representation $h _ { m o l }$ .
|
| 68 |
+
|
| 69 |
+
PickAtomOrMotif uses $h _ { m o l }$ as an input to an MLP that selects from the set of known atom types, motifs, and a special END_GEN class to signal the end of the generation. PickAttachment is used to select which of the atoms in an added motif to connect to the partial molecule (this is trivial in the case of adding a single atom). This is implemented by another MLP that computes a score for each added atom $v _ { a }$ using its representation $h _ { v _ { a } }$ and $h _ { m o l }$ . As motifs are often highly symmetric, we determine the symmetries using RDKit and only consider one atom per equivalence class. An example of this is shown in step (3) at the bottom of Figure 1, where only three of the five atoms in the newly-added motif are available as choices, as there are only three equivalence classes.
|
| 70 |
+
|
| 71 |
+
Finally, PickBond is used to predict which bonds to add, using another MLP that scores each candidate bond between the focus atom $v ^ { \mathcal { O } }$ and a potential partner $v _ { b }$ using their representations $h _ { v ^ { \circledcirc } }$ , $h _ { v _ { b } }$ and $h _ { m o l }$ . We also consider a special, learned END_BONDS partner to allow the network to choose to stop adding bonds. Similarly to Liu et al. (2018), we employ valence checks to mask out bonds that would lead to chemically invalid molecules. Moreover, if $v ^ { \mathcal { O } }$ was selected as an attachment point in a motif, we mask out edges to other atoms in the same motif.
|
| 72 |
+
|
| 73 |
+
The probability of a generation sequence is the product of probabilities of its steps; we note that the probability of a molecule is the sum over the probability of all different generation sequences leading to it, which is infeasible to compute. However, note that steps are only conditioned on the input $z$ and the current partial molecule $M$ . Our decoding is therefore not fully auto-regressive, as it marginalizes over all different generation sequences yielding the partial molecule $M$ . During training, we use a softmax over the candidates considered by each subnetwork to obtain a probability distribution. As there are many steps where there are several correct next actions (e.g. many atoms could be added next), during training, we use a multi-hot objective that encourages the model to learn a uniform distribution over all correct choices. For more details about the architecture see Appendix B.
|
| 74 |
+
|
| 75 |
+
# 2.3 MOLECULE GENERATION ORDERS
|
| 76 |
+
|
| 77 |
+
As alluded to above, to train MoLeR we need to provide supervision for each individual step of the generative procedure, which is complicated by the fact that a single molecule may be generated in a variety of different orders. To define a concrete generation sequence, we first choose a starting atom, and then for every partial molecule choose the next atom from its frontier, i.e. atoms adjacent to already generated atoms. After each choice, if the currently selected atom is part of a motif, we add the entire motif into the partial graph at once. We formalize this concept in Algorithm 2.
|
| 78 |
+
|
| 79 |
+
# Algorithm 2 Determining a generation order
|
| 80 |
+
|
| 81 |
+
Input: Target molecule $M$ , partial mapping
|
| 82 |
+
$\mathcal { A }$ from atoms to motifs that cover them
|
| 83 |
+
$t , V _ { 0 } \gets 0 , \emptyset$
|
| 84 |
+
while not all atoms visited do if $t = 0$ then $c _ { t } \gets \mathsf { V a l i d F i r s t A t o m s } ( M )$ else $c _ { t } \gets \mathsf { V a l i d N e x t A t o m s } ( V _ { t } , M )$ $a _ { t } \sim \mathcal { U } ( c _ { t } )$ $\triangleright$ Sample $a _ { t }$ uniformly if $a _ { t }$ is covered by $\mathcal { A }$ then $V _ { + } A ( a _ { t } )$ $\triangleright$ Add an entire motif else $\begin{array} { r } { V _ { + } \{ a _ { t } \} \quad \quad \triangleright \mathrm { A d d } } \\ { V _ { t + 1 } , t V _ { t } \cup V _ { + } , t + 1 } \end{array}$ a single atom
|
| 85 |
+
|
| 86 |
+
In Section 3, we evaluate orders commonly used in the literature: random, where ValidFirstAtoms returns all atoms and ValidNextAtoms all atoms
|
| 87 |
+
|
| 88 |
+
on the frontier on the current partial graph, i.e., a randomly chosen valid generation order; canonical, which is fully deterministic and follows a canonical ordering (Schneider et al., 2015) of the atoms computed using RDKit; and two variants of breadth-first search $( B F S )$ , where we choose the first atom either randomly or as the first atom in canonical order, and then explore the remaining atoms in BFS order, breaking ties between equidistant next nodes randomly.
|
| 89 |
+
|
| 90 |
+
# 2.4 TRAINING MOLER
|
| 91 |
+
|
| 92 |
+
MoLeR is trained in the autoencoder paradigm, and so we extend our decoder from above with an encoder that computes a single representation for the entire molecule. This encoder GNN operates directly on the full molecular graph, but is motif-aware through the motif annotations included in the atom features. These annotations are deterministic functions of the input molecule, and thus in principle could be learned by the GNN itself, but we found them to be crucial to achieve good performance. Our model is agnostic to the concrete GNN type; in practice, we use a simple yet expressive GNN-MLP layer, which computes messages for each edge by passing the states of its endpoints through an MLP. Similar to Brockschmidt (2020), we found that this approach outperforms commonly used GNN layers such as GCN (Kipf & Welling, 2016) or GIN (Xu et al., 2018).
|
| 93 |
+
|
| 94 |
+
We train our overall model to optimize a standard VAE loss (Kingma & Welling, 2013) with several minor modifications, resulting in the linear combination $\lambda _ { p r i o r } { \cdot } \mathcal { L } _ { p r i o r } ( x ) { + } \mathcal { L } _ { r e c } ( x ) { + } \lambda _ { p r o p } { \cdot } \mathcal { L } _ { p r o p } ( x )$ The weights $\lambda _ { p r i o r }$ and $\lambda _ { p r o p }$ are hyperparameters that we tuned empirically. We now elaborate on each of these loss components.
|
| 95 |
+
|
| 96 |
+
We define $\mathcal { L } _ { p r i o r } ( x ) = - \mathcal { D } _ { K L } ( q _ { \theta } ( z \mid x ) | | p ( z ) )$ , where $p ( z )$ is a multivariate Gaussian; as discussed above, the encoder $q _ { \theta }$ is implemented as a GNN followed by two heads used to parameterize the mean and the standard deviation of the latent code $z$ . We found that choosing $\lambda _ { p r i o r } < 1$ and using a sigmoid annealing schedule (Bowman et al., 2016) was required to make the training stable.
|
| 97 |
+
|
| 98 |
+
Following our decoder definition above, the reconstruction term $\mathcal { L } _ { r e c }$ could be written as a sum over the log probabilities of each step $s _ { i }$ , conditioned on the partial molecule $M _ { i }$ . However, we instead rewrite this term as an expectation with the step chosen uniformly over the entire generation:
|
| 99 |
+
|
| 100 |
+
$$
|
| 101 |
+
\begin{array} { r } { \mathcal { L } _ { r e c } ( x ) = \mathbb { E } _ { z \sim q _ { \theta } ( z \mid x ) } \mathbb { E } _ { i \sim \mathcal { U } } \log p ( s _ { i } \mid z , M _ { i } ) . } \end{array}
|
| 102 |
+
$$
|
| 103 |
+
|
| 104 |
+
This makes it explicit that different generation steps for a fixed input molecule do not depend on each other. Figure 1 illustrates this visually, as there are no dependencies between the individual steps. We use this to train in parallel on all generation steps at once (i.e., a batch is made up of many steps like (1)-(5) in Figure 1). Additionally, we subsample generation steps, i.e., uniformly at random drop some of the generation steps from training, to get a wider variety of molecules within each batch. These enhancements improve training speed and robustness, and are feasible precisely because our model does not depend on the generation history. In Appendix I.2 we show empirically that subsampling leads to faster convergence on several downstream metrics.
|
| 105 |
+
|
| 106 |
+
Finally, following prior works (Gómez-Bombarelli et al., 2018; Winter et al., $2 0 1 9 \mathrm { a }$ ; Li et al., 2021), we use $\mathcal { L } _ { p r o p } ( x )$ to ensure that simple chemical properties can be accurately predicted from the latent encoding of a molecule. Concretely, we use an MLP regressor on top of the sampled latent code $z$ to predict molecular weight, synthetic accessibility (SA) score, and octanol-water partition coefficient $( \mathrm { l o g P } )$ , using MSE on these values as objective. We found that choosing the weight $\lambda _ { p r o p }$ of this objective to be smaller than 0.1 was necessary to avoid the decoder ignoring the latent code $z$ . All of these properties can be readily computed from the input molecule $x$ using the RDKit library, and hence do not require additional annotations in the training data. Note that due to the inherent stochasticity in the VAE encoding process, obtaining a low value of $\mathcal { L } _ { p r o p }$ is only possible if the latent space learned by $q _ { \theta }$ is smooth with respect to the predicted properties.
|
| 107 |
+
|
| 108 |
+
# 3 EXPERIMENTS
|
| 109 |
+
|
| 110 |
+
Setup We use training data from GuacaMol (Brown et al., 2019), which released a curated set of ${ \approx } 1 . 5 \mathbf { M }$ drug-like molecules, divided into train, validation and test sets. We train MoLeR on the GuacaMol training set until loss on the validation set does not improve; we then use the best checkpoint selected based on validation loss to evaluate on downstream tasks. As discussed above, we found that subsampling generation sequence steps to use only half of the steps per molecule tends to speed up convergence, as it yields more variety within each batch. Therefore, we subsample generation steps for all MoLeR experiments unless noted otherwise. For molecular optimization, we pair MoLeR with Molecular Swarm Optimization (MSO) (Winter et al., 2019b), which is a black-box latent space optimization method that was shown to achieve state-of-the-art performance. For more details on the training routine, experimental setup, and hyperparameters, see Appendix C. We show samples from the model’s prior in Appendix D.
|
| 111 |
+
|
| 112 |
+
Baselines As baselines, we consider three established graph-based generative models: CGVAE (Liu et al., 2018), JT-VAE (Jin et al., 2018), and HierVAE (Jin et al., 2020). Since the publicly released code of Liu et al. (2018) does not scale to datasets as large as GuacaMol, we re-implemented CGVAE following the released code to make it more efficient. For JT-VAE, we used the open-source code, but implemented multithreaded decoding, which made sampling ${ 8 \mathrm { x } }$ faster. For HierVAE, we used the released code with no changes. Due to the high cost of training JT-VAE and HierVAE, we did not tune their hyperparameters and instead used the default values.
|
| 113 |
+
|
| 114 |
+
# 3.1 QUANTITATIVE RESULTS
|
| 115 |
+
|
| 116 |
+
Efficiency We measure the speed of different models in training and inference, quantified by the number of molecules processed per second. Note that we do not subsample generation steps for this comparison, so that every model processes all the steps, even though MoLeR can learn from only a subset of them. We compare
|
| 117 |
+
|
| 118 |
+
Table 1: Training and sampling speed for our model and the baselines on a Tesla K80 GPU.
|
| 119 |
+
|
| 120 |
+
<table><tr><td>Model</td><td>Train (mol/sec)</td><td>Sample (mol/sec)</td></tr><tr><td>CGVAE</td><td>57.0</td><td>1.4</td></tr><tr><td>JT-VAE</td><td>3.2</td><td>3.4</td></tr><tr><td>HierVAE</td><td>17.0</td><td>12.3</td></tr><tr><td>MoLeR</td><td>95.2</td><td>34.2</td></tr></table>
|
| 121 |
+
|
| 122 |
+
these results in Table 1. We see that, thanks to a simpler formulation and parallel training on all generation steps, MoLeR is much faster than all baselines for both training and inference.
|
| 123 |
+
|
| 124 |
+
Unconstrained Generation Similarly to Brown et al. (2019), we use Frechet ChemNet Distance (FCD) (Preuer et al., 2018) to measure how much sampled molecules resemble those in the training data. We show the results in Figure 2 (left), in which we compare different models and variations of MoLeR trained with different choices of generation order (see Section 2.3) and different motif vocabulary sizes. It shows that MoLeR with a large vocabulary outperforms the baselines substantially, despite being much faster to train and sample from, and having support for scaffold-constrained generation. Furthermore, we can see that MoLeR’s performance increases as the vocabulary size grows. Finally, we note that training with generation orders with a deterministic starting point performs best, and that random order performs less well, as modeling a wide range of orders is harder.
|
| 125 |
+
|
| 126 |
+

|
| 127 |
+
Figure 2: Frechet ChemNet Distance (lower is better) for different generation orders and vocabulary sizes. We consider generation from scratch (left), and generation starting from a scaffold (right).
|
| 128 |
+
|
| 129 |
+
Unlike some prior work (De Cao & Kipf, 2018; Brown et al., 2019), we do not compare validity, uniqueness and novelty, as our models get near-perfect results on these metrics, making comparison meaningless. Concretely, we obtain $100 \%$ validity by design (due to the use of valence checks), uniqueness above $9 9 \%$ , and novelty above $9 7 \%$ .
|
| 130 |
+
|
| 131 |
+
Scaffold-constrained Generation Next, we consider the setting of enforcing a given scaffold. We first choose a chemically relevant scaffold $\Sigma$ (PubChem CID 12658820) that commonly appears in GuacaMol training data. We then estimate the posterior distribution on latent codes induced by $\Sigma$ by encoding all training molecules that contain it and approximating the result with a Gaussian Mixture Model (GMM) with 50 mixture components. Finally, we draw latent codes from the GMM, decode them starting the generation process from $\Sigma$ , and compare the resulting molecules with molecules from the data that contain $\Sigma$ . By using samples from the GMM-approximated posterior, as opposed to samples from the prior, we ensure that we use latent codes which are compatible with the scaffold $\Sigma$ , which we found to dramatically improve the downstream metrics. Intuitively, constraining the decoding restricts the latent codes of output molecules to a manifold defined by the scaffold constraint; using an approximate posterior ensures that the projected samples lie close to that manifold.
|
| 132 |
+
|
| 133 |
+
In Figure 2 (right) we show the resulting FCD. We find that the relative performance of different generation orders is largely reversed: since the models trained with canonical order can only complete prefixes of that order, they are not well equipped to complete arbitrary scaffolds. On the other hand, models trained with randomized orders are more flexible and handle the task well. As with generation from scratch, using a larger motif vocabulary tends to help, especially if motifs happen to decompose the scaffold into smaller fragments (or even the entire scaffold may appear in the vocabulary). Finally, we note that BFS order using a random starting point gives the best results for this task, while still showing good performance for unconstrained sampling.
|
| 134 |
+
|
| 135 |
+
Unconstrained Optimization We experiment on the GuacaMol optimization benchmarks (Brown et al., 2019), tracking two metrics: raw performance score, and quality, defined as absence of undesirable substructures. In Table 2 (left), we compare our results with those taken from the literature. We find that MoLeR maintains a good balance between raw score and quality. Note that the quality filters are not directly available to the models during optimization, and rather are evaluated post-hoc on the optimized molecules. This ensures that high quality scores can only be achieved if the model is biased towards reasonable molecules, and not by learning to exploit and “slip through” the quality filters, similarly to what has been shown for property predictors (Renz et al., 2020). Consequently, the best performing models often produce unreasonable molecules (Winter et al., 2019b; Xu et al., 2020). While the SMILES LSTM baseline of Brown et al. (2019) also gets good results on both score and quality, as we will see below, it struggles to complete arbitrary scaffolds. Note that, out of 20 tasks in this suite, only one tests optimization from a scaffold, and that task uses a small scaffold (Figure 3 (top)), making it relatively easy (even simple models get near-perfect results). In contrast, scaffolds typically used in drug discovery are much more complex (Schuffenhauer et al., 2007; Schuffenhauer, 2012). We conclude that while MoLeR shows good performance on GuacaMol tasks, they do not properly evaluate the ability to complete realistic scaffolds.
|
| 136 |
+
|
| 137 |
+
Table 2: Results on 20 GuacaMol tasks (left) and 4 additional scaffold-based tasks (right). First five rows correspond to baselines from Brown et al. (2019). We do not compute quality if less than 100 molecules per benchmark were found.
|
| 138 |
+
|
| 139 |
+
<table><tr><td></td><td colspan="2">GuacaMol</td><td colspan="2">Scaffolds</td></tr><tr><td>Method</td><td>Score</td><td>Quality</td><td>Score</td><td>Quality</td></tr><tr><td>Best of dataset</td><td>0.61</td><td>0.77</td><td>0.17</td><td>-</td></tr><tr><td>SMILESLSTM</td><td>0.87</td><td>0.77</td><td>0.45</td><td>=</td></tr><tr><td>SMILES GA</td><td>0.72</td><td>0.36</td><td>0.45</td><td>=</td></tr><tr><td>GRAPHMCTS</td><td>0.45</td><td>0.22</td><td>0.20</td><td>=</td></tr><tr><td>GRAPH GA</td><td>0.90</td><td>0.40</td><td>0.79</td><td>=</td></tr><tr><td>CDDD + MSO</td><td>0.90</td><td>0.58</td><td>0.92</td><td>0.59</td></tr><tr><td>MNCE-RL</td><td>0.92</td><td>0.54</td><td>0.95</td><td>0.47</td></tr><tr><td>MoLeR+MSO</td><td>0.82</td><td>0.75</td><td>0.93</td><td>0.63</td></tr></table>
|
| 140 |
+
|
| 141 |
+

|
| 142 |
+
Figure 3: Scaffold from a GuacaMol benchmark (top) and a scaffold from our additional benchmark (bottom).
|
| 143 |
+
|
| 144 |
+
Scaffold-constrained Optimization To evaluate scaffold-constrained optimization, we extend the GuacaMol benchmarks with 4 new scaffold-based tasks, using larger scaffolds extracted from or inspired by clinical candidate molecules or marketed drugs, which are more representative of realworld drug discovery (e.g. Figure 3 (bottom)). The task is to perform scaffold-constrained exploration towards a target property profile; as the components of the scoring functions are aggregated via the geometric mean, and presence of the scaffold is binary, molecules that do not contain the scaffold receive a total score of 0 (see Appendix E for more details). We show the results in Table 2 (right). We see that MoLeR performs well, while most baseline approaches struggle to maintain the scaffold.
|
| 145 |
+
|
| 146 |
+
Finally, we run the tasks of Lim et al. (2019), where the aim is to generate 100 distinct decorations of large scaffolds to match one or several property targets: molecular weight, logp and TPSA. While the model of Lim et al. (2019) is specially designed to produce samples conditioned on the values of these three properties in one-shot, we convert the target property values into a single objective that we can optimize with MSO. Concretely, for each property we compute the absolute difference to the target value, which we divide by the result of Lim et al. (2019) for a given task, and then average over all properties of interest; under the resulting metric, the model of Lim et al. (2019) gets a score of 1.0 by design. We show the results in Figure 4. Despite not being trained for this this task, MoLeR outperforms the baseline on all benchmarks. These results show that MoLeR can match the capabilities of existing scaffold-based models out-of-the-box. To verify that this cannot be attributed solely to using MSO, we also tried using CDDD as the generative model. We find that CDDD often produces invalid molecules or molecules that do not contain the scaffold; MoLeR avoids both of these problems thanks to valence constraints and scaffold-constrained generation. As a result, in some cases CDDD needs many steps to discover 100 distinct decorations or does not discover them at all; having 100 decorations is needed to compare the average result to Lim et al. (2019). Thus, for CDDD we plot a modified score by duplicating the worst score an appropriate number of times; this was not needed for MoLeR, as it always finds enough decorations in the first few steps.
|
| 147 |
+
|
| 148 |
+
# 3.2 QUALITATIVE RESULTS
|
| 149 |
+
|
| 150 |
+
Unconstrained and constrained interpolation To test the smoothness of our latent space and analyze how adding the scaffold constraint impacts decoding, we select a chemically relevant scaffold (PubChem CID 7375) and two dissimilar molecules $m _ { 1 }$ and $m _ { 2 }$ that contain it. We then linearly interpolate between the latent encodings of $m _ { 1 }$ and $m _ { 2 }$ , and select those intermediate points at which the corresponding decoded molecule changes. We show in Figure 5 (top) that MoLeR correctly identifies a smooth transition from $m _ { 1 }$ to $m _ { 2 }$ . Most of the differences between $m _ { 1 }$ and $m _ { 2 }$ stem from the latter containing two additional rings, and we see that rings are consistently added during the interpolation. For example, in the third step, the molecule grows by one extra ring, but of a type that does not appear in $m _ { 2 }$ ; in the next step, this ring transforms into the correct type, and is then present in all subsequent steps (a similar pattern can be observed for the other ring). However, we see that some intermediate molecules do not contain the scaffold: although all of the scaffold’s building blocks are present, the interpolation goes through a region in which the model decides to move the NH group to a different location, thus breaking the integrity of the scaffold. This shows that while latent space distance strongly correlates with structural similarity, latent space smoothness alone does not guarantee the presence of a scaffold, which necessitates scaffold-based generation.
|
| 151 |
+
|
| 152 |
+

|
| 153 |
+
Figure 4: Comparison on tasks from Lim et al. (2019). We show both single-property optimization tasks as well as one where all properties must be optimized simultaneously. We plot averages and standard error over 20 runs for each task; each run uses a different scaffold and property targets.
|
| 154 |
+
|
| 155 |
+

|
| 156 |
+
Figure 5: Interpolation between latent encodings of two molecules; unconstrained decoding (top), constrained with scaffold (bottom). The scaffold is highlighted in each molecule that contains it.
|
| 157 |
+
|
| 158 |
+
In contrast, in Figure 5 (bottom), we show the same sequence of latent codes decoded with a scaffold constraint. We see that the constraint keeps the NH group locked in place, so that all intermediate molecules contain the scaffold. The molecule decoded under a scaffold constraint is typically very similar to the one decoded without, showing that constrained decoding preserves chemical features that are not related to the presence of the scaffold. However, when trying to include the scaffold, our model does not have to resort to a simple rearrangement of existing building blocks: for example, in the 7th step, adding a constraint also modifies one of the ring types, which results in a smoother interpolation in comparison to the unconstrained case. Finally, while the interpolation points were chosen to remove duplicates from the unconstrained path, we see that the last two latent points both get mapped to $m _ { 2 }$ when the constraint is introduced. This is because the last step of the unconstrained interpolation merely rearranges the motifs, moving back the NH group to its initial location, and restoring the scaffold. This modification is not needed if the scaffold is already present, and therefore our model chooses to project both latent codes to the same point on the scaffold-constrained manifold.
|
| 159 |
+
|
| 160 |
+
Latent Space Neighborhood To analyze the structure of our scaffold-constrained latent space, we select another scaffold and perform scaffold-constrained decoding of a group of neighboring latent points. We note that close-by latent codes decode to similar molecules, often composing the same motifs in a different way, mirroring the observation of Jin et al. (2018). Moreover, some latent space directions seem to track simple chemical properties. For further analysis of this result see Appendix F.
|
| 161 |
+
|
| 162 |
+
Learned Motif Representations To better understand how MoLeR uses motifs, we extract learned motif representations from a trained model. We found that, despite the weights having no direct access to molecular structure or features of motifs, nearest neighbors in the representation space correspond to pairs of nearly identical motifs. See Appendix G for visualization and further discussion.
|
| 163 |
+
|
| 164 |
+
# 3.3 ABLATIONS
|
| 165 |
+
|
| 166 |
+
We tested a number of ablations of our model to analyze the effect of its individual components. Figure 2 shows the effect of motif vocabulary size; in particular, the points for 0 motifs correspond to not using any motif information at all. In Appendix H we repeat the analysis from Figure 2 for optimization performance, showing that some of the trends transfer also to that setting. Finally, we considered partially removing motifs by not using motif embeddings in the encoder, and found that this also decreases performance, as the model needs to use some of its capacity to recognize motifs in the input graphs (see Appendix I.1 for details).
|
| 167 |
+
|
| 168 |
+
We also evaluated the impact of subsampling generation steps (as described in Section 2.4), and found that this method allows MoLeR to match the training data more rapidly, as measured by FCD (see Appendix I.2 for details). Finally, we analyzed the influence of using the auxiliary loss term $\mathcal { L } _ { p r o p }$ , and found that in a model trained without this objective, molecules that are close in latent space are less similar to each other in important chemical properties such as synthetic accessibility (details can be found in Appendix I.3).
|
| 169 |
+
|
| 170 |
+
# 4 RELATED WORK
|
| 171 |
+
|
| 172 |
+
Our work naturally relates to the rich family of in silico drug discovery methods. However, it is most related to works that perform iterative generation of molecular graphs, works that employ fragments or motifs, and works that explicitly consider scaffolds.
|
| 173 |
+
|
| 174 |
+
Iterative generation of molecular graphs Many graph-based models for molecule generation employ some form of iterative decoding. Often a single arbitrary ordering is chosen: Liu et al. (2018) first generate all atoms in a one-shot manner, and then generate bonds in BFS order; Jin et al. (2018; 2020) generate a coarsened tree-structured form of the molecular graph in a deterministic DFS order; and You et al. (2018) use random order. Some works go beyond a single ordering: Liao et al. (2019) marginalize over several orders, while Mercado et al. (2020) try both random and canonical, and find the latter produces better samples, which is consistent with our unconstrained generation results. Sacha et al. (2020) generate graph edits with the goal of modeling reactions, and evaluate a range of editing orders. Although the task in their work is different, the results are surprisingly close to ours: a fully random order performs badly, and the optimal amount of non-determinism is task-dependent.
|
| 175 |
+
|
| 176 |
+
Motif extraction Several other works make use of motif extraction approaches related to the one described in Section 2.1. Jin et al. (2020) propose a very similar strategy, but additionally do not break leaf bonds, i.e. bonds incident to an atom of degree 1, which we found produces many motifs that are variations of the same underlying structure (e.g. a ring) with different combinations of leaf atoms; for simplicity, we chose to omit that rule in our extraction strategy. More complex molecular fragmentation approaches also exist (Degen et al., 2008), and we plan to explore them in future work.
|
| 177 |
+
|
| 178 |
+
Motif-based generation Our work is closely related to the work of Jin et al. (2018; 2020), which also uses motifs to generate molecular graphs. However, these works cannot be easily extended to scaffold-based generation, and cannot generate molecules which use building blocks not covered by the motif vocabulary. While HierVAE (Jin et al., 2020) does include individual atoms and bonds in its vocabulary, motifs are still assembled in a tree-like manner, meaning that the model cannot generate an arbitrary cyclic structure if its base cycles are not present in the vocabulary.
|
| 179 |
+
|
| 180 |
+
Scaffold-conditioned generation Some prior works can construct molecules under a hard scaffold constraint. Lim et al. (2019) proposes a graph-based model with persistent state; scaffold-based generation is possible because the model is explicitly trained on (scaffold, molecule) pairs. In contrast, MoLeR treats every intermediate partial graph as if it were a scaffold to be completed. Li et al. (2018a) use a soft constraint, where the scaffold is part of the input, but is not guaranteed to be present in the generated molecule. Finally, Arús-Pous et al. (2020); Langevin et al. (2020) adapt SMILES-based models to work with scaffolds, and cannot guarantee validity of generated molecules.
|
| 181 |
+
|
| 182 |
+
Overall, it is non-trivial to extend existing molecule generators to the scaffold setting. For SMILESbased models, the scaffold may not be represented by a substring of the SMILES representation of the complete molecule, and so its presence cannot easily be enforced by forcing some of the decoder’s choices. Junction tree-based models (Jin et al., 2018) start the generation at a leaf of the junction tree, but the junction tree for a scaffold does not necessarily match that of the full molecule, or reaches its leaves. Furthermore, graph-based models often use a recurrent state updated throughout the entire generative procedure (Jin et al., 2018; 2020). Finally, fragment-based models that do not support substructures not covered by their fragment library (Jin et al., 2020) fail when a scaffold is not fully covered by known fragments. MoLeR, through seemingly minor design choices (graph-based, conditioned only on a partial graph, not reliant on a fixed generation order, flexibility to switch between fragment-based and atom-by-atom generation), side-steps all of these issues.
|
| 183 |
+
|
| 184 |
+
# 5 CONCLUSION
|
| 185 |
+
|
| 186 |
+
In this work, we presented MoLeR: a novel graph-based model for molecular generation. As our model does not depend on history, it can complete arbitrary scaffolds, while still outperforming state-of-the-art graph-based generative models in unconstrained generation. Our quantitative and qualitative results show that MoLeR retains desirable properties of generative models - such as smooth interpolation - while respecting the scaffold constraint. Finally, we show that it exhibits good performance in unconstrained optimization, while excelling in scaffold-constrained optimization.
|
| 187 |
+
|
| 188 |
+
# 6 ETHICS STATEMENT
|
| 189 |
+
|
| 190 |
+
As we consider our work to be fundamental research, there are no direct ethical risks or societal consequences; these have to be analyzed per concrete applications. Broadly speaking, tools such as MoLeR can be widely beneficial for the pharmaceutical industry. However, note that while MoLeR performs optimization tasks that would otherwise be done manually by medicinal chemists, it is unlikely to be considered a replacement for them, and rather an enhancement to their creative process.
|
| 191 |
+
|
| 192 |
+
# 7 ACKNOWLEDGMENTS
|
| 193 |
+
|
| 194 |
+
We would like to thank Hubert Misztela, Michał Pikusa and William Jose Godinez Navarro for work on the JT-VAE baseline. Moreover, we want to acknowledge the larger team (Ashok Thillaisundaram, Jessica Lanini, Megan Stanley, Nikolas Fechner, Paweł Czyz, Richard Lewis, Sarah Lewis and Qurrat ˙ Ul Ain) for engaging in helpful discussions.
|
| 195 |
+
|
| 196 |
+
# REFERENCES
|
| 197 |
+
|
| 198 |
+
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.
|
| 199 |
+
|
| 200 |
+
Sungsoo Ahn, Junsu Kim, Hankook Lee, and Jinwoo Shin. Guiding deep molecular optimization with genetic exploration. arXiv preprint arXiv:2007.04897, 2020.
|
| 201 |
+
|
| 202 |
+
Apixaban. Pubchem compound summary for cid 10182969, apixaban. November, 2021. URL https://pubchem.ncbi.nlm.nih.gov/compound/Apixaban.
|
| 203 |
+
|
| 204 |
+
Josep Arús-Pous, Atanas Patronov, Esben Jannik Bjerrum, Christian Tyrchan, Jean-Louis Reymond, Hongming Chen, and Ola Engkvist. Smiles-based deep generative scaffold decorator for de-novo drug design. Journal of cheminformatics, 12:1–18, 2020.
|
| 205 |
+
|
| 206 |
+
Rim Assouel, Mohamed Ahmed, Marwin H Segler, Amir Saffari, and Yoshua Bengio. Defactor: Differentiable edge factorization-based probabilistic graph generation. arXiv preprint arXiv:1811.09766, 2018.
|
| 207 |
+
|
| 208 |
+
Jimmy Lei Ba, Jamie Ryan Kiros, and Geoffrey E Hinton. Layer normalization. arXiv preprint arXiv:1607.06450, 2016.
|
| 209 |
+
|
| 210 |
+
Samuel R. Bowman, Luke Vilnis, Oriol Vinyals, Andrew Dai, Rafal Jozefowicz, and Samy Bengio. Generating sentences from a continuous space. In Proceedings of The 20th SIGNLL Conference on Computational Natural Language Learning, pp. 10–21, 2016.
|
| 211 |
+
|
| 212 |
+
John Bradshaw, Brooks Paige, Matt J Kusner, Marwin HS Segler, and José Miguel Hernández-Lobato. Barking up the right tree: an approach to search over molecule synthesis dags. arXiv preprint arXiv:2012.11522, 2020.
|
| 213 |
+
|
| 214 |
+
Marc Brockschmidt. GNN-film: Graph neural networks with feature-wise linear modulation. In International Conference on Machine Learning, pp. 1144–1152. PMLR, 2020.
|
| 215 |
+
|
| 216 |
+
Nathan Brown, Marco Fiscato, Marwin HS Segler, and Alain C Vaucher. Guacamol: benchmarking models for de novo molecular design. Journal of chemical information and modeling, 59(3): 1096–1108, 2019.
|
| 217 |
+
|
| 218 |
+
Gabriele Corso, Luca Cavalleri, Dominique Beaini, Pietro Liò, and Petar Velickovi ˇ c. Principal ´ neighbourhood aggregation for graph nets. arXiv preprint arXiv:2004.05718, 2020.
|
| 219 |
+
|
| 220 |
+
Nicola De Cao and Thomas Kipf. Molgan: An implicit generative model for small molecular graphs. arXiv preprint arXiv:1805.11973, 2018.
|
| 221 |
+
|
| 222 |
+
Jörg Degen, Christof Wegscheid-Gerlach, Andrea Zaliani, and Matthias Rarey. On the art of compiling and using’drug-like’chemical fragment spaces. ChemMedChem: Chemistry Enabling Drug Discovery, 3(10):1503–1507, 2008.
|
| 223 |
+
|
| 224 |
+
Justin Gilmer, Samuel S Schoenholz, Patrick F Riley, Oriol Vinyals, and George E Dahl. Neural message passing for quantum chemistry. arXiv preprint arXiv:1704.01212, 2017.
|
| 225 |
+
|
| 226 |
+
Rafael Gómez-Bombarelli, Jennifer N Wei, David Duvenaud, José Miguel Hernández-Lobato, Benjamín Sánchez-Lengeling, Dennis Sheberla, Jorge Aguilera-Iparraguirre, Timothy D Hirzel, Ryan P Adams, and Alán Aspuru-Guzik. Automatic chemical design using a data-driven continuous representation of molecules. ACS central science, 4(2):268–276, 2018.
|
| 227 |
+
|
| 228 |
+
Wengong Jin, Regina Barzilay, and Tommi Jaakkola. Junction tree variational autoencoder for molecular graph generation. arXiv preprint arXiv:1802.04364, 2018.
|
| 229 |
+
|
| 230 |
+
Wengong Jin, Regina Barzilay, and Tommi Jaakkola. Hierarchical generation of molecular graphs using structural motifs. arXiv preprint arXiv:2002.03230, 2020.
|
| 231 |
+
|
| 232 |
+
Diederik P Kingma and Jimmy Ba. Adam: A method for stochastic optimization. arXiv preprint arXiv:1412.6980, 2014.
|
| 233 |
+
|
| 234 |
+
Diederik P Kingma and Max Welling. Auto-encoding variational bayes. arXiv preprint arXiv:1312.6114, 2013.
|
| 235 |
+
|
| 236 |
+
Thomas N Kipf and Max Welling. Semi-supervised classification with graph convolutional networks. arXiv preprint arXiv:1609.02907, 2016.
|
| 237 |
+
|
| 238 |
+
Greg Landrum et al. Rdkit: Open-source cheminformatics. 2006. URL http://www.rdkit. org.
|
| 239 |
+
|
| 240 |
+
Maxime Langevin, Hervé Minoux, Maximilien Levesque, and Marc Bianciotto. Scaffold-constrained molecular generation. Journal of Chemical Information and Modeling, 2020.
|
| 241 |
+
|
| 242 |
+
Lenacapavir. Pubchem compound summary for cid 133082658, lenacapavir. November, 2021. URL https://pubchem.ncbi.nlm.nih.gov/compound/Lenacapavir.
|
| 243 |
+
|
| 244 |
+
Yibo Li, Liangren Zhang, and Zhenming Liu. Multi-objective de novo drug design with conditional graph generative model. Journal of cheminformatics, 10(1):1–24, 2018a.
|
| 245 |
+
|
| 246 |
+
Yibo Li, Jianxing Hu, Yanxing Wang, Jielong Zhou, Liangren Zhang, and Zhenming Liu. Deepscaffold: A comprehensive tool for scaffold-based de novo drug discovery using deep learning. Journal of chemical information and modeling, 60(1):77–91, 2019.
|
| 247 |
+
|
| 248 |
+
Yifeng Li, Hsu Kiang Ooi, and Alain Tchagang. Deep evolutionary learning for molecular design, 2021. URL https://openreview.net/forum?id $=$ Fo6S5-3Dx_.
|
| 249 |
+
|
| 250 |
+
Yujia Li, Daniel Tarlow, Marc Brockschmidt, and Richard Zemel. Gated graph sequence neural networks. arXiv preprint arXiv:1511.05493, 2015.
|
| 251 |
+
|
| 252 |
+
Yujia Li, Oriol Vinyals, Chris Dyer, Razvan Pascanu, and Peter Battaglia. Learning deep generative models of graphs. arXiv preprint arXiv:1803.03324, 2018b.
|
| 253 |
+
|
| 254 |
+
Renjie Liao, Yujia Li, Yang Song, Shenlong Wang, Charlie Nash, William L Hamilton, David Duvenaud, Raquel Urtasun, and Richard S Zemel. Efficient graph generation with graph recurrent attention networks. arXiv preprint arXiv:1910.00760, 2019.
|
| 255 |
+
|
| 256 |
+
Jaechang Lim, Sang-Yeon Hwang, Seungsu Kim, Seokhyun Moon, and Woo Youn Kim. Scaffoldbased molecular design using graph generative model. arXiv preprint arXiv:1905.13639, 2019.
|
| 257 |
+
|
| 258 |
+
Qi Liu, Miltiadis Allamanis, Marc Brockschmidt, and Alexander Gaunt. Constrained graph variational autoencoders for molecule design. Advances in neural information processing systems, 31:7795– 7804, 2018.
|
| 259 |
+
|
| 260 |
+
Andrew L Maas, Awni Y Hannun, and Andrew Y Ng. Rectifier nonlinearities improve neural network acoustic models. In Proc. icml, volume 30, pp. 3. Citeseer, 2013.
|
| 261 |
+
|
| 262 |
+
Rocío Mercado, Tobias Rastemo, Edvard Lindelöf, Günter Klambauer, Ola Engkvist, Hongming Chen, and Esben Jannik Bjerrum. Graph networks for molecular design. Machine Learning: Science and Technology, 2020.
|
| 263 |
+
|
| 264 |
+
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 (eds.), Advances in Neural Information Processing Systems 32, pp. 8024–8035. Curran Associates, Inc., 2019.
|
| 265 |
+
|
| 266 |
+
Agnieszka Pocha, Tomasz Danel, and Łukasz Maziarka. Comparison of atom representations in graph neural networks for molecular property prediction. arXiv preprint arXiv:2012.04444, 2020.
|
| 267 |
+
|
| 268 |
+
Kristina Preuer, Philipp Renz, Thomas Unterthiner, Sepp Hochreiter, and Günter Klambauer. Frechet chemnet distance: a metric for generative models for molecules in drug discovery. Journal of chemical information and modeling, 58(9):1736–1741, 2018.
|
| 269 |
+
|
| 270 |
+
PubChem CID 12658820. Pubchem compound summary for cid 12658820 1,4-Dihydroquinoline. January, 2021. URL https://pubchem.ncbi.nlm.nih.gov/compound/1_ 4-Dihydroquinoline.
|
| 271 |
+
|
| 272 |
+
PubChem CID 57732551. Pubchem compound summary for cid 57732551 1,3-Dimethylquinolin4(1H)-one. January, 2021. URL https://pubchem.ncbi.nlm.nih.gov/compound/ 1_3-Dimethylquinolin-4_1H_-one.
|
| 273 |
+
|
| 274 |
+
PubChem CID 7375. Pubchem compound summary for cid 7375, 3-(trifluoromethyl)aniline. January, 2021. URL https://pubchem.ncbi.nlm.nih.gov/compound/3-_ Trifluoromethyl_aniline.
|
| 275 |
+
|
| 276 |
+
Matthias Rarey and J Scott Dixon. Feature trees: a new molecular similarity measure based on tree matching. Journal of computer-aided molecular design, 12(5):471–490, 1998.
|
| 277 |
+
|
| 278 |
+
Philipp Renz, Dries Van Rompaey, Jörg Kurt Wegner, Sepp Hochreiter, and Günter Klambauer. On failure modes of molecule generators and optimizers. 2020.
|
| 279 |
+
|
| 280 |
+
Mikołaj Sacha, Mikołaj Błaz, Piotr Byrski, Paweł Włodarczyk-Pruszy ˙ nski, and Stanisław Jastrz˛ebski. ´ Molecule edit graph attention network: Modeling chemical reactions as sequences of graph edits. arXiv preprint arXiv:2006.15426, 2020.
|
| 281 |
+
|
| 282 |
+
Nadine Schneider, Roger A Sayle, and Gregory A Landrum. Get your atoms in order - an open-source implementation of a novel and robust molecular canonicalization algorithm. Journal of chemical information and modeling, 55(10):2111–2120, 2015.
|
| 283 |
+
|
| 284 |
+
Ansgar Schuffenhauer. Computational methods for scaffold hopping. Wiley Interdisciplinary Reviews: Computational Molecular Science, 2(6):842–867, 2012.
|
| 285 |
+
|
| 286 |
+
Ansgar Schuffenhauer, Peter Ertl, Silvio Roggo, Stefan Wetzel, Marcus A Koch, and Herbert Waldmann. The scaffold tree- visualization of the scaffold universe by hierarchical scaffold classification. Journal of chemical information and modeling, 47(1):47–58, 2007.
|
| 287 |
+
|
| 288 |
+
Marwin HS Segler, Thierry Kogej, Christian Tyrchan, and Mark P Waller. Generating focused molecule libraries for drug discovery with recurrent neural networks. ACS central science, 4(1): 120–131, 2018.
|
| 289 |
+
|
| 290 |
+
Sildenafil. Pubchem compound summary for cid 135398744, sildenafil. November, 2021. URL https://pubchem.ncbi.nlm.nih.gov/compound/Sildenafil.
|
| 291 |
+
|
| 292 |
+
Martin Simonovsky and Nikos Komodakis. Graphvae: Towards generation of small graphs using variational autoencoders. In International Conference on Artificial Neural Networks, pp. 412–422. Springer, 2018.
|
| 293 |
+
|
| 294 |
+
Niclas Ståhl, Goran Falkman, Alexander Karlsson, Gunnar Mathiason, and Jonas Bostrom. Deep reinforcement learning for multiparameter optimization in de novo drug design. Journal of chemical information and modeling, 59(7):3166–3176, 2019.
|
| 295 |
+
|
| 296 |
+
Robin Winter, Floriane Montanari, Frank Noé, and Djork-Arné Clevert. Learning continuous and data-driven molecular descriptors by translating equivalent chemical representations. Chemical science, 10(6):1692–1701, 2019a.
|
| 297 |
+
|
| 298 |
+
Robin Winter, Floriane Montanari, Andreas Steffen, Hans Briem, Frank Noé, and Djork-Arné Clevert. Efficient multi-objective molecular optimization in a continuous latent space. Chem. Sci., 10: 8016–8024, 2019b. doi: 10.1039/C9SC01928F. URL http://dx.doi.org/10.1039/ C9SC01928F.
|
| 299 |
+
|
| 300 |
+
Xarelto. Pubchem compound summary for cid 6433119, xarelto. November, 2021. URL https: //pubchem.ncbi.nlm.nih.gov/compound/6433119.
|
| 301 |
+
|
| 302 |
+
Yutong Xie, Chence Shi, Hao Zhou, Yuwei Yang, Weinan Zhang, Yong Yu, and Lei Li. Mars: Markov molecular sampling for multi-objective drug discovery. arXiv preprint arXiv:2103.10432, 2021.
|
| 303 |
+
|
| 304 |
+
Chencheng Xu, Qiao Liu, Minlie Huang, and Tao Jiang. Reinforced molecular optimization with neighborhood-controlled grammars. arXiv preprint arXiv:2011.07225, 2020.
|
| 305 |
+
|
| 306 |
+
Keyulu Xu, Weihua Hu, Jure Leskovec, and Stefanie Jegelka. How powerful are graph neural networks? arXiv preprint arXiv:1810.00826, 2018.
|
| 307 |
+
|
| 308 |
+
Jiaxuan You, Bowen Liu, Rex Ying, Vijay Pande, and Jure Leskovec. Graph convolutional policy network for goal-directed molecular graph generation. arXiv preprint arXiv:1806.02473, 2018.
|
| 309 |
+
|
| 310 |
+
# A BACKGROUND: GRAPH NEURAL NETWORKS
|
| 311 |
+
|
| 312 |
+
In this work we consider graphs $\mathcal { G } = ( \nu , \mathcal { E } )$ with vertices $\nu$ and edges $\mathcal { E }$ . In the case of molecules, edges $\mathcal { E }$ correspond to bonds between pairs of atoms, and are thus typed, with each bond being either single, double or triple. Formally
|
| 313 |
+
|
| 314 |
+
$$
|
| 315 |
+
\mathcal { E } \subseteq \mathcal { V } \times \{ \mathsf { s i n g l e } , \mathsf { d o u b l e } , \mathsf { t r i p l e } \} \times \mathcal { V }
|
| 316 |
+
$$
|
| 317 |
+
|
| 318 |
+
Note that while cheminformatics tools such as RDKit also distinguish a fourth type of bonds, called aromatic, generating aromatic rings in a step-by-step fashion is known to be challenging (Jin et al., 2018). Thus, during preprocessing we convert aromatic rings to alternating single and double bonds, following a process called kekulization.
|
| 319 |
+
|
| 320 |
+
Given $\mathcal { G }$ , we learn node and graph representations using Graph Neural Networks. The network begins with starting node representations $\{ \bar { h } _ { v } ^ { 0 } : v \in \mathcal { V } \}$ ; in our case, we set these to linear projections of the node features $h _ { v } ^ { ( i n i t ) }$ . Each GNN layer propagates node representations $\{ h _ { v } ^ { t } : v \in \mathcal { V } \}$ to compute $\{ h _ { v } ^ { t + 1 } : v \in \mathcal { V } \}$ using message passing (Gilmer et al., 2017):
|
| 321 |
+
|
| 322 |
+
$$
|
| 323 |
+
h _ { v } ^ { t + 1 } = f ( h _ { v } ^ { t } , \mathsf { a g g r e g a t e } ( \{ m _ { \ell } ( h _ { v } ^ { t } , h _ { u } ^ { t } ) : ( v , \ell , u ) \in \mathscr { E } \} ) )
|
| 324 |
+
$$
|
| 325 |
+
|
| 326 |
+
where $m _ { \ell }$ computes the message between two nodes connected by an edge of type $\ell$ , aggregate combines all messages received by a given node, and $f$ computes the new node representation given the old representation and the aggregated messages. A common choice is to use a linear layer for every $m _ { l }$ , a pointwise sum for aggregate, and a GRU update for $f$ (Li et al., 2015), but many other variants exist (Brockschmidt, 2020; Corso et al., 2020).
|
| 327 |
+
|
| 328 |
+
After $L$ layers of message passing we obtain final representations $\{ h _ { v } ^ { L } \ : \ v \ \in \ \mathcal { V } \}$ , with $h _ { v } ^ { L }$ summarizing the $L$ -hop neighborhood of $v$ . These representations can be pooled to form a graph-level representation by using any permutation-invariant aggregator, such as a weighted sum.
|
| 329 |
+
|
| 330 |
+
# B ARCHITECTURE
|
| 331 |
+
|
| 332 |
+
The backbone of our architecture consists of two GNNs: one used to encode the input molecule, and the other used to encode the current partial graph. Both GNNs have the same architecture, but are otherwise completely separate, and do not share any parameters.
|
| 333 |
+
|
| 334 |
+
To implement our GNNs, we employ the GNN-MLP layer (Brockschmidt, 2020). We use 12 layers with separate parameters, Leaky ReLU non-linearities (Maas et al., 2013), and LayerNorm (Ba et al., 2016) after every GNN layer. If using motifs, we concatenate the atom features with a motif embedding of size 64, and then linearly project the result back into 64 dimensions. We use 64 as the hidden dimension throughout all GNN layers, guided by early experiments showing that wider hidden representations were less beneficial than a deeper GNN. Moreover, to improve the flow of gradients in the GNNs, we produce the final node-level feature vectors by concatenating both initial and intermediate node representations across all layers, resulting in feature vectors of size $6 4 \cdot 1 3 = 8 3 2$ . Intuitively, this concatenation serves as a skip connection that shortens the path from the node features to the final representation.
|
| 335 |
+
|
| 336 |
+
To pool node-level representations into a graph-level representation, we use an expressive multiheaded aggregation scheme. The $i$ -th aggregation head consists of two MLPs: $s ^ { i }$ which computes a scalar aggregation score, and $t ^ { i }$ which computes a transformed version of the node representation. These are then used to compute the $i$ -th graph-level output $o ^ { i }$ according to
|
| 337 |
+
|
| 338 |
+
$$
|
| 339 |
+
\begin{array} { r c l } { w ^ { i } } & { = } & { \mathsf { n o r m a l i z e } ( \{ s ^ { i } ( h _ { v } ) : v \in \mathcal { V } \} ) } \\ { o ^ { i } } & { = } & { \displaystyle \sum _ { v \in \mathcal { V } } w _ { v } ^ { i } \cdot t ^ { i } ( h _ { v } ) } \end{array}
|
| 340 |
+
$$
|
| 341 |
+
|
| 342 |
+
Specifically, we compute the scores $s ^ { i } ( h _ { v } )$ for all of the nodes, normalize across the graph using normalize, and then use them to construct a weighted sum of the transformed representations $t ^ { i } ( h _ { v } )$ . For the normalization function we consider either passing the scores through a softmax (which results in a head that implements a weighted mean) or a sigmoid (weighted sum). We use 32 heads for the encoder GNN, and 16 heads for the partial graphs GNN. In both cases, half of the heads use a softmax normalization, while the other half uses sigmoid. The outputs from all heads are concatenated to form the final graph-level vector; as different heads use different normalization functions (softmax or sigmoid), this is in spirit related to Principal Neighborhood Aggregation (Corso et al., 2020), but here used for graph-level readout instead of aggregating node-level messages.
|
| 343 |
+
|
| 344 |
+
Our node aggregation layer allows to construct a powerful graph-level representation; its dimensionality can be adjusted by varying the number of heads and the output dimension of the transformations $t _ { i }$ . For input graphs we use a 512-dimensional graph-level representation (which is then transformed to produce the mean and standard deviation of a 512-dimensional latent code $z$ ), and for partial graphs we use 256 dimensions.
|
| 345 |
+
|
| 346 |
+
To implement the functions used in our decoder procedure (i.e., the neural networks implementing PickAtomOrMotif, PickAttachment, and PickBond in Algorithm 1), we use simple multilayer perceptrons (MLPs).
|
| 347 |
+
|
| 348 |
+
The MLP for PickAtomOrMotif has to output a distribution over all atom and motif types and the special END_GEN option. As input, it receives the latent code $z$ and the partial molecule representation $h _ { m o l }$ . As the number of choices is large, we use hidden layers which maintain high dimensionality (two hidden layers with dimension 256). Predicting the type of the first node in an empty graph would require encoding an empty partial molecule to obtain $h _ { m o l }$ ; in practice, we side-step this technicality by using a separate MLP to predict the first node type, which takes as input only the latent encoding $z$ .
|
| 349 |
+
|
| 350 |
+
In contrast, the networks for PickAttachment and PickBond are used as scorers (i.e. need to output a single value), therefore we use MLPs with hidden layers that gradually reduce dimensionality (concretely, three hidden layers with dimension 128, 64, 32, respectively). The MLPs for PickAttachment and PickBond take the latent code $z$ , the partial molecule representation $h _ { m o l }$ , and the representation $h _ { v }$ of each scored candidate node $v$ . Finally, PickBond not only needs to predict the partner of a bond, but also one of three bond types (single, double and triple); for that we use an additional MLP with the same architecture as the scoring network, but used for classification.
|
| 351 |
+
|
| 352 |
+
# C TRAINING AND INFERENCE
|
| 353 |
+
|
| 354 |
+
We train our model using the Adam optimizer (Kingma & Ba, 2014). We found that adding an initial warm-up phase for the KL loss coefficient $\lambda _ { p r i o r }$ (i.e. increasing it from 0 to a target value over the course of training) helps to stabilize the model. However, our warm-up phase is relatively short: we reach the target $\lambda _ { p r i o r }$ in 5000 training steps, whereas full convergence requires around $2 0 0 0 0 0$ steps. This is in contrast to Jin et al. (2018), which varies $\lambda _ { p r i o r }$ (also referred to as $\beta$ ) uniformly over the entire training. A short warm-up phase is beneficial, as it allows to perform early stopping based on reaching a plateau in validation loss; this cannot be done while $\lambda _ { p r i o r }$ is being varied, as there is no clear notion of improvement if the training objective is changing.
|
| 355 |
+
|
| 356 |
+
When constructing minibatches during training, we combine the molecular graphs until a limit of $2 5 0 0 0$ nodes is reached. We cap the total number of nodes rather than the total number of molecules, as that is more robust to varying sizes of molecules in the training data.
|
| 357 |
+
|
| 358 |
+
# C.1 HYPERPARAMETER TUNING
|
| 359 |
+
|
| 360 |
+
Due to a very large design space of GNNs, we performed only limited hyperparameter tuning during preliminary experiments. In our experience, improving the modeling (e.g. changing the motif vocabulary or generation order) tends to have a larger impact than tuning low-level GNN architectural choices. For hyperparameters describing the expressiveness of the model, such as the number of layers or hidden representation size, we set them to reasonably high values, which is feasible as our model is very efficient to train. We did not make an attempt to reduce model size; it is likely that a smaller model would give equivalent downstream performance.
|
| 361 |
+
|
| 362 |
+
One parameter that we found to be tricky to tune is the $\lambda _ { p r i o r }$ coefficient that weighs the $\mathcal { L } _ { p r i o r }$ loss term. An additional complication stems from the fact that we compute $\mathcal { L } _ { r e c }$ as an average over the generation steps instead of a sum. While we made this design choice to make the loss scaling robust to training steps subsampling (i.e. $\lambda _ { p r i o r }$ does not have to be adjusted if we use only a subset of steps at training time), it led to decreased robustness when the difficulty of an average step varies between experiments. Concretely, when a larger motif vocabulary is used, generating a molecule entails fewer steps, but those steps are harder on average, since the underlying classification tasks distinguish between more classes. In preliminary experiments, we noticed the optimal value of $\lambda _ { p r i o r }$ increased with vocabulary size, closely following a logarithmic trend: doubling the motif vocabulary size translated to the optimum $\lambda _ { p r i o r }$ increasing by 0.005. For vocabulary sizes up to 32 we used $\lambda _ { p r i o r } = 0 . 0 1$ , and then followed the logarithmic trend described here. Note that, due to differences in the loss definitions, our value of $\lambda _ { p r i o r }$ is not directly comparable to the values for $\beta$ in $\beta$ -VAE works.
|
| 363 |
+
|
| 364 |
+
Finally, varying the generation order and the size of the motif vocabulary explores different performance trade-offs depending on the downstream task. For all optimization benchmarks in Section 3 we used 128 motifs; moreover, we chose the BFS order with a random starting point for unconstrained optimization, and the fully random order for scaffold-constrained optimization.
|
| 365 |
+
|
| 366 |
+
# C.2 SOFTWARE AND HARDWARE
|
| 367 |
+
|
| 368 |
+
We performed all experiments on a single GPU. For all measurements in Table 1, we used a machine with a single Tesla K80 GPU. Our own implementations (MoLeR, CGVAE) are based on TensorFlow 2 (Abadi et al., 2016), while the models of Jin et al. (2018; 2020) (JT-VAE, HierVAE) use PyTorch (Paszke et al., 2019).
|
| 369 |
+
|
| 370 |
+
Training MoLeR requires first preprocessing the data, which takes up to one CPU day for GuacaMol, followed by training itself, which takes up to a few GPU days. While the generation benchmarks are cheap to run, optimization benchmarks are typically expensive. Each individual optimization benchmark takes between 6 and 130 hours of GPU time, depending on the details of the scoring function and size of the molecules that the algorithm ends up exploring. In particular, scaffold-based optimization benchmarks on average tend to be more compute intensive, as for full correctness the scoring functions need to verify that the scaffold is present (even though with MoLeR it is guaranteed to be included).
|
| 371 |
+
|
| 372 |
+
# C.3 OPTIMIZATION
|
| 373 |
+
|
| 374 |
+
To perform optimization we used the original MSO code of Winter et al. (2019b); we found that the default hyperparameters already resulted in good performance. However, we made two modifications to the algorithms to make the interplay of MSO and MoLeR smoother.
|
| 375 |
+
|
| 376 |
+
Deterministic encoding Despite being a black-box optimization method, MSO does use the encoder part of the generative model: first, to encode the seed molecules, but more interestingly, to re-encode molecules found in each step of optimization, adjusting the particle positions as $x \gets$ encode(decode $( x ) _ { , }$ ); we hypothesise that the latter was introduced to "snap back" the particles to the latent space region "preferred" by the encoder. Unlike CDDD, MoLeR is a variational autoencoder, thus by design the encoding process is non-deterministic; this randomness interacts badly with MSO’s re-encoding. Therefore, for all of our optimization experiments we made the MoLeR encoder deterministic by always returning the maximum likelihood latent code $z$ (which coincides with the mean of the predicted Gaussian).
|
| 377 |
+
|
| 378 |
+
Latent code clipping One detail of MSO that we adapted to MoLeR is clipping of the particles’ latent coordinates. Winter et al. (2019b) clip to a hypercube $[ - 1 , 1 ] ^ { D }$ where $D = 5 1 2$ is the latent space dimension; while this makes sense for an unregularized autoencoder such as CDDD, the output of MoLeR’s encoder is regularized through the $\mathcal { L } _ { p r i o r }$ loss term. Concretely, the mean of the distribution predicted by the encoder is penalized proportionally to its norm. This suggests that a ball may better approximate the encoder’s distribution than a hypercube, which we indeed found to hold in practice. Therefore, for MoLeR we clip to a ball of fixed radius $R = 1 0$ ; on the GuacaMol benchmarks (Brown et al., 2019) this modification alone improved MoLeR’s score from 0.77 to 0.82, while also improving quality from 0.74 to 0.76. We chose the radius $R$ so that almost all encodings of training set molecules land within the corresponding ball.
|
| 379 |
+
|
| 380 |
+
# D SAMPLES FROM THE PRIOR
|
| 381 |
+
|
| 382 |
+

|
| 383 |
+
Figure 6: Samples from the prior of a trained MoLeR model.
|
| 384 |
+
|
| 385 |
+
# E SCAFFOLD-BASED OPTIMIZATION BENCHMARKS
|
| 386 |
+
|
| 387 |
+
Our new scaffold-based benchmarks were inspired by real-world clinical candidates or marketed drugs, and employ large challenging scaffolds. The format closely follows the one used for tasks in Guacamol (Brown et al., 2019); in all cases, the score is a task-specific real number in the [0, 1] range, with higher values being better, indicating how well the given molecules match a target molecular profile. To measure quality, we used the same quality filters as Brown et al. (2019).
|
| 388 |
+
|
| 389 |
+

|
| 390 |
+
|
| 391 |
+
We designed four tasks, three of which ask to maximize similarity towards a fixed target molecule (which may already have some of the required properties we care about in a drug discovery project e.g. binding), while enforcing the presence of a scaffold (which is not present in the target, making the task non-trivial). In real-world drug design, this scenario is known as scaffold hopping. Finally, the fourth task, apart from a scaffold, uses two target molecules, maximizing structural similarity to one (Xarelto), while maintaining the properties of the other (Apixaban). In Table 3 we show all molecules used to define our tasks, along with references to the PubChem database. The target molecules have been inspired by existing drugs, however, to make the tasks harder, have in most cases been structurally modified such that they are not present in the Guacamol dataset, which is used by some of the algorithms (e.g. GraphGA, SMILES LSTM) to select the set of starting molecules.
|
| 392 |
+
|
| 393 |
+
# F LATENT SPACE NEIGHBORHOOD
|
| 394 |
+
|
| 395 |
+
In this section, we present more details on the latent space neighborhood learned by MoLeR. For the purpose of this analysis we fixed a scaffold (PubChem CID 57732551), and chose an arbitrary molecule $m$ that contains it. In order to visualize the neighborhood of $m$ , we encode it, and then decode a $5 \times 5$ grid of neighboring latent codes centered at the encoding of $m$ . To produce the grid, we choose two random orthogonal directions in the latent space, and then use binary search to select the smallest step size which results in all 25 latent points decoding to distinct molecules. We show the resulting latent neighborhood in Figure 7, where the scaffold is highlighted in each molecule. We see that the model is able to produce reasonable variations of $m$ , while maintaining local smoothness, as most adjacent pairs of molecules are very similar. Moreover, we notice that the left-to-right direction is correlated with size, showing that the latent space respects basic chemical properties. If the same 25 latent codes are decoded without the scaffold constraint, only 9 of them end up containing the scaffold, while the other 16 contain similar but different substructures.
|
| 396 |
+
|
| 397 |
+

|
| 398 |
+
Figure 7: Latent space neighborhood of a fixed molecule containing a chemically relevant scaffold. Each latent code is decoded under a scaffold constraint, so that the desired scaffold (highlighted in red) is present in each molecule.
|
| 399 |
+
|
| 400 |
+
# G LEARNED MOTIF REPRESENTATIONS
|
| 401 |
+
|
| 402 |
+
To extract learned motif representations from a trained MoLeR model, we could use any of its weights that are motif-specific. We first examine the embedding layer in the encoder, which is used to construct atom features. Interestingly, we find that these embeddings do not cluster in any way, and even very similar motifs are assigned distant embeddings. We hypothesize that this is due to the use of a simple classification loss function for $\mathcal { L } _ { r e c }$ , which asks to recover the exact motif type, and does not give a smaller penalty for predicting an incorrect but similar motif. Therefore, for two motifs that are similar on the atom level, it may be beneficial to place their embeddings further apart, since otherwise it would be hard for the GNN to differentiate them at all. We hope this observation can inspire future work to scale to very large motif vocabularies, but use domain knowledge to craft a soft reconstruction loss that respects motif similarity.
|
| 403 |
+
|
| 404 |
+
Now, we turn to a different set of motif embeddings, which we extract from the last layer of the next node prediction MLP in the decoder. This results in one weight vector per every output class (i.e. atom and motif type); in contrast to the encoder-side embeddings, the role of these weight vectors is prediction rather than encoding. We find that pairs of motif embeddings that have high cosine similarity indeed correspond to very similar motifs, which often differ in very subtle details of the molecular graph. We show some of the closest pairs in Figure 8.
|
| 405 |
+
|
| 406 |
+

|
| 407 |
+
Figure 8: Six pairs of similar motifs (one per column), as extracted from weights of a trained MoLeR model.
|
| 408 |
+
|
| 409 |
+
Finally, note that the motif embeddings discussed here (both encoder side and decoder side) were trained end-to-end with the rest of the model, and did not have direct access to graph structure or chemical features of motifs. Therefore, there is no bias that would make embeddings of similar motifs close, and this can only arise as a consequence of training.
|
| 410 |
+
|
| 411 |
+
# H EFFECT OF USING MOTIFS ON OPTIMIZATION PERFORMANCE
|
| 412 |
+
|
| 413 |
+
In Figure 2 we show how the choice of generation order and motif vocabulary size impact the samples generated by MoLeR. In Figure 9 we mirror this analysis, looking at optimization performance on both groups of tasks reported in Table 2: original tasks of Brown et al. (2019), and our scaffold-based tasks.
|
| 414 |
+
|
| 415 |
+
For unconstrained optimization, we see that using motifs generally improves results for most generation orders, but the trends are much more noisy than in the case of generation performance. We speculate this may be caused by the fact that MoLeR is not directly trained for optimization performance, and thus we see more variance between reruns due to randomness.
|
| 416 |
+
|
| 417 |
+
For scaffold-constrained optimization, we see some improvement when motifs are introduced $\left. 0 \right.$ 32), but there is no improvement with larger motif vocabularies, which we attribute to the fact that our scaffold-based tasks use very large scaffolds, and so their optimal decorations typically do not contain large or uncommon motifs. Finally, we note that MoLeR trained under a canonical order performs competitively in unconstrained optimization, but underperforms in scaffold-constrained optimization, matching the insights from Section 3.1.
|
| 418 |
+
|
| 419 |
+

|
| 420 |
+
Figure 9: Optimization performance (higher is better) for different generation orders and vocabulary sizes. We separately show the original GuacaMol benchmarks (left), and our new scaffold-based benchmarks (right).
|
| 421 |
+
|
| 422 |
+
# I ABLATION STUDIES
|
| 423 |
+
|
| 424 |
+
In this section, we perform ablation studies to understand the contribution of different design choices to MoLeR’s performance.
|
| 425 |
+
|
| 426 |
+
# I.1 ADDING MOTIF EMBEDDINGS AS INPUT FEATURES
|
| 427 |
+
|
| 428 |
+
In Section 2.1, we introduced motif embeddings, which allow the encoder network to be motif-aware without having to learn to simulate the motif decomposition algorithm. Since the decoder network must reassemble the molecule using the right motifs, it is crucial for the encoder to understand which motifs are present, and including this information explicitly simplifies the learning task.
|
| 429 |
+
|
| 430 |
+
To confirm this intuition, we ran two MoLeR training runs: one using motif embeddings, and one using only atom-level features. To compare the models, we observed how samples from the prior evolved over the course of training. Concretely, every 5 000 training steps we drew 10 000 samples from the prior of each model, and computed three metrics using the GuacaMol package (Brown et al., 2019): uniqueness (defined as a fraction of unique samples; higher is better), KL divergence to the training set (defined over several simple chemical properties and then transformed into the [0, 1] range; higher is better) and Frechet ChemNet Distance to the training set (defined as a divergence in intermediate activations of ChemNet; lower is better). We show the results of this in Figure 10. We see that without motif embeddings, MoLeR takes longer to learn to match the training data; this is most pronounced when comparing Frechet ChemNet distance.
|
| 431 |
+
|
| 432 |
+

|
| 433 |
+
Figure 10: Generation metrics during training, measured for MoLeR both with and without motif embeddings. Using motif embeddings simplifies the learning task, improving the quality of downstream samples.
|
| 434 |
+
|
| 435 |
+
# I.2 SUBSAMPLING GENERATION STEPS
|
| 436 |
+
|
| 437 |
+
In Section 2.4, we introduced generation step subsampling as a way to get more variety within each training batch. Intuitively, different generation steps can be thought of as separate training samples for the decoder network. As generation steps corresponding to the same full molecule are correlated, subsampling them decreases the intra-batch correlation.
|
| 438 |
+
|
| 439 |
+

|
| 440 |
+
Figure 11: Generation metrics during training, measured for MoLeR both with and without training step subsampling. Subsampling training steps leads to faster convergence on all downstream metrics.
|
| 441 |
+
|
| 442 |
+
To show that the subsampling strategy is effective in practice, we ran an ablation study, comparing MoLeR trained with and without subsampling, following the same methodology as in Appendix I.1. We show the results in Figure 11. We see that while both runs eventually reach roughly the same performance, the run employing subsampling coverges faster across all metrics; the difference is especially pronounced in the first few thousand training steps.
|
| 443 |
+
|
| 444 |
+

|
| 445 |
+
I.3 ENCOURAGING LATENT SPACE SMOOTHNESS WITH A PROPERTY PREDICTION LOSS
|
| 446 |
+
Figure 12: Mean difference in property value when decoding random pairs of latent codes with a given cosine similarity, shown for MoLeR both with and without the $\mathcal { L } _ { p r o p }$ loss. Adding the property prediction loss increases the correlation between latent space distance and property value.
|
| 447 |
+
|
| 448 |
+
Finally, we analyze the contribution of the $\mathcal { L } _ { p r o p }$ auxiliary loss to the shape of the latent space. In particular, we are interested in understanding whether the latent space is indeed “smooth” with respect to the predicted properties. To quantify this, we consider pairs of latent vectors with cosine similarity in the (0.9, 1.0) range, which we uniformly split into 8 buckets. We continue drawing pairs of samples and adding them to their respective buckets (or discarding them, if the similarity is less than 0.9), until each bucket has at least 1 000 pairs. For each bucket, we compute the mean absolute difference of molecular weight, synthetic accessibility (SA) score, and octanol-water partition coefficient (logP) between the two molecules of each pair and plot this in Figure 12. The results show that using the additional objective indeed makes molecules decoded from very similar latent codes have more similar properties.
|
md/dev/Zq2G_VTV53T/Zq2G_VTV53T.md
ADDED
|
@@ -0,0 +1,489 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# FASTSHAP: REAL-TIME SHAPLEY VALUE ESTIMATION
|
| 2 |
+
|
| 3 |
+
Neil Jethani∗ New York University
|
| 4 |
+
|
| 5 |
+
Mukund Sudarshan∗ New York University
|
| 6 |
+
|
| 7 |
+
Ian Covert∗ University of Washington
|
| 8 |
+
|
| 9 |
+
Su-In Lee University of Washington
|
| 10 |
+
|
| 11 |
+
Rajesh Ranganath New York University
|
| 12 |
+
|
| 13 |
+
# ABSTRACT
|
| 14 |
+
|
| 15 |
+
Although Shapley values are theoretically appealing for explaining black-box models, they are costly to calculate and thus impractical in settings that involve large, high-dimensional models. To remedy this issue, we introduce FastSHAP, a new method for estimating Shapley values in a single forward pass using a learned explainer model. To enable efficient training without requiring ground truth Shapley values, we develop an approach to train FastSHAP via stochastic gradient descent using a weighted least squares objective function. In our experiments with tabular and image datasets, we compare FastSHAP to existing estimation approaches and find that it generates accurate explanations with an orders-ofmagnitude speedup.
|
| 16 |
+
|
| 17 |
+
# 1 INTRODUCTION
|
| 18 |
+
|
| 19 |
+
With the proliferation of black-box models, Shapley values (Shapley, 1953) have emerged as a popular explanation approach due to their strong theoretical properties (Lipovetsky and Conklin, 2001; Štrumbelj and Kononenko, 2014; Datta et al., 2016; Lundberg and Lee, 2017). In practice, however, Shapley value-based explanations are known to have high computational complexity, with an exact calculation requiring an exponential number of model evaluations (Van den Broeck et al., 2021). Speed becomes a critical issue as models increase in size and dimensionality, and for the largest models in fields such as computer vision and natural language processing, there is an unmet need for significantly faster Shapley value approximations that maintain high accuracy.
|
| 20 |
+
|
| 21 |
+
Recent work has addressed the computational challenges with Shapley values using two main approaches. First, many works have proposed stochastic estimators (Castro et al., 2009; Štrumbelj and Kononenko, 2014; Lundberg and Lee, 2017; Covert et al., 2020) that rely on sampling either feature subsets or permutations; though often consistent, these estimators require many model evaluations and impose an undesirable trade-off between run-time and accuracy. Second, some works have proposed model-specific approximations, e.g., for trees (Lundberg et al., 2020) or neural networks (Shrikumar et al., 2017; Chen et al., 2018b; Ancona et al., 2019; Wang et al., 2021); while generally faster, these approaches can still require many model evaluations, often induce bias, and typically lack flexibility regarding the handling held-out features—a subject of ongoing debate in the field (Aas et al., 2019; Janzing et al., 2020; Frye et al., 2020; Covert et al., 2021).
|
| 22 |
+
|
| 23 |
+
Here, we introduce a new approach for efficient Shapley value estimation: to achieve the fastest possible run-time, we propose learning a separate explainer model that outputs precise Shapley value estimates in a single forward pass. Naïvely, such a learning-based approach would seem to require a large training set of ground truth Shapley values, which would be computationally intractable. Instead, our approach trains an explainer model by minimizing an objective function inspired by the Shapley value’s weighted least squares characterization (Charnes et al., 1988), which enables efficient gradient-based optimization.
|
| 24 |
+
|
| 25 |
+
Our contributions. We introduce FastSHAP, an amortized approach for generating real-time Shapley value explanations.1 We derive an objective function from the Shapley value’s weighted least squares characterization and investigate several ways to reduce gradient variance during training. Our experiments show that FastSHAP provides accurate Shapley value estimates with an ordersof-magnitude speedup relative to non-amortized estimation approaches. Finally, we also find that FastSHAP generates high-quality image explanations (fig. 1) that outperform gradient-based methods (e.g., IntGrad and GradCAM) on quantitative inclusion and exclusion metrics.
|
| 26 |
+
|
| 27 |
+

|
| 28 |
+
Figure 1: Explanations generated by each method for Imagenette images.
|
| 29 |
+
|
| 30 |
+
# 2 BACKGROUND
|
| 31 |
+
|
| 32 |
+
In this section, we introduce notation used throughout the paper and provide an overview of Shapley values and their weighted least squares characterization. Let $\mathbf x \in \mathcal X$ be a random vector consisting of $d$ features, or $\mathbf { x } = ( \mathbf { x } _ { 1 } , \ldots , \mathbf { x } _ { d } )$ , and let $\mathbf { y } \in \mathcal { Y } = \{ 1 , \dots , K \}$ be the response variable for a classification problem. We use $\mathbf { s } \in \{ 0 , 1 \} ^ { d }$ to denote subsets of the indices $\{ \bar { 1 } , \ldots , d \}$ and define $\mathbf { x } _ { s } : = \{ \mathbf { x } _ { i } \} _ { i : s _ { i } = 1 }$ . The symbols $\mathbf { x }$ , y, s are random variables and $x , y , s$ denote possible values. We use 1 and 0 to denote vectors of ones and zeros in $\mathbb { R } ^ { d }$ , so that $\mathbf { 1 } ^ { \top } \boldsymbol { s }$ is a subset’s cardinality, and we use $e _ { i }$ to denote the ith standard basis vector. Finally, $f ( \mathbf { x } ; \boldsymbol { \eta } ) : \mathcal { X } \mapsto \Delta ^ { K - 1 }$ is a model that outputs a probability distribution over y given $\mathbf { x }$ , and $f _ { y } ( \mathbf { x } ; \eta )$ is the probability for the yth class.
|
| 33 |
+
|
| 34 |
+
# 2.1 SHAPLEY VALUES
|
| 35 |
+
|
| 36 |
+
Shapley values were originally developed as a credit allocation technique in cooperative game theory (Shapley, 1953), but they have since been adopted to explain predictions from black-box machine learning models (Štrumbelj and Kononenko, 2014; Datta et al., 2016; Lundberg and Lee, 2017). For any value function (or set function) $v : 2 ^ { d } \mapsto \mathbb { R }$ , the Shapley values $\mathbf { \Phi } _ { \phi ( v ) } \mathbf { \bar { \Psi } } \in \mathbb { R } ^ { d }$ , o r $\phi _ { i } ( v ) \in \mathbb { R }$ for each feature $i = 1 , \ldots , d$ , are given by the formula
|
| 37 |
+
|
| 38 |
+
$$
|
| 39 |
+
\phi _ { i } ( v ) = \frac { 1 } { d } \sum _ { s _ { i } \neq 1 } { \binom { d - 1 } { \mathbf { 1 } ^ { \top } s } } ^ { - 1 } \Big ( v ( s + e _ { i } ) - v ( s ) \Big ) .
|
| 40 |
+
$$
|
| 41 |
+
|
| 42 |
+
The difference $v ( s + e _ { i } ) - v ( s )$ represents the ith feature’s contribution to the subset $s$ , and the summation represents a weighted average across all subsets that do not include $i$ . In the model explanation context, the value function is chosen to represent how an individual prediction varies as different subsets of features are removed. For example, given an input-output pair $( x , y )$ , the prediction for the $y$ th class can be represented by a value function $v _ { x , y }$ defined as
|
| 43 |
+
|
| 44 |
+
$$
|
| 45 |
+
v _ { x , y } ( s ) = \mathrm { l i n k } \left( \underset { p ( \mathbf { x _ { 1 } } - s ) } { \mathbb { E } } \left[ f _ { y } \left( x _ { s } , \mathbf { x _ { 1 - s } } ; \eta \right) \right] \right) ,
|
| 46 |
+
$$
|
| 47 |
+
|
| 48 |
+
where the held out features $\mathbf { x _ { 1 } } _ { - s }$ are marginalized out using their joint marginal distribution $p ( \mathbf { x _ { 1 } } _ { - s } )$ , and a link function (e.g., logit) is applied to the model output. Recent work has debated the properties of different value function formulations, particularly the choice of how to remove features (Aas et al., 2019; Janzing et al., 2020; Frye et al., 2020; Covert et al., 2021). However, regardless of the formulation, this approach to model explanation enjoys several useful theoretical properties due to its use of Shapley values: for example, the attributions are zero for irrelevant features, and they are guaranteed to sum to the model’s prediction. We direct readers to prior work for a detailed discussion of these properties (Lundberg and Lee, 2017; Covert et al., 2021).
|
| 49 |
+
|
| 50 |
+
Unfortunately, Shapley values also introduce computational challenges: the summation in eq. (1) involves an exponential number of subsets, which makes it infeasible to calculate for large $d$ . Fast approximations are therefore required in practice, as we discuss next.
|
| 51 |
+
|
| 52 |
+
# 2.2 KERNELSHAP
|
| 53 |
+
|
| 54 |
+
KernelSHAP (Lundberg and Lee, 2017) is a popular Shapley value implementation that relies on an alternative Shapley value interpretation. Given a value function $v _ { x , y } ( \mathbf { s } )$ , eq. (1) shows that the values $\phi ( v _ { x , y } )$ are the features’ weighted average contributions; equivalently, their weighted least squares characterization says that they are the solution to an optimization problem over $\phi _ { x , y } \in \mathbb { R } ^ { d }$ ,
|
| 55 |
+
|
| 56 |
+
$$
|
| 57 |
+
\begin{array} { r l } & { \boldsymbol { \phi } ( v _ { x , y } ) = \underset { \phi _ { x , y } } { \arg \operatorname* { m i n } } \ \underset { p ( \mathbf { s } ) } { \mathbb { E } } \left[ \left( v _ { x , y } ( \mathbf { s } ) - v _ { x , y } ( \mathbf { 0 } ) - \mathbf { s } ^ { \top } \phi _ { x , y } \right) ^ { 2 } \right] } \\ & { \mathrm { s . t . } \quad \mathbf { 1 } ^ { \top } \phi _ { x , y } = v _ { x , y } ( \mathbf { 1 } ) - v _ { x , y } ( \mathbf { 0 } ) , } \end{array}
|
| 58 |
+
$$
|
| 59 |
+
|
| 60 |
+
(Efficiency constraint)
|
| 61 |
+
|
| 62 |
+
where the distribution $p ( \mathbf { s } )$ is defined as
|
| 63 |
+
|
| 64 |
+
$$
|
| 65 |
+
p ( s ) \propto \frac { d - 1 } { \binom { d } { \mathbf { 1 } ^ { \top } s } \cdot \mathbf { 1 } ^ { \top } s \cdot ( d - \mathbf { 1 } ^ { \top } s ) }
|
| 66 |
+
$$
|
| 67 |
+
|
| 68 |
+
(Shapley kernel)
|
| 69 |
+
|
| 70 |
+
for $s$ such that $0 < \mathbf { 1 } ^ { \top } s < d$ (Charnes et al., 1988). Based on this view of the Shapley value, Lundberg and Lee (2017) introduced KernelSHAP, a stochastic estimator that solves an approximate version of eq. (3) given some number of subsets sampled from $p ( \mathbf { s } )$ . Although the estimator is consistent and empirically unbiased (Covert and Lee, 2021), KernelSHAP often requires many samples to achieve an accurate estimate, and it must solve eq. (3) separately for each input-output pair $( x , y )$ . As a result, it is unacceptably slow for some use cases, particularly in settings with large, high-dimensional models. Our approach builds on KernelSHAP, leveraging the Shapley value’s weighted least squares characterization to design a faster, amortized estimation approach.
|
| 71 |
+
|
| 72 |
+
# 3 FASTSHAP
|
| 73 |
+
|
| 74 |
+
We now introduce FastSHAP, a method that amortizes the cost of generating Shapley values across many data samples. FastSHAP has two main advantages over existing approaches: (1) it avoids solving separate optimization problems for each input to be explained, and (2) it can use similar data points to efficiently learn the Shapley value function $\phi ( v _ { x , y } )$ .
|
| 75 |
+
|
| 76 |
+
# 3.1 AMORTIZING SHAPLEY VALUES
|
| 77 |
+
|
| 78 |
+
In our approach, we propose generating Shapley value explanations using a learned parametric function $\phi _ { \mathrm { f a s t } } ( \mathbf { x } , \mathbf { y } ; \theta ) : \mathcal { \hat { X } } \times \mathcal { y } \mapsto \mathbb { R } ^ { d }$ . Once trained, the parametric function can generate explanations in a single forward pass, providing a significant speedup over methods that approximate Shapley values separately for each sample $( x , y )$ . Rather than using a dataset of ground truth Shapley values for training, we train $\phi _ { \mathrm { f a s t } } ( \mathbf { x } , \mathbf { y } ; \theta )$ by penalizing its predictions according to the weighted least squares objective in eq. (3), or by minimizing the following loss,
|
| 79 |
+
|
| 80 |
+
$$
|
| 81 |
+
\begin{array} { r } { \mathcal { L } ( \boldsymbol { \theta } ) = \underset { p ( \mathbf { x } ) } { \mathbb { E } } \underset { \mathrm { U n i f } ( \mathbf { y } ) } { \mathbb { E } } \underset { p ( \mathbf { s } ) } { \mathbb { E } } \left[ \left( v _ { \mathbf { x } , \mathbf { y } } ( \mathbf { s } ) - v _ { \mathbf { x } , \mathbf { y } } ( \mathbf { 0 } ) - \mathbf { s } ^ { \top } \phi _ { \mathrm { f a s t } } ( \mathbf { x } , \mathbf { y } ; \boldsymbol { \theta } ) \right) ^ { 2 } \right] , } \end{array}
|
| 82 |
+
$$
|
| 83 |
+
|
| 84 |
+
where $\operatorname { U n i f } ( \mathbf { y } )$ represents a uniform distribution over classes. If the model’s predictions are forced to satisfy the Efficiency constraint, then given a large enough dataset and a sufficiently expressive model class for $\phi _ { \mathrm { f a s t } }$ , the global optimizer $\phi _ { \mathrm { f a s t } } ( \mathbf { x } , \mathbf { y } ; \theta ^ { * } )$ is a function that outputs exact Shapley values (see proof in appendix A). Formally, the global optimizer satisfies the following:
|
| 85 |
+
|
| 86 |
+
$$
|
| 87 |
+
\phi _ { \mathrm { f a s t } } ( \mathbf { x } , \mathbf { y } ; \theta ^ { * } ) = \phi ( v _ { \mathbf { x } , \mathbf { y } } ) \mathrm { a l m o s t s u r e l y i n } p ( \mathbf { x } , \mathbf { y } ) .
|
| 88 |
+
$$
|
| 89 |
+
|
| 90 |
+
We explore two approaches to address the efficiency requirement. First, we can enforce efficiency by adjusting the Shapley value predictions using their additive efficient normalization (Ruiz et al., 1998), which applies the following operation to the model’s outputs:
|
| 91 |
+
|
| 92 |
+
$$
|
| 93 |
+
\phi _ { \mathrm { f a s t } } ^ { \mathrm { e f f } } ( x , y ; \theta ) = \phi _ { \mathrm { f a s t } } ( x , y ; \theta ) + \frac { 1 } { d } \underbrace { \Big ( v _ { x , y } ( \mathbf { 1 } ) - v _ { x , y } ( \mathbf { 0 } ) - \mathbf { 1 } ^ { \top } \phi _ { \mathrm { f a s t } } ( x , y ; \theta ) \Big ) } _ { \mathrm { E f f i c i e n c y \thinspace g a p } } .
|
| 94 |
+
$$
|
| 95 |
+
|
| 96 |
+
The normalization step can be applied at inference time and optionally during training; in appendix B, we show that this step is guaranteed to make the estimates closer to the true Shapley values. Second, we can relax the efficiency property by augmenting $\mathcal { L } ( \boldsymbol { \theta } )$ with a penalty on the efficiency gap (see eq. (6)); the penalty requires a parameter $\gamma > 0$ , and as we set $\gamma \to \infty$ we can guarantee that efficiency holds (see appendix A). Algorithm 1 summarizes our training approach.
|
| 97 |
+
|
| 98 |
+
Empirical considerations. Optimizing $\mathcal { L } ( \boldsymbol { \theta } )$ using a single set of samples $( x , y , s )$ is problematic because of high variance in the gradients, which can lead to poor optimization. We therefore consider several steps to reduce gradient variance. First, as is conventional in deep learning, we minibatch across multiple samples from $p ( \mathbf { x } )$ . Next, when possible, we calculate the loss jointly across all classes $y \in \{ 1 , \ldots , K \}$ . Then, we experiment with using multiple samples $s \sim p ( \mathbf { s } )$ for each input sample $x$ . Finally, we explore paired sampling, where each sample $s$ is paired with its complement $\mathbf { 1 } - s$ , which has been shown to reduce KernelSHAP’s variance (Covert and Lee, 2021). Appendix C shows proofs that these steps are guaranteed to reduce gradient variance, and ablation experiments in appendix D demonstrate their improvement on FastSHAP’s accuracy.
|
| 99 |
+
|
| 100 |
+
# 3.2 A DEFAULT VALUE FUNCTION FOR FASTSHAP
|
| 101 |
+
|
| 102 |
+
FastSHAP has the flexibility to work with any value function $v _ { x , y } ( \mathbf { s } )$ . Here, we describe a default value function that is useful for explaining predictions from a classification model.
|
| 103 |
+
|
| 104 |
+
The value function’s aim is to assess, for each subset $s$ , the classification probability when only the features $\mathbf { x } _ { s }$ are observed. Because most models $f ( \mathbf { x } ; \eta )$ do not support making predictions without all the features, we require an approximation that simulates the inclusion of only $\mathbf { x } _ { s }$ (Covert et al., 2021). To this end, we use a supervised surrogate model (Frye et al., 2020; Jethani et al., 2021) to approximate marginalizing out the remaining features $\mathbf { x _ { 1 } } _ { - s }$ using their conditional distribution.
|
| 105 |
+
|
| 106 |
+
# Algorithm 1: FastSHAP training
|
| 107 |
+
|
| 108 |
+
Input: Value function $v _ { x , y }$ , learning rate $\alpha$
|
| 109 |
+
Output: FastSHAP explainer $\phi _ { \mathrm { f a s t } } ( \mathbf { x } , \mathbf { y } ; \theta )$
|
| 110 |
+
initialize $\phi _ { \mathrm { f a s t } } ( \mathbf { x } , \mathbf { y } ; \theta )$
|
| 111 |
+
while not converged do sample $x \sim p ( \mathbf { x } )$ $( \mathbf { x } ) , y \sim \mathrm { U n i f } ( \mathbf { y } ) , s \sim p ( \mathbf { s } )$ predict $\hat { \phi } \phi _ { \mathrm { f a s t } } ( x , y ; \theta )$ if normalize then $\begin{array} { r l } & { \mathrm { s e t } \hat { \phi } } \\ & { \quad \hat { \phi } + d ^ { - 1 } ( v _ { x , y } ( { \bf 1 } ) - v _ { x , y } ( { \bf 0 } ) - { \bf 1 } ^ { T } \hat { \phi } ) } \end{array}$ end calculate $\begin{array} { r l } & { \quad \mathcal { L } \bigg ( v _ { x , y } ( s ) - v _ { x , y } ( \mathbf { 0 } ) - s ^ { T } \hat { \phi } \bigg ) ^ { 2 } } \\ & { \quad \mathrm { u p d a t e \ } \theta \theta - \alpha \nabla _ { \theta } \mathcal { L } } \end{array}$
|
| 112 |
+
end
|
| 113 |
+
|
| 114 |
+
Separate from the original model $f ( \mathbf { x } ; \eta )$ , the surrogate model $p _ { \mathrm { s u r r } } ( \mathbf { y } \mid m ( \mathbf { x } , \mathbf { s } ) ; \beta )$ takes as input a vector of masked features $m ( x , s )$ , where the masking function $m$ replaces features $x _ { i }$ such that $s _ { i } = 0$ with a $[ \mathrm { m a s k } ]$ value that is not in the support of $\mathcal { X }$ . Similar to prior work (Frye et al., 2020; Jethani et al., 2021), the parameters $\beta$ are learned by minimizing the following loss function:
|
| 115 |
+
|
| 116 |
+
$$
|
| 117 |
+
\begin{array} { r } { \mathcal { L } ( \beta ) = \underset { p ( { \mathbf x } ) } { \mathbb { E } } \underset { p ( { \mathbf s } ) } { \mathbb { E } } \left[ D _ { \mathrm { K L } } \big ( f ( { \mathbf x } ; \eta ) \mid \mid p _ { \mathrm { s u r r } } ( { \mathbf y } \mid m ( { \mathbf x } , { \mathbf s } ) ; \beta ) \big ) \right] . } \end{array}
|
| 118 |
+
$$
|
| 119 |
+
|
| 120 |
+
It has been shown that the global optimizer to eq. (7), or $p _ { \mathrm { s u r r } } ( \mathbf { y } \mid m ( \mathbf { x } , \mathbf { s } ) ; \beta ^ { * } )$ , is equivalent to marginalizing out features from $f ( \mathbf { x } ; \eta )$ with their conditional distribution (Covert et al., 2021):
|
| 121 |
+
|
| 122 |
+
$$
|
| 123 |
+
p _ { \mathrm { s u r r } } ( y \mid m ( x , s ) ; \beta ^ { * } ) = \mathbb { E } [ f _ { y } ( \mathbf { x } ; \boldsymbol { \eta } ) \mid \mathbf { x } _ { s } = x _ { s } ] .
|
| 124 |
+
$$
|
| 125 |
+
|
| 126 |
+
The choice of distribution over $p ( \mathbf { s } )$ does not affect the global optimizer of eq. (7), but we use the Shapley kernel to put more weight on subsets likely to be encountered when training FastSHAP. We use the surrogate model as a default choice for two reasons. First, it requires a single prediction for each evaluation of $v _ { x , y } ( s )$ , which permits faster training than the common approach of averaging across many background samples (Lundberg and Lee, 2017; Janzing et al., 2020). Second, it yields explanations that reflect the model’s dependence on the information communicated by each feature, rather than its algebraic dependence (Frye et al., 2020; Covert et al., 2021).
|
| 127 |
+
|
| 128 |
+
# 4 RELATED WORK
|
| 129 |
+
|
| 130 |
+
Recent work on Shapley value explanations has largely focused on how to remove features (Aas et al., 2019; Frye et al., 2020; Covert et al., 2021) and how to approximate Shapley values efficiently (Chen et al., 2018b; Ancona et al., 2019; Lundberg et al., 2020; Covert and Lee, 2021). Model-specific approximations are relatively fast, but they often introduce bias and are entangled with specific feature removal approaches (Shrikumar et al., 2017; Ancona et al., 2019; Lundberg et al., 2020). In contrast, model-agnostic stochastic approximations are more flexible, but they must trade off run-time and accuracy in the explanation. For example, KernelSHAP samples subsets to approximate the solution to a weighted least squares problem (Lundberg and Lee, 2017), while other approaches sample marginal contributions (Castro et al., 2009; Štrumbelj and Kononenko, 2014) or feature permutations (Illés and Kerényi, 2019; Mitchell et al., 2021). FastSHAP trains an explainer model to output an estimate that would otherwise require orders of magnitude more model evaluations, and, unlike other fast approximations, it is agnostic to the model class and feature removal approach.
|
| 131 |
+
|
| 132 |
+

|
| 133 |
+
Figure 2: Comparison of Shapley value approximation accuracy across methods. Using three datasets, we measure the distance of each method’s estimates to the ground truth as a function of the number of model evaluations. FastSHAP is represented by a horizontal line since it requires only a single forward pass. The baselines require $2 0 0 { - } 2 0 0 0 \times$ model evaluations to achieve FastSHAP’s level of accuracy.
|
| 134 |
+
|
| 135 |
+
Other methods have been proposed to generate explanations using learned explainer models. These are referred to as amortized explanation methods (Covert et al., 2021; Jethani et al., 2021), and they include several approaches that are comparable to gradient-based methods in terms of compute time (Dabkowski and Gal, 2017; Chen et al., 2018a; Yoon et al., 2018; Schwab and Karlen, 2019; Schulz et al., 2020; Jethani et al., 2021). Notably, one approach generates a training dataset of ground truth explanations and then learns an explainer model to output explanations directly (Schwab and Karlen, 2019)—a principle that can be applied with any attribution method, at least in theory. However, for Shapley values, generating a large training set would be very costly, so FastSHAP sidesteps the need for a training set using a custom loss function based on the Shapley value’s weighted least squares characterization (Charnes et al., 1988).
|
| 136 |
+
|
| 137 |
+
# 5 STRUCTURED DATA EXPERIMENTS
|
| 138 |
+
|
| 139 |
+
We analyze FastSHAP’s performance by comparing it to several well-understood baselines. First, we evaluate its accuracy on tabular (structured) datasets by comparing its outputs to the ground truth Shapley values. Then, to disentangle the benefits of amortization from the in-distribution value function, we make the same comparisons using different value function formulations $v _ { x , y } ( \mathbf { s } )$ . Unless otherwise stated, we use the surrogate model value function introduced in section 3.2. Later, in section 6, we test FastSHAP’s ability to generate image explanations.
|
| 140 |
+
|
| 141 |
+
Baseline methods. To contextualize FastSHAP’s accuracy, we compare it to several nonamortized stochastic estimators. First, we compare to KernelSHAP (Lundberg and Lee, 2017) and its acceleration that uses paired sampling (Covert and Lee, 2021). Next, we compare to a permutation sampling approach and its acceleration that uses antithetical sampling (Mitchell et al., 2021). As a performance metric, we calculate the proximity to Shapley values that were obtained by running KernelSHAP to convergence; we use these values as our ground truth because KernelSHAP is known to converge to the true Shapley values given infinite samples (Covert and Lee, 2021). These baselines were all run using an open-source implementation.2
|
| 142 |
+
|
| 143 |
+
Implementation details. We use either neural networks or tree-based models for each of $f ( \mathbf { x } ; \eta )$ and $p _ { \mathrm { s u r r } } ( \mathbf { y } \mid m ( \mathbf { x } , \mathbf { s } ) ; \beta )$ . The FastSHAP explainer model $\phi _ { \mathrm { f a s t } } ( \mathbf { x } , \mathbf { y } ; \theta )$ is implemented with a network $g ( \mathbf { x } ; \theta ) : \mathcal { X } \mathbb { R } ^ { d } \times \mathcal { Y }$ that outputs a vector of Shapley values for every $y \in \mathcal { V }$ ; deep neural networks are ideal for FastSHAP because they have high representation capacity, they can provide many-to-many mappings, and they can be trained by stochastic gradient descent. Appendix D contains more details about our implementation, including model classes, network architectures and training hyperparameters.
|
| 144 |
+
|
| 145 |
+

|
| 146 |
+
Figure 3: FastSHAP approximation accuracy for different value functions. Using the marketing dataset, we find that FastSHAP provides accurate Shapley value estimates regardless of the value function (surrogate, marginal, baseline), with the baselines requiring $2 0 0 { - } 1 0 0 0 \times$ model evaluations to achieve FastSHAP’s level of accuracy. Error bars represent $9 5 \%$ confidence intervals.
|
| 147 |
+
|
| 148 |
+
We also perform a series of experiments to determine several training hyperparameters for FastSHAP, exploring (1) whether or not to use paired sampling, (2) the number of subset samples to use, and (3) how to best enforce the efficiency constraint. Based on the results (see appendix D), we use the following settings for our tabular data experiments: we use paired sampling, between 32 and 64 samples of s per x sample, additive efficient normalization during both training and inference, and we set $\gamma = 0$ (since the normalization step is sufficient to enforce efficiency).
|
| 149 |
+
|
| 150 |
+
# 5.1 ACCURACY OF FASTSHAP EXPLANATIONS
|
| 151 |
+
|
| 152 |
+
Here, we test whether FastSHAP’s estimates are close to the ground truth Shapley values. Our experiments use data from a 1994 United States census, a bank marketing campaign, bankruptcy statistics, and online news articles (Dua and Graff, 2017). The census data contains 12 input features, and the binary label indicates whether a person makes over $\$ 50 K$ a year (Kohavi et al., 1996). The marketing dataset contains 17 input features, and the label indicates whether the customer subscribed to a term deposit (Moro et al., 2014). The bankruptcy dataset contains 96 features describing various companies and whether they went bankrupt (Liang et al., 2016). The news dataset contains 60 numerical features about articles published on Mashable, and our label indicates whether the share count exceeds the median number (1400) (Fernandes et al., 2015). The datasets were each split 80/10/10 for training, validation and testing.
|
| 153 |
+
|
| 154 |
+
In fig. 2, we show the distance of each method’s estimates to the ground truth as a function of the number of model evaluations for the news, census and bankruptcy datasets. Figure 3 shows results for the marketing dataset with three different value functions (see section 5.2). For the baselines, each sample s requires evaluating the model given a subset of features, but since FastSHAP requires only a single forward pass of $\phi _ { \mathrm { f a s t } } ( \mathbf { x } , \mathbf { y } ; \tilde { \theta ) }$ , we show it as a horizontal line.
|
| 155 |
+
|
| 156 |
+
To reach FastSHAP’s level of accuracy on the news, census and bankruptcy datasets, KernelSHAP requires between 1,200-2,000 model evaluations; like prior work (Covert and Lee, 2021), we find that paired sampling improves KernelSHAP’s rate of convergence, helping reach FastSHAP’s accuracy in 250-1,000 model evaluations. The permutation sampling baselines tend to be faster: the original version requires between 300-1,000 evaluations, and antithetical sampling takes 200-500 evaluations to reach an accuracy equivalent to FastSHAP. Across all four datasets, however, FastSHAP achieves its level of accuracy at least at least $6 0 0 \times$ faster than the original version of KernelSHAP, and $2 0 0 \times$ faster than the best non-amortized baseline.
|
| 157 |
+
|
| 158 |
+
# 5.2 DISENTANGLING AMORTIZATION AND THE CHOICE OF VALUE FUNCTION
|
| 159 |
+
|
| 160 |
+
In this experiment, we verify that FastSHAP produces accurate Shapley value estimates regardless of the choice of value function. We use the marketing dataset for this experiment and test the following value functions:
|
| 161 |
+
|
| 162 |
+
1. (Surrogate/In-distribution) $v _ { x , y } ( s ) = p _ { \mathrm { s u r r } } ( y \mid m ( x , s ) ; \beta )$
|
| 163 |
+
2. (Marginal/Out-of-distribution) $v _ { x , y } ( s ) = \mathbb { E } _ { p ( \mathbf { x _ { 1 } } - s ) } \left[ f _ { y } ( x _ { s } , \mathbf { x _ { 1 - } } _ { s } ; \eta ) \right]$
|
| 164 |
+
3. (Baseline removal) $v _ { x , y } ( s ) = f _ { y } ( x _ { s } , x _ { 1 - s } ^ { b } ; \eta )$ , where $x ^ { b } \in { \mathcal { X } }$ are fixed baseline values (the mean for continuous features and mode for discrete ones)
|
| 165 |
+
|
| 166 |
+

|
| 167 |
+
Figure 4: Explanations generated by each method for CIFAR-10 images.
|
| 168 |
+
|
| 169 |
+
In fig. 3 we compare FastSHAP to the same non-amortized baseline methods, where each method generates Shapley value estimates using the value functions listed above. The results show that FastSHAP maintains the same computational advantage across all three cases: to achieve the same accuracy as FastSHAP’s single forward pass, the baseline methods require at least 200 model evaluations, but in some cases up to nearly 1,000.
|
| 170 |
+
|
| 171 |
+
# 6 IMAGE EXPERIMENTS
|
| 172 |
+
|
| 173 |
+
Images represent a challenging setting for Shapley values due to their high dimensionality and the computational cost of model evaluation. We therefore compare FastSHAP to KernelSHAP on two image datasets. We also consider several widely used gradient-based explanation methods, because they are the most commonly used methods for explaining image classifiers.
|
| 174 |
+
|
| 175 |
+
# 6.1 DATASETS
|
| 176 |
+
|
| 177 |
+
We consider two popular image datasets for our experiments. CIFAR-10 (Krizhevsky et al., 2009) contains $6 0 { , } 0 0 0 \ 3 2 \times \ 3 2$ images across 10 classes, and we use 50,000 samples for training and 5,000 samples each for validation and testing. Each image is resized to $2 2 4 \times 2 2 4$ using bilinear interpolation to interface with the ResNet-50 architecture (He et al., 2016). Figure 4 shows example CIFAR-10 explanations generated by each method. The Imagenette dataset (Howard and Gugger, 2020), a subset of 10 classes from the ImageNet dataset, contains 13,394 total images. Each image is cropped to keep the $2 2 4 \times 2 2 4$ central region, and the data is split 9,469/1,963/1,962. Example Imagenette explanations are shown in fig. 1.
|
| 178 |
+
|
| 179 |
+
# 6.2 EXPLANATION METHODS
|
| 180 |
+
|
| 181 |
+
We test three Shapley value estimators, FastSHAP, KernelSHAP, and DeepSHAP (Lundberg and Lee, 2017), where the last is an existing approximation designed for neural networks. We test KernelSHAP with the zeros baseline value function, which we refer to simply as KernelSHAP, and with the in-distribution surrogate value function, which we refer to as KernelSHAP-S. We also compare these methods to the gradient-based explanation methods GradCAM (Selvaraju et al., 2017), SmoothGrad (Smilkov et al., 2017) and IntGrad (Sundararajan et al., 2017). Gradient-based methods are relatively fast and have therefore been widely adopted for explaining image classifiers. Finally, we also compare to CXPlain (Schwab and Karlen, 2019), an amortized explanation method that generates attributions that are not based on Shapley values.
|
| 182 |
+
|
| 183 |
+
Implementation details. The models $f ( \mathbf { x } ; \eta )$ and $p _ { \mathrm { s u r r } } ( \mathbf { y } \mid m ( \mathbf { x } , \mathbf { s } ) ; \beta )$ are both ResNet-50 networks (He et al., 2016) pretrained on ImageNet and fine-tuned on the corresponding imaging dataset. FastSHAP, CXPlain, and KernelSHAP are all implemented to output $1 4 \times 1 4$ superpixel attributions for each class. For FastSHAP, we parameterize $\phi _ { \mathrm { f a s t } } ( \mathbf { x } , \mathbf { y } ; \theta )$ to output superpixel attributions: we use an identical pretrained ResNet-50 but replace the final layers with a $1 \times 1$ convolutional layer so that the output is $1 4 \times 1 4 \times K$ (see details appendix D). We use an identical network to produce attributions for CXPlain. For FastSHAP, we do not use additive efficient normalization, and we set $\gamma = 0$ ; we find that this relaxation of the Shapley value’s efficiency property does not inhibit FastSHAP’s ability to produce high-quality image explanations. KernelSHAP and KernelSHAP-S are implemented using the shap3 package’s default parameters, and GradCAM, SmoothGrad, and IntGrad are implemented using the tf-explain4 package’s default parameters.
|
| 184 |
+
|
| 185 |
+
# 6.3 QUALITATIVE REMARKS
|
| 186 |
+
|
| 187 |
+
Explanations generated by each method are shown in fig. 4 for CIFAR-10 and fig. 1 for Imagenette (see appendix E for more examples). While a qualitative evaluation is insufficient to draw conclusions about each method, we offer several remarks on these examples. FastSHAP, and to some extent GradCAM, appear to reliably highlight the important objects, while the KernelSHAP explanations are noisy and fail to localize important regions. To a lesser extent, CXPlain occasionally highlights important regions. In comparison, the remaining methods (SmoothGrad, IntGrad and DeepSHAP) are granulated and highlight only small parts of the key objects. Next, we consider quantitative metrics that test these observations more systematically.
|
| 188 |
+
|
| 189 |
+
# 6.4 QUANTITATIVE EVALUATION
|
| 190 |
+
|
| 191 |
+
Evaluating the quality of Shapley value estimates requires access to ground truth Shapley values, which is computationally infeasible for images. Instead, we use two metrics that evaluate an explanation’s ability to identify informative image regions. These metrics build on several recent proposals (Petsiuk et al., 2018; Hooker et al., 2018; Jethani et al., 2021) and evaluate the model’s classification accuracy after including or excluding pixels according to their estimated importance.
|
| 192 |
+
|
| 193 |
+
Similar to Jethani et al. (2021), we begin by training a single evaluation model $p _ { \mathrm { e v a l } }$ to approximate the $f ( \mathbf { x } ; \eta )$ model’s output given a subset of features; this serves as an alternative to training separate models on each set of features (Hooker et al., 2018) and offers a more realistic option than masking features with zeros (Schwab and Karlen, 2019). This procedure is analogous to the $p _ { \mathrm { s u r r } }$ training procedure in section 3.2, except it sets the subset distribution to $p ( \mathbf { s } ) = \bar { \mathrm { U n i f o r m } ( \{ 0 , 1 \} ^ { d } ) }$ to ensure all subsets are equally weighted.
|
| 194 |
+
|
| 195 |
+
Next, we analyze how the model’s predictions change as we remove either important or unimportant features according to each explanation. Using a set of 1,000 images, each image is first labeled by the original model $f ( \mathbf { x } ; \eta )$ using the most likely predicted class. We then use explanations generated by each method to produce feature rankings and compute the top-1 accuracy (a measure of agreement with the original model) as we either include or exclude the most important features, ranging from 0-
|
| 196 |
+
|
| 197 |
+

|
| 198 |
+
Figure 5: Imagenette inclusion and exclusion curves. The change in top-1 accuracy as an increasing percentage of the pixels estimated to be important are excluded (top) or included (bottom).
|
| 199 |
+
|
| 200 |
+
$100 \%$ . The area under each curve (AUC) is termed the Inclusion AUC or Exclusion AUC.
|
| 201 |
+
|
| 202 |
+
These metrics match the idea that an accurate image explanation should (1) maximally degrade the performance of $p _ { \mathrm { e v a l } }$ when important features are excluded, and (2) maximally improve the performance of $p _ { \mathrm { e v a l } }$ when important features are included (Petsiuk et al., 2018; Hooker et al., 2018). The explanations are evaluated by removing superpixels; for gradient-based methods, we coarsen the explanations using the sum total importance within each superpixel. In appendix E, we replicate these metrics using log-odds rather than top-1 accuracy, finding a similar ordering among methods.
|
| 203 |
+
|
| 204 |
+
Results. Table 1 shows the Inclusion and Exclusion AUC achieved by each method for both CIFAR-10 and Imagenette. In fig. 5, we also present the curves used to generate these AUCs for Imagenette. Lower Exclusion AUCs and higher Inclusion AUCs are better. These results show that FastSHAP outperforms all baseline methods when evaluated with Exclusion AUC: when the pixels identified as important by FastSHAP are removed from the images, the sharpest decline in top-1 accuracy is observed. Additionally, FastSHAP performs well when evaluated on the basis of Inclusion AUC, second only to KernelSHAP-S.
|
| 205 |
+
|
| 206 |
+
Table 1: Exclusion and Inclusion AUCs. Evaluation of each method on the basis of Exclusion AUC (lower is better) and Inclusion AUC (higher is better) calculated using top-1 accuracy. Parentheses indicate $9 5 \%$ confidence intervals, and the best methods are bolded in each column.
|
| 207 |
+
|
| 208 |
+
<table><tr><td rowspan="2"></td><td colspan="2">CIFAR-10</td><td colspan="2">Imagenette</td></tr><tr><td>Exclusion AUC</td><td>Inclusion AUC</td><td>Exclusion AUC</td><td>Inclusion AUC</td></tr><tr><td>FastSHAP</td><td>0.42 (0.41, 0.43)</td><td>0.78 (0.77, 0.79)</td><td>0.51 (0.49, 0.52)</td><td>0.79 (0.78, 0.80)</td></tr><tr><td>KernelSHAP</td><td>0.64 (0.63, 0.65)</td><td>0.78 (0.77, 0.79)</td><td>0.68 (0.67, 0.70)</td><td>0.77 (0.75, 0.78)</td></tr><tr><td>KernelSHAP-S</td><td>0.54 (0.52, 0.55)</td><td>0.86 (0.85, 0.87)</td><td>0.61 (0.60, 0.62)</td><td>0.82 (0.80, 0.83)</td></tr><tr><td>GradCAM</td><td>0.52 (0.51, 0.53)</td><td>0.76 (0.75, 0.77)</td><td>0.52 (0.50, 0.53)</td><td>0.74 (0.73,0.76)</td></tr><tr><td>Integrated Gradients</td><td>0.55 (0.54, 0.56)</td><td>0.74 (0.73, 0.75)</td><td>0.65 (0.64, 0.67)</td><td>0.73 (0.71, 0.74)</td></tr><tr><td>SmoothGrad</td><td>0.70 (0.69, 0.71)</td><td>0.72 (0.71, 0.73)</td><td>0.72 (0.71, 0.73)</td><td>0.73 (0.72, 0.75)</td></tr><tr><td>DeepSHAP</td><td>0.65 (0.64, 0.66)</td><td>0.79 (0.78, 0.80)</td><td>0.69 (0.68, 0.71)</td><td>0.74 (0.73, 0.75)</td></tr><tr><td>CXPlain</td><td>0.56 (0.55, 0.57)</td><td>0.71 (0.70, 0.72)</td><td>0.60 (0.58, 0.61)</td><td>0.72 (0.71, 0.74)</td></tr></table>
|
| 209 |
+
|
| 210 |
+
For Imagenette, GradCAM performs competitively with FastSHAP on Exclusion AUC and KernelSHAP-S marginally beats FastSHAP on Inclusion AUC. KernelSHAP-S also outperforms on Inclusion AUC with CIFAR-10, which is perhaps surprising given its high level of noise (fig. 4). However, KernelSHAP-S does not do as well when evaluated using Exclusion AUC, and GradCAM does not do as well on Inclusion AUC. The remaining methods are, by and large, not competitive on either metric (except DeepSHAP on CIFAR-10 Inclusion AUC). An accurate explanation should perform well on both metrics, so these results show that FastSHAP provides the most versatile explanations, because it is the only approach to excel at both Inclusion and Exclusion AUC.
|
| 211 |
+
|
| 212 |
+
Finally, we also test FastSHAP’s robustness to limited training data. In appendix E, we find that FastSHAP outperforms most baseline methods on Inclusion and Exclusion AUC when using just $2 5 \%$ of the Imagenette data, and that it remains competitive when using just $10 \%$ .
|
| 213 |
+
|
| 214 |
+
# 6.5 SPEED EVALUATION
|
| 215 |
+
|
| 216 |
+
The image experiments were run using 8 cores of an Intel Xeon Gold 6148 processor and a single NVIDIA Tesla V100. Table 2 records the time required to explain 1,000 images. For FastSHAP, KernelSHAP-S and CXPlain, we also report the time required to train the surrogate and/or explainer models.
|
| 217 |
+
|
| 218 |
+
The amortized explanation methods, FastSHAP and CXPlain, incur a fixed training cost but very low marginal cost for each explanation. The gradient-based methods are slightly slower, but KernelSHAP requires significantly more time. These results suggest that FastSHAP is well suited for real-time applications where it is cru
|
| 219 |
+
|
| 220 |
+
Table 2: Training and explanation run-times for 1,000 images (in minutes).
|
| 221 |
+
|
| 222 |
+
<table><tr><td colspan="2"></td><td>CIFAR-10</td><td>Imagenette</td></tr><tr><td rowspan="5">rdg</td><td>FastSHAP</td><td>0.04</td><td>0.04</td></tr><tr><td>KernelSHAP</td><td>453.69</td><td>1089.50</td></tr><tr><td>KernelSHAP-S</td><td>460.10</td><td>586.12</td></tr><tr><td>GradCAM IntGrad</td><td>0.38 0.91</td><td>0.30 0.92</td></tr><tr><td>SmoothGrad DeepSHAP</td><td>1.00 5.39</td><td>1.05 6.01</td></tr><tr><td rowspan="3">TTTrm</td><td>CXPlain</td><td>0.04</td><td>0.04</td></tr><tr><td>FastSHAP</td><td>693.57</td><td>146.49</td></tr><tr><td>KernelSHAP-S CXPlain</td><td>362.03 538.49</td><td>73.22 93.00</td></tr></table>
|
| 223 |
+
|
| 224 |
+
cial to keep explanation times as low as possible. Further, when users need to explain a large quantity of data, FastSHAP’s low explanation cost can quickly compensate for its training time.
|
| 225 |
+
|
| 226 |
+
# 7 DISCUSSION
|
| 227 |
+
|
| 228 |
+
In this work, we introduced FastSHAP, a method for estimating Shapley values in a single forward pass using a learned explainer model. To enable efficient training, we sidestepped the need for a training set and derived a learning approach from the Shapley value’s weighted least squares characterization. Our experiments demonstrate that FastSHAP can produce accurate Shapley value estimates while achieving a significant speedup over non-amortized approaches, as well as more accurate image explanations than popular gradient-based methods.
|
| 229 |
+
|
| 230 |
+
While Shapley values provide a strong theoretical grounding for model explanation, they have not been widely adopted for explaining large-scale models due to their high computational cost. FastSHAP can solve this problem, making fast and high-quality explanations possible in fields such as computer vision and natural language processing. By casting model explanation as a learning problem, FastSHAP stands to benefit as the state of deep learning advances, and it opens a new direction of research for efficient Shapley value estimation.
|
| 231 |
+
|
| 232 |
+
# 8 REPRODUCIBILITY
|
| 233 |
+
|
| 234 |
+
Code to implement FastSHAP is available online in two separate repositories: https://github. com/iancovert/fastshap contains a PyTorch implementation and https://github. com/neiljethani/fastshap/ a TensorFlow implementation, both with examples of tabular and image data experiments. The complete code for our experiments is available at https: //github.com/iclr1814/fastshap, and details are described throughout section 5 and section 6, with model architectures and hyperparameters reported in appendix D. Proofs for our theoretical claims are provided in appendix A, appendix B, and appendix C.
|
| 235 |
+
|
| 236 |
+
# 9 ACKNOWLEDGEMENTS
|
| 237 |
+
|
| 238 |
+
We thank the reviewers for their thoughtful feedback, and we thank the Lee Lab for helpful discussions. Neil Jethani was partially supported by NIH T32 GM136573. Mukund Sudarshan was partially supported by a PhRMA Foundation Predoctoral Fellowship. Mukund Sudarshan and Rajesh Ranganath were partly supported by NIH/NHLBI Award R01HL148248, and by NSF Award 1922658 NRT-HDR: FUTURE Foundations, Translation, and Responsibility for Data Science. Ian Covert and Su-In Lee were supported by the NSF Awards CAREER DBI-1552309 and DBI-1759487; the NIH Awards R35GM128638 and R01NIAAG061132; and the American Cancer Society Award 127332-RSG-15-097-01-TBG.
|
| 239 |
+
|
| 240 |
+
# REFERENCES
|
| 241 |
+
|
| 242 |
+
Aas, K., Jullum, M., and Løland, A. (2019). Explaining individual predictions when features are dependent: More accurate approximations to Shapley values. arXiv preprint arXiv:1903.10464.
|
| 243 |
+
|
| 244 |
+
Ancona, M., Oztireli, C., and Gross, M. (2019). Explaining deep neural networks with a polynomial time algorithm for Shapley value approximation. In International Conference on Machine Learning, pages 272–281. PMLR.
|
| 245 |
+
|
| 246 |
+
Castro, J., Gómez, D., and Tejada, J. (2009). Polynomial calculation of the Shapley value based on sampling. Computers & Operations Research, 36(5):1726–1730.
|
| 247 |
+
|
| 248 |
+
Charnes, A., Golany, B., Keane, M., and Rousseau, J. (1988). Extremal principle solutions of games in characteristic function form: core, Chebychev and Shapley value generalizations. In Econometrics of Planning and Efficiency, pages 123–133. Springer.
|
| 249 |
+
|
| 250 |
+
Chen, J., Song, L., Wainwright, M., and Jordan, M. (2018a). Learning to explain: An informationtheoretic perspective on model interpretation. In International Conference on Machine Learning, pages 883–892. PMLR.
|
| 251 |
+
|
| 252 |
+
Chen, J., Song, L., Wainwright, M. J., and Jordan, M. I. (2018b). L-Shapley and C-Shapley: Efficient model interpretation for structured data. arXiv preprint arXiv:1808.02610.
|
| 253 |
+
|
| 254 |
+
Chen, T. and Guestrin, C. (2016). XGBoost: A scalable tree boosting system. In Proceedings of the 22nd ACM SIGKDD International Conference on Knowledge Discovery and Data Mining, pages 785–794.
|
| 255 |
+
|
| 256 |
+
Covert, I. and Lee, S.-I. (2021). Improving KernelSHAP: Practical Shapley value estimation using linear regression. In International Conference on Artificial Intelligence and Statistics, pages 3457– 3465. PMLR.
|
| 257 |
+
|
| 258 |
+
Covert, I., Lundberg, S., and Lee, S.-I. (2020). Understanding global feature contributions with additive importance measures. Advances in Neural Information Processing Systems, 33.
|
| 259 |
+
|
| 260 |
+
Covert, I., Lundberg, S., and Lee, S.-I. (2021). Explaining by removing: A unified framework for model explanation. Journal of Machine Learning Research, 22(209):1–90.
|
| 261 |
+
|
| 262 |
+
Cybenko, G. (1989). Approximation by superpositions of a sigmoidal function. Mathematics of Control, Signals and Systems, 2(4):303–314.
|
| 263 |
+
|
| 264 |
+
Dabkowski, P. and Gal, Y. (2017). Real time image saliency for black box classifiers. In Advances in Neural Information Processing Systems, pages 6967–6976.
|
| 265 |
+
|
| 266 |
+
Datta, A., Sen, S., and Zick, Y. (2016). Algorithmic Transparency via Quantitative Input Influence: Theory and Experiments with Learning Systems. In Proceedings - 2016 IEEE Symposium on Security and Privacy, SP 2016, pages 598–617. Institute of Electrical and Electronics Engineers Inc.
|
| 267 |
+
|
| 268 |
+
Dua, D. and Graff, C. (2017). UCI machine learning repository.
|
| 269 |
+
|
| 270 |
+
Fernandes, K., Vinagre, P., and Cortez, P. (2015). A proactive intelligent decision support system for predicting the popularity of online news. In Portuguese Conference on Artificial Intelligence, pages 535–546. Springer.
|
| 271 |
+
|
| 272 |
+
Frye, C., de Mijolla, D., Begley, T., Cowton, L., Stanley, M., and Feige, I. (2020). Shapley explainability on the data manifold. In International Conference on Learning Representations.
|
| 273 |
+
|
| 274 |
+
He, K., Zhang, X., Ren, S., and Sun, J. (2016). Deep residual learning for image recognition. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pages 770– 778.
|
| 275 |
+
|
| 276 |
+
Hooker, S., Erhan, D., Kindermans, P.-J., and Kim, B. (2018). A benchmark for interpretability methods in deep neural networks. arXiv preprint arXiv:1806.10758.
|
| 277 |
+
|
| 278 |
+
Hornik, K. (1991). Approximation capabilities of multilayer feedforward networks. Neural Networks, 4(2):251–257.
|
| 279 |
+
|
| 280 |
+
Howard, J. and Gugger, S. (2020). FastAI: A layered API for deep learning. Information, 11(2):108.
|
| 281 |
+
|
| 282 |
+
Illés, F. and Kerényi, P. (2019). Estimation of the Shapley value by ergodic sampling. arXiv preprint arXiv:1906.05224.
|
| 283 |
+
|
| 284 |
+
Janzing, D., Minorics, L., and Blöbaum, P. (2020). Feature relevance quantification in explainable AI: A causal problem. In International Conference on Artificial Intelligence and Statistics, pages 2907–2916. PMLR.
|
| 285 |
+
|
| 286 |
+
Jethani, N., Sudarshan, M., Aphinyanaphongs, Y., and Ranganath, R. (2021). Have we learned to explain?: How interpretability methods can learn to encode predictions in their interpretations. In International Conference on Artificial Intelligence and Statistics, pages 1459–1467. PMLR.
|
| 287 |
+
|
| 288 |
+
Ke, G., Meng, Q., Finley, T., Wang, T., Chen, W., Ma, W., Ye, Q., and Liu, T.-Y. (2017). LightGBM: A highly efficient gradient boosting decision tree. Advances in Neural Information Processing Systems, 30:3146–3154.
|
| 289 |
+
|
| 290 |
+
Kohavi, R. et al. (1996). Scaling up the accuracy of naive-bayes classifiers: A decision-tree hybrid. In Knowledge Discovery and Data Mining, volume 96, pages 202–207.
|
| 291 |
+
|
| 292 |
+
Krizhevsky, A., Hinton, G., et al. (2009). Learning multiple layers of features from tiny images.
|
| 293 |
+
|
| 294 |
+
Liang, D., Lu, C.-C., Tsai, C.-F., and Shih, G.-A. (2016). Financial ratios and corporate governance indicators in bankruptcy prediction: A comprehensive study. European Journal of Operational Research, 252(2):561–572.
|
| 295 |
+
|
| 296 |
+
Lipovetsky, S. and Conklin, M. (2001). Analysis of regression in game theory approach. Applied Stochastic Models in Business and Industry, 17(4):319–330.
|
| 297 |
+
|
| 298 |
+
Lundberg, S. M., Erion, G., Chen, H., DeGrave, A., Prutkin, J. M., Nair, B., Katz, R., Himmelfarb, J., Bansal, N., and Lee, S.-I. (2020). From local explanations to global understanding with explainable AI for trees. Nature Machine Intelligence, 2(1):56–67.
|
| 299 |
+
|
| 300 |
+
Lundberg, S. M. and Lee, S.-I. (2017). A unified approach to interpreting model predictions. Advances in Neural Information Processing Systems, 30:4765–4774.
|
| 301 |
+
|
| 302 |
+
Mitchell, R., Cooper, J., Frank, E., and Holmes, G. (2021). Sampling permutations for Shapley value estimation. arXiv preprint arXiv:2104.12199.
|
| 303 |
+
|
| 304 |
+
Moro, S., Cortez, P., and Rita, P. (2014). A data-driven approach to predict the success of bank telemarketing. Decision Support Systems, 62:22–31.
|
| 305 |
+
|
| 306 |
+
Petsiuk, V., Das, A., and Saenko, K. (2018). RISE: Randomized input sampling for explanation of black-box models. arXiv preprint arXiv:1806.07421.
|
| 307 |
+
Ruiz, L. M., Valenciano, F., and Zarzuelo, J. M. (1998). The family of least square values for transferable utility games. Games and Economic Behavior, 24(1-2):109–130.
|
| 308 |
+
Schulz, K., Sixt, L., Tombari, F., and Landgraf, T. (2020). Restricting the flow: Information bottlenecks for attribution. arXiv preprint arXiv:2001.00396.
|
| 309 |
+
Schwab, P. and Karlen, W. (2019). CXPlain: Causal explanations for model interpretation under uncertainty. In Advances in Neural Information Processing Systems, pages 10220–10230.
|
| 310 |
+
Selvaraju, R. R., Cogswell, M., Das, A., Vedantam, R., Parikh, D., and Batra, D. (2017). GradCAM: Visual explanations from deep networks via gradient-based localization. In Proceedings of the IEEE International Conference on Computer Vision, pages 618–626.
|
| 311 |
+
Shapley, L. S. (1953). A value for n-person games. Contributions to the Theory of Games, 2(28):307– 317.
|
| 312 |
+
Shrikumar, A., Greenside, P., and Kundaje, A. (2017). Learning important features through propagating activation differences. In International Conference on Machine Learning, pages 3145–3153. PMLR.
|
| 313 |
+
Smilkov, D., Thorat, N., Kim, B., Viégas, F., and Wattenberg, M. (2017). Smoothgrad: removing noise by adding noise. arXiv preprint arXiv:1706.03825.
|
| 314 |
+
Štrumbelj, E. and Kononenko, I. (2014). Explaining prediction models and individual predictions with feature contributions. Knowledge and Information Systems, 41(3):647–665.
|
| 315 |
+
Sundararajan, M., Taly, A., and Yan, Q. (2017). Axiomatic attribution for deep networks. In International Conference on Machine Learning, pages 3319–3328. PMLR.
|
| 316 |
+
Van den Broeck, G., Lykov, A., Schleich, M., and Suciu, D. (2021). On the tractability of SHAP explanations. In Proceedings of the 35th Conference on Artificial Intelligence (AAAI).
|
| 317 |
+
Wang, R., Wang, X., and Inouye, D. I. (2021). Shapley explanation networks. In International Conference on Learning Representations.
|
| 318 |
+
Yoon, J., Jordon, J., and van der Schaar, M. (2018). INVASE: Instance-wise variable selection using neural networks. In International Conference on Learning Representations.
|
| 319 |
+
|
| 320 |
+
# A FASTSHAP GLOBAL OPTIMIZER
|
| 321 |
+
|
| 322 |
+
Here, we prove that FastSHAP is trained using an objective function whose global optimizer outputs the true Shapley values. Recall that the loss function for the explainer model $\phi _ { \mathrm { f a s t } } ( \mathbf { x } , \mathbf { y } ; \theta )$ is
|
| 323 |
+
|
| 324 |
+
$$
|
| 325 |
+
\begin{array} { r } { \mathcal { L } ( \boldsymbol { \theta } ) = \underset { p ( \mathbf { x } ) } { \mathbb { E } } \underset { \mathrm { U n i f } ( \mathbf { y } ) } { \mathbb { E } } \underset { p ( \mathbf { s } ) } { \mathbb { E } } \left[ \left( v _ { \mathbf { x } , \mathbf { y } } ( \mathbf { s } ) - v _ { \mathbf { x } , \mathbf { y } } ( \mathbf { 0 } ) - \mathbf { s } ^ { \top } \phi _ { \mathrm { f a s t } } ( \mathbf { x } , \mathbf { y } ; \boldsymbol { \theta } ) \right) ^ { 2 } \right] . } \end{array}
|
| 326 |
+
$$
|
| 327 |
+
|
| 328 |
+
As mentioned in the main text, it is necessary to force the model to satisfy the Efficiency constraint, or the property that the predictions from $\phi _ { \mathrm { f a s t } } ( \mathbf { x } , \mathbf { y } ; \theta )$ satisfy
|
| 329 |
+
|
| 330 |
+
$$
|
| 331 |
+
\mathbf { 1 } ^ { \top } \phi _ { \mathrm { f a s t } } ( x , y ; \theta ) = v _ { x , y } ( \mathbf { 1 } ) - v _ { x , y } ( \mathbf { 0 } ) \quad \forall x \in \mathcal { X } , y \in \mathcal { Y } .
|
| 332 |
+
$$
|
| 333 |
+
|
| 334 |
+
One option for guaranteeing the efficiency property is to adjust the model outputs using their additive efficient normalization (see section 3.1). Incorporating this constraint on the predictions, we can then view the loss function as an expectation across $\displaystyle ( \mathbf { x } , \mathbf { y } )$ and write the expected loss for each sample $( x , y )$ as a separate optimization problem over the variable $\phi _ { x , y } \in \mathbb { R } ^ { d }$ :
|
| 335 |
+
|
| 336 |
+
$$
|
| 337 |
+
\begin{array} { r l } & { \underset { \phi _ { x , y } } { \operatorname* { m i n } } \underset { p ( \mathbf { s } ) } { \mathbb { E } } \left[ \left( v _ { x , y } ( \mathbf { s } ) - v _ { x , y } ( \mathbf { 0 } ) - \mathbf { s } ^ { \top } \phi _ { x , y } \right) ^ { 2 } \right] } \\ & { \mathrm { ~ s . t . ~ } \quad \phi _ { x , y } = v _ { x , y } ( { \bf 1 } ) - v _ { x , y } ( \mathbf { 0 } ) . } \end{array}
|
| 338 |
+
$$
|
| 339 |
+
|
| 340 |
+
This is a constrained weighted least squares problem with a unique global minimizer, and it is precisely the Shapley value’s weighted least squares characterization (see eq. (3)). We can therefore conclude that the optimal prediction for each pair $( x , y )$ is the true Shapley values, or that $\phi _ { x , y } ^ { * } =$ $\phi ( v _ { x , y } )$ . As a result, the global optimizer for our objective is a model $\phi _ { \mathrm { f a s t } } ( \mathbf { x } , \mathbf { y } ; \theta ^ { * } )$ that outputs the true Shapley values almost everywhere in the data distribution $p ( \mathbf { x } , \mathbf { y } )$ .
|
| 341 |
+
|
| 342 |
+
Achieving the global optimum requires the ability to sample from $p ( \mathbf { x } )$ (or a sufficiently large dataset), perfect optimization, and a function class for $\phi _ { \mathrm { f a s t } } ( \mathbf { x } , \mathbf { y } ; \theta )$ that is expressive enough to contain the global optimizer. The universal approximation theorem (Cybenko, 1989; Hornik, 1991) implies that a sufficiently large neural network can represent the Shapley value function to arbitrary accuracy as long as it is a continuous function. Specifically, we require the function $h _ { y } ( x ) = \phi ( v _ { x , y } )$ to be continuous in $x$ for all $y$ . This holds in practice when we use a surrogate model parameterized by a continuous neural network, because $v _ { x , y } ( s )$ is continuous in $x$ for all $( s , y )$ , and the Shapley value is a linear combination of $v _ { x , y } ( s )$ across different values of $s$ (see eq. (1)).
|
| 343 |
+
|
| 344 |
+
Another approach to enforce the efficiency property is by using efficiency regularization, or penalizing the efficiency gap in the explainer model’s predictions (section 3.1). If we incorporate this regularization term with parameter $\gamma > 0$ , then our objective yields the following optimization problem for each $( x , y )$ pair:
|
| 345 |
+
|
| 346 |
+
$$
|
| 347 |
+
\operatorname* { m i n } _ { \phi _ { x , y } } \quad \operatorname { \mathbb { E } } _ { p ( \mathbf { s } ) } \left[ \left( v _ { x , y } ( \mathbf { s } ) - v _ { x , y } ( \mathbf { 0 } ) - \mathbf { s } ^ { \top } \phi _ { x , y } \right) ^ { 2 } \right] + \gamma \big ( v _ { x , y } ( \mathbf { 1 } ) - v _ { x , y } ( \mathbf { 0 } ) - \mathbf { 1 } ^ { \top } \phi _ { x , y } \big ) ^ { 2 } .
|
| 348 |
+
$$
|
| 349 |
+
|
| 350 |
+
For finite hyperparameter values $\gamma \in [ 0 , \infty )$ , this problem relaxes the Shapley value’s efficiency property and eliminates the requirement that predictions must sum to the grand coalition’s value. However, as we let $\gamma \to \infty$ , the penalty term becomes closer to the hard constraint in eq. (9). Note that in practice, we use finite values for $\gamma$ and observe sufficiently accurate results, whereas using excessively large $\gamma$ values would render gradient-based optimization ineffective.
|
| 351 |
+
|
| 352 |
+
# B ADDITIVE EFFICIENT NORMALIZATION
|
| 353 |
+
|
| 354 |
+
Here, we provide a geometric interpretation for the additive efficient normalization step and prove that it is guaranteed to yield Shapley value estimates closer to their true values. Consider a game $v$ with Shapley values $\phi ( v ) \in \mathbb { R } ^ { d }$ , and assume that we have Shapley values estimates $\boldsymbol { \hat { \phi } } \in \mathbb { R } ^ { \bar { d } }$ that do not satisfy the efficiency property. To force this property to hold, we can project these estimates onto the efficient hyperplane, or the subset of $\mathbb { R } ^ { d }$ where the efficiency property is satisfied. This corresponds to solving the following optimization problem over $\phi _ { \mathrm { e f f } } \in \bar { \mathbb { R } ^ { d } }$ :
|
| 355 |
+
|
| 356 |
+
$$
|
| 357 |
+
\operatorname* { m i n } _ { \phi _ { \mathrm { e f f } } } | | \phi _ { \mathrm { e f f } } - \hat { \phi } | | ^ { 2 } \quad \mathrm { s . t . } \quad \mathbf { 1 } ^ { \top } \phi _ { \mathrm { e f f } } = v ( \mathbf { 1 } ) - v ( \mathbf { 0 } ) .
|
| 358 |
+
$$
|
| 359 |
+
|
| 360 |
+
We can solve the problem via its Lagrangian, denoted by $\mathcal { L } ( \phi _ { \mathrm { e f f } } , \nu )$ , with the Lagrange multiplier $\nu \in \mathbb { R }$ as follows:
|
| 361 |
+
|
| 362 |
+
$$
|
| 363 |
+
\begin{array} { r l } & { \mathcal { L } ( \phi _ { \mathrm { e f f } } , \nu ) = | | \phi _ { \mathrm { e f f } } - \hat { \phi } | | ^ { 2 } + \nu \Big ( v ( \mathbf { 1 } ) - v ( \mathbf { 0 } ) - \mathbf { 1 } ^ { \top } \phi _ { \mathrm { e f f } } \Big ) } \\ & { \quad \Rightarrow \phi _ { \mathrm { e f f } } ^ { * } = \hat { \phi } - \mathbf { 1 } \frac { v ( \mathbf { 1 } ) - v ( \mathbf { 0 } ) - \mathbf { 1 } ^ { \top } \hat { \phi } } { d } . } \end{array}
|
| 364 |
+
$$
|
| 365 |
+
|
| 366 |
+
This transformation, where the efficiency gap is split evenly and added to each estimate, is known as additive efficient normalization (Ruiz et al., 1998). We implement it as an output layer for FastSHAP’s predictions to ensure that they satisfy the efficiency property (section 3). This step can therefore be understood as a projection of the network’s output onto the efficient hyperplane.
|
| 367 |
+
|
| 368 |
+
The normalization step is guaranteed to produce corrected estimates $\phi _ { \mathrm { e f f } } ^ { * }$ that are closer to the true Shapley values $\phi ( v )$ than the original estimates $\hat { \phi }$ . To see this, note that the projection step guarantees that $\hat { \phi } - \phi _ { \mathrm { e f f } } ^ { * }$ and $\phi _ { \mathrm { e f f } } ^ { * } - \phi ( v )$ are orthogonal vectors, so the Pythagorean theorem yields the following inequality:
|
| 369 |
+
|
| 370 |
+
$$
|
| 371 |
+
\begin{array} { r l } & { | | \phi ( v ) - \hat { \phi } | | ^ { 2 } = | | \phi ( v ) - \phi _ { \mathrm { e f f } } ^ { * } | | ^ { 2 } + | | \phi _ { \mathrm { e f f } } ^ { * } - \hat { \phi } | | ^ { 2 } } \\ & { \qquad \geq | | \phi ( v ) - \phi _ { \mathrm { e f f } } ^ { * } | | ^ { 2 } . } \end{array}
|
| 372 |
+
$$
|
| 373 |
+
|
| 374 |
+
# C REDUCING GRADIENT VARIANCE
|
| 375 |
+
|
| 376 |
+
Recall that our objective function $\mathcal { L } ( \boldsymbol { \theta } )$ is defined as follows:
|
| 377 |
+
|
| 378 |
+
$$
|
| 379 |
+
\begin{array} { r } { \mathcal { L } ( \boldsymbol { \theta } ) = \underset { p ( \mathbf { x } ) } { \mathbb { E } } \underset { \mathrm { U n i f } ( \mathbf { y } ) } { \mathbb { E } } \underset { p ( \mathbf { s } ) } { \mathbb { E } } \left[ \left( v _ { \mathbf { x } , \mathbf { y } } ( \mathbf { s } ) - v _ { x , y } ( \mathbf { 0 } ) - \mathbf { s } ^ { \top } \phi _ { \mathrm { f a s t } } ( \mathbf { x } , \mathbf { y } ; \boldsymbol { \theta } ) \right) ^ { 2 } \right] . } \end{array}
|
| 380 |
+
$$
|
| 381 |
+
|
| 382 |
+
The objective’s gradient is given by
|
| 383 |
+
|
| 384 |
+
$$
|
| 385 |
+
\begin{array} { r } { \nabla _ { \boldsymbol { \theta } } \mathcal { L } ( \boldsymbol { \theta } ) = \underset { p ( \mathbf { x } ) } { \mathbb { E } } \underset { \mathrm { U n i f } ( \mathbf { y } ) } { \mathbb { E } } \underset { p ( \mathbf { s } ) } { \mathbb { E } } \left[ \nabla ( \mathbf { x } , \mathbf { y } , \mathbf { s } ; \boldsymbol { \theta } ) \right] , } \end{array}
|
| 386 |
+
$$
|
| 387 |
+
|
| 388 |
+
where we define
|
| 389 |
+
|
| 390 |
+
$$
|
| 391 |
+
\nabla ( x , y , s ; \theta ) : = \nabla _ { \theta } \big ( v _ { x , y } ( s ) - v _ { x , y } ( \mathbf { 0 } ) - s ^ { \top } \phi _ { \mathrm { f a s t } } ( x , y ; \theta ) \big ) ^ { 2 } .
|
| 392 |
+
$$
|
| 393 |
+
|
| 394 |
+
When FastSHAP is trained with a single sample $( x , y , s )$ , the gradient covariance is given by $\operatorname { C o v } \big ( \nabla ( \mathbf { x } , \mathbf { y } , \mathbf { s } ; \theta ) \big )$ , which may be too large for effective optimization. We use several strategies to reduce gradient variance. First, given a model that outputs estimates for all classes $y \in \{ 1 , \ldots , K \}$ , we calculate the loss jointly for all classes. This yields gradients that we denote as $\nabla ( \mathbf { x } , \mathbf { s } ; \theta )$ , defined as
|
| 395 |
+
|
| 396 |
+
$$
|
| 397 |
+
\begin{array} { r } { \nabla ( x , s ; \theta ) : = \underset { \operatorname { U n i f } ( \mathbf { y } ) } { \mathbb { E } } [ \nabla ( x , \mathbf { y } , s ; \theta ) ] , } \end{array}
|
| 398 |
+
$$
|
| 399 |
+
|
| 400 |
+
where we have the relationship
|
| 401 |
+
|
| 402 |
+
$$
|
| 403 |
+
\operatorname { C o v } \big ( \nabla ( \mathbf { x } , \mathbf { s } ; \theta ) \big ) \preceq \operatorname { C o v } \big ( \nabla ( \mathbf { x } , \mathbf { y } , \mathbf { s } ; \theta ) \big )
|
| 404 |
+
$$
|
| 405 |
+
|
| 406 |
+
due to the law of total covariance. Next, we consider minibatches of $b$ independent $x$ samples, which yields gradients $\nabla _ { b } ( \mathbf { x } , \mathbf { s } ; \theta )$ with covariance given by
|
| 407 |
+
|
| 408 |
+
$$
|
| 409 |
+
\mathrm { C o v } \big ( \nabla _ { b } ( \mathbf { x } , \mathbf { s } ; \theta ) \big ) = \frac { 1 } { b } \mathrm { C o v } \big ( \nabla ( \mathbf { x } , \mathbf { s } ; \theta ) \big ) .
|
| 410 |
+
$$
|
| 411 |
+
|
| 412 |
+
We then consider sampling $m$ independent coalitions $s$ for each input $x$ , resulting in the gradients $\nabla _ { b } ^ { m } ( \mathbf { x } , \mathbf { s } ; \theta )$ with covariance given by
|
| 413 |
+
|
| 414 |
+
$$
|
| 415 |
+
\operatorname { C o v } \big ( \nabla _ { b } ^ { m } ( \mathbf { x } , \mathbf { s } ; \theta ) \big ) = \frac { 1 } { m b } \mathrm { C o v } \big ( \nabla ( \mathbf { x } , \mathbf { s } ; \theta ) \big ) .
|
| 416 |
+
$$
|
| 417 |
+
|
| 418 |
+
Finally, we consider a paired sampling approach, where each sample $s \sim p ( \mathbf { s } )$ is paired with its complement ${ \bf 1 } - s$ . Paired sampling has been shown to reduce KernelSHAP’s variance (Covert and Lee, 2021), and our experiments show that it helps improve FastSHAP’s accuracy (appendix D).
|
| 419 |
+
|
| 420 |
+
The training algorithm in the main text is simplified by omitting these gradient variance reduction techniques, so we also provide algorithm 2 below, which includes minibatching, multiple coalition samples, paired sampling, efficiency regularization and parallelization over all output classes.
|
| 421 |
+
|
| 422 |
+
Algorithm 2: Full FastSHAP training
|
| 423 |
+
|
| 424 |
+
<table><tr><td>Input: Value function Ux,y,learning rate α, batch size b,samples m, penalty parameter y Output:FastSHAP explainer Φfast (x,y; 0) initialize Φfast (x,y;0) while not converged do setR↑0,L←0 for i=1,..., bdo sample x ~ p(x)</td></tr><tr><td>for y = 1,..., K do</td></tr><tr><td>predict Φ ← Φfast (x,y; 0)</td></tr><tr><td>calculate R ← R+ (ux,y(1)- Ux,y(0)-1Tó)² //Pre-normalization</td></tr><tr><td>if normalize then set←Φ+d-1(x,y(1)-Ux,y(0)-1Φ)</td></tr><tr><td>end</td></tr><tr><td>for j=1,...,m do if paired sampling and i mod 2= O then</td></tr><tr><td>sets←1-s// Invert previous subset</td></tr><tr><td>else 一 sample s~ p(s)</td></tr><tr><td>end</td></tr><tr><td>calculateL←L+(xy(s)-Ur,y(0)-sΦ)</td></tr><tr><td>end</td></tr><tr><td>end</td></tr><tr><td>end</td></tr><tr><td>update←θ-αVθ(bmk+γ)</td></tr><tr><td></td></tr><tr><td>end</td></tr></table>
|
| 425 |
+
|
| 426 |
+

|
| 427 |
+
Figure 6: FastSHAP accuracy as a function of the number of training samples. The results show that using more s samples per $\mathbf { x }$ improves FastSHAP’s closeness to the ground truth Shapley values, as does the use of paired sampling.
|
| 428 |
+
|
| 429 |
+
# D FASTSHAP MODELS AND HYPERPARAMETERS
|
| 430 |
+
|
| 431 |
+
In this section, we describe the models and architectures used for each dataset, as well as the hyperparameters used when training FastSHAP.
|
| 432 |
+
|
| 433 |
+
# D.1 MODELS
|
| 434 |
+
|
| 435 |
+
Tabular datasets. For the original model $f ( \mathbf { x } ; \eta )$ , we use neural networks for the news and marketing datasets and gradient boosted trees for the census (LightGBM (Ke et al., 2017)) and bankruptcy (XGBoost (Chen and Guestrin, 2016)) datasets. The FastSHAP model $\phi _ { \mathrm { f a s t } } ( \mathbf { x } , \mathbf { y } ; \theta )$ and the surrogate model $p _ { \mathrm { s u r r } } ( \mathbf { y } \mid m ( \mathbf { x } , \mathbf { s } ) ; \beta )$ are implemented using neural networks that consist of 2-3 fully connected layers with 128 units and ReLU activations. The $p _ { \mathrm { s u r r } }$ models use a softmax output layer, while $\phi _ { \mathrm { f a s t } }$ has no output activation. The models are trained using Adam with a learning rate of $1 0 ^ { - 3 }$ , and we use a learning rate scheduler that multiplies the learning rate by a factor of 0.5 after 3 epochs of no validation loss improvement. Early stopping was triggered after the validation loss ceased to improve for 10 epochs.
|
| 436 |
+
|
| 437 |
+
Image datasets. The models $f ( \mathbf { x } ; \eta )$ and $p _ { \mathrm { s u r r } }$ are ResNet-50 models pretrained on Imagenet. We use these without modification to the architecture and fine-tune them on each image dataset. To create the $\phi _ { \mathrm { f a s t } } ( \mathbf { x } , \mathbf { y } ; \theta )$ model, we modify the architecture to return a tensor of size $1 4 \times 1 4 \times K$ . First, the layers after the 4th convolutional block are removed; the output of this block is $1 4 \times 1 4 \times$ 256. We then append a 2D convolutional layer with $K$ filters, each of size $1 \times 1$ , so that the output is $1 4 \times 1 4 \times K$ and the yth $1 4 \times 1 4$ slice corresponds to the superpixel-level Shapley values for each class $y \in \mathcal { V }$ . Each model is trained using Adam with a learning rate of $1 0 ^ { - 3 }$ , and we use a learning rate scheduler that multiplies the learning rate by a factor of 0.8 after 3 epochs of no validation loss improvement. Early stopping was triggered after the validation loss ceased to improve for 20 epochs.
|
| 438 |
+
|
| 439 |
+
# D.2 FASTSHAP HYPERPARAMETERS
|
| 440 |
+
|
| 441 |
+
We now explore various settings of FastSHAP’s hyperparameters and observe their impact on FastSHAP’s performance. There are two types of hyperparameters: sampling hyperparameters, which affect the number of samples of s taken during training, and efficiency hyperparameters, which control how we enforce the Efficiency constraint. Sampling hyperparameters include: (1) whether to use paired sampling, and (2) the number of samples of s per $\mathbf { x }$ to take during training. Efficiency hyperparameters include: (1) the choice of $\gamma$ in eq. (4), and (2) whether to perform the additive efficient normalization during training, inference or both.
|
| 442 |
+
|
| 443 |
+
To understand the effect of sampling hyperparameters, we perform experiments using the same tabular datasets from the main text. We use the in-distribution value function $p _ { \mathrm { s u r r } }$ and compute the ground truth SHAP values the same way as in our previous experiments (i.e., by running KernelSHAP to convergence).
|
| 444 |
+
|
| 445 |
+
Figure 6 shows the mean $\ell _ { 2 }$ distance between FastSHAP’s estimates and the ground truth. We find that across all four datasets, increasing the number of training samples of s generally improves the mean $\ell _ { 2 }$ distance to ground truth. We also find that for any fixed number of samples (greater than 1), using paired sampling improves FastSHAP’s accuracy.
|
| 446 |
+
|
| 447 |
+
Table 3 shows the results of an ablation study for the efficiency hyperparameters. Normalization (or Norm.) refers to the additive efficient normalization step (applied during training and inference, or only during inference), and penalty refers to the efficiency regularization technique with the parameter set to $\gamma = 0 . 1$ . We find that using normalization during training uniformly achieves better results than without normalization or with normalization only during inference. The efficiency regularization approach proves to be less effective, generally leading to less accurate Shapley value estimates. Based on these results, we opt to use additive efficient normalization in our tabular data experiments.
|
| 448 |
+
|
| 449 |
+
Table 3: FastSHAP ablation results. The distance to the ground truth Shapley values is displayed for several FastSHAP variations, showing that normalization helps and that the penalty is unnecessary.
|
| 450 |
+
|
| 451 |
+
<table><tr><td rowspan="2"></td><td colspan="2">Census</td><td colspan="2">Bankruptcy</td></tr><tr><td>l2</td><td>l1</td><td>l2</td><td>l1</td></tr><tr><td>Normalization</td><td>0.0229</td><td>0.0863</td><td>0.0295</td><td>0.2436</td></tr><tr><td>Normalization + Penalty</td><td>0.0261</td><td>0.0971</td><td>0.0320</td><td>0.2740</td></tr><tr><td>Inference Norm.</td><td>0.0406</td><td>0.1512</td><td>0.0407</td><td>0.3450</td></tr><tr><td>Inference Norm. + Penalty</td><td>0.0452</td><td>0.1671</td><td>0.0473</td><td>0.4471</td></tr><tr><td>No Norm.</td><td>0.0501</td><td>0.1933</td><td>0.0408</td><td>0.3474</td></tr><tr><td>No Norm.+Penalty</td><td>0.0513</td><td>0.1926</td><td>0.0474</td><td>0.4490</td></tr></table>
|
| 452 |
+
|
| 453 |
+
# E ADDITIONAL RESULTS FOR IMAGE EXPERIMENTS
|
| 454 |
+
|
| 455 |
+
In this section, we provide additional results for the FastSHAP image experiments.
|
| 456 |
+
|
| 457 |
+
# E.1 INCLUSION AND EXCLUSION METRICS
|
| 458 |
+
|
| 459 |
+
Table 4 shows our inclusion and exclusion metrics when replicated using log-odds rather than accuracy. Similar to our metrics described in the main text, we choose the class predicted by the original model for each image, and we measure the average log-odds for that class as we include or exclude important features according to the explanations generated by each method. The results confirm roughly the same ordering between methods, with FastSHAP being the only method to achieve strong results on both metrics for both datasets. Figure 7 shows the raw inclusion and exclusion curves for both the accuracy and log-odds-derived metrics.
|
| 460 |
+
|
| 461 |
+
Table 4: Exclusion and Inclusion AUCs calculated using the average log-odds of the predicted class.
|
| 462 |
+
|
| 463 |
+
<table><tr><td></td><td colspan="2">CIFAR-10</td><td colspan="2">Imagenette</td></tr><tr><td></td><td>Exclusion AUC</td><td>Inclusion AUC</td><td>Exclusion AUC</td><td>Inclusion AUC</td></tr><tr><td>FastSHAP</td><td>5.92 (5.62, 6.14)</td><td>5.36 (5.16, 5.63)</td><td>7.98 (7.68, 8.33)</td><td>5.40 (5.16, 5.60)</td></tr><tr><td>KernelSHAP</td><td>9.88 (9.55, 10.20)</td><td>5.36 (5.14,5.63)</td><td>10.68 (10.36,11.00)</td><td>5.07 (4.81, 5.31)</td></tr><tr><td>KernelSHAP-S</td><td>8.01 (7.68, 8.34)</td><td>6.80 (6.65, 6.96)</td><td>9.39 (9.11, 9.66)</td><td>6.01 (5.78, 6.26)</td></tr><tr><td>GradCAM</td><td>7.75 (7.44, 8.09)</td><td>4.99 (4.81, 5.26)</td><td>7.77 (7.49, 8.05)</td><td>4.65 (4.40,4.89)</td></tr><tr><td>Integrated Gradients</td><td>8.34 (8.03,8.61)</td><td>4.58 (4.37, 4.85)</td><td>10.14 (9.79,10.46)</td><td>4.34 (4.10,4.58)</td></tr><tr><td>SmoothGrad</td><td>10.99 (10.67, 11.29)</td><td>4.30 (4.08,4.58)</td><td>11.19 (10.84, 11.48)</td><td>4.47 (4.24, 4.70)</td></tr><tr><td>DeepSHAP</td><td>9.96 (9.61, 10.24)</td><td>5.47 (5.28,5.76)</td><td>10.93 (10.61,11.20)</td><td>4.63 (4.38,4.85)</td></tr><tr><td>CXPlain</td><td>8.34 (8.00, 8.58)</td><td>4.02 (3.80, 4.31)</td><td>9.13 (8.83, 9.41)</td><td>4.33 (4.11, 4.57)</td></tr></table>
|
| 464 |
+
|
| 465 |
+

|
| 466 |
+
Figure 7: Additional inclusion and exclusion curves. The change in top-1 accuracy or average log-odds of the predicted class as an increasing percentage of the pixels estimated to be important are excluded (left) or included (right) from the set of 1,000 images.
|
| 467 |
+
|
| 468 |
+

|
| 469 |
+
Figure 8: FastSHAP robustness to limited data. The curves are generated by training FastSHAP with varying portions of the Imagenette dataset and evaluating the Inclusion and Exclusion AUC. Horizontal lines show the Exclusion and Inclusion AUCs for each of the baseline methods, as reported in table 1.
|
| 470 |
+
|
| 471 |
+
# E.2 FASTSHAP ROBUSTNESS TO LIMITED DATA
|
| 472 |
+
|
| 473 |
+
To test FastSHAP’s robustness to the size of the training data, we compare its performance when trained with varying amounts of the Imagenette dataset. Figure 8 plots the change in inclusion and exclusion AUC, calculated using top-1 accuracy, achieved when training FastSHAP with $9 5 \%$ , $8 5 \%$ , $7 5 \%$ , $50 \%$ , $2 5 \%$ , $15 \%$ , $10 \%$ , and $5 \%$ of the training dataset. We find that FastSHAP remains competitive when using just $10 \%$ of the data, and that it outperforms most baseline methods by a large margin when using just $2 5 \%$ .
|
| 474 |
+
|
| 475 |
+
# E.3 EXAMPLE FASTSHAP IMAGE EXPLANATIONS
|
| 476 |
+
|
| 477 |
+
Finally, we show additional explanations generated by FastSHAP and the baseline methods for both CIFAR-10 and Imagenette.
|
| 478 |
+
|
| 479 |
+

|
| 480 |
+
Figure 9: Explanations generated by FastSHAP for 18 randomly selected CIFAR-10 images. Each column corresponds to a CIFAR-10 class, and the model’s prediction (in logits) is provided below each image.
|
| 481 |
+
|
| 482 |
+

|
| 483 |
+
Figure 10: Explanations generated by FastSHAP for 18 randomly selected Imagenette images. Each column corresponds to an Imagenette class, and the model’s prediction (in logits) is provided below each image.
|
| 484 |
+
|
| 485 |
+

|
| 486 |
+
Figure 11: Explanations generated for the predicted class for 15 randomly selected CIFAR-10 images. Each column corresponds to an explanation method, and each row is labeled with the image’s corresponding class.
|
| 487 |
+
|
| 488 |
+

|
| 489 |
+
Figure 12: Explanations generated for the predicted class for 15 randomly selected Imagenette images. Each column corresponds to an explanation method, and each row is labeled with the image’s corresponding class.
|
md/dev/_CDixzkzeyb/_CDixzkzeyb.md
ADDED
|
@@ -0,0 +1,826 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# PROMPT-TO-PROMPT IMAGE EDITINGWITH CROSS-ATTENTION CONTROL
|
| 2 |
+
|
| 3 |
+
Amir Hertz∗1,2, Ron Mokady∗1,2, Jay Tenenbaum 1, Kfir Aberman1, Yael Pritch1, and Daniel Cohen-Or∗1,2
|
| 4 |
+
|
| 5 |
+
1 Google Research 2The Blavatnik School of Computer Science, Tel Aviv University
|
| 6 |
+
|
| 7 |
+
# ABSTRACT
|
| 8 |
+
|
| 9 |
+
Recent large-scale text-driven synthesis diffusion models have attracted much attention thanks to their remarkable capabilities of generating highly diverse images that follow given text prompts. Therefore, it is only natural to build upon these synthesis models to provide text-driven image editing capabilities. However, Editing is challenging for these generative models, since an innate property of an editing technique is to preserve some content from the original image, while in the text-based models, even a small modification of the text prompt often leads to a completely different outcome. State-of-the-art methods mitigate this by requiring the users to provide a spatial mask to localize the edit, hence, ignoring the original structure and content within the masked region. In this paper, we pursue an intuitive prompt-to-prompt editing framework, where the edits are controlled by text only. We analyze a text-conditioned model in depth and observe that the cross-attention layers are the key to controlling the relation between the spatial layout of the image to each word in the prompt. With this observation, we propose to control the attention maps of the edited image by injecting the attention maps of the original image along the diffusion process. Our approach enables us to monitor the synthesis process by editing the textual prompt only, paving the way to a myriad of caption-based editing applications such as localized editing by replacing a word, global editing by adding a specification, and even controlling the extent to which a word is reflected in the image. We present our results over diverse images and prompts with different text-to-image models, demonstrating high-quality synthesis and fidelity to the edited prompts.
|
| 10 |
+
|
| 11 |
+
# 1 INTRODUCTION
|
| 12 |
+
|
| 13 |
+
Recently, large-scale language-image (LLI) models, such as Imagen (Saharia et al., 2022b), DALL·E 2 (Ramesh et al., 2022) and Parti (Yu et al., 2022), have shown phenomenal generative semantic and compositional power, and gained unprecedented attention from the research community and the public eye. These LLI models are trained on extremely large language-image datasets and use state-of-the-art image generative models including auto-regressive and diffusion models. However, these models do not provide simple editing means, and generally lack control over specific semantic regions of a given image. In particular, even the slightest change in the textual prompt may lead to a completely different output image. To circumvent this, LLI-based methods (Nichol et al., 2021; Avrahami et al., 2022a; Ramesh et al., 2022) require the user to explicitly mask a part of the image to be inpainted, and drive the edited image to change in the masked area only, while matching the background of the original image. This approach has provided appealing results, however, the masking procedure is cumbersome, hampering quick and intuitive text-driven editing. Moreover, masking the image content removes important structural information, which is completely ignored in the inpainting process. Therefore, some capabilities are out of the inpainting scope, such as modifying the texture of a specific object.
|
| 14 |
+
|
| 15 |
+
In this paper, we introduce an intuitive and powerful textual editing method to semantically edit images in pre-trained text-conditioned diffusion models via Prompt-to-Prompt manipulations. To do so, we dive deep into the cross-attention layers and explore their semantic strength as a handle to control the generated image. Specifically, we consider the internal cross-attention maps, which are high-dimensional tensors that bind pixels and tokens extracted from the prompt text. We find that these maps contain rich semantic relations which critically affect the generated image.
|
| 16 |
+
|
| 17 |
+

|
| 18 |
+
Figure 1: Prompt-to-Prompt editing capabilities. Our method paves the way for a myriad of caption-based editing operations: tuning the level of influence of an adjective word (bottom-left), making a local modification in the image by replacing or adding a word (bottom-middle), or specifying a global modification (bottom-right).
|
| 19 |
+
|
| 20 |
+
Our key idea is that we can edit images by injecting the cross-attention maps during the diffusion process, controlling which pixels attend to which tokens of the prompt text during which diffusion steps. To apply our approach to various creative editing applications, we show several methods to control the cross-attention maps through a simple and semantic interface (see fig. 1). The first is to change a single token’s value in the prompt (e.g., “dog” to “cat”), while fixing the cross-attention maps, to preserve the scene composition. The second is adding new words to the prompt and freezing the attention on previous tokens while allowing new attention to flow to the new tokens. This enables us to perform global editing or modify a specific object. The third is to amplify or attenuate the semantic effect of a word in the generated image. Furthermore, we demonstrate how to use these attention maps to obtain a local editing effect that accurately preserves the background.
|
| 21 |
+
|
| 22 |
+
Our approach constitutes an intuitive image editing interface through editing only the textual prompt, therefore called Prompt-to-Prompt. This method enables various editing tasks, which are challenging otherwise, and does not require model training, fine-tuning, extra data, or optimization. Throughout our analysis, we discover even more control over the generation process, recognizing a trade-off between the fidelity to the edited prompt and the source image. We also demonstrate that our method operates with different text-to-image models as a backbone and we will publish our code for the public models upon acceptance. Finally, our method even applies to real images by using an existing inversion technique. Our experiments show that our method enables intuitive text-based editing over diverse images that current methods struggle with.
|
| 23 |
+
|
| 24 |
+
# 2 RELATED WORK
|
| 25 |
+
|
| 26 |
+
Image editing is one of the most fundamental tasks in computer graphics, encompassing the process of modifying an input image through the use of an auxiliary input, such as a label, mask, or reference image. A specifically intuitive way to edit an image is through textual prompts provided by the user. Recently, text-driven image manipulation has achieved significant progress using GANs (Goodfellow et al., 2014; Brock et al., 2018; Karras et al., 2019), which are known for their highquality generation, in tandem with CLIP (Radford et al., 2021), which consists of a semantically rich joint image-text representation, trained over millions of text-image pairs. Seminal works (Patashnik et al., 2021; Gal et al., 2021; Xia et al., 2021a) which combined these components were revolutionary, since they did not require extra manual labor, and produced realistic manipulations using text only. For instance, Bau et al. (2021) further demonstrated how to use masks to restrict the text-based editing to a specific region. However, while GAN-based editing approaches succeed on curated data, e.g., human faces, they struggle over large and diverse datasets (Mokady et al., 2022).
|
| 27 |
+
|
| 28 |
+
To obtain more expressive generation capabilities, Crowson et al. (2022) use VQ-GAN (Esser et al., 2021b), trained over diverse data, as a backbone. Other works (Avrahami et al., 2022b; Kim et al., 2022) exploit the recent Diffusion models (Ho et al., 2020; Song & Ermon, 2019; Ho et al., 2020; Song et al., 2020; Rombach et al., 2021; Ho et al., 2022; Saharia et al., 2021; 2022a), which achieve state-of-the-art generation quality over diverse datasets, often surpassing GANs (Dhariwal & Nichol, 2021). Kim et al. (2022) show how to perform global changes, whereas Avrahami et al. (2022b) successfully perform local manipulations using user-provided masks for guidance. While most works that require only text (i.e., no masks) are limited to global editing (Crowson et al., 2022; Kwon & Ye, 2021), Bar-Tal et al. (2022) proposed a text-based localized editing technique without using any mask, showing impressive results. Yet, their techniques mainly allow changing textures, but not modifying complex structures, such as changing a bicycle to a car. Moreover, unlike our method, their approach requires training a network for each input.
|
| 29 |
+
|
| 30 |
+

|
| 31 |
+
fixed attention maps and random seed
|
| 32 |
+
Figure 2: Content modification through attention injection. We start from an original image generated from the prompt ”lemon cake” (top left), and modify the text prompt to a variety of other cakes. On the top row, we inject the attention weights of the original image during the diffusion process. On the bottom, we only use the same random seeds as the original image, without injecting attention. The latter leads to a completely new structure that is hardly related to the original.
|
| 33 |
+
|
| 34 |
+
Numerous works (Ding et al., 2021; Hinz et al., 2020; Tao et al., 2020; Li et al., 2019; Ramesh et al., 2021; Zhang et al., 2018b; Crowson et al., 2022; Gafni et al., 2022; Rombach et al., 2021) advanced the generation of images conditioned on plain text, known as text-to-image synthesis. But only recently these were followed by several large-scale text-image models, such as Imagen (Saharia et al., 2022b), DALL-E2 (Ramesh et al., 2022), and Parti (Yu et al., 2022), demonstrating unprecedented semantic generation. However, these models do not provide control over a generated image, specifically using text guidance only. Changing a single word in the original prompt associated with the image often leads to a completely different outcome. For instance, adding the adjective “white” to “dog” often changes the dog’s shape. To overcome this, several works (Nichol et al., 2021; Avrahami et al., 2022a) assume that the user provides a mask to restrict the edited region.
|
| 35 |
+
|
| 36 |
+
Unlike previous works, our method requires textual input only, by using the spatial information from the internal layers of the generative model itself. This offers the user a much more intuitive editing experience of modifying local or global details by merely modifying the text prompt.
|
| 37 |
+
|
| 38 |
+
# 3 METHOD
|
| 39 |
+
|
| 40 |
+
Let $\mathcal { T }$ be an image that was generated by a text-guided diffusion model using the text prompt $\mathcal { P }$ and a random seed $s$ . Our goal is to edit $\mathcal { T }$ , using only the guidance of an edited prompt ${ \mathcal { P } } ^ { * }$ , in order to get an edited image $\mathcal { T } ^ { * }$ that maintains the content and structure of the original image but corresponds to the edited prompt. For example, consider an image generated from the prompt “my new bicycle”, and assume that the user wants to edit the color of the bicycle or replace it with a scooter while preserving the appearance and structure of the original image. An intuitive interface for the user is to directly change the text prompt by further describing the appearance of the bike, or replacing it with another word, respectively. As opposed to previous works, we wish to avoid relying on any user-defined mask to assist or signify where the edit should occur. A simple, but unsuccessful attempt is to fix the internal randomness and regenerate using the edited text prompt. Unfortunately, as fig. 2 shows, this results in a completely different structure and composition.
|
| 41 |
+
|
| 42 |
+
Our key observation is that the structure and appearance of the generated image depend not only on the random seed, but also on the interaction between the pixels to the text embedding through the diffusion process. By modifying the pixel-to-text interaction that occurs in cross-attention layers, we provide Prompt-to-Prompt image editing capabilities. More specifically, injecting the crossattention maps of the input image $\mathcal { T }$ enables us to preserve the original composition and structure. In Section 3.1, we review how cross attention is used, and in Section 3.2, we describe how to exploit the cross-attention for editing. Self-attention is discussed in section 3.3. For background on diffusion models, refer to appendix A.
|
| 43 |
+
|
| 44 |
+

|
| 45 |
+
Figure 3: Method overview. Top: visual and textual embedding are fused using cross-attention layers that produce attention maps for each textual token. Bottom: we control the spatial layout and geometry of the generated image using the attention maps of a source image. This enables various editing tasks through editing the textual prompt only. When swapping a word in the prompt, we inject the source image maps $M _ { t }$ , overriding the target maps $M _ { t } ^ { * }$ . In the case of adding a refinement phrase, we inject only the maps that correspond to the unchanged part of the prompt. To amplify or attenuate the semantic effect of a word, we re-weight the corresponding attention map.
|
| 46 |
+
|
| 47 |
+
# 3.1 CROSS-ATTENTION IN TEXT-CONDITIONED DIFFUSION MODELS
|
| 48 |
+
|
| 49 |
+
In this section, we refer to the Imagen (Saharia et al., 2022b) text-guided synthesis model as our backbone, although our method is not limited to a specific model, and results with Latent Diffusion and Stable Diffusion (Rombach et al., 2021) are presented in section 4.1 and appendix C. All three models condition on the text prompt in the noise prediction of each diffusion step throughout cross-attention layers. For further details about the attention layers within each model, please see appendix A.2. Since the composition and geometry are mostly determined at the $6 4 \times 6 4$ resolution, we only adapt the text-to-image diffusion model, using the super-resolution process as is. Recall that each diffusion step $t$ consists of predicting the noise $\epsilon$ from a noisy image $z _ { t }$ and text embedding $\psi ( \mathcal P )$ using a U-shaped network (Ronneberger et al., 2015). At the final step, this process yields the generated image $\mathcal { T } = z _ { 0 }$ . Most importantly, the interaction between the two modalities occurs during the noise prediction, where the embeddings of the visual and textual features are fused using cross-attention layers that produce spatial attention maps for each textual token. More formally, as illustrated in fig. 3 (top), the deep spatial features of the noisy image $\phi ( { \boldsymbol { z } } _ { t } )$ are projected to a query matrix $Q = \ell _ { Q } ( \phi ( z _ { t } ) )$ , and the textual embedding is projected to a key matrix $\bar { \boldsymbol { K } } \doteq \ell _ { K } ( \psi ( \mathcal { P } ) \bar { ) }$ and a value matrix $V = \ell _ { V } ( \psi ( \mathcal { P } ) )$ , via learned linear projections $\ell _ { Q } , \ell _ { K } , \ell _ { V }$ . Attention maps are then
|
| 50 |
+
|
| 51 |
+
$$
|
| 52 |
+
M = \mathrm { S o f t m a x } \left( \frac { Q K ^ { T } } { \sqrt { d } } \right) ,
|
| 53 |
+
$$
|
| 54 |
+
|
| 55 |
+
where the cell $M _ { i j }$ defines the weight of the value of the $j$ -th token on the pixel $i$ , and $d$ is the latent projection dimension of the keys and queries. Finally, the cross-attention output is defined to be $\widehat { \phi } \left( \widehat { z } _ { t } \right) = M V$ , which is then used to update the spatial features $\phi \big ( z _ { t } \big )$ .
|
| 56 |
+
|
| 57 |
+
Intuitively, the cross-attention output $M V$ is a weighted average of the values $V$ where the weights are the attention maps $M$ , which are correlated to the similarity between $Q$ and $K$ . In practice, to increase their expressiveness, multi-head attention (Vaswani et al., 2017) is used in parallel, and then the results are concatenated and passed through a learned linear layer to get the final output.
|
| 58 |
+
|
| 59 |
+
# 3.2 CONTROLLING THE CROSS-ATTENTION
|
| 60 |
+
|
| 61 |
+
We return to our key observation — the spatial layout and geometry of the generated image depend on the cross-attention maps. The interaction between pixels and text is illustrated in fig. 4, where the average attention maps are plotted. As can be seen, pixels are more attracted to the words that describe them, e.g., pixels of the bear are correlated with the word “bear”. Note that averaging is done for visualization purposes, and attention maps are kept separate for each head. Interestingly, we can see that the structure is already determined in the early steps of the diffusion process.
|
| 62 |
+
|
| 63 |
+
Since the attention reflects the overall composition, we can inject the attention maps $M$ that were obtained from the generation with the original prompt $\mathcal { P }$ , into a second generation with the modified prompt ${ \mathcal { P } } ^ { * }$ . This allows the synthesis of an edited image $\mathcal { T } ^ { * }$ that is not only manipulated according to the edited prompt, but also preserves the structure of the input image $\mathcal { T }$ . This is a specific instance of a broader set of attention-based manipulations leading to different types of intuitive editing. We, therefore, start by proposing a general framework, followed by the details of the specific operations.
|
| 64 |
+
|
| 65 |
+

|
| 66 |
+
Figure 4: Cross-attention maps of a text-conditioned diffusion image generation. Top: average attention masks for each word in the prompt which was used to synthesize the left image. Bottom: attention maps with respect to the word “bear” from different diffusion steps, ranging from the first step $T = 2 5 6$ to the last step $t = 1$ in equal intervals.
|
| 67 |
+
|
| 68 |
+
Let $D M ( \boldsymbol { z } _ { t } , \mathcal { P } , t , \boldsymbol { s } )$ be the computation of a single step $t$ of the diffusion process, which outputs the noisy image $z _ { t - 1 }$ , and the attention map $M _ { t }$ (omitted if not used). We denote by ${ \cal D } M ( z _ { t } , \mathcal { P } , t , s ) \{ M \widehat { M } \}$ the diffusion step where we override the attention map $M$ with an additional given map $\widehat { M }$ , but keep the values $V$ from the supplied prompt. We also denote by $M _ { t } ^ { * }$ the produced attention map using the edited prompt ${ \mathcal { P } } ^ { * }$ . Lastly, we define $E d i t ( M _ { t } , M _ { t } ^ { * } , t )$ to be a general edit function, receiving as input the $t ^ { \prime }$ ’th attention maps of the original and edited images.
|
| 69 |
+
|
| 70 |
+
Our general algorithm for controlled generation consists of performing the iterative diffusion process for both prompts simultaneously, where an attention-based manipulation is applied in each step according to the desired editing task. We fix the internal randomness since even for the same prompt, two random seeds produce drastically different outputs. We also define a local editing scheme in a subsequent paragraph. Formally, our general algorithm for editing the image $\mathcal { T }$ , which is generated by prompt $\mathcal { P }$ and seed $s$ , is defined:
|
| 71 |
+
|
| 72 |
+
1 Input: A source prompt $\mathcal { P }$ , a target prompt ${ \mathcal { P } } ^ { * }$ , and a random seed $s$ .
|
| 73 |
+
2 Optional for local editing: $w$ and $w ^ { * }$ , words in $\mathcal { P }$ and ${ \mathcal { P } } ^ { * }$ , specifying the editing region.
|
| 74 |
+
3 Output: A source image $x _ { s r c }$ and an edited image $x _ { d s t }$ .
|
| 75 |
+
4 $z _ { T } \sim N ( 0 , I )$ a unit Gaussian random variable with random seed $s$ ;
|
| 76 |
+
5 $z _ { T } ^ { * } \gets z _ { T }$ ;
|
| 77 |
+
6 for $t = T , T - 1 , \dots , 1$ do
|
| 78 |
+
7 $z _ { t - 1 } , M _ { t } \gets D M ( z _ { t } , \mathcal { P } , t , s ) ;$ ;
|
| 79 |
+
8 $M _ { t } ^ { * } \gets D M ( z _ { t } ^ { * } , \mathcal { P } ^ { * } , t , s )$ ;
|
| 80 |
+
9 $\widehat { M _ { t } } \gets E d i t ( M _ { t } , M _ { t } ^ { * } , t ) ;$ ;
|
| 81 |
+
10 $z _ { t - 1 } ^ { * } D M ( z _ { t } ^ { * } , \mathcal { P } ^ { * } , t , s ) \{ M \widehat { M } _ { t } \} ;$
|
| 82 |
+
11 if local then
|
| 83 |
+
12 $\begin{array} { r l } & { \alpha B ( \overline { { M } } _ { t , w } ) \cup B ( \overline { { M } } _ { t , w ^ { * } } ^ { * } ) ; } \\ & { z _ { t - 1 } ^ { * } ( 1 - \alpha ) \odot z _ { t - 1 } + \alpha \odot z _ { t - 1 } ^ { * } } \end{array}$
|
| 84 |
+
13
|
| 85 |
+
14 end
|
| 86 |
+
15 end
|
| 87 |
+
16 Return $( z _ { 0 } , z _ { 0 } ^ { * } )$
|
| 88 |
+
|
| 89 |
+
For editing real images, see section 4. Also, note that we can skip the forward call in line 8 by applying the edit function inside the diffusion forward function. Moreover, a diffusion step can be applied on both $z _ { t - 1 }$ and $z _ { t } ^ { * }$ in the same batch (i.e., in parallel). We now turn to address local editing followed by specific editing operations, filling the missing definition of the $E d i t ( M _ { t } , M _ { t } ^ { * } , t )$ function. An overview is presented in fig. 3(Bottom).
|
| 90 |
+
|
| 91 |
+
Local Editing. In a common scenario, the user would like to modify a specific object or region, while preserving the rest of the details (i.e., background). For this purpose, we utilize the crossattention map layers corresponding to the edited object. In practice, we approximate a mask of the edited part and constrain the modification to be applied only in this local region (lines 11-14 in Algorithm 1). To calculate the mask at step $t$ , we compute the average attention map $\overline { { M } } _ { t , w }$ (averaged over steps $T , \ldots , t )$ of the original word $w$ and the map $\overline { { M } } _ { t , w ^ { * } } ^ { * }$ of the new word $w *$ . We then apply a threshold to produce binary maps, where $B ( x ) : = x > k$ and $k = 0 . 3$ throughout all our experiments. To support geometry modifications of the object, the edited region should include the silhouettes of both the original and the newly edited object, therefore, our final mask $\alpha$ is a union of the binary maps. Lastly, we use the mask to constrain the editing region (line 13), where $\odot$ denotes an element-wise multiplication.
|
| 92 |
+
|
| 93 |
+

|
| 94 |
+
Figure 5: Attention injection through a varied number of diffusion steps. We edit the image by replacing a word and injecting the cross-attention maps of the source image ranging from $0 \%$ (left) to $100 \%$ (right) of the steps. Without injection, none of the source content is preserved, while injecting throughout all the steps may over-constrain the geometry. The latter results in low fidelity to the text, e.g., the car becomes a bicycle. The full figure is in the appendix (fig. 11).
|
| 95 |
+
|
| 96 |
+
Word Swap. In this case, the user swaps tokens of the original prompt with others, e.g., $\mathcal { P } = ^ { 6 } \mathrm { { a } }$ big bicycle” to ${ \mathcal { P } } ^ { * } = { } ^ { * } { \bf { a } }$ big car”. The main challenge is to preserve the original composition while also addressing the content of the new prompt. To this end, we inject the attention maps of the source image into the generation with the modified prompt. However, the proposed attention injection may over-constrain the geometry, especially when a large structural modification, such as “car” to “bicycle”, is involved. We address this by suggesting a softer attention constrain:
|
| 97 |
+
|
| 98 |
+
$$
|
| 99 |
+
E d i t ( M _ { t } , M _ { t } ^ { * } , t ) : = { \left\{ \begin{array} { l l } { M _ { t } ^ { * } \quad } & { { \mathrm { i f ~ } } t < \tau } \\ { M _ { t } \quad } & { { \mathrm { o t h e r w i s e , } } } \end{array} \right. }
|
| 100 |
+
$$
|
| 101 |
+
|
| 102 |
+
where $\tau$ is a timestamp parameter that determines until which step the injection is applied. Note that the composition is determined in the early steps. Therefore, by limiting the number of injection steps, we can guide the composition while allowing the necessary geometry freedom for adapting to the new prompt. An illustration is provided in section 4. Another relaxation is to assign a different number of injection steps for the different tokens in the prompt. If the two words are represented using a different number of tokens, we duplicate/average the maps as necessary using an alignment function as described in the next paragraph.
|
| 103 |
+
|
| 104 |
+
Prompt Refinement. In another setting, the user adds new tokens to the prompt, e.g., $\mathcal { P } \mathrm { ~ = ~ } ^ { \ast } \mathrm { a }$ castle” to ${ \mathcal { P } } ^ { * } =$ “children drawing of a castle”. To preserve the common details, we apply the attention injection only over the common tokens from both prompts. Formally, we use an alignment function $A$ that receives a token index from target prompt ${ \mathcal { P } } ^ { * }$ and outputs the corresponding token index in $\mathcal { P }$ or None if there isn’t a match. Then, the editing function is:
|
| 105 |
+
|
| 106 |
+
$$
|
| 107 |
+
\begin{array} { r } { \big ( E d i t \left( M _ { t } , M _ { t } ^ { * } , t \right) \big ) _ { i , j } : = \left\{ \begin{array} { l l } { \big ( M _ { t } ^ { * } \big ) _ { i , j } \quad } & { \mathrm { ~ i f ~ } A ( j ) = N o n e } \\ { \big ( M _ { t } \big ) _ { i , A ( j ) } \quad } & { \mathrm { ~ o t h e r w i s e . } } \end{array} \right. } \end{array}
|
| 108 |
+
$$
|
| 109 |
+
|
| 110 |
+
Recall that the index $i$ corresponds to a pixel value, where $j$ corresponds to a text token. Again, we may control the number of injection steps. This enables diverse capabilities such as stylization, specification of object attributes, or global manipulations as demonstrated in section 4.
|
| 111 |
+
|
| 112 |
+
Attention Re–weighting. Lastly, the user may wish to strengthen or weakens the extent to which each token affects the resulting image. For example, consider the prompt $\mathcal { P } = { ^ { 6 } } \mathrm { a }$ fluffy ball”, and assume we want to make the ball more or less fluffy. To achieve such a manipulation, we scale the attention map of the assigned token $j ^ { * }$ with a parameter $c \in [ - 2 , 2 ]$ , resulting in a stronger/weaker effect. The rest of the attention maps remain unchanged. The editing function is therefore:
|
| 113 |
+
|
| 114 |
+
$$
|
| 115 |
+
\big ( E d i t ( M _ { t } , M _ { t } ^ { * } , t ) \big ) _ { i , j } : = \left\{ \begin{array} { l l } { c \cdot ( M _ { t } ) _ { i , j } \quad } & { \mathrm { i f ~ } j = j ^ { * } } \\ { ( M _ { t } ) _ { i , j } \quad } & { \mathrm { o t h e r w i s e . } } \end{array} \right.
|
| 116 |
+
$$
|
| 117 |
+
|
| 118 |
+
As described in section 4, the parameter $c$ allows fine and intuitive control over the induced effect. In addition, since fine textures are generated during the super-resolution phase, we observe that this application can benefit from applying our method also to the super-resolution diffusion model in the case of amplifying or attenuating such fine textures, such as “fluffiness” as shown in fig. 7.
|
| 119 |
+
|
| 120 |
+

|
| 121 |
+
Figure 6: Editing by prompt refinement. By extending the description of the initial prompt, we perform local or global editing. Additional results are in the appendix (fig. 13, 23) .
|
| 122 |
+
|
| 123 |
+

|
| 124 |
+
“The picnic is ready under a blossom( ) tree.”
|
| 125 |
+
Figure 7: Text-based editing with fader control. By reducing or increasing the cross-attention of specific words (marked with an arrow), we control the extent to which it influences the generation. Additional results are in the appendix (fig. 24).
|
| 126 |
+
|
| 127 |
+
# 3.3 SELF-ATTENTION
|
| 128 |
+
|
| 129 |
+
“My fluffy( ) bunny doll.Most models also consist of self-attention layers, which affect the spatial layout and geometry of the generated image as well. However, unlike cross-attention, the interaction that occurs in selfattention layers is only between the pixels to themselves. Therefore, manipulations with respect to specific textual tokens are not feasible. For example, our proposed attention re-weighting and local editing require the matching between the cross-attention maps to the prompt tokens. Another example is presented in the appendix (fig. 16), where we do not inject the attention of the entire prompt but only the attention of a specific word – “butterfly”. This enables the preservation of the original butterfly while changing the rest of the content. Contrarily, we can’t specify which object should be preserved using only self-attention. Moreover, we observe that the self-attention maps provide inferior semantic control compared to the cross-attention. For instance, as demonstrated in the appendix (fig. 17), using cross-attention injection we can swap between apples and oranges by swapping these words in the prompt. The same experiment fails when using self-attention which lacks a strong interaction between textual tokens and pixels.
|
| 130 |
+
|
| 131 |
+
Yet, we find that injecting self-attention through a small portion $( 2 0 \% )$ of the steps in addition to cross-attention injection might further help preserve the source content in some cases. And so, we consider it as an additional tool for Prompt-to-Prompt editing. We provide further analysis in appendix B.
|
| 132 |
+
|
| 133 |
+
# 4 RESULTS
|
| 134 |
+
|
| 135 |
+
In this section, we show several applications of our approach and compare it to other methods.
|
| 136 |
+
|
| 137 |
+
# 4.1 APPLICATIONS
|
| 138 |
+
|
| 139 |
+
Text-Only Localized Editing. We first demonstrate localized editing by modifying the userprovided prompt without requiring any user-provided mask. In fig. 2, we generate an image using the prompt “lemon cake”. Our method allows us to retain the spatial layout, geometry, and semantics when replacing the word “lemon” with “apple” (top row). Observe that the background is well-preserved, including the top-left lemons transforming into apples. On the other hand, naively feeding the model with the prompt “apple cake” results in a completely different geometry (2nd row), even when using the same randomness in a deterministic setting (DDIM). Our method succeeds even for a challenging “pasta cake.” — the generated cake consists of pasta layers with tomato sauce on top. In case the user adds a new specification, we keep the attention maps of the original prompt, while allowing the generator to address the newly added words. For example, see fig. 6, where we add “old” to the “car”, resulting in newly added details over the source car while the background is preserved. Additional results are in the appendix (fig. 16, 22, and 23).
|
| 140 |
+
|
| 141 |
+
As presented in fig. 5, our method is not confined to modifying only textures and can modify the structure as well, e.g., changing a “bicycle” to a “car”. We first show the results without crossattention injection, where changing a word leads to an entirely different outcome. We then show the resulting image by injecting attention to an increasing number of steps. Note that applying the cross-attention injection in a larger number of steps results in greater similarity to the source image. Therefore, the optimal result is not necessarily achieved by applying the injection throughout all steps. This enables us an even better control by changing the number of injection steps.
|
| 142 |
+
|
| 143 |
+
Table 1: User Study results. The participants were asked to rate: (1) background / structure preservation with respect to the source image, (2) alignment to the text, and (3) realism.
|
| 144 |
+
|
| 145 |
+
<table><tr><td></td><td>VQGAN+CLIP</td><td>Text2Live</td><td>baseline</td><td>Ours</td></tr><tr><td>(1) Background / Structure ↑</td><td>1.84 ± 1.11</td><td>4.15 ± 1.09</td><td>3.38 ± 1.12</td><td>4.64 ± 0.64</td></tr><tr><td>(2) Text Alignment ↑</td><td>2.46 ± 1.16</td><td>2.89 ±1.22</td><td>4.26 ± 1.03</td><td>4.55 ± 0.71</td></tr><tr><td>(3) Realism ↑</td><td>1.32 ± 0.70</td><td>2.36 ± 1.12</td><td>4.11 ± 0.93</td><td>4.42 ± 0.82</td></tr></table>
|
| 146 |
+
|
| 147 |
+
Global editing. Preserving the composition is not only valuable for local editing, but also an important aspect of global editing. In this setting, the editing should affect all parts of the image, but still retain the original composition, such as the location and identity of the objects. For example, in fig. 6, we preserve the content while changing the lighting. Additional examples are in the appendix (fig. 18), including translating a sketch into a realistic image and inducing an artistic style.
|
| 148 |
+
|
| 149 |
+
Fader Control using Attention Re-weighting. While controlling the image by editing the prompt is very effective, we find that it still does not allow full control over the generated image. Consider the prompt “snowy mountain”. A user may want to control the amount of snow on the mountain. However, it is quite difficult to describe the desired amount of snow through text. Instead, we suggest a fader control (Lample et al., 2017), where the user controls the magnitude of the effect induced by a specific word, as in fig. 7. As described in section 3.2, we achieve such control by re-scaling the attention of the specified word. Additional results are in the appendix (fig. 24, 27 and 30).
|
| 150 |
+
|
| 151 |
+
Different Backbone We use the Imagen (Saharia et al., 2022b) model as a backbone for most of our experiments and results, exploiting its state-of-the-art synthesis quality. However, our method is not limited to a specific model and can be applied to different models as long as they consist of cross-attention layers which are widely used. To validate this, we present results in the appendix (fig. 25, 26, 27, 28, 29, and 30) using the public and popular Latent Diffusion and Stable Diffusion models (Rombach et al., 2021). As can be seen, our method works well using these models as a backbone, enabling various editing capabilities while preserving the source image content. Further analysis is provided in appendix C.1.
|
| 152 |
+
|
| 153 |
+
Real Image Editing. Editing a real image requires finding an initial noise vector that produces the given input image when fed into the diffusion process. This process, known as inversion, has recently drawn considerable attention for GANs (Xia et al., 2021b; Bermano et al., 2022), but has not yet been fully addressed for text-guided diffusion models. We show preliminary editing results on real images, based on common inversion techniques for diffusion models. First, a rather na¨ıve approach is to add Gaussian noise to the input image, and then perform a predefined number of diffusion steps. Since this results in significant distortions, we adopt an improved inversion approach (Dhariwal & Nichol, 2021; Song et al., 2020), which is based on the deterministic DDIM model rather than the DDPM. We perform the diffusion process in the reverse direction, that is $x _ { 0 } x _ { T }$ instead of $x _ { T } \to x _ { 0 }$ , where $x _ { 0 }$ is set to be the given real image. This process often produces satisfying results, as presented in the appendix (fig. 19). However, the inversion is not sufficiently accurate in other cases, as in fig. 20. This is partially due to a distortion-editability tradeoff, where we recognize that reducing the classifier-free guidance (Ho & Salimans, 2021) parameter (i.e., reducing the prompt influence) improves reconstruction but constrains our ability to perform significant manipulations.
|
| 154 |
+
|
| 155 |
+
To alleviate this limitation, we propose to restore the unedited regions of the original image using a mask, directly extracted from the attention maps. Note that here the mask is generated with no guidance from the user, as described in the local editing paragraph (section 3.2). As presented in fig. 21, this approach works well even using the na¨ıve DDPM inversion scheme (adding noise followed by denoising). Note that the cat’s identity is well-preserved under various editing operations, while the mask is produced only from the prompt itself.
|
| 156 |
+
|
| 157 |
+
# 4.2 COMPARISONS
|
| 158 |
+
|
| 159 |
+
To evaluate our method, we first randomly generate text-based editing examples from predefined text templates, see appendix F for more details. Source text is then fed to the Imagen model to obtain the source image. We compare our results to other text-guided editing methods: (1) $V Q G A N { + } C L I P$ (Crowson, 2021), (2) Text2Live (Bar-Tal et al., 2022), (3) Blended Diffusion Avrahami et al. (2022b) and (4) Glide (Nichol et al., 2021). We also consider (5) a baseline approach where we only replace the source prompt with the target prompt after $2 0 \%$ of diffusion steps using the same random seed.
|
| 160 |
+
|
| 161 |
+

|
| 162 |
+
“Photo of a squirrel bear enjoys at the playground.”
|
| 163 |
+
Figure 8: Visual comparison. Top: text-guided editing methods (same supervision as ours). Bottom: text-guided inpainting methods which rely on an additional input mask (on the left).
|
| 164 |
+
|
| 165 |
+
Qualitative Comparison. As can be seen in fig. 8, both VQGAN $^ +$ CLIP and Text2Live may result in severe artifacts when editing highly structured objects, e.g., a squirrel to a bear. Our method and Text2Live better preserve the background since both methods estimate a mask editing layer. In contrast, the baseline approach produces realistic and meaningful results, but fails to preserve the background. Furthermore, both VQGAN $+ \ell$ CLIP and Text2Live require optimization per example which takes 3 and 9 minutes respectively on a GPU. Our method is applied in a single diffusion pass which takes up to 20 seconds.
|
| 166 |
+
|
| 167 |
+
We also consider text-driven inpainting methods which rely on a given user-defined mask. As can be seen in fig. 8, Glide and Blended Diffusion do produce meaningful edits, but fail to preserve the original structure. Note that these approaches are limited to local changes and cannot handle global edits such as changing the weather in the image. See fig. 14 and 15 in the appendix for more qualitative comparisons.
|
| 168 |
+
|
| 169 |
+
Quantitative Comparison. In the absence of ground truth for text-based editing, quantitative evaluation remains an open challenge. Therefore, similar to (Bar-Tal et al., 2022), we present a user study in table 1. The participants were asked to rate each result in terms of (1) background and structure preservation with respect to the source image, (2) alignment to the text, and (3) realism. Please see appendix E for more details. As shown, the users preferred our method with regard to all three aspects. Glide and Blended Diffusion were not quantitatively evaluated since they require manual labor to produce the input masks.
|
| 170 |
+
|
| 171 |
+
We provide additional measures in the appendix (table 2) to further validate our claims. We evaluate text-image correspondence using their CLIP score, demonstrating competitive results to methods that directly optimize this metric. In addition, we evaluate the perceptual similarity between the original and edited images using LPIPS (Zhang et al., 2018a) and MS-SSIM (Wang et al., 2003). This shows our capability of performing local editing, similar to Text2Live (Bar-Tal et al., 2022). However, CLIP score and perceptual similarity do not reflect our superior quality and realism which are demonstrated in the user study.
|
| 172 |
+
|
| 173 |
+
# 5 CONCLUSIONS
|
| 174 |
+
|
| 175 |
+
In this work, we uncovered the powerful capabilities of the cross-attention layers within text-toimage diffusion models. We showed that these high-dimensional layers have an interpretable representation of spatial maps that play a key role in tying the words in the text prompt to the spatial layout of the synthesized image. With this observation, we showed how various manipulations of the prompt can directly control attributes in the synthesized image, paving the way to various applications including local and global editing. This work is a first step towards providing users with simple and intuitive means to edit images and navigate through a semantic, textual, space, which exhibits incremental changes after each step, rather than producing an image from scratch after each text manipulation.
|
| 176 |
+
|
| 177 |
+
# 6 ETHIC STATEMENT
|
| 178 |
+
|
| 179 |
+
Our work suggests a new editing technique for images that are generated using state-of-the-art textto-image diffusion models. As explained in section 4.1 and appendix D, our approach can edit real images, although this still remains a more challenging setting. Such manipulation of real photos might be exploited by malicious parties to produce fake content in order to spread disinformation. This is a known problem, common to all image editing techniques. However, research in identifying and preventing malicious editing is already making significant progress. We believe our work would contribute to this line of work, since we provide a comprehensive analysis of the editing procedure using text-to-image diffusion models.
|
| 180 |
+
|
| 181 |
+
# ACKNOWLEDGMENTS
|
| 182 |
+
|
| 183 |
+
We thank Noa Glaser, Adi Zicher, Yaron Brodsky, Shlomi Fruchter and David Salesin for their valuable inputs that helped improve this work, and to Mohammad Norouzi, Chitwan Saharia and William Chan for providing us with their support and the pretrained models of Imagen (Saharia et al., 2022b). Special thanks to Yossi Matias for early inspiring discussion on the problem and for motivating and encouraging us to develop technologies along the avenue of intuitive interaction.
|
| 184 |
+
|
| 185 |
+
# REFERENCES
|
| 186 |
+
|
| 187 |
+
Omri Avrahami, Ohad Fried, and Dani Lischinski. Blended latent diffusion. arXiv preprint arXiv:2206.02779, 2022a.
|
| 188 |
+
Omri Avrahami, Dani Lischinski, and Ohad Fried. Blended diffusion for text-driven editing of natural images. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 18208–18218, 2022b.
|
| 189 |
+
Omer Bar-Tal, Dolev Ofri-Amar, Rafail Fridman, Yoni Kasten, and Tali Dekel. Text2live: Textdriven layered image and video editing. arXiv preprint arXiv:2204.02491, 2022.
|
| 190 |
+
David Bau, Alex Andonian, Audrey Cui, YeonHwan Park, Ali Jahanian, Aude Oliva, and Antonio Torralba. Paint by word, 2021.
|
| 191 |
+
Amit H Bermano, Rinon Gal, Yuval Alaluf, Ron Mokady, Yotam Nitzan, Omer Tov, Oren Patashnik, and Daniel Cohen-Or. State-of-the-art in the architecture, methods and applications of stylegan. In Computer Graphics Forum, volume 41, pp. 591–611. Wiley Online Library, 2022.
|
| 192 |
+
Andrew Brock, Jeff Donahue, and Karen Simonyan. Large scale gan training for high fidelity natural image synthesis. arXiv preprint arXiv:1809.11096, 2018.
|
| 193 |
+
Katherine Crowson. Vqgan $^ +$ clip, 2021. https://colab.research.google.com/ drive/1L8oL-vLJXVcRzCFbPwOoMkPKJ8-aYdPN.
|
| 194 |
+
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.
|
| 195 |
+
Prafulla Dhariwal and Alexander Nichol. Diffusion models beat gans on image synthesis. Advances in Neural Information Processing Systems, 34:8780–8794, 2021.
|
| 196 |
+
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:19822–19835, 2021.
|
| 197 |
+
Patrick Esser, Robin Rombach, and Bjorn Ommer. Taming transformers for high-resolution image ¨ synthesis. 2021 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), pp. 12868–12878, 2021a.
|
| 198 |
+
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, pp. 12873–12883, 2021b.
|
| 199 |
+
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.
|
| 200 |
+
Rinon Gal, Or Patashnik, Haggai Maron, Gal Chechik, and Daniel Cohen-Or. Stylegan-nada: Clipguided domain adaptation of image generators. arXiv preprint arXiv:2108.00946, 2021.
|
| 201 |
+
Ian Goodfellow, Jean Pouget-Abadie, Mehdi Mirza, Bing Xu, David Warde-Farley, Sherjil Ozair, Aaron Courville, and Yoshua Bengio. Generative adversarial nets. Advances in neural information processing systems, 27, 2014.
|
| 202 |
+
Tobias Hinz, Stefan Heinrich, and Stefan Wermter. Semantic object accuracy for generative text-toimage synthesis. IEEE transactions on pattern analysis and machine intelligence, 2020.
|
| 203 |
+
Jonathan Ho and Tim Salimans. Classifier-free diffusion guidance. In NeurIPS 2021 Workshop on Deep Generative Models and Downstream Applications, 2021.
|
| 204 |
+
Jonathan Ho, Ajay Jain, and Pieter Abbeel. Denoising diffusion probabilistic models. Advances in Neural Information Processing Systems, 33:6840–6851, 2020.
|
| 205 |
+
Jonathan Ho, Chitwan Saharia, William Chan, David J Fleet, Mohammad Norouzi, and Tim Salimans. Cascaded diffusion models for high fidelity image generation. J. Mach. Learn. Res., 23: 47–1, 2022.
|
| 206 |
+
Tero Karras, Samuli Laine, and Timo Aila. A style-based generator architecture for generative adversarial networks. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 4401–4410, 2019.
|
| 207 |
+
Gwanghyun Kim, Taesung Kwon, and Jong Chul Ye. Diffusionclip: Text-guided diffusion models for robust image manipulation. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 2426–2435, 2022.
|
| 208 |
+
Gihyun Kwon and Jong Chul Ye. Clipstyler: Image style transfer with a single text condition. arXiv preprint arXiv:2112.00374, 2021.
|
| 209 |
+
Guillaume Lample, Neil Zeghidour, Nicolas Usunier, Antoine Bordes, Ludovic Denoyer, and Marc’Aurelio Ranzato. Fader networks: Manipulating images by sliding attributes. Advances in neural information processing systems, 30, 2017.
|
| 210 |
+
Bowen Li, Xiaojuan Qi, Thomas Lukasiewicz, and Philip Torr. Controllable text-to-image generation. Advances in Neural Information Processing Systems, 32, 2019.
|
| 211 |
+
Ron Mokady, Omer Tov, Michal Yarom, Oran Lang, Inbar Mosseri, Tali Dekel, Daniel Cohen-Or, and Michal Irani. Self-distilled stylegan: Towards generation from internet photos. In Special Interest Group on Computer Graphics and Interactive Techniques Conference Proceedings, pp. 1–9, 2022.
|
| 212 |
+
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.
|
| 213 |
+
Or Patashnik, Zongze Wu, Eli Shechtman, Daniel Cohen-Or, and Dani Lischinski. Styleclip: Textdriven manipulation of stylegan imagery. arXiv preprint arXiv:2103.17249, 2021.
|
| 214 |
+
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. arXiv preprint arXiv:2103.00020, 2021.
|
| 215 |
+
Colin Raffel, Noam Shazeer, Adam Roberts, Katherine Lee, Sharan Narang, Michael Matena, Yanqi Zhou, Wei Li, Peter J Liu, et al. Exploring the limits of transfer learning with a unified text-to-text transformer. J. Mach. Learn. Res., 21(140):1–67, 2020.
|
| 216 |
+
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, pp. 8821–8831. PMLR, 2021.
|
| 217 |
+
|
| 218 |
+
Aditya Ramesh, Prafulla Dhariwal, Alex Nichol, Casey Chu, and Mark Chen. Hierarchical textconditional image generation with clip latents. arXiv preprint arXiv:2204.06125, 2022.
|
| 219 |
+
|
| 220 |
+
Robin Rombach, Andreas Blattmann, Dominik Lorenz, Patrick Esser, and Bjorn Ommer. High- ¨ resolution image synthesis with latent diffusion models, 2021.
|
| 221 |
+
|
| 222 |
+
Olaf Ronneberger, Philipp Fischer, and Thomas Brox. U-net: Convolutional networks for biomedical image segmentation. In International Conference on Medical image computing and computerassisted intervention, pp. 234–241. Springer, 2015.
|
| 223 |
+
|
| 224 |
+
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.
|
| 225 |
+
|
| 226 |
+
Chitwan Saharia, William Chan, Huiwen Chang, Chris Lee, Jonathan Ho, Tim Salimans, David Fleet, and Mohammad Norouzi. Palette: Image-to-image diffusion models. In ACM SIGGRAPH 2022 Conference Proceedings, pp. 1–10, 2022a.
|
| 227 |
+
|
| 228 |
+
Chitwan Saharia, William Chan, Saurabh Saxena, Lala Li, Jay Whang, Emily Denton, Seyed Kamyar Seyed Ghasemipour, Burcu Karagol Ayan, S Sara Mahdavi, Rapha Gontijo Lopes, Tim Salimans, Tim Salimans, Jonathan Ho, David J Fleet, and Mohammad Norouzi. Photorealistic textto-image diffusion models with deep language understanding. arXiv preprint arXiv:2205.11487, 2022b.
|
| 229 |
+
|
| 230 |
+
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.
|
| 231 |
+
|
| 232 |
+
Jiaming Song, Chenlin Meng, and Stefano Ermon. Denoising diffusion implicit models. In International Conference on Learning Representations, 2020.
|
| 233 |
+
|
| 234 |
+
Yang Song and Stefano Ermon. Generative modeling by estimating gradients of the data distribution. Advances in Neural Information Processing Systems, 32, 2019.
|
| 235 |
+
|
| 236 |
+
Ming Tao, Hao Tang, Songsong Wu, Nicu Sebe, Xiao-Yuan Jing, Fei Wu, and Bingkun Bao. Dfgan: Deep fusion generative adversarial networks for text-to-image synthesis. arXiv preprint arXiv:2008.05865, 2020.
|
| 237 |
+
|
| 238 |
+
Narek Tumanyan, Omer Bar-Tal, Shai Bagon, and Tali Dekel. Splicing vit features for semantic appearance transfer. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 10748–10757, 2022.
|
| 239 |
+
|
| 240 |
+
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, volume 30, 2017.
|
| 241 |
+
|
| 242 |
+
Zhou Wang, Eero P Simoncelli, and Alan C Bovik. Multiscale structural similarity for image quality assessment. In The Thrity-Seventh Asilomar Conference on Signals, Systems & Computers, 2003, volume 2, pp. 1398–1402. Ieee, 2003.
|
| 243 |
+
|
| 244 |
+
Weihao Xia, Yujiu Yang, Jing-Hao Xue, and Baoyuan Wu. Tedigan: Text-guided diverse face image generation and manipulation. In Proceedings of the IEEE/CVF conference on computer vision and pattern recognition, pp. 2256–2265, 2021a.
|
| 245 |
+
|
| 246 |
+
Weihao Xia, Yulun Zhang, Yujiu Yang, Jing-Hao Xue, Bolei Zhou, and Ming-Hsuan Yang. Gan inversion: A survey, 2021b.
|
| 247 |
+
|
| 248 |
+
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.
|
| 249 |
+
|
| 250 |
+
Jiahui Yu, Yuanzhong Xu, Jing Yu Koh, Thang Luong, Gunjan Baid, Zirui Wang, Vijay Vasudevan, Alexander Ku, Yinfei Yang, Burcu Karagol Ayan, et al. Scaling autoregressive models for contentrich text-to-image generation. arXiv preprint arXiv:2206.10789, 2022.
|
| 251 |
+
|
| 252 |
+
Richard Zhang, Phillip Isola, Alexei A. Efros, Eli Shechtman, and Oliver Wang. The unreasonable effectiveness of deep features as a perceptual metric. 2018 IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 586–595, 2018a.
|
| 253 |
+
|
| 254 |
+
Zizhao Zhang, Yuanpu Xie, and Lin Yang. Photographic text-to-image synthesis with a hierarchically-nested adversarial network. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 6199–6208, 2018b.
|
| 255 |
+
|
| 256 |
+
# A BACKGROUND
|
| 257 |
+
|
| 258 |
+
# A.1 DIFFUSION MODELS
|
| 259 |
+
|
| 260 |
+
Diffusion Denoising Probabilistic Models (DDPM) Sohl-Dickstein et al. (2015); Ho et al. (2020) are generative latent variable models that aim to model a distribution $p _ { \theta } ( x _ { 0 } )$ that approximates the data distribution $q ( x _ { 0 } )$ and easy to sample from. DDPMs model a “forward process” in the space of $x _ { 0 }$ from data to noise.1 This process is a Markov chain starting from $x _ { 0 }$ , where we gradually add noise to the data to generate the latent variables $x _ { 1 } , \dots , x _ { T } \in X$ . The sequence of latent variables therefore follows $\begin{array} { r } { \dot { q ( x _ { 1 } , \dots , x _ { t } \mid x _ { 0 } ) } = \prod _ { i = 1 } ^ { t } q ( x _ { t } \mid x _ { t - 1 } ) } \end{array}$ , where a step in the forward process is defined as a Gaussian transition $q ( x _ { t } \mid x _ { t - 1 } ) : = N ( x _ { t } ; { \sqrt { 1 - \beta _ { t } } } x _ { t - 1 } , \beta _ { t } I )$ parameterized by a schedule $\beta _ { 0 } , \dots , \beta _ { T } \in ( 0 , 1 )$ . When $T$ is large enough, the last noise vector $x _ { T }$ nearly follows an isotropic Gaussian distribution.
|
| 261 |
+
|
| 262 |
+
An interesting property of the forward process is that one can express the latent variable $x _ { t }$ directly as the following linear combination of noise and $x _ { 0 }$ without sampling intermediate latent vectors:
|
| 263 |
+
|
| 264 |
+
$$
|
| 265 |
+
x _ { t } = \sqrt { \alpha _ { t } } x _ { 0 } + \sqrt { 1 - \alpha _ { t } } w , \ w \sim N ( 0 , I ) ,
|
| 266 |
+
$$
|
| 267 |
+
|
| 268 |
+
where $\begin{array} { r } { \alpha _ { t } : = \prod _ { i = 1 } ^ { t } ( 1 - \beta _ { i } ) } \end{array}$ .
|
| 269 |
+
|
| 270 |
+
In order to sample from the distribution $q ( x _ { 0 } )$ , we define the dual “reverse process” $p ( x _ { t - 1 } \mid x _ { t } )$ from isotropic Gaussian noise $x _ { T }$ to data by sampling the posteriors $q ( x _ { t - 1 } \mid x _ { t } )$ . Since the intractable reverse process $q ( x _ { t - 1 } \mid x _ { t } )$ depends on the unknown data distribution $q ( x _ { 0 } )$ , we approximate it with a parameterized Gaussian transition network $p _ { \theta } ( x _ { t - 1 } ~ \vert ~ x _ { t } ) : = N ( x _ { t - 1 } ~ \vert$ $\mu _ { \boldsymbol { \theta } } ( x _ { t } , t ) , \Sigma _ { \boldsymbol { \theta } } ( x _ { t } , t ) )$ . The $\mu _ { \theta } ( x _ { t } , t )$ can be replaced (Ho et al., 2020) by predicting the noise $\epsilon _ { \theta } ( x _ { t } , t )$ added to $x _ { 0 }$ using equation 2.
|
| 271 |
+
|
| 272 |
+
Under this definition, we use Bayes’ theorem to approximate
|
| 273 |
+
|
| 274 |
+
$$
|
| 275 |
+
\mu _ { \theta } ( x _ { t } , t ) = \frac { 1 } { \sqrt { \alpha _ { t } } } \left( x _ { t } - \frac { \beta _ { t } } { \sqrt { 1 - \alpha _ { t } } } \epsilon _ { \theta } ( x _ { t } , t ) \right) .
|
| 276 |
+
$$
|
| 277 |
+
|
| 278 |
+
Once we have a trained $\epsilon _ { \theta } ( x _ { t } , t )$ , we can using the following sample method
|
| 279 |
+
|
| 280 |
+
$$
|
| 281 |
+
x _ { t - 1 } = \mu _ { \theta } ( x _ { t } , t ) + \sigma _ { t } z , \ z \sim N ( 0 , I ) .
|
| 282 |
+
$$
|
| 283 |
+
|
| 284 |
+
We can control $\sigma _ { t }$ of each sample stage, and in DDIMs (Song et al., 2020) the sampling process can be made deterministic using $\sigma _ { t } = 0$ in all the steps. The reverse process can finally be trained by solving the following optimization problem:
|
| 285 |
+
|
| 286 |
+
$$
|
| 287 |
+
\operatorname* { m i n } _ { \theta } L ( \theta ) : = \operatorname* { m i n } _ { \theta } E _ { x _ { 0 } \sim q ( x _ { 0 } ) , w \sim N ( 0 , I ) , t } \left\| w - \epsilon _ { \theta } ( x _ { t } , t ) \right\| _ { 2 } ^ { 2 } ,
|
| 288 |
+
$$
|
| 289 |
+
|
| 290 |
+
teaching the parameters $\theta$ to fit $q ( x _ { 0 } )$ by maximizing a variational lower bound.
|
| 291 |
+
|
| 292 |
+
# A.2 ATTENTION LAYERS IN TEXT TO IMAGE DIFFUSION MODELS
|
| 293 |
+
|
| 294 |
+
We implement our method on three different diffusion models: Imagen, Latent Diffusion, and Stable Diffusion. We describe here only a high-level description of each model and its attention layers that are relevant to our method. Note that these models condition on the text prompt in the noise prediction of each diffusion step through two types of attention layers: i) cross-attention layers. ii)
|
| 295 |
+
|
| 296 |
+
hybrid attention that acts both as self-attention and cross-attention by concatenating the text embedding sequence to the key-value pairs of each self-attention layer. Our method only intervenes in the cross-attention part of the hybrid attention. That is, only the last channels, which refer to text tokens, are modified in the hybrid attention modules.
|
| 297 |
+
|
| 298 |
+
Imagen. (Saharia et al., 2022b) consists of three text-conditioned diffusion models and a language model: A text-to-image $6 4 \times 6 4$ model, two super-resolution models $- 6 4 \times 6 4 \to 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$ and a pre-trained $\mathrm { T } 5 \ \mathrm { X L }$ language model Raffel et al. (2020). These predict the noise $\boldsymbol { \epsilon } _ { \theta } ( \boldsymbol { z } _ { t } , \boldsymbol { c } , t )$ via a U-shaped network, for $t$ ranging from $T$ to 1. Where $z _ { t }$ is the latent vector and $c$ is the text embedding of the language model. We highlight the differences between the three diffusion models:
|
| 299 |
+
|
| 300 |
+
��� $6 4 \times 6 4 -$ starts from a random noise, and uses the U-Net as in (Dhariwal & Nichol, 2021). This model is conditioned on text embeddings via both cross-attention layers at resolutions [16, 8] and hybrid-attention layers at resolutions [32, 16, 8] of the downsampling and upsampling within the U-Net.
|
| 301 |
+
• $6 4 \times 6 4 2 5 6 \times 2 5 6 -$ conditions on a naively upsampled $6 4 \times 6 4$ image. An efficient version of a U-Net is used, which includes Hybrid attention layers in the bottleneck (resolution of 32).
|
| 302 |
+
• $2 5 6 \times 2 5 6 \to 1 0 2 4 \times 1 0 2 4 -$ conditions on a naively upsampled $2 5 6 \times 2 5 6$ image. An efficient version of a U-Net is used, which only includes cross-attention layers in the bottleneck (resolution of 64).
|
| 303 |
+
|
| 304 |
+
Latent Diffusion. Latent Diffusion Model (LDM) (Rombach et al., 2021) is substantially different from Imagen. First, to reduce memory consummation, LDM operates in the latent space of a pretrained VQGAN Yu et al. (2021); Esser et al. (2021a). This reduces the spatial size of an input image from $2 5 6 \times 2 5 6$ to a quantized latent space of size $3 2 \times 3 2$ with 4 channels. Second, the language model is trained from scratch with the main diffusion model and consists of 32 transformer layers. For the diffusion process, a U-Net is used as in (Dhariwal & Nichol, 2021), which consists of selfattention layers followed by text-conditioned cross-attention layers at resolutions 32, 16, 8 and 4.
|
| 305 |
+
|
| 306 |
+
Stable Diffusion. Stable Diffusion (SD) is an improved version of LDM which is trained on higher resolution with more resources and data. The latent space is of size $6 4 \times 6 4$ with 4 channels, which after decoding results in an image of size $5 1 2 \times 5 1 2$ . SD uses pre-trained CLIP model (Radford et al., 2021) for the conditioned text embedding, and consists of self-attention layers followed by text-conditioned cross-attention layers at resolutions 64, 32, 16 and 8.
|
| 307 |
+
|
| 308 |
+
# B SELF-ATTENTION IN TEXT-CONDITIONED DIFFUSION MODELS
|
| 309 |
+
|
| 310 |
+
An interesting question is the role of self-attention maps. In particular, compared to cross-attention, how well it reveals the structure of the generated image, and how its injection affects the image generation under our settings.
|
| 311 |
+
|
| 312 |
+
Similar to the cross-attention maps, we found that self-attention maps are correlated to the structure and different semantic regions in the image. As can be seen in fig. 9, the self-attention maps of different pixels highlight the close region of the pixel in addition to regions in the image that contain the same semantic content. For example, a pixel on the crust of the pizza attends to other pixels on the crust. In addition, if we look at the top principle components of the self-attention maps, we can clearly identify the layout of the generated image, as previously shown in (Tumanyan et al., 2022) for a different model. However, since the self-attention maps are not correlated to specific words, these provide inferior control compared to cross-attention maps. For instance, it is much more challenging to find a map that highlights only the pepperoni using self-attention.
|
| 313 |
+
|
| 314 |
+
Next, we inject the self-attention maps of a source image during the generation of an image conditioned on another target prompt. Notice that the source and target prompts might be unaligned in this scenario. Such examples are shown in fig. 12, where we apply self-attention injection for a gradually increased number of diffusion steps. As we can see, the attention maps drastically affect the resulting images such that injecting the maps for more than $5 0 \%$ steps suppresses almost any connection to the target prompt. Interestingly, the self-attention maps can also determine the color palette in the image. Since the self-attention injection may restrict the editing capability of our method, we use self-attention injection for up to $2 0 \%$ of the diffusion steps. We found that this may improve the source background preservation in some cases.
|
| 315 |
+
|
| 316 |
+

|
| 317 |
+
Figure 9: Visualization of cross and self-attention. The top row for each example illustrates the average cross-attention maps for the given prompt. The second row shows the self-attention maps with respect to different pixels (marked in green). The third row shows the principle components of the self-attention maps. All examples present the attention maps at resolution $1 6 \times 1 6$ after averaging across diffusion steps, different layers, and attention heads.
|
| 318 |
+
|
| 319 |
+
# C ADDITIONAL RESULTS
|
| 320 |
+
|
| 321 |
+
Additional quantitative results are provided in table 2.
|
| 322 |
+
|
| 323 |
+
Full figures for fig. 5 and 6, are in fig. 11 and 13 respectively. Additional qualitative comparisons are provided in fig. 14 and 15.
|
| 324 |
+
|
| 325 |
+
In fig. 16, we do not inject the attention of the entire prompt but only the attention of a specific word – “butterfly”. This enables the preservation of the original butterfly while changing the rest of the content. As demonstrated in fig. 17, using cross-attention injection we can swap between apples and oranges by swapping these words in the prompt. The same experiment fails when using self-attention which lacks a strong interaction between textual tokens and pixels.
|
| 326 |
+
|
| 327 |
+
Additional global editing results are presented in fig. 18, illustrating a translation of a sketch into a photo-realistic image and inducing an artistic style. Examples for editing of real images provided in fig. 19, 20, and 21.
|
| 328 |
+
|
| 329 |
+
We provide additional visual examples for different editing operations using our method: fig. 22 show word swap results, fig. 23 show adding specification to an image, and fig. 24 show attention re-weighting.
|
| 330 |
+
|
| 331 |
+
# C.1 DIFFERENT BACKBONES
|
| 332 |
+
|
| 333 |
+
Results for the Latent Diffusion and Stable Diffusion models are in fig. 25, 26, 27, 28, 29, and 30. We observe that text-based replacement and refinement operations work well for all three models. However, we notice a small difference between the three models in the Fader Control using Attention Re-weighting. Visual examples of this application are presented in fig. 24, 27 and 30 using Imagen, Latent Diffusion and Stabe Diffusion respectively. As can be seen, when using Imagen as the backbone, our method produces high-quality results and can even handle delicate changes such as reducing the “cubic” appearance of sushi. On the other hand, applying our method with Stable Diffusion may result in unexpected artifacts. For example, when reducing the attention to the word “night” (last example in fig. 30), not only the time of the day is changed but also the dark skies turns into trees.
|
| 334 |
+
|
| 335 |
+
We hypothesize that this difference is the result of using different language models for text embedding. Imagen uses a T5 language model that is trained using an unsupervised language objective of span masking. Stable Diffusion uses CLIP which is trained with a multi-modal constructive objective. Lastly, the Latent Diffusion language model is trained with the same reconstitution objective as the diffusion model. Therefore, we suggest that the text embedding of T5 better represents disentangled information and so yields superior results.
|
| 336 |
+
|
| 337 |
+
# D LIMITATIONS
|
| 338 |
+
|
| 339 |
+
While we have demonstrated semantic control by changing only textual prompts, our technique is subject to a few limitations. First, the current inversion process results in a visible distortion over some of the test images, see fig. 20. Moreover, the inversion requires the user to come up with a suitable prompt which could be challenging for complicated compositions. Note that the challenge of inversion for text-guided diffusion models is an orthogonal endeavor to our work, which would be studied in the future. Second, current attention maps are of low resolution, as the cross-attention is placed in the network’s bottleneck. This bounds our ability to perform more precise editing. To alleviate this, we suggest incorporating cross-attention also in higher-resolution layers. We leave this for future work as it requires analyzing the training which is out of our scope. Third, our method requires setting the timestamp parameter for attention injection and the scale parameter for attention re-weighting. Tuning these usually requires roughly a minute for the Imagen model. However, our method is not highly sensitive to these, and using a constant timestamp produces satisfying results in most cases.Furthermore, we believe that future works will reduce the inference time of these models, so tuning the parameter will be quicker and more intuitive. Finally, we recognize that our method cannot be used for large structural changes in the image, like changing the pose of an animal, move objects or changing the number of objects in the image, see examples in fig. 10. We leave this kind of control for future work.
|
| 340 |
+
|
| 341 |
+
# E USER STUDY
|
| 342 |
+
|
| 343 |
+
32 participants answered our user study. Each was asked to evaluate 18 randomly selected Promptto-Prompt examples for each method. The examples were given in random order and were divided into three parts: (A) consists of 6 replacement examples using templates 1 and 2 (see appendix F). (B) consists of 6 local refinement examples using templates 3 and 4. (C) consist of 6 global refinement examples using templates 5 and 6. For each example the user was asked to rate the image on a $1 - 5$ scale (higher is better) with respect to the following questions:
|
| 344 |
+
|
| 345 |
+

|
| 346 |
+
Figure 10: Editing Failure Cases. Since Prompt-to-Prompt preserves the overall structure of the source image, it fails when large structural modification is required. For example, changing the pose of the dog from “playing” to “sleeping” (on the left) or changing the number of chairs (middle). In addition, our method is limited by the semantic understanding of the diffusion model, for example, on the right, we add the refinement ”smiling bunny doll” that made both the bunny and the child smile.
|
| 347 |
+
|
| 348 |
+
(1) How well does the right image preserve the structure and the background of the left image? Consider the preservation of properties that are not specified by the text above the images.
|
| 349 |
+
|
| 350 |
+
(2) How well does the right image match the text description above it? Specifically, consider the highlighted text.
|
| 351 |
+
|
| 352 |
+
(3) Rate the overall realism and quality of the right image.
|
| 353 |
+
|
| 354 |
+
See fig. 31 for screenshots.
|
| 355 |
+
|
| 356 |
+
# F EVALUATION PROMPTS
|
| 357 |
+
|
| 358 |
+
We use the following prompt templates to generate the evaluation data:
|
| 359 |
+
|
| 360 |
+
T e m p l a t e 1 : ” Image o f <A RPC> i n s i d e a <B CONST $>$ .”
|
| 361 |
+
S e l e c t A $=$ [ ” a p p l e s ” , ” o r a n g e s ” , ” c h o c o l a t e s ” , ” k i t t e n s ” , ” p u p p i e s ” , ” c a n d i e s ” ]
|
| 362 |
+
S e l e c t B $=$ [ ” b o x ” , ” b o w l ” , ” b u c k e t ” , ” n e s t ” , ” p o t ” ]
|
| 363 |
+
|
| 364 |
+
T e m p l a t e 2 : ”A <A RPC> f u l l o f <B CONST> i s l y i n g on t h e t a b l e . ” S e l e c t A $=$ [ ” b o x ” , ” b o w l ” , ” b u c k e t ” , ” n e s t ” , ” p o t ” ] S e l e c t B $=$ [ ” a p p l e s ” , ” o r a n g e s ” , ” c h o c o l a t e s ” , ” k i t t e n s ” , ” p u p p i e s ” , ” c a n d i e s ” ]
|
| 365 |
+
|
| 366 |
+
T e m p l a t e 3 : ” Pho to o f a <A RPC> <CONST>.”
|
| 367 |
+
|
| 368 |
+
s e l e c t f r o m a $=$ [ ” c a t ” , ” d o g ” , ” l i o n ” , ” c a m e l ” , ” h o r s e ” , ” b e a r ” , ” s q u i r r e l ” , ” e l e p h a n t ” , ” z e b r a ” , ” g i r a f f e ” , ” cow ” ]
|
| 369 |
+
s e l e c t f r o m b $=$ [ ” s e a t i n g i n t h e f i e l d ” , ” w a l k i n g i n t h e f i e l d ” , ” w a l k i n g i n t h e c i t y ” , ” w a n d e r i n g a r o u n d t h e c i t y ” , ” w a n d e r i n g i n t h e s t r e e t s ” , ” w a l k i n g i n t h e d e s e r t ” , ” s e a t i n g i n t h e d e s e r t ” , ” w a l k i n g i n t h e f o r e s t ” , ” s e a t i n g i n t h e f o r e s t ” , ” w a l k i n g i n t h e d e s e r t ” , ” s e a t i n g i n t h e d e s e r t ” , ” p l a y s a t t h e p l a y g r o u n d ” , ” e n j o y s a t t h e p l a y g r o u n d ” ]
|
| 370 |
+
Template 3 : ” Photo of a <A CONST> <B ADD> wi th a <C CONST> on i t . ”
|
| 371 |
+
S e l e c t A $=$ [ ” t r e e ” , ” s h r u b ” , ” f l o w e r ” , ” c h a i r ” , ” f r u i t ” ]
|
| 372 |
+
s e l e c t B $=$ [ ” made o f c a n d i e s ” , ” made o f b r i c k s ” , ” made o f p a p e r ” , ” made o f c l a y ” , ” made o f wax ” , ” made o f f e a t h e r s ” ]
|
| 373 |
+
S e l e c t C $=$ [ ” b u g ” , ” b u t t e r f l y ” , ” b e e ” , ” g r a s s h o p p e r ” , ” b i r d ” ]
|
| 374 |
+
|
| 375 |
+
T e m p l a t e 4 : ” Image o f a <A ADD> <B CONST> on t h e s i d e o f t h e r o a d . ” S e l e c t A $=$ [ ” wooden ” , ” o l d ” , ” c r a s h e d ” , ” g o l d e n ” , ” s i l v e r ” , ” s p o r t ” , ” t o y ” ] s e l e c t B $=$ [ ” c a r ” , ” b u s ” , ” b i c y c l e ” , ” m o t o r c y c l e ” , ” s c o o t e r ” , ” v a n ” ]
|
| 376 |
+
|
| 377 |
+
T e m p l a t e 5 : ”A l a n d s c a p e Image o f <A CONST> <B ADD>.”
|
| 378 |
+
S e l e c t A $=$ [ ” a r i v e r ” , ” a l a k e ” , ” a v a l l e y ” , ” m o u n t a i n s ” , ” a f o r e s t ” , ” a r i v e r i n t h e v a l l e y ” , ” a v l i l a g e on a m o u n t a i n ” ,
|
| 379 |
+
s e l e c t B $=$ ” a w a t e r f a l l b e t w e e n t h e m o u n t a i n s ” , ” t h e c l i f f s i n t h e d e s e r t ” ] [ ” i n t h e w i n t e r ” , ” i n t h e a u t u m n ” , ” a t n i g h t ” , ” a t s u n s e t ” , ” a t s u n r i s e ” , ” a t f a l l ” , ” i n r a i n y d a y ” , ” i n a c l o u d y d a y ” , ” a t e v e n i n g ” ]
|
| 380 |
+
|
| 381 |
+
Source image
|
| 382 |
+
|
| 383 |
+
Source Prompt: “Photo of a cat riding on a bicycle.”
|
| 384 |
+
|
| 385 |
+

|
| 386 |
+
|
| 387 |
+

|
| 388 |
+
bicycle motorcycle
|
| 389 |
+
Figure 11: Attention injection through a varied number of diffusion steps. Top: source image and prompt. In each row, we modify the content of the image by replacing a single word in the text and injecting the cross-attention maps of the source image ranging from $0 \%$ (left) to $100 \%$ (right) of the steps. Without our method, none of the source image content is guaranteed to be preserved. On the other hand, injecting the cross-attention throughout all the steps may over-constrain the geometry, resulting in low fidelity to the text.
|
| 390 |
+
|
| 391 |
+
W.O.cross-attention injection → Full cross-attention injection
|
| 392 |
+
|
| 393 |
+
T e m p l a t e 6 : ”<A CONST> i n t h e <B ADD> s t r e e t . ”
|
| 394 |
+
S e l e c t A $=$ [ ” H e a v y t r a f f i c ” , ” The h o u s e s ” , ” The b u i l d i n g s ” , ” C y c l i n g ” , ” The t r a m i s p a s s i n g ” , ” The b u s a r r i v e d a t t h e s t a t i o n ” ]
|
| 395 |
+
s e l e c t B $=$ [ ” snowy ” , ” f l o o d e d ” , ” b l o s s o m ” , ” modern ” , ” h i s t o r i c ” , ” c o m m e r c i a l ” , ” c o l o r f u l ” ]
|
| 396 |
+
|
| 397 |
+
We generate 20 random examples using each template where the tokens <CONST>, ${ \mathrm { - R P C } } >$ and ${ \mathrm { < A D D > } }$ where randomly replaced with one item in the corresponding selection list below each template.
|
| 398 |
+
|
| 399 |
+
${ \mathrm { \ C O N S T { \mathrm { > } } } }$ stands for phrase that is used in both source and target prompt.
|
| 400 |
+
|
| 401 |
+
${ \mathrm { < R P C > } }$ stands for phrase that is different between the source and target.
|
| 402 |
+
|
| 403 |
+
${ \mathrm { < A D D > } }$ stands for refinement phrase which is only replaced in the target prompt and omitted in the source prompt.
|
| 404 |
+
|
| 405 |
+
# Source image
|
| 406 |
+
|
| 407 |
+
Source prompt: “A sailing boat near a castle.”
|
| 408 |
+
|
| 409 |
+

|
| 410 |
+
|
| 411 |
+

|
| 412 |
+
Figure 12: Self-attention injection through a varied number of diffusion steps. In each row, we conditioned the image generation on a new target prompt and inject the self-attention maps of the source image ranging from $0 \%$ (left) to $100 \%$ (right) of the diffusion steps.
|
| 413 |
+
|
| 414 |
+
Target prompt: “An elephant in the field.”
|
| 415 |
+
Table 2: Additional quantitative results. We measure text-image correspondence using CLIP (Radford et al., 2021), demonstrating competitive results to methods that directly optimize the CLIP score. In addition, we evaluate the similarity between the original and the edited images using the LPIPS (Zhang et al., 2018a) perceptual distance and MS-SSIM (Wang et al., 2003). This show our capability of performing local editing, similar to Text2Live (Bar-Tal et al., 2022).
|
| 416 |
+
|
| 417 |
+
<table><tr><td></td><td>CLIP score个</td><td>MS-SSIM↑</td><td>LPIPS↓</td></tr><tr><td>VQGAN+CLIP</td><td>0.282 ±0.04</td><td>0.27 ± 0.046</td><td>0.64± 0.05</td></tr><tr><td>Text2Live</td><td>0.247 ± 0.04</td><td>0.82±0.065</td><td>0.25± 0.05</td></tr><tr><td>baseline</td><td>0.253 ± 0.03</td><td>0.69 ± 0.13</td><td>0.35 ± 0.12</td></tr><tr><td>Ours</td><td>0.253± 0.04</td><td>0.81± 0.11</td><td>0.22 ± 0.1</td></tr></table>
|
| 418 |
+
|
| 419 |
+
“A car on the side of the street.”
|
| 420 |
+
|
| 421 |
+

|
| 422 |
+
Figure 13: Editing by prompt refinement. By extending the description of the initial prompt, we can make local edits to the car (top rows) or global modifications (bottom rows).
|
| 423 |
+
|
| 424 |
+
“Photo of a cat camel seating in the forest.”
|
| 425 |
+
|
| 426 |
+

|
| 427 |
+
|
| 428 |
+
“Image of a bowl with oranges chocolates.”
|
| 429 |
+
|
| 430 |
+

|
| 431 |
+
|
| 432 |
+
“Photo of a flower made of candies with a butterfly on it.”
|
| 433 |
+
|
| 434 |
+

|
| 435 |
+
|
| 436 |
+
“Image of a golden scooter on the side of the road.”
|
| 437 |
+
|
| 438 |
+

|
| 439 |
+
|
| 440 |
+
“A landscape image of a lake at sunset.”
|
| 441 |
+
|
| 442 |
+

|
| 443 |
+
Figure 14: Additional comparisons to text-guided image editing. Similar to ours, these methods do not require a user-provided mask.
|
| 444 |
+
|
| 445 |
+
“Photo of a lion zebra seating in the forest.”
|
| 446 |
+
|
| 447 |
+

|
| 448 |
+
Figure 15: Additional comparisons to text-guided in-painting methods. Unlike our method, these techniques require an auxiliary segmentation mask which is provided by the user.
|
| 449 |
+
|
| 450 |
+

|
| 451 |
+
Cross–attention injection
|
| 452 |
+
Figure 16: Object preservation and replacement using cross and self attention injection. Top: by injecting only the cross-attention weights of the word “butterfly” taken from the top-left image we can preserve the structure and appearance of a single item while replacing its context (i.e., background). Bottom: using only self-attention injection we can’t specify which object should be preserved, therefore, modifying the background while keeping the butterfly is more challenging.
|
| 453 |
+
|
| 454 |
+
“A photo of a butterfly on...”
|
| 455 |
+
|
| 456 |
+
Cross–attention injection
|
| 457 |
+
|
| 458 |
+

|
| 459 |
+
Figure 17: Object replacement using cross-attention injection and self-attention injection. Cross–attention injection better preserves the semantic relation between the generated image and the text prompt. Top: using cross-attention injection (third row) we can swap between apples and oranges in the source image by swapping these words in the prompt “apples and oranges are on the table.”. The same experiment fails when using self-attention which lacks a strong interaction between textual tokens and pixels. Bottom: cross-attention injection (6th row) better preserves the distinct elements in the image when replacing the word “oranges” with “kittens” in the sentence “a basket with oranges on the counter.”
|
| 460 |
+
|
| 461 |
+
“drawing of...” “photo of...”
|
| 462 |
+
|
| 463 |
+

|
| 464 |
+
Figure 18: Image stylization. By adding a style description to the prompt while injecting the source attention maps, we can create various images in the new desired styles that preserve the structure of the original image.
|
| 465 |
+
|
| 466 |
+

|
| 467 |
+
Figure 19: Editing of real images. On the left, inversion results using DDIM Song et al. (2020) sampling. We reverse the diffusion process initialized on a given real image and text prompt. This results in a latent noise that produces an approximation to the input image when fed to the diffusion process. Afterward, on the right, we apply our Prompt-to-Prompt technique to edit the images.
|
| 468 |
+
|
| 469 |
+

|
| 470 |
+
Figure 20: Inversion Failure Cases. Current DDIM-based inversion of real images might result in unsatisfied reconstructions.
|
| 471 |
+
|
| 472 |
+

|
| 473 |
+
different noise seeds
|
| 474 |
+
Figure 21: Mask-based editing. Using the attention maps, we preserve the unedited parts of the image when the inversion distortion is significant. This does not require any user-provided masks, as we extract the spatial information from the model using our method. Note how the cat’s identity is retained after the editing process.
|
| 475 |
+
|
| 476 |
+

|
| 477 |
+
|
| 478 |
+
“A ball between two chairs on the beach.
|
| 479 |
+
|
| 480 |
+

|
| 481 |
+
Figure 22: Additional results for Prompt-to-Prompt editing by word swapping using the Imagen model (Saharia et al., 2022b)..
|
| 482 |
+
|
| 483 |
+

|
| 484 |
+
Figure 23: Additional results for Prompt-to-Prompt editing by adding a specification using the Imagen model (Saharia et al., 2022b)..
|
| 485 |
+
|
| 486 |
+

|
| 487 |
+
“A leopard sleeping( ) cake next to an apple.”
|
| 488 |
+
|
| 489 |
+

|
| 490 |
+
“A smiling( ) teddy bear.”
|
| 491 |
+
|
| 492 |
+

|
| 493 |
+
“Photo of a cubic( ) sushi.”
|
| 494 |
+
|
| 495 |
+

|
| 496 |
+
|
| 497 |
+
“A photo of a birthday( ) cake next to an apple.”
|
| 498 |
+
|
| 499 |
+

|
| 500 |
+
“My colorful( ) bedroom.”
|
| 501 |
+
|
| 502 |
+

|
| 503 |
+
Figure 24: Additional results for Prompt-to-Prompt editing by attention re-weighting using the Imagen model (Saharia et al., 2022b).
|
| 504 |
+
|
| 505 |
+
“Photo of a field of poppies at night( ).”
|
| 506 |
+
|
| 507 |
+

|
| 508 |
+
“A painting of a squirrel eating a burger pizza.”
|
| 509 |
+
|
| 510 |
+

|
| 511 |
+
“A bench with a pile of books magazines on top.”
|
| 512 |
+
|
| 513 |
+

|
| 514 |
+
“Banknote portrait of a cow horse.”
|
| 515 |
+
|
| 516 |
+

|
| 517 |
+
|
| 518 |
+

|
| 519 |
+
|
| 520 |
+
“Snail Turtle in the middle of the forest. Afternoon light.”
|
| 521 |
+
|
| 522 |
+

|
| 523 |
+
|
| 524 |
+
“A bowl with apples snacks on a table.”
|
| 525 |
+
|
| 526 |
+
“Photo of a butterfly bee on a flower.”
|
| 527 |
+
|
| 528 |
+

|
| 529 |
+
“A photo of a dog wearing a floral dotted shirt.”
|
| 530 |
+
|
| 531 |
+

|
| 532 |
+
|
| 533 |
+

|
| 534 |
+
“A photo of a cat dog wearing a blue tie.”
|
| 535 |
+
|
| 536 |
+
“A photo of a cat playing chess domino .”
|
| 537 |
+
|
| 538 |
+

|
| 539 |
+
“A vase filed with cotton tennis balls.”
|
| 540 |
+
|
| 541 |
+

|
| 542 |
+
“A beautiful bouquet of tulips daisies on a table.”
|
| 543 |
+
|
| 544 |
+

|
| 545 |
+
“A deflated inflated tire on the ground.”
|
| 546 |
+
|
| 547 |
+

|
| 548 |
+
|
| 549 |
+
“A painting of a lion bear eating an apple.”
|
| 550 |
+
|
| 551 |
+

|
| 552 |
+
“A car is driving on the beach road.”
|
| 553 |
+
|
| 554 |
+

|
| 555 |
+
“Soup with rice noodles.”
|
| 556 |
+
|
| 557 |
+

|
| 558 |
+
“Watercolour painting photo of a latent space.”
|
| 559 |
+
|
| 560 |
+

|
| 561 |
+
“A photo of an astronaut riding a horse camel.”
|
| 562 |
+
|
| 563 |
+

|
| 564 |
+
“A castle made out of sand corn.”
|
| 565 |
+
|
| 566 |
+

|
| 567 |
+
“A snowman scarecrow in the garden.”
|
| 568 |
+
Figure 25: Additional results for Prompt-to-Prompt editing by word swap using the Latent Diffusion Model (Rombach et al., 2021).
|
| 569 |
+
|
| 570 |
+

|
| 571 |
+
“Lemon Apple cake on the table.”
|
| 572 |
+
|
| 573 |
+

|
| 574 |
+
“Image of candies toys inside a box.”
|
| 575 |
+
|
| 576 |
+

|
| 577 |
+
“A beautiful bouquet of tulips of the colour red and yellow.”
|
| 578 |
+
|
| 579 |
+

|
| 580 |
+
“A school bus is driving in the street.”
|
| 581 |
+
|
| 582 |
+

|
| 583 |
+
“A car is driving in the flooded street.”
|
| 584 |
+
|
| 585 |
+

|
| 586 |
+
“A landscape with a lake between mountains at sunset.”
|
| 587 |
+
|
| 588 |
+

|
| 589 |
+
|
| 590 |
+

|
| 591 |
+
“Pizza with mushrooms.”
|
| 592 |
+
|
| 593 |
+
“A wooden bike in the yard.”
|
| 594 |
+
|
| 595 |
+

|
| 596 |
+
“A fashion sketch of an evening dress with long sleeves.” ,
|
| 597 |
+
|
| 598 |
+

|
| 599 |
+
“A speeding race car is driving on the beach.”
|
| 600 |
+
|
| 601 |
+

|
| 602 |
+
“A big yellow apple on a table”
|
| 603 |
+
|
| 604 |
+

|
| 605 |
+
|
| 606 |
+
“My bicycle are in the street of Las Vegas.”
|
| 607 |
+
|
| 608 |
+

|
| 609 |
+
“A banknote portrait of a cat.”
|
| 610 |
+
|
| 611 |
+

|
| 612 |
+
|
| 613 |
+
“A cubist painting of a vase with lilies.”
|
| 614 |
+
|
| 615 |
+

|
| 616 |
+
“A small clay bunny with a big smile.”
|
| 617 |
+
|
| 618 |
+

|
| 619 |
+
“My bicycle are in the street at blossom.”
|
| 620 |
+
|
| 621 |
+

|
| 622 |
+
“Photo of a landscape with a river and mountains at sunrise.”
|
| 623 |
+
|
| 624 |
+

|
| 625 |
+
“A TV screen with many burnt pixels.”
|
| 626 |
+
|
| 627 |
+

|
| 628 |
+
“A stove outside creating a smoke cloud above.”
|
| 629 |
+
|
| 630 |
+

|
| 631 |
+
“A bear with yellow sunglasses and a drink.”
|
| 632 |
+
|
| 633 |
+

|
| 634 |
+
|
| 635 |
+
“A photo of a dog wearing a floral shirt.”
|
| 636 |
+
|
| 637 |
+

|
| 638 |
+
“A landscape photo of a harbor in the storm.”
|
| 639 |
+
Figure 26: Additional results for Prompt-to-Prompt editing by adding a specification using the Latent Diffusion Model (Rombach et al., 2021).
|
| 640 |
+
|
| 641 |
+

|
| 642 |
+
“The scooter at the city at winter.”
|
| 643 |
+
|
| 644 |
+

|
| 645 |
+
|
| 646 |
+
"A photo of a blossom ( ) tree."
|
| 647 |
+
|
| 648 |
+

|
| 649 |
+
“A landscape with a snowy ( ) mountain.”
|
| 650 |
+
|
| 651 |
+

|
| 652 |
+
|
| 653 |
+
“A photo of the ancient ( ) city.”
|
| 654 |
+
|
| 655 |
+

|
| 656 |
+
“A crahsed ( ) car.”
|
| 657 |
+
|
| 658 |
+

|
| 659 |
+
“My puffy ( ) shirt.”
|
| 660 |
+
|
| 661 |
+

|
| 662 |
+
“A photo of a poppy field at night ( ).”
|
| 663 |
+
Figure 27: Additional results for Prompt-to-Prompt editing by attention re-weighting using the Latent Diffusion Model (Rombach et al., 2021).
|
| 664 |
+
|
| 665 |
+

|
| 666 |
+
“A painting of a squirrel cat eating a burger.”
|
| 667 |
+
|
| 668 |
+

|
| 669 |
+
“A bench with many books magazines on top.”
|
| 670 |
+
|
| 671 |
+

|
| 672 |
+
“Banknote portrait of a mouse horse.”
|
| 673 |
+
|
| 674 |
+

|
| 675 |
+
|
| 676 |
+
“A car is driving on the beach road.”
|
| 677 |
+
|
| 678 |
+

|
| 679 |
+
“A chair in the bed living room.”
|
| 680 |
+
|
| 681 |
+

|
| 682 |
+
|
| 683 |
+
“A deflated inflated tire on the ground.”
|
| 684 |
+
|
| 685 |
+

|
| 686 |
+
“A fashion BW sketch of an evening dress of an evening dress.”
|
| 687 |
+
|
| 688 |
+

|
| 689 |
+
|
| 690 |
+
“A huge translucent mushroom avocado in the middle of the forest. Afternoon light.”
|
| 691 |
+
|
| 692 |
+

|
| 693 |
+
“A kangaroo deer in a pub eating sushi. DSLR.”
|
| 694 |
+
|
| 695 |
+

|
| 696 |
+
“A pepperoni mushroom pizza on a table.”
|
| 697 |
+
|
| 698 |
+

|
| 699 |
+
|
| 700 |
+

|
| 701 |
+
|
| 702 |
+
“A stove over a pile of diverse random house sports objects. Low lighting image.”
|
| 703 |
+
|
| 704 |
+
“An evil robot holding a sword broom.”
|
| 705 |
+
|
| 706 |
+

|
| 707 |
+
“An origami bottle cup.”
|
| 708 |
+
|
| 709 |
+

|
| 710 |
+
“A vase filed with cotton tennis balls.”
|
| 711 |
+
|
| 712 |
+

|
| 713 |
+
“A photo of a cat playing chess domino .”
|
| 714 |
+
|
| 715 |
+

|
| 716 |
+
“Photo of a dog cat in the street.”
|
| 717 |
+
|
| 718 |
+

|
| 719 |
+
“A piano made out of Lego cubes.”
|
| 720 |
+
|
| 721 |
+

|
| 722 |
+
“A painting of a squirrel eating a burger pizza.” ,
|
| 723 |
+
|
| 724 |
+

|
| 725 |
+
|
| 726 |
+
“A beautiful bouquet of tulips daisies.”
|
| 727 |
+
|
| 728 |
+

|
| 729 |
+
“An apple orange on a table.”
|
| 730 |
+
|
| 731 |
+

|
| 732 |
+
“Image of candies mints inside a box.”
|
| 733 |
+
Figure 28: Additional results for Prompt-to-Prompt editing by word swap using the Stable Diffusion Model .
|
| 734 |
+
|
| 735 |
+

|
| 736 |
+
“A beautiful bouquet of tulips of the colour red and yellow.”
|
| 737 |
+
|
| 738 |
+

|
| 739 |
+
“A big yellow apple on a table”
|
| 740 |
+
|
| 741 |
+

|
| 742 |
+
“A wooden bike in the yard.”
|
| 743 |
+
|
| 744 |
+

|
| 745 |
+
“A bridge made of rope between two cliffs.”
|
| 746 |
+
|
| 747 |
+

|
| 748 |
+
“A dangerous bridge missing its steps between two cliffs.”
|
| 749 |
+
|
| 750 |
+

|
| 751 |
+
“A speeding race car is driving on the beach.”
|
| 752 |
+
|
| 753 |
+

|
| 754 |
+
“A fashion sketch of an evening dress with long sleeves.”
|
| 755 |
+
|
| 756 |
+

|
| 757 |
+
“A painting of a squirrel jumping over a metal fence with spikes.”
|
| 758 |
+
|
| 759 |
+

|
| 760 |
+
|
| 761 |
+
“A huge translucent mushroom in the middle of the forest. Afternoon light.”
|
| 762 |
+
|
| 763 |
+

|
| 764 |
+
“A painting of lilies in the style of Van Gogh.”
|
| 765 |
+
|
| 766 |
+

|
| 767 |
+
“A pepperoni pizza with mushroom and olive toppings on a table”
|
| 768 |
+
|
| 769 |
+

|
| 770 |
+
“A banknote portrait of a mouse.”
|
| 771 |
+
|
| 772 |
+

|
| 773 |
+
“A small clay bunny with a big smile.”
|
| 774 |
+
|
| 775 |
+

|
| 776 |
+
“A recliner sofa in the living room”
|
| 777 |
+
|
| 778 |
+

|
| 779 |
+
“A deflated and ripped up tire on the ground.”
|
| 780 |
+
|
| 781 |
+

|
| 782 |
+
“A vase filled with cotton and metal balls.”
|
| 783 |
+
|
| 784 |
+

|
| 785 |
+
“A stove outside creating a smoke cloud above.”
|
| 786 |
+
|
| 787 |
+

|
| 788 |
+
“A TV screen with many burnt pixels.”
|
| 789 |
+
|
| 790 |
+

|
| 791 |
+
|
| 792 |
+
“An image of soup with alphabet soup crackers in English and Russian.
|
| 793 |
+
|
| 794 |
+

|
| 795 |
+
“Eyeglasses on the desk reflecting a strong glare.”
|
| 796 |
+
|
| 797 |
+

|
| 798 |
+
“Image of candies covered with chocolate inside a box.”
|
| 799 |
+
|
| 800 |
+
Figure 29: Additional results for Prompt-to-Prompt editing by adding a specification using the Stable Diffusion Model.
|
| 801 |
+
|
| 802 |
+

|
| 803 |
+
|
| 804 |
+
"A photo of a blossom ( ) tree."
|
| 805 |
+
|
| 806 |
+

|
| 807 |
+
“A landscape with a snowy ( ) mountain.”
|
| 808 |
+
|
| 809 |
+

|
| 810 |
+
|
| 811 |
+
“A photo of the ancient ( ) city.”
|
| 812 |
+
|
| 813 |
+

|
| 814 |
+
“A crahsed ( ) car.”
|
| 815 |
+
|
| 816 |
+

|
| 817 |
+
|
| 818 |
+
“A smiling( ) teddy bear.”
|
| 819 |
+
|
| 820 |
+

|
| 821 |
+
Figure 30: Additional results for Prompt-to-Prompt editing by attention re-weighting using the Stable Diffusion Model.
|
| 822 |
+
|
| 823 |
+
“A photo of a poppy field at night ( ).”
|
| 824 |
+
|
| 825 |
+

|
| 826 |
+
Figure 31: Screenshots from our User study. The participants were asked to evaluate: (1) background, structure, and content preservation with respect to the source image, (2) alignment to the text, and (3) realism. The study evaluates both local and global editing.
|
md/dev/_h2FKc6E_YV/_h2FKc6E_YV.md
ADDED
|
@@ -0,0 +1,279 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Rethinking and Scaling Up Graph Contrastive Learning: An Extremely Efficient Approach with Group Discrimination
|
| 2 |
+
|
| 3 |
+
Yizhen Zheng1, Shirui $\mathbf { P a n } ^ { 2 }$ ∗, Vincent CS Lee1, Yu Zheng3, Phillip S. $\mathbf { V } \mathbf { u } ^ { 4 }$ ,
|
| 4 |
+
1Monash University, 2Griffith University, 3La Trobe University, 4 University of Illinons at Chicago
|
| 5 |
+
yizhen.zheng1@monash.edu, s.pan@griffth.edu.au, vincent.cs.lee@monash.edu yu.zheng@latrobe.edu.au, psyu@uic.edu
|
| 6 |
+
|
| 7 |
+
# Abstract
|
| 8 |
+
|
| 9 |
+
Graph contrastive learning (GCL) alleviates the heavy reliance on label information for graph representation learning (GRL) via self-supervised learning schemes. The core idea is to learn by maximising mutual information for similar instances, which requires similarity computation between two node instances. However, GCL is inefficient in both time and memory consumption. In addition, GCL normally requires a large number of training epochs to be well-trained on largescale datasets. Inspired by an observation of a technical defect (i.e., inappropriate usage of Sigmoid function) commonly used in two representative GCL works, DGI and MVGRL, we revisit GCL and introduce a new learning paradigm for self-supervised graph representation learning, namely, Group Discrimination (GD), and propose a novel GD-based method called Graph Group Discrimination (GGD). Instead of similarity computation, GGD directly discriminates two groups of node samples with a very simple binary cross-entropy loss. In addition, GGD requires much fewer training epochs to obtain competitive performance compared with GCL methods on large-scale datasets. These two advantages endow GGD with very efficient property. Extensive experiments show that GGD outperforms state-of-theart self-supervised methods on eight datasets. In particular, GGD can be trained in 0.18 seconds (6.44 seconds including data preprocessing) on ogbn-arxiv, which is orders of magnitude $^ { ( 1 0 , 0 0 0 + ) }$ faster than GCL baselines while consuming much less memory. Trained with 9 hours on ogbn-papers100M with billion edges, GGD outperforms its GCL counterparts in both accuracy and efficiency.
|
| 10 |
+
|
| 11 |
+
# 1 Introduction
|
| 12 |
+
|
| 13 |
+
Graph Neural Networks (GNNs) have been widely-adopted in learning representations for graphstructured data. By utilising message-passing over the topology of a graph, GNNs can learn effective low-dimensional node embeddings, which can be used for a variety of downstream tasks such as node classification [1]. GNNs have been further applied in diverse domains, e.g., federated learning [2, 3], trustworthy systems [4, 5], dynamic graphs [6, 7] and anomaly detection [8, 9].
|
| 14 |
+
|
| 15 |
+
However, many GNNs adopt a supervised learning manner to train models with label information, which is expensive and labour-intensive to collect in real-world. To address this issue, a few studies (e.g., DGI [10], MVGRL [11], GMI [12], and GRACE [13]) borrow the idea of contrastive learning from computer vision (CV), and introduce graph contrastive learning (GCL) methods for selfsupervised GRL. The core idea of these methods is to maximise the mutual information (MI) between an anchor node and its positive counterparts, sharing similar semantic information while doing the opposite for negative counterparts as shown in Figure 1(a). Nonetheless, such a scheme relies on similarity calculation in contrastive loss computation. Additionally, GCL normally requires a large number of training epochs to be well-trained on large-scale datasets. Thus, when the size of the dataset is large, these methods require a significant amount of time and resources to be well-trained.
|
| 16 |
+
|
| 17 |
+
Though a few GCL works attempt to improve graph contrastive learning with specially designed schemes, e.g., BGRL [15] and GBT [14], they are still inefficient and require high time consumption for model training. Inspired by BYOL [16], BGRL [15] adopts a bootstrapping scheme and remove negative node pairs. It only contrasts a node from the online network (i.e., updated with gradient) to its corresponding embedding from the target network (i.e., updated momentumly with stop gradient). Based on Barlow-Twins [17],
|
| 18 |
+
|
| 19 |
+

|
| 20 |
+
Figure 1: The left subfigure shows the GCL learning scheme. Red line indicates MI maximisation between two nodes, each of which $\in \mathbb { R } ^ { 1 \times D }$ , while blue line indicates the opposite operation. The right subfigure presents Group Discrimination. It discriminates positive and negative node samples, each of which ∈ R1×1.
|
| 21 |
+
|
| 22 |
+
GBT [14] borrows the idea of redundancy-reduction principle and utilises a cross-correlation-based loss to build contrastiveness between embedding dimensions.
|
| 23 |
+
|
| 24 |
+
To boost training efficiency of self-supervised GRL, inspired by an observation of a technical defect (i.e., inappropriate application of Sigmoid function) in two representative GCL studies, we introduce a novel learning paradigm, namely, Group Discrimination (GD). Instead of similarity computation, GD directly discriminates a group of positive nodes from a group of negative nodes, as shown in Figure 1(b). Specifically, GD defines node samples generated with original graph as the positive group, while node samples obtained with corrupted topology are regarded as the negative group. Then, GD trains the model by classifying these node samples into the correct group with a very simple binary cross-entropy loss. By doing so, the model can extract valuable self-supervised signals from learning the edge distribution of a graph. Com
|
| 25 |
+
|
| 26 |
+
Table 1: Training time in seconds comparison between GGD and GBT [14] (i.e., the most efficient GCL baseline as shown in section 5.1) on ogbnarxiv. Number in brackets means the hidden size. ‘Pre’, ‘Tr’ and ‘Epo’ indicate preprocessing time, training time per epoch, and the number of epochs for training GNNs. ‘Total(E)’ and ‘Total(T)’ are total end-to-end training time (i.e., including preprocessing), which equals to $( { \mathrm { P r e } } + { \mathrm { E p o } } \times { \mathrm { T r } } )$ and total training time, which is $( { \mathrm { E p o } } \times { \mathrm { T r } } )$ . ‘Imp(E)’ and $\mathrm { \cdot { I m p ( T ) } } ^ { \mathrm { , } }$ indicate how many times GGD improve on ‘Total(E)’ and ‘Total(T)’. ‘Acc’ is averaged accuracy result on test set over five runs.
|
| 27 |
+
|
| 28 |
+
<table><tr><td>Method</td><td>Pre</td><td>Tr</td><td>Epo</td><td colspan="2">Total(E) Imp(E)</td><td colspan="2">Total(T)Imp(T)</td><td>Acc</td></tr><tr><td>GBT(256)</td><td>5.52</td><td>6.47</td><td>300</td><td>1,946.52</td><td>-</td><td>1,941.00</td><td>=</td><td>70.1</td></tr><tr><td>GGD(256)</td><td>6.26 0.18</td><td></td><td>1</td><td>6.44</td><td>302.25×</td><td>0.18</td><td>10,783.33x</td><td>70.3</td></tr><tr><td>GGD(1,500)</td><td></td><td>6.260.95</td><td>1</td><td>7.21</td><td>269.96×</td><td>0.95</td><td>2.043.16×</td><td>71.6</td></tr></table>
|
| 29 |
+
|
| 30 |
+
pared with GCL, GD enjoys numerous merits including extremely fast training, fast convergence (e.g., 1 epoch to be well-trained on large-scale datasets), and high scalability while achieving SOTA performance with existing GCL approaches.
|
| 31 |
+
|
| 32 |
+
Using GD as backbone, we design a new self-supervised GRL model with the Siamese structure called Graph Group Discrimination (GGD). Firstly, we can optionally augment a given graph with augmentation techniques, e.g., feature and edge dropout. Then, the augmented graph is fed into a GNN encoder and a projector to obtain embeddings for the positive group. After that, the augmented feature is corrupted with node shuffling (i.e., disarranging the order of nodes in the feature matrix) to disrupt the topology of a graph and input to the same network for obtaining embeddings of the opposing group. Finally, the model is trained by discriminating these two groups of node samples. The contributions of this paper are three-fold: 1) We re-examine existing GCL approaches (e.g., DGI [10] and MVGRL [11]), and we introduce a novel and efficient self-supervised GRL paradigm, namely, Group Discrimination (GD). 2) Based on GD, we propose a new self-supervised GRL model, GGD, which is fast in training and convergence, and possess high scalability. 3) We conduct extensive experiments on eight datasets, including an extremely large dataset, ogbn-papers100M with billion edges. The experiment results show that our proposed method reaches state-of-the-art performance while consuming much less time and memory than baselines, e.g., $\mathbf { 1 0 7 8 3 \times }$ faster than the most efficient GCL baseline with its best selected epochs number [14], as shown in Table 1.
|
| 33 |
+
|
| 34 |
+
# 2 Rethinking Representative GCL Methods
|
| 35 |
+
|
| 36 |
+
In this section, we analyse a technical defect observed in two representative GCL methods, DGI [10] and MVGRL [11]. Based on the technical defect, we show that mutual information maximisation behind these two approaches is not the contributed factor to contrastive learning, but a new paradigm, group discrimination. Finally, from the analysis, we provide the definition of this new concept.
|
| 37 |
+
|
| 38 |
+
# 2.1 Rethinking GCL Methods
|
| 39 |
+
|
| 40 |
+
DGI [10] is the first work introducing contrastive learning into GRL. However, due to a technical defect observed in their official opensource code, we found it is essentially not working as the authors thought (i.e., learning via MI interaction).
|
| 41 |
+
|
| 42 |
+

|
| 43 |
+
Figure 2: The architecture of DGI. Cubes indicate node embeddings. Red and blue lines represent MI maximisation and minimisation, respectively. G and $\widetilde { \mathcal { G } }$ denote the original graph and the corrupted graph. s is the summary vector.
|
| 44 |
+
|
| 45 |
+
Constant Summary Vector. As shown in Figure 2, the original idea of DGI is to maximise the MI (i.e., the red line) between a node $a$ and the summary vector s, which is obtained by averaging all node embeddings in a graph G. Also, to regularise the model training, DGI corrupts G by shuffling the node order of the input feature matrix to get G˜. Then, generated embeddings of $\widetilde { \mathcal { G } }$ serve as negative samples, which are pulled apart from the summary vector s via MI minimisation.
|
| 46 |
+
|
| 47 |
+
Nonetheless, in the implementation of DGI, a Sigmoid function is inappropriately applied on the summary vector generated from a GNN whose weight is initialised with Xavier initialisation. As a result, elements in the summary vector are very close to the same value. We have validated this finding on three datasets, Cora, CiteSeer and PubMed. The experiment result is shown in Table 2, which shows that summary vec
|
| 48 |
+
|
| 49 |
+
Table 2: Summary vector statistics on three datasets with different activation functions including ReLU, LeakyReLU (i.e., LReLU shown below), PReLU, and Sigmoid.
|
| 50 |
+
|
| 51 |
+
<table><tr><td>Activation</td><td>Statistics</td><td>Cora</td><td>CiteSeer</td><td>PubMed</td></tr><tr><td rowspan="3">ReLU/LReLU/PReLU</td><td>Mean</td><td>0.50</td><td>0.50</td><td>0.50</td></tr><tr><td>Std</td><td>1.3e-03</td><td>1.0e-04</td><td>4.0e-04</td></tr><tr><td>Range</td><td>1.4e-03</td><td>8.0e-04</td><td>1.5e-03</td></tr><tr><td rowspan="3">Sigmoid</td><td>Mean</td><td>0.62</td><td>0.62</td><td>0.62</td></tr><tr><td>Std</td><td>5.4e-05</td><td>2.9e-05</td><td>6.6e-05</td></tr><tr><td>Range</td><td>3.6e-03</td><td>3.0e-03</td><td>3.2e-03</td></tr></table>
|
| 52 |
+
|
| 53 |
+
tors in all datasets are approximately a constant vector $\epsilon I$ , where $\epsilon$ is a scalar and $\pmb { I }$ is an all-ones vector (i.e., $\scriptstyle \epsilon = 0 . 5 0$ with ReLU/LReLU/PReLU and $\epsilon { = } 0 . 6 2$ with Sigmoid as non-linear activation in these datasets).
|
| 54 |
+
|
| 55 |
+
To theoretically explain this phenomenon, we present the proposition below:
|
| 56 |
+
|
| 57 |
+
Table 3: The experiment result on three datasets with changing value from 0 to 1.0 for the summary vector.
|
| 58 |
+
|
| 59 |
+
<table><tr><td>Dataset</td><td>0</td><td>0.2</td><td>0.4</td><td>0.6</td><td>0.8</td><td>1.0</td></tr><tr><td>Cora</td><td></td><td></td><td></td><td></td><td>70.3±0.7 82.4±0.2 82.3±0.3 82.5±0.4 82.3±0.3 82.5±0.1</td><td></td></tr><tr><td>CiteSeer</td><td></td><td></td><td></td><td></td><td>61.8±0.8 71.7±0.6 71.9±0.7 71.6±0.9 71.7±1.0 71.6±0.8</td><td></td></tr><tr><td>PubMed</td><td>68.3±1.5 77.8±0.5 77.9±0.8 77.7±0.9 77.4±1.1 77.2±0.9</td><td></td><td></td><td></td><td></td><td></td></tr></table>
|
| 60 |
+
|
| 61 |
+
Proposition 1 Given $\mathcal { G } = \{ \mathbf { X } \in \mathbb { R } ^ { N \times D } , \mathbf { A } \in \mathbb { R } ^ { N \times N } \} ,$ and a GCN encoder $g ( \cdot )$ initialised with Xavier initialisation, we can obtain its embedding $\mathbf { H } = \sigma ( g ( \mathcal { G } ) )$ , where $\sigma ( \cdot )$ is a non-linear activation function. By applying the sigmoid function $\sigma _ { s i g } ( \cdot )$ to the summary vector s (i.e., the average row vector of H), values in $\sigma _ { s i g } ( \mathbf { s } )$ approximately become 0.5 with ReLU/LReLU/PReLU or 0.62 with Sigmoid as non-linear activation of $g ( \cdot )$ at the initialisation stage.
|
| 62 |
+
|
| 63 |
+
Based on this proposition, we can see these summary vectors can lose variance and become a constant vector at the initialisation stage. Based on Table 2, we can see the constant in the summary vector remain unchanged, and the information loss still occurs even if the GNN encoder is trained. Thus, we conjecture the training process won’t affect the constant value much in the summary vector of DGI. The proof for the proposition is presented in Appendix A.1.
|
| 64 |
+
|
| 65 |
+
To evaluate the effect of $\epsilon$ to constant summary vector, we vary the scalar $\epsilon$ (from 0 to 1 increment by 0.2) to change the constant summary vector and report the model performance (i.e., averaged accuracy on five runs) in Table 3.
|
| 66 |
+
|
| 67 |
+
From this table, we can see, except for 0, the model performance is trivially affected by $\epsilon$ for constant summary vector. When the summary vector is set to 0, the model performance plummets because node embeddings become all 0 when multiplying with such vector and the model converges to the trivial solution. As the summary vector only has a trivial effect on model training, the hypothesis of DGI [10] on learning via contrastiveness between anchor nodes and the summary instance does not hold, which raises a question to be investigated: What truly leads to the success of DGI?
|
| 68 |
+
|
| 69 |
+
Simplifying DGI. To answer the question, we predigest the objective function proposed in DGI (i.e., maximising the MI between $\mathbf { h } _ { i }$ and the summary vector s) by using an all-ones vector as the summary vector s (i.e., setting $\mathbf { s } = \epsilon \pmb { I } = \pmb { I }$ ) and simplifying the discriminator $\mathcal { D } ( \cdot )$ (i.e., removing the learnable weight matrix). Then, we rewrite the objective function to the following form:
|
| 70 |
+
|
| 71 |
+
$$
|
| 72 |
+
\begin{array} { l } { \displaystyle \mathcal { L } _ { D G I } = \frac { 1 } { 2 N } ( \sum _ { i = 1 } ^ { N } \log \mathcal { D } ( \mathbf { h } _ { i } , \mathbf { s } ) + \log ( 1 - \mathcal { D } ( \tilde { \mathbf { h } } _ { i } , \mathbf { s } ) ) ) , } \\ { \displaystyle \qquad = \frac { 1 } { 2 N } ( \sum _ { i = 1 } ^ { N } \log ( \mathbf { h } _ { i } \cdot \mathbf { s } ) + \log ( 1 - \tilde { \mathbf { h } } _ { i } \cdot \mathbf { s } ) ) ) , } \\ { \displaystyle \qquad = \frac { 1 } { 2 N } ( \sum _ { i = 1 } ^ { N } \log ( s u m ( \mathbf { h } _ { i } ) ) + \log ( 1 - s u m ( \tilde { \mathbf { h } } _ { i } ) ) ) , } \end{array}
|
| 73 |
+
$$
|
| 74 |
+
|
| 75 |
+
where $\cdot$ is the vector multiplication operation, $N$ is the number of nodes in a graph, $\mathbf { h } _ { i } \in \mathbb { R } ^ { 1 \times D }$ and $\tilde { \mathbf { h } } _ { i } \in \mathbb { R } ^ { 1 \times D }$ are the original and corrupted embedding for node $i$ $, s u m ( \cdot )$ is the summation function, and $\mathcal { D } ( \cdot )$ is a discriminator for bilinear transformation, which can be formulated as follows:
|
| 76 |
+
|
| 77 |
+
$$
|
| 78 |
+
\begin{array} { r } { \mathrm { \bf ~ \mathcal { D } } ( { \bf h } _ { i } , { \bf s } ) = \sigma _ { s i g } ( { \bf h } _ { i } \cdot { \bf W } \cdot { \bf s } ) , } \end{array}
|
| 79 |
+
$$
|
| 80 |
+
|
| 81 |
+
where $\mathbf { W }$ is a learnable weight matrix and $\sigma _ { s i g } ( \cdot )$ is the sigmoid function. Specifically, as shown in Equation 2, by removing the weight matrix $\mathbf { W } , { \mathbf { h } } _ { i }$ is directly multiplied with s. As s is a vector containing only one, the multiplication of $\mathbf { h } _ { i }$ and s is equivalent to summing $\mathbf { h } _ { i }$ itself directly. From this form, we can see that the multiplication of $\mathbf { h } _ { i }$ and the summary vector only serves as an aggregation function (i.e., summation aggregation) to aggregate $\mathbf { h } _ { i }$ . To explore the effect of other aggregation functions, we replace the summation function in Equation 1 with other aggregation methods such as mean-, minimum-, and maximum- pooling, and present the experiment result in Appendix A.3.
|
| 82 |
+
|
| 83 |
+
Table 4: Comparison of the original DGI and $\mathrm { D G I } _ { B C E }$ in terms of accuracy (averaged on five runs), memory efficiency (in MB) and training time (in seconds). Number after | shows how many times have $\mathrm { D G I } _ { B C E }$ improved on top of DGI.
|
| 84 |
+
|
| 85 |
+
<table><tr><td>Experiment</td><td>Method</td><td>Cora</td><td>CiteSeer</td><td>PubMed</td></tr><tr><td>Accuracy</td><td>DGI</td><td>81.7±0.6</td><td>71.5±0.7</td><td>77.3±0.6</td></tr><tr><td></td><td>DGIBCE</td><td>82.5±0.3</td><td>71.7±0.6</td><td>77.7±0.5</td></tr><tr><td>Memory</td><td>DGI</td><td>4189MB</td><td>8199MB</td><td>11471MB</td></tr><tr><td></td><td>DGIBCE</td><td></td><td></td><td>1475MBl64.8%1587MBl80.6%1629MBl85.8%</td></tr><tr><td>Time</td><td>DGI</td><td>0.085s</td><td>0.134s</td><td>0.158s</td></tr><tr><td></td><td>DGIBCE</td><td>0.010sl8.5×</td><td>0.021sl6.4×</td><td>0.015sl10.5×</td></tr></table>
|
| 86 |
+
|
| 87 |
+
Based on Equation 1, we can rewrite it to a very simple binary cross entropy loss if we also include corrupted nodes as data samples and setting ${ \hat { y } } _ { i } = a g g ( \mathbf { h } _ { i } )$ , where $a g g ( \cdot )$ stands for aggregation:
|
| 88 |
+
|
| 89 |
+
$$
|
| 90 |
+
\mathcal { L } _ { B C E } = - \frac { 1 } { 2 N } ( \sum _ { i = 1 } ^ { 2 N } y _ { i } \log \hat { y } _ { i } + ( 1 - y _ { i } ) \log ( 1 - \hat { y } _ { i } ) ) ,
|
| 91 |
+
$$
|
| 92 |
+
|
| 93 |
+
where $y _ { i } \in \mathbb { R } ^ { 1 \times 1 }$ means the indicator for node $i$ (i.e., if node $i$ is corrupted, $y _ { i }$ is 0, otherwise it is 1), and $\hat { y } _ { i } \in \mathbb { R } ^ { 1 \times 1 }$ represents the prediction for a node sample $i$ . As we include corrupted nodes as data samples, the size of nodes to be processed is doubled to $2 N$ (i.e., the number of corrupted nodes is equal to the number of original nodes). From the equation above, we can easily observe that what DGI truly does is discriminate between a group of nodes generated with correct topology and nodes generated with corrupted topology, as shown in Figure 1. We name this self-supervised learning paradigm "Group Discrimination". To validate the effectiveness of this paradigm, we replace the original DGI loss with Equation 3, namely, $\mathrm { D G I } _ { B C E }$ and compare it with DGI on three datasets in terms of training time, memory efficiency and model performance as shown in Table 4. Here, $\mathrm { D G I } _ { B C E }$ adopts the same parameter setting as DGI. From this table, we can observe $\mathrm { D G I } _ { B C E }$ dramatically improves DGI in both memory and time efficiency while it slightly enhances the model performance of DGI. This may be contributed to the removal of multiplication operations between node pairs, which eases the burden of computation and memory consumption.
|
| 94 |
+
|
| 95 |
+
Similar to DGI, the same technical defect is observed in MVGRL [11], which makes it become a GD-based method. Extended on DGI, MVGRL [11] incorporates diffusion augmentation to inject additional global information into model training, which enhances the model performance. The detailed analysis for MVGRL is presented in Appendix A.4.
|
| 96 |
+
|
| 97 |
+
# 2.2 Definition of Group Discrimination
|
| 98 |
+
|
| 99 |
+
As mentioned above, Group Discrimination is a self-supervised GRL paradigm, which learns by discriminating different groups of node samples. Specifically, the paradigm assigns different indicators to different groups of node samples. For example, for binary group discrimination, one group is considered as the positive group with class 1 as its indicator, whereas the other group is the negative group, having its indicator assigned as 0. Given a graph G, the positive group usually includes node samples generated with the original graph G or its augmented views (i.e., similar graph instances of G created by augmentation). In contrast, the opposing group contains negative samples obtained by corrupting G, e.g., changing its topology structure.
|
| 100 |
+
|
| 101 |
+
Based on our theoretical analysis, group discrimination is learning to avoid making ‘mistakes’ (i.e., bias the encoder towards avoiding mistaken samples), thus improving the quality of generated embeddings. The analysis and an intuitive explanation are presented in Section 6.1.1 and A.2.1.
|
| 102 |
+
|
| 103 |
+
# 3 Methodology
|
| 104 |
+
|
| 105 |
+
We first define unsupervised node representation learning and then present the architecture of GGD, which extends $\mathbf { D G I } _ { B C E }$ with additional augmentation, the projector and embedding reinforcement to reach better model performance. Given a graph G with attributes $\mathbf { X } \in \mathbb { R } ^ { N \times D }$ , where $N$ is the number of nodes in G, and $D$ is the number of dimensions of $\mathbf { X }$ , our aim is to train a GNN encoder without the reliance on labelling information. With the trained encoder, taking G and $\mathbf { X }$ as input, it can output learned representations $\mathbf { H } \in \mathbb { R } ^ { N \times D ^ { \prime } }$ , where $D ^ { \prime }$ is the predefined hidden dimension. H can then be used in many downstream tasks such as node classification.
|
| 106 |
+
|
| 107 |
+

|
| 108 |
+
|
| 109 |
+
Figure 3: The architecture of GGD. Given a graph G with a feature matrix $\mathbf { X }$ , we can optionally apply augmentation on them to generate $\hat { \mathcal G }$ and $\hat { \mathbf X }$ . Then, we corrupt $\hat { \mathbf { X } }$ and $\hat { \mathcal G }$ to obtain $\tilde { \mathbf { X } }$ and G˜. Taking $\dot { \hat { \mathbf { X } } }$ and $\hat { \mathcal G }$ as input to the encoder and the projector, i.e., a multilayer perceptron, positive node samples can be obtained. Similarly, $\tilde { \mathbf { X } }$ and $\tilde { \mathcal { G } }$ are fed to the same encoder and projector to generate negative samples. The generated embeddings are aggregated to get predictions for the group discrimination task. This process will be iteratively conducted until reaching the predefined training epochs.
|
| 110 |
+
|
| 111 |
+
# 3.1 Graph Group Discrimination
|
| 112 |
+
|
| 113 |
+
Based on the proposed self-supervised GRL paradigm, group discrimination, we have designed a novel method, namely GGD, to learn node representations using a siamese network structure and a BCE loss. The architecture of GGD is presented in Figure 3. The framework mainly consists of four components: augmentation, corruption, a siamese GNN network, and group discrimination.
|
| 114 |
+
|
| 115 |
+
Augmentation. With a given graph G and feature matrix $\mathbf { X }$ , optionally, we can augment it with augmentation techniques such as edge and feature dropout to create $\hat { \mathcal G }$ and $\hat { \mathbf X }$ . In practice, we follow the augmentation proposed in GraphCL [18]. Specifically, edge dropout removes a predefined fraction of edges, while we use node dropout to mask a predefined proportion of feature dimension, i.e., assigning 0 to replace values in randomly selected dimensions. This step is optional in implementation.
|
| 116 |
+
|
| 117 |
+
Notably, the motivation of using augmentation in our framework is distinct from contrastive learning methods. In our study, augmentation is used to increase the difficulty of the self-supervised training tasks. With augmentation, $\hat { \mathcal G }$ and $\hat { \mathbf { X } }$ change in every training iteration, which forces the model to lessen the dependence on the fixed pattern (i.e., unchanged edge and feature distribution) in a monotonous graph. However, in contrastive learning, augmentation creates augmented views sharing similar semantic information for building contrastiveness.
|
| 118 |
+
|
| 119 |
+
Corruption. $\hat { \mathcal G }$ and $\hat { \mathbf X }$ are then corrupted to build $\tilde { \mathcal { G } }$ and $\tilde { \mathbf { X } }$ for the generation of node embeddings in the negative group. We adopt the same corruption technique used in DGI [10] and MVGRL [11] (as shown in Figure 5). The corruption technique devastates the topology structure of $\hat { \mathcal G }$ by randomly changing the order of nodes in $\hat { \mathbf { X } }$ . The corrupted $\tilde { \mathbf { X } }$ and $\tilde { \mathcal { G } }$ can be used for producing node representations with incorrect network connections.
|
| 120 |
+
|
| 121 |
+
The Siamese GNN. We have designed a siamese GNN network to output node representations given a graph and its attribute. The siamese GNN network is made up of two components, which are a GNN encoder and a projector. The backbone GNN encoder is replaceable with a variety of choices of GNNs, e.g., GCN [19] and GAT [20]. In our work, we adopt GCN as the backbone. The projector is a multi-layer perceptron network, whose number of layers can be adjusted. When generating node embeddings of the positive group, the Siamese network takes $\hat { \mathcal G }$ and $\hat { \mathbf { X } }$ as input. Using the same encoder and projector, the Siamese network output the negative group with $\bar { \mathfrak { G } }$ and $\tilde { \mathbf { X } }$ . These two groups of node embeddings are considered as a collection of data samples with a size of $2 N$ for discrimination. Before conducting group discrimination, in the “aggregation” phase, all data samples are aggregated with the same aggregation technique, e.g., sum-, mean-, and linear aggregation.
|
| 122 |
+
|
| 123 |
+
Group Discrimination. In the group discrimination process, we adopt a very simple binary cross entropy (BCE) loss to discriminate two groups of node samples as shown in Equation 3. In our implementation, $y _ { i }$ is 0 and 1 for node embeddings in negative and positive groups. During model training, the model is optimised by categorising node embeddings in the collection of data samples into their corresponding class correctly. The loss is computed by comparing the prediction of a node $i$ , i.e., a scalar, with its indicator $y _ { i }$ . With the ease of BCE loss computation, the training process of GGD is very fast and memory efficient.
|
| 124 |
+
|
| 125 |
+
# 3.2 Model Inference
|
| 126 |
+
|
| 127 |
+
During training, the model is optimised via loss minimisation with Equation 3. The time complexity analysis of GGD is provided in Appendix A.5. In the inference phase, we freeze the trained GNN encoder $g _ { \theta }$ and obtain node embeddings $\mathbf { H } _ { \theta }$ with the input G.
|
| 128 |
+
|
| 129 |
+
Inspired by MVGRL [11], which strengthens the output embeddings by including additional global information, we adopt a conceptually similar embedding reinforcement approach. Specifically, they obtain the final embeddings by summing up embeddings from two views: the original view comprising local information and the diffused view with global information. This operation reinforces the final embeddings and leads to model performance improvement. Nonetheless, graph diffusion impairs the scalability of a model [21] and hence cannot be directly applied in our embedding generation process. To avoid the diffusion computation, we have come up with a workaround in the virtue of the power of a graph to extract global information. The power of a graph can extend the message passing scope of $\mathbf { H } _ { \theta }$ to n-hop neighbourhood, which encodes global information from distant neighbours. It can be formulated as follows:
|
| 130 |
+
|
| 131 |
+
$$
|
| 132 |
+
\begin{array} { r } { \mathbf { H } _ { \theta } ^ { g l o b a l } = \mathbf { A } ^ { n } \mathbf { H } _ { \theta } , } \end{array}
|
| 133 |
+
$$
|
| 134 |
+
|
| 135 |
+
where Hglobal is the global embedding, and $\mathbf { A }$ is the adjacency matrix of the graph G. It is notable that this operation can be easily decomposed with the associative property of matrix multiplication and is easy to compute. To show the easiness of such computation, we conduct an experiment showing its time consumption on various datasets in Appendix A.6. Finally, the final embedding can be achieved by $\mathbf { H } = \mathbf { H } _ { \theta } ^ { g l o \bar { b } a l } + \mathbf { H } _ { \theta }$ , which can be used for downstream tasks. In our experiment, we conduct node classification tasks. Following the common practice of GCL methods [10, 13, 15, 12, 17], these tasks are performed by using the final embeddings $\mathbf { H }$ to train and test a simple logistic regression classifier.
|
| 136 |
+
|
| 137 |
+
# 4 Related Work
|
| 138 |
+
|
| 139 |
+
Graph Neural Networks (GNNs). are generalised deep neural networks for graph-structured data. GNNs mainly have two categories, spectral-based GNNs and spatial-based GNNs. Spectral GNNs attempt to use eigen-decomposition to obtain the spectral-based representation of graphs, whereas spatial GNNs focus on using spatial neighbours of nodes for message passing. Extending spectral-based methods to the spatial domain, GCN [19] utilises first-order Chebyshev polynomial filters to approximate spectral-based graph convolution. Taking the weight of spatial neighbours in consideration, GAT [20], improves GCN by introducing attention module in message passing. To decouple message passing from neural networks, SGC [22] simplifies GCN by removing non-linearity and weight matrices in graph convolution layers. However, these studies cannot handle datasets with limited or no labels. Graph contrastive learning has been recently exploited to address this issue.
|
| 140 |
+
|
| 141 |
+
Graph Contrastive Learning (GCL). aims to alleviate the reliance on labelling information in model training based on the concept of mutual information (MI). Specifically, GCL approaches maximise MI between instances with similar semantic information, and minimise MI between dissimilar instances. For example, DGI [10] builds contrastiveness between node embeddings and a summary vector (i.e., a graph level embedding obtained by averaging all node embeddings) with a JSD estimator. To improve DGI, MVGRL [11] and GMI [12] extends the idea of DGI by introducing multi-view contrastiveness with diffusion augmentation, and focusing on a local scope with the first-order neighbourhood, respectively. Adopting InfoNCE loss, GRACE [13] applies augmentation techniques to create two augmented views and inject contrastiveness between them. Though these GCL methods have successfully outperformed some supervised baselines in benchmark datasets, these methods suffer from significant limitations, including time-consuming training, memory inefficiency, and poor scalability. In contrast, GGD requires much less time in training and posses high scalability.
|
| 142 |
+
|
| 143 |
+
Scalable GNNs. Efficiency is a bottleneck for most existing GNNs to handle large graphs. To address this challenge, there are mainly three categories of approaches: layer-wise sampling (e.g., GraphSage [23]), graph sampling methods such as Cluster-GCN [24] and GraphSAINT [25], and linear models, e.g., SGC [22] and PPRGo [26]. GraphSage [23] introduces a neighbour-sampling approach, which creates fixed-size subgraphs for each node. Underpinned by graph sampling, Cluster-GCN [24] decomposes a large-scale graph into multiple subgraphs based on clustering, while GraphSAINT [25] utilises light-weight graph samplers along with a normalisation technique for biases elimination in mini-batches. Linear models, SGC [22] and PPRGo [26], decouple graph convolution from embedding transformation (i.e., matrix multiplication with weight matrices), and leverage Personalised PageRank to encode multi-hop neighbourhood, respectively. However, all these methods only focus on supervised learning on graphs. For unsupervised/self-supervised learning settings where no labelled supervision signal is available, these frameworks are not applicable. The closest works to ours to handle large scale graph datasets under self-supervised settings are BGRL [15] and GBT [14]. They try to improve the contrastive losses by removing negative samples. However, BGRL [15] and GBT [14] still require much more time in training compared with GGD.
|
| 144 |
+
|
| 145 |
+
# 5 Experiments
|
| 146 |
+
|
| 147 |
+
We evaluate the effectiveness of our model using eight benchmark datasets of different sizes. These datasets include five small- and mediumscale datasets: Cora, CiteSeer, PubMed [27], Amazon Computers, and Amazon Photos [28], as well as large-scale datasets ogbn-arxiv, ogbnproducts and ogbn-papers100M. Notably, ogbnpapers100M is the largest dataset provided by Open Graph Benchmark[29] for node property prediction tasks. It has over 110 million nodes and 1 billion edges. The statistics of these datasets are summarised in Appendix A.7. To
|
| 148 |
+
|
| 149 |
+
Table 5: Model performance of node classification on 5 datasets. X, A and Y represent feature, adjacency matrix, and labels. Best performance for each dataset is in bold. Comp and Photo refer to Amazon Computers and Amazon Photos.
|
| 150 |
+
|
| 151 |
+
<table><tr><td>Data</td><td>Method</td><td>Cora</td><td></td><td>CiteSeer PubMed</td><td>Comp</td><td>Photo</td></tr><tr><td>X,A,Y</td><td>GCN</td><td>81.5</td><td>70.3</td><td>79.0</td><td></td><td>76.3±0.5 87.3±1.0</td></tr><tr><td>X,A,Y</td><td>GAT</td><td>83.0±0.7 72.5±0.7 79.0±0.3 79.3±1.1 86.2±1.5</td><td></td><td></td><td></td><td></td></tr><tr><td>X,A,Y</td><td>SGC</td><td>81.0±0.0 71.9±0.1 78.9±0.0 74.4±0.1 86.4±0.0</td><td></td><td></td><td></td><td></td></tr><tr><td>X,A,Y</td><td>CG3</td><td>83.4±0.7 73.6±0.8 80.2±0.8 79.9±0.6 89.4±0.5</td><td></td><td></td><td></td><td></td></tr><tr><td>X,A</td><td>DGI</td><td>81.7±0.6 71.5±0.7 77.3±0.6 75.9±0.6 83.1±0.5</td><td></td><td></td><td></td><td></td></tr><tr><td>X,A</td><td>GMI</td><td>82.7±0.2 73.0±0.3 80.1±0.2 76.8±0.1 85.1±0.1</td><td></td><td></td><td></td><td></td></tr><tr><td>X,A</td><td>MVGRL</td><td>82.9±0.7 72.6±0.7 79.4±0.3 79.0±0.6 87.3±0.3</td><td></td><td></td><td></td><td></td></tr><tr><td>X,A</td><td>GRACE</td><td></td><td></td><td></td><td></td><td>80.0±0.4 71.7±0.6 79.5±1.1 71.8±0.4 81.8±1.0</td></tr><tr><td>X,A</td><td>GraphCL</td><td>82.5±0.2 72.8±0.3 77.5±0.2 OOM</td><td></td><td></td><td></td><td>79.5±0.4</td></tr><tr><td>X,A</td><td>BGRL</td><td></td><td></td><td></td><td></td><td>80.5±1.0 71.0±1.2 79.5±0.6 89.2±0.9 91.2±0.8</td></tr><tr><td>X,A</td><td>GBT</td><td></td><td></td><td></td><td>81.0±0.5 70.8±0.2 79.0±0.1 88.5±1.0 91.1±0.7</td><td></td></tr><tr><td>X,A</td><td>GGD</td><td></td><td></td><td></td><td>83.9±0.4 73.0±0.6 81.3±0.8 90.1±0.9 92.5±0.6</td><td></td></tr></table>
|
| 152 |
+
|
| 153 |
+
ensure reproducibility, the detailed experiment settings and computing infrastructure are summarised in Appendix A.8. The source code is already open sourced2.
|
| 154 |
+
|
| 155 |
+
# 5.1 Evaluating on Small- and Medium-scale Datasets
|
| 156 |
+
|
| 157 |
+
We compare GGD with ten baselines including four supervised GNNs (i.e., GCN [19], GAT [20], SGC [22], and CG3 [30]) and six GCL methods (i.e., DGI [10], GMI [12], MVGRL [11], GRACE [13], BGRL [15] and GBT [14]) on five small- and medium scale benchmark datasets. In the experiment, we follow the same data splits as [31] for Cora, CiteSeer and PubMed. For Amazon Computers and Photos, we use a random split setting, which randomly allocates $10 / 1 0 / 8 0 \%$ of data to training/validation/test set, respectively. The model performance is measured using the averaged
|
| 158 |
+
|
| 159 |
+
Table 6: Comparison of training time per epoch in seconds between six GCL-based methods and GGD on five datasets. Improve means how many times are GGD faster than baselines. ‘-’ means the improvement range.
|
| 160 |
+
|
| 161 |
+
<table><tr><td>Method</td><td>Cora</td><td>CiteSeer</td><td>PubMed</td><td>Comp</td><td>Photo</td></tr><tr><td>DGI</td><td>0.085</td><td>0.134</td><td>0.158</td><td>0.171</td><td>0.059</td></tr><tr><td>GMI</td><td>0.394</td><td>0.497</td><td>2.285</td><td>1.297</td><td>0.637</td></tr><tr><td>MVGRL</td><td>0.123</td><td>0.171</td><td>0.488</td><td>0.663</td><td>0.468</td></tr><tr><td>GRACE</td><td>0.056</td><td>0.092</td><td>0.893</td><td>0.546</td><td>0.203</td></tr><tr><td>GraphCL</td><td>0.073</td><td>0.085</td><td>0.123</td><td>OOM</td><td>0.188</td></tr><tr><td>BGRL</td><td>0.085</td><td>0.094</td><td>0.147</td><td>0.337</td><td>0.273</td></tr><tr><td>GBT</td><td>0.073</td><td>0.072</td><td>0.103</td><td>0.492</td><td>0.173</td></tr><tr><td>GGD</td><td>0.010</td><td>0.021</td><td>0.015</td><td>0.016</td><td>0.009</td></tr><tr><td>Improve</td><td>7.3-39.4×</td><td>3.4-23.7×</td><td>6.9-152.3×</td><td>10.7-15.3×</td><td>19.2-70.8x</td></tr></table>
|
| 162 |
+
|
| 163 |
+
classification accuracy with five results along with standard deviations and reported in Table 5.
|
| 164 |
+
|
| 165 |
+
Accuracy. From Table 5, we can observe that GGD generally outperforms all baselines in all datasets. The only exception is on CiteSeer dataset, where the semi-supervised method, CG3[30], slightly outperforms GGD, which still provides the 2nd best performance. In this experiment, we use the officially released code of GraphCL [18], BGRL [15] and GBT [14] to reproduce the result, while the other results are sourced from previous studies [30, 1].
|
| 166 |
+
|
| 167 |
+
# Efficiency and Memory Consumption. GGD is
|
| 168 |
+
|
| 169 |
+
Table 7: Comparison of memory consumption in MBs of six GCL baselines and GGD on five datasets.
|
| 170 |
+
|
| 171 |
+
<table><tr><td>Method</td><td>Cora</td><td>CiteSeer</td><td>PubMed</td><td>Comp</td><td>Photo</td></tr><tr><td>DGI</td><td>4,189</td><td>8,199</td><td>11,471</td><td>7,991</td><td>4.946</td></tr><tr><td>GMI</td><td>4,527</td><td>5,467</td><td>14.697</td><td>10.655</td><td>5,219</td></tr><tr><td>MVGRL</td><td>5,381</td><td>5,429</td><td>6.619</td><td>6.645</td><td>6.645</td></tr><tr><td>GRACE</td><td>1,913</td><td>2.043</td><td>12.597</td><td>8,129</td><td>4,881</td></tr><tr><td>GraphCL</td><td>4,163</td><td>8,249</td><td>11,555</td><td>OOM</td><td>9.083</td></tr><tr><td>BGRL</td><td>1,627</td><td>1,749</td><td>2.299</td><td>5.069</td><td>3.303</td></tr><tr><td>GBT</td><td>1,651</td><td>1,799</td><td>2,461</td><td>5.037</td><td>2.641</td></tr><tr><td>GGD</td><td>1,475</td><td>1,587</td><td>1,629</td><td>1,787</td><td>1,637</td></tr><tr><td>Improve</td><td>10.7-72.6%</td><td>11.8-80.6%</td><td>27.2-85.8%</td><td>64.5-83.2%</td><td>38.0-75.4%</td></tr></table>
|
| 172 |
+
|
| 173 |
+
substantially more efficient than other self-supervised baselines in time and memory consumption as shown in Table 6 and Table 7. Remarkably, GGD is 19.2 times faster in Amazon Photos for training time per epoch, and consumes $6 4 . 5 \%$ less memory in Amazon Computers for memory consumption than the most efficient baseline (i.e., GBT [14]). The dramatic boost of time and memory efficiency of GGD is contributed to the exclusion of similarity computation, which enables model training without multiplication of node embeddings.
|
| 174 |
+
|
| 175 |
+
# 5.2 Evaluating on Large-scale datasets
|
| 176 |
+
|
| 177 |
+
To evaluate the scalability of GGD, we choose three large-scale datasets from Open Graph Benchmark [29], which are ogbn-arxiv, ogbn-products, and ogbn-papers100M. ogbn-papers100M is the most challenging large-scale graph available in Open Graph Benchmark for node property prediction with over 1 billion edges and 110 million nodes. Extending to extremely large graphs (i.e., ogbnproducts and ogbn-papers100M), we adopt a Neighbourhood Sampling strategy, which is described in Appendix A.8.
|
| 178 |
+
|
| 179 |
+
ogbn-arxiv & ogbn-products. For ogbn-arxiv, we compare GGD against four self-supervised baselines (i.e., DGI [10], GRACE [13], BGRL [15]and GBT [14]), whereas BGRL [15] and GBT [14] are selected to be compared for ogbn-products. In addition, we include the performance of MLP, Node2vec [32], and supervised GCN [19] sourced from [29] in Table 8 and Table 9. For memory and training time comparison, we only compare GGD with the two most efficient baselines (i.e., BGRL and GBT according to Tables 6 and 7). In ogbn-arxiv, we reproduce BGRL [15] and found it fails to process
|
| 180 |
+
|
| 181 |
+
Table 8: Node classification result and efficiency comparison on ogbn-arxiv. ‘epo’ means epoch. ‘Time’ means training time per epoch (in seconds). ‘Total’ is total training time (Number of epochs $\times$ ‘Time’). OOM indicates out-of-memory on Nvidia A40 (48GB). Number after \ means the hidden size of GGD.
|
| 182 |
+
|
| 183 |
+
<table><tr><td>Method</td><td>Valid</td><td>Memory</td><td>Time</td><td>Total</td></tr><tr><td>Supervised GCN</td><td>73.0±0.2 71.7±0.3</td><td></td><td>=</td><td></td></tr><tr><td>MLP</td><td>57.7±0.4 55.5±0.2</td><td></td><td></td><td></td></tr><tr><td>Node2vec</td><td>71.3±0.1 70.1±0.1</td><td></td><td></td><td></td></tr><tr><td>DGI</td><td>71.3±0.1 70.3±0.2</td><td></td><td></td><td></td></tr><tr><td>GRACE(10k epos)</td><td>72.6±0.2 71.5±0.1</td><td></td><td></td><td></td></tr><tr><td>BGRL(10k epos)</td><td>72.5±0.1 71.6±0.1</td><td>OOM (Full-graph)</td><td>/</td><td>/</td></tr><tr><td>GBT(300 epos)</td><td>71.0±0.1 70.1±0.2</td><td>14.959MB</td><td></td><td>6.47 1,941.00</td></tr><tr><td>GGD(1 epo\1500)</td><td>72.7±0.3 71.6±0.5</td><td>14.666MB</td><td></td><td>0.95 0.9512.043×</td></tr><tr><td>GGD(1 epo\256)</td><td>71.0±0.2 70.3±0.3</td><td>4,513MBl69.8%</td><td></td><td>0.18 0.18|10,783×</td></tr></table>
|
| 184 |
+
|
| 185 |
+
ogbn-arxiv in full batch. Thus, we only compare GGD and GBT in this dataset, which can successfully train in full-graph processing mode.
|
| 186 |
+
|
| 187 |
+
From Table 8 and Table 9, we can see GGD remarkably achieves the state-of-the-art performance using only one epoch to train. As a result, GGD is 10,783 times faster than the most efficient baseline, i.e., GBT [14], on total training time to reach the desirable performance in ogbn-arxiv. Please note that the number of epoches in our experiment is consistent with the optimal choice
|
| 188 |
+
|
| 189 |
+
Table 9: Node classification result and efficiency comparison on ogbn-products.
|
| 190 |
+
|
| 191 |
+
<table><tr><td>Method</td><td>Valid</td><td>Test</td><td>Memory</td><td>Time</td><td>Total</td></tr><tr><td>Supervised GCN</td><td>92.0±0.0</td><td>75.6±0.2</td><td>-</td><td>-</td><td></td></tr><tr><td>MLP</td><td>75.5±0.0</td><td>61.1±0.0</td><td></td><td></td><td></td></tr><tr><td>Node2vec</td><td>70.0±0.0</td><td>68.8±0.0</td><td></td><td></td><td></td></tr><tr><td>BGRL(100 epos)</td><td>78.1±2.1</td><td>64.0±1.6</td><td>29,303MB</td><td></td><td>53m16s 5.326m40s</td></tr><tr><td>GBT(100 epos)</td><td>85.0±0.1</td><td>70.5±0.4</td><td>20.419MB</td><td></td><td>48m38s 4.863m20s</td></tr><tr><td>GGD(1 epo)</td><td>90.9±0.5</td><td>75.7±0.4</td><td>4,391MBl78.5%12m46s 12m46sl381x</td><td></td><td></td></tr></table>
|
| 192 |
+
|
| 193 |
+
of this hyperparameter specified in GBT [14]. For ogbn-products, we are $3 8 1 \mathrm { ~ \times ~ }$ faster than GBT [14] on total training time. Notably, our performance is significantly higher than GCL baselines using 100 epochs (i.e., $6 \%$ and $5 . 2 \%$ improvement on GBT [14] in validation and test set, respectively) with only one epoch training in this dataset. In addition, we compare the convergence speed among GGD, BGRL [15] and GBT [14] on ogbn-arxiv and ogbn-products, which are shown in Figure 4. For ogbn-arxiv, BGRL [15] is running using batched processing with neighbour sampling. This figure shows the preeminence of our GGD in convergence speed as GGD can be well-trained with only one epoch (i.e., reaching the peak model performance in the first epoch and staying stable with increased epochs). In contrast, the other two baselines require comparatively much more epochs to gradually improve their performance. Compared with GCL baselines, GGD achieves much faster convergence via Group Discrimination. We conjecture this is because GD-based method focuses on the general edge distribution of graphs instead of node-specific information. Inversely, GCL methods can suffer from convergence inefficiency as they may be easily distracted from too-detailed node-specific information during training.
|
| 194 |
+
|
| 195 |
+
ogbn-papers100M. We further compare GGD with BGRL [15] and GBT [14] on ogbn-papers100M, the largest OGB dataset with billion scale edges. Other self-supervised learning algorithms such as DGI [10] and GMI [12] fail to scale to such a large graph with a reasonable batch size (i.e., 256). We only report the performance of each algorithm after a single epoch of training in Table 10 due to the extreme scale of the dataset and the limitation of our available re
|
| 196 |
+
|
| 197 |
+

|
| 198 |
+
Figure 4: Convergence speed comparison among GGD, BGRL[15] and GBT [14]. X-axis means number of epochs, while Y-axis represents the accuracy on test set.
|
| 199 |
+
|
| 200 |
+
sources. From the table, we can observe that GGD outperforms the two GCL counterparts, BGRL [15] and GBT [14] in both accuracy and efficiency. Specifically, GGD achieves 60.2 in accuracy while BGRL and GBT reach 59.3 and 58.9 in test set, respectively. With only one epoch, these two algorithms may not be well trained. However, training each epoch of these two requires over 1 day and if we would like to train them for 100 epochs, then we will need $1 0 0 +$ GPU days, which is prohibitively impractical for general practitioners. In contrast, GGD can be trained in about 9 hours to achieve a good result for this dataset, which is more appealing in practice.
|
| 201 |
+
|
| 202 |
+
# 6 Explore Group Discrimination
|
| 203 |
+
|
| 204 |
+
In this section, we explore the corruption technique in GGD and provide the theoretical analysis of group discrimination.
|
| 205 |
+
|
| 206 |
+
# 6.1 Exploring Corruption
|
| 207 |
+
|
| 208 |
+
Firstly, we explore the corruption technique used in DGI [10] and MVGRL [11], which is shown in Figure 5. These two studies corrupt the topology of a given graph G by shuffling the feature matrix $\mathbf { X }$ . This is because by changing the node order of $\mathbf { X }$ , the neighbouring structure of G is completely changed, e.g., neighbours of node $a$ become node $b$ neighbours.
|
| 209 |
+
|
| 210 |
+
Table 10: Node classification result and efficiency comparison on ogbn-papers100M.
|
| 211 |
+
|
| 212 |
+
<table><tr><td>Method</td><td>Validation</td><td>Test</td><td>Memory</td><td>Time</td></tr><tr><td>Supervised SGC</td><td>63.3±0.2</td><td>66.5±0.2|</td><td>-</td><td>-</td></tr><tr><td>MLP</td><td>47.2±0.3</td><td>49.6±0.3</td><td>·</td><td>=</td></tr><tr><td>Node2vec</td><td>55.6±0.0</td><td>58.1±0.0</td><td>-</td><td>-</td></tr><tr><td>BGRL (1 epoch)</td><td>59.3±0.5</td><td>62.1±0.3</td><td>14,057MB</td><td>26h28m</td></tr><tr><td>GBT(1 epoch)</td><td>58.9±0.4</td><td>61.5±0.5</td><td>13,185MB</td><td>24h38m</td></tr><tr><td>GGD(1 epoch)</td><td>60.2±0.3</td><td>63.5±0.5</td><td>4,105MBl68.9% 9h15ml2.7×</td><td></td></tr></table>
|
| 213 |
+
|
| 214 |
+
With the corruption technique, negative samples in the negative group are generated with incorrect edges. Thus, by discriminating the positive group (i.e., nodes generated with ground truth edges) and the negative group, we conjecture the model can distil valuable signals by learning how to identify nodes generated with correct topology and output effective node embeddings. To provide explanation to this, we present the theoretical analysis of group discrimination in the following section.
|
| 215 |
+
|
| 216 |
+
# 6.1.1 Theoretical Analysis of Group Discrimination
|
| 217 |
+
|
| 218 |
+
Group discrimination is learning to avoid making ‘mistakes’ (i.e., bias the encoder towards avoiding mistaken samples). To explain this point, we first present Theorem 1 and then provide an intuitive explanation for group discrimination.
|
| 219 |
+
|
| 220 |
+

|
| 221 |
+
Figure 5: Corruption technique in DGI and MVGRL.
|
| 222 |
+
|
| 223 |
+
Theorem 1 Given a graph G, a corrupted
|
| 224 |
+
graph ${ \widetilde { \mathsf { S } } } ,$ , and a encoding network $g ( \cdot )$ , we consider the distribution of positive embeddings $g ( \mathcal { G } )$ as $P _ { p o s }$ and negative embeddings $g ( \tilde { \mathcal { G } } )$ as $P _ { n e g }$ . Optimising the group discrimination loss is equivalent to maximising the Jensen-Shannon divergence between $P _ { p o s }$ and $P _ { n e g }$ .
|
| 225 |
+
|
| 226 |
+
The proof for Theorem 1 is presented in Appendix A.2. From the theorem above, we can see maximising the group discrimination loss $\mathcal { L }$ is the same as maximising $J S ( P _ { p o s } \parallel P _ { n e g } )$ , where $J S$ represents the Jenson-Shannon divergence. Thus, by optimising the loss $\mathcal { L }$ , $P _ { p o s }$ and $P _ { n e g }$ tend to be separated. As a result, group discrimination is intuitively learning to avoid making ‘mistakes’ (i.e., bias the encoder towards avoiding mistaken samples) as shown in Figure 6. This is because by separating $P _ { p o s }$ and $P _ { n e g }$ , $P _ { p o s }$ can gradually become similar to $P _ { o p t i m a l }$ , the optimal distribution for node embeddings. As $P _ { o p t i m a l }$ , is disjoint with $P _ { n e g }$ , if the generated embeddings can avoid being similar to out-of-distribution samples, i.e., negative samples, it can be ideally closer to $P _ { o p t i m a l }$ . Therefore, the trained model can improve the quality of generated node embeddings for node samples.
|
| 227 |
+
|
| 228 |
+
# 7 Future Work
|
| 229 |
+
|
| 230 |
+
In this paper, we have introduced a new self-supervised GRL paradigm: Group Discrimination, which achieves the same level of performance as GCL methods with much less resource consumption (i.e., training time and memory). Some limitations of this work are we still have not explored some questions for GD. For example, can we extend the current binary Group Discrimination scheme (i.e., classifying nodes generated with different topology) to discrimination among multiple groups? Are there any other corruption tech
|
| 231 |
+
|
| 232 |
+

|
| 233 |
+
Figure 6: $P _ { o p t i m a l }$ is the optimal distribution for node embeddings, $P _ { p o s }$ is the distribution of positive samples, $P _ { n e g }$ is the distribution of negative samples, blue nodes represent negative samples, and red nodes are samples in the optimal distribution. At the beginning, $P _ { p o s }$ is overlapped with $P _ { n e g }$ . Then, $P _ { p o s }$ is gradually separated from $P _ { n e g }$ and ideally become closer to $P _ { o p t i m a l }$ .
|
| 234 |
+
|
| 235 |
+
nique to create a more difficult negative group for discrimination? More importantly, with the extremely efficient property, GD has the potential to be deployed to various real-world applications, e.g., recommendation systems, which have limited labelling information and desire fast computation with limited resources.
|
| 236 |
+
|
| 237 |
+
# Acknowledgments and Disclosure of Funding
|
| 238 |
+
|
| 239 |
+
This research was partially supported by an Australian Research Council (ARC) Future Fellowship (FT210100097).
|
| 240 |
+
|
| 241 |
+
This work is supported in part by NSF under grants III-1763325, III-1909323, III-2106758, and SaTC-1930941.
|
| 242 |
+
|
| 243 |
+
# References
|
| 244 |
+
|
| 245 |
+
[1] Ming Jin, Yizhen Zheng, Yuan-Fang Li, Chen Gong, Chuan Zhou, and Shirui Pan. Multi-scale contrastive siamese networks for self-supervised graph representation learning. IJCAI, 2021.
|
| 246 |
+
[2] Yue Tan, Guodong Long, Jie Ma, Lu Liu, Tianyi Zhou, and Jing Jiang. Federated learning from pre-trained models: A contrastive learning approach. In First Workshop on Pre-training: Perspectives, Pitfalls, and Paths Forward at ICML 2022.
|
| 247 |
+
[3] Yue Tan, Guodong Long, Lu Liu, Tianyi Zhou, Qinghua Lu, Jing Jiang, and Chengqi Zhang. Fedproto: Federated prototype learning across heterogeneous clients. In AAAI Conference on Artificial Intelligence, volume 1, page 3, 2022.
|
| 248 |
+
[4] He Zhang, Bang Wu, Xingliang Yuan, Shirui Pan, Hanghang Tong, and Jian Pei. Trustworthy graph neural networks: Aspects, methods and trends. arXiv preprint arXiv:2205.07424, 2022.
|
| 249 |
+
[5] He Zhang, Bang Wu, Xiangwen Yang, Chuan Zhou, Shuo Wang, Xingliang Yuan, and Shirui Pan. Projective ranking: A transferable evasion attack method on graph neural networks. In CIKM, 2021.
|
| 250 |
+
[6] Ming Jin, Yuan-Fang Li, and Shirui Pan. Neural temporal walks: Motif-aware representation learning on continuous-time dynamic graphs. In Advances in Neural Information Processing Systems, 2022.
|
| 251 |
+
[7] Ming Jin, Yu Zheng, Yuan-Fang Li, Siheng Chen, Bin Yang, and Shirui Pan. Multivariate time series forecasting with dynamic graph neural odes. arXiv preprint arXiv:2202.08408, 2022.
|
| 252 |
+
[8] Yixin Liu, Zhao Li, Shirui Pan, Chen Gong, Chuan Zhou, and George Karypis. Anomaly detection on attributed networks via contrastive self-supervised learning. TNNLS, 2021.
|
| 253 |
+
[9] Yizhen Zheng, Vincent Lee, Zonghan Wu, and Shirui Pan. Heterogeneous graph attention network for small and medium-sized enterprises bankruptcy prediction. In PAKDD, pages 140–151. Springer, 2021.
|
| 254 |
+
[10] Petar Velickovi ˇ c, William Fedus, William L Hamilton, Pietro Liò, Yoshua Bengio, and R Devon Hjelm. ´ Deep graph infomax. ICLR, 2019.
|
| 255 |
+
[11] Kaveh Hassani and Amir Hosein Khasahmadi. Contrastive multi-view representation learning on graphs. In ICML, pages 4116–4126. PMLR, 2020.
|
| 256 |
+
[12] Zhen Peng, Wenbing Huang, Minnan Luo, Qinghua Zheng, Yu Rong, Tingyang Xu, and Junzhou Huang. Graph representation learning via graphical mutual information maximization. In WWW, pages 259–270, 2020.
|
| 257 |
+
[13] Yanqiao Zhu, Yichen Xu, Feng Yu, Qiang Liu, Shu Wu, and Liang Wang. Deep graph contrastive representation learning. ICML Workshop on Graph Representation Learning and Beyond, 2020.
|
| 258 |
+
[14] Piotr Bielak, Tomasz Kajdanowicz, and Nitesh V Chawla. Graph barlow twins: A self-supervised representation learning framework for graphs. arXiv preprint arXiv:2106.02466, 2021.
|
| 259 |
+
[15] Shantanu Thakoor, Corentin Tallec, Mohammad Gheshlaghi Azar, Rémi Munos, Petar Velickovi ˇ c, and ´ Michal Valko. Bootstrapped representation learning on graphs. ICLR2021, 2021.
|
| 260 |
+
[16] 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. NIPS, 2020.
|
| 261 |
+
[17] Jure Zbontar, Li Jing, Ishan Misra, Yann LeCun, and Stéphane Deny. Barlow twins: Self-supervised learning via redundancy reduction. In ICML, pages 12310–12320, 2021.
|
| 262 |
+
[18] Yuning You, Tianlong Chen, Yongduo Sui, Ting Chen, Zhangyang Wang, and Yang Shen. Graph contrastive learning with augmentations. NIPS, 33:5812–5823, 2020.
|
| 263 |
+
[19] Thomas N Kipf and Max Welling. Semi-supervised classification with graph convolutional networks. ICLR, 2017.
|
| 264 |
+
[20] Petar Velickovi ˇ c, Guillem Cucurull, Arantxa Casanova, Adriana Romero, Pietro Lio, and Yoshua Bengio. ´ Graph attention networks. ICLR, 2018.
|
| 265 |
+
[21] Yizhen Zheng, Ming Jin, Shirui Pan, Yuan-Fang Li, Hao Peng, Ming Li, and Zhao Li. Towards graph self-supervised learning with contrastive adjusted zooming. arXiv preprint arXiv:2111.10698, 2021.
|
| 266 |
+
[22] Felix Wu, Amauri Souza, Tianyi Zhang, Christopher Fifty, Tao Yu, and Kilian Weinberger. Simplifying graph convolutional networks. In ICML, pages 6861–6871. PMLR, 2019.
|
| 267 |
+
[23] William L Hamilton, Rex Ying, and Jure Leskovec. Inductive representation learning on large graphs. In NIPS, pages 1025–1035, 2017.
|
| 268 |
+
[24] 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 KDD, pages 257–266, 2019.
|
| 269 |
+
[25] Johannes Klicpera, Aleksandar Bojchevski, and Stephan Günnemann. Predict then propagate: Graph neural networks meet personalized pagerank. ICLR, 2019.
|
| 270 |
+
[26] Aleksandar Bojchevski, Johannes Klicpera, Bryan Perozzi, Amol Kapoor, Martin Blais, Benedek Rózemberczki, Michal Lukasik, and Stephan Günnemann. Scaling graph neural networks with approximate pagerank. In KDD, pages 2464–2473, 2020.
|
| 271 |
+
[27] Prithviraj Sen, Galileo Namata, Mustafa Bilgic, Lise Getoor, Brian Galligher, and Tina Eliassi-Rad. Collective classification in network data. AI magazine, 29(3):93–93, 2008.
|
| 272 |
+
[28] Oleksandr Shchur, Maximilian Mumme, Aleksandar Bojchevski, and Stephan Günnemann. Pitfalls of graph neural network evaluation. arXiv preprint arXiv:1811.05868, 2018.
|
| 273 |
+
[29] 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. NIPS, 2020.
|
| 274 |
+
[30] Sheng Wan, Shirui Pan, Jian Yang, and Chen Gong. Contrastive and generative graph convolutional networks for graph-based semi-supervised learning. AAAI, 2020.
|
| 275 |
+
[31] Zhilin Yang, William Cohen, and Ruslan Salakhudinov. Revisiting semi-supervised learning with graph embeddings. In ICML, pages 40–48. PMLR, 2016.
|
| 276 |
+
[32] Aditya Grover and Jure Leskovec. node2vec: Scalable feature learning for networks. In KDD, pages 855–864, 2016.
|
| 277 |
+
[33] Behzad Kamgar-Parsi, Behrooz Kamgar-Parsi, and Menashe Brosh. Distribution and moments of the weighted sum of uniforms random variables, with applications in reducing monte carlo simulations. Journal of Statistical Computation and Simulation, 52(4):399–414, 1995.
|
| 278 |
+
[34] Jean Daunizeau. Semi-analytical approximations to statistical moments of sigmoid and softmax mappings of normal variables. arXiv preprint arXiv:1703.00091, 2017.
|
| 279 |
+
[35] Ian Goodfellow, Jean Pouget-Abadie, Mehdi Mirza, Bing Xu, David Warde-Farley, Sherjil Ozair, Aaron Courville, and Yoshua Bengio. Generative adversarial nets. Advances in neural information processing systems, 27, 2014.
|
md/dev/_nGgzQjzaRy/_nGgzQjzaRy.md
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
md/dev/aUkOeKsGe2X/aUkOeKsGe2X.md
ADDED
|
@@ -0,0 +1,345 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# AUTOENCODER FOR SYNTHETIC TO REAL GENERAL-IZATION: FROM SIMPLE TO MORE COMPLEX SCENES
|
| 2 |
+
|
| 3 |
+
Anonymous authors Paper under double-blind review
|
| 4 |
+
|
| 5 |
+
# ABSTRACT
|
| 6 |
+
|
| 7 |
+
Learning on synthetic data and transferring the resulting properties to their real counterparts is an important challenge for reducing costs and increasing safety in machine learning. In this work, we focus on autoencoder architectures and aim at learning latent space representations that are invariant to inductive biases caused by the domain shift between simulated and real images showing the same scenario. We train on synthetic images only, present approaches to increase generalizability and improve the preservation of the semantics to real datasets of increasing visual complexity. We show that pre-trained feature extractors (e.g. VGG) can be sufficient for generalization on images of lower complexity, but additional improvements are required for visually more complex scenes. To this end, we demonstrate a new sampling technique, which matches semantically important parts of the image, while randomizing the other parts, leads to salient feature extraction and a neglection of unimportant parts. This helps the generalization to real data and we further show that our approach outperforms fine-tuned classification models.
|
| 8 |
+
|
| 9 |
+
# 1 INTRODUCTION
|
| 10 |
+
|
| 11 |
+
The generation of synthetic data constitutes a cost efficient way for acquiring machine learning training data together with exact and free annotations. Notwithstanding this obvious advantage, bridging the gap between synthetic and real data remains an open challenge, in particular for camera based applications. Learning from synthetic data is an important tool in robotics: Lee et al. (2020) introduced a method for training a quadrupedal robot on synthetic data by incorporating proprioceptive feedback. Akkaya et al. (2019) trained a robot hand to solve real Rubik’s cubes by learning the model in a simulation only. Zhang et al. (2019) made the robot feel at home by translating the real world input data into synthetic data for their reinforcement learning agent. In view of safety critical applications, synthetic data can provide the means to reduce costs related to acquiring samples for edge cases, or which are difficult to obtain because they are too dangerous, e.g. accidents. We focus on learning invariances empirically on synthetic data, which should transfer to real data, as opposed to constructing invariances as in equivariant neural networks (Romero & Hoogendoorn, 2020).
|
| 12 |
+
|
| 13 |
+
We investigate the case of single independent images for which consistency between frames and physical interactions cannot be taken advantage of. The latter is commonly used by reinforcement learning methods (Lee et al., 2020). We focus on training on synthetic data only and limit ourselves to autoencoder models which provide interesting properties due to their bottleneck design. The low-dimensional latent space of autoencoders can be subject to metric constraints (Hoffer & Ailon, 2015), allows for scene decomposition (Engelcke et al., 2020) and it is believed that latent factor disentanglement can be useful for downstream tasks (van Steenkiste et al., 2019). We assess to what extend we can generalize to real images and we highlight which design choices improve the autoencoder models performance with respect to accuracy and reconstruction quality. To this end, we first develop a method using features of pre-trained classifiers and show that we achieve better results on MPI3D (Gondal et al., 2019) to generalize from synthetic (toy or realistic) to real images compared to Autoencoder, Variational Autoencoder (VAE) (Kingma & Welling, 2014), $\beta$ - VAE (Higgins et al., 2017) and FactorVAE (Kim & Mnih, 2018). Although successful, we highlight that insights and design choices on a simple dataset do not necessarily transfer to real applications of higher visual complexity. To improve generalization, we propose to use the partially impossible reconstruction loss (PIRL) (Dias Da Cruz et al., 2021) (matching semantically important parts while randomizing the other parts) and we propose a novel variation thereof. We extensively show that our variation is the driving force for the improved generalization capacities. Additionally, we induce structure in the latent space by a triplet loss regularization. We evaluate and justify the benefits of the different design choices on an automotive application focusing on occupancy classification in the vehicle interior. The challenge of training in a single vehicle interior and transferring results between different vehicle interiors has been investigated by Dias Da Cruz et al. (2021). The latter and similar industrial applications suffer from the limited availability and variability of training data. A successful transfer from synthetic to real data would avoid the necessity of collecting real data for each vehicle interior: the invariances could be learned and improved on synthetic data only.
|
| 14 |
+
|
| 15 |
+

|
| 16 |
+
Figure 1: Impossible Instance Extractor Triplet Autoencoder (II-E-TAE) model architecture.
|
| 17 |
+
|
| 18 |
+
# 2 RELATED WORKS
|
| 19 |
+
|
| 20 |
+
There have been successful applications of reinforcement learning systems being trained in a simulated environment and deployed to a real one, for example by combining real and synthetic data during training (Kang et al., 2019; Rao et al., 2020; Fang et al., 2018; Bewley et al., 2019). However, these approaches can take into account temporal information and action-reaction causalities while in this work we use independent frames only. A good overview on reinforcement learning based simulation to real transferability is provided in (Zhao et al., 2020). Another line of research uses generative adversarial networks (GAN) to make synthetic images look like real images or vice versa (Ho et al., 2020; Carlson et al., 2019). This requires both synthetic and real images, whereas we focus on training on synthetic images only. Part of our methodology is related to domain randomization (Tremblay et al., 2018), where the environment is being randomized, but Tremblay et al. (2018) deployed this to object detection and the resulting model needs to be fine-tuned on real data. A similar idea of freezing the layers of a pre-trained model was investigated for object detection (Hinterstoisser et al., 2018), but neither with a dedicated sampling strategy nor in the context of autoencoders. While Tobin et al. (2017) focuses on localization and training on synthetic images only, the applicability is only tested on simple geometries. Although, we start our investigations on the simple dataset MPI3D, we increase the visual complexity by incorporating human models and child seats. Inoue et al. (2018) and Zhang et al. (2015) rely on the use of real images during training as well for the minimization of the synthetic to real gap for autoencoders. Recent advances on synthetic to real image segmentation (Chen et al., 2020; Yue et al., 2019; Pan et al., 2018) on the VisDA (Peng et al., 2017) dataset show a promising direction to overcome the gap between synthetic and real images, however, this cannot straightforwardly be compared against the investigation in this work, particularly, since we are focusing on autoencoder models and their generative nature. While our cost function variation is based on Dias Da Cruz et al. (2021), we show that our approach improves generalization while needing less demanding training data such that it can easily be applied to any commonly recorded dataset (i.e. no variations of the same scene are needed).
|
| 21 |
+
|
| 22 |
+
# 3 METHOD
|
| 23 |
+
|
| 24 |
+
Consider $N _ { s }$ sceneries and $N _ { v }$ variations of the same scenery, e.g. same scenery under different illuminations, with different backgrounds or under different data augmentation transformations. Let $\mathcal { X } = \{ X _ { i } ^ { j } | 1 \le i \le N _ { v } , 1 \le j \le N _ { s } \}$ denote the training data, where each $X _ { i } ^ { j } ~ \in ~ \mathbb { R } ^ { C \times H \times W }$ is the ith variation of scene $j$ consisting of $C$ channels and being of height $H$ and width $W$ . Let $X ^ { j } = \{ X _ { i } ^ { j } | 1 \leq i \leq N _ { v } \}$ be the set of all variations $i$ of scenery $j$ and $\mathcal { V } = \{ Y ^ { j } | 1 \le j \le N _ { s } \}$ be the corresponding target classes of the scenes of $\mathcal { X }$ . Notice that the classes remain constant for the variations $i$ of each scene $j$ . In the following, we will present the final model architecture as illustrated in Fig. 1 and we provide evidences for each design choice in Section 4.
|
| 25 |
+
|
| 26 |
+

|
| 27 |
+
Figure 2: Illustration of the different input-target pairs for the autoencoder reconstruction loss.
|
| 28 |
+
|
| 29 |
+
# 3.1 MODEL ARCHITECTURE: EXTRACTOR AUTOENCODER
|
| 30 |
+
|
| 31 |
+
By an abuse of terminology, we will refer to our method as a variation of vanilla autoencoders, although an encoder-decoder formulation would strictly speaking be more correct, because the goal will not be to reconstruct the input image exactly. We propose to apply ideas from transfer learning and use a pre-trained classification model to extract more general features from the input images. Instead of using the images itself, the extracted features are used as input. Our autoencoder consists of a summarization module which reduces the number of convolutional filters. This is fed to a simple MLP encoder which is then decoded by a transposed convolutional network. We refer to this model as extractor autoencoder (E-AE). Let $\mathrm { e } _ { \phi }$ be the encoder, $\mathrm { d } _ { \theta }$ the decoder and $\mathrm { e x t } _ { \omega }$ be a pre-trained classification model, referred to as extractor. For ease of notation, we define $\mathrm { e } _ { \phi } ( \mathrm { e x t } _ { \omega } ( \cdot ) ) = \mathrm { e e } _ { \phi , \omega } ( \cdot )$ . The model, using the vanilla reconstruction loss, can be formulated for a single input sample as
|
| 32 |
+
|
| 33 |
+
$$
|
| 34 |
+
\begin{array} { r } { \mathcal { L } _ { R } ( X _ { i } ^ { j } ; \theta , \phi ) = \mathrm { r } \left( \mathrm { d } _ { \theta } ( \mathrm { e x t } _ { \omega } ( X _ { i } ^ { j } ) ) ) , X _ { i } ^ { j } \right) = \mathrm { r } \left( \mathrm { d } _ { \theta } ( \mathrm { e e } _ { \phi , \omega } ( X _ { i } ^ { j } ) ) , X _ { i } ^ { j } \right) , } \end{array}
|
| 35 |
+
$$
|
| 36 |
+
|
| 37 |
+
where $\mathrm { r } ( \cdot , \cdot )$ computes the error loss between target and reconstruction. We use the structural similarity index measure (SSIM) (Bergmann et al., 2018) and binary cross entropy (BCE), but our method is not limited to them. Model details are provided in the appendix A.2.1.
|
| 38 |
+
|
| 39 |
+
# 3.2 SAMPLING STRATEGY: PARTIAL IMPOSSIBLE
|
| 40 |
+
|
| 41 |
+
An additional improvement to the autoencoder training approach is a dedicated sampling strategy for which we provide two variations. The first one is the partially impossible reconstruction loss (PIRL) as introduced by Dias Da Cruz et al. (2021) for illumination normalization. As our results will show, this also helps the transfer between synthetic and real images. For sampling the individual elements of a batch, we randomly select for each scene two images, one as input and the other one as target. This sampling strategy preserves the semantics while varying the unimportant features such that the model needs to focus on what remains constant. For random $a , b \in [ 0 , \mathsf { \bar { N } } _ { v } ]$ and $a \neq b$ :
|
| 42 |
+
|
| 43 |
+
$$
|
| 44 |
+
\begin{array} { r } { \mathcal { L } _ { R , I } ( X _ { a } ^ { j } ; \theta , \phi ) = \mathrm { r } \left( \mathrm { d } _ { \theta } \big ( \mathrm { e e } _ { \phi , \omega } ( X _ { a } ^ { j } ) \big ) , X _ { b } ^ { j } \right) . } \end{array}
|
| 45 |
+
$$
|
| 46 |
+
|
| 47 |
+
We refer to models using the PIRL by prepending an $I$ , e.g. I-E-AE.
|
| 48 |
+
|
| 49 |
+
# 3.3 SAMPLING STRATEGY: PARTIAL IMPOSSIBLE CLASS INSTANCE
|
| 50 |
+
|
| 51 |
+
We propose a novel variation to further improve this strategy by sampling a target image of a different scene, but of the same class. This should cause the model to learn invariances with respect to certain class variations which are not important for the task at hand, e.g. clothes, human poses, textures. This sampling variation would be reflected in the reconstruction loss as follows
|
| 52 |
+
|
| 53 |
+
$$
|
| 54 |
+
\begin{array} { r } { \mathcal { L } _ { R , I I } ( X _ { a } ^ { j } ; \theta , \phi ) = \mathrm { r } \left( \mathrm { d } _ { \theta } ( \mathrm e \varphi _ { \phi , \omega } ( X _ { a } ^ { j } ) ) , X _ { b } ^ { k } \right) , } \end{array}
|
| 55 |
+
$$
|
| 56 |
+
|
| 57 |
+
for random $a , b \in [ 0 , N _ { v } ]$ , $j \neq k$ and $Y ^ { j } = Y ^ { k }$ . We refer to this method as impossible class instance sampling marked by prepending $\boldsymbol { { I I } }$ , e.g. II-E-AE. It is important to notice that our novel variation can easily be applied to any common dataset. The sampling variations are visualized in Fig. 2.
|
| 58 |
+
|
| 59 |
+
# 3.4 STRUCTURE IN THE LATENT SPACE: TRIPLET LOSS
|
| 60 |
+
|
| 61 |
+
The final adjustment to our training strategy is the incorporation of the triplet loss regularization in the latent space (Hoffer & Ailon, 2015) to induce structure. This can be integrated by
|
| 62 |
+
|
| 63 |
+
$$
|
| 64 |
+
\mathcal { L } _ { T } ( X _ { a } ^ { j } ; \phi ) = \operatorname* { m a x } \left( 0 , \left. \mathrm { e e } _ { \phi , \omega } ( X _ { a } ^ { j } ) - \mathrm { e e } _ { \phi , \omega } ( X _ { b } ^ { k } ) \right. ^ { 2 } - \left. \mathrm { e e } _ { \phi , \omega } ( X _ { a } ^ { j } ) - \mathrm { e e } _ { \phi , \omega } ( X _ { c } ^ { l } ) \right. ^ { 2 } + 0 . 2 \right) ,
|
| 65 |
+
$$
|
| 66 |
+
|
| 67 |
+
for random $a , b , c \in [ 0 , N _ { v } ]$ , $j \neq k \neq l$ and $Y ^ { j } = Y ^ { k } \neq Y ^ { l }$ . We refer to this model as triplet autoencoder (TAE) either with or without using the PIRL. We can sample impossible target instances for the positive and negative triplet samples such that the total loss becomes (for some $\alpha$ and $\beta$ ):
|
| 68 |
+
|
| 69 |
+
$$
|
| 70 |
+
\begin{array} { r } { \mathcal { L } ( X _ { a } ^ { j } ; \theta , \phi ) = \alpha \mathcal { L } _ { T } ( X _ { a } ^ { j } ; \phi ) + \beta \left( \mathcal { L } _ { R , I I } ( X _ { a } ^ { j } ; \theta , \phi ) + \mathcal { L } _ { R , I I } ( X _ { b } ^ { k } ; \theta , \phi ) + \mathcal { L } _ { R , I I } ( X _ { c } ^ { l } ; \theta , \phi ) \right) . } \end{array}
|
| 71 |
+
$$
|
| 72 |
+
|
| 73 |
+
# 4 EXPERIMENTS
|
| 74 |
+
|
| 75 |
+
This section is organized in observations, formulated as subsections, which are built on one another and contain results highlighting the improvements. This provides explanations for the design choices leading to our final model architecture and cost function formulations presented in Section 3. Improvements regarding the transfer to real images when only being trained on synthetic images are assessed qualitatively based on reconstruction quality and latent space structure and quantitatively on classification accuracy. All experiments use the same hyperparameters whenever possible. Training details and additional results are provided in the appendix and in our implementation.
|
| 76 |
+
|
| 77 |
+
We perform a baseline evaluation on MPI3D (Gondal et al., 2019), which provides simple and realistic renderings and real counterparts. We reduced the dataset to contain only the large objects. For a higher visual complexity, we use as synthetic images the SVIRO (Dias Da Cruz et al., 2020) dataset. TICaM (Katrolia et al., 2021) is used to evaluate the performance on a real dataset of a similar application. The latter datasets are grayscale images from the vehicle interior and consider the task of classification (empty, infant, child or adult) for each seat position. The design choices made on MPI3D and the available synthetic images are not sufficient to obtain a good transferability to real images from the vehicle interior. Hence, we release an additional dataset, see Section 4.5 and A.1.4. We introduce step by step modifications to the autoencoder architecture leading to steady quantitative and qualitative improvements. MPI3D and the vehicle interior share interesting properties: they have almost identical backgrounds and the environment is more tractable than many computer vision datasets. The transfer from SVIRO to TICaM is further complicated by new unseen attributes, e.g. steering wheel. An additional ablation study shows that our novel variation of PIRL is the driving force for the improved generalization capacity. Finally, to be in line with common benchmark datasets, we show that our design choices also improve the transfer from training on MNIST (LeCun et al., 1998) to generalizing to real images of digits (De Campos et al., 2009).
|
| 78 |
+
|
| 79 |
+
# 4.1 AUTOENCODERS STRUGGLE ON REAL IMAGES WHEN TRAINED ON SYNTHETIC IMAGES
|
| 80 |
+
|
| 81 |
+
In the first, albeit na¨ıve experiment we assumed that due to the bottleneck of autoencoders, the latter should generalize to some extent to real images when trained on synthetic ones. We trained convolutional autoencoders (AE) on the toy and realistic MPI3D images, respectively, and evaluated the resulting models on the real recordings. The first row of Fig. 3b shows the reconstruction of real images when trained on the realistic synthetic images: the model preserves some of the semantics. The model fails to perform senseful reconstructions when trained on toy images, see Fig. 3c.
|
| 82 |
+
|
| 83 |
+
# 4.2 AUTOENCODERS OVERFIT TO THE SYNTHETIC DISTRIBUTION
|
| 84 |
+
|
| 85 |
+
An immediate consequence of the results of the previous section is the assumption that the autoencoder overfits to the synthetic distribution and takes into consideration some artefacts (e.g. rendering noise). We followed the idea of Gondal et al. (2019) and trained Variational Autoencoder (VAE) (Kingma & Welling, 2014), $\beta$ -VAE (Higgins et al., 2017) and FactorVAE (Kim & Mnih, 2018) on the same data as before using the BCE reconstruction loss. The results in the second $\beta$ -VAE with $\beta = 8$ ) and third (FactorVAE with $\gamma = 5 0$ ) row of Fig. 3b show that the models reconstruct real images better and more of the semantics are preserved. If trained on toy renderings, the representation gap is too large, causing the reconstruction of the real images to be bad: see Fig. 3c.
|
| 86 |
+
|
| 87 |
+
# 4.3 MORE GENERAL INPUT FEATURES IMPROVE AUTOENCODER RECONSTRUCTIONS
|
| 88 |
+
|
| 89 |
+
A small gap between the synthetic and real distribution can potentially be closed by a dedicated data augmentation approach to avoid overfitting to synthetic artefacts. Nevertheless, and while making sense, an abstraction from toy to real images cannot be achieved by means of simple data transformations or model constraints (e.g. denoising autoencoder). To this end we propose to use a (a) Synthetic realistic and toy training data as well as real data used as input after training (b) Reconstruction of real data when being trained on realistic data.
|
| 90 |
+
|
| 91 |
+

|
| 92 |
+
|
| 93 |
+

|
| 94 |
+
|
| 95 |
+

|
| 96 |
+
(c) Reconstruction of real data when being trained on toy data.
|
| 97 |
+
|
| 98 |
+

|
| 99 |
+
Figure 3: Reconstruction of unseen real data for different autoencoders: Autoencoder (AE), $\beta$ Variational Autoencoder $\beta$ -VAE), FactorVAE (F-VAE) and Extractor Autoencoder (E-AE).
|
| 100 |
+
Figure 4: t-SNE projection of the 10 dimensional latent space representation of the realistic training (blue circle) together with the real (orange cross) images. Autoencoder (AE), $\beta$ Variational Autoencoder ( $\beta$ -VAE), FactorVAE and Extractor Autoencoder (E-AE). The extractor approach is the only method clustering both synthetic and real images together.
|
| 101 |
+
|
| 102 |
+
pre-trained feature extractor as presented in Section 3 and as defined by Eq. 1. In the following, we used the VGG-11 model pre-trained on Imagenet as the extractor if not stated otherwise.
|
| 103 |
+
|
| 104 |
+
The results from the fourth row of Fig. 3b and Fig. 3c, respectively, show that the proposed modifications enable the model to generalize to real images when trained on synthetic ones. Much more of the semantics are preserved even when the model was only trained on toy images. Our method produces semantically more correct and less noisy reconstructions compared to the VAE and FactorVAE baseline results. Additional qualitative improvements are highlighted by visualizing the latent space: both the 10-dimensional training (synthetic) and test (real) data latent spaces are projected together into a 2-dimensional representation using t-SNE. In Fig. 4 we can observe that VAE and FactorVAE improve the representation of real and synthetic images in the same region in the latent space, however, only partially, indicating a different representation for real and synthetic images. When using E-AE, real and synthetic images are represented more similarly in the latent space and the clusters are completely overlapping. Even when trained on the toy dataset, the latent space representation for synthetic and real images produced by E-AE overlaps partially as visualized in the appendix Fig. 8. Finally, we report in Table 1 a quantitative evaluation between the reconstructions of the real images against their synthetic training counterparts across all dataset images for different norms. We compute the same metrics between the real input images and their reconstruction to measure whether the semantics are being preserved : in all cases E-AE performs best. Additional results can be found in the appendix in Table 8 and reconstructions of synthetic input images in Fig 9. The latter shows that all models perform similarly well on the training data, hence the training was successful, but our proposed design choices generalize best to the real images.
|
| 105 |
+
|
| 106 |
+
Table 1: We report the L1, SSIM and LIPIPS (Zhang et al., 2018) norm between the reconstructions of the real images (unknown) and the corresponding synthetic (Synth.) training images (realistic or toy) or input images (Real). We report the mean of the norms across the dataset: for SSIM larger $\uparrow$ and for the others smaller $\downarrow$ is better. E-AE performs best.
|
| 107 |
+
|
| 108 |
+
<table><tr><td></td><td></td><td></td><td colspan="2">L1↓</td><td colspan="2">SSIM↑</td><td colspan="2">LPIPS↓</td></tr><tr><td>Trained on</td><td>Model</td><td>Variant</td><td>Synth.</td><td>Real</td><td>Synth.</td><td>Real</td><td>Synth.</td><td>Real</td></tr><tr><td>Toy</td><td>AE</td><td>SSIM</td><td>932</td><td>1763</td><td>0.56</td><td>0.42</td><td>0.35</td><td>0.40</td></tr><tr><td>Toy</td><td>VAE</td><td>BCE</td><td>659</td><td>1497</td><td>0.50</td><td>0.33</td><td>0.34</td><td>0.42</td></tr><tr><td>Toy</td><td>β-VAE</td><td>BCE,β=4</td><td>710</td><td>1542</td><td>0.53</td><td>0.38</td><td>0.31</td><td>0.44</td></tr><tr><td>Toy</td><td>β-VAE</td><td>BCE,β=8</td><td>406</td><td>1321</td><td>0.71</td><td>0.48</td><td>0.26</td><td>0.37</td></tr><tr><td>Toy</td><td>FactorVAE</td><td>BCE,= 10</td><td>521</td><td>1288</td><td>0.66</td><td>0.45</td><td>0.26</td><td>0.39</td></tr><tr><td>Toy</td><td>FactorVAE</td><td>BCE, = 50</td><td>430</td><td>1295</td><td>0.71</td><td>0.51</td><td>0.22</td><td>0.35</td></tr><tr><td>Toy</td><td>E-AE (ours)</td><td>SSIM</td><td>177</td><td>1165</td><td>0.90</td><td>0.58</td><td>0.10</td><td>0.28</td></tr><tr><td>Realistic</td><td>AE</td><td>SSIM</td><td>568</td><td>1133</td><td>0.83</td><td>0.62</td><td>0.20</td><td>0.24</td></tr><tr><td>Realistic</td><td>VAE</td><td>BCE</td><td>482</td><td>890</td><td>0.74</td><td>0.61</td><td>0.20</td><td>0.23</td></tr><tr><td>Realistic</td><td>β-VAE</td><td>BCE,β= 4</td><td>372</td><td>833</td><td>0.81</td><td>0.64</td><td>0.18</td><td>0.20</td></tr><tr><td>Realistic</td><td>β-VAE</td><td>BCE,β=8</td><td>384</td><td>854</td><td>0.79</td><td>0.64</td><td>0.19</td><td>0.21</td></tr><tr><td>Realistic</td><td>FactorVAE</td><td>BCE, = 10</td><td>218</td><td>734</td><td>0.88</td><td>0.68</td><td>0.15</td><td>0.19</td></tr><tr><td>Realistic</td><td>FactorVAE</td><td>BCE,= 50</td><td>391</td><td>830</td><td>0.78</td><td>0.64</td><td>0.16</td><td>0.18</td></tr><tr><td>Realistic</td><td>E-AE (ours)</td><td>SSIM</td><td>251</td><td>841</td><td>0.92</td><td>0.70</td><td>0.08</td><td>0.14</td></tr></table>
|
| 109 |
+
|
| 110 |
+
# 4.4 IT WORKS FOR VISUALLY SIMPLE IMAGES - MORE IS NEEDED ON MORE COMPLEX DATA
|
| 111 |
+
|
| 112 |
+
Since the method introduced in the previous section achieved good results, even when being trained on toy images, we were optimistic to apply it to images of higher visual complexity, e.g. a vehicle interior. We trained the same model architecture as in the previous section, but with a 64-dimensional latent space, on images from the Tesla vehicle from SVIRO and the Kodiaq vehicle from SVIROIllumination dataset, respectively, and evaluated the model on the real TICaM images. Examples of the resulting model’s reconstructions are plotted in Fig. 5 (b) and in the appendix Fig. 10. In both cases only blurry human models are being reconstructed, which is similar to the mode collapse in the first row of Fig. 3c. We concluded that more robust features are needed.
|
| 113 |
+
|
| 114 |
+
# 4.5 PARTIALLY IMPOSSIBLE RECONSTRUCTION LOSS HELPS GENERALIZATION
|
| 115 |
+
|
| 116 |
+
As defined by Eq. 2, a partially impossible reconstruction loss (PIRL) for autoencoders has proven to work well for image normalization (Dias Da Cruz et al., 2021). We hypothesized that the same approach could lead to a better generalization to real vehicle interiors. In a first approach, we applied this strategy to variations of the same scene under different illumination conditions, but realized that the learned invariances are not suitable for the transfer between synthetic and real. An example is provided in Fig. 5 (c) where we trained on the Kodiaq images from the SVIRO-Illumination dataset.
|
| 117 |
+
|
| 118 |
+

|
| 119 |
+
Figure 5: Reconstructions of unseen real data (a) from TICaM: (b) E-AE and (c) I-E-AE trained on Kodiaq SVIRO-Illumination, (d) E-AE, (e) I-E-AE, (f) II-E-AE and (g) II-E-TAE trained on our new dataset. A red (wrong) or green (correct) box highlights whether the classes are preserved.
|
| 120 |
+
|
| 121 |
+
We concluded that, for learning more general features by applying the PIRL, we needed input-target pairs where both images are of the same scene, but differ in the properties we want to become invariant to: the dominant background. To this end we created 5919 synthetic scenes where we placed humans, child and infant seats as if they would be sitting in a vehicle interior, but instead of a vehicle, the background was replaced by selecting randomly from a pool of available HDRI images. Each scene was rendered using 10 different backgrounds. Examples from the dataset are shown in Fig. 7 in the appendix. During training, we randomly select two images per scene and use one as input and the other as target, i.e. as defined in Eq. 2. When applied to real images, see Fig. 5 (e), the model better preserves the semantics of the real images: the model starts to reconstruct child seats and not people only, anymore. We also trained a model without the PIRL to show that the success is not due to the design choice of the dataset: in Fig. 5 (d) the model performs worse.
|
| 122 |
+
|
| 123 |
+
Finally, we extended this idea further with our novel PIRL loss formulation: instead of taking the same scene with a different background as target image, we randomly selected a different scene of the same class, e.g. if a person is sitting at the left seat position, we would take another image with a person on the left seat, potentially a different person with a different pose. This approach is formulated in Eq. 3. While this leads to a blurrier object reconstruction, which is expected because the autoencoder needs to learn an average class representation, the classes are preserved more robustly and the reconstructions look better than before, see Fig. 5 (f). Moreover, this additional randomization improves classification accuracy as discussed in Section 4.7 and in Section 5. A visualization of the different input-target pair combinations can be found in Fig. 2. The dataset can been downloaded from this link (Google Drive - Anonymous user) and it will be made publicly available.
|
| 124 |
+
|
| 125 |
+
# 4.6 STRUCTURE IN THE LATENT SPACE HELPS GENERALIZATION
|
| 126 |
+
|
| 127 |
+
The final improvement is based on the assumption that structure in the latent space should help the model performance. Class labels are included by formulating a triplet loss regularization to the latent space representation as defined by Eq. 4: images of the same class should be mapped closely together and images of different classes pushed away. The triplet loss induces a more meaningful $L ^ { \tilde { 2 } }$ -norm in the latent space (Dias Da Cruz et al., 2021) such that a k-nearest neighbor (KNN) classifier can be used in the next section. As the results of Fig. 5 (g) and in the appendix show, these final improvements, together with the previous changes, yield the semantically most correct reconstructions. In the appendix we show that due to the triplet loss the nearest neighbour of (g) makes sense and yields a clearer reconstruction. The triplet loss without the PIRL is not sufficient and in Section 5 we show that the II-PIRL loss is the driving force for the improved performance.
|
| 128 |
+
|
| 129 |
+

|
| 130 |
+
Figure 6: Comparison of the training performance distribution for each epoch over 250 epochs. II-E-TAE is compared against training the corresponding extractor from scratch or fine-tuning the layers after the features which are used by the extractor in our autoencoder approach.
|
| 131 |
+
|
| 132 |
+
# 4.7 KNN WITH TRIPLET LOSS OUT-PERFORMS FINE TUNED CLASSIFICATION MODELS
|
| 133 |
+
|
| 134 |
+
We investigated whether the qualitative improvements also transfer to a quantitative improvement. We took the most basic approach: we combined the E-TAE with a k-nearest neighbor classifier in the latent space and used our new dataset for training. We retrieve the latent space vectors for all flipped training images as well and used only a single image per scene (i.e. not all 10 variations).√ We choose $k \stackrel { - } { = } \sqrt { N } = 1 1 5$ , where $N$ is the size of the training data together with its flipped version (Jirina et al., 2011). The model should classify occupancy (empty, infant, child or adult) for each seat position and we used the same hyperparameters for all methods and variations thereof. We froze the same layers of the pre-trained models for fine-tuning the later layers in case of classification models or to train our autoencoder using it as an extractor. We evaluated the model performance after each epoch on the real TICaM images (normal and flipped images of the training and test splits) for both the autoencoder and the corresponding classification model. This provides a measure on the best possible result for each method, but is of course not a valid approach for model selection. We report in Fig. 6 the training results for seeds 1 to 10 and summarize the training performance by plotting the mean and standard deviation per epoch per method. Our approach converges more robustly and consistently to a better mean accuracy. For each experiment, we retrieve the best accuracy across all epochs and compute the mean, standard deviation and maximum of these values across all runs: these statistics are reported in Table 2. See the appendix for training from scratch and Densenet121 results. The model weights corresponding to the epochs selected by the previous heuristics were applied on the SVIRO dataset to verify whether the learned representations are universally applicable to other vehicle interiors. For SVIRO, we used the training images and excluded all images containing empty child seats or empty infant seats, treated everyday objects as background. The results show that our E-AE significantly outperforms the classification models across three different pre-trained models and across all datasets. A consistent improvement for the different modifications is achieved: I-E-TAE outperforms E-TAE and II-E-TAE outperforms I-E-TAE.
|
| 135 |
+
|
| 136 |
+
# 5 DISCUSSION AND LIMITATIONS
|
| 137 |
+
|
| 138 |
+
We want to highlight that most of the contribution to the success of our introduced model variations stems from the novel II variation of the PIRL loss. To this end we trained several types of classifiers in the latent space of different autoencoder model variations and report the results in Table 3. The II variation of the PIRL loss largely improves the classification accuracy compared to the I variation. Moreover, the performance is better compared to the triplet loss variation which uses the label information explcitily as a latent space constraints, compared to the implicit use by the II-PIRL.
|
| 139 |
+
|
| 140 |
+
Table 2: For each experiment, the best accuracy on real TICaM images across all epochs is taken and the mean, standard deviation and maximum of those values across all 10 runs is reported. The model weights achieving maximum performance per run on TiCAM are evaluated on SVIRO. Our approach outperforms the corresponding classification models significantly.
|
| 141 |
+
|
| 142 |
+
<table><tr><td></td><td></td><td colspan="2">TICaM</td><td colspan="2">SVIRO</td></tr><tr><td>Model</td><td>Variant</td><td>Mean</td><td>Max</td><td>Mean</td><td>Max</td></tr><tr><td>VGG-11</td><td>Pre-trained</td><td>75.5 ± 1.5</td><td>78.0</td><td>78.7± 2.9</td><td>84.0</td></tr><tr><td>Resnet-50</td><td>Pre-trained</td><td>78.1 ± 1.7</td><td>80.4</td><td>83.5 ± 2.7</td><td>88.1</td></tr><tr><td>VGG-11 Resnet-50</td><td>E-TAE E-TAE</td><td>76.7± 2.3 83.8 ± 1.3</td><td>81.5 86.0</td><td>78.6 ± 2.6 85.8± 2.4</td><td>82.3</td></tr><tr><td></td><td></td><td></td><td></td><td></td><td>89.1</td></tr><tr><td>VGG-11</td><td>I-E-TAE</td><td>79.7 ± 2.1</td><td>82.2</td><td>80.9 ± 4.0</td><td>85.6</td></tr><tr><td>Resnet-50</td><td>I-E-TAE</td><td>83.5 ± 1.3</td><td>85.6</td><td>89.2 ± 1.0</td><td>90.3</td></tr><tr><td>VGG-11</td><td>II-E-TAE</td><td>81.0± 0.6</td><td>82.0</td><td>79.1± 3.9</td><td>84.8</td></tr><tr><td>Resnet-50</td><td>II-E-TAE</td><td>83.7± 0.5</td><td>84.5</td><td>93.0± 0.8</td><td>94.1</td></tr></table>
|
| 143 |
+
|
| 144 |
+
Table 3: For each of the 10 experimental runs per method after 250 epochs (i.e. not the best model weights per training were selected) and using the VGG-11 extractor we trained different classifiers in the latent space: $\mathbf { k }$ -nearest neighbour (KNN), random forest (RForest) and support vector machine with a linear kernel (SVM). The results show that most of the contribution to the synthetic to real generalization is due to the novel II variation of the PIRL cost function.
|
| 145 |
+
|
| 146 |
+
<table><tr><td></td><td colspan="3">TICaM</td><td colspan="3">SVIRO</td></tr><tr><td>Variant</td><td>KNN</td><td>RForest</td><td>SVM</td><td>KNN</td><td>RForest</td><td>SVM</td></tr><tr><td>E-AE</td><td>17.1 ± 6.7</td><td>24.2 ± 4.1</td><td>40.6 ± 8.5</td><td>38.7 ± 2.9</td><td>58.2 ± 2.0</td><td>72.9 ± 2.3</td></tr><tr><td>I-E-AE</td><td>18.2 ± 7.3</td><td>42.4± 6.5</td><td>50.1± 3.7</td><td>61.0 ± 3.5</td><td>72.2 ± 2.5</td><td>73.8 ± 2.3</td></tr><tr><td>II-E-AE</td><td>73.2 ± 3.9</td><td>68.8 ± 5.7</td><td>66.9 ± 6.7</td><td>83.7 ±1.9</td><td>79.8± 2.7</td><td>81.4± 2.2</td></tr><tr><td>E-TAE</td><td>69.2 ± 3.4</td><td>66.4± 4.0</td><td>68.7 ± 2.2</td><td>76.2 ± 2.3</td><td>71.2 ± 2.5</td><td>75.3 ± 2.5</td></tr></table>
|
| 147 |
+
|
| 148 |
+
The II variation of the PIRL loss implicitly assumes that the classes are uni-modal, i.e. objects of the same class should be mapped onto a similar point in the latent space. This characteristic can either improve generalization or have a detrimental effect on the performance depending on the task to be solved. Under its current form there is no guarantee that, for example, facial landmarks or poses would be presereved. Nevertheless, we believe that extensions of our proposed loss, for example based on constraints (e.g. preservation of poses) could be an interesting direction for future work. It can be observed that our model is not perfect and sometimes struggles: e.g. in case an object (e.g. backpack) is located on the seat and for more complex human poses (e.g. people turning over). However, we believe that these problems are related to the training data: a more versatile synthetic dataset would probably improve the model performance on more challenging real images.
|
| 149 |
+
|
| 150 |
+
Finally, we show that improvements reported in this work are not limited to the application in the vehicle interior. To this end, we trained models using the same design choices on MNIST LeCun et al. (1998) and evaluate the generalization onto real digits De Campos et al. (2009) in Fig. 12 and Table 10 in the appendix: similar improvements by the different design choices can be observed.
|
| 151 |
+
|
| 152 |
+
# 6 CONCLUSION
|
| 153 |
+
|
| 154 |
+
We introduced an autoencoder model which uses a pre-trained classification model as a feature extractor. Our results showed that the resulting model produces superior reconstructions for synthetic to real generalization. However, we highlighted that design choices made on simple datasets do not necessarily transfer to visually more complex tasks. We performed a step-by-step investigation of additional model changes and showcased the improvements of each change. Although only a simple $\mathbf { k }$ -nearest neigbor classifier is being used in the latent space, our proposed autoencoder model outperforms consistently and more robustly all classification model counterparts.
|
| 155 |
+
|
| 156 |
+
# REPRODUCIBILITY STATEMENT
|
| 157 |
+
|
| 158 |
+
Reproducibility of our results is ensured by the code implementation provided in the supplementary material. Moreover, the model weights for all results reported in this work are available for download (anonymously): see the readme file in the supplementary material for download links. This readme file also explains how the code implementation can be used and how the results of the paper can be reproduced. The code implementation contains all the evaluation scripts necessary to get the results reported in this work. The appendix contains additional details about the training and models details as well as the datasets and data pre-processing part. For the latter, we also implemented preprocessing functions for all datasets used in our work together with links to the different datasets to download them. The datasets used in this work are all publicly available. The newly created dataset used in this work is also readily available for download. Lastly, the licenses of all datasets used are detailed in the readme file as well.
|
| 159 |
+
|
| 160 |
+
# CODE OF ETHICS
|
| 161 |
+
|
| 162 |
+
Our proposed improvements on reducing the performance gap between synthetic and real images could reduce the necessity for human labelling and improve privacy since fewer human subjects are needed for data recordings. It would reduce the financial investment and time investment of companies, institutions and individuals. The question arises whether the usage of a pre-trained extractor introduces biases in the sub-sequent model, whether better disentanglement properties can be achieved and how it is affected by the choice of the latter. The first part of this work investigates model design choices on a simpler dataset without human subjects. The second part investigates the application in the vehicle interior. According to the authors of the TICaM dataset, written consent of the human participants was obtained together with their signature. Regarding the application in the vehicle interior - insights and improvements for the transfer from synthetic to real could be used to cover important edge cases (e.g. accidents) by simulations such that security and safety could be improved. The licenses for all publicly available datasets used in this work is referenced as well.
|
| 163 |
+
|
| 164 |
+
# REFERENCES
|
| 165 |
+
|
| 166 |
+
Ilge Akkaya, Marcin Andrychowicz, Maciek Chociej, Mateusz Litwin, Bob McGrew, Arthur Petron, Alex Paino, Matthias Plappert, Glenn Powell, Raphael Ribas, et al. Solving rubik’s cube with a robot hand. arXiv preprint arXiv:1910.07113, 2019.
|
| 167 |
+
|
| 168 |
+
Vassileios Balntas, Edgar Riba, Daniel Ponsa, and Krystian Mikolajczyk. Learning local feature descriptors with triplets and shallow convolutional neural networks. In British Machine Vision Conference (BMVC), 2016.
|
| 169 |
+
|
| 170 |
+
Paul Bergmann, Sindy Lowe, Michael Fauser, David Sattlegger, and Carsten Steger. Improving un- ¨ supervised defect segmentation by applying structural similarity to autoencoders. arXiv preprint arXiv:1807.02011, 2018.
|
| 171 |
+
|
| 172 |
+
Alex Bewley, Jessica Rigley, Yuxuan Liu, Jeffrey Hawke, Richard Shen, Vinh-Dieu Lam, and Alex Kendall. Learning to drive from simulation without real world labels. In IEEE International Conference on Robotics and Automation (ICRA), 2019.
|
| 173 |
+
|
| 174 |
+
Alexandra Carlson, Katherine A Skinner, Ram Vasudevan, and Matthew Johnson-Roberson. Sensor transfer: Learning optimal sensor effect image augmentation for sim-to-real domain adaptation. IEEE Robotics and Automation Letters (RA-L), 2019.
|
| 175 |
+
|
| 176 |
+
Wuyang Chen, Zhiding Yu, Zhangyang Wang, and Animashree Anandkumar. Automated syntheticto-real generalization. In International Conference on Machine Learning (ICML, 2020.
|
| 177 |
+
|
| 178 |
+
Teofilo Em ´ ´ıdio De Campos, Bodla Rakesh Babu, Manik Varma, et al. Character recognition in natural images. Proceedings of the International Conference on Computer Vision Theory and Applications (VISAPP), 2009.
|
| 179 |
+
|
| 180 |
+
Steve Dias Da Cruz, Oliver Wasenmuller, Hans-Peter Beise, Thomas Stifter, and Didier Stricker. ¨ Sviro: Synthetic vehicle interior rear seat occupancy dataset and benchmark. In Proceedings of the IEEE/CVF Winter Conference on Applications of Computer Vision (WACV), 2020.
|
| 181 |
+
|
| 182 |
+
Steve Dias Da Cruz, Bertram Taetz, Thomas Stifter, and Didier Stricker. Illumination normalization by partially impossible encoder-decoder cost function. In Proceedings of the IEEE/CVF Winter Conference on Applications of Computer Vision (WACV), 2021.
|
| 183 |
+
|
| 184 |
+
Steve Dias Da Cruz, Bertram Taetz, Oliver Wasenmuller, Thomas Stifter, and Didier Stricker. Au- ¨ toencoder based inter-vehicle generalization for in-cabin occupant classification. In IEEE Intelligent Vehicles Symposium (IV), 2021.
|
| 185 |
+
|
| 186 |
+
Martin Engelcke, Adam R. Kosiorek, Oiwi Parker Jones, and Ingmar Posner. Genesis: Generative scene inference and sampling with object-centric latent representations. In International Conference on Learning Representations (ICLR), 2020.
|
| 187 |
+
|
| 188 |
+
Kuan Fang, Yunfei Bai, Stefan Hinterstoisser, Silvio Savarese, and Mrinal Kalakrishnan. Multi-task domain adaptation for deep learning of instance grasping from simulation. In IEEE International Conference on Robotics and Automation (ICRA), 2018.
|
| 189 |
+
|
| 190 |
+
Muhammad Waleed Gondal, Manuel Wuthrich, Djordje Miladinovic, Francesco Locatello, Martin Breidt, Valentin Volchkov, Joel Akpo, Olivier Bachem, Bernhard Scholkopf, and Stefan Bauer. ¨ On the transfer of inductive bias from simulation to the real world: a new disentanglement dataset. In Advances in Neural Information Processing Systems (NeurIPS), 2019.
|
| 191 |
+
|
| 192 |
+
Fang Gongfan. Pytorch ms-ssim. https://github.com/VainF/pytorch-msssim, 2019.
|
| 193 |
+
|
| 194 |
+
Irina Higgins, Loic Matthey, Arka Pal, Christopher Burgess, Xavier Glorot, Matthew Botvinick, Shakir Mohamed, and Alexander Lerchner. beta-vae: Learning basic visual concepts with a constrained variational framework. In International Conference on Learning Representations (ICLR), 2017.
|
| 195 |
+
|
| 196 |
+
Stefan Hinterstoisser, Vincent Lepetit, Paul Wohlhart, and Kurt Konolige. On pre-trained image features and synthetic images for deep learning. In Proceedings of the European Conference on Computer Vision (ECCV) Workshops, 2018.
|
| 197 |
+
|
| 198 |
+
Daniel Ho, Kanishka Rao, Zhuo Xu, Eric Jang, Mohi Khansari, and Yunfei Bai. Retinagan: An object-aware approach to sim-to-real transfer. arXiv preprint arXiv:2011.03148, 2020.
|
| 199 |
+
|
| 200 |
+
Elad Hoffer and Nir Ailon. Deep metric learning using triplet network. In International Workshop on Similarity-Based Pattern Recognition (SIMBAD), 2015.
|
| 201 |
+
|
| 202 |
+
Tadanobu Inoue, SLINEMOD ubhajit Choudhury, Giovanni De Magistris, and Sakyasingha Dasgupta. Transfer learning from synthetic to real images using variational autoencoders for precise position detection. In IEEE International Conference on Image Processing (ICIP), 2018.
|
| 203 |
+
|
| 204 |
+
Marcel Jirina, MJ Jirina, and K Funatsu. Classifiers based on inverted distances. In New fundamental technologies in data mining, volume 1, pp. 369–387. InTech, 2011.
|
| 205 |
+
|
| 206 |
+
Katie Kang, Suneel Belkhale, Gregory Kahn, Pieter Abbeel, and Sergey Levine. Generalization through simulation: Integrating simulated and real data into deep reinforcement learning for vision-based autonomous flight. In IEEE International Conference on Robotics and Automation (ICRA), 2019.
|
| 207 |
+
|
| 208 |
+
Jigyasa Singh Katrolia, Bruno Mirbach, Ahmed El-Sherif, Hartmut Feld, Jason Rambach, and Didier Stricker. Ticam: A time-of-flight in-car cabin monitoring dataset, 2021.
|
| 209 |
+
|
| 210 |
+
Hyunjik Kim and Andriy Mnih. Disentangling by factorising. In International Conference on Machine Learning (ICML), 2018.
|
| 211 |
+
|
| 212 |
+
Diederik P Kingma and Max Welling. Auto-encoding variational bayes. In International Conference on Learning Representations (ICLR), 2014.
|
| 213 |
+
|
| 214 |
+
Yann LeCun, Leon Bottou, Yoshua Bengio, and Patrick Haffner. Gradient-based learning applied to ´ document recognition. Proceedings of the IEEE, 1998.
|
| 215 |
+
|
| 216 |
+
Joonho Lee, Jemin Hwangbo, Lorenz Wellhausen, Vladlen Koltun, and Marco Hutter. Learning quadrupedal locomotion over challenging terrain. Science Robotics, 5(47), 2020.
|
| 217 |
+
|
| 218 |
+
Xingang Pan, Ping Luo, Jianping Shi, and Xiaoou Tang. Two at once: Enhancing learning and generalization capacities via ibn-net. In Proceedings of the European Conference on Computer Vision (ECCV), 2018.
|
| 219 |
+
|
| 220 |
+
Xingchao Peng, Ben Usman, Neela Kaushik, Judy Hoffman, Dequan Wang, and Kate Saenko. Visda: The visual domain adaptation challenge, 2017.
|
| 221 |
+
|
| 222 |
+
Kanishka Rao, Chris Harris, Alex Irpan, Sergey Levine, Julian Ibarz, and Mohi Khansari. Rlcyclegan: Reinforcement learning aware simulation-to-real. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), 2020.
|
| 223 |
+
|
| 224 |
+
David W. Romero and Mark Hoogendoorn. Co-attentive equivariant neural networks: Focusing equivariance on transformations co-occurring in data. In International Conference on Learning Representations (ICLR), 2020.
|
| 225 |
+
|
| 226 |
+
Josh Tobin, Rachel Fong, Alex Ray, Jonas Schneider, Wojciech Zaremba, and Pieter Abbeel. Domain randomization for transferring deep neural networks from simulation to the real world. In IEEE/RSJ International Conference on Intelligent Robots and Systems (IROS), 2017.
|
| 227 |
+
|
| 228 |
+
Jonathan Tremblay, Aayush Prakash, David Acuna, Mark Brophy, Varun Jampani, Cem Anil, Thang To, Eric Cameracci, Shaad Boochoon, and Stan Birchfield. Training deep networks with synthetic data: Bridging the reality gap by domain randomization. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR) Workshops, 2018.
|
| 229 |
+
|
| 230 |
+
Sjoerd van Steenkiste, Francesco Locatello, Jurgen Schmidhuber, and Olivier Bachem. Are disen- ¨ tangled representations helpful for abstract visual reasoning? In Advances in Neural Information Processing Systems (NeurIPS), 2019.
|
| 231 |
+
|
| 232 |
+
Xiangyu Yue, Yang Zhang, Sicheng Zhao, Alberto Sangiovanni-Vincentelli, Kurt Keutzer, and Boqing Gong. Domain randomization and pyramid consistency: Simulation-to-real generalization without accessing target domain data. In Proceedings of the IEEE/CVF International Conference on Computer Vision (ICCV), 2019.
|
| 233 |
+
|
| 234 |
+
Jingwei Zhang, Lei Tai, Peng Yun, Yufeng Xiong, Ming Liu, Joschka Boedecker, and Wolfram Burgard. Vr-goggles for robots: Real-to-sim domain adaptation for visual control. IEEE Robotics and Automation Letters (RA-L), 2019.
|
| 235 |
+
|
| 236 |
+
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/CVF Conference on Computer Vision and Pattern Recognition (CVPR), 2018.
|
| 237 |
+
|
| 238 |
+
Xi Zhang, Yanwei Fu, Shanshan Jiang, Leonid Sigal, and Gady Agam. Learning from synthetic data using a stacked multichannel autoencoder. In IEEE International Conference on Machine Learning and Applications (ICMLA), 2015.
|
| 239 |
+
|
| 240 |
+
Wenshuai Zhao, Jorge Pena Queralta, and Tomi Westerlund. Sim-to-real transfer in deep reinforce- ˜ ment learning for robotics: a survey. In IEEE Symposium Series on Computational Intelligence (SSCI), 2020.
|
| 241 |
+
|
| 242 |
+
# A APPENDIX
|
| 243 |
+
|
| 244 |
+
# A.1 DATASET DETAILS
|
| 245 |
+
|
| 246 |
+
If not specified otherwise, all images have been centre cropped and resized to 128 pixels.
|
| 247 |
+
|
| 248 |
+
# A.1.1 MPI3D
|
| 249 |
+
|
| 250 |
+
We used the synthetic realistic and toy images as well as the real images, but we restricted the dataset to use only large objects, since even for humans the small objects cannot always be distinguished reliably. The dataset can be downloaded from Github.
|
| 251 |
+
|
| 252 |
+
# A.1.2 SVIRO
|
| 253 |
+
|
| 254 |
+
We only used the grayscale training images from the SVIRO dataset. We considered everyday objects as background and removed all images containing empty child and infant seats. For the classification evaluation we used all the images from all the different vehicles, but we used training images only. Occupancy classification is performed on the entire image such that all three seats need to be classified simultaneously. Since four classes are available per seat (empty, infant seat, child seat and adult) this results in a total of $4 ^ { 3 } = 6 4$ classes. The dataset can be downloaded from their website.
|
| 255 |
+
|
| 256 |
+
# A.1.3 SVIRO-ILLUMINATION
|
| 257 |
+
|
| 258 |
+
For the classification evaluation we used all the training and test images from all the different vehicles. We used all the variations per scenes, i.e. not just a single variation per illumination variation. The dataset can be downloaded from their website.
|
| 259 |
+
|
| 260 |
+
# A.1.4 OUR NEWLY RELEASED DATASET
|
| 261 |
+
|
| 262 |
+
We created 2938 training and 2981 test sceneries where each scenery is rendered with 10 different backgrounds out of a pool of 450 backgrounds. The background and the corresponding illumination conditions were defined using high dynamic range images (HDRI). The latter were downloaded from https://hdrihaven.com/. Human models, child seats and infant seats were randomly placed as if they were located inside a vehicle, but no vehicle is visible. There are four possible classes for each seat position (empty, infant seat, child seat and adult) leading to a total of $4 ^ { 3 } = 6 4$ classes for the whole image. We created randomly 172 adults using http://www.makehumancommunity.org/ and we used 6 child seats and 7 infant seats which were textured using randomly one out of five textures. Since the dataset is synthetic, there are no consent and privacy concerns. We will release the dataset under the license CC BY-NC-SA 4.0. At the moment, it can be downloaded from this link (Google Drive - Anonymous user). Examples are visualized in Fig. 7. We noticed that a larger number of different human models increases the transferability to real images.
|
| 263 |
+
|
| 264 |
+
# A.1.5 TICAM
|
| 265 |
+
|
| 266 |
+
We used all training and test images and also flipped the images for the classification evaluation. This was done, because otherwise the class variability is quite low and there is a strong bias towards people sitting on the right driver seat. Moreover, the steering wheel would always be placed at the same right position. We also needed to perform some pre-processing to make the real TICaM images compatible with the synthetic images. First, we adapted the labels: we extracted the labels for the left and right seat from the filename. The file name is split at the character after which the third (right seat) and ninth (left seat) part is responsible for the class definition. If the latter was a 0 or contained an $o$ , we kept it as a 0. If it contained a $p$ , it was changed into a 3. We changed the value to 2 if it was one of the child seats s03, $s 1 3$ , $s 0 4$ , $s 1 4$ or the variation $g 0 0$ for the child seats $s 0 1$ , s11, s02, s12. In all other cases, it was transformed to a 1, i.e. for the child seats s05, s15, s06, $s 1 6$ and variations $g 0 1 g 1 1 g 1 0$ for s01, s11, s02, $s 1 2$ . Second, the illumination of the images was normalized using a histogram equalization. After that the images were cropped at height position 120 with height 300 and left position 106 with width 300. Finally, the images were resized to 128 pixels. The dataset can be downloaded from their website.
|
| 267 |
+
|
| 268 |
+

|
| 269 |
+
Figure 7: Examples of sceneries with different backgrounds from the newly generated dataset.
|
| 270 |
+
|
| 271 |
+
# A.2 TRAINING DETAILS
|
| 272 |
+
|
| 273 |
+
All our experiments were conducted using PyTorch 1.8. Pre-defined and models pre-trained on Imagenet were taken from torchvision 0.9.0.
|
| 274 |
+
|
| 275 |
+
We used the same hyperparameters for all training experiments and for all autoencoder and classification models respectively. We used the AdamW optimizer with a learning rate of $1 e - 4$ and weight decay of $1 e - 5$ . We used a batch size of 64 and the only augmentation performed was a random horizontal flip. All models were trained for 100 epochs on MPI3D and 250 epochs for the other datasets.
|
| 276 |
+
|
| 277 |
+
Both the extractor autoencoder and the classification models used the same layer for extracting the features from the pre-trained models. In both cases and for all pre-trained models we used layer level $- 3$ in our implementation: those features were used to fine-tune the rest of the pretrained classification model or to train from scratch our added autoencoder layers. In all cases, we interpolated the input images to be of size 224 and copied the single grayscale image channel twice along the channel dimension.
|
| 278 |
+
|
| 279 |
+
For the autoencoder training, we used the structural similarity index measure (SSIM) Bergmann et al. (2018) or the binary cross entropy (BCE) to measure the error between reconstruction and target image. We used PyTorch MS-SSIM Gongfan (2019) to compute the SSIM. In Eq. 5 we chose $\alpha = 1$ and $\beta = 1$ . We used a latent space dimension of 64 for all models trained on the vehicle interior and a latent space dimension of 10 for the MPI3D dataset. Further, we used the ReLU activation function. In case of a triplet loss, we used the swap parameter of Pytorch to make the negative mining more challenging Balntas et al. (2016). As a positive sample, we selected an image of a different scenery of the same class, i.e. the same objects are at the same seat position. For the negative sample we selected a scenery which differs in a single seat position and we did not allow sceneries with empty seats only. In case the partially impossible reconstruction loss was used, the target images for the positive and negative samples are chosen to be partially impossible as well.
|
| 280 |
+
|
| 281 |
+
# A.2.1 MODEL DETAILS
|
| 282 |
+
|
| 283 |
+
The autoencoder model architecture details are provided in Table 4, 6 and 7. Regarding the pretrained models, we used the output of the following layers to retrieve the extracted features. The notations is according to the torchvision model definitions:
|
| 284 |
+
|
| 285 |
+
VGG-11
|
| 286 |
+
(16): Conv2d(512, 512, kernel_size $=$ (3, 3), stride $=$ (1, 1), padding $=$ (1, 1))
|
| 287 |
+
(17): ReLU(inplace=True)
|
| 288 |
+
|
| 289 |
+
Resnet-50
|
| 290 |
+
|
| 291 |
+
(5): Bottleneck( (conv1): Conv2d(1024, 256, kernel_size $=$ (1, 1), stride $=$ (1, 1), bias=False) (bn1): BatchNorm2d(256, eps=1e-05, momentum $_ { 1 = 0 }$ .1, affine=True, track_running_stats=True) (conv2): Conv2d(256, 256, kernel_size $=$ (3, 3), stride $=$ (1, 1), padding $=$ (1, 1), bias=False) (bn2): BatchNorm2d(256, ep $\displaystyle { \cdot \mathsf { s } } = 1 \mathsf { e } - 0 5$ , momentum $_ { 1 = 0 }$ .1, affine $=$ True, track_running_stats=True) (conv3): Conv2d(256, 1024, kernel_size $=$ (1, 1), stride $=$ (1, 1), bias=False) (bn3): BatchNorm2d(1024, eps $= 1 \mathrm { e } - 0 5$ , momentum=0.1, affine $=$ True, track_running_stats $=$ True) (relu): ReLU(inplace $=$ True)
|
| 292 |
+
)
|
| 293 |
+
|
| 294 |
+
Densenet-121
|
| 295 |
+
|
| 296 |
+
(denselayer24): _DenseLayer( (norm1): BatchNorm2d(992, eps ${ } , = { }$ 1e-05, momentum $\iota { = } 0 \cdot 1$ , affine $: =$ True, track_running_stat ${ \tt S } =$ True) (relu1): ReLU(inplace $=$ True) (conv1): Conv2d(992, 128, kernel_size $=$ (1, 1), stride $=$ (1, 1), bias=False) (norm2): BatchNorm2d(128, eps=1e-05, momentum $\iota { = } 0 \cdot 1$ , affine=True, track_running_stats=True) (relu2): ReLU(inplace $=$ True) (conv2): Conv2d(128, 32, kernel_size $=$ (3, 3), strid $: =$ (1, 1), padding $\bf { \dot { \alpha } } =$ (1, 1), bias $=$ False)
|
| 297 |
+
)
|
| 298 |
+
|
| 299 |
+
Table 4: Model architecture for AE, VAE and $\beta$ -VAE on MPI3D
|
| 300 |
+
|
| 301 |
+
<table><tr><td>Encoder</td><td>Decoder</td></tr><tr><td>Input: 3 x 64 x 64</td><td>Input: 10</td></tr><tr><td>Conv, 4x4, 32, padding 1, stride 2 ReLU</td><td>FC,256, bias True ReLU</td></tr><tr><td>Conv, 4x4,32, padding 1, stride 2 ReLU</td><td>FC,1024,bias True ReLU</td></tr><tr><td>Conv, 4x4, 64, padding 1, stride 2 ReLU</td><td>ConvTranspose, 4x4,64, padding 1, stride 2 ReLU</td></tr><tr><td>Conv, 4x4, 64, padding 1, stride 2 ReLU</td><td>ConvTranspose, 4x4,32, padding 1, stride 2 ReLU</td></tr><tr><td>FC,256, bias True ReLU</td><td>ConvTranspose, 4x4, 32, padding 1, stride 2 ReLU</td></tr><tr><td>FC,10, bias True (twice in case of VAE)</td><td>ConvTranspose, 4x4, 3, padding 1, stride 2 Sigmoid</td></tr></table>
|
| 302 |
+
|
| 303 |
+
Table 5: Model architecture for FactorVAE on MPI3D. The model is exactly the same as the VAE model and uses the following discriminator.
|
| 304 |
+
|
| 305 |
+
<table><tr><td rowspan=1 colspan=1>Discriminator</td></tr><tr><td rowspan=1 colspan=1>Input: 10</td></tr><tr><td rowspan=1 colspan=1>FC,1000,bias TrueLeakyReLU(0.2)</td></tr><tr><td rowspan=1 colspan=1>FC,1000, bias TrueLeakyReLU(0.2)</td></tr><tr><td rowspan=1 colspan=1>FC,1000, bias TrueLeakyReLU(0.2)</td></tr><tr><td rowspan=1 colspan=1>FC,1000,bias TrueLeakyReLU(0.2)</td></tr><tr><td rowspan=1 colspan=1>FC,1000, bias TrueLeakyReLU(0.2)</td></tr><tr><td rowspan=1 colspan=1>FC, 2, bias True</td></tr></table>
|
| 306 |
+
|
| 307 |
+
Table 6: Model architecture for E-AE on MPI3D. The extractor is fixed during training.
|
| 308 |
+
|
| 309 |
+
<table><tr><td>Extractor + Summarizer + Encoder</td><td>Decoder</td></tr><tr><td>Input: 3 x 224 x 224</td><td>Input: 10</td></tr><tr><td>VGG-11 extractor after 7th Conv layer + ReLU Avgpool, 2x2, stride 2, padding 0</td><td>FC, 256, bias True ReLU</td></tr><tr><td>Conv, 4x4,256, padding 0, stride 1 ReLU</td><td>FC,1024,bias True ReLU</td></tr><tr><td>FC,256,bias True ReLU</td><td>ConvTranspose, 4x4, 64, padding 1, stride 2 ReLU</td></tr><tr><td>FC,10, bias True</td><td>ConvTranspose, 4x4,32, padding 1, stride 2 ReLU</td></tr><tr><td></td><td>ConvTranspose, 4x4, 32, padding 1, stride 2 ReLU</td></tr><tr><td></td><td>ConvTranspose,4x4,3, padding 1, stride 2 Sigmoid</td></tr></table>
|
| 310 |
+
|
| 311 |
+
Table 7: Model architecture for E-AE on SVIRO, SVIRO-Illumination and TICaM. C is the channel dimension which is 1 for all datasets. The extractor is fixed during training.
|
| 312 |
+
|
| 313 |
+
<table><tr><td>Extractor+ Summarizer+ Encoder</td><td>Decoder</td></tr><tr><td>Input: C x 224 x 224</td><td>Input: 64</td></tr><tr><td>VGG-11 extractor after 7th Conv layer + ReLU Avgpool, 2x2, stride 2, padding 0</td><td>FC, 256, bias True ReLU</td></tr><tr><td>Conv, 4x4, 256, padding 0, stride 1 ReLU</td><td>FC, 4096,bias True ReLU</td></tr><tr><td>FC,256, bias True ReLU</td><td>ConvTranspose, 4x4, 64, padding 1, stride 2 ReLU</td></tr><tr><td>FC, 64, bias True</td><td>ConvTranspose, 4x4,32, padding 1, stride 2 ReLU</td></tr><tr><td></td><td>ConvTranspose, 4x4,32,padding 1, stride 2 ReLU</td></tr><tr><td></td><td>ConvTranspose, 4x4, C, padding 1, stride 2 Sigmoid</td></tr></table>
|
| 314 |
+
|
| 315 |
+

|
| 316 |
+
Figure 8: t-SNE projection of the 10 dimensional latent space representation of the toy training (blue circle) together with the real (orange cross) images. Autoencoder (AE), $\beta$ Variational Autoencoder ( $\beta$ -VAE), FactorVAE and Extractor Autoencoder (E-AE). When trained on toy images, our extractor approach performs still best although the synthetic-real distributions are not as overlapped as if trained on realistic images.
|
| 317 |
+
|
| 318 |
+
Table 8: We report the L1, SSIM and LIPIPS (Zhang et al., 2018) norm between the reconstructions of the real images (unknown) and the corresponding synthetic training images (realistic or toy). We report the mean of the norms across the entire reduced dataset: for SSIM larger $\uparrow$ and for the others smaller $\downarrow$ is better. E-AE performs best. Some models used SSIM, others BCE during training.
|
| 319 |
+
|
| 320 |
+
<table><tr><td>Trained on</td><td>Model</td><td>Variant</td><td>L1↓</td><td>SSIM↑</td><td>LPIPS↓</td></tr><tr><td>Toy</td><td>AE</td><td>BCE</td><td>768</td><td>0.559</td><td>0.412</td></tr><tr><td>Toy</td><td>AE</td><td>SSIM</td><td>932</td><td>0.558</td><td>0.347</td></tr><tr><td>Toy</td><td>E-AE (ours)</td><td>BCE</td><td>291</td><td>0.896</td><td>0.095</td></tr><tr><td>Toy</td><td>E-AE (ours)</td><td>SSIM</td><td>177</td><td>0.899</td><td>0.103</td></tr><tr><td>Toy</td><td>VAE</td><td>BCE</td><td>659</td><td>0.497</td><td>0.338</td></tr><tr><td>Toy</td><td>β-VAE</td><td>BCE,β= 4</td><td>710</td><td>0.527</td><td>0.311</td></tr><tr><td>Toy</td><td>β-VAE</td><td>BCE,β=8</td><td>406</td><td>0.709</td><td>0.258</td></tr><tr><td>Toy</td><td>FactorVAE</td><td>BCE,=10</td><td>521</td><td>0.660</td><td>0.262</td></tr><tr><td>Toy</td><td>FactorVAE</td><td>BCE, = 30</td><td>447</td><td>0.710</td><td>0.344</td></tr><tr><td>Toy</td><td>FactorVAE</td><td>BCE,γ = 50</td><td>430</td><td>0.712</td><td>0.221</td></tr><tr><td>Realistic</td><td>AE</td><td>BCE</td><td>373</td><td>0.841</td><td>0.211</td></tr><tr><td>Realistic</td><td>AE</td><td>SSIM</td><td>568</td><td>0.832</td><td>0.195</td></tr><tr><td>Realistic</td><td>E-AE (ours)</td><td>BCE</td><td>220</td><td>0.917</td><td></td></tr><tr><td>Realistic</td><td>E-AE (ours)</td><td>SSIM</td><td>251</td><td>0.921</td><td>0.071</td></tr><tr><td>Realistic</td><td>VAE</td><td>BCE</td><td>482</td><td>0.740</td><td>0.081</td></tr><tr><td>Realistic</td><td>β-VAE</td><td>BCE,β= 4</td><td>372</td><td>0.810</td><td>0.197</td></tr><tr><td>Realistic</td><td>β-VAE</td><td>BCE,β=8</td><td>384</td><td>0.794</td><td>0.176</td></tr><tr><td></td><td>FactorVAE</td><td>BCE,γ= 10</td><td>218</td><td>0.880</td><td>0.189</td></tr><tr><td>Realistic</td><td>FactorVAE</td><td>BCE, = 30</td><td>244</td><td>0.862</td><td>0.151</td></tr><tr><td>Realistic</td><td></td><td></td><td>391</td><td></td><td>0.161</td></tr><tr><td>Realistic</td><td>FactorVAE</td><td>BCE,γ = 50</td><td></td><td>0.779</td><td>0.164</td></tr></table>
|
| 321 |
+
|
| 322 |
+

|
| 323 |
+
(a) Reconstruction of training data when being trained on realistic data.
|
| 324 |
+
|
| 325 |
+

|
| 326 |
+
Figure 9: Reconstruction of realistic and toy training data for different autoencoders: Autoencoder (AE), $\beta$ Variational Autoencoder ( $\beta$ -VAE), FactorVAE (F-VAE) and Extractor Autoencoder (E-AE).
|
| 327 |
+
|
| 328 |
+
(b) Reconstruction of training data when being trained on toy data.
|
| 329 |
+
|
| 330 |
+
Table 9: For each experiment, the best performance (in percentage) on real vehicle interior images (TICaM) across all epochs is taken and then the mean and maximum of those values across all 10 runs is reported. For the same backbone model extractor, our approach outperforms the vanilla classification models significantly. The model weights achieving the maximum performance per run are also evaluated on SVIRO where they perform better as well.
|
| 331 |
+
|
| 332 |
+
<table><tr><td></td><td>Dataset</td><td colspan="2">TICaM</td><td colspan="2">SVIRO</td></tr><tr><td></td><td>Dataset size</td><td>13356</td><td></td><td>11959</td><td></td></tr><tr><td>Model</td><td>Variant</td><td>Mean</td><td>Max</td><td>Mean</td><td>Max</td></tr><tr><td>VGG-11</td><td>Scratch</td><td>58.5 ± 4.0</td><td>64.6</td><td>65.6 ± 5.4</td><td>72.7</td></tr><tr><td>Resnet-50</td><td>Scratch</td><td>53.3 ± 3.5</td><td>60.4</td><td>56.4 ± 2.6</td><td>59.3</td></tr><tr><td>Densenet-121</td><td>Scratch</td><td>56.3 ± 5.5</td><td>62.1</td><td>68.8± 2.4</td><td>74.9</td></tr><tr><td>VGG-11</td><td>Pre-trained</td><td>75.5 ± 1.5</td><td>78.0</td><td>78.7± 2.9</td><td>84.0</td></tr><tr><td>Resnet-50</td><td>Pre-trained</td><td>78.1 ± 1.7</td><td>80.4</td><td>83.5 ± 2.7</td><td>88.1</td></tr><tr><td>Densenet-121</td><td>Pre-trained</td><td>72.2 ± 4.2</td><td>77.4</td><td>85.0 ± 2.3</td><td>88.0</td></tr><tr><td>VGG-11</td><td>E-TAE</td><td>76.7 ± 2.3</td><td>81.5</td><td>78.6 ± 2.6</td><td>82.3</td></tr><tr><td>Resnet-50</td><td>E-TAE</td><td>83.8 ± 1.3</td><td>86.0</td><td>85.8 ± 2.4</td><td>89.1</td></tr><tr><td>Densenet-121</td><td>E-TAE</td><td>78.5 ± 2.4</td><td>81.8</td><td>86.7 ± 1.3</td><td>88.2</td></tr><tr><td>VGG-11</td><td>I-E-TAE</td><td>79.7 ± 2.1</td><td>82.2</td><td>80.9 ± 4.0</td><td>85.6</td></tr><tr><td>Resnet-50</td><td>I-E-TAE</td><td>83.5 ± 1.3</td><td>85.6</td><td>89.2 ± 1.0</td><td>90.3</td></tr><tr><td>Densenet-121</td><td>I-E-TAE</td><td>77.2 ± 1.7</td><td>79.3</td><td>90.4 ± 1.3</td><td>92.1</td></tr><tr><td>VGG-11</td><td>II-E-TAE</td><td>81.0 ± 0.6</td><td>82.0</td><td>79.1 ± 3.9</td><td>84.8</td></tr><tr><td>Resnet-50</td><td>II-E-TAE</td><td>83.7 ± 0.5</td><td>84.5</td><td>93.0 ± 0.8</td><td>94.1</td></tr><tr><td>Densenet-121</td><td>II-E-TAE</td><td>79.3 ± 1.3</td><td>81.5</td><td>89.9 ± 1.8</td><td>92.3</td></tr></table>
|
| 333 |
+
|
| 334 |
+

|
| 335 |
+
Figure 10: Reconstruction results of unseen real data (a) from the TICaM dataset: (b) E-AE Trained on Tesla SVIRO, (c) E-AE Trained on Kodiaq SVIRO-Illumination , (d) I-E-AE Trained on Kodiaq SVIRO-Illumination , (e) E-AE, (f) I-E-AE, (g) II-E-AE, (h) E-TAE, (i) I-E-TAE, (j) II-E-TAE and (k) Nearest neighbour of (j). Examples (e)-(k) are all trained on our new dataset. A red (wrong) or green (correct) box highlights whether the semantics are preserved by the reconstruction.
|
| 336 |
+
|
| 337 |
+
Table 10: Different model architecture variations trained on MNIST. Then different classifiers were trained on the latent space representation of the training data and evaluated on real images of digits. Models were trained for 20 epochs using a latent dimension of 64 and MSE reconstruction loss. See Fig. 12 for the corresponding reconstruction results and input images.
|
| 338 |
+
|
| 339 |
+
<table><tr><td>Model</td><td>KNN</td><td>RForest</td><td>SVM</td></tr><tr><td>AE</td><td>15.7</td><td>12.5</td><td>11.6</td></tr><tr><td>TAE</td><td>11.1</td><td>11.6</td><td>8.4</td></tr><tr><td>II-AE II-TAE</td><td>27.8 21.8</td><td>20.2 17.9</td><td>23.6 23.9</td></tr><tr><td>E-AE E-TAE</td><td>27.3</td><td>23.1</td><td>26.5</td></tr><tr><td></td><td>26.1</td><td>19.1</td><td>23.3</td></tr><tr><td>II-E-AE</td><td>65.</td><td>61.9</td><td>65.6</td></tr><tr><td></td><td></td><td></td><td></td></tr><tr><td>II-E-TAE</td><td>64.1</td><td>63.7</td><td>63.7</td></tr></table>
|
| 340 |
+
|
| 341 |
+

|
| 342 |
+
Figure 11: Comparison of the training performance distribution for each epoch over 250 epochs. II-E-TAE is compared against training the corresponding extractor from scratch or fine-tuning the layers after the features which are used by the extractor in our autoencoder approach.
|
| 343 |
+
|
| 344 |
+

|
| 345 |
+
Figure 12: Reconstruction of real input images of digits by models trained on MNIST. Similar to the vehicle interior, the II-PIRL loss provides the best class preserving reconstructions. The latter is supported by the quantiative results in Table 10.
|
md/dev/ayPPc0SyLv1/ayPPc0SyLv1.md
ADDED
|
@@ -0,0 +1,394 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# DO WE REALLY NEED COMPLICATED MODEL ARCHITECTURES FOR TEMPORAL NETWORKS?
|
| 2 |
+
|
| 3 |
+
Weilin Cong Penn State weilin@psu.edu
|
| 4 |
+
|
| 5 |
+
Si Zhang
|
| 6 |
+
Meta
|
| 7 |
+
sizhang@meta.com
|
| 8 |
+
|
| 9 |
+
Jian Kang University of Illinois at Urbana-Champaign jiank2@illinois.edu
|
| 10 |
+
|
| 11 |
+
# Baichuan Yuan & Hao Wu & Xin Zhou
|
| 12 |
+
|
| 13 |
+
Meta {bcyuan,haowu1,markzhou}@meta.com
|
| 14 |
+
|
| 15 |
+
Hanghang Tong
|
| 16 |
+
University of Illinois at Urbana-Champaign
|
| 17 |
+
htong@illinois.edu
|
| 18 |
+
|
| 19 |
+
Mehrdad MahdaviPenn Statemzm616@psu.edu
|
| 20 |
+
|
| 21 |
+
# ABSTRACT
|
| 22 |
+
|
| 23 |
+
Recurrent neural network (RNN) and self-attention mechanism (SAM) are the de facto methods to extract spatial-temporal information for temporal graph learning. Interestingly, we found that although both RNN and SAM could lead to a good performance, in practice neither of them is always necessary. In this paper, we propose GraphMixer, a conceptually and technically simple architecture that consists of three components: $\textcircled{1}$ a link-encoder that is only based on multi-layer perceptrons (MLP) to summarize the information from temporal links, $\textcircled{2}$ a node-encoder that is only based on neighbor mean-pooling to summarize node information, and $\textcircled{3}$ an MLP-based link classifier that performs link prediction based on the outputs of the encoders. Despite its simplicity, GraphMixer attains an outstanding performance on temporal link prediction benchmarks with faster convergence and better generalization performance. These results motivate us to rethink the importance of simpler model architecture. [Code].
|
| 24 |
+
|
| 25 |
+
# 1 INTRODUCTION
|
| 26 |
+
|
| 27 |
+
In recent years, temporal graph learning has been recognized as an important machine learning problem and has become the cornerstone behind a wealth of high-impact applications Yu et al. (2018); Bui et al. (2021); Kazemi et al. (2020); Zhou et al. (2020); Cong et al. (2021b). Temporal link prediction is one of the classic downstream tasks which focuses on predicting the future interactions among nodes. For example, in an ads ranking system, the user-ad clicks can be modeled as a temporal bipartite graph whose nodes represent users and ads, and links are associated with timestamps indicating when users click ads. Link prediction between them can be used to predict whether a user will click an ad. Designing graph learning models that can capture node evolutionary patterns and accurately predict future links is a crucial direction for many real-world recommender systems.
|
| 28 |
+
|
| 29 |
+
In temporal graph learning, recurrent neural network (RNN) and self-attention mechanism (SAM) have become the de facto standard for temporal graph learning Kumar et al. (2019); Sankar et al. (2020); Xu et al. (2020); Rossi et al. (2020); Wang et al. (2020), and the majority of the existing works focus on designing neural architectures with one of them and additional components to learn representations from raw data. Although powerful, these methods are conceptually and technically complicated with advanced model architectures. It is non-trivial to understand which parts of the model design truly contribute to its success, and whether these components are indispensable. Thus, in this paper, we aim at answering the following two questions:
|
| 30 |
+
|
| 31 |
+
Q1: Are RNN and SAM always indispensable for temporal graph learning? To answer this question, we propose GraphMixer, a simple architecture based entirely on the multi-layer perceptrons (MLPs) and neighbor mean-pooling, which does not utilize any RNN or SAM in its model architecture (Section 3). Despite its simplicity, GraphMixer could obtain outstanding results when comparing it
|
| 32 |
+
|
| 33 |
+
$$
|
| 34 |
+
\begin{array} { l l } { { \mathrm { n o w } { \displaystyle \frac { t _ { 0 } \ t _ { 1 } \ t _ { 2 } \ t _ { 3 } \ t _ { 4 } \quad t _ { 4 } \quad t _ { 5 } \quad t _ { 6 } } { \ \longrightarrow \ ( \mathrm { p a s t } ) } } } } & { { \ \mathrm { N o d e ~ f e a t u r e s } \ \textcircled { \bigcirc _ { 1 } } } } \\ { { \mathrm { e m p o r a l ~ g r a p h ~ ( \bigcirc _ { 1 } ) } { \frac { t _ { 1 } , t _ { 5 } } { \ \mathrm { f } _ { 3 } , t _ { 4 } } } \overbrace { { \bigcirc _ { 2 } } ^ { \mathrm { ( \bigoplus _ { 3 } ) } } \big _ { \big < _ { 3 } } ^ { \mathrm { ( \bigoplus _ { 4 } ) } } { \big > } ^ { \mathrm { ( \bigoplus _ { 6 } ) } } { \big _ { \qquad t _ { 6 } } \ \big ( \bigcirc _ { 5 } \big ) } } } } & { { \ \mathrm { L i n k ~ f e a t u r e s } \ \mathrm { \Gamma } \big ( \bigcirc _ { 1 } \big ) \ t _ { 1 } , t _ { 5 } \ \big ( \bigcirc _ { 2 } ^ { \mathrm { ( \ominus _ { 3 } ) } } \ \mathrm { \ { x } } _ { 1 , 2 } ^ { \mathrm { l i n k } } ( t _ { 1 } ) , \ \mathrm { x } _ { 1 , 2 } ^ { \mathrm { l i n k } } ( t _ { 5 } ) } } \end{array}
|
| 35 |
+
$$
|
| 36 |
+
|
| 37 |
+
Figure 1: (Left) Temporal graph with nodes $v _ { 1 } , \ldots , v _ { 5 }$ , per-link timestamps $t _ { 1 } , \ldots , t _ { 6 }$ indicate when two nodes interact. For example, $v _ { 1 } , v _ { 2 }$ interact at $t _ { 1 } , t _ { 5 }$ . (Right) Each node has its node features (e.g., $\mathbf { x } _ { 1 } ^ { \mathrm { n o d e } }$ for $v _ { 1 }$ ) and each temporal link has its link features (e.g., $\mathbf { x } _ { 1 , 2 } ^ { \mathrm { l i n k } } ( t _ { 1 } ) , \mathbf { x } _ { 1 , 2 } ^ { \mathrm { l i n k } } ( t _ { 5 } )$ are link features between $v _ { 1 } , v _ { 2 }$ at $t _ { 1 } , t _ { 5 } )$ . For scenarios without node or link features, we use all-zero vectors instead.
|
| 38 |
+
|
| 39 |
+
against baselines that are equipped with the RNNs and SAM. In practice, it achieves state-of-the-art performance in terms of different evaluation metrics (e.g., average precision, AUC, Recall $@ \mathrm { K }$ , and MRR) on real-world temporal graph datasets, with the even smaller number of model parameters and hyper-parameters, and a conceptually simpler input structure and model architecture (Section 4).
|
| 40 |
+
|
| 41 |
+
Q2: What are the key factors that lead to the success of GraphMixer? We identify three key factors that contribute to the success of GraphMixer: $\textcircled{1}$ The simplicity of GraphMixer’s input data and neural architecture. Different from most deep learning methods that focus on designing conceptually complicated data preparation techniques and technically complicated neural architectures, we choose to simplifying the neural architecture and utilize a conceptually simpler data as input. Both of which could lead to a better model performance and better generalization (Section 4.4). $\textcircled{2} A$ time-encoding function that encodes any timestamp as an easily distinguishable input vector for GraphMixer. Different from most of the existing methods that propose to learn the time-encoding function from the raw input data, our time-encoding function utilizes conceptually simple features and is fixed during training. Interestingly, we show that our fixed time-encoding function is more preferred than the trainable version (used by most previous studies), and could lead to a smoother optimization landscape, a faster convergence speed, and a better generalization (Section 4.2); $\textcircled{3} A$ link-encoder that could better distinguish temporal sequences. Different from most existing methods that summarize sequences using SAM, our encoder module is entirely based on MLPs. Interestingly, our encoder can distinguish temporal sequences that cannot be distinguished by SAM, and it could generalize better due to its simpler neural architecture and lower model complexity (Section 4.3).
|
| 42 |
+
|
| 43 |
+
To this end, we summarize our contributions as follows: $\textcircled{1}$ We propose a conceptually and technically simple architecture GraphMixer; $\textcircled{2}$ Even without RNN and SAM, GraphMixer not only outperforms all baselines but also enjoys a faster convergence and better generalization ability; $\textcircled{3}$ Extensive study identifies three factors that contribute to the success of GraphMixer. $\textcircled{4}$ Our results could motivate future research to rethink the importance of the conceptually and technically simpler method.
|
| 44 |
+
|
| 45 |
+
# 2 PRELIMINARY AND EXISTING WORKS
|
| 46 |
+
|
| 47 |
+
Preliminary. Figure 1 is an illustration on the temporal graph. Our goal is to predict whether two nodes are connected at a specific timestamp $t _ { 0 }$ based on all the available temporal graph information happened before that timestamp. For example, to predict whether $v _ { 1 } , v _ { 2 }$ are connected at $t _ { 0 }$ , we only have access to the graph structure, node features, and link features with timestamps from $t _ { 1 }$ to $t _ { 6 }$ .
|
| 48 |
+
|
| 49 |
+
Related works. Most of the temporal graph learning methods are conceptually and technically complicated with advanced neural architectures. It is non-trivial to fully understand the algorithm details without looking into their implementations. Therefore, we select the four most representative and most closely-related methods to introduce and compare them in more details.
|
| 50 |
+
|
| 51 |
+
• JODIE Kumar et al. (2019) is a RNN-based method. Let us denote ${ \bf x } _ { i } ( t )$ as the embedding of
|
| 52 |
+
nodthat $v _ { i }$ at time latest in $t$ , e ${ \bf x } _ { i j } ^ { \mathrm { l i n k } } ( t )$ as the link feature between h other node. JODIE pre- $v _ { i } , v _ { j }$ at time ses and $t$ , and updat $m _ { i }$ as the timestamphe representation $v _ { i }$ of each node via RNNs (is it just one RNN or multiple RNNs). More specifically, when an interaction between $v _ { i } , v _ { j }$ happens at time $t$ , JODIE updates the temporal embedding using RNN
|
| 53 |
+
by $\begin{array} { r } { \mathbf { x } _ { i } ( t ) = \mathbb { R } \mathrm { N N } \left( \mathbf { x } _ { i } ( m _ { i } ) , \mathbf { x } _ { j } ( \bar { m } _ { j } ) , \mathbf { x } _ { i j } ^ { \mathrm { l i n k } } ( t ) , t - m _ { i } \right) . } \end{array}$ . Then, the dynamic embedding of node $v _ { i }$ at time $t _ { 0 }$ is computed by $\mathbf { h } _ { i } ( t _ { 0 } ) = ( 1 + \bar { ( t _ { 0 } - m _ { i } ) } \mathbf { w } ) \cdot \mathbf { x } _ { i } ( m _ { i } ) .$ . Finally, the prediction on any node pair at time $t _ { 0 }$ is computed by $\mathbb { M L P } \left( \left[ \mathbf { h } _ { i } ( t _ { 0 } ) \mathbf { \Lambda } | | \mathbf { h } _ { j } ( t _ { 0 } ) \right] \right)$ , where $[ \cdot | | \cdot ]$ is the concatenate operation and $\mathtt { M L P } ( \mathbf { x } )$ is applying 2-layer MLP on $\mathbf { x }$ .
|
| 54 |
+
|
| 55 |
+
• DySAT Sankar et al. (2020) is a SAM-based method. DySAT requires pre-processing the temporal graph into multiple snapshot graphs by first splitting all timestamps into multiple time-slots, then merging all edges in each time-slot. Let $\mathcal { G } _ { t } ( \nu , \mathcal { E } _ { t } )$ denote the $t$ -th snapshot graph. To capture spatial information, DySAT first applies Graph Attention Network (GAT) Velickovi ˇ c et al. ´ (2018) on each snapshot graph $\mathcal { G } _ { t }$ independently by $\mathbf { X } ( t ) = \ G \mathbb { A } \mathrm { T } ( \mathcal { G } _ { t } )$ . Then, to capture of temporal information for each node, Transformer is applied to $\mathbf { x } _ { i } ( t ) \dot { = } [ \dot { \mathbf { X } } ( t ) ] _ { i }$ at different timestamps to capture the temporal information by $\mathbf { h } _ { i } ( t _ { k } ) , \ldots \mathbf { h } _ { i } ( t _ { 0 } ) =$ Transformer $\big ( \mathbf { x } _ { i } ( t _ { k } ) , \ldots , \mathbf { x } _ { i } ( \dot { t } _ { 0 } ) \big )$ . Finally, the prediction on any node pair at time $t _ { 0 }$ is computed by $\mathbb { M L P } \big ( [ \mathbf { h } _ { i } ( t _ { 0 } ) | | \mathbf { h } _ { j } ( t _ { 0 } ) ] \big )$ .
|
| 56 |
+
|
| 57 |
+
• TGAT Xu et al. (2020) is a SAM-based method that could capture the spatial and temporal information simultaneously. TGAT first generates the time augmented feature of node $i$ at time $t$ by concatenating the raw feature $\mathbf { x } _ { i }$ with a trainable time encoding ${ \bf z } ( t )$ of time $t$ , i.e., $\mathbf { x } _ { i } ( t ) = [ \mathbf { x } _ { i } \mid \mid \mathbf { z } ( t ) ]$ and ${ \bf z } ( t ) = \cos ( t { \bf w } + { \bf b } )$ . Then, SAM is applied to the time augmented features and produces node representation $\mathbf { \dot { h } } _ { i } ( t _ { 0 } ) = \operatorname { S A M } \left( \mathbf { x } _ { i } ( t _ { 0 } ) , \{ \bar { \mathbf { x } _ { u } } ( h _ { u } ) \mid u \in \mathcal { N } _ { t _ { 0 } } ( i ) \bar \} \right)$ , where $\mathcal { N } _ { t _ { 0 } } ( i )$ denotes the neighbors of node $i$ at time $t _ { 0 }$ and $h _ { u }$ denotes the timestamp of the latest interaction of node $u$ . Finally, the prediction on any node pair at time $t _ { 0 }$ is computed by $\mathbb { M L P } \left( \left[ \mathbf { h } _ { i } ( t _ { 0 } ) \mathbf { \Lambda } | | \mathbf { h } _ { j } ( t _ { 0 } ) \right] \right)$ . TGN Rossi et al. (2020) is a mixture of RNN- and SAM-based method. In practice, TGN first captures the temporal information using RNN (similarly to JODIE), and then applies graph attention convolution to capture the spatial and temporal information jointly (similarly to TGAT).
|
| 58 |
+
|
| 59 |
+
Besides, we also consider the following temporal graph learning methods as baselines. These methods could be thought of as an extension on top of the above four most representative methods, but with the underlying idea behind the model design much more conceptually complicated. CAWs Wang et al. (2020) is a mixer of RNN- and SAM- based method that proposes to represent network dynamics by extracting temporal network motifs using temporal random walks. CAWs replaces node identities with the hitting counts of the nodes based on a set of sampled walks to establish the correlation between motifs. Then, the extracted motifs are fed into RNNs to encode each walk as a representation, and use SAM to aggregate the representations of multi-walks into a single vector for downstream tasks. TGSRec Fan et al. (2021) is a SAM-based method that proposes to unify sequential patterns and temporal collaborative signals to improve the quality of recommendation. To achieve this goal, they propose to advance the SAM by adopting novel collaborative attention, such that SAM can simultaneously capture collaborative signals from both users and items, as well as consider temporal dynamics inside sequential patterns. APAN Wang et al. (2021b) is a RNN-based method that proposes to decouple model inference and graph computation to alleviate the damage of the heavy graph query operation to the speed of model inference. More related works are deferred to Appendix B.
|
| 60 |
+
|
| 61 |
+
# 3 GRAPHMIXER: A CONCEPTUALLY AND TECHNICALLY SIMPLE METHOD
|
| 62 |
+
|
| 63 |
+
In this section, we first introduce the neural architecture of GraphMixer in Section 3.1 then explicitly highlight its difference to baseline methods in Section 3.2.
|
| 64 |
+
|
| 65 |
+
3.1 DETAILS ON GRAPHMIXER: NEURAL ARCHITECTURE AND INPUT DATA
|
| 66 |
+
|
| 67 |
+
GraphMixer has three modules: $\textcircled{1}$ link-encoder is designed to summarize the information from temporal links (e.g., link timestamps and link features); $\textcircled{2}$ node-encoder is designed to summarize the information from nodes (e.g., node features and node identity); $\textcircled{3}$ link classifier predicts whether a link exists based on the output of the aforementioned two encoders.
|
| 68 |
+
|
| 69 |
+
Link-encoder. The link-encoder is designed to summarize the temporal link information associated with each node sorted by timestamps, where temporal link information is referring to the timestamp and features of each link. For example in Figure 1, the temporal link information for node $v _ { 2 }$ is $\{ ( t _ { 1 } , \mathbf { x } _ { 1 , 2 } ^ { \mathrm { l i n k } } ( t _ { 1 } ) ) , ( t _ { 3 } , \mathbf { x } _ { 2 , 4 } ^ { \mathrm { l i n k } } ( t _ { 3 } ) ) , ( t _ { 4 } , \mathbf { \hat { x } } _ { 2 , 4 } ^ { \mathrm { l i n k } } ( t _ { 4 } ) ) ^ { \sim } ( t _ { 5 } , \mathbf { x } _ { 1 , 2 } ^ { \mathrm { l i n k } } ( t _ { 5 } ) ) \}$ and for node $v _ { 5 }$ is $\{ ( t _ { 2 } , \mathbf { x } _ { 3 , 5 } ^ { \mathrm { l i n k } } ( t _ { 2 } ) ) , ( t _ { 6 } , \dot { \mathbf { x } } _ { 4 , 5 } ^ { \mathrm { l i n k } } ( t _ { 6 } ) ) \}$ . In practice, we only keep the top $K$ most recent temporal link information, where $K$ is a dataset dependent hyper-parameter. If multiple links have the same timestamps, we simply keep them the same order as the input raw data. To summarize temporal link information, our link-encoder should have the ability to distinguish different timestamps (achieved by our time-encoding function) and different temporal link information (achieved by the Mixer module).
|
| 70 |
+
|
| 71 |
+
• Time-enfunction $\cos ( t \omega )$ unction. To distinguish d, which utilizes features $\omega = \{ \alpha ^ { - ( i - 1 ) / \beta } \} _ { i = 1 } ^ { \cdot }$ we introduce our time-encoding to encode each timestamps into a $d$ -dimensional vector. More specifically, we first map each $t$ to a vector with monotonically exponentially decreasing values $t \omega \in ( 0 , t ]$ among the feature dimension, then use cosine function to project all values to $\cos ( t \omega ) \in [ - 1 , + \bar { 1 } ]$ . The selection of $\alpha , \beta$ is depending on the scale of the maximum timestamp $t _ { \mathrm { m a x } }$ we wish to encode. In order to distinguish all timestamps, we have to make sure $t _ { \mathrm { m a x } } \stackrel { \bullet } { \times } \alpha ^ { - ( i - 1 ) / \beta } 0$ as $i d$ to distinguish all timestamps. In practice, we found $d = 1 0 0$ and $\alpha = \beta = \sqrt { d }$ works well for all datasets. Notice that $\omega$ is fixed and will not be updated during training. As shown in Figure 2a, the output of this time-encoding function has two main properties that could help GraphMixer distinguish different timestamps: similar timestamps have similar time-encodings (e.g., the plot of $t _ { 1 } , t _ { 2 } )$ and the larger the timestamp the later the values in time-encodings converge to $+ 1$ (e.g., the plot of $t _ { 1 } , t _ { 3 }$ or $t _ { 1 } , t _ { 4 } )$ .
|
| 72 |
+
|
| 73 |
+

|
| 74 |
+
Figure 2: (a) Time-encoding function that pre-process timestamp $t$ into a vector $\cos ( t \omega )$ . The $\mathbf { X }$ -axis is the vector dimension and the y-axis is the cosine value. (b) link-encoder takes the temporal link information of node $v _ { 2 }$ as inputs and outputs a vector $\mathbf { t } _ { 2 } ( t _ { 0 } )$ that will be used for link prediction.
|
| 75 |
+
|
| 76 |
+
• Mixer for information summarizing. We use a 1-layer MLP-mixer Tolstikhin et al. (2021) to summarize the temporal link information. Figure 2b is an example on summarizing the temporal link information of node $\{ ( t _ { 1 } , \mathbf { x } _ { 1 , 2 } ^ { \mathrm { l i n k } } ( t _ { 1 } ) ) , ( t _ { 3 } , \mathbf { x } _ { 2 , 4 } ^ { \mathrm { l i n k } } ( t _ { 3 } ) ) , ( t _ { 4 } , \mathbf { x } _ { 2 , 4 } ^ { \mathrm { l i n k } } ( t _ { 4 } ) ) , ( t _ { 5 } , \mathbf { x } _ { 1 , 2 } ^ { \mathrm { l i n k } } ( t _ { 5 } ) ) \}$ $v _ { 2 }$ . Recall that the temporal link information of node 2 . We first encode timestamps by our is time-encoding function then concatenate it with its corresponding link features. For example, we encode $( t _ { 1 } , \mathbf { x } _ { 1 , 2 } ^ { \mathrm { l i n k } } ( t _ { 1 } ) )$ as $\left[ \cos ( ( t _ { 0 } - t _ { 1 } ) \omega ) | | \mathbf { x } _ { 1 , 2 } ^ { \mathrm { l i n k } } ( t _ { 1 } ) ) \right]$ where $t _ { 0 }$ is the timestamp that we want to predict whether the link exists. Then, we stack all the outputs into a big matrix and zero-pad to the fixed length $K$ denoted as $\mathbf { T } _ { 2 } ( t _ { 0 } )$ . Finally, we use an 1-layer MLP-mixer with mean-pooling to compress $\mathbf { T } _ { 2 } ( t _ { 0 } )$ into a single vector $\mathbf { t } _ { 2 } ( t _ { 0 } )$ . Specifically, the MLP-mixer takes $\mathbf { T } _ { 2 } ( t _ { 0 } )$ as input
|
| 77 |
+
|
| 78 |
+
$$
|
| 79 |
+
\begin{array} { r } { \begin{array} { r } { \mathbf { T } _ { 2 } ( t _ { 0 } ) \to \mathbf { H } _ { \mathrm { i n p u t } } , \mathbf { H } _ { \mathrm { t o k e n } } = \mathbf { H } _ { \mathrm { i n p u t } } + \mathbf { W } _ { \mathrm { t o k e n } } ^ { ( 2 ) } \mathcal { G e } \mathbf { L U } ( \mathbf { W } _ { \mathrm { t o k e n } } ^ { ( 1 ) } \mathrm { L a y e r N o r m } ( \mathbf { H } _ { \mathrm { i n p u t } } ) ) , } \\ { \mathbf { H } _ { \mathrm { c h a m e l } } = \mathbf { H } _ { \mathrm { t o k e n } } + \mathcal { G e } \mathbf { L U } ( \mathrm { L a y e r N o r m } ( \mathbf { H } _ { \mathrm { t o k e n } } ) \mathbf { W } _ { \mathrm { c h a n n e l } } ^ { ( 1 ) } ) \mathbf { W } _ { \mathrm { c h a m e l } } ^ { ( 2 ) } , } \end{array} } \end{array}
|
| 80 |
+
$$
|
| 81 |
+
|
| 82 |
+
and output the temporal encoding $\mathbf { t } _ { 2 } ( t _ { 0 } ) = \mathbb { M } \mathrm { e a n } ( \mathbf { H } _ { \mathrm { c h a n n e l } } )$ . Please notice that zero-padding operator is important to capture how often a node interacts with other nodes. The node with more zero-padded dimensions has less temporal linked neighbors. This information is very important in practice according to our experimental observation.
|
| 83 |
+
|
| 84 |
+
Node-encoder. The node-encoder is designed to capture the node identity and node feature information via neighbor mean-pooling. Let us define the 1-hop neighbor of node $v _ { i }$ with link timestamps from $t$ to $t _ { 0 }$ as $\mathcal { N } ( \bar { v _ { i } } ; t , t _ { 0 } )$ . For example in Figure 1, we have $\mathcal { N } ( v _ { 2 } ; t _ { 4 } , t _ { 0 } ) = \{ v _ { 1 } , v _ { 4 } \}$ and $\mathcal { N } ( v _ { 5 } ; t _ { 4 } , t _ { 0 } ) = \{ v _ { 3 } \}$ . Then, the node-info feature is computed based on the 1-hop neighbor by $\mathbf { s } _ { i } ( t _ { 0 } ) = \mathbf { x } _ { i } ^ { \mathrm { n o d e } } + \dot { \mathrm { M e a n } } \{ \mathbf { x } _ { j } ^ { \mathrm { n o d e } } \ \vert \ v _ { j } \in \mathcal { N } ( v _ { i } ; t _ { 0 } - T , t _ { 0 } ) \}$ , where $T$ is a dataset-dependent hyperparameter. In practice, we found 1-hop neighbors are enough to achieve good performance, and we use one-hot node representations for datasets without node features.
|
| 85 |
+
|
| 86 |
+
Link classifier. Link classifier is designed to classify whether a link exists at time $t _ { 0 }$ using the output of link-encoder $\mathbf { t } _ { i } ( t _ { 0 } )$ and the output of node-encoder ${ \bf s } _ { i } ( t _ { 0 } )$ . Let us denote the node $v _ { i }$ ’s representation at time $t _ { 0 }$ as the concatenation of the above two encodings $\mathbf { h } _ { i } ( t _ { 0 } ) = \left[ \mathbf { s } _ { i } ( t _ { 0 } ) \mathbf { \nabla } \| \mathbf { \ v } _ { i } ( t _ { 0 } ) \right]$ . Then, the prediction on whether an interaction between node $v _ { i } , v _ { j }$ happens at time $t _ { 0 }$ is computed by applying a 2-layer MLP model on $[ \mathbf { h } _ { i } ( t _ { 0 } ) \mathbf { \epsilon } ] | \mathbf { h } _ { j } ( t _ { 0 } ) ]$ , i.e., $\begin{array} { r } { p _ { i j } = \mathbf { \tilde { M L P } } ( \left[ \mathbf { h } _ { i } ( t _ { 0 } ) \mathbf { \mathbf { \tau } } \right| \left| \mathbf { h } _ { j } ( t _ { 0 } ) \right] ) } \end{array}$ .
|
| 87 |
+
|
| 88 |
+
# 3.2 COMPARISON TO EXISTING METHODS
|
| 89 |
+
|
| 90 |
+
In the following, we highlight some differences between GraphMixer and other methods, which will be explicitly ablation studied in the experiment section (Section 4.4).
|
| 91 |
+
|
| 92 |
+
Temporal graph as undirected graph. Most of the existing works consider temporal graphs as directed graphs with information only flows from the source node (e.g., users in the recommender system) to the destination nodes (e.g., ads in the recommender system). However, we consider the temporal graph as an undirected graph. By doing so, if two nodes are frequently connected in the last few timestamps, the “most recent 1-hop neighbors” sampled for the two nodes on the “undirected” temporal graph would be similar. In other words, the similarity between the sampled neighbors provides information on whether two nodes are frequently connected in the last few timestamps, which is essential for temporal graph link prediction. Intuitively, if two nodes are frequently connected in the last few timestamps, they are also likely to be connected in the recent future.
|
| 93 |
+
|
| 94 |
+
Table 1: Comparison on the average precision score for link prediction. GraphMixer uses one-hot node encoding for datasets without node features (marked by ♮). For each dataset, we indicate whether we have the corresponding feature (“L” link features, “N” node features, and “T” link timestamps). Red is the best score, Blue is the best score excluding GraphMixer and its variants.
|
| 95 |
+
|
| 96 |
+
<table><tr><td></td><td>Reddit L,T</td><td>Wiki L,T</td><td>MOOC T</td><td>LastFM T</td><td>GDELT L,N,T</td><td>GDELT-ne T</td><td>GDELT-e N,T</td></tr><tr><td>JODIE</td><td>99.30±0.01</td><td>98.81 ± 0.01</td><td>99.16± 0.01</td><td>67.51 ± 0.87</td><td>98.27±0.02</td><td>97.13± 0.02</td><td>96.96±0.02</td></tr><tr><td>DySAT</td><td>98.52 ± 0.01</td><td>96.71 ± 0.02</td><td>98.82±0.02</td><td>76.40± 0.77</td><td>98.52 ± 0.02</td><td>82.47 ± 0.13</td><td>97.25 ± 0.02</td></tr><tr><td>TGAT</td><td>99.66 ± 0.01</td><td>97.75 ± 0.02</td><td>98.43 ±0.01</td><td>54.77 ± 1.01</td><td>98.25 ±0.02</td><td>84.30 ±0.10</td><td>96.96 ±0.02</td></tr><tr><td>TGN</td><td>99.80 ± 0.01</td><td>99.55 ± 0.01</td><td>99.62 ± 0.01</td><td>82.23 ± 0.50</td><td>98.15±0.02</td><td>97.13 ± 0.02</td><td>96.04±0.02</td></tr><tr><td>CAWs-mean</td><td>98.43±0.02</td><td>97.72 ± 0.03</td><td>62.99±0.87</td><td>76.35±0.08</td><td>95.11± 0.12</td><td>69.20±0.10</td><td>91.72 ± 0.19</td></tr><tr><td>CAWs-attn</td><td>98.51 �� 0.02</td><td>97.95 ± 0.03</td><td>63.07 ±0.82</td><td>76.31±0.10</td><td>95.06 ± 0.11</td><td>69.54 ± 0.19</td><td>91.54± 0.22</td></tr><tr><td>TGSRec</td><td>95.21±0.08</td><td>91.64± 0.12</td><td>83.62 ± 0.34</td><td>76.91± 0.87</td><td>97.03 ±0.61</td><td>97.03 ± 0.61</td><td>97.03 ± 0.61</td></tr><tr><td>APAN</td><td>99.24± 0.02</td><td>98.14± 0.01</td><td>98.70 ±0.98</td><td>69.39 ± 0.81</td><td>95.96 ±0.10</td><td>97.38 ± 0.23</td><td>96.77 ± 0.18</td></tr><tr><td>GraphMixer-L</td><td>99.84±0.01</td><td>99.70±0.01</td><td>99.81±0.01</td><td>95.50±0.03</td><td>98.99±0.02</td><td>96.14±0.02</td><td>98.99±0.02</td></tr><tr><td>GraphMixer-N</td><td>99.24±0.01</td><td>90.33± 0.01</td><td>97.35±0.02b</td><td>63.80±0.03</td><td>94.44 ± 0.02</td><td>96.00±0.024</td><td>98.81±0.02b</td></tr><tr><td>GraphMixer</td><td>99.93 ± 0.01§</td><td>99.85± 0.01</td><td>99.91 ± 0.01§</td><td>96.31 ± 0.02</td><td>98.89 ±0.02</td><td>98.39 ± 0.02§</td><td>98.22 ±0.02</td></tr></table>
|
| 97 |
+
|
| 98 |
+
Selection on neighbors. Existing methods consider either “multi-hop recent neighbors” or “multihop uniform sampled neighbors”, whereas we only consider the “1-hop most recent neighbors”. For example, TGAT Xu et al. (2020), DySAT Sankar et al. (2020), and TGSRe Fan et al. (2021) consider multi-hop uniform sampled neighbors; JODIE Kumar et al. (2019), TGN Rossi et al. (2020), and APAN Wang et al. (2021b) maintain the historical node interactions via RNN, which can be think of as multi-hop recent neighbors; CAWs Wang et al. (2020) samples neighbors by random walks, which can also be think of as multi-hop recent neighbors. Although sampling more neighbors could provide a sufficient amount of information for models to reason about, it could also carry much spurious or noisy information. As a result, more complicated model architectures (e.g., RNN or SAM) are required to extract useful information from the raw data, which could lead to a poor model trainability and potentially weaker generalization ability. Instead, we only take the “most recent 1-hop neighbors” into consideration, which is conceptually simpler and enjoys better performance.
|
| 99 |
+
|
| 100 |
+
# 4 EXPERIMENTS
|
| 101 |
+
|
| 102 |
+
Dataset. We conduct experiments on five real-world datasets, including the Reddit, Wiki, MOOC, LastFM datasets that are used in Kumar et al. (2019) and the GDELT dataset1 which is introduced in Zhou et al. (2022). Besides, since GDELT is the only dataset with both node and link features, we create its two variants to understand the effect of training data on model performance: GDELT-e removes the link feature from GDELT and keep the node feature and link timestamps, GDELT-ne removes both the link and edge features from GDELT and only keep the link timestamps. For each dataset, we use the same $7 0 \% / 1 5 \% / 1 5 \%$ chronological splits for the train/validation/test sets as existing works. The detailed dataset statistics are summarized in Appendix A.2.
|
| 103 |
+
|
| 104 |
+
Baselines. We compare baselines that are introduced in Section 2. Besides, we create two variants to better understand how node- and link-information contribute to our results, where GraphMixer-L is only using link-encoder and GraphMixer-N is only using node-encoder. We conduct experiments under the transductive learning setting and use average precision for evaluation. The detailed model configuration, training and evaluation process are summarized in Appendix A.3. Due to the space limit, more experiment results on using Recall@K, MRR, and AUC as the evaluation metrics, comparison on wall-clock time and number of parameters are deferred to Appendix C
|
| 105 |
+
|
| 106 |
+
Outline. We first compare GraphMixer with baselines in Section 4.1 then highlight the three key factors that contribute to the success of GraphMixer in Section 4.2, Section 4.3, and Section 4.4.
|
| 107 |
+
|
| 108 |
+
# 4.1 MAIN EMPIRICAL RESULTS.
|
| 109 |
+
|
| 110 |
+
GraphMixer achieves outstanding performance. We compare the average precision score with baselines in Table 1. We have the following observations: $\textcircled{1}$ GraphMixer outperforms all baselines on all datasets. The experiment results provide sufficient support on our argument that neither RNN nor SAM is necessary for temporal graph link prediction. $\textcircled{2}$ According to the performance of GraphMixer-L on datasets only have link timestamp information (MOOC, LastFM, and GDELT-ne), we know that our time-encoding function could successfully pre-process each timestamp into a meaningful vector. In fact, we will show later in Section 4.2 that our time-encoding function is more preferred than baselines’ trainable version. $\textcircled{3}$ By comparing the performance GraphMixer-N and GraphMixer on Wiki, MOOC, and LastFM datasets, we know that node-encoder alone is not enough to achieve a good performance. However, it provides useful information that could benefit the link-encoder. $\textcircled{4}$ By comparing the performance of GraphMixer-N on GDELT and GDELT-ne, we observe that using one-hot encoding outperforms using node features. This also shows the importance of node identity information because one-hot encoding only captures such information. $\textcircled{5}$ More complicated methods (e.g., CAWs, TGSRec, and DDGCL) do not perform well when using the default hyper-parameters2, which is understandable because these methods have more components with an excessive amount of hyper-parameters to tune.
|
| 111 |
+
|
| 112 |
+

|
| 113 |
+
Figure 3: Comparison on the training set average precision and generalization gap for the first 100 training epochs. Results on other datasets can be found in Figure 8.
|
| 114 |
+
|
| 115 |
+
GraphMixer enjoys better convergence and generalization ability. To better understand the model performance, we take a closer look at the dynamic of training accuracy and the generalization gap (the absolute difference between training and evaluation score). The results are reported in Figure 3 and Figure 8: $\textcircled{1}$ The slope of training curves reflects the expressive power and convergence speed of an algorithm. From the first row figures, we can observe that GraphMixer always converge to a high average precision score in just a few epochs, and the training curve is very smooth when compared to baselines. Interestingly, we can observe that the baseline methods cannot always fit the training data, and their training curves fluctuate a lot throughout the training process. $\textcircled{2}$ The generalization gap reflects how well the model could generalize and how stable the model could perform on unseen data (the smaller the better). From the second row figures, the generalization gap curve of GraphMixer is lesser and smoother than baselines, which indicates the generalization power of GraphMixer.
|
| 116 |
+
|
| 117 |
+
GraphMixer enjoys a smoother loss landscape. To understand why “GraphMixer converges faster and generalizes better, while baselines suffer training unstable issue and generalize poorly”, we explore the loss landscape by using the visualization tools introduced in Li et al. (2018a). We illustrate the loss landscape in Figure 4 by calculating and visualizing the loss surface along two random directions near the pre-trained optimal parameters. The $\mathbf { X \cdot }$ - and y-axis indicate how much the optimal solution is stretched along the two random directions, and the optimal point is when x- and y-axis are zero. $\textcircled{1}$ From Figure 4a, 4d, we know GraphMixer enjoys a smoother landscape with a flatter surface at the optimal point, the slope becomes steeper when stretching along the two random directions. The steeper slope on the periphery explains why GraphMixer could converge fast, the flatter surface at the optimal point explains why it could generalize well. $\textcircled{2}$ Surprisingly, we find that baselines have a non-smooth landscape with many spikes on its surface from Figure 4b, 4c, 4e, 4f. This observation provides sufficient explanation on the training instability and poor generalization issue of baselines as shown in Figure 3, 8. Interestingly, as we will show later in Section 4.2, the trainable time-encoding function in baselines is the key to this non-smooth landscape issue. Replacing it with our fixed time-encoding function could flatten the landscape and boost their model performance.
|
| 118 |
+
|
| 119 |
+

|
| 120 |
+
Figure 4: Comparison on the training loss landscape. Results on other datasets and other baselines can be found in Appendix E.
|
| 121 |
+
|
| 122 |
+
# 4.2 ON THE IMPORTANCE OF OUR FIXED TIME-ENCODING FUNCTION.
|
| 123 |
+
|
| 124 |
+
Existing works (i.e., JODIE, TGAT, and TGN) leverage a trainable time-encoding function ${ \bf z } ( t ) =$ $\cos ( t \mathbf { w } ^ { \top } + \mathbf { b } )$ to represent timestamps3. However, we argue that using trainable time-encoding function could cause instability during training because its gradient $\begin{array} { r } { \frac { \partial \cos ( \mathbf { \breve { t } w } + \mathbf { b } ) } { \partial \mathbf { w } } = t \times \sin ( t \mathbf { w } + \mathbf { b } ) } \end{array}$ scales proportional to the timestamps, which could lead to training instability issue and cause the baselines’ the non-smooth landscape issue as shown in Figure 4. As an alternative, we utilize the fixed time-encoding function $\mathbf { z } ( t ) \dot { = } \cos ( t \omega )$ with fixed features $\omega$ that could capture the relative difference between two timestamps (introduced in Section 3.1). To verify this, we introduce a simple experiment to test whether the time-encoding functions (both our fixed version and baselines’ trainable version) are expressive enough, such that a simple linear classifier can distinguish the time-encodings of two different timestamps produced by the time-encoding functions. Specially, our goal is to classify if $t _ { 1 } > t _ { 2 }$ by learning a linear classifier on $[ { \bf z } ( t _ { 1 } ) | | { \bf z } ( t _ { 2 } ) ]$ . During training, we randomly generate two timestamps $t _ { 1 } , t _ { 2 } \in [ 0 , 1 0 ^ { 6 } ]$ and ask a fully connected layer to classify whether a timestamp is greater than another. As shown in Figure 5a, using the trainable time-encoding function (orange curve) will suffer from the unstable exploding gradient issue (left upper figure) and its performance remains almost the same during the training process (left lower figure). However, using our fixed time-encoding function (blue curve) does not have the unstable exploding gradient issue and can quickly achieve high accuracy within several iterations. Meanwhile, we compare the parameter trajectories of the two models in Figure 5b. We observe that the change of parameters on the trainable time-encoding function is drastically larger than our fixed version. A huge change in weight parameters could deteriorate the model’s performance. Most importantly, by replacing baselines’ trainable time-encoding function with our fixed version, most baselines have a smoother optimization landscape (Figure 6) and a better model performance (in Table 2), which further verifies our argument that our fixed time-encoding function is more preferred than the trainable version.
|
| 125 |
+
|
| 126 |
+
Table 2: Comparison on average precision score with fixed/trainable time encoding function (TEF). The results before $\ddot { \bullet } \ '$ is for trainable TEF (same as Table 1) and after $\ddot { \bullet } \acute { \bullet } \ '$ is for fixed TEF.
|
| 127 |
+
4.3 ON THE IMPORTANCE OF MLP-MIXER IN GRAPHMIXER’S LINK-ENCODER
|
| 128 |
+
|
| 129 |
+
<table><tr><td></td><td colspan="2">Reddit</td><td>Wiki</td><td colspan="2">MOOC</td><td colspan="2">LastFM</td><td colspan="2">GDELT-ne</td></tr><tr><td>JODIE</td><td>99.30→99.76</td><td></td><td>98.81→99.00</td><td></td><td>99.16→99.17</td><td>67.51→79.89</td><td>97.13</td><td>→98.23</td><td>96.96→96.96</td></tr><tr><td>TGAT</td><td>98.66→99.48</td><td></td><td>96.71→ 98.55</td><td></td><td>98.43→ 99.33</td><td>54.77 → 76.26</td><td>84.30</td><td>→92.31</td><td>96.96 →96.28</td></tr><tr><td>TGN</td><td>99.80</td><td>→99.83</td><td>99.55 → 99.54</td><td></td><td>99.62 →99.62</td><td>82.23→87.58</td><td>98.15</td><td>→98.25</td><td>96.04→97.34</td></tr></table>
|
| 130 |
+
|
| 131 |
+
In this section, we aim to achieve a deeper understanding on the expressive power of the link-encoder by answering the following two questions: “Can we replace the MLP-mixer in link-encoder with selfattention?” and “Why MLP-mixer is a good alternative of self-attention?” To answer these questions, let us first conduct experiments by replacing the MLP-mixer in link-encoder with full/1-hop selfattention and sum/mean-pooling, where full self-attention is widely used in Transformers and 1-hop self-attention is widely used in graph attention networks. As shown in Table 3, GraphMixer suffers from performance degradation when using self-attention: the best performance is achieved when using MLP-mixer with zero-padding, while the model performance drop slightly when using selfattention with sum-pooling (row 2 and 4), and the performance drop significantly when using self-attention with mean-pooling (row 3 and 5). Self-attention with mean-pooling has a weaker model performance because it cannot distinguish “temporal sequences with identical link timestamps and features” (e.g., cannot distinguish $[ a _ { 1 } , a _ { 1 } ]$ and $[ a _ { 1 } ]$ and it cannot explicitly capture “the length of temporal sequences” (e.g., cannot distinguish if $[ a _ { 1 } , a _ { 2 } ]$ is longer than $[ a _ { 3 } ] ,$ ), which are both very important for GraphMixer understand how frequent a node interacts with other nodes. We explicitly verify this in Figure 7 by first generating two temporal sequences (with timestamps but without link features), then encoding the timestamps into vectors via time-encoding function, and asking full self-attention and MLP-mixer to distinguish. As shown in Figure 7, self-attention with mean-pooling cannot distinguish two temporal sequences with identical timestamps (because all the self-attention weights are equivalent if the features of the node on the two sides of a link are identical) and cannot capture the sequence length (because of mean-pooling simply averages the inputs and does not take the input size into consideration). However, MLP-mixer in GraphMixer can distinguish the above two sequences because of zero-padding. Fortunately, the aforementioned two weaknesses could be alleviated by replacing the mean-pooling in temporal self-attention with the sum-pooling, which explains why using sum-pooling brings better model performance than mean-pooling. However, since self-attention modules have more parameters and are harder to train, they could generalize poor when the downstream task is not too complicated.
|
| 132 |
+
|
| 133 |
+

|
| 134 |
+
Figure 5: (a) Comparison on the gradient / parameters norm and accuracy at each iteration. (b) Comparison on the trajectories of parameter change, where the radius is $r _ { t } = \lvert \lvert \delta _ { t } \rvert \rvert / \lvert \lvert \delta _ { 0 } \rvert \rvert$ , the angle is $\theta _ { t } = \mathrm { \bar { a r c c o s } } \langle \delta _ { t } / \| \delta _ { t } \| _ { 2 } , \delta _ { 0 } / \| \delta _ { 0 } \| _ { 2 } \bar { \rangle }$ , and $\pmb { \delta } _ { t } = \mathbf { w } _ { t } - \mathbf { w } ^ { \star }$ is the difference between $\mathbf { w } _ { t }$ to optimal point $\mathbf { w } ^ { \star }$ . The more the model parameters change during training, the larger the semicircle.
|
| 135 |
+
|
| 136 |
+

|
| 137 |
+
Figure 6: Comparison on the training loss landscape fixed time-encoding function. Results on other datasets and baselines can be found in Appendix F.
|
| 138 |
+
|
| 139 |
+
# 4.4 KEY FACTORS TO THE BETTER PERFORMANCE
|
| 140 |
+
|
| 141 |
+
One of the major factors that contributes to GraphMixer’s success is the simplicity of GraphMixer’s neural architecture and input data. Using conceptually simple input data that better aligned with their labels allows a simple neural network model to capture the underlying mapping between the input to their labels, which could lead to a better generalization ability. In the following, we explicitly verify this by comparing the performance of GraphMixer with different input data in Table 4: $\textcircled{1}$ Recall from Section 3.2 that the “most recent 1-hop neighbors” sampled for the two nodes on the “undirected” temporal graph could provide information on whether two nodes are frequently connected in the last few timestamps, which is essential for temporal graph link prediction. To verify this, we conduct ablation study by comparing the model performance on direct and undirected temporal graphs. As shown in the 1st and 2nd row of Table 4, changing from undirected to direct graph results in a significant performance drop because such information is missing. $\textcircled{2}$ Recall from Section 3.1 that instead of feeding the raw timestamp to GraphMixer and encoding each timestamp with a trainable time-encoding function, GraphMixer encodes the timestamps via our fixed time-encoding function and feed the encoded representation to GraphMixer, which reduces the model complexity of learning a time-encoding function from data. This could be verified by the 3rd and 4th rows of Table 4, where using the pre-encoded time information could give us a better performance. $\textcircled{3}$ Selecting the input data that has similar distribution in training and evaluation set could also potentially improve the evaluation error. For example, using relative timestamps (i.e., each neighbor’s timestamp is subtracted by its root node’s timestamp) is better than absolute timestamps (e.g., using Unix timestamp)because the absolute timestamps in the evaluation set and training set are from different range when using chronological splits, but they are very likely to overlap if using relative timestamps. As shown in the 3rd to 6th rows of Table 4, using relative time information always gives a better model performance than using absolute time information. $\textcircled{4}$ Selecting the most representative neighbors for each node. For example, we found 1-hop most recent interacted neighbors are the most representative for link prediction. Switching to either 2-hop neighbors or uniform sampled neighbors will hurt the model performance according to the 7th to the 10th row of Table 4.
|
| 142 |
+
|
| 143 |
+

|
| 144 |
+
Figure 7: (a) We generate identical timestamp sequences with different length, then ask MLP-mixer and GAT to distinguish whether the generated sequence are identical (b) We generate random sequence with different length, then ask MLP-mixer and GAT to classify which sequence is longer.
|
| 145 |
+
|
| 146 |
+
Table 3: Comparison on the average precision score. ♮ use 20 neighbors due to out of GPU memory.
|
| 147 |
+
Table 4: Comparison on the average precision score of GraphMixer with different input data. The highlighted rows are identical to our default setting.
|
| 148 |
+
|
| 149 |
+
<table><tr><td colspan="3"></td><td>Reddit</td><td>Wiki</td><td>MOOC</td><td>LastFM</td></tr><tr><td rowspan="3">Direct vs undirect temporal graph</td><td colspan="2">Directed temporal graph</td><td>99.69</td><td>88.37</td><td>97.87</td><td>78.34</td></tr><tr><td colspan="2">Undirected temporal graph</td><td>99.93</td><td>99.85</td><td>99.91</td><td>96.31</td></tr><tr><td colspan="2">Relative timestamp (ti-to)</td><td>99.79</td><td>99.80</td><td>99.81</td><td>95.32</td></tr><tr><td rowspan="3">Time information</td><td>Relative time-encoding cos((ti - to)ω)</td><td></td><td>99.93</td><td>99.85</td><td>99.91</td><td>96.31</td></tr><tr><td></td><td>Absolute timestamp ti</td><td>98.90</td><td>98.23</td><td>98.73</td><td>92.25</td></tr><tr><td>Absolute time-encoding cos(tiω)</td><td></td><td>99.52</td><td>99.13</td><td>99.74</td><td>95.28</td></tr><tr><td rowspan="4">Neighbor selection</td><td>2-hop</td><td>Most recent neighbors</td><td>99.39</td><td>98.05</td><td>99.11</td><td>89.36</td></tr><tr><td>1-hop</td><td>Most recent neighbors</td><td>99.93</td><td>99.85</td><td>99.91</td><td>96.31</td></tr><tr><td>2-hop</td><td>Uniform sample neighbors</td><td>97.66</td><td>92.57</td><td>98.87</td><td>65.72</td></tr><tr><td>1-hop</td><td>Uniform sample neighbors</td><td>98.19</td><td>94.74</td><td>98.40</td><td>60.02</td></tr></table>
|
| 150 |
+
|
| 151 |
+
# 5 CONCLUSION
|
| 152 |
+
|
| 153 |
+
In this paper, we propose a conceptually and technically simple architecture GraphMixer for temporal link prediction. GraphMixer not only outperforms all baselines but also enjoys a faster convergence speed and better generalization ability. An extensive study identifies three key factors that contribute to the success of GraphMixer and highlights the importance of simpler neural architecture and input data structure. An interesting future direction, not limited to temporal graph learning, is designing algorithms that could automatically select the best input data and data pre-processing strategies for different downstream tasks.
|
| 154 |
+
|
| 155 |
+
# ACKNOWLEDGEMENTS
|
| 156 |
+
|
| 157 |
+
This work was supported in part by NSF grant 2008398. Majority of this work was completed during Weilin Cong’s internship at Meta AI under the mentorship of Si Zhang. We also extend our gratitude to Long Jin for his co-mentorship and for his contribution to the idea of using MLP-Mixer on graphs.
|
| 158 |
+
|
| 159 |
+
# REFERENCES
|
| 160 |
+
|
| 161 |
+
Uri Alon and Eran Yahav. On the bottleneck of graph neural networks and its practical implications. arXiv preprint arXiv:2006.05205, 2020.
|
| 162 |
+
|
| 163 |
+
Khac-Hoai Nam Bui, Jiho Cho, and Hongsuk Yi. Spatial-temporal graph neural network for traffic forecasting: An overview and open research issues. Applied Intelligence, pp. 1–12, 2021.
|
| 164 |
+
|
| 165 |
+
Huixuan Chi, Hao Xu, Hao Fu, Mengya Liu, Mengdi Zhang, Yuji Yang, Qinfen Hao, and Wei Wu. Long short-term preference modeling for continuous-time sequential recommendation. arXiv preprint arXiv:2208.00593, 2022.
|
| 166 |
+
|
| 167 |
+
Weilin Cong, Morteza Ramezani, and Mehrdad Mahdavi. On provable benefits of depth in training graph convolutional networks. Advances in Neural Information Processing Systems, 34:9936–9949, 2021a.
|
| 168 |
+
|
| 169 |
+
Weilin Cong, Yanhong Wu, Yuandong Tian, Mengting Gu, Yinglong Xia, Chun cheng Jason Chen, and Mehrdad Mahdavi. Dyformer: A scalable dynamic graph transformer with provable benefits on generalization ability. 2021b.
|
| 170 |
+
|
| 171 |
+
Ziwei Fan, Zhiwei Liu, Jiawei Zhang, Yun Xiong, Lei Zheng, and Philip S Yu. Continuous-time sequential recommendation with temporal graph collaborative transformer. In Proceedings of the 30th ACM International Conference on Information & Knowledge Management, pp. 433–442, 2021.
|
| 172 |
+
|
| 173 |
+
Jianfei Gao and Bruno Ribeiro. On the equivalence between temporal and static equivariant graph representations. In Proceedings of the 39th International Conference on Machine Learning, 2022.
|
| 174 |
+
|
| 175 |
+
Palash Goyal, Sujit Rokka Chhetri, and Arquimedes Canedo. dyngraph2vec: Capturing network dynamics using dynamic graph representation learning. arXiv preprint arXiv:1809.02657, 2018.
|
| 176 |
+
|
| 177 |
+
Ehsan Hajiramezanali, Arman Hasanzadeh, Krishna Narayanan, Nick Duffield, Mingyuan Zhou, and Xiaoning Qian. Variational graph recurrent neural networks. Advances in neural information processing systems, 32, 2019.
|
| 178 |
+
|
| 179 |
+
Seyed Mehran Kazemi, Rishab Goel, Kshitij Jain, Ivan Kobyzev, Akshay Sethi, Peter Forsyth, and Pascal Poupart. Representation learning for dynamic graphs: A survey. J. Mach. Learn. Res., 21 (70):1–73, 2020.
|
| 180 |
+
|
| 181 |
+
Thomas N Kipf and Max Welling. Variational graph auto-encoders. arXiv preprint arXiv:1611.07308, 2016.
|
| 182 |
+
|
| 183 |
+
Srijan Kumar, Xikun Zhang, and Jure Leskovec. Predicting dynamic embedding trajectory in temporal interaction networks. In Proceedings of the 25th ACM SIGKDD international conference on Knowledge discovery and data mining. ACM, 2019.
|
| 184 |
+
|
| 185 |
+
Hao Li, Zheng Xu, Gavin Taylor, Christoph Studer, and Tom Goldstein. Visualizing the loss landscape of neural nets. In Neural Information Processing Systems, 2018a.
|
| 186 |
+
|
| 187 |
+
Qimai Li, Zhichao Han, and Xiao-Ming Wu. Deeper insights into graph convolutional networks for semi-supervised learning. In Thirty-Second AAAI conference on artificial intelligence, 2018b.
|
| 188 |
+
|
| 189 |
+
Yuhong Luo and Pan Li. Neighborhood-aware scalable temporal network representation learning. arXiv preprint arXiv:2209.01084, 2022.
|
| 190 |
+
|
| 191 |
+
Aldo Pareja, Giacomo Domeniconi, Jie Chen, Tengfei Ma, Toyotaro Suzumura, Hiroki Kanezashi, Tim Kaler, Tao Schardl, and Charles Leiserson. Evolvegcn: Evolving graph convolutional networks for dynamic graphs. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 34, pp. 5363–5370, 2020.
|
| 192 |
+
|
| 193 |
+
Emanuele Rossi, Ben Chamberlain, Fabrizio Frasca, Davide Eynard, Federico Monti, and Michael Bronstein. Temporal graph networks for deep learning on dynamic graphs. In ICML 2020 Workshop on Graph Representation Learning, 2020.
|
| 194 |
+
|
| 195 |
+
Aravind Sankar, Yanhong Wu, Liang Gou, Wei Zhang, and Hao Yang. Dysat: Deep neural representation learning on dynamic graphs via self-attention networks. In Proceedings of the 13th International Conference on Web Search and Data Mining, pp. 519–527, 2020.
|
| 196 |
+
|
| 197 |
+
Amauri H Souza, Diego Mesquita, Samuel Kaski, and Vikas Garg. Provably expressive temporal graph networks. arXiv preprint arXiv:2209.15059, 2022.
|
| 198 |
+
|
| 199 |
+
Sheng Tian, Ruofan Wu, Leilei Shi, Liang Zhu, and Tao Xiong. Self-supervised representation learning on dynamic graphs. CIKM ’21, 2021. doi: 10.1145/3459637.3482389.
|
| 200 |
+
|
| 201 |
+
Ilya O Tolstikhin, Neil Houlsby, Alexander Kolesnikov, Lucas Beyer, Xiaohua Zhai, Thomas Unterthiner, Jessica Yung, Andreas Steiner, Daniel Keysers, Jakob Uszkoreit, et al. Mlp-mixer: An all-mlp architecture for vision. Advances in Neural Information Processing Systems, 34: 24261–24272, 2021.
|
| 202 |
+
|
| 203 |
+
Rakshit Trivedi, Mehrdad Farajtabar, Prasenjeet Biswal, and Hongyuan Zha. Dyrep: Learning representations over dynamic graphs. In International conference on learning representations, 2019.
|
| 204 |
+
|
| 205 |
+
Petar Velickovi ˇ c, Guillem Cucurull, Arantxa Casanova, Adriana Romero, Pietro Liò, and Yoshua ´ Bengio. Graph attention networks. In International Conference on Learning Representations, 2018.
|
| 206 |
+
|
| 207 |
+
Lu Wang, Xiaofu Chang, Shuang Li, Yunfei Chu, Hui Li, Wei Zhang, Xiaofeng He, Le Song, Jingren Zhou, and Hongxia Yang. Tcl: Transformer-based dynamic graph modelling via contrastive learning. arXiv preprint arXiv:2105.07944, 2021a.
|
| 208 |
+
|
| 209 |
+
Minjie Wang, Da Zheng, Zihao Ye, Quan Gan, Mufei Li, Xiang Song, Jinjing Zhou, Chao Ma, Lingfan Yu, Yu Gai, Tianjun Xiao, Tong He, George Karypis, Jinyang Li, and Zheng Zhang. Deep graph library: A graph-centric, highly-performant package for graph neural networks. arXiv preprint arXiv:1909.01315, 2019.
|
| 210 |
+
|
| 211 |
+
Xuhong Wang, Ding Lyu, Mengjian Li, Yang Xia, Qi Yang, Xinwen Wang, Xinguang Wang, Ping Cui, Yupu Yang, Bowen Sun, et al. Apan: Asynchronous propagation attention network for real-time temporal graph embedding. In Proceedings of the 2021 International Conference on Management of Data, pp. 2628–2638, 2021b.
|
| 212 |
+
|
| 213 |
+
Yanbang Wang, Yen-Yu Chang, Yunyu Liu, Jure Leskovec, and Pan Li. Inductive representation learning in temporal networks via causal anonymous walks. In International Conference on Learning Representations, 2020.
|
| 214 |
+
|
| 215 |
+
Yiwei Wang, Yujun Cai, Yuxuan Liang, Henghui Ding, Changhu Wang, Siddharth Bhatia, and Bryan Hooi. Adaptive data augmentation on temporal graphs. Advances in Neural Information Processing Systems, 34:1440–1452, 2021c.
|
| 216 |
+
|
| 217 |
+
Yiwei Wang, Yujun Cai, Yuxuan Liang, Henghui Ding, Changhu Wang, and Bryan Hooi. Time-aware neighbor sampling for temporal graph networks. arXiv preprint arXiv:2112.09845, 2021d.
|
| 218 |
+
|
| 219 |
+
Da Xu, Chuanwei Ruan, Evren Korpeoglu, Sushant Kumar, and Kannan Achan. Inductive representation learning on temporal graphs. arXiv preprint arXiv:2002.07962, 2020.
|
| 220 |
+
|
| 221 |
+
Bing Yu, Haoteng Yin, and Zhanxing Zhu. Spatio-temporal graph convolutional networks: A deep learning framework for traffic forecasting. In IJCAI, 2018.
|
| 222 |
+
|
| 223 |
+
Hongkuan Zhou, Da Zheng, Israt Nisa, Vasileios Ioannidis, Xiang Song, and George Karypis. Tgl: A general framework for temporal gnn training on billion-scale graphs. arXiv preprint arXiv:2203.14883, 2022.
|
| 224 |
+
|
| 225 |
+
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, 2020.
|
| 226 |
+
|
| 227 |
+
# A EXPERIMENT SETUP DETAILS
|
| 228 |
+
|
| 229 |
+
# A.1 HARDWARE SPECIFICATION AND ENVIRONMENT
|
| 230 |
+
|
| 231 |
+
We run our experiments on a single machine with Intel i9-10850K, Nvidia RTX 3090 GPU, and 64GB RAM memory. The code is written in Python 3.8 and we use PyTorch 1.12.1 on CUDA 11.6 to train the model on the GPU. Implementation details could be found at
|
| 232 |
+
|
| 233 |
+
https://github.com/CongWeilin/GraphMixer.
|
| 234 |
+
|
| 235 |
+
# A.2 DETAILS ON DATASET
|
| 236 |
+
|
| 237 |
+
The dataset used in this paper could be automatically downloaded by this script. Reddit dataset4 consists of one month of posts made by users on subreddits. The link feature is extracted by converting the text of each post into a feature vector. Wikipedia dataset5 consists of one month of edits made by edits on Wikipedia pages. The link feature is extracted by converting the edit test into an LIWCfeature vector. LastFM dataset6: consists of one month of who listens-to-which song information. MOOC dataset7 consists of actions done by students on a MOOC online course. GDELT dataset8 is a temporal knowledge graph dataset originated from the Event Database which records events happening in the world from news and articles.
|
| 238 |
+
|
| 239 |
+
Table 5: Dataset statistic.
|
| 240 |
+
|
| 241 |
+
<table><tr><td></td><td>V</td><td>3</td><td>(tmax-tmin)//ε|</td><td>dim(xnode)</td><td>dim(x)</td><td>Node features</td><td>Linkfeatures</td><td>Timestamps</td></tr><tr><td>Reddit</td><td>10,984</td><td>672,447</td><td></td><td>0</td><td>172</td><td>No</td><td>Yes</td><td>Yes</td></tr><tr><td>Wiki</td><td>9,227</td><td>157,474</td><td></td><td></td><td>172</td><td>No</td><td>Yes</td><td>Yes</td></tr><tr><td>MOOC</td><td>7,144</td><td>411,749</td><td>17 3.6</td><td></td><td>0</td><td>No</td><td>No</td><td>Yes</td></tr><tr><td>LastFM</td><td>1,980</td><td>1,293,103</td><td>106</td><td>0 0</td><td>0</td><td>No</td><td>No</td><td>Yes</td></tr><tr><td>GDELT</td><td>8,831</td><td>1,912,909</td><td>0.1</td><td>413</td><td>186</td><td>Yes</td><td>Yes</td><td>Yes</td></tr><tr><td>GDELT-ne</td><td>8,831</td><td>1,912,909</td><td>0.1</td><td>0</td><td>0</td><td>No</td><td>No</td><td>Yes</td></tr><tr><td>GDELT-n</td><td>8,831</td><td>1,912,909</td><td>0.1</td><td>0</td><td>186</td><td>No</td><td>Yes</td><td>Yes</td></tr></table>
|
| 242 |
+
|
| 243 |
+
# A.3 MODEL CONFIGURATIONS, TRAINING AND EVALUATION PROCESS
|
| 244 |
+
|
| 245 |
+
Baseline implementations. The implementation on JODIE, DySAT, TGAT, TGN, and APPN follows the temporal graph learning framework Zhou et al. $( 2 0 \dot { 2 } 2 ) ^ { 9 }$ . Compared to the original baselines’ implementation, this framework’s implementation could achieve a better overall score than its original implementation. The implementation of CAWs-mean and CAWs-attn follows their official implementation10, we choose the number of random walk steps from 8, 16, 32 to balance the training time. The implementation of TGSRec follows their official implementation11. The implementation of DDGCL follows their official implementation12. We directly test using their official implementation by changing our data structure to their required structure and using their default hyper-parameters.
|
| 246 |
+
|
| 247 |
+
GraphMixer implementation. We implement GraphMixer under the TGL framework Zhou et al. (2022) and use their default hyper-parameters (e.g., learning rate 0.0001, weight decay $1 0 ^ { - 6 }$ , batch size 600, hidden dimension 100, etc) to achieve a fair comparison. In GraphMixer, there are only two hyper-parameters as introduced in Section 3: The number of 1-hop most recent neighbors $K$ and the time-slot size $T$ . In practice, hyper-parameter $T$ is set the time-gap of the last 2, 000 interactions, which is fixed for all datasets; hyper-parameter $K = 1 0$ for Reddit and LastFM, $K = 2 0$ for MOOC, and $K = 3 0$ for GDELT and Wiki.
|
| 248 |
+
|
| 249 |
+
Training and evaluation. A unified training and evaluation process (e.g., mini-batch and data preparation) is used for GraphMixer and baselines. Specifically, each mini-batch is constructed by first sampling a set of positive node pairs and an equal amount of negative node pairs. Then, an algorithm-dependent node sampler is used to sample the neighboring of each mini-batch node and computed their node representation based on the sampled neighborhood. Finally, we concatenate each node pair and use the link prediction classifier (introduced in Section 3.1) for binary classification. We conduct experiments under the transduction learning setting and use average precision for evaluation.
|
| 250 |
+
|
| 251 |
+
B MORE DISCUSSION ON EXISTING TEMPORAL GRAPH METHODS
|
| 252 |
+
|
| 253 |
+
# B.1 RECENT METHODS THAT WE DO NOT COMPARE WITH
|
| 254 |
+
|
| 255 |
+
There are other temporal graph learning algorithms that are related to the temporal link prediction task but we did not compare GraphMixer with them because (1) the official implementation of some of the above works are not released by the authors and we could not reproduce their results as reported in the paper, and (2) we already compare many recent baselines that we believe it is enough to verify the success of GraphMixer.
|
| 256 |
+
|
| 257 |
+
For example, MeTA Wang et al. (2021c) proposes data augmentation to overcome the over-fitting issue in temporal graph learning. More specifically, they generate a few graphs with different data augmentation magnitudes and perform the message passing between these graphs to provide adaptively augmented inputs for every prediction. TCL Wang et al. (2021a) proposes to use a transformer to separately extract the temporal neighborhoods representations associated with the two interaction nodes and then utilizes a co-attentional transformer to model inter-dependencies at a semantic level. To boost model performance, contrastive learning is used to maximize mutual information between the predictive representations of two future interaction nodes. TNS Wang et al. (2021d) proposes a temporal-aware neighbor sampling strategy that can provide an adaptive receptive neighborhood for every node at any time. LSTSR Chi et al. (2022) propose Long Short-Term Preference Modeling for Continuous-Time Sequential Recommendation to capture the evolution of short-term preference under dynamic graph. DyRep Trivedi et al. (2019) uses RNNs to propagate messages in interactions to update node representations. DynAERNN Goyal et al. (2018) uses a fully connected layer to first encode the network representation, then pass the encoded features to the RNN, and use the fully connected network to decode the future network structure. VRGNN Hajiramezanali et al. (2019) generalizes variational GAE Kipf & Welling (2016) to temporal graphs, which makes priors dependent on historical dynamics and captures these dynamics using RNN. EvolveGCN Pareja et al. (2020) uses RNN to estimate GCN parameters for future snapshots. DDGCL Tian et al. (2021) is a SAM-based method that propose a debiased GAN-type contrastive loss as the learning objective to correct the sampling bias that occurred in the negative sample construction process of temporal graph learning. NAT Luo & Li (2022) maintain two sets of representations for each node, i.e., node representations and link representations. For each node, NAT not only preserve a node representation, but also keep node pair representations for a subset of neighbors of the node. PINT Souza et al. (2022) using 1-WL test and proposes temporal encoding to boost the expressive power.
|
| 258 |
+
|
| 259 |
+
# B.2 WHY EXISTING METHODS ARE CONCEPTUALLY AND TECHNICALLY COMPLICATED?
|
| 260 |
+
|
| 261 |
+
Please notice that we are not claiming conceptually and technically complicated is bad. Instead, we are simply suggesting that the conceptually and technically complicated simpler methods might be more preferred than the complicated one if they could achieve similar performance.
|
| 262 |
+
|
| 263 |
+
• We say a method is conceptually complicated if the underlying idea behind the method is non-trivial. For example, CAWs represents network dynamics by “motifs extracted using temporal random walks”, represents node identity by “hitting counts of the nodes based on a set of sampled walks”; TGSRec takes “temporal collaborative signals” into consideration. These concepts are non-trivial to understand in the first place and could potentially require much domain knowledge from other fields to understand the behavior of the method. • We say a method is technically complicated if the method is non-trivial to implement due to many hyper-parameters and many details that need to be taken care of, which could potentially make the application to a real-world scenario challenge. For example, JODIE and TGN require maintaining a “memory” for each node by using RNN, and this “memory” needs to be reset every time after evaluation because then it might carry information about the evaluation data. CAWs extracts features by using multiple temporal random walks, which makes implementing and hyper-parameter finetuning more challenging. MeTA and TCL consider many data augmentation strategies, each of which is not trivial to implement and could affect the model’s performance in different ways.
|
| 264 |
+
|
| 265 |
+
# B.3 THEORETICAL WORKS ON TEMPORAL GRAPH LEARNING
|
| 266 |
+
|
| 267 |
+
Recently, researchers have investigated the expressive power of temporal graph neural networks using graph isomorphism tests. For instance, Gao & Ribeiro (2022) have categorized temporal graph learning methods into "time-and-graph" and "time-then-graph" and compared their expressiveness. They have demonstrated that "time-then-graph" outperforms "time-and-graph" in terms of 1-WL test expressive power. This partially explains why GraphMixer has shown good performance, as it can be thought of as a "time-then-graph" algorithm. Additionally, Souza et al. (2022) have shown that incorporating temporal encoding and using the 1-WL test can enhance the expressive power of temporal graph neural networks.
|
| 268 |
+
|
| 269 |
+
# C MORE EXPERIMENT RESULTS
|
| 270 |
+
|
| 271 |
+
# C.1 COMPARISON ON CONVERGENCE SPEED AND GENERALIZATION
|
| 272 |
+
|
| 273 |
+
We include the missing figures of Section 4. Results on other datasets and the discussion on the experiment results could be found next to Figure 3.
|
| 274 |
+
|
| 275 |
+

|
| 276 |
+
Figure 8: Comparison of the link prediction training average precision and generalization gap for the first 100 training epochs. Results on other datasets can be found in Figure 3.
|
| 277 |
+
|
| 278 |
+
# C.2 TRANSDUCTIVE LEARNING WITH RECALL $@ \mathrm { K }$ AND MRR AS EVALUATION METRIC
|
| 279 |
+
|
| 280 |
+
Recall $@ \mathrm { K }$ and MRR (mean reciprocal rank) are popular evaluation metrics used in the real-world recommendation system. The larger the numbers, the better the model performance. Our Recall $@ \mathrm { K }$ and MRR is implemented based on the Open Graph Benchmark’s link prediction evaluation metrics implementation13. More specifically, we first sample 100 negative destination nodes for the source node of each temporal link node pair, then our goal is to rank the positive temporal link node pairs higher than 100 negative destination nodes. In the following, we compare the Recall $\textcircled { \alpha } 5$ and MRR score of GraphMixer with the selected four most representative baselines. Please notice that since these methods are implemented under the same framework, the model performance is evaluated by using the same model used in Table 1, the comparison is guaranteed to be fair.
|
| 281 |
+
|
| 282 |
+
Table 6: Comparison on the Recall $@ \mathrm { K }$ and MRR.
|
| 283 |
+
|
| 284 |
+
<table><tr><td rowspan="2"></td><td colspan="2">Reddit</td><td colspan="2">Wiki</td><td colspan="2">MOOC</td><td colspan="2">LastFM</td><td colspan="2">GDELT</td></tr><tr><td>R@5</td><td>MRR</td><td>R@5</td><td>MRR</td><td>R@5</td><td>MRR</td><td>R@5</td><td>MRR</td><td>R@5</td><td>MRR</td></tr><tr><td>JODIE</td><td>0.9181</td><td>0.6271</td><td>0.9098</td><td>0.7752</td><td>0.9818</td><td>0.7551</td><td>0.2034</td><td>0.1206</td><td>0.8554</td><td>0.6048</td></tr><tr><td>DySAT</td><td>0.9189</td><td>0.7774</td><td>0.8889</td><td>0.7561</td><td>0.9989</td><td>0.7906</td><td>0.4159</td><td>0.3322</td><td>0.8302</td><td>0.4236</td></tr><tr><td>TGAT</td><td>0.9774</td><td>0.8709</td><td>0.8508</td><td>0.6132</td><td>0.9736</td><td>0.7425</td><td>0.1040</td><td>0.0769</td><td>0.3513</td><td>0.2366</td></tr><tr><td>TGN</td><td>0.9787</td><td>0.9093</td><td>0.8878</td><td>0.8016</td><td>0.9904</td><td>0.9904</td><td>0.1649</td><td>0.1153</td><td>0.9297</td><td>0.7295</td></tr><tr><td>GraphMixer</td><td>1.0</td><td>0.9965</td><td>0.9972</td><td>0.9876</td><td>0.9999</td><td>0.9910</td><td>0.9998</td><td>0.9649</td><td>0.9930</td><td>0.8934</td></tr></table>
|
| 285 |
+
|
| 286 |
+
13https://github.com/snap-stanford/ogb/blob/master/ogb/linkproppred/ evaluate.py
|
| 287 |
+
|
| 288 |
+
We have the following observations on Table 1:
|
| 289 |
+
|
| 290 |
+
• According to the results in Table 6, GraphMixer could achieve outstanding performance across all datasets. Especially on the LastFM and GDELT datasets (denser graphs than other datasets). This might implies GraphMixer is more suitable for denser graphs than other baseline methods.
|
| 291 |
+
|
| 292 |
+
• The results of some baseline methods behave less better with Recall $@ \mathrm { K }$ and MRR evaluation metrics. For example, TGN on LastFM dataset, TGAT on LastFM and GDELT, etc. The above results also imply the limitation of only considering average precision and AUC score for temporal link evaluation.
|
| 293 |
+
|
| 294 |
+
# C.3 COMPARISON ON WALL-CLOCK TIME
|
| 295 |
+
|
| 296 |
+
In the following, we compare the wall-clock time it takes for GraphMixer and baselines to finish a single epoch of training.
|
| 297 |
+
|
| 298 |
+
Table 7: Comparison on the wall-clock computation time for single-epoch of training.
|
| 299 |
+
|
| 300 |
+
<table><tr><td></td><td>Reddit</td><td>Wiki</td><td>MOOC</td><td>LastFM</td><td>GDELT</td></tr><tr><td>JODIE</td><td>5 sec</td><td>2 sec</td><td>4 sec</td><td>11 sec</td><td>16 sec</td></tr><tr><td>DySAT</td><td>33 sec</td><td>6 sec</td><td>16 sec</td><td>41 sec</td><td>83 sec</td></tr><tr><td>TGAT</td><td>15 sec</td><td>4 sec</td><td>8 sec</td><td>28 sec</td><td>41 sec</td></tr><tr><td>TGN</td><td>8 sec</td><td>2 sec</td><td>5sec</td><td>15 sec</td><td>32 sec</td></tr><tr><td>CAWs-mean</td><td>1,893 sec</td><td>277 sec</td><td>641 sec</td><td>1,797 sec</td><td>4,544 sec</td></tr><tr><td>CAWs-attn</td><td>1,930 sec</td><td>282 sec</td><td>653 sec</td><td>1,832 sec</td><td>4,634 sec</td></tr><tr><td>TGSRec</td><td>538 sec</td><td>157 sec</td><td>656 sec</td><td>1,810 sec</td><td>3,707 sec</td></tr><tr><td>APAN</td><td>13 sec</td><td>4 sec</td><td>9 sec</td><td>28 sec</td><td>25 sec</td></tr><tr><td>GraphMixer</td><td>12 sec</td><td>3 sec</td><td>7 sec</td><td>21 sec</td><td>32 sec</td></tr></table>
|
| 301 |
+
|
| 302 |
+
When comparing the computation time of GraphMixer with CAWs, TGSRec, and DDGCL, we found that GraphMixer takes significantly lesser time than these baselines, which indicates the effectiveness of GraphMixer. When comparing the computation time of GraphMixer with JODIE, DySAT, TGAT, APAN, and TGN, we found that GraphMixer is very close to or even slightly faster than some baseline methods. Our computation time is slightly slower than other baseline methods (e.g., JODIE and TGN) mainly because these baselines are using well-optimized computation functions from DGL Wang et al. (2019), while GraphMixer is just using a composition of basic PyTorch functions. In fact, according to the Table 8, GraphMixer has a similar/smaller amount of parameters with these baselines.
|
| 303 |
+
|
| 304 |
+
Table 8: Comparison on the number of model parameters.
|
| 305 |
+
|
| 306 |
+
<table><tr><td></td><td>GraphMixer</td><td>GraphMixer-T</td><td>GraphMixer-S</td><td>Jodie</td><td>DySAT</td><td>TGAT</td><td>TGN</td></tr><tr><td>#Parameters (×105)</td><td>2.25</td><td>1.42</td><td>2.07</td><td>1.21</td><td>9.38</td><td>3.80</td><td>3.54</td></tr></table>
|
| 307 |
+
|
| 308 |
+
Besides, our current implementation also need to preprocess the input data for each epoch of training, e.g., sorting nodes in subgraph according to temporal order and removing duplicated edges. For example, the data preparation at each epoch takes 41 sec on Reddit, 9 sec on Wiki, 20 sec on MOOC, $4 8 \ \mathrm { s e c }$ on LastFM, and 71 sec on GDELT. However, by caching the pre-processed data in the memory, we only need to pre-process the input data at the first epoch of the training process because our neighbor selection is deterministic and the input data does not change at each epoch.
|
| 309 |
+
|
| 310 |
+
# C.4 TRANSDUCTIVE LEARNING WITH AUC AS EVALUATION METRIC
|
| 311 |
+
|
| 312 |
+
AUC (Under the ROC Curve) is one of the most widely accepted evaluation metric for link prediction, which has been used in many existing works Xu et al. (2020); Rossi et al. (2020). In the following, we compare the AUC score of GraphMixer with baselines. We have the following observations: $\textcircled{1}$ GraphMixer outperforms all baselines on all datasets. In particular, GraphMixer attains more than $1 \%$ gain over all baselines on the LastFM, GDELT-ne, and GDELT-e datasets, attains around $2 \%$ gain over non-RNN methods $D y S A T$ and TGAT on the Wiki dataset, and attains around $1 1 \%$ gain over non-RNN methods $D y S A T$ and TGAT on the GDELT-ne dataset. The experiment results provide sufficient support on our argument that neither RNN nor SAM is necessary for temporal graph link prediction. $\textcircled{2}$ According to the performance of GraphMixer-L on datasets only have link timestamp information (MOOC, LastFM, and GDELT-ne), we know that our time-encoding function could successfully pre-process each timestamp into a meaningful vector. $\textcircled{3}$ By comparing the performance GraphMixer-N and GraphMixer on Wiki, MOOC, and LastFM datasets, we know that node-info encoder alone is not enough to achieve a good performance. However, it provides useful information that could benefit the link-info encoder. $\textcircled{4}$ By comparing the performance of GraphMixer-N on GDELT and GDELT-ne, we observe that using one-hot encoding outperforms using node features. This also shows the importance of node identity information because one-hot encoding only captures such information.
|
| 313 |
+
|
| 314 |
+
Table 9: Comparison on the AUC score for link prediction. GraphMixer uses one-hot node encoding for datasets without node features (marked by ♮). For each dataset we indicate whether we have the corresponding feature (“L” link features, “N” node features, and “T” link timestamps).
|
| 315 |
+
|
| 316 |
+
<table><tr><td></td><td>Reddit L,T</td><td>Wiki L,T</td><td>MOOC T</td><td>LastFM T</td><td>GDELT L,N,T</td><td>GDELT-ne T</td><td>GDELT-e N,T</td></tr><tr><td>JODIE</td><td>99.30±0.01</td><td>98.81 ± 0.01</td><td>99.16± 0.01</td><td>67.51 ± 1.99</td><td>98.55±0.01</td><td>97.13±0.02</td><td>96.96±0.02</td></tr><tr><td>DySAT</td><td>98.52 ±0.01</td><td>96.71 ±0.02</td><td>98.82 ±0.01</td><td>76.40 ± 0.81</td><td>98.52 ±0.01</td><td>82.47 ± 0.04</td><td>97.25 ±0.02</td></tr><tr><td>TGAT</td><td>99.66 ± 0.01</td><td>97.75 ± 0.02</td><td>98.43±0.01</td><td>54.77 ± 1.02</td><td>98.25 ±0.01</td><td>84.30 ± 0.03</td><td>96.96 ±0.02</td></tr><tr><td>TGN</td><td>99.80 ±0.01</td><td>99.55 ± 0.01</td><td>99.62 ± 0.01</td><td>82.23 ±0.50</td><td>98.15 ±0.01</td><td>97.13 ± 0.02</td><td>96.04± 0.02</td></tr><tr><td>CAWs-mean</td><td>98.18± 0.01</td><td>97.25±0.03</td><td>63.88±0.92</td><td>72.92± 0.33</td><td>95.19±0.09</td><td>71.82 ± 0.08</td><td>91.40± 0.19</td></tr><tr><td>CAWs-attn</td><td>98.30 ±0.01</td><td>97.89 ±0.02</td><td>63.95 ±0.81</td><td>72.93 ± 0.54</td><td>95.13 ± 0.11</td><td>71.82 ±0.08</td><td>91.64± 0.24</td></tr><tr><td>TGSRec</td><td>94.74±0.20</td><td>91.32 ± 0.19</td><td>80.70 ± 2.31</td><td>76.66 ± 1.54</td><td>96.72 ± 0.42</td><td>96.72 ±0.42</td><td>96.72 ± 0.42</td></tr><tr><td>APAN</td><td>99.24±0.01</td><td>97.25 ± 0.01</td><td>98.58 ±0.01</td><td>62.73±0.64</td><td>96.46 ± 0.11</td><td>98.39 ± 0.17</td><td>97.85 ± 0.19</td></tr><tr><td>GraphMixer-L</td><td>99.84± 0.01</td><td>99.70±0.01</td><td>99.87 ± 0.01</td><td>97.04± 0.02</td><td>98.99± 0.02</td><td>96.54±0.02</td><td>98.99± 0.02</td></tr><tr><td>GraphMixer-N</td><td>99.53 ±0.01</td><td>91.49 ± 0.01</td><td>98.66±0.02</td><td>71.51 ± 0.03</td><td></td><td>94.44±0.02 96.00±0.02</td><td>98.81±0.02</td></tr><tr><td>GraphMixer</td><td>99.94±0.01</td><td>99.82 ± 0.01</td><td>99.93 ± 0.01</td><td>97.38± 0.025</td><td>98.89 ±0.02</td><td>98.50±0.02</td><td>98.48±0.02</td></tr></table>
|
| 317 |
+
|
| 318 |
+
# C.5 BASELINES WITH UNDIRECTED TEMPORAL GRAPH
|
| 319 |
+
|
| 320 |
+
GraphMixer utilizes undirected temporal graph to capture whether two nodes are frequently connected in the last few timestamps. In the following, we test whether using undirected temporal graph could improve the performance of baseline methods. As we can see from Table 10, using undirected temporal graph cannot improve the performance of baseline methods much because such information are already implicitly captured via their neural architecture design or sampling methods.
|
| 321 |
+
|
| 322 |
+
Table 10: Comparison on baselines with undirected temporal graph (Average precision | AUC score).
|
| 323 |
+
|
| 324 |
+
<table><tr><td></td><td colspan="2">Reddit</td><td colspan="2">Wiki</td><td colspan="2">MOOC</td><td colspan="2">LastFM</td></tr><tr><td>JODIE</td><td>99.24</td><td>99.40</td><td>98.91</td><td>99.07</td><td>99.18</td><td>99.53</td><td>73.25</td><td>80.24</td></tr><tr><td>DySAT</td><td>98.53</td><td>98.42</td><td>96.61</td><td>96.88</td><td>98.80</td><td>99.26</td><td>76.23</td><td>73.90</td></tr><tr><td>TGAT</td><td>99.70</td><td>99.73</td><td>97.35</td><td>97.68</td><td>98.41</td><td>98.85</td><td>54.58</td><td>57.03</td></tr><tr><td>TGN</td><td>99.84</td><td>99.87</td><td>99.59</td><td>99.61</td><td>99.44</td><td>99.66</td><td>91.96</td><td>93.20</td></tr></table>
|
| 325 |
+
|
| 326 |
+
# D DISCUSSION ABOUT MODEL PERFORMANCE ON LASTFM
|
| 327 |
+
|
| 328 |
+
Our results show that GraphMixer could outperform baselines on LastFM dataset with a large margin, which is due to a composite effect of multiple factors. In the following, we summarize several potential factors that lead to our observation on the model performance.
|
| 329 |
+
|
| 330 |
+
• Larger average time-gap. LastFM has a larger average time-gap $( t _ { \operatorname* { m a x } } - t _ { \operatorname* { m i n } } ) / | \mathcal { E } |$ than other datasets. As shown in the dataset statistic (Table 5), LastFM has an average time gap of 106, which is significantly larger than other datasets. For example, Reddit’s average time gap is 4, Wiki’s average time gap is 17, MOOC’s average time gap is 3.6, and GDELT’s average time gap is 0.1. Since baseline methods are relying on RNN and SAM to process the historical temporal information, they implicitly assumes the temporal information is “smooth” and with smaller average time gap. Therefore, baseline methods could potentially work better on the dataset with a smaller average time gap but are less ideal on LastFM. GraphMixer is not relying on RNN or SAM, therefore could be less affected by the aforementioned issue.
|
| 331 |
+
|
| 332 |
+
• Larger average node degree. LastFM has a larger average node degree $| \mathcal { E } | / | \nu |$ than other datasets, which potentially prone to over-smoothing (aggregating features from many neighbors make output representation less distinguishable Li et al. (2018b)), over-squashing (aggregating much information into a limited memory might compress too much useful information Alon & Yahav (2020)) and over-fitting Cong et al. (2021a) effect. For example, according to the dataset statistic in Table 5, LastFM has an average node degree of 653, which is larger than the Reddit’s average node degree 61, Wiki’s average node degree 17, MOOC’s average node degree 57, and GDELT’s average node degree 216. Existing methods either use the memory cell in RNN to store temporal information or use SAM to aggregate temporal information from multi-hops, which could be less ideal on a dense graph due to over-smoothing and over-squashing. However, GraphMixer is less relying on the aggregation schema, therefore its performance is better than the baseline methods.
|
| 333 |
+
|
| 334 |
+
• Larger maximum timestamp. GraphMixer is using fixed time encoder but baselines are using trainable time-encoders. Since the largest timestamp $t _ { \mathrm { m a x } }$ in LastFM is larger than other datasets, the trainable time-encoder is more affected by the unbounded gradient issue as discussed in Table 2 and Section 4.2. For example, the $t _ { \mathrm { m a x } }$ in LastFM is 137 millon, while $t _ { \mathrm { m a x } }$ in GDELT 0.2 millon, $t _ { \mathrm { m a x } }$ in Reddit 2.6 millon, $t _ { \mathrm { m a x } }$ in Wiki 2.6 millon, and $t _ { \mathrm { m a x } }$ in MOOC 2.6 millon.
|
| 335 |
+
|
| 336 |
+
# E MISSING FIGURES ON LOSS LANDSCAPE
|
| 337 |
+
|
| 338 |
+
# E.1 LOSS LANDSCAPE ON WIKI
|
| 339 |
+
|
| 340 |
+

|
| 341 |
+
Figure 9: Comparison on the training loss landscape (Contour) on Wiki Dataset.
|
| 342 |
+
|
| 343 |
+

|
| 344 |
+
Figure 10: Comparison on the training loss landscape (Surface) on Wiki Dataset.
|
| 345 |
+
|
| 346 |
+

|
| 347 |
+
Figure 11: Comparison on the training loss landscape (Contour) on Reddit Dataset.
|
| 348 |
+
|
| 349 |
+

|
| 350 |
+
Figure 12: Comparison on the training loss landscape (Surface) on Reddit Dataset.
|
| 351 |
+
|
| 352 |
+

|
| 353 |
+
Figure 13: Comparison on the training loss landscape (Contour) on MOOC Dataset.
|
| 354 |
+
|
| 355 |
+

|
| 356 |
+
Figure 14: Comparison on the training loss landscape (Surface) on MOOC Dataset.
|
| 357 |
+
|
| 358 |
+

|
| 359 |
+
Figure 15: Comparison on the training loss landscape (Contour) on LastFM Dataset.
|
| 360 |
+
|
| 361 |
+

|
| 362 |
+
Figure 16: Comparison on the training loss landscape (Surface) on LastFM Dataset.
|
| 363 |
+
|
| 364 |
+

|
| 365 |
+
Figure 17: Comparison on the training loss landscape (Contour) on GDELT-ne Dataset.
|
| 366 |
+
|
| 367 |
+

|
| 368 |
+
Figure 18: Comparison on the training loss landscape (Surface) on GDELT-ne Dataset.
|
| 369 |
+
|
| 370 |
+

|
| 371 |
+
Figure 19: Comparison on the training loss landscape (Contour) on GDELT-e Dataset.
|
| 372 |
+
|
| 373 |
+

|
| 374 |
+
Figure 20: Comparison on the training loss landscape (Surface) on GDELT-e Dataset.
|
| 375 |
+
|
| 376 |
+
# F.1 TGAT WITH FIXED TIME-ENCODING FUNCTION
|
| 377 |
+
|
| 378 |
+

|
| 379 |
+
Figure 21: Training loss landscape (Contour) of TGAT with fixed time-encoding function.
|
| 380 |
+
|
| 381 |
+

|
| 382 |
+
Figure 22: Training loss landscape (Surface) of TGAT with fixed time-encoding function.
|
| 383 |
+
|
| 384 |
+

|
| 385 |
+
Figure 23: Training loss landscape (Contour) of TGN with fixed time-encoding function.
|
| 386 |
+
|
| 387 |
+

|
| 388 |
+
Figure 24: Training loss landscape (Surface) of TGN with fixed time-encoding function.
|
| 389 |
+
|
| 390 |
+

|
| 391 |
+
Figure 25: Training loss landscape (Contour) of JODIE with fixed time-encoding function.
|
| 392 |
+
|
| 393 |
+

|
| 394 |
+
Figure 26: Training loss landscape (Surface) of JODIE with fixed time-encoding function.
|
md/dev/b90lKL1IqcF/b90lKL1IqcF.md
ADDED
|
@@ -0,0 +1,272 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# VoxGRAF: Fast 3D-Aware Image Synthesis with Sparse Voxel Grids
|
| 2 |
+
|
| 3 |
+
Katja Schwarz1 Axel Sauer1 Michael Niemeyer1 Yiyi Liao2 Andreas Geiger1
|
| 4 |
+
|
| 5 |
+
1University of Tübingen and Max Planck Institute for Intelligent Systems, Tübingen 2 Zhejiang University, China
|
| 6 |
+
|
| 7 |
+
# Abstract
|
| 8 |
+
|
| 9 |
+
State-of-the-art 3D-aware generative models rely on coordinate-based MLPs to parameterize 3D radiance fields. While demonstrating impressive results, querying an MLP for every sample along each ray leads to slow rendering. Therefore, existing approaches often render low-resolution feature maps and process them with an upsampling network to obtain the final image. Albeit efficient, neural rendering often entangles viewpoint and content such that changing the camera pose results in unwanted changes of geometry or appearance. Motivated by recent results in voxel-based novel view synthesis, we investigate the utility of sparse voxel grid representations for fast and 3D-consistent generative modeling in this paper. Our results demonstrate that monolithic MLPs can indeed be replaced by 3D convolutions when combining sparse voxel grids with progressive growing, free space pruning and appropriate regularization. To obtain a compact representation of the scene and allow for scaling to higher voxel resolutions, our model disentangles the foreground object (modeled in 3D) from the background (modeled in 2D). In contrast to existing approaches, our method requires only a single forward pass to generate a full 3D scene. It hence allows for efficient rendering from arbitrary viewpoints while yielding 3D consistent results with high visual fidelity. Code and models are available at https://github.com/autonomousvision/voxgraf.
|
| 10 |
+
|
| 11 |
+
# 1 Introduction
|
| 12 |
+
|
| 13 |
+
Generating photorealistic renderings of scenes at high resolution is a long-standing goal in computer vision and graphics. The primary paradigm is to carefully design 3D models, which are then rendered using realistic camera and illumination models. In recent years, the computer vision community has made significant headway towards reducing these design efforts by approaching content generation from a data-centric perspective. Generative Adversarial Networks (GANs) [9] have emerged as a powerful class of generative models for photorealistic high-resolution image synthesis [2, 16, 17, 19, 20, 35, 36]. One benefit of these 2D models is that they can be trained with large collections of images which are readily available. However, scaling GANs to 3D is non-trivial because 3D supervision is difficult to obtain. Recently, $3 D$ -aware GANs have emerged to address the gap between handcrafted 3D models and image synthesis with 2D GANs which lack 3D constraints [4, 13, 23, 29, 30, 37]. 3D-aware GANs combine 3D generators, differentiable rendering and adversarial training to synthesize novel images with explicit control over the camera pose and, potentially, other scene properties like object shape and appearance.
|
| 14 |
+
|
| 15 |
+
Early 3D-aware GANs explored voxel-based 3D representations [13, 29]. To compensate for the cubic memory growth of voxel grids, HoloGAN [29] generates features on a small 3D grid and uses a neural network to map 3D features to a 2D image. While such a neural renderer allows scaling to higher image resolutions, it may also entangle viewpoint and generated content [37].
|
| 16 |
+
|
| 17 |
+

|
| 18 |
+
Figure 1: 3D-aware image synthesis with sparse voxel grids. We investigate neural radiance fields represented as sparse voxel grids in the context of 3D-aware generative modeling. While training from unstructured image collections, our method allows for high quality image synthesis with explicit control over the camera viewpoint. In contrast to previous works, our method generates a 3D scene in a single forward pass allowing for more efficient and 3D-consistent rendering.
|
| 19 |
+
|
| 20 |
+
Consequently, early voxel-based approaches were either limited in image resolution or lacking 3D consistency. About the same time, Neural Radiance Fields (NeRF) [27] emerged in the context of view synthesis as a powerful alternative 3D representation. In their seminal work, Mildenhall et al. [27] represent a scene as a function of color and density, parameterized by a coordinate-based MLP. The predicted color and density values are then projected to an image with differentiable volume rendering. GRAF [38] adapts NeRF’s coordinate-based representation to Generative Radiance Fields (GRAF) and proposes a 3D-aware GAN using a coordinate-based MLP and volume rendering. This propelled 3D-aware image synthesis to higher image resolutions while better preserving 3D consistency due to the physically-based and parameter-free rendering. These benefits led to the establishment of coordinate-based MLPs as new de facto standard for 3D-aware image synthesis [4, 31]. While recent 3D-aware GANs [4, 6, 10] have started to attain image fidelity and resolution similar to 2D GANs, training and inference is computationally expensive as the MLP must be queried at multiple points along each ray for volume rendering. However, querying 3D space densely is prohibitively costly. For example, rendering an image at resolution $2 5 6 ^ { \hat { 2 } }$ using 48 sample points along each ray requires to query the neural network $2 5 6 ^ { 2 } \cdot 4 8 \approx 3 M$ times. As a result, most recent works combine neural and volume rendering to ease computational cost at high resolutions [30]. Consequently, viewpoint and 3D content are often entangled, such that changing the camera pose might result in unwanted changes of the geometry or the appearance of the 3D scene. Further, for many downstream applications, e.g. integrating assets into physics engines, it is desirable to generate 3D content at high resolution directly. These shortcomings identify the need for a 3D representation that can be efficiently rendered at high resolution with a model that is $3 D$ -consistent by design.
|
| 21 |
+
|
| 22 |
+
Recently, there has been significant progress towards accelerated training of novel view synthesis models for single scenes by removing the MLP from the representation. In particular, DVGO [40] and Plenoxels [1] directly optimize a sparse voxel grid for novel-view synthesis, demonstrating that the visual fidelity attained by NeRF [27] is not primarily attributed to its MLP-based representation but rather to volumetric rendering and gradient-based optimization. In addition to impressive image quality, [1, 40] obtain large rendering speedups due to their fast density and color queries. Taking inspiration from these works, we revisit voxel-based representations for 3D-aware GANs [13, 29] in the context of volumetric rendering. To circumvent the cubic memory growth that limits early voxel-based approaches [13, 29], we explore sparse voxel grids for the generative settings, see Fig. 1. We observe that sparsity is key to enable scaling the 3D representation to higher resolution and to combine it with volume rendering. Specifically, we propose a 3D-aware GAN with a sparse voxel grid generator at its core. As a result, our approach inherits fast rendering and trilinear interpolation while being 3D-consistent by design, separating it from other recent 3D-aware GANs [3, 6, 10] which require a forward pass for every point along each camera ray of every view. Another difference to existing 3D-aware GANs is that sparsity is a built-in feature of our representation, mitigating the need for exploiting sophisticated strategies to sample points along camera rays as in [4, 33, 43]. Our final model achieves image fidelity similar to recent 3D-aware GANs leveraging neural rendering while generating high-resolution geometry and improving 3D consistency. During inference, our model only requires a single forward pass which takes up most of the inference time. Once the 3D scene is generated, images can be rendered within milliseconds while existing approaches require another forward pass which is two orders of magnitude slower. We refer to our model as VoxGRAF.
|
| 23 |
+
|
| 24 |
+
# 2 Related Work
|
| 25 |
+
|
| 26 |
+
2D GANs. Rapid progress on Generative Adversarial Networks [9] now enables photorealistic synthesis up to megapixel resolution [2, 16, 18–20, 26, 36]. While the disentangled style-space of StyleGANs [18–20] allows for control over the viewpoint of the generated images to some extent [12, 24, 39, 48], gaining precise 3D-consistent control is still non-trivial due to its lack of physical interpretation and operation in 2D. In contrast, in this work we aim for explicit control over the camera pose by incorporating a 3D representation into the generator.
|
| 27 |
+
|
| 28 |
+
3D-Aware GANs. The first 3D-aware GANs, i.e. GANs that incorporate a 3D representation into the generator model, were voxel-based approaches. Dense grid-based approaches [13, 50] are limited to a lower grid resolution due to their cubic memory growth. Other works combine lower-resolution grids with neural rendering [23, 29] which scale to higher resolutions, but the generated images lack 3D consistency [38]. Recently, GRAF [37] and $\pi$ -GAN combine volume rendering and coordinate-based representations [27] allowing to scale 3D-aware GANs with physically inspired rendering to high resolutions. However, dense ray marching remains computationally expensive and limits image fidelity. GIRAFFE [31] therefore proposes a hybrid rendering approach. They render a low-resolution feature map with ray marching and use a neural renderer to decode it into a high-resolution image. Due to efficiency, this approach has been widely adopted in subsequent works [3,10,15,32,44,47,49]. While some approaches try to counteract introduced inconsistencies, e.g. via dual discrimination [3] or a reconstruction loss [10], we instead propose a model that is $3 D$ -consistent by design and can generate the 3D object at high-resolution.
|
| 29 |
+
|
| 30 |
+
As an alternative to hybrid rendering, GOF [43], ShadeGAN [33] and GRAM [6] focus on reducing the number of query points for volume rendering. While aforementioned methods aim for reducing the number of sample points as querying a large MLP is computationally expensive, we instead use a sparse voxel grid as 3D representation. This allows us to speed up rendering without reducing the sample size as feature querying via trilinear interpolation is fast and can be efficiently implemented via custom CUDA kernels.
|
| 31 |
+
|
| 32 |
+
Sparse 3D Representations. As NeRF requires an optimization time in the order of multiple days per scene, a series of follow-up works [25,34,41,46] propose techniques to speed up this process. The recent works Plenoxels [1] and DVGO [40] demonstrate that sparse voxel grid representations can achieve even faster convergence and higher rendering speed. In addition to efficient rendering, sparse voxel grids enable fast trilinear interpolation when queried beyond their grid resolution. Building on this representation, our approach inherits these benefits. We remark that very recently InstantNGP [28] achieves even faster rendering by combining small MLPs with a multi-resolution hash table. Exploring this representation might be an interesting avenue for future extensions of our work. Note that all of these works focus on novel-view-synthesis for single scenes and require multi-view image supervision. Instead, we propose a generative model that trains with raw image collections and that can generate multiple novel instances at inference.
|
| 33 |
+
|
| 34 |
+
# 3 Method
|
| 35 |
+
|
| 36 |
+
We first provide the necessary background by summarizing the currently dominating paradigm for designing 3D-aware GANs which combines an MLP scene representation and volume rendering as introduced in GRAF [38]. Next, we introduce our sparse voxel-based scene representation which boosts rendering speed while retaining 3D-consistency by design. We refer to our model as VoxGRAF.
|
| 37 |
+
|
| 38 |
+

|
| 39 |
+
Figure 2: VoxGRAF. Conditioned on a camera pose $\xi$ , the foreground generator $\mathbf { G } _ { \theta _ { f } } ^ { f g }$ maps a latent code $\mathbf { z }$ to color values $\mathbf { c } \in \mathbb { R } ^ { 3 \times R _ { G } \times R _ { G } \times R _ { G } }$ and densities $\sigma \in \mathbb { R } ^ { 1 \times R _ { G } \times R _ { G } \times R _ { G } }$ on a sparse voxel grid of resolution $R _ { G }$ . Given camera intrinsics $\mathbf { K }$ and a camera pose $\xi ^ { \prime }$ , a foreground image is obtained using differentiable volume rendering [27]. The values at the sampling points along the camera rays are computed by trilinearly interpolating the voxel grid [1]. The background is generated by a 2D GAN $\mathbf { G } _ { \theta _ { b } } ^ { b _ { g } }$ and combined with the foreground using alpha composition. The discriminator $D _ { \phi }$ compares the generated image $\hat { \bf I }$ to the real image ${ \bf \cal I } ^ { r e a l }$ .
|
| 40 |
+
|
| 41 |
+
# 3.1 3D-aware GANs with Coordinate-Based Scene Representations
|
| 42 |
+
|
| 43 |
+
Recent 3D-aware GANs typically consist of a learned coordinate-based MLP as 3D generator, a deterministic volume rendering step potentially combined with a learned neural renderer in the 2D image domain, and a learned 2D discriminator. Let $G _ { \psi } ^ { M L P }$ denote the 3D generator parameterized by a coordinate-based MLP with learnable parameters $\psi$ . The 3D generator predicts a radiance field defined by color $\mathbf { c } \in [ 0 , 1 ]$ and density values $\sigma \in \mathbb { R } ^ { + }$ . The radiance field is defined at any 3D point $\mathbf { x } \in \mathbb { R } ^ { 3 }$ and for any viewing direction $ { \mathbf { d } } \in \mathbb { S } ^ { 2 }$ . To model different 3D scenes, the generator is additionally conditioned on an $M$ -dimensional latent variable $\mathbf { z } \in \mathcal { N } ( \mathbf { 0 } , \mathbf { 1 } )$ . The inputs $\mathbf { x }$ and $\mathbf { d }$ are projected to higher-dimensional features $\gamma ( \mathbf { x } ) \in L _ { \mathbf { x } }$ and $\gamma ( \mathbf { d } ) \in L _ { \mathbf { d } }$ with a fixed positional encoding to overcome the MLP’s smoothness bias and model high-frequency content $\gamma ( \cdot )$ [27, 42]. Formally,
|
| 44 |
+
|
| 45 |
+
$$
|
| 46 |
+
G _ { \psi } ^ { M L P } : \mathbb { R } ^ { L _ { \mathbf { x } } } \times \mathbb { R } ^ { L _ { \mathbf { d } } } \times \mathbb { R } ^ { M } \to \mathbb { R } ^ { 3 } \times \mathbb { R } ^ { + } \qquad ( \gamma ( \mathbf { x } ) , \gamma ( \mathbf { d } ) , \mathbf { z } ) \mapsto ( \mathbf { c } , \sigma )
|
| 47 |
+
$$
|
| 48 |
+
|
| 49 |
+
In this paper, we challenge this paradigm and investigate a sparse 3D CNN instead of a coordinatebased MLP as generator, as described in the next section.
|
| 50 |
+
|
| 51 |
+
The radiance field is rendered by approximating the intractable volumetric projection integral via numerical integration. First, the generator is queried at $N$ sampling points along each camera ray $r$ yielding colors and densities $\{ ( \mathbf { c } _ { r } ^ { \breve { i } } , \sigma _ { r } ^ { i } ) \} _ { i = 1 } ^ { N }$ . For each camera ray $r$ , these points are projected to an RGB color value $\mathbf { c } _ { r }$ and optionally an alpha mask ${ \bf a } _ { r }$ using alpha composition
|
| 52 |
+
|
| 53 |
+
$$
|
| 54 |
+
\begin{array} { r l } & { \boldsymbol \pi : ( \mathbb { R } ^ { 3 } \times \mathbb { R } ^ { + } ) ^ { N } \to \mathbb { R } ^ { 3 } \qquad \{ ( \mathbf c _ { r } ^ { i } , \sigma _ { r } ^ { i } ) \} \mapsto \mathbf c _ { r } } \\ { \mathbf c _ { r } = \displaystyle \sum _ { i = 1 } ^ { N } T _ { r } ^ { i } \alpha _ { r } ^ { i } \mathbf c _ { r } ^ { i } \quad } & { \mathbf a _ { r } = \displaystyle \sum _ { i = 1 } ^ { N } T _ { r } ^ { i } \alpha _ { r } ^ { i } \quad } & { T _ { r } ^ { i } = \displaystyle \prod _ { j = 1 } ^ { i - 1 } \big ( 1 - \alpha _ { r } ^ { j } \big ) \quad \quad \alpha _ { r } ^ { i } = 1 - \exp \big ( - \sigma _ { r } ^ { i } \delta _ { r } ^ { i } \big ) } \end{array}
|
| 55 |
+
$$
|
| 56 |
+
|
| 57 |
+
where $T _ { r } ^ { i }$ and $\alpha _ { r } ^ { i }$ denote the transmittance and alpha value of sample point $i$ along ray $r$ and $\delta _ { r } ^ { i } = \left. \mathbf { x } _ { r } ^ { i + 1 } - \mathbf { x } _ { r } ^ { i } \right. _ { 2 }$ is the distance between neighboring sample points. As volume rendering has proven a powerful tool for high-fidelity reconstruction, VoxGRAF retains this rendering mechanism but reduces its computational cost by leveraging sparse scene representations.
|
| 58 |
+
|
| 59 |
+
# 3.2 VoxGRAF: Generating Radiance Fields on Sparse Voxel Grids
|
| 60 |
+
|
| 61 |
+
Our goal is to design a 3D-aware GAN based on a sparse scene representation that allows for efficient rendering. Fig. 2 shows an overview over our approach. In contrast to recent works [3, 6, 43], we do not use a coordinate-based MLP to parameterize the radiance field. Instead, inspired by recent work on novel view synthesis [1, 40], we generate values on a sparse voxel grid using a 3D convolutional neural network. Therefore, our generator requires only a single forward pass to generate a 3D scene. To disentangle 3D content from the background we combine a 3D foreground generator $\mathbf { G } _ { \theta _ { f } } ^ { f g }$ with a 2D background generator $\mathbf { G } _ { \theta _ { b } } ^ { b g }$ . Gf gθf takes a camera matrix $\mathbf { K }$ , camera pose $\xi$ and a latent code $\mathbf { z }$ as input and predicts colors c and density values $\sigma$ on a sparse voxel grid. For unstructured images, camera matrix $\mathbf { K }$ and pose $\xi$ can be determined e.g. with an off-the-shelf pose detector as done in [4]. Volume rendering yields a foreground image and an alpha mask. The background generator maps the latent code $\mathbf { z }$ to a background image which is then combined with the foreground image using alpha composition. We train our model in an adversarial setting using a 2D discriminator on the full image.
|
| 62 |
+
|
| 63 |
+

|
| 64 |
+
Figure 3: Pruning and Progressive Growing. A sparse representation is key for scaling voxel grids to high resolution. To sparsify the generated voxel grids, we combine density-based pruning (a) and progressive growing (b) while training our model. See text for details.
|
| 65 |
+
|
| 66 |
+
Foreground Generator. Our foreground generator builds on the popular StyleGAN2 architecture [19] which achieves high fidelity in the 2D image domain. Conditioned on a camera pose $\boldsymbol { \xi } \in \mathbb { R } ^ { P }$ , it maps a latent code $\mathbf { z }$ to color values c and density values $\sigma$ on a sparse voxel grid
|
| 67 |
+
|
| 68 |
+
$$
|
| 69 |
+
\begin{array} { r l } { \mathbf { G } _ { \theta _ { f } } ^ { f g } : } & { { } \mathbb { R } ^ { M } \times \mathbb { R } ^ { P } \mathbb { R } ^ { 3 \times R _ { G } \times R _ { G } \times R _ { G } } \times \mathbb { R } ^ { 1 \times R _ { G } \times R _ { G } \times R _ { G } } \quad ( \mathbf { z } , \xi ) \mapsto ( \mathbf { c } , \sigma ) } \end{array}
|
| 70 |
+
$$
|
| 71 |
+
|
| 72 |
+
where $\theta _ { f }$ and $R _ { G }$ denote the learnable parameters and the resolution of the voxel grid, respectively. Note that in contrast to most existing coordinate-based 3D-aware GANs, see Eq. (1), we do not condition the 3D generator on the view direction (per-ray). Instead, we follow [3] and condition it on the pose $\boldsymbol { \xi }$ (per-image) to model directional dependencies. For rendering, we compute $( \mathbf { c } _ { r } ^ { i } , \sigma _ { r } ^ { i } )$ via trilinear interpolation of densities and colors stored at the nearest eight vertices [1]. We use the same rendering formulation outlined in 3.1 and leverage custom CUDA kernels1 for efficiency.
|
| 73 |
+
|
| 74 |
+
To generate voxel grids instead of images, we replace all 2D operations of the StyleGAN2 generator with their 3D equivalent, e.g., 3D modulated convolutions and 3D upsampling. At resolutions beyond $3 2 ^ { 3 }$ , we investigate sparse convolutions [11] instead of dense ones as they can be more computationally efficient. We compare the computational efficiency of sparse convolutions2 to dense convolutions for which we zero out the values of pruned voxels. For our architecture, using sparse convolutions reduces the memory consumption but due to the computational overhead for managing coordinates increases the runtime, see Table 1. To sparsify the representation, we combine progressive growing [16] with pruning [1] as illustrated in Fig. 3a. Specifically, we start with training a dense model at resolution $\mathrm { \dot { 3 2 } ^ { 3 } }$ . After sufficient training, we add the next layer of convolutions and prune its inputs based on the rendered view. Intuitively, the next layer should only operate on voxels visible in the rendered view to yield a sparse representation. Consequently, we prune voxels that are either occluded or have a low density. Following Eq. (2), the rendered alpha value is $\begin{array} { r } { \mathbf { a } _ { r } = \sum _ { i = 1 } ^ { N } T _ { r } ^ { i } \alpha _ { r } ^ { i } } \end{array}$ Accordingly, occluded voxels (low transmittance $T _ { i }$ ) and empty voxels (low density $\sigma _ { i }$ ) do not contribute to the final image. The pruning operator $\rho$ discards all voxels along a camera ray $r$ for which transmittance $T ^ { i }$ or density $\sigma _ { i }$ is smaller than threshold $\tau _ { T }$ or $\tau _ { \sigma }$ , respectively. Let $\mathcal { V } _ { r }$ denote the set of voxels intersecting with ray $\mathbf { r }$ , then
|
| 75 |
+
|
| 76 |
+
$$
|
| 77 |
+
\rho : \mathcal { V } _ { r } \mapsto \mathcal { V } _ { r } ^ { p } \qquad \mathcal { V } _ { r } ^ { p } = \{ i \in \mathcal { V } _ { r } | ( T _ { i } > \tau _ { T } ) \wedge ( \sigma _ { i } > \tau _ { \sigma } ) \}
|
| 78 |
+
$$
|
| 79 |
+
|
| 80 |
+
where $\mathcal { V } _ { r } ^ { p }$ is the set of the retained voxels. After pruning, we upsample the kept voxels via sparse transposed convolutions. After the newly-added layer is sufficiently trained, we repeat this process for the next added stage. Fig. 3b shows images and voxel grids at different resolutions. We implement this on-the-fly pruning operation using efficient custom CUDA kernels.
|
| 81 |
+
|
| 82 |
+
In agreement with [3], we observe that it is crucial to account for view dependent effects or posecorrelated attributes in the training data, like eyes always looking into the camera. We take two measures to increase the flexibility of our model: Following [3], $\bar { \mathbf { G } } _ { \theta _ { f } } ^ { f g }$ is conditioned on the pose $\xi$ which corresponds to the rendering pose $\xi ^ { \prime }$ in $5 0 \%$ of the cases and is randomly chosen otherwise. Formally, $\xi \sim p _ { \xi } | _ { p ( \xi = \xi ^ { \prime } ) = 0 . 5 }$ . At inference, the pose-conditioning is fixed to retain 3D consistency. However, we find that pose conditioning alone is not always sufficient to account for strong correlations in the data. Depending on the dataset, we optionally refine the rendered image with a shallow 2D CNN with 2 hidden layers of dimension 16 and kernel size 3. While this refinement is powerful enough to model dataset biases, it is considerably less flexible than the neural rendering used in [4, 10, 30]: Our 2D CNN operates on the rendered image instead of rendered features at smaller resolution. Operating on 3 channels at full resolution allows to keep its capacity at a minimum and, due to not using any upsampling operation, results in a local receptive field.
|
| 83 |
+
|
| 84 |
+
Background Generator. We consider datasets with a single object per image. Modeling only the object in 3D saves computation and is advantageous for potential downstream tasks, e.g., integrating generated assets into new environments Hence, we model the object in 3D and generate the background of the image with a 2D GAN. Specifically, we use the StyleGAN2 generator [19] with reduced channel size as modeling the background requires less capacity than generating the full image:
|
| 85 |
+
|
| 86 |
+
$$
|
| 87 |
+
\mathbf { G } _ { \theta _ { b } } ^ { b g } : \quad \mathbb { R } ^ { M } \to \mathbb { R } ^ { 3 \times R _ { I } \times R _ { I } } \quad \mathbf { z } \mapsto \hat { \mathbf { I } } ^ { b g }
|
| 88 |
+
$$
|
| 89 |
+
|
| 90 |
+
We choose the same latent code $\mathbf { z }$ for foreground and background to allow for modeling correlations like lighting between the two. Note that, unlike the foreground generator, the background generator is not conditioned on the camera pose. As the background remains fixed when changing the camera pose, the generator is encouraged to model pose-dependent content with the foreground generator leading to disentanglement (see supp. mat. for qualitative disentanglement results).
|
| 91 |
+
|
| 92 |
+
The final image is obtained using alpha composition
|
| 93 |
+
|
| 94 |
+
$$
|
| 95 |
+
\hat { \bf I } = \hat { \bf I } _ { m a s k } ^ { f g } \cdot \hat { \bf I } ^ { f g } + ( 1 - \hat { \bf I } _ { m a s k } ^ { f g } ) \cdot \hat { \bf I } ^ { b g }
|
| 96 |
+
$$
|
| 97 |
+
|
| 98 |
+
The full generator is defined as
|
| 99 |
+
|
| 100 |
+
$$
|
| 101 |
+
\begin{array} { r l } { \mathbf { G } _ { \theta } : } & { { } \mathbb { R } ^ { M } \times \mathbb { R } ^ { P } \times \mathbb { R } ^ { P } \times \mathbb { R } ^ { K } \mathbb { R } ^ { 3 \times R _ { I } \times R _ { I } } \quad ( \mathbf { z } , \xi , \xi ^ { \prime } , \mathbf { K } ) \mapsto \hat { \mathbf { I } } } \end{array}
|
| 102 |
+
$$
|
| 103 |
+
|
| 104 |
+
Regularization. For fast rendering, it is crucial that most generated voxels are either fully opaque or empty such that early stopping and empty space skipping are effective. By regularizing the variance of the expected depth $\hat { z } _ { r }$ along each ray $r$ , the foreground generator is encouraged to generate a single, sharp surface:
|
| 105 |
+
|
| 106 |
+
$$
|
| 107 |
+
\hat { z } = \sum _ { i } T _ { i } \alpha _ { i } z _ { i } \qquad V a r ( \hat { z } ) = \frac { 1 } { \sum _ { i } T _ { i } \alpha _ { i } } \sum _ { j } T _ { j } \alpha _ { j } ( z _ { j } - \hat { z } ) ^ { 2 }
|
| 108 |
+
$$
|
| 109 |
+
|
| 110 |
+
$$
|
| 111 |
+
\mathcal { L } _ { D V } = \lambda _ { D V } \operatorname* { m a x } ( V a r ( \hat { z } ) , \tau )
|
| 112 |
+
$$
|
| 113 |
+
|
| 114 |
+
where $\tau$ is a hyperparameter that defines the thickness of the surface. We find that thresholding the loss $\mathcal { L } _ { T V }$ portant to avoid an empty foreground. In addition, we find thatfrom [1] and fore- and background coverage regularization $\mathcal { L } _ { c v g } ^ { f g }$ ng thand $\hat { \mathcal { L } } _ { c v g } ^ { b g }$ TV regularizationfrom [45] further stabilizes training (see sup. mat. for details). The full regularization term of our generator is
|
| 115 |
+
|
| 116 |
+
$$
|
| 117 |
+
\mathcal { L } _ { \mathrm { r e g } } = \mathcal { L } _ { D V } + \mathcal { L } _ { T V } + \mathcal { L } _ { c v g } ^ { f g } + \mathcal { L } _ { c v g } ^ { b g }
|
| 118 |
+
$$
|
| 119 |
+
|
| 120 |
+
Discriminator. We use the StyleGAN2 discriminator and condition it on the camera pose as proposed in [3]. Similarly, we find that conditioning guides the generator to learn correct 3D priors and a canonical representation. Since rendering our sparse representation is fast, our discriminator is able to operate on the full image and does not need to consider image patches as done in GRAF [38].
|
| 121 |
+
|
| 122 |
+
# 3.3 Training
|
| 123 |
+
|
| 124 |
+
Given images $\mathbf { I }$ from the data distribution $p _ { \mathcal { D } }$ with known camera extrinsics $\xi _ { \mathbf { I } }$ and intrinsics $\mathbf { K } _ { \mathbf { I } }$ and latent codes $\mathbf { z } \in \mathcal { N } ( \mathbf { 0 } , \mathbf { 1 } )$ , we train our model using a GAN objective with R1-regularization [26]
|
| 125 |
+
|
| 126 |
+
$$
|
| 127 |
+
\begin{array} { r l } & { V ( \theta , \phi ) = \mathbb { E } _ { \mathbf { z } \sim \mathcal { N } ( 0 , \mathbf { 1 } ) , \xi , \xi ^ { \prime } \sim p _ { \xi } } \left[ f ( - D _ { \phi } \left( G _ { \theta } ( \mathbf { z } , \xi , \xi ^ { \prime } , \mathbf { K } ) , \xi ^ { \prime } \right) ) \right] } \\ & { \qquad + \ \mathbb { E } _ { \mathbf { I } \sim p _ { \mathcal { D } } } \left[ f ( D _ { \phi } ( \mathbf { I } , \xi _ { \mathbf { I } } ) ) - \lambda \Vert \nabla D _ { \phi } ( \mathbf { I } , \xi _ { \mathbf { I } } ) \Vert ^ { 2 } \right] } \end{array}
|
| 128 |
+
$$
|
| 129 |
+
|
| 130 |
+
where $f ( t ) = - \log ( 1 + \exp ( - t ) )$ and $\lambda$ controls the strength of the R1-regularizer. $G _ { \theta }$ and $D _ { \phi }$ are trained with alternating gradient descent combining the GAN objective with the regularization terms:
|
| 131 |
+
|
| 132 |
+
$$
|
| 133 |
+
\operatorname* { m i n } _ { \theta } \operatorname* { m a x } _ { \phi } \quad \quad V ( \theta , \phi ) + \mathcal { L } _ { r e g } ( \theta )
|
| 134 |
+
$$
|
| 135 |
+
|
| 136 |
+
In practice, we optimize the generator with a non-saturating variant of Eq. (12) [9]. We train our approach with Adam [21] using a batch size of 64 at grid resolution $R _ { G } = 3 2 $ , 64 and 32 at $R _ { G } = 1 2 8$ . We use a learning rate of 0.0025 for the generator and 0.002 for the discriminator. For faster training, we first grow $R _ { I }$ from 32 to 128 while keeping $R _ { G }$ at 32. Then, we alternately increase the grid resolution and the image resolution until the dataset resolution and $R _ { G } = 1 2 8$ are reached. For synthetic datasets, i.e. Carla [38], we do not add any refinement layers. Depending on the dataset, we train our models for 3 to 7 days on 8 Tesla V100 GPUs. Details on the network architectures can be found in the supplemental material.
|
| 137 |
+
|
| 138 |
+
# 4 Results
|
| 139 |
+
|
| 140 |
+
Datasets. We validate our approach on standard benchmark datasets for 3D-aware image synthesis. The synthetic Carla dataset [8, 37] contains 10k images and camera poses of 18 car models with randomly sampled colors. FFHQ [19] comprises 70k aligned face images. AFHQv2 Cats [5] consists of 4834 cat faces. Following [4], we estimate camera poses for both datasets with off-the-shelf pose estimators [7, 22] and augment all datasets with horizontal flips. Due to the limited number of images in AFHQv2 and Carla, we use adaptive discriminator augmentation [17] for these datasets.
|
| 141 |
+
|
| 142 |
+
Evaluation Metrics. We measure image fidelity by calculating the Fréchet Inception Distance $( F I D )$ [14] between 20k generated images and the full dataset. For all runtime comparisons, we report times on a single Tesla V100 GPU with a batch size of 1.
|
| 143 |
+
|
| 144 |
+
# 4.1 Ablation Study
|
| 145 |
+
|
| 146 |
+
We investigate the sparsity of the generated voxel grids and validate the importance of the depth variance loss, see Eq. (8). Sparsity is evaluated by fusing the pruned voxel grids from 16 equally spaced camera views and reporting the number of empty voxels divided by the total number of voxels $\dot { R } _ { G } ^ { 3 }$ . Table 1 shows results averaged over 100 instances. The depth variance loss increases sparsity from $7 4 \%$ to ${ \bar { 9 } } 5 \%$ , lowering the memory consumption. With the sparser representation, the times needed for scene generation $t _ { G ^ { f g + b g } }$ and rendering $t _ { \pi }$ are reduced significantly. We
|
| 147 |
+
|
| 148 |
+
<table><tr><td></td><td>Sparsity [%]</td><td>Memory [GB]</td><td>tGfg+bg [ms]</td><td>tπ [ms]</td></tr><tr><td>w/o LDv</td><td>74</td><td>1.4</td><td>229</td><td>7</td></tr><tr><td>w LDV.</td><td>95</td><td>0.9</td><td>198</td><td>4</td></tr><tr><td>w LDv+</td><td>95</td><td>1.1</td><td>58</td><td>4</td></tr></table>
|
| 149 |
+
|
| 150 |
+
Table 1: Regularization. We compare sparsity and rendering time with and without depth variance regularization $\mathcal { L } _ { \mathcal { D V } }$ on FFHQ with $R _ { G } =$ 128 and $R _ { I } = 1 2 8$ . † denotes an architecture with dense convolutions where values of pruned voxels are set to zero.
|
| 151 |
+
|
| 152 |
+
further compare an implementation with dense instead of sparse convolutions where we zero out the values of pruned voxels. While this increases memory consumption, it reduces the runtime due to the computational overhead of managing coordinates for sparse convolutions. We prioritize faster training over memory and hence train our models with dense convolutions where we set values of pruned voxels to zero.
|
| 153 |
+
|
| 154 |
+
# 4.2 Baseline Comparison
|
| 155 |
+
|
| 156 |
+
Baselines. We group the baselines into two categories: (i) methods that render low-resolution features and use 2D-upsampling, i.e. a neural renderer, to obtain the final image, e.g. StyleNeRF [10], and (ii) methods that render the 3D representation directly at the final image resolution, e.g. π- GAN [4]. VoxGRAF falls into the second group. We use the official code release for all methods. Further, we reference numbers reported by concurrent works GRAM [6] and EG3D [3].
|
| 157 |
+
|
| 158 |
+
Qualitative Results. Fig. 4 shows samples from multiple views for StyleNeRF, GRAM and VoxGRAF on FFHQ at resolution $2 5 6 ^ { 2 }$ . StyleNeRF can generate additional faces or strands of hair across views, as indicated by the red frames in Fig. 4. These inconsistencies under viewpoint changes are introduced by StyleNeRF’s powerful neural renderer. GRAM achieves more consistent results, but its plane representation creates stripe artifacts for large viewpoint ranges. Due to the shallow 2D CNN, VoxGRAF can model the dataset bias of eyes looking into the camera but otherwise achieves high 3D-consistency even under large viewing angles. Additional samples of our method and the corresponding sparse voxel grids for all datasets are provided in Fig. 1 and Fig. 5.
|
| 159 |
+
|
| 160 |
+

|
| 161 |
+
Figure 4: Qualitative Comparison on Multi-View Consistency. We compare multi-view consistency of state-of-the-art baselines and our method. While StyleNeRF’s powerful neural renderer can introduce multi-view inconsistencies (appearing faces, moving strands of hair), GRAM’s manifold representation becomes visible in layered artifacts for steeper viewing angles. In contrast, our method leads to more multi-view consistent results.
|
| 162 |
+
|
| 163 |
+
Table 2: Quantitative Comparison. We compare against state-of-the-art methods with a neural rendering pipeline (first block) and without one (second block). We report FID [14] between 20k generated images and the full dataset.
|
| 164 |
+
|
| 165 |
+
<table><tr><td>FFHQ[19] AFHQ[5]Carla [38] R1=256² R=256² R=128²</td></tr><tr><td>GIRAFFE [31] 31.5 16.1 1 VolumeGAN[44]</td></tr><tr><td>9.1 7.9 1 8.0 1 1</td></tr><tr><td>StyleNeRF[10] EG3D [3] 4.8 3.9 1</td></tr><tr><td>GRAF[38] 71 121 41</td></tr><tr><td>π-GAN [4] 85 47 29.2</td></tr><tr><td>GOF[43] 69.2 54.1 29.3</td></tr><tr><td>GRAM[6] 17.9 18.5 26.3 VoxGRAF 9.6 9.6 6.7</td></tr></table>
|
| 166 |
+
|
| 167 |
+
Table 3: Rendering times. We report time in ms per image. Note that our method allows for separating scene generation (first number) and rendering (second number) which is useful for real-time rendering applications. $\mathrm { ^ { * } E G 3 D }$ is evaluated on a faster GPU (RTX 3090 GPU) compared to the others (Tesla V100 GPU).
|
| 168 |
+
|
| 169 |
+
<table><tr><td>R =128²</td><td>R1=256²</td></tr><tr><td>GIRAFFE [30]</td><td>5</td></tr><tr><td>StyleNeRF[10]</td><td>49</td></tr><tr><td>EG3D*[3] 1</td><td>27</td></tr><tr><td>GRAF [38] 219</td><td>878</td></tr><tr><td>π-GAN [4] 154</td><td>608</td></tr><tr><td>GOF[43] 199</td><td>742</td></tr><tr><td>GRAM[6] 136</td><td>418</td></tr><tr><td>VoxGRAF 58+3</td><td>58+6</td></tr></table>
|
| 170 |
+
|
| 171 |
+
Quantitative Results. Table 2 reports FID on all datasets. As expected, methods that use neural rendering with upsampling, i.e., StyleNeRF and EG3D, perform best in terms of image fidelity. This is expected as a neural renderer can add flexibility. But, as shown in Fig. 4, for StyleNeRF it reduces 3D-consistency. Among methods without a neural renderer, VoxGRAF significantly improves over $\pi$ -GAN and GOF and surpasses the current state-of-the-art approach GRAM.
|
| 172 |
+
|
| 173 |
+

|
| 174 |
+
Figure 5: Qualitative Results for our Method. We show generated images at resolution $2 5 6 ^ { 2 }$ for FFHQ [19] and AFHQ [5] and samples at resolution $1 2 8 ^ { 2 }$ for Carla [38].
|
| 175 |
+
|
| 176 |
+
Runtime Comparison. Lastly, we compare the rendering times at inference for methods with and methods without a neural renderer. In contrast to all baselines, VoxGRAF requires only a single forward pass to generate the scene, which can then be rendered from different viewpoints efficiently. Note that at inference, voxels are pruned solely based on their density to amortize the rendering costs per scene. We find that this does not visibly affect the rendered images. We report the times for generating the scene and rendering one view separately in Table 3. One of the earliest works, GIRAFFE, is the fastest among all approaches as it renders a low-resolution feature volume and uses comparably small neural networks. StyleNeRF significantly increases the neural renderer’s size to improve image fidelity, which comes at the cost of speed compared to GIRAFFE. Yet, StyleNeRF is the fastest approach for generating a single image among the best-performing methods. However, a potential application of 3D-aware GANs is generating novel views of a single instance in real-time. In this setting, at resolution $2 5 6 ^ { 2 }$ , VoxGRAF generates novel views at 167 FPS, whereas StyleNeRF runs at 20 FPS as its rendering costs are not amortized per scene.
|
| 177 |
+
|
| 178 |
+
# 5 Limitations and Discussion
|
| 179 |
+
|
| 180 |
+
In this work, we investigate sparse voxel grids as representation for 3D-aware image synthesis. We find that the key to generating sparse voxel grids is to combine progressive growing, pruning, and regularization to encourage a sharp surface that can be rendered efficiently. Our approach outperforms all methods that do not employ a neural renderer. Instead of discarding neural rendering entirely, we find it advantageous to utilize a shallow CNN for refinement. This CNN can model dataset bias but is significantly weaker than standard neural rendering approaches that upsample low resolution feature maps. Our approach can reduce the gap to models that build heavily on neural rendering, yet a trade-off between 3D-consistency and image fidelity remains. Whether a certain amount of neural rendering is inherently needed to reach best performance is an important direction for future research. Lastly, the speed of our method depends on the sparsity of the modeled scene. Therefore, rendering times will likely increase on more complex datasets than those commonly used in literature.
|
| 181 |
+
|
| 182 |
+
# Acknowledgments and Disclosure of Funding
|
| 183 |
+
|
| 184 |
+
We acknowledge the financial support by the BMWi in the project KI Delta Learning (project number 19A19013O), the support from the BMBF through the Tuebingen AI Center (FKZ:01IS18039A), and the support of the DFG under Germany’s Excellence Strategy (EXC number 2064/1 - Project number 390727645). Andreas Geiger and Michael Niemeyer were supported by the ERC Starting Grant LEGO-3D (850533). We thank the International Max Planck Research School for Intelligent Systems (IMPRS-IS) for supporting Katja Schwarz and Michael Niemeyer. This work was supported by an NVIDIA research gift. We thank Christian Reiser for the helpful discussions and suggestions. Lastly, we would like to thank Nicolas Guenther for his general support.
|
| 185 |
+
|
| 186 |
+
# References
|
| 187 |
+
|
| 188 |
+
[1] Alex Yu and Sara Fridovich-Keil, M. Tancik, Q. Chen, B. Recht, and A. Kanazawa. Plenoxels: Radiance fields without neural networks. Proc. IEEE Conf. on Computer Vision and Pattern Recognition (CVPR), 2022. 2, 3, 4, 5, 6
|
| 189 |
+
[2] A. Brock, J. Donahue, and K. Simonyan. Large scale GAN training for high fidelity natural image synthesis. In Proc. of the International Conf. on Learning Representations (ICLR), 2019. 1, 3
|
| 190 |
+
[3] E. R. Chan, C. Z. Lin, M. A. Chan, K. Nagano, B. Pan, S. D. Mello, O. Gallo, L. Guibas, J. Tremblay, S. Khamis, T. Karras, and G. Wetzstein. Efficient geometry-aware 3D generative adversarial networks. In Proc. IEEE Conf. on Computer Vision and Pattern Recognition (CVPR), 2022. 2, 3, 4, 5, 6, 7, 8
|
| 191 |
+
[4] E. R. Chan, M. Monteiro, P. Kellnhofer, J. Wu, and G. Wetzstein. Pi-gan: Periodic implicit generative adversarial networks for 3d-aware image synthesis. In Proc. IEEE Conf. on Computer Vision and Pattern Recognition (CVPR), 2021. 1, 2, 3, 5, 6, 7, 8
|
| 192 |
+
[5] Y. Choi, Y. Uh, J. Yoo, and J.-W. Ha. Stargan v2: Diverse image synthesis for multiple domains. In Proc. IEEE Conf. on Computer Vision and Pattern Recognition (CVPR), 2020. 7, 8, 9
|
| 193 |
+
[6] Y. Deng, J. Yang, J. Xiang, and X. Tong. Gram: Generative radiance manifolds for 3d-aware image generation. In Proc. IEEE Conf. on Computer Vision and Pattern Recognition (CVPR), 2022. 2, 3, 4, 7, 8
|
| 194 |
+
[7] Y. Deng, J. Yang, S. Xu, D. Chen, Y. Jia, and X. Tong. Accurate 3d face reconstruction with weakly-supervised learning: From single image to image set. In Proc. IEEE Conf. on Computer Vision and Pattern Recognition (CVPR) Workshops, 2019. 7
|
| 195 |
+
[8] A. Dosovitskiy, G. Ros, F. Codevilla, A. Lopez, and V. Koltun. CARLA: An open urban driving simulator. In Proc. Conf. on Robot Learning (CoRL), 2017. 7
|
| 196 |
+
[9] I. J. Goodfellow, J. Pouget-Abadie, M. Mirza, B. Xu, D. Warde-Farley, S. Ozair, A. C. Courville, and Y. Bengio. Generative adversarial nets. In Advances in Neural Information Processing Systems (NIPS), 2014. 1, 3, 7
|
| 197 |
+
[10] J. Gu, L. Liu, P. Wang, and C. Theobalt. Stylenerf: A style-based 3d-aware generator for high-resolution image synthesis. Proc. of the International Conf. on Learning Representations (ICLR), 2022. 2, 3, 6, 7, 8
|
| 198 |
+
[11] J. Gwak, C. B. Choy, and S. Savarese. Generative sparse detection networks for 3d single-shot object detection. In Proc. of the European Conf. on Computer Vision (ECCV), 2020. 5
|
| 199 |
+
[12] E. Härkönen, A. Hertzmann, J. Lehtinen, and S. Paris. Ganspace: Discovering interpretable GAN controls. arXiv.org, 2020. 3
|
| 200 |
+
[13] P. Henzler, N. J. Mitra, , and T. Ritschel. Escaping plato’s cave: 3d shape from adversarial rendering. In Proc. of the IEEE International Conf. on Computer Vision (ICCV), 2019. 1, 2, 3
|
| 201 |
+
[14] M. Heusel, H. Ramsauer, T. Unterthiner, B. Nessler, and S. Hochreiter. Gans trained by a two time-scale update rule converge to a local nash equilibrium. In Advances in Neural Information Processing Systems (NIPS), 2017. 7, 8
|
| 202 |
+
[15] K. Jo, G. Shim, S. Jung, S. Yang, and J. Choo. Cg-nerf: Conditional generative neural radiance fields. arXiv.org, 2021. 3
|
| 203 |
+
[16] T. Karras, T. Aila, S. Laine, and J. Lehtinen. Progressive growing of GANs for improved quality, stability, and variation. In Proc. of the International Conf. on Learning Representations (ICLR), 2018. 1, 3, 5
|
| 204 |
+
[17] T. Karras, M. Aittala, J. Hellsten, S. Laine, J. Lehtinen, and T. Aila. Training generative adversarial networks with limited data. In Advances in Neural Information Processing Systems (NeurIPS), 2020. 1, 7
|
| 205 |
+
[18] T. Karras, M. Aittala, S. Laine, E. Härkönen, J. Hellsten, J. Lehtinen, and T. Aila. Aliasfree generative adversarial networks. In Advances in Neural Information Processing Systems (NeurIPS), 2021. 3
|
| 206 |
+
[19] T. Karras, S. Laine, and T. Aila. A style-based generator architecture for generative adversarial networks. In Proc. IEEE Conf. on Computer Vision and Pattern Recognition (CVPR), 2019. 1, 3, 5, 6, 7, 8, 9
|
| 207 |
+
[20] T. Karras, S. Laine, M. Aittala, J. Hellsten, J. Lehtinen, and T. Aila. Analyzing and improving the image quality of StyleGAN. Proc. IEEE Conf. on Computer Vision and Pattern Recognition (CVPR), 2020. 1, 3
|
| 208 |
+
[21] D. P. Kingma and J. Ba. Adam: A method for stochastic optimization. In Proc. of the International Conf. on Learning Representations (ICLR), 2015. 7
|
| 209 |
+
[22] T. B. Lee. Cat hipsterizer, 2018. 7
|
| 210 |
+
[23] Y. Liao, K. Schwarz, L. Mescheder, and A. Geiger. Towards unsupervised learning of generative models for 3d controllable image synthesis. In Proc. IEEE Conf. on Computer Vision and Pattern Recognition (CVPR), 2020. 1, 3
|
| 211 |
+
[24] H. Ling, K. Kreis, D. Li, S. W. Kim, A. Torralba, and S. Fidler. Editgan: High-precision semantic image editing. In Advances in Neural Information Processing Systems (NeurIPS), 2021. 3
|
| 212 |
+
[25] L. Liu, J. Gu, K. Z. Lin, T. Chua, and C. Theobalt. Neural sparse voxel fields. In Advances in Neural Information Processing Systems (NeurIPS), 2020. 3
|
| 213 |
+
[26] L. Mescheder, A. Geiger, and S. Nowozin. Which training methods for gans do actually converge? In Proc. of the International Conf. on Machine learning (ICML), 2018. 3, 6
|
| 214 |
+
[27] B. Mildenhall, P. P. Srinivasan, M. Tancik, J. T. Barron, R. Ramamoorthi, and R. Ng. NeRF: Representing scenes as neural radiance fields for view synthesis. In Proc. of the European Conf. on Computer Vision (ECCV), 2020. 2, 3, 4
|
| 215 |
+
[28] T. Müller, A. Evans, C. Schied, and A. Keller. Instant neural graphics primitives with a multiresolution hash encoding. ACM Trans. on Graphics, 2022. 3
|
| 216 |
+
[29] T. Nguyen-Phuoc, C. Li, L. Theis, C. Richardt, and Y.-L. Yang. Hologan: Unsupervised learning of 3d representations from natural images. In Proc. of the IEEE International Conf. on Computer Vision (ICCV), 2019. 1, 2, 3
|
| 217 |
+
[30] M. Niemeyer and A. Geiger. Giraffe: Representing scenes as compositional generative neural feature fields. In Proc. IEEE Conf. on Computer Vision and Pattern Recognition (CVPR), 2021. 1, 2, 6, 8
|
| 218 |
+
[31] M. Niemeyer, L. Mescheder, M. Oechsle, and A. Geiger. Differentiable volumetric rendering: Learning implicit 3d representations without 3d supervision. In Proc. IEEE Conf. on Computer Vision and Pattern Recognition (CVPR), 2020. 2, 3, 8
|
| 219 |
+
[32] R. Or-El, X. Luo, M. Shan, E. Shechtman, J. Park, and I. Kemelmacher. Stylesdf: Highresolution 3d-consistent image and geometry generation. In Proc. IEEE Conf. on Computer Vision and Pattern Recognition (CVPR), 2022. 3
|
| 220 |
+
[33] X. Pan, X. Xu, C. C. Loy, C. Theobalt, and B. Dai. A shading-guided generative implicit model for shape-accurate 3d-aware image synthesis. In Advances in Neural Information Processing Systems (NeurIPS), 2021. 3
|
| 221 |
+
[34] C. Reiser, S. Peng, Y. Liao, and A. Geiger. Kilonerf: Speeding up neural radiance fields with thousands of tiny mlps. In Proc. of the IEEE International Conf. on Computer Vision (ICCV), 2021. 3
|
| 222 |
+
[35] A. Sauer, K. Chitta, J. Müller, and A. Geiger. Projected gans converge faster. In Advances in Neural Information Processing Systems (NeurIPS), 2021. 1
|
| 223 |
+
[36] A. Sauer, K. Schwarz, and A. Geiger. Stylegan-xl: Scaling stylegan to large diverse datasets. ACM Trans. on Graphics, 2022. 1, 3
|
| 224 |
+
[37] K. Schwarz, Y. Liao, M. Niemeyer, and A. Geiger. GRAF: generative radiance fields for 3d-aware image synthesis. Advances in Neural Information Processing Systems (NIPS), 2020. 1, 3, 7
|
| 225 |
+
[38] K. Schwarz, Y. Liao, M. Niemeyer, and A. Geiger. Graf: Generative radiance fields for 3d-aware image synthesis. In Advances in Neural Information Processing Systems (NeurIPS), 2020. 2, 3, 6, 7, 8, 9
|
| 226 |
+
[39] Y. Shi, D. Aggarwal, and A. K. Jain. Lifting 2d stylegan for 3d-aware face generation. In Proc. IEEE Conf. on Computer Vision and Pattern Recognition (CVPR), 2021. 3
|
| 227 |
+
[40] C. Sun, M. Sun, and H.-T. Chen. Direct voxel grid optimization: Super-fast convergence for radiance fields reconstruction. Proc. IEEE Conf. on Computer Vision and Pattern Recognition (CVPR), 2022. 2, 3, 4
|
| 228 |
+
[41] T. Takikawa, J. Litalien, K. Yin, K. Kreis, C. Loop, D. Nowrouzezahrai, A. Jacobson, M. McGuire, and S. Fidler. Neural geometric level of detail: Real-time rendering with implicit 3D shapes. In Proc. IEEE Conf. on Computer Vision and Pattern Recognition (CVPR), 2021. 3
|
| 229 |
+
[42] M. Tancik, P. Srinivasan, B. Mildenhall, S. Fridovich-Keil, N. Raghavan, U. Singhal, R. Ramamoorthi, J. Barron, and R. Ng. Fourier features let networks learn high frequency functions in low dimensional domains. In Advances in Neural Information Processing Systems (NeurIPS), 2020. 4
|
| 230 |
+
[43] X. Xu, X. Pan, D. Lin, and B. Dai. Generative occupancy fields for 3d surface-aware image synthesis. In Advances in Neural Information Processing Systems (NeurIPS), 2021. 3, 4, 8
|
| 231 |
+
[44] Y. Xu, S. Peng, C. Yang, Y. Shen, and B. Zhou. 3d-aware image synthesis via learning structural and textural representations. Proc. IEEE Conf. on Computer Vision and Pattern Recognition (CVPR), 2022. 3, 8
|
| 232 |
+
[45] Y. Xue, Y. Li, K. K. Singh, and Y. J. Lee. GIRAFFE HD: A high-resolution 3d-aware generative model. In Proc. IEEE Conf. on Computer Vision and Pattern Recognition (CVPR), 2022. 6
|
| 233 |
+
[46] A. Yu, R. Li, M. Tancik, H. Li, R. Ng, and A. Kanazawa. PlenOctrees for real-time rendering of neural radiance fields. In Proc. of the IEEE International Conf. on Computer Vision (ICCV), 2021. 3
|
| 234 |
+
[47] J. Zhang, E. Sangineto, H. Tang, A. Siarohin, Z. Zhong, N. Sebe, and W. Wang. 3d-aware semantic-guided generative model for human synthesis. arXiv.org, 2021. 3
|
| 235 |
+
[48] Y. Zhang, W. Chen, H. Ling, J. Gao, Y. Zhang, A. Torralba, and S. Fidler. Image gans meet differentiable rendering for inverse graphics and interpretable 3d neural rendering. In Proc. IEEE Conf. on Computer Vision and Pattern Recognition (CVPR), 2021. 3
|
| 236 |
+
[49] P. Zhou, L. Xie, B. Ni, and Q. Tian. CIPS-3D: A 3D-Aware Generator of GANs Based on Conditionally-Independent Pixel Synthesis. arXiv.org, 2021. 3
|
| 237 |
+
[50] J.-Y. Zhu, Z. Zhang, C. Zhang, J. Wu, A. Torralba, J. B. Tenenbaum, and W. T. Freeman. Visual object networks: Image generation with disentangled 3D representations. Advances in Neural Information Processing Systems (NIPS), 2018. 3
|
| 238 |
+
|
| 239 |
+
# Checklist
|
| 240 |
+
|
| 241 |
+
1. For all authors...
|
| 242 |
+
|
| 243 |
+
(a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes]
|
| 244 |
+
(b) Did you describe the limitations of your work? [Yes]
|
| 245 |
+
(c) Did you discuss any potential negative societal impacts of your work? [Yes] See supplemental material.
|
| 246 |
+
(d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
|
| 247 |
+
|
| 248 |
+
2. If you are including theoretical results...
|
| 249 |
+
|
| 250 |
+
(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]
|
| 251 |
+
|
| 252 |
+
3. If you ran experiments...
|
| 253 |
+
|
| 254 |
+
(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] We will provide code upon acceptance.
|
| 255 |
+
(b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes]
|
| 256 |
+
(c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [No] Multiple runs are computationally infeasible for our models.
|
| 257 |
+
|
| 258 |
+
(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] We include total training time and the type of GPU we used.
|
| 259 |
+
|
| 260 |
+
4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
|
| 261 |
+
|
| 262 |
+
(a) If your work uses existing assets, did you cite the creators? [Yes]
|
| 263 |
+
(b) Did you mention the license of the assets? [N/A]
|
| 264 |
+
(c) Did you include any new assets either in the supplemental material or as a URL? [No]
|
| 265 |
+
(d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [N/A]
|
| 266 |
+
(e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [N/A]
|
| 267 |
+
|
| 268 |
+
5. If you used crowdsourcing or conducted research with human subjects...
|
| 269 |
+
|
| 270 |
+
(a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A]
|
| 271 |
+
(b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A]
|
| 272 |
+
(c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]
|
md/dev/bydKs84JEyw/bydKs84JEyw.md
ADDED
|
@@ -0,0 +1,320 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# VLMO: Unified Vision-Language Pre-Training with Mixture-of-Modality-Experts
|
| 2 |
+
|
| 3 |
+
Hangbo Bao1∗, Wenhui Wang2, Li Dong2, Qiang $\mathbf { L i u ^ { 2 } }$ , Owais Khan Mohammed2, Kriti Aggarwal2, Subhojit $\mathbf { S o m ^ { 2 } }$ , Songhao Piao1, Furu Wei2
|
| 4 |
+
|
| 5 |
+
1Harbin Institute of Technology, 2Microsoft Corporation https://aka.ms/msragi
|
| 6 |
+
|
| 7 |
+
# Abstract
|
| 8 |
+
|
| 9 |
+
We present a unified Vision-Language pretrained Model (VLMO) that jointly learns a dual encoder and a fusion encoder with a modular Transformer network. Specifically, we introduce Multiway Transformer, where each block contains a pool of modality-specific experts and a shared self-attention layer. Because of the modeling flexibility of Multiway Transformer, pretrained VLMO can be fine-tuned as a fusion encoder for vision-language classification tasks, or used as a dual encoder for efficient image-text retrieval. Moreover, we propose a stagewise pre-training strategy, which effectively leverages large-scale image-only and text-only data besides image-text pairs. Experimental results show that VLMO achieves state-of-the-art results on various vision-language tasks, including VQA, NLVR2 and image-text retrieval. The code and pretrained models are available at http://aka.ms/vlmo.
|
| 10 |
+
|
| 11 |
+
# 1 Introduction
|
| 12 |
+
|
| 13 |
+
Vision-Language (VL) pre-training [31, 42, 36, 27, 21, 24] learns generic cross-modal representations from large-scale image-text pairs. Previous models usually employ image-text matching, image-text contrastive learning, masked region classification/feature regression, word-region/patch alignment and masked language modeling to aggregate and align visual and linguistic information. Then the pretrained models can be directly fine-tuned on downstream vision-language tasks, such as VL retrieval and classification (visual question answering, visual reasoning, etc.).
|
| 14 |
+
|
| 15 |
+
Two mainstream architectures are widely used in previous work. CLIP [36] and ALIGN [19] adopt a dual-encoder architecture to encode images and text separately. Modality interaction is handled by the cosine similarity of the image and text feature vectors. The dual-encoder architecture is effective for retrieval tasks, especially for masses of images and text. Feature vectors of images and text can be pre-computed and stored. However, the shallow interaction between images and text is not enough to handle complex VL classification tasks. ViLT [21] finds that CLIP gives a relatively low accuracy on visual reasoning task. Another line of work [31, 42, 44, 4, 21, 24] relies on a fusion encoder with cross-modal attention to model image-text pairs. Multi-layer Transformer [46] networks are usually employed to fuse image and text representations. The fusion-encoder architecture achieves superior performance on VL classification tasks. But it requires to jointly encode all possible image-text pairs to compute similarity scores for retrieval tasks. The quadratic time complexity leads to a much slower inference speed than the dual-encoder models whose time complexity is linear.
|
| 16 |
+
|
| 17 |
+
In order to take advantage of the two types of architectures, we propose a unified Vision-Language pretrained Model (VLMO) that can be used as either a dual encoder to separately encode images and text for retrieval tasks, or used as a fusion encoder to model the deep interaction of image-text pairs for classification tasks. This is achieved by introducing Multiway Transformer that can encode various modalities (images, text, and image-text pairs) within a Transformer block. Multiway Transformer employs a pool of modality experts to replace the feed-forward network in standard Transformer. It captures modality-specific information by switching to different modality experts, and uses the shared self-attention across modalities to align visual and linguistic information. Specifically, Multiway Transformer consists of three modality experts, namely vision expert for image encoding, language expert for text encoding, and vision-language expert for image-text fusion. Thanks to the modeling flexibility, we can reuse Multiway Transformer with the shared parameters for different purposes, i.e., text-only encoder, image-only encoder, and image-text fusion encoder.
|
| 18 |
+
|
| 19 |
+
VLMO is jointly learned with three pre-training tasks, namely image-text contrastive learning, imagetext matching, and masked language modeling. In addition, we propose a stagewise pre-training strategy to effectively leverage large-scale image-only and text-only corpus besides image-text pairs in VLMO pre-training. We first pretrain vision experts and self-attention modules of Multiway Transformer on image-only data using masked image modeling proposed in BEIT [3]. We then pretrain language experts on text-only data using masked language modeling [11]. Finally, the model is used to initialize vision-language pre-training. By getting rid of the limited size of image-text pairs and their simple and short captions, stagewise pre-training on large amounts of image-only and text-only data helps VLMO to learn more generalizable representations.
|
| 20 |
+
|
| 21 |
+
Experimental results demonstrate that VLMO achieves state-of-the-art results on vision-language retrieval and classification tasks. Our model, used as a dual encoder, outperforms fusion-encoderbased models [4, 15, 21, 24] while enjoying a much faster inference speed on retrieval tasks. Moreover, our model also achieves state-of-the-art results on visual question answering (VQA) and natural language for visual reasoning (NLVR2), where VLMO is used as a fusion encoder.
|
| 22 |
+
|
| 23 |
+
Our main contributions are summarized as follows:
|
| 24 |
+
|
| 25 |
+
• We propose a unified vision-language pretrained model VLMO that can be used as a fusion encoder for classification tasks, or fine-tuned as a dual encoder for retrieval tasks.
|
| 26 |
+
• We introduce a general-purpose multimodal Transformer for vision-language tasks, namely Multiway Transformer, to encode different modalities. It captures modality-specific information by modality experts, and aligns contents of different modalities by the self-attention module shared across modalities.
|
| 27 |
+
• We show that stagewise pre-training using large amounts of image-only and text-only data greatly improves our vision-language pretrained model.
|
| 28 |
+
|
| 29 |
+
# 2 Related Work
|
| 30 |
+
|
| 31 |
+
Pre-training with Transformer [46] backbone networks has substantially advanced the state of the art across natural language processing [35, 11, 29, 23, 12, 37, 2, 8, 9, 5–7, 32], computer vision [13, 45, 3] and vision-language [44, 42, 4, 51, 36, 19, 21, 24, 47] tasks.
|
| 32 |
+
|
| 33 |
+
The approaches of vision-language pre-training can be divided into two categories. The first category utilizes a dual encoder to encode images and text separately, and uses cosine similarity or a linear projection layer to model the interaction between images and text [36, 19]. Image-text contrastive learning is usually employed to optimize the model. Dual-encoder models are effective for visionlanguage retrieval tasks. However, the simple interaction is not enough to handle tasks that require complex reasoning, such as visual reasoning and visual question answering (VL classification tasks). The second category models the interaction of images and text using a deep fusion encoder with cross-modal attention [44, 31, 42, 25, 53, 4, 27, 26, 15, 51, 17, 18, 21, 24, 48]. Image-text matching, masked language modeling, word-region/patch alignment, masked region classification and feature regression are widely used to train fusion-encoder-based models. These models achieve better performance for vision-language classification tasks, while the joint encoding of all image-text pairs leads to a slow inference speed for retrieval tasks. A large portion of fusion-encoder-based models rely on an off-the-shelf object detector like Faster R-CNN [38] to obtain image region features. Generating region features slows down the inference speed and renders the approach less scalable. Recently, Pixel-BERT [17] removes object detector and encodes images into grid features by convolutional neural networks. ALBEF [24] employs image Transformer [13, 45] to obtain the representations of images, and uses text Transformer [11] to learn the contextualized representations of text. These representations are then fused by cross-modal attention. ViLT [21] encodes images into patch embeddings, and then feed the concatenation of image patch embeddings and word embeddings into a Transformer network to learn contextualized representations and model the interaction of images and text.
|
| 34 |
+
|
| 35 |
+

|
| 36 |
+
Figure 1: Overview of VLMO pre-training. We introduce Multiway Transformer to encode different modality input by modality-specific experts. The model parameters are shared across image-text contrastive learning, masked language modeling, and image-text matching pre-training tasks. During fine-tuning, the flexible modeling enables us to use VLMO as either a dual encoder (i.e., separately encode images and text for retrieval tasks) or a fusion encoder (i.e., jointly encode image-text pairs for better interaction across modalities).
|
| 37 |
+
|
| 38 |
+
Different from previous work, our unified pre-training using shared Multiway Transformer enables the model perform separate encoding for retrieval tasks, and jointly encode image-text pairs to capture deeper interaction for classification tasks. Our model achieves competitive performance, while enjoying a faster inference speed for both retrieval and classification tasks.
|
| 39 |
+
|
| 40 |
+
# 3 Methods
|
| 41 |
+
|
| 42 |
+
Given image-text pairs, VLMO obtains image-only, text-only and image-text pair representations by the Multiway Transformer network. As shown in Figure 1, the unified pre-training optimizes shared Multiway Transformer with image-text contrastive learning on image-only and text-only representations, image-text matching and masked language modeling on image-text pair representations. Thanks to the modeling flexibility, the model can be used as a dual encoder for retrieval tasks to encode images and text separately during fine-tuning. It can also be fine-tuned as a fusion encoder to model deeper modality interaction of images and text for classification tasks.
|
| 43 |
+
|
| 44 |
+

|
| 45 |
+
Figure 2: Stagewise pre-training using image-only and text-only corpora. We first pretrain the vision expert (V-FFN) and self-attention module on large-scale image-only data as in BEIT [3]. Then the parameters of vision expert and self-attention module are frozen, and we train the language expert (L-FFN) by masked language modeling on large amounts of text-only data. Finally, we train the whole model with vision-language pre-training.
|
| 46 |
+
|
| 47 |
+
# 3.1 Input Representations
|
| 48 |
+
|
| 49 |
+
Given an image-text pair, we encode the pair into image, text and image-text vector representations. These representations are then fed into the Multiway Transformer to learn contextualized representations and align image and text feature vectors.
|
| 50 |
+
|
| 51 |
+
Image Representations Following vision Transformers [13, 45, 3], the 2D image ${ \pmb v } \in \mathbb { R } ^ { H \times W \times C }$ is split and reshaped into $N = H W / P ^ { 2 }$ patches $\pmb { v } ^ { p } \in \mathbb { R } ^ { N \times ( P ^ { 2 } C ) }$ , where $C$ is the number of channels, $( H , W )$ is the resolution of the input image, and $( P , P )$ is the patch resolution. The image patches are then flattened into vectors and are linearly projected to obtain patch embeddings. We also prepend a learnable special token [I_CLS] to the sequence. Finally, image input representations are obtained via summing patch embeddings, learnable 1D position embeddings $\dot { V } _ { p o s } \dot { \in } \mathbb { R } ^ { ( N + 1 ) \times D }$ and image type embedding $V _ { t y p e } \in \mathbb { R } ^ { D } \colon H _ { 0 } ^ { v } = [ \pmb { v } _ { [ \mathbb { I } _ { - } \mathbb { C } \mathbb { S } ] } , V \pmb { v } _ { i } ^ { p } , \dots , V \pmb { v } _ { N } ^ { p } ] + V _ { p o s } + V _ { t y p e }$ , where $\pmb { H } _ { 0 } ^ { v } \in \mathbb { R } ^ { ( N + 1 ) \times D }$ , linear projection $V \in \mathbb { R } ^ { ( P ^ { 2 } C ) \times D }$ .
|
| 52 |
+
|
| 53 |
+
Text Representations Following BERT [11], we tokenize the text to subword units by WordPiece [49]. A start-of-sequence token ([T_CLS]) and a special boundary token ([T_SEP]) are added to the text sequence. Text input representations $\bar { \mathbf { H } } _ { 0 } ^ { w } \ \in \ \mathbb { R } ^ { ( M + 2 ) \times D }$ are computed via summing the corresponding word embedding, text position embedding and text type embedding $\pmb { H } _ { 0 } ^ { w } = [ \pmb { w } _ { [ \Gamma _ { - } \mathbb { C } \mathbb { B } ] } , \pmb { w } _ { i } , \dots , \pmb { w } _ { M } , \pmb { w } _ { [ \tilde { \Gamma } _ { - } \mathbb { S } \mathbb { E } \mathbb { P } ] } ] + \pmb { T } _ { p o s } + \pmb { T } _ { t y p e }$ . $M$ indicates the length of tokenized subword units.
|
| 54 |
+
|
| 55 |
+
Image-Text Representations We concatenate image and text input vectors to form the image-text input representations $\pmb { H } _ { 0 } ^ { v l } = [ \pmb { H } _ { 0 } ^ { w } ; \pmb { H } _ { 0 } ^ { v } ]$
|
| 56 |
+
|
| 57 |
+
# 3.2 Multiway Transformer
|
| 58 |
+
|
| 59 |
+
Inspired by mixture-of-experts networks [41, 14], we propose a general-purpose multimodal Transformer for vision-language tasks, namely Multiway Transformer, to encode different modalities. Multiway Transformer introduces mixture of modality experts as a substitute of the feed forward network of standard Transformer. Each modality expert is also the feed forward network which consists of two linear transformations and an activation. Given previous layer’s output vectors $H _ { l - 1 } , l \ \in \ [ 1 , L ]$ , each Multiway Transformer block captures modality-specific information by switching to different modality expert, and employs multi-head self-attention (MSA) shared across modalities to align visual and linguistic contents. LN is short for layer normalization.
|
| 60 |
+
|
| 61 |
+
$$
|
| 62 |
+
\begin{array} { r } { H _ { l } ^ { \prime } = \mathrm { M S A } ( \mathrm { L N } ( H _ { l - 1 } ) ) + H _ { l - 1 } } \\ { \quad H _ { l } = \mathrm { M u l t i w a y – F F N } ( \mathrm { L N } ( H _ { l } ^ { \prime } ) ) + H _ { l } ^ { \prime } } \end{array}
|
| 63 |
+
$$
|
| 64 |
+
|
| 65 |
+
Multiway-FFN selects an expert among multiple modality experts to process the input according to the modality of the input vectors $\pmb { H } _ { l } ^ { \prime }$ and the index of the Transformer layer. Specifically, there are three modality experts: vision expert (V-FFN), language expert (L-FFN) and vision-language expert (VL-FFN). If the input is image-only or text-only vectors, we use vision expert for encoding images and language expert for encoding text. If the input consists of vectors of multiple modalities, such as the vectors of image-text pair, we employ vision expert and language expert to encode the respective modality vectors at the bottom Transformer layers. Vision-language expert is then used at the top layers to capture more modality interaction. Compared with conventional mixture-of-experts networks [41, 14], Multiway Transformer conducts hard routing according the input modality. Given the three types of input vectors, we obtain image-only, text-only and image-text contextualized representations.
|
| 66 |
+
|
| 67 |
+

|
| 68 |
+
Figure 3: Fine-tuning VLMO on vision-language retrieval and classification tasks. The model can be fine-tuned as a dual encoder to separately encode image and text for retrieval tasks. VLMO can also be used as a fusion encoder to handle interaction of image-text pairs for classification tasks.
|
| 69 |
+
|
| 70 |
+
# 3.3 Pre-Training Tasks
|
| 71 |
+
|
| 72 |
+
VLMO is jointly pretrained by image-text contrastive learning on the image and text representations, masked language modeling and image-text matching on the image-text pair representations with shared parameters.
|
| 73 |
+
|
| 74 |
+
Image-Text Contrast Given a batch of $N$ image-text pairs, image-text contrastive learning aims to predict the matched pairs from $N \times N$ possible image-text pairs. There are $N ^ { 2 } - N$ negative image-text pairs within a training batch.
|
| 75 |
+
|
| 76 |
+
The final output vectors of [I_CLS] token and [T_CLS] token are used as the aggregated representation of the image and text, respectively. Followed by a linear projection and normalization, we obtain image vectors $\{ \hat { h } _ { i } ^ { v } \} _ { i = 1 } ^ { N }$ and text vectors $\{ \hat { h } _ { i } ^ { w } \} _ { i = 1 } ^ { N }$ in a training batch to compute image-to-text and text-to-image similarities:
|
| 77 |
+
|
| 78 |
+
$$
|
| 79 |
+
\begin{array} { c } { { s _ { i , j } ^ { i 2 t } = \hat { h } _ { i } ^ { v \top } \hat { h } _ { j } ^ { w } , s _ { i , j } ^ { t 2 i } = \hat { h } _ { i } ^ { w \top } \hat { h } _ { j } ^ { v } } } \\ { { p _ { i } ^ { i 2 t } = \displaystyle \frac { \exp ( s _ { i , i } ^ { i 2 t } / \sigma ) } { \sum _ { j = 1 } ^ { N } \exp ( s _ { i , j } ^ { i 2 t } / \sigma ) } , p _ { i } ^ { t 2 i } = \displaystyle \frac { \exp ( s _ { i , i } ^ { t 2 i } / \sigma ) } { \sum _ { j = 1 } ^ { N } \exp ( s _ { i , j } ^ { t 2 i } / \sigma ) } } } \end{array}
|
| 80 |
+
$$
|
| 81 |
+
|
| 82 |
+
Where si2ti,j represents image-to-text similarity of image of $i$ -th pair and text of $j$ -th pair, $s _ { i , j } ^ { t 2 i }$ is the text-to-image similarity. $\hat { h } _ { i } ^ { w } \in \mathbb { R } ^ { D }$ and $\hat { h } _ { j } ^ { v } \in \mathbb { R } ^ { D }$ indicate the normalized vectors of $i$ -th text and $j$ -th image, $\sigma$ is a learned temperature parameter. $p _ { i } ^ { i 2 t }$ and $p _ { i } ^ { t 2 i }$ are the softmax-normalized similarities. Cross-entropy losses over image-to-text and text-to-image similarities are used to train the model.
|
| 83 |
+
|
| 84 |
+
Masked Language Modeling Following BERT [11], we randomly choose tokens in the text sequence, and replace them with the [MASK] token. The model is trained to predict these masked tokens from all the other unmasked tokens and vision clues. We use $1 5 \%$ masking probability as in BERT. The final output vectors of masked tokens are fed into a classifier over the whole text vocabulary with cross-entropy loss.
|
| 85 |
+
|
| 86 |
+
Image-Text Matching Image-text matching aims to predict whether the image and text is matched. We use the final hidden vector of the [T_CLS] token to represent the image-text pair, and feed the vector into a classifier with cross-entropy loss for binary classification. Inspired by ALBEF [24], we sample hard negative image-text pairs based on the contrastive image-to-text and text-to-image similarities.
|
| 87 |
+
|
| 88 |
+
# 3.4 Stagewise Pre-Training
|
| 89 |
+
|
| 90 |
+
We introduce a stagewise pre-training strategy, which leverages large-scale image-only and text-only corpus to improve the vision-language model. As present in Figure 2, we first perform vision pretraining on image-only data, and then perform language pre-training on text-only data to learn general image and text representations. The model is used to initialize the vision-language pre-training to learn the alignment of visual and linguistic information. For vision pre-training, we train the attention module and vision expert of Multiway Transformer as in BEIT [3] on image-only data. We directly utilize the pretrained parameters of BEIT to initialize the attention module and vision expert. For language pre-training, we freeze parameters of the attention module and vision expert to avoid catastrophic forgetting of vision knowledge learned in the first stage, and utilize masked language modeling [11] to optimize the language expert on text-only data. Compared with image-text pairs, image-only and text-only data are easier to collect. In addition, text data of image-text pairs is usually short and simple. Pre-training on image-only and text-only corpus improves the generalization on complex pairs.
|
| 91 |
+
|
| 92 |
+
# 3.5 Fine-Tuning VLMO on Downstream Tasks
|
| 93 |
+
|
| 94 |
+
As present in Figure 3, our model can be fine-tuned to adapt to various vision-language retrieval and classification tasks.
|
| 95 |
+
|
| 96 |
+
Vision-Language Classification For classification tasks such as visual question answering and visual reasoning, VLMO is used as a fusion encoder to model modality interaction of images and text. We use the final encoding vector of the token [T_CLS] as the representation of the image-text pair, and feed it to a task-specific classifier layer to predict the label.
|
| 97 |
+
|
| 98 |
+
Vision-Language Retrieval For retrieval tasks, VLMO can be used as a dual encoder to encode images and text separately. During fine-tuning, our model is optimized for the image-text contrastive loss. During inference, we compute representations of all images and text, and then use dot product to obtain image-to-text and text-to-image similarity scores of all possible image-text pairs. Separate encoding enables a much faster inference speed than fusion-encoder-based models.
|
| 99 |
+
|
| 100 |
+
# 4 Experiments
|
| 101 |
+
|
| 102 |
+
We pretrain our model using large-scale image-text pairs and evaluate the model on visual-linguistic classification and retrieval tasks.
|
| 103 |
+
|
| 104 |
+
# 4.1 Pre-Training Setup
|
| 105 |
+
|
| 106 |
+
Following previous work [4, 21], our pre-training data consists of four image captioning datasets: Conceptual Captions (CC) [40], SBU Captions [33], COCO [28] and Visual Genome (VG) [22] datasets. There are about 4M images and 10M image-text pairs in the pre-training data.
|
| 107 |
+
|
| 108 |
+
Our models adopt the same network configuration as ViT [13] and BEIT [3]. VLMO-Base consists of 12-layer Transformer blocks with 768 hidden size and 12 attention heads. VLMO-Large is a 24-layer Transformer network with 1024 hidden size and 16 attention heads. VLMO-Base uses vision-language expert on the top two Transformer layers, and VLMO-Large introduces visionlanguage expert on the top three layers. VLMO-Base consists of 175M parameters and VLMO-Large contains 562M parameters. For images, the input resolution is $2 2 4 \times 2 2 4$ and the patch size is $1 6 \times 1 6$ during pre-training. We apply RandAugment [10] to the input images. The tokenizer of the uncased version of BERT is employed to tokenize the text. The maximum text sequence length is set to 40. We also employ whole word masking for the masked language modeling pre-training task. We pretrain the models for $2 0 0 \mathrm { k }$ steps with 1024 batch size. We utilize AdamW [30] optimizer with $\beta _ { 1 } = 0 . 9$ , $\beta _ { 2 } = 0 . 9 8$ . The peak learning is 2e-4 for the base-size model, 5e-5 for the large-size model. Weight decay is set to 0.01. We use linear warmup over the first $2 . 5 \mathrm { k }$ steps and linear decay.
|
| 109 |
+
|
| 110 |
+
<table><tr><td rowspan="2">Model</td><td rowspan="2">#Pretrain Images</td><td colspan="2">VQA</td><td colspan="2">NLVR2</td></tr><tr><td>test-dev</td><td>test-std</td><td>dev</td><td>test-P</td></tr><tr><td>Base-SizeModelsPretrained on COCO,VG,</td><td></td><td></td><td>,SBUand CCdatasets</td><td></td><td></td></tr><tr><td>UNITER-Base [4]</td><td>4M</td><td>72.70</td><td>72.91</td><td>77.18</td><td>77.85</td></tr><tr><td>VILLA-Base [15]</td><td>4M</td><td>73.59</td><td>73.67</td><td>78.39</td><td>79.30</td></tr><tr><td>UNIMO-Base [26]</td><td>4M</td><td>73.79</td><td>74.02</td><td></td><td></td></tr><tr><td>ViLT-Base [21]</td><td>4M</td><td>71.26</td><td>1</td><td>75.70</td><td>76.13</td></tr><tr><td>ALBEF-Base [24]</td><td>4M</td><td>74.54</td><td>74.70</td><td>80.24</td><td>80.50</td></tr><tr><td>VLMo-Base</td><td>4M</td><td>76.64</td><td>76.89</td><td>82.77</td><td>83.34</td></tr><tr><td colspan="6">Large-Size Models Pretrained on COCO, VG, SBU and CC datasets</td></tr><tr><td>UNITER-Large [4]</td><td>4M</td><td>73.82</td><td>74.02</td><td>79.12</td><td>79.98</td></tr><tr><td>VILLA-Large [15]</td><td>4M</td><td>74.69</td><td>74.87</td><td>79.76</td><td>81.47</td></tr><tr><td>UNIMO-Large [26]</td><td>4M</td><td>75.06</td><td>75.27</td><td>=</td><td>=</td></tr><tr><td>VLMo-Large</td><td>4M</td><td>79.94</td><td>79.98</td><td>85.64</td><td>86.86</td></tr><tr><td colspan="6">ModelsPretrainedonMoreData</td></tr><tr><td>VinVL-Large [51]</td><td>5.7M</td><td>76.52</td><td>76.60</td><td>82.67</td><td>83.98</td></tr><tr><td>SimVLM-Large [48]</td><td>1.8B</td><td>79.32</td><td>79.56</td><td>84.13</td><td>84.84</td></tr><tr><td>SimVLM-Huge [48]</td><td>1.8B</td><td>80.03</td><td>80.34</td><td>84.53</td><td>85.15</td></tr><tr><td>Florence-Huge [50]</td><td>900M</td><td>80.16</td><td>80.36</td><td>、</td><td></td></tr><tr><td>Flamingo [1]</td><td>2.3B</td><td>82.00</td><td>82.10</td><td>=</td><td>1</td></tr><tr><td>VLMo-Large++</td><td>1.0B</td><td>82.88</td><td>82.78</td><td>88.62</td><td>89.54</td></tr></table>
|
| 111 |
+
|
| 112 |
+
Table 1: Fine-tuning results of base-size and large-size VLMO on vision-language classification datasets. VLMO-Large $^ { + + }$ is the model trained on one billion noisy image-text pairs with a larger batch size. We report vqa-score on VQA test-dev and test-standard split, and report accuracy for NLVR2 development and public test set (test-P).
|
| 113 |
+
|
| 114 |
+
# 4.2 Training on Larger-scale Datasets
|
| 115 |
+
|
| 116 |
+
We scale up vision-language representation learning by training VLMO-Large on one billion noisy web image-text pairs with a larger batch size. We first pretrain the model for 200k steps with 16k batch size, and then continue train the model for $1 0 0 \mathrm { k }$ steps with $3 2 \mathrm { k }$ batch size. The other hyperparameters are the same as the training on 4M data. Please refer to the supplementary material for more details of hyper-parameters used for pre-training and fine-tuning.
|
| 117 |
+
|
| 118 |
+
# 4.3 Evaluation on Vision-Language Classification Tasks
|
| 119 |
+
|
| 120 |
+
We first conduct fine-tuning experiments on two widely used classification datasets: visual question answering [16] and natural language for visual reasoning [43]. The model is fine-tuned as a fusion encoder to model deeper interaction.
|
| 121 |
+
|
| 122 |
+
Visual Question Answering (VQA) For VQA, a natural image and a question are given, the task is to generate/choose the correct answer. We train and evaluate the model on VQA 2.0 dataset [16]. Following common practices, we convert VQA 2.0 to a classification task, and choose the answer from a shared set consists of 3, 129 answers. We use the final encoding vector of the [T_CLS] token as the representation of the image-question pair and feed it to a classifier layer to predict the answer.
|
| 123 |
+
|
| 124 |
+
Natural Language for Visual Reasoning (NLVR2) The NLVR2 [43] dataset requires the model to predict whether a text description is true about a pair of images. Following OSCAR [27] and VinVL [51], we convert the triplet input to two image-text pairs, each containing the text description and one image. We concatenate the final output vectors of the [T_CLS] token of the two input pairs. The concatenated vector is then fed into a classification layer to predict the label.
|
| 125 |
+
|
| 126 |
+
We present the results of VL classification tasks in Table 1. VLMO achieves state-of-the-art performance and substantially outperforms previous methods. Our large-size model even outperforms SimVLM-Huge [48] and Florence-Huge [50] by a large margin, which consists of more parameters and are also trained on larger-scale image-text pairs. Our model uses a simple linear projection to embed images as in ViLT [21]. This leads to a significant speedup compared with previous models using image region features, which are extracted by an off-the-shelf object detector [31, 42, 4, 15, 26, 51].
|
| 127 |
+
|
| 128 |
+
<table><tr><td></td><td colspan="7">#Pretrain</td><td colspan="6">Flickr30K (1K test set)</td></tr><tr><td>Model</td><td colspan="2">Images</td><td colspan="2">MSCOCO (5K test set) TR</td><td colspan="2">IR</td><td colspan="2"></td><td colspan="2">TR</td><td></td><td>IR</td><td></td></tr><tr><td></td><td></td><td></td><td></td><td>R@1 R@5 R@10 R@1 R@5 R@10|</td><td></td><td></td><td></td><td>R@1 R@5 R@10 R@1 R@5 R@10</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td colspan="10">Base-Size Models Pretrained on COCO,VG, SBU and CC datasets</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>UNITER-Base</td><td>4M</td><td></td><td>64.4 87.4</td><td>93.1</td><td>50.3</td><td>78.5</td><td>87.2</td><td>85.9</td><td>97.1</td><td>98.8</td><td>72.5</td><td>92.4</td><td>96.1</td></tr><tr><td>VILLA-Base</td><td>4M</td><td>1</td><td>-</td><td>1</td><td>-</td><td>-</td><td>-</td><td>86.6</td><td>97.9</td><td>99.2</td><td>74.7</td><td>92.9</td><td>95.8</td></tr><tr><td>ViLT-Base</td><td>4M</td><td>61.5</td><td>86.3</td><td>92.7</td><td>42.7</td><td>72.9</td><td>83.1</td><td>83.5</td><td>96.7</td><td>98.6</td><td>64.4</td><td>88.7</td><td>93.8</td></tr><tr><td>ALBEF-Baset</td><td>4M</td><td>73.1</td><td>91.4</td><td>96.0</td><td>56.8</td><td>81.5</td><td>89.2</td><td>94.3</td><td>99.4</td><td>99.8</td><td>82.8</td><td>96.7</td><td>98.4</td></tr><tr><td>VLMo-Base†</td><td>4M</td><td>74.8</td><td>93.1</td><td>96.9</td><td>57.2</td><td>82.6</td><td>89.8</td><td>92.3</td><td>99.4</td><td>99.9</td><td>79.3</td><td>95.7</td><td>97.8</td></tr><tr><td colspan="10">Large-Size Models Pretrained on COCO, VG, SBU and CC datasets</td><td></td><td></td><td></td><td></td></tr><tr><td>UNITER-Large</td><td>4M</td><td>65.7</td><td>88.6</td><td>93.8</td><td>52.9</td><td>79.9</td><td>88.0</td><td>87.3</td><td>98.0</td><td>99.2</td><td>75.6</td><td>94.1</td><td>96.8</td></tr><tr><td>VILLA-Large</td><td>4M</td><td>=</td><td>-</td><td>1</td><td>-</td><td>-</td><td></td><td>87.9</td><td>97.5</td><td>98.8</td><td>76.3</td><td>94.2</td><td>96.8</td></tr><tr><td>VLMo-Larget</td><td>4M</td><td>78.2 94.4</td><td></td><td>97.4</td><td>60.6</td><td>84.4</td><td>91.0</td><td>95.3</td><td>99.9</td><td>100.0</td><td>84.5</td><td>97.3</td><td>98.6</td></tr><tr><td colspan="10">Models Pretrained on More Data</td><td></td><td></td><td></td><td></td></tr><tr><td>VinVL-Large</td><td>5.7M</td><td>75.4</td><td>92.9</td><td>96.2</td><td>58.8</td><td>83.5</td><td>90.3</td><td>-</td><td>=</td><td>=</td><td></td><td>=</td><td>-</td></tr><tr><td>ALIGN-Larget</td><td>1.8B</td><td>77.0</td><td>93.5</td><td>96.9</td><td>59.9</td><td>83.3</td><td>89.8</td><td>95.3</td><td>99.8</td><td>100.0 84.9</td><td></td><td>97.4</td><td>98.6</td></tr><tr><td>Florence-Huget</td><td>900M</td><td>81.8</td><td>95.2</td><td>-</td><td>63.2</td><td>85.7</td><td>-</td><td>97.2</td><td>99.9</td><td>1</td><td>87.9</td><td>98.1</td><td>-</td></tr><tr><td>VLMO-Large++†</td><td>1.0B</td><td>83.1</td><td>96.0</td><td>98.2</td><td>65.2</td><td>86.5</td><td>92.2</td><td>96.8</td><td>100.0</td><td>100.0</td><td>88.1</td><td>98.4</td><td>99.3</td></tr></table>
|
| 129 |
+
|
| 130 |
+
Table 2: Fine-tuning results of text-retrieval (TR) and image-retrieval (IR) on COCO and Flickr30K. †: ALIGN, Florence and our model encode images and text separately, and then employ a shallow interaction (dot product) to obtain the similarity scores. $\ddagger$ : ALBEF first encodes images and text separately to obtain the top- $k$ candidates, and then feed these representations into a fusion encoder to rerank the candidates. The others require to encode all image-text combinations by a fusion encoder. VLMO-Large $^ { + + }$ represents the model trained on one billion noisy image-text pairs with a larger batch size.
|
| 131 |
+
|
| 132 |
+
Table 3: Ablation studies of stagewise pre-training, i.e., different initialization for vision-language pre-training. We report the average of $\mathbf { R } \ @ 1$ , ${ \mathrm { R @ 5 } }$ and $\mathrm { R @ 1 0 }$ for Flickr30k. Results of NLVR2 are averaged over three runs.
|
| 133 |
+
|
| 134 |
+
<table><tr><td rowspan="2">Stagewise Pre-Training</td><td colspan="2">NLVR2</td><td colspan="2">Flickr30k</td></tr><tr><td>dev</td><td>test-P</td><td>TR</td><td>IR</td></tr><tr><td>Image-Only Pre-Training</td><td>80.33</td><td>81.06</td><td>95.60</td><td>87.69</td></tr><tr><td>Image-Only + Text-Only Pre-Training</td><td>82.09</td><td>82.49</td><td>95.67</td><td>88.52</td></tr></table>
|
| 135 |
+
|
| 136 |
+
# 4.4 Evaluation on Vision-Language Retrieval Tasks
|
| 137 |
+
|
| 138 |
+
The retrieval tasks contain image-to-text retrieval and text-to-image retrieval. We evaluate the model on the widely used COCO [28] and Flickr30K [34] datasets, and use the Karpathy split [20] for both datasets. The model is used as a dual encoder for retrieval tasks. We encode images and text separately and compute their similarity scores by the dot product of image and text vectors.
|
| 139 |
+
|
| 140 |
+
As present in Table 2, VLMO achieves competitive performance with previous fusion-encoder-based models while having a much faster speed. Fusion-encoder-based models need to jointly encode all possible image-text pairs to compute their similarity scores, which requires quadratic time complexity. Moreover, our large-size model even outperforms the huge-size model of Florence [50], which also trained on massive image-text pairs using a larger batch size. VLMO pre-training can effectively leverage larger-scale noisy pairs and benefit from large batch training.
|
| 141 |
+
|
| 142 |
+
# 4.5 Evaluation on Vision Tasks
|
| 143 |
+
|
| 144 |
+
As shown in Table 4, we use VLMO as an image-only encoder and evaluate it on image classification (ImageNet [39]) and semantic segmentation (ADE20K [52]) tasks. The model also achieves competitive performance, even slightly better than the BEIT model used for the initialization of VLMO. The image resolution is $2 2 4 \times 2 2 4$ for ImageNet, and $5 1 2 \times 5 1 2$ for ADE20K. We perform intermediate fine-tuning [3] on ImageNet-21k for all three models.
|
| 145 |
+
|
| 146 |
+
Table 4: Results on image classification and semantic segmentation.
|
| 147 |
+
|
| 148 |
+
<table><tr><td>Models</td><td>ImageNet (acc @1)</td><td>ADE20K (mIoU)</td></tr><tr><td>VIT-Base</td><td>83.6</td><td>-</td></tr><tr><td>BEIT-Base</td><td>85.2</td><td>52.8</td></tr><tr><td>VLMo-Base</td><td>85.5</td><td>53.4</td></tr></table>
|
| 149 |
+
|
| 150 |
+
Table 5: Ablation studies of Multiway Transformer and vision-language pre-training tasks. “ITC” is short for image-text contrastive loss, “ITM” is image-text matching, and “MLM” is masked language modeling. “Std TRM” is short for standard Transformer, and “Multiway−VLExp” is Multiway Transformer without VL experts. The average of $\mathbf { R } \ @ 1$ , $\mathbf { R } @ 5$ and $\mathrm { R @ 1 0 }$ is reported for Flickr30k. Results of NLVR2 are averaged over three runs.
|
| 151 |
+
|
| 152 |
+
<table><tr><td colspan="3">Pre-Training Tasks</td><td colspan="3">Transformer</td><td colspan="2">NLVR2</td><td colspan="2">Flickr30k</td></tr><tr><td>ITC</td><td>ITM</td><td>MLM</td><td>Std TRM</td><td>Multiway</td><td>Multiway-VLExp</td><td>dev</td><td>test-P</td><td>TR</td><td>IR</td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td><td>58.51</td><td>58.83</td><td>92.23</td><td>84.24</td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td><td>73.91</td><td>73.75</td><td>94.07</td><td>85.82</td></tr><tr><td></td><td></td><td></td><td>xxx/xx</td><td>///xxν</td><td>xxx</td><td>76.46</td><td>76.19</td><td>94.37</td><td>85.67</td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td><td>78.81</td><td>79.27</td><td>93.37</td><td>85.73</td></tr><tr><td></td><td>xx///</td><td></td><td></td><td></td><td>x/x</td><td>79.58</td><td>80.11</td><td>94.50</td><td>86.69</td></tr><tr><td>//////</td><td></td><td>x/xν//</td><td></td><td></td><td></td><td>80.13</td><td>80.31</td><td>95.17</td><td>87.25</td></tr></table>
|
| 153 |
+
|
| 154 |
+
# 4.6 Ablation Studies
|
| 155 |
+
|
| 156 |
+
Stagewise Pre-Training We first conduct ablation experiments of stagewise pre-training. ViLT [21] shows that using the ViT [13] model pretrained on image-only data as the initialization achieves better performance than the BERT model pretrained on text-only data. Therefore we start experiments with image-only pre-training. We compare using image-only pre-training, and image-only pre-training plus text-only pre-training as the initialization. For image-only pre-training, we directly use the parameters of BEIT-Base to initialize the self-attention module and all modality experts. For imageonly pre-training plus text-only pre-training, we use pretrained parameters of BEIT-Base to initialize the vision expert and self-attention module of Multiway Transformer, and then pretrain its language expert on text corpora. As shown in Table 3, image-only pre-training plus text-only pre-training improves our vision-language model. We also have tried to perform vision-language pre-training with random initialization but obtain a relatively low accuracy on downstream tasks. Stagewise pre-training effectively leverages large-scale image-only and text-only corpus, and improves our vision-language pre-training. Moreover, given the limited size of image-text pairs we used during pretraining, stage-wise pre-training on image-only and text-only data alleviates the need for image-text pair data. We have tried to perform multitask training on image-only and text-only data to combine the first two stages and observe similar performance. Stage-wise pre-training effectively leverages the pretrained weights to reduce the computation cost.
|
| 157 |
+
|
| 158 |
+
Multiway Transformer We also conduct ablation experiments of Multiway Transformer. We employ ViT-Base to initialize the models for the ablation experiments. As present in Table 5, using Multiway Transformer achieves better performance than standard Transformer for both retrieval and classification tasks. In addition, we also analyse the contribution of vision-language expert (VL-FFN) used in Multiway Transformer. We remove the vision-language expert used in the top Transformer layers. Experimental results demonstrate that the introduction of vision-language expert improves the model. Using vision-language expert captures more modality interaction.
|
| 159 |
+
|
| 160 |
+
Pre-Training Tasks We perform ablation studies to analyse the contribution of different pre-training tasks, and the results are presented in Table 5. Compared with the model trained only using image-text contrastive loss, our unified training performs much better across classification and retrieval tasks. Introducing image-text matching with hard negative mining also greatly improves the model. This demonstrates the effectiveness of our unified-training framework with Multiway Transformer. In addition, experimental results show that masked language modeling positively contribute to our model. Please refer to the supplementary material for more ablation studies.
|
| 161 |
+
|
| 162 |
+
Table 6: Global hard negative mining improves the model. We perform experiments using 32 V100 GPUs for the base-size model. The batch size per GPU is 32, and the total batch size is 1024. Local hard negative mining samples hard negatives from training examples of the single GPU (32 examples), while global hard negative mining uses training examples gathered from all GPUs as the candidates (1024 examples).
|
| 163 |
+
|
| 164 |
+
<table><tr><td>Models</td><td colspan="2">NLVR2</td></tr><tr><td></td><td>dev</td><td>test-P</td></tr><tr><td>Local hard negative mining [24]</td><td>77.70</td><td>77.95</td></tr><tr><td>Global hard negative mining (ours)</td><td>79.54</td><td>79.48</td></tr></table>
|
| 165 |
+
|
| 166 |
+
Global Hard Negative Mining Different from ALBEF [24], which samples hard negatives from training examples of the single GPU (named as local hard negative mining). We perform hard negative mining from more candidates by gathering training examples of all GPUs (named as global hard negative mining). As shown in Table 6, our global hard negative mining brings significant improvements.
|
| 167 |
+
|
| 168 |
+
# 5 Conclusion
|
| 169 |
+
|
| 170 |
+
In this work, we propose a unified vision-language pretrained model VLMO, which jointly learns a dual encoder and a fusion encoder with a shared Multiway Transformer backbone. Multiway Transformer introduces a pool of modality experts to encode modality-specific information, and aligns different modalities using the shared self-attention module. The unified pre-training with Multiway Transformer enables the model to be used as a dual encoder for efficient vision-language retrieval, or as a fusion encoder to model cross-modal interactions for classification tasks. We also show that stagewise pre-training that leverages large-scale image-only and text-only corpus greatly improves vision-language pre-training. Experimental results demonstrate that VLMO outperforms previous state-of-the-art models on various vision-language classification and retrieval benchmarks.
|
| 171 |
+
|
| 172 |
+
In the future, we would like to work on improving VLMO from the following perspectives:
|
| 173 |
+
|
| 174 |
+
• We will scale up the model size used in VLMO pre-training.
|
| 175 |
+
• We are also interested in fine-tuning VLMO for vision-language generation tasks, such as image captioning, following the method proposed in UniLM [12].
|
| 176 |
+
• We are going to explore to what extent vision-language pre-training can help each other modality, especially as the shared Multiway Transformer backbone naturally blends in text and image representations.
|
| 177 |
+
• We can extend the proposed model to integrate more modalities (e.g., speech, video, and structured knowledge), supporting general-purpose multimodal pre-training.
|
| 178 |
+
|
| 179 |
+
# References
|
| 180 |
+
|
| 181 |
+
[1] 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. CoRR, abs/2204.14198, 2022. doi: 10.48550/arXiv.2204.14198. URL https://doi.org/10.48550/arXiv.2204.14198.
|
| 182 |
+
|
| 183 |
+
[2] Hangbo Bao, Li Dong, Furu Wei, Wenhui Wang, Nan Yang, Xiaodong Liu, Yu Wang, Jianfeng Gao, Songhao Piao, Ming Zhou, and Hsiao-Wuen Hon. UniLMv2: Pseudo-masked language models for unified language model pre-training. In Proceedings of the 37th International Conference on Machine Learning, ICML 2020, 13-18 July 2020, Virtual Event, volume 119 of Proceedings of Machine Learning Research, pages 642–652. PMLR, 2020. URL http: //proceedings.mlr.press/v119/bao20a.html.
|
| 184 |
+
|
| 185 |
+
[3] Hangbo Bao, Li Dong, and Furu Wei. BEiT: BERT pre-training of image transformers. CoRR, abs/2106.08254, 2021. URL https://arxiv.org/abs/2106.08254.
|
| 186 |
+
|
| 187 |
+
[4] Yen-Chun Chen, Linjie Li, Licheng Yu, Ahmed El Kholy, Faisal Ahmed, Zhe Gan, Yu Cheng, and Jingjing Liu. UNITER: universal image-text representation 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 XXX, volume 12375 of Lecture Notes in Computer Science, pages 104–120. Springer, 2020. doi: 10.1007/ 978-3-030-58577-8\_7. URL https://doi.org/10.1007/978-3-030-58577-8_7.
|
| 188 |
+
|
| 189 |
+
[5] Zewen Chi, Li Dong, Furu Wei, Wenhui Wang, Xianling Mao, and Heyan Huang. Cross-lingual natural language generation via pre-training. CoRR, abs/1909.10481, 2019.
|
| 190 |
+
|
| 191 |
+
[6] Zewen Chi, Li Dong, Furu Wei, Nan Yang, Saksham Singhal, Wenhui Wang, Xia Song, XianLing Mao, Heyan Huang, and Ming Zhou. InfoXLM: An information-theoretic framework for cross-lingual language model pre-training. In Proceedings of the 2021 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, pages 3576–3588, Online, June 2021. Association for Computational Linguistics. URL https://www.aclweb.org/anthology/2021.naacl-main.280.
|
| 192 |
+
|
| 193 |
+
[7] 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, abs/2106.16138, 2021.
|
| 194 |
+
|
| 195 |
+
[8] Alexis Conneau and Guillaume Lample. Cross-lingual language model pretraining. In Advances in Neural Information Processing Systems, volume 32. Curran Associates, Inc., 2019. URL https://proceedings.neurips.cc/paper/2019/file/ c04c19c2c2474dbf5f7ac4372c5b9af1-Paper.pdf.
|
| 196 |
+
|
| 197 |
+
[9] Alexis Conneau, Kartikay Khandelwal, Naman Goyal, Vishrav Chaudhary, Guillaume Wenzek, Francisco Guzmán, Edouard Grave, Myle Ott, Luke Zettlemoyer, and Veselin Stoyanov. Unsupervised cross-lingual representation learning at scale. In Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics, pages 8440–8451, Online, July 2020. Association for Computational Linguistics. URL https://www.aclweb.org/anthology/ 2020.acl-main.747.
|
| 198 |
+
|
| 199 |
+
[10] Ekin D. Cubuk, Barret Zoph, Jonathon Shlens, and Quoc V. Le. Randaugment: Practical automated data augmentation with a reduced search space. In 2020 IEEE/CVF Conference on Computer Vision and Pattern Recognition, CVPR Workshops 2020, Seattle, WA, USA, June 14-19, 2020, pages 3008–3017. Computer Vision Foundation / IEEE, 2020.
|
| 200 |
+
|
| 201 |
+
[11] 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, editors, Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, NAACL-HLT 2019, Minneapolis, MN, USA, June 2-7, 2019, Volume 1 (Long and Short Papers), pages 4171– 4186. Association for Computational Linguistics, 2019. doi: 10.18653/v1/n19-1423. URL https://doi.org/10.18653/v1/n19-1423.
|
| 202 |
+
|
| 203 |
+
[12] Li Dong, Nan Yang, Wenhui Wang, Furu Wei, Xiaodong Liu, Yu Wang, Jianfeng Gao, Ming Zhou, and Hsiao-Wuen Hon. Unified language model pre-training for natural language understanding and generation. 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, pages 13042–13054, 2019.
|
| 204 |
+
|
| 205 |
+
[13] 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. preprint arXiv:2010.11929, 2020.
|
| 206 |
+
|
| 207 |
+
[14] William Fedus, Barret Zoph, and Noam Shazeer. Switch transformers: Scaling to trillion parameter models with simple and efficient sparsity. CoRR, abs/2101.03961, 2021. URL https://arxiv.org/abs/2101.03961.
|
| 208 |
+
|
| 209 |
+
[15] Zhe Gan, Yen-Chun Chen, Linjie Li, Chen Zhu, Yu Cheng, and Jingjing Liu. Large-scale adversarial training for vision-and-language representation learning. In Hugo Larochelle, Marc’Aurelio Ranzato, Raia Hadsell, Maria-Florina Balcan, and Hsuan-Tien Lin, editors, Advances in Neural Information Processing Systems 33: Annual Conference on Neural Information Processing Systems 2020, NeurIPS 2020, December 6-12, 2020, virtual, 2020.
|
| 210 |
+
|
| 211 |
+
[16] Yash Goyal, Tejas Khot, Douglas Summers-Stay, Dhruv Batra, and Devi Parikh. Making the V in VQA matter: Elevating the role of image understanding in visual question answering. In 2017 IEEE Conference on Computer Vision and Pattern Recognition, CVPR 2017, Honolulu, HI, USA, July 21-26, 2017, pages 6325–6334. IEEE Computer Society, 2017. doi: 10.1109/ CVPR.2017.670. URL https://doi.org/10.1109/CVPR.2017.670.
|
| 212 |
+
|
| 213 |
+
[17] Zhicheng Huang, Zhaoyang Zeng, Bei Liu, Dongmei Fu, and Jianlong Fu. Pixel-bert: Aligning image pixels with text by deep multi-modal transformers. CoRR, abs/2004.00849, 2020. URL https://arxiv.org/abs/2004.00849.
|
| 214 |
+
|
| 215 |
+
[18] Zhicheng Huang, Zhaoyang Zeng, Yupan Huang, Bei Liu, Dongmei Fu, and Jianlong Fu. Seeing out of the box: End-to-end pre-training for vision-language representation learning. In IEEE Conference on Computer Vision and Pattern Recognition, CVPR 2021, virtual, June 19-25, 2021, pages 12976–12985. Computer Vision Foundation / IEEE, 2021.
|
| 216 |
+
|
| 217 |
+
[19] 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 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 4904–4916. PMLR, 2021. URL http://proceedings.mlr.press/v139/jia21b.html.
|
| 218 |
+
|
| 219 |
+
[20] Andrej Karpathy and Li Fei-Fei. Deep visual-semantic alignments for generating image descriptions. In IEEE Conference on Computer Vision and Pattern Recognition, CVPR 2015, Boston, MA, USA, June 7-12, 2015, pages 3128–3137. IEEE Computer Society, 2015.
|
| 220 |
+
|
| 221 |
+
[21] Wonjae Kim, Bokyung Son, and Ildoo Kim. Vilt: Vision-and-language transformer without convolution or region supervision. 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 5583–5594. PMLR, 2021. URL http://proceedings.mlr.press/v139/kim21k.html.
|
| 222 |
+
|
| 223 |
+
[22] Ranjay Krishna, Yuke Zhu, Oliver Groth, Justin Johnson, Kenji Hata, Joshua Kravitz, Stephanie Chen, Yannis Kalantidis, Li-Jia Li, David A. Shamma, Michael S. Bernstein, and Li Fei-Fei. Visual genome: Connecting language and vision using crowdsourced dense image annotations. Int. J. Comput. Vis., 123(1):32–73, 2017.
|
| 224 |
+
|
| 225 |
+
[23] Mike Lewis, Yinhan Liu, Naman Goyal, Marjan Ghazvininejad, Abdelrahman Mohamed, Omer Levy, Veselin Stoyanov, and Luke Zettlemoyer. BART: Denoising sequence-to-sequence pre-training for natural language generation, translation, and comprehension. arXiv preprint arXiv:1910.13461, 2019.
|
| 226 |
+
|
| 227 |
+
[24] Junnan Li, Ramprasaath R. Selvaraju, Akhilesh Deepak Gotmare, Shafiq R. Joty, Caiming Xiong, and Steven C. H. Hoi. Align before fuse: Vision and language representation learning with momentum distillation. CoRR, abs/2107.07651, 2021. URL https://arxiv.org/abs/ 2107.07651.
|
| 228 |
+
|
| 229 |
+
[25] Liunian Harold Li, Mark Yatskar, Da Yin, Cho-Jui Hsieh, and Kai-Wei Chang. Visualbert: A simple and performant baseline for vision and language. CoRR, abs/1908.03557, 2019. URL http://arxiv.org/abs/1908.03557.
|
| 230 |
+
|
| 231 |
+
[26] Wei Li, Can Gao, Guocheng Niu, Xinyan Xiao, Hao Liu, Jiachen Liu, Hua Wu, and Haifeng Wang. UNIMO: towards unified-modal understanding and generation via cross-modal contrastive learning. In Chengqing Zong, Fei Xia, Wenjie Li, and Roberto Navigli, editors, Proceedings of the 59th Annual Meeting of the Association for Computational Linguistics and the 11th International Joint Conference on Natural Language Processing, ACL/IJCNLP 2021, (Volume 1: Long Papers), Virtual Event, August 1-6, 2021, pages 2592–2607. Association for Computational Linguistics, 2021.
|
| 232 |
+
|
| 233 |
+
[27] Xiujun Li, Xi Yin, Chunyuan Li, Pengchuan Zhang, Xiaowei Hu, Lei Zhang, Lijuan Wang, Houdong Hu, Li Dong, Furu Wei, Yejin Choi, and Jianfeng Gao. Oscar: Object-semantics aligned pre-training for vision-language tasks. 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 XXX, volume 12375 of Lecture Notes in Computer Science, pages 121–137. Springer, 2020. doi: 10.1007/978-3-030-58577-8\_8. URL https://doi.org/10.1007/978-3-030-58577-8_8.
|
| 234 |
+
|
| 235 |
+
[28] Tsung-Yi Lin, Michael Maire, Serge J. Belongie, James Hays, Pietro Perona, Deva Ramanan, Piotr Dollár, and C. Lawrence Zitnick. Microsoft COCO: common objects in context. In David J. Fleet, Tomás Pajdla, Bernt Schiele, and Tinne Tuytelaars, editors, Computer Vision - ECCV 2014 - 13th European Conference, Zurich, Switzerland, September 6-12, 2014, Proceedings, Part V, volume 8693 of Lecture Notes in Computer Science, pages 740–755. Springer, 2014.
|
| 236 |
+
|
| 237 |
+
[29] 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. CoRR, abs/1907.11692, 2019. URL http://arxiv.org/abs/1907. 11692.
|
| 238 |
+
|
| 239 |
+
[30] 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.
|
| 240 |
+
|
| 241 |
+
[31] Jiasen Lu, Dhruv Batra, Devi Parikh, and Stefan Lee. Vilbert: Pretraining task-agnostic visiolinguistic representations for vision-and-language tasks. 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 13–23, 2019. URL https://proceedings.neurips.cc/paper/2019/ hash/c74d97b01eae257e44aa9d5bade97baf-Abstract.html.
|
| 242 |
+
|
| 243 |
+
[32] Shuming Ma, Li Dong, Shaohan Huang, Dongdong Zhang, Alexandre Muzio, Saksham Singhal, Hany Hassan Awadalla, Xia Song, and Furu Wei. Deltalm: Encoder-decoder pre-training for language generation and translation by augmenting pretrained multilingual encoders. CoRR, abs/2106.13736, 2021. URL https://arxiv.org/abs/2106.13736.
|
| 244 |
+
|
| 245 |
+
[33] Vicente Ordonez, Girish Kulkarni, and Tamara L. Berg. Im2text: Describing images using 1 million captioned photographs. In John Shawe-Taylor, Richard S. Zemel, Peter L. Bartlett, Fernando C. N. Pereira, and Kilian Q. Weinberger, editors, Advances in Neural Information Processing Systems 24: 25th Annual Conference on Neural Information Processing Systems 2011. Proceedings of a meeting held 12-14 December 2011, Granada, Spain, pages 1143–1151, 2011. URL https://proceedings.neurips.cc/paper/2011/hash/ 5dd9db5e033da9c6fb5ba83c7a7ebea9-Abstract.html.
|
| 246 |
+
|
| 247 |
+
[34] Bryan A. Plummer, Liwei Wang, Chris M. Cervantes, Juan C. Caicedo, Julia Hockenmaier, and Svetlana Lazebnik. Flickr30k entities: Collecting region-to-phrase correspondences for richer image-to-sentence models. In 2015 IEEE International Conference on Computer Vision, ICCV 2015, Santiago, Chile, December 7-13, 2015, pages 2641–2649. IEEE Computer Society, 2015. doi: 10.1109/ICCV.2015.303. URL https://doi.org/10.1109/ICCV.2015.303.
|
| 248 |
+
|
| 249 |
+
[35] Alec Radford, Karthik Narasimhan, Tim Salimans, and Ilya Sutskever. Improving language understanding by generative pre-training. 2018. URL https://s3-us-west-2.amazonaws.com/openaiassets/research-covers/ language-unsupervised/languageunderstandingpaper.pdf.
|
| 250 |
+
|
| 251 |
+
[36] 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, 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 8748–8763. PMLR, 2021. URL http://proceedings.mlr.press/v139/radford21a.html.
|
| 252 |
+
|
| 253 |
+
[37] 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. J. Mach. Learn. Res., 21:140:1–140:67, 2020. URL http://jmlr. org/papers/v21/20-074.html.
|
| 254 |
+
|
| 255 |
+
[38] Shaoqing Ren, Kaiming He, Ross B. Girshick, and Jian Sun. Faster R-CNN: towards real-time object detection with region proposal networks. IEEE Trans. Pattern Anal. Mach. Intell., 39(6): 1137–1149, 2017. doi: 10.1109/TPAMI.2016.2577031. URL https://doi.org/10.1109/ TPAMI.2016.2577031.
|
| 256 |
+
|
| 257 |
+
[39] 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. IJCV, 2015.
|
| 258 |
+
|
| 259 |
+
[40] Piyush Sharma, Nan Ding, Sebastian Goodman, and Radu Soricut. Conceptual captions: A cleaned, hypernymed, image alt-text dataset for automatic image captioning. In Iryna Gurevych and Yusuke Miyao, editors, Proceedings of the 56th Annual Meeting of the Association for Computational Linguistics, ACL 2018, Melbourne, Australia, July 15-20, 2018, Volume 1: Long Papers, pages 2556–2565. Association for Computational Linguistics, 2018. URL https://aclanthology.org/P18-1238/.
|
| 260 |
+
|
| 261 |
+
[41] Noam Shazeer, Azalia Mirhoseini, Krzysztof Maziarz, Andy Davis, Quoc V. Le, Geoffrey E. Hinton, and Jeff Dean. Outrageously large neural networks: The sparsely-gated mixtureof-experts layer. 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 $\underset { . } { = }$ B1ckMDqlg.
|
| 262 |
+
|
| 263 |
+
[42] Weijie Su, Xizhou Zhu, Yue Cao, Bin Li, Lewei Lu, Furu Wei, and Jifeng Dai. VL-BERT: pretraining of generic visual-linguistic representations. In 8th International Conference on Learning Representations, ICLR 2020, Addis Ababa, Ethiopia, April 26-30, 2020. OpenReview.net, 2020. URL https://openreview.net/forum?id $\cdot ^ { = }$ SygXPaEYvH.
|
| 264 |
+
|
| 265 |
+
[43] Alane Suhr, Stephanie Zhou, Ally Zhang, Iris Zhang, Huajun Bai, and Yoav Artzi. A corpus for reasoning about natural language grounded in photographs. In Anna Korhonen, David R. Traum, and Lluís Màrquez, editors, Proceedings of the 57th Conference of the Association for Computational Linguistics, ACL 2019, Florence, Italy, July 28- August 2, 2019, Volume 1: Long Papers, pages 6418–6428. Association for Computational Linguistics, 2019. doi: 10.18653/v1/p19-1644. URL https://doi.org/10.18653/v1/p19-1644.
|
| 266 |
+
|
| 267 |
+
[44] Hao Tan and Mohit Bansal. LXMERT: learning cross-modality encoder representations from transformers. In Kentaro Inui, Jing Jiang, Vincent Ng, and Xiaojun Wan, editors, 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, Hong Kong, China, November 3-7, 2019, pages 5099–5110. Association for Computational Linguistics, 2019. doi: 10.18653/v1/D19-1514. URL https://doi.org/10.18653/v1/D19-1514.
|
| 268 |
+
|
| 269 |
+
[45] Hugo Touvron, Matthieu Cord, Matthijs Douze, Francisco Massa, Alexandre Sablayrolles, and Hervé Jégou. Training data-efficient image transformers & distillation through attention. preprint arXiv:2012.12877, 2020.
|
| 270 |
+
|
| 271 |
+
[46] Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N. Gomez, Lukasz Kaiser, and Illia Polosukhin. Attention is all you need. 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 5998–6008, 2017. URL http://papers.nips.cc/paper/ 7181-attention-is-all-you-need.
|
| 272 |
+
|
| 273 |
+
[47] 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-to-sequence learning framework. CoRR, abs/2202.03052, 2022. URL https://arxiv.org/abs/2202.03052.
|
| 274 |
+
|
| 275 |
+
[48] Zirui Wang, Jiahui Yu, Adams Wei Yu, Zihang Dai, Yulia Tsvetkov, and Yuan Cao. Simvlm: Simple visual language model pretraining with weak supervision. CoRR, abs/2108.10904, 2021. URL https://arxiv.org/abs/2108.10904.
|
| 276 |
+
|
| 277 |
+
[49] Yonghui Wu, Mike Schuster, Zhifeng Chen, Quoc V. Le, Mohammad Norouzi, Wolfgang Macherey, Maxim Krikun, Yuan Cao, Qin Gao, Klaus Macherey, Jeff Klingner, Apurva Shah, Melvin Johnson, Xiaobing Liu, Lukasz Kaiser, Stephan Gouws, Yoshikiyo Kato, Taku Kudo, Hideto Kazawa, Keith Stevens, George Kurian, Nishant Patil, Wei Wang, Cliff Young, Jason Smith, Jason Riesa, Alex Rudnick, Oriol Vinyals, Greg Corrado, Macduff Hughes, and Jeffrey Dean. Google’s neural machine translation system: Bridging the gap between human and machine translation. CoRR, abs/1609.08144, 2016. URL http://arxiv.org/abs/1609. 08144.
|
| 278 |
+
|
| 279 |
+
[50] Lu Yuan, Dongdong Chen, Yi-Ling Chen, Noel Codella, Xiyang Dai, Jianfeng Gao, Houdong Hu, Xuedong Huang, Boxin Li, Chunyuan Li, Ce Liu, Mengchen Liu, Zicheng Liu, Yumao Lu, Yu Shi, Lijuan Wang, Jianfeng Wang, Bin Xiao, Zhen Xiao, Jianwei Yang, Michael Zeng, Luowei Zhou, and Pengchuan Zhang. Florence: A new foundation model for computer vision. CoRR, abs/2111.11432, 2021. URL https://arxiv.org/abs/2111.11432.
|
| 280 |
+
|
| 281 |
+
[51] Pengchuan Zhang, Xiujun Li, Xiaowei Hu, Jianwei Yang, Lei Zhang, Lijuan Wang, Yejin Choi, and Jianfeng Gao. Vinvl: Revisiting visual representations in vision-language models. In IEEE Conference on Computer Vision and Pattern Recognition, CVPR 2021, virtual, June 19-25, 2021, pages 5579–5588. Computer Vision Foundation / IEEE, 2021. URL https: //openaccess.thecvf.com/content/CVPR2021/html/Zhang_VinVL_Revisiting_ Visual_Representations_in_Vision-Language_Models_CVPR_2021_paper.html.
|
| 282 |
+
|
| 283 |
+
[52] Bolei Zhou, Hang Zhao, Xavier Puig, Tete Xiao, Sanja Fidler, Adela Barriuso, and Antonio Torralba. Semantic understanding of scenes through the ADE20K dataset. Int. J. Comput. Vis., 127(3):302–321, 2019. doi: 10.1007/s11263-018-1140-0. URL https://doi.org/10.1007/ s11263-018-1140-0.
|
| 284 |
+
|
| 285 |
+
[53] Luowei Zhou, Hamid Palangi, Lei Zhang, Houdong Hu, Jason J. Corso, and Jianfeng Gao. Unified vision-language pre-training for image captioning and VQA. In The Thirty-Fourth AAAI Conference on Artificial Intelligence, AAAI 2020, The Thirty-Second Innovative Applications of Artificial Intelligence Conference, IAAI 2020, The Tenth AAAI Symposium on Educational Advances in Artificial Intelligence, EAAI 2020, New York, NY, USA, February 7-12, 2020, pages 13041–13049. AAAI Press, 2020.
|
| 286 |
+
|
| 287 |
+
# Checklist
|
| 288 |
+
|
| 289 |
+
1. For all authors...
|
| 290 |
+
|
| 291 |
+
(a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes]
|
| 292 |
+
(b) Did you describe the limitations of your work? [Yes] Please refer to the conclusion.
|
| 293 |
+
(c) Did you discuss any potential negative societal impacts of your work? [N/A]
|
| 294 |
+
(d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
|
| 295 |
+
|
| 296 |
+
2. If you are including theoretical results...
|
| 297 |
+
|
| 298 |
+
(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]
|
| 299 |
+
|
| 300 |
+
3. If you ran experiments...
|
| 301 |
+
|
| 302 |
+
(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]
|
| 303 |
+
(b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes]
|
| 304 |
+
(c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [Yes] We report average results of multiple runs.
|
| 305 |
+
|
| 306 |
+
(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]
|
| 307 |
+
|
| 308 |
+
4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
|
| 309 |
+
|
| 310 |
+
(a) If your work uses existing assets, did you cite the creators? [Yes]
|
| 311 |
+
(b) Did you mention the license of the assets? [N/A]
|
| 312 |
+
(c) Did you include any new assets either in the supplemental material or as a URL? [Yes]
|
| 313 |
+
(d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [N/A]
|
| 314 |
+
(e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [N/A]
|
| 315 |
+
|
| 316 |
+
5. If you used crowdsourcing or conducted research with human subjects...
|
| 317 |
+
|
| 318 |
+
(a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A]
|
| 319 |
+
(b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A]
|
| 320 |
+
(c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]
|
md/dev/cVak2hs06z/cVak2hs06z.md
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
md/dev/cmt-6KtR4c4/cmt-6KtR4c4.md
ADDED
|
@@ -0,0 +1,333 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# LEVERAGING AUTOMATED UNIT TESTS FOR UNSUPERVISED CODE TRANSLATION
|
| 2 |
+
|
| 3 |
+
Baptiste Rozière Facebook AI Research Paris-Dauphine University broz@fb.com
|
| 4 |
+
|
| 5 |
+
Jie M. Zhang University College London† zhangjie@fb.com
|
| 6 |
+
|
| 7 |
+
François Charton Facebook AI Research fcharton@fb.com
|
| 8 |
+
|
| 9 |
+
Mark Harman
|
| 10 |
+
Facebook
|
| 11 |
+
markharman@fb.com
|
| 12 |
+
|
| 13 |
+
Gabriel Synnaeve Facebook AI Research gab@fb.com
|
| 14 |
+
|
| 15 |
+
Guillaume Lample Facebook AI Research glample@fb.com
|
| 16 |
+
|
| 17 |
+
# ABSTRACT
|
| 18 |
+
|
| 19 |
+
With little to no parallel data available for programming languages, unsupervised methods are well-suited to source code translation. However, the majority of unsupervised machine translation approaches rely on back-translation, a method developed in the context of natural language translation and one that inherently involves training on noisy inputs. Unfortunately, source code is highly sensitive to small changes; a single token can result in compilation failures or erroneous programs, unlike natural languages where small inaccuracies may not change the meaning of a sentence. To address this issue, we propose to leverage an automated unit-testing system to filter out invalid translations, thereby creating a fully tested parallel corpus. We found that fine-tuning an unsupervised model with this filtered data set significantly reduces the noise in the translations so-generated, comfortably outperforming the state-of-the-art for all language pairs studied. In particular, for Java Python and Python $ \mathbf { C } + +$ we outperform the best previous methods by more than $16 \%$ and $24 \%$ respectively, reducing the error rate by more than $3 5 \%$ .
|
| 20 |
+
|
| 21 |
+
# 1 INTRODUCTION
|
| 22 |
+
|
| 23 |
+
Ancient languages such as COBOL still underpin much of the financial industry and government services. Their outdated structures and thinning developer bases induce costs and severely slow down development, prompting businesses to modernize their codebases. For instance, the Commonwealth Bank of Australia spent around $\$ 750$ million over 5 years to migrate its COBOL codebase to a more recent language. More generally, most large companies own code written in several programming languages, which can hinder interoperability and make programmers less efficient. Automatic translation systems could make codebase migrations faster and cheaper, and help programmers learn new languages or understand existing code. Systems to automatically translate between programming languages with approximately the same level of abstraction are called transpilers or sourceto-source compilers. They need to be distinguished from compilers which translate source code to a lower-level language. The particularities of some languages allow the creation of very successful rule-based transpilers for a few language pairs (e.g. Java Scala, CoffeeScript JavaScript). Methods leveraging verified lifting (Kamil et al., 2016), which offer formal guarantees, can significantly speedup some pre-defined code fragments (Ahmad & Cheung, 2016; Ahmad et al., 2019).
|
| 24 |
+
|
| 25 |
+
However, source-to-source translation for arbitrary programming languages is still an open problem. Rule-based systems are commonly used, but they are never exhaustive due to the considerable number of translation rules that should be written to translate every function and object from every standard library. Unlike in natural languages, there is little to no parallel data available for source code, making it impossible to train standard machine translation models. Recently, TransCoder (Roziere et al., 2020) showed that unsupervised methods can be used to translate source code. However, it is trained without any supervised signal and only learns the semantics of tokens from their contexts. As shown in Figure 1, it can confuse tokens that have different semantics in different languages, for instance the float division in Python and integer division in $\mathrm { C } { + } { + }$ and Java which use the token / or more subtle operator priority differences (e.g. Java prioritizes $= =$ over & unlike Python). While small inaccuracies often merely hinder comprehension in natural languages, they often make the entire translation erroneous in the context of programming languages.
|
| 26 |
+
|
| 27 |
+

|
| 28 |
+
Figure 1: Improvements over TransCoder. The first function returns whether an input integer is odd and is translated from Python to Java. The translation of TransCoder does not compile because the $= =$ operator has precedence over & in Java, and parentheses are required unlike in Python. The second example is a function that prints an integer in base two, which is translated from Java to Python. TransCoder translates does not modify the expression $\mathrm { ~ x ~ } / { = } 2$ , even though it corresponds to the integer division in Java and to the float division in Python. In the third example, a function reversing a char array, TransCoder does not manage to translate the Java Stack object into the right Python object and uses the unsafe str parameter name. In all three cases, TransCoder-ST manages to leverage the semantics contained in unit tests to translate the function correctly.
|
| 29 |
+
|
| 30 |
+
TransCoder leverages back-translation (Sennrich et al., 2015), an effective data-augmentation scheme where the model translates source sequences to generate training data for the target-tosource direction, and vice versa. Although being highly effective in low-resource translation, backtranslation also has issues, as the model is trained on potentially invalid input-output pairs. Neural machine translation models being highly sensitive to input noise (Belinkov & Bisk, 2018; Khayrallah & Koehn, 2018), this can severely deteriorate the performance. Fortunately, many programming languages come with relatively mature tools and technologies for automated test data generation. In this paper, we propose to leverage these tools to guide the translation process, weeding out unsuccessful translations, thereby increasing the overall confidence in the machine translation process.
|
| 31 |
+
|
| 32 |
+
The topic of automated test data generation has been active for over three decades in the software engineering research community (Myers, 1979; Miller & Spooner, 1976). There are now many existing mature tools for test data generation, both open source research tools (Fraser & Arcuri, 2011; Lakhotia et al., 2013; Cadar et al., 2008), and production testing systems (Alshahwan et al., 2018; Tillmann et al., 2014). Because of its pivotal impact on practical software engineering, automated testing remains a highly active research area (Anand et al., 2013), with the result that future automated testing advances will lead to ongoing improvement in automated translation.
|
| 33 |
+
|
| 34 |
+
We use one such open source automated test generation tool, EvoSuite (Fraser & Arcuri, 2011), in this paper. EvoSuite is a well-established test generation tool for Java which uses coverage metrics (Chekam et al., 2017) and mutation scores (Jia & Harman, 2011) to generate high-quality tests. It has been widely used in the Software Testing research literature for test data generation although it has not, hitherto, been used as part of an automated code translation approach, the topic of the present paper.
|
| 35 |
+
|
| 36 |
+
More generally, software testing tools have been largely ignored by the machine learning community (Zhang et al., 2020). In this paper, we propose to use automatically created unit tests to guide unsupervised translation models for programming languages. More precisely, we create unit tests automatically for a large number of functions from the source dataset. Since the unit tests are composed of simple inputs and asserts, they can easily be translated to semantically equivalent tests in the target languages using simple scripts. Using our unit-tests and a pre-trained unsupervised translation model, we create parallel datasets by translating functions and selecting the translations that have the same semantics as the original function for the tested inputs. Overall, we make the following contributions:
|
| 37 |
+
|
| 38 |
+
• We introduce a novel approach, TransCoder-ST (for Self-Trained), that leverages an automated unit test generation pipeline to filter out invalid translations and reduce the noise coming from the back-translation process in unsupervised machine translation. • We present two implementations of this approach (online and offline), and show that it significantly outperforms the previous state of the art in code translation on all the language pairs we considered. In particular, we improve the state of the art for translating between Java, Python and $\mathrm { C } { + } { + }$ by an average of $12 . 6 \%$ Computational Accuracy $( \mathbf { C A @ 1 } )$ , corresponding to an average relative improvement of $2 5 . 5 \%$ . For Python $ \mathrm { C } + +$ , we improve the $\mathrm { C A @ 1 }$ by $24 \%$ , reducing the error rate by $3 5 . 7 \%$ compared to previous models. We generate multilingual unit tests for hundreds of thousands of Java functions and create a large parallel dataset of 135,000 parallel functions between Java, Python, and $\mathrm { C } { + } { + }$ . • Our method is completely unsupervised and could easily be generalized to other programming languages and unit test creation tools.
|
| 39 |
+
|
| 40 |
+
# 2 RELATED WORK
|
| 41 |
+
|
| 42 |
+
Unit Test Generation. Software testing is challenging due to the large number of possibilities to be tested, and the inherent cost of covering reasonable representative sample (Myers, 1979). When test design is performed by humans, the cost can be prohibitive. To reduce such cost, much research over the last three decades has focused on automating the process of test generation (Anand et al., 2013). Although automated test generation has been studied since the mid-1970s (Miller & Spooner, 1976), it was only in the last decade that industrial-strength tools have become widely available. There are now several test data generation tools for languages, including C (Cadar et al., 2008; Lakhotia et al., 2013) and Java (Fraser & Arcuri, 2011). Popular test data generation techniques include symbolic execution of the code (Cadar & Sen, 2013), dynamic execution guided by a fitness function (Harman et al., 2015), and hybrids of these two techniques (Baars et al., 2011). Recently, neural networks have also been used successfully to generate unit tests (Tufano et al., 2020).
|
| 43 |
+
|
| 44 |
+
One of the most well-established and widely-used open source tools for test data generation is the EvoSuite system (Fraser & Arcuri, 2011). EvoSuite uses search based software engineering (SBSE) (Harman et al., 2012) to generate test cases. Like all SBSE techniques, EvoSuite is guided by fitness functions, in this case aimed at capturing the test suite’s coverage and mutation score of the code being tested. We use EvoSuite in our work for three reasons: it is publicly available in open source (thereby facilitating replication), it is under current active development (thereby supporting future work), and it is widely used by other researchers (thereby enabling interoperability). The test framework can be considered as a parameter in our overall approach and could be substituted with another.
|
| 45 |
+
|
| 46 |
+
In order to assess the effectiveness of the test suites generated, we use mutation testing, a topic also widely-studied since the 1970s (DeMillo et al., 1978). A mutant is a version of the program into which a fault is deliberately inserted, thereby assessing the test suite’s fault detection ability (Jia & Harman, 2011; Papadakis et al., 2019). For a given set of mutants and a test suite, the mutation score is defined to be the proportion of mutants for which the test suite distinguishes the behavior of the mutant from that of the original program. The mutation score is thus a proxy for the faultrevealing power of the test suite on a set of simulated faults (the mutants). Mutation scores have been empirically demonstrated to be correlated to real fault revelation (Chekam et al., 2017), motivating our adoption of this approach.
|
| 47 |
+
|
| 48 |
+
Machine Learning for Programming Languages. In recent years, deep learning methods have been used to tackle various tasks in software engineering, with a particular interest in bug detection and repair (Wang et al., 2018; Chen et al., 2019; Allamanis et al., 2018; Tarlow et al., 2020; Murali et al., 2021; Dinella et al., 2020; Yasunaga & Liang, 2020; Tufano et al., 2019; Drain et al., 2021) and code completion (Li et al., 2018; Liu et al., 2020; Kim et al., 2021; Svyatkovskiy et al., 2021). Unsupervised pre-training methods for code based on BERT (Kanade et al., 2020; Feng et al., 2020),
|
| 49 |
+
|
| 50 |
+

|
| 51 |
+
Figure 2: Our iterative self-training method. Using EvoSuite, we generate unit tests in Java, Python and $\mathrm { C } { + + }$ corresponding to several input Java functions. With a machine translation model (e.g. TransCoder), we generate several candidate translations of the the Java function in Python and $\mathrm { C } { + + }$ . Generated translations that pass the unit tests are used to create a parallel dataset on which we fine-tune the model. Discarding translations that fail the unit tests reduces the noise of data coming from the back-translation process, and significantly improves the overall performance of the model.
|
| 52 |
+
|
| 53 |
+
BART (Ahmad et al., 2021) or other objectives tailored to source code (Guo et al., 2020; Roziere et al., 2021) have shown strong results on benchmarks such as CodeXGLUE (Lu et al., 2021).
|
| 54 |
+
|
| 55 |
+
Recently, Hendrycks et al. (2021) evaluated the competence of several language models for solving coding challenges. Chen et al. (2021) trained a a large model to generate programs from docstrings and are able to solve $2 8 . 8 \%$ of the problems in their HumanEval dataset. Austin et al. (2021) also evaluated the capabilities of large language models for generating code solving problem statements written in natural language. The goal of code translation is also to generate code solving a specific problem, but the input (code written in a different language) is more precise and often more concise.
|
| 56 |
+
|
| 57 |
+
Translation of Programming Languages Several studies used statistical methods to translate between programming languages. Early methods extracted parallel datasets and trained phrasebased models to translate between $\mathbf { C } \#$ and Java (Nguyen et al., 2013; Karaivanov et al., 2014) or from Python 2 to Python 3 (Aggarwal et al., 2015). Later, Chen et al. (2018) proposed a tree-to-tree neural network to translate between CoffeeScript and JavaScript and between C# and Java using the dataset created by Nguyen et al. (2013). However, these approaches are limited to a few language pairs for which small parallel datasets were created manually (e.g. C#-Java) or can be created with rule-based tools (e.g. Python 2-Python 3 and CoffeeScript-JavaScript).
|
| 58 |
+
|
| 59 |
+
Instead, Roziere et al. (2020) proposed TransCoder, an unsupervised model that leverages the principles of unsupervised machine translation (Lample et al., 2018), to translate between Python, Java and $\mathrm { C } { + } { + }$ . They showed that their method outperforms well-established rule-based baselines, does not require any parallel data or expert knowledge, and can easily be generalized to other languages. They pre-trained their model with the Masked Language Modeling (MLM) objective of Devlin et al. (2018), and trained it with the denoising auto-encoding (DAE) (Vincent et al., 2008) and the back-translation (BT) (Sennrich et al., 2015) objectives. Later, Roziere et al. (2021) showed that augmenting MLM with a deobfuscation objective (dubbed DOBF) can substantially improve the performance of TransCoder. In the rest of the paper, we will refer to their model as DOBF.
|
| 60 |
+
|
| 61 |
+
Even though unsupervised methods can be trained on large amounts of data, they sometimes lack the signal needed to differentiate between semantically different tokens that often occur in similar contexts (see Figure 1). There is a need for a method providing supervised signal directly related to the semantics of the code without manually crafted parallel datasets.
|
| 62 |
+
|
| 63 |
+
# 3 METHOD
|
| 64 |
+
|
| 65 |
+
# 3.1 PARALLEL DATA CREATION
|
| 66 |
+
|
| 67 |
+
Parallel unit test generation: We use EvoSuite to automatically generate unit tests for Java functions. EvoSuite is a well-established open source tool for automated test generation in Java, which is still under active development and frequently used. It is designed for Java programs but its searchbased technique is general and could be used for any programming language. Unit tests can be thought of as lists of inputs and asserts testing the semantics of a program (e.g., the output of the function, the side effects on its arguments such as sorting the input list). EvoSuite uses evolutionary methods to derive tests that maximize criteria such as code coverage or mutation score. During its search, each candidate solution in EvoSuite is a test input. The candidate inputs are evolved using crossover and mutation, and filtered by a fitness function (e.g., mutation score). With each generation the fitness improves until it reaches a plateau or the budget is exhausted. The final test inputs are wrapped up as test cases. Each program is associated to a test suite containing a series of test cases. Figure 3 shows an example of a test case generated by EvoSuite.
|
| 68 |
+
|
| 69 |
+

|
| 70 |
+
Figure 3: A unit test generated by EvoSuite. The Java function clamps the given value $a$ between the given min and max. This test case is not sufficient to test the semantics of the function thoroughly but could be part of a suitable test suite. See Figure 5 in the Appendix for a generated test suite with a high mutation score.
|
| 71 |
+
|
| 72 |
+
Parallel test suites selection: Some test suites created by EvoSuite only cover a few parts of the semantics of functions. We only trust the translations verified by test suites which examine the function semantics thoroughly. We use the mutation score, which is the most effective test assessment metric in the literature (Jia & Harman, 2011), to pick out these test suites. The mutation score is computed through mutation testing, in which mutants (i.e., program variants with syntactic changes) are generated from the original program based on a set of transformation rules (more details in Appendix A.2). A mutant is said to be killed if at least one test from the test suite has different results on the mutant and the original program. Otherwise, the mutant is said to survive. The mutation score is the ratio of killed mutants. A test suite with a higher mutation score checks the code semantics more thoroughly. We adopt a strict strategy in test suite selection: we keep only the Unit test suites with a mutation score larger than $90 \%$ for building the parallel dataset.
|
| 73 |
+
|
| 74 |
+
Parallel dataset building: The generated test suites can be used to test the semantics of programs written in any programming language as long as there is a clear mapping between the types of the output and parameters in the original language and the language of the translated unit tests. We transform the generated Java tests into $\mathrm { C } { + + }$ and Python tests with identical inputs and expected outputs and side effects (i.e., assertions). In practice, we selected the Java functions which can be compiled and run in isolation and with simple output and parameter types. These types are the Java primitive types (e.g. int, long, bool, float. . . ), standard data types (e.g. Integer, Double, String. . . ), array and List or ArrayList types of elements of supported types (e.g. double[], List<Integer>. . . ).
|
| 75 |
+
|
| 76 |
+
We use the best unsupervised translation models available for Java to Python and Java to $\mathrm { C } { + + }$ translation, namely TransCoder (Roziere et al., 2020) for Java to $\mathrm { C } { + + }$ and DOBF (Roziere et al., 2021) for Java to Python. For each Java function, we generate 20 Python and $\mathrm { C } { + + }$ translations with beam search and select the first element in the beam that passes the unit tests. The created tests are executed against the translated functions. If all the tests pass, the Python and $\mathrm { C } { + } { + }$ functions have the same semantics assessed by the generated tests. Our method is illustrated in Figure 2.
|
| 77 |
+
|
| 78 |
+
# 3.2 TRAINING METHOD
|
| 79 |
+
|
| 80 |
+
Our parallel data generation method relies on a pre-existing model to translate from Java to Python and $\mathrm { C } { + } { + }$ . There is little parallel data for these tasks and the best performing published models are unsupervised. TransCoder (Roziere et al., 2020) is trained using the MLM, denoising and backtranslation objectives and is able to translate between Java, $\mathrm { C } { + } { + }$ and Python. DOBF (Roziere et al., 2021) provides clear improvements over TransCoder for translating between Java and Python but was not trained on $\mathrm { C } { + } { + }$ . Therefore, we use DOBF to translate from Java to Python and TransCoder to translate from Java to $\mathrm { C } { + } { + }$ . When fine-tuning, we also reload these models. For DOBF, we initialize the $\mathrm { C } { + } { + }$ language embeddings with those of Java.
|
| 81 |
+
|
| 82 |
+
Table 1: Size of the parallel datasets generated offline at each iteration.
|
| 83 |
+
|
| 84 |
+
<table><tr><td>Languages</td><td>First iteration</td><td>Second iteration</td><td>Third iteration</td><td>Fourth iteration</td></tr><tr><td>Java ←→ C++</td><td>27,875</td><td>37,769</td><td>47,729</td><td>60,495</td></tr><tr><td>Java ←→Python</td><td>33,496</td><td>43,194</td><td>43,956</td><td>45,311</td></tr><tr><td>C++ ←→Python</td><td>14,935</td><td>21,026</td><td>27,080</td><td>32,869</td></tr></table>
|
| 85 |
+
|
| 86 |
+
The parallel examples we generate can be used to improve the performance of pre-existing translation models. Since the number of examples we generate also depends on the performance of the translation model, it creates a positive feedback loop where improving the model allows to improve the parallel dataset which in turn can be used to improve the model again. We propose offline and online approaches to use our method to maximize the unsupervised translation performance.
|
| 87 |
+
|
| 88 |
+
Offline training. With the offline training method, we use the method described in Section 3.1 to create parallel Java Python, $\mathrm { J a v a } \mathrm { C } + +$ and Python $ \mathbf { C } + +$ datasets using every input Java function we selected. For the first iteration, we fine-tune the model on these parallel examples until convergence. We can iterate this process by selecting the best checkpoints for Java Python and Java $ \mathrm { C } + +$ using the validation dataset and using them to generate new parallel datasets, which can in turn be used to train a better model. We iterate this process until convergence, i.e. when we see no significant improvements on the validation set.
|
| 89 |
+
|
| 90 |
+
Online training. With the online method, we create parallel examples on the fly while training the model. Compared to the offline method, it allows to always use the last model to generate new examples and it is much more convenient to automate. However, this process can be unstable if done naively. For instance, the model can start over-fitting only a few examples and stop generating anything that passes the unit tests for any other example. In order to stabilize the training, we follow Likhomanenko et al. (2020) and implement a cache mechanism storing the previous examples that passed the unit tests. At each step, the model can either train on parallel functions sampled from the cache or create new parallel functions to add to the cache. When an example is sampled, we remove it from the cache with a given probability. The online training allows the model to always benefit from the performance of the latest model and the cache mechanism ensures that the model does not forget the correct examples that it was able to generate at previous time steps.
|
| 91 |
+
|
| 92 |
+
# 3.3 EVALUATION
|
| 93 |
+
|
| 94 |
+
In the context of natural languages, machine translation models are generally benchmarked against a reference solution using the BLEU score (Koehn, 2009; Bahdanau et al., 2015; Vaswani et al., 2017). Early studies on source code translation used the same metric to evaluate the quality of the generated functions (Nguyen et al., 2013; Karaivanov et al., 2014; Aggarwal et al., 2015; MiceliBarone & Sennrich, 2017), or the exact match score which requires the translation to be exactly equal to the ground truth (Chen et al., 2018). However, these metrics fail to capture the semantics of the code and typically correlate poorly with the correctness of the generated function, prompting the use of new metrics checking if the generated solution passes series of test cases (Kulal et al., 2019; Roziere et al., 2020; Hendrycks et al., 2021; Chen et al., 2021; Drain et al., 2021).
|
| 95 |
+
|
| 96 |
+
We evaluate our models on the full validation and test sets of TransCoder. It contains a few hundreds of parallel functions extracted from GeeksforGeeks along with associated unit tests. As our TransCoder and DOBF baselines, we evaluate our models with the $\mathrm { C A @ N }$ metric, which checks if any of the top-N solutions proposed by the model passes all the corresponding unit tests. This metric can be computed independently of the beam size (as long as the beam size is greater or equal to N).
|
| 97 |
+
|
| 98 |
+
# 4 EXPERIMENTS
|
| 99 |
+
|
| 100 |
+
# 4.1 TRAINING DETAILS
|
| 101 |
+
|
| 102 |
+
Model architecture. We use a sequence-to-sequence model with attention composed of an encoder and a decoder model with a transformer architecture (Vaswani et al., 2017). In order to provide fair comparisons, we use the exact same architecture as TransCoder: an encoder and a decoder of 6 layers each, a hidden dimension of 1024 and 8 attention heads. We limit the size of the input to 512 tokens. Roziere et al. (2021) train models with two different architectures. For Java Python, we compare ourselves to the version of DOBF using the same architecture as TransCoder. We initialize our models with either the best TransCoder checkpoint for Java $ \mathrm { C } + +$ or the best DOBF checkpoint for Java Python with $\mathrm { C } { + } { + }$ language embeddings initialized with those of Java.
|
| 103 |
+
|
| 104 |
+
Table 2: Computational accuracy scores for our methods and baselines. We show the $\mathrm { C A @ 1 }$ metric computed with beam size 10. For the baselines, we ran the evaluations again and reported the best result between those reported in the original paper and those we obtained. Both the offline and online self-training methods lead to significant improvements over our baselines for every language pair and direction. Online self-training outperforms offline self-training, even after several iterations.
|
| 105 |
+
|
| 106 |
+
<table><tr><td></td><td>C++ →Ja</td><td>C++ →Py</td><td>Ja→C++</td><td>Ja→Py</td><td>Py→C++</td><td>Py→Ja</td><td>AVG</td></tr><tr><td>TransCoder DOBF</td><td>65.1% -</td><td>47.1% 1</td><td>79.8% -</td><td>49.0% 52.7%</td><td>32.6% 1</td><td>36.6% 45.7%</td><td>51.7% 1</td></tr><tr><td>Offline ST 1</td><td>65.5%</td><td>56.2%</td><td>81.6%</td><td>61.8%</td><td>46.8%</td><td>55.1%</td><td>61.1%</td></tr><tr><td>Offline ST 2</td><td>65.5%</td><td>58.3%</td><td>83.7%</td><td>63.3%</td><td>46.4%</td><td>52.2%</td><td>61.6%</td></tr><tr><td>Offline ST 3</td><td>66.5%</td><td>56.2%</td><td>85.2%</td><td>66.3%</td><td>48.1%</td><td>56.6%</td><td>63.1%</td></tr><tr><td>Offline ST 4</td><td>65.3%</td><td>48.2%</td><td>81.1%</td><td>58.1%</td><td>48.9%</td><td>54.7%</td><td>59.4%</td></tr><tr><td>Online ST</td><td>68.0%</td><td>61.3%</td><td>84.6%</td><td>68.9%</td><td>56.7%</td><td>58.2%</td><td>66.3%</td></tr></table>
|
| 107 |
+
|
| 108 |
+
Datasets. As TransCoder and DOBF, we use the GitHub public dataset available on Google BigQuery filtered to keep only projects with open-source licenses1. As our unit test creation tool can only be used on Java code, we only use the Java files and we select only the functions that can be compiled in isolation. We obtain a dataset containing 333,542 Java functions. We run EvoSuite with a budget of 20 seconds and a criterion including the line, branch, cbranch and output coverages, as well as the weak and strong mutation scores. We set the maximum absolute value of integers that can be generated as an input to $\sqrt { 2 ^ { 3 1 } - 1 }$ to limit the number of overflows. We manage to obtain high-quality (mutation score $> 0 . 9$ and at least two asserts) test cases for 103,488 functions. See Figures 3 and 5, 6 in the appendix for examples of selected and filtered out test suites.
|
| 109 |
+
|
| 110 |
+
Training details. During the training, we alternate between batches for every source and target language so that language pairs for which we managed to create more parallel examples are not overrepresented in our training batches. For the online version, we set a cache warm-up parameter to ensure that we always generate new parallel examples if there are less than 500 examples in the cache for any language pair. Otherwise, we sample from the cache with probability 0.5, or generate new examples, train on them once and put them in the cache also with probability 0.5. The sampled elements are removed from the cache with probability 0.3, so that each element we create is trained on about 4 times in average before being removed from the cache. We initialize the cache with parallel examples created offline.
|
| 111 |
+
|
| 112 |
+
During beam decoding, we compute the score of generated sequences by dividing the sum of token log-probabilities by $l ^ { \alpha }$ where $l$ is the sequence length. We found that taking $\alpha = 0 . 5$ (and penalizing long generations) leads to the best performance on the validation set.
|
| 113 |
+
|
| 114 |
+
# 4.2 RESULTS AND DISCUSSION
|
| 115 |
+
|
| 116 |
+
Results. In Tables 2 and 3, we compare the results of our offline and online training methods with those of TransCoder and DOBF. DOBF outperforms TransCoder for the Java Python pair. We compare our models against the best baseline for each language pair and direction.
|
| 117 |
+
|
| 118 |
+
Training on the generated parallel examples brings substantial improvements for every language pair, direction, and metric. Offline training already provides clear improvements over the baseline after one iteration. The computational accuracy $( \mathbf { C A @ 1 } )$ computed with beam size 10 is higher for every direction and it is substantially higher for the language pairs involving Python. It allows to reduce the error rate of the best baseline by $2 5 . 5 \%$ for Java Python. In average, it increases the $\mathrm { C A @ 1 }$ by $7 . 4 \%$ over the best previous models, and reduces the error rate by $1 6 . 6 \%$ . In the two next iterations, the model is trained on significantly more examples (see Table 1). It results in average improvements of $2 \%$ points between the first and third iteration. Although the model for the fourth iteration is trained on more parallel samples, its performance on the test set of TransCoder is actually worse than after the third iteration. After three iterations, the model learned to generate more samples that pass the unit tests but some of them are actually incompatible with the types of translations expected by TransCoder (e.g. example with overflows in Figure 4), causing the computational accuracy score to go down.
|
| 119 |
+
|
| 120 |
+
Table 3: $\mathbf { C A @ n }$ metric for several beam sizes averaged on all language pairs. The value k corresponds to the beam size. For instance, $\mathbf { C A @ 1 k = } 1 0$ means that we use beam decoding to generate 10 translations, and select the one with the highest score. The best baseline corresponds to taking the best model between TransCoder and DOBF for every language pair and direction. The error rate reduction of the offline and online self-training methods over the best baseline are high $( > 2 0 \%$ ) across all $\mathrm { C A @ N }$ metrics and beam sizes.
|
| 121 |
+
|
| 122 |
+
<table><tr><td></td><td>CA@1 k=1</td><td>CA@1 k=10</td><td>CA@1 k=20</td><td>CA@10 k=10</td><td>CA@20 k=20</td></tr><tr><td>Best baseline</td><td>52.2%</td><td>53.7%</td><td>53.4%</td><td>67.3%</td><td>70.5%</td></tr><tr><td>Offline ST 1</td><td>60.8%</td><td>61.1%</td><td>61.1%</td><td>72.9%</td><td>75.3%</td></tr><tr><td>Offline ST 2</td><td>61.4%</td><td>61.6%</td><td>61.4%</td><td>73.3%</td><td>75.8%</td></tr><tr><td>Offline ST 3</td><td>61.7%</td><td>63.1%</td><td>63.0%</td><td>73.3%</td><td>75.8%</td></tr><tr><td>Offline ST 4</td><td>58.5%</td><td>59.4%</td><td>59.2%</td><td>70.8%</td><td>73.6%</td></tr><tr><td>Online ST</td><td>64.7%</td><td>66.3%</td><td>66.3%</td><td>75.4%</td><td>77.2%</td></tr></table>
|
| 123 |
+
|
| 124 |
+
Table 4: Ablation study. We show the $\mathbf { C A } \ @ 1$ metric computed with greedy decoding at evaluation time except for the last line where the beam size is set to 10. We evaluate models trained with no cache system, without initializing the cache (with or without selecting the tests with a minimum mutation score of 0.9), and a beam size of 1 when generating examples. We also compare the $\mathrm { C A @ 1 }$ score of our full model when evaluating with greedy decoding and with beam size 10. Using a pre-filled cache and selecting only the tests with a high mutation score lead to substantially better performance, although these steps are not necessary to outperform our baseline. The online method already performs well with greedy decoding at generation time, but generating with beam size 20 further improves the results.
|
| 125 |
+
|
| 126 |
+
<table><tr><td></td><td>C++→Ja</td><td>C++ →Py</td><td>Ja→C++</td><td>Ja→Py</td><td>Py→C++</td><td>Py→Ja</td><td>AVG</td></tr><tr><td>No cache</td><td>66.5%</td><td>52.7%</td><td>83.7%</td><td>60.3%</td><td>41.2%</td><td>51.8%</td><td>59.4%</td></tr><tr><td>Cache not initialized</td><td>64.9%</td><td>51.6%</td><td>82.4%</td><td>62.4%</td><td>46.6%</td><td>52.6%</td><td>60.1%</td></tr><tr><td>+ No min mut. score</td><td>64.0%</td><td>50.1%</td><td>82.6%</td><td>60.9%</td><td>47.4%</td><td>47.0%</td><td>58.7%</td></tr><tr><td>ST greedy decoding</td><td>65.9%</td><td>54.2%</td><td>82.2%</td><td>60.9%</td><td>56.2%</td><td>56.6%</td><td>62.7%</td></tr><tr><td>Full model(ST beam 20)</td><td>66.7%</td><td>61.1%</td><td>84.1%</td><td>67.8%</td><td>52.2%</td><td>56.7%</td><td>64.7%</td></tr><tr><td>+ Eval beam 10</td><td>68.0%</td><td>61.3%</td><td>84.6%</td><td>68.9%</td><td>56.7%</td><td>58.2%</td><td>66.3%</td></tr></table>
|
| 127 |
+
|
| 128 |
+
The online self-training method provides further improvements over training on the pseudo-labeled examples offline. It outperforms every other method in every case except the third iteration of offline training for Java $ \mathrm { C } + +$ . In average, this model outperforms the baseline by $12 . 6 \%$ points, corresponding to an error rate reduction of $2 5 . 5 \%$ . For Python $ \mathrm { C } + +$ , it improves previous performance by more than $24 \%$ points, which corresponds to reducing the error rate by $3 5 . 7 \%$ . Examples of avoided errors can be found in Figure 1 and Appendix B. Overall, all our models significantly improve previous results. As shown in Table 3, these improvements are stable across several beam sizes and $\mathbf { \mathrm { C A @ n } }$ metrics. The $\mathrm { C A @ 2 0 }$ metric shows that the number of examples for which none of the 20 elements in the beam are correct is reduced by more than $22 \%$ with online self-training. It indicates that, even though we train only on the output of the model, our method does much more than reordering the elements in the beam and allows the model to find correct solutions that were not assigned a high probability by the baseline model. See Table 6 in the appendix for more results.
|
| 129 |
+
|
| 130 |
+
Ablation study. The results of our ablation study are shown in Table 4. Training online with no cache makes the training much less stable. The model improves at the beginning of training and we can select a few checkpoints where it performs well, but it ends up over-fitting a few examples it generated and the performance drops after a few epochs. Starting with an empty cache slows down the training and hinders generalization, leading to a clear drop in performance. We also try removing the minimum mutation score requirement for the model with no initial cache, which leads to even lower scores as the model is trained partly on lower-quality parallel data.
|
| 131 |
+
|
| 132 |
+
All these models were trained using a self-training beam size of 20 when generating new examples. Training with greedy decoding is much faster since computing the results for all the 20 elements of the beam is costly. However, generating new examples with greedy decoding leads to a loss of about two percentage points in average compared to our full model using beams of size 20. It shows that initializing the cache of the model with beam size 20 is not sufficient and creating new examples with beam search is necessary to reach our best performance. Our full model provides some improvements over the ablated versions for every language pair and direction, except over the model trained with greedy decoding for Python $ \mathrm { C } + +$ translation. Evaluating with beam size 10 (still returning only the first element) leads to some improvements for every language pair.
|
| 133 |
+
|
| 134 |
+
Limitations. We found that the unit tests we create with this method are sometimes incompatible with those of the test set of TransCoder, and that the capacity of a model to generate functions that pass these unit tests is not perfectly correlated to its score on the test set. It raises the deeper issue of defining what constitutes a correct translation. For instance, most programmers would translate a factorial function implemented with long integers into a factorial function implemented with Python’s integer type. However, these functions are not semantically equivalent since the Java implementation would return a negative number for the input 21 due to integer overflow while the Python implementation would return 21! correctly. The human developers who wrote the parallel functions in the test set of TransCoder often assumed that these functions would only be used on a limited domain where no overflow occurs (see Figure 4). However, the test cases of EvoSuite and TransCoder are not limited to this domain and they sometimes assert different semantics. By using the test suites from EvoSuite as source of truth, we sometimes train the model to generate translations that are more rigorous but also less natural.
|
| 135 |
+
|
| 136 |
+
<table><tr><td>Input Java function</td><td>Gold translation</td><td>Translation passing multilingual tests</td></tr><tr><td>static int factorial(int n){</td><td>def factorial(n):</td><td>def factorial(n) :</td></tr><tr><td>if (n<2) return 1;</td><td>ifn<2:</td><td>n = np.int32(n)</td></tr><tr><td>return n * factorial(n - 1);</td><td>return 1</td><td>ifn<2:</td></tr><tr><td></td><td>return n factorial(n-1)</td><td>return np.int32(1)</td></tr><tr><td></td><td></td><td>return n factorial(n - 1)</td></tr></table>
|
| 137 |
+
|
| 138 |
+
# 5 CONCLUSION
|
| 139 |
+
|
| 140 |
+
In this paper, we introduced a novel method to grow a parallel corpus for automated code translation, from completely monolingual data. We leverage multilingual unit tests to filter good pseudo-labels, improving the model, and in turn the candidate translations. We show that both offline and online methods substantially improve the state of the art in unsupervised code translation, with an average improvement of $12 . 6 \%$ points in computational accuracy, and up to $24 \%$ points for Python $ \mathrm { C } + +$ , corresponding to translation error rate reductions of $2 5 . 5 \%$ and $3 5 . 7 \%$ respectively, without using any unit test generation tool for Python and $\mathrm { C } { + } { + }$ (exclusively for Java).
|
| 141 |
+
|
| 142 |
+
Our method would automatically gain from improvements of automatic unit test generation tools. We could also increase the size of the dataset we generate by using test creation tools written for other languages in addition to Java, or by generating tests with EvoSuite on translated examples. Similarly, we could also extract the semantics of human-written unit tests found in open-source projects to obtain larger, and possibly higher-quality datasets. In this paper, we focused on translation correctness and our parallel example validation criterion was only based on semantics. It could be supplemented with other requirements, such as a specific code formatting or the output of linters to generate code verifying arbitrary criteria. Finally, the approach presented in this paper could easily be transferred to natural languages. Although there is no concept of unit tests in natural language, traditional grammar and syntax checkers could be used to filter out some incorrect generations, and reduce the noise coming from the back-translation process. Neural machine translation systems being highly sensitive to noise coming from parallel data (Belinkov & Bisk, 2018; Khayrallah & Koehn, 2018), this may improve the performance in low-resource machine translation significantly.
|
| 143 |
+
|
| 144 |
+
# REPRODUCIBILITY
|
| 145 |
+
|
| 146 |
+
We made sure to use the same architecture and framework as previous works in source code translation so that our results are comparable (see Section 4.1). We submit our code with this submission, along with a ReadMe file detailing clear steps to reproduce our results, including a script to set-up a suitable environment. We will open-source our code and release our trained models. Our models were trained using standard hardware (Tesla V100 GPUs) and libraries (e.g. Pytorch, Cuda) for machine-learning research.
|
| 147 |
+
|
| 148 |
+
# ETHICAL CONSIDERATIONS
|
| 149 |
+
|
| 150 |
+
In this paper, we improve source code translation methods. Our methods could facilitate codebase migrations and interoperability, encouraging companies to move away from ancient programming languages and making software developers more efficient. Although increased efficiency could reduce the number of developers needed to perform a task, its impact on the labor market is unclear as lower costs would also lower the bar for starting new projects and increase the demand for software engineers. Today, the demand for software engineering skills is high despite (or thanks to) the development of software (e.g. git, IDEs), programming languages (e.g. python), libraries (e.g. pytorch) and methodologies (e.g. continuous deployment) improving the efficiency of software developers, and we believe that the development of automatic translation tools would not drastically affect the prospects of software developers either. In the long term, the migration of codebases written in antiquated programming languages (e.g. COBOL) could negatively impact experts in those languages, who are in particularly high demand at the moment. However, it would also benefit society by facilitating debugging and updating software still used in most of our financial transactions and for many government services, and by increasing the demand for other software engineering skills.
|
| 151 |
+
|
| 152 |
+
# REFERENCES
|
| 153 |
+
|
| 154 |
+
Karan Aggarwal, Mohammad Salameh, and Abram Hindle. Using machine translation for converting python 2 to python 3 code. Technical report, PeerJ PrePrints, 2015.
|
| 155 |
+
|
| 156 |
+
Maaz Bin Safeer Ahmad and Alvin Cheung. Leveraging parallel data processing frameworks with verified lifting. SYNT@CAV, 2016.
|
| 157 |
+
|
| 158 |
+
Maaz Bin Safeer Ahmad, Jonathan Ragan-Kelley, Alvin Cheung, and Shoaib Kamil. Automatically translating image processing libraries to halide. ACM Transactions on Graphics (TOG), 38(6): 1–13, 2019.
|
| 159 |
+
|
| 160 |
+
Wasi Ahmad, Saikat Chakraborty, Baishakhi Ray, and Kai-Wei Chang. Unified pre-training for program understanding and generation. In Proceedings of the 2021 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, pp. 2655–2668, 2021.
|
| 161 |
+
|
| 162 |
+
Miltiadis Allamanis, Marc Brockschmidt, and Mahmoud Khademi. Learning to represent programs with graphs. In International Conference on Learning Representations, 2018.
|
| 163 |
+
|
| 164 |
+
Nadia Alshahwan, Xinbo Gao, Mark Harman, Yue Jia, Ke Mao, Alexander Mols, Taijin Tei, and Ilya Zorin. Deploying search based software engineering with Sapienz at Facebook (keynote paper). In $1 0 ^ { t h }$ International Symposium on Search Based Software Engineering (SSBSE 2018), pp. 3–45, Montpellier, France, September 8th-10th 2018. Springer LNCS 11036.
|
| 165 |
+
|
| 166 |
+
Saswat Anand, Antonia Bertolino, Edmund Burke, Tsong Yueh Chen, John Clark, Myra B. Cohen, Wolfgang Grieskamp, Mark Harman, Mary Jean Harrold, Jenny Li, Phil McMinn, and Hong Zhu. An orchestrated survey of methodologies for automated software test case generation. Journal of Systems and Software, 86(8):1978–2001, August 2013.
|
| 167 |
+
|
| 168 |
+
Jacob Austin, Augustus Odena, Maxwell Nye, Maarten Bosma, Henryk Michalewski, David Dohan, Ellen Jiang, Carrie Cai, Michael Terry, Quoc Le, et al. Program synthesis with large language models. arXiv preprint arXiv:2108.07732, 2021.
|
| 169 |
+
|
| 170 |
+
Arthur Baars, Mark Harman, Youssef Hassoun, Kiran Lakhotia, Phil McMinn, Paolo Tonella, and Tanja Vos. Symbolic search-based testing. In $2 6 ^ { t h }$ IEEE/ACM International Conference on Automated Software Engineering (ASE 2011), pp. 53 – 62, Lawrence, Kansas, USA, 6th - 10th November 2011.
|
| 171 |
+
|
| 172 |
+
Dzmitry Bahdanau, Kyung Hyun Cho, and Yoshua Bengio. Neural machine translation by jointly learning to align and translate. In 3rd International Conference on Learning Representations, 2015.
|
| 173 |
+
|
| 174 |
+
Yonatan Belinkov and Yonatan Bisk. Synthetic and natural noise both break neural machine translation. In International Conference on Learning Representations, 2018.
|
| 175 |
+
|
| 176 |
+
Cristian Cadar and Koushik Sen. Symbolic execution for software testing: Three decades later. Communications of the ACM, 56(2):82–90, February 2013. ISSN 0001-0782.
|
| 177 |
+
|
| 178 |
+
Cristian Cadar, Daniel Dunbar, Dawson R Engler, et al. Klee: unassisted and automatic generation of high-coverage tests for complex systems programs. In OSDI, volume 8, pp. 209–224, 2008.
|
| 179 |
+
|
| 180 |
+
Thierry Titcheu Chekam, Mike Papadakis, Yves Le Traon, and Mark Harman. An empirical study on mutation, statement and branch coverage fault revelation that avoids the unreliable clean program assumption. In Proceedings of the 39th International Conference on Software Engineering, ICSE 2017, Buenos Aires, Argentina, May 20-28, 2017, pp. 597–608, 2017.
|
| 181 |
+
|
| 182 |
+
Mark Chen, Jerry Tworek, Heewoo Jun, Qiming Yuan, Henrique Ponde, Jared Kaplan, Harri Edwards, Yura Burda, Nicholas Joseph, Greg Brockman, et al. Evaluating large language models trained on code. arXiv preprint arXiv:2107.03374, 2021.
|
| 183 |
+
|
| 184 |
+
Xinyun Chen, Chang Liu, and Dawn Song. Tree-to-tree neural networks for program translation. In Advances in neural information processing systems, pp. 2547–2557, 2018.
|
| 185 |
+
|
| 186 |
+
Zimin Chen, Steve James Kommrusch, Michele Tufano, Louis-Noël Pouchet, Denys Poshyvanyk, and Martin Monperrus. Sequencer: Sequence-to-sequence learning for end-to-end program repair. IEEE Transactions on Software Engineering, 2019.
|
| 187 |
+
|
| 188 |
+
Richard A. DeMillo, Richard J. Lipton, and Frederick G. Sayward. Hints on test data selection: Help for the practical programmer. IEEE Computer, 11:31–41, 1978.
|
| 189 |
+
|
| 190 |
+
Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. Bert: Pre-training of deep bidirectional transformers for language understanding. CoRR, abs/1810.04805, 2018.
|
| 191 |
+
|
| 192 |
+
Elizabeth Dinella, Hanjun Dai, Ziyang Li, Mayur Naik, Le Song, and Ke Wang. Hoppity: Learning graph transformations to detect and fix bugs in programs. In International Conference on Learning Representations (ICLR), 2020.
|
| 193 |
+
|
| 194 |
+
Dawn Drain, Colin B Clement, Guillermo Serrato, and Neel Sundaresan. Deepdebug: Fixing python bugs using stack traces, backtranslation, and code skeletons. arXiv preprint arXiv:2105.09352, 2021.
|
| 195 |
+
|
| 196 |
+
Zhangyin Feng, Daya Guo, Duyu Tang, Nan Duan, Xiaocheng Feng, Ming Gong, Linjun Shou, Bing Qin, Ting Liu, Daxin Jiang, et al. Codebert: A pre-trained model for programming and natural languages. In Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing: Findings, pp. 1536–1547, 2020.
|
| 197 |
+
|
| 198 |
+
Gordon Fraser and Andrea Arcuri. EvoSuite: automatic test suite generation for object-oriented software. In $8 ^ { t h }$ European Software Engineering Conference and the ACM SIGSOFT Symposium on the Foundations of Software Engineering (ESEC/FSE ’11), pp. 416–419. ACM, September 5th - 9th 2011. ISBN 978-1-4503-0443-6.
|
| 199 |
+
|
| 200 |
+
Gordon Fraser and Andrea Arcuri. Achieving scalable mutation-based generation of whole test suites. Empirical Software Engineering, 20(3):783–812, 2015.
|
| 201 |
+
|
| 202 |
+
Daya Guo, Shuo Ren, Shuai Lu, Zhangyin Feng, Duyu Tang, LIU Shujie, Long Zhou, Nan Duan, Alexey Svyatkovskiy, Shengyu Fu, et al. Graphcodebert: Pre-training code representations with data flow. In International Conference on Learning Representations, 2020.
|
| 203 |
+
|
| 204 |
+
Mark Harman, Afshin Mansouri, and Yuanyuan Zhang. Search based software engineering: Trends, techniques and applications. ACM Computing Surveys, 45(1):11:1–11:61, November 2012.
|
| 205 |
+
|
| 206 |
+
Mark Harman, Yue Jia, and Yuanyuan Zhang. Achievements, open problems and challenges for search based software testing (keynote paper). In $8 ^ { t h }$ IEEE International Conference on Software Testing, Verification and Validation (ICST 2015), Graz, Austria, April 2015.
|
| 207 |
+
|
| 208 |
+
Dan Hendrycks, Steven Basart, Saurav Kadavath, Mantas Mazeika, Akul Arora, Ethan Guo, Collin Burns, Samir Puranik, Horace He, Dawn Song, et al. Measuring coding challenge competence with apps. arXiv preprint arXiv:2105.09938, 2021.
|
| 209 |
+
|
| 210 |
+
Yue Jia and Mark Harman. An analysis and survey of the development of mutation testing. IEEE Transactions on Software Engineering, 37(5):649 – 678, September–October 2011.
|
| 211 |
+
|
| 212 |
+
Shoaib Kamil, Alvin Cheung, Shachar Itzhaky, and Armando Solar-Lezama. Verified lifting of stencil computations. ACM SIGPLAN Notices, 51(6):711–726, 2016.
|
| 213 |
+
|
| 214 |
+
Aditya Kanade, Petros Maniatis, Gogul Balakrishnan, and Kensen Shi. Learning and evaluating contextual embedding of source code. In International Conference on Machine Learning, pp. 5110–5121. PMLR, 2020.
|
| 215 |
+
|
| 216 |
+
Svetoslav Karaivanov, Veselin Raychev, and Martin Vechev. Phrase-based statistical translation of programming languages. In Proceedings of the 2014 ACM International Symposium on New Ideas, New Paradigms, and Reflections on Programming & Software, pp. 173–184, 2014.
|
| 217 |
+
|
| 218 |
+
Huda Khayrallah and Philipp Koehn. On the impact of various types of noise on neural machine translation. In Proceedings of the 2nd Workshop on Neural Machine Translation and Generation, pp. 74–83, 2018.
|
| 219 |
+
|
| 220 |
+
Seohyun Kim, Jinman Zhao, Yuchi Tian, and Satish Chandra. Code prediction by feeding trees to transformers. In 2021 IEEE/ACM 43rd International Conference on Software Engineering (ICSE), pp. 150–162. IEEE, 2021.
|
| 221 |
+
|
| 222 |
+
Philipp Koehn. Statistical machine translation. Cambridge University Press, 2009.
|
| 223 |
+
|
| 224 |
+
Sumith Kulal, Panupong Pasupat, Kartik Chandra, Mina Lee, Oded Padon, Alex Aiken, and Percy S Liang. Spoc: Search-based pseudocode to code. Advances in Neural Information Processing Systems, 32:11906–11917, 2019.
|
| 225 |
+
|
| 226 |
+
Kiran Lakhotia, Mark Harman, and Hamilton Gross. AUSTIN: An open source tool for search based software testing of C programs. Journal of Information and Software Technology, 55(1):112–125, January 2013.
|
| 227 |
+
|
| 228 |
+
Guillaume Lample, Myle Ott, Alexis Conneau, Ludovic Denoyer, and Marc’Aurelio Ranzato. Phrase-based & neural unsupervised machine translation. In EMNLP, 2018.
|
| 229 |
+
|
| 230 |
+
Jian Li, Yue Wang, Michael R Lyu, and Irwin King. Code completion with neural attention and pointer networks. IJCAI, 2018.
|
| 231 |
+
|
| 232 |
+
Tatiana Likhomanenko, Qiantong Xu, Jacob Kahn, Gabriel Synnaeve, and Ronan Collobert. slimipl: Language-model-free iterative pseudo-labeling. arXiv preprint arXiv:2010.11524, 2020.
|
| 233 |
+
|
| 234 |
+
Fang Liu, Ge Li, Bolin Wei, Xin Xia, Zhiyi Fu, and Zhi Jin. A self-attentional neural architecture for code completion with multi-task learning. In Proceedings of the 28th International Conference on Program Comprehension, pp. 37–47, 2020.
|
| 235 |
+
|
| 236 |
+
Shuai Lu, Daya Guo, Shuo Ren, Junjie Huang, Alexey Svyatkovskiy, Ambrosio Blanco, Colin Clement, Dawn Drain, Daxin Jiang, Duyu Tang, et al. Codexglue: A machine learning benchmark dataset for code understanding and generation. arXiv preprint arXiv:2102.04664, 2021.
|
| 237 |
+
|
| 238 |
+
Antonio Valerio Miceli-Barone and Rico Sennrich. A parallel corpus of python functions and documentation strings for automated code documentation and code generation. In Proceedings of the Eighth International Joint Conference on Natural Language Processing (Volume 2: Short Papers), pp. 314–319, 2017.
|
| 239 |
+
|
| 240 |
+
W. Miller and D. Spooner. Automatic generation of floating-point test data. IEEE Transactions on Software Engineering, 2(3):223–226, 1976.
|
| 241 |
+
|
| 242 |
+
Vijayaraghavan Murali, Lee Gross, Rebecca Qian, and Satish Chandra. Industry-scale ir-based bug localization: A perspective from facebook. In 2021 IEEE/ACM 43rd International Conference on Software Engineering: Software Engineering in Practice (ICSE-SEIP), pp. 188–197. IEEE, 2021.
|
| 243 |
+
|
| 244 |
+
Glenford J. Myers. The Art of Software Testing. Wiley - Interscience, New York, 1979. ISBN 0-471-04328-1.
|
| 245 |
+
|
| 246 |
+
Anh Tuan Nguyen, Tung Thanh Nguyen, and Tien N Nguyen. Lexical statistical machine translation for language migration. In Proceedings of the 2013 9th Joint Meeting on Foundations of Software Engineering, pp. 651–654, 2013.
|
| 247 |
+
|
| 248 |
+
Mike Papadakis, Marinos Kintis, Jie Zhang, Yue Jia, Yves Le Traon, and Mark Harman. Mutation testing advances: an analysis and survey. In Advances in Computers, volume 112, pp. 275–378. Elsevier, 2019.
|
| 249 |
+
|
| 250 |
+
Baptiste Roziere, Marie-Anne Lachaux, Lowik Chanussot, and Guillaume Lample. Unsupervised translation of programming languages. Advances in Neural Information Processing Systems, 33, 2020.
|
| 251 |
+
|
| 252 |
+
Baptiste Roziere, Marie-Anne Lachaux, Marc Szafraniec, and Guillaume Lample. DOBF: A deobfuscation pre-training objective for programming languages. arXiv preprint arXiv:2102.07492, 2021.
|
| 253 |
+
|
| 254 |
+
Rico Sennrich, Barry Haddow, and Alexandra Birch. Improving neural machine translation models with monolingual data. In Proceedings of the 54th Annual Meeting of the Association for Computational Linguistics, pp. 86–96, 2015.
|
| 255 |
+
|
| 256 |
+
Alexey Svyatkovskiy, Sebastian Lee, Anna Hadjitofi, Maik Riechert, Juliana Vicente Franco, and Miltiadis Allamanis. Fast and memory-efficient neural code completion. In 2021 IEEE/ACM 18th International Conference on Mining Software Repositories (MSR), pp. 329–340. IEEE, 2021.
|
| 257 |
+
|
| 258 |
+
Daniel Tarlow, Subhodeep Moitra, Andrew Rice, Zimin Chen, Pierre-Antoine Manzagol, Charles Sutton, and Edward Aftandilian. Learning to fix build errors with graph2diff neural networks. In Proceedings of the IEEE/ACM 42nd International Conference on Software Engineering Workshops, pp. 19–20, 2020.
|
| 259 |
+
|
| 260 |
+
Nikolai Tillmann, Jonathan de Halleux, and Tao Xie. Transferring an automated test generation tool to practice: From Pex to Fakes and Code Digger. In 29th ACM/IEEE International Conference on Automated Software Engineering (ASE), pp. 385–396, 2014.
|
| 261 |
+
|
| 262 |
+
Michele Tufano, Cody Watson, Gabriele Bavota, Massimiliano Di Penta, Martin White, and Denys Poshyvanyk. An empirical study on learning bug-fixing patches in the wild via neural machine translation. ACM Transactions on Software Engineering and Methodology (TOSEM), 28(4):1– 29, 2019.
|
| 263 |
+
|
| 264 |
+
Michele Tufano, Dawn Drain, Alexey Svyatkovskiy, Shao Kun Deng, and Neel Sundaresan. Unit test case generation with transformers. arXiv preprint arXiv:2009.05617, 2020.
|
| 265 |
+
|
| 266 |
+
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.
|
| 267 |
+
|
| 268 |
+
Pascal Vincent, Hugo Larochelle, Yoshua Bengio, and Pierre-Antoine Manzagol. Extracting and composing robust features with denoising autoencoders. In Proceedings of the 25th international conference on Machine learning, pp. 1096–1103, 2008.
|
| 269 |
+
|
| 270 |
+
Ke Wang, Rishabh Singh, and Zhendong Su. Dynamic neural program embeddings for program repair. In International Conference on Learning Representations, 2018.
|
| 271 |
+
|
| 272 |
+
Michihiro Yasunaga and Percy Liang. Graph-based, self-supervised program repair from diagnostic feedback. In International Conference on Machine Learning, pp. 10799–10808. PMLR, 2020.
|
| 273 |
+
|
| 274 |
+
Jie M Zhang, Mark Harman, Lei Ma, and Yang Liu. Machine learning testing: Survey, landscapes and horizons. IEEE Transactions on Software Engineering, 2020.
|
| 275 |
+
|
| 276 |
+
# A MULTILINGUAL UNIT TESTS CREATION
|
| 277 |
+
|
| 278 |
+
# A.1 GENERATED UNIT TESTS
|
| 279 |
+
|
| 280 |
+

|
| 281 |
+
Figure 5: A generated unit test suite with high mutation score. The mutation score of this test suite is $9 5 \%$ and we selected it in our dataset for pseudo-labelling. The third test case (i.e. test2) may be too strict as it would make translations using the python int type fail the unit tests.
|
| 282 |
+
Figure 6: A test suite with a good mutation score but only one assert. Even though it contains only one test and one assert, this test suite tests the semantics of the function on the left properly since it only returns a constant and its mutation score is $100 \%$ . We found that test suites with good mutation scores and only one assert generally correspond to uninteresting input functions. Removing these functions and tests from our dataset for self labelling improves the performance of our model.
|
| 283 |
+
|
| 284 |
+
<table><tr><td>Java function</td><td>Generated test suite</td></tr><tr><td>public static int sizeBits_cmd(){ return 8;</td><td>public void test0() throws Throwable{ assertEquals(8,Example.sizeBits_cmd());</td></tr></table>
|
| 285 |
+
|
| 286 |
+
As discussed in Section 3.1, we only generate unit tests for static functions with selected return and parameter types. It makes it easy to map the types of inputs and outputs in Java to Python or $\mathrm { C } { + } { + }$ types in the translated unit tests. While most of the unit tests are translated correctly, the translation sometimes fails due to EvoSuite generating test cases expecting exceptions. Our analysis shows that it happens for about $5 . 6 \%$ of all tests and less than $2 \%$ of the tests with high mutation scores. In that case, the candidate translations cannot pass the translated tests and no parallel examples are created.
|
| 287 |
+
|
| 288 |
+
# A.2 MUTATION SCORE
|
| 289 |
+
|
| 290 |
+
In mutation testing, mutants are programs transformed from the original programs based on a series of syntactic transformation rules called mutation operators. Mutation testing consists in introducing minor syntactic faults on the code and running the tests against the mutated code. A strong test suite is expected to detect the code changes by having at least one test failing. Table 5 shows the examples of mutation operators adopted in EvoSuite when generating mutants (Fraser & Arcuri, 2015).
|
| 291 |
+
|
| 292 |
+
A mutant is said to be killed by a test case if the output of this test case on the mutant is different from its output on the original program (i.e., the test fails the mutant). Otherwise, the mutant is said to have survived. Figure 7 shows an example of a mutant generated by changing the $<$ in the return statement into $>$ . The test with input (-800, -800, -1), as shown by Figure 3, does not kill this generated mutant, because its outputs on the original program and the mutant are the same.
|
| 293 |
+
|
| 294 |
+
Mutation score is considered as the most effective criteria in accessing the fault-revealing ability of test suites. Other criteria, such as code coverage, are weak: they check only whether the test executes the code, but do not check whether the execution result is correct. A test suite without any assertions can achieve $100 \%$ code coverage, but could not detect any faults.
|
| 295 |
+
|
| 296 |
+

|
| 297 |
+
Figure 7: A mutant generated by the “Replace arithmetic operator” mutation in EvoSuite. The $<$ operator in the return statement is replaced with $>$ .
|
| 298 |
+
|
| 299 |
+

|
| 300 |
+
Figure 8: Histogram of mutation scores for our generated unit tests. We select about $40 \%$ of the unit tests with our threshold at 0.9. Many of the remaining unit tests have a mutation score of 0.
|
| 301 |
+
|
| 302 |
+

|
| 303 |
+
Figure 9: Python to $\mathbf { C } + +$ translation examples. TransCoder sometimes fails to capture the semantics of the incoming code and translates them to other expressions that could occur in similar contexts. Self-training helps the model to avoid such mistakes.
|
| 304 |
+
|
| 305 |
+

|
| 306 |
+
Figure 10: Python to Java translation examples. Similarly to Python to $\mathrm { C } { + + }$ , TransCoder often fails to get the right semantics, especially for conditions where it can hallucinate extra clauses or write incorrect comparisons. TransCoder-ST often solves these issues.
|
| 307 |
+
|
| 308 |
+

|
| 309 |
+
Figure 11: $\mathbf { C } + +$ to Python translation examples. For $\mathrm { C } { + } { + }$ to Python translation, many of the errors of TransCoder come from incorrectly translated conditions, wrong operators and badly translated functions. TransCoder-ST better comprehends the semantics of the code and is generally able to solve these issues.
|
| 310 |
+
|
| 311 |
+

|
| 312 |
+
Figure 12: $\mathbf { C } { + + }$ to Java translation examples. In the first example computed the minimum XOR between two elements of an array, TransCoder erroneously translates INT_MAX into Integer.MIN_VALUE. This value is used in similar contexts (i.e. to compute a maximum instead of a minimum) but is inappropriate here. TransCoder-ST manages to correct this and outputs a function with the right semantics. In the second example, where the function computes the size of the largest subset of elements of the list that could form a sequence of consecutive integers, TransCoderST manages to translate the semantics of S.find $( \mathsf { a r r } [ \mathrm { i } ] - 1 ) = = \mathsf { S }$ .end() appropriately while TransCoder translates it into its negation.
|
| 313 |
+
|
| 314 |
+

|
| 315 |
+
Figure 13: Java to $\mathbf { C } + +$ translation examples. In the first example, which returns whether a given string corner is present at the beginning and at the end of a string str, TransCoder completely fails to translate the last logical expression correctly while TransCoder-ST manages to translate the logic to get the right substrings and to return the right output. The second example is a line defining a priority queue extracted from the kthLargestSum function in the test set of TransCoder. The PriorityQueue object in Java returns the smallest elements first by default, while priority_queue in $\mathrm { C } { + } { + }$ returns the largest. TransCoder, which was not trained on any semantic signal, manages to instantiate a priority queue object but instantiates a max queue instead of a min queue. TransCoder-ST, which was trained with some supervised signal directly linked to the semantics of the code, manages to instantiate the right type of priority queue.
|
| 316 |
+
|
| 317 |
+

|
| 318 |
+
Figure 14: Translation examples for Java to Python. When translating to Python, TransCoder was often failing to distinguish between float division $( / )$ and integer division $( / \nearrow )$ . It also often confuses other operations, for instance $\star$ and $\star \star$ . Training on self-created labels often solves this issue.
|
| 319 |
+
|
| 320 |
+

|
| 321 |
+
Figure 15: Our parallel unit tests lead to the generation of more general solutions using templates. Solutions using templates can pass the unit tests for several parameter types, while guessing the wrong parameter type can lead to some errors. Solutions using templates succeed more often, are more likely to appear in the parallel data we generate and, as a result, in our model’s generations. It leads to our model generating more templates (three times more often for our online model trained the longest).
|
| 322 |
+
|
| 323 |
+
# C EXTRA RESULTS
|
| 324 |
+
|
| 325 |
+
# C.1 BEAM REORDERING
|
| 326 |
+
|
| 327 |
+
We also evaluate a simpler method where we create unit tests for the Java functions in the test dataset and use them to reorder the elements of the beam at test time. We compute the results of the tests for every proposed $\mathrm { C } { + + }$ or Python translation and prioritize the elements that pass the unit tests.
|
| 328 |
+
|
| 329 |
+
As shown on Table 6, reordering the elements of the beam at test time when translating from Java leads only to small improvements compared to the best baseline (up to $1 . 7 \%$ $\mathrm { C A @ 1 }$ for Java Python) and the scores of this method are far from those obtained when requiring any of the 10 element of the beam to be correct (i.e. $\mathrm { C A @ 1 0 } ) _ { \mathrm { \Omega } }$ . It can be explained by the fact that the tests generated by EvoSuite on these functions can have low mutation scores and be insufficient to thoroughly test the semantics of the functions. Moreover, the tests we create are sometimes incompatible with those of our test set (see Figure 4 for an example).
|
| 330 |
+
|
| 331 |
+
Table 6: Extra results table. We show the $\mathbf { C A } \ @ 1$ metric computed with beam size 10 for our baselines, and our offline and online methods, the beam reordering, and a model trained from scratch with our dataset. Beam reordering leads only to small improvements compared to our offline and online self-training methods. Training on our generated parallel dataset from scratch leads to decent performances, but that are still below those of TransCoder and TransCoder-ST.
|
| 332 |
+
|
| 333 |
+
<table><tr><td></td><td>C++→Ja</td><td>C++ →Py</td><td>Ja→C++</td><td>Ja→Py</td><td>Py→C++</td><td>Py→Ja</td><td>AVG</td></tr><tr><td>TransCoder DOBF</td><td>65.1% =</td><td>47.1% -</td><td>79.8% -</td><td>49.0% 52.7%</td><td>32.6% =</td><td>36.6% 45.7%</td><td>51.7% =</td></tr><tr><td>Beam reordering</td><td>-</td><td>-</td><td>80.3%</td><td>54.4%</td><td>=</td><td>=</td><td>=</td></tr><tr><td>Offline ST scratch</td><td>43.0%</td><td>41.3%</td><td>54.3%</td><td>43.2%</td><td>31.1%</td><td>39.7%</td><td>42.1%</td></tr><tr><td>Offline ST1</td><td>65.5%</td><td>56.2%</td><td>81.6%</td><td>61.8%</td><td>46.8%</td><td>55.1%</td><td>61.1%</td></tr><tr><td>Offline ST 2</td><td>65.5%</td><td>58.3%</td><td>83.7%</td><td>63.3%</td><td>46.4%</td><td>52.2%</td><td>61.6%</td></tr><tr><td>Offline ST 3</td><td>66.5%</td><td>56.2%</td><td>85.2%</td><td>66.3%</td><td>48.1%</td><td>56.6%</td><td>63.1%</td></tr><tr><td>Offline ST 4</td><td>65.3%</td><td>48.2%</td><td>81.1%</td><td>58.1%</td><td>48.9%</td><td>54.7%</td><td>59.4%</td></tr><tr><td>Online ST</td><td>68.0%</td><td>61.3%</td><td>84.6%</td><td>68.9%</td><td>56.7%</td><td>58.2%</td><td>66.3%</td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr></table>
|
md/dev/e0uknAgETh/e0uknAgETh.md
ADDED
|
@@ -0,0 +1,232 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# ADVERSARIAL ATTACKS ON SPIKING CONVOLUTIONAL NETWORKS FOR EVENT-BASED VISION
|
| 2 |
+
|
| 3 |
+
Anonymous authors Paper under double-blind review
|
| 4 |
+
|
| 5 |
+
# ABSTRACT
|
| 6 |
+
|
| 7 |
+
Event-based sensing using dynamic vision sensors is gaining traction in lowpower vision applications. Spiking neural networks work well with the sparse nature of event-based data and suit deployment on low-power neuromorphic hardware. Being a nascent field, the sensitivity of spiking neural networks to potentially malicious adversarial attacks has received very little attention so far. In this work, we show how white-box adversarial attack algorithms can be adapted to the discrete and sparse nature of event-based visual data, and to the continuous-time setting of spiking neural networks. We test our methods on the N-MNIST and IBM Gestures neuromorphic vision datasets and show adversarial perturbations achieve a high success rate, by injecting a relatively small number of appropriately placed events. We also verify, for the first time, the effectiveness of these perturbations directly on neuromorphic hardware. Finally, we discuss the properties of the resulting perturbations and possible future directions.
|
| 8 |
+
|
| 9 |
+
# 1 INTRODUCTION
|
| 10 |
+
|
| 11 |
+
Unlike the usual neural networks of contemporary deep learning, spiking neural networks (SNN) resemble the animal brain more closely in at least two main aspects: the way their neurons communicate through impulses (spikes), and their dynamics, which evolve in continuous time. Aside from offering the field of computational neuroscience more biologically plausible neuron models and communication schemes, research in the technological applications of spiking neural networks is currently blooming because of the rise of neuromorphic technology. Neuromorphic hardware is directly compatible with spiking neural networks and enables the design of low-power models for use in battery-operated, always-on devices.
|
| 12 |
+
|
| 13 |
+
Adversarial examples are an “intriguing property of neural networks” (Szegedy et al., 2013) by which the network is easily fooled into misclassifying an input which has been altered in an almost imperceptible way by the attacker. This property is usually undesirable in applications: it was proven, for example, that an adversarial attack may pose a threat to self-driving cars, by making them misclassify a stop sign as a speed limit sign; and that this attack can be implemented in the real world through stickers physically placed on the road sign (Eykholt et al., 2018). Because of their relevance to real-world applications, a large amount of work has been published on this subject, typically following a pattern where new attacks are discovered, followed by new defense strategies, in turn followed by proof of other strategies that can still break through them (see Akhtar & Mian (2018) for a review).
|
| 14 |
+
|
| 15 |
+
With the advent of real-world applications of spiking networks in neuromorphic devices, it is essential to make sure they work securely and reliably in a variety of contexts. In particular, there is a significant need for research on the possibility of adversarial attacks on spiking network models used for computer sensing tasks. In this paper, we make an attempt at modifying event-based data, by adding and removing events, to generate adversarial examples that fool spiking networks into misclassifying them. This offers important insight into the reliability and security of neuromorphic vision devices, with important implications for commercial applications.
|
| 16 |
+
|
| 17 |
+
# 1.1 WHAT IS EVENT-BASED SENSING?
|
| 18 |
+
|
| 19 |
+
Event-based cameras, usually called Dynamic Vision Sensors (DVS), share many characteristics with the mammalian retina, which make them excel in some circumstances where traditional framebased cameras do not perform well (Liu & Delbruck, 2010; Liu et al., 2019b). First, events are generated only when there are changes in the visual scene, automatically removing redundancies; second, their pixels fire independently of each other which means that there is no frame rate, but rather a continuous stream of asynchronous events, so that the latency can be extremely small; third, they have a very high dynamic range which makes them suitable to detect motion in both bright and dark settings. For these reasons, they have found applications in human-robot interaction, odometry, drone control, tracking, and surveillance, including on devices that are already commercially available (Gallego et al., 2019; Kueng et al., 2016; Falanga et al., 2020). Beyond computer vision, the realm of event-based sensing extends to auditory sensors known as silicon cochleas (Chan et al., 2007), as well as radar (Stuijt et al., 2021) and tactile sensors (Caviglia et al., 2016).
|
| 20 |
+
|
| 21 |
+
Neuromorphic sensors make available a new kind of sparse, asynchronous data, which does not suit current high-throughput, synchronous accelerators such as GPUs. To process event-based data efficiently, a new generation of neuromorphic hardware is being developed in parallel to the spiking neural network models that can be trained in software. Spiking neuromorphic implementations include large-scale simulation of neuronal networks for neuroscience research (Furber et al., 2012) and lowpower real-world deployments of machine learning algorithms. In particular, convolutional neural network (CNN) architectures, used for computer vision, have been run on neuromorphic chips such as IBM’s TrueNorth (Esser et al., 2016), Intel’s Loihi (Davies et al., 2018) and SynSense’s Speck and Dynap-CNN hardware (Liu et al., 2019a). The full pipeline of event-based sensors that output sparse data, stateful spiking neural networks which extract semantic meaning and asynchronous hardware backends allows for large gains in power-efficiency when compared to conventional systems.
|
| 22 |
+
|
| 23 |
+
# 1.2 ADVERSARIAL ATTACKS ON DISCRETE DATA
|
| 24 |
+
|
| 25 |
+
The history of attack strategies against various kinds of machine-learning algorithms pre-dates the advent of deep learning (Biggio & Roli, 2018), but the phenomenon received widespread interest when adversarial examples were first found for deep convolutional networks (Szegedy et al., 2013). Generally speaking, given a neural network classifier $C$ and an input $x$ which is correctly classified, finding an adversarial perturbation means finding the smallest $\delta$ such that $C ( x + \delta ) \neq C ( x )$ . Here, “smallest” refers to minimising $\| \delta \|$ , where the norm is chosen arbitrarily depending on the requirements of the experiment. For example, using the $L ^ { \infty }$ norm (maximum norm) will generally make the perturbation less noticeable to a human eye, since the difference in any pixel value between the original and perturbed images will be below a maximum value that is kept as low as possible. Conversely, the use of the $L ^ { 1 }$ norm will encourage sparsity, i.e. a smaller number of perturbed pixels. The main challenges in transferring existing adversarial algorithms to event-based neuromorphic vision lie in the dynamics of the data and network, which develop in continuous time, and in the discrete nature of events, which can either be present or absent at a given time and location, unlike the continuous pixel values of traditional image data.
|
| 26 |
+
|
| 27 |
+
Event-based sensors encode information in the timing, location, and polarity of events, which can be of ‘on’ or ‘off’ type. Because at any point in time an event can either be triggered or not, one can simply view event-based inputs as binary data by discretising time (Figure 1). In this view, the network’s input is a three-dimensional array whose entries describe the number of events at a location $( x , y )$ and in time bin $t$ ; an additional dimension, of length 2, is added due to the polarity of events. If the time discretisation is sufficiently precise, and no more than one event appears in each bin, the data can be treated as binary. A possible approach to attacking these data is exploiting recent work done on attacking binary images, i.e. with either black or white pixels, which are used in the automatic processing of cheques and other documents. Most methods proposed for attacking binary inputs have focused on brute-force approaches that rely on heuristics to reduce the search space (Bagheri et al., 2018; Balkanski et al., 2020). For example, SCAR (Balkanski et al., 2020) is a black-box algorithm that only assumes access to the output probabilities of the network. The algorithm flips bits in areas chosen according to a specific heuristic and keeps flipped those that cause a change in the confidence of the network. Naturally, this algorithm does not scale well to large input sizes, as the number of queries made to the network grows exponentially. In particular, this becomes a serious problem when the time dimension is added, greatly increasing the dimensionality of the input. Instead, in this paper, we chose to focus on the easier problem of white box attacks, where the attacker has full access to the network and can backpropagate gradients through it. This allows us to adapt faster and more effective algorithms to the case of event-based data.
|
| 28 |
+
|
| 29 |
+
To this end, we chose to adapt existing attack strategies so that they could work with the time dynamics of spiking neural networks, and with the discrete nature of event-based data. We test our attacks on the Neuromorphic MNIST (Orchard et al., 2015) and IBM Gestures (Amir et al., 2017) datasets, which are the most common benchmark datasets within the neuromorphic community. Previous work on adversarial attacks in spiking networks has been reported by Sharmin et al. (2020); however, their work only uses static image data with continuous pixel values converted to Poisson input frequencies, so does not involve dealing with discrete data which was the main challenge in our work. More recently, Liang et al. (2020) did apply attacks to DVS data, using a discretisedgradient technique. They report high success rates, despite some notable problems of vanishing gradients. Concurrently with our work, Marchisio et al. (2021) designed custom algorithms for DVS data, rather than adapting existing ones, but did not report on the magnitudes of the resulting perturbations. None of these validated the effectiveness of their attack strategies against an on-chip model deployed on neuromorphic hardware. Our contributions beyond the existing literature can be summarised as follows:
|
| 30 |
+
|
| 31 |
+
• We provide detailed results to quantify the effectiveness and scalability of several adversarial attacks strategies, including some not tried before on SNNs.
|
| 32 |
+
• We show targeted universal attacks on event-based data in the form of adversarial patches, which do not require prior knowledge of the input.
|
| 33 |
+
• We validate the resulting adversarial examples on an SNN deployed on a convolutional neuromorphic chip. To the best of our knowledge, this is the first time the effectiveness of adversarial examples is demonstrated directly on neuromorphic hardware.
|
| 34 |
+
|
| 35 |
+
# 2 METHODS
|
| 36 |
+
|
| 37 |
+
# 2.1 ATTACK STRATEGIES
|
| 38 |
+
|
| 39 |
+
Projected Gradient Descent As a baseline, we use Projected Gradient Descent (PGD) (Madry et al., 2019), a standard attack algorithm which we use on discrete data in two ways. The first consists in naively rounding the data at each iteration. However, in this case, updates will be retained only if the gradient magnitude is large enough: otherwise, the small changes made to the adversarial input are lost due to the subsequent discretization. Instead, we adopt an approach that prevents this loss of information: we keep a continuous version of the image as a copy, but use the gradients computed on the discretized image to update the continuous version which is kept in memory. To adapt PGD to the scenario where we want to find the smallest perturbation that triggers a misclassification, we sort the values based on how much PGD adjusted them. We then iterate through the sorted list of indices and flip each value until a misclassification is triggered. It should be noted that this step incurs most of the computational overhead, but is necessary to produce good results. Unless stated otherwise, we used the following values for the parameters: the magnitude of the initial random perturbation to the input is set to $\tau = 0 . 0 1$ . The maximum norm of the perturbation was set to $\epsilon = 1 . 5$ . We found that 50 iterations $( N _ { \mathrm { p g d } } )$ of PGD sufficed and the results did not improve by much afterwards.
|
| 40 |
+
|
| 41 |
+
Probabilistic PGD We also devised an alternative way of using PGD on discrete data, which we call “Probabilistic PGD”. Probabilistic PGD works by assuming that the binary input was generated by sampling from a series of independent Bernoulli random variables. This approach aligns with how the DVS camera generates the binary data: the probability of emitting a spike at time $t$ is proportional to the light intensity, a continuous metric. For each round of PGD, the input is sampled in a differentiable manner by the Gumbel-softmax reparameterization trick (Jang et al., 2017):
|
| 42 |
+
|
| 43 |
+
$$
|
| 44 |
+
{ \bf x } _ { \mathrm { a d v } } = \sigma \left( \left[ \log ( { \bf r } ) - \log ( { \bf 1 } - { \bf r } ) + \log ( { \bf p } _ { \mathrm { a d v } } ) - \log ( { \bf 1 } - { \bf p } _ { \mathrm { a d v } } ) \right] / T \right) ,
|
| 45 |
+
$$
|
| 46 |
+
|
| 47 |
+
where $\mathbf { r } \sim \mathcal { U } ( \mathbf { 0 } , \mathbf { 1 } )$ , and $T = 0 . 0 1$ is a temperature parameter. The underlying probabilities $\mathbf { p } _ { \mathrm { a d v } }$ , instead of the pixel values $\mathbf { x } _ { \mathrm { a d v } }$ , are updated using the gradient obtained from the loss function that is minimised by PGD. We saw that this generally improved the performance compared to the PGD version explained above. Gradients are averaged over $N _ { \mathrm { m c } } = 1 0$ samples of $\mathbf { r }$ . It should be noted that the need for a gradient sampling procedure significantly increases the runtime.
|
| 48 |
+
|
| 49 |
+
SparseFool on discrete data To operate on event-based data efficiently, the ideal adversarial algorithm requires two main properties: sparsity and scalability. Scalability is needed because of the increased dimensionality given by the additional time dimension. Sparsity ensures that the number of events added or removed is kept to a minimum. One approach that combines the above is SparseFool (Modas et al., 2018), which iteratively finds the closest point in $L ^ { 2 }$ on the linearised decision boundary of the network using the DeepFool algorithm (Moosavi-Dezfooli et al., 2015) as a subroutine, followed by a linear solver that enforces sparsity and boundary constraints on the perturbation. Because Spiking Neural Networks (SNNs) have discrete outputs (the number of spikes over time for each output neuron), it is easier to incur in vanishing gradients as the perturbation approaches the decision boundary. Therefore, we had to make changes to the algorithm to take this into account. Firstly, we found that clamping the perturbation at every iteration of DeepFool, so that it was no smaller than a value $\eta$ , offered protection against vanishing gradients. $\eta$ was treated as a hyperpa
|
| 50 |
+
|
| 51 |
+

|
| 52 |
+
Figure 1: Schematic of the attack procedure on DVS data.
|
| 53 |
+
|
| 54 |
+
rameter that should be kept as small as it can without incurring in vanishing gradients. Secondly, to account for the discreteness of event-based data, we rounded the output of SparseFool to the nearest integer at each iteration. Finally, SparseFool normally involves upper and lower bounds $l$ and $u$ on pixel values (normally set, for images, to $l = 0 ; u = 2 5 5 )$ . We exploit these to enforce the binary constraint on the data $( l = 0 ; u = 1 )$ , or, in the on-chip experiments, to fix a maximum firing rate in each time bin, which is the same as that of the original input $( l = 0 ; u = \operatorname* { m a x } ( \operatorname* { i n p u t } ) )$ .
|
| 55 |
+
|
| 56 |
+
Adversarial patches As the name suggests, adversarial patches are perturbations that are accumulated in a certain region of the image. The idea is that these patches are generated in a way that enables the adversary to place them anywhere in the image. This attack is targeted to a desired label, and universal, i.e. not specific to an input. To test a more realistic scenario where an adversary could potentially perform an attack without previous knowledge of the input, we apply these patches to the IBM hand gesture dataset. We note that the prediction of the CNN trained on this dataset is mostly determined by spatial location of the input. For example, the original input of “Right Hand Wave” is not recognised as such if it is shifted or rotated by a substantial amount. In order to simulate effective realistic attacks, we choose to limit both computed and random attack patches to the area of where the actual gesture is performed. As in Brown et al. (2017), we generate the patches using PGD on the log softmax value of the target output neuron. PGD is performed iteratively on different images of the training set and the position of the patch is randomised after each sample. For each item in the training data, the algorithm updates the patch until the target label confidence has reached a pre-defined threshold. The algorithm skips the point if the original label equals the target label. This process is repeated for every training sample and for multiple epochs. To measure the effectiveness of our computed patches, we also generate random patches of the same size, and measure the target success rates. In a random patch, every pixel has a $50 \%$ chance of emitting a spike at each time step.
|
| 57 |
+
|
| 58 |
+
# 2.2 DATASETS AND DATA PREPARATION
|
| 59 |
+
|
| 60 |
+
Binarised MNIST We tried our methods on three datasets. The first is a binarised version of MNIST (BMNIST for short), which is derived from the popular MNIST Handwritten Digits database (LeCun & Cortes, 2010), binarised so that pixel values 0 to 127 are mapped to white, and 128 to 255 are mapped to black. No other preprocessing is applied. This is not a dataset of DVS recordings: we use it in order to compare our white box attacks against the SCAR attacks for binary datasets mentioned above (Balkanski et al., 2020).
|
| 61 |
+
|
| 62 |
+
Neuromorphic MNIST Our first DVS benchmark is NMNIST (Neuromorphic MNIST), which consists of $3 0 0 ~ \mathrm { { m s } }$ -long recordings of MNIST digits that are captured using the saccadic motion of a DVS sensor (Orchard et al., 2015). This is the most commonly used DVS benchmark dataset for simpler tasks: since digits are only translating through the frame without changing, temporal features are not necessary for classification. When testing the spiking network, and for creating adversarial examples, each sample is fed to the network as a sequence of 5 ms-long binary frames. Additional spikes that fall in the same pixel within the same $5 ~ \mathrm { m s }$ window are discarded, so that each bin can contain either 0 or 1 events per pixel. The resulting data is a binary array (referred to as “raster”) of dimensions $( t , p , x , y ) = ( 6 0 , 2 , 3 4 , 3 4 )$ , where $t = 3 0 0 \mathrm { m s } / 5 \mathrm { m s } = 6 0$ is the number of time bins, $p = 2$ are the polarity channels, and $x = y = 3 4$ is the spatial resolution of the recording.
|
| 63 |
+
|
| 64 |
+
IBM Gestures For a more advanced event-based vision benchmark, we used the IBM Gestures dataset, which consists of recordings of 11 classes of human gestures, captured under three different lighting conditions (Amir et al., 2017). Here, unlike the previous cases, the model must have some ability to process features in time, e.g. to distinguish between clockwise and counterclockwise hand motion in the same spatial position. The length of each gesture recording varies between 4 and 7 seconds. In this work, we never test on the full length of the recording at once, but we use $2 0 0 ~ \mathrm { { m s } }$ slices as the fundamental unit of the dataset. The data fed to the spiking network at test time are the same $2 0 0 ~ \mathrm { { m s } }$ samples, with time discretised in $1 0 ~ \mathrm { m s }$ bins. As above, spikes are capped to 1 per pixel per time bin. The dimensions of the resulting raster are $( t , p , x , y ) = ( 2 0 , 2 , 1 2 8 , 1 2 8 )$ . The experiments designed to run on the chip were binned at a higher time resolution of $2 \mathrm { m s }$ since the neuromorphic hardware is capable to process events in continuous time.
|
| 65 |
+
|
| 66 |
+
# 2.3 NETWORKS
|
| 67 |
+
|
| 68 |
+
For the BMNIST experiments, we use a non-spiking network, similar to the one used in Balkanski et al. (2020): two $3 \times 3$ convolutional layers (32 and 64 channels each), with ReLU activations, followed by $2 \times 2$ max-pooling, dropout, and a fully connected layer of 128 features, projecting onto the final layer of 10 output units. The network is trained for 50 epochs at batch size 64, using the Adam (Kingma & Ba, 2014) optimiser with learning rate $1 0 ^ { - 3 }$ on a cross-entropy loss function. The network reached a test accuracy of $9 9 . 1 2 \%$ .
|
| 69 |
+
|
| 70 |
+
The spiking networks used for the NMNIST and IBM Gestures tasks are simulated using a PyTorchbased SNN library which simulates non-leaky, linear integrate-and-fire neurons with no synaptic dynamics, equivalent to the ones emulated by the neuromorphic chip. In this neuron model, the inputs to each neuron are multiplied by the input weight and simply added to the neuron’s membrane potential. The neuron spikes as soon as its membrane potential reaches a threshold, which is always set to 1. The threshold value is then subtracted from the membrane potential. The network’s output label is the one corresponding to the output neuron that spikes the most, over the timespan during which the input is presented. There are no bias terms in our SNN’s convolutional and linear layers.
|
| 71 |
+
|
| 72 |
+
The models used for NMNIST were trained using the “weight transfer” method, whereby an equivalent CNN is trained on accumulated frames (i.e. summing the data over the time dimension), and the CNN weights are transferred to the spiking network with thresholds set to 1 (Rueckauer et al., 2017; Sorbaro et al., 2020). The ANN was trained with Adam at batch size 64 with learning rate $1 0 ^ { - 3 }$ for 10 epochs. We then rescaled the weights by layer-wise global factors so that the 99th percentile of activity was the same at each layer, as described by Rueckauer et al. (2017). The model we used consists of three convolutional layers of 20, 32, and 128 channels (kernel size 5 for the first, 3 for the other two), each followed by ReLU activation and $2 \times 2$ average-pooling. The convolutional stack is followed by a fully connected layer with feature size 500, which projects onto the 10 output units. The network achieves $8 4 . 9 3 \%$ classification test accuracy.
|
| 73 |
+
|
| 74 |
+
For the IBM Gestures task, training is done using backpropagation-through-time (BPTT), required even for feed-forward networks, because of the neurons’ internal states, which persist in time. We make use of a surrogate gradient in the backwards pass to enable learning despite the discontinuous nature of spikes (Neftci et al., 2019): for gradient purposes, the neuron’s nonlinearity is treated as a ReLU with zero-point placed at a value threshold – window. The window value is set to 0.5. For the simulated experiments, we used a network with a convolutional layer of kernel size 2, stride 2, and 8 channels, followed by two convolutional layers of kernel size 3 and 8 channels, and a fully connected layer of 64 channels that projects to the 11 output units. After every convolutional layer, batch-norm, spiking activation, and $2 \times 2$ average pooling are inserted. This network achieves a classification test accuracy of $8 4 . 2 \%$ . The network used for the on-chip experiments has a slightly different architecture and does not have batch-normalisation layers to make it compliant with the hardware.
|
| 75 |
+
|
| 76 |
+

|
| 77 |
+
Figure 2: Examples of adversarial inputs on the BMNIST (top), NMNIST (middle) and IBM Gestures (bottom) datasets, as obtained by the SparseFool method. The captions show the original (true) label, correctly identified, and the class later identified by the model. The data was re-framed in time for convenience of visualisation. Red indicates added spikes. In the BMNIST examples, blue indicates removed pixels. We note that in the lower-dimensional BMNIST case, the effect of the attack is semantically interpretable: for example, adding a stroke that closes the upper left part of a “7” makes it look like a $" 9 "$ not only for the network but also for a human observer. See the supplementary video for more examples and motion visualisation.
|
| 78 |
+
|
| 79 |
+
# 2.4 EXPERIMENTS ON THE NEUROMORPHIC CHIP
|
| 80 |
+
|
| 81 |
+
In order to verify our attack strategies in a more realistic scenario, we ran our experiments on neuromorphic hardware1, which is especially suited for SNN inference due to its asynchronous nature. We use a digital, convolutional neuromorphic chip designed for computer vision applications. Weight precision, number of computations per second and throughput are typically reduced as the hardware is optimised for very low power consumption. This can lead to a degradation in prediction accuracy when compared to simulations. Because the networks detailed in the previous sections have to be modified in order to make them suitable for neuromorphic on-chip inference, their weights are rescaled and discretised as required by the chip’s 8-bit weight precision.
|
| 82 |
+
|
| 83 |
+
<table><tr><td></td><td>Attack</td><td>Success Rate (%)</td><td>Median Elapsed Time (s/sample)</td><td>Median No. Queries</td><td>Median L</td></tr><tr><td rowspan="4">BSIIIY</td><td>SCAR</td><td>100.00</td><td>1.14</td><td>1175</td><td>7</td></tr><tr><td>PGD</td><td>98.89</td><td>0.16</td><td>102</td><td>50</td></tr><tr><td>Probabilistic PGD</td><td>99.70</td><td>0.54</td><td>275</td><td>23</td></tr><tr><td>SparseFool (n = 0.2,λ= 2)</td><td>99.90</td><td>0.08</td><td>11</td><td>14</td></tr><tr><td rowspan="4">LSINNN</td><td>PGD</td><td>48.63</td><td>72.56</td><td>1052</td><td>_t</td></tr><tr><td>Probabilistic PGD</td><td>54.46</td><td>68.35</td><td>774</td><td>522</td></tr><tr><td>SparseFool (n = 0.2,λ = 2)</td><td>99.76</td><td>30.22</td><td>45</td><td>254</td></tr><tr><td>SparseFool (n = 0.5,入= 2)</td><td>99.88</td><td>13.08</td><td>26</td><td>268</td></tr><tr><td rowspan="3"></td><td>SparseFool(n = 0.1,λ= 3)</td><td>100.00</td><td>2.78</td><td>11</td><td>310</td></tr><tr><td>SparseFool (n =0.1,λ= 2)</td><td>99.87</td><td>2.57 3.02</td><td>11</td><td>200</td></tr><tr><td>SparseFool (n =0.1,λ=1)</td><td>97.69</td><td></td><td>17</td><td>116</td></tr></table>
|
| 84 |
+
|
| 85 |
+
† Samples for which the attack was unsuccessful were considered to have $L ^ { 0 } =$ undefined. Because PGD fails more than half of the time, the median is undefined.
|
| 86 |
+
|
| 87 |
+
Table 1: Comparison of attack strategies (1000 samples). SCAR was implemented according to the pseudo code in Balkanski et al. (2020) and PGD was run for 50 iterations. SparseFool takes only a fraction of the time compared to PGD while obtaining much sparser results at almost perfect success rate on Neuromorphic MNIST. The input size for this dataset is set to (60,2,34,34). We also use SparseFool to attack samples from the IBM Gestures dataset at different values of $\lambda$ , a parameter trading-off speed and sparsity. The success rate is here defined as the fraction of samples that were initially correctly classified, for which the attack algorithm converged to an adversarial example that the network classifies incorrectly.
|
| 88 |
+
|
| 89 |
+
As this work focuses on white-box attacks, we first computed the adversarial examples using the network simulation on the computer, then tested both original and attacked spiketrains in simulation and on the chip. The simulation and the attack work in discrete time, while the chip receives events in continuous time. In order to convert the discrete-time attacked raster back to a list of events for the chip, we compared the original and attacked rasters, identifying new events added by the attack and adding them to the original list (Figure 1). We empirically found very few events removed by SparseFool (see supplementary section 1) and chose to ignore removals for on-chip experiments.
|
| 90 |
+
|
| 91 |
+
# 3 RESULTS
|
| 92 |
+
|
| 93 |
+
# 3.1 SPARSEFOOL ATTACKS ON BINARY AND DVS DATA
|
| 94 |
+
|
| 95 |
+
Table 1 compares the different algorithms on Binary-MNIST and shows that SparseFool finds successful adversarial examples with a low median $L ^ { 0 }$ (i.e. number of perturbed pixels), while requiring a very low median execution time. Figure 2 (top) illustrates samples of perturbations found by SparseFool and the corresponding label that was predicted by the network after applying the perturbation. Because of the small sample size and the fact that there is no time dimension, BinaryMNIST enables us to compare SparseFool to other, more inefficient methods. However, more realistic datasets are needed to truly evaluate the feasibility of applying these algorithms.
|
| 96 |
+
|
| 97 |
+
After having established that SparseFool can efficiently and reliably generate sparse perturbations on discrete data, we evaluated SparseFool’s performance on the DVS benchmarks for different hyperparameters (Table 1). $\eta$ indicates the minimum step size for updates to the perturbation: higher values of $\eta$ find less precise perturbations (larger $L ^ { 0 }$ values), but are sometimes needed in order to prevent zero-gradient issues within the algorithm. $\lambda$ is the sparsity parameter: lower $\lambda$ (with a minimum of 1) yields sparser results, but gives a slightly lower success rate. Overall we consistently found that SparseFool performs better than PGD and Probabilistic PGD, both in terms of success rate and in the number of added or suppressed events. Additionally, it requires far fewer iterations and therefore converges more quickly. Figure 2 and the supplementary video show examples of successful attacks. Supplementary section 1 provides further information on the characteristics of the resulting samples.
|
| 98 |
+
|
| 99 |
+

|
| 100 |
+
Figure 3: Examples of adversarial patches successfully applied to a single “right hand clockwise” data sample, with different target classes. See also the supplementary video for motion visualisation and more examples of successful patch attacks.
|
| 101 |
+
|
| 102 |
+
# 3.2 VALIDATION ON NEUROMORPHIC HARDWARE
|
| 103 |
+
|
| 104 |
+
We randomly chose 1000 snippets, each $2 0 0 ~ \mathrm { { m s } }$ long, from the IBM Gestures dataset, on which we ran the SparseFool attack. Out of these, 833 were successfully classified by the network and were therefore eligible for an attack; the attacks converged and were successful in simulation in 777 cases. We presented these 777 successful attacks to the chip, alongside the un-attacked original data, finding that $9 6 . 9 \%$ (753) of the originals are successfully classified by the chip, and $8 5 . 3 \%$ of the attacks are able to fool the chip (663) too. A possible reason for this discrepancy lies in how the chip is limited in computing capacity by weight quantization and restricted throughput per time unit, which causes some of the input events to be dropped. The conversion of binned data back into lists of spikes, discussed in the Methods section, is necessarily lossy at this time. In terms of attack efficiency, we observe a median $L ^ { 1 }$ distance (i.e., difference in number of spikes) of 903 among the attacks that were successful on chip, corresponding to a median $9 . 3 \%$ increase in the number of spikes per sample. The full distribution is shown in Figure S1 (bottom left). Figure S1 also shows the time profile of the perturbation and how the network classified the data after the attack.
|
| 105 |
+
|
| 106 |
+
# 3.3 ADVERSARIAL PATCHES
|
| 107 |
+
|
| 108 |
+
Although we have demonstrated that one can achieve high success rates on custom spiking hardware that operates with microsecond precision, the applicability of this method is still limited, as the adversary needs to suppress and add events at high spatial and temporal resolution, thus making the assumption that the adversary can modify the event-stream coming from the DVS camera. Furthermore, SparseFool assumes knowledge of the model and requires computing the perturbation offline, which is not feasible in a timely manner. In a more realistic setting, the adversary is assumed to generate perturbations by changing the input the DVS camera receives on the fly.
|
| 109 |
+
|
| 110 |
+
Using the training data from the IBM Gestures dataset, we generated an adversarial patch for each target class with high temporal precision (event samples of $2 0 0 ~ \mathrm { { m s } }$ were binned using 0.5 ms-wide bins) and evaluated the effectiveness in triggering a targeted misclassification both in simulation and on-chip using the test data. To simulate spatial imprecision during deployment, each test sample was perturbed by a patch that was randomly placed within the area of the original gesture. Table 2 summarises our findings on target success rates for generated and random patches. Simulated results show high success rates, and on-chip performance shows a slight degradation, which can be expected due to weight quantization on the tested specialised hardware. We also found that the chip had trouble processing inputs because most of the added patch events occurred concentrated in the beginning of recordings in a large transient peak. In one case, the targeted attack for label “Arm Roll“ mostly fails on chip as not all events are processed, which makes it harder to discriminate between similar labels such as “Hand Clap“, a similar gesture that occurs in the same central spatial location. This could somewhat be mitigated by limiting the number of events in a patch to ensure that they could all be correctly processed on the chip.
|
| 111 |
+
|
| 112 |
+
Table 2: Adversarial patches for different target labels were evaluated on– and off–chip. Shown here are the success rates in percent for each target label. An attack is considered successful if the original label is not the target label and the network predicts the target label when the patch is applied.
|
| 113 |
+
|
| 114 |
+
<table><tr><td>Target label</td><td>Hand clap</td><td>RH Wave</td><td>LH Wave</td><td>RH Clockwise</td><td>RH Counter Clockwise</td><td>LH Clockwise</td><td>LH Counter Clockwise</td><td>Arm Roll</td><td>Air Drum</td><td>Air Guitar</td><td>Other</td></tr><tr><td>Adversarial patch</td><td>90.3</td><td>99.0</td><td>89.8</td><td>87.3</td><td>79.7</td><td>49.7</td><td>51.5</td><td>63.6</td><td>79.1</td><td>92.3</td><td>64.7</td></tr><tr><td>Adv. patch (on-chip)</td><td>94.0</td><td>89.0</td><td>94.1</td><td>81.3</td><td>65.1</td><td>35.9</td><td>43.8</td><td>5.0</td><td>82.7</td><td>87.3</td><td>66.8</td></tr><tr><td>Random patch</td><td>18.8</td><td>80.7</td><td>77.0</td><td>0</td><td>0</td><td>3.6</td><td>0.6</td><td>0</td><td>0</td><td>12.6</td><td>16.6</td></tr><tr><td>Rand. patch (on-chip)</td><td>43</td><td>76.8</td><td>72.2</td><td>0</td><td>0</td><td>9.0</td><td>2.4</td><td>0</td><td>0</td><td>0</td><td>17.7</td></tr></table>
|
| 115 |
+
|
| 116 |
+
We compare this result with a baseline of randomly generated patches, and we observe that two labels, namely “Left“ and “Right Hand Wave“ subsume all other attacked labels in this case. This hints that randomly injecting events in various locations is not enough to perturb network prediction to a desired label and that our algorithm succeeds in finding a meaningful patch. To summarise, adversarial patches are effective in triggering a targeted misclassification both on– and off–chip compared to randomly generated ones. Figure 3 and the supplementary video show examples of successful patch attacks. Importantly, these attacks are universal, meaning that they can be applied to any input and do not need to be generated for each sample.
|
| 117 |
+
|
| 118 |
+
# 4 DISCUSSION
|
| 119 |
+
|
| 120 |
+
We studied the possibility of fooling spiking neural networks through adversarial perturbations to dynamic vision sensor data, and verified these perturbations on a convolutional neuromorphic chip. There were two main challenges to this endeavour: the discrete nature of event-based data, and their dependence on time. This translated, in practice, in the need for an extra temporal dimension, and in different sparsity requirements, because the magnitude of the perturbation is measured in terms of number of events added or removed. For this purpose, we adapted the sparse adversarial algorithm SparseFool, and showed that it achieves high convergence rates on time-discretised samples of the Neuromorphic MNIST and IBM Gestures datasets. Empirically, we observe that the algorithm mostly resorts to adding, rather than removing, input events, and the number of new events necessary to fool the network varies significantly from sample to sample. In the best cases, the attack requires the addition of less than a hundred events over a $2 0 0 ~ \mathrm { { m s } }$ sample, an increase of a few percent. With this, we have proven adversarial examples in DVS data are possible, and, to the best of our knowledge, we were also the first to show that the perturbation is effective in a network deployed on a neuromorphic chip. As the history of adversarial attack algorithms shows, future research in this field may well find adversarial perturbations that are even less noticeable, detectable, or computationally intensive. One should be aware of this possibility when deploying any neuromorphic devices using DVS technology together with neural network models in all contexts where malicious attacks may have serious consequences, such as autonomous driving, surveillance, or control. For this reason, it is also important to consider how to counter these attacks. Defence mechanisms such as adversarial-aware training exist and can provide better robustness. In preliminary work outlined in supplementary section 2 we apply one such method to SparseFool attacks.
|
| 121 |
+
|
| 122 |
+
SparseFool computes perturbations offline, and it is currently not obvious how to do this on the fly on a live stream of DVS events. Therefore, we also investigated a more realistic setting, where an adversary can, with low spatial, but high temporal precision, inject spurious events in the form of a patch inserted into the visual field of the DVS camera. We showed that we can generate patches for different target labels, which trigger targeted misclassifications with high precision. Although these patches require a much higher amount of added events, they do not require prior knowledge of the input sample and therefore offer a realistic way of fooling deployed convolutional neuromorphic systems. A natural next step would be to understand whether it is possible to build real-world patches that can fool networks when shown to the DVS camera from a variety of distances and orientations, as Eykholt et al. (2018) did for photographs. Additionally, it will be interesting to see how important knowledge about the architecture is and if one can generate adversarial patches by having access to a network that differs from the deployed ones.
|
| 123 |
+
|
| 124 |
+
# 5 ETHICS STATEMENT
|
| 125 |
+
|
| 126 |
+
The authors aim to minimise the impact of potential attacks on deployed SNNs by contributing to overall understanding and supporting public discussion thereof.
|
| 127 |
+
|
| 128 |
+
A subset of the authors are currently employed by the neuromorphic chip manufacturer, which could be perceived as a conflict of interest. We did our best to counteract this by making available all source code used in the experiments and we encourage other researchers to reproduce our results. The other authors report no current conflicts of interest.
|
| 129 |
+
|
| 130 |
+
# 6 REPRODUCIBILITY STATEMENT
|
| 131 |
+
|
| 132 |
+
The authors made available all code that was used to generate results and plots in this paper, which we attach as supplementary material. The code will be made publicly available after the review process. The libraries used for SNN simulation and DVS data management are available as opensource code. The DVS datasets are available online. The neuromorphic chip is available for research purposes. When reproducing experiments on chip, results are expected to differ slightly due to variations in the manufacturing process.
|
| 133 |
+
|
| 134 |
+
# REFERENCES
|
| 135 |
+
|
| 136 |
+
Naveed Akhtar and Ajmal Mian. Threat of adversarial attacks on deep learning in computer vision: A survey. IEEE Access, 6:14410–14430, 2018. doi:10.1109/ACCESS.2018.2807385.
|
| 137 |
+
|
| 138 |
+
Arnon Amir, Brian Taba, David Berg, Timothy Melano, Jeffrey McKinstry, Carmelo Di Nolfo, Tapan Nayak, Alexander Andreopoulos, Guillaume Garreau, Marcela Mendoza, Jeff Kusnitz, Michael Debole, Steve Esser, Tobi Delbruck, Myron Flickner, and Dharmendra Modha. A low power, fully event-based gesture recognition system. In 2017 IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pp. 7388–7397, 2017. doi:10.1109/CVPR.2017.781.
|
| 139 |
+
|
| 140 |
+
Alireza Bagheri, Osvaldo Simeone, and Bipin Rajendran. Adversarial training for probabilistic spiking neural networks, 2018.
|
| 141 |
+
|
| 142 |
+
Eric Balkanski, Harrison Chase, Kojin Oshiba, Alexander Rilee, Yaron Singer, and Richard Wang. Adversarial attacks on binary image recognition systems. CoRR, abs/2010.11782, 2020. URL https://arxiv.org/abs/2010.11782.
|
| 143 |
+
|
| 144 |
+
Battista Biggio and Fabio Roli. Wild patterns: Ten years after the rise of adversarial machine learning. Pattern Recognition, 84:317–331, 2018.
|
| 145 |
+
|
| 146 |
+
Tom B. Brown, Dandelion Mane, Aurko Roy, Mart ´ ´ın Abadi, and Justin Gilmer. Adversarial patch. CoRR, abs/1712.09665, 2017. URL http://arxiv.org/abs/1712.09665.
|
| 147 |
+
|
| 148 |
+
Stefano Caviglia, Luigi Pinna, Maurizio Valle, and Chiara Bartolozzi. An event-driven posfet taxel for sustained and transient sensing. In 2016 IEEE International Symposium on Circuits and Systems (ISCAS), pp. 349–352. IEEE, 2016.
|
| 149 |
+
|
| 150 |
+
Vincent Chan, Shih-Chii Liu, and Andre van Schaik. Aer ear: A matched silicon cochlea pair with ´ address event representation interface. IEEE Transactions on Circuits and Systems I: Regular Papers, 54(1):48–59, 2007.
|
| 151 |
+
|
| 152 |
+
Mike Davies, Narayan Srinivasa, Tsung-Han Lin, Gautham Chinya, Yongqiang Cao, Sri Harsha Choday, Georgios Dimou, Prasad Joshi, Nabil Imam, Shweta Jain, Yuyun Liao, Chit-Kwan Lin, Andrew Lines, Ruokun Liu, Deepak Mathaikutty, Steven McCoy, Arnab Paul, Jonathan Tse, Guruguhanathan Venkataramanan, Yi-Hsin Weng, Andreas Wild, Yoonseok Yang, and Hong Wang. Loihi: A neuromorphic manycore processor with on-chip learning. IEEE Micro, 38(1):82–99, 2018. doi:10.1109/MM.2018.112130359.
|
| 153 |
+
|
| 154 |
+
Steven K Esser, Paul A Merolla, John V Arthur, Andrew S Cassidy, Rathinakumar Appuswamy, Alexander Andreopoulos, David J Berg, Jeffrey L McKinstry, Timothy Melano, Davis R Barch, et al. Convolutional networks for fast, energy-efficient neuromorphic computing. Proceedings of the national academy of sciences, 113(41):11441–11446, 2016.
|
| 155 |
+
|
| 156 |
+
Kevin Eykholt, Ivan Evtimov, Earlence Fernandes, Bo Li, Amir Rahmati, Chaowei Xiao, Atul Prakash, Tadayoshi Kohno, and Dawn Song. Robust physical-world attacks on deep learning visual classification. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 1625–1634, 2018.
|
| 157 |
+
|
| 158 |
+
Davide Falanga, Kevin Kleber, and Davide Scaramuzza. Dynamic obstacle avoidance for quadrotors with event cameras. Science Robotics, 5(40), 2020.
|
| 159 |
+
|
| 160 |
+
Steve B Furber, David R Lester, Luis A Plana, Jim D Garside, Eustace Painkras, Steve Temple, and Andrew D Brown. Overview of the spinnaker system architecture. IEEE Transactions on Computers, 62(12):2454–2467, 2012.
|
| 161 |
+
|
| 162 |
+
Guillermo Gallego, Tobi Delbruck, Garrick Orchard, Chiara Bartolozzi, Brian Taba, Andrea Censi, Stefan Leutenegger, Andrew Davison, Jorg Conradt, Kostas Daniilidis, et al. Event-based vision: ¨ A survey. arXiv preprint arXiv:1904.08405, 2019.
|
| 163 |
+
|
| 164 |
+
Eric Jang, Shixiang Gu, and Ben Poole. Categorical reparameterization with gumbel-softmax, 2017.
|
| 165 |
+
|
| 166 |
+
Diederik Kingma and Jimmy Ba. Adam: A method for stochastic optimization. International Conference on Learning Representations, 12 2014.
|
| 167 |
+
|
| 168 |
+
Beat Kueng, Elias Mueggler, Guillermo Gallego, and Davide Scaramuzza. Low-latency visual odometry using event-based feature tracks. In 2016 IEEE/RSJ International Conference on Intelligent Robots and Systems (IROS), pp. 16–23. IEEE, 2016.
|
| 169 |
+
|
| 170 |
+
Yann LeCun and Corinna Cortes. MNIST handwritten digit database. 2010. URL http://yann. lecun.com/exdb/mnist/.
|
| 171 |
+
|
| 172 |
+
Ling Liang, Xing Hu, Lei Deng, Yujie Wu, Guoqi Li, Yufei Ding, Peng Li, and Yuan Xie. Exploring adversarial attack in spiking neural networks with spike-compatible gradient. CoRR, abs/2001.01587, 2020. URL http://arxiv.org/abs/2001.01587.
|
| 173 |
+
|
| 174 |
+
Qian Liu, Ole Richter, Carsten Nielsen, Sadique Sheik, Giacomo Indiveri, and Ning Qiao. Live demonstration: face recognition on an ultra-low power event-driven convolutional neural network asic. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition Workshops, pp. 0–0, 2019a.
|
| 175 |
+
|
| 176 |
+
Shih-Chii Liu and Tobi Delbruck. Neuromorphic sensory systems. Current opinion in neurobiology, 20(3):288–295, 2010.
|
| 177 |
+
|
| 178 |
+
Shih-Chii Liu, Bodo Rueckauer, Enea Ceolini, Adrian Huber, and Tobi Delbruck. Event-driven sensing for efficient perception: Vision and audition algorithms. IEEE Signal Processing Magazine, 36(6):29–37, 2019b.
|
| 179 |
+
|
| 180 |
+
Aleksander Madry, Aleksandar Makelov, Ludwig Schmidt, Dimitris Tsipras, and Adrian Vladu. Towards deep learning models resistant to adversarial attacks, 2019.
|
| 181 |
+
|
| 182 |
+
Alberto Marchisio, Giacomo Pira, Maurizio Martina, Guido Masera, and Muhammad Shafique. Dvs-attacks: Adversarial attacks on dynamic vision sensors for spiking neural networks. In 2021 International Joint Conference on Neural Networks (IJCNN), pp. 1–9. IEEE, 2021.
|
| 183 |
+
|
| 184 |
+
Apostolos Modas, Seyed-Mohsen Moosavi-Dezfooli, and Pascal Frossard. Sparsefool: a few pixels make a big difference. CoRR, abs/1811.02248, 2018. URL http://arxiv.org/abs/ 1811.02248.
|
| 185 |
+
|
| 186 |
+
Seyed-Mohsen Moosavi-Dezfooli, Alhussein Fawzi, and Pascal Frossard. Deepfool: a simple and accurate method to fool deep neural networks. CoRR, abs/1511.04599, 2015. URL http: //arxiv.org/abs/1511.04599.
|
| 187 |
+
|
| 188 |
+
Emre O Neftci, Hesham Mostafa, and Friedemann Zenke. Surrogate gradient learning in spiking neural networks: Bringing the power of gradient-based optimization to spiking neural networks. IEEE Signal Processing Magazine, 36(6):51–63, 2019.
|
| 189 |
+
|
| 190 |
+
Garrick Orchard, Ajinkya Jayawant, Gregory K. Cohen, and Nitish Thakor. Converting static image datasets to spiking neuromorphic datasets using saccades. Frontiers in Neuroscience, 9:437, 2015. ISSN 1662-453X. doi:10.3389/fnins.2015.00437. URL https://www.frontiersin. org/article/10.3389/fnins.2015.00437.
|
| 191 |
+
|
| 192 |
+
Bodo Rueckauer, Iulia-Alexandra Lungu, Yuhuang Hu, Michael Pfeiffer, and Shih-Chii Liu. Conversion of continuous-valued deep networks to efficient event-driven networks for image classification. Frontiers in neuroscience, 11:682, 2017.
|
| 193 |
+
|
| 194 |
+
Saima Sharmin, Nitin Rathi, Priyadarshini Panda, and Kaushik Roy. Inherent adversarial robustness of deep spiking neural networks: Effects of discrete input encoding and non-linear activations. In European Conference on Computer Vision, pp. 399–414. Springer, 2020.
|
| 195 |
+
|
| 196 |
+
Martino Sorbaro, Qian Liu, Massimo Bortone, and Sadique Sheik. Optimizing the energy consumption of spiking neural networks for neuromorphic applications. Frontiers in neuroscience, 14:662, 2020.
|
| 197 |
+
|
| 198 |
+
Jan Stuijt, Manolis Sifalakis, Amirreza Yousefzadeh, and Federico Corradi. µbrain: An event-driven and fully synthesizable architecture for spiking neural networks. Frontiers in neuroscience, 15: 538, 2021.
|
| 199 |
+
|
| 200 |
+
Christian Szegedy, Wojciech Zaremba, Ilya Sutskever, Joan Bruna, Dumitru Erhan, Ian Goodfellow, and Rob Fergus. Intriguing properties of neural networks. arXiv preprint arXiv:1312.6199, 2013.
|
| 201 |
+
|
| 202 |
+
Hongyang Zhang, Yaodong Yu, Jiantao Jiao, Eric Xing, Laurent El Ghaoui, and Michael Jordan. Theoretically principled trade-off between robustness and accuracy. In International Conference on Machine Learning, pp. 7472–7482. PMLR, 2019.
|
| 203 |
+
|
| 204 |
+
# SUPPLEMENTARY MATERIAL
|
| 205 |
+
|
| 206 |
+
# 1 EMPIRICAL ANALYSIS OF THE RESULTING SPARSEFOOL PERTURBATIONS
|
| 207 |
+
|
| 208 |
+

|
| 209 |
+
Figure S1: Properties of the adversarial perturbations found by SparseFool, for two experiments: NMNIST (in simulation, $\eta = 0 . 5 , \lambda = 2 )$ and IBM Gestures (as tested on chip). Top left: Number of events in time within each data sample. The shaded areas represent the 0.1-0.9 interquantile range (not shown for the ‘original’ curve in the bottom panel). The perturbation tends to consist of spikes added at the beginning of the sample, especially for NMNIST which does not rely on temporal structure for inference. Very few spikes are removed, which justifies the choice of ignoring removed spikes in on-chip experiments. The periodic structure of NMNIST samples is intrinsic to the dataset, recorded with saccades. Bottom left: Distribution of increase in number of spikes after the attack, relative to the original number. Right: Matrices showing the label identified by the network when presented with the adversarial examples, given the original label, for the two experiments. Most IBM Gestures classes are perturbed towards the ‘other’ class, while there is no clear structure in the NMNIST case. $\mathrm { L H } =$ Left Hand, $\mathrm { R H } =$ Right Hand, $\mathrm { ( C ) C W = }$ (Counter) ClockWise.
|
| 210 |
+
|
| 211 |
+
With the aim of gaining more insight into the behaviour of our methods, we studied the characteristics of the perturbations resulting from SparseFool attacks in more detail. For this, we chose two specific experiments: a SparseFool run on NMNIST with hyperparameters $\eta = 0 . 5$ and $\lambda = 2$ ; and the on-chip IBM Gestures experiment. First, we empirically notice that SparseFool-based perturbations rarely involve the removal of events. In the NMNIST experiment considered here, an average of 7.6 events is removed from each sample, compared to an average of 214 spikes added. This justified our choice to ignore removed events in the course of the on-chip experiments.
|
| 212 |
+
|
| 213 |
+
As is evident from the examples in Figure 2, we also find that SparseFool’s adversarial perturbations tend to consist in the insertion of spikes at the beginning of the sample, with only a few spikes added later in time. The top left panel of figure S1 shows the time profile of the perturbations in detail. We believe this is a consequence of the use of the non-leaky neuron model. In non-leaky neurons, information can be stored indefinitely in the membrane potential, so early spikes have a further chance of contributing to a spike later in time, and are more effective compared to events added later in the sample. This effect is also present in the IBM Gestures experiment, but looks less prominent, possibly because networks trained with BPTT on data with richer features in time have a non-trivial dynamics. In this sense, we expect this phenomenon to be further reduced or disappear entirely when the task is strictly linked to the time evolution of the input signal, such as in auditory speech recognition. The timing of adversarial events could potentially be used for model interpretability purposes, to measure how much the model relies on temporal features.
|
| 214 |
+
|
| 215 |
+
Further to the median values reported in table 1, the lower left panel of figure S1 reports the full distributions of the number of added or removed events $L ^ { 1 }$ distances). Here, we display the numbers relative to the original number of events in the sample. We notice a minority of cases where the attack is successful only at the cost of a very significant injection of events.
|
| 216 |
+
|
| 217 |
+
Finally, we analysed the statistics of classes identified by the networks after the attack. SparseFool is used as an “untargeted” algorithm, i.e. it attempts to change the output of the network but without requirements on what the new class should be. Unsurprisingly, the “other gesture” class is a natural target class for many ground truth classes, but there are some exceptions which we find rather natural, such as “left hand wave” gestures being most often converted to “left hand clockwise”. Conversely, we observe no dominant target class in the NMNIST experiment. If the target class structure is undesirable, targeted attacks can be used instead.
|
| 218 |
+
|
| 219 |
+
# 2 DEFENCE VIA ADVERSARIAL TRAINING
|
| 220 |
+
|
| 221 |
+

|
| 222 |
+
Figure S2: Success rate and median $L ^ { 0 }$ of SparseFool for networks trained with TRADES robustness based on PGD attacks.
|
| 223 |
+
|
| 224 |
+
Once it is known that a model or system is sensitive to a certain type of adversarial attack, it is natural to investigate whether there is a way to build a network that is more resistent to these attacks. We therefore experimented with adversarial training using the TRadeoff-inspired Adversarial DEfense via Surrogate-loss minimization (TRADES) method (Zhang et al., 2019). The method consists of adding a new term to the loss function during training, which minimises the Kullback-Leibler divergence between the output of the network when the original input is presented, and the output when the adversarial example is presented:
|
| 225 |
+
|
| 226 |
+
$$
|
| 227 |
+
\mathcal { L } _ { \mathrm { r o b } } = \mathcal { L } + \frac { \beta _ { \mathrm { r o b } } } { B } \operatorname { D } _ { \mathrm { K L } } \bigl ( f \bigl ( \mathbf { x } _ { \mathrm { a d v } } \bigr ) ; f \bigl ( \mathbf { x } _ { 0 } \bigr ) \bigr ) .
|
| 228 |
+
$$
|
| 229 |
+
|
| 230 |
+
Here, $B$ is the batch size, $\beta _ { \mathrm { r o b } }$ is the parameter that defines the trade-off between robustness and accuracy, $f$ is the network and $\mathbf { x } _ { \mathrm { a d v } }$ is the adversarial input. Although networks that were trained using SparseFool would probably be more robust, we opted for PGD at training time, since it can be easily batched — but we attack the resulting networks using SparseFool. We used PGD in the $L ^ { \infty }$ domain and chose $\epsilon = 0 . 5$ as the maximum perturbation, with $N _ { \mathrm { p g d } } = 5$ attack steps. We also did not greedily chose the best indices to flip as described in section 2.1. Even if this was a much simplified version of the PGD attack, we found that this configuration produced perturbations with reasonable Hamming distances while being extremely efficient, and it was sufficient in inducing some level of robustness.
|
| 231 |
+
|
| 232 |
+
From the results in Figure S2 we note that the success rate is still quite high despite the adversarial training for the choices of $\beta _ { \mathrm { r o b } }$ we considered. However, given the fact that SparseFool aims at finding the smallest perturbation that triggers a misclassification, this is expected, and there is already a noticeable increase in the number of added spikes required, which is indeed a sign of robustness. In other words, the adversarially-trained network requires stronger and less stealthy attacks before it is fooled. Further work is required for a comprehensive investigation of other possible defence strategies.
|
md/dev/e42KbIw6Wb/e42KbIw6Wb.md
ADDED
|
@@ -0,0 +1,351 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# PIX2SEQ: A LANGUAGE MODELING FRAMEWORK FOR OBJECT DETECTION
|
| 2 |
+
|
| 3 |
+
Ting Chen, Saurabh Saxena, Lala Li, David J. Fleet, Geoffrey Hinton Google Research, Brain Team
|
| 4 |
+
|
| 5 |
+
# ABSTRACT
|
| 6 |
+
|
| 7 |
+
We present Pix2Seq, a simple and generic framework for object detection. Unlike existing approaches that explicitly integrate prior knowledge about the task, we cast object detection as a language modeling task conditioned on the observed pixel inputs. Object descriptions (e.g., bounding boxes and class labels) are expressed as sequences of discrete tokens, and we train a neural network to perceive the image and generate the desired sequence. Our approach is based mainly on the intuition that if a neural network knows about where and what the objects are, we just need to teach it how to read them out. Beyond the use of task-specific data augmentations, our approach makes minimal assumptions about the task, yet it achieves competitive results on the challenging COCO dataset, compared to highly specialized and well optimized detection algorithms.1
|
| 8 |
+
|
| 9 |
+

|
| 10 |
+
Figure 1: Illustration of Pix2Seq framework for object detection. The neural net perceives an image and generates a sequence of tokens that correspond to bounding boxes and class labels.
|
| 11 |
+
|
| 12 |
+
# 1 INTRODUCTION
|
| 13 |
+
|
| 14 |
+
Visual object detection systems aim to recognize and localize all objects of pre-defined categories in an image. The detected objects are typically described by a set of bounding boxes and associated class labels. Given the difficulty of the task, most existing methods, such as (Girshick, 2015; Ren et al., 2015; He et al., 2017; Lin et al., 2017b; Carion et al., 2020), are carefully designed and highly customized, with a significant amount of prior knowledge in the choice of architecture and loss function. For example, many architectures are tailored to the use of bounding boxes (e.g., with region proposals (Girshick, 2015; Ren et al., 2015) and RoI pooling (Girshick et al., 2014; He et al., 2017)). Others are tied to the use of object queries for object binding (Carion et al., 2020). Loss functions are often similarly tailored to the use of bounding boxes, such as box regression (Szegedy et al., 2013; Lin et al., 2017b), set-based matching (Erhan et al., 2014; Carion et al., 2020), or by incorporating specific performance metrics, like intersection-over-union on bounding boxes (Rezatofighi et al., 2019). Although existing systems find applications in myriad domains, from self-driving cars (Sun et al., 2020), to medical image analysis (Jaeger et al., 2020), to agriculture (Sa et al., 2016), the specialization and complexity make them difficult to integrate into a larger system, or generalize to a much broader array of tasks associated with general intelligence.
|
| 15 |
+
|
| 16 |
+
This paper advocates a new approach, based on the intuition that if a neural net knows about where and what the objects are, we just need to teach it to read them out. And by learning to “describe” objects the model can learn to ground the “language” on pixel observations, leading to useful object representations. This is realized with our Pix2Seq framework (see Figure 1). Given an image, our model produces a sequence of discrete tokens that correspond to object descriptions (e.g., object bounding boxes and class labels), reminiscent of an image captioning system (Vinyals et al., 2015b; Karpathy & Fei-Fei, 2015; Xu et al., 2015). In essence, we cast object detection as a language modeling task conditioned on pixel inputs, for which the model architecture and loss function are generic and relatively simple, without being engineered specifically for the detection task. As such, one can readily extend the framework to different domains or applications, or incorporate it into a perceptual system supporting general intelligence, for which it provides a language interface to a wide range of vision tasks.
|
| 17 |
+
|
| 18 |
+
To tackle the detection task with Pix2Seq, we first propose a quantization and serialization scheme that converts bounding boxes and class labels into sequences of discrete tokens. We then leverage an encoder-decoder architecture for perceiving pixel inputs and generating the target sequence. The objective function is simply the maximum likelihood of tokens conditioned on pixel inputs and the preceding tokens. While both the architecture and loss function are task-agnostic (without assuming prior knowledge about object detection, e.g., bounding boxes), we can still incorporate task-specific prior knowledge with a sequence augmentation technique, proposed below, that alters both input and target sequences during training. Through extensive experimentation, we demonstrate that this simple Pix2Seq framework can achieve competitive results on the COCO dataset compared to highly customized, well established approaches, including Faster R-CNN (Ren et al., 2015) and DETR (Carion et al., 2020). By pretraining our model on a larger object detection dataset, its performance can be further improved.
|
| 19 |
+
|
| 20 |
+
# 2 THE PIX2SEQ FRAMEWORK
|
| 21 |
+
|
| 22 |
+
In the proposed Pix2Seq framework we cast object detection as a language modeling task, conditioned on pixel inputs (Figure 1). The system consists of four main components (Figure 2):
|
| 23 |
+
|
| 24 |
+
• Image Augmentation: As is common in training computer vision models, we use image augmentations to enrich a fixed set of training examples (e.g., with random scaling and crops). • Sequence construction & augmentation: As object annotations for an image are usually represented as a set of bounding boxes and class labels, we convert them into a sequence of discrete tokens. • Architecture: We use an encoder-decoder model, where the encoder perceives pixel inputs, and the decoder generates the target sequence (one token at a time). • Objective/loss function: The model is trained to maximize the log likelihood of tokens conditioned on the image and the preceding tokens (with a softmax cross-entropy loss).
|
| 25 |
+
|
| 26 |
+

|
| 27 |
+
Figure 2: Major components of the Pix2Seq learning framework.
|
| 28 |
+
|
| 29 |
+
# .1 SEQUENCE CONSTRUCTION FROM OBJECT DESCRIPTIONS
|
| 30 |
+
|
| 31 |
+
In common object detection datasets, such as Pascal VOC (Everingham et al., 2010), COCO (Lin et al., 2014), and OpenImages (Kuznetsova et al., 2020), images have variable numbers of objects, represented as sets of bounding boxes and class labels. In Pix2Seq we express them as sequences of discrete tokens.
|
| 32 |
+
|
| 33 |
+
While class labels are naturally expressed as discrete tokens, bounding boxes are not. A bounding box is determined by two of its corner points (i.e., top-left and bottom-right), or by its center point plus height and width. We propose to discretize the continuous numbers used to specify the $x$ , $y$ coordinates of corner points (similarly for height and width if the other box format is used). Specifically, an object is represented as a sequence of five discrete tokens, i.e. $[ y _ { \mathrm { m i n } } , x _ { \mathrm { m i n } } , y _ { \mathrm { m a x } } , x _ { \mathrm { m a x } } , c ]$ , where each of the continuous corner coordinates is uniformly discretized into an integer between $[ 1 , n _ { \mathrm { b i n s } } ]$ , and $c$ is the class index. We use a shared vocabulary for all tokens, so the vocabulary size is equal to number of bins $^ +$ number of classes. This quantization scheme for the bounding boxes allows us to use a small vocabulary while achieving high precision. For example, a $6 0 0 \times 6 0 0$ image requires only 600 bins to achieve zero quantization error. This is much smaller than modern language models with vocabulary sizes of 32K or higher (Radford et al., 2018; Devlin et al., 2018). The effect of different levels of quantization on the placement of bounding boxes is illustrated in Figure 3.
|
| 34 |
+
|
| 35 |
+
With each object description expressed as a short discrete sequence, we next need to serialize multiple object descriptions to form a single sequence for a given image. Since order of objects does not matter for the detection task per se, we use a random ordering strategy (randomizing the order objects each time an image is shown). We also explore other deterministic ordering strategies, but we hypothesize that random ordering will work just as well as any deterministic ordering, given a capable neural net and autoregressive modeling (where the net can learn to model the distribution of remaining objects conditioned on those observed).
|
| 36 |
+
|
| 37 |
+
Finally, because different images often have different numbers of objects, the generated sequences will have different lengths. To indicate the end of a sequence, we therefore incorporate an EOS token.0 0 0 0 The sequence construction process with different ordering strategies is illustrated in Figure 4.
|
| 38 |
+
|
| 39 |
+

|
| 40 |
+
Figure 3: Applying the proposed discritization of bounding box on an image of $4 8 0 \times 6 4 0$ . Only a 200 300 400 500 600 0 100 200 300 400 500 600 0 100 200 300 400 500 600 0 100 200 300 400 500 0 100 200 300 quarter of the image is shown for better clarity. With a small number of bins, such as 500 bins $( \sim 1$ Truth Truthpixel/bin), it achieves high precision even for small objects.
|
| 41 |
+
|
| 42 |
+

|
| 43 |
+
Figure 4: Examples of sequence construction with $n _ { \mathrm { b i n s } } = 1 0 0 0$ , and 0 is EOS token.
|
| 44 |
+
|
| 45 |
+

|
| 46 |
+
|
| 47 |
+
# 2.2 ARCHITECTURE, OBJECTIVE AND INFERENCE
|
| 48 |
+
|
| 49 |
+
Treating the sequences that we construct from object descriptions as a “dialect”, we turn to generic architectures and objective functions that have been effective in language modeling.
|
| 50 |
+
|
| 51 |
+
Architecture We use an encoder-decoder architecture. The encoder can be a general image encoder that perceives pixels and encodes them into hidden representations, such as a ConvNet (LeCun et al., 1989; Krizhevsky et al., 2012; He et al., 2016), Transformer (Vaswani et al., 2017; Dosovitskiy et al., 2020), or their combination (Carion et al., 2020). For generation we use a Transformer decoder, widely used in modern language modeling (Radford et al., 2018; Raffel et al., 2019). It generates one token at a time, conditioned on the preceding tokens and the encoded image representation. This removes the complexity and customization in architectures of modern object detectors, e.g., bounding box proposal and regression, since tokens are generated from a single vocabulary with a softmax.
|
| 52 |
+
|
| 53 |
+
Objective Similar to language modeling, Pix2Seq is trained to predict tokens, given an image and preceding tokens, with a maximum likelihood loss, i.e.,
|
| 54 |
+
|
| 55 |
+
$$
|
| 56 |
+
\mathrm { m a x i m i z e } \sum _ { j = 1 } ^ { L } { \pmb w } _ { j } \log P ( \tilde { \pmb y } _ { j } | { \pmb x } , { \pmb y } _ { 1 : j - 1 } ) ~ ,
|
| 57 |
+
$$
|
| 58 |
+
|
| 59 |
+
where $_ { \textbf { \em x } }$ is a given image, $\textbf { { y } }$ and $\tilde { \pmb { y } }$ are input and target sequences associated with $_ { \textbf { \em x } }$ , and $L$ is the target sequence length. $\textbf { { y } }$ and $\tilde { y }$ are identical in the standard language modeling setup, but they can also be different (as in our later augmented sequence construction). Also, ${ \pmb w } _ { j }$ is a pre-assigned weight for $j$ -th token in the sequence. We set ${ \pmb w } _ { j } = 1 , \forall j$ , however it would be possible to weight tokens by their types (e.g., coordinate vs class tokens), or by the size of the corresponding object.
|
| 60 |
+
|
| 61 |
+
Inference At inference time, we sample tokens from model likelihood, i.e., $P ( \pmb { y } _ { j } | \pmb { x } , \pmb { y } _ { 1 : j - 1 } )$ . This can be done by either taking the token with the largest likelihood (arg max sampling), or using other stochastic sampling techniques. We find that using nucleus sampling (Holtzman et al., 2019) leads to higher recall than arg max sampling (Appendix C). The sequence ends when the EOS token is generated. Once the sequence is generated, it is straight-forward to extract and de-quantize the object descriptions (i.e., obtaining the predicted bounding boxes and class labels).
|
| 62 |
+
|
| 63 |
+
# 2.3 SEQUENCE AUGMENTATION TO INTEGRATE TASK PRIORS
|
| 64 |
+
|
| 65 |
+
The EOS token allows the model to decide when to terminate generation, but in practice we find that the model tends to finish without predicting all objects. This is likely due to 1) annotation noise (e.g., where annotators did not identify all the objects), and 2) uncertainty in recognizing or localizing some objects. While this only affects the overall performance by a small percentage (e.g., $1 \%$ in average precision), it has a larger effect on recall. To encourage higher recall rates, one trick is to delay the sampling of the EOS token by artificially decreasing its likelihood. However, this often leads to noisy and duplicated predictions. In part, this difficult trade-off between precision and recall is a consequence of our model being task agnostic, unaware of the detection task per se.
|
| 66 |
+
|
| 67 |
+
To mitigate the problem we simply introduce a sequence augmentation technique, thereby incorporating prior knowledge about the task. The target sequence $\tilde { y }$ in conventional autoregressive language modeling (i.e., with no sequence augmentation) is the same as the input sequence $\textbf { { y } }$ . And all tokens in a sequence are real (e.g., converted from human annotations). With sequence augmentation, we instead augment input sequences during training to include both real and synthetic noise tokens. We also modify target sequences so that the model can learn to identify the noise tokens rather than mimic them. This improves the robustness of the model against noisy and duplicated predictions (particularly when the EOS token is delayed to increase recall). The modifications introduced by sequence augmentation are illustrated in Figure 5, and detailed below.
|
| 68 |
+
|
| 69 |
+
Altered sequence construction We first create synthetic noise objects to augment input sequences in the following two ways: 1) adding noise to existing ground-truth objects (e.g., random scaling or shifting their bounding boxes), and 2) generating completely random boxes (with randomly associated class labels). It is worth noting that some of these noise objects may be identical to, or overlapping with, some of the ground-truth objects, simulating noisy and duplicated predictions, as demonstrated in Figure 6. After noise objects are synthesised and discretized, we then append them in the end of the original input sequence. As for the target sequence, we set the target tokens of noise objects to “noise” class (not belonging to any of the ground-truth class labels), and the coordinate tokens of noise objects to $\mathrm { ^ { 6 6 } n / a } ^ { \prime \prime }$ , whose loss weights are set to zero, i.e., setting $\pmb { w } _ { j } = \mathbb { 1 } _ { [ \tilde { \pmb { y } } _ { j } \neq \mathbf { \ " { n } } / \mathbf { a } ^ { \prime \prime } ] }$ in Eq 1.
|
| 70 |
+
|
| 71 |
+

|
| 72 |
+
|
| 73 |
+

|
| 74 |
+
Figure 5: Illustration of language modeling with / without sequence augmentation. With sequence augmentation, input tokens are constructed to include both real objects (blue) and synthetic noise objects (orange). For the noise objects, the model is trained to identify them as the “noise” class, and we set the loss weight of $\mathrm { \ddot { \Delta } n / a ^ { \prime } \mathrm { \Delta } }$ tokens (corresponding to coordinates of noise objects) to zero since we do not want the model to mimic them.
|
| 75 |
+
Figure 6: Illustrations of randomly sampled noise objects (in white), vs. ground-truth objects (in red).
|
| 76 |
+
|
| 77 |
+
Altered inference With sequence augmentation, we are able to substantially delay the EOS token, improving recall without increasing the frequency of noisy and duplicated predictions. Thus, we let the model predict to a maximum length, yielding a fixed-sized list of objects. When we extract the list of bounding boxes and class labels from the generated sequences, we replace the “noise” class label with a real class label that has the highest likelihood among all real class labels. We use the likelihood of the selected class token as a (ranking) score for the object.
|
| 78 |
+
|
| 79 |
+
# 3 EXPERIMENTS
|
| 80 |
+
|
| 81 |
+
# 3.1 EXPERIMENTAL SETUP
|
| 82 |
+
|
| 83 |
+
We evaluate the proposed method on the MS-COCO 2017 detection dataset (Lin et al., 2014), containing 118k training images and $5 \mathrm { k }$ validation images. To compare with DETR and Faster R-CNN, we report average precision (AP), an integral metric over multiple thresholds, on validation set at the last training epoch. We employ two training strategies: 1) training from scratch on COCO in order to compare fairly with the baselines, and also 2) pretraining $^ + .$ finetuning, i.e., pretrain the Pix2Seq model on a larger object detection dataset, namely Objects365 (Shao et al., 2019), and then finetune the model on COCO. Since our approach incorporates zero inductive bias / prior knowledge of the object detection task, we expect the second training strategy to be superior.
|
| 84 |
+
|
| 85 |
+
Table 1: Comparison of average precision, over multiple thresholds and object sizes, on COCO validation set. Each section compares different methods of the similar ResNet “backbone”. Our models achieve competitive results to both Faster R-CNN and DETR baselines.
|
| 86 |
+
|
| 87 |
+
<table><tr><td>Method</td><td>Backbone</td><td>#params</td><td>AP</td><td>AP50</td><td>AP75</td><td>APs</td><td>APm</td><td>APL</td></tr><tr><td>Faster R-CNN</td><td>R50-FPN</td><td>42M</td><td>40.2</td><td>61.0</td><td>43.8</td><td>24.2</td><td>43.5</td><td>52.0</td></tr><tr><td>Faster R-CNN+</td><td>R50-FPN</td><td>42M</td><td>42.0</td><td>62.1</td><td>45.5</td><td>26.6</td><td>45.4</td><td>53.4</td></tr><tr><td>DETR</td><td>R50</td><td>41M</td><td>42.0</td><td>62.4</td><td>44.2</td><td>20.5</td><td>45.8</td><td>61.1</td></tr><tr><td>Pix2seq (Ours)</td><td>R50</td><td>37M</td><td>43.0</td><td>61.0</td><td>45.6</td><td>25.1</td><td>46.9</td><td>59.4</td></tr><tr><td>Faster R-CNN</td><td>R101-FPN</td><td>60M</td><td>42.0</td><td>62.5</td><td>45.9</td><td>25.2</td><td>45.6</td><td>54.6</td></tr><tr><td>Faster R-CNN+</td><td>R101-FPN</td><td>60M</td><td>44.0</td><td>63.9</td><td>47.8</td><td>27.2</td><td>48.1</td><td>56.0</td></tr><tr><td>DETR</td><td>R101</td><td>60M</td><td>43.5</td><td>63.8</td><td>46.4</td><td>21.9</td><td>48.0</td><td>61.8</td></tr><tr><td>Pix2seq (Ours)</td><td>R101</td><td>56M</td><td>44.5</td><td>62.8</td><td>47.5</td><td>26.0</td><td>48.2</td><td>60.3</td></tr><tr><td>Faster R-CNN</td><td>R50-DC5</td><td>166M</td><td>39.0</td><td>60.5</td><td>42.3</td><td>21.4</td><td>43.5</td><td>52.5</td></tr><tr><td>Faster R-CNN+</td><td>R50-DC5</td><td>166M</td><td>41.1</td><td>61.4</td><td>44.3</td><td>22.9</td><td>45.9</td><td>55.0</td></tr><tr><td>DETR</td><td>R50-DC5</td><td>41M</td><td>43.3</td><td>63.1</td><td>45.9</td><td>22.5</td><td>47.3</td><td>61.1</td></tr><tr><td>Pix2seq (Ours)</td><td>R50-DC5</td><td>38M</td><td>43.2</td><td>61.0</td><td>46.1</td><td>26.6</td><td>47.0</td><td>58.6</td></tr><tr><td>DETR</td><td>R101-DC5</td><td>60M</td><td>44.9</td><td>64.7</td><td>47.7</td><td>23.7</td><td>49.5</td><td>62.3</td></tr><tr><td>Pix2seq (Ours)</td><td>R101-DC5</td><td>57M</td><td>45.0</td><td>63.2</td><td>48.6</td><td>28.2</td><td>48.9</td><td>60.4</td></tr></table>
|
| 88 |
+
|
| 89 |
+
For training from scratch, we follow (Carion et al., 2020) using a ResNet backbone (He et al., 2016), followed by 6 layers of transformer encoder and 6 layers of (causal) transformer decoder (Vaswani et al., 2017). We resize images (with a fixed aspect ratio) so the longer side is 1333 pixels. For sequence construction, we use 2000 quantization bins, and we randomize the order of objects every time an image is shown. We append noise objects to real objects such that each image contains 100 objects in total, and hence a sequence length of 500. The model is trained for 300 epochs with a batch size of 128.
|
| 90 |
+
|
| 91 |
+
For pretraining on Objects365 dataset, we use similar settings as above with a few differences. Notably, instead of using the large $1 3 3 3 \times 1 3 3 3$ image size, we use a smaller image size of $6 4 0 \times 6 4 0$ , and pretrain the models for 400K steps with batch size of 256. It is worth noting that this pretraining process is even faster than training from scratch due to the use of smaller image size. During the finetuning on COCO dataset, only a small number of epochs (e.g., 20 to 60 epochs) are needed to achieve good results. And we could use larger image size during fine-tuning as well. Due to the use of larger pretraining dataset, we also experiment with larger models with Vision Transformers (Dosovitskiy et al., 2020).
|
| 92 |
+
|
| 93 |
+
More details for both training strategies can be found in Appendix B. As for ablations, we use a ResNet-101 backbone with a smaller image size (the longer side is 640), and we train the model from scratch for 200 epochs.
|
| 94 |
+
|
| 95 |
+
# 3.2 MAIN COMPARISONS
|
| 96 |
+
|
| 97 |
+
Training from scratch on COCO We mainly compare with two widely recognized baselines: DETR and Faster R-CNN. DETR and our model have comparable architectures, but our Transformer decoder does not require learned “object queries” or separated heads for box regression and classification, since our model generates different types of tokens (e.g., coordinate and class tokens) with a single softmax. Faster R-CNN is a well established method, with optimized architectures such as feature-pyramid networks (FPN) (Lin et al., 2017a). Faster R-CNN is typically trained in fewer epochs than DETR or our model, likely because it explicitly incorporates prior knowledge of the task in the architecture itself. Thus we also include an improved Faster R-CNN baseline, denoted as Faster $\mathrm { R - C N N + }$ , from (Carion et al., 2020), where Faster R-CNN models are trained with the GIoU loss (Rezatofighi et al., 2019), train-time random crop augmentations, and the long $9 \mathrm { x }$ training schedule.
|
| 98 |
+
|
| 99 |
+
Results are shown in Table 1, where each section compares different methods of the same ResNet “backbone”. Overall, Pix2Seq achieves competitive results to both baselines. Our model performs comparably to Faster R-CNN on small and medium objects, but better on larger objects. Compared with DETR, our model performs comparably or slightly worse on large and medium objects, but substantially better (4-5 AP) on small objects.
|
| 100 |
+
|
| 101 |
+
Table 2: Average precision of finetuned Pix2seq models on COCO with different backbone architectures and image sizes. All models are pretrained on Objects365 dataset. As a comparison, our best model without pretraining obtains 45.0 AP (in Table 1) with image size of $1 3 3 3 \times 1 3 3 3$ . The pretraining is with $6 4 0 \times 6 4 0$ image size while fine-tuning (a few epochs) can use larger image sizes.
|
| 102 |
+
|
| 103 |
+
<table><tr><td rowspan="2">Backbone</td><td rowspan="2"># params</td><td colspan="3">Image size during finetuning</td></tr><tr><td>640×640</td><td>1024×1024</td><td>1333×1333</td></tr><tr><td>R50</td><td>37M</td><td>39.1</td><td>41.7</td><td>42.6</td></tr><tr><td>R50-C4</td><td>85M</td><td>44.7</td><td>46.9</td><td>47.3</td></tr><tr><td>ViT-B</td><td>115M</td><td>44.2</td><td>46.5</td><td>47.1</td></tr><tr><td>ViT-L</td><td>341M</td><td>47.6</td><td>49.0</td><td>50.0</td></tr></table>
|
| 104 |
+
|
| 105 |
+
Pretrain on Objects365 and finetune on COCO As shown in Table 2, the performances of Objects365 pretrained Pix2Seq models are strong across various model sizes and image sizes. The best performance (with 1333 image size) is $5 0 ~ \mathrm { A P }$ which is $5 \%$ higher than the best model trained from scratch, and the performance holds up very well even with 640 image size. Notably, with a smaller image size used for pretraining, the pretrain+finetune process is faster than training from scratch, and also generalizes better. Both factors are crucial for training larger and better models.
|
| 106 |
+
|
| 107 |
+
# 3.3 ABLATION ON SEQUENCE CONSTRUCTION
|
| 108 |
+
|
| 109 |
+
Figure 7a explores the effect of coordinate quantization on performance. For this ablation we consider images the longest size of which is 640 pixels. The plot indicates that quantization to 500 bins or more is sufficient; with 500 bins there are approximately 1.3 pixels per bin, which does not introduce significant approximation error. Indeed, as long as one has as many bins as the number of pixels (along the longest side of the image) there should be no significant error due to quantization of the bounding box coordinates.
|
| 110 |
+
|
| 111 |
+
We also consider different object ordering strategies in sequence construction during training. These include 1) random, 2) area (i.e., descending object size), 3) dist2ori (i.e., the distance of top-left corner of the bounding box to the origin), 4) class (name), 5) class $^ +$ area (i.e., the objects are first ordered by their class, and if there are multiple objects of the same class, they are ordered by area), and 6) class $^ +$ dist2ori. Figure 7b shows average precision (AP) and Figure $\mathrm { 7 c }$ shows average recall (AR) at the top-100 predictions. Both in terms of precision and recall, the random ordering yields the best performance. We conjecture that with deterministic ordering, it may be difficult for the model to recover from mistakes of missing objects made earlier on, while with random ordering it would still be possible to retrieve them later.
|
| 112 |
+
|
| 113 |
+

|
| 114 |
+
Figure 7: Ablations on sequence construction. (a) Quantization bins vs. performance. (b) and (c) show AP and AR $@ 1 0 0$ for different object ordering strategies.
|
| 115 |
+
|
| 116 |
+
# 3.4 ABLATION ON SEQUENCE AUGMENTATION
|
| 117 |
+
|
| 118 |
+
Here we study the impact of sequence augmentation (i.e., adding the noise objects) for both model training strategies: 1) training from scratch on COCO, and 2) pretraining on Objects365 and finetuning on COCO. Results for training from scratch w/wo sequence augmentation are shown in Figure 8, and we find that without sequence augmentation, the AP is marginally worse if one delays the sampling of EOS token during the inference (via likelihood offsetting), but the recall is significantly worse for the optimal AP. Table 3 shows similar results for pretraining $^ +$ finetuning setting (where we set a loss weight of 0.1 on ending token instead of tuning their likelihood offset), and we find that AP is not significantly affected while recall is significantly worse without sequence augmentation. It is also worth noting that sequence augmentation is mainly effective during the fine-tuning.
|
| 119 |
+
|
| 120 |
+
<table><tr><td>SeqAug in Pretrain</td><td>SeqAug in Finetune</td><td>AP</td><td>AR@100</td></tr><tr><td>×</td><td>义</td><td>43.7</td><td>55.4</td></tr><tr><td>X</td><td></td><td>44.5</td><td>61.6</td></tr><tr><td>√</td><td>√</td><td>44.7</td><td>61.7</td></tr></table>
|
| 121 |
+
|
| 122 |
+

|
| 123 |
+
Figure 8: Impact of sequence augmentation on when training from scratch on COCO.
|
| 124 |
+
|
| 125 |
+
Table 3: Impact of sequence augmentation when pretraining on Objects365 and finetuning on COCO. Sequence augmentation has a major impact on average recall $( \ @ 1 0 0 )$ but a smaller influence on AP. Most improvements can be achieved during fine-tuning.
|
| 126 |
+
|
| 127 |
+
# 3.5 VISUALIZATION OF DECODER’S CROSS ATTENTION MAP
|
| 128 |
+
|
| 129 |
+
When generating a new token, the transformer decoder uses self attention over the preceding tokens and cross attention over the encoded visual feature map. Here we visualize the cross attention (averaged over layers and heads) as the model predicts a new token. Figure 9 shows cross attention maps as the first few tokens are generated. One can see that the attention is very diverse when predicting the first coordinate token (i.e $y _ { \mathrm { m i n . } }$ ), but then quickly concentrates and fixates on the object.
|
| 130 |
+
|
| 131 |
+

|
| 132 |
+
Figure 9: Decoder’s cross attention to visual feature map when predicting the first 5 objects. (b) we reshape a prediction sequence of 25 into a 5x5 grid, so each row represents a prediction for 5 tokens $[ y _ { \mathrm { m i n } } , x _ { \mathrm { m i n } } , y _ { \mathrm { m a x } } , x _ { \mathrm { m a x } } , c ]$ . The attention is diverse when selecting the first token of the object, then quickly concentrates on the object. (c) Overlay of the cross attention (when predicting the class token) on the original image.
|
| 133 |
+
|
| 134 |
+
# 4 RELATED WORK
|
| 135 |
+
|
| 136 |
+
Object detection. Existing object detection algorithms incorporate explicit prior knowledge about the task in their choice of architecture and loss function. To predict a set of bounding boxes, architectures of modern detectors are specifically designed to produce a large set of proposals (Girshick, 2015; Ren et al., 2015; Cai & Vasconcelos, 2018), anchors (Lin et al., 2017b), or window centers (Tian et al., 2019; Zhou et al., 2019). Non-maximum suppression (Bodla et al., 2017) is often required to prevent duplicate predictions. While DETR (Carion et al., 2020) avoids sophisticated bounding box proposals and non-maximum suppression, it still requires a set of learned “object queries”, specially for object binding. These detectors all require sub-networks (or extra layers) separately for regressing bounding boxes and class labels. Pix2Seq avoids such complexities by having a generic image encoder and sequence decoder, with a single softmax for producing coordinate tokens and class labels.
|
| 137 |
+
|
| 138 |
+
Beyond architectures, the loss functions of existing detectors are also highly tailored for matching bounding boxes. For example, the loss function is often based on bounding box regression (Szegedy et al., 2013; Lin et al., 2017b), intersection over union (Rezatofighi et al., 2019), and set-based matching (Erhan et al., 2014; Liu et al., 2016; Redmon et al., 2016; Stewart et al., 2016; Carion et al., 2020). Pix2Seq avoids specialized losses, showing that a straightforward maximum likelihood objective with softmax cross entropy can work well.
|
| 139 |
+
|
| 140 |
+
Our work is also related to recurrent models in object detection (Stewart et al., 2016; Park & Berg, 2015; Romera-Paredes & Torr, 2016; Salvador et al., 2017; Ren & Zemel, 2017), in which the system learns to predict one object at a time. As above, both architecture and loss functions in these approaches are often tailored to the detection task. Furthermore, these approaches are not based on Transformers, and have not been evaluated against modern baselines on larger datasets.
|
| 141 |
+
|
| 142 |
+
Language modeling. Our work is inspired by recent success of modern language modeling (Radford et al., 2019; Raffel et al., 2019; Brown et al., 2020). Although originally intended for natural languages, the underlying methodology has been shown capable of modeling various sequential data, such as machine translation (Sutskever et al., 2014; Bahdanau et al., 2014), image captioning (Vinyals et al., 2015b; Karpathy & Fei-Fei, 2015; Xu et al., 2015), and many others (Vinyals et al., 2015a; Huang et al., 2018; Ramesh et al., 2021; Chen et al., 2021). Our work enriches this portfolio and shows that it works for even non-sequential data (by turning a set of objects into a sequence of tokens). We augment both input and target sequences for our model to incorporate task-specific prior knowledge; similar sequence corruption scheme have been used in language models (Devlin et al., 2018; Clark et al., 2020), and bear some similarity to noise-contrastive learning (Gutmann & Hyvarinen, 2010) and the discriminator in GANs (Goodfellow et al., 2014). ¨
|
| 143 |
+
|
| 144 |
+
# 5 CONCLUSION AND FUTURE WORK
|
| 145 |
+
|
| 146 |
+
This paper introduces Pix2Seq, a simple yet generic framework for object detection. By casting object detection as a language modeling task, our approach largely simplifies the detection pipeline, removing most of the specialization in modern detection algorithms. We believe that our framework not only works for object detection, but can also be applied to other vision tasks where the output can be represented by a relatively concise sequence of discrete tokens (e.g., keypoint detection, image captioning, visual question answering). To this end, we hope to extend Pix2Seq as a generic and unified interface for solving a large variety of vision tasks.
|
| 147 |
+
|
| 148 |
+
A major limitation of our approach is that autoregressive modeling is expensive for long sequences (mainly during model inference). Practical measures to mitigate the issue includes: 1) stop inference when the ending token is produced (e.g., in COCO dataset, there are, in average, 7 objects per image, leading to a relatively small number of ${ \sim } 3 5 $ tokens), 2) applying it to offline inference, or online scenarios where the objects of interest are relatively sparse (e.g. locate a specific object with language description). However, future work is needed to make it faster for real-time object detection applications. Another limitation is that the current approach for training $\mathrm { P i x 2 S e q }$ is entirely based on human annotation, and by reducing such dependence, it can enable the model to benefit from more unlabeled data.
|
| 149 |
+
|
| 150 |
+
# ACKNOWLEDGEMENTS
|
| 151 |
+
|
| 152 |
+
We specially thank Xiuye Gu for preparing the Objects365 dataset. We thank Mohammad Norouzi, Simon Kornblith, Tsung-Yi Lin, Allan Jabri, and Kevin Swersky for the helpful discussions.
|
| 153 |
+
|
| 154 |
+
# REFERENCES
|
| 155 |
+
|
| 156 |
+
Dzmitry Bahdanau, Kyunghyun Cho, and Yoshua Bengio. Neural machine translation by jointly learning to align and translate. arXiv preprint arXiv:1409.0473, 2014.
|
| 157 |
+
|
| 158 |
+
Navaneeth Bodla, Bharat Singh, Rama Chellappa, and Larry S Davis. Soft-nms–improving object detection with one line of code. In Proceedings of the IEEE International Conference on Computer Vision, pp. 5561–5569, 2017.
|
| 159 |
+
|
| 160 |
+
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.
|
| 161 |
+
|
| 162 |
+
Zhaowei Cai and Nuno Vasconcelos. Cascade r-cnn: Delving into high quality object detection. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 6154–6162, 2018.
|
| 163 |
+
|
| 164 |
+
Nicolas Carion, Francisco Massa, Gabriel Synnaeve, Nicolas Usunier, Alexander Kirillov, and Sergey Zagoruyko. End-to-end object detection with transformers. In European Conference on Computer Vision, pp. 213–229. Springer, 2020.
|
| 165 |
+
|
| 166 |
+
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.
|
| 167 |
+
|
| 168 |
+
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.
|
| 169 |
+
|
| 170 |
+
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.
|
| 171 |
+
|
| 172 |
+
Kevin Clark, Minh-Thang Luong, Quoc V. Le, and Christopher D. Manning. ELECTRA: Pre-training text encoders as discriminators rather than generators. In ICLR, 2020.
|
| 173 |
+
|
| 174 |
+
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.
|
| 175 |
+
|
| 176 |
+
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.
|
| 177 |
+
|
| 178 |
+
Dumitru Erhan, Christian Szegedy, Alexander Toshev, and Dragomir Anguelov. Scalable object detection using deep neural networks. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 2147–2154, 2014.
|
| 179 |
+
|
| 180 |
+
M. Everingham, L. Van Gool, C. K. I. Williams, J. Winn, and A. Zisserman. The pascal visual object classes (voc) challenge. International Journal of Computer Vision, 88(2):303–338, June 2010.
|
| 181 |
+
|
| 182 |
+
Golnaz Ghiasi, Yin Cui, Aravind Srinivas, Rui Qian, Tsung-Yi Lin, Ekin D Cubuk, Quoc V Le, and Barret Zoph. Simple copy-paste is a strong data augmentation method for instance segmentation. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 2918–2928, 2021.
|
| 183 |
+
|
| 184 |
+
Ross Girshick. Fast r-cnn. In Proceedings of the IEEE International Conference on Computer Vision, pp. 1440–1448, 2015.
|
| 185 |
+
|
| 186 |
+
Ross Girshick, Jeff Donahue, Trevor Darrell, and Jitendra Malik. Rich feature hierarchies for accurate object detection and semantic segmentation. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 580–587, 2014.
|
| 187 |
+
|
| 188 |
+
Ian Goodfellow, Jean Pouget-Abadie, Mehdi Mirza, Bing Xu, David Warde-Farley, Sherjil Ozair, Aaron Courville, and Yoshua Bengio. Generative adversarial nets. Advances in Neural Information Processing Systems, 27, 2014.
|
| 189 |
+
|
| 190 |
+
Michael Gutmann and Aapo Hyvarinen. Noise-contrastive estimation: A new estimation principle for unnormal-¨ ized statistical models. In Proceedings of the thirteenth International Conference on artificial intelligence and statistics, pp. 297–304. JMLR Workshop and Conference Proceedings, 2010.
|
| 191 |
+
|
| 192 |
+
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.
|
| 193 |
+
|
| 194 |
+
Kaiming He, Georgia Gkioxari, Piotr Dollar, and Ross Girshick. Mask r-cnn. In ´ Proceedings of the IEEE International Conference on Computer Vision, pp. 2961–2969, 2017.
|
| 195 |
+
|
| 196 |
+
Elad Hoffer, Tal Ben-Nun, Itay Hubara, Niv Giladi, Torsten Hoefler, and Daniel Soudry. Augment your batch: Improving generalization through instance repetition. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 8129–8138, 2020.
|
| 197 |
+
|
| 198 |
+
Ari Holtzman, Jan Buys, Li Du, Maxwell Forbes, and Yejin Choi. The curious case of neural text degeneration. arXiv preprint arXiv:1904.09751, 2019.
|
| 199 |
+
|
| 200 |
+
Andrew G Howard. Some improvements on deep convolutional neural network based image classification. arXiv preprint arXiv:1312.5402, 2013.
|
| 201 |
+
|
| 202 |
+
Cheng-Zhi Anna Huang, Ashish Vaswani, Jakob Uszkoreit, Noam Shazeer, Ian Simon, Curtis Hawthorne, Andrew M Dai, Matthew D Hoffman, Monica Dinculescu, and Douglas Eck. Music transformer. arXiv preprint arXiv:1809.04281, 2018.
|
| 203 |
+
|
| 204 |
+
Gao Huang, Yu Sun, Zhuang Liu, Daniel Sedra, and Kilian Q Weinberger. Deep networks with stochastic depth. In European Conference on Computer Vision, pp. 646–661. Springer, 2016.
|
| 205 |
+
|
| 206 |
+
Paul F Jaeger, Simon AA Kohl, Sebastian Bickelhaupt, Fabian Isensee, Tristan Anselm Kuder, Heinz-Peter Schlemmer, and Klaus H Maier-Hein. Retina u-net: Embarrassingly simple exploitation of segmentation supervision for medical object detection. In Machine Learning for Health Workshop, pp. 171–183. PMLR, 2020.
|
| 207 |
+
|
| 208 |
+
Andrej Karpathy and Li Fei-Fei. Deep visual-semantic alignments for generating image descriptions. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 3128–3137, 2015.
|
| 209 |
+
|
| 210 |
+
Diederik P Kingma and Jimmy Ba. Adam: A method for stochastic optimization. arXiv preprint arXiv:1412.6980, 2014.
|
| 211 |
+
|
| 212 |
+
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.
|
| 213 |
+
|
| 214 |
+
Alina Kuznetsova, Hassan Rom, Neil Alldrin, Jasper Uijlings, Ivan Krasin, Jordi Pont-Tuset, Shahab Kamali, Stefan Popov, Matteo Malloci, Alexander Kolesnikov, et al. The open images dataset v4. International Journal of Computer Vision, 128(7):1956–1981, 2020.
|
| 215 |
+
|
| 216 |
+
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, 1(4): 541–551, 1989.
|
| 217 |
+
|
| 218 |
+
Yi Li, Haozhi Qi, Jifeng Dai, Xiangyang Ji, and Yichen Wei. Fully convolutional instance-aware semantic segmentation. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 2359–2367, 2017.
|
| 219 |
+
|
| 220 |
+
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.
|
| 221 |
+
|
| 222 |
+
Tsung-Yi Lin, Piotr Dollar, Ross Girshick, Kaiming He, Bharath Hariharan, and Serge Belongie. Feature ´ pyramid networks for object detection. In Proceedings of the IEEE Conference on Computer Vision and pattern recognition, pp. 2117–2125, 2017a.
|
| 223 |
+
|
| 224 |
+
Tsung-Yi Lin, Priya Goyal, Ross Girshick, Kaiming He, and Piotr Dollar. Focal loss for dense object detection.´ In Proceedings of the IEEE International Conference on Computer Vision, pp. 2980–2988, 2017b.
|
| 225 |
+
|
| 226 |
+
Wei Liu, Dragomir Anguelov, Dumitru Erhan, Christian Szegedy, Scott Reed, Cheng-Yang Fu, and Alexander C Berg. Ssd: Single shot multibox detector. In European Conference on Computer Vision, pp. 21–37. Springer, 2016.
|
| 227 |
+
|
| 228 |
+
Ilya Loshchilov and Frank Hutter. Decoupled weight decay regularization. In International Conference on Learning Representations, 2018.
|
| 229 |
+
|
| 230 |
+
Eunbyung Park and Alexander C Berg. Learning to decompose for object detection and instance segmentation. arXiv preprint arXiv:1511.06449, 2015.
|
| 231 |
+
|
| 232 |
+
Alec Radford, Karthik Narasimhan, Tim Salimans, and Ilya Sutskever. Improving language understanding by generative pre-training. 2018.
|
| 233 |
+
|
| 234 |
+
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.
|
| 235 |
+
|
| 236 |
+
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.
|
| 237 |
+
|
| 238 |
+
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.
|
| 239 |
+
|
| 240 |
+
Joseph Redmon, Santosh Divvala, Ross Girshick, and Ali Farhadi. You only look once: Unified, real-time object detection. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 779–788, 2016.
|
| 241 |
+
|
| 242 |
+
Mengye Ren and Richard S Zemel. End-to-end instance segmentation with recurrent attention. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 6656–6664, 2017.
|
| 243 |
+
|
| 244 |
+
Shaoqing Ren, Kaiming He, Ross Girshick, and Jian Sun. Faster r-cnn: Towards real-time object detection with region proposal networks. Advances in Neural Information Processing Systems, 28:91–99, 2015.
|
| 245 |
+
|
| 246 |
+
Hamid Rezatofighi, Nathan Tsoi, JunYoung Gwak, Amir Sadeghian, Ian Reid, and Silvio Savarese. Generalized intersection over union. June 2019.
|
| 247 |
+
|
| 248 |
+
Bernardino Romera-Paredes and Philip Hilaire Sean Torr. Recurrent instance segmentation. In European Conference on Computer Vision, pp. 312–329. Springer, 2016.
|
| 249 |
+
|
| 250 |
+
Inkyu Sa, Zongyuan Ge, Feras Dayoub, Ben Upcroft, Tristan Perez, and Chris McCool. Deepfruits: A fruit detection system using deep neural networks. sensors, 16(8):1222, 2016.
|
| 251 |
+
|
| 252 |
+
Amaia Salvador, Miriam Bellver, Victor Campos, Manel Baradad, Ferran Marques, Jordi Torres, and Xavier Giro-i Nieto. Recurrent neural networks for semantic instance segmentation. arXiv preprint arXiv:1712.00617, 2017.
|
| 253 |
+
|
| 254 |
+
Shuai Shao, Zeming Li, Tianyuan Zhang, Chao Peng, Gang Yu, Xiangyu Zhang, Jing Li, and Jian Sun. Objects365: A large-scale, high-quality dataset for object detection. In Proceedings of the IEEE/CVF international conference on computer vision, pp. 8430–8439, 2019.
|
| 255 |
+
|
| 256 |
+
Russell Stewart, Mykhaylo Andriluka, and Andrew Y Ng. End-to-end people detection in crowded scenes. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 2325–2333, 2016.
|
| 257 |
+
|
| 258 |
+
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 Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 2446–2454, 2020.
|
| 259 |
+
|
| 260 |
+
Ilya Sutskever, Oriol Vinyals, and Quoc V Le. Sequence to sequence learning with neural networks. In Advances in Neural Information Processing Systems, pp. 3104–3112, 2014.
|
| 261 |
+
|
| 262 |
+
Christian Szegedy, Alexander Toshev, and Dumitru Erhan. Deep neural networks for object detection. 2013.
|
| 263 |
+
|
| 264 |
+
Zhi Tian, Chunhua Shen, Hao Chen, and Tong He. Fcos: Fully convolutional one-stage object detection. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pp. 9627–9636, 2019.
|
| 265 |
+
|
| 266 |
+
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.
|
| 267 |
+
|
| 268 |
+
Oriol Vinyals, Łukasz Kaiser, Terry Koo, Slav Petrov, Ilya Sutskever, and Geoffrey Hinton. Grammar as a foreign language. Advances in Neural Information Processing Systems, 28:2773–2781, 2015a.
|
| 269 |
+
|
| 270 |
+
Oriol Vinyals, Alexander Toshev, Samy Bengio, and Dumitru Erhan. Show and tell: A neural image caption generator. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 3156– 3164, 2015b.
|
| 271 |
+
|
| 272 |
+
Yuxin Wu, Alexander Kirillov, Francisco Massa, Wan-Yen Lo, and Ross Girshick. Detectron2. https: //github.com/facebookresearch/detectron2, 2019.
|
| 273 |
+
|
| 274 |
+
Kelvin Xu, Jimmy Ba, Ryan Kiros, Kyunghyun Cho, Aaron Courville, Ruslan Salakhudinov, Rich Zemel, and Yoshua Bengio. Show, attend and tell: Neural image caption generation with visual attention. In International Conference on Machine Learning, pp. 2048–2057. PMLR, 2015.
|
| 275 |
+
|
| 276 |
+
Xingyi Zhou, Dequan Wang, and Philipp Krahenb ¨ uhl. Objects as points. ¨ arXiv preprint arXiv:1904.07850, 2019.
|
| 277 |
+
|
| 278 |
+
# A QUANTIZATION AND DEQUANTIZATION OF COORDINATES
|
| 279 |
+
|
| 280 |
+
Algorithm 1 and 2 illustrate the quantization and dequantization process of (normalized) coordinates.
|
| 281 |
+
|
| 282 |
+
# Algorithm 1 Quantization of (normalized) coordinates
|
| 283 |
+
|
| 284 |
+
# Algorithm 2 Dequantization of discrete tokens of coordinates
|
| 285 |
+
|
| 286 |
+
def quantize(x, bins $= 1 0 0 0 ;$ ): # x is a real number between [0, 1] # returns an integer between [0, bins-1] return int(x \* (bins - 1))
|
| 287 |
+
|
| 288 |
+
def dequantize(x, bins=1000): # x is an integer between [0, bins-1] # returns a real number between [0, 1] return float(x) / (bins - 1)
|
| 289 |
+
|
| 290 |
+
# B TRAINING DETAILS
|
| 291 |
+
|
| 292 |
+
Training from scratch on COCO For baseline architectures, we follow (Carion et al., 2020) using a ResNet backbone (He et al., 2016), followed by 6 layers of transformer encoder and 6 layers of (causal) transformer decoder (Vaswani et al., 2017). The main dimension of transformer is set to 256 with 8 attention heads, and the dimension of the feed-forward network is set to 1024. We use the stochastic depth (Huang et al., 2016) with a rate of $10 \%$ to reduce overfitting. Per (Carion et al., 2020), we also experiment with the DC5 variant of ResNet (Li et al., 2017), which increases the resolution of its output feature map by a factor of two.2
|
| 293 |
+
|
| 294 |
+
For image augmentation during training, we perform scale jittering with random crops (Ghiasi et al., 2021; Wu et al., 2019) with strength of [0.1, 3]. We resize images (with a fixed aspect ratio) so the longer side is 1333 pixels. Following (Howard, 2013; Chen et al., 2020a;b), we also use color distortion with a strength of 0.5. For sequence construction, we use 2000 quantization bins, and we randomize the order of objects every time an image is shown. We append noise objects to real objects such that each image contains 100 objects in total, and hence a sequence length of 500.
|
| 295 |
+
|
| 296 |
+
We train the entire network from scratch for 300 epochs with a batch size of 128. For each image in a mini-batch, we perform two independent augmentations, similar to (Hoffer et al., 2020), resulting in a 256 effective batch size, which we find helpful to reduce overfitting. We use AdamW optimizer (Kingma & Ba, 2014; Loshchilov & Hutter, 2018) with a learning rate of 0.003 and weight decay of 0.05. We use a learning rate warmup for 10 epochs and then linearly decay the learning rate over the course of training.
|
| 297 |
+
|
| 298 |
+
Pretraining on Objects365 We explore a wider range of architecture variants including both hybrid ResNet and transformer models (Carion et al., 2020), as well as pure transformers based on image patches (Dosovitskiy et al., 2020). The details of the architecture can be found in our released code. Since Objects365 dataset is much larger than COCO (1.7M images vs 118K images), we use a weaker image augmentation (scale jittering range of [0.3, 2] for ViT backbones, and [0.9, 1.2] for ResNet backbones) without color distortion. For sequence construction, we use 1000 quantization bins. And we still apply sequence augmentation with sampled noise objects added by default.
|
| 299 |
+
|
| 300 |
+
We use a smaller image size of $6 4 0 \times 6 4 0$ , and pretrain the models for 400K steps with batch size of 256. We do not perform two augmentations per batch as in training from scratch. And we use a smaller learning rate of 0.001 with the same weight decay of 0.05. We use a cosine learning rate decay with a initial warmup of 20K steps.
|
| 301 |
+
|
| 302 |
+
As for the finetuning on COCO dataset, we use a batch size of 128 for ResNet backbones, and 64 for ViT backbones. Most models are finetuned for 60 epochs with a learning rate of $3 e ^ { - 5 }$ , but even fewer epochs yield similar results. We still use scale jittering with a range of [0.3, 2] for image augmentation.
|
| 303 |
+
|
| 304 |
+
Nucleus sampling (Holtzman et al., 2019) has been applied to language modeling to reduce duplication and increase diversity in generated samples. Here we study its impact on sampling from our trained model.
|
| 305 |
+
|
| 306 |
+
Given the distribution $P ( \pmb { y } _ { j } | \pmb { x } , \pmb { y } _ { 1 : j - 1 } )$ , to apply nucleus sampling, we first define its top- $p$ vocabulary $V ^ { ( p ) } \subset V$ as the smallest set such that
|
| 307 |
+
|
| 308 |
+
$$
|
| 309 |
+
\sum _ { { \pmb y } _ { j } \in V ^ { ( p ) } } P ( { \pmb y } _ { j } | { \pmb x } , { \pmb y } _ { 1 : j - 1 } ) \geq p .
|
| 310 |
+
$$
|
| 311 |
+
|
| 312 |
+
Let $\begin{array} { r } { p ^ { \prime } = \sum _ { { \pmb y } _ { j } \in V ^ { ( p ) } } P \big ( { \pmb y } _ { j } | { \pmb x } , { \pmb y } _ { 1 : j - 1 } \big ) } \end{array}$ , and we can re-calibrate the conditional likelihood as following for sampling the next token.
|
| 313 |
+
|
| 314 |
+
$$
|
| 315 |
+
P ^ { \prime } ( { y } _ { j } | { x } , { y } _ { 1 : j - 1 } ) = \left\{ \begin{array} { l l } { P ( { y } _ { j } | { x } , { y } _ { 1 : i - 1 } ) / p ^ { \prime } } & { \mathrm { i f } { y } _ { j } \in V ^ { ( p ) } } \\ { 0 } & { \mathrm { o t h e r w i s e . } } \end{array} \right.
|
| 316 |
+
$$
|
| 317 |
+
|
| 318 |
+
We vary the hyper-parameter $p$ of nucleus sampling used in generating the output sequence (during inference). When $p = 0$ , it corresponds to arg max sampling, otherwise it samples from a truncated ranked list of tokens that has a cumsum larger or equal to $p$ . In Figure 10, we see that use of nucleus sampling (with $p > 0$ ) improves object recall and thus also leads to better average precision. There is a relatively flat region of AP between 0.2 and 0.5, and we select $p$ to be 0.4 as our default value for other experiments.
|
| 319 |
+
|
| 320 |
+

|
| 321 |
+
Figure 10: Varying parameter $p$ in nucleus sampling during inference results in different AP and AR. With $p = 0$ , it is equivalent to argmax sampling. Sampling with $p > 0$ is helpful for increasing recall (and precision).
|
| 322 |
+
|
| 323 |
+
# D VISUALIZATION OF SIMILARITY AMONG COORDINATE TOKENS
|
| 324 |
+
|
| 325 |
+
In our model, bounding box coordinates are not represented as floating points, but encoded as discrete tokens. Here we study the similarity among these coordinate tokens via their embeddings. Note that the discrete coordinate tokens and class name tokens are in the same vocabulary and share the same embedding matrix. Specifically, we first slice the learned embedding matrix corresponding to coordinate tokens, and then compute the cosine similarity of embedding vectors for these coordinate tokens.
|
| 326 |
+
|
| 327 |
+
Figure 11 shows cosine similarity among embeddings of coordinate tokens. We can see that nearby coordinates have higher similarities in their token embeddings than far away ones. This emergent property of our model is likely due to the noises / uncertainties in bounding box annotations (i.e. a bounding box annotation is a random sample from a distribution over potential bounding boxes which encodes locality of coordinates).
|
| 328 |
+
|
| 329 |
+
# E THE ABILITY TO DIRECT THE ATTENTION WITH GIVEN COORDINATES
|
| 330 |
+
|
| 331 |
+
We explore the model’s ability to pay attention to a pointed region specified via coordinates. We divide an image evenly into an $N \times N$ grid of rectangular regions, each specified by a sequence of coordinates for its bounding box. We then visualize the decoder’s cross attention to visual feature map after reading the sequence of coordinates for each region, i.e., $[ y _ { \mathrm { m i n } } , x _ { \mathrm { m i n } } , y _ { \mathrm { m a x } } , x _ { \mathrm { m a x } } ]$ . We shuffle the pixels in the image to remove distraction from existing objects, and remove $2 \%$ of the top attentions for clarity. Interestingly, as shown in Figure 12, it seems the model can pay attention to the specified region at different scales.
|
| 332 |
+
|
| 333 |
+

|
| 334 |
+
Figure 11: (a) Cosine similarity among embeddings of coordinate tokens. (b) is part of (a) covering only the first 100 tokens. (c), (d) and (e) are the 500-th, 1000-th and 1500-th rows of (a), respectively. Nearby coordinates have higher similarities in their token embeddings.
|
| 335 |
+
|
| 336 |
+

|
| 337 |
+
Figure 12: Each grid is a visualization of decoder’s attention after reading a small sequence of coordinates, i.e., $[ y _ { \mathrm { m i n } } , x _ { \mathrm { m i n } } , y _ { \mathrm { m a x } } , x _ { \mathrm { m a x } } ]$ . Visualization is done for grids of different sizes. The network learns to pay attention to pointed region at different scales.
|
| 338 |
+
|
| 339 |
+
# F MORE VISUALIZATION ON DECODER’S CROSS ATTENTION
|
| 340 |
+
|
| 341 |
+
In Figure 13, we overlay the cross attention (when predicting the class token) on the original image for several other images, and it shows that the decoder pays the most attention to the object when predicting the class token.
|
| 342 |
+
|
| 343 |
+

|
| 344 |
+
Figure 13: Visualization of Transformer decoder’s cross attention (when predicting class tokens) conditioned on the given bounding boxes.
|
| 345 |
+
|
| 346 |
+
# G VISUALIZATION OF DETECTION RESULTS
|
| 347 |
+
|
| 348 |
+
In Figure 14, we visualize detection results of one of Pix2seq model (with 46 AP) on a subset of images from COCO validation set that contain a crowded set of objects.
|
| 349 |
+
|
| 350 |
+

|
| 351 |
+
Figure 14: Examples of the model’s predictions (at the score threshold of 0.5). Original images accessed by clicking the images in supported PDF readers.
|
md/dev/fPhKeld3Okz/fPhKeld3Okz.md
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|