diff --git a/md/dev/-H48S9ePSUC/-H48S9ePSUC.md b/md/dev/-H48S9ePSUC/-H48S9ePSUC.md new file mode 100644 index 0000000000000000000000000000000000000000..b2dd1d5b6a0227fd9b3feb13e929dbc42e7b23c1 --- /dev/null +++ b/md/dev/-H48S9ePSUC/-H48S9ePSUC.md @@ -0,0 +1,424 @@ +# FUNDAMENTAL LIMITS OF TRANSFER LEARNING IN BINARY CLASSIFICATIONS + +Anonymous authors Paper under double-blind review + +# ABSTRACT + +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. + +# 1 INTRODUCTION + +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. + +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? + +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. + +In summary our key contributions are as follows: + +• 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. +• 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. +• We investigate the sharpness of our lower bounds and demonstrate their utility via experiments on action recognition and image classification. + +# 2 PRIOR WORKS + +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. + +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. + +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. + +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. + +# 3 PROBLEM FORMULATION + +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. + +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. + +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 + +$$ +\mathcal { E } _ { T } ( h ) = \mathbb { Q } [ h ( \mathbf { x } _ { T } ) \neq y _ { T } ] - \mathbb { Q } [ h _ { T } ^ { * } ( \mathbf { x } _ { T } ) \neq y _ { T } ] +$$ + +and + +$$ +\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} +$$ + +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 + +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. + +Definition 2 (Transfer distance) We define the transfer distance between a source and a target with distributions $\mathbb { P }$ and $\mathbb { Q }$ as follows + +$$ +\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 } ] +$$ + +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. + +# 4 MAIN RESULTS + +In this section we characterize the fundamental limits of transfer learning in binary classifications by deriving a minimax lower bound via information-theoretic arguments. + +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 + +$$ +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 } , +$$ + +where + +$$ +\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 } } } . +$$ + +This also implies that + +$$ +\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 ) . +$$ + +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. + +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 )$ . + +Remark 3 One can show that the numerical constant c in equation 4.1 obeys c > 3−2 248 . + +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. + +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. + +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. + +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. + +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. + +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 + +$$ +\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 } , +$$ + +where + +$$ +\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 } } } } . +$$ + +This in turn implies that + +$$ +\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 } ) . +$$ + +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. + +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 + +$$ +\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} +$$ + +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. + +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. + +# 5 EXPERIMENTAL RESULTS + +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. + +# 5.1 ACTION RECOGNITION + +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. + +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 + +$$ +\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 ) } ) +$$ + +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. + +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. + +Table 1 + +
TaskTest accuracy of Target us- ing the source network
Target:CricketBowlingvs.TableTennis Source1: CricketBowling vs.Baseball Pitch Source2: Cricketshot vs.Archery Source3:BasketballDunk vs.Basketball1 0.946 0.61 0.52
+ +
pair of tasksp(Source,Target)
(Source1, Target)0.053
(Source2, Target)0.39
(Source3,Target)0.48
+ +Table 2: Transfer distance of pairs of source and target on UCF101 action recognition. + +![](images/2c241193221490f096d20c1db5bb3ebe4553c3e1b29a5f9a4c43fa4d3551c9e2.jpg) +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. + +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. + +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. + +# 5.2 IMAGE CLASSIFICATION + +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 + +![](images/1df4f1137b5f43be56ef563df21cd603dfe5643d8bffa4d7a5b2e8b91d2fa116.jpg) +Figure 2: Average $\lambda$ in weighted empirical risk minimization for three different pairs of source and target tasks for action recognition. + +Table 3 + +
TaskTest Accuracy of Target using the source network
Target: Clock vs. Ambulance (Clipart) Source1: Clock vs.Ambulance (Sketch) Source2: Clock vs. Crow(Sketch)0.916 0.697
+ +![](images/13e028571da16adec8995d8d638a4e0ce066f5cf2190ce602d12a912311c3bd1.jpg) +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. + +
pair of tasksp(Source, Target)
(Source1, Target)0.083
(Source2, Target)0.3
(Source3, Target)0.35
+ +Table 4: Transfer distance of pairs of source and target on DomainNet image classifications]. + +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. + +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. + +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. + +![](images/7a303c3706559f7a90ce3dfe420c8b7330324be99f6ba51d8e74ec5e3805fcc7.jpg) +Figure 4: Average $\lambda$ in weighted empirical risk minimization for three different pairs of source and target tasks for image classification. + +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. + +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. + +# 6 PROOF OUTLINE + +The main idea of proof is based on the following proposition proved in Tsybakov (2009) + +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: + +$$ +d ( \theta _ { i } , \theta _ { j } ) \geq 2 s > 0 , \ \forall 0 \leq j < k \leq M +$$ + +(ii) $P _ { j } \ll P _ { 0 } , \ \forall \ j = 1 , . . . , M .$ , and + +$$ +\frac { 1 } { M } \sum _ { j = 1 } ^ { M } { \mathcal { D } } _ { k l } ( P _ { j } | P _ { 0 } ) \leq \alpha \log M +$$ + +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 + +$$ +\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 ) +$$ + +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. + +# REFERENCES + +Kamyar Azizzadenesheli, Anqi Liu, Fanny Yang, and Animashree Anandkumar. Regularized learning for domain adaptation under label shifts. In International Conference on Learning Representations, 2018. + +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. + +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. + +John Blitzer, Koby Crammer, Alex Kulesza, Fernando Pereira, and Jennifer Wortman. Learning bounds for domain adaptation. In NIPS, 2007. + +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. + +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. + +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. + +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. + +Steve Hanneke and Samory Kpotufe. On the value of target data in transfer learning. In NeurIPS, 2019. + +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. + +Alireza Karbalayghareh, Xiaoning Qian, and Edward R Dougherty. Optimal bayesian transfer regression. IEEE Signal Processing Letters, 25(11):1655–1659, 2018. + +Alireza Karbalayghareh, Xiaoning Qian, and Edward Russell Dougherty. Optimal bayesian transfer learning for count data. IEEE/ACM transactions on computational biology and bioinformatics, 2019. + +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. + +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. + +Mingsheng Long, Han Zhu, Jianmin Wang, and Michael I Jordan. Unsupervised domain adaptation with residual transfer networks. Advances in Neural Information Processing Systems, 2016. + +Yishay Mansour, Mehryar Mohri, and Afshin Rostamizadeh. Domain adaptation: Learning bounds and algorithms. In 22nd Conference on Learning Theory, COLT 2009, 2009. + +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. + +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. + +Sinno Jialin Pan and Qiang Yang. A survey on transfer learning. IEEE Transactions on knowledge and data engineering, 22(10):1345–1359, 2009. + +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. + +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. + +Alexandre B Tsybakov. Introduction to Nonparametric Estimation. Springer series in statistics. Springer, Dordrecht, 2009. doi: 10.1007/b13794. + +Karl Weiss, Taghi M Khoshgoftaar, and DingDing Wang. A survey of transfer learning. Journal of Big data, 3(1):1–40, 2016. + +# 7 APPENDIX + +# 7.1 PROOF OF THEOREM 1 + +We also use the following famous result in information theory known as Gilbert-Varhsamov’s bound for packing argument. + +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 )$ , + +$$ +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 } , +$$ + +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 } )$ . + +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. + +Lemma 1 Let $0 < \epsilon < 1 / 2$ and $z \in \{ - 1 , 1 \}$ . Then + +$$ +\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 , +$$ + +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 }$ . + +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. + +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: + +$$ +\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} +$$ + +For the conditional distributions: + +$$ +\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} +$$ + +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: + +$$ +\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} +$$ + +For the conditional distributions: + +$$ +\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} +$$ + +Verifying $\rho ( \mathbb { P } _ { w } , \mathbb { Q } _ { w } ) \leq \Delta$ : Bayes classifier of the domain generated by $\mathbb { P } _ { w }$ is as follows: + +$$ +\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} +$$ + +Similarly for the domain generated by $\mathbb { Q } _ { w }$ , we have + +$$ +\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} +$$ + +So $h _ { S } ^ { * }$ and $h _ { T } ^ { * }$ disagree only on ${ \pmb x } _ { - 1 }$ which implies that + +$$ +\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 +$$ + +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 + +$$ +\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 } } +$$ + +when the target domain is generated by $\mathbb { Q } _ { w }$ + +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 + +$$ +\mathcal { E } _ { T } ( h _ { w ^ { \prime } } ) \geq \frac { d } { 8 } \cdot \frac { \epsilon } { 1 0 0 d } = \frac { \epsilon } { 8 0 0 } +$$ + +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 )$ . + +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 + +$$ +\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} +$$ + +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. + +Proof of Theorem 2 is similar to that of Theorem 1. However, we construct different target and source probability distributions. + +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$ . + +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: + +$$ +\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} +$$ + +For the conditional distributions: + +$$ +\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} +$$ + +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: + +$$ +\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} +$$ + +For the conditional distributions: + +$$ +\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} +$$ + +Verifying $\rho ( \mathbb { P } _ { w } ^ { ( i ) } , \mathbb { Q } _ { w } ) \leq \Delta _ { i }$ + +Bayes classifier of the domain generated by $\mathbb { P } _ { w } ^ { ( i ) }$ is as follows: + +$$ +\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} +$$ + +Similarly for the domain generated by $\mathbb { Q } _ { w }$ , we have + +$$ +\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} +$$ + +So $h _ { S _ { i } } ^ { * }$ and $h _ { T } ^ { * }$ disagree on $\pmb { x } _ { - i } , . . , \pmb { x } _ { - N }$ which implies that + +$$ +\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 } +$$ + +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 } }$ . + +The rest of the proof is exactly the same except the part regarding the KL divergence bound. + +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 × + +$$ +\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} +$$ + +for small enough $c _ { 1 }$ we can apply Proposition 1. + +# 7.3 ADDITIONAL EXPERIMENTAL RESULTS + +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. + +![](images/68afa0a6eca3c2060650667d2fbccf678290c955da93e7e8eaee731207bf9f06.jpg) +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$ \ No newline at end of file diff --git a/md/dev/03RLpj-tc_/03RLpj-tc_.md b/md/dev/03RLpj-tc_/03RLpj-tc_.md new file mode 100644 index 0000000000000000000000000000000000000000..c737f99426ca5427d5744a8c6fc71b67ae060a71 --- /dev/null +++ b/md/dev/03RLpj-tc_/03RLpj-tc_.md @@ -0,0 +1,470 @@ +# CRYSTAL DIFFUSION VARIATIONAL AUTOENCODER FOR PERIODIC MATERIAL GENERATION + +Tian Xie∗, Xiang Fu∗, Octavian-Eugen Ganea∗, Regina Barzilay, Tommi Jaakkola + +Computer Science and Artificial Intelligence Laboratory +Massachusetts Institute of Technology +Cambridge, MA 02139, USA +{txie,xiangfu,oct,regina,tommi}@csail.mit.edu + +# ABSTRACT + +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. + +# 1 INTRODUCTION + +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). + +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 + +![](images/f9a16b0c92de6c778ad170e8c78bce773bc7a6fa978abde181eb0a9ecf697006.jpg) +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. + +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. + +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. + +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. + +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: + +• We curate 3 standard datasets from QM simulations and create a set of physically meaningful tasks and metrics for the problem of material generation. +• 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. +• We encode permutation, translation, rotation, and periodic invariances, as well as interactions crossing periodic boundaries with SE(3) equivariant GNNs adapted with periodicity. +• 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. + +# 2 RELATED WORK + +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). + +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. + +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). + +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. + +# 3 PRELIMINARIES + +# 3.1 PERIODIC STRUCTURE OF MATERIALS + +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, + +$$ +\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} +$$ + +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. + +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. + +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. + +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. + +![](images/76a1088a1b2eb4c9f18fb457bb21e8b7032f46cf2c7456e531b05a39e4c96707.jpg) +Figure 2: Overview of the proposed CDVAE approach. + +# 3.2 PROBLEM DEFINITION AND ITS PHYSICAL ORIGIN + +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. + +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. + +# 3.3 DIFFUSION MODELS + +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. + +# 4 PROPOSED METHOD + +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. + +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. + +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. + +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. + +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. + +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 )$ . + +$\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 } ) )$ . + +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. + +The training loss for the decoder $\mathcal { L } _ { \mathrm { D E C } }$ can be written as, + +$$ +\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] , +$$ + +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. + +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. + +# Algorithm 1 Material Generation via Annealed Langevin Dynamics + +1: Input: latent representation $_ { z }$ , type and coordinate noise +levels $\{ \sigma _ { A } \} , ~ \{ \bar { \sigma } _ { X } \}$ , step size $\epsilon$ , number of sampling +steps $T$ +2: Predict aggregated properties $c , L , N$ from $_ { z }$ . +3: Uniformly initialize $X _ { 0 }$ within the unit cell by $\pmb { L }$ . +4: Randomly initialize $\pmb { A } _ { 0 }$ with $^ c$ . +5: for 6: $j 1$ $L$ +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}$ +9: +10: +11: +12: +13: +14: + +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. + +# 5 EXPERIMENTS + +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. + +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. + +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 + +![](images/578fc93f934b4eaf42ba8a5e6f4ba0d08297c97c2bd4b63b3ba7427bffdf402c.jpg) +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. + +Table 1: Reconstruction performance. + +
MethodMatch rate(%)个RMSE↓
Perov-5Carbon-24MP-20Perov-5Carbon-24MP-20
FTCP99.3462.2869.890.02590.25630.1593
Cond-DFC-VAE51.65110.02171
CDVAE97.5255.2245.430.01560.12510.0356
+ +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. + +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. + +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. + +# 5.1 MATERIAL RECONSTRUCTION + +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. + +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. + +![](images/46996ad50747cc42c9777944916f911c171bbc32b70cd77b6a0f3f7c42b47d98.jpg) +Figure 4: Structures sampled from $\mathcal { N } ( 0 , 1 )$ and filtered by the validity test. + +Table 2: Generation performance3. + +
MethodDataValidity (%) 4个COV(%)↑Property Statistics ↓
Struc.Comp.R.PpE# elem.
FTCP5Perov-50.2454.240.000.0010.27156.00.6297
Cond-DFC-VAECarbon-240.080.000.005.20619.05
MP-201.5548.374.720.0923.71160.90.7363
Perov-573.6082.9573.9210.132.2684.1110.8373
Perov-599.9298.790.180.231.6254.7460.03684
Carbon-2499.940.000.000.94271.320
P-G-SchNetMP-2099.6575.9638.3399.573.03442.090.6411
Perov-579.6399.130.370.250.27551.3880.4552
Carbon-2448.390.000.001.533134.7
MP-2077.5176.4041.9399.744.042.4480.6234
CDVAEPerov-5100.098.5999.4598.460.12580.02640.0628
Carbon-24100.099.8083.080.14070.2850
MP-20100.086.7099.1599.490.68750.27781.432
+ +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. + +# 5.2 MATERIAL GENERATION + +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. + +Table 3: Property optimization performance. + +
MethodPerov-5Carbon-24MP-20
SR5SR10SR15SR5SR10SR15SR5SR10SR15
FTCP0.060.110.160.00.00.00.020.040.05
Cond-DFC-VAE0.550.640.6911111
CDVAE0.520.650.790.00.060.060.780.860.90
+ +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. + +# 5.3 PROPERTY OPTIMIZATION + +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. + +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. + +# 6 CONCLUSIONS AND OUTLOOK + +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. + +# REPRODUCIBILITY STATEMENT + +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. + +# ACKNOWLEDGMENTS + +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. + +# REFERENCES + +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 + +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 + +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 + +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 + +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 + +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 + +Chi Chen and Shyue Ping Ong. A universal graph deep learning interatomic potential for the periodic table. arXiv preprint arXiv:2202.02450, 2022. 3 + +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 + +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 + +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 + +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 + +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 + +Prafulla Dhariwal and Alex Nichol. Diffusion models beat gans on image synthesis. arXiv preprint arXiv:2105.05233, 2021. 4 + +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 + +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 + +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 + +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 + +Colin W Glass, Artem R Oganov, and Nikolaus Hansen. Uspex—evolutionary crystal structure prediction. Computer physics communications, 175(11-12):713–720, 2006. 2 + +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 + +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 + +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 + +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 + +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 + +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 + +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 + +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 + +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 + +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 + +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 + +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 + +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 + +Johannes Klicpera, Florian Becker, and Stephan Gunnemann. Gemnet: Universal directional graph ¨ neural networks for molecules. arXiv preprint arXiv:2106.08903, 2021. 2, 15 + +Zhifeng Kong and Wei Ping. On fast sampling of diffusion probabilistic models. arXiv preprint arXiv:2106.00132, 2021. 17 + +Meng Liu, Keqiang Yan, Bora Oztekin, and Shuiwang Ji. Graphebm: Molecular graph generation with energy-based models. arXiv preprint arXiv:2102.00546, 2021. 3 + +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 + +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 + +Youzhi Luo, Keqiang Yan, and Shuiwang Ji. Graphdf: A discrete flow model for molecular graph generation. arXiv preprint arXiv:2102.01189, 2021. 3 + +Alexander Quinn Nichol and Prafulla Dhariwal. Improved denoising diffusion probabilistic models. In International Conference on Machine Learning, pp. 8162–8171. PMLR, 2021. 17 + +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 + +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 + +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 + +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 + +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 + +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 + +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 + +Chris J Pickard and RJ Needs. High-pressure phases of silane. Physical review letters, 97(4):045504, 2006. 16 + +Chris J Pickard and RJ Needs. Ab initio random structure searching. Journal of Physics: Condensed Matter, 23(5):053201, 2011. 2, 16 + +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 + +Tim Salimans and Jonathan Ho. Progressive distillation for fast sampling of diffusion models. arXiv preprint arXiv:2202.00512, 2022. 17 + +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 + +Yoshihide Sawada, Koji Morikawa, and Mikiya Fujii. Study of deep generative models for inorganic chemical compositions. arXiv preprint arXiv:1910.11499, 2019. 3 + +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 + +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 + +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 + +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 + +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 + +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 + +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 + +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 + +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 + +Alexander Frank Wells et al. Three dimensional nets and polyhedra. Wiley, 1977. 3 + +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 + +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 + +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 + +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 + +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 + +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 + +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 + +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 + +# A PROOF FOR THE CONNECTION TO A HARMONIC FORCE FIELD + +We assume the loss in Equation 2 can be minimized to zero when the noises are small, meaning that + +$$ +s _ { X } ( \tilde { A } , \tilde { X } , L | z ) = \frac { d _ { \operatorname* { m i n } } ( X , \tilde { X } ) } { \sigma _ { X , j } } , \forall j > J , +$$ + +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. + +The force term in the Langevin dynamics $\alpha _ { j } { \pmb s } _ { { \pmb X } , t }$ can then be written as + +$$ +\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} +$$ + +If we write $\epsilon / \sigma _ { X , L } ^ { 2 } = k$ , then, + +$$ +\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 +$$ + +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, + +$$ +\alpha _ { j } s _ { X } ( \tilde { A } , \tilde { X } , { \cal L } | z ; \sigma _ { A , j } , \sigma _ { X , j } ) = - k ( \tilde { X } - X ) , \forall j > J . +$$ + +# B IMPLEMENTATION DETAILS + +# B.1 PREDICTION OF LATTICE PARAMETERS + +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. + +# B.2 MULTI-GRAPH CONSTRUCTION + +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. + +# B.3 GNN ARCHITECTURE + +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. + +# C DATASET CURATION + +# C.1 PEROV-5 + +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). + +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. + +# C.2 CARBON-24 + +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 }$ . + +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. + +# C.3 MP-20 + +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. + +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. + +# D EXPERIMENT DETAILS + +# D.1 REASONS FOR THE UNSUITABILITY OF SOME METRICS FOR SPECIFIC DATASETS + +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. + +Materials in Perov-5 have the same structure, so it is not meaningful to require higher structure diversity. + +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. + +# D.2 COMPOSITION VALIDITY CHECKER + +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. + +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. + +# D.3 NON-GAUSSIAN STATISTICAL STRUCTURE OF MATERIALS + +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. + +# D.4 HYPERPARAMETERS AND TRAINING DETAILS + +The total loss can be written as, + +$$ +{ \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 } } . +$$ + +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$ . + +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$ . + +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$ . + +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. + +During the generation, we use $\epsilon = 0 . 0 0 0 1$ and run Langevin dynamics for 100 steps at each noise level. + +# E VISUALIZATION OF MULTIPLE RECONSTRUCTED STRUCTURES + +![](images/014198feed124d83196e3770da4948847d47fbbe02a6692b9c0aeb6b4b8e0a13.jpg) +Figure 5: Different reconstructed structures from CDVAE from the same $_ { z }$ , following 3 Langevin dynamics sampling with different random seeds. + +# F SAMPLING SPEED FOR MATERIAL GENERATION + +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). + +Table 4: Time used for generating 10,000 materials on a single RTX 2080 Ti GPU. + +
FTCPCond-DFC-VAEG-SchNetP-G-SchNetCDVAE
Perov-5<1min0.5h2.0h2.0h3.1 h
Carbon-24<1min16.2 h6.3h5.3 h
MP-20<1min16.3 h6.3h5.8h
+ +# G COVERAGE METRICS FOR MATERIAL GENERATION + +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 ] }$ . + +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. + +Following the established classification metrics of Precision and Recall, we define the coverage metrics as: + +$$ +\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} +$$ + +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)). + +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. + +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. + +Table 5: Full coverage metrics for the generation task. + +
MethodDataCOV-R↑AMSD-R↓AMCD-R↓COV-P↑AMSD-P↓AMCD-P↓
FTCPPerov-50.000.74477.2120.000.35823.390
Carbon-240.001.1810.000.000.882224.16
MP-204.720.65429.2710.090.19544.378
Cond-DFC-VAEPerov-573.920.15082.77310.130.31624.257
G-SchNetPerov-50.180.59621.0060.230.42591.3163
Carbon-240.000.58870.000.000.59700.00
MP-2038.330.53653.23399.570.20263.601
Perov-50.370.55101.02640.250.39671.316
CDVAECarbon-240.000.63080.000.000.81660.00
MP-2041.930.53273.27499.740.19853.567
Perov-599.450.04820.696998.460.05931.272
Carbon-2499.800.04890.0083.080.13430.00
MP-2099.150.15493.62199.490.18834.014
+ +![](images/df4a9ab8291867bf7d43b05e7e5021163cda44e434b159383cce5c820edc7a42.jpg) +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. + +![](images/3565eef4857703cd54d2fbd09011c227cb6f03ede855b110cc9ce720c5b6f647.jpg) +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. + +![](images/c2b820bf4f97c03bb50f377af925aea32bca53720d95774535f0d070c0d563f2.jpg) +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. \ No newline at end of file diff --git a/md/dev/1YEF6TA8Di/1YEF6TA8Di.md b/md/dev/1YEF6TA8Di/1YEF6TA8Di.md new file mode 100644 index 0000000000000000000000000000000000000000..af370815d1ae54d0140d688f096e0e914a4fe54a --- /dev/null +++ b/md/dev/1YEF6TA8Di/1YEF6TA8Di.md @@ -0,0 +1,475 @@ +# Langevin Quasi-Monte Carlo + +Sifan Liu Department of Statistics Stanford University Stanford, CA 94305 sfliu@stanford.edu + +# Abstract + +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. + +# 1 Introduction + +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). + +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. + +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. + +![](images/bea1dbc0489080cb7836fa89b3f143e12237f65da9d81a18d220019f9c986b24.jpg) +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). + +These quasi-random numbers are carefully designed to sample from the target distribution more evenly and more balanced, leading to improved estimation accuracy. + +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. + +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. + +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. + +# 2 Backgrounds + +This section provides some background on Langevin Monte Carlo and quasi-Monte Carlo. + +# 2.1 Langevin Monte Carlo + +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 + +$$ +\mathrm { d } \theta ( t ) = - \nabla U ( \theta ( t ) ) \mathrm { d } t + \sqrt { 2 } \mathrm { d } W _ { t } , +$$ + +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 + +$$ +\theta _ { k + 1 } \theta _ { k } - h \nabla U ( \theta _ { k } ) + \sqrt { 2 h } \xi _ { k + 1 } +$$ + +where $\xi _ { k } \overset { i i d } { \sim } \mathcal { N } ( 0 , I _ { d } )$ + +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 + +$$ +{ \hat { \mu } } _ { n } = { \frac { 1 } { n } } \sum _ { k = 1 } ^ { n } f ( \theta _ { k } ) , +$$ + +where $n$ is the number of iterations. + +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. + +# 2.2 Quasi-Monte Carlo + +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 + +$$ +{ \hat { \mu } } = { \frac { 1 } { n } } \sum _ { i = 1 } ^ { n } f ( \mathbf { u } _ { i } ) . +$$ + +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 + +$$ +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 . +$$ + +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 + +$$ +| \hat { \mu } - \mu | \leq D _ { n } ^ { * } \cdot \| f \| _ { \mathrm { H K } } \leq O ( n ^ { - 1 } ( \log n ) ^ { d - 1 } ) . +$$ + +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. + +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). + +# 2.3 Related work + +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. + +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). + +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. + +# 3 QMC for LMC + +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. + +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. + +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. + +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$ . + +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. + +# 3.1 LQMC algorithm + +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) + +$$ +\mathbf { u } _ { k } \mathbf { u } _ { k } + \Delta \mod 1 , +$$ + +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 + +$$ +\theta _ { k + 1 } = \theta _ { k } - h \nabla U ( \theta _ { k } ) + \sqrt { 2 h } \cdot \Phi ^ { - 1 } ( \mathbf { u } _ { k + 1 } ) , \quad k \geq 0 . +$$ + +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. + +# 3.2 Construction of CUD sequences + +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. + +The binary Galois LFSR (Tausworthe generator, Tausworthe (1965)) of order $m$ updates the states $b _ { i } \in \{ 0 , 1 \}$ recursively by + +$$ +b _ { i } = \sum _ { j = 0 } ^ { m - 1 } a _ { j } b _ { i - m + j } \mod 2 , \quad i \geq m +$$ + +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 + +$$ +x ^ { m } + a _ { m - 1 } x ^ { m - 1 } + \ldots + a _ { 1 } x + a _ { 0 } +$$ + +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 + +$$ +v _ { i } = \sum _ { j = 0 } ^ { m - 1 } b _ { s i + j } 2 ^ { - j - 1 } , \quad i = 0 , 1 , \ldots , 2 ^ { m } - 2 . +$$ + +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. + +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 + +$$ +\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) . +$$ + +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. + +# Algorithm 1 Langevin quasi-Monte Carlo (LQMC) + +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 +Output: $\theta _ { 1 } , \ldots , \theta _ { n }$ + +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. + +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. + +# 4 Theoretical guarantee + +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. + +Assumption 1. The potential function $U$ is $L$ -smooth + +$$ +\| \nabla U ( \theta ) - \nabla U ( \theta ^ { \prime } ) \| _ { 2 } \le L \| \theta - \theta ^ { \prime } \| _ { 2 } , \quad \forall \theta , \theta ^ { \prime } , +$$ + +and $M$ -strongly convex + +$$ +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 } . +$$ + +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. + +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. + +$$ +\| \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 } . +$$ + +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 + +$$ +\theta _ { k } = \psi _ { \ell } ( \theta _ { k - \ell } , \mathbf { w } _ { k } ^ { ( \ell ) } ) +$$ + +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. + +$$ +\bar { f } _ { \ell } ( \mathbf { w } _ { k } ^ { ( \ell ) } ) = \int f \circ \psi _ { \ell } ( x , \mathbf { w } _ { k } ^ { ( \ell ) } ) \pi ( \mathrm { d } x ) . +$$ + +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. + +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 + +$$ +\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 . +$$ + +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]$ + +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. + +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. + +# 5 Numerical experiments + +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. + +![](images/711d95f81584702ce987bb3b555e889589fcac7e1ae0f7fa9aa7d395db72c8fa.jpg) +Figure 2: Bayesian logistic regression with accurate gradients (top) and stochastic gradients (bottom). + +# 5.1 Bayesian logistic regression + +We first consider the Bayesian logistic model + +$$ +\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} +$$ + +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. + +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. + +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. + +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. + +# 5.2 Bayesian linear regression + +Now we try a higher-dimensional example with Bayesian linear regression. The model is defined as + +$$ +\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} +$$ + +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. + +![](images/bbfcb350aef010496d700422f157e1fb65400bdfea5ca9ef459b33cbb7646348.jpg) +Figure 3: Bayesian linear regression in 100 dimensions. + +![](images/8d6b00ad90b084168d4d46cfd574ad385bcee892df89ec67464f8e036835017e.jpg) +Figure 4: Crossed random effect. + +# 5.3 A hierarchical Bayesian model + +We consider a hierarchical Bayesian model known as the crossed random effect model + +$$ +\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} +$$ + +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. + +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. + +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$ . + +![](images/044ec0893d8ac106377d731757837a9257b8c1e1fc339530b893fe2cdfbbd550.jpg) +Figure 5: Double well potential. + +# 5.4 Nonconvex potential + +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. + +# Acknowledgments and Disclosure of Funding + +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. + +# References + +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. +Baker, J., Fearnhead, P., Fox, E. B., and Nemeth, C. (2019). Control variates for stochastic gradient MCMC. Statistics and Computing, 29:599–615. +Basu, K. and Owen, A. B. (2016). Transformations and Hardy–Krause variation. SIAM Journal on Numerical Analysis, 54(3):1946–1966. +Brosse, N., Durmus, A., and Moulines, E. (2018). The promises and pitfalls of stochastic gradient Langevin dynamics. Advances in Neural Information Processing Systems, 31. +Buchholz, A., Wenzel, F., and Mandt, S. (2018). Quasi-Monte Carlo variational inference. In International Conference on Machine Learning, pages 668–677. PMLR. +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. +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. +Chen, S. (2011). Consistency and convergence rate of Markov chain quasi Monte Carlo with examples. PhD thesis, Stanford University. +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. +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. +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. +Cranley, R. and Patterson, T. N. (1976). Randomization of number theoretic methods for multiple integration. SIAM Journal on Numerical Analysis, 13(6):904–914. +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. +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. +Dick, J. and Feischl, M. (2021). A quasi-monte carlo data compression algorithm for machine learning. Journal of Complexity, 67:101587. +Dick, J. and Pillichshammer, F. (2010). Digital Sequences, Discrepancy and Quasi-Monte Carlo Integration. Cambridge University Press, Cambridge. +Dick, J. and Rudolf, D. (2014). Discrepancy estimates for variance bounding Markov chain quasiMonte Carlo. Electron. J. Probab, 19(105):1–24. +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. +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. +Erdogdu, M. A., Mackey, L., and Shamir, O. (2018). Global non-convex optimization with discretized diffusions. Advances in Neural Information Processing Systems, 31. +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. +Hofmann, N. and Mathé, P. (1997). On quasi-Monte Carlo simulation of stochastic differential equations. Mathematics of computation, 66(218):573–589. +Korobov, N. (1948). On functions with uniformly distributed fractional parts. In Dokl. Akad. Nauk SSSR, volume 62, pages 21–22. +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. +Levin, M. B. (1999). Discrepancy estimates of completely uniformly distributed and pseudorandom number sequences. International Mathematics Research Notices, 1999(22):1231–1251. +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. +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. +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. +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. +Markovic, J. and Taylor, J. (2016). Bootstrap inference after using multiple queries for model selection. arXiv preprint arXiv:1612.07811. +Niederreiter, H. (1987). Point sets and sequences with small discrepancy. Monatshefte für Mathematik, 104:273–337. +Niederreiter, H. (1992). Random Number Generation and Quasi-Monte Carlo Methods. SIAM. +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. +Owen, A. B. (1997a). Monte Carlo variance of scrambled net quadrature. SIAM Journal of Numerical Analysis, 34(5):1884–1910. +Owen, A. B. (1997b). Scrambled net variance for integrals of smooth functions. Annals of Statistics, 25(4):1541–1562. +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. +Pagès, G. and Panloup, F. (2018). Weighted multilevel langevin simulation of invariant measures. Annals of Applied Probability, 28(6):3358–3417. +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. +Roberts, G. O. and Tweedie, R. L. (1996). Exponential convergence of Langevin distributions and their discrete approximations. Bernoulli, pages 341–363. +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. +Shi, J., Liu, C., and Mackey, L. (2022). Sampling with mirrored stein operators. In International Conference on Learning Representations. +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. +Tausworthe, R. C. (1965). Random numbers generated by linear recurrence modulo two. Mathematics of Computation, 19(90):201–209. +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. +Tribble, S. D. (2007). Markov chain Monte Carlo algorithms using completely uniformly distributed driving sequences. PhD thesis, Citeseer. +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. +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. +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. + +# A Proofs + +# A.1 Proof of Theorem 4.1 + +We start by decomposing the error $\textstyle { \frac { 1 } { n } } \sum _ { k = 1 } ^ { n } f ( \theta _ { k } ) - \pi ( f ) |$ into three parts + +$$ +\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} +$$ + +We first upper bound $( I )$ . + +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 + +$$ +\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 } . +$$ + +Proof of Lemma $^ { l }$ . Note that + +$$ +\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} +$$ + +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 + +$$ +\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 } ) . +$$ + +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 + +$$ +\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} +$$ + +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. + +To bound $( I I ) ^ { \prime }$ , we use the following result. + +Lemma 2 (Upper bound on discretization error $( I I ) ^ { \prime } $ ). Under Assumption $I$ , we have for $f$ 1- Lipschitz, + +$$ +| \pi ( f ) - \pi P _ { \ell } ( f ) | \leq \frac { 3 \sqrt { 2 } } { 2 } \frac { L } { M } h ^ { 1 / 2 } d . +$$ + +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 + +$$ +\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 } +$$ + +and + +$$ +\theta _ { k + 1 } = \theta _ { k } - h \nabla U ( \theta _ { k } ) + \sqrt { 2 h } \xi _ { k + 1 } . +$$ + +Combing the previous two equations gives + +$$ +\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 . +$$ + +Let $\Delta _ { k } = \theta ( t _ { k } ) - \theta _ { k }$ . The last display reads + +$$ +\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 . +$$ + +By the contracting property (6) in the main paper, + +$$ +\begin{array} { r } { \| \Delta _ { k } - h [ \nabla U ( \theta _ { k } + \Delta _ { k } ) - \nabla U ( \theta _ { k } ) ] \| \le \rho \| \Delta _ { k } \| . } \end{array} +$$ + +Taking expectation and use $L$ -smoothness of $U$ , we have + +$$ +\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 . +$$ + +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, + +$$ +\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} +$$ + +Note that + +$$ +\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 } } . +$$ + +Thus, + +$$ +\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} +$$ + +Denote $\begin{array} { r } { r = \frac { 3 \sqrt { 2 } } { 2 } L h ^ { 3 / 2 } d . } \end{array}$ . So + +$$ +\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} +$$ + +Therefore, for any $k \geq 1$ , + +$$ +\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} +$$ + +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. + +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 + +$$ +O ( n ^ { - 1 } ( \log n ) ^ { d + 1 } \log \log n ) +$$ + +with an implied constant depending only on $d$ and the average is taken over all primitive polynomials over $G F ( 2 )$ of degree $m$ . + +Proof of Theorem 4.1. The error on the left-hand-side is bounded by + +$$ +( I ) + ( I I ) ^ { \prime } + ( I I ) ^ { \prime \prime } + \frac { 4 \ell } { n } \| f \| _ { \infty } . +$$ + +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 }$ . + +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 } }$ . + +Therefore, the upper bound becomes + +$$ +( 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 } . +$$ + +# B Additional numerical results + +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. + +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. + +
DatasetsParkinsonsBikeProtein
N (number of instances)58751737945730
p (number of features)21129
+ +Table 1: Summary of datasets used for Bayesian posterior prediction. + +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. + +![](images/f6acd57f6cfbd7761952326b942ddaeef1cc2dc6b22870c352cfb01ab6a1d5e7.jpg) +Figure 6: Test error versus number of iterations for the three UCI datasets. \ No newline at end of file diff --git a/md/dev/1qvx610Cu7/1qvx610Cu7.md b/md/dev/1qvx610Cu7/1qvx610Cu7.md new file mode 100644 index 0000000000000000000000000000000000000000..87bd6c38e7f09ea1c5adf3cd67be007a15ab95d8 --- /dev/null +++ b/md/dev/1qvx610Cu7/1qvx610Cu7.md @@ -0,0 +1,217 @@ +# Is Your Code Generated by ChatGPT Really Correct? Rigorous Evaluation of Large Language Models for Code Generation + +Jiawei Liu ∗ Chunqiu Steven Xia ∗ Yuyao Wang Lingming Zhang + +University of Illinois Urbana-Champaign Nanjing University + +{jiawei6, chunqiu2, lingming}@illinois.edu yuyao6@outlook.com + +# Abstract + +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. + +# 1 Introduction + +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]. + +![](images/3123815fc6ee764f610b9ae26921911c0080b9bf9a5fda7fb8f6bb0ec472825d.jpg) +Figure 1: Exemplary wrong code synthesized by ChatGPT for HUMANEVAL #58. + +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: + +• 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. + +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? + +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. + +![](images/db8c3d3ffdb7024ce0d9bfd7ea7adb89d8b708b14a9e41e575743b2eb90d60f0.jpg) +Figure 2: Overview of EvalPlus + +Contribution. Our work revisited and proposed to automatically improve code benchmarks for LLMs: + +• 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. + +• 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. + +• 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. + +# 2 Approach + +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. + +Table 1: List of basic type-aware mutations over input $x$ . + +
TypeMutationTypeMutation
int|floatReturns x±1ListRemove/repeat a random item x[i] Insert/replace x[i] with Mutate(x[i])
boolReturns a random booleanTupleReturns Tuple(Mutate(List(x)))
NoneTypeReturns NoneSetReturns Set(Mutate(List(x)))
strRemove a sub-string s Repeat a sub-string s Replace s with Mutate(s)DictRemove a key-value pair k→ U Update k -→v to k-→Mutate(u) Insert Mutate(k)→Mutate(u)
+ +# 2.1 Automated Test Input Generation + +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. + +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. + +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. + +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. + +# 2.2 Test-Suite Reduction + +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: + +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. + +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. + +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. + +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. + +# 2.3 Program Input Contracts + +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. + +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. + +Table 2: Overview of EvalPlus-improved benchmarks. + +
#Tests#Tasks
Avg.MediumMin.Max.
HUMANEVAL9.67.01105²164
HUMANEVAL+764.1982.5121,100
HUMANEVAL+ -MINI16.113.05110
+ +# 3 Evaluation + +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. + +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. + +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. + +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. + +
Size pass@kk=1*k=1k=10k=100TT0T100
GPT-4 [49]N/Abase +extra88.4 76.2
Phind-CodeLlama [52]34Bbase71.371.690.596.22.8.8
WizardCoder-CodeLlama [38]34B+extra base67.1 73.267.0 61.685.0 85.292.5 94.52.8 .8.8 .8
N/A+extra base64.6 73.2 69.454.578.6 88.688.9 94.0.8.8
ChatGPT [48]34B+extra63.4 51.862.5 52.082.191.1.2.8.8
CODELLAMA [54]13Bbase +extra42.7 43.182.495.0.2.8.8
base42.7 44.673.7 77.689.4.4.8.8
+extra36.6 37.469.492.7 88.2.4.8.8
7Bbase37.839.2 69.189.7.2.8.8
StarCoder [13]15B+extra base34.1 34.134.5 32.261.4 56.782.9 84.2.2 .2.8.8 .8
16B+extra base29.3 32.927.8 32.2 56.050.375.4 81.5.2 .2.8 .6.8 .8
CodeGen [46]6B +extra26.8 29.327.2 48.471.4 .2.2.6 .6.8 .8
base +extra27.7 25.646.972.7.2.6.8
base23.6 18.441.064.6.2.8.8
CODET5+ [64]2B+extra24.4 20.715.139.8 34.866.8 55.8.22.8
16Bbase +extra31.7 26.232.2 27.458.5 51.183.52.6 .6.8 .8
MISTRAL [26]7Bbase +extra28.7 23.828.155.276.4 83.82.8 .8
CodeGen2 [45]16B4base19.523.748.576.4
+extra16.5
7Bbase +extra18.317.9 30.950.92.2.2.2..6 .6.8 .8
3Bbase16.5 15.915.9 15.227.1 23.945.4 38.6.4.8
1B +extra12.812.9 21.234.3.2.4 .6.8 .6
base11.010.2 15.124.7.2.6.6
+extra9.1 8.713.721.2.2.8.8
VICUNA [12]13Bbase +extra16.5 15.215.3 13.930.1 25.854.8.2.8.8
base11.610.923.846.7 42.3.2 .2.6.6
SantaCoder [2]7B+extra11.010.320.335.0.4.6 .6.6 .8
1.1Bbase +extra14.6 12.816.6 14.229.245.4 40.6.4.6.8
15.926.2 27.745.0.2.4.6
INCODER [18]6.7Bbase12.215.6.2.6.6
+extra base12.212.4 10.022.2 15.938.9 25.2.2 .2.6.6
1.3B+extra10.4 7.913.520.7.6.4
GPT-J[63]6Bbase12.211.317.731.8.2 .2.6.6
+extra10.49.5 15.225.9.6.6
GPT-NE0 [5]2.7Bbase7.96.511.820.7.2 .2.6 .6.6 .6
+extra6.76.09.016.8 17.1.6
base6.15.9 10.22.4.6 .6
PolyCoder [70] StableLM[60]2.7B 7B+extra base5.5 2.45.3 2.77.9 7.513.6 15.8.2 .2.6 .6
+ +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). + +
SizeCoverageKilled mutantsKilled samplesFullRef. pass@1*
pass@1*#testspass@1*#testspass@1*#testspass@1*#testsbase+extra
GPT-4N/A86.011.382.911.478.713.878.016.188.476.2
ChatGPTN/A71.311.369.511.465.213.765.216.073.263.4
StarCoder15B32.911.332.911.429.313.629.315.934.129.3
CodeGen2B23.211.323.811.421.313.221.315.424.420.7
6B28.711.329.311.425.613.225.615.429.325.6
16B31.711.331.111.427.413.227.415.432.926.8
CodeGen21B10.411.311.011.49.113.89.116.011.09.1
3B15.911.315.911.412.813.812.816.015.912.8
7B18.311.318.311.416.513.816.516.018.316.5
16B19.511.318.911.416.513.816.516.019.516.5
VICUNA7B11.611.311.611.411.013.811.016.111.610.4
13B16.511.316.511.415.213.815.216.117.115.2
SantaCoder1.1B14.611.314.611.412.813.812.816.114.612.8
1.3B12.211.312.211.410.413.610.416.012.210.4
INCODER GPT-J6.7B14.611.314.611.412.213.612.216.015.912.2
6B12.211.312.211.410.413.810.416.012.210.4
GPT-NEO2.7B7.311.37.311.46.713.86.716.17.96.7
PolyCoder2.7B6.111.36.111.45.513.85.516.16.15.5
StableLM7B2.411.32.411.42.413.82.416.12.42.4
+ +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. + +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. + +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. + +![](images/8957033a3d75d416829c6f5be232a3f78cb93a579c8114a591c0782819eac96d.jpg) +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. + +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. + +![](images/343bed10bdc118b6c4dec60fa0c9e6e3926d4db9f0838f1b97fa215f9f8ee865.jpg) +Figure 4: Exemplary incorrect-logic ground-truth solution in HUMANEVAL (#124) + +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. + +# 4 Related Work + +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. + +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. + +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. + +# 5 Conclusion & Future Work + +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. + +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]). + +# 6 Acknowledgements + +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. + +References +[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. +[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. +[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. +[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. +[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. +[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. +[7] T. A. Budd. Mutation analysis of program test data. Yale University, 1980. +[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. +[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. +[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. +[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. +[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. +[13] B. Code. Starcoder. https://github.com/bigcode-project/starcoder, 2023. +[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. +[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. +[16] fauxpilot. Fauxpilot: an open-source alternative to github copilot server. https: //github.com/fauxpilot/fauxpilot, 2022. +[17] U. Feige. A threshold of ln n for approximating set cover. Journal of the ACM (JACM), 45(4):634–652, 1998. +[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. +[19] C. Green. Application of theorem proving to problem solving. In Readings in Artificial Intelligence, pages 202–222. Elsevier, 1981. +[20] S. Gulwani. Automating string processing in spreadsheets using input-output examples. SIGPLAN Not., 46(1):317–330, jan 2011. +[21] S. Gulwani, O. Polozov, and R. Singh. Program synthesis. Foundations and Trends® in Programming Languages, 4(1-2):1–119, 2017. +[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. +[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. +[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. +[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. +[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. +[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. +[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. +[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. +[30] J. C. King. Symbolic execution and program testing. Communications of the ACM, 19(7):385–394, 1976. +[31] M.-A. Lachaux, B. Roziere, L. Chanussot, and G. Lample. Unsupervised translation of programming languages. arXiv preprint arXiv:2006.03511, 2020. +[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. +[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. +[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. +[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. +[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. +[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. +[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. +[39] Z. Manna and R. J. Waldinger. Toward automatic program synthesis. Communications of the ACM, 14(3):151–165, 1971. +[40] W. M. McKeeman. Differential testing for software. Digital Technical Journal, 10(1):100–107, 1998. +[41] B. Meyer. Applying’design by contract’. Computer, 25(10):40–51, 1992. +[42] Microsoft. GitHub Copilot – Your AI pair programmer. https://github.com/features/ copilot, 2023. +[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. +[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. +[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. +[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. +[47] P. Oehlert. Violating assumptions with fuzzing. IEEE Security & Privacy, 3(2):58–62, 2005. +[48] OpenAI. Chatgpt: Optimizing language models for dialogue. https://openai.com/blog/ chatgpt/, 2022. +[49] OpenAI. Gpt-4 technical report. ArXiv, abs/2303.08774, 2023. +[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. +[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. +[52] Phind. Phind/phind-codellama-34b-v2 $\cdot$ hugging face. https://huggingface.co/Phind/ Phind-CodeLlama-34B-v2, 2023. +[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. +[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. +[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. +[56] M. Security. jsfunfuzz. https://github.com/MozillaSecurity/funfuzz, 2007. +[57] K. Serebryany. Continuous fuzzing with libfuzzer and addresssanitizer. In 2016 IEEE Cybersecurity Development (SecDev), pages 157–157. IEEE, 2016. +[58] D. E. Shaw, W. R. Swartout, and C. C. Green. Inferring lisp programs from examples. In IJCAI, volume 75, pages 260–267, 1975. +[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. +[60] Stability-AI. Stablelm: Stability ai language models. https://github.com/Stability-AI/ StableLM, 2023. +[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. +[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. +[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. +[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. +[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. +[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. +[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. +[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. +[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. +[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. +[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. +[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. +[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. +[74] M. Zalewski. American fuzzing lop (afl). https://lcamtuf.coredump.cx/afl/, 2018. +[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. +[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. + +Table 5: Overview of evaluated models. + +
Model NameSizesRelease YearOpen-Source
Cuipoo2B,6B,16B2022 2022<
CodeGen [46] INCODER [18]1.3B, 6.7B
PolyCoder [70]2.7B2022
SantaCoder [2]1.1B 2023
CodeGen2 [45]1B,3B,7B,16B2023
StarCoder[13]15B 2023
CODET5+ [64]16B 2023
CODELLAMA [54]7B,13B,34B 2023
WizardCoder-CodeLlama [38]2023
34B Phind-CodeLlama [52] 34B2023
GPT-J [63] Geeeeer StableLM [60]6B2021
GPT-NEO [5]2.7B 2021
ChatGPT[48]2022
GPT-4 [49]N/A N/A
VICUNA [12]2023 2023
7B,13B 7B2023
MISTRAL [26]2023
+ +# A Detailed Experimental Setup + +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. + +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. + +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. \ No newline at end of file diff --git a/md/dev/3KWnuT-R1bh/3KWnuT-R1bh.md b/md/dev/3KWnuT-R1bh/3KWnuT-R1bh.md new file mode 100644 index 0000000000000000000000000000000000000000..c2a84577d46098ab5ac279036439c20ecd9cb6d3 --- /dev/null +++ b/md/dev/3KWnuT-R1bh/3KWnuT-R1bh.md @@ -0,0 +1,419 @@ +# CONDITIONAL POSITIONAL ENCODINGS FOR VISION TRANSFORMERS + +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 + +# ABSTRACT + +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. + +# 1 INTRODUCTION + +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. + +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. + +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. + +![](images/0c4b2513e8c89ba2d4113b63f9bdb7b99d31471e828098a2ee34f19b9c920289.jpg) +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. + +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. + +• 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. + +• 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). + +• 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. + +# 2 RELATED WORK + +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. + +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. + +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. + +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. + +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. + +# 3 VISION TRANSFORMER WITH CONDITIONAL POSITION ENCODINGS + +# 3.1 MOTIVATION + +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. + +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 \%$ . + +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 \%$ ). + +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 + +
ModelEncodingTop-1@224(%)Top-1@384(%)
DeiT-tiny (Touvron et al., 2020)X68.268.6
DeiT-tiny (Touvron et al., 2020)learnable72.271.2
DeiT-tiny (Touvron et al., 2020)sin-cos72.370.8
DeiT-tiny2D RPE (Shaw et al., 2018)70.569.8
+ +# 3.2 CONDITIONAL POSITIONAL ENCODINGS + +We argue that a successful positional encoding for vision tasks should meet these requirements, + +(1) Making the input sequence permutation-variant and providing stronger explicit bias towards translation-equivariance. +(2) Being inductive and able to handle the sequences longer than the ones during training. +(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). + +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. + +Therefore, we propose positional encoding generators (PEG) to dynamically produce the positional encodings conditioned on the local neighborhood of an input token. + +Positional Encoding Generator. PEG is illustrated in Figure 2. To condition on the local neighbors, we first + +![](images/e12ed07e330e1cbad3fc807996e87af006eec2275384ddc7e13bc09ba9a2aac7.jpg) +Figure 2. Schematic illustration of Positional Encoding Generator (PEG). Note $d$ is the embedding size, $N$ is the number of tokens. + +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. + +# 3.3 CONDITIONAL POSITIONAL ENCODING VISION TRANSFORMERS + +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 + +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. + +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. + +# 4 EXPERIMENTS + +# 4.1 SETUP + +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). + +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. + +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. + +# 4.2 GENERALIZATION TO HIGHER RESOLUTIONS + +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. + +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 + +
ModelParams160(%)224(%)384(%)448(%)512(%)
DeiT-tinyDeiT-tiny (sin)DeiT-tiny (no pos)CPVT-TiCPVT-Ti ‡6M6M6M6M6M65.665.262.166.8(+1.2)67.7 (+2.1)72.272.368.272.4(+0.2)73.4(+1.2)71.270.868.673.2(+2.0)74.2(+3.0)68.868.268.471.8(+3.0)72.6(+3.8)65.965.165.070.3(+4.4)70.8(+4.9)
DeiT-smallCPVT-S22M22M75.676.1(+0.5)79.979.978.180.4(+1.5)75.978.6(+2.7)72.676.8(+4.2)
DeiT-baseCPVT-B86M86M79.180.5(+1.4)81.881.9(+0.1)79.782.3(+2.6)79.882.4(+2.6)78.281.0(+2.8)
+ +‡: Insert one PEG each after the first encoder till the fifth encoder + +# 4.3 CPVT WITH GLOBAL AVERAGE POOLING + +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. + +Table 3. Performance comparison of Class Token (CLT) and global average pooling (GAP) on ImageNet. CPVT’s can be further boosted with GAP + +
ModelHeadParamsTop-1 Acc(%)Top-5 Acc(%)
DeiT-tiny (Touvron et al., 2020)DeiT-tinyCPVT-Ti tCPVT-Ti tCLTGAPCLTGAP6M6M6M6M72.272.673.474.991.091.291.892.6
DeiT-small (Touvron et al.,2020)DeiT-smallCPVT-S ‡CPVT-S tCLTGAP22M22M23M79.980.280.595.095.295.295.7
CLT
GAP23M81.5
+ +‡: Insert one PEG each after the first encoder till the fifth encoder + +# 4.4 COMPLEXITY OF PEG + +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. + +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. + +# 4.5 PERFORMANCE COMPARISON + +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. + +![](images/c53aeceb62b3945f870e2289f3bd7dc81107062bd6e3b4e704ad90e2320543d6.jpg) +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. + +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 + +
ModelsParams(M) InputInput|throughput*ImNettop-1 %Realtop-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)2545602122421226.176.282.5
224222422242753.6526.41156.7753.677.483.7
78.380.084.186.4
5891219522422694.377.183.5
240²1662.51255.7732.179.184.9
260²300280.181.685.986.8
3802349.482.988.0
ViT-B/16 (Dosovitskiy et al., 2021)ViT-L/1686307384285.927.377.976.511
3842
DeiT-tiny w/o PE (Touvron et al., 2020)DeiT-tiny (Touvron et al.,2020)DeiT-tiny (sine)CPVT-Ti tCPVT-Ti-GAP‡66666224222422242224²22422536.52536.52536.52500.72520.168.272.272.373.474.9180.180.381.382.5
DeiT-tiny (Touvron et al., 2020)CPVT-Tim66224222422536.52500.774.575.982.183.0
DeiT-small (Touvron et al., 2020)CPVT-S $CPVT-S-GAP‡22232322422242224²940.4930.5942.379.980.585.786.086.6
81.5
DeiT-base (Touvron et al.,2020)CPVT-B ‡CPVT-B-GAP‡862242292.381.886.7
888822422242285.5290.282.387.087.7
82.7
+ +?: 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. + +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 \%$ . + +# 4.6 PEG ON PYRAMID TRANSFORMER ARCHITECTURES + +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. + +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. + +# 5 ABLATION STUDY + +# 5.1 POSITIONAL ENCODING OR MERELY A HYBRID? + +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. + +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 + +Table 5. Positional encoding rather than added parameters gives the most improvement + +
KernelStyleParams (M)Top-1 Acc (%)
none 35.6868.2
3fixed (random init)5.6871.3
1(12 ×)fixed (learned init)5.6872.3
learnable6.1368.6
3learnable5.6872.4
+ +learnable parameters than PEG. However, it only boosts the performance by $0 . 4 \%$ to $6 8 . 6 \%$ + +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 \% )$ . + +# 5.2 PEG POSITION IN CPVT + +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]. + +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. + +Table 6. Comparison of different plugin positions (left) and kernels (right) using DeiT-tiny + +
PosIdxTop-1 (%)Top-5 (%)
none -168.288.7
0 370.690.2
72.491.2
72.391.1
71.790.8
6 1069.089.1
+ +
PosIdxkernelParamsTop-1 (%)Top-5 (%)
-13×35.7M70.690.2
-127×275.8M72.591.3
+ +# 5.3 COMPARISONS WITH OTHER POSITIONAL ENCODINGS + +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. + +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. + +Table 7. Comparison of various positional encoding strategies. LE: learnable positional encoding. RPE: relative positional encoding + +
ModelPEG PosEncodingTop-1 (%)Top-5 (%)
DeiT-tiny (2020)LE72.2 72.391.0 91.0
DeiT-tiny DeiT-tiny2D sin-cos 2DRPE70.590.0
CPVT-Ti= 0-1PEG72.491.2
CPVT-Ti0-1PEG+LE72.991.4
CPVT-Ti0-14×PEG+LE72.9
0-591.4
CPVT-TiPEG73.491.8
+ +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. + +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. + +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. + +
ModelPositionalParams160(%)224(%)384(%)448(%)512(%)
DeiT-tiny (LE+RPE)DeiT-tiny (PEG at Pos 0)40011192065.666.872.472.470.873.268.471.865.670.3
+ +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. + +# 6 CONCLUSION + +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. + +# REFERENCES + +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. + +Irwan Bello. Lambdanetworks: Modeling long-range interactions without attention. In International Conference on Learning Representations, 2021. URL https://openreview.net/forum? id=xTJEN-ggl1b. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +Jean-Baptiste Cordonnier, Andreas Loukas, and Martin Jaggi. On the relationship between selfattention and convolutional layers. In International Conference on Learning Representations, 2020. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +Pengcheng He, Xiaodong Liu, Jianfeng Gao, and Weizhu Chen. Deberta: Decoding-enhanced bert with disentangled attention. arXiv preprint arXiv:2006.03654, 2020. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +Abdelrahman Mohamed, Dmytro Okhonko, and Luke Zettlemoyer. Transformers with convolutional context for asr. arXiv preprint arXiv:1904.11660, 2019. + +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. + +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. + +Alec Radford, Karthik Narasimhan, Tim Salimans, and Ilya Sutskever. Improving language understanding by generative pre-training. 2018. + +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. + +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. + +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. + +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. + +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. + +Jianlin Su, Yu Lu, Shengfeng Pan, Bo Wen, and Yunfeng Liu. Roformer: Enhanced transformer with rotary position embedding. arXiv preprint arXiv:2104.09864, 2021. + +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. + +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. + +Mingxing Tan and Quoc Le. Efficientnet: Rethinking model scaling for convolutional neural networks. In International Conference on Machine Learning, pp. 6105–6114. PMLR, 2019. + +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. + +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. + +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. + +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. + +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. + +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. + +Baosong Yang, Longyue Wang, Derek Wong, Lidia S Chao, and Zhaopeng Tu. Convolutional selfattention networks. arXiv preprint arXiv:1904.03107, 2019a. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +# A TRANSLATION EQUIVARIANCE + +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. + +# B EXPERIMENT DETAILS + +# B.1 ARCHITECTURE VARIANTS OF CPVT + +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 + +
Model#channels#heads#layers#params
CPVT-Ti1923126M
CPVT-S38461222M
CPVT-B768121286M
+ +# B.2 THE HYPERPARAMETERS OF CPVT + +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. + +Table 10. Hyper-parameters for ViT, DeiT and CPVT + +
MethodsViTDeiTCPVT
Epochs Batch size300 4096300 1024300 1024
OptimizerAdamWAdamWLAMB
Learning rate decaycosinecosinecosine
Weight decay0.30.050.05
Warmup epochs3.455
Label smoothing ε (Szegedy et al., 2016)X0.1 X0.1
Dropout (Srivastava et al.,2014)0.1X
Stoch.Depth (Huang et al., 2016)X0.1 √0.1
Repeated Aug (Hoffer et al., 2020)XX
Gradient Clip.9/0.5X
Rand Augment (Cubuk et al., 2020)X9/0.5
Mixup prob. (Zhang et al.,2018)X0.80.8
Cutmix prob. (Yun et al., 2019)X1.01.0
Erasing prob. (Zhong et al.,2020)X0.250.25
+ +# B.3 IMPORTANCE OF ZERO PADDINGS + +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. + +Table 11. Ablation study on ImageNet performance w/ or w/o zero paddings + +
ModelPaddingTop-1 Acc(%)Top-5 Acc(%)
CPVT-Ti72.491.2
X70.589.8
+ +# B.4 SINGLE PEG VS. MULTIPLE PEGS + +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). + +Table 12. CPVT’s sensitivity to number of plugin positions + +
PositionsModelParams (M)Top-1 Acc (%)Top-5 Acc (%)
0-1tiny5.772.491.2
0-5tiny5.973.491.8
0-11tiny6.173.491.8
0-1 0-5small small22.0 22.979.9 80.595.0 95.2
+ +# B.5 CLASSFICATION EVALUATION OF SWIN WITH PEG + +We show the validation curves when training Swin (Liu et al., 2021) equipped with PEG in Figure 4. +It can boost Swin-tiny from $8 1 . 1 0 \%$ to $8 2 . 2 5 \%$ $( + 1 . 1 5 \% \uparrow )$ on ImageNet. + +![](images/37115738de8c41b823e0aa8bb65e1c60638e6d07fe274cb734b5b2f7bcc4fd09.jpg) +Figure 4. CPE boosts Swin Tiny on ImageNet by $1 . 1 5 \%$ top-1 Acc. + +# B.6 EVALUATION ON SEGMENTATION AND DETECTION + +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. + +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. + +Table 13. Our method boosts the performance of PVT on ImageNet classification, ADE20K segmentation and COCO detection + +
BackboneImageNetSemantic FPN on ADE20KRetinaNet on COCO
Params (M)Top-1 (%)Params (M)mIoU (%)Params (M)mAP (%,1x)mAP (%,3×,+MS)
ResNet-18 (He et al.,2016)1269.81632.92131.835.4
PVT-tiny (Wang et al., 2021)1375.01735.72336.739.4
PVT-tiny+PEG1377.31738.02338.041.8
PVT-tiny+GAP1375.91736.02336.939.7
PVT-tiny+PEG+GAP1378.11738.82338.741.8
PVT-small (Wang et al., 2021)2579.82839.83440.442.2
PVT-small+PEG+GAP2581.22844.33443.045.2
PVT-Medium (Wang et al.,2021)4481.24841.65441.943.2
PVT-Medium+PEG+GAP4482.74844.95444.346.4
+ +# B.7 ABLATION ON OTHER FORMS OF PEG + +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. + +Table 14. Other forms of PEG. The simple form of a single depth-wise $3 \times 3$ is good enough. + +
VariantsModelTop-1 Acc (%)
1 Depthwise Conv 3×3tiny72.4
1 Depthwise Conv 7×7tiny72.5
4 *(Depthwise Conv 3×3+BN+ReLU)tiny72.4
1 Dense Conv 3×3tiny72.3
4 * (Dense Conv 3×3+BN+ReLU)tiny72.5
+ +# C EXAMPLE CODE + +# C.1 PEG + +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. + +# D MORE DISCUSSIONS + +# D.1 WHY RPE WORKS LESS WELL THAN ABSOLUTE PE? + +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. + +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. + +# Algorithm 1 PyTorch snippet of PEG. + +import torch +import torch.nn as nn +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] +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 + +# D.2 COMPARISON TO LAMBDA NETWORKS + +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. + +# D.3 QUALITATIVE ANALYSIS OF CPVT + +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. + +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). + +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. + +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. + +![](images/19c1477edf28cf26db81ecd53fd8947ea0edbe4a9868e6368aab289ef778d7ce.jpg) +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. + +![](images/0a11531d79480ac414e128993ffaedb8cbf0d456688b90d3ed26f02be66c7b97.jpg) +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). + +# D.4 COMPARISON WITH OTHER APPROACHES + +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. + +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. + +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. + +
ModelTypeParamsFLOPsTop-1 Acc(%)
DeiT-small (Touvron et al., 2020)ConViT-S (d'Ascoli et al.,2021)CPVT-S-GAP (ours)PlainPlainPlain22M27M23M4.6G5.4G4.6G79.981.381.5
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+GAPPyramidPyramidPyramidPyramidPyramidPyramid25M20M25M25M29M4.2G4.5G3.8G3.8G4.5G81.681.679.881.281.382.3
29M4.5G
+ +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. + +
ModelParamsInsert PositionTop-1 Acc (%)
CPVT-Ti DeiT+ Convolutional Projection5681320 56853520 072.4 70.6
\ No newline at end of file diff --git a/md/dev/3ly9cG9Ql9h/3ly9cG9Ql9h.md b/md/dev/3ly9cG9Ql9h/3ly9cG9Ql9h.md new file mode 100644 index 0000000000000000000000000000000000000000..838722b13e8b3f02c0bbeb614602acd74ed0c85b --- /dev/null +++ b/md/dev/3ly9cG9Ql9h/3ly9cG9Ql9h.md @@ -0,0 +1,899 @@ +# WHAT DOES A PLATYPUS LOOK LIKE? GENERATING CUSTOMIZED PROMPTS FOR ZERO-SHOT IMAGE CLASSIFICATION + +Anonymous authors Paper under double-blind review + +# ABSTRACT + +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. + +![](images/207af72be1be806a825dfae0cb16b9568232e896028ef4212770a11f27d035ec.jpg) +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. + +# 1 INTRODUCTION + +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. + +However, this new paradigm poses a challenge: + +How can we best represent an image category through natural language prompts? + +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). + +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)). + +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). + +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. + +# 2 METHODS + +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. + +# 2.1 GENERATING CUSTOMIZED PROMPTS + +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”. + +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. + +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. + +![](images/94599b7e4d40c35d0489d8e2ef6be722491d18fe350b748d1afd73f9e7bb8418.jpg) +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. + +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. + +# 2.2 UTILIZING CUSTOMIZED PROMPTS + +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. + +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. + +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. + +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: + +Describe what a/the looks like: Describe a/the : What are the identifying characteristics of a/the ? + +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. + +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. + +# 3 EXPERIMENTS AND RESULTS + +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. + +# 3.1 SETUP + +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). + +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), + +![](images/c244cd77f35daae89804f631443e697dbdef5cbf87a124bd967b690b5c34a523.jpg) +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. + +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. + +
eee0ssrr rlrts163308[oPooIFraielelrod prirtCErreaelBir SiemiIGDECEIIErregisg0PPSSSSSCIPAIII1CEIAAIIIOTrrsppgweeauanbrun
std #hw75.5455.20 877.53 869.31 293.08 132.88 293.33 193.24 3478.53 177.45 4860.07 2871.10 1895.59 1878.26 1850.43 1|73.43268|175
CuPL (base)8058.9076.4972.7493.3336.6993.3793.4578.8377.7460.2468.9695.8178.4751.11|74.15
△std76.19 +0.65+3.70-1.04+3.43+0.25+3.81+0.04+0.21+0.30+0.29+0.17-2.14+0.22+0.21+0.63
#hw333333333333333453
CuPL (full)76.6961.7077.6373.3193.36 36.1193.8193.4579.6778.3660.6371.6995.8478.5751.1174.80
△std+1.15+6.50+0.10+4.00+0.28+3.23+0.48+0.21+1.14+0.91+0.56+0.59+0.25+0.31+0.635945
#hw569332232545343
+ +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). + +# 3.2 RESULTS + +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. + +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. + +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. + +# 3.3 ANALYSIS AND ABLATIONS + +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. + +![](images/351179f81d6228fdb143732fd2a363036bdcae430a3f38c626aa3176dbb472d7.jpg) +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. + +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 + +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. + +![](images/51232e3355f62f445d6fb060f714a79c2fe5dac53a8b65db8ea8f54267fa9bf1.jpg) +Figure 5: Effect of LLM temperature. More prompt diversity leads to higher performance. + +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. + +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. + +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). + +![](images/dc357d96ea3b897f119d11c1086b962a15b2a4e985b1ac6d6b76091f7014871e.jpg) +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. + +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. + +Table 2: ImageNet Top-1 accuracy for different methods of generating imageprompts. + +
StandardCuPLWordNetWiki
75.5476.6973.4468.20
+ +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. + +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 \%$ ). + +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) + +
eeee TeirierrPPd PpiritGrleaarBi eiEGUUIIIIErrresiso0PPSSSSSSCIATII1CEIPAIIIOTrrsppgnaea
Ensemble76.5161.6077.6673.5193.4236.4793.7193.8779.7378.1661.5073.0395.8879.3351.0975.03
△std+0.97+6.40+0.13+4.20+0.34+3.59+0.38+0.63+1.20+0.71+1.43+1.93+0.29+1.07+0.66
△ CuPL-0.18-0.1+0.03+0.20+0.06+0.36-0.10+0.42+0.06+0.20+0.87+1.34+0.04+0.76-0.02
+ +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). + +# 4 RELATED WORK + +# 4.1 NATURAL LANGUAGE DESCRIPTIONS FOR IMAGE CLASSIFICATION + +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. + +# 4.2 GENERATED TEXT FOR DOWNSTREAM TASKS + +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. + +![](images/3105f1cca8a0d1b0fcc9c992507a786dc459f1f78af82d59265bf760d6a1b731.jpg) +per class accuracy difference of CuPL vs Standard image-prompts +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.) + +# 4.3 PROMPT ENGINEERING + +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). + +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. + +# 5 CONCLUSION + +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. + +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. + +# 6 REPRODUCIBILITY + +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). + +# REFERENCES + +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. + +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. + +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. + +Lukas Bossard, Matthieu Guillaumin, and Luc Van Gool. Food-101 – mining discriminative components with random forests. In European Conference on Computer Vision, 2014. + +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. + +Sebastian Bujwid and Josephine Sullivan. Large-scale zero-shot image classification from rich and diverse textual descriptions. ArXiv, abs/2103.09669, 2021a. + +Sebastian Bujwid and Josephine Sullivan. Large-scale zero-shot image classification from rich and diverse textual descriptions. arXiv preprint arXiv:2103.09669, 2021b. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +Tianyu Gao, Adam Fisch, and Danqi Chen. Making pre-trained language models better few-shot learners. arXiv preprint arXiv:2012.15723, 2020. + +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. + +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. + +Siteng Huang, Min Zhang, Yachen Kang, and Donglin Wang. Attributes-guided and pure-visual attention alignment for few-shot recognition. In AAAI, 2021. + +Tony Huang, Jack Chu, and Fangyun Wei. Unsupervised prompt learning for vision-language models. arXiv preprint arXiv:2204.03649, 2022. + +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. + +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. + +Takeshi Kojima, Shixiang Shane Gu, Machel Reid, Yutaka Matsuo, and Yusuke Iwasawa. Large language models are zero-shot reasoners. ArXiv, abs/2205.11916, 2022. + +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. + +Alex Krizhevsky, Geoffrey Hinton, et al. Learning multiple layers of features from tiny images. 2009. + +Brian Lester, Rami Al-Rfou, and Noah Constant. The power of scale for parameter-efficient prompt tuning. ArXiv, abs/2104.08691, 2021. + +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. + +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. + +S. Maji, J. Kannala, E. Rahtu, M. Blaschko, and A. Vedaldi. Fine-grained visual classification of aircraft. Technical report, 2013. + +George A Miller. Wordnet: a lexical database for english. Communications of the ACM, 38(11): 39–41, 1995. + +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. + +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. + +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. + +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. + +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. + +Guanghui Qin and Jas’ Eisner. Learning how to ask: Querying lms with mixtures of soft prompts. ArXiv, abs/2104.06599, 2021. + +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. + +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. + +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. + +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. + +Ohad Rubin, Jonathan Herzig, and Jonathan Berant. Learning to retrieve prompts for in-context learning. In NAACL, 2022. + +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. + +Timo Schick and Hinrich Schutze. Exploiting cloze-questions for few-shot text classification and ¨ natural language inference. In EACL, 2021. + +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. + +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. + +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. + +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. + +Laurens Van der Maaten and Geoffrey Hinton. Visualizing data using t-sne. Journal of machine learning research, 9(11), 2008. + +Ben Wang and Aran Komatsuzaki. Gpt-j-6b: A 6 billion parameter autoregressive language model, 2021. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +APPENDIX: What does a platypus look like? Generating customized prompts for zero-shot image classification + +OVERVIEW + +A. CuPL (Full Prompts) vs Standard Prompts +B. CuPL Base Prompts +C. Evaluation Metric +D. Open-Source LLM +E. Single Sentence Baseline +F. Robustness +G. CuPL Improvement Analysis +H. Error Analysis +I. Image-Prompt Distribution +J. Tempurature Analysis +K. Example Generated image-prompts + +A CUPL (FULL PROMPTS) VS STANDARD PROMPTS + +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. + +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”). + +
Caltech101
CuPL hand-writtenStandard hand-written
Describe what a(n) {} looks like: Describe a(n) {}: What are the identifying characteristics of a(n) {}?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 {}.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 {}.
+ +
Food101
CuPL hand-writtenStandard hand-written
Describe what {} looks likeVisually describe {}How can you tell that the food in this photo is {}?a photo of {},a type of food.
+ +# Stanford Cars + +
CuPL hand-writtenStandard hand-written
+ +
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) {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 {}.
+ +
Oxford Pets
CuPL hand-writtenStandard hand-writen
Describe what a pet {} looks likeVisually describe a(n)‘{}',a type of pet.a photo of a , a type of pet.
+ +# + +
ImageNet
CuPL hand-writtenStandard hand-written
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) {}: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 {}.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 {}.
+ +
FGVC Aircraft
CuPL hand-writtenStandard hand-written
Describe a(n) {}aircraftDescribe the{}aircrafta photo of a {},a type of aircraft.a photo of the {,a type of aircraft.
+ +
DTD
CuPL hand-writtenStandard hand-written
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?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.
+ +
SUN397
CuPL hand-writtenStandard hand-written
Describe what a(n) {}looks likeHow can you identify a(n) {}?Describe a photo of a(n) {}a photo of a {}.a photo of the {}.
+ +# Kinetics-700 + +Describe the action ”{}” What does a person $\{ \}$ look like? What does the act of $\{ \}$ look like? Describe ”{}” + +
UCT101CuPL hand-writtenDescribe the action of {}What does the act of {} look like?What does a person doing {} look like?Describe“}"Describe the action “{}"UCT101
CuPL hand-writtenStandard hand-written
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 {.
+ +
RESISC 45
CuPL hand-writtenStandard hand-written
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) {}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 {}.
+ +
Birdsnap CuPL hand-writen
Describe what the bird {} looks like: a photo of a {},a type of bird. Describe the bird {}:
What are the identifying characteristics of the bird {}?
Flowers 102 CuPL hand-writtenStandard hand-written
Describe how to identify a(n) {},a type of flower What does a(n) { flower look like?a photo of a {},a type of flower."
CIFAR-10 CuPL hand-writtenStandard hand-written
Describe what a(n) {} looks like Describe a(n) {}: What are the identifying characteristics of a(n) {}?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 {}.
CIFAR-100
CuPL hand-writtenStandard hand-written
Describe a photo of a(n) {:What are the identifying characteristics of a(n) {}?Describe what a(n) {} looks like:Describe a(n) {}: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 {.
+ +# B CUPL BASE PROMPTS + +The three general sentences used in the base prompt setting are: + +Describe what a/the looks like: Describe a/the : What are the identifying characteristics of a/the ? + +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’): + +
DatasetBase LLM-prompt type specification
ImageNeta(n) {}
DTDthe texture {}
StanfordCars SUN397the car {}
Food 101a(n)0
the food {
FGVC Aircraftthe aircraft {}
Oxford Petsa pet
Caltech101a(n){
CIFAR-10a(n)
CIFAR-100a(n)
Flowers 102the flower {}
Kinetics-700
the action of {}
UCF101the action of {}
RESISC45a satellite photo of {}
Birdsnapthe bird {}
+ +# C EVALUATION METRIC + +
1eegeeDLIsrsrr prlrersL30300ToopoonFAVTileersod porrtCrreeaerTirsionISUUUIIITrrreeisieonPPSSSSSCIPAIII1CIIPPPPI0Prrspg
+ +
Acc.|Acc.Acc.Acc.Acc.Acc.MeanperclassMeanperclassMeanperclassMeanperclassAcc.Mean(top1,top5)Acc.Acc.Acc.Acc.
+ +# D OPEN-SOURCE LLM + +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. + +Table 4: CuPL with an open-source model. CuPL is able to improve over hand-written baselines even for smaller open-source models. + +
ImageNet
standard75.54
CuPL(GPT-J-6B)75.62
CuPL (GPT-3)76.69
+ +# E SINGLE SENTENCE BASELINE + +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. + +
ImageNet
a photo of a{73.46
CuPL(1 hand-written)75.71
CuPL (1 generated)74.24
+ +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. + +# F ROBUSTNESS + +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. + +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. + +
ImageNet(Deng et al., 2009)ImageNet-V2(Recht et al., 2019)ImageNet-Sketch(Wang et al., 2019)
Standard75.5469.8659.60
CuPL76.6970.8560.05
+ +# G CUPL IMPROVEMENT ANALYSIS + +# G.1 VISUAL SIMILARITY ANALYSIS + +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. + +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. + +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. + +# G.2 CO-OCCURRENCES BETWEEN OBJECTS + +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. + +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 + +# Image Embedding vs CuPL improvement + +![](images/a7df4c5d1fadec3e954f095e0a30de9ec48244c47ceb9633e46e7db060ce85a2.jpg) +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. + +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. + +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. + +
One class present (85.1% of ims)Multiple classes present (14.9% of ims)
Standard79.8951.59
CuPL80.7953.58
+ +# H ERROR ANALYSIS + +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. + +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. + +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. + +![](images/474bd93d7d1cb89c6d066da6d8426ed282d9fffb3d39648a95712ea72a19b243.jpg) +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. + +![](images/09c49d31d88d74d0ab0121cdb7742d5d17e3fb0ce1da41f588c9a2bd52fd4e5c.jpg) +TSNE of text embeddings of Image-prompts generated by different LLM-prompts +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. + +# I IMAGE-PROMPT DISTRIBUTION + +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. + +# J TEMPERATURE ANALYSIS + +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. + +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. + +![](images/0a4a77925f37cfa3fa317cb1c6b2610abbe2c1378129efb22ba9ed7728f489c0.jpg) +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. + +# K EXAMPLE GENERATED IMAGE-PROMPTS + +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. + +# K.1 ALL GENERATED IMAGE-PROMPTS FOR “TENCH” CATEGORY + +# Temperature $\mathbf { \mu = 0 . 9 9 }$ + +"A tench is a freshwater fish of the carp family.", +"A tench is a freshwater fish that is typically brown or olive in +color.", +"A tench is a fresh water fish that can grow up to 2 feet in length.", +"A tench is a freshwater fish of the family Cyprinidae.", +"A tench is a freshwater fish of the carp family.", +"A tench is a freshwater fish with a dark green back and light-colored +sides.", +"Tench are a freshwater fish found in Europe.", +"A tench is a small freshwater fish in the carp family.", +"A tench is a heavyset freshwater fish with a mottled brown body and a +small, flat head.", +"A tench is a freshwater fish that looks similar to a carp.", +"A tench is a freshwater fish in the carp family.", +"A tench is a freshwater fish of the Cyprinidae family.", +"The tench is a freshwater fish of the Cyprinidae family.", +"The tench is a fresh-water fish in the family Cyprinidae.", +"The easiest way to identify a tench is by its herringbone-patterned +scales.", +"A tench is a freshwater fish of the carp family.", +"Tench are a freshwater fish found in Europe.", +"Tench have a large, slimy body with scales that have a green hue.", +"The tench is a freshwater fish belonging to the carp family.", +"A tench is a freshwater fish of the Cynoglossidae family.", +"A tench is a freshwater fish in the carp family.", +"Tensch are freshwater fish with Olive Green backs, shading to Yellowish +on the sides.", +"A tench looks like a green freshwater fish with a brownish hue.", +"A tench looks like a freshwater fish with a dark olive-green back, +fading to yellowish-brown on the sides.", +"A tench usually has olive-green skin with dark spots, and a +orange-yellow underbelly.", +"Tench are a freshwater fish that can grow up to $7 0 \mathrm { c m }$ long! They have +olive-brown skin with dark spots, and their meat is white and firm.", +"A tench is a freshwater fish with a sturdy body and a greenish-brown +coloration.", +"A tench is a freshwater fish that can grow up to about two feet long.", +"A tench is a freshwater fish in the carp family.", +"A tench is a large, freshwater fish with a thick body and large head.", +"The image is of a tench fish swimming in water.", +"The image is of a tench fish swimming in a pond.", +"The tench is a freshwater fish native to Europe.", +"This image shows a large, dark green tench swimming in a pond.", +"An image of a tench from the internet would likely show a dark green +fish with a lighter underside.", +"The image is of a tench fish.", +"The image is of a tench fish on a white background.", +"A tench is a freshwater fish of the Cyprinidae family.", +"The image is of a tench swimming in a murky pond.", +"In the image, a tench swims in a pond with lily pads.", +" A tench in a river.", +"A tench (Tinca tinca) is a freshwater fish in the carp family that is +found throughout Europe.", +" Tench (Tinca tinca), a member of the carp family (Cyprinidae), native +to Eurasia.", +" A tench, a freshwater fish in the family Cyprinidae.", +" The tench (Tinca tinca) is a freshwater fish of the cyprinid family +found throughout Eurasia.", +" A tench in a Finnish lake.", +"A tench (Tinca tinca) is a freshwater fish belonging to the carp family +(Cyprinidae).", +"A tench in a fishpond.", +" The common tench is a freshwater fish of the cyprinid family found +throughout Eurasia.", +"Tench (Tinca tinca) in a pond." + +# Temperature $\mathbf { \tau } = \mathbf { 0 . 5 }$ + +"A tench is a freshwater fish that is typically greenish-brown in color with a brassy sheen.", + +"A tench is a freshwater fish that typically has a dark green back, light brown sides, and a white belly.", + +"A tench is a freshwater fish that can grow up to two feet long.", "Tench are a freshwater fish found in Europe.", + +"A tench is a freshwater fish that is typically olive green in color with +dark spots.", +"A tench is a freshwater fish that is typically olive green in color with +a brownish tint.", +"A tench is a freshwater fish of the Cyprinidae family.", +"Tench are a freshwater fish found in Europe.", +"A tench is a freshwater fish that has a dark green back, light brown +sides, and a white belly.", +"A tench is a freshwater fish that is typically olive-green in color with +a brownish dorsal fin.", +"A tench is a freshwater fish of the cyprinid family.", +"A tench is a freshwater fish of the carp family.", +"A tench is a freshwater fish that is typically olive green in color with +a brownish back.", +"The tench is a freshwater fish of the carp family Cyprinidae.", +"A tench is a freshwater fish that is typically greenish-brown in +color.", +"A tench is a freshwater fish of the carp family.", +"A tench is a freshwater fish of the carp family.", +"Tench have olive green backs and flanks, with yellowish bellies.", +"A tench is a freshwater fish of the carp family.", +"A tench is a freshwater fish of the cyprinid family.", +"A tench is a freshwater fish that can grow up to 30 inches long.", +"A tench is a freshwater fish that is typically greenish-brown in +color.", +"A tench is a freshwater fish that can grow up to about two feet long.", +"A tench is a freshwater fish with a brownish-green back and sides, and a +yellowish-brown belly.", +"A tench is a freshwater fish that can grow up to two feet long.", +"A tench is a freshwater fish that looks similar to a carp.", +"A tench is a freshwater fish that is typically greenish-brown in +color.", +"A tench is a freshwater fish that is part of the carp family.", +"A tench is a freshwater fish of the cyprinid family.", +"A tench is a freshwater fish that can grow up to two feet long.", +"The image is of a tench fish swimming in water.", +"The image is of a tench fish swimming in a pond.", +"The image is of a tench fish swimming in a pond.", +"The image is of a tench fish swimming in a pond.", +"The image is of a tench fish swimming in a pond.", +"In the image, a tench is swimming in a pond with lily pads.", +"The image is of a tench fish swimming in a pond.", +"The image is of a tench fish swimming in a pond.", +"The image is of a tench fish swimming in a pond.", +"The image is of a tench fish swimming in a pond.", +"A tench fish, native to Europe, characterized by its greenish-brown +color and spots.", +" A tench (Tinca tinca) in a pond.", +"A tench (Tinca tinca) is a freshwater fish belonging to the carp family +(Cyprinidae).", +"A tench (Tinca tinca) is a freshwater fish in the carp family.", +"A tench (Tinca tinca) is a freshwater fish in the carp family +(Cyprinidae).", +" A tench in a river.", +"A tench (Tinca tinca) is a freshwater fish in the carp family +(Cyprinidae).", +"A tench (Tinca tinca) in a pond.", +" A tench (Tinca tinca) in a garden pond.", +" A tench in a river." + +# Temperature $\mathbf { \mu } = \mathbf { 0 . 1 }$ + +"A tench is a freshwater fish that is typically olive green in color with dark spots.", + +"A tench is a freshwater fish that can grow up to 30 inches long.", +"A tench is a freshwater fish that can grow to a length of over two +feet.", +"A tench is a freshwater fish that can grow up to two feet long.", +"A tench is a freshwater fish that can grow up to two feet long.", +"A tench is a freshwater fish that is typically olive green in color with +dark spots.", +"A tench is a freshwater fish that can grow up to two feet long.", +"A tench is a freshwater fish that can grow up to two feet long.", +"A tench is a freshwater fish that can grow up to two feet long.", +"A tench is a freshwater fish that is typically olive green in color with +dark spots.", +"A tench is a freshwater fish of the carp family.", +"A tench is a freshwater fish of the carp family.", +"A tench is a freshwater fish of the carp family.", +"A tench is a freshwater fish of the carp family.", +"A tench is a freshwater fish of the carp family.", +"A tench is a freshwater fish of the carp family.", +"Tench have a dark green back, light olive sides, and a yellowish +belly.", +"A tench is a freshwater fish of the carp family.", +"A tench is a freshwater fish of the carp family.", +"A tench is a freshwater fish of the carp family.", +"A tench is a freshwater fish that can grow up to two feet long.", +"A tench is a freshwater fish that can grow up to two feet long.", +"A tench is a freshwater fish that can grow up to two feet long.", +"A tench is a freshwater fish that can grow up to two feet long.", +"A tench is a freshwater fish that is typically olive green in color with +a brownish dorsal side.", +"A tench is a freshwater fish that can grow up to two feet long.", +"A tench is a freshwater fish that can grow up to two feet long.", +"A tench is a freshwater fish that is typically olive green in color with +a brownish dorsal side.", +"A tench is a freshwater fish that can grow up to two feet long.", +"A tench is a freshwater fish that can grow up to two feet long.", +"The image is of a tench fish swimming in a pond.", +"The image is of a tench fish swimming in a pond.", +"The image is of a tench fish swimming in a pond.", +"The image is of a tench fish swimming in a pond.", +"The image is of a tench fish swimming in a pond.", +"The image is of a tench fish swimming in a pond.", +"The image is of a tench fish swimming in a pond.", +"The image is of a tench fish swimming in a pond.", +"The image is of a tench fish swimming in a pond.", +"The image is of a tench fish swimming in a pond.", +"A tench (Tinca tinca) is a freshwater fish in the carp family.", +"A tench (Tinca tinca) is a freshwater fish of the carp family +(Cyprinidae).", +"A tench (Tinca tinca) is a freshwater fish in the carp family.", +"A tench (Tinca tinca) is a freshwater fish in the carp family.", +"A tench (Tinca tinca) is a freshwater fish in the carp family.", +"A tench (Tinca tinca) is a freshwater fish in the carp family.", +"A tench (Tinca tinca) is a freshwater fish in the carp family.", +" A tench (Tinca tinca) in a garden pond.", +" A tench (Tinca tinca) in a garden pond.", +"A tench (Tinca tinca) is a freshwater fish of the carp family +(Cyprinidae)." + +# K.2 SAMPLE GENERATED IMAGE-PROMPTS FOR RANDOMLY SELECTED IMAGENET CATEGORIES + +"bubble": + +"A bubble is a sustained period of inflated asset prices.", + +"A bubble looks like a sphere of air.", +"A bubble is often characterized by rapidly increasing prices in an asset +or security, followed by a sharp decrease in prices.", +"A bubble looks like a small, round, thin film of soap filled with air.", +"A bubble looks like a round sphere of soap film.", +" \"A bubble being blown in the park.", +"A close-up of a soap bubble with a thin film of water in between two +layers of air.", +"A bubble is a spherical shape made up of a thin film of soap water.", +"A bubble is a circle of air surrounded by water.", +"A bubble looks like a round, thin layer of soap surrounding a pocket of +air." + +# "kit fox": + +"A kit fox is a small species of fox, about the size of a domestic cat.", +"You can identify a kit fox by its small size, its big ears, and its +long, bushy tail.", +" A kit fox laying on the ground in a desert habitat.", +"A kit fox is a small fox found in North America.", +"A kit fox is a small fox with a sleek coat of fur.", +"A kit fox is a small fox with large ears, a long, black-tipped tail, and +pale fur.", +"A kit fox has a reddish coat, with white patches on its chest and +throat.", +"This kit fox has a reddish coat and large ears.", +"A kit fox looks like a small fox with a pointed nose, large ears, and a +long, bushy tail.", +"A kit fox is a small species of fox." +"toy terrier": +"A toy terrier looks like a very small version of a terrier.", +"The image is of a toy terrier that is mostly white with brown spots.", +"You can identify a toy terrier by looking for a compact, short-legged +dog with a short muzzle.", +" Cute little guy.", +"Toy terriers are miniature versions of terriers, such as the Jack +Russell Terrier.", +"A toy terrier is a small, lightweight breed of dog.", +"The image is of a small, brown toy terrier.", +"A toy terrier typically has a long, narrow head with pointy ears, and a +small, compact body.", +"A toy terrier is a small, short-legged dog with a long body, pointy +nose, and large ears.", +"A small, brown and white toy terrier is sitting on a beige couch, +looking at the camera." + +"mousetrap": + +"In the image, there is a mousetrap made of wood and metal.", +"An image of a mousetrap from the internet would most likely show a +traditional wooden mousetrap with a metal spring.", +"A mousetrap is a device made to catch and kill mice.", +"A mousetrap is a small device that is used to catch mice.", +"The classic mousetrap consists of a wooden base with a metal spring +mounted on one end.", +"The mousetrap is a small wooden box with a metal spring inside.", +"The mousetrap is a simple device that has been used for centuries to +catch mice.", +"The classic mousetrap - simple, effective, and deadly.", +"The most common way to identify a mousetrap is by its small size and +rectangular shape.", +"A mousetrap typically has a wire or wooden frame that is baited with +food and springs open quickly to snap shut on the mouse when it attempts +to steal the bait." +"A dog sled is a vehicle on runners, typically with a thin frame and +a flat bottom, that is used to convey goods or passengers over snow or +ice.", +"A dog sled is a toboggan pulled by dogs, typically over snow.", +"A dog sled looks like a bed on runners that is pulled by dogs.", +"A dog sled is typically a heavy frame on runners that is pulled by one +or more dogs.", +"A dog sled is traditionally a sled pulled by dogs, used for +transportation, racing, or other purposes.", +" teamA dog sled team is a group of dogs that are harnessed together to +pull a sled.", +"A dog sled looks like a small, open vehicle that is pulled by one or +more dogs.", +"Dog sledding in winter.", +" pulled by huskiesThe image is of a dog sled pulled by huskies.", +"A dog sled looks like a large cart that is pulled by a team of dogs." + +# "geyser": + +"A geyser is a hot spring that periodically erupts, shooting a column of +water and steam into the air.", +"A geyser looks like a hole in the ground that sometimes spurts hot water +and steam into the air.", +"Geysers are hot springs that periodically spout water and steam into the +air.", +"The image is of a geyser erupting.", +"A geyser is a hot spring that periodically erupts, spraying water into +the air.", +"A geyser typically looks like a cone of rocks with a small hole at the +top.", +"A geyser is a hot spring where water intermittently boils, sending a jet +of hot water and steam into the air.", +"A geyser is a hot spring that periodically shoots a stream of hot water +and steam into the air.", +"The image is of a geyser shooting water high into the air.", +"A geyser looks like a column of water that shoots into the air and then +falls back down." + +"Schipperke": + +"A Schipperke is a small, Belgian breed of dog.", +"A Schipperke is a small black Belgian dog with a rat-like tail.", +"The image is of a black and white dog with pointy ears and a long +body.", +"A Schipperke is a small, black, Belgian breed of dog.", +"A Schipperke is a small, black, Belgian breed of dog that closely +resembles a fox.", +"A Schipperke is a small Belgian breed of dog that resembles a fox.", +"Schipperkes have a long, black coat and a pointed muzzle.", +"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 +brick wall.", +"Black, small, spitz-type dog with a long, fox-like snout, large erect +ears, and a long, high-set tail." + +"go-kart": + +"A go-kart typically looks like a small car or buggy with a small engine +in the back.", +"A go-kart is a small vehicle with four wheels, a steering wheel, and a +gas pedal.", +"A go-kart is a small vehicle with a steering wheel, pedals, and an +engine.", +"Two young girls in go-karts race down a path in a park.", +"A go-kart is a small, lightweight vehicle with four wheels and a simple, +open frame.", +"A go-kart is a small, open-wheeled vehicle used for racing.", +"Two kids racing go-karts on a dirt track.", +"A go-kart is a small, racing car.", +"A go-kart typically looks like a small, open-wheeled car.", +"A go-kart is a small, lightweight vehicle with four wheels that is +propelled by a small engine." + +"black-and-white colobus": + +"The Black-and-White Colobus is a type of Old World monkey, found in +Africa.", +"A black-and-white colobus has long black fur, and a white face with a +black triangle around the eyes.", +"Colobus Monkey in the TreesThis elegant colobus monkey is swinging +through the trees in search of food.", +" monkeyIn this image, a black-and-white colobus monkey is shown perched +atop a tree branch.", +"The black-and-white colobus monkey is one of the most beautiful and +distinctive of all the colobus monkeys.", +"The black-and-white colobus monkey is a species of primate in the +Colobidae family.", +"Colobus monkeys are generally black with white patches on their face, +back, and sides.", +"The black-and-white colobus is a species of Old World monkey.", +" monkeyThe image is of a black-and-white colobus monkey sitting on a +tree branch.", +" monkeyIn the image, the black-and-white colobus monkey is sitting in a +tree." + +# "sock": + +"A sock usually has a cuff at the top, and a heel at the bottom.", +" A black sock with a white line running down the middle.", +"A sock is typically a garment worn on the feet and made from a soft +material, such as cotton.", +"A sock normally has a heel, toe and a cuff at the top.", +"A sock is a small amount of money that is given to someone without them +knowing.", +"A sock is an article of clothing worn on the feet.", +"A sock is a piece of clothing that is worn on the feet.", +"A sock is a tubular garment that covers the foot and ankle.", +"This image is of a blue and white striped sock.", +"There are many ways that you can identify a sock." + +"Cocker Spaniel": + +"A Cocker Spaniel is a medium sized dog with long, floppy ears, and a +silky coat that is usually either brown or black.", +"The Cocker Spaniel has a long floppy ears, a silky coat, and a bushy +tail.", +"A Cocker Spaniel has a long, black muzzle and big, brown eyes.", +"The Cocker Spaniel is a breed of dog.", +"An image of a Cocker Spaniel from the internet shows a small brown and +white dog with long floppy ears.", +"The image is of a Cocker Spaniel with short, brown fur and long, floppy +ears.", +"Cocker spaniels have long, floppy ears and a long, silky coat.", +"A Cocker Spaniel is a small to medium sized dog.", +"The image is of a light brown and white Cocker Spaniel standing on a +green grassy field with its head turned to the side.", +"A Cocker Spaniel has a long, silky coat that is usually either black, +brown, or golden." + +"southern black widow": + +"A southern black widow spider perched atop a web.", +"Female southern black widows have a black body with a red hourglass +shape on their abdomen.", +"The southern black widow is black with a red hourglass shape on its +belly.", +"Female southern black widow spiders are black with a characteristic red +hourglass-shaped mark on their ventral abdomen.", +" spiderThe image is of a large, black spider with a red hourglass shape +on its abdomen.", +"A southern black widow is a spider that is black with a red hourglass +shape on its abdomen.", +"A southern black widow spider is a small, black spider with a red +hourglass-shaped mark on its underside.", +"There’s an image on the internet of a southern black widow that’s really +cool.", +"A southern black widow can be identified by its black coloration with a +red hourglass shape on its abdomen.", +"A Southern black widow is a type of spider that is black with a red +hourglass shape on its belly." + +# "catamaran": + +"A catamaran is a sailboat that has two hulls, or wide bodies, that are +connected by beams.", +"The easiest way to identify a catamaran is by its two hulls.", +"A catamaran is a type of boat that has two parallel hulls.", +"A catamaran is a multi-hulled vessel with two parallel hulls of equal +size.", +"My dream boat! A sleek catamaran that can zip through the waves.", +"A catamaran is a multi-hulled vessel with two parallel hulls of equal +size.", +"The image is of a white catamaran with blue trim.", +"A catamaran is a type of boat that has two hulls, or platforms, that are +parallel to each other.", +"The image is of a yellow catamaran with white trim, sitting in calm +water.", +"A catamaran is a type of sailing vessel that consists of two parallel +hulls of equal size." + +"beach": + +".", +"Blue skies, white sands, and clear turquoise waters make this beach a +paradise.", +"A beach usually has sand and water.", +"Beach identification can be accomplished through the identification of +physical characteristics.", +"A beach is a naturally occurring feature of the landscape.", +"The sun sets over the ocean, casting a beautiful orange hue in the +sky.", +"A beach is a large body of water with sand or small rocks at the +shore.", +"In the image, the beach is Brilliant white with crystal blue waters.", +"The beach looks like a long strip of land next to the ocean.", +"A beach typically looks like a large, flat expanse of sand with some +rocks or other natural features nearby." + +"rotary dial telephone": + +"A rotary dial is a device used to dial telephone numbers.", +"Rotary dial telephone from the mid-20th century.", +"A rotary dial telephone is a phone with a circular dial on the front +face.", +"When looking at a rotary telephone, you can tell it is a rotary phone by +the Place the phone’s receiver on your ear and listen for a dial tone.", +"A rotary dial phone is an older model phone that has a circular device +with numbers on it that you rotate with your finger to dial a number.", +"A rotary dial telephone is a type of telephone that uses a mechanical +dial to select the telephone number that a user wishes to call.", +"History of the Rotary Dial Telephone.", +"A rotary dial telephone is an old-fashioned telephone that has a round +dial on the front of it.", \ No newline at end of file diff --git a/md/dev/4G1Sfp_1sz7/4G1Sfp_1sz7.md b/md/dev/4G1Sfp_1sz7/4G1Sfp_1sz7.md new file mode 100644 index 0000000000000000000000000000000000000000..b8acaf13e5962e8fe069a45bf369ee90af62a74d --- /dev/null +++ b/md/dev/4G1Sfp_1sz7/4G1Sfp_1sz7.md @@ -0,0 +1,367 @@ +# Generating Training Data with Language Models: Towards Zero-Shot Language Understanding + +Yu Meng, Jiaxin Huang, Yu Zhang, Jiawei Han Department of Computer Science, University of Illinois at Urbana-Champaign {yumeng5,jiaxinh3,yuz9,hanj}@illinois.edu + +# Abstract + +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. + +# 1 Introduction + +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. + +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. + +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. + +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. + +# 2 Related Work + +# 2.1 Few-Shot and Zero-Shot Learning with PLMs + +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. + +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. + +# 2.2 Controlled Text Generation with PLMs + +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. + +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. + +![](images/801aec59c9633f7891b483be336be9aeac6c924769ec046dea1586f20d530364.jpg) +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. + +# 3 Method + +# 3.1 Preliminaries + +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. + +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: + +$$ +\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 } ) } . +$$ + +Here, $p _ { \theta } ( \cdot )$ is usually parameterized using token embeddings $e$ and contextualized embeddings $^ { h }$ given by a Transformer [65] encoder. + +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: + +$$ +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 ) } , +$$ + +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. + +# 3.2 Training Data Generation + +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. + +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. + +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: + +$$ +\pmb { x } ^ { g } G _ { \theta } ( \pmb { w } _ { y } ) , +$$ + +
TaskLabelPrompt
SST-2positive negativeRating:5.0xg Rating: 1.0 xg
MNLIentailmentx.In other words,xg
neutralx.Furthermore,xg
There is a rumor that x.
contradictionHowever, the truth is:x9
QNLIentailmentx?xg
not entailmentx?...g
RTEentailmentx.In other words,xg
not entailmentx.Furthermore,xg
MRPCequivalentx.In other words,xg
not equivalentx.Furthermore,xg
QQPequivalentx ?In other words,xg
not equivalentx"?Furthermore,xg
+ +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 )$ . + +For syntactic tasks like linguistic acceptabil +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. + +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 }$ : + +$$ +\pmb { x } ^ { g } G _ { \theta } ( [ \pmb { x } ^ { s } ; \pmb { w } _ { y } ] ) , \pmb { x } ^ { s } \sim \mathcal { D } . +$$ + +The sequence pair training sample will then be formed as $( \pmb { x } ^ { s } , \pmb { x } ^ { g } , y )$ . + +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 + +Eq. (1) that rewards/penalizes repetition based on whether the token has appeared in ${ \pmb x } ^ { s } / { \pmb x } ^ { g }$ : + +$$ +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. , +$$ + +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. + +# 3.3 Effective Fine-Tuning on Generated Texts + +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. + +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 }$ : + +$$ +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) . +$$ + +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]: + +$$ +r = \frac { 1 } { n } \sum _ { i = 1 } ^ { n } \log p _ { \theta } \left( x _ { i } \middle | [ \pmb { w } _ { y } ; \pmb { x } _ { < i } ^ { g } ] \right) . +$$ + +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. + +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. + +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: + +$$ +\operatorname* { m i n } _ { \phi } - \sum _ { j = 1 } ^ { | \mathcal { V } | } q _ { j } \log ( p _ { \phi } ( \pmb { x } ^ { g } ) _ { j } ) , +$$ + +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. + +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: + +$$ +\hat { z } \gamma \hat { z } + ( 1 - \gamma ) p _ { \phi } , \bar { z } \hat { z } / ( 1 - \gamma ^ { t } ) , +$$ + +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. + +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$ : + +$$ +\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 } } . +$$ + +We follow [28] to slowly ramp-up $\lambda$ during training. + +# 3.4 Overall Algorithm + +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 }$ . + +# Algorithm 1: SuperGen for Zero-Shot Learning. + +Input: $\mathcal { V }$ : Label space; $\mathcal { P }$ : Label-descriptive prompts; $G _ { \theta }$ : Unidirectional PLM; $C _ { \phi }$ : Bidirectional PLM. + +# 4 Experimental Setup + +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. + +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. +Output: $C _ { \phi } ^ { * }$ : Classifier that classifies input texts into $\mathcal { V }$ . +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 +end +$\tau \{ \}$ +// Selected train set. +for $y \in \mathcal { V }$ do Sort $\mathcal { T } _ { y }$ in descending order by Eq. (3) $\tau \tau \cup \mathcal { T } _ { y } [ : N ]$ +end +$\hat { z } \gets \mathbf { 0 }$ +// Ensembled prediction init. +$\tau ^ { * } \tau$ +// Filtered train set. +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 +end +return $C _ { \phi } ^ { * } = C _ { \phi }$ + +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. + +Fine-Tuning Settings and Hyperparameters. We note that SuperGen is compatible with any fine-tuning method; while using more sophisticated methods may grant + +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. + +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]. + +
MethodMNLI-(m/mm) (Acc.)QQP (F1)QNLI (Acc.)SST-2 (Acc.)CoLA (Matt.)RTE (Acc.)MRPC (F1)AVG
Zero-Shot Setting: No task-specific data (neither labeled nor unlabeled).
Promptingt50.80.0/51.70.049.70.050.80.083.60.02.00.051.30.061.90.050.1
SuperGen72.30.5/73.80.566.1.173.31.992.80.632.75.565.31.282.20.569.4
- data selection63.71.5/64.21.662.32.263.93.291.32.030.58.862.41.581.60.265.1
- label smooth70.70.8/72.10.765.10.971.42.591.00.99.51.064.81.183.00.765.2
- temporal ensemble62.04.6/63.64.863.90.372.42.092.50.923.57.063.51.078.82.265.3
Few-Shot Seting: Use 32 labeled samples/class (half for training and half for development).
Fine-tuning†45.86.4/47.86.860.74.360.26.581.43.833.914.354.43.976.62.559.1
Manual prompt†68.32.3/70.51.965.55.364.54.292.70.99.37.369.13.674.55.363.6
+ demonstrationt70.71.3/72.01.269.81.869.21.992.60.518.78.868.72.377.82.066.9
Auto prompt68.32.5/70.12.667.03.068.37.492.31.014.014.173.92.276.22.365.8
+ demonstration†70.03.6/72.03.167.75.868.55.493.00.621.815.971.15.378.13.467.3
Fully supervisedt89.8/89.581.793.395.062.680.991.484.9
+ +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. + +
Prompt GroupMNLI-(m/mm)QQPQNLISST-2RTEMRPC
#0 (Original)72.30.5/73.80.566.1.173.31.992.80.665.31.282.20.5
#170.71.4/72.41.265.51.471.91.792.20.964.41.681.90.4
#270.80.6/72.10.865.61.172.22.292.40.864.71.881.80.8
#370.91.4/72.21.4-----
Mixed72.20.7/73.40.666.91.573.01.792.80.966.31.081.32.0
+ +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. + +# 5 Evaluation + +# 5.1 Main Results + +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. + +# 5.2 Using Different Prompts + +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. + +![](images/69e5c74206bf221048ac17346d9f4ccd6da2f7b8626c7e65c64dc66d8d607e07.jpg) +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. + +![](images/86bad6e8a307687f725a2dde6b8fe1da692480e94a43dd09f20030092b822a1f.jpg) +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. + +# 5.3 Results with Different Amount of Generated Data + +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. + +# 5.4 Using SuperGen in Few-Shot Settings + +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. + +Table 4: Comparisons with using CTRL for zeroshot prompting and for knowledge distillation. †: The entire training set is used as unlabeled data. + +
MethodMNLI-(m/mm)SST-2
SuperGen72.30.5/73.80.592.80.6
CTRL Prompting38.50.0/39.20.072.50.0
Knowledge Distillt40.80.5/41.50.673.60.8
+ +Table 5: Results with different generator/classifier PLMs. + +
PLMs (Ge/CΦ)MNLI-(m/mm)SST-2
CTRL/COCO-LM72.30.5/73.80.592.80.6
CTRL/RoBERTa69.00.8/70.60.993.01.5
GPT-2/COCO-LM69.51.2/71.31.388.21.8
GPT-2/RoBERTa68.30.9/69.70.788.60.8
+ +# 5.5 Using Generators for Knowledge Distillation + +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. + +# 5.6 Using Different PLMs + +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. + +# 5.7 Case Studies + +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. + +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. + +
TaskLabelGenerated Text
SST-2positiveRating:5.0 The film is a great example of the kind of movie that you can watch over and over.
negativeRating:1.0 The film was a total waste of time.I would not recommend this movie to anyone.
MNLIentailmentThe 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.
neutralTheconstruction of the station began in 2O16,when the opening date was estimated to mid-2020.
Furthermore,it is expected that a new bus terminal will be built at this station.
contradictionThere 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.
QQPequivalent not equivalentWhat 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?
+ +# 6 Discussions and Conclusions + +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. + +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. + +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. + +# Acknowledgments + +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. + +# References + +[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. +[2] Emily M. Bender and Alexander Koller. Climbing towards NLU: On meaning, form, and understanding in the age of data. In ACL, 2020. +[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. +[4] Luisa Bentivogli, Peter Clark, Ido Dagan, and Danilo Giampiccolo. The fifth pascal recognizing textual entailment challenge. In TAC, 2009. +[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. +[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. +[7] Jiaao Chen, Zichao Yang, and Diyi Yang. Mixtext: Linguistically-informed interpolation of hidden space for semi-supervised text classification. In ACL, 2020. +[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. +[9] Ido Dagan, Oren Glickman, and Bernardo Magnini. The pascal recognising textual entailment challenge. In Machine Learning Challenges Workshop, 2005. +[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. +[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. +[12] William B Dolan and Chris Brockett. Automatically constructing a corpus of sentential paraphrases. In International Workshop on Paraphrasing (IWP), 2005. +[13] Tianyu Gao, Adam Fisch, and Danqi Chen. Making pre-trained language models better few-shot learners. In ACL, 2021. +[14] Tianyu Gao, Xingcheng Yao, and Danqi Chen. SimCSE: Simple contrastive learning of sentence embeddings. In EMNLP, 2021. +[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. +[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. +[17] Aaron Gokaslan and Vanya Cohen. OpenWebText corpus. http://Skylion007.github. io/OpenWebTextCorpus, 2019. +[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. +[19] Pengcheng He, Xiaodong Liu, Jianfeng Gao, and Weizhu Chen. DeBERTa: Decoding-enhanced BERT with disentangled attention. In ICLR, 2021. +[20] Geoffrey E. Hinton, Oriol Vinyals, and Jeffrey Dean. Distilling the knowledge in a neural network. ArXiv, abs/1503.02531, 2015. +[21] Ari Holtzman, Jan Buys, Maxwell Forbes, and Yejin Choi. The curious case of neural text degeneration. In ICLR, 2020. +[22] Zhiting Hu, Zichao Yang, Xiaodan Liang, Ruslan Salakhutdinov, and Eric P. Xing. Toward controlled generation of text. In ICML, 2017. +[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. +[24] Muhammad Khalifa, Hady ElSahar, and Marc Dymetman. A distributional approach to controlled text generation. In ICLR, 2021. +[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. +[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. +[27] Sachin Kumar, Eric Malmi, Aliaksei Severyn, and Yulia Tsvetkov. Controlled text generation as continuous optimization with multiple constraints. In NeurIPS, 2021. +[28] Samuli Laine and Timo Aila. Temporal ensembling for semi-supervised learning. In ICLR, 2017. +[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. +[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. +[31] Xiang Lisa Li and Percy Liang. Prefix-tuning: Optimizing continuous prompts for generation. In ACL, 2021. +[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. +[33] Xiao Liu, Yanan Zheng, Zhengxiao Du, Ming Ding, Yujie Qian, Zhilin Yang, and Jie Tang. GPT understands, too. ArXiv, abs/2103.10385, 2021. +[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. +[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. +[36] Michal Lukasik, Srinadh Bhojanapalli, Aditya Krishna Menon, and Surinder Kumar. Does label smoothing mitigate label noise? In ICML, 2020. +[37] Xinyao Ma, Maarten Sap, Hannah Rashkin, and Yejin Choi. PowerTransformer: Unsupervised controllable revision for biased language correction. In EMNLP, 2020. +[38] Yu Meng, Jiaming Shen, Chao Zhang, and Jiawei Han. Weakly-supervised neural text classification. In CIKM, 2018. +[39] Yu Meng, Jiaming Shen, Chao Zhang, and Jiawei Han. Weakly-supervised hierarchical text classification. In AAAI, 2019. +[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. +[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. +[42] Swaroop Mishra, Daniel Khashabi, Chitta Baral, and Hannaneh Hajishirzi. Cross-task generalization via natural language crowdsourcing instructions. arXiv preprint arXiv:2104.08773, 2021. +[43] Takeru Miyato, Andrew M. Dai, and Ian J. Goodfellow. Adversarial training methods for semi-supervised text classification. In ICLR, 2017. +[44] Rafael Muller, Simon Kornblith, and Geoffrey E. Hinton. When does label smoothing help? In ¨ NeurIPS, 2019. +[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. +[46] Artidoro Pagnoni, Vidhisha Balachandran, and Yulia Tsvetkov. Understanding factuality in abstractive summarization with FRANK: A benchmark for factuality metrics. In NAACL, 2021. +[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. +[48] Ethan Perez, Douwe Kiela, and Kyunghyun Cho. True few-shot learning with language models. In NeurIPS, 2021. +[49] Shrimai Prabhumoye, Yulia Tsvetkov, Ruslan Salakhutdinov, and Alan W. Black. Style transfer through back-translation. In ACL, 2018. +[50] Raul Puri and Bryan Catanzaro. Zero-shot text classification with generative language models. ArXiv, abs/1912.10165, 2019. +[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. +[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. +[53] Nils Reimers and Iryna Gurevych. Sentence-BERT: Sentence embeddings using siamese BERT-networks. In EMNLP, 2019. +[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. +[55] Teven Le Scao and Alexander M. Rush. How many data points is a prompt worth? In NAACL, 2021. +[56] Timo Schick and Hinrich Schutze. Exploiting cloze-questions for few-shot text classification ¨ and natural language inference. In EACL, 2021. +[57] Timo Schick and Hinrich Schutze. Few-shot text generation with natural language instructions. ¨ In EMNLP, 2021. +[58] Timo Schick and Hinrich Schutze. Generating datasets with pretrained language models. In ¨ EMNLP, 2021. +[59] Timo Schick and Hinrich Schutze. It’s not just size that matters: Small language models are ¨ also few-shot learners. In NAACL, 2021. +[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. +[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. +[62] Christian Szegedy, Vincent Vanhoucke, Sergey Ioffe, Jonathon Shlens, and Zbigniew Wojna. Rethinking the inception architecture for computer vision. In CVPR, 2016. +[63] Derek Tam, Rakesh R Menon, Mohit Bansal, Shashank Srivastava, and Colin Raffel. Improving and simplifying pattern exploiting training. In EMNLP, 2021. +[64] Lisa Torrey and Jude Shavlik. Transfer learning. In Handbook of research on machine learning applications and trends: algorithms, methods, and techniques. 2010. +[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. +[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. +[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. +[68] Zirui Wang, Adams Wei Yu, Orhan Firat, and Yuan Cao. Towards zero-label language learning. arXiv preprint arXiv:2109.09193, 2021. +[69] Alex Warstadt, Amanpreet Singh, and Samuel R Bowman. Neural network acceptability judgments. In TACL, 2019. +[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. +[71] Sean Welleck, Ilia Kulikov, Stephen Roller, Emily Dinan, Kyunghyun Cho, and Jason Weston. Neural text generation with unlikelihood training. In ICLR, 2020. +[72] Adina Williams, Nikita Nangia, and Samuel Bowman. A broad-coverage challenge corpus for sentence understanding through inference. In NAACL-HLT, 2018. +[73] Qizhe Xie, Zihang Dai, Eduard H. Hovy, Minh-Thang Luong, and Quoc V. Le. Unsupervised data augmentation for consistency training. In NeurIPS, 2020. +[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. +[75] Kevin Yang and Dan Klein. FUDGE: Controlled text generation with future discriminators. In NAACL, 2021. +[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. +[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. +[78] Qinyuan Ye, Bill Yuchen Lin, and Xiang Ren. Crossfit: A few-shot learning challenge for cross-task generalization in nlp. In EMNLP, 2021. +[79] Wenpeng Yin, Jamaal Hay, and Dan Roth. Benchmarking zero-shot text classification: Datasets, evaluation and entailment approach. In EMNLP, 2019. +[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. +[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. +[82] Weizhe Yuan, Graham Neubig, and Pengfei Liu. BARTScore: Evaluating generated text as text generation. In NeurIPS, 2021. +[83] Chiyuan Zhang, Samy Bengio, Moritz Hardt, Benjamin Recht, and Oriol Vinyals. Understanding deep learning requires rethinking generalization. In ICLR, 2017. +[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. +[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. +[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. +[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. +[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. + +# Checklist + +1. For all authors... + +(a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes] +(b) Did you describe the limitations of your work? [Yes] +(c) Did you discuss any potential negative societal impacts of your work? [Yes] +(d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes] + +2. If you are including theoretical results... + +(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] + +3. If you ran experiments... + +(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] +(b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes] +(c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [Yes] +(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] + +4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets... + +(a) If your work uses existing assets, did you cite the creators? [Yes] +(b) Did you mention the license of the assets? [Yes] +(c) Did you include any new assets either in the supplemental material or as a URL? [N/A] +(d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [N/A] + +(e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [N/A] + +5. If you used crowdsourcing or conducted research with human subjects... + +(a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A] +(b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A] +(c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A] \ No newline at end of file diff --git a/md/dev/4R7YrAGhnve/4R7YrAGhnve.md b/md/dev/4R7YrAGhnve/4R7YrAGhnve.md new file mode 100644 index 0000000000000000000000000000000000000000..56b9d8d37c40964c9b78b2b03cabab1b8a6217fd --- /dev/null +++ b/md/dev/4R7YrAGhnve/4R7YrAGhnve.md @@ -0,0 +1,255 @@ +# SegViT: Semantic Segmentation with Plain Vision Transformers + +Bowen Zhang1∗, Zhi Tian2∗, Quan Tang4, Xiangxiang $\mathbf { C h u ^ { 2 } }$ , Xiaolin Wei2, Chunhua Shen3, Yifan Liu1 + +1 The University of Adelaide, Australia 2 Meituan Inc. 3 Zhejiang University, China 4 South China University of Technology, China + +# Abstract + +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. + +# 1 Introduction + +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. + +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. + +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. + +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. + +We summarize our main contributions as follows: + +• 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. +• 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. +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). + +# 2 Related Work + +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. + +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]. + +![](images/d4684106657fd91e50f1ae4dbfc23811e0a8d9bf529682b3f8d4363fdb795cf5.jpg) +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. + +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. + +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. + +# 3 Method + +# 3.1 Encoder + +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. + +![](images/34cbf2f58eed90953a49e4ee13e4b168073eba542e2899120d61dd93c2b7b2f1.jpg) +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. + +# 3.2 Decoder + +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). + +$$ +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 } , +$$ + +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: + +$$ +\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} +$$ + +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$ . + +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: + +$$ +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 } +$$ + +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. + +![](images/937a25918d13b9bb305644659197a9d1f00fc926dfb7e1a6dcf30600feacaa80.jpg) +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. + +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. + +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, + +$$ +\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 } +$$ + +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. + +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. + +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. + +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. + +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. + +# 4 Experiments + +# 4.1 Datasets + +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. + +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. + +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’. + +# 4.2 Implementation details + +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. + +# 4.3 Comparisons with the State-of-the-art Methods + +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 + +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. + +
MethodBackboneCrop SizeGFLOPsmIoU (ss)mIoU (ms)
UperNet* [32]ViT-Base512 × 512>25046.647.5
DPT*[7]ViT-Base512 × 512219.847.247.9
SETR-MLA* [6]ViT-Base512 × 512113.548.249.3
Segmenter* [8]ViT-Base512 × 512129.649.050.0
StructToken [31]ViT-Base512 × 512>15050.951.8
SegViT (Ours)ViT-Base512 × 512120.951.353.0
DPT* [7]ViT-Large†640 × 640479.049.249.5
UperNet* [32]ViT-Larget640 × 640>70048.650.0
SETR-MLA [6]ViT-Large512 × 512368.648.650.3
MCIBI [33]ViT-Large512 × 512>400150.8
Segmenter [8]ViT-Large†640 × 640671.851.853.6
StructToken [31]ViT-Larget640 × 640>70052.854.2
SegViT (Shrunk, ours)ViT-Large†640 × 640373.553.955.1
SegViT (ours)ViT-Larget640 × 640637.954.655.2
+ +$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). + +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. + +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$ . + +
MethodBackboneGFLOPsmIoU (ms)
DANet [34]Dilated-ResNet-101289.339.7
MaskFormer[15]ResNet-101-fpn81.739.8
EMANet [35]Dilated-ResNet-101247.439.9
SpyGR [36]ResNet-101-fpnv8039.9
OCRNet [3]HRNetV2-W48167.940.5
GINet [37]JPU-ResNet-101>20040.6
RecoNet [38]Dilated-ResNet-101>20041.5
ISNet [39]Dilated-ResNeSt-101228.342.1
MCIBI [33]ViT-Large>38044.9
StructToken [31]ViT-Large>40049.1
SegViT (Shrunk, ours)ViT-Large224.849.4
SegViT (ours)ViT-Large383.950.3
+ +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. + +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$ . + +
MethodBackboneGFLOPsmIoU59 (ms)mIoU60 (ms)
RefineNet [41]ResNet-152=47.3
UNet++ [42]ResNet-101=47.71
PSPNet [11]Dilated-ResNet-101157.047.8
Ding et al. [43]ResNet-101=51.6
EncNet [44]Dilated-ResNet-101192.152.6=
HRNet [40]HRNetV2-W4882.754.048.3
NRD [45]ResNet-10142.954.149.0
GFFNet [46]Dilated-ResNet-101=54.31
EfficientFCN [47]ResNet-10152.855.3
OCRNet [3]HRNetV2-W48143.956.2=
SETR-MLA [6]ViT-Large318.5155.8
Segmenter [8]ViT-Large346.2159.0
SegViT (Shrunk, ours)ViT-Large186.963.757.4
SegViT (ours)ViT-Large321.665.359.3
+ +# 4.4 Ablation Study + +In this section, we conduct the ablation study to show the effectiveness of our proposed methods. + +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). + +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. + +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. + +
DecoderLossmIoU (ss)
SETRCE loss46.5
ATMCE loss47.0 (+0.5)
ATMLmask loss49.6 (+3.1)
+ +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. + +
Used layersmIoU (ss)
Single[12]49.6
Cascade[6,12]50.9 (+1.3)
Cascade[6,8,12]51.3 (+1.7)
Cascade[3,6,9,12]51.2 (+1.6)
+ +Ablation for the ATM Decoder. We conduct experiments to show the effectiveness of the proposed ATM decoder + +$\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. + +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. + +
MethodmIoU (ss)GFLOPs
Maskformer [15]46.757.3
Mask2former [48]47.773.7
SegViT (Ours)47.148.0
+ +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. + +
Applied toMethodsmIoU (ss)
QConv44.5
Q,K,VNearest52.6
QNearest53.9
+ +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. + +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. + +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. + +
StructureQDQUHeadmIoU (ss)GFLOPs
SingleSETR46.5107.3
SingleATM49.6 (+3.1)115.8
Naive Shrunk<ATM46.9 (+0.4)74.1
ShrunkATM50.0 (+3.5)97.1
+ +# 5 Conclusion + +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. + +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. + +# References + +IEEE Conf. Comp. Vis. Patt. Recogn., pp. 3431–3440, 2015. +[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. +[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. +[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. +[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. +[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. +[7] R. Ranftl, A. Bochkovskiy, and V. Koltun, “Vision transformers for dense prediction,” in Proc. IEEE Int. Conf. Comp. Vis., pp. 12179–12188, 2021. +[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. +[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. +[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. +[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. +[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. +[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. +[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. +[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. +[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. +[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. +[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. +[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. +[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. +[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. +[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. +[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. +[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. +[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. +[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. +[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. +[28] MMSegmentation, “MMSegmentation: OpenMMLab semantic segmentation toolbox and benchmark.” https://github.com/open-mmlab/mmsegmentation, 2020. +[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. +[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. +[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. +[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. +[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. +[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. +[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. +[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. +[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. +[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. +[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. +[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. +[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. +[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. +[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. +[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. +[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. +[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. +[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. +[48] B. Cheng, I. Misra, A. G. Schwing, A. Kirillov, and R. Girdhar, “Masked-attention mask transformer for universal image segmentation,” 2022. + +# Checklist + +1. For all authors... + +(a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes] +(b) Did you describe the limitations of your work? [Yes] +(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. +(d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes] + +2. If you are including theoretical results... + +(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] + +3. If you ran experiments... + +(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. +(b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes] See implementation details. +(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 +(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. + +4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets... + +(a) If your work uses existing assets, did you cite the creators? [Yes] +(b) Did you mention the license of the assets? [No] The license can be found in their own homepages. +(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. +(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. +(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. + +5. If you used crowdsourcing or conducted research with human subjects... + +(a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A] +(b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A] +(c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A] \ No newline at end of file diff --git a/md/dev/6MmiS0HUJHR/6MmiS0HUJHR.md b/md/dev/6MmiS0HUJHR/6MmiS0HUJHR.md new file mode 100644 index 0000000000000000000000000000000000000000..34b1980dca9fb523f33bbcd336868cc10d8d78dc --- /dev/null +++ b/md/dev/6MmiS0HUJHR/6MmiS0HUJHR.md @@ -0,0 +1,1841 @@ +# WHEN CAN WE LEARN GENERAL-SUM MARKOV GAMES WITH A LARGE NUMBER OF PLAYERS SAMPLE-EFFICIENTLY? + +Ziang Song +School of Mathematical Sciences, Peking University +songziang@pku.edu.cn + +Song Mei Department of Statistics, UC Berkeley songmei@berkeley.edu + +# Yu Bai + +Salesforce Research yu.bai@salesforce.com + +# ABSTRACT + +Multi-agent reinforcement learning has made substantial empirical progresses in solving games with a large number of players. However, theoretically, the best known sample complexity for finding a Nash equilibrium in general-sum games scales exponentially in the number of players due to the size of the joint action space, and there is a matching exponential lower bound. This paper investigates what learning goals admit better sample complexities in the setting of $m$ -player general-sum Markov games with $H$ steps, $S$ states, and $A _ { i }$ actions per player. First, we design algorithms for learning an $\varepsilon$ -Coarse Correlated Equilibrium (CCE) in $\widetilde { \mathcal { O } } ( H ^ { 5 } S \operatorname* { m a x } _ { i \leq m } A _ { i } / \varepsilon ^ { 2 } )$ episodes, and an $\varepsilon$ -Correlated Equilibrium (CE) in $\widetilde { \mathcal { O } } ( H ^ { 6 } S \operatorname* { m a x } _ { i \leq m } A _ { i } ^ { 2 } / \varepsilon ^ { 2 } )$ episodes. This is the first line of results for learning CCE and CE with sample complexities polynomial in $\operatorname* { m a x } _ { i \leq m } A _ { i }$ . Our algorithm for learning CE integrates an adversarial bandit subroutine which minimizes a weighted swap regret, along with several novel designs in the outer loop. Second, we consider the important special case of Markov Potential Games, and design an algorithm that learns an $\varepsilon$ -approximate Nash equilibrium within $\begin{array} { r } { \widetilde { \mathcal { O } } ( S \sum _ { i \leq m } { \bar { A } _ { i } / \varepsilon ^ { 3 } } ) } \end{array}$ episodes (when only highlighting the dependence on $S$ , $A _ { i }$ , and $\varepsilon$ ), which only depends linearly in $\textstyle \sum _ { i \leq m } A _ { i }$ and significantly improves over existing efficient algorithms in the $\varepsilon$ dependence. Overall, our results shed light on what equilibria or structural assumptions on the game may enable sample-efficient learning with many players. + +# 1 INTRODUCTION + +Multi-agent reinforcement learning (RL) has achieved substantial recent successes in solving artificial intelligence challenges such as GO (Silver et al., 2016; 2018), multi-player games with team play such as Starcraft (Vinyals et al., 2019) and Dota2 (Berner et al., 2019), behavior learning in social interactions (Baker et al., 2019), and economic simulation (Zheng et al., 2020; Trott et al., 2021). In many applications, multi-agent RL is able to yield high quality policies for multi-player games with a large number of players (Wang et al., 2016; Yang et al., 2018). + +Despite these empirical progresses, theoretical understanding of when we can sample-efficiently solve multi-player games with a large number of players remains elusive, especially in the setting of multi-player Markov games. A main bottleneck here is the exponential blow-up of the joint action space—The total number of joint actions in a generic game with simultaneous plays is equal to the product of the number of actions for each player, which scales exponentially in the number of players. Such an exponential dependence is indeed known to be unavoidable in the worst-case for certain standard problems. For example, for learning an approximate Nash equilibrium from payoff queries in an one-step multi-player general-sum game, the query complexity lower bound of Chen et al. (2015) and Rubinstein (2016) shows that at least exponentially many queries (samples) is required, even when each player only has two possible actions and the query is noiseless. Moreover, for learning Nash equilibrium in Markov games, the best existing sample complexity upper bound also scales with the size of the joint action space (Liu et al., 2021). + +Nevertheless, these exponential lower bounds do not completely rule out interesting theoretical inquiries—there may well be other notions of equilibria or additional structures within the game that allow us to learn with a better sample complexity. This motivates us to ask the following + +Question: When can we solve general-sum Markov games with sample complexity milder than exponential in the number of players? + +This paper makes steps towards answering the above question by considering multi-player generalsum Markov games (MGs) with $m$ players, $H$ steps, $S$ states, and $A _ { i }$ actions per player. We make two lines of investigations: (1) Can we learn alternative notions of equilibria with better sample complexity than learning Nash; (2) Can the Nash equilibrium be learned with better sample complexity under additional structural assumptions on the game. This paper makes contributions on both ends, which we summarize as follows. + +• We first design an algorithm that learns the $\varepsilon$ -approximate Coarse Correlated Equilibrium (CCE) with $\widetilde { \mathcal { O } } ( H ^ { 5 } S \operatorname* { m a x } _ { i \in [ m ] } A _ { i } / \varepsilon ^ { 2 } )$ episodes of play (Section 3). Our algorithm CCE-VLEARNING is a multi-player adaptation of the Nash V-Learning algorithm of Bai et al. (2020). We design an algorithm CE-V-LEARNING which learns the stricter notion of $\varepsilon$ -approximate Correlated Equilibrium (CE) with $\widetilde { \mathcal { O } } ( H ^ { 6 } S \operatorname* { m a x } _ { i \in [ m ] } A _ { i } ^ { 2 } / \varepsilon ^ { 2 } )$ episodes of play (Section 4). For Markov games, these are the first line of sample complexity results for learning CE and CCE that only scales polynomially with $\mathrm { m a x } _ { i \in [ m ] } A _ { i }$ , and improves significantly in the $A _ { i }$ dependency over the current best algorithm which scales with $\textstyle \prod _ { i \in [ m ] } A _ { i }$ . • Technically, our algorithm CE-V-LEARNING makes several major modifications over CCEV-LEARNING in order to learn the CE (Section 4.2). Notably, inspired by the connection between CE and low swap-regret learning, we use a mixed-expert Follow-The-Regularized Leader algorithm within its inner loop to achieve low swap-regret for a particular adversarial bandit problem. Our analysis also contains new results for adversarial bandits on weighted swap regret and weighted regret with predicable weights, which may be of independent interest. • Finally, we consider learning Nash equilibrium in Markov Potential Games (MPGs), an important subclass of general-sum Markov games. By a reduction to single-agent RL, we design an algorithm NASH-CA that achieves $\begin{array} { r } { \widetilde { \mathcal { O } } ( \Phi _ { \operatorname* { m a x } } H ^ { 3 } S \sum _ { i \in [ m ] } A _ { i } / \varepsilon ^ { 3 } ) } \end{array}$ sample complexity, where $\Phi _ { \mathrm { m a x } } \leq H m$ is the bound on the potential function (Section 5). Compared with the recent result of Leonardos et al. (2021), we significantly improves the $\varepsilon$ dependence from their $1 / \varepsilon ^ { 6 }$ . + +# 1.1 RELATED WORK + +Learning equilibria in general-sum games The sample (query) complexity of learning Nash, CE, and CCE from samples in one-step (i.e. normal form) general-sum games with $m$ players and $A _ { i }$ actions per player has been studied extensively in literature (Hart & Mas-Colell, 2000; Hart, 2005; Stoltz, 2005; Cesa-Bianchi & Lugosi, 2006; Blum & Mansour, 2007; Fearnley et al., 2015; Babichenko & Barman, 2015; Chen et al., 2015; Fearnley & Savani, 2016; Goldberg & Roth, 2016; Babichenko, 2016; Rubinstein, 2016; Hart & Nisan, 2018). It is known that learning Nash equilibrium requires exponential in $m$ samples in the worst case (Rubinstein, 2016), whereas CE and CCE admit efficient poly $( m , \operatorname* { m a x } _ { i \leq m } A _ { i } )$ -sample complexity algorithms by independent no-regret learning (Hart & Mas-Colell, 2000; Hart, 2005; Syrgkanis et al., 2015; Goldberg & Roth, 2016; Chen & Peng, 2020; Daskalakis et al., 2021). Our results for learning CE and CCE can be seen as extension of these works into Markov games. We remark that even when the game is fully known, the computational complexity for finding Nash in general-sum games is PPAD-hard (Daskalakis, 2013). + +Markov games Markov games (Shapley, 1953; Littman, 1994) is a widely used framework for game playing with sequential decision making, e.g. in multi-agent reinforcement learning. Algorithms with asymptotic convergence have been proposed in the early works of Hu & Wellman (2003); Littman (2001); Hansen et al. (2013). A recent line of work studies the non-asymptotic sample complexity for learning Nash in two-player zero-sum Markov games (Bai & Jin, 2020; Xie et al., 2020; Bai et al., + +2020; Zhang et al., 2020; Liu et al., 2021; Chen et al., 2021; Jin et al., 2021; Huang et al., 2021) and learning various equilibria in general-sum Markov games (Liu et al., 2021; Bai et al., 2021), building on techniques for learning single-agent Markov Decision Processes sample-efficiently (Azar et al., 2017; Jin et al., 2018). Learning the Nash equilibrium in general-sum Markov games are much harder than that in zero-sum Markov games. Liu et al. (2021) present the first line of results for learning Nash, CE, and CCE in general-sum Markov games; however their sample complexity scales with $\Pi _ { i \leq m } A _ { i }$ due to the model-based nature of their algorithm. Algorithms for computing CE in extensive-form games has been widely studied (Von Stengel & Forges, 2008; Celli et al., 2020; Farina et al., 2021; Morrill et al., 2021), though we remark Markov games and extensive-form games are different frameworks and our results do not imply each other. + +Markov potential games Lastly, a recent line of works considers Markov potential games (Macua et al., 2018; Leonardos et al., 2021; Zhang et al., 2021), a subset of general-sum Markov games in which the Nash equilibrium admits more efficient algorithms. Leonardos et al. (2021) gives a sample-efficient algorithm based on the policy gradient method (Agarwal et al., 2021). The special case of Markov cooperative games is studied empirically in e.g. Lowe et al. (2017); Yu et al. (2021). For one step potential games, Kleinberg et al. (2009); Palaiopanos et al. (2017); Cohen et al. (2017a) show the convergence to Nash equilibria of no-regret dynamics. + +# 2 PRELIMINARIES + +We present preliminaries for multi-player general-sum Markov games as well as the solution concept of (approximate) Nash equilibrium. Alternative solution concepts and other concrete subclasses of Markov games considered in this paper will be defined in the later sections. + +Marwith $m$ v games A multi-player general splayers can be described by a tuple $\mathbf { M G } ( H , S , \{ \mathbf { \bar { \mathcal { A } } } _ { i } \} _ { i = 1 } ^ { m } , \mathbb { P } , \{ r _ { i } \} _ { i = 1 } ^ { m } )$ (1953);, where $H$ ittman (1994))is the episode length, $s$ is the state space with $| S | = S$ , $A _ { i }$ is the action space for the $i ^ { \mathrm { { t h } } }$ player with $| { \mathcal { A } } _ { i } | = A _ { i }$ Without loss of generality, we assume $\mathbf { \mathcal { A } } _ { i } = \left[ A _ { i } \right]$ . We let $\pmb { a } : = ( a _ { 1 } , \cdots , a _ { m } )$ denote the vector of joint actions taken by all the players and $\overset { \vartriangle } { \mathcal { A } } = \mathcal { A } _ { 1 } \times \cdots \times \mathcal { A } _ { m }$ denote the joint action space. Throughout this paper we assume that $S$ and $A _ { i }$ are finite. The transition probability $\mathbb { P } = \{ \mathbb { P } _ { h } \} _ { h \in [ H ] }$ is the collection of transition matrices, where $\mathbb { P } _ { h } ( \cdot | s , \pmb { a } ) \in \Delta _ { \mathcal { S } }$ denotes the distribution of the next state when actions $^ { a }$ are taken at state $s$ at step $h$ . The rewards $r _ { i } = \{ r _ { h , i } \} _ { h \in [ H ] , i \in [ m ] }$ is the collection of reward functions for the $i ^ { \mathrm { { t h } } }$ player, where $r _ { h , i } ( s , \pmb { a } ) \in [ 0 , 1 ]$ gives the deterministic1 reward of $i ^ { \mathrm { { t h } } }$ player if actions $\textbf { \em a }$ are taken at state $s$ at step $h$ . Without loss of generality, we assume the initial state $s _ { 1 }$ is deterministic. A key feature of general-sum games is that the rewards $r _ { i }$ are in general different for each player $i$ , and the goal of each player is to maximize her own cumulative reward. + +Markov product policy, value function A product policy is a collection of $m$ policies $\pi : =$ $\{ \pi _ { i } \} _ { i \in [ m ] }$ where $\pi _ { i }$ is the general (potentially history-dependent) policy for the $i$ -th player. We first focus on the case of Markov product policies, in which $\pi _ { i } = \{ \pi _ { h , i } : { \cal S } \Delta _ { A _ { i } } \} _ { h \in [ H ] }$ , and $\pi _ { h , i } ( \boldsymbol { a } _ { i } | \boldsymbol { s } )$ is the probability for the $i ^ { \mathrm { { t h } } }$ player to take action $a _ { i }$ at state $s$ at step $h$ . For a policy $\pi$ and $i \in [ m ]$ , we use $\pi _ { - i } : = \{ \pi _ { j } \} _ { j \in [ m ] , j \neq i }$ to denote the policy of all but the $i ^ { \mathrm { { t h } } }$ player. The value function $V _ { h , i } ^ { \pi } ( s ) : \mathcal { S } \mathbb { R }$ is defined as the expected cumulative reward for the $i ^ { \mathrm { { t h } } }$ player when policy $\pi$ is taken starting from state $s$ and step $h$ : + +$$ +V _ { h , i } ^ { \pi } ( s ) : = \mathbb { E } _ { \pi } \bigg [ \sum _ { h ^ { \prime } = h } ^ { H } r _ { h ^ { \prime } , i } ( s _ { h ^ { \prime } } , \mathbf { a } _ { h ^ { \prime } } ) \bigg | s _ { h } = s \bigg ] . +$$ + +Best response & Nash equilibrium For any product policy $\pi = \{ \pi _ { i } \} _ { i \in [ m ] }$ , the best response for the $i ^ { \mathrm { t h } }$ player against $\pi _ { - i }$ is defined as any policy $\pi ^ { \dagger }$ such that $\begin{array} { r } { V _ { 1 , i } ^ { { \pi ^ { \dagger } } , \pi _ { - i } } ( s _ { 1 } ) = \operatorname* { s u p } _ { \pi _ { i } ^ { \prime } } V _ { 1 , i } ^ { \pi _ { i } ^ { \prime } , \pi _ { - i } } ( s _ { 1 } ) } \end{array}$ For any Markov product policy, this best response is guaranteed to exist (and be Markov) as the above maximization problem is equivalent to solving a Markov Decision Process (MDP) for the $i ^ { \mathrm { { t h } } }$ player. We will also use the notation $V _ { 1 , i } ^ { \dag , \pi - i } \left( s _ { 1 } \right)$ to denote the above value function V π†,π−i (s1). + +We say $\pi$ is a Nash equilibrium (e.g. Nash (1951); Pérolat et al. (2017)) if all players play the best response against other players, i.e., for all $i \in [ m ]$ , + +$$ +V _ { 1 , i } ^ { \pi } ( s _ { 1 } ) = V _ { 1 , i } ^ { \dag , \pi - i } ( s _ { 1 } ) . +$$ + +Note that in general-sum MGs, there may exist multiple Nash equilibrium policies with different value functions, unlike in two-player zero-sum MGs (Shapley, 1953). To measure the suboptimality of any policy $\pi$ , we define the NE-gap as + +$$ +\operatorname { N E - g a p } ( \pi ) : = \operatorname* { m a x } _ { i \in [ m ] } \left[ \operatorname* { s u p } _ { \mu _ { i } } V _ { 1 , i } ^ { \mu _ { i } , \pi _ { - i } } ( s _ { 1 } ) - V _ { 1 , i } ^ { \pi } ( s _ { 1 } ) \right] . +$$ + +For any $\varepsilon \geq 0$ , we say $\pi$ is $\varepsilon$ -approximate Nash equilibrium $\dot { \varepsilon }$ -Nash) if $\mathrm { N E - g a p } ( \pi ) \leq \varepsilon$ + +General correlated policy $\pmb { \& }$ Its best response A general correlated policy $\pi$ is a set of $H$ maps $\pi : = \{ \pi _ { h } : \Omega \times ( \hat { S ^ { \mathrm { ~ \scriptstyle ~ \mathscr ~ { \cal ~ O } ~ } } } \times \bar { A } ) ^ { h - 1 } \times \bar { S } \to \bar { \Delta _ { A } } \} _ { h \in [ H ] }$ . The first argument of $\pi _ { h }$ is a random variable $\omega \in \Omega$ sampled from some underlying distribution, and the other arguments contain all the history information and the current state information (unlike Markov policies in which the policies only depend on the current state information). The output of $\pi _ { h }$ is a general distribution of actions in $\mathcal { A } = \mathcal { A } _ { 1 } \times \cdot \cdot \cdot \times \mathcal { A } _ { m }$ (unlike product policies in which the action distribution is a product distribution). + +For any correlated policy $\pi = \{ \pi _ { h } \} _ { h \in [ H ] }$ and any player $i$ , we can define a marginal policy $\pi _ { - i }$ as a set of $H$ maps $\pi _ { - i } ~ : = ~ \{ \pi _ { h , - i } ~ : ~ \dot { \Omega } \times ( \mathcal { S } \times \mathcal { A } ) ^ { h - 1 } \times \mathcal { S } ~ \to ~ \Delta _ { \mathcal { A } _ { - i } } \} _ { h \in [ H ] }$ where $A _ { - i } : =$ $\mathcal { A } _ { 1 } \times \cdot \cdot \cdot \times \mathcal { A } _ { i - 1 } \times \mathcal { A } _ { i + 1 } \times \cdot \cdot \cdot \times \mathcal { A } _ { m }$ , and the output of $\pi _ { h , - i }$ is defined as the marginal distribution of the output of $\pi _ { h }$ restricted to the space $A _ { - i }$ . For any general correlated policy $\pi$ , we can define its initial state value function $V _ { 1 , i } ^ { \pi } ( s _ { 1 } )$ similar as (1). The best response value of the $i ^ { \mathrm { { t h } } }$ player against $\pi$ is $V _ { 1 , i } ^ { \dagger , \pi _ { - i } } ( s _ { 1 } ) = \operatorname* { s u p } _ { \mu _ { i } } V _ { 1 , i } ^ { \mu _ { i } , \pi _ { - i } } ( s _ { 1 } )$ , where $V _ { 1 , i } ^ { \mu _ { i } , \pi - i } \left( s _ { 1 } \right)$ is the value function of the policy $( \mu _ { i } , \pi _ { - i } )$ (the $i ^ { \mathrm { { t h } } }$ player plays according to general policy $\mu _ { i }$ , and all other players play according to $\pi _ { - i }$ ), and the supremum is taken over all general policy $\mu _ { i }$ of the $i ^ { \mathrm { { t h } } }$ player. + +Learning setting Throughout this paper we consider the interactive learning (i.e. exploration) setting where algorithms are able to play episodes within the MG and observe the realized transitions and rewards. Our focus is on the PAC sample complexity (i.e. number of episodes of play) for any learning algorithm to output an approximate equilibrium. + +# 2.1 EXPONENTIAL LOWER BOUND FOR LEARNING APPROXIMATE NASH EQUILIBRIUM + +The focus of this paper is the setting where the number of players $m$ is large. Intuitively, as the joint action space has size $\textstyle | { \mathcal { A } } | = \prod _ { i = 1 } ^ { \bar { m } } A _ { i }$ which scales exponentially in $m$ (if each $A _ { i } \geq 2 $ ), naive algorithms for learning Nash equilibrium may learn all $r _ { i } ( { \pmb a } )$ by enumeratively querying all $\mathbf { \pmb { a } } \in \mathcal { A }$ , and this costs exponential in $m$ samples. Unfortunately, recent work shows that such exponential in $m$ dependence is unavoidable in the worst-case for any algorithm—there is an $\exp ( \Omega ( { \bar { m } } ) )$ sample complexity lower bound for learning approximate Nash, even in one-step general-sum games (Chen et al., 2015; Rubinstein, 2016) (see Proposition A.2 for formal statement). + +This suggests that the Nash equilibrium as a solution concept may be too hard to learn efficiently for MGs with a large number of players, and calls for alternative solution concepts or additional structural assumptions on the game in order to achieve an improved $m$ dependence. + +# 3 EFFICIENT LEARNING OF COARSE CORRELATED EQUILIBRIA (CCE) + +Given the difficulty of learning Nash when the number of players $m$ is large , we consider learning other relaxed notions of equilibria for general-sum MGs. Two standard notions of equilibria for games are the Correlated Equilibrium (CE) and Coarse Correlated Equilibrium (CCE), and they satisfy $\{ \mathrm { N a s h } \} \subset \{ \mathrm { C E } \} \subset \{ \mathrm { C C E } \}$ for general-sum MGs (Nisan et al., 2007). + +We begin by considering learning CCE (most relaxed notion above) for Markov games. + +Definition 1 ( $\varepsilon$ -approximate CCE for general-sum MGs). We say a (general) correlated policy π is an $\varepsilon$ -approximate Coarse Correlated Equilibrium ( $\varepsilon$ -CCE) $i f$ + +$$ +\operatorname* { m a x } _ { i \in [ m ] } \left( V _ { 1 , i } ^ { \dagger , \pi _ { - i } } ( s _ { 1 } ) - V _ { 1 , i } ^ { \pi } ( s _ { 1 } ) \right) \leq \varepsilon . +$$ + +We say π is an (exact) CCE if the above is satisfied with $\varepsilon = 0$ . + +The following result shows that there exists an algorithm that can learn an $\varepsilon$ -approximate CCE in general-sum Markov games within $\widetilde { \mathcal { O } } ( H ^ { 5 } S \operatorname* { m a x } _ { i \in [ m ] } A _ { i } / \varepsilon ^ { 2 } )$ episodes of play. + +Theorem 2 (Learning $\varepsilon$ -approximate CCE for general-sum MGs). Suppose we run the CCE-VLEARNING algorithm (Algorithm 4) for all $m$ players and + +$$ +K \geq \mathcal { O } \bigg ( \frac { H ^ { 5 } S \operatorname* { m a x } _ { i \in [ m ] } A _ { i } \iota } { \varepsilon ^ { 2 } } + \frac { H ^ { 4 } S \iota ^ { 3 } } { \varepsilon } \bigg ) +$$ + +episodes $\scriptstyle ( \iota = \log ( m \operatorname* { m a x } _ { i \in [ m ] } A _ { i } H S K / ( p \varepsilon ) )$ is a log factor). Then with probability at least $1 - p$ , the certified policy $\widehat { \pi }$ defined in Algorithm 2 is an $\varepsilon$ -CCE, i.e. $\begin{array} { r } { \operatorname* { m a x } _ { i \in [ m ] } ( V _ { 1 , i } ^ { \dagger , \widehat { \pi } _ { - i } } ( s _ { 1 } ) - V _ { 1 , i } ^ { \widehat { \pi } _ { + } } ( s _ { 1 } ) ) \leq \varepsilon } \end{array}$ + +Mild dependence on action space For small enough $\varepsilon$ , the sample complexity featured in Theorem 2 scales as $\widetilde { \mathcal { O } } ( H ^ { 5 } S \operatorname* { m a x } _ { i \in [ m ] } A _ { i } / \varepsilon ^ { 2 } )$ . Most notably, this is the first algorithm that scales with $\mathrm { m a x } _ { i \in [ m ] } A _ { i }$ , and exhibits a sharp difference in learning Nash and learning CCE in view of the $\exp ( \Omega ( m ) )$ lower bound for learning Nash in Proposition A.2. Indeed, existing algorithms such as Multi-Nash-VI Algorithm with CCE subroutine (Liu et al., 2021) does require $\begin{array} { r } { \widetilde { \mathcal { O } } ( H ^ { 4 } S ^ { 2 } \prod _ { i = 1 } ^ { m } A _ { i } / \varepsilon ^ { 2 } ) } \end{array}$ episodes of play, which scales with $\textstyle \prod _ { i \in [ m ] } A _ { i }$ due to its model-based nature. We achieve significantly better dependence on $A _ { i }$ and also $S$ , though slightly worse $H$ dependence. + +Overview of algorithm and techniques Our CCE-V-LEARNING algorithm (deferred to Appendix B.1 due to space limit) is a multi-player adaptation of the Nash V-Learning algorithm of Bai et al. (2020); Tian et al. (2021) for learning Nash equilibria in two-player zero-sum MGs. Similar as Bai et al. (2020), we show that this algorithm enjoys a “no-regret” like guarantee for each player at each $( h , s )$ (Lemma B.3). We also adopted the choice of hyperparameters in Tian et al. (2021) so that the sample complexity has a slightly better dependence in $H$ . When combined with the “certified correlated policy” procedure (Algorithm 2), our algorithm outputs a policy that is $\varepsilon$ -CCE. Our certified policy procedure is adapted from the certified policy of Bai et al. (2020), and differs in that ours output a correlated policy for all the players whereas Bai et al. (2020) outputs a product policy. The key feature enabling this $\mathrm { m a x } _ { i \in [ m ] } A _ { i }$ dependence is that this algorithm uses decentralized learning for each player to learn the value function $( V )$ , instead of learning the $Q$ function (as in Liu et al. (2021)) that requires sample size scales as $\textstyle \prod _ { i \in [ m ] } A _ { i }$ . The proof of Theorem 2 is in Appendix B. + +# 4 EFFICIENT LEARNING OF CORRELATED EQUILIBRIA (CE) + +In this section, we move on to considering the harder problem of learning Correlated Equilibria (CE). +We first present the definition of CE in Markov games. + +Definition 3 (Strategy modification for ith player). A strategy modification φ := {φh,s}(h,s)∈[H]×S for player $i$ is a set of $H \times S$ functions $\phi _ { h , s } : ( \mathcal { S } \times \mathcal { A } ) ^ { h - 1 } \times \mathcal { A } _ { i } \to \mathcal { A } _ { i }$ . A strategy modification $\phi$ can be composed with any policy $\pi$ to give a modified policy $\phi \diamond \pi$ defined as follows: At any step $h$ and state s with the history information $\tau _ { h - 1 } = ( s _ { 1 } , \pmb { a } _ { 1 } , \cdot \cdot \cdot , s _ { h - 1 } , \pmb { a } _ { h - 1 } )$ , if $\pi$ chooses to play $\pmb { a } = ( a _ { 1 } , \dots , a _ { m } )$ , the modified policy $\phi \diamond \pi$ will play $( a _ { 1 } , \dots , a _ { i - 1 } , \phi _ { h , s } ( \tau _ { h - 1 } , a _ { i } ) , a _ { i + 1 } , \dots , a _ { m } )$ . We use $\Phi _ { i }$ denote the set of all possible strategy modifications for player $i$ . + +Definition 4 ( $\varepsilon$ -approximate CE for general-sum MGs). We say $a$ (general) correlated policy $\pi$ is an $\varepsilon$ -approximate $C E \left( \varepsilon \mathbf { - } C E \right) i f$ + +$$ +\operatorname* { m a x } _ { i \in [ m ] } \operatorname* { s u p } _ { \phi \in \Phi _ { i } } \left( V _ { 1 , i } ^ { \phi \diamond \pi } ( s _ { 1 } ) - V _ { 1 , i } ^ { \pi } ( s _ { 1 } ) \right) \leq \varepsilon . +$$ + +We say $\pi$ is an (exact) $C E$ if the above is satisfied with $\varepsilon = 0$ . + +Our definition of CE follows (Liu et al., 2021) and is a natural generalization of the CE for the well-studied special case of one-step (i.e. normal form) games (Nisan et al., 2007). + +# 4.1 ALGORITHM DESCRIPTION + +Our algorithm CE-V-LEARNING (Algorithm 1) builds further on top of CCE-V-LEARNING and Nash V-Learning, and makes several novel modifications in order to learn the CE. The key feature of CE-V-LEARNING is that it uses a weighted swap regret algorithm (mixed-expert FTRL) for every $( s , h , i )$ . At a high-level, CE-V-LEARNING consists of the following steps: + +• Line 6-11 (Sample action using mixed-expert FTRL): For each $( h , s )$ we maintain $A _ { i }$ “subexperts” indexed by $b ^ { \prime } \in [ A _ { i } ]$ (Each sub-expert represents an independent “expert” that runs her own FTRL algorithm). Sub-expert $b ^ { \prime }$ first computes an action distribution $q ^ { \bar { b ^ { \prime } } } ( \cdot ) \in \Delta _ { \mathcal { A } _ { i } }$ via Follow-the-Regularized-Leader (FTRL; Line 8). Then we employ a two-step sampling procedure to obtain the action: First sample a sub-expert $b$ from a suitable distribution $\mu$ computed from $\{ q ^ { b ^ { \prime } } \} _ { b ^ { \prime } \in [ A _ { i } ] }$ , then sample the actual action $a _ { h , i }$ from $q ^ { b }$ . +• Line 13-17 (Take action and record observations): Player $i$ takes action $a _ { h , i }$ and observes other player’s actions, the reward, and the next state. Sub-expert $b$ then computes a loss estimator and weight according to the observations, which will be used in future FTRL updates. +• Line 19 (Optimistic value update): Updates the optimistic estimate of the value $\overline { { V } } _ { h , i }$ using step-size $\alpha _ { t }$ and bonus $\overline { { \beta } } _ { t }$ . + +Finally, after executing Algorithm 1 for $K$ episodes, we use the certified correlated policy procedure (Algorithm 2) to obtain our final output policy $\widehat { \pi }$ . This procedure is a direct modification of the bcertified policy procedure of (Bai et al., 2020) and outputs a correlated policy (because the randomly sampled $k$ and $l$ in line 1 and line 4 of Algorithm 2 are used by all the players) instead of product policy. The same procedure is also used for learning CCEs earlier in Section 3. + +Here we specify the hyperparameters used in Algorithm 1: + +$$ +\alpha _ { t } = ( H + 1 ) / ( H + t ) , \quad \eta _ { t } = \sqrt { \iota / ( A _ { i } t ) } , \quad \overline { { \beta } } _ { t } = c H ^ { 2 } A _ { i } \sqrt { \iota / t } + 2 c H ^ { 2 } \iota / t . +$$ + +The constants $\alpha _ { t } ^ { j }$ used in Algorithm 2 is defined as + +$$ +\begin{array} { r } { \alpha _ { t } ^ { 0 } : = \prod _ { k = 1 } ^ { t } \left( 1 - \alpha _ { k } \right) , \alpha _ { t } ^ { j } : = \alpha _ { j } \prod _ { k = j + 1 } ^ { t } \left( 1 - \alpha _ { k } \right) . } \end{array} +$$ + +Note that for any $t \geq 1$ , $\{ \alpha _ { t } ^ { j } \} _ { 1 \leq j \leq t }$ sums to one and defines a distribution over $[ t ]$ . + +# 4.2 OVERVIEW OF TECHNIQUES + +Here we briefly overview the techniques used in Algorithm 1. + +Minimizing swap regret via mixed-expert FTRL The key technical advance in our Algorithm 1 over CCE-V-LEARNING and Nash V-Learning is the use of mixed-expert FTRL (Line 6-11). The purpose of this is to allow the algorithm to achieve low swap regret at each $( h , s )$ in a suitable sense—For one-step (normal form) games, it is known that combining low-swap-regret learning for each player leads to an approximate CE (Stoltz, 2005; Cesa-Bianchi & Lugosi, 2006). To integrate this into Markov games, we utilize a celebrated reduction from low-swap-regret learning to usual low-regret learning (Blum & Mansour, 2007), which for any bandit problem with $A _ { i }$ actions maintains $A _ { i }$ sub-experts each running its own FTRL algorithm. Our particular application builds upon the two-step randomization scheme of Ito (2020) which first samples a sub-expert $b$ and the action from this sub-expert. The distribution $\mu ( \cdot )$ for sampling the sub-expert is carefully chosen by solving a linear system (Line 10) so that $\mu$ also coincides with the (marginal) distribution of the sampled action, from which the reduction follows. + +FTRL with predictable weights Applied naively, the above reduction does not directly work for our purpose, as our analysis requires minimizing the weighted swap regret with weights $\alpha _ { t } ^ { i }$ , whereas the reduction of Ito (2020) relies crucially on the vanilla (average) regret. We address this challenge by using a slightly modified FTRL algorithm for each sub-expert that takes in random but predictable weights (i.e. depending fully on prior information and “external” randomness). We present the analysis for such FTRL algorithm in Appendix F.4, and the consequent analysis for the weighted swap regret in Appendix F.1-F.3, both of which may be of independent interest. + +Proposal distributions Finally, a nuanced but important new design in CE-V-LEARNING is that all sub-experts compute a proposal action distribution to sample the sub-expert and the associated action. + +# Algorithm 1 CE-V-LEARNING for general-sum MGs $_ i$ -th player’s version) + +Require: Hyperparameters: $\begin{array} { r } { \{ \alpha _ { t } ^ { j } \} _ { 1 \leq j \leq t \leq K } , \{ \alpha _ { t } \} _ { 1 \leq t \leq K } , \{ \eta _ { t } \} _ { 1 \leq t \leq K } , \{ \bar { \beta } _ { t } \} _ { 1 \leq t \leq K } . } \end{array}$ + +1: Initialize: For any $( s , a , h )$ , set $\overline { { V } } _ { h , i } ( s ) H$ , $N _ { h } ( s ) \gets 0$ . Set $\mu _ { h } ( a | s ) 1 / A _ { i }$ , $q _ { h } ^ { b ^ { \prime } } ( a | s ) \gets$ $1 / A _ { i }$ , $\ell _ { h , t } ^ { b ^ { \prime } } ( a | s ) \gets 0$ , $N _ { h } ^ { b ^ { \prime } } ( s ) \gets 0$ for all $( b ^ { \prime } , a , h , s , t ) \in [ A _ { i } ] \times [ A _ { i } ] \times [ H ] \times \mathcal { S } \times [ K ]$ . + +2: for episode $k = 1 , \ldots , K$ do + +3: Receive $s _ { 1 }$ + +4: for step $h = 1 , \ldots , H$ do + +// Compute proposal action distributions by FTRL + +Let $t _ { b ^ { \prime } } \gets N _ { h } ^ { b ^ { \prime } } ( s _ { h } )$ for all $b ^ { \prime } \in [ A _ { i } ]$ for shorthand. + +8: Compute the action distribution for all sub-experts $b ^ { \prime } \in [ A _ { i } ]$ : + +$$ +\begin{array} { r } { q _ { h } ^ { b ^ { \prime } } ( a | s _ { h } ) \propto _ { a } \exp \big ( - ( \eta _ { t _ { b ^ { \prime } } } / u _ { t } ) \sum _ { \tau = 1 } ^ { t _ { b ^ { \prime } } } w _ { h , \tau } ( b ^ { \prime } | s _ { h } ) \ell _ { h , \tau } ^ { b ^ { \prime } } ( a | s _ { h } ) \big ) . } \end{array} +$$ + +// Sample sub-expert $b$ and action from $q ^ { b } ( \cdot )$ + +Compute $\mu _ { h } ( \cdot | s _ { h } ) \in \Delta _ { [ A _ { i } ] }$ by solving $\begin{array} { r } { \mu _ { h } ( \cdot | s _ { h } ) = \sum _ { b ^ { \prime } = 1 } ^ { A _ { i } } \mu _ { h } ( b ^ { \prime } | s _ { h } ) q _ { h } ^ { b ^ { \prime } } ( \cdot | s _ { h } ) . } \end{array}$ + +// Take action and feed the observations to sub-expert $b$ + +14: Observe reward $r _ { h , i } = r _ { h , i } ( s _ { h } , a _ { h , i } , { \pmb a } _ { h , - i } )$ and the next state $s _ { h + 1 }$ from the environment. + +15: Update accumulator for the sampled sub-expert: $t _ { b } : = N _ { h } ^ { b } ( s _ { h } ) \gets N _ { h } ^ { b } ( s _ { h } ) + 1$ . + +16: Compute and update loss estimator + +$$ +\ell _ { h , t _ { b } } ^ { b } ( a | s _ { h } ) \gets \frac { \left[ H - h + 1 - ( r _ { h , i } + \operatorname* { m i n } \{ \overline { { V } } _ { h + 1 , i } ( s _ { h + 1 } ) , H - h \} ) \right] / H \cdot \mathbf { 1 } \{ a _ { h , i } = a \} } { q _ { h } ^ { b } ( a | s _ { h } ) + \eta _ { t _ { b } } } . +$$ + +17: Set $w _ { h , t _ { b } } ( b | s _ { h } ) \gets u _ { t }$ + +8: // Optimistic value update + +$$ +\begin{array} { r } { \overline { { V } } _ { h , i } \widetilde { ( s _ { h } ) } ( 1 - \alpha _ { t } ) \overline { { V } } _ { h , i } ( s _ { h } ) + \alpha _ { t } \big ( r _ { h , i } ( s _ { h } , a _ { h , i } , \mathbf { a } _ { h , - i } ) + \overline { { V } } _ { h + 1 , i } ( s _ { h + 1 } ) + \overline { { \beta } } _ { t } \big ) . } \end{array} +$$ + +# Algorithm 2 Certified correlated policy $\widehat { \pi }$ for general-sum MGs + +1: Sample $k \gets \operatorname { U n i f o r m } ( [ K ] )$ . +2: for step $h = 1 , \ldots , H$ do +3: Observe $s _ { h }$ , and set $t \gets N _ { h } ^ { k } ( s _ { h } )$ (the value of $N _ { h } ( s _ { h } )$ at the beginning of the $k$ ’th episode). +4: Sample $l \in [ t ]$ with $\mathbb { P } ( l = j ) = \alpha _ { t } ^ { j }$ (c.f. Eq. (3)). +5: Update $k \gets k _ { h } ^ { l } ( s _ { h } )$ (the episode at the end of which the state $s _ { h }$ is observed exactly $l$ times). +6: Jointly take action $\begin{array} { r } { ( a _ { h , 1 } , a _ { h , 2 } , \ldots , a _ { h , m } ) \sim \prod _ { i = 1 } ^ { m } \mu _ { h , i } ^ { k } ( \cdot | s _ { h } ) } \end{array}$ , where $\mu _ { h , i } ^ { k } ( \cdot | s _ { h } )$ is the policy +$\mu _ { h , i } ( \cdot | s _ { h } )$ at the beginning of the $k ^ { \mathrm { : } }$ ’th episode. + +Then, only the sampled sub-expert takes this action, and all other proposal distributions are discarded. This is different from the original algorithms of (Blum & Mansour, 2007; Ito, 2020) in which the FTRL update come after the sub-expert sampling and only happens for the sampled sub-expert. Our design is required here as otherwise the sub-experts are required to predict the next time when it is sampled in order to compute the weighted FTRL update, which is impossible. + +# 4.3 THEORETICAL GUARANTEE + +We are now ready to present the theoretical guarantee for our CE-V-LEARNING algorithm. + +Theorem 5 (Learning $\varepsilon$ -approximate CE for general-sum MGs). Suppose we run the CE-VLEARNING algorithm (Algorithm 1) for all m players for + +$$ +K \geq \mathcal { O } \bigg ( \frac { H ^ { 6 } S \operatorname* { m a x } _ { i \in [ m ] } A _ { i } ^ { 2 } \iota } { \varepsilon ^ { 2 } } + \frac { H ^ { 4 } S \operatorname* { m a x } _ { i \in [ m ] } A _ { i } \iota ^ { 3 } } { \varepsilon } \bigg ) +$$ + +episodes $\begin{array} { l c l } { ( \iota } & { = } & { \log ( m \operatorname* { m a x } _ { i \in [ m ] } A _ { i } H S K / ( p \varepsilon ) ) } \end{array}$ is a log factor). Then with probability at least $1 \ - \ p ,$ , the certified correlated policy $\widehat { \pi }$ defined in Algorithm 2 is an $\varepsilon$ -CE, i.e. $\begin{array} { r } { \operatorname* { m a x } _ { i \in [ m ] } \operatorname* { s u p } _ { \phi \in \Phi _ { i } } ( V _ { 1 , i } ^ { \phi \diamond \widehat { \pi } } ( s _ { 1 } ) - V _ { 1 , i } ^ { \widehat { \pi } } ( s _ { 1 } ) ) \leq \varepsilon } \end{array}$ . + +Discussions To the best of our knowledge, Theorem 5 presents the first result for learning CE that scales polynomially with $\mathrm { m a x } _ { i \in [ m ] } A _ { i }$ , which is significantly better than the best known existing algorithm of Multi-Nash-VI with CE subroutine (Liu et al., 2021) whose sample complexity scales with $\textstyle \prod _ { i \in [ m ] } A _ { i }$ . Similar as in Theorem 2, this follows as our CE-V-LEARNING uses decentralized learning for each player to learn the value function $( V )$ . We also observe that our sample complexity for learning CE is higher than for learning CCE by a factor of $\widetilde { \mathcal { O } } ( H \operatorname* { m a x } _ { i \in [ m ] } A _ { i } )$ ; the additional $\mathrm { m a x } _ { i \in [ m ] } A _ { i }$ factor is expected as CE is a strictly harder notion of equilibrium. The proof of Theorem 5 can be found in Appendix C. + +# 5 LEARNING NASH EQUILIBRIA IN MARKOV POTENTIAL GAMES + +In this section, we consider learning Nash equilibria in Markov Potential Games (MPGs), an important subclass of general-sum MGs. Despite the curse of number of players of learning Nash in general-sum MGs, recent work shows that learning Nash in MPGs does not require sample size exponential in $m$ by using stochastic policy gradient based algorithms (Leonardos et al., 2021; Zhang et al., 2021). In this section, we provide an alternative algorithm NASH-CA that also achieves a mild dependence on $m$ and an improved dependence on $\varepsilon$ by a simple reduction to single-agent learning. + +# 5.1 MARKOV POTENTIAL GAMES + +We first present the definition of MPGs. Our definition is the finite-horizon variant2 of the definitions of Macua et al. (2018); Leonardos et al. (2021); Zhang et al. (2021) and is slightly more general as we only require (4) on the total return. Throughout this section, $\pi$ denotes a Markov product policy. + +Definition 6. (Markov potential games) $A$ general-sum Markov game is a Markov potential game $i f$ there exists a potential function $\Phi$ mapping any product policy to a real number in $[ 0 , \Phi _ { \mathrm { m a x } } ]$ , such that for any $i \in [ m ]$ , any two policies $\pi _ { i } , \pi _ { i } ^ { \prime }$ of the $i ^ { t h }$ player, and any policy $\pi _ { - i }$ of other players, the difference of the value functions of the $i ^ { t h }$ player with policies $( \pi _ { i } , \pi _ { - i } )$ and $( \pi _ { i } ^ { \prime } , \pi _ { - i } )$ is equals the difference of the potential function on the same policies, i.e., + +$$ +V _ { 1 , i } ^ { \pi _ { i } , \pi _ { - i } } ( s _ { 1 } ) - V _ { 1 , i } ^ { \pi _ { i } ^ { \prime } , \pi _ { - i } } ( s _ { 1 } ) = \Phi ( \pi _ { i } , \pi _ { - i } ) - \Phi ( \pi _ { i } ^ { \prime } , \pi _ { - i } ) . +$$ + +Note that the range of the potential function $\Phi _ { \mathrm { m a x } }$ admits a trivial upper bound $\Phi _ { \mathrm { m a x } } \le m H$ (this can be seen by varying $\pi _ { i }$ for one $i$ at a time). An important example of MPGs is Markov Cooperative Games (MCGs) where all players share the same reward $r _ { i } \equiv r$ . + +# 5.2 ALGORITHM AND THEORETICAL GUARANTEE + +We present a simple algorithm NASH-CA (Nash Coordinate Ascent) for learning an $\varepsilon$ -Nash in MPGs. As its name suggests, the algorithm operates by solving single-agent Markov Decision Processes (MDPs) one player at a time, and intrinsically performing coordinate ascent on the potential function of the Markov game. Due to the potential structure of MPGs and the boundedness of the potential function, the local improvements of players across the steps can have an accumulative effect on the potential function, and the algorithm is guaranteed to stop after a bounded number of steps. We give the full description of the NASH-CA in Algorithm 3. We remark that NASH-CA is additionally guaranteed to output a pure-strategy Nash equilibrium (cf. Appendix D for definition). + +Theorem 7 (Sample complexity for NASH-CA). For Markov potential games, with probability at least $1 - p$ , Algorithm 3 terminates within $4 \Phi _ { m a x } / \varepsilon$ steps of the while loop, and outputs an $\varepsilon$ -approximate (pure-strategy) Nash equilibrium. The total episodes of play is at most + +$$ +K = { \mathcal O } \left( \frac { \Phi _ { \mathrm { m a x } } H ^ { 3 } S \sum _ { i = 1 } ^ { m } A _ { i } \iota } { \varepsilon ^ { 3 } } + \frac { \Phi _ { \mathrm { m a x } } H ^ { 3 } S ^ { 2 } \sum _ { i = 1 } ^ { m } A _ { i } \iota ^ { 2 } } { \varepsilon ^ { 2 } } \right) , +$$ + +where $\begin{array} { r } { \iota = \log ( \frac { m H S K \operatorname* { m a x } _ { 1 \leq i \leq m } A _ { i } } { \varepsilon p } ) } \end{array}$ is a log factor. + +2Our results can easily adapted to the discounted infinite time horizon setup. + +# Algorithm 3 NASH-CA for Markov potential games + +Require: Error tolerance $\varepsilon$ + +1: Initialize: $\pi = \{ \pi _ { i } \} _ { i \in [ m ] }$ , where $\pi _ { i } = \{ \pi _ { h , i } \} _ { ( h , i ) \in [ H ] \times [ m ] }$ for some deterministic policy $\pi _ { h , i }$ . +2: while true do +3: Execute policy of the total ret $\pi$ for un $\begin{array} { r } { N = \Theta ( \frac { H ^ { 2 } \iota } { \varepsilon ^ { 2 } } ) } \end{array}$ episodes and obtain $\widehat { V } _ { 1 , i } ( \pi )$ which is the empirical average $\pi$ +4: for player $i = 1 , \ldots , m$ do +5: Fix $\pi _ { - i }$ , and let the $i ^ { \mathrm { { t h } } }$ player run UCBVI-UPLOW (Algorithm 7) for $\begin{array} { r } { K _ { i } = \Theta ( \frac { H ^ { 3 } S A _ { i } \iota } { \varepsilon ^ { 2 } } + } \end{array}$ H3S2Aiι2ε ) episodes and get a new deterministic policy πi. +6: Execute policy $( \widehat { \pi } _ { i } , \pi _ { - i } )$ for $\begin{array} { r } { N = \Theta ( \frac { H ^ { 2 } \iota } { \varepsilon ^ { 2 } } ) } \end{array}$ b episodes and obtain $\widehat { V } _ { 1 , i } \big ( \widehat { \pi } _ { i } , \pi _ { - i } \big )$ which is the bempirical average of the total return under policy $( \widehat { \pi } _ { i } , \pi _ { - i } )$ . +7: Set $\Delta _ { i } \gets \widehat { V } _ { 1 , i } ( \widehat { \pi } _ { i } , \pi _ { - i } ) - \widehat { V } _ { 1 , i } ( \pi )$ . +8: if $\operatorname* { m a x } _ { i \in [ m ] } \Delta _ { i } > \varepsilon / 2$ then +9: Update $\dot { \pi } _ { j } \widehat { \pi } _ { j }$ where $j = \arg \operatorname* { m a x } _ { i \in [ m ] } \Delta _ { i }$ . +10: else +11: return $\pi$ + +Discussions For small enough $\varepsilon$ , the sample complexity for the NASH-CA algorithm in the above theorem is $\begin{array} { r } { \widetilde { \mathcal { O } } ( \Phi _ { \operatorname* { m a x } } H ^ { 3 } S \sum _ { i \le m } A _ { i } / \varepsilon ^ { 3 } ) } \end{array}$ . As $\Phi _ { \mathrm { m a x } } \le m H$ , this at most scales with the number of players as $m \sum _ { i \leq m } A _ { i }$ , which is much better than the exponential in $m$ sample complexity for general-sum MGs without additional structures. Compared with recent results on learning Nash via policy gradients (Leonardos et al., 2021; Zhang et al., 2021), the NASH-CA algorithm also achieves $\operatorname { p o l y } ( m , \operatorname* { m a x } _ { i \leq m } A _ { i } )$ dependence, and significantly improves on the $\varepsilon$ dependence from their $\varepsilon ^ { - 6 }$ to $\varepsilon ^ { - 3 }$ . In addition, our algorithm does not require assumptions on bounded distribution mismatch coefficient as they do, due to the exploration nature of our single-agent MDP subroutine. + +Also, compared with the sample complexity bound $\begin{array} { r } { \widetilde { \mathcal { O } } ( H ^ { 4 } S ^ { 2 } \prod _ { i = 1 } ^ { m } A _ { i } / \varepsilon ^ { 2 } ) } \end{array}$ of the Nash-VI algorithm (Liu et al., 2021) for general-sum MGs (not restricted to MPGs), our NASH-CA algorithm doesn’t suffer from the exponential dependence on $m$ thanks to the MPG structure. We do achieve a looser in the dependence on $\varepsilon$ , yet overall our sample complexity is still better unless $\textstyle \varepsilon < ( \sum _ { i = 1 } ^ { m } A _ { i } ) / ( \prod _ { i = 1 } ^ { m } \bar { A } _ { i } )$ is exponentially small. The proof of Theorem 7 can be found in Appendix D. + +A lower bound To accompany Theorem 7, we establish a sample complexity lower bound of $\begin{array} { r } { \Omega ( H ^ { 2 } \sum _ { i = 1 } ^ { m } A _ { i } / \varepsilon ^ { 2 } ) } \end{array}$ for learning pure-strategy Nash in MCGs and hence MPGs (Theorem E.1 in Appendix E). This lower bound improves in the $A _ { i }$ dependence over the naive reduction to singleplayer MDPs (Domingues et al., 2021), which gives $\scriptstyle { \dot { \Omega } } ( H ^ { 3 } S \operatorname* { m a x } _ { i \in [ m ] } A _ { i } / \varepsilon ^ { 2 } )$ , though is loose on the $S , H$ dependence. The improved $A _ { i }$ dependence is achieved by constructing a novel class of hard instances of on one-step games (Lemma E.2), which may be of further technical interest. However, there is still a large gap between these lower bounds and the best current upper bound of either our $\widetilde { \mathcal { O } } ( \sum _ { i = 1 } ^ { m } A _ { i } / \varepsilon ^ { 3 } )$ or the $\scriptstyle { \widetilde { \mathcal { O } } } ( \prod _ { i = 1 } ^ { m } A _ { i } / \varepsilon ^ { 2 } )$ of Liu et al. (2021), which we leave as future work. + +# 6 CONCLUSION + +This paper investigates the question of when can we solve general-sum Markov games (MGs) sampleefficiently with a mild dependence on the number of players. Our results show that this is possible for learning approximate (Coarse) Correlated Equilibria in general-sum MGs, as well as learning approximate Nash equilibrium in Markov potential games. In both cases, our sample complexity bounds improve over existing results in many aspects. Our work opens up many interesting directions for future work, such as sharper algorithms for both problems, sample complexity lower bounds, or how to perform sample-efficient learning in general-sum MGs with function approximations. In addition to Markov potential games, it would also be interesting to explore alternative structural assumptions that permit sample-efficient learning. + +# ACKNOWLEDGEMENT + +Ziang Song is partially supported by the elite undergraduate training program of School of Mathematical Sciences in Peking University. + +# REFERENCES + +Alekh Agarwal, Sham M Kakade, Jason D Lee, and Gaurav Mahajan. On the theory of policy gradient methods: Optimality, approximation, and distribution shift. Journal of Machine Learning Research, 22(98):1–76, 2021. + +Mohammad Gheshlaghi Azar, Ian Osband, and Rémi Munos. Minimax regret bounds for reinforcement learning. In International Conference on Machine Learning, pp. 263–272. PMLR, 2017. + +Yakov Babichenko. Query complexity of approximate nash equilibria. Journal of the ACM (JACM), 63(4):1–24, 2016. + +Yakov Babichenko and Siddharth Barman. Query complexity of correlated equilibrium. ACM Transactions on Economics and Computation (TEAC), 3(4):1–9, 2015. + +Yu Bai and Chi Jin. Provable self-play algorithms for competitive reinforcement learning. In International Conference on Machine Learning, pp. 551–560. PMLR, 2020. + +Yu Bai, Chi Jin, and Tiancheng Yu. Near-optimal reinforcement learning with self-play. Advances in Neural Information Processing Systems, 33, 2020. + +Yu Bai, Chi Jin, Huan Wang, and Caiming Xiong. Sample-efficient learning of stackelberg equilibria in general-sum games. arXiv preprint arXiv:2102.11494, 2021. + +Bowen Baker, Ingmar Kanitscheider, Todor Markov, Yi Wu, Glenn Powell, Bob McGrew, and Igor Mordatch. Emergent tool use from multi-agent autocurricula. arXiv preprint arXiv:1909.07528, 2019. + +Christopher Berner, Greg Brockman, Brooke Chan, Vicki Cheung, Przemysław D˛ebiak, Christy Dennison, David Farhi, Quirin Fischer, Shariq Hashme, Chris Hesse, et al. Dota 2 with large scale deep reinforcement learning. arXiv preprint arXiv:1912.06680, 2019. + +Avrim Blum and Yishay Mansour. From external to internal regret. Journal of Machine Learning Research, 8(6), 2007. + +Andrea Celli, Alberto Marchesi, Gabriele Farina, and Nicola Gatti. No-regret learning dynamics for extensive-form correlated equilibrium. arXiv preprint arXiv:2004.00603, 2020. + +Nicolo Cesa-Bianchi and Gábor Lugosi. Prediction, learning, and games. Cambridge university press, 2006. + +Xi Chen and Binghui Peng. Hedging in games: Faster convergence of external and swap regrets. arXiv preprint arXiv:2006.04953, 2020. + +Xi Chen, Yu Cheng, and Bo Tang. Well-supported versus approximate nash equilibria: Query complexity of large games. arXiv preprint arXiv:1511.00785, 2015. + +Zixiang Chen, Dongruo Zhou, and Quanquan Gu. Almost optimal algorithms for two-player markov games with linear function approximation. arXiv preprint arXiv:2102.07404, 2021. + +Johanne Cohen, Amélie Héliou, and Panayotis Mertikopoulos. Learning with bandit feedback in potential games. In Proceedings of the 31st International Conference on Neural Information Processing Systems, pp. 6372–6381, 2017a. + +Michael B Cohen, Jonathan Kelner, John Peebles, Richard Peng, Anup B Rao, Aaron Sidford, and Adrian Vladu. Almost-linear-time algorithms for markov chains and new spectral primitives for directed graphs. In Proceedings of the 49th Annual ACM SIGACT Symposium on Theory of Computing, pp. 410–419, 2017b. + +Christoph Dann and Emma Brunskill. Sample complexity of episodic fixed-horizon reinforcement learning. arXiv preprint arXiv:1510.08906, 2015. + +Constantinos Daskalakis. On the complexity of approximating a nash equilibrium. ACM Transactions on Algorithms (TALG), 9(3):1–35, 2013. + +Constantinos Daskalakis, Maxwell Fishelson, and Noah Golowich. Near-optimal no-regret learning in general games. arXiv preprint arXiv:2108.06924, 2021. + +Omar Darwiche Domingues, Pierre Ménard, Emilie Kaufmann, and Michal Valko. Episodic reinforcement learning in finite mdps: Minimax lower bounds revisited. In Algorithmic Learning Theory, pp. 578–598. PMLR, 2021. + +Gabriele Farina, Andrea Celli, Alberto Marchesi, and Nicola Gatti. Simple uncoupled no-regret learning dynamics for extensive-form correlated equilibrium. arXiv preprint arXiv:2104.01520, 2021. + +John Fearnley and Rahul Savani. Finding approximate nash equilibria of bimatrix games via payoff queries. ACM Transactions on Economics and Computation (TEAC), 4(4):1–19, 2016. + +John Fearnley, Martin Gairing, Paul W Goldberg, and Rahul Savani. Learning equilibria of games via payoff queries. J. Mach. Learn. Res., 16:1305–1344, 2015. + +Paul W Goldberg and Aaron Roth. Bounds for the query complexity of approximate equilibria. ACM Transactions on Economics and Computation (TEAC), 4(4):1–25, 2016. + +Richard W Hamming. Error detecting and error correcting codes. The Bell system technical journal, 29(2):147–160, 1950. + +Thomas Dueholm Hansen, Peter Bro Miltersen, and Uri Zwick. Strategy iteration is strongly polynomial for 2-player turn-based stochastic games with a constant discount factor. Journal of the ACM (JACM), 60(1):1–16, 2013. + +Sergiu Hart. Adaptive heuristics. Econometrica, 73(5):1401–1430, 2005. + +Sergiu Hart and Andreu Mas-Colell. A simple adaptive procedure leading to correlated equilibrium. Econometrica, 68(5):1127–1150, 2000. + +Sergiu Hart and Noam Nisan. The query complexity of correlated equilibria. Games and Economic Behavior, 108:401–410, 2018. + +Junling Hu and Michael P Wellman. Nash q-learning for general-sum stochastic games. Journal of machine learning research, 4(Nov):1039–1069, 2003. + +Baihe Huang, Jason D Lee, Zhaoran Wang, and Zhuoran Yang. Towards general function approximation in zero-sum markov games. arXiv preprint arXiv:2107.14702, 2021. + +Shinji Ito. A tight lower bound and efficient reduction for swap regret. Advances in Neural Information Processing Systems, 33, 2020. + +Chi Jin, Zeyuan Allen-Zhu, Sebastien Bubeck, and Michael I Jordan. Is q-learning provably efficient? In Proceedings of the 32nd International Conference on Neural Information Processing Systems, pp. 4868–4878, 2018. + +Chi Jin, Qinghua Liu, and Tiancheng Yu. The power of exploiter: Provable multi-agent rl in large state spaces. arXiv preprint arXiv:2106.03352, 2021. + +Robert Kleinberg, Georgios Piliouras, and Éva Tardos. Multiplicative updates outperform generic no-regret learning in congestion games. In Proceedings of the forty-first annual ACM symposium on Theory of computing, pp. 533–542, 2009. + +Tor Lattimore and Csaba Szepesvári. Bandit algorithms. Cambridge University Press, 2020. + +Stefanos Leonardos, Will Overman, Ioannis Panageas, and Georgios Piliouras. Global convergence of multi-agent policy gradient in markov potential games. arXiv preprint arXiv:2106.01969, 2021. + +Michael L Littman. Markov games as a framework for multi-agent reinforcement learning. In Machine learning proceedings 1994, pp. 157–163. Elsevier, 1994. + +Michael L Littman. Friend-or-foe q-learning in general-sum games. In ICML, volume 1, pp. 322–328, 2001. + +Qinghua Liu, Tiancheng Yu, Yu Bai, and Chi Jin. A sharp analysis of model-based reinforcement learning with self-play. In International Conference on Machine Learning, pp. 7001–7010. PMLR, 2021. + +Ryan Lowe, Yi Wu, Aviv Tamar, Jean Harb, Pieter Abbeel, and Igor Mordatch. Multi-agent actorcritic for mixed cooperative-competitive environments. arXiv preprint arXiv:1706.02275, 2017. + +Sergio Valcarcel Macua, Javier Zazo, and Santiago Zazo. Learning parametric closed-loop policies for markov potential games. In International Conference on Learning Representations, 2018. + +Dustin Morrill, Ryan D’Orazio, Marc Lanctot, James R Wright, Michael Bowling, and Amy R Greenwald. Efficient deviation types and learning for hindsight rationality in extensive-form games. In International Conference on Machine Learning, pp. 7818–7828. PMLR, 2021. + +John Nash. Non-cooperative games. Annals of mathematics, pp. 286–295, 1951. + +Gergely Neu. Explore no more: Improved high-probability regret bounds for non-stochastic bandits. arXiv preprint arXiv:1506.03271, 2015. + +Noam Nisan, Tim Roughgarden, Eva Tardos, and Vijay V Vazirani. Algorithmic Game Theory. Cambridge University Press, 2007. + +Gerasimos Palaiopanos, Ioannis Panageas, and Georgios Piliouras. Multiplicative weights update with constant step-size in congestion games: Convergence, limit cycles and chaos. arXiv preprint arXiv:1703.01138, 2017. + +Julien Pérolat, Florian Strub, Bilal Piot, and Olivier Pietquin. Learning nash equilibrium for generalsum markov games from batch data. In Artificial Intelligence and Statistics, pp. 232–241. PMLR, 2017. + +Aviad Rubinstein. Settling the complexity of computing approximate two-player nash equilibria. In 2016 IEEE 57th Annual Symposium on Foundations of Computer Science (FOCS), pp. 258–265. IEEE, 2016. + +Lloyd S Shapley. Stochastic games. Proceedings of the national academy of sciences, 39(10): 1095–1100, 1953. + +David Silver, Aja Huang, Chris J Maddison, Arthur Guez, Laurent Sifre, George Van Den Driessche, Julian Schrittwieser, Ioannis Antonoglou, Veda Panneershelvam, Marc Lanctot, et al. Mastering the game of go with deep neural networks and tree search. nature, 529(7587):484–489, 2016. + +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. + +Gilles Stoltz. Incomplete information and internal regret in prediction of individual sequences. PhD thesis, Université Paris Sud-Paris XI, 2005. + +Vasilis Syrgkanis, Alekh Agarwal, Haipeng Luo, and Robert E Schapire. Fast convergence of regularized learning in games. arXiv preprint arXiv:1507.00407, 2015. + +Yi Tian, Yuanhao Wang, Tiancheng Yu, and Suvrit Sra. Online learning in unknown markov games. In International Conference on Machine Learning, pp. 10279–10288. PMLR, 2021. + +Alexander Trott, Sunil Srinivasa, Douwe van der Wal, Sebastien Haneuse, and Stephan Zheng. Building a foundation for data-driven, interpretable, and robust policy design using the ai economist. arXiv preprint arXiv:2108.02904, 2021. + +Oriol Vinyals, Igor Babuschkin, Wojciech M Czarnecki, Michaël Mathieu, Andrew Dudzik, Junyoung Chung, David H Choi, Richard Powell, Timo Ewalds, Petko Georgiev, et al. Grandmaster level in starcraft ii using multi-agent reinforcement learning. Nature, 575(7782):350–354, 2019. + +Bernhard Von Stengel and Françoise Forges. Extensive-form correlated equilibrium: Definition and computational complexity. Mathematics of Operations Research, 33(4):1002–1022, 2008. + +Jun Wang, Weinan Zhang, and Shuai Yuan. Display advertising with real-time bidding (rtb) and behavioural targeting. arXiv preprint arXiv:1610.03013, 2016. + +Qiaomin Xie, Yudong Chen, Zhaoran Wang, and Zhuoran Yang. Learning zero-sum simultaneousmove markov games using function approximation and correlated equilibrium. In Conference on Learning Theory, pp. 3674–3682. PMLR, 2020. + +Tengyang Xie, Nan Jiang, Huan Wang, Caiming Xiong, and Yu Bai. Policy finetuning: Bridging sample-efficient offline and online reinforcement learning. arXiv preprint arXiv:2106.04895, 2021. + +Yaodong Yang, Rui Luo, Minne Li, Ming Zhou, Weinan Zhang, and Jun Wang. Mean field multiagent reinforcement learning. In International Conference on Machine Learning, pp. 5571–5580. PMLR, 2018. + +Chao Yu, Akash Velu, Eugene Vinitsky, Yu Wang, Alexandre Bayen, and Yi Wu. The surprising effectiveness of mappo in cooperative, multi-agent games. arXiv preprint arXiv:2103.01955, 2021. + +Kaiqing Zhang, Sham M Kakade, Tamer Ba¸sar, and Lin F Yang. Model-based multi-agent rl in zero-sum markov games with near-optimal sample complexity. arXiv preprint arXiv:2007.07461, 2020. + +Runyu Zhang, Zhaolin Ren, and Na Li. Gradient play in multi-agent markov stochastic games: Stationary points and convergence. arXiv preprint arXiv:2106.00198, 2021. + +Stephan Zheng, Alexander Trott, Sunil Srinivasa, Nikhil Naik, Melvin Gruesbeck, David C Parkes, and Richard Socher. The ai economist: Improving equality and productivity with ai-driven tax policies. arXiv preprint arXiv:2004.13332, 2020. + +# A EXPONENTIAL IN m LOWER BOUND FOR LEARNING NASH IN GENERAL-SUM MGS + +In this section, we give a sample complexity lower bound for computing approximate Nash equilibrium in one-step binary-action general-sum MGs ( $H = 1$ , $S = 1$ and $A _ { i } = 2$ ) which has an exponential dependence in $m$ , the number of players. The result is built on the lower bound of query complexity in Rubinstein (2016). + +We use $\mathcal { G }$ to denote the one-step Markov game $H = 1$ and $S = 1$ ), in which there are $m$ players and $A = 2$ actions for each player. We index the players by $[ m ] = \{ 1 , \dots , m \}$ and denote the actions space of each player by $[ A ] = \{ 1 , 2 \}$ . Since we restricted attention to binary-action games (i.e. $A = 2$ ), the total number of joint actions is $2 ^ { m }$ . + +We define a (exact) query as the procedure where the algorithm queries a joint action $\pmb { a } \in [ A ] ^ { m }$ and observes the (deterministic) reward $r _ { i } ( \mathbf { a } ) \in [ 0 , 1 ]$ . We define the query complexity (Chen et al., 2015) for learning $\varepsilon$ -approximate Nash equilibrium (ANE) as the following. + +Definition A.1 (Query complexity). The query complexity $Q C _ { p } ( \mathrm { A N E } ( m , \varepsilon ) )$ for learning $\varepsilon$ -ANE is defined as the smallest n such that there exists a randomized oracle algorithm $\mathcal { A }$ satisfying the following: for any binary-action, m-player game $\mathcal { G }$ , the algorithm $\mathcal { A }$ can use no more than $n$ sequential queries of the reward to output an $\varepsilon$ -ANE with probability at least $1 - p$ . + +In one-step MGs with deterministic reward, the query complexity is equivalent to the sample complexity, since each query obtains a reward entry. The following result in Rubinstein (2016) gives a $\bar { 2 } ^ { \Omega ( m ) }$ query complexity lower bound for learning $\varepsilon _ { 0 }$ -ANE in $m$ -player binary action games. + +Require: Hyperparameters: $\{ \alpha _ { t } \} _ { 1 \leq t \leq K } , \{ \eta _ { t } \} _ { 1 \leq t \leq K } , \{ \bar { \beta } _ { t } \} _ { 1 \leq t \leq K } .$ +1: Initialize: For any $( s , a , h )$ , set $\overline { { V } } _ { h , i } ( s ) H$ , $\underline { { V } } _ { h , i } ( s ) 0$ , $\overline { { L } } _ { h , i } \gets 0$ , $\mu _ { h } ( a | s ) 1 / A _ { i }$ , +$N _ { h } ( s ) \gets 0$ . +2: for episode $k = 1 , \ldots , K$ do +3: Receive $s _ { 1 }$ . +4: for step $h = 1 , \ldots , H$ do +5: Take action $a _ { h } \sim \mu _ { h } ( \cdot | s _ { h } )$ , observe the action ${ \mathbf { } } ^ { a _ { h , - i } }$ from the other players. +6: Observe reward $r _ { h , i } = r _ { h , i } ( s _ { h } , a _ { h } , \mathbf { 4 } _ { h , - i } )$ and next state $s _ { h + 1 }$ from the environment. +7: Update accumulators: $t : = N _ { h } ( s _ { h } ) \gets N _ { h } ( s _ { h } ) + 1$ . +8: $\begin{array} { r l } & { \overline { { V } } _ { h , i } ( s _ { h } ) ( 1 - \alpha _ { t } ) \overline { { V } } _ { h , i } ( s _ { h } ) + \alpha _ { t } ( r _ { h , i } ( s _ { h } , a _ { h } , a _ { h , - i } ) + \overline { { V } } _ { h + 1 , i } ( s _ { h + 1 } ) + \overline { { \beta } } _ { t } ) } \\ & { \underline { { V } } _ { h , i } ( s _ { h } ) ( 1 - \alpha _ { t } ) \underline { { V } } _ { h , i } ( s _ { h } ) + \alpha _ { t } ( r _ { h , i } ( s _ { h } , a _ { h } , a _ { h , - i } ) + \underline { { V } } _ { h + 1 , i } ( s _ { h + 1 } ) - \overline { { \beta } } _ { t } ) } \\ & { \mathbf { f } _ { \ell h , i } ( s _ { h } , a ) \frac { 1 } { H } \big [ H - h + 1 - r _ { h , i } - \operatorname* { m i n } \{ \overline { { V } } _ { h + 1 , i } ( s _ { h + 1 } ) , H - h \} \big ] \mathbf { 1 } \{ a _ { h } = a \} \big / \big [ \mu _ { h } ( a _ { h } \vert s _ { h } ) + \eta _ { t } \big ] . } \\ & { \overline { { L } } _ { h , i } ( s _ { h } , a ) ( 1 - \alpha _ { t } ) \overline { { L } } _ { h , i } ( s _ { h } , a ) + \alpha _ { t } \overline { { L } } _ { h , i } ( s _ { h } , a ) } \\ & { \mathrm { S e t } \mu _ { h } \big ( \cdot \vert s _ { h } \rangle \propto \exp \lbrack - ( \eta _ { t } / \alpha _ { t } ) \overline { { L } } _ { h , i } ( s _ { h } , \cdot ) \rbrack . } \end{array}$ +9: +10: +11: +12: +13: + +Proposition A.2 (Corollary 4.5, (Rubinstein, 2016)). There exists absolute constants $\varepsilon _ { 0 } > 0$ and $c > 0$ , such that for all $m$ , + +$$ +Q C _ { p } ( \mathrm { A N E } ( m , \varepsilon _ { 0 } ) ) = 2 ^ { \Omega ( m ) } , w h e r e p = 2 ^ { - c m } . +$$ + +This result shows that it is impossible for any algorithm to learn an $\varepsilon _ { \mathrm { 0 } }$ -ANE for every binary action game with probability at least $( 1 - p )$ using $\operatorname { p o l y } ( m , \log ( 1 / p ) )$ samples: such an algorithm with $\bar { p } = 2 ^ { - c m }$ would only use poly $( m , \log ( 2 ^ { c m } ) ) = \mathrm { p o l y } ( m )$ samples, yet the sample complexity lower bound in Proposition A.2 requires at least $2 ^ { \Omega ( m ) } = \exp ( \Omega ( m ) )$ samples. Since Proposition A.2 allows $\varepsilon _ { 0 } = \Theta ( 1 )$ , this also rules out the possibility of learning $\varepsilon$ -ANE with $\mathrm { p o l y } ( m , \bar { \log } ( 1 / p ) , 1 / \varepsilon )$ samples for all small $\varepsilon$ . + +# B PROOFS FOR SECTION 3 + +# B.1 ALGORITHM FOR LEARNING CCE IN GENERAL-SUM MARKOV GAMES + +Our algorithm used to learn CCE in general-sum MGs is a combination of Algorithm 4 and Algorithm 2. In particular, Algorithm 4 computes a set of policies and plays these policies in each episode. Algorithm 2 used the full history in Algorithm 4 to produce a certified, general correlated policy which we will show to be a CCE (we will also use the same Algorithm 2 to produce the certified policy in the algorithm of learning CE). During the execution of Algorithm 2, if the index $t$ is 0 at some step $h$ , the certified policy can choose any action at and after step $h$ . + +In Algorithm 4, we choose the hyper-parameters as follows: + +$$ +\alpha _ { t } = \frac { H + 1 } { H + t } , \quad \eta _ { t } = \sqrt { \frac { H \iota } { A _ { i } t } } , \quad \overline { { \beta } } _ { t } = c \sqrt { \frac { H ^ { 3 } A _ { i } \iota } { t } } + 2 c \frac { H ^ { 2 } \iota } { t } , +$$ + +where $c > 0$ is some absolute constant, and $\begin{array} { r } { \iota = \log ( \frac { m \operatorname* { m a x } _ { i \in [ m ] } A _ { i } H S K } { p \varepsilon } ) } \end{array}$ is a log factor. The choice of $\eta _ { t }$ follows the V-OL algorithm in Tian et al. (2021) which helps to shave off an $H$ factor in the sample complexity compared with the original Nash V-Learning algorithm in Bai et al. (2020). + +Here, we have a short comment on the log factor $\iota$ . In fact, we need $\iota$ to be $\begin{array} { r } { C \log ( \frac { m \operatorname* { m a x } _ { i \in [ m ] } A _ { i } H S K } { p \varepsilon } ) } \end{array}$ for some absolute constant $C$ . For the cleanness of the results, in this paper, we ignore this difference since this would not harm the correctness of all the results we present. + +# B.2 PROOF OF THEOREM 2 + +We begin with an auxiliary lemma on $\alpha _ { t } ^ { j }$ (its definition is in (3)). + +Lemma B.1 (Lemma 4.1 in Jin et al. (2018)). The following properties hold for $\alpha _ { t } ^ { j }$ : + +1. $\begin{array} { r } { \frac { 1 } { \sqrt { t } } \leq \sum _ { j = 1 } ^ { t } \frac { \alpha _ { t } ^ { j } } { \sqrt { j } } \leq \frac { 2 } { \sqrt { t } } } \end{array}$ for every $t \geq 1$ . +2. $\begin{array} { r } { \operatorname* { m a x } _ { j \in [ t ] } \alpha _ { t } ^ { j } \leq \frac { 2 H } { t } } \end{array}$ and $\begin{array} { r } { \sum _ { j = 1 } ^ { t } \left( \alpha _ { t } ^ { j } \right) ^ { 2 } \le \frac { 2 H } { t } } \end{array}$ for every $t \geq 1$ . +3. $\textstyle \sum _ { t = j } ^ { \infty } \alpha _ { t } ^ { j } = 1 + { \frac { 1 } { H } }$ for every $j \geq 1$ . +4. $\textstyle \sum _ { j = 1 } ^ { t } { \frac { \alpha _ { t } ^ { j } } { j } } \geq { \frac { 1 } { 2 t } }$ for every $t \geq 1$ . + +Property 4 above does not appear in (Jin et al., 2018), for which we provide a quick proof here: + +$$ +\sum _ { j = 1 } ^ { t } \frac { \alpha _ { t } ^ { j } } { j } \geq \sum _ { j = [ t / 2 ] } ^ { t } \frac { \alpha _ { t } ^ { j } } { j } \geq 1 / t \sum _ { j = [ t / 2 ] } ^ { t } \alpha _ { t } ^ { j } \overset { ( i ) } { \geq } 1 / ( 2 t ) \sum _ { j = 1 } ^ { t } \alpha _ { t } ^ { j } = 1 / ( 2 t ) . +$$ + +Here, (i) uses $\alpha _ { t } ^ { j }$ is increasing in $j$ for fixed $t$ + +Some notations The following notations will be used repeatedly (throughout this section and the next section). At the beginning of any episode $k$ for a particular state $s _ { h }$ , we denote $k _ { h } ^ { 1 } ( s _ { h } ) < \cdots <$ kNkh (sh)h (sh) < k to be all the episodes that the state sh was visited, where N kh (sh) is the times the state $s _ { h }$ has been visited before the start of $k$ -th episode. When there is no confusion, we sometimes will write $k ^ { j } = k _ { h } ^ { j } ( s _ { h } )$ in short. For player $i$ , we let $\underline { { V } } _ { h , i } ^ { k }$ , $\overline { { V } } _ { h , i } ^ { k }$ , $\mu _ { i } ^ { k }$ denote the values and policies maintained by Algorithm 4 at the beginning of $k$ -th episode, and $\mathbf { \Delta } \mathbf { a } _ { h } ^ { k }$ denote taken action at step $h$ and episode $k$ . For any joint policy $\mu _ { h }$ (over all players), reward function $r$ and value function $V$ , we define the operators $\mathbb { P } _ { h }$ and $\mathbb { D } _ { \mu _ { h } }$ as + +$$ +\begin{array} { r l } & { [ \mathbb { P } _ { h } V ] ( s , { \boldsymbol a } ) : = \mathbb { E } _ { s ^ { \prime } \sim \mathbb { P } _ { h } ( \cdot \vert s , { \boldsymbol a } ) } V ( s ^ { \prime } ) , } \\ & { \mathbb { D } _ { \boldsymbol { \mu } _ { h } } [ r + \mathbb { P } _ { h } V ] ( s ) : = \mathbb { E } _ { { \boldsymbol a } _ { h } \sim \boldsymbol { \mu } _ { h } } [ r ( s , { \boldsymbol a } _ { h } ) + \mathbb { E } _ { s _ { h + 1 } \sim \mathbb { P } _ { h } ( \cdot \vert s , { \boldsymbol a } _ { h } ) } V ( s _ { h + 1 } ) ] . } \end{array} +$$ + +Towards proving Theorem 2, we begin with a simple consequence of the update rule in Algorithm 4, which will be used several times later. + +Lemma B.2 (Update rule). Fix a state s in time step $h$ and fix an episode $k$ , let $t = N _ { h } ^ { k } ( s )$ and suppose s was previously visited at episodes $k ^ { 1 } < \cdots < k ^ { t } < k$ at the $h$ -th step. The update rules in Algorithm 4 gives the following equations: + +$$ +\begin{array} { l } { { \displaystyle \overline { { V } } _ { h , i } ^ { k } ( s ) = \alpha _ { t } ^ { 0 } H + \sum _ { j = 1 } ^ { t } \alpha _ { t } ^ { j } \left[ r _ { h , i } \left( s , a _ { h } ^ { k ^ { j } } , \pmb { a } _ { h , - i } ^ { k ^ { j } } \right) + \overline { { V } } _ { h + 1 , i } ^ { k ^ { j } } \left( s _ { h + 1 } ^ { k ^ { j } } \right) + \overline { { \beta } } _ { j } \right] , } } \\ { { \displaystyle \underline { { V } } _ { h , i } ^ { k } ( s ) = \sum _ { j = 1 } ^ { t } \alpha _ { t } ^ { j } \left[ r _ { h , i } \left( s , a _ { h } ^ { k ^ { j } } , \pmb { a } _ { h , - i } ^ { k ^ { j } } \right) + \underline { { V } } _ { h + 1 , i } ^ { k ^ { j } } \left( s _ { h + 1 } ^ { k ^ { j } } \right) - \overline { { \beta } } _ { j } \right] . } } \end{array} +$$ + +We next present and prove the following lemma which helps to explain why our choice of the bonus term is $\overline { { \beta } } _ { t }$ . The constant $c$ in $\overline { { \beta } } _ { t }$ is actually the same with the constant $c$ in this lemma. + +Lemma B.3 (Per-state guarantee). Fix a state s in time step $h$ and fix an episode $k$ , let $t = N _ { h } ^ { k } ( s )$ and suppose s was previously visited at episodes $k ^ { 1 } < \cdots < \bar { k } ^ { t } < k$ at the $h$ -th step. With probability at least $1 - { \frac { p } { 2 } }$ , for any $( i , s , h , t ) \in [ m ] \times S \times [ H ] \times [ K ] ,$ , there exist a constant c s.t. + +$$ +\begin{array} { c } { { \displaystyle \operatorname* { m a x } _ { \mu \in \Delta _ { A _ { 4 } } } \displaystyle \sum _ { j = 1 } ^ { t } \alpha _ { t } ^ { j } { \mathbb D } _ { \mu \times \mu _ { h , - i } ^ { k j } } \left( r _ { h , i } + { \mathbb P } _ { h } \operatorname* { m i n } \{ \overline { { { V } } } _ { h + 1 , i } ^ { k j } , H - h \} \right) ( s ) } } \\ { { - \displaystyle \sum _ { j = 1 } ^ { t } \alpha _ { t } ^ { j } \left[ r _ { h , i } \left( s , a _ { h } ^ { k j } , a _ { h , - i } ^ { k j } \right) + \operatorname* { m i n } \{ \overline { { { V } } } _ { h + 1 , i } ^ { k j } ( s _ { h + 1 } ^ { k j } ) , H - h \} \right] \leq c \sqrt { H ^ { 3 } A _ { i } \iota / t } + c H ^ { 2 } \iota / t . } } \end{array} +$$ + +# Proof of Lemma B.3 First, we decompose + +$$ +\begin{array} { r l r } & { } & { \underset { \mu } { \operatorname* { m a x } } \sum _ { j = 1 } ^ { t } \alpha _ { t } ^ { j } \mathbb { D } _ { \mu \times \mu _ { h , - i } ^ { k ^ { j } } } \left( r _ { h , i } + \mathbb { P } _ { h } \operatorname* { m i n } \{ \overline { { V } } _ { h + 1 , i } ^ { k ^ { j } } , H - h \} \right) ( s ) } \\ & { } & { - \underset { j = 1 } { \overset { t } { \sum } } \alpha _ { t } ^ { j } \left[ r _ { h , i } \left( s , a _ { h } ^ { k ^ { j } } , \mathbf { a } _ { h , - i } ^ { k ^ { j } } \right) + \operatorname* { m i n } \{ \overline { { V } } _ { h + 1 , i } ^ { k ^ { j } } ( s _ { h + 1 } ^ { k ^ { j } } ) , H - h \} \right] } \end{array} +$$ + +into $R ^ { \star } ( i , s , h , t ) + U ( i , s , h , t )$ where + +$$ +\begin{array} { r l r } & { } & { R ^ { \star } ( i , s , h , t ) : = \displaystyle \operatorname* { m a x } _ { \mu } \sum _ { j = 1 } ^ { t } \alpha _ { t } ^ { j } \mathbb { D } _ { \mu \times \mu _ { h , - i } ^ { k ^ { j } } } \left( r _ { h , i } + \mathbb { P } _ { h } \operatorname* { m i n } \{ \overline { { V } } _ { h + 1 , i } ^ { k ^ { j } } , H - h \} \right) ( s ) } \\ & { } & { \displaystyle - \sum _ { j = 1 } ^ { t } \alpha _ { t } ^ { j } \mathbb { D } _ { \mu _ { h , i } ^ { k ^ { j } } \times \mu _ { h , - i } ^ { k ^ { j } } } \left( r _ { h , i } + \mathbb { P } _ { h } \operatorname* { m i n } \{ \overline { { V } } _ { h + 1 , i } ^ { k ^ { j } } , H - h \} \right) ( s ) , } \end{array} +$$ + +and + +$$ +\begin{array} { l } { { U ( i , s , h , t ) : = \displaystyle \sum _ { j = 1 } ^ { t } \alpha _ { t } ^ { j } \mathbb { D } _ { \mu _ { h , i } ^ { k j } \times \mu _ { h , - i } ^ { k j } } \left( r _ { h , i } + \mathbb { P } _ { h } \operatorname* { m i n } \{ \overline { { { V } } } _ { h + 1 , i } ^ { k ^ { j } } , H - h \} \right) ( s ) } } \\ { { \displaystyle \qquad - \sum _ { j = 1 } ^ { t } \alpha _ { t } ^ { j } \left[ r _ { h , i } \left( s , a _ { h } ^ { k j } , a _ { h , - i } ^ { k ^ { j } } \right) + \operatorname* { m i n } \{ \overline { { { V } } } _ { h + 1 , i } ^ { k ^ { j } } ( s _ { h + 1 } ^ { k ^ { j } } ) , H - h \} \right] . } } \end{array} +$$ + +We first bound $\boldsymbol { U } ( i , s , h , t )$ . Define $\mathcal { F } _ { l }$ as the $\sigma$ -algebra generated by all the random variables up to the time when $s _ { h }$ is observed at the $l$ -th episode. Recall that for $j \geq 1$ , $k ^ { j } = k _ { h } ^ { j } ( s ) = \operatorname* { i n f } \{ l >$ $k ^ { j - 1 } : s$ is visited at step $h$ in episode $l \}$ (with convention $k ^ { 0 } = 0$ ). Then $\{ k ^ { j } \} _ { j \geq 1 }$ is a sequence of increasing stopping times w.r.t. $\{ \mathcal { F } _ { l } \} _ { l \ge 1 }$ . Define $\mathcal { G } _ { j } = \mathcal { F } _ { k ^ { j + 1 } }$ . So $\{ \mathcal { G } _ { j } \} _ { j \ge 0 }$ is also a filtration. Under $\mathcal { G } _ { j - 1 } \left( = \mathcal { F } _ { k ^ { j } } \right)$ , by the definition of operator $\mathbb { D }$ and $\mathbb { P }$ , we have + +$$ +\begin{array} { r l } & { \mathbb { E } \bigg [ r _ { h , i } \left( s , a _ { h } ^ { k ^ { j } } , \pmb { a } _ { h , - i } ^ { k ^ { j } } \right) + \operatorname* { m i n } \{ \overline { { V } } _ { h + 1 , i } ^ { k ^ { j } } ( s _ { h + 1 } ^ { k ^ { j } } ) , H - h \} \bigg | \mathcal { G } _ { j - 1 } \bigg ] } \\ & { = \mathbb { D } _ { \mu _ { h , i } ^ { k ^ { j } } \times \mu _ { h , - i } ^ { k ^ { j } } } \left( r _ { h , i } + \mathbb { P } _ { h } \operatorname* { m i n } \{ \overline { { V } } _ { h + 1 , i } ^ { k ^ { j } } , H - h \} \right) ( s ) . } \end{array} +$$ + +So we can apply Azuma-Hoeffding inequality. Note that $\textstyle \sum _ { j = 1 } ^ { t } ( \alpha _ { t } ^ { j } ) ^ { 2 } \leq 2 H / t$ by Lemma B.1. Using Azuma-Hoeffding inequality, we have with probability at least $\begin{array} { r } { 1 - \frac { p } { 4 m H S K } } \end{array}$ + +$$ +\begin{array} { l } { \displaystyle U ( i , s , h , t ) = \sum _ { j = 1 } ^ { t } \alpha _ { t } ^ { j } { \mathbb D } _ { \mu _ { h , i } ^ { k j } \times \mu _ { h , - i } ^ { k j } } \left( r _ { h , i } + { \mathbb P } _ { h } \operatorname* { m i n } \{ \overline { { V } } _ { h + 1 , i } ^ { k j } , H - h \} \right) ( s ) } \\ { \displaystyle \qquad - \sum _ { j = 1 } ^ { t } \alpha _ { t } ^ { j } \left[ r _ { h , i } \left( s , a _ { h } ^ { k j } , a _ { h , - i } ^ { k j } \right) + \operatorname* { m i n } \{ \overline { { V } } _ { h + 1 , i } ^ { k j } ( s _ { h + 1 } ^ { k j } ) , H - h \} \right] } \\ { \displaystyle \qquad \leq \sqrt { 2 H ^ { 2 } \log ( 4 m H S K / p ) \sum _ { j = 1 } ^ { t } ( \alpha _ { t } ^ { j } ) ^ { 2 } } \leq 2 \sqrt { H ^ { 3 } \iota / t } . } \end{array} +$$ + +After taking a union bound, we have the following statement is true with probability at least $1 - p / 4$ + +$$ +U ( i , s , h , t ) \leq 2 \sqrt { H ^ { 3 } \iota / t } \mathrm { ~ f o r ~ a l l ~ } ( i , s , h , t ) \in [ m ] \times \mathcal { S } \times [ H ] \times [ K ] . +$$ + +Then we bound $R ^ { \star } ( i , s , h , t )$ . For fixed $( i , s , h )$ , if we define the loss function + +$$ +\ell _ { j } ( a ) = \frac { 1 } { H } \mathbb { E } _ { a _ { i } = a , a _ { - i } \sim \mu _ { h , - i } ^ { k j } } [ H - h + 1 - r _ { h , i } ( s , a ) - \mathbb { P } _ { h } \operatorname* { m i n } \{ \overline { { V } } _ { h + 1 , i } ^ { k ^ { j } } , H - h \} ( s ) ] \in [ 0 , 1 ] , +$$ + +Algorithm 5 Correlated policy $\widehat { \pi } _ { h } ^ { k }$ for general-sum Markov games + +1: for step $h ^ { \prime } = h , \ldots , H$ do +2: Observe $s _ { h ^ { \prime } }$ , and set $t \gets N _ { h ^ { \prime } } ^ { k } ( s _ { h ^ { \prime } } )$ . +3: Sample $l \in [ t ]$ with $\mathbb { P } ( l = j ) = \alpha _ { t } ^ { j }$ . +4: Update $k \bar { k } _ { t } ^ { l } ( s _ { h ^ { \prime } } )$ . +5: Jointly take action $\begin{array} { r } \binom { 2 } { a _ { h ^ { \prime } , 1 } , a _ { h ^ { \prime } , 2 } , \dotsc , a _ { h ^ { \prime } , m } ) \sim \prod _ { i = 1 } ^ { m } \mu _ { h ^ { \prime } , i } ^ { k } ( \cdot | s _ { h ^ { \prime } } ) . } \end{array}$ + +then $\begin{array} { r } { R ^ { \star } ( i , s , h , t ) = H \operatorname* { m a x } _ { \mu } \sum _ { j = 1 } ^ { t } \alpha _ { t } ^ { j } \left. \mu - \mu _ { h , i } ^ { k ^ { j } } , \ell _ { j } \right. } \end{array}$ becomes the weighted regret with weight $\alpha _ { t } ^ { j }$ . Note that the update rule for $\mu _ { h , i } ^ { k ^ { j } } ( \cdot | s )$ is essentially performing Follow-the-Regularized-Leader (FTRL) algorithm with changing step size for each state $s$ and each step $h$ to solve an adversarial bandit problem. Lemma 17 in (Bai et al., $2 0 2 0 ) ^ { 3 }$ bounds the weight regret with high probability. Using that lemma, we have with probability at least 1 − p4mHS , + +$$ +\mathfrak { x } ^ { \star } ( i , s , h , t ) \leq \frac { H \alpha _ { t } ^ { t } \log A _ { i } } { \eta _ { t } } + \frac { 3 H A _ { i } } { 2 } \sum _ { j = 1 } ^ { t } \eta _ { j } \alpha _ { t } ^ { j } + H \sqrt { 2 \iota \sum _ { j = 1 } ^ { t } ( \alpha _ { t } ^ { j } ) ^ { 2 } } + \frac { H } { 2 } \operatorname* { m a x } _ { j \leq t } \alpha _ { t } ^ { j } \iota + H \operatorname* { m a x } _ { j \leq t } \alpha _ { t } ^ { j } \iota / \eta _ { t } +$$ + +simultaneously for all $t \in [ K ]$ . By Lemma B.1 and $\begin{array} { r } { \eta _ { t } = \sqrt { \frac { H \iota } { A _ { i } t } } } \end{array}$ , we have with probability at least 1 − p4mH S + +$$ +\begin{array} { r l } & { R ^ { \star } ( i , s , h , t ) \leq 2 \sqrt { H ^ { 3 } A _ { i } \iota / t } + 3 \sqrt { H ^ { 3 } A _ { i } \iota / t } + 2 \sqrt { H ^ { 3 } \iota / t } + H ^ { 2 } \iota / t + 2 \sqrt { H ^ { 3 } A _ { i } \iota / t } } \\ & { \qquad \leq 1 0 \sqrt { H ^ { 3 } A _ { i } \iota / t } + 1 0 H ^ { 2 } \iota / t \quad \mathrm { f o r ~ a l l ~ } t \in [ K ] . } \end{array} +$$ + +Again, taking a union bound in all $( i , s , h ) \in [ m ] \times \mathcal { S } \times [ H ]$ , we have with probability at least $1 - p / 4$ , + +$$ +\begin{array} { r } { R ^ { \star } ( i , s , h , t ) \leq 1 0 \sqrt { H ^ { 3 } A _ { i } \iota / t } + 1 0 H ^ { 2 } \iota / t \mathrm { f o r } \mathrm { a l l } ( i , s , h , t ) \in [ m ] \times S \times [ H ] \times [ K ] . } \end{array} +$$ + +Finally, we concluded that with probability at least $1 - p / 2$ , we have + +$$ +U ( i , s , h , t ) + R ^ { \star } ( i , s , h , t ) \leq c \sqrt { H ^ { 3 } A _ { i } \iota / t } + c H ^ { 2 } \iota / t \mathrm { f o r } \mathrm { a l l } ( i , s , h , t ) \in [ m ] \times S \times [ H ] \times [ K ] +$$ + +for some absolute constant $c$ + +Recall that the certified policy $\widehat { \pi }$ as in Algorithm 2 is a nested mixture of policies. We further define policies $\{ \widehat { \pi } _ { h } ^ { k } \} _ { h \in [ H ] , k \in [ K ] }$ b in Algorithm 5. By construction, the relationship between $\widehat { \pi }$ and $\widehat { \pi } _ { h } ^ { k }$ is bthat when players jointly play policy the $\widehat { \pi }$ , they first sample $k$ from Uniform $( [ K ] )$ b b, then they play together the policy $\widehat { \pi } _ { 1 } ^ { k }$ (Algorithm 5 for $h = 1$ ) with the same sampled $k$ . As a result, we have the b following relationship: + +$$ +V _ { 1 , i } ^ { \widehat { \pi } } ( s _ { 1 } ) = \frac { 1 } { K } \sum _ { k = 1 } ^ { K } V _ { 1 , i } ^ { \widehat { \pi } _ { 1 } ^ { k } } ( s _ { 1 } ) . +$$ + +Definition B.4 (Policy starting from the $h$ -th step). We define the policy starting from the h-th step for player $i$ as $\pi _ { \geq h , i } : = \{ \pi _ { h ^ { \prime } , i } : \Omega \times ( S \times \mathcal { A } ) ^ { h ^ { \prime } - h } \times S \to \Delta _ { \mathcal { A } _ { i } } \} _ { h ^ { \prime } = h } ^ { H }$ . At each step $h ^ { \prime } \geq h$ , $\pi _ { \geq h , i }$ samples action based on current state, the history starting from the $h$ -th step and a random number $\omega \in \Omega$ . We use $\Pi _ { \geq h , i }$ to denote all policies for player $i$ starting from the $h$ -th step. Similar to Section 2, we can define general correlated policy starting from the $h$ -th step (where the random numbers may be correlated for different players), and we use $\Pi _ { \geq h }$ to denote all such general correlated policy starting from the $h$ -th step. + +For $\pi \in \Pi _ { \geq h }$ , we can define the value function starting from the $h$ -th step as: + +$$ +V _ { h , i } ^ { \pi } ( s ) : = \mathbb { E } _ { \pi } \left[ \sum _ { h ^ { \prime } = h } ^ { H } r _ { h ^ { \prime } , i } | s _ { h } = s \right] . +$$ + +We also define the value function of the best response as: + +$$ +V _ { h , i } ^ { \dagger , \pi _ { h , - i } } ( s ) : = \operatorname* { m a x } _ { \mu _ { i } \in \Pi _ { \geq h , i } } V _ { h , i } ^ { \mu _ { i } \times \pi _ { h , - i } } ( s ) . +$$ + +of a and ng from the . $h$ -th step is $\widehat { \pi } _ { h } ^ { k }$ defined in Algorithm 5, so that we can define V πbkhh,i (s) $V _ { h , i } ^ { \dag , \widehat { \pi } _ { h , - i } ^ { k } } ( s )$ + +Lemma B.5 (Valid upper and lower bounds). We have + +$$ +\overline { { V } } _ { h , i } ^ { k } ( s ) \geq V _ { h , i } ^ { \dagger , \widehat { \pi } _ { h , - i } ^ { k } } ( s ) , \quad \underline { { V } } _ { h , i } ^ { k } ( s ) \leq V _ { h , i } ^ { \widehat { \pi } _ { h } ^ { k } } ( s ) +$$ + +for all $( i , s , h , k ) \in [ m ] \times S \times [ H ] \times [ K ]$ with probability at least $1 - p$ . + +Proof of Lemma B.5 We prove this lemma by backward induction over $h \in [ H + 1 ]$ . The base case of $h = H + 1$ is true as all the value functions equal 0 by definition. Suppose the claim is true for h + 1. We begin with upper bounding V †,πbkh,−ih,i (s). Let t = N kh (s) and kj = kjh(s) for 1 ≤ j ≤ t to be the $j ^ { \dagger }$ ’th time that $s$ is previously visited. By the definition of certified policies $\widehat { \pi } _ { h , i } ^ { k }$ and by the value iteration formula of MGs, we have for any policy $\mu _ { i } \in \Pi _ { \geq h , i }$ , + +$$ +\begin{array} { l } { { V _ { h , i } ^ { \mu _ { i } , \widehat { \pi } _ { h , - i } ^ { k } } ( s ) = \displaystyle \sum _ { j = 1 } ^ { t } \alpha _ { t } ^ { j } \mathbb { E } _ { a \sim \mu _ { h , i } \times \mu _ { h , - i } ^ { k j } } \left[ r _ { h , i } ( s , a ) + \mathbb { E } _ { s ^ { \prime } \sim \mathbb { P } _ { h } ( \cdot \vert s , a ) } V _ { h + 1 , i } ^ { ( \mu _ { h + 1 : H , i } | s , a ) , \widehat { \pi } _ { h + 1 , - i } ^ { k j } } ( s ^ { \prime } ) \right] } } \\ { { \displaystyle \qquad \leq \displaystyle \sum _ { j = 1 } ^ { t } \alpha _ { t } ^ { j } \mathbb { E } _ { a \sim \mu _ { h , i } \times \mu _ { h , - i } ^ { k j } } \left[ r _ { h , i } ( s , a ) + \mathbb { E } _ { s ^ { \prime } \sim \mathbb { P } _ { h } ( \cdot \vert s , a ) } V _ { h + 1 , i } ^ { \dagger , \widehat { \pi } _ { h + 1 , - i } ^ { k j } } ( s ^ { \prime } ) \right] . } } \end{array} +$$ + +Here, $\mu _ { h , i }$ is the policy $\mu _ { i }$ at the $h$ -th step, and $\left( \mu _ { h + 1 : H , i } | s , \pmb { a } \right)$ is the policy $\mu _ { i }$ from time $h + 1$ to $H$ with history information at $h$ -th step to be $s _ { h } = s$ and ${ \bf { a } } _ { h } = { \bf { a } }$ . By the definition of $\Pi _ { \geq h , i }$ , we have $( \mu _ { h + 1 : H , i } | s , \pmb { a } ) \in \Pi _ { \geq h + 1 , i }$ which implies the inequality in the equation above. By taking supremum over $\mu _ { i } \in \Pi _ { \geq h , i }$ and using the definition of the operator $\mathbb { D }$ in (6), we have + +$$ +V _ { h , i } ^ { \dagger , \widehat { \pi } _ { h , - i } ^ { k } } ( s ) \leq \operatorname* { s u p } _ { \mu _ { i } \in \Delta _ { A _ { i } } } \sum _ { j = 1 } ^ { t } \alpha _ { t } ^ { j } \mathbb { D } _ { \mu _ { i } \times \mu _ { h , - i } ^ { k j } } [ r _ { h , i } + \mathbb { P } _ { h } V _ { h + 1 , i } ^ { \dagger , \widehat { \pi } _ { h + 1 , - i } ^ { k j } } ] ( s ) . +$$ + +Conditional on the high probability event in Lemma B.3, we use the inductive hypothesis to obtain + +$$ +\begin{array} { r l } { { { \mathcal { F } _ { h , i } ^ { t } } \widetilde { \alpha } _ { h - 1 } ^ { k } ( s ) \leq \operatorname* { s u p } _ { \mu \leq \frac { \hat { \varepsilon } } { \hat { \varepsilon } } } \sum _ { \theta ^ { \prime } \leq 1 } ^ { \theta } \alpha _ { h } ^ { \beta } \mu _ { h , i \times \frac { \theta ^ { \prime } } { h } - 1 } { [ { \boldsymbol { r } } _ { h , i } + { \operatorname { P } } _ { h } \operatorname* { m i n } \{ \bar { V } _ { h + 1 , i } ^ { k } , \boldsymbol { H } - h \} ] ( s ) } } \qquad \quad } & { } \\ & { \leq \displaystyle \sum _ { j = 1 } ^ { \frac { \hat { \varepsilon } } { \hat { \varepsilon } } } \alpha _ { t } ^ { j } [ { \boldsymbol { r } } _ { h , i } ( s , \alpha _ { h } ^ { k j } , \alpha _ { h - i } ^ { k j } ) + \operatorname* { m i n } \{ \bar { V } _ { h + 1 , i } ^ { k ^ { 2 } } ( s _ { h + 1 } ^ { \beta } ) , H - h \} ] + c \sqrt { H ^ { 3 } \boldsymbol { A } _ { i ^ { \prime } i } / \hat { \varepsilon } } + c H ^ { 2 } \iota / } \\ & { \overset { ( i ) } { \leq } \displaystyle \sum _ { j = 1 } ^ { \frac { \hat { \varepsilon } } { \hat { \varepsilon } } } \alpha _ { t } ^ { j } [ { \boldsymbol { r } } _ { h , i } ( s , \alpha _ { h } ^ { k j } , \alpha _ { h - i } ^ { k j } ) + \operatorname* { m i n } \{ \bar { V } _ { h + 1 , i } ^ { k j } ( s _ { h + 1 } ^ { k j } ) , H - h \} + \bar { \beta } _ { j } ] } \\ & { \leq \displaystyle \sum _ { j = 1 } ^ { \hat { \varepsilon } } \alpha _ { t } ^ { j } [ { \boldsymbol { r } } _ { h , i } ( s , \alpha _ { h } ^ { k j } , \alpha _ { h - i } ^ { k j } ) + \bar { V } _ { h + 1 , i } ^ { k j } ( s _ { h + 1 } ^ { j i } ) + \bar { \beta } _ { j } ] } \\ & { = \overline { { V } } _ { h , i } ^ { k } ( s , h ) . } \end{array} +$$ + +Here, (i) uses our choice of $\begin{array} { r } { \overline { { \beta } } _ { j } = c \sqrt { \frac { H ^ { 3 } A _ { i } \iota } { j } } + 2 c \frac { H ^ { 2 } \iota } { j } } \end{array}$ and $\begin{array} { r } { \frac { 1 } { \sqrt { t } } \leq \sum _ { j = 1 } ^ { t } \frac { \alpha _ { t } ^ { j } } { \sqrt { j } } } \end{array}$ , $\begin{array} { r } { \frac { 1 } { t } \leq \sum _ { j = 1 } ^ { t } \frac { 2 \alpha _ { t } ^ { j } } { j } } \end{array}$ + +Meanwhile, for $\underline { { V } } _ { h , i } ^ { k } ( s )$ , by the definition of certified policy and inductive hypothesis, + +$$ +\begin{array} { r l } & { V _ { h , i } ^ { \widehat { \pi } _ { h } ^ { k } } ( s ) = \displaystyle \sum _ { j = 1 } ^ { t } \alpha _ { t } ^ { j } \mathbb { D } _ { \mu _ { h } ^ { k ^ { j } } } \big [ r _ { h , i } + \mathbb { P } _ { h } V _ { h + 1 , i } ^ { \widehat { \pi } ^ { k ^ { j } } } \big ] ( s ) } \\ & { \qquad \quad \geq \displaystyle \sum _ { j = 1 } ^ { t } \alpha _ { t } ^ { j } \mathbb { D } _ { \mu _ { h } ^ { k ^ { j } } } \big [ r _ { h , i } + \mathbb { P } _ { h } \operatorname* { m a x } \{ \underline { { V } } _ { h + 1 , i } ^ { k ^ { j } } , 0 \} \big ] ( s ) . } \end{array} +$$ + +Then we note that $\left\{ \mathbb { D } _ { \mu _ { h } ^ { k j } } [ r _ { h , i } + \mathbb { P } _ { h } \operatorname* { m a x } \{ \underline { { V } } _ { h + 1 , i } ^ { k j } , 0 \} ] ( s ) - \left[ r _ { h , i } \left( s , a _ { h } ^ { k _ { h } ^ { j } } , a _ { h , - i } ^ { k _ { h } ^ { j } } \right) + \operatorname* { m a x } \{ \underline { { V } } _ { h + 1 , i } ^ { k _ { h } ^ { j } } ( s _ { h + 1 } ^ { k _ { h } ^ { j } } ) , 0 \} \right] \right\} _ { j \geq 1 }$ is a martingale difference w.r.t. the filtration $\{ \mathcal { G } _ { j } \} _ { j \ge 0 }$ , which is defined in the proof of Lemma B.3. So by Azuma-Hoeffding inequality, with probability at least 1 − p2mSKH + +$$ +\begin{array} { c } { { \displaystyle \sum _ { j = 1 } ^ { t } \alpha _ { t } ^ { j } \mathbb { D } _ { \mu _ { h } ^ { k j } } [ r _ { h , i } + \mathbb { P } _ { h } \operatorname* { m a x } \{ \underline { { { V } } } _ { h + 1 , i } ^ { k j } , 0 \} ] ( s ) } } \\ { { \displaystyle \geq \sum _ { j = 1 } ^ { t } \alpha _ { t } ^ { j } \left[ r _ { h , i } \left( s , a _ { h } ^ { k _ { h } ^ { j } } , { a } _ { h , - i } ^ { k _ { h } ^ { j } } \right) + \operatorname* { m a x } \{ \underline { { { V } } } _ { h + 1 , i } ^ { k _ { h } ^ { j } } ( s _ { h + 1 } ^ { k _ { h } ^ { j } } ) , 0 \} \right] - 2 \sqrt { \frac { H ^ { 3 } \iota } t } . } } \end{array} +$$ + +On this event, we have + +$$ +\begin{array} { r l } & { \displaystyle \sum _ { j = 1 } ^ { t } \alpha _ { t } ^ { j } \mathbb { D } _ { \mu _ { h } ^ { k ^ { j } } } [ r _ { h , i } + \mathbb { P } _ { h } \operatorname* { m a x } \left\{ \underline { { V } } _ { h + 1 , i } ^ { k ^ { j } } , 0 \right\} ] ( s ) } \\ & { \displaystyle \geq \sum _ { j = 1 } ^ { t } \alpha _ { t } ^ { j } \left[ r _ { h , i } \left( s , a _ { h } ^ { k _ { h } ^ { j } } , a _ { h , - i } ^ { k _ { h } ^ { j } } \right) + \operatorname* { m a x } \left\{ \underline { { V } } _ { h + 1 , i } ^ { k _ { h } ^ { j } } ( s _ { h + 1 } ^ { k _ { h } ^ { j } } ) , 0 \right\} - \overline { { \beta } } _ { j } \right] } \\ & { = \displaystyle { V } _ { h , i } ^ { k } ( s ) . } \end{array} +$$ + +Here, (i) uses $\begin{array} { r } { \sum _ { j = 1 } ^ { t } \alpha _ { t } ^ { j } \beta _ { j } \geq 2 \sum _ { j = 1 } ^ { t } \alpha _ { t } ^ { j } \sqrt { H ^ { 3 } \iota / j } \geq 2 \sqrt { H ^ { 3 } \iota / t } . } \end{array}$ + +As a result, the backward induction would work well for all $h$ as long as the inequalities in Lemma B.3 and (9) hold for all $( i , s , h , k ) \in [ m ] \times { \mathcal { S } } \times [ H ] \times [ K ]$ . Taking a union bound in all $( i , s , h , k ) \in [ m ] \times S \times [ H ] \times [ K ]$ , we have with probability at least $1 - p / 2$ , the inequality in (9) is true simultaneously for all $( i , s , \dot { h , } k ) \in [ m ] \times \mathcal { S } \dot { \times } [ H ] \times [ K ]$ . Therefore the inequalities in Lemma B.3 and (9) hold simultaneously for all $( i , s , h , k ) \in [ m ] \times S \times [ H ] \times [ K ]$ with probability at least $1 - p$ . This finishes the proof of this lemma. □ + +Equipped with these lemmas, we are ready to prove Theorem 2. + +Proof of Theorem 2 Conditional on the high probability event in Lemma B.5 (this happens with probability at least $1 - p )$ , we have + +$$ +\overline { { V } } _ { h , i } ^ { k } ( s ) \geq V _ { h , i } ^ { \dag , \widehat { \pi } _ { h , - i } ^ { k } } ( s ) , \quad \underline { { V } } _ { h , i } ^ { k } ( s ) \leq V _ { h , i } ^ { \widehat { \pi } _ { h } ^ { k } } ( s ) +$$ + +for all $( i , s , h , k ) \in [ m ] \times S \times [ H ] \times [ K ]$ . Then, choosing $h = 1$ and $s = s _ { 1 }$ , we have + +$$ +\begin{array} { r } { V _ { 1 , i } ^ { \dagger , \widehat { \pi } _ { 1 , - i } ^ { k } } ( s _ { 1 } ) - V _ { 1 , i } ^ { \widehat { \pi } _ { 1 } ^ { k } } ( s _ { 1 } ) \leq \overline { { V } } _ { 1 , i } ^ { k } ( s _ { 1 } ) - \underline { { V } } _ { 1 , i } ^ { k } ( s _ { 1 } ) . } \end{array} +$$ + +Moreover, by (7), value function of certified policy can be decomposed as + +$$ +V _ { 1 , i } ^ { \widehat { \pi } } ( s ) = \frac { 1 } { K } \sum _ { k = 1 } ^ { K } V _ { 1 , i } ^ { \widehat { \pi } _ { 1 } ^ { k } } ( s ) , \quad V _ { 1 , i } ^ { \mu _ { 1 } , \widehat { \pi } _ { - i } } ( s _ { 1 } ) = \frac { 1 } { K } \sum _ { k = 1 } ^ { K } V _ { 1 , i } ^ { \mu _ { 1 } , \widehat { \pi } _ { 1 , - i } ^ { k } } ( s _ { 1 } ) +$$ + +where the decomposition is due to the first line in the Algorithm 2: sample $k \gets \mathrm { U n i f o r m } ( [ K ] )$ . + +So we have + +$$ +\begin{array} { r l } & { V _ { 1 , i } ^ { \dagger , \widehat { \pi } _ { - i } } ( s _ { 1 } ) - V _ { 1 , i } ^ { \widehat { \pi } _ { } } ( s _ { 1 } ) \leq \displaystyle \frac { 1 } { K } \sum _ { k = 1 } ^ { K } \left( V _ { 1 , i } ^ { \dagger , \widehat { \pi } _ { 1 , - i } ^ { k } } ( s _ { 1 } ) - V _ { 1 , i } ^ { \widehat { \pi } _ { 1 } ^ { k } } ( s _ { 1 } ) \right) } \\ & { \qquad \leq \displaystyle \frac { 1 } { K } \sum _ { k = 1 } ^ { K } \left( \overline { { V } } _ { 1 , i } ^ { k } ( s _ { 1 } ) - \underline { { V } } _ { 1 , i } ^ { k } ( s _ { 1 } ) \right) . } \end{array} +$$ + +To prove $\widehat { \pi }$ is an approximate CCE, we only need to bound $\begin{array} { r l } { \sum _ { k = 1 } ^ { K } \Big ( \overline { { V } } _ { 1 , i } ^ { k } ( s _ { 1 } ) - \underline { { V } } _ { 1 , i } ^ { k } ( s _ { 1 } ) \Big ) } & { { } } \end{array}$ . Letting $\delta _ { h , i } ^ { k } : = \overline { { V } } _ { h , i } ^ { k } ( s _ { h } ^ { k } ) - \underline { { V } } _ { h , i } ^ { k } ( s _ { h } ^ { k } )$ and $t = N _ { h } ^ { k } ( s _ { h } ^ { k } )$ . Suppose $s _ { h } ^ { k }$ was previously visited at episodes $k ^ { 1 } , \dots , k ^ { t }$ at the $h$ -th step. By the update rule, + +$$ +\begin{array} { r l } & { \delta _ { h , i } ^ { k } = \overline { { V } } _ { h , i } ^ { k } ( s _ { h } ^ { k } ) - \underline { { V } } _ { h , i } ^ { k } ( s _ { h } ^ { k } ) } \\ & { \quad = \alpha _ { t } ^ { 0 } H + \displaystyle \sum _ { j = 1 } ^ { t } \alpha _ { t } ^ { j } \overline { { [ V _ { h + 1 , i } ^ { k } ( s _ { h + 1 } ^ { k ^ { j } } ) - \underline { { V } } _ { h + 1 , i } ^ { k } ( s _ { h + 1 } ^ { k ^ { j } } ) + 2 \overline { { \beta } } _ { j } ] } } } \\ & { \quad = \alpha _ { t } ^ { 0 } H + \displaystyle \sum _ { j = 1 } ^ { t } \alpha _ { t } ^ { j } \delta _ { h + 1 , i } ^ { k ^ { j } } + \displaystyle \sum _ { j = 1 } ^ { t } 2 \alpha _ { t } ^ { j } \overline { { \beta } } _ { j } } \\ & { \quad = \alpha _ { t } ^ { 0 } H + \displaystyle \sum _ { j = 1 } ^ { t } \alpha _ { t } ^ { j } \delta _ { h + 1 , i } ^ { k ^ { j } } + 2 c \displaystyle \sum _ { j = 1 } ^ { t } \alpha _ { t } ^ { j } \sqrt { \frac { A _ { i } H ^ { 3 } { \lambda } _ { t } } { j } } + 4 c \displaystyle \sum _ { j = 1 } ^ { t } \alpha _ { t } ^ { j } \frac { H ^ { 2 } { \lambda } _ { t } } { j } . } \end{array} +$$ + +We can use Lemma B.1 which gives $\textstyle \sum _ { j = 1 } ^ { t } \alpha _ { t } ^ { j } / \sqrt { j } \leq 2 / t$ and $\textstyle \operatorname* { m a x } _ { j \leq t } \alpha _ { t } ^ { j } \leq 2 H / t$ to get + +$$ +\delta _ { h , i } ^ { k } \leq \alpha _ { t } ^ { 0 } H + \sum _ { j = 1 } ^ { t } \alpha _ { t } ^ { j } \delta _ { h + 1 , i } ^ { k ^ { j } } + 4 c \sqrt { H ^ { 3 } A _ { i } \iota / t } + 8 c H ^ { 3 } \iota ( 1 + \log t ) / t , +$$ + +where we also uses $\textstyle \sum _ { j = 1 } ^ { t } 1 / j \leq 1 + \log t$ + +Taking the summation w.r.t. k, we begin by the first two terms; + +$$ +\sum _ { k = 1 } ^ { K } \alpha _ { t } ^ { 0 } H = \sum _ { k = 1 } ^ { K } H { \bf 1 } \left\{ t = 0 \right\} = \sum _ { k = 1 } ^ { K } H { \bf 1 } \left\{ N _ { h } ^ { k } ( s _ { h } ^ { k } ) = 0 \right\} \le S H . +$$ + +$$ +\sum _ { k = 1 } ^ { K } \sum _ { j = 1 } ^ { N _ { h } ^ { k } ( s _ { h } ^ { k } ) } \alpha _ { N _ { h } ^ { k } ( s _ { h } ^ { k } ) } ^ { j } \delta _ { h + 1 , i } ^ { k _ { h } ^ { j } ( s _ { h } ^ { k } ) } \overset { ( i ) } { \leq } \sum _ { k ^ { \prime } = 1 } ^ { K } \delta _ { h + 1 , i } ^ { k ^ { \prime } } \sum _ { j = N _ { h } ^ { k ^ { \prime } } ( s _ { h } ^ { k ^ { \prime } } ) + 1 } ^ { \infty } \alpha _ { j } ^ { N _ { h } ^ { k ^ { \prime } } ( s _ { h } ^ { k ^ { \prime } } ) } \overset { ( i i ) } { \leq } ( 1 + \frac { 1 } { H } ) \sum _ { k ^ { \prime } = 1 } ^ { K } \delta _ { h + 1 , i } ^ { k ^ { \prime } } , +$$ + +where (i) is by changing the order of summation and (ii) is by Lemma B.1. + +So + +$$ +\sum _ { \mathfrak { s } = 1 } ^ { K } \delta _ { h , i } ^ { k } \le S H + \left( 1 + \frac { 1 } { H } \right) \sum _ { k = 1 } ^ { K } \delta _ { h + 1 , i } ^ { k } + 4 c \sqrt { H ^ { 3 } A _ { i } \iota } \sum _ { k = 1 } ^ { K } \frac { 1 } { \sqrt { N _ { h } ^ { k } ( s ) } } + 8 c H ^ { 3 } \iota \sum _ { k = 1 } ^ { K } \frac { 1 + \log N _ { h } ^ { k } ( s ) } { N _ { h } ^ { k } ( s ) } . +$$ + +By pigeonhole argument, + +$$ +\sum _ { k = 1 } ^ { K } \frac { 1 } { \sqrt { N _ { h } ^ { k } ( s ) } } = \sum _ { s \in \cal { S } } \sum _ { n = 1 } ^ { N _ { h } ^ { K } ( s ) } \frac { 1 } { \sqrt { n } } \le \mathcal { O } ( 1 ) \sqrt { S K } . +$$ + +Similarly, + +$$ +\sum _ { k = 1 } ^ { K } \frac { 1 + \log N _ { h } ^ { k } ( s ) } { N _ { h } ^ { k } ( s ) } \leq \mathcal { O } ( 1 ) ( 1 + \log ( K ) S ( 1 + \log ( K / S ) ) ) \leq \mathcal { O } ( 1 ) S ( \iota + \iota ^ { 2 } ) \leq \mathcal { O } ( 1 ) S \iota ^ { 2 } , +$$ + +where we assume $\iota \geq 1$ . So we have + +$$ +\sum _ { k = 1 } ^ { K } \delta _ { h , i } ^ { k } \leq S H + \left( 1 + \frac { 1 } { H } \right) \sum _ { k = 1 } ^ { K } \delta _ { h + 1 , i } ^ { k } + \mathcal { O } ( 1 ) \sqrt { H ^ { 3 } A _ { i } S K \iota } + \mathcal { O } ( 1 ) S H ^ { 3 } \iota ^ { 3 } . +$$ + +Recursing this argument for $h \in [ H ]$ gives + +$$ +\sum _ { k = 1 } ^ { K } \delta _ { 1 , i } ^ { k } \leq e H ^ { 2 } S + \mathcal { O } ( 1 ) \sqrt { H ^ { 5 } A _ { i } S K \iota } + \mathcal { O } ( 1 ) S H ^ { 4 } \iota ^ { 3 } . +$$ + +To conclude, + +$$ +\begin{array} { r } { V _ { 1 , i } ^ { \dagger , \widehat { \pi } _ { - i } } ( s _ { 1 } ) - V _ { 1 , i } ^ { \widehat { \pi } } ( s _ { 1 } ) \leq \displaystyle \frac { 1 } { K } \sum _ { k = 1 } ^ { K } \left( \overline { { V } } _ { 1 , i } ^ { k } ( s _ { 1 } ) - \underline { { V } } _ { 1 , i } ^ { k } ( s _ { 1 } ) \right) = \displaystyle \frac { 1 } { K } \sum _ { k = 1 } ^ { K } \delta _ { 1 , i } ^ { k } } \\ { \leq \mathcal { O } ( 1 ) S H ^ { 4 } \iota ^ { 3 } / K + \mathcal { O } \left( \sqrt { H ^ { 5 } S \operatorname* { m a x } _ { i \in [ m ] } A _ { i } \iota / K } \right) . } \end{array} +$$ + +Therefore, $\begin{array} { r } { K \geq \mathcal { O } ( \frac { H ^ { 5 } S \operatorname* { m a x } _ { i \in [ m ] } A _ { i } \iota } { \varepsilon ^ { 2 } } + \frac { S H ^ { 4 } \iota ^ { 3 } } { \varepsilon } ) } \end{array}$ guarantees that we have $V _ { 1 , i } ^ { \dagger , \widehat { \pi } _ { - i } } ( s _ { 1 } ) - V _ { 1 , i } ^ { \widehat { \pi } } ( s _ { 1 } ) \leq \varepsilon$ for all $i \in [ m ]$ . This complete the proof of Theorem 2. □ + +# C PROOFS FOR SECTION 4 + +In this section we prove Theorem 5. We first define a set of lower value estimates $\underline { { V } } _ { h , i } ^ { k } ( s )$ (along with the upper estimates used in Algorithm 1) via the following update rule: + +$$ +\underline { { V } } _ { h , i } \left( s _ { h } \right) \gets \left( 1 - \alpha _ { t } \right) \underline { { V } } _ { h , i } \left( s _ { h } \right) + \alpha _ { t } \left( r _ { h , i } \left( s _ { h } , a _ { h } , \boldsymbol { a } _ { h , - i } \right) + \underline { { V } } _ { h + 1 , i } \left( s _ { h + 1 } \right) - \overline { { \beta } } _ { t } \right) . +$$ + +We emphasize that $\underline { { V } } _ { h , i } ^ { k } ( s )$ are analyses quantities only for simplifying the proof, and are not used by the algorithm. + +We restate and use several notations we introduced in the last section. At the beginning of any episode $k$ for a particular state $s _ { h }$ , we denote $k _ { h } ^ { 1 } ( s _ { h } ) < \cdots < k _ { h } ^ { N _ { h } ^ { k } ( s _ { h } ) } ( s _ { h } ) < k$ kNkh (sh)h (sh) < k to be all the episodes that the state $s _ { h }$ was visited, where $N _ { h } ^ { k } ( s _ { h } )$ is the times the state $s _ { h }$ has been visited before the start of $k$ -th episode. When there is no confusion, we sometimes will write $k ^ { j } = k _ { h } ^ { j } ( s _ { h } )$ in short. For player $i$ , we let $\underline { { V } } _ { h , i } ^ { k }$ , $\overline { { V } } _ { h , i } ^ { k }$ , $\mu _ { i } ^ { k }$ denote the values and policies maintained by Algorithm 4 at the beginning of $k$ -th episode, and $\mathbf { \Delta } \mathbf { a } _ { h } ^ { k }$ denote taken action at step $h$ and episode $k$ . For any joint policy $\mu _ { h }$ (over all players), reward function $r$ and value function $V$ , we define the operators $\mathbb { P } _ { h }$ and $\mathbb { D } _ { \mu _ { h } }$ as + +$$ +\begin{array} { r l } & { [ \mathbb { P } _ { h } V ] ( s , { \boldsymbol a } ) : = \mathbb { E } _ { s ^ { \prime } \sim \mathbb { P } _ { h } ( \cdot \vert s , { \boldsymbol a } ) } V ( s ^ { \prime } ) , } \\ & { \mathbb { D } _ { \boldsymbol { \mu } _ { h } } [ r + \mathbb { P } _ { h } V ] ( s ) : = \mathbb { E } _ { { \boldsymbol a } _ { h } \sim \boldsymbol { \mu } _ { h } } [ r ( s , { \boldsymbol a } _ { h } ) + \mathbb { E } _ { s _ { h + 1 } \sim \mathbb { P } _ { h } ( \cdot \vert s , { \boldsymbol a } _ { h } ) } V ( s _ { h + 1 } ) ] . } \end{array} +$$ + +The following lemma is the same as Lemma B.2 in the CCE case (except that for a different algorithm). + +Lemma C.1 (Update rule). Fix a state s in time step h and fix an episode $k$ , let $t = N _ { h } ^ { k } ( s )$ and suppose s was previously visited at episodes $k ^ { 1 } < \cdots < k ^ { t } < \bar { k }$ at the $h$ -th step. The update rule for $\overline { { V } } _ { h , i } ( s )$ and $\underline { { V } } _ { h , i } ( s )$ in Algorithm $I$ and (10) gives the following equations: + +$$ +\begin{array} { r l } & { \overline { { V } } _ { h , i } ^ { k } ( s ) = \alpha _ { t } ^ { 0 } H + \displaystyle \sum _ { j = 1 } ^ { t } \alpha _ { t } ^ { j } \left[ r _ { h , i } \left( s , a _ { h } ^ { k ^ { j } } , \pmb { a } _ { h , - i } ^ { k ^ { j } } \right) + \overline { { V } } _ { h + 1 , i } ^ { k ^ { j } } + \overline { { \beta } } _ { j } \right] , } \\ & { \underline { { V } } _ { h , i } ^ { k } ( s ) = \displaystyle \sum _ { j = 1 } ^ { t } \alpha _ { t } ^ { j } \left[ r _ { h , i } \left( s , a _ { h } ^ { k ^ { j } } , \pmb { a } _ { h , - i } ^ { k ^ { j } } \right) + \underline { { V } } _ { h + 1 , i } ^ { k ^ { j } } \left( s _ { h + 1 } ^ { k ^ { j } } \right) - \overline { { \beta } } _ { j } \right] . } \end{array} +$$ + +We next prove the following lemma which helps explain our choice of the bonus term $\overline { { \beta } } _ { t }$ . The constant $c$ in $\overline { { \beta } } _ { t }$ is the same with the constant $c$ in this lemma. For any policy modification $\varphi _ { i } : { \mathcal { A } } _ { i } { \mathcal { A } } _ { i }$ for the $i ^ { \mathrm { { t h } } }$ player and one-step policy $\pi _ { h } : { \mathcal { S } } \to \Delta _ { { \mathcal { A } } }$ for any $h$ , the modified policy $\varphi _ { i } \diamond \pi _ { h }$ is defined as follows: if $\pi _ { h }$ chooses to play $\pmb { a } = ( a _ { 1 } , \dots , a _ { m } )$ , the modified policy $\varphi _ { i } \diamond \pi _ { h }$ will play $( a _ { 1 } , \ldots , a _ { i - 1 } , \varphi _ { i } ( a _ { i } ) , a _ { i + 1 } , \ldots , a _ { m } )$ . Moreover, for $\pi _ { h , i } : { \mathcal { S } } \Delta _ { { \mathcal { A } } _ { i } }$ , policy $\varphi _ { i } \diamond \pi _ { h , i }$ chooses $\varphi _ { i } ( a )$ when $\pi _ { h , i }$ chooses $a$ . + +Lemma C.2 (Per-state guarantee). Fix a state s in time step $h$ and fix an episode $k$ , let $t = N _ { h } ^ { k } ( s )$ and suppose s was previously visited at episodes $k ^ { 1 } < \cdots < \dot { k } ^ { t } < k$ at the $h$ -th step. With probability $1 - { \frac { p } { 2 } }$ , for any $( i , s , h , t ) \in [ m ] \times S \times [ H ] \times [ K ] ,$ , there exist a constant c s.t. + +$$ +\begin{array} { r l } & { \displaystyle \operatorname* { s u p } _ { \varphi _ { i } : A _ { i } \to A _ { i } } \sum _ { j = 1 } ^ { t } \alpha _ { t } ^ { j } \mathbb { D } _ { \varphi _ { i } \circ \mu _ { h } ^ { k j } } \left( r _ { h , i } + \mathbb { P } _ { h } \operatorname* { m i n } \{ \overline { { V } } _ { h + 1 , i } ^ { k j } , H - h \} \right) ( s ) } \\ & { \displaystyle - \sum _ { j = 1 } ^ { t } \alpha _ { t } ^ { j } \left[ r _ { h , i } \left( s , a _ { h } ^ { k j } , \pmb { a } _ { h , - i } ^ { k j } \right) + \operatorname* { m i n } \{ \overline { { V } } _ { h + 1 , i } ^ { k j } ( s _ { h + 1 } ^ { k j } ) , H - h \} \right] \leq c H ^ { 2 } A _ { i } \sqrt { 2 \iota / t } + c H ^ { 2 } A _ { i } \iota / t . } \end{array} +$$ + +Proof of Lemma C.2 First, like the prove in Lemma B.3, we decompose + +$$ +\begin{array} { c } { { \displaystyle \operatorname* { s u p } _ { \varphi _ { i } : A _ { i } \to A _ { i } } \sum _ { j = 1 } ^ { t } \alpha _ { t } ^ { j } \mathbb { D } _ { \varphi _ { i } \circ \mu _ { h } ^ { k ^ { j } } } \left( r _ { h , i } + \mathbb { P } _ { h } \operatorname* { m i n } \{ \overline { { { V } } } _ { h + 1 , i } ^ { k ^ { j } } , H - h \} \right) ( s ) } } \\ { { - \displaystyle \sum _ { j = 1 } ^ { t } \alpha _ { t } ^ { j } \left[ r _ { h , i } \left( s , a _ { h } ^ { k ^ { j } } , a _ { h , - i } ^ { k ^ { j } } \right) + \operatorname* { m i n } \{ \overline { { { V } } } _ { h + 1 , i } ^ { k ^ { j } } ( s _ { h + 1 } ^ { k ^ { j } } ) , H - h \} \right] } } \end{array} +$$ + +into $R ^ { \star } ( i , s , h , t ) + U ( i , s , h , t )$ where + +$$ +\begin{array} { l } { R ^ { \star } ( i , s , h , t ) : = \displaystyle \operatorname* { s u p } _ { \varphi _ { i } : A _ { i } \to A _ { i } } \sum _ { j = 1 } ^ { t } \alpha _ { t } ^ { j } \mathbb { D } _ { \varphi _ { i } \diamond \mu _ { h } ^ { k ^ { j } } } \left( r _ { h , i } + \mathbb { P } _ { h } \operatorname* { m i n } \{ \overline { { V } } _ { h + 1 , i } ^ { k ^ { j } } , H - h \} \right) ( s ) } \\ { \displaystyle - \sum _ { j = 1 } ^ { t } \alpha _ { t } ^ { j } \mathbb { E } _ { a _ { - i } \sim \mu _ { h , - i } ^ { k ^ { j } } } \left[ r _ { h , i } \left( s , a _ { h } ^ { k ^ { j } } , a _ { - i } \right) + \mathbb { E } _ { s _ { h + 1 } \sim \mathbb { P } _ { h } ( \cdot \vert s , a _ { h } ^ { k ^ { j } } , a _ { - i } ) } \operatorname* { m i n } \{ \overline { { V } } _ { h + 1 , i } ^ { k ^ { j } } ( s _ { h + 1 } ) , H - h \} \right] , } \end{array} +$$ + +and + +$$ +\begin{array} { l } { { \displaystyle { J ( i , s , h , t ) : = \sum _ { j = 1 } ^ { t } \alpha _ { t } ^ { j } \mathbb { E } _ { a _ { - i } \sim \mu _ { h , - i } ^ { b ^ { j } } } \left[ r _ { h , i } \left( s , a _ { h } ^ { k ^ { j } } , a _ { - i } \right) + \mathbb { E } _ { s _ { h + 1 } \sim \mathbb { P } _ { h } ( \cdot \vert s , a _ { h } ^ { k ^ { j } } , a _ { - i } ) } \operatorname* { m i n } \{ \overline { { { V } } } _ { h + 1 , i } ^ { k ^ { j } } ( s _ { h + 1 } ) , H ( \cdot \vert s , a _ { - i } \vert ) \} \right. } } } \\ { { \displaystyle { \left. \qquad - \sum _ { j = 1 } ^ { t } \alpha _ { t } ^ { j } \left[ r _ { h , i } \left( s , a _ { h } ^ { k ^ { j } } , a _ { h , - i } ^ { k ^ { j } } \right) + \operatorname* { m i n } \{ \overline { { { V } } } _ { h + 1 , i } ^ { k ^ { j } } ( s _ { h + 1 } ^ { k ^ { j } } ) , H - h \} \right] . \right.} } } \end{array} +$$ + +We first bound $\boldsymbol { U } ( i , s , h , t )$ . By the same reason in proof of Lemma B.3, we can apply AzumaHoeffding inequality. Note that Ptj=1(αjt )2 ≤ 2H/t by Lemma B.1. Using Azuma-Hoeffding inequality, we have with probability at least $\begin{array} { r } { 1 - \frac { p } { 4 m H S K } } \end{array}$ , + +$$ +U ( i , s , h , t ) \leq \sqrt { 2 H ^ { 2 } \log ( 4 m H S K / p ) \sum _ { j = 1 } ^ { t } ( \alpha _ { t } ^ { j } ) ^ { 2 } } \leq 2 \sqrt { H ^ { 3 } \iota / t } . +$$ + +After taking a union bound, the following statement is true with probability at least $1 - p / 4$ , + +$$ +U ( i , s , h , t ) \leq 2 \sqrt { H ^ { 3 } \iota / t } \mathrm { ~ f o r ~ a l l ~ } ( i , s , h , t ) \in [ m ] \times \mathcal { S } \times [ H ] \times [ K ] . +$$ + +Then we bound $R ^ { \star } ( i , s , h , t )$ . For fixed $( i , s , h )$ , we define loss function + +$$ + \mathbf { \Sigma } _ { j } ^ { \prime } ( a ) = \frac { 1 } { H } \mathbb { E } _ { a _ { i } = a , a = \dots \mu \nu _ { k , - i } ^ { k j } } [ H - h + 1 - r _ { h , i } ( s , a ) - \mathbb { E } _ { s _ { h + 1 } \sim \mathbb { P } _ { h } ( \cdot \vert s , a , a - i ) } \operatorname* { m i n } \{ \overline { { V } } _ { h + 1 , i } ^ { k j } ( s _ { h + 1 } ) , H - h \} ] +$$ + +Algorithm 6 Correlated policy $\widehat { \pi } _ { h } ^ { k }$ for general-sum Markov games + +1: for step $h ^ { \prime } = h , \ldots , H$ do +2: Observe $s _ { h ^ { \prime } }$ , and set $t \gets N _ { h ^ { \prime } } ^ { k } ( s _ { h ^ { \prime } } )$ . +3: Sample $l \in [ t ]$ with $\mathbb { P } ( l = j ) = \alpha _ { t } ^ { j }$ . +4: Update $k \bar { k } _ { t } ^ { l } ( s _ { h ^ { \prime } } )$ . +5: Jointly take action $\begin{array} { r } \binom { 2 } { a _ { h ^ { \prime } , 1 } , a _ { h ^ { \prime } , 2 } , \dotsc , a _ { h ^ { \prime } , m } ) \sim \prod _ { i = 1 } ^ { m } \mu _ { h ^ { \prime } , i } ^ { k } ( \cdot | s _ { h ^ { \prime } } ) . } \end{array}$ + +Then we have $\ell _ { j } ( a ) \in [ 0 , 1 ]$ for all $a$ and the realized loss function: + +$$ +\tilde { \ell } _ { j } ( a _ { h } ^ { k ^ { j } } ) = \frac { 1 } { H } [ H - h + 1 - r _ { h , i } ( s , a _ { h } ^ { k ^ { j } } , \mathbf { a } _ { - i } ^ { k ^ { j } } ) - \operatorname* { m i n } \{ \overline { { V } } _ { h + 1 , i } ^ { k ^ { j } } ( s _ { h + 1 } ^ { k ^ { j } } ) , H - h \} ] \in [ 0 , 1 ] +$$ + +is an unbiased estimator of $\ell _ { j } ( a _ { h } ^ { k ^ { j } } )$ . Then $R ^ { \star } ( i , s , h , t )$ can be written as + +$$ +R ^ { \star } ( i , s , h , t ) = H \operatorname* { s u p } _ { \varphi _ { i } : A _ { i } A _ { i } } \sum _ { j = 1 } ^ { t } \alpha _ { t } ^ { j } [ \ell _ { j } ( a _ { h , i } ^ { k ^ { j } } ) - \langle \varphi _ { i } \diamond \mu _ { h , i } ^ { k ^ { j } } , \ell _ { j } \rangle ] . +$$ + +Now, for any fixed step $h$ and state $s$ , the distributions $\left\{ q _ { h } ^ { b } ( \cdot | s ) \right\} _ { b }$ and visitation counts $\left\{ N _ { h } ^ { b } ( s ) \right\} _ { b }$ are only updated at episodes $k _ { h } ^ { 1 } ( s ) , \ldots , k _ { h } ^ { t } ( s )$ . Further, these updates are exactly equivalent to the mixed-expert FTRL update algorithm which we describe in Algorithm 8. Therefore, the $R ^ { \star } ( i , s , h , t )$ above can be bounded by the weighted swap regret bound of Lemma F.1 (choosing the log term as $\begin{array} { r } { \iota = 4 \log { \frac { 1 0 m S A H K } { p } } ) } \end{array}$ 10mSAHK ) to yield that + +$$ +H \operatorname* { s u p } _ { \varphi _ { i } : A _ { i } \to A _ { i } } \sum _ { j = 1 } ^ { t } \alpha _ { t } ^ { j } [ \ell _ { j } ( a _ { h , i } ^ { k ^ { j } } ) - \langle \varphi _ { i } \diamond \mu _ { h , i } ^ { k ^ { j } } , \ell _ { j } \rangle ] \leq 4 0 H ^ { 2 } A _ { i } \sqrt { \iota / t } + 4 0 H ^ { 2 } A _ { i } \iota / t \mathrm { f o r } \mathrm { a l l } t \in [ K ] +$$ + +with probability at least $1 - p / ( 4 m S H )$ . Taking a union bound over all $( i , s , h ) \in [ m ] \times { \mathcal { S } } \times [ H ]$ , we have with probability at least $1 - p / 4$ , + +$$ +\begin{array} { r } { R ^ { \star } ( i , s , h , t ) \leq 4 0 H ^ { 2 } A _ { i } \sqrt { \iota / t } + 4 0 H ^ { 2 } A _ { i } \iota / t \mathrm { f o r } \mathrm { a l l } ( i , s , h , t ) \in [ m ] \times \mathcal { S } \times [ H ] \times [ K ] . } \end{array} +$$ + +Finally, we conclude that with probability at least $1 - p / 2$ , we have + +$\begin{array} { r } { J ( i , s , h , t ) + R ^ { \star } ( i , s , h , t ) \leq c H ^ { 2 } A _ { i } \sqrt { \iota / t } + c H ^ { 2 } A _ { i } \iota / t \mathrm { f o r ~ a l l } \left( i , s , h , t \right) \in [ m ] \times S \times [ H ] \times [ K ] } \end{array}$ for some absolute constant $c$ . + +We define the auxiliary certified policies $\widehat { \pi } _ { h } ^ { k }$ in Algorithm 6 (same as Algorithm 5 for the CCE case bbut repeated here for clarity). Again, we have the following relationship: + +$$ +V _ { 1 , i } ^ { \widehat { \pi } } ( s ) = \frac { 1 } { K } \sum _ { k = 1 } ^ { K } V _ { 1 , i } ^ { \widehat { \pi } _ { 1 } ^ { k } } ( s ) . +$$ + +Definition C.3 (Policy modification starting from the $h$ -th step). $A$ strategy modification starting from the $h$ -th step $\bar { \phi _ { \geq h } } : = \{ \phi _ { h ^ { \prime } , s } \} _ { ( h ^ { \prime } , s ) \in \{ h , h + 1 , \ldots , H \} \times S }$ for player $i$ is a set of $\dot { S } \times ( H - h + \bar { 1 ) }$ functions $\phi _ { h ^ { \prime } , s } : ( S \times { \mathcal { A } } ) ^ { h ^ { \prime } - h } \times { \mathcal { A } } _ { i } \to { \mathcal { A } } _ { i }$ . This strategy modification $\phi _ { \geq h }$ can be composed with any policy $\pi \in \Pi _ { \geq h }$ (as in Definition $B . 4$ ) to give a modified policy $\phi _ { \geq h } \circ \pi$ defined as follows: At any step $h ^ { \prime } \geq h$ and state $s$ with the history information starting from the $h$ -th step $\tau _ { h : h ^ { \prime } - 1 } = ( s _ { h } , \pmb { a } _ { h } , \cdot \cdot \cdot , s _ { h ^ { \prime } - 1 } , \pmb { a } _ { h ^ { \prime } - 1 } )$ , if $\pi$ chooses to play $\pmb { a } = ( a _ { 1 } , \dots , a _ { m } )$ , the modified policy $\phi \diamond \pi$ will play $( a _ { 1 } , \dots , a _ { i - 1 } , \phi _ { h ^ { \prime } , s } ( \tau _ { h : h ^ { \prime } - 1 } , a _ { i } ) , a _ { i + 1 } , \dots , a _ { m } )$ . We use $\Phi _ { \geq h , i }$ denote the set of all such possible strategy modifications for player $i$ . + +For any $\phi \in \Phi _ { \geq h , i } , \phi \circ \widehat { \pi } _ { h } ^ { k }$ also doesn’t depend on the history before the $h$ -th step, so $\phi \diamond \widehat { \pi } _ { h } ^ { k } \in \Pi _ { \geq h }$ , bwhich implies that V φπbkhh,i ( is well-defined in (8). + +Lemma C.4 (Valid upper and lower bounds). We have + +$$ +\overline { { V } } _ { h , i } ^ { k } ( s ) \geq \operatorname* { s u p } _ { \phi \in \Phi _ { \geq h , i } } V _ { h , i } ^ { \phi \circ \widehat { \pi } _ { h } ^ { k } } ( s ) , \quad \underline { { V } } _ { h , i } ^ { k } ( s ) \leq V _ { h , i } ^ { \widehat { \pi } _ { h } ^ { k } } ( s ) +$$ + +for all $( i , k , h , s ) \in [ m ] \times [ K ] \times [ H ] \times \mathcal { S }$ with probability at least $1 - p / 2$ . + +Proof of Lemma C.4 We prove this lemma by backward induction over $h \in [ H + 1 ]$ . The base case of $h = H + 1$ is true as all the value functions equal 0. Suppose the claim is true for $h + 1$ . We begin with upper bounding supφ∈Φ≥h,i $\begin{array} { r } { \operatorname* { s u p } _ { \phi \in \Phi _ { \geq h , i } } V _ { h , i } ^ { \phi \diamond \widehat { \pi } _ { h } ^ { k } } ( s ) } \end{array}$ . Let $t = N _ { h } ^ { k } ( s )$ and $k ^ { j } = k _ { h } ^ { j } ( s )$ for $1 \le j \le t$ to be the $j ^ { : }$ ’th time that $s$ is previously visited. By the definition of certified policies $\widehat { \pi } _ { h , i } ^ { k }$ and by the value iteration formula of MGs, we have for any $\phi \in \Phi _ { \geq h , i }$ , + +$$ +\begin{array} { r l } & { V _ { h , i } ^ { \phi \phi \widehat \pi _ { h } ^ { k } } ( s ) = \displaystyle \sum _ { j = 1 } ^ { t } \alpha _ { t } ^ { j } \mathbb { E } _ { a \sim \phi _ { h , i } \diamond \mu _ { h } ^ { k j } } \left[ r _ { h , i } ( s , a ) + \mathbb { E } _ { s ^ { \prime } \sim \mathbb { P } _ { h } ( \cdot \vert s , a ) } V _ { h + 1 , i } ^ { ( \phi _ { \geq h + 1 } \vert s , a ) \diamond \widehat \pi _ { h + 1 } ^ { k j } } ( s ^ { \prime } ) \right] } \\ & { \quad \quad \leq \displaystyle \sum _ { j = 1 } ^ { t } \alpha _ { t } ^ { j } \mathbb { E } _ { a \sim \phi _ { h , i } \diamond \mu _ { h } ^ { k j } } \left[ r _ { h , i } ( s , a ) + \mathbb { E } _ { s ^ { \prime } \sim \mathbb { P } _ { h } ( \cdot \vert s , a ) } \operatorname* { s u p } _ { \phi \in \Phi _ { \geq h + 1 , i } } V _ { h + 1 , i } ^ { \phi \circ \widehat \pi _ { h + 1 } ^ { k j } } ( s ^ { \prime } ) \right] . } \end{array} +$$ + +Here, $\phi _ { h , i }$ is the strategy modification function $\phi$ at the $h$ -th step, and $\left( \phi _ { \geq h + 1 } | s , \pmb { a } \right)$ is the modification $\phi$ from the $h + 1$ -th step with history information to be $s _ { h } = s$ and ${ \bf { a } } _ { h } = { \bf { a } }$ . By the definition of $\Phi _ { \geq h , i }$ , we have $( \phi _ { \geq h + 1 } | s , \pmb { a } ) \in \Phi _ { \geq h + 1 , i }$ which implies the above inequality. By taking supremum over $\phi \in \Phi _ { \geq h , i }$ and using the definition of the operator $\mathbb { D }$ in (6), we have + +$$ +\operatorname* { s u p } _ { \phi \in \Phi _ { \geq h , i } } V _ { h , i } ^ { \phi \circ \widehat { \pi } _ { h } ^ { k } } ( s ) \leq \operatorname* { s u p } _ { \varphi _ { i } : A _ { i } \to A _ { i } } \sum _ { j = 1 } ^ { t } \alpha _ { t } ^ { j } \mathbb { D } _ { \varphi _ { i } \diamond \mu _ { h } ^ { k j } } \big [ r _ { h , i } + \mathbb { P } _ { h } \operatorname* { s u p } _ { \phi \in \Phi _ { \geq h + 1 , i } } V _ { h + 1 , i } ^ { \phi \circ \widehat { \pi } _ { h + 1 } ^ { k j } } \big ] ( s ) . +$$ + +Condition on the high probability event (with probability at least $1 - p / 2$ ) in Lemma C.2, we can use the inductive hypothesis to obtain + +$$ +\begin{array} { r l } & { \underset { \psi \in \{ A , 1 , \ldots , A _ { j - 1 } ^ { k } \} } { \operatorname* { s u p } } \displaystyle \sum _ { i = 1 } ^ { j } \alpha _ { j } ^ { 2 } \mathbb { I } _ { \nabla _ { \phi \in \phi _ { \phi } ^ { k } } } \mathbb { I } _ { \Gamma _ { i , i } } + \mathbb { I } _ { \hat { \pi } _ { \delta } \times \hat { \pi } _ { \delta - 1 } } \displaystyle \sum _ { i = 1 , i } ^ { N _ { j } ^ { k } \otimes \mathcal { I } _ { i + 1 } ^ { k } } \big [ \big ( \delta ) } \\ & { \leq \underset { \psi \in \{ A , 1 , \ldots , A _ { j - 1 } ^ { k } \} } { \operatorname* { s u p } } \displaystyle \sum _ { i = 1 } ^ { j } \alpha _ { j } ^ { 2 } \mathbb { I } _ { \nabla _ { \phi \in \phi _ { \phi } ^ { k } } } \mathbb { I } _ { \Gamma _ { i , i } } + \mathbb { I } _ { \hat { \pi } _ { \delta } \times \hat { \pi } _ { \delta - 1 } } \big ( \overline { { \mathbb { V } _ { \hat { \pi } _ { i + 1 , i } ^ { k } \setminus \mathcal { I } _ { i } } ^ { k } } } - b \big ) \big ] \big ( s \big ) } \\ & \leq \displaystyle \sum _ { i = 1 } ^ { N } \alpha _ { j } ^ { 2 } \Big \langle \mathbb { I } _ { \Gamma _ { i , i } } \Big ( s , \alpha _ { j } ^ { 3 } , \alpha _ { i - \lfloor \lfloor \xi _ { i - 1 } ^ { k } \rfloor } ^ { k } \Big ) + \Pi \mathrm { i n } \{ \overline { { \mathbb { V } _ { \hat { \pi } _ { i + 1 , i } ^ { k } \delta ( s _ { i + 1 } ^ { k } ) , H } ^ { k } } - b \} \Big \} + c H ^ { 2 } 4 _ { i } \sqrt { i \mathcal { I } _ { i } } + c H ^ { 2 } A _ { i } \hat { \mu } \hat { \mu } } \\ & \overset { ( a ) } { \leq } \displaystyle \sum _ { j = 1 } ^ { \infty } \alpha _ { j } ^ { 2 } \Big [ \Gamma _ { i , j } \Big ( s , \alpha _ { j } ^ { 3 } , \alpha _ { i - \lfloor \xi _ { i - 1 } ^ { k } \rfloor } ^ { \beta } + \Pi \mathrm { i n } \{ \overline { V } _ { \hat { \pi } _ { i + 1 , i } ^ { k } } ( s _ { i + 1 } ^ { k } ) , H - h \} + \ \end{array} +$$ + +Here, (i) uses our choice of $\begin{array} { r } { \overline { { \beta } } _ { j } = c H ^ { 2 } A _ { i } \sqrt { \frac { \iota } { j } } + 2 c \frac { H ^ { 2 } A _ { i } \iota } { j } } \end{array}$ and $\begin{array} { r } { \frac { 1 } { \sqrt { j } } \leq \sum _ { j = 1 } ^ { t } \frac { \alpha _ { t } ^ { j } } { \sqrt { j } } , \frac { 1 } { t } \leq \sum _ { j = 1 } ^ { t } \frac { 2 \alpha _ { t } ^ { j } } { j } } \end{array}$ , so that $\begin{array} { r } { c H ^ { 2 } A _ { i } \sqrt { \iota / t } + c H ^ { 2 } A _ { i } \iota / t \leq \sum \alpha _ { t } ^ { j } \overline { { \beta } } _ { j } } \end{array}$ . + +Meanwhile, for $\underline { { V } } _ { h , i } ^ { k } ( s )$ , by the definition of certified policy and inductive hypothesis, + +$$ +\begin{array} { r l } & { V _ { h , i } ^ { \widehat { \pi } _ { h } ^ { k } } ( s ) = \displaystyle \sum _ { j = 1 } ^ { t } \alpha _ { t } ^ { j } \mathbb { D } _ { \mu _ { h } ^ { k ^ { j } } } \big [ r _ { h , i } + \mathbb { P } _ { h } V _ { h + 1 , i } ^ { \widehat { \pi } _ { h + 1 } ^ { k ^ { j } } } \big ] ( s ) } \\ & { \qquad \quad \geq \displaystyle \sum _ { j = 1 } ^ { t } \alpha _ { t } ^ { j } \mathbb { D } _ { \mu _ { h } ^ { k ^ { j } } } \big [ r _ { h , i } + \mathbb { P } _ { h } \operatorname* { m a x } \{ \underline { { V } } _ { h + 1 , i } ^ { k ^ { j } } , 0 \} \big ] ( s ) . } \end{array} +$$ + +Note tha $\begin{array} { r } { \tau \biggl \{ \mathbb { D } _ { \mu _ { h } ^ { k j } } \bigl [ r _ { h , i } + \mathbb { P } _ { h } \operatorname* { m a x } \left\{ \underline { { V } } _ { h + 1 , i } ^ { k j } , 0 \right\} \bigr ] ( s ) - \biggl [ r _ { h , i } \left( s , a _ { h } ^ { k _ { h } ^ { j } } , a _ { h , - i } ^ { k _ { h } ^ { j } } \right) + \operatorname* { m a x } \{ \underline { { V } } _ { h + 1 , i } ^ { k _ { h } ^ { j } } ( s _ { h + 1 } ^ { k _ { h } ^ { j } } ) , 0 \} \biggr ] \biggr \} _ { \substack { i > 1 } } } \end{array}$ is a martingale difference sequence w.r.t. the filtration $\{ \mathcal { G } _ { j } \} _ { j \ge 0 }$ , which is defined in the proof of Lemma B.3. So by Azuma-Hoeffding inequality, with probability at least 1 − p2mSKH , + +$$ +\begin{array} { c } { { \displaystyle \sum _ { j = 1 } ^ { t } \alpha _ { t } ^ { j } \mathbb { D } _ { \mu _ { h } ^ { k j } } [ r _ { h , i } + \mathbb { P } _ { h } \operatorname* { m a x } \{ \underline { { { V } } } _ { h + 1 , i } ^ { k ^ { j } } , 0 \} ] ( s ) } } \\ { { \displaystyle \geq \sum _ { j = 1 } ^ { t } \alpha _ { t } ^ { j } \left[ r _ { h , i } \left( s , a _ { h } ^ { k _ { h } ^ { j } } , a _ { h , - i } ^ { k _ { h } ^ { j } } \right) + \operatorname* { m a x } \{ \underline { { { V } } } _ { h + 1 , i } ^ { k _ { h } ^ { j } } ( s _ { h + 1 } ^ { k _ { h } ^ { j } } ) , 0 \} \right] - 2 \sqrt { \frac { H ^ { 3 } \iota } t } . } } \end{array} +$$ + +On this event, we have + +$$ +\begin{array} { r l } & { \quad \displaystyle \sum _ { j = 1 } ^ { k } \alpha _ { t } ^ { j } \mathbb { D } _ { \mu _ { h } ^ { k , j } } \big [ r _ { h , i } + \mathbb { P } _ { h } \operatorname* { m a x } \left\{ \underline { { V } } _ { h + 1 , i } ^ { k ^ { j } } , 0 \right\} \big ] ( s ) } \\ & { \stackrel { ( i ) } { \geq } \displaystyle \sum _ { j = 1 } ^ { k } \alpha _ { t } ^ { j } \left[ r _ { h , i } \left( s , a _ { h } ^ { k _ { h } ^ { j } } , a _ { h , - i } ^ { k _ { h } ^ { j } } \right) + \operatorname* { m a x } \left\{ \underline { { V } } _ { h + 1 , i } ^ { k _ { h } ^ { j } } ( s _ { h + 1 } ^ { k _ { h } ^ { j } } ) , 0 \right\} - \overline { { \beta } } _ { j } \right] } \\ & { \geq \displaystyle \sum _ { j = 1 } ^ { k } \alpha _ { t } ^ { j } \left[ r _ { h , i } \left( s , a _ { h } ^ { k _ { h } ^ { j } } , a _ { h , - i } ^ { k _ { h } ^ { j } } \right) + \underline { { V } } _ { h + 1 , i } ^ { k _ { h } ^ { j } } ( s _ { h + 1 } ^ { k _ { h } ^ { j } } ) - \overline { { \beta } } _ { j } \right] } \\ & { = \underline { { V } } _ { h , i } ^ { k } ( s ) . } \end{array} +$$ + +Here, (i) uses $\begin{array} { r } { \sum _ { j = 1 } ^ { t } \alpha _ { t } ^ { j } \beta _ { j } \geq 2 \sum _ { j = 1 } ^ { t } \alpha _ { t } ^ { j } \sqrt { H ^ { 3 } \iota / j } \geq 2 \sqrt { H ^ { 3 } \iota / t } . } \end{array}$ + +As a result, the backward induction would work well for all $h$ as long as the inequalities in Lemma C.2 and (12) hold for all $( i , s , h , k ) \in [ m ] \times S \times [ H ] \times [ K ]$ . Taking a union bound in all $( i , s , h , k ) \in [ m ] \times { \mathcal { S } } \times [ H ] \times [ K ]$ , we have with probability at least $\dot { 1 - p / 2 }$ , the inequality in (12) is true simultaneously for all $( i , \dot { s } , \dot { h , } k ) \in [ m ] \times \dot { \mathcal { S } } \times [ H ] \times \dot { [ K ] }$ . Therefore the inequalities in Lemma B.3 and (12) hold simultaneously for all $( i , s , h , k ) \in [ m ] \times S \times [ H ] \times [ K ]$ with probability at least $1 - p$ . This finishes the proof of this lemma. □ + +Equipped with these lemmas, we are ready to prove Theorem 5. + +Proof of Theorem 5 Conditional on the high probability event in Lemma C.4 (this happens with probability at least $1 - p )$ , we have + +$$ +\overline { { V } } _ { h , i } ^ { k } ( s ) \geq \operatorname* { s u p } _ { \phi \in \Phi _ { \geq h , i } } V _ { h , i } ^ { \phi \circ \widehat { \pi } _ { h } ^ { k } } ( s ) , \quad \underline { { V } } _ { h , i } ^ { k } ( s ) \leq V _ { h , i } ^ { \widehat { \pi } _ { h } ^ { k } } ( s ) +$$ + +for all $( i , s , h , k ) \in [ m ] \times S \times [ H ] \times [ K ]$ . Then, choosing $h = 1$ and $s = s _ { 1 }$ , we have + +$$ +\operatorname* { s u p } _ { \phi \in \Phi _ { i } } V _ { 1 , i } ^ { \phi \diamond \widehat { \pi } _ { 1 } ^ { k } } \big ( s _ { 1 } \big ) - V _ { 1 , i } ^ { \widehat { \pi } _ { 1 } ^ { k } } \big ( s _ { 1 } \big ) \leq \overline { { V } } _ { 1 , i } ^ { k } \big ( s _ { 1 } \big ) - \underline { { V } } _ { 1 , i } ^ { k } \big ( s _ { 1 } \big ) . +$$ + +Moreover, by (11), value function of certified policy can be decomposed as + +$$ +V _ { 1 , i } ^ { \widehat { \pi } } ( s _ { 1 } ) = \frac { 1 } { K } \sum _ { k = 1 } ^ { K } V _ { 1 , i } ^ { \widehat { \pi } _ { 1 } ^ { k } } ( s _ { 1 } ) , \quad V _ { 1 , i } ^ { \phi \diamond \widehat { \pi } } ( s _ { 1 } ) = \frac { 1 } { K } \sum _ { k = 1 } ^ { K } V _ { 1 , i } ^ { \phi \diamond \widehat { \pi } _ { 1 } ^ { k } } ( s _ { 1 } ) , +$$ + +where the decomposition is due to the first line in the Algorithm 2: sample $k \gets \mathrm { U n i f o r m } ( [ K ] )$ . Therefore we have the following bound on $\begin{array} { r } { \operatorname* { s u p } _ { \phi \in \Phi _ { i } } V _ { 1 , i } ^ { \phi \diamond \widehat { \pi } } ( s _ { 1 } ) - V _ { 1 , i } ^ { \widehat { \pi } } ( s _ { 1 } ) } \end{array}$ : + +$$ +\operatorname* { s u p } _ { \phi \in \Phi _ { i } } V _ { 1 , i } ^ { \phi \diamond \widehat { \pi } } ( s _ { 1 } ) - V _ { 1 , i } ^ { \widehat { \pi } } ( s _ { 1 } ) = \operatorname* { s u p } _ { \phi \in \Phi _ { i } } \frac { 1 } { K } \sum _ { k = 1 } ^ { K } V _ { 1 , i } ^ { \phi \diamond \widehat { \pi } _ { 1 } ^ { k } } ( s _ { 1 } ) - V _ { 1 , i } ^ { \widehat { \pi } } ( s _ { 1 } ) +$$ + +$$ +\leq \frac { 1 } { K } \sum _ { k = 1 } ^ { K } \left( \operatorname* { s u p } _ { \phi \in \Phi _ { i } } V _ { 1 , i } ^ { \phi \circ \widehat { \pi } _ { 1 } ^ { k } } ( s _ { 1 } ) - V _ { 1 , i } ^ { \widehat { \pi } _ { 1 } ^ { k } } ( s _ { 1 } ) \right) \leq \frac { 1 } { K } \sum _ { k = 1 } ^ { K } \left( \overline { { V } } _ { 1 , i } ^ { k } ( s _ { 1 } ) - \underline { { V } } _ { 1 , i } ^ { k } ( s _ { 1 } ) \right) . +$$ + +By Lemma C.4 Letting $\delta _ { h , i } ^ { k } : = \overline { { V } } _ { h , i } ^ { k } ( s _ { h } ^ { k } ) - \underline { { V } } _ { h , i } ^ { k } ( s _ { h } ^ { k } )$ and $t = N _ { h } ^ { k } ( s _ { h } ^ { k } )$ . By the update rule, we have + +$$ +\begin{array} { l } { { \displaystyle \delta _ { h , i } ^ { k } = \overline { { { V } } } _ { h , i } ^ { k } ( s _ { h } ^ { k } ) - \underline { { { V } } } _ { h , i } ^ { k } ( s _ { h } ^ { k } ) } } \\ { { \displaystyle \quad = \alpha _ { t } ^ { 0 } H + \sum _ { j = 1 } ^ { t } \alpha _ { t } ^ { j } \big [ \overline { { { V } } } _ { h + 1 , i } ^ { k } ( s _ { h + 1 } ^ { k j } ) - \underline { { { V } } } _ { h + 1 , i } ^ { k } ( s _ { h + 1 } ^ { k j } ) + 2 \overline { { { \beta _ { j } } } } \big ] } } \\ { { \displaystyle \quad = \alpha _ { t } ^ { 0 } H + \sum _ { j = 1 } ^ { t } \alpha _ { t } ^ { j } \delta _ { h + 1 , i } ^ { k j } + \sum _ { j = 1 } ^ { t } 2 \alpha _ { t } ^ { j } \overline { { { \beta } } } _ { j } } } \\ { { \displaystyle \quad = \alpha _ { t } ^ { 0 } H + \sum _ { j = 1 } ^ { t } \alpha _ { t } ^ { j } \delta _ { h + 1 , i } ^ { k j } + 2 c A _ { i } H ^ { 2 } \sum _ { j = 1 } ^ { t } \alpha _ { t } ^ { j } \sqrt { \frac { t } { j } } + 4 c \sum _ { j = 1 } ^ { t } \alpha _ { t } ^ { j } \frac { H ^ { 2 } A _ { i } t } { j } . } } \end{array} +$$ + +Taking the summation w.r.t. $\mathrm { k }$ , by the same argument in the proof of Theorem 2, we can get + +$$ +\begin{array} { r l } & { \displaystyle \operatorname* { m a x } _ { \phi \in \Phi } V _ { 1 , i } ^ { \phi \circ \widehat { \pi } } ( s _ { 1 } ) - V _ { 1 , i } ^ { \widehat { \pi } } ( s _ { 1 } ) = \frac { 1 } { K } \sum _ { k = 1 } ^ { K } \left( \overline { { V } } _ { 1 , i } ^ { k } ( s _ { 1 } ) - \underline { { V } } _ { 1 , i } ^ { k } ( s _ { 1 } ) \right) = \frac { 1 } { K } \sum _ { k = 1 } ^ { K } \delta _ { 1 , i } ^ { k } } \\ & { \leq \mathcal { O } ( 1 ) { S } H ^ { 4 } \operatorname* { m a x } _ { i \in [ m ] } A _ { i } \iota ^ { 3 } / K + \mathcal { O } \left( \sqrt { H ^ { 6 } S \operatorname* { m a x } _ { i \in [ m ] } A _ { i } ^ { 2 } \iota / K } \right) . } \end{array} +$$ + +Therefore, if $\begin{array} { r } { K \ \ge \ { \mathcal O } ( \frac { H ^ { 6 } S \operatorname* { m a x } _ { i \in [ m ] } A _ { i } ^ { 2 } \iota } { \varepsilon ^ { 2 } } + \frac { H ^ { 4 } S \operatorname* { m a x } _ { i \in [ m ] } A _ { i } \iota ^ { 3 } } { \varepsilon } ) } \end{array}$ , we have $\begin{array} { r } { \operatorname* { m a x } _ { \phi \in \Phi } V _ { 1 , i } ^ { \phi \diamond \widehat { \pi } } ( s _ { 1 } ) \ - } \end{array}$ $V _ { 1 , i } ^ { \widehat { \pi } } ( s _ { 1 } ) \leq \varepsilon$ holds for all $i \in [ m ]$ , which means $\widehat { \pi }$ is an $\varepsilon$ -approximate CE. This completes the proof of Theorem 2. □ + +# D PROOFS FOR SECTION 5 + +Here, we first define pure-strategy Nash equilibrium. We say policy $\pi$ is a pure strategy (deterministic policy) if and only if for any $( \bar { h , i } , s ) \in [ \bar { H ] } \times [ m ] \times S , \pi _ { h , i } \bar { ( a _ { i } | s ) } \stackrel { . . } { = } \mathbb { I } _ { a _ { i } = a _ { h \ , i } ^ { \prime } ( s ) }$ for some $a _ { h , i } ^ { \prime } ( s )$ . We say $\pi$ a pure-strategy Nash equilibrium if $\pi$ is a pure-strategy and is a Nash equilibrium. Similarly, we say $\pi$ is a pure strategy $\varepsilon$ -approximate Nash equilibrium if $\pi$ is a pure strategy and $\mathrm { N E - g a p } ( \pi ) \leq \varepsilon$ . Pure-strategy Nash equilibrium does not always exist in general-sum MGs, but is guaranteed to exist (as we will see) in Markov Potential Games. + +D.1 EXISTENCE OF PURE-STRATEGY NASH EQUILIBRIA IN MARKOV POTENTIAL GAMES + +A particular property of MPGs is that, there always exists a pure-strategy Nash equilibrium. Such a property does not hold for every general-sum MG. Pure-strategy Nash equilibria are preferred in many scenarios since each player can take deterministic actions. + +Proposition D.1. For any Markov potential games, there exists a pure-strategy Nash equilibrium. + +See Theorem 3.1 in Leonardos et al. (2021) or Proposition 1 in Zhang et al. (2021) for a proof of Proposition D.1. + +# D.2 THE UCBVI-UPLOW SUB-ROUTINE + +In this subsection we consider the problem of learning a near optimal policy in the fixed horizon stochastic reward RL problem $\mathrm { M D P } ( H , S , { \mathcal { A } } , \mathbb { P } , r )$ . The setting is standard (c.f. Jin et al. (2018)) and is a special case of Markov games (c.f. Section 2) by setting the number of agents $m = 1$ . We will use the same notations including policies and value functions as that of the Markov games as + +# Algorithm 7 UCB-VI with Upper and Lower Confidence Bounds (UCBVI-UPLOW) + +1: Initialize: For any $( s , a , h , s ^ { \prime } )$ : $\overline { { Q } } _ { h } ( s , a ) \ \ H$ , $\underline { { Q } } _ { h } ( s , a ) \ \ 0$ , $N _ { h } ( s ) \ = \ N _ { h } ( s , a ) \ =$ +$N _ { h } ( s , a , s ^ { \prime } ) \gets 0$ . +2: for episode $k = 1 , \ldots , K$ do +3: for step $h = H , \ldots , 1$ do +4: for $( s , a ) \in S \times \mathcal { A }$ do +5: Set $t \gets N _ { h } ( s , a )$ . +6: if $t > 0$ then +7: $\beta \gets \mathrm { B o n v o s } ( t , \widehat { \mathbb { V } } _ { h } [ ( \overline { { V } } _ { h + 1 } + \underline { { V } } _ { h + 1 } ) / 2 ] ( s , a ) )$ (c.f. Eq. (13)) +8: $\gamma ( c / H ) \cdot \widehat { \mathbb { P } } _ { h } ( \overline { { V } } _ { h + 1 } - \underline { { V } } _ { h + 1 } ) ( s , a )$ . +9: $\begin{array} { r l } & { \overline { { Q } } _ { h } ( s , a ) \gets \operatorname* { m i n } \Big \{ ( r _ { h } + \widehat { \mathbb { P } } _ { h } \overline { { V } } _ { h + 1 } ) ( s , a ) + \gamma + \beta , H \Big \} . } \\ & { \underline { { Q } } _ { h } ( s , a ) \gets \operatorname* { m a x } \Big \{ ( r _ { h } + \widehat { \mathbb { P } } _ { h } \underline { { V } } _ { h + 1 } ) ( s , a ) - \gamma - \beta , 0 \Big \} } \end{array}$ +10: +11: for $s \in S$ do +12: $\pi _ { h } ( s ) \gets \arg \operatorname* { m a x } _ { a \in \mathcal { A } } \overline { { Q } } _ { h } ( s , a )$ . +13: $\overline { { { V } } } _ { h } ( s ) \overline { { { Q } } } _ { h } ( s , \pi _ { h } ( s ) ) ; \underline { { { V } } } _ { h } ( s ) \underline { { { Q } } } _ { h } ( s , \pi _ { h } ( s ) ) .$ . +14: Receive the initial state $s _ { 1 }$ from the MDP. +15: for step $h = 1 , \ldots , H$ do +16: Take action $a _ { h } = \pi _ { h } ( s _ { h } )$ , observe reward $r _ { h }$ and next state $s _ { h + 1 }$ . +17: Increment $N _ { h } ( s _ { h } )$ , $N _ { h } ( s _ { h } , a _ { h } )$ , and $N _ { h } ( s _ { h } , a _ { h } , s _ { h + 1 } )$ by 1. +18: $\widehat { \mathbb { P } } _ { h } ( \cdot | s _ { h } , a _ { h } ) \gets N _ { h } ( s _ { h } , a _ { h } , \cdot ) / N _ { h } ( s _ { h } , a _ { h } ) .$ . +19: Let $( \overline { { V } } _ { h } ^ { k } , \underline { { V } } _ { h } ^ { k } , \pi ^ { k } )$ denote the value estimates and policy at the beginning of episode $k$ . +20: return Policy $\pi ^ { k _ { \star } }$ where $\begin{array} { r } { k _ { \star } = \arg \operatorname* { m i n } _ { k \in [ K ] } ( \overline { { V } } _ { 1 } ^ { k } ( s _ { 1 } ) - \underline { { V } } _ { 1 } ^ { k } ( s _ { 1 } ) ) . } \end{array}$ . + +introduced in Section 2, except that we will omit the sub-scripts $i$ ’s since here we just have a single agent. + +We consider the UCBVI-UPLOW algorithm (Algorithm 7), which is adapted from (Xie et al., 2021; Liu et al., 2021), for learning approximate optimal policy in reinforcement learning problems. Such an algorithm is used as a sub-routine in Algorithm 3 to learn approximate pure-strategy Nash equilibria in MPGs. We remark that although in Algorithm 3 we propose to use the UCBVI-UPLOW algorithm to search for a near optimal policy, many alternative algorithms can be used to find the near optimal policy (e.g., UCBVI (Azar et al., 2017) or Q-learning (Jin et al., 2018)). Here we choose the UCBVIUPLOW algorithm because 1) it has a tight sample complexity bound; 2) it outputs a deterministic policy which can be used to find a pure-strategy approximate Nash equilibrium. + +In the description of Algorithm 7, the $\widehat { \mathbb { P } } _ { h }$ quantity appeared in lines 8,9,10, and 18 can be viewed either as a set of empirical probability distributions or as an operator: for any fixed $\left( s _ { h } , a _ { h } \right)$ , we can view $\widehat { \mathbb { P } } _ { h } ( \cdot | s _ { h } , a _ { h } )$ as a probability distribution over $s$ ; for any given function $V : S \mathbb { R }$ , we can view $\widehat { \mathbb { P } } _ { h }$ as an operator by defining $( \widehat { \mathbb { P } } _ { h } V ) ( s , a ) : = \mathbb { E } _ { s ^ { \prime } \sim \widehat { \mathbb { P } } _ { h } ( \cdot | s , a ) } [ V ( s ^ { \prime } ) ]$ . The $\widehat { \mathbb { V } } _ { h }$ operator in line 7 is the empirical variance operator defined as ${ \widehat { \mathbb { V } } _ { h } } V = { \widehat { \mathbb { P } } _ { h } } V ^ { 2 } - ( { \widehat { \mathbb { P } } _ { h } } V ) ^ { 2 }$ . The BONUS function in the algorithm is chosen to be the Bernstein type bonus function + +$$ +\begin{array} { r } { \mathrm { B O N U S } ( t , \widehat { \sigma } ^ { 2 } ) = c ( \sqrt { \widehat { \sigma } ^ { 2 } \iota / t } + H ^ { 2 } S \iota / t ) . } \end{array} +$$ + +We have the following sample complexity guarantee for the UCBVI-UPLOW algorithm returning an $\varepsilon$ -approximate optimal policy. + +Lemma D.2. The UCBVI-UPLOW algorithm always returns a deterministic policy $\pi ^ { k _ { \star } }$ . Moreover, for any $p \in ( 0 , 1 ] ,$ , letting $\iota = \log ( S A H K / p )$ and taking the number of episodes + +$$ +K \ge \mathcal { O } ( H ^ { 3 } S A \iota / \varepsilon ^ { 2 } + H ^ { 3 } S ^ { 2 } A \iota ^ { 2 } / \varepsilon ) , +$$ + +then with probability at least $1 \ : - \ : p ,$ , the returned policy $\pi ^ { k _ { \star } }$ is $\varepsilon$ -approximate optimal, i.e., $\operatorname* { s u p } _ { \mu } V _ { 1 } ^ { \mu } ( s _ { 1 } ) - V _ { 1 } ^ { \pi ^ { k _ { \star } } } ( s _ { 1 } ) \leq \varepsilon$ . + +Proof of Lemma D.2 First, $\pi ^ { k _ { \star } }$ is obviously deterministic from line 12 of Algorithm 7. + +The sample complexity guarantee of the UCBVI-UPLOW algorithm is a consequence of the sample complexity guarantee of the Nash-VI algorithm for learning Nash in zero-sum Markov games as proved in Liu et al. (2021). + +More specifically, we denote the rewards and transition matrices by $\{ r _ { h } ( s , a ) \} _ { h \in [ H ] }$ and $\mathbb { P } =$ $\{ P _ { h } ( s _ { h + 1 } | s _ { h } , a _ { h } ) \} _ { h \in [ H ] }$ for the $\mathrm { M D P } ( H , S , { \mathcal { A } } , \mathbb { P } , r )$ . Such a MDP can be viewed as a zero-sum Markov game $\mathrm { M G } ( H , \mathcal { S } , \mathcal { A } , \mathcal { B } , \overline { { \mathbb { P } } } , \bar { r } )$ , in which $( H , S , A )$ are the same as that of the MDP, the action space for the min-player is a singleton $B = 1$ so that the rewards $\bar { r } _ { h } ( s , a , b ) \equiv r _ { h } ( s , a )$ do not depend on the action of the min-player and the transition matrices $\overline { { \mathbb { P } } } _ { h } ( \cdot | s , a , b ) = \mathbb { P } _ { h } ( \cdot | s , a _ { 1 } )$ do not depend on the action of the min-player either. Then, for any $\varepsilon$ -approximate Nash equilibrium $( \mu , \nu )$ of the associated zero-sum Markov game, the max-player’s policy $\mu$ must be $\varepsilon$ -approximate optimal for the original MDP. + +By this correspondence, the UCBVI-UPLOW algorithm is actually a specific version of the Nash-VI algorithm in Liu et al. (2021), and Line 12 in UCBVI-UPLOW is actually a specific version of line 12 in Nash-VI in Liu et al. (2021): this is because in this specific Markov game, $\overline { { Q } } ( s , a , b )$ and $Q ( s , a , b )$ only depend on $s$ and $a$ , so that $\pi _ { h } ( s ) = \arg \operatorname* { m a x } _ { a \in \mathcal { A } } \overline { { Q } } _ { h } ( s , a )$ is actually in the CCE set $\mathrm { C C E } ( \overline { { Q } } _ { h } ( s , a , b ) , \underline { { Q } } _ { h } ( s , a , b ) )$ . + +By this reduction and by Theorem 4 in Liu et al. (2021), this lemma is proved. + +# D.3 PROOF OF THEOREM 7 + +We use superscript $t$ to represent variables at the $t$ -th step (before $\pi$ is updated) of the while loop. + +Because we can choose the log factor as $\begin{array} { r } { \iota \ = \ 4 \log ( \frac { m H S K \operatorname* { m a x } _ { i \in [ m ] } A _ { i } } { \varepsilon p } ) } \end{array}$ ( mHSK maxi∈[m] Ai ) (this doesn’t affect the correctness of the theorem), for each execution of UCBVI-UPLOW, by Lemma D.2, it return a $\varepsilon / 4$ -optimal deterministic policy with probability at least $\begin{array} { r } { 1 - \frac { p \varepsilon } { 8 m ^ { 2 } H } } \end{array}$ . Taking a union bound, we have + +$$ +\operatorname* { m a x } _ { \mu _ { i } } V _ { 1 , i } ( \mu _ { i } , \pi _ { - i } ^ { t } ) - V _ { 1 , i } ( \widehat { \pi } _ { i } ^ { t } , \pi _ { - i } ^ { t } ) \leq \varepsilon / 4 +$$ + +simultaneously for all $i \in [ m ]$ and $t \leq 4 m H / \varepsilon$ with probability at least $1 - p / 2$ . For the empirical estimator $\widehat { V } _ { 1 , i } ^ { t }$ , it’s bounded in $[ 0 , H ]$ . Thus by Hoeffding’s inequality, for fixed $i \in [ m ]$ and $t$ + +$$ +\mathbb { P } ( | \widehat { V } _ { 1 , i } ^ { t } - V _ { 1 , i } ^ { t } | \geq \varepsilon / 8 ) \leq 2 \exp \left( - \frac { N \varepsilon ^ { 2 } } { 3 2 H ^ { 2 } } \right) . +$$ + +Choosing $N = C H ^ { 2 } \iota / \varepsilon ^ { 2 }$ for some large constant $C$ , we have + +$$ +\mathbb { P } ( | \widehat { V } _ { 1 , i } ^ { t } - V _ { 1 , i } ^ { t } | \geq \varepsilon / 8 ) \leq \frac { \varepsilon p } { 1 6 m ^ { 2 } H } . +$$ + +Apply this inequality to $\widehat { V } _ { 1 , i } ^ { t } ( \widehat { \pi } _ { i } ^ { t } , \pi _ { - i } ^ { t } )$ and $\widehat { V } _ { 1 , i } ( \pi ^ { t } )$ and taking a union bound, we have + +$$ +| \widehat { V } _ { 1 , i } ^ { t } ( \widehat { \pi } _ { i } ^ { t } , \pi _ { - i } ^ { t } ) - V _ { 1 , i } ( \widehat { \pi } _ { i } ^ { t } , \pi _ { - i } ^ { t } ) | \leq \varepsilon / 8 , \quad | \widehat { V } _ { 1 , i } ^ { t } ( \pi ^ { t } ) - V _ { 1 , i } ( \pi ^ { t } ) | \leq \varepsilon / 8 +$$ + +simultaneously for all $i \in [ m ]$ and $\begin{array} { r } { t \leq \frac { 4 m H } { \varepsilon } } \end{array}$ with probability at least $1 - p / 2$ . As a result, by (14) and (15), we have + +$$ +\begin{array} { r } { \underset { \mu _ { i } } { \operatorname* { m a x } } V _ { 1 , i } ( \mu _ { i } , \pi _ { - i } ^ { t } ) - V _ { 1 , i } ( \widehat { \pi } _ { i } ^ { t } , \pi _ { - i } ^ { t } ) \leq \varepsilon / 4 } \\ { | \widehat { V } _ { 1 , i } ^ { t } ( \widehat { \pi } _ { i } ^ { t } , \pi _ { - i } ^ { t } ) - V _ { 1 , i } ( \widehat { \pi } _ { i } ^ { t } , \pi _ { - i } ^ { t } ) | \leq \varepsilon / 8 } \\ { | \widehat { V } _ { 1 , i } ^ { t } ( \pi ^ { t } ) - V _ { 1 , i } ( \pi ^ { t } ) | \leq \varepsilon / 8 } \end{array} +$$ + +simultaneously for all $i \in [ m ]$ and $t \leq 4 m H / \varepsilon$ with probability at least $1 - p$ . On this event, + +$$ +\begin{array} { r l } & { \Delta _ { i } ^ { t } = \widehat { V } _ { 1 , i } ^ { t } ( \widehat { \pi } _ { i } ^ { t } , \pi _ { - i } ^ { t } ) - \widehat { V } _ { 1 , i } ^ { t } ( \pi ^ { t } ) } \\ & { \qquad \leq V _ { 1 , i } ( \widehat { \pi } _ { i } ^ { t } , \pi _ { - i } ^ { t } ) - V _ { 1 , i } ( \pi ^ { t } ) + \varepsilon / 4 . } \end{array} +$$ + +If the while loop doesn’t end after the $t$ -th iteration and $t \leq 4 m H / \varepsilon$ , there exists $j ^ { t }$ s.t. $\Delta _ { j ^ { t } } ^ { t } \geq \varepsilon / 2$ , so we have + +$$ +\begin{array} { r l } & { \Phi ( \pi ^ { t + 1 } ) - \Phi ( \pi ^ { t } ) = \Phi ( \widehat { \pi } _ { j ^ { t } } ^ { t } , \pi _ { - j ^ { t } } ^ { t } ) - \Phi ( \pi ^ { t } ) } \\ & { \qquad \stackrel { ( i ) } { = } V _ { 1 , j ^ { t } } ( \widehat { \pi } _ { j ^ { t } } ^ { t } , \pi _ { - j ^ { t } } ^ { t } ) - V _ { 1 , j ^ { t } } ( \pi ^ { t } ) } \\ & { \qquad \geq \Delta _ { j ^ { t } } ^ { t } - \varepsilon / 4 = \varepsilon / 4 . } \end{array} +$$ + +Here, $( i )$ follows the definition of potential function. Because $\Phi$ is bounded, the while loop ends within $4 \Phi _ { \mathrm { m a x } } / \varepsilon \leq 4 m H / \varepsilon$ steps. Therefore, (16) holds simultaneously for all $i \in [ m ]$ and $t$ before the end of while loop with probability at least $1 - p$ . Again, on this event, if the while loop stops at the end of $t$ -th step, we have $\operatorname* { m a x } _ { i \in [ m ] } \Delta _ { i } ^ { t } \leq \varepsilon / 2$ , then + +$$ +\begin{array} { r l } { \underset { \mu _ { i } } { \operatorname* { m a x } } V _ { 1 , i } ( \mu _ { i } , \pi _ { - i } ^ { t } ) - V _ { 1 , i } ( \pi ^ { t } ) = \underset { \mu _ { i } } { \operatorname* { m a x } } V _ { 1 , i } ( \mu _ { i } , \pi _ { - i } ^ { t } ) - V _ { 1 , i } ( \widehat { \pi } _ { i } ^ { t } , \pi _ { - i } ^ { t } ) + V _ { 1 , i } ( \widehat { \pi } _ { i } ^ { t } , \pi _ { - i } ^ { t } ) - V _ { 1 , i } ( \pi ^ { t } ) } & { } \\ { \leq \varepsilon / 4 + \widehat { V } _ { 1 , i } ^ { t } ( \widehat { \pi } _ { i } ^ { t } , \pi _ { - i } ^ { t } ) - \widehat { V } _ { 1 , i } ^ { t } ( \pi ^ { t } ) + 2 \varepsilon / 8 } & { } \\ { = \varepsilon / 2 + \Delta _ { i } ^ { t } } & { } \\ { \leq \varepsilon . } \end{array} +$$ + +So the returned policy $\pi ^ { t }$ is a $\varepsilon$ -approximate Nash equilibrium. Moreover, since UCBVI-UPLOW outputs a pure-strategy policy and our initial policy is also a pure-strategy policy, we can conclude that with probability at least $1 - p$ , within $4 \Phi _ { \mathrm { m a x } } / \varepsilon$ steps of the while loop, Algorithm 3 outputs an $\varepsilon$ -approximate (pure-strategy) Nash equilibrium. + +Finally, the number of episodes within each step of the while loop is + +$$ +\begin{array} { l } { { \displaystyle N + \sum _ { i = 1 } ^ { m } ( K _ { i } + N ) = { \mathcal O } \left( \frac { H ^ { 3 } S \sum _ { i = 1 } ^ { m } A _ { i } \iota } { \varepsilon ^ { 2 } } + \frac { H ^ { 3 } S ^ { 2 } \sum _ { i = 1 } ^ { m } A _ { i } \iota ^ { 2 } } { \varepsilon } + \frac { H ^ { 2 } m \iota } { \varepsilon ^ { 2 } } \right) } } \\ { { \displaystyle = { \mathcal O } \left( \frac { H ^ { 3 } S \sum _ { i = 1 } ^ { m } A _ { i } \iota } { \varepsilon ^ { 2 } } + \frac { H ^ { 3 } S ^ { 2 } \sum _ { i = 1 } ^ { m } A _ { i } \iota ^ { 2 } } { \varepsilon } \right) . } } \end{array} +$$ + +So the total sample complexity (episodes) is at most + +$$ +K = { \mathcal O } \left( \frac { \Phi _ { \mathrm { m a x } } H ^ { 3 } S \sum _ { i = 1 } ^ { m } A _ { i } \iota } { \varepsilon ^ { 3 } } + \frac { \Phi _ { \mathrm { m a x } } H ^ { 3 } S ^ { 2 } \sum _ { i = 1 } ^ { m } A _ { i } \iota ^ { 2 } } { \varepsilon ^ { 2 } } \right) . +$$ + +This concludes the proof. + +# E LOWER BOUND OF FINDING APPROXIMATE PURE-STRATEGY NASH EQUILIBRIUM + +In this section, we present an result on the sample complexity lower bound for learning a pure-strategy Nash equilibrium in MPGs (a harder task than learning Nash as pure-strategy Nash is a stricter notion). We remark that our lower bounds are actually constructed on Markov Cooperative Games (MCGs) which is a subset of MPGs. Note that for MCGs, the potential function $\Phi$ is bounded in $[ 0 , H ]$ , so by Theorem 7, the sample complexity of Nash-CA (Algorithm 3) is $\widetilde { \mathcal { O } } ( \sum _ { i = 1 } ^ { m } A _ { i } / \varepsilon ^ { 3 } )$ highlighting the dependency on $\varepsilon$ , $m$ and $A _ { i }$ $_ i , i = 1 , \ldots , m$ . We would show this $\textstyle \sum _ { i = 1 } ^ { m } A _ { i }$ dependency is inevitable for learning $\varepsilon$ -approximate pure-strategy Nash equilibrium in MCGs by proving an $\textstyle \Omega ( \sum _ { i = 1 } ^ { m } A _ { i } / \varepsilon ^ { 2 } )$ lower bound. + +We first present our main theorem: + +Theorem E.1 (Lower bound for learning pure-strategy Nash in MCGs). Suppose $A _ { i } = 2 k , i =$ $1 , \ldots , m$ , $H \geq 2$ , $S \geq 3$ and $m \geq 4$ . Then, there exists an absolute constant $c _ { 0 }$ such that for any $\varepsilon \leq 0 . 4$ and any online finetuning algorithm $\mathcal { M }$ that outputs a pure-strategy policy $\widehat { \pi } = ( \widehat { \pi } _ { 1 } , \ldots , \widehat { \pi } _ { m } )$ , if the number of episodes + +$$ +K \leq c _ { 0 } \frac { H ^ { 2 } \sum _ { i = 1 } ^ { m } A _ { i } } { \varepsilon ^ { 2 } } = c _ { 0 } \frac { 2 k m H ^ { 2 } } { \varepsilon ^ { 2 } } , +$$ + +then there exists general-sum Markov cooperative game M G on which the algorithm $\mathcal { M }$ suffers from $\varepsilon / 4$ -suboptimality, i.e. + +$$ +\begin{array} { r } { \mathbb { E } _ { M } N E { \cdot } g a p ( \widehat { \pi } ) \geq \varepsilon / 4 , } \end{array} +$$ + +where the expectation $\mathbb { E } _ { M }$ is w.r.t. the randomness during the algorithm’s execution within Markov game MG. + +This theorem can be viewed as a corollary of the following lemma by a simple reduction. We would prove this theorem in the next subsection. One-step (general-sum) game is a game with only one state and one step. In a one-step game, each player chooses an action simultaneously and then receive it’s own reward. The Nash equilibrium and NE-gap can be defined similarly in one-step games. + +Lemma E.2 (Lower bound for one-step game). Suppose $A _ { i } = 2 k$ , $i = 1 , \ldots , m$ and $m \geq 4$ . Then, there exists an absolute constant $c _ { 0 }$ such that for any $\varepsilon \leq 0 . 4$ and any online finetuning algorithm that outputs a pure strategy $\widehat { \pi } = ( \widehat { \pi } _ { 1 } , \ldots , \widehat { \pi } _ { m } )$ , if the number of samples + +$$ +n \leq c _ { 0 } { \frac { \sum _ { i = 1 } ^ { m } A _ { i } } { \varepsilon ^ { 2 } } } = c _ { 0 } { \frac { 2 k m } { \varepsilon ^ { 2 } } } , +$$ + +then there exists a one-step game $M$ with stochastic reward, on which the algorithm suffers from $\varepsilon / 4$ -suboptimality, i.e. + +$$ +\mathbb { E } _ { M } N E { - } G a p ( \widehat { \pi } ) = \mathbb { E } _ { M } \operatorname* { m a x } _ { i } \left[ \operatorname* { m a x } _ { \pi _ { i } } u _ { i } ( \pi _ { i } , \widehat { \pi } _ { - i } ) - u _ { i } ( \widehat { \pi } ) \right] \geq \varepsilon / 4 , +$$ + +where the expectation $\mathbb { E } _ { M }$ is w.r.t. the randomness during the algorithm’s execution within game $M$ . +$u _ { i } ( \pi )$ is the expected reward of the $i ^ { t h }$ player when strategy $\pi$ are taken for each player. + +The proof of this lemma is also in the next subsection. In the proof, we first construct a class of one-step games which reward is Bernoulli $\left( { \frac { 1 } { 2 } } \right)$ or Bernoulli $\left( { \frac { 1 } { 2 } } + \varepsilon \right)$ depending on the taken joint-action. The proportion of joint-actions with reward Bernoulli $\left( { \frac { 1 } { 2 } } + \varepsilon \right)$ is relatively small. Most importantly, every pure-strategy $\varepsilon$ -approximate Nash equilibrium has reward Bernoull $\left( { \frac { 1 } { 2 } } + \varepsilon \right)$ . So in order to find an $\varepsilon$ -approximate pure-strategy Nash equilibrium, we must explore sufficient joint-actions. The number of the joint-actions with reward Bernoulli $\left( { \frac { 1 } { 2 } } + \varepsilon \right)$ can be bounded by the covering number of $[ 2 k ] ^ { m }$ under Hamming distance. Then we use KL divergence decomposition (Lemma E.5) to argue rigorously that we need to explore sufficient joint-actions to get an $\varepsilon$ -approximate pure-strategy Nash equilibrium. + +The rest of this section is organized as follows: We first prove Lemma E.2 in Section E.1, and then prove the main Theorem E.1 in Section E.2. + +Discussions of Theorem E.1 There’s $\textstyle \sum _ { i = 1 } ^ { m } A _ { i }$ dependency4 in the lower bound of sample complexity for finding a pure-strategy $\varepsilon$ -approximate Nash equilibrium in MCGs. This bound is novel and improves the existing result. The existing proof in sample complexity’s lower bound of Markov games (Bai & Jin (2020)) relies on an reduction from Markov games to single-agent MDPs, so the existing lower bound’s dependency on $A _ { i }$ $( i = 1 , \ldots , m )$ is $\mathrm { m a x } _ { i \in [ m ] } A _ { i }$ . + +Here, we don’t include $S$ factor in our lower bound. The difficulty is that the NE-gap only depends on the player with the most suboptimality. For a single-agent MDP, if the player can change the policy at each state to improve the expected cumulative reward by $\varepsilon$ , then the player can change policy at all state to improve the expected cumulative reward to the utmost extent. In general-sum Markov games, at different state, maybe different players can change the policy for this state to improve his expected This difference in nature makes cumulative reward by $\varepsilon$ . However, the definition NE-gap only allows one player to change the policy. $S$ and $\textstyle \sum _ { i = 1 } ^ { m } A _ { i }$ incompatible in the lower bound. + +If we consider another notion of suboptimality, i.e., changing maximum to summation: + +$$ +\mathrm { N E - g a p } ^ { \prime } ( \pi ) : = \sum _ { i \in [ m ] } \left[ \operatorname* { s u p } _ { \mu _ { i } } V _ { 1 , i } ^ { \mu _ { i } , \pi _ { - i } } \big ( s _ { 1 } \big ) - V _ { 1 , i } ^ { \pi } \big ( s _ { 1 } \big ) \right] . +$$ + +This definition of NE-gap is different from the previous definition. With $\mathrm { { N E - g a p } ^ { \prime } }$ , if each player can change his policy to improve his expected cumulative reward by $\varepsilon$ , the $\mathrm { { N E - g a p } ^ { \prime } }$ would be at least $m \varepsilon$ . Then we can similarly define $\varepsilon$ -approximate Nash equilibrium as the policy $\pi$ such that $\mathrm { N E - g a p } ^ { \prime } ( \pi ) \leq \varepsilon$ . We simply point out that with this new definition of $\mathrm { { N E - g a p } ^ { \prime } }$ and $\varepsilon \cdot$ -approximate Nash equilibrium, mimicking the proof of Theorem 2 in Dann $\&$ Brunskill (2015), we can prove the sample complexity’s lower boMarkov (cooperative) games is e-strategy . $\varepsilon$ -approximate Nash equilibrium in $\begin{array} { r } { \Omega ( H ^ { 2 } S \sum _ { i = 1 } ^ { m } { \bf \bar { A } } _ { i } \bar { / } \varepsilon ^ { 2 } ) } \end{array}$ + +# E.1 PROOF OF LEMMA E.2 + +For convenience, we call the joint-action (in one-step game) that is a Nash equilibrium a Nash strategy. +We begin with a special case of Lemma E.2, i.e. the case when $A _ { i } = 2$ for all $i \in [ m ]$ . + +Lemma E.3. Suppose $A _ { i } = 2$ , $i = 1 , \ldots , m$ and $m \geq 4$ . Then, there exists an absolute constant $c _ { 0 }$ such that for any $\varepsilon \leq 0 . 4$ and any algorithm that outputs a pure strategy ${ \widehat { \pi } } = ( { \widehat { \pi } } _ { 1 } , \ldots , { \widehat { \pi } } _ { m } ) ,$ , if the number of samples + +$$ +n \leq c _ { 0 } \frac { 2 m } { \varepsilon ^ { 2 } } , +$$ + +then there exists a one step game $M$ with stochastic reward on which the algorithm suffers from $\varepsilon / 4$ -suboptimality, i.e., + +$$ +\mathbb { E } _ { M } N E - g a p ( \widehat { \pi } ) = \mathbb { E } _ { M } \operatorname* { m a x } _ { i } \left[ \operatorname* { m a x } _ { \pi _ { i } } u _ { i } ( \pi _ { i } , \widehat { \pi } _ { - i } ) - u _ { i } ( \widehat { \pi } ) \right] \geq \varepsilon / 4 , +$$ + +where the expectation $\mathbb { E } _ { M }$ is w.r.t. the randomness during the algorithm’s execution within game M. +$u _ { i } ( \pi )$ is the expected reward of the $i ^ { t h }$ player when strategy $\pi$ are taken for each player. + +The proof of this lemma further relies on the following lemma. + +Lemma E.4. There exists a one-step game for m players where each player has two actions. The deterministic reward is 0 or 1 and the number of joint actions that have $^ { l }$ is at most $\frac { 2 ^ { m + 1 } } { m }$ . Moreover, the only pure-strategy Nash equilibria are these joint actions which have reward 1. + +Proof of Lemma E.4 We use $r ( a )$ to denote the reward of (joint) actions $\pmb { a } \in \{ 1 , 2 \} ^ { m }$ and define hamming distance $d ( \pmb { a } , \pmb { a } ^ { \prime } ) = \# \{ i : a _ { i } \neq a _ { i } ^ { \prime } \}$ . To ensure that pure-strategy Nash equilibria must have reward 1, we only need to ensure that for a $\pmb { a } \in \{ 1 , 2 \} ^ { m }$ , there exists one $\pmb { a } ^ { \prime } \in \{ 1 , \bar { 2 } \} ^ { m }$ such that + +$$ +r ( { \pmb a } ^ { \prime } ) = 1 , \quad d ( { \pmb a } , { \pmb a } ^ { \prime } ) \leq 1 . +$$ + +In other words, the set $\{ \pmb { a } : r ( \pmb { a } ) = 1 \}$ is a 1-net of $\{ 1 , 2 \} ^ { m }$ under the distance $d ( \cdot , \cdot )$ . By the definition of covering number, we only need to prove + +$$ +\mathcal { N } ( \{ 1 , 2 \} ^ { m } , d , 1 ) \leq \frac { 2 ^ { m + 1 } } { m } . +$$ + +Define $K ( m , 1 ) = \mathcal { N } ( \{ 1 , 2 \} ^ { m } , d , 1 )$ . By hamming code (Hamming (1950)), we know that for any integer $k \geq 1$ , + +$$ +K ( 2 ^ { k } - 1 , 1 ) = 2 ^ { 2 ^ { k } - k - 1 } . +$$ + +Moreover, we also have $K ( n , 1 ) \leq 2 K ( n - 1 , 1 )$ by adding 0 and 1 behind the 1-net of $\{ 0 , 1 \} ^ { n - 1 }$ . Taking largest $k$ such that $2 ^ { k } - 1 \leq n$ and iterating this construction on the Hamming code we get $\begin{array} { r } { K ( m , 1 ) \leq 2 ^ { m - [ \log _ { 2 } ( m + 1 ) ] } \leq \frac { 2 ^ { m + 1 } } { m } } \end{array}$ . This ends the proof. □ + +The next lemma is KL divergence decomposition (Lemma 15.1 of (Lattimore & Szepesvári, 2020)]), we restate it in one-step games. + +Lemma E.5 (KL divergence decomposition in one-step games). For any one-step games with stochastic reward and any algorithm. Let $X = ( \pmb { a } _ { 1 } , r _ { 1 } , \pmb { a } _ { 2 } , r _ { 2 } , \dots , \pmb { a } _ { n } , r _ { n } )$ , where $\mathbf { \delta } _ \mathbf { \alpha } \mathbf { \alpha } \mathbf { \alpha } \mathbf { \alpha } \mathbf { \alpha } \mathbf { \alpha } \mathbf { \alpha } \mathbf { \alpha } \mathbf { \alpha } \mathbf { \alpha } \mathbf { \alpha } \mathbf { \alpha } \mathbf { \alpha } \mathbf { \alpha } \mathbf { \alpha } \mathbf { \alpha } \mathbf { \alpha } \mathbf { \alpha } \mathbf { \alpha } \mathrm { \bf ~ \textit ~ { ~ a ~ } } _ { k }$ is the action (adaptively) chosen by the algorithm at the $k ^ { t h }$ round and $r _ { k }$ is the reward received at the $k ^ { t h }$ round after $\mathbf { \em a } _ { k }$ is taken. $\mathbb { P }$ and $\mathbb { Q }$ are two probability measure for the stochastic reward. Let $N ( a )$ be the total number of actions $\textbf { \em a }$ in the first n rounds. Then + +$$ +\mathrm { K L } ( X | _ { \mathbb { P } } \| X | _ { \mathbb { Q } } ) = \sum _ { a } \mathbb { E } _ { \mathbb { P } } [ N ( a ) ] \mathrm { K L } ( \mathbb { P } ( \cdot | a ) \| \mathbb { Q } ( \cdot | a ) ) . +$$ + +Then we return to the proof of Lemma E.3. Suppose a game $M$ satisfies the condition in Lemma E.4, by permuting the actions of $M$ , we get $2 ^ { m }$ games. They all satisfy the condition in Lemma E.4. Suppose the reward of the $i$ -th game is $r ^ { ( i ) } ( \cdot ) ( i = 1 , \cdot \cdot \cdot , 2 ^ { m } )$ . + +We consider the following family of one-step games with stochastic reward: Let $\begin{array} { r l } { a } & { { } = } \end{array}$ $( a _ { 1 } , a _ { 2 } , \ldots , a _ { m } )$ . + +$$ +\mathfrak { M } ( \varepsilon ) = \{ \mathcal { M } ^ { ( i ) } \in \mathbb { R } ^ { \{ 1 , 2 \} ^ { m } } \ \mathrm { w i t h } \mathcal { M } ^ { ( i ) } ( \mathbf { a } ) = \frac { 1 } { 2 } + r ^ { ( i ) } ( \mathbf { a } ) \varepsilon , i = 1 , 2 , \ldots , 2 ^ { m } \} , +$$ + +where in one-step game $\mathcal { M } ^ { ( i ) }$ , the reward is sampled from Bernoulli $( \mathcal { M } ^ { ( i ) } ( { \mathbf a } ) )$ if the joint action is $\pmb { a } = ( a _ { 1 } , a _ { 2 } , \dots b , a _ { m } )$ . Moreover, we define $\mathcal { M } ^ { ( 0 ) }$ as a game whose reward is sampled from Bernoulli $\left( { \frac { 1 } { 2 } } \right)$ independent of the action. + +We further let $\nu$ denote the uniform distribution on $\{ 1 , 2 , \ldots , 2 ^ { m } \}$ . + +Proof of Lemma E.3 Fix a one-step game $\mathcal { M } ^ { ( i ) } \in \mathfrak { M } ( \varepsilon )$ , by Lemma E.4, it’s clear that purestrategy Nash equilibria form a set $D ^ { ( i ) } : = { \pmb a } \in \{ { \pmb a } : r ^ { ( i ) } ( { \pmb a } ) = 1 \}$ . We have $\# D ^ { ( i ) } \leq 2 ^ { m + 1 } / m$ . For any online finetuning algorithm $\mathcal { A }$ that outputs a pure strategy $\widehat { \pi }$ . Suppose $\widehat { \pi }$ takes joint-action $\widehat { \pmb { a } } = ( \widehat { \widehat { a } } _ { 1 } , \widehat { a } _ { 2 } , \cdot \cdot \cdot , \widehat { a } _ { m } )$ . From the structure of the $\mathfrak { M } ( \varepsilon )$ , we know + +$$ +\mathrm { N E \mathrm { - } G a p } ( \widehat { \pi } ) = \varepsilon \mathbb { P } _ { i } ( \widehat { \pmb { a } } \notin D ^ { ( i ) } ) , +$$ + +where $\mathbb { P } _ { i }$ is w.r.t. the randomness of the algorithm and game $\mathcal { M } ^ { ( i ) }$ . So we only need to use $n$ , the number of samples to give a lower bound of $\mathbb { P } _ { i } ( \widehat { \pmb { a } } \notin D ^ { ( i ) } )$ . + +Since $X = \{ \pmb { a } _ { 1 } , r _ { 1 } , \cdots , \pmb { a } _ { n } , r _ { n } \}$ is a sufficient statistics for the posterior distribution $D ^ { ( i ) }$ , we have + +$$ +\begin{array} { r l } { \mathbb { E } _ { i \sim \nu } \mathbb { P } _ { i } ( \hat { a } \notin D ^ { ( i ) } ) \geq \operatorname* { i n f } \mathbb { E } _ { i \sim \nu } \mathbb { P } _ { i } ( g ( X ) \notin D ^ { ( i ) } ) } \\ & { \overset { ( i ) } { \geq } \operatorname* { i n f } \mathbb { E } _ { i \sim \nu } \mathbb { P } _ { 0 } ( g ( X ) \notin D ^ { ( i ) } ) - \mathbb { E } _ { i \sim \nu } \mathrm { T V } ( X | _ { \mathbb { P } _ { 0 } } , X | _ { \mathbb { P } _ { i } } ) } \\ & { \overset { ( i i ) } { \geq } \frac { 1 } { 2 } - \mathbb { E } _ { i \sim \nu } \mathrm { T V } ( X | _ { \mathbb { P } _ { 0 } } , X | _ { \mathbb { P } _ { i } } ) } \\ & { \overset { ( i i i ) } { \geq } \frac { 1 } { 2 } - \mathbb { E } _ { i \sim \nu } \sqrt { \frac { 1 } { 2 } \mathrm { K L } ( X | _ { \mathbb { P } _ { 0 } } | X | _ { \mathbb { P } _ { i } } ) } } \\ & { \overset { ( i i v ) } { = } \frac { 1 } { 2 } - \mathbb { E } _ { i \sim \nu } \sqrt { \frac { 1 } { 2 } \sum _ { a } \mathbb { E } _ { \mathbb { P } _ { 0 } } [ N ( a ) ] \mathrm { K L } ( \mathbb { P } _ { 0 } ( \cdot | a ) | | \mathbb { P } _ { i } ( \cdot | a ) ) } . } \end{array} +$$ + +Above, (i) follows from the definition of total variation distance; (ii) uses the fact that under $\mathbb { P } _ { 0 }$ , we can’t get any information about $\mathbf { \delta } _ { \mathbf { \alpha } \mathbf { \alpha } \mathbf { \alpha } \mathbf { \alpha } \mathbf { \alpha } \mathbf { \alpha } \mathbf { \alpha } \mathbf { \beta } \mathbf { \alpha } \mathbf { \vec { a \alpha } \mathbf { \alpha } \mathbf { \alpha \ x } } }$ , so $\begin{array} { r } { \mathbb { E } _ { i \sim \nu } \mathbb { P } _ { 0 } ( g ( X ) \notin D ^ { ( i ) } ) = 1 - \frac { | D ^ { ( 1 ) } | } { 2 ^ { m } } \ge \frac { 1 } { 2 } } \end{array}$ ; (iii) uses Pinsker’s inequality; (iv) uses KL divergence decomposition (Lemma E.5). + +For $\mathbf { a } \in D ^ { ( i ) }$ , we have + +$$ +\begin{array} { r l } & { \displaystyle \mathrm { K L } ( \mathbb { P } _ { 0 } ( \cdot | { \boldsymbol a } ) | | \mathbb { P } _ { i } ( \cdot | { \boldsymbol a } ) ) = \mathrm { K L } \bigg ( \bigg ( \frac { 1 } { 2 } , \frac { 1 } { 2 } \bigg ) \| \bigg ( \frac { 1 } { 2 } - \varepsilon , \frac { 1 } { 2 } + \varepsilon \bigg ) \bigg ) } \\ & { \quad \quad \quad = \frac { 1 } { 2 } \log \frac { 1 } { 1 - 4 \varepsilon ^ { 2 } } } \\ & { \quad \quad \quad \leq 4 \varepsilon ^ { 2 } , } \end{array} +$$ + +if $\varepsilon \in ( 0 , 0 . 4 ] . \mathrm { F o r } \ \pmb { a } \notin D ^ { ( i ) } , \mathrm { K L } ( \mathbb { P } _ { 0 } ( \cdot | \pmb { a } ) | | \mathbb { P } _ { i } ( \cdot | \pmb { a } ) ) = 0 .$ . So + +$$ +\begin{array} { r l } { \displaystyle \mathbb { E } _ { i \sim \nu } \mathbb { P } _ { i } ( \hat { \pmb { a } } \notin D ^ { ( i ) } ) \geq \frac { 1 } { 2 } - \mathbb { E } _ { i \sim \nu } \sqrt { 2 \sum _ { \pmb { a } \in D ^ { ( i ) } } \mathbb { E } _ { \mathbb { P } _ { 0 } } [ N ( \pmb { a } ) ] \varepsilon ^ { 2 } } } & { } \\ { \displaystyle \overset { ( i ) } { \geq } \frac { 1 } { 2 } - \sqrt { 2 \mathbb { E } _ { i \sim \nu } \sum _ { \pmb { a } \in D ^ { ( i ) } } \mathbb { E } _ { \mathbb { P } _ { 0 } } [ N ( \pmb { a } ) ] \varepsilon ^ { 2 } } } & { } \\ { \displaystyle \overset { ( i i ) } { = } \frac { 1 } { 2 } - \sqrt { 2 \frac { n | D ^ { ( i ) } | } { 2 m } \varepsilon ^ { 2 } } } & { } \end{array} +$$ + +$$ +\geq { \frac { 1 } { 2 } } - { \sqrt { 4 { \frac { n } { m } } \varepsilon ^ { 2 } } } . +$$ + +Above, $( i )$ uses Jensen’s inequality, $( i i )$ uses the fact that $\mathbb { E } _ { \mathbb { P } _ { 0 } } [ N ( a ) ]$ is independent of $i$ which gives + +$$ +\begin{array} { r l r } { { \mathbb { E } _ { i \sim \nu } \sum _ { \pmb { a } \in D ^ { ( i ) } } \mathbb { E } _ { \mathbb { P } _ { 0 } } [ N ( \pmb { a } ) ] = \frac { 1 } { 2 ^ { m } } \sum _ { \pmb { a } } \mathbb { E } _ { \mathbb { P } _ { 0 } } [ N ( \pmb { a } ) ] \sum _ { i : \pmb { a } \in D ^ { ( i ) } } 1 } } \\ & { } & { = \frac { 1 } { 2 ^ { m } } n | D ^ { ( 1 ) } | , } \end{array} +$$ + +where $\textstyle \sum _ { i : a \in D ^ { ( i ) } } 1 = | D ^ { ( 1 ) } |$ is because of the permutation. Finally, we choose $\begin{array} { r } { c _ { 0 } = \frac { 1 } { 3 2 } } \end{array}$ , if $\begin{array} { r } { n \le \frac { 1 } { 3 2 } \frac { 2 m } { \varepsilon ^ { 2 } } } \end{array}$ + +$$ +\mathbb { E } _ { i \sim \nu } \mathbb { P } _ { i } ( \widehat { \pmb { a } } \notin D ^ { ( i ) } ) \geq \frac { 1 } { 4 } . +$$ + +So there’s a game instance $\mathcal { M } ^ { ( i ) }$ on which the algorithm suffer from $\varepsilon / 4$ sub-optimality. + +The difference between Lemma E.3 and E.2 is the size of action space. To prove the $A _ { i } = 2 k$ case, we need to generalized E.4 to the case each player have $2 k$ actions. + +Lemma E.6. For all positive integers m and $k$ . There exists a one-step game for m players where each player has $2 k$ actions. The deterministic reward is 0 or 1 and the number of joint actions that have $^ { l }$ is at most $\frac { 2 \cdot ( 2 k ) ^ { m } } { k m }$ . Moreover, the only pure-strategy Nash equilibria are these joint actions which has reward 1. + +Proof of Lemma E.6 We would prove this lemma by induction. Without loss of generality, we suppose the action for each player is $1 , 2 , \ldots , 2 k$ . First, we define the hamming distance between two vectors. + +$$ +d ( { \pmb x } , { \pmb y } ) : = \# \{ i : { \pmb x } ( i ) \neq { \pmb y } ( i ) \} . +$$ + +The joint action space is $[ 2 k ] ^ { m } = \{ 1 , 2 , \dots , 2 k \} ^ { m }$ . Suppose we have an 1-net of $[ 2 k ] ^ { m } , D$ , which means for every $y \in [ 2 k ] ^ { m }$ , we can find a $\pmb { x } \in D$ , s.t. $d ( { \pmb x } , { \pmb y } ) \le 1$ . If the reward of a game satisfy: + +$$ +r ( \pmb { a } ) = 1 \mathrm { f o r } \mathrm { a l l } \pmb { a } \in D , \mathrm { a n d } r ( \pmb { a } ) = 0 \mathrm { f o r } \mathrm { a l l } \pmb { a } \notin D . +$$ + +Then for every pure strategy $\textbf { \em a }$ which has reward 0, we can find another pure strategy $\mathbf { { a } ^ { \prime } }$ s.t. $r ( { \pmb a } ^ { \prime } ) = 1$ and $d ( a , a ^ { \prime } ) = 1$ . This means that one player can change to obtain higher reward. So $\textbf { \em a }$ is not a pure-strategy Nash equilibrium. + +As a result, we can construct a game based on the 1-net. The only thing left to be verified is that the number of joint actions that have reward 1 is at most $\frac { 2 \cdot ( 2 k ) ^ { m } } { k m }$ . Note that the number of joint actions that have reward 1 is actually $| D |$ , so we need to prove + +$$ +\mathcal { N } ( [ 2 k ] ^ { m } , d , 1 ) \leq \frac { 2 \cdot ( 2 k ) ^ { m } } { k m } , +$$ + +where $\mathcal { N } ( \cdot , d , \varepsilon )$ denotes the covering number. + +For $k = 1$ , from the proof of Lemma E.4, (17) is true. For $k > 1$ , we first decompose $[ 2 k ] ^ { m }$ into $k ^ { m }$ smaller blocks, i.e. + +$$ +\Omega ( l _ { 1 } , l _ { 2 } , \ldots , l _ { m } ) = \{ 2 l _ { 1 } - 1 , 2 l _ { 1 } \} \times \{ 2 l _ { 2 } - 1 , 2 l _ { 2 } \} \times \cdots , \times \{ 2 l _ { m } - 1 , 2 l _ { m } \} , +$$ + +where $\{ l _ { 1 } , l _ { 2 } , \ldots , l _ { m } \} \ \in \ [ k ] ^ { m }$ . Among these $k ^ { m }$ blocks, we choose the blocks which satisfy $k | l _ { 1 } + l _ { 2 } + \cdots + l _ { m }$ . Apparently, there are $k ^ { m - 1 }$ blocks satisfying $m | l _ { 1 } + l _ { 2 } + \cdot \cdot \cdot + l _ { m }$ . Because (17) is true for $k = 1$ , we can pick a 1-net of $\Omega ( 1 , 1 , \dots , 1 )$ with at most $\frac { 2 { \cdot } 2 ^ { m } } { m }$ elements. By a translation, (all elements add a constant vector), we can pick a 1-net of each block with at most $\frac { 2 { \cdot } 2 ^ { m } } { m }$ elements. Totally there are at most 2·2mkm−1 $\begin{array} { r } { \frac { 2 \cdot 2 ^ { m } k ^ { m - 1 } } { m } = \frac { 2 \cdot ( 2 k ) ^ { m } } { k m } } \end{array}$ elements. These elements form a set $P$ . We would prove $P$ is a 1-net of $[ 2 k ] ^ { m }$ . + +In fact, for any $\boldsymbol { x } ~ \in ~ [ 2 k ] ^ { m }$ , suppose $_ { \textbf { \em x } }$ is in $\Omega ( l _ { 1 } , l _ { 2 } , \dots , l _ { m } )$ . After translating this block to $\Omega ( 1 , 1 , \dots , 1 )$ , $_ { \textbf { \em x } }$ is coincided with $\scriptstyle { \mathbf { { \mathit { x } } } } _ { \mathbf { { 0 } } }$ . + +![](images/849a994006d5d49860091ff558696dd29ade42bcf4e6a0d788b454891335b067.jpg) +Figure 1: A class of hard-to-learn MDPs where $s _ { + }$ and $s _ { - }$ are absorbing state. + +If $\mathbf { \boldsymbol { x } _ { 0 } } ~ \in ~ \mathcal { P }$ , change $l _ { 1 }$ to $l _ { 1 } ^ { \prime }$ such that $k | l _ { 1 } ^ { \prime } + l _ { 2 } + \cdots + l _ { m }$ . Suppose $\mathbf { x } ^ { \prime }$ is the vector in block $\Omega ( l _ { 1 } ^ { \prime } , l _ { 2 } , \dots , l _ { m } )$ that corresponds to $\scriptstyle { \mathbf { { \mathit { x } } } } _ { 0 }$ in $\Omega ( 1 , 1 , \dots , 1 )$ . This gives $\pmb { x } ^ { \prime } \in P$ . Moreover, $d ( { \pmb x } , { \pmb x } ^ { \prime } ) \leq$ 1 because the translation from $\Omega ( l _ { 1 } , l _ { 2 } , \dots , l _ { m } )$ to $\Omega ( l _ { 1 } ^ { \prime } , l _ { 2 } , \ldots , l _ { m } )$ only changes the first component. + +If $\pmb { x } _ { 0 } \notin \mathcal { P }$ , we can find $\pmb { x } _ { 0 } ^ { \prime }$ in $P \cap \Omega ( 1 , 1 , . . . , 1 )$ such that $d ( \pmb { x } _ { 0 } , \pmb { x } _ { 0 } ^ { \prime } ) = 1$ because $P | _ { \Omega ( 1 , 1 , \dots , 1 ) }$ is a 1-net. Suppose $\scriptstyle { \mathbf { { \vec { x } } } } _ { \mathbf { 0 } }$ and $\mathbf { { x } _ { 0 } ^ { \prime } }$ differs at the $j$ -th component. We can change $l _ { j }$ to $l _ { j } ^ { \prime }$ s.t. $k | l _ { 1 } +$ $l _ { 2 } + \cdots + l _ { j - 1 } + l _ { j } ^ { \prime } + l _ { j + 1 } + \cdots + l _ { m } .$ . Suppose $\mathbf { { x _ { 0 } ^ { \prime } } }$ corresponds to $\mathbf { x } ^ { \prime }$ in $\Omega ( l _ { 1 } , \dots , l _ { m } )$ and $\mathbf { x } ^ { \prime \prime }$ in $\Omega ( l _ { 1 } , \dots , l _ { j - 1 } , l _ { j } ^ { \prime } , l _ { j + 1 } , \dots , l _ { m } )$ . By the definition of $P$ , we know ${ \pmb x } ^ { \prime \prime } \in P$ . Moreover, $_ { \textbf { \em x } }$ and $\mathbf { x } ^ { \prime }$ only differ at the $j$ -th component because of translation and the fact that $\scriptstyle { \mathbf { { \mathit { x } } } } _ { \mathbf { { 0 } } }$ and $\mathbf { { x _ { 0 } ^ { \prime } } }$ only differ at the $j$ -th component. $\mathbf { x } ^ { \prime }$ and $\scriptstyle { \pmb x } ^ { \prime \prime }$ also only differ at the $j$ -th component because of translation. So we have $_ { \textbf { \em x } }$ and ${ \boldsymbol { x } } ^ { \prime \prime }$ may only differ at the $j$ -th component, i.e. $d ( { \pmb x } , { \pmb x } ^ { \prime \prime } ) \leq 1$ . + +Recall that ${ \pmb x } ^ { \prime \prime } \in P$ . To conclude, we can always find another vector $\pmb { y } \in P$ such that $d ( \pmb { x } , \pmb { y } ) \leq 1$ this means $P$ is a 1-net of $[ 2 k ] ^ { m }$ . So (17) is proved. □ + +Using this fundamental lemma and suppose a game $M$ satisfies the condition in Lemma E.6, by permuting the actions of $M$ , we get $( 2 k ) ^ { m }$ games. They all satisfy the condition in Lemma E.6. Suppose the reward of the $i$ -th game is $r ^ { ( i ) } ( \cdot ) ( i = 1 , \cdot \cdot \cdot , ( 2 k ) ^ { m } )$ . + +We consider the following family of one-step games with stochastic reward: Let $\begin{array} { r l } { a } & { { } = } \end{array}$ $( a _ { 1 } , a _ { 2 } , \ldots , a _ { m } )$ . + +$$ +\mathfrak { M } ( \varepsilon ) = \{ \mathcal { M } ^ { ( i ) } \in \mathbb { R } ^ { [ 2 k ] ^ { m } } \mathrm { ~ w i t h ~ } \mathcal { M } ^ { ( i ) } ( \mathfrak { a } ) = \frac { 1 } { 2 } + r ^ { ( i ) } ( \mathfrak { a } ) \varepsilon , i = 1 , 2 , \ldots , ( 2 k ) ^ { m } \} , +$$ + +where in one-step game $\mathcal { M } ^ { ( i ) }$ , the reward is sampled from Bernoulli $( \mathcal { M } ^ { ( i ) } ( { \boldsymbol a } ) )$ if the joint action is $\pmb { a } = ( a _ { 1 } , a _ { 2 } , \dots b , a _ { m } )$ . Moreover, we define $\mathcal { M } ^ { ( 0 ) }$ as a game whose reward is sampled from Bernoulli $\left( { \frac { 1 } { 2 } } \right)$ independent of the action. + +Then by the same argument in proof of Lemma E.3, we can easily prove Lemma E.2. + +# E.2 PROOF OF THEOREM E.1 + +We are now ready to prove Theorem E.1 based on Lemma E.2. + +Because $S \geq 3$ , we construct a class of general-sum Markov games as follows (see figure 1): the set of all joint-actions $\mathcal { A }$ can be divided into two sets $\mathcal { A } ^ { + }$ an $\mathcal { A } ^ { - }$ . + +Transition Starting from $s _ { 1 }$ , for $a \in \mathcal { A } ^ { + }$ , $\begin{array} { r } { \mathbb { P } _ { 1 } ( s _ { + } | s _ { 1 } , \pmb { a } ) = \frac { 1 } { 2 } + \frac { \varepsilon } { 2 ( H - 1 ) } } \end{array}$ and $\mathbb { P } _ { 1 } ( s _ { - } | s _ { 1 } , a ) \ =$ $\begin{array} { r } { \frac { 1 } { 2 } \mathrm { ~ - ~ } \frac { \varepsilon } { 2 \left( H - 1 \right) } } \end{array}$ . For $a \in A ^ { - }$ , $\mathbb { P } _ { 1 } ( s _ { + } | s _ { 1 } , \pmb { a } ) = \mathbb { P } _ { 1 } ( s _ { - } | s _ { 1 } , \pmb { a } ) = \frac { 1 } { 2 }$ . For all $h \geq 1$ and $\textbf { \em a } \in \mathcal { A }$ $\mathbb { P } _ { h } ( s _ { + } | s _ { + } , \pmb { a } ) = 1$ and $\mathbb { P } _ { h } ( s _ { - } | s _ { - } , \pmb { a } ) = 1$ . + +Rewards For any $\textbf { \em a }$ and $i \in [ m ]$ $\bar { \bar { \mathbf { \tau } } } [ m ] , r _ { 1 , i } ( s , \pmb { a } ) = 0 r _ { h , i } ( s _ { + } , \pmb { a } ) = 1$ and $r _ { h , i } ( s _ { - } , { \pmb a } ) = 0$ , where $h > 1$ This also implies the Markov game is cooperative. + +If we choose $\mathcal { A } ^ { + }$ as the joint action with reward Bernoulli $\left( { \frac { 1 } { 2 } } + \varepsilon \right)$ in $\mathcal { M } ^ { ( i ) }$ defined in (18). By the construction, for any pure-strategy policy $\pi$ , if the joint actions taken at step 1 is $a \not \in A ^ { + }$ , we have + +# Algorithm 8 Mixed-expert FTRL for weighted adversarial bandits + +Require: Hyper-parameters $\left\{ \eta _ { t } \right\} _ { 1 \leq t \leq T }$ , $\left\{ \gamma _ { t } \right\} _ { 1 \leq t \leq T }$ . Sequence $\left\{ \alpha _ { t } ^ { i } \right\} _ { 1 \leq i \leq t \leq T }$ + +1: Initialize: Accumulators $t _ { b ^ { \prime } } \gets 0$ for all $b ^ { \prime } \in [ A ]$ . +2: for $t = 1 , 2 , \dots , T$ do +3: Compute weight $u _ { t } \gets \alpha _ { t } ^ { t } / \alpha _ { t } ^ { 1 }$ . +4: Compute action distributions for all sub-experts $b ^ { \prime } \in [ A ]$ by FTRL: + +$$ +q ^ { b ^ { \prime } } ( a ) \propto _ { a } \exp { \left( - ( \eta _ { t _ { b ^ { \prime } } } / u _ { t } ) \cdot \sum _ { \tau = 1 } ^ { t _ { b ^ { \prime } } } w _ { \tau } ( b ^ { \prime } ) \widehat { \ell } _ { \tau } ^ { b ^ { \prime } } ( a ) \right) } . +$$ + +5: Compute $p ^ { t } \in \Delta _ { [ A ] }$ by solving the linear system $\begin{array} { r } { p ^ { t } ( \cdot ) = \sum _ { b ^ { \prime } = 1 } ^ { A } p ^ { t } ( b ^ { \prime } ) q ^ { b ^ { \prime } } ( \cdot ) } \end{array}$ + +6: Sample sub-expert $b \sim p ^ { t }$ . + +7: Sample action $\bar { \boldsymbol { a } } ^ { t } \sim \boldsymbol { q } ^ { b }$ from sub-expert $b$ + +Play the action $a ^ { t }$ , and observe the (bandit-feedback) loss $\tilde { \ell } _ { t } ( a ^ { t } )$ + +9: Update accumulator for sub-expert $b$ : $t _ { b } \gets t _ { b } + 1$ + +10: Compute the loss estimate $\textstyle \widehat { \ell } _ { t _ { b } } ^ { b } ( \cdot ) \in \mathbb { R } _ { \geq 0 } ^ { A }$ as + +$$ +\widehat { \ell } _ { t _ { b } } ^ { b } ( a ) \gets \frac { \tilde { \ell } _ { t _ { b } } ( a ) \mathbf { 1 } \{ a = a ^ { t } \} } { q ^ { b } ( a ) + \gamma _ { t _ { b } } } . +$$ + +11: Set $w _ { t _ { b } } ( b ) u _ { t }$ + +$\mathrm { N E - g a p } ( \pi ) \geq \varepsilon .$ The only useful information in each episode is the transition at step 1. Transition from $s _ { 1 }$ to $s _ { + }$ can be viewed as getting a 1 reward and transition from $s _ { 1 }$ to $s _ { - }$ can be viewed as getting a 0 reward. So learning pure-strategy Nash equilibrium of this class of Markov games is equivalent to learning pure-strategy Nash equilibrium of a game for $m$ players with stochastic reward. As a result, by Lemma E.2, if the number of episodes + +$$ +K \leq c _ { 0 } \frac { \sum _ { i = 1 } ^ { m } A _ { i } } { \varepsilon ^ { 2 } / ( H - 1 ) ^ { 2 } } \leq 4 c _ { 0 } \frac { H ^ { 2 } \sum _ { i = 1 } ^ { m } A _ { i } } { \varepsilon ^ { 2 } } , +$$ + +then there exists general-sum Markov cooperative game $_ { M G }$ on which the algorithm suffers from $\varepsilon / 4$ -suboptimality, i.e. + +$$ +\mathbb { E } _ { M } \mathbf { N E - g a p } ( \widehat { \pi } ) \geq \varepsilon / 4 . +$$ + +This finish the proof of Theorem E.1. + +# F ADVERSARIAL BANDIT WITH LOW WEIGHTED SWAP REGRET + +In this section, we describe and analyze our main algorithm for adversarial bandits with low weighted swap regret. Our Algorithm, Mixed-expert Follow-The-Regularized-Leader (FTRL) for weighted adversarial bandits, is described in Algorithm 8. + +Problem setting Throughout this section, we consider a standard (adversarial) bandit problem with action space is $[ A ] = \left\{ 1 , \dots , A \right\}$ for some $A \geq 1$ . We assume that the realized loss values $\tilde { \ell } _ { t } \in [ 0 , 1 ] ^ { A }$ , and let $\ell _ { t } ( a ) : = \mathbb { E } _ { t } [ \tilde { \ell } _ { t } ( a ) ]$ denote the expected loss conditioned on (as usual) all information before the sampling of the action $a ^ { t }$ in Line 6 & 7. The hyperparameters in Algorithm 8 are chosen as + +$$ +\eta _ { t } = \gamma _ { t } = \sqrt { \iota / ( A t ) } , +$$ + +where the log factor + +$$ +\iota : = 4 \log ( 8 H A T / p ) . +$$ + +We first define a strategy modification. A strategy modification is a function $F : [ A ] \to [ A ]$ which can also be applied to any action distribution $\mu \in \Delta _ { A }$ , such that $F \diamond \mu$ gives the swap distribution which takes action $F ( a )$ with probability $\mu ( a )$ . + +The swap regret (Blum & Mansour, 2007; Ito, 2020) measures the difference between the cumulative realized loss for the algorithm and that for swapped action sequences generated by an arbitrary strategy modification $F$ . Here, we consider a weighted version of the swap regret with some non-negative weights αit 1≤i≤t, defined as + +$$ +R _ { \mathrm { s w a p } } ( t ) : = \operatorname* { m a x } _ { F : [ A ] \to [ A ] } \sum _ { i = 1 } ^ { t } \alpha _ { t } ^ { i } [ \ell _ { i } ( a ^ { i } ) - \ell _ { i } ( F ( a ^ { i } ) ) ] . +$$ + +We will also consider a slightly modified version of the swap regret used in our analyses for learning CE, defined as + +$$ +\widetilde { R } _ { \mathrm { s w a p } } ( t ) : = \operatorname* { m a x } _ { F : [ A ] \to [ A ] } \sum _ { i = 1 } ^ { t } \alpha _ { t } ^ { i } [ \ell _ { i } ( a ^ { i } ) - \langle F \diamond p ^ { i } , \ell _ { i } \rangle ] , +$$ + +where $p ^ { t }$ is $t$ -th action distribution (from which the action $a ^ { t }$ is sampled from) played by the algorithm. + +We now state our main result of this section. + +Lemma F.1 (Bound on weighted swap regret). If we execute Algorithm 8 for $T$ rounds and the weights $\left\{ \alpha _ { t } ^ { i } \right\}$ are chosen according to (2), then with probability at least $1 - p / 2$ , we have the following bounds on the swap regret simultaneously for all $t \in [ T ]$ : + +$$ +\begin{array} { r l } & { R _ { \mathrm { s w a p } } ( t ) = \displaystyle \operatorname* { m a x } _ { F : [ A ] \to [ A ] } \sum _ { i = 1 } ^ { t } \alpha _ { t } ^ { i } [ \ell _ { i } ( a ^ { i } ) - \ell _ { i } ( F ( a ^ { i } ) ) ] \le C ( H A \sqrt { \iota / t } + H A \iota / t ) , } \\ & { } \\ & { \widetilde { R } _ { \mathrm { s w a p } } ( t ) = \displaystyle \operatorname* { m a x } _ { F : [ A ] \to [ A ] } \sum _ { i = 1 } ^ { t } \alpha _ { t } ^ { i } [ \ell _ { i } ( a ^ { i } ) - \left. F \diamond p ^ { i } , \ell _ { i } \right. ] \le C ( H A \sqrt { \iota / t } + H A \iota / t ) , } \end{array} +$$ + +where $C > 0$ is some absolute constant. + +The rest of this section is devoted to proving Lemma F.1, organized as follows. We first present some important properties of Algorithm 8 in Section F.2. We then prove Lemma F.1 in Section F.3 using new auxiliary results on weighted adversarial bandits with predictable weights. Lastly, these auxiliary results are stated and proved in Appendix F.4. + +# F.2 PROPERTIES OF ALGORITHM 8 + +Solution of the linear system In Line 5, we need to compute $p ^ { t } \in \Delta _ { [ A ] }$ by solving the linear +system Markov $\begin{array} { r } { p ^ { t } ( \cdot ) = \sum _ { b ^ { \prime } = 1 } ^ { A } p ^ { t } ( b ^ { \prime } ) q ^ { b ^ { \prime } } ( \cdot ) } \end{array}$ . Such ion pr $p ^ { t } ( \cdot )$ cality as the stationary distribution of a. This guarantees the existence of $[ A ]$ $\mathbb { P } ( b | a ) \stackrel { - } { = } q ^ { a } ( b )$ +$p ^ { t } \in \Delta _ { [ A ] }$ such that $\begin{array} { r } { p ^ { t } ( \cdot ) = \sum _ { b ^ { \prime } = 1 } ^ { A } p ^ { t } ( b ^ { \prime } ) q ^ { b ^ { \prime } } ( \cdot ) } \end{array}$ . Moreover, $p ^ { t } ( \cdot )$ can be computed efficiently (see +e.g. Cohen et al. (2017b)). + +FTRL update for each sub-expert Here we show that, the updates for any particular sub-expert $b \in [ A ]$ in Algorithm 8 is exactly equivalent to an FTRL update (with loss sequence being the ones only over the episodes in which $b$ is sampled) which we summarize in Algorithm 9. This is important as our proof relies on reducing the weighted swap regret to a linear combination of weighted regrets for each sub-expert $b \in [ A ]$ . + +To see this, fix any $b \in [ A ]$ . When $b$ is sampled in Line 6 at episode $t$ , we have accumulator $t _ { b }$ and weight $w _ { t _ { b } } ( b ) = \dot { u } _ { t } = \dot { \alpha } _ { t } ^ { t } / \alpha _ { t } ^ { 1 }$ at the end of episode $t$ . Action $a ^ { t }$ is chosen from distribution + +$$ +q ^ { b } ( a ) \propto _ { a } \exp \left( - ( \eta _ { t _ { b } } / w _ { t _ { b } } ) \cdot \sum _ { \tau = 1 } ^ { t _ { b } - 1 } w _ { \tau } ( b ^ { \prime } ) \widehat { \ell } _ { \tau } ^ { b } ( a ) \right) +$$ + +after $w _ { t _ { b } } ( b ) = u _ { t } = \alpha _ { t } ^ { t } / \alpha _ { t } ^ { 1 }$ is observed. The loss estimate $\widehat { \ell } _ { t _ { b } }$ is + +$$ +\widehat { \ell } _ { t _ { b } } ^ { b } ( a ) \gets \frac { \tilde { \ell } _ { t _ { b } } ( a ) \mathbf { 1 } \{ a = a ^ { t } \} } { q ^ { b } ( a ) + \gamma _ { t _ { b } } } . +$$ + +So from the sub-expert $b$ ’s perspective, she is performing FTRL (follow the regularized leader) with changing step size and random weight (We summarize this in Algorithm 9). Suppose the sub-expert $b$ is chosen at episode $t = k _ { 1 } , k _ { 2 } , \ldots , k _ { t _ { b } }$ , then the weighted regret for sub-expert $b$ becomes + +$$ +R _ { t } ( b ) : = \operatorname* { s u p } _ { \theta ^ { * } \in \Delta _ { A } } \left[ \sum _ { \tau = 1 } ^ { t _ { b } } w _ { \tau } ( b ) ( \ell _ { k _ { \tau } } ( a ^ { k _ { \tau } } ) - \langle \theta ^ { * } , \ell _ { k _ { \tau } } \rangle ) \right] . +$$ + +Bounded weight $w _ { i } ( b )$ Recall $\left\{ \alpha _ { t } ^ { i } \right\}$ is chosen as in (2). We have the following bound: + +$$ +\frac { \alpha _ { t } ^ { t } } { \alpha _ { t } ^ { 1 } } \leq \frac { 1 } { \alpha _ { t } ^ { 1 } } = \frac { 1 } { \alpha _ { 1 } ( 1 - \alpha _ { 2 } ) \cdot \cdot \cdot ( 1 - \alpha _ { t } ) } = \frac { ( H + 2 ) ( H + 3 ) \cdot \cdot \cdot ( H + t ) } { 1 \cdot 2 \cdot \cdot ( t - 1 ) } \leq ( H + t ) ^ { H + 1 } . +$$ + +So for any $t \leq T$ , we have + +$$ +\alpha _ { t } ^ { t } / \alpha _ { t } ^ { 1 } \leq ( H + T ) ^ { 2 H } \equiv W . +$$ + +The weight $w _ { n _ { b } } ( b ) = \alpha _ { t } ^ { t } / \alpha _ { t } ^ { 1 }$ have a (non-random) upper bound $W$ + +# F.3 PROOF OF LEMMA F.1 + +We use $b ^ { i }$ to denote the sampled sub-expert $b$ at the $i$ -th episode. Define $\mathcal { G } _ { i }$ as the $\sigma$ -algebra generated by all the random variables observed up to the end of the $i$ -th episode. + +First observe that for $R _ { \mathrm { s w a p } } ( t )$ we have the bound + +$$ +\begin{array} { r l } & { R _ { \mathrm { s w a p } } ( t ) = \underset { F : [ A ] [ A ] } { \operatorname* { m a x } } \underset { i = 1 } { \overset { t } { \sum } } \alpha _ { t } ^ { i } [ \ell _ { i } ( a ^ { i } ) - \ell _ { i } ( F ( a ^ { i } ) ) ] } \\ & { \leq \underset { \underset { F : [ A ] [ A ] } { \operatorname* { m a x } } [ A ] } { \operatorname* { m a x } } \underset { i = 1 } { \overset { t } { \sum } } \alpha _ { t } ^ { i } [ \ell _ { i } ( a ^ { i } ) - \ell _ { i } ( F ( b ^ { i } ) ) ] + \underset { \underset { \mathrm { ~ I ~ } } { \overset { t } { \sum : [ A ] [ A ] } [ A ] } } { \operatorname* { m a x } } \underset { i = 1 } { \overset { t } { \sum } } \alpha _ { t } ^ { i } [ \ell _ { i } ( F ( b ^ { i } ) ) - \ell _ { i } ( F ( a ^ { i } ) ) ] , } \end{array} +$$ + +also, for $\widetilde { R } _ { \mathrm { s w a p } } ( t )$ we have the bound + +$$ +\begin{array} { r l } & { \widetilde { R } _ { \mathrm { s w a p } } ( t ) = \underset { F : [ A ] [ A ] } { \operatorname* { m a x } } \underset { i = 1 } { \overset { t } { \sum } } \alpha _ { t } ^ { i } [ \ell _ { i } ( a ^ { i } ) - F \diamond p ^ { i } , \ell _ { i } ] } \\ & { \leq \underset { \underset { F : [ A ] [ A ] } { \operatorname* { m a x } } [ A ] } { \operatorname* { m a x } } \underset { i = 1 } { \overset { t } { \sum } } \alpha _ { t } ^ { i } [ \ell _ { i } ( a ^ { i } ) - \ell _ { i } ( F ( b ^ { i } ) ) ] + \underset { \underset { \tilde { \Pi } } { \overset { F : [ A ] [ A ] } { \prod } } [ A ] } { \operatorname* { m a x } } \underset { i = 1 } { \overset { t } { \sum } } \alpha _ { t } ^ { i } [ \ell _ { i } ( F ( b ^ { i } ) ) - F \diamond p ^ { i } , \ell _ { i } ] , } \end{array} +$$ + +Term II and $\widetilde { \mathrm { I I } }$ can be bounded by concentration in a similar fashion; here we first focus on term II. Observe that at the $i$ -th episode, as $p ^ { i }$ obtained in Line 5 solves the equation + +$$ +p ^ { i } ( a ) = \sum _ { b ^ { \prime } = 1 } ^ { A } p ^ { i } ( b ^ { \prime } ) q ^ { b ^ { \prime } } ( a ) , +$$ + +we have $b ^ { i } \sim p ^ { i } ( \cdot )$ and $a ^ { i } \sim q ^ { b ^ { i } } ( \cdot )$ has the same marginal distribution conditioned on $\mathcal { G } _ { i - 1 }$ , where $\mathcal { G } _ { i - 1 }$ denote the $\sigma$ -algebra generated by $\ell _ { i }$ and all the random variables in the first $_ { i - 1 }$ episodes. Therefore, fixing any strategy modification $F : [ A ] \to [ A ]$ , we have $\{ \alpha _ { t } ^ { i } [ \ell _ { i } ( F ( b ^ { i } ) ) - \ell _ { i } ( F \dot { ( a ^ { i } ) ) } ] \} _ { 1 \leq i \leq t }$ is a bounded martingale difference sequence w.r.t. the filtration $\left\{ { \mathcal { G } } _ { i } \right\}$ , so by Azuma-Hoeffding inequality and $\textstyle \sum _ { i = 1 } ^ { t } ( \alpha _ { t } ^ { j } ) ^ { 2 } \leq 2 H / t$ , + +$$ +\mathbb { P } \left( \sum _ { i = 1 } ^ { t } \alpha _ { t } ^ { i } [ \ell _ { i } ( F ( b ^ { i } ) ) - \ell _ { i } ( F ( a ^ { i } ) ) ] \geq 2 { \sqrt { \frac { H \log 1 / p } { t } } } \right) \leq p . +$$ + +As there is at most $A ^ { A }$ strategy modifications, we can substitute $p$ with $p / ( 4 A ^ { A } T )$ , and take a union bound to get + +$$ +\Pi = \operatorname* { m a x } _ { F : [ A ] [ A ] } \sum _ { i = 1 } ^ { t } \alpha _ { t } ^ { i } [ \ell _ { i } ( F ( b ^ { i } ) ) - \ell _ { i } ( F ( a ^ { i } ) ) ] \leq 2 \sqrt { H A \log ( A T / p ) / t } \leq C \sqrt { H A \iota / t } +$$ + +simultaneously for all $t \in [ T ]$ with probability at least $1 - p / 4$ . We also note that, by a similar argument (as $b ^ { i }$ is also distributed according to $\bar { p } ^ { i }$ conditioned on the past), we have that + +$$ +\widetilde { \mathrm { I I } } = \operatorname* { m a x } _ { F : [ A ] [ A ] } \sum _ { i = 1 } ^ { t } \alpha _ { t } ^ { i } [ \ell _ { i } ( F ( b ^ { i } ) ) - F \diamond p ^ { i } , \ell _ { i } ] \leq C \sqrt { H A \iota / t } . +$$ + +Therefore for bounding both $R _ { \mathrm { s w a p } } ( t )$ and $\widetilde { R } _ { \mathrm { s w a p } } ( t )$ , it suffices to bound term I. + +We next bound term I. Define $\mathcal { U } _ { b } : = \{ i \in [ t ] : b ^ { i } = b \}$ and let $n _ { b } ^ { t }$ be the value of $t _ { b }$ at the end of the $t$ -th episode, i.e. $n _ { b } ^ { t } = \# \{ i : b ^ { i } = b \}$ . We also suppose the sub-expert $b$ was chosen at episode $t = k _ { 1 } ^ { b } , k _ { 2 } ^ { b } , \ldots , k _ { n _ { b } ^ { t } } ^ { b }$ up to episode $t$ . Then we have + +$$ +\begin{array} { r l } { \displaystyle \sum _ { i = 1 } ^ { t } \alpha _ { t } ^ { i } [ \ell _ { i } ( a ^ { i } ) - \ell _ { i } ( F ( b ^ { i } ) ) ] = \sum _ { b \in A } \sum _ { i \in \mathcal { U } _ { b } } \alpha _ { t } ^ { i } [ \ell _ { i } ( a ^ { i } ) - \ell _ { i } ( F ( b ) ) ] } & { } \\ & { = \displaystyle \sum _ { b \in A } \sum _ { \tau = 1 } ^ { n _ { b } ^ { i } } \alpha _ { t } ^ { 1 } \frac { \alpha _ { t } ^ { k _ { \tau } ^ { b } } } { \alpha _ { t } ^ { 1 } } [ \ell _ { k _ { \tau } ^ { b } } ( a ^ { k _ { \tau } ^ { b } } ) - \ell _ { k _ { \tau } ^ { b } } ( F ( b ) ) ] } \\ & { = \displaystyle \sum _ { b \in A } \sum _ { \tau = 1 } ^ { n _ { b } ^ { i } } \alpha _ { t } ^ { 1 } w _ { \tau } ( b ) [ \ell _ { k _ { \tau } ^ { b } } ( a ^ { k _ { \tau } ^ { b } } ) - \ell _ { k _ { \tau } ^ { b } } ( F ( b ) ) ] . } \end{array} +$$ + +Here the last equation is because our choice of wτ (b) = αkbτkbτ /αi $w _ { \tau } ( b ) = \alpha _ { k _ { \tau } ^ { b } } ^ { k _ { \tau } ^ { b } } / \alpha _ { k _ { \tau } ^ { b } } ^ { 1 } = \alpha _ { t } ^ { k _ { \tau } ^ { b } } / \alpha _ { t } ^ { 1 }$ which is a simple + +Then because + +$$ +\sum _ { \tau = 1 } ^ { n _ { b } ^ { t } } w _ { \tau } ( b ) [ \ell _ { k _ { \tau } ^ { b } } ( a ^ { k _ { \tau } ^ { b } } ) - \ell _ { k _ { \tau } ^ { b } } ( F ( b ) ) ] \leq \operatorname* { m a x } _ { \theta ^ { * } } \sum _ { \tau = 1 } ^ { n _ { b } ^ { t } } w _ { \tau } ( b ) [ \ell _ { k _ { \tau } ^ { b } } ( a ^ { k _ { \tau } ^ { b } } ) - \langle \ell _ { k _ { \tau } ^ { b } } , \theta ^ { * } \rangle ] = R _ { t } ( b ) , +$$ + +where $R _ { t } ( b )$ defined in (22) is the weighted regret $R _ { t } ( b )$ for sub-expert $b$ , we can use our result on weighted adversarial bandits with predictable weights (Lemma F.2) to bound this term (The upper bound $W$ of the weight $w _ { \tau } ( b )$ can be taken as $( \breve { H } + \dot { T } ) ^ { 2 H }$ by the calculation of (23). Moreover, $w _ { \tau } ( b ) = \alpha _ { t } ^ { k _ { \tau } ^ { b } } / \alpha _ { t } ^ { 1 }$ and $\{ \alpha _ { t } ^ { j } \} _ { j = 1 } ^ { t }$ is increasing, so $\{ w _ { \tau } ( b ) \} _ { \tau \geq 1 }$ is non-decreasing.). Recall that our choice of log term is $\begin{array} { r } { \iota = 4 \log { \frac { 4 H A T } { p } } = \log { \frac { A T \lceil \log _ { 2 } W \rceil } { p ^ { \prime } } } } \end{array}$ where $p ^ { \prime } \leq p / ( 4 A )$ . Thus by Lemma F.2, with probability at least $1 - p / ( 4 A )$ , + +$$ +R _ { t } ( b ) \leq 1 5 \operatorname* { m a x } _ { \tau \leq n _ { b } ^ { t } } w _ { \tau } ( b ) \biggl [ \sqrt { A n _ { b } ^ { t } \iota } + \iota \biggr ] \mathrm { f o r ~ a l l } t \in [ T ] . +$$ + +Taking a union bound, we get + +$$ +R _ { t } ( b ) \leq 1 5 \operatorname* { m a x } _ { \tau \leq n _ { b } ^ { t } } w _ { \tau } ( b ) \biggl [ \sqrt { A n _ { b } ^ { t } \iota } + \iota \biggr ] \mathrm { f o r } \mathrm { a l l } \left( t , b \right) \in [ T ] \times [ A ] +$$ + +with probability at least $1 - p / 4$ . + +On this event, we have + +$$ +\operatorname* { m a x } _ { F : [ A ] [ A ] } \sum _ { i = 1 } ^ { t } \alpha _ { t } ^ { i } [ \ell _ { i } ( a ^ { i } ) - \ell _ { i } ( F ( b ^ { i } ) ) ] = \operatorname* { m a x } _ { F : [ A ] [ A ] } \sum _ { b \in A } \sum _ { \tau = 1 } ^ { n _ { b } ^ { t } } \alpha _ { t } ^ { 1 } w _ { \tau } ( b ) [ \ell _ { k _ { \tau } ^ { b } } ( a ^ { k _ { \tau } ^ { b } } ) - \ell _ { k _ { \tau } ^ { b } } ( F ( b ) ) ] +$$ + +$$ +\begin{array} { r l } & { \le \displaystyle \sum _ { b \in \mathcal { A } } \displaystyle \sum _ { \ell ^ { \prime } \ne \lambda ( 1 ) \to \ell } \displaystyle \sum _ { i = 1 } ^ { n } \sum _ { \ell ^ { \prime } = 1 } ^ { n } \alpha _ { i } ^ { 1 } w _ { \ell ^ { \prime } } ( b ) [ \ell _ { i \mathrm { k } _ { \ell } } ( a ^ { k _ { \ell } ^ { k } } ) - \ell _ { i \mathrm { k } _ { \ell } ^ { k } } ( F ( b ) ) ] } \\ & { \le \displaystyle \sum _ { i \in \mathcal { A } } \alpha _ { i } ^ { 1 } R _ { \ell } ( b ) } \\ & { \overset { ( a ) } { \le } \displaystyle \sum _ { b \in \mathcal { A } } \alpha _ { i } ^ { 1 } \displaystyle \sum _ { \ell ^ { \prime } \ge \lambda _ { i } ^ { 1 } } w _ { \ell ^ { \prime } } ( a ) ( 1 5 \sqrt { \mathcal { A } n _ { b \ell } ^ { \ell } } + 1 5 \ell ) } \\ & { \overset { ( a ) } { \le } \displaystyle \sum _ { b \in \mathcal { A } } \alpha _ { i } ^ { 1 } \displaystyle \frac { \alpha _ { i } ^ { 1 } } { \alpha _ { i } ^ { 1 } } ( 1 5 \sqrt { \mathcal { A } n _ { b \ell } ^ { \ell } } + 1 5 \ell ) } \\ & { \overset { ( a i ) } { \le } \displaystyle \sum _ { b \in \mathcal { A } } \alpha _ { i } ^ { 1 } \displaystyle \frac { \alpha _ { i } ^ { 1 } } { \alpha _ { i } ^ { 1 } } ( 1 5 \sqrt { \mathcal { A } n _ { b \ell } ^ { \ell } } + 1 5 \ell ) } \\ & { \overset { ( a i i ) } { \le } \displaystyle \sum _ { a \in \mathcal { A } } \frac { 2 H } { \ell } ( 1 5 \sqrt { \mathcal { A } n _ { b \ell } ^ { \ell } } + 1 5 \ell ) . } \end{array} +$$ + +Here, (i) uses (26), (ii) uses the $\alpha _ { t } ^ { t ^ { \prime } }$ is increasing w.r.t. $t ^ { \prime }$ and (iii) uses √ $\operatorname* { m a x } _ { 0 \leq t ^ { \prime } \leq t } \alpha _ { t } ^ { t ^ { \prime } } \leq 2 H / t$ . Finally, because $\textstyle \sum _ { b \in { \mathcal { A } } } n _ { b } ^ { t } = t$ , by the concavity of $x \mapsto { \sqrt { x } }$ , we have with probability at least $1 - p / 4$ , + +$$ +\begin{array} { r l } { { \mathrm { I } = \operatorname* { m a x } _ { F : [ A ] \to [ A ] } \sum _ { i = 1 } ^ { t } \alpha _ { t } ^ { i } [ \ell _ { i } ( a ^ { i } ) - \ell _ { i } ( F ( b ^ { i } ) ) ] \le \frac { 3 0 H } { t } \cdot ( \sum _ { b \in \mathcal { A } } ( \sqrt { A n _ { b } ^ { t } } \iota + \iota ) ) } } \\ & { \le \frac { 3 0 H } { t } \cdot ( A \sqrt { t } + A \iota ) } \\ & { = 3 0 H A \sqrt { \iota / t } + 3 0 H A \iota / t . } \end{array} +$$ + +Combining this with (24) and (25), we finish the proof. + +F.4 AUXILIARY LEMMAS FOR WEIGHTED ADVERSARIAL BANDIT WITH PREDICTABLEWEIGHTS + +In this subsection, we consider the Follow the Regularized Leader (FTRL) algorithm (Lattimore & Szepesvári, 2020) with + +1. changing step size, +2. weighted regret with $\mathcal { F } _ { t - 1 }$ -measurable weights and loss distributions, +3. high probability regret bound. + +We present these results because the predictable weights we would use are potentially unbounded from above; if weights are predictable and also bounded, then there may be an easier analysis. + +Interaction protocol We first describe the interaction protocol between the environment and the player for this problem. At each episode $t$ , the environment adversarially choose a weight $w _ { t }$ which takes values in $\mathbb { R } _ { > 0 }$ , and distributions $( { \mathcal { L } } _ { a t } ) _ { a \in [ A ] }$ , where each $\mathcal { L } _ { a t }$ is a distribution that takes values in ${ \mathcal { P } } ( [ 0 , 1 ] )$ (the space of distributions supported on $[ 0 , 1 ] )$ . Then the player receives the weight $w _ { t }$ , chooses an action $a _ { t }$ , and observes a loss $\tilde { \ell } _ { t } ( a _ { t } ) \sim \mathcal { L } _ { a _ { t } , t }$ . The action chosen $a _ { t }$ can be based on all the information in $\mathcal { D } _ { t } \equiv \{ ( a _ { i } , w _ { i } , \tilde { \ell } _ { i } ( a _ { i } ) ) _ { i \leq t - 1 } , w _ { t } \}$ . Then, the environment can observe the player’s action $a _ { t }$ and the incurred loss realization $\tilde { \ell } _ { t } ( a _ { t } )$ , and use these information and some external randomness $z _ { t }$ to choose the weight and distributions $( w _ { t + 1 } , ( \mathcal { L } _ { a , t + 1 } ) _ { a \in [ A ] } )$ of the next episode. We will consider the following variant of FTRL algorithm for the player. + +We denote $\ell _ { t } \ \equiv \ ( \mathbb { E } _ { \widetilde { \ell } \sim \mathcal { L } _ { a t } } [ \widetilde { \ell } ] ) _ { a \in [ A ] } \ \in \ [ 0 , 1 ] ^ { A }$ which is a random vector but is $\sigma ( ( \mathcal { L } _ { a t } ) _ { a \in [ A ] } )$ measurable. For some $\theta ^ { * } \in \mathbb { R } ^ { A }$ , the regret of the player up to episode $t$ is defined as + +$$ +R _ { t } \equiv \sum _ { i = 1 } ^ { t } w _ { i } ( \ell _ { i } ( a _ { i } ) - \langle \theta ^ { * } , \ell _ { i } \rangle ) . +$$ + +# Algorithm 9 FTRL for Weighted Regret with Changing Step Size and Predictable Weights + +1: for episode $t = 1 , \dots , T$ do +2: 3: $w _ { t } > 0$ . +$\begin{array} { r } { \theta _ { t } ( a ) \propto _ { a } \exp ( - ( \eta _ { t } / w _ { t } ) \sum _ { i = 1 } ^ { t - 1 } w _ { i } \widehat { \ell } _ { i } ( a ) ) } \end{array}$ +4: Take action $a _ { t } \sim \theta _ { t } ( \cdot )$ , and observe loss $\tilde { \ell } _ { t } ( a _ { t } )$ . +5: $\widehat { \ell } _ { t } ( a ) \gets \tilde { \ell } _ { t } ( a ) \mathbf { 1 } \left\{ a _ { t } = a \right\} / ( \theta _ { t } ( a ) + \gamma _ { t } )$ for all $a$ + +Let $( z _ { t } ) _ { t \geq 1 }$ be a sequence of external random variables which are identically and independently distributed as $\operatorname { U n i f } ( [ 0 , 1 ] )$ and are independent of all other random variables. We define $\mathcal { F } _ { t } ~ =$ $\sigma ( \{ a _ { i } , \tilde { \ell } _ { i } , z _ { i } \} _ { i \leq t } )$ to be the sigma algebra generated by the random chosen action $a _ { i }$ , the random loss $\tilde { \ell } _ { i } ( a _ { i } )$ , and the external random variables $z _ { i }$ by episode $t$ . We assume that the random weights and the random loss distributions $( w _ { t } , ( \mathcal { L } _ { a t } ) _ { a \in [ A ] } ) _ { t \geq 1 }$ are a $( \mathcal { F } _ { t } ) _ { t \geq 1 }$ -predictable sequence, in the sense that $( w _ { t } , ( \mathcal { L } _ { a t } ) _ { a \in [ A ] } )$ is $\mathcal { F } _ { t - 1 }$ -measurable. Then $\mathcal { F } _ { t }$ contains all information (random chosen action, random observed loss, random weight, and random loss distributions) before action $a _ { t + 1 }$ is taken. + +We assume the predictable sequence $\left( w _ { t } \right) _ { 1 \leq t \leq T }$ have a global (non-random) upper bound $W$ . Then we define the log term $\iota = \log ( A T / \log _ { 2 } \bar { W } \bar { ] } / p )$ . We set + +$$ +\eta _ { t } = \gamma _ { t } = \sqrt { \frac { \iota } { A t } } . +$$ + +# F.4.1 REGRET BOUND + +In the following, we consider to give a high probability weighted regret bound for Algorithm 9. + +Lemma F.2. Let $( w _ { t } , ( \mathcal { L } _ { a t } ) _ { a \in [ A ] } ) _ { t \geq 1 }$ be any $\mathcal { F } _ { t }$ -predictable sequence satisfying $1 \leq \operatorname* { m i n } _ { i \leq t } w _ { i } \leq$ $\operatorname* { m a x } _ { i \leq t } w _ { i } \leq W$ for some constant (non-random) $W > 0$ almost surely. Moreover, suppose $w _ { i }$ is non-decreasing. Then, following Algorithm 9, with probability at least $1 - 4 p ,$ , for any $\theta ^ { * } \in \Delta ^ { A }$ and $t \leq T$ we have + +$$ +\sum _ { i = 1 } ^ { t } w _ { i } ( \ell _ { i } ( a ^ { i } ) - \langle \theta ^ { * } , \ell _ { i } \rangle ) \leq 1 5 \operatorname* { m a x } _ { i \leq t } w _ { i } \cdot \Big [ \sqrt { A t } { + } \ i \Big ] , +$$ + +where $\iota = \log ( A T \lceil \log _ { 2 } W \rceil / p )$ . + +Proof. This lemma follows from the bound in Lemma F.3 and a concentration step that we establish below. + +Define $M = \lceil \log _ { 2 } W \rceil$ , and $w _ { i } ( k ) = w _ { i } { \bf 1 } \left\{ w _ { i } \leq 2 ^ { k } \right\}$ . Then $w _ { i } ( k )$ is also $\mathcal { F } _ { i - 1 }$ measurable. We Consider sequence $\left\{ w _ { i } ( k ) ( \ell _ { i } ( a ^ { i } ) - \langle \theta _ { i } , \ell _ { i } \rangle ) \right\} _ { i > 1 }$ . Since $w _ { i }$ is $\mathcal { F } _ { i - 1 }$ -measurable, $\mathbb { E } [ w _ { i } ( \ell _ { i } ( a ^ { i } ) -$ $\langle \theta _ { i } , \ell _ { i } \rangle ) | \mathcal { F } _ { i - 1 } ] = 0$ , which means $\left\{ w _ { i } ( k ) ( \ell _ { i } ( a ^ { i } ) ^ { - } - \langle \theta _ { i } , \ell _ { i } \rangle ) \right\} _ { i \geq 1 }$ is a martingale difference sequence w.r.t. filtration $( \mathcal { F } _ { i } )$ . So by Azuma-Hoeffding inequality, + +$$ +\mathbb { P } \Bigg ( \sum _ { i = 1 } ^ { t } w _ { i } ( k ) ( \ell _ { i } ( a ^ { i } ) - \langle \theta _ { i } , \ell _ { i } \rangle ) \leq \sqrt { 2 \cdot \iota t ( 2 ^ { k } ) ^ { 2 } } \Bigg ) \geq 1 - \frac { p } { T M } . +$$ + +Taking a union bound, we have + +$$ +\mathbb { P } \Bigg ( \forall k \in [ M ] , \sum _ { i = 1 } ^ { t } w _ { i } ( k ) ( \ell _ { i } ( a ^ { i } ) - \langle \theta _ { i } , \ell _ { i } \rangle ) \leq 2 ^ { k } \sqrt { 2 t } u \Bigg ) \geq 1 - p / T . +$$ + +Denote $k ^ { \prime } = \lceil \log _ { 2 } \operatorname* { m a x } _ { i \leq t } w _ { i } \rceil$ , then we have + +$$ +\begin{array} { r l r } { { \Big \{ \forall k \in [ M ] , \sum _ { i = 1 } ^ { t } w _ { i } ( k ) ( \ell _ { i } ( a ^ { i } ) - \langle \theta _ { i } , \ell _ { i } \rangle ) \leq 2 ^ { k } \sqrt { 2 t \iota } \Big \} } } \\ & { } & { \subseteq \Big \{ \sum _ { i = 1 } ^ { t } w _ { i } ( k ^ { \prime } ) ( \ell _ { i } ( a ^ { i } ) - \langle \theta _ { i } , \ell _ { i } \rangle ) \leq 2 ^ { k } \sqrt { 2 t \iota } \Big \} \subseteq \Big \{ \sum _ { i = 1 } ^ { t } w _ { i } ( \ell _ { i } ( a ^ { i } ) - \langle \theta _ { i } , \ell _ { i } \rangle ) \leq 2 \operatorname* { m a x } _ { i \leq t } w _ { i } \sqrt { 2 t \iota } \Big \} . } \end{array} +$$ + +Then probability bound gives + +$$ +\mathbb { P } \Bigg ( \sum _ { i = 1 } ^ { t } w _ { i } \big ( \ell _ { i } ( a ^ { i } ) - \langle \theta _ { i } , \ell _ { i } \rangle \big ) \leq 2 \operatorname* { m a x } _ { i \leq t } w _ { i } \sqrt { 2 t \iota } \Bigg ) \geq 1 - p / T . +$$ + +Taking a union bound, we get + +$$ +\sum _ { i = 1 } ^ { t } w _ { i } ( \ell _ { i } ( a ^ { i } ) - \langle \theta _ { i } , \ell _ { i } \rangle ) \leq 2 \operatorname* { m a x } _ { i \leq t } w _ { i } \sqrt { 2 t } \mathrm { f o r } \mathrm { a l l } t \in [ T ] +$$ + +with probability at least $1 - p$ . Summing the above and the regret bound shown in Lemma F.3, we finish the proof. □ + +Lemma F.3. Let $( w _ { t } , ( \mathcal { L } _ { a t } ) _ { a \in [ A ] } ) _ { t \geq 1 }$ be any $\mathcal { F } _ { t }$ -predictable sequence satisfying $1 \leq \operatorname* { m i n } _ { i \leq t } w _ { i } \leq$ $\operatorname* { m a x } _ { i \leq t } w _ { i } \leq W$ for some constant (non-random) $W > 0$ almost surely. Moreover, suppose $w _ { i }$ is non-decreasing. Then, following Algorithm $^ { 9 }$ , with probability at least $1 - 3 p ,$ , for any $\theta ^ { * } \in \Delta ^ { A }$ and $t \leq T$ we have + +$$ +\sum _ { i = 1 } ^ { t } w _ { i } \left. \theta _ { i } - \theta ^ { * } , \ell _ { i } \right. \leq 1 0 \operatorname* { m a x } _ { i \leq t } w _ { i } \cdot \Big [ \sqrt { A t } + \iota \Big ] , +$$ + +where $\iota = \log ( A T \lceil \log _ { 2 } W \rceil / p )$ . + +Proof. The regret $R _ { t } ( \theta ^ { * } )$ can be decomposed into three terms + +$$ +\begin{array}{c} \underbrace { R _ { t } \left( \theta ^ { * } \right) = \sum _ { i = 1 } ^ { t } w _ { i } \left. \theta _ { i } - \theta ^ { * } , \ell _ { i } \right. } _ { ( A ) } \\ { = \underbrace { \sum _ { i = 1 } ^ { t } w _ { i } \left. \theta _ { i } - \theta ^ { * } , \widehat { \ell _ { i } } \right. } _ { ( A ) } + \underbrace { \sum _ { i = 1 } ^ { t } w _ { i } \left. \theta _ { i } , \ell _ { i } - \widehat { \ell _ { i } } \right. } _ { ( B ) } + \underbrace { \sum _ { i = 1 } ^ { t } w _ { i } \left. \theta ^ { * } , \widehat { \ell _ { i } } - \ell _ { i } \right. } _ { ( C ) } } \end{array} +$$ + +and we bound $( A )$ in Lemma F.5, $( B )$ in Lemma F.6 and $( C )$ in Lemma F.7. + +Setting $\begin{array} { r } { \eta _ { t } = \gamma _ { t } = \sqrt { \frac { \iota } { A t } } } \end{array}$ , the conditions in Lemma F.5 and Lemma F.7 are satisfied. Putting them together and take union bound, we have with probability $1 - 3 p$ + +$$ +\begin{array} { l l l } { \displaystyle R _ { t } \left( \theta ^ { * } \right) \leq \frac { w _ { t } \log { A } } { \eta _ { t } } + \frac { A } { 2 } \sum _ { i = 1 } ^ { t } \eta _ { i } w _ { i } + \operatorname* { m a x } _ { i \leq t } w _ { i } \nu _ { i } + A \sum _ { i = 1 } ^ { t } \gamma _ { i } w _ { i } + 2 \operatorname* { m a x } _ { i \leq t } w _ { i } \sqrt { 2 t } + 2 \operatorname* { m a x } _ { i \leq t } w _ { i } \nu _ { i } / \gamma _ { t } } \\ { \displaystyle \qquad \leq \operatorname* { m a x } _ { i \leq t } w _ { i } \left[ \sqrt { A \iota t } + \frac { 3 \sqrt { A \iota } } { 2 } \sum _ { i = 1 } ^ { t } \frac { 1 } { \sqrt { t } } + \iota + 2 \sqrt { 2 t \iota } + 2 \sqrt { A \iota t } \right] } \\ { \displaystyle \qquad \leq 1 0 \operatorname* { m a x } _ { i \leq t } w _ { i } \left[ \sqrt { A t \iota } + \iota \right] \mathrm { ~ f o r ~ a l l ~ } t \in [ T ] } \end{array} +$$ + +This proves the lemma. + +The rest of this section is devoted to the proofs of the Lemmas used in the proofs of Lemma F.3. We begin the following useful lemma adapted from Lemma 1 in Neu (2015), which is crucial in constructing high probability guarantees. + +Lemma F.4. For any predictable sequence of coefficients $c _ { 1 } , c _ { 2 } , \ldots , c _ { t }$ s.t. $c _ { i } \in [ 0 , 2 \gamma _ { i } ] ^ { A } w . r . t$ $( \mathcal { F } _ { i } ) _ { i \geq 1 }$ and fixing $t$ , we have with probability at least $1 - p / ( A T )$ , + +$$ +\sum _ { i = 1 } ^ { t } w _ { i } \left. c _ { i } , \widehat { \ell } _ { i } - \ell _ { i } \right. \leq 2 \operatorname* { m a x } _ { i \leq t } w _ { i } \iota +$$ + +Proof. Define $M = \lceil \log _ { 2 } W \rceil$ , and $w _ { i } ( k ) = w _ { i } { \bf 1 } \left\{ w _ { i } \leq 2 ^ { k } \right\}$ . By definition, + +$$ +\begin{array} { r l } & { w _ { i } ( k ) \widehat { \ell } _ { i } \left( a \right) = \frac { w _ { i } \left( k \right) \widetilde { \ell } _ { i } \left( a \right) \mathbf { 1 } \left\{ a _ { i } = a \right\} } { \theta _ { i } \left( a \right) + \gamma _ { i } } \leq \frac { w _ { i } \left( k \right) \widetilde { \ell } _ { i } \left( a \right) \mathbf { 1 } \left\{ a _ { i } = a \right\} } { \theta _ { i } \left( a \right) + \frac { w _ { i } \left( k \right) \widetilde { \ell } _ { i } \left( a \right) \mathbf { 1 } \left\{ a _ { i } = a \right\} } { 2 ^ { k } } \gamma _ { i } } } \\ & { \qquad = \frac { 2 ^ { k } } { 2 \gamma _ { i } } \frac { \frac { 2 \gamma _ { i } w _ { i } \left( k \right) \widetilde { \ell } _ { i } \left( a \right) \mathbf { 1 } \left\{ a _ { i } = a \right\} } { 2 ^ { k } \theta _ { i } \left( a \right) } } { 1 + \frac { \gamma _ { i } w _ { i } \left( k \right) \widetilde { \ell } _ { i } \left( a \right) \mathbf { 1 } \left\{ a _ { i } = a \right\} } { 2 ^ { k } \theta _ { i } \left( a \right) } } \overset { ( i ) } { \leq } \frac { 2 ^ { k } } { 2 \gamma _ { i } } \log \left( 1 + \frac { 2 \gamma _ { i } w _ { i } \left( k \right) \widetilde { \ell } _ { i } \left( a \right) \mathbf { 1 } \left\{ a _ { i } = a \right\} } { 2 ^ { k } \theta _ { i } \left( a \right) } \right) } \end{array} +$$ + +where $( i )$ is because $\frac { z } { 1 + z / 2 } \leq \log { ( 1 + z ) }$ for all $z \geq 0$ + +Defining the sum + +$$ +\widehat { S } _ { i } = \frac { w _ { i } ( k ) } { 2 ^ { k } } \left. c _ { i } , \widehat { \ell } _ { i } \right. , S _ { i } = \frac { w _ { i } ( k ) } { 2 ^ { k } } \left. c _ { i } , \ell _ { i } \right. , +$$ + +Then $S _ { i }$ is $\mathcal { F } _ { i - 1 }$ -measurable since $w _ { i } , c _ { i } , \ell _ { i }$ are $\mathcal { F } _ { i - 1 }$ -measurable. Using $\mathbb { E } _ { i } [ \cdot ]$ to denote the conditional expectation $\mathbb { E } [ \cdot | \mathcal { F } _ { i } ]$ , we have + +$$ +\begin{array} { r l } & { \mathbb { E } _ { i - 1 } \left[ \exp \left( \widehat { S } _ { i } \right) \right] \leq \mathbb { E } _ { i - 1 } \left[ \exp \left( \displaystyle \sum _ { a } \frac { c _ { i } \left( a \right) } { 2 \gamma _ { i } } \log \left( 1 + \frac { 2 \gamma _ { i } w _ { i } \left( k \right) \widetilde { \ell } _ { i } \left( a \right) \mathbf { 1 } \left\{ a _ { i } = a \right\} } { 2 ^ { k } \theta _ { i } \left( a \right) } \right) \right) \right] } \\ & { \stackrel { ( i ) } { \leq } \mathbb { E } _ { i - 1 } \left[ \displaystyle \prod _ { a } \left( 1 + \frac { c _ { i } \left( a \right) w _ { i } \left( k \right) \widetilde { \ell } _ { i } \left( a \right) \mathbf { 1 } \left\{ a _ { i } = a \right\} } { 2 ^ { k } \theta _ { i } \left( a \right) } \right) \right] } \\ & { = \mathbb { E } _ { i - 1 } \left[ 1 + \displaystyle \sum _ { a } \frac { c _ { i } \left( a \right) w _ { i } \left( k \right) \widetilde { \ell } _ { i } \left( a \right) \mathbf { 1 } \left\{ a _ { i } = a \right\} } { 2 ^ { k } \theta _ { i } \left( a \right) } \right] } \\ & { = 1 + S _ { i } \leq \exp \left( S _ { i } \right) } \end{array} +$$ + +where $( i )$ is because $z _ { 1 } \log { ( 1 + z _ { 2 } ) } \leq \log { ( 1 + z _ { 1 } z _ { 2 } ) }$ for any $0 \leq z _ { 1 } \leq 1$ and $z _ { 2 } \geq - 1$ . Here we are using the condition $c _ { i } \left( a \right) \leq 2 \gamma _ { i }$ to guarantee the condition is satisfied. + +Equipped with the above bound, we can now prove the concentration result. + +$$ +\begin{array} { r l } { \mathbb { P } \left[ \displaystyle \sum _ { i = 1 } ^ { t } \left( \hat { S } _ { i } - S _ { i } \right) \geq \nu \right] \leq \mathbb { P } \left[ \exp \left[ \displaystyle \sum _ { i = 1 } ^ { t } \left( \hat { S } _ { i } - S _ { i } \right) \right] \geq \frac { A T M } { p } \right] } & { } \\ & { \leq \frac { p } { A T M } \mathbb { E } _ { t - 1 } \left[ \exp \left[ \displaystyle \sum _ { i = 1 } ^ { t } \left( \hat { S } _ { i } - S _ { i } \right) \right] \right] } \\ & { \leq \frac { p } { A T M } \mathbb { E } _ { t - 2 } \left[ \exp \left[ \displaystyle \sum _ { i = 1 } ^ { t - 1 } \left( \hat { S } _ { i } - S _ { i } \right) \right] E _ { t - 1 } \left[ \exp \left( \hat { S } _ { t } - S _ { t } \right) \right] \right] } \\ & { \leq \frac { p } { A T M } \mathbb { E } _ { t - 2 } \left[ \exp \left[ \displaystyle \sum _ { i = 1 } ^ { t - 1 } \left( \hat { S } _ { i } - S _ { i } \right) \right] \right] } \\ & { \leq \cdots \leq \frac { p } { A T M } . } \end{array} +$$ + +So we have + +$$ +\mathbb { P } \Big ( \sum _ { t = 1 } ^ { t } w _ { i } ( k ) \left. c _ { i } , \widehat { \ell } _ { i } - \ell _ { i } \right. \leq 2 ^ { k } \iota \Big ) \geq 1 - p / ( A T M ) . +$$ + +Taking a union bound, + +$$ +\mathbb { P } \Big ( \forall k \in [ M ] , \sum _ { t = 1 } ^ { t } w _ { i } ( k ) \left. c _ { i } , \widehat { \ell } _ { i } - \ell _ { i } \right. \leq 2 ^ { k } \iota \Big ) \geq 1 - p / ( A T ) . +$$ + +Denote $k ^ { \prime } = \lceil \log _ { 2 } \operatorname* { m a x } _ { i \leq t } w _ { i } \rceil$ , and note that + +$$ +\begin{array} { l } { \displaystyle \Big \lbrace \forall k \in [ M ] , \sum _ { t = 1 } ^ { t } w _ { i } ( k ) \left. c _ { i } , \widehat { \ell } _ { i } - \ell _ { i } \right. \leq 2 ^ { k } \iota \Big \rbrace } \\ { \displaystyle \subseteq \Big \lbrace \sum _ { t = 1 } ^ { t } w _ { i } ( k ^ { \prime } ) \left. c _ { i } , \widehat { \ell } _ { i } - \ell _ { i } \right. \leq 2 ^ { k ^ { \prime } } \iota \Big \rbrace \subseteq \Big \lbrace \sum _ { t = 1 } ^ { t } w _ { i } \left. c _ { i } , \widehat { \ell } _ { i } - \ell _ { i } \right. \leq 2 \operatorname* { m a x } _ { i \leq t } w _ { i } \iota \Big \rbrace . } \end{array} +$$ + +Therefore, we have + +$$ +\mathbb { P } \left( \sum _ { i = 1 } ^ { t } w _ { i } \left. c _ { i } , \widehat { \ell } _ { i } - \ell _ { i } \right. \leq 2 \operatorname* { m a x } _ { i \leq t } w _ { i } \iota \right) \geq 1 - p / ( A T ) . +$$ + +This proves the lemma. + +Using Lemma F.4, we can bound the $( A ) ( B ) ( C )$ separately as below. + +Lemma F.5. If $\eta _ { i } \leq 2 \gamma _ { i }$ for all $i \leq t$ and $\{ \eta _ { i } / w _ { i } \} _ { i \ge 1 }$ is non-increasing, with probability $1 - p ,$ for any $t \in [ T ]$ and $\theta ^ { * } \in \Delta ^ { A }$ , + +$$ +\sum _ { i = 1 } ^ { t } w _ { i } \left. \theta _ { i } - \theta ^ { * } , \widehat { \ell } _ { i } \right. \leq \frac { w _ { t } \log A } { \eta _ { t } } + \frac { A } { 2 } \sum _ { i = 1 } ^ { t } \eta _ { i } w _ { i } + \frac { 1 } { 2 } \operatorname* { m a x } _ { i \leq t } w _ { i } \iota . +$$ + +Proof. We use the standard analysis of FTRL with changing step size, see for example Exercise 28.12(b) in Lattimore & Szepesvári (2020). Notice the essential step size is $\eta _ { t } / w _ { t }$ which is nonincreasing and the essential loss vector is $\boldsymbol { w _ { t } } \boldsymbol { \widehat { \ell } _ { t } }$ , we have + +$$ +\sum _ { i = 1 } ^ { t } w _ { i } \left. \theta _ { i } - \theta ^ { * } , \widehat { \ell } _ { i } \right. \leq \frac { w _ { t } \log A } { \eta _ { t } } + \sum _ { i = 1 } ^ { t } w _ { i } \left[ \left. \theta _ { i } - \theta _ { i + 1 } , \ell _ { i } \right. - \frac { \mathrm { K L } ( \theta _ { i + 1 } \| \theta _ { i } ) } { \eta _ { i } } \right] . +$$ + +We claim that + +$$ +\left. \theta _ { i } - \theta _ { i + 1 } , \widehat { \ell } _ { i } \right. - \frac { \mathrm { K L } ( \theta _ { i + 1 } \| \theta _ { i } ) } { \eta _ { i } } \leq \frac { \eta _ { i } } { 2 } \left. \theta _ { i } , \widehat { \ell } _ { i } ^ { 2 } \right. . +$$ + +In fact, applying Theorem 26.13 in Lattimore & Szepesvári (2020) gives that + +$$ +\left. \theta _ { i } - \theta _ { i + 1 } , \widehat { \ell } _ { i } \right. - \frac { \mathrm { K L } ( \theta _ { i + 1 } | | \theta _ { i } ) } { \eta _ { i } } \leq \frac { \eta _ { i } } { 2 } \left. u _ { i } \theta _ { i } + ( 1 - u _ { i } ) \theta _ { i + 1 } , \widehat { \ell } _ { i } ^ { 2 } \right. , +$$ + +for some $u _ { i } \in [ 0 , 1 ]$ . Note that our $\widehat { \ell } _ { i }$ only have at most one non-zero entry, i.e. $\widehat { \ell } _ { i } ( a ) > 0$ if and only if $a = a _ { i }$ . If $\theta _ { i } ( a _ { i } ) \geq \theta _ { i + 1 } ( a _ { i } )$ , we have + +$$ +\begin{array} { r l r } { { \frac { \eta _ { i } } { 2 } u _ { i } \theta _ { i } + ( 1 - u _ { i } ) \theta _ { i + 1 } , \widehat { \ell } _ { i } ^ { 2 } = \frac { \eta _ { i } } { 2 } [ u _ { i } \theta _ { i } ( a _ { i } ) + ( 1 - u _ { i } ) \theta _ { i + 1 } ( a _ { i } ) ] \widehat { \ell } _ { i } ( a _ { i } ) ^ { 2 } } } \\ & { } & { \leq \frac { \eta _ { i } } { 2 } \theta _ { i } ( a _ { i } ) \widehat { \ell } _ { i } ( a _ { i } ) ^ { 2 } = \frac { \eta _ { i } } { 2 } \theta _ { i } , \widehat { \ell } _ { i } ^ { 2 } . \quad } \end{array} +$$ + +Otherwise, $\theta _ { i } ( a _ { i } ) < \theta _ { i + 1 } ( a _ { i } )$ , so we have $\left. \theta _ { i } - \theta _ { i + 1 } , \widehat { \ell } _ { i } \right. = [ \theta _ { i } ( a _ { i } ) - \theta _ { i + 1 } ( a _ { i } ) ] \widehat { \ell } _ { i } ( a _ { i } ) \leq 0$ and $- \mathrm { K L } ( \theta _ { i + 1 } | | \theta _ { i } ) / \eta _ { i } \leq 0$ . In both cases, (29) is correct. As a result, + +$$ +\begin{array} { r l r } { { \sum _ { i = 1 } ^ { t } w _ { i } \theta _ { i } - \theta ^ { * } , \widehat { \ell } _ { i } \leq \frac { w _ { t } \log { A } } { \eta _ { t } } + \frac { 1 } { 2 } \sum _ { i = 1 } ^ { t } \eta _ { i } w _ { i } \theta _ { i } , \widehat { l } _ { i } ^ { 2 } } } \\ & { } & { \leq \frac { w _ { t } \log { A } } { \eta _ { t } } + \frac { 1 } { 2 } \sum _ { i = 1 } ^ { t } \sum _ { a \in A } \eta _ { i } w _ { i } \widehat { \ell } _ { i } ( a ) } \\ & { } & { \stackrel { ( i ) } { \leq } \frac { w _ { t } \log { A } } { \eta _ { t } } + \frac { 1 } { 2 } \sum _ { i = 1 } ^ { t } \underset { a \in A } { \sum } \eta _ { i } w _ { i } \ell _ { i } ( a ) + \underset { i \leq t } { \operatorname* { m a x } } w _ { i } } \end{array} +$$ + +$$ +\leq \frac { w _ { t } \log A } { \eta _ { t } } + \frac { A } { 2 } \sum _ { i = 1 } ^ { t } \eta _ { i } w _ { i } + \operatorname* { m a x } _ { i \leq t } w _ { i } \iota +$$ + +where $( i )$ is by using Lemma F.4 with $c _ { i } ( a ) = \eta _ { i }$ . The any-time guarantee is justified by taking union bound. □ + +Lemma F.6. With probability $1 - p ,$ , for any $t \in [ T ]$ , + +$$ +\sum _ { i = 1 } ^ { t } w _ { i } \left. \theta _ { i } , \ell _ { i } - \widehat { \ell } _ { i } \right. \leq A \sum _ { i = 1 } ^ { t } \gamma _ { i } w _ { i } + 2 \operatorname* { m a x } _ { i \leq t } w _ { i } \sqrt { 2 t } . +$$ + +Proof. We further decompose the left side into + +$$ +\sum _ { i = 1 } ^ { t } w _ { i } \left. \theta _ { i } , \ell _ { i } - \widehat { \ell } _ { i } \right. = \sum _ { i = 1 } ^ { t } w _ { i } \left. \theta _ { i } , \ell _ { i } - \mathbb { E } _ { i - 1 } [ \widehat { \ell } _ { i } ] \right. + \sum _ { i = 1 } ^ { t } w _ { i } \left. \theta _ { i } , \mathbb { E } _ { i - 1 } [ \widehat { \ell } _ { i } ] - \widehat { \ell } _ { i } \right. . +$$ + +The first term is bounded by + +$$ +\begin{array} { r } { \displaystyle \sum _ { i = 1 } ^ { t } w _ { i } \left. \theta _ { i } , \ell _ { i } - \mathbb { E } _ { i - 1 } [ \widehat { \ell } _ { i } ] \right. = \displaystyle \sum _ { i = 1 } ^ { t } w _ { i } \left. \theta _ { i } , \ell _ { i } - \frac { \theta _ { i } } { \theta _ { i } + \gamma _ { i } } \ell _ { i } \right. } \\ { = \displaystyle \sum _ { i = 1 } ^ { t } w _ { i } \left. \theta _ { i } , \frac { \gamma _ { i } } { \theta _ { i } + \gamma _ { i } } \ell _ { i } \right. \leq { \cal A } \displaystyle \sum _ { i = 1 } ^ { t } \gamma _ { i } w _ { i } . } \end{array} +$$ + +To bound the second term, we use similar argument in the proof of Lemma F.4 , we define $w =$ $\operatorname* { m a x } _ { i \leq t } w _ { i }$ , $M = \lceil \log _ { 2 } W \rceil$ . and $w _ { i } ( k ) = w _ { i } \bar { \bf 1 } \left\{ w _ { i } \leq 2 ^ { k } \right\}$ , notice + +$$ +\left. \theta _ { i } , \widehat { \ell } _ { i } \right. \leq \sum _ { a \in \mathcal { A } } \theta _ { i } \left( a \right) \frac { \mathbf { 1 } \left\{ a _ { t } = a \right\} } { \theta _ { i } ( a ) + \gamma _ { i } } \leq \sum _ { a \in \mathcal { A } } \mathbf { 1 } \left\{ a _ { i } = a \right\} = 1 , +$$ + +thus $\{ w _ { i } ( k ) \left. \theta _ { i } , \mathbb { E } _ { i - 1 } [ \widehat { \ell } _ { i } ] - \widehat { \ell } _ { i } \right. \} _ { i = 1 } ^ { t }$ is a bounded martingale difference sequence w.r.t. the filtration $\{ \mathcal { F } _ { i } \} _ { i = 1 } ^ { t }$ . By Azuma-Hoeffding inequality, + +$$ +\sum _ { i = 1 } ^ { t } w _ { i } ( k ) \left. \theta _ { i } , \mathbb { E } _ { i - 1 } [ \widehat { \ell } _ { i } ] - \widehat { \ell } _ { i } \right. \leq \sqrt { 2 \iota \sum _ { i = 1 } ^ { t } w _ { i } ( k ) ^ { 2 } } \leq \sqrt { 2 \iota \cdot t ( 2 ^ { k } ) ^ { 2 } } +$$ + +with probability at least $1 - p / T M$ . Taking a union bound, we get + +$$ +\sum _ { i = 1 } ^ { t } w _ { i } ( k ) \left. \theta _ { i } , \mathbb { E } _ { i - 1 } [ \widehat { \ell } _ { i } ] - \widehat { \ell } _ { i } \right. \leq \sqrt { 2 \iota \cdot t 2 ^ { 2 k } } , \mathrm { ~ f o r ~ a l l ~ } ( t , k ) \in [ T ] \times [ M ] +$$ + +with probability at least $1 - p$ . On this event, choosing $k ^ { \prime } = \lceil \log _ { 2 } w \rceil$ , we have + +$$ +\begin{array} { r } { \displaystyle \sum _ { i = 1 } ^ { t } w _ { i } \left. \theta _ { i } , \mathbb { E } _ { i - 1 } [ \widehat { \ell } _ { i } ] - \widehat { \ell } _ { i } \right. \leq \displaystyle \sum _ { i = 1 } ^ { t } w _ { i } ( k ^ { \prime } ) \left. \theta _ { i } , \mathbb { E } _ { i - 1 } [ \widehat { \ell } _ { i } ] - \widehat { \ell } _ { i } \right. } \\ { \leq 2 ^ { k ^ { \prime } } \sqrt { 2 \iota \cdot t } \leq 2 \operatorname* { m a x } w _ { i } \sqrt { 2 \iota \cdot t } . } \end{array} +$$ + +This ends the proof. + +Lemma F.7. With probability $1 - p ,$ , for any $t \in [ T ]$ and any $\theta ^ { * } \in \Delta ^ { A }$ , $i f \gamma _ { i }$ is non-increasing in i, + +$$ +\sum _ { i = 1 } ^ { t } w _ { i } \left. \theta ^ { * } , \widehat { \ell } _ { i } - \ell _ { i } \right. \leq 2 \operatorname* { m a x } _ { i \leq t } w _ { i } \iota / \gamma _ { t } . +$$ + +Proof. Define a basis $\{ e _ { j } \} _ { j = 1 } ^ { A }$ of $\mathbb { R } ^ { A }$ by + +$$ +e _ { j } \left( a \right) = \left\{ { 1 \mathrm { i f } a = j , \atop 0 \mathrm { o t h e r w i s e . } } \right. +$$ + +Then for all the $j \in [ A ]$ , apply Lemma F.4 with $c _ { i } = \gamma _ { t } e _ { j }$ . Since now $c _ { i } ( a ) \leq \gamma _ { t } \leq \gamma _ { i }$ , the condition in Lemma F.4 is satisfied. As a result, for any $t \in [ T ]$ and $j \in [ A ]$ , we have with probability at least $1 - p / ( T A )$ that + +$$ +\sum _ { i = 1 } ^ { t } w _ { i } \left. e _ { j } , \widehat { \ell } _ { i } - \ell _ { i } \right. \leq 2 \operatorname* { m a x } _ { i \leq t } w _ { i } \iota / \gamma _ { t } . +$$ + +Taking a union bound, we have with probability at least $1 - p$ , + +$$ +\sum _ { i = 1 } ^ { t } w _ { i } \left. e _ { j } , \widehat { \ell } _ { i } - \ell _ { i } \right. \leq 2 \operatorname* { m a x } _ { i \leq t } w _ { i } \iota \big / \gamma _ { t } \mathrm { f o r ~ a l l } \left( j , t \right) \in [ m ] \times [ T ] . +$$ + +Since any $\theta ^ { * }$ is a convex combination of $\{ e _ { j } \} _ { j = 1 } ^ { A }$ , on this event, we also have + +$$ +\sum _ { i = 1 } ^ { t } w _ { i } \left. \theta ^ { * } , \widehat { \ell } _ { i } - \ell _ { i } \right. \leq 2 \operatorname* { m a x } _ { i \leq t } w _ { i } \iota / \gamma _ { t } \mathrm { ~ f o r ~ a l l ~ } t \in [ T ] . +$$ + +This finishes the proof. \ No newline at end of file diff --git a/md/dev/6Pv8AMSylux/6Pv8AMSylux.md b/md/dev/6Pv8AMSylux/6Pv8AMSylux.md new file mode 100644 index 0000000000000000000000000000000000000000..3a3e1674a6785e4147e10b9b1f073e350fa3cc55 --- /dev/null +++ b/md/dev/6Pv8AMSylux/6Pv8AMSylux.md @@ -0,0 +1,774 @@ +# DIVISION: MEMORY EFFICIENT TRAINING VIA DUAL ACTIVATION PRECISION + +Anonymous authors Paper under double-blind review + +# ABSTRACT + +Activation compressed training (ACT) has been shown to be a promising way to reduce the memory cost of training deep neural networks (DNNs). However, existing work of ACT relies on searching for optimal bit-width during DNN training to reduce the quantization noise, which makes the procedure complicated and less transparent. To this end, we propose a simple and effective method to compress DNN training. Our method is motivated by an instructive observation: DNN backward propagation mainly utilizes the low-frequency component (LFC) of the activation maps, while the majority of memory is for caching the high-frequency component (HFC) during the training. This indicates the HFC of activation maps is highly redundant and compressible during DNN training, which inspires our proposed Dual ActIVation PrecISION (DIVISION). During the training, DIVISION preserves the high-precision copy of LFC and compresses the HFC into a light-weight copy with low numerical precision. This can significantly reduce the memory cost without negatively affecting the precision of backward propagation such that DIVISION maintains competitive model accuracy. Experimental results show DIVISION achieves over $1 0 \times$ compression of activation maps, and significantly higher training throughput than state-of-theart ACT methods, without loss of model accuracy. The code is available at https://anonymous.4open.science/r/division-5CC0/. + +# 1 INTRODUCTION + +Deep neural networks (DNNs) have been widely applied to real-world tasks such as language understanding (Devlin et al., 2018), machine translation (Vaswani et al., 2017), visual detection and tracking (Redmon et al., 2016). With increasingly larger and deeper architectures, DNNs achieve remarkable improvement in representation learning and generalization capacity (Krizhevsky et al., 2012). Generally, training a larger model requires more memory resources to cache the activation values of all intermediate layers during the back-propagation1. For example, training a DenseNet121 (Huang et al., 2017) on the ImageNet dataset (Deng et al., 2009) requires to cache over 1.3 billion float activation values (4.8GB) during back-propagation; and training a ResNet-50 (He et al., 2016) requires to cache over 4.6 billion float activation values (17GB). Some techniques have been developed to reduce the training cache of DNNs, such as checkpointing (Chen et al., 2016; Gruslys et al., 2016), mix precision training (Vanholder, 2016), low bit-width training (Lin et al., 2017; Chen et al., 2020) and activation compressed training (Georgiadis, 2019; Liu et al., 2022). Among these, the activation compressed training (ACT) has emerged as a promising method due to its significant reduction of training memory and the competitive learning performance (Liu et al., 2021b). + +Existing work of ACT relies on quantizing the activation maps to reduce the memory consumption of DNN training, such as BLPA (Chakrabarti & Moseley, 2019), TinyScript (Fu et al., 2020) and ActNN (Chen et al., 2021). Although ACT could significantly reduce the training memory cost, the quantization process introduces noises in backward propagation, which makes the training suffer from undesirable degradation of accuracy (Fu et al., 2020). Due to this reason, BLPA requires 4- bit ACT to ensure the convergence to optimal solution on the ImageNet dataset, which has only $6 \times$ compression rate2 of activation maps (Chakrabarti & Moseley, 2019). Other works propose to search for optimal bit-width to match different samples during training, such as ActNN (Chen et al., 2021) and AC-GC (Evans & Aamodt, 2021). Although it can moderately reduce the quantization noise and achieves optimal solution under 2-bit ACT (nearly $1 0 \times$ compression rate), the following issues cannot be ignored. First, it is time-consuming to search for optimal bit-width during training. Second, the framework of bit-width searching is complicated and non-transparent, which brings new challenges to follow-up studies on the ACT and its real-world applications. + +In this work, we propose a simple and transparent method to reduce the memory cost of DNN training. Our method is motivated by an instructive observation: DNN backward propagation mainly utilizes the low-frequency component (LFC) of the activation maps, while the majority of memory is for the storage of high-frequency component (HFC) during the training. This indicates the HFC of activation map is highly redundant and compressible during the training. Following this direction, we propose Dual Activation Precision (DIVISION), which preserves the high-precision copy of LFC and compresses the HFC into a light-weight copy with low numerical precision during the training. In this way, DIVISION can significantly reduce the memory cost. Meanwhile, it will not negatively affect the quality of backward propagation and could maintain competitive model accuracy. + +Compared with existing work that integrates searching into learning (Liu et al., 2022), DIVISION has a more simplified compressor and decompressor, speeding up the procedure of ACT. More importantly, it reveals the compressible (HFC) and non-compressible factors (LFC) during DNN training, improving the transparency of ACT. Experiments are conducted to evaluate DIVISION in terms of memory cost, model accuracy, and training throughput. An overall comparison is given in Figure 1 (a). Our proposed DIVISION consistently outperforms state-of-the-art baseline methods in the above three aspects. The contributions of this work are summarized as follows: + +• We experimentally demonstrate and theoretically prove that DNN backward propagation mainly utilizes the LFC of the activation maps. The HFC is highly redundant and compressible. • We propose a simple framework DIVISION to effectively reduce the memory cost of DNN training via removing the redundancy in the HFC of activation maps during the training. • Experiments on three benchmark datasets demonstrate the effectiveness of DIVISION in terms of memory cost, model accuracy, and training throughput. + +# 2 PRELIMINARY + +# 2.1 NOTATIONS + +Without loss of generality, we consider an $L$ -layer deep neural network in this work. During the forward pass, for each layer $l$ $\begin{array} { r } { 1 \leq l \leq L } { } \end{array}$ ), the activation map is calculated by + +$$ +\mathbf { H } _ { l } = \operatorname { f o r w a r d } ( \mathbf { H } _ { l - 1 } ; \mathbf { W } _ { l } ) , +$$ + +where $\mathbf { H } _ { l }$ denotes the activation map of layer $l$ ; $\mathbf { H } _ { 0 }$ takes a mini-batch of input images; $\mathbf { W } _ { l }$ denotes the weight of layer $l$ ; and forward $( \cdot )$ denotes the feed-forward operation. During the backward pass, the gradients of the loss value towards the activation maps and weights are be estimated by + +$$ +\begin{array} { r } { \left[ \hat { \nabla } _ { \mathbf { H } _ { l - 1 } } , \hat { \nabla } _ { \mathbf { W } _ { l } } \right] = \operatorname { b a c k w a r d } ( \hat { \nabla } _ { \mathbf { H } _ { l } } , \mathbf { H } _ { l - 1 } , \mathbf { W } _ { l } ) , } \end{array} +$$ + +where $\hat { \nabla } _ { \mathbf { H } _ { l - 1 } }$ and $\hat { \nabla } _ { \mathbf { H } _ { l } }$ denote the gradient towards the activation map of layer $l - 1$ and $l$ , respectively; $\hat { \nabla } _ { \mathbf { W } _ { l } }$ denotes the gradient towards the weight of layer $l$ ; and backward $( \cdot ) ^ { 3 }$ denotes the backward function which takes $\hat { \nabla } _ { \mathbf { H } _ { l } }$ , $\mathbf { H } _ { l - 1 }$ and $\mathbf { W } _ { l }$ , and outputs the gradients $\hat { \nabla } _ { \mathbf { H } _ { l - 1 } }$ and $\hat { \nabla } _ { \mathbf { W } _ { l } }$ . Equation (2) indicates it is required to cache the activation maps $\mathbf { H } _ { 0 } , \cdots , \mathbf { H } _ { L - 1 }$ after the feedforward operations for gradient estimation during backward propagation. + +# 2.2 ACTIVATION COMPRESSED TRAINING + +It has been proved in existing work (Chen et al., 2020) that majority of memory (nearly $90 \%$ ) is for caching activation maps during the training of DNNs. Following this direction, the activation compressed training (ACT) reduces the memory cost via real-time compressing the activation maps during the training. A typical ACT framework in existing work (Chakrabarti & Moseley, 2019) is shown in Figure 1 (b). Specifically, after the feed-forward operation of each layer $l$ , activation map $\mathbf { H } _ { l - 1 }$ is compressed into a representation for caching. The compression enables a significant reduction of memory compared with caching the original (exact) activation maps. During the backward pass of layer $l$ , ACT decompresses the cached representation into $\hat { \mathbf { H } } _ { l - 1 }$ , and estimates the gradient by taking the reconstructed $\hat { \mathbf { H } } _ { l - 1 }$ into Equation (2): $[ \hat { \nabla } _ { \mathbf { H } _ { l - 1 } } , \hat { \nabla } _ { \mathbf { W } _ { l } } ] = \operatorname { b a c k w a r d } ( \hat { \nabla } _ { \mathbf { H } _ { l } } , \hat { \mathbf { H } } _ { l - 1 } , \mathbf { W } _ { l } ) .$ + +![](images/4acc6fe49c2733f27a4d011e3f7727507aa4634198fedf43d0dc08186513d825.jpg) +Figure 1: (a) Overall performance of DIVISION versus baseline methods. (b) Activation compressed training. + +![](images/9760f45e24475edce7d3e16c225a62b86a6a9641f48444d2e41c89f8c5ea79f9.jpg) +Figure 2: (a) Adopting DCT to estimate the low frequency component (LFC) and high frequency component (HFC) of an image. (b) Top-1 accuracy and (c) Memory cost of normal training, LFC-ACT and HFC-ACT, where RN-18, DN-121, and SN refer to the ResNet-18, DenseNet-121, and ShuffleNet-V2, respectively. + +Even though the pipeline of compression and decompression is lossy, i.e. $\hat { \mathbf { H } } _ { l } \neq \mathbf { H } _ { l }$ for $1 \le l \le L$ . It has been proved ACT can limit the reconstruction error flowing back to early layers and enables the training to approach an approximately optimal solution (Chen et al., 2021). + +# 2.3 DISCRETE COSINE TRANSFORMATION + +Discrete Cosine Transformation (DCT) projects the target data from the spatial domain to the frequency domain via the inner-production of the data and a collection of cosine functions with different frequency (Rao & Yip, 2014). We focus on the 2D-DCT in this work, where the target data is the input image and activation maps of DNNs. Specifically, for 2D-matrix data $\mathbf { H }$ , the frequency-domain feature $\widetilde { \bf H }$ is estimated by $\widetilde { \mathbf { H } } = \mathrm { D C T } ( \mathbf { H } )$ , where $\mathbf { H }$ and $\widetilde { \bf H }$ have the same shape of $N \times N$ . and each of the element $\tilde { h } _ { i , j }$ is given by + +$$ +\tilde { h } _ { i , j } = \sum _ { m = 0 } ^ { N - 1 } \sum _ { n = 0 } ^ { N - 1 } h _ { m , n } \cos { \left[ \frac { \pi } { N } \left( m + \frac { 1 } { 2 } \right) i \right] } \cos { \left[ \frac { \pi } { N } \left( n + \frac { 1 } { 2 } \right) j \right] } , +$$ + +where $h _ { m , n }$ , $0 \leq m , n \leq N - 1$ , are elements in the original matrix $\mathbf { H }$ . During the training of DNNs, an image or activation map has the shape of Minibatch $\times { \mathrm { C h a n n e l } } \times N \times N$ . In this case, the frequency-domain feature is estimated via operating 2D-DCT for each $N { \times } N$ matrix in each channel. + +With DCT, we could extract the low-frequency/high-frequency component (LFC/HFC) of an image or activation map, using a pipeline of low-pass/high-pass masking and inverse DCT, as shown in Figure 2. To be concrete, the estimation of LFC and HFC is given by + +$$ +\begin{array} { r l } & { \mathbf { H } ^ { \mathsf { L } } = \mathrm { i } \mathrm { D C T } ( \widetilde { \mathbf { H } } \odot \mathbf { M } ) } \\ & { \mathbf { H } ^ { \mathsf { H } } = \mathrm { i } \mathrm { D C T } ( \widetilde { \mathbf { H } } \odot ( \mathbf { 1 } _ { N \times N } - \mathbf { M } ) ) , } \end{array} +$$ + +where $\mathrm { i D C T } ( \cdot )$ denotes the inverse DCT (Rao & Yip, 2014); $\mathbf { M } = [ m _ { i , j } | 1 \leq i , j \leq N ]$ denotes an $N \times N$ low-pass mask satisfying $m _ { i , j } = 1$ for $1 \leq i , j \leq W$ and $m _ { i , j } = 0$ for other elements; and $\mathbf { 1 } _ { N \times N } - \mathbf { M }$ indicates the high-pass mask. Intuitively, $\mathbf { H } ^ { \mathsf { L } }$ has $W ^ { 2 }$ non-zero float numbers in each channel, in contrast with $N ^ { \Xi } - W ^ { 2 }$ non-zero float numbers in each channel of $\mathbf { H } ^ { \mathsf { H } }$ . Generally, we have $W \ll N$ in practical scenarios, e.g. $W / N = 0 . 1$ in Figure 2 (a). This indicates the HFC takes the majority of the memory cost in the caching of activation maps. + +# 3 CONTRIBUTION OF LFC AND HFC TO BACKWARD PROPAGATION + +In this section, we experimentally prove the LFC of activation maps has significantly more contribution to DNN backward propagation than the HFC. Moreover, our theoretical result indicates the LFC enables the estimated gradient to be bounded into a tighter range around the optimal value, leading to a more accurate learned model, which is consistent with the experimental results. + +![](images/6e15190f61de85f9bafe7e5aee52d33e715b5ef6a4a1d059f25a5f3640c2618a.jpg) +Figure 3: $\lambda _ { l } ^ { \downarrow } = \hat { | } | \widetilde { \mathbf { H } } _ { l } \odot \mathbf { M } | | _ { F }$ versus $\lambda _ { l } ^ { \sf H } = | | \widetilde { \bf H } _ { l } \odot ( { \bf 1 } - \dot { \bf M } ) | | _ { F }$ in the training (epoches 20, 40, and 60) of ResNet18. $\mathbf { H } _ { l }$ takes the activation maps of four BasicBlocks in ResNet-18; $\boxed { \begin{array} { r l } \end{array} }$ indicates the mean values; $W { = } 0 . 5 N$ . + +# 3.1 EXPERIMENTAL ANALYSIS + +To study the individual contribution of LFC and HFC to DNN backward propagation, we design three training methods with different backward propagations: LFC-ACT takes LFC into the backward function as shown in Equation (6), where $\dot { \bf H } _ { l } ^ { \mathrm { L } }$ is estimated by Equations (4); HFC-ACT takes HFC into the backward function as given in Equation (7), where $\mathbf { H } _ { l } ^ { \mathsf { H } }$ is according to Equation (5); Normal training (for comparison) estimates the gradients by Equation (2). + +$$ +\begin{array} { r l } & { [ \hat { \nabla } _ { \mathbf { H } _ { l - 1 } } ^ { \bullet } , \hat { \nabla } _ { \mathbf { W } _ { l } } ] = \mathrm { b a c k w a r d } ( \hat { \nabla } _ { \mathbf { H } _ { l } } , \check { \mathbf { H } } _ { l } ^ { \ L } , \dot { \mathbf { W } } _ { l } ) , } \\ & { [ \hat { \nabla } _ { \mathbf { H } _ { l - 1 } } , \hat { \nabla } _ { \mathbf { W } _ { l } } ] = \mathrm { b a c k w a r d } ( \hat { \nabla } _ { \mathbf { H } _ { l } } , \mathbf { H } _ { l } ^ { \ H } , \mathbf { W } _ { l } ) . } \end{array} +$$ + +We conduct the experiments on the CIFAR-10 dataset. The implementation details are given in Appendix A. The top-1 accuracy and memory cost of LFC-ACT, HFC-ACT, and normal training are shown in Figure 2 (b) and (c), respectively. Overall, we have the following observations: + +• Accuracy drop: According to Figure 2 (b), HFC-ACT suffers from significantly more degradation of accuracy than LFC-ACT. This indicates DNN backward propagation mainly utilizes the LFC of activation maps during the training. • Memory cost: According to Figure 2 (c), the storage of HFC requires significantly more memory than that of the LFC. i.e. The storage of HFC consumes the majority of memory. + +To better understand the results of model accuracy, we theoretically prove the gradient for backward propagation is bounded into a tighter range around the optimal value in LFC-ACT. This enables LFC-ACT to learn a more accurate model than HFC-ACT. + +# 3.2 THEORETICAL ANALYSIS + +We theoretically analyze the gradient estimation error of LFC-ACT and HFC-ACT which adopt Equations (6) aHFC-ACT, let $\hat { \nabla } _ { \mathbf { W } _ { l } } ^ { \ L }$ ) forand $\hat { \nabla } _ { \mathbf { W } _ { l } } ^ { \mathsf { H } }$ ward propagation, respectively. Generdenote the estimated gradient of layer $l$ ly, for the LFC-ACT and, respectively. In this way, $\big | \big | \hat { \nabla } _ { \mathbf { W } _ { l } } ^ { \mathsf { L } } - \bigtriangledown _ { \mathbf { W } _ { l } } \big | \big | _ { F } 4$ and a ref $| | \hat { \nabla } _ { \mathbf { W } _ { l } } ^ { \mathsf { H } } - \nabla _ { \mathbf { W } _ { l } } | | _ { F }$ indicates the gradient estimation errors, taking the completere the distortion of backward propagation in LFC-ACT and $\nabla _ { \mathbf { W } _ { l } }$ HFC-ACT, let $\mathrm { G E B } _ { l } ^ { \mathsf { L } }$ and $\mathrm { G E B } _ { l } ^ { \mathsf { H } }$ denote the gradient error upper bound (GEB), respectively, i.e. $\| \hat { \nabla } _ { \mathbf { W } _ { l } } ^ { \ L } - \nabla _ { \mathbf { W } _ { l } } \| _ { F } \leq \mathrm { G E B } _ { l } ^ { \ L }$ and $\lvert \lvert \hat { \nabla } _ { \mathbf { W } _ { l } } ^ { \mathsf { H } } - \nabla _ { \mathbf { W } _ { l } } \lvert \lvert _ { F } \leq \mathrm { G E B } _ { l } ^ { \mathsf { H } }$ . Intuitively, higher GEB indicates less accurate backward propagation, leading to a less accurate model after training. To this end, we give Theorem 1 to compare $\mathrm { \bar { G E B } } _ { l } ^ { \mathsf { L } }$ and $\mathrm { G E B } _ { l } ^ { \mathsf { H } }$ , where a convolutional layer is considered. The proof is given in Appendix B. A similar analysis of GEB for a linear layer is provided in Appendix C. + +Theorem 1. During the backward pass of a convolutional layer $l$ , $\mathrm { G E B } _ { l } ^ { \mathsf { L } }$ and $\mathrm { G E B } _ { l } ^ { \mathsf { H } }$ satisfy + +$$ +\mathbf { G E B } _ { l } ^ { \mathbf { L } } - \mathbf { G E B } _ { l } ^ { \mathbf { H } } = \left( \alpha _ { l , l } | | \mathbf { H } _ { l - 1 } ^ { \mathsf { T } } | | _ { F } + \beta _ { l } \right) ( \lambda _ { l } ^ { \mathsf { H } } - \lambda _ { l } ^ { \mathbf { L } } ) + | | \mathbf { H } _ { l - 1 } ^ { \mathsf { T } } | | _ { F } \sum _ { i = l + 1 } ^ { L } \alpha _ { l , i } ( \lambda _ { i } ^ { \mathsf { H } } - \lambda _ { i } ^ { \mathbf { L } } ) \prod _ { j = l } ^ { i - 1 } \gamma _ { j } , +$$ + +where $\alpha _ { l , i } , \beta _ { l } , \gamma _ { l } > 0$ for $1 \leq l , i \leq L$ depend on the model weights before backward propagation (given by Equations (24) in Appendix $B$ ); $\lambda _ { l } ^ { \mathbf { L } } = | | \widetilde { \mathbf { H } } _ { l } { \odot } \mathbf { M } | | _ { F } ; { \boldsymbol { \lambda } } _ { l } ^ { \mathsf { H } } { = } | | \widetilde { \mathbf { H } } _ { l } { \odot } ( \mathbf { 1 } { - } \mathbf { M } ) | | _ { F } ; \widetilde { \mathbf { H } } _ { l } { = } \mathrm { D C T } ( \mathbf { H } _ { l } ) ,$ ; and M denotes the loss-pass mask given by Equation (4). + +Theorem 1 indicates the GEB difference depends on $\lambda _ { \underline { { l } } } ^ { \mathsf { H } } - \lambda _ { l } ^ { \mathsf { L } }$ for $1 \leq l \leq L$ during the training. Following this direction, we estimate $\lambda _ { l } ^ { \mathsf { L } }$ and $\lambda _ { l } ^ { \mathsf { H } }$ via $\lambda _ { l } ^ { \mathbf { L } } { = } | | \widetilde { \mathbf { H } } _ { l } { \odot } \mathbf { M } | | _ { F }$ and $\lambda _ { l } ^ { \mathsf { H } } = | | \widetilde { \mathbf { H } } _ { l } \odot ( \mathbf { 1 - M } ) | | _ { F }$ during the training of ResNet-18 and DenseNet-121 on the CIFAR-10 dataset. Specifically, $\mathbf { H } _ { l }$ takes the activation maps of the BasicBlocks in ResNet-18, and Denseblocks in DenseNet-121. The estimation of $\lambda _ { l } ^ { \mathsf { L } }$ and $\lambda _ { l } ^ { \mathsf { H } }$ is based on the checkpoint of ResNet-18 in epoches 20, 40, and 60, and visualized in Figures 3 (a)-(c), respectively; and the results of DenseNet-121 are given in Appendix D. It is consistently observed that $\lambda _ { l } ^ { \mathsf { L } } > \lambda _ { l } ^ { \mathsf { H } }$ for different instances and layers. This leads to $\mathrm { \bar { G E B } } _ { l } ^ { \mathsf { L } } < \mathrm { G E B } _ { l } ^ { \mathsf { H } }$ according to Theorem 1. Therefore, HFC-ACT suffers from a worse distortion of backward propagation during the training, eventually leading to less accurate learned model than LFC-ACT. + +![](images/a2b627f97dbfa1492cc5b154bc8008a695ed5791bcff3c0c85d3030644330850.jpg) +Figure 4: Framework of Dual Activation Precision Training. + +In this section, from both experimental and theoretical perspectives, we prove the HFC of activation maps has less contribution to backward propagation than LFC. However, according to Figure 2 (c), the HFC takes the majority of memory cost during the training. This indicates the HFC is highly redundant and compressible during the training. Following this direction, we propose DIVISION to compress the activation maps into a dual precision representation: high-precision LFC combined with low-precision HFC. On the one hand, both LFC and low-precision HFC requires much less memory to cache. On the other hand, removing the redundancy of HFC cannot cause much distortion of backward propagation. In this way, DIVISION enables effective compression of training memory without degradation of model accuracy. + +# 4 DUAL ACTIVATION PRECISION TRAINING + +We introduce the proposed Dual ActIVation PrecISION (DIVISION) in this section. The framework of DIVISION is shown in Figure 4. Specifically, after the feed-forward operation of each layer, DIVISION estimates the LFC and compresses the HFC into a low-precision copy such that the total memory cost is significantly decreased after the compression. Before the backward propagation of each layer, the low-precision HFC is decompressed and combined with LFC to reconstruct the activation map. The detailed compression and decompression are given as follows. + +# 4.1 ACTIVATION MAP COMPRESSION + +For compressing the activation map $\mathbf { H } _ { l }$ of layer $l$ , DIVISION estimates the LFC $\mathbf { H } _ { l } ^ { \mathrm { L } }$ and HFC $\mathbf { H } _ { l } ^ { \mathsf { H } }$ after the feed-forward operation. However, the high computational complexity of DCT prevents us from directly applying it to real-time algorithms. We thus give Theorem 2 to introduce a moving average operation that can approximate the loss-pass filter. The proof is given in Appendix E. + +Theorem 2. For any real-valued function f(x) and its moving average ¯f(x) = 12B R x+x $\begin{array} { r } { \bar { f } ( x ) = \frac { 1 } { 2 B } \int _ { x } ^ { x + 2 B } f ( t ) \mathrm { d } t , } \end{array}$ , let $F ( \omega )$ and $\overline { { F } } ( \omega )$ denote the Fourier transformation of $f ( x )$ and ${ \bar { f } } ( x )$ , respectively. Generally, we have $\overline { { F } } ( \omega ) = H ( \omega ) F ( \omega )$ , where $\begin{array} { r } { | H ( \omega ) | = | \frac { \sin \omega B } { \omega B } | } \end{array}$ + +Remark 1. The frequency response of $H ( \omega )$ depends on its envelope function $\frac { 1 } { | { \boldsymbol { \omega } } { \boldsymbol { B } } | }$ . Note that $\frac { 1 } { | { \boldsymbol { \omega } } { \boldsymbol { B } } | }$ decreases with $| \omega |$ such that $\begin{array} { r } { \frac { 1 } { | \omega B | } 0 } \end{array}$ as $\omega \infty$ . Hence, $H ( \omega )$ is an approximate loss-pass filter. + +According to Remark 1, we approximate the LFC $\mathbf { H } _ { l } ^ { \mathrm { L } }$ into the moving average of $\mathbf { H } _ { l }$ . Note that the average pooling operator provides efficient moving average. DIVISION adopts average pooling to estimate the LFC by $\mathbf { H } _ { l } ^ { \lfloor } = \mathrm { A v e r a g e P o o l i n g } ( \mathbf { H } _ { l } )$ . The value of block-size and moving stride is a unified hyper-parameter $B$ , which controls the memory of $\mathbf { H } _ { l } ^ { \mathsf { L } 5 }$ . Moreover, $\mathbf { H } _ { l } ^ { \mathsf { L } }$ is cached in the format of bfloat16 for saving the memory. In our experiments, we found $\dot { B } = 8$ can provide representative LFC for backward propagation, where the memory cost of $\mathbf { H } _ { l } ^ { \mathrm { L } }$ is only $0 . 8 \%$ of $\mathbf { H } _ { l }$ . + +To estimate the HFC, DIVISION calculates the residual value $\mathbf { H } _ { l } ^ { \mathsf { H } } = \mathbf { H } _ { l } - \mathrm { U p S a m p l i n g } ( \mathbf { H } _ { l } ^ { \mathsf { L } } )$ , where the UpSampling(·) enlarges $\mathbf { H } _ { l } ^ { \mathsf { L } }$ to shape Minibatc $1 \times \mathrm { C h a n n e l } \times i$ N ×N via nearest interpolation. Then, DIVISION compress the $\mathbf { H } _ { l } ^ { \mathsf { H } }$ into low-precision because it plays a less important role during the backward propagation but consumes most of the memory. Specifically, DIVISION adopts $Q$ -bit per-channel quantization67 for the compression, where the bit-width $Q$ controls the precision and memory cost of HFC after the compression. Let $\mathbf { V } _ { l } ^ { \mathsf { H } }$ denote a $Q$ -bit integer matrix, as the lowprecision representation of $\mathbf { H } _ { l } ^ { \mathsf { H } }$ . The detailed procedure of compressing $\mathbf { H } _ { l } ^ { \mathsf { H } }$ into $\mathbf { V } _ { l } ^ { \mathsf { H } }$ is given by + +$$ +\mathbf { V } _ { l } ^ { \mathsf { H } } = \mathrm { Q u a n t } ( \mathbf { H } _ { l } ^ { \mathsf { H } } ) = \big [ \Delta _ { l } ^ { - 1 } ( \mathbf { H } _ { l } ^ { \mathsf { H } } - \delta _ { l } ) \big ] , +$$ + +where $\delta _ { l }$ denotes the minimum element in $\mathbf { H } _ { l } ^ { \mathsf { H } }$ ; $\Delta _ { l } = ( h _ { \operatorname* { m a x } } - \delta _ { l } ) / ( 2 ^ { Q } - 1 )$ denotes the quantization step; $h _ { \mathrm { m a x } }$ denotes the maximum element in $\mathbf { H } _ { l } ^ { \mathsf { H } } ; \lfloor \bullet \rceil$ denotes the stochastic rounding89 (Gupta et al., 2015); and $\delta _ { l }$ and $\Delta _ { l }$ are cached in the formate of bfloat16 for saving memory. In this way, the memory cost of $( \mathbf { V } _ { l } ^ { \mathsf { H } } , \delta _ { l } , h _ { \operatorname* { m a x } } )$ is $\left( N ^ { 2 } Q / 8 + 4 \right)$ bytes per channel, in contrast with that of $\mathbf { H } _ { l }$ being $4 N ^ { 2 }$ bytes per channel. In our experiments, we found $Q = 2$ can provide enough representation for backward propagation, where the memory cost of $\mathbf { V } _ { l } ^ { \mathsf { H } }$ is only $8 . 3 \%$ of $\mathbf { H } _ { l }$ . + +After the compression, as the representation of $\mathbf { H } _ { l }$ , the tuple of $( \mathbf { H } _ { l } ^ { \mathsf { L } } , \mathbf { V } _ { l } ^ { \mathsf { H } } , \Delta _ { l } , \delta _ { l } )$ is cached to the memory for reconstructing the activation maps during the backward pass. + +# 4.2 ACTIVATION MAP DECOMPRESSION + +During the backward pass, DIVISION adopts the cached tuples of $\{ ( \mathbf { H } _ { l } ^ { \mathsf { L } } , \mathbf { V } _ { l } ^ { \mathsf { H } } , \Delta _ { l } , \delta _ { l } ) \mid 0 \leq l \leq$ $L - 1 \}$ to reconstruct the activation map layer-by-layer. Specifically, for each layer $l$ , DIVISION dequantizes the HFC via $\hat { \mathbf { H } } _ { l } ^ { \mathsf { H } } = \Delta _ { l } \mathbf { V } _ { l } ^ { \mathsf { H } } + \delta _ { l }$ , which is the inverse process of Equation (9). Then, the activation map is reconstructed via + +$$ +\hat { \mathbf { H } } _ { l } = \mathrm { U p S a m p l i n g } ( \mathbf { H } _ { l } ^ { \mathsf { L } } ) + \hat { \mathbf { H } } _ { l } ^ { \mathsf { H } } , +$$ + +where UpSampling $( \cdot )$ enlarges $\mathbf { H } _ { l } ^ { \mathrm { L } }$ to shape Minibatch×Channe ${ \times } N { \times } N$ via nearest interpolation. After the decompression, DIVISION frees the caching of $( \mathbf { H } _ { l } ^ { \mathsf { L } } , \mathbf { V } _ { l } ^ { \mathsf { H } } , \Delta _ { l } , \delta _ { l } )$ , and takes $\hat { \mathbf { H } } _ { l }$ into $[ \hat { \nabla } _ { \mathbf { H } _ { l - 1 } } , \hat { \nabla } _ { \mathbf { W } _ { l } } ] = \operatorname { b a c k w a r d } ( \hat { \nabla } _ { \mathbf { H } _ { l } } , \hat { \mathbf { H } } _ { l - 1 } , \mathbf { W } _ { l } )$ to estimate the gradient for backward propagation. Without loss of generality, 1D/3D activation maps are considered for DIVISION in Appendix F. + +# 4.3 ALGORITHM OF DIVISION + +Algorithm 1 demonstrates a mini-batch updating of DIVISION, which includes a forward pass and backward pass. During the forward pass of each layer, DIVISION first forwards the exact activation map to the next layer (line 2); then, estimates the LFC and HFC (line 3- 4); after this, achieves the low precision copy of HFC (lines 5); finally caches the representation to the memory (line 6). During the backward pass of each layer, DIVISION first decompresses the HFC (line 10); then reconstructs the activation map (line 11); after this, estimates the gradients and updates the weights of layer $l$ (line 12); finally frees the caching of $( \mathbf { H } _ { l - 1 } ^ { \mathsf { L } } , \mathbf { V } _ { l - 1 } ^ { \mathsf { H } } , \Delta _ { l - 1 } , \delta _ { l - 1 } )$ (line 13). For each minibatch updating, the memory usage reaches the + +# Algorithm 1 Mini-batch updating of DIVISION + +Input: Mini-batch samples $\mathbf { x }$ and labels y. +Output: Weight and bias $\{ \mathbf { W } _ { l } , \mathbf { B } _ { l } | 1 \le l \le L \}$ . +1: for layer $l : = 1$ to $L$ do +2: $\mathbf { H } _ { l } = f ( \mathbf { W } _ { l } \mathbf { H } _ { l - 1 } + \mathbf { B } _ { l } ) / / \mathbf { H } _ { 0 } = \mathbf { x }$ +3: $\mathbf { H } _ { l - 1 } ^ { \mathsf { L } } = \mathrm { A v e r a g e P o o l i n g } ( \mathbf { H } _ { l - 1 } )$ +4: $\mathbf { H } _ { l - 1 } ^ { \mathsf { H } } = \mathbf { H } _ { l - 1 } - \mathrm { U p S a m p l i n g } ( \mathbf { H } _ { l - 1 } ^ { \mathsf { L } } )$ +5: $\boldsymbol { \mathsf { V } } _ { l - 1 } ^ { \mathsf { H } } , \boldsymbol { \Delta _ { l - 1 } } , \delta _ { l - 1 } = \operatorname { Q u a n t } ( \mathbf { H } _ { l - 1 } ^ { \mathsf { H } } )$ +6: Cache $( \mathbf H _ { l - 1 } ^ { \mathsf { L } } , \mathbf V _ { l - 1 } ^ { \mathsf { H } } , \Delta _ { l - 1 } , \delta _ { l - 1 } \big )$ +7: end for +8: Estimate the loss value and gradient $\hat { \nabla } _ { \mathbf { H } _ { L } }$ . +9: for layer $l : = L$ to 1 do +10: $\hat { \mathbf { H } } _ { l - 1 } ^ { \sf H } = \mathrm { D e q u a n t } ( \mathbf { V } _ { l - 1 } ^ { \sf H } , \Delta _ { l - 1 } , \delta _ { l - 1 } )$ +11: $\hat { \mathbf { H } } _ { l - 1 } = \mathrm { U p S a m p l i n g } ( \mathbf { H } _ { l - 1 } ^ { \mathsf { L } } ) + \hat { \mathbf { H } } _ { l - 1 } ^ { \mathsf { H } }$ +12: Estimate $[ \hat { \nabla } _ { \mathbf { H } _ { l - 1 } } , \hat { \nabla } _ { \mathbf { W } _ { l } } ]$ and update $\mathbf { W } _ { l }$ +13: Free $( \mathbf H _ { l - 1 } ^ { \mathsf { L } } , \mathbf V _ { l - 1 } ^ { \mathsf { H } } , \Delta _ { l - 1 } , \delta _ { l - 1 } \big )$ . +14: end for + +maximum value after the forward pass (caching the representation of activation maps layer-bylayer), and reduces to the minimum value after the backward pass (freeing the cache layer-by-layer). Existing work (Chen et al., 2021) estimates the memory cost of activation maps by + +Memory Cost $=$ Memory Utilizationafter forward − Memory Utilizationafter backward, where existing deep learning tools provide $\mathsf { A P I s } ^ { 1 0 }$ to estimate the memory utilization. + +The theoretical compression rate $R$ of DIVISION is given in Appendix G, where general cases of convolutional neural networks and multi-layer perception are considered for the estimation. For the model architectures in our experiments, we have $R _ { \mathrm { R e s N e t - 5 0 } } , R _ { \mathrm { W R N - 5 0 - 2 } } \geq 1 0 . 3 5$ . + +![](images/79bd97596a52de0297dfdde60309cfc0ce3fd8c03be7a093d5f384a7932aa30f.jpg) + +# 5 EVALUATION OF DIVISION + +We conduct the experiments to evaluate DIVISION by answering the following research questions. RQ1: How does DIVISION perform compared with state-of-the-art baseline methods in terms of the model accuracy, memory cost, and training throughput? RQ2: Does the strategy of dual-precision compression contribute to DIVISION? RQ3: What is the effect of hyper-parameters on DIVISION? + +The experiment setting including the datasets, baseline methods and DNN architectures is specified in Appendix H. The implementation details including the hyper-parameters of DIVISION and configuration of baseline methods are given in Appendix I. More experiments on MLPs, vision transformers, depthwise, and pointwise convolutional layers are given in Appendix K, L, and M. + +# 5.1 EVALUATION BY MODEL ACCURACY (RQ1) + +In this section, we evaluate the training methods in terms of model accuracy on the CIFAR-10, CIFAR-100 and ImageNet datasets. Specifically, DIVISION is compared with BLPA (Chakrabarti & Moseley, 2019), AC-GC (Evans & Aamodt, 2021) and ActNN (Chen et al., 2021) in Figure 5 (a)- (c), respectively, where different model architectures are considered. Here, Checkpoint and SWAP are not considered in this section because they are able to reduce the training memory without degradation of model accuracy. Overall, we have the following observations: + +• DIV vs Baseline Methods: Compared with normal training, DIVISION achieves almost the same top-1 validation accuracy. In contrast, the baseline methods suffer from slightly higher validation error. This indicates DIVISION provides nearly loss-less compression of DNN training. + +• Flexibility of DIV: DIVISION consistently achieves competitive model accuracy in the training of different architectures on different datasets. This indicates DIVISION is a flexible framework that can be applied to different scenarios. + +• Compressibility of HFC: Note that DIVISION adopts a significantly high compression rate $1 2 \times$ for the HFC during the training, and achieves nearly loss-less accuracy. This result indicates the HFC of activation map is highly redundant and compressible during the training. + +# 5.2 EVALUATION BY MEMORY COST (RQ1) + +We evaluate the training methods in terms of the training memory cost on the ImageNet datasest, where the configuration of our computational infrastructure is given in Appendix R. Table 1 indicates the training memory cost and practical compression rate of DIVISION and baseline methods. Moreover, DIVISION is compared with the checkpoint strategy of Megatron-LM (Shoeybi et al., 2019) in Appendix O. Overall, we have the following observations: + +• DIV vs SWAP, Checkpoint & BLPA: SWAP reduces the GPU memory cost merely by transferring the overhead from GPU to CPU, which is non-effective if considering the memory utilization of both GPU and CPU. Checkpoint shows considerable memory overhead because it caches some key activation maps to reconstruct other activation maps during backward pass. BLPA is less effective than DIVISION because it relies on at least 4-bit compression. + +• DIV vs AC-GC: The practical memory cost of AC-GC should be greater than the values given in Table 1. AC-GC searches the bit-width from an initial maximum value, and finalizes with an optimal bit-width. Thus, the average memory cost should be greater than that in the last epoch. + +• DIV vs ActNN: DIVISION has approximately the same memory cost as ActNN. Beyond the storage of 2-bit activation maps, DIVISION has overhead for caching the LFC; and ActNN spends almost equal overhead for storing the parameters of per-group quantization. + +Table 1: Memory cost $\downarrow$ and compression rate $\uparrow$ . Total Mem refers to total memory cost of weights, optimizer, data and activation maps. Act Mem refers to memory cost of activation maps. $O O M$ refers to out of memory. + +
ArchitectureResNet-50WRN-50-2
Batch-size6412825651264128256512
Total Mem (GB)Normal5.4610.6220.920OM7.5214.2327.680OM
SWAP5.46 (1x)10.62 (1x)20.92 (1x)0OM7.52 (1x)14.23 (1x)27.68 (1x)00M
Checkpoint1.23 (4.4x)2.16 (4.9x)4.03 (5.2x)7.761.71 (4.4x)2.65 (5.4x)4.51 (6.1x)8.25
BLPA1.15 (4.7x)2.01 (5.3x)3.72 (5.6x)7.141.87 (4.0x)2.96 (4.8x)5.15 (5.4x)9.51
AC-GC1.80 (3.0x)3.31 (3.2x)6.31 (3.3x)12.332.72 (2.8x)4.66 (3.1x)8.53 (3.2x)16.27
ActNN0.81 (6.7x)1.34 (7.9x)2.39 (8.8x)4.471.44 (5.2x)2.09 (6.8x)3.41 (8.1x)6.03
DIVISION0.82 (6.7x)1.35 (7.9x)2.41 (8.7x)4.521.45 (5.2x)2.12 (6.7x)3.44 (8.0x)6.08
Act. Mem (GB)Normal5.1410.2520.4800M6.7013.3826.750OM
SWAP5.14 (1x)10.25 (1x)20.48 (1x)00M6.70 (1x)13.38 (1x)26.75 (1x)0OM
Checkpoint0.90 (5.7x)1.80 (5.7x)3.59 (5.7x)7.180.90 (7.4x)1.80 (7.4x)3.59 (7.5x)7.18
BLPA0.82 (6.3x)1.64 (6.2x)3.28 (6.2x)6.561.06 (6.3x)2.11 (6.3x)4.22 (6.3x)8.44
AC-GC1.47 (3.5x)2.94 (3.5x)5.88 (3.5x)11.751.91 (3.5x)3.81 (3.5x)7.61 (3.5x)15.20
ActNN0.49 (10.5x)0.97 (10.6x)1.94 (10.6x)3.890.62 (10.8×)1.25 (10.7×)2.49 (10.7x)4.97
DIVISION0.49 (10.5×)0.99 (10.4×)1.97 (10.4x)3.940.64 (10.5x)1.27 (10.5x)2.52 (10.6x)5.02
+ +![](images/8c64adb55d32edfcf6b576434633c3c4834f80f8c3a18b625cef7579f1a0723b.jpg) +Figure 6: Training throughput $\uparrow$ of (a) Resnet-50 and (b) WRN-50-2 on the ImageNet dataset, where \$ indicates out of memory. (c) Top-1 validation accuracy $( \% ) \uparrow$ of DIVISION, DIVISION w/o HFC, DIVISION w/o LFC and fixed bit-width quantization on the ImageNet dataset. + +• Act. Maps: For normal training, the caching of activation maps takes the majority of memory cost $( > 9 0 \%$ , growing with the mini-batch size), which is consistent with our discussion in Section 1. + +• Compression rate: The activation map compression rate of DIVISION is consistently with the theoretical results $( R _ { \mathrm { R e s N e t - } 5 0 }$ , $R _ { \mathrm { W R N - 5 0 - 2 } } ~ \geq ~ 1 0 . 3 5$ , see Appendix $\mathbf { G }$ ), which is not influenced by the mini-batch size. Moreover, the overall compression rate grows with the mini-batch size. + +# 5.3 EVALUATION BY TRAINING THROUGHPUT (RQ1) + +We now evaluate the training methods in terms of the training throughput on the Imagenet dataset. Generally, the throughput indicates the running speed of a training method via counting the average number of data samples processed per second. The throughput is given by $\frac { \mathrm { M i n i - b a t c h ~ S i z e } } { T _ { \mathrm { b a t c h } } }$ e , where Tbatch denotes the time consumption of single mini-batch updating. Each method is combined with the automatic mixed precision $( \mathbf { A M P } ) ^ { 1 1 }$ to speed up the training. Figures 6 (a) and (b) show the average throughput of 20 times of mini-batch updating. Overall, we have the following observations: + +• Reason for Time overhead: Compared with normal training, the time overhead of DIVISION comes from the estimation of LFC and compression of HFC. In ActNN, the overhead mainly comes from the the dynamic bit-width allocation and activation map quantization. In Checkpoint, it comes from replaying the forward process of inter-media layers. In SWAP, the overhead mainly derives from the communication cost between the CPUs and GPUs. + +• DIV vs ActNN: DIVISION shows higher throughput than ActNN as a result of more simplified data compression. To be concrete, DIVISION adopts average-pooling to extract the LFC, and a fixed bit-width per-channel quantization to compress the HFC. In contrast, ActNN relies on searching optimal bit-width to match different samples, and per-group quantization based on the searched bit-width. ActNN has more complex processing, which leads to its lower throughput. + +• DIV vs SWAP: SWAP is less efficient than ACT-based methods (DIVISION and ActNN), which indicates the CPU-GPU communication cost is larger than the cost of activation map processing. + +# 5.4 EFFECT OF DUAL PRECISION STRATEGY (RQ2) + +To study the effect of our proposed dual precision strategy, DIVISION is compared with three training methods: DIVISION w/o HFC: Merely caching the high-precision LFC for back-propagation. DIVISION w/o LFC: Merely caching the low-precision HFC for back-propagation. Fixed Quant: Compressing the activation maps using a fixed bit-width quantization. The experiments are conducted on the ImageNet dataset using the hyper-parameters given in Appendix S. More experiments of Fixed Quant with different bit-width are given in Appendix P. The model accuracy are given in Figure 6 (c). Overall, we have the following insights: + +• LFC & Low Precision HFC: Removing either HFC or LFC from DIVISION, the training converges to far lower levels of accuracy. This indicates both the LFC and low precision HFC of activation maps are necessary for leading the training to converge to an optimal solution. • Benifits of Dual Precision: The fixed bit-width quantization fails to converge to an optimal solution. This indicates the noise caused by the fixed bit-width quantization can terribly disturb the back-propagation. DIVISION solves this problem by combining a high-precision LFC and a fixed bit-width quantization for compressing the activation maps. + +# 5.5 HYPER-PARAMETER TUNING FOR DIVISION (RQ3) + +We study the effect of hyper-parameters $B$ (block-size) and $Q$ (bitwidth) on the accuracy and compression rate. Specifically, we adopt DIVISION to train ResNet-18 on the CIFAR-10 dataset with $B \in$ $\{ 8 , 1 2 , 1 8 \}$ and $Q \in \{ 2 , 4 , 8 \}$ . The accuracy versus compression rate is shown in Figure 7 (a). Overall, we have the following insights: + +• Effect of $Q$ : The accuracy is stable (consistently nearly $9 5 \%$ ) when reducing the precision-level of HFC $Q$ reduces from 8 to 2). This indicates DIVISION only requires approximate values of HFC during backward propagation. +• Effect of $B$ : Lower-precision LFC for backward propagation leads to significant degradation of accuracy (as $B$ grows from 8 to 18). This is because DIVISION relies on a high-precision LFC to reconstruct the activation maps for backward propagation. +• Optimal Setting: DIVISION has optimal accuracy-compression trade-off taking $B = 8$ and $Q = 2$ , where the degradation of accuracy is less than $0 . 4 \%$ . According to more empirical studies in Appendix N, $B { = } 8$ and $Q = 2$ can be a default setting effective for most of model architectures and datasets. + +Note that normal training can be accelerated by the automatic mixed precision (AMP) (Micikevicius et al., 2017) without loss of accuracy. + +![](images/30d185c1054d7c87522d141914160b9525a69c3458480157bec28ed00590633f.jpg) + +![](images/be1a685a31b16109bac6a2fd8be0957874916ea1cde3aeac9d6cdfaee3f1773d.jpg) +(a) Effect of Hyper-parameters. +(b) Effect of AMP. Figure 7: (a) Top-1 Accuracy and compression rate of DIVISION in different settings. (b) Top-1 accuracy and training throughput of DIVISION w/ and w/o AMP. + +We study whether AMP can speed up DIVISION without loss of accuracy. Specifically, we follow the setting of DIVISION $B = 8$ , $Q = 2$ to train ResNet-18 on the CIFAR-10 dataset. The accuracy and training throughput of DIVISION w/ and w/o AMP are shown in Figure 7 (b). More experiments with different mini-batch size are given in Appendix Q. It is observed that AMP can significantly speed up the DIVISION when MiniBatch-size $\geq 2 5 6$ without loss of model accuracy. This indicates DIVISION has the potential to be applied to scenarios where both time and memory are limited. + +# 6 CONCLUSION + +In this work, we propose a simple framework of activation compressed training. Our framework is motivated by an instructive observation: DNN backward propagation mainly depends on the LFC of the activation maps, while the majority of memory is for the storage of HFC during the training. This indicates back-propagation mainly utilizes the LFC to estimate the gradient, while the HFC is highly redundant and compressible. Following this direction, our proposed DIVISION compresses the activation maps into dual precision representations: high-precision LFC and low-precision HFC, according to their contributions to the back-propagation. This dual precision compression can significantly reduce the memory cost of activation maps without disturbing the training. + +Different from the existing work of ACT, DIVISION is a simple and transparent framework, where the simplicity enables efficient compression and decompression; and transparency allows us to understand the compressible (HFC) and non-compressible factors (LFC) during DNN training. To this end, we hope our work could provide some inspiration for the compression of DNN training. + +# REFERENCES + +Ayan Chakrabarti and Benjamin Moseley. Backprop with approximate activations for memoryefficient network training. Advances in Neural Information Processing Systems, 32, 2019. + +Jianfei Chen, Yu Gai, Zhewei Yao, Michael W Mahoney, and Joseph E Gonzalez. A statistical framework for low-bitwidth training of deep neural networks. Advances in Neural Information Processing Systems, 33:883–894, 2020. + +Jianfei Chen, Lianmin Zheng, Zhewei Yao, Dequan Wang, Ion Stoica, Michael Mahoney, and Joseph Gonzalez. Actnn: Reducing training memory footprint via 2-bit activation compressed training. In International Conference on Machine Learning, pp. 1803–1813. PMLR, 2021. + +Tianqi Chen, Bing Xu, Chiyuan Zhang, and Carlos Guestrin. Training deep nets with sublinear memory cost. arXiv preprint arXiv:1604.06174, 2016. + +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. + +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. + +Paulo SR Diniz, Eduardo AB Da Silva, and Sergio L Netto. Digital signal processing: system analysis and design. Cambridge University Press, 2010. + +Dheeru Dua and Casey Graff. UCI machine learning repository, 2017. URL http://archive. ics.uci.edu/ml. + +R David Evans and Tor Aamodt. Ac-gc: Lossy activation compression with guaranteed convergence. Advances in Neural Information Processing Systems, 34:27434–27448, 2021. + +Fangcheng Fu, Yuzheng Hu, Yihan He, Jiawei Jiang, Yingxia Shao, Ce Zhang, and Bin Cui. Don’t waste your bits! squeeze activations and gradients for deep neural networks via tinyscript. In International Conference on Machine Learning, pp. 3304–3314. PMLR, 2020. + +Georgios Georgiadis. Accelerating convolutional neural networks via activation map compression. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 7085–7095, 2019. + +Priya Goyal, Piotr Dollar, Ross Girshick, Pieter Noordhuis, Lukasz Wesolowski, Aapo Kyrola, An-´ drew Tulloch, Yangqing Jia, and Kaiming He. Accurate, large minibatch sgd: Training imagenet in 1 hour. arXiv preprint arXiv:1706.02677, 2017. + +Audrunas Gruslys, Remi Munos, Ivo Danihelka, Marc Lanctot, and Alex Graves. Memory-efficient ´ backpropagation through time. Advances in Neural Information Processing Systems, 29, 2016. + +Suyog Gupta, Ankur Agrawal, Kailash Gopalakrishnan, and Pritish Narayanan. Deep learning with limited numerical precision. In International conference on machine learning, pp. 1737–1746. PMLR, 2015. + +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. + +Roger A Horn and Charles R Johnson. Matrix analysis. Cambridge university press, 2012. + +Chien-Chin Huang, Gu Jin, and Jinyang Li. Swapadvisor: Pushing deep learning beyond the gpu memory limit via smart swapping. In Proceedings of the Twenty-Fifth International Conference on Architectural Support for Programming Languages and Operating Systems, pp. 1341–1355, 2020. + +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. + +Alex Krizhevsky, Geoffrey Hinton, et al. Learning multiple layers of features from tiny images. 2009. + +Alex Krizhevsky, Ilya Sutskever, and Geoffrey E Hinton. Imagenet classification with deep convolutional neural networks. Advances in neural information processing systems, 25, 2012. + +Xiaofan Lin, Cong Zhao, and Wei Pan. Towards accurate binary convolutional neural network. Advances in neural information processing systems, 30, 2017. + +Xiaoxuan Liu, Lianmin Zheng, Dequan Wang, Yukuo Cen, Weize Chen, Xu Han, Jianfei Chen, Zhiyuan Liu, Jie Tang, Joey Gonzalez, et al. Gact: Activation compressed training for generic network architectures. In International Conference on Machine Learning, pp. 14139–14152. PMLR, 2022. + +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, pp. 10012–10022, 2021a. + +Zirui Liu, Kaixiong Zhou, Fan Yang, Li Li, Rui Chen, and Xia Hu. Exact: Scalable graph neural networks training via extreme activation compression. In International Conference on Learning Representations, 2021b. + +Vijay Madisetti. The digital signal processing handbook. CRC press, 1997. + +Paulius Micikevicius, Sharan Narang, Jonah Alben, Gregory Diamos, Erich Elsen, David Garcia, Boris Ginsburg, Michael Houston, Oleksii Kuchaiev, Ganesh Venkatesh, et al. Mixed precision training. arXiv preprint arXiv:1710.03740, 2017. + +Zizheng Pan, Peng Chen, Haoyu He, Jing Liu, Jianfei Cai, and Bohan Zhuang. Mesa: A memorysaving training framework for transformers. arXiv preprint arXiv:2111.11124, 2021. + +K Ramamohan Rao and Ping Yip. Discrete cosine transform: algorithms, advantages, applications. Academic press, 2014. + +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. + +Mohammad Shoeybi, Mostofa Patwary, Raul Puri, Patrick LeGresley, Jared Casper, and Bryan Catanzaro. Megatron-lm: Training multi-billion parameter language models using model parallelism. arXiv preprint arXiv:1909.08053, 2019. + +Karen Simonyan and Andrew Zisserman. Very deep convolutional networks for large-scale image recognition. arXiv preprint arXiv:1409.1556, 2014. + +Duraisamy Sundararajan. The discrete Fourier transform: theory, algorithms and applications. World Scientific, 2001. + +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. + +Mingxing Tan and Quoc Le. Efficientnet: Rethinking model scaling for convolutional neural networks. In International conference on machine learning, pp. 6105–6114. PMLR, 2019. + +Han Vanholder. Efficient inference with tensorrt. In GPU Technology Conference, volume 1, pp. 2, 2016. + +Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Łukasz Kaiser, and Illia Polosukhin. Attention is all you need. Advances in neural information processing systems, 30, 2017. + +# APPENDIX + +# A IMPLEMENTATION DETAILS OF SECTION 3 + +We give the details of the experiment in Section 3. Without loss of generality, the experiment is conducted on the CIFAR-10 dataset using ResNet-18, DenseNet-121 and ShuffleNet-V2. During the backward propagation of normal training, the gradient of each layer $l$ is estimated by + +$$ +[ \hat { \nabla } _ { \mathbf { H } _ { l - 1 } } , \hat { \nabla } _ { \mathbf { W } _ { l } } ] = \operatorname { b a c k w a r d } ( \hat { \nabla } _ { \mathbf { H } _ { l } } , \mathbf { H } _ { l } , \mathbf { W } _ { l } ) +$$ + +For LFC-ACT, the gradient is estimated by + +$$ +[ \hat { \nabla } _ { \mathbf { H } _ { l - 1 } } , \hat { \nabla } _ { \mathbf { W } _ { l } } ] = \operatorname { b a c k w a r d } ( \hat { \nabla } _ { \mathbf { H } _ { l } } , \mathbf { H } _ { l } ^ { \perp } , \mathbf { W } _ { l } ) , +$$ + +where HFC-ACT denotes the HFC of $\mathbf { H } _ { l }$ ; for HFC-ACT, the gradient is estimated by + +$$ +[ \hat { \nabla } _ { \mathbf { H } _ { l - 1 } } , \hat { \nabla } _ { \mathbf { W } _ { l } } ] = \operatorname { b a c k w a r d } ( \hat { \nabla } _ { \mathbf { H } _ { l } } , \mathbf { H } _ { l } ^ { \mathrm { H } } , \mathbf { W } _ { l } ) , +$$ + +where $\mathbf { H } _ { l } ^ { \mathsf { H } }$ denotes the HFC of $\mathbf { H } _ { l }$ . Note that Equations (13) and (14) causes the distortion of backward propagation in LFC-ACT and HFC-ACT, respectively. The objective of this experiment is to investigate whether this distortion of back-propagation may be powerful enough to lead training to a non-optimal solution. The hyper-parameter setting of the training is given in Table 2. + +Table 2: Hyper-parameter setting. + +
ArchitectureResNet-18DenseNet-121ShuffleNet-V2
Epoch100100100
Batch-size256256256
Initial LR0.10.10.1
LR schedulerStep LRStep LRStep LR
Weight-decay0.00050.00050.0005
OptimizerSGDSGDSGD
SGD Momentum0.90.90.9
Ratio of LFC (W/N)0.30.30.5
+ +# B PROOF OF THEOREM 1 + +We prove Theorem 1 in this section. + +Theorem 1 During the backward pass of a convolutional layer $l$ , $\mathrm { G E B } _ { l } ^ { \mathsf { L } }$ and $\mathrm { G E B } _ { l } ^ { \mathsf { H } }$ satisfy + +$$ +\mathbf { G E B } _ { l } ^ { \mathbf { L } } - \mathbf { G E B } _ { l } ^ { \mathsf { H } } = \left( \alpha _ { l , l } | | \mathbf { H } _ { l - 1 } ^ { \mathsf { T } } | | _ { F } + \beta _ { l } \right) ( \lambda _ { l } ^ { \mathsf { H } } - \lambda _ { l } ^ { \mathsf { L } } ) + | | \mathbf { H } _ { l - 1 } ^ { \mathsf { T } } | | _ { F } \sum _ { i = l + 1 } ^ { L } \alpha _ { l , i } ( \lambda _ { i } ^ { \mathsf { H } } - \lambda _ { i } ^ { \mathsf { L } } ) \prod _ { j = l } ^ { i - 1 } \gamma _ { j } , +$$ + +where $\alpha _ { l , i } , \beta _ { l } , \gamma _ { l } \ > \ 0$ for $1 \leq l , i \leq L$ are given by Equation (24); $\lambda _ { l } ^ { \mathbf { L } } = | | \widetilde { \mathbf { H } } _ { l } \odot \mathbf { M } | | _ { F }$ ; $\lambda _ { l } ^ { \mathsf { H } } =$ +$| | \widetilde { \mathbf { H } } _ { l } \odot ( \mathbf { 1 } - \mathbf { M } ) | | _ { F } ; \widetilde { \mathbf { H } } _ { l } = \mathrm { D C T } ( \mathbf { H } _ { l } )$ ; and M denotes the loss-pass mask given by Equation (4). + +Proof. For simplicity of derivation, we study the case with a single input channel and output channel number. In this case, $\mathbf { H } _ { l }$ and $\mathbf { W } _ { l }$ are 2-D matrix for each layer $l$ , where $1 \le l \le L$ . The backward propagation of a convolutional layer is given by + +$$ +\begin{array} { r l } & { \hat { \nabla } _ { \mathbf Z _ { l } } = \hat { \nabla } _ { \mathbf Z _ { l + 1 } } * \mathbf W _ { l + 1 } ^ { \mathrm { r o t } } \odot \sigma ^ { \prime } ( \hat { \mathbf Z } _ { l } ) , } \\ & { \hat { \nabla } _ { \mathbf W _ { l } } = \hat { \nabla } _ { \mathbf Z _ { l } } * \hat { \mathbf H } _ { l - 1 } ^ { \mathrm { T } } , } \end{array} +$$ + +where $^ *$ denotes a convolutional operation; $\hat { \mathbf { Z } } _ { l } = \mathbf { W } _ { l } * \hat { \mathbf { H } } _ { l - 1 } + b _ { l } ; b _ { l }$ denotes the bias of layer $l$ ; and $\mathbf { W } _ { l } ^ { \mathsf { r o t } }$ denotes to rotate $\mathbf { W } _ { l }$ by $1 8 0 ^ { \circ }$ . The case of multiple input and output channels can be proved in an analogous way, which is omitted in this work. + +According to Equation (16), we have the gradient of $\mathbf { Z } _ { l }$ given by + +$$ +\begin{array} { r l } & { \hat { \nabla } _ { \mathbf { Z } _ { l } } - \nabla _ { \mathbf { Z } _ { l } } } \\ & { = \hat { \nabla } _ { \mathbf { Z } _ { l + 1 } } * \mathbf { W } _ { l + 1 } ^ { \mathrm { r o t } } \odot \boldsymbol { \sigma } ^ { \prime } ( \hat { \mathbf { Z } } _ { l } ) - \nabla _ { \mathbf { Z } _ { l + 1 } } * \mathbf { W } _ { l + 1 } ^ { \mathrm { r o t } } \odot \boldsymbol { \sigma } ^ { \prime } ( \mathbf { Z } _ { l } ) , } \\ & { = \hat { \nabla } _ { \mathbf { Z } _ { l + \frac { 1 } { 7 } } } \mathbf { W } _ { l + 1 } ^ { \mathrm { r o t } } \odot \boldsymbol { \sigma } ^ { \prime } ( \hat { \mathbf { Z } } _ { l } ) - \hat { \nabla } _ { \mathbf { Z } _ { l + \frac { 1 } { 7 } } } \mathbf { W } _ { l + 1 } ^ { \mathrm { r o t } } \odot \boldsymbol { \sigma } ^ { \prime } ( \mathbf { Z } _ { l } ) + \hat { \nabla } _ { \mathbf { Z } _ { l + \frac { 1 } { 7 } } } \mathbf { W } _ { l + 1 } ^ { \mathrm { r o t } } \odot \boldsymbol { \sigma } ^ { \prime } ( \mathbf { Z } _ { l } ) - \nabla _ { \mathbf { Z } _ { l + 1 } } * \mathbf { W } _ { l + 1 } ^ { \mathrm { r o t } } \odot \boldsymbol { \sigma } ^ { \prime } ( \mathbf { Z } _ { l } ) } \\ & { = \hat { \nabla } _ { \mathbf { Z } _ { l + 1 } } * \mathbf { W } _ { l + 1 } ^ { \mathrm { r o t } } \odot \left[ \boldsymbol { \sigma } ^ { \prime } ( \hat { \mathbf { Z } } _ { l } ) - \boldsymbol { \sigma } ^ { \prime } ( \mathbf { Z } _ { l } ) \right] + ( \hat { \nabla } _ { \mathbf { Z } _ { l + 1 } } - \nabla _ { \mathbf { Z } _ { l + 1 } } ) * \mathbf { W } _ { l + 1 } ^ { \mathrm { r o t } } \odot \boldsymbol { \sigma } ^ { \prime } ( \mathbf { Z } _ { l } ) . } \end{array} +$$ + +For the activation functions $\mathrm { R e L u } ( \cdot )$ , LeakyReLu $( \cdot )$ , Sigmoid $( \cdot )$ , $\operatorname { T a n h } ( { \cdot } )$ and SoftPlus(·), the gradient $\sigma ^ { \prime } ( \cdot )$ satisfies $| \sigma ^ { \prime \prime } ( \cdot ) | \leq 1$ in the differentable domains. Note that we have $| | \mathbf { W } _ { l ^ { * } } \mathbf { H } _ { l - 1 } | | _ { F } \leq$ $( K _ { l } + N _ { l } - 1 ) | | \mathbf { W } _ { l } | | _ { F } | | \mathbf { H } _ { l - 1 } | | _ { F }$ according to Corollary 1. $| | \boldsymbol { \sigma } ^ { \prime } ( \hat { \mathbf { Z } } _ { l } ) - \boldsymbol { \sigma } ^ { \prime } ( { \mathbf { Z } } _ { l } ) | | _ { F }$ satisfies + +$$ +| | \sigma ^ { \prime } ( \hat { \mathbf { Z } } _ { l } ) - \sigma ^ { \prime } ( \mathbf { Z } _ { l } ) | | _ { F } \leq | | \hat { \mathbf { Z } } _ { l } - \mathbf { Z } _ { l } | | _ { F } \leq \left( K _ { l } + N _ { l } - 1 \right) | | \hat { \mathbf { H } } _ { l - 1 } - \mathbf { H } _ { l - 1 } | | _ { F } | | \mathbf { W } _ { l } ^ { \prime } | | _ { F } , +$$ + +where $K _ { l }$ and $N _ { l }$ denote the size of convolutional kernel $\mathbf { W } _ { l }$ and activation map $\mathbf { H } _ { l }$ in layer $l$ , respectively. After taking Equation (18) into Equation (17), we have + +$$ +\begin{array} { r l } & { \| \hat { \nabla } _ { \mathbf { Z } _ { l } } - \nabla _ { \mathbf { Z } _ { l } } \| _ { F } \leq ( K _ { l } + N _ { l } - 1 ) \| \hat { \nabla } _ { \mathbf { Z } _ { l + 1 } } \vert \vert \hat { \mathbf { V } } \mathbf { Z } _ { l + 1 } \vert \vert _ { F } \vert \vert \boldsymbol { \sigma } ^ { \prime } ( \hat { \mathbf { Z } } _ { l } ) - \boldsymbol { \sigma } ^ { \prime } ( \mathbf { Z } _ { l } ) \vert \vert _ { F } } \\ & \phantom { \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad + ( K _ { l } + N _ { l } - 1 ) \vert \vert \hat { \nabla } _ { \mathbf { Z } _ { l + 1 } } - \nabla _ { \mathbf { Z } _ { l + 1 } } \vert \vert _ { F } \vert \vert \mathbf { W } _ { l + 1 } ^ { \mathrm { r o t } } \vert \vert _ { F } \vert \vert \boldsymbol { \sigma } ^ { \prime } ( \mathbf { Z } _ { l } ) \vert \vert _ { F } , } \\ & \phantom { \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad } \\ & \phantom { \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad } \\ & \phantom { \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad + ( K _ { l } + N _ { l } - 1 ) \vert \vert \hat { \mathbf { V } } \mathbf { Z } _ { l + 1 } \vert \vert _ { F } \vert \vert \mathbf { W } _ { l + 1 } ^ { \mathrm { r o t } } \vert \vert _ { F } \vert \vert \mathbf { H } _ { l - 1 } - \mathbf { H } _ { l - 1 } \vert \vert _ { F } \vert \vert \mathbf { W } _ { l } ^ { \prime } \vert \vert _ { F } } \\ & \phantom \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \end{array} +$$ + +where $\eta _ { l }$ and $\gamma _ { l }$ are given by + +$$ +\begin{array} { r l } & { \eta _ { l } = ( K _ { l } + N _ { l } - 1 ) ^ { 2 } | | \hat { \nabla } _ { \mathbf { Z } _ { l + 1 } } | | _ { F } | | \mathbf { W } _ { l + 1 } | | _ { F } | | \mathbf { W } _ { l } ^ { \prime } | | _ { F } ; } \\ & { \gamma _ { l } = ( K _ { l } + N _ { l } - 1 ) | | \mathbf { W } _ { l + 1 } | | _ { F } | | \sigma ^ { \prime } ( \mathbf { Z } _ { l } ) | | _ { F } ; } \end{array} +$$ + +the value $\eta _ { l }$ and $\gamma _ { l }$ depend on the model weight before backward propagation, which is constant with respect to the gradient. Iterate Equation (19) until $l = L$ where $| | \hat { \nabla } _ { \mathbf { Z } _ { L } } - \nabla _ { \mathbf { Z } _ { L } } | | _ { F } \leq \eta _ { L } | | \hat { \mathbf { H } } _ { L - 1 } - $ $\mathbf { H } _ { L - 1 } | | _ { F }$ . In this way, we have + +$$ +\vert \vert \hat { \nabla } _ { \mathbf { Z } _ { l } } - \nabla _ { \mathbf { Z } _ { l } } \vert \vert _ { F } \leq \eta _ { l } \vert \vert \hat { \mathbf { H } } _ { l - 1 } - \mathbf { H } _ { l - 1 } \vert \vert _ { F } + \sum _ { i = l + 1 } ^ { L } \eta _ { i } \vert \vert \hat { \mathbf { H } } _ { i - 1 } - \mathbf { H } _ { i - 1 } \vert \vert _ { F } \prod _ { j = l } ^ { i - 1 } \gamma _ { j } . +$$ + +According to Equation (16), we have the gradient of $\mathbf { W } _ { l }$ given by + +$$ +\begin{array} { r l } & { \hat { \nabla } _ { \mathbf { W } _ { l } } - \nabla _ { \mathbf { W } _ { l } } = \hat { \nabla } _ { \mathbf { Z } _ { l } } * \hat { \mathbf { H } } _ { l - 1 } ^ { \mathsf { T } } - \nabla _ { \mathbf { Z } _ { l } } * \mathbf { H } _ { l - 1 } ^ { \mathsf { T } } , } \\ & { \quad \quad \quad \quad = \hat { \nabla } _ { \mathbf { Z } _ { l } } * \hat { \mathbf { H } } _ { l - 1 } ^ { \mathsf { T } } - \hat { \nabla } _ { \mathbf { Z } _ { l } } * \mathbf { H } _ { l - 1 } ^ { \mathsf { T } } + \hat { \nabla } _ { \mathbf { Z } _ { l } } * \mathbf { H } _ { l - 1 } ^ { \mathsf { T } } - \nabla _ { \mathbf { Z } _ { l } } * \mathbf { H } _ { l - 1 } ^ { \mathsf { T } } , } \\ & { \quad \quad \quad \quad = \hat { \nabla } _ { \mathbf { Z } _ { l } } * ( \hat { \mathbf { H } } _ { l - 1 } ^ { \mathsf { T } } - \mathbf { H } _ { l - 1 } ^ { \mathsf { T } } ) + ( \hat { \nabla } _ { \mathbf { Z } _ { l } } - \nabla _ { \mathbf { Z } _ { l } } ) * \mathbf { H } _ { l - 1 } ^ { \mathsf { T } } . } \end{array} +$$ + +Taking Equation (21) into Equation (22), we have + +$$ +\begin{array} { r l } & { \| \hat { \nabla } _ { \mathbf { W } _ { l } } - \nabla _ { \mathbf { W } _ { l } } \| _ { F } } \\ & { \leq ( K _ { l } + N _ { l } - 1 ) \| \hat { \nabla } _ { \mathbf { Z } _ { \mathit { t } } } | | \hat { \mathbf { H } } _ { l - 1 } ^ { \mathsf { T } } - \mathbf { H } _ { l - 1 } ^ { \mathsf { T } } | | _ { F } + ( K _ { l } + N _ { l } - 1 ) | | \hat { \nabla } _ { \mathbf { Z } _ { \mathit { t } } } - \nabla _ { \mathbf { Z } _ { \mathit { t } } } | | \mathcal { F } | | \mathbf { H } _ { l - 1 } ^ { \mathsf { T } } | | _ { F } , } \\ & { \leq ( K _ { l } + N _ { l } - 1 ) \bigg ( \| \hat { \nabla } _ { \mathbf { Z } _ { \mathit { t } } } | | \mathcal { F } | \hat { \mathbf { H } } _ { l - 1 } ^ { \mathsf { T } } - \mathbf { H } _ { l - 1 } ^ { \mathsf { T } } | | _ { F } + | | \mathbf { H } _ { l - 1 } ^ { \mathsf { T } } | | _ { F } \Big | | \hat { \mathbf { H } } _ { l - 1 } - \mathbf { H } _ { l - 1 } | | _ { F } + \underset { i = l + 1 } { \sum } _ { \eta _ { i } } | | \hat { \mathbf { H } } _ { i - 1 } - \mathbf { H } _ { i - 1 } | | _ { F } \prod _ { j = l } ^ { \mathsf { T } } \bigg ) } \\ & { \qquad \quad = ( K _ { l } + N _ { l } - 1 ) \bigg [ ( \| \hat { \nabla } _ { \mathbf { Z } _ { \mathit { t } } } | | _ { F } + \eta _ { l } | | \mathbf { H } _ { l - 1 } ^ { \mathsf { T } } | | _ { F } ) | | \hat { \mathbf { H } } _ { l - 1 } ^ { \mathsf { T } } - \mathbf { H } _ { l - 1 } ^ { \mathsf { T } } | | _ { F } + | | \mathbf { H } _ { l - 1 } ^ { \mathsf { T } } | | _ { F } \displaystyle \sum _ { i = l + 1 } ^ { L } | | \hat { \mathbf { H } } _ { i - 1 } - \mathbf { H } _ { i - 1 } | | _ { F } \displaystyle \prod _ { j = l } ^ { i - 1 } \gamma _ { j } \bigg ] , } \\ & \qquad = \big ( \beta _ { l } + \alpha _ { l } , \boldsymbol { l } | | \mathbf \end{array} +$$ + +where + +$$ +\begin{array} { r l } & { \alpha _ { l , i } = ( K _ { l } + N _ { l } - 1 ) ( K _ { i } + N _ { i } - 1 ) ^ { 2 } | | \hat { \nabla } _ { \mathbf { Z } _ { i + 1 } } | | _ { F } | | \mathbf { W } _ { i + 1 } | | _ { F } | | \mathbf { W } _ { i } ^ { \prime } | | _ { F } ; } \\ & { \quad \beta _ { l } = ( K _ { l } + N _ { l } - 1 ) | | \hat { \nabla } _ { \mathbf { Z } _ { l } } | | _ { F } ; } \\ & { \quad \gamma _ { l } = ( K _ { l } + N _ { l } - 1 ) | | \mathbf { W } _ { l + 1 } | | _ { F } | | \sigma ^ { \prime } ( \mathbf { Z } _ { l } ) | | _ { F } ; } \end{array} +$$ + +$K _ { l }$ and $N _ { l }$ denote the size of convolutional kernel $\mathbf { W } _ { l }$ and activation map $\mathbf { H } _ { l }$ in layer $l$ , respectively. + +During the LFC-ACT and HFC-ACT trainings, the activation map of a convolutional layer satisfies + +$$ +\begin{array} { r l } & { \lvert | \mathbf { H } _ { l } - \mathbf { H } _ { l } ^ { \mathtt { L } } \rvert | _ { F } = \lvert | \widetilde { \mathbf { H } } _ { l } - \widetilde { \mathbf { H } } _ { l } ^ { \mathtt { L } } \rvert | _ { F } = \lvert | \widetilde { \mathbf { H } } _ { l } \odot ( \mathbf { 1 } - \mathbf { M } ) \rvert | _ { F } \triangleq \lambda _ { l } ^ { \mathtt { H } } , } \\ & { \lvert | \mathbf { H } _ { l } - \mathbf { H } _ { l } ^ { \mathtt { H } } \rvert | _ { F } = \lvert | \widetilde { \mathbf { H } } _ { l } - \widetilde { \mathbf { H } } _ { l } ^ { \mathtt { H } } \rvert | _ { F } = \lvert | \widetilde { \mathbf { H } } _ { l } \odot \mathbf { M } \rvert | _ { F } \triangleq \lambda _ { l } ^ { \mathtt { L } } . } \end{array} +$$ + +Taking Equations (25) and (26) into (23), we have $\mathrm { G E B } _ { l } ^ { \mathsf { L } }$ and $\mathrm { G E B } _ { l } ^ { \mathsf { H } }$ of a convolutional layer by + +$$ +\begin{array} { r l } & { \displaystyle | | \hat { \nabla } _ { \mathbf { W } _ { l } } - \nabla _ { \mathbf { W } _ { l } } ^ { \ L } | | _ { F } \leq \left( \alpha _ { l , l } | | \mathbf { H } _ { l - 1 } ^ { \top } | | _ { F } + \beta _ { l } \right) \lambda _ { l } ^ { \sf H } + | | \mathbf { H } _ { l - 1 } ^ { \top } | | _ { F } \sum _ { i = l + 1 } ^ { L } \alpha _ { l , i } \lambda _ { i } ^ { \sf H } \prod _ { j = l } ^ { i - 1 } \gamma _ { j } \triangleq \operatorname { G E B } _ { l } ^ { \lfloor } , } \\ & { \displaystyle | | \hat { \nabla } _ { \mathbf { W } _ { l } } - \nabla _ { \mathbf { W } _ { l } } ^ { \sf H } | | _ { F } \leq \left( \alpha _ { l , l } | | \mathbf { H } _ { l - 1 } ^ { \top } | | _ { F } + \beta _ { l } \right) \lambda _ { l } ^ { \lfloor } + | | \mathbf { H } _ { l - 1 } ^ { \top } | | _ { F } \sum _ { i = l + 1 } ^ { L } \alpha _ { l , i } \lambda _ { i } ^ { \lfloor } \prod _ { j = l } ^ { i } \gamma _ { j } \triangleq \operatorname { G E B } _ { l } ^ { \sf H } . } \end{array} +$$ + +Given the expression of $\mathrm { G E B } _ { l } ^ { \mathsf { L } }$ and $\mathrm { G E B } _ { l } ^ { \mathsf { H } }$ by Equations (27) and (28), respectively, we have the GEB for a convolutional layer given by + +$$ +\mathbf { G E B } _ { l } ^ { \mathbf { L } } - \mathbf { G E B } _ { l } ^ { \mathsf { H } } = \left( \alpha _ { l , l } | | \mathbf { H } _ { l - 1 } ^ { \mathsf { T } } | | _ { F } + \beta _ { l } \right) ( \lambda _ { l } ^ { \mathsf { H } } - \lambda _ { l } ^ { \mathsf { L } } ) + | | \mathbf { H } _ { l - 1 } ^ { \mathsf { T } } | | _ { F } \sum _ { i = l + 1 } ^ { L } \alpha _ { l , i } ( \lambda _ { i } ^ { \mathsf { H } } - \lambda _ { i } ^ { \mathsf { L } } ) \prod _ { j = l } ^ { i - 1 } \gamma _ { j } . +$$ + +Corollary 1. For a $K \times K$ convolutional kernel and a $N \times N$ square matrix $\mathbf { H }$ , we have the + +$$ +| | \mathbf { W } * \mathbf { H } | | _ { F } \leq ( K + N - 1 ) | | \mathbf { W } | | _ { F } | | \mathbf { H } | | _ { F } +$$ + +Proof. According to the relations between convolutional operation and Discrete Fourier Transformation (Sundararajan, 2001), $\mathbf { W } * \mathbf { H }$ satisfies + +$$ +\mathrm { F F T } ( \mathbf { W } * \mathbf { H } ) = \mathrm { F F T } ( \mathrm { Z P } ( \mathbf { W } ) ) \odot \mathrm { F F T } ( \mathrm { Z P } ( \mathbf { H } ) ) , +$$ + +where $\mathrm { F F T } ( \cdot )$ denotes the discrete Fourier transformation; $\mathrm { Z P ( W ) }$ denotes zero-padding $\mathbf { W }$ into a $( K + N - 1 ) \times ( K + N - 1 )$ matrix. According to the Parseval’s theorem (Diniz et al., 2010), $\mathrm { F F T } ( \mathrm { Z P } ( \mathbf { W } ) )$ and $\mathrm { F F T } ( \mathrm { Z P } ( \mathbf { H } ) )$ and FF $\mathrm { T } ( \mathbf { W } * \mathbf { H } )$ satisfy + +$$ +\begin{array} { r l } & { | | \mathrm { F F T } ( \mathrm { Z P } ( \mathbf { W } ) ) | | _ { F } = ( K + N - 1 ) | | \mathbf { W } | | _ { F } , } \\ & { | | \mathrm { F F T } ( \mathrm { Z P } ( \mathbf { H } ) ) | | _ { F } = ( K + N - 1 ) | | \mathbf { H } | | _ { F } , } \\ & { | | \mathrm { F F T } ( \mathbf { W } * \mathbf { H } ) | | _ { F } = ( K + N - 1 ) | | \mathbf { W } * \mathbf { H } | | _ { F } . } \end{array} +$$ + +Taking $| | \mathbf { A } _ { 1 } \odot \mathbf { A } _ { 2 } | | _ { F } \leq | | \mathbf { A } _ { 1 } | | _ { F } | | \mathbf { A } _ { 2 } | | _ { F }$ into Equation (31), we have + +$$ +\mathrm { F F T } ( \mathrm { Z P } ( \mathbf { W } ) ) \odot \mathrm { F F T } ( \mathrm { Z P } ( \mathbf { H } ) ) \le | | \mathrm { F F T } ( \mathbf { W } ) | | _ { F } | | \mathrm { F F T } ( \mathbf { H } ) | | _ { F } +$$ + +Taking Equation (31) into Equation (32), we have + +$$ +\begin{array} { r l } { ( K + N - 1 ) | | \mathbf { W } * \mathbf { H } | | _ { F } = | | \mathrm { F F T } ( \mathbf { W } ) \odot \mathrm { F F T } ( \mathbf { H } ) | | _ { F } } & { } \\ { \leq | | \mathrm { F F T } ( \mathbf { W } ) | | _ { F } | | \mathrm { F F T } ( \mathbf { H } ) | | _ { F } } & { } \\ { = ( K + N - 1 ) | | \mathbf { W } | | _ { F } ( K + N - 1 ) | | \mathbf { H } | | _ { F } } \end{array} +$$ + +# C GRADIENT ERROR BOUND (GEB) OF A LINEAR LAYER + +We give the Gradient Error upper Bound (GEB) of a linear layer and proof in this section. + +Theorem 1B. During the backward pass of a linear layer $l$ , $\mathrm { G E B } _ { l } ^ { \mathsf { L } }$ and $\mathrm { G E B } _ { l } ^ { \mathsf { H } }$ satisfy + +$$ +\mathrm { G E B } _ { l } ^ { \mathrm { L } } - \mathrm { G E B } _ { l } ^ { \mathsf { H } } = \left( \alpha _ { l } \lvert \lvert { \bf H } _ { l - 1 } ^ { \mathsf { T } } \rvert \rvert _ { F } + \beta _ { l } \right) ( \lambda _ { l } ^ { \mathsf { H } } - \lambda _ { l } ^ { \mathrm { L } } ) + \lvert \lvert { \bf H } _ { l - 1 } ^ { \mathsf { T } } \rvert \rvert _ { F } \sum _ { i = l + 1 } ^ { L } \alpha _ { i } ( \lambda _ { i } ^ { \mathsf { H } } - \lambda _ { i } ^ { \mathrm { L } } ) \prod _ { j = l } ^ { i - 1 } \gamma _ { j } , +$$ + +where $\alpha _ { l } , \beta _ { l } , \gamma _ { l } > 0$ for $1 \leq l \leq L$ are given by Equation (42); $\lambda _ { l } ^ { \mathbf { L } } = | | \widetilde { \mathbf { H } } _ { l } \odot \mathbf { M } | | _ { F }$ ; $\lambda _ { l } ^ { \mathsf { H } } = | | \widetilde { \mathbf { H } } _ { l } \odot ( \mathbf { 1 } -$ +$\mathbf { M } ) | | _ { F } ; \widetilde { \mathbf { H } } _ { l } = \mathrm { D C T } ( \mathbf { H } _ { l } ) ,$ ; and M denotes the 1-D loss-pass mask. + +Proof. For simplicity of derivation, we consider the case MiniBatch ${ } = 1$ . In this case, $\mathbf { H } _ { l }$ is a vector; and $\mathbf { W } _ { l }$ is a 2-D matrix, for $1 \leq l \leq L$ . The backward propagation of a linear layer is given by + +$$ +\begin{array} { r l } & { \hat { \nabla } _ { \mathbf { Z } _ { l } } = ( \mathbf { W } _ { l + 1 } \hat { \nabla } _ { \mathbf { Z } _ { l + 1 } } ) \odot \sigma ^ { \prime } ( \hat { \mathbf { Z } } _ { l } ) , } \\ & { \hat { \nabla } _ { \mathbf { W } _ { l } } = \hat { \nabla } _ { \mathbf { Z } _ { l } } \hat { \mathbf { H } } _ { l - 1 } ^ { \top } , } \end{array} +$$ + +where $\hat { \mathbf { Z } } _ { l } = \mathbf { W } _ { l } ^ { \mathsf { T } } \hat { \mathbf { H } } _ { l - 1 } + b _ { l }$ ; and $b _ { l }$ denotes the bias of layer $l$ . The case of $\mathrm { M i n i B a t c h } \geq 2$ can be proved in an analogous way, which is omitted in this work. + +According to Equation (34), we have the gradient of $\mathbf { Z } _ { l }$ given by + +$$ +\begin{array} { r l } & { \nabla \mathbf { z } _ { l } - \mathbf { v } \mathbf { z } _ { l } } \\ & { = \mathbf { W } _ { l + 1 } \hat { \nabla } \mathbf { z } _ { l + 1 } \odot \boldsymbol \sigma ^ { \prime } ( \hat { \mathbf { Z } } _ { l } ) - \mathbf { W } _ { l + 1 } \nabla \mathbf { z } _ { l + 1 } \odot \boldsymbol \sigma ^ { \prime } ( \mathbf { Z } _ { l } ) , } \\ & { = \mathbf { W } _ { l + 1 } \hat { \nabla } \mathbf { z } _ { l + 1 } \odot \boldsymbol \sigma ^ { \prime } ( \hat { \mathbf { Z } } _ { l } ) - \mathbf { W } _ { l + 1 } \hat { \nabla } \mathbf { z } _ { l + 1 } \odot \boldsymbol \sigma ^ { \prime } ( \mathbf { Z } _ { l } ) + \mathbf { W } _ { l + 1 } \hat { \nabla } \mathbf { z } _ { l + 1 } \odot \boldsymbol \sigma ^ { \prime } ( \mathbf { Z } _ { l } ) - \mathbf { W } _ { l + 1 } \nabla \mathbf { z } _ { l + 1 } \odot \boldsymbol \sigma ^ { \prime } ( \mathbf { Z } _ { l } ) , } \\ & { = \mathbf { W } _ { l + 1 } \hat { \nabla } \mathbf { z } _ { l + 1 } \odot \left[ \boldsymbol \sigma ^ { \prime } ( \hat { \mathbf { Z } } _ { l } ) - \boldsymbol \sigma ^ { \prime } ( \mathbf { Z } _ { l } ) \right] + \left( \hat { \nabla } _ { \mathbf { Z } _ { l + 1 } } - \mathbf { W } _ { l + 1 } \nabla \mathbf { z } _ { l + 1 } \right) \odot \boldsymbol \sigma ^ { \prime } ( \mathbf { Z } _ { l } ) . } \end{array} +$$ + +For activation functions $\mathrm { R e L u } ( \cdot )$ , LeakyReLu(·), Sigmoid $( \cdot )$ , $\operatorname { T a n h } ( { \cdot } )$ and $\operatorname { S o f t P l u s } ( \cdot )$ , the gradient $\sigma ^ { \prime } ( \cdot )$ satisfies $| \sigma ^ { \prime \prime } ( \cdot ) | \leq 1$ in each differentiable domain. Combined with Cauchy–Schwarz inequality $| | \mathbf { A } _ { 1 } \mathbf { A } _ { 2 } | | _ { F } \leq | | \mathbf { A } _ { 1 } | | _ { F } | | \mathbf { A } _ { 2 } | | _ { F }$ (Horn & Johnson, 2012), we have + +$$ +| | \sigma ^ { \prime } ( \hat { \mathbf { Z } } _ { l } ) - \sigma ^ { \prime } ( \mathbf { Z } _ { l } ) | | _ { F } \leq | | \hat { \mathbf { Z } } _ { l } - \mathbf { Z } _ { l } | | _ { F } \leq | | \mathbf { W } _ { l } | | _ { F } | | \hat { \mathbf { H } } _ { l - 1 } - \mathbf { H } _ { l - 1 } | | _ { F } . +$$ + +According to inequality $| | \mathbf { A } _ { 1 } \odot \mathbf { A } _ { 2 } | | _ { F } \le | | \mathbf { A } _ { 1 } | | _ { F } | | \mathbf { A } _ { 2 } | | _ { F }$ (Horn & Johnson, 2012), we have the upper bound of $\| \hat { \nabla } _ { \mathbf { Z } _ { l } } - \nabla _ { \mathbf { Z } _ { l } } \| _ { F }$ given by + +$$ +\begin{array} { r l r } { { \| \hat { \nabla } \mathbf { \tilde { z } } _ { t } - \nabla \mathbf { z } _ { t } \| _ { F } } } \\ & { \leq \| \mathbf { W } _ { l + 1 } \| _ { F } \| | \hat { \nabla } \mathbf { z } _ { t + 1 } \| _ { F } \| | \sigma ^ { \prime } ( \hat { \mathbf { z } } _ { l } ) - \sigma ^ { \prime } ( \mathbf { \mathbf { z } } _ { l } ) \| _ { F } + \| \mathbf { W } _ { l + 1 } \| _ { F } \| | \hat { \nabla } \mathbf { z } _ { t + 1 } - \nabla \mathbf { z } _ { t + 1 } \| _ { F } \| | \sigma ^ { \prime } ( \mathbf { Z } _ { l } ) \| _ { F } , } \\ & { = \| \mathbf { W } _ { l + 1 } \| _ { F } \| | \hat { \mathbf { Y } } \mathbf { z } _ { t + 1 } \| _ { F } \| | \hat { \mathbf { H } } _ { l - 1 } - \mathbf { H } _ { l - 1 } \| _ { F } \| | \mathbf { W } _ { l } ^ { \prime } \| _ { F } + \| \mathbf { W } _ { l + 1 } \| _ { F } \| | \hat { \mathbf { Y } } \mathbf { z } _ { t + 1 } - \nabla \mathbf { z } _ { t + 1 } \| _ { F } \| | \sigma ^ { \prime } ( \mathbf { Z } _ { l } ) \| _ { F } , } \\ & { = \alpha _ { l } \| \hat { \mathbf { H } } _ { l - 1 } - \mathbf { H } _ { l - 1 } \| _ { F } + \gamma _ { l } \| \hat { \mathbf { Y } } \mathbf { z } _ { l + 1 } - \nabla \mathbf { z } _ { l + 1 } \| _ { F } , } & { ( 3 ) ^ { \prime } } \end{array} +$$ + +where $\alpha _ { l }$ and $\gamma _ { l }$ are given by + +$$ +\begin{array} { r l } & { \alpha _ { l } = | | \mathbf { W } _ { l + 1 } | | _ { F } | | \hat { \nabla } _ { \mathbf { Z } _ { l + 1 } } | | _ { F } | | \mathbf { W } _ { l } ^ { \prime } | | _ { F } ; } \\ & { \gamma _ { l } = | | \mathbf { W } _ { l + 1 } | | _ { F } | | \boldsymbol { \sigma } ^ { \prime } ( \mathbf { Z } _ { l } ) | | _ { F } ; } \end{array} +$$ + +the value $\alpha _ { l }$ and $\gamma _ { l }$ depend on the model weight before backward propagation, which are constant with respect to the gradient. Iterate Equation (37) until $l = L$ where $| | \hat { \nabla } _ { \mathbf { Z } _ { L } } - \nabla _ { \mathbf { Z } _ { L } } | | _ { F } \leq \alpha _ { l } | | \hat { \mathbf { H } } _ { L - 1 } -$ $\left. \mathbf { H } _ { L - 1 } \right| \overset { - } { | F | }$ . In such a manner, we have + +$$ +\| \hat { \nabla } _ { \mathbf { Z } _ { l } } - \nabla _ { \mathbf { Z } _ { l } } \| _ { F } \leq \alpha _ { l } \| \hat { \mathbf { H } } _ { l - 1 } - \mathbf { H } _ { l - 1 } \| _ { F } + \sum _ { i = l + 1 } ^ { L } \alpha _ { i } \| \hat { \mathbf { H } } _ { i - 1 } - \mathbf { H } _ { i - 1 } \| _ { F } \prod _ { j = l } ^ { i - 1 } \gamma _ { j } . +$$ + +According to Equation (34), we have the gradient of $\mathbf { W } _ { l }$ given by + +$$ +\begin{array} { r l } & { \hat { \nabla } _ { \mathbf { W } _ { l } } - \nabla _ { \mathbf { W } _ { l } } = \hat { \nabla } _ { \mathbf { Z } _ { l } } \hat { \mathbf { H } } _ { l - 1 } ^ { \top } - \nabla _ { \mathbf { Z } _ { l } } \mathbf { H } _ { l - 1 } ^ { \top } , } \\ & { \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad } \\ & { \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad } \\ & { \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad } \\ & { \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad } \\ & { \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad } \\ & { \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad } \\ & { \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad } \\ & { \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad } \\ & { \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad } \\ & { \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad } \\ & { \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad } \\ & \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \end{array} +$$ + +Taking Equation (39) into Equation (40), we have + +$$ +\begin{array} { r l } { { \| \hat { \nabla } _ { \mathbf { W } _ { l } } - \nabla _ { \mathbf { W } _ { l } } \| _ { F } } } \\ & { \le \| \hat { \nabla } _ { \mathbf { Z } _ { l } } \| _ { F } \| \hat { \mathbf { H } } _ { l - 1 } ^ { \top } - \mathbf { H } _ { l - 1 } ^ { \top } \| _ { F } + \| \hat { \nabla } _ { \mathbf { Z } _ { l } } - \nabla _ { \mathbf { Z } _ { l } } \| _ { F } \| \mathbf { H } _ { l - 1 } ^ { \top } \| _ { F } , } \\ & { \le \| \hat { \nabla } _ { \mathbf { Z } _ { l } } \| _ { F } \| \hat { \mathbf { H } } _ { l - 1 } ^ { \top } - \mathbf { H } _ { l - 1 } ^ { \top } \| _ { F } + \| \mathbf { H } _ { l - 1 } ^ { \top } \| _ { F } \Big [ \alpha _ { l } \| \hat { \mathbf { H } } _ { l - 1 } - \mathbf { H } _ { l - 1 } \| _ { F } + \sum _ { i = l + 1 } ^ { L } \alpha _ { i } \| \hat { \mathbf { H } } _ { i - 1 } - \mathbf { H } _ { i - 1 } \| _ { F } \prod _ { j = l } ^ { i - 1 } \gamma _ { j } \Big ] , } \\ & { = \Big ( \beta _ { l } + \alpha _ { l } \| \mathbf { H } _ { l - 1 } ^ { \top } \| _ { F } \Big ) \| \hat { \mathbf { H } } _ { l - 1 } ^ { \top } - \mathbf { H } _ { l - 1 } ^ { \top } \| _ { F } + \big \| \mathbf { H } _ { l - 1 } ^ { \top } \| _ { F } \sum _ { i = l + 1 } ^ { L } \alpha _ { i } \big \| \hat { \mathbf { H } } _ { i - 1 } ^ { \top } - \mathbf { H } _ { i - 1 } ^ { \top } \| _ { F } \prod _ { j = l } ^ { i - 1 } \gamma _ { j } , \qquad ( 4 1 ) } \end{array} +$$ + +where $\beta _ { l }$ is given by + +$$ +\begin{array} { r l } & { \alpha _ { l } = | | \mathbf { W } _ { l + 1 } | | _ { F } | | \hat { \nabla } _ { \mathbf { Z } _ { l + 1 } } | | _ { F } | | \mathbf { W } _ { l } ^ { \prime } | | _ { F } ; } \\ & { \beta _ { l } = | | \hat { \nabla } _ { \mathbf { Z } _ { l } } | | _ { F } ; } \\ & { \gamma _ { l } = | | \mathbf { W } _ { l + 1 } | | _ { F } | | \boldsymbol { \sigma } ^ { \prime } ( \mathbf { Z } _ { l } ) | | _ { F } . } \end{array} +$$ + +During the LFC-ACT and HFC-ACT trainings, the activation map of a linear layer satisfies + +$$ +\begin{array} { r l } & { \lvert | \mathbf { H } _ { l } - \mathbf { H } _ { l } ^ { \mathsf { L } } \rvert | _ { F } = \lvert | \widetilde { \mathbf { H } } _ { l } - \widetilde { \mathbf { H } } _ { l } ^ { \mathsf { L } } \rvert | _ { F } = \lvert | \widetilde { \mathbf { H } } _ { l } \odot ( \mathbf { 1 } - \mathbf { M } ) \rvert | _ { F } \triangleq \lambda _ { l } ^ { \mathsf { H } } , } \\ & { \lvert | \mathbf { H } _ { l } - \mathbf { H } _ { l } ^ { \mathsf { H } } \rvert | _ { F } = \lvert | \widetilde { \mathbf { H } } _ { l } - \widetilde { \mathbf { H } } _ { l } ^ { \mathsf { H } } \rvert | _ { F } = \lvert | \widetilde { \mathbf { H } } _ { l } \odot \mathbf { M } \rvert | _ { F } \triangleq \lambda _ { l } ^ { \mathsf { L } } . } \end{array} +$$ + +Taking Equations (43) and (44) into (41), we have the $\mathrm { G E B } _ { l } ^ { \mathsf { L } }$ and $\mathrm { G E B } _ { l } ^ { \mathsf { H } }$ of a linear layer given by + +$$ +\begin{array} { r l } & { \displaystyle | | \hat { \nabla } _ { \mathbf { W } _ { l } } - \nabla _ { \mathbf { W } _ { l } } ^ { \mathsf { L } } | | _ { F } \leq \Big ( \alpha _ { l } | | \mathbf { H } _ { l - 1 } ^ { \mathsf { T } } | | _ { F } + \beta _ { l } \Big ) \lambda _ { l } ^ { \mathsf { H } } + | | \mathbf { H } _ { l - 1 } ^ { \mathsf { T } } | | _ { F } \sum _ { i = l + 1 } ^ { L } \alpha _ { i } \lambda _ { i } ^ { \mathsf { H } } \prod _ { j = l } ^ { i - 1 } \gamma _ { j } \triangleq \mathrm { G E B } _ { l } ^ { \mathsf { L } } , } \\ & { \displaystyle | | \hat { \nabla } _ { \mathbf { W } _ { l } } - \nabla _ { \mathbf { W } _ { l } } ^ { \mathsf { H } } | | _ { F } \leq \Big ( | | \alpha _ { l } | | \mathbf { H } _ { l - 1 } ^ { \mathsf { T } } | | _ { F } + \beta _ { l } \Big ) \lambda _ { l } ^ { \mathsf { L } } + | | \mathbf { H } _ { l - 1 } ^ { \mathsf { T } } | | _ { F } \sum _ { i = l + 1 } ^ { L } \alpha _ { i } \lambda _ { i } ^ { \mathsf { L } } \prod _ { j = l } ^ { i - 1 } \gamma _ { j } \triangleq \mathrm { G E B } _ { l } ^ { \mathsf { H } } . } \end{array} +$$ + +Given the expression of $\mathrm { G E B } _ { l } ^ { \mathsf { L } }$ and $\mathrm { G E B } _ { l } ^ { \mathsf { H } }$ by Equations (45) and (46), we have the GEB difference for a linear layer given by + +$$ +\mathbf { G E B } _ { l } ^ { \mathbf { L } } - \mathbf { G E B } _ { l } ^ { \mathbf { H } } = \left( | | \alpha _ { l } | | \mathbf { H } _ { l - 1 } ^ { \mathsf { T } } | | _ { F } + \beta _ { l } \right) { ( \lambda _ { l } ^ { \mathsf { H } } - \lambda _ { l } ^ { \mathbf { L } } ) } + | | \mathbf { H } _ { l - 1 } ^ { \mathsf { T } } | | _ { F } \sum _ { i = l + 1 } ^ { L } \alpha _ { i } { ( \lambda _ { i } ^ { \mathsf { H } } - \lambda _ { i } ^ { \mathsf { L } } ) } \prod _ { j = l } ^ { i - 1 } \gamma _ { j } . +$$ + +# D $\lambda _ { l } ^ { L }$ VERSUS $\lambda _ { l } ^ { H }$ IN DENSENET-121 + +A further experiment is conducted to study whether $\lambda _ { l } ^ { L } > \lambda _ { l } ^ { H }$ can be guaranteed for DenseNet-121. Specifically, the values of $\lambda _ { l } ^ { L }$ and $\lambda _ { l } ^ { H }$ in the training (epoches 20, 40, and 60) of DenseNet-121 are given in Tables 3 and 4, where the low-pass $M$ mask satisfies $W / N = \ 0 . 1$ and $W / N =$ 0.2, respectively; and $\lambda _ { l } ^ { L }$ and $\lambda _ { l } ^ { H }$ are estimated based on the input activation maps of the four DenseBlocks. It is consistently observed that $\lambda _ { l } ^ { L } > \lambda _ { l } ^ { H }$ for $W / N = \ 0 . 1$ and $W / N = \ 0 . 2$ in different training epochs. This indicates our proposed Theorem 1 holds without loss of generality. + +# E PROOF OF THEOREM 2 + +We give the proof of Theorem 2 in this section. + +Theorem 2. For any real-valued function f(x) and its moving average ¯f(x) = 12B $\begin{array} { r } { \bar { f } ( x ) = \frac { 1 } { 2 B } \int _ { x } ^ { x + 2 B } f ( t ) \mathrm { d } t , } \end{array}$ , let $F ( \omega )$ and $\overline { { F } } ( \omega )$ denote the Fourier transformation (Madisetti, 1997) of $f ( x )$ and ${ \bar { f } } ( x )$ , respectively. Generally, we have $\overline { { F } } ( \omega ) = H ( \omega ) F ( \omega )$ , where $\begin{array} { r } { | H ( \omega ) | = | \frac { \sin \omega B } { \omega B } | } \end{array}$ + +Table 3: $W / N = 0 . 1$ . + +
Epoch204060Average入LH
DenseBlock-1入= 298.281入= 218.605入= 184.913Ⅱ138.069入= 142.668Ⅱ104.7551.36
DenseBlock-2入Ⅱ3.245川1.713X= 1.284=:0.689VⅡ0.687=0.3721.87
DenseBlock-3入=0.387XⅡ0.260入= 0.160Ⅱ: 0.086交Ⅱ0.084X=:0.0481.70
DenseBlock-4X= 0.062= 0.009= 0.011入= 0.001X= 0.006临= 0.0017.56
Average X/λ2.953.123.303.12
+ +Table 4: $W / N = 0 . 2$ . + +
Epoch204060Average X /λH
DenseBlock-1 362.672X=154.214X = 225.543XⅡ: 97.439入F= 173.595XⅡ73.8282.34
DenseBlock-2XⅡ3.632YⅡ1.326X= 1.440XⅡ: 0.533XⅡ:0.774又Ⅱ:0.2852.72
DenseBlock-3交Ⅱ:0.445=0.202入Ⅱ:0.179入Ⅱ:0.067入Ⅱ:0.095X= 0.0372.49
DenseBlock-4入=:0.062入H= 0.009入= 0.011海= 0.001广= 0.006入= 0.0017.56
Average λ/λH3.583.783.973.78
+ +Proof. We adopt the limit operator to reformulate ${ \bar { f } } ( x )$ into + +$$ +\bar { f } ( x ) = \frac { 1 } { 2 B } \int _ { x } ^ { x + 2 B } f ( t ) \mathrm { d } t = \frac { 1 } { 2 B } \operatorname* { l i m } _ { N \to \infty } \sum _ { n = 0 } ^ { N - 1 } \frac { 2 B } { N } f ( x + \frac { 2 B n } { N } ) = \operatorname* { l i m } _ { N \to \infty } \sum _ { n = 0 } ^ { N - 1 } \frac { 1 } { N } f ( x + \frac { 2 B n } { N } ) +$$ + +Taking Equation (47) into the Fourier Transform of ${ \bar { f } } ( x )$ , we have + +$$ +\begin{array} { l } { { \displaystyle F ^ { \prime } ( \omega ) = \int _ { - \infty } ^ { \infty } \bar { f } ( x ) e ^ { - i \omega x } \mathrm { d } x = \int _ { - \infty } ^ { \infty } \frac { 1 } { N } \operatorname* { l i m } _ { N \to \infty } \sum _ { n = 0 } ^ { N - 1 } f ( x + \frac { 2 B n } { N } ) e ^ { - i \omega x } \mathrm { d } x } } \\ { { \displaystyle \qquad = \operatorname* { l i m } _ { N \to \infty } \frac { 1 } { N } \sum _ { n = 0 } ^ { N - 1 } \int _ { - \infty } ^ { \infty } f ( x + \frac { 2 B n } { N } ) e ^ { - i \omega x } \mathrm { d } x } } \\ { { \displaystyle \qquad = \operatorname* { l i m } _ { N \to \infty } \frac { 1 } { N } \sum _ { n = 0 } ^ { N - 1 } e ^ { i \omega \frac { 2 B n } { N } } \int _ { - \infty } ^ { \infty } f ( x ) e ^ { - i \omega x } \mathrm { d } x = F ( \omega ) \operatorname* { l i m } _ { N \to \infty } \frac { 1 } { N } \sum _ { n = 0 } ^ { N - 1 } e ^ { i \omega \frac { 2 B n } { N } } } } \\ { { \displaystyle \qquad = F ( \omega ) ( 1 - e ^ { i \omega 2 B } ) \operatorname* { l i m } _ { N \to \infty } \frac { 1 } { N ( 1 - e ^ { i \omega \frac { 2 B n } { N } } ) } = F ( \omega ) \frac { 1 - \mathrm { \it ~ } e ^ { i \omega 2 B } } { - i \omega 2 B } , } } \end{array} +$$ + +where $i$ denotes the imaginary unit. + +Let H(ω) = 1−eiω2B . The magnitude of $H ( \omega )$ is given by + +$$ +\begin{array} { r l } & { | H ( \omega ) | = \frac { | 1 - \cos \omega 2 B + i \sin \omega 2 B | } { | \omega 2 B | } = \frac { \sqrt { ( 1 - \cos \omega 2 B ) ^ { 2 } + \sin ^ { 2 } \omega 2 B | } } { | \omega 2 B | } } \\ & { \quad = \frac { \sqrt { 4 \sin ^ { 4 } \omega B + 4 \sin ^ { 2 } \omega B \cos ^ { 2 } \omega B } } { | \omega 2 B | } = \frac { \sqrt { 4 \sin ^ { 2 } \omega B ( \sin ^ { 2 } \omega B + \cos ^ { 2 } \omega B ) } } { | \omega 2 B | } } \\ & { \quad = | \frac { \sin \omega B } { \omega B } | } \end{array} +$$ + +# F COMPRESSION OF 1D AND 3D ACTIVATION MAPS BY DIVISION + +We give more details about DIVISION considering 1D, 2D and 3D activation maps in this section. + +# F.1 ACTIVATION MAP COMPRESSION + +DIVISION adopts average pooling to estimate the LFC by $\mathbf { H } _ { l } ^ { \mathrm { L } } = \mathrm { A v e r a g e P o o l i n g } ( \mathbf { H } _ { l } )$ . The value of block-size and moving stride is a unified hyper-parameter $B$ , which controls the memory of $\mathbf { H } _ { l } ^ { \mathrm { L } }$ . The average pooling of 1D, 2D and 3D activation maps are considered as follows, + +$$ +\begin{array} { r l r } & { ~ } & { \mathrm { M i n i b a t c h \times C h a n n e l \times N } \times N ^ { \mathrm { \ A v e r a g e P o o i i n g \underline { { 1 } } D } } \mathrm { M i n i b a t c h \times C h a n n e l \times } \left\lfloor N / B \right\rfloor \qquad ( 5 0 ) } \\ & { ~ } & { \mathrm { M i n i b a t c h \times C h a n n e l \times N \times N } \stackrel { \mathrm { A v e r a g e P o o i n g \underline { { 2 } } D } } { \longrightarrow } \mathrm { M i n i b a t c h \times C h a n n e l \times } \left\lfloor N / B \right\rfloor \times \left\lfloor N / B \right\rfloor } \\ & { ~ } & { \mathrm { M i n i b a t c h \times C h a n n e l \times } N \times N \times N \stackrel { \mathrm { A v e r a g e P o o i n g \underline { { 2 } } D } } { \longrightarrow } \mathrm { M i n i b a t c h \times C h a n n e l \times } \left\lfloor N / B \right\rfloor \times \left\lfloor N / B \right\rfloor \times \left\lfloor N / B \right\rfloor } \end{array} +$$ + +To estimate the HFC, DIVISION calculates the residual value $\mathbf { H } _ { l } ^ { \mathsf { H } } = \mathbf { H } _ { l } - \mathrm { U p S a m p l i n g } ( \mathbf { H } _ { l } ^ { \mathsf { L } } )$ , where the UpSampling $( \cdot )$ enlarges $\mathbf { H } _ { l } ^ { \mathrm { L } }$ to the shape of $\mathbf { H } _ { l }$ via nearest interpolation. The up sampling of 1D, 2D and 3D activation maps are considered as follows, + +$$ +\begin{array} { r l r } & { } & { \mathrm { M i n i b a t c h } \times \mathrm { C h a n n e l } \times \left\lfloor N / B \right\rfloor \stackrel { \mathrm { U p S a m p l i n g 1 } D } { \longrightarrow } \mathrm { M i n i b a t c h } \times \mathrm { C h a n n e l } \times N \quad ( 5 1 ) } \\ & { } & { \mathrm { M i n i b a t c h } \times \mathrm { C h a n n e l } \times \left\lfloor N / B \right\rfloor \times \left\lfloor N / B \right\rfloor \stackrel { \mathrm { U p S a m p l i n g 2 } D } { \longrightarrow } \mathrm { M i n i b a t c h } \times \mathrm { C h a n n e l } \times N \times N } \\ & { } & { \mathrm { M i n i b a t c h } \times \mathrm { C h a n n e l } \times \left\lfloor N / B \right\rfloor \times \left\lfloor N / B \right\rfloor \stackrel { \mathrm { U p S a m p l i n g 3 } D } { \longrightarrow } \mathrm { M i n i b a t c h } \times \mathrm { C h a n n e l } \times N \times N } \end{array} +$$ + +Then, DIVISION adopts $Q$ -bit per-channel quantization for the compression, where the bit-width $Q$ controls the precision and memory cost of HFC after the compression. Let $\mathbf { V } _ { l } ^ { \mathsf { H } }$ denote a $Q$ -bit integer matrix, as the low-precision representation of $\mathbf { H } _ { l } ^ { \mathsf { H } }$ . The detailed procedure of compressing $\mathbf { H } _ { l } ^ { \mathsf { H } }$ into $\mathbf { V } _ { l } ^ { \mathsf { H } }$ is given by + +$$ +\mathbf { V } _ { l } ^ { \mathsf { H } } = \mathrm { Q u a n t } ( \mathbf { H } _ { l } ^ { \mathsf { H } } ) = \big [ \Delta _ { l } ^ { - 1 } ( \mathbf { H } _ { l } ^ { \mathsf { H } } - \delta _ { l } ) \big ] , +$$ + +where $\delta _ { l }$ denotes the minimum element in $\mathbf { f } _ { l } ^ { \mathsf { H } } ; \Delta _ { l } = ( h _ { \operatorname* { m a x } } - \delta _ { l } ) / ( 2 ^ { Q } - 1 )$ denotes the quantization step; $h _ { \mathrm { m a x } }$ denotes the maximum element in $\mathbf { H } _ { l } ^ { \mathsf { H } }$ ; $\lfloor \bullet \rceil$ denotes the stochastic rounding. + +After the compression, as the representation of $\mathbf { H } _ { l }$ , the tuple of $( \mathbf { H } _ { l } ^ { \mathsf { L } } , \mathbf { V } _ { l } ^ { \mathsf { H } } , \Delta _ { l } , \delta _ { l } )$ is cached to the memory for reconstructing the activation maps during the backward pass. + +# F.2 ACTIVATION MAP DECOMPRESSION + +During the backward pass, DIVISION adopts the cached tuples of $\{ ( \mathbf { H } _ { l } ^ { \mathsf { L } } , \mathbf { V } _ { l } ^ { \mathsf { H } } , \Delta _ { l } , \delta _ { l } ) \mid 0 \leq l \leq$ $L - 1 \}$ to reconstruct the activation map layer-by-layer. Specifically, for each layer $l$ , DIVISION dequantizes the HFC via $\hat { \mathbf { H } } _ { l } ^ { \mathsf { H } } = \Delta _ { l } \mathbf { V } _ { l } ^ { \mathsf { H } } + \delta _ { l }$ , which is the inverse process of Equation (52). Then, the activation map is reconstructed via $\hat { \mathbf { H } } _ { l } = \mathrm { U p S a m p l i n g } ( \mathbf { H } _ { l } ^ { \mathsf { L } } ) + \hat { \mathbf { H } } _ { l } ^ { \mathsf { H } }$ , where UpSampling $( \cdot )$ enlarges $\mathbf { H } _ { l } ^ { \mathrm { L } }$ to the shape of $\mathbf { H } _ { l }$ via nearest interpolation. The cases of 1D, 2D and 3D activation maps are considered in Equation (51). + +After the decompression, DIVISION frees the caching of $( \mathbf { H } _ { l } ^ { \mathsf { L } } , \mathbf { V } _ { l } ^ { \mathsf { H } } , \Delta _ { l } , \delta _ { l } )$ , and takes $\hat { \mathbf { H } } _ { l }$ into $[ \hat { \nabla } _ { \mathbf { H } _ { l - 1 } } , \hat { \nabla } _ { \mathbf { W } _ { l } } ] = \mathrm { b a c k w a r d } ( \hat { \nabla } _ { \mathbf { H } _ { l } } , \hat { \mathbf { H } } _ { l - 1 } , \mathbf { W } _ { l } )$ to estimate the gradient for backward propagation. + +# G THEORETICAL COMPRESSION RATE OF DIVISION + +The compression rate of DIVISION is estimated in this section. A general case of convolutional neural networks (CNN) and multi-layer perceptron (MLP) are considered for the estimation. + +# G.1 COMPRESSION RATE OF CNN TRAINING + +Without loss of generality, we estimate the compression rate for a block of convolutional layer (conv), batch normalization layer (BN) and Relu activation. Most of existing backbones purely stacks conv-BN-Relu blocks (He et al., 2016; Huang et al., 2017; Szegedy et al., 2015; Tan & Le, 2019; Simonyan & Zisserman, 2014), which makes our estimated compression rate hold in practice. Generally, the compression rate is defined as the memory reduction ratio after the compression. To be concrete, let Minibatch $\times$ Channel $. { \times } N { \times } N$ denote the shape of activaition maps for a conv-BN-Relu block; given the block-size $B$ and bit-width $Q$ , DIVISION has the compression rate of activation maps given by Theorem 3A. + +Theorem 3A. DIVISION has average activation map compression rate for a conv-BN-Relu block given by + +$$ +R = { \frac { M e m \ o f { \bf H } } { M e m \ o f ( { \bf H } ^ { \mathrm { L } } , { \bf V } ^ { \mathrm { H } } , \Delta , \delta ) } } = { \frac { 9 } { { \frac { 4 } { \operatorname* { m i n } \{ B ^ { 2 } , N ^ { 2 } \} } } + { \frac { Q } { 4 } } + { \frac { 8 } { N ^ { 2 } } } + { \frac { 1 } { 8 } } } } , +$$ + +where Minibatc $\mathrm { h } \times \mathrm { C h a n n e l } \times N \times N$ is the shape of activation map $\pmb { H } _ { l }$ ; $B$ denotes the block-size of LFC average pooling; and $Q$ denotes the bit-width of HFC quantization. + +Proof. For each mini-batch updating of normal training, a conv-layer or BN-layer caches $N ^ { 2 }$ float $3 2 \times $ 4byte/float $\dot { 3 } 2 = \hat { 4 } N ^ { 2 }$ byte activation map; a Relu operator caches ${ \dot { N } } ^ { 2 } { \dot { \mathrm { 1 } } } \mathrm { n t } 8 \ \times$ 1byte/int $8 = N ^ { 2 }$ byte activation map. For each mini-batch updating of DIVISION, a conv-layer or BN-layer caches $\frac { N ^ { 2 } } { \operatorname* { m i n } \{ B ^ { 2 } , N ^ { 2 } \} }$ bfloat1 $6 ~ \times$ 2byte/bfloat1 2N2min{B2,N2} byte LFC; and $\begin{array} { r } { Q N ^ { 2 } \mathrm { b i t } \times \frac { 1 } { 8 } \mathrm { b i t } / \mathrm { b y t e } = \frac { Q } { 8 } N ^ { 2 } } \end{array}$ byte HFC; and spends 2bfloat1 $6 \times 2$ byte/bfloat1 $6 = 4$ byte for $\Delta _ { l }$ and $\delta _ { l }$ 8 . Moreover, a Relu operator caches $\begin{array} { r } { N ^ { 2 } \mathrm { b i t } \times \frac { 1 } { 8 } \mathrm { b y t e } / \mathrm { b i t } = \frac { N ^ { 2 } } { 8 } . } \end{array}$ byte activation map. 8 8Therefore, the average activation map compression rate of a conv-BN-Relu block is given by + +$$ +R = { \frac { 4 N ^ { 2 } \times 2 + N ^ { 2 } } { \left( { \frac { 2 N ^ { 2 } } { \operatorname* { m i n } \{ B ^ { 2 } , N ^ { 2 } \} } } + { \frac { Q } { 8 } } N ^ { 2 } + 4 \right) \times 2 + { \frac { 1 } { 8 } } N ^ { 2 } } } = { \frac { 9 } { { \frac { 4 } { \operatorname* { m i n } \{ B ^ { 2 } , N ^ { 2 } \} } } + { \frac { Q } { 4 } } + { \frac { 8 } { N ^ { 2 } } } + { \frac { 1 } { 8 } } } } . +$$ + +A higher compression rate indicates more effective compression. It is observed that the compression rate grows with $B$ and $N$ , and decreases with $Q$ . In our experiments, we found $B { = } 8$ and $Q = 2$ can provide loss-less model accuracy. In this condition, the shape of activation maps satisfies $N \geq 7$ for ResNet-50 and WRN-50-2 on the ImageNet dataset (He et al., 2016). According to Equation (53), we have $R _ { \mathrm { R e s N e t - } 5 0 }$ , $R _ { \mathrm { W R N - } 5 0 - 2 } \geq 1 0 . 3 5$ . + +# G.2 COMPRESSION RATE OF MLP TRAINING + +We estimate the compression rate for a linear-Relu block in Theorem 3B. An MLP simply stacks multiple linear-Relu blocks, such that our estimated compression rate holds for MLP models. + +Theorem 3B. DIVISION has average activation map compression rate for a linear-Relu block given by + +$$ +R = \frac { M e m \ o f { \bf H } } { M e m \ o f { ( { \bf H } ^ { \mathrm { L } } , { \bf V } ^ { \mathrm { H } } , \Delta , \delta ) } } = \frac { 5 } { \frac { 2 } { \operatorname* { m i n } \{ B , N \} } + \frac { Q } { 8 } + \frac { 4 } { N } + \frac { 1 } { 8 } } , +$$ + +where Minibatch $\times N$ is the shape of activation map $\pmb { H } _ { l }$ ; $B$ denotes the block-size of LFC average pooling; and $Q$ denotes the bit-width of HFC quantization. + +Proof. For each mini-batch updating of normal training, a linear-layer caches $N$ float $3 2 \ \times$ 4byte/float $3 2 \ : = \ : 4 N$ byte activation map; a Relu operator caches $N { \mathrm { i n t } } 8 \times 1 { \mathrm { b y t e / i n t } } 8 =$ $N$ byte activation map. For each mini-batch updating of DIVISION, a linear-layer caches $\frac { \mathrm { ~ \bar { ~ } { ~ N ~ } ~ } } { \operatorname* { m i n } \{ B , N \} }$ bfloat1 $6 \times 2$ byte/bfloat1 $\begin{array} { r } { \hat { \varsigma } = \frac { - 2 N } { \operatorname* { m i n } \left\{ B , N \right\} } } \end{array}$ byte LFC; and $Q N _ { \mathrm { { b i t } } } \times \mathsf { \Pi } _ { 8 } ^ { \mathrm { { 1 } } } \mathrm { { b i t / b y t e } } =$ $\frac { Q } { 8 }$ Nbyte HFC; and spends 2bfloat1 $6 \times 2$ byte/bfloat1 $6 =$ 4byte for $\Delta _ { l }$ and $\delta _ { l }$ . Moreover, a Relu operator caches $\begin{array} { r } { N { \mathrm { b i t } } \times \frac { 1 } { 8 } { \mathrm { b y t e / b i t } } = \frac { N } { 8 } { \mathrm { b y } } } \end{array}$ te activation map. Therefore, the average activation map compression rate of a linear-Relu block given by + +$$ +R = { \frac { 4 N + N } { { \frac { 2 N } { \operatorname* { m i n } \{ B , N \} } } + { \frac { Q } { 8 } } N + 4 + { \frac { 1 } { 8 } } N } } = { \frac { 5 } { { \frac { 2 } { \operatorname* { m i n } \{ B , N \} } } + { \frac { Q } { 8 } } + { \frac { 4 } { N } } + { \frac { 1 } { 8 } } } } . +$$ + +# H EXPERIMENT SETTING + +We give the experiment setting including the datasets, baseline methods and model architectures in this section. + +Datasets. We consider CIFAR-10, CIFAR-100 (Krizhevsky et al., 2009) and ImageNet (Deng et al., 2009) datasets in our experiments. CIFAR-10: An image dataset with 60,000 color images in 10 different classes, where each image has $3 2 \times 3 2$ pixels. CIFAR-100: An image dataset with 60,000 color images in 100 different classes, where each image has $3 2 \times 3 2$ pixels. ImageNet: A large scale image dataset which has over one million color images covering 1000 categories, where each image has $2 2 4 \times 2 2 4$ pixels. + +Baseline Methods. Normal: Caching the exact activation map for backward propagation. BLPA: A systemic implementation of ACT by (Chakrabarti & Moseley, 2019), which only supports ResNetrelated architectures. AC-GC: A framework of ACT with automatic searched bit-width for the quantization of activation maps (Evans & Aamodt, 2021). ActNN: Activation compression training with dynamic bit-width quantization, where the bit-allocation minimizes the variance of activation maps via dynamic processing (Chen et al., 2021). Checkpoint: Caching some key activation maps to reconstruct other activation maps via replaying parts of the forward pass during the backward pass (Chen et al., 2016). SWAP: Swapping the activation maps to the CPU during the forward pass the memory consumption of GPU, and reload the activation maps to GPU during the backward pass (Huang et al., 2020). + +DNN Architectures. For benchmarking the model accuracy, we consider ResNet-18 (top-1 accuracy $9 4 . 8 9 \%$ ) and ResNet-164 (top-1 accuracy $9 4 . 9 \% )$ ) on the CIFAR-10 dataset; DenseNet121 (top-1 accuracy $7 9 . 7 5 \% )$ and ResNet-164 (top-1 accuracy $7 7 . 3 \%$ ) on the CIFAR-100 dataset; and ResNet-50 (top-1 accuracy $7 6 . 1 5 \%$ ) as well as DenseNet-161 (top-1 accuracy $7 7 . 6 5 \%$ ) on the ImageNet dataset. Our reproduced validating accuracy is consistent with the official results of torchvision12. Moreover, for benchmarking the memory cost and training throughput, we consider the large models ResNet-50 and WRN-50-2 on the ImageNet dataset. + +# I IMPLEMENTATION DETAILS ABOUT DIVISION AND BASELINE METHODS + +DIVISION: DIVISION adopts block-size 8 $B = 8 ,$ ) and 2-bit quantization $Q = 2 { \it \Psi }$ ) to compress the activation maps of linear, convolutional and BatchNorm layers, where the theoretical compression rate is not less than $1 0 . 3 5 \times$ . For the operators without quantization error during backward propagation such as pooling layers, ReLu activation, and Dropout, DIVISION follows the algorithms in Appendix J to compress the activation maps. Other hyper-parameter settings are given in Table 5. + +BLPA: Existing work (Chakrabarti & Moseley, 2019) has shown that BLPA requires at least 4-bit ACT for loss-less DNN training. We follow this setting for BLPA, where the compression rate of activation maps is not more than $8 \times$ . AC-GC: AC-GC follows existing work (Evans & Aamodt, 2021) to take the multiplicative error $( 1 + e _ { \mathrm { A C - G C } } ^ { 2 } ) = 1 . 5$ , where the searched bit-width enables ACGC to satisfy this loss bound (training loss not more than $1 5 0 \%$ of normal training). In this setting, AC-GC finalizes the bit-with as 7.01 after the searching, which has a nearly $4 . 5 7 \times$ compression rate of activation maps. ActNN: ActNN adopts 2-bit ACT and dynamic programming for searching the optimal bit-width specific for each layer, and uses per-group quantization for compressing the activation map, which has approximately $1 0 . 5 \times$ compression rate of activation maps. Such experimentally setting is denoted as L3 strategy in the original work (Chen et al., 2021), and we follow this setting in this section. Checkpoint: Checkpoint relies on the model-specific design of the checkpointed layers. We find that it provides a good trade-off between memory cost and running speed to checkpoint the activation map of each Botteneck block in ResNet-50 and WRN-50-2 (a ResNet-50 or WRN-50-2 has four Botteneck blocks). To implement the checkpointing of inter-media layers, we revised the forward function of the ResNet-50 and WRN-50-2 as Figure 8. SWAP: For the SWAP method, the memory utilization is considered both GPU and CPU because the activation maps are stored on both GPU and CPU in SWAP. + +Table 5: Hyper-parameter setting. + +
DatasetCIFAR-10CIFAR-100ImageNet
ArchitectureResNet-18ResNet-164ResNet-164DenseNet-121ResNet-50DenseNet-161
Epoch100100200100120120
Batch-size2562562562562562560.1Cos LR0.0001SGD0.982
Initial LRLR schedulerWeight-decay0.10.10.150.10.1Cos LR0.0001
Cos LR0.0005Cos LR0.0005Cos LR0.0005Cos LR0.0005
OptimizerSGDSGDSGDSGDSGD
SGD MomentumBlock-size B0.90.90.90.90.9
88888
Bit-width Q22222
+ +![](images/c9121f542bec996c866be63283d3da6a4ff739148a9f99048bc30ddbe4db423b.jpg) +Figure 8: Implementation of checkpointed ResNet-50 and WRN-50-2. + +J COMPRESSION OF POOLING LAYERS, RELU ACTIVATIONS, AND DROPOUT + +DIVISION follows Algorithms 2, 3, 4 and 5 to compresse the activation map of a Max-Pooling layer, Average-Pooling layer, Relu activation and Dropout operator, respectively. For the pooling layers, we consider a simple case kernelsize $=$ movingstride $= k$ . General cases with different kernelsize and movingstride can be designed in analogous ways. + +
Algorithm2 Max-Pooling layer.Algorithm 3 Average-Pooling layer.
1:Function Forward (Hl-1,k, **kwargs)H,Vl-112=Max-Pooling(Hl-1,k,kwargs)1:Function Forward (Hl-1,k, **kwargs) H =Avg-Pooling(Hl-1,k,kwargs)
2: 3:Pack & CacheVt-1 using Int8.2: 3: return H
4: return H4:
5:5:
6:Function Backward(VH )6:
7: Load Vl-1 and k.7: Function Backward(VHl)
8:VH =1kxk VH8: VH =1k×k VHl
9:VH-1 =Vi-1OVH9: VHl-1=k-²VH
10:return VHl-110: return VHl-1
+ +
Algorithm 4Relu operator.Algorithm 5 Dropout operator.
1:Function Forward (Hl-1)1:Function Forward (Hl-1)
2: Vt-1 = sgn(Hl-1)2:Generate a Minibatch× Channel × N ×N binary matrix Vl-1
3:H=V-1H-1 3:following the Bernouli distribution with dropout probability p.
4: Pack & Cache Vl-1 using Int84:H=V-1OH-1
5: return H5:Pack & Cache Vl-1 using Int8.
6:6:return H
7:7:
8:Function Backward(VH )8: Function Backward(VHl)
9: Load Vt-1.9:Load Vl-1.
10:VHl-1 =Vl-1OVHt 10:VHl-1 =Vi-1 VH
11:return VHl-1 11:return VHl-1
+ +# K EVALUATION OF DIVISION ON MULTI-LAYER PERCEPTRONS (MLPS) + +We conduct experiments on the GAS dataset (Dua & Graff, 2017) (128-dimensional features, 13910 instances, 6 classification task). The classification model is a 4-layer MLP (128 neuros in the input layer, 6 neuros in the output layer, and 64 neuros in the hidden layer); The setting of DIVISION is $B = 1 6$ and $Q = 2$ . The model accuracy and memory cost of activation map are given in Table 6. It is observed that DIVISION has $7 . 3 \times$ compression rate with only $0 . 0 7 \%$ degradation of model accuracy. This indicates the effectiveness of DIVISION on the MLP models. + +Table 6: Model Accuracy on the GAS dataset. + +
TrainingTesting Accuracy (%)Memory (KB)Compression Rate
Normal TrainingDIVISION98.9298.8525034.2N/A7.3×
+ +# L EVALUATION OF DIVISION ON VISION TRANSFORMERS + +We conduct experiments to study the performance of DIVISION on Swin Transformer (Liu et al., 2021a). In this experiment, a Swin Transformer-T is trained on the ImageNet datset, where DIVISION is compared with Mesa (Pan et al., 2021), an ACT framework for visual transformer. The model accuracy and memory cost (with batch-size 128) are given in Table 7. It is observed that DIVISION achieves almost the same model accuracy compared with normal training. This indicates DIVISION can effectively compress the training of the vision Transformer. + +Although DIVISION shows slightly lower accuracy lower than Mesa, the compression rate is significantly higher than Mesa. Moreover, DIVISION can be applied to general vision models, including MLPs, CNNs, and vision transformers; while Mesa is explicitly designed for vision transformers. + +Table 7: Accuracy of Swin Transformer-T on the ImageNet dataset. + +
MethodAccuracy (%)Memory (GB)Compression Rate
Normal TrainingDIVISIONMesa81.281.081.311.814.195.37N/A2.8×2.2×
+ +# M EVALUATION OF DIVISION ON DEPTHWISE AND POINTWISE CONVOLUTIONAL LAYERS + +To evaluate DIVISION on the depthwise convlution and pointwise convulution layers, we conduct experiments of MobileNet-V2 on the CIFAR-10 and CIFAR-100 datasets, where the model accuracy are given Table 8. It is observed that DIVISION achieve nearly the same accuracy compared with normal training. This indicates the effectiveness of DIVISION for the depthwise convlution and pointwise convulution layers. + +Table 8: Accuracy of MoblieNet-V2 on the CIFAR-10 and CIFAR-100 datasets. + +
MethodMobileNet-V2 (CIFAR-10)MoblieNet-V2 (CIFAR-100)
Normal TrainingDIVISION91.991.871.070.6
+ +# N RE-UTILIZATION OF HYPER-PARAMETER SETTINGS ACROSS DIFFERENT MODEL ARCHITECTURES AND DATASESTS + +We conduct the follow-up experiments to study whether the hyper-parameter setting of DIVISION has a consistent effect on different model architectures and datasets. Specifically, the hyperparameters of DIVISION are selected from $B \in \{ 8 , 1 8 \}$ and $Q \in \{ 2 , 8 \}$ to train ResNet-18 and MobileNet-V2 on the CIFAR-10 and CIFAR-100 datasets. The model accuracy is given in Table 9. It is observed $B$ and $Q$ have a consistent impact on different model architectures and datasets: the accuracy slightly grows with $Q$ and considerably reduces with $B$ . This indicates we can reuse the hyper-parameter setting of DIVISION on CIFAR-10 to CIFAR-100 with the same model architecture, or we can reuse the setting with ResNet-18 and MobileNet-V2 on the same dataset. + +Table 9: Accuracy of ResNet-18 and MoblieNet-V2 with different hyper-parameter settings. + +
B=18Q=2B=8Q=2B=8Q=8
ResNet-18 CIFAR-10ResNet-18 CIFAR-100MobileNet-V2CIFAR-10MobileNet-V2 CIFAR-10078.773.294.694.977.091.0
73.276.9
10.010.091.7
62.470.671.6
+ +# O COMPARISON OF DIVISION WITH CHECKPOINT STRATEGY OF MEGATRON-LM + +DIVISION is compared with the checkpointing strategy of Megatron-LM (Shoeybi et al., 2019). According to the official guideline, Megatron-LM checkpoints the activation map after each transformer block. We follow this strategy to checkpoint the activation map after each transformer block in the Swin Transformer, and after each Bottleneck block in the ResNet-50. The memory cost (on the ImageNet dataset with batch-size 128) is given in Table 10. It is observed DIVISION has a higher compression rate $2 . 8 \times$ for Swin Transformer-T and $7 . 9 \times$ for ResNet-50) than the Checkpoint strategy of Megatron-LM $2 . 3 \times$ for Swin Transformer-T and $2 . 2 7 \times$ for ResNet-50). This indicates the effectiveness of DIVISION over the checkpoint strategy of Megatron-LM. + +Table 10: Memory cost of DIVISION and Checkpoint strategy of Megatron-LM. + +
Memory cost (GB) Normal TrainingDIVISIONCheckpoint strategy of Megatron-LM
Swin Transformer-TResNet-5011.8110.624.19 (2.8×)1.35 (7.9x)5.14 (2.3x)4.68 (2.27×)
+ +# P EFFECT OF BIT-WIDTH ON THE FIXED QUANTIZATION + +To demonstrate the effectiveness of dual activation precision, DIVISION $\boldsymbol { B } = \boldsymbol { 8 }$ , $Q = 2 { \it \Psi }$ ) is compared with the fixed quantization under different bit-width. The model accuracy of ResNet-50 on the ImageNet dataset is given in Table 11. It is observed the training fails to converge to an optimal solution under 2-bit quantization, even though it performs favorably under 4-bit and 8-bit quantization. This result is consistent with existing work (Chen et al., 2021) (Table 3 in (Chen et al., 2021)). In contrast, DIVISION achieves $7 5 . 9 \%$ accuracy when adopting 2-bit quantization to compress the HFC. This indicates the effectiveness of dual activation precision in terms of the model accuracy under low bit-width quantization. + +Table 11: Model accuracy of fixed quantization under different bit-width. + +
Bit-width248
Fixed QuantizationDIVISION0.175.976.05omit76.35omit
+ +# Q EFFECT OF MINI-BATCH SIZE ON THE THROUGHPUT + +As a supplementary of Section 5.5, a follow-up experiment is conducted to study the effect of batchsize on the training throughput. The result on the CIFAR-10 dataset is given in Table 12. It is observed: for the experiment w/o AMP, the throughput significantly grows as the batch-size grows from 64 to 128, but is almost unchanged when the batch-size $\geq 1 2 8$ ; for the experiment w/ AMP, it grows continuously when the batch-size grows from 64 to 256, and becomes stable when the batch-size $\geq 2 5 6$ . + +Table 12: Traininig throughput versus the batch-size. + +
images/sBatchsize=64Batchsize=128Batchsize=256Batchsize=512Batchsize=1024
w/o AMP1185.272184.362335.412394.842409.99
w/ AMP1273.462285.873753.063981.954068.67
+ +Intuitively, as the batch-size grows, the GPU can parallel process more images per second, until the GPU is $100 \%$ utilized (Goyal et al., 2017). In the experiment w/o AMP, the GPU is almost $100 \%$ utilized when batch-size $\geq 1 2 8$ ; while this happens when batch-size $\geq 2 5 6$ in the experiment w/ AMP. More images can be processed in the experiment w/ AMP, since it employs bfloat16 operations in the training, in contrast with the float32 operations in the training w/o AMP, where a bfloat16 operation has nearly half of the computation cost of a float32 operation. Therefore, the training throughput significantly grows from 2086 (images/s) to 3753 (images/s) as the batch-size grows from 128 to 256 in the experiment w/ AMP, but is almost unchanged (2184 images/s vs 2335 images/s) in the same condition in the experiment w/o AMP. + +# R DETAILS ABOUT THE COMPUTATION INFRASTRUCTURE + +The details about our physical computing infrastructure for testing the training memory cost and throughput are given in Table 13. + +Table 13: Computing infrastructure for the experiments. + +
Device AttributeValue
Computing infrastructureGPU
GPU modelNvidia-RTX3090
GPU number1
GPUMemory24567 MB
+ +# S IMPLEMENTATION DETAILS OF THE EXPERIMENT IN SECTION 5.4 + +We give the implementation details of the experiment in Section 5.4. Specifically, DIVISION w/o $H F C$ takes block-size $B = 4$ for estimating LFC; DIVISION w/o LFC takes the bit-width $Q = 2$ for the quantization of HFC; DIVISION combines these settings for the training; and Fixed Quant has a 2-bit per-group quantization of activation maps during the backward pass of the training, where the group size of quantization is 256. Other training hyper-parameters are given in Table 5. \ No newline at end of file diff --git a/md/dev/AJg35fkqOPA/AJg35fkqOPA.md b/md/dev/AJg35fkqOPA/AJg35fkqOPA.md new file mode 100644 index 0000000000000000000000000000000000000000..aca00c7dee126a15b45d7ba621c0dc1f0a314450 --- /dev/null +++ b/md/dev/AJg35fkqOPA/AJg35fkqOPA.md @@ -0,0 +1,262 @@ +# TEXT-DRIVEN IMAGE MANIPULATION VIA SEMANTIC-AWARE KNOWLEDGE TRANSFER + +Anonymous authors Paper under double-blind review + +# ABSTRACT + +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. + +# 1 INTRODUCTION + +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). + +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. + +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. + +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. + +Our contributions are summarized as follows: + +• 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. + +# 2 RELATED WORK + +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. + +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. + +![](images/0a855f9fd91735343743771b0cbbcd356d2018299f616cd16110b5d15d287c9f.jpg) +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. + +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. + +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. + +# 3 METHODOLOGY + +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. + +# 3.1 PRELIMINARIES + +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. + +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: + +$$ +\mathcal { L } _ { s t y l e c l i p } = D _ { \mathrm { C L I P } } ( G ( w ) , t e x t ) , +$$ + +where $D _ { \mathrm { C L I P } }$ is the cosine distance metric in CLIP-space, and $G$ is the pre-trained StyleGAN generator. + +![](images/9ab91a6a5e91c830f4013b388d228e7380eb6299535eaee7b90d708604bbb256.jpg) +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. + +# 3.2 PROBLEM FORMULATION + +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. + +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 ) )$ . + +# 3.3 DIRECTIONAL LATENT MAPPING + +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: + +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: + +$$ +M ( w ) = [ M _ { 1 } ( w _ { 1 } ) , M _ { 2 } ( w _ { 2 } ) , . . . , M _ { g } ( w _ { g } ) ] , +$$ + +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 } )$ . + +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: + +$$ +\begin{array} { c } { { y _ { i } ; \hat { y _ { i } } = E _ { I } ( x ; \hat { x } ) , } } \\ { { y _ { t } = E _ { T } ( t ) , } } \end{array} +$$ + +![](images/6319cd20319308bfa543afbc202eb39dd245bfa6a592ab33ebaa36a063af4ee0.jpg) +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. + +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$ . + +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: + +$$ +\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} +$$ + +where $S ( \cdot , \cdot )$ is the similarity measurement. In this paper, we use the effective cosine similarity as the measurement. + +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: + +$$ +\mathcal { L } _ { \mathrm { I D } } = 1 - \left. R ( G ( w ) ) , R ( G ( \hat { w } ) ) \right. , +$$ + +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: + +$$ +\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 ) . +$$ + +# 3.4 SEMANTIC DIRECTIONAL DECOMPOSITION + +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). + +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 }$ . + +![](images/a42c290dc0d3755ecd6b895c9e1dbab8d88f351e03476d25131bed5a4d947f7a.jpg) +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. + +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. + +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 }$ : + +$$ +\vec { \mathcal { V } _ { p } } = \mathcal { V } _ { R T } ^ { } \cdot ( \frac { \vec { \mathcal { V } _ { t } } } { | \mathcal { V } _ { t } | } ) ^ { 2 } , +$$ + +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: + +$$ +y _ { g o a l } = y _ { t a r } + \beta \vec { \mathcal { V } _ { p } } , +$$ + +where $\beta$ is the hyperparameter. + +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: + +$$ +\mathcal { L } _ { \mathrm { A T } } = \mathrm { M S E } ( \hat { y } , y _ { g o a l } ) , +$$ + +where $\mathrm { M S E } ( \cdot , \cdot )$ is the mean squared error. + +Meanwhile, we use the same $L 2$ loss and identity loss to preserve the irrelevant parts. The whole training objective of SDD-Net is: + +$$ +\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 } } . +$$ + +![](images/32527924cb4a64c62e9b2fa1e9563a20ec8e5225f4869fab2b07231e7afb59eb.jpg) +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. + +# 4 EXPERIMENTS + +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. + +# 4.1 DATASET + +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. + +# 4.2 IMPLEMENTATION DETAILS + +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$ . + +![](images/881485244855762ebbec0b98b0a6e810c0a3080469b5802969e477e744d83c5a.jpg) +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. + +# 4.3 BASELINE METHODS + +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\*. + +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. + +# 4.4 RESULTS AND ANALYSIS + +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. + +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. + +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. + +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. + +# 4.5 ABLATION STUDY + +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$ . + +![](images/a6296e98bdcc63d20c6418746537725052a3e376b135b68d3f5699b724454f5e.jpg) +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. + +# 5 CONCLUSIONS + +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. + +# REFERENCES + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +Erik Hark ¨ onen, Aaron Hertzmann, Jaakko Lehtinen, and Sylvain Paris. Ganspace: Discovering ¨ interpretable gan controls. arXiv preprint arXiv:2004.02546, 2020. + +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. + +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. + +Bingwen Hu, Zhedong Zheng, Ping Liu, Wankou Yang, and Mingwu Ren. Unsupervised eyeglasses removal in the wild. IEEE Transactions on Cybernetics, 2020. + +Ali Jahanian, Lucy Chai, and Phillip Isola. On the” steerability” of generative adversarial networks. arXiv preprint arXiv:1907.07171, 2019. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +Yotam Nitzan, Rinon Gal, Ofir Brenner, and Daniel Cohen-Or. Large: Latent-based regression through gan semantics. arXiv preprint arXiv:2107.11186, 2021. + +Or Patashnik, Zongze Wu, Eli Shechtman, Daniel Cohen-Or, and Dani Lischinski. Styleclip: Textdriven manipulation of stylegan imagery. arXiv preprint arXiv:2103.17249, 2021. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. \ No newline at end of file diff --git a/md/dev/AP1MKT37rJ/AP1MKT37rJ.md b/md/dev/AP1MKT37rJ/AP1MKT37rJ.md new file mode 100644 index 0000000000000000000000000000000000000000..e2f2c4b7e83533b7c0382fd4a4aeae3824c42c42 --- /dev/null +++ b/md/dev/AP1MKT37rJ/AP1MKT37rJ.md @@ -0,0 +1,1101 @@ +# WHEN SHOULD WE PREFER OFFLINE REINFORCEMENT LEARNING OVER BEHAVIORAL CLONING? + +Aviral Kumar∗,1,2, Joey $\mathbf { H o n g ^ { * , 1 } }$ , Anikait Singh1, Sergey Levine1,2 1Department of EECS, UC Berkeley 2Google Research (∗Equal Contribution) {aviralk, joey hong}@berkeley.edu + +# ABSTRACT + +Offline reinforcement learning (RL) algorithms can acquire effective policies by utilizing previously collected experience, without any online interaction. It is widely understood that offline RL is able to extract good policies even from highly suboptimal data, a scenario where imitation learning finds suboptimal solutions that do not improve over the demonstrator that generated the dataset. However, another common use case for practitioners is to learn from data that resembles demonstrations. In this case, one can choose to apply offline RL, but can also use behavioral cloning (BC) algorithms, which mimic a subset of the dataset via supervised learning. Therefore, it seems natural to ask: when can an offline RL method outperform BC with an equal amount of expert data, even when BC is a natural choice? To answer this question, we characterize the properties of environments that allow offline RL methods to perform better than BC methods, even when only provided with expert data. Additionally, we show that policies trained on sufficiently noisy suboptimal data can attain better performance than even BC algorithms with expert data, especially on long-horizon problems. We validate our theoretical results via extensive experiments on both diagnostic and high-dimensional domains including robotic manipulation, maze navigation, and Atari games, with a variety of data distributions. We observe that, under specific but common conditions such as sparse rewards or noisy data sources, modern offline RL methods can significantly outperform BC. + +# 1 INTRODUCTION + +Offline reinforcement learning (RL) algorithms aim to leverage large existing datasets of previously collected data to produce effective policies that generalize across a wide range of scenarios, without the need for costly active data collection. Many recent offline RL algorithms [16, 26, 66, 27, 69, 61, 25] can work well even when provided with highly suboptimal data, and a number of these approaches have been studied theoretically [64, 71, 52, 20]. While it is clear that offline RL algorithms are a good choice when the available data is either random or highly suboptimal, it is less clear if such methods are useful when the dataset consists of demonstration that come from expert or near-expert demonstrations. In these cases, imitation learning algorithms, such as behavorial cloning (BC), can be used to train policies via supervised learning. It then seems natural to ask: When should we prefer to use offline RL over imitation learning? + +To our knowledge, there has not been a rigorous characterization of when offline RL perform better than imitation learning. Existing empirical studies comparing offline RL to imitation learning have come to mixed conclusions. Some works show that offline RL methods appear to greatly outperform imitation learning, specifically in environments that require “stitching” parts of suboptimal trajectories [14]. In contrast, a number of recent works have argued that BC performs better than offline RL on both expert and suboptimal demonstration data over a variety of tasks [38, 12, 17]. This makes it confusing for practitioners to understand whether to use offline RL or simply run BC on collected demonstrations. Thus, in this work we aim to understand if there are conditions on the environment or the dataset under which an offline RL algorithm might outperform BC for a given task, even when BC is provided with expert data or is allowed to use rewards as side information. Our findings can inform a practitioner in determining whether offline RL is a good choice in their domain, even when expert or near-expert data is available and BC might appear to be a natural choice. + +Our contribution in this paper is a theoretical and empirical characterization of certain conditions when offline RL outperforms BC. Theoretically, our work presents conditions on the MDP and dataset that are sufficient for offline RL to achieve better worst-case guarantees than even the best-case lower-bound for BC using the same amount of expert demonstrations. These conditions are grounded in practical problems, and provide guidance to the practitioner as to whether they should use RL or BC. Concretely, we show that in the case of expert data, the error incurred by offline RL algorithms can scale significantly more favorably when the MDP enjoys some structure, which includes horizonindependent returns (i.e., sparse rewards) or a low volume of states where it is “critical” to take the same action as the expert (Section 4.2). Meanwhile, in the case of sufficiently noisy data, we show that offline RL again enjoys better guarantees on long-horizon tasks (Section 4.3). Finally, since BC methods ignore rewards, we consider generalized BC methods that use the observed rewards to inform learning, and show that it is still preferable to perform offline RL (Section 4.4). + +Empirically, we validate our theoretical conclusions on diagnostic gridworld domains [13] and largescale benchmark problems in robotic manipulation and navigation and Atari games, using human data [14], scripted data [60], and data generated from RL policies [3]. We verify that in multiple long-horizon problems where the conditions we propose are likely to be satisfied, practical offline RL methods can outperform BC and generalized BC methods. We show that using careful offline tuning practices, we show that it is possible for offline RL to outperform cloning an expert dataset for the same task, given equal amounts of data. We also highlight open questions for hyperparameter tuning that have the potential to make offline RL methods work better in practice. + +# 2 RELATED WORK + +Offline RL [32, 34] has shown promise in domains such as robotic manipulation [22, 37, 60, 23], NLP [19] and healthcare [58, 63]. The major challenge in offline RL is distribution shift [16, 26], where the learned policy might execute out-of-distribution actions. Prior offline RL methods can broadly be characterized into two categories: (1) policy-constraint methods that regularize the learned policy to be “close” to the behavior policy either explicitly [16, 26, 36, 66, 15] or implicitly [59, 47, 45], or via importance sampling [35, 62, 43], and (2) conservative methods that learn a conservative, estimate of return and optimize the policy against it [27, 25, 24, 69, 70]. Our goal is not to devise a new algorithm, but to understand when existing offline RL methods can outperform BC. + +When do offline RL methods outperform BC? Rashidinejad et al. [52] derive a conservative offline RL algorithm based on lower-confidence bounds (LCB) that provably outperforms BC in the simpler contextual bandits (CB) setting, but do not extend it to MDPs. While this CB result signals the possibility that offline RL can outperform BC in theory, this generalization is not trivial, as RL suffers from compounding errors [41, 42, 64]. Laroche et al. [33], Nadjahi et al. [44], Kumar et al. [27], Liu et al. [36], Xie et al. [68] present safe policy improvement bounds expressed as improvements over the behavior policy, which imitation aims to recover, but these bounds do not clearly indicate when offline RL is better or worse. Empirically, Fu et al. [14] show that offline RL considerably outperforms BC for tasks that require “stitching” trajectory segments to devise an optimal policy. In contrast, Mandlekar et al. [38], Brandfonbrener et al. [6], Chen et al. [8], Hahn et al. [17] suggest that BC or filtered BC using the top fraction of the data performs better on other tasks. While the performance results in D4RL [14], especially on the Adroit domains, show that offline RL outperforms BC even on expert data, Florence et al. [12] reported superior BC results, making it unclear if the discrepancy arises from different hyperparameter tuning practices. Kurenkov & Kolesnikov [31] emphasize the importance of the online evaluation budget for offline RL methods and show that BC is more favorable in a limited budget. While these prior works discussed above primarily attempt to show that BC can be better than offline RL, we attempt to highlight when offline RL is expected to be better by providing a characterization of scenarios where we would expect offline RL to be better than BC, and empirical results verifying that offline RL indeed performs better on such problems [14, 60, 4]. + +Our theoretical analysis combines tools from a number of prior works. We analyze the total error incurred by RL via an error propagation analysis [41, 42, 11, 7, 67, 36], which gives rise to bounds with concentrability coefficients that bound the total distributional shift between the learned policy and the data distribution [67, 36]. We use tools from Ren et al. [53], which provide horizon-free bounds for standard (non-conservative) offline Q-learning but relax their strict coverage assumptions. While our analysis studies a LCB-style algorithm similar to Rashidinejad et al. [52], Jin et al. [20], we modify it to use tighter Bernstein bonuses [73, 1], which is key to improving the guarantee. + +# 3 PROBLEM SETUP AND PRELIMINARIES + +The goal in reinforcement learning is to learn a policy $\pi ( \cdot | \mathbf { s } )$ that maximizes the expected cumulative discounted reward in a Markov decision process (MDP), which is defined by a tuple $( S , { \mathcal { A } } , P , r , \gamma )$ . + +$s , A$ represent state and action spaces, $P ( \mathbf { s } ^ { \prime } | \mathbf { s } , \mathbf { a } )$ and $r ( \mathbf { s } , \mathbf { a } )$ represent the dynamics and mean reward function, and $\gamma \in ( 0 , 1 )$ represents the discount factor. The effective horizon of the MDP is given by $H = 1 / ( 1 - \gamma )$ . The Q-function, $Q ^ { \pi } ( \mathbf { s } , \mathbf { a } )$ for a given policy $\pi$ is equal to the discounted long-term reward attained by executing a at the state s and then following policy $\pi$ thereafter. $Q ^ { \pi }$ satisfies the recursion: $\forall \mathbf { s } , \mathbf { a } \in \mathcal { S } \times \mathcal { A } , Q ^ { \pi } ( \mathbf { s } , \mathbf { a } ) = r ( \mathbf { s } , \mathbf { a } ) + \gamma \mathbb { E } _ { \mathbf { s ^ { \prime } } \sim P ( \cdot | \mathbf { s } , \mathbf { a } ) , \mathbf { a } ^ { \prime } \sim \pi ( \cdot | \mathbf { s } ^ { \prime } ) } \left[ Q ( \mathbf { s } ^ { \prime } , \mathbf { a } ^ { \prime } ) \right]$ . The value function $V ^ { \pi }$ considers the expectation of the Q-function over the policy $V ^ { \pi } ( { \bf s } ) = \mathbb { E } _ { { \bf a } \sim \pi ( \cdot | { \bf s } ) } \left[ Q ^ { \pi } ( { \bf s } , { \bf a } ) \right]$ . Meanwhile, the Q-function of the optimal policy, $Q ^ { * }$ , satisfies the recursion: $Q ^ { * } ( \mathbf { s } , \mathbf { a } ) = r ( \mathbf { s } , \mathbf { a } ) +$ $\mathbb { E } _ { { \mathbf { s } } ^ { \prime } \sim P ( \cdot | { \mathbf { s } } , { \mathbf { a } } ) } \left[ \operatorname* { m a x } _ { { \mathbf { a } } ^ { \prime } } Q ^ { * } \big ( { \mathbf { s } } ^ { \prime } , { \mathbf { a } } ^ { \prime } \big ) \right]$ , and the optimal value function is given by $V ^ { * } ( \mathbf { s } ) = \operatorname* { m a x } _ { \mathbf { a } } Q ^ { * } ( \mathbf { s } , \mathbf { a } )$ . Finally, the expected cumulative discounted reward is given by $J ( \pi ) = \mathbb { E } _ { \mathbf { s } _ { 0 } \sim \rho } \left[ V ^ { \pi } ( \mathbf { s } _ { 0 } ) \right]$ . + +In offline RL, we are provided with a dataset $\mathcal { D }$ of transitions, $\mathbf { \mathcal { D } } = \{ ( \mathbf { s } _ { i } , \mathbf { a } _ { i } , r _ { i } , \mathbf { s } _ { i } ^ { \prime } ) \} _ { i = 1 } ^ { N }$ of size $| \mathcal { D } | = N$ . We assume that the dataset $\mathcal { D }$ is generated i.i.d. from a distribution $\mu ( \mathbf { s } , \mathbf { a } )$ that specifies the effective behavior policy $\begin{array} { r } { \pi _ { \beta } ( \mathbf { a } | \mathbf { s } ) : = \mu ( \mathbf { s } , \mathbf { a } ) / \sum _ { \mathbf { a } } \mu ( \mathbf { s } , \mathbf { a } ) } \end{array}$ . Note that this holds even if the data itself is generated by running a non-Markovian policy $\pi _ { \beta }$ [48]. Let $n ( \mathbf { s } , \mathbf { a } )$ be the number of times $( \mathbf { s } , \mathbf { a } )$ appear in $\mathcal { D }$ , and $\widehat { P } ( \cdot | \mathbf { s } , \mathbf { a } )$ and ${ \widehat { r } } ( \mathbf { s } , \mathbf { a } )$ denote the empirical dynamics and reward distributions in $\mathcal { D }$ , which may be different from $P$ band $r$ due to stochasticity. Following Rashidinejad et al. [52], the goal is to minimize the suboptimality of the learned policy $\widehat { \pi }$ : + +$$ +\operatorname { S u b O p t } ( \widehat { \pi } ) = \mathbb { E } _ { \mathcal { D } \sim \mu } \left[ J ( \pi ^ { * } ) - J ( \widehat { \pi } ) \right] = \mathbb { E } _ { \mathcal { D } } \left[ \mathbb { E } _ { \mathbf { s } _ { 0 } \sim \rho } \left[ V ^ { * } ( \mathbf { s } _ { 0 } ) - V ^ { \widehat { \pi } } ( \mathbf { s } _ { 0 } ) \right] \right] . +$$ + +We will now define some conditions on the offline dataset and MDP structure that we will use in our analysis. The first characterizes the distribution shift between the data distribution $\mu ( \mathbf { s } , \mathbf { a } )$ and the normalized state-action marginal of $\pi ^ { * }$ , given by $\begin{array} { r } { d ^ { * } ( \mathbf { s } , \mathbf { a } ) = ( 1 - \gamma ) \sum _ { t = 0 } ^ { \infty } \gamma ^ { t } \mathbb { P } \left( \mathbf { s } _ { t } = s , \mathbf { a } _ { t } = a ; \pi ^ { * } \right) } \end{array}$ via a concentrability coefficient $C ^ { * }$ . + +Condition 3.1 (Rashidinejad et al. [52], Concentrability of the data distribution). Define $C ^ { * }$ to be the smallest, finite constant that satisfies: $d ^ { * } ( \mathbf { s } , \mathbf { a } ) / \mu ( \mathbf { s } , \mathbf { a } ) \leq C ^ { * } \forall \mathbf { s } \in S , \mathbf { a } \in \mathcal { A }$ . + +Intuitively, the coefficient $C ^ { * }$ formalizes how well the data distribution $\mu ( \mathbf { s } , \mathbf { a } )$ covers the state-action pairs visited under the optimal $\pi ^ { * }$ , where $C ^ { * } = 1$ corresponds to data from $\pi ^ { * }$ . If $\mu ( \mathbf { s } , \mathbf { a } )$ primarily covers state-action pairs that are not visited by $\pi ^ { * }$ , $C ^ { * }$ would be large. The next condition is that the return for any trajectory in the MDP is bounded by a constant, which w.l.o.g., we assume to be 1. + +Condition 3.2 (Ren et al. [53], thediscounted return for any trajectory $\tau = ( \mathbf { s } _ { 0 } , \mathbf { a } _ { 0 } , r _ { 0 } , \mathbf { s } _ { 1 } , \cdot \cdot \cdot )$ is bounded byis bounded as $\textstyle \sum _ { t = 0 } ^ { \infty } \gamma ^ { t } r _ { t } \leq 1$ -horizon. + +This condition holds in sparse-reward tasks, particularly those where an agent succeeds or fails at its task once per episode. This is common in domains such as robotics [60, 22] and games [4], where the agent receives a signal upon succeeding a task or winning. This condition also appears in prior work deriving suboptimality bounds for RL algorithms [53, 73]. Let $n \wedge 1 = \operatorname* { m a x } \{ n , 1 \}$ . Denote $\iota =$ $\mathrm { p o l y l o g } ( | \boldsymbol { S } | , H , N )$ . We let $\iota$ be a polylogarithmic quantity, changing with context. For $d$ -dimensional vectors $\mathbf { x } , \mathbf { y } , \mathbf { x } ( i )$ denotes its $i$ -th entry, and define $\begin{array} { r } { \mathbb { V } ( \mathbf { x } , \mathbf { \bar { y } } ) = \bar { \sum _ { i } } \mathbf { x } ( i ) \mathbf { y } ( i ) ^ { 2 } - ( \sum _ { i } \mathbf { x } ( i ) \mathbf { y } ( i ) ) ^ { 2 } } \end{array}$ . + +# 4 THEORETICAL COMPARISON OF BC AND OFFLINE RL + +In this section, we present performance guarantees for BC and offline RL, and characterize scenarios where offline RL algorithms will outperform BC. We first present general upper bounds for both algorithms in Section 4.1, by extending prior work to account for the conditions discussed in Section 3. Then, we compare the performance of BC and RL when provided with the same data generated by an expert in Section 4.2 and when RL is given noisy, suboptimal data in Section 4.3. Our goal is to characterize the conditions on the environment and offline dataset where RL can outperform BC. Furthermore, we provide intuition for when they are likely to hold in Appendix D. + +# 4.1 IMPROVED PERFORMANCE GUARANTEES OF BC AND OFFLINE RL + +Our goal is to understand if there exist offline RL methods that can outperform BC for a given task. As our aim is to provide a proof of existence, we analyze representative offline RL and BC algorithms that achieve optimal suboptimality guarantees. For brevity, we only consider a conservative offline RL algorithm (as defined in Section 2) in the main paper and defer analysis of a representative policy-constraint method to Appendix C. Both algorithms are described in Algorithms 1 and 2. + +Guarantees for BC. For analysis purposes, we consider a BC algorithm that matches the empirical behavior policy on states in the offline dataset, and takes uniform random actions outside the support of the dataset. This BC algorithm was also analyzed in prior work [49], and is no worse than other schemes for acting at out-of-support states in general. Denoting the learned BC policy as $\widehat { \pi } _ { \beta }$ , we have $\forall \mathbf { s } \in \mathcal { D } , \widehat { \pi } _ { \beta } ( \mathbf { a } | \mathbf { s } ) n ( \mathbf { s } , \mathbf { a } ) / n ( \mathbf { s } )$ , and $\forall \mathbf { s } \notin \mathcal { D } , \widehat { \pi } _ { \beta } ( \mathbf { a } | \mathbf { s } ) \gets 1 / | A |$ b. We adapt the results presented b bby Rajaraman et al. [49] to the setting with Conditions 3.1 and 3.2. BC can only incur a non-zero asymptotic suboptimality (i.e., does not decrease to 0 as $N \infty$ ) in scenarios where $C ^ { * } = 1$ , as it aims to match the data distribution $\mu ( \mathbf { s } , \mathbf { a } )$ , and a non-expert dataset will inhibit the cloned policy from matching the expert $\pi ^ { * }$ . The performance for BC is bounded in Theorem 4.1. + +Theorem 4.1 (Performance of BC). Under Conditions 3.1 and 3.2, the suboptimality of $B C$ satisfies + +$$ +\mathsf { S u b O p t } ( \widehat { \pi } _ { \beta } ) \lesssim \frac { ( C ^ { * } - 1 ) H } { 2 } + \frac { | \mathcal { S } | H \iota } { N } . +$$ + +A proof of Theorem 4.1 is presented in Appendix B.1. The first term is the additional suboptimality incurred due to discrepancy between the behavior and optimal policies. The second term in this bound is derived by bounding the expected visitation frequency of the learned policy $\widehat { \pi } _ { \beta }$ onto bstates not observed in the dataset. The analysis is similar to that for existing bounds for imitation learning [54, 49]. We achieve $\tilde { \mathcal { O } } ( H )$ suboptimality rather than $\tilde { \mathcal { O } } ( H ^ { 2 } )$ due to Condition 3.2, since the worst-case suboptimality of any trajectory is 1 rather than $H$ . + +Guarantees for conservative offline RL. We consider guarantees for a class of offline RL algorithms that maintain conservative value estimator such that the estimated value lower-bounds the true one, i.e., ${ \widehat { V } } ^ { \pi } \leq V ^ { \pi }$ for policy $\pi$ . Existing offline RL algorithms achieve this by subtracting a penalty from the reward, either explicitly [69, 24] or implicitly [27]. We only analyze one such algorithm that does the former, but we believe the algorithm can serve as a theoretical model for general conservative offline RL methods, where similar algorithms can be analyzed using the same technique. While the algorithm we consider is similar to VI-LCB , which was proposed by Rashidinejad et al. [52] and subtracts a penalty $b ( \mathbf { s } , \mathbf { a } )$ from the reward during value iteration, we use a different penalty that results in a tighter bound. The estimated Q-values are obtained by iteratively solving the following Bellman backup: $\begin{array} { r } { \widehat { Q } ( \mathbf { s } , \mathbf { a } ) \gets \widehat { r } ( \mathbf { s } , \mathbf { a } ) - b ( \mathbf { s } , \mathbf { a } ) + \sum _ { \mathbf { s } ^ { \prime } } \widehat { P } ( \mathbf { s } ^ { \prime } | \mathbf { s } , \mathbf { a } ) \operatorname* { m a x } _ { \mathbf { a } ^ { \prime } } \widehat { Q } ( \mathbf { s } ^ { \prime } , \mathbf { a } ^ { \prime } ) } \end{array}$ . The learned policy is then given by ${ \widehat { \pi } } ^ { * } ( \mathbf { s } ) \longleftarrow \arg \operatorname* { m a x } _ { \mathbf { a } } { \widehat { Q } } ( \mathbf { s } , \mathbf { a } )$ . The specific $b ( \mathbf { s } , \mathbf { a } )$ is derived using Bernstein’s inequality: + +$$ +b ( \mathbf { s } , \mathbf { a } ) \gets \sqrt { \frac { \mathbb { V } ( \widehat { P } ( \cdot | \mathbf { s } , \mathbf { a } ) , \widehat { V } ) \iota } { ( n ( \mathbf { s } , \mathbf { a } ) \wedge 1 ) } } + \sqrt { \frac { \widehat { r } ( \mathbf { s } , \mathbf { a } ) \iota } { ( n ( \mathbf { s } , \mathbf { a } ) \wedge 1 ) } } + \frac { \iota } { ( n ( \mathbf { s } , \mathbf { a } ) \wedge 1 ) } . +$$ + +The performance of the learned policy $\widehat { \pi } ^ { * }$ can then be bounded as: + +Theorem 4.2 (Performance of conservative offline RL). Under Conditions 3.1 and 3.2, the policy $\widehat { \pi } ^ { * }$ found by conservative offline $R L$ algorithm can satisfy + +$$ +\mathsf { S u b O p t } ( \widehat { \pi } ^ { * } ) \lesssim \sqrt { \frac { C ^ { * } | S | H \iota } { N } } + \frac { C ^ { * } | S | H \iota } { N } . +$$ + +We defer a proof for Theorem 4.2 to Appendix B.2. At a high level, we first show that our algorithm is always conservative, i.e., $\forall \mathbf { s }$ , ${ \widehat { V } } ( \mathbf { s } ) \leq V ^ { \widehat { \pi } ^ { * } } ( \mathbf { s } )$ , and then bound the total suboptimality incurred as a result of being conservative. Our bound in Theorem 4.2 improves on existing bounds several ways: (1) by considering pessimistic value estimates, we are able to remove the strict coverage assumptions used by Ren et al. [53], (2) by using variance recursion techniques on the Bernstein bonuses, with Condition 3.2, we save a $O ( H ^ { 2 } )$ factor over VI-LCB in Rashidinejad et al. [52], and (3) we shave a $| S |$ factor by introducing $s$ -absorbing MDPs for each state as in Agarwal et al. [1]. Building on this analysis of the representative offline RL method, we will now compare BC and offline RL under specific conditions on the MDP and dataset. + +# 4.2 COMPARISON UNDER EXPERT DATA + +We first compare the performance bounds from Section 4.1 when the offline dataset is generated from the expert. In relation to Condition 3.1, this corresponds to small $C ^ { * }$ . Specifically, we consider $C ^ { * } \in [ 1 , 1 \bar { + } \tilde { \mathcal { O } } ( 1 / N ) ]$ and in this case, the suboptimality of BC in Theorem 4.1 scales as $\tilde { \mathcal { O } } ( | S | H / N )$ In this regime, we perform a nuanced comparison by analyzing specific scenarios where RL may outperform BC. We consider the case of $C ^ { * } = 1$ and $C ^ { * } = 1 + \tilde { \mathcal { O } } ( 1 / N )$ separately. + +What happens when $C ^ { * } = 1 2$ In this case, we derive a lower-bound of $| S | H / N$ for any offline algorithm, by utilizing the analysis of Rajaraman et al. [49] and factoring in Condition 3.2. + +Theorem 4.3 (Information-theoretic lower-bound for offline learning with $C ^ { * } = 1 $ ). For any learner $\widehat { \pi }$ , there exists an MDP $\mathcal { M }$ satisfying Assumption 3.2, and a deterministic expert $\pi ^ { * }$ , such that the bexpected suboptimality of the learner is lower-bounded: + +$$ +\operatorname* { s u p } _ { \mathcal { M } , \pi ^ { * } } \mathrm { ~ S u b O p t } ( \widehat { \pi } ) \gtrsim \frac { | \mathcal { S } | H } { N } +$$ + +The proof of Theorem 4.3 uses the same hard instance from Theorem 6.1 of Rajaraman et al. [49], except that one factor of $H$ is dropped due to Condition 3.2. The other factor of $H$ arises from the performance difference lemma and is retained. In this case, where BC achieves the lower bound up to logarithmic factors, we argue that we cannot improve over BC. This is because the suboptimality of BC is entirely due to encountering states that do not appear in the dataset; without additional assumptions on the ability to generalize to unseen states, offline RL must incur the same suboptimality, as both methods would choose actions uniformly at random. + +Practical Observation 4.1. When no assumptions are made on the environment structure, both offline RL and BC perform equally poorly with trajectories from an expert demonstrator. + +However, we argue that even with expert demonstrations as data, $C ^ { * }$ may not exactly be 1. Na¨ıvely, it seems plausible that the expert that collected the dataset did not perform optimally at every transition; this is often true for humans, or stochastic experts such as $\epsilon$ -greedy or maximum-entropy policies. In addition, there are scenarios where $C ^ { * } > 1$ even though the expert behaves optimally: for example, when the environment is stochastic or in the presence of small distribution shifts in the environment. One practical example of this is when the initial state distribution changes between dataset collection and evaluation (e.g., in robotics [60], or self-driving [5]). Since the normalized state-action marginals $d ^ { * } ( \mathbf { s } , \mathbf { a } ) , \mu ( \mathbf { s } , \mathbf { a } )$ depend on $\rho ( \mathbf { s } )$ , this would lead to $C ^ { * } > 1$ even when the data collection policy acts exactly as the expert $\pi ^ { * }$ at each state. + +What happens when ${ \cal C } ^ { * } = 1 + \tilde { \mathcal { O } } ( 1 / N ) \Im \mathrm { \Lambda }$ Here $C ^ { * }$ is small enough that BC still achieves the same optimal $\tilde { \mathcal { O } } ( | S | H / N )$ performance guarantee. However, there is suboptimality incurred by BC even for states that appear in the dataset due to distribution shift, which allows us to argue about structural properties of MDPs that allow offline RL to perform better across those states, particularly for problems with large effective horizon $H$ . We discuss one such structure below. + +In several practical problem domains, the return of any trajectory can mostly be explained by the actions taken at a small fraction of states, which we call critical states. This can occur when there exist a large proportion of states in a trajectory where it is not costly to recover after deviating from the optimal trajectory, or when identifying an optimal trajectory is easy: this could be simply because there exists a large volume of near-optimal trajectories, or because at all but a few states, the volume of “good-enough” actions is large. Therefore, we would expect that offline RL can quickly identify and master such good-enough actions at a majority of the states while reward-agnostic BC would be unable to do so. + +Two examples are in robotic manipulation and navigation. In manipulation tasks such as grasping, if the robot is not near the object, it can take many different actions and still pick up the object by the end; this is because unless the object breaks, actions taken by the robot are typically reversible [21]. In this phase, the robot just needs to avoid performing actions that do not at all move it closer to the object since it will fail to grasp it, but it needs to know no more than a general sense of how to approach the object, which is easily identifiable from the reward information. It is only at a few “critical states” when the robot grasps the object, where the robot should be careful to not drop and break the object. + +![](images/1e1a0834532795f8d9fb2fd562098404d6df1f324a10f37603d456c6df49b7f7.jpg) +Figure 1: Illustration showing the intuition behind critical states. The agent is supposed to navigate to a high-reward region marked as the yellow polygon, without crashing into the walls. For different states, A, B and C that we consider, the agent has a high volume of actions that allow it to reach the goal at states A and C, but only few actions that allow it to do so at state B. States around A and C are not critical, and so this task has only a small volume of critical states (i.e., those in the thin tunnel). + +In navigation, as we pictorially illustrate in Figure 1, there may exist multiple paths that end at the same goal, particularly in large, unobstructed areas [55]. For example, while navigating through a wide tunnel, the exact direction the agent takes may not matter so much as multiple directions will take the agent through the tunnel, and identifying these good-enough actions using reward information is easy. However, there are “critical states” like narrow doorways where taking a specific action is important. Domains that do not satisfy this structure include cliffwalk environments, where a single incorrect action at any state will cause the agent to fall off the cliff. We can formally define one notion of critical states as follows: + +Definition 4.1 (Non-critical states). A state s is said to be non-critical (i.e., ${ \bf s } \notin \mathcal { C }$ ) if there exists a large subset $\mathcal { G } ( \mathbf { s } )$ of $\varepsilon$ -good actions, such that, + +$$ +' \mathbf { a } \in \mathcal { G } ( \mathbf { s } ) , \quad \operatorname* { m a x } _ { \mathbf { a } ^ { \prime } } Q ^ { * } ( \mathbf { s } , \mathbf { a } ^ { \prime } ) - Q ^ { * } ( \mathbf { s } , \mathbf { a } ) \leq \frac { \varepsilon } { H } , \ a n d \ \forall \mathbf { a } \in \mathcal { A } \setminus \mathcal { G } ( \mathbf { s } ) , \ \operatorname* { m a x } _ { \mathbf { a } ^ { \prime } } Q ^ { * } ( \mathbf { s } , \mathbf { a } ^ { \prime } ) - Q ^ { * } ( \mathbf { s } , \mathbf { a } ) \simeq \Delta +$$ + +Now the structural condition we consider is that for any policy, the total density of critical states, $\mathbf { s } \in \mathcal { C }$ is bounded by $p _ { c }$ , and we will control $p _ { c }$ for our bound. + +Condition 4.1 (Occupancy of critical states is small). Let $\exists p _ { c } \in ( 0 , 1 )$ such that for any policy $\pi$ the average occupancy of critical states is bounded above by $p _ { c }$ : $\begin{array} { r } { \sum _ { \mathbf { s } \in \mathcal { C } } \dot { d } ^ { \pi } ( \mathbf { s } ) \leq p _ { c } } \end{array}$ . + +We can show that, if the MDP satisfies the above condition with a small enough $p _ { c }$ and and the number of good actions $| \mathcal G ( \mathbf { s } ) |$ are large enough, then by controlling the gap $\Delta ( \mathbf { s } )$ between suboptimality of good and bad actions some offline RL algorithms can outperform BC. We perform this analysis under a simplified setting where the state-marginal distribution in the dataset matches that of the optimal policy and find that a policy constraint offline RL algorithm can outperform BC. We describe the informal statement below and discuss the details and a proof in Appendix B.3. + +Corollary 4.1 (Offline RL vs BC with critical states). Let the dataset distribution be such that $\forall \mathbf { s } , d ^ { \pi ^ { * } } ( \mathbf { s } ) = \mu ( \mathbf { s } )$ and all for state-action pairs $\forall ( \mathbf { s } , \mathbf { a } ) , n ( \mathbf { s } , \mathbf { a } ) \geq n _ { 0 }$ . Then, under Conditions 4.1 with $p _ { c } = 1 / H$ , 3.1 and 3.2 a policy $\widehat { \pi } ^ { * }$ found by policy constraint offline RL (Equation 10) satisfies + +$$ +\mathsf { S u b O p t } ( \widehat { \pi } ^ { * } ) \lesssim \mathsf { S u b O p t } ( \widehat { \pi } _ { B C } ) . +$$ + +The above statement indicates that when we encounter $\mathcal { O } ( 1 / H )$ critical states on average in any trajectory, then we can achieve better performance via offline RL than BC. In this simplified setting of full coverage over all states, the proof relies on showing that the particular offline RL algorithm we consider can collapse to good-enough actions at non-critical states quickly, whereas BC is unable to do so since it simply mimics the data distribution. On the other hand, BC and RL perform equally well at critical states. We can control the convergence rate of RL by adjusting $\Delta$ , and $| \mathcal G ( \mathbf { s } ) |$ , whereas BC does not benefit from this and incurs a suboptimality that matches the information-theoretic lower bound (Theorem 4.3). While this proof only considers one offline RL algorithm, we conjecture that it should be possible to generalize such an argument to the general family of offline RL algorithms. + +Practical Observation 4.2. Offline RL can be preferred over BC, even with expert or nearexpert data, when either the initial state distribution changes during deployment, or when the environment has a few “critical” states. + +# 4.3 COMPARISON UNDER NOISY DATA + +In practice, it is often much more tractable to obtain suboptimal demonstrations rather than expert ones. For example, suboptimal demonstrations can be obtained by running a scripted policy. From Theorem 4.1, we see that for $C ^ { * } = 1 + \Omega ( 1 / \sqrt { N } )$ , BC will incur suboptimality that is worse asymptotically than offline RL. In contrast, from Theorem 4.2, we note that offline RL does not scale nearly as poorly with increasing $C ^ { * }$ . Since offline RL is not as reliant on the performance of the behavior policy, we hypothesize that RL can actually benefit from suboptimal data when this improves coverage. In this section, we aim to answer the following question: Can offline RL with suboptimal data outperform BC with expert data? + +We show in Corollary 4.2 that, if the suboptimal dataset $\mathcal { D }$ satisfies an additional coverage condition, then running√ conservative offline RL can attain $\tilde { \mathcal { O } } ( \sqrt { H } )$ suboptimality in the horizon. This implies, perhaps surprisingly, that offline RL with suboptimal data can actually outperform BC, even when the latter is provided expert data. Formally: + +![](images/7fc0a5070c51fc4d8bc1ba6b0e0458f77da6c245ea59c4e78e8983c384354d43.jpg) +Figure 2: Illustration showing the intuition behind noisy data. BC trained on expert data (data composition is shown on the left) may diverge away from the expert and find a poor policy that does not solve the task. If offline RL is provided with noisy expert data that sometimes ventures away from the expert distribution, RL can use this data to learn to stay on the course to the goal. + +Condition 4.2 (Coverage of the optimal policy). $\exists b \in [ \log H / N , 1 )$ such that $\mu$ satisfies: $\forall ( \mathbf { s } , \mathbf { a } ) \in$ $\boldsymbol { s } \times \boldsymbol { A }$ where $d ^ { * } ( \mathbf { s } , \mathbf { a } ) \geq b / H$ , we have $\mu ( \mathbf { s } , \mathbf { a } ) \geq b$ . + +Intuitively, this means that the data distribution puts sufficient mass on states that have non-negligible density in the optimal policy distribution. Note that this is a weaker condition than prior works that require (1) full coverage of the state-action space, and (2) enforce a constraint on the empirical state-action visitations ${ \widehat { \mu } } ( \mathbf { s } , \mathbf { a } )$ instead of $\mu ( \mathbf { s } , \mathbf { a } )$ [53, 73]. This condition is reasonable when the dataset is collected by $\epsilon$ b-greedy or a maximum-entropy expert, which is a standard assumption in MaxEnt IRL [74]. Even if the expert is not noisy, we argue that in several real-world applications, creating noisy-expert data is feasible. In many robotics applications, it is practical to augment expert demonstrations with counterfactual data by using scripted exploration policies [21, 23]. Existing work has also simulated trajectories to increase coverage, as was done in self-driving by perturbing the vehicle location [5], or in robotics using learned simulators [51]. For intuition, we provide an illustrative example of the noisy data that can help offline RL in Figure 2. + +Corollary 4.2 (Performance of conservative offline RL with noisy data). If $\mu$ satisfies Condition 4.2, and under Conditions 3.1 and 3.2, the policy $\widehat { \pi } ^ { * }$ found by conservative offline RL can satisfy: + +$$ +\mathsf { S u b O p t } ( \widehat { \pi } ^ { * } ) \lesssim \sqrt { \frac { H \iota } { b N } } + \frac { H \iota } { b N } + \sqrt { b \iota } + \frac { C ^ { * } | S | \iota } { N } . +$$ + +If we take $b \sim \sqrt { H } / N$ , then SubOpt(π∗) ≲ O˜( H). + +The bound in Corollary 4.2 has $\tilde { \mathcal { O } } ( \sqrt { H } )$ scaling compared to $\tilde { \mathcal { O } } ( H )$ for BC. Thus, when the data satisfies the practical coverage conditions (more discussion in Appendix D), offline RL performs better in long-horizon tasks compared to BC with the same amount of expert data. + +Practical Observation 4.3. Offline RL outperforms BC on expert data on long-horizon tasks, when provided with noisy-expert data. Thus, if noisy-expert data is easy to collect (e.g., through scripted policies or by first running standard behavioral cloning, and then storing data from evaluations of the behavior-cloned policy), doing so and then using offline RL can lead to better results. + +# 4.4 COMPARISON OF GENERALIZED BC METHODS AND OFFLINE RL + +So far we have studied scenarios where offline RL can outperform na¨ıve BC. One might now wonder how offline RL methods perform relative to generalized BC methods that additionally use reward information to inform learning. We study two such approaches: (1) filtered BC [8], which only fits to the top $k$ -percentage of trajectories in $\mathcal { D }$ , measured by the total reward, and (2) BC with one-step policy improvement [6], which fits a Q-function for the behavior policy, then uses the values to perform one-step of policy improvement over the behavior policy. In this section, we aim to answer how these methods perform relative to RL. + +Filtered BC. In expectation, this algorithm uses $\alpha N$ samples of the offline dataset $\mathcal { D }$ for $\alpha \in [ 0 , 1 ]$ to perform BC on. This means that the upper bound (Theorem 4.1) will have worse scaling in $N$ . For $C ^ { * } = 1$ , this leads to a strictly worse bound than regular BC. However, for suboptimal data, the filtering step could decrease $C ^ { * }$ by filtering out suboptimal trajectories, allowing filtered BC to outperform traditional BC. Nevertheless, from our analysis in Section 4.3, offline RL is still preferred√ to filtered BC because RL can leverage the noisy data and potentially achieve $O ( { \sqrt { H } } )$ suboptimality, whereas even filtered BC would always incur a worse $O ( H )$ suboptimality. + +BC with policy improvement. This algorithm utilizes the entire dataset to estimate the Q-value of the behavior policy, ${ \widehat Q } ^ { \widehat \pi _ { \beta } }$ , and performs one step of policy improvement using the estimated Q-function, typically via an advantage-weighted update: $\widehat { \pi } ^ { 1 } ( \mathbf { a } | \mathbf { s } ) = \widehat { \pi } _ { \beta } ( \mathbf { a } | \mathbf { s } ) \exp ( \eta H \widehat { A } ^ { \widehat { \pi } _ { \beta } } ( \mathbf { s } , \mathbf { a } ) ) / \mathbb { Z } _ { 1 } ( \mathbf { s } )$ . When b bwould this algorithm perform poorly compared to offline $R L$ ? Intutively, this would happen when multiple steps of policy improvement are needed to effectively discover high-advantage actions under the behavior policy. This is the case when the the behavior policy puts low density on high-advantage transitions. In Theorem 4.4, we show that more than one step of policy improvement can improve the policy under Condition 4.2, for the special case of the softmax policy parameterization [2]. + +Theorem 4.4 (One-step is worse than $k$ -step policy improvement). Assume that the learned policies are represented via a softmax parameterization (Equation $^ 3$ , Agarwal et al. [2]). Let $\widehat { \pi } ^ { k }$ denote the policy obtained after $k$ -steps of policy improvement using exponentiated advantage weights. Then, under Condition 4.2, the performance difference between $\widehat { \pi } ^ { k }$ and $\widehat { \pi } ^ { 1 }$ is lower-bounded by: + +$$ +J ( \widehat { \pi } ^ { k } ) - J ( \widehat { \pi } ^ { 1 } ) \gtrsim \frac { k } { H \eta } \mathbb { E } _ { \mathbf { s } \sim \boldsymbol { \mu } } \left[ \frac { 1 } { k } \sum _ { t = 1 } ^ { k } \log \mathbb { Z } _ { t } ( \mathbf { s } ) \right] - \sqrt { \frac { C ^ { * } H \iota } { N } } . +$$ + +A proof of Theorem 4.4 is provided in Appendix B.5. This result implies that when the average exponentiated empirical advantage constant), which is usually the ca $1 / k \textstyle \sum _ { i = 1 } ^ { k } \log \mathbb { Z } _ { t } ( \mathbf { s } )$ is large enoughr policy is high $( i . e . , \ge c _ { 0 }$ for some univimal, then for $k =$ $\mathcal { O } ( H )$ , multiple steps of policy improvement will improve performance, i.e., $J ( { \widehat { \pi } } ^ { k } ) - J ( { \widehat { \pi } } ^ { 1 } ) =$ $\tilde { \mathcal { O } } ( H - \sqrt { H / N } )$ b b, where the gap increases with a longer horizon. This is typically the case when the structure of the MDP allow for stitching parts of poor-performing trajectories. One example is in navigation, where trajectories that fail may still contain segments of a successful trajectory. + +Practical Observation 4.4. Using multiple policy improvement steps (i.e., full offline RL) can lead to greatly improved performance on long-horizon tasks, particularly when parts of various trajectories can be concatenated or stitched together to give better performance. + +# 5 EMPIRICAL EVALUATION OF BC AND OFFLINE RL + +Having characterized scenarios where offline RL methods can outperform BC in theory, we now validate our results empirically. Concretely, we aim to answer the following questions: (1) Does an existing offline RL method trained on expert data outperform BC on expert data in MDPs with few critical points?, (2) Can offline RL trained on noisy data outperform BC on expert data?, and (3) How does full offline RL compare to the reward-aware BC methods studied in Section 4.4? We first validate our findings on high-dimensional domains below, but we provide some diagnostic experiments on a gridworld domain in Appendix H. + +Evaluation in high-dimensional tasks. Next, we turn to high-dimensional problems. We consider a diverse set of domains and behavior policies that are representative of practical scenarios: multi-stage robotic manipulation tasks from state (Adroit domains from Fu et al. [14]) and image observations [60], antmaze navigation [14], and 7 Atari games [3]. We use the scripted expert provided by Fu et al. [14] for antmaze and those provided by Singh et al. [60] for manipulation, an RL-trained expert for Atari, and human expert for Adroit [50]. We obtain suboptimal data using failed attempts from a noisy expert policy (i.e., previous policies in the replay buffer for Atari, and noisy scripted experts for antmaze and manipulation). All these tasks utilize sparse rewards such that the return of any trajectory is bounded by a constant much smaller than the horizon. We use CQL [27] as a representative RL method, and utilize Brandfonbrener et al. [6] as a representative BC-PI method. + +Tuning offline RL and BC. Na¨ıvely running offline RL can lead to poor performance, as noted by prior works [38, 12]. This is also true for BC, but, some solutions such as early stopping based on validation losses, can help improve performance. We claim that an offline tuning strategy is also crucial for offline RL. In our experiments we utilize the offline workflow proposed by Kumar et al. [30] to perform policy selection, and address overfitting and underfitting, purely offline. While this workflow does not fully address all the tuning issues, we find that it is sufficient to improve performance. When the Q-values learned by CQL are extremely negative (typically on the Adroit domains), we utilize a capacity-decreasing dropout regularization with probability 0.4 on the layers of the Q-function to combat overfitting. On the other hand, when the Q-values exhibit a relatively stable trend (e.g., in Antmaze or Atari), we utilize the DR3 regularizer [29] to increase capacity. Consistent with prior work, we find that na¨ıve offline RL generally performs worse than BC without offline tuning, but we find that tuned offline RL can work well. For tuning BC and BC-PI, we applied regularizers such as dropout on the policy to prevent overfitting in Adroit, and utilized a larger ResNet [18] architecture for the robotic manipulation tasks and Atari domains. For BC, we report the performance of the best checkpoint found during training, giving BC an unfair advantage, but we still find that offline-tuned offline RL can do better better. More details about tuning each algorithm can be found in Appendix F. + +Answers to questions (1) to (3). For (1), we run CQL and BC on expert data in each task, and present the comparison in Table 1 and Figure 3. While na¨ıve CQL performs comparable or worse than BC in this case, after offline tuning, CQL outperforms BC. This tuning does not require any additional online rollouts. Note that while BC performs better or comparable to RL for antmaze (large) with + +
Domain/Behavior PolicyTask/Data QualityBCNaive CQLTuned CQL
AntMaze (scripted)Medium,Expert Large,Expert53.2%±8.7% 4.83%±0.8%20.8% ±1.0% 0.0% ±0.0%55.9% ±3.2% 0.0% ±0.0%
Medium,Expert w/diverseinitial55.2%±6.7%19.0%±5.2%67.0% ± 7.3%
Large,Expert w/diverse initial1.3%±0.5%0.0%± 0.05.1% ± 6.9%
Manipulation (scripted)pick-place-open-grasp,Expert14.5%±1.8%12.3%±5.3%23.5%±6.0%
17.4%±3.1%20.0%±6.0%49.7%±5.4%
close-open-grasp,Expert open-grasp,Expert33.2%±8.1%22.8%±5.3%51.9%±6.8%
Adroit (Human)hammer-human,Expert71.0% ±9.3%62.5% ± 39.0%78.1% ± 6.7%
door-human,Expert86.3% ± 6.5%70.3% ± 27.2%79.1% ± 4.7%
pen-human,Expert73.0 % ± 9.1%64.0% ± 6.9%74.1% ± 6.1%
relocate-human,Expert0.0% ± 0.0%0.0% ±0.0%0.0% ± 0.0%
+ +Table 1: Offline CQL vs. BC with expert dataset compositions averaged over 3 seeds. While na¨ıve offline CQL often performs comparable or worse than BC, the performance of offline RL improves drastically after offline tuning. Also note that offline RL can improve when provided with diverse initial states in the Antmaze domain. Additionally, note that offline-tuned offline RL outperforms BC significantly in the manipulation domains. + +![](images/9d5547f26b83eb9e2b3fc850bb08247545252496bb0cf37451d6867b0382ccf4.jpg) +Figure 3: IQM performance of various algorithms evaluated on 7 Atari games under various dataset compositions (per game scores in Table 3). Note that offline-tuned CQL with expert data (“Tuned CQL”) outperforms cloning the expert data (“BC (Expert)”), even though na¨ıve CQL is comparable to BC in this setting. When CQL is provided with noisy-expert data, it significantly outperforms cloning the expert policy. + +expert data, it performs worse than RL when the data admits a more diverse initial state distribution such that $C ^ { * } \neq 1$ , even though the behavior policy matches the expert. + +For (2), we compare offline RL trained on noisyexpert data with BC trained on on an equal amount of expert data, on domains where noisyexpert data is easy to generate: (a) manipulation domains (Table 2) and (b) Atari games (Figure 3). Observe that CQL outperforms BC and also improves over only using expert data. The + +
TaskBC (Expert)CQL (Noisy Expert)
pick-place-open-grasp14.5%±1.8%85.7%±3.1%
close-open-grasp17.4% ±3.1%90.3% ±2.3%
open-grasp33.2% ±8.1%92.4% ± 4.9%
+ +Table 2: CQL with noisy-expert data vs BC with expert data with equal dataset size on manipulation tasks. CQL outperforms BC as well as CQL with only expert data. + +performance gap also increases with $H$ , i.e., open-grasp ( $H = 4 0$ ) vs pick-place-open-grasp $H = 8 0 ^ { \circ } ,$ ) vs Atari domains $H = 2 7 0 0 0$ ). This validates that some form of offline RL with noisy-expert data can outperform BC with expert data, particularly on long-horizon tasks. + +Finally, for (3), we compare CQL to a representative BC-PI method [6] trained using noisy-expert data on Atari domains, which present multiple stitching opportunities. The BC-PI method estimates the Q-function of the behavior policy using SARSA and then performs one-step of policy improvement. The results in Figure 3 support what is predicted by our theoretical results, i.e., BC-PI still performs significantly worse than CQL with noisy-expert data, even though we utilized online rollouts for tuning BC-PI and report the best hyperparameters found. + +# 6 DISCUSSION + +We sought to understand if offline RL is at all preferable over running BC, even provided with expert or near-expert data. While in the worst case, both approaches attain similar performance on expert data, additional assumptions on the environment can provide certain offline RL methods with an advantage. We also show that running RL on noisy-expert, suboptimal data attains more favorable guarantees compared to running BC on expert data for the same task, using equal amounts of data. Empirically, we observe that offline-tuned offline RL can outperform BC on various practical problem domains, with different kinds of expert policies. While our work is an initial step towards understanding when RL presents a favorable approach, there is still plenty of room for further investigation. Our theoretical analysis can be improved to handle function approximation. Understanding if offline RL is preferred over BC for other real-world data distributions is also important. Finally, our work focuses on analyzing cases where we might expect offline RL to outperform BC. An interesting direction is to understand cases where the opposite holds; such analysis would further contribute to this discussion. + +# ACKNOWLEDGEMENTS + +We thank Dibya Ghosh, Yi Su, Xinyang Geng, Tianhe Yu, Ilya Kostrikov and Michael Janner for informative discussions, Karol Hausman for providing feedback on an early version of this paper, and Bo Dai for answering some questions pertaining to Ren et al. [53]. AK thanks George Tucker for informative discussions. We thank the members of RAIL at UC Berkeley for their support and suggestions. We thank anonymous reviewers for feedback on an early version of this paper. This research is funded in part by the DARPA Assured Autonomy Program, the Office of Naval Research, an EECS departmental fellowship, and in part by compute resources from Google Cloud. + +# REFERENCES + +[1] Alekh Agarwal, Sham Kakade, and Lin F Yang. Model-based reinforcement learning with a generative model is minimax optimal. In Conference on Learning Theory, pp. 67–83. PMLR, 2020. +[2] Alekh Agarwal, Sham M Kakade, Jason D Lee, and Gaurav Mahajan. On the theory of policy gradient methods: Optimality, approximation, and distribution shift. Journal of Machine Learning Research, 22(98):1–76, 2021. +[3] Rishabh Agarwal, Dale Schuurmans, and Mohammad Norouzi. An optimistic perspective on offline reinforcement learning. In International Conference on Machine Learning (ICML), 2020. +[4] Marc G. Bellemare, Yavar Naddaf, Joel Veness, and Michael Bowling. The arcade learning environment: An evaluation platform for general agents. J. Artif. Int. Res., 47(1):253–279, May 2013. ISSN 1076-9757. +[5] Mariusz Bojarski, Davide Del Testa, Daniel Dworakowski, Bernhard Firner, Beat Flepp, Prasoon Goyal, Lawrence D Jackel, Mathew Monfort, Urs Muller, Jiakai Zhang, et al. End to end learning for self-driving cars. arXiv preprint arXiv:1604.07316, 2016. +[6] David Brandfonbrener, William F Whitney, Rajesh Ranganath, and Joan Bruna. Offline rl without off-policy evaluation. arXiv preprint arXiv:2106.08909, 2021. +[7] Jinglin Chen and Nan Jiang. Information-theoretic considerations in batch reinforcement learning. ICML, 2019. +[8] 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. +[9] Minmin Chen, Alex Beutel, Paul Covington, Sagar Jain, Francois Belletti, and Ed H Chi. Top-k off-policy correction for a reinforce recommender system. In Proceedings of the Twelfth ACM International Conference on Web Search and Data Mining, pp. 456–464, 2019. +[10] Lasse Espeholt, Hubert Soyer, Remi Munos, Karen Simonyan, Volodymyr Mnih, Tom Ward, ´ Yotam Doron, Vlad Firoiu, Tim Harley, Iain Dunning, Shane Legg, and Koray Kavukcuoglu. IMPALA: scalable distributed deep-rl with importance weighted actor-learner architectures. In International Conference on Machine Learning, 2018. +[11] Amir-massoud Farahmand, Csaba Szepesvari, and R ´ emi Munos. Error propagation for approxi-´ mate policy and value iteration. In Advances in Neural Information Processing Systems (NIPS), 2010. +[12] Pete Florence, Corey Lynch, Andy Zeng, Oscar A Ramirez, Ayzaan Wahid, Laura Downs, Adrian Wong, Johnny Lee, Igor Mordatch, and Jonathan Tompson. Implicit behavioral cloning. In 5th Annual Conference on Robot Learning, 2021. URL https://openreview.net/ forum?id ${ \underline { { \mathbf { \Pi } } } } =$ rif3a5NAxU6. +[13] Justin Fu, Aviral Kumar, Matthew Soh, and Sergey Levine. Diagnosing bottlenecks in deep Q-learning algorithms. arXiv preprint arXiv:1902.10250, 2019. + +[14] Justin Fu, Aviral Kumar, Ofir Nachum, George Tucker, and Sergey Levine. D4rl: Datasets for deep data-driven reinforcement learning, 2020. + +[15] Scott Fujimoto and Shixiang Shane Gu. A minimalist approach to offline reinforcement learning. arXiv preprint arXiv:2106.06860, 2021. + +[16] Scott Fujimoto, David Meger, and Doina Precup. Off-policy deep reinforcement learning without exploration. arXiv preprint arXiv:1812.02900, 2018. + +[17] Meera Hahn, Devendra Chaplot, Shubham Tulsiani, Mustafa Mukadam, James M. Rehg, and Abhinav Gupta. No rl, no simulation: Learning to navigate without navigating. In Advances in Neural Information Processing Systems, 2021. + +[18] Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 770–778, 2016. + +[19] Natasha Jaques, Judy Hanwen Shen, Asma Ghandeharioun, Craig Ferguson, Agata Lapedriza, Noah Jones, Shixiang Shane Gu, and Rosalind Picard. Human-centric dialog training via offline reinforcement learning. arXiv preprint arXiv:2010.05848, 2020. + +[20] Ying Jin, Zhuoran Yang, and Zhaoran Wang. Is pessimism provably efficient for offline rl? In International Conference on Machine Learning, pp. 5084–5096. PMLR, 2021. + +[21] Dmitry Kalashnikov, Alex Irpan, Peter Pastor, Julian Ibarz, Alexander Herzog, Eric Jang, Deirdre Quillen, Ethan Holly, Mrinal Kalakrishnan, Vincent Vanhoucke, et al. Scalable deep reinforcement learning for vision-based robotic manipulation. In Conference on Robot Learning, pp. 651–673, 2018. + +[22] Dmitry Kalashnikov, Alex Irpan, Peter Pastor, Julian Ibarz, Alexander Herzog, Eric Jang, Deirdre Quillen, Ethan Holly, Mrinal Kalakrishnan, Vincent Vanhoucke, et al. Scalable deep reinforcement learning for vision-based robotic manipulation. In Conference on Robot Learning, pp. 651–673. PMLR, 2018. + +[23] Dmitry Kalashnikov, Jacob Varley, Yevgen Chebotar, Benjamin Swanson, Rico Jonschkowski, Chelsea Finn, Sergey Levine, and Karol Hausman. Mt-opt: Continuous multi-task robotic reinforcement learning at scale. arXiv preprint arXiv:2104.08212, 2021. + +[24] Rahul Kidambi, Aravind Rajeswaran, Praneeth Netrapalli, and Thorsten Joachims. Morel: Model-based offline reinforcement learning. arXiv preprint arXiv:2005.05951, 2020. + +[25] Ilya Kostrikov, Jonathan Tompson, Rob Fergus, and Ofir Nachum. Offline reinforcement learning with fisher divergence critic regularization. arXiv preprint arXiv:2103.08050, 2021. + +[26] Aviral Kumar, Justin Fu, Matthew Soh, George Tucker, and Sergey Levine. Stabilizing off-policy q-learning via bootstrapping error reduction. In Advances in Neural Information Processing Systems, pp. 11761–11771, 2019. + +[27] Aviral Kumar, Aurick Zhou, George Tucker, and Sergey Levine. Conservative q-learning for offline reinforcement learning. arXiv preprint arXiv:2006.04779, 2020. + +[28] Aviral Kumar, Rishabh Agarwal, Dibya Ghosh, and Sergey Levine. Implicit underparameterization inhibits data-efficient deep reinforcement learning. In International Conference on Learning Representations, 2021. URL https://openreview.net/forum? id=O9bnihsFfXU. + +[29] Aviral Kumar, Rishabh Agarwal, Tengyu Ma, Aaron Courville, George Tucker, and Sergey Levine. DR3: Value-Based Deep Reinforcement Learning Requires Explicit Regularization. arXiv preprint arXiv:2112.04716, 2021. + +[30] Aviral Kumar, Anikait Singh, Stephen Tian, Chelsea Finn, and Sergey Levine. A workflow for offline model-free robotic reinforcement learning. In 5th Annual Conference on Robot Learning, 2021. URL https://openreview.net/forum?id=fy4ZBWxYbIo. + +[31] Vladislav Kurenkov and Sergey Kolesnikov. Showing your offline reinforcement learning work: Online evaluation budget matters. In Proceedings of the AAAI Conference on Artificial Intelligence, 2022. + +[32] Sascha Lange, Thomas Gabel, and Martin A. Riedmiller. Batch reinforcement learning. In Reinforcement Learning, volume 12. Springer, 2012. +[33] Romain Laroche, Paul Trichelair, and Remi Tachet Des Combes. Safe policy improvement with baseline bootstrapping. In International Conference on Machine Learning, pp. 3652–3661. PMLR, 2019. +[34] Sergey Levine, Aviral Kumar, George Tucker, and Justin Fu. Offline reinforcement learning: Tutorial, review, and perspectives on open problems. arXiv preprint arXiv:2005.01643, 2020. +[35] Yao Liu, Adith Swaminathan, Alekh Agarwal, and Emma Brunskill. Off-policy policy gradient with state distribution correction. CoRR, abs/1904.08473, 2019. +[36] Yao Liu, Adith Swaminathan, Alekh Agarwal, and Emma Brunskill. Provably good batch reinforcement learning without great exploration. arXiv preprint arXiv:2007.08202, 2020. +[37] Ajay Mandlekar, Fabio Ramos, Byron Boots, Silvio Savarese, Li Fei-Fei, Animesh Garg, and Dieter Fox. Iris: Implicit reinforcement without interaction at scale for learning control from offline robot manipulation data. In 2020 IEEE International Conference on Robotics and Automation (ICRA), pp. 4414–4420. IEEE, 2020. +[38] Ajay Mandlekar, Danfei Xu, Josiah Wong, Soroush Nasiriany, Chen Wang, Rohun Kulkarni, Fei-Fei Li, Silvio Savarese, Yuke Zhu, and Roberto Mart´ın-Mart´ın. What matters in learning from offline human demonstrations for robot manipulation. In 5th Annual Conference on Robot Learning, 2021. URL https://openreview.net/forum?id $=$ JrsfBJtDFdI. +[39] Andreas Maurer and Massimiliano Pontil. Empirical bernstein bounds and sample variance penalization. arxiv preprint arxiv:0907.3740, 2009. +[40] Volodymyr Mnih, Koray Kavukcuoglu, David Silver, Alex Graves, Ioannis Antonoglou, Daan Wierstra, and Martin Riedmiller. Playing atari with deep reinforcement learning. arXiv preprint arXiv:1312.5602, 2013. +[41] Remi Munos. Error bounds for approximate policy iteration. In ´ Proceedings of the Twentieth International Conference on International Conference on Machine Learning, ICML’03, pp. 560–567. AAAI Press, 2003. ISBN 1577351894. +[42] Remi Munos. Error bounds for approximate value iteration. In ´ AAAI Conference on Artificial intelligence (AAAI), pp. 1006–1011. AAAI Press, 2005. +[43] Ofir Nachum, Bo Dai, Ilya Kostrikov, Yinlam Chow, Lihong Li, and Dale Schuurmans. Algaedice: Policy gradient from arbitrary experience. arXiv preprint arXiv:1912.02074, 2019. +[44] Kimia Nadjahi, Romain Laroche, and Remi Tachet des Combes. Safe policy improvement with ´ soft baseline bootstrapping. arXiv preprint arXiv:1907.05079, 2019. +[45] Ashvin Nair, Murtaza Dalal, Abhishek Gupta, and Sergey Levine. Accelerating online reinforcement learning with offline datasets. arXiv preprint arXiv:2006.09359, 2020. +[46] Xue Bin Peng, Angjoo Kanazawa, Jitendra Malik, Pieter Abbeel, and Sergey Levine. Sfv: Reinforcement learning of physical skills from videos. ACM Transactions On Graphics (TOG), 37(6):1–14, 2018. +[47] Xue Bin Peng, Aviral Kumar, Grace Zhang, and Sergey Levine. Advantage-weighted regression: Simple and scalable off-policy reinforcement learning. arXiv preprint arXiv:1910.00177, 2019. +[48] Martin L Puterman. Markov Decision Processes: Discrete Stochastic Dynamic Programming. John Wiley & Sons, Inc., 1994. +[49] Nived Rajaraman, Lin F Yang, Jiantao Jiao, and Kannan Ramachandran. Toward the fundamental limits of imitation learning. arXiv preprint arXiv:2009.05990, 2020. + +[50] Aravind Rajeswaran, Vikash Kumar, Abhishek Gupta, Giulia Vezzani, John Schulman, Emanuel Todorov, and Sergey Levine. Learning complex dexterous manipulation with deep reinforcement learning and demonstrations. In Robotics: Science and Systems, 2018. + +[51] 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, pp. 11157–11166, 2020. + +[52] Paria Rashidinejad, Banghua Zhu, Cong Ma, Jiantao Jiao, and Stuart Russell. Bridging offline reinforcement learning and imitation learning: A tale of pessimism. arXiv preprint arXiv:2103.12021, 2021. + +[53] Tongzheng Ren, Jialian Li, Bo Dai, Simon S Du, and Sujay Sanghavi. Nearly horizon-free offline reinforcement learning. arXiv preprint arXiv:2103.14077, 2021. + +[54] Stephane Ross and Drew Bagnell. Efficient reductions for imitation learning. In ´ International Conference on Artificial Intelligence and Statistics (AISTATS), pp. 661–668, 2010. + +[55] Manolis Savva, Abhishek Kadian, Oleksandr Maksymets, Yili Zhao, Erik Wijmans, Bhavana Jain, Julian Straub, Jia Liu, Vladlen Koltun, Jitendra Malik, Devi Parikh, and Dhruv Batra. Habitat: A Platform for Embodied AI Research. In Proceedings of the IEEE/CVF International Conference on Computer Vision (ICCV), 2019. + +[56] Tom Schaul, John Quan, Ioannis Antonoglou, and David Silver. Prioritized experience replay. International Conference on Learning Representations (ICLR), 2015. + +[57] Dhruv Shah, Benjamin Eysenbach, Gregory Kahn, Nicholas Rhinehart, and Sergey Levine. Ving: Learning open-world navigation with visual goals. In 2021 IEEE International Conference on Robotics and Automation (ICRA), pp. 13215–13222. IEEE, 2021. + +[58] Susan M Shortreed, Eric Laber, Daniel J Lizotte, T Scott Stroup, Joelle Pineau, and Susan A Murphy. Informing sequential clinical decision-making through reinforcement learning: an empirical study. Machine learning, 84(1-2):109–136, 2011. + +[59] Noah Y Siegel, Jost Tobias Springenberg, Felix Berkenkamp, Abbas Abdolmaleki, Michael Neunert, Thomas Lampe, Roland Hafner, and Martin Riedmiller. Keep doing what worked: Behavioral modelling priors for offline reinforcement learning. arXiv preprint arXiv:2002.08396, 2020. + +[60] Avi Singh, Albert Yu, Jonathan Yang, Jesse Zhang, Aviral Kumar, and Sergey Levine. Cog: Connecting new skills to past experience with offline reinforcement learning. arXiv preprint arXiv:2010.14500, 2020. + +[61] Samarth Sinha, Ajay Mandlekar, and Animesh Garg. S4RL: Surprisingly simple self-supervision for offline reinforcement learning in robotics. In 5th Annual Conference on Robot Learning, 2021. URL https://openreview.net/forum?id $\bar { }$ 8xC5NNej-l_. + +[62] Adith Swaminathan and Thorsten Joachims. Batch learning from logged bandit feedback through counterfactual risk minimization. J. Mach. Learn. Res, 16:1731–1755, 2015. + +[63] L. Wang, Wei Zhang, Xiaofeng He, and H. Zha. Supervised reinforcement learning with recurrent neural network for dynamic treatment recommendation. Proceedings of the 24th ACM SIGKDD International Conference on Knowledge Discovery & Data Mining, 2018. + +[64] Ruosong Wang, Dean Foster, and Sham M. Kakade. What are the statistical limits of offline $\{ \mathrm { r l } \}$ with linear function approximation? In International Conference on Learning Representations, 2021. URL https://openreview.net/forum?id=30EvkP2aQLD. + +[65] Ziyu Wang, Alexander Novikov, Konrad Zołna, Jost Tobias Springenberg, Scott Reed, Bobak ˙ Shahriari, Noah Siegel, Josh Merel, Caglar Gulcehre, Nicolas Heess, et al. Critic regularized regression. arXiv preprint arXiv:2006.15134, 2020. + +[66] Yifan Wu, George Tucker, and Ofir Nachum. Behavior regularized offline reinforcement learning. arXiv preprint arXiv:1911.11361, 2019. + +[67] Tengyang Xie and Nan Jiang. $\mathrm { Q ^ { * } }$ approximation schemes for batch reinforcement learning: A eoretical comparison. 2020. +[68] Tengyang Xie, Ching-An Cheng, Nan Jiang, Paul Mineiro, and Alekh Agarwal. Bellmanconsistent pessimism for offline reinforcement learning. arXiv preprint, 2021. +[69] Tianhe Yu, Garrett Thomas, Lantao Yu, Stefano Ermon, James Zou, Sergey Levine, Chelsea Finn, and Tengyu Ma. Mopo: Model-based offline policy optimization. arXiv preprint arXiv:2005.13239, 2020. +[70] Tianhe Yu, Aviral Kumar, Rafael Rafailov, Aravind Rajeswaran, Sergey Levine, and Chelsea Finn. Combo: Conservative offline model-based policy optimization. arXiv preprint arXiv:2102.08363, 2021. +[71] Andrea Zanette. Exponential lower bounds for batch reinforcement learning: Batch rl can be exponentially harder than online rl. arXiv preprint arXiv:2012.08005, 2020. +[72] Yufeng Zhang, Qi Cai, Zhuoran Yang, Yongxin Chen, and Zhaoran Wang. Can temporaldifference and q-learning learn representation? a mean-field theory. arXiv preprint arXiv:2006.04761, 2020. +[73] Zihan Zhang, Xiangyang Ji, and Simon Du. Is reinforcement learning more difficult than bandits? a near-optimal algorithm escaping the curse of horizon. In Conference on Learning Theory, pp. 4528–4531. PMLR, 2021. +[74] B. D. Ziebart, A. Maas, J. A. Bagnell, and A. K. Dey. Maximum entropy inverse reinforcement learning. In International Conference on Artificial Intelligence (AAAI), 2008. + +# Appendices + +A PSEUDOCODE FOR ALGORITHMS + +# Algorithm 1 Conservative Offline RL Algorithm + +Require: Offline dataset $\mathcal { D }$ , discount factor $\gamma$ , and confidence level $\delta$ +1: Compute $n ( \mathbf { s } , \mathbf { a } )$ from $\mathcal { D }$ , and estimate ${ \widehat { r } } ( \mathbf { s } , \mathbf { a } )$ , $\widehat { P } ( s ^ { \prime } | { \bf s } , { \bf a } )$ , $\forall ( \mathbf { s } , \mathbf { a } ) \in \mathcal { S } \times \mathcal { A }$ +2: Initialize $\widehat { Q } ( \mathbf { s } , \mathbf { a } ) \gets 0 , \widehat { V } ( \mathbf { s } ) \gets 0$ , $\forall ( \mathbf { s } , \mathbf { a } )$ +3: for $i = 1 , 2 , \dots , m$ do +4: Calculate $b ( \mathbf { s } , \mathbf { a } )$ as: + +$$ +b ( \mathbf { s } , \mathbf { a } ) \gets \sqrt { \frac { \mathbb { V } ( \widehat { P } ( \mathbf { s } , \mathbf { a } ) , \widehat { V } ) \log ( | \mathcal { S } | | \mathcal { A } | m / \delta ) ) } { ( n ( \mathbf { s } , \mathbf { a } ) \wedge 1 ) } } + \sqrt { \frac { \widehat { r } ( \mathbf { s } , \mathbf { a } ) \log ( | \mathcal { S } | | \mathcal { A } | m / \delta ) } { ( n ( \mathbf { s } , \mathbf { a } ) \wedge 1 ) } } + \frac { \log ( | \mathcal { S } | | \mathcal { A } | m / \delta ) } { ( n ( \mathbf { s } , \mathbf { a } ) \wedge 1 ) } +$$ + +5: Calculate $\widehat { \pi } ^ { * } ( \mathbf { s } )$ as: + +$$ +\begin{array} { r l } & { \widehat { Q } ( \mathbf { s } , \mathbf { a } ) \xleftarrow { \widehat { r } } ( \mathbf { s } , \mathbf { a } ) - b ( \mathbf { s } , \mathbf { a } ) + \gamma \widehat { P } ( \mathbf { s } , \mathbf { a } ) \cdot \widehat { V } } \\ & { \quad \widehat { V } ( \mathbf { s } ) \xleftarrow { \widehat { V } } _ { a } \times \widehat { Q } ( \mathbf { s } , \mathbf { a } ) } \\ & { \quad \widehat { \pi } ^ { * } ( \mathbf { s } ) \xleftarrow { \relax } \underset { a } { \arg \operatorname* { m a x } } \widehat { Q } ( \mathbf { s } , \mathbf { a } ) } \end{array} +$$ + +6: Return π∗ + +# Algorithm 2 Policy-Constraint Offline RL Algorithm + +Require: Offline dataset $\mathcal { D }$ , discount factor $\gamma$ , and threshold $b$ + +1: Compute $n ( \mathbf { s } , \mathbf { a } )$ from $\mathcal { D }$ , and estimate ${ \widehat { r } } ( \mathbf { s } , \mathbf { a } )$ , $\widehat { P } ( s ^ { \prime } | { \bf s } , { \bf a } )$ , µ(s, a), ∀(s, a) ∈ S × A +2: Compute $\zeta ( \mathbf { s } , \mathbf { a } ) \gets \mathbb { I } \{ \widehat { \mu } ( \mathbf { s } , \mathbf { a } ) \geq b \}$ , $\forall ( \mathbf { s } , \mathbf { a } )$ +3: Initialize $\begin{array} { r } { \widehat { \pi } ^ { * } ( \mathbf { a } | \mathbf { s } ) \gets \frac { 1 } { | \mathcal { A } | } } \end{array}$ , $\widehat { Q } _ { \zeta } ^ { \widehat { \pi } ^ { * } } ( \mathbf { s } , \mathbf { a } ) \gets 0$ , $\widehat { V } _ { \zeta } ^ { \widehat { \pi } ^ { * } } ( \mathbf { s } ) \gets 0$ , ∀(s, a) +4: for $\ell = 1 , 2 , \ldots , k$ do +5: for $i = 1 , 2 , \dots , m$ do +6: Update $\widehat { Q } _ { \zeta } ^ { \widehat { \pi } ^ { * } } ( \mathbf { s } , \mathbf { a } ) , \widehat { V } _ { \zeta } ^ { \widehat { \pi } ^ { * } } ( \mathbf { s } )$ as: + +$$ +\begin{array} { l } { { \displaystyle \widehat { Q } _ { \zeta } ^ { \widehat \pi ^ { * } } ( \mathbf { s } , \mathbf { a } ) \gets \widehat { r } ( \mathbf { s } , \mathbf { a } ) + \gamma \widehat { P } ( \mathbf { s } , \mathbf { a } ) \cdot \widehat { V } _ { \zeta } ^ { \widehat \pi ^ { * } } } } \\ { { \displaystyle \widehat { V } _ { \zeta } ^ { \widehat \pi ^ { * } } ( \mathbf { s } ) \gets \sum _ { \mathbf { a } } \widehat { \pi } ^ { * } ( \mathbf { a } \vert \mathbf { s } ) \zeta ( \mathbf { s } , \mathbf { a } ) \cdot \widehat { Q } ( \mathbf { s } , \mathbf { a } ) } } \end{array} +$$ + +7: Compute $\widehat { \pi } ^ { * }$ as: + +$$ +\widehat { \pi } ^ { * } \gets \arg \operatorname* { m a x } _ { \pi } \mathbb { E } _ { \mathbf { s } \sim \mathcal { D } } \left[ \mathbb { E } _ { \mathbf { a } \sim \pi ^ { \prime } } \left[ \zeta ( \mathbf { s } , \mathbf { a } ) \cdot \widehat { Q } _ { \zeta } ^ { \pi } ( \mathbf { s } , \mathbf { a } ) \right] \right] +$$ + +8: Return $\widehat { \pi } ^ { * }$ . + +# B PROOFS + +# B.1 PROOF OF THEOREM 4.1 + +Let $\pi _ { \beta }$ be the behavior policy that we fit our learned policy $\widehat { \pi } _ { \beta }$ to. Recall that the BC algorithm we analyze fits $\widehat { \pi } _ { \beta }$ bto choose actions according to the empirical dataset distribution for states that appear in dataset $\mathcal { D }$ b, and uniformly at random otherwise. We have + +$$ +\mathbb { E } _ { \mathcal { D } } \left[ J ( \pi ^ { * } ) - J ( \widehat { \pi } _ { \beta } ) \right] \leq J ( \pi ^ { * } ) - J ( \pi _ { \beta } ) + \mathbb { E } _ { \mathcal { D } } \left[ J ( \pi _ { \beta } ) - J ( \widehat { \pi } _ { \beta } ) \right] +$$ + +The following lemma from Rajaraman et al. [49] bounds the suboptimality from performing BC on a (potentially stochastic) expert, which we adapt below factoring in bounded returns of trajectories from Condition 3.2. + +Lemma B.1 (Theorem 4.4, Rajaraman et al. [49]). The policy returned by BC on behavior policy $\pi _ { \beta }$ has expected error bounded as + +$$ +\mathbb { E } _ { \mathcal { D } } \left[ J ( \pi _ { \beta } ) - J ( \widehat { \pi } _ { \beta } ) \right] \leq \frac { S H \log N } { N } , +$$ + +where $\pi _ { \beta }$ could be stochastic. + +Using Lemma B.1, we have $\mathbb { E } _ { \mathcal { D } } \left[ J ( \pi _ { \beta } ) - J ( \widehat { \pi } _ { \beta } ) \right] \ \leq \ S H \iota / N$ . What remains is bounding the bsuboptimality of the behavior policy, which we can upper-bound as + +$$ +\begin{array} { r l } { J ( \pi ^ { * } ) - J ( \pi _ { \mathcal { B } } ) \le \displaystyle \sum _ { t = 0 } ^ { \infty } \sum _ { 0 } ^ { t } \gamma ^ { t } \mathbb { P } ( s _ { t } = s ) \mathbb { E } _ { \pi _ { \mathcal { B } } ( \cdot ( s ) ) } [ \| \mathbf { i } ( \mathbf { a } \neq \pi _ { t } ^ { * } ( s ) ) \| } & { } \\ & { = \frac { 1 } { 2 } \displaystyle \sum _ { t = 0 } ^ { \infty } \sum _ { s } \gamma ^ { t } d _ { t } ^ { * } ( s ) \sum _ { \mathbf { u } } | \pi _ { \mathcal { B } } ( \mathbf { a } | \mathbf { s } ) - 1 \{ \mathbf { a } = \pi _ { t } ^ { * } ( s ) \} } \\ & { = \frac { 1 } { 2 } \displaystyle \sum _ { t = 0 } ^ { \infty } \sum _ { 0 } ^ { t } \gamma ^ { t } | d _ { t } ^ { * } ( s ) \pi _ { \mathcal { B } } ( \mathbf { a } | \mathbf { s } ) - d _ { t } ^ { * } ( \mathbf { s } , \mathbf { a } ) | } \\ & { \le \frac { C ^ { * } - 1 } { 2 } H \displaystyle \sum _ { ( s , \mathbf { u } ) } \mu ( s , \mathbf { a } ) } \\ & { = \frac { ( C ^ { * } - 1 ) H } { 2 } , } \end{array} +$$ + +where we use the definition of $C ^ { * }$ in Condition 3.1. Taking the sum of both terms yields the desired result. + +# B.2 PROOF OF THEOREM 4.2 + +In this section, we proof the performance guarantee for the conservative offline RL algorithm detailed in Algorithm 1. Recall that the algorithm we consider builds upon empirical value iteration but subtracts a penalty during each $Q$ -update. Specifically, we initialize $\bar { Q _ { 0 } ( \mathbf { s } , \mathbf { a } ) } = 0 , V _ { 0 } ( \mathbf { s } ) = 0$ for all $( \mathbf { s } , \mathbf { a } )$ . Let $n ( \mathbf { s } , \mathbf { a } )$ be the number of times $( \mathbf { s } , \mathbf { a } )$ appeared in $\mathcal { D }$ , and let ${ \widehat { r } } ( \mathbf { s } , \mathbf { a } )$ , $\widehat { P } ( \mathbf { s } , \mathbf { a } )$ be the bempirical estimates of their reward and transition probabilities. Then, for each iteration $i \in [ m ]$ : + +$$ +\begin{array} { r l } & { \widehat { Q } _ { i } ( \mathbf { s } , \mathbf { a } ) \gets \widehat { r } ( \mathbf { s } , \mathbf { a } ) \qquad + \gamma \widehat { P } ( \mathbf { s } , \mathbf { a } ) \cdot \widehat { V } _ { i - 1 } , \quad \mathrm { f o r ~ a l l ~ \mathbf { s } , \mathbf { a } , } } \\ & { \qquad \widehat { V } _ { i } ( \mathbf { s } ) \gets \operatorname* { m a x } \{ \widehat { V } _ { t - 1 } ( \mathbf { s } ) , \operatorname* { m a x } _ { a } \widehat { Q } _ { i } ( \mathbf { s } , \mathbf { a } ) \} , \quad \mathrm { f o r ~ a l l ~ } s , } \end{array} +$$ + +In our algorithm we define the penalty function as + +$$ +b _ { i } ( { \mathbf s } , { \mathbf a } ) \gets \sqrt { \frac { \mathbb { V } ( \widehat { P } ( { \mathbf s } , { \mathbf a } ) , \widehat { V } _ { i - 1 } ) \boldsymbol { \iota } } { ( n ( { \mathbf s } , { \mathbf a } ) \wedge 1 ) } } + \sqrt { \frac { \widehat { r } ( { \mathbf s } , { \mathbf a } ) \boldsymbol { \iota } } { ( n ( { \mathbf s } , { \mathbf a } ) \wedge 1 ) } } + \frac { \boldsymbol { \iota } } { ( n ( { \mathbf s } , { \mathbf a } ) \wedge 1 ) } , +$$ + +where we let $\iota$ to capture all poly-logarithmic terms. As notation, we drop the subscript $i$ to denote the final $\widehat { Q }$ and $\widehat { V }$ at iteration $m$ , where $m = H \log N$ . Finally, the learned policy $\widehat { \pi } ^ { * }$ satisfies ${ \widehat { \pi } } ^ { * } ( \mathbf { s } ) \in \arg \operatorname* { m a x } _ { a } { \widehat { Q } } ( \mathbf { s } , \mathbf { a } )$ for all $s$ , if multiple such actions exist, then the policy samples an action buniformly at random. + +# B.2.1 TECHNICAL LEMMAS + +Lemma B.2 (Bernstein’s inequality). Let $\boldsymbol { X } , \{ X _ { i } \} _ { i = 1 } ^ { n }$ be i.i.d random variables with values in $[ 0 , 1 ]$ and let $\delta > 0$ . Then we have + +$$ +\mathbb P \left( \left| \mathbb E \left[ X \right] - \frac { 1 } { n } \sum _ { i = 1 } ^ { n } X _ { i } \right| > \sqrt { \frac { 2 \mathrm { V a r } \left[ X \right] \log ( 2 / \delta ) } { n } } + \frac { \log ( 2 / \delta ) } { n } \right) \le \delta . +$$ + +Lemma B.3 (Theorem 4, Maurer & Pontil [39]). Let $\ X , \{ X _ { i } \} _ { i = 1 } ^ { n }$ with $n \geq 2$ be i.i.d random variables with values in [0, 1]. Define $\begin{array} { r } { \bar { X } = \frac { 1 } { n } \sum _ { i = 1 } ^ { n } X _ { i } } \end{array}$ and $\textstyle \widehat { \operatorname { V a r } } ( X ) = { \frac { 1 } { n } } \sum _ { i = 1 } ^ { n } ( X _ { i } - { \bar { X } } ) ^ { 2 }$ . Let $\delta > 0$ . Then we have + +$$ +\mathbb { P } \left( \left| \mathbb { E } \left[ X \right] - \frac { 1 } { n } \sum _ { i = 1 } ^ { n } X _ { i } \right| > \sqrt { \frac { 2 \widehat { \mathrm { V a r } } ( \bar { X } ) \log ( 2 / \delta ) } { n - 1 } } + \frac { 7 \log ( 2 / \delta ) } { 3 ( n - 1 ) } \right) \le \delta . +$$ + +Lemma B.4 (Lemma 4, Ren et al. [53]). Let $\lambda _ { 1 } , \lambda _ { 2 } > 0$ be constants. Let $f : \mathbb { Z } _ { \ge 0 } \to \mathbb { R }$ be $a$ function such that $f ( i ) \leq H$ , ∀i and $f ( i )$ satisfies the recursion + +$$ +f ( i ) \leq \sqrt { \lambda _ { 1 } f ( i + 1 ) } + \lambda _ { 1 } + 2 ^ { i + 1 } \lambda _ { 2 } . +$$ + +Then, we have that $f ( 0 ) \leq 6 ( \lambda _ { 1 } + \lambda _ { 2 } )$ . + +# B.2.2 PESSIMISM GUARANTEE + +The first thing we want to show is that with high probability, the algorithm provides pessimistic value estimates, namely that $\widehat { V } _ { i } ( \mathbf { s } ) \leq V ^ { * } ( \mathbf { s } )$ for all $t \in [ T ]$ and $\mathbf { s } \in { \mathcal { S } }$ . To do so, we introduce a notion of a “good” event, which occurs when our empirical estimates of the MDP are not far from the true MDP. We define ${ \mathcal { E } } _ { 1 }$ to be the event where + +$$ +\begin{array} { r } { \left| ( \widehat { P } ( { \mathbf s } , { \mathbf a } ) - P ( { \mathbf s } , { \mathbf a } ) ) \cdot \widehat { V } _ { i } \right| \leq \sqrt { \frac { \mathbb { V } ( \widehat { P } ( { \mathbf s } , { \mathbf a } ) , \widehat { V } _ { i } ) \iota } { ( n ( { \mathbf s } , { \mathbf a } ) \wedge 1 ) } } + \frac { \iota } { ( n ( { \mathbf s } , { \mathbf a } ) \wedge 1 ) } } \end{array} +$$ + +holds for all $i \in [ m ]$ and $( \mathbf { s } , \mathbf { a } ) \in \mathcal { S } \times \mathcal { A }$ . We also define ${ \mathcal { E } } _ { 2 }$ to be the event where + +$$ +| \widehat { r } ( \mathbf { s } , \mathbf { a } ) - r ( \mathbf { s } , \mathbf { a } ) | \leq \sqrt { \frac { \widehat { r } ( \mathbf { s } , \mathbf { a } ) \iota } { ( n ( \mathbf { s } , \mathbf { a } ) \wedge 1 ) } } + \frac { \iota } { ( n ( \mathbf { s } , \mathbf { a } ) \wedge 1 ) } +$$ + +holds for all $( \mathbf { s } , \mathbf { a } )$ + +We want to show that the good event $\mathcal { E } = \mathcal { E } _ { 1 } \cap \mathcal { E } _ { 2 }$ occurs with high probability. The proof mostly follows from Bernstein’s inequality in Lemma B.2 . Note that because $\widehat { \cal P } ( { \bf s } , { \bf a } ) , \widehat { V } _ { i }$ are not independent, we cannot straightforwardly apply Bernstein’s inequality. We instead use the approach of Agarwal et al. [1] who, for each state $s$ , partition the range of $\widehat { V } _ { i } ( \mathbf { s } )$ within a modified $s$ -absorbing MDP to create independence from $\widehat { P }$ . The following lemma from Agarwal et al. [1] is a result of such analysis, and is slightly modified below to account for bounded returns of trajectories, i.e., $\widehat { V } _ { i } ( \mathbf { s } ) \leq 1$ : + +Lemma B.5 (Lemma 9, Agarwal et al. [1]). For any iteration $t$ , state-action $( \mathbf { s } , \mathbf { a } ) \in \mathcal { S } \times \mathcal { A }$ such that $n ( \mathbf { s } , \mathbf { a } ) \geq 1$ , and $\delta > 0$ , we have + +$$ +\mathbb { P } \left( \left| \left( \widehat { P } ( \mathbf { s } , \mathbf { a } ) - P ( \mathbf { s } , \mathbf { a } ) \right) \cdot \widehat { V } _ { i } \right| > \sqrt { \frac { \mathbb { V } ( \widehat { P } ( \mathbf { s } , \mathbf { a } ) , \widehat { V } _ { i } ) \iota } { n ( \mathbf { s } , \mathbf { a } ) } } + \frac \iota { n ( \mathbf { s } , \mathbf { a } ) } \right) \leq \delta . +$$ + +Using this, we can show that $\mathcal { E }$ occurs with high probability: + +Lemma B.6. $\mathbb { P } \left( \mathcal { E } \right) \geq 1 - 2 | S | | \mathcal { A } | m \delta$ . + +Proof. For each $i$ and $( \mathbf { s } , \mathbf { a } )$ , if $n ( \mathbf { s } , \mathbf { a } ) ~ \leq ~ 1$ , then equation 3 and equation 4 hold trivially. For $n ( \mathbf { s } , \mathbf { a } ) \geq 2$ , we have from Lemma B.5 that + +$$ +\mathbb { P } \left( \left| \left( \widehat { P } ( \mathbf { s } , \mathbf { a } ) - P ( \mathbf { s } , \mathbf { a } ) \right) \cdot \widehat { V } _ { i } \right| > \sqrt { \frac { \mathbb { V } ( \widehat { P } ( \mathbf { s } , \mathbf { a } ) , \widehat { V } _ { i } ) \iota } { n ( \mathbf { s } , \mathbf { a } ) } } + \frac \iota { n ( \mathbf { s } , \mathbf { a } ) } \right) \leq \delta . +$$ + +Similarly, we can use Lemma B.3 to derive + +$$ +\begin{array} { r l } & { \mathbb { P } \left( | \widehat { r } ( \mathbf { s } , \mathbf { a } ) - r ( \mathbf { s } , \mathbf { a } ) | > \sqrt { \frac { \widehat { r } ( \mathbf { s } , \mathbf { a } ) \iota } { n ( \mathbf { s } , \mathbf { a } ) } } + \frac { \iota } { n ( \mathbf { s } , \mathbf { a } ) } \right) } \\ & { \leq \mathbb { P } \left( | \widehat { r } ( \mathbf { s } , \mathbf { a } ) - r ( \mathbf { s } , \mathbf { a } ) | > \sqrt { \frac { \widehat { \mathrm { V a r } } ( \widehat { r } ( \mathbf { s } , \mathbf { a } ) ) \iota } { 2 ( n ( \mathbf { s } , \mathbf { a } ) - 1 ) } } + \frac { \iota } { 2 ( n ( \mathbf { s } , \mathbf { a } ) - 1 ) } \right) \leq \delta , } \end{array} +$$ + +where we use that ${ \widehat { \mathrm { V a r } } } ( { \widehat { r } } ( \mathbf { s } , \mathbf { a } ) ) \leq { \widehat { r } } ( \mathbf { s } , \mathbf { a } )$ for [0, 1] rewards, and with slight abuse of notation, let $\iota$ b bcapture all constant factors. Taking the union bound over all $i$ and $( \mathbf { s } , \mathbf { a } )$ yields the desired result. + +Now, we can prove that our value estimates are indeed pessimistic. + +Lemma B.7 (Pessimism Guarantee). On event $\mathcal { E }$ , we have that $\widehat { V } _ { i } ( \mathbf { s } ) \leq V ^ { \widehat { \pi } ^ { * } } ( \mathbf { s } ) \leq V ^ { * } ( \mathbf { s } )$ for any iteration $i \in [ m ]$ and state $\mathbf { s } \in { \mathcal { S } }$ . + +Proof. We aim to prove the following for any $i$ and $s$ : $\widehat { V } _ { i - 1 } ( \mathbf { s } ) \leq \widehat { V } _ { i } ( \mathbf { s } ) \leq V ^ { \widehat { \pi } ^ { * } } ( \mathbf { s } ) \leq V ^ { * } ( \mathbf { s } )$ . We prove the claims one by one. + +${ \widehat { V } } _ { i - 1 } ( \mathbf { s } ) \leq { \widehat { V } } _ { i } ( \mathbf { s } )$ : This is directly implied by the monotonic update of our algorithm. + +$\widehat { V } _ { i } ( \mathbf { s } ) \leq V ^ { \widehat { \pi } ^ { * } } ( \mathbf { s } )$ : We will prove this via induction. We have that this holds for $\widehat { V } _ { 0 }$ trivially. Assume it holds for $t - 1$ , then we have + +$$ +\begin{array} { r l } & { V ^ { \widehat { \pi } ^ { * } } ( \mathbf { s } ) \geq \mathbb { E } _ { a \sim \widehat { \pi } ^ { * } ( \cdot \vert s ) } \left[ r ( \mathbf { s } , \mathbf { a } ) + \gamma P ( \mathbf { s } , \mathbf { a } ) \cdot \widehat { V } _ { i - 1 } \right] } \\ & { \qquad \geq \mathbb { E } _ { a } \left[ \widehat { r } ( \mathbf { s } , \mathbf { a } ) - b _ { i } ( \mathbf { s } , \mathbf { a } ) + \gamma \widehat { P } ( \mathbf { s } , \mathbf { a } ) \cdot \widehat { V } _ { t - 1 } \right] + } \\ & { \qquad \mathbb { E } _ { a } \left[ b _ { i } ( \mathbf { s } , \mathbf { a } ) - ( \widehat { r } ( s , a ) - r ( \mathbf { s } , \mathbf { a } ) ) - \gamma ( \widehat { P } ( \mathbf { s } , \mathbf { a } ) - P ( \mathbf { s } , \mathbf { a } ) ) \cdot \widehat { V } _ { i - 1 } \right] } \\ & { \qquad \geq \widehat { V } _ { t } ( \mathbf { s } ) , } \end{array} +$$ + +where we use that + +$$ +\begin{array} { l l l } { \displaystyle b _ { i } ( \mathbf { s } , \mathbf { a } ) = \sqrt { \frac { \mathbb { V } ( \widehat { P } ( \mathbf { s } , \mathbf { a } ) , \widehat { V } _ { i - 1 } ) \iota } { ( n ( \mathbf { s } , \mathbf { a } ) \wedge 1 ) } } + \sqrt { \frac { \widehat { r } ( \mathbf { s } , \mathbf { a } ) \iota } { ( n ( \mathbf { s } , \mathbf { a } ) \wedge 1 ) } } + \frac { \iota } { ( n ( \mathbf { s } , \mathbf { a } ) \wedge 1 ) } } \\ { \geq ( \widehat { r } ( s , a ) - r ( \mathbf { s } , \mathbf { a } ) ) + \gamma ( \widehat { P } ( \mathbf { s } , \mathbf { a } ) - P ( \mathbf { s } , \mathbf { a } ) ) \cdot \widehat { V } _ { i - 1 } } \end{array} +$$ + +under event $\mathcal { E }$ + +Finally, the claim of $V ^ { \widehat { \pi } ^ { * } } ( \mathbf { s } ) ~ \leq ~ V ^ { * } ( \mathbf { s } )$ is trivial, which completes the proof of our pessimism guarantee. + +# B.2.3 VALUE DIFFERENCE LEMMA + +Now, we are ready to derive the performance guarantee from Theorem 4.2. The following lemma is a bound on the estimation error of our pessimistic $Q$ -values. + +Lemma B.8. On event $\mathcal { E }$ , the following holds for any $i \in [ m ]$ and $( \mathbf { s } , \mathbf { a } ) \in \mathcal { S } \times \mathcal { A }$ : + +$$ +\begin{array} { r } { Q ^ { * } ( \mathbf { s } , \mathbf { a } ) - \widehat { Q } _ { i } ( \mathbf { s } , \mathbf { a } ) \leq \gamma P ( \mathbf { s } , \mathbf { a } ) \cdot ( Q ^ { * } ( \cdot ; \pi ^ { * } ) - \widehat { Q } _ { i - 1 } ( \cdot ; \pi ^ { * } ) ) + 2 b _ { i } ( \mathbf { s } , \mathbf { a } ) , } \end{array} +$$ + +where $f ( \cdot ; \pi )$ satisfies $\begin{array} { r } { f ( s ; \pi ) = \sum _ { \mathbf { a } } \pi ( \mathbf { a } | \mathbf { s } ) f ( \mathbf { s } , \mathbf { a } ) } \end{array}$ . + +Proof. We have, + +$$ +\begin{array} { r l } & { Q ^ { * } ( \mathbf { s } , \mathbf { a } ) - \widehat { Q } _ { i } ( \mathbf { s } , \mathbf { a } ) } \\ & { \quad = r ( \mathbf { s } , \mathbf { a } ) + \gamma P ( \mathbf { s } , \mathbf { a } ) \cdot V ^ { * } - ( \widehat { r } ( \mathbf { s } , \mathbf { a } ) - b _ { i } ( \mathbf { s } , \mathbf { a } ) + \gamma \widehat { P } ( \mathbf { s } , \mathbf { a } ) \cdot \widehat { V } _ { t - 1 } ) } \\ & { \quad = b _ { i } ( \mathbf { s } , \mathbf { a } ) + r ( \mathbf { s } , \mathbf { a } ) - \widehat { r } ( \mathbf { s } , \mathbf { a } ) + \gamma P ( \mathbf { s } , \mathbf { a } ) \cdot ( V ^ { * } - \widehat { V } _ { t - 1 } ) + \gamma ( P ( \mathbf { s } , \mathbf { a } ) - \widehat { P } ( \mathbf { s } , \mathbf { a } ) ) \cdot \widehat { V } _ { t - 1 } } \\ & { \quad \leq \gamma P ( \mathbf { s } , \mathbf { a } ) \cdot ( V ^ { * } - \widehat { V } _ { t - 1 } ) + 2 b _ { i } ( \mathbf { s } , \mathbf { a } ) } \\ & { \quad \leq \gamma P ( \mathbf { s } , \mathbf { a } ) \cdot ( Q ^ { * } ( \cdot ; \pi ^ { * } ) - \widehat { Q } _ { t - 1 } ( \cdot ; \pi ^ { * } ) ) + 2 b _ { i } ( \mathbf { s } , \mathbf { a } ) . } \end{array} +$$ + +The first inequality is due by definition of $\mathcal { E }$ and the second is because $\widehat { V } _ { t - 1 } \geq \operatorname* { m a x } _ { a } \widehat { Q } _ { t - 1 } ( \cdot , a ) \geq$ $\widehat { Q } _ { i } ( \cdot , \pi ^ { * } )$ . L + +By recursively applying Lemma B.8, we can derive the following value difference lemma: + +Lemma B.9 (Value Difference Lemma). On event $\mathcal { E }$ , at any iteration $i \in [ m ]$ , we have + +$$ +J ( \pi ^ { * } ) - J ( \widehat { \pi } ^ { * } ) \leq \gamma ^ { i } + 2 \sum _ { t = 1 } ^ { i } \sum _ { ( \mathbf { s } , \mathbf { a } ) } \gamma ^ { i - t } d _ { i - t } ^ { * } ( \mathbf { s } , \mathbf { a } ) b _ { t } ( \mathbf { s } , \mathbf { a } ) , +$$ + +where $d _ { t } ^ { * } ( \mathbf { s } , \mathbf { a } ) = \mathbb { P } \left( s _ { t } = \mathbf { s } , \mathbf { a } _ { t } = a ; \pi ^ { * } \right)$ ). + +Proof. We have, + +$$ +J ( \pi ^ { * } ) - J ( \widehat { \pi } ^ { * } ) = \mathbb { E } _ { \rho } \left[ V ^ { * } ( \mathbf { s } ) - V ^ { \widehat { \pi } ^ { * } } ( \mathbf { s } ) \right] \leq \mathbb { E } _ { \rho } \left[ V ^ { * } ( \mathbf { s } ) - \widehat { V } _ { i } ( \mathbf { s } ) \right] \leq \rho ( Q ^ { * } ( \cdot ; \pi ^ { * } ) - \widehat { Q } _ { i } ( \cdot ; \pi ^ { * } ) ) +$$ + +where we use Lemma B.7 in the first inequality. As shorthand, let $P ^ { \pi } \in \mathbb { R } ^ { ( S \times A ) \times ( S \times A ) }$ where $P ^ { \pi } ( { \bf s } , { \bf a } , s ^ { \prime } , a ^ { \prime } ) = P ( s ^ { \prime } | { \bf s } , { \bf a } ) \pi ( a ^ { \prime } | s ^ { \prime } )$ be the transition matrix for policy $\pi$ . Now, we can apply Lemma B.8 recursively to derive + +$$ +\begin{array} { r l } { \rho ^ { \pi ^ { * } } \left( Q ^ { * } - \widehat { Q } _ { i } \right) \leq \rho ^ { \pi ^ { * } } \left( \gamma P ^ { \pi ^ { * } } \left( Q - \widehat { Q } _ { i - 1 } \right) + 2 b _ { i } \right) } & { } \\ & { \leq \rho ^ { \pi ^ { * } } \left( \gamma P ^ { \pi ^ { * } } \left( \gamma P ^ { \pi ^ { * } } \left( Q ^ { * } - \widehat { Q } _ { i - 2 } \right) + 2 b _ { i - 1 } \right) + 2 b _ { i } \right) } \\ & { \leq \ldots } \\ & { \leq \rho ^ { \pi ^ { * } } \left( \gamma P ^ { \pi ^ { * } } \right) ^ { i } ( Q ^ { * } - \widehat { Q } _ { 0 } ) + 2 \displaystyle \sum _ { t = 1 } ^ { i } \rho ^ { \pi ^ { * } } \left( \gamma P ^ { \pi ^ { * } } \right) ^ { i - t } b _ { t } } \\ & { \leq \gamma ^ { i } { \boldsymbol 1 } + 2 \displaystyle \sum _ { t = 1 } ^ { i } \gamma ^ { i - t } d _ { i - t } ^ { * } b _ { t } } \end{array} +$$ + +where we use that $d _ { t } ^ { * } = \rho ^ { \pi ^ { * } } ( P ^ { \pi ^ { * } } ) ^ { t }$ . This yields the desired result. + +Now, we are ready to bound the desired quantity $\mathsf { S u b O p t } ( \widehat { \pi } ^ { * } ) = \mathbb { E } _ { \mathcal { D } } \left[ J ( \pi ^ { * } ) - J ( \widehat { \pi } ^ { * } ) \right]$ . We have + +$$ +\begin{array} { r l } & { \mathbb { E } _ { \mathcal { D } } \left[ J ( \pi ^ { * } ) - J ( \widehat { \pi ^ { * } } ) \right] = \mathbb { E } _ { \mathcal { D } } \left[ \displaystyle \sum _ { s } \rho ( \mathsf { s } ) ( V ^ { * } ( \mathsf { s } ) - V ^ { \widehat { \pi ^ { * } } } ( \mathsf { s } ) ) \right] } \\ & { \qquad = \underbrace { \mathbb { E } _ { \mathcal { D } } \left[ \mathbb { I } \{ \bar { \mathcal { E } } \} \displaystyle \sum _ { s } \rho ( \mathsf { s } ) ( V ^ { * } ( \mathsf { s } ) - V ^ { \widehat { \pi ^ { * } } } ( \mathsf { s } ) ) \right] } _ { \displaystyle : = \Delta _ { 1 } } } \\ & { \qquad + \mathbb { E } _ { \mathcal { D } } \mathbb { I } \{ \frac { \mathsf { I } \{ \bar { \mathcal { B } } \mathsf { e } \} } { \Xi \mathsf { S } \mathsf { e } } \mathsf { S } , \pi ( \mathsf { s } , \pi ^ { * } ( \mathsf { s } ) ) = 0 \big | \displaystyle \sum _ { s } \rho ( \mathsf { s } ) ( V ^ { * } ( \mathsf { s } ) - V ^ { \widehat { \pi ^ { * } } } ( \mathsf { s } ) ) \} _ { \displaystyle : = \Delta _ { 2 } } } \\ & { \qquad + \mathbb { E } _ { \mathcal { D } } \mathbb { I } \{ \| \nabla \mathsf { s } \mathsf { e } \mathcal { S } , n ( \mathsf { s } , \pi ^ { * } ( \mathsf { s } ) ) > 0 \| \{ \mathcal { E } \} \displaystyle \sum _ { s } \rho ( \mathsf { s } ) ( V ^ { * } ( \mathsf { s } ) - V ^ { \widehat { \pi ^ { * } } } ( \mathsf { s } ) ) \} _ { \displaystyle : } . } \end{array} +$$ + +We bound each term individually. The first is bounded as $\Delta _ { 1 } \leq \mathbb { P } \left( { \bar { \mathcal { E } } } \right) \leq 2 | { \mathcal { S } } | | { \mathcal { A } } | m \delta \leq { \frac { \iota } { N } }$ for choice of δ = 12|S||A|HN . + +# B.2.4 BOUND ON $\Delta _ { 2 }$ + +For the second term, we have + +$$ +\begin{array} { r l } & { \displaystyle \Delta _ { 2 } \leq \sum _ { s } \rho ( \mathbf { s } ) \mathbb { E } _ { \mathcal { D } } \left[ \mathbb { I } \{ n ( \mathbf { s } , \boldsymbol { \pi } ^ { * } ( \mathbf { s } ) ) = 0 \} \right] } \\ & { \quad \leq H \displaystyle \sum _ { \mathbf { s } } d ^ { * } ( \mathbf { s } , \boldsymbol { \pi } ^ { * } ( \mathbf { s } ) ) \mathbb { E } _ { \mathcal { D } } \left[ \mathbb { I } \{ n ( \mathbf { s } , \boldsymbol { \pi } ^ { * } ( \mathbf { s } ) ) = 0 \} \right] } \\ & { \quad \leq C ^ { * } H \displaystyle \sum _ { \mathbf { s } } \mu ( \mathbf { s } , \boldsymbol { \pi } ^ { * } ( \mathbf { s } ) ) ( 1 - \mu ( \mathbf { s } , \boldsymbol { \pi } ^ { * } ( \mathbf { s } ) ) ) ^ { N } } \\ & { \quad \leq \frac { 4 C ^ { * } | \mathcal { S } | H } { 9 N } , } \end{array} +$$ + +where we use that $\rho ( \mathbf { s } ) \leq H d ^ { * } ( \mathbf { s } , \pi ^ { * } ( \mathbf { s } ) )$ , and that $\begin{array} { r } { \operatorname* { m a x } _ { p \in [ 0 , 1 ] } p ( 1 - p ) ^ { N } \le \frac { 4 } { 9 N } } \end{array}$ + +# B.2.5 BOUND ON $\Delta _ { 3 }$ + +What remains is bounding the last term, which we know from Lemma B.9 is bounded by + +$$ +\Delta _ { 3 } \leq \frac { 1 } { N } + 2 \mathbb { E } _ { \mathcal { D } } \left[ \mathbb { I } \{ \forall \mathbf { s } \in \mathcal { S } , ~ n ( \mathbf { s } , \pi ^ { * } ( \mathbf { s } ) ) > 0 \} \sum _ { t = 0 } ^ { m } \sum _ { ( \mathbf { s } , \mathbf { a } ) } \gamma ^ { m - t } d _ { m - t } ^ { * } ( \mathbf { s } , \mathbf { a } ) b _ { t } ( \mathbf { s } , \mathbf { a } ) \right\} , +$$ + +where we use that $\begin{array} { r } { \gamma ^ { m } \leq \frac { 1 } { N } } \end{array}$ for $m = H \log N$ . Recall that $b _ { t } ( \mathbf { s } , \mathbf { a } )$ is given by + +$$ +b _ { t } ( { \mathbf s } , { \mathbf a } ) = \sqrt { \frac { \mathbb { V } ( \widehat { P } ( { \mathbf s } , { \mathbf a } ) , \widehat { V } _ { t - 1 } ) { \iota } } { n ( { \mathbf s } , { \mathbf a } ) } } + \sqrt { \frac { \widehat { r } ( { \mathbf s } , { \mathbf a } ) { \iota } } { n ( { \mathbf s } , { \mathbf a } ) } } + \frac { \iota } { n ( { \mathbf s } , { \mathbf a } ) } +$$ + +We can bound the summation of each term separately. For the third term we have, + +$$ +\begin{array} { r l } & { \mathbb { E } _ { \mathcal { D } } \left[ \displaystyle \sum _ { t = 1 } ^ { m } \sum _ { ( \mathbf { s } , \mathbf { a } ) } \gamma ^ { m - t } d _ { m - t } ^ { \mathsf { s } } ( \mathbf { s } , \mathbf { a } ) \frac { \iota } { n ( \mathbf { s } , \mathbf { a } ) } \right] \leq \displaystyle \sum _ { t = 0 } ^ { m - 1 } \sum _ { ( \mathbf { s } , \mathbf { s } ) } \gamma ^ { t } d _ { t } ^ { \mathsf { s } } ( \mathbf { s } , \mathbf { a } ) \mathbb { E } _ { \mathcal { D } } \left[ \frac { \iota } { n ( \mathbf { s } , \mathbf { a } ) } \right] } \\ & { \qquad \leq \displaystyle \sum _ { \mathbf { s } } \displaystyle \sum _ { t = 0 } ^ { \infty } \sum _ { t = 0 } ^ { t } \gamma ^ { t } d _ { t } ^ { \mathsf { s } } ( \mathbf { s } , \boldsymbol { \pi } ^ { \mathsf { s } } ( \mathbf { s } ) ) \frac { \iota } { N \mu ( \mathbf { s } , \boldsymbol { \pi } ^ { \mathsf { s } } ( \mathbf { s } ) ) } } \\ & { \qquad \leq \displaystyle \frac { H \iota } { N } \displaystyle \sum _ { \mathbf { s } } \left( ( 1 - \gamma ) \displaystyle \sum _ { t = 0 } ^ { \infty } \gamma ^ { t } d _ { t } ^ { \mathsf { s } } ( \mathbf { s } , \boldsymbol { \pi } ^ { \mathsf { s } } ( \mathbf { s } ) ) \right) \frac { 1 } { \mu ( \mathbf { s } , \boldsymbol { \pi } _ { h } ^ { \mathsf { s } } ( \mathbf { s } ) ) } } \\ & { \qquad \leq \displaystyle \frac { C ^ { \mathsf { s } } | \mathcal { S } | H \iota } { N } . } \end{array} +$$ + +Here we use Jensen’s inequality and that $\begin{array} { r } { ( 1 - \gamma ) \sum _ { t = 1 } ^ { \infty } \gamma ^ { t } d _ { t } ^ { * } ( \mathbf { s } , \mathbf { a } ) \leq C ^ { * } \mu ( \mathbf { s } , \mathbf { a } ) } \end{array}$ for any $( \mathbf { s } , \mathbf { a } )$ . For the second term, we similarly have + +$$ +\begin{array} { r l } & { \mathbb { E } _ { \mathcal { D } } \left[ \displaystyle \sum _ { t = 1 } ^ { m } \sum _ { ( \mathbf { s } , \mathbf { a } ) } \gamma ^ { m - t } d _ { m - t } ^ { * } ( \mathbf { s } , \mathbf { a } ) \sqrt { \frac { \widehat { r } ( \mathbf { s } , \mathbf { a } ) \iota } { n ( \mathbf { s } , \mathbf { a } ) } } \right] } \\ & { \leq \mathbb { E } _ { \mathcal { D } } \left[ \sqrt { \displaystyle \sum _ { t = 1 } ^ { m } \sum _ { ( \mathbf { s } , \mathbf { a } ) } \gamma ^ { m - t } d _ { m - t } ^ { * } ( \mathbf { s } , \mathbf { a } ) \frac { \iota } { n ( \mathbf { s } , \mathbf { a } ) } } \right] \sqrt { \displaystyle \sum _ { t = 1 } ^ { m } \sum _ { ( \mathbf { s } , \mathbf { a } ) } \gamma ^ { m - t } d _ { m - t } ^ { * } ( \mathbf { s } , \mathbf { a } ) \widehat { r } ( \mathbf { s } , \mathbf { a } ) } } \\ & { \leq \sqrt { \displaystyle \frac { C ^ { * } | \mathcal { S } | H \iota } { N } } , } \end{array} +$$ + +where we use Cauchy-Schwarz, then Condition 3.2 to bound the total estimated reward. Finally, we consider the first term of $b _ { t } ( \mathbf { s } , \mathbf { a } )$ + +$$ +\begin{array} { r l } & { \mathbb { E } _ { \mathcal { D } } \left[ \displaystyle \sum _ { t = 1 } ^ { m } \sum _ { ( \mathbf { s } , \mathbf { a } ) } \gamma ^ { m - t } d _ { m - t } ^ { \ast } ( \mathbf { s } , \mathbf { a } ) \sqrt { \frac { \mathbb { V } ( \widehat { P } ( \mathbf { s } , \mathbf { a } ) , \widehat { V } _ { t - 1 } ) \iota } { n ( \mathbf { s } , \mathbf { a } ) } } \right] } \\ & { \leq \mathbb { E } _ { \mathcal { D } } \left[ \sqrt { \displaystyle \sum _ { t = 1 } ^ { m } \sum _ { ( \mathbf { s } , \mathbf { a } ) } \gamma ^ { m - t } d _ { m - t } ^ { \ast } ( \mathbf { s } , \mathbf { a } ) \frac { \iota } { n ( \mathbf { s } , \mathbf { a } ) } } \right] \sqrt { \displaystyle \sum _ { t = 1 } ^ { m } \sum _ { ( \mathbf { s } , \mathbf { a } ) } \gamma ^ { m - t } d _ { m - t } ^ { \ast } ( \mathbf { s } , \mathbf { a } ) \mathbb { V } ( \widehat { P } ( \mathbf { s } , \mathbf { a } ) , \widehat { V } _ { t - 1 } ) } } \\ & { \leq \sqrt { \displaystyle \frac { C ^ { \ast } | S | H } { N } } \sqrt { \displaystyle \sum _ { t = 1 } ^ { m } \sum _ { ( \mathbf { s } , \mathbf { a } ) } \gamma ^ { m - t } d _ { m - t } ^ { \ast } ( \mathbf { s } , \mathbf { a } ) \mathbb { V } ( \widehat { P } ( \mathbf { s } , \mathbf { a } ) , \widehat { V } _ { t - 1 } ) } . } \end{array} +$$ + +Similar to what was done in Zhang et al. [72], Ren et al. [53] for finite-horizon MDPs, we can bound this term using variance recursion for infinite-horizon ones. Define + +$$ +f ( i ) : = \sum _ { t = 1 } ^ { \infty } \sum _ { ( \mathbf { s } , \mathbf { a } ) } \gamma ^ { m - t } d _ { m - t } ^ { \ast } ( \mathbf { s } , \mathbf { a } ) \mathbb { V } ( \widehat { P } ( \mathbf { s } , \mathbf { a } ) , ( \widehat { V } _ { t - 1 } ) ^ { 2 ^ { i } } ) . +$$ + +Using Lemma 3 of Ren et al. [53] for the infinite-horizon case, we have the following recursion: + +$$ +f ( i ) \leq \sqrt { \frac { C ^ { * } \vert S \vert H \iota } { N } f ( i + 1 ) } + \frac { C ^ { * } \vert S \vert H \iota } { N } + 2 ^ { i + 1 } ( \Phi + 1 ) , +$$ + +where + +$$ +\Phi : = \sqrt { \frac { C ^ { * } | S | H \iota } { N } } \sqrt { \sum _ { t = 1 } ^ { m } \sum _ { ( \mathbf { s } , \mathbf { a } ) } \gamma ^ { m - t } d _ { m - t } ^ { * } ( \mathbf { s } , \mathbf { a } ) \mathbb { V } ( \widehat { P } ( \mathbf { s } , \mathbf { a } ) , \widehat { V } _ { t - 1 } ) } + \frac { C ^ { * } | S | H \iota } { N } +$$ + +Using Lemma B.4, we can bound $\begin{array} { r } { f ( 0 ) = \mathcal { O } \left( \frac { C ^ { * } | S | H \iota } { N } + \Phi + 1 \right) } \end{array}$ . Using that for constant $c$ + +$$ +\begin{array} { l } { \displaystyle \Phi = \sqrt { \frac { C ^ { * } | \mathcal { S } | H \iota } { N } \ f ( 0 ) } + \frac { C ^ { * } | \mathcal { S } | H \iota } { N } } \\ { \displaystyle \quad \leq \sqrt { \frac { C ^ { * } | \mathcal { S } | H \iota } { N } \left( \frac { c C ^ { * } | \mathcal { S } | H \iota } { N } + c \Phi + c \right) } + \frac { C ^ { * } | \mathcal { S } | H \iota } { N } } \\ { \displaystyle \quad \leq \frac { c \Phi } { 2 } + \frac { 2 c C ^ { * } | \mathcal { S } | H \iota } { N } + \frac { c } { 2 } } \end{array} +$$ + +we have that + +$$ +\Phi \le c + \frac { 4 c C ^ { * } | \boldsymbol { S } | H \iota } { N } . +$$ + +Substituting this back into the inequality for $\Phi$ yields, + +$$ +\Phi = \mathcal { O } \left( \sqrt { \frac { C ^ { * } | S | H \iota } { N } } + \frac { C ^ { * } | S | H \iota } { N } \right) +$$ + +Finally, we can bound + +$$ +\Delta _ { 3 } \leq \sqrt { \frac { C ^ { * } | { \cal S } | H \iota } { N } } + \frac { C ^ { * } | { \cal S } | H \iota } { N } . +$$ + +Combining the bounds for the three terms yields the desired result. + +# B.3 PROOF OF COROLLARY 4.1 + +In this section, we will provide a proof of Corollary 4.1. + +Intuition and strategy: The intuition for why offline RL can outperform BC in this setting, despite the near-expert data comes from the fact that RL can better control the performance of the policy on non-critical states that it has seen before in the data. This is not true for BC since it does not utilize reward information. Intuitively, we can partition the states into two categories: + +1. critical states including those that are visited enough and those that are not visited enough in the dataset bound this via the machinery already discussed in Appendix B.2. 2. non-critical states offline RL can perform well here: we show that under some technical conditions, it can exponentially fast collapse at a good-enough action at such states, while BC might still choose bad actions. + +We restate the definition of non-critical points below for convenience. + +Definition B.1 ((Non-critical points, restated)). $A$ state s is said to be non-critical (i.e., s $\not \in { \mathcal { C } }$ ) if there exists a subset $\mathcal G ( \mathbf { s } )$ of $\varepsilon$ -good actions, such that, + +$$ +\begin{array} { c l l } { { \displaystyle \forall \mathbf { a } \in { \mathcal G } ( \mathbf { s } ) , ~ \operatorname* { m a x } _ { \mathbf { a } ^ { \prime } } Q ^ { * } ( \mathbf { s } , \mathbf { a } ^ { \prime } ) - Q ^ { * } ( \mathbf { s } , \mathbf { a } ) \leq \frac { \varepsilon } { H } , ~ a n d } } & { { } } & { { } } \\ { { \displaystyle \forall \mathbf { a } \in { \mathcal A } \setminus { \mathcal G } ( \mathbf { s } ) , ~ \operatorname* { m a x } _ { \mathbf { a } ^ { \prime } } Q ^ { * } ( \mathbf { s } , \mathbf { a } ^ { \prime } ) - Q ^ { * } ( \mathbf { s } , \mathbf { a } ) \simeq \Delta ( \mathbf { s } ) , } } & { { } } & { { } } \end{array} +$$ + +and $\Delta ( \mathbf { s } ) \leq \Delta _ { 0 }$ , where we will define $\Delta _ { 0 }$ later. + +Recall that our condition on critical states was that for any policy $\pi$ in the MDP, the expected occupancy of critical states is bounded by $p _ { c }$ and $\begin{array} { r } { p _ { c } \le \frac { 1 } { H } } \end{array}$ . We restate this condition below: + +Condition B.1 ((Occupancy of critical states is low, restated)). For any policy $\pi$ , the total occupancy of critical states in the MDP is bounded by $p _ { c }$ , i.e., + +$$ +\sum _ { \mathbf { s } \in \mathcal { C } } d ^ { \pi } ( \mathbf { s } ) \leq p _ { c } . +$$ + +Now, using this definition, we will bound the total suboptimality of RL separately at critical and non-critical states. At critical states, i.e., scenario (1) from the list above, we will reuse the existing machinery for the general setting from Appendix B.2. For non-critical states (2), we will utilize a stronger argument for RL that relies on the fact that $\Delta _ { 0 }$ and $| \mathcal G ( \mathbf { s } ) |$ are large enough, and consider policy-constraint offline RL algorithms that extract the policy via a pessimistic policy extraction step. + +This policy constraint algorithm follows Algorithm 2, but in addition to using the learned Q-function for policy extraction, it uses a local pessimistic term in Step 7, i.e., + +$$ +\widehat { \pi } ^ { * } \gets \arg \operatorname* { m a x } _ { \pi } \mathbb { E } _ { \mathbf { s } \sim \mathcal { D } } \left[ \mathbb { E } _ { \mathbf { a } \sim \pi } \left[ \widehat { Q } ^ { \pi } ( \mathbf { s } , \mathbf { a } ) - \sigma b ( \mathbf { s } , \mathbf { a } ) \right] \right] , +$$ + +where $b ( \mathbf { s } , \mathbf { a } )$ refers to the bonus (Equation 2) and $\sigma > 0$ . This modification makes the algorithm more pessimistic but allows us to obtain guarantees when $\forall ( \mathbf { s } , \mathbf { a } ) , n ( \mathbf { s } , \mathbf { a } ) \geq n _ { 0 }$ as we can express the probability that the policy makes a mistake at a given state-action pair in terms of the count of the given state-action pair. Finally, as all state-action pairs are observed in the dataset, the learned Q-values, $\widehat { Q }$ can only differ from $Q ^ { * }$ in a bounded manner, i.e., $\left| { \widehat { Q } } ( \mathbf { s } , \mathbf { a } ) - Q ^ { * } ( \mathbf { s } , \mathbf { a } ) \right| \leq \varepsilon _ { 0 }$ . + +Lemma B.10 (Fast convergence at non-critical states.). Consider a non-critical state $\mathbf { s } \in \mathcal { D }$ , such that $| \mathcal { D } ( \mathbf { s } ) | \geq n _ { 0 }$ and let $\forall \mathbf { a } \in { \mathcal { A } }$ , $\begin{array} { r } { \frac { \pi ^ { * } ( \mathbf { a } | \mathbf { s } ) } { \mu ( \mathbf { a } | \mathbf { s } ) } \leq \alpha < 2 } \end{array}$ , where $\mu ( \mathbf { a } | \mathbf { s } )$ is the conditional action distribution at state s. Then, the probability that the policy $\widehat { \pi } _ { R L }$ obtained from the modified offline RL algorithm babove does not choose a good action at state s is upper bounded as $\scriptstyle \mathrm { ' } c _ { 0 }$ is a universal constant): + +$$ +\mathbb { P } \left( { \widehat { \pi } } _ { R L } ( \mathbf { s } ) \notin { \mathcal { G } } ( \mathbf { s } ) \right) \leq \exp \left( - n _ { 0 } \cdot \frac { \alpha ^ { 2 } } { 2 ( \alpha - 1 ) } \cdot \left[ \frac { | { \mathcal { G } } ( \mathbf { s } ) | \sigma c _ { 0 } } { n _ { 0 } \cdot ( c _ { 1 } \sigma + \Delta ) } - \frac { 1 } { \alpha } \right] ^ { 2 } \right) . +$$ + +Proof. First note that: + +$$ +\begin{array} { r l } & { \mathbb { \mathrm { \ p } } \left[ \widehat { \pi } _ { { \mathbf { R } } , { \mathbf { L } } } ( { \mathbf { s } } ) \notin \mathcal { G } ( { \mathbf { s } } ) \right] = \mathbb { \mathrm { P } } \left[ \exists { \mathbf { a } } \notin \mathcal { G } ( { \mathbf { s } } ) , \ { \mathbf { s } } { \mathbf { . t } } \forall { \mathbf { a } } _ { g } \in \mathcal { G } ( { \mathbf { s } } ) , \ \widehat { Q } ( { \mathbf { s } } , { \mathbf { a } } ) - \sigma b ( { \mathbf { s } } , { \mathbf { a } } ) \geq \widehat { Q } ( { \mathbf { s } } , { \mathbf { a } } _ { g } ) - \sigma b ( { \mathbf { s } } , { \mathbf { a } } _ { g } ) \right] } \\ & { \leq \mathbb { P } \left[ \exists { \mathbf { a } } \notin \mathcal { G } ( { \mathbf { s } } ) , \ { \mathbf { s } } { \mathbf { . t } } , \forall { \mathbf { a } } _ { g } \in \mathcal { G } ( { \mathbf { s } } ) , \widehat { Q } ( { \mathbf { s } } , { \mathbf { a } } ) - Q ^ { * } ( { \mathbf { s } } , { \mathbf { a } } ) \geq \widehat { Q } ( { \mathbf { s } } , { \mathbf { a } } _ { g } ) - Q ^ { * } ( { \mathbf { s } } , { \mathbf { a } } _ { g } ) + \Delta ( { \mathbf { s } } ) - \sigma b ( { \mathbf { s } } , { \mathbf { a } } _ { g } ) \right] } \\ & { \leq \mathbb { P } \left[ \mathsf { T } _ { { \mathbf { a } } _ { g } \in \mathcal { G } ( { \mathbf { s } } ) } \left\{ \sigma b ( { \mathbf { s } } , { \mathbf { a } } _ { g } ) \geq \Delta ( { \mathbf { s } } ) - 2 \varepsilon _ { 0 } \right\} \right] } \\ & { \leq \mathbb { P } \left[ \mathsf { T } _ { { \mathbf { a } } _ { g } \in \mathcal { G } ( { \mathbf { s } } ) } \left\{ n ( { \mathbf { s } } , { \mathbf { a } } ) \leq n _ { \Delta } \right\} \right] , } \end{array} +$$ + +where $n _ { \Delta }$ corresponds to the maximum value of $n ( \mathbf { s } , \mathbf { a } )$ such that + +$$ +b ( \mathbf { s } , \mathbf { a } ) : = \frac { c _ { 1 } } { \sqrt { n ( \mathbf { s } , \mathbf { a } ) \wedge 1 } } + \frac { c _ { 2 } } { n ( \mathbf { s } , \mathbf { a } ) \wedge 1 } \geq \frac { \Delta ( \mathbf { s } ) - 2 \varepsilon _ { 0 } } { \sigma } . +$$ + +We can then upper bound the probability using a Chernoff bound for Bernoulli random variables (the Bernoulli random variable here is whether the action sampled from the dataset $\mu ( \mathbf { a } | \mathbf { s } )$ belongs to the good set $\mathcal { G } ( \mathbf { s } )$ or not): + +$$ +\begin{array} { r l } & { \displaystyle \mathbb { P } \left[ \bigcap _ { \mathbf { a } \in { \mathcal { G } } ( \mathbf { s } ) } \left\{ n ( \mathbf { s } , \mathbf { a } ) \leq n _ { \Delta } ( \mathbf { s } ) \right\} \right] \leq \mathbb { P } \left[ \sum _ { \mathbf { a } \in { \mathcal { G } } ( \mathbf { s } ) } n ( \mathbf { s } , \mathbf { a } ) \leq | { \mathcal { G } } ( \mathbf { s } ) | n _ { \Delta } ( \mathbf { s } ) \right] . } \\ & { \qquad \leq \mathbb { P } \left[ \frac { \sum _ { \mathbf { a } \in { \mathcal { G } } ( \mathbf { s } ) } n ( \mathbf { s } , \mathbf { a } ) } { n _ { 0 } } \leq \frac { | { \mathcal { G } } ( \mathbf { s } ) | n _ { \Delta } ( \mathbf { s } ) } { n _ { 0 } } \right] } \\ & { \qquad \leq \exp \left( - n _ { 0 } \mathrm { K L } \left( \mathbf { B } \mathrm { e r n } \left( \frac { | { \mathcal { G } } ( \mathbf { s } ) | n _ { \Delta } ( \mathbf { s } ) } { n _ { 0 } } \right) | | \mathbf { B } \mathrm { e r n } ( 1 / \alpha ) \right) \right) . } \end{array} +$$ + +The above expression can then be simplified using the inequality that $\begin{array} { r } { \mathrm { K L } ( p + \varepsilon | | p ) \geq \frac { \varepsilon ^ { 2 } } { 2 p ( 1 - p ) } } \end{array}$ if $p \ge 1 / 2$ , which is the case here, since $\textstyle p = { \frac { 1 } { \alpha } }$ , and $\alpha \leq 2$ . Thus, we can simplify the bound as: + +$$ +\mathbb { P } \left[ \cap _ { \mathbf { a } \in \mathcal { G } ( \mathbf { s } ) } \left\{ n ( \mathbf { s } , \mathbf { a } ) \leq n _ { \Delta } ( \mathbf { s } ) \right\} \right] \leq \exp \left( - n _ { 0 } \cdot \frac { \alpha ^ { 2 } } { 2 ( \alpha - 1 ) } \cdot \left. \frac { | \mathcal { G } ( \mathbf { s } ) | n _ { \Delta } ( \mathbf { s } ) } { n _ { 0 } } - \frac { 1 } { \alpha } \right. ^ { 2 } \right) . +$$ + +To finally express the bound in terms of $\Delta ( \mathbf { s } )$ , we note that the maximum-valued solution $n _ { \Delta } ( \mathbf { s } )$ to Equation 11 satisfies $\begin{array} { r } { n _ { \Delta } ( \mathbf { s } ) \simeq \frac { \sigma } { c _ { 1 } \sigma + \Delta ( \mathbf { s } ) } } \end{array}$ . Substituting the above in the bound, we obtain: + +$$ +\mathbb { P } \left[ \bigcap _ { \mathbf { a } \in \mathcal { G } ( \mathbf { s } ) } \left\{ n ( \mathbf { s } , \mathbf { a } ) \leq n _ { \Delta } ( \mathbf { s } ) \right\} \right] \leq \exp \left( - n _ { 0 } \cdot \frac { \alpha ^ { 2 } } { 2 ( \alpha - 1 ) } \cdot \left[ \frac { | \mathcal { G } ( \mathbf { s } ) | \sigma c _ { 0 } } { n _ { 0 } \cdot ( c _ { 1 } \sigma + \Delta ) } - \frac { 1 } { \alpha } \right] ^ { 2 } \right) , +$$ + +for some universal constants $c _ { 0 }$ and $c _ { 1 }$ . + +We will now use Lemma B.10 to prove the formal comparison of RL and BC when only a few critical states are encountered in a given trajectory (i.e., under Condition B.1). + +Theorem B.1 (Critical states). Assume that the data distribution $\mu$ satisfies $\begin{array} { r } { \rho ( \mathbf { s } ) : = \frac { \boldsymbol { d } ^ { \pi ^ { * } } ( \mathbf { s } ) } { \mu ( \mathbf { s } ) } = 1 } \end{array}$ and $\begin{array} { r } { C ^ { * } \leq 1 + \frac { 1 } { N } } \end{array}$ . Let $\Delta ( \mathbf { s } ) \geq \Delta _ { 0 }$ for all ${ \bf s } \notin \mathcal { C }$ . Then, under Condition B.1, for an appropriate value of $\Delta _ { 0 }$ and $p _ { c } \lesssim \frac { 1 } { H }$ , the worst-case suboptimality incurred by conservative offline $R L$ is upper bounded by the lower bound on performance from BC from Theorem 4.3, i.e., + +$$ +\mathsf { S u b O p t } ( \widehat { \pi } _ { \mathrm { R L } } ) \lesssim \mathsf { S u b O p t } ( \widehat { \pi } _ { \mathrm { B C } } ) . +$$ + +Proof. For any learning algorithm that returns a policy $\widehat { \pi } ^ { * }$ , the suboptimality is given by: + +$$ +\begin{array} { r l } & { I ( \pi ^ { * } ) - J ( \widehat { \pi } ^ { * } ) = \displaystyle H \sum _ { \mathbf { s } \in \mathcal { S } } d ^ { \widehat { \pi } ^ { * } } ( \mathbf { s } ) \left( Q ^ { * } ( s ; \pi ^ { * } ) - Q ^ { * } ( s ; \widehat { \pi } ^ { * } ) \right) } \\ & { \qquad = \displaystyle H \sum _ { \mathbf { s } \in \mathcal { C } } d ^ { \widehat { \pi } ^ { * } } ( \mathbf { s } ) \left( Q ^ { * } ( s ; \pi ^ { * } ) - Q ^ { * } ( s ; \widehat { \pi } ^ { * } ) \right) + \displaystyle H \sum _ { \mathbf { s } \notin \mathcal { C } } d ^ { \widehat { \pi } ^ { * } } ( \mathbf { s } ) \left( Q ^ { * } ( s ; \pi ^ { * } ) - Q ^ { * } ( s ; \widehat { \pi } ^ { * } ) \right) } \end{array} +$$ + +The first term (i) corresponds to the value difference at critical states, and the second term corresponds to the value difference at non-critical states. To bound the first term, we can consider it as the value difference under a modified MDP where the advantage for all actions at all states that are non-critical is 0. One way to construct such an MDP is to take each $s \not \in { \mathcal { C } }$ and modify the reward and transitions so that $r ( \mathbf { s } , \mathbf { a } ) = r ( \mathbf { s } , \pi ^ { * } ( \mathbf { s } ) ) , P ( \mathbf { s } , \mathbf { a } ) = P ( \mathbf { s } , \pi ^ { * } ( \mathbf { s } ) )$ for all actions. Let us denote the performance function for this modified MDP be $J _ { \mathcal { C } }$ , then we have + +$$ +J ( \pi ^ { * } ) - J ( \widehat { \pi } ^ { * } ) \leq J _ { \mathcal { C } } ( \pi ^ { * } ) - J _ { \mathcal { C } } ( \widehat { \pi } ^ { * } ) + \varepsilon +$$ + +The first term can be bounded as was done in Appendix B.2. Namely, we can show the following equivalent of Lemma B.9: + +$$ +J _ { \mathcal { C } } ( \pi ^ { * } ) - J _ { \mathcal { C } } ( \widehat { \pi } ^ { * } ) \leq \gamma ^ { i } + 2 \sum _ { t = 1 } ^ { i } \sum _ { \mathbf { s } \in \mathcal { C } } \gamma ^ { i - t } d _ { i - t } ^ { * } ( \mathbf { s } , \pi ^ { * } ( \mathbf { s } ) ) b _ { t } ( \mathbf { s } , \pi ^ { * } ( \mathbf { s } ) ) . +$$ + +Bounding this for $i = H \iota$ can be done exactly as in was done in Appendix B.2.4 and B.2.5, except with the dependence on all states $s$ replaced by $\mathcal { C }$ only the critical ones. We get the following bound: + +$$ +J _ { \mathcal { C } } ( \pi ^ { * } ) - J _ { \mathcal { C } } ( \widehat { \pi } ^ { * } ) \leq \sqrt { \frac { C ^ { * } p _ { c } | \mathcal { S } | H \iota } { N } } + \frac { C ^ { * } p _ { c } | \mathcal { S } | H \iota } { N } +$$ + +Now, we will focus on the second term, which we will control tightly for RL using Lemma B.10. We can decompose this term into separate components for good and bad actions: + +$$ +\begin{array} { r l } & { \mathfrak { l } _ { \mathcal { D } } \left[ \mathsf { t e r m } \left( \mathrm { i i } \right) \right] = \mathbb { E } _ { \mathcal { D } } \left[ \displaystyle \sum _ { \mathbf { s } \notin \mathcal { C } } \sum _ { \mathbf { a } \in \mathcal { A } } d ^ { \widehat { \pi } ^ { * } } \left( \mathbf { s } \right) \widehat { \pi } ^ { * } \left( \mathbf { a } | \mathbf { s } \right) \left( Q ^ { * } \left( s ; \pi ^ { * } \right) - Q ^ { * } \left( s , a \right) \right) \right] } \\ & { = \mathbb { E } _ { \mathcal { D } } \left[ \displaystyle \sum _ { \mathbf { s } \notin \mathcal { C } } \sum _ { \mathbf { a } \in \mathcal { O } \left( \mathbf { s } \right) } d ^ { \widehat { \pi } ^ { * } } \left( \mathbf { s } , \mathbf { a } \right) \left( Q ^ { * } \left( s ; \pi ^ { * } \right) - Q ^ { * } \left( s , a \right) \right) \right] + \mathbb { E } _ { \mathcal { D } } \left[ \displaystyle \sum _ { \mathbf { s } \notin \mathcal { C } } \displaystyle \sum _ { \mathbf { a } \in \mathcal { A } \setminus \mathcal { G } \left( \mathbf { s } \right) } d ^ { \widehat { \pi } ^ { * } } \left( \mathbf { s } , \mathbf { a } \right) \left( Q ^ { * } \left( s ; \pi ^ { * } \right) - Q ^ { * } \left( s , a \right) \right) \right] , } \end{array} +$$ + +We bound each term independently: + +$$ +\begin{array} { r l } & { \quad \mathbb { E } _ { \mathcal { D } } \left[ \displaystyle \sum _ { \mathbf { s } \notin \mathcal { C } } \displaystyle \sum _ { \mathbf { a } \in \mathcal { G } ( \mathbf { s } ) } d ^ { \widehat { \pi } ^ { * } } ( \mathbf { s } , \mathbf { a } ) \left( Q ^ { * } ( s ; \pi ^ { * } ) - Q ^ { * } ( s , a ) \right) \right] \leq \mathbb { E } _ { \mathcal { D } } \left[ \displaystyle \sum _ { \mathbf { s } \notin \mathcal { C } } d ^ { \widehat { \pi } ^ { * } } \left( \mathbf { s } \right) \widehat { \pi } ^ { * } ( \mathcal { G } ( \mathbf { s } ) | \mathbf { s } ) \cdot \frac { \varepsilon } { H } \right] } \\ & { \widetilde { z } _ { \mathcal { D } } \left[ \displaystyle \sum _ { \mathbf { s } \notin \mathcal { C } } \displaystyle \sum _ { \mathbf { a } \in \mathcal { A } \setminus \mathcal { G } ( \mathbf { s } ) } d ^ { \widehat { \pi } ^ { * } } \left( \mathbf { s } , \mathbf { a } \right) \left( Q ^ { * } ( s ; \pi ^ { * } ) - Q ^ { * } ( s , a ) \right) \right] \leq \mathbb { E } _ { \mathcal { D } } \left[ \displaystyle \sum _ { \mathbf { s } \notin \mathcal { C } } d ^ { \widehat { \pi } ^ { * } } \left( \mathbf { s } \right) \left( 1 - \widehat { \pi } ^ { * } ( \mathcal { G } ( \mathbf { s } ) | \mathbf { s } ) \right) \left( \Delta ( \mathbf { s } ) + \varepsilon \right) \right] } \end{array} +$$ + +The first equation corresponds to bounding the suboptimality due to good actions. The second term above bounds the suboptimality due to bad actions. The first term is controlled as best as it can using the definition of critical states. The second term can be controlled by applying Lemma B.10. Further note that since ∀(s, a), $\begin{array} { r } { \frac { d ^ { \pi ^ { * } } ( \mathbf { s } , \mathbf { a } ) } { \mu ( \mathbf { s } , \mathbf { a } ) } \leq C ^ { * } } \end{array}$ , and per the assumption in this theorem, $\forall \mathbf { s }$ , $\begin{array} { r } { \frac { \boldsymbol { d } ^ { \pi ^ { * } } ( \mathbf { s } ) } { \boldsymbol { \mu } ( \mathbf { s } ) } = 1 } \end{array}$ , where we assume that $0 / 0 = 1$ . Therefore, at each state, $\forall \mathbf { s } , \mathbf { a }$ , $\frac { \pi ^ { * } ( \mathbf { a } | \mathbf { s } ) } { \mu ( \mathbf { a } | \mathbf { s } ) } \leq C ^ { * }$ . Also note that in this case, we are interested in the setting where $\begin{array} { r } { C ^ { * } = 1 + \mathcal { O } \left( \frac { 1 } { N } \right) } \end{array}$ , and as a result, $\begin{array} { r } { \frac { 1 } { C ^ { * } } \approx \frac { N } { N + 1 } } \end{array}$ . Therefore, the upper bound for term (ii) is given by: + +$$ +\begin{array} { r l } & { \mathbb { E } _ { \mathcal { D } } \left[ \displaystyle \sum _ { \mathbf { s } \notin \mathcal { C } } d ^ { \widehat { \pi } ^ { * } } ( \mathbf { s } ) \left( 1 - \widehat { \pi } ^ { * } ( \mathcal { G } ( \mathbf { s } ) | \mathbf { s } ) \right) \Delta ( \mathbf { s } ) \right] } \\ & { \lesssim \mathbb { E } _ { \mathcal { D } } \left[ \displaystyle \sum _ { \mathbf { s } \notin \mathcal { C } } d ^ { \widehat { \pi } ^ { * } } ( \mathbf { s } ) \cdot \Delta ( \mathbf { s } ) \cdot \exp \left( - n _ { 0 } \cdot \frac { ( N + 1 ) ^ { 2 } } { 2 ( N ) } \cdot \left[ \frac { | \mathcal { G } ( \mathbf { s } ) | c _ { 0 } \sigma } { n _ { 0 } \cdot \left( c _ { 1 } \sigma + \Delta ( \mathbf { s } ) \right) } - \frac { N + 1 } { N } \right] ^ { 2 } \right) \right] } \\ & { \lesssim \left( 1 - p _ { c } \right) \Delta _ { 0 } \exp \left( - n _ { 0 } \cdot \frac { ( N + 1 ) ^ { 2 } } { 2 ( N ) } \cdot \left[ \frac { | \mathcal { G } ( \mathbf { s } ) | c _ { 0 } \sigma } { n _ { 0 } \cdot \left( c _ { 1 } \sigma + \Delta _ { 0 } \right) } - \frac { N + 1 } { N } \right] ^ { 2 } \right) : = f _ { \mathrm { R L } } ( N + 1 , \Delta _ { 0 } ) , } \end{array} +$$ + +where $1 - p _ { c }$ appears from the condition of bounded critical states (Definition 4.1). On the other hand, the corresponding term for BC grows as $\frac { 1 } { N + 1 }$ , and is given by: + +$$ +\mathbb { E } _ { \mathcal { D } } \left[ \sum _ { \mathbf { s } \notin { \cal C } } d ^ { \widehat { \pi } ^ { * } } ( \mathbf { s } ) \left( 1 - \widehat { \pi } ^ { * } ( { \mathcal { G } } ( \mathbf { s } ) | \mathbf { s } ) \right) \Delta ( \mathbf { s } ) \right] \lesssim \left( 1 - p _ { c } \right) \cdot \operatorname* { m a x } _ { \mathbf { s } \notin { \cal C } } \Delta ( \mathbf { s } ) \cdot \frac { 1 } { N + 1 } : = g _ { \mathrm { B C } } ( N + 1 , \Delta _ { 0 } ) +$$ + +The bound for BC matches the information-theoretic lower-bound from Theorem 4.3, implying that this bound is tight for BC. + +We will now compare the bounds for RL and BC by noting that the function $\begin{array} { r } { h ( N , \Delta ) : = \frac { f _ { \mathrm { R L } } ( N + 1 , \Delta ) } { g _ { \mathrm { B C } } ( N + 1 , \Delta ) } } \end{array}$ can be set to $\leq \frac { 1 } { \sqrt { H } }$ since $f$ is an exponential function of $- N$ , and $g$ decays linearly in $N$ , by controlling $\Delta _ { 0 }$ and $| \mathcal G ( \mathbf { s } ) |$ are implicitly defined as a function of $N$ . Per condition (Condition B.1), if $\Delta \ge \Delta _ { 0 }$ , then $h ( N , \Delta ) = \mathcal { O } \left( H \right)$ . This means that the suboptimalities of RL and BC compare as follows: + +$$ +\frac { \mathrm { S u b O p t } ( \widehat { \pi } _ { \mathrm { R L } } ) } { \mathrm { S u b O p t } ( \widehat { \pi } _ { \mathrm { B C } } ) } = \frac { \sqrt { p _ { c } \frac { C ^ { * } | S | H \iota } { N } } + \frac { C ^ { * } p _ { c } | S | H \iota } { N } + \left( 1 - p _ { c } \right) \cdot \mathbf { \widehat { u } } \cdot \frac { 1 } { \sqrt { H } } } { p _ { c } \frac { H } { N } + \left( 1 - p _ { c } \right) \mathbf { \widehat { u } } } . +$$ + +By setting $\begin{array} { r } { p _ { c } = \frac { 1 } { H } } \end{array}$ , we get + +$$ +\mathsf { S u b O p t } ( \widehat { \pi } _ { \mathrm { B C } } ) \gtrsim \mathsf { S u b O p t } ( \widehat { \pi } _ { \mathrm { R L } } ) \sqrt { H } \gtrsim \mathsf { S u b O p t } ( \widehat { \pi } _ { \mathrm { R L } } ) . +$$ + +# B.4 PROOF OF COROLLARY 4.2 + +The proof of Corollary 4.2 is a slight modification of the one for Theorem 4.2. For brevity, we will point out the parts of the proof that change, and simply defer to the proof in Appendix B.2 for parts that are similar. Recall the decomposition for suboptimality in equation 7, which we restate below: + +$$ +\begin{array} { r l } & { \displaystyle \mathfrak { L } _ { \mathcal { D } } \left[ J ( \pi ^ { * } ) - J ( \widehat { \pi } ^ { * } ) \right] = \underbrace { \mathbb { E } _ { \mathcal { D } } \left[ \mathbb { I } \{ \bar { \mathcal { E } } \} \sum _ { s } \rho ( \mathbf { s } ) ( V ^ { * } ( \mathbf { s } ) - V ^ { \widehat { \pi } ^ { * } } ( \mathbf { s } ) ) \right] } _ { \displaystyle \Delta _ { 1 } } } \\ & { \quad \quad \quad + \mathbb { E } _ { \mathcal { D } } \left[ \mathbb { I } \{ \exists \mathbf { s } \in \mathcal { S } , \ n ( \mathbf { s } , \pi ^ { * } ( \mathbf { s } ) ) = 0 \} \sum _ { s } \rho ( \mathbf { s } ) ( V ^ { * } ( \mathbf { s } ) - V ^ { \widehat { \pi } ^ { * } } ( \mathbf { s } ) ) \right\} _ { \displaystyle \Delta _ { 2 } } } \\ & \quad \quad \quad + \underbrace { \mathbb { E } _ { \mathcal { D } } \left[ \mathbb { I } \{ \forall \mathbf { s } \in \mathcal { S } , \ n ( \mathbf { s } , \pi ^ { * } ( \mathbf { s } ) ) > 0 \} \mathbb { I } \{ \mathcal { E } \sum _ { s } \rho ( \mathbf { s } ) ( V ^ { * } ( \mathbf { s } ) - V ^ { \widehat { \pi } ^ { * } } ( \mathbf { s } ) ) \} \right\} _ { \displaystyle \Delta _ { 3 } } . } \end{array} +$$ + +$\Delta _ { 1 }$ is bounded by $\textstyle { \frac { \iota } { N } }$ as before. + +# B.4.1 BOUND ON $\Delta _ { 2 }$ + +The bound for $\Delta _ { 2 }$ changes slightly from Appendix B.2.4 due to accounting for the lower-bound on $\textstyle \mu ( \mathbf { s } , \mathbf { a } ) \geq b \geq { \frac { \log H } { N } }$ . We have + +$$ +\begin{array} { r l } & { \displaystyle \Delta _ { 2 } \leq \sum _ { \mathbf { s } } \rho ( \mathbf { s } ) \mathbb { E } _ { D } \left[ \mathbb { I } \{ n ( \mathbf { s } , \pi ^ { * } ( \mathbf { s } ) ) = 0 \} \right] } \\ & { \quad \leq H \displaystyle \sum _ { \mathbf { s } } d ^ { * } ( \mathbf { s } , \pi ^ { * } ( \mathbf { s } ) ) \mathbb { E } _ { D } \left[ \mathbb { I } \{ n ( \mathbf { s } , \pi ^ { * } ( \mathbf { s } ) ) = 0 \} \right] } \\ & { \quad \leq H \displaystyle \sum _ { \mathbf { s } } d ^ { * } ( \mathbf { s } , \pi ^ { * } ( \mathbf { s } ) ) \mathbb { I } \{ d ^ { * } ( \mathbf { s } , \pi ^ { * } ( \mathbf { s } ) ) \leq \frac { b } { H } \} + H \displaystyle \sum _ { \mathbf { s } } d ^ { * } ( \mathbf { s } , \pi ^ { * } ( \mathbf { s } ) ) \mathbb { E } _ { D } \left[ \mathbb { I } \{ n ( \mathbf { s } , \pi ^ { * } ( \mathbf { s } ) ) = 0 \} \right] } \\ & { \quad \leq | \mathcal { S } | c + C ^ { * } H \displaystyle \sum _ { \mathbf { s } } \mu ( \mathbf { s } , \pi ^ { * } ( \mathbf { s } ) ) ( 1 - \mu ( \mathbf { s } , \pi ^ { * } ( \mathbf { s } ) ) ) ^ { N } } \\ & { \quad \leq | \mathcal { S } | b + \frac { C ^ { * } | \mathcal { S } | \mathcal { L } } { N } , } \end{array} +$$ + +where we use that $\rho ( \mathbf { s } ) \leq H d ^ { * } ( \mathbf { s } , \pi ^ { * } ( \mathbf { s } ) )$ , and that + +$$ +\operatorname* { m a x } _ { p \in [ \frac { \log H } { N } , 1 ] } p ( 1 - p ) ^ { N } \leq \frac { \log H } { N } \left( 1 - \frac { \log H } { N } \right) ^ { N } \leq \frac { \log H } { H N } . +$$ + +# B.4.2 BOUND ON $\Delta _ { 3 }$ + +Due to the lower bound on $\mu ( \mathbf { s } , \mathbf { a } ) \geq b$ , we can instead bound, + +$$ +\begin{array} { r l } { \bigg [ \displaystyle \sum _ { t = 1 } ^ { m } \sum _ { ( t - 1 ) } \gamma ^ { m - t } d _ { m - t } ^ { \ast } ( \mathbf { s } , \mathbf { a } ) \bigg ] \displaystyle \sum _ { n = 0 } ^ { t } \sum _ { ( t ) } \gamma ^ { t } d _ { t } ^ { \ast } ( \mathbf { s } , \mathbf { a } ) \mathbb { E } _ { D } \left[ \displaystyle \frac { b } { n ( \mathbf { s } , \mathbf { a } ) } \right] } & { } \\ { \leq \displaystyle \sum _ { \mathbf { \hat { s } } } \displaystyle \sum _ { t = 0 } ^ { \infty } \gamma ^ { t } d _ { t } ^ { \ast } ( \mathbf { s } , \boldsymbol { \pi } ^ { \ast } ( \mathbf { s } ) ) \frac { b } { N \mu \left( \mathbf { s } , \boldsymbol { \pi } ^ { \ast } ( \mathbf { s } ) \right) } } & { } \\ { \leq \mathbb { I } \{ d ^ { \ast } ( \mathbf { s } , \mathbf { a } ) \leq \displaystyle \frac { b } { H } \} H \displaystyle \sum _ { \mathbf { \hat { s } } } \left( ( 1 - \gamma ) \displaystyle \sum _ { t = 0 } ^ { \infty } \gamma ^ { t } d _ { t } ^ { \ast } ( \mathbf { s } , \boldsymbol { \pi } ^ { \ast } ( \mathbf { s } ) ) \right) + } & { } \\ { \displaystyle \frac { H \boldsymbol { \ell } } { N c } \sum _ { \mathbf { \hat { s } } } \left( ( 1 - \gamma ) \displaystyle \sum _ { t = 0 } ^ { \infty } \gamma ^ { t } d _ { t } ^ { \ast } ( \mathbf { s } , \boldsymbol { \pi } ^ { \ast } ( \mathbf { s } ) ) \right) } & { } \\ { \leq \delta + \displaystyle \frac { H \boldsymbol { \ell } } { b N } . } \end{array} +$$ + +The analysis for bounding $\Delta _ { 3 }$ proceeds exactly as in Appendix B.2.5 but using the new bound. Namely, we end up with the recursion + +$$ +f ( i ) \leq \sqrt { \frac { H \iota } { b N } + b } \sqrt { f ( i + 1 ) } + \frac { H \iota } { b N } + b + 2 ^ { i + 1 } ( \Phi + 1 ) , +$$ + +where + +$$ +\Phi : = \sqrt { \frac { H \iota } { b N } + b } \sqrt { \sum _ { t = 1 } ^ { m } \sum _ { ( \mathbf { s } , \mathbf { a } ) } \gamma ^ { m - t } d _ { m - t } ^ { \ast } ( \mathbf { s } , \mathbf { a } ) \mathbb { V } ( \widehat { P } ( \mathbf { s } , \mathbf { a } ) , \widehat { V } _ { t - 1 } ) } + \frac { H \iota } { N b } + b . +$$ + +Using Lemma B.4 and proceeding as in Appendix B.2.5 yields the bound + +$$ +\Delta _ { 3 } \leq \sqrt { \frac { H \iota } { b N } } + \frac { H \iota } { b N } + \sqrt { b \iota } . +$$ + +Combining the new bounds for $\Delta _ { 2 } , \Delta _ { 3 }$ results in the bound in the Corollary 4.2. + +# B.5 PROOF OF THEOREM 4.4 + +The proof of Theorem 4.4 builds on analysis by Agarwal et al. [2] that we apply to policies with a softmax parameterization, which we define below. + +Definition B.2 (Softmax parameterization). For a given θ ∈ R|S|×|A|, πθ(a|s) = P exp(θs,a)a′ exp(θs,a′ ) . + +We consider generalized BC algorithms that perform advantage-weighted policy improvement for $k$ improvement steps. A BC algorithm with $k$ -step policy improvement is defined as follows: + +Definition B.3 (BC with $k$ -step policy improvement). Let $\widehat { A } ^ { k } ( \mathbf { s } , \mathbf { a } )$ denote the advantage of action a at state s under a given policy $\widehat { \pi } _ { k }$ , where the policy $\widehat { \pi } ^ { k } ( \mathbf { a } | \mathbf { s } )$ is defined via the recursion: + +$$ +\widehat { \pi } ^ { k + 1 } ( \mathbf { a } | \mathbf { s } ) : = \widehat { \pi } ^ { k } ( \mathbf { a } | \mathbf { s } ) \frac { \exp ( \eta H \widehat { A } ^ { k } ( \mathbf { s } , \mathbf { a } ) ) } { \mathbb { Z } _ { k } ( \mathbf { s } ) } , +$$ + +starting from $\widehat { \pi } ^ { 0 } ( \mathbf { a } | \mathbf { s } ) = \widehat { \pi } _ { \beta }$ . Then, $B C$ with $k$ -step policy improvement returns $\widehat { \pi } ^ { k }$ + +This advantage weighted update is utilized in practical works such as Brandfonbrener et al. [6], which first estimates the Q-function of the behavior policy using the offline dataset, i.e, $\widehat { Q } ^ { 0 } ( \mathbf { s } , \mathbf { a } )$ , and then computes $\widehat { \pi } ^ { 1 }$ as the final policy returned by the algorithm. To understand the performance difference bbetween multiple values of $k$ , we first utilize essentially Lemma 5 from Agarwal et al. [2], which we present below for completeness: + +Lemma B.11 (Lower bound on policy improvement in the empirical MDP, $\widehat { M }$ ). The iterates $\widehat { \pi } ^ { k }$ generated by $k$ -steps of policy improvement, for any initial state distributions $\rho _ { 0 } ( \mathbf { s } )$ b satisfy the following lower-bound on improvement: + +$$ +\widehat { J } ( \widehat { \pi } ^ { k + 1 } ) - \widehat { J } ( \widehat { \pi } ^ { k } ) : = \mathbb { E } _ { \mathbf { s } _ { 0 } \sim \rho _ { 0 } } \left[ \widehat { V } ^ { \widehat { \pi } _ { k + 1 } } ( \mathbf { s } _ { 0 } ) \right] - \mathbb { E } _ { \mathbf { s } _ { 0 } \sim \rho _ { 0 } } \left[ \widehat { V } ^ { \widehat { \pi } _ { k } } ( \mathbf { s } _ { 0 } ) \right] \geq \frac { 1 } { \eta H } \mathbb { E } _ { \mathbf { s } _ { 0 } \sim \rho _ { 0 } } \log \mathbb { Z } _ { t } ( \mathbf { s } _ { 0 } ) . +$$ + +Proof. We utilize the performance difference lemma in the empirical MDP to show this: + +$$ +\begin{array} { r l } { \widehat { J } ( \widehat { \pi } ^ { k + 1 } ) - \widehat { J } ( \widehat { \pi } ^ { k } ) = H \mathbb { E } _ { \mathbf { s } \sim d ^ { \widehat { \pi } _ { k + 1 } } } \left[ \displaystyle \sum _ { \mathbf { a } } \widehat { \pi } _ { k + 1 } ( \mathbf { a } | \mathbf { s } ) \widehat { A } ^ { k } ( \mathbf { s } , \mathbf { a } ) \right] } & { } \\ & { = \frac { 1 } { \eta } \mathbb { E } _ { \mathbf { s } \sim d ^ { \widehat { \pi } _ { k + 1 } } } \left[ \displaystyle \sum _ { \mathbf { a } } \widehat { \pi } ^ { k + 1 } ( \mathbf { a } | \mathbf { s } ) \log \frac { \widehat { \pi } ^ { k + 1 } ( \mathbf { a } | \mathbf { s } ) \mathbb { Z } _ { k } ( \mathbf { s } ) } { \widehat { \pi } ^ { k } ( \mathbf { a } | \mathbf { s } ) } \right] } \\ & { = \frac { 1 } { \eta } \mathbb { E } _ { \mathbf { s } \sim d ^ { \widehat { \pi } _ { k + 1 } } } \left[ \operatorname { D } _ { \mathbf { K L } } ( \widehat { \pi } ^ { k + 1 } ( \cdot | \mathbf { s } ) | | \widehat { \pi } ^ { k } ( \cdot | \mathbf { s } ) ) \right] + \frac { 1 } { \eta } \mathbb { E } _ { \mathbf { s } \sim d ^ { \overline { { \pi } } _ { k + 1 } } } \left[ \log \mathbb { Z } _ { k } ( \mathbf { s } ) \right] } \\ & { \geq \frac { 1 } { \eta } \mathbb { E } _ { \mathbf { s } \sim d ^ { \widehat { \pi } _ { k + 1 } } } \left[ \log \mathbb { Z } _ { k } ( \mathbf { s } ) \right] . } \end{array} +$$ + +Finally, note that the final term $\log \mathbb { Z } _ { t } ( \mathbf { s } )$ is always positive because of Jensen’s inequality, and the fact that the expected advantage under a given policy is 0 for any MDP. □ + +Utilizing Lemma B.11, we can then lower bound the total improvement of the learned policy in the actual MDP as: + +$$ +\begin{array} { r l } & { J ( \widehat \pi ^ { k } ) - J ( \widehat \pi ^ { l } ) \geq \underbrace { J ( \widehat \pi ^ { k } ) - \widehat J ( \widehat \pi ^ { k } ) } _ { ( \mathrm { a } ) } + \underbrace { \widehat J ( \widehat \pi ^ { k } ) - \widehat J ( \widehat \pi ^ { l } ) } _ { ( \mathrm { b } ) } - \underbrace { J ( \widehat \pi ^ { l } ) - \widehat J ( \widehat \pi ^ { l } ) } _ { ( \mathrm { c } ) } - \underbrace { \widehat J ( \widehat \pi ^ { l } ) - \widehat J ( \widehat \pi ^ { l } ) } _ { ( \mathrm { c } ) } } \\ & { \qquad \geq \displaystyle \frac { 1 } { \eta } \sum _ { j = l } ^ { k } \mathbb { E } _ { { \mathbf s } \sim d ^ { \widehat \pi _ { j + 1 } } } \left[ \log \mathbb { Z } _ { j } ( { \mathbf s } ) \right] - \sqrt { \frac { C ^ { * } H \iota } { N } } } \end{array} +$$ + +where the $\sqrt { C ^ { * } H \iota / N }$ guarantee for terms (a) and (c) arises under the conditions studied in Section 4.3. + +Interpretation of Theorem 4.4. Theorem 4.4 says that if atleast $k$ many updates can be made to the underlying empirical MDP, $\widehat { M }$ , such that each update is non-trivially lower-bounded, i.e., $\mathbb { E } _ { \mathbf { s } \sim d _ { k + 1 } ^ { \widehat { \pi } } } \left[ \log \mathbb { Z } _ { k } ( \mathbf { \bar { s } } ) \right] \geq c _ { 0 } > 0$ , then the performance improvement obtained by $k$ -steps of policy improvement is bounded below by $k c _ { 0 } / \eta - \mathcal { O } ( \sqrt { H / N } )$ . This result indicates that if $k = \mathcal { O } ( H )$ many high advantage policy updates are possible in a given empirical MDP, then the methods with that perform $\mathcal { O } ( H )$ steps of policy improvement will attain higher performance than the counterparts that perform only one update. + +This is typically the case in maze navigation-style environments, where $\mathcal O ( H )$ many possible highadvantage updates are possible on the empirical MDP, especially by “stitching” parts of suboptimal trajectories to obtain a much better trajectory. Therefore, we expect that in offline RL problems where stitching is possible, offline RL algorithms will attain an improved performance compared to one or a few-steps of policy improvement. + +# C GUARANTEES FOR POLICY-CONSTRAINT OFFLINE RL + +In this section, we analyze a policy-constraint offline algorithm [34] that constrains the policy to choose a safe set of actions by explicitly preventing action selection from previously unseen, lowdensity actions. The algorithm we consider builds upon the MBS-PI algorithm from Liu et al. [36], which truncates Bellman backups and policy improvement steps from low-density, out-of-support state-action pairs. The algorithm is described in detail in Algorithm 2, but we provide a summary below. Let $\bar { \widehat { \mu } ( \mathbf { s } , \mathbf { a } ) }$ denote the empirical state-action distribution and choose a constant $b$ . Then, let $\zeta ( \mathbf { s } , \mathbf { a } ) = 1 \{ \widehat { \mu } ( \mathbf { s } , \mathbf { a } ) \geq b \}$ be the indicator of high-density state-action tuples. The algorithm we banalyze performs the following update until convergence: + +$$ +\begin{array} { r l } & { \widehat { Q } _ { \zeta } ^ { \pi } ( \mathbf { s } , \mathbf { a } ) \ \widehat { r } ( \mathbf { s } , \mathbf { a } ) + \gamma \displaystyle \sum _ { ( \mathbf { s } ^ { \prime } , \mathbf { a } ^ { \prime } ) } \widehat { P } ( \mathbf { s } ^ { \prime } | \mathbf { s } , \mathbf { a } ) \pi ( \mathbf { a } ^ { \prime } | \mathbf { s } ^ { \prime } ) \zeta ( \mathbf { s } ^ { \prime } , \mathbf { a } ^ { \prime } ) \cdot \widehat { Q } _ { \zeta } ^ { \pi } ( \mathbf { s } ^ { \prime } , \mathbf { a } ^ { \prime } ) , \quad \mathrm { f o r ~ a l l ~ } ( \mathbf { s } , \mathbf { a } ) , } \\ & { \quad \quad \quad \widehat { \mathcal { \alpha } } _ { \zeta } ^ { \pi } ( \mathbf { s } , \mathbf { a } ) } \\ & { \quad \quad \quad \pi \ \arg \operatorname* { m a x } \mathbb { E } _ { \mathbf { s } \sim \mathcal { D } } [ \mathbb { E } _ { \mathbf { a } \sim \pi ^ { \prime } } [ \zeta ( \mathbf { s } , \mathbf { a } ) \cdot \widehat { Q } _ { \zeta } ^ { \pi } ( \mathbf { s } , \mathbf { a } ) ] ] , } \end{array} +$$ + +In order to derive performance guarantees for this generic policy-constraint algorithm, we define the notion of a $\zeta -$ covered policy following Liu et al. [36] in Definition C.1. The total occupancy of all out-of-support state-action pairs (i.e., $( \mathbf { s } , \mathbf { a } )$ such that $\zeta ( \mathbf { s } , \mathbf { a } ) = 0 ,$ under a $\zeta$ -covered policy is bounded by a small constant $U$ , which depends on the threshold $b$ . Let $\pi _ { \zeta } ^ { * }$ denote the best performing $\zeta$ -covered policy. + +Definition C.1 ( $\zeta$ -covered). $\pi$ is called $\zeta$ -covered i $\begin{array} { r } { ^ { \prime } \sum _ { ( \mathbf { s } , \mathbf { a } ) } ( 1 - \zeta ( \mathbf { s } , \mathbf { a } ) ) d ^ { \pi } ( \mathbf { s } , \mathbf { a } ) \leq ( 1 - \gamma ) U ( b ) . } \end{array}$ + +Equipped with this definition C.1, Lemma C.1 shows that the total value estimation error of any given $\zeta -$ covered policy, $\pi$ , $| J ( \pi ) - \widehat { J } _ { \zeta } ( \pi ) |$ is upper bounded in expectation over the dataset + +Lemma C.1 (Value estimation error of a $\zeta$ -covered policy). For any given $\zeta$ -covered policy $\pi$ , under Condition 3.2, the estimation error $| J ( \pi ) - \widehat { J } _ { \zeta } ( \pi ) |$ is bounded as: + +$$ +\mathbb { E } _ { \mathcal { D } } \left[ \left| J ( \pi ) - \widehat { J } _ { \zeta } ( \pi ) \right| \right] \lesssim \sqrt { \frac { C ^ { * } | \mathcal { S } | H \iota } { N } } + \frac { C ^ { * } | \mathcal { S } | H \iota } { N } + U ( b ) +$$ + +Proof. To prove this lemma, we consider the following decomposition of the policy performance estimate: + +$$ +\begin{array} { r l } & { \Big | J ( \pi ) - \widehat { J } _ { \zeta } ( \pi ) \Big | } \\ & { = \displaystyle \sum _ { t = 0 } ^ { \infty } \displaystyle \sum _ { ( \mathbf { s } , \mathbf { a } ) } \gamma ^ { t } d _ { t } ^ { \pi } ( \mathbf { s } , \mathbf { a } ) \left[ \displaystyle \sum _ { ( \mathbf { s } ^ { \prime } , \mathbf { a } ^ { \prime } ) } \left( \widehat { P } ( \mathbf { s } ^ { \prime } | \mathbf { s } , \mathbf { a } ) \zeta ( \mathbf { s } ^ { \prime } , \mathbf { a } ^ { \prime } ) - P ( \mathbf { s } ^ { \prime } | \mathbf { s } , \mathbf { a } ) \right) \cdot \widehat { Q } ^ { \pi } ( \mathbf { s } ^ { \prime } , \mathbf { a } ^ { \prime } ) \right] } \\ & { = \displaystyle \sum _ { t = 0 } ^ { \infty } \displaystyle \sum _ { ( \mathbf { s } , \mathbf { a } ) } \gamma ^ { t } d _ { t } ^ { \pi } ( \mathbf { s } , \mathbf { a } ) \sum _ { ( \mathbf { s } ^ { \prime } , \mathbf { a } ^ { \prime } ) } \left( \widehat { P } ( \mathbf { s } ^ { \prime } | \mathbf { s } , \mathbf { a } ) - P ( \mathbf { s } ^ { \prime } | \mathbf { s } , \mathbf { a } ) \right) \cdot \zeta ( \mathbf { s } ^ { \prime } , \mathbf { a } ^ { \prime } ) \cdot \pi ( \mathbf { a } ^ { \prime } | \mathbf { s } ^ { \prime } ) \cdot \widehat { Q } ( \mathbf { s } ^ { \prime } , \mathbf { a } ^ { \prime } ) } \end{array} +$$ + +$$ ++ \sum _ { t = 0 } ^ { \infty } \gamma ^ { t } d _ { t } ^ { \pi } ( \mathbf { s } , \mathbf { a } ) \sum _ { ( \mathbf { s } ^ { \prime } , \mathbf { a } ^ { \prime } ) } P ( \mathbf { s } ^ { \prime } | \mathbf { s } , \mathbf { a } ) \cdot \left( 1 - \zeta ( \mathbf { s } ^ { \prime } , \mathbf { a } ^ { \prime } ) \right) \cdot \pi ( \mathbf { a } ^ { \prime } | \mathbf { s } ^ { \prime } ) \cdot \widehat { Q } ^ { \pi } ( \mathbf { s } ^ { \prime } , \mathbf { a } ^ { \prime } ) +$$ + +To bound the inner summation over $( \mathbf { s } ^ { \prime } , \mathbf { a } ^ { \prime } )$ in term (a), we can apply Lemma B.5 since $\widehat { P } ( \mathbf { s } ^ { \prime } | \mathbf { s } , \mathbf { a } )$ and $\zeta ( \mathbf { s } ^ { \prime } , \mathbf { a } ^ { \prime } )$ are not independent, to obtain a horizon-free bound. Finally, we use Condition 3.1 to bound the density ratios, in expectation over the randomness in dataset $\mathcal { D }$ , identical to the proof for the conservative lower-confidence bound method from before. Formally, using Lemma B.5, we get, with high probability $\geq 1 - \delta$ : + +$$ +\forall ( \mathbf { s } , \mathbf { a } ) \ \mathrm { s . t . } \ n ( \mathbf { s } , \mathbf { a } ) \geq 1 , \ \left| \left( \widehat { P } ( \mathbf { s } , \mathbf { a } ) - P ( \mathbf { s } , \mathbf { a } ) \right) \cdot \widehat { V } _ { \zeta } ^ { \pi } \right| \leq \sqrt { \frac { \mathbb { V } ( \widehat { P } ( \mathbf { s } , \mathbf { a } ) , \widehat { V } _ { \zeta } ^ { \pi } ) \iota } { n ( \mathbf { s } , \mathbf { a } ) } } + \frac { \iota } { n ( \mathbf { s } , \mathbf { a } ) } , +$$ + +where we utilized the fact that $\widehat { V } _ { \zeta } ^ { \pi } \leq \widehat { V } ^ { \pi } \leq 1$ due to Condition 3.2. For bounding $\Delta _ { 2 }$ , we note that this term is bounded by the definition of $\zeta$ -covered policy: + +$$ +\Delta _ { 2 } \leq \sum _ { t = 0 } ^ { \infty } \gamma ^ { t } ( 1 - \gamma ) U ( b ) \leq U ( b ) . +$$ + +Thus, the overall policy evaluation error is given by: + +$$ +\left| J ( \pi ) - { \widehat { J } } _ { \zeta } ( \pi ) \right| \lesssim \sum _ { t = 0 } ^ { \infty } \gamma ^ { t } d _ { t } ^ { \pi } ( \mathbf { s } , \mathbf { a } ) \left[ \sqrt { \frac { \mathbb { V } ( \widehat { P } ( \mathbf { s } , \mathbf { a } ) , \widehat { V } _ { \zeta } ^ { \pi } ) \iota } { n ( \mathbf { s } , \mathbf { a } ) } } + \frac { \iota } { n ( \mathbf { s } , \mathbf { a } ) } \right] + U ( b ) . +$$ + +![](images/09d1a432d399f7f4c6fee59c149611c0ec89f43c8082d2d26b8d87d8478e4c1c.jpg) +Figure 4: (Figure 1 restated) Illustration showing the intuition behind critical points in a navigation task. The agent is supposed to navigate to a high-reward region marked as the yellow polygon, without crashing into the walls. For different states, A, $\mathbf { B }$ and C that we consider, the agent has a high volume of actions that allow it to reach the goal at states A and C, but only few actions that allow it to do so at state B. States around A and C are not critical, and so this task has only a small volume of critical states (i.e., those in the thin tunnel). + +Equation 15 mimics the $\Phi$ term in equation 9 that is bounded in Section B.2.5, with an additional offset $U ( b )$ . Hence, we can reuse the same machinery to show the bound in expectation over the randomness in the dataset, which completes the proof. □ + +Using Lemma C.1, we can now that the policy constraint algorithm attains a favorable guarantee when compared to the best policy that is $\zeta$ -covered: + +Theorem C.1 (Performance of policy-constraint offline RL). Under Condition 3.2, the policy $\widehat { \pi } ^ { * }$ incurs bounded suboptimality against the best $\zeta$ -covered policy, with high probability $\geq 1 - \delta$ : + +$$ +\mathbb { E } _ { \mathcal { D } } \left[ J ( \pi _ { \zeta } ^ { * } ) - J ( \widehat { \pi } ^ { * } ) \right] \lesssim \sqrt { \frac { C ^ { * } | \mathcal { S } | H \iota } { N } } + \frac { C ^ { * } | \mathcal { S } | H \iota } { N } + 2 U ( b ) . +$$ + +To prove this theorem, we use the result of Lemma C.1 for the fixed policy, that is agnostic of the dataset, and then again use the recursion as before to bound the value of the data-dependent policy. The latter uses Lemma B.5 and ends up attaining a bound previously found in Appendix B.2.5, which completes the proof of this Theorem. When the term $U ( b )$ is small, such that $U \dot { ( b ) } \le \mathcal { O } ( H ^ { 0 . 5 - \varepsilon } )$ for $\varepsilon > 0$ , then we find that the guarantee in Theorem C.1 matches that in Theorem 4.2, modulo a term that grows slower in the horizon than the other terms in the bound. If $U ( b )$ is indeed small, then all properties that applied to conservative offline RL shall also follow for policy-constraint algorithms. + +Note on the bound. We conjecture that it is possible to get rid of the $U ( b )$ term, under certain assumptions on the support indicator $\zeta ( \mathbf { s } , \mathbf { a } )$ , and by relating the values of $\zeta ( \mathbf { s } , \mathbf { a } )$ and $\zeta ( \mathbf { s } ^ { \prime } , \mathbf { a } ^ { \prime } )$ , at consecutive state-action tuples. For example, if $\zeta ( \mathbf { s } ^ { \prime } , \mathbf { a } ^ { \prime } ) = 1 \implies \zeta ( \mathbf { s } , \mathbf { a } ) = 1$ , then we can derive a stronger guarantee. + +# D INTUITIVE ILLUSTRATIONS OF THE CONDITIONS ON THE ENVIRONMENT AND PRACTICAL GUIDELINES FOR VERIFYING THEM + +In this section, we present intuitive illustrations of the various conditions we study and discuss practical guidelines that allow a practitioner to verify whether they are likely to hold for their problem domain. We focus on Conditions 4.1 and 4.2, as Condition 3.2 is satisfied in very common settings such as learning from sparse rewards obtained at the end of an episode, indicating success or failure. + +# D.1 CONDITION 4.1 + +To provide intuition behind when this condition is satisfied, we first provide an example of a sample navigation domain in Figure 4, to build examples of critical states. As shown in the figure, the task is to navigate to the high-reward yellow-colored region. We wish to understand if states marked as A, $\mathbf { B }$ and C are critical or not. The region where the agent can move is very wide in the neighborhood around state A, very narrow around state $\mathbf { B }$ and wide again around state C. In this case, as marked on the figure if the agent executes actions shown via green arrows at the various states, then it is likely to sill finish the task, while if it executes the actions shown via red arrows it is likely not on track to reach the high-reward region. + +Several actions at states A and C allow the agent to still reach the goal, without crashing into the walls, while only one action at state B allows so, as shown in the figure. Thus, state B is a “critical state” as per Definition ??. But since most of the states in the wide regions of the tunnel are non-critical, this navigation domain satisfies Condition 4.1. + +# D.2 CONDITION 4.2 + +Now we discuss the intuition behind why offline RL run on a form of noisy-expert data can outperform BC on expert data. As shown in Figure 5, the task is to navigate from the Start to the Goal. In this case, when BC is trained using only expert trajectories, and the environment consists of a stochastic dynamics, then running the BC policy during evaluation may diverge to low reward regions as shown in the second row, second column of Figure 5. On the other hand, if RL is provided with some noisy-expert data that visits states around expert trajectories which might eventually lead to low-rewarding states, then an effective offline RL method should be able to figure out how to avoid such states and solve the task successfully. + +![](images/c60a2ed19aa766e7a853a197c47638ba4899f5c460876cd3a94622f82d31f1d1.jpg) +Figure 5: (Figure 2 restated) Illustration showing the intuition behind suboptimal data in a simple navigation task. BC trained on expert data (data composition is shown on the left) may diverge away from the expert and find a poor policy that does not solve the task. On the other hand, if instead of expert data, offline RL is provided with noisy expert data that sometimes ventures away from the expert distribution, RL can use this data to learn to stay on the course to the goal. + +Condition 4.2 requires that state-action tuples with $d ^ { * } ( \mathbf { s } , \mathbf { a } ) \geq b / H$ under the expert policy have high-enough density $\mu ( \mathbf { s } , \mathbf { a } ) \geq b$ under the data distribution. There are two ways to attain this condition: (1) the expert policy already sufficiently explores the state $( d ^ { * } ( \mathbf { s } , \mathbf { a } ) \geq b )$ ), for example, when the environment is mostly deterministic or when trajectories are cyclic (e.g., in locomotion tasks discussed below), or, (2) the offline dataset is noisy such that states that are less-frequently visited by the expert are explored more in the data. The latter can be satisfied when the agent is provided with “negative data”, i.e., failed trajectories, starting from states in an optimal trajectory as shown in Figure 5. Such counterfactual trajectories allow the agent to observe more outcomes starting from a state in the optimal trajectory. And running offline RL on them will enable the agent to learn what not to do, as illustrated in Figure 5. On the other hand, BC cannot use this negative data. + +This condition is satisfied in the following practical problems: + +• Robotics: In robotics noisy-expert data may not be directly available via demonstrations but can be obtained by a practitioner by running some limited autonomous data collection using noisy scripted policies (e.g., Kalashnikov et al. [21] and Kalashnikov et al. [23] run partly trained RL policies for noisy collection for running offline RL). Another simple way to obtain such data is to first run standard BC on the offline demonstrations, then store the rollouts obtained from the BC policy when evaluating it, and then run offline RL on the entire dataset (of expert demonstrations $^ +$ suboptimal/noisy BC evaluation rollouts). + +• Autonomous driving and robotics: In some domains such as autonomous driving and robotics, rolling out short counterfactual trajectories from states visited in the offline data, and labeling it with failures is a common strategy [5, 51]. A practitioner could therefore satisfy this condition by tuning the amount of counterfactual data they augment to training. + +• Recommender systems: In recommender systems, Chen et al. [9] found that it was practical to add additional stochasticity while rolling out a policy for data collection which could be controlled, enabling the practitioner to satisfy this condition. + +• Trajectories consist of cyclic states (e.g., robot locomotion, character animation in computer graphics): This condition can be satisfied in several applications such as locomotion (e.g., in character animation in computer graphics [46], or open-world robot navigation [57]) where the states observed by the agent are repeated over the course of the trajectory. Therefore a state with sufficient density under the optimal policy may appear enough times under $\mu$ . + +# D.3 PRACTICAL GUIDELINES FOR VERIFYING THESE CONDITIONS + +These conditions listed above and discussed in the paper can be difficult to check for in practice; for example, it is non-obvious how to quantitatively compute the volume of critical states, or how wellexplored the dataset is. However, we believe that a practitioner who has sufficient domain-specific knowledge has enough intuition to qualitatively reason about whether the conditions hold. We believe that such practitioners can answer the following questions about their particular problem domain: + +• Does there only exist a large fraction of states along a trajectory where either multiple good actions exist, or it is easy to recover from suboptimal actions? +• Is the offline dataset collected from a noisy-expert policy, and if not, can the dataset be augmented using perturbed or simulated trajectories? + +If either of those questions can be answered positively, our theoretical and empirical results show that it is favorable to use offline RL algorithms, even over collecting expert data and using BC. At least, offline RL algorithms should be tried on the problem under consideration. Hence, the goal of our contributions is not to provide a rigid set of guidelines, but rather provide practical advice to the ML practitioner. We would like to highlight that such non-rigid guidelines exist in general machine learning, beyond RL. For example, in supervised learning, tuning the architecture of a deep neural network depends heavily on domain knowledge, and choosing kernel in a kernel machine again depends on the domain. + +# E EXPERIMENTAL DETAILS + +In this section we provide a detailed description of the various tasks used in this paper, and describe the data collection procedures for various tasks considered. We discuss the details of our tasks and empirical validation at the following website: https://sites.google.com/view/ shouldirunrlorbc/home. + +# E.1 TABULAR GRIDWORLD DOMAINS + +The gridworld domains we consider are described by $1 0 \times 1 0$ grids, with a start and goal state, and walls and lava placed in between. We consider a sparse reward where the agent earns a reward of 1 upon reaching the goal state; however, if the agent reaches a lava state, then its reward is 0 for the rest of the trajectory. The agent is able to move in either of the four direction (or choose to stay still); to introduce stochasticity in the transition dynamics, there is a $1 0 \%$ chance that the agent travels in a different direction than commanded. + +The exact three gridworlds we evaluate on vary in the number of critical points encountered per trajectory. We model critical states as holes in walls through which the agent must pass; if the agent chooses a wrong action at those states, it veers off into a lava state. The exact three gridworlds we evaluate on are: (a) “Single Critical” with one critical state per trajectory, (b) “Multiple Critical” with three critical states per trajectory, and (c) “Cliffwalk”, where every state is critical [56]. The renderings of each gridworld are in Figure 6. + +![](images/c1e359ce227d08e44fed8770f757bf198438c13760fae9f2780f01c63a61975c.jpg) +Figure 6: Renderings of three gridworld domains we evaluate on, where states are colored as: Start:blue, Goal:green, Lava:red, Wall:grey, and Open:white. The domains have varying number of critical points. Left: Single Critical. Middle: Multiple Critical. Right: Cliffwalk. + +# E.2 MULTI-STAGE ROBOTIC MANIPULATION DOMAINS + +Overview of domains. These tasks are taken from Singh et al. [60]. The robotic manipulation simulated domains comprise of a 6-DoF WidowX robot that interacts with objects in the environment. There are three tasks of interest, all of which involve a drawer and a tray. The objective of each task is to remove obstructions of the drawer, open the drawer, pick an object and place it in a tray. The obstructions of the drawer were varied giving rise to three different domains — open-grasp (no obstruction of the drawer), close-open-grasp (an open top drawer obstructs the bottom drawer), pick-place-open-grasp (an object obstructs the bottom drawer). + +![](images/bfad56b70268b047e66af3096ba53434f9cb09d564b47a04e0ee8ff7f50b5ef6.jpg) +Figure 7: Filmstrip of the three tasks that we stufy for robotic manipulation – open-grasp, close-open-grasp and pick-place-open-grasp. + +Reward function. For all the three tasks considered, a reward of $+ 1$ is provided when the robot is successfully able to open the drawer of interest (bottom drawer in close-open-grasp and pick-placeopen-grasp; the only drawer in open-grasp) and is able to grasp the object inside it. If the robot fails at doing so, it gets no reward. + +Dataset composition. For each task, we collected a dataset comprising of 5000 trajectories. For our experiments where we utilize expert data, we used the (nearly)-expert scripted policy for collecting trajectories and discarded the ones that failed to succeed. Thus the expert data attains a $100 \%$ success rate on this task. For our experiments with suboptimal data, which is used to train offline RL, we ran a noisy version of this near-expert scripted policy and collected 5000 trajectories. The average success rate in the suboptimal data is around $40 \%$ in both opening and closing the drawers with, $70 \%$ success rate in grasping objects, and a $70 \%$ success rate in place those objects at random locations in the workspace. + +# E.3 ANTMAZE DOMAINS + +Overview of the domain. This task is based on the antmaze-medium and antmaze-large environments from Fu et al. [14]. The goal in this environment is to train an 8-DoF quadraped ant robot to successfully navigate to a given, pre-specifcied target location in a maze. We consider two different maze layouts provided by Fu et al. [14]. We believe that this domain is well-suited to test BC and RL methods in the presence of multiple critical points, and is representative of real-world navigation scenarios. + +Scripted policies and datasets. We utilize the scripted policies provided by Fu et al. [14] to generate two kinds of expert datasets: first, we generate trajectories that actually traverse the path from a given default start location to the target goal location that we consider for evaluation, and second, we generate trajectories that go from multiple random start positions in the maze to the target goal location in the maze. The latter has a wider coverage and a different initial state distribution compared to what we will test these algorithms on. We collected a dataset of 500k transitions, which was used by both BC and offline RL. + +Reward functions. In this task, we consider a sparse binary reward $r ( \mathbf { s } , \mathbf { a } ) = + 1$ , if $| \mathbf { s } ^ { \prime } - \mathbf { g } | \leq \varepsilon =$ 0.5 and 0 otherwise. This reward is only provided at the end of a trajectory. This reward function is identical to the one reported by D4RL [14], but the dataset composition in our case comes from an expert policy. + +# E.4 ADROIT DOMAINS + +Overview of the domain. The Adroit domains [50, 14] involve controlling a 24-DoF simulated Shadow Hand robot tasked with hammering a nail (hammer), opening a door (door), twirling a pen (pen) or picking up and moving a ball (relocate). This domain presents itself with narrow data distributions, and we utilize the demonstrations provided by Rajeswaran et al. [50] as our expert dataset for this task. The environments were instantiated via D4RL, and we utilized the environments marked as: hammer-human-longhorizon, door-human-longhorizon, pen-human-longhorizon and relocate-human-longhorizon for evaluation. + +Reward functions. We directly utilize the data from D4RL [14] for this task. However, we modify the reward function to be used for RL. While the D4RL adroit domains provide a dense reward function, with intermediate bonuses provided for various steps, we train offline RL using a binary reward function. To compute this binary reward function, we first extract the D4RL dataset for these tasks, and then modify the reward function as follows: + +$$ +\begin{array} { r l } & { r ( \mathbf { s } , \mathbf { a } ) = + 1 ~ \mathrm { i f } ~ r _ { \mathrm { D 4 R L } } ( \mathbf { s } , \mathbf { a } ) \geq 7 0 . 0 } \\ & { r ( \mathbf { s } , \mathbf { a } ) = + 1 ~ \mathrm { i f } ~ r _ { \mathrm { D 4 R L } } ( \mathbf { s } , \mathbf { a } ) \geq 9 . 0 } \\ & { r ( \mathbf { s } , \mathbf { a } ) = + 1 ~ \mathrm { i f } ~ r _ { \mathrm { D 4 R L } } ( \mathbf { s } , \mathbf { a } ) \geq 4 7 . 0 } \\ & { r ( \mathbf { s } , \mathbf { a } ) = + 1 ~ \mathrm { i f } ~ r _ { \mathrm { D 4 R L } } ( \mathbf { s } , \mathbf { a } ) \geq 1 8 . 0 } \end{array} +$$ + +The constant thresholds for various tasks are chosen in a way that only any transition that actually activates the flag goal achieved $\underline { { \underline { { \mathbf { \Pi } } } } } =$ True flag in the D4RL Adroit environments attains a reward $+ 1$ , while other transitions attain a reward 0. We evaluate the performance of various algorithms on this new sparse reward that we consider for our setting. + +# E.5 ATARI DOMAINS + +We utilized 7 Atari games which are commonly studied in prior work [27, 28]: ASTERIX, BREAKOUT, SEAQUEST, PONG, SpaceInvaders, ${ \bf Q } ^ { * } { \bf B } { \bf E } { \bf R } { \bf T }$ , ENDURO for our experiments. We do not modify the Atari domains, directly utilize the sparse reward for RL training and operate in the stochastic Atari setting with sticky actions for our evaluations. For our experiments, we extracted datasets of different qualities from the DQN-Replay dataset provided by Agarwal et al. [3]. The DQN-Replay dataset is stored as 50 buffers consisting of sequentially stored data observed during training of an online DQN agent over the course of training. + +Expert data. To obtain expert data for training BC and RL algorithms, we utilized all the data from buffer with id 49 (i.e., the last buffer stored). Since each buffer in DQN-Replay consists of 1M transition samples, all algorithms training on expert data learn from 1M samples. + +Table 3: Per-game results for the Atari domains with expert data. Note that while na¨ıve CQL does not perform much better than BC (it performs similarly as BC), tuned CQL with the addition of the DR3 regularizer performs much better. + +
Domain /Behavior PolicyTask/Data QualityBCNaive CQLTuned CQL
7 Atari games (RL policy)Pong,Expert109.78 ± 2.93102.03 ± 4.43105.84 ± 2.22
Breakout,Expert75.59 ± 21.5971.22 ± 27.5594.77 ± 27.02
Asterix,Expert41.10 ± 9.544.81 ±12.080.19 ± 20.7
SpaceInvaders,Expert40.88 ± 4.1745.27 ± 7.3254.15 ± 2.96
Q*bert, Expert121.48 ± 9.06105.83 ± 23.1798.52 ± 18.62
Enduro,Expert78.67 ± 3.98141.53 ± 18.79127.02 ± 10.53
Seaquest, Expert63.15 ± 9.4764.03 ± 27.6785.28 ± 21.28
+ +
TaskBC-PICQL
Pong100.03 ± 5.0194.48 ± 8.39
Breakout25.99 ± 1.9886.92 ± 13.74
Asterix29.77 ± 5.33157.54 ± 37.94
SpaceInvaders31.45 ± 1.9663.7 ± 16.18
Q*bert106.06 ± 8.6388.72 ± 20.41
Enduro68.56 ± 0.23148.97 ± 12.3
Seaquest22.51 ± 2.23124.95 ± 43.86
+ +Table 4: Comparing the performance of BC-PI and offline RL on noisy-expert data. Observe that in general, offline RL significantly outperforms BC-PI. + +Noisy-expert data. For obtaining noisy-expert data, analogous to the gridworld domains we study, we mix data from the optimal policy (buffer 49) with an equal amount of random exploration data drawn from the initial replay buffers in DQN replay (buffers 0-5). i.e. we utilize $0 . 5 \mathbf { M }$ samples form buffer 49 in addition to $0 . 5 \mathbf { M }$ samples sampled uniformly at random from the first 5 replay buffers. + +# F TUNING AND HYPERPARAMETERS + +In this section, we discuss our tuning strategy for BC and CQL used in our experiments. + +Tuning CQL. We tuned CQL offline, using recommendations from prior work [30]. We used default hyperparameters for the CQL algorithm (Q-function learning rate $= 3 \mathrm { e } { \cdot } 4$ , policy learning rate $= 1 \mathrm { e } { - } 4 \AA$ ), based on prior works that utilize these domains. Note that prior works do not use the kind of data distributions we use, and our expert datasets can be very different in composition compared to some of the other medium or diverse data used by prior work in these domains. In particular, with regards to the hyperaprameter $\alpha$ in CQL that trades off conservatism and the TD error objective, we used $\alpha = 0 . 1$ for all Atari games (following Kumar et al. [28]), and $\alpha = 1 . 0$ for the robotic manipulation domains following [60]. For the Antmaze and Adroit domains, we ran CQL training with multiple values of $\alpha \in \{ 0 . 0 1 , 0 . 1 , 0 . 5 , 1 . 0 , 5 . 0 , 1 0 . 0 , 2 0 . 0 \}$ , and then picked the smallest $\alpha$ that did not lead to eventually divergent Q-values (either positively or negatively) with more (1M) gradient steps. Next, we discuss how we regularized the Q-function training and performed policy selection on the various domains. + +• Detecting overfitting and underfitting: Following Kumar et al. [30], as a first step, we detect whether the run is overfitting or underfitting, by checking the trend in $\mathrm { Q }$ -values. In our experiments, we found that Q-values learned on Adroit domains exhibited a decreasing trend throughout training, from which we concluded it was overfitting. On the Antmaze and Atari experiments, Q-values continued to increase and eventually stabilized, indicating that the run might be underfitting (but not overfitting). + +• Correcting for overfitting and policy selection: As recommended, we applied a capacity decreasing regularizer to correct for overfitting, by utilizing dropout on every layer of the Q-function. We ran with three values of dropout parobability, $p \in \{ 0 . 1 , \bar { 0 } . 2 , 0 . 4 \}$ , and found that 0.4 was the most effective in alleviating the monotonically decreasing trend in $\mathrm { Q }$ -values, so used that for our results. + +Then, we performed policy checkpoint selection by picking the earliest checkpoint that appears after the peak in the Q-values for our evaluation. + +• Correcting for underfitting: In the Atari and Antmaze domains, we observed that the Q-values exhibited a stable, convergent trend and did not decrease with more training. Following Kumar et al. [30], we concluded that this resembled underfitting and utilized a capacity-increasing regularizer (DR3 regularizer [29]) for addressing this issue. We used identical hyperparameter for the multiplier $( \beta )$ on this regularizer term for both Atari and Antmaze, $\beta = 0 . 0 3$ and did not tune it. + +Tuning BC. In all domains, we tested BC with different network architectures. On the antmaze domain, we evaluated two feed-forward policy architectures of sizes (256, 256, 256) and (256, 256, 256, 256, 256, 256) and picked the one that performed best online. ON Adroit domains, we were not able to get a tanh-Gaussian policy, typically used in continuous control to work well, since it overfitted very quickly giving rise to worse-than-random performance and therefore, we switched to utilizing a Gaussian policy network with hidden layer sizes (256, 256, 256, 256), and a learned, state-dependent standard deviation. To prevent overfitting in BC, we applied a strong dropout regularization of $p = 0 . 2$ after each layer for Adroit domains. On Atari and the manipulation domains, we utilized a Resnet architecture borrowed from IMPALA [10], but without any layer norm. + +Tuning BC-PI. Our BC-PI method is implemented by training a Q-function via SARSA, i.e., $Q ( \mathbf { s } , \mathbf { a } ) r ( \mathbf { s } , \mathbf { a } ) + \gamma Q ( \mathbf { s } ^ { \prime } , \mathbf { a } ^ { \prime } )$ , where $( \mathbf { s } ^ { \prime } , \mathbf { a } ^ { \prime } )$ is the state-action pair that appears next in the trajectory after $( \mathbf { s } , \mathbf { a } )$ in the dataset using the following Bellman error loss function to train $Q _ { \theta }$ : + +$$ +\mathcal { L } ( \theta ) = \frac { 1 } { | \mathcal { D } | } \sum _ { \mathbf { s } , \mathbf { a } , \mathbf { s } ^ { \prime } , \mathbf { a } ^ { \prime } \sim \mathcal { D } } \left( Q _ { \theta } ( \mathbf { s } , \mathbf { a } ) - ( r ( \mathbf { s } , \mathbf { a } ) + \gamma \bar { Q } _ { \bar { \theta } } ( \mathbf { s } ^ { \prime } , \mathbf { a } ^ { \prime } ) \right) ^ { 2 } , +$$ + +and then performing advantage-weighted policy extraction: $\pi ( \mathbf { a } | \mathbf { s } ) \propto \widehat { \pi _ { \beta } } ( \mathbf { a } | \mathbf { s } ) \cdot \exp ( A ( \mathbf { s } , \mathbf { a } ) / \eta )$ on the offline dataset $\mathcal { D }$ c. The loss function for this policy extraction step, following Peng et al. [47] is given by: + +$$ +\pi _ { \phi } \gets \operatorname* { m a x } _ { \pi _ { \phi } } \sum _ { \mathbf { s } , \mathbf { a } } \log \pi _ { \phi } ( \mathbf { a } | \mathbf { s } ) \cdot \exp \left( \frac { Q _ { \theta } ( \mathbf { s } , \mathbf { a } ) - V ( \mathbf { s } ) } { \eta } \right) , +$$ + +where the value function was given by $\begin{array} { r } { V ( \mathbf { s } ) = \sum _ { \mathbf { a } ^ { \prime } } \pi _ { \beta } ( \mathbf { a } ^ { \prime } | \mathbf { s } ) Q _ { \theta } ( \mathbf { s } , \mathbf { a } ^ { \prime } ) } \end{array}$ and $\pi _ { \beta }$ is a learned model of the behavior policy, as done in the implementation of Brandfonbrener et al. [6]. This model of the behavior policy is trained according to the tuning protocol for BC, and is hence well-tuned. + +What we tuned: We tuned the temperature hyperparameter $\eta$ using multiple values spanning various levels of magnitude: $\{ 0 . 0 0 5 , 0 . 0 5 , 0 . 1 , 0 . 5 , 1 . 0 , 3 . 0 \}$ and additionally tried two different clippings of the advantage values $A ( \mathbf { s } , \mathbf { a } ) : = Q ( \mathbf { s } , \mathbf { a } ) - V ( \mathbf { s } )$ between $[ - 1 0 , 2 ]$ and $[ - 1 0 , 4 ]$ . The Q-function architecture is identical to tuned CQL, and the policy and the model of the behavior policy both utilize the architecture used by our BC baseline. + +Our observations: We summarize our observations below: + +• We found that in all the runs the temporal difference (TD) error for SARSA was in the range of [0.001, 0.003], indicating that the SARSA Q-function is well behaved. + +• The optimal hyperparameters that lead to the highest average performance across all games is $\eta = 0 . 0 0 5$ , and the advantage clipping between $[ - 1 0 , 2 ]$ . We find a huge variation in the performance of a given $\eta$ , but we used a single hyperparameter $\eta$ across all games, in accordance with the Atari evaluation protocols [40], and as we did for all other baselines. For example, while on some games such as Qbert, BC-PI improves quite a lot and attains $11 8 \%$ normalized return, on Enduro it attains only $78 \%$ and on SpaceInvaders it attains $3 1 . 7 \%$ . + +• These results perhaps indicate the need for per-state tuning of $\eta$ , i.e., utilizing $\eta ( \mathbf { s } )$ , however, this is not covered in our definition of BC-PI from Section 4.4, and so we chose to utilize a single $\eta$ across all states. Additionally, we are unaware of any work that utilizes per-state $\eta ( \mathbf { s } )$ values for exponentiated-advantage weighted policy extraction. + +# G REGARDING OFFLINE RL LOWER BOUNDS + +Here we address the connection between recently published lower-bounds for offline RL by Zanette [71] and Wang et al. [64] and our work. + +Zanette [71] worst-case analysis does address function approximation even under realizability and closure. However, this analysis concerns policy evaluation and applies to policies that go out of the support of the offline data. This does not necessarily prove that any conservative offline RL algorithm (i.e., one that prevents the learned policy from going out of the support of the offline dataset) would suffer from this issue during policy learning, just that there exist policies for which evaluation would be exponentially bad. Offline RL can exactly prevent the policy from going out of the support of the dataset in Zanette [71]’s counterexample since the dynamics and reward functions are deterministic. This policy can still improve over behavior cloning by stitching overlapping trajectories, similar to the discussion of one-step vs multi-step PI in Theorem 4.4. Thus, while the lower-bound applies to off-policy evaluation of some target policies, it doesn’t apply to evaluation of every policy in the MDP, and specifically does not apply to in-support policies, which modern offline RL algorithms produce, in theory and practice. Certainly, their lower bound would apply to an algorithm aiming to estimate $Q ^ { * }$ from the offline data, but that’s not the goal of pessimistic algorithms that we study. Finally, our practical results indicates that offline RL methods can be made to perform well in practice despite the possibility of any such lower bound. + +The lower bound in Wang et al. [65] only applies to non-pessimistic algorithms that do not tackle distributional shift. In fact, Section 5, Theorem 5.1 in Wang et al. [64] provides an upper bound for the performance of offline policy evaluation with low distribution shift. The algorithms analyzed in our paper are pessimistic and guarantee low distribution shift between the learned policy and the dataset, and so the lower bound does not apply to the algorithms we analyze. + +# H DIAGNOSTIC EXPERIMENTS ON A GRIDWORLD + +We first evaluate tabular versions of the BC and offline RL methods analyzed in Section 4.1 on sparse-reward $1 0 \times 1 0$ gridworlds environments [13]. Complete details about the setup can be found in Appendix E.1. On a high-level, we consider three different environments, each with varying number of critical states, from “Single Critical” with exactly one, to “Cliffwalk” where every state is critical and veering off yields zero reward. The methods we consider are: naive BC (BC), conservative RL (RL-C), policy-constraint RL (RL-PC), and generalized BC with one-step and $\mathbf { k }$ -step policy improvement (BC-PI, BC-kPI). In the left plot of Figure 8, we show the return (normalized by return of the optimal policy) across all the different environments for optimal data $C ^ { * } = 1$ ) and data generated from the optimal policy but with a different initial state distribution $C ^ { * } > 1$ but $\pi _ { \beta } ( \cdot | \bar { \bf s } ) = \pi ^ { * } ( \cdot | { \bf s } ) )$ . As expected from our discussion in Section 4.2, BC performs best under $C ^ { * } = 1$ , but RL-C and RL-PC performs much better when $C ^ { * } > 1$ ; also BC with one-step policy improvement outperforms naive BC for $C ^ { * } > 1$ , but does not beat full offline RL. In Figure 8, we vary $C ^ { * }$ by interpolating the dataset with one generated by a random policy, where $\alpha$ is the proportion of random data. RL performs much better over all BC methods, when the data supporting our analysis in Section 4.3. Finally, BC with multiple policy improvement steps performs better than one step when the data is noisy, which validates Theorem 4.4. + +![](images/faed53f70b0011589e040ef02299b2c28b7ddab1c791fcac7563165f214ea66d.jpg) +Figure 8: Offline RL vs BC on gridworld domains. Left: We compare offline RL and BC on three different gridworlds with varying number of critical points for expert and near-expert data. Right: Taking the “Multiple Critical” domain, we examine the effect of increasing the noisiness of the dataset by interpolating it with one generated by a random policy, and show that RL improves drastically with increased noise over BC. \ No newline at end of file diff --git a/md/dev/BvowzJp_Yl6/BvowzJp_Yl6.md b/md/dev/BvowzJp_Yl6/BvowzJp_Yl6.md new file mode 100644 index 0000000000000000000000000000000000000000..a5b53cc028c3de62b238c349875949004f6556c0 --- /dev/null +++ b/md/dev/BvowzJp_Yl6/BvowzJp_Yl6.md @@ -0,0 +1,205 @@ +# HOMOGENEOUS LEARNING: SELF-ATTENTION DECENTRALIZED DEEP LEARNING + +Anonymous authors Paper under double-blind review + +# ABSTRACT + +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. + +# 1 INTRODUCTION + +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. + +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. + +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 \%$ . + +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. + +# 2 RELATED WORK + +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. + +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. + +# 3 HOMOGENEOUS LEARNING + +# 3.1 PRELIMINARY + +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. + +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$ . + +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. + +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). + +$$ +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 ] +$$ + +Where $d _ { i , j }$ represents the relative distance from node $i$ to node $j$ . + +# 3.2 TECHNICAL FUNDAMENTALS OF HOMOGENEOUS LEARNING + +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. + +![](images/ecd623d62773e805fd51a645bcba731729c9badeaa981d4a95c10c43dce5965d.jpg) +Figure 1: Homogeneous learning: self-attention decentralized deep learning. + +# 3.2.1 LOCAL ML TASK MODEL + +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. + +# 3.2.2 REINFORCEMENT LEARNING MODEL + +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. + +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. + +![](images/fd916144b0198d174ea4414a40209f4a753612b47f57fc422561019066d787b6.jpg) +Figure 2: Next-node selection based on the RL model of HL. + +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. + +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. + +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$ . + +$$ +\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 } ) ) +$$ + +$$ +\theta ^ { * } = a r g m i n \ell ( \theta ) , s u b j e c t t o \theta = L _ { t } ^ { D Q N } +$$ + +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. + +Finally, the model training of $\mathrm { H L }$ is formulated as Algorithm 1. + +# Algorithm 1 Model Training of Homogeneous Learning + +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 + +# 4 EVALUATION + +# 4.1 EXPERIMENT SETUP + +# 4.1.1 DATASET. + +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. + +# 4.1.2 BASELINE MODELS. + +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. + +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. + +# 4.1.3 HOMOGENEOUS LEARNING SETTINGS. + +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. + +# 4.2 NUMERICAL RESULTS + +# 4.2.1 LEARNING A COMMUNICATION POLICY BASED ON DEEP Q-NETWORKS + +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. + +Table 1: Hyperparameters in Homogeneous Learning + +
MLTASKMODEL
RL MODEL
Epoch 1Episode 120
Batch size 32Future reward discount0.9
Learning rate 0.001Epsilon decay0.02
Optimization function AdamEpoch1
Maximum step 35 (MNIST)/100 (Fashion-MNIST)Batch size16
Learning rate0.001
+ +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. + +![](images/1d84796ab717ed20e6d99d08353be2627f19cdaa8c7ce3892b514571e1200c10.jpg) +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. + +# 4.2.2 COMPARISONS REGARDING COMPUTATIONAL AND COMMUNICATION COST + +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. + +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. + +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. + +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 \%$ . + +![](images/f8813d0e3c2c3b64e4752d432c9b2491635d8a4e2b975c4a02fc94b89fcf140d.jpg) +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. + +# 4.2.3 COMPARISONS REGARDING VARIOUS HETEROGENEITY LEVELS + +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. + +# 5 CONCLUSION + +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. + +# REFERENCES + +General data protection regulation. https://gdpr-info.eu. Accessed: 2021-09-22. + +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. + +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. + +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. + +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. + +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. + +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. + +Yann LeCun, Corinna Cortes, and CJ Burges. Mnist handwritten digit database. ATT Labs [Online]. Available: http://yann.lecun.com/exdb/mnist, 2, 2010. + +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. + +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. + +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. + +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. + +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. + +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. + +T. Nguyen, P. Rieger, Markus Miettinen, and A. Sadeghi. Poisoning attacks on federated learningbased iot intrusion detection system. 2020. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +# A APPENDIX + +# A.1 COMMUNICATION DISTANCE MATRIX + +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. + +![](images/c3d6dbe01c3553037e81da5683b6e95d54f97d981eef6900e3743500ba5d41ee.jpg) +Figure 5: The adopted distance matrix $D _ { i \times j }$ in the 10-node scenario. + +# A.2 OPTIMIZATION OF MODEL DISTRIBUTION REPRESENTATION + +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. + +![](images/319bc5872870c0e6a26fdc49e7b3b775ec12bf8edb1c81d28cf5408435fc3df0.jpg) +Figure 6: Optimization of model distribution representation in the 10-node scenario. \ No newline at end of file diff --git a/md/dev/E9dH0BP5VW/E9dH0BP5VW.md b/md/dev/E9dH0BP5VW/E9dH0BP5VW.md new file mode 100644 index 0000000000000000000000000000000000000000..1945ad601c2be75e985055d64b63dfa6f30da3f1 --- /dev/null +++ b/md/dev/E9dH0BP5VW/E9dH0BP5VW.md @@ -0,0 +1,298 @@ +# Scaling Laws vs Model Architectures: How Does Inductive Bias Influence Scaling? + +Yi Tay∗ † Mostafa Dehghani∗ Samira Abnar† Hyung Won Chung† William Fedus† Jinfeng Rao† Sharan Narang† Vinh Q. Tran Dani Yogatama† Donald Metzler + +Google + +dehghani@google.com + +# Abstract + +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. + +# 1 Introduction + +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. + +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. + +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. + +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. + +![](images/562b1c952383d9df7cd288762ba3d6315075c2adaabc7f18885d89c4ae9eb06f.jpg) +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). + +Our Contributions and Insights The key contributions of this paper are as follows: + +• 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. + +• 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. + +• 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. + +• 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. + +# 2 Related Work + +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., + +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. + +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. + +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. + +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). + +# 3 Methods + +This section outlines our experimental setup. + +# 3.1 Models + +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. + +Transformer Variants We consider several standard Transformer variants. + +• 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. + +• 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. + +• 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. + +• 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. + +Efficient Transformer Variants These class of models are mainly concerned at reducing computational costs, memory usage, or parameter count of models. + +• 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. + +• 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). + +• 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. + +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). + +• Mixture of Softmaxes (Yang et al., 2017) - A transformer architecture adopting the MoS method at the Softmax layer. + +• Gated Linear Units with GeLU (GLUTransformer) - Replacing position-wise feedforward-networks in Transformers with Gated Linear Units (Dauphin et al., 2017). + +Non-Transformer Architectures We are interested in the scaling behaviour of non-Transformer based architectures such as convolutions and/or mixer architectures. + +• Lightweight Convolutions (Wu et al., 2019) - Lightweight depthwise convolutions that have shown promise over Transformer architectures. + +• Dynamic Convolutions (Wu et al., 2019) - An extension of the Lightweight Convolution to create time-dependent kernels. + +• 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. + +# 4 Experiment Setup + +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. + +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. + +![](images/79b680724c098e48ee63b32018a8f1e3aa02f02b0af19b26189347899155f039.jpg) +Figure 2: Upstream Negative Log-Perplexity of vanilla Transformer compared to other models. + +# 5 Main Results + +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). + +# 5.1 Do all models scale the same way? + +We compare on both upstream perplexity and downstream finetuning performance here. + +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. + +![](images/85feb280dbea6c12a414b0883a7b765c274a188edcc46f2bec14f36dab60aa1f.jpg) +Figure 3: Downstream accuracy of vanilla Transformer compared to other models. + +The pre-training perplexity metric only decreases by $2 . 7 \%$ going from base to large scale compared to $8 . 4 \%$ of the vanilla Transformer. + +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. + +# 5.2 Are the best models at each scale different? + +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. + +# 5.3 Scaling Law for Each Model + +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 + +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. + +
Model#ParamsFLOPsSpeedNeg Log PplGLUESGLUESQuAD
Transformer Tiny16M1.2138.4-2.4769.356.973.6
Transformer Small60M3.7022.7-2.0278.165.381.9
Transformer Base223M11.49.3-1.7583.874.086.3
Transformer Large738M34.33.6-1.6186.478.388.6
Transformer XL2.9B63.81.3-1.4987.881.589.5
Evolved Transformer Tiny19M1.3139.7-2.4569.657.169.6
Evolved Transformer Small79M4.2323.7-2.0475.766.280.2
Evolved Transformer Base218M10.28.9-1.7983.070.584.8
Evolved Transformer Large1.0B49.32.1-1.6286.277.188.0
Evolved Transformer XL2.2B71.30.8-1.5587.078.388.2
Universal Transformer Tiny11M1.7738.1-2.7369.856.162.3
Universal Transformer Small52M7.3018.3-2.1276.864.275.4
Universal Transformer Base127M20.38.4-1.9180.067.980.1
Universal Transformer Large283M27.61.6-1.6784.073.485.4
Switch Transformer Tiny174M3.2529.7-2.0178.263.880.7
Switch Transformer Small460M4.6322.3-1.8580.368.082.9
Switch Transformer Base2.0B12.78.4-1.6684.274.186.5
Switch Transformer Large3.9B23.04.1-1.5684.675.887.9
Switch Transformer XL29.6B43.30.8-1.6284.075.287.5
Performer Tiny16M1.1442.0-2.8850.548.815.0
Performer Small61M3.5039.0-2.4457.851.131.1
Performer Base224M10.811.7-2.2361.453.437.8
Performer Large739M32.84.4-2.1662.452.430.8
Funnel Transformer Tiny16M1.1039.9-2.5863.449.454.6
Funnel Transformer Small61M2.9632.7-2.1170.058.575.1
Funnel Transformer Base223M8.1011.9-1.8376.362.981.6
Funnel Transformer Large739M22.65.0-1.6979.867.183.8
Funnel Transformer XL2.9B40.31.89-1.6179.868.083.7
ALBERT Small15M3.5742.0-2.3673.762.077.1
ALBERTBase21M9.4016.4-2.2869.057.264.3
ALBERT Large34M31.65.1-2.2062.954.127.3
MoS-Transformer Tiny27M1.2939.7-2.3770.657.974.1
MoS-Transformer Small81M3.7026.3-1.9879.767.183.1
MoS-Transformer Base257M11.48.6-1.7084.573.986.8
MoS-Transformer Large800M35.03.4-1.5686.579.789.1
MoS-Transformer XL2.9B1121.2-1.4588.281.490.0
GLU-Transformer Tiny26M1.2931.7-2.3570.557.074.2
GLU-Transformer Small77M3.7026.4-1.9779.167.483.0
GLU-Transformer Base248M11.48.6-1.7184.674.587.2
GLU-Transformer Large748M35.03.4-1.5684.274.386.2
GLU-Transformer XL2.85B61.31.0-1.4987.682.989.4
LConv Tiny17M 67M1.2031.2-2.5051.151.349.5
LConv Small LConv Base210M3.8012.8-2.1071.859.964.7
LConv Large741M10.612.8-1.9573.863.670.3
LConv XL41.03.0-1.7676.865.676.3
2.3B77.01.0-1.7573.364.172.9
DConv Tiny22M1.3927.3-2.4651.148.930.2
DConv Small96M4.9719.8-2.0868.657.464.3
DConv Base DConv Large324M 1.2B15.3 78.07.6 1.1-1.90 -1.8272.9 70.860.1 58.563.7 58.2
+ +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 )$ . + +
ModelQF,UQF,DαP,UαP,DαU,D
Transformer0.540.280.470.240.49
GLU-Trans.0.490.240.420.220.46
LConv0.320.130.290.110.48
Funnel0.470.220.380.180.46
Switch0.230.140.130.080.58
Universal0.500.200.560.220.35
ALBERT0.08-0.120.13-0.21-1.67
Evolved0.440.220.420.210.47
Performer0.250.050.240.050.24
MoS-Trans.0.430.210.430.200.47
MLP-Mixer0.32-0.030.260.65-0.02
+ +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. + +![](images/e49faf6dfe8777846fdc8ab0cb1eb514fb0ecdd281790c705505213dc831d63c.jpg) +Figure 4: Scaling depth + +![](images/d094e4a3bbd554d6b103308552a12ae4d3bbfd674419199d0c5425320dae41e7.jpg) +Figure 5: Scaling width of FFN + +# 5.4 Do Scaling Protocols influence model architectures in the same way? + +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. + +# 6 Epilogue and Conclusion + +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). + +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. + +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. + +# References + +Samira Abnar, Mostafa Dehghani, Behnam Neyshabur, and Hanie Sedghi. 2021. Exploring the limits of large scale pre-training. arXiv preprint arXiv:2110.02095. + +Samira Abnar, Mostafa Dehghani, and Willem Zuidema. 2020. Transferring inductive biases through knowledge distillation. arXiv preprint arXiv:2006.00555. + +Yasaman Bahri, Ethan Dyer, Jared Kaplan, Jaehoon Lee, and Utkarsh Sharma. 2021. Explaining neural scaling laws. arXiv preprint arXiv:2102.06701. + +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. + +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. + +# 7 Limitations + +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 + +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. + +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. + +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. + +Mostafa Dehghani, Anurag Arnab, Lucas Beyer, Ashish Vaswani, and Yi Tay. 2021a. The efficiency misnomer. arXiv preprint arXiv:2110.12894. + +Mostafa Dehghani, Stephan Gouws, Oriol Vinyals, Jakob Uszkoreit, and Łukasz Kaiser. 2018. Universal transformers. arXiv preprint arXiv:1807.03819. + +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. + +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. + +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. + +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. + +Danny Hernandez, Jared Kaplan, Tom Henighan, and Sam McCandlish. 2021. Scaling laws for transfer. arXiv preprint arXiv:2102.01293. + +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. + +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. + +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. + +Zhenzhong Lan, Mingda Chen, Sebastian Goodman, Kevin Gimpel, Piyush Sharma, and Radu Soricut. + +2019. Albert: A lite bert for self-supervised learning of language representations. arXiv preprint arXiv:1909.11942. + +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. + +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. + +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. + +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. + +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. + +Noam Shazeer. 2020. Glu variants improve transformer. arXiv preprint arXiv:2002.05202. + +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. + +Noam Shazeer and Mitchell Stern. 2018. Adafactor: Adaptive learning rates with sublinear memory cost. In International Conference on Machine Learning, pages 4596–4604. PMLR. + +David So, Quoc Le, and Chen Liang. 2019. The evolved transformer. In International Conference on Machine Learning, pages 5877–5886. PMLR. + +Ilya Sutskever, Oriol Vinyals, and Quoc V Le. 2014. Sequence to sequence learning with neural networks. arXiv preprint arXiv:1409.3215. + +Yi Tay, Mostafa Dehghani, Dara Bahri, and Donald Metzler. 2020. Efficient transformers: A survey. arXiv preprint arXiv:2009.06732. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +# 8 Appendix + +# 8.1 Scaling Details for Individual Models + +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: + +
ModelNLdffdmodeldkuNH#Params
Tiny4/4102425632416M
Small6/6204851232860M
Base12/1230727686412220M
Large24/24409610246416738M
XL24/24163841024128323B
+ +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. + +Scaling for Switch Transformer For Switch Transformers, we use the following scaling: + +Table 4: Scaling for Switch Transformer. $N _ { E }$ is the number of experts. + +
ModelNLdffdmodeldkuNHNE#Params
Tiny41024512641232173M
Small62048512641232460M
Base1230727686412322B
Large2430727686412328B
XL483072768641212830B
+ +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. + +
ModelNRdffdmodeldkuNH#Params
UT Tiny3/3102412832811M
UT Small3/3204851232852M
UTBase3/330727686412127M
UTLarge3/33276810246416283M
+ +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. + +# 8.2 Full Results + +![](images/cc0b6657d094587e1fa8e0a314c8c93e66363a02d756ac4514eb7e4b7dd3d26f.jpg) +Figure 6: Quality-FLOP trade off for the upstream Negative Log-Perplexity of vanilla Transformer compared to other models. + +![](images/9a737b3f61783d3d6cb3807c95311b27a497b16989ddd226bdeacc6787c892ec.jpg) +Figure 7: Quality-Parameter trade off for the upstream Negative Log-Perplexity of vanilla Transformer compared to other models. + +![](images/ece19d0530939b3aa1f42365454ef1e6c217d25798a95a5647de90287e96fd12.jpg) +Figure 8: Quality-Throughput trade off for the upstream Negative Log-Perplexity of vanilla Transformer compared to other models. + +![](images/46b569b34597a0fbf4d0ec50ab3802d48670e26a860359bf9910d622f137d429.jpg) +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. + +![](images/c860edf9d97b206cc940fb89f68874f91e1bb60dc64e441db9d1e3284d87efbf.jpg) +Figure 10: Quality-Parameter trade off for the downstream SuperGlue Accuracy of vanilla Transformer compared to other models. + +![](images/6a1c98b657422b088b8f9e4cde0ccd6a9211ac86282fa9d759703f8811847059.jpg) +Figure 11: Quality-Throughput trade off for the downstream SuperGlue Accuracy of vanilla Transformer compared to other models. + +![](images/a517d7a9aa4a95b967d3f28a1bccab9048a3b9b3424589dba93a1f121669d161.jpg) +Figure 12: Quality-FLOP trade off for the downstream Glue Accuracy of vanilla Transformer compared to other models. + +![](images/5375cea2b6145c344d29ec132a03d01ebec75b826bb9083068489fe440224bf8.jpg) +Figure 13: Quality-Parameter trade off for the downstream Glue Accuracy of vanilla Transformer compared to other models. + +![](images/cdb4b3e369beb7f1a7229cc14e5835e569d36cd2581584aa13df14a61faa3202.jpg) +Figure 14: Quality-Throughput trade off for the downstream Glue Accuracy of vanilla Transformer compared to other models. + +![](images/69fbccd5c6e8e550a9f375ee7008b0c53ebfee6524d5d5faf83d5cb90a4360ad.jpg) +Figure 15: Quality-FLOP trade off for the downstream Squad Accuracy of vanilla Transformer compared to other models. + +![](images/db6399e5060e39cde976fe0652a0aca795bd425de028960ff78417966c4ace1b.jpg) +Figure 16: Quality-Parameter trade off for the downstream Squad Accuracy of vanilla Transformer compared to other models. + +![](images/4b7555dfb92695499b06bfaeaf43145e54d12524706e1ae76130bebabc18125b.jpg) +Figure 17: Quality-Throughput trade off for the downstream Squad Accuracy of vanilla Transformer compared to other models. \ No newline at end of file diff --git a/md/dev/EMLJ_mTz_z/EMLJ_mTz_z.md b/md/dev/EMLJ_mTz_z/EMLJ_mTz_z.md new file mode 100644 index 0000000000000000000000000000000000000000..93d4638b07e389687c3a8721704fcd0b5aa015cb --- /dev/null +++ b/md/dev/EMLJ_mTz_z/EMLJ_mTz_z.md @@ -0,0 +1,292 @@ +# CONVOLUTIONAL NEURAL NETWORK DYNAMICS: A GRAPH PERSPECTIVE + +Anonymous authors Paper under double-blind review + +# ABSTRACT + +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. + +# 1 INTRODUCTION + +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. + +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: + +![](images/e289bcecb54995782532600550750cd3ff3c42731d3d05d640a0ee59c5f43ee7.jpg) +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). + +• 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. + +• 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. + +• 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 \%$ . + +# 2 PRELIMINARIES + +We first present the key concepts that our work builds upon. Table 1 gives the major symbols and their descriptions. + +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. + +# 2.1 GRAPHS: TERMINOLOGY AND NOTATION + +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. + +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$ . + +• 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. + +• 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 }$ . + +# 2.2 FULLY-CONNECTED LAYERS: GRAPH REPRESENTATION + +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 } | }$ . + +Table 1: Major symbols and definitions + +
SymbolDefinition
G= (V,ε) 9={Gi,.,G𝑇}a graph with its nodeset and edgeset a time-evolving graph,i.e.,series of graph snapshots
du,du Wdegree and weighted degree of node u learnableweightmatrixinanNN,and
the weighted adj matrix of G
Kconvolutional kernel
Din/outdimension of the input/output vectors
c,fnumber of channels and filters
h,wheight and width of an input image
hker,Wkerheight and width of a kernel
xinput tensor of conv layer
+ +# 2.3 CONVOLUTIONAL LAYERS: UNROLLED GRAPH REPRESENTATION + +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 + +![](images/50157361f7d0836e8518212df6cdf24242bb9454432482bd5a371b0fc0aeee97.jpg) +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). + +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. + +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 }$ . + +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. + +# 3 NEURAL NETWORK PERFORMANCE PREDICTION: A TEMPORALGRAPH-BASED APPROACH + +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 )$ + +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 }$ . + +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. + +# 3.1 ROLLED GRAPH REPRESENTATION FOR CONVOLUTIONAL LAYERS + +We call our proposed graph representation for conv layers “rolled,” since it avoids unrolling the convolutional operations introduced in (Rieck et al., 2019). + +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). + +![](images/7051065a2d20e1f400b4423d47355d2f618c86e339e0360238b85cb8ec3b9b1a.jpg) +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. + +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. + +# 3.2 PROPOSED TEMPORAL GRAPH-BASED FRAMEWORK + +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. + +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. + +(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 }$ . + +(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. + +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. + +(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. + +(S4) Performance prediction. For the last step of performance prediction, we consider two tasks: + +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). + +
CIFAR-10ImageNet
LeNetAlexNetVGGResNet-32ResNet-44LeNetAlexNetResNet-50
Early stopping11~5030~5045~5016~12016~12016~5016~5016~120
Acc. range9.4~ 73.85.5~82.48.8~87.68.4~90.09.9~89.80.6~14.40.6~20.10.86~41.66
Acc. thres.404040404091025
+ +• 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. + +• 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). + +# 4 EMPIRICAL ANALYSIS + +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). + +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. + +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. + +# 4.1 CLASSIFICATION: PREDICTING NN ACCURACY RANGE FROM NN TRAINING DYNAMICS + +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. + +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. + +![](images/474b2bc179ef6780beb4b2042007fa98943c8f1ff7ba0dbec980e12613a49e0f.jpg) +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. + +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. + +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. + +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 \%$ . + +4.2 REGRESSION ANALYSIS: PREDICTING NN ACCURACY FROM NN TRAINING DYNAMICS + +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. + +Table 4: Regression Analysis on CIFAR-10: Accuracy prediction based on the rolled graph representation and the degree-based signature. + +
LeNetAlexNetVGGResNet
TimeMAEMAEMAEMAE
0-214.950.1618.7120.6217.720.6219.840.60
1-314.670.318.570.6611.980.8119.410.62
3-517.090.6718.40.5911.910.8117.630.67
5-712.490.7516.740.666.870.9418.280.68
+ +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 } )$ . + +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.) + +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 + +![](images/3d32b327795b2241af9c59f39e8bf38b9bc7d42232d19e73538ebeac97b39dbd.jpg) +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). + +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 }$ . + +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$ . + +# 4.3 DISCUSSION + +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. + +Table 3: Regression Analysis on ImageNet: Accuracy prediction based on the rolled graph representation and the degree-based signature. + +
AlexNetLeNetResNet
TimeMAEMAEMAE
0-3114.040.307.990.57
3-54.100.653.940.348.360.60
5-73.960.703.580.468.020.62
7-92.700.843.240.547.490.67
+ +for that architecture to achieve the highest accuracy in classification task. For all the 3 architectures + +![](images/82123f4b0801d63b1f28e0a64dbf2d7e4ae1386bbc2659e72c8ed030c20b36c6.jpg) +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. + +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. + +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. + +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$ . + +# 5 RELATED WORK + +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. + +# 6 CONCLUSION + +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. + +# 7 REPRODUCIBILITY STATEMENT + +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. + +# REFERENCES + +Tiny imagenet. https://www.kaggle.com/c/tiny-imagenet/data. + +Charu Aggarwal and Karthik Subbian. Evolutionary network analysis: A survey. ACM CSUR, 47(1):1–36, 2014. + +Dzmitry Bahdanau, Kyunghyun Cho, and Yoshua Bengio. Neural machine translation by jointly learning to align and translate. ICLR, 2015. + +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. + +Phillip Bonacich. Factoring and weighting approaches to status scores and clique identification. J math soc, 2 (1):113–120, 1972. + +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. + +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. + +Daniel Filan, Shlomi Hod, Cody Wild, Andrew Critch, and Stuart Russell. Neural networks are surprisingly modular. arXiv preprint arXiv:2003.04881, 2020. + +Daniel Filan, Stephen Casper, Shlomi Hod, Cody Wild, Andrew Critch, and Stuart Russell. Clusterability in neural networks. arXiv preprint arXiv:2103.03386, 2021. + +Thomas Gebhart, Paul Schrater, and Alan Hylton. Characterizing the shape of activation space in deep neural networks. In IEEE ICMLA, pp. 1537–1542, 2019. + +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. + +Jie Hu, Li Shen, and Gang Sun. Squeeze-and-excitation networks. In CVPR, pp. 7132–7141, 2018. doi: 10.1109/CVPR.2018.00745. + +Sergey Ioffe and Christian Szegedy. Batch normalization: Accelerating deep network training by reducing internal covariate shift. In ICML, pp. 448–456. PMLR, 2015. + +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. + +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. + +Alex Krizhevsky, Ilya Sutskever, and Geoffrey E Hinton. Imagenet classification with deep convolutional neural networks. In NeurIPS, 2012. + +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. + +Hao Li, Asim Kadav, Igor Durdanovic, Hanan Samet, and Hans Peter Graf. Pruning filters for efficient convnets. arXiv preprint arXiv:1608.08710, 2016. + +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. + +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. + +Mark EJ Newman. Finding community structure in networks using the eigenvectors of matrices. Physical review E, 74(3):036104, 2006. + +Ashwin Paranjape, Austin R Benson, and Jure Leskovec. Motifs in temporal networks. In WSDM, pp. 601–610, 2017. +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. +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. +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. +Matteo Riondato, David García-Soriano, and Francesco Bonchi. Graph summarization with quality guarantees. DMKD, 31(2):314–349, 2017. +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. +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. +K. Simonyan and A. Zisserman. Very deep convolutional networks for large-scale image recognition. In ICLR, May 2015. +Uriel Singer, Ido Guy, and Kira Radinsky. Node embedding over temporal graphs. In IJCAI, pp. 4605–4612, 7 2019. +Ilya Sutskever, Oriol Vinyals, and Quoc V Le. Sequence to sequence learning with neural networks. NeurIPS, 27:3104–3112, 2014. +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. +Jiaxuan You, Jure Leskovec, Kaiming He, and Saining Xie. Graph structure of neural networks. In ICML, pp. 10881–10891, 2020. +Tong Yu and Hong Zhu. Hyper-parameter optimization: A review of algorithms and applications. arXiv preprint arXiv:2003.05689, 2020. + +# A APPENDIX + +# A.1 EXPERIMENTAL SETUP: CONFIGURATION + +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. + +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)). + +# A.2 UNROLLED GRAPH REPRESENTATION + +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 \%$ . + +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. + +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. + +# A.3 FEATURE ANALYSIS + +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. + +![](images/d672de29cb178d51564999d9e15647b734d50e10211ba9dea7981fac942251bc.jpg) +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. + +![](images/a9aed3cd6ccbaad1d34e703358f6379219eb34f83b4cf11ff909db1d5fcdcd5d.jpg) +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). + +![](images/7582bf7c2059c82a11f7ed783a27c075047d3ab80c8141018cfdf58e0a3a461b.jpg) +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). + +# A.4 GENERALIZING TO UNSEEN ARCHITECTURES + +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: + +![](images/1b429c8a5279688fe049c63b437d6c09ae77533e96ad356d830c88071b1ede3d.jpg) +(a) CIFAR-10, ResNet-44 (b) ImageNet, ResNet-50 (c) CIFAR-10, ResNet-32 (d) CIFAR-10, ResNet-44 +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 )$ . + +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. + +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). + +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. + +# A.5 ADDITIONAL RELATED WORK + +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. + +![](images/759d5efdb9b81d03f670814fcb3444eaa800fe2cdcda54829e3fe34ca2c19135.jpg) +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. + +![](images/e6d91b80109e8cb353b1584b2663c89452d35eb021d661fddad8ecd097e55f78.jpg) +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. + +Table 5: Size of a generated graph snapshot based on the rolled and unrolled conv layer representation. + +
CIFAR-10ImageNet
LeNetAlexNetVGGResNet32ResNet44LeNetAlexNetResNet50
[V|,rolled2392925161311491597713301522823
, rolled1295411604803045765188873392115 362120656010 821824
V,unrolled11166549862050661164055076
|ε, unrolled65802445 997 696119 71449684337646043 776
\ No newline at end of file diff --git a/md/dev/F7nD--1JIC/F7nD--1JIC.md b/md/dev/F7nD--1JIC/F7nD--1JIC.md new file mode 100644 index 0000000000000000000000000000000000000000..4607a30b7c9a76ae60484d1acac347abae5633b7 --- /dev/null +++ b/md/dev/F7nD--1JIC/F7nD--1JIC.md @@ -0,0 +1,324 @@ +# SHAPLEY-NAS: DISCOVERING OPERATION CONTRIBUTION FOR NEURAL ARCHITECTURE SEARCH + +Anonymous authors Paper under double-blind review + +# ABSTRACT + +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. + +# 1 INTRODUCTION + +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. + +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. + +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). + +![](images/2e9408347c1fe46d5bbcca444489c687e91f2ed17e204b358980faf433f7db07.jpg) +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. + +# 2 RELATED WORK + +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. + +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. + +# 3 METHODOLOGY + +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. + +# 3.1 PRELIMINARIES + +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: + +$$ +\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 ) } ) , +$$ + +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 + +by jointly optimizing the network weight $w$ and architecture parameters $\alpha$ in a differentiable manner with the following bi-level objective: + +$$ +\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 ) . +$$ + +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. + +# 3.2 OPERATION IMPORTANCE EVALUATION + +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. + +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: + +
OperationαStand-aloneShapley value (normalized)
(softmaxed)accuracy
sep_conv_3x30.103897.47%0.2487
sep_conv_5x50.146597.38%0.2094
avg_pool_3x30.170197.34%0.1363
skip_connect0.123397.29%0.0904
max_pool_3x30.184197.21%0.1078
dil_conv_3x30.108697.16%0.1212
dil_conv_5x50.163597.02%0.0863
+ +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 )$ . + +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. + +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 . + +Linearity If the performance metric $\mathrm { v }$ is a linear combination of other metrics (i.e. $V = a \times V _ { 1 } +$ +$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 } )$ . + +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. + +For operation $o ^ { ( i , j ) }$ in our problem, its Shapley value can be computed as: + +$$ +\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 | } } +$$ + +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. + +# 3.3 SHAPLEY VALUE APPROXIMATION + +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: + +$$ +\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 ) } ) } ) ] +$$ + +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. + +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. + +# 3.4 SHAPLEY-BASED ARCHITECTURE SEARCH + +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: + +$$ +\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 ) . +$$ + +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: + +$$ +\alpha _ { t } = \alpha _ { t - 1 } + \epsilon \cdot \frac { s _ { t } } { | | s _ { t } | | _ { 2 } } +$$ + +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: + +$$ +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 } } +$$ + +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. + +# 4 EXPERIMENTS + +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. + +4.1 COMPARISON WITH THE STATE-OF-THE-ART NAS METHODS + +# 4.1.1 RESULTS ON CIFAR-10 + +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. + +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. + +Table 1: Comparison with state-of-the-art image classifiers on CIFAR-10. + +
ArchitectureTestError (%)Params (M)Search Cost (GPU days)Search Method
DenseNet-BC (Huang et al., 2017)3.4625.6=manual
NASNet-A (Zoph et al., 2018)2.653.32000RL
AmoebaNet-A (Real et al.,2019)3.34 ± 0.063.23150evolution
AmoebaNet-B (Real et al., 2019)2.55 ± 0.052.83150evolution
PNAS (Liu et al., 2018a)3.41 ± 0.093.2225SMBO
ENAS (Pham et al., 2018)2.894.60.5RL
NAONet (Luo et al., 2018)3.533.10.4NAO
RandomNAS (Li& Talwalkar,2020)2.85±0.084.32.7Random
DARTS (1st order) (Liu et al., 2018b)3.00±0.143.30.4gradient
DARTS (2nd order) (Liu et al., 2018b)2.76 ± 0.093.31.0gradient
SNAS(moderate) (Xie et al., 2018)2.85 ±0.022.81.5gradient
GDAS (Dong & Yang,2019)2.933.40.3gradient
BayesNAS (Zhou et al., 2019)2.81 ± 0.043.40.2gradient
ProxylessNAS (Cai et al.,2018b)2.085.74.0gradient
P-DARTS (Chen et al.,2019)2.503.40.3gradient
PC-DARTS (Xu et al., 2019)2.57 ± 0.073.60.1gradient
SGAS (Cri 1. avg) (Li et al., 2020)2.66 ± 0.243.70.25gradient
SDARTS-RS (Chen &Hsieh,2020)2.61 ±0.023.40.4gradient
DrNAS (Chen et al., 2020)2.54±0.034.00.4gradient
DARTS+PT(Wang et al., 2021b)2.61 ±0.083.00.8gradient
Shapley-NAS(avg.)‡ Shapley-NAS(best)2.47 ± 0.04 2.433.4 3.60.3 0.3sampling sampling
+ +‡ Means and standard deviations are obtained by repeated experiments with 4 random seeds. + +# 4.1.2 RESULTS ON IMAGENET + +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 }$ . + +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. + +# 4.1.3 RESULTS ON NAS-BENCH-201 + +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. + +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. + +Table 2: Comparison with state-of-the-art image classifiers on ImageNet under the mobile setting. + +
ArchitectureTest Error(%)Params (M)Search Cost (GPU days)Search Method
top-1top-5
Inception-vl (Szegedy et al.,2015)30.110.16.6=manual
MobileNet (Howard et al.,2017)29.410.54.2manual
ShuffleNet 2× (v1) (Zhang et al.,2018)26.410.2~5manual
ShuffleNet 2× (v2) (Ma et al.,2018)25.1-~5=manual
NASNet-A (Zoph et al., 2018)26.08.45.32000RL
AmoebaNet-C (Real et al.,2019)24.37.66.43150evolution
PNAS (Liu et al., 2018a)25.88.15.1225SMBO
MnasNet-92 (Tan et al.,2019)25.28.04.4=RL
DARTS (2nd) (Liu et al.,2018b)26.78.74.71.0gradient
SNAS (mild) (Xie et al.,2018)27.39.24.31.5gradient
GDAS (Dong & Yang,2019)26.08.55.30.3gradient
BayesNAS (Zhou et al., 2019)26.58.93.90.2gradient
ProxylessNAS (GPU) (Cai et al.,2018b)†24.97.57.18.3gradient
P-DARTS (CIFAR-1O) (Chen et al.,2019)24.47.44.90.3gradient
P-DARTS (CIFAR-10O) (Chen et al.,2019)24.77.55.10.3gradient
PC-DARTS (CIFAR-1O) (Xu et al., 2019)25.17.85.30.1gradient
PC-DARTS (ImageNet) (Xu et al.,2019)t24.27.35.33.8gradient
SGAS (Cri 1. best) (Li et al.,2020)24.27.25.30.25gradient
SDARTS-ADV (Chen & Hsieh,2020)25.68.26.10.4gradient
DrNAS (ImageNet) (Chen et al., 2020)t24.27.35.23.9gradient
Shapley-NAS (CIFAR-10)24.37.35.10.3
Shapley-NAS (ImageNet)+23.97.25.44.2sampling sampling
+ +† indicates the results obtained by searching on ImageNet, otherwise on CIFAR-10 or CIFAR-100. + +Table 3: Comparison results with state-of-the-art NAS methods on NAS-Bench-201. + +
MethodCIFAR-10CIFAR-100ImageNet-16-120
validationtestvalidationtestvalidationtest
ResNet (He et al.,2016)90.8393.9770.4270.8644.5343.63
Random (baseline)90.93±0.3693.70±0.3670.60± 1.3770.65 ± 1.3842.92± 2.0042.96 ± 2.15
RSPS (Li& Talwalkar,2020)84.16 ± 1.6987.66 ± 1.6945.78 ±6.3346.60±6.5731.09 ± 5.6530.78 ±6.12
REINFORCE (Zoph et al.,2018)†91.09 ± 0.3793.85 ± 0.3771.61 ± 1.1271.71 ± 1.0945.05 ± 1.0245.24 ± 1.18
ENAS (Pham et ail.,2018)39.77 ±0.0054.30±0.0010.23 ± 0.1210.62 ± 0.2716.43 ±0.0016.32±0.00
DARTS(Liu et al.,2018b)†39.77±0.0054.30±0.0015.03±0.0015.61±0.0016.43±0.0016.32±0.00
DARTS (Liu et al.,2018b)39.77 ± 0.0054.30 ± 0.0038.57±0.0038.97±0.0018.87 ±0.0018.41 ± 0.00
SNAS(Xie et al.,2018)90.10 ± 1.0492.77 ± 0.8369.69 ± 2.3969.34 ± 1.9842.84 ± 1.7943.16 ± 2.64
GDAS (Dong & Yang,2019)90.01± 0.4693.23±0.2324.05 ± 8.1224.20±8.0840.66±0.0041.02 ± 0.00
PC-DARTS (Xu et al.,2019)89.96 ± 0.1593.41 ± 0.3067.12 ± 0.3967.48±0.8940.83 ±0.0841.31 ± 0.22
iDARTS (Zhang et al.,2021)t89.96 ±0.6093.58±0.3270.57 ± 0.2470.83±0.4840.38 ± 0.5940.89±0.68
DrNAS (Chen et al.,2020)91.55 ±0.0094.36 ±0.0073.49 ± 0.0073.51 ±0.0046.37 ±0.0046.34±0.00
Shapley-NAS91.61±0.0094.37±0.0073.49±0.0073.51±0.0046.57±0.0846.85±0.12
optimal91.6194.3773.4973.5146.7747.31
+ +† Results are obtained by searching on CIFAR-10, otherwise by directly searching on the evaluation dataset. + +# 4.2 ABLATION STUDY + +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. + +
MethodC10
S1S2S3S4
DARTS3.843.112.952.82
DARTS+Shapley4.852.922.842.55
DARTS+Shapley*3.342.582.672.42
Shapley-NAS7.203.452.942.63
MethodC100
S1S2S3S4
DARTS29.4628.2125.2423.60
DARTS+Shapley26.0524.5124.6622.77
DARTS+Shapley*28.9023.6722.3921.92
Shapley-NAS22.8522.7822.1521.53
MethodSVHN
S1S2S3S4
DARTS4.582.592.882.36
DARTS+Shapley3.532.722.642.49
DARTS+Shapley*3.412.832.492.34
Shapley-NAS3.052.652.582.41
+ +![](images/ba9efd8da2aafef1c06569fcca63388f3bd0682b12c195a8cf34ec8df31ec2eb.jpg) +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. + +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. + +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$ . + +
step size eμ=0.2μ=0.5μ=0.8μ=0.9
Test Error(%)Params(M)Test Error(%)Params(M)Test Error(%)Params(M)Test Error(%)Params(M)
0.012.89± 0.214.02.87± 0.163.72.67±0.063.52.74 ± 0.113.8
0.052.85± 0.183.62.79 ±0.123.42.55 ±0.073.22.68± 0.073.5
0.12.82 ± 0.113.72.66 ± 0.103.32.47 ± 0.043.42.61± 0.064.1
0.52.92 ± 0.193.52.84±0.134.22.71 ± 0.123.82.83± 0.153.9
+ +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. + +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. + +# 5 CONCLUSION + +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. + +# REFERENCES + +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. + +Marco Ancona, Cengiz Oztireli, and Markus Gross. Shapley value as principled metric for structured ¨ network pruning. arXiv preprint arXiv:2006.01795, 2020. + +Han Cai, Tianyao Chen, Weinan Zhang, Yong Yu, and Jun Wang. Efficient architecture search by network transformation. In AAAI, volume 32, 2018a. + +Han Cai, Ligeng Zhu, and Song Han. Proxylessnas: Direct neural architecture search on target task and hardware. arXiv preprint arXiv:1812.00332, 2018b. + +Javier Castro, Daniel Gomez, and Juan Tejada. Polynomial calculation of the shapley value based ´ on sampling. Computers & Operations Research, 36(5):1726–1730, 2009. + +Xiangning Chen and Cho-Jui Hsieh. Stabilizing differentiable architecture search via perturbationbased regularization. In ICML, pp. 1554–1565, 2020. + +Xiangning Chen, Ruochen Wang, Minhao Cheng, Xiaocheng Tang, and Cho-Jui Hsieh. Drnas: Dirichlet neural architecture search. arXiv preprint arXiv:2006.10355, 2020. + +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. + +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. + +Terrance DeVries and Graham W Taylor. Improved regularization of convolutional neural networks with cutout. arXiv preprint arXiv:1708.04552, 2017. + +Xuanyi Dong and Yi Yang. Searching for a robust neural architecture in four gpu hours. In CVPR, pp. 1761–1770, 2019. + +Xuanyi Dong and Yi Yang. Nas-bench-201: Extending the scope of reproducible neural architecture search. arXiv preprint arXiv:2001.00326, 2020. + +Amirata Ghorbani and James Zou. Data shapley: Equitable valuation of data for machine learning. In ICML, pp. 2242–2251, 2019. + +Amirata Ghorbani and James Zou. Neuron shapley: Discovering the responsible neurons. arXiv preprint arXiv:2002.09815, 2020. + +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. + +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. + +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. + +Eric Jang, Shixiang Gu, and Ben Poole. Categorical reparameterization with gumbel-softmax. arXiv preprint arXiv:1611.01144, 2016. + +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. + +Alex Krizhevsky, Geoffrey Hinton, et al. Learning multiple layers of features from tiny images. 2009. + +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. + +Liam Li and Ameet Talwalkar. Random search and reproducibility for neural architecture search. In Uncertainty in artificial intelligence, pp. 367–377. PMLR, 2020. + +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. + +Hanxiao Liu, Karen Simonyan, and Yiming Yang. Darts: Differentiable architecture search. arXiv preprint arXiv:1806.09055, 2018b. + +Scott M Lundberg and Su-In Lee. A unified approach to interpreting model predictions. In NeurIPS, pp. 4768–4777, 2017. + +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. + +Renqian Luo, Fei Tian, Tao Qin, Enhong Chen, and Tie-Yan Liu. Neural architecture optimization. arXiv preprint arXiv:1808.07233, 2018. + +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. + +Masayoshi Mase, Art B Owen, and Benjamin Seiler. Explaining black box decisions by shapley cohort refinement. arXiv preprint arXiv:1911.00467, 2019. + +Hieu Pham, Melody Guan, Barret Zoph, Quoc Le, and Jeff Dean. Efficient neural architecture search via parameters sharing. In ICML, pp. 4095–4104, 2018. + +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. + +Alvin E Roth. The Shapley value: essays in honor of Lloyd S. Shapley. Cambridge University Press, 1988. + +Lloyd S Shapley. 17. A value for n-person games. Princeton University Press, 2016. + +Erik Strumbelj and Igor Kononenko. An efficient explanation of individual classifications using game theory. The Journal of Machine Learning Research, 11:1–18, 2010. + +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. + +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. + +Rui Wang, Xiaoqian Wang, and David I Inouye. Shapley explanation networks. arXiv preprint arXiv:2104.02297, 2021a. + +Ruochen Wang, Minhao Cheng, Xiangning Chen, Xiaocheng Tang, and Cho-Jui Hsieh. Rethinking architecture selection in differentiable nas. arXiv preprint arXiv:2108.04392, 2021b. + +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. + +Eyal Winter. The shapley value. Handbook of game theory with economic applications, 3:2025– 2054, 2002. + +Sirui Xie, Hehui Zheng, Chunxiao Liu, and Liang Lin. Snas: stochastic neural architecture search. arXiv preprint arXiv:1812.09926, 2018. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +Yuan Zhou, Xukai Xie, and Sun-Yuan Kung. Exploiting operation importance for differentiable neural architecture search. TNNLS, 2021. + +Barret Zoph and Quoc V Le. Neural architecture search with reinforcement learning. arXiv preprint arXiv:1611.01578, 2016. + +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. + +# A APPENDIX + +A.1 THE MONTE-CARLO SAMPLING ALGORITHM FOR SHAPLEY VALUE ESTIMATION + +# Algorithm 1: Estimating Shapley value of operations + +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$ +Output: Shapley value of operations $\{ \phi _ { o } ^ { ( i , j ) } \} _ { o \in \mathcal { O } , ( i , j ) \in \mathcal { E } }$ +Initialization:Shapley of operation $\{ \phi _ { o } ^ { ( i , j ) } \} = 0$ , $t = 0$ . +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 +end +Return φ(i,j)o $\phi _ { o } ^ { ( i , j ) } = \phi _ { o } ^ { ( i , j ) } / M$ , for $o ^ { ( i , j ) } \in N$ . + +# Algorithm 2: Shapley-NAS + +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$ . +Output: The final architecture with chosen operation on every edge $\left\{ o _ { \left( i , j \right) } \right\}$ . +Initialization:accumulated Shapley $s _ { 0 } = 0$ , $t = 0$ . +Stage 1 (Warm-up) +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$ ; +end +Stage 2 (Architecture Search) +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$ ; +end +Derive the final architecture through argmax: $o ^ { ( i , j ) } = \arg \operatorname* { m a x } _ { o \in \mathcal { O } } \alpha _ { o } ^ { ( i , j ) }$ . + +# A.3 TRAINING DETAILS + +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. + +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. + +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. + +# A.4 SEARCHED ARCHITECTURES ON CIFAR-10 + +![](images/cfe3f0e4474f1966a6d1bbfea8991aac574dbb2c478db7707f5f469bb0b34a39.jpg) +Figure 4: Normal and Reduction cells discovered by Shapley-NAS on CIFAR-10 + +# A.5 SEARCHED ARCHITECTURES ON IMAGENET + +![](images/4a19c60fff5f23d5cc5387f0b9778e783d0b77a811121ad89cb3480d4661d6e9.jpg) +Figure 5: Normal and Reduction cells discovered by Shapley-NAS on ImageNet \ No newline at end of file diff --git a/md/dev/GGi4igGZEB-/GGi4igGZEB-.md b/md/dev/GGi4igGZEB-/GGi4igGZEB-.md new file mode 100644 index 0000000000000000000000000000000000000000..f37972ed6b6e0f16d192226cc2e06c94b0a8bcc8 --- /dev/null +++ b/md/dev/GGi4igGZEB-/GGi4igGZEB-.md @@ -0,0 +1,856 @@ +# Characteristic Neural Ordinary Differential Equations + +Anonymous Author(s) +Affiliation +Address +email + +# Abstract + +1 We propose Characteristic-Neural Ordinary Differential Equations (C-NODEs), a +2 framework for extending Neural Ordinary Differential Equations (NODEs) beyond +3 ODEs. While NODEs model the evolution of latent variables as the solution to an +4 ODE, C-NODE models the evolution of the latent variables as the solution of a +5 family of first-order quasi-linear partial differential equations (PDEs) along curves +6 on which the PDEs reduce to ODEs, referred to as characteristic curves. This in +7 turn allows the application of the standard frameworks for solving ODEs, namely +8 the adjoint method. Learning optimal characteristic curves for given tasks improves +9 the performance and computational efficiency, compared to state of the art NODE +10 models. We prove that the C-NODE framework extends the classical NODE on +11 classification tasks by demonstrating explicit C-NODE representable functions +12 not expressible by NODEs. Additionally, we present C-NODE-based continuous +13 normalizing flows, which describe the density evolution of latent variables along +14 multiple dimensions. Empirical results demonstrate the improvements provided +15 by the proposed method for classification and density estimation on CIFAR-10, +16 SVHN, and MNIST datasets under a similar computational budget as the existing +17 NODE methods. The results also provide empirical evidence that the learned +18 curves improve the efficiency of the system through a lower number of parameters +19 and function evaluations compared with baselines. + +# 20 1 Introduction + +21 Deep learning and differential equations share many connections, and techniques in the intersection +22 have led to insights in both fields. One predominant connection is based on certain neural network +23 architectures resembling numerical integration schemes, leading to the development of Neural +24 Ordinary Differential Equations (NODEs) [5]. NODEs use a neural network parameterization of +25 an ODE to learn a mapping from observed variables to a latent variable that is the solution to the +26 learned ODE. A central benefit of NODEs is the constant memory cost, where backward passes are +27 computed using the adjoint sensitivity method rather than backpropagating through individual forward +28 solver steps. Backpropagating through adaptive differential equation solvers to train large NODEs +29 will often result in memory outage, as mentioned in [5]. Moreover, NODEs provide a flexible +30 probability density representation often referred to as continuous normalizing flows (CNFs). However, +31 since NODEs can only represent solutions to ODEs, the class of functions is somewhat limited +32 and may not apply to more general problems that do not have smooth and one-to-one mappings. +33 To address this limitation, a series of analyses based on methods from differential equations have +34 been employed to enhance the representation capabilities of NODEs, such as the technique of +35 controlled differential equations [24], learning higher-order ODEs [32], augmenting dynamics [10], +36 and considering dynamics with delay terms [55]. Moreover, certain works consider generalizing the +37 ODE case to partial differential equations (PDEs), such as in [40, 44]. However, these methods do +38 not use the adjoint method, removing the primary advantage of constant memory cost. This leads us +39 to the central question motivating the work: can we combine the benefits of the rich function class of +40 PDEs with the efficiency of the adjoint method? To do so, we propose a method of continuous-depth +41 neural networks that solves a PDE over parametric curves that reduce the PDE to an ODE. Such +42 curves are known as characteristics, and they define the solution of the PDE in terms of an ODE +43 [15]. The proposed Characteristic Neural Ordinary Differential Equations (C-NODE) learn both the +44 characteristics and the ODE along the characteristics to solve the PDE over the data space. This +45 allows for a richer class of models while still incorporating the same memory efficiency of the adjoint +46 method. The proposed C-NODE is also an extension of existing methods, as it improves the empirical +47 accuracy of these methods in classification tasks and image quality in generation tasks. + +# 2 Related Work + +49 We discuss the related work from both machine learning +50 and numerical analysis perspectives. + +# 51 2.1 Machine Learning and ODEs + +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: + +$$ +u _ { t + 1 } = u _ { t } + f ( u _ { t } , \theta ) , +$$ + +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: + +$$ +u _ { t + \Delta t } = u _ { t } + f ( u _ { t } , \theta ) \Delta t . +$$ + +To adapt this model to a continuous setting, we let $\Delta t \to 0$ and obtain: + +![](images/ff563256b4a0dac136062485dd04f703af9137a971f6ac668b234ff27857a416.jpg) +Multiple Characteristics (PDE)Single Characteristic (ODE) +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 )$ . + +$$ +\operatorname* { l i m } _ { \Delta t \to 0 } { \frac { u _ { t + \Delta t } - u _ { t } } { \Delta t } } = { \frac { d u ( t ) } { d t } } . +$$ + +52 The model can then be evaluated through existing numerical integration techniques, as proposed by +53 [5]: + +$$ +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 . +$$ + +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: + +$$ +\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 } ) } , +$$ + +54 that dictates the gradient with respect to the parameters. The loss $\mathcal { L } ( u ( t _ { 1 } ) )$ can then be calculated by +55 solving another ODE (the adjoint) rather than backpropagating through the calculations involved in +56 the numerical integration. +57 However, the hidden state governed by an ODE imposes a limitation on the expressiveness of the +58 mapping. For example, Dupont et al. [10] describes a notable limitation of NODEs is in the inability +59 to represent dynamical systems with intersecting trajectories. In response to such limitations, many +60 works have tried to increase the expressiveness of the mapping. Dupont et al. [10] proposed to solve +61 the intersection trajectories problem by augmenting the vector space, lifting the points into additional +62 dimensions; Zhu et al. [55] included time delay in the equation to represent dynamical systems of +63 greater complexity; Massaroli et al. [32] proposed to condition the vector field on the inputs, allowing +64 the integration limits to be conditioned on the input; Massaroli et al. [32] and Norcliffe et al. [35] +65 additionally proposed and proved a second-order ODE system can efficiently solve the intersecting +66 trajectories problem. +67 Multiple works have attempted to expand NODE systems to other common differential equation +68 formulations. Sun et al. [44] employed a dictionary method and expanded NODEs to a PDE case, +69 achieving high accuracies both in approximating PDEs and in classifying real-world image datasets. +70 However, Sun et al. [44] suggested that the method is unstable when training with the adjoint +71 method and therefore is unable to make use of the benefits that come with training with adjoint. +72 Zhang et al. [53] proposed a normalizing flow approach based on the Monge-Ampere equation. +73 However, Zhang et al. [53] did not consider using adjoint-based training. Long et al. [30, 31], Raissi +74 et al. [37], Brunton et al. [3] considered discovering underlying hidden PDEs from data and predict +75 dynamics of complex systems. Kidger et al. [24], Morrill et al. [33, 34] used ideas from rough path +76 theory and controlled differential equations to propose a NODE architecture as a continuous recurrent +77 neural network framework. Multiple works have expanded to the stochastic differential equations +78 setting and developed efficient optimization methods for them [16, 22, 23, 25, 26, 28, 29, 49]. Salvi +79 et al. [41] considered stochastic PDEs for spatio-temporal dynamics prediction. Additionally, Chen +80 et al. [6] models spatio-temporal data using NODEs, and Rubanova et al. [39], De Brouwer et al. [8] +81 makes predictions on time series data using NODEs. Physical modeling is also a popular application +82 of NODEs, as control problems are often governed by latent differential equations that can be +83 discovered with data driven methods [7, 14, 51, 54]. +84 NODE systems have also been used for modeling the flow from a simple probability density to +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 +86 $f ( u ( t ) ) \in \mathbb R ^ { n }$ , then its log likelihood from [5, Appendix A] is given by: + +$$ +\frac { \partial \log p ( u ( t ) ) } { \partial t } = - \operatorname { t r } \left( \frac { d f } { d u ( t ) } \right) . +$$ + +87 The trace can be calculated efficiently with a Hutchinson trace estimator [13]. Subsequent work +88 uses invertible ResNet, optimal transport theory, among other techniques to further improve the +89 performance of CNFs [1, 2, 4, 11, 18, 20, 21, 46, 50, 53]. CNF is desirable for having no constraints +90 on the type of neural network used, unlike discrete normalizing flows, which often have constraints +91 on the structure of the latent features [9, 36, 38]. CNFs also inspire development in other generative +92 modeling methods. For instance, a score-based generative model can be seen as a probability flow +93 modeled with an ODE [42, 47]. + +# 94 3 Method + +95 We describe the proposed C-NODE method in this section by first providing a brief introduction to +96 the method of characteristics (MoC) for solving PDEs with an illustrative example. We then discuss +97 how we apply the MoC to our C-NODE framework. We finally discuss the types of PDEs we can +98 describe using this method. + +# 3.1 Method of Characteristics + +100 The MoC provides a procedure for transforming certain PDEs into ODEs along paths known as +101 characteristics. In the most general sense, the method applies to general hyperbolic differential +102 equations; however, for illustration purposes, we will consider a canonical example using the inviscid +103 Burgers equation. A complete exposition on the topic can be found in [15, Chapter 9], but we +104 introduce some basic concepts here for completeness. Let $u ( x , t ) : \mathbb { R } \times \mathbb { R } _ { + } \to \mathbb { R }$ satisfy the +105 following inviscid Burgers equation + +$$ +\frac { \partial u } { \partial t } + u \frac { \partial u } { \partial x } = 0 , +$$ + +106 where we dropped the dependence on $x$ and $t$ for ease of notation. We are interested in the solution +107 of $u$ over some bounded domain $\Omega \subset \mathbb { R } \times \mathbb { R } _ { + }$ . Consider parametric forms for the spatial component +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 ]$ +109 Intuitively, this allows us to solve an equation on curves $x , t$ as functions of a variable $s$ which we +110 denote $( { \dot { x ( s ) } } , t ( s ) )$ as the characteristic. Expanding, and writing d as the total derivative, we get + +$$ +{ \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 } } . +$$ + +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 + +$$ +{ \frac { \mathrm { d } } { \mathrm { d } s } } u ( x ( s ) , t ( s ) ) = { \frac { \partial u } { \partial t } } + u { \frac { \partial u } { \partial x } } = 0 , +$$ + +111 where we can integrate over $s$ through + +$$ +\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} +$$ + +112 using the adjoint method with boundary conditions $x _ { 0 } , t _ { 0 }$ . This contrasts the usual direct integration +113 over the variable $t$ that is done in NODE; we now jointly couple the integration through the character +114 istics. An example of solving this equation over multiple initial conditions is given in Figure 1 with +115 the contrast to standard NODE integration. +116 To provide some intuition for using MoC, we note that MoC most generally applies to hyperbolic +117 PDEs. The transport equation is an example of this family of PDEs, which roughly describes the +118 propagation of physical quantities through time. Such equations are appropriate for deep learning +119 tasks due to their ability to transport data into different regions of the state space. For instance, in a +120 classification task, we consider the problem of transporting high-dimensional data points that are not +121 linearly separable to spaces where they are linearly separable. Similarly, in generative modeling, we +122 transport a base distribution to data distribution. + +# 123 3.2 Neural Representation of Characteristics + +124 In the proposed method, we learn the components involved in the MoC, namely the characteristics +125 and the function coefficients. We now generalize the example given in 3.1, which involved two +126 variables, to a $k$ -dimensional system. Specifically, consider the following nonhomogeneous boundary +127 value problem (BVP) + +$$ +\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} +$$ + +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 +129 dependent on values of $\mathbf { u }$ and $x$ ’s. This problem is well-defined and has a solution so long as +130 Pki=1 a i i ∂u∂x is continuous [12]. +131 MoC has historically been used in a scalar context, but generalization to the vector case is relatively +132 straightforward. A proof of the generalization can be found in Appendix B.1. We decompose the +133 PDE in (4) into the following system of ODEs + +$$ +\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} +$$ + +134 We represent this ODE system by parameterizing $d x _ { i } / d s$ and $\partial { \bf u } / \partial x _ { i }$ with neural networks. Conse +135 quently, $d \mathbf { u } / d s$ is evolving according to (6). + +136 Following this expansion, we arrive at + +$$ +\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} +$$ + +137 where we remove u’s dependency on $\mathbf { x } ( s )$ and $\mathbf { x }$ ’s dependency on $s$ for simplicity of notation. In +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 +139 neural networks with inputs $\mathbf { x }$ , $\mathbf { u }$ and parameters $\Theta _ { 2 }$ . + +# 3.3 Conditioning on data + +141 Previous works primarily modeled the task of classifying a set of data points with a fixed differential +142 equation, neglecting possible structural variations lying in the data. Here, we condition C-NODE +143 on each data point, thereby solving a PDE with a different initial condition. Specifically, consider +144 the term given by the integrand in (7). The neural network representing the characteristic $d \mathbf { x } / d s$ is +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 +146 have + +$$ +\frac { d x _ { i } } { d s } = a _ { i } ( x _ { 1 } , \dots , x _ { k } , \mathbf { u } ; \mathbf { g } ( \mathbf { z } ) ) . +$$ + +147 By introducing $\mathbf { g } ( \mathbf { z } )$ in (8), the equation describing the characteristics changes depending on the +148 current data point. This leads to the classification task being modeled with a family rather than one +149 single differential equation. + +# 3.4 Training C-NODEs + +151 After introducing the main components of C-NODEs, we can integrate them into a unified algorithm. +152 To motivate this section, and to be consistent with part of the empirical evaluation, we will consider +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, +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 +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 +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 +157 different characteristic curves indexed by $s \in [ 0 , T ]$ with boundary condition $\mathbf { u } ^ { ( j ) } ( \mathbf { x } ( 0 ) ) = \mathbf { u } _ { 0 } ^ { ( j ) }$ , and +158 compute the end values as given by (7), where we mentioned in Section 3.2, + +$$ +\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 +$$ + +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 +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 }$ +161 The entire learning is now is reduced to finding optimal weights $( \Theta _ { 1 } , \Theta _ { 2 } , \Theta _ { 3 } )$ which can be achieved +162 by minimizing the loss + +$$ +\mathcal { L } = \sum _ { j = 1 } ^ { N } L ( \Phi ( \mathbf { u } ^ { ( j ) } ( \mathbf { x } ( T ) ) ; \Theta _ { 3 } ) , \mathbf { y } _ { j } ) , +$$ + +63 where $L ( \cdot )$ is a loss function of choice. In Algorithm 1, we illustrate the implementation procedure +64 with the forward Euler method for simplicity for the framework but note any ODE solver can be used. + +# 3.5 Combining MoC with Existing NODE Modifications + +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 + +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 } )$ . +end for + +# 170 4 Properties of C-NODEs + +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. + +# 4.1 Intersecting trajectories + +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: + +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}$ . + +Proof. See Appendix B.2. + +# 4.2 Density estimation with C-NODEs + +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: + +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: + +$$ +{ \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) +$$ + +189 Proof. See Appendix B.3. + +190 CNFs are continuous and invertible one-to-one mappings onto themselves, i.e., homeomorphisms. +191 Zhang et al. [52] proved that vanilla NODEs are not universal estimators of homeomorphisms, and +192 augmented neural ODEs (ANODEs) are universal estimators of homeomorphisms. We demonstrate +193 that C-NODEs are pointwise estimators of homeomorphisms, which we formalize in the following +194 proposition: + +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 } )$ + +![](images/e80f2f7347f465f5e9f254f588628582d127c001d0ffcd4f403ec6f19829f3f1.jpg) +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. + +# 5 Experiments + +We present experiments on image classification tasks on benchmark datasets, image generation tasks on benchmark datasets, PDE modeling, and time series prediction. + +# 5.1 Classification Experiments with Image Datasets + +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. + +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. + +220 We also report training results using a traditional backpropagation through the forward Euler solver +221 in Figure 2b. The experiments are performed using the same network architectures as the previous +222 experiments using the adjoint method. It appears that C-NODEs converge significantly faster than +223 the NODEs (usually in one epoch) and generally have a more stable training process with smaller +224 variance. In experiments with MNIST, C-NODEs converge in only one epoch, while NODEs converge +225 in roughly 15 epochs. This provides additional empirical evidence on the benefits of training using the +226 characteristics. As shown in Figures 2a, 2b, compared to training with the adjoint method, training +227 with the forward Euler solver results in less variance, indicating a more stable training process. At the +228 same time, training with the adjoint method results in more accurate models, as the adjoint method +229 uses a constant amount of memory, and can employ more accurate adaptive ODE solvers. + +# 5.2 Continuous normalizing flow with C-NODEs + +231 We compare the performance of CNFs defined with NODEs to with C-NODEs on MNIST, SVHN, +232 and CIFAR-10. We use a Hutchinson trace estimator to calculate the trace and use multi-scale + +
DatasetMethodAccuracy ↑NFE↓Param.[K]↓
SVHNNODE75.28 ± 0.836%131115.444
C-NODE82.19 ± 0.478%124113.851
ANODE89.8 ± 0.952%167112.234
ANODE+C-NODE92.23± 0.176%146112.276
2nd-Ord88.22 ± 1.11%161112.801
2nd-Ord+C-NODE92.37 ± 0.118%135112.843
IL-NODE89.69 ± 0.369%195113.368
IL-NODE+C-NODE93.31 ± 0.088%95113.752
CIFAR-10NODE56.30 ± 0.742%152115.444
C-NODE64.28 ± 0.243%151113.851
ANODE70.99 ± 0.483%177112.234
ANODE+C-NODE71.36 ± 0.220%224112.276
2nd-Ord70.84 ± 0.360%189112.801
2nd-Ord+C-NODE73.68 ± 0.153%131112.843
IL-NODE72.55 ± 0.238%134113.368
IL-NODE+C-NODE73.78 ± 0.154%85113.752
MNISTNODE96.90 ± 0.154%7285.468
C-NODE97.56 ± 0.431%7283.041
ANODE99.12 ±0.021%6889.408
ANODE+C-NODE99.20±0.002%6088.321
2nd-Ord99.35 ±0.002%5289.552
2nd-Ord+C-NODE99.38 ± 0.037%6188.465
IL-NODE99.33 ± 0.039%5389.597
IL-NODE+C-NODE99.33 ± 0.001%6088.51
+ +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. + +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. + +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. + +# 40 5.3 PDE modeling with C-NODEs + +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: + +$$ +\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. +$$ + +
ModelMNISTCIFAR-10 SVHN
B/DParam.NFEB/DParam.NFEB/DParam.NFE
Real NVP [9]1.05N/A13.49N/A1111
Glow [27]1.06N/A13.3544.0M1111
RQ-NSF[11]1113.3811.8M1111
Res. Flow [4]0.9716.6M13.2825.2M1111
CP-Flow [21]1.022.9M13.401.9M1111
NODE1.00336.1K13503.49410.1K18472.15410.1K1844
C-NODE0.95338.0K13233.44406.0K15382.12406.0K1352
+ +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. + +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 +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. +250 We test C-NODE and NODE on 200 points randomly sampled as $( x , t ) \in [ 1 , 2 ] \times [ 0 , 1 ]$ . For this +251 experiment, C-NODE uses 809 parameters while NODE uses 1185 parameters. C-NODE deviates +252 $8 . 0 5 \%$ from the test dataset, while NODE deviates $3 0 . 5 2 \%$ . Further experimental details can be found +253 in Appendix A.3. + +# 5.4 Time series prediction with C-NODEs + +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. + +# 64 6 Discussion + +![](images/33dea39c7f78554a82f43e484e8b3d58033a40082c0ff7ffda9875a277ec00ca.jpg) +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. + +265 We describe an approach for extending NODEs to +266 the case of PDEs by solving a series of ODEs along +267 the characteristics of a PDE. The approach applies + +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. + +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. + +# + +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. + +[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. +[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. +[22] Junteng Jia and Austin R Benson. Neural jump stochastic differential equations. Advances in Neural Information Processing Systems, 32, 2019. +[23] Junteng Jia and Austin R. Benson. Neural jump stochastic differential equations. arXiv preprint arXiv:1905.10403, 2020. +[24] Patrick Kidger, James Morrill, James Foster, and Terry Lyons. Neural controlled differential equations for irregular time series. arXiv preprint arXiv:2005.08926, 2020. +[25] Patrick Kidger, James Foster, Xuechen Li, and Terry Lyons. Efficient and accurate gradients for neural sdes. arXiv preprint arXiv:2105.13493, 2021. +[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. +[27] Durk P Kingma and Prafulla Dhariwal. Glow: Generative flow with invertible 1x1 convolutions. Advances in neural information processing systems, 31, 2018. +[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. +[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. +[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. +[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. +[32] Stefano Massaroli, Michael Poli, Jinkyoo Park, Atsushi Yamashita, and Hajime Asama. Dissecting neural odes. arXiv preprint arXiv:2002.08071, 2021. +[33] James Morrill, Patrick Kidger, Lingyi Yang, and Terry Lyons. Neural controlled differential equations for online prediction tasks, 2021. +[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. +[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. +[36] George Papamakarios, Iain Murray, and Theo Pavlakou. Masked autoregressive flow for density estimation. arXiv preprint arXiv:1705.07057, 2017. +[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. +[38] Danilo Jimenez Rezende and Shakir Mohamed. Variational inference with normalizing flows. In ICML, 2015. +[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. +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. +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. +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. +79 [43] Robert Strichartz. The way of analysis. Jones and bartlett mathematics, 2000. +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. +03 [52] Han Zhang, Xi Gao, Jacob Unterman, and Tom Arodz. Approximation capabilities of neural odes and invertible residual networks. In ICML, 2020. +05 [53] Linfeng Zhang, Weinan E, and Lei Wang. Monge-ampère flow for generative modeling. arXiv preprint arXiv:1809.10188, 2018. +407 [54] Yaofeng Desmond Zhong, Biswadip Dey, and Amit Chakraborty. Symplectic ode-net: Learning hamiltonian dynamics with control. arXiv preprint arXiv:1909.12077, 2019. +409 [55] Qunxi Zhu, Yao Guo, and Wei Lin. Neural delay differential equations. arXiv preprint arXiv:2102.10801, 2021. + +# 411 Checklist + +1. For all authors... + +(a) Do the main claims made in the abstract and introduction accurately reflect the paper’s +contributions and scope? [Yes] +(b) Have you read the ethics review guidelines and ensured that your paper conforms to +them? [Yes] +(c) Did you discuss any potential negative societal impacts of your work? [N/A] +(d) Did you describe the limitations of your work? [Yes] + +419 2. If you are including theoretical results... + +(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] + +3. If you ran experiments... + +(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] +(b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes] +(c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [Yes] +(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] + +431 4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets... + +(a) If your work uses existing assets, did you cite the creators? [Yes] +(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. +(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] +(e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [N/A] + +# 441 A Experimental Details + +# 2 A.1 Experimental details of classification tasks + +We report the average performance over five independent training processes, and the models are trained for 100 epochs for all three datasets. + +445 The input for 2nd-Ord, NODE, and C-NODE are the original images. In the IL-NODE, we transform +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 }$ +447 dimensional input image into the $\mathbb { R } ^ { ( c + p ) \times h \times w }$ dimensional latent feature space3. We decode the +448 result after performing the continuous transformations along characteristics curves, back to the +449 $\mathbb { R } ^ { c \times h \times w }$ dimensional object space. Combining this with the C-NODE can be seen as solving a PDE +450 on the latest features of the images rather than on the images directly. We solve first-order PDEs with +451 three variables in CIFAR-10 and SVHN and solve first-order PDEs with two variables in MNIST. +452 The number of parameters of the models is similar by adjusting the number of features used in the +453 networks. We use similar training hyperparameters as [32]. +454 Unlike ODEs, we take derivatives with respect to different variables in PDEs. For a PDE with $k$ +455 variables, this results in the constraint of the balance equations + +$$ +\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 . +$$ + +456 This can be satisfied by defining the $k$ -th derivative with a neural network, and integrate $k - 1$ times +457 to get the first order derivatives. Another way of satisfying the balance equation is to drop the +458 dependency on the variables, i.e., $\forall i \in \{ 1 , 2 , . . . , k \}$ , + +$$ +\frac { \partial u } { \partial x _ { i } } = f _ { i } ( u ; \theta ) . +$$ + +459 When we drop the dependency, all higher order derivatives are zero, and the balance equations are +460 satisfied. + +All experiments were performed on NVIDIA RTX 3090 GPUs on a cloud cluster. + +# A.2 Experimental details of continuous normalizing flows + +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. + +The experiments are developed using code adapted from the code that the authors of [13] provided in https://github.com/rtqichen/ffjord. + +70 All experiments were performed on NVIDIA RTX 3090 GPUs on a cloud cluster. + +# A.3 Experimental details of PDE modeling + +472 We want to solve the initial value problem + +$$ +\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. +$$ + +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. + +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 } } }$ , +476 for the initial condition. The result is +477 calculated in four steps: + +![](images/8bb820f4cd3cc03e50cb22a6e7e8a826a907cf391d0d264459c7829d205cf95d.jpg) +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. + +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. + +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$ . + +3. Calculate initial value $u ( x ( 0 ) , t ( 0 ) ) = N N _ { 4 } ( \iota )$ . + +4. $\boldsymbol { u } ( \boldsymbol { x } , t ) = \Delta \boldsymbol { u } + \boldsymbol { u } ( \boldsymbol { x } ( 0 ) , t ( 0 ) )$ . + +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}$ . + +All experiments were performed on NVIDIA RTX 3080 ti GPUs on a local machine. + +# A.4 Experimental results and details of time series predictions + +# A.4.1 Experimental details of time series predictions on MuJoCo dataset + +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. + +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. + +![](images/d31ec47cff9043187db17492d74dfceac65796ea5a5343bf75f03d93f687fc72.jpg) +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. + +# A.4.2 Experiment results of time series predictions on synthetic dataset + +500 We test C-NODEs, ANODEs, and NODEs on a synthetic time series prediction problem. We define +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 +502 $x \in [ 1 , 2 ]$ , $t \in [ 0 , 1 ]$ to generate the training dataset. We test the performance on $t \in [ n , n + 1 ]$ +503 with $n \in \{ 0 , 1 , \ldots , 5 \}$ . To make the problem more challenging, $x$ values are omitted, and only $t$ +504 values are provided during both training and testing. As shown in Table 3, C-NODE produces more +505 profound improvements over NODEs as time increases. + +
Time[0,1][1,2][2.3][3,4][4,5][5,6]
NODE0.03220.17640.46810.80931.19111.6202
ANODE0.04280.06290.12480.27780.53600.9252
C-NODE0.02700.03650.05820.14740.33000.6054
+ +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. + +506 We also test C-NODEs, NODEs, and ANODEs on time series prediction with different levels of +507 noise. Specifically, using the same function as above, we form training and testing dataset with +508 $\epsilon _ { t } \sim \mathcal { N } ( 0 , m )$ , $\_$ . We test the performance on the time period $t \in [ 0 , 1 ]$ . + +
Noise Level012345
NODE0.03260.17840.78861.96853.75306.1553
ANODE0.040.19840.60351.05741.48502.0593
C-NODE0.02670.10110.32940.71481.28562.0834
+ +Table 4: Time series prediction results for NODE, ANODE, and C-NODE at different noise levels. Errors are testing mean squared errors. + +# 509 A.4.3 Experimental details of time series predictions on synthetic dataset + +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 )$ . + +512 We use a 8 dimensional C-NODE network. The result is calculated with + +$$ +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 . +$$ + +$$ +u ( x , t ) = u ( 1 , 0 ) + \int _ { 0 } ^ { t } \frac { \partial u } { \partial t } d t . +$$ + +514 In our experiments, C-NODEs use 1221 parameters, ANODEs use 1270 parameters, NODEs use +515 1290 parameters. + +All experiments were performed on NVIDIA RTX 3080 ti GPUs on a local machine. + +# 517 B Approximation Capabilities of C-NODE + +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 + +$$ +\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 . +$$ + +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 + +$$ +\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. +$$ + +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 +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 +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 +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 +526 (11) for all $\mathbf { x } \in \Omega$ . + +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: + +$$ +\frac { d { \bf h _ { 1 } } ( t ) } { d t } = f ( { \bf h _ { 1 } } ( t ) , t ) , { \bf h _ { 1 } } ( 0 ) = { \bf x _ { 1 } } , +$$ + +$$ +\frac { d { \bf h _ { 2 } } ( t ) } { d t } = f ( { \bf h _ { 2 } } ( t ) , t ) , { \bf h _ { 2 } } ( 0 ) = { \bf x _ { 2 } } . +$$ + +If there exists non-negative constant $C$ such that for all $t \in [ 0 , T ]$ + +$$ +\| \mathbf { f } ( \mathbf { h _ { 2 } } ( t ) , t ) - \mathbf { f } ( \mathbf { h _ { 1 } } ( t ) , t ) \| \leq C \| \mathbf { h _ { 2 } } ( t ) - \mathbf { h _ { 1 } } ( t ) \| , +$$ + +where $\| \cdot \|$ is the Euclidean norm. Then, for all $t \in [ 0 , T ]$ , + +$$ +\| \mathbf { h } _ { \mathbf { 2 } } ( t ) - \mathbf { h } _ { \mathbf { 1 } } ( t ) \| \leq e ^ { C t } \| \mathbf { x } _ { \mathbf { 2 } } - \mathbf { x } _ { \mathbf { 1 } } \| . +$$ + +# 527 B.1 Proof of Proposition B.1 + +This proof is largely based on the proof for the univarate case provided at4. We extend for the vector valued case. + +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 + +$$ +\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 } ) . +$$ + +4https://en.wikipedia.org/wiki/Method_of_characteristics#Proof_for_quasilinear_ Case + +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}$ +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 + +$$ +\mathbf { J } ( \mathbf { u } ( \mathbf { x } ) ) \mathbf { a } ( \mathbf { x } , \mathbf { u } ) = \mathbf { c } ( \mathbf { x } , \mathbf { u } ) . +$$ + +From proposition B.1, the characteristic curves are given by + +$$ +{ \frac { d x _ { i } } { d s } } = a _ { i } ( x _ { 1 } , \dots , x _ { k } , \mathbf { u } ) , +$$ + +534 and the ODE system is given by + +$$ +\frac { d \mathbf { x } } { d s } ( s ) = \mathbf { a } ( \mathbf { x } ( s ) , \mathbf { U } ( s ) ) , +$$ + +535 + +$$ +\frac { d \mathbf { U } } { d s } ( s ) = \mathbf { c } ( \mathbf { x } ( s ) , \mathbf { U } ( s ) ) . +$$ + +Define the difference between the solution to (15) and the PDE in (11) as + +$$ +\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) , +$$ + +536 Differentiating $\Delta ( s )$ with respect to $s$ and plugging in (14), we get + +$$ +\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} +$$ + +(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 + +$$ +\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} +$$ + +539 Combining terms, we have + +$$ +\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} +$$ + +540 Applying triangle inequality, we have + +$$ +\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} +$$ + +541 By the assumption in proposition B.1, a and c are Lipschitz continuous. By Lipschitz continuity, we +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 +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, +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 } )$ +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 +546 have + +$$ +\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} +$$ + +From proposition B.1, we have $\mathbf { u } ( \mathbf { x } ( 0 ) ) = \mathbf { U } ( 0 )$ . As proved above, we have + +$$ +\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 ) \| , +$$ + +where $C < \infty$ . Thus, by lemma B.2, we have + +$$ +\| \boldsymbol { \Delta } ( s ) \| \leq e ^ { C t } \| \boldsymbol { \Delta } ( 0 ) \| = e ^ { C t } \| \mathbf { u } ( \mathbf { x } ( 0 ) ) - \mathbf { U } ( 0 ) \| = 0 . +$$ + +547 This further implies that $\mathbf { U } ( s ) = \mathbf { u } ( \mathbf { x } ( s ) )$ , so long as a and c are Lipschitz continuous. + +![](images/52e53c6563e567951e0b634c20deb4f9c88a2fef183583ad661ca0836e1cc5a7.jpg) +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. + +# 548 B.2 Proof of Proposition 4.1 + +Proof. Suppose have C-NODE given by + +$$ +{ \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 } } . +$$ + +549 Write out specific functions for these terms to match the desired properties of the function. Define +550 initial condition $u ( 0 , 0 ) = u _ { 0 }$ . By setting + +$$ +\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} +$$ + +551 have the ODE and solution, + +$$ +\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} +$$ + +552 To be specific, we can represent this system with the following family of PDEs: + +$$ +{ \frac { \partial u } { \partial x } } + u _ { 0 } { \frac { \partial u } { \partial t } } = 1 - 2 u _ { 0 } . +$$ + +553 We can solve this system to obtain a function that has intersecting trajectories. The solution is +554 visualized in Figure 6, which shows that C-NODE can be used to learn and represent this function +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$ , +556 we fall back to a NODE system with the dynamical system conditioned on the input data. In this +557 conditioned setting, we can then represent $\mathcal { G }$ by stopping the dynamics at different times $t$ as in [32]. + +558 + +# B.3 Proof of Proposition 4.2 + +560 The proof uses the change of variables formula for a particle that depends on a vector rather than a +561 scalar and it follows directly from the proof given in [5, Appendix A]. We provide the full proof for +562 completeness. + +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. + +565 Want + +$$ +{ \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) . +$$ + +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 } ) =$ + +568 Take the limit of the time difference between $u _ { 0 }$ and $u _ { 1 }$ , by definition of derivatives, + +$$ + \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} +$$ + +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 + +$$ +\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} +$$ + +571 Substituting $T _ { \epsilon }$ with its Taylor series expansion and taking the limit, we have + +$$ +\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} +$$ + +572 + +# B.4 Proof of Proposition 4.3 + +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 } )$ . + +76 Without loss of generality, say $T = 1$ + +577 Define C-NODE system + +$$ +\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. +$$ + +$\begin{array} { r } { \frac { d u } { d s } = h ( u _ { 0 } ) - u _ { 0 } } \end{array}$ . At $s = 1$ + +$$ +{ \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} } +$$ + +579 The inverse map will be defined by integration backwards. Specifically, have + +$$ +\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} +$$ + +580 Thus, for any homeomorphism $h ( \cdot )$ , there exists a C-NODE system, such that forward integration for +581 time $s = 1$ is equivalent as applying $h ( \cdot )$ , and backward integration for time $s = 1$ is equivalent to +582 applying $h ^ { - 1 } ( \cdot ) $ . □ + +# C Ablation Study + +# 584 C.1 Ablation study on dimension of C-NODE + +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. + +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. + +# C.2 Ablation study on number of parameters + +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. + +![](images/d41db9a8de33a806ecb6a03506af68373f2f837a487a07b0cc446b6f2f2b2df9.jpg) +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. + +![](images/2c624970c774389190b845c346495696212c1a7dea99c8cfeab8791bdfc52150.jpg) +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. + +![](images/b820c215dee92345662347a926897605e783828112688e0f94758451377bce96.jpg) +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. + +![](images/3575f3b3867ee7abd8d50a0c2470db3e5a9ee0b3dd023d69df37b67654795e04.jpg) +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. + +# 603 D Algorithm for continuous normalizing flows defined with C-NODE + +We additionally provide algorithms for training and sampling CNFs defined with C-NODEs. + +# Algorithm 2 Algorithm for training CNFs defined with C-NODE + +given probability density function of $p ( \mathbf { u } ( s = 0 ) ) = p _ { 0 } ( \cdot )$ +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.) +end for + +# Algorithm 3 Algorithm for sampling CNFs defined with C-NODE + +procedure sample $\mathbf { u } ( s = 0 )$ from base distribution $p _ { 0 } ( \cdot )$ +procedure Integrate from $0 1$ to get $\mathbf { u } ( s = 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 \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}$ . +end for +end procedure +$\mathbf { u } ( s = 1 )$ is our sample from the CNF \ No newline at end of file diff --git a/md/dev/GMYWzWztDx5/GMYWzWztDx5.md b/md/dev/GMYWzWztDx5/GMYWzWztDx5.md new file mode 100644 index 0000000000000000000000000000000000000000..d1d67f49a662559b99ed38ae91098bd9497f894c --- /dev/null +++ b/md/dev/GMYWzWztDx5/GMYWzWztDx5.md @@ -0,0 +1,312 @@ +# NORMFORMER: IMPROVED TRANSFORMER PRETRAINING WITH EXTRA NORMALIZATION + +# ABSTRACT + +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. + +# 1 INTRODUCTION + +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.: + +$$ +\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 ) ) , +$$ + +with + +$$ +\mathrm { L a y e r N o r m } ( x ) = \frac { x - E [ x ] } { \sqrt { V a r [ x ] + \epsilon } } \cdot \gamma + \beta , +$$ + +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.: + +$$ +\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 ) ) . +$$ + +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. + +![](images/e432752f64d333fc81f82f72403fe579507153d1934fd7d710a6d5f0fe4e9794.jpg) +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. + +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. + +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. + +# 2 APPROACH + +# 2.1 NORMFORMER + +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. + +Scaling Attention Heads The standard multi-head attention operation is defined as: + +$$ +\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} +$$ + +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. + +We propose scaling the output of each attention head via learned scalar coefficients $\gamma _ { i }$ + +$$ +\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 } +$$ + +where $\gamma$ are learnable parameters initialized to 1. + +Additional Layer Normalization and Putting it All Together In the Pre-LN transformer each layer $l$ modifies an input $x _ { l }$ as follows: + +$$ +x _ { l + 1 } ^ { \mathtt { P r e L N } } = \mathrm { F F N } ( \mathrm { M H A } ( x _ { l } ) ) +$$ + +$$ +\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} +$$ + +In this work $\sigma$ is the GELU non-linear activation introduced in Hendrycks & Gimpel (2016). + +Our overall method, NormFormer, instead modifies each input $x _ { l }$ as: + +$$ +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 } ) ) +$$ + +$$ +\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 ) ) +$$ + +$$ +\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 } +$$ + +where bolded operations are newly introduced. + +# 3 RELATED WORK + +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. + +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. + +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. + +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. + +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 }$ : + +$$ +{ \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 ) ) +$$ + +where $\circ$ is elementwise multiplication, and $\lambda _ { r e s i d }$ are learned parameters initialized to + +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, + +$$ +\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} +$$ + +
Model SizeGPT-3 PaperBaselineNormFormer
125M6e-43e-33e-3
355M3e-41e-31e-3
1.3B2e-46e-46e-4
+ +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. + +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. + +# 4 EXPERIMENTS + +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). + +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. + +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. + +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 + +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. + +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. + +![](images/2704f10389bffb183e69eb7adad4b513173f711e17b73b09e5f1c1c2befe1cb4.jpg) +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. + +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. + +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). + +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. + +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. + +# 5 RESULTS + +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. + +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. + +
LRRelu²XresidStepsPPLHSPIWGSCOBAvg
Random Baseline---=--25.050.050.050.025.040.0
GPT3-125M (paper)124.46e-4572K-33.764.652.063.335.649.8
GPT3-125M (replicated)124.46e-4572K21.1133.766.552.266.135.450.8
GPT3-125M (High LR)124.43e-3572K21.0935.367.550.566.335.050.9
NormFormer-125M124.53e-3=540K20.3434.967.152.366.338.051.7
NormFormer-125M124.53e-3539K20.1134.965.953.467.540.052.3
GPT3-355M (paper)354.73e-4=572K-43.670.252.168.543.255.5
GPT3-355M (replicated)354.73e-4=572K15.4146.170.854.671.141.256.8
GPT3-355M (High LR)354.71e-3572K14.8548.471.753.873.343.458.1
NormFormer-355M355.01e-3552K14.5449.771.856.073.843.659.0
NormFormer-355M355.01e-3550K14.5249.772.056.773.243.859.1
GPT3-1.3B (paper)1313.52e-4286K-54.775.158.073.446.861.6
GPT3-1.3B (replicated)1313.52e-4286K12.5658.574.658.176.849.463.5
GPT3-1.3B (High LR)1313.56e-4286K12.2157.574.359.376.350.863.6
NormFormer-1.3B1314.06e-4275K11.9460.574.560.177.550.864.7
GPT3-2.7B (paper)2648.71.6e-4286K=62.875.662.377.253.066.2
GPT3-2.7B (replicated)2648.71.6e-4286K10.9265.976.661.478.249.666.3
NormFormer-2.7B2649.56e-4277K10.5568.178.164.479.453.468.7
GPT3-2.7B-Relu2648.71.6e-4230K10.9965.976.163.279.349.466.8
GPT3-2.7B-Relu2648.76e-428Kdiverged
NormFormer-2.7B2649.56e-4222K10.7367.477.264.478.952.668.1
+ +
Model SizeXresidPPLCoLAMNLIMRPCQNLIQQPRTESST-2Avg
Baseline125.423.4274.385.984.691.690.766.492.983.77
NormFormer125.503.3182.686.386.091.991.367.993.885.69
NormFormer125.51<3.2980.986.285.391.591.262.894.284.59
+ +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. + +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. + +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. + +# 6 ANALYSIS + +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. + +![](images/0484dfb5fe2c68a209eb020937e3c584826364b33328067390a2107769155977.jpg) +Figure 3: Average L1 norm of gradients to the second fully connected weight for layers 0,1,6,10 and 11, early in training. + +![](images/34840cb49fcd642e68cd84e903c875aced1e6b39cb10a666ea97ff26ca69eaa9.jpg) +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. + +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). + +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. + +![](images/1a08004f938b39d9c3b9868aa7559a8537cfa8299fe874ad9ae7c9cff9a75e2c.jpg) +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. + +# 6.1 RESIDUAL SCALING + +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. + +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. + +# 7 ABLATIONS + +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. + +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. + +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. + +
Architecture Valid PPL
NormFormer+ResScale15.88
- Post-Attn LN15.92
- FFN LN16.14
- Head Scale16.22
- Res Scale16.20
+ 3 More LN15.88
Baseline16.37
+ +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. + +# 8 CONCLUSION + +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. + +# 9 APPENDIX + +![](images/71938c0dd898d8095a4f2ff61f2f077f721903eb75346d31a712f8ccffeec329.jpg) +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. + +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. + +
Learning Rate Setting ChangesValid PPL
Baseline NormFormer0.00116.80
0.00116.33
Baseline NormFormer0.00316.37
0.00315.88
Baseline NormFormer0.00616.58
0.006-16.22
Baseline NormFormer0.003Longer Warmup16.50
0.003Longer Warmup16.06
Baseline NormFormer0.003GPT316.29
0.003GPT315.88
Baseline NormFormer0.003Clip Grad Norms at 0.116.46
0.003Clip Grad Norms at 0.116.14
+ +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. + +# 9.1 COMPARISON TO RELATED WORK + +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. + +
Steps to Target PPLFinal PPLA100 Hours
Baseline279.89318.70288
NormFormer223.90418.65237
+ +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 + +. A100 Hours Cost of reaching Target PPL. + +![](images/58a85b6a09ae00bd61c570b98cb068da3d78b05aadb0a34a7d93ff84eb241bfa.jpg) +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. + +The Architecture and LN Variant columns show whether we changed the model architecture completely and/or used a non-standard LayerNorm algorithm. + +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. +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. +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. +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. +5. T5[5] (Raffel et al., 2020): Switch LNs to the T5 variant, which removes the mean centering and bias. +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. +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. + +
Learning Rate0.003
Batch Size524KTokens
Parameters124M+
Layers12
Layer Dimension768
Dropout0
LR Warmup Updates500
LR SchedulerLinear Decay
Sequence Length1024
Train Budget470 V100 Hours
+ +Table 7: Hyperparameters for ablations in Tables 4 and 7. This train budget allows the baseline model to run for 100,000 updates. + +Table 8: Stability and Performance for different architectures for 1.3B parameter CLMs, see Section 9.1 for details. + +
IDArch.Scale FCScale AttnXResidScale HeadsLN VariantStabilityPerf
0PowerNorm[6]15-
1CatFormer[2]-34=
252=
3DeepInit[7]52
4DeepInit[7]?<58=
5=FFNGeglu[4]6717.1
669=
7LayerScale[3]7617.5
87617.1
98117.1
10CogView[1]CogView[1]86-
11=91
12T5[5]93
13FFNGeglu[4]94=
149417.1
15No Bias or γ951
16No Bias96=
17No γ98=
1811216.8
19CogView[1]CogView[1]11817.1
20CogView[1]122=
21CogView[1]CogView[1]124
22=128
23PowerNorm[6]135
24LayerScale[3]-148
25No Y157
26CogView[1]165
27No Bias or γ17816.9
28No Bias184-
29T5[5]189=
30119216.7
3120016.6
+ +8. No $\gamma$ : Freeze $\gamma = 1$ in LN + +9. No Bias or $\gamma$ : Freeze $\gamma = 1$ , bias ${ } = 0$ in LN + +10. No Bias: Freeze bias ${ } = 0$ in LN. + +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. + +# REFERENCES + +Jimmy Lei Ba, Jamie Ryan Kiros, and Geoffrey E. Hinton. Layer normalization, 2016. + +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. + +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. + +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. + +Xiaohan Chen, Yu Cheng, Shuohang Wang, Zhe Gan, Zhangyang Wang, and Jingjing Liu. Earlybert: Efficient bert training via early-bird lottery tickets, 2021. + +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. + +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. + +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. + +Dan Hendrycks and Kevin Gimpel. Gaussian error linear units (gelus). arXiv preprint arXiv:1606.08415, 2016. + +Opher Lieber, Or Sharir, Barak Lenz, and Yoav Shoham. Jurassic-1: Technical details and evaluation. Technical report, AI21 Labs, August 2021. + +Liyuan Liu, Xiaodong Liu, Jianfeng Gao, Weizhu Chen, and Jiawei Han. Understanding the difficulty of training transformers. arXiv preprint arXiv:2004.08249, 2020. + +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. + +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. + +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. + +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. + +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. + +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. + +Ofir Press, Noah A. Smith, and Omer Levy. Improving transformer models by reordering their sublayers, 2020a. + +Ofir Press, Noah A Smith, and Mike Lewis. Shortformer: Better language modeling using shorter inputs. arXiv preprint arXiv:2012.15832, 2020b. + +Alec Radford, Jeffrey Wu, Rewon Child, David Luan, Dario Amodei, and Ilya Sutskever. Language models are unsupervised multitask learners. Technical report, OpenAI, 2019. + +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. + +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. + +Noam Shazeer. Glu variants improve transformer, 2020. + +Sheng Shen, Zhewei Yao, Amir Gholami, Michael W. Mahoney, and Kurt Keutzer. Powernorm: Rethinking batch normalization in transformers, 2020. + +David R. So, Wojciech Manke, Hanxiao Liu, Zihang Dai, Noam Shazeer, and Quoc V. Le. Primer:´ Searching for efficient transformers for language modeling, 2021. + +Hugo Touvron, Matthieu Cord, Alexandre Sablayrolles, Gabriel Synnaeve, and Herve J ´ egou. Going ´ deeper with image transformers, 2021. + +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. + +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. + +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. + +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. + +Biao Zhang, Ivan Titov, and Rico Sennrich. Improving deep transformer with depth-scaled initialization and merged attention, 2019. + +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. + +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. \ No newline at end of file diff --git a/md/dev/GUrhfTuf_3/GUrhfTuf_3.md b/md/dev/GUrhfTuf_3/GUrhfTuf_3.md new file mode 100644 index 0000000000000000000000000000000000000000..708989881b6d29095220d8a0a4725aa4b7e7b75b --- /dev/null +++ b/md/dev/GUrhfTuf_3/GUrhfTuf_3.md @@ -0,0 +1,345 @@ +# SIMVLM: SIMPLE VISUAL LANGUAGE MODEL PRETRAINING WITH WEAK SUPERVISION + +Zirui Wang1,2∗, Jiahui $\mathbf { Y u } ^ { 2 }$ , Adams Wei $\mathbf { Y u } ^ { 2 }$ , Zihang Dai2, Yulia Tsvetkov3, Yuan Cao2 + +1Carnegie Mellon University +{ziruiw}@cs.cmu.edu +2Google Research, Brain Team +{jiahuiyu,adamsyuwei,zihangd,yuancao}@google.com +3University of Washington +{yuliats}@cs.washington.edu + +# ABSTRACT + +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. + +# 1 INTRODUCTION + +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. + +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. + +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: + +• Objective. It is trained end-to-end from scratch with a single objective of Prefix Language +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. +• Architecture. The framework employs ViT/CoAtNet (Dosovitskiy et al., 2021; Dai et al., +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. +Data. These setups relieve the requirement for object detection and allow the model to +utilize the large-scale weakly labeled dataset, which has better potential towards zero-shot +generalization. + +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. + +# 2 RELATED WORK + +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. + +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. + +![](images/e827c64d1d645458d694e88950b02c4e209c70121a7c8ba4e0a6a0de1a73a2b2.jpg) +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. + +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. + +# 3 SIMVLM + +# 3.1 BACKGROUND + +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: + +$$ +\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} +$$ + +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. + +Alternatively, the unidirectional Language Modeling (LM) trains the model to directly maximize the likelihood of the sequence $\mathbf { X }$ under the forward autoregressive factorization: + +$$ +\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] . +$$ + +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 + +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. + +# 3.2 PROPOSED OBJECTIVE: PREFIX LANGUAGE MODELING + +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: + +$$ +\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] . +$$ + +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. + +# 3.3 ARCHITECTURE + +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. + +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. + +# 3.4 DATASETS + +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. + +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). + +
VQANLVR2SNLI-VECoCo CaptionNoCapsMulti30k En-De
test-devtest-stddevtest-Pdev testB@4MCSCS
Base-sized Models
LXMERT72.4272.5474.9074.50-=-=
VL-T5-70.3074.673.6-116.5---45.5
SOHO73.2573.4776.3777.3285.0084.95===-
SimVLMbase77.8778.1481.7281.7784.2084.1539.032.9134.824.094.813.146.6
Large-sized Models
UNITER73.8274.0279.1279.9879.3979.38===-
OSCAR73.6173.8279.1280.37==41.730.6140.024.580.911.3=
Villa74.6974.8779.7681.4780.1880.02-=--=
UNIMO75.0675.27-=81.1180.6339.6-127.7---=
VinVL SimVLMlarge76.5676.60 79.5682.67 84.1383.98=41.031.1140.925.292.513.1
79.3284.8485.6885.6240.333.4142.624.7108.514.247.5
Huge-sized Models
SimVLMhuge80.0380.3484.5385.1586.2186.3240.633.7143.325.4110.314.547.6
+ +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). + +# 4 EXPERIMENTS + +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. + +# 4.1 SETUP + +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. + +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. + +# 4.2 COMPARISON WITH EXISTING APPROACHES + +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). + +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. + +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). + +
SetupCoCo CaptionNoCaps
B@4MCSInNearOutOverall
BUTDasupervised36.327.7120.121.4---
AoANetbt39.529.3129.323.2-=--
M2 Transformerc†39.129.2131.222.681.2-69.475.0
SimVLMbasezero-shot9.511.524.07.583.284.182.583.5
SimVLMlarge10.512.024.98.397.696.596.396.6
SimVLMhuge11.214.732.28.5101.2100.4102.3101.4
SimVLMbasefew-shot34.729.2118.721.995.091.998.593.7
SimVLMIarge35.430.2124.122.7102.5100.9106.0102.2
SimVLMhuge36.831.5131.324.0111.8110.6111.0110.4
OSCAR+pretrain-finetune41.730.6140.024.585.484.080.383.4
VinVL†41.031.1140.925.2103.795.683.894.3
SimVLMhuge40.633.7143.325.4113.7110.9115.2112.2
+ +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. + +# 4.3 ZERO-SHOT GENERALIZATION + +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. + +# 4.3.1 ZERO-SHOT/FEW-SHOT IMAGE CAPTIONING + +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). + +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. + +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). + +
SNLI-VE (T)SNLI-VE SNLI AcCdev/AcCtestMNLIMulti30k Multi30k (T) B@4M
Fully Supervised Baseline
EVE-Image71.56 /71.16
UNITER78.59 /78.28
SOHO85.00 /84.95
LIUMa23.835.1
GroundedTransa15.831.2
Zero-Shot Cross-Modality Transfer
SimVLMbase71.35 /71.0272.65 /72.2464.37 /63.9815.024.8
SimVLMlarge72.85 /72.4473.62/73.2366.97 / 66.3117.730.1
SimVLMhuge73.56 /73.0874.24 /73.8667.45 /66.9718.232.6
+ +# 4.3.2 ZERO-SHOT CROSS-MODALITY TRANSFER + +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. + +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. + +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. + +# 4.3.3 OPEN-ENDED VQA + +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. + +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. + +
DevKarpathy-testPartial Train Out-domain
In-domainOut-domainOverallIn-domainOverall
Discriminative
UNITER-74.410.070.5
VL-T5-70.27.166.4==
VL-BART SimVLMbase-69.47.065.7=-=
SimVLMlarge73.8 76.079.0 80.416.7 17.375.3 76.778.4 79.510.370.5
SimVLMhuge17.577.280.211.071.8
76.581.011.172.2
Generative
VL-T5-71.413.167.9===
VL-BART-72.113.268.6--=
SimVLMbase73.278.325.875.277.127.171.3
SimVLMlarge75.279.529.676.578.728.472.5
SimVLMhuge75.579.930.377.079.128.873.0
+ +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. + +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 + +Table 5: Linear evaluation on ImageNet classification, compared to state-of-the-art representation learning methods. + +
MethodAcc@1
SimCLRv2 (Chen et al., 2020a)79.8
DINO (Caron et al., 2021)80.1
CLIP (Radford et al., 2021)85.4
ALIGN (Jia et al., 2021)85.5
SimVLMbase SimVLMlarge80.6
SimVLMhuge82.3
83.6
+ +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. + +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) + +show that open-ended VQA ability emerges in SimVLM such that it can generate related responses after finetuning on the knowledge-rich wikipedia dataset. + +# 4.4 ANALYSIS + +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. + +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. + +
Method VQA score
No Pretraining49.70
Decoder-only w/ LM65.23 64.48
SimVLMsmall67.43
w/o Image2Text w/o Text2Text49.23
65.25
w/o conv stage63.11
w/ span corruption66.23
w/ 2 conv blks65.57
w/ 4 conv blks66.55
w/10% ALIGN66.71
w/ CC-3M63.32
+ +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. + +# 5 CONCLUSION + +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. + +# ACKNOWLEDGMENTS + +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. + +# REFERENCES + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +Jaemin Cho, Jie Lei, Hao Tan, and Mohit Bansal. Unifying vision-and-language tasks via text generation. arXiv preprint arXiv:2102.02779, 2021. + +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. + +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. + +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. + +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. + +Desmond Elliott, Stella Frank, Khalil Sima’an, and Lucia Specia. Multi30k: Multilingual englishgerman image descriptions. arXiv preprint arXiv:1605.00459, 2016. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +Salman Khan, Muzammal Naseer, Munawar Hayat, Syed Waqas Zamir, Fahad Shahbaz Khan, and Mubarak Shah. Transformers in vision: A survey, 2021. + +Wonjae Kim, Bokyung Son, and Ildoo Kim. Vilt: Vision-and-language transformer without convolution or region supervision, 2021. + +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. + +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. + +Guillaume Lample and Alexis Conneau. Cross-lingual language model pretraining. arXiv preprint arXiv:1901.07291, 2019. + +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. + +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. + +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. + +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. + +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. + +Ilya Loshchilov and Frank Hutter. Decoupled weight decay regularization. arXiv preprint arXiv:1711.05101, 2017. + +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. + +Ofir Press and Lior Wolf. Using the output embedding to improve language models. arXiv preprint arXiv:1608.05859, 2016. + +Alec Radford, Karthik Narasimhan, Tim Salimans, and Ilya Sutskever. Improving language understanding by generative pre-training. 2018. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +Jonathan Shen, Patrick Nguyen, Yonghui Wu, Zhifeng Chen, et al. Lingvo: a modular and scalable framework for sequence-to-sequence modeling, 2019. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. +Adina Williams, Nikita Nangia, and Samuel R Bowman. A broad-coverage challenge corpus for sentence understanding through inference. arXiv preprint arXiv:1704.05426, 2017. +Tete Xiao, Mannat Singh, Eric Mintun, Trevor Darrell, Piotr Dollar, and Ross Girshick. Early ´ convolutions help transformers see better, 2021. +Ning Xie, Farley Lai, Derek Doran, and Asim Kadav. Visual entailment: A novel task for finegrained image understanding. arXiv preprint arXiv:1901.06706, 2019. +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. +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. +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. +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. + +![](images/6e00f6fcc1995e6ba3e0bc0f6c6219f6f118bf5a70c76493897cd8e0cf10939a.jpg) +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. + +# A GENERATED EXAMPLES + +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. + +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. + +
CoLASST-2RTEMRPCQQPMNLIQNLIWNLI
BERT54.692.562.581.9/87.690.6/87.484.291.048.8
VisualBERT38.689.456.671.9/82.189.4/86.081.687.053.1
UNITER37.489.755.669.3/80.389.2/85.780.986.055.4
VL-BERT38.789.855.770.6/81.889.0/85.481.286.353.1
VilBERT36.190.453.769.0/79.488.6/85.079.983.855.4
LXMERT39.090.257.269.8/80.475.3/75.380.484.246.0
SimVLMbase46.790.963.975.2/84.490.4/87.283.488.658.1
+ +# B EXPERIMENTAL DETAILS + +# B.1 PRETRAINING + +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. + +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. + +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). + +# B.2 FINETUNING + +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: + +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. + +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. + +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. + +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. + +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. + +# C MODEL PERFORMANCE ON LANGUAGE-ONLY TASK + +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. + +# D ERRATUM + +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. \ No newline at end of file diff --git a/md/dev/HPuSIXJaa9/HPuSIXJaa9.md b/md/dev/HPuSIXJaa9/HPuSIXJaa9.md new file mode 100644 index 0000000000000000000000000000000000000000..95a1b70839801b8a2a067577e0db60ba9fb8b3d8 --- /dev/null +++ b/md/dev/HPuSIXJaa9/HPuSIXJaa9.md @@ -0,0 +1,292 @@ +# Direct Preference Optimization: Your Language Model is Secretly a Reward Model + +Rafael Rafailov⇤† Archit Sharma⇤† Eric Mitchell⇤† + +Stefano Ermon†‡ Christopher D. Manning† Chelsea Finn† + +† Stanford University $^ { \ddagger } { \bf C } { \bf Z }$ Biohub {rafailov,architsh,eric.mitchell}@cs.stanford.edu + +# Abstract + +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. + +# 1 Introduction + +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. + +![](images/b92df1d095977ec1ffcf2a3d52f229d155cbc4ce01193deca23b8c7d461955fc.jpg) +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. + +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. + +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. + +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. + +# 2 Related Work + +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 + +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. + +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. + +# 3 Preliminaries + +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. + +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 } }$ . + +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: + +$$ +p ^ { * } ( y _ { 1 } \succ y _ { 2 } \mid x ) = \frac { \exp { ( r ^ { * } ( x , y _ { 1 } ) ) } } { \exp { ( r ^ { * } ( x , y _ { 1 } ) ) } + \exp { ( r ^ { * } ( x , y _ { 2 } ) ) } } . +$$ + +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: + +$$ +\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] +$$ + +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$ . + +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 + +$$ +\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 ] +$$ + +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 } }$ . + +# 4 Direct Preference Optimization + +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. + +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: + +$$ +\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) , +$$ + +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: + +$$ +r ( x , y ) = \beta \log \frac { \pi _ { r } ( y \mid x ) } { \pi _ { \mathrm { r e f } } ( y \mid x ) } + \beta \log Z ( x ) . +$$ + +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: + +$$ +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) } } +$$ + +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. + +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: + +$$ +\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} +$$ + +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 + +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. + +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: + +$$ +\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} +$$ + +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 )$ + +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. + +# 5 Theoretical Analysis of DPO + +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 | }$ ). + +# 5.1 Your Language Model Is Secretly a Reward Model + +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. + +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$ . + +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: + +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. + +Lemma 2. Two reward functions from the same equivalence class induce the same optimal policy under the constrained RL problem. + +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$ + +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 )$ . + +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 + +$$ +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) +$$ + +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. □ + +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: + +$$ +\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 , +$$ + +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$ . + +# 5.2 Instability of Actor-Critic Algorithms + +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: + +$$ +\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 ] +$$ + +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. + +![](images/f78d1fde84ebabcb4afc76dd35e62fd84f7dff5b281afd651c71e835f61e0e0a.jpg) +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. + +# 6 Experiments + +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 } }$ + +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. + +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. + +![](images/d07263c5eb75355fe5346e867b232f5da59aaf4d1212fd36e83e84d909b3fa1e.jpg) +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. + +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. + +# 6.1 How well can DPO optimize the RLHF objective? + +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; + +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). + +# 6.2 Can DPO scale to real preference datasets? + +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. + +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. + +# 6.3 Generalization to a new input distribution + +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 + +
Alg.Win rate vs. ground truth
Temp 0Temp 0.25
DPO0.360.31
PPO0.260.23
+ +Table 1: GPT-4 win rates vs. ground truth summaries for out-of-distribution CNN/DailyMail input articles. + +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. + +# 6.4 Validating GPT-4 judgments with human judgments + +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. + +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. + +
DPOSFTPPO-1
N respondents272122199
GPT-4 (S) win %472713
GPT-4 (C) win %543212
Human win %584317
GPT-4 (S)-H agree707786
GPT-4 (C)-H agree677985
H-H agree65-87
+ +# 7 Discussion + +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. + +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. + +# Acknowledgements + +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. + +References +[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. +[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. +[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. +[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. +[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. +[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. +[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. +[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. +[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. +[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. +[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. +[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. + +[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. + +[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. + +[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. + +[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. + +[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. + +[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. + +[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. + +[20] S. Levine. Reinforcement learning and control as probabilistic inference: Tutorial and review, 2018. + +[21] R. D. Luce. Individual choice behavior: A theoretical analysis. Courier Corporation, 2012. + +[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. + +[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. + +[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. + +[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. + +[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. + +[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-. + +[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. + +[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. + +[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. + +[31] A. Radford, J. Wu, R. Child, D. Luan, D. Amodei, and I. Sutskever. Language models are unsupervised multitask learners, 2019. Ms., OpenAI. + +[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. + +[33] M. Ranzato, S. Chopra, M. Auli, and W. Zaremba. Sequence level training with recurrent neural networks. CoRR, abs/1511.06732, 2015. + +[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. + +[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. + +[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. + +[37] J. Schulman, F. Wolski, P. Dhariwal, A. Radford, and O. Klimov. Proximal policy optimization algorithms, 2017. + +[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. + +[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. + +[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. + +[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. + +[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. + +[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. + +[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. + +[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. + +[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. + +[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. + +[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. \ No newline at end of file diff --git a/md/dev/JhzzvJnL9t/JhzzvJnL9t.md b/md/dev/JhzzvJnL9t/JhzzvJnL9t.md new file mode 100644 index 0000000000000000000000000000000000000000..41c3cb517ca6df4906ecb4c451d7a531659663dc --- /dev/null +++ b/md/dev/JhzzvJnL9t/JhzzvJnL9t.md @@ -0,0 +1,395 @@ +# Out-of-Domain Intent Detection Considering Multi-turn Dialogue Contexts + +Anonymous EMNLP submission + +# Abstract + +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. + +# 1 Introduction + +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) + +intents while rejecting unseen OOD intents (Yan et al., 2020a). + +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). + +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). + +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. + +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: + +1. We propose a novel framework Caro to address a challenging yet under-explored problem of OOD intent detection considering multi-turn dialogue contexts. + +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. + +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). + +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). + +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. + +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. + +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. + +# 2 Related Work + +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 + +# 3 Problem Setup + +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. + +# 4 Method + +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). + +# 4.1 Multi-View Information Bottleneck + +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. + +To achieve this goal, we adopt the multi-view information bottleneck loss introduced by Federici et al. (2019). + +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). + +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: + +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: + +$$ +v _ { 1 } ( { \pmb x } ) = \sum _ { i = 1 } ^ { n } e _ { i } / n +$$ + +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 } }$ : + +$$ +\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} +$$ + +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). + +![](images/ec34b8206bb9c97dc57749c02ad12495b366b37fcf1344ec4aef852fb2c7c68f.jpg) +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 }$ + +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 } )$ : + +$$ +\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} +$$ + +where $I$ calculates the mutual information of two random variables, and $D _ { K L }$ calculates the KL divergence between two distributions. + +# 4.2 Two-stage Self-training + +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. + +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. + +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: + +$$ +\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 } +$$ + +where $\lambda$ is a scalar hyper-parameter to control the weight of the information bottleneck loss. + +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: + +$$ +\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} +$$ + +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. + +The training of Caro is given in Algorithm 1. + +# 5 Experiments + +# 5.1 Datasets + +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 + +Input: IND data $\mathcal { D } _ { I }$ , unlabeled data $\mathcal { D } _ { U }$ . Output: A trained OOD detector $F$ . // Stage 1 +1 Synthesize pseudo OOD samples $\mathcal { D } _ { P }$ by mixing up IND representations. +2 Train $F$ using the cross-entropy loss $\mathcal { L } _ { C E }$ on $\mathcal { D } _ { I } \cup \mathcal { D } _ { P }$ . // Stage 2 +3 Mine OOD samples $\mathcal { D } _ { O }$ from $\mathcal { D } _ { U }$ using $F$ . +4 Train $F$ using $\mathcal { L }$ (Eq. 4) on $\mathcal { D } _ { I }$ , $\mathcal { D } _ { O }$ , and $\mathcal { D } _ { U }$ + +Algorithm 1: The training process of Caro +Table 1: Dataset statistics. + +
TrainValid Test Dv DT#Avg.( Context Turns
D1Du
STAR-Full15.4K7.9K2.8K 2.9K6.13
STAR-Small7.7K3.9K2.8K 2.9K6.12
+ +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. + +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. + +# 5.2 Metrics + +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. + +# 5.3 Implementation Details + +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). + +# 5.4 Baselines + +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. + +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. + +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. + +
ModelSTAR-FullSTAR-Small
OracleF1-All 50.1F1-OOD 64.46F1-IND 50F1-All 46.54F1-OOD 58.23F1-IND 46.46
D1MSP40.8319.7440.9737.1718.137.31
MSP w/o h17.2914.1217.3117.1213.4917.14
SEG17.456.8517.5311.667.3911.69
SEG w/o h0.062.770.040.052.270.04
DOC26.5316.8026.603.4711.783.41
DOC w/o h11.3114.1611.290.0811.040
ADB44.6420.5644.8041.3618.2341.51
ADB w/o h23.2717.6323.3020.0821.2720.07
DAADB37.2722.8737.3734.8120.4334.91
DAADB w/o h17.8715.1517.8816.3417.0316.33
Outlier43.8419.5344.0139.5119.9239.64
Outlier w/o h23.3516.7523.3919.5615.4219.59
CDA43.765.2644.0340.0210.4840.22
D1+DuASS+MSP41.9725.1542.0840.8519.4740.99
ASS+LOF39.8717.6540.0239.5418.4939.68
ASS+GDA43.7321.2443.8840.8616.7241.02
Caro (ours)48.75(±1.0)54.75(±3.2)48.71(±1.0)45.02(±1.1)46.78(±1.8)45.01(±1.1)
+ +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. + +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. + +# 5.5 Main Results + +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. + +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). + +# 5.6 Ablation Studies + +To validate our motivation and model design, we ablate our model components and loss terms. + +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. + +Table 3: Ablation on different components of Caro. + +
ModelSTAR-Full F1-Al1 F1-00D F1-INDSTAR-Small F1-All F1-OOD F1-IND
Caro48.7554.7548.7145.0246.7845.01
w/o Du45.9721.4546.1442.2423.2342.37
w/o MV47.7153.3547.6744.4238.8944.46
w/o VA47.3450.8547.3244.1443.8844.15
w/o IB48.2349.3748.2244.1437.0644.19
+ +Table 4: Ablation on the representation learning loss. + +
ModelSTAR-Full F1-All F1-OOD F1-INDSTAR-Small F1-All F1-OOD F1-IND
Caro48.7554.7548.7145.0246.7845.01
InfoMax47.2749.9247.2544.2736.6644.32
MVI48.4651.9948.4444.7036.1644.76
CL48.1852.5448.1544.5935.3144.65
SimCSE47.7347.7447.7344.3027.0244.42
+ +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. + +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. + +![](images/7aa014feefd3b2909f1ce0559c1f9927e49dae567493f9d32c2d68d804f0054c.jpg) +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. + +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. + +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 + +
Context LenF1-AllF1-00DF1-IND
Longw/o IB44.1437.0644.19
wIB45.02 (+0.88)46.78 (+9.72)45.01 (+0.82)
Shortw/o IB43.6140.6843.63
wIB43.70 (+0.09)43.32 (+2.64)43.70 (+0.07)
+ +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 }$ + +![](images/d1561594e06b7d8513f3a4e23de151fb6026d0472528e92e84fafdeddb0bfa1a.jpg) +Figure 3: Difference of averaged weight score at each token index for testing samples from STAR-Full. + +![](images/9846852431019202568fe98535b16466a493e4d239f2a3034c13b1f9ee58d0e9.jpg) +Figure 4: Difference of averaged aggregation weights at each dimension for testing samples in STAR-Full. + +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. + +high predictive ability. + +# 5.7 Further Analysis + +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. + +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. + +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 + +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. + +# 6 Conclusion + +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. + +# Limitations + +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. + +# Ethics Statement + +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. + +# References + +Philip Bachman, R Devon Hjelm, and William Buchwalter. 2019. Learning representations by maximizing mutual information across views. Advances in neural information processing systems, 32. + +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. + +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. + +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. + +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. + +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. + +Thomas G Dietterich. 2017. Steps toward robust artificial intelligence. Ai Magazine, 38(3):3–24. + +Marco Federici, Anjan Dutta, Patrick Forré, Nate Kushman, and Zeynep Akata. 2019. Learning robust representations via multi-view information bottleneck. + +In International Conference on Learning Representations. + +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. + +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. + +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. + +Tianyu Gao, Xingcheng Yao, and Danqi Chen. 2021. SimCSE: Simple contrastive learning of sentence embeddings. In Empirical Methods in Natural Language Processing (EMNLP). + +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. + +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. + +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. + +Dan Hendrycks, Mantas Mazeika, and Thomas Dietterich. 2018. Deep anomaly detection with outlier exposure. In International Conference on Learning Representations. + +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. + +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. + +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. + +Diederik P Kingma and Jimmy Ba. 2014. Adam: A method for stochastic optimization. arXiv preprint arXiv:1412.6980. + +Balaji Lakshminarayanan, Alexander Pritzel, and Charles Blundell. 2017. Simple and scalable predictive uncertainty estimation using deep ensembles. Advances in neural information processing systems, 30. + +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. + +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. + +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. + +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. + +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. + +Weitang Liu, Xiaoyun Wang, John Owens, and Yixuan Li. 2020. Energy-based out-of-distribution detection. Advances in Neural Information Processing Systems, 33. + +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. + +Johannes EM Mosig, Shikib Mehri, and Thomas Kober. 2020. Star: A schema-guided dialog dataset for transfer learning. arXiv preprint arXiv:2010.11853. + +Biraj Pandey, Marius Pachitariu, Bingni W. Brunton, and Kameron Decker Harris. 2022. Structured random receptive fields enable informative sensory encodings. bioRxiv. + +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. + +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. + +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. + +Libo Qin, Tianbao Xie, Wanxiang Che, and Ting Liu. 2021. A survey on spoken language understanding: Recent advances and new frontiers. In IJCAI. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +Naftali Tishby, Fernando C Pereira, and William Bialek. 2000. The information bottleneck method. arXiv preprint physics/0004057. + +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. + +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). + +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). + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +Hanlei Zhang, Hua Xu, Shaojie Zhao, and Qianrui Zhou. 2021c. Learning discriminative representations and decision boundaries for open intent detection. + +Jing Zhao, Xijiong Xie, Xin Xu, and Shiliang Sun. 2017. Multi-view learning overview: Recent progress and new challenges. Information Fusion, 38:43–54. + +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. + +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. + +# A More Implementation Details + +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. + +# B More Details about Baselines + +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. + +C Computational Cost Analysis +Table 6: Number of parameters (Million), average training time for each epoch (minutes) and the total time for testing (seconds) on STAR-Full dataset. + +
Methods#Para.Training TimeTesting Time
Outlier111.47 M7.26 min14.46 s
Caro116.80 M8.75 min14.53 s
+ +![](images/221d07a1bc62bdff635efb0a61f367d260d9c441cf9e3202b11ae46521f70791.jpg) + +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. + +# D More Details about Measurements Used to Produce the Graph + +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. + +![](images/db644dd24ae35a305c4e0315787fbdc03100f7415afbcbefb306bbf5d21797c9.jpg) + +![](images/495985d73f53a469c54188db054551ec6a4f03a2dbda3f622f98a547a12a72c1.jpg) + +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. + +# E Analysis for Unlabeled Data Size + +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. + +Table 7: Effect of unlabeled data size on the OOD intent detection performance. The reported performance are produced on the STAR-Small dataset. + +
DownSample-RateF1-AllF1-OODF1-IND
100%75%50%25%45.0246.7845.01
44.4037.7744.44
45.0430.1345.15
44.4720.7644.62
+ +# F Analysis for Loss Weight $\lambda$ + +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. + +Table 8: Effect of $\lambda$ on the OOD intent detection performance. The reported performance are produced on the STAR-Full dataset. + +
F1-AllF1-0ODF1-IND
0.347.5755.6847.51
0.448.1051.4448.08
0.548.7554.7548.71
0.647.1550.8447.12
0.747.8350.6047.81
+ +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. + +
DialoguePrediction of “Outlier”Prediction of “Caro”
CustomerAgent
Somebody has transferred $5oo from my account.bank_ask_pinOOD
yes pleaseWould you like to file a fraud report? Could I get your full name,please?
Jane Doe
Can you tell me your account number, please?
What am I doing on this chat? Hey there! Can you tell me what the weather will be tomorrow please?weather _informOOD
oh dang when's the next time it will be sunny?It will be Raining all day on Saturday in Los Angeles,with temperatures of around 19 degrees celsius._forecast
It will be Sunny all day on Friday in Los Angeles,with temperatures of around 11 degrees celsius.
Nice! I think I'll head to La brea tar pits. I've never been there.have you seen those animals? Crazybank_inform
apartment for Thursday at 8pm my name is john
Ican't rememberHave you already paid the application fee for the apartment?_cannot _authenticateOOD
Iam sorry, but there is no viewing available at your preferred time.
Ihave a hot date by 8pmo ThursdayWhen would you like the viewing to start?
\ No newline at end of file diff --git a/md/dev/MpJjrfSJ-Xs/MpJjrfSJ-Xs.md b/md/dev/MpJjrfSJ-Xs/MpJjrfSJ-Xs.md new file mode 100644 index 0000000000000000000000000000000000000000..7dc96a1ab0159f946f2b7a0ccee57781fc732a89 --- /dev/null +++ b/md/dev/MpJjrfSJ-Xs/MpJjrfSJ-Xs.md @@ -0,0 +1,346 @@ +# CROSS-DOMAIN CROSS-SET FEW-SHOT LEARNING VIA LEARNING COMPACT AND ALIGNED REPRESENTATIONS + +Anonymous authors Paper under double-blind review + +# ABSTRACT + +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. + +# 1 INTRODUCTION + +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. + +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). + +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. + +![](images/6195d55e54d50ecc1d283cad810a9d7f87b756770ac9394945eb8c50e978d425.jpg) +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. + +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. + +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. + +# 2 RELATED WORK + +# 2.1 FEW-SHOT LEARNING + +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. + +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. + +# 2.2 UNSUPERVISED DOMAIN ADAPTATION + +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. + +# 3 PROBLEM SETUP + +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 } }$ +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 } }$ . + +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: + +![](images/63905d977bf979f4af2309de5f85f896ee88d0c4267fc9246f9fd02b889ffd8a.jpg) +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. + +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 }$ . +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 }$ . + +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. + +# 4 APPROACH + +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. + +# 4.1 BI-DIRECTIONAL PROTOTYPICAL ALIGNMENT + +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. + +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. + +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: + +$$ +\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 ) } } , +$$ + +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: + +$$ +\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 ) } } . +$$ + +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: + +$$ +w ( t ) = \frac { 2 } { 1 + \exp \left( - \alpha t / T _ { m a x } \right) } - 1 , +$$ + +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). + +Therefore, the total loss for the bi-directional prototypical alignment is + +$$ +\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 } ) , +$$ + +where $p ( \cdot )$ is the confidence of a pseudo label, and $\beta$ is the confidence threshold below which the data samples will be dropped. + +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 }$ : + +$$ +\hat { y } _ { i } = \arg \operatorname* { m a x } _ { k } \lambda \phi _ { 0 } ( k | x _ { i } ) + ( 1 - \lambda ) \phi _ { t } ( k | x _ { i } ) , +$$ + +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. + +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: + +$$ +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 } ) , +$$ + +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. + +# 4.2 stabPA + +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. + +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. + +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 + +$$ +\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 } ) , +$$ + +where $\widetilde { B }$ and $\widetilde { \mathcal { U } }$ are the augmented base set and unlabeled target set, respectively. + +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). + +# 5 EXPERIMENTS + +# 5.1 ADAPTING THE DATASETS FOR CDCS-FSL + +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. + +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. + +# 5.2 COMPARISON WITH BASELINES + +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. + +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. + +
Methodreal-paintingreal-clipartreal-sketch
1-shot5-shot1-shot5-shot1-shot5-shot
ProtoNet (NeurIPS'17)45.36±0.8157.23±0.7944.65±0.8158.04±0.8139.28±0.7751.68±0.81
RelationNet (CVPR'18)42.69±0.7752.63±0.7444.12±0.8157.24±0.8036.52±0.7347.32±0.75
MetaOptNet (CVPR'19)44.02±0.7756.34±0.3442.46±0.8057.92±0.7936.37±0.7248.20±0.79
Tian et al. (ECCV'20)46.69±0.8656.87±0.8448.30±0.8559.67±0.8440.23±0.7350.41±0.80
DeepEMD (CVPR'20)47.60±0.8756.62±0.7849.02±0.8360.43±0.8242.75±0.7951.66±0.80
DANN (JMLR'16)45.94±0.8456.83±0.8647.31±0.8659.42±0.8442.44±0.7953.47±0.75
Mean Teacher (NeurIPS'17)46.92±0.8357.74±0.8448.48±0.8161.54±0.8443.39±0.8154.57±0.79
Fixmatch (NeurIPS'20)48.86±0.8761.62±0.7948.70±0.8261.94±0.8244.48±0.8055.26±0.83
STARTUP (ICLR'21)47.53±0.8858.13±0.8249.24±0.8761.51±0.8643.78±0.8254.89±0.81
stabPA (Ours)50.51±0.8563.19±0.7851.63±0.8362.78±0.8547.54±0.8159.10±0.79
painting-realclipart-realsketch-real
ProtoNet (NeurIPS'17)45.25±0.9765.60±0.9547.50±0.9565.91±0.7842.85±0.8959.46±0.85
RelationNet (CVPR'18)43.04±0.9761.18±0.9045.86±0.9562.65±0.8141.29±0.9656.39±0.88
MetaOptNet (CVPR'19)44.31±0.9463.20±0.8946.15±0.9863.51±0.8240.27±0.9555.65±0.85
Tian el al. (ECCV'20)46.57±0.9963.90±0.9549.66±0.9865.33±0.8041.90±0.8656.95±0.84
DeepEMD (CVPR'20)47.86±1.0463.86±0.9350.89±1.0067.46±0.7846.02±0.9360.39±0.87
DANN (JMLR'16)46.85±0.9764.29±0.9450.02±0.9466.87±0.7843.66±0.9260.14±0.81
Mean Teacher (NeurIPS'17)46.84±0.9664.97±0.9449.60±0.9767.39±0.8944.52±0.8960.04±0.86
Fixmatch (NeurIPS'20)49.15±0.9367.46±0.8949.18±0.9366.72±0.8145.97±0.9562.46±0.87
STARTUP (ICLR'21)47.58±0.9865.27±0.9251.32±0.9867.95±0.7845.23±0.9661.97±0.88
stabPA (Ours)51.87±0.9970.84±0.8853.53±1.0471.57±0.8149.18±0.9667.14±0.85
+ +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. + +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. + +# 5.3 RESULTS ANALYSIS + +# 5.3.1 HAS stabPA LEARNED COMPACT AND ALIGNED REPRESENTATIONS? + +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. + +![](images/dc2387df0436c682f6941ed8af1cb365dcfc9584be64192eeebc47cf15811494.jpg) +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. + +# 5.3.2 CAN stabPA LEARN GENERALIZABLE REPRESENTATIONS FOR NEW CLASSES? + +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. + +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. + +Table 3: Ablation studies on DomainNet. Mean and $9 5 \%$ confidence interval are reported. + +
sketch-realreal-sketch
ls-tlt-saug1-shot5-shot1-shot5-shot
×××41.90±0.8656.95±0.8440.23±0.7350.41±0.80
××44.83±0.9560.87±0.9142.86±0.7852.16±0.78
××44.45±0.9261.97±0.9044.20±0.7754.83±0.79
×47.59±1.0064.32±0.8647.01±0.8456.68±0.81
49.18±0.9667.14±0.8547.54±0.8159.10±0.79
+ +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. + +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. + +# 5.3.3 ABLATION STUDIES + +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. + +# 6 CONCLUSIONS + +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. + +# 7 REPRODUCIBILITY STATEMENT + +We have uploaded the source code as supplemental materials to ensure reproducibility. + +# REFERENCES + +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. + +Yoshua Bengio, Jer´ ome Louradour, Ronan Collobert, and Jason Weston. Curriculum learning. In ˆ International Conference on Machine Learning, 2009. + +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. + +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. + +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. + +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. + +Terrance DeVries and Graham W Taylor. Improved regularization of convolutional neural networks with cutout. arXiv preprint arXiv:1708.04552, 2017. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +Diederik P Kingma and Jimmy Ba. Adam: A method for stochastic optimization. arXiv preprint arXiv:1412.6980, 2014. + +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. + +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. + +Mingsheng Long, ZHANGJIE CAO, Jianmin Wang, and Michael I Jordan. Conditional adversarial domain adaptation. In Advances in Neural Information Processing Systems, 2018a. + +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. + +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. + +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. + +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. + +Cheng Perng Phoo and Bharath Hariharan. Self-training for few-shot transfer across extreme task differences. In International Conference on Learning Representations, 2021. + +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. + +Sachin Ravi and Hugo Larochelle. Optimization as a model for few-shot learning. In International Conference on Learning Representations, 2017. + +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. + +Jake Snell, Kevin Swersky, and Richard Zemel. Prototypical networks for few-shot learning. In Advances in Neural Information Processing Systems, volume 30, 2017. + +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. + +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. + +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. + +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. + +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. + +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. + +Laurens Van der Maaten and Geoffrey Hinton. Visualizing data using t-sne. Journal of Machine Learning Research, 9(11), 2008. + +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. + +Ricardo Vilalta and Youssef Drissi. A perspective view and survey of meta-learning. Artificial Intelligence Review, 18(2):77–95, 2002. + +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. + +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. + +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. + +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. + +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. + +# A APPENDIX + +# A.1 IMPLEMENTATION DETAILS + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +# A.2 PSEUDO LABEL UPDATE STRATEGY + +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. + +Table 4: The impact of interpolation coefficient $\lambda$ . + +
Methodpainting-realreal-painting
1-shot5-shot1-shot5-shot
ls-t0.048.56±1.0466.24±0.9248.89±0.8558.72±0.79
0.248.76±0.9967.21±0.9149.08±0.8459.33±0.77
1.048.20±0.9965.79±0.9048.79±0.8757.51±0.79
lt-s0.047.83±1.0166.30±0.9248.26±0.8359.17±0.77
0.248.53±1.0267.09±0.9448.88±0.8460.18±0.80
1.048.93±1.0167.12±0.9448.53±0.8659.29±0.80
ls-t&lt-s0.048.35±1.0266.96±0.9148.72±0.8459.78±0.78
0.249.31±1.0668.15±0.9249.63±0.8460.13±0.79
1.048.74±1.0266.81±0.9349.26±0.8759.33±0.81
+ +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. + +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). + +# A.3 DATASET PARTITION + +# A.3.1 DOMAINNET + +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: + +$$ +\mathcal { D } _ { b a s e } = +$$ + +{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} + +$$ +\mathcal { V } _ { v a l i d a t i o n } = +$$ + +{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, + +spreadsheet, suitcase, swan, telephone, traffic light, trumpet, wine glass, wristwatch} + +$$ +\mathcal { 3 } _ { n o v e l } = +$$ + +{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} + +# A.3.2 OFFICE-HOME + +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: + +$$ +\mathcal { D } _ { b a s e } = +$$ + +{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} + +$$ +\mathcal { V } _ { v a l i d a t i o n } = +$$ + +{bed, computer, couch, flowers, marker, mop, notebook, pan, shelf, soda} + +$$ +\mathcal { 3 } _ { n o v e l } = +$$ + +{backpack, batteries, candles, drill, flipflops, fork, helmet, knives, oven, push pin, ruler, screwdriver, sink, trash can, webcam} \ No newline at end of file diff --git a/md/dev/NjeEfP7e3KZ/NjeEfP7e3KZ.md b/md/dev/NjeEfP7e3KZ/NjeEfP7e3KZ.md new file mode 100644 index 0000000000000000000000000000000000000000..b2ae926d20b439f9a574792e3c6574139c7f0ebd --- /dev/null +++ b/md/dev/NjeEfP7e3KZ/NjeEfP7e3KZ.md @@ -0,0 +1,302 @@ +# Revisiting Heterophily For Graph Neural Networks + +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 + +# Abstract + +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 + +# 1 Introduction + +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. + +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. + +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. + +# 2 Preliminaries + +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$ . + +# 2.1 Graph Laplacian, Affinity Matrix and Variants + +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. + +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: + +$$ +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 } ) +$$ + +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 + +$$ +\mathcal { L } = - \mathrm { t r a c e } ( Z ^ { T } \log Y ) +$$ + +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. + +# 2.2 Metrics of Homophily + +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: + +$$ +\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} +$$ + +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. + +# 3 Analysis of Heterophily + +# 3.1 Motivation and Aggregation Homophily + +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. + +![](images/c1b018a040bcfe67973ad8ddb5a86b14d4e381ebf8420d541eb78816666b447f.jpg) +Figure 1: Example of harmless heterophily + +To this end, we first define the post-aggregation node similarity matrix as follows: + +$$ +S ( \hat { A } , X ) \equiv \hat { A } X ( \hat { A } X ) ^ { T } \in \mathbb { R } ^ { N \times N } +$$ + +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. + +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: + +$$ +Y = \mathrm { s o f t m a x } ( \hat { A } X W ) = \mathrm { s o f t m a x } ( Y ^ { \prime } ) +$$ + +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): + +$$ +\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 ) +$$ + +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. + +Based on the above definition and observation, we define the aggregation similarity score as follows. + +Definition 1. The aggregation similarity score is: + +$$ +\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} +$$ + +where ${ \mathrm { M e a n } } _ { u } \left( \{ \cdot \} \right)$ takes the average over u of a given multiset of values or variables. + +$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, + +$$ +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 ] _ { + } +$$ + +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: + +$$ +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 ) +$$ + +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. + +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. + +![](images/c95a51bb06fe7d52938b07387a269b7b689a3d8e5d1b6f893e2e8ce23be9f235.jpg) +Figure 2: Comparison of baseline performance under different homophily metrics. + +![](images/abb5804f92603addff9a469f330855d8dbb69fa9416266712a781ee36aa03741.jpg) +Figure 3: Example of how diversification can address harmful heterophily + +# 3.2 Empirical Evaluation and Comparison on Synthetic Graphs + +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. + +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. + +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 } } } } } .$ + +# 4 Adaptive Channel Mixing (ACM) + +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. + +# 4.1 Diversification Helps with Harmful Heterophily + +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. + +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. + +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, + +$$ +\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} +$$ + +Then, graph diversification distinguishability value is defined as + +$$ +\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 | +$$ + +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: + +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$ . + +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. + +# 4.2 Filterbank and Adaptive Channel Mixing (ACM) Framework + +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 .$ . + +![](images/948c74e2e0a95c52ca6bfa8cd28e2de0781c1415f3b7b05909f8c2cf17024534.jpg) +Figure 4: $H _ { \mathrm { n o d e } } ^ { v }$ distributions + +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. + +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: + +# Step 1. Feature Extraction for Each Channel: + +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; + +# Step 2. Row-wise Feature-based Weight Learning: + +$$ +\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} +$$ + +# Step 3. Node-wise Adaptive Channel Mixing: + +$$ +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) +$$ + +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. + +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. + +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. + +# 5 Related Work + +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, + +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. + +# 6 Empirical Evaluation + +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. + +![](images/06b082d90bb15827608044fd54d9bb9b958aed44d5b74f2466f243d2ba99013d.jpg) +Figure 5: t-SNE visualization of the output layer of ACM-GCN and GCN trained on Squirrel + +# 6.1 Ablation Study & Efficiency + +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. + +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 + +
Ablation Study on Different Components in ACM-SGC and ACM-GCN (%)
BaselineModelComponentsCornellWisconsinTexasFilmChameleonSquirrelCoraCiteSeerPubMedRank
ModelsLP HP Identity Mixing|Acc ± StdAcc ± StdAcc ± StdAcc ± StdAcc ± StdAcc ± StdAcc ± StdAcc ± StdAcc ± Std
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.7612.89
ACM-SGC-1 w/√ √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.4210.44
√ √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.589.44
√ √ √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.2111.00
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.8810.00
ACM-GCN w/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.3211.44
√ √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.87.22
√ √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.554.44
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.73.11
√ √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.532.78
ACMII-GCN w/√ √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.397.44
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.674.67
√ √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.476.67
√ √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.52.78
Comparison of Average Running Time Per Epoch(ms)
2.532.833.473.43
√ √ √4.014.572.5 4.243.18 4.553.48 4.764.65 5.095.394.694.04 4.75
ACM-SGC-1 w/3.884.014.044.434.064.54.383.824.16
√ √3.313.493.183.73.534.833.923.874.24
√ √5.535.965.435.215.416.9665.96.04
3.673.743.594.185.08
√ √ √6.638.067.894.86 8.114.96 7.86.41 9.394.24 7.827.388.74 6.8
ACM-GCN w/5.735.915.936.866.357.157.346.656.16
√ √5.165.255.25.935.648.025.735.65
√ √8.258.117.897.978.4111.98.848.38
√ √6.627.357.397.627.339.697.497.58
ACMII-GCNw/6.36.056.266.876.446.56.147.217.97 6.6 6.33
√ √ √ √√ √5.24 7.595.27 8.285.46 8.065.72 8.855.65 87.87 105.48 8.275.65 8.58.68
+ +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. + +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. + +# 6.2 Comparison with Baseline and SOTA Models + +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. + +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 } \|$ . + +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. + +![](images/c2317f25ac17c47b2c2adcd91fddc0282fbefedf72865098382678ee0912eb14.jpg) +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. + +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. + +# 7 Conclusions and Limitations + +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. + +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. + +# 8 Acknowledge + +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. + +# References + +[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. +[10] M. Defferrard, X. Bresson, and P. Vandergheynst. Convolutional neural networks on graphs with fast localized spectral filtering. arXiv, abs/1606.09375, 2016. +[11] V. N. Ekambaram. Graph structured data viewed through a fourier lens. University of California, Berkeley, 2014. +[12] M. Fey and J. E. Lenssen. Fast graph representation learning with pytorch geometric. arXiv preprint arXiv:1903.02428, 2019. +[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. +[14] W. L. Hamilton. Graph representation learning. Synthesis Lectures on Artifical Intelligence and Machine Learning, 14(3):1–159, 2020. +[15] W. L. Hamilton, R. Ying, and J. Leskovec. Inductive representation learning on large graphs. arXiv, abs/1706.02216, 2017. +[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. +[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. +[18] D. P. Kingma and J. Ba. Adam: A method for stochastic optimization. arXiv preprint arXiv:1412.6980, 2014. +[19] T. N. Kipf and M. Welling. Semi-supervised classification with graph convolutional networks. arXiv, abs/1609.02907, 2016. +[20] J. Klicpera, A. Bojchevski, and S. Günnemann. Predict then propagate: Graph neural networks meet personalized pagerank. arXiv preprint arXiv:1810.05997, 2018. +[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. +[22] Y. LeCun, Y. Bengio, and G. Hinton. Deep learning. nature, 521(7553):436, 2015. +[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. +[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. +[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. +[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. +[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. +[28] M. Liu, Z. Wang, and S. Ji. Non-local graph neural networks. arXiv preprint arXiv:2005.14612, 2020. +[29] M. Liu, Z. Wang, and S. Ji. Non-local graph neural networks. IEEE Transactions on Pattern Analysis and Machine Intelligence, 2021. +[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. +[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. +[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. +[33] Y. Ma, X. Liu, N. Shah, and J. Tang. Is homophily a necessity for graph neural networks? arXiv preprint arXiv:2106.06134, 2021. +[34] T. Maehara. Revisiting graph neural networks: All we have is low-pass filters. arXiv preprint arXiv:1905.09550, 2019. +[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. +[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. +[37] B. Rozemberczki, C. Allen, and R. Sarkar. Multi-Scale Attributed Node Embedding. Journal of Complex Networks, 9(2), 2021. +[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. +[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. +[40] P. Vary. An adaptive filter-bank equalizer for speech enhancement. Signal Processing, 86(6):1206–1214, 2006. +[41] P. Velickovic, G. Cucurull, A. Casanova, A. Romero, P. Lio, and Y. Bengio. Graph attention networks. arXiv, abs/1710.10903, 2017. +[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. +[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. +[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. +[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. +[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. + +# Checklist + +1. For all authors... + +(a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes] +(b) Did you describe the limitations of your work? [Yes] +(c) Did you discuss any potential negative societal impacts of your work? [N/A] +(d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes] + +2. If you are including theoretical results... + +(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] + +3. If you ran experiments... + +(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] +(b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes] +(c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [Yes] +(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] + +4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets... + +(a) If your work uses existing assets, did you cite the creators? [Yes] +(b) Did you mention the license of the assets? [N/A] +(c) Did you include any new assets either in the supplemental material or as a URL? [No] +(d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [No] +(e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [No] + +5. If you used crowdsourcing or conducted research with human subjects... + +(a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A] +(b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A] +(c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A] \ No newline at end of file diff --git a/md/dev/PUIqjT4rzq7/PUIqjT4rzq7.md b/md/dev/PUIqjT4rzq7/PUIqjT4rzq7.md new file mode 100644 index 0000000000000000000000000000000000000000..62a29d14312042d1469ec207b5ed2050e8926dc6 --- /dev/null +++ b/md/dev/PUIqjT4rzq7/PUIqjT4rzq7.md @@ -0,0 +1,410 @@ +# TRAINING-FREE STRUCTURED DIFFUSION GUIDANCE FOR COMPOSITIONAL TEXT-TO-IMAGE SYNTHESIS + +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 + +# ABSTRACT + +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. + +# 1 INTRODUCTION + +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. + +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. + +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. + +![](images/b61a2adf2a0c4ffb5419a27d01d3d821224796a6f7589f156e3de323e338125e.jpg) +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. + +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. + +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: + +• 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. +• 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. +• 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. + +![](images/09bca81db2a15f234e6b30d656ac74ab6f9b1cbc101365fd59e52c1916f786df.jpg) +Figure 2: An illustration of cross-attention operations and the token-region associations from attention maps. We omit some tokens for simplicity. + +# 2 DIFFUSION MODELS & STRUCTURED GUIDANCE + +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. + +# 2.1 BACKGROUND + +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. + +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”. + +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 )$ + +$$ +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 ) } . +$$ + +![](images/a4f20aec4802f8a65ee210c0541bcc6905c7389daea131d1a009bc1e10573207.jpg) +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. + +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. + +# 2.2 STRUCTURED DIFFUSION GUIDANCE + +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. + +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: + +$$ +\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 . +$$ + +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 }$ : + +$$ +\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} +$$ + +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 }$ + +# Algorithm 1 StructureDiffusion Guidance. + +# Require: + +Input: Prompt $\mathcal { P }$ , Parser $\xi$ , decoder $\psi$ , trained diffusion model $\phi$ . +Output: Generated image $x$ . +1: Retrieve concept set ${ \mathcal { C } } = [ c _ { 1 } , \ldots , c _ { k } ]$ by traversing $\xi ( \mathcal { P } )$ ; +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$ +3: for $t = T , T - 1 , \dots , 1$ do +4: for each cross attention layer in $\phi$ do +5: Obtain previous layer’s output $\mathcal { X } ^ { t }$ . +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}$ +7: Obtain attention maps $M ^ { t }$ from $Q ^ { t } , K _ { \mathrm { p } }$ ; +8: Obtain $O ^ { t }$ from $M ^ { t }$ , $\{ V _ { i } \}$ , and feed to following layers; +9: end for +10: end for +11: Feed $z ^ { 0 }$ to decoder $\psi ( \cdot )$ to generate $\mathbf { X }$ . + +(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 }$ : + +$$ +\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} +$$ + +$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. + +# 3 EXPERIMENT + +# 3.1 EXPERIMENT SETTINGS + +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. + +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. + +# 3.2 COMPOSITIONAL PROMPTS + +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. + +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. + +
BenchmarkStructureDiffusion (ours) v.s.AlignmentFidelity
Win (↑)Lose (↓)TieWin (↑)Lose (↓)Tie
ABC-6KStable Diffusion42.235.622.248.339.112.6
CC-500Stable Diffusion31.827.738.937.830.631.6
Composable Diffusion46.530.122.861.419.818.8
+ +![](images/cde95ccdebc9693de8c741688cd3b4fadc9ef5c3215551ed35f2b60c361cda4c.jpg) +Figure 4: Qualitative results on ABC-6K. Our method improves both object-level and scene-level compositionality. + +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. + +# 3.3 CONCEPT CONJUNCTION + +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. + +
CC-500 (Prompt format: “a [colorA] [objectA] and a [colorB] [objectB]")
Human AnnotationsGLIPHuman-GLIP
MethodsZero/One obj. ()Two obj.Two obj. w/ correct colorsZero/One obj.(↓)Two obj.Consistency
Stable Diffusion65.534.519.269.031.046.4
Composable Diffusion69.730.320.674.225.848.9
StructureDiffusion (Ours)62.038.022.768.831.247.6
+ +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. + +![](images/3902d5a9c111e4d4a12e67c65e27de1a9c2c07d74efa1fca4dfa19aefa3dbcb9.jpg) +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”. + +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). + +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). + +# 3.4 OTHER PROMPTS + +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 + +![](images/e0cc7567ff201cd421e0f017febca9fe7cd7bc251c12c2c41f6a6f273c0b81cb.jpg) +Figure 6: Qualitative results of using scene graph parser to generate structured representations. + +![](images/7dfce557e99a420d3ccd8d1cf8e3979db4bd6ad9b3761a1fd404947bf41071bb.jpg) +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. + +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. + +# 3.5 SCENE GRAPH INPUT + +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. + +# 4 ABLATION STUDY + +# 4.1 RE-ALIGNING SEQUENCE + +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. + +# 4.2 CONTEXTUALIZED TEXT EMBEDDINGS + +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 } }$ . + +# 5 RELATED WORK + +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. + +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. + +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. + +# 6 CONCLUSION + +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. + +# ACKNOWLEDGEMENT + +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. + +# REPRODUCIBILITY STATEMENT + +We release our core codebase containing the methodology implementation, settings, benchmarks containing compositional prompts under supplementary materials. + +# ETHICAL STATEMENT + +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. + +# REFERENCES + +Prafulla Dhariwal and Alexander Nichol. Diffusion models beat gans on image synthesis. Advances in Neural Information Processing Systems, 34:8780–8794, 2021. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +Jonathan Ho and Tim Salimans. Classifier-free diffusion guidance. arXiv preprint arXiv:2207.12598, 2022. + +Jonathan Ho, Ajay Jain, and Pieter Abbeel. Denoising diffusion probabilistic models. Advances in Neural Information Processing Systems, 33:6840–6851, 2020. + +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. + +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. + +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. + +Bowen Li, Xiaojuan Qi, Thomas Lukasiewicz, and Philip Torr. Controllable text-to-image generation. Advances in Neural Information Processing Systems, 32, 2019. + +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. + +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. + +Luping Liu, Yi Ren, Zhijie Lin, and Zhou Zhao. Pseudo numerical methods for diffusion models on manifolds. In International Conference on Learning Representations, 2021a. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +Aditya Ramesh, Prafulla Dhariwal, Alex Nichol, Casey Chu, and Mark Chen. Hierarchical textconditional image generation with clip latents. arXiv preprint arXiv:2204.06125, 2022. + +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. + +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. + +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. + +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. + +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. + +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. + +Yang Song and Stefano Ermon. Generative modeling by estimating gradients of the data distribution. Advances in Neural Information Processing Systems, 32, 2019. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +# A RELATED WORK + +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). + +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. + +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. + +# B IMPLEMENTATION DETAILS + +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. + +# C VISUALIZATION OF ATTENTION MAPS + +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. + +![](images/e22e2d5e7ace9b5fbcfe4a7cc12e67be8180444f5dc3271034867469bdbfde5a.jpg) +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. + +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. + +![](images/0be7b80d0f76ab47ff37221209affb8a234d6aaf76276fa61011c736050abb18.jpg) +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. + +![](images/6ce94909eda492a7e78221376ea5b39def302a7a1f5a92084ca40943ea3a1fda.jpg) +Figure 10: Visualization of attention maps for token “sheep” of different methods. Our method with multiple Keys successfully rectify image layouts. + +# D ABLATION STUDY + +# D.1 A CASE STUDY OF ATTRIBUTE BINDING + +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). + +![](images/3523608906863534f4a3e158ef3281942b6bb6822477164e5d40472b91acf880.jpg) +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. + +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. + +# D.2 COMPARISON OF PARSERS + +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. + +# E LIMITATIONS & FUTURE WORK + +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. + +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. + +
Constituency ParserScene Graph Parser
Example 0CC-500 Prompt: A white sheep and a red car
“A white sheep”,“a red car”“A white sheep”,“a red car”
Example 1Prompt: A silver car with a black cat sleeping on top of it
“A silver car”,“a black cat”,“A silver car with a black cat”“A silver car”,"a black cat”,“top of it”,“a black cat sleeping on top of it"
Example 2Prompt:A horse running in a white field next to a black and green pole
“Ahorse”,“a white feld",“a black and green pole",“a white field next to a black and green pole”“Ahorse”,“a white field”,“a black and green pole”,“A horse running in a white field"
Example 3Prompt:Rice with red sauce with eggs over the top and orange slices on the side
“red sauce”,“the side”,“the top and orange slices”,“the top and orange slices on the side"“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”
Example 4Prompt:A pink scooter with a black seat next to a blue car
“A pink scooter”,“a black seat”,“a blue car”“A pink scooter”,“a black seat”,“a blue car”,"a pink scooter with a black seat",“a black seat next to a blue car”
+ +![](images/5505e9c9fabb63da9b36d9e776d538f607231efc48fb6c2f6bc627e1951a2d11.jpg) +Figure 12: Synthesized images corresponding to prompts in Table 3. Yellow boxes annotate compositions that are improved using different parsers. + +![](images/9a323a017b67c428078490d9067e77f606d8f54878028c43b59103d5e505fc9b.jpg) +Figure 13: Qualitative results on CC-500 + +# Stable Diffusion + +# Ours + +# Stable Diffusion + +# Ours + +# Stable Diffusion + +# Ours + +a purple cat with a orange hat on its head + +A red cat sits on a rug with a black cord + +A yellow cat is wearing a blue plastic baseball hat. + +![](images/660bc275b91b59866cd20e3a88baefb5a552b3ad21116d920fca9476c0987944.jpg) + +![](images/44f8df4e6174cfaee77c876deda6de6350198075800255d17326b31cbf9a0166.jpg) + +![](images/26a9991969c15534788eae2f5acc0d8cda40c915d13508aea40a64234a837dfe.jpg) +A red helmet is on a yellow toilet in the dirt + +A red stop sign above a white walk across road sign + +Two elephants walking by a green wall with tan palm trees painted on it + +![](images/cfd38b6e692be180d8d214269d4b921af9c6ea51e92262d22844436ebebe2b8b.jpg) + +![](images/408e26c582eccff899a6069e2265d99daf61980c8cc47f66c6c8328d8054ffd6.jpg) + +![](images/7c5f1e143277e8913a928bce5fd0f6aacb27ceb05fed39986d71058a5a715923.jpg) + +# A bathroom with red tile and a green shower curtain + +A spacious kitchen has white walls , red countertops , and a large stove + +A large white bed sitting in a hotel room next to a red couch + +![](images/4a43f884cd58a3781a856b40d946e06aa95a3781630c49ecd2683d6082a67e4e.jpg) + +![](images/91f6e969166829de16eb4f631fbb73f19ef0d5390410d037d4a690f99df02786.jpg) + +![](images/c40deaf2eb3b4751d7c5816cee4083bcc77c9b78e322402b3ca26513daf3706d.jpg) + +A pink towel stands out greatly in the white bathroom + +![](images/bacd240485e26a532174d993863ebd922208a129b432bdb6bcd36b94119a092b.jpg) +A white toilet bowl with a purple rug in front + +# A large pizza on a white plate sitting on a blue table + +![](images/fc3d8bd9df11cad37a11762b0e2c5fd1165c80053f07eca502b775632458b10e.jpg) + +![](images/48b52b815f2fadf7e93602f86d613241414c34c280fa91397edfec9c1c36a9c5.jpg) + +A spoon and bowl of red pea soup and green beans with onions + +A cow standing outside of a white building with a blue entrance + +A black and white curtain +hanging in a room that is +decorated in black, white and +red + +![](images/b7fd1fb2b097479ee0c8daa0225ada709939a000e386f9227ee3d53632006091.jpg) + +![](images/6fd1de4853b4e135bbd29c014613e0ba1aebc6158a4201d581f5433d4629e15d.jpg) + +![](images/d5d8e5dbed72e828a9bba99342c7933385ffcda9b12e7d2758d88218380089c8.jpg) +Figure 14: Qualitative results on ABC-6K + +![](images/cfdda3c5e52b24145788d8db72809206b16643bae64a24cf322cb9114b08223e.jpg) +Figure 15: Qualitative results characterizing attributes beyond colors, including shape, size and materials. + +![](images/228590b790dbd98fc2e4f38e8af5d5b6c518ba667976fe594af7a5e67dfcd7e5.jpg) +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. \ No newline at end of file diff --git a/md/dev/QkRV50TZyP/QkRV50TZyP.md b/md/dev/QkRV50TZyP/QkRV50TZyP.md new file mode 100644 index 0000000000000000000000000000000000000000..0c6408beb8610e176a5dedd6f7b4653003cfecd3 --- /dev/null +++ b/md/dev/QkRV50TZyP/QkRV50TZyP.md @@ -0,0 +1,412 @@ +# BEYOND IMAGENET ATTACK: TOWARDS CRAFTINGADVERSARIAL EXAMPLES FOR BLACK-BOX DOMAINS + +Qilong Zhang1∗, Xiaodan $\mathbf { L i } ^ { 2 }$ , Yuefeng Chen2, Jingkuan Song1†, +Lianli $\mathbf { G a o ^ { 1 } }$ , Yuan $\mathbf { H e } ^ { 2 }$ , and Hui $\mathbf { X } \mathbf { u } \mathbf { e } ^ { 2 }$ +1University of Electronic Science and Technology of China, China +qilong.zhang $@$ std.uestc.edu.cn, jingkuan.song $@$ gmail.com, lianli.gao $@$ uestc.edu.cn +2Alibaba Group, China +{fiona.lxd,yuefeng.chenyf,heyuan.hy,hui.xueh}@alibaba-inc.com + +# ABSTRACT + +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. + +# 1 INTRODUCTION + +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. + +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. + +Table 1: A comparison of datasets from different domains. + +
DatasetResolutionTypeTest sizeClasses
ImageNet (Russakovsky et al., 2015)224×224-50,0001,000
CIFAR-10 (Krizhevsky, 2009)32×32coarse-grained10.00010
CIFAR-100 (Krizhevsky,2009)32×32coarse-grained10.000100
STL-10 (Coates et al., 2011)96×96coarse-grained8.00010
SVHN (Netzer et al., 2011)32×32coarse-grained26.03210
CUB-200-2011 (Wah et al.,2011)448×448fine-grained5,740200
Stanford Cars (Krause etal., 2013)448×448fine-grained8.041196
FGVC Aircraft (Maji et al., 2013)448×448fine-grained3,333100
+ +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. + +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. + +# 2 RELATED WORKS + +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. + +![](images/8121e455617a649017241861a0fbc7220d54b3c9c76dd54682286770fd75431c.jpg) +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. + +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. + +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. + +# 3 TRANSFERABLE ADVERSARIAL EXAMPLES BEYOND IMAGENET + +# 3.1 PROBLEM FORMULATION + +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: + +$$ +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 , +$$ + +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. + +# 3.2 PRELIMINARY + +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). + +![](images/01a8e12d393b8450d7e888a6a7666abc0cb6492505ac5a19f70963ecd4f17185.jpg) +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). + +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: + +$$ +\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 } ) ) . +$$ + +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: + +$$ +\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} +$$ + +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: + +• 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). + +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. + +# 3.3 RANDOM NORMALIZATION MODULE + +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). + +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: + +$$ +{ \mathcal R N } ( { \pmb x } _ { s } ) = \pmb { \sigma } \cdot \frac { { \pmb x } _ { s } - { \pmb \mu } ^ { \prime } } { \sigma ^ { \prime } } + { \pmb \mu } , +$$ + +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: + +$$ +\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 } ) ) ) . +$$ + +# 3.4 DOMAIN-AGNOSTIC ATTENTION MODULE + +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$ : + +$$ +\mathbf { \mathcal { A } } ^ { L } = \frac { | \sum _ { i = 0 } ^ { C } [ f _ { s } ^ { L } ( \pmb { x _ { s } } ) ] _ { i } | } { C } , +$$ + +where $C$ is channel number of $f _ { s } ^ { L } ( { \pmb x } _ { s } )$ + +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 + +![](images/017cda7c2d8d0c9cb2d8fcde5c6da85a3ebbab2a3f5a58b40ec4e00c88081cc2.jpg) +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. + +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: + +$$ +\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 } ) ) , +$$ + +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. + +# 4 EXPERIMENTS + +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., + +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. + +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. + +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. + +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. + +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. + +# 4.1 TRANSFERABILITY COMPARISONS + +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. + +# 4.1.1 RESULTS ON COARSE-GRAINED DOMAIN + +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. + +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. + +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$ . + +
ModelAttacks CleanCIFAR-10 93.78CIFAR-100 74.27STL-10 77.59SVHN 96.03AVG. 85.42ModelAttacks CleanCIFAR-10 93.78CIFAR-100 74.27STL-10 77.59SVHN 96.03AVG. 85.42
91-99APGD79.6348.0274.3294.6674.16PGD DIM86.1756.3874.5193.9477.75
DIM77.1644.7572.7491.5371.5580.5048.0371.290.8772.65
DR72.4939.0472.5693.2769.34DR78.8648.6271.6693.2673.10
SSP68.5433.6372.7793.9867.23SSP75.5442.3872.6692.6370.80
CDA66.4132.3772.9192.1765.97P2s3152CDA66.4739.3069.8188.0965.92
CDA+gs86.7059.4373.3891.6177.78CDA+gs85.6157.2773.0690.3476.57
BIA (Ours)57.3822.4769.4590.4459.94BIA(Ours)65.4933.4869.9189.4664.59
BIA+DA(Ours)55.1621.7170.0091.7659.66BIA+DA(Ours)65.3432.6869.6591.3864.76
BIA+RN(Ours)52.8120.8267.5588.0357.30BIA+RN(Ours)61.2332.8468.0485.7961.98
6-D5APGD79.1547.7374.7194.8674.11PGD84.5554.2974.5593.8376.81
DIM77.5491.6871.50DIM80.8973.02
DR70.7243.8172.9693.7368.51DR78.2449.06 48.6772.6489.47 93.272.72
SSP70.4637.59 35.2871.98 73.2193.6768.16GD-sse50SSP77.1342.1870.7591.6470.87
CDA81.6051.5371.4392.6474.30CDA67.7535.0372.53 69.0088.7665.14
CDA+gs88.5561.9073.6492.1879.07CDA+gs85.0154.7172.6188.6975.26
BIA (Ours)57.8823.1259.93BIA (Ours)72.02
BIA+DA(Ours)57.2623.0469.84 70.1688.89 90.0860.14BIA+DA(Ours)71.6938.99 38.9569.8086.1266.73
BIA+RN (Ours)54.4722.6168.2388.0858.35BIA+RN (Ours)66.6734.4170.60 68.7988.02 81.5467.32 62.85
+ +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$ . + +
ModelAttacksCUB-200-2011Stanford CarsFGVC AircraftAVG.
Res-50SENet154SE-Res101Res-50SENet154SE-Res101Res-50SENet154SE-Res101
9I-55AClean87.3586.8186.5694.3593.3692.9792.2392.0891.9090.85
PGD80.6579.5880.6987.4589.0490.3084.8883.9282.1584.30
DIM70.0262.8670.5774.7278.1084.3373.5466.8862.3871.49
DR81.0882.0582.5290.8290.5991.1284.9787.5585.5486.25
SSP62.2760.4471.5258.0275.7183.0254.9168.7463.7966.49
CDA69.69 70.1962.5171.0075.9472.4584.6471.5358.3363.3969.94
CDA+gs63.1968.9285.0379.5283.5278.5565.6268.3873.66
BIA (Ours)32.74 25.0052.9958.0439.6169.9070.1728.9260.3146.9251.07
BIA+DA(Ours) BIA+RN(Ours)26.1340.27 46.1553.24 55.0722.24 20.6159.48 62.6461.52 63.3815.36 16.5047.91 52.5440.83 45.4840.65 43.17
6--555PGD80.9879.0080.6087.5488.8790.5684.7084.0183.3584.40
DIM69.9361.6070.9075.0278.5584.6374.5967.6965.2672.02
DR80.8381.5781.9591.0090.2391.1584.4385.9684.5785.74
SSP62.9458.3470.4561.9076.2783.7758.7869.5266.8867.65
CDA59.4861.0868.5058.5370.7080.7059.2652.2462.2663.64
CDA+gs67.8859.4267.5782.8378.6182.6479.3665.8968.3572.51
BIA (Ours)48.9052.3356.4766.3472.45
BIA+DA(Ours)27.4637.6150.1435.2761.4075.08 64.4150.95 17.9754.04 45.8151.79 44.0158.71
BIA+RN(Ours)31.7743.4151.0942.8168.9066.2727.7552.4845.5742.68 47.78
P1s-152PGD73.2175.8976.1183.9986.8988.2479.0079.3075.6479.81
DIM56.3059.3563.3667.8876.3779.7764.2162.9554.4964.96
DR77.5882.0780.6087.9690.1190.6777.8982.2780.0883.25
SSP47.6466.1767.9053.2979.0983.4558.3573.3669.3466.51
CDA45.1553.6952.8657.7263.0973.0564.8746.7459.1157.36
CDA+gs59.3264.2460.0881.1582.9182.5675.5273.7266.5871.79
BIA(Ours)43.5549.5055.5431.6554.12
BIA+DA(Ours)25.8039.7152.8333.4352.4167.21 68.0338.49 27.5132.46 27.4251.19 47.2847.08 41.60
GDr-ese5gBIA+RN(Ours)23.5440.1351.3612.3947.9260.5932.3432.8546.8938.67
PGD79.29
DIM63.1781.14 62.0179.74 65.9687.66 72.8890.1389.8083.2384.3181.2484.06
DR74.8478.8977.9386.5478.29 88.8281.25 89.5268.89 77.8065.26 78.7354.79 74.4768.06 80.84
SSP41.8049.9559.7226.6568.7174.3616.8055.7844.0748.65
CDA52.9260.9657.0453.6473.6675.5162.2361.4259.8361.91
CDA+gs60.8661.3460.1074.9576.3578.8672.9468.6864.6668.75
BIA (Ours)21.7929.2939.139.5844.4649.068.0427.8433.8729.23
BIA+DA(Ours) 12.36
+ +# 4.1.2 RESULTS ON FINE-GRAINED DOMAIN + +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. + +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. + +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$ . + +
ModelAttack CleanVGG-16 70.14Dense-169 75.75VGG-19 70.95Res-50 74.61Res-152 77.34Dense-121 74.22Inc-v3 76.19AVG. 74.17
VGG-16PGD2.49*53.224.2745.5258.6948.2861.0839.08
DIM3.32*22.723.3919.1333.0318.5030.0518.59
DR20.95*67.9143.5964.9070.0064.7369.2257.33
SSP0.95*39.563.4226.2241.6834.4547.4627.68
CDA0.40*42.670.7736.2751.0538.8954.0232.01
CDA+gs12.10*57.0920.4851.8760.8352.2155.1244.24
BIA (Ours)1.55*32.353.6125.3642.9826.9741.2024.86
BIA+DA(Ours)1.04*24.522.0718.6336.4319.9734.5419.60
BIA+RN(Ours)1.44*25.962.5816.5231.8018.2528.5417.87
Dense-169PGD38.515.03*40.5333.9144.9721.1858.3034.63
DIM12.315.25*13.208.9812.935.9121.4411.43
DR38.4523.99*41.5950.1958.7049.9563.7046.65
SSP11.531.32*12.5412.9725.669.7425.5814.19
CDA7.260.63*7.916.4615.565.1343.7812.39
CDA+gs27.9822.95*28.5631.5243.6731.6649.1833.65
BIA (Ours)4.766.45*7.156.9713.836.6038.5812.05
BIA+DA(Ours)3.173.32*4.094.445.853.9826.517.34
BIA+RN(Ours)3.664.05*5.236.9113.254.2114.247.36
+ +# 4.1.3 RESULTS ON SOURCE DOMAIN + +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. + +4.2 COMBINATION OF DOMAIN-AGNOSTIC ATTENTION AND RANDOM NORMALIZATION + +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: + +$$ +\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 } ) ) ) . +$$ + +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, + +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. + +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 + +![](images/4ecd10a3691d3714ff189539f01805d221cf14ddcec75d479aeab721ab4e2388.jpg) +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. + +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. + +![](images/ba820367a302ab95b1868a9130cf44d4e19cb1331f48670968e85446d3bf274e.jpg) +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. + +# 5 CONCLUSION + +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. + +# 6 ACKNOWLEDGE + +This work was supported by the National Natural Science Foundation of China (Grant No. +62020106008, No. 61772116 and No. 61872064) and Alibaba Group. + +# REFERENCES + +Shumeet Baluja and Ian Fischer. Adversarial transformation networks: Learning to generate adversarial examples. CoRR, abs/1703.09387, 2017. + +Wieland Brendel, Jonas Rauber, and Matthias Bethge. Decision-based adversarial attacks: Reliable attacks against black-box machine learning models. In ICLR, 2018. + +Nicholas Carlini and David A. Wagner. Towards evaluating the robustness of neural networks. In Symposium on Security and Privacy, 2017. + +Rich Caruana, Alexandru Niculescu-Mizil, Geoff Crew, and Alex Ksikes. Ensemble selection from libraries of models. In ICML, 2004. + +Jianbo Chen, Michael I. Jordan, and Martin J. Wainwright. Hopskipjumpattack: A query-efficient decision-based attack. In SP, 2020. + +Yue Chen, Yalong Bai, Wei Zhang, and Tao Mei. Destruction and construction learning for finegrained image recognition. In CVPR, 2019. + +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. + +Yinpeng Dong, Fangzhou Liao, Tianyu Pang, Hang Su, Jun Zhu, Xiaolin Hu, and Jianguo Li. Boosting adversarial attacks with momentum. In CVPR, 2018. + +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. + +Lianli Gao, Qilong Zhang, Jingkuan Song, Xianglong Liu, and Hengtao Shen. Patch-wise attack for fooling deep neural network. In ECCV, 2020a. + +Lianli Gao, Qilong Zhang, Jingkuan Song, and Heng Tao Shen. Patch-wise $^ { + + }$ perturbation for adversarial targeted attacks. CoRR, abs/2012.15503, 2020b. + +Lianli Gao, Yaya Cheng, Qilong Zhang, Xing Xu, and Jingkuan Song. Feature space targeted attacks by statistic alignment. In IJCAI, 2021. + +Ian J. Goodfellow, Jonathon Shlens, and Christian Szegedy. Explaining and harnessing adversarial examples. In Yoshua Bengio and Yann LeCun (eds.), ICLR, 2015. + +Lars Kai Hansen and Peter Salamon. Neural network ensembles. IEEE Trans. Pattern Anal. Mach. Intell., 1990. + +Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. In CVPR, 2016. + +Jie Hu, Li Shen, and Gang Sun. Squeeze-and-excitation networks. In CVPR, 2018. + +Gao Huang, Zhuang Liu, Laurens van der Maaten, and Kilian Q. Weinberger. Densely connected convolutional networks. In CVPR, 2017. + +Nathan Inkawhich, Wei Wen, Hai (Helen) Li, and Yiran Chen. Feature space perturbations yield more transferable adversarial examples. In CVPR, 2019. + +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. + +Diederik P. Kingma and Jimmy Ba. Adam: A method for stochastic optimization. In ICLR, 2015. + +Jonathan Krause, Jia Deng, Michael Stark, and Li Fei-Fei. Collecting a large-scale dataset of finegrained cars. 2013. + +Alex Krizhevsky. Learning multiple layers of features from tiny images. 2009. + +Alex Krizhevsky, Ilya Sutskever, and Geoffrey E. Hinton. Imagenet classification with deep convolutional neural networks. In NeurPIS, 2012. + +Alexey Kurakin, Ian J. Goodfellow, and Samy Bengio. Adversarial examples in the physical world. In ICLR, 2017a. + +Alexey Kurakin, Ian J. Goodfellow, and Samy Bengio. Adversarial machine learning at scale. In ICLR, 2017b. + +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. + +Yanpei Liu, Xinyun Chen, Chang Liu, and Dawn Song. Delving into transferable adversarial examples and black-box attacks. In ICLR, 2017. + +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. + +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. + +Aleksander Madry, Aleksandar Makelov, Ludwig Schmidt, Dimitris Tsipras, and Adrian Vladu. Towards deep learning models resistant to adversarial attacks. In ICLR, 2018. + +Subhransu Maji, Esa Rahtu, Juho Kannala, Matthew B. Blaschko, and Andrea Vedaldi. Fine-grained visual classification of aircraft. volume abs/1306.5151, 2013. + +Xiaofeng Mao, Yuefeng Chen, Shuhui Wang, Hang Su, Yuan He, and Hui Xue. Composite adversarial attacks. In AAAI, 2021. + +Seyed-Mohsen Moosavi-Dezfooli, Alhussein Fawzi, and Pascal Frossard. Deepfool: A simple and accurate method to fool deep neural networks. In CVPR, 2016. + +Konda Reddy Mopuri, Utkarsh Ojha, Utsav Garg, and R. Venkatesh Babu. NAG: network for adversary generation. In CVPR, 2018. + +Muzammal Naseer, Salman H. Khan, Muhammad Haris Khan, Fahad Shahbaz Khan, and Fatih Porikli. Cross-domain transferability of adversarial perturbations. In NeurPIS, 2019. + +Muzammal Naseer, Salman H. Khan, Munawar Hayat, Fahad Shahbaz Khan, and Fatih Porikli. A self-supervised approach for adversarial robustness. In CVPR, 2020. + +Yuval Netzer, Tao Wang, Adam Coates, Alessandro Bissacco Bo Wu, and Andrew Y. Ng. Reading digits in natural images with unsupervised feature learning. 2011. + +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. + +Omid Poursaeed, Isay Katsman, Bicheng Gao, and Serge J. Belongie. Generative adversarial perturbations. In CVPR, 2018. + +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. + +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. + +Yucheng Shi, Siyu Wang, and Yahong Han. Curls & whey: Boosting black-box adversarial attacks. In CVPR, 2019. + +Karen Simonyan and Andrew Zisserman. Very deep convolutional networks for large-scale image recognition. In Yoshua Bengio and Yann LeCun (eds.), ICLR, 2015. + +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. + +Christian Szegedy, Vincent Vanhoucke, Sergey Ioffe, Jonathon Shlens, and Zbigniew Wojna. Rethinking the inception architecture for computer vision. In CVPR, 2016. + +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. + +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. + +Xiaosen Wang, Xuanran He, Jingdong Wang, and Kun He. Admix: Enhancing the transferability of adversarial attacks. In ICCV, 2021. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +Zhengyu Zhao, Zhuoran Liu, and Martha A. Larson. On success and simplicity: A second look at transferable targeted attacks. CoRR, abs/2012.11207, 2020. + +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. + +# A APPENDIX + +![](images/a3eb2cf3d05fabc4b32c9e9f34ad5e4e9486195d6355aacf96d920c8c62d5115.jpg) +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. + +![](images/742ca68f8adfdb07b0b2688fcc47f11ed2f4f5fbf9d0acac484a073811109501.jpg) +Figure 7: The structure of the generator. + +![](images/319485c961167e8f852f7873feb57a1fb4bded4e02eaef9e0b9ec9d1bf79d6df.jpg) +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. + +# A.1 SELECT LAYER FOR ATTACKING + +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. + +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. + +# A.2 SELECT GAUSSIAN DISTRIBUTION FOR RANDOM NORMALIZATION + +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). + +![](images/4955a0520f0dfb069af0d2360393bde7466120aebc110a8a60ecc7e0e354bbdd.jpg) +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 }$ . + +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. + +# A.3 DATA AUGMENTATION VS. RANDOM NORMALIZATION + +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. + +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. + +# A.4 INSIGHT INTO THE GENERATOR + +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: + +![](images/cffcba5f5c5804d61a8eb199fb31cdc2b10ae019bcb69bc47c3424cebf3b65ac.jpg) +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. + +![](images/4ec3751736a8ca1997448b8ac8402ca0c000c1fec5f5e85e61492c892ceb1c60.jpg) +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. + +• 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. +• Residual block: Unlike the downsampling block, this block is responsible for adding noise and its behavior looks very similar to the iterative algorithm. +• Upsampling block: This block gradually reconstructs the adversarial example from abstract features. + +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. + +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 + +![](images/c533ac52894362944c993885611d63588c7ef8cbe930655443a15ceffa0bd085.jpg) +Figure 13: A benign image (label is “Boeing 747”) from FGVC Aircraft (Maji et al., 2013) and its corresponding adversarial examples and difference map. + +duced. Specifically, we first apply cross-channel average pooling to the output of the downsampling + +![](images/eaa3a0a03e90e4247293ba6bf07592e5f6f00a59257c996993a39c4dff27f299.jpg) +Figure 12: We apply cross-channel average pooling to visualize each block of our generator $\mathcal { G } _ { \theta ^ { * } }$ + +block: + +$$ +\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} +$$ + +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: + +$$ +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. } +$$ + +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. + +# A.5 DISCUSSION ON CHANGING SOURCE DOMAIN + +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. + +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$ . + +
AttacksCUB-200-2011CIFAR-10CIFAR-100STL-10SVHNStanford CarsFGVC AircraftImageNet
CDA64.3483.6154.8370.4991.8174.3771.1750.99
BIA40.4082.6254.5771.4391.6768.2557.9044.15
BIA+DA29.5582.9454.1571.7087.2854.6555.1537.15
BIA+RN42.8883.8453.6369.7987.9557.0150.8539.43
+ +# A.6 DISCUSSION ON ENSEMBLE-MODEL ATTACKS + +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. + +From the result, We can observe that ensemble-based training can also improve the transferability of adversarial examples towards black-box domains significantly. + +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$ . + +
CIFAR-10CIFAR-100STL-10SVHNCUB-200-2011 (SENet-154)Stanford Cars (SENet-154)FGVC Aircraft (SENet-154)
BIA57.3822.4769.4590.4452.9969.9060.31
BIA (ensemble)54.9621.7368.9485.8529.1546.4736.87
BIA+DA55.1621.7170.0091.7640.2759.4847.91
BIA+DA (ensemble)52.9720.5169.5189.1518.4738.9925.41
BIA+RN52.8120.8267.5588.0346.1562.6452.54
BIA+RN (ensemble)50.9922.3566.0681.6635.4041.8727.81
+ +# A.7 DISCUSSION ON STANDARD DEVIATION ACROSS MULTIPLE RANDOM RUNS + +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. + +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$ . + +
CIFAR-10CIFAR-100STL-10SVHNCUB-200-2011 (SENet-154)Stanford Cars (SENet-154)FGVC Aircraft (SENet-154)ImageNet (Res-152)
BIAPaper report (Table2&3&4)57.3822.4769.4590.4452.9969.9060.3142.98
Random runs56.7521.8669.6190.4852.4768.1361.4544.04
57.3122.3269.8390.3552.0469.4857.3741.67
57.1322.8270.0690.0153.2769.7458.5441.02
57.0322.3870.0590.4353.0471.9162.0243.09
57.3622.5069.5589.7851.4868.1558.3642.00
Paper report57.16 ± 0.2422.39 ± 0.3169.76±0.2690.25±0.2952.55 ± 0.6969.55 ± 1.3959.68 ± 1.8642.47 ± 1.10
BIA+RN(Table2&3&4)52.8120.8267.5588.0346.1562.6452.5431.80
52.5621.1266.7588.6344.8463.1851.5530.71
52.6321.4367.2487.9348.3863.455.0933.76
52.2921.4267.388.6445.4163.252.9931.8
52.6021.68 21.6667.2187.6948.8863.9852.6929.56
53.41 52.70±0.4267.0088.4049.0164.1655.9630.96
BIA+DAPaper report (Table2&3&4)21.46 ± 0.2367.10± 0.23 70.0088.26 ± 0.43 91.7647.30 ± 2.01 40.2763.58 ± 0.46 59.4853.66 ± 1.8131.36 ± 1.56
55.1621.7147.9136.43
Random runs55.0521.869.9391.4341.0157.7048.1535.81
54.4721.3470.0591.539.9657.9848.3035.23
55.3021.3769.7992.1541.8958.6548.7836.73
55.1521.3170.0592.1840.7359.1549.0836.09
54.5221.3669.7192.0441.9258.5749.0237.67
Paper reportResult 54.90 ± 0.3821.44 ± 0.2069.91 ± 0.1591.86 ± 0.3741.10 ± 0.8358.41 ± 0.5748.67 ± 0.4236.31 ± 0.93
BIA+DA+RN(Table 2&3&4)50.2920.0367.5190.440.4657.2637.0124.91
Random runs
51.3520.18 20.1767.5391.3443.56 43.0358.29 58.436.11 38.0722.25 23.83
50.49 50.6420.2767.5 67.6490.95 90.5641.1856.4637.0526.07
50.7220.4867.1090.6539.1155.6936.0024.31
50.4920.0967.1590.7738.7855.8137.3825.27
Result50.74±0.36 20.24±0.15 67.38±0.24 90.85± 0.3141.13 ± 2.1956.93 ± 1.3336.92 ± 0.8724.35± 1.46
+ +A.8 EFFECTS OF $\mathcal { R N }$ AND $\mathcal { D A }$ ON COARSE-GRAINED AND FINE-GRAINED TASKS + +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: + +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. + +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. \ No newline at end of file diff --git a/md/dev/Qy1D9JyMBg0/Qy1D9JyMBg0.md b/md/dev/Qy1D9JyMBg0/Qy1D9JyMBg0.md new file mode 100644 index 0000000000000000000000000000000000000000..0724d0ea52c59ed99dd140b7422a8d32dda55753 --- /dev/null +++ b/md/dev/Qy1D9JyMBg0/Qy1D9JyMBg0.md @@ -0,0 +1,291 @@ +# Multimodal Contrastive Learning with LIMoE: the Language-Image Mixture of Experts + +Basil Mustafa∗, Carlos Riquelme\*, Joan Puigcerver\*, Rodolphe Jenatton, Neil Houlsby Google Brain {basilm, rikel, jpuigcerver, rjenatton, neilhoulsby}@google.com + +# Abstract + +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. + +# 1 Introduction + +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. + +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]. + +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). + +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. + +In summary, our contributions are as follows. + +• We propose LIMoE, the first large-scale multimodal mixture of experts models. +• 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. +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. +• Lastly, we present ablations and analysis to understand the model’s behavior and our design decisions. + +![](images/8eeba2d62d78eb816871876d9a4ee56cfc52e295d2cdec1da69f33730a297a8e.jpg) +Figure 1: LIMoE, a sparsely activated multimodal model, processes both images and texts, utilising conditional computation to allocate computations in a modality-agnostic fashion. + +# 2 Multimodal Mixture of Experts + +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. + +# 2.1 Multimodal contrastive learning + +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: + +$$ +\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 } } . +$$ + +# 2.2 The LIMoE Architecture + +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 } }$ . + +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. + +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: + +![](images/0dba0eb0d7f5394cb7861652bd1f0a30fe2c7060fad594e8077fcfc13bfc8625.jpg) +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. + +$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}$ . + +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. + +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. + +# 2.2.1 Challenges for multimodal MoEs + +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]. + +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. + +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. + +# 2.2.2 Auxiliary losses + +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. + +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 }$ ; + +this later dictates which experts process $\mathbf { x }$ . The local and global entropy losses are defined by: + +$$ +\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 } } ) ) , +$$ + +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. + +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. + +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. + +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. + +![](images/b2a40b88d4645387584f6c2d2126829a0805542cea992fdb2dcd26d91f2b0b7d.jpg) +(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 +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). + +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. + +# 2.2.3 Priority routing + +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. + +# 3 Experiments + +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. + +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. + +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. + +# 3.1 Controlled study across scales + +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]. + +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. + +# 3.2 Scaling up LIMoE + +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. + +![](images/d0d34beaf46f0869823a29e8690c67130cab31729b0bf0a2f5794a23881b3ac4.jpg) +Figure 4: LIMoE scales well to large models, with consistent performance improvements. + +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. + +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. + +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]. + +
Key: PretrainedExamplesseen duringpretrainingUsesFixRes[24]3Other non-contrastivetrainingobjective
ArchitectureBatchExamples seenParametersImageNet top-1 % Test
ImageTextsizeper tokenV2R
COCA [25]ViT-gT-g65k32.8B1.1B86.380.796.590.2
BASIC[18]CoAtNet-7*T-H*65k19.7BPT +32.8B1.5B85.780.695.785.6
LIT[16]ViT-g*T-g32k25.8BPT + 18.2B1.1B84.578.793.979.4
ALIGN [10]EffNet-L2T-L*16k19.8B~410M76.470.192.275.8
CLIP [7]ViT-L/14†T-B32k12.8B~ 200M76.270.188.977.2
LIMoEH/1421k23.3B675M84.177.794.978.7
+ +# 4 Ablations + +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. + +# 4.1 Routing and auxiliary losses + +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. + +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$ $( \% )$ . + +
Modeli1k Oshoti1k 10shotcoco t2icoco i2t
dense one-tower49.8 50.4 49.243.8 44.3 43.323.7 2423.436.7 38.9 34.6
dense two-tower54.7 55.2 54.147.1 47.6 46.726.6 27.1 26.241.3 42.0 40.6
LIMoEB71 56.958 50.525.62839.7 42.2 37.1
+ +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. + +
ValidationOshot10shot
Auxiliary lossXXX
Importance70.570.655.456.251.151.3
Load70.370.656.255.751.351.1
Z-Loss70.370.655.856.250.551.3
Global Ent Image70.670.556.056.250.851.3
Global Ent Text69.170.654.356.251.151.3
Local Ent Image70.668.756.253.551.347.5
Local Ent Text67.270.653.356.247.551.3
+ +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: + +• $\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. + +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. + +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). + +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. + +![](images/c8221e4e8f21d5d938c2021afc77bffbe44052e6a5771f002dfb281e1fdf415a.jpg) +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. + +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. + +![](images/f8731692c249ccf80dd2a2093e9d2bd9f03365dd66a90ed68048ba6eed1c733b.jpg) +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. + +# 4.2 Other ablations + +We summarize our other ablations here due to space constraints; details can be found in Appendix E. + +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. + +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$ . + +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]). + +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. + +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. + +# 5 Model Analysis + +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. + +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). + +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. + +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. + +# 6 Related work + +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. + +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]. + +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. + +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. + +# 7 Conclusions and Future Work + +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. + +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. + +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. + +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. + +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. + +# 8 Acknowledgements + +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. + +References +[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. +[2] Yuxuan Lou, Fuzhao Xue, Zangwei Zheng, and Yang You. Cross-token modeling with conditional computation, 2022. +[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. +[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. +[5] Mark Collier, Efi Kokiopoulou, Andrea Gesmundo, and Jesse Berent. Routing networks with co-training for continual learning, 2020. +[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. +[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. +[8] William Fedus, Barret Zoph, and Noam Shazeer. Switch transformers: Scaling to trillion parameter models with simple and efficient sparsity. JMLR, 23(120), 2022. +[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. +[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. +[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. +[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. +[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. +[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. +[15] Thomas M Cover. Elements of information theory. John Wiley & Sons, 1999. +[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. +[17] Xiaohua Zhai, Alexander Kolesnikov, Neil Houlsby, and Lucas Beyer. Scaling vision transformers. CVPR, 2021. +[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. + +[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. + +[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. + +[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. + +[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. + +[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. + +[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. + +[25] Jiahui Yu, Zirui Wang, Vijay Vasudevan, Legg Yeung, Mojtaba Seyedhosseini, and Yonghui Wu. Coca: Contrastive captioners are image-text foundation models, 2022. + +[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. + +[27] Yi Tay, Mostafa Dehghani, Dara Bahri, and Donald Metzler. Efficient transformers: A survey. ACM Comput. Surv., 2022. + +[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. + +[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. + +[30] Hao Tan and Mohit Bansal. Lxmert: Learning cross-modality encoder representations from transformers. In EMNLP, 2019. + +[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. + +[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. + +[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. + +[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. + +[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. + +[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. + +[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. + +[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. + +[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. + +[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. + +[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. + +[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. + +[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. + +[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. + +[45] Abeba Birhane, Vinay Uday Prabhu, and Emmanuel Kahembwe. Multimodal datasets: misogyny, pornography, and malignant stereotypes. CoRR, 2021. + +[46] Sara Hooker, Nyalleng Moorosi, Gregory Clark, Samy Bengio, and Emily L. Denton. Characterising bias in compressed models. ArXiv, abs/2010.03058, 2020. + +[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. + +[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. + +[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. + +[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. \ No newline at end of file diff --git a/md/dev/RdJVFCHjUMI/RdJVFCHjUMI.md b/md/dev/RdJVFCHjUMI/RdJVFCHjUMI.md new file mode 100644 index 0000000000000000000000000000000000000000..c1aa00b2305f2fe963d2a19ffe0920fbab5576a2 --- /dev/null +++ b/md/dev/RdJVFCHjUMI/RdJVFCHjUMI.md @@ -0,0 +1,819 @@ +# AN EXPLANATION OF IN-CONTEXT LEARNING AS IMPLICIT BAYESIAN INFERENCE + +Sang Michael Xie, Aditi Raghunathan, Percy Liang, Tengyu Ma Stanford University {xie,aditir,pliang,tengyuma}@cs.stanford.edu + +# ABSTRACT + +Large language models (LMs) such as GPT-3 have the surprising ability to do in-context learning, where the model learns to do a downstream task simply by conditioning on a prompt consisting of input-output examples. The LM learns from these examples without being explicitly pretrained to learn. Thus, it is unclear what enables in-context learning. In this paper, we study how in-context learning can emerge when pretraining documents have long-range coherence. Here, the LM must infer a latent document-level concept to generate coherent next tokens during pretraining. At test time, in-context learning occurs when the LM also infers a shared latent concept between examples in a prompt. We prove when this occurs despite a distribution mismatch between prompts and pretraining data in a setting where the pretraining distribution is a mixture of HMMs. In contrast to messy large-scale datasets used to train LMs capable of in-context learning, we generate a small-scale synthetic dataset (GINC) where Transformers and LSTMs both exhibit in-context learning1. Beyond the theory, experiments on GINC exhibit large-scale real-world phenomena including improved in-context performance with model scaling (despite the same pretraining loss), sensitivity to example order, and instances where zero-shot is better than few-shot in-context learning. + +# 1 INTRODUCTION + +Large language models (LMs) such as GPT-3 (Brown et al., 2020; Lieber et al., 2021; Wang & Komatsuzaki, 2021; Radford et al., 2019) are pretrained on massive text corpora to predict the next word given previous words. They demonstrate the surprising ability to do in-context learning, where an LM “learns” to do a task simply by conditioning on a prompt containing input-output pairs, achieving SOTA results on LAMBADA (Paperno et al., 2016) and TriviaQA (Joshi et al., 2017) tasks ( $1 8 \%$ and $3 \%$ over previous SOTA (Brown et al., 2020)). For example, consider the task of predicting nationalities from names. A prompt (Figure 1) is constructed by concatenating independent “training” examples (e.g., “Albert Einstein was German”) followed by a “test example” (“Marie Curie was”). Conditioning on this prompt, GPT-3 places the largest probability on the correct output + +p(“Polish” | “Albert Einstein was German \n Mahatma Gandhi was Indian \n Marie Curie was”) + +by inferring the task from examples. Intruigingly, GPT-3 was not explicitly pretrained to learn from examples, and the distribution of prompts (which concatenate independent examples) is quite different from natural language. Our understanding of in-context learning is limited since (i) real pretraining data is messy and (ii) in-context learning has so far required large-scale datasets and models. + +In this paper, we introduce a simple pretraining distribution where in-context learning emerges. To generate a document, we first draw a latent concept $\theta$ , which parameterizes the transitions of a Hidden Markov Model (HMM) (Baum & Petrie, 1966), then sample a sequence of tokens from the HMM (Figure 9). This latent variable structure is common in topic models such as LDA (Blei et al., 2003; Gruber et al., 2007). During pretraining, the LM must infer the latent concept across multiple sentences to generate coherent continuations. When conditioning on a prompt, in-context learning occurs when the LM also infers a shared prompt concept across examples to make a prediction. We assume the LM fits the pretraining distribution $p$ exactly with enough data and expressivity, so that the question of in-context learning becomes characterizing the conditional distribution of completions given prompts $p$ (output|prompt) under the pretraining distribution, where the prompt is generated from a different distribution $p _ { \mathrm { p r o m p t } }$ . This conditional distribution, which is the posterior predictive distribution, marginalizes out the latent concepts: + +![](images/ef15d855fb378be489ad7425d7f776ce065843f3b413f440d9613872316ff485.jpg) +Figure 1: In-context learning can emerge from modeling long-range coherence in the pretraining data. During pretraining, the language model (LM) implicitly learns to infer a latent concept (e.g., wiki bios, which typically transition between name (Albert Einstein) nationality (German) occupation (physicist) $ \ldots$ ) shared across sentences in a document. Although prompts are unnatural sequences that concatenate independent examples, in-context learning occurs if the LM can still infer the shared concept across examples to do the task (name nationality, which is part of wiki bios). + +$$ +p ( \mathrm { o u t p u t } | \mathrm { p r o m p t } ) = \int _ { \mathrm { c o n c e p t } } p ( \mathrm { o u t p u t } | \mathrm { c o n c e p t } , \mathrm { p r o m p t } ) p ( \mathrm { c o n c e p t } | \mathrm { p r o m p t } ) d ( \mathrm { c o n c e p t } ) . +$$ + +If $p$ (concept|prompt) concentrates on the prompt concept with more examples, then the LM learns via marginalization by “selecting” the prompt concept. Thus, in-context learning can be viewed as the LM implicitly performing Bayesian inference. + +The main challenge is that prompts are sampled from a different distribution than the pretraining distribution. The canonical Bayesian asymptotic tool is the Bernstein-von Mises theorem (van der Vaart, 1998; Kleijn & van der Vaart, 2012; Gunst & Shcherbakova, 2008), which asserts (under regularity conditions) that the posterior distribution of a latent variable concentrates on the maximum likelihood estimate. However, Bernstein-von Mises typically assumes observations are independent and/or drawn from the same distribution as the model, both of which are not satisfied. We prove that despite the distribution mismatch, the asymptotic prediction error of in-context learning is optimal when the signal about the latent concept in each prompt example is larger than the error due to the distribution mismatch. Additionally, we prove that the in-context learning error decreases with the length of each example— thus, information in the inputs, not just the input-output mapping, can be useful for in-context learning. + +As a companion to this theory, we created the Generative IN-Context learning dataset (GINC), which is a small-scale synthetic dataset for studying in-context learning. We find that both Transformers (Vaswani et al., 2017) and LSTMs (Hochreiter & Schmidhuber, 1997) trained on GINC exhibit incontext learning. We verify intuitions from the theory, showing that the accuracy of in-context learning improves with the number of examples and example length. Ablations of the GINC dataset show that the latent concept structure in the pretraining distribution is crucial to the emergence of in-context learning. + +The experiments also bring up open questions which go beyond our theory, which only studies the pretraining distribution. We find that scaling up the number of model parameters steadily improves the in-context accuracy despite achieving the same pretraining loss, showing that larger models may improve in-context learning beyond increasing the capacity for memorizing the training data better. Previously observed in-context learning phenomena such as sensitivity to example ordering (Zhao et al., 2021) and the existence of settings where zero-shot is better than one/few-shot learning (Brown et al., 2020) are also mirrored in GINC. + +# 2 IN-CONTEXT LEARNING SETTING + +Pretraining distribution. In our framework, a latent concept $\theta$ from a family of concepts $\Theta$ defines a distribution over observed tokens $o$ from a vocabulary $\boldsymbol { \mathcal { O } }$ . To generate a document, we first sample a + +concept from a prior $p ( \theta )$ and then sample the document given the concept. Each pretraining document is a length $T$ sequence: + +$$ +p ( o _ { 1 } , . . . , o _ { T } ) = \int _ { \theta \in \Theta } p ( o _ { 1 } , . . . , o _ { T } | \theta ) p ( \theta ) d \theta . +$$ + +We assume $p ( o _ { 1 } , . . . , o _ { T } | \theta )$ is defined by a Hidden Markov Model (HMM). The concept $\theta$ determines the transition probability matrix of the HMM hidden states $h _ { 1 } , . . . , h _ { T }$ from a hidden state set $\mathcal { H }$ . + +Prompt distribution. The prompt distribution $p _ { \mathrm { p r o m p t } }$ generates prompts for in-context learning. A prompt is a concatenation of $n$ independent training examples and 1 test input $x _ { \mathrm { t e s t } }$ , which are all conditioned on a shared prompt concept $\theta ^ { * }$ . The goal is to predict the test output $y _ { \mathrm { t e s t } }$ by predicting the next token conditioned on the prompt. + +A prompt example is composed of an input token sequence $x$ (e.g., Albert Einstein was) followed by an output token $y$ (e.g., German). In particular, the $i$ -th training example $O _ { i }$ consists of an input $x _ { i } { = } O _ { i } [ 1 { : } k - 1 ]$ (the first $k - 1$ tokens) followed by an output token $y _ { i } = O _ { i } [ k ]$ at the end2. The $i$ -th training example is independently generated as follows: + +1. Generate a start hidden state $h _ { i } ^ { \mathrm { s t a r t } }$ from a prompt start distribution $p _ { \mathrm { p r o m p t } }$ . 2. Given $h _ { i } ^ { \mathrm { s t a r t } }$ , generate the example sequence $O _ { i } = [ x _ { i } , y _ { i } ]$ from $p \dot { ( } O _ { i } \vert h _ { i } ^ { \mathrm { s t a r t } } , \theta ^ { \ast } )$ , the pretraining distribution conditioned on a prompt concept $\theta ^ { * }$ . + +The test input $x _ { \mathrm { { t e s t } } } = x _ { n + 1 }$ is sampled similarly. Between each example, there is a special delimiter token $o ^ { \mathrm { { d e l i m } } }$ . The prompt consists of a sequence of training examples $( S _ { n } )$ ) followed by the test example $x _ { \mathrm { t e s t } }$ + +$$ +[ S _ { n } , x _ { \mathsf { t e s t } } ] = [ x _ { 1 } , y _ { 1 } , o ^ { \mathsf { d e l i m } } , x _ { 2 } , y _ { 2 } , o ^ { \mathsf { d e l i m } } , . . . , x _ { n } , y _ { n } , o ^ { \mathsf { d e l i m } } , x _ { \mathsf { t e s t } } ] \sim p _ { \mathsf { p r o m p t } } . +$$ + +Mismatch between prompt and pretraining distributions. Since transitions between independent examples can be unnatural, the prompts are low probability sequences under the pretraining distribution. We provide a simple illustration using the names to nationalities example. Suppose that wiki bio documents in the pretraining data typically transition between name nationality occupation $ \ldots$ In the prompt, the examples transition between name nationality name nationality $ . . .$ , which contains low-probability transitions such as “German” “Mahatma Gandhi”. The prompt formatting (e.g., choice of delimiter) can also be a source of mismatch. We aim to show that despite this mismatch, large LMs can infer the prompt concept from examples. + +In-context predictor and task. For in-context learning, the output target $y$ for each example $x$ is sampled according to $p _ { \mathrm { p r o m p t } } ( y | x )$ : + +$$ +y _ { \mathrm { t e s t } } \sim p _ { \mathrm { p r o m p t } } ( y | x _ { \mathrm { t e s t } } ) = \mathbb { E } _ { h _ { \mathrm { t e s t } } ^ { \mathrm { s t a r t } } \sim p _ { \mathrm { p r o m p t } } ( h _ { \mathrm { t e s t } } ^ { \mathrm { s t a r t } } | x _ { \mathrm { t e s t } } ) } \left[ p ( y | x _ { \mathrm { t e s t } } , h _ { \mathrm { t e s t } } ^ { \mathrm { s t a r t } } , \theta ^ { \ast } ) \right] . +$$ + +where $h _ { \mathrm { t e s t } } ^ { \mathrm { s t a r t } }$ denotes the hidden state corresponding to the first token of $x _ { \mathrm { t e s t } }$ . We analyze the in-context predictor $\begin{array} { r } { \dot { f } _ { n } ( x _ { \mathrm { t e s t } } ) = \mathrm { a r g m a x } _ { y } p ( y | S _ { n } , x _ { \mathrm { t e s t } } ) } \end{array}$ , which outputs the most likely prediction over the pretraining distribution conditioned on the prompt from the prompt distribution3. We study the in-context predictor and its expected 0-1 error with $n$ examples $\begin{array} { r } { L _ { 0 - 1 } ( f _ { n } ) = \mathbb { E } _ { x _ { \mathrm { t e s t } } , y _ { \mathrm { t e s t } } \sim p _ { \mathrm { p r o m p t } } } [ { \bf 1 } [ f _ { n } ( \bar { x } _ { \mathrm { t e s t } } ) \neq y _ { \mathrm { t e s t } } ] ] } \end{array}$ . + +# 2.1 ASSUMPTIONS + +We detail the assumptions in our framework, including the structure of delimiters and regularity assumptions. We first assume that there exists a subset of delimiter hidden states $\mathcal { D }$ which generates the special delimiter token $o ^ { \mathrm { d e l i m } }$ deterministically. + +Assumption 1 (Delimiter hidden states). Let the delimiter hidden states $\mathcal { D }$ be a subset of $\mathcal { H }$ . For any $h ^ { d e l i m } \in \bar { \mathcal { D } }$ and $\theta \in \Theta$ , $p ( o ^ { d e l i m } | h ^ { d e l i m } , \theta ) = 1$ and for any $h \notin { \mathcal { D } }$ , $p ( o ^ { d e l i m } | h , \theta ) = 0$ . + +Thus, observing the delimiter $o ^ { \mathrm { { d e l i m } } }$ reveals that the corresponding hidden state is in $\mathcal { D }$ , but does not reveal which element of $\mathcal { D }$ it is. The delimiter is usually a token that can appear in a broad range of contexts (e.g., newline). The delimiter ideally does not distract from the examples — for example, an adversarial delimiter could look like part of the input $x$ . To mitigate these scenarios, we assume that no delimiter (e.g., newline) is significantly more likely under one concept rather than another. + +Assumption 2 (Bound on delimiter transitions). For any delimiter state $h ^ { d e l i m } \in \mathcal { D }$ and any hidden state $h \in \mathcal H$ , the probability of transitioning to a delimiter hidden state under $\theta$ is upper bounded $p ( h ^ { d e l i m } | h , \theta ) < c _ { 2 }$ for any $\theta \in \Theta \backslash \left\{ \theta ^ { * } \right\}$ , and is lower bounded $p ( h ^ { d e l i m } | h , \theta ^ { * } ) > c _ { 1 } > 0 _ { \mathcal { J } }$ for $\theta ^ { * }$ . Additionally, the start hidden state distribution for delimiter hidden states is bounded as $p ( h ^ { \tilde { d e } l i m } | \theta ) \in [ c _ { 3 } , c _ { 4 } ]$ . + +The prompt start distribution is a source of distribution shift that is separate from the shift from concatenating independent examples. We make an assumption that limits how much distribution shift is introduced by the prompt start distribution. + +Assumption 3 (Distribution shift from prompt start distribution). We assume that the prompt start distribution pprompt is close in TV distance to all hidden transition distributions (under $\theta ^ { * }$ ) starting from a delimiter hidden state: $\begin{array} { r } { \operatorname* { m a x } _ { h ^ { d e l i m } \in \mathcal { D } } T V ( p _ { p r o m p t } ( h ) \| p ( h | h ^ { d e l i m } , \theta ^ { * } ) ) < \Delta / 4 } \end{array}$ . Here, $\begin{array} { r } { \Delta = p _ { p r o m p t } ( y _ { m a x } | x _ { t e s t } ) - \operatorname* { m a x } _ { y \neq y _ { m a x } } p _ { p r o m p t } ( y | x _ { t e s t } ) } \end{array}$ is the margin between the most likely label $y _ { m a x } = \mathrm { a r g m a x } _ { y } p _ { p r o m p t } ( y | x _ { t e s t } )$ and the second most likely label. + +Even if the maximum TV distance is 0, there is still distribution shift from concatenating independent examples. We also assume the prompt concept $\theta ^ { * }$ is in the family $\Theta$ , a broad set of concepts. + +Assumption 4 (Well-specification). The prompt concept $\theta ^ { * }$ is in $\Theta$ + +Even though the pretraining distribution is broad, the prompt is still low probability under the pretraining distribution since it concatenates independent examples. Finally, if the prompt has zero probability under the prompt concept $\theta ^ { * }$ , then Bayesian inference will not be able to infer the prompt concept as in Section 3.1. The following are regularity assumptions which mainly ensure that the prompt is not zero probability under $\theta ^ { * }$ . + +Assumption 5 (Regularity). The pretraining distribution $p$ satisfies: $^ { l }$ ) Lower bound on transition probability for the prompt concept $\theta ^ { * }$ : for any pair of hidden states $h , h ^ { \prime } \in { \mathcal { H } }$ , $p ( h | h ^ { \prime } , \theta ^ { * } ) > c _ { 5 } > 0$ . 2) Start hidden state is lower bounded: for any $h \in { \mathcal { H } }$ , $p ( h | \theta ^ { * } ) \geq c _ { 8 } > 0 . \ 3 )$ All tokens can be emitted: for every symbol o, there is some hidden state $h \in \mathcal H$ such that $p ( o | h , \theta ^ { * } ) > c _ { 6 } > 0 , .$ 4) The prior $p ( \theta )$ has support over the entire concept family $\Theta$ and is bounded above everywhere. + +# 3 THEORETICAL ANALYSIS + +We prove that in the limit of infinite examples, the error of the in-context predictor is optimal if a distinguishability condition holds — the prompt concept $\theta ^ { * }$ is distinct enough from the other concepts in $\Theta$ (e.g., when $\Theta$ is a discrete set). When distinguishability does not hold (e.g, $\Theta$ is continuous-valued), we show that the expected error still decreases with the length of each example, showing that information in both the inputs and the input-output mapping contribute to in-context learning. + +# 3.1 HIGH-LEVEL APPROACH + +Our goal is to show that a $\mathrm { r g m a x } _ { y } p ( y | S _ { n } , x _ { \mathrm { t e s t } } ) \to \mathrm { a r g m a x } _ { y } p _ { \mathrm { p r o m p t } } ( y | x _ { \mathrm { t e s t } } )$ as the number of examples $n$ grows. In the following, assume that the prompt has non-zero probability under the pretraining distribution $p$ given $\theta ^ { * }$ , meaning that $p ( S _ { n } , x _ { \mathrm { t e s t } } \vert \theta ^ { * } \bar { ) } > 0$ . We expand $p ( y | S _ { n } , x _ { \mathrm { t e s t } } )$ to analyze its limit: + +$$ +\begin{array} { r l } { p ( y | S _ { n } , x _ { \mathrm { t e s t } } ) = \displaystyle \int _ { \theta } p ( y | S _ { n } , x _ { \mathrm { t e s t } } , \theta ) p ( \theta | S _ { n } , x _ { \mathrm { t e s t } } ) d \theta } & { } \\ { \displaystyle } & { \propto \displaystyle \int _ { \theta } p ( y | S _ { n } , x _ { \mathrm { t e s t } } , \theta ) p ( S _ { n } , x _ { \mathrm { t e s t } } | \theta ) p ( \theta ) d \theta \quad \mathrm { ( B a y e s ' ~ r u l e , ~ d r o p ~ t h e ~ c o n s t a n t ~ } \frac { 1 } { p ( S _ { n } , x _ { \mathrm { t e s t } } ) } } \\ { \displaystyle } & { = \displaystyle \int _ { \theta _ { h _ { \mathrm { t e s t } } ^ { \mathrm { s u r t } } \in \mathcal H } } p ( y | x _ { \mathrm { t e s t } } , h _ { \mathrm { t e s t } } ^ { \mathrm { s u r t } } , \theta ) p ( h _ { \mathrm { t e s t } } ^ { \mathrm { s u r t } } | S _ { n } , x _ { \mathrm { t e s t } } , \theta ) \frac { p ( S _ { n } , x _ { \mathrm { t e s t } } | \theta ) } { p ( S _ { n } , x _ { \mathrm { t e s t } } | \theta ^ { * } ) } p ( \theta ) d \theta } \end{array} +$$ + +(Law of total prob, Markov property, divide by $p ( S _ { n } , x _ { \mathrm { t e s t } } | \theta ^ { * } )$ (a constant)) + +$$ += \int _ { \theta } \sum _ { h _ { \mathrm { t e s t } } ^ { \mathrm { s t a r t } } \in \mathcal { H } } p ( y | x _ { \mathrm { t e s t } } , h _ { \mathrm { t e s t } } ^ { \mathrm { s t a r t } } , \theta ) p ( h _ { \mathrm { t e s t } } ^ { \mathrm { s t a r t } } | S _ { n } , x _ { \mathrm { t e s t } } , \theta ) \mathrm { e x p } ( n \cdot r _ { n } ( \theta ) ) p ( \theta ) d \theta +$$ + +where $\begin{array} { r } { r _ { n } ( \theta ) = \frac { 1 } { n } \log \frac { p ( S _ { n } , x _ { \mathrm { t e s t } } | \theta ) } { p ( S _ { n } , x _ { \mathrm { t e s t } } | \theta ^ { * } ) } } \end{array}$ . In Theorem 1, we prove that under a distinguishability condition, $\exp ( n \cdot r _ { n } ( \theta ) ) \to 0$ for all concepts except the prompt concept , where $\exp ( n \cdot r _ { n } ( \theta ^ { * } ) ) = 1$ . The only nonzero term in the integral is when $\theta = \theta ^ { * }$ , and thus the prompt concept is “selected” as a consequence of Bayesian inference4. Lemma 1 shows that the argmax after restricting to $\theta ^ { * }$ is the same as the most likely label under $p _ { \mathrm { p r o m p t } } ( y | x _ { \mathrm { t e s t } } )$ (using Assumption 3). Putting these together with Equation 6, the in-context predictor infers the prompt concept $\theta ^ { * }$ : + +$$ +\underset { y } { \operatorname { a r g m a x } } p ( y | S _ { n } , x _ { \mathrm { t e s t } } ) \to \underset { y } { \operatorname { a r g m a x } } p _ { \mathrm { p r o m p t } } ( y | x _ { \mathrm { t e s t } } ) +$$ + +Thus, the in-context predictor is optimal as the number of in-context examples increases. + +# 3.2 HEURISTIC DERIVATION + +Recall from Section 3.1 that if $\exp ( n \cdot r _ { n } ( \theta ) ) \to 0$ for all $\theta \neq \theta ^ { * }$ , then Bayesian inference “selects” the prompt concept through marginalization. To do this, we focus on showing that $r _ { n } ( \theta )$ , the average log-likelihood ratio between $\theta$ and $\theta ^ { * }$ , converges to a negative constant, and thus $n r _ { n }$ goes to $- \infty$ . + +The main technical challenge is to handle the sequence-of-examples structure of the prompt, which makes all the examples dependent with respect to the pretraining distribution. Our approach uses properties of delimiter tokens to approximately factorize the examples, with constant error per example. We let $O _ { i } ^ { \mathrm { e x } } = \left[ o _ { i - 1 } ^ { \mathrm { d e l i m } } , O _ { i } \right]$ be the $i$ -th input-output pair and the previous delimiter together for $i > 1$ and define $O _ { 1 } ^ { \mathrm { e x } } { = } O _ { 1 }$ . Expanding the likelihood term inside $r _ { n } ( \theta )$ , our goal is to show + +$$ +p ( S _ { n } , x _ { \mathrm { t e s t } } | \theta ) { = } p ( x _ { \mathrm { t e s t } } | S _ { n } , \theta ) p ( S _ { n } | \theta ) { \approx } \prod _ { i = 1 } ^ { n } O ( 1 ) p ( O _ { i } | \theta ) +$$ + +To show this, we expand $p ( S _ { n } | \theta )$ with the chain rule, and with Assumption 5 (to bound $p ( x _ { \mathrm { t e s t } } | S _ { n } , \theta )$ by $O ( 1 ) _ { . }$ ) it can be shown that + +$$ +p ( x _ { \mathrm { t e s t } } | S _ { n } , \theta ) p ( S _ { n } | \theta ) \approx \prod _ { i = 1 } ^ { n } O ( 1 ) p ( O _ { i } ^ { \mathrm { e x } } | O _ { 1 : i - 1 } ^ { \mathrm { e x } } , \theta ) . +$$ + +We then marginalize $p ( O _ { i } ^ { \mathrm { e x } } | O _ { 1 : i - 1 } ^ { \mathrm { e x } } , \theta )$ over the hidden state $h _ { i - 1 } ^ { \mathrm { d e l i m } }$ corresponding to the delimiter in $O _ { i } ^ { \mathrm { e x } } = \left[ o _ { i - 1 } ^ { \mathrm { d e l i m } } , O _ { i } \right]$ : + +$$ +\prod _ { i = 1 } ^ { n } O ( 1 ) p ( O _ { i } ^ { \mathrm { e x } } | O _ { 1 : i - 1 } ^ { \mathrm { e x } } , \theta ) = \prod _ { i = 1 } ^ { n } O ( 1 ) \sum _ { h _ { i - 1 } ^ { \mathrm { d i m } } \in D } p ( O _ { i } | h _ { i - 1 } ^ { \mathrm { d e f i m } } , \theta ) p ( h _ { i - 1 } ^ { \mathrm { d e f i m } } | O _ { 1 : i - 1 } ^ { \mathrm { e x } } , \theta ) \approx \prod _ { i = 1 } ^ { n } O ( 1 ) p ( O _ { i } | \theta ) +$$ + +While summing over $\mathcal { H }$ above would be a trivial equality, we can replace $\mathcal { H }$ with the set of delimiter hidden states $\mathcal { D }$ since $p ( h | O _ { 1 : i - 1 } ^ { \mathrm { e x } } , \theta ) = 0$ for non-delimiter hidden states $h \notin \mathcal { D }$ (Assumption 1). We used in the first equality that $O _ { 1 : i - 1 } ^ { \mathrm { e x } } \to h _ { i - 1 } ^ { \mathrm { d e l i m } } \to O _ { i } ^ { \mathrm { e x } }$ forms a Markov chain and $p ( o _ { i - 1 } ^ { \mathrm { d e l i m } } | h _ { i - 1 } ^ { \mathrm { d e l i m } } ) = 1$ (Assumption 1) to change $O _ { i } ^ { \mathrm { e x } }$ to $O _ { i }$ . Finally, we can show using properties of delimiter hidden states (Assumption 2) that $p ( h _ { i - 1 } ^ { \mathrm { d e l i m } } | O _ { 1 : i - 1 } ^ { \mathrm { e x } } , \theta ) = O ( 1 )$ and $\begin{array} { r } { \sum _ { h _ { i - 1 } ^ { \mathrm { d e l i m } } \in { \cal D } } p ( O _ { i } | h _ { i - 1 } ^ { \mathrm { d e l i m } } , \theta ) \approx O ( 1 ) p ( O _ { i } | \theta ) } \end{array}$ in the second step. Therefore, we can upper bound $r _ { n } ( \theta )$ as + +$$ +r _ { n } ( \theta ) \leq \frac { 1 } { n } \left( O ( n ) + \sum _ { i = 1 } ^ { n } \log \frac { p ( O _ { i } | \theta ) } { p ( O _ { i } | \theta ^ { * } ) } \right) \to O ( 1 ) + \mathbb { E } _ { O \sim p _ { \mathrm { p r o m p t } } } \left[ \log \frac { p ( O | \theta ) } { p ( O | \theta ^ { * } ) } \right] . +$$ + +The expectation term can be written as the difference of two KL divergences, $K L ( p _ { \mathrm { p r o m p t } } ( O ) \| p ( O | \theta ^ { * } ) ) - K L ( p _ { \mathrm { p r o m p t } } ( O ) \| p ( O | \theta ) )$ . We bound the first KL term by a constant using Assumption 5 — intuitively for one example, $p _ { \mathrm { p r o m p t } }$ and $p ( \cdot | \theta ^ { * } )$ are close. We break the second term into a sum of negative KL divergences over $k$ tokens. There are $O ( k )$ KL terms and only $O ( 1 )$ other error terms, which come from the distribution mismatch between the prompt and pretraining distributions. If the KL terms are larger than the error terms, then $r _ { n } ( \theta )$ has a negative limit. If this holds for all $\theta \neq \theta ^ { * }$ , then we have $\exp ( n \cdot r _ { n } ( \theta ) ) \to 0$ for all $\theta \neq \theta ^ { * }$ , enabling in-context learning. + +# 3.3 FORMAL RESULTS + +# 3.3.1 IN-CONTEXT LEARNING UNDER DISTINGUISHABILITY + +We define a distinguishability condition which formalizes when in-context learning occurs. Letting $p _ { \theta } ^ { j } ( o ) : = p ( O [ j ] = o | O [ 1 : j - 1 ] , \theta )$ be the output distribution of the $j$ -th token given the previous tokens and $p _ { \mathrm { p r o m p t } } ^ { j } ( o ) : = p _ { \mathrm { p r o m p t } } ( O [ j ] = o | O [ 1 : j - 1 ] )$ be the analogous distribution under the prompt + +![](images/269ff6dcd4b15f03fee40435180d835df83d447f8fe8dee4ae95ad91bd5e7ffe.jpg) +Figure 2: When the signal about the prompt concept within each example (green) is greater than the error from low-probability transitions between examples, in-context learning succeeds in our latent concept setting (Theorem 1). Increasing the example length $k$ increases the signal. The signal for in-context learning comes from tokens in both the inputs and the input-output mapping. + +distribution, the distinguishability condition depends on the KL divergence between $p _ { \mathrm { p r o m p t } } ^ { j }$ (which represents $\theta ^ { * }$ ) and $p _ { \theta } ^ { j }$ as well as error terms $\epsilon _ { \mathrm { s t a r t } } ^ { \theta }$ and $\epsilon _ { \mathrm { d e l i m } } ^ { \theta }$ coming from the distribution mismatch between the prompt and pretraining distributions at the start and delimiter token for each example: + +$$ +\begin{array} { r l } & { K L _ { j } ( \theta ^ { * } \| \theta ) : = \mathbb { E } _ { \cal O [ 1 : j - 1 ] \sim p _ { \mathrm { p r o m p t } } } [ K L ( p _ { \mathrm { p r o m p t } } ^ { j } \| p _ { \theta } ^ { j } ) ] } \\ & { \epsilon _ { \mathrm { d e l i m } } ^ { \theta } : = 2 ( \log ( c _ { 2 } ) - \log ( c _ { 1 } ) ) + \log ( c _ { 4 } ) - \log ( c _ { 3 } ) , \quad \epsilon _ { \mathrm { s t a r t } } ^ { \theta } : = \log ( 1 / c _ { 8 } ) . } \end{array} +$$ + +Condition 1 (Distinguishability). We define $\theta ^ { * }$ to be distinguishable if for all $\theta \in \Theta , \theta \neq \theta ^ { * }$ , + +$$ +\sum _ { j = 2 } ^ { k } K L _ { j } ( \theta ^ { * } \| \theta ) > \epsilon _ { s t a r t } ^ { \theta } + \epsilon _ { d e l i m } ^ { \theta } . +$$ + +When the signal from KL divergence (LHS) is larger than the error terms, Equation 14 is satisfied (Figure 2). For larger example lengths $k$ , the LHS increases, improving distinguishability. Intuitively, larger example lengths increase the proportion of the prompt sampled from the pretraining distribution by providing more evidence for Bayesian inference. Under Condition 1, the in-context predictor asymptotically achieves the optimal expected error. + +Theorem 1. Assume the assumptions in Section 2.1 hold. If Condition 1 holds, then as $n \to \infty$ the prediction according to the pretraining distribution is + +$$ +\underset { y } { \operatorname { a r g m a x } } p ( y | S _ { n } , x _ { t e s t } ) \underset { y } { \operatorname { a r g m a x } } p _ { p r o m p t } ( y | x _ { t e s t } ) . +$$ + +Thus, the in-context predictor $f _ { n }$ achieves the optimal 0-1 risk: $\begin{array} { r } { \operatorname* { l i m } _ { n \to \infty } L _ { O - I } ( f _ { n } ) = \operatorname* { i n f } _ { f } L _ { O - I } ( f ) } \end{array}$ + +# 3.3.2 NON-DISTINGUISHABLE CASE + +The distinguishability condition (Condition 1) fails when there is some $\theta \neq \theta ^ { * }$ for which the KL divergence between $\theta$ and $\theta ^ { * }$ is less than the error terms. However, this also means that the output distributions of $\theta$ and $\theta ^ { * }$ are close in KL. We leverage this to prove that the expected 0-1 error decreases with the example length $k$ under two different settings where distinguishability does not hold. + +Continuity. Our first result relies on a continuity assumption between the concept parameter and its corresponding output distribution. Our assumption is based on prior works (Kleijn $\&$ van der Vaart, 2012), where the KL divergence is assumed to have a 2nd-order Taylor expansion. + +Theorem 2. Let the set of $\theta$ which does not satisfy Equation $^ { I 4 }$ in Condition $I$ to be $\boldsymbol { B }$ . Assume that KL divergences have a 2nd-order Taylor expansion around $\theta ^ { * }$ : + +$$ +\forall j > 1 , K L _ { j } ( \theta ^ { * } \| \theta ) = \frac { 1 } { 2 } ( \theta - \theta ^ { * } ) ^ { \top } I _ { j , \theta ^ { * } } ( \theta - \theta ^ { * } ) + O ( \| \theta - \theta ^ { * } \| ^ { 3 } ) +$$ + +where $I _ { j , \theta ^ { * } }$ is the Fisher information matrix of the $j$ -th token distribution with respect to $\theta ^ { * }$ . Let $\gamma _ { \theta ^ { * } } = \frac { \operatorname* { m a x } _ { j } \lambda _ { m a x } ( I _ { j , \theta ^ { * } } ) } { \operatorname* { m i n } j \lambda _ { m i n } ( I _ { j , \theta ^ { * } } ) }$ where $\lambda _ { m a x } , \lambda _ { m i n }$ return the largest and smallest eigenvalues. Then for $k > 1$ and as $n \to \infty$ , the 0-1 risk of the in-context learning predictor $f _ { n }$ is bounded as + +$$ +\operatorname* { l i m } _ { n \to \infty } L _ { O - I } ( f _ { n } ) \mathop { \le } \operatorname* { i n f } _ { f } L _ { O - I } ( f ) + g ^ { - 1 } \left( O \left( \frac { \gamma _ { \theta ^ { * } } \operatorname* { s u p } _ { \theta \in \mathcal { B } } ( \epsilon _ { s t a r t } ^ { \theta } + \epsilon _ { d e l i m } ^ { \theta } ) } { k - 1 } \right) \right) +$$ + +where $g ( \delta ) = \textstyle { \frac { 1 } { 2 } } { \big ( } ( 1 - \delta ) \log ( 1 - \delta ) + ( 1 + \delta ) \log ( 1 + \delta ) { \big ) }$ is a calibration function (Steinwart, 2007; Avila ´ Pires & Szepesvari, 2016) for the multiclass logistic loss for ´ $\delta \in [ 0 , 1 )$ . + +![](images/285122a99765b89a4928b3742f27d6d83500154a506454675a5316275817cc40.jpg) +Figure 3: In-context accuracy $9 5 \%$ intervals) of Transformers (left) and LSTMs (right) on the GINC dataset. Accuracy increases with number of examples $n$ and length of each example $k$ . + +![](images/c909c4d27a03648d4129694ca4e5ae1e71a17f8d19f5f3f3db3f1a392c8f2d9f.jpg) + +![](images/0e267f4694aecf98a8e50c19dc6bc8c46c458d5d97c08199c8805b7dd27d63e6.jpg) +Figure 4: Ablation studies for 4 layer Transformers on the GINC dataset with vocab size 50. (Left) When pretrained with only one concept, in-context learning fails. (Middle) When the pretraining data has random transitions, the model sees all token transitions but in-context learning fails. (Right) When prompts are from random unseen concepts, in-context learning fails to extrapolate. + +Since the inverse calibration function $g ^ { - 1 }$ is roughly linear in $\epsilon$ for $\epsilon \leq 0 . 7$ , the excess risk roughly decreases as $O ( 1 / k )$ . When the “worst-case condition number” $\gamma _ { \theta ^ { * } }$ of the Fisher information matrices is smaller (well-conditioned), the error decreases. Intuitively, this means that there is no direction to vary $\theta ^ { * }$ in which the output distribution will sharply change. As a consequence, the concepts $\theta$ that are not distinguishable from the prompt concept $\theta ^ { * }$ parameterize distributions that produce similar outputs to the prompt concept and thus achieve a small error. + +Varying-length test examples. In the setting where the length of $x _ { \mathrm { t e s t } }$ is random (uniformly from 2 to $k$ ), we can give a similar error guarantee without continuity. + +Theorem 3. Let the set of $\theta$ which does not satisfy Equation $^ { I 4 }$ in Condition $I$ to be $B$ . Let the length of the test example $x _ { t e s t }$ be uniformly distributed between 2 and $k$ , for $k \geq 2$ . Then for $k \geq 2$ and as $n \to \infty$ , the $O - I$ risk of the in-context learning predictor $f _ { n }$ is bounded as + +$$ +\operatorname* { l i m } _ { n \to \infty } L _ { O - I } ( f _ { n } ) \leq \operatorname* { i n f } _ { f } L _ { O - I } ( f ) + g ^ { - 1 } \biggl ( O \biggl ( \frac { \operatorname* { s u p } _ { \theta \in \mathcal { B } } ( \epsilon _ { s t a r t } ^ { \theta } + \epsilon _ { d e l i m } ^ { \theta } ) } { k - 1 } \biggr ) \biggr ) . +$$ + +Instead of measuring only the error at the $k$ -th token, we average the prediction error on the 2nd to $k$ -th tokens. However, we leave bridging the mismatch between training examples, which are consistently length $k$ , and test examples, which have random length, to future work. + +# 4 SIMULATIONS + +We generate the GINC dataset and show that Transformers (Vaswani et al., 2017) and LSTMs (Hochreiter & Schmidhuber, 1997) trained on GINC exhibit in-context learning. In the theory, we assumed that the pretrained LM fits the pretraining distribution exactly. Here, we pretrain LMs to approximate the pretraining distribution and find that the in-context learning properties transfer to the LM. + +GINC dataset. We construct the GINC dataset according to our theory (see Appendix F.1). For pretraining, we define a uniform mixture of HMMs over a family $\Theta$ of 5 concepts to generate 1000 pretraining documents with ${ \sim } 1 0$ million tokens total. For prompting, we generate prompts with 0 to 64 training examples and example lengths $k \in \{ 3 , 5 , 8 , 1 0 \}$ (2500 prompts for each setting). The target token $y _ { \mathrm { t e s t } }$ is taken to be the most likely output instead of sampling so that the intrinsic error is 0. + +Main result. We train GPT-2-based Transformers (Radford et al., 2019) and LSTMs on three versions of the GINC dataset with vocabulary sizes 50, 100, and 150, then evaluate the in-context accuracy (see Appendix F.2, F.3). We average all results over 5 pretraining runs. Figure 3 shows that for both Transformer and LSTMs, in-context accuracy improves as the number of prompt examples $n$ and the example length $k$ increase, verifying our theory. + +![](images/988828c94f04a215090813594df314946cb1c63030bbb349694684a910952807.jpg) +Figure 5: In-context accuracy $9 5 \%$ intervals) of Transformers improves as model size increases on the GINC dataset for vocabulary sizes 50, 100, and 150. + +Figure 6: In-context accuracies $9 5 \%$ intervals) on GINC with vocab sizes (50, 100, 150) for Transformers and LSTMs. Accuracy improves with scale even though the pretraining loss may be the same. + +
Model# ParamsTrain loss (pretraining)Val loss (pretraining)In-context Acc
Vocab size 50, k =10,n =64
Transformer (4 layer)29M1.491.5060.2 ± 5.7
Transformer(12 layer)85M1.311.3381.2 ± 7.1
Transformer (16 layer)115M1.311.3384.7 ± 3.4
LSTM28M1.311.3595.8 ± 1.11
Vocab size 100, k = 10,n =64
Transformer (4 layer)29M1.581.5967.4 ± 4.7
Transformer(12 layer)85M1.401.4284.6 ± 3.0
Transformer (16 layer)115M1.411.4388.7 ± 1.6
LSTM28M1.431.4495.8 ± 1.54
Vocab size 150, k = 10,n =64
Transformer (4 layer)29M1.441.4592.8 ± 1.9
Transformer (12 layer)85M1.271.2898.4 ±0.4
Transformer (16 layer)115M1.271.2898.1 ± 0.5
LSTM28M1.261.3199.2 ± 1.06
+ +Ablations on the latent concept structure. We ablate the role of the mixture-of-concepts structure in GINC. In Figure 4 (left), we pretrain a 4 layer Transformer on data with only one concept (removing the prior) from $\Theta$ , resulting in flat in-context learning curves. Figure 4 (middle) shows that pretraining on random pretraining data, which contains all possible token transitions, in-context learning also fails. Therefore, the mixture-of-concepts structure is important and simply seeing diverse token transitions does not enable in-context learning. + +Extrapolation to unseen concepts. Full generative control of GINC allows for experimentation with latent variables in the pretraining distribution. For example, in large-scale datasets, it is difficult to test whether a concept or task is in the pretraining data. We test this in GINC by testing the in-context accuracy of a 4 layer Transformer on prompts generated from 5 random concepts that are not in the pretraining family of concepts. Figure 4 (right) shows that in-context learning also fails for these novel concepts. + +Effect of model size and architecture. Figure 5 shows that increasing the size of the Transformer (4, 12, 16 layers) steadily increases the in-context accuracy, corroborating the results of Brown et al. (2020). Table 6 shows that even though larger Transformers may have the same pretraining loss (e.g., 12 and 16 layer Transformers both get 1.33 validation loss for vocab size 50), the in-context accuracy still improves ( $81 \%$ to $85 \%$ from 12 to 16 layers), suggesting that larger models can improve in-context learning beyond improving pretraining perplexity. This may be related to phenomena from overparameterization and overtraining (Zhang et al., 2017; Power et al., 2021). Finally, the model architecture also plays a role — LSTMs consistently outperform Transformers on GINC despite having fewer parameters, perhaps due to the similarity between HMMs and LSTMs. We leave analysis of the effect of model scaling and model architecture as open questions. + +Sensitivity to example ordering. In Figure 7 (left), we test the sensitivity of in-context accuracy on GINC to the ordering of the prompt examples, following Zhao et al. (2021). For this experiment, we consider prompts generated from a single concept and prompt start distribution. We sample 10 different sets (leading to 10 training set IDs) of 4 examples and generate all 24 possible permutations for each example set. We consider the in-context accuracy of the 4 layer Transformer trained on GINC with vocabulary size 50. Similarly to the behavior of GPT-3 (Zhao et al., 2021), there is a significant variation ( $1 0 \%$ difference) between permutations of the same set of examples. + +Zero-shot is sometimes better than few-shot. In some settings in GINC, we find that zero-shot performance can be better than few-shot performance. This mirrors GPT-3 on some datasets (e.g., LAMBADA, HellaSwag, PhysicalQA, RACE-m, CoQA/SAT analogies for smaller models (Brown et al., 2020)). This occurs especially when the transition probabilities in GINC are lower entropy (controlled via a temperature parameter). For this experiment, we consider GINC with transition matrix temperature parameter 0.01 (instead of 0.1), 12 concepts, and vocabulary size 100. Figure 7 (right) shows that here, few-shot accuracy is initially worse than zero-shot accuracy, but can recover with more examples. We hypothesize that the distracting prompt structure initially decreases the accuracy in this setting. + +![](images/4ae9e5fff011f1c06e039a6339fa2dc8f7bcfa7dbb78c28625cec5e2ab174ada.jpg) + +![](images/e50a958a91385dd44650bdb0885d424f49c2aa234554121adc0ef52dfada5b8c.jpg) +Figure 7: (Left) In-context accuracy varies widely with example ordering. Each training ID refers to a set of training examples. Each dot refers to the in-context learning accuracy of one permutation of the training examples for that particular training ID. (Right) Zero-shot performance can be higher than one/few-shot performance in some settings in GINC, mirroring the behavior of GPT-3 on some datasets such as LAMBADA (Brown et al., 2020). The few-shot setting introduces the distracting prompt structure, which can initially lower accuracy. + +# 5 DISCUSSION AND RELATED WORK + +Learning via Bayesian inference and extrapolation. The canonical Bernstein-von Mises theorem (van der Vaart, 1998) does not apply for in-context learning since the prompt examples are not independent under the pretraining distribution. Gunst & Shcherbakova (2008) show a Bernstein-von Mises-type result for observations from an HMM, but do not handle observations from a different distribution. Future directions include more precise asymptotic results about the posterior distribution and results under misspecification/extrapolation (Kleijn & van der Vaart, 2012). A possible avenue for extrapolation to some types of unseen concepts is to factorize the latent concept into semantics and syntax. While the pretraining data may contain only some semantics-syntax pairs, the language model could generalize to unseen pairs if it learns generalizable syntactical operations such as copying or reordering. + +Topic models and HMMs. Topic models such as LDA (Blei et al., 2003) also have document-level latent variables, but learning is typically relies on algorithms such as EM (Dempster et al., 1977), variational inference (Jordan et al., 1999), or MCMC (Metropolis et al., 1953; Hastings, 1970). We focus on learning as a natural result of Bayesian inference without an explicit inference algorithm. Wei et al. (2021a) also use an HMM model in their pretraining analysis. However, they analyze how pre-trained representations learned with masked LMs (Devlin et al., 2019; Liu et al., 2019; Lewis et al., 2020; Clark et al., 2020) can improve optimization-based downstream learning (Li & Liang, 2021; Lester et al., 2021) rather than in-context learning. + +Bridging the mismatch between pretraining and prompting. Prior works support our theoretical intuitions that reducing the prompt distribution mismatch would improve in-context learning. Finetuning LMs on text with a prompting format improves its zero-shot performance (Wei et al., 2021b; Sanh et al., 2021) and optimizing prompt templates improves few-shot finetuning (Jiang et al., 2020; Schick & Schutze, 2021; Shin et al., 2020; Gao et al., 2021). Zhao et al. (2021); Holtzman et al. (2021) improve ¨ in-context accuracy via calibration or renormalization, a form of adaptation to the prompt distribution. + +Meta-learning. Meta-learning methods can also train a sequence model to learn from examples (Ravi & Larochelle, 2017). However, meta-learning models are trained to learn, while in-context learning emerges from LM pretraining. + +Studying large-scale phenomena at a small scale. We can study in-context learning, a large scale phenomenon, at a small scale in GINC because the complexity of the pretraining distribution (HMM hidden state size, number of latent concepts) is small, such that the data and models are relatively larger. Since GINC is synthetic, we can also control the latent data properties (e.g., unseen concepts) to make predictions about large LMs while working at a small scale. + +# 6 CONCLUSION + +We cast in-context learning as implicit Bayesian inference, where the pretrained LM implicitly infers a concept when making a prediction. We show that in-context learning occurs when the pre-training distribution is a mixture of HMMs. Our work provides a first step towards understanding in-context learning, which we hope will provide insight for improving pretraining and prompting. + +# ACKNOWLEDGEMENTS + +We thank Tianyi Zhang, Frieda Rong, Lisa Li, Colin Wei, Shibani Santurkar, Tri Dao, Ananya Kumar, and Shivam Garg for helpful discussions and feedback. SMX is supported by an NDSEG Fellowship. The work is partially supported by an Open Philanthropy Project Award, SDSI, and SAIL at Stanford University. TM acknowledges support of Google Faculty Award, NSF IIS 2045685, the Sloan Fellowship, and JD.com. Toyota Research Institute provided funds to support this work. + +# REFERENCES + +Leonard E Baum and Ted Petrie. Statistical inference for probabilistic functions of finite state markov chains. The annals of mathematical statistics, 37(6):1554–1563, 1966. + +D. Blei, Andrew Ng, and M. I. Jordan. Latent Dirichlet allocation. Journal of Machine Learning Research (JMLR), 3:993–1022, 2003. + +Tom B. Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah, Jared Kaplan, Prafulla Dhariwal, Arvind Neelakantan, Pranav Shyam, Girish Sastry, Amanda Askell, Sandhini Agarwal, Ariel Herbert-Voss, Gretchen Krueger, Tom Henighan, Rewon Child, Aditya Ramesh, Daniel M. Ziegler, Jeffrey Wu, Clemens Winter, Christopher Hesse, Mark Chen, Eric Sigler, Mateusz Litwin, Scott Gray, Benjamin Chess, Jack Clark, Christopher Berner, Sam McCandlish, Alec Radford, Ilya Sutskever, and Dario Amodei. Language models are few-shot learners. arXiv preprint arXiv:2005.14165, 2020. + +Kevin Clark, Minh-Thang Luong, Quoc V. Le, and Christopher D. Manning. Electra: Pre-training text encoders as discriminators rather than generators. In International Conference on Learning Representations (ICLR), 2020. + +A. P. Dempster, Laird N. M., and Rubin D. B. Maximum likelihood from incomplete data via the EM algorithm. Journal of the Royal Statistical Society: Series B, 39(1):1–38, 1977. + +Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. BERT: Pre-training of deep bidirectional transformers for language understanding. In Association for Computational Linguistics (ACL), pp. 4171–4186, 2019. + +Tianyu Gao, Adam Fisch, and Danqi Chen. Making pre-trained language models better few-shot learners. arXiv, 2021. + +Zoubin Ghahramani and Michael Jordan. Factorial hidden Markov models. Machine Learning, 29: 245–273, 1997. + +Amit Gruber, Yair Weiss, and Michal Rosen-Zvi. Hidden topic Markov models. In Artificial Intelligence and Statistics (AISTATS), 2007. + +M. Gunst and O. Shcherbakova. Asymptotic behavior of Bayes estimators for hidden Markov models with application to ion channels. Mathematical Methods of Statistics, 17, 2008. + +Keith W. Hastings. Monte Carlo sampling methods using Markov chains and their applications. Biometrika, 57(1):97–109, 1970. + +Sepp Hochreiter and Jurgen Schmidhuber. Long short-term memory. ¨ Neural Computation, 9(8): 1735–1780, 1997. + +Ari Holtzman, Jan Buys, Li Du, Maxwell Forbes, and Yejin Choi. The curious case of neural text degeneration. In International Conference on Learning Representations (ICLR), 2020. + +Ari Holtzman, Peter West, Vered Shwartz, Yejin Choi, and Luke Zettlemoyer. Surface form competition: Why the highest probability answer isn’t always right, 2021. + +Zhengbao Jiang, Frank F Xu, Jun Araki, and Graham Neubig. How can we know what language models know? In Association for Computational Linguistics (ACL), 2020. + +Michael I. Jordan, Zoubin Ghahramani, Tommi S. Jaakkola, and Lawrence K. Saul. An introduction to variational methods for graphical models. Machine Learning, 37:183–233, 1999. + +Mandar Joshi, Eunsol Choi, Daniel Weld, and Luke Zettlemoyer. TriviaQA: A large scale distantly supervised challenge dataset for reading comprehension. In Association for Computational Linguistics (ACL), 2017. + +Diederik Kingma and Jimmy Ba. Adam: A method for stochastic optimization. In International Conference on Learning Representations (ICLR), 2015. + +B.J.K. Kleijn and A.W. van der Vaart. The Bernstein-von mises theorem under misspecification. Electronic Journal of Statistics, 6, 2012. + +Brian Lester, Rami Al-Rfou, and Noah Constant. The power of scale for parameter-efficient prompt tuning. arXiv preprint arXiv:2104.08691, 2021. + +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. In Association for Computational Linguistics (ACL), 2020. + +Xiang Lisa Li and Percy Liang. Prefix-tuning: Optimizing continuous prompts for generation. In Association for Computational Linguistics (ACL), 2021. + +Opher Lieber, Or Sharir, Barak Lenz, and Yoav Shoham. Jurassic-1: Technical details and evaluation. Technical report, AI21 Labs, August 2021. + +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. + +Ilya Loshchilov and Frank Hutter. Decoupled weight decay regularization. In International Conference on Learning Representations (ICLR), 2019. + +Nicholas Metropolis, Arianna W. Rosenbluth, Marshall N. Rosenbluth, Augusta H. Teller, and Edward Teller. Equation of state calculations by fast computing machines. The journal of chemical physics, 21(6):1087–1092, 1953. + +Denis Paperno, German Kruszewski, Angeliki Lazaridou, Quan Ngoc Pham, Raffaella Bernardi, Sandro Pezzelle, Marco Baroni, Gemma Boleda, and Raquel Fernandez. The LAMBADA dataset: Word prediction requiring a broad discourse context. In Association for Computational Linguistics (ACL), 2016. + +Alethea Power, Yuri Burda, Harri Edwards, Igor Babuschkin, and Vedant Misra. Grokking: Generalization beyond overfitting on small algorithmic datasets. In ICLR MATH AI Workshop, 2021. + +Alec Radford, Jeffrey Wu, Rewon Child, David Luan, Dario Amodei, and Ilya Sutskever. Language models are unsupervised multitask learners. OpenAI Blog, 1(8), 2019. + +Sachin Ravi and Hugo Larochelle. Optimization as a model for few-shot learning. In International Conference on Learning Representations (ICLR), 2017. + +Victor Sanh, Albert Webson, Colin Raffel, Stephen H. Bach, Lintang Sutawika, Zaid Alyafeai, Antoine Chaffin, Arnaud Stiegler, Teven Le Scao, Arun Raja, Manan Dey, M Saiful Bari, Canwen Xu, Urmish Thakker, Shanya Sharma Sharma, Eliza Szczechla, Taewoon Kim, Gunjan Chhablani, Nihal Nayak, Debajyoti Datta, Jonathan Chang, Mike Tian-Jian Jiang, Han Wang, Matteo Manica, Sheng Shen, Zheng Xin Yong, Harshit Pandey, Rachel Bawden, Thomas Wang, Trishala Neeraj, Jos Rozen, Abheesht Sharma, Andrea Santilli, Thibault Fevry, Jason Alan Fries, Ryan Teehan, Stella Biderman, Leo Gao, Tali Bers, Thomas Wolf, and Alexander M. Rush. Multitask prompted training enables zero-shot task generalization, 2021. + +Timo Schick and Hinrich Schutze. Exploiting cloze questions for few shot text classification and ¨ natural language inference. In European Association for Computational Linguistics (EACL), 2021. + +Taylor Shin, Yasaman Razeghi, Robert L Logan IV, Eric Wallace, and Sameer Singh. Eliciting knowledge from language models using automatically generated prompts. In Empirical Methods in Natural Language Processing (EMNLP), 2020. + +Ingo Steinwart. How to compare different loss functions and their risks. Constructive Approximation, 26, 2007. +A. W. van der Vaart. Asymptotic statistics. Cambridge University Press, 1998. +Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Lukasz Kaiser, and Illia Polosukhin. Attention is all you need. arXiv preprint arXiv:1706.03762, 2017. +Ben Wang and Aran Komatsuzaki. GPT-J-6B: A 6 Billion Parameter Autoregressive Language Model. https://github.com/kingoflolz/mesh-transformer-jax, May 2021. +Colin Wei, Sang Michael Xie, and Tengyu Ma. Why do pretrained language models help in downstream tasks? an analysis of head and prompt tuning. arXiv, 2021a. +Jason Wei, Maarten Bosma, Vincent Y. Zhao, Kelvin Guu, Adams Wei Yu, Brian Lester, Nan Du, Andrew M. Dai, and Quoc V. Le. Finetuned language models are zero-shot learners. arXiv, 2021b. +Thomas Wolf, Lysandre Debut, Victor Sanh, Julien Chaumond, Clement Delangue, Anthony Moi, Pierric Cistac, Tim Rault, R’emi Louf, Morgan Funtowicz, and Jamie Brew. HuggingFace’s transformers: State-of-the-art natural language processing. arXiv preprint arXiv:1910.03771, 2019. +Chiyuan Zhang, Samy Bengio, Moritz Hardt, Benjamin Recht, and Oriol Vinyals. Understanding deep learning requires rethinking generalization. In International Conference on Learning Representations (ICLR), 2017. +Tony Z. Zhao, Eric Wallace, Shi Feng, Dan Klein, and Sameer Singh. Calibrate before use: Improving few-shot performance of language models. In International Conference on Machine Learning (ICML), 2021. +Bernardo Avila Pires and Csaba Szepesv ´ ari. Multiclass classification calibration functions. ´ arXiv, 2016. + +# A FRAMEWORK DETAILS + +Prompt distribution details. For in-context learning, we sample a prompt from a new distribution $p _ { \mathrm { p r o m p t } }$ , which consists of $n$ independent training examples and 1 test example. We first sample $n$ hidden segments $H$ of length $k$ by sampling the first element $h ^ { \mathrm { s t a r t } } = H [ 1 ]$ from a prompt start distribution pprompt . Then, we sample the rest of the segment $H ^ { \mathrm { s e g } } = H [ 2 : k ]$ from the hidden transition distribution of the pretraining distribution $p$ corresponding to a particular concept $\theta ^ { * }$ : + +$$ +\begin{array} { r l } { H _ { 1 } , . . . , H _ { n } , } & { H _ { i } = [ h _ { i , 1 } , . . . , h _ { i , k } ] } \\ { h _ { i } ^ { \mathrm { s t a r t } } = H _ { i } [ 1 ] \sim p _ { \mathrm { p r o m p t } } , } & { H _ { i } ^ { \mathrm { s e g } } = H _ { i } [ 2 : k ] \sim p ( H _ { i } ^ { \mathrm { s e g } } | { h ^ { \mathrm { s t a r t } } } , \theta ^ { * } ) . } \end{array} +$$ + +$n$ $h ^ { \mathrm { d e l i m } } \in \mathcal { D }$ $p _ { \mathrm { p r o m p t } } ^ { \mathrm { d e l i m } }$ + +$$ +h _ { 1 } ^ { \mathrm { d e l i m } } , . . . , h _ { n } ^ { \mathrm { d e l i m } } , \quad h _ { i } ^ { \mathrm { d e l i m } } \sim p _ { \mathrm { p r o m p t } } ^ { \mathrm { d e l i m } } . +$$ + +Conditioned on hidden variables $H _ { i }$ and $h _ { i } ^ { \mathrm { d e l i m } }$ , we sample the observed tokens $O _ { i } = [ o _ { i , 1 } , . . . , o _ { i , k } ]$ and $o _ { i } ^ { \mathrm { d e l i m } }$ irespectively from the pre-training distribution: + +$$ +O _ { 1 } , . . . , O _ { n } , \quad O _ { i } { \sim } p ( O _ { i } | H _ { i } ) +$$ + +$$ +o _ { 1 } ^ { \mathrm { d e l i m } } , . . . , o _ { n } ^ { \mathrm { d e l i m } } , \quad o _ { i } ^ { \mathrm { d e l i m } } \sim p ( o _ { i } ^ { \mathrm { d e l i m } } | h _ { i } ^ { \mathrm { d e l i m } } , \theta ^ { * } ) +$$ + +The “input” for each example is $x _ { i } = O _ { i } [ 1 : k - 1 ]$ and the “output” is $y _ { i } = O _ { i } [ k ]$ . Taking $S$ to be the sequence of training examples (without the test example), the resulting prompt sequence is + +$$ +\left[ S _ { n } , x _ { \mathsf { t e s t } } \right] = [ O _ { 1 } , o _ { 1 } ^ { \mathsf { d e l i m } } , . . . , O _ { n } , o _ { n } ^ { \mathsf { d e l i m } } , x _ { \mathsf { t e s t } } ] = [ x _ { 1 } , y _ { 1 } , o _ { 1 } ^ { \mathsf { d e l i m } } , x _ { 2 } , y _ { 2 } , o _ { 2 } ^ { \mathsf { d e l i m } } , . . . , x _ { n } , y _ { n } , o _ { n } ^ { \mathsf { d e l i m } } , x _ { \mathsf { t e s t } } ] \sim p _ { \mathsf { p r o m p t } } +$$ + +where $x _ { \mathrm { { t e s t } } } = x _ { n + 1 } = O _ { n + 1 } [ 1 : k - 1 ]$ is sampled via the same process but with $k - 1$ elements. + +# B PROPOSITIONS FOR THEOREM 1 + +The following propositions, which lower bound the probability of a delimiter token and probability of an example under $\theta ^ { * }$ , are direct corollaries of the assumptions. + +Proposition 1. For all $i$ , we have $p ( h _ { i } ^ { d e l i m } | O _ { 1 } , o _ { 1 } ^ { d e l i m } , . . . , O _ { i } , \theta ^ { * } ) > c _ { 1 }$ and $p ( h _ { i } ^ { d e l i m } | O _ { 1 } , o _ { 1 } ^ { d e l i m } , . . . , O _ { i } , \theta ) <$ $c _ { 2 }$ . + +Proof. By Assumption 2, + +$$ +\begin{array} { r l r } { { p ( h _ { i } ^ { \mathrm { { d e l i m } } } | \mathcal { O } _ { 1 } , o _ { 1 } ^ { \mathrm { { d e l i m } } } , . . . , \mathcal { O } _ { i } , \theta ) = \sum _ { h _ { i , k } } p ( h _ { i } ^ { \mathrm { { d e l i m } } } | h _ { i , k } ) p ( h _ { i , k } | \mathcal { O } _ { 1 } , o _ { 1 } ^ { \mathrm { { d e l i m } } } , . . . , \mathcal { O } _ { i } , \theta ) } } \\ & { } & { < \sum _ { h _ { i , k } } { c } _ { 2 } p ( h _ { i , k } | \mathcal { O } _ { 1 } , o _ { 1 } ^ { \mathrm { { d e l i m } } } , . . . , \mathcal { O } _ { i } , \theta ) = c _ { 2 } . } \end{array} +$$ + +Similarly, + +$$ +\begin{array} { r l r } { { p ( h _ { i } ^ { \mathrm { { d e l i m } } } | O _ { 1 } , o _ { 1 } ^ { \mathrm { { d e l i m } } } , . . . , O _ { i } , \theta ^ { * } ) = \sum _ { h _ { i , k } } p ( h _ { i } ^ { \mathrm { { d e l i m } } } | h _ { i , k } ) p ( h _ { i , k } | O _ { 1 } , o _ { 1 } ^ { \mathrm { { d e l i m } } } , . . . , O _ { i } , \theta ^ { * } ) } } \\ & { } & { > \sum _ { h _ { i , k } } c _ { 1 } p ( h _ { i , k } | O _ { 1 } , o _ { 1 } ^ { \mathrm { { d e l i m } } } , . . . , O _ { i } , \theta ^ { * } ) = c _ { 1 } . } \end{array} +$$ + +Proposition 2. The probability of an example is lower bounded for $\theta ^ { * }$ : there is some $c _ { 7 } > 0$ such that $p ( \bar { O _ { i } } | h _ { i } ^ { s t a r t } , h _ { j , l } , \theta ^ { * } ) > c _ { 7 } .$ for all i and future hidden states $h _ { j , l } ,$ , for any $l$ and $j > i$ . + +Proof. By Assumption 5, we have + +$$ +p ( O _ { i } | h _ { i } ^ { \mathrm { s t a r t } } , h _ { j , l } , \theta ^ { * } ) = \sum _ { H _ { i } } p ( O _ { i } | H _ { i } ) p ( H _ { i } | h _ { i } ^ { \mathrm { s t a r t } } , h _ { j , l } , \theta ^ { * } ) > ( c _ { 6 } ) ^ { k } +$$ + +for some $H _ { i }$ . We have + +$$ +p ( H _ { i } | h _ { i } ^ { \mathrm { s t a r t } } , h _ { j , l } , \theta ^ { * } ) = \frac { p ( h _ { j , l } | H , h _ { i } ^ { \mathrm { s t a r t } } , \theta ^ { * } ) p ( H | h _ { i } ^ { \mathrm { s t a r t } } , \theta ^ { * } ) } { p ( h _ { j , l } | h _ { i } ^ { \mathrm { s t a r t } } , \theta ^ { * } ) } > c _ { 5 } ^ { 2 } +$$ + +which lower bounds the terms in the numerator by $c _ { 5 }$ (marginalizing over previous hidden states), and upper bounding the denominator by 1. Setting $\dot { c } _ { 7 } = ( c _ { 6 } ) ^ { k } c _ { 5 } ^ { 2 }$ finishes the proof. □ + +# C CONVERGENCE OF THE IN-CONTEXT PREDICTOR + +Under Assumption 3, we show that the in-context predictor $\begin{array} { r } { f _ { n } ( x _ { \mathrm { t e s t } } ) = \mathrm { a r g m a x } _ { y } p ( y | S _ { n } , x _ { \mathrm { t e s t } } ) } \end{array}$ converges when abstracting away the Bayesian inference component (the selection of $\theta ^ { * }$ from $\Theta$ ) of the in-context predictor. We will complete the argument for the convergence of the in-context predictor in the proof of Theorem 1. + +Lemma 1. Suppose the prompt $S _ { n }$ and the test input $x _ { t e s t }$ are given. Under Assumption $^ 3$ , we show that the argmax of the averaged predictive distribution conditioned on $\theta ^ { * }$ and a prompt $S _ { n }$ is the same as the argmax of the prompt predictive distribution: + +$$ +\underset { y } { \arg \operatorname* { m a x } } \sum _ { h _ { t e x t } ^ { s t o t } \in \mathcal { H } } p ( y | x _ { t e s t } , h _ { t e s t } ^ { s t a r t } , \theta ^ { * } ) p ( h _ { t e s t } ^ { s t a r t } | S _ { n } , x _ { t e s t } , \theta ^ { * } ) = \underset { y } { \arg \operatorname* { m a x } } p _ { p r o m p t } ( y | x _ { t e s t } ) . +$$ + +Proof. First, we note by definition that + +$$ +p _ { \mathrm { p r o m p t } } ( y | x _ { \mathrm { t e s t } } ) = \sum _ { h _ { \mathrm { t e s t } } ^ { \mathrm { s t a r t } } \in \mathcal { H } } p ( y | x _ { \mathrm { t e s t } } , h _ { \mathrm { t e s t } } ^ { \mathrm { s t a r t } } , \theta ^ { * } ) p _ { \mathrm { p r o m p t } } ( h _ { \mathrm { t e s t } } ^ { \mathrm { s t a r t } } | x _ { \mathrm { t e s t } } ) . +$$ + +Expanding the last term, we have + +$$ +p _ { \mathrm { p r o m p t } } ( h _ { \mathrm { t e s t } } ^ { \mathrm { s t a r t } } | x _ { \mathrm { t e s t } } ) \propto p ( x _ { \mathrm { t e s t } } | h _ { \mathrm { t e s t } } ^ { \mathrm { s t a r t } } , \theta ^ { * } ) p _ { \mathrm { p r o m p t } } ( h _ { \mathrm { t e s t } } ^ { \mathrm { s t a r t } } ) . +$$ + +which is proportional to a constant in $x _ { \mathrm { t e s t } }$ + +On the other hand, analyzing one term inside the LHS of the lemma statement, we have + +$$ +p ( h ^ { \mathrm { s t a r t } } | S _ { n } , x _ { \mathrm { t e s t } } , \theta ^ { * } ) \propto p ( x _ { \mathrm { t e s t } } | h _ { \mathrm { t e s t } } ^ { \mathrm { s t a r t } } , \theta ^ { * } ) p ( h _ { \mathrm { t e s t } } ^ { \mathrm { s t a r t } } | S _ { n } , \theta ^ { * } ) +$$ + +which is proportional to a constant in $x _ { \mathrm { t e s t } }$ and $S _ { n }$ . The quantities differ in the last term, which we expand below and put in matrix form. Let $T \in \mathbb { R } ^ { | \mathcal { H } | \times | \mathcal { D } | }$ be the matrix that represents the transition probabilities starting from a delimiter state: $p ( h _ { \mathrm { t e s t } } ^ { \mathrm { s t a r t } } | h ^ { \mathrm { d e l i m } } )$ for $h _ { \mathrm { t e s t } } ^ { \mathrm { s t a r t } } \in \mathcal { H }$ and $h ^ { \mathrm { d e l i m } } \in { \mathcal { D } }$ . As a result, + +$$ +\begin{array} { r l r } { { p ( h _ { \mathrm { t e s t } } ^ { \mathrm { s t a r t } } | S _ { n } , \theta ^ { * } ) = \sum _ { h _ { n } ^ { \mathrm { d e l i m } } } p ( h _ { \mathrm { t e s t } } ^ { \mathrm { s t a r t } } | h _ { n } ^ { \mathrm { d e l i m } } , \theta ^ { * } ) p ( h _ { n } ^ { \mathrm { d e l i m } } | S _ { n } , \theta ^ { * } ) } } \\ & { } & { = T v } \end{array} +$$ + +$h _ { n } ^ { \mathrm { d e l i m } }$ is the delimiter hidden state before $h _ { \mathrm { t e s t } } ^ { \mathrm { s t a r t } }$ + +Let $W \in \mathbb { R } ^ { | \mathcal { V } | \times | \mathcal { H } | }$ be the matrix that represents the probabilities $p ( y | x _ { \mathrm { t e s t } } , h _ { \mathrm { t e s t } } ^ { \mathrm { s t a r t } } , \theta ^ { * } ) p ( x _ { \mathrm { t e s t } } | h _ { \mathrm { t e s t } } ^ { \mathrm { s t a r t } } , \theta ^ { * } )$ for all the possible $y \in \mathcal { V }$ and $h _ { \mathrm { t e s t } } ^ { \mathrm { s t a r t } } \in \mathcal { H }$ . Overall, we can write + +$$ +\begin{array} { r } { \sum _ { \boldsymbol { h } _ { \mathrm { t e s t } } ^ { \mathrm { s t a r t } } \in \mathcal { H } } p ( \cdot | x _ { \mathrm { t e s t } } , h _ { \mathrm { t e s t } } ^ { \mathrm { s t a r t } } , \boldsymbol { \theta } ^ { * } ) p ( h _ { \mathrm { t e s t } } ^ { \mathrm { s t a r t } } | S _ { n } , x _ { \mathrm { t e s t } } , \boldsymbol { \theta } ^ { * } ) = W T v } \\ { h _ { \mathrm { t e s t } } ^ { \mathrm { s t a r t } } \in \mathcal { H } } \\ { p _ { \mathrm { p r o m p t } } ( \cdot | x _ { \mathrm { t e s t } } ) = W u } \end{array} +$$ + +where $u \in \mathbb { R } ^ { | \mathcal { H } | }$ is the vector of probabilities that corresponds to the prompt start distribution $p _ { \mathrm { p r o m p t } }$ + +Bounding the difference between the two predictive distributions, + +$$ +\begin{array} { r l } { \| W ^ { T } v - W _ { u } \| _ { \infty } \le \| W ^ { T } v - W _ { u } \| _ { 1 } } & { } \\ & { = \displaystyle \sum _ { i = 1 } ^ { \lfloor y \rfloor } W _ { i } ^ { - 1 } ( T v - u ) \| _ { \infty } } \\ & { = \displaystyle \sum _ { i = 1 } ^ { \lfloor y \rfloor } \left| \displaystyle \sum _ { j = 1 } ^ { \lfloor y \rfloor } W _ { i j } ( T v - u ) _ { j } \right| } \\ & { = \displaystyle \sum _ { i = 1 } ^ { \lfloor y \rfloor } \left| \displaystyle \sum _ { j = 1 } ^ { \lfloor y \rfloor } W _ { i j } ( T v - u ) _ { j } \right| } \\ & { \le \displaystyle \sum _ { i = 1 } ^ { \lfloor y \rfloor } \displaystyle \sum _ { j = 1 } ^ { \lfloor y \rfloor } W _ { i j } ( T v - u ) _ { j } \quad \{ W _ { i j } \ge \mathbb { C } \} } \\ & { = \displaystyle \sum _ { j = 1 } ^ { \lfloor y \rfloor } \displaystyle \{ \frac { 1 9 ! } { 2 } ( 1 - W _ { i j } ) ( T v - u ) _ { j } \} } \\ & { = \displaystyle \sum _ { j = 1 } ^ { \lfloor y \rfloor } \displaystyle \{ 1 / \nu - w \} _ { j } \{ 1 / \nu } \\ & { = \| T v - u \| _ { 1 } . } \end{array} +$$ + +Using Assumption 3, we can further bound this by $\Delta / 2$ : + +$$ +\begin{array} { r l } & { \| T v - u \| _ { 1 } = 2 T V ( p _ { \mathrm { p r o m p t } } ( \cdot ) \| \displaystyle \sum _ { i = 1 } ^ { | \mathcal { D } | } v _ { i } p ( \cdot | h ^ { \mathrm { d e l i m } } = i , \theta ^ { * } ) ) } \\ & { \qquad \le 2 \displaystyle \sum _ { i = 1 } ^ { | \mathcal { D } | } v _ { i } T V ( p _ { \mathrm { p r o m p t } } ( \cdot ) \| p ( \cdot | h ^ { \mathrm { d e l i m } } = i , \theta ^ { * } ) ) \quad \mathrm { ( c o n v e x i t y ~ o f ~ T V ~ d i s t a n c e ) } } \\ & { \qquad \le 2 \displaystyle \operatorname* { m a x } _ { h ^ { \mathrm { d e l i m } } \in \mathcal { D } } T V ( p _ { \mathrm { p r o m p t } } ( \cdot ) \| p ( \cdot | h ^ { \mathrm { d e l i m } } , \theta ^ { * } ) ) < \Delta / 2 . } \end{array} +$$ + +Since the probability of any output does not change by more than $\Delta / 2$ and the margin between the most likely label and the second most likely label is $\Delta$ , the argmax’s are the same, showing the result. + +# D PROOF OF THEOREM 1 + +Proof. We analyze the most likely prediction over the pretraining distribution conditioned on the prompt argmax ${ } _ { y } p ( y | S _ { n } , x _ { \mathrm { t e s t } } )$ . + +$$ +\begin{array} { l } { \displaystyle p ( y | S _ { n } , x _ { \mathrm { t e s t } } ) = \int _ { \theta } p ( y | S _ { n } , x _ { \mathrm { t e s t } } , \theta ) p ( \theta | S _ { n } , x _ { \mathrm { t e s t } } ) d \theta } \\ { \displaystyle \propto \int _ { \theta } p ( y | S _ { n } , x _ { \mathrm { t e s t } } , \theta ) p ( S _ { n } , x _ { \mathrm { t e s t } } | \theta ) p ( \theta ) d \theta } \\ { \displaystyle \propto \int _ { \theta } p ( y | S _ { n } , x _ { \mathrm { t e s t } } , \theta ) \frac { p ( S _ { n } , x _ { \mathrm { t e s t } } | \theta ) } { p ( S _ { n } , x _ { \mathrm { t e s t } } | \theta ^ { * } ) } p ( \theta ) d \theta } \\ { \displaystyle = \int _ { \theta _ { h } \underset { \mathrm { t e s t } } { \sum } \sum } p ( y | x _ { \mathrm { t e s t } } , h _ { \mathrm { t e s t } } ^ { \mathrm { s t a t } } , \theta ) p ( h _ { \mathrm { t e s t } } ^ { \mathrm { s t a t } } | S _ { n } , x _ { \mathrm { t e s t } } , \theta ) \frac { p ( S _ { n } , x _ { \mathrm { t e s t } } | \theta ) } { p ( S _ { n } , x _ { \mathrm { t e s t } } | \theta ^ { * } ) } p ( \theta ) d \theta } \end{array} +$$ + +Defining the following quantity, + +$$ +r _ { n } ( \theta ) { = } \frac { 1 } { n } { \log } \frac { p ( S _ { n } , x _ { \mathrm { t e s t } } | \theta ) } { p ( S _ { n } , x _ { \mathrm { t e s t } } | \theta ^ { * } ) } . +$$ + +we will show that under distinguishability for all $\theta \neq \theta ^ { \ast } , r _ { n } ( \theta )$ converges to a negative constant such that + +$$ +\frac { p ( S _ { n } , x _ { \mathrm { t e s t } } | \theta ) } { p ( S _ { n } , x _ { \mathrm { t e s t } } | \theta ^ { * } ) } { = } \mathrm { e x p } ( n \cdot r _ { n } ( \theta ) ) { \to } 0 +$$ + +for $\theta \neq \theta ^ { * }$ , whereas this ratio is always 1 for $\theta = \theta ^ { * }$ . This will then “select” the desired prompt concept through marginalization. + +upposing that Equation 53 holds, we show that the theorem statement holds. Let + +$$ +\Delta ^ { \prime } = \operatorname* { m a x } _ { h ^ { \mathrm { d e l i m } } \in \mathcal { D } } T V ( p _ { \mathrm { p r o m p t } } ( \cdot ) \| p ( \cdot | h ^ { \mathrm { d e l i m } } , \theta ^ { * } ) ) < \Delta / 2 , +$$ + +and let $\epsilon < ( \Delta / 2 - \Delta ^ { \prime } ) p ( \theta ^ { * } )$ . Then for $n$ large enough (due to Equation 53), + +$$ +\begin{array} { r l } { \displaystyle \int _ { \theta } \displaystyle \sum _ { h _ { \mathrm { t e s t } } ^ { \mathrm { s t a t } } \in \mathcal { H } } p ( y | x _ { \mathrm { t e s t } } , h _ { \mathrm { t e s t } } ^ { \mathrm { s t a t } } , \theta ) p ( h _ { \mathrm { t e s t } } ^ { \mathrm { s t a r t } } | S _ { n } , x _ { \mathrm { t e s t } } , \theta ) \frac { p ( S _ { n } , x _ { \mathrm { t e s t } } | \theta ) } { p ( S _ { n } , x _ { \mathrm { t e s t } } | \theta ^ { * } ) } p ( \theta ) d \theta } & { } \\ { = \displaystyle \sum _ { h _ { \mathrm { t e s t } } ^ { \mathrm { s t a t } } \in \mathcal { H } } p ( y | x _ { \mathrm { t e s t } } , h _ { \mathrm { t e s t } } ^ { \mathrm { s t a r t } } , \theta ^ { * } ) p ( h _ { \mathrm { t e s t } } ^ { \mathrm { s t a r t } } | S _ { n } , x _ { \mathrm { t e s t } } , \theta ^ { * } ) p ( \theta ^ { * } ) + \displaystyle \int _ { \theta \neq \theta ^ { * } } \epsilon _ { \theta } ( y ) p ( \theta ) d \theta } & { } \\ { \displaystyle \propto \sum _ { h _ { \mathrm { t e s t } } ^ { \mathrm { s t a r t } } \in \mathcal { H } } p ( y | x _ { \mathrm { t e s t } } , h _ { \mathrm { t e s t } } ^ { \mathrm { s t a r t } } , \theta ^ { * } ) p ( h _ { \mathrm { t e s t } } ^ { \mathrm { s t a r t } } | S _ { n } , x _ { \mathrm { t e s t } } , \theta ^ { * } ) + \frac { 1 } { p ( \theta ^ { * } ) } \int _ { \theta \neq \theta ^ { * } } \epsilon _ { \theta } ( y ) p ( \theta ) d \theta } & { } \end{array} +$$ + +where $\epsilon _ { \theta } ( y ) { \le } \epsilon / 2$ for all $y \in \mathcal { V }$ . + +By Lemma 1, the argmax of the first term of Equation 57 is the same as $\operatorname { a r g m a x } _ { y } p _ { \mathrm { p r o m p t } } ( y | x _ { \mathrm { t e s t } } )$ , where the margin between the most likely label and the second most likely is at least $\Delta / 2 - \Delta ^ { \prime }$ . Since + +$$ +\frac { 1 } { p ( \theta ^ { * } ) } \int _ { \theta \ne \theta ^ { * } } \epsilon _ { \theta } ( y ) p ( \theta ) \le \frac { \epsilon } { 2 p ( \theta ^ { * } ) } < ( \Delta / 2 - \Delta ^ { \prime } ) / 2 +$$ + +for all $y \in \mathcal { V }$ , the argmax of Equation 57 is also the same as $\mathrm { a r g m a x } p _ { \mathrm { p r o m p t } } ( y | x _ { \mathrm { t e s t } } )$ + +Now it remains to show that $r _ { n } ( \theta )$ converges to a negative constant for $\theta \neq \theta ^ { * }$ . Let $O _ { i } ^ { \mathrm { e x } } = \left[ o _ { i - 1 } ^ { \mathrm { d e l i m } } , O _ { i } \right]$ be the $i$ -th observation segment and the previous delimiter together for $i > 1$ and define $O _ { 1 } ^ { \mathrm { e x } } = O _ { 1 }$ Expanding the numerator of the ratio in $r _ { n } ( \theta )$ , we have + +$$ +\begin{array} { r l r } { p ( S _ { n } , x _ { \mathrm { t e x } } | \theta ) = p ( x _ { \mathrm { t e x } } | S _ { n } , \theta ) p ( S _ { n } | \theta ) } & { { } } & { { \scriptstyle ( 5 9 ) } } \\ { \displaystyle } & { = \sum _ { h _ { \mathrm { t e x } } ^ { \mathrm { a u r } } } p ( x _ { \mathrm { t e x } } | I _ { \mathrm { t s e t } } ^ { \mathrm { s t a r } } , \theta ) p ( h _ { \mathrm { t s e t } } ^ { \mathrm { s t a r } } | S _ { n } , \theta ) p ( o _ { n } ^ { \mathrm { d e l i m } } | O _ { 1 : n } ^ { \mathrm { c x } } , \theta ) \prod _ { i = 1 } ^ { n } p ( O _ { i } ^ { \mathrm { c x } } | O _ { 1 : i - 1 } ^ { \mathrm { c x } } , \theta ) } & { { } } & { { \scriptstyle ( 6 0 ) } } \\ { \displaystyle } & { { } } & { { \scriptstyle = \sum _ { h _ { \mathrm { t e x } } ^ { \mathrm { a u r } } } p ( x _ { \mathrm { t e x } } | I _ { \mathrm { t s e t } } ^ { \mathrm { s t a r } } , \theta ) p ( h _ { \mathrm { t e x } } ^ { \mathrm { s t a r } } | S _ { n } , \theta ) } } & { { } } & { { \scriptstyle ( 6 1 , \atop h _ { \mathrm { t e x } } ^ { \mathrm { a u r } } } ) } \\ { \displaystyle } & { { } } & { { \scriptstyle \geq \sum _ { h _ { \mathrm { t e x } } ^ { \mathrm { a u r } } } \sum _ { \ell } p ( o _ { n } ^ { \mathrm { d e l i m } } | h _ { n } ^ { \mathrm { d e l i m } } ) p ( h _ { \mathrm { t s e t } } ^ { \mathrm { d e l i m } } | O _ { 1 : n } ^ { \mathrm { c x } } , \theta ) \prod _ { i = 1 } ^ { n } \sum _ { h _ { \mathrm { d e l i m } } ^ { \mathrm { d e l i m } } \in \mathcal D } } } \\ { \displaystyle } & { { } } & { \scriptstyle h _ { n } ^ { \mathrm { a i n i m } } \in \mathcal D \displaystyle ( o _ { n } ^ { \mathrm { d e l i m } } | I _ { n } ^ { \mathrm { d e l i m } } ) p ( h _ { n } ^ { \mathrm { d e l i m } } | O _ { 1 : n } ^ { \mathrm { c x } } , \theta ) \prod _ { i = 1 } ^ { n } \sum _ { h _ { \mathrm { t e m } } ^ { \mathrm { d e l i m } } \in \mathcal D } } \end{array} +$$ + +$$ +\begin{array} { r l } { \displaystyle } & { = \displaystyle \sum _ { h _ { \mathrm { t s t } } ^ { \mathrm { s t a r t } } } p ( x _ { \mathrm { t e s t } } | h _ { \mathrm { t e s t } } ^ { \mathrm { s t a r t } } , \theta ) p ( h _ { \mathrm { t e s t } } ^ { \mathrm { s t a r t } } | S _ { n } , \theta ) } \\ { \displaystyle } & { \qquad \displaystyle \sum _ { h _ { n } ^ { \mathrm { d e i m } } \in \mathcal { D } } p ( h _ { n } ^ { \mathrm { d e l i m } } | { \mathcal O } _ { 1 : n } ^ { \mathrm { e x } } , \theta ) \prod _ { i = 1 } ^ { n } \sum _ { h _ { i - 1 } ^ { \mathrm { d e i m } } \in \mathcal { D } } p ( { \mathcal O } _ { i } | h _ { i - 1 } ^ { \mathrm { d e l i m } } , \theta ) p ( h _ { i - 1 } ^ { \mathrm { d e l i m } } | { \mathcal O } _ { 1 : i - 1 } ^ { \mathrm { e x } } , \theta ) } \\ { \displaystyle } & { = \sum _ { h _ { \mathrm { t s t } } ^ { \mathrm { s t a r t } } } p ( x _ { \mathrm { t e s t } } | h _ { \mathrm { t e s t } } ^ { \mathrm { s t a r t } } , \theta ) p ( h _ { \mathrm { t e s t } } ^ { \mathrm { s t a r t } } | S _ { n } , \theta ) \prod _ { i = 1 } ^ { n } \sum _ { h _ { i } ^ { \mathrm { d e i m } } \in \mathcal { D } } p ( { O } _ { i } | h _ { i - 1 } ^ { \mathrm { d e l i m } } , \theta ) p ( h _ { i - 1 } ^ { \mathrm { d e l i m } } | O _ { 1 : i - 1 } ^ { \mathrm { e x } } , \theta ) } \end{array} +$$ + +Note that in the last line, the inner sum is over the set of delimiter states $\mathcal { D }$ by using the assumption that observing a delimiter $o ^ { \mathrm { { d e l i m } } }$ implies that the corresponding hidden state $\dot { h } ^ { \mathrm { d e l i m } }$ must be in $\mathcal { D }$ . We also see that $\begin{array} { r } { \sum _ { h _ { n } ^ { \mathrm { d e l i m } } } p ( h _ { n } ^ { \mathrm { d e l i m } } | O _ { 1 : n } ^ { \mathrm { e x } } , \theta ) = 1 } \end{array}$ . + +We restrict our attention to $\theta$ where $p ( S _ { n } , x _ { \mathrm { t e s t } } | \theta ) > 0$ , since otherwise $\theta$ does not affect the prediction. Expanding $r _ { n } ( \theta )$ , we have the following upper bound: + +$$ +\begin{array} { r l r } { { n \setminus \Bigm " ( \log \sum _ { n \in \mathbb { N } } p ( S _ { n } , x _ { \mathrm { t e s t } } | \theta ^ { * } ) \Bigm ) } } \\ & { } & { = \frac { 1 } { n } \Bigg ( \log \frac { \sum _ { h _ { \mathrm { t e s t } } ^ { \mathrm { s a r i n } } } p ( x _ { \mathrm { t e s t } } | h _ { \mathrm { t e s t } } ^ { \mathrm { s a r t } } , \theta ) p ( h _ { \mathrm { t e s t } } ^ { \mathrm { s a r t } } | S _ { n } , \theta ) } { \sum _ { h _ { \mathrm { t e s t } } ^ { \mathrm { s a r i } } } p ( x _ { \mathrm { t e s t } } | h _ { \mathrm { t e s t } } ^ { \mathrm { s a r t } } , \theta ^ { * } ) p ( h _ { \mathrm { t e s t } } ^ { \mathrm { s a r t } } | S _ { n } , \theta ^ { * } ) } + \sum _ { i = 1 } ^ { n } \log \frac { n } { \sum _ { h _ { \mathrm { t - i } } ^ { \mathrm { s a r i n } } \in \mathcal { D } } p ( O _ { i } | h _ { i - 1 } ^ { \mathrm { d e i n } } , \theta ^ { * } ) p ( h _ { i - 1 } ^ { \mathrm { d e i n } } | O _ { 1 } ^ { \mathrm { c h i n } } | O _ { 1 } ^ { \mathrm { c h i n } } ) } } \\ & { } & \leq \frac { 1 } { n } \Bigg ( \log \frac { \sum _ { h _ { \mathrm { t e s t } } ^ { \mathrm { s a r i n } } } 1 \cdot p ( h _ { \mathrm { t e s t } } ^ { \mathrm { s a r t } } | S _ { n } , \theta ) } { \sum _ { h _ { \mathrm { t e s t } } ^ { \mathrm { s a r i } } } { \cal U } \cdot p ( h _ { \mathrm { t e s t } } ^ { \mathrm { s a r t } } | S _ { n } , \theta ^ { * } ) } + n ( \log ( c _ { 2 } ) - \log ( c _ { 1 } ) ) + \sum _ { i = 1 } ^ { n } \log \frac { n } { \sum _ { h _ { \mathrm { t - i } } ^ { \mathrm { s a r i n } } \in \mathcal { D } } p ( O _ { i } | h _ { i - 1 } ^ { \mathrm { d e i n } } , \theta ^ { * } ) } \\ & { } & \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \ \end{array} +$$ + +$$ += \frac { 1 } { n } \Bigg ( - \log ( c _ { 7 } ) + n ( \log ( c _ { 2 } ) - \log ( c _ { 1 } ) ) + \sum _ { i = 1 } ^ { n } \log \frac { \sum _ { h _ { i - 1 } ^ { \mathrm { d e l i m } } \in \mathcal { D } } p ( O _ { i } | h _ { i - 1 } ^ { \mathrm { d e l i m } } , \theta ) } { \sum _ { h _ { i - 1 } ^ { \mathrm { d e l i m } } \in \mathcal { D } } p ( O _ { i } | h _ { i - 1 } ^ { \mathrm { d e l i m } } , \theta ^ { * } ) } \Bigg ) +$$ + +In the above steps, we used both Propositions 1 and 2 in the terms involving $c _ { 2 } , c _ { 1 }$ (bounding the probability of $h ^ { \mathrm { { d e l i m } } }$ hidden states) and $c _ { 7 }$ (bounding the probability of $x _ { \mathrm { t e s t } }$ ). Note that in the second line, the sum can must be over the set of delimiter states $\mathcal { D }$ by using the assumption that observing a delimiter $o ^ { \mathrm { { d e l i m } } }$ implies that the corresponding hidden state $\bar { h ^ { \mathrm { { d e l i m } } } }$ must be in $\mathcal { D }$ . + +Focusing on the numerator of the ratio term and summing over the start hidden state for the $i$ -th example, + +$$ +\begin{array} { r l } { \displaystyle \sum _ { h _ { i - 1 } ^ { \mathrm { d e i m } } \in \mathcal { D } } p ( O _ { i } | h _ { i - 1 } ^ { \mathrm { d e i m } } , \theta ) = \sum _ { h _ { i - 1 } ^ { \mathrm { d e i m } } \in \mathcal { D } h _ { i } ^ { \mathrm { s t a r t } } } p ( O _ { i } | h _ { i } ^ { \mathrm { s t a r t } } , \theta ) p ( h _ { i } ^ { \mathrm { s t a r t } } | h _ { i - 1 } ^ { \mathrm { d e i m } } , \theta ) ) } & { } \\ { = \displaystyle \sum _ { h _ { i } ^ { \mathrm { s t a r t } } } p ( O _ { i } | h _ { i } ^ { \mathrm { s t a r t } } , \theta ) p ( h _ { i } ^ { \mathrm { s t a r t } } | \theta ) \sum _ { h _ { i - 1 } ^ { \mathrm { d e i m } } \in \mathcal { D } } \frac { p ( h _ { i } ^ { \mathrm { s t a r t } } | h _ { i - 1 } ^ { \mathrm { d e i m } } , \theta ) } { p ( h _ { i } ^ { \mathrm { s t a r t } } | \theta ) } } & { } \\ { = \displaystyle \sum _ { h _ { i } ^ { \mathrm { s t a r t } } } p ( O _ { i } | h _ { i } ^ { \mathrm { s t a r t } } , \theta ) p ( h _ { i } ^ { \mathrm { s t a r t } } | \theta ) \sum _ { h _ { i - 1 } ^ { \mathrm { d e i m } } \in \mathcal { D } } \frac { p ( h _ { i - 1 } ^ { \mathrm { d e i m } } | h _ { i } ^ { \mathrm { s t a r t } } , \theta ) } { p ( h _ { i - 1 } ^ { \mathrm { d e i m } } | \theta ) } } & { } \end{array} +$$ + +where the last step applies Bayes’ rule. We can lower and upper bound the following quantity for any $\theta$ using Assumption 2: + +$$ +\begin{array} { r l } & { \frac { p ( h _ { i - 1 } ^ { \mathrm { d e l i m } } | h _ { i } ^ { \mathrm { s t a r t } } , \theta ) } { p ( h _ { i - 1 } ^ { \mathrm { d e l i m } } | \theta ) } { \leq } \frac { p ( h _ { i - 1 } ^ { \mathrm { d e l i m } } | h _ { i } ^ { \mathrm { s t a r t } } , \theta ) } { c _ { 3 } } } \\ & { \frac { p ( h _ { i - 1 } ^ { \mathrm { d e l i m } } | h _ { i } ^ { \mathrm { s t a r t } } , \theta ) } { p ( h _ { i - 1 } ^ { \mathrm { d e l i m } } | \theta ) } { \geq } \frac { p ( h _ { i - 1 } ^ { \mathrm { d e l i m } } | h _ { i } ^ { \mathrm { s t a r t } } , \theta ) } { c _ { 4 } } . } \end{array} +$$ + +This implies that + +$$ +\begin{array} { r l r } { { \sum _ { h _ { i - 1 } ^ { \mathrm { d e l i m } } \in \mathcal { D } } \frac { p ( h _ { i - 1 } ^ { \mathrm { d e l i m } } \vert h _ { i } ^ { \mathrm { s t a r t } } , \theta ) } { p ( h _ { i - 1 } ^ { \mathrm { d e l i m } } \vert \theta ) } \le \frac { 1 } { c _ { 3 } } } } \\ & { } & { \displaystyle \sum _ { h _ { i - 1 } ^ { \mathrm { d e l i m } } \in \mathcal { D } } \frac { p ( h _ { i - 1 } ^ { \mathrm { d e l i m } } \vert h _ { i } ^ { \mathrm { s t a r t } } , \theta ) } { p ( h _ { i - 1 } ^ { \mathrm { d e l i m } } \vert \theta ) } \ge \frac { 1 } { c _ { 4 } } . } \end{array} +$$ + +Plugging in these bounds, we have + +$$ +\dot { \mathbf { \eta } } _ { n } ( \theta ) \leq \frac { 1 } { n } \bigg ( - \log ( c _ { 7 } ) + 2 n ( \log ( c _ { 2 } ) - \log ( c _ { 1 } ) ) + n ( \log ( c _ { 4 } ) - \log ( c _ { 3 } ) ) + \sum _ { i = 1 } ^ { n } \log \frac { \sum _ { h _ { i } ^ { \mathrm { s a r n } } } p ( O _ { i } | h _ { i } ^ { \mathrm { s a r n } } , \theta ) p ( h _ { i } ^ { \mathrm { s a r n } } , \theta ) } { \sum _ { h _ { i } ^ { \mathrm { s a r n } } } p ( O _ { i } | h _ { i } ^ { \mathrm { s a r n } } , \theta ) p ( h _ { i } ^ { \mathrm { s a r n } } , \theta ) } \bigg ) . +$$ + +$$ +\begin{array} { r l } & { = \displaystyle \frac { 1 } { n } \bigg ( - \log ( c _ { 7 } ) + 2 n ( \log ( c _ { 2 } ) - \log ( c _ { 1 } ) ) + n ( \log ( c _ { 4 } ) - \log ( c _ { 3 } ) ) + \sum _ { i = 1 } ^ { n } \log \frac { p ( O _ { i } | \theta ) } { p ( O _ { i } | \theta ^ { * } ) } \bigg ) } \\ & { \to _ { n \to \infty } \mathbb { E } _ { O \sim p _ { \mathrm { p r o m g t } } } \bigg [ \log \frac { p ( O | \theta ) } { p ( O | \theta ^ { * } ) } \bigg ] + \epsilon _ { \mathrm { d e l i m } } ^ { \theta } } \end{array} +$$ + +where we set + +$$ +\epsilon _ { \mathrm { d e l i m } } ^ { \theta } = 2 ( \log ( c _ { 2 } ) - \log ( c _ { 1 } ) ) + \log ( c _ { 4 } ) - \log ( c _ { 3 } ) . +$$ + +Next, we convert the expectation in the bound into a KL divergence. We have + +$$ +\begin{array} { r } { \mathbb { E } _ { { O } \sim p _ { \mathrm { p r o m p t } } } \left[ \log \frac { p ( { O } | { \boldsymbol { \theta } } ) } { p ( { O } | { \boldsymbol { \theta } } ^ { * } ) } \right] = \mathbb { E } _ { { O } \sim p _ { \mathrm { p r o m p t } } } \left[ \log \frac { p ( { O } | { \boldsymbol { \theta } } ) } { p _ { \mathrm { p r o m p t } } ( { O } ) } + \log \frac { p _ { \mathrm { p r o m p t } } ( { O } ) } { p ( { O } | { \boldsymbol { \theta } } ^ { * } ) } \right] } \\ { = K L ( p _ { \mathrm { p r o m p t } } \| p ( \cdot | { \boldsymbol { \theta } } ^ { * } ) ) - K L ( p _ { \mathrm { p r o m p t } } \| p ( \cdot | { \boldsymbol { \theta } } ) ) . } \end{array} +$$ + +We will upper bound the first KL term: + +$$ +K L ( p _ { \mathrm { p r o m p t } } | | p ( \cdot | \theta ^ { * } ) ) = \mathbb { E } _ { O \sim p _ { \mathrm { p r o m p t } } } \biggl [ \log \frac { p _ { \mathrm { p r o m p t } } ( O ) } { p ( O | \theta ^ { * } ) } \biggr ] . +$$ + +Expanding the numerator and denominator of the ratio inside, we have + +$$ +\begin{array} { l } { { \displaystyle p _ { \mathrm { p r o m p t } } ( O ) = \sum _ { H } p _ { \mathrm { p r o m p t } } ( H [ 1 ] ) p ( O [ 1 ] \vert H [ 1 ] , \theta ^ { * } ) \prod _ { j = 2 } ^ { k } p ( O [ j ] \vert H [ j ] , \theta ^ { * } ) p ( H [ j ] \vert H [ j - 1 ] , \theta ^ { * } ) } } \\ { { \displaystyle p ( O \vert \theta ^ { * } ) = \sum _ { H } p ( H [ 1 ] \vert \theta ^ { * } ) p ( O [ 1 ] \vert H [ 1 ] , \theta ^ { * } ) \prod _ { j = 2 } ^ { k } p ( O [ j ] \vert H [ j ] , \theta ^ { * } ) p ( H [ j ] \vert H [ j - 1 ] , \theta ^ { * } ) } } \end{array} +$$ + +which differ in only the hidden start distribution. Using Assumption 5, we have that $p ( h | \theta ^ { * } ) \geq c _ { 8 }$ for any $h \in { \mathcal { H } }$ , which implies that + +$$ +\begin{array} { r } { \displaystyle \frac { p _ { \mathrm { p r o m p t } } ( h ) } { p ( h | \theta ^ { * } ) } \le \frac { 1 } { c _ { 8 } } } \\ { \displaystyle \Longrightarrow p _ { \mathrm { p r o m p t } } ( O ) \le \frac { 1 } { c _ { 8 } } p ( O | \theta ^ { * } ) . } \end{array} +$$ + +Finally, this implies that the KL term is bounded as + +$$ +K L ( p _ { \mathrm { p r o m p t } } | | p ( \cdot | \theta ^ { * } ) ) { \leq } \mathrm { - l o g } ( c _ { 8 } ) . +$$ + +This term is non-negative since $c _ { 8 } \leq 1$ + +Aiming to decompose the second $\mathrm { K L }$ term into a sum over the $k$ tokens, we write $p _ { \theta } ^ { j } ( o ) = p ( O [ j ] = o | O [ 1 : j - 1 ] , \theta )$ and $p _ { \mathrm { p r o m p t } } ^ { j } ( o ) { = } p _ { \mathrm { p r o m p t } } ( O [ j ] { = } o | O [ 1 { : } j - 1 ] )$ . We have + +$$ +\begin{array}{c} \begin{array} { l l } { \displaystyle - K L ( p _ { \mathrm { p r o n p t } } | | p ( \cdot | \theta ) ) = - \sum _ { O } p _ { \mathrm { p r o n p t } } ( O ) \log \frac { p _ { \mathrm { p r o n p t } } ( O ) } { p ( O | \theta ) } } \\ { \displaystyle } \\ { \displaystyle } \\ { \quad } \\ { \displaystyle } \\ { \quad } \\ { \displaystyle } \\ { \quad } \\ { \displaystyle } \\ { \quad } \\ { \displaystyle } \\ { \quad } \\ { \displaystyle } \\ { \quad } \\ { \displaystyle } \end{array} \left( \begin{array} { l } { \displaystyle \sum _ { \sigma } p _ { \mathrm { p r o n p t } } ( O ) \sum _ { j = 1 } ^ { k } \log \frac { p _ { \mathrm { p r o n p t } } ( O [ j ] | O [ 1 : j - 1 ] ) } { p ( O [ j ] | O [ 1 : j - 1 ] , \theta ) } } \\ { \displaystyle } \\ { \displaystyle } \\ { \displaystyle } \\ { \displaystyle } \\ { \displaystyle } \\ { \displaystyle } \\ { \quad } \\ { \displaystyle } \end{array} \right) \\ { \displaystyle } \\ { \displaystyle } { \quad } \\ { \displaystyle } { \displaystyle } \\ { \quad } \\ { \displaystyle } { \quad } \\ { \displaystyle } { \quad } \\ { \displaystyle } { \quad } \\ { \displaystyle } { \quad } \\ { \quad } \\ { \displaystyle } { \quad } \\ { \displaystyle } { \quad } \\ { \quad } \\ { \displaystyle } { \quad } \\ { \quad } \\ { \displaystyle } { \quad } \\ { \quad } \\ { \displaystyle } { \quad } \\ { \quad } \\ { \displaystyle } { \quad } \\ { \quad } \\ { \displaystyle } { \quad } \\ { \quad } \\ { \displaystyle } { \sum _ { j = 1 } ^ { k } \mathbb { Q [ 1 : j - 1 ] \sim \mathrm { p r e r e r e } \left[ K L ( p _ { \mathrm { p r o n p t } } ^ { j } | | O [ 1 : j - 1 ] ) \right] } } \\ { \displaystyle } \\ { \quad } \\ { \displaystyle } \end{array} +$$ + +Then we have that + +$$ +\operatorname* { l i m } _ { n \to \infty } r _ { n } ( \theta ) < - \sum _ { j = 1 } ^ { k } \mathbb { E } _ { O [ 1 : j - 1 ] \sim p _ { \mathrm { p r o m p t } } } [ K L ( p _ { \mathrm { p r o m p t } } ^ { j } \| p _ { \theta } ^ { j } ) ] + \epsilon _ { \mathrm { s t a r t } } ^ { \theta } + \epsilon _ { \mathrm { d e l i m } } ^ { \theta } +$$ + +The second term (set $\begin{array} { r } { \epsilon _ { \mathrm { s t a r t } } ^ { \theta } { = } \log ( \frac { 1 } { c _ { 8 } } ) ) } \end{array}$ is an error term that depends on how different the starting prompt distribution $p _ { \mathrm { p r o m p t } }$ (which is part of $p _ { \mathrm { p r o m p t } } )$ is to the pretraining distribution. The third term is an error term that comes from the delimiter transitions. The bound is negative when the sum of KL terms is larger in magnitude than the error terms. Note that as $k$ becomes larger, the number of observations of $\theta ^ { * }$ “overpowers” the distracting transitions in the prompt distribution. This condition is equivalent to the disinguishability condition (Condition 1). + +By assumption, for $\theta \neq \theta ^ { * }$ the Condition 1 holds, and thus + +$$ +\operatorname* { l i m } _ { n \to \infty } \frac { p ( S _ { n } , x _ { \mathrm { t e s t } } | \theta ) } { p ( S _ { n } , x _ { \mathrm { t e s t } } | \theta ^ { * } ) } { = } \operatorname* { l i m } _ { n \to \infty } \exp ( n { \cdot } r _ { n } ( \theta ) ) { = } 0 +$$ + +since $r _ { n } ( \theta )$ has a negative, constant limit. Note that $\exp ( n \cdot r _ { n } ( \theta ^ { * } ) ) = 1$ for $\theta ^ { * }$ + +# E NON-DISTINGUISHABLE CASE + +When Condition 1 is unsatisfied, Equation 14), gives an upper bound on the sum of KL divergences for the next token distributions given different-length histories. In contrast, the in-context task only measures the accuracy of the last ( $k$ -th) token. The main challenge is to relate the different-length histories to each other to give a more precise bound for the error on the in-context task (last token). + +Before addressing this challenge, we give the following lemma, which leverages the result of Avila ´ Pires & Szepesvari (2016); Steinwart (2007) to relate a bound on the KL divergence to 0-1 loss. ´ + +Lemma 2. Let the set of $\theta$ which does not satisfy Condition $^ { l }$ to be $B _ { \cdot }$ . Assume that $K L ( p _ { p r o m p t } ( y _ { t e s t } | x _ { t e s t } ) | | p ( y _ { t e s t } | x _ { t e s t } , \theta )$ is bounded above for all $\theta$ and that $\theta ^ { * }$ minimizes the multiclass logistic risk $L _ { C E } ( \theta ) = - \mathbb { E } _ { x _ { t e s t } \sim p _ { p r o m p t } } [ p _ { p r o m p t } ( y _ { t e s t } | x _ { t e s t } ) \mathrm { l o g } p ( y _ { t e s t } | x _ { t e s t } , \theta ) ] .$ If + +$$ +\mathbb { E } _ { x _ { t e s t } \sim p _ { p r o m p t } } [ K L ( p _ { p r o m p t } ( y _ { t e s t } | x _ { t e s t } ) | | p ( y _ { t e s t } | x _ { t e s t } , \theta ) ) ] \le \epsilon _ { \theta } f o r a l l \theta \in \mathcal { B } , +$$ + +then + +$$ +\operatorname* { l i m } _ { n \to \infty } L _ { O - I } ( f _ { n } ) \underset { f } { \leq } \operatorname* { i n f } _ { f } L _ { O - I } ( f ) + g ^ { - 1 } \left( \underset { \theta \in \mathcal { B } } { \operatorname* { s u p } } \epsilon _ { \theta } \right) +$$ + +where + +$$ +g ( \delta ) = \frac { 1 } { 2 } ( ( 1 - \delta ) \mathrm { l o g } ( 1 - \delta ) + ( 1 + \delta ) \mathrm { l o g } ( 1 + \delta ) ) +$$ + +is a calibration function for the multiclass logistic loss for $\delta \in [ 0 , 1 ]$ . + +Proof. First, we note that we can study the 0-1 risk of the limiting predictor: + +$$ +\begin{array} { r l r } & { } & { \underset { n \infty } { \operatorname* { l i m } } L _ { 0 - 1 } ( f _ { n } ) = \underset { n \infty } { \operatorname* { l i m } } \mathbb { E } _ { x _ { \mathrm { t e s t } } , y _ { \mathrm { t e s t } } \sim p _ { \mathrm { p r o m p t } } } [ { \bf 1 } [ f _ { n } ( x _ { \mathrm { t e s t } } ) \neq y _ { \mathrm { t e s t } } ] ] } \\ & { } & { = \mathbb { E } _ { x _ { \mathrm { t e s t } } , y _ { \mathrm { t e s t } } \sim p _ { \mathrm { p r o m p t } } } [ \underset { n \infty } { \operatorname* { l i m } } { \bf 1 } [ f _ { n } ( x _ { \mathrm { t e s t } } ) \neq y _ { \mathrm { t e s t } } ] ] } \\ & { } & { = \mathbb { E } _ { x _ { \mathrm { t e s t } } , y _ { \mathrm { t e s t } } \sim p _ { \mathrm { p r o m p t } } } [ { \bf 1 } [ \underset { n \infty } { \operatorname* { l i m } } f _ { n } ( x _ { \mathrm { t e s t } } ) \neq y _ { \mathrm { t e s t } } ] ] } \end{array} +$$ + +(dominated convergence, boundedness of indicator) + +where in the last step we use that since the output space of $f _ { n }$ is discrete and the probabilities that the in-context predictor takes an argmax over converges, then for $N$ large enough, $f _ { N } ( x _ { \mathrm { t e s t } } ) { = } \operatorname* { l i m } _ { n \infty } f _ { n } ( x _ { \mathrm { t e s t } } )$ . + +Note that for every input $x _ { \mathrm { t e s t } }$ , the limiting in-context learning predictor outputs the argmax of a predictive distribution which can be a mixture of predictive distributions over $\boldsymbol { B }$ : + +$$ +\operatorname* { l i m } _ { n \infty } f _ { n } ( x _ { \mathrm { t e s t } } ) { = } \underset { y } { \operatorname { a r g m a x } } \mathbb { E } _ { \theta \sim q } [ p ( y | x _ { \mathrm { t e s t } } , \theta ) ] +$$ + +for some distribution $q$ over $\boldsymbol { B }$ . The KL divergence between this mixture and the prompt concept is bounded by the KL divergence of any one $\theta \in B$ , due to the convexity of KL: + +$$ +\begin{array} { r l } { \mathbb { E } _ { x _ { \mathrm { t e s t } } \sim p _ { \mathrm { p r o m p t } } } [ K L ( p _ { \mathrm { p r o m p t } } ( y | x _ { \mathrm { t e s t } } ) | | \mathbb { E } _ { \theta \sim q } [ p ( y | x _ { \mathrm { t e s t } } , \theta ) ] ] } & { } \\ & { \le \mathbb { E } _ { x _ { \mathrm { t e s t } } \sim p _ { \mathrm { p r o m p t } } } [ \mathbb { E } _ { \theta \sim q } [ K L ( p _ { \mathrm { p r o m p t } } ( y | x _ { \mathrm { t e s t } } ) | | p ( y | x _ { \mathrm { t e s t } } , \theta ) ) ] ] } \\ & { = \mathbb { E } _ { \theta \sim q } [ \mathbb { E } _ { x _ { \mathrm { t s t } } \sim p _ { \mathrm { p r o m p t } } } [ K L ( p _ { \mathrm { p r o m p t } } ( y | x _ { \mathrm { t e s t } } ) | | p ( y | x _ { \mathrm { t e s t } } , \theta ) ) ] ] } \\ & { \le \operatorname* { s u p } _ { \theta \in \mathcal { B } } \mathbb { E } _ { x _ { \mathrm { t e s t } } \sim p _ { \mathrm { p r o m p t } } } [ K L ( p _ { \mathrm { p r o m p t } } ( y | x _ { \mathrm { t e s t } } ) | | p ( y | x _ { \mathrm { t e s t } } , \theta ) ) ] } \end{array} +$$ + +where we can exchange the order of expectations since the $\mathrm { K L }$ is bounded (dominated convergence). + +From the KL bound $K L ( p _ { \mathrm { p r o m p t } } ( y _ { \mathrm { t e s t } } | x _ { \mathrm { t e s t } } ) | | p ( y _ { \mathrm { t e s t } } | x _ { \mathrm { t e s t } } , \theta )$ , we thus have + +$$ +\mathbb { E } _ { x _ { \mathrm { t e x t } } \sim p _ { \mathrm { p r o m p t } } } [ K L ( p _ { \mathrm { p r o m p t } } ( y _ { \mathrm { t e s t } } | x _ { \mathrm { t e s t } } ) | | p ( y _ { \mathrm { t e s t } } | x _ { \mathrm { t e s t } } , \theta ) ) ] = L _ { \mathrm { C E } } ( \theta ) - L _ { \mathrm { C E } } ( \theta ^ { * } ) \le \operatorname* { s u p } _ { \theta \in \mathcal { B } } \epsilon _ { \theta ^ { * } } +$$ + +where $L _ { \mathrm { C E } } ( \theta ) = - \mathbb { E } _ { x _ { \mathrm { t e s t } } \sim p _ { \mathrm { p r o m p t } } } [ p _ { \mathrm { p r o m p t } } ( y _ { \mathrm { t e s t } } | x _ { \mathrm { t e s t } } ) \log p ( y _ { \mathrm { t e s t } } | x _ { \mathrm { t e s t } } , \theta ) ]$ is the multiclass logistic risk, and $L _ { \mathrm { C E } } ( \theta ^ { * } )$ is the optimal risk over $\theta \in \Theta$ by assumption. Applying Theorem 2.2 and 5.11 of Avila ´ Pires & Szepesvari (2016), ´ $g$ is a calibration function for the multiclass logistic loss, and allows us to convert the surrogate risk bound to a bound on the 0-1 loss, giving the result. Note that we have zero approximation error here, since $\theta ^ { * } \in \Theta$ . □ + +Note that $g ^ { - 1 }$ is roughly linear in $\epsilon$ for $\epsilon$ smaller than 0.7, where the bound is non-vacuous. + +# E.1 PROOF OF THEOREM 2 + +Proof. By the continuity assumption, we have for any $\theta$ in $\boldsymbol { B }$ that + +$$ +\begin{array} { r l } & { \displaystyle \sum _ { j = 2 } ^ { k } K L _ { j } ( \theta ^ { * } \| \theta ) \ge \frac { 1 } { 2 } \sum _ { j = 2 } ^ { k } ( \theta - \theta ^ { * } ) ^ { \top } I _ { j , \theta ^ { * } } \left( \theta - \theta ^ { * } \right) + ( k - 1 ) O ( \| \theta - \theta ^ { * } \| ^ { 3 } ) } \\ & { \qquad \ge \frac { 1 } { 2 } ( k - 1 ) \lambda _ { \operatorname* { m i n } } ( I _ { j , \theta ^ { * } } ) \| \theta - \theta ^ { * } \| ^ { 2 } } \\ & { \displaystyle \Longrightarrow \| \theta - \theta ^ { * } \| ^ { 2 } \le \frac { \epsilon _ { \mathrm { s t a r t } } ^ { \theta } + \epsilon _ { \mathrm { d i m } } ^ { \theta } } { \frac { 1 } { 2 } ( k - 1 ) ( \operatorname* { m i n } _ { j } \lambda _ { \operatorname* { m i n } } \left( I _ { j , \theta ^ { * } } \right) ) } . } \end{array} +$$ + +We use this to bound the last KL term by plugging it in below: + +$$ +\begin{array} { r l } & { K L _ { k } ( \theta ^ { * } \| \theta ) = \displaystyle \frac { 1 } { 2 } ( \theta - \theta ^ { * } ) ^ { \top } I _ { j , \theta ^ { * } } ( \theta - \theta ^ { * } ) + O ( \| \theta - \theta ^ { * } \| ^ { 3 } ) } \\ & { \qquad \le \displaystyle \frac { 1 } { 2 } ( \operatorname* { m a x } _ { j } \lambda _ { \operatorname* { m a x } } ( I _ { j , \theta ^ { * } } ) ) \| \theta - \theta ^ { * } \| ^ { 2 } + O ( \| \theta - \theta ^ { * } \| ^ { 2 } ) } \\ & { \qquad \le \displaystyle \frac { \left( \epsilon _ { \mathrm { s t a r t } } ^ { \theta } + \epsilon _ { \mathrm { d i m } } ^ { \theta } \right) ( \operatorname* { m a x } _ { j } \lambda _ { \operatorname* { m a x } } ( I _ { j , \theta ^ { * } } ) + O ( 1 ) ) } { ( k - 1 ) \operatorname* { m i n } _ { j } \lambda _ { \operatorname* { m i n } } ( I _ { j , \theta ^ { * } } ) } . } \end{array} +$$ + +Rearranging and noting that $K L _ { k } ( \theta ^ { * } | | \theta ) = \mathbb { E } _ { x _ { \mathrm { t e s t } } \sim p _ { \mathrm { p r o m p } } } [ K L ( p _ { \mathrm { p r o m p t } } ( y _ { \mathrm { t e s t } } | x _ { \mathrm { t e s t } } ) | | p ( y _ { \mathrm { t e s t } } | x _ { \mathrm { t e s t } } , \theta ) ) ]$ , we have + +$$ +\mathbb { E } _ { x _ { \mathrm { t e a r } } \sim p _ { \mathrm { r o r a r g } } } [ K L ( p _ { \mathrm { p r o m p t } } ( y _ { \mathrm { t e s t } } | x _ { \mathrm { t e s t } } ) | | p ( y _ { \mathrm { t e s t } } | x _ { \mathrm { t e s t } } , \theta ) ) ] \le \frac { ( \epsilon _ { \mathrm { s t a r } } ^ { \theta } + \epsilon _ { \mathrm { d e l i m } } ^ { \theta } ) ( \operatorname* { m a x } _ { j } \lambda _ { \operatorname* { m a x } } ( I _ { j , \theta ^ { \star } } ) + O ( 1 ) ) } { ( k - 1 ) \operatorname* { m i n } _ { j } \lambda _ { \operatorname* { m i n } } ( I _ { j , \theta ^ { \star } } ) } +$$ + +Plugging into Lemma 2 gives the result. + +# E.2 PROOF OF THEOREM 3 + +Note that Condition 1 ensures that the sum of KL divergences between positions within a $k$ -length input is bounded. This means that we have a bound over not only the last-position KL divergence, but also for all the intermediate tokens. Intuitively, the random length test example allows the in-context predictor to “take credit” for fitting the intermediate tokens. The proof is immediate given the KL bound and Lemma 2, given that the length of $x _ { \mathrm { t e s t } }$ is uniformly random between 2 to $k$ . + +Proof. Let the set of $\theta$ that does not satisfy Condition 1 to be $\boldsymbol { B }$ . We have for any $\theta$ in $\boldsymbol { B }$ that + +$$ +\begin{array} { r l r } { { \mathbb { E } _ { x _ { \mathrm { t s t } } \sim p _ { \mathrm { p r o m p } } } [ K L ( p _ { \mathrm { p r o m p r } } ( y _ { \mathrm { t s t } } | x _ { \mathrm { t s t } } ) \| p ( y _ { \mathrm { t s t } } | x _ { \mathrm { t s t } } , \theta ) ) ] } \quad } & { ( 1 ! \cdot \langle x _ { \mathrm { p r o m p } } ( y _ { \mathrm { t s t } } | x _ { \mathrm { t s t } } ) \rangle ) } \\ & { } & { \leq \frac { 1 } { k - 1 } \sum _ { j = 2 } ^ { k } \mathbb { E } _ { O [ 1 : j - 1 ] \sim p _ { \mathrm { p r o m p } } } K L ( p _ { \mathrm { p r o m p t } } ( O [ j ] | O [ 1 : j - 1 ] ) \| p ( O [ j ] | O [ 1 : j - 1 ] , \theta ) ) } \\ & { } & { ( 1 ! \cdot \langle x _ { \mathrm { t s t } } ^ { \theta } + \epsilon _ { \mathrm { d e t i m i } } ^ { \theta } \rangle _ { \mathrm { ~ a ~ n ~ d ~ e ~ l ~ i ~ c ~ a ~ t ~ } } ) } \\ & { } & { ~ ( 1 ! - 1 ) } \end{array} +$$ + +by Theorem 1 and Condition 1. Plugging this into Lemma 2 gives the result. + +# F EXPERIMENTAL DETAILS + +# F.1 GINC DATASET + +Pretraining distribution. We consider a pretraining distribution from a mixture of HMMs with an interpretable hidden state structure and emission distribution. The HMM hidden state $h _ { t } = [ s _ { t } , v _ { t } ]$ at time $t$ is composed of an entity $v _ { t } \in \{ 1 , . . . , | \nu | \}$ (e.g., Einstein) and a property $s _ { t } \in \{ 1 , . . . , | S | \}$ (e.g., nationality, first name, last name, other grammatical tokens). We model the entities and properties as independent Markov chains (i.e., a factorial HMM (Ghahramani & Jordan, 1997)), while the emissions depend on both. In pretraining documents, we expect that the entities (e.g., Einstein) change slowly over time while and the properties of the entity (e.g., their nationality) change quickly with some pattern to generate + +# Pretraining document + +# In-context Prompt + +![](images/b09e28b372405917cb5ea6ab15c79a3b88d003c439b3a0fce47db9aae5f4c168.jpg) +Figure 8: Example pretraining document snippet (Left) and example prompt with 3 training examples, 1 test example, and example length 3 (Right). The delimiter token is the backslash. + +l aw ac / ax aj ae / ac j + +![](images/94df93077f930f0fb260478aa917b326cb2ba696835ec842b6ffbbfcc3692e50.jpg) +Figure 9: The GINC dataset generates sequences from a mixture of HMMs. The HMM hidden states consist of entities $( v )$ and properties (s), which index into a memory matrix to produce the observed token. The entity and property sequences are sampled from independent Markov chains. The concept parameter $\theta$ is the transition matrix for properties, which defines relations between properties. In this example, the sequence of properties [2,3,5,4] relates names to nationalities, defining the in-context task. The blue color represents hidden states/observations sampled from the prompt distribution, and the purple color represents hidden states/observations sampled from the pretraining distribution. + +natural sentences. We implement this by ensuring that the probability of transitioning to the same entity index in the next step is at least 0.9. The emission distribution depends on a memory matrix $M$ with $| \nu |$ rows and $| S |$ columns (Figure 9). At step $t$ , we use the entity $v _ { t }$ and property $s _ { t }$ to index into the memory matrix. In particular, the observed tokens are deterministic with $p ( o _ { t } | h _ { t } ) = 1$ if $o _ { t } = M [ v _ { t } , s _ { t } ]$ . This construction satisfies the structure on delimiter states (Assumption 1). We ensure that all the transitions have nonzero probability and use a uniform prior over concepts, satisfying Assumptions 2 and 5. + +Concept parameter. The concept parameter is the property transition matrix, while the entity transition matrix is fixed for all concepts. The prompt start distribution and the concept together determine the in-context task. We define a uniform mixture of HMMs over a family $\Theta$ of 5 concepts to generate 1000 documents with ${ \sim } 1 0$ million tokens total. + +Vocabulary. The GINC dataset is generated from a mixture of HMMs. These HMMs output tokens from a vocabulary of size in $\{ 5 0 , 1 0 0 , \bar { 1 } 5 0 \}$ . The vocabulary contains a special delimiter token (backslash – see Figure 8, designated to be index 1. The vocabulary is generated as combinations of letters starting from a to z, then aa to az, and so on. All sequences are tokenized by splitting on whitespaces. + +![](images/1c18a8a2c6ea76a84d9433fda0d53b3541dd8fa6594e471d41f6fde733bb9aaa.jpg) +Figure 10: In-context accuracy curve of the 4 layer Transformer on the GINC dataset when the entity transition matrix does not have an additional identity component, for vocabulary sizes 50 (left), 100 (middle), and 150 (right). In-context learning is still generally successful. + +Memory matrix. The shared memory matrix has 10 entities and 10 properties, totaling 100 entries (corresponding to 100 hidden states). The first column of the memory matrix is fixed to be the delimiter token, while each remaining entry of the shared memory matrix is populated with a token sampled uniformly from the vocabulary. + +Transition matrix for properties. We generate 5 property transition matrices, one for each component of the HMM mixture. We generate each transition matrix via a convex combination of 100 random permutation matrices. The weights of the convex combination are randomly generated as + +$$ +\operatorname { s o f t m a x } ( ( u - 0 . 5 ) / t ) +$$ + +where $u \in \mathbb { R } ^ { 1 0 0 }$ has uniform random entries in [0,1] and $t$ is a temperature parameter, set to 0.1. + +Transition matrix for entities. The entity transition matrix is shared between all the HMMs that consistute the mixture. The entity transition matrix is generated in the same way as the property transition matrices, except with one additional step. Letting $T$ be a transition matrix sampled in the same way as a property transition matrix, + +In pretraining documents, we expect that the entities (e.g., Einstein) change slowly over time while and the properties of the entity (e.g., their occupation) change quickly with some pattern to generate natural sentences. We implement this by ensuring that the probability of transitioning to the same entity index in the next step is at least 0.9. The final entity transition matrix is then $0 . 1 T + 0 . 9 I$ where $I$ is the identity matrix. Although we add the diagonal component for added realism, we also consider not adding this component. Figure 10 shows in-context learning curves for a small (4 layer) Transformer trained on data that does not add the diagonal component (we check this for vocabulary sizes 50, 100, and 150). In-context learning still works in this case, although not as well for the 50 vocab size case. + +Start distribution. The starting distribution for the hidden states in all HMMs in the mixture are close to uniform. We generate the start distribution as softmax $\left( ( u - 0 . 5 ) / t \right)$ for random vector $u$ with entries uniformly from [0,1] and temperature $t = 1 0$ . In the pretraining documents, we only sample from the start distribution in the beginning of the document. + +Prompt distribution. To generate the prompts, we first sample a concept $\theta$ uniformly at random from $\Theta$ (well-specification, Assumption 4), then use it to generate all the prompt examples. The prompt start distribution is chosen to be uniform over entities but with a fixed starting property that is chosen randomly for each prompt, for consistency in the task. This may not satisfy Assumption 3, but we found this to still work empirically and is simpler. Given the starting property, we sample $k$ tokens from the HMM defined by the concept $\theta$ . Finally, we append the delimiter token for the example. We repeat this process for each example in the prompt, concatenating all examples. The label is generated as + +$$ +\underset { y } { \mathrm { a r g m a x } } \ p _ { \mathrm { p r o m p t } } ( y | x _ { \mathrm { t e s t } } ) +$$ + +under the prompt concept $\theta ^ { * }$ . This differs from the theory, which samples $y _ { \mathrm { t e s t } }$ instead of taking it to be the most likely token. However, there can be a large amount of intrinsic error that sampling introduces. We define the label this way in the simulations to remove the intrinsic error from sampling. + +Example of prompt generation. In the example in Figure 8 (right), the starting property is fixed to be 5 (for example). The first token (l) is generated by sampling a random entity index (3), and indexing into the memory matrix returns l. Running the hidden state chain of the HMM forward gives the next pair of property and entity. Since the entity Markov chain changes slowly, the entity is still 3 in the next step – however, the property has changed to 4, and indexing into the memory matrix outputs the next token (aw). Following this same process to generate the third token (the output for the first example), we finish generating one example. To end the example, we append a delimiter (backslash). We repeat this example generation process for all the examples, except for the test example at the end, where we do not generate the last token. We condition the HMM on the generated prompt to compute the posterior distribution over the next token $p _ { \mathrm { p r o m p t } } ( y | x _ { \mathrm { t e s t } } )$ . We take the argmax of this distribution to be the ground truth label. + +Dataset details. The dataset contains 1000 training documents and 100 validation documents, where training documents have 10240 tokens and validation documents have 1024 tokens. Each document is generated by first selecting one of the HMMs from the mixture uniformly at random, then generating 10240 tokens from the HMM. + +We also generate 2500 in-context prompts for each (example length,number of examples) pair, for example lengths $k = [ 3 , 5 , 8 , 1 0 ]$ and number of examples n = [0,1,2,4,8,16,32,64]. Each prompt is generated using a random HMM in the mixture. + +# F.2 TRANSFORMER DETAILS + +Our Transformer models are based on the GPT-2 architectures with 4, 12, and 16 layers respectively, with 12 attention heads, 768 dimensional embeddings, residual/embedding/attention dropout set to 0.1, and a context window of 1024. Other than the number of layers, the other parameters are the default settings from the HuggingFace library (Wolf et al., 2019). We train for 5 epochs using the AdamW optimizer (Loshchilov & Hutter, 2019; Kingma & Ba, 2015) with a batch size of 8 and a linear learning rate schedule (with 1000 step warmup) up to a learning rate of 8e-4 for the 4 layer and 12 layer model, while for the 16 layer model we start with a constant learning rate of 8e-4 and reduce by a factor of 0.25 whenever the best validation loss does not improve. We tried both learning rate strategies for all models and take the most consistent. We tuned these models so that the training loss curves between seeds have smaller variability between the runs in terms of the curve shape and when the loss decreases – we found that this is an important indication of stable results. The models took 50 minutes, 2 hours, 3 hours to train respectively. The hardware was mainly Titan Xp GPUs, trained and evaluated using 16-bit precision. All the results are reported with 5 pretraining runs (5 different seeds). + +# F.3 LSTM DETAILS + +We train an LSTM language model with embedding size 768, hidden layer size 768, and 6 layers. We use dropout 0.2 and weight decay 1e-5. The optimizer is AdamW starting with a learning rate of 1e-3, then reducing by a factor of 0.25 whenever the best validation loss does not go down. We train for a total of 10 epochs, with gradient clipping at norm 1.0. We use a batch size of 8 and backpropagate through time for 1024 steps (each pretraining data segment is also 1024 tokens). Each model takes roughly 2 hours to train on Titan Xp GPUs. + +# F.4 VARYING THE VOCABULARY SIZE + +To do well on the in-context learning task, the model must both infer the prompt concept and the last HMM hidden state. In general, increasing the number of observable symbols makes the in-context task easier by making the inference of the HMM hidden state easier. With more symbols, each hidden state is more likely to output a different symbol, making the inference problem easier. This improvement comes despite the number of output classes in the problem (same as the vocabulary size) increasing. Figures 11, 12, 13, 14 show in-context learning curves for vocabulary sizes 50, 100, and 150, keeping other hyperparmeters of the dataset the same. + +# F.5 EXPERIMENT ON GPT-3 + +We conduct an additional experiment which shows that longer examples improve in-context learning in GPT-3 on the LAMBADA (Paperno et al., 2016) completion task. + +Data. In this experiment, we define a short version of the LAMBADA test dataset (LAMBADA test-short) which contains only test examples with up to 200–300 characters in length. We also define two “training” datasets from which to sample examples for the in-context prompts from. The short training dataset (LAMBADA train-short) contains examples from the training set that are + +![](images/483919cb0b8be205024dbc80d102224785caf41a4e841c90b364e139ccec0f8f.jpg) +Figure 11: In-context accuracy of the 4 layer Transformer on the GINC dataset for vocabulary sizes 50 (left), 100 (middle) and 150 (right). Accuracies generally improve as the vocabulary size increases. + +![](images/bea22bf8fdd51721ec77a061eb0ab5ea3d897ca708cf8a98e2338e6ddf11e177.jpg) +Figure 12: In-context accuracy of the 12 layer Transformer on the GINC dataset for vocabulary sizes 50 (left), 100 (middle) and 150 (right). Accuracies generally improve as the vocabulary size increases. + +![](images/e3799000d12769435ce4004c9ab18392a27c968ed040af9abb3e729657d2f9ad.jpg) +Figure 13: In-context accuracy of the 16 layer Transformer on the GINC dataset for vocabulary sizes 50 (left), 100 (middle) and 150 (right). Accuracies generally improve as the vocabulary size increases. + +![](images/3d733ad47ccb0248361633badd98c0416990f86e6e1a69d310ea27a7b6074859.jpg) +Figure 14: In-context accuracy of the LSTM on the GINC dataset for vocabulary sizes 50 (left), 100 (middle) and 150 (right). Accuracies generally improve as the vocabulary size increases. + +200–300 characters in length, which matches the distribution of test-short. The long training dataset (LAMBADA train-long) contains training examples that are 500–600 characters long. We cut the number of examples in the larger of the two training datasets so that the two training datasets are equally sized (47 examples). For each test example, we sample 5 random training examples (5-shot learning). + +We also consider equalizing the total length of the prompts in two ways. First, we consider duplicating the 5 short examples (if the examples are [1,2,3,4,5], duplicating refers to [1,2,3,4,5,1,2,3,4,5]). This allows for equalizing the total length without increasing the number of examples. As a skyline comparison, we also consider sampling 10 independent short examples, which contains more input-output pairs for the task. + +Result. Table 1 shows that when evaluating only on LAMBADA test-short, 5-shot in-context learning using LAMBADA train-long improves the test accuracy by almost $1 \%$ compared to LAMBADA train-short, despite the long/short distribution mismatch between train and test. This supports intuitions from our theory. + +Table 1: Accuracies for 5-shot in-context learning of GPT-3 on a filtered LAMBADA test set with short examples (200–300 characters). Even though there is distribution mismatch with the test set, having longer examples improves the accuracy, supporting theoretical intuitions. The first two rows use 5 training examples in the prompt, while the last two rows use 10 training examples to equalize the total length. + +
Prompt example lengthTest Acc (200-300 chars)
5 examples
Short (200-300 chars)69.8
Long (500-600 chars)70.7
10 examples
Short, duplicated examples69.6
Short, independent examples71.4
+ +In comparison, simply increasing the total prompt length by duplicating the short examples does not improve the accuracy. Intuitively, the longer examples have additional information that is not directly related to mapping between the input and output, but can be leveraged to improve in-context learning by helping the model infer the latent concept. Using 5 long examples (as opposed to 5 short examples) closes about $56 \%$ of the gap between using 5 short examples and 10 independent short examples despite not adding additional examples or task-related information. \ No newline at end of file diff --git a/md/dev/SJ0Lde3tRL/SJ0Lde3tRL.md b/md/dev/SJ0Lde3tRL/SJ0Lde3tRL.md new file mode 100644 index 0000000000000000000000000000000000000000..e9c4f2ed55c6914cfa61e66f8ef73e74e42c52c1 --- /dev/null +++ b/md/dev/SJ0Lde3tRL/SJ0Lde3tRL.md @@ -0,0 +1,748 @@ +# EXTREME Q-LEARNING: MAXENT RL WITHOUT ENTROPY + +Divyansh Garg∗ Stanford University divgarg@stanford.edu + +Joey Hejna∗ Stanford University jhejna@stanford.edu + +Matthieu Geist +Google Brain +mfgeist@google.com + +Stefano Ermon Stanford University ermon@stanford.edu + +# ABSTRACT + +Modern Deep Reinforcement Learning (RL) algorithms require estimates of the maximal Q-value, which are difficult to compute in continuous domains with an infinite number of possible actions. In this work, we introduce a new update rule for online and offline RL which directly models the maximal value using Extreme Value Theory (EVT), drawing inspiration from economics. By doing so, we avoid computing Q-values using out-of-distribution actions which is often a substantial source of error. Our key insight is to introduce an objective that directly estimates the optimal soft-value functions (LogSumExp) in the maximum entropy RL setting without needing to sample from a policy. Using EVT, we derive our Extreme $Q$ -Learning framework and consequently online and, for the first time, offline MaxEnt Q-learning algorithms, that do not explicitly require access to a policy or its entropy. Our method obtains consistently strong performance in the D4RL benchmark, outperforming prior works by $^ { 1 0 + }$ points on the challenging Franka Kitchen tasks while offering moderate improvements over SAC and TD3 on online DM Control tasks. Visualizations and code can be found on our website 1. + +# 1 INTRODUCTION + +Modern Deep Reinforcement Learning (RL) algorithms have shown broad success in challenging control (Haarnoja et al., 2018; Schulman et al., 2015) and game-playing domains (Mnih et al., 2013). While tabular Q-iteration or value-iteration methods are well understood, state of the art RL algorithms often make theoretical compromises in order to deal with deep networks, high dimensional state spaces, and continuous action spaces. In particular, standard Q-learning algorithms require computing the max or soft-max over the Q-function in order to fit the Bellman equations. Yet, almost all current off-policy RL algorithms for continuous control only indirectly estimate the Q-value of the next state with separate policy networks. Consequently, these methods only estimate the $Q$ -function of the current policy, instead of the optimal $Q ^ { * }$ , and rely on policy improvement via an actor. Moreover, actor-critic approaches on their own have shown to be catastrophic in the offline settings where actions sampled from a policy are consistently out-of-distribution (Kumar et al., 2020; Fujimoto et al., 2018). As such, computing max $Q$ for Bellman targets remains a core issue in deep RL. + +One popular approach is to train Maximum Entropy (MaxEnt) policies, in hopes that they are more robust to modeling and estimation errors (Ziebart, 2010). However, the Bellman backup $B ^ { * }$ used in MaxEnt RL algorithms still requires computing the log-partition function over Q-values, which is usually intractable in high-dimensional action spaces. Instead, current methods like SAC (Haarnoja et al., 2018) rely on auxiliary policy networks, and as a result do not estimate $B ^ { * }$ , the optimal Bellman backup. Our key insight is to apply extreme value analysis used in branches of Finance and Economics to Reinforcement Learning. Ultimately, this will allow us to directly model the LogSumExp over Q-functions in the MaxEnt Framework. + +Intuitively, reward or utility-seeking agents will consider the maximum of the set of possible future returns. The Extreme Value Theorem (EVT) tells us that maximal values drawn from any exponential tailed distribution follows the Generalized Extreme Value (GEV) Type-1 distribution, also referred to as the Gumbel Distribution $\mathcal { G }$ . The Gumbel distribution is thus a prime candidate for modeling errors in Q-functions. In fact, McFadden’s 2000 Nobel-prize winning work in Economics on discrete choice models (McFadden, 1972) showed that soft-optimal utility functions with logit (or softmax) choice probabilities naturally arise when utilities are assumed to have Gumbel-distributed errors. This was subsequently generalized to stochastic MDPs by Rust (1986). Nevertheless, these results have remained largely unknown in the RL community. By introducing a novel loss optimization framework, we bring them into the world of modern deep RL. + +Empirically, we find that even modern deep RL approaches, for which errors are typically assumed to be Gaussian, exhibit errors that better approximate the Gumbel Distribution, see Figure 1. By assuming errors to be Gumbel distributed, we obtain Gumbel Regression, a consistent estimator over log-partition functions even in continuous spaces. Furthermore, making this assumption about $Q$ - values lets us derive a new Bellman loss objective that directly solves for the optimal MaxEnt Bellman operator $B ^ { * }$ , instead of the operator under the current policy $B ^ { \pi }$ . As soft optimality emerges from our framework, we can run MaxEnt RL independently of the policy. In the online setting, we avoid using a policy network to explicitly compute entropies. In the offline setting, we completely avoid sampling from learned policy networks, minimizing the aforementioned extrapolation error. Our resulting algorithms surpass or consistently match state-of-the-art (SOTA) methods while being practically simpler. + +In this paper we outline the theoretical motivation for using Gumbel distributions in reinforcement learning, and show how it can be used to derive practical online and offline MaxEnt RL algorithms. Concretely, our contributions are as follows: + +• We motivate Gumbel Regression and show it allows calculation of the log-partition function (LogSumExp) in continuous spaces. We apply it to MDPs to present a novel loss objective for RL using maximum-likelihood estimation. +• Our formulation extends soft-Q learning to offline RL as well as continuous action spaces without the need of policy entropies. It allows us to compute optimal soft-values $V ^ { * }$ and soft-Bellman updates $B ^ { * }$ using SGD, which are usually intractable in continuous settings. +• We provide the missing theoretical link between soft and conservative Q-learning, showing how these formulations can be made equivalent. We also show how Max-Ent RL emerges naturally from vanilla RL as a conservatism in our framework. +• Finally, we empirically demonstrate strong results in Offline RL, improving over prior methods by a large margin on the D4RL Franka Kitchen tasks, and performing moderately better than SAC and TD3 in Online RL, while theoretically avoiding actor-critic formulations. + +# 2 PRELIMINARIES + +In this section we introduce Maximium Entropy (MaxEnt) RL and Extreme Value Theory (EVT), which we use to motivate our framework to estimate extremal values in RL. + +We consider an infinite-horizon Markov decision process (MDP), defined by the tuple $( S , { \mathcal { A } } , { \mathcal { P } } , r , \gamma )$ , where $s , A$ represent state and action spaces, $\mathcal { P } ( \mathbf { s } ^ { \prime } | \mathbf { s } , \mathbf { a } )$ represents the environment dynamics, $r ( \mathbf { s } , \mathbf { a } )$ represents the reward function, and $\gamma \in ( 0 , 1 )$ represents the discount factor. In the offline RL setting, we are given a dataset $\mathcal { D } = ( \mathbf { s } , \mathbf { a } , r , \mathbf { s } ^ { \prime } )$ of tuples sampled from trajectories under a behavior policy $\pi _ { \mathcal { D } }$ without any additional environment interactions. We use $\rho _ { \pi } ( \mathbf { s } )$ to denote the distribution of states that a policy $\pi ( \mathbf { a } | \mathbf { s } )$ generates. In the MaxEnt framework, an MDP with entropy-regularization is referred to as a soft-MDP (Bloem & Bambos, 2014) and we often use this notation. + +# 2.1 MAXIMUM ENTROPY RL + +Standard RL seeks to learn a policy that maximizes the expected sum of (discounted) rewards $\mathbb { E } _ { \pi } \left[ \sum _ { t = 0 } ^ { \infty } \gamma ^ { t } r ( \mathbf { s } _ { t } , \mathbf { a } _ { t } ) \right]$ , for $\left( \mathbf { s } _ { t } , \mathbf { a } _ { t } \right)$ drawn at timestep $t$ from the trajectory distribution that $\pi$ generates. We consider a generalized version of Maximum Entropy RL that augments the standard reward objective with the KL-divergence between the policy and a reference distribution $\mu$ $\begin{array} { r } { \mathbb { E } _ { \pi } [ \sum _ { t = 0 } ^ { \infty } \gamma ^ { t } ( r ( \mathbf { s } _ { t } , \mathbf { a } _ { t } ) - \beta \log { \frac { \pi ( \mathbf { a } _ { t } | \mathbf { s } _ { t } ) } { \mu ( \mathbf { a } _ { t } | \mathbf { s } _ { t } ) } } ) ] } \end{array}$ , where $\beta$ is the regularization strength. When $\mu$ is uniform $\mathcal { U }$ , this becomes the standard MaxEnt objective used in online RL up to a constant. In the offline RL setting, we choose $\mu$ to be the behavior policy $\pi _ { \mathcal { D } }$ that generated the fixed dataset $\mathcal { D }$ . Consequently, this objective enforces a conservative KL-constraint on the learned policy, keeping it close to the behavior policy (Neu et al., 2017; Haarnoja et al., 2018). + +In MaxEnt RL, the soft-Bellman operator $\boldsymbol { B ^ { * } } : \mathbb { R } ^ { S \times A } \mathbb { R } ^ { S \times A }$ is defined as $( B ^ { * } Q ) ( { \bf s } , { \bf a } ) = r ( { \bf s } , { \bf a } ) +$ $\gamma \mathbb { E } _ { \mathbf { s } ^ { \prime } \sim \mathcal { P } ( \cdot \vert \mathbf { s } , \mathbf { a } ) } V ^ { * } ( \mathbf { s } ^ { \prime } )$ where $Q$ is the soft-Q function and $V ^ { * }$ is the optimal soft-value satisfying: + +$$ +V ^ { \ast } ( \mathbf { s } ) = \beta \log \sum _ { \mathbf { a } } \mu ( \mathbf { a } | \mathbf { s } ) \exp \left( Q ( \mathbf { s } , \mathbf { a } ) / \beta \right) : = \mathbb { L } _ { a \sim \mu ( \cdot | \mathbf { s } ) } ^ { \beta } \left[ Q ( \mathbf { s } , \mathbf { a } ) \right] , +$$ + +where we denote the log-sum-exp (LSE) using an operator $\mathbb { L } ^ { \beta }$ for succinctness2. The soft-Bellman operator has a unique contraction $Q ^ { * }$ (Haarnoja et al., 2018) given by the soft-Bellman equation: $Q ^ { * } = B ^ { * } Q ^ { * }$ and the optimal policy satisfies (Haarnoja et al., 2017): + +$$ +\pi ^ { * } ( \mathbf { a } | \mathbf { s } ) = \mu ( \mathbf { a } | \mathbf { s } ) \exp { \big ( } ( Q ^ { * } ( \mathbf { s } , \mathbf { a } ) - V ^ { * } ( \mathbf { s } ) ) / \beta { \big ) } . +$$ + +Instead of estimating soft-values for a policy $\begin{array} { r } { V ^ { \pi } ( \mathbf { s } ) \ = \ \mathbb { E } _ { \mathbf { a } \sim \pi ( \cdot | \mathbf { s } ) } \left[ Q ( \mathbf { s } , \mathbf { a } ) - \beta \log \frac { \pi ( \mathbf { a } | \mathbf { s } ) } { \mu ( \mathbf { a } | \mathbf { s } ) } \right] } \end{array}$ , our approach will seek to directly fit the optimal soft-values $V ^ { * }$ , i.e. the log-sum-exp (LSE) of $\mathrm { Q }$ values. + +# 2.2 EXTREME VALUE THEOREM + +The Fisher-Tippett or Extreme Value Theorem tells us that the maximum of i.i.d. samples from exponentially tailed distributions will asymptotically converge to the Gumbel distribution ${ \mathcal { G } } ( \mu , \beta )$ , which has PDF $p ( x ) = \exp ( - ( z + e ^ { - z } ) )$ where $z = { \bar { ( } } x - \mu { \bar { ) } } { \bar { / } } \beta$ with location parameter $\mu$ and scale parameter $\beta$ . + +Theorem 1 (Extreme Value Theorem (EVT) (Mood, 1950; Fisher & Tippett, 1928)). For i.i.d. random variables $X _ { 1 } , . . . , X _ { n } \sim f _ { X }$ , with exponential tails, $\scriptstyle \operatorname* { l i m } _ { n \to \infty } \operatorname* { m a x } _ { i } ( X _ { i } )$ follows the Gumbel (GEV-1) distribution. Furthermore, $\mathcal { G }$ is max-stable, i.e. if $X _ { i } \sim \mathcal { G }$ , then $\operatorname* { m a x } _ { i } ( X _ { i } ) \sim \mathcal G$ holds. + +This result is similar to the Central Limit Theorem (CLT), which states that means of i.i.d. errors approach the normal distribution. Thus, under a chain of max operations, any i.i.d. exponential tailed errors3 will tend to become Gumbel distributed and stay as such. EVT will ultimately suggest us to characterize nested errors in Q-learning as following a Gumbel distribution. In particular, the Gumbel distribution $\mathcal { G }$ exhibits unique properties we will exploit. + +One intriguing consequence of the Gumbel’s max-stability is its ability to convert the maximum over a discrete set into a softmax. This is known as the Gumbel-Max Trick (Papandreou & Yuille, 2010; Hazan & Jaakkola, 2012). Concretely for i.i.d. $\epsilon _ { i } \sim \mathcal { G } ( 0 , \beta )$ added to a set $\{ x _ { 1 } , . . . , x _ { n } \} \in \mathbb { R }$ $\begin{array} { r } { \operatorname* { m a x } _ { i } ( x _ { i } + \epsilon _ { i } ) \sim \mathcal { G } ( \beta \log \sum _ { i } \exp { ( x _ { i } / \beta ) } , \beta ) } \end{array}$ , and argmax $( x _ { i } + \epsilon _ { i } ) \sim$ softmax $( x _ { i } / \beta )$ . Furthermore, the Max-trick is unique to the Gumbel (Luce, 1977). These properties lead into the McFadden-Rust model (McFadden, 1972; Rust, 1986) of MDPs as we state below. + +McFadden-Rust model: An MDP following the standard Bellman equations with stochasticity in the rewards due to unobserved state variables will satisfy the soft-Bellman equations over the observed state with actual rewards ${ \bar { r } } ( \mathbf { s } , \mathbf { a } )$ , given two conditions: + +1. Additive separability (AS): observed rewards have additive i.i.d. Gumbel noise, i.e. $r ( \mathbf { s } , \mathbf { a } ) = \bar { r } ( \mathbf { s } , \mathbf { a } ) + \epsilon ( \mathbf { s } , \mathbf { a } )$ , with actual rewards ${ \bar { r } } ( \mathbf { s } , \mathbf { a } )$ and i.i.d. noise $\epsilon ( \mathbf { s } , \mathbf { a } ) \sim \mathcal { G } ( 0 , \beta )$ . +2. Conditional Independence (CI): the noise $\epsilon ( \mathbf { s } , \mathbf { a } )$ in a given state-action pair is conditionally independent of that in any other state-action pair. + +Moreover, the converse also holds: Any MDP satisfying the Bellman equations and following a softmax policy, necessarily has any i.i.d. noise in the rewards with $A S + C I$ conditions be Gumbel distributed. These results were first shown to hold in discrete choice theory by McFadden (1972), with the $A S + C I$ conditions derived by Rust (1986) for discrete MDPs. We formalize these results in Appendix A and give succinct proofs using the developed properties of the Gumbel distribution. These results enable the view of a soft-MDP as an MDP with hidden i.i.d. Gumbel noise in the rewards. Notably, this result gives a different interpretation of a soft-MDP than entropy regularization to allow us to recover the soft-Bellman equations. + +# 3 EXTREME Q-LEARNING + +In this section, we motivate our Extreme Q-learning framework, which directly models the softoptimal values $V ^ { * }$ , and show it naturally extends soft-Q learning. Notably, we use the Gumbel distribution to derive a new optimization framework for RL via maximum-likelihood estimation and apply it to both online and offline settings. + +# 3.1 GUMBEL ERROR MODEL + +Although assuming Gumbel errors in MDPs leads to intriguing properties, it is not obvious why the errors might be distributed as such. First, we empirically investigate the distribution of Bellman errors by computing them over the course of training. Specifically, we compute $r ( { \bf s } , { \bf a } ) \ - \ \gamma Q ( { \bf s } ^ { \prime } , \pi ( { \bf s } ^ { \prime } ) ) \ { \bar { - } } \ Q ( { \bf s } , { \bf a } )$ for samples $( \mathbf { s } , \mathbf { a } , \mathbf { s } ^ { \prime } )$ from the replay-buffer using a single $Q$ -function from SAC (Haarnoja et al., 2018) (See Appendix D for more details). In Figure 1, we find the errors to be skewed and better fit by a Gumbel distribution. We explain this using EVT. + +Consider fitting $Q$ -functions by learning an unbiased function approximator $\hat { Q }$ to solve the Bellman equation. We will assume access to $M$ such function approximators, each of which are assumed to be independent e.g. + +![](images/fd58e7b7964bae2cad9249c6634bd00716a46fc027aa93262cf0ca70a4d88c5c.jpg) +Figure 1: Bellman errors from SAC on Cheetah-Run (Tassa et al., 2018). The Gumbel distribution better captures the skew versus the Gaussian. Plots for TD3 and more environments can be found in Appendix D. + +parallel runs of a model over an experiment. We can see approximate Q-iteration as performing: + +$$ +\hat { Q } _ { t } ( \mathbf { s } , \mathbf { a } ) = \bar { Q } _ { t } ( \mathbf { s } , \mathbf { a } ) + \epsilon _ { t } ( \mathbf { s } , \mathbf { a } ) , +$$ + +where $\mathbb { E } [ \hat { Q } ] = \bar { Q } _ { t }$ is the expected value of our prediction $\hat { Q } _ { t }$ for an intended target $\bar { Q } _ { t }$ over our estimators, and $\epsilon _ { t }$ is the (zero-centered) error in our estimate. Here, we assume the error $\epsilon _ { t }$ comes from the same underlying distribution for each of our estimators, and thus are i.i.d. random variables with a zero-mean. Now, consider the bootstrapped estimate using one of our $\mathbf { M }$ estimators chosen randomly: + +$$ +\hat { B ^ { * } } \hat { Q } _ { t } ( \mathbf { s } , \mathbf { a } ) = r ( \mathbf { s } , \mathbf { a } ) + \gamma \operatorname* { m a x } _ { \mathbf { a } ^ { \prime } } \hat { Q } _ { t } ( \mathbf { s } ^ { \prime } , \mathbf { a } ^ { \prime } ) = r ( \mathbf { s } , \mathbf { a } ) + \gamma \operatorname* { m a x } _ { \mathbf { a } ^ { \prime } } ( \bar { Q } _ { t } ( \mathbf { s } ^ { \prime } , \mathbf { a } ^ { \prime } ) + \epsilon _ { t } ( \mathbf { s } ^ { \prime } , \mathbf { a } ^ { \prime } ) ) . +$$ + +We now examine what happens after a subsequent update. At time $t + 1$ , suppose that we fit a fresh set of $M$ independent functional approximators $\bar { \hat { Q } } _ { t + 1 }$ with the target $\hat { B ^ { * } Q _ { t } }$ , introducing a new unbiased error $\epsilon _ { t + 1 }$ . Then, for $\bar { Q } _ { t + 1 } = \mathbb { E } [ \hat { Q } _ { t + 1 } ]$ it holds that + +$$ +\bar { Q } _ { t + 1 } ( \mathbf { s } , \mathbf { a } ) = r ( \mathbf { s } , \mathbf { a } ) + \gamma \mathbb { E } _ { \mathbf { s } ^ { \prime } | \mathbf { s } , \mathbf { a } } [ \mathbb { E } _ { \epsilon _ { t } } [ \operatorname* { m a x } _ { \mathbf { a } ^ { \prime } } ( \bar { Q } _ { t } ( \mathbf { s } ^ { \prime } , \mathbf { a } ^ { \prime } ) + \epsilon _ { t } ( \mathbf { s } ^ { \prime } , \mathbf { a } ^ { \prime } ) ) ] ] . +$$ + +As $\bar { Q } _ { t + 1 }$ is an expectation over both the dynamics and the functional errors, it accounts for all uncertainty (here $\mathbb { E } [ \epsilon _ { t + 1 } ] = 0 .$ ). But, the i.i.d. error $\epsilon _ { t }$ remains and will be propagated through the Bellman equations and its chain of max operations. Due to Theorem 1, $\epsilon _ { t }$ will become Gumbel distributed in the limit of $t$ , and remain so due to the Gumbel distribution’s max-stability.4 + +This highlights a fundamental issue with approximation-based RL algorithms that minimize the MeanSquared Error (MSE) in the Bellman Equation: they implicitly assume, via maximum likelihood estimation, that errors are Gaussian. In Appendix A, we further study the propagation of errors using the McFadden-Rust MDP model, and use it to develop a simplified Gumbel Error Model (GEM) for errors under functional approximation. In practice, the Gumbel nature of the errors may be weakened as estimators between timesteps share parameters and errors will be correlated across states and actions. + +# 3.2 GUMBEL REGRESSION + +The goal of our work is to directly model the log-partition function (LogSumExp) over $Q ( s , a )$ to avoid all of the aforementioned issues with taking a max in the function approximation domain. + +![](images/21e11a4df56b4f538cc310d316fd4ba7569d9df60f9febeb6fe7996870d52bd5.jpg) +Figure 2: Left: The pdf of the Gumbel distribution with $\mu = 0$ and different values of $\beta$ . Center: Our Gumbel loss for different values of $\beta$ . Right: Gumbel regression applied to a two-dimensional random variable for different values of $\beta$ . The smaller the value of $\beta$ , the more the regression fits the extrema. + +In this section we derive an objective function that models the LogSumExp by simply assuming errors follow a Gumbel distribution. Consider estimating a parameter $h$ for a random variable $X$ using samples $x _ { i }$ from a dataset $\mathcal { D }$ , which have Gumbel distributed noise, i.e. $x _ { i } = h + \epsilon _ { i }$ where $\epsilon _ { i } \sim - \mathscr { G } ( 0 , \beta )$ . Then, the average log-likelihood of the dataset $\mathcal { D }$ as a function of $h$ is given as: + +$$ +\mathbb { E } _ { x _ { i } \sim \mathcal { D } } \left[ \log p ( x _ { i } ) \right] = \mathbb { E } _ { x _ { i } \sim \mathcal { D } } \left[ - e ^ { ( ( x _ { i } - h ) / \beta ) } + ( x _ { i } - h ) / \beta \right] +$$ + +Maximizing the log-likelihood yields the following convex minimization objective in $h$ + +$$ +\mathcal { L } ( h ) = \mathbb { E } _ { x _ { i } \sim \mathcal { D } } \left[ e ^ { ( x _ { i } - h ) / \beta } - ( x _ { i } - h ) / \beta - 1 \right] +$$ + +which forms our objective function $\mathcal { L } ( \cdot )$ , which resembles the Linex loss from econometrics (Parsian & Kirmani, 2002) 5. $\beta$ is fixed as a hyper-parameter, and we show its affect on the loss in Figure 2. Critically, the minima of this objective under a fixed $\beta$ is given by $h = \beta \log \mathbb { E } _ { x _ { i } \sim \mathcal { D } } [ e ^ { x _ { i } / \beta } ]$ , which resembles the LogSumExp with the summation replaced with an (empirical) expectation. In fact, this solution is the the same as the operator $\mathbb { L } _ { \mu } ^ { \beta } ( X )$ defined for MaxEnt in Section 2.1 with $x _ { i }$ sampled from $\mu$ . In Figure 2, we show plots of Gumbel Regression on a simple dataset with different values of $\beta$ . As this objective recovers $\mathbb { L } ^ { \beta } ( X )$ , we next use it to model soft-values in Max-Ent RL. + +# 3.2.1 THEORY + +Here we show that Gumbel regression is well behaved, considering the previously defined operator $\mathbb { L } ^ { \beta }$ for random variables $\mathbb { L } ^ { \beta } ( \bar { X } ) : = \beta \log \mathbb { E } \left[ e ^ { X / \beta } \right]$ . First, we show it models the extremum. + +Lemma 3.1. For any $\beta _ { 1 } > \beta _ { 2 }$ , we have $\mathbb { L } ^ { \beta _ { 1 } } ( X ) \angle \mathbb { L } ^ { \beta _ { 2 } } ( X )$ . And $\mathbb { L } ^ { \infty } ( X ) = \mathbb { E } \left[ X \right]$ , $\mathbb { L } ^ { 0 } ( X ) =$ $s u p ( X )$ . Thus, for any $\beta \in ( 0 , \infty )$ , the operator $\mathbb { L } ^ { \beta } ( X )$ is a measure that interpolates between the expectation and the max of $X$ . + +The operator $\mathbb { L } ^ { \beta } ( X )$ is known as the cumulant-generating function or the log-Laplace transform, and is a measure of the tail-risk closely linked to the entropic value at risk (EVaR) (Ahmadi-Javid, 2012) . + +Lemma 3.2. The risk measure $\mathcal { L }$ has a unique minima at $\beta \log \mathbb { E } \left[ e ^ { X / \beta } \right]$ . And an empirical risk $\hat { \mathcal { L } }$ is an unbiased estimate of the true risk. Furthermore, for $\beta \gg 1$ , $\begin{array} { r } { \mathcal { L } ( \boldsymbol { \theta } ) \approx \frac { 1 } { 2 \beta ^ { 2 } } \mathbb { E } _ { \boldsymbol { x } _ { i } \sim \mathcal { D } } [ ( \boldsymbol { x } _ { i } - \boldsymbol { \theta } ) ^ { 2 } ] } \end{array}$ , thus behaving as the MSE loss with errors $\sim \mathcal { N } ( 0 , \beta )$ . + +In particular, the empirical loss $\hat { \mathcal { L } }$ over a dataset of $N$ samples can be minimized using stochastic gradient-descent (SGD) methods to give an unbiased estimate of the LogSumExp over the $N$ samples. + +Lemma 3.3. ${ \hat { \mathbb { L } } } ^ { \beta } ( X )$ over a finite $N$ samples is a consistent estimator of the log-partition function $\mathbb { L } ^ { \beta } ( X )$ . Similarly, $\exp ( \hat { \mathbb { L } } ^ { \beta } ( X ) / \beta )$ is an unbiased estimator for the partition function $Z = \mathbb { E } \left[ e ^ { X / \beta } \right]$ + +We provide PAC learning bounds for Lemma 3.3, and further theoretical discussion on Gumbel Regression in Appendix B. + +# 3.3 MAXENT RL WITHOUT ENTROPY + +Given Gumbel Regression can be used to directly model the LogSumExp , we apply it to Q-learning. +First, we connect our framework to conservative Q-learning (Kumar et al., 2020). + +Lemma 3.4. Consider the loss objective over $Q$ -functions: + +$\mathfrak { L } ( Q ) = \mathbb { E } _ { \mathbf { s } \sim \rho _ { \mu } , \mathbf { a } \sim \mu ( \cdot | \mathbf { s } ) } \left[ e ^ { ( T ^ { \pi } \hat { Q } ^ { k } ( \mathbf { s } , \mathbf { a } ) - Q ( \mathbf { s } , \mathbf { a } ) ) / \beta } \right] - \mathbb { E } _ { \mathbf { s } \sim \rho _ { \mu } , \mathbf { a } \sim \mu ( \cdot | \mathbf { s } ) } [ ( T ^ { \pi } \hat { Q } ^ { k } ( \mathbf { s } , \mathbf { a } ) - Q ( \mathbf { s } , \mathbf { a } ) ) / \beta ] - 1$ (8) where $\mathcal T ^ { \pi } : = r ( \mathbf s , \mathbf a ) + \gamma \mathbb { E } _ { \mathbf s ^ { \prime } | \mathbf s , \mathbf a } \mathbb { E } _ { \mathbf a ^ { \prime } \sim \pi } [ Q ( \mathbf s ^ { \prime } , \mathbf a ^ { \prime } ) ]$ is the vanilla Bellman operator under the policy $\pi ( \mathbf { a } | \mathbf { s } )$ . Then minimizing $\mathcal { L }$ gives the update rule: + +$$ +\forall \mathbf { s } , \mathbf { a } , k \ { \hat { Q } } ^ { k + 1 } ( \mathbf { s } , \mathbf { a } ) = { \mathcal { T } } ^ { \pi } { \hat { Q } } ^ { k } ( \mathbf { s } , \mathbf { a } ) - \beta \log { \frac { \pi ( \mathbf { a } \mid \mathbf { s } ) } { \mu ( \mathbf { a } \mid \mathbf { s } ) } } = { \mathcal { B } } ^ { \pi } { \hat { Q } } ^ { k } ( \mathbf { s } , \mathbf { a } ) . +$$ + +The above lemma transforms the regular Bellman backup into the soft-Bellman backup without the need for entropies, letting us convert standard RL into MaxEnt RL. Here, $\mathcal { L } ( \cdot )$ does a conservative Q-update similar to CQL (Kumar et al., 2020) with the nice property that the implied conservative term is just the KL-constraint between $\pi$ and $\mu$ .6 This enforces a entropy-regularization on our policy with respect to the behavior policy without the need of entropy. Thus, soft-Q learning naturally emerges as a conservative update on regular Q-learning under our objective. Here, Equation 8 is the dual of the KL-divergence between $\mu$ and $\pi$ (Garg et al., 2021), and we motivate this objective for RL and establish formal equivalence with conservative Q-learning in Appendix C. + +In our framework, we use the MaxEnt Bellman operator $B ^ { * }$ which gives our ExtremeQ loss, which is the same as our Gumbel loss from the previous section: + +$$ +\mathcal { L } ( Q ) = \mathbb { E } _ { { \mathbf s } , { \mathbf a } \sim \mu } \left[ e ^ { ( \hat { \mathcal { B } } ^ { * } \hat { Q } ^ { k } ( { \mathbf s } , { \mathbf a } ) - Q ( { \mathbf s } , { \mathbf a } ) ) / \beta } \right] - \mathbb { E } _ { { \mathbf s } , { \mathbf a } \sim \mu } [ ( \hat { \mathcal { B } } ^ { * } \hat { Q } ^ { k } ( { \mathbf s } , { \mathbf a } ) - Q ( { \mathbf s } , { \mathbf a } ) ) / \beta ] - 1 +$$ + +This gives an update rule: $\hat { Q } ^ { k + 1 } ( \mathbf { s } , \mathbf { a } ) = B ^ { * } \hat { Q } ^ { k } ( \mathbf { s } , \mathbf { a } )$ . $\mathcal { L } ( \cdot )$ here requires estimation of $B ^ { * }$ which is very hard in continuous action spaces. Under deterministic dynamics, $\mathcal { L }$ can be obtained without $B ^ { * }$ as shown in Appendix C. However, in general we still need to estimate $B ^ { * }$ . Next, we motivate how we can solve this issue. Consider the soft-Bellman equation from Section 2.1 (Equation 1), + +$$ +\begin{array} { r } { B ^ { * } Q = r ( \mathbf { s } , \mathbf { a } ) + \gamma \mathbb { E } _ { \mathbf { s } ^ { \prime } \sim P ( \cdot | \mathbf { s } , \mathbf { a } ) } [ V ^ { * } ( \mathbf { s } ^ { \prime } ) ] , } \end{array} +$$ + +where $V ^ { * } ( \mathbf { s } ) = \mathbb { L } _ { \mathbf { a } \sim \mu ( \cdot | \mathbf { s } ^ { \prime } ) } ^ { \beta } [ Q ( \mathbf { s } , \mathbf { a } ) ]$ . Then $V ^ { * }$ can be directly estimated using Gumbel regression by $\beta$ +following ExtremeV loss objective: + +$$ +\mathcal { I } ( V ) = \mathbb { E } _ { \mathbf { s } , \mathbf { a } \sim \mu } \left[ e ^ { ( \hat { Q } ^ { k } ( \mathbf { s } , \mathbf { a } ) - V ( \mathbf { s } ) ) / \beta } \right] - \mathbb { E } _ { \mathbf { s } , \mathbf { a } \sim \mu } [ ( \hat { Q } ^ { k } ( \mathbf { s } , \mathbf { a } ) - V ( \mathbf { s } ) ) / \beta ] - 1 . +$$ + +Lemma 3.5. Minimizing $\mathcal { I }$ over values gives the update rule: $\hat { V } ^ { k } ( \mathbf { s } ) = \mathbb { L } _ { \mathbf { a } \sim \mu ( \cdot | \mathbf { s } ) } ^ { \beta } [ \hat { Q } ^ { k } ( \mathbf { s } , \mathbf { a } ) ] .$ + +Then we can obtain $V ^ { * }$ from $Q ( s , a )$ using Gumbel regression and substitute in Equation 10 to estimate the optimal bellman backup $B ^ { * } Q$ . Thus, Lemma 3.4 and 3.5 give us a scheme to solve the Max-Ent RL problem without the need of entropy. + +# 3.4 LEARNING POLICIES + +In the above section we derived a $Q$ -learning strategy that does not require explicit use of a policy $\pi$ . However, in continuous settings we still often want to recover a policy that can be run in the environment. Per Eq. 2 (Section 2.2), the optimal MaxEnt policy $\pi ^ { * } ( \mathbf { a } | \mathbf { \bar { s } } ) = \bar { \mu } ( \mathbf { a } | \mathbf { s } ) e ^ { ( Q ( \mathbf { s } , \mathbf { a } ) - V ( \mathbf { s } ) ) / \beta }$ . By minimizing the forward KL-divergence between $\pi$ and the optimal $\pi ^ { * }$ induced by $Q$ and $V$ we obtain the following training objective: + +$$ +\pi ^ { * } = \underset { \pi } { \operatorname { a r g m a x } } \mathbb { E } _ { \rho _ { \mu } ( \mathbf { s } , \mathbf { a } ) } [ e ^ { ( Q ( \mathbf { s } , \mathbf { a } ) - V ( \mathbf { s } ) ) / \beta } \log \pi ] . +$$ + +If we take $\rho _ { \mu }$ to be a dataset $\mathcal { D }$ generated from a behavior policy $\pi _ { \mathcal { D } }$ , we exactly recover the AWR objective used by prior works in Offline RL (Peng et al., 2019; Nair et al., 2020), which can easily be computed using the offline dataset. This objective does not require sampling actions, which may + +potentially take $Q ( s , a )$ out of distribution. Alternatively, if we want to sample from the policy instead of the reference distribution $\mu$ , we can minimize the Reverse-KL divergence which gives us the SAC-like actor update: + +$$ +\pi ^ { * } = \underset { \pi } { \mathrm { a r g m a x } } \mathbb { E } _ { \rho _ { \pi } ( \mathbf { s } ) \pi ( \mathbf { a } | \mathbf { s } ) } [ Q ( \mathbf { s } , \mathbf { a } ) - \beta \log ( \pi ( \mathbf { a } | \mathbf { s } ) / \mu ( \mathbf { a } | \mathbf { s } ) ) ] . +$$ + +Interestingly, we note this doesn’t depend on $V ( s )$ . If $\mu$ is chosen to be the last policy $\pi _ { k }$ , the second term becomes the KL-divergence between the current policy and $\pi _ { k }$ , performing a trust region update on $\pi$ (Schulman et al., 2015; Vieillard et al., 2020).7 While estimating the log ratio $\log ( \pi ( \mathbf { a } | \mathbf { s } ) / \mu ( \mathbf { a } | \mathbf { s } ) )$ can be difficult depending on choice of $\mu$ , our Gumbel Loss $\mathcal { I }$ removes the need for $\mu$ during $Q$ learning by estimating soft- $Q$ values of the form $Q ( \mathbf { s } , \mathbf { a } ) - \beta \log ( \pi ( \mathbf { a } | \mathbf { s } ) / \mu ( \mathbf { a } | \mathbf { s } ) )$ . + +# 3.5 PRACTICAL ALGORITHMS + +In this section we develop a practical approach to Extreme Q-learning ( $\mathcal { X }$ -QL) for both online and offline RL. We consider parameterized functions $V _ { \theta } ( \mathbf { s } )$ , $Q _ { \phi } ( \mathbf { s } , \mathbf { a } )$ , and $\pi _ { \psi } ( { \bf a } | { \bf s } )$ and let $\mathcal { D }$ be the training data distribution. A core issue with directly optimizing Eq. 10 is over-optimism about dynamics (Levine, 2018) when using simple-sample estimates for the Bellman backup. To overcome this issue in stochastic settings, we separate out the optimization of $V _ { \theta }$ from that of $Q _ { \phi }$ following Section 3.3. We learn $V _ { \theta }$ using Eq. 11 to directly fit the optimal soft-values $V ^ { * } ( \mathbf { s } )$ based on Gumbel regression. Using $V _ { \theta } ( \mathbf { s } ^ { \prime } )$ we can + +# Algorithm 1 Extreme Q-learning $\mathcal { X }$ -QL) (Under Stochastic Dynamics) + +1: Init $Q _ { \phi }$ , $V _ { \theta }$ , and $\pi _ { \psi }$ +2: Let $\boldsymbol { \mathcal { D } } = \{ ( \mathbf { s } , \mathbf { a } , r , \mathbf { s } ^ { \prime } ) \}$ be data from $\pi _ { \mathcal { D } }$ (offline) or replay buffer (online) +3: for step $t$ in {1...N} do +4: Train $Q _ { \phi }$ using ${ \mathcal { L } } ( \phi )$ from Eq. 14 +5: Train $V _ { \theta }$ using ${ \mathcal { I } } ( \theta )$ from Eq. 11 (with a $\sim \mathcal { D }$ (offline) or $\mathbf { a } \sim \pi _ { \psi }$ (online)) +6: Update $\pi _ { \psi }$ via Eq. 12 (offline) or Eq. 13 (online) +7: end for + +get single-sample estimates of $B ^ { * }$ as $r ( \mathbf { s } , \mathbf { a } ) + \gamma V _ { \theta } ( \mathbf { s } ^ { \prime } )$ . Now we can learn an unbiased expectation over the dynamics, $Q _ { \phi } \approx \mathbb { E } _ { \mathbf { s } ^ { \prime } | \mathbf { s } , \mathbf { a } } [ r ( \mathbf { s } , \mathbf { a } ) + \gamma V _ { \theta } ( \mathbf { s } ^ { \prime } ) ]$ by minimizing the Mean-squared-error (MSE) loss between the single-sample targets and $Q _ { \phi }$ : + +$$ +\begin{array} { r } { \mathcal { L } ( \phi ) = \mathbb { E } _ { ( \mathbf { s } , \mathbf { a } , \mathbf { s } ^ { \prime } ) \sim \mathcal { D } } \left[ ( Q _ { \phi } ( \mathbf { s } , \mathbf { a } ) - r ( \mathbf { s } , \mathbf { a } ) - \gamma V _ { \theta } ( \mathbf { s } ^ { \prime } ) ) ^ { 2 } \right] . } \end{array} +$$ + +In deterministic dynamics, our approach is largely simplified and we directly learn a single $Q _ { \phi }$ using Eq. 9 without needing to learn $B ^ { * }$ or $V ^ { * }$ . Similarly, we learn soft-optimal policies using Eq. 12 (offline) or Eq. 13 (online) settings. + +Offline RL. In the offline setting, $\mathcal { D }$ is specified as an offline dataset assumed to be collected with the behavior policy $\pi _ { \mathcal { D } }$ . Here, learning values with Eq. 11 has a number of practical benefits. First, we are able to fit the optimal soft-values $V ^ { * }$ without sampling from a policy network, which has been shown to cause large out-of-distribution errors in the offline setting where mistakes cannot be corrected by collecting additional data. Second, we inherently enforce a KL-constraint on the optimal policy $\pi ^ { * }$ and the behavior policy $\pi _ { \mathcal { D } }$ . This provides tunable conservatism via the temperature $\beta$ . After offline training of $Q _ { \phi }$ and $V _ { \theta }$ , we can recover the policy post-training using the AWR objective (Eq. 12). Our practical implementation follows the training style of Kostrikov et al. (2021), but we train value network using using our ExtremeQ loss. + +Online RL. In the online setting, $\mathcal { D }$ is usually given as a replay buffer of previously sampled states and actions. In practice, however, obtaining a good estimate of $V ^ { * } ( \mathbf { s } ^ { \prime } )$ requires that we sample actions with high Q-values instead of uniform sampling from $\mathcal { D }$ . As online learning allows agents to correct over-optimism by collecting additional data, we use a previous version of the policy network $\pi _ { \psi }$ to sample actions for the Bellman backup, amounting to the trust-region policy updates detailed at the end of Section 3.4. In practice, we modify SAC and TD3 with our formulation. To embue SAC (Haarnoja et al., 2018) with the benefits of Extreme Q-learning, we simply train $V _ { \theta }$ using Eq. 11 with $\mathbf { s } \sim \mathcal { D } , \mathbf { a } \sim \pi _ { \psi _ { k } } ( \mathbf { a } | \mathbf { s } )$ . This means that we do not use action probabilities when updating the value networks, unlike other MaxEnt RL approaches. The policy is learned via the objective $\mathrm { m a x } _ { \psi } \mathbb { E } [ Q _ { \phi } ( s , \pi _ { \psi } ( s ) ) ]$ with added entropy regularization, as SAC does not use a fixed noise schedule. TD3 by default does not use a value network, and thus we use our algorithm for deterministic dynamics by changing the loss to train $Q$ in TD3 to directly follow Eq. 9. The policy is learned as in SAC, except without entropy regularization as TD3 uses a fixed noise schedule. + +# 4 EXPERIMENTS + +We compare our Extreme Q-Learning $\mathcal { X }$ -QL) approach to state-of-the-art algorithms across a wide set of continuous control tasks in both online and offline settings. In practice, the exponential nature of the Gumbel regression poses difficult optimization challenges. We provide Offline results on Androit, details of loss implementation, ablations, and hyperparameters in Appendix D. + +# 4.1 OFFLINE RL + +Table 1: Averaged normalized scores on MuJoCo locomotion and Ant Maze tasks. $\mathcal { X }$ -QL-C gives results with the same consistent hyper-parameters in each domain, and $\mathcal { X }$ -QL-T gives results with per-environment $\beta$ and hyper-parameter tuning. + +
DatasetBC10%BCDTAWACOnestep RLTD3+BCCQLIQLX-QL CX-QL T
Aaaeehalfcheetah-medium-v242.642.542.643.548.448.344.047.447.748.3
hopper-medium-v252.956.967.657.059.659.358.566.371.174.2
walker2d-medium-v275.375.074.072.481.883.772.578.381.584.2
halfcheetah-medium-replay-v236.640.636.640.538.144.645.544.244.845.2
hopper-medium-replay-v218.175.982.737.297.560.995.094.797.3100.7
walker2d-medium-replay-v226.062.566.627.049.581.877.273.975.982.2
halfcheetah-medium-expert-v255.292.986.842.893.490.791.686.789.894.2
hopper-medium-expert-v2 walker2d-medium-expert-v252.5 107.5110.9 109.0107.655.8103.398.0105.491.5107.1111.2
antmaze-umaze-v054.662.8108.1 59.274.5113.0110.1108.8109.6110.1112.7
antmaze-umaze-diverse-v045.6 50.253.056.7 49.364.378.674.087.587.293.8
60.771.484.062.269.1782.0
antmaze-medium-play-v0 antmaze-medium-diverse-v00.05.40.00.00.310.661.271.273.576.0
antmaze-large-play-vo0.0 0.09.8 0.00.0 0.00.70.03.053.770.067.873.6
antmaze-large-diverse-v00.06.00.00.0 1.00.0 0.00.2 0.015.8 14.939.6 47.54146.5
raaakitchen-complete-v065.047.349.0
kitchen-partial-v038.0---1-43.862.5 46.372.582.4
kitchen-mixed-v051.5- -- 11 -1= 149.8 51.051.073.873.7
runtime * We see very fast convergence for our method on some tasks,and saturate performance at half the iterations as IQL.10m10m 960m20m- 20m20m80m20m54.6 10-20m62.5 10-20m*
+ +Our offline results with fixed hyperparameters for each domain outperform prior methods (Chen et al., 2021; Kumar et al., 2019; 2020; Kostrikov et al., 2021; Fujimoto & Gu, 2021) in several environments, reaching state-of-the-art on the Franka Kitchen tasks, as shown in Table 1. We find performance on the Gym locomotion tasks to be already largely saturated without introducing ensembles An et al. (2021), but our method achieves consistently high performance across environments. While we attain good performance using fixed hyper-parameters per domain, $\mathcal { X }$ -QL achieves even higher absolute performance and faster convergence than IQL’s reported results when hyper-parameters are turned per environment. With additional tuning, we also see particularly large improvements on the AntMaze tasks, which require a significant amount of “stitching” between trajectories (Kostrikov et al., 2021). Full learning curves are in the Appendix. Like IQL, $\mathcal { X }$ -QL can be easily fine-tuned using online data to attain even higher performance as shown in Table 2. + +# 4.2 ONLINE RL + +Table 2: Finetuning results on the AntMaze environments + +
DatasetCQLIQLX-QL T
umaze-vO70.1 →99.486.7 →96.093.8 →99.6
umaze-diverse-v031.1 →99.475.0 →84.082.0 →99.0
medium-play-v023.0 →0.072.0 →95.076.0 →97.0
medium-diverse-v023.0 →32.368.3 →92.073.6 →97.1
large-play-v01.0 →0.025.5 →46.045.1 →59.3
large-diverse-v01.0 →0.042.6 →60.749.0 →82.1
+ +We compare ExtremeQ variants of SAC (Haarnoja et al., 2018) and TD3 (Fujimoto et al., 2018), denoted $\mathcal { X }$ -SAC and $\mathcal { X }$ -TD3, to their vanilla versions on tasks in the DM Control, shown in Figure 3. Across all tasks an ExtremeQ variant matches or + +surpasses the performance of baselines. We see particularly large gains in the Hopper environment, and more significant gains in comparison to TD3 overall. Consistent with SAC (Haarnoja et al., 2018), we find the temperature $\beta$ needs to be tuned for different environments with different reward scales and sparsity. A core component of TD3 introduced by Fujimoto et al. (2018) is Double Q-Learning, which takes the minimum of two $Q$ functions to remove overestimate bias in the Q-target. As we assume errors to be Gumbel distributed, we expect our $\mathcal { X }$ -variants to be more robust to such errors. In all environments except Cheetah Run, our $\mathcal { X }$ -TD3 without the Double-Q trick, denoted $\mathcal { X }$ -QL - DQ, performs better than standard TD3. While the gains from Extreme-Q learning are modest in online settings, none of our methods require access to the policy distribution to learn the Q-values. + +![](images/25086ebef695df67b47ca41680050457511c6a740aa26c23947e34bd9c4321cf.jpg) +Figure 3: Results on the DM Control for SAC and TD3 based versions of Extreme Q Learning. + +# 5 RELATED WORK + +Our approach builds on works online and offline RL. Here we review the most salient ones. Inspiration for our framework comes from econometrics (Rust, 1986; McFadden, 1972), and our Gumbel loss is motivated by IQ-Learn (Garg et al., 2021). + +Online RL. Our work bridges the theoretical gap between RL and Max-Ent RL by introducing our Gumbel loss function. Unlike past work in MaxEnt RL (Haarnoja et al., 2018; Eysenbach & Levine, 2020), our method does not require explicit entropy estimation and instead addresses the problem of obtaining soft-value estimates (LogSumExp) in high-dimensional or continuous spaces (Vieillard et al., 2021) by directly modeling them via our proposed Gumbel loss, which to our knowledge has not previously been used in RL. Our loss objective is intrinsically linked to the KL divergence, and similar objectives have been used for mutual information estimation (Poole et al., 2019) and statistical learning Parsian & Kirmani (2002); Atiyah et al. (2020). IQ-Learn (Garg et al., 2021) proposes learning Q-functions to solve imitation introduced the same loss in IL to obtain an unbiased dual form for the reverse KL-divergence between an expert and policy distribution. Other works have also used forward KL-divergence to derive policy objectives (Peng et al., 2019) or for regularization (Schulman et al., 2015; Abdolmaleki et al., 2018). Prior work in RL has also examined using other types of loss functions (Bas-Serrano et al., 2021) or other formulations of the argmax in order to ease optimization (Asadi & Littman, 2017). Distinct from most off-Policy RL Methods (Lillicrap et al., 2015; Fujimoto et al., 2018; Haarnoja et al., 2018), we directly model $B ^ { * }$ like Haarnoja et al. (2017); Heess et al. (2015) but attain significantly more stable results. + +Offline RL. Prior works in offline RL can largely be categorized as relying on constrained or regularized Q-learning (Wu et al., 2019; Fujimoto & Gu, 2021; Fujimoto et al., 2019; Kumar et al., 2019; 2020; Nair et al., 2020), or extracting a greedy policy from the known behavior policy (Peng et al., 2019; Brandfonbrener et al., 2021; Chen et al., 2021). Most similar to our work, IQL (Kostrikov et al., 2021) fits expectiles of the Q-function of the behavior policy, but is not motivated to solve a particular problem or remain conservative. On the other hand, conservatism in CQL (Kumar et al., 2020) is motivated by lower-bounding the Q-function. Our method shares the best of both worlds – like IQL we do not evaluate the Q-function on out of distribution actions and like CQL we enjoy the benefits of conservatism. Compared to CQL, our approach uses a KL constraint with the behavior policy, and for the first time extends soft-Q learning to offline RL without needing a policy or explicit entropy values. Our choice of using the reverse KL divergence for offline RL follows closely with BRAC (Wu et al., 2019) but avoids learning a policy during training. + +# 6 CONCLUSION + +We propose Extreme Q-Learning, a new framework for MaxEnt RL that directly estimates the optimal Bellman backup $B ^ { * }$ without relying on explicit access to a policy. Theoretically, we bridge the gap between the regular, soft, and conservative Q-learning formulations. Empirically, we show that our framework can be used to develop simple, performant RL algorithms. A number of future directions remain such as improving stability with training with the exponential Gumbel Loss function and integrating automatic tuning methods for temperature $\beta$ like SAC (Haarnoja et al., 2018). Finally, we hope that our framework can find general use in Machine Learning for estimating log-partition functions. + +# Acknowledgements + +Div derived the theory for Extreme Q-learning and Gumbel regression framework and ran the tuned offline RL experiments. Joey ran the consistent offline experiments and online experiments. Both authors contributed equally to paper writing. + +We thank John Schulman and Bo Dai for helpful discussions. Our research was supported by NSF(1651565), AFOSR (FA95501910024), ARO (W911NF-21-1-0125), ONR, CZ Biohub, and a Sloan Fellowship. Joey was supported by the Department of Defense (DoD) through the National Defense Science & Engineering Graduate (NDSEG) Fellowship Program. + +# REFERENCES + +Abbas Abdolmaleki, Jost Tobias Springenberg, Yuval Tassa, Remi Munos, Nicolas Heess, and Martin Riedmiller. Maximum a posteriori policy optimisation. In International Conference on Learning Representations, 2018. 9 + +A. Ahmadi-Javid. Entropic value-at-risk: A new coherent risk measure. Journal of Optimization Theory and Applications, 155(3):1105–1123, 2012. URL https://EconPapers.repec.org/ RePEc:spr:joptap:v:155:y:2012:i:3:d:10.1007_s10957-011-9968-2. 5 + +Gaon An, Seungyong Moon, Jang-Hyun Kim, and Hyun Oh Song. Uncertainty-based offline reinforcement learning with diversified q-ensemble. In Neural Information Processing Systems, 2021. 8 + +Kavosh Asadi and Michael L Littman. An alternative softmax operator for reinforcement learning. In International Conference on Machine Learning, pp. 243–252. PMLR, 2017. 9 + +Israa Abdzaid Atiyah, Adel Mohammadpour, Narges Ahmadzadehgoli, and S Mahmoud Taheri. Fuzzy c-means clustering using asymmetric loss function. Journal of Statistical Theory and Applications, 19(1):91–101, 2020. 9 + +Jimmy Lei Ba, Jamie Ryan Kiros, and Geoffrey E Hinton. Layer normalization. arXiv preprint arXiv:1607.06450, 2016. 21 + +Joan Bas-Serrano, Sebastian Curi, Andreas Krause, and Gergely Neu. Logistic q-learning. In International Conference on Artificial Intelligence and Statistics, pp. 3610–3618. PMLR, 2021. 9 + +M. Bloem and N. Bambos. Infinite time horizon maximum causal entropy inverse reinforcement learning. 53rd IEEE Conference on Decision and Control, pp. 4911–4916, 2014. 2 + +David Brandfonbrener, Will Whitney, Rajesh Ranganath, and Joan Bruna. Offline rl without off-policy evaluation. Advances in Neural Information Processing Systems, 34:4933–4946, 2021. 9 + +Lili Chen, Kevin Lu, Aravind Rajeswaran, Kimin Lee, Aditya Grover, Misha Laskin, Pieter Abbeel, Aravind Srinivas, and Igor Mordatch. Decision transformer: Reinforcement learning via sequence modeling. Advances in neural information processing systems, 34, 2021. 8, 9 + +Benjamin Eysenbach and Sergey Levine. If maxent {rl} is the answer, what is the question?, 2020. URL https://openreview.net/forum?id $=$ SkxcZCNKDS. 9 + +R. A. Fisher and L. H. C. Tippett. Limiting forms of the frequency distribution of the largest or smallest member of a sample. Mathematical Proceedings of the Cambridge Philosophical Society, 24(2):180–190, 1928. doi: 10.1017/S0305004100015681. 3 + +Scott Fujimoto and Shixiang Shane Gu. A minimalist approach to offline reinforcement learning. Advances in Neural Information Processing Systems, 34, 2021. 8, 9 + +Scott Fujimoto, Herke van Hoof, and David Meger. Addressing function approximation error in actor-critic methods. ArXiv, abs/1802.09477, 2018. 1, 8, 9, 14, 20, 21 + +Scott Fujimoto, David Meger, and Doina Precup. Off-policy deep reinforcement learning without exploration. In International Conference on Machine Learning, pp. 2052–2062. PMLR, 2019. 9 + +Divyansh Garg, Shuvam Chakraborty, Chris Cundy, Jiaming Song, and Stefano Ermon. Iq-learn: Inverse soft-q learning for imitation. In Thirty-Fifth Conference on Neural Information Processing Systems, 2021. URL https://openreview.net/forum?id $=$ Aeo-xqtb5p. 6, 9, 18 + +Tuomas Haarnoja, Haoran Tang, Pieter Abbeel, and Sergey Levine. Reinforcement learning with deep energy-based policies. 2017. 3, 9, 21 + +Tuomas Haarnoja, Aurick Zhou, Pieter Abbeel, and Sergey Levine. Soft actor-critic: Off-policy maximum entropy deep reinforcement learning with a stochastic actor. In International conference on machine learning, pp. 1861–1870. PMLR, 2018. 1, 3, 4, 7, 8, 9 + +Tamir Hazan and Tommi Jaakkola. On the partition function and random maximum a-posteriori perturbations. arXiv preprint arXiv:1206.6410, 2012. 3 + +Nicolas Heess, Gregory Wayne, David Silver, Timothy Lillicrap, Tom Erez, and Yuval Tassa. Learning continuous control policies by stochastic value gradients. Advances in neural information processing systems, 28, 2015. 9 + +Ilya Kostrikov, Ashvin Nair, and Sergey Levine. Offline reinforcement learning with implicit q-learning. arXiv preprint arXiv:2110.06169, 2021. 7, 8, 9, 20 + +Aviral Kumar, Justin Fu, Matthew Soh, George Tucker, and Sergey Levine. Stabilizing off-policy q-learning via bootstrapping error reduction. Advances in Neural Information Processing Systems, 32, 2019. 8, 9 + +Aviral Kumar, Aurick Zhou, George Tucker, and Sergey Levine. Conservative q-learning for offline reinforcement learning. Advances in Neural Information Processing Systems, 33:1179–1191, 2020. 1, 5, 6, 8, 9, 17, 18 + +Sergey Levine. Reinforcement learning and control as probabilistic inference: Tutorial and review. arXiv preprint arXiv:1805.00909, 2018. 7 + +Qing Li. Continuous control benchmark of deepmind control suite and mujoco. https://github. com/LQNew/Continuous_Control_Benchmark, 2021. 22 + +Timothy P Lillicrap, Jonathan J Hunt, Alexander Pritzel, Nicolas Heess, Tom Erez, Yuval Tassa, David Silver, and Daan Wierstra. Continuous control with deep reinforcement learning. arXiv preprint arXiv:1509.02971, 2015. 9 + +R.Duncan Luce. The choice axiom after twenty years. Journal of Mathematical Psychology, 15(3):215–233, 1977. ISSN 0022-2496. doi: https://doi.org/10.1016/0022-2496(77) 90032-3. URL https://www.sciencedirect.com/science/article/pii/ 0022249677900323. 3, 14 + +Daniel McFadden. Conditional logit analysis of qualitative choice behavior. 1972. 2, 3, 9, 13, 14 + +Volodymyr Mnih, Koray Kavukcuoglu, David Silver, Alex Graves, Ioannis Antonoglou, Daan Wierstra, and Martin Riedmiller. Playing atari with deep reinforcement learning. arXiv preprint arXiv:1312.5602, 2013. 1 + +Alexander McFarlane Mood. Introduction to the theory of statistics. 1950. 3 + +Ashvin Nair, Abhishek Gupta, Murtaza Dalal, and Sergey Levine. Awac: Accelerating online reinforcement learning with offline datasets. arXiv preprint arXiv:2006.09359, 2020. 6, 9 + +Gergely Neu, Anders Jonsson, and V. Gómez. A unified view of entropy-regularized markov decision processes. ArXiv, abs/1705.07798, 2017. 3 + +George Papandreou and Alan L Yuille. Gaussian sampling by local perturbations. Advances in Neural Information Processing Systems, 23, 2010. 3 + +Ahmad Parsian and SNUA Kirmani. Estimation under linex loss function. In Handbook of applied econometrics and statistical inference, pp. 75–98. CRC Press, 2002. 5, 9 + +Xue Bin Peng, Aviral Kumar, Grace Zhang, and Sergey Levine. Advantage-weighted regression: Simple and scalable off-policy reinforcement learning. arXiv preprint arXiv:1910.00177, 2019. 6, 9 + +Ben Poole, Sherjil Ozair, Aäron van den Oord, Alexander A. Alemi, and G. Tucker. On variational bounds of mutual information. In ICML, 2019. 9 + +John Rust. Structural estimation of markov decision processes. In R. F. Engle and D. McFadden (eds.), Handbook of Econometrics, volume 4, chapter 51, pp. 3081–3143. Elsevier, 1 edition, 1986. URL https://editorialexpress.com/jrust/papers/handbook_ec_v4_ rust.pdf. 2, 3, 9 + +John Schulman, Sergey Levine, Pieter Abbeel, Michael Jordan, and Philipp Moritz. Trust region policy optimization. In International conference on machine learning, pp. 1889–1897. PMLR, 2015. 1, 7, 9 + +Slavko Simic. On a new converse of jensen’s inequality. ´ Publications De L’institut Mathematique, 85:107–110, 01 2009. doi: 10.2298/PIM0999107S. 15 + +Yuval Tassa, Yotam Doron, Alistair Muldal, Tom Erez, Yazhe Li, Diego de Las Casas, David Budden, Abbas Abdolmaleki, Josh Merel, Andrew Lefrancq, et al. Deepmind control suite. arXiv preprint arXiv:1801.00690, 2018. 4 + +Sebastian Thrun and Anton Schwartz. Issues in using function approximation for reinforcement learning. 1999. 14 + +Nino Vieillard, Tadashi Kozuno, Bruno Scherrer, Olivier Pietquin, Rémi Munos, and Matthieu Geist. Leverage the average: an analysis of kl regularization in rl. 34th Conference on Neural Information Processing Systems, 2020. 7 + +Nino Vieillard, Marcin Andrychowicz, Anton Raichuk, Olivier Pietquin, and Matthieu Geist. Implicitly regularized rl with implicit q-values. arXiv preprint arXiv:2108.07041, 2021. 9 + +Yifan Wu, George Tucker, and Ofir Nachum. Behavior regularized offline reinforcement learning. arXiv preprint arXiv:1911.11361, 2019. 9 + +Denis Yarats and Ilya Kostrikov. Soft actor-critic (sac) implementation in pytorch. https:// github.com/denisyarats/pytorch_sac, 2020. 20, 21, 22 + +G. Alastair Young. High-dimensional statistics: A non-asymptotic viewpoint, martin j. wainwright, cambridge university press, 2019, xvii 552 pages, £57.99, hardback isbn: 978-1-1084-9802-9. International Statistical Review, 88(1):258–261, 2020. doi: https://doi.org/10.1111/insr.12370. URL https://onlinelibrary.wiley.com/doi/abs/10.1111/insr.12370. 3 + +Brian D Ziebart. Modeling purposeful adaptive behavior with the principle of maximum causal entropy. Carnegie Mellon University, 2010. 1 + +# A THE GUMBEL ERROR MODEL FOR MDPS + +In this section, we functionally analyze Q-learning using our framework and further develop the Gumbel Error Model (GEM) for MDPs. + +# A.1 RUST-MCFADDEN MODEL OF MDPS + +For an MDP following the Bellman equations, we assume the observed rewards to be stochastic due to an unobserved component of the state. Let s be the observed state, and $( \mathbf { s } , \mathbf { z } )$ be the actual state with hidden component $\mathbf { z }$ . Then, + +$$ +\begin{array} { r l } & { Q ( \mathbf { s } , \mathbf { z } , \mathbf { a } ) = R ( \mathbf { s } , \mathbf { z } , \mathbf { a } ) + \gamma \mathbb { E } _ { \mathbf { s } ^ { \prime } \sim P ( \cdot | \mathbf { s } , \mathbf { a } ) } [ \mathbb { E } _ { \mathbf { z } ^ { \prime } | \mathbf { s } ^ { \prime } } [ V ( \mathbf { s } ^ { \prime } , \mathbf { z } ^ { \prime } ) ] , } \\ & { \quad V ( \mathbf { s } , \mathbf { z } ) = \underset { \mathbf { a } } { \operatorname* { m a x } } Q ( \mathbf { s } , \mathbf { z } , \mathbf { a } ) . } \end{array} +$$ + +Lemma A.1. Given, $^ { l }$ ) conditional independence $( C I )$ assumption that $\mathbf { z } ^ { \prime }$ depends only on $\mathbf { s } ^ { \prime }$ , i.e. $p ( \mathbf { s } ^ { \prime } , z ^ { \prime } | \mathbf { s } , \mathbf { z } , \mathbf { a } ) = p ( \mathbf { z } ^ { \prime } | \mathbf { s } ^ { \prime } ) p ( \mathbf { s } ^ { \prime } | \mathbf { s } , \mathbf { a } )$ and 2) additive separablity (AS) assumption on the hidden noise: $\begin{array} { r } { R ( \mathbf { s } , \mathbf { a } , \mathbf { z } ) = r ( \mathbf { s } , \mathbf { a } ) + \epsilon ( \mathbf { z } , \mathbf { a } ) } \end{array}$ . + +Then for i.i.d. $\epsilon ( \mathbf { z } , \mathbf { a } ) \sim \mathcal { G } ( 0 , \beta )$ , we recover the soft-Bellman equations for $Q ( \mathbf { s } , \mathbf { z } , \mathbf { a } ) = q ( \mathbf { s } , \mathbf { a } ) +$ $\epsilon ( \mathbf { z } , \mathbf { a } )$ and $v ( \mathbf { s } ) = \mathbb { E } _ { z } [ V ( \mathbf { s } , \mathbf { z } ) ]$ , with rewards $r ( \mathbf { s } , \mathbf { a } )$ and entropy regularization $\beta$ . + +Hence, a soft-MDP in MaxEntRL is equivalent to an MDP with an extra hidden variable in the state that introduces i.i.d. Gumbel noise in the rewards and follows the $A S { + } C I$ conditions. + +Proof. We have, + +$$ +\begin{array} { r } { q ( \mathbf { s } , \mathbf { a } ) = r ( \mathbf { s } , \mathbf { a } ) + \gamma \mathbb { E } _ { \mathbf { s } ^ { \prime } \sim P ( \cdot | \mathbf { s } , \mathbf { a } ) } [ \mathbb { E } _ { \mathbf { z } ^ { \prime } | \mathbf { s } ^ { \prime } } [ V ( \mathbf { s } ^ { \prime } , \mathbf { z } ^ { \prime } ) ] } \\ { v ( \mathbf { s } ) = \mathbb { E } _ { \mathbf { z } } [ V ( \mathbf { s } , \mathbf { z } ) ] = \mathbb { E } _ { z } [ \underset { \mathbf { a } } { \mathrm { m a x } } ( q ( \mathbf { s } , \mathbf { a } ) + \epsilon ( \mathbf { z } ) ) ] . } \end{array} +$$ + +From this, we can get fixed-point equations for $q$ and $\pi$ , + +$$ +\begin{array} { r l } & { q ( \mathbf { s } , \mathbf { a } ) = r ( \mathbf { s } , \mathbf { a } ) + \gamma \mathbb { E } _ { \mathbf { s } ^ { \prime } \sim P ( \cdot | \mathbf { s } , \mathbf { a } ) } [ \mathbb { E } _ { \mathbf { z } ^ { \prime } | \mathbf { s } ^ { \prime } } [ \operatorname* { m a x } ( q ( \mathbf { s } ^ { \prime } , \mathbf { a } ^ { \prime } ) + \epsilon ( \mathbf { z } ^ { \prime } , \mathbf { a } ^ { \prime } ) ) ] ] , } \\ & { \pi ( \cdot | s ) = \mathbb { E } _ { \mathbf { z } } [ \underset { \mathbf { a } } { \mathrm { a r g m a x } } ( q ( \mathbf { s } , \mathbf { a } ) + \epsilon ( \mathbf { z } , \mathbf { a } ) ) ] \in \Delta _ { \cal A } , } \end{array} +$$ + +where $\Delta _ { \mathcal { A } }$ is the set of all policies. + +Now, let $\epsilon ( \mathbf { z } , \mathbf { a } ) \sim \mathcal { G } ( 0 , \beta )$ and assumed independent for each $( \mathbf { z } , \mathbf { a } )$ (or equivalently $( \mathbf { s } , \mathbf { a } )$ due to the CI condition). Then we can use the Gumbel-Max trick to recover the soft-Bellman equations for $q ( \mathbf { s } , \mathbf { a } )$ and $v ( \mathbf { s } )$ with rewards $r ( \mathbf { s } , \mathbf { a } )$ : + +$$ +\begin{array} { r l } & { q ( \mathbf { s } , \mathbf { a } ) = r ( \mathbf { s } , \mathbf { a } ) + \gamma \mathbb { E } _ { \mathbf { s } ^ { \prime } \sim P ( \cdot | \mathbf { s } , \mathbf { a } ) } [ \mathbb { L } _ { \mathbf { a } ^ { \prime } } ^ { \beta } [ q ( \mathbf { s } ^ { \prime } , \mathbf { a } ^ { \prime } ) ] ] , } \\ & { ~ \pi ( \cdot | s ) = \mathrm { s o f t m a x } ( q ( \mathbf { s } , \mathbf { a } ) ) . } \end{array} +$$ + +Thus, we have that the soft-Bellman optimality equation and related optimal policy can arise either from the entropic regularization viewpoint or from the Gumbel error viewpoint for an MDP. + +Corollary A.1.1. Converse: An MDP following the Bellman optimality equation and having a policy that is softmax distributed, necessarily has any i.i.d. noise in the rewards due to hidden state variables be Gumbel distributed, given the $A S { + } C I$ conditions hold. + +Proof. McFadden (McFadden, 1972) proved this converse in his seminal work on discrete choice theory, that for i.i.d. $\epsilon$ satisfiying Equation 19 with a choice policy $\pi \sim$ softmax has $\epsilon$ be Gumbel distributed. And we show a proof here similar to the original for MDPs. + +Considering Equation 20, we want $\pi ( a | s )$ to be softmax distributed. Let $\epsilon$ have an unknown CDF $F$ and we consider there to be $N$ possible actions. Then, + +$$ +\begin{array} { r l r } & { } & { { \mathrm { s } } \mathrm { ( a r g m a x } ( q ( { \bf s } , { \bf a } ) + \epsilon ( z , { \bf a } ) ) = { \bf a } _ { i } \vert { \bf s } , { \bf z } ) = P ( q ( { \bf s } , { \bf a } _ { i } ) + \epsilon ( { \bf z } , { \bf a } _ { i } ) \geq q ( { \bf s } , { \bf a } _ { j } ) + \epsilon ( z , { \bf a } _ { j } ) \forall i \neq j \vert { \bf s } , { \bf z } ) } \\ & { } & { { \mathrm { ~ } } { \mathrm { ~ } } } \\ & { } & { = P ( \epsilon ( { \bf z } , { \bf a } _ { j } ) - \epsilon ( { \bf z } , { \bf a } _ { i } ) \leq q ( { \bf s } , { \bf a } _ { i } ) - q ( { \bf s } , { \bf a } _ { j } ) \forall i \neq j \vert { \bf s } , { \bf z } ) } \end{array} +$$ + +Simplifying the notation, we write $\epsilon ( \mathbf { z } , \mathbf { a } _ { i } ) = \epsilon _ { i }$ and $q ( \mathbf { s } , \mathbf { a } _ { i } ) = q _ { i }$ . Then $\epsilon _ { 1 } , . . . , \epsilon _ { N }$ has a joint CDF $G$ : + +$$ +G ( \epsilon _ { 1 } , . . . , \epsilon _ { N } ) = \prod _ { j = 1 } ^ { N } P ( \epsilon _ { j } \le \epsilon _ { i } + q _ { i } - q _ { j } ) = \prod _ { j = 1 } ^ { N } F ( \epsilon _ { i } + q _ { i } - q _ { j } ) +$$ + +and we can get the required probability $\pi ( i )$ as: + +$$ +\pi ( i ) = \int _ { \varepsilon = - \infty } ^ { + \infty } \prod _ { j = 1 , j \neq i } ^ { N } F ( \varepsilon + q _ { i } - q _ { j } ) d F ( \varepsilon ) +$$ + +For $\pi = \operatorname { s o f t m a x } ( q )$ , McFadden (McFadden, 1972) proved the uniqueness of $F$ to be the Gumbel CDF, assuming translation completeness property to hold for $F$ . Later this uniqueness was shown to hold in general for any $N \geq 3$ (Luce, 1977). □ + +# A.2 GUMBEL ERROR MODEL (GEM) FOR MDPS + +To develop our Gumbel Error Model (GEM) for MDPs under functional approximation as in Section 3.1, we follow our simplified scheme of $M$ independent estimators $\hat { Q }$ , which results in the following equation over $\bar { Q } = \mathbb { E } [ \hat { Q } ]$ : + +$$ +\bar { Q } _ { t + 1 } ( \mathbf { s } , \mathbf { a } ) = r ( \mathbf { s } , \mathbf { a } ) + \gamma \mathbb { E } _ { \mathbf { s } ^ { \prime } | \mathbf { s } , \mathbf { a } } [ \mathbb { E } _ { \epsilon _ { t } } [ \operatorname* { m a x } _ { \mathbf { a } ^ { \prime } } ( \bar { Q } _ { t } ( \mathbf { s } ^ { \prime } , \mathbf { a } ^ { \prime } ) + \epsilon _ { t } ( \mathbf { s } ^ { \prime } , \mathbf { a } ^ { \prime } ) ) ] ] . +$$ + +Here, the maximum of random variables will generally be greater than the true max, i.e. $\begin{array} { r } { \mathbb { E } _ { \epsilon } [ \operatorname* { m a x } _ { \mathbf { a } ^ { \prime } } ( \bar { Q } ( \mathbf { s } ^ { \prime } , \mathbf { a } ^ { \prime } ) + \epsilon ( \mathbf { s } ^ { \prime } , \mathbf { a } ^ { \prime } ) ) ] \geq \operatorname* { m a x } _ { \mathbf { a } ^ { \prime } } \bar { Q } ( \mathbf { s } ^ { \prime } , \mathbf { a } ^ { \prime } ) } \end{array}$ (Thrun & Schwartz, 1999). As a result, even initially zero-mean error can cause $\mathrm { Q }$ updates to propagate consistent overestimation bias through the Bellman equation. This is a known issue with function approximation in RL (Fujimoto et al., 2018). + +Now, we can use the Rust-McFadden model from before. To account for the stochasticity, we consider extra unobserved state variables $z$ in the MDP to be the model parameters $\theta$ used in the functional approximation. The errors from functional approximation $\epsilon _ { t }$ can thus be considered as noise added in the reward. Here, $C I$ condition holds as $\epsilon$ is separate from the dynamics and becomes conditionally independent for each state-action pair and $A S$ condition is implied. Then for $\bar { Q }$ satisfying Equation 24, we can apply the McFadden-Rust model, which implies that for the policy to be soft-optimal i.e. a softmax over $\bar { Q }$ , $\epsilon$ will be Gumbel distributed. + +Conversely, for the i.i.d. $\epsilon \sim \mathcal G , \bar { Q } ( \mathbf { s } , \mathbf { a } )$ follows the soft-Bellman equations and $\pi ( \mathbf { a } | \mathbf { s } ) \ =$ softmax $\mathbf { \Phi } ( Q ( \mathbf { s } , \mathbf { a } ) )$ . + +This indicates an optimality condition on the MDP – for us to eventually attain the optimal softmax policy in the presence of functional boostrapping (Equation 24), the errors should follow the Gumbel distribution. + +# A.2.1 TIME EVOLUTION OF ERRORS IN MDPS UNDER DETERMINISTIC DYNAMICS + +In this section, we characterize the time evolution of errors in an MDP using GEM. We assume deterministic dynamics to simplify our analysis. + +We suppose that we know the distribution of Q-values at time $t$ and model the evolution of this distribution through the Bellman equations. Let $Z _ { t } ( \mathbf { s } , \mathbf { a } )$ be a random variable sampled from the distribution of $Q$ -values at time $t$ , then the following Bellman equation holds: + +$$ +Z _ { t + 1 } ( \mathbf { s } , \mathbf { a } ) = r ( \mathbf { s } , \mathbf { a } ) + \gamma \operatorname* { m a x } _ { \mathbf { a } ^ { \prime } } Z _ { t } ( \mathbf { s } ^ { \prime } , \mathbf { a } ^ { \prime } ) . +$$ + +Here, $Z _ { t + 1 } ( \mathbf { s } , \mathbf { a } ) = \operatorname* { m a x } _ { \mathbf { a } ^ { \prime } } \bigl [ r ( \mathbf { s } , \mathbf { a } ) + \gamma Z _ { t } ( \mathbf { s } ^ { \prime } , \mathbf { a } ^ { \prime } ) \bigr ]$ is a maximal distribution and based on EVT should eventually converge to an extreme value distribution, which we can model as a Gumbel. + +Concretely, let’s assume that we fix $Z _ { t } ( \mathbf { s } , \mathbf { a } ) \sim \mathcal { G } ( Q _ { t } ( \mathbf { s } , \mathbf { a } ) , \beta )$ for some $Q _ { t } ( \mathbf { s } , \mathbf { a } ) \in \mathbb { R }$ and $\beta > 0$ . Furthermore, we assume that the Q-value distribution is jointly independent over different stateactions i.e. $Z ( \mathbf { s } , \mathbf { a } )$ is independent from $Z ( \mathbf { s } ^ { \prime } , \mathbf { a } ^ { \prime } )$ for $\forall ( \mathbf { s } , \mathbf { \bar { a } } ) \neq ( \mathbf { s } ^ { \prime } , \bar { \mathbf { a } ^ { \prime } } )$ . Then $\begin{array} { r } { \operatorname* { m a x } _ { \mathbf { a } ^ { \prime } } Z _ { t } ( \mathbf { s } ^ { \prime } , \mathbf { a } ^ { \prime } ) \sim } \end{array}$ $\mathcal { G } ( V ( \mathbf { s } ^ { \prime } ) , \beta )$ with $\begin{array} { r } { \dot { V } ( \mathbf { s } ) = \mathbb { \dot { L } } _ { \mathbf { a } } ^ { \beta } [ Q ( \mathbf { s } , \mathbf { a } ) ] } \end{array}$ using the Gumbel-max trick. + +Then substituting in Equation 25 and rescaling $Z _ { t }$ with $\gamma$ , we get: + +$$ +Z _ { t + 1 } ( \mathbf { s } , \mathbf { a } ) \sim \mathcal { G } \left( r ( \mathbf { s } , \mathbf { a } ) + \gamma \mathbb { L } _ { \mathbf { a } ^ { \prime } } ^ { \beta } [ Q ( \mathbf { s } ^ { \prime } , \mathbf { a } ^ { \prime } ) ] , \gamma \beta \right) . +$$ + +So very interestingly the Q-distribution becomes a Gumbel process, where the location parameter $Q ( \mathbf { s } , \mathbf { a } )$ follows the optimal soft-Bellman equation. Similarly, the temperature scales as $\gamma \beta$ and the distribution becomes sharper after every timestep. + +After a number of timesteps, we see that $Z ( \mathbf { s } , \mathbf { a } )$ eventually collapses to the Delta distibution over the unique contraction $Q ^ { * } ( \mathbf { s } , \mathbf { a } )$ . Here, $\gamma$ controls the rate of decay of the Gumbel distribution into the collapsed Delta distribution. Thus we get the expected result in deterministic dynamics that the optimal $Q$ -function will be deterministic and its distribution will be peaked. + +So if a Gumbel error enters into the MDP through a functional error or some other source at a timestep $t$ in some state $s$ , it will trigger off an wave that propagates the Gumbel error into its child states following Equation 26. Thus, this Gumbel error process will decay at a $\gamma$ rate every timestep and eventually settle down with $\mathrm { Q }$ -values reaching the the steady solution $Q ^ { * }$ . The variance of this Gumbel process given as $\textstyle { \frac { \pi ^ { 2 } } { 6 } } \beta ^ { 2 }$ will decay as $\gamma ^ { 2 }$ , similarly the bias will decay as $\gamma$ -contraction in the norm. + +Hence, GEM gives us an analytic characterization of error propogation in MDPs under deterministic dynamics. + +Nevertheless under stochastic dynamics, characterization of errors using GEM becomes non-trivial as Gumbel is not mean-stable unlike the Gaussian distribution. We hypothesise that the errors will follow some mix of Gumbel-Gaussian distributions, and leave this characterization as a future open direction. + +# B GUMBEL REGRESSION + +We characterize the concentration bounds for Gumbel Regression in this section. First, we bound the bias on applying $\mathbb { L } ^ { \beta }$ to inputs containing errors. Second, we bound the PAC learning error due to an empirical $\hat { \mathbb { L } } ^ { \beta }$ over finite $N$ samples. + +# B.1 OVERESTIMATION BIAS + +Let $\hat { Q } ( \mathbf { s } , \mathbf { a } )$ be a random variable representing a Q-value estimate for a state and action pair $( \mathbf { s } , \mathbf { a } )$ . We assume that it is an unbiased estimate of the true Q-value $Q ( \mathbf { s } , \mathbf { a } )$ with $\mathbb { E } [ \hat { Q } ( { \mathbf { s } } , { \mathbf { a } } ) ] = Q ( { \mathbf { s } } , { \mathbf { a } } )$ . Let $Q ( \mathbf { s } , \mathbf { a } ) \in [ - Q _ { m a x } , Q _ { m a x } ]$ + +Then, $V ( \mathbf { s } ) = \mathbb { L } _ { a \sim \mu } ^ { \beta } Q ( \mathbf { s } , \mathbf { a } )$ is the true value function, and $\hat { V } ( \mathbf { s } ) = \mathbb { L } _ { a \sim \mu } ^ { \beta } \hat { Q } ( \mathbf { s } , \mathbf { a } )$ is its estimate. + +Lemma B.1. We have $V ( \mathbf { s } ) \leq \mathbb { E } [ \hat { V } ( \mathbf { s } ) ] \leq \mathbb { E } _ { a \sim \mu } [ Q ( \mathbf { s } , \mathbf { a } ) ] + \beta \log \cosh ( Q _ { m a x } / \beta ) .$ + +Proof. The lower bound $V ( \mathbf { s } ) \leq \mathbb { E } [ \hat { V } ( \mathbf { s } ) ]$ is easy to show using Jensen’s Inequality as log_sum_exp is a convex function. + +For the upper bound, we can use a reverse Jensen’s inequality (Simic´, 2009) that for any convex mapping $f$ on the interval $[ a , b ]$ it holds that: + +$$ +\sum _ { i } p _ { i } f \left( x _ { i } \right) \leq f \left( \sum _ { i } p _ { i } x _ { i } \right) + f ( a ) + f ( b ) - f \left( { \frac { a + b } { 2 } } \right) +$$ + +Setting $f = - \log ( \cdot )$ and $x _ { i } = e ^ { \hat { Q } ( \mathbf { s } , \mathbf { a } ) / \beta }$ , we get: + +$$ +\mathfrak { L } _ { \mathfrak { a } \sim \mu } [ - \log ( e ^ { \hat { Q } ( \mathbf { s } , \mathbf { a } ) / \beta } ) ] \le - \log ( \mathbb { E } _ { \mathfrak { a } \sim \mu } [ e ^ { \hat { Q } ( \mathbf { s } , \mathbf { a } ) / \beta } ] ) - \log ( e ^ { Q _ { m a x } / \beta } ) - \log ( e ^ { - Q _ { m a x } / \beta } ) + \log \left( \frac { e ^ { Q _ { m a x } / \beta } - \log ( e ^ { Q _ { m a x } / \beta } ) } { \log ( \sqrt { \beta } ) } \right) . +$$ + +On simplifying, + +$$ +\hat { V } ( \mathbf { s } ) = \beta \log ( \mathbb { E } _ { \mathbf { a } \sim \boldsymbol { \mu } } e ^ { \hat { Q } ( \mathbf { s } , \mathbf { a } ) / \beta } ) \leq \mathbb { E } _ { \mathbf { a } \sim \boldsymbol { \mu } } [ \hat { Q } ( \mathbf { s } , \mathbf { a } ) ] + \beta \log \cosh ( Q _ { m a x } / \beta ) +$$ + +Taking expectations on both sides, $\mathbb { E } [ \hat { V } ( \mathbf { s } ) ] \leq \mathbb { E } _ { \mathbf { a } \sim \mu } [ Q ( \mathbf { s } , \mathbf { a } ) ] + \beta \log \cosh ( Q _ { m a x } / \beta )$ . This gives an estimate of how much the LogSumExp overestimates compared to taking the expectation over actions ndom variableand for large $\hat { Q }$ . This bias ecaying as cally decreases with . $\beta$ , with $\beta = 0$ having a max bias of $Q _ { m a x }$ $\beta$ $\frac { 1 } { 2 \beta } Q _ { m a x } ^ { 2 }$ + +# B.2 PAC LEARNING BOUNDS FOR GUMBEL REGRESSION + +Lemma B.2. $\exp ( \hat { \mathbb { L } } ^ { \beta } ( X ) / \beta )$ over a finite $N$ samples is an unbiased estimator for the partition function $Z ^ { \beta } = \mathbb { E } \left[ e ^ { X / \beta } \right]$ and with a probability at least $1 - \delta$ it holds that: + +$$ +\exp ( \hat { \mathbb { L } } ^ { \beta } ( X ) / \beta ) \leq Z ^ { \beta } + \sinh ( X _ { m a x } / \beta ) \sqrt { \frac { 2 \log { ( 1 / \delta ) } } { N } } . +$$ + +Similarly, ${ \hat { \mathbb { L } } } ^ { \beta } ( X )$ over a finite $N$ samples is a consistent estimator of $\mathbb { L } ^ { \beta } ( X )$ and with a probability at least $1 - \delta$ it holds that: + +$$ +\hat { \mathbb { L } } ^ { \beta } ( X ) \le \mathbb { L } ^ { \beta } ( X ) + \frac { \beta \sinh ( X _ { m a x } / \beta ) } { Z ^ { \beta } } \sqrt { \frac { 2 \log { ( 1 / \delta ) } } { N } } . +$$ + +Proof. To prove these concentration bounds, we consider random variables $e ^ { X _ { 1 } / \beta } , . . . , e ^ { X _ { n } / \beta }$ with $\beta > 0$ , such that $a _ { i } \leq X _ { i } \leq b _ { i }$ almost surely, i.e. $e ^ { a _ { i } / \beta } \leq e ^ { X _ { i } / \beta } \leq e ^ { b _ { i } / \beta }$ . + +We consider the sum $\begin{array} { r } { S _ { n } = \sum _ { i = 1 } ^ { N } e ^ { X _ { i } / \beta } } \end{array}$ and use Hoeffding’s inequality, so that for all $t > 0$ + +$$ +P \left( S _ { n } - \mathbb { E } S _ { n } \geq t \right) \leq \exp \left( \frac { - 2 t ^ { 2 } } { \sum _ { i = 1 } ^ { n } \left( e ^ { b _ { i } / \beta } - e ^ { a _ { i } / \beta } \right) ^ { 2 } } \right) +$$ + +To simplify, we let $a _ { i } = - X _ { m a x }$ and $b _ { i } = X _ { m a x }$ for all $i$ . We also rescale $\mathrm { \Delta t }$ as $t = N s$ , for $s > 0$ Then + +$$ +P \left( S _ { n } - \mathbb { E } S _ { n } \ge N s \right) \le \exp \left( \frac { - N s ^ { 2 } } { 2 \sinh ^ { 2 } ( X _ { m a x } / \beta ) } \right) +$$ + +We can notice that L.H.S. is same as $P ( \exp ( \hat { \mathbb { L } } ^ { \beta } ( X ) / \beta ) - \exp ( \mathbb { L } ^ { \beta } ( X ) / \beta ) \geq s )$ , which is the required probability we want. Letting the R.H.S. have a value $\delta$ , we get + +$$ +s = \sinh ( X _ { m a x } / \beta ) \sqrt { \frac { 2 \log { ( 1 / \delta ) } } { N } } +$$ + +Thus, with a probability $1 - \delta$ , it holds that: + +$$ +\exp ( \hat { \mathbb { L } } ^ { \beta } ( X ) / \beta ) \leq \exp ( \mathbb { L } ^ { \beta } ( X ) / \beta ) + \sinh ( X _ { m a x } / \beta ) \sqrt { \frac { 2 \log { ( 1 / \delta ) } } { N } } +$$ + +Thus, we get a concentration bound on $\exp ( \hat { \mathbb { L } } ^ { \beta } ( X ) / \beta )$ which is an unbiased estimator of the partition function $\breve { Z } ^ { \beta } = \exp ( \mathbb { L } ^ { \beta } ( X ) / \beta )$ . This bound becomes tighter with increasing $\beta$ , and asymptotically behaves as $\frac { X _ { m a x } } { \beta } \sqrt { \frac { 2 \log ( 1 / \delta ) } { N } }$ . + +Similarly, to prove the bound on the log-partition function ${ \hat { \mathbb { L } } } ^ { \beta } ( X )$ , we can further take $\log ( \cdot )$ on both sides and use the inequality $\log ( 1 + x ) \leq x$ , to get a direct concentration bound on ${ \hat { \mathbb { L } } } ^ { \beta } ( X )$ , + +$$ +\begin{array} { r l } & { \hat { \mathbb { L } } ^ { \beta } ( X ) \leq \mathbb { L } ^ { \beta } ( X ) + \beta \log \left( 1 + \sinh ( X _ { m a x } / \beta ) e ^ { - \mathbb { L } ^ { \beta } ( X ) / \beta } \sqrt { \frac { 2 \log \left( 1 / \delta \right) } { N } } \right) } \\ & { \quad \quad \quad = \mathbb { L } ^ { \beta } ( X ) + \beta \sinh ( X _ { m a x } / \beta ) e ^ { - \mathbb { L } ^ { \beta } ( X ) / \beta } \sqrt { \frac { 2 \log \left( 1 / \delta \right) } { N } } } \\ & { \quad \quad = \mathbb { L } ^ { \beta } ( X ) + \frac { \beta \sinh \left( X _ { m a x } / \beta \right) } { Z ^ { \beta } } \sqrt { \frac { 2 \log \left( 1 / \delta \right) } { N } } } \end{array} +$$ + +This bound also becomes tighter with increasing $\beta$ , and asymptotically behaves as $\frac { X _ { m a x } } { Z ^ { \beta } } \sqrt { \frac { 2 \log ( 1 / \delta ) } { N } }$ . + +# C EXTREME Q-LEARNING + +In this section we provide additional theoretical details of our algorithm, $\mathcal { X }$ -QL, and its connection to conservatism in CQL (Kumar et al., 2020). + +# C.1 $\mathcal { X }$ -QL + +For the soft-Bellman equation given as: + +$$ +\begin{array} { r l } & { { \cal Q } ( \mathbf { s } , \mathbf { a } ) = r ( \mathbf { s } , \mathbf { a } ) + \gamma \mathbb { E } _ { \mathbf { s } ^ { \prime } \sim P ( \cdot | \mathbf { s } , \mathbf { a } ) } V ( \mathbf { s } ) , } \\ & { \quad V ( \mathbf { s } ) = \mathbb { L } _ { \mu ( \cdot | s ) } ^ { \beta } ( { \cal Q } ( \mathbf { s } , \mathbf { a } ) ) , } \end{array} +$$ + +we have the fixed-point characterization, that can be found with a recurrence: + +$$ +V ( \mathbf { s } ) = \mathbb { L } _ { \mu ( \cdot | s ) } ^ { \beta } \left( r ( \mathbf { s } , \mathbf { a } ) + \gamma \mathbb { E } _ { \mathbf { s } ^ { \prime } \sim P ( \cdot | \mathbf { s } , \mathbf { a } ) } V ( \mathbf { s } ) \right) . +$$ + +In the main paper we discuss the case of $\mathcal { X }$ -QL under stochastic dynamics which requires the estimation of $B ^ { * }$ . Under deterministic dynamic, however, this can be avoided as we do not need to account for an expectation over the next states. This simplifies the bellman equations. We develop two simple algorithms for this case without needing $B ^ { * }$ . + +Value Iteration. We can write the value-iteration objective as: + +$$ +\begin{array} { r l } & { Q ( \mathbf { s } , \mathbf { a } ) \gets r ( \mathbf { s } , \mathbf { a } ) + \gamma V _ { \theta } ( \mathbf { s } ^ { \prime } ) , } \\ & { \quad \mathcal { I } ( \theta ) = \mathbb { E } _ { s \sim \rho _ { \mu } , a \sim \mu ( \cdot | s ) } \left[ e ^ { ( Q ( \mathbf { s } , \mathbf { a } ) - V _ { \theta } ( \mathbf { s } ) ) / \beta } - ( Q ( \mathbf { s } , \mathbf { a } ) - V _ { \theta } ( \mathbf { s } ) ) / \beta - 1 \right] . } \end{array} +$$ + +Here, we learn a single model of the values $V _ { \theta } ( \mathbf { s } )$ to directly solve Equation 35. For the current value estimate with our $V _ { \theta } ( \mathbf { s } )$ , wive alculate targets . Using our Gu $r ( \mathbf { s } , \mathbf { a } ) + \gamma V _ { \theta } ( \mathbf { s } )$ and find a new estimate amework, we can guaran $V _ { \theta } ^ { \prime } ( \mathbf { s } )$ by t as ing fin $\mathbb { L } _ { \mu } ^ { \beta }$ $\mathcal { I }$ $\mathcal { I }$ consistent estimate of the $\mathbb { L } _ { \mu } ^ { \bar { \beta } }$ , and $V _ { \theta } ( \mathbf { s } )$ will converge to the optimal $V ( \mathbf { s } )$ upto some sampling error. + +Q-Iteration. Alternatively, we can develop a Q-iteration objective solving the recurrence: + +$$ +\begin{array} { r l } & { { \cal Q } _ { t + 1 } ( \mathbf { s } , \mathbf { a } ) = r ( \mathbf { s } , \mathbf { a } ) + \gamma \mathbb { L } _ { \mathbf { a } ^ { \prime } \sim \mu } ^ { \beta } \left[ { \cal Q } _ { t } ( \mathbf { s } ^ { \prime } , \mathbf { a } ^ { \prime } ) \right] } \\ & { \quad \quad \quad = r ( \mathbf { s } , \mathbf { a } ) + \mathbb { L } _ { \mathbf { a } ^ { \prime } \sim \mu } ^ { \gamma \beta } \left[ \gamma { \cal Q } _ { t } ( \mathbf { s } ^ { \prime } , \mathbf { a } ^ { \prime } ) \right] } \\ & { \quad \quad \quad = \mathbb { L } _ { \mathbf { a } ^ { \prime } \sim \mu } ^ { \gamma \beta } \left[ r ( \mathbf { s } , \mathbf { a } ) + \gamma { \cal Q } _ { t } ( \mathbf { s } ^ { \prime } , \mathbf { a } ^ { \prime } ) \right] . } \end{array} +$$ + +where we can rescale $\beta$ to $\gamma \beta$ to move $\mathbb { L }$ out. + +This gives the objective: + +$$ +\begin{array} { r l } & { Q ^ { t } ( \mathbf { s } , \mathbf { a } ) \xleftarrow { } r ( \mathbf { s } , \mathbf { a } ) + \gamma Q _ { \theta } ( \mathbf { s } ^ { \prime } , \mathbf { a } ^ { \prime } ) , } \\ & { \mathcal { I } ( Q _ { \theta } ) = \mathbb { E } _ { \mu ( \mathbf { s } , a , \mathbf { s } ^ { \prime } ) } \left[ e ^ { ( Q ^ { t } ( \mathbf { s } , \mathbf { a } ) - Q _ { \theta } ( \mathbf { s } , \mathbf { a } ) ) / \gamma \beta } - ( Q ^ { t } ( \mathbf { s } , \mathbf { a } ) - Q _ { \theta } ( \mathbf { s } , \mathbf { a } ) ) / \gamma \beta - 1 \right] . } \end{array} +$$ + +Thus, this gives a method to directly estimate $Q _ { \theta }$ without learning values, and forms our $\mathcal { X }$ -TD3 method in the main paper. Note, that $\beta$ is a hyperparameter, so we can use an alternative hyperparameter $\beta ^ { \prime } = \gamma \beta$ to simplify the above. + +We can formalize this as a Lemma in the deterministic case: + +Lemma C.1. Let + +$$ +\mathcal { I } ( T _ { \mu } Q - Q ^ { \prime } ) = \mathbb { E } _ { { \mathbf s } , { \mathbf s } , { \mathbf s ^ { \prime } } , { \mathbf a ^ { \prime } } \sim \mu } \left[ e ^ { ( T _ { \mu } Q ( { \mathbf s } , { \mathbf a } ) - Q ^ { \prime } ( { \mathbf s } , { \mathbf a } ) / \gamma \beta } - ( T _ { \mu } Q ( { \mathbf s } , { \mathbf a } ) - Q ^ { \prime } ( { \mathbf s } , { \mathbf a } ) ) / \gamma \beta - 1 \right] . +$$ + +where $\tau _ { \mu }$ is a linear operator that maps $Q$ from current $( \mathbf { s } , \mathbf { a } )$ to the next $( \mathbf { s } ^ { \prime } , \mathbf { a } ^ { \prime } )$ : $\mathcal { T } _ { \mu } Q ( \mathbf { s } , \mathbf { a } ) : =$ $r ( \mathbf { s } , \mathbf { a } ) \dot { + } \gamma Q ( \mathbf { s } ^ { \prime } , \mathbf { a } ^ { \prime } )$ + +Then we have $B ^ { * } Q ^ { t } = \operatorname * { a r g m i n } _ { Q ^ { \prime } \in \Omega } \mathcal { I } ( T _ { \mu } Q ^ { t } - Q ^ { \prime } )$ , where $\Omega$ is the space of $Q$ -functions. + +Proof. We use that in deterministic dynamics, + +$$ +\mathbb { L } _ { { \mathbf a } ^ { \prime } \sim \mu } ^ { \gamma \beta } [ \mathcal { T } _ { \mu } Q ( { \mathbf s } , { \mathbf a } ) ] = r ( { \mathbf s } , { \mathbf a } ) + \gamma \mathbb { L } _ { { \mathbf a } ^ { \prime } \sim \mu } ^ { \beta } [ Q ( { \mathbf s } ^ { \prime } , { \mathbf a } ^ { \prime } ) ] = \mathcal { B } ^ { * } Q ( { \mathbf s } , { \mathbf a } ) +$$ + +Then solving for the unique minima for $\mathcal { I }$ establishes the above results. + +Thus, optimizing $\mathcal { I }$ with a fixed-point is equivalent to $\mathbf { Q }$ -iteration with the Bellman operator. + +# C.2 BRIDGING SOFT AND CONSERVATIVE Q-LEARNING + +Inherent Convervatism in $\mathcal { X }$ -QL Our method is inherently conservative similar to CQL (Kumar et al., 2020) in that it underestimates the value function (in vanilla Q-learning) $V ^ { \pi } ( \mathbf { s } )$ by $\begin{array} { r l } { - \beta } & { { } \mathbb { E } _ { \mathbf { a } \sim \pi ( \mathbf { a } | \mathbf { s } ) } \left[ \log { \frac { \pi ( \mathbf { a } | \mathbf { s } ) } { \pi _ { \mathcal { D } } ( \mathbf { a } | \mathbf { s } ) } } \right] } \end{array}$ whereas CQL understimates values by a factor $- \beta \mathbb { E } _ { \mathbf { a } \sim \pi ( \mathbf { a } | \mathbf { s } ) } \left[ \frac { \pi ( \mathbf { a } | \mathbf { s } ) } { \pi _ { \mathcal { D } } ( \mathbf { a } | \mathbf { s } ) } - 1 \right]$ , where $\pi _ { \mathcal { D } }$ is the behavior policy. Notice that the underestimation factor transforms $V ^ { \pi }$ in vanilla Q-learning into $V ^ { \pi }$ used in the soft-Q learning formulation. Thus, we observe that KL-regularized Q-learning is inherently conservative, and this conservatism is built into our method. + +Furthermore, it can be noted that CQL conservatism can be derived as adding a $\chi ^ { 2 }$ regularization to an MDP and although not shown by the original work (Kumar et al., 2020) or any follow-ups to our awareness, the last term of Eq. 14 in CQL’s Appendix $\mathbf { B }$ (Kumar et al., 2020), is simply $\chi ^ { \bar { 2 } } ( \pi | | \pi _ { \mathcal { D } } )$ and what the original work refers to as $D _ { C Q L }$ is actually the $\chi ^ { 2 }$ divergence. Thus, it is possible to show that all the results for CQL hold for our method by simply replacing $D _ { C Q L }$ with $D _ { K L }$ i.e. the $\chi ^ { 2 }$ divergence with the KL divergence everywhere. + +We show a simple proof below that $D _ { C Q L }$ is the $\chi ^ { 2 }$ divergence: + +$$ +\begin{array} { r l } & { \gamma _ { C Q L } \left( \pi , \pi _ { \mathcal { D } } \right) \left( \mathbf { s } \right) : = \displaystyle \sum _ { \mathbf { a } } \pi ( \mathbf { a } \mid \mathbf { s } ) \left[ \frac { \pi \left( \mathbf { a } \mid \mathbf { s } \right) } { \pi _ { \mathcal { D } } \left( \mathbf { a } \mid \mathbf { s } \right) } - 1 \right] } \\ & { \qquad = \displaystyle \sum _ { \mathbf { a } } \left( \pi ( \mathbf { a } \mid \mathbf { s } ) - \pi _ { \mathcal { D } } ( \mathbf { a } \mid \mathbf { s } ) + \pi _ { \mathcal { D } } ( \mathbf { a } \mid \mathbf { s } ) \right) \left[ \frac { \pi ( \mathbf { a } \mid \mathbf { s } ) } { \pi _ { \mathcal { D } } \left( \mathbf { a } \mid \mathbf { s } \right) } - 1 \right] } \\ & { \qquad = \displaystyle \sum _ { \mathbf { a } } \left( \pi ( \mathbf { a } \mid \mathbf { s } ) - \pi _ { \mathcal { D } } ( \mathbf { a } \mid \mathbf { s } ) \right) \left[ \frac { \pi ( \mathbf { a } \mid \mathbf { s } ) - \pi _ { \mathcal { D } } ( \mathbf { a } \mid \mathbf { s } ) } { \pi _ { \mathcal { D } } \left( \mathbf { a } \mid \mathbf { s } \right) } \right] + \sum _ { \mathbf { a } } \pi _ { \mathcal { D } } ( \mathbf { a } \mid \mathbf { s } ) \left[ \frac { \pi ( \mathbf { a } \mid \mathbf { s } ) } { \pi _ { \mathcal { D } } \left( \mathbf { a } \mid \mathbf { s } \right) } \right. } \\ & { \qquad = \displaystyle \sum _ { \mathbf { a } } \pi _ { \mathcal { D } } ( \mathbf { a } \mid \mathbf { s } ) \left[ \frac { \pi ( \mathbf { a } \mid \mathbf { s } ) } { \pi _ { \mathcal { D } } \left( \mathbf { a } \mid \mathbf { s } \right) } - 1 \right] ^ { 2 } + 0 \mathrm { s i n c e , ~ } \displaystyle \sum _ { \mathbf { a } } \pi ( \mathbf { a } \mid \mathbf { s } ) = \sum _ { \mathbf { a } } \pi _ { \mathcal { D } } ( \mathbf { a } \mid \mathbf { s } ) = 1 } \\ & { \qquad = \displaystyle x ^ { 2 } ( \pi ( \cdot \mid \mathbf { s } ) \mid \pi _ { \mathcal { D } } ( \mathbf { \cdot } \mid \mathbf { s } ) ) , \mathrm { u s i n g ~ f i e d e n i t i o n ~ o f ~ c h i s g u a r e ~ d i v e r g e n c e } } \end{array} +$$ + +Why ${ \mathcal { X } } { - } \mathbf { 0 } \mathbf { L }$ is better than CQL for offline RL In light of the above results, we know that CQL adds a $\chi ^ { 2 }$ regularization to the policy $\pi$ with respect to the behavior policy $\pi _ { \mathcal { D } }$ , whereas our method does the same using the reverse-KL divergence. + +Now, the reverse-KL divergence has a mode-seeking behavior, and thus our method will find a policy that better fits the mode of the behavior policy and is more robust to random actions in the offline dataset. CQL does not have such a property and can be easily affected by noisy actions in the dataset. + +Connection to Dual KL representation For given distributions $\mu$ and $\pi$ , we can write their KL-divergence using the dual representation proposed by IQ-Learn (Garg et al., 2021): + +$$ +D _ { K L } ( \pi \mid | \mu ) = \operatorname* { m a x } _ { x \in \mathbb { R } } \mathbb { E } _ { \mu } [ - e ^ { - x } ] - \mathbb { E } _ { \pi } [ x ] - 1 , +$$ + +which is maximized for $x = - \log ( \pi / \mu )$ . + +We can make a clever substitution to exploit the above relationship. Let $x = ( Q - \mathcal { T } ^ { \pi } \hat { Q } ^ { k } ) / \beta$ for a variable $Q \in \mathbb { R }$ and a fixed constant ${ \mathcal { T } } ^ { \pi } { \hat { Q } } ^ { k }$ , then on variable substitution we get the equation: + +$$ +\operatorname { \mathbb { E } } _ { s \sim \rho _ { \mu } } [ D _ { K L } ( \pi ( \cdot | \mathbf { s } ) ~ | | ~ \mu ( \cdot | \mathbf { s } ) ) ] = \operatorname* { m i n } _ { Q } { \mathcal { L } } ( Q ) , { \mathrm { w i t h } } +$$ + +$$ +\begin{array} { r l } & { \ z ( Q ) = \mathbb { E } _ { \mathbf { s } \sim \rho _ { \mu } , \mathbf { a } \sim \mu ( \cdot | \mathbf { s } ) } \left[ e ^ { ( T ^ { \pi } \hat { Q } ^ { k } ( \mathbf { s } , \mathbf { a } ) - Q ( \mathbf { s } , \mathbf { a } ) ) / \beta } \right] - \mathbb { E } _ { \mathbf { s } \sim \rho _ { \mu } , \mathbf { a } \sim \pi ( \cdot | \mathbf { s } ) } [ ( T ^ { \pi } \hat { Q } ^ { k } ( \mathbf { s } , \mathbf { a } ) - Q ( \mathbf { s } , \mathbf { a } ) ) / \beta ] - 1 } \end{array} +$$ + +This gives us Equation 8 in Section 3.3 of the main paper, and is minimized for $Q = \mathcal { T } ^ { \pi } \hat { Q } ^ { k } -$ $\beta \log ( \pi / \mu )$ as we desire. Thus, this lets us transform the regular Bellman update into the soft-Bellman update. + +# D EXPERIMENTS + +In this section we provide additional results and more details on all experimental procedures. + +# D.1 A TOY EXAMPLE + +![](images/de719ac44386e0fd254f407da9b6ea7f263c12be05bd36e6b9238412422ba32c.jpg) +Figure 4: Here we show the effect of using different ways of fitting the value function on a toy grid world, where the agents goal is to navigate from the beginning of the maze on the bottom left to the end of the maze on the top left. The color of each square shows the learned value. As the environment is discrete, we can investigate how well Gumbel Regression fits the maximum of the Q-values. As seen, when MSE loss is used instead of Gumbel regression, the resulting policy is poor at the beginning and the learned values fail to propagate. As we increase the value of beta, we see that the learned values begin to better approximate the optimal max Q policy shown on the very right. + +# D.2 BELLMAN ERROR PLOTS + +![](images/5fcb0aa05e4cc692f513f23f8fac010c087bff59e72890dce15258f752e55387.jpg) +Figure 5: Additional plots of the error distributions of SAC for different environments. We find that the Gumbel distribution strongly fit the errors in first two environments, Cheetah and Walker, but provides a worse fit in the Hopper environment. Nonetheless, we see performance improvements in Hopper using our approach. + +![](images/b9b54000dce514b71c9701e9ad2a003c24bd090fe4c06e154841b2cd25d70e7d.jpg) +Figure 6: Plots of the error distributions of TD3 for different environments. + +Additional plots of the error distributions for SAC and TD3 can be found in Figure 5 and Figure 6, respectively. Figure 1 and the aforementioned plots were generated by running RL algorithms for 100,000 timesteps and logging the bellman errors every 5,000 steps. In particular, the Bellman errors were computed as: + +$$ +r ( \mathbf { s } , \mathbf { a } ) + \gamma Q _ { \theta _ { 1 } } ( \mathbf { s } ^ { \prime } , \pi _ { \psi } ( \mathbf { s } ^ { \prime } ) ) - Q _ { \theta _ { 1 } } ( \mathbf { s } , \mathbf { a } ) +$$ + +In the above equation $Q _ { \theta _ { 1 } }$ represents the first of the two Q networks used in the Double Q trick. We do not use target networks to compute the bellman error, and instead compute the fully online quantity. $\pi _ { \boldsymbol { \psi } } ( \mathbf { s } ^ { \prime } )$ represents the mean or deterministic output of the current policy distribution. We used an implementation of SAC based on Yarats & Kostrikov (2020) and an implementation of TD3 based on Fujimoto et al. (2018). For SAC we did the entropy term was not added when computing the error as we seek to characterize the standard bellman error and not the soft-bellman error. Before generating plots the errors were clipped to the ranges shown. This tended prevented over-fitting to large outliers. The Gumbel and Gaussian curves we fit using MLE via Scipy. + +# D.3 NUMERIC STABILITY + +In practice, a naive implementation of the Gumbel loss function $\mathcal { I }$ from Equation 11 suffers from stability issues due to the exponential term. We found that stabilizing the loss objective was essential for training. Practically, we follow the common max-normalization trick used in softmax computation. This amounts to factoring out $e ^ { \operatorname* { m a x } _ { z } z }$ from the loss and consequently scaling the gradients. This adds a per-batch adaptive normalization to the learning rate. We additionally clip loss inputs that are too large to prevent outliers. An example code snippet in Pytorch is included below: + +def gumbel_loss(pred, label, beta, clip): $z =$ (label - pred)/beta $z =$ torch.clamp(z, -clip, clip) max_z $=$ torch.max(z) max_z $=$ torch.where(max_z < -1.0, torch.tensor(-1.0), max_z) max_z $=$ max_z.detach() # Detach the gradients loss $=$ torch.exp(z - max_z) - z\*torch.exp(-max_z) - torch.exp(-max_z) return loss.mean() + +In some experiments we additionally clip the value of the gradients for stability. + +# D.4 OFFLINE EXPERIMENTS + +In this subsection, we provide additional results in the offline setting and hyper-parameter and implementation details. + +Table 3 shows results for the Androit benchmark in D4RL. Again, we see strong results for $\mathcal { X }$ -QL, where $\mathcal { X }$ -QL-C with the same hyperparameters as used in the Franka Kitchen environments surpasses prior works on five of the eight tasks. Figure 7 shows learning curves which include baseline methods. We see that $\mathcal { X }$ -QL exhibits extremely fast convergence, particularly when tuned. One issue however, is numerical stability. The untuned version of $\mathcal { X }$ -QL exhibits divergence on the Antmaze environment. + +We base our implementation of $\mathcal { X }$ -QL off the official implementation of IQL from Kostrikov et al. (2021). We use the same network architecture and also apply the Double- $Q$ trick. We also apply the same data preprocessing which is described in their appendix. We additionally take their baseline results and use them in Table 1, Table 2, and Table 3 for accurate comparison. + +![](images/7700e154afa93411965cb103668880517bf9ba168553ec0abbfd8b1461790eee.jpg) +Figure 7: Offline RL Results. We show the returns vs number of training iterations for the D4RL benchmark, averaged over 6 seeds. For a fair comparison, we use batch size of 1024 for each method. XQL Tuned tunes the temperature for each environment, whereas XQL consistent uses a default temperature. + +We keep our general algorithm hyper-parameters and evaluation procedure the same but tune $\beta$ and the gradient clipping value for each environment. Tuning values of $\beta$ was done via hyper-parameter sweeps over a fixed set of values $[ 0 . 6 , 0 . 8 , 1 , 2 , 5 ]$ for offline save for a few environments where larger values were clearly better. Increasing the batch size tended to also help with stability, since our rescaled loss does a per-batch normalization. AWAC parameters were left identical to those in IQL. For MuJoCo locomotion tasks we average mean returns over 10 evaluation trajectories and 6 random seeds. For the AntMaze tasks, we average over 1000 evaluation trajectories. We don’t see stability issues in the mujoco locomotion environments, but found that offline runs for the AntMaze environments could occasionally exhibit divergence in training for a small $\beta < 1$ . In order to help mitigate this, we found adding Layer Normalization (Ba et al., 2016) to the Value networks to work well. Full hyper-parameters we used for experiments are given in Table 4. + +# D.5 OFFLINE ABLATIONS + +In this section we show hyper-parameter ablations for the offline experiments. In particular, we ablate the temperature parameter, $\beta$ , and the batch size. The temperature $\beta$ controls the strength of KL penalization between the learned policy and the dataset behavior policy, and a small $\beta$ is beneficial for datasets with lots of random noisy actions, whereas a high $\beta$ favors more expert-like datasets. + +Because our implementation of the Gumbel regression loss normalizes gradients at the batch level, larger batches tended to be more stable and in some environments lead to higher final performance. To show that our tuned $\mathcal { X }$ -QL method is not simply better than IQL due to bigger batch sizes, we show a comparison with a fixed batch size of 1024 in Fig. 7. + +# D.6 ONLINE EXPERIMENTS + +We base our implementation of SAC off pytorch_sac (Yarats & Kostrikov, 2020) but modify it to use a Value function as described in Haarnoja et al. (2017). Empirically we see similar performance with and without using the value function, but leave it in for fair comparison against our $\mathcal { X }$ -SAC variant. We base our implementation of TD3 on the original author’s code from Fujimoto et al. (2018). Like in offline experiments, hyper-parameters were left as default except for $\beta$ , which we tuned for each environment. For online experiments we swept over [1, 2, 5] for $\mathcal { X }$ –SAC and TD3. We found that these values did not work as well for TD3 - DQ, and swept over values [3, 4, 10, 20]. In online experiments we used an exponential clip value of 8. For SAC we ran three seeds in each environment as it tended to be more stable. For TD3 we ran four. Occasionally, our $\mathcal { X } .$ variants would experience instability due to outliers in collected online policy rollouts causing exploding loss terms. We see this primarily in the Hopper and Quadruped environments, and rarely for Cheetah or Walker. For Hopper and Quadruped, we found that approximately one in six runs became unstable after about $1 0 0 \mathrm { k }$ gradient steps. This sort of instability is also common in other online RL algorithms like PPO due to noisy online policy collection. We restarted runs that become unstable during training. We verified our SAC results by comparing to Yarats & Kostrikov (2020) and our TD3 results by comparing to Li (2021) . We found that our TD3 implementation performed marginally better overall. + +![](images/1e8fcb48ba11d1517f8768b53739a07d8180111d160d985fd736d0093450df81.jpg) +Figure 8: $\beta$ Ablation. Too large of a temperature $\beta$ and performance drops. When $\beta$ is too small, the loss becomes sensitive to noisy outliers, and training can diverge. Some environments are more sensitive to $\beta$ than others. + +![](images/6e422f0d1decabb2b904232e6a775cf174714edacdc299113beeb135dd9d99f9.jpg) +Figure 9: Batch Size Ablation. Larger batch sizes can make Gumbel regression more stable. + +Table 4: Offline RL Hyperparameters used for $\mathcal { X }$ –QL. The first values given are for the non per-environment tuned version of $\mathcal { X }$ –QL, and the values in parenthesis are for the tuned offline results, $\mathcal { X }$ –QL-T. V-updates gives the number of value updates per Q update, and increasing it reduces the variance of value updates using Gumbel loss on some hard environments. + +
EnvBetaGrad ClipBatch SizeV_updates
halfcheetah-medium-v22(1)7(7)256 (256)1(1)
hopper-medium-v22(5)7(7)256 (256)1(1)
walker2d-medium-v22(10)7(7)256 (256)1(1)
halfcheetah-medium-replay-v22(1)7(5)256 (256)1(1)
hopper-medium-replay-v22(2)7(7)256 (256)1(1)
walker2d-medium-replay-v22(5)7(7)256 (256)1(1)
halfcheetah-medium-expert-v22(1)7(5)256 (1024)1(1)
hopper-medium-expert-v22(2)7(7)256 (1024)1(1)
walker2d-medium-expert-v22(2)7(5)256 (1024)1(1)
antmaze-umaze-vO0.6 (1)7(7)256 (256)1(1)
antmaze-umaze-diverse-v00.6 (5)7(7)256 (256)1(1)
antmaze-medium-play-v00.6 (0.8)7(7)256 (1024)1(2)
antmaze-medium-diverse-vO0.6 (0.6)7(7)256 (256)1(4)
antmaze-large-play-v00.6 (0.6)7(5)256 (1024)1(1)
antmaze-large-diverse-v00.6 (0.6)7(5)256 (1024)1(1)
kitchen-complete-v05(2)7(7)256 (1024)1(1)
kitchen-partial-v05(5)7(7)256 (1024)1(1)
kitchen-mixed-v05(8)7(7)256 (1024)1(1)
pen-human-v05(5)7(7)256 (256)1(1)
hammer-human-vO5 (0.5)7(3)256 (1024)1(4)
door-human-vo5(1)7(5)256 (256)1(1)
relocate-human-v05 (0.8)7(5)256 (1024)1(2)
pen-cloned-v05 (0.8)7(5)256 (1024)1(2)
hammer-cloned-v05(5)7(7)256 (256)1(1)
door-human-vo5(5)7(7)256 (256)1(1)
relocate-human-vO5(5)7(7)256 (256)1(1)
+ +Table 5: Hyperparameters for online RL Algorithms + +
ParameterSACTD3
Batch Size1024256
Learning Rate0.00010.001
Critic Freq11
Actor Freq12
Actor and Critic Arch1024,1024256,256
Buffer Size1,000,0001,000,000
Actor NoiseAuto-tuned0.1,0.05 (Hopper)
Target Noise0.2
+ +Table 6: Values of temperature $\beta$ used for online experiments + +
EnvX-SACX-TD3X-TD3-DQ
Cheetah Run254
Walker Run124
Hopper Hop223
Quadruped Run5520
+ +![](images/497f7ee3496e7a52972939b1a8ab5123e77c2c0d111aa6538fb1469f48d8e650.jpg) +Figure 10: Offline Mujoco Results. We show the returns vs number of training iterations for the mujoco benchmarks in D4RL (Averaged over 6 seeds). $\mathcal { X }$ -QL Tuned gives results after hyper-parameter tuning to reduce run variance for each environment, and $\mathcal { X }$ -QL consistent uses the same hyper-parameters for every environment. + +![](images/6aae9085cb60f245fcf3615e51dd98fa4fb3fdd3d77537da06e57346c1b4e8de.jpg) +Figure 11: Offline AntMaze Results. We show the returns vs number of training iterations for the antmaze benchmarks in D4RL (Averaged over 6 seeds). $\mathcal { X }$ -QL Tuned gives results after hyper-parameter tuning to reduce run variance for each environment, and $\mathcal { X }$ -QL consistent uses the same hyper-parameters for every environment. + +![](images/0e88149f29860f0fb9e0e7bb504281b9f7af591c1232648ec14d2701b5472934.jpg) +Figure 12: Offline Franka Results. We show the returns vs number of training iterations for the Franka Kitchen benchmarks in D4RL (Averaged over 6 seeds). $\mathcal { X }$ -QL Tuned gives results after hyper-parameter tuning to reduce run variance for each environment, and $\mathcal { X }$ -QL consistent uses the same hyper-parameters for every environment. + +![](images/f9d2d4bfaa41771c1879902b29d679a75484025b1a6756e8ccf5d6de165f22fe.jpg) +Figure 13: Offline Androit Results. We show the returns vs number of training iterations for the Androit benchmark in D4RL (Averaged over 6 seeds). $\mathcal { X }$ -QL Tuned gives results after hyper-parameter tuning to reduce run variance for each environment, and $\mathcal { X }$ -QL consistent uses the same hyper-parameters for every environment. On some environments the “consistent” hyperparameters did best. \ No newline at end of file diff --git a/md/dev/TrjbxzRcnf-/TrjbxzRcnf-.md b/md/dev/TrjbxzRcnf-/TrjbxzRcnf-.md new file mode 100644 index 0000000000000000000000000000000000000000..32bc3edbdd003c9a938122555a5b9a31e9293c40 --- /dev/null +++ b/md/dev/TrjbxzRcnf-/TrjbxzRcnf-.md @@ -0,0 +1,447 @@ +# MEMORIZING TRANSFORMERS + +Yuhuai Wu, Markus N. Rabe, DeLesley Hutchins, Christian Szegedy + +{yuhuai,mrabe,delesley,szegedy}@google.com + +# ABSTRACT + +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. + +# 1 INTRODUCTION + +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. + +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. + +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). + +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. + +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. + +![](images/c348262572039ee17a0180d1f12a1ab33318f7e59c45735bf4ae47b93ca7fd68.jpg) +Figure 1: Adding a memory of 8K tokens improves perplexity across different model sizes. + +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. + +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. + +# 2 RELATED WORK + +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. + +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. + +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. + +![](images/93d8466b573b5325cd9a069c63eddcdd2572eb8799f9d4720b8a3dbfc7a46115.jpg) +Figure 2: We extend Transformers with access to (key, value) pairs of previously seen subsequences. + +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.) + +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. + +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. + +$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. + +# 3 METHOD + +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. + +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). + +![](images/81f98de49b0afcae04d1631ab7e72f49483236312e44999b1680cfebdad0dc90.jpg) +Figure 3: Our data pipeline splits documents into subsequences and packs subsequences into batches. + +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. + +# 3.1 $k$ NN-AUGMENTED ATTENTION LAYER + +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. + +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. + +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. + +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: + +$$ +\begin{array} { c } { { g = \sigma ( b _ { g } ) } } \\ { { V _ { a } = V _ { m } \odot g + V _ { c } \odot ( 1 - g ) } } \end{array} +$$ + +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. + +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. + +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. + +# 3.2 DISTRIBUTIONAL SHIFT + +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. + +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. + +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. + +# 3.3 APPROXIMATE $k \mathbf { N N }$ + +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. + +# 4 EXPERIMENTS + +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. + +# 4.1 DATASETS + +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. + +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. + +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. + +Table 4: Average token-level perplexities of each model when trained for 500k steps. + +
ContextMemoryXL cachearXivPG19C4(4K+)GitHubIsabelle
512NoneNone3.2913.7117.203.053.09
2048NoneNone2.6912.3714.812.222.39
512None5122.6712.3415.382.262.46
2048None20482.4211.8814.032.102.16
5121536None2.6112.5014.972.202.33
5128192None2.4912.2914.422.092.19
51281925122.3711.9314.042.032.08
51265K5122.3111.6214.041.872.06
2048819220482.3311.8413.801.982.06
204865K20482.2611.3713.641.801.99
+ +$\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. + +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. + +# 4.2 EXPERIMENTAL METHOD + +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. + +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). + +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. + +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). + +# 4.3 EFFECT OF EXTERNAL MEMORY + +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. + +
ContextPretrainFine-tunePerplexity
5128192None2.37
51265KNone2.31
512819265K2.32
5128192131K2.30
5128192262K2.26
20488192None2.33
204865KNone2.26
204865K131K2.23
204865K262K2.21
+ +Table 5: Finetuning for 20K steps to make use of a larger memory on the arXiv data set. + +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. + +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. + +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. + +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. + +# 4.4 SCALING TO LARGER MODELS + +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. + +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. + +# 4.5 FINETUNING ON LARGER MEMORIES + +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). + +![](images/14d1bef481a2ec3931ed59a899d428ebe8a68caed797c0d03c05a6ce7c996ad0.jpg) +Figure 6: Finetuning a 1B vanilla Transformer model to use external memory of size 65K. + +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! + +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. + +# 4.6 INFORMATION RETRIEVAL PATTERNS + +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. + +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. + +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. + +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. + +![](images/ac7dcbfadeffdce1e7c62204b4feff0227f84bf9079091c5be4d5700f286a668.jpg) +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. + +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. + +
Query indexInputTargetSurrounding contextRetrieved index Retrieved surrounding context
29721markovrule prob_space. markov_inequality8088M.t\<le> X a} \<le> expectation X /t"
409191th= ( subgraph_threshold Hn / p n)27219threshold H n = n powr (-(1 / max_density’
49699SWassumes' orthonormal_system Sw"28050definition orthonormal_system “
+ +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. + +# 5 CONCLUSION + +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. + +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. + +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. + +# ACKNOWLEDGMENTS + +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. + +# ETHICS + +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. + +# REPRODUCIBILITY + +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. + +# REFERENCES + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. BERT: pre-training of deep bidirectional transformers for language understanding. In ACL, 2019. + +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. + +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. + +Edouard Grave, Armand Joulin, and Nicolas Usunier. Improving neural language models with a continuous cache. In ICLR, 2017. + +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. + +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. + +Kelvin Guu, Kenton Lee, Zora Tung, Panupong Pasupat, and Ming-Wei Chang. Retrieval augmented language model pre-training. In ICML, 2020. + +Christopher Hahn, Frederik Schmitt, Jens U. Kreber, Markus Norman Rabe, and Bernd Finkbeiner. Teaching temporal logics to neural networks. In ICLR, 2021. + +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. + +Alex Henry, Prudhvi Raj Dachapally, Shubham Shantaram Pawar, and Yuxuan Chen. Query-key normalization for transformers. In EMNLP, 2020. + +Jeff Johnson, Matthijs Douze, and Hervé Jégou. Billion-scale similarity search with GPUs. IEEE Transactions on Big Data, 2021. + +Urvashi Khandelwal, Omer Levy, Dan Jurafsky, Luke Zettlemoyer, and Mike Lewis. Generalization through memorization: Nearest neighbor language models. In ICLR, 2020. + +Nikita Kitaev, Łukasz Kaiser, and Anselm Levskaya. Reformer: The efficient transformer. In ICLR, 2020. + +Taku Kudo and John Richardson. Sentencepiece: A simple and language independent subword tokenizer and detokenizer for neural text processing. In EMNLP, 2018. + +Guillaume Lample, Alexandre Sablayrolles, Marc’Aurelio Ranzato, Ludovic Denoyer, and Hervé Jégou. Large memory layers with product keys. In NeurIPS, 2019. + +Mike Lewis, Marjan Ghazvininejad, Gargi Ghosh, Armen Aghajanyan, Sida Wang, and Luke Zettlemoyer. Pre-training via paraphrasing. In NeurIPS, 2020a. + +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. + +Wenda Li, Lei Yu, Yuhuai Wu, and Lawrence C. Paulson. Isarstep: a benchmark for high-level mathematical reasoning. In ICLR, 2021. + +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. + +Stanislas Polu and Ilya Sutskever. Generative language modeling for automated theorem proving. CoRR, abs/2009.03393, 2020. URL https://arxiv.org/abs/2009.03393. + +Markus Norman Rabe, Dennis Lee, Kshitij Bansal, and Christian Szegedy. Mathematical reasoning via self-supervised skip-tree training. In ICLR, 2021. + +Jack W Rae, Anna Potapenko, Siddhant M Jayakumar, Chloe Hillier, and Timothy P Lillicrap. Compressive transformers for long-range sequence modelling. In ICLR, 2020. + +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. + +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. + +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. + +Noam Shazeer and Mitchell Stern. Adafactor: Adaptive learning rates with sublinear memory cost. In ICML, 2018. + +Sainbayar Sukhbaatar, Edouard Grave, Guillaume Lample, Herve Jegou, and Armand Joulin. Augmenting self-attention with persistent memory. arXiv preprint arXiv:1907.01470, 2019. + +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. + +Simeng Sun, Kalpesh Krishna, Andrew Mattarella-Micke, and Mohit Iyyer. Do long-range language models actually use long-range context? In EMNLP, 2021. + +Yi Tay, Mostafa Dehghani, Dara Bahri, and Donald Metzler. Efficient transformers: A survey. arXiv preprint arXiv:2009.06732, 2020. + +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. + +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. + +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. + +Sinong Wang, Belinda Z Li, Madian Khabsa, Han Fang, and Hao Ma. Linformer: Self-attention with linear complexity. arXiv preprint arXiv:2006.04768, 2020b. + +Xun Wang, Haozhi Zhang, Weilin Huang, and Matthew R. Scott. Cross-batch memory for embedding learning. In CVPR, 2020c. + +Ronald J. Williams and Jing Peng. An efficient gradient-based algorithm for on-line training of recurrent network trajectories. Neural Computation, 1990. + +Dani Yogatama, Cyprien de Masson d’Autume, and Lingpeng Kong. Adaptive semiparametric language models. ACL, 9:362–373, 2021. + +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. + +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. + +Zhenhai Zhu and Radu Soricut. H-transformer-1d: Fast one-dimensional hierarchical attention for sequences. In ACL, 2021. + +# A LENGTH OF INPUTS + +![](images/590dba826b536883dbd7b839ee67cfd0767b9162d302b75f3df6ce355c757fe0.jpg) + +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. + +![](images/392ac5da3e6f25f1ea04b96cb84fa3eff4102cd04a0f0ce5ff97fef8be49ba65.jpg) + +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. + +![](images/869058a85d9ebbb8cb3aece05d5f6c75030dc1420ab9ed7ce7b5e7a8cff0cae2.jpg) +Figure 11: Histogram of the number of tokens in Isabelle proof scripts dataset. + +![](images/bdeca69f56f05a45e94288812872dd89cc33979dff117d6c86f428d2a5fc1362.jpg) +Figure 12: Histogram of the number of tokens in PG19 books dataset. + +![](images/049c1502062b0ef6c727e79a603400063a529317f7c6978f8199ef3811fadea6.jpg) +Figure 13: Histogram of the number of tokens in C4 documents filtered by documents that have less than 4096 tokens. + +# A.1 ABLATION STUDIES + +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. + +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. + +$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. + +Table 14: Different layer index. + +
Layer indexPerplexity
32.40
62.36
92.37
122.43
+ +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. + +Table 15: Number of neighbors. + +
Number of neighborsPerplexity
322.38
1282.37
2562.37
+ +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. + +Table 16: Random seeds. + +
ModelsPerplexity
Transformer XL2.67± 0.01
Memorizing Transformer2.37 ± 0.005
+ +B WHAT DOES THE MODEL RETRIEVE FROM MEMORY? + +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. + +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. + +
Query index1InputtTargetSurrounding contextRetrieved index Retrieved surrounding context
20389Monthusbibitem{ComtetMonthusYor2208Brownian motion \cite{ComtetMonthus Yor
16623chakra\cite{ chakrabarti)4677~1.2 of\cite{chakrabarti
14747asd\eqref( asdfg ) }which3365begin{equation}\n \labelt asdfg
+ +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. + +Table 18: Examples of memory retrieval in the Github dataset. The model looks up how functions are used elsewhere in the repository. + +
Query indexInputTargetSurrounding contextRetrieved indexRetrieved surrounding context
23837Fontemenu_play-> setarFonte14607menu_load-> setarFonte
2382535hscreen/2-50,50,200,35 );1459920, y+40,200,35)
14546->adipanel-> adicionaComponente5205panel-> adicionaComponente
+ +# B.1 MORE RETRIEVING EXAMPLES IN FORMAL THEOREM PROVING CORPU + +# Example 1 + +• Input token index: 64604 +• Input token: “_” +• Target token: “pair” +• Surrounding context: )) by (simp add: Fourier_sum_limit_pair [OF f, symmetric] Fourier’ • Name needs to be predicted: Fourier_sum_limit_pair +• Retrieved token: “Four” +• Retrieved token index: 64412 +• Retrieved context: $2 ^ { \ast } { \mathfrak { n } }$ . Fourier_coefficient f k \* trigonometric_set k t) +• 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. kn. a k \* trigonometric_set k x) Name needs to be predicted: orthonormal_system_trigonometric_set Retrieved token: “gon” +• Retrieved token index: 35457 +• Retrieved context: lemma orthonormal_system_trigonometric_set: $\backslash \mathrm { n }$ "orthonormal_system +• Definition of the name: + +![](images/83343cb6eed79c43cb0dd8e243d363d5ae700fb0872618464e56ae9135f177c1.jpg) +Figure 19: Definition of Fourier_sum_limit_pair. +Figure 20: Definition of orthonormal_system_trigonometric_set. + +# Example 3 + +• Input token index: 49760 +• Input token: “sum”’ +• Target token: “m” +• Surrounding context: nusing Fourier_series_square_summable [OF assms, of’ +• Name needs to be predicted: Fourier_series_square_summable +• Retrieved token: “sum” +• Retrieved token index: 35457 +• Retrieved context: lemma Fourier_series_square_summable\n assumes: +• Definition of the name: + +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)" + +Figure 21: Definition of Fourier_series_square_summable. + +# Example 4 + +• Input token index: 49697 +• Input token: “_”’ +• Target token: “system” +• Surrounding context: lemma Riemann_lebesgue_square_integrable: nassumes "orthonormal_system S w +• Name needs to be predicted: orthonormal_system +• Retrieved token: “system” +• Retrieved token index: 28052 +• Retrieved context: definition orthonormal_system :: "\’a::euclidean’ +• Definition of the name: + +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)" + +# Example 5 + +• Input token index: 34817 +• Input token: “.”’ +• Target token: “b” +• Surrounding context: shows "integrable (lebesgue_on {a..b}) +• Retrieved token 1: “.” +• Retrieved token index 1: 2416 +• Retrieved context 1: lebesgue_on {a..b}) f i +• Retrieved token 2: “-” +• Retrieved token index 2: 2445 +• Retrieved context 2: (lebesgue_on {a-c..b-c}) ( +• Retrieved token 3: “-” +• Retreived token index 3: 6479 +• Retrieved context 3: (lebesgue_on {-pi..pi}) ( + +# Example 6 + +• Input token index: 49759 +• Input token: “_”’ +• Target token: “sum” +• Surrounding context: $0 " \backslash \mathtt { n }$ using Fourier_series_square_summable [OF assms +• Retrieved token 1: “set” +• Retrieved token index 1: 35044 +• Retrieved context 1: definition trigonometric_set :: "nat \ +• Retrieved token 2: “ier” +• Retrieved token index 2: 47272 +• Retrieved context 2: definition Fourier_coefficient\nwhere +• Retrieved token 3: “ine” +• Retrieved token index 3: 18160 +• Retrieved context 3: lemma Schwartz_inequality_strong:\nassumes “f’ +• Retrieved token 4: “system” +• Retrieved token index 4: 28052 +• Retrieved context 4: definition orthonormal_system :: “\’a::euclidean’ +• Retrieved token 5: “<” +• Retrieved token index 5: 47241 +• Retrieved context 5: subsection\Convergence wrt the L’ +• Retrieved token 6: “n” +• Retrieved token index 6: 40835 +• Retrieved context 6: \n subsection\A bit of extra’ \ No newline at end of file diff --git a/md/dev/TwyEk7HzJb6/TwyEk7HzJb6.md b/md/dev/TwyEk7HzJb6/TwyEk7HzJb6.md new file mode 100644 index 0000000000000000000000000000000000000000..4b14b5b180b41a14c556144d83ed8b9f3c080676 --- /dev/null +++ b/md/dev/TwyEk7HzJb6/TwyEk7HzJb6.md @@ -0,0 +1,440 @@ +# Bandit Learning in Many-to-one Matching Markets with Uniqueness Conditions + +Anonymous Author(s) +Affiliation +Address +email + +# Abstract + +1 An emerging line of research is dedicated to the problem of one-to-one matching +2 markets with bandits, where the preference of one side is unknown and thus we +3 need to match while learning the preference through multiple rounds of interaction. +4 However, in many real-world applications such as online recruitment platform for +5 short-term workers, one side of the market can select more than one participant from +6 the other side, which motivates the study of the many-to-one matching problem. +7 Moreover, the existence of a unique stable matching is crucial to the competitive +8 equilibrium of the market. In this paper, we first introduce a more general new $\tilde { \alpha }$ - +9 condition to guarantee the uniqueness of stable matching in many-to-one matching +10 problems, which generalizes some established uniqueness conditions such as $S P C$ +11 and Serial Dictatorship, and recovers the known $\alpha$ -condition if the problem is +12 reduced to one-to-one matching. Under this new condition, we design an MO +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, +14 $N$ is the number of agents, $K$ is the number of arms, and $\Delta$ is the minimum +15 reward gap. Extensive experiments show that our algorithm achieves uniform good +16 performances under different uniqueness conditions. + +# 17 1 Introduction + +18 The rise of platforms for the online matching market has led to an emergence of opportunities for +19 companies to participate in personalized decision-making [14, 18]. Companies (like Thumbtack +20 and Taskrabbit and Upwork platforms) use online platforms to address short-term needs or seasonal +21 spikes in production demands, accommodate workers who are voluntarily looking for more flexible +22 work arrangements or probation period before permanent employment. The supply and demand +23 sides in two-sided markets make policies on the basis of their diversified needs, which is abstracted +24 as a matching market with agent side and arm side, and each side has a preference profile over the +25 opposite side. They choose from the other side according to preference and perform a matching. The +26 stability of the matching result is a key property of the market [32, 1, 27]. +27 The preferences in the online labor market may be unknown to one side in advance, thus matching +28 while learning the preferences is necessary. The multi-armed bandit (MAB) [36, 13, 4] is an important +29 tool for $N$ independent agents in matching market simultaneously selecting arms adaptively from +30 received rewards at each round. The idea of applying MAB to one-to-one matching problems, +31 introduced by [21], assumes that there is a central platform to make decisions for all agents. Following +32 this, other works [22, 34, 7] consider a more general decentralized setting where there is no central +33 platform to arrange matchings, and our work is also based on this setting. +34 However, it is not enough to just study the one-to-one setting. Take online short-term worker +35 employment as an example, it is an online platform design with an iterative matching, where +36 employers have numerous similar short-term tasks or internships to be recruited. Workers can only +37 choose one task according to the company’s needs at a time while one company can accept more +38 than one employee. Each company makes a fixed ranking for candidates according to its own +39 requirements but workers have no knowledge of companies’ preferences. The reward for workers +40 is a comprehensive consideration of salary and job environment. Since tasks are short-term, each +41 candidate can try many times in different companies to choose the most suitable job. We abstract +42 companies as arms and workers as agents. Each arm has a capacity $q$ which is the maximum number +43 of agents this arm can accommodate. When an arm faces multiple choices, it accepts its most $q$ +44 preferred agents. Agents thus compete for arms and may receive zero reward if losing the conflict. It +45 is worth mentioning that arms with capacity $q$ in the many-to-one matching can not just be replaced +46 by $q$ independent individuals with the same preference since there would be implicit competition +47 among different replicates of this arm, not equal treatment. In addition, when multiple agents select +48 one arm at a time, there may be no collision, which will hinder the communication among different +49 agents under the decentralized assumption. They cannot distinguish who is more preferred by this +50 arm in one round as it can accept more than one agent while this can be done in one-to-one case. +51 Communication here lets each agent learn more about the preferences of arms and other agents, so as +52 to formulate better policies to reduce collisions and learn fast about their stable results. +53 This work focuses on a many-to-one market under uniqueness conditions. Previous work [10, 15] +54 emphasize the importance of constructing a unique stable matching for the equilibrium of matching +55 problems and some existing uniqueness conditions are studied in many-to-one matching, such as +56 Sequential Preference Condition (SPC) and Acyclicity [26, 2]. Our work is motivated by [7], but the +57 unique one-to-one mapping between arms and agents in their study which gives a surrogate threshold +58 for arm elimination does not work in the many-to-one setting. And the uniqueness conditions in +59 many-to-one matching are not well-studied, which also brings a challenge to identify and leverage +60 the relationship between the resulting stable matching and preferences of two sides in the design +61 of bandit algorithms. We propose an $\tilde { \alpha }$ -condition that can guarantee a unique stable matching and +62 recover $\alpha$ -condition [19] if reduced to the one-to-one setting. We establish the relationships between +63 our new $\tilde { \alpha }$ -condition and existing uniqueness conditions in many-to-one setting. +64 In this paper, we study the bandit algorithm for a decentralized many-to-one matching market +65 with uniqueness conditions. Under our newly introduced $\tilde { \alpha }$ -condition, we design an MO-UCB-D4 +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$ +67 is the number of agents, $K$ is the number of arms, and $\Delta$ is the minimum reward gap. Finally, +68 we conduct a series of experiments to simulate our algorithm under various conditions of Serial +69 dictatorship, $S P C$ and $\tilde { \alpha }$ -condition to study the stability and regret of the algorithm. +70 Related Work The study of matching markets has a long history in economics and operation +71 research [8, 6, 32] with real applications like school enrollment, labor employment, hospital resource +72 allocation, and so on [1, 23, 31, 17]. A salient feature of market matching is making decisions for +73 competing players on both sides [36, 12]. MAB is an important tool to study matching problems under +74 uncertainty to obtain a maximum reward, and upper confidence bound algorithm (UCB) [4] is a typical +75 algorithm, which sets a confidence interval to represent uncertainty. Matching market with MAB is +76 studied in both centralized and decentralized setting [21, 22]. Following these, Abishek Sankararaman +77 et al. [34] propose a phased UCB algorithm under a uniqueness condition, Serial Dictatorship, to +78 manage collisions. They solve the problem of the decentralized market without knowing arm-gaps +79 or time horizon, and reduce the probability of linear regret through non-monotonic arm elimination. +80 The introduction of the uniqueness condition plays an important role in the equilibrium of matching +81 results [15, 7]. Under a stronger and robust condition, Uniqueness Consistency [19], Soumya Basu +82 et.al [7] apply MAB to online matching and obtain robust results that the subset of stable matchings +83 being separated from the system does not affect other stable matchings. +84 We discuss many-to-one problems such as online short-term employment and MOOC [14, 24, 18] as +85 the one-to-one setting has limitations in practice. Somouaoga Bonkoungo [9] runs a student-proposing +86 deferred acceptance algorithm (DA) [12] to study decentralized college admission. Ahmet Altinok +87 [3] considers dynamic matching in many-to-one that can be solved as if it is static many-to-one or +88 dynamic one-to-one under certain assumptions. As the existence and uniqueness of competitive +89 equilibrium and core are important to allocations, the unique stable results need to be considered [27]. +90 Similar to conditions for unique stable matching in one-to-one, some uniqueness conditions of stable +91 results in the many-to-one setting also are studied [16, 28, 15, 2, 27]. +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}$ +94 are a finite arm set and a finite agent set, respectively. And each arm $k$ has a capacity $q _ { k } \geq 1$ . To +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 +96 fixed preference order of agents and arms, which is ranked by the mean reward. We assume that arm +97 preferences for agents are unknown and needed to be learned. If agent $j$ prefers arm $k$ over $k ^ { \prime }$ , which +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 +99 $k \neq k ^ { \prime }$ . Similarly, each arm $k$ has a fixed and known preference $\succ _ { k }$ over all agents, and specially, +100 $j \succ _ { k } j ^ { \prime }$ means that arm $k$ prefers agent $j$ over $j ^ { \prime }$ . Throughout, we focus on the market where all +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 ]$ . +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 +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 +104 denote whether $j$ is successfully matched with its selected arm. $M _ { t } ( j ) = 1$ if agent $j$ is matched with +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 +106 can successfully match. The agent $j$ matched with arm $k$ can observe the reward $X _ { j , m _ { t } ( j ) } ( t )$ , where +107 the random reward $X _ { j , k } ( t ) \in [ 0 , 1 ]$ is independently drawn from a fixed distribution with mean $\mu _ { j , k }$ . +108 While the unmatched ones have collisions and receive zero reward. Generally, the reward obtained by +109 agent $j$ is $X _ { j , I _ { t } ( j ) } ( t ) \ M _ { t } ( j )$ . +110 An agent $j$ and an arm $k$ form a blocking pair for a matching $m$ if they are not matched but prefer +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 +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, +113 every worker prefers to find a job rather than do nothing, and every company also wants to recruit +114 workers rather than not recruit anyone. Under the IR condition, a matching in the many-to-one setting +115 is stable if there does not exist a blocking pair [33, 35]. +116 This paper considers the matching markets under the uniqueness condition. Thus the overall goal is +117 to find the unique stable matching between the agent side and arm side through iterations. Let $m ^ { * } ( j )$ +118 be the stable matched arm for agent $j$ under the stable matching $m ^ { * }$ . The reward obtained by agent $j$ +119 is compared against the reward received by matching with $m ^ { * } ( j )$ at each time. We aim to minimize +120 the expected stable regret for agent $j$ over time horizon $T$ , which is defined as + +$$ +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] . +$$ + +# 121 3 Algorithm + +122 In this section, we introduce our MO-UCB-D4 Algorithm (Many-to-one UCB with Decentralized +123 Dominated arms Deletion and Local Deletion Algorithm) (Algorithm 1) for the decentralized many +124 to-one market, where there is no platform to arrange actions for agents, which leads to conflicts +125 among agents. The MO-UCB-D4 algorithm for each agent $j$ first takes agent set $\mathcal { I }$ and arm set $\kappa$ a s +126 input and chooses a parameter $\theta \in ( 0 , 1 / K )$ (discussed in Section C). It sets multiple phases, and +127 each phase $i$ mainly includes regret minimization block (line 6 - 12) and communication block (line +128 $1 3 - 1 6 )$ ) with duration $2 ^ { i - 1 } , i = { \bar { 1 } } , 2 , \cdots$ . +129 For each agent $j$ in phase $i$ , the algorithm adds arm deletion to reduce potential conflicts, which +130 mainly contains global deletion and local deletion. The former eliminates the arms most preferred +131 by agents who rank higher than agent $j$ and obtain active set $\mathrm { C h } _ { j } [ i ]$ (line 4), and the latter deletes +132 the arms that still have many conflicts with agent $j$ after global deletion (line 6). We set a collision +133 counter $C _ { j , k } [ i ]$ to record the number of collisions for agent $j$ pulling arm $k$ . + +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 + +# Algorithm 1 MO-UCB-D4 algorithm (for agent $j$ ) + +Input: +$\theta \in ( 0 , 1 / K )$ , $\alpha > 1$ . +1: Set global dominated set $G _ { j } [ 0 ] = \phi$ +2: for phase $i = 1 , 2 , \dots$ do +3: Reset the collision set $C _ { j , k } [ i ] = 0$ , $\forall k \in [ K ]$ ; +4: Reset active arms set $\begin{array} { r } { \dot { \mathsf { C h } _ { j } } [ i ] = [ K ] \backslash G _ { j } [ i - 1 ] } \end{array}$ ; +5: if $t < 2 ^ { i } + N K ( i - 1 )$ then +6: Local deletion $L _ { j } [ i ] = \{ k : C _ { j k } [ i ] \geq \lceil \theta 2 ^ { i } \rceil \}$ ; +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}$ +8: if $k = I _ { t } ( j )$ is successfully matched with agent $j$ , i.e. $m _ { t } ( j ) = k$ then +9: Update estimate $\hat { \mu } _ { j , k } ( t )$ and matching count $N _ { j , k } ( t )$ ; +10: else +11: $C _ { j , k } [ i ] = C _ { j , k } [ i ] + 1 ;$ +12: end if +13: else if $t = 2 ^ { i } + N K ( i - 1 )$ then +14: $\mathcal { O } _ { j } [ i ] \mathrm { m o s t }$ matched arm in phase $i$ ; +15: $G _ { j } \bar { [ } i ] C O M M U N I C A T I O N ( i , { \mathcal { O } } _ { j } [ i ] ) ;$ ; +16: end if +17: end for +139 $k$ have been matched at time $t - 1$ . If the selected arm is successfully matched with agent $j$ , then the +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 )$ +141 and $N _ { j , k } ( t )$ (line 9). Otherwise, the collision happens (line 11) and $j$ receives zero reward. The +142 regret minimization block identifies the most played arm $\mathcal { O } _ { j } [ i ]$ for agent $j$ in each phase $i$ , which is +143 estimated as the best arm for $j$ , thus making optimal policy to minimize expected regret. + +# Algorithm 2 COMMUNICATION + +# + +Phase number $i$ , and most played arms $\mathcal { O } _ { j } [ i ]$ for agent $j , \forall j \in [ N ]$ . +1: Set ${ \mathcal { C } } = \emptyset$ ; +2: for $t = 1 , 2 , \cdots , N K - 1$ do +3: if $K ( j - 1 ) \le t \le K j - 1$ then +4: Agent $j$ plays arm $\begin{array} { r } { \bar { I } _ { t } ( j ) = ( t \mod K ) + 1 } \end{array}$ ; +5: if Collision Occurs then +6: $\mathcal { C } = \mathcal { C } \cup \{ I _ { t } ( j ) \}$ ; +7: end if +8: else +9: Play arm $I _ { t } ( j ) = \mathcal { O } _ { j } [ i ]$ ; +10: end if +11: end for +12: RETURN $\mathcal { C }$ ; +144 In the communication block (Algorithm 2), there are $N$ sub-blocks, each with duration $K$ . In the +145 $\ell - t h$ sub-block, only agent $\ell$ pulls arm 1, arm $2 , \cdots$ , arm $K$ in round-robin while the other agents +146 select their most preferred arms estimated as the most played ones (line 4). This block aims to detect +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 +148 globally dominated arms set for agent $j$ is denoted as $G _ { j } ^ { * }$ . After the communication block in phase +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 +150 $G _ { j } [ i ]$ , and enters into the next phase (line 4 in Algorithm 1). +151 Hence, multi-phases setting can guarantee that the active set in different phases has no inclusion +152 relationship so that if an agent deletes an arm in a certain phase, this arm can still be selected in the +153 later rounds. This ensures that each agent will not permanently eliminate its stable matched arm, and +154 when the agent mistakenly deletes an arm, it will not lead to linear regret. + +# 4 Results + +# 4.1 Uniqueness Conditions + +# 4.1.1 $\tilde { \alpha }$ -condition + +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. + +Definition 1. A preference profile satisfies uniqueness consistency if and only if (i) there exists a unique stable matching $m ^ { * }$ ; + +(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. + +170 It guarantees that even if an arbitrary subset of agents are deleted out of the system with their +171 respective stable matched arms, there still exists a unique stable matching among the remaining +172 agents and arms. This condition allows any algorithm to identify at least one stable pair in a unique +173 stable matching system and guides the system to a global unique stable matching in an iterative +174 manner. To obtain consistent stable results in the many-to-one market, we propose a new $\tilde { \alpha }$ -condition, +175 which is a sufficient and necessary condition for Unqc (proved in Appendix B). +176 We considers a finite set of arms $[ K ] = \{ 1 , 2 , \cdots , K \}$ and a finite set of agents $[ N ] = \{ 1 , 2 , \cdots , N \}$ +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 \}$ +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 +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 +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 ]$ +181 Considering arm capacity, we denote $\gamma ^ { * } ( c _ { k } )$ (right order) as the stable matched agents set for arm $c _ { k }$ + +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 + +$$ +\forall j \in [ N ] , \forall k > j , k \in [ K ] , \mu _ { j , m ^ { * } ( j ) } > \mu _ { j , k } , +$$ + +where 183 $m ^ { * } ( j )$ is agent $j$ ’s stable matched arm; + +(ii) The right order of agents and arms satisfies + +$$ +\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} +$$ + +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 }$ + +186 Under our $\tilde { \alpha }$ -condition, the left order and the right order satisfy the following rule. The left order +187 gives rankings according to agents’ preferences. The first agent in the left order set $[ N ]$ prefers arm 1 +188 in $[ K ]$ most and has it as the stable matched arm. Similar properties for the agent 2 to $q _ { 1 }$ since arm 1 +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 +190 matched arm and prefers arm 2 most except arm 1. The remaining agents follow similarly. Similarly, +191 the right order gives rankings according to arms’ preferences. The first arm 1 in the right order set +192 $[ K ] _ { r }$ most prefers first $q _ { c _ { 1 } }$ agents in the right order set $[ N ] _ { r }$ and takes them as its stable matched +193 agents. The remaining arms follow similarly. +194 This condition is more general than existing uniqueness conditions like SPC [28] and can recover +195 the known $\alpha$ -condition in one-to-one matching market [19]. The relationship between the existing +196 uniqueness conditions and our proposed conditions will be analyzed in detail later in Section 4.1.2. +197 The main idea from one-to-one to many-to-one analysis is to replace individuals with sets. In +198 general, under $\tilde { \alpha }$ -condition, the left order satisfies that when arm 1 to arm $k - 1$ are removed, agents + +$\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. + +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. + +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. + +# 4.1.2 Unique Stable Conditions in Many-to-one Matching + +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. + +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. + +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. + +31 Theorem 2. In a many-to-one matching market $\mathcal { M } = ( \mathcal { K } , \mathcal { I } , \mathcal { P } )$ , our $\tilde { \alpha }$ -condition satisfies: + +(i) SPC is a sufficient condition to $\tilde { \alpha }$ -condition; + +(ii) $\tilde { \alpha }$ -condition is a necessary and sufficient condition to Unqc; + +(iii) 234 $\tilde { \alpha }$ -condition is a sufficient condition to Acyclicity∗. + +![](images/26103e7512ce5d2b267aa1d5c03670fa92da9aa759dbc7c4b7597706aef77700.jpg) +Figure 1: Relations of Uniqueness Conditions in Many-to-one Market. + +236 We then provide theoretical results of MO-UCB-D4 algorithm under our $\tilde { \alpha }$ -condition. Recall that $G _ { j } ^ { * }$ +237 is the globally dominated arms for agent $j$ under stable matching $m ^ { * }$ . For each arm $k \notin G _ { j } ^ { * }$ , we give +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 +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.$ +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 } |$ +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 +242 assume that the reward is different for each agent, thus $\Delta _ { j , k } > 0$ for every agent $j$ and arm $k$ . +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 +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 +245 order and the right order for agent $j$ . Following MO-UCB-D4 algorithm with horizon $T$ , the expected +246 regret of a stable matching under $\tilde { \alpha }$ -condition (Definition 2) for agent $j \in [ N ]$ is upper bounded by + +$$ +\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} +$$ + +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$ . + +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. + +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. + +263 Lemma 2. (Regret Decomposition) For a stable matching under $\tilde { \alpha }$ -condition, the upper bound of +264 regret for the agent $j \in [ N ]$ under our algorithm can be decomposed by: + +$$ +\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} +$$ + +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 +266 phase respectively, mentioned as "good phase" above, are defined in Appendix A.2. + +While putting forward our $\tilde { \alpha }$ -condition in the many-to-one setting, many new problems need to be taken into account. + +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. + +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. + +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. + +# 04 6 Experiments + +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 }$ . + +317 Varying the market size To test effects on two indicators, cumulative regret and cumulative +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 +319 and $K = 5$ arms. The number of rounds is set to be 100, 000. The cumulative regret in Figure +320 2(a)(c)(e) show an increasing trend with convergence as the number of agents increases under these +321 three conditions. When the number of agents increases, there is a high probability of collisions +322 among different agents, resulting in the increase of cumulative regret. Similar results for cumulative +323 unstability are shown in Figure 2(b)(d)(f). When $N$ is larger, the number of unstable pairs becomes +324 more. With the increase of the number of rounds, both two indicators increase first and then tend to +325 be stable. The jumping points are caused by multi-phases setting of MO-UCB-D4 algorithm. +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 +327 $q = N / K$ . The number of rounds we set is 400, 000. With the increase of $K$ , both the cumulative +328 regret in Figure 3(a)(c)(e) and the cumulative unstability in Figure 3(b)(d)(f) increase monotonously. +329 When $K$ increases, the capacity $q _ { k }$ for each arm $k$ decreases, and then the number of collisions +330 will increase, which leads to an increase of cumulative regret. And it also leads to more unstable +331 pairs, which needs more communication blocks to converge to a stable matching. Under these three +332 conditions, the performances of the algorithm are similar. + +![](images/a935016500007b98645f039e72e8495dda8e6d244c582a275ac103d3f6337015.jpg) +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. + +![](images/889d902d82c5359d4cc1b595ed845374eb12b9e248a87926721b95bc8eae8f28.jpg) +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. + +# 7 Conclusion + +334 We are the first to study the bandit algorithm for the many-to-one matching market under the unique +335 stable matching. This work focuses on a decentralized market. A new $\tilde { \alpha }$ -condition is proposed +336 to guarantee a unique stable outcome in many-to-one market, which is more general than existing +337 uniqueness conditions like SPC, Serial Dictatorship and could recover the usual $\alpha$ -condition in +338 one-to-one setting. We propose a phase-based algorithm of MO-UCB-D4 with arm-elimination, +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 +340 arms to the least preferred agent in its stable matched set, we could effectively correspond arms and +341 agents by individual-to-individual. A series of experiments under two environments of varying the +342 market size and varying arm capacity are conducted. The results show that our algorithm performs +343 well under Serial Dictatorship, $S P C$ and $\tilde { \alpha }$ -condition respectively. + +References +[1] Azar Abizada. Stability and incentives for college admissions with budget constraints. Theoretical Economics, 11(2):735–756, 2016. +[2] Takashi Akahoshi. Singleton core in many-to-one matching problems. Mathematical Social Sciences, 72:7–13, 2014. +[3] Ahmet Altinok. Dynamic many-to-one matching. Available at SSRN 3526522, 2019. +[4] Peter Auer, Nicolo Cesa-Bianchi, and Paul Fischer. Finite-time analysis of the multiarmed bandit problem. Machine learning, 47(2):235–256, 2002. +[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. +[6] Sophie Bade. Random serial dictatorship: the one and only. Mathematics of Operations Research, 45(1):353–368, 2020. +[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. +[8] Anna Bogomolnaia and Hervé Moulin. A new solution to the random assignment problem. Journal of Economic theory, 100(2):295–328, 2001. +[9] Somouaoga Bonkoungou. Decentralized college admissions under single application. Review of Economic Design, 25(1):65–91, 2021. +[10] Simon Clark. The uniqueness of stable matchings. Contributions in Theoretical Economics, 6(1), 2006. +[11] Jan Eeckhout. On the uniqueness of stable marriage matchings. Economics Letters, 69(1):1–8, 2000. +[12] David Gale and Lloyd S Shapley. College admissions and the stability of marriage. The American Mathematical Monthly, 69(1):9–15, 1962. +[13] Aurélien Garivier, Tor Lattimore, and Emilie Kaufmann. On explore-then-commit strategies. Advances in Neural Information Processing Systems, 29:784–792, 2016. +[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. +[15] Gregory Z Gutin, Philip R Neary, and Anders Yeo. Unique stable matchings. arXiv preprint arXiv:2106.12977, 2021. +[16] Guillaume Haeringer and Flip Klijn. Constrained school choice. Journal of Economic theory, 144(5):1921–1947, 2009. +[17] John William Hatfield, Fuhito Kojima, and Scott Duke Kominers. Investment incentives in labor market matching. American Economic Review, 104(5):436–41, 2014. +[18] Ramesh Johari, Vijay Kamble, and Yash Kanoria. Matching while learning. Operations Research, 69(2):655–681, 2021. +[19] Alexander Karpov. A necessary and sufficient condition for uniqueness consistency in the stable marriage matching problem. Economics Letters, 178:63–65, 2019. +[20] Bettina Klaus and Flip Klijn. Local and global consistency properties for student placement. Journal of Mathematical Economics, 49(3):222–229, 2013. +[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. +[22] Lydia T Liu, Feng Ruan, Horia Mania, and Michael I Jordan. Bandit learning in decentralized matching markets. arXiv preprint arXiv:2012.07348, 2020. +[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. +[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. +[25] Hai Nguyen, Thành Nguyen, and Alexander Teytelboym. Stability in matching markets with complex constraints. Management Science, 67(12):7438–7454, 2021. +[26] Muriel Niederle and Leeat Yariv. Decentralized matching with aligned preferences. Technical report, National Bureau of Economic Research, 2009. +[27] Jaeok Park. Competitive equilibrium and singleton cores in generalized matching problems. International Journal of Game Theory, 46(2):487–509, 2017. +[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. +[29] Antonio Romero-Medina and Matteo Triossi. Acyclicity and singleton cores in matching markets. Economics Letters, 118(1):237–239, 2013. +[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. +[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. +[32] Alvin E Roth and Marilda Sotomayor. Two-sided matching. Handbook of game theory with economic applications, 1:485–541, 1992. +[33] Hannu Salonen and Mikko AA Salonen. Mutually best matches. Mathematical Social Sciences, 91:42–50, 2018. +[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. +[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. +[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. + +# Checklist + +1. For all authors... + +(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. +(b) Did you describe the limitations of your work? [Yes] Please see Section C.4. +(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. + +(d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes] + +2. If you are including theoretical results... + +(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. + +3. If you ran experiments... + +(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. +(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. +(c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [Yes] Please see Section 6. +(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] + +4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets... + +(a) If your work uses existing assets, did you cite the creators? [N/A] +(b) Did you mention the license of the assets? [N/A] +(c) Did you include any new assets either in the supplemental material or as a URL? [N/A] +(d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [N/A] +(e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [N/A] + +5. If you used crowdsourcing or conducted research with human subjects... + +(a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A] +(b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A] +(c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A] \ No newline at end of file diff --git a/md/dev/WZ3yjh8coDg/WZ3yjh8coDg.md b/md/dev/WZ3yjh8coDg/WZ3yjh8coDg.md new file mode 100644 index 0000000000000000000000000000000000000000..68fc8676ada34da6cef246a2d6ad1f3b279227b8 --- /dev/null +++ b/md/dev/WZ3yjh8coDg/WZ3yjh8coDg.md @@ -0,0 +1,1119 @@ +# AN UNCONSTRAINED LAYER-PEELED PERSPECTIVE ON NEURAL COLLAPSE + +Wenlong Ji Peking University + +Yiping Lu Stanford University + +Yiliang Zhang University of Pennsylvania + +Zhun Deng Harvard University + +Weijie J. Su University of Pennsylvania + +# ABSTRACT + +Neural collapse is a highly symmetric geometry of neural networks that emerges during the terminal phase of training, with profound implications on the generalization performance and robustness of the trained networks. To understand how the last-layer features and classifiers exhibit this recently discovered implicit bias, in this paper, we introduce a surrogate model called the unconstrained layer-peeled model (ULPM). We prove that gradient flow on this model converges to critical points of a minimum-norm separation problem exhibiting neural collapse in its global minimizer. Moreover, we show that the ULPM with the cross-entropy loss has a benign global landscape for its loss function, which allows us to prove that all the critical points are strict saddle points except the global minimizers that exhibit the neural collapse phenomenon. Empirically, we show that our results also hold during the training of neural networks in real-world tasks when explicit regularization or weight decay is not used. + +# 1 INTRODUCTION + +Deep learning has achieved state-of-the-art performance in various applications (LeCun et al., 2015), such as computer vision (Krizhevsky et al., 2012), natural language processing (Brown et al., 2020), and scientific discovery (Long et al., 2018; Zhang et al., 2018). Despite the empirical success of deep learning, how gradient descent or its variants lead deep neural networks to be biased towards solutions with good generalization performance on the test set is still a major open question. To develop a theoretical foundation for deep learning, many studies have investigated the implicit bias of gradient descent in different settings (Li et al., 2018; Amari et al., 2020; Vaswani et al., 2020; Soudry et al., 2018; Lyu & Li, 2019; Arora et al., 2019). + +It is well acknowledged that well-trained end-to-end deep architectures can effectively extract features relevant to a given label. Although theoretical analysis of deep learning has been successful in recent years (Arora et al.; Goldblum et al., 2019), most of the studies that aim to analyze the properties of the final output function fail to understand the features learned by neural networks. Recently, in Papyan et al. (2020), the authors observed that the features in the same class will collapse to their mean and the mean will converge to an equiangular tight frame (ETF) during the terminal phase of training, that is, the stage after achieving zero training error. This phenomenon, namely, neural collapse (Papyan et al., 2020), provides a clear view of how the last-layer features in the neural network evolve after interpolation and enables us to understand the benefit of training after achieving zero training error to achieve better performance in terms of generalization and robustness. To theoretically analyze the neural collapse phenomenon, Fang et al. (2021) proposed the layer-peeled model (LPM) as a simple surrogate for neural networks, where the last-layer features are modeled as free optimization variables. In particular, in a balanced $K$ -class classification problem using a neural network with $d$ neurons in the last hidden layer, the LPM takes the following form: + +$$ +\operatorname* { m i n } _ { W , H } \frac { 1 } { n } \sum _ { i = 1 } ^ { n } \mathcal { L } \left( W h _ { i } , y _ { i } \right) , \quad \mathrm { ~ s . t . ~ } \frac { 1 } { 2 } | | W | | _ { F } ^ { 2 } \leq C _ { 1 } , \frac { 1 } { 2 } | | H | | _ { F } ^ { 2 } \leq C _ { 2 } , +$$ + +where $C _ { 1 } , C _ { 2 }$ are positive constants. Here, $\ b { W } = [ \ b { w } _ { 1 } , \ b { w } _ { 2 } , \ b { \cdot } \ b { \cdot } \ \ b { \cdot } \ , \ b { w } _ { K } ] ^ { \top } \in \mathbb { R } ^ { K \times d }$ is the weight of the final linear classifier, $H = [ h _ { 1 } , h _ { 2 } , \cdot \cdot \cdot , h _ { n } ] \in \bar { \mathbb { R } } ^ { d \times n }$ is the feature of the last layer and $\mathbf { \nabla } _ { \mathbf { \psi } _ { 3 } } \mathbf { \psi } _ { 2 } \qquad \mathbf { \psi } _ { 3 } \mathbf { \psi } _ { 4 } \qquad \mathbf { \psi } _ { 3 } \mathbf { \psi } _ { 4 } \qquad \mathbf { \psi } _ { 3 } \mathbf { \psi } _ { 4 } \mathbf { \psi } _ { 3 } \qquad \mathbf { \psi } _ { 4 } \mathbf { \psi } _ { 4 } \mathbf { \psi } _ { 3 } \mathbf { \psi } _ { 4 } \mathbf { \psi } _ { 4 } \mathbf { \psi } _ { 3 } \qquad \mathbf { \psi } _ { 3 } \mathbf { \psi } _ { 4 } \mathbf { \psi } _ { 4 } \mathbf { \psi } _ { 3 } \mathbf { \psi } _ { 4 } \mathbf { \psi } _ { 4 }$ is the corresponding label. The intuition behind the LPM is that modern deep networks are often highly over-parameterized, with the capacity to learn any representations of the input data. It has been shown that an equiangular tight frame (ETF), i.e., feature with neural collapse, is the only global optimum of the LPM objective (1.1) (Fang et al., 2021; Lu & Steinerberger, 2020; Wojtowytsch & E, 2020; Zhu et al., 2021). + +However, feature constraints in LPMs are not equivalent to weight decay used in practice. In this study, we directly deal with the unconstrained model and show that gradient flow can find those neural collapse solutions without the help of explicit constraints and regularization. To do this, we build a connection between the neural collapse and recent theories on max-margin implicit regularization (Lyu & Li, 2019; Wei et al., 2018), and use it to provide a convergence result to the first-order stationary point of a minimum-norm separation problem. Furthermore, we illustrate that the crossentropy loss enjoys a benign global landscape where all the critical points are strict saddles in the tangent space, except for the only global minimizers that exhibit the neural collapse phenomenon. Finally, we verify our insights via empirical experiments. + +In contrast to previous theoretical works on neural collapse, our analysis does not incorporate any explicit regularization or constraint on features. A comparison with other results can be found in Table 1 and we defer a detailed discussion to Section 5.2. The reasons we investigate the unregularized objective are summarized as follows: + +1. Feature regularization or constrain is still not equivalent to weight decay used in practice. However, previous studies have justified that neural networks continue to perform well without any regularization or constraint (Zhang et al., 2021). Moreover, it is proved that SGD with exponential learning rate on unconstrained objective is equivalent to SGD with weight decay. (Li & Arora, 2019). +2. As shown in this study, neural collapse exists even under an unconstrained setting, which implies the emergence of neural collapse should be attributed to gradient descent and cross-entropy loss rather than explicit regularization. +3. Regularization or constraint feature constraint can be barriers for existing theories of neural networks (Jacot et al., 2018; Lyu & Li, 2019). By allowing features to be totally free, we hope our results can inspire further analysis to plug in a realistic neural network. + +Table 1: Comparison of recent analysis for neural collapse. We provide theoretical results with the minimum modification of the training objective function. Here we use CE loss to refer to the cross-entropy loss. + +
ReferenceContributionFeature NormConstraintFeature NormRegularizationLossFunction
(Papyan et al., 2020)Empirical ResultsXXCE Loss
(Wojtowytsch & E, 2020)(Lu & Steinerberger, 2020)(Fang et al., 2021)Global Optimum×CE Loss
(Mixon et al., 2020)(Poggio & Liao,2020)(Han et al., 2021)ModifiedTraining Dynamics××l2 Loss
(Zhu et al., 2021)concurrentLandscape Analysis×CE Loss
This paperTraining Dynamics+Landscape AnalysisXXCE Loss
+ +# 1.1 CONTRIBUTIONS + +The contributions of the present study can be summarized as follows. + +• We build a relationship between the max-margin analysis (Soudry et al., 2018; Nacson et al., 2019b; Lyu & Li, 2019) and the neural collapse and provide the implicit bias analysis to the feature rather than the output function. Although both parameters and features diverge to infinity, we prove that the convergent direction is along the direction of the minimum-norm separation problem. +• Previous works (Lyu & Li, 2019; Ji et al., 2020) only prove that gradient flow on homogeneous neural networks will converge to the KKT point of the corresponding minimum-norm separation problem. However, the minimum-norm separation problem remains a highly non-convex problem and a local KKT point may not be the neural collapse solution. In this study, we perform a more detailed characterization of the convergence direction via landscape analysis. +• Previous analysis about neural collapse relies on the explicit regularization or constraint. In this study, we show that the implicit regularization effect of gradient flow is sufficient to lead to a neural collapse solution. The emergence of neural collapse should be attributed to gradient descent and loss function, rather than explicit regularization or constraint. We put detailed discussion in Section 5.2. + +# 1.2 RELATED WORKS + +Implicit Bias of Gradient Descent: To understand how gradient descent or its variants helps deep learning to find solutions with good generalization performance on the test set, a recent line of research have studied the implicit bias of gradient descent in different settings. For example, gradient descent is biased toward solutions with smaller weights under $\ell _ { 2 }$ loss (Li et al., 2018; Amari et al., 2020; Vaswani et al., 2020) and will converge to large margin solution while using logistic loss (Soudry et al., 2018; Nacson et al., 2019b; Lyu & Li, 2019; Chizat & Bach, 2020; Ji et al., 2020). For linear networks, Arora et al. (2019); Razin & Cohen (2020); Gidel et al. (2019) have shown that gradient descent determines a low-rank approximation. + +Loss Landscape Analysis: Although the practical optimization problems encountered in machine learning are often nonconvex, recent works have shown the landscape can enjoy benign properties which allow further analysis. In particular, these landscapes do not exhibit spurious local minimizers or flat saddles and can be easily optimized via gradient-based methods (Ge et al., 2015). Examples include phase retrieval (Sun et al., 2018), low-rank matrix recovery (Ge et al., 2016; 2015), dictionary learning (Sun et al., 2016; Qu et al., 2019; Laurent & Brecht, 2018) and blind deconvolution (Lau et al., 2019). + +# 2 PRELIMINARIES AND PROBLEM SETUP + +In this paper, $| | \cdot | | _ { F }$ denotes the Frobenius norm, $\| \cdot \| _ { 2 }$ denotes the matrix spectral norm, $\| \cdot \| _ { * }$ denotes the nuclear norm, $\| \cdot \|$ denotes the vector $l _ { 2 }$ norm and $\operatorname { t r } ( \cdot )$ is the trace of matrices. We use $[ K ] : = \{ 1 , 2 , \cdots , K \}$ to denote the set of indices up to $K$ . + +# 2.1 PRELIMINARIES + +We consider a balanced dataset with $K$ classes $\textstyle \bigcup _ { k = 1 } ^ { K } \{ \pmb { x } _ { k , i } \} _ { i = 1 } ^ { n }$ . A standard fully connected neural network can be represented as: + +$$ +f \left( x ; W _ { f u l l } \right) = b _ { L } + W _ { L } \sigma \left( b _ { L - 1 } + W _ { L - 1 } \sigma \left( \cdot \cdot \cdot \sigma \left( b _ { 1 } + W _ { 1 } x \right) \cdot \cdot \cdot \cdot \right) \right) . +$$ + +Here $W _ { f u l l } = ( W _ { 1 } , W _ { 2 } , \cdot \cdot \cdot , W _ { L } )$ denote the weight matrices in each layer, $( b _ { 1 } , b _ { 2 } , \cdots , b _ { L } )$ denote the bias terms, and $\sigma ( \cdot )$ denotes the nonlinear activation function, for example, ReLU or sigmoid. Let $\begin{array} { r } { \pmb { h } _ { k , i } = \sigma \left( \pmb { b } _ { L - 1 } + \pmb { W } _ { L - 1 } \sigma \left( \cdots \sigma \left( \pmb { b } _ { 1 } + \pmb { W } _ { 1 } \pmb { x } _ { k , i } \right) \right) \right) \in \mathbb { R } ^ { d } } \end{array}$ denote the last layer feature for data ${ \bf { x } } _ { k , i }$ and $\begin{array} { r } { \bar { \boldsymbol { h } } _ { k } = \frac { 1 } { n } \sum _ { i = 1 } ^ { n } h _ { k , i } } \end{array}$ denotes the feature mean within the $\mathbf { k }$ -th class. To provide a formal definition of neural collapse, we first introduce the concept of a simplex equiangular tight frame (ETF): + +Definition 2.1 (Simplex ETF). A symmetric matrix $M \in \mathbb { R } ^ { K \times K }$ is said to be a simplex equiangular tight frame (ETF) if + +$$ +M = \sqrt { \frac { K } { K - 1 } } Q ( { \cal I } _ { K } - \frac { 1 } { K } { \bf 1 } _ { K } { \bf 1 } _ { K } ^ { \top } ) . +$$ + +Where $Q \in \mathbb { R } ^ { d \times K }$ is a matrix with orthogonal columns. + +Let $\pmb { W } \in \mathbb { R } ^ { K \times d } = \pmb { W } _ { L } = [ \pmb { w } _ { 1 } , \pmb { w } _ { 2 } , \cdot \cdot \cdot , \pmb { w } _ { K } ] ^ { \top }$ be the weight of the final layer classifier, the four criteria of neural collapse can be formulated precisely as: + +• (NC1) Variability collapse: As training progresses, the within-class variation of the activation becomes negligible as these activation collapse to their class mean $\begin{array} { r } { \bar { \pmb { h } } _ { k } = \frac { 1 } { n } \sum _ { i = 1 } ^ { n } { \pmb { h } } _ { k , i } } \end{array}$ + +$$ +| | h _ { k , i } - \bar { h } _ { k } | | = 0 , \quad 1 \leq k \leq K . +$$ + +• (NC2) Convergence to Simplex ETF: The vectors of the class-means (after centering by their global-mean) converge to having equal length, forming equal-size angles between any given pair, and being the maximally pairwise-distanced configuration constrained to the previous two properties. + +$$ +\cos ( \bar { h } _ { k } , \bar { h } _ { j } ) = - \frac { 1 } { K - 1 } , \quad | | \bar { h } _ { k } | | = | | \bar { h } _ { j } | | , \quad k \neq j . +$$ + +• (NC3) Convergence to self-duality: The linear classifiers and class-means will converge to align with each other, up to appropriate rescaling, that is, there exist a universal constant $C > 0$ such that + +$$ +\begin{array} { r } { { \pmb w } _ { k } = C \bar { \pmb h } _ { k } , \quad k \in [ K ] . } \end{array} +$$ + +• (NC4) Simplification to Nearest Class-Center For a given deepnet activation: + +$$ +\begin{array} { r } { \pmb { h } = \sigma \left( \pmb { b } _ { L - 1 } + \pmb { W } _ { L - 1 } \sigma \left( \cdots \sigma \left( \pmb { b } _ { 1 } + \pmb { W } _ { 1 } \pmb { x } \right) \cdots \right) \right) \in \mathbb { R } ^ { d } , } \end{array} +$$ + +the network classifier converges to choose whichever class has the nearest train class-mean + +$$ +\underset { k } { \arg \operatorname* { m i n } } \pmb { w } _ { k } , \pmb { h } \underset { k } { \arg \operatorname* { m i n } } \| \pmb { h } - \bar { \pmb { h } } _ { k } \| , +$$ + +In this paper, we say that a point $\pmb { W } \in \mathbb { R } ^ { K \times d } , \pmb { H } \in \mathbb { R } ^ { d \times n K }$ satisfies the neural collapse conditions or is a neural collapse solution if the above four criteria are all satisfied for $( W , H )$ . + +# 2.2 PROBLEM SETUP + +We mainly focus on the neural collapse phenomenon, which is only related to the classifiers and features in the last layer. Since the general analysis of the highly non-smooth and non-convex neural network is difficult, we peel down the last layer of the neural network and propose the following unconstrained layer-peeled model (ULPM) as a simplification to capture the main characters related to neural collapse during training dynamics. A similar simplification is commonly used in previous theoretical works (Lu & Steinerberger, 2020; Fang et al., 2021; Wojtowytsch & E, 2020; Zhu et al., 2021), but ours does not have any constraint or regularization on features. It should be mentioned that although Mixon et al. (2020); Han et al. (2021) also studied the unconstrained model, their analysis adopted an approximation to real dynamics and was highly dependent on the $\ell _ { 2 }$ loss function, which is rarely used in classification tasks. Compared with their works, we directly deal with the real training dynamics and cover the most popular cross-entropy loss in classification tasks. + +Let $\ b { W } = [ \ b { w } _ { 1 } , \ b { w } _ { 2 } , \ b { \cdot } \ b { \cdot } \ b { \cdot } \ , \ b { w } _ { K } ] ^ { \top } \in \mathbb { R } ^ { K \times d }$ and $H = [ h _ { 1 , 1 } , \cdot \cdot \cdot , h _ { 1 , n } , h _ { 2 , 1 } , \cdot \cdot \cdot , h _ { K , n } ] \in \mathbb { R } ^ { d \times K n }$ be the matrices of classifiers and features in the last layer, where $K$ is the number of classes and $n$ is the number of data points in each class. The ULPM is defined as follows: + +$$ +\operatorname* { m i n } _ { W , H } \mathcal { L } ( W , H ) = \operatorname* { m i n } _ { W , H } - \sum _ { k = 1 } ^ { K } \sum _ { i = 1 } ^ { n } \log \left( \frac { \exp ( w _ { k } ^ { \top } h _ { k , i } ) } { \sum _ { j = 1 } ^ { K } \exp ( w _ { j } ^ { \top } h _ { k , i } ) } \right) . +$$ + +Here, we do not have any constraint or regularization on features, which corresponds to the absence of weight decay in deep learning training. The objective function (2.3) is generally non-convex on $( W , H )$ and we aim to study the landscape of the objective function (2.3). Furthermore, we consider the gradient flow of the objective function: + +$$ +\frac { d \pmb { W } ( t ) } { d t } = - \frac { \partial \mathcal { L } ( \pmb { W } ( t ) , \pmb { H } ( t ) ) } { \partial \pmb { W } } , \frac { d \pmb { H } } { d t } = - \frac { \partial \mathcal { L } ( \pmb { W } ( t ) , \pmb { H } ( t ) ) } { \partial \pmb { H } } . +$$ + +# 3 MAIN RESULTS + +In this section, we present our main results regarding the training dynamics and landscape analysis of (2.3). This section is organized as follows: First, in Section 3.1, we show the relationship between the margin and neural collapse in our surrogate model. Inspired by this relationship, we propose a minimum-norm separation problem (3.1) and show the connection between the convergence direction of the gradient flow and the KKT point of (3.1). In addition, we explicitly solve the global optimum of (3.1) and show that it must satisfy the neural collapse conditions. However, owing to the nonconvexity, we find an Example 3.1 in Section 3.2, which shows that there exist some bad KKT points such that a simple gradient flow will get stuck in them and does not converge to the neural collapse solution, which is proved to be optimal in Theorem 3.3. Then, we present our second–order analysis result in Theorem 3.4 to show that those bad points will exhibit decreasing directions in the tangent space thus gradient descent and its variants can avoid those bad directions and only converge to the neural collapse solutions (Lee et al., 2016; Ge et al., 2015). + +# 3.1 CONVERGENCE TO THE FIRST–ORDER STATIONARY POINT + +Heuristically speaking, the simplex ETF (Definition 2.1) gives a set of vectors with the maximum average angle between them. As a result, neural collapse implies that the neural networks tend to maximize the angles between each class and the corresponding classifiers. At a high level, such behavior is quite similar to margin maximization which is known to be an implicit regularization effect of gradient descent and has been extensively studied in Soudry et al. (2018); Nacson et al. (2019b); Lyu & Li (2019); Ji et al. (2020). First, we illustrate the connection between the margin and neural collapse. Recall that the margin of a single data point ${ \pmb x } _ { k , i }$ and the associated feature $h _ { k , i }$ is $\begin{array} { r } { q _ { k , i } ( W , H ) : = w _ { k } ^ { \top } h _ { k , i } - \operatorname* { m a x } _ { j \neq k } w _ { j } ^ { \top } h _ { k , i } . } \end{array}$ . Then, the margin of the entire dataset can be defined as + +$$ +q _ { \operatorname* { m i n } } ( W , H ) : = \operatorname* { m i n } _ { k \in [ K ] , i \in [ n ] } q _ { k , i } ( W , H ) . +$$ + +The following theorem demonstrates that neural collapse yields the maximum margin solution of our ULPM model: + +Theorem 3.1 (Neural collapse as max-margin solution). For the ULPM model (2.3), the margin of the entire dataset always satisfies + +$$ +q _ { \operatorname* { m i n } } ( W , H ) \leq \frac { \| W \| _ { F } ^ { 2 } + \| H \| _ { F } ^ { 2 } } { 2 ( K - 1 ) \sqrt { n } } +$$ + +and the equality holds if and only if $( W , H )$ satisfies the neural collapse conditions with $\| W \| _ { F } =$ $\| H \| _ { F }$ . + +Based on this finding, we present an analysis of the convergence of the gradient flow on the ULPM (2.3). Following Lyu & Li (2019), we link the gradient flow on cross-entropy loss to a minimum-norm separation problem. + +Theorem 3.2. For problem (2.3), let $( W ( t ) , H ( t ) )$ be the path of gradient flow at time $t$ , if there exist a time $t _ { 0 }$ such that $\mathcal { L } ( W ( t _ { 0 } ) , H ( t _ { 0 } ) ) < \log 2$ , then any limit point of + +$$ +\{ ( \hat { H } ( t ) , \hat { W } ( t ) ) : = ( \frac { H ( t ) } { \sqrt { \| W ( t ) \| _ { F } ^ { 2 } + \| H ( t ) \| _ { F } ^ { 2 } } } , \frac { W ( t ) } { \sqrt { \| W ( t ) \| _ { F } ^ { 2 } + \| H ( t ) \| _ { F } ^ { 2 } } } ) \} +$$ + +is along the direction (i.e., a constant multiple) of a Karush-Kuhn-Tucker (KKT) point of the following minimum-norm separation problem: + +$$ +\begin{array} { r l r } & { \underset { W , H } { \operatorname* { m i n } } \frac { 1 } { 2 } | | W | | _ { F } ^ { 2 } + \frac { 1 } { 2 } | | H | | _ { F } ^ { 2 } } & \\ & { \mathit { s . t . } w _ { k } ^ { \top } h _ { k , i } - w _ { j } ^ { \top } h _ { k , i } \geq 1 , \quad k \neq j \in [ K ] , i \in [ n ] . } & \end{array} +$$ + +Remark 3.1. Here we write (3.1) as a constraint problem, but the constraint is introduced by the implicit regularization effect of gradient flow on our ULPM objective (2.3). Since the training dynamics will diverge to infinity, we hope to justify that the diverge direction is highly related to neural collapse and an appropriate normalization is needed, which is why it appears to be a constraint optimization form. Our goal is to justify that the neural collapse phenomenon is caused by the properties of the loss function and training dynamics rather than an explicit regularization or constraint, which seems to be necessary for previous studies (Fang et al., 2021; Lu & Steinerberger, 2020; Wojtowytsch & E, 2020). + +Remark 3.2. In Theorem 3.2, we assume that there exists a time $t _ { 0 }$ such that $\mathcal { L } ( W ( t _ { 0 } ) , H ( t _ { 0 } ) ) <$ $\log 2$ . Note that the loss function can be rewritten as: + +$$ +\mathcal { L } ( W , H ) = \sum _ { k = 1 } ^ { K } \sum _ { i = 1 } ^ { n } \log ( 1 + \sum _ { j \neq k } \exp ( w _ { j } h _ { k , i } - w _ { k } h _ { k , i } ) ) +$$ + +the requirement $\mathcal { L } ( W , H ) < \log 2$ implies that $w _ { k } h _ { k , i } - w _ { j } h _ { k , i } \geq 0$ for any $k , j \in [ K ] , i \in [ n ]$ , which is equivalent to $q _ { m i n } ( W , H ) > 0$ ; that is, every feature is separated perfectly by the classifier. This assumption is common in the study of implicit bias in the nonlinear setting (Nacson et al., $2 0 1 9 \mathrm { a }$ ; Lyu & Li, 2019; Ji et al., 2020) and its validity can be justified by the fact that neural collapse is found only in the terminal phase of training in the deep neural network, where the training accuracy has achieved $100 \%$ . It is also an interesting direction to remove this assumption and study the early-stage dynamics of training, which is beyond the scope of this study and we leave it to future exploration. + +Theorem 3.2 indicates that the convergent direction of the gradient flow is restricted to the max-margin directions, which usually have good robustness and generalization performance. In general, the KKT conditions are not sufficient to obtain global optimality because the minimum-norm separation problem (3.1) is non-convex. On the other hand, we can precisely characterize its global optimum in the ULPM case based on Theorem 3.1: + +Corollary 3.1. Every global optimum of the minimum-norm separation problem (3.1) is also a KKT point that satisfies the neural collapse conditions. + +With Theorem 3.2 bridging dynamics with KKT points of (3.1) and Corollary 3.1 associating global optimum of (3.1) with neural collapse, the remaining work is to close the gap between the KKT point and the global optimum. + +# 3.2 SECOND–ORDER LANDSCAPE ANALYSIS + +In the convex optimization problem, the KKT conditions are usually equivalent to global optimality. Unfortunately, owing to the non-convex nature of the objective (2.3), the KKT points can also be saddle points or local optimum other than the global optimum. In this section, we aim to show that this non-convex optimization problem is actually not scary via landscape analysis. To be more specific, we prove that except for the global optimum given by neural collapse, all the other KKT points are actually saddle points that can be avoided by gradient flow. + +In contrast to previous landscape analysis of non-convex problems, where people aim to show that the objective has a negative directional curvature around any stationary point (Sun et al., 2015; Zhang et al., 2020), our analysis is slightly different. Note that since the model is unconstrained, once features can be perfectly separated, the ULPM objective (2.3) will always decrease along the direction of the current point and the optimum is attained only in infinity. Although growing along all of those perfectly separating directions can let the loss function decrease to 0, the speed of decrease is quite different and there exists an optimal direction with the fastest decreasing speed. As shown in Section 3.1, first-order analysis of training dynamics fails to distinguish such an optimal direction from KKT points, and we need second-order analysis to help us fully characterize the realistic training dynamics. First, we provide an example to illustrate the motivation and necessity of second-order landscape analysis. + +Example 3.1 (A Motivating Example). Consider the case where $K = 4 , n = 1$ , let $( W , H )$ be the following point: + +$$ +W = H = \left[ \begin{array} { c c c c } { { 1 } } & { { - 1 } } & { { 0 } } & { { 0 } } \\ { { - 1 } } & { { 1 } } & { { 0 } } & { { 0 } } \\ { { 0 } } & { { 0 } } & { { 1 } } & { { - 1 } } \\ { { 0 } } & { { 0 } } & { { - 1 } } & { { 1 } } \end{array} \right] . +$$ + +One can easily verify that $( W , H )$ enables our model to classify all features perfectly. Furthermore, we can show that it is along the direction of a KKT point of the minimum-norm separation problem + +(3.1) by constructing the Lagrangian multiplier $\Lambda = ( \lambda _ { i j } ) _ { i , j = 1 } ^ { K }$ as follows: + +$$ +\Lambda = \left[ \begin{array} { c c c c } { { 0 } } & { { 0 } } & { { { \textstyle { \frac { 1 } { 2 } } } } } & { { { \textstyle { \frac { 1 } { 2 } } } } } \\ { { 0 } } & { { 0 } } & { { { \textstyle { \frac { 1 } { 2 } } } } } & { { { \textstyle { \frac { 1 } { 2 } } } } } \\ { { { \textstyle { \frac { 1 } { 2 } } } } } & { { { \textstyle { \frac { 1 } { 2 } } } } } & { { 0 } } & { { 0 } } \\ { { { \textstyle { \frac { 1 } { 2 } } } } } & { { { \textstyle { \frac { 1 } { 2 } } } } } & { { 0 } } & { { 0 } } \end{array} \right] . +$$ + +To see this, simply write down the corresponding Lagrangian (note that we aim to justify $( W , H )$ is along the direction of a KKT point of (3.1), to make it a true KKT point , one needs to multiple√ $1 / \sqrt { 2 }$ on $W , H )$ : + +$$ +\mathcal { L } ( W , H , \Lambda ) = \frac { 1 } { 4 } \| W \| _ { F } ^ { 2 } + \frac { 1 } { 4 } \| H \| _ { F } ^ { 2 } - \sum _ { i = 1 } ^ { 4 } \sum _ { j \neq i } \lambda _ { i , j } ( \frac { 1 } { 2 } w _ { i } h _ { i } - \frac { 1 } { 2 } w _ { j } h _ { i } - 1 ) . +$$ + +Simply take derivatives for $W , H$ and $\Lambda$ we find that it satisfies the KKT conditions. However, the gradient of $( W , H )$ is: + +$$ +\nabla _ { W } \mathcal { L } ( W , H ) = \nabla _ { H } \mathcal { L } ( W , H ) = - \frac { 2 + 2 e ^ { - 2 } } { 2 + 2 e ^ { - 2 } + 2 e ^ { 2 } } \left[ \begin{array} { c c c c } { 1 } & { - 1 } & { 0 } & { 0 } \\ { - 1 } & { 1 } & { 0 } & { 0 } \\ { 0 } & { 0 } & { 1 } & { - 1 } \\ { 0 } & { 0 } & { - 1 } & { 1 } \end{array} \right] . +$$ + +We can see that the directions of the gradient and the parameter align with each other (i.e., $W$ is parallel to $\nabla _ { W } \mathcal { L } ( W , H )$ , and $\pmb { H }$ is parallel to $\nabla _ { H } \mathcal { L } ( W , H ) )$ , which implies that simple gradient descent may get stuck in this direction and only grow the parameter norm. However, if we construct: + +$$ +W ^ { \prime } = { H ^ { \prime } } ^ { \top } = \sqrt { \frac { 1 } { 1 + 2 \alpha ^ { 2 } } } \left[ \begin{array} { c c c c } { 1 + \alpha } & { - 1 + \alpha } & { \alpha } & { \alpha } \\ { - 1 + \alpha } & { 1 + \alpha } & { \alpha } & { \alpha } \\ { - \alpha } & { - \alpha } & { 1 - \alpha } & { - 1 - \alpha } \\ { - \alpha } & { - \alpha } & { - 1 - \alpha } & { 1 - \alpha } \end{array} \right] , +$$ + +By simple calculation, we find that $f ( \alpha ) : = \mathcal { L } ( W ^ { \prime } , H ^ { \prime } )$ satisfies $f ^ { \prime } ( \alpha ) = 0 , f ^ { \prime \prime } ( \alpha ) < 0$ . Since $\lVert \dot { \boldsymbol { W } } ^ { \prime } \rVert _ { F } = \lVert \boldsymbol { W } \rVert _ { F } , \lVert \boldsymbol { H } ^ { \prime } \rVert _ { F } = \lVert \boldsymbol { H } \rVert _ { F }$ and $| | W ^ { \prime } - W | | _ { F } ^ { 2 } + | | H ^ { \prime } - H | | _ { F } ^ { 2 } \to 0$ as $\alpha 0$ , this result implies that for any $\epsilon > 0$ , we can choose appropriate $\alpha$ such that: + +$$ +\begin{array} { r l } & { | | W ^ { \prime } | | _ { F } ^ { 2 } = | | W | | _ { F } ^ { 2 } , | | H ^ { \prime } | | _ { F } ^ { 2 } = | | H | | _ { F } ^ { 2 } , } \\ & { | | W ^ { \prime } - W | | _ { F } ^ { 2 } + | | H ^ { \prime } - H | | _ { F } ^ { 2 } < \epsilon , \mathcal { L } ( W ^ { \prime } , H ^ { \prime } ) < \mathcal { L } ( W , H ) . } \end{array} +$$ + +In Example 3.1, it is shown that there are some KKT points of the minimum-norm separation problem (3.1) that are not globally optimal, but there exist some better points close to it; thus, the gradientbased method can easily avoid them (see Lee et al. (2016); Ge et al. (2015) for a detailed discussion). In the following theorem, we will show that the best directions are neural collapse solutions in the sense that the loss function is the lowest among all the growing directions. + +Theorem 3.3. The optimal value of the loss function (2.3) on a sphere is obtained (i.e., $\begin{array} { r } { \mathcal { L } ( W , H ) \le } \end{array}$ $\mathcal { L } ( W ^ { \prime } , H ^ { \prime } )$ for any $| | \boldsymbol { W } ^ { \prime } | | _ { F } ^ { 2 } + | | \boldsymbol { H } ^ { \prime } | | _ { F } ^ { 2 } = | | \boldsymbol { W } | | _ { F } ^ { 2 } + | | \boldsymbol { H } | | _ { F } ^ { 2 } )$ if only if $( W , H )$ satisfies neural collapse conditions and $| | \bar { W } | | _ { F } = | | \bar { H } | | _ { F }$ . + +Remark 3.3. Note that the second condition is necessary because neural collapse conditions do not specify the norm ratio of $W$ and $\pmb { H }$ . That is, if $( W , H )$ satisfies the neural collapse conditions, then for any $\alpha , \beta \in \mathbb { R } , ( \alpha W , \beta H )$ will also satisfy them, but only some certain $\alpha , \beta$ are optimal. + +Now, we turn to those points that are not globally optimal. To formalize our discussion in the motivating example 3.1, we first introduce the tangent space: + +Definition 3.1 (tangent space). The tangent space of $( W , H )$ is defined as a set of directions that are orthogonal to $( W , H )$ : + +$$ +\mathcal { T } ( W , H ) = \{ \Delta W \in \mathbb { R } ^ { K \times d } , \Delta H \in \mathbb { R } ^ { d \times n K } \} : \operatorname { t r } ( W ^ { \top } \Delta W ) + \operatorname { t r } ( H ^ { \top } \Delta H ) = 0 \} +$$ + +Our next result justifies our observation in Example 3.1 that for those non-optimal points, there exists a direction in the tangent space such that moving along this direction will lead to a lower objective value. + +Theorem 3.4. If $( W , H )$ is not the optimal solution in Theorem 3.3 (i.e., $( W , H )$ is not a neural collapse solution or it is a neural collapse solution but $\| \boldsymbol { W } \| _ { F } \neq \| \boldsymbol { H } \| _ { F } )$ , then there exists a direction $( \Delta \bar { W } , \Delta H ) \in \mathcal { T } ( W , H )$ and constant $M > 0$ such that for any $0 < \delta < M$ , + +$$ +\mathcal { L } ( W + \delta \Delta W , H + \delta \Delta H ) < \mathcal { L } ( W , H ) . +$$ + +Further more, it implies that for any $\epsilon > 0$ there exists a point $( W ^ { \prime } , H ^ { \prime } )$ such that: + +$$ +| | \boldsymbol { W } ^ { \prime } | | _ { F } ^ { 2 } + | | \boldsymbol { H } ^ { \prime } | | _ { F } ^ { 2 } = | | \boldsymbol { W } | | _ { F } ^ { 2 } + | | \boldsymbol { H } | | _ { F } ^ { 2 } , +$$ + +$$ +| | W ^ { \prime } - W | | _ { F } ^ { 2 } + | | H ^ { \prime } - H | | _ { F } ^ { 2 } < \epsilon , \mathcal { L } ( W ^ { \prime } , H ^ { \prime } ) < \mathcal { L } ( W , H ) . +$$ + +Remark 3.4. The result in (3.3) gives us a decreasing direction orthogonal to the direction of $( W , H )$ . As shown in Example 3.1, the gradient on these non-optimal points might be parallel to $( W , H )$ ; thus, the first-order analysis fails to explain the prevalence of neural collapse. Here the decreasing direction is obtained by analyzing the Riemannian Hessian matrix and finding its eigenvector corresponding to a negative eigenvalue, which further indicates that these points are first-order saddle points in the tangent space. That is why we name it second-order landscape analysis. A formal statement and proof are presented in the appendix C. Previous works have shown that for a large family of gradient-based methods, they can avoid saddle points and only converge to minimizers (Lee et al., 2016; Ge et al., 2015; Panageas et al., 2019), thus our landscape analysis indicates that the gradient flow dynamics only find neural collapse directions. + +# 4 EMPIRICAL RESULTS + +![](images/62312ce732c365fe335901fc61064c9a9d63cca8fb8e8758c81e86ff43fc61a2.jpg) +Figure 1: Experiments on real datasets without weight decay. We trained a ResNet18 on both MNIST and CIFAR10 datasets. The $x$ -axis in the figures are set to have $\log ( \log ( t ) )$ scales and the $_ y$ -axis in the figures are set to have log scales. + +To evaluate our theory, we trained the ResNet18 (He et al., 2016) on both MNIST (LeCun et al., 1998) and CIFAR-10 (Krizhevsky et al., 2009) datasets without weight decay, and tracked how the last layer features and classifiers converge to neural collapse solutions. The results are plotted in Figure 1. Here we reported the following metrics to measure the level of neural collapse: + +1. The variation of both feature norm (i.e., $\mathrm { S t d } ( \| \bar { \boldsymbol { h } } _ { k } - \bar { \boldsymbol { h } } \| ) / \mathrm { A v g } ( \| \bar { \boldsymbol { h } } _ { k } - \bar { \boldsymbol { h } } \| ) )$ and classifier norm in the last layer (i.e., $\mathrm { S t d } ( \| \bar { \boldsymbol { w } } _ { k } \| ) / \mathrm { A v g } ( \| \bar { \boldsymbol { w } } _ { k } \| ) )$ . +2. Within-class variation for last layer features (i.e., $\mathrm { A v g } ( \| h _ { k , i } - h _ { k } \| ) / \mathrm { A v g } ( \| h _ { k , i } - \bar { h } \| ) ) .$ . +3. Average cosine between last layer features (i.e., $\mathrm { A v g } ( | \cos ( \bar { h } _ { k } , \bar { h } _ { k ^ { \prime } } ) + 1 / ( K - 1 ) | ) \}$ ) and that of last layer classifiers (i.e., $\mathrm { A v g } ( | \cos ( \bar { w } _ { k } , \bar { w } _ { k ^ { \prime } } ) + 1 / ( K - 1 ) | ) \}$ ). +4. Self-duality distance between features and classifiers corresponding to the same class in the last layer. (i.e., $\mathrm { A v g } ( | ( \bar { h } _ { k } - \bar { h } ) / \| \bar { h } _ { k } - \bar { h } \| - \bar { w } _ { k } / \| \bar { w } _ { k } \| | ) )$ + +Here a smaller value of each metric indicates a closer state to a neural collapse solution. Specifically, the within-class variation measures (NC1) ,the variation of norms measures and cosine between pairs measure (NC2), the self-duality measures (NC3), and (NC4) has been shown to be a corollary of (NC1)-(NC3) (Papyan et al., 2020). More experiment results under various settings and training details can be found in Appendix D. As shown in the Figure 1, all of these metric decreases along the training epochs. These results reveal strong evidence for the emergence of neural collapse in the unconstrained setting and provide sound support for our theory. + +# 5 CONCLUSION AND DISCUSSION + +# 5.1 CONCLUSION + +To understand the implicit bias of neural features from gradient descent training, we built a connection between max-margin implicit bias and the neural collapse phenomenon and studied the ULPM in this study. We proved that the gradient flow of the ULPM converges to the KKT point of a minimum-norm separation problem, where the global optimum satisfies the neural collapse conditions. Although the ULPM is non-convex, we show that ULPM has a benign landscape where all the stationary points are strict saddle points in the tangent space, except for the global neural collapse solution. Our study helps to demystify the neural collapse phenomenon, which sheds light on the generalization and robustness during the terminal phase of training deep networks in classification problems. + +# 5.2 RELATIONSHIP WITH OTHER RESULTS ON NEURAL COLLAPSE + +Theoretical analysis of neural collapse was first provided by Lu & Steinerberger (2020); Wojtowytsch & E (2020); Fang et al. (2021), who showed that the neural collapse solution is the only global minimum of the simplified non-convex objective function. In particular, Wojtowytsch & E (2020); Lu & Steinerberger (2020) studied a continuous integral form of the loss function and showed that the features learned should have a uniform distribution on the sphere. A more realistic discrete setting was studied in Fang et al. (2021), where the constraint is on the entire feature matrix rather than individual features. Our result utilizes the implicit bias of the cross-entropy loss function to remove the feature norm constraint, which is not practical in real applications. + +Although the global optimum can be fully characterized by neural collapse conditions, the ULPM objective is still highly non-convex. Regarding optimization, Mixon et al. (2020); Poggio & Liao (2020); Han et al. (2021) analyzed the unconstrained feature model with $\ell _ { 2 }$ loss and established convergence results for collapsed features for gradient descent. However, they fail to generalize to the more practical cross-entropy loss functions used in classification tasks. The analysis relies highly on the $\ell _ { 2 }$ loss to obtain a closed-form gradient flow and still requires some additional approximation to guarantee global convergence. + +The most relevant study is a concurrent work (Zhu et al., 2021), which provides a landscape analysis of the regularized unconstrained feature model. Zhu et al. (2021) turns the feature norm constraint in Fang et al. (2021) into feature norm regularization and still preserves the neural collapse global optimum. At the same time, it shows that the modified regularized objective shares a benign landscape, where all the critical points are strict saddles except for the global one. Although our study and Zhu et al. (2021) discover similar landscape results, we believe our characterization remains closer to the real algorithms since we do not introduce any constraints or regularization on the feature norm following the conventional setting in realist training. The regularization of features introduced in Zhu et al. (2021) is still different from weight decay regularization (Krogh & Hertz, 1992). However, weight decay on homogeneous neural networks is equivalent to gradient descent with scaling step size on an unregularized objective (Li & Arora, 2019; Zhang et al., 2018). Moreover, neural networks are found to perform well in the absence of weight decay, which highlights the importance of implicit regularization (Zhang et al., 2021). As a result, instead of explicit feature norm constraint/regularization, in this study, we consider implicit regularization brought by the gradient flow on cross-entropy. We show that implicit regularization is sufficient to lead the dynamics to converge to the neural collapse solution without the explicit regularization. + +# ACKNOWLEDGMENTS + +We are grateful to Qing Qu and X.Y. Han for helpful discussions and feedback on an early version of the manuscript. Wenlong Ji is partially supported by the elite undergraduate training program of the School of Mathematical Sciences at Peking University. Yiping Lu is supported by the Stanford Interdisciplinary Graduate Fellowship (SIGF). + +# REFERENCES + +Shun-ichi Amari, Jimmy Ba, Roger Grosse, Xuechen Li, Atsushi Nitanda, Taiji Suzuki, Denny Wu, and Ji Xu. When does preconditioning help or hurt generalization? arXiv preprint arXiv:2006.10732, 2020. + +Raman Arora, Sanjeev Arora, Joan Bruna, Nadav Cohen, Rong Ge, Suriya Gunasekar, Chi Jin, Jason Lee, Tengyu Ma, Behnam Neyshabua, and Zhao Song. Theory of deep learning. https://www.cs.princeton.edu/courses/archive/fall19/cos597B/ lecnotes/bookdraft.pdf/. + +Sanjeev Arora, Nadav Cohen, Wei Hu, and Yuping Luo. Implicit regularization in deep matrix factorization. arXiv preprint arXiv:1905.13655, 2019. + +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. + +Lenaic Chizat and Francis Bach. Implicit bias of gradient descent for wide two-layer neural networks trained with the logistic loss. In Conference on Learning Theory, pp. 1305–1338. PMLR, 2020. + +Tarin Clanuwat, Mikel Bober-Irizar, Asanobu Kitamoto, Alex Lamb, Kazuaki Yamamoto, and David Ha. Deep learning for classical japanese literature. arXiv preprint arXiv:1812.01718, 2018. + +J. Dutta, K. Deb, Rupesh Tulshyan, and Ramnik Arora. Approximate kkt points and a proximity measure for termination. Journal of Global Optimization, 56:1463–1499, 2013. + +C. Fang, H. He, Q. Long, and W. Su. Exploring deep neural networks via layer-peeled model: Minority collapse in imbalanced training. Proceedings of the National Academy of Sciences (in press), 2021. + +Rong Ge, Furong Huang, Chi Jin, and Yang Yuan. Escaping from saddle points—online stochastic gradient for tensor decomposition. In Conference on learning theory, pp. 797–842. PMLR, 2015. + +Rong Ge, Jason D Lee, and Tengyu Ma. Matrix completion has no spurious local minimum. arXiv preprint arXiv:1605.07272, 2016. + +Gauthier Gidel, Francis Bach, and Simon Lacoste-Julien. Implicit regularization of discrete gradient dynamics in linear neural networks. arXiv preprint arXiv:1904.13262, 2019. + +Micah Goldblum, Jonas Geiping, Avi Schwarzschild, Michael Moeller, and Tom Goldstein. Truth or backpropaganda? an empirical investigation of deep learning theory. arXiv preprint arXiv:1910.00359, 2019. + +Benjamin D Haeffele and René Vidal. Global optimality in tensor factorization, deep learning, and beyond. arXiv preprint arXiv:1506.07540, 2015. + +X. Y. Han, Vardan Papyan, and David L. Donoho. Neural collapse under mse loss: Proximity to and dynamics on the central path, 2021. + +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. + +Arthur Jacot, Franck Gabriel, and Clément Hongler. Neural tangent kernel: convergence and generalization in neural networks. In Proceedings of the 32nd International Conference on Neural Information Processing Systems, pp. 8580–8589, 2018. + +Ziwei Ji, Miroslav Dudík, Robert E Schapire, and Matus Telgarsky. Gradient descent follows the regularization path for general losses. In Conference on Learning Theory, pp. 2109–2136. PMLR, 2020. + +Alex Krizhevsky, Geoffrey Hinton, et al. Learning multiple layers of features from tiny images. 2009. + +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. + +Anders Krogh and John A Hertz. A simple weight decay can improve generalization. In Advances in neural information processing systems, pp. 950–957, 1992. + +Yenson Lau, Qing Qu, Han-Wen Kuo, Pengcheng Zhou, Yuqian Zhang, and John Wright. Short-andsparse deconvolution–a geometric approach. arXiv preprint arXiv:1908.10959, 2019. + +Thomas Laurent and James Brecht. Deep linear networks with arbitrary loss: All local minima are global. In International conference on machine learning, pp. 2902–2907. PMLR, 2018. + +Yann LeCun, Léon Bottou, Yoshua Bengio, and Patrick Haffner. Gradient-based learning applied to document recognition. Proceedings of the IEEE, 86(11):2278–2324, 1998. + +Yann LeCun, Yoshua Bengio, and Geoffrey Hinton. Deep learning. nature, 521(7553):436–444, 2015. + +Jason D Lee, Max Simchowitz, Michael I Jordan, and Benjamin Recht. Gradient descent only converges to minimizers. In Conference on learning theory, pp. 1246–1257. PMLR, 2016. + +Yuanzhi Li, Tengyu Ma, and Hongyang Zhang. Algorithmic regularization in over-parameterized matrix sensing and neural networks with quadratic activations. In Conference On Learning Theory, pp. 2–47. PMLR, 2018. + +Zhiyuan Li and Sanjeev Arora. An exponential learning rate schedule for deep learning. arXiv preprint arXiv:1910.07454, 2019. + +Zichao Long, Yiping Lu, Xianzhong Ma, and Bin Dong. Pde-net: Learning pdes from data. In International Conference on Machine Learning, pp. 3208–3216. PMLR, 2018. + +Jianfeng Lu and Stefan Steinerberger. Neural collapse with cross-entropy loss. arXiv preprint arXiv:2012.08465, 2020. + +Kaifeng Lyu and Jian Li. Gradient descent maximizes the margin of homogeneous neural networks. arXiv preprint arXiv:1906.05890, 2019. + +Dustin G Mixon, Hans Parshall, and Jianzong Pi. Neural collapse with unconstrained features. arXiv preprint arXiv:2011.11619, 2020. + +Mor Shpigel Nacson, Suriya Gunasekar, Jason Lee, Nathan Srebro, and Daniel Soudry. Lexicographic and depth-sensitive margins in homogeneous and non-homogeneous deep models. In International Conference on Machine Learning, pp. 4683–4692. PMLR, 2019a. + +Mor Shpigel Nacson, Jason Lee, Suriya Gunasekar, Pedro Henrique Pamplona Savarese, Nathan Srebro, and Daniel Soudry. Convergence of gradient descent on separable data. In The 22nd International Conference on Artificial Intelligence and Statistics, pp. 3420–3428. PMLR, 2019b. + +Ioannis Panageas, Georgios Piliouras, and Xiao Wang. First-order methods almost always avoid saddle points: The case of vanishing step-sizes. arXiv preprint arXiv:1906.07772, 2019. + +Vardan Papyan, XY Han, and David L Donoho. Prevalence of neural collapse during the terminal phase of deep learning training. Proceedings of the National Academy of Sciences, 117(40): 24652–24663, 2020. + +Tomaso Poggio and Qianli Liao. Explicit regularization and implicit bias in deep network classifiers trained with the square loss. arXiv preprint arXiv:2101.00072, 2020. + +Qing Qu, Yuexiang Zhai, Xiao Li, Yuqian Zhang, and Zhihui Zhu. Analysis of the optimization landscapes for overcomplete representation learning. arXiv preprint arXiv:1912.02427, 2019. + +Noam Razin and Nadav Cohen. Implicit regularization in deep learning may not be explainable by norms. arXiv preprint arXiv:2005.06398, 2020. + +Karen Simonyan and Andrew Zisserman. Very deep convolutional networks for large-scale image recognition. arXiv preprint arXiv:1409.1556, 2014. + +Daniel Soudry, Elad Hoffer, Mor Shpigel Nacson, Suriya Gunasekar, and Nathan Srebro. The implicit bias of gradient descent on separable data. The Journal of Machine Learning Research, 19(1): 2822–2878, 2018. + +Ju Sun, Qing Qu, and John Wright. When are nonconvex problems not scary? arXiv preprint arXiv:1510.06096, 2015. + +Ju Sun, Qing Qu, and John Wright. Complete dictionary recovery over the sphere i: Overview and the geometric picture. IEEE Transactions on Information Theory, 63(2):853–884, 2016. + +Ju Sun, Qing Qu, and John Wright. A geometric analysis of phase retrieval. Foundations of Computational Mathematics, 18(5):1131–1198, 2018. + +Sharan Vaswani, Reza Babanezhad, Jose Gallego, Aaron Mishkin, Simon Lacoste-Julien, and Nicolas Le Roux. To each optimizer a norm, to each norm its generalization. arXiv preprint arXiv:2006.06821, 2020. + +G Alistair Watson. Characterization of the subdifferential of some matrix norms. Linear algebra and its applications, 170:33–45, 1992. + +Colin Wei, Jason Lee, Qiang Liu, and Tengyu Ma. On the margin theory of feedforward neural networks. 2018. + +Stephan Wojtowytsch and Weinan E. On the emergence of tetrahedral symmetry in the final and penultimate layers of neural network classifiers. arXiv preprint arXiv:2012.05420, 2020. + +Han Xiao, Kashif Rasul, and Roland Vollgraf. Fashion-mnist: a novel image dataset for benchmarking machine learning algorithms. arXiv preprint arXiv:1708.07747, 2017. + +Chiyuan Zhang, Samy Bengio, Moritz Hardt, Benjamin Recht, and Oriol Vinyals. Understanding deep learning (still) requires rethinking generalization. Communications of the ACM, 64(3):107–115, 2021. + +Linfeng Zhang, Jiequn Han, Han Wang, Roberto Car, and Weinan E. Deep potential molecular dynamics: a scalable model with the accuracy of quantum mechanics. Physical Review Letters, 120(14):143001, 2018. + +Yuqian Zhang, Qing Qu, and John Wright. From symmetry to geometry: Tractable nonconvex problems. arXiv preprint arXiv:2007.06753, 2020. + +Zhihui Zhu, Tianyu Ding, Jinxin Zhou, Xiao Li, Chong You, Jeremias Sulam, and Qing Qu. A geometric analysis of neural collapse with unconstrained features. arXiv preprint arXiv:2105.02375, 2021. + +# A ELEMENTS OF OPTIMIZATION + +In this section, we introduce some basic definitions and theory about optimization. In the following discussion, we consider a standard form inequality constrained optimization problem: + +$$ +\stackrel { \operatorname* { m i n } } { { } _ { x \in \mathbb { R } ^ { d } } } f ( x ) \quad { } _ { i \in [ n ] . } +$$ + +In addition, we assume all of those functions $f$ and $g _ { i }$ are twice differentiable. A point $x \in \mathbb { R } ^ { d }$ is said to be feasible if and only if it satisfies all of the constraints in (A.1), i.e., $g _ { i } ( x ) \leq 0 , \quad i \in [ n ]$ . And the Lagrangian of problem (A.1) is defined as following: + +$$ +L ( x , \lambda ) = f ( x ) + \sum _ { i = 1 } ^ { n } \lambda _ { i } g _ { i } ( x ) . +$$ + +# A.1 KARUSH KUHN TUCKER CONDITIONS + +Now let’s first introduce the definition of Karush Kuhn Tucker (KKT) point and approximate KKT point. Here we follows the definition of $( \epsilon , \delta )$ -KKT point as in Lyu & Li (2019). + +Definition A.1 (Definition of KKT point). A feasible point is said to be KKT point of problem (A.1) if there exist $\lambda _ { 1 } , \lambda _ { 2 } , \dotsb , \lambda _ { n } \geq 0$ such that the following Karush Kuhn Tucker (KKT) conditions hold: + +$$ +\begin{array} { r } { 1 . \ \nabla f ( x ) + \sum _ { i = 1 } ^ { n } \lambda _ { i } \nabla g _ { i } ( x ) = 0 } \end{array} +$$ + +Definition A.2 (Definition of $( \epsilon , \delta )$ -KKT point). For any $\epsilon , \delta > 0$ , a feasible point of (A.1) is said to be $( \epsilon , \delta )$ -KKT point of problem (A.1) if there exist $\lambda _ { 1 } , \lambda _ { 2 } , \dotsb , \lambda _ { n } \geq 0$ such that: + +$$ +\begin{array} { r } { 1 . \ | | \nabla f ( x ) + \sum _ { i = 1 } ^ { n } \lambda _ { i } \nabla g _ { i } ( x ) | | \leq \epsilon } \end{array} +$$ + +Generally speaking, KKT conditions might not be necessary for global optimality. We need some additional regular conditions to make it necessary. For example, as shown in Dutta et al. (2013) we can require the problem to satisfy the following Mangasarian-Fromovitz constraint qualification (MFCQ): + +Definition A.3 (Mangasarian-Fromovitz constraint qualification (MFCQ) ). For a feasible point $x$ of (A.1), problem (A.1) is said to satisfy (MFCQ) at $x$ if there exist a vector $v \in \mathbb { R } ^ { d }$ such that: + +$$ +\langle \nabla _ { x } g _ { i } ( x ) , v \rangle > 0 , \quad i \in [ n ] . +$$ + +Moreover, when MFCQ holds we can build a connection between approximate KKT point and KKT point, see detailed proof in Dutta et al. (2013): + +Theorem A.1 (Relationship between Approximate KKT point and KKT point). Let $\left\{ x _ { k } \in \mathbb { R } ^ { d } : k \in \tilde { \mathbb { N } } \right\}$ be a sequence of feasible points of (A.1) , $\{ \epsilon _ { k } > 0 : \bar { k } \in \mathbb { N } \}$ and $\{ \delta _ { k } > 0 : k \in \mathbb { N } \}$ be two sequences of real numbers such that $x _ { k }$ is an $( \epsilon _ { k } , \delta _ { k } )$ -KKT point for every $k$ , and $\epsilon _ { k } 0 , \delta _ { k } 0 .$ . If $x _ { k } \to x$ as $k \to + \infty$ . If MFCQ (A.3) holds at $x$ , then $x$ is a KKT point of $( P )$ . + +# B OMITTED PROOFS FROM SECTION 3.1 + +Recall our ULPM problem: + +$$ +\operatorname* { m i n } _ { W , H } \mathcal { L } ( W , H ) = - \sum _ { k = 1 } ^ { K } \sum _ { i = 1 } ^ { n } \log \left( \frac { \exp ( w _ { k } ^ { \top } h _ { k , i } ) } { \sum _ { j = 1 } ^ { K } \exp ( w _ { j } ^ { \top } h _ { k , i } ) } \right) . +$$ + +Let’s review some basic notations defined in the main body. Let $s _ { k , i , j } = \pmb { w } _ { k } ^ { \top } h _ { k , i } - \pmb { w } _ { j } ^ { \top } h _ { k , i } , \forall k \in$ $[ K ] , i \in [ n ] , j \in [ K ]$ , the margin of a single feature $h _ { k , i }$ is defined to be $q _ { k , i } ( W , H ) \ : =$ $\begin{array} { r } { \operatorname* { m i n } _ { j \neq k } s _ { k , i , j } = \pmb { w } _ { k } ^ { \top } \pmb { h } _ { k , i } - \operatorname* { m a x } _ { j \neq k } \pmb { w } _ { j } ^ { \top } \pmb { h } _ { k , i } } \end{array}$ . We define the margin of entire dataset as $q _ { m i n } =$ $\begin{array} { r } { q _ { \mathrm { m i n } } ( W , H ) = \operatorname* { m i n } _ { k \in [ 1 , K ] , i \in [ 1 , n ] } q _ { k , i } ( W , H ) . } \end{array}$ We first prove Theorem 3.1 in the mainbody. + +Proof of Theorem 3.1. First we can find that the margin will not change if we minus a vector $a$ for all $w _ { j }$ , so if we denote the mean of classifier $\begin{array} { r } { \tilde { \pmb { w } } _ { i } = \pmb { w } _ { i } - \frac { 1 } { K } \sum _ { i = 1 } ^ { K } \pmb { w } _ { i } } \end{array}$ and then we have $\begin{array} { r } { w _ { k } ^ { \top } h _ { k , i } - \operatorname* { m a x } _ { j \neq k } w _ { j } ^ { \top } h _ { k , i } = \tilde { w } _ { k } ^ { \top } h _ { k , i } - \operatorname* { m a x } _ { j \neq k } \tilde { w } _ { j } ^ { \top } h _ { k , i } \geq q _ { m i n } \tilde { ( } \tilde { W } , H ) , \tilde { ( } \tilde { W } , H ) . } \end{array}$ that is: + +$$ +\tilde { w } _ { k } ^ { \top } h _ { k , i } - \tilde { w } _ { j } ^ { \top } h _ { k , i } \geq q _ { m i n } ( W , H ) , \forall j \neq k \in [ K ] , i \in [ n ] . +$$ + +$\begin{array} { r } { \sum _ { j = 1 } ^ { K } \tilde { \pmb { w } } _ { j } ^ { \top } \pmb { h } _ { k , i } = 0 } \end{array}$ then sum this inequality over $j$ + +$$ +( K - 1 ) \tilde { w } _ { k } ^ { \top } h _ { k , i } - \sum _ { j \neq k } \tilde { w } _ { j } ^ { \top } h _ { k , i } = K \tilde { w } _ { k } ^ { \top } h _ { k , i } \geq ( K - 1 ) q _ { m i n } ( W , H ) , \forall k \in [ K ] , i \in [ n ] . +$$ + +By Cauchy inequality, we have: + +$$ +\frac { 1 } { 2 } ( \frac { 1 } { \sqrt { n } } | | \tilde { w } _ { k } | | _ { 2 } ^ { 2 } + \sqrt { n } | | h _ { k , i } | | _ { 2 } ^ { 2 } ) \geq \tilde { w } _ { k } ^ { \top } h _ { k , i } \geq \frac { K - 1 } { K } q _ { m i n } ( W , H ) . +$$ + +Sum (B.2) over $\mathbf { k }$ and i we have: + +$$ +\frac { 1 } { 2 } \sqrt { n } ( | | \tilde { W } | | _ { F } ^ { 2 } + | | H | | _ { F } ^ { 2 } ) \geq n ( K - 1 ) q _ { m i n } ( W , H ) . +$$ + +On the other hand, we know that: + +$$ +\lvert | \tilde { \boldsymbol { W } } \rvert | _ { F } ^ { 2 } = \sum _ { i = 1 } ^ { K } | | \boldsymbol { w } _ { i } - \frac { 1 } { K } \sum _ { i = 1 } ^ { K } \boldsymbol { w } _ { i } | | _ { 2 } ^ { 2 } \leq \sum _ { i = 1 } ^ { K } | | \boldsymbol { w } _ { i } | | _ { 2 } ^ { 2 } = | | \boldsymbol { W } | | _ { F } ^ { 2 } . +$$ + +Then we can conclude that: + +$$ +q _ { \operatorname* { m i n } } ( W , H ) \leq \frac { \| W \| _ { F } ^ { 2 } + \| H \| _ { F } ^ { 2 } } { 2 ( K - 1 ) \sqrt { n } } +$$ + +as desired. When the equality holds, first we have $| | \tilde { \cal W } | | _ { F } ^ { 2 } = | | { \cal W } | | _ { F } ^ { 2 }$ which is equivalent to $\begin{array} { r } { \frac { 1 } { K } \sum _ { i = 1 } ^ { K } w _ { i } = 0 , \tilde { w } _ { i } = w _ { i } } \end{array}$ . Take it back into (B.3), then we must have all of the equality holds in (B.2) and (B.1), which give us: + +$$ +{ \pmb w } _ { k } = \sqrt { n } { \pmb h } _ { k , i } , | | { \pmb w } _ { k } | | _ { 2 } ^ { 2 } = n | | { \pmb h } _ { k , i } | | _ { 2 } ^ { 2 } = \frac { | | { \pmb W } | | _ { F } ^ { 2 } + | | { \pmb H } | | _ { F } ^ { 2 } } { 2 K } . +$$ + +Take this into (B.1) we have: + +$$ +\pmb { h } _ { k , i } = \pmb { h } _ { k , i ^ { \prime } } , \pmb { h } _ { k , i } ^ { \top } \pmb { h } _ { j , i ^ { \prime } } = \pmb { w } _ { k } ^ { \top } \pmb { w } _ { j } = - \frac { \vert \vert \pmb { W } \vert \vert _ { F } ^ { 2 } + \vert \vert \pmb { H } \vert \vert _ { F } ^ { 2 } } { 2 K ( K - 1 ) \sqrt { n } } , +$$ + +which implies neural collapse conditions. + +Now let’s turn to the training dynamics and prove Theorem 3.2. Before starting the proof, we need to introduce some additional notations. Since the $W$ and $\pmb { H }$ are all optimization variables here, we denote $\theta = v e c ( W , H )$ as the whole parameter for simplicity and all of previous function can be defined on $\theta$ by matching the corresponding parameters. Denote $\rho = \| \theta \|$ as the norm of $\theta$ and $\begin{array} { r } { \tilde { \gamma } = \frac { - \log \left( e ^ { \mathcal { L } ( \theta ) } - 1 \right) } { \rho ^ { 2 } } } \end{array}$ . Now we can state our first lemma to show how training dynamics of gradient flow on ULPM objective (B) is related to a KKT point of (3.1). + +Lemma B.1. If there exist a time $t _ { 0 }$ such that $\mathcal { L } ( \theta ( t _ { 0 } ) ) ~ < ~ \log 2$ , then for any $t > t _ { 0 } \tilde { \theta } : =$ $\theta / q _ { \mathrm { m i n } } ( \theta ) ^ { 1 / 2 }$ is an $( \epsilon , \delta )$ - approximate KKT point of the following minimum-norm separation problem. More precisely, we have + +$$ +\epsilon = \sqrt { \frac { 2 ( 1 - \beta ( t ) ) } { \tilde { \gamma } ( t ) } } , \delta = \frac { K ^ { 2 } ( K - 1 ) n } { 2 e \tilde { \gamma } ( t ) q _ { m i n } ( t ) } , +$$ + +where: + +$$ +\beta = \langle { \frac { \theta } { | | \theta | | _ { 2 } } } , { \frac { d \theta } { d t } } / | | { \frac { d \theta } { d t } } | | _ { 2 } \rangle +$$ + +is the angle between $\theta$ and its corresponding gradient. + +Proof. The training dynamics is given by gradient flow: + +$$ +\frac { d \theta } { d t } = - \frac { \partial \mathcal { L } ( \theta ) } { \partial \theta } . +$$ + +Then by the chain rule we have: + +$$ +- \frac { d \mathcal { L } ( \theta ) } { d t } = - \frac { \partial \mathcal { L } } { \partial \theta } \frac { d \theta } { d t } = \left. \frac { d \theta } { d t } \right. ^ { 2 } . +$$ + +It indicates that the loss function $\mathcal { L }$ is monotonically decreasing. If $\mathcal { L } ( \theta ( t _ { 0 } ) ) < \log 2$ , we have $\mathcal { L } ( \theta ( t ) ) < \log 2 , \forall t > t _ { 0 }$ . On the other hand, note that + +$$ +\mathcal { L } ( \theta ( t ) ) = \sum _ { k = 1 } ^ { K } \sum _ { i = 1 } ^ { n } \log ( 1 + \sum _ { j \neq k } e ^ { - s _ { k , i , j } ( t ) } ) \geq \log ( 1 + \exp ( - q _ { m i n } ( t ) ) ) , +$$ + +which gives us $q _ { m i n } ( t ) > 0 , \forall t > t _ { 0 }$ . + +Let $\textstyle g = { \frac { d \theta } { d t } }$ , note that we can rewrite the ULPM objective function (B) as $\begin{array} { r } \mathcal { L } ( \theta ) = \sum _ { k = 1 } ^ { K } \sum _ { i = 1 } ^ { n } \log ( 1 + \ \end{array}$ $\textstyle \sum _ { j \neq k } e ^ { - s _ { k , i , j } } )$ . By the chain rule and the gradient flow equation we have + +$$ +g = - \frac { \partial \mathcal { L } } { \partial \theta } \sum _ { k = 1 } ^ { K } \sum _ { i = 1 } ^ { n } \sum _ { j \neq k } \frac { e ^ { - s _ { k , i , j } } } { 1 + \sum _ { l \neq k } e ^ { - s _ { k , i , l } } } g _ { k , i , j } , +$$ + +where $g _ { k , i , j }$ is the gradient of $s _ { k , i , j }$ , i.e. $g _ { k , i , j } = \nabla _ { \theta } s _ { k , i , j } ( \theta )$ . Now let $\tilde { g } _ { k , i , j } = g _ { k , i , j } / q _ { m i n } ^ { 1 / 2 } =$ $\nabla _ { \theta } s _ { k , i , j } ( \tilde { \theta } )$ and construct $\begin{array} { r } { \lambda _ { k , i , j } = \frac { \rho } { | | g | | _ { 2 } } \frac { e ^ { - s _ { k , i , j } } } { 1 + \sum _ { l \neq k } e ^ { - s _ { k , i , l } } } } \end{array}$ , we only need to show: + +$$ +| | \tilde { \theta } - \sum _ { k = 1 } ^ { K } \sum _ { i = 1 } ^ { n } \sum _ { j \neq k } \lambda _ { k , i , j } \tilde { g } _ { k , i , j } | | _ { 2 } ^ { 2 } \leq \frac { 1 - \beta } { \tilde { \gamma } } , +$$ + +$$ +\sum _ { k = 1 } ^ { K } \sum _ { i = 1 } ^ { n } \sum _ { j \neq k } \lambda _ { k , i , j } \big ( s _ { k , i , j } ( \tilde { \theta } ) - 1 \big ) \leq \frac { K ^ { 2 } ( K - 1 ) n } { 2 e q _ { m i n } \tilde { \gamma } } . +$$ + +To prove (B.6), we only need to compute (Recall that $\tilde { \theta } = \theta / q _ { m i n } ( \theta ) ^ { 1 / 2 } )$ : + +$$ +| | \tilde { \theta } - \sum _ { k = 1 } ^ { K } \sum _ { i = 1 } ^ { n } \sum _ { j \neq y _ { n } } \lambda _ { k , i , j } \tilde { g } _ { k , i , j } | | _ { 2 } ^ { 2 } = \frac { \rho ^ { 2 } } { q _ { m i n } } | | \frac { \theta } { | | \theta | | _ { 2 } } - \frac { g } { | | g | | _ { 2 } } | | _ { 2 } ^ { 2 } = \frac { \rho ^ { 2 } } { q _ { m i n } } ( 2 - 2 \beta ) . +$$ + +Note that: + +$$ +\tilde { \gamma } = \frac { - \log ( e ^ { C ( \theta ) } - 1 ) } { \rho ^ { 2 } } , \quad \mathcal { L } ( \theta ) = \sum _ { n = 1 } ^ { N } \log ( 1 + \sum _ { j \neq y _ { n } } e ^ { - s _ { n j } } ) \geq \log ( 1 + \exp ( - q _ { m i n } ) ) . +$$ + +Then we have the following inequality: + +$$ +\tilde { \gamma } \leq \frac { q _ { m i n } } { \rho ^ { 2 } } . +$$ + +Take this back into (B.8) we have (B.6) as desired. + +To prove (B.7), first by our construction: + +$$ +\sum _ { k = 1 } ^ { K } \sum _ { i = 1 } ^ { n } \sum _ { j \neq k } \lambda _ { k , i , j } ( s _ { k , i , j } ( \tilde { \theta } ) - 1 ) = \frac { \rho } { q _ { m i n } \left| | g | \right| _ { 2 } } \sum _ { k = 1 } ^ { K } \sum _ { i = 1 } ^ { n } \sum _ { j \neq k } \frac { e ^ { - s _ { k , i , j } } } { 1 + \sum _ { l \neq k } e ^ { - s _ { k , i , l } } } ( s _ { k , i , j } - q _ { m i n } ) . +$$ + +Note that $\begin{array} { r } { | | g | | _ { 2 } \geq \left. g , \frac { \theta } { | | \theta | | _ { 2 } } \right. = \frac { 1 } { \rho } \left. g , \theta \right. } \end{array}$ and $\langle g _ { k , i , j } , \theta \rangle = 2 s _ { k , i , j }$ since $s _ { k , i , j } = \pmb { w } _ { k } ^ { \top } \pmb { h } _ { k , i } - \pmb { w } _ { j } ^ { \top } \pmb { h } _ { k , i }$ , we have: + +$$ +\begin{array} { r l r } { { \| g \| _ { 2 } \geq \frac { 1 } { \rho } \langle g , \theta \rangle = \frac { 1 } { \rho } \sum _ { k = 1 } ^ { K } \displaystyle \sum _ { i \neq 1 } ^ { n } \sum _ { j \neq k } \frac { e ^ { - s _ { k , i , j } } } { 1 + \sum _ { l \neq k } e ^ { - s _ { k , i , l } } } \langle g _ { k , i , j } , \theta \rangle } } \\ & { } & { = \frac { 2 } { \rho } \displaystyle \sum _ { k = 1 } ^ { K } \displaystyle \sum _ { i = 1 } ^ { n } \sum _ { j \neq k } \frac { e ^ { - s _ { k , i , j } } } { 1 + \sum _ { l \neq k } e ^ { - s _ { k , i , l } } } s _ { k , i , j } } \\ & { } & { \geq \frac { 2 } { \rho } \displaystyle \frac { q _ { m i n } ~ K } { K } \sum _ { k = 1 } ^ { N } \sum _ { j \neq k } e ^ { - s _ { k , i , j } } ( \mathrm { s i n c e ~ } s _ { k , i , j } \geq q _ { m i n } > 0 \mathrm { ~ a n d ~ } e ^ { - s _ { k , i , l } } \leq 1 ) } \\ & { } & { \geq \frac { 2 } { \rho } \displaystyle \frac { q _ { m i n } } { K } e ^ { - q _ { m i n } } . } \end{array} +$$ + +Take this inequality back into the (B.10) we have: + +$$ +\begin{array} { r l } { { \sum _ { k = 1 } ^ { K } \sum _ { i = 1 } ^ { n } \sum _ { j \neq k } ^ { n } \lambda _ { k , i , j } ( s _ { k , i , j } ( \widetilde { \theta } ) - 1 ) \leq \frac { K \rho ^ { 2 } } { 2 q _ { m i n } ^ { 2 } } \sum _ { k = 1 } ^ { K } \sum _ { i = 1 } ^ { n } \sum _ { j \neq k } \frac { e ^ { q _ { m i n } - s _ { k , i , j } } } { 1 + \sum _ { l \neq k } e ^ { - s _ { k , i , j } } } ( s _ { k , i , j } - q _ { m i n } ) } } \\ & { \leq \frac { K \rho ^ { 2 } } { 2 q _ { m i n } ^ { 2 } } \sum _ { k = 1 } ^ { K } \sum _ { i = 1 } ^ { n } \sum _ { j \neq k } e ^ { q _ { m i n } - s _ { k , i , j } } ( s _ { k , i , j } - q _ { m i n } ) } \\ & { \leq \frac { K } { 2 q _ { m i n } \widetilde { \gamma } } \sum _ { k = 1 } ^ { K } \sum _ { i = 1 } ^ { n } \sum _ { j \neq k } e ^ { q _ { m i n } - s _ { k , i , j } } ( s _ { k , i , j } - q _ { m i n } ) } \\ & { \leq \frac { K ^ { 2 } ( K - 1 ) n } { 2 q _ { m i n } \widetilde { \gamma } } . } \end{array} +$$ + +Where the last inequality is obtained from the fact $\begin{array} { r } { x e ^ { - x } \le \frac { 1 } { e } , \forall x > 0 } \end{array}$ , which can be proved by some elementary calculus. + +Based on Lemma B.1, we have shown that the $( W , H )$ will be a $( \epsilon , \delta )$ -KKT point, if we can show $( \epsilon , \delta )$ converge to zero, then by Theorem A.1 we know the limit point will be along the direction of a KKT point. Ignoring the constant term, we only have to show how $\tilde { \gamma } ( t ) , \beta ( t )$ and $q _ { m i n } ( t )$ evolve along time. Now we provide the following lemmas to illustrate their dynamics. The first lemma aims at proving that the norms of parameter $\rho ( t )$ and $\tilde { \gamma } ( t )$ are monotonically increasing. + +Lemma B.2. If there exist $t _ { 0 }$ such that $\mathcal { L } ( \theta ( t _ { 0 } ) ) < \log 2$ , then for any $t > t _ { 0 }$ we have: + +$$ +\frac { d \rho ^ { 2 } } { d t } > 0 , \frac { d { \tilde { \gamma } } } { d t } \geq 0 . +$$ + +Proof. We can disentangle the whole training dynamics into the following two parts: + +• the radial part: $v : = { \hat { \theta } } { \hat { \theta } } ^ { \top } { \frac { d \theta } { d t } }$ , • the tangent part: $\begin{array} { r } { u = ( I - \hat { \theta } \hat { \theta } ^ { \top } ) \frac { d \theta } { d t } } \end{array}$ + +First analyze the radial part, by the chain rule: $\begin{array} { r } { | | \boldsymbol { v } | | _ { 2 } = | \hat { \theta } ^ { \top } \frac { d \theta } { d t } | = | \frac { 1 } { \rho } \left. \theta , \frac { d \theta } { d t } \right. | = | \frac { 1 } { \rho } \frac { 1 } { 2 } \frac { d \rho ^ { 2 } } { d t } | } \end{array}$ . For $\frac { d \rho ^ { 2 } } { d t }$ , we have the following equation: + +$$ +{ \frac { 1 } { 2 } } { \frac { d \rho ^ { 2 } } { d t } } = \left. \theta , { \frac { d \theta } { d t } } \right. = 2 \sum _ { k = 1 } ^ { K } \sum _ { i = 1 } ^ { n } \sum _ { j \neq k } { \frac { e ^ { - s _ { k , i , j } } } { 1 + \sum _ { l \neq k } e ^ { - s _ { k , i , l } } } } s _ { k , i , j } , +$$ + +where the last equality holds by equation (B.11).Then when $t > t _ { 0 }$ , we have shown that $q _ { m i n } ( t ) \geq 0$ , combine this with the fact $s _ { k , i , j } \geq q _ { m i n }$ we obtain the first inequality in (B.12) + +$$ +\begin{array} { c } { \displaystyle \frac 1 2 \frac { d \rho ^ { 2 } } { d t } = 2 \sum _ { k = 1 } ^ { K } \sum _ { i = 1 } ^ { n } \sum _ { j \neq k } \frac { e ^ { - s _ { k , i , j } } } { 1 + \sum _ { l \neq k } e ^ { - s _ { k , i , l } } } s _ { k , i , j } } \\ { \displaystyle \geq 2 \sum _ { k = 1 } ^ { K } \sum _ { i = 1 } ^ { n } \sum _ { j \neq k } \frac { e ^ { - s _ { k , i , j } } } { 1 + \sum _ { l \neq k } e ^ { - s _ { k , i , l } } } q _ { m i n } \geq 0 . } \end{array} +$$ + +Next, we aim to prove the monotonicity of $\tilde { \gamma } ( t )$ , compute the derivative of $\tilde { \gamma } ( t )$ we have: + +$$ +\begin{array} { c } { \displaystyle \tilde { \gamma } = \frac { - \log \left( e ^ { \mathcal { L } ( \theta ) } - 1 \right) } { \rho ^ { 2 } } , \quad \frac { d } { d t } \log \tilde { \gamma } = \frac { d } { d t } ( \log ( - \log ( e ^ { \mathcal { L } ( \theta ) } - 1 ) ) - 2 \log \rho ) , } \\ { \displaystyle \frac { d } { d t } \log ( - \log ( e ^ { \mathcal { L } ( \theta ) } - 1 ) ) = \frac { 1 } { \log \left( e ^ { \mathcal { L } ( \theta ) } - 1 \right) } \frac { e ^ { \mathcal { L } ( \theta ) } } { e ^ { \mathcal { L } ( \theta ) } - 1 } \frac { d \mathcal { L } ( \theta ) } { d t } \geq - \frac { d \mathcal { L } ( \theta ) } { d t } \frac { 1 } { q _ { m i n } } \frac { e ^ { \mathcal { L } ( \theta ) } } { e ^ { \mathcal { L } ( \theta ) } - 1 } . } \end{array} +$$ + +Recall that we have: + +$$ +\begin{array} { r l } & { \frac { 1 } { 2 } \frac { d \rho ^ { 2 } } { d t } = \displaystyle \sum _ { k = 1 } ^ { K } \sum _ { i = 1 } ^ { n } \sum _ { j \neq k } \frac { e ^ { - s _ { k , i , 2 } } } { 1 + \sum _ { i \neq j } \epsilon ^ { - s _ { k , i , 4 } } } s _ { k , i , j } } \\ & { \qquad \geq 2 \displaystyle \sum _ { k = 1 } ^ { K } \sum _ { i = 1 } ^ { N } \frac { \sum _ { j \neq k } c ^ { - s _ { k , 4 } } } { 1 + \sum _ { j \neq k } e ^ { - s _ { k , i , 2 } } } q _ { m i n } } \\ & { \qquad = \displaystyle \sum _ { k = 1 } ^ { K } \sum _ { i = 1 } ^ { n } \log ( 1 + \sum _ { j \neq k } e ^ { - s _ { k , i , 4 } } ) \frac { 1 } { \log ( 1 + \sum _ { j \neq k } e ^ { - s _ { k , i , 4 } } ) } \frac { \sum _ { j \neq k } e ^ { - s _ { k , i , j } } } { 1 + \sum _ { j \neq k } e ^ { - s _ { k , i , 4 } } } q _ { m i n } } \\ & { \qquad \leq 2 \displaystyle \sum _ { k = 1 + 1 - 1 } ^ { K } \log ( 1 + \sum _ { j \neq k } e ^ { - s _ { k , i , 4 } } ) \frac { e ^ { \tilde { \zeta } ( \theta ) } - 1 } { \tilde { \zeta } ( \theta ) e ^ { \tilde { \zeta } ( \theta ) } + \tilde { \zeta } ( \theta ) ^ { 2 } - \tilde { \zeta } ( \theta ) ^ { 2 } m i n } } \\ & { \qquad = 2 \displaystyle \frac { e ^ { \tilde { \zeta } ( \theta ) } - 1 } { e ^ { \tilde { \zeta } ( \theta ) } } q _ { m i n } . } \end{array} +$$ + +Then second last line is because the definition of the loss function $\begin{array} { r } { \mathcal { L } ( \theta ) = \sum _ { k = 1 } ^ { K } \sum _ { i = 1 } ^ { n } \log ( 1 + \mathbf { \lambda } } \end{array}$ $\begin{array} { r } { \sum _ { j \neq k } e ^ { - s _ { k , i , j } } \bigr ) \ \geq \ \log ( 1 + \sum _ { j \neq k } e ^ { - s _ { k , i , j } } ) } \end{array}$ and the monotonicity of $\frac { e ^ { x } - 1 } { x e ^ { x } }$ (in fact, $\begin{array} { l l } { d } & { { \underline { { e } } } ^ { x } - 1 } \\ { d x } & { { \underline { { x } } } e ^ { x } } \end{array} =$ e−x(x−ex+1) ≤ 0, ∀x > 0). + +As a result, we notice that + +$$ +\frac { 1 } { 2 } \frac { d } { d t } \log \tilde { \gamma } ( t ) \geq - \left( \frac { 1 } { 2 } \frac { d \rho ^ { 2 } } { d t } \right) ^ { - 1 } \frac { d \mathcal { L } } { d t } - \frac { d } { d t } \log \rho . +$$ + +At the same time, we notice that $\begin{array} { r } { \| v \| ^ { 2 } = \frac { 1 } { \rho ^ { 2 } } \left( \frac { 1 } { 2 } \frac { d \rho ^ { 2 } } { d t } \right) ^ { 2 } = \frac { 1 } { 2 } \frac { d \rho ^ { 2 } } { d t } \cdot \frac { d } { d t } \log \rho } \end{array}$ on the one hand, and by the chain rule: + +$$ +\frac { d } { d t } \hat { \theta } = \frac { 1 } { \rho ^ { 2 } } \left( \rho \frac { d \theta } { d t } - \frac { d \rho } { d t } \theta \right) = \frac { 1 } { \rho ^ { 2 } } \left( \rho \frac { d \theta } { d t } - \left( \hat { \theta } ^ { \top } \frac { d \theta } { d t } \right) \theta \right) = \frac { u } { \rho } . +$$ + +Combine this with the radial term: + +$$ +- { \frac { d { \mathcal { L } } } { d t } } = \left\| { \frac { d \theta } { d t } } \right\| ^ { 2 } = \| v \| ^ { 2 } + \| u \| ^ { 2 } = { \frac { 1 } { 2 } } { \frac { d \rho ^ { 2 } } { d t } } \cdot { \frac { d } { d t } } \log \rho + \rho ^ { 2 } \left\| { \frac { d \hat { \theta } } { d t } } \right\| ^ { 2 } . +$$ + +Dividing 12 dρ dt on both sides, we have + +$$ +- \frac { d \mathcal { L } } { d t } \cdot \left( \frac { 1 } { 2 } \frac { d \rho ^ { 2 } } { d t } \right) ^ { - 1 } = \frac { d } { d t } \log \rho + \left( \frac { d } { d t } \log \rho \right) ^ { - 1 } \left\| \frac { d \hat { \theta } } { d t } \right\| ^ { 2 } , +$$ + +$$ +\frac { d } { d t } \log \rho + \left( \frac { d } { d t } \log \rho \right) ^ { - 1 } \left\| \frac { d \hat { \theta } } { d t } \right\| ^ { 2 } \leq - \frac { d \mathcal { L } ( \theta ) } { d t } \frac { 1 } { q _ { m i n } } \frac { e ^ { \mathcal { L } ( \theta ) } } { 2 ( e ^ { \mathcal { L } ( \theta ) } - 1 ) } . +$$ + +Now by equation (B.15) and (B.16) we obtain: + +$$ +\frac { 1 } { 2 } \frac { d } { d t } \log \tilde { \gamma } \geq - \frac { d \mathcal { L } ( \theta ) } { d t } \frac { 1 } { q _ { m i n } } \frac { e ^ { C ( \theta ) } } { 2 \left( e ^ { \mathcal { L } ( \theta ) } - 1 \right) } - \frac { d } { d t } \log \rho \geq \left( \frac { d } { d t } \log \rho \right) ^ { - 1 } \left\| \frac { d \hat { \theta } } { d t } \right\| ^ { 2 } . +$$ + +By (B.14) we know the $\rho$ is monotonically increasing, we have $\begin{array} { r } { \frac { d } { d t } \log \rho > 0 } \end{array}$ and then we get the second inequality in (B.12). + +Lemma B.2 gives us the monotonicity of $\tilde { \gamma }$ , note that since the loss function $\mathcal { L } ( \theta ( t _ { 0 } ) ) < \log 2$ , we have $\tilde { \gamma } ( t ) \geq \bar { \tilde { \gamma } } ( t _ { 0 } ) > 0$ , then we can treat $\tilde { \gamma } ( t )$ in Lemma B.1 as a positive constant. The remaining work is to show $q _ { m i n } ( t )$ grows to infinity and $\beta ( t ) 1$ . To show $q _ { m i n } ( t ) \to \infty$ , it’s equivalent to show $\mathcal { L } ( t ) 0$ and we have the following lemma: + +Lemma B.3. If there exist $t _ { 0 }$ such that $\mathcal { L } ( \theta ( t _ { 0 } ) ) < \log 2$ , then $\mathcal { L } ( \boldsymbol { \theta } ( t ) ) \mathrm { 0 }$ and $q _ { m i n } ( \theta ( t ) ) \to \infty$ as $t \to \infty$ , moreover we have the convergence rate $\mathcal { L } ( \theta ( t ) ) = O ( \mathrm { { 1 } } / t )$ + +Proof. By (B.4) and (B.13), the evolution of loss function $\mathcal { L } ( \boldsymbol { \theta } )$ can be written as: + +$$ +\frac { d \mathcal { L } ( \theta ) } { d t } = - \left\| \frac { d \theta } { d t } \right\| ^ { 2 } \leq - \left. \frac { d \theta } { d t } , \frac { \theta } { | | \theta | | _ { 2 } } \right. ^ { 2 } = - ( 2 \sum _ { k = 1 } ^ { K } \sum _ { i = 1 } ^ { n } \sum _ { j \neq k } \frac { e ^ { - s _ { k , i , j } } } { 1 + \sum _ { l \neq k } e ^ { - s _ { k , i , l } } } s _ { k , i , j } ) ^ { 2 } . +$$ + +Combine it with (B.5),(B.14) and (B.17) we have: + +$$ +2 \sum _ { k = 1 } ^ { K } \sum _ { i = 1 } ^ { n } \sum _ { j \neq k } \frac { e ^ { - s _ { k , i , j } } } { 1 + \sum _ { l \neq k } e ^ { - s _ { k , i , l } } } s _ { k , i , j } \geq 2 \frac { e ^ { \mathcal { L } ( \theta ) } - 1 } { e ^ { \mathcal { L } ( \theta ) } } q _ { m i n } \geq - 2 \frac { e ^ { \mathcal { L } ( \theta ) } - 1 } { e ^ { \mathcal { L } ( \theta ) } } \log ( e ^ { \mathcal { L } ( \theta ) } - 1 ) , +$$ + +which indicates: + +$$ +\frac { d \mathcal { L } ( \theta ( t ) ) } { d t } \leq - 4 ( \frac { e ^ { \mathcal { L } ( \theta ( t ) ) } - 1 } { e ^ { \mathcal { L } ( \theta ( t ) ) } } \log ( e ^ { \mathcal { L } ( \theta ( t ) ) } - 1 ) ) ^ { 2 } . +$$ + +Since $0 < \mathcal { L } ( \theta ( t ) ) < \mathcal { L } ( \theta ( t _ { 0 } ) ) < \log 2$ , note that: + +$$ +\frac { d } { d x } ( \frac { e ^ { x } - 1 } { x } ) > 0 , \operatorname* { l i m } _ { x 0 } \frac { e ^ { x } - 1 } { x } = 1 , +$$ + +which implies: + +$$ +1 < \frac { e ^ { \mathcal { L } ( \theta ( t ) ) } - 1 } { \mathcal { L } ( \theta ( t ) ) } < \frac { 1 } { \log ( 2 ) } , +$$ + +On the other hand, we can find that: + +$$ +\log ( e ^ { \mathcal { L } ( \theta ( t ) ) } - 1 ) < \log ( e ^ { \mathcal { L } ( \theta ( t _ { 0 } ) ) } - 1 ) < 0 , \quad 1 < e ^ { \mathcal { L } ( \theta ( t ) ) } < 2 +$$ + +Combine equation (B.21) and (B.22) together, one can conclude that there exist a constant $C > 0$ such that for $t > t _ { 0 }$ : + +$$ +\frac { d \mathcal { L } ( \theta ( t ) ) } { d t } \leq - C ( \mathcal { L } ( \theta ( t ) ) ) ^ { 2 } +$$ + +It further implies that: + +$$ +C < \frac { d } { d t } ( \frac { 1 } { \mathcal { L } ( \theta ( t ) ) } ) , +$$ + +then integral on both side we have: + +$$ +C ( t - t _ { 0 } ) < \frac { 1 } { \mathcal { L } ( \theta ( t ) ) } - \frac { 1 } { \mathcal { L } ( \theta ( t _ { 0 } ) ) } , +$$ + +and + +$$ +{ \mathcal { L } } ( \theta ( t ) ) = O ( 1 / t ) . +$$ + +Thus we must have ${ \mathcal { L } } ( \theta ( t ) ) \to 0$ and combine this with $q _ { m i n } ~ \ge ~ - \log ( e ^ { \mathcal { L } ( \theta ( t ) ) } - 1 )$ we know $q _ { m i n } ( \theta ( t ) ) \to \infty$ as desired. + +To bound $\beta ( t )$ , we first need a useful lemma to bound the changes of the direction of $\theta$ . + +Lemma B.4. If there exist $t _ { 0 }$ such that $\mathcal { L } ( \theta ( t _ { 0 } ) ) < \log 2$ , then for any $t > t _ { 0 }$ + +$$ +\left\| \frac { d \hat { \theta } } { d t } \right\| \leq \frac { 1 } { \tilde { \gamma } ( t _ { 0 } ) } \frac { d } { d t } \log \rho . +$$ + +Proof. First we know that: + +$$ +\begin{array} { c } { \displaystyle \left\| \frac { d \hat { \theta } } { d t } \right\| = \frac { 1 } { \rho } \left\| ( I - \hat { \theta } \hat { \theta } ^ { \top } ) \frac { d \theta } { d t } \right\| \leq \frac { 1 } { \rho } \left\| \frac { d \theta } { d t } \right\| , } \\ { \displaystyle \left\| \frac { d \theta } { d t } \right\| = \left\| \sum _ { k = 1 } ^ { K } \sum _ { i = 1 } ^ { n } \sum _ { j \neq k } \frac { e ^ { - s _ { k , i , j } } } { 1 + \sum _ { l \neq k } e ^ { - s _ { k , i , l } } g _ { k , i , j } } \right\| \leq \sum _ { k = 1 } ^ { K } \sum _ { i = 1 } ^ { n } \sum _ { j \neq k } \frac { e ^ { - s _ { k , i , j } } } { 1 + \sum _ { l \neq k } e ^ { - s _ { k , i , l } } } \left\| g _ { k , i , j } \right\| . } \end{array} +$$ + +Recall our $\begin{array} { r } { g _ { k , i , j } = \frac { \partial s _ { k , i , j } } { \partial \theta } } \end{array}$ ∂sk,i,j∂θ and sk,i,j = w>k hk,i − w>j hk,i, we can find that kgk,i,j k ≤ 2ρ. On the other hand, Combine it with (B.13) and (B.9) we have: + +$$ +\left| \left| \frac { d \hat { \theta } } { d t } \right| \right| \leq \frac { 1 } { \rho } \left\| \frac { d \theta } { d t } \right\| \leq \frac { 1 } { 2 q _ { m i n } } \frac { d \rho ^ { 2 } } { d t } = \frac { \rho ^ { 2 } } { q _ { m i n } } \frac { d } { d t } \log \rho \leq \frac { 1 } { \tilde { \gamma } } \frac { d } { d t } \log \rho \leq \frac { 1 } { \tilde { \gamma } ( t _ { 0 } ) } \frac { d } { d t } \log \rho +$$ + +as desired. Where the second inequality holds by multiple $\frac { \rho } { q _ { m i n } }$ on the right hand of (B.23) and the formula of dρ2 in equation (B.13), and the last inequality holds since we have shown that $\tilde { \gamma } ( t )$ is monotonically increasing in (B.2) and $\tilde { \gamma } ( t _ { 0 } ) > 0$ since $\mathcal { L } ( t _ { 0 } ) < \log 2$ . □ + +Let’s turn back to $\beta$ , though we can not show directly that it increase to one, we can find a sequence of time $\left\{ { { t } _ { m } } \right\}$ for each limit point such that $\beta ( t _ { m } ) 1$ + +Lemma B.5. If there exist $t _ { 0 }$ such that $\mathcal { L } ( \theta ( t _ { 0 } ) ) < \log 2$ , then for every limit point $\bar { \theta }$ of $\{ { \hat { \theta } } ( t ) :$ $t \geq 0 \}$ , there exists a sequence of time $\{ t _ { m } > 0 : m \in \mathbb { N } \}$ such that $t _ { m } \infty , { \hat { \theta } } ( t _ { m } ) { \bar { \theta } }$ , and $\beta ( t _ { m } ) 1$ . + +Proof. Recall that in equation (B.19) we have shown that: + +$$ +\frac { d } { d t } \log \tilde { \gamma } \geq 2 \left( \frac { d } { d t } \log \rho \right) ^ { - 1 } \left\| \frac { d \hat { \theta } } { d t } \right\| ^ { 2 } . +$$ + +Since $\begin{array} { r } { \frac { d } { d t } \log \rho = \frac { 1 } { \rho } \frac { d \rho } { d t } = \frac { 1 } { 2 \rho ^ { 2 } } \frac { d \rho ^ { 2 } } { d t } = \frac { 1 } { \rho ^ { 2 } } \left. \theta , \frac { d \theta } { d t } \right. } \end{array}$ and: + +$$ +\frac { d \hat { \theta } } { d t } = \frac { d } { d t } \frac { \theta } { \| \theta \| } = \frac { 1 } { \rho ^ { 2 } } ( \rho \frac { d \theta } { d t } - \frac { 1 } { \rho } \theta \theta ^ { \top } \frac { d \theta } { d t } ) = \frac { 1 } { \rho } \big ( I - \hat { \theta } \hat { \theta } ^ { \top } \big ) \frac { d \theta } { d t } . +$$ + +Plug them into (B.24) we have: + +$$ +\frac { d } { d t } \log \tilde { \gamma } \geq 2 \frac { \left. \frac { d \theta } { d t } \right. ^ { 2 } - \left. \hat { \theta } , \frac { d \theta } { d t } \right. ^ { 2 } } { \left. \hat { \theta } , \frac { d \theta } { d t } \right. ^ { 2 } } \frac { d } { d t } \log \rho = 2 ( \beta ^ { - 2 } - 1 ) \frac { d } { d t } \log \rho . +$$ + +For any $t _ { 2 } > t _ { 1 } > t _ { 0 }$ , integrate both sides from time $t _ { 2 }$ to $t _ { 1 }$ we have: $\log \tilde { \gamma } ( t _ { 2 } ) - \log \tilde { \gamma } ( t _ { 1 } ) \ \geq$ $\begin{array} { r } { 2 \int _ { t _ { 1 } } ^ { t _ { 2 } } ( \beta ( t ) ^ { - 2 } - 1 ) \frac { d } { d t } \log \rho d t } \end{array}$ . By the continuity of $\beta$ we know there exist a time $t ^ { * }$ such that: + +$$ +\begin{array} { l } { \log \tilde { \gamma } ( t _ { 2 } ) - \log \tilde { \gamma } ( t _ { 1 } ) \geq 2 \displaystyle \int _ { t _ { 1 } } ^ { t _ { 2 } } ( \beta ( t ) ^ { - 2 } - 1 ) \frac { d } { d t } \log \rho d t } \\ { = 2 ( \beta ( t ^ { \ast } ) ^ { - 2 } - 1 ) \displaystyle \int _ { t _ { 1 } } ^ { t _ { 2 } } \frac { d } { d t } \log \rho d t } \\ { = 2 ( \beta ( t ^ { \ast } ) ^ { - 2 } - 1 ) ( \log \rho ( t _ { 2 } ) - \log \rho ( t _ { 1 } ) ) . } \end{array} +$$ + +By (B.9) we know that $\begin{array} { r l } { \tilde { \gamma } ~ \leq ~ \frac { q _ { m i n } } { \rho ^ { 2 } } } \end{array}$ and the right hand is bounded, and the $\tilde { \gamma }$ is monotonically increasing, then there exist $\tilde { \gamma } _ { \infty }$ such that $\tilde { \gamma } ( t ) \uparrow \tilde { \gamma } _ { \infty }$ . + +Now we are ready to construct the sequence of $t _ { m }$ , first take a sequence of $\{ \epsilon _ { m } > 0 , m \in \mathbb { N } \}$ such that $\epsilon _ { m } \to 0$ . We construct $t _ { m }$ by induction, suppose we have already find $t _ { 1 } < t _ { 2 } < \cdot \cdot \cdot < t _ { m - 1 }$ satisfy our requirement, since $\bar { \theta }$ is a limit point of $\{ \hat { \theta } ( t ) : t > 0 \}$ , then we can find a time $s _ { m }$ such that: + +$$ +\begin{array} { r } { \| \hat { \theta } ( s _ { m } ) - \bar { \theta } \| \leq \epsilon _ { m } , \quad \log \frac { \tilde { \gamma } _ { \infty } } { \tilde { \gamma } \left( s _ { m } \right) } \leq \epsilon _ { m } ^ { 3 } . } \end{array} +$$ + +By the monotonicity and continuity of $\rho$ we can find a time $s _ { m } ^ { \prime }$ such that $\log \rho ( s _ { m } ^ { \prime } ) - \log \rho ( s _ { m } ) \leq \epsilon _ { m }$ Take $t _ { 2 } = s _ { m } ^ { \prime } , t _ { 1 } = s _ { m }$ in (B.25), there exist a time $t _ { m }$ such that: + +$$ +2 ( \beta ( t _ { m } ) ^ { - 2 } - 1 ) \le \frac { \log \tilde { \gamma } ( t _ { 2 } ) - \log \tilde { \gamma } ( t _ { 1 } ) } { \log \rho ( t _ { 2 } ) - \log \rho ( t _ { 1 } ) } \le \epsilon _ { m } ^ { 2 } +$$ + +on the other hand, by Lemma B.4 we have: + +$$ +\begin{array} { r l r } { { \| \hat { \theta } ( t _ { m } ) - \bar { \theta } \| \leq \| \hat { \theta } ( s _ { m } ) - \bar { \theta } \| + \| \hat { \theta } ( s _ { m } ) - \hat { \theta } ( t _ { m } ) \| } } \\ & { } & { \leq \epsilon _ { m } + \frac { 1 } { \tilde { \gamma } ( t _ { 0 } ) } ( \log \rho ( t _ { m } ) - \log \rho ( s _ { m } ) ) \leq ( 1 + \frac { 1 } { \tilde { \gamma } ( t _ { 0 } ) } ) \epsilon _ { m } . } \end{array} +$$ + +Note that $\textstyle \left. \theta , { \frac { d \theta } { d t } } \right. > 0$ , then by definition we know $\beta > 0$ . Combine equations (B.26) and (B.27) we have $\beta ( t _ { m } ) 1$ and $\hat { \theta } ( t _ { m } ) \to \bar { \theta }$ as desired. □ + +Now we are ready to prove Theorem 3.2: + +Proof of Theorem 3.2. By Lemma B.1, we know that once $\begin{array} { r l r l r l } { t } & { { } } & { > } & { { } } & { t _ { 0 } } \end{array}$ , $( W ( t ) , H ( t ) ) / q _ { m i n } ( W ( t ) , H ( t ) )$ is an $( \sqrt { \frac { 2 ( 1 - \beta ( t ) ) } { \tilde { \gamma } ( t ) } }$ , $\frac { K ^ { 2 } ( K - 1 ) n } { 2 \tilde { \gamma } ( t ) q _ { m i n } ( t ) } )$ -approximate KKT point. We have shown that $\tilde { \gamma } ( t ) ~ > ~ \tilde { \gamma } ( t _ { 0 } ) ~ \dot { > } ~ 0$ in Lemma B.2, $q _ { m i n } \ \to \ \infty$ in Lemma B.3 and from Lemma B.5 we know for any limit point $( \bar { W } , \bar { H } )$ of $\begin{array} { r l } { \{ ( \hat { H } ( t ) , \hat { W } ( t ) ) } & { { } : = } \end{array}$ $( \frac { \pmb { H } ( t ) } { \sqrt { \| \pmb { W } ( t ) \| _ { F } ^ { 2 } + \| \pmb { H } ( t ) \| _ { F } ^ { 2 } } } , \frac { \pmb { W } ( t ) } { \sqrt { \| \pmb { W } ( t ) \| _ { F } ^ { 2 } + \| \pmb { H } ( t ) \| _ { F } ^ { 2 } } } ) \}$ , there exists a sequence of time $\{ t _ { m } > 0 : m \in \mathbb { N } \}$ such that $t _ { m } \infty , \beta ( t _ { m } ) 1$ and $( \hat { H } ( t _ { m } ) , \hat { W } ( t _ { m } ) ) ( \hat { W } , \bar { H } )$ . Then $( \bar { W } , \bar { H } )$ is along the direction of a limit point of a sequence of $( \epsilon , \delta )$ -approximate KKT point with $\epsilon , \delta \to 0$ . On the other hand, we can verify that the problem (3.1) satisfies MCFQ (A.3) by simply setting $v = \theta$ , then: + +$$ +\left. \nabla s _ { k , i , j } , \theta \right. = 2 s _ { k , i , j } \geq 0 . +$$ + +Now by Theorem A.1 we know $( \bar { W } , \bar { H } )$ is along the direction of a KKT point of problem (3.1) + +Theorem 3.2 characterize the convergent behaviour of gradient flow, under separable conditions the limit point is along the direction of a KKT point of (3.1), next we show that the global minimum of (3.1) must satisfy neural collapse conditions by proving Corollary 3.1: + +Proof of Corollary 3.1. Since we have shown that the problem (3.1) satisfy MCFQ, then the KKT conditions are necessary for global optimality, we only need to show the global optimum satisfies neural collapse conditions. First the constraints in (3.1) can be transformed to be a single constraint by the definition of margin: + +$$ +\forall k \neq j \in [ K ] , i \in [ n ] , \quad w _ { k } ^ { \top } h _ { k , i } - w _ { j } ^ { \top } h _ { k , i } \geq 1 . \Leftrightarrow q _ { \operatorname* { m i n } } ( W , H ) \geq 1 . +$$ + +Note that the margin is homogeneous: + +$$ +q _ { \operatorname* { m i n } } ( \alpha W , \alpha H ) = \alpha ^ { 2 } q _ { \operatorname* { m i n } } ( W , H ) , \forall \alpha \in \mathbb { R } . +$$ + +Then for any point $( W , H )$ satisfies $q _ { \mathrm { m i n } } ( W , H ) \ > \ 0$ , after an appropriate scaling $\alpha$ , $( \alpha W , \alpha H ) , \dot { \forall } \alpha ^ { \hat { 2 } } \ge 1 / q _ { \operatorname* { m i n } } ( W , H )$ is feasible for (3.1). Take optimum among all scaling factor $\alpha$ we know the minimum norm is attained if and only if $\alpha ^ { 2 } = 1 / \overset { \cdot } { q } _ { \mathrm { m i n } } ( W , H )$ . And the optimum norm is: + +$$ +\frac { 1 } { 2 } | | \boldsymbol { \alpha } \boldsymbol { W } | | _ { F } ^ { 2 } + \frac { 1 } { 2 } | | \boldsymbol { \alpha } \boldsymbol { H } | | _ { F } ^ { 2 } = \frac { 1 } { 2 q _ { \mathrm { m i n } } ( \boldsymbol { W } , \boldsymbol { H } ) } ( | | \boldsymbol { W } | | _ { F } ^ { 2 } + | | \boldsymbol { H } | | _ { F } ^ { 2 } ) . +$$ + +Then by Theorem 3.1 we have: + +$$ +\frac { 1 } { 2 q _ { \mathrm { m i n } } ( W , H ) } ( | | W | | _ { F } ^ { 2 } + | | H | | _ { F } ^ { 2 } ) \geq 2 ( K - 1 ) \sqrt { n } . +$$ + +And the global optimum is attained only when $( W , H )$ satisfies neural collapse conditions + +# C OMITTED PROOFS FROM SECTION 3.2 + +To begin with, let’s finish the computation in the motivating example (Example 3.1) + +Proof in Example 3.1. Consider the case where $K = 4 , n = 1$ , let $( W , H )$ be the following point: + +$$ +W = H = \left[ \begin{array} { c c c c } { { 1 } } & { { - 1 } } & { { 0 } } & { { 0 } } \\ { { - 1 } } & { { 1 } } & { { 0 } } & { { 0 } } \\ { { 0 } } & { { 0 } } & { { 1 } } & { { - 1 } } \\ { { 0 } } & { { 0 } } & { { - 1 } } & { { 1 } } \end{array} \right] . +$$ + +One can easily verify that this $( W , H )$ enables our model to classify all of the features perfectly. Further more, we can show it is along the direction of a KKT point of the minimum-norm separation problem (3.1) by construct the Lagrangian multiplier $\Lambda = ( \bar { \lambda _ { i j } } ) _ { i , j = 1 } ^ { K }$ as following: + +$$ +\Lambda = \left[ \begin{array} { c c c c } { { 0 } } & { { 0 } } & { { { \textstyle { \frac { 1 } { 2 } } } } } & { { { \textstyle { \frac { 1 } { 2 } } } } } \\ { { 0 } } & { { 0 } } & { { { \textstyle { \frac { 1 } { 2 } } } } } & { { { \textstyle { \frac { 1 } { 2 } } } } } \\ { { { \textstyle { \frac { 1 } { 2 } } } } } & { { { \textstyle { \frac { 1 } { 2 } } } } } & { { 0 } } & { { 0 } } \\ { { { \textstyle { \frac { 1 } { 2 } } } } } & { { { \textstyle { \frac { 1 } { 2 } } } } } & { { 0 } } & { { 0 } } \end{array} \right] . +$$ + +To see this, just write down the corresponding Lagrangian (note that to make it to be a true KKT point of (3.1), one needs to multiple $1 / \sqrt { 2 }$ on $W , H )$ : + +$$ +\mathcal { L } ( W , H , \Lambda ) = \frac { 1 } { 4 } \| W \| _ { F } ^ { 2 } + \frac { 1 } { 4 } \| H \| _ { F } ^ { 2 } - \sum _ { i = 1 } ^ { 4 } \sum _ { j \neq i } \lambda _ { i , j } ( \frac { 1 } { 2 } w _ { i } h _ { i } - \frac { 1 } { 2 } w _ { j } h _ { i } - 1 ) . +$$ + +Simply take derivatives for $W , H$ and $\Lambda$ we can find it satisfies KKT conditions. On the other hand, the gradient of $( W , H )$ is + +$$ +\nabla _ { W } \mathcal { L } ( W , H ) = \nabla _ { H } \mathcal { L } ( W , H ) = - \frac { 2 + 2 e ^ { - 2 } } { 2 + 2 e ^ { - 2 } + 2 e ^ { 2 } } \left[ \begin{array} { c c c c } { 1 } & { - 1 } & { 0 } & { 0 } \\ { - 1 } & { 1 } & { 0 } & { 0 } \\ { 0 } & { 0 } & { 1 } & { - 1 } \\ { 0 } & { 0 } & { - 1 } & { 1 } \end{array} \right] . +$$ + +We can find that the directions of gradient and the parameter align with each other (i.e., $W$ is parallel to $\nabla _ { W } \mathcal { L } ( W , H )$ , and $\pmb { H }$ is parallel to $\nabla _ { H } \mathcal { L } ( W , H ) )$ , which implies that simple gradient descent may gets stuck in this direction and only grows the parameters’ norm. However, if we construct: + +$$ +\begin{array} { l } { { W ^ { \prime } = \sqrt { \displaystyle { \frac { 1 } { 1 + 2 \alpha ^ { 2 } } } } \left[ \begin{array} { c c c c } { { 1 + \alpha } } & { { - 1 + \alpha } } & { { \alpha } } & { { \alpha } } \\ { { - 1 + \alpha } } & { { 1 + \alpha } } & { { \alpha } } & { { \alpha } } \\ { { - \alpha } } & { { - \alpha } } & { { 1 - \alpha } } & { { - 1 - \alpha } } \\ { { - \alpha } } & { { - \alpha } } & { { - 1 - \alpha } } & { { 1 - \alpha } } \end{array} \right] , } } \\ { { { } } } \\ { { { \cal H } ^ { \prime } = \sqrt { \displaystyle { \frac { 1 } { 1 + 2 \alpha ^ { 2 } } } } \left[ \begin{array} { c c c c } { { 1 + \alpha } } & { { - 1 + \alpha } } & { { - \alpha } } & { { - \alpha } } \\ { { - 1 + \alpha } } & { { 1 + \alpha } } & { { - \alpha } } & { { - \alpha } } \\ { { \alpha } } & { { \alpha } } & { { 1 - \alpha } } & { { - 1 - \alpha } } \\ { { \alpha } } & { { \alpha } } & { { - 1 - \alpha } } & { { 1 - \alpha } } \end{array} \right] . } } \end{array} +$$ + +Note that $\lVert \boldsymbol { W } ^ { \prime } \rVert _ { F } = \lVert \boldsymbol { W } \rVert _ { F } , \lVert \boldsymbol { H } ^ { \prime } \rVert _ { F } = \lVert \boldsymbol { H } \rVert _ { F }$ and $| | W ^ { \prime } - W | | _ { F } ^ { 2 } + | | H ^ { \prime } - H | | _ { F } ^ { 2 } \to 0$ as $\alpha 0$ First we can compute: + +$$ +W ^ { \prime } H ^ { \prime } = \frac { 1 } { 1 + 2 \alpha ^ { 2 } } \left[ \begin{array} { c c c c } { { 2 + 4 \alpha ^ { 2 } } } & { { 4 \alpha ^ { 2 } - 2 } } & { { - 4 \alpha ^ { 2 } } } & { { - 4 \alpha ^ { 2 } } } \\ { { 4 \alpha ^ { 2 } - 2 } } & { { 2 + 4 \alpha ^ { 2 } } } & { { - 4 \alpha ^ { 2 } } } & { { - 4 \alpha ^ { 2 } } } \\ { { - 4 \alpha ^ { 2 } } } & { { - 4 \alpha ^ { 2 } } } & { { 2 + 4 \alpha ^ { 2 } } } & { { 4 \alpha ^ { 2 } - 2 } } \\ { { - 4 \alpha ^ { 2 } } } & { { - 4 \alpha ^ { 2 } } } & { { 4 \alpha ^ { 2 } - 2 } } & { { 2 + 4 \alpha ^ { 2 } } } \end{array} \right] , +$$ + +and: + +$$ +\mathcal { L } ( W ^ { \prime } , H ^ { \prime } ) = - 4 \log \frac { e ^ { 2 } } { e ^ { 2 } + e ^ { 2 \frac { 2 \alpha ^ { 2 } - 1 } { 1 + 2 \alpha ^ { 2 } } } + 2 e ^ { - 2 \frac { 2 \alpha ^ { 2 } } { 1 + 2 \alpha ^ { 2 } } } } . +$$ + +Our aim is to show that for any $\epsilon > 0$ , there exist $\alpha$ such that $| \alpha | < \epsilon$ and $\mathcal { L } ( W ^ { \prime } , H ^ { \prime } ) < \mathcal { L } ( W , H )$ . +By the formulation of L(W 0, H0), it’s sufficient to show that f (α) , e2 2α2−11+2α2 + $f ( \alpha ) \triangleq e ^ { 2 \frac { 2 \alpha ^ { 2 } - 1 } { 1 + 2 \alpha ^ { 2 } } } + 2 e ^ { - 2 \frac { 2 \alpha ^ { 2 } } { 1 + 2 \alpha ^ { 2 } } } < f ( 0 )$ . + +$$ +f ^ { \prime } ( \alpha ) = e ^ { \frac { 4 \alpha ^ { 2 } - 2 } { 1 + 2 \alpha ^ { 2 } } } \left( \frac { 8 \alpha } { 1 + 2 \alpha ^ { 2 } } - \frac { 8 \alpha \left( 2 \alpha ^ { 2 } - 1 \right) } { \left( 1 + 2 \alpha ^ { 2 } \right) ^ { 2 } } \right) + 2 e ^ { - \frac { 4 \alpha ^ { 2 } } { 1 + 2 \alpha ^ { 2 } } } \left( \frac { 1 6 \alpha ^ { 3 } } { \left( 1 + 2 \alpha ^ { 2 } \right) ^ { 2 } } - \frac { 8 \alpha } { 1 + 2 \alpha ^ { 2 } } \right) , +$$ + +$$ +{ \begin{array} { r l } & { f ^ { \prime \prime } ( \alpha ) = e ^ { \frac { 4 \alpha ^ { 2 } - 2 } { 1 + 2 \alpha ^ { 2 } } } \left( { \cfrac { 8 \alpha } { 1 + 2 \alpha ^ { 2 } } } - { \cfrac { 8 \alpha \left( 2 \alpha ^ { 2 } - 1 \right) } { \left( 1 + 2 \alpha ^ { 2 } \right) ^ { 2 } } } \right) ^ { 2 } + 2 e ^ { - { \frac { 4 \alpha ^ { 2 } } { 1 + 2 \alpha ^ { 2 } } } } \left( { \cfrac { 1 6 \alpha ^ { 3 } } { \left( 1 + 2 \alpha ^ { 2 } \right) ^ { 2 } } } - { \cfrac { 8 \alpha } { 1 + 2 \alpha ^ { 2 } } } \right) ^ { 2 } } \\ & { \qquad + e ^ { \frac { 4 \alpha ^ { 2 } - 2 } { 1 + 2 \alpha ^ { 2 } } } \left( - { \cfrac { 6 4 \alpha ^ { 2 } } { \left( 1 + 2 \alpha ^ { 2 } \right) ^ { 2 } } } + { \cfrac { 6 4 \left( 2 \alpha ^ { 2 } - 1 \right) \alpha ^ { 2 } } { \left( 1 + 2 \alpha ^ { 2 } \right) ^ { 3 } } } + { \cfrac { 8 } { 1 + 2 \alpha ^ { 2 } } } - { \cfrac { 8 \left( 2 \alpha ^ { 2 } - 1 \right) } { \left( 1 + 2 \alpha ^ { 2 } \right) ^ { 2 } } } \right) } \\ & { \qquad + 2 e ^ { - { \frac { 4 \alpha ^ { 2 } } { 1 + 2 \alpha ^ { 2 } } } } \left( { \cfrac { 8 0 \alpha ^ { 2 } } { \left( 1 + 2 \alpha ^ { 2 } \right) ^ { 2 } } } - { \cfrac { 8 } { 1 + 2 \alpha ^ { 2 } } } - { \cfrac { 1 2 8 \alpha ^ { 4 } } { \left( 1 + 2 \alpha ^ { 2 } \right) ^ { 3 } } } \right) . } \end{array} } +$$ + +Now we can find that $f ^ { \prime } ( 0 ) = 0$ and $f ^ { \prime \prime } ( 0 ) = 1 6 ( \frac { 1 } { e ^ { 2 } } - 1 ) < 0$ . Since the function $f ( \alpha )$ is continuously twice differentiable, we can conclude that for any $\epsilon > 0$ , we can choose appropriate $\alpha$ such that: + +$$ +\begin{array} { r l } & { | | W ^ { \prime } | | _ { F } ^ { 2 } = | | W | | _ { F } ^ { 2 } , | | H ^ { \prime } | | _ { F } ^ { 2 } = | | H | | _ { F } ^ { 2 } , } \\ & { | | W ^ { \prime } - W | | _ { F } ^ { 2 } + | | H ^ { \prime } - H | | _ { F } ^ { 2 } < \epsilon , \mathcal { L } ( W ^ { \prime } , H ^ { \prime } ) < \mathcal { L } ( W , H ) . } \end{array} +$$ + +Now we prove Theorem 3.3 by some similar strategies as used in proving Theorem 3.1. + +Proof of Theorem 3.3. Again we rewrite the ULPM objective by introducing $s _ { k , i , j } = \boldsymbol { w } _ { k } ^ { \top } \boldsymbol { h } _ { k , i } -$ $\pmb { w } _ { j } ^ { \top } \pmb { h } _ { k , i }$ : + +$$ +\mathcal { L } ( W , H ) = \sum _ { k = 1 } ^ { K } \sum _ { i = 1 } ^ { n } \log ( 1 + \sum _ { j \neq k } \exp ( - s _ { k , i , j } ) ) . +$$ + +In addition, we can find that centralizing $\begin{array} { r } { \frac { 1 } { K } \sum _ { k = 1 } ^ { K } { \pmb w } _ { k } , \forall i \in [ K ] } \end{array}$ , then $s _ { k , i , j } = \underline { { w } } _ { k } ^ { \top } h _ { k , i } - \pmb { w } _ { j } ^ { \top } h _ { k , i } = \tilde { \pmb { w } } _ { k } ^ { \top } \pmb { h } _ { k , i } - \tilde { \pmb { w } } _ { j } ^ { \top } \pmb { h } _ { k , i }$ ${ \pmb w } _ { i }$ does not change the value of $s _ { k , i , j }$ and . Let $\begin{array} { r } { \sum _ { i = 1 } ^ { K } \tilde { \pmb { w } } _ { i } = 0 } \end{array}$ $\tilde { \pmb { w } } _ { i } = \pmb { w } _ { i } -$ First by the strict convexity of $e ^ { x }$ and Jensen Inequality: + +$$ +\begin{array} { r } { \mathcal { L } ( W , H ) \geq \displaystyle \sum _ { k = 1 } ^ { K } \sum _ { i = 1 } ^ { n } \log ( 1 + ( K - 1 ) \exp ( \frac { 1 } { K - 1 } \sum _ { j \neq k } - s _ { k , i , j } ) ) } \\ { = \displaystyle \sum _ { k = 1 } ^ { K } \sum _ { i = 1 } ^ { n } \log ( 1 + ( K - 1 ) \exp ( - \frac { K \tilde { w } _ { k } ^ { \top } h _ { k , i } } { K - 1 } ) ) . } \end{array} +$$ + +Where the last equality is obtained from: + +$$ +\sum _ { j \neq k } s _ { k , i , j } = \sum _ { j \neq k } \tilde { w } _ { k } ^ { \top } h _ { k , i } - \tilde { w } _ { j } ^ { \top } h _ { k , i } = ( K - 1 ) \tilde { w } _ { k } ^ { \top } h _ { k , i } - \sum _ { j \neq k } \tilde { w } _ { j } ^ { \top } h _ { k , i } = K \tilde { w } _ { k } ^ { \top } h _ { k , i } . +$$ + +Now again by the strict convexity of $\log ( 1 + ( K - 1 ) \exp ( - x ) )$ and Jensen inequality, we have: + +$$ +\begin{array} { l } { \displaystyle \mathcal { L } ( W , H ) \geq \sum _ { k = 1 } ^ { K } \displaystyle \sum _ { i = 1 } ^ { n } \log ( 1 + ( K - 1 ) \exp ( - \frac { K \hat { w } _ { k } ^ { \top } h _ { k , i } } { K - 1 } ) ) } \\ { \displaystyle \geq n K \log ( 1 + ( K - 1 ) \exp ( - \frac { 1 } { n ( K - 1 ) } \displaystyle \sum _ { k = 1 } ^ { K } \sum _ { i = 1 } ^ { n } \tilde { w } _ { k } ^ { \top } h _ { k , i } ) ) } \\ { \displaystyle \geq n K \log ( 1 + ( K - 1 ) \exp ( - \frac { 1 } { 2 n ( K - 1 ) } \displaystyle \sum _ { k = 1 } ^ { K } \sum _ { i = 1 } ^ { n } \frac { 1 } { \sqrt { n } } \| \tilde { w } _ { k } \| ^ { 2 } + \sqrt { n } \| h _ { k , i } \| ^ { 2 } ) ) } \\ { \displaystyle \geq n K \log ( 1 + ( K - 1 ) \exp ( - \frac { 1 } { 2 \sqrt { n ( K - 1 ) } } ( \| W \| _ { F } ^ { 2 } + \| H \| _ { F } ^ { 2 } ) ) ) . } \end{array} +$$ + +Where the last inequality holds since $\begin{array} { r } { \| \pmb { W } \| _ { F } ^ { 2 } = \sum _ { k = 1 } ^ { K } \| \pmb { w } _ { k } \| ^ { 2 } \geq \sum _ { k = 1 } ^ { K } \| \pmb { w } _ { k } \| ^ { 2 } - \frac { 1 } { K } \| \sum _ { k = 1 } ^ { K } \pmb { w } _ { k } \| ^ { 2 } = } \end{array}$ $\textstyle \sum _ { k = 1 } ^ { K } | | \tilde { \pmb { w } } _ { k } | | ^ { 2 }$ . + +When all of the above inequality reduce to equality, we must have: + +$\begin{array} { r } { \sum _ { i = 1 } ^ { K } \pmb { w } _ { i } = 0 , \tilde { \pmb { w } } _ { i } = \pmb { w } _ { i } } \end{array}$ + +2. $\pmb { w } _ { k } = \sqrt { n } \pmb { h } _ { k , i } , \forall i \in [ n ]$ (the third inequality in (C.2)) + +3. $\| \pmb { w } _ { k } \| = \| \pmb { w } _ { k ^ { \prime } } \| , \| \pmb { h } _ { k , i } \| = \| \pmb { h } _ { k ^ { \prime } , j } \| , \forall k , k ^ { \prime } \in [ K ] , i , j \in [ n ]$ (the second inequality in (C.2)) + +4. $\begin{array} { r } { s _ { k , i , j } = w _ { k } ^ { \top } h _ { k , i } - w _ { j } ^ { \top } h _ { k , i } = \frac { K } { K - 1 } w _ { k } ^ { \top } h _ { k , i } , \forall k , j \in [ K ] , i \in [ n ] } \end{array}$ (the first inequality in (C.1)) + +These four conditions are exactly equivalent to neural collapse conditions and $\| \boldsymbol { W } \| _ { F } = \| \boldsymbol { H } \| _ { F }$ + +The global optimality is not enough to illustrate how does gradient flow converges to neural collapse since there may exist some bad local minimum. We will provide the following second-order analysis to eliminate spurious local minimum. First, define the cross-entropy loss on a matrix $\boldsymbol { Z } \in \mathbb { R } ^ { K \times \mathbf { \breve { n } } K }$ : + +$$ +L ( Z ) = \sum _ { k = 1 } ^ { K } \sum _ { i = 1 } ^ { n } - \log \frac { e ^ { z _ { k , i , j } } } { \sum _ { l = 1 } ^ { K } e ^ { z _ { k , i , l } } } , +$$ + +where $z _ { k , i , j }$ denote the $j$ -th row and $[ ( k - 1 ) K + i ]$ -th column elements of $z$ . Then we have $\mathcal { L } ( W , H ) = L ( W H )$ . Now compute the gradient of $L ( Z )$ to each element: + +$$ +\begin{array} { r l } & { \frac { \partial L ( Z ) } { \partial z _ { k , i , k } } = - 1 + \frac { z _ { k , i , k } } { \sum _ { l = 1 } ^ { K } e ^ { z _ { k , i , l } } } } \\ & { \frac { \partial L ( Z ) } { \partial z _ { k , i , j } } = \frac { z _ { k , i , j } } { \sum _ { l = 1 } ^ { K } e ^ { z _ { k , i , l } } } , \forall k \neq j . } \end{array} +$$ + +If $u \in \mathbb { R } ^ { K }$ satisfies $u ^ { \top } \nabla L ( Z ) = 0$ , denote $u _ { p }$ as the maximum element of $u$ , then we have: + +$$ +\begin{array} { r l r } { { 0 = u _ { p } \frac { \partial L ( \pmb { Z } ) } { \partial z _ { p , i , p } } + \sum _ { q \neq p } u _ { q } \frac { \partial L ( \pmb { Z } ) } { \partial z _ { p , i , q } } = u _ { p } ( - 1 + \frac { z _ { p , i , p } } { \sum _ { l = 1 } ^ { K } e ^ { z _ { p , i , l } } } ) + \sum _ { q \neq p } u _ { q } \frac { z _ { p , i , q } } { \sum _ { l = 1 } ^ { K } e ^ { z _ { p , i , l } } } } } \\ & { } & { \qquad = - \sum _ { q \neq p } ( u _ { p } - u _ { q } ) \frac { z _ { p , i , q } } { \sum _ { l = 1 } ^ { K } e ^ { z _ { p , i , l } } } \leq 0 . } \end{array} +$$ + +Where the last inequality holds if and only if $u _ { q } = u _ { p } , \forall q \in [ K ]$ . Which indicates that the rank of $\nabla L ( Z )$ is $K - 1$ and $\boldsymbol { u } ^ { \intercal } \boldsymbol { \nabla } L ( Z ) = 0 \Leftrightarrow \boldsymbol { u } = \mathbf { 1 }$ . Now we are ready to prove Theorem 3.4 in the main body. + +Proof of Theorem 3.4. First compute the gradient of ULPM objective (B), by the chain rule we have: + +$$ +\nabla _ { W } \mathcal { L } ( W , H ) = \nabla L ( W H ) H ^ { \top } , \nabla _ { H } \mathcal { L } ( W , H ) = W ^ { \top } \nabla L ( W H ) . +$$ + +If there exist a vector $( \Delta W , \Delta H ) \quad \in \quad { \mathcal { T } } ( W , H )$ such that $\langle \nabla _ { W } \mathcal { L } ( W , H ) , \Delta W \rangle \ +$ $\langle \nabla _ { H } \mathcal { L } ( W , H ) , \Delta H \rangle \quad \mathrm { ~ \neq ~ \Gamma ~ } \mathrm { ~ 0 ~ }$ , moreover we can assume $\begin{array} { r l } { \langle \nabla _ { W } \mathcal { L } ( W , H ) , \Delta W \rangle } & { { } + } \end{array}$ $\langle \nabla _ { H } \mathcal { L } ( W , H ) , \Delta H \rangle < 0$ since we can take the negative direction if the formula is greater than zero, then by Taylor expansion: + +$\begin{array} { r } { \dot { \boldsymbol { \Sigma } } ( \boldsymbol { W } + \delta \Delta \boldsymbol { W } , \boldsymbol { H } + \delta \Delta \boldsymbol { H } ) = \mathcal { L } ( \boldsymbol { W } , \boldsymbol { H } ) + \delta \langle \nabla _ { \boldsymbol { W } } \mathcal { L } ( \boldsymbol { W } , \boldsymbol { H } ) , \Delta \boldsymbol { W } \rangle + \delta \langle \nabla _ { \boldsymbol { H } } \mathcal { L } ( \boldsymbol { W } , \boldsymbol { H } ) , \Delta \boldsymbol { H } \rangle + \mathcal { L } ( \nabla _ { \boldsymbol { H } } \mathcal { L } ( \boldsymbol { W } , \boldsymbol { H } ) ) , } \end{array}$ (δ2), we know that $( \Delta W , \Delta H )$ satisfies our requirement. + +Now let’s discuss the case when: + +$$ +\langle \nabla _ { W } \mathcal { L } ( W , H ) , \Delta W \rangle + \langle \nabla _ { H } \mathcal { L } ( W , H ) , \Delta H \rangle = 0 , \forall ( \Delta W , \Delta H ) \in \mathcal { T } ( W , H ) , +$$ + +by definition of $\mathcal { T } ( W , H )$ , it contains all vectors that are orthogonal to $( W , H )$ , so $( \dot { \nabla } _ { W } \mathcal { L } ( W , H ) , \nabla _ { H } \dot { \mathcal { L } } ( W , H ) )$ is parallel to $( W , H )$ , that is, there exist $\lambda$ such that: + +$$ +\nabla L ( W H ) H ^ { \top } = \lambda W , W ^ { \top } \nabla L ( W H ) = \lambda H . +$$ + +If there does not exist $( \Delta W , \Delta H )$ satisfying the requirement, we know that for any feasible curve $\phi ( t ) = ( W ( t ) , H ( t ) )$ with $\phi ( 0 ) = \left( W , H \right)$ on the sphere $\mathcal { S } = \{ ( W ^ { \prime } , H ^ { \prime } ) : \| W ^ { \prime } \| _ { F } ^ { 2 } + \| H ^ { \prime } \| _ { F } ^ { 2 } =$ $\| \dot { \pmb { W } } \| _ { F } ^ { 2 } + \| \dot { \pmb { H } } \| _ { F } ^ { 2 } \}$ , $t = 0$ admits the local minimum of ${ \mathcal { L } } ( \phi ( t ) )$ and thus: + +$$ +0 \leq \frac { d ^ { 2 } } { d t ^ { 2 } } \mathscr { L } ( \phi ( t ) ) | _ { t = 0 } = \phi ^ { \prime } ( 0 ) ^ { T } \nabla ^ { 2 } \mathscr { L } ( W , H ) \phi ^ { \prime } ( 0 ) + \nabla \mathscr { L } ( W , H ) \phi ^ { \prime \prime } ( 0 ) . +$$ + +On the other hand, since the curve lies on the sphere $s$ , denote $h ( W , H ) = \| W \| _ { F } ^ { 2 } + \| H \| _ { F } ^ { 2 }$ , then $h ( \phi ( t ) )$ must stay as a constant, take twice derivative we have: + +$$ +0 = \frac { d ^ { 2 } } { d t ^ { 2 } } h ( \phi ( t ) ) | _ { t = 0 } = \phi ^ { \prime } ( 0 ) ^ { T } \nabla ^ { 2 } h ( W , H ) \phi ^ { \prime } ( 0 ) + \nabla h ( W , H ) \phi ^ { \prime \prime } ( 0 ) . +$$ + +Then sum these two conditions together, we have: + +$$ +\mathrm { ~ \xi ~ } \leq \frac { d ^ { 2 } } { d t ^ { 2 } } ( \mathcal { L } ( \phi ( t ) ) + \frac { | \lambda | } { 2 } h ( \phi ( t ) ) ) | _ { t = 0 } = \phi ^ { \prime } ( 0 ) ^ { T } \nabla ^ { 2 } ( \mathcal { L } + \frac { | \lambda | } { 2 } h ) ( W , H ) \phi ^ { \prime } ( 0 ) + \nabla ( \mathcal { L } + \frac { | \lambda | } { 2 } h ) ( W , H ) ) +$$ + +By equation (C.4) we know that $\nabla ( \mathcal { L } + \frac { | \lambda | } { 2 } h ) ( W , H ) = 0$ Note that $\phi ^ { \prime } ( 0 ) \in \mathcal { T } ( W , H )$ since the curve lies on $s$ and for any $( \Delta W , \Delta H ) \in { \mathcal { T } } ( W , H )$ we can construct a curve $\phi ( t )$ such that $\phi ^ { \prime } ( 0 ) = ( \Delta W , \Delta H )$ . Then (C.7) indicates that $\forall ( \Delta W , \Delta H ) \in { \mathcal { T } } ( W , H )$ we have: + +$$ +\begin{array} { r l } & { 0 \leq ( \Delta W , \Delta H ) ^ { \top } \nabla ^ { 2 } \mathcal { L } ( W , H ) ( \Delta W , \Delta H ) + \frac { \left| \lambda \right| } { 2 } ( \Delta W , \Delta H ) ^ { \top } \nabla ^ { 2 } h ( W , H ) ( \Delta W , \Delta H ) } \\ & { \quad = ( \Delta W , \Delta H ) ^ { \top } \nabla ^ { 2 } \mathcal { L } ( W , H ) ( \Delta W , \Delta H ) + | \lambda | ( \| \Delta W \| _ { F } ^ { 2 } + \| \Delta H \| _ { F } ^ { 2 } ) . } \end{array} +$$ + +When $\lambda ~ = ~ 0$ , by equation (C.3) we know that $\| \nabla L ( W H ) \| _ { 2 } ~ > ~ 0$ , which gives us $| \lambda | \ \leq$ $\lVert \nabla L ( W H ) \rVert _ { 2 }$ When $\lambda \neq 0$ , combine the two equations in (C.4) we know: + +$$ +\lambda W ^ { \top } W = W ^ { \top } \nabla L ( W H ) H ^ { \top } = \lambda H H ^ { \top } \Rightarrow W ^ { \top } W = H H ^ { \top } , +$$ + +which further implies: + +$$ +\lvert | W \rvert | _ { F } = \lvert | H \rvert | _ { F } , \quad \lvert | W \rvert | _ { 2 } = \lvert | H \rvert | _ { 2 } . +$$ + +Thus we also have (Note that when $W = H = 0$ we can take $\lambda$ to be zero): + +$$ +\begin{array} { r l } & { \nabla L ( W H ) H ^ { \top } = \lambda W \Rightarrow | \lambda | | W | | _ { 2 } \leq | | \nabla L ( W H ) | | _ { 2 } | | H | | _ { 2 } } \\ & { \qquad \Rightarrow | \lambda | \leq | | \nabla L ( W H ) | | _ { 2 } . } \end{array} +$$ + +Now when $| \lambda | < | | \nabla L ( W H ) | | _ { 2 }$ , we can show that it will contradict with (C.8): We have shown that the rank of $\nabla L ( Z )$ is $K - 1$ , so by (C.4) and (C.9) there exist a vector $a$ such that $\pmb { W } a = \pmb { H } ^ { \top } a = 0$ + +let $u$ and $v$ are the left and right singular vectors corresponding to the largest singular value of $\nabla L ( W H )$ , construct $\Delta W = u a ^ { \top }$ , $\bar { \Delta { \cal H } } = - a v ^ { \top }$ , then $( \Delta W , \Delta H ) \in { \mathcal { T } } ( W , H )$ and: + +$$ +\begin{array} { r l } & { \quad ( \Delta W , \Delta H ) ^ { \top } \nabla ^ { 2 } \mathcal { L } ( W , H ) ( \Delta W , \Delta H ) - \lambda ( \| \Delta W \| _ { F } ^ { 2 } + \| \Delta H \| _ { F } ^ { 2 } ) } \\ & { = ( W \Delta H + \Delta W H ) \nabla ^ { 2 } L \left( W H \right) \left( W \Delta H + \Delta W H \right) + 2 \langle \nabla L ( W H ) , \Delta W \Delta H \rangle + | \lambda | ( \| \Delta W \| _ { F } ^ { 2 } ) } \\ & { \leq 2 | | a | | _ { 2 } ^ { 2 } ( | \lambda | - u ^ { \top } \nabla L ( W H ) v ) < 0 . } \end{array} +$$ + +Then it only remains to analyze the $| \lambda | = | | \nabla L ( W H ) | | _ { 2 }$ cases, construct another convex optimization problem: + +$$ +\operatorname* { m i n } _ { z } L ( Z ) + | \lambda | | | Z | | _ { * } , +$$ + +suppose $z$ has SVD $\pmb { Z } = \pmb { U } \pmb { \Sigma } \pmb { V } ^ { \top }$ , as we know that the subgradient of $| | Z | | _ { * }$ can be written as (see Watson (1992) for a proof): + +$$ +\begin{array} { r } { \partial \| Z \| _ { * } = \left\{ U V ^ { \top } + W , W \in \mathbb { R } ^ { K \times n K } \vert U ^ { \top } W = \mathbf { 0 } , W V = \mathbf { 0 } , \| W \| _ { 2 } \leq 1 \right\} . } \end{array} +$$ + +On the other hand, we know that: + +$$ +\begin{array} { r l } & { H ^ { \top } H H ^ { \top } H = H ^ { \top } W ^ { \top } W H = V \Sigma ^ { 2 } V ^ { \top } } \\ & { W W ^ { \top } W W ^ { \top } = W H H ^ { \top } W ^ { \top } = U \Sigma ^ { 2 } U ^ { \top } , } \end{array} +$$ + +which indicates that $\pmb { H } ^ { \top } \pmb { H } = \pmb { V } \pmb { \Sigma } \pmb { V } ^ { \top }$ and $W W ^ { \top } = U \Sigma U ^ { \top }$ . Combine them with (C.4) we have: + +$$ +\begin{array} { r l } & { \nabla L ( W H ) H ^ { \top } H = \lambda W H \Leftrightarrow \nabla L ( W H ) V \Sigma V ^ { \top } = \lambda U \Sigma V ^ { \top } } \\ & { \qquad \Leftrightarrow \nabla L ( W H ) V = \lambda U } \\ & { W W ^ { \top } \nabla L ( W H ) = \lambda W H \Leftrightarrow U \Sigma U ^ { \top } \nabla L ( W H ) = \lambda U \Sigma V ^ { \top } } \\ & { \qquad \Leftrightarrow U ^ { \top } \nabla L ( W H ) = \lambda V ^ { \top } . } \end{array} +$$ + +Note that $| \lambda | = | | \nabla L ( W H ) | | _ { 2 }$ , then by (C.11) we know that $- \nabla L ( W H ) \in | \lambda | \partial \| W H \| _ { * }$ . Then by the strict convexity of (C.10) we know $W H$ is the global minimum of it. In addition, we have $\| \mathbf { \dot { W } } \| _ { F } ^ { 2 } + \| \mathbf { H } \| _ { F } ^ { 2 } = 2 \mathbf { \dot { t } } \pmb { \Sigma } ^ { 2 } \mathbf { \dot { \tau } } ) = 2 \| \mathbf { W } \pmb { H } \| _ { \ast }$ . In addition, previous works (Haeffele & Vidal, 2015) have shown that: + +$$ +\| Z \| _ { * } = \operatorname* { m i n } _ { Z = W H } \frac { 1 } { 2 } \left( \| W \| _ { F } ^ { 2 } + \| H \| _ { F } ^ { 2 } \right) , +$$ + +which is equivalent to: + +$$ +\| W H \| _ { * } \leq \frac { 1 } { 2 } ( \| W \| _ { F } ^ { 2 } + \| H \| _ { F } ^ { 2 } ) . +$$ + +Now for any $( W ^ { \prime } , H ^ { \prime } )$ , we know that: + +$$ +\begin{array} { r l r } { { \mathcal { L } ( W , H ) + \frac { | \lambda | } { 2 } ( \| W \| _ { F } ^ { 2 } + \| H \| _ { F } ^ { 2 } ) = L ( W H ) + | \lambda | \| W H \| _ { * } \le L ( W ^ { \prime } H ^ { \prime } ) + | \lambda | \| W ^ { \prime } H ^ { \prime } \| _ { * } } } \\ & { } & { \le \mathcal { L } ( W ^ { \prime } , H ^ { \prime } ) + \frac { | \lambda | } { 2 } ( \| W ^ { \prime } \| _ { F } ^ { 2 } + \| H ^ { \prime } \| _ { F } ^ { 2 } ) , ~ } \end{array} +$$ + +which indicates $( W , H )$ must attain global minimum of the following optimization problem: + +$$ +\operatorname* { m i n } _ { W , H } \mathcal { L } ( W , H ) + \frac { | \lambda | } { 2 } ( \| W \| _ { F } ^ { 2 } + \| H \| _ { F } ^ { 2 } ) . +$$ + +If $( W , H )$ does not satisfy neural collapse conditions, by the optimality of neural collapse solution (Theorem 3.3) we know there exists another point $( W ^ { \prime } , H ^ { \prime } )$ such that $\mathcal { L } ( W ^ { \prime } , H ^ { \prime } ) < \mathcal { L } ( W , H )$ and $\lVert \boldsymbol { W } \rVert _ { F } ^ { 2 } + \lVert \boldsymbol { H } \rVert _ { F } ^ { 2 } = \lVert \boldsymbol { W } ^ { \prime } \rVert _ { F } ^ { 2 } + \lVert \boldsymbol { H } ^ { \prime } \rVert _ { F } ^ { 2 }$ thus: + +$$ +\mathcal { L } ( W , H ) + \frac { | \lambda | } { 2 } ( \| W \| _ { F } ^ { 2 } + \| H \| _ { F } ^ { 2 } ) > \mathcal { L } ( W ^ { \prime } , H ^ { \prime } ) + \frac { | \lambda | } { 2 } ( \| W ^ { \prime } \| _ { F } ^ { 2 } + \| H ^ { \prime } \| _ { F } ^ { 2 } ) , +$$ + +which contradicts with the global optimality of $( W , H )$ , thus $( W , H )$ must satisfy all of the neural collapse conditions and we finish the proof. □ + +# D ADDITIONAL EMPIRICAL RESULTS + +Gradient Descent on the ULPM Objective. We conduct experiments on the ULPM objective (2.3) to support the results of convergence toward neural collapse in our theories. We set $N = 1 0$ , $K = 5$ , and $d = 2 0$ , and used gradient descent with a learning rate of 5 to run $1 0 ^ { 5 }$ epochs. We characterize the dynamics of the training procedure in Figure 2 based on four aspects: (1) Relative variation of the centered class-mean feature norms (i.e., $\mathrm { S t d } ( \| \bar { \boldsymbol { h } } _ { k } - \bar { \boldsymbol { h } } \| ) / \mathrm { A v g } ( \| \bar { \boldsymbol { h } } _ { k } ^ { * } - \bar { \boldsymbol { h } } \| ) )$ and the variation of the classifier’s norms (i.e., $\operatorname { S t d } ( \| \bar { \pmb { w } } _ { k } \| ) / \operatorname { A v g } ( \| \bar { \pmb { w } } _ { k } \| ) )$ ). (2) Within-class variation of the last layer features (i.e., $\mathrm { A v g } ( \| h _ { k , i } - h _ { k } \| ) / \mathrm { A v g } ( \| h _ { k , i } - \bar { h } \| ) )$ . (3) The cosines between pairs of last layer features (i.e., $\mathrm { A v g } ( | \cos ( \bar { h } _ { k } , \bar { h } _ { k ^ { \prime } } ) + 1 / ( K - 1 ) | ) \rangle$ ) and that of the classifiers (i.e., $\mathrm { A v g } ( | \cos ( \bar { w } _ { k } , \bar { w } _ { k ^ { \prime } } ) + 1 / ( K - 1 ) | ) ;$ ). (4) The distance between the normalized centered classifier and the normalized last layer feature (i.e., $\mathrm { A v g } ( | ( \bar { h } _ { k } - \bar { h } ) / \| \bar { h } _ { k } - \bar { h } \| - \bar { w } _ { k } / \| \bar { w } _ { k } \| | ) )$ . Empirically, we observe that all four quantities decrease at approximately the rate $O ( 1 / ( \log ( t ) ) )$ . + +![](images/2b4f0f56e01c4a175de8ef52f5300ac0b4f043c8c9337f1916765e10840ba949.jpg) +Figure 2: Training dynamics in ULPM. The $x$ -axis in the figures is set to have $\log ( \log ( t ) )$ scales, and the $y$ -axis in the figures are set to have log scales. (a) The dynamics of the variation of the centered class-mean features’ norms (shown in blue) and the variation of the classifier’s norms (shown in red). We observe that the logarithm of both terms decreases at a rate $O ( 1 / ( \log ( t ) ) )$ . (b) Dynamics of within-class variation of the last layer features. The logarithm of the variation converges at approximately the rate $O ( 1 / \log ( t ) ) )$ ). (c) The dynamics of the cosines between pairs of last layer features (shown in blue) and those of the classifiers (shown in red). The logarithm of both terms converge approximately at rate $O ( 1 / \log ( t ) ) )$ . (d) Dynamics of the distance between the normalized centered classifier and normalized last layer feature. The logarithm of the quantity converges at approximately the rate $O ( 1 / \log ( t ) ) )$ to the point of self-duality. + +Details of Realistic Training. In the real data experiments, we trained the VGG-13 (Simonyan & Zisserman, 2014) and ResNet18 (He et al., 2016) on MNIST (LeCun et al., 1998), KMNIST (Clanuwat et al., 2018), FashionMNIST (Xiao et al., 2017) and CIFAR-10 datasets (Krizhevsky et al., 2009) without weight decay, and with a learning rate of 0.01, momentum of 0.3, and batch size of 128. The metrics are defined similarly to the ULPM case and the experiment results are reported in Figure 1, 3, 4, 5, 6, 7, and 8. All experiments were run in Python (version 3.6.9) on Google Colab. It should be mentioned that we can observe that the variation of classifier norm stays at a low value and do not decrease in some settings (e.g., Figure 7a and Figure 8a), this phenomenon is also found in Figure 2 of (Papyan et al., 2020), which might attribute to the network architecture (e.g., batch normalization) and characteristics of real-world datasets. Overall, we can find that neural collapse occurs for various network architectures and datasets under an unconstrained setting, which provides sound support for our theory. + +![](images/3a4eb68a1a3fa70939f95f7b5a628ecab0c722b6176a0d624cd2f29826b3e41a.jpg) +Figure 3: Experiments on real datasets without weight decay. We trained a VGG13 on CIFAR10 dataset. The $x$ -axis in the figures are set to have $\log ( \log ( t ) )$ scales and the $_ y$ -axis in the figures are set to have log scales. + +![](images/b0e707c1b2660f180f86896baa651dd5d8e83c698ad85b577337c5553b2ed8fe.jpg) +Figure 4: Experiments on real datasets without weight decay. We trained a VGG13 on the MNIST dataset. The $_ x$ -axis in the figures are set to have $\log ( \log ( t ) )$ scales and the $_ y$ -axis in the figures are set to have log scales. + +![](images/68acbba97e1b5bc18599140b46209dc003b2745f5c4499e46e4a8c9f9852fc5c.jpg) +Figure 5: Experiments on real datasets without weight decay. We trained a VGG18 on the KMNIST dataset. The $_ x$ -axis in the figures are set to have $\log ( \log ( t ) )$ scales and the $y$ -axis in the figures are set to have log scales. + +![](images/f59e8cb15adcbd9d02f32f593fa311e883715020b43aa5dd4bfda4f92ff065db.jpg) +Figure 6: Experiments on real datasets without weight decay. We trained a ResNet18 on the KMNIST dataset. The $_ x$ -axis in the figures are set to have $\log ( \log ( t ) )$ scales and the $y$ -axis in the figures are set to have log scales. + +![](images/58aa137f0c601f50ae82911c120896254865f9835c5fddb31bbb04796654ffaf.jpg) +Figure 7: Experiments on real datasets without weight decay. We trained a VGG13 on the Fashion-MNIST dataset. The $x$ -axis in the figures are set to have $\log ( \log ( t ) )$ scales and the $y$ -axis in the figures are set to have $\log$ scales. + +![](images/075ce356aa5a2e2d763615909f6abbbc457a53967bf77980d718f5def97c407f.jpg) +Figure 8: Experiments on real datasets without weight decay. We trained a ResNet18 on the Fashion-MNIST dataset. The $x$ -axis in the figures are set to have $\log ( \log ( t ) )$ scales and the $y$ -axis in the figures are set to have log scales. + +# E LIMITATION AND FUTURE DIRECTIONS + +Currently, our analysis is still limited in the terminal phase of training and only studies the training behavior after data is perfectly separated. Such assumption is necessary for all implicit regularization analysis (Lyu & Li, 2019; Ji et al., 2020; Nacson et al., 2019a) under a nonlinear setting, and how to fully characterize the early time training dynamics is still an open problem. Moreover, we have provided a loss landscape analysis in the paper showing that there is no spurious minimum in the tangent space. To guarantee the training dynamics do not get stuck in saddle points and converge to neural collapse solution, we need to introduce randomness in the training dynamics (e.g. use stochastic gradient descent (Ge et al., 2015)), otherwise simple gradient flow may get stuck in saddle points as we have shown in Example 3.1. How to characterize the training dynamics of stochastic gradient descent in the nonlinear setting is also an open problem. It is an interesting direction to further build a complete characterization of convergence to neural collapse solutions by addressing the early time training dynamics and studying the stochastic gradient descent. \ No newline at end of file diff --git a/md/dev/WZH7099tgfM/WZH7099tgfM.md b/md/dev/WZH7099tgfM/WZH7099tgfM.md new file mode 100644 index 0000000000000000000000000000000000000000..d3946d9814368e8c698747daf5f471c4099597ac --- /dev/null +++ b/md/dev/WZH7099tgfM/WZH7099tgfM.md @@ -0,0 +1,2038 @@ +# LEAST-TO-MOST PROMPTING ENABLES COMPLEXREASONING IN LARGE LANGUAGE MODELS + +Denny Zhou∗ Nathanael Scharli Le Hou Jason Wei Nathan Scales Xuezhi Wang ¨ Dale Schuurmans Claire Cui Olivier Bousquet Quoc Le Ed Chi + +Google Research, Brain Team + +# ABSTRACT + +Chain-of-thought prompting has demonstrated remarkable performance on various natural language reasoning tasks. However, it tends to perform poorly on tasks which requires solving problems harder than the exemplars shown in the prompts. To overcome this challenge of easy-to-hard generalization, we propose a novel prompting strategy, least-to-most prompting. The key idea in this strategy is to break down a complex problem into a series of simpler subproblems and then solve them in sequence. Solving each subproblem is facilitated by the answers to previously solved subproblems. Our experimental results on tasks related to symbolic manipulation, compositional generalization, and math reasoning reveal that least-to-most prompting is capable of generalizing to more difficult problems than those seen in the prompts. A notable finding is that when the GPT-3 code-davinci-002 model is used with least-to-most prompting, it can solve the compositional generalization benchmark SCAN in any split (including length split) with an accuracy of at least $9 9 \%$ using just 14 exemplars, compared to only $16 \%$ accuracy with chain-of-thought prompting. This is particularly noteworthy because neural-symbolic models in the literature that specialize in solving SCAN are trained on the entire training set containing over 15,000 examples. We have included prompts for all the tasks in the Appendix. + +# 1 INTRODUCTION + +Despite the great success of deep learning in the past decade, there still remain huge differences between human intelligence and machine learning: (1) Given a new task, humans usually can learn to accomplish it from only a few demonstration examples, while machine learning requires a large amount of labeled data for model training; (2) Humans can clearly explain the underlying rationale for their predictions or decisions, while machine learning is essentially a black box; (3) Humans can solve problems more difficult than any they have seen before, while for machine learning, examples in training and testing are typically at the same level of difficulty. + +The recently proposed chain-of-thought prompting approach (Wei et al., 2022; Chowdhery et al., 2022) has taken a significant step for narrowing the gap between human intelligence and machine intelligence. It combines the idea of natural language rationales (Ling et al., 2017; Cobbe et al., 2021) with few-shot prompting (Brown et al., 2020). When further integrated with self-consistency decoding (Wang et al., 2022b) rather than using the typical greedy decoding, few-shot chain-of-thought prompting largely outperforms the state-of-the-art results in the literature on many challenging natural language processing tasks obtained from specially designed neural models trained with hundreds of times more annotated examples, while being fully interpretable. + +However, chain-of-thought prompting has a key limitation—it often performs poorly on tasks that require generalization of solving problems harder than the demonstration examples, such as compositional generalization (Lake & Baroni, 2018; Keysers et al., 2020). To tackle such easy-to-hard generalization issues, we propose least-to-most prompting. It consists of two stages: first decomposing a complex problem into a list of easier subproblems, and then sequentially solving these subproblems, whereby solving a given subproblem is facilitated by the answers to previously solved subproblems. Both stages are implemented by few-shot prompting, so that there is no training or finetuning in either stage. An example usage of least-to-most prompting is illustrated in Figure 1. + +The term least-to-most prompting is borrowed from educational psychology (Libby et al., 2008), where it is used to denote the technique of using a progressive sequence of prompts to help a student to learn a new skill. Here we apply this technique for teaching humans to teach language models. Empirical results on symbolic manipulation, compositional generalization, and math reasoning show that least-to-most prompting can indeed generalize to problems harder than those demonstrated. + +![](images/9a4237d2b9911a0d4a21385438f44eeac4a1917d3b364b1144af18280fa2a7c2.jpg) +Stage 1: Decompose Question into Subquestions + +# Stage 2: Sequentially Solve Subquestions + +![](images/c8b655bd8857e06fb1c31a1a5ac377dac55edb39cbf112a49996c1cb65ad7a71.jpg) +Figure 1: Least-to-most prompting solving a math word problem in two stages: (1) query the language model to decompose the problem into subproblems; (2) query the language model to sequentially solve the subproblems. The answer to the second subproblem is built on the answer to the first subproblem. The demonstration examples for each stage’s prompt are omitted in this illustration. + +# 2 LEAST-TO-MOST PROMPTING + +Least-to-most prompting teaches language models how to solve a complex problem by decomposing it to a series of simpler subproblems. It consists of two sequential stages: + +1. Decomposition. The prompt in this stage contains constant examples that demonstrate the decomposition, followed by the specific question to be decomposed. 2. Subproblem solving. The prompt in this stage consists of three parts: (1) constant examples demonstrating how subproblems are solved; (2) a potentially empty list of previously answered subquestions and generated solutions, and (3) the question to be answered next. + +In the example shown in Figure 1, the language model is first asked to decompose the original problem into subproblems. The prompt that is passed to the model consists of examples that illustrate how to decompose complex problems (which are not shown in the figure), followed by the specific problem to be decomposed (as shown in the figure). The language model figures out that the original problem can be solved via solving an intermediate problem “How long does each trip take?”. + +In the next phase, we ask the language model to sequentially solve the subproblems from the problem decomposition stage. The original problem is appended as the final subproblem. The solving starts from passing to the language model a prompt that consists of examples that illustrate how problems are solved (not shown in the figure), followed by the first subproblem “How long does each trip take?”. We then take the answer generated by the language model (“... each trip takes 5 minutes.”) and construct the next prompt by appending the generated answer to the previous prompt, followed by the next subproblem, which happens to be the original problem in this example. The new prompt is then passed back to the language model, which returns the final answer. + +Least-to-most prompting can be combined with other prompting techniques like chain-of-thought (Wei et al., 2022) and self-consistency (Wang et al., 2022b), but does not need to be. Also, for some tasks, the two stages in least-to-most prompting can be merged to form a single-pass prompt. + +# 3 RESULTS + +We present least-to-most prompting results for symbolic manipulation, compositional generalization, and math reasoning tasks, and compare it with chain-of-thought prompting. + +# 3.1 SYMBOLIC MANIPULATION + +We take the last-letter-concatenation task (Wei et al., 2022). In this task, each input is a list of words, and the corresponding output is the concatenation of the last letters of the words in the list. For example, “thinking, machine” outputs “ge”, since the last letter of “thinking” is $" \mathrm { g } ^ { \prime \prime }$ and the last letter of “machine” is “e”. Chain-of-thought prompting does a perfect job when the testing lists have the same length as the lists in the prompt exemplars. However, it performs poorly when the testing lists are much longer than the lists in the prompt exemplars. We show that least-to-most prompting overcomes this limitation and significantly outperforms chain-of-thought prompting on length generalization. + +Q: “think, machine, learning” A: “think”, “think, machine”, “think, machine, learning” + +Table 1: Least-to-most prompt context (decomposition) for the last-letter-concatenation task. It can decompose arbitrary long lists into sequential sublists with an accuracy of $100 \%$ . + +Q: “think, machine” +A: The last letter of “think” is “k”. The last letter of “machine” is “e”. Concatenating “k”, “e” leads to “ke”. So, “think, machine” outputs “ke”. Q: “think, machine, learning” +A: “think, machine” outputs “ke”. The last letter of “learning” is “g”. Concatenating “ke”, “g” leads to “keg”. So, “think, machine, learning” outputs “keg”. + +Least-to-most prompting. The least-to-most prompt contexts for the last-letter-concatenation task are shown in Tables 1 and 2. The exemplar in Table 1 demonstrates how to decompose a list into a sequence of sublists. The exemplar in Table 2 demonstrates how to map an input to the desired output. Given a new list, we first append it to the exemplar in Table 1 to construct the decomposition prompt, which is sent to the language model to obtain the list’s decomposition. Then, we construct for each sublist $S$ a solution prompt, which consists of the exemplars in Table 2, followed by the previous sublist/response pairs (if any), followed by $S$ . We sequentially issue these prompts to the language model and use the last response as the final solution. + +It is worth a closer look at the exemplars in Table 2. Essentially, they teach language models how to build answers to new problems using the answers to previously solved problems: (1) the list in the second exemplar (“think, machine, learning”) is an extension of the list in the first exemplar (“think, machine”) rather than an entirely independent one; (2) the response to “think, machine, learning” is built on the output of “think, machine” by starting with a sentence saying that “think, machine” outputs “ke”. The two exemplars together illustrate a base case and a recursive step. + +Chain-of-thought prompting. The chain-of-thought prompt context for the last-letterconcatenation task is listed in Table 3. It uses the same lists as the least-to-most prompt in Table 2. The only difference is that, in the chain-of-thought prompt, the response to the second list (“think, machine, learning”) is built from scratch, instead of using the output of the first list (“think, machine”). + +Q: “think, machine” +A: The last letter of “think” is “k”. The last letter of “machine” is “e”. Concatenating “k”, “e” leads to “ke”. So, “think, machine” outputs “ke”. + +Q: “think, machine, learning” A: The last letter of “think” is “k”. The last letter of “machine” is “e”. The last letter of “learning” is “g”. Concatenating “k”, “e”, “g” leads to “keg”. So, “think, machine, learning” outputs “keg”. + +Table 3: Chain-of-thought prompt context for the last-letter-concatenation task. Unlike the leastto-most prompt in Table 2, the exemplars in the chain-of-thought prompt are independent of each other. + +We compare least-to-most prompting (Table 1 & 2) with chain-of-thought prompting (Table 3) and the standard few-shot prompting. The prompt for the standard few-shot prompting is constructed by removing the intermediate explanations in the chain-of-thought prompt. That is, it just consists of these two exemplars: (1) “think, machine” outputs “ke”; and (2) “think, machine, learning” outputs “keg”. We do not consider a training or finetuning baseline because a machine learning model based on two examples would generalize very poorly. + +Results. We randomly sample words in Wiktionary1 to construct testing lists with lengths varying from 4 to 12. For each given length, 500 lists are constructed. The accuracies of different methods with code-davinci-002 in GPT-3 are shown in Table 4. Standard prompting completely fails all test cases with an accuracy of 0. Chain-of-thought prompting significantly boosts the performance over standard prompting, but it still falls well behind least-to-most prompting, particularly when the lists are long. Moreover, the performance of chain-of-thought prompting drops much faster than least-to-most prompting as the length increases. + +
L=4L=6L=8L=10L=12
Standard prompting0.00.00.00.00.0
Chain-of-Thought84.269.250.239.831.8
Least-to-Most94.088.483.076.474.0
+ +Table 4: Accuracies of different prompting methods on the last-letter-concatenation task. The length of testing lists increases from 4 to 12. + +In Appendices 7.2 and 7.3, we present additional experiments with different chain-of-thought prompts and different language models. Note that in contrast to least-to-most prompting, the exemplars in a chain-of-thought prompt can be independent of each other. For the last-letter concatenation task, this means that we do not need to present exemplars that are sublists of other exemplars. In fact, a chain-of-thought prompt with independent lists tends to outperform one with dependent lists, as the former conveys more information. Furthermore, we can enhance chain-of-thought prompting by incorporating additional exemplars. This seems to be fair, as the least-to-most prompt contains more words due to its extra decomposition. As shown in Table 13 (Appendix 7.3), for lists with length 12, chain-of-thought prompting achieves an accuracy of $3 7 . 4 \%$ with 4 independent exemplars (Appendix 7.2.2), and $3 8 . 4 \%$ with 8 independent exemplars (Appendix 7.2.3). Although there have been notable advancements compared to an accuracy of $3 1 . 8 \%$ by the original prompt in Table 3, chain-of-thought prompting still lags behind least-to-most prompting, which boasts an accuracy of $7 4 . 0 \%$ . + +Error analysis. While least-to-most prompting significantly outperforms chain-of-thought prompting, it is still far from achieving $100 \%$ accuracy for long lists. In Appendix 7.4, we present a detailed error analysis. We find that only very few of them are due to incorrect last letters, while most of them are concatenation errors (dropping or adding a letter). For example, given the list “gratified, contract, fortitude, blew”, the model drops the last letter in the concatenation of “dte” and “w”, and thus predicts the outcome to be “dte” instead of “dtew”. In another example “hollow, supplies, function, gorgeous”, the model somehow duplicates the last letter “s” in the concatenation of “wsn” and “s”, and thus the prediction becomes “wsnss” instead of “wsns”. + +# 3.2 COMPOSITIONAL GENERALIZATION + +SCAN (Lake & Baroni, 2018) is probably the most popular benchmark for evaluating compositional generalization. It requires mapping natural language commands to action sequences (Table 5). Sequence-to-sequence models perform poorly under length split where the action sequences in the training set (about $8 0 \%$ of the full set with over 20,000 examples) are shorter than the action sequences in the testing set. Many specialized neural-symbolic models have been proposed to solve SCAN (Chen et al., 2020; Liu et al., 2020; Nye et al., 2020; Shaw et al., 2021; Kim, 2021). We show that large language models with least-to-most prompting can solve SCAN using only a few demonstration examples. No training or finetuning is needed. + +Table 5: Example commands in SCAN and their corresponding action sequences. An agent successfully executes a natural language command by performing its corresponding action sequence. + +
CommandAction Sequence
“look thrice after jump”JUMPLOOKLOOKLOOK
“run left and walk”TURNLEFTRUNWALK
“look opposite right”TURN_RIGHTTURN_RIGHTLOOK
+ +Least-to-most prompting. Like the last-letter-concatenation task in Section 3.1, least-to-most prompting for SCAN is based on two kinds of prompts: (1) a command decomposition prompt containing 8 exemplars to demonstrate how to decompose a long command to a list of short commands (see Table 6 for some of these exemplars); and (2) a command mapping prompt containing 14 exemplars to demonstrate how to map natural language commands to action sequences (see Table 7 for some of these exemplars). The full prompt contexts for both decomposition and mapping are listed in Appendix 8. The exemplars used in the command-mapping prompt are intended to fully cover the semantics of the SCAN commands. + +Table 6: Two exemplars taken from the least-to-most prompt for decomposing a long command to a sequence of short commands. + +
thrice”.“walk”can be solved by“walk". So,“look opposite right thrice after walk” can beQ: “look opposite right thrice after walk” A:"look opposite right thrice”can be solved by:“look opposite right”,“look opposite right
solved by:“look opposite right”,“look opposite right thrice”,“walk".
Q: “look around right thrice and walk"
A: “look around right thrice”can be solved by: “look right”,“look around right”,“look around
solved by:“look right”,"look around right”,“look around right thrice”,“walk".right thrice”.“walk” can be solved by“walk". So,“look around right thrice and walk” can be
+ +We use Python notation to make our prompts in least-to-most prompting and the baselines (stand few-shot prompting and chain-of-thought prompting) concise and meet the input size limit of language models (usually up to 2048 tokens). For example, in our prompt design, we map “look twice” + +to “LOOK” $^ { * } 2$ rather than “LOOK LOOK”. We may have to point out that these Python expressions are just intermediate representations. After obtaining responses from language models, we run a postprocessing script to expand the Python expressions to generate the final results. However, it should not be surprising that we can also further teach language models to correctly process expressions. In Appendix 8.4, we show that with several demonstration exemplars, language models are able to expand Python expressions with a near-perfect accuracy of $9 9 . 7 \%$ . + +Table 7: Two exemplars taken from the least-to-most / chain-of-thought prompt for mapping commands to action sequences. Python expressions are used as intermediate representations. + +
Q: "jump left"
A: The output of "jump left” concatenates: the output of "turn left", the output of "jump". “turn
left” outputs “TURN_LEFT". “jump” outputs “JUMP". So concatenating the output of “turn
left" and the output of "jump” leads to “TURN_LEFT”+“JUMP". So the output of "jump left" is“TURN_LEFT"+“JUMP".
Q:“run and look twice”
A: The output of “run and look twice” concatenates: the output of“run”, the output of “look
twice".“run” outputs “RUN".“look twice” outputs “LOOK” * 2. So concatenating the output of
“run”and the output of “look twice” leads to “RUN” +“LOOK” * 2. So the output of “run and
look twice” is “RUN”+“LOOK” * 2.
+ +Chain-of-thought prompting. The chain-of-thought prompt for SCAN uses the same commandmapping context as least-to-most prompting (see Table 7) but it does not use command decomposition, which is exclusively used for least-to-most prompting. + +Results. We compare least-to-most prompting with chain-of-thought prompting and standard fewshot prompting. The exemplars for standard few-shot prompting are derived from the chain-ofthought prompt by removing the intermediate explanations. The accuracies of different prompting methods with different language models are presented in Table 8. Example outputs can be found in Appendix 8.3. Using code-davinci-002, least-to-most prompting achieves an accuracy of $9 9 . 7 \bar { \% }$ under length split. We also test least-to-most prompting on all other splits and even the full SCAN dataset. We find that its solving rate remains the same. In addition, it may be interesting to note that code-davinci-002 consistently outperforms text-davinci-002, regardless of the prompting method. + +
MethodStandard promptingChain-of-ThoughtLeast-to-Most
code-davinci-00216.716.299.7
text-davinci-0026.00.076.0
code-davinci-0010.40.060.7
+ +Table 8: Accuracies $( \% )$ of different prompting methods on the test set of SCAN under length split. +The results of text-davinci-002 are based on a random subset of 100 commands. + +Error analysis. In the test set of the length split, there are 13 failures in total from least-to-most prompting: 6 of them incorrectly interpret “twice” and “thrice” following “around”, and the rest incorrectly interpret “after” as “and”. Let us show a failed example for each category. In the example “walk opposite right twice after run around right thrice”, code-davinci-002 correctly translates the expression “run around right” to (“TURN RIGHT” $^ +$ “RUN”) $\ast ~ 4$ . Then it makes a mistake when applying “thrice” to this expression and produces (“T $\mathrm { U R N . R I G H T ^ { \prime \prime } + ^ { \prime \prime } R U N ^ { \prime \prime } ) \ ^ { * } \ \mathcal { G } }$ instead of (“TURN RIGHT” $^ +$ “RUN”) $* \ 4 \ast \ 3$ or (“TURN RIGHT” $^ +$ “RUN”) $* \ 1 2$ . In the example “run opposite left thrice after run around left twice”, code-davinci-002 produces the correct translations for both sub-expressions that are connected by “after” but it combines them as if they were connected by “and”. This means that the model produces (“TURN LEFT” $\mathrm { ~ \# ~ } 2 + \mathrm { ~ \# ~ } { \mathrm { R U N } } ^ { , , * } ) \mathrm { ~ } ^ { * } 3 +$ (“TURN LEF $\Gamma ^ { \prime \prime } + \mathrm { ^ { * } R U N ^ { \prime \prime } } ) \ast 4 \ast 2$ instead of (“TURN LEFT” $^ +$ “RUN”) $^ { * } 4 ^ { * } 2 +$ (“TURN LEFT” $^ { * } 2 + ^ { * } \mathrm { R U N } ^ { , * } ) \ ^ { * } 3$ . A detailed error analysis can be found in Appendix 8.2. + +# 3.3 MATH REASONING + +In this section, we apply least-to-most prompting to solve math word problems in GSM8K (Cobbe et al., 2021) and DROP (Dua et al., 2019). We are particularly interested at seeing if large language models combined with least-to-most prompting can solve problems more difficult than those seen in the prompts. Here, we simply measure the difficulty by the number of solving steps. + +1. Anna has 2 more apples than Elsa. So Anna has $2 + 5 = 7$ apples. +2. Elsa and Anna have $5 + 7 = 1 2$ apples together. + +The answer is: 12. + +Table 9: The least-to-most prompt for solving GSM8K. The demonstration problem is solved in only two steps, but the prompt can handle problems that require multiple steps to be solved. + +Q: Elsa has 5 apples. Anna has 2 more apples than Elsa. How many apples do they have together? A: Anna has 2 more apples than Elsa. So Anna has $2 + 5 = 7$ apples. So Elsa and Anna have $5 + 7$ $= 1 2$ apples together. + +The answer is: 12. + +Table 10: The chain-of-thought prompt for solving GSM8K. It is derived from the least-to-most prompt in Table 9 by removing the decomposition part. + +The prompt that we design to solve GSM8K is shown in Table 9. The demonstration exemplar consists of two parts. The first part (starting from “Let’s break down this problem . . . ”) shows how the original problem can be decomposed into simpler subproblems, and the the second part shows how the subproblems are solved in sequence. Note that this prompt combines decomposition and subproblem solving into a single pass. One may instead design two different prompts respectively for decomposition and subproblem solving, as the least-to-most prompts in the previous sections, to further improve performance. Here, we focus on investigating how this simple least-to-most prompt generalizes from a simple 2-step problem to more complex multi-step problems. + +We also construct a chain-of-thought prompt (Table 10) as our baseline. It is derived from the leastto-most prompt (Table 9) by removing the decomposition part. The results are shown in Table 11. Overall, least-to-most prompting only slightly improves chain-of-thought prompting: from $6 0 . 9 7 \%$ to $6 2 . 3 9 \%$ . However, least-to-most prompting essentially improves chain-of-thought prompting in solving problems which need at least 5 steps to be solved: from $3 9 . 0 7 \%$ to $4 5 . 2 3 \%$ (Table 12). We find that almost every problem in GSM8K that least-to-most prompting fails to solve can be eventually solved by using a manually crafted decomposition. This should not be surprising. For our humans, as long as we know how to decompose a complex problem into simpler subproblems, we actually have solved it. For the DROP benchmark, least-to-most prompting outperforms chainof-thought prompting by a large margin (Table 11). That is probably because most problems in DROP can be trivially decomposed. + +
MethodNon-football (DROP)Football (DROP)GSM8K
Zero-Shot43.8651.7716.38
Standard prompting58.7862.7317.06
Chain-of-Thought74.7759.5660.87
Least-to-Most82.4573.4262.39
+ +Table 11: Accuracies $( \% )$ of different prompting methods on GSM8K and DROP (only the subset containing numerical problems). The base language model is code-davinci-002. + +Table 12: Accuracies $( \% )$ of least-to-most prompting and chain-of-thought prompting, broken down by the number of reasoning steps required in the expected solution. + +
Accuracy by Steps (GSM8K)All2 Steps3 Steps4 steps≥ 5 steps
Least-to-Most62.3974.5368.9159.7345.23
Chain-of-Thought60.8776.6867.2959.3939.07
+ +# 4 RELATED WORK + +Compositional generalization. SCAN (Lake & Baroni, 2018) is a widely used benchmark to evaluate compositional generalization. Among all of its splits, the most challenging is the length split, which requires a model to generalize to test sequences longer than training ones. Prior work with good performance on SCAN mostly proposed neural-symbolic architectures (Chen et al., 2020; Liu et al., 2020) and grammar induction techniques (Nye et al., 2020; Shaw et al., 2021; Kim, 2021). Chen et al. (2020) proposed the neural-symbolic stack machine, which contains a neural network as the controller to generate an execution trace for a given input, and a symbolic stack machine to execute the trace and produce the output. The execution trace consists of domain-specific primitives for sequence manipulation, which allows the machine to break down the input sentence into different components, translate them separately, and compose them together. Liu et al. (2020) proposed a framework that cooperatively learns two neural modules, a composer and a solver, to jointly learn the input structure and the symbolic grammar rules. Both Nye et al. (2020) and Shaw et al. (2021) inferred the symbolic grammar rules of SCAN, while Kim (2021) proposed to learn a latent neural grammar. While approaches with symbolic components are able to achieve $1 0 0 \%$ accuracy on SCAN (Chen et al., 2020; Liu et al., 2020; Nye et al., 2020; Shaw et al., 2021), they require complicated model training and grammar inference algorithms to search in a large grammar space. Another line of work on SCAN designs data augmentation schemes (Andreas, 2020; Akyurek et al. ¨ , 2021; Lake, 2019). Both Andreas (2020) and Akyurek et al. ¨ (2021) construct synthetic training samples by recombining fragments occurring in different training samples, and Akyurek et al. ¨ (2021) further designs a sampling scheme that encourages the recombination model to produce rare samples. On the other hand, Lake (2019) proposed a meta training algorithm, which requires a meta-grammar space to construct training data, and the format of sampled grammars is similar to the SCAN grammar. While these data augmentation techniques improve the performance on several compositional generalization benchmarks, they fail to solve the length split of SCAN. Other prior works propose neural network architectures to improve compositional generalization, where they encourage the model to learn the word and span mapping (Russin et al., 2019; Li et al., 2019), the alignment of input and output as span trees (Herzig & Berant, 2021), and the permutation equivariance of input and output words (Gordon et al., 2020). Still, these end-to-end neural networks without symbolic components do not generalize to longer test inputs. Unlike the existing work, we demonstrate that without model architectures and symbolic components specially designed to improve compositional generalization, least-to-most prompting achieves $9 9 . 7 \%$ accuracy on any split (including length split) with only a handful of demonstration examples, and it does not require any training or finetuning. + +Easy-to-hard generalization. In addition to compositional generalization, there are many other tasks where the test cases require more reasoning steps to solve than the training examples, for example, the last-letter-concatenation task where the test lists are longer than the demonstration examples. Dong et al. (2019) propose Neural Logic Machines (NLMs) for both inductive learning and logic reasoning. NLMs trained on small-scale tasks (such as small size block worlds) can perfectly generalize to large-scale tasks (such as larger size block worlds). Schwarzschild et al. (2021) show that recurrent networks trained to solve simple problems with few recurrent steps (such as small size mazes or chess puzzles) can solve more complex problems (such as larger size mazes or chess puzzles) by performing additional recurrences during inference. In our method, we achieve easy-to-hard generalization by decomposing a complex problem into a series of easier problems. + +Task decomposition. Perez et al. (2020) decompose a multi-hop question into a number of independent single-hop subquestions, which are answered by an off-the-shelf question answering (QA) model. Then those answers are aggregated to form the final answer. Both question decomposition and answer aggregation are implemented by trained models. Wang et al. (2022a) conducts multi-hop QA by modeling prompts as continuous virtual tokens and progressively eliciting relevant knowledge from language models via iterative prompting. Unlike these methods, our approach does not involve any training or finetuning. Moreover, the subquestions generated in least-to-most prompting are usually dependent and have to be sequentially solved in a specific order so that answers to some subquestions can be used as building blocks to solve other subquestions. Yang et al. (2022) translate natural language questions to SQL queries by decomposing a question into a sequence of slot-filling natural language prompts corresponding to SQL clauses via a rule-based system. Wu et al. (2022) propose chaining large language model steps such that the output of one step becomes the input for the next and develop an interactive system for users to construct and modify chains. Least-to-most prompting chains the processes of problem decomposition and subproblem solving. + +# 5 LIMITATIONS + +Decomposition prompts typically don’t generalize well across different domains. For instance, a prompt that demonstrates decomposing math word problems (as seen in Table 9) isn’t effective for teaching large language models to break down common sense reasoning problems, such as “Did Aristotle use a laptop?” (Geva et al., 2021). A new prompt must be designed to demonstrate decomposition for these types of problems in order to achieve optimal performance. + +Generalizing decomposition can even be difficult within the same domain. We’ve observed that nearly all problems in GSM8K can be accurately solved if the large language models are provided with the correct decomposition of those challenging problems. This finding isn’t surprising and aligns with our experiences in solving math problems. Whenever we successfully break down a math problem into simpler subproblems we can solve, we’ve essentially solved the original problem. Exceptional results are achieved on the last-letter-concatenation task and the SCAN benchmark because decomposition in these tasks is relatively straightforward. + +# 6 CONCLUSION AND DISCUSSION + +We introduced least-to-most prompting to enable language models to solve problems that are harder than those in the prompt. This approach entails a two-fold process: a top-down decomposition of the problem and a bottom-up resolution generation. Our empirical findings, which encompass symbolic manipulation, compositional generalization, and mathematical reasoning, reveal that least-to-most prompting significantly surpasses standard prompting and chain-of-thought prompting. + +In general, prompting might not be the optimal method for teaching reasoning skills to large language models. Prompting can be viewed as a unidirectional communication form in which we instruct a language model without considering its feedback. A natural progression would be to evolve prompting into fully bidirectional conversations, enabling immediate feedback to language models, thereby facilitating more efficient and effective learning. The least-to-most prompting technique represents a stride towards instructing language models through such bidirectional interactions. + +# ACKNOWLEDGEMENT + +We sincerely thank Xinyun Chen, Xinying Song, Jeff Dean, Zoubin Ghahramani, Fernando Pereira, Jacob Devlin, and Pete Shaw for sharing their valuable knowledge and advice during our discussions. Their expertise greatly improved the quality of our work. Additionally, we are grateful to the anonymous reviewers for their careful review and helpful suggestions, which helped shape our manuscript into its final form. + +# REFERENCES + +Ekin Akyurek, Afra Feyza Aky ¨ urek, and Jacob Andreas. Learning to recombine and resample ¨ data for compositional generalization. In International Conference on Learning Representations, 2021. + +Jacob Andreas. Good-enough compositional data augmentation. In Annual Meeting of the Association for Computational Linguistics, 2020. + +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. + +Xinyun Chen, Chen Liang, Adams Wei Yu, Dawn Song, and Denny Zhou. Compositional generalization via neural-symbolic stack machines. Advances in Neural Information Processing Systems, 33:1690–1701, 2020. + +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. + +Karl Cobbe, Vineet Kosaraju, Mohammad Bavarian, Jacob Hilton, Reiichiro Nakano, Christopher Hesse, and John Schulman. Training verifiers to solve math word problems. arXiv preprint arXiv:2110.14168, 2021. + +Honghua Dong, Jiayuan Mao, Tian Lin, Chong Wang, Lihong Li, and Denny Zhou. Neural logic machines. In International Conference on Learning Representations, 2019. + +Dheeru Dua, Yizhong Wang, Pradeep Dasigi, Gabriel Stanovsky, Sameer Singh, and Matt Gardner. DROP: A reading comprehension benchmark requiring discrete reasoning over paragraphs. arXiv preprint arXiv:1903.00161, 2019. + +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 (TACL), 2021. + +Jonathan Gordon, David Lopez-Paz, Marco Baroni, and Diane Bouchacourt. Permutation equivariant models for compositional generalization in language. In International Conference on Learning Representations, 2020. + +Jonathan Herzig and Jonathan Berant. Span-based semantic parsing for compositional generalization. In Annual Meeting of the Association for Computational Linguistics, 2021. + +Daniel Keysers, Nathanael Scharli, Nathan Scales, Hylke Buisman, Daniel Furrer, Sergii Kashubin, ¨ Nikola Momchev, Danila Sinopalnikov, Lukasz Stafiniak, Tibor Tihon, et al. Measuring compositional generalization: A comprehensive method on realistic data. International Conference on Learning Representations, 2020. + +Yoon Kim. Sequence-to-sequence learning with latent neural grammars. Advances in Neural Information Processing Systems, 34, 2021. + +Brenden Lake and Marco Baroni. Generalization without systematicity: On the compositional skills of sequence-to-sequence recurrent networks. In International conference on machine learning, pp. 2873–2882. PMLR, 2018. + +Brenden M Lake. Compositional generalization through meta sequence-to-sequence learning. Advances in neural information processing systems, 32, 2019. + +Yuanpeng Li, Liang Zhao, Jianyu Wang, and Joel Hestness. Compositional generalization for primitive substitutions. 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. 4284–4293, 2019. + +Myrna E Libby, Julie S Weiss, Stacie Bancroft, and William H Ahearn. A comparison of most-toleast and least-to-most prompting on the acquisition of solitary play skills. Behavior analysis in practice, 1(1):37–43, 2008. + +Wang Ling, Dani Yogatama, Chris Dyer, and Phil Blunsom. Program induction by rationale generation: Learning to solve and explain algebraic word problems. In Proceedings of the 55th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), 2017. + +Qian Liu, Shengnan An, Jian-Guang Lou, Bei Chen, Zeqi Lin, Yan Gao, Bin Zhou, Nanning Zheng, and Dongmei Zhang. Compositional generalization by learning analytical expressions. Advances in Neural Information Processing Systems, 33:11416–11427, 2020. + +Maxwell Nye, Armando Solar-Lezama, Josh Tenenbaum, and Brenden M Lake. Learning compositional rules via neural program synthesis. Advances in Neural Information Processing Systems, 33:10832–10842, 2020. + +Ethan Perez, Patrick Lewis, Wen-tau Yih, Kyunghyun Cho, and Douwe Kiela. Unsupervised question decomposition for question answering. In Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing (EMNLP), pp. 8864–8880, 2020. + +Jake Russin, Jason Jo, Randall C O’Reilly, and Yoshua Bengio. Compositional generalization in a deep seq2seq model by separating syntax and semantics. arXiv preprint arXiv:1904.09708, 2019. + +Avi Schwarzschild, Eitan Borgnia, Arjun Gupta, Furong Huang, Uzi Vishkin, Micah Goldblum, and Tom Goldstein. Can you learn an algorithm? generalizing from easy to hard problems with recurrent networks. Advances in Neural Information Processing Systems, 34, 2021. + +Peter Shaw, Ming-Wei Chang, Panupong Pasupat, and Kristina Toutanova. Compositional generalization and natural language variation: Can a semantic parsing approach handle both? 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. 922–938, 2021. + +Boshi Wang, Xiang Deng, and Huan Sun. Shepherd pre-trained language models to develop a train of thought: An iterative prompting approach. arXiv preprint arXiv:2203.08383, 2022a. + +Xuezhi Wang, Jason Wei, Dale Schuurmans, Quoc Le, Ed Chi, and Denny Zhou. Self-consistency improves chain of thought reasoning in language models. arXiv preprint arXiv:2203.11171, 2022b. + +Jason Wei, Xuezhi Wang, Dale Schuurmans, Maarten Bosma, Ed Chi, Brian Ichter, Fei Xia, Quoc Le, and Denny Zhou. Chain of thought prompting elicits reasoning in large language models. Advances in Neural Information Processing Systems, 35, 2022. + +Tongshuang Wu, Michael Terry, and Carrie Jun Cai. AI chains: Transparent and controllable humanAI interaction by chaining large language model prompts. In CHI Conference on Human Factors in Computing Systems, pp. 1–22, 2022. + +Jingfeng Yang, Haoming Jiang, Qingyu Yin, Danqing Zhang, Bing Yin, and Diyi Yang. Seqzero: Few-shot compositional semantic parsing with sequential prompts and zero-shot models. arXiv preprint arXiv:2205.07381, 2022. + +# Appendix + +# Table of Contents + +# 7 Last-letter-concatenation 14 + +# 7.1 Prompt context for decomposing a word list into subproblems 14 + +# 7.2 Prompt contexts with more and different examples 14 + +7.2.1 Standard prompting, 4-shot 14 +7.2.2 Chain-of-thought prompting, 4-shot . 14 +7.2.3 Chain-of-thought prompting, 8-shot . 15 +7.2.4 Chain-of-thought prompting, 2-shot, same examples as for least-to-most . 15 +7.2.5 Least-to-most prompting, 4-shot 15 + +7.3 Data Generation and additional results 16 + +7.4 Error analysis: Least-to-most prompting 17 + +# 7.5 Example outputs from code-davinci-002 18 + +7.5.1 Standard prompting: Failure 18 +7.5.2 Chain-of-thought prompting: Success . 19 +7.5.3 Chain-of-thought prompting: Failure 21 +7.5.4 Least-to-most prompting: Success 22 +7.5.5 Least-to-most prompting: Failure 25 + +# 8 SCAN + +# 28 + +# 8.1 Prompt contexts 28 + +8.1.1 Standard prompting 29 +8.1.2 Least-to-most prompting 29 +8.1.3 Chain-of-thought prompting 31 + +8.2 Error analysis: Least-to-most prompting 31 + +# 8.3 Example outputs from code-davinci-002 33 + +8.3.1 Chain-of-thought prompting: Success . 33 +8.3.2 Chain-of-thought prompting: Failure 35 +8.3.3 Least-to-most prompting: Success 37 +8.3.4 Least-to-most prompting: Failure 40 + +# 9 DROP + +# 9.1 Results with text-davinci-002 and LM-540B 46 + +# 9.2 Non-football Subset 46 + +9.2.1 Zero-shot prompting 46 +9.2.2 Standard prompting with 3 examples 47 +9.2.3 Chain-of-thought prompting with 3 examples 47 +9.2.4 Least-to-most prompting I: problem decomposition (5 examples) 48 +9.2.5 Least-to-most prompting II: problem solving (3 examples) 48 + +# 9.3 Football subset . 49 + +9.3.1 Zero-shot prompting 49 +9.3.2 Standard prompting with 3 examples 49 +9.3.3 Chain-of-thought prompting with 3 examples 49 +9.3.4 Least-to-most prompting I: problem decomposition (6 examples) 50 +9.3.5 Least-to-most prompting II: problem solving (3 examples) 51 + +# 9.4 Examples where least-to-most succeeded but chain-of-thought failed . 52 + +9.4.1 Case 1 52 +9.4.2 Case 2 52 +9.4.3 Case 3 53 +9.4.4 Case 4 5454 +9.5 Error analysis: Least-to-most prompting 54 +9.5.1 Example of wrong problem decomposition 55 +9.5.2 Example of wrong problem solving 55 +9.5.3 Example of wrong given label . 55 + +# 10 GSM8K 56 + +10.1 Experiment results: One-shot prompts 56 +10.2 Experiment results: Engineered prompts 56 +10.3 Prompt contexts: One-shot prompts 57 +10.3.1 Chain-of-Thought (1-shot) 58 +10.3.2 Least-to-Most (1-shot) 58 +10.4 Prompt contexts: Engineered prompts . . . 58 +10.4.1 Zero-Shot 58 +10.4.2 Standard prompting: 4 examples 58 +10.4.3 Chain-of-Thought (best): 4 examples 59 +10.4.4 Least-to-Most (best) I - problem decomposition: 7 examples 59 +10.4.5 Least-to-Most (best) II - problem solving: 4 examples 60 + +# 7 LAST-LETTER-CONCATENATION + +7.1 PROMPT CONTEXT FOR DECOMPOSING A WORD LIST INTO SUBPROBLEMS + +In Section 3.1 we mentioned that language model prompting can be used to decompose a word list such as “think, machine, learning, reasoning” into a sequence of subproblems “think, machine”, “think, machine, learning”, and “think, machine, learning, reasoning”. + +The following prompt context achieves $100 \%$ accuracy on this task when using the text-davinci-002 model. Note that it achieves perfect accuracy on lists up to size 12 (which is the maximum that we tested for our experiment) even though it only contains one exemplar each for lists of sizes 2 and 3. + +Q: “machine, learning” +A: creating sequential sublists of the list “machine, learning”: +“machine” +“machine, learning” +Q: “machine, learning, artificial” +A: creating sequential sublists of the list “machine, learning, artificial”: +“machine” +“machine, learning” +“machine, learning, artificial” + +# .2 PROMPT CONTEXTS WITH MORE AND DIFFERENT EXAMPLES + +The last-letter-concatenation experiments presented in Section 3.1 are based on prompt contexts that consists of 2 demonstration examples. To make sure that the accuracy gain achieved by leastto-most prompting is not caused by the slight increase in example length when compared to chainof-thought, we also performed experiments with more context examples so that we can compare least-to-most vs. chain-of-thought for different prompt sizes. Also, we perform experiments where we use for chain-of-thought prompting the same prompt examples that we use for least-to-most prompting (unlike the situation in Table ?? where we use different examples). All these prompts are shown below, and we present and discuss the corresponding accuracies in Section 7.3. + +# 7.2.1 STANDARD PROMPTING, 4-SHOT + +Q: “think, machine” +A: “ke” +Q: “learning, reasoning, generalization” +A: “ggn” +Q: “artificial, intelligence” +A: “le” +Q: “transformer, language, vision” +A: “ren” + +7.2.2 CHAIN-OF-THOUGHT PROMPTING, 4-SHOT + +Q: “think, machine” +A: The last letter of “think” is “k”. The last letter of “machine” is “e”. Concatenating “k”, “e” leads to “ke”. So, “think, machine” outputs “ke”. Q: “learning, reasoning, generalization” +A: The last letter of “learning” is “g”. The last letter of “reasoning” is “g”. The last letter of “generalization” is “n”. Concatenating “g”, “g”, “n” leads to “ggn”. So, “learning, reasoning, generalization” outputs “ggn”. + +Q: “artificial, intelligence” + +A: The last letter of “artificial” is “l”. The last letter of “intelligence” is “e”. Concatenating “l”, “e” leads to “le”. So, “artificial, intelligence” outputs “le”. + +Q: “transformer, language, vision” + +A: The last letter of “transformer” is “r”. The last letter of “language” is “e”. The last letter of “vision” is “n”. Concatenating “r”, “e”, “n” leads to “ren”. So, “transformer, language, vision” outputs “ren”. + +7.2.3 CHAIN-OF-THOUGHT PROMPTING, 8-SHOT + +Q: “think, machine” + +A: The last letter of “think” is “k”. The last letter of “machine” is “e”. Concatenating “k”, “e” leads to “ke”. So, “think, machine” outputs “ke”. + +Q: “learning, reasoning, generalization” + +A: The last letter of “learning” is “g”. The last letter of “reasoning” is “g”. The last letter of “generalization” is “n”. Concatenating “g”, “g”, “n” leads to “ggn”. So, “learning, reasoning, generalization” outputs “ggn”. + +Q: “artificial, intelligence” + +A: The last letter of “artificial” is “l”. The last letter of “intelligence” is “e”. Concatenating “l”, “e” leads to “le”. So, “artificial, intelligence” outputs “le”. + +Q: “transformer, language, vision” + +A: The last letter of “transformer” is “r”. The last letter of “language” is “e”. The last letter of “vision” is “n”. Concatenating “r”, “e”, “n” leads to “ren”. So, “transformer, language, vision” outputs “ren”. + +Q: “school, teacher” + +A: The last letter of “school” is “l”. The last letter of “teacher” is “r”. Concatenating “l”, “r” leads to “lr”. +So, “school, teacher” outputs “lr”. + +Q: “art, science, department” + +A: The last letter of “art” is “t”. The last letter of “science” is “e”. The last letter of “department” is “t”. +Concatenating “t”, “e”, “t” leads to “tet”. So, “art, science, department” outputs “tet”. + +Q: “pen, laptop” + +A: The last letter of “pen” is “n”. The last letter of “laptop” is “p”. Concatenating: “n”, “p” leads to “np”. +So, “pen, laptop” outputs “np”. + +Q: “book, campus, university” A: The last letter of “book” is “k”. The last letter of “campus” is “s”. The last letter of “university” is “y”. Concatenating: “k”, “s”, “y” leads to “ksy”. So, “book, campus, university” outputs “ksy”. + +7.2.4 CHAIN-OF-THOUGHT PROMPTING, 2-SHOT, SAME EXAMPLES AS FOR LEAST-TO-MOST + +Q: “think, machine” + +A: The last letter of “think” is “k”. The last letter of “machine” is “e”. Concatenating “k”, “e” leads to “ke”. So, “think, machine” outputs “ke”. + +Q: “think, machine, learning” A: The last letter of “think” is “k”. The last letter of “machine” is “e”. The last letter of “learning” is “g”. Concatenating “k”, “e”, “g” leads to “keg”. So, “think, machine, learning” outputs “keg”. + +7.2.5 LEAST-TO-MOST PROMPTING, 4-SHOT + +Q: “think, machine” + +A: The last letter of “think” is “k”. The last letter of “machine” is “e”. Concatenating “k”, “e” leads to + +“ke”. So, “think, machine” outputs “ke”. + +Q: “think, machine, learning” +A: “think, machine” outputs “ke”. The last letter of “learning” is “g”. Concatenating “ke”, “g” leads to “keg”. So, “think, machine, learning” outputs “keg”. Q: “transformer, language” +A: The last letter of “transformer” is “r”. The last letter of “language” is “e”. Concatenating: “r”, “e” leads to “re”. So, “transformer, language” outputs “re”. Q: “transformer, language, vision” +A: “transformer, language” outputs “re”. The last letter of “vision” is “n”. Concatenating: “re”, “n” leads to “ren”. So, “transformer, language, vision” outputs “ren”. + +# 7.3 DATA GENERATION AND ADDITIONAL RESULTS + +Data generation. The last-letter-concatenation dataset is based on a list of the $1 0 \mathrm { k }$ most common English words (including proper nouns) used in books that are part of project Gutenberg, as collected in Wiktionary2. After eliminating profane words, we ended up with a list of 9694 words (all lowercase). For each of the desired list sizes 2, 4, 6, 8, 10, 12, we then generated 500 examples, each of which consists of a random sequence of these words (input) and the corresponding sequence of last letters (output). We will release the full dataset upon publication of this paper. Below are 10 random examples of list size 6: + +• IN: “narrative, celebrate, neighbouring, indebted, stove, calling” OUT: “eegdeg” • IN: “barley, silk, thankful, kiss, logs, silent” OUT: “yklsst” • IN: “knitting, conveyance, receives, represent, cow, shut” OUT: “gestwt” • IN: “olive, dark, limitation, airy, pocket, wondered” OUT: “eknytd” IN: “apprehensive, exclamation, perspiration, trusting, destiny, tactics” OUT: “enngys” • IN: “qualified, envoy, disciple, exert, witnesses, plane” OUT: “dyetse” • IN: “decidedly, dome, france, chris, knowing, peaceful” OUT: “yeesgl” • IN: “deceit, refinement, tips, cord, princes, discovery” OUT: “ttsdsy” • IN: “drops, paste, defective, bohemia, requested, convenient” OUT: “seeadt” • IN: “diverse, christopher, homely, agreeable, fright, suspended” OUT: “eryetd” + +Complete results. Table 13 summarizes all the experiments we performed for the last-letterconcatenation task. In addition to the experiments where prompt contexts contain 2 demonstration examples presented in Section 3.1, this includes experiments where the prompts contain 4 and 8 demonstration examples (see above). + +While more prompt examples have no effect for standard prompting (the accuracy remains at 0), they increase the accuracy across the board for chain-of-thought and least-to-most prompting. However, least-to-most prompting consistently outperforms chain-of-thought prompting. In fact, even if we compare 2-shot least-to-most (prompt size 123 GPT3 tokens) to 8-shot chain-of-thought (prompt size 573 GPT3 tokens), the accuracy for least-to-most prompting is much higher than for chainof-thought prompting. The difference is especially pronounced for long sequences (e.g., for $\mathrm { ~ L ~ } =$ 12, we have least-to-most at $7 4 . 0 \%$ vs. chain-of-thought at $3 8 . 4 \%$ ). This shows that least-to-most prompting is much more data-efficient than chain-of-thought prompting for this problem. + +Comparing the first two rows for chain-of-thought prompting shows that chain-of-thought achieves higher accuracy if we use two independent examples (see prompt in Table ??) instead of the two dependent examples that we use for least-to-most prompting. This demonstrates that the accuracy advantage of least-to-most prompting over chain-of-thought prompting remains even if the use the same examples for both of them. + +
Prompting method#ExamplesModelL=4L=6L=8L=10L = 12
StandardAnyAny0.00.00.00.00.0
Chain-of-Thought22 (L2M)4844code-002code-002code-002code-002text-002*code-00189.475.051.839.833.6
84.269.250.239.831.8
88.691.087.013.077.079.864.01.853.456.846.00.044.046.825.00.037.4
38.4
14.00.0
Least-to-Most2444code-00294.088.483.084.684.04.076.480.272.01.074.076.666.00.1
code-002text-002*code-00196.094.019.692.090.08.4
+ +Table 13: Accuracy of different prompting methods, prompt sizes, and GPT3 models on the lastletter-concatenation task with the length of lists increasing from 4 to 12. We use $\mathtt { C O d e - } 0 0 2$ to denote the model code-davinci-002, text-002 to denote the model text-davinci-002, and $\mathtt { C O d e - } 0 0 1$ to denote the model code-davinci-001. The results in the second row for chain-of-thought prompting correspond to the experiment where we use for chain-of-thought the same prompt examples that we use for least-to-most. The results of text-davinci-002 are based on a subset of 100 random examples (rather than the full set of 500 exammples). + +The table also contains the results from running against two additional GPT-3 models: text-davinci-002 and codex-davinci-001. While text-davinci-002 shows similar accuracy to code-davinci-002 on small list sizes, the accuracy drops off much faster when moving to larger list sizes, both for chain-of-thought prompting as well as for least-to-most prompting. This indicates that the code-davinci-002 model has an advantage when it comes to dealing with iteration and recursion. + +The code-davinci-001 model performs much worse than code-davinci-002 across all dimensions. Even for the shortest list size $\left( \mathrm { L } = 4 \right)$ , the accuracy for least-to-most prompting is only $1 9 . 6 \%$ compared to $96 \%$ for code-davinci-002. This indicates that there is a large potential for improvement when using the exact same configuration with new model generations. + +7.4 ERROR ANALYSIS: LEAST-TO-MOST PROMPTING + +
Error type2 examples4 examples
L=4|L=12L=4L=12
Concatenation error13192120
- Dropping a letter8121515
- Adding a letter4743
- Wrong order1022
Wrong template7100
Incorrect last letter2112
Copy error0010
+ +Table 14: Least-to-most prompting error analysis of 20 random failures of the code-davinci-002 model on list lengths 4 and 12 for prompt contexts consisting of 2 and 4 examples. Note that for some examples, the model made more than one type of error (e.g., dropping and adding a letter during concatenation). + +For least-to-most prompting, we analyzed 20 random failures of the code-davinci-002 model on list lengths 4 and 12 for prompt contexts consisting of 2 and 4 examples. The results are shown in Table 14. Concatenation errors may either be due to dropping a letter, adding a letter or outputting the letters in the wrong order. Wrong template means that the model used the extension template instead of the base template to concatenate the last letter of the first two words of the list. Incorrect last letter means that the model got the last letter of a word wrong, and copy error means that the error was due to making a mistake when copying an intermediate result. + +We observe that for the prompt consisting of 2 examples, the fraction of concatenation errors increases as we go from length 4 to length 12 while the fraction of wrong template errors go down. This makes sense because the number of concatenations grows with the length of the list, while the number of times the model needs to use the base template stays constant. Note that the template errors disappear when we move to the double prompt, which means that adding two more examples helps the model recognize which template to use. As a consequence, the double prompt has a similar distribution of errors for both list lengths. + +Examples of concatenation errors. In the example “gratified, contract, fortitude, blew”, the model drops the last letter in the concatenation of “dte” and “w”, which means that it predicts the last letter sequence to be “dte” instead of “dtew”. + +In the example “hollow, supplies, function, gorgeous”, the model duplicates the last letter “s” in the concatenation of “wsn” and “s”, which means that it predicts the last letter sequence “wsnss” instead of “wsns”. + +In the example “madly, vengeance, cowardice, monk”, the model drops the last letter “k” in the concatenation of “yee” and ”k” and instead adds the letter $" \mathrm { g } ^ { \prime \prime }$ . Consequently, the model predicts “yeeg” instead of “yeek”. + +In the example “slender, lash, throng, scheme”, the model breaks the order of the letters “h” and “g” in the concatenation of “rh” and $" \mathrm { g } ^ { \prime \prime }$ , which means that it predicts the last letter sequence “rghe” instead of “rhge”. + +Example of incorrect last letter. In the example “modification, introducing, schools, lunch”, the model determines the last letter of the word “modification” to be “g”. Consequently, the predicted last letter sequence is “ggsh” instead of “ngsh”. + +Example of wrong template application. In the example “upper, unexpectedly, specifically, connection”, the model uses the extension template to determine the output of the first two words “upper, unexpectedly”. I.e., it produces: + +• “upper” outputs “er”. The last letter of “unexpectedly” is “y”. Concatenating “er”, “y” leads to “ery”. So, “upper, unexpectedly” outputs “ery”. + +when it should have produced: + +• The last letter of “upper” is “r”. The last letter of “unexpectedly” is “y”. Concatenating “r”, “y” leads to “ry”. + +As a consequence, the model predicts the sequence “eryyn” instead of “ryyn”. + +Example of copy error. In the example “displeased, hawk, healing, anchor”, the model correctly computes the final concatenation “dkgr” but then makes a mistake when copying the result to the final output and drops the final “r”, which leads to the prediction “dkg” instead of “dkgr”: + +• “displeased, hawk, healing” outputs “dkg”. The last letter of “anchor” is “r”. Concatenating: “dkg”, “r” leads to “dkgr”. So, “displeased, hawk, healing, anchor” outputs “dkg”. + +# 7.5 EXAMPLE OUTPUTS FROM CODE-DAVINCI-002 + +In this section, we present 5 examples (one example for lengths 4, 6, 8, 10, 12) of successes and failures of the code-davinci-002 model for standard prompting, chain-of-thought prompting, and least-to-most prompting. They are all based on the prompt contexts containing 4 demonstration examples. + +# 7.5.1 STANDARD PROMPTING: FAILURE + +“witnesses, arkansas, remaining, privileged” + +Golden: “ssgd” + +# Solution: + +Q: “witnesses, arkansas, remaining, privileged” A: “n” + +“clan, noun, roy, nicholas, relish, liking” + +Golden: “nnyshg” + +# Solution: + +Q: “clan, noun, roy, nicholas, relish, liking” A: “nicholas” + +“franklin, temporarily, high, origin, rapidly, diversion, firmament, promptly” + +Golden: “nyhnynty” + +# Solution: + +Q: “franklin, temporarily, high, origin, rapidly, diversion, firmament, promptly” A: “n” + +“conquered, owed, enclosure, indeed, shattered, beads, increased, provided, weak, grind” + +Golden: “ddeddsddkd” + +# Solution: + +Q: “conquered, owed, enclosure, indeed, shattered, beads, increased, provided, weak, grind” A: “d” + +“hope, alison, mirrors, benefits, altered, curve, keen, portuguese, distance, interfaces, proof, seamus” + +Golden: “enssdeneesfs” + +# Solution: + +Q: “hope, alison, mirrors, benefits, altered, curve, keen, portuguese, distance, interfaces, proof, +seamus” +A: “hope” + +7.5.2 CHAIN-OF-THOUGHT PROMPTING: SUCCESS + +“geese, rogers, benefactor, version” + +Golden: “esrn” + +# Solution: + +Q: “geese, rogers, benefactor, version” A: The last letter of “geese” is “e”. The last letter of “rogers” is “s”. The last letter of “benefactor” is “r”. The last letter of “version” is “n”. Concatenating “e”, “s”, “r”, “n” leads to “esrn”. So, “geese, rogers, + +benefactor, version” outputs “esrn”. + +“amply, bestow, maryland, edited, blowing, prosperous” + +Golden: “ywddgs” + +# Solution: + +Q: “amply, bestow, maryland, edited, blowing, prosperous” +A: The last letter of “amply” is “y”. The last letter of “bestow” is “w”. The last letter of “maryland” is “d”. The last letter of “edited” is “d”. The last letter of “blowing” is “g”. The last letter of “prosperous” is “s”. Concatenating “y”, “w”, “d”, “d”, “g”, “s” leads to “ywddgs”. So, “amply, bestow, maryland, edited, blowing, prosperous” outputs “ywddgs”. + +“needless, courts, reflected, curly, glowing, asp, chronicles, anthony” + +Golden: “ssdygpsy” + +# Solution: + +Q: “needless, courts, reflected, curly, glowing, asp, chronicles, anthony” +A: The last letter of “needless” is “s”. The last letter of “courts” is “s”. The last letter of “reflected” is “d”. The last letter of “curly” is “y”. The last letter of “glowing” is “g”. The last letter of “asp” is “p”. The last letter of “chronicles” is “s”. The last letter of “anthony” is “y”. Concatenating “s”, “s”, “d”, “y”, “g”, “p”, “s”, “y” leads to “ssdygpsy”. So, “needless, courts, reflected, curly, glowing, asp, chronicles, anthony” outputs “ssdygpsy”. + +“nigel, alaska, rent, hospital, newspaper, medical, nation, dave, associated, rumour” + +# Golden: + +“latlrlnedr” + +# Solution: + +Q: “nigel, alaska, rent, hospital, newspaper, medical, nation, dave, associated, rumour” A: The last letter of “nigel” is “l”. The last letter of “alaska” is “a”. The last letter of “rent” is “t”. The last letter of “hospital” is “l”. The last letter of “newspaper” is “r”. The last letter of “medical” is “l”. The last letter of “nation” is “n”. The last letter of “dave” is “e”. The last letter of “associated” is “d”. The last letter of “rumour” is “r”. Concatenating “l”, “a”, “t”, “l”, “r”, “l”, “n”, “e”, “d”, “r” leads to “latlrlnedr”. So, “nigel, alaska, rent, hospital, newspaper, medical, nation, dave, associated, rumour” outputs “latlrlnedr”. + +“brightness, preparatory, intense, accumulated, reluctantly, nets, inquiries, grip, inquisition, alley, innocent, herbert” + +Golden: “syedysspnytt” + +# Solution: + +Q: “brightness, preparatory, intense, accumulated, reluctantly, nets, inquiries, grip, inquisition, alley, innocent, herbert” + +A: The last letter of “brightness” is “s”. The last letter of “preparatory” is “y”. The last letter of “intense” is “e”. The last letter of “accumulated” is “d”. The last letter of “reluctantly” is “y”. The last letter of “nets” is “s”. The last letter of “inquiries” is “s”. The last letter of “grip” is “p”. The last letter of “inquisition” is “n”. The last letter of “alley” is “y”. The last letter of “innocent” is “t”. The last letter of “herbert” is “t”. Concatenating “s”, “y”, “e”, “d”, “y”, “s”, “s”, “p”, “n”, “y”, “t”, “t” leads to “syedysspnytt”. So, “brightness, preparatory, intense, accumulated, reluctantly, nets, inquiries, grip, inquisition, alley, innocent, herbert” outputs “syedysspnytt”. + +7.5.3 CHAIN-OF-THOUGHT PROMPTING: FAILURE “pattern, vote, afterwards, solemn” + +Golden: “nesn” + +# Solution: + +Q: “pattern, vote, afterwards, solemn” +A: The last letter of “pattern” is “n”. The last letter of “vote” is “e”. The last letter of “afterwards” is “s”. The last letter of “solemn” is “n”. Concatenating “n”, “e”, “s”, “n” leads to “ness”. So, “pattern, vote, afterwards, solemn” outputs “ness”. + +“disappointment, troublesome, respectfully, monstrous, worry, politics” + +Golden: “teysys” + +# Solution: + +Q: “disappointment, troublesome, respectfully, monstrous, worry, politics” + +A: The last letter of “disappointment” is “t”. The last letter of “troublesome” is “e”. The last letter of “respectfully” is “y”. The last letter of “monstrous” is “s”. The last letter of “worry” is “y”. The last letter of “politics” is “s”. Concatenating “t”, “e”, “y”, “s”, “y”, “s” leads to “teyssy”. So, “disappointment, troublesome, respectfully, monstrous, worry, politics” outputs “teyssy”. + +“drawing, changes, purified, basic, others, send, chimney, vice” + +Golden: “gsdcsdye” + +# Solution: + +Q: “drawing, changes, purified, basic, others, send, chimney, vice” +A: The last letter of “drawing” is “g”. The last letter of “changes” is “s”. The last letter of “purified” is “d”. The last letter of “basic” is “c”. The last letter of “others” is “s”. The last letter of “send” is “d”. The last letter of “chimney” is “y”. The last letter of “vice” is “e”. Concatenating “g”, “s”, “d”, “c”, “s”, “d”, “y”, “e” leads to “gsdcsyde”. So, “drawing, changes, purified, basic, others, send, chimney, vice” outputs “gsdcsyde”. + +“sensitive, pray, wreath, betwixt, golden, regions, loyalty, interval, hunting, ranch” + +Golden: “eyhtnsylgh” + +# Solution: + +Q: “sensitive, pray, wreath, betwixt, golden, regions, loyalty, interval, hunting, ranch” A: The last letter of “sensitive” is “e”. The last letter of “pray” is “y”. The last letter of “wreath” is “h”. The last letter of “betwixt” is “t”. The last letter of “golden” is “n”. The last letter of “regions” is “s”. The last letter of “loyalty” is “y”. The last letter of “interval” is “l”. The last letter of “hunting” is “g”. The last letter of “ranch” is “h”. Concatenating “e”, “y”, “h”, “t”, “n”, “s”, “y”, “l”, “g”, “h” leads to “eyhtsynslgh”. So, “sensitive, pray, wreath, betwixt, golden, regions, loyalty, interval, hunting, ranch” outputs “eyhtsynslgh”. + +“freezing, arduous, pushing, vitality, hue, generosity, white, motto, matthew, preferred, hounds, breast” + +Golden: “gsgyeyeowdst” + +# Solution: + +Q: “freezing, arduous, pushing, vitality, hue, generosity, white, motto, matthew, preferred, hounds, breast” + +A: The last letter of “freezing” is “g”. The last letter of “arduous” is “s”. The last letter of “pushing” is “g”. The last letter of “vitality” is “y”. The last letter of “hue” is “e”. The last letter of “generosity” is “y”. The last letter of “white” is “e”. The last letter of “motto” is “o”. The last letter of “matthew” is “w”. The last letter of “preferred” is “d”. The last letter of “hounds” is “s”. The last letter of “breast” is “t”. Concatenating “g”, “s”, “g”, “y”, “e”, “y”, “e”, “o”, “w”, “d”, “s”, “t” leads to “gsgyeyowdst”. So, “freezing, arduous, pushing, vitality, hue, generosity, white, motto, matthew, preferred, hounds, breast” outputs “gsgyeyowdst”. + +7.5.4 LEAST-TO-MOST PROMPTING: SUCCESS “worm, jackson, widow, car” + +Golden: “mnwr” + +# Solution: + +Q: “worm, jackson” +A: The last letter of “worm” is “m”. The last letter of “jackson” is “n”. Concatenating: “m”, “n” leads to “mn”. So, “worm, jackson” outputs “mn”. Q: “worm, jackson, widow” +A: “worm, jackson” outputs “mn”. The last letter of “widow” is “w”. Concatenating: “mn”, “w” leads to “mnw”. So, “worm, jackson, widow” outputs “mnw”. Q: “worm, jackson, widow, car” +A: “worm, jackson, widow” outputs “mnw”. The last letter of “car” is “r”. Concatenating: “mnw”, “r” leads to “mnwr”. So, “worm, jackson, widow, car” outputs “mnwr”. + +“twinkle, blushed, pale, fast, irony, tearing” + +Golden: “edetyg” + +# Solution: + +Q: “twinkle, blushed” +A: The last letter of “twinkle” is “e”. The last letter of “blushed” is “d”. Concatenating: “e”, “d” leads to “ed”. So, “twinkle, blushed” outputs “ed”. Q: “twinkle, blushed, pale” +A: “twinkle, blushed” outputs “ed”. The last letter of “pale” is “e”. Concatenating: “ed”, “e” leads to “ede”. So, “twinkle, blushed, pale” outputs “ede”. Q: “twinkle, blushed, pale, fast” +A: “twinkle, blushed, pale” outputs “ede”. The last letter of “fast” is “t”. Concatenating: “ede”, “t” leads to “edet”. So, “twinkle, blushed, pale, fast” outputs “edet”. + +Q: “twinkle, blushed, pale, fast, irony” + +A: “twinkle, blushed, pale, fast” outputs “edet”. The last letter of “irony” is “y”. Concatenating: “edet”, “y” leads to “edety”. So, “twinkle, blushed, pale, fast, irony” outputs “edety”. + +Q: “twinkle, blushed, pale, fast, irony, tearing” A: “twinkle, blushed, pale, fast, irony” outputs “edety”. The last letter of “tearing” is “g”. Concatenating: “edety”, “g” leads to “edetyg”. So, “twinkle, blushed, pale, fast, irony, tearing” outputs “edetyg”. + +“colonists, empty, fowl, intend, diligent, reluctantly, seed, gentry” + +Golden: “syldtydy” + +# Solution: + +Q: “colonists, empty” +A: The last letter of “colonists” is “s”. The last letter of “empty” is “y”. Concatenating: “s”, “y” leads to “sy”. So, “colonists, empty” outputs “sy”. Q: “colonists, empty, fowl” +A: “colonists, empty” outputs “sy”. The last letter of “fowl” is “l”. Concatenating: “sy”, “l” leads to “syl”. So, “colonists, empty, fowl” outputs “syl”. Q: “colonists, empty, fowl, intend” +A: “colonists, empty, fowl” outputs “syl”. The last letter of “intend” is “d”. Concatenating: “syl”, “d” leads to “syld”. So, “colonists, empty, fowl, intend” outputs “syld”. + +Q: “colonists, empty, fowl, intend, diligent” A: “colonists, empty, fowl, intend” outputs “syld”. The last letter of “diligent” is “t”. Concatenating: “syld”, “t” leads to “syldt”. So, “colonists, empty, fowl, intend, diligent” outputs “syldt”. + +Q: “colonists, empty, fowl, intend, diligent, reluctantly” +A: “colonists, empty, fowl, intend, diligent” outputs “syldt”. The last letter of “reluctantly” is “y”. Concatenating: “syldt”, “y” leads to “syldty”. So, “colonists, empty, fowl, intend, diligent, reluctantly” outputs “syldty”. Q: “colonists, empty, fowl, intend, diligent, reluctantly, seed” +A: “colonists, empty, fowl, intend, diligent, reluctantly” outputs “syldty”. The last letter of “seed” is “d”. Concatenating: “syldty”, “d” leads to “syldtyd”. So, “colonists, empty, fowl, intend, diligent, reluctantly, seed” outputs “syldtyd”. Q: “colonists, empty, fowl, intend, diligent, reluctantly, seed, gentry” +A: “colonists, empty, fowl, intend, diligent, reluctantly, seed” outputs “syldtyd”. The last letter of “gentry” is “y”. Concatenating: “syldtyd”, “y” leads to “syldtydy”. So, “colonists, empty, fowl, intend, diligent, reluctantly, seed, gentry” outputs “syldtydy”. + +“leo, observations, power, thou, dart, emergency, notorious, indulging, consume, provoke” + +Golden: “osrutysgee” + +# Solution: + +Q: “leo, observations” +A: The last letter of “leo” is “o”. The last letter of “observations” is “s”. Concatenating: “o”, “s” leads to “os”. So, “leo, observations” outputs “os”. Q: “leo, observations, power” +A: “leo, observations” outputs “os”. The last letter of “power” is “r”. Concatenating: “os”, “r” leads to “osr”. So, “leo, observations, power” outputs “osr”. + +Q: “leo, observations, power, thou” A: “leo, observations, power” outputs “osr”. The last letter of “thou” is “u”. Concatenating: “osr”, “u” + +leads to “osru”. So, “leo, observations, power, thou” outputs “osru”. + +Q: “leo, observations, power, thou, dart” A: “leo, observations, power, thou” outputs “osru”. The last letter of “dart” is “t”. Concatenating: “osru”, “t” leads to “osrut”. So, “leo, observations, power, thou, dart” outputs “osrut”. + +Q: “leo, observations, power, thou, dart, emergency” +A: “leo, observations, power, thou, dart” outputs “osrut”. The last letter of “emergency” is “y”. Concatenating: “osrut”, “y” leads to “osruty”. So, “leo, observations, power, thou, dart, emergency” outputs “osruty”. Q: “leo, observations, power, thou, dart, emergency, notorious” +A: “leo, observations, power, thou, dart, emergency” outputs “osruty”. The last letter of “notorious” is “s”. Concatenating: “osruty”, “s” leads to “osrutys”. So, “leo, observations, power, thou, dart, emergency, notorious” outputs “osrutys”. Q: “leo, observations, power, thou, dart, emergency, notorious, indulging” +A: “leo, observations, power, thou, dart, emergency, notorious” outputs “osrutys”. The last letter of “indulging” is “g”. Concatenating: “osrutys”, “g” leads to “osrutysg”. So, “leo, observations, power, thou, dart, emergency, notorious, indulging” outputs “osrutysg”. + +Q: “leo, observations, power, thou, dart, emergency, notorious, indulging, consume” A: “leo, observations, power, thou, dart, emergency, notorious, indulging” outputs “osrutysg”. The last letter of “consume” is “e”. Concatenating: “osrutysg”, “e” leads to “osrutysge”. So, “leo, observations, power, thou, dart, emergency, notorious, indulging, consume” outputs “osrutysge”. + +Q: “leo, observations, power, thou, dart, emergency, notorious, indulging, consume, provoke” A: “leo, observations, power, thou, dart, emergency, notorious, indulging, consume” outputs “osrutysge”. The last letter of “provoke” is “e”. Concatenating: “osrutysge”, “e” leads to “osrutysgee”. So, “leo, observations, power, thou, dart, emergency, notorious, indulging, consume, provoke” outputs “osrutysgee”. + +“niece, greedy, anything, retain, moisture, jest, adrian, attic, hugo, accurate, wet, howard” + +Golden: “eygnetncoetd” + +# Solution: + +Q: “niece, greedy” +A: The last letter of “niece” is “e”. The last letter of “greedy” is “y”. Concatenating: “e”, “y” leads to “ey”. So, “niece, greedy” outputs “ey”. Q: “niece, greedy, anything” +A: “niece, greedy” outputs “ey”. The last letter of “anything” is “g”. Concatenating: “ey”, “g” leads to “eyg”. So, “niece, greedy, anything” outputs “eyg”. Q: “niece, greedy, anything, retain” +A: “niece, greedy, anything” outputs “eyg”. The last letter of “retain” is “n”. Concatenating: “eyg”, “n” leads to “eygn”. So, “niece, greedy, anything, retain” outputs “eygn”. + +Q: “niece, greedy, anything, retain, moisture” A: “niece, greedy, anything, retain” outputs “eygn”. The last letter of “moisture” is “e”. Concatenating: “eygn”, “e” leads to “eygne”. So, “niece, greedy, anything, retain, moisture” outputs “eygne”. + +Q: “niece, greedy, anything, retain, moisture, jest” +A: “niece, greedy, anything, retain, moisture” outputs “eygne”. The last letter of “jest” is “t”. Concatenating: “eygne”, “t” leads to “eygnet”. So, “niece, greedy, anything, retain, moisture, jest” outputs “eygnet”. + +Q: “niece, greedy, anything, retain, moisture, jest, adrian” + +A: “niece, greedy, anything, retain, moisture, jest” outputs “eygnet”. The last letter of “adrian” is “n”. Concatenating: “eygnet”, “n” leads to “eygnetn”. So, “niece, greedy, anything, retain, moisture, jest, adrian” outputs “eygnetn”. + +Q: “niece, greedy, anything, retain, moisture, jest, adrian, attic” +A: “niece, greedy, anything, retain, moisture, jest, adrian” outputs “eygnetn”. The last letter of “attic” is “c”. Concatenating: “eygnetn”, “c” leads to “eygnetnc”. So, “niece, greedy, anything, retain, moisture, jest, adrian, attic” outputs “eygnetnc”. Q: “niece, greedy, anything, retain, moisture, jest, adrian, attic, hugo” +A: “niece, greedy, anything, retain, moisture, jest, adrian, attic” outputs “eygnetnc”. The last letter of “hugo” is “o”. Concatenating: “eygnetnc”, “o” leads to “eygnetnco”. So, “niece, greedy, anything, retain, moisture, jest, adrian, attic, hugo” outputs “eygnetnco”. + +Q: “niece, greedy, anything, retain, moisture, jest, adrian, attic, hugo, accurate” A: “niece, greedy, anything, retain, moisture, jest, adrian, attic, hugo” outputs “eygnetnco”. The last letter of “accurate” is “e”. Concatenating: “eygnetnco”, “e” leads to “eygnetncoe”. So, “niece, greedy, anything, retain, moisture, jest, adrian, attic, hugo, accurate” outputs “eygnetncoe”. + +Q: “niece, greedy, anything, retain, moisture, jest, adrian, attic, hugo, accurate, wet” A: “niece, greedy, anything, retain, moisture, jest, adrian, attic, hugo, accurate” outputs “eygnetncoe”. The last letter of “wet” is “t”. Concatenating: “eygnetncoe”, “t” leads to “eygnetncoet”. So, “niece, greedy, anything, retain, moisture, jest, adrian, attic, hugo, accurate, wet” outputs “eygnetncoet”. + +Q: “niece, greedy, anything, retain, moisture, jest, adrian, attic, hugo, accurate, wet, howard” A: “niece, greedy, anything, retain, moisture, jest, adrian, attic, hugo, accurate, wet” outputs “eygnetncoet”. The last letter of “howard” is “d”. Concatenating: “eygnetncoet”, “d” leads to “eygnetncoetd”. So, “niece, greedy, anything, retain, moisture, jest, adrian, attic, hugo, accurate, wet, howard” outputs “eygnetncoetd”. + +7.5.5 LEAST-TO-MOST PROMPTING: FAILURE “supper, procession, region, ruby” + +Golden: “rnny” + +# Solution: + +Q: “supper, procession” +A: The last letter of “supper” is “r”. The last letter of “procession” is “n”. Concatenating: “r”, “n” leads to “rn”. So, “supper, procession” outputs “rn”. Q: “supper, procession, region” +A: “supper, procession” outputs “rn”. The last letter of “region” is “n”. Concatenating: “rn”, “n” leads to “rnn”. So, “supper, procession, region” outputs “rnn”. Q: “supper, procession, region, ruby” +A: “supper, procession, region” outputs “rnn”. The last letter of “ruby” is “y”. Concatenating: “rnn”, “y” leads to “rnnn”. So, “supper, procession, region, ruby” outputs “rnnn”. + +“release, appeared, endure, field, render, monk” + +Golden: “ededrk” + +# Solution: + +Q: “release, appeared” A: The last letter of “release” is “e”. The last letter of “appeared” is “d”. Concatenating: “e”, “d” leads + +to “ed”. So, “release, appeared” outputs “ed”. + +Q: “release, appeared, endure” +A: “release, appeared” outputs “ed”. The last letter of “endure” is “e”. Concatenating: “ed”, “e” leads to “ede”. So, “release, appeared, endure” outputs “ede”. Q: “release, appeared, endure, field” +A: “release, appeared, endure” outputs “ede”. The last letter of “field” is “d”. Concatenating: “ede”, “d” leads to “eded”. So, “release, appeared, endure, field” outputs “eded”. + +Q: “release, appeared, endure, field, render” A: “release, appeared, endure, field” outputs “eded”. The last letter of “render” is “r”. Concatenating: “eded”, “r” leads to “ededer”. So, “release, appeared, endure, field, render” outputs “ededer”. + +Q: “release, appeared, endure, field, render, monk” +A: “release, appeared, endure, field, render” outputs “ededer”. The last letter of “monk” is “k”. Concatenating: “ededer”, “k” leads to “edederk”. So, “release, appeared, endure, field, render, monk” outputs “edederk”. + +“mentally, uncomfortable, amount, straight, whatsoever, deference, channel, integrity” + +Golden: “yettrely” + +# Solution: + +Q: “mentally, uncomfortable” +A: The last letter of “mentally” is “y”. The last letter of “uncomfortable” is “e”. Concatenating: “y”, “e” leads to “ye”. So, “mentally, uncomfortable” outputs “ye”. Q: “mentally, uncomfortable, amount” +A: “mentally, uncomfortable” outputs “ye”. The last letter of “amount” is “t”. Concatenating: “ye”, “t” leads to “yet”. So, “mentally, uncomfortable, amount” outputs “yet”. + +Q: “mentally, uncomfortable, amount, straight” A: “mentally, uncomfortable, amount” outputs “yet”. The last letter of “straight” is “t”. Concatenating: “yet”, “t” leads to “yett”. So, “mentally, uncomfortable, amount, straight” outputs “yett”. + +Q: “mentally, uncomfortable, amount, straight, whatsoever” +A: “mentally, uncomfortable, amount, straight” outputs “yett”. The last letter of “whatsoever” is “r”. Concatenating: “yett”, “r” leads to “yettar”. So, “mentally, uncomfortable, amount, straight, whatsoever” outputs “yettar”. Q: “mentally, uncomfortable, amount, straight, whatsoever, deference” +A: “mentally, uncomfortable, amount, straight, whatsoever” outputs “yettar”. The last letter of “deference” is “e”. Concatenating: “yettar”, “e” leads to “yettare”. So, “mentally, uncomfortable, amount, straight, whatsoever, deference” outputs “yettare”. + +Q: “mentally, uncomfortable, amount, straight, whatsoever, deference, channel” A: “mentally, uncomfortable, amount, straight, whatsoever, deference” outputs “yettare”. The last letter of “channel” is “l”. Concatenating: “yettare”, “l” leads to “yettarel”. So, “mentally, uncomfortable, amount, straight, whatsoever, deference, channel” outputs “yettarel”. + +Q: “mentally, uncomfortable, amount, straight, whatsoever, deference, channel, integrity” A: “mentally, uncomfortable, amount, straight, whatsoever, deference, channel” outputs “yettarel”. The last letter of “integrity” is “y”. Concatenating: “yettarel”, “y” leads to “yettarely”. So, “mentally, uncomfortable, amount, straight, whatsoever, deference, channel, integrity” outputs “yettarely”. + +“complexion, criminal, assume, seven, driver, hero, horse, purpose, zeus, joint” + +# Golden: + +“nlenroeest” + +# Solution: + +Q: “complexion, criminal” +A: The last letter of “complexion” is “n”. The last letter of “criminal” is “l”. Concatenating: “n”, “l” leads to “nl”. So, “complexion, criminal” outputs “nl”. Q: “complexion, criminal, assume” +A: “complexion, criminal” outputs “nl”. The last letter of “assume” is “e”. Concatenating: “nl”, “e” leads to “nle”. So, “complexion, criminal, assume” outputs “nle”. + +Q: “complexion, criminal, assume, seven” A: “complexion, criminal, assume” outputs “nle”. The last letter of “seven” is “n”. Concatenating: “nle”, “n” leads to “nlen”. So, “complexion, criminal, assume, seven” outputs “nlen”. + +Q: “complexion, criminal, assume, seven, driver” A: “complexion, criminal, assume, seven” outputs “nlen”. The last letter of “driver” is “r”. Concatenating: “nlen”, “r” leads to “nlenr”. So, “complexion, criminal, assume, seven, driver” outputs “nlenr”. + +Q: “complexion, criminal, assume, seven, driver, hero” +A: “complexion, criminal, assume, seven, driver” outputs “nlenr”. The last letter of “hero” is “o”. Concatenating: “nlenr”, “o” leads to “nlenro”. So, “complexion, criminal, assume, seven, driver, hero” outputs “nlenro”. Q: “complexion, criminal, assume, seven, driver, hero, horse” +A: “complexion, criminal, assume, seven, driver, hero” outputs “nlenro”. The last letter of “horse” is “e”. Concatenating: “nlenro”, “e” leads to “nlenroe”. So, “complexion, criminal, assume, seven, driver, hero, horse” outputs “nlenroe”. Q: “complexion, criminal, assume, seven, driver, hero, horse, purpose” +A: “complexion, criminal, assume, seven, driver, hero, horse” outputs “nlenroe”. The last letter of “purpose” is “e”. Concatenating: “nlenroe”, “e” leads to “nlenroee”. So, “complexion, criminal, assume, seven, driver, hero, horse, purpose” outputs “nlenroee”. + +Q: “complexion, criminal, assume, seven, driver, hero, horse, purpose, zeus” A: “complexion, criminal, assume, seven, driver, hero, horse, purpose” outputs “nlenroee”. The last letter of “zeus” is “s”. Concatenating: “nlenroee”, “s” leads to “nlenroees”. So, “complexion, criminal, assume, seven, driver, hero, horse, purpose, zeus” outputs “nlenroees”. + +Q: “complexion, criminal, assume, seven, driver, hero, horse, purpose, zeus, joint” A: “complexion, criminal, assume, seven, driver, hero, horse, purpose, zeus” outputs “nlenroees”. The last letter of “joint” is “t”. Concatenating: “nlenroees”, “t” leads to “nlenroeast”. So, “complexion, criminal, assume, seven, driver, hero, horse, purpose, zeus, joint” outputs “nlenroeast”. + +“provoked, columbia, sir, principal, seven, extreme, timothy, submitted, considered, spies, dost, treasury” + +Golden: “darlneyddsty” + +# Solution: + +Q: “provoked, columbia” +A: The last letter of “provoked” is “d”. The last letter of “columbia” is “a”. Concatenating: “d”, “a” leads to “da”. So, “provoked, columbia” outputs “da”. Q: “provoked, columbia, sir” +A: “provoked, columbia” outputs “da”. The last letter of “sir” is “r”. Concatenating: “da”, “r” leads to “dar”. So, “provoked, columbia, sir” outputs “dar”. + +Q: “provoked, columbia, sir, principal” A: “provoked, columbia, sir” outputs “dar”. The last letter of “principal” is “l”. Concatenating: “dar”, “l” + +leads to “darl”. So, “provoked, columbia, sir, principal” outputs “darl”. + +Q: “provoked, columbia, sir, principal, seven” A: “provoked, columbia, sir, principal” outputs “darl”. The last letter of “seven” is “n”. Concatenating: “darl”, “n” leads to “darln”. So, “provoked, columbia, sir, principal, seven” outputs “darln”. + +Q: “provoked, columbia, sir, principal, seven, extreme” +A: “provoked, columbia, sir, principal, seven” outputs “darln”. The last letter of “extreme” is “e”. Concatenating: “darln”, “e” leads to “darle”. So, “provoked, columbia, sir, principal, seven, extreme” outputs “darle”. Q: “provoked, columbia, sir, principal, seven, extreme, timothy” +A: “provoked, columbia, sir, principal, seven, extreme” outputs “darle”. The last letter of “timothy” is “y”. Concatenating: “darle”, “y” leads to “darley”. So, “provoked, columbia, sir, principal, seven, extreme, timothy” outputs “darley”. Q: “provoked, columbia, sir, principal, seven, extreme, timothy, submitted” +A: “provoked, columbia, sir, principal, seven, extreme, timothy” outputs “darley”. The last letter of “submitted” is “d”. Concatenating: “darley”, “d” leads to “darleyd”. So, “provoked, columbia, sir, principal, seven, extreme, timothy, submitted” outputs “darleyd”. + +Q: “provoked, columbia, sir, principal, seven, extreme, timothy, submitted, considered” A: “provoked, columbia, sir, principal, seven, extreme, timothy, submitted” outputs “darleyd”. The last letter of “considered” is “d”. Concatenating: “darleyd”, “d” leads to “darleydd”. So, “provoked, columbia, sir, principal, seven, extreme, timothy, submitted, considered” outputs “darleydd”. + +Q: “provoked, columbia, sir, principal, seven, extreme, timothy, submitted, considered, spies” A: “provoked, columbia, sir, principal, seven, extreme, timothy, submitted, considered” outputs “darleydd”. The last letter of “spies” is “s”. Concatenating: “darleydd”, “s” leads to “darleydds”. So, “provoked, columbia, sir, principal, seven, extreme, timothy, submitted, considered, spies” outputs “darleydds”. + +Q: “provoked, columbia, sir, principal, seven, extreme, timothy, submitted, considered, spies, dost” + +A: “provoked, columbia, sir, principal, seven, extreme, timothy, submitted, considered, spies” outputs “darleydds”. The last letter of “dost” is “t”. Concatenating: “darleydds”, “t” leads to “darleyddst”. So, “provoked, columbia, sir, principal, seven, extreme, timothy, submitted, considered, spies, dost” outputs “darleyddst”. + +Q: “provoked, columbia, sir, principal, seven, extreme, timothy, submitted, considered, spies, dost, treasury” + +A: “provoked, columbia, sir, principal, seven, extreme, timothy, submitted, considered, spies, dost” outputs “darleyddst”. The last letter of “treasury” is “y”. Concatenating: “darleyddst”, “y” leads to “darleyddsty”. So, “provoked, columbia, sir, principal, seven, extreme, timothy, submitted, considered, spies, dost, treasury” outputs “darleyddsty”. + +# 8 SCAN + +# 8.1 PROMPT CONTEXTS + +In this section we present the prompt contexts used for the SCAN benchmark in Section 3.2. It includes one context for each of standard prompting, least-to-most prompting, and chain-of-thought prompting. + +# 8.1.1 STANDARD PROMPTING + +The context for standard prompting consist of a set of commands together with the corresponding action sequences. + +Q: “turn left” +A: “TURN LEFT” +Q: “turn right” +A: “TURN RIGHT” +Q: “jump left” +A: “TURN LEFT” $^ +$ “JUMP” +Q: “run right” +A: “TURN RIGHT” $^ +$ “RUN” +Q: “look twice” +A: “LOOK” \* 2 +Q: “run and look twice” +A: “RUN” $^ +$ “LOOK” \* 2 +Q: “jump right thrice” +A: (“TURN RIGHT” $^ +$ “JUMP”) \* 3 +Q: “walk after run” +A: “RUN” $^ +$ “WALK” +Q: “turn opposite left” +A: “TURN LEFT” \* 2 +Q: “turn around left” +A: “TURN LEFT” \* 4 +Q: “turn opposite right” +A: “TURN RIGHT” \* 2 +Q: “turn around right” +A: “TURN RIGHT” \* 4 +Q: “walk opposite left” +A: “TURN LEFT” $^ { \star } \boldsymbol { \sf { Z } } +$ “WALK” +Q: “walk around left” +A: (“TURN LEFT” $^ +$ “WALK”) \* 4 + +# 8.1.2 LEAST-TO-MOST PROMPTING + +For least-to-most prompting, we need 2 different prompt contexts: one to decompose commands into a sequence of components and one to map commands to actions. + +Command mapping. The command mapping prompt context consists of a set of commands together with the corresponding action sequences and explanations of how they were obtained. + +Q: “turn left” +A: “turn left” outputs “TURN LEFT”. Q: “turn right” +A: “turn right” outputs “TURN RIGHT”. + +Q: “jump left” + +A: The output of “jump left” concatenates: the output of “turn left”, the output of “jump”. “turn left” outputs “TURN LEFT”. “jump” outputs “JUMP”. So concatenating the output of “turn left” and the output of “jump” leads to “TURN LEFT” $^ +$ “JUMP”. So the output of “jump left” is “TURN LEFT” $^ +$ “JUMP”. + +Q: “run right” + +A: The output of “run right” concatenates: the output of “turn right”, the output of “run”. “turn right” outputs “TURN RIGHT”. “run” outputs “RUN”. So concatenating the output of “turn right” and the output of “run” leads to “TURN RIGHT” $^ +$ “RUN”. So the output of “run right” is “TURN RIGHT” $^ +$ “RUN”. + +Q: “look twice” + +A: The output of “look twice” concatenates: the output of “look”, the output of “look”. “look” outputs “LOOK”. So repeating the output of “look” two times leads to “LOOK” \* 2. So the output of “look twice” is “LOOK” $^ { \star } 2$ . + +Q: “run and look twice” + +A: The output of “run and look twice” concatenates: the output of “run”, the output of “look twice”. “run” outputs “RUN”. “look twice” outputs “LOOK” \* 2. So concatenating the output of “run” and the output of “look twice” leads to “RUN” $^ +$ “LOOK” $^ { \star } \sf { 2 }$ . So the output of “run and look twice” is “RUN” $^ +$ “LOOK” \* 2. + +Q: “jump right thrice” + +A: The output of “jump right thrice” concatenates: the output of “jump right”, the output of “jump right”, the output of “jump right”. “jump right” outputs “TURN RIGHT” $^ +$ “JUMP”. So repeating the output of “jump right” three times leads to (“TURN RIGHT” $^ +$ “JUMP”) $\star _ { 3 }$ . So the output of “jump right thrice” is (“TURN RIGHT” $^ +$ “JUMP”) $^ { \star } 3$ . + +Q: “walk after run” + +A: The output of “walk after run” concatenates: the output of “run”, the output of “walk”. “run” outputs “RUN”. “walk” outputs “WALK”. So concatenating the output of “run” and the output of “walk” leads to “RUN” $^ +$ “WALK”. So the output of “walk after run” is “RUN” $^ +$ “WALK”. + +Q: “turn opposite left” + +A: The output of “turn opposite left” concatenates: the output of “turn left”, the output of “turn left”. “turn left” outputs “TURN LEFT”. So repeating the output of “turn left” twice leads to “TURN LEFT” \* 2. So the output of “turn opposite left” is “TURN LEFT” $^ \star 2$ . + +Q: “turn around left” + +A: The output of “turn around left” concatenates: the output of “turn left”, the output of “turn left”, the output of “turn left”, the output of “turn left”. “turn left” outputs “TURN LEFT”. So repeating the output of “turn left” four times leads to “TURN LEFT” \* 4. So the output of “turn around left” is “TURN LEFT” $\star _ { 4 }$ . + +Q: “turn opposite right” + +A: The output of “turn opposite right” concatenates: the output of “turn right”, the output of “turn right”. “turn right” outputs “TURN RIGHT”. So repeating the output of “turn right” twice leads to “TURN RIGHT” $^ { \star } 2$ . So the output of “turn opposite right” is “TURN RIGHT” $^ \star 2$ . + +Q: “turn around right” + +A: The output of “turn around right” concatenates: the output of “turn right”, the output of “turn right”, the output of “turn right”, the output of “turn right”. “turn right” outputs “TURN RIGHT”. So repeating the output of “turn right” four times leads to “TURN RIGHT” $\star _ { 4 }$ . So the output of “turn around right” is “TURN RIGHT” \* 4. + +Q: “walk opposite left” + +A: The output of “walk opposite left” concatenates: the output of “turn opposite left”, the output of “walk”. “turn opposite left” outputs “TURN LEFT” \* 2. “walk” outputs “WALK”. So concatenating the output of “turn opposite left” and the output of “walk” leads to “TURN LEFT” $^ \star \sf { 2 } +$ “WALK”. So the output of “walk opposite left” is “TURN LEFT” $^ { \star } \boldsymbol { \sf { Z } } +$ “WALK”. + +Q: “walk around left” + +A: The output of “walk around left” concatenates: the output of “walk left”, the output of “walk left”, the output of “walk left”, the output of “walk left”. “walk left” outputs “TURN LEFT” $^ +$ “WALK”. So repeating the output of “walk around left” four times leads to (“TURN LEFT” $^ +$ “WALK”) $\times 4$ . So the output of “walk around left” is (“TURN LEFT” $^ +$ “WALK”) $\star _ { 4 }$ . + +Command decomposition. The command decomposition prompt context consists of a set of commands together with the corresponding sequence of decomposed commands. + +Q: “look right after look twice” + +A: “look right after look twice” can be solved by: “look right”, “look twice”. + +Q: “jump opposite right thrice and walk” + +A: “jump opposite right thrice” can be solved by: “jump opposite right”, “jump opposite right thrice”. “walk” can be solved by: “walk”. So, “jump opposite right thrice and walk” can be solved by: “jump opposite right”, “jump opposite right thrice”, “walk”. + +Q: “run left twice and run right” + +A: “run left twice” can be solved by: “run left”, “run left twice”. “run right” can be solved by “run right”. +So, “run left twice and run right” can.be solved by: “run left”, “run left twice”, “run right”. + +Q: “run opposite right” + +A: “run opposite right” can be solved by “run opposite right”. + +Q: “look opposite right thrice after walk” + +A: “look opposite right thrice” can be solved by: “look opposite right”, “look opposite right thrice”. “walk” can be solved by “walk”. So, “look opposite right thrice after walk” can be solved by: “look opposite right”, “look opposite right thrice”, “walk”. + +Q: “jump around right” + +A: “jump around right” can be solved by: “jump right”, “jump around right”. So, “jump around right” can be solved by: “jump right”, “jump around right”. + +Q: “look around right thrice and walk” + +A: “look around right thrice” can be solved by: “look right”, “look around right”, “look around right thrice”. “walk” can be solved by “walk”. So, “look around right thrice and walk” can be solved by: “look right”, “look around right”, “look around right thrice”, “walk”. + +Q: “turn right after run right thrice” + +A: “turn right” can be solved by: “turn right”. “run right thrice” can be solved by: “run right”, “run right thrice”. So, “turn right after run right thrice” can be solved by: “turn right”, “run right”, “run right thrice”. + +# 8.1.3 CHAIN-OF-THOUGHT PROMPTING + +We reuse the command mapping prompt context from least-to-most prompting shown above. + +8.2 ERROR ANALYSIS: LEAST-TO-MOST PROMPTING + +For least-to-most prompting, we analyzed 20 random failures for the models code-davinci-001 and text-davinci-002, and we analyzed all 13 errors for the model code-davinci-002. The results are shown in Table 15. Errors may either occur during command decomposition or during command translation. The translation errors are further split into the following types. Incorrect interpretation of “twice” and “thrice” means that the model made an error when applying “twice” and “thrice” to an expression. “After” interpreted as “and” means that the model translated an expression containing “after” as if it instead contained “and”. Copy error means that the model made a mistake when copying an intermediate result. + +
Error typecode-002code-001text-002
Decomposition error071
Incorrect interpretation of"twice" and “thrice"- Following “around”- Following“opposite”- Other661016151
334
00
"after” interpreted as“and”740
Incorrect interpretation of"left”and "right"004
Copy error040
+ +Table 15: Least-to-most prompting error analysis of 20 random failures for the models code-davinci-001 and text-davinci-002 and all 13 errors for the model code-davinci-002. Note that for some examples, the model made more than one type of error. + +We observe that the best model text-davinci-002 made only 2 types of mistakes: it sometimes makes a mistake when applying “twice” and “thrice” to an expression containing “around”, and it sometimes interprets “after” as “and”. For text-davinci-001, which is the older version of the same model, the errors are spread across all types. In particular, it’s worth noting that text-davinci-001 makes a significant number of decomposition errors and copy errors that were completely eliminated by its successor. + +The model text-davinci-002 made most of its mistakes when interpreting “twice” and “thrice” following “around”. In addition, it sometimes made a mistake when translating “left” and “right”, which is something we did not observe with the other models. In some cases, it dropped the command entirely, whereas in other cases it invented a new action such as “LOOK LEFT” (see examples below). + +Examples of decomposition errors. In the example “run around left twice after jump around right thrice”, the code-davinci-001 model does not properly decompose the sub-expression “run around left twice”. Instead of decomposing it to the sequence [“run left”, “run around left”, “run around left twice”], it skips “run around left” and decomposes it to [“run left”, “run around left twice”]. Consequently, the model translates this sub-expression to (“TURN LEFT” $^ +$ “RUN”) $^ { * } 2$ instead of (“TURN LEFT” $+ \mathrm { \bf \ddot { \delta } R U N } ^ { , * } ) \mathrm { \bf \ddot { \delta } } 4 \mathrm { \bf \ddot { \delta } } 2$ . + +In the example “look around right twice after jump around left twice”, the code-davinci-001 model does not properly decompose the sub-expression “jump around left twice”. Instead of decomposing it to the sequence [“jump left”, “jump around left”, “jump around left twice”], it skips “jump around left” and decomposes it to [“jump left”, “jump around left twice”]. Interestingly, the model is able to recover from this mistake and correctly translates the sub-expression to (“TURN LEFT” $+ \ { } ^ { } \mathbf { J } \mathbf { U } \mathbf { M } \mathbf { P } ^ { \prime \prime } ) \ast \ 4 \ ^ { * } \ 2$ , but still produces the wrong final action sequence because it interprets “after” like “and”. + +Examples of incorrect interpretation of “twice” and “thrice”. In the example “walk opposite right twice after run around right thrice”, the code-davinci-002 model correctly translates the expression “run around right” to (“TURN RIGH $\mathrm { [ T ^ { 9 } + \Sigma ^ { 6 6 } }$ RUN”) $\ast ~ 4$ . Then it makes a mistake when applying “thrice” to this expression and produces (“TURN RIGHT” $^ +$ “RUN”) $\ast 9$ instead of (“TURN RIGHT” $^ +$ “RUN”) $* 4 * 3$ or (“TURN RIGHT” $^ +$ “RUN”) $\ast _ { 1 2 }$ . + +In the example “jump opposite right twice and jump around right thrice”, the code-davinci-002 model correctly translates the expression “jump around right” to (“ $\mathrm { T U R N \mathrm { \mathrm { . R I G H T ^ { 3 } + \mathrm { ^ { 4 } J U M P } } } }$ ”) $\ast 4$ . Then it makes a mistake when applying “thrice” to this expression and produces ( $\mathrm { ^ { 4 9 } T U R N . R I G H T ^ { 3 } + ^ { 4 9 } J U M P ^ { 3 } ) \ ^ { \ast } \ 8 }$ instead of (“TURN RIG $\mathrm { i H T ^ { } + \Phi ^ { } J U M P ^ { } }$ ) $^ * 4$ $\ast _ { 3 }$ or (“TURN RIGHT” $\mathbf { + \Sigma ^ { } J U M P ^ { } } ) \ast 1 2$ . + +In the example “walk around left thrice after run opposite left thrice”, the code-davinci-001 model correctly translates the expression “run opposite left” to “TURN LEFT” $^ { \ast } 2 +$ “RUN”. Then it makes a mistake when applying “thrice” to this expression and produces “TURN LEFT” $* \geq +$ “RUN” $^ \ast 3$ instead of (“TURN LEFT” $^ { * } 2 + ^ { * } \mathrm { R U N } ^ { , * } ) \ ^ { * } 3$ . + +In the example “walk around left thrice after look right twice”, the code-davinci-001 model correctly translates the expression “look right” to “TURN RIGHT” $^ +$ “LOOK”. Then it makes a mistake when applying “twice” to this expression and produces “TURN RIGHT” $^ +$ “LOOK” $^ { * } 2$ rather than (“TURN RIGHT” $^ +$ “LOOK”) $^ { * } 2$ . + +In the example “walk left and run around right thrice”, the code-davinci-001 model interprets “thrice” as ‘twice”. This means that it produces “TURN LEFT” $^ +$ “WALK” $^ +$ (“TURN RIGHT” $^ +$ “RUN”) $* 4 * 2$ instead of “TURN LEFT” $^ +$ “WALK” $^ +$ (“TURN RIGHT” $^ +$ “RUN”) $* 4 * 3$ . + +In the example “jump right twice and look around left thrice”, the text-davinci-002 model correctly translates the sub-expression “look around left” to (“TURN LEFT” ${ \bf \tau } + { \bf \tilde { \tau } } \mathrm { L O O K ^ { 3 3 } } ) \ ^ { * } \ 4 .$ . But when applying “thrice”, it produces the incorrect translation (“TURN LEFT” $^ +$ “LOOK”) $\ast _ { 3 }$ instead of (“TURN LEFT” $^ +$ “LOOK”) $* 4 * 3$ . + +Example of interpreting “after” as “and”. In the example “run opposite left thrice after run around left twice”, the code-davinci-002 model produces the correct translations for both sub-expressions that are connected by “after”, but it combines them as if they were connected by “and”. This means that the model produces (“TURN LEFT” $^ { \ast } 2 +$ “RUN”) $^ { \ast } 3 +$ (“TURN LEFT” $+ \mathrm { ^ { * } R U N ^ { * } } ) \ast 4 \ast 2$ instead of (“TURN LEFT” $^ +$ “RUN”) $^ { * } 4 ^ { * } 2 +$ (“TURN LEFT” $^ { * } 2 + ^ { * } \mathrm { R U N } ^ { \prime \prime } ) ^ { * }$ 3. + +In the example “walk around left thrice after walk twice”, the code-davinci-002 model produces the correct translations for both sub-expressions that are connected by “after”, but it combines them as if they were connected by “and”. This means that the model produces (“TURN LEFT” $^ +$ “WALK”) $* 4 * 3 + \mathrm { \ddot { } W A L K ^ { \prime * } } 2$ instead of “WALK” $^ { \ast } 2 +$ (“TURN LEFT $\mathrm { } ^ { 5 } + \mathrm { } ^ { 6 6 } \mathrm { W }$ ALK”) $* 4 * 3$ . + +In the example “look around right twice after jump around left twice”, the code-davinci-001 model produces the correct translations for both sub-expressions that are connected by “after”, but it combines them as if they were connected by “and”. This means that the model produces (“TU $\mathrm { 2 N . R I G H T ^ { \prime \prime } + ^ { } L O O K ^ { \prime \prime } ) ^ { \ast } }$ $* _ { \mathrm { ~ 4 ~ } ^ { * } \mathrm { ~ 2 ~ + ~ } }$ (“ $\mathrm { \Delta T U R N \mathrm { { \_ L E F T ^ { \prime \prime } } } + \Sigma ^ { } J U M P ^ { \prime \prime } } ) * 4 * 2$ instead of (“TURN LEFT” $^ +$ “JUMP” $\rangle * 4 * 2 + ( ^ { \mathrm { * * } } \mathrm { T U R N \mathrm { . R I G H T ^ { \prime \prime } } } + ^ { \mathrm { * } } \mathrm { L O O K ^ { \prime \prime } } ) * 4 * 2$ . + +Examples of incorrect interpretation of “left” and “right”. In the example “look opposite right thrice after look around left thrice”, the text-davinci-002 model translates the component “look left” to “LOOK” instead of “TURN LEFT LOOK”. As a consequence, the whole command is translated to “LOOK” $^ { * } 4 ^ { * } 3 +$ (“TURN RIGHT” $\mathrm { ~ } ^ { * } 2 + \mathrm { ~ } ^ { * } \mathrm { { T O O K } } ^ { , * } ) \mathrm { ~ } ^ { * } 3$ instead of (“TURN LEFT” $+ ^ { \cdot \mathrm { { c } } } \mathrm { { L O O K ^ { \prime \prime } } } ) * 4 * 3 + ( ^ { \cdot \mathrm { { c } } } \mathrm { { T U R N } } . \mathrm { { R I G H T ^ { \prime \prime } } } * 2 + ^ { \cdot } \mathrm { { L O O K ^ { \prime \prime } } } ) * 3 .$ + +In the example “turn around right thrice after look around left twice”, the text-davinci-002 model makes up the new action “LOOK LEFT” as the translation of the component “look left”. As a consequence, it translates the whole command to (“LOOK LEFT” $\ast 4$ ) $^ { \ast } 2 +$ (“TURN RIGHT” \* $4 ) \ast 3$ instead of (“TURN LEFT $" + "$ “LOOK”) $^ { * } 4 ^ { * } 2 +$ (“TURN RIGHT” \* 4) \* 3. + +Example of copy error. In the example “walk opposite right twice after look around left thrice”, the code-davinci-001 model produces the correct translations for both sub-expressions that are connected with “after”. In particular, it correctly translates “walk opposite right twice” to (“TURN RIGHT” $^ { * } 2 + ^ { \ } \mathrm { W A L K ^ { \prime \prime } } ) ^ { * } 2$ . Then it makes two mistakes when combining them: it treats “after” like an “and”, and it omits the parenthesis when copying the expression (“TURN RIGHT” $* 2 + \mathrm { \cdots W A L K ^ { \prime \prime } } ) * 2$ . This means that the model produces the translation “TURN RIGHT” $^ { \ast } 2 +$ “WALK” $2 + ( \mathrm { ^ { * * } T U R N \underline { { { L E F T ^ { * * } } } } + \mathrm { ^ { * } L O O K ^ { * * } } } ) * 4 * 3 ^ { , }$ instead of (“TURN LEFT” $^ +$ “LOOK”) $* 4 *$ $^ { 3 + }$ (“TURN RIGHT” $^ { \ast } 2 +$ “WALK”) $^ { * } 2$ . + +# 8.3 EXAMPLE OUTPUTS FROM CODE-DAVINCI-002 + +In this section, we present 5 examples of successes and failures of the code-davinci-002 model for chain-of-thought prompting and least-to-most prompting. + +# 8.3.1 CHAIN-OF-THOUGHT PROMPTING: SUCCESS + +# “jump around left twice after walk opposite left thrice” + +# Golden: + +TURN LEFT TURN LEFT WALK TURN LEFT TURN LEFT WALK TURN LEFT TURN LEFT WALK + +# TURN LEFT JUMP TURN LEFT JUMP TURN LEFT JUMP TURN LEFT JUMP TURN LEFT JUMP TURN LEFT JUMP TURN LEFT JUMP TURN LEFT JUMP + +# Solution: + +Q: “jump around left twice after walk opposite left thrice” +A: The output of “jump around left twice after walk opposite left thrice” concatenates: the output of “walk opposite left thrice”, the output of “jump around left twice”. “walk opposite left thrice” outputs (“TURN LEFT” $^ { \star } 2 + ^ { \circ } \mathsf { W A L K } ^ { \prime \prime } ) ^ { \star } 3$ . “jump around left twice” outputs (“TURN LEFT” $^ +$ “JUMP”) $\star _ { 4 } \star _ { 2 }$ . So concatenating the output of “walk opposite left thrice” and the output of “jump around left twice” leads to (“TURN LEFT” $\star 2 + \ " W A L K ^ { , , }$ ) $^ { \star } 3 +$ (“TURN LEFT” $^ +$ “JUMP”) $\star _ { 4 } \star _ { 2 }$ . So the output of “jump around left twice after walk opposite left thrice” is (“TURN LEFT” $^ { \star } 2 + ^ { \mathfrak { s o } } \mathsf { W A L K } ^ { \mathfrak { s } }$ ) $^ { \star } \sf { 3 } +$ (“TURN LEFT” ${ } + \mathsf { \Pi } ^ { \mathsf { J } } \mathsf { U } \mathsf { M } \mathsf { P } ^ { \mathfrak { w } } ) ^ { \mathrm { ~ \star ~ } } 4 ^ { \mathrm { ~ \star ~ } } 2$ . + +# “walk around left twice and turn around right thrice” + +# Golden: + +TURN LEFT WALK TURN LEFT WALK TURN LEFT WALK TURN LEFT WALK TURN LEFTWALK TURN LEFT WALK TURN LEFT WALK TURN LEFT WALK TURN RIGHT TURN RIGHTTURN RIGHT TURN RIGHT TURN RIGHT TURN RIGHT TURN RIGHT TURN RIGHTTURN RIGHT TURN RIGHT TURN RIGHT TURN RIGHT + +# Solution: + +Q: “walk around left twice and turn around right thrice” +A: The output of “walk around left twice and turn around right thrice” concatenates: the output of “walk around left”, the output of “walk around left”, the output of “turn around right”, the output of “turn around right”, the output of “turn around right”. “walk around left” outputs (“TURN LEFT” $^ +$ “WALK”) \* 4. “turn around right” outputs “TURN RIGHT” $\star _ { 4 }$ . So concatenating the output of “walk around left”, the output of “walk around left”, the output of “turn around right”, the output of “turn around right”, the output of “turn around right” leads to (“TURN LEFT” $^ +$ “WALK”) $\times 4 +$ (“TURN LEFT” $^ +$ “WALK”) \* 4 $^ +$ “TURN RIGHT” $\star 4 +$ “TURN RIGHT” $\times 4 +$ “TURN RIGHT” \* 4. So the output of “walk around left twice and turn around right thrice” is (“TURN LEFT” $^ +$ “WALK”) $\star _ { 4 + }$ (“TURN LEFT” $^ +$ “WALK”) $\star _ { 4 + }$ “TURN RIGHT” $\star _ { 4 + }$ “TURN RIGHT” $\star _ { 4 + }$ “TURN RIGHT” \* 4. + +# “jump around right thrice after run left thrice” + +# Golden: + +TURN LEFT RUN TURN LEFT RUN TURN LEFT RUN TURN RIGHT JUMP TURN RIGHT JUMPTURN RIGHT JUMP TURN RIGHT JUMP TURN RIGHT JUMP TURN RIGHT JUMP TURN RIGHTJUMP TURN RIGHT JUMP TURN RIGHT JUMP TURN RIGHT JUMP TURN RIGHT JUMPTURN RIGHT JUMP + +# Solution: + +Q: “jump around right thrice after run left thrice” + +A: The output of “jump around right thrice after run left thrice” concatenates: the output of “run left thrice”, the output of “jump around right thrice”. “run left thrice” outputs (“TURN LEFT” $^ +$ “RUN”) \* 3. “jump around right thrice” outputs (“TURN RIGHT” $^ +$ “JUMP”) \* 12. So concatenating the output of “run left thrice” and the output of “jump around right thrice” leads to (“TURN LEFT” $^ +$ “RUN”) $\cdot _ { 3 }$ $^ +$ (“TURN RIGHT” $^ +$ “JUMP”) \* 12. So the output of “jump around right thrice after run left thrice” is (“TURN LEFT” $^ +$ “RUN”) $^ { \star } 3 +$ (“TURN RIGHT” $^ +$ “JUMP”) $\star 1 2$ . + +# “run around left twice and walk around left thrice” + +# Golden: + +TURN LEFT RUN TURN LEFT RUN TURN LEFT RUN TURN LEFT RUN TURN LEFT RUN TURN LEFT RUN TURN LEFT RUN TURN LEFT RUN TURN LEFT WALK TURN LEFT WALK TURN LEFT WALK TURN LEFT WALK TURN LEFT WALK TURN LEFT WALK TURN LEFT WALK TURN LEFT WALK TURN LEFT WALK TURN LEFT WALK TURN LEFT WALK TURN LEFT WALK + +# Solution: + +Q: “run around left twice and walk around left thrice” + +A: The output of “run around left twice and walk around left thrice” concatenates: the output of “run around left twice”, the output of “walk around left thrice”. “run around left twice” outputs (“TURN LEFT” $^ +$ “RUN”) $\star _ { 4 } \star _ { 2 }$ . “walk around left thrice” outputs (“TURN LEFT” $^ +$ “WALK”) $\times 4 ^ { \star }$ 3. So concatenating the output of “run around left twice” and the output of “walk around left thrice” leads to (“TURN LEFT” $^ +$ “RUN”) $\star _ { 4 } \star _ { 2 + }$ (“TURN LEFT” $^ +$ “WALK”) $\star 4 \star 3$ . So the output of “run around left twice and walk around left thrice” is (“TURN LEFT” $^ +$ “RUN”) $^ { \star } 4 ^ { \star } 2 +$ (“TURN LEFT” $^ +$ “WALK”) $\star _ { 4 } \star _ { 3 }$ . + +# “jump around left thrice after turn around left thrice” + +# Golden: + +TURN LEFT TURN LEFT TURN LEFT TURN LEFT TURN LEFT TURN LEFT TURN LEFT TURN LEFT TURN LEFT TURN LEFT TURN LEFT TURN LEFT TURN LEFT JUMP TURN LEFT JUMP TURN LEFT JUMP TURN LEFT JUMP TURN LEFT JUMP TURN LEFT JUMP TURN LEFT JUMP TURN LEFT JUMP TURN LEFT JUMP TURN LEFT JUMP TURN LEFT JUMP TURN LEFT JUMP + +# Solution: + +Q: “jump around left thrice after turn around left thrice” + +A: The output of “jump around left thrice after turn around left thrice” concatenates: the output of “turn around left thrice”, the output of “jump around left thrice”. “turn around left thrice” outputs “TURN LEFT” $\star _ { \mathrm { ~ 4 ~ } } \star _ { \mathrm { ~ 3 ~ } }$ . “jump around left thrice” outputs (“TURN L $\mathsf { E F T } ^ { \prime \prime } + \mathsf { \Omega } ^ { \mathrm { i } } \mathsf { J } \mathsf { U } \mathsf { M } \mathsf { P } ^ { \prime \prime } ) \ ^ { \mathrm { ~ \star ~ } } 4$ $\star _ { \mathrm { ~ 4 ~ } } \star _ { \mathrm { ~ 3 ~ } }$ . So concatenating the output of “turn around left thrice” and the output of “jump around left thrice” leads to “TURN LEFT” $^ { \star } 4 ^ { \star } 3 +$ (“TURN LEFT” $^ +$ “JUMP”) $\star _ { 4 } \star _ { 3 }$ . So the output of “jump around left thrice after turn around left thrice” is “TURN LEFT” $^ { \star } 4 ^ { \star } 3 +$ (“TURN LEFT” $^ +$ “JUMP”) $\star _ { 4 } \star _ { 3 }$ . + +8.3.2 CHAIN-OF-THOUGHT PROMPTING: FAILURE + +# “look around right and look around right thrice” + +# Golden: + +# TURN RIGHT LOOK TURN RIGHT LOOK TURN RIGHT LOOK TURN RIGHT LOOK TURN RIGHTLOOK TURN RIGHT LOOK TURN RIGHT LOOK TURN RIGHT LOOK TURN RIGHT LOOKTURN RIGHT LOOK TURN RIGHT LOOK TURN RIGHT LOOK TURN RIGHT LOOK TURN RIGHTLOOK TURN RIGHT LOOK TURN RIGHT LOOK + +# Solution: + +Q: “look around right and look around right thrice” A: The output of “look around right and look around right thrice” concatenates: the output of “look around right”, the output of “look around right thrice”. “look around right” outputs “TURN RIGHT” \* 4 $^ +$ “LOOK”. “look around right thrice” outputs (“TURN RIGHT” $\star 4 + \bar { \cdot } \mathsf { L O O K } ^ { \prime \prime } ) \star 3$ . So concatenating the output of “look around right” and the output of “look around right thrice” leads to “TURN RIGHT” $\star 4 + \mathsf { \Omega } ^ { \bullet } \mathsf { L } \mathsf { O } \mathsf { O } \mathsf { K } ^ { \prime \prime } +$ (“TURN RIGHT” $\times ~ 4 \div$ “LOOK”) $\yen 3$ . So the output of “look around right and look around right thrice” is “TURN RIGHT” $\star 4 + \mathsf { \Omega } ^ { \bullet } \mathsf { L O O K } ^ { \prime \prime } +$ (“TURN RIGHT” $\star 4 + \mathsf { \Omega } ^ { \bullet } \mathsf { L O O K } ^ { \mathfrak { v } } ) \star \bar { 3 }$ . + +# “run around left thrice and run left twice” + +# Golden: + +TURN LEFT RUN TURN LEFT RUN TURN LEFT RUN TURN LEFT RUN TURN LEFT RUN TURN LEFT RUN TURN LEFT RUN TURN LEFT RUN TURN LEFT RUN TURN LEFT RUN TURN LEFT RUN TURN LEFT RUN TURN LEFT RUN TURN LEFT RUN + +# Solution: + +$\mathsf { Q }$ : “run around left thrice and run left twice” A: The output of “run around left thrice and run left twice” concatenates: the output of “run around left thrice”, the output of “run left twice”. “run around left thrice” outputs (“TURN LEFT” $^ +$ “RUN”) \* 3. “run left twice” outputs “TURN LEFT” $^ +$ “RUN” \* 2. So concatenating the output of “run around left thrice” and the output of “run left twice” leads to (“TURN LEFT” $^ +$ “RUN”) $^ { \star } 3 +$ “TURN LEFT” $^ +$ “RUN” $^ { \star } \sf { 2 } .$ . So the output of “run around left thrice and run left twice” is (“TURN LEFT” $^ +$ “RUN”) $^ { \star } 3$ $^ +$ “TURN LEFT” $^ +$ “RUN” $^ \star 2$ . + +# “walk and walk around left thrice” + +# Golden: WALK TURN LEFT WALK TURN LEFT WALK TURN LEFT WALK TURN LEFT WALK TURN LEFT WALK TURN LEFT WALK TURN LEFT WALK TURN LEFT WALK TURN LEFT WALK TURN LEFT WALK TURN LEFT WALK TURN LEFT WALK + +# Solution: + +Q: “walk and walk around left thrice” +A: The output of “walk and walk around left thrice” concatenates: the output of “walk”, the output of “walk around left thrice”. “walk” outputs “WALK”. “walk around left thrice” outputs (“TURN LEFT” $^ +$ “WALK”) $\star _ { 4 }$ . So concatenating the output of “walk” and the output of “walk around left thrice” leads to “WALK” $^ +$ (“TURN LEFT” $^ +$ “WALK”) \* 4. So the output of “walk and walk around left thrice” is “WALK” $^ +$ (“TURN LEFT” $^ +$ “WALK”) $\star _ { 4 }$ . + +# “jump around right thrice after turn opposite left twice” + +# Golden: + +TURN LEFT TURN LEFT TURN LEFT TURN LEFT TURN RIGHT JUMP TURN RIGHT JUMPTURN RIGHT JUMP TURN RIGHT JUMP TURN RIGHT JUMP TURN RIGHT JUMP TURN RIGHTJUMP TURN RIGHT JUMP TURN RIGHT JUMP TURN RIGHT JUMP TURN RIGHT JUMPTURN RIGHT JUMP + +# Solution: + +Q: “jump around right thrice after turn opposite left twice” + +A: The output of “jump around right thrice after turn opposite left twice” concatenates: the output of “turn opposite left twice”, the output of “jump around right thrice”. “turn opposite left twice” outputs “TURN LEFT” $^ { \star } \sf { \sf { 2 } }$ . “jump around right thrice” outputs (“TUR $\mathsf { V \_ R l G H T ^ { * } } + \mathsf { \Omega } ^ { * } \mathsf { J U I }$ MP”) \* 4. So concatenating the output of “turn opposite left twice” and the output of “jump around right thrice” leads to “TURN LEFT” $^ \star \sf { 2 } +$ (“TURN RIGHT” $^ +$ “JUMP”) \* 4. So the output of “jump around right thrice after turn opposite left twice” is “TURN LEFT” $^ { \star } 2 +$ (“TURN RIGHT” $^ +$ “JUMP”) $\dot { \star } _ { 4 }$ . + +# “run opposite right after walk around right thrice” + +# Golden: + +TURN RIGHT WALK TURN RIGHT WALK TURN RIGHT WALK TURN RIGHT WALK TURN RIGHTWALK TURN RIGHT WALK TURN RIGHT WALK TURN RIGHT WALK TURN RIGHT WALKTURN RIGHT WALK TURN RIGHT WALK TURN RIGHT WALK TURN RIGHT TURN RIGHT RUN + +# Solution: + +Q: “run opposite right after walk around right thrice” + +A: The output of “run opposite right after walk around right thrice” concatenates: the output of “walk around right thrice”, the output of “run opposite right”. “walk around right thrice” outputs (“TURN RIGHT” $^ +$ “WALK”) $\star \ 3$ . “run opposite right” outputs “TURN RIGHT” $\textbf { \star } _ { 2 \mathrm { ~ + ~ } }$ “RUN”. So concatenating the output of “walk around right thrice” and the output of “run opposite right” leads to (“TURN RIGHT” $^ +$ “WALK”) $\star _ { 3 + }$ “TURN RIGHT” $\star _ { 2 + }$ “RUN”. So the output of “run opposite right after walk around right thrice” is (“TURN RIGHT” $^ +$ “WALK”) $^ { \star } \sf { 3 } +$ “TURN RIGHT” $^ { \star } \boldsymbol { \sf { Z } } +$ “RUN”. + +# 8.3.3 LEAST-TO-MOST PROMPTING: SUCCESS + +# “jump around left thrice and walk opposite right” + +# Golden: + +TURN LEFT JUMP TURN LEFT JUMP TURN LEFT JUMP TURN LEFT JUMP TURN LEFT JUMPTURN LEFT JUMP TURN LEFT JUMP TURN LEFT JUMP TURN LEFT JUMP TURN LEFT JUMPTURN LEFT JUMP TURN LEFT JUMP TURN RIGHT TURN RIGHT WALK + +# Decomposition: + +Q: “jump around left thrice and walk opposite right” +A: “jump around left thrice” can be solved by: “jump left”, “jump around left”, “jump around left thrice”. “walk opposite right” can be solved by: “walk opposite right”. So, “jump around left thrice and walk opposite right” can be solved by: “jump left”, “jump around left”, “jump around left thrice”, “walk opposite right”. + +# Solution: + +Q: “jump left” + +A: The output of “jump left” concatenates: the output of “turn left”, the output of “jump”. “turn left” outputs “TURN LEFT”. “jump” outputs “JUMP”. So concatenating the output of “turn left” and the output of “jump” leads to “TURN LEFT” $^ +$ “JUMP”. So the output of “jump left” is “TURN LEFT” $^ +$ “JUMP”. + +Q: “jump around left” + +A: The output of “jump around left” concatenates: the output of “jump left”, the output of “jump left”, the output of “jump left”, the output of “jump left”. “jump left” outputs “TURN LEFT” $^ +$ “JUMP”. So repeating the output of “jump around left” four times leads to (“TURN LEFT” $^ +$ “JUMP”) $\times 4$ . So the output of “jump around left” is (“TURN LEFT” $^ +$ “JUMP”) $\star _ { 4 }$ . + +Q: “jump around left thrice” + +A: The output of “jump around left thrice” concatenates: the output of “jump around left”, the output of “jump around left”, the output of “jump around left”. “jump around left” outputs (“TURN LEFT” $^ +$ “JUMP”) \* 4. So repeating the output of “jump around left” three times leads to (“TURN LEFT” $^ +$ “JUMP”) $\star _ { 4 } \star _ { 3 }$ . So the output of “jump around left thrice” is (“TURN LEFT” $^ +$ “JUMP”) $\star _ { 4 } \star _ { 3 }$ . + +Q: “walk opposite right” + +A: The output of “walk opposite right” concatenates: the output of “turn opposite right”, the output of “walk”. “turn opposite right” outputs “TURN RIGHT” $^ { \star } \sf { 2 }$ . “walk” outputs “WALK”. So concatenating the output of “turn opposite right” and the output of “walk” leads to “TURN RIGHT” $^ { \star } \boldsymbol { \sf { z } } +$ “WALK”. So the output of “walk opposite right” is “TURN RIGHT” $^ { \star } \boldsymbol { \sf { Z } } +$ “WALK”. + +Q: “jump around left thrice and walk opposite right” + +A: The output of “jump around left thrice and walk opposite right” concatenates: the output of “jump around left thrice”, the output of “walk opposite right”. “jump around left thrice” outputs (“TURN LEFT” $^ +$ “JUMP”) $\star _ { 4 } \star _ { 3 }$ . “walk opposite right” outputs “TURN RIGHT” $\bf { \Omega } ^ { \star } \lambda \geq \delta ^ { \circ } + \Delta ^ { \circ } V A L K ^ { \prime \prime }$ . So concatenating the output of “jump around left thrice” and the output of “walk opposite right” leads to (“TURN LEFT” $^ +$ “JUMP”) $\star _ { 4 } \star _ { 3 + }$ “TURN RIGHT” ${ ^ { \star } } 2 + { ^ { \circ } { \mathsf { W A L K } } ^ { \star } }$ . So the output of “jump around left thrice and walk opposite right” is (“TURN LEFT” $^ +$ “JUMP”) $^ { \star } 4 ^ { \star } 3 +$ “TURN RIGHT” \* $\geq +$ “WALK”. + +# “turn around left thrice after run around right thrice” + +# Golden: + +TURN RIGHT RUN TURN RIGHT RUN TURN RIGHT RUN TURN RIGHT RUN TURN RIGHT RUNTURN RIGHT RUN TURN RIGHT RUN TURN RIGHT RUN TURN RIGHT RUN TURN RIGHTRUN TURN RIGHT RUN TURN RIGHT RUN TURN LEFT TURN LEFT TURN LEFT TURN LEFTTURN LEFT TURN LEFT TURN LEFT TURN LEFT TURN LEFT TURN LEFT TURN LEFTTURN LEFT + +# Decomposition: + +Q: “turn around left thrice after run around right thrice” A: “turn around left thrice” can be solved by: “turn left”, “turn around left”, “turn around left thrice”. “run around right thrice” can be solved by: “run right”, “run around right”, “run around right thrice”. So, “turn around left thrice after run around right thrice” can be solved by: “turn left”, “turn around left”, “turn around left thrice”, “run right”, “run around right”, “run around right thrice”. + +# Solution: + +Q: “turn around left” + +A: The output of “turn around left” concatenates: the output of “turn left”, the output of “turn left”, the output of “turn left”, the output of “turn left”. “turn left” outputs “TURN LEFT”. So repeating the output of “turn left” four times leads to “TURN LEFT” \* 4. So the output of “turn around left” is “TURN LEFT” $\star _ { 4 }$ . + +Q: “turn around left thrice” + +A: The output of “turn around left thrice” concatenates: the output of “turn around left”, the output of “turn around left”, the output of “turn around left”. “turn around left” outputs “TURN LEFT” \* 4. So repeating the output of “turn around left” three times leads to (“TURN LEFT” \* 4) $^ { \star } 3$ . So the output of “turn around left thrice” is (“TURN LEFT” \* 4) $^ \star 3$ . + +Q: “run right” + +A: The output of “run right” concatenates: the output of “turn right”, the output of “run”. “turn right” outputs “TURN RIGHT”. “run” outputs “RUN”. So concatenating the output of “turn right” and the output of “run” leads to “TURN RIGHT” $^ +$ “RUN”. So the output of “run right” is “TURN RIGHT” $^ +$ “RUN”. + +Q: “run around right” + +A: The output of “run around right” concatenates: the output of “run right”, the output of “run right”, the output of “run right”, the output of “run right”. “run right” outputs “TURN RIGHT” $^ +$ “RUN”. So repeating the output of “run right” four times leads to (“TURN RIGHT” $^ +$ “RUN”) $\star _ { 4 }$ . So the output of “run around right” is (“TURN RIGHT” $^ +$ “RUN”) $\times 4$ . + +Q: “run around right thrice” + +A: The output of “run around right thrice” concatenates: the output of “run around right”, the output of “run around right”, the output of “run around right”. “run around right” outputs (“TURN RIGHT” $^ +$ “RUN”) $\times 4$ . So repeating the output of “run around right” three times leads to ((“TURN RIGHT” $^ +$ $\mathrm { ^ { * } R U N ^ { \prime \prime } } ) \\\^ { \star } 4 ) \\\\\ t` :$ . So the output of “run around right thrice” is ((“TUR $\vee . \mathsf { R l G H T ^ { \prime \prime } } + \ " { \mathsf { R U N } } ^ { \prime \prime } ) \ ^ { \star } \ 4 ) \ ^ { \star } \ ;$ . + +Q: “turn around left thrice after run around right thrice” + +A: The output of “turn around left thrice after run around right thrice” concatenates: the output of “run around right thrice”, the output of “turn around left thrice”. “run around right thrice” outputs $( ( ^ { \circ } \mathsf { T } \mathsf { U R N } _ { \mathsf { - } } \mathsf { R I G H T ^ { \circ } } + ^ { \circ } \mathsf { R U N ^ { \circ } } ) ^ { \mathrm { ~ \star ~ } } 4 ) ^ { \mathrm { ~ \star ~ } } 3 .$ “turn around left thrice” outputs (“TURN LEFT” \* 4) $\yen 3$ . So concatenating the output of “run around right thrice” and the output of “turn around left thrice” leads to $( ( ^ { \circ } \mathsf { T } \mathsf { U R N \mathrm { . } R I G H T ^ { \prime \prime } } + ^ { \circ } \mathsf { R U N ^ { \prime \prime } } ) \star 4 )$ $\textrm { \scriptsize * } _ { 3 \mathrm { ~ + ~ } }$ (“TURN LEFT” \* 4) $\star _ { 3 }$ . So the output of “turn around left thrice after run around right thrice” is ((“TURN RIGHT” $^ +$ “RUN”) $\star$ 4) $^ { \star } \sf { 3 } +$ (“TURN LEFT” \* 4) $^ \star 3$ . + +# “turn left after look around left thrice” + +# Golden: + +# TURN LEFT LOOK TURN LEFT LOOK TURN LEFT LOOK TURN LEFT LOOK TURN LEFT LOOK TURN LEFT LOOK TURN LEFT LOOK TURN LEFT LOOK TURN LEFT LOOK TURN LEFT LOOK TURN LEFT LOOK TURN LEFT LOOK TURN LEFT + +# Decomposition: + +Q: “turn left after look around left thrice” +A: “turn left” can be solved by: “turn left”. “look around left thrice” can be solved by: “look left”, “look around left”, “look around left thrice”. So, “turn left after look around left thrice” can be solved by: “turn left”, “look left”, “look around left”, “look around left thrice”. + +# Solution: + +Q: “look left” + +A: The output of “look left” concatenates: the output of “turn left”, the output of “look”. “turn left” outputs “TURN LEFT”. “look” outputs “LOOK”. So concatenating the output of “turn left” and the output of “look” leads to “TURN LEFT” $^ +$ “LOOK”. So the output of “look left” is “TURN LEFT” $^ +$ “LOOK”. + +Q: “look around left” + +A: The output of “look around left” concatenates: the output of “look left”, the output of “look left”, the output of “look left”, the output of “look left”. “look left” outputs “TURN LEFT” $^ +$ “LOOK”. So repeating the output of “look left” four times leads to (“TURN LEFT” $^ +$ “LOOK”) \* 4. So the output of “look around left” is (“TURN LEFT” $^ +$ “LOOK”) $\star _ { 4 }$ . + +Q: “look around left thrice” + +A: The output of “look around left thrice” concatenates: the output of “look around left”, the output of “look around left”, the output of “look around left”. “look around left” outputs (“TURN LEFT” $^ +$ “LOOK”) \* 4. So repeating the output of “look around left” three times leads to ((“TURN LEFT” $^ +$ $\cdot { \mathsf { L O O K } } ^ { 3 } ) \ ^ { \star } \ 4 ) \ ^ { \star } \ 3$ . So the output of “look around left thrice” is ((“TURN LEFT” $+ ~ ^ { \circ } \mathsf { L O O K } ^ { \prime \prime } ) \ ^ { \star } \ 4 ) \ ^ { \star } \ 3$ . + +$\mathsf { Q }$ : “turn left after look around left thrice” + +A: The output of “turn left after look around left thrice” concatenates: the output of “look around left thrice”, the output of “turn left”. “look around left thrice” outputs ((“TURN $\mathsf { L E F T } ^ { \prime \prime } + \mathsf { \ " L O O K } ^ { \prime \prime } ) \mathsf { \Sigma } ^ { \star } 4 ) \mathsf { \Sigma } ^ { \star }$ 3. “turn left” outputs “TURN LEFT”. So concatenating the output of “look around left thrice” and the output of “turn left” leads to ((“TURN LEFT” $^ +$ “LOOK”) \* 4) $\star \textsf { 3 + }$ “TURN LEFT”. So the output of “turn left after look around left thrice” is ((“TURN LEFT” $^ +$ “LOOK”) \* 4) $^ { \star } \sf { 3 } +$ “TURN LEFT”. + +# “turn around left thrice and jump around left thrice” + +# Golden: + +TURN LEFT TURN LEFT TURN LEFT TURN LEFT TURN LEFT TURN LEFT TURN LEFT TURN LEFT TURN LEFT TURN LEFT TURN LEFT TURN LEFT TURN LEFT JUMP TURN LEFT JUMP TURN LEFT JUMP TURN LEFT JUMP TURN LEFT JUMP TURN LEFT JUMP TURN LEFT JUMP TURN LEFT JUMP TURN LEFT JUMP TURN LEFT JUMP TURN LEFT JUMP TURN LEFT JUMP + +# Decomposition: + +Q: “turn around left thrice and jump around left thrice” + +A: “turn around left thrice” can be solved by: “turn left”, “turn around left”, “turn around left thrice”. “jump around left thrice” can be solved by: “jump left”, “jump around left”, “jump around left thrice”. So, “turn around left thrice and jump around left thrice” can be solved by: “turn left”, “turn around left”, “turn around left thrice”, “jump left”, “jump around left”, “jump around left thrice”. + +# Solution: + +Q: “turn around left” + +A: The output of “turn around left” concatenates: the output of “turn left”, the output of “turn left”, the output of “turn left”, the output of “turn left”. “turn left” outputs “TURN LEFT”. So repeating the output of “turn left” four times leads to “TURN LEFT” \* 4. So the output of “turn around left” is “TURN LEFT” $\star _ { 4 }$ . + +Q: “turn around left thrice” + +A: The output of “turn around left thrice” concatenates: the output of “turn around left”, the output of “turn around left”, the output of “turn around left”. “turn around left” outputs “TURN LEFT” \* 4. So repeating the output of “turn around left” three times leads to (“TURN LEFT” \* 4) $^ { \star } 3$ . So the output of “turn around left thrice” is (“TURN LEFT” \* 4) $^ \star 3$ . + +Q: “jump left” + +A: The output of “jump left” concatenates: the output of “turn left”, the output of “jump”. “turn left” outputs “TURN LEFT”. “jump” outputs “JUMP”. So concatenating the output of “turn left” and the output of “jump” leads to “TURN LEFT” $^ +$ “JUMP”. So the output of “jump left” is “TURN LEFT” $^ +$ “JUMP”. + +Q: “jump around left” + +A: The output of “jump around left” concatenates: the output of “jump left”, the output of “jump left”, the output of “jump left”, the output of “jump left”. “jump left” outputs “TURN LEFT” $^ +$ “JUMP”. So repeating the output of “jump left” four times leads to (“TURN LEFT” $^ +$ “JUMP”) $\star _ { 4 }$ . So the output of “jump around left” is (“TURN LEFT” $^ +$ “JUMP”) $\star _ { 4 }$ . + +Q: “jump around left thrice” + +A: The output of “jump around left thrice” concatenates: the output of “jump around left”, the output of “jump around left”, the output of “jump around left”. “jump around left” outputs (“TURN LEFT” $^ +$ “JUMP”) \* 4. So repeating the output of “jump around left” three times leads to ((“TURN LEFT” $^ +$ $\ J \ U \mathsf { M P } ^ { , , } ) \ ^ { \star } \ 4 ) \ ^ { \star } \ 3$ . So the output of “jump around left thrice” is ((“TURN LEFT” ${ \bf \Phi } _ { { \bf \Phi } _ { } + } \ " { \bf J } { \bf U } _ { }$ MP”) \* 4) $^ { \star } 3$ . + +Q: “turn around left thrice and jump around left thrice” + +A: The output of “turn around left thrice and jump around left thrice” concatenates: the output of “turn around left thrice”, the output of “jump around left thrice”. “turn around left thrice” outputs (“TURN LEFT” \* 4) $\yen 3$ . “jump around left thrice” outputs ((“TURN LEFT” $^ +$ “JUMP”) \* 4) $^ { \star } \sf 3$ . So concatenating the output of “turn around left thrice” and the output of “jump around left thrice” leads to (“TURN LEFT” \* 4) $\star 3 +$ ((“TURN LEFT” $^ +$ “JUMP”) \* 4) $^ \star 3$ . So the output of “turn around left thrice and jump around left thrice” is (“TURN LEFT” \* 4) $^ { \star } \sf { 3 } +$ ((“TURN LEFT” $^ +$ “JUMP”) \* 4) \* 3. + +# “walk around right twice after walk around right twice” + +# Golden: + +TURN RIGHT WALK TURN RIGHT WALK TURN RIGHT WALK TURN RIGHT WALK TURN RIGHTWALK TURN RIGHT WALK TURN RIGHT WALK TURN RIGHT WALK TURN RIGHT WALKTURN RIGHT WALK TURN RIGHT WALK TURN RIGHT WALK TURN RIGHT WALK TURN RIGHTWALK TURN RIGHT WALK TURN RIGHT WALK + +# Decomposition: + +Q: “walk around right twice after walk around right twice” + +A: “walk around right twice” can be solved by: “walk right”, “walk around right”, “walk around right twice”. “walk around right twice” can be solved by: “walk right”, “walk around right”, “walk around right twice”. So, “walk around right twice after walk around right twice” can be solved by: “walk right”, “walk around right”, “walk around right twice”, “walk right”, “walk around right”, “walk around right twice”. + +# Solution: + +Q: “walk right” + +A: The output of “walk right” concatenates: the output of “turn right”, the output of “walk”. “turn right” outputs “TURN RIGHT”. “walk” outputs “WALK”. So concatenating the output of “turn right” and the output of “walk” leads to “TURN RIGHT” $^ +$ “WALK”. So the output of “walk right” is “TURN RIGHT” $^ +$ “WALK”. + +Q: “walk around right” + +A: The output of “walk around right” concatenates: the output of “walk right”, the output of “walk right”, the output of “walk right”, the output of “walk right”. “walk right” outputs “TURN RIGHT” $^ +$ “WALK”. So repeating the output of “walk around right” four times leads to (“TURN RIGHT” $^ +$ “WALK”) \* 4. So the output of “walk around right” is (“TURN RIGHT $" + " W _ { \ast }$ ALK”) $\star _ { 4 }$ . + +Q: “walk around right twice” + +A: The output of “walk around right twice” concatenates: the output of “walk around right”, the output of “walk around right”. “walk around right” outputs (“TURN RIGHT” $^ +$ “WALK”) $\star _ { 4 }$ . So repeating the output of “walk around right” twice leads to (“TURN RIGHT” $^ +$ “WALK”) $\star _ { 4 } \star _ { 2 }$ . So the output of “walk around right twice” is (“TURN RIGHT” $^ +$ “WALK”) $\star _ { 4 } \star _ { 2 }$ . + +Q: “walk around right twice after walk around right twice” + +A: The output of “walk around right twice after walk around right twice” concatenates: the output of “walk around right twice”, the output of “walk around right twice”. “walk around right twice” outputs $\mathrm { \Delta ^ { * } T U R N . R l G H T ^ { \prime \prime } } + \mathrm { \Delta ^ { * } W A L K ^ { \prime \prime } } ) \^ { \mathrm { ~ \star ~ } } 4 \ ^ { \star } 2$ . So repeating the output of “walk around right twice” twice leads to (“TURN RIGHT” $^ +$ “WALK”) $\star _ { 4 } \star _ { 2 } \star _ { 2 }$ . So the output of “walk around right twice after walk around right twice” is (“TURN RIGHT” $^ +$ “WALK”) $^ { \star } 4 ^ { \star } 2 ^ { \star } 2$ . + +8.3.4 LEAST-TO-MOST PROMPTING: FAILURE + +# “jump opposite right twice and jump around right thrice” + +# Golden: + +TURN RIGHT TURN RIGHT JUMP TURN RIGHT TURN RIGHT JUMP TURN RIGHT JUMP + +# TURN RIGHT JUMP TURN RIGHT JUMP TURN RIGHT JUMP TURN RIGHT JUMP TURN RIGHTJUMP TURN RIGHT JUMP TURN RIGHT JUMP TURN RIGHT JUMP TURN RIGHT JUMPTURN RIGHT JUMP TURN RIGHT JUMP + +# Decomposition: + +Q: “jump opposite right twice and jump around right thrice” + +A: “jump opposite right twice” can be solved by: “jump opposite right”, “jump opposite right twice”. “jump around right thrice” can be solved by: “jump right”, “jump around right”, “jump around right thrice”. So, “jump opposite right twice and jump around right thrice” can be solved by: “jump opposite right”, “jump opposite right twice”, “jump right”, “jump around right”, “jump around right thrice”. + +# Solution: + +Q: “jump opposite right” + +A: The output of “jump opposite right” concatenates: the output of “turn opposite right”, the output of “jump”. “turn opposite right” outputs “TURN RIGHT” $^ { \star } \sf { 2 }$ . “jump” outputs “JUMP”. So concatenating the output of “turn opposite right” and the output of “jump” leads to “TURN RIGHT” $^ { \star } \boldsymbol { \sf { z } } +$ “JUMP”. So the output of “jump opposite right” is “TURN RIGHT” $^ { \star } 2 +$ “JUMP”. + +Q: “jump opposite right twice” + +A: The output of “jump opposite right twice” concatenates: the output of “jump opposite right”, the output of “jump opposite right”. “jump opposite right” outputs “TURN RIGHT” $^ { \star } \hat { z } +$ “JUMP”. So repeating the output of “jump opposite right” twice leads to (“TURN RIGHT” $^ { \star } \boldsymbol { \sf { z } } +$ “JUMP”) $^ { \star } \sf { 2 }$ . So the output of “jump opposite right twice” is (“TURN RIGHT” $^ { \star } 2 +$ “JUMP”) $^ { \star } 2$ . + +Q: “jump right” + +A: The output of “jump right” concatenates: the output of “turn right”, the output of “jump”. “turn right” outputs “TURN RIGHT”. “jump” outputs “JUMP”. So concatenating the output of “turn right” and the output of “jump” leads to “TURN RIGHT” $^ +$ “JUMP”. So the output of “jump right” is “TURN RIGHT” $^ +$ “JUMP”. + +Q: “jump around right” + +A: The output of “jump around right” concatenates: the output of “jump right”, the output of “jump right”, the output of “jump right”, the output of “jump right”. “jump right” outputs “TURN RIGHT” $^ +$ “JUMP”. So repeating the output of “jump around right” four times leads to (“TURN RIGHT” $^ +$ “JUMP”) $\times 4$ . So the output of “jump around right” is (“TURN RIGHT” $^ +$ “JUMP”) $\star _ { 4 }$ . + +Q: “jump around right thrice” + +A: The output of “jump around right thrice” concatenates: the output of “jump right”, the output of “jump right”, the output of “jump right”, the output of “jump right”, the output of “jump right”, the output of “jump right”, the output of “jump right”, the output of “jump right”. “jump right” outputs “TURN RIGHT” $^ +$ “JUMP”. So repeating the output of “jump around right” eight times leads to (“TURN RIGHT” $^ +$ “JUMP”) $\star _ { 8 }$ . So the output of “jump around right thrice” is (“TURN RIGHT” $^ +$ “JUMP”) $\star _ { 8 }$ . + +Q: “jump opposite right twice and jump around right thrice” + +A: The output of “jump opposite right twice and jump around right thrice” concatenates: the output of “jump opposite right twice”, the output of “jump around right thrice”. “jump opposite right twice” outputs (“TURN RIGHT” \* 2 + “JUMP”) $\yen 2$ . “jump around right thrice” outputs (“TURN RIGHT” $^ +$ “JUMP”) $\star _ { 8 }$ . So concatenating the output of “jump opposite right twice” and the output of “jump around right thrice” leads to (“TURN RIGHT” \* 2 + “JUMP”) $^ { \star } 2 +$ (“TURN RIGHT” $^ +$ “JUMP”) \* 8. So the output of “jump opposite right twice and jump around right thrice” is (“TURN RIGHT” $^ { \star } 2 +$ “JUMP”) $^ { \star } \dot { 2 } +$ (“TURN RIGHT” $^ +$ “JUMP”) $\star _ { 8 }$ . + +# “walk around left thrice after walk around right twice” + +# Golden: + +TURN RIGHT WALK TURN RIGHT WALK TURN RIGHT WALK TURN RIGHT WALK TURN RIGHTWALK TURN RIGHT WALK TURN RIGHT WALK TURN RIGHT WALK TURN LEFT WALKTURN LEFT WALK TURN LEFT WALK TURN LEFT WALK TURN LEFT WALK TURN LEFT WALKTURN LEFT WALK TURN LEFT WALK TURN LEFT WALK TURN LEFT WALK TURN LEFT WALKTURN LEFT WALK + +# Decomposition: + +Q: “walk around left thrice after walk around right twice” + +A: “walk around left thrice” can be solved by: “walk left”, “walk around left”, “walk around left thrice”. “walk around right twice” can be solved by: “walk right”, “walk around right”, “walk around right twice”. So, “walk around left thrice after walk around right twice” can be solved by: “walk left”, “walk around left”, “walk around left thrice”, “walk right”, “walk around right”, “walk around right twice”. + +# Solution: + +Q: “walk left” + +A: The output of “walk left” concatenates: the output of “turn left”, the output of “walk”. “turn left” outputs “TURN LEFT”. “walk” outputs “WALK”. So concatenating the output of “turn left” and the output of “walk” leads to “TURN LEFT” $^ +$ “WALK”. So the output of “walk left” is “TURN LEFT” $^ +$ “WALK”. + +Q: “walk around left” + +A: The output of “walk around left” concatenates: the output of “walk left”, the output of “walk left”, the output of “walk left”, the output of “walk left”. “walk left” outputs “TURN LEFT” $^ +$ “WALK”. So repeating the output of “walk around left” four times leads to (“TURN LEFT” $^ +$ “WALK”) $\times 4$ . So the output of “walk around left” is (“TURN LEFT” $^ +$ “WALK”) $\star _ { 4 }$ . + +Q: “walk around left thrice” + +A: The output of “walk around left thrice” concatenates: the output of “walk around left”, the output of “walk around left”, the output of “walk around left”. “walk around left” outputs (“TURN LEFT” $^ +$ “WALK”) $\times 4$ . So repeating the output of “walk around left” three times leads to (“TURN LEFT” $^ +$ $\ " { \mathsf { W A L K } } ^ { \prime \prime } ) \ \star \ 4 \ ^ { \star } \ 3$ . So the output of “walk around left thrice” is (“TURN LEFT” $^ +$ “WALK”) $\star _ { 4 } \star _ { 3 }$ . + +Q: “walk right” + +A: The output of “walk right” concatenates: the output of “turn right”, the output of “walk”. “turn right” outputs “TURN RIGHT”. “walk” outputs “WALK”. So concatenating the output of “turn right” and the output of “walk” leads to “TURN RIGHT” $^ +$ “WALK”. So the output of “walk right” is “TURN RIGHT” $^ +$ “WALK”. + +Q: “walk around right” + +A: The output of “walk around right” concatenates: the output of “walk right”, the output of “walk right”, the output of “walk right”, the output of “walk right”. “walk right” outputs “TURN RIGHT” $^ +$ “WALK”. So repeating the output of “walk around right” four times leads to (“TURN RIGHT” $^ +$ “WALK”) $\star _ { 4 }$ . So the output of “walk around right” is (“TURN RIGHT” $^ +$ “WALK”) $\star _ { 4 }$ . + +Q: “walk around right twice” + +A: The output of “walk around right twice” concatenates: the output of “walk around right”, the output of “walk around right”. “walk around right” outputs (“TURN RIGHT” $^ +$ “WALK”) $\star _ { 4 }$ . So repeating the output of “walk around right” twice leads to (“TURN RIGHT” $^ +$ “WALK”) $\star _ { 4 } \star _ { 2 }$ . So the output of “walk around right twice” is (“TUR $\Lambda { \mathsf { N } } { \mathsf { R I G H T } } ^ { \prime \prime } + { \mathsf { \Omega } } ^ { \prime \prime } { \mathsf { W A L K } } ^ { \prime \prime } { \mathsf { \Omega } } ^ { \star } { \mathsf { 4 \Omega } } ^ { \star }$ $\star _ { 4 } \star _ { 2 }$ . + +Q: “walk around left thrice after walk around right twice” + +A: The output of “walk around left thrice after walk around right twice” concatenates: the output of “walk around left thrice”, the output of “walk around right twice”. “walk around left thrice” outputs (“TURN LEFT” $\begin{array} { r l } { + } & { } \ddot { \mathsf { W A L K } } ^ { \prime \prime } \end{array}$ $\star _ { 4 } \star _ { 3 }$ . “walk around right twice” outputs (“TURN RIGHT $^ { \cdots } + ^ { \cdots } $ WALK”) $\star _ { 4 } \star _ { 2 }$ . So concatenating the output of “walk around left thrice” and the output of “walk around right twice” leads to (“TURN LEFT” $^ +$ “WALK”) $^ { \star } 4 ^ { \star } 3 +$ (“TURN RIGHT” $^ +$ “WALK”) $\star _ { 4 } \star _ { 2 }$ . So the output of “walk around left thrice after walk around right twice” is (“TURN LEFT” $^ +$ “WALK”) $^ { \star } 4 ^ { \star } 3 +$ (“TURN RIGHT $\ " + \ \ " \mathsf { W } \mathsf { A } \mathsf { L }$ K”) $\star _ { 4 } \star _ { 2 }$ . + +# “run around left thrice after run around right twice” + +# Golden: + +TURN RIGHT RUN TURN RIGHT RUN TURN RIGHT RUN TURN RIGHT RUN TURN RIGHTRUN TURN RIGHT RUN TURN RIGHT RUN TURN RIGHT RUN TURN LEFT RUN TURN LEFTRUN TURN LEFT RUN TURN LEFT RUN TURN LEFT RUN TURN LEFT RUN TURN LEFT RUNTURN LEFT RUN TURN LEFT RUN TURN LEFT RUN TURN LEFT RUN TURN LEFT RUN + +# Decomposition: + +Q: “run around left thrice after run around right twice” + +A: “run around left thrice” can be solved by: “run left”, “run around left”, “run around left thrice”. “run around right twice” can be solved by: “run right”, “run around right”, “run around right twice”. So, “run around left thrice after run around right twice” can be solved by: “run left”, “run around left”, “run around left thrice”, “run right”, “run around right”, “run around right twice”. + +# Solution: + +Q: “run left” + +A: The output of “run left” concatenates: the output of “turn left”, the output of “run”. “turn left” outputs “TURN LEFT”. “run” outputs “RUN”. So concatenating the output of “turn left” and the output of “run” leads to “TURN LEFT” $^ +$ “RUN”. So the output of “run left” is “TURN LEFT” $^ +$ “RUN”. + +Q: “run around left” + +A: The output of “run around left” concatenates: the output of “run left”, the output of “run left”, the output of “run left”, the output of “run left”. “run left” outputs “TURN LEFT” $^ +$ “RUN”. So repeating the output of “run around left” four times leads to (“TURN LEFT” $^ +$ “RUN”) $\star _ { 4 }$ . So the output of “run around left” is (“TURN LEFT” $^ +$ “RUN”) $\star _ { 4 }$ . + +Q: “run around left thrice” + +A: The output of “run around left thrice” concatenates: the output of “run around left”, the output of “run around left”, the output of “run around left”. “run around left” outputs (“TURN LEFT” $^ +$ “RUN”) $^ { \star }$ 4. So repeating the output of “run around left” three times leads to (“TURN LEFT” $^ +$ “RUN”) $\star _ { 4 } \star _ { 3 }$ . So the output of “run around left thrice” is (“TURN LEFT” $^ +$ “RUN”) $\star _ { 4 } \star _ { 3 }$ . + +Q: “run right” + +A: The output of “run right” concatenates: the output of “turn right”, the output of “run”. “turn right” outputs “TURN RIGHT”. “run” outputs “RUN”. So concatenating the output of “turn right” and the output of “run” leads to “TURN RIGHT” $^ +$ “RUN”. So the output of “run right” is “TURN RIGHT” $^ +$ “RUN”. + +Q: “run around right” + +A: The output of “run around right” concatenates: the output of “run right”, the output of “run right”, the output of “run right”, the output of “run right”. “run right” outputs “TURN RIGHT” $^ +$ “RUN”. So repeating the output of “run around right” four times leads to (“TURN RIGHT” $^ +$ “RUN”) $\times 4$ . So the output of “run around right” is (“TURN RIGHT” $^ +$ “RUN”) $\times 4$ . + +Q: “run around right twice” + +A: The output of “run around right twice” concatenates: the output of “run around right”, the output of “run around right”. “run around right” outputs (“TURN RIGHT” $^ +$ “RUN”) $\star _ { 4 }$ . So repeating the output of “run around right” twice leads to (“TURN RIGHT” $^ +$ “RUN”) $\star _ { 4 } \star _ { 2 }$ . So the output of “run around right twice” is (“TURN RIGHT” $^ +$ “RUN”) $\star _ { 4 } \star _ { 2 }$ . + +Q: “run around left thrice after run around right twice” + +A: The output of “run around left thrice after run around right twice” concatenates: the output of “run around left thrice”, the output of “run around right twice”. “run around left thrice” outputs (“TURN LEFT $\ " + \mathrm { ~ \cdots ~ } \mathrm { ~ \sf ~ R } \mathrm { ~ \ U N ^ { * } ) ~ } \ \cdots \ .$ $\star _ { 4 } \star _ { 3 }$ . “run around right twice” outputs (“TU $\mathsf { W } \mathsf { \mathrm { { - R I G H T } ^ { \prime \prime } } } + \mathsf { \Omega } ^ { \mathrm { e } } \mathsf { R U N } ^ { \prime \prime } )$ $\times 4 ^ { \star }$ + +2. So concatenating the output of “run around left thrice” and the output of “run around right twice” leads to (“TURN LEFT” $^ +$ “RUN”) $^ \star 4 ^ { \star } 3 +$ (“TURN RIGHT” $^ +$ “RUN”) $\star _ { 4 } \star _ { 2 }$ . So the output of “run around left thrice after run around right twice” is (“TURN LEFT” $^ +$ “RUN”) $^ { \star } 4 ^ { \star } 3 +$ (“TURN RIGHT” $~ + ~ \mathrm { ^ { 4 } R U N ^ { 3 } } ) \\\^ { \star } ~ 4 ^ { \star } ~ 2 .$ + +# “jump opposite right twice after jump around right thrice” + +# Golden: + +TURN RIGHT JUMP TURN RIGHT JUMP TURN RIGHT JUMP TURN RIGHT JUMP TURN RIGHTJUMP TURN RIGHT JUMP TURN RIGHT JUMP TURN RIGHT JUMP TURN RIGHT JUMPTURN RIGHT JUMP TURN RIGHT JUMP TURN RIGHT JUMP TURN RIGHT TURN RIGHT JUMPTURN RIGHT TURN RIGHT JUMP + +# Decomposition: + +Q: “jump opposite right twice after jump around right thrice” + +A: “jump opposite right twice” can be solved by: “jump opposite right”, “jump opposite right twice”. “jump around right thrice” can be solved by: “jump right”, “jump around right”, “jump around right + +thrice”. So, “jump opposite right twice after jump around right thrice” can be solved by: “jump opposite right”, “jump opposite right twice”, “jump right”, “jump around right”, “jump around right thrice”. + +# Solution: + +Q: “jump opposite right” + +A: The output of “jump opposite right” concatenates: the output of “turn opposite right”, the output of “jump”. “turn opposite right” outputs “TURN RIGHT” $^ { \star } \sf { 2 } .$ . “jump” outputs “JUMP”. So concatenating the output of “turn opposite right” and the output of “jump” leads to “TURN RIGHT” $^ { \star } \boldsymbol { \sf { z } } +$ “JUMP”. So the output of “jump opposite right” is “TURN RIGHT” $^ { \star } 2 +$ “JUMP”. + +Q: “jump opposite right twice” + +A: The output of “jump opposite right twice” concatenates: the output of “jump opposite right”, the output of “jump opposite right”. “jump opposite right” outputs “TURN RIGHT” $^ { \star } \hat { z } +$ “JUMP”. So repeating the output of “jump opposite right” twice leads to (“TURN RIGHT” \* 2 + “JUMP”) $^ { \star } \sf { 2 }$ . So the output of “jump opposite right twice” is (“TURN RIGHT” $^ { \star } 2 +$ “JUMP”) $^ { \star } 2$ . + +Q: “jump right” + +A: The output of “jump right” concatenates: the output of “turn right”, the output of “jump”. “turn right” outputs “TURN RIGHT”. “jump” outputs “JUMP”. So concatenating the output of “turn right” and the output of “jump” leads to “TURN RIGHT” $^ +$ “JUMP”. So the output of “jump right” is “TURN RIGHT” $^ +$ “JUMP”. + +Q: “jump around right” + +A: The output of “jump around right” concatenates: the output of “jump right”, the output of “jump right”, the output of “jump right”, the output of “jump right”. “jump right” outputs “TURN RIGHT” $^ +$ “JUMP”. So repeating the output of “jump around right” four times leads to (“TURN RIGHT” $^ +$ “JUMP”) $\times 4$ . So the output of “jump around right” is (“TURN RIGHT” $^ +$ “JUMP”) $\star _ { 4 }$ . + +Q: “jump around right thrice” + +A: The output of “jump around right thrice” concatenates: the output of “jump right”, the output of “jump right”, the output of “jump right”, the output of “jump right”, the output of “jump right”, the output of “jump right”, the output of “jump right”, the output of “jump right”. “jump right” outputs “TURN RIGHT” $^ +$ “JUMP”. So repeating the output of “jump around right” eight times leads to (“TURN RIGHT” $^ +$ “JUMP”) $\star _ { 8 }$ . So the output of “jump around right thrice” is (“TURN RIGHT” $^ +$ “JUMP”) $\star _ { 8 }$ . + +Q: “jump opposite right twice after jump around right thrice” + +A: The output of “jump opposite right twice after jump around right thrice” concatenates: the output of “jump around right thrice”, the output of “jump opposite right twice”. “jump around right thrice” outputs (“TURN RIGHT” $^ +$ “JUMP”) $^ { \star } 8$ . “jump opposite right twice” outputs (“TURN RIGHT” $\yen 2$ $^ +$ “JUMP”) $\boldsymbol { \star } \ \boldsymbol { _ { 2 } }$ . So concatenating the output of “jump around right thrice” and the output of “jump opposite right twice” leads to (“TURN RIGHT” $^ +$ “JUMP”) $^ \star 8 +$ (“TURN RIGHT” \* 2 + “JUMP”) 2. So the output of “jump opposite right twice after jump around right thrice” is (“TURN RIGHT” $^ +$ “JUMP”) $^ { \star } 8 +$ (“TURN RIGHT” \* 2 + “JUMP”) $^ { \star } 2$ . + +# “walk around left thrice after walk right twice” + +# Golden: + +TURN RIGHT WALK TURN RIGHT WALK TURN LEFT WALK TURN LEFT WALK TURN LEFTWALK TURN LEFT WALK TURN LEFT WALK TURN LEFT WALK TURN LEFT WALK TURN LEFTWALK TURN LEFT WALK TURN LEFT WALK TURN LEFT WALK TURN LEFT WALK + +# Decomposition: + +Q: “walk around left thrice after walk right twice” +A: “walk around left thrice” can be solved by: “walk left”, “walk around left”, “walk around left thrice”. “walk right twice” can be solved by: “walk right”, “walk right twice”. So, “walk around left thrice after walk right twice” can be solved by: “walk left”, “walk around left”, “walk around left thrice”, “walk right”, “walk right twice”. + +# Solution: + +Q: “walk left” + +A: The output of “walk left” concatenates: the output of “turn left”, the output of “walk”. “turn left” outputs “TURN LEFT”. “walk” outputs “WALK”. So concatenating the output of “turn left” and the output of “walk” leads to “TURN LEFT” $^ +$ “WALK”. So the output of “walk left” is “TURN LEFT” $^ +$ “WALK”. + +Q: “walk around left” + +A: The output of “walk around left” concatenates: the output of “walk left”, the output of “walk left”, the output of “walk left”, the output of “walk left”. “walk left” outputs “TURN LEFT” $^ +$ “WALK”. So repeating the output of “walk around left” four times leads to (“TURN LEFT” $^ +$ “WALK”) $\times 4$ . So the output of “walk around left” is (“TURN LEFT” $^ +$ “WALK”) $\star _ { 4 }$ . + +Q: “walk around left thrice” + +A: The output of “walk around left thrice” concatenates: the output of “walk around left”, the output of “walk around left”, the output of “walk around left”. “walk around left” outputs (“TURN LEFT” $^ +$ “WALK”) $\times 4$ . So repeating the output of “walk around left” three times leads to (“TURN LEFT” $^ +$ “WALK”) $\star _ { 4 } \star _ { 3 }$ . So the output of “walk around left thrice” is (“TURN LEFT” $^ +$ “WALK”) $\star _ { 4 } \star _ { 3 }$ . + +Q: “walk right” + +A: The output of “walk right” concatenates: the output of “turn right”, the output of “walk”. “turn right” outputs “TURN RIGHT”. “walk” outputs “WALK”. So concatenating the output of “turn right” and the output of “walk” leads to “TURN RIGHT” $^ +$ “WALK”. So the output of “walk right” is “TURN RIGHT” $^ +$ “WALK”. + +Q: “walk right twice” + +A: The output of “walk right twice” concatenates: the output of “walk right”, the output of “walk right”. “walk right” outputs “TURN RIGHT” $^ +$ “WALK”. So repeating the output of “walk right” twice leads to (“TURN RIGHT” $^ +$ “WALK”) $^ { \star } 2$ . So the output of “walk right twice” is (“TURN RIGHT” $^ +$ “WALK”) $^ { \star } 2$ . + +Q: “walk around left thrice after walk right twice” + +A: The output of “walk around left thrice after walk right twice” concatenates: the output of “walk around left thrice”, the output of “walk right twice”. “walk around left thrice” outputs (“TURN LEFT” $+ ~ ^ { \circ } \mathsf { W A L K } ^ { \prime \prime } ) \ ^ { \star } ~ 4 \ ^ { \star } ~ 3$ . “walk right twice” outputs (“TURN RIGHT” $^ +$ “WALK”) $\yen 2$ . So concatenating the output of “walk around left thrice” and the output of “walk right twice” leads to (“TURN LEFT” $^ +$ “WALK”) $^ { \star } 4 ^ { \star } 3 +$ (“TURN RIGHT” $^ +$ “WALK”) $^ { \star } \sf { 2 }$ . So the output of “walk around left thrice after walk right twice” is (“TURN LEFT” $^ +$ “WALK”) $^ { \star } 4 ^ { \star } 3 +$ (“TURN RIGHT” $^ +$ “WALK”) $^ { \star } 2$ . + +# 8.4 EXPANDING PYTHON EXPRESSIONS USING PROMPTING + +In Section 3.2, we mention that expanding the Python expressions that we use as an intermediate representation can be done either with a simple postprocessing script or by prompting a language model. In the following, we present a prompt that achieves $9 9 . 7 \%$ accuracy on a random sample of 1000 Python expressions that are outputted by our solution (using the code-davinci-002 model). This demonstrates that the L2M method can solve SCAN with a combined accuracy more than $9 9 \%$ $( 9 9 . 7 \%$ accuracy for generating the intermediate Python expressions and $9 9 . 7 \%$ for expanding these expressions), even if we do not use the Python executor and instead perform the expansion of the intermediate representation via prompting. + +Q: “JUMP” $^ { \star } 3$ Rewrite: “JUMP” $^ { \star } 3$ A: 1 JUMP 2 JUMP 3 JUMP + +Q: “RUN” $\star _ { 4 } \star _ { 2 }$ +Rewrite: “RUN” \* 8 +A: 1 RUN 2 RUN 3 RUN 4 RUN 5 RUN 6 RUN 7 RUN 8 RUN + +Q: “TURN RIGHT” $^ +$ “WALK” Rewrite: “TURN RIGHT” $^ +$ “WALK” A: TURN RIGHT WALK + +Q: (“TURN LEFT” $^ +$ “LOOK”) $^ { \star } \boldsymbol { \sf { Z } } +$ “TURN LEFT” $^ +$ “LOOK” Rewrite: (“TURN LEFT” $^ +$ “LOOK”) $^ { \star } \boldsymbol { \sf { Z } } +$ “TURN LEFT” $^ +$ “LOOK” A: 1 (TURN LEFT LOOK) 2 (TURN LEFT LOOK) TURN LEFT LOOK + +Q: (“TURN RIGHT” $^ { \star } \boldsymbol { \sf { z } } +$ “JUMP”) \* 4 +Rewrite: (“TURN RIGHT” $^ { \star } \boldsymbol { \sf { Z } } +$ “JUMP”) \* 4 +A: 1 (1 TURN RIGHT 2 TURN RIGHT JUMP) 2 (1 TURN RIGHT 2 TURN RIGHT JUMP) 3 (1 +TURN RIGHT 2 TURN RIGHT JUMP) 4 (1 TURN RIGHT 2 TURN RIGHT JUMP) +Q: “TURN LEFT” $^ { \star } \boldsymbol { \sf { Z } } +$ (“TURN RIGHT” $^ +$ “WALK”) \* 4 \* 2 +Rewrite: “TURN LEFT” $\bf \Pi ^ { \star } 2 + ( \bar { \bar { \bf \Delta } } T U R N . \bar { R } I G H T ^ { \star } + \bar { \bar { \bf \Delta } } W A L K ^ { \star } ) \bar { \bf \Delta } ^ { \star } 8$ +A: 1 TURN LEFT 2 TURN LEFT 1 (TURN RIGHT WALK) 2 (TURN RIGHT WALK) 3 (TURN RIGHT +WALK) 4 (TURN RIGHT WALK) 5 (TURN RIGHT WALK) 6 (TURN RIGHT WALK) 7 (TURN RIGHT +WALK) 8 (TURN RIGHT WALK) + +Discussion. The prompt consists of 6 examples, each of which illustrates part of the knowledge needed for this task. Note that we add numbers and parentheses when we unfold multiplication to make it easier for the model to keep track of the repetitions. + +1. Multiplication +2. Sequential multiplication +3. Addition +4. Avoid commutativity / associativity in addition +5. Nested multiplication +6. Addition of two multiplications + +# 9 DROP + +9.1 RESULTS WITH T E X T-D A V I N C I-002 AND LM-540B + +We reported the results using code-davinci-002. Here, we report results using the text-davinci-002 model and a language model with 540 billion parameters (LM-540B). + +
text-davinci-002
Prompting methodNon-football (500 cases)Football (500 cases)
Zero-Shot27.0031.60
Standard prompting49.4054.40
Chain-of-Thought60.8057.40
Least-to-Most74.2063.40
+ +Table 16: Accuracies $( \% )$ of zero-shot and prompting methods with the GPT-3 text-davinci-002 model on the numerical reasoning subset of DROP. We evaluate on 500 randomly sampled non-football/football examples. Compared to Table ??, we observe that text-davinci-002 is consistently worse than code-davinci-002. + +# 9.2 NON-FOOTBALL SUBSET + +# 9.2.1 ZERO-SHOT PROMPTING + +For zero-shot, the prompt format is as follows: + +Q: {question} A: The answer is + +Notice that we add “The answer is” at the beginning of the answer section. + +
lm-540b
Prompting methodNon-football (3988 cases)Football (1862 cases)
Zero-Shot48.4244.95
Standard prompting56.5460.47
Chain-of-Thought63.8467.35
Least-to-Most79.2469.98
+ +Table 17: Accuracies $( \% )$ of zero-shot and prompting methods with a pretrained language model with 540 billion parameters $( \mathrm { l m } { - } 5 4 0 )$ . + +# 9.2.2 STANDARD PROMPTING WITH 3 EXAMPLES + +Q: Since the 1970s, U.S. governments have negotiated managed-trade agreements, such as the North American Free Trade Agreement in the 1990s, the Dominican Republic-Central America Free Trade Agreement in 2006, and a number of bilateral agreements. In Europe, six countries formed the European Coal and Steel Community in 1951 which became the European Economic Community in 1958. Two core objectives of the EEC were the development of a common market, subsequently renamed the single market, and establishing a customs union between its member states. How many years did the European Coal and Steel Community exist? + +A: The answer is 7. + +Q: In the county, the population was spread out with $2 3 . 5 0 \%$ under the age of 18, $8 . 7 0 \%$ from 18 to 24, $2 9 . 7 0 \%$ from 25 to 44, $2 4 . 7 0 \%$ from 45 to 64, and $1 3 . 3 0 \%$ who were 65 years of age or older. How many more percent are under the age of 18 compared to the 18 to 24 group? + +A: The answer is 14.8. + +Q: Playing in their second straight Thanksgiving game, the Eagles struggled especially on defense, where they were unable to stop the much-hyped Lions offense. The worst of it all was how unproven rookie Eric Rowe was tasked with covering wide receiver Calvin Johnson, leading to Johnson catching 3 touchdowns. Stafford’s five passing touchdowns, including three of them to Johnson was too much for the Eagles to overcome and for the second consecutive time this season, the Eagles gave up 45 points in a game. With the loss, the Eagles drop to 4-7 on the season and 6-1 when playing on Thanksgiving. How many TD passes did Stafford throw other than to Johnson? + +A: The answer is 2. + +# 9.2.3 CHAIN-OF-THOUGHT PROMPTING WITH 3 EXAMPLES + +Q: Since the 1970s, U.S. governments have negotiated managed-trade agreements, such as the North American Free Trade Agreement in the 1990s, the Dominican Republic-Central America Free Trade Agreement in 2006, and a number of bilateral agreements. In Europe, six countries formed the European Coal and Steel Community in 1951 which became the European Economic Community in 1958. Two core objectives of the EEC were the development of a common market, subsequently renamed the single market, and establishing a customs union between its member states. How many years did the European Coal and Steel Community exist? + +A: According to the passage, the European Coal and Steel Community was established in 1951 and became the EEC in $1 9 5 8 . \ 1 9 5 8 \textrm { - } 1 9 5 1 = 7 $ . So the answer is 7. + +Q: In the county, the population was spread out with $2 3 . 5 0 \%$ under the age of 18, $8 . 7 0 \%$ from 18 to 24, $2 9 . 7 0 \%$ from 25 to 44, $2 4 . 7 0 \%$ from 45 to 64, and $1 3 . 3 0 \%$ who were 65 years of age or older. How many more percent are under the age of 18 compared to the 18 to 24 group? + +A: According to the passage, $2 3 . 5 \%$ are under the age of 18, and $8 . 7 \%$ are from ages 18 to $2 4 . 2 3 . 5 \%$ - $8 . 7 \% = 1 4 . 8 \%$ . So the answer is 14.8. + +Q: Playing in their second straight Thanksgiving game, the Eagles struggled especially on defense, where they were unable to stop the much-hyped Lions offense. The worst of it all was how unproven rookie Eric Rowe was tasked with covering wide receiver Calvin Johnson, leading to Johnson catching 3 touchdowns. Stafford’s five passing touchdowns, including three of them to Johnson was too much for the Eagles to overcome and for the second consecutive time this season, the Eagles gave up 45 points in a game. With the loss, the Eagles drop to 4-7 on the season and 6-1 when playing on Thanksgiving. How many TD passes did Stafford throw other than to Jhonson? + +A: According to the passage, Stafford threw 5 TD passes, 3 of which were to Johnson. $5 - 3 = 2$ . So the answer is 2. + +# 9.2.4 LEAST-TO-MOST PROMPTING I: PROBLEM DECOMPOSITION (5 EXAMPLES) + +Q: The median age in the city was 22.1 years. $1 0 . 1 \%$ of residents were under the age of 18; $5 6 . 2 \%$ were between the ages of 18 and 24; $1 6 . 1 \%$ were from 25 to 44; $1 0 . 5 \%$ were from 45 to 64; and $7 \%$ were 65 years of age or older. Which age group is larger: under the age of 18 or 18 and 24? + +A: To answer the question “Which age group is larger: under the age of 18 or 18 and $2 4 ? ^ { , , }$ , we need to know: “How many percent were under the age of $1 8 ? { } ^ { , }$ , “How many percent were between the ages of 18 and 24?”. + +Q: Old age pensions were raised by 300 francs per month to 1,700 francs for a single person and to 3,700 francs for a couple, while health insurance benefits were made more widely available to unemployed persons and part-time employees. How many francs were the old age pensions for a single person before they were raised? + +A: To answer the question “How many francs were the old age pensions for a single person before they were raised?”, we need to know: “How many francs were the old age pensions for a single person?”, “How many francs were old age pensions raised for a single person?”. + +Q: In April 2011, the ECB raised interest rates for the first time since 2008 from $1 \%$ to $1 . 2 5 \%$ , with a further increase to $1 . 5 0 \%$ in July 2011. However, in 2012-2013 the ECB lowered interest rates to encourage economic growth, reaching the historically low $0 . 2 5 \%$ in November 2013. Soon after the rates were cut to $0 . 1 5 \%$ , then on 4 September 2014 the central bank reduced the rates from $0 . 1 5 \%$ to $0 . 0 5 \%$ , the lowest rates on record. How many percentage points did interest rates drop between April 2011 and September 2014? + +A: To answer the question “How many percentage points did interest rates drop between April 2011 and September 2014?”, we need to know: “What was the interest rate in April 2011?”, “What was the interest rate in September 2014?”. + +Q: Non-nationals make up more than half of the population of Bahrain. According to government statistics dated between 2005-2009 roughly 290,000 Indians, 125,000 Bangladeshis, 45,000 Pakistanis, 45,000 Filipinos, and 8,000 Indonesians. How many Pakistanis and Indonesians are in Bahrain? A: To answer the question “How many Pakistanis and Indonesians are in Bahrain?”, we need to know: “How many Pakistanis are in Bahrain?”, “How many Indonesians are in Bahrain?”. + +Q: The Census Bureaus 2006-2010 American Community Survey showed that (in 2010 inflation adjustment dollars) median household income was $\$ 52,056$ and the median family income was $\$ 58,942$ . How many years did the Census Bureaus American Community Survey last? + +A: To answer the question “How many years did the Census Bureaus American Community Survey last?”, we need to know: “When did the Census Bureaus American Community Survey start?”, “When did the Census Bureaus American Community Survey end?”. + +9.2.5 LEAST-TO-MOST PROMPTING II: PROBLEM SOLVING (3 EXAMPLES) + +The city of Bangkok has a population of 8,280,925. The census showed that it is home to 81,570 Japanese and 55,893 Chinese nationals, as well as 117,071 expatriates from other Asian countries, 48,341 from Europe, 23,418 from the Americas. + +Q: How many Chinese nationals are there? + +A: “The census showed that it is home to 81,570 Japanese and 55,893 Chinese nationals”. So the answer is 55,893 Chinese nationals. + +Q: How many European nationals are there? + +A: “48,341 from Europe”. So the answer is 48,341. + +Q: How many more Chinese nationals are there than European nationals? + +A: We know that there are 55,893 Chinese nationals. We also know that there are 48,341 European nationals. So there are $5 5 , 8 9 3 - 4 8 , 3 4 1 = 7 5 5 2$ more Chinese nationals than European nationals. So the answer is 7552. + +The gender distribution of the population was $5 0 . 2 \%$ male and $4 9 . 8 \%$ female. Of the adult population, 29 people or $1 4 . 6 \%$ of the population are between 20 and 29 years old. 28 people or $1 4 . 1 \%$ are + +30 to 39, 36 people or $1 8 . 2 \%$ are 40 to 49, and 31 people or $1 5 . 7 \%$ are 50 to 59. + +Q: What is the percentage of people between 40 to 49?. + +A: “36 people or $1 8 . 2 \%$ are 40 to $4 9 '$ . So the answer is 18.2 + +Q: How many percent of people were not 40 to 49? + +A: We know that $1 8 . 2 \%$ are 40 to 49. So $1 0 0 \% - 1 8 . 2 \% = 8 1 . 8 \%$ are not 40 to 49. So the answer is $8 1 . 8 \%$ . + +During the 1970s the oil shocks (1973 oil crisis and 1979 energy crisis) hit Iceland hard. Inflation rose to $43 \%$ in 1974 and $59 \%$ in 1980, falling to $15 \%$ in 1987 but rising to $30 \%$ in 1988. Iceland experienced moderately strong GDP growth $3 \%$ on average) from 1995 to 2004. Growth slowed between 2000 and 2002, but the economy expanded by $4 . 3 \%$ in 2003 and grew by $6 . 2 \%$ in 2004. Growth in 2005 exceeded $6 \%$ . + +Q: When did the oil crisis occur? + +A: “1973 oil crisis and 1979 energy crisis”. So the answer is 1973. + +Q: When did the energy crisis occur? + +A: “1979 energy crisis”. So the answer is 1979. + +Q: How many years passed between the oil and energy crises? + +A: We know that the oil crisis occurred in 1973. We also know that the energy crisis occurred in 1979. So $1 9 7 9 - 1 9 7 3 = 6$ years passed between the oil and energy crises. So the answer is 6. + +# 9.3 FOOTBALL SUBSET + +# 9.3.1 ZERO-SHOT PROMPTING + +For zero-shot, the prompt format is as follows: + +Q: {question} A: The answer is + +Notice that we add “The answer is” at the beginning of the answer section. + +# 9.3.2 STANDARD PROMPTING WITH 3 EXAMPLES + +Q: The Seahawks played the San Francisco 49ers. In the first quarter, the Hawks RB Julius Jones got a 27-yard TD run, along with DT Craig Terrill returning a fumble 9 yards for a touchdown. In the third quarter, the 49ers almost rallied as RB H. J. Torres made a 12-yard TD pass to Lucas Nelly, along with Mare kicking a 32-yard field goal. In the final quarter, Julius Jones got another 11-yard TD. How many yards do the shortest touchdown run and the longest touchdown pass combine for? + +A: The answer is 21. + +Q: The Steelers went home for a duel with the Baltimore Ravens. Pittsburgh would deliver the opening punch in the first quarter with a 1-yard touchdown from running back Rashard Mendenhall. The Ravens would make it even as running back Willis McGahee got a 9-yard TD. The Ravens kicker Billy Cundiff got a 45-yard field goal in the second quarter, concluding the first half with a 10-7 lead. The Steelers brought the game into overtime with a 38-yard field goal by Andrew Foster. The Ravens Billy Cundiff pulled off a winning 33-yard field goal in overtime. How many points did the Ravens have at halftime? + +A: The answer is 10. + +Q: The Vikings flew to Bank of America Stadium to face the Carolina Panthers. After a scoreless first quarter, Carolina got on the board with quarterback Matt Moore finding fullback Brad Hoover on a 1-yard TD pass. After yet another scoreless quarter, Carolina sealed the game as Matt Moore completed a 42-yard touchdown pass to wide receiver Steve Smith. How many scoreless quarters were there? + +A: The answer is 2. + +# 9.3.3 CHAIN-OF-THOUGHT PROMPTING WITH 3 EXAMPLES + +Q: The Seahawks played the San Francisco 49ers. In the first quarter, the Hawks RB Julius Jones got a 27-yard TD run, along with DT Craig Terrill returning a fumble 9 yards for a touchdown. In the third quarter, the 49ers almost rallied as RB H. J. Torres made a 12-yard TD pass to Lucas Nelly, along with Mare kicking a 32-yard field goal. In the final quarter, Julius Jones got another 11-yard TD. How many yards do the shortest touchdown run and the longest touchdown pass combine for? A: All the touchdown runs are: a 27-yard touchdown run, a 9-yard touchdown run, a 11-yard touchdown run. The smallest number among 27, 9, 11 is 9. So the shortest touchdown run was 9 yards. All the touchdown passes are: a 12-yard touchdown pass. So the longest touchdown pass was 12 yards. So the shortest touchdown run and the longest touchdown pass combine for $9 + 1 2 = 2 1$ yards. So the answer is 21 yards. + +Q: The Steelers went home for a duel with the Baltimore Ravens. Pittsburgh would deliver the opening punch in the first quarter with a 1-yard touchdown from running back Rashard Mendenhall. The Ravens would make it even as running back Willis McGahee got a 9-yard TD. The Ravens kicker Billy Cundiff got a 45-yard field goal in the second quarter, concluding the first half with a 10-7 lead. The Steelers brought the game into overtime with a 38-yard field goal by Andrew Foster. The Ravens Billy Cundiff pulled off a winning 33-yard field goal in overtime. How many points did the Ravens have at halftime? + +A: The Ravens kicker Billy Cundiff got a 45-yard field goal in the second quarter, concluding the first half with a 10-7 lead. So the Ravens had 10 points at halftime. So the answer is 10 points. + +Q: The Vikings flew to Bank of America Stadium to face the Carolina Panthers. After a scoreless first quarter, Carolina got on the board with quarterback Matt Moore finding fullback Brad Hoover on a 1-yard TD pass. After yet another scoreless quarter, Carolina sealed the game as Matt Moore completed a 42-yard touchdown pass to wide receiver Steve Smith. How many scoreless quarters were there? + +A: The first and third quarters were the scoreless quarters. So there are 2 scoreless quarters. So the answer is 2. + +# 9.3.4 LEAST-TO-MOST PROMPTING I: PROBLEM DECOMPOSITION (6 EXAMPLES) + +Q: The Seahawks played the San Francisco 49ers. In the first quarter, the ’Hawks RB Julius Jones got a 27-yard TD run, along with DT Craig Terrill returning a fumble 9 yards for a touchdown. In the third quarter, the 49ers almost rallied as RB T. J. Duckett made a 12-yard TD pass to Lucas Nelly, along with Mare kicking a 32-yard field goal. How many yards do the shortest touchdown run and the longest touchdown pass combine for? + +A: To answer the question “How many yards do the shortest touchdown run and the longest touchdown pass combine for?”, we need to know: “How many yards was the shortest touchdown run?”, “How many yards was the longest touchdown pass?”. + +Q: The Steelers went home for an AFC North duel with the Baltimore Ravens. Pittsburgh would deliver the opening punch in the first quarter with a 1-yard touchdown run from running back Rashard Mendenhall. The Ravens would make it even in the second quarter as running back Willis McGahee got a 9-yard touchdown run. The Ravens kicker Billy Cundiff got a 45-yard field goal in the second quarter and a 33-yard field goal in the third quarter. Game ended with a scoreless fourth quarter. How many points did the Ravens have at halftime? + +A: To answer the question “How many points did the Ravens have at halftime?”, we need to know: “What were all the scores the Ravens had at halftime?”. + +Q: In 1995, the Kings overcame a 3-4 start to win eight of their final nine games and finished with a record, the second-best in the AFC. Quarterback Neil ODonnell, who completed 246 out of 416 passes for 2,970 yards and 17 touchdowns, with only seven interceptions led their offense. The Kings finished their 1995 season having lost how many games difference to the number of games they had won? + +A: To answer the question “The Kings finished their 1995 season having lost how many games difference to the number of games they had won?”, we need to know: “How many games the Kings had lost in their 1995 season?”, “How many games the Kings had won in their 1995 season?”. + +Q: The Broncos traveled to Sun Life Stadium to face the Miami Dolphins. The Dolphins grabbed the lead in the second quarter, with field goals of 35 and 45 yards by kicker Dan Carpenter. In the final quarter, the Dolphins quarterback Matt Moore threw a 16-yard touchdown pass to tight end Anthony Fasano (with a failed two-point conversion attempt), followed by a 35-yard field goal by Carpenter, giving Miami a 15-0 lead. Finally, the Broncos answered with Alex Jake kicking a 48-yard field goal, ending the game with 15-3. How many yards was Dan Carpenter’s longest field goal? + +A: To answer the question “How many yards was Dan Carpenter’s longest field goal?”, we need to know: “What were all Dan Carpenter’s field goals?”. + +Q: The Cardinals flew to Gillette Stadium for a duel with the New England Patriots. In the fourth quarter, New England ended the boring game with Gostkowski’s 30-yard field goal. Original starting quarterback Kurt Warner (6/18 for 30 yards) was pulled in the third quarter via coach’s decision. How many incomplete passes did Kurt Warner have? + +A: To answer the question “How many incomplete passes did Kurt Warner have?”, we need to know: “How many passes did Kurt Warner attempt?”, “How many passes did Kurt Warner complete?”. + +Q: The Vikings flew to Bank of America Stadium to face the Carolina Panthers. After a scoreless first quarter, Carolina got on the board with quarterback Matt Moore finding fullback Brad Hoover on a 1-yard touchdown pass. After yet another scoreless quarter, Carolina sealed the game as Matt Moore completed a 42-yard TD pass to wide receiver Steve Smith. How many scoreless quarters were there? + +A: To answer the question “How many scoreless quarters were there?”, we need to know: “What were all the scoreless quarters?”. + +9.3.5 LEAST-TO-MOST PROMPTING II: PROBLEM SOLVING (3 EXAMPLES) + +The Seahawks played the San Francisco 49ers. In the first quarter, the ’Hawks RB Julius Jones got a 27-yard TD run, along with DT Craig Terrill returning a fumble 9 yards for a touchdown. In the third quarter, the 49ers almost rallied as RB H. J. Torres made a 12-yard TD pass to Lucas Nelly, along with Mare kicking a 32-yard field goal. In the final quarter, Julius Jones got another 11-yard TD. + +Q: How many yards was the shortest touchdown run? + +A: All the touchdown runs are: a 27-yard touchdown run, a 9-yard touchdown run, a 11-yard touchdown run. The smallest number between 27, 9, 11 is 9. The shortest touchdown run was 9 yards. The answer is 9. + +Q: How many yards was the longest touchdown pass? + +A: All the touchdown passes are: a 12-yard touchdown pass. The longest touchdown pass was 12 yards. The answer is 12. + +Q: How many yards do the shortest touchdown run and the longest touchdown pass combine for? + +A: We know that the shortest touchdown run was 9-yard. We also know that the longest touchdown pass was 12-yard. $9 + 1 2 = 2 1$ . The answer is 21. + +The Steelers went home for a duel with the Baltimore Ravens. Pittsburgh would deliver the opening punch in the first quarter with a 1-yard touchdown from running back Rashard Mendenhall. The Ravens would make it even as running back Willis McGahee got a 9-yard TD. The Ravens kicker Billy Cundiff got a 45-yard field goal in the second quarter, concluding the first half. The Steelers brought the game into overtime with a 38-yard field goal by Andrew Foster. The Ravens Billy Cundiff pulled off a winning 33-yard field goal in overtime. + +Q: What were all the scores the Ravens had at halftime? + +A: The answer is: a 9-yard touchdown run, a 45-yard field goal. + +Q: How many points did the Ravens have at halftime? + +A: We know that the Ravens had a touchdown and a field goal at halftime. We also know that a touchdown is worth 7 points and a field goal is worth 3 points. $7 + 3 = 1 0$ . The answer is 10. + +The Vikings flew to Bank of America Stadium to face the Carolina Panthers. After a scoreless first quarter, Carolina got on the board with quarterback Matt Moore finding fullback Brad Hoover on a 1-yard TD pass. After yet another scoreless quarter, Carolina sealed the game as Matt Moore completed a 42-yard touchdown pass to wide receiver Steve Smith. + +Q: What were all the scoreless quarters? + +A: The answer is: the first quarter and the third quarter. + +Q: How many scoreless quarters were there? + +A: We know that the first and third quarters were all the scoreless quarters. The answer is 2. + +.4 EXAMPLES WHERE LEAST-TO-MOST SUCCEEDED BUT CHAIN-OF-THOUGHT FAILE + +# 9.4.1 CASE 1 + +Q: The first two Buick automobiles were made in 1899 and 1900 at the “Buick Auto-Vim and Power Company” by chief-engineer Walter Lorenzo Marr, but company owner David Dunbar Buick was reluctant to begin making automobiles, being satisfied with stationary and marine engine production, so Marr left Buick in 1901 to found Marr (automobile) under his own name. His replacement was Eugene Richard, who applied for a patent in 1902 for Marrs valve-in-head (Overhead valve engine) engine, which patent, number 771,095, was awarded to Richard in the name of Buick in 1904. In 1903, the third Buick automobile was made, this time by Richard, but in 1904 Buick, whose company was now called “Buick Motor Company,” moved to Flint, Michigan, and Richard stayed behind. Marr was rehired in Flint as chief engineer, to begin making automobiles in production. That year, 37 Buick automobiles were made, production increasing to 750 in 1905, 1,400 in 1906, 4,641 in 1907, and 8,800 in 1908, taking the number one spot away from close competitors Oldsmobile, Ford Motor Company, and Maxwell automobile. How many Buick automobiles were built between 1904 and 1905? + +Chain-of-thought by code-davinci-002 A: According to the passage, 37 Buick automobiles were made in 1904, and 750 were made in 1 $9 0 5 . 7 5 0 \cdot 3 7 = 7 1 3 .$ . So the answer is 713. + +Least-to-most by code-davinci-002 Q: How many Buick automobiles were built in 1904? A: “In 1903, the third Buick automobile was made, this time by Richard, but in 1904 Buick, whose company was now called “Buick Motor Company,” moved to Flint, Michigan, and Richard stayed behind. Marr was rehired in Flint as chief engineer, to begin making automobiles in production. That year, 37 Buick automobiles were made”. So the answer is 37. + +Q: How many Buick automobiles were built in 1905? +A: “production increasing to 750 in $1 9 0 5 '$ . So the answer is 750. +Q: How many Buick automobiles were built between 1904 and 1905? +A: We know that 37 Buick automobiles were built in 1904. We also know that 750 Buick automobiles were built in 1905. So $3 7 + 7 5 0 = 7 8 7$ Buick automobiles were built between 1904 and 1905. So the answer is 787. + +Analysis Chain-of-thought failed because it computed $^ { * } 7 5 0 \ - \ 3 7 = 7 1 3 ^ { , }$ , which is wrong. The correct answer is $^ { * } 3 7 + 7 5 0 = 7 8 7 ^ { * }$ . + +# 9.4.2 CASE 2 + +Q: The Guatemalan authorities were unaware of ongoing contacts between the colonial authorities in Yucatan and the Itza. In the second half of 1695 President Barrios began planning another expedition ´ against the Itza from Verapaz, following harsh criticism of Juan D´ıaz de Velasco’s retreat from near Lake Peten Itz ´ a in April of that year. Barrios died in November, and oidor Jos ´ e de Escals became ´ acting head of the Guatemalan colonial administration. He appointed oidor Bartolome de Am ´ esqueta ´ to lead the next expedition against the Itza. Amesqueta marched his men through torrential rain ´ from Cahabon to Mop ´ an, arriving on 25 February 1696; the Guatemalans were still unaware of the ´ clashes between Garc´ıa’s forces and the Itza. Amesqueta’s expedition was suffering from shortages ´ of native labour and supplies. Twenty-five of his 150 men were sick, and his advance stalled as the force rested up at Mopan. Captain D ´ ´ıaz de Velasco volunteered to lead a party of 25 men ahead to the lake; he was accompanied by Dominican friars Cristobal de Prada and Jacinto de Vargas. He was ´ also accompanied by AjK’ixaw, the Itza nobleman who had been taken prisoner on D´ıaz’s previous expedition, who served as a trusted guide, scout and translator. They set out from Mopan on 7 March ´ and left some sick soldiers with some supplies after five days, they then caught up with an advance party of roadbuilders and their military escort at R´ıo Chakal. The two forces combined, giving D´ıaz a force of 49 soldiers and 34 porters and archers from Verapaz. Once they arrived at IxB’ol, near the shore of Lake Peten Itz ´ a, AjK’ixaw was sent ahead as an emissary to Nojpet ´ en. How many months ´ after Juan D´ıaz de Velasco’s retreat did President Barrios die? + +Chain-of-thought by code-davinci-002 A: According to the passage, President Barrios died in November, and the expedition against the Itza was led by Bartolome de Am ´ esqueta in Febru- ´ ary. So the answer is 3. + +Least-to-most by code-davinci-002 Q: When did Juan D´ıaz de Velasco’s retreat? + +A: “April of that year”. So the answer is April. +Q: When did President Barrios die? +A: “November”. So the answer is November. +Q: How many months after Juan D´ıaz de Velasco’s retreat did President Barrios die? +A: We know that Juan D´ıaz de Velasco’s retreat was in April. We also know that President Barrios died in November. So November - April $= 7$ months after Juan D´ıaz de Velasco’s retreat did President Barrios die. So the answer is 7. + +Analysis Chain-of-thought generated the wrong final answer because one fact it used, “the expedition against the Itza was led by Bartolome de Am ´ esqueta in February”, is unrelated. ´ + +# 9.4.3 CASE 3 + +Q: Peele was christened on 25 July 1556 at St James Garlickhythe in the City of London. His father, James Peele (d. Dec 30, 1585), who appears to have belonged to a Devonshire family, was clerk of Christs Hospital, a school which was then situated in central London, and wrote two treatises on bookkeeping, The Maner and Fourme How to Kepe a Perfecte Reconyng (1553) and The Pathe Waye to Perfectnes (1569). The latter depicts James Peele in a woodcut on the title page. No contemporary likeness of George is known, although he was said to be short-legged, dark complected, red haired, and squinting, although not necessarily from reliable sources. Georges mother, Anne, died July 1, 1580, and his father married Christian Widers (d. 1597 in St. Christopher le Stocks) on November 3, 1580. She became a nurse on the Hospital payroll, where she remained five years after James Peeles death, when she married Ralph Boswell. His siblings included Anne (d. Jan 10, 1568/9), Isabel, Judith (d. Apr. 16, 1582), and James (b. Jan 3, 1563/4). Anne married John Alford on May 14, 1565, and had one son, Robert (October 9, 1567- c. March 12, 1654/5). Judith married John Jackman on June 19, 1575, and had three children, Susan (b. June 3, 1576), William (April 30, 1577-July 1, 1577), and Sarah (d. May 24, 1578). On Feb. 5, 1568/9, Isabel married Mathew Shakespeare, with whom she had eight children. Many scholars believe that this was a cousin of William Shakespeare, but this has not been verified. James Peele also wrote the Ironmongers Pageants of 1566 and 1569, which may have led to Georges writing of two Lord Mayors pageants. How many years after her marriage to James Peele did Christian Widers die? + +Chain-of-thought by code-davinci-002 A: According to the passage, Christian Widers died in 1597. James Peele died in 1585. 1597 - 1585 = 12. So the answer is 12. + +Least-to-most by code-davinci-002 Q: When did Christian Widers marry James Peele? + +A: “She became a nurse on the Hospital payroll, where she remained five years after James Peeles death, when she married Ralph Boswell”. So the answer is 1580. + +Q: When did Christian Widers die? +A: “She became a nurse on the Hospital payroll, where she remained five years after James Peeles death, when she married Ralph Boswell”. So the answer is 1597. + +Q: How many years after her marriage to James Peele did Christian Widers die? A: We know that Christian Widers married James Peele in 1580. We also know that Christian Widers died in 1597. So $1 5 9 7 - 1 5 8 0 = 1 7$ years after her marriage to James Peele did Christian Widers die. So the answer is 17. + +Analysis Chain-of-thought generated the wrong final answer because one fact it used, “James Peele died in $1 5 8 5 '$ , is unrelated. + +# 9.4.4 CASE 4 + +Q: Among the other denominations there are approximately 93,000 Mormons in 253 congregations, 25,000 Jewish adherents in 21 synagogues, 12,000 Muslims in 39 masjids, 7,000 Buddhists in 34 temples, 7,000 Hindus in 17 temples, 2,500 Unitarian Universalism in 9 congregations, 2,000 Bahai in 17 temples, 5 Sikh temples, a Zoroastrian temple, a Jain temple and an uncounted number of neopagans. How many more Mormons were there compared to Muslims? + +Chain-of-thought by code-davinci-002 A: According to the passage, there are 93,000 Mormons and 25,000 Muslims. $9 3 , 0 0 0 - 2 5 , 0 0 0 = 6 8 , 0 0 0$ . So the answer is 68,000. + +Least-to-most by code-davinci-002 Q: How many Mormons were there? + +A: “93,000 Mormons”. So the answer is 93,000. +Q: How many Muslims were there? +A: “12,000 Muslims”. So the answer is 12,000. +Q: How many more Mormons were there compared to Muslims? +A: We know that there were 93,000 Mormons. We also know that there were 12,000 Muslims. So there were $9 3 , 0 0 0 - 1 2 , 0 0 0 = 8 1 , 0 0 0$ more Mormons than Muslims. So the answer is 81,000. + +Analysis Chain-of-thought failed because it got one intermediate fact (the number of Muslims) wrong. + +# 9.4.5 CASE 5 + +Q: Killigrew lived in Hanworth in Middlesex and Falmouth in Cornwall. On 4 November 1566 Killigrew married in the church of St Peter Le Poer, London, Catherine, fourth daughter of Sir Anthony Cooke. He thus became Cecil’s brother-in-law. His wife died in 1583, and on 7 November 1590 he was married in the same church to Jael de Peigne, a French Hugenot. She was naturalised ´ in June 1601. After Henry’s death she remarried on 19 April 1617 George Downham, Bishop of Derry, and died c.1632. By his first wife, Killigrew had four daughters: How many years after here marriage to Killigrew did Catherine die? + +Chain-of-thought by code-davinci-002 A: According to the passage, Catherine died in 1583, and Killigrew married Jael de Peigne in 1590. 1590 - 1583 = 7. So the answer is 7. ´ + +Least-to-most by code-davinci-002 Q: When did Catherine marry Killigrew? + +A: “On 4 November 1566 Killigrew married in the church of St Peter Le Poer, London, Catherine”. So the answer is 4 November 1566. +Q: When did Catherine die? +A: “His wife died in 1583”. So the answer is 1583. +Q: By his first wife, Killigrew had four daughters: How many years after here marriage to Killigrew did Catherine die? +A: We know that Catherine married Killigrew in 1566. We also know that Catherine died in 1583. S $\phantom { + } 0 1 5 8 3 - 1 5 6 6 = 1 7$ years after here marriage to Killigrew did Catherine die. So the answer is 17. + +Analysis Chain-of-thought generated the wrong final answer because one fact it used, “Killigrew married Jael de Peigne in´ $1 5 9 0 ^ { \circ }$ , is unrelated. + +# 9.5 ERROR ANALYSIS: LEAST-TO-MOST PROMPTING + +We randomly picked 20 failure cases, and found that out of those 20 failure cases: + +• 4 are due to wrong problem decomposition – the decomposed problems do not make sense, or there is no decomposition at all. • 13 are due to wrong problem solving – it gave the wrong answer for a decomposed problem. + +• 3 are due to wrong “ground truth” – the given label is wrong regardless whether the prediction is correct or not (although, the model predictions for the sampled 4 cases are all correct). + +# 9.5.1 EXAMPLE OF WRONG PROBLEM DECOMPOSITION + +In the following example, the decomposed question is just a rephrase of the original question. + +Q: Then, in 1544, five French galleys under Polin, including the superb Reale, accompanied Bar- ´ barossa’s fleet, on a diplomatic mission to Suleiman. The French fleet accompanied Barbarossa during his attacks on the west coast of Italy on the way to Constantinople, as he laid waste to the cities of Porto Ercole, Giglio, Talamona, Lipari and took about 6,000 captives, but separated in Sicily from Barbarossa’s fleet to continue alone to the Ottoman capital. Jerome Maurand, a priest ˆ of Antibes who accompanied Polin and the Ottoman fleet in 1544, wrote a detailed account in Itineraire d’Antibes ´ a Constantinople. They arrived in Constantinople on 10 August 1544 to meet \` with Suleiman and give him an account of the campaign. Polin was back to Toulon on 2 October 1544. On his way to Constantinople, how many cities did Polin laid waste to? + +A: To answer the question ”On his way to Constantinople, how many cities did Polin laid waste to?”, we need to know: ”How many cities did Polin laid waste to on his way to Constantinople?”. + +# 9.5.2 EXAMPLE OF WRONG PROBLEM SOLVING + +In the following example, the answer to the decomposed question, “How many percent of people were from 2 or more races in 2000?” is wrong. + +As of 2011 the 88,112 residents of Orem had a racial and ethnic composition of $8 9 . 3 \%$ White American, $0 . 9 \%$ black or African American, $0 . 9 \%$ Native Americans of the United States, $1 . 6 \%$ Asian American, $0 . 5 \%$ Pacific Islanders, $4 \%$ non-Hispanics reporting some other race, $2 . 9 \%$ two or more races reported and $1 4 . 8 \%$ Hispanic, as Orem has a large Mexican American community with other Latinos residing in the city. This contrasts with the census of 2000, which showed a racial makeup of $9 0 . 8 0 \%$ White (U.S. Census), $0 . 3 3 \%$ African American (U.S. Census), $0 . 7 3 \%$ Native American (U.S. Census), $1 . 4 5 \%$ Asian (U.S. Census), $0 . 8 6 \%$ Pacific Islander (U.S. Census), $3 . 6 4 \%$ from Race (United States Census), and $2 . 1 8 \%$ from two or more races. Hispanic (U.S. Census) or Latino (U.S. Census) of any race were $8 . 5 6 \%$ of the population. The 2000 Census counted 84,324 people, 23,382 households, and 19,079 families. The population density at that time was 4,572.6 people per square mile $( 1 , 7 6 5 . 6 / \mathrm { k m ^ { 2 } } )$ . There were 24,166 housing units at an average density of 1,310.4 per square mile $( 5 0 6 . 0 / \mathrm { k m } ^ { 2 } )$ ). There were 23,382 households out of which $4 8 . 8 \%$ had children under the age of 18 living with them, $6 9 . 0 \%$ were Marriage living together, $9 . 5 \%$ had a female householder with no husband present, and $1 8 . 4 \%$ were non-families. $1 2 . 4 \%$ of all households were made up of individuals and $5 . 1 \%$ had someone living alone who was 65 years of age or older. The average household size was 3.57 and the average family size was 3.93. + +Q: How many percent of people were from 2 or more races in 2000? +A: “ $3 . 6 4 \%$ from Race (United States Census), and $2 . 1 8 \%$ from two or more races”. So the answer is $3 . 6 4 \% + 2 . 1 8 \% = 5 . 8 2 \%$ . Q: How many percent of people were not from 2 or more races in 2000? +A: We know that $5 . 8 2 \%$ were from 2 or more races. So $1 0 0 \% - 5 . 8 2 \% = 9 4 . 1 8 \%$ were not from 2 or more races. So the answer is $9 4 . 1 8 \%$ . + +# 9.5.3 EXAMPLE OF WRONG GIVEN LABEL + +In the example below, the given label is 417, which is incorrect. The correct ground truth should be 418. The model gives the correct answer via least-to-most prompting. + +There were 20,928 births in 2006. Of these, 19,757 $9 4 . 4 0 \%$ of the births, $9 5 . 1 9 \%$ of the population) were to Non-Hispanic Whites. There were 22 births to American Indians $0 . 1 1 \%$ of the births and $0 . 5 4 \%$ of the population), 177 births to Asians $( 0 . 8 5 \%$ of the births and $0 . 6 8 \%$ of the population), 219 births to Hispanics $1 . 0 5 \%$ of the births and $0 . 8 8 \%$ of the population) and 753 births to Blacks and others ( $3 . 6 0 \%$ of the births and $3 . 5 6 \%$ of the population). + +Q: How many births were there for Asians? + +A: “177 births to Asians”. So the answer is 177. +Q: How many births were there for Native Americans? +A: “22 births to American Indians”. So the answer is 22. +Q: How many births were there for Hispanics? +A: “219 births to Hispanics”. So the answer is 219. +Q: How many total births were there for Asians, Native Americans and Hispanics? +A: We know that there were 177 births for Asians. We also know that there were 22 births for Native Americans. We also know that there were 219 births for Hispanics. So $1 7 7 + 2 2 + 2 1 9 = 4 1 8$ total births for Asians, Native Americans and Hispanics. So the answer is 418. + +# 10 GSM8K + +# 10.1 EXPERIMENT RESULTS: ONE-SHOT PROMPTS + +We compare here the effectiveness on compositional generalization of least-to-most prompting vs. chain-of-thought prompting by constructing for each prompting method a simple prompt context that contains a single example that is solvable with just 2 reasoning steps. We then evaluate accuracy on examples that may involve larger numbers of reasoning steps. The same example is used for both prompting methods. For the least-to-most prompting prompt, we adopt a simplified approach in which the problem decomposition and solution stages are merged into a single pass, with just one follow-up request being made to the language model to solicit the final answer. + +The accuracy $( \% )$ of the two prompting methods with the GPT-3 code-davinci-002 model, with breakdown by number of steps in the expected solution, are listed in Table 18. + +Accuracy numbers for all prompting methods are calculated after applying the same post-processing as described in Section 3.3 for DROP. + +While the least-to-most prompting accuracy is overall only moderately higher than that of chain-ofthought prompting, the accuracy breakdown by number of steps shows that least-to-most prompting significantly outperforms chain-of-thought prompting as the number of reasoning steps increases beyond what was illustrated in the prompt. + +
Accuracy by StepsAll2345+
Least-to-Most (1-shot): a L62.3974.5368.9159.7345.23
Chain-of-Thought (1-shot): ac60.8776.6867.2959.3939.07
Accuracy change: (aL/ac)-1+2.49-2.80+2.40+0.58+15.77
+ +Table 18: Accuracy $( \% )$ of a simple 1-shot least-to-most prompt with the GPT-3 code-davinci-002 model on GSM8K, compared to that of a corresponding chain-of-thought prompt, broken down by number of reasoning steps required in the expected solution. Examples with 3 or more reasoning steps would require generalizing to more steps than were shown in the demonstration example in the prompt (which contains just 2 steps). + +# 10.2 EXPERIMENT RESULTS: ENGINEERED PROMPTS + +We compare here the overall accuracy of the above-reported “Chain-of-Thought (1-shot)” and “Least-to-Most (1-shot)” methods with alternative existing prompting methods, as well as with variants of chain-of-thought and least-to-most prompting in which the prompts were engineered using multiple in-domain examples taken from the GSM8K train set. + +The evaluated prompting methods are as follows (see Appendices 10.3 and 10.4 for the exact prompt contexts): + +• Zero-Shot: Simple zero-shot prompting. +• Standard prompting: Standard few-shot prompting, using the same 4 examples as in the “problem solving” prompt context of “Least-to-Most (best)”. +• Chain-of-Thought (original): Chain-of-thought prompting, using the original 8-shot prompt context described in Wei et al. (2022). Chain-of-Thought (1-shot): The simple 1-shot chain-of-thought prompting method described in Appendix 10.1 above. +• Least-to-Most (1-shot): The simple 1-shot least-to-most prompting method described in Appendix 10.1 above. +• Chain-of-Thought (best): Chain-of-thought prompting, using the same 4 examples as in the “problem solving” prompt context of “Least-to-Most (best)”, with the solutions adjusted to chain-of-thought format. Least-to-Most (best): Least-to-most prompting using separate prompts for the “problem decomposition” and “problem solution” steps and with multiple examples selected from the GSM8K train set. The “problem decomposition” prompt context contains 7 examples, with hand-crafted problem decompositions. The “problem solution” prompt contains 4 examples, with hand-crafted solutions for each step. + +The accuracies $( \% )$ of these prompting methods with the GPT-3 code-davinci-002 model are listed in Table 19. + +It can be noted first that, although the “Chain-of-Thought (1-shot)” prompt context is considerably simpler than the 8-shot prompt context proposed in the original chain-of-thought paper, we find the overall accuracy achieved to be quite close $6 0 . 8 7 \%$ for the 1-shot prompt, compared to $6 1 . 1 8 \%$ for the original 8-shot prompt). This suggests that “Chain-of-Thought (1-shot)” is indeed a reasonable chain-of-thought baseline to analyze in comparison to “Least-to-Most (1-shot)”. + +Further, while we find the proposed 1-shot prompt attractive due to its simplicity and lack of datasetspecific content, we do find that further improvements in overall accuracy of both chain-of-thought and least-to-most prompting can be achieved if additional prompt engineering is applied, using multiple in-domain examples of arbitrary complexity from the GSM8K train set, as seen in the accuracies of “Chain-of-Thought (best)” and “Least-to-Most (best)”. We do not observe improvement in overall accuracy from least-to-most prompting compared to chain-of-thought prompting in this setting, where most of the test questions do not require more steps more steps to solve than the demonstration examples. + +
Prompting methodAccuracy
Zero-Shot16.38
Standard prompting17.063
Chain-of-Thought (original)61.18
Chain-of-Thought (1-shot)60.88
Least-to-Most (1-shot)62.39
Chain-of-Thought (best)68.613
Least-to-Most (best)68.01
+ +Table 19: Accuracies $( \% )$ of various prompting methods with the GPT-3 code-davinci-002 model on GSM8K. + +# 10.3 PROMPT CONTEXTS: ONE-SHOT PROMPTS + +We include here the prompt contexts used in the experiments reported in Appendix 10.1. + +In this section and in the following one, the placeholder “{question}” indicates the place where the original question is to be inserted, in cases where the format would not be obvious (e.g., where instead of simply ending the prompt with “A:”, we include some additional prompt text like “A: The answer is”). + +In the case of “Least-to-Most (1-shot)”, the prompt prefix for the initial request ends in “Let’s break down this problem:”. We then append to that prompt the initial reply that was received from the language model, followed by a newline and the string “The answer is:”, which we then use as the prompt in a second request, whose reply we treat as the final answer. + +# 10.3.1 CHAIN-OF-THOUGHT (1-SHOT) + +Q: Elsa has 5 apples. Anna has 2 more apples than Elsa. How many apples do they have together? A: Anna has 2 more apples than Elsa, so Anna has $2 + 5 = 7$ apples. Elsa and Anna have $5 + 7 = 1 2$ apples together. The answer is 12. + +# 10.3.2 LEAST-TO-MOST (1-SHOT) + +: Elsa has 5 apples. Anna has 2 more apples than Elsa. How many apples do they have together + +A: Let’s break down this problem: 1. How many apples does Anna have? 2. How many apples do Elsa and Anna have together? + +1. Anna has 2 more apples than Elsa. So Anna has $2 + 5 = 7$ apples. + +2. Elsa and Anna have $5 + 7 = 1 2$ apples together. + +Q: {question} +A: Let’s break down this problem: +The answer is: + +# 10.4 PROMPT CONTEXTS: ENGINEERED PROMPTS + +We include here the additional prompt templates used in the experiments reported in Appendix 10.2, with the exception of “Chain-of-Thought (original)“, which is the same as the “Prompt for Math Word Problems” reported in Appendix G of Wei et al. (2022). + +# 10.4.1 ZERO-SHOT + +Q: {question} A: The answer is + +10.4.2 STANDARD PROMPTING: 4 EXAMPLES + +Q: Four years ago, Kody was only half as old as Mohamed. If Mohamed is currently twice 30 years old, how old is Kody? + +A: The answer is 32. + +Q: Carla bought 2 bags of mini peanut butter cups on clearance. Each bag was $\$ 600$ but was $7 5 \%$ off. How much did she spend on 2 bags of candy? + +A: The answer is 3. + +Q: If Pam is currently twice as young as Rena is, and in 10 years Rena will be 5 years older than her, how old is Pam now? + +A: The answer is 5. + +Q: Cappuccinos cost $\$ 2$ , iced teas cost $\$ 3$ , cafe lattes cost $\$ 1.5$ and espressos cost $\$ 1$ each. Sandy orders some drinks for herself and some friends. She orders three cappuccinos, two iced teas, two cafe lattes, and two espressos. How much change does she receive back for a twenty-dollar bill? + +A: The answer is 3. + +# 10.4.3 CHAIN-OF-THOUGHT (BEST): 4 EXAMPLES + +Q: Four years ago, Kody was only half as old as Mohamed. If Mohamed is currently twice 30 years old, how old is Kody? + +A: We were told that Mohamed is currently twice 30 years old, so he is currently $3 0 * 2 = 6 0$ years old. That means that four years ago he must have been $6 0 - 4 = 5 6$ years old. Four years ago, Kody was half as old as Mohamed, so Kody must have been $5 6 / 2 = 2 8 $ years old then. Since Kody was 28 years old four years ago, she must now be $2 8 + 4 = 3 2$ years old. The answer is 32. + +Q: Carla bought 2 bags of mini peanut butter cups on clearance. Each bag was $\$ 600$ but was $7 5 \%$ off. How much did she spend on 2 bags of candy? + +A: Each bag was $\$ 600$ but was $7 5 \%$ off. So each bag cost $\ S 6 . 0 0 \ast \left( 1 - 0 . 7 5 \right) = \ S 6 . 0 0 \ast 0 . 2 5 = \ S 1 . 5 0$ Carla bought 2 bags. So she spent $\$ 1.50*2=\ S 3.00$ . The answer is 3. + +Q: If Pam is currently twice as young as Rena is, and in 10 years Rena will be 5 years older than her, how old is Pam now? + +A: Since Rena will be 5 years older than Pam in 10 years, she must be 5 years older than Pam now as well. If Pam is currently twice as young as Rena, that means that Rena is currently twice as old as Pam is. So if P stands for Pam’s age now and R stands for Rena’s age now, then we know that R ${ \bf \Lambda } = 2 { \bf \Lambda } ^ { * } \mathrm { \bf P }$ And since Rena is 5 years older than Pam now, we know that ${ \sf R } = { \sf P } + 5$ . By substitution, we have $\mathrm { P } + 5 = 2 \ast \mathrm { P } ,$ which means that $\boldsymbol { \mathrm { P } } = 5$ . The answer is 5. + +Q: Cappuccinos cost $\$ 2$ , iced teas cost $\$ 3$ , cafe lattes cost $\$ 1.5$ and espressos cost $\$ 1$ each. Sandy orders some drinks for herself and some friends. She orders three cappuccinos, two iced teas, two cafe lattes, and two espressos. How much change does she receive back for a twenty-dollar bill? + +A: Sandy ordered three cappuccinos, which cost $\$ 2$ each, so she spent $\$ 2$ on cappuccinos. She ordered two iced teas, which cost $\$ 3$ each, so she spent $\$ 3*2=9$ dollars on ice teas. She ordered two cafe lattes, which cost $\$ 1.5$ each, so she spent $\$ 1.5 *2=\ S 3$ on cafe lattes. She ordered two espressos, which cost $\$ 1$ each, so she spent $\$ 1*2=\ S 2$ on espressos. So altogether, Sandy spent $\$ 6+86+8 3+ \ S 2= \ S 17$ on drinks, which means that sandy will get $\$ 20-\$ 17=93$ as change. The answer is 3. + +0.4.4 LEAST-TO-MOST (BEST) I - PROBLEM DECOMPOSITION: 7 EXAMPLE + +Q: Four years ago, Kody was only half as old as Mohamed. If Mohamed is currently twice 30 years old, how old is Kody? + +A: To answer the question “How old is Kody?”, we need to know: “How old is Mohamed?”, “How old was Mohamed four years ago?”, “How old was Kody four years ago?”. + +Q: If Pam is currently twice as young as Rena is, and in 10 years Rena will be 5 years older than her, how old is Pam now? + +A: To answer the question “How old is Pam now?”, we need to know: “How much older is Rena than Pam currently?”. + +Q: As a freelancer, Baylor is paid for every finished work of a client he does on a freelance marketplace. Currently, he has $\$ 4000$ on his dashboard from previous work done. He is currently working for three clients, with the first client paying him half the amount of money he currently has on his dashboard once the job is done. The second client will pay him 2/5 times more money than the first client once Baylor finishes his work. The third client will pay him twice the amount of money the first and second clients pay him together once he finishes the job. How much money will Baylor have in his dashboard after all the clients pay him for his work? + +A: To answer the question “How much money will Baylor have in his dashboard after all the clients pay him for his work?”, we need to know: “How much will Baylor’s first client pay him for his work?”, “How much more will Baylor’s second client pay him for his work compared to the first client?”, “How much will Baylor’s second client pay him for his work?”, “How much will the first and second clients pay him together once he finishes the job?”, “How much will Baylor’s third client pay him for his work?”, “How much money will all the clients pay Baylor for his work?”. + +Q: Cappuccinos cost $\$ 2$ , iced teas cost $\$ 3$ , cafe lattes cost $\$ 1.5$ and espressos cost $\$ 1$ each. Sandy orders some drinks for herself and some friends. She orders three cappuccinos, two iced teas, two cafe lattes, and two espressos. How much change does she receive back for a twenty-dollar bill? + +A: To answer the question “How much change does she receive back for a twenty-dollar bill?”, we need to know: “How much did the cappuccinos cost in total?”, “How much did the iced teas cost in total?”, “How much did the cafe lattes cost in total?”, “How much did the espressos cost in total?”, “How much did the drinks cost in total?”. + +Q: Betty & Paige are raising money for their kids’ little league team by hosting a bake sale. Betty has baked 4 dozen chocolate chip cookies, 6 dozen oatmeal raisin cookies and 2 dozen regular brownies. Paige baked 6 dozen sugar cookies, 3 dozen blondies and 5 dozen cream cheese swirled brownies. If they sell the cookies for $\$ 1.00$ apiece and the blondies/brownies at $\$ 2.00$ apiece, how much money will they raise? + +A: To answer the question “How much money will they raise?”, we need to know: “How many dozen cookies did they bake (not including blondies/brownies)?”, “How many cookies did they bake (not including blondies/brownies)?”, “How many dozen blondies/brownies did they bake (not including cookies)?”, “How many blondies/brownies did they bake (not including cookies)?”, “How much money will they raise from the cookies (not including blondies/brownies)?”, “How much money will they raise from the blondies/brownies (not including cookies)?”. + +Q: On a moonless night, three fireflies danced in the evening breeze. They were joined by four less than a dozen more fireflies, before two of the fireflies flew away. How many fireflies remained? + +A: To answer the question “How many fireflies remained?”, we need to know: “How many fireflies joined?”. + +Q: Sam, Sid, and Steve brought popsicle sticks for their group activity in their Art class. Sam has thrice as many as Sid, and Sid has twice as many as Steve. If Steve has 12 popsicle sticks, how many popsicle sticks can they use for their Art class activity? + +A: To answer the question “How many popsicle sticks can they use for their Art class activity?”, we need to know: “How many popsicle sticks does Sid have?”, “How many popsicle sticks does Sam have?”. + +10.4.5 LEAST-TO-MOST (BEST) II - PROBLEM SOLVING: 4 EXAMPLES + +Four years ago, Kody was only half as old as Mohamed. If Mohamed is currently twice 30 years old, how old is Kody? + +Q: How old was Mohamed four years ago? + +A: We were told that Mohamed is currently twice 30 years old, so he is currently $3 0 * 2 = 6 0$ years old. That means that four years ago he must have been $6 0 - 4 = 5 6$ years old. The answer is 56. + +Q: How old is Kody? + +A: Four years ago, Kody was half as old as Mohamed, so Kody must have been $5 6 / 2 = 2 8 $ years old then. Since Kody was 28 years old four years ago, she must now be $2 8 + 4 = 3 2$ years old. The answer is 32. + +Carla bought 2 bags of mini peanut butter cups on clearance. Each bag was $\$ 600$ but was $7 5 \%$ off. How much did she spend on 2 bags of candy? + +Q: How much did she spend on 2 bags of candy? +A: Each bag was $\$ 600$ but was $7 5 \%$ off. So each bag cost $\ S 6 . 0 0 \ast \left( 1 - 0 . 7 5 \right) = \ S 6 . 0 0 \ast 0 . 2 5 = \ S 1 . 5 0$ . Carla bought 2 bags. So she spent $\$ 1.50*2=\$ 53.00$ . The answer is 3. + +If Pam is currently twice as young as Rena is, and in 10 years Rena will be 5 years older than her, how old is Pam now? + +Q: How much older is Rena than Pam currently? + +A: Since Rena will be 5 years older than Pam in 10 years, she must be 5 years older than Pam now as well. The answer is 5. + +Q: How old is Pam now? + +A: If Pam is currently twice as young as Rena, that means that Rena is currently twice as old as Pam is. So if $\mathrm { \bf P }$ stands for Pam’s age now and $\mathbf { R }$ stands for Rena’s age now, then we know that ${ \bf R } =$ $2 ^ { \ast } \mathrm { \bf P }$ And since Rena is 5 years older than Pam now, we know that ${ \sf R } = { \sf P } + 5$ . By substitution, we have $\mathrm { P } + 5 = 2 \ast \mathrm { P } ,$ which means that $\boldsymbol { \mathrm { P } } = 5$ . The answer is 5. + +Cappuccinos cost $\$ 2$ , iced teas cost $\$ 3$ , cafe lattes cost $\$ 1.5$ and espressos cost $\$ 1$ each. Sandy orders some drinks for herself and some friends. She orders three cappuccinos, two iced teas, two cafe lattes, and two espressos. How much change does she receive back for a twenty-dollar bill? + +Q: How much did Sandy spend on drinks? + +A: Sandy ordered three cappuccinos, which cost $\$ 2$ each, so she spent $\$ 2$ on cappuccinos. She ordered two iced teas, which cost $\$ 3$ each, so she spent $\$ 3*2=9$ dollars on ice teas. She ordered two cafe lattes, which cost $\$ 1.5$ each, so she spent $\$ 1.5 *2=\ S 3$ on cafe lattes. She ordered two espressos, which cost $\$ 1$ each, so she spent $\$ 1*2=\ S 2$ on espressos. So altogether, Sandy spent $\ S 6 + \ S 6 + \ S 3 + \ S 2 = \ S 1 7$ on drinks. The answer is 17. \ No newline at end of file diff --git a/md/dev/Wjp1AYB8lH/Wjp1AYB8lH.md b/md/dev/Wjp1AYB8lH/Wjp1AYB8lH.md new file mode 100644 index 0000000000000000000000000000000000000000..0f8422c73f231d898c2fe15428bc3fd4835b8fb3 --- /dev/null +++ b/md/dev/Wjp1AYB8lH/Wjp1AYB8lH.md @@ -0,0 +1,435 @@ +# Large Language Models as Commonsense Knowledge for Large-Scale Task Planning + +Zirui Zhao Wee Sun Lee David Hsu National University of Singapore {ziruiz, leews, dyhsu}@comp.nus.edu.sg + +# Abstract + +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 + +# 1 Introduction + +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. + +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. + +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. + +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: + +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. +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]. +F3. LLM-MCTS outperforms L-Model. This clearly shows the benefit of using the LLM as a heuristic policy to guide the search. +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. + +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. + +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). + +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. + +![](images/d3a86493932917f60740a2a2f3e1eab1b1ad4a19df626a8233cb29f65da1584e.jpg) +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. + +# 2 LLM-MCTS: Monte Carlo planning with commonsense knowledge + +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. + +# 2.1 Task planning + +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}$ . + +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. + +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. + +# 2.2 LLM as a commonsense world model + +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. + +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. + +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 } }$ . + +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. + +# 2.3 LLM as a heuristic policy + +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. + +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 + +1: procedure SEARCH(h, b, , N) +2: n 0 +3: while n < N do +4: s ∼ b(s) +5: SIMULATE(s, h, False, 0, ) +6: n ← n + 1 +7: end while +8: return $\operatorname { a r g m a x } _ { a \in A } Q ( h , a )$ +9: end procedure +10: procedure ROLLOUT $( s , h , { \mathrm { d o n e } } , d )$ +11: if $\gamma ^ { d } < \epsilon$ or done $=$ True then +12: return 0 +13: end if +14: $a \sim \pi _ { \mathrm { r o l l o u t } } ( h , \cdot )$ +15: $( s ^ { \prime } , o , r , \mathrm { d o n e } ) \sim \mathcal { G } ( s , a )$ +16: $h ^ { \prime } \gets \mathrm { P U S H B A C K } ( h , [ a ^ { * } , o ] ) , d ^ { \prime } \gets d + 1$ +17: return r + γ $\cdot \mathrm { R o L L O U T } ( s , h ^ { \prime } , \mathrm { d o n e } , d ^ { \prime } )$ +18: end procedure +19: procedure SIMULAT $\mathrm { E } ( s , h , \mathrm { d o n e } , d , \mathcal { T } )$ +20: if γd < ϵ or done $=$ True then +21: return 0 +22: end if +23: if $h$ is not in $\tau$ then +24: h, N (h) 0 +25: $\forall a \in A , N ( h , a ) \stackrel { \prime } { } 0 , Q ( h , a ) 0$ +26: return ROLLOUT(s, h, done, d) +27: end if +28: $\hat { \pi } ( a | h ) \gets$ QUERYLLMPOLICY(h) +29: a∗←argmax Q(h, a)+cπˆ(a|h) N(h)N(h,a)+1 +30: $( s ^ { \prime } , o , r , \mathrm { d o n e } ) \sim \mathcal { G } ( s , a ^ { * } )$ +31: $h ^ { \prime } \gets \mathrm { P U S H B A C K } ( h , [ a ^ { * } , o ] ) , d ^ { \prime } \gets d + 1$ +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 } )$ +33: N (h, a∗) += 1, N (h) += 1 +34: Q(h, a∗) ← Q(h, a∗) + R−Q(h,a∗)N(h,a∗) +35: return R +36: end procedure + +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. + +# 2.4 Monte Carlo tree search + +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. + +# 3 Experiments + +# 3.1 Experimental setup + +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. + +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. + +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. + +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. + +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. + +This baseline demonstrates the benefits of additional information from the commonsense model and algorithmic benefits from MCTS. + +# 3.2 Results + +Table 1: Main results: mean $\pm$ standard error of success rate $( \% )$ + +
Seen Home
SimpleComp.NovelSimple NovelComp.(2) NovelComp.(3)
UCT [21]0.0±0.00.0±0.00.0±0.0 0.0±0.00.0±0.0
finetuned GPT2 policy [22]81.3±2.4 59.0±6.741.2±7.1 30.9±2.82.3±1.5
GPT3.5Policy[18]83.4±6.8 47.0±7.874.3±4.0 48.2±8.85.4±2.0
GPT3.5-MCTS (Ours)91.4±3.3 71.2±6.288.1±4.3 72.6±6.933.6±3.1
Unseen Home
MethodSimpleComp.NovelSimple NovelComp.(2) NovelComp.(3)
UCT[21]0.0±0.00.0±0.00.0±0.00.0±0.0
finetuned GPT2 policy [22]65.5±3.4 39.9±5.233.4±6.40.0±0.0 12.8±3.91.1±0.9
GPT3.5Policy[18]74.3±5.0 43.3±4.067.8±4.954.0±3.06.9±2.1
GPT3.5-MCTS(Ours)82.9±3.2 71.9±5.679.3±3.370.4±6.438.8±3.4
+ +Main result. The main results of the experiments are shown in Table 1, reporting the success rate of our method + +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. + +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. + +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. + +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 + +Table 2: Ablation Study: mean $\pm$ standard error of success rate $( \% )$ + +
MethodSeen Home
SimpleComp.NovelSimple NovelComp.(2) NovelComp.(3)
GPT3.5-MCTS (No Heuristic Policy)0.0±0.00.0±0.00.0±0.00.0±0.00.0±0.0
GPT3.5-MCTS(Uniform State Prior)3.2±1.10.0±0.01.1±0.40.0±0.00.0±0.0
GPT3.5-MCTS (Fully Observable)94.0±2.180.7±3.394.3±2.478.5±4.034.0±4.4
GPT3.5-MCTS (Ours)91.4±3.3 71.2±6.288.1±4.372.6±6.933.6±3.1
Unseen Home
MethodSimpleComp.NovelSimple NovelComp.(2) NovelComp.(3)
GPT3.5-MCTS (No Heuristic Policy)0.0±0.00.0±0.00.0±0.00.0±0.00.0±0.0
GPT3.5-MCTS (Uniform State Prior)1.1±0.20.0±0.00.0±0.00.0±0.00.0±0.0
GPT3.5-MCTS(Fully Observable)85.1±5.0 77.5±3.282.2±3.376.6±3.137.9±2.9
GPT3.5-MCTS (Ours)82.9±3.2 71.9±5.679.3±3.370.4±6.438.8±3.4
+ +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. + +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). + +# 4 LLM as a model or a policy? + +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: + +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 )$ . + +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. + +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. + +Besides the multiplication example described earlier, we discuss an air travel planning task and the VirtualHome object rearrangement task examined earlier. + +# 4.1 Travel planning + +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$ . + +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). + +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. + +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. + +![](images/b64826072bda0ef9f00d63e5f49bc978d52958ce604d2214b6c8047bb969e4bd.jpg) +Figure 2: Flight planning results. + +# 4.2 Object rearrangement task + +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. + +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. + +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. + +# 4.3 Discussion + +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. + +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. + +# 5 Related work + +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. + +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. + +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. + +# 6 Conclusion + +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. + +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. + +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. + +# Acknowledgments and Disclosure of Funding + +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). + +# References + +[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 +[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 +[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 +[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 +[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 +[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 +[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 +[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 +[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 +[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 +[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 +[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 +[14] Malte Helmert. The fast downward planning system. Journal of Artificial Intelligence Research, 26:191–246, 2006. 10 +[15] Jörg Hoffmann. Ff: The fast-forward planning system. AI magazine, 22(3):57–57, 2001. 10 +[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 +[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 +[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 +[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 +[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 +[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 +[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 +[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 +[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 +[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 +[26] Nils Reimers and Iryna Gurevych. Sentence-bert: Sentence embeddings using siamese bertnetworks. arXiv preprint arXiv:1908.10084, 2019. 4, 5 +[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 +[28] Shai Shalev-Shwartz and Shai Ben-David. Understanding machine learning: From theory to algorithms. Cambridge university press, 2014. 2, 8 +[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 +[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 +[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 +[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 +[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 +[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 +[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 +[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 +[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 +[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 +[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 +[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 +[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 +[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 +[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 +[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 + +# Appendix + +# A Virtualhome experimental environments + +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. + +# A.1 List of objects, containers, surfaces, and rooms in the apartment + +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. + +• Containers: bathroom cabinet, kitchen cabinet, bathroom counter, fridge, oven, dishwasher, microwave, stove, bathroom cabinet +• Surfaces: bed, bookshelf, cabinet, coffee table, cutting board, floor, fryingpan, kitchen counter, kitchen table, nightstand, sofa, stove +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 +• Rooms: bedroom, bathroom, living room, kitchen. + +# A.2 Tasks + +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. + +The tasks are randomly sampled from different distributions. We define various types of object rearrangement tasks for evaluation: + +• 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. +• 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. +• 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. +• 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. +• 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. + +We also have different household environments: + +• 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]. + +![](images/98287ae96eaee6175debc4f12c11110d0bb713b95b41500cced14e5ef7d2db9a.jpg) +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. + +![](images/f9cc3c7756485d19e82943f6d52f5d61abf5fe7be6b6f203af086ce54e4f8e2f.jpg) +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. + +# A.3 Goal specification + +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. + +# A.4 Actions + +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: + +• Walk(): walk to the . The can be a moveable object, a container, or a room. The precondition of this action is that the is visible. The effect of this action is that the agent is close to the if the is an object or inside the if the is a room. The action is translated into the sentence “walk to the ” when feeding into LLMs. +Open(): open the . The can be a moveable object or a container. The precondition of this action is that the agent should be close to . The effect of this action is that the is opened. The action is translated into the sentence “open the ” when feeding into LLMs. Close(): close the . The can be a moveable object or a container. The precondition of this action is that the agent should be close to . The effect of this action is that the is closed. The action is translated into the sentence “close the ” when feeding into LLMs. +• Grab(): grab the . The should be a moveable object. The precondition of this action is that the agent should be close to the , and the agent is not holding any objects. The effect of this action is that the agent will hold the . The action is translated into the sentence “grab the ” when feeding into LLMs. +• PutIn(, ): put the moveable object inside the container . The precondition of this action is that the agent should be close to the and holding . The effect of this action is that the agent is not holding any objects, and the $ is inside the . The action is translated into the sentence “put the inside the ” when feeding into LLMs. +PutBack(, ): put the moveable object on the surface . The precondition of this action is that the agent should be close to the and holding . The effect of this action is that the agent is not holding any objects, and the is on the . The action is translated into the sentence “put the on the ” when feeding into LLMs. + +# A.5 Observations + +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.” + +# B Data gathering + +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. + +# C Implementation details of belief in LLM-MCTS + +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. + +# C.1 State representation + +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. + +# C.2 Belief + +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. + +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. + +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. + +# D Visualized examples + +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). + +Instruction: Put one plate inside the +kitchen cabinet and one chicken +inside microwave. +1: Walk to kitchen +2: Walk to plate +3: Grab plate +4: Walk to kitchen cabinet +5: Open kitchen cabinet +6: Put plate inside kitchen cabinet +7: Move fridge +8: Open fridge +9: Grab chicken +10: Walk to microwave +11: Open microwave +12: Put chicken inside microwave + +Instruction: Put one apple on the kitchen table and one toothbrush inside the bathroom cabinet. + +![](images/7e889755628e7fc0f820dc40ce53c62b36928d42c21199d1cc22ece2c70822c6.jpg)![](images/32503abb3807addb506d0049e114bb1a427c843162d0931f8743ae69e5296361.jpg) +Figure 5: Successful examples + +1: Walk to fridge +2: Open fridge +3: Walk to apple +4: Grab apple +5: Walk to kitchen table +6: Put apple on kitchen table +7: Walk to bathroom +8: Walk to toothbrush +9: Grab toothbrush +10: Open bathroom cabinet +11: Put toothbrush inside bathroom +cabinet +1: Walk to kitchen +2: Walk to kitchen cabinet +3: Open kitchen cabinet +4: Walk to dishwasher +5: Open dishwasher +6: Grab cutlery fork +7: Walk to kitchen table +8: Put cutlery fork on kitchen table +9: Walk to apple +10: Grab apple +11: Walk fridge +12: Open fridge +13: Put apple inside fridge +14: Close fridge +15: Walk to kitchen cabinet +16: Open kitchen cabinet (Failed) +17: Grab chips +18: Walk to living room +19: Walk to coffee table +20: Put chips on coffee table + +Instruction: Put one cutlery fork on +the coffee table +1: Walk to kitchen +2: Walk to cutlery knife +3: Walk to cutlery knife +4: Walk to cutlery knife +Instruction: Put one apple inside the +fridge +1: Walk to living room +2: Walk to coffee table +3: Walk to bedroom +4: Walk to nightstand +5: Walk to kitchen +6: Walk to kitchen cabinet +7: Open kitchen cabinet + +![](images/c8cca9d5d4e0d507619f15269eda7be86f0cddfe8ea390954ada91288b22b58d.jpg) +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. + +Table 3: Runtime performance (second $\pm$ standard error) + +
GPT3.5-MCTSGPT3.5 PolicyUCTGPT2 Policy
Runtime67.83 ± 18.921.19 ± 0.81120.0 ± 0.00.33 ± 0.07
+ +# E Runtime performance + +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: + +• CPU: Intel(R) Xeon(R) Gold 6240 CPU $@$ 2.60GHz (72 cores) • GPU: NVIDIA GeForce RTX 2080 Ti + +# F Prompts + +One example prompt for the LLM policy and the exact prompt we used for building up the commonsense belief is shown below. + +# Listing 1: Example prompt for the heuristic policy + +You need to generate a high-level plan for completing a household task using the allowed actions and visible objects. Allowed actions: walk to , walk to , walk to , walk to , grab , open , close , put on , put inside . +3 Rooms in the house: bedroom, bathroom, living room, kitchen +4 You need to strictly follow the format in the following examples: +5 Goal: Put one apple inside the fridge +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. +8 Next actions: grab the apple, walk to the fridge, open the fridge, put the apple inside the fridge, close the fridge, done. +9 Now, finish the next following task. +10 +11 Goal: Put one apple on the kitchen table +12 Completed actions: walk to the kitchen +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 + +# Listing 2: Example prompt for the commonsense world model + +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? + +# Listing 3: Example prompt for the natural language instruction interpretation + +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: \ No newline at end of file diff --git a/md/dev/X6dEqXIsEW/X6dEqXIsEW.md b/md/dev/X6dEqXIsEW/X6dEqXIsEW.md new file mode 100644 index 0000000000000000000000000000000000000000..eefc3e7e369e4d122f2bf8ae5a4fe0a05b4d782e --- /dev/null +++ b/md/dev/X6dEqXIsEW/X6dEqXIsEW.md @@ -0,0 +1,222 @@ +# On the Planning Abilities of Large Language Models : A Critical Investigation + +Karthik Valmeekam School of Computing & AI Arizona State University Tempe. kvalmeek@asu.edu + +Matthew Marquez School of Computing & AI Arizona State University, Tempe. mmarqu22@asu.edu + +Sarath Sreedharan∗ Department of Computer Science, Colorado State University, Fort Collins. sarath.sreedharan@colostate.edu + +Subbarao Kambhampati School of Computing & AI Arizona State University, Tempe. rao@asu.edu + +# Abstract + +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. + +# 1 Introduction + +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]. + +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: + +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)? +2. How good are LLMs in being a source of heuristic guidance for other agents in their planning tasks? + +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. + +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. + +![](images/89c4ff73d93d4e9706caa68cf963311cc1fc37c13740df2131635c53ad85a188.jpg) +Figure 1: The diagrammatic overview of the two modes of LLMs for planning. + +# 2 Related Work + +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. + +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]. + +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. + +# 3 Prompt Generation for Classical Planning Problems + +# 3.1 Background + +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. + +(: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)))) + +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. + +# 3.2 Prompt Generation + +![](images/642747863f0ac95f99387bb3732e05cc831ea3428dac9efab84f28bb5198f230.jpg) +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. + +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. + +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. + +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. + +
DomainMethodInstances correct
GPT-4GPT-3.5I-GPT3.5I-GPT3GPT-3
Blocksworld (BW)One-shot206/600 (34.3%)37/600 (6.1%)54/600 (9%)41/600 (6.8%)6/600 (1%)
Zero-shot210/600 (34.6%)8/600 (1.3%)111
COT214/600 (35.6%)=1
Logistics DomainOne-shot28/200 (14%)1/200 (0.5%)6/200 (3%)3/200 (1.5%)
Zero-shot15/200 (7.5%)1/200 (0.5%)=-1
Mystery BW (Deceptive)One-shot26/600 (4.3%)0/600 (0%)4/600 (0.6%)14/6000/600
Zero-shot1/600 (0.16%)0/600 (0%)-(2.3%) 1(0%) 1
COT54/600 (9%)--1
Mystery BW (Randomized)One-shot12/600 (2%)0/600 (0%)5/600 (0.8%)5/600 (0.8%)1/600
Zero-shot0/600 (0%)0/600 (0%)--(0.1%) -
+ +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. + +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. + +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. + +# 4 Evaluating Planning Capabilities of LLMs in Autonomous Mode + +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. + +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. + +
DomainMethodInstances correct
GPT-4GPT-3.5
Blocksworld (BW)One-shot75/600 (12.5%)12/600 (2%)
Zero-shot106/600 (17.6%)12/600 (2%)
Logistics DomainOne-shot28/200 (14%)1/200 (0.5%)
Zero-shot11/200 (5.5%)0/200 (0%)
Mystery BW (Deceptive)One-shot17/600 (2.8%)1/600 (0.1%)
Zero-shot3/600 (0.5%)0/600 (0%)
+ +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). + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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). + +![](images/79db4ebc8d5a577b2f247f5c8eef63c89a5f78d19fc05ecd4053e3ee95c61117.jpg) +Figure 3: Assessment of GPT-4 plans with relaxations in Blocksworld domain + +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. + +
DomainLLMAvg. Search StepsAvg. Plan LengthAvg. Lev. Distance
Empty SeedRandom SeedLLM SeedEmpty SeedRandom SeedLLM Seed
BWI-GPT-3Plan 15.8Plan 20.07Plan 14.5Plan 8.45Plan 9.62Plan 11.77.22
GPT-415.820.078.98.459.6210.764.15
LogisticsGPT-477.5144.3951.323.732.7232.2415.04
Mystery BWGPT-415.820.4516.098.459.7811.537.77
+ +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. + +# 5 Evaluating LLMs as Idea Generators + +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). + +# 5.1 LLM Plans as Heuristics to Sound Planners + +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. + +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. + +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. + +# 5.2 Verifier-assisted repeated backprompting of LLMs + +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). + +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. + +
Domain1.CA.FR
GPT-4GPT-4
Blocksworld (BW)41/50 (82%)3.68
Logistics35/50 (70%)3.31
Mystery BW5/50 (10%)7.0
+ +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. + +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. + +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]. + +# 5.3 LLMs as idea generators for humans-in-the-loop + +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. + +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. + +# 6 Conclusion and Future Work + +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. + +# 7 Acknowledgements + +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. + +# References + +[1] Clever Hans. https://en.wikipedia.org/wiki/Clever_Hans. + +[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. + +[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. + +[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. + +[5] Mary L Cummings. Automation bias in intelligent time critical decision support systems. In Decision making in aviation, pages 289–294. Routledge, 2017. + +[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. + +[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. + +[8] Malik Ghallab, Dana S. Nau, and Paolo Traverso. Automated Planning and Acting. Cambridge University Press, 2016. + +[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. + +[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. + +[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. + +[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. + +[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. + +[14] IPC. International planning competition, 1998. + +[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. + +[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. + +[17] Subbarao Kambhampati and James A. Hendler. A validation-structure-based theory of plan modification and reuse. Artif. Intell., 55(2):193–258, 1992. + +[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/. + +[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. + +[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. + +[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. + +[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. + +[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. + +[24] OpenAI. Introducing chatgpt by openai, 2022. + +[25] OpenAI. Gpt-4 technical report, 2023. + +[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. + +[27] Alec Radford, Karthik Narasimhan, Tim Salimans, and Ilya Sutskever. Improving language understanding by generative pre-training. 2018. + +[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. + +[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. + +[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. + +[31] Big Science. BigScience Large Open-science Open-access Multilingual Language Model. https://huggingface.co/bigscience/bloom, 2022. + +[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. + +[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. + +[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. + +[35] Alon Talmor, Jonathan Herzig, Nicholas Lourie, and Jonathan Berant. Commonsenseqa: A question answering challenge targeting commonsense knowledge. arXiv preprint arXiv:1811.00937, 2018. + +[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. + +[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. +[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. +[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. +[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. \ No newline at end of file diff --git a/md/dev/Yacmpz84TH/Yacmpz84TH.md b/md/dev/Yacmpz84TH/Yacmpz84TH.md new file mode 100644 index 0000000000000000000000000000000000000000..3f852f4ca2abf10211cdfdedb5a5290f588c3c79 --- /dev/null +++ b/md/dev/Yacmpz84TH/Yacmpz84TH.md @@ -0,0 +1,281 @@ +# Toolformer: Language Models Can Teach Themselves to Use Tools + +Timo Schick Jane Dwivedi-Yu Roberto Dessì† Roberta Raileanu Maria Lomeli Eric Hambro Luke Zettlemoyer Nicola Cancedda Thomas Scialom + +FAIR, Meta †Universitat Pompeu Fabra + +# Abstract + +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. + +# 1 Introduction + +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). + +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: + +• 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. + +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; + +![](images/efd2dac35f6d1a63826328723565885e1aad2ceea0a3379b92e4c40bd9922f6b.jpg) +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. + +![](images/5869d239001ffcca88eb10a98a653d9f154d0247150188f33783d20eda69ab5b.jpg) +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 } ^ { * }$ . + +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. + +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. + +# 2 Approach + +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: + +$$ +\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} +$$ + +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. + +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: + +Input: Joe Biden was born in Scranton, Pennsylvania. +Output: Joe Biden was born in [QA("Where was Joe Biden born?")] Scranton, [QA("In which state is Scranton?")] Pennsylvania. + +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. + +Input: x Output: + +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. + +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. + +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 }$ . + +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 + +$$ +L _ { i } ( \mathbf { z } ) = - \sum _ { j = i } ^ { n } w _ { j - i } \cdot \log p _ { M } ( x _ { j } \mid \mathbf { z } , x _ { 1 : j - 1 } ) +$$ + +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: + +$$ +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) +$$ + +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. + +Table 1: Examples of inputs and outputs for all APIs used. + +
API NameExample InputExample Output
Question AnsweringWhere was the Knights of Columbus founded?New Haven, Connecticut
Wikipedia SearchFishing Reel TypesSpin 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,
Calculator27+4*2the open faced reel and the closed faced reel. 35
CalendarmToday is Monday, January 30,2023.
Machine Translationsureté nucléairenuclear safety
+ +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. + +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. + +# 3 Tools + +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. + +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). + +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. + +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). + +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. + +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. + +Table 2: Number of examples with API calls in $\mathcal { C } ^ { * }$ for different values of our filtering threshold $\tau _ { f }$ + +
Number of Examples
APITf = 0.5Tf = 1.0Tf = 2.0
Question Answering51,98718,5265,135
Wikipedia Search207,24160,97413,944
Calculator3,680994138
Calendar61,81120,5873,007
Machine Translation3,1561,034229
+ +# 4 Experiments + +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). + +# 4.1 Experimental Setup + +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 + +$$ +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 ) +$$ + +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: + +• 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. + +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. + +# 4.2 Downstream Tasks + +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. + +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. + +
LAMAMath Benchmarks
ModelSQuADGoogle-RET-RExASDivSVAMPMAWPS
GPT-J17.84.931.97.55.29.9
GPT-J + CC19.25.633.29.65.09.3
Toolformer (disabled)22.16.334.914.86.315.0
Toolformer33.811.553.540.429.444.0
OPT (66B)21.62.930.16.04.97.9
GPT-3 (175B)26.87.039.814.010.019.8
+ +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. + +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 \% )$ . + +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. + +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, + +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. + +
LAMATemporal Datasets
ModelWebQSNQTriviaQATEMPLAMADATESET
GPT-J18.512.843.913.73.9
GPT-J + CC18.412.245.612.92.9
Toolformer (disabled)18.912.646.712.75.9
Toolformer26.317.748.816.327.3
OPT (66B)18.611.445.714.51.3
GPT-3 (175B)29.022.665.915.50.8
+ +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. + +
ModelEsDeHiViZhAr
GPT-J15.216.51.38.218.28.2
GPT-J + CC15.714.90.58.313.74.6
Toolformer (disabled)19.811.91.210.115.03.1
Toolformer20.613.51.410.616.83.7
OPT (66B)0.30.11.10.20.70.1
GPT-3 (175B)3.41.10.11.717.70.1
GPT-J (All En)24.327.023.923.323.123.6
GPT-3 (All En)24.727.226.124.923.624.0
+ +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. + +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. + +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. + +![](images/071c4fdbad1e77e8404f0631b4a51c5e303496f5cf70832da7e556306980604d.jpg) +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. + +# 4.3 Language Modeling + +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 + +# 4.4 Scaling Laws + +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. + +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. + +# 5 Related Work + +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. + +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. + +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. + +# 6 Limitations + +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. + +# 7 Conclusion + +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. + +# References + +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. + +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. + +Ricardo Baeza-Yates, Berthier Ribeiro-Neto, et al. 1999. Modern information retrieval, volume 463. ACM press New York. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +Luyu Gao, Aman Madaan, Shuyan Zhou, Uri Alon, Pengfei Liu, Yiming Yang, Jamie Callan, and Graham Neubig. 2022. Pal: Program-aided language models. + +Kelvin Guu, Kenton Lee, Zora Tung, Panupong Pasupat, and Ming-Wei Chang. 2020. Realm: Retrieval-augmented language model pre-training. + +Junxian He, Jiatao Gu, Jiajun Shen, and Marc’Aurelio Ranzato. 2020. Revisiting self-training for neural sequence generation. In International Conference on Learning Representations. + +Or Honovich, Thomas Scialom, Omer Levy, and Timo Schick. 2022. Unnatural instructions: Tuning language models with (almost) no human labor. + +Gautier Izacard and Edouard Grave. 2021. Distilling knowledge from reader to retriever for question answering. In International Conference on Learning Representations. + +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. + +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. + +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. + +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. + +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. + +Nitish Shirish Keskar, Bryan McCann, Lav R. Varshney, Caiming Xiong, and Richard Socher. 2019. Ctrl: A conditional transformer language model for controllable generation. + +Philipp Koehn. 2005. Europarl: A parallel corpus for statistical machine translation. In Proceedings of machine translation summit x: papers, pages 79–86. + +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. + +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. + +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. + +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. + +Patrick Lewis, Barlas Oguz, Ruty Rinott, Sebastian Riedel, and Holger Schwenk. 2019. Mlqa:˘ Evaluating cross-lingual extractive question answering. arXiv preprint arXiv:1910.07475. + +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. + +Joshua Maynez, Shashi Narayan, Bernd Bohnet, and Ryan McDonald. 2020. On faithfulness and factuality in abstractive summarization. + +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. + +Stephen Merity, Caiming Xiong, James Bradbury, and Richard Socher. 2017. Pointer sentinel mixture models. In International Conference on Learning Representations. + +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. + +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. + +Aaron Parisi, Yao Zhao, and Noah Fiedel. 2022. Talm: Tool augmented language models. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +Ben Wang and Aran Komatsuzaki. 2021. GPT-J-6B: A 6 Billion Parameter Autoregressive Language Model. https://github.com/kingoflolz/mesh-transformer-jax. + +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. + +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. + +Shunyu Yao, Jeffrey Zhao, Dian Yu, Nan Du, Izhak Shafran, Karthik Narasimhan, and Yuan Cao. 2022. React: Synergizing reasoning and acting in language models. + +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. + +Eric Zelikman, Yuhuai Wu, Jesse Mu, and Noah D. Goodman. 2022. Star: Bootstrapping reasoning with reasoning. + +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. \ No newline at end of file diff --git a/md/dev/Z4kZxAjg8Y/Z4kZxAjg8Y.md b/md/dev/Z4kZxAjg8Y/Z4kZxAjg8Y.md new file mode 100644 index 0000000000000000000000000000000000000000..796d5f0da3f371ee230658a5b55d49059082a914 --- /dev/null +++ b/md/dev/Z4kZxAjg8Y/Z4kZxAjg8Y.md @@ -0,0 +1,362 @@ +# Autoregressive Search Engines: Generating Substrings as Document Identifiers + +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 + +# Abstract + +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. + +# 1 Introduction + +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]. + +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. + +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]. + +![](images/4d91f3462677d41543238f05e84a397175096319e1f767b9cf1d34e11c842f50.jpg) +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). + +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. + +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). + +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. + +# 2 Related Work + +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]. + +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]. + +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. + +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 )$ . + +# 3 Background + +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. + +# 3.1 The FM-Index + +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: + +$$ +\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} +$$ + +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. + +# 4 Method + +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. + +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. + +Factoring in FM-index frequencies To counterbalance the monotonic probability decrease, we integrate in scoring unconditional ngram probabilities, computed as normalized index frequencies: + +$$ +P ( n ) = \frac { F ( n , \mathcal { R } ) } { \sum _ { d \in \mathcal { R } } \left| d \right| } +$$ + +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: + +$$ +w ( n , q ) = \operatorname* { m a x } \left( 0 , \log { \frac { P ( n | q ) ( 1 - P ( n ) ) } { P ( n ) ( 1 - P ( n | q ) ) } } \right) +$$ + +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. + +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 ) }$ : + +$$ +W ( d , q ) = \sum _ { n \in K ^ { ( d ) } } w ( n , q ) ^ { \alpha } \cdot \mathrm { c o v e r } ( n , K ^ { ( d ) } ) +$$ + +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: + +$$ +\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 ) | } } +$$ + +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. + +# 5 Experimental Setting + +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. + +# 5.1 Data + +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. + +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. + +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. + +
SystemModel ParamsIndex
plain textSize 13.4GBParamsGPU?
---
DPR BM25220M64.6GB16.1B
GAR- 406M18.8GB-X
DSI-BART406M18.8 GBX
1
SEAL406M8.8GBX
+ +# 5.2 SEAL configuration + +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). + +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: + +$$ +\frac { e ^ { L ( q , d _ { i : i + k } ) / \tau } } { \sum _ { j = 1 } ^ { | d | - k + 1 } e ^ { L ( q , d _ { j : j + k } ) / \tau } } +$$ + +where $L$ is the Levenshtein distance and $\tau$ $( = 1 . 5$ in our experiments) is a temperature parameter, controlling the peakiness of the distribution. + +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. + +# 5.3 Retriever Baselines + +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. + +Table 2: Results on $\mathrm { N Q } 3 2 0 k$ . Reporting hits $@ 1$ and hits@10. Best in bold. + +
Systemhits@k 110
BM25 (gensim) BM25 DSI-BART GENRE15.3 22.7 25.0 26.344.5 59.0 63.6 71.2
SEAL (LM, |n| = 3) SEAL (LM, |n| = 4) SEAL (LM, In| = 5) SEAL (LM+FM) SEAL (LM+FM, intersect.)21.3 22.2 22.6 25.3 26.366.5 68.2 68.7 72.0 74.5
+ +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. + +
System accuracy@kOverlap? (A@100)EM
520100ans.Xques.X
BM2543.662.978.182.970.180.976.640.4
DPR [Karpukhin et al.,2020]68.380.186.191.476.893.283.247.2
GAR [Mao et al.,2021]59.373.985.091.674.494.180.446.2
DSI-BART28.347.365.577.844.284.957.731.4
Izacard and Grave [2021]1----1148.2
SEAL (LM, |n| = 5)40.560.273.182.257.185.264.936.0
SEAL (LM+FM)43.965.881.186.970.989.578.142.9
SEAL (LM+FM, intersective)61.376.286.391.277.793.284.148.0
+ +# 5.4 Reader + +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. + +# 6 Results + +$\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. + +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). + +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. + +
ModelFEVT-RExzsRENQHoPoTQAWoWAVG
BM2540.151.653.014.238.416.218.433.1
DPR Maillard et al. [2021]43.958.578.828.143.523.820.742.5
MT-DPR [Maillard et al., 2021]52.153.541.728.838.434.224.139.0
MT-DPR [Oguz et al., 2021]52.161.454.140.141.034.224.643.9
MT-DPRt [Oguz et al., 2021]61.468.473.344.144.638.926.551.0
MT-DPRt (large) [Oguz et al., 2021]62.866.666.942.642.137.923.448.9
SEAL (LM+FM)31.542.034.021.724.721.417.627.6
SEAL (LM+FM, intersective)67.858.978.843.654.341.836.054.5
+ +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. + +
SystemFEV ACCT-REx ACCzsRE ACCNQ EMHoPo EMTQA EMWoW F1
KGI [Glass et al., 2021]+85.684.472.645.2-61.018.6
Hindsight [Paranjape et al., 2021]1---1-19.2
DPR+BART [Petroni et al.,2021]86.759.230.441.325.258.615.2
RAG [Petroni et al.,2021]86.359.244.744.427.071.313.1
MT-DPR+BART [Maillard et al., 2021]86.3158.039.831.859.615.3
MT-DPR+FiD [Piktus et al., 2021]89.082.571.749.936.971.015.7
MT-DPR-WEB+FiD [Piktus et al.,2021]89.081.774.251.638.372.715.5
SEAL+FiD (LM+FM)87.983.774.247.337.665.817.5
SEAL+FiD (LM+FM, intersective)89.583.674.753.740.570.918.3
+ +Table 6: Retrieval results on the NQ test set with different model sizes. DPR (large) performance from [Oguz et al., 2021]. ˘ + +
System#Par.A@20A@100
DPR (base)~220M80.186.1
DPR (large)~350M80.286.7
SEAL (large)~400M76.286.3
+ +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. + +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]) + +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$ . + +
SystemConstr.BeamA@20A@100
SEAL1565.881.1
(LM+FM)×1565.380.1
363.378.0
564.779.9
1065.480.8
SEAL1576.286.3
(LM+FM,X1576.286.2
intersective)375.284.9
·575.985.8
1076.486.4
+ +Table 8: Performance on Natural Questions with different max ngrams sizes, using SEAL $\mathrm { ( L M + F M }$ , intersective). + +
LengthA@20A@100
364.774.8
573.683.7
1076.286.3
+ +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. + +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. + +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. + +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 ) ^ { , }$ . + +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. + +
score#identifierdoc #1doc #2
273.21earthquakes can be predictedSeismology @@ for precise earth- Earthquake prediction @ @ reliably
272.775Earthquake prediction @ @quake predictions,including theidentified across significant spatial
269.93predicted earthquakesVAN method.Most seismologistsand temporal scales.While part of the
229.711Earthquake forecasting @@do not believe that a system to pro-scientific community hold that, taking
217.22prediction Earthquakevide timely warnings for individualinto account non-seismic precursors
211.51used to predict earthquakesearthquakes has yet been developed,and given enough resources to study
205.37earthquakes.Earthquakeand many believe that such a sys-them extensively,prediction might
tem would be unlikely to give usefulbe possible,most scientists are pes-
-77.09Seismic metamaterial @@warning of impending seismic events.simistic and some maintain that earth-
-97.4 -113.414Seismic risk in Malta @@However,more general forecasts rou-quake prediction is inherently impos-
-150.33Quaternary (EP) @ @tinely predict seismic hazard. Suchsible.Predictions are deemed signif-
-301.51 17used to predict the locatio[.]forecasts estimate the probability oficant if they can be shown to be suc-
Precipice (Battlestar Gala[.]an earthquake of a particular [...]cessful beyond random chance.[...]
+ +# 7 Discussion + +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. + +# 8 Conclusion + +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. + +# 9 Broader Impact + +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. + +# Acknowledgments and Disclosure of Funding + +We thank Aleksandra Piktus, Edoardo Barba, Niccolò Campolungo, and Pere-Lluis Huguet Cabot for their helpful comments and suggestions. + +# References + +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. + +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. + +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. + +M. Burrows and D. J. Wheeler. A block-sorting lossless data compression algorithm. Technical report, 1994. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +Mojtaba Komeili, Kurt Shuster, and Jason Weston. Internet-augmented dialogue generation. CoRR, abs/2107.07566, 2021. + +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. + +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. + +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. + +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. + +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. + +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. + +Omer Levy, Minjoon Seo, Eunsol Choi, and Luke Zettlemoyer. Zero-shot relation extraction via reading comprehension. CoNLL, 2017. + +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. + +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. + +Patrick Lewis, Barlas Oguz, Wenhan Xiong, Fabio Petroni, Wen tau Yih, and Sebastian Riedel.˘ Boosted dense retriever. CoRR, abs/2112.07771, 2021a. + +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. + +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. + +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. + +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. + +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 + +Development in Information Retrieval, Virtual Event, Canada, July 11-15, 2021, pages 1723–1727. +ACM, 2021. doi: 10.1145/3404835.3463030. URL https://doi.org/10.1145/3404835. +3463030. + +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. + +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. + +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. + +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. + +Rodrigo Nogueira and Jimmy Lin. From doc2query to doctttttquery. 2021. URL https://cs. uwaterloo.ca/\~jimmylin/publications/Nogueira_Lin_2019_docTTTTTquery.pdf. + +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. + +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. + +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. + +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. + +Fabio Petroni, Tim Rocktäschel, Patrick Lewis, Anton Bakhtin, Yuxiang Wu, Alexander H Miller, and Sebastian Riedel. Language models as knowledge bases? EMNLP, 2019. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +James Thorne, Andreas Vlachos, Christos Christodoulopoulos, and Arpit Mittal. FEVER: a largescale dataset for fact extraction and verification. In NAACL-HLT, 2018. + +Ellen M Voorhees et al. The trec-8 question answering track report. In Trec, volume 99, pages 77–82, 1999. + +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. + +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. + +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. + +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. + +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. + +# Checklist + +1. For all authors... + +(a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes] +(b) Did you describe the limitations of your work? [Yes] +(c) Did you discuss any potential negative societal impacts of your work? [Yes] Discussion in the Appendix (§9) +(d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes] + +2. If you are including theoretical results... + +(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] + +3. If you ran experiments... + +(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). +(b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes] +(c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [No] +(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] + +4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets... + +(a) If your work uses existing assets, did you cite the creators? [Yes] +(b) Did you mention the license of the assets? [No] +(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] +(e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [No] + +5. If you used crowdsourcing or conducted research with human subjects... + +(a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A] +(b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A] +(c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A] \ No newline at end of file diff --git a/md/dev/ZTsoE8G3GG/ZTsoE8G3GG.md b/md/dev/ZTsoE8G3GG/ZTsoE8G3GG.md new file mode 100644 index 0000000000000000000000000000000000000000..5442033ff4c27a84faad6cc8f44b200976c520bd --- /dev/null +++ b/md/dev/ZTsoE8G3GG/ZTsoE8G3GG.md @@ -0,0 +1,448 @@ +# LEARNING TO EXTEND MOLECULAR SCAFFOLDS WITH STRUCTURAL MOTIFS + +Krzysztof Maziarz∗ Microsoft Research United Kingdom + +Henry Jackson-Flux Microsoft Research United Kingdom + +Pashmina Cameron Microsoft Research United Kingdom + +Finton Sirockin Novartis Switzerland + +Nadine Schneider Novartis Switzerland + +Nikolaus Stiefl Novartis Switzerland + +Marwin Segler Microsoft Research United Kingdom + +Marc Brockschmidt Microsoft Research United Kingdom + +# ABSTRACT + +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. + +# 1 INTRODUCTION + +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. + +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. + +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. + +![](images/16a71552e994227486658aa42641aa443f9d9fad651d27acc684c684214a3798.jpg) +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). + +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. + +In this work we make the following contributions: + +• 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. + +Code is available at https://github.com/microsoft/molecule-generation. + +# 2 OUR APPROACH + +# 2.1 DATA REPRESENTATION + +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. + +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. + +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. + +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. + +# 2.2 THE MOLER DECODER + +# Algorithm 1 MoLeR’s Generative Procedure + +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. + +Our decoder relies on three neural networks to implement the functions PickAtomOrMotif, + +Input: vector $z$ , scaffold as partial graph $S$ +Output: molecule $M$ and probability $p$ +$M , p \gets S , 1$ +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) + +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 }$ . + +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. + +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. + +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. + +# 2.3 MOLECULE GENERATION ORDERS + +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. + +# Algorithm 2 Determining a generation order + +Input: Target molecule $M$ , partial mapping +$\mathcal { A }$ from atoms to motifs that cover them +$t , V _ { 0 } \gets 0 , \emptyset$ +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 + +In Section 3, we evaluate orders commonly used in the literature: random, where ValidFirstAtoms returns all atoms and ValidNextAtoms all atoms + +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. + +# 2.4 TRAINING MOLER + +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). + +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. + +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. + +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: + +$$ +\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} +$$ + +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. + +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. + +# 3 EXPERIMENTS + +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. + +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. + +# 3.1 QUANTITATIVE RESULTS + +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 + +Table 1: Training and sampling speed for our model and the baselines on a Tesla K80 GPU. + +
ModelTrain (mol/sec)Sample (mol/sec)
CGVAE57.01.4
JT-VAE3.23.4
HierVAE17.012.3
MoLeR95.234.2
+ +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. + +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. + +![](images/018d2e2579f1b9c3e063afb912a3ea6d1f776debcf12433c1e57c4bf3c7a5099.jpg) +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). + +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 \%$ . + +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. + +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. + +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. + +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. + +
GuacaMolScaffolds
MethodScoreQualityScoreQuality
Best of dataset0.610.770.17-
SMILESLSTM0.870.770.45=
SMILES GA0.720.360.45=
GRAPHMCTS0.450.220.20=
GRAPH GA0.900.400.79=
CDDD + MSO0.900.580.920.59
MNCE-RL0.920.540.950.47
MoLeR+MSO0.820.750.930.63
+ +![](images/057e001cad3056e056a1b1ccc48a422de94a944434e2164b62eea28d69e5206f.jpg) +Figure 3: Scaffold from a GuacaMol benchmark (top) and a scaffold from our additional benchmark (bottom). + +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. + +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. + +# 3.2 QUALITATIVE RESULTS + +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. + +![](images/adc9a8f52c03f7186991525f2cb30928fd523dd243465d7c3bbbd130a566f0d1.jpg) +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. + +![](images/bd9f08bc103f603aaeb7b385db7a1b2e0d9b9e302e4898fc20d87ba847afb7e1.jpg) +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. + +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. + +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. + +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. + +# 3.3 ABLATIONS + +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). + +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). + +# 4 RELATED WORK + +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. + +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. + +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. + +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. + +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. + +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. + +# 5 CONCLUSION + +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. + +# 6 ETHICS STATEMENT + +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. + +# 7 ACKNOWLEDGMENTS + +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. + +# REFERENCES + +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. + +Sungsoo Ahn, Junsu Kim, Hankook Lee, and Jinwoo Shin. Guiding deep molecular optimization with genetic exploration. arXiv preprint arXiv:2007.04897, 2020. + +Apixaban. Pubchem compound summary for cid 10182969, apixaban. November, 2021. URL https://pubchem.ncbi.nlm.nih.gov/compound/Apixaban. + +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. + +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. + +Jimmy Lei Ba, Jamie Ryan Kiros, and Geoffrey E Hinton. Layer normalization. arXiv preprint arXiv:1607.06450, 2016. + +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. + +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. + +Marc Brockschmidt. GNN-film: Graph neural networks with feature-wise linear modulation. In International Conference on Machine Learning, pp. 1144–1152. PMLR, 2020. + +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. + +Gabriele Corso, Luca Cavalleri, Dominique Beaini, Pietro Liò, and Petar Velickovi ˇ c. Principal ´ neighbourhood aggregation for graph nets. arXiv preprint arXiv:2004.05718, 2020. + +Nicola De Cao and Thomas Kipf. Molgan: An implicit generative model for small molecular graphs. arXiv preprint arXiv:1805.11973, 2018. + +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. + +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. + +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. + +Wengong Jin, Regina Barzilay, and Tommi Jaakkola. Junction tree variational autoencoder for molecular graph generation. arXiv preprint arXiv:1802.04364, 2018. + +Wengong Jin, Regina Barzilay, and Tommi Jaakkola. Hierarchical generation of molecular graphs using structural motifs. arXiv preprint arXiv:2002.03230, 2020. + +Diederik P Kingma and Jimmy Ba. Adam: A method for stochastic optimization. arXiv preprint arXiv:1412.6980, 2014. + +Diederik P Kingma and Max Welling. Auto-encoding variational bayes. arXiv preprint arXiv:1312.6114, 2013. + +Thomas N Kipf and Max Welling. Semi-supervised classification with graph convolutional networks. arXiv preprint arXiv:1609.02907, 2016. + +Greg Landrum et al. Rdkit: Open-source cheminformatics. 2006. URL http://www.rdkit. org. + +Maxime Langevin, Hervé Minoux, Maximilien Levesque, and Marc Bianciotto. Scaffold-constrained molecular generation. Journal of Chemical Information and Modeling, 2020. + +Lenacapavir. Pubchem compound summary for cid 133082658, lenacapavir. November, 2021. URL https://pubchem.ncbi.nlm.nih.gov/compound/Lenacapavir. + +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. + +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. + +Yifeng Li, Hsu Kiang Ooi, and Alain Tchagang. Deep evolutionary learning for molecular design, 2021. URL https://openreview.net/forum?id $=$ Fo6S5-3Dx_. + +Yujia Li, Daniel Tarlow, Marc Brockschmidt, and Richard Zemel. Gated graph sequence neural networks. arXiv preprint arXiv:1511.05493, 2015. + +Yujia Li, Oriol Vinyals, Chris Dyer, Razvan Pascanu, and Peter Battaglia. Learning deep generative models of graphs. arXiv preprint arXiv:1803.03324, 2018b. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +Philipp Renz, Dries Van Rompaey, Jörg Kurt Wegner, Sepp Hochreiter, and Günter Klambauer. On failure modes of molecule generators and optimizers. 2020. + +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. + +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. + +Ansgar Schuffenhauer. Computational methods for scaffold hopping. Wiley Interdisciplinary Reviews: Computational Molecular Science, 2(6):842–867, 2012. + +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. + +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. + +Sildenafil. Pubchem compound summary for cid 135398744, sildenafil. November, 2021. URL https://pubchem.ncbi.nlm.nih.gov/compound/Sildenafil. + +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. + +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. + +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. + +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. + +Xarelto. Pubchem compound summary for cid 6433119, xarelto. November, 2021. URL https: //pubchem.ncbi.nlm.nih.gov/compound/6433119. + +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. + +Chencheng Xu, Qiao Liu, Minlie Huang, and Tao Jiang. Reinforced molecular optimization with neighborhood-controlled grammars. arXiv preprint arXiv:2011.07225, 2020. + +Keyulu Xu, Weihua Hu, Jure Leskovec, and Stefanie Jegelka. How powerful are graph neural networks? arXiv preprint arXiv:1810.00826, 2018. + +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. + +# A BACKGROUND: GRAPH NEURAL NETWORKS + +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 + +$$ +\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 } +$$ + +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. + +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): + +$$ +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 } \} ) ) +$$ + +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). + +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. + +# B ARCHITECTURE + +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. + +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. + +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 + +$$ +\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} +$$ + +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. + +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. + +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). + +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$ . + +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. + +# C TRAINING AND INFERENCE + +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. + +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. + +# C.1 HYPERPARAMETER TUNING + +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. + +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. + +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. + +# C.2 SOFTWARE AND HARDWARE + +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). + +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). + +# C.3 OPTIMIZATION + +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. + +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). + +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. + +# D SAMPLES FROM THE PRIOR + +![](images/6801508433a748d3e9be7c2874821cda8147aacb7e3e7bedfc02890ff3838a85.jpg) +Figure 6: Samples from the prior of a trained MoLeR model. + +# E SCAFFOLD-BASED OPTIMIZATION BENCHMARKS + +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). + +![](images/c90117faf874e20e34fd161e2bab917ed39b0d927df59cb4a91786695fcf488b.jpg) + +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. + +# F LATENT SPACE NEIGHBORHOOD + +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. + +![](images/c25bb6f57bf77b78fb3dc93d2c9dca7ea15b38b293aabaf275949b86503d9fa9.jpg) +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. + +# G LEARNED MOTIF REPRESENTATIONS + +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. + +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. + +![](images/3fc9abdd1aa951b6368c14a98738fdaea05964899e9234ad4130fb0b59c49970.jpg) +Figure 8: Six pairs of similar motifs (one per column), as extracted from weights of a trained MoLeR model. + +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. + +# H EFFECT OF USING MOTIFS ON OPTIMIZATION PERFORMANCE + +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. + +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. + +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. + +![](images/bd3de5443bd09295d9038b9aa025fc68edc873cb92a928a27f0dfb2ba13f1f9e.jpg) +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). + +# I ABLATION STUDIES + +In this section, we perform ablation studies to understand the contribution of different design choices to MoLeR’s performance. + +# I.1 ADDING MOTIF EMBEDDINGS AS INPUT FEATURES + +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. + +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. + +![](images/85724acf27d832abeb7c36f647005038d34d905ad6df3c8c46f78b43f8157851.jpg) +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. + +# I.2 SUBSAMPLING GENERATION STEPS + +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. + +![](images/4254395bb4deba43a5c443b75fecd658bbbda57294aa07c68d71d5e389ae8906.jpg) +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. + +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. + +![](images/f5e93271baf74ab31c26bcc5c1c68bb52234bdb4da92ac3f12d188130356915d.jpg) +I.3 ENCOURAGING LATENT SPACE SMOOTHNESS WITH A PROPERTY PREDICTION LOSS +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. + +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. \ No newline at end of file diff --git a/md/dev/Zq2G_VTV53T/Zq2G_VTV53T.md b/md/dev/Zq2G_VTV53T/Zq2G_VTV53T.md new file mode 100644 index 0000000000000000000000000000000000000000..287659258bf705d5f05009c24f5d57516baa5091 --- /dev/null +++ b/md/dev/Zq2G_VTV53T/Zq2G_VTV53T.md @@ -0,0 +1,489 @@ +# FASTSHAP: REAL-TIME SHAPLEY VALUE ESTIMATION + +Neil Jethani∗ New York University + +Mukund Sudarshan∗ New York University + +Ian Covert∗ University of Washington + +Su-In Lee University of Washington + +Rajesh Ranganath New York University + +# ABSTRACT + +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. + +# 1 INTRODUCTION + +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. + +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). + +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. + +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. + +![](images/2cc09ceaa47a3ac2b457b5e0575e9e1c41541c656dfbbf617f73d7a607d33f58.jpg) +Figure 1: Explanations generated by each method for Imagenette images. + +# 2 BACKGROUND + +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. + +# 2.1 SHAPLEY VALUES + +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 + +$$ +\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 ) . +$$ + +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 + +$$ +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) , +$$ + +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). + +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. + +# 2.2 KERNELSHAP + +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 }$ , + +$$ +\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} +$$ + +(Efficiency constraint) + +where the distribution $p ( \mathbf { s } )$ is defined as + +$$ +p ( s ) \propto \frac { d - 1 } { \binom { d } { \mathbf { 1 } ^ { \top } s } \cdot \mathbf { 1 } ^ { \top } s \cdot ( d - \mathbf { 1 } ^ { \top } s ) } +$$ + +(Shapley kernel) + +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. + +# 3 FASTSHAP + +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 } )$ . + +# 3.1 AMORTIZING SHAPLEY VALUES + +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, + +$$ +\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} +$$ + +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: + +$$ +\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 } ) . +$$ + +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: + +$$ +\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 } } . +$$ + +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. + +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. + +# 3.2 A DEFAULT VALUE FUNCTION FOR FASTSHAP + +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. + +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. + +# Algorithm 1: FastSHAP training + +Input: Value function $v _ { x , y }$ , learning rate $\alpha$ +Output: FastSHAP explainer $\phi _ { \mathrm { f a s t } } ( \mathbf { x } , \mathbf { y } ; \theta )$ +initialize $\phi _ { \mathrm { f a s t } } ( \mathbf { x } , \mathbf { y } ; \theta )$ +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}$ +end + +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: + +$$ +\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} +$$ + +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): + +$$ +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 } ] . +$$ + +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). + +# 4 RELATED WORK + +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. + +![](images/16a53cc41f4285fd446707f675124530c32fda8859de23c7e20c112fcd7bb7e1.jpg) +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. + +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). + +# 5 STRUCTURED DATA EXPERIMENTS + +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. + +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 + +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. + +![](images/0e4368fc74e8b1892b47dae2d83fe8ac3b17caf1756275963843955933d5a0dd.jpg) +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. + +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). + +# 5.1 ACCURACY OF FASTSHAP EXPLANATIONS + +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. + +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. + +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. + +# 5.2 DISENTANGLING AMORTIZATION AND THE CHOICE OF VALUE FUNCTION + +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: + +1. (Surrogate/In-distribution) $v _ { x , y } ( s ) = p _ { \mathrm { s u r r } } ( y \mid m ( x , s ) ; \beta )$ +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]$ +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) + +![](images/abcad0d1d3cfe2a74001d5271fab5c18e2cc9edbfefc91b5a28203e54557ef06.jpg) +Figure 4: Explanations generated by each method for CIFAR-10 images. + +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. + +# 6 IMAGE EXPERIMENTS + +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. + +# 6.1 DATASETS + +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. + +# 6.2 EXPLANATION METHODS + +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. + +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. + +# 6.3 QUALITATIVE REMARKS + +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. + +# 6.4 QUANTITATIVE EVALUATION + +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. + +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. + +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- + +![](images/92e7c3a4a4f449600c70bbedb1a75227ddc0fbf030aeeef27e54856172e20146.jpg) +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). + +$100 \%$ . The area under each curve (AUC) is termed the Inclusion AUC or Exclusion AUC. + +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. + +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. + +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. + +
CIFAR-10Imagenette
Exclusion AUCInclusion AUCExclusion AUCInclusion AUC
FastSHAP0.42 (0.41, 0.43)0.78 (0.77, 0.79)0.51 (0.49, 0.52)0.79 (0.78, 0.80)
KernelSHAP0.64 (0.63, 0.65)0.78 (0.77, 0.79)0.68 (0.67, 0.70)0.77 (0.75, 0.78)
KernelSHAP-S0.54 (0.52, 0.55)0.86 (0.85, 0.87)0.61 (0.60, 0.62)0.82 (0.80, 0.83)
GradCAM0.52 (0.51, 0.53)0.76 (0.75, 0.77)0.52 (0.50, 0.53)0.74 (0.73,0.76)
Integrated Gradients0.55 (0.54, 0.56)0.74 (0.73, 0.75)0.65 (0.64, 0.67)0.73 (0.71, 0.74)
SmoothGrad0.70 (0.69, 0.71)0.72 (0.71, 0.73)0.72 (0.71, 0.73)0.73 (0.72, 0.75)
DeepSHAP0.65 (0.64, 0.66)0.79 (0.78, 0.80)0.69 (0.68, 0.71)0.74 (0.73, 0.75)
CXPlain0.56 (0.55, 0.57)0.71 (0.70, 0.72)0.60 (0.58, 0.61)0.72 (0.71, 0.74)
+ +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. + +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 \%$ . + +# 6.5 SPEED EVALUATION + +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. + +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 + +Table 2: Training and explanation run-times for 1,000 images (in minutes). + +
CIFAR-10Imagenette
rdgFastSHAP0.040.04
KernelSHAP453.691089.50
KernelSHAP-S460.10586.12
GradCAM IntGrad0.38 0.910.30 0.92
SmoothGrad DeepSHAP1.00 5.391.05 6.01
TTTrmCXPlain0.040.04
FastSHAP693.57146.49
KernelSHAP-S CXPlain362.03 538.4973.22 93.00
+ +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. + +# 7 DISCUSSION + +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. + +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. + +# 8 REPRODUCIBILITY + +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. + +# 9 ACKNOWLEDGEMENTS + +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. + +# REFERENCES + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +Covert, I., Lundberg, S., and Lee, S.-I. (2020). Understanding global feature contributions with additive importance measures. Advances in Neural Information Processing Systems, 33. + +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. + +Cybenko, G. (1989). Approximation by superpositions of a sigmoidal function. Mathematics of Control, Signals and Systems, 2(4):303–314. + +Dabkowski, P. and Gal, Y. (2017). Real time image saliency for black box classifiers. In Advances in Neural Information Processing Systems, pages 6967–6976. + +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. + +Dua, D. and Graff, C. (2017). UCI machine learning repository. + +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. + +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. + +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. + +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. + +Hornik, K. (1991). Approximation capabilities of multilayer feedforward networks. Neural Networks, 4(2):251–257. + +Howard, J. and Gugger, S. (2020). FastAI: A layered API for deep learning. Information, 11(2):108. + +Illés, F. and Kerényi, P. (2019). Estimation of the Shapley value by ergodic sampling. arXiv preprint arXiv:1906.05224. + +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. + +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. + +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. + +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. + +Krizhevsky, A., Hinton, G., et al. (2009). Learning multiple layers of features from tiny images. + +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. + +Lipovetsky, S. and Conklin, M. (2001). Analysis of regression in game theory approach. Applied Stochastic Models in Business and Industry, 17(4):319–330. + +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. + +Lundberg, S. M. and Lee, S.-I. (2017). A unified approach to interpreting model predictions. Advances in Neural Information Processing Systems, 30:4765–4774. + +Mitchell, R., Cooper, J., Frank, E., and Holmes, G. (2021). Sampling permutations for Shapley value estimation. arXiv preprint arXiv:2104.12199. + +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. + +Petsiuk, V., Das, A., and Saenko, K. (2018). RISE: Randomized input sampling for explanation of black-box models. arXiv preprint arXiv:1806.07421. +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. +Schulz, K., Sixt, L., Tombari, F., and Landgraf, T. (2020). Restricting the flow: Information bottlenecks for attribution. arXiv preprint arXiv:2001.00396. +Schwab, P. and Karlen, W. (2019). CXPlain: Causal explanations for model interpretation under uncertainty. In Advances in Neural Information Processing Systems, pages 10220–10230. +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. +Shapley, L. S. (1953). A value for n-person games. Contributions to the Theory of Games, 2(28):307– 317. +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. +Smilkov, D., Thorat, N., Kim, B., Viégas, F., and Wattenberg, M. (2017). Smoothgrad: removing noise by adding noise. arXiv preprint arXiv:1706.03825. +Štrumbelj, E. and Kononenko, I. (2014). Explaining prediction models and individual predictions with feature contributions. Knowledge and Information Systems, 41(3):647–665. +Sundararajan, M., Taly, A., and Yan, Q. (2017). Axiomatic attribution for deep networks. In International Conference on Machine Learning, pages 3319–3328. PMLR. +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). +Wang, R., Wang, X., and Inouye, D. I. (2021). Shapley explanation networks. In International Conference on Learning Representations. +Yoon, J., Jordon, J., and van der Schaar, M. (2018). INVASE: Instance-wise variable selection using neural networks. In International Conference on Learning Representations. + +# A FASTSHAP GLOBAL OPTIMIZER + +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 + +$$ +\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} +$$ + +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 + +$$ +\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 } . +$$ + +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 }$ : + +$$ +\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} +$$ + +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 } )$ . + +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)). + +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: + +$$ +\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 } . +$$ + +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. + +# B ADDITIVE EFFICIENT NORMALIZATION + +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 } }$ : + +$$ +\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 } ) . +$$ + +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: + +$$ +\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} +$$ + +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. + +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: + +$$ +\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} +$$ + +# C REDUCING GRADIENT VARIANCE + +Recall that our objective function $\mathcal { L } ( \boldsymbol { \theta } )$ is defined as follows: + +$$ +\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} +$$ + +The objective’s gradient is given by + +$$ +\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} +$$ + +where we define + +$$ +\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 } . +$$ + +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 + +$$ +\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} +$$ + +where we have the relationship + +$$ +\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 ) +$$ + +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 + +$$ +\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 ) . +$$ + +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 + +$$ +\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 ) . +$$ + +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). + +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. + +Algorithm 2: Full FastSHAP training + +
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)
for y = 1,..., K do
predict Φ ← Φfast (x,y; 0)
calculate R ← R+ (ux,y(1)- Ux,y(0)-1Tó)² //Pre-normalization
if normalize then set←Φ+d-1(x,y(1)-Ux,y(0)-1Φ)
end
for j=1,...,m do if paired sampling and i mod 2= O then
sets←1-s// Invert previous subset
else 一 sample s~ p(s)
end
calculateL←L+(xy(s)-Ur,y(0)-sΦ)
end
end
end
update←θ-αVθ(bmk+γ)
end
+ +![](images/5665784d9818405c4eaf24e0acafb10ba0601d104b7fa1eedb5bae79d00216f3.jpg) +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. + +# D FASTSHAP MODELS AND HYPERPARAMETERS + +In this section, we describe the models and architectures used for each dataset, as well as the hyperparameters used when training FastSHAP. + +# D.1 MODELS + +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. + +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. + +# D.2 FASTSHAP HYPERPARAMETERS + +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. + +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). + +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. + +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. + +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. + +
CensusBankruptcy
l2l1l2l1
Normalization0.02290.08630.02950.2436
Normalization + Penalty0.02610.09710.03200.2740
Inference Norm.0.04060.15120.04070.3450
Inference Norm. + Penalty0.04520.16710.04730.4471
No Norm.0.05010.19330.04080.3474
No Norm.+Penalty0.05130.19260.04740.4490
+ +# E ADDITIONAL RESULTS FOR IMAGE EXPERIMENTS + +In this section, we provide additional results for the FastSHAP image experiments. + +# E.1 INCLUSION AND EXCLUSION METRICS + +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. + +Table 4: Exclusion and Inclusion AUCs calculated using the average log-odds of the predicted class. + +
CIFAR-10Imagenette
Exclusion AUCInclusion AUCExclusion AUCInclusion AUC
FastSHAP5.92 (5.62, 6.14)5.36 (5.16, 5.63)7.98 (7.68, 8.33)5.40 (5.16, 5.60)
KernelSHAP9.88 (9.55, 10.20)5.36 (5.14,5.63)10.68 (10.36,11.00)5.07 (4.81, 5.31)
KernelSHAP-S8.01 (7.68, 8.34)6.80 (6.65, 6.96)9.39 (9.11, 9.66)6.01 (5.78, 6.26)
GradCAM7.75 (7.44, 8.09)4.99 (4.81, 5.26)7.77 (7.49, 8.05)4.65 (4.40,4.89)
Integrated Gradients8.34 (8.03,8.61)4.58 (4.37, 4.85)10.14 (9.79,10.46)4.34 (4.10,4.58)
SmoothGrad10.99 (10.67, 11.29)4.30 (4.08,4.58)11.19 (10.84, 11.48)4.47 (4.24, 4.70)
DeepSHAP9.96 (9.61, 10.24)5.47 (5.28,5.76)10.93 (10.61,11.20)4.63 (4.38,4.85)
CXPlain8.34 (8.00, 8.58)4.02 (3.80, 4.31)9.13 (8.83, 9.41)4.33 (4.11, 4.57)
+ +![](images/709376565890fab73ef403c03406220d888ef37a729e56a52ef92ee2e173a5a9.jpg) +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. + +![](images/7de028d8eb935789145419a25f2399c677985a854ba8d57222b2df7cb6233ea5.jpg) +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. + +# E.2 FASTSHAP ROBUSTNESS TO LIMITED DATA + +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 \%$ . + +# E.3 EXAMPLE FASTSHAP IMAGE EXPLANATIONS + +Finally, we show additional explanations generated by FastSHAP and the baseline methods for both CIFAR-10 and Imagenette. + +![](images/3c32268e4bef03850935df25914fa1fcc59e0b146f75e37c948fde8c9174022d.jpg) +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. + +![](images/f3756c77d8c74ba02c889b8a72b2ec5c19add34f37fa8b5f4e47a2eb1a27884f.jpg) +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. + +![](images/f1c179d23eadaff8f539f754d9e583cd4e31fa136720d9c4970286ab23dd05de.jpg) +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. + +![](images/b2691ffe09d58305000164af4b0a75cb8e252cba5e060d5739f575a4afa69077.jpg) +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. \ No newline at end of file diff --git a/md/dev/_CDixzkzeyb/_CDixzkzeyb.md b/md/dev/_CDixzkzeyb/_CDixzkzeyb.md new file mode 100644 index 0000000000000000000000000000000000000000..2de6d00ba2db4b2f229a92d18ce0a8c332eeb390 --- /dev/null +++ b/md/dev/_CDixzkzeyb/_CDixzkzeyb.md @@ -0,0 +1,826 @@ +# PROMPT-TO-PROMPT IMAGE EDITINGWITH CROSS-ATTENTION CONTROL + +Amir Hertz∗1,2, Ron Mokady∗1,2, Jay Tenenbaum 1, Kfir Aberman1, Yael Pritch1, and Daniel Cohen-Or∗1,2 + +1 Google Research 2The Blavatnik School of Computer Science, Tel Aviv University + +# ABSTRACT + +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. + +# 1 INTRODUCTION + +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. + +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. + +![](images/36663772727eeca2767f67d8990a9655a2fc02b30d4d13358a8585229a5fbb38.jpg) +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). + +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. + +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. + +# 2 RELATED WORK + +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). + +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. + +![](images/5c39d917ac357fb8469671390c594fbb67b027412fd380b4da6824d57051b53f.jpg) +fixed attention maps and random seed +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. + +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. + +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. + +# 3 METHOD + +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. + +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. + +![](images/fd97880c668fb7c758b7964c399b16a9c86cc41b963fd74483d48f2b09770075.jpg) +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. + +# 3.1 CROSS-ATTENTION IN TEXT-CONDITIONED DIFFUSION MODELS + +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 + +$$ +M = \mathrm { S o f t m a x } \left( \frac { Q K ^ { T } } { \sqrt { d } } \right) , +$$ + +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 )$ . + +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. + +# 3.2 CONTROLLING THE CROSS-ATTENTION + +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. + +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. + +![](images/16fe3c3c57160f199ace7cda7d6c5807449e10c6dc51e859cd9c38e080ecf350.jpg) +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. + +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. + +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: + +1 Input: A source prompt $\mathcal { P }$ , a target prompt ${ \mathcal { P } } ^ { * }$ , and a random seed $s$ . +2 Optional for local editing: $w$ and $w ^ { * }$ , words in $\mathcal { P }$ and ${ \mathcal { P } } ^ { * }$ , specifying the editing region. +3 Output: A source image $x _ { s r c }$ and an edited image $x _ { d s t }$ . +4 $z _ { T } \sim N ( 0 , I )$ a unit Gaussian random variable with random seed $s$ ; +5 $z _ { T } ^ { * } \gets z _ { T }$ ; +6 for $t = T , T - 1 , \dots , 1$ do +7 $z _ { t - 1 } , M _ { t } \gets D M ( z _ { t } , \mathcal { P } , t , s ) ;$ ; +8 $M _ { t } ^ { * } \gets D M ( z _ { t } ^ { * } , \mathcal { P } ^ { * } , t , s )$ ; +9 $\widehat { M _ { t } } \gets E d i t ( M _ { t } , M _ { t } ^ { * } , t ) ;$ ; +10 $z _ { t - 1 } ^ { * } D M ( z _ { t } ^ { * } , \mathcal { P } ^ { * } , t , s ) \{ M \widehat { M } _ { t } \} ;$ +11 if local then +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}$ +13 +14 end +15 end +16 Return $( z _ { 0 } , z _ { 0 } ^ { * } )$ + +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). + +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. + +![](images/690b3ff6124d0d81832c42baf8d5630364893701e00834863624f7787de356cc.jpg) +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). + +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: + +$$ +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. } +$$ + +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. + +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: + +$$ +\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} +$$ + +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. + +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: + +$$ +\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. +$$ + +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. + +![](images/df261f19d50229b578ac37cdaea33ad5b8a94eed140f12e83c0b78fafb0ed531.jpg) +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) . + +![](images/03dbb0f64ef9794f91e062c8af2220c86c091e71d2949661d9ae81df5623e490.jpg) +“The picnic is ready under a blossom( ) tree.” +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). + +# 3.3 SELF-ATTENTION + +“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. + +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. + +# 4 RESULTS + +In this section, we show several applications of our approach and compare it to other methods. + +# 4.1 APPLICATIONS + +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). + +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. + +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. + +
VQGAN+CLIPText2LivebaselineOurs
(1) Background / Structure ↑1.84 ± 1.114.15 ± 1.093.38 ± 1.124.64 ± 0.64
(2) Text Alignment ↑2.46 ± 1.162.89 ±1.224.26 ± 1.034.55 ± 0.71
(3) Realism ↑1.32 ± 0.702.36 ± 1.124.11 ± 0.934.42 ± 0.82
+ +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. + +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). + +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. + +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. + +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. + +# 4.2 COMPARISONS + +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. + +![](images/3a206c1ec4a07d6268f75c17ef1f6bc2fc97a19ccd91d60d38f9b606b4d68bd1.jpg) +“Photo of a squirrel bear enjoys at the playground.” +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). + +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. + +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. + +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. + +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. + +# 5 CONCLUSIONS + +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. + +# 6 ETHIC STATEMENT + +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. + +# ACKNOWLEDGMENTS + +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. + +# REFERENCES + +Omri Avrahami, Ohad Fried, and Dani Lischinski. Blended latent diffusion. arXiv preprint arXiv:2206.02779, 2022a. +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. +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. +David Bau, Alex Andonian, Audrey Cui, YeonHwan Park, Ali Jahanian, Aude Oliva, and Antonio Torralba. Paint by word, 2021. +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. +Andrew Brock, Jeff Donahue, and Karen Simonyan. Large scale gan training for high fidelity natural image synthesis. arXiv preprint arXiv:1809.11096, 2018. +Katherine Crowson. Vqgan $^ +$ clip, 2021. https://colab.research.google.com/ drive/1L8oL-vLJXVcRzCFbPwOoMkPKJ8-aYdPN. +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. +Prafulla Dhariwal and Alexander Nichol. Diffusion models beat gans on image synthesis. Advances in Neural Information Processing Systems, 34:8780–8794, 2021. +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. +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. +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. +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. +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. +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. +Tobias Hinz, Stefan Heinrich, and Stefan Wermter. Semantic object accuracy for generative text-toimage synthesis. IEEE transactions on pattern analysis and machine intelligence, 2020. +Jonathan Ho and Tim Salimans. Classifier-free diffusion guidance. In NeurIPS 2021 Workshop on Deep Generative Models and Downstream Applications, 2021. +Jonathan Ho, Ajay Jain, and Pieter Abbeel. Denoising diffusion probabilistic models. Advances in Neural Information Processing Systems, 33:6840–6851, 2020. +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. +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. +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. +Gihyun Kwon and Jong Chul Ye. Clipstyler: Image style transfer with a single text condition. arXiv preprint arXiv:2112.00374, 2021. +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. +Bowen Li, Xiaojuan Qi, Thomas Lukasiewicz, and Philip Torr. Controllable text-to-image generation. Advances in Neural Information Processing Systems, 32, 2019. +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. +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. +Or Patashnik, Zongze Wu, Eli Shechtman, Daniel Cohen-Or, and Dani Lischinski. Styleclip: Textdriven manipulation of stylegan imagery. arXiv preprint arXiv:2103.17249, 2021. +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. +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. +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. + +Aditya Ramesh, Prafulla Dhariwal, Alex Nichol, Casey Chu, and Mark Chen. Hierarchical textconditional image generation with clip latents. arXiv preprint arXiv:2204.06125, 2022. + +Robin Rombach, Andreas Blattmann, Dominik Lorenz, Patrick Esser, and Bjorn Ommer. High- ¨ resolution image synthesis with latent diffusion models, 2021. + +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. + +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. + +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. + +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. + +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. + +Jiaming Song, Chenlin Meng, and Stefano Ermon. Denoising diffusion implicit models. In International Conference on Learning Representations, 2020. + +Yang Song and Stefano Ermon. Generative modeling by estimating gradients of the data distribution. Advances in Neural Information Processing Systems, 32, 2019. + +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. + +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. + +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. + +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. + +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. + +Weihao Xia, Yulun Zhang, Yujiu Yang, Jing-Hao Xue, Bolei Zhou, and Ming-Hsuan Yang. Gan inversion: A survey, 2021b. + +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. + +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. + +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. + +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. + +# A BACKGROUND + +# A.1 DIFFUSION MODELS + +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. + +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: + +$$ +x _ { t } = \sqrt { \alpha _ { t } } x _ { 0 } + \sqrt { 1 - \alpha _ { t } } w , \ w \sim N ( 0 , I ) , +$$ + +where $\begin{array} { r } { \alpha _ { t } : = \prod _ { i = 1 } ^ { t } ( 1 - \beta _ { i } ) } \end{array}$ . + +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. + +Under this definition, we use Bayes’ theorem to approximate + +$$ +\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) . +$$ + +Once we have a trained $\epsilon _ { \theta } ( x _ { t } , t )$ , we can using the following sample method + +$$ +x _ { t - 1 } = \mu _ { \theta } ( x _ { t } , t ) + \sigma _ { t } z , \ z \sim N ( 0 , I ) . +$$ + +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: + +$$ +\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 } , +$$ + +teaching the parameters $\theta$ to fit $q ( x _ { 0 } )$ by maximizing a variational lower bound. + +# A.2 ATTENTION LAYERS IN TEXT TO IMAGE DIFFUSION MODELS + +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) + +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. + +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: + +• $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. +• $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). +• $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). + +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. + +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. + +# B SELF-ATTENTION IN TEXT-CONDITIONED DIFFUSION MODELS + +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. + +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. + +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. + +![](images/b8d2d2f2b9382a6ba39effacff8a47e282baa6e260257776478547ed1783da4e.jpg) +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. + +# C ADDITIONAL RESULTS + +Additional quantitative results are provided in table 2. + +Full figures for fig. 5 and 6, are in fig. 11 and 13 respectively. Additional qualitative comparisons are provided in fig. 14 and 15. + +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. + +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. + +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. + +# C.1 DIFFERENT BACKBONES + +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. + +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. + +# D LIMITATIONS + +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. + +# E USER STUDY + +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: + +![](images/d8536c0e62cb50c753c52b2873f9d67ce908040906112f4b04c1e63a93168c06.jpg) +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. + +(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. + +(2) How well does the right image match the text description above it? Specifically, consider the highlighted text. + +(3) Rate the overall realism and quality of the right image. + +See fig. 31 for screenshots. + +# F EVALUATION PROMPTS + +We use the following prompt templates to generate the evaluation data: + +T e m p l a t e 1 : ” Image o f i n s i d e a $ .” +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 ” ] +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 ” ] + +T e m p l a t e 2 : ”A f u l l o f 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 ” ] + +T e m p l a t e 3 : ” Pho to o f a .” + +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 ” ] +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 ” ] +Template 3 : ” Photo of a wi th a on i t . ” +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 ” ] +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 ” ] +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 ” ] + +T e m p l a t e 4 : ” Image o f a 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 ” ] + +T e m p l a t e 5 : ”A l a n d s c a p e Image o f .” +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 ” , +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 ” ] + +Source image + +Source Prompt: “Photo of a cat riding on a bicycle.” + +![](images/b311c1e201d2f9aa43afcb39502ca0ab0c789158dd9b58a6420e70c17a3396ca.jpg) + +![](images/1f7ea96e3b7aded70b43cd99770387c7c5b689205bd8c1bd5d387e95eafe2526.jpg) +bicycle motorcycle +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. + +W.O.cross-attention injection → Full cross-attention injection + +T e m p l a t e 6 : ” i n t h e s t r e e t . ” +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 ” ] +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 ” ] + +We generate 20 random examples using each template where the tokens , ${ \mathrm { - R P C } } >$ and ${ \mathrm { < A D D > } }$ where randomly replaced with one item in the corresponding selection list below each template. + +${ \mathrm { \ C O N S T { \mathrm { > } } } }$ stands for phrase that is used in both source and target prompt. + +${ \mathrm { < R P C > } }$ stands for phrase that is different between the source and target. + +${ \mathrm { < A D D > } }$ stands for refinement phrase which is only replaced in the target prompt and omitted in the source prompt. + +# Source image + +Source prompt: “A sailing boat near a castle.” + +![](images/2b28aca107b155d607471e8ce29a1aca39aca263fb38912aad246d85d402a210.jpg) + +![](images/c536b7e9d7582407dfe01a2a88f498b26199092557885d463c78562f6f3a228b.jpg) +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. + +Target prompt: “An elephant in the field.” +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). + +
CLIP score个MS-SSIM↑LPIPS↓
VQGAN+CLIP0.282 ±0.040.27 ± 0.0460.64± 0.05
Text2Live0.247 ± 0.040.82±0.0650.25± 0.05
baseline0.253 ± 0.030.69 ± 0.130.35 ± 0.12
Ours0.253± 0.040.81± 0.110.22 ± 0.1
+ +“A car on the side of the street.” + +![](images/04df67b44a4f163e14f3af863e2c08a26768554be9f0dd5e3aa010534f78cae0.jpg) +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). + +“Photo of a cat camel seating in the forest.” + +![](images/7654a981632f30da67785934e4e9abfda068e5b96672173b5f3ac3b34f822094.jpg) + +“Image of a bowl with oranges chocolates.” + +![](images/a8e6ff1a6ce1198af712b96544455055bc54237c259b2f008eb7d021a5b0b146.jpg) + +“Photo of a flower made of candies with a butterfly on it.” + +![](images/d4d77c9ee07edf6bcf02f2fd515d581ac5e99b603243cc14cad2fe278288befc.jpg) + +“Image of a golden scooter on the side of the road.” + +![](images/530f6b6a2e668fe70b1e0d9ce1132eb570c02a8d6741dd864ad026f009685363.jpg) + +“A landscape image of a lake at sunset.” + +![](images/d93d4dbe157de84fa7f1ec9771dcd7c2e4fa58413efa8d56f9d152b1bb5b4aca.jpg) +Figure 14: Additional comparisons to text-guided image editing. Similar to ours, these methods do not require a user-provided mask. + +“Photo of a lion zebra seating in the forest.” + +![](images/91b64ec0e20a42e0e9fb5c3b7727fb3af60b584cf4d4660bd6e2735a84af531a.jpg) +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. + +![](images/393c330088b967161f7a5914a69ed090e7653553d5f12c8922db87a6826f7b85.jpg) +Cross–attention injection +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. + +“A photo of a butterfly on...” + +Cross–attention injection + +![](images/cf84f8281b7b824a4e2fbbafc5d6109038cf2cd9e0ff44b6669e7f03346a1610.jpg) +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.” + +“drawing of...” “photo of...” + +![](images/abff34e1b7365e5e51deb7e776dbaa0f40961abaa50e7755378d50589e13d90d.jpg) +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. + +![](images/8e93e24bf262b6810b1ae56332d36ba1e0b8213a238897afa557bea75bdfba13.jpg) +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. + +![](images/84091c78f84a55cfae9848ca261ac5c3c7f706c1d9fb1648ed4c83f6d94d9c3e.jpg) +Figure 20: Inversion Failure Cases. Current DDIM-based inversion of real images might result in unsatisfied reconstructions. + +![](images/bf8888ae938ed56ce79fd652f5467f693d275870fd25b0897a20d9cd282a1b13.jpg) +different noise seeds +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. + +![](images/89378203e8d0041750ac9145c1a673ce3a78ef3d990f4dd9310f2c1e00481a01.jpg) + +“A ball between two chairs on the beach. + +![](images/7381076577b65d1d5ab687b4f7f0302730ab35f536cb3efcc5e8897ac81a5dcf.jpg) +Figure 22: Additional results for Prompt-to-Prompt editing by word swapping using the Imagen model (Saharia et al., 2022b).. + +![](images/88286251b3b8e5650f7a0e84e00100f1e1caf6c464d8f1e18e6d79e7cd5ff49e.jpg) +Figure 23: Additional results for Prompt-to-Prompt editing by adding a specification using the Imagen model (Saharia et al., 2022b).. + +![](images/b3d120a0df41e28d1c1a60993ba8885a520d0095bf249613de6b86ddef6a2be7.jpg) +“A leopard sleeping( ) cake next to an apple.” + +![](images/97139ab2ef4572d81a2052b53036ed5cca30fd4724de7f77caf8eb1b1746ab4c.jpg) +“A smiling( ) teddy bear.” + +![](images/c8591a92775ade73b88af9a5edca79890485d172d246d305773a575b96f7983d.jpg) +“Photo of a cubic( ) sushi.” + +![](images/bd646e01f693602867ebd8ba08ed27b5308f07a1f812688f6182f333f34d83a7.jpg) + +“A photo of a birthday( ) cake next to an apple.” + +![](images/4fe2d7f332a1601a8ad5e4953240238b7edd7262120c9b128f9db66011a1bcd9.jpg) +“My colorful( ) bedroom.” + +![](images/e65d1884e620b721a67abd7c48e8ec4263aef3145d7647fce5c13e8e596c2887.jpg) +Figure 24: Additional results for Prompt-to-Prompt editing by attention re-weighting using the Imagen model (Saharia et al., 2022b). + +“Photo of a field of poppies at night( ).” + +![](images/0173d57ad3035482d0069cf24d53e0878193e5a85006139fd3c8582d29060b8e.jpg) +“A painting of a squirrel eating a burger pizza.” + +![](images/33586fcfc05ad6959c605f3fc615c47de43ba17e2facd6a7b198ba4f8f661292.jpg) +“A bench with a pile of books magazines on top.” + +![](images/6943e732a25acda4ab2ff15d2afb9158177290433c6dee38cddeeb36ad1e41fe.jpg) +“Banknote portrait of a cow horse.” + +![](images/7711404414a610930b20f7a82acc82c1f0926399e390bca8d5a1e95ddac4e7e7.jpg) + +![](images/a184576bbaf79ed07b7e40cbca889e54bf779014980b57f57e6ec8481420c3d0.jpg) + +“Snail Turtle in the middle of the forest. Afternoon light.” + +![](images/019a06f2e798428f95586b69d04b17e9fb8d6caed86bab242dd64c9def80b54e.jpg) + +“A bowl with apples snacks on a table.” + +“Photo of a butterfly bee on a flower.” + +![](images/b4a1c915f50965866d36e0ab1f6a1cdc5849cc791a1e21f3306647b00b7c389f.jpg) +“A photo of a dog wearing a floral dotted shirt.” + +![](images/426a15442cd3e9c026276e9883388d0c93b44ec555685d0d1bb2ef5b94a6ceb1.jpg) + +![](images/f4e234875a365303c7c9450d11c549847e391f85cb3ab5cec84bf74a05d08a67.jpg) +“A photo of a cat dog wearing a blue tie.” + +“A photo of a cat playing chess domino .” + +![](images/704a8b7cbd1fe240be8cf3f9560eb6e7510d92b6cd594e5cc38f9f800a19712c.jpg) +“A vase filed with cotton tennis balls.” + +![](images/b8388857c365e45f1fef72d619a4d8d61e11231943f457bc7344e49e77c8a333.jpg) +“A beautiful bouquet of tulips daisies on a table.” + +![](images/996d6d3ec3b8d0ae63250845e4dc87101be9fa7a37c0e00b9f93e57914b27743.jpg) +“A deflated inflated tire on the ground.” + +![](images/6fe1135eda1e6f684bc29df0d0b86d7cc872d4ed2c068045398bbc05e2128b8b.jpg) + +“A painting of a lion bear eating an apple.” + +![](images/1d7071266a96af7ea98044b54aad85294376949ac527f3b5fd96c37ec5a4319d.jpg) +“A car is driving on the beach road.” + +![](images/bf702a877a63a3118c21707ce90c6c41463b33d2987a0a84ef0f1a0d10f90784.jpg) +“Soup with rice noodles.” + +![](images/c16c2b8fd3d010e5b2da1065215c123075ce32da2fdbfbfe76acc1d67cc2fad8.jpg) +“Watercolour painting photo of a latent space.” + +![](images/908db1a5aded712c56039570b70c595066f212fee06b26c9a969b93f03a082dc.jpg) +“A photo of an astronaut riding a horse camel.” + +![](images/fdb7aa0044115654b4c7ae007c4975788653803ae5e3395fb2e39a4bedde201f.jpg) +“A castle made out of sand corn.” + +![](images/dfcde095a547d23e32e85fc39dc7f890958e8043fb0aa9aa63fce74b8ee7b7d2.jpg) +“A snowman scarecrow in the garden.” +Figure 25: Additional results for Prompt-to-Prompt editing by word swap using the Latent Diffusion Model (Rombach et al., 2021). + +![](images/b4ec7122bd6f8db2dd014bda90d9ea2ce9d3b0e1098fb88e508d9b10f8a26657.jpg) +“Lemon Apple cake on the table.” + +![](images/20a409519afd83918755291d140cec62d7511d52d13a44341e8b6311f84fd5ac.jpg) +“Image of candies toys inside a box.” + +![](images/029c1832f055f49243414768d74b381363e5a7abb419962a07e8b95410ac3834.jpg) +“A beautiful bouquet of tulips of the colour red and yellow.” + +![](images/087a536b31d1b4ee497a7d99237795aa6b0c66a66b489d166c89ad11c6176424.jpg) +“A school bus is driving in the street.” + +![](images/15fa14d4e70f4699917d971f1a04d16520d2b59804868e903f8ca8e22a17e2a9.jpg) +“A car is driving in the flooded street.” + +![](images/817ba9687efcf22eb6a95220461e46b8495cfb3e399bcbf4c4c6520b19a3a2cf.jpg) +“A landscape with a lake between mountains at sunset.” + +![](images/50e59f9e8e5c36a200142a443d9b19caad5bf6d67ceefff8d0899a495007df05.jpg) + +![](images/f17acc516225ced6b648772aa6f0b8832462926fd23b66ed5c42b085bcca7865.jpg) +“Pizza with mushrooms.” + +“A wooden bike in the yard.” + +![](images/d8e3b2e97ee0b82fcc2c639588070470554a266a980c48859ac1e24310ae2d0f.jpg) +“A fashion sketch of an evening dress with long sleeves.” , + +![](images/7f6a606c009bb7c6869e3b50f28fe3eb9c56347cdbeccd9f5204b5684f5c33ab.jpg) +“A speeding race car is driving on the beach.” + +![](images/f842cd397cef277e94521e6c3a827cd1c9be082ac7446ca755c4ae183bc8abee.jpg) +“A big yellow apple on a table” + +![](images/a27cb78c7567b55408a920be947faabf4bca71048b7a64219521c9cd9f57118d.jpg) + +“My bicycle are in the street of Las Vegas.” + +![](images/70b0d16f05ca948a29719bf2c8e91cac8f4453a2a3719f230234997a911184db.jpg) +“A banknote portrait of a cat.” + +![](images/800f11cb64def02c1a7a06972f855273ac8f74621a715bb645f72d1c6bc5b1a1.jpg) + +“A cubist painting of a vase with lilies.” + +![](images/86d9e941b1dec22cc451a67977257ba49b41237dde0d8ae63b47bc8adcbecbcf.jpg) +“A small clay bunny with a big smile.” + +![](images/bba3e2dbb585ff155bcda5c5b4711aab6c6e468873fadf36655bb1f5cc97f889.jpg) +“My bicycle are in the street at blossom.” + +![](images/f726cc9c29131f79fcb63722dc2cdfb4d27f78a91495dc0aca099d057a36b8b2.jpg) +“Photo of a landscape with a river and mountains at sunrise.” + +![](images/b564bc7b838196c7bc14b9d298fde77bf67dddc0458180b8643530df76ebcdb0.jpg) +“A TV screen with many burnt pixels.” + +![](images/220da86a7cfbcca2617c2a32e2dad0107e6c68dd6076af61eaf436b180dca0ba.jpg) +“A stove outside creating a smoke cloud above.” + +![](images/029016f182177acf76a987d36a8cdbfe6244f3de6befb696a08d56035e2ec3b9.jpg) +“A bear with yellow sunglasses and a drink.” + +![](images/60f89048121db9f373004e8d50e6a50d33bb6bf22bb1dddcc55dde23e90c46c7.jpg) + +“A photo of a dog wearing a floral shirt.” + +![](images/dded79333cd8b0b9e6d38d325a73988486b2dd4a8c99c65d6a35fc9d2abed8f4.jpg) +“A landscape photo of a harbor in the storm.” +Figure 26: Additional results for Prompt-to-Prompt editing by adding a specification using the Latent Diffusion Model (Rombach et al., 2021). + +![](images/c54e2101e3cd2ea0a89f8fa13cd91e4dfd03c2c315eafaca75eafeb6ad2dcc12.jpg) +“The scooter at the city at winter.” + +![](images/144c1c40d1b2b55c0c3ec5efae6b97c4baaa5dec703f253b81674d98404a41b5.jpg) + +"A photo of a blossom ( ) tree." + +![](images/01b45cf9c44ebc9713f5e485ebe0b8d244d3fd0ca280e44075c09135a71442ed.jpg) +“A landscape with a snowy ( ) mountain.” + +![](images/35f19b15adce1457e77d0ac6a9efd0d61db7cbe2b45d9eac0e004c40ab4e193e.jpg) + +“A photo of the ancient ( ) city.” + +![](images/75af99811fde35c35302c6ca3afd810cad8e503a72c049c5795ecf7a5ce58bae.jpg) +“A crahsed ( ) car.” + +![](images/4e141fc700d1d58b31182ecbfcfee3f6c5d4ae41b5f25ab4d51ca7ea8cd1ba57.jpg) +“My puffy ( ) shirt.” + +![](images/3a1e9a69e15a155e04730bb77b8c5c7fa10b1adad819a478b3e93e0c56e31e46.jpg) +“A photo of a poppy field at night ( ).” +Figure 27: Additional results for Prompt-to-Prompt editing by attention re-weighting using the Latent Diffusion Model (Rombach et al., 2021). + +![](images/ccf8abf4c921109d3140438a44ac292933616ec6c3046245c7c53a2a78941c40.jpg) +“A painting of a squirrel cat eating a burger.” + +![](images/b8eb17c875a7cd7a241de1a6952b012b641da4f0054bf14861c91e58323a5b16.jpg) +“A bench with many books magazines on top.” + +![](images/aa18b837f7d29cbe0e08ab938e84b308849dd976f39fd1f15dcf100886276060.jpg) +“Banknote portrait of a mouse horse.” + +![](images/3c1be40db1411e6d7b245afd1fdc58ade53e316f252575cf19e3e2ab6e19b160.jpg) + +“A car is driving on the beach road.” + +![](images/f578011fb88d217d10b573f343d16c1cffcfd73eacf93b46e27ebcc4c8c3fd98.jpg) +“A chair in the bed living room.” + +![](images/0d2f318a6372effbf9709d804a39b970f89b9cd4729117cc1bbe21f4344ae562.jpg) + +“A deflated inflated tire on the ground.” + +![](images/c849c075696e9d6aa677ebfc5cef48b76d2423aedaf0f27ee6ad93cb904cd0b6.jpg) +“A fashion BW sketch of an evening dress of an evening dress.” + +![](images/de6ad14a713a4ce3cc772f5a3496d279590b265f2418baf33a96973b97b8a903.jpg) + +“A huge translucent mushroom avocado in the middle of the forest. Afternoon light.” + +![](images/d9a837231df413d3b820b40aaba3c756cbc26b2a215c4e875837bb4693a04ee1.jpg) +“A kangaroo deer in a pub eating sushi. DSLR.” + +![](images/cd6e77bb5ea3b77d9381ddb46ef88bf6357750d7224bc47cf98d39ed876db719.jpg) +“A pepperoni mushroom pizza on a table.” + +![](images/db61ee1d9fc5b07e9b423cc95eda6f92d05f50ee12c64de80fd71852c5cb3c95.jpg) + +![](images/855220727e98240cfa994b71bfcb3295e00044d9009616b8ae093d860c7154ca.jpg) + +“A stove over a pile of diverse random house sports objects. Low lighting image.” + +“An evil robot holding a sword broom.” + +![](images/26d7e66782faa8adf20eab9f6aa214cb7b53ddf685ebe815a95b965529781a13.jpg) +“An origami bottle cup.” + +![](images/d3e7b977043ecdebb407281ed5925af1c71624d64d001fea90f2a000fa20f2a5.jpg) +“A vase filed with cotton tennis balls.” + +![](images/968b1fc94b926f917b55d2693b6589257ced71844d883e3472b404501cd1d5e0.jpg) +“A photo of a cat playing chess domino .” + +![](images/bb1ccc59692fb1934f6899cf2f4ad2ad37b6d9d4cb98a8493304a3719e0d0c94.jpg) +“Photo of a dog cat in the street.” + +![](images/7ad12530b226c8b914788cb875277e897741a7ad3dc20f9de98a600e9f63c77d.jpg) +“A piano made out of Lego cubes.” + +![](images/cb77b9ee39f9fda22d09dc711771c44eae4cc005710afaa8d24f9f1a5b466743.jpg) +“A painting of a squirrel eating a burger pizza.” , + +![](images/662d60037e54a64d4cea0d3b87cc03cc408f7dd690063c0701dcc1ee3a420273.jpg) + +“A beautiful bouquet of tulips daisies.” + +![](images/2e4be728f25124060775eb9a1a1e34ce808979733843a50647c49b7a0ac1e03f.jpg) +“An apple orange on a table.” + +![](images/1860a787bc3078038a925a9eafbfc66044f996766230a86ad02334ec7a16b18c.jpg) +“Image of candies mints inside a box.” +Figure 28: Additional results for Prompt-to-Prompt editing by word swap using the Stable Diffusion Model . + +![](images/0a041bb19649a2e30c9a3933bb530bcf491805cb1d7217ca72b52722367ebd07.jpg) +“A beautiful bouquet of tulips of the colour red and yellow.” + +![](images/64b38c2ab640cbf3336f56d728a9eb902ad0cc97d2b580fb4f719474e3119855.jpg) +“A big yellow apple on a table” + +![](images/a7417ca9978619cbeacf2050df8613ff9fd061b491e2329308d0fd3fe7557ceb.jpg) +“A wooden bike in the yard.” + +![](images/cc23760f853adcdb3ace5dabbc6ec994464f648282be87aba5b9d40a13e200c9.jpg) +“A bridge made of rope between two cliffs.” + +![](images/e29e8286ae201cd77ba838e8b49c74ceb8d55a3fa4a60c196391d6cb893aad6f.jpg) +“A dangerous bridge missing its steps between two cliffs.” + +![](images/8eebaebfab04439b6668f8817c6916b20c41276f433549a852af7287a4058f64.jpg) +“A speeding race car is driving on the beach.” + +![](images/164350de1a09703e2fd940a8a1f6105a717faee9eb42a1b6642733eb7ec5b087.jpg) +“A fashion sketch of an evening dress with long sleeves.” + +![](images/1ff0905d95b388a0f5edad64c548877eb7d9ba70ce4acca7c48bc844cef01828.jpg) +“A painting of a squirrel jumping over a metal fence with spikes.” + +![](images/4453385716b51185a9aa9da3ed8e064f02fa966a522055c7ed497d51bd8c3819.jpg) + +“A huge translucent mushroom in the middle of the forest. Afternoon light.” + +![](images/5c1fdabedb974b32d09e8f67473950a6d241e8e78f48274065c18b164c61ae36.jpg) +“A painting of lilies in the style of Van Gogh.” + +![](images/72098a0028e8ae939a61310ad9f39c3b3841fd3a05561c085d3ccc96ddf07b01.jpg) +“A pepperoni pizza with mushroom and olive toppings on a table” + +![](images/3e4e1ae2f94c978f707c5b59e50cdf8b44f606107a7bad49ea739d46157e352a.jpg) +“A banknote portrait of a mouse.” + +![](images/50a9e25f3be63521c823a624669076fcf4d12538a80867f7d928e31f4829d631.jpg) +“A small clay bunny with a big smile.” + +![](images/15fe8098433f5211675b060372788b2c3b9fec2b604001ac3ca4fa8d0c5b03cc.jpg) +“A recliner sofa in the living room” + +![](images/2e404c084ee7e4a46a0a7238d05f42181e3689f1bcd2e9912d380e115e4ba3b6.jpg) +“A deflated and ripped up tire on the ground.” + +![](images/611123441d9d67efcf806eff9ca5809a0c9e4d47e554a04ef6e8b6fd8ba08c60.jpg) +“A vase filled with cotton and metal balls.” + +![](images/210b6e16cd6ac26016870837e9bf8532c42976f3f6c8c68620fabffc599e4682.jpg) +“A stove outside creating a smoke cloud above.” + +![](images/bb7fba0d80763b6271265801c9d16740ae23ce073f58252039a8e48b7d63d249.jpg) +“A TV screen with many burnt pixels.” + +![](images/6845425ec2f4c276060ad699b7f4014a79124dbf5d1f2044d5679b23ee140ecd.jpg) + +“An image of soup with alphabet soup crackers in English and Russian. + +![](images/83bcaddffed29cabf2be024c0651be7a2ae831bea19cebd3721ac06704091c14.jpg) +“Eyeglasses on the desk reflecting a strong glare.” + +![](images/98e1addd18587efec632c60f243dc52e29d29b5506a4bcd9f290a7d884ff6547.jpg) +“Image of candies covered with chocolate inside a box.” + +Figure 29: Additional results for Prompt-to-Prompt editing by adding a specification using the Stable Diffusion Model. + +![](images/41b81e16a773060102ec26d0afc647cb63fa4a6809f4c8de2324c7bf5396574d.jpg) + +"A photo of a blossom ( ) tree." + +![](images/7a19e6bbf48b4cbf8413416b1e81b2feec4e43b9c42b73af8eb9c6e0fe7deee8.jpg) +“A landscape with a snowy ( ) mountain.” + +![](images/34ca07bc654a67ce0c3a546b28f2055856a557bcfaec286725c72392d72b49ac.jpg) + +“A photo of the ancient ( ) city.” + +![](images/130cc77105ba97ad15e008a3a716c8c50d5fec58ff5471a2fcebc392fddcf8dc.jpg) +“A crahsed ( ) car.” + +![](images/5ddcea0a932859862d02969e915bdd874a8400b7877f59a19c4ade0258771993.jpg) + +“A smiling( ) teddy bear.” + +![](images/c6fbf7b7c93dc1968ec3d401cd6097a6fe2aa267346ac2799bbc7dbe124c071a.jpg) +Figure 30: Additional results for Prompt-to-Prompt editing by attention re-weighting using the Stable Diffusion Model. + +“A photo of a poppy field at night ( ).” + +![](images/dd6383bbc42d653fd0626802134a5fbf4a6c2ea328e1a19e87b809f9affaaf5a.jpg) +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. \ No newline at end of file diff --git a/md/dev/_h2FKc6E_YV/_h2FKc6E_YV.md b/md/dev/_h2FKc6E_YV/_h2FKc6E_YV.md new file mode 100644 index 0000000000000000000000000000000000000000..d8a6d8925d4fae4d809a3904d303891876575204 --- /dev/null +++ b/md/dev/_h2FKc6E_YV/_h2FKc6E_YV.md @@ -0,0 +1,279 @@ +# Rethinking and Scaling Up Graph Contrastive Learning: An Extremely Efficient Approach with Group Discrimination + +Yizhen Zheng1, Shirui $\mathbf { P a n } ^ { 2 }$ ∗, Vincent CS Lee1, Yu Zheng3, Phillip S. $\mathbf { V } \mathbf { u } ^ { 4 }$ , +1Monash University, 2Griffith University, 3La Trobe University, 4 University of Illinons at Chicago +yizhen.zheng1@monash.edu, s.pan@griffth.edu.au, vincent.cs.lee@monash.edu yu.zheng@latrobe.edu.au, psyu@uic.edu + +# Abstract + +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. + +# 1 Introduction + +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]. + +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. + +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], + +![](images/95495bd797059e0d73a939f5afdde8d9b4ab6a0077dd735aea28b14bb0b91a6a.jpg) +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. + +GBT [14] borrows the idea of redundancy-reduction principle and utilises a cross-correlation-based loss to build contrastiveness between embedding dimensions. + +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 + +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. + +
MethodPreTrEpoTotal(E) Imp(E)Total(T)Imp(T)Acc
GBT(256)5.526.473001,946.52-1,941.00=70.1
GGD(256)6.26 0.1816.44302.25×0.1810,783.33x70.3
GGD(1,500)6.260.9517.21269.96×0.952.043.16×71.6
+ +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. + +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. + +# 2 Rethinking Representative GCL Methods + +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. + +# 2.1 Rethinking GCL Methods + +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). + +![](images/e005a7bfab03de24a46df553ee290e45d447140dd4a7b74c7ad6162d90db0cd4.jpg) +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. + +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. + +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 + +Table 2: Summary vector statistics on three datasets with different activation functions including ReLU, LeakyReLU (i.e., LReLU shown below), PReLU, and Sigmoid. + +
ActivationStatisticsCoraCiteSeerPubMed
ReLU/LReLU/PReLUMean0.500.500.50
Std1.3e-031.0e-044.0e-04
Range1.4e-038.0e-041.5e-03
SigmoidMean0.620.620.62
Std5.4e-052.9e-056.6e-05
Range3.6e-033.0e-033.2e-03
+ +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). + +To theoretically explain this phenomenon, we present the proposition below: + +Table 3: The experiment result on three datasets with changing value from 0 to 1.0 for the summary vector. + +
Dataset00.20.40.60.81.0
Cora70.3±0.7 82.4±0.2 82.3±0.3 82.5±0.4 82.3±0.3 82.5±0.1
CiteSeer61.8±0.8 71.7±0.6 71.9±0.7 71.6±0.9 71.7±1.0 71.6±0.8
PubMed68.3±1.5 77.8±0.5 77.9±0.8 77.7±0.9 77.4±1.1 77.2±0.9
+ +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. + +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. + +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. + +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? + +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: + +$$ +\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} +$$ + +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: + +$$ +\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} +$$ + +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. + +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. + +
ExperimentMethodCoraCiteSeerPubMed
AccuracyDGI81.7±0.671.5±0.777.3±0.6
DGIBCE82.5±0.371.7±0.677.7±0.5
MemoryDGI4189MB8199MB11471MB
DGIBCE1475MBl64.8%1587MBl80.6%1629MBl85.8%
TimeDGI0.085s0.134s0.158s
DGIBCE0.010sl8.5×0.021sl6.4×0.015sl10.5×
+ +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: + +$$ +\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 } ) ) , +$$ + +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. + +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. + +# 2.2 Definition of Group Discrimination + +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. + +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. + +# 3 Methodology + +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. + +![](images/35924d1789fec858cdd0bc17c036fbafa43902aba9cf673742249a05da6a4c9a.jpg) + +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. + +# 3.1 Graph Group Discrimination + +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. + +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. + +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. + +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. + +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. + +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. + +# 3.2 Model Inference + +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. + +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: + +$$ +\begin{array} { r } { \mathbf { H } _ { \theta } ^ { g l o b a l } = \mathbf { A } ^ { n } \mathbf { H } _ { \theta } , } \end{array} +$$ + +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. + +# 4 Related Work + +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. + +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. + +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. + +# 5 Experiments + +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 + +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. + +
DataMethodCoraCiteSeer PubMedCompPhoto
X,A,YGCN81.570.379.076.3±0.5 87.3±1.0
X,A,YGAT83.0±0.7 72.5±0.7 79.0±0.3 79.3±1.1 86.2±1.5
X,A,YSGC81.0±0.0 71.9±0.1 78.9±0.0 74.4±0.1 86.4±0.0
X,A,YCG383.4±0.7 73.6±0.8 80.2±0.8 79.9±0.6 89.4±0.5
X,ADGI81.7±0.6 71.5±0.7 77.3±0.6 75.9±0.6 83.1±0.5
X,AGMI82.7±0.2 73.0±0.3 80.1±0.2 76.8±0.1 85.1±0.1
X,AMVGRL82.9±0.7 72.6±0.7 79.4±0.3 79.0±0.6 87.3±0.3
X,AGRACE80.0±0.4 71.7±0.6 79.5±1.1 71.8±0.4 81.8±1.0
X,AGraphCL82.5±0.2 72.8±0.3 77.5±0.2 OOM79.5±0.4
X,ABGRL80.5±1.0 71.0±1.2 79.5±0.6 89.2±0.9 91.2±0.8
X,AGBT81.0±0.5 70.8±0.2 79.0±0.1 88.5±1.0 91.1±0.7
X,AGGD83.9±0.4 73.0±0.6 81.3±0.8 90.1±0.9 92.5±0.6
+ +ensure reproducibility, the detailed experiment settings and computing infrastructure are summarised in Appendix A.8. The source code is already open sourced2. + +# 5.1 Evaluating on Small- and Medium-scale Datasets + +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 + +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. + +
MethodCoraCiteSeerPubMedCompPhoto
DGI0.0850.1340.1580.1710.059
GMI0.3940.4972.2851.2970.637
MVGRL0.1230.1710.4880.6630.468
GRACE0.0560.0920.8930.5460.203
GraphCL0.0730.0850.123OOM0.188
BGRL0.0850.0940.1470.3370.273
GBT0.0730.0720.1030.4920.173
GGD0.0100.0210.0150.0160.009
Improve7.3-39.4×3.4-23.7×6.9-152.3×10.7-15.3×19.2-70.8x
+ +classification accuracy with five results along with standard deviations and reported in Table 5. + +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]. + +# Efficiency and Memory Consumption. GGD is + +Table 7: Comparison of memory consumption in MBs of six GCL baselines and GGD on five datasets. + +
MethodCoraCiteSeerPubMedCompPhoto
DGI4,1898,19911,4717,9914.946
GMI4,5275,46714.69710.6555,219
MVGRL5,3815,4296.6196.6456.645
GRACE1,9132.04312.5978,1294,881
GraphCL4,1638,24911,555OOM9.083
BGRL1,6271,7492.2995.0693.303
GBT1,6511,7992,4615.0372.641
GGD1,4751,5871,6291,7871,637
Improve10.7-72.6%11.8-80.6%27.2-85.8%64.5-83.2%38.0-75.4%
+ +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. + +# 5.2 Evaluating on Large-scale datasets + +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. + +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 + +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. + +
MethodValidMemoryTimeTotal
Supervised GCN73.0±0.2 71.7±0.3=
MLP57.7±0.4 55.5±0.2
Node2vec71.3±0.1 70.1±0.1
DGI71.3±0.1 70.3±0.2
GRACE(10k epos)72.6±0.2 71.5±0.1
BGRL(10k epos)72.5±0.1 71.6±0.1OOM (Full-graph)//
GBT(300 epos)71.0±0.1 70.1±0.214.959MB6.47 1,941.00
GGD(1 epo\1500)72.7±0.3 71.6±0.514.666MB0.95 0.9512.043×
GGD(1 epo\256)71.0±0.2 70.3±0.34,513MBl69.8%0.18 0.18|10,783×
+ +ogbn-arxiv in full batch. Thus, we only compare GGD and GBT in this dataset, which can successfully train in full-graph processing mode. + +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 + +Table 9: Node classification result and efficiency comparison on ogbn-products. + +
MethodValidTestMemoryTimeTotal
Supervised GCN92.0±0.075.6±0.2--
MLP75.5±0.061.1±0.0
Node2vec70.0±0.068.8±0.0
BGRL(100 epos)78.1±2.164.0±1.629,303MB53m16s 5.326m40s
GBT(100 epos)85.0±0.170.5±0.420.419MB48m38s 4.863m20s
GGD(1 epo)90.9±0.575.7±0.44,391MBl78.5%12m46s 12m46sl381x
+ +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. + +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 + +![](images/369404741420a9881e06aace9ef0fa35449dda32773f5aba54e1e7e7eefff56b.jpg) +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. + +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. + +# 6 Explore Group Discrimination + +In this section, we explore the corruption technique in GGD and provide the theoretical analysis of group discrimination. + +# 6.1 Exploring Corruption + +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. + +Table 10: Node classification result and efficiency comparison on ogbn-papers100M. + +
MethodValidationTestMemoryTime
Supervised SGC63.3±0.266.5±0.2|--
MLP47.2±0.349.6±0.3·=
Node2vec55.6±0.058.1±0.0--
BGRL (1 epoch)59.3±0.562.1±0.314,057MB26h28m
GBT(1 epoch)58.9±0.461.5±0.513,185MB24h38m
GGD(1 epoch)60.2±0.363.5±0.54,105MBl68.9% 9h15ml2.7×
+ +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. + +# 6.1.1 Theoretical Analysis of Group Discrimination + +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. + +![](images/3734132db1045b5ec7bbf7c9dacdc5503ab585b756c7fe339d5873634c35c1d5.jpg) +Figure 5: Corruption technique in DGI and MVGRL. + +Theorem 1 Given a graph G, a corrupted +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 }$ . + +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. + +# 7 Future Work + +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 + +![](images/3dcd4dfa5eb1418c564634e60ad5c8f101c15fec5f400327bbc709da259065ba.jpg) +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 }$ . + +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. + +# Acknowledgments and Disclosure of Funding + +This research was partially supported by an Australian Research Council (ARC) Future Fellowship (FT210100097). + +This work is supported in part by NSF under grants III-1763325, III-1909323, III-2106758, and SaTC-1930941. + +# References + +[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. +[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. +[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. +[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. +[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. +[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. +[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. +[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. +[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. +[10] Petar Velickovi ˇ c, William Fedus, William L Hamilton, Pietro Liò, Yoshua Bengio, and R Devon Hjelm. ´ Deep graph infomax. ICLR, 2019. +[11] Kaveh Hassani and Amir Hosein Khasahmadi. Contrastive multi-view representation learning on graphs. In ICML, pages 4116–4126. PMLR, 2020. +[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. +[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. +[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. +[15] Shantanu Thakoor, Corentin Tallec, Mohammad Gheshlaghi Azar, Rémi Munos, Petar Velickovi ˇ c, and ´ Michal Valko. Bootstrapped representation learning on graphs. ICLR2021, 2021. +[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. +[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. +[18] Yuning You, Tianlong Chen, Yongduo Sui, Ting Chen, Zhangyang Wang, and Yang Shen. Graph contrastive learning with augmentations. NIPS, 33:5812–5823, 2020. +[19] Thomas N Kipf and Max Welling. Semi-supervised classification with graph convolutional networks. ICLR, 2017. +[20] Petar Velickovi ˇ c, Guillem Cucurull, Arantxa Casanova, Adriana Romero, Pietro Lio, and Yoshua Bengio. ´ Graph attention networks. ICLR, 2018. +[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. +[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. +[23] William L Hamilton, Rex Ying, and Jure Leskovec. Inductive representation learning on large graphs. In NIPS, pages 1025–1035, 2017. +[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. +[25] Johannes Klicpera, Aleksandar Bojchevski, and Stephan Günnemann. Predict then propagate: Graph neural networks meet personalized pagerank. ICLR, 2019. +[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. +[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. +[28] Oleksandr Shchur, Maximilian Mumme, Aleksandar Bojchevski, and Stephan Günnemann. Pitfalls of graph neural network evaluation. arXiv preprint arXiv:1811.05868, 2018. +[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. +[30] Sheng Wan, Shirui Pan, Jian Yang, and Chen Gong. Contrastive and generative graph convolutional networks for graph-based semi-supervised learning. AAAI, 2020. +[31] Zhilin Yang, William Cohen, and Ruslan Salakhudinov. Revisiting semi-supervised learning with graph embeddings. In ICML, pages 40–48. PMLR, 2016. +[32] Aditya Grover and Jure Leskovec. node2vec: Scalable feature learning for networks. In KDD, pages 855–864, 2016. +[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. +[34] Jean Daunizeau. Semi-analytical approximations to statistical moments of sigmoid and softmax mappings of normal variables. arXiv preprint arXiv:1703.00091, 2017. +[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. \ No newline at end of file diff --git a/md/dev/_nGgzQjzaRy/_nGgzQjzaRy.md b/md/dev/_nGgzQjzaRy/_nGgzQjzaRy.md new file mode 100644 index 0000000000000000000000000000000000000000..462e6faa909b5adeadb778a7f5afdf9ef872f0a2 --- /dev/null +++ b/md/dev/_nGgzQjzaRy/_nGgzQjzaRy.md @@ -0,0 +1,2404 @@ +# Decomposed Prompting: A MODULAR APPROACH FOR SOLVING COMPLEX TASKS + +Tushar Khot♣, Harsh Trivedi♡, Matthew Finlayson♣, Yao Fu♠∗, +Kyle Richardson♣, Peter Clark♣, Ashish Sabharwal♣ +♣Allen Institute for AI ♡Stony Brook University ♠University of Edinburgh +tushark $@$ allenai.org, hjtrivedi $@$ cs.stonybrook.edu, matthewf $@$ allenai.org, yao.fu@ed.ac.uk, +kyler $@$ allenai.org, peterc $@$ allenai.org, ashishs $@$ allenai.org + +# ABSTRACT + +Few-shot prompting is a surprisingly powerful way to use Large Language Models (LLMs) to solve various tasks. However, this approach struggles as the task complexity increases or when the individual reasoning steps of the task themselves are hard to learn, especially when embedded in more complex tasks. To address this, we propose Decomposed Prompting, a new approach to solve complex tasks by decomposing them (via prompting) into simpler sub-tasks that can be delegated to a shared library of prompting-based LLMs dedicated to these sub-tasks. This modular structure allows each prompt to be optimized for its specific sub-task, further decomposed if necessary, and even easily replaced with more effective prompts, trained models, or symbolic functions if desired. + +We show that the flexibility and modularity of Decomposed Prompting allows it to outperform prior work on few-shot prompting using GPT-3. On symbolic reasoning tasks, we can further decompose sub-tasks that are hard for LLMs into even simpler solvable sub-tasks. When the complexity comes from the input length, we can recursively decompose the task into the same task but with smaller inputs. We also evaluate our approach on textual multi-step reasoning tasks: on long-context multi-hop QA, we can more effectively teach the sub-tasks via our separate sub-tasks prompts; and on open-domain multi-hop QA, we can easily incorporate a symbolic information retrieval module within our decomposition framework, leading to improved performance on both tasks.1 + +# 1 INTRODUCTION + +Large Language Models (LLMs) such as GPT-3 (Brown et al., 2020) have been shown to solve various tasks given only a few examples as prompts, also referred to as in-context learning. These models can even perform more complex reasoning tasks when shown the sequence of simple reasoning steps needed to perform the complex task as a prompt (Wei et al., 2022; Nye et al., 2021). In essence, the sequence of reasoning steps, such as in Chains-of-Thought (CoT) prompting (Wei et al., 2022), demonstrates how to decompose the complex task as well as how each reasoning step should be performed. However, as tasks become more complex, few demonstrations of the complex task aren’t sufficient for current models to learn to perform all necessary reasoning steps. E.g., fewshot demonstrations of concatenating the $k ^ { \mathrm { t h } }$ letter of words in a string is insufficient for GPT-3 to learn to extract the $k ^ { \mathrm { t h } }$ letter, or learn to answer hard single-hop questions when only provided a few demonstrations of multi-hop questions. Additionally, it is unclear whether tasks such as document retrieval and integration, for knowledge-intensive tasks, can even be done by few-shot prompts. + +To address these limitations, we propose Decomposed Prompting (DECOMP), a new approach to solve complex tasks by instead decomposing them into simpler sub-tasks and delegating these to sub-task specific LLMs, with both the decomposer and the sub-task LLMs (henceforth, sub-task handlers) having their own few-shot prompts. Fig 1 illustrates our approach. The decomposer prompt only describes a sequence of sub-tasks (A, B, and C) needed to solve the complex tasks, indicated with the dashed lines. Each sub-task is then delegated to the corresponding sub-task handler shown on the right. + +![](images/f8f5e081b973cf99396288c2b8c140b4717fba11c19e28836f1079115ec1b6b8.jpg) +Figure 1: While standard approaches only provide labeled examples (shown as a grey input box with green label box), Chain-of-Thought prompting also describes the reasoning steps to arrive at the answer for every example in the prompt. Decomposed Prompting, on the other hand, uses the decomposer prompt to only describe the procedure to solve the complex tasks using certain subtasks. Each sub-task, indicated here with A, B and C is handled by sub-task specific handlers which can vary from a standard prompt (sub-task A), a further decomposed prompt (sub-task B) or a symbolic function such as retrieval (sub-task C) + +Using a software engineering analogy, the decomposer defines the top-level program for the complex task using interfaces to simpler, sub-task functions. The sub-task handlers serve as modular, debuggable, and upgradable implementations of these simpler functions, akin to a software library. If a particular sub-task handler, say the one for identifying the $k ^ { \mathrm { t h } }$ letter or retrieving a document, is not performing well enough, we can debug this handler in isolation, explore alternative prompts or implementations, and seamlessly plug the improved module back into the overall system, as a systematic way to try to improve performance on the complex end-task. + +This approach has several advantages over prior work (as also shown in the figure). The sub-task handlers can be shown a broader and richer set of examples (of the simpler task) than the specific ones needed for the complex task prompt (task A). If a sub-task is too complex, it can be further decomposed into simpler sub-tasks (task B). Similar to software libraries, these sub-task handlers can be shared across multiple tasks; e.g., here tasks A and C are reused in the model for task B. As noted above, a sub-task handler can be easily swapped with an improved implementation without any change to the rest of the system. Few-shot prompt based LLMs can be even replaced with a symbolic system for tasks more suited for non-neural methods; e.g., task C uses a symbolic retrieval system such as Elasticsearch that can handle very large-scale corpora. Lastly, we can even improve upon prior work by simply adding an error-correcting sub-task handler as a post-processing step. + +To illustrate these advantages of DECOMP, we empirically evaluate it against prior work on eight challenging datasets using GPT3 models: (1) On a task of concatenating the $k ^ { \mathrm { t h } }$ letter, we show that our approach of factoring out each sub-task allows us to more effectively teach the sub-problem of extracting the $k ^ { \mathrm { t h } }$ letter(specifically, by decomposing it into even easier sub-tasks). (2) On a task of reversing a list, we show that DECOMP allows us to extend the capabilities of a weaker model and build a scale-invariant system by recursively decomposing the task into reversal of smaller and smaller lists. (3) On a task of long-context QA (Khot et al., 2022), our approach allows each subtask handler to accommodate more examples than feasible with CoT prompting leading to better QA performance. (4) On three multi-hop open-domain QA datasets (Yang et al., 2018; Ho et al., 2020; Trivedi et al., 2022), we can incorporate a symbolic retrieval (ElasticSearch) API as the handler for the retrieval sub-task leading to better results than CoT. (5) On two Math QA datasets (Cobbe et al., 2021; Roy & Roth, 2015), we can post-process CoT to easily fix frequent formatting errors, resulting in a surprisingly high improvement of 14-17 pts. + +# 2 RELATED WORK + +Few-shot Prompts for Multi-Step Reasoning Large-scale Language models (LLMs) have been shown to learn various NLP tasks given just few examples as prompts (Brown et al., 2020). Recently, they have also been successfully applied to various multi-step reasoning tasks by providing the intermediate reasoning steps, i.e. Chain-of-Thought (Wei et al., 2022; Chowdhery et al., 2022), needed to arrive at the answer. An alternate approach has been to compose multiple LLMs or LLMs with symbolic functions to perform multi-step reasoning (Jung et al., 2022; Creswell et al., 2023; + +Press et al., 2022; Parisi et al., 2022; Gao et al., 2022; Schick et al., 2023, inter alia). We view these prior works as specialized systems with a pre-defined decomposition structure. + +The closest works to our approach are the ideas of least-to-most prompting (Zhou et al., 2023) and successive prompting (Dua et al., 2022) where one prompt/model is used to generate the subquestions needed to answer a complex question and a second prompt/model sequentially answers these sub-questions. In contrast, our approach allows for diverse decomposition structures including recursion and other non-linear decomposition structures. E.g., by definition, least-to-most asks questions from easiest to the hardest and requires an LLM to eventually answer the complete question (“most” in least-to-most) whereas we have no such restriction. Additionally, we iteratively generate new questions based on previous answers (similar to successive prompting) and can explicitly assign different prompts or symbolic systems to answer each sub-question. + +Modular Approaches for Multi-Step Reasoning Our work follows a long literature in NLP on neural modular modeling architectures (Andreas et al., 2016; Talmor & Berant, 2018; Min et al., 2019; Jiang & Bansal, 2019; Gupta et al., 2020; Perez et al., 2020; Khot et al., 2021; Levine et al., 2022) for question-answering and other tasks. We take particular inspiration from the Text Modular Networks approach of Khot et al. (2021), whereby problem decomposition consists of a learned next question generator trained to generate questions in the language of a collection of textual and symbolic agents. Best-first search strategy was used to explore the space of possible decompositions during inference. In contrast to this work, which largely centered around supervised training of the next-question generator given existing agents, we leverage the power and recent successes of fewshot LLMs to build both the decomposer and the sub-task agents that best fit the ideal decomposition. This has the advantage of obviating the need for specialized supervised training data that may not always be available for all sub-tasks – a key bottleneck of this prior work. + +# 3 DECOMPOSED PROMPTING + +As with conventional few-shot prompting, the goal is to teach an LLM to find an answer $A$ to a query $Q$ using a small set of in-context examples $\boldsymbol { D } = \{ E _ { 1 } , . . . , E _ { | D | } \}$ . The answer $A$ is obtained from the underlying distribution $p ( A \mid Q , D , \theta )$ (Dohan et al., 2022). In the most basic few-shot setup, examples take the form $E _ { j } = ( Q _ { j } , A _ { j } )$ . In the case of CoT-style prompting, the goal is to obtain answers by first generating a sequence or chain of intermediate reasoning steps or “thoughts” $T$ , and then deriving the final answer based on $T$ . To teach this ability, one uses more sophisticated in-context examples that take the form $E _ { j } = ( Q _ { j } , ( T _ { j , 1 } , \dots , T _ { j , k } ) , A _ { j } )$ . + +In DECOMP, the core is a decomposer LLM that tries to solve a complex task by generating a prompting program $P$ for it. Each step of $P$ directs a simpler sub-query to a function in an auxiliary set of sub-task functions $\mathcal { F }$ available to the system. Given a query $Q$ whose answer is $A$ , the program $P$ is a sequence of the form $\big ( ( f _ { 1 } , Q _ { 1 } , \dot { A _ { 1 } } ) , . . . , ( f _ { k } , Q _ { k } , \dot { A _ { k } } ) \big )$ where $A _ { k }$ is the final answer predicted by $P$ and $Q _ { i }$ is a sub-query directed to the sub-task function $f _ { i } \in \mathcal { F }$ . $P$ is executed by a high-level imperative controller, which passes the inputs and outputs between the decomposer and sub-task handler until a stopping condition in $P$ is met and the final output obtained. + +To teach the decomposer LLM in a few-shot prompting manner, we use in-context examples that take the form $E _ { j } = \left. ( Q _ { j } , ( f _ { j , 1 } , Q _ { j , 1 } , A _ { j , 1 } ) , . . . , ( f _ { j , k _ { j } } , \bar { Q _ { j , k _ { j } } } , A _ { j , k _ { j } } ) ) \right.$  where $A _ { j , k _ { j } } = A _ { j }$ is the final answer for $Q _ { j }$ and $( Q _ { j , 1 } , \ldots , Q _ { j , k _ { j } } )$ is a decomposition of $Q _ { j }$ . Each sub-task function $f$ , in turn, is operationalized via a sub-task handler as an in-context prompting LLM (e.g., a separate CoT-style prompt or a additional prompting program dedicated to that sub-task), or any other symbolic or learned function (e.g., a calculator or specialized supervised trained model). + +# 3.1 DECOMPOSED PROMPTS + +To illustrate this with an example, consider a multi-step task such as “Concatenate the first letter of every word in str using a space”. We can solve this task by decomposing it into a sequence of three simple sub-tasks: 1) Collect the list of words in the str; 2) For each word, extract the third letter; 3) Concatenate the extracted letters using space as the separator. Fig. 2 shows an example decomposition prompt for this task. Much like a conventional structured program, the top-level decomp prompt provides an example program $E _ { j }$ using three sub-task functions: $f _ { 1 }$ :split that splits words in an input string, $f _ { 2 }$ :str pos that finds character positions in strings and $f _ { 3 }$ :merge that concatenates characters. In this case, we operationalize each sub-task function as a separate in-context prompt (e.g., using a standard prompting approach for split and merge on the right side), each containing a set of in-context examples that are independent of the original complex task. + +![](images/08ffc19209ed844f13ea83a09c8fb32366eb67208d17b1255c96e5779fecf1e4.jpg) +Figure 2: Prompts for the decomposer and the split and merge sub-tasks used by the decomposer. The decomposer specifies the sequence of questions and corresponding sub-tasks (within square braces). The sub-task prompts can be written independent of the complex task examples and can even capture generalizations, e.g., letters in word (split) and no delimiter (merge). + +In addition to the three functions described above, additional control structure is included, such as the symbolic function foreach, which iterates over arrays and references to previous answers such as #1. We note that such a helper function is not strictly necessary (e.g., we could directly generate “Q2’: What is the first letter of Jack?” and $" \mathrm { Q } 3 ^ { \bullet }$ : What is the first letter of Ryan?” instead of Q2 in the figure) and is added to reduce the manual effort needed to specify the decomposition and also reduce potential errors during decomposition. In our experiments we use two of the compositional operators defined by Khot et al. (2022) (see appendix for details), although it is capable of using all their operators (which also capture the QDMR operators from Wolfson et al. (2020)). + +![](images/c34a9140c553612ff75691ece7a456b9d6a7566baa9186fe6af685de23e471f8.jpg) +Figure 3: The inference procedure in DECOMP iteratively calls the decomposer prompt to generate the next question and sub-task at each step, given the current history of question and answers. The generated question is then routed to the assigned sub-task handler (with some handling of special operators, when needed). When the special end-of-questions [EOQ] marker is generated, the previous answer is returned as the final prediction. + +# 3.2 PROMPT EXECUTION AND INFERENCE + +Given a new question and a set of background in-context examples $D$ , the inference (i.e., the program construction and execution) process is illustrated in Fig. 3. The new complex question is fed to the decomposer prompt to get the first sub-question to be asked to the split prompt. With the help of our symbolic controller, the answer generated from this prompt is then appended to the decomposer prompt to get the second sub-question, $Q 2$ . Due to the foreach operator in the generated question, $Q 2$ results in two questions (one for each word in $\# 1$ ) to be fed to the str pos prompt. The answers are combined into an array to get the answer $\# 2$ . The entire decomposition history is used to generate $Q 3$ and passed to the merge prompt to get the final answer. Since the task has been solved, the decomposition prompt produces the special end-of-sequence marker([EOQ]) and the last answer is returned as the final answer. Formally, performing inference involves finding the best answer $A$ to a new query $Q$ , which in the simplest form involves computing the MAP answer using the + +LLMs predictive distribution for $A$ , i.e., ${ \hat { A } } = \arg \operatorname* { m a x } _ { A } p ( A \mid D , Q , \theta )$ (Dohan et al., 2022). For practicality, such computations are approximated using greedy search in our experiments. + +# 3.3 DECOMP CAPABILITIES + +Hierarchical Decomposition Certain sub-tasks, even when given many examples, are not solvable with few-shot prompting. E.g., we found identifying the $\bar { k ^ { \mathrm { { t h } } } }$ letter of a string to be challenging for the GPT3 text-davinci-002 model. In such a scenario, we can decompose the sub-task prompt further, to first identify the letters and their position and then select the $k ^ { \mathrm { { \bar { t h } } } }$ element of this array (see Fig. 4). We can also re-use existing sub-task prompts in our framework. E.g., the split prompt can be reused since it was developed for the general task of splitting strings.2 + +![](images/d16ac6f18670b03a4ebe3789598412246f25c6efae9cf96b2c0469e7d532203f.jpg) +Figure 4: Since identifying the $k ^ { t h }$ character is challenging for GPT3 davinci-002 model, we further decompose it into two simpler sub-tasks: split the word into its letters (using the shared subtask split) and then return the $\hat { k } ^ { t h }$ item of this list using the arr pos prompt. + +Recursive Decomposition Some problems can be naturally broken down into one or more smaller problems of the same form. Recursive algorithms such as merge sort use this idea to solve large problems efficiently, using a succinctly described method. We apply this same principle in DECOMP by allowing the decomposer prompt to recursively call itself, as shown in Fig. 5 for the task of list reversal. By using recursion, we are able to generalize any base prompting approach (CoT in this figure) to much longer lists by breaking the input into smaller and smaller lists till we reach a list length where the model is highly accurate. Such recursive approaches can not be described by current methods such as CoT and standard prompting. Least-to-most prompting (Zhou et al., 2023) also proposes a similar solution but differs in two key aspects (a) it has to identify all the subproblems in one-shot instead of our iterative top-down decomposition (b) it has to learn to identify the relevant answers from the previous solutions which we get for free from our decomposition. + +![](images/cbabab91136bb2dc45e57dffbf1e82ae3f806c690d79b91b3de1358ac1bdae7c.jpg) +Figure 5: Sample prompt for recursive decomposition for reversing lists. Each list is split into two halves and each half is reversed and concatenated in the reverse order. We can recursively split a list till we hit the base case (lists of length 3 here) where existing approaches such as CoT are accurate. + +External API Calls In certain cases, the sub-tasks may not be feasible to solve using only a LLM. E.g., retrieving knowledge from a KB or large corpus. Such sub-tasks, however, can be easily solved using existing systems such as retrieving documents using an Elasticsearch index or webpages using Google search (Lazaridou et al., 2022). Fig. 6 shows how DECOMP can easily use such a system to retrieve the relevant documents and answer a single-hop open-domain question. + +![](images/04a19aec28db07b4cd150634738c727f389473822a813909f453d5a36926288a.jpg) +Figure 6: A Decomposed Prompt to answer open-domain questions using Elasticsearch-based retrieval. Full usage of this prompt for open-domain multihop questions is given in Fig. 11. + +# 4 CASE STUDIES + +We showcase DECOMP’s strengths through four tasks; two symbolic manipulation tasks similar to those investigated by Wei et al. (2022) and two existing textual multi-hop reasoning tasks. Unless specified, we use text-davinci-002 InstructGPT3 model (Ouyang et al., 2022) as the LLM and report the Exact Match (EM) numbers, following prior work. For order-independent list answers, we evaluate set equality as EM. We compare our approach to CoT rather than each specific decomposition structure used in prior work. See App. G for the complete prompts for all our tasks. + +# 4.1 $k ^ { \mathrm { t h } }$ LETTER CONCATENATION (HIERARCHICAL DECOMPOSITION) + +We compare DECOMP to CoT prompting for concatenating letters at the $k ^ { \mathrm { t h } }$ position. All prompts contain examples of concatenating letters in position 1, 4, and last position of strings with 3 words. We create three different prompts for all our baselines and present the average to account for variance due to the choice of examples following Perez et al. (2021). We use the decomp, split, str pos (further decomposed as shown in Fig. 4), and merge prompts for decomposition prompting. We adapt the CoT for last letter concatenation from prior work (Wei et al., 2022) for this task as shown below. In addition, we consider a rolled out version of our decomposition prompts in terms of a CoT, i.e., we describe the entire decomposition process (identify words, split each word into letters, take $k ^ { \mathrm { t h } }$ letter and concatenate) as a single CoT. e.g, for the question “Take the letters at position 4 of the words in ”Herbert Alexander Simon” and concatenate them using a space.”, we use the CoT: + +# Chain-Of-Thought + +# Chain-Of-Thought (rolled out) + +The letter at position 4 of ”Herbert” is ”b”. The letter at position 4 of ”Alexander” is ”x”. The letter at position 4 of ”Simon” is ”o”. Concatenating ”b”, ”x”, ”o” using a space leads to ”b x o”. So, ”Herbert Alexander Simon” outputs ”b x o”. ... + +The words in ”Herbert Alexander Simon” are ”Herbert”, ”Alexander”, and ”Simon”. The letters and their positions in ”Herbert” are ”[(H, 1), (e, 2), (r, 3), (b, 4), (e, 5), (r, 6), (t, 7)]”. The letter at position 4 in this sequence is ”b”. · · · outputs ”b x o”. ... + +We similarly adapt the least-to-most prompt (Zhou et al., 2023) to include rollout. (see App. G). We compare these four prompting techniques on 4 datasets to evaluate generalization along 3 axes: (1) new letter position $k = 3$ ;3 (2) longer inputs, #words $^ { = 4 }$ and 5; (3) new delimiter ”;”. The words in the test examples come from a list of most popular first and last names.4 All evaluation datasets have 100 examples. We present results on space as a delimiter averaged across three prompts in Fig. 7.5 + +DECOMP outperforms chain-of-thought and least-to-most prompting, even when the prompt uses the same reasoning procedure as the rolled out decomposition. This shows that the separate prompts are more effective at teaching hard sub-tasks than a single CoT prompt. + +DECOMP generalizes perfectly to longer sequences. As the length of the input sequence increases, our approach continues to achieve close to $100 \%$ accuracy on this task.6 The CoT-based approaches drop noticeably in their scores with longer input lengths, widening the performance gap. + +![](images/0d72e11a957cacad8edb4e56c4cddde6654c71df5bfbb790ed5d1e68f2b93146.jpg) +Figure 7: EM Results on the $k ^ { t h }$ letter concatenation task $\left( \mathrm { k } \mathrm { = } 3 \right)$ using space as delimiter with different number of words in the input. DECOMP outperforms and generalizes better than CoT as well as Least-to-most prompting. + +![](images/5bb1f7df7271f9917ed9b336ead29eac56414a6c6193dd28a502e27aff858749.jpg) +Figure 8: EM results on reversing sequences. Incorporating CoT in DECOMP greatly increases the ability of the model to generalize to new sequence lengths. +Figure 9: Sample prompts used for the CommaQA dataset. On the left, the coarse-grained decomposition defines a single QA sub-task with all single-hop questions being delegated to a single sub-task handler. On the right, the fine-grained decomposition assigns questions to three different sub-tasks (see App. G for their prompts) depending on the question type. This allows us to provide more examples for each question type allowing the model to learn the sub-task more effectively. + +# 4.2 LIST REVERSAL (RECURSIVE DECOMPOSITION) + +We use the task of reversing lists of words7to show how recursive DECOMP enables length generalization. We adapt the relevant CoT prompt from Wei et al. (2022), and integrate it in a decomposed prompt. As a control, we also compare to a CoT version w/ rollout of our decomposed prompt. All prompts contain the same 3 examples of reversing word sequences with 3-5 items. We evaluate all prompts for generalization to 4, 6, 8, and 10-item sequences. Here we use davinci-001 to show that DECOMP enables a weaker model approach davinci-002’s performance (which does solve this task). We use the strategy from Fig. 5 and provide our prompts in App. G. Fig. 8 shows the results of the prompting strategies on different input lengths. + +DECOMP improves the length generalization of few-shot prompting. While our base CoT prompt does not generalize at all to longer sequences, our approach can recursively decompose the problem and achieve better length generalization. Moreover, the CoT version of our decomposition strategy fails because the unrolled prompt becomes too long and convoluted without the ability to abstract away sub-modules. + +# 4.3 LONG-CONTEXT QUESTION ANSWERING + +We next evaluate on the CommaQA-E dataset (Khot et al., 2022) under the reading comprehension setting. The dataset consists of synthetically generated entities (e.g. Erowid award), facts (“Wetherality was an actor in the movie Dewbar.”) and multi-hop questions (e.g., “What awards have the actors of the Erowid winning movies received?”). Due to the presence of many distractors and, as a result, longer context, this dataset has been shown to be hard for standard LMs even when fine-tuned. + +
What awards have movies produced by people born in 1910 won? What awards have movies produced by people born in 1910won? QS:[qa] Who were born in the year 1910? QS: [simp_qa] Who were born in the year 1910? A:["Teeplemole","Muntaril"] QS: (foreach_merge) [qa] For which movies was #1 the producer? A:["Featsaw","Zalate","Premercy"]
A:["Teeplemole","Muntaril"] QS: (foreach_merge) [pos_qa] For which movies was #1 the producer? A:["Featsaw","Zalate","Premercy"] QS: (foreach_merge)[aw_qa] Which awards were given to #2?
QS: (foreach_merge)[qa] Which awards were given to #2? A:["Zorgion","Chowwurst","Hallowcock"] A:["Zorgion","Chowwurst","Hallowcock"] QS: [EOQ] QS:[EOQ]
+ +To fit these questions within GPT3’s context limit (2049 tokens), we generate a smaller version of the CommaQA-E dataset and of the compositional generalization split such that we can fit at least four examples in the context for CoT prompts. The CoT prompts describe the sequence of facts needed to arrive at the answer (see App. G for all the prompts). + +For DECOMP, we can separate the task of decomposition (independent of the context) from the sub-tasks of single-hop question answering. As shown in Fig. 9, we provide examples of the context-independent decomposition in the decomposer prompt and use the separate sub-task prompts to teach the QA skill over the given context. Additionally, we can choose the granularity of decomposition to trade off human effort for increased accuracy. For example, we could have single QA prompt to handle all the questions or create QA prompts for different classes of questions. In our experiments, each sub-task prompt contains 8 QA examples (2 questions/para). We evaluate three different prompts and report the average results in Fig. 10. + +We make three observations on CommaQA. DECOMP is more accurate than CoT irrespective of the granularity of decomposition or the evaluation split. Finer grained decomposition can help improve task performance by providing more examples for each class of questions, which in turn increases single-hop QA accuracy. DECOMP generalizes to new compositions such as the compositional generalization split of CommaQA, which tests models on unseen compositions of relations observed in the training set. While CoT has a drop in score, both decomposition-based approaches actually get a small bump (the subset of relations used in this split are easier for our QA models). + +![](images/51de75b24ed6c90483061a4b0d9cd7d34ed29cdf854d09a04ad7da55a486c11e.jpg) +Figure 10: EM results on the CommaQA-E datasets. DECOMP always outperforms CoT, with fine-grained marginally out-performing coarse-grained decomposition. + +# 4.4 OPEN-DOMAIN QUESTION ANSWERING + +Next, we demonstrate the ability of our approach to integrate external API calls on the task of open-domain multihop question answering. We evaluate our approach on three datasets: (1) 2WikiMultihopQA (Ho et al., 2020) (2) MuSiQue (Trivedi et al., 2022) (3) HotpotQA (Yang et al., 2018). We describe the open-domain versions of these datasets in more detail in App. A We use the Codex (code-davinci-002) model here since it can fit the much longer contexts needed. We also evaluate the impact of model scale on DECOMP by using models from the Flan-T5 family: Flan-T5-Large (0.7B), Flan-T5-XL (3B), and Flan-T5-XXL (11B).8 + +![](images/a42abe8cd936427320d57708cf7a506c85c4647a076bb8a1d30fca2bb5f9e6a4.jpg) +Figure 11: The prompt used to answer open-domain multihop questions using Elasticsearch-based retrieval. The retrieve odqa prompt is given in Fig. 6. + +Fig. 11 shows the decomposition prompt we use. The decomposer generates (singlehop) subquestions and delegates them to retrieve odqa (described in Fig. 6). As we showed earlier, this module retrieves relevant documents then uses an RC model to answer. retrieve odqa returns both the answer and the documents, allowing subsequent sub-questions to use the answers (e.g. “Mack Rides”) and the multihop rcqa model to use the documents. The final multihop rcqa model is prompted to produce the answer directly or using CoT given K paragraphs. + +We compare our approach against two baselines: A. No Context (No-Ctxt), A closed-book setting baseline where the model must rely only on its parametric knowledge. B. NoDecomp Context (NoDecomp-Ctxt), A simple retrieval baseline where we retrieve K paragraphs using the multi-hop question as the input and use that as context. For both NoDecomp-Ctxt and Decomp-Ctxt, K is selected by hyperparameter tuning (App. A). We manually annotate CoTs and decompositions for 20 training set questions, and sample 3 prompts of 15 questions each for all approaches. The detailed prompts are given in the Appendix G. We evaluate on 300 held-out dev questions in each dataset. + +![](images/0031ea7186ac29786dc1ad7d4d7baad8176fc305ceeaa8159f6b28ad197f30a8.jpg) +Figure 12: Answer $\mathrm { F } 1 ^ { 9 } \mathrm { o n }$ three open-domain QA datasets using two base LMs: Codex (left) and Flan-T5-XXL (right) with direct prompting. Decomp-Ctxt models (ours) significantly outperforms the No-Ctxt models (no retrieval) in all settings and also outperforms our strong retrieval baseline (NoDecomp-Ctxt QA), with the exception of Codex on HotpotQA where it is comparable. See App. A.3 for results on smaller Flan-T5 models and CoT prompting. + +We present results on all three datasets with direct QA prompts in Fig. 12 with other results in App. A. The Decomp-Ctxt models performs significantly better than No-Ctxt models in all the settings showing that external knowledge can be leveraged to improve few-shot models on open-domain mulithop QA. Furthermore, we show that our Decomp-Ctxt models outperform the strong retrieval baseline (NoDecomp-Ctxt) in all settings except one (Codex with HotpotQA). Finally, we show that even with the much smaller Flan-T5-XXL model, Decomp-Ctxt outperforms all the baselines and can even achieve scores comparable to the Codex-only systems. + +# 4.5 ADDITIONAL RESULTS + +Post-processing CoT for error correction DECOMP also allows us to create a targeted sub-task handler to focus on the source of error in any system. For example, CoT for arithmetic reasoning often rely on patterns (answer is . $\star$ ) to extract answers but the CoT does not always fit this pattern. Instead, we can assign the answer extraction to a better sub-task handler (GPT3) and reduce these types of errors. This results in a 17 pt improvement on MultiArith ( $7 8 9 5$ ) and 14 pt improvement on GSM8K $3 6 5 0 . 6 $ ) compared to CoT prompting (details in App. B). + +While DECOMP outperforms the baselines in aggregate, we also see the gains of DECOMP are consistent across prompt choices (see App. D) and decomposition schemes (see App. E). + +# 5 CONCLUSION + +We proposed a new approach, Decomposed Prompting, to solve complex tasks using few-shot prompts, by decomposing them into a prompting program built out of simpler sub-tasks. Drawing inspiration from software libraries, our decomposer and shared sub-tasks are designed in a modular fashion: they use their own few-shot prompts, allowing one to independently optimize each prompt, decompose a sub-task further if necessary, or even seamlessly replace it with a symbolic system. We show that Decomposed Prompting outperforms prior work on four different tasks and generalization settings, establishing it as an effective few-shot paradigm for solving complex tasks. + +# ACKNOWLEDGEMENTS + +We thank members of the Aristo team at the Allen Institute for AI (AI2) for their constructive feedback and the reviewers for their invaluable suggestions. This work was supported in part by the National Science Foundation under grants IIS2007290. + +# REFERENCES + +Jacob Andreas, Marcus Rohrbach, Trevor Darrell, and Dan Klein. Neural module networks. In CVPR, 2016. + +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. + +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. + +Karl Cobbe, Vineet Kosaraju, Mohammad Bavarian, Mark Chen, Heewoo Jun, Lukasz Kaiser, Matthias Plappert, Jerry Tworek, Jacob Hilton, Reiichiro Nakano, Christopher Hesse, and John Schulman. Training verifiers to solve math word problems. arXiv preprint arXiv:2110.14168, 2021. + +Antonia Creswell, Murray Shanahan, and Irina Higgins. Selection-inference: Exploiting large language models for interpretable logical reasoning. In ICLR, 2023. URL https:// openreview.net/forum?id $\underline { { \underline { { \mathbf { \Pi } } } } } =$ 3Pf3Wg6o-A4. + +David Dohan, Winnie Xu, Aitor Lewkowycz, Jacob Austin, David Bieber, Raphael Gontijo Lopes, Yuhuai Wu, Henryk Michalewski, Rif A Saurous, Jascha Sohl-dickstein, et al. Language model cascades. arXiv preprint arXiv:2207.10342, 2022. + +Dheeru Dua, Shivanshu Gupta, Sameer Singh, and Matt Gardner. Successive prompting for decomposing complex questions. In Proceedings of the 2022 Conference on Empirical Methods in Natural Language Processing, pp. 1251–1265, Abu Dhabi, United Arab Emirates, December 2022. Association for Computational Linguistics. URL https://aclanthology.org/ 2022.emnlp-main.81. + +Luyu Gao, Aman Madaan, Shuyan Zhou, Uri Alon, Pengfei Liu, Yiming Yang, Jamie Callan, and Graham Neubig. PAL: Program-aided language models. ArXiv, abs/2211.10435, 2022. + +Nitish Gupta, Kevin Lin, Dan Roth, Sameer Singh, and Matt Gardner. Neural module networks for reasoning over text. In ICLR, 2020. + +Xanh Ho, A. Nguyen, Saku Sugawara, and Akiko Aizawa. Constructing a multi-hop qa dataset for comprehensive evaluation of reasoning steps. In COLING, 2020. + +Yichen Jiang and Mohit Bansal. Self-assembling modular networks for interpretable multi-hop reasoning. In EMNLP, 2019. + +Jaehun Jung, Lianhui Qin, Sean Welleck, Faeze Brahman, Chandra Bhagavatula, Ronan Le Bras, and Yejin Choi. Maieutic prompting: Logically consistent reasoning with recursive explanations. In EMNLP, 2022. + +Tushar Khot, Daniel Khashabi, Kyle Richardson, Peter Clark, and Ashish Sabharwal. Text modular networks: Learning to decompose tasks in the language of existing models. In NAACL, 2021. + +Tushar Khot, Kyle Richardson, Daniel Khashabi, and Ashish Sabharwal. Hey AI, can you solve complex tasks by talking to agents? In Findings of ACL, 2022. + +Angeliki Lazaridou, Elena Gribovskaya, Wojciech Stokowiec, and Nikolai Grigorev. Internetaugmented language models through few-shot prompting for open-domain question answering. ArXiv, abs/2203.05115, 2022. + +Yoav Levine, Itay Dalmedigos, Ori Ram, Yoel Zeldes, Daniel Jannai, Dor Muhlgay, Yoni Osin, Opher Lieber, Barak Lenz, Shai Shalev-Shwartz, et al. Standing on the shoulders of giant frozen language models. arXiv preprint arXiv:2204.10019, 2022. + +Sewon Min, Victor Zhong, Luke Zettlemoyer, and Hannaneh Hajishirzi. Multi-hop reading comprehension through question decomposition and rescoring. In ACL, 2019. + +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. + +Long Ouyang, Jeff Wu, Xu Jiang, Diogo Almeida, Carroll L. Wainwright, Pamela Mishkin, Chong Zhang, Sandhini Agarwal, Katarina Slama, Alex Ray, John Schulman, Jacob Hilton, Fraser Kelton, Luke E. Miller, Maddie Simens, Amanda Askell, Peter Welinder, Paul Francis Christiano, Jan Leike, and Ryan J. Lowe. Training language models to follow instructions with human feedback. In NeurIPS, 2022. + +Aaron Parisi, Yao Zhao, and Noah Fiedel. TALM: Tool augmented language models. arXiv preprint arXiv:2205.12255, 2022. + +Ethan Perez, Patrick Lewis, Wen-tau Yih, Kyunghyun Cho, and Douwe Kiela. Unsupervised question decomposition for question answering. In EMNLP, 2020. + +Ethan Perez, Douwe Kiela, and Kyunghyun Cho. True few-shot learning with language models. In NeurIPS, 2021. + +Ofir Press, Muru Zhang, Sewon Min, Ludwig Schmidt, Noah A Smith, and Mike Lewis. Measuring and narrowing the compositionality gap in language models. arXiv preprint arXiv:2210.03350, 2022. + +Pranav Rajpurkar, Jian Zhang, Konstantin Lopyrev, and Percy Liang. SQuAD: 100, $0 0 0 +$ questions for machine comprehension of text. In EMNLP, 2016. + +Subhro Roy and Dan Roth. Solving general arithmetic word problems. In Proceedings of the 2015 Conference on Empirical Methods in Natural Language Processing, pp. 1743–1752, 2015. doi: 10.18653/v1/D15-1202. URL https://aclanthology.org/D15-1202. + +Timo Schick, Jane Dwivedi-Yu, Roberto Dess\`ı, Roberta Raileanu, Maria Lomeli, Luke Zettlemoyer, Nicola Cancedda, and Thomas Scialom. Toolformer: Language models can teach themselves to use tools. ArXiv, abs/2302.04761, 2023. + +Alon Talmor and Jonathan Berant. The web as a knowledge-base for answering complex questions. In NAACL, 2018. + +Harsh Trivedi, Niranjan Balasubramanian, Tushar Khot, and Ashish Sabharwal. MuSiQue: Multihop questions via single-hop question composition. TACL, 2022. + +Xuezhi Wang, Jason Wei, Dale Schuurmans, Quoc Le, Ed Chi, and Denny Zhou. Self-consistency improves chain of thought reasoning in language models. In ICLR, 2023. + +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. In NeurIPS, 2022. + +Tomer Wolfson, Mor Geva, Ankit Gupta, Matt Gardner, Yoav Goldberg, Daniel Deutch, and Jonathan Berant. Break it down: A question understanding benchmark. TACL, 2020. + +Zhilin Yang, Peng Qi, Saizheng Zhang, Yoshua Bengio, William W. Cohen, Ruslan Salakhutdinov, and Christopher D. Manning. HotpotQA: A dataset for diverse, explainable multi-hop question answering. In EMNLP, 2018. + +Denny Zhou, Nathanael Scharli, Le Hou, Jason Wei, Nathan Scales, Xuezhi Wang, Dale Schuurmans, Olivier Bousquet, Quoc Le, and Ed Chi. Least-to-most prompting enables complex reasoning in large language models. In ICLR, 2023. + +# A OPEN DOMAIN QA DETAILS + +# A.1 RETRIEVAL CORPUSES FOR OPEN DOMAIN QA + +We use HotpotQA in the fullwiki setting where it comes with the associated Wikipedia corpus for open-domain QA. 2WikiMultihopQA and MuSiQue, however, are originally reading comprehension datasets. Questions in 2WikiMultihopQA and MuSiQue are associated with 10 and 20 paragraphs respectively. To turn these datasets into open-domain QA datasets, we create a corpora for each dataset by combining all the paragraphs in the train, dev and test questions. As a result we get a corpus size of 430,225 paragraphs for 2WikiMultihopQA and 139,416 for MuSiQue. + +# A.2 HYPERPARAMETER TUNING FOR OPEN DOMAIN QA + +We treat the number of paragraphs to retrieve $( K )$ in NoDecomp-Ctxt and Decomp-Ctxt models as a hyperparameter. We select it based on a grid search on a set of values to maximize performance on a held out set of 100 questions for each dataset. For NoDecomp-Ctxt, we search $\bar { K \in \{ 6 , 8 , 1 0 \} }$ for GPT3 models and $K \in 2 , 4 , 6 , 8$ for Flan-T5-\* models. For Decomp-Ctxt, we search $K \in \{ 2 , 4 , 6 \}$ for GPT3 and Flan-T5-\* models. Note that the ranges are different between GPT3 and Flan-T5-\* as GPT3 can fit in more number of tokens. The ranges are different for NoDecomp-Ctxt and DecompCtxt as $K$ refers to number of paragraphs retrieved in each round of retrieval, and NoDecomp-Ctxt has only one step of retrieval whereas Decomp-Ctxt usually has multiple retrieval steps. + +![](images/fd2570b5b5042b81aaa8bdc78a39badf451564c357e82ffb980009fab978aa2d.jpg) +A.3 ADDITIONAL RESULTS +Figure 13: Results on MuSiQue dataset + +![](images/6060e6c34b44c2ab61eeae76fbb6fde84735b05b2d906876d44f62fd72638e4b.jpg) +Figure 14: Results on HotpotQA dataset + +![](images/38f49c5d0790309d35f126b75caedba68aa01a600152b8429588a69a7500b64e.jpg) +Figure 15: Results on 2WikiMultihopQA dataset + +# A.3.1 MUSIQUE + +We present all the results on the MuSiQue dataset in Fig. 13. Across all settings, we can see that retrieval helps substantially (large gains over No-Ctxt QA) with further improvements achieved by our DecomP-based Decomp-Ctxt QA model. + +# A.3.2 HOTPOTQA + +We present all the results on the HotpotQA dataset in Fig. 14. On this dataset too, we can see large gains by incorporating retrieval but the gains from using DecomP are mostly seen in the smaller models. + +# A.3.3 2WIKIMULTIHOPQA + +We present all the results on the 2WikiMultihopQA dataset in Fig. 15. On this dataset, we can see large gains by incorporating retrieval and also observe substantial gains by incorporating DecomP (as compared to NoDecomp-Ctxt). + +# B MATH QA + +We apply Decomposed Prompting to two math QA datasets: GSM8K Cobbe et al. (2021) and MultiArith Roy & Roth (2015). For Chain-of-thought, we used the original prompts for math reasoning Wei et al. (2022). For example: + +Q: There are 15 trees in the grove. Grove workers will plant trees in the grove today. After they are done, there will be 21 trees. How many trees did the grove workers plant today? A: There are 15 trees originally. Then there were 21 trees after some more were planted. So there must have been $2 1 - 1 5 = 6$ . The answer is 6. + +Most CoT systems Wei et al. (2022); Wang et al. (2023) rely on extracting the answer by finding the number following “answer is”. However, this may not always be accurate. For example, the following CoT would be unanswerable by relying on simple patterns. + +Parker chews 4 pieces of gum a day. There are 15 pieces of gum in a pack. So he will need 4 \* 30 / $1 5 = 8$ packs of gum to last him 30 days. + +Rather than relying on patterns with limited generalization, we can use a language model to extract the answer more reliably. Specifically, we use Decomposed Prompting to decompose the task into first identifying the chain-of-thought reasoning and then using a second GPT3-based sub-module to extract the answer from the CoT. We show examples of our prompts here (full prompt in App. G): + +# Example from the Decomposition Prompt + +QC: There are 15 trees in the grove. Grove workers will plant trees in the grove today. After they are done, there will be 21 trees. How many trees did the grove workers plant today? +QS: [cot] There are 15 trees in the grove. Grove workers will plant trees in the grove today. After they are done, there will be 21 trees. How many trees did the grove workers plant today? +A: There are 15 trees originally. Then there were 21 trees after some more were planted. So there must have been $2 1 - 1 5 = 6$ trees planted. +QS: [gpt ans] There are 15 trees originally. Then there were 21 trees after some more were planted. So there must have been $2 1 - 1 5 = 6$ trees planted. +A: 6 +QS: [EOQ] + +# Example from the gpt ans prompt + +Q: There are 15 trees originally. Then there were 21 trees after some more were planted. So there must have been $2 1 - 1 5 = 6$ trees planted. +A: 6 + +![](images/2cbba565f98f861e394013210e2f12a6f39cbfcb94a8b959ba6d94a31cc20765.jpg) +Figure 16: Our simple decomposition results in 14-17 pts on two MathQA datasets: GSM8k and MultiArith. + +![](images/70a46c50e489b4f77e54866f88f549e384f33f6e75c3a68aef6052c9e88b89d6.jpg) +Figure 17: As the models become weaker (davinci-001) and smaller (curie-001), the performance of all the models drop. DECOMP still outperforms CoT till the performance reaches close to zero with curie. + +We present our results in Fig. 16. On the GSM8K data set10, we outperform CoT by 14 points. On the MultiArith dataset11, we achieve a 17 pt improvement compare to CoT. While this is a simple change, it illustrates the possibility of using DECOMP for other complex answer types, e.g. nonextractive answer generation from chain-of-thoughts. + +# C EFFECT OF SCALE ON COMMAQA + +We evaluate text-curie-001, text-davinci-001 and text-davinci-002 on the CommAQA dataset. Since the curie-001 and davinci-001 have a smaller context window size, we further reduced our prompts to fit within their context windows (2048 tokens). As shown in Fig. 17, both CoT and DECOMP are effected by the model size. + +# D RESULTS ON ALL PROMPTS + +# D.1 PER-PROMPT RESULT ON LETTER CONCATENATION + +We present the results of the letter concatenation task (with space delimiter) for different values of N in Fig. 18. Our results are stable across the different prompts (P1, P2 and P3) and always outperform CoT and Least-to-Most prompting. + +![](images/6e908e8522272cb0d2f5962a15158305e58857ac8fc612cfc715cafd2539e199.jpg) +Figure 18: Across all values of $\mathbf { N }$ and different prompts (P1, P2 and P3), DECOMP outperform chain-of-thought reasoning and even least-to-most prompting. + +D.2 PER-PROMPT RESULTS ON COMMAQA + +We also present the results of all the prompts on the CommAQA dataset in Fig. 19. Here too, we can observe that DECOMP outperforms CoT on each prompt set. + +![](images/812b5cb04b0233e675d0849633d003e26678f97a46ef6f37874fe7b02a06981c.jpg) +Figure 19: Results of different prompts on the CommAQA dataset. + +# E EFFECT OF DECOMPOSITION SCHEME + +To evaluate the effect of the decomposition scheme, we experiment with two other simple decomposition structures for the letter concatenation and reversal tasks. + +Letter Concatenation For letter concatenation, we consider an alternate scheme where we use GPT3 to generate each question rather than loop over the answers, e.g., + +QC: Take the last letters of the words in ”Augusta Ada King” and concatenate them using a space. QS: [split] What are the words in ”Augusta Ada King”? +A: [”Augusta”, ”Ada”, ”King”] +QS: [str position] What is the last letter in ”Augusta”? +A: ”a” +QS: [str position] What is the last letter in ”Ada”? +A: ”a” +QS: [str position] What is the last letter in ”King”? +A: ”g” +QS: [merge] Concatenate [”a”, ”a”, ”g”] using a space. +A: ”a a g” +QS: [EOQ] + +By using the decomposer prompt model to generate the sub-questions, we can be more robust to formatting issues in the output answers, e.g., we can expect GPT3 to still generate the appropriate sub-questions even if the first answer is not a valid array. However, the generated sub-questions may not correctly use all the elements of the list (change in order, missed element, repeated elements, etc). + +List Reversal For list reversal, instead of splitting into halves, we take the tail of the list, reverse it and then concatenate it to the head. i.e. reverse(list) $=$ reverse(list[1:]) $^ +$ list[0]. This requires more GPT3 calls (O(n)) compared to the original approach of splitting the list into halves $\left( \mathrm { O } ( \log ( \mathrm { n } ) ) \right)$ . + +In both these cases, we noticed that the performance did not drop as shown in Fig. 20 and Fig. 21. On the letter concatenation task, the results were exactly the same. The new reversal decomposition schema was actually stronger on longer inputs at the cost of more calls to GPT3 $\mathrm { ( O ( l n ( n ) ) }$ using binary splits vs ${ \mathrm { O } } ( { \mathrm { n } } )$ one element at a time). Both these decomposition schemes are still better than CoT. + +![](images/f40cf8b504ff72f5c953dc86cc0a8ec5ea14e9f85f95ac6d74ce57ede5383f04.jpg) +Figure 20: Both decomposition schemes for the letter concatenation task have the same scores. + +![](images/b32fa919d6512a6a76b67ccd77f6577df70bae48e4f8cc4b13518ca24b904eca.jpg) +Figure 21: Recursively reversing the tail of a list is more stable at longer lengths but comes at the cost of more calls to GPT3. + +# F ERROR ANALYSIS + +# F.1 LETTER CONCATENATION + +# F.1.1 DECOMP + +We analyzed the errors in DECOMP on the letter concatenation task and only found errors in the sub-task execution. + +![](images/c32608beb02a6132ee7f4f6990bffcbe6e199ef291a925324f156bd7eab2c835.jpg) +Figure 22: EM Results on the $k ^ { t h }$ letter concatenation task $\left( \mathrm { k } \mathrm { = } 3 \right)$ using semi-colon as delimiter with different values for N, the number of words in the input. DECOMP always outperforms and generalizes better than CoT. + +Q: Take the letters at position 3 of the words in ”Nancy Samina Abbas Caudhari Bano” and concatenate them using a space. +A: n m b u n +Prediction: c m b u n +Error: Incorrect letter extraction (Sub-task) +What is at position 3 in ”[(N, 1), (a, 2), (n, 3), (c, 4), (y, 5)]”? ⇒ ”c” Q: Take the letters at position 3 of the words in ”Orlando Stephen Cho Teixeira Pierre” and concatenate them using a space. +A: l e o i e +Prediction: leoie +Error: Incorrect concatenation (Sub-task) +Concatenate e o” ”e”] using a space. $\cdot$ ”leoie” + +# F.1.2 COT W/ ROLLOUT + +We analyzed the errors in CoT on the letter concatenation task and found similar errors during the generation of CoT. But the frequency of these errors was higher than DECOMP, as it is not possible to effectively teach each sub-task with CoT. + +Q: Take the letters at position 3 of the words in ”Sheila Nicolas Verma Sha Sousa” and concatenate them using a space. +A: e c r a u +Pred: i c r a u +Error: Incorrect letter extraction +...The letters and their positions in ”Sheila” are ”[(S, 1), (h, 2), (e, 3), (i, 4), (l, 5), (a, 6)]”. The letter at position 3 in this sequence is ”i”... +Q:Take the letters at position 3 of the words in ”Shobha Kailash Nakamura Peter Benitez” and concatenate them using a space. +A: o i k t n +Pred: o l k t i +Error: Incorrect letter extraction +...”Benitez” are ”[(B, 1), (e, 2), $( n , ~ 3 ) , ~ ( i , ~ 4 ) , ~ ( t , ~ 5 ) , ~ ( e , ~ 6 ) , ~ ( z , ~ 7 ) J ^ { , , }$ . The letter at position 3 in this sequence is ” ... + +# F.2 COMMAQA + +Similarly in CommaQA, the errors are mostly due to sub-task errors, which in this dataset correspond to answering single-hop questions. CoT also makes the same types of errors but they are more frequent since this QA sub-task can not be delegated to a specialized prompt in CoT. Since all errors are of this type, we show only one example here. + +Q: What awards have movies written by people born in 1933 won? +A: [”Hydrallium”, ”Pompasole”] +Pred: [”Pompasole”] +Error: Incorrect sub-question answer +Sub-Q:What movies has Haldron written? +Sub-A: [”Polytetrafluoromethane”, ”Skia”, ”Warpstone”] +Pred: [”Skia”, ”Warpstone”] + +# G TASK PROMPTS + +We have provided the task prompts for all the datasets for COT and our Decomposed Prompting approach. + +CoT Since CoT methods also perform 2-step reasoning: first generate the chain-of-thought and second extract the answer from the CoT, we use the same decomposition-based framework for COT baselines too. For example, consider the following example in our COT prompt: + +QC: Take the letters at position 1 of the words in ”Alan Mathison Turing” and concatenate them using a space. +QS: [extract] The letter at position 1 of ”Alan” is ”A”. The letter at position 1 of ”Mathison” is ”M”. The letter at position 1 of ”Turing” is ”T”. Concatenating ”A”, ”M”, ”T” using a space leads to ”A M T”. So, ”Alan Mathison Turing” outputs ”A M T”. +A: ”A M T” +QS: [EOQ] + +GPT3 generates the chain-of-thought during the ”decomposition” step and a regex-based answer extractor extract (’. $\star$ outputs $" ( . . . ) " \setminus ( . . ^ { \prime } )$ then takes this CoT and generates the answer. In some cases, the module name is skipped in the prompt (the CoT is sent to the extractor by default). + +Operators In this work, we use the same operators as defined by Khot et al.. Their select operator is just the basic operator that replaces references to an answer index with its answer. When not specified, select is assumed to be the default operator. In addition, we consider two operators in our experiments: project values and project values flat unique. + +• project values: This operator takes a list answer $\# i = X$ and iterates over it to generate new questions by replacing mentions of $\# i$ i.e. $\mathbf { Q } =$ [q.replace(#i, x) for ${ \textbf { X } } \in$ X]. The answer to each question is simply concatenated to get the final answer i.e. $\mathbf { A } =$ [model(q) for ${ \mathfrak { q } } \in \mathrm { Q } ]$ . We refer to this as foreach for simplicity in the main text. • project values flat unique: This operator performs the same steps as project values but then additionally flattens the list and only returns the unique entities in the flattened list. We refer to this as foreach merge in the main text for simplicity. + +# G.1 LETTER CONCATENTATION + +We show one of the prompts used for experiments here. The entire set of prompts is provided as supplemetary material. + +# G.1.1 DECOMPOSED PROMPTING + +# decomp + +QC: Take the last letters of the words in ”Augusta Ada King” and concatenate them using a space. QS: [split] What are the words in ”Augusta Ada King”? + +A: [”Augusta”, ”Ada”, ”King”] + +QS: (project values) [str position] What is the last letter in ”#1”? + +A: [”a”, ”a”, ”g”] QS: [merge] Concatenate #2 using a space. + +A: ”a a g” + +QS: [EOQ] + +QC: Take the letters at position 1 of the words in ”Alan Mathison Turing” and concatenate them using a space. + +QS: [split] What are the words in ”Alan Mathison Turing”? + +A: [”Alan”, ”Mathison”, ”Turing”] + +QS: (project values) [str position] What is the letter at position 1 in ”#1”? + +QS: [merge] Concatenate #2 using a space. + +A: ”A M T” QS: [EOQ] + +QC: Take the letters at position 4 of the words in ”Herbert Alexander Simon” and concatenate them using a space. + +QS: [split] What are the words in ”Herbert Alexander Simon”? + +A: [”Herbert”, ”Alexander”, ”Simon”] + +S: (project values) [str position] What is the letter at position 4 in ”#1”? + +QS: [merge] Concatenate #2 using a space. + +Q: What are the words in ”Alan Mathison Turing”? + +A: [”Alan”, ”Mathison”, ”Turing”] + +Q: What are the letters in ”Alan”? + +A: [”A”, ”l”, ”a”, ”n”] + +Q: What are the letters and their positions in ”Mathison”? + +A: ”[(M, 1), (a, 2), (t, 3), (h, 4), (i, 5), (s, 6), (o, 7), (n, 8)]” + +Q: What are the words and their positions in ”Herbert Alexander Simon”? A: ”[(Herbert, 1), (Alexander, 2), (Simon, 3)]” + +# str position + +QC: What is the letter at position 1 of the word ”Augusta”? QS: (select) [split] What are the letters and their positions in ”Augusta”? + +A: ”[(A, 1), (u, 2), (g, 3), (u, 4), (s, 5), (t, 6), (a, 7)]” + +QS: (select) [arr position] What is at position 1 in #1? +A: ”A” +QS: [EOQ] + +QC: What is the last letter of the word ”Mathison”? + +QS: (select) [split] What are the letters and their positions in ”Mathison”? + +A: ”[(M, 1), (a, 2), (t, 3), (h, 4), (i, 5), (s, 6), (o, 7), (n, 8)]” + +QS: (select) [arr position] What is the last letter in #1? A: ”n” + +QS: [EOQ] + +QC: What is the word at the position 4 in ”Colorless green ideas sleep furiously”? + +QS: (select) [split] What are the words and their positions in ”Colorless green ideas sleep furiousl ” + +A: ”[(Colorless, 1), (green, 2), (ideas, 3), (sleep, 4), (furiously, 5)]” + +QS: (select) [arr position] What is at the position 4 in #1? +A: ”sleep” +QS: [EOQ] + +merge + +Q: Concatenate [”A”, ”l”, ”a”, ”n”]. + +A: ”Alan” + +Q: Concatenate [”b”, ”x”, ”o”] using a space. + +A: ”b x o” + +Q: Concatenate [”a”, ”a”, ”g”] using a comma. + +A: ”a,a,g” + +Q: Concatenate [”Alan”, ”Mathison”, ”Turing”] using a space. + +A: ”Alan Mathison Turing” + +Q: Concatenate [”Allen”, ”Institute”]. + +A: ”AllenInstitute” + +arr position + +Q: What is at position 4 in ”[(”Colorless”, 1), (”green”, 2), (”ideas”, 3), (”sleep”, 4), (”furiously”, 5)]”? + +A: ”sleep” + +Q: What is at position 1 in ”[(M, 1), (a, 2), (t, 3), (h, 4), (i, 5), (s, 6), (o, 7), (n, 8)]”? + +A: ”M” + +Q: What is at the last position in ”[(A, 1), (u, 2), (g, 3), (u, 4), (s, 5), (t, 6), (a, 7)]”? + +A: ”a” + +Q: What is at position 1 in ”[(Herbert, 1), (Alexander, 2), (Simon, 3)]”? + +A: ”Herbert” + +Q: What is at last position in ”[(Allen, 1), (Institute, 2), (for, 3), (Artificial, 4), (Intelligence, 5)]”? + +A: ”Intelligence” + +Q: What is at position 4 in ”[(A, 1), (l, 2), (e, 3), (x, 4), (a, 5), (n, 6), (d, 7), (e, 8), (r, 9)]”? A: ”x” + +# G.1.2 COT WITH ROLLOUT + +# COT w/ rollout + +QC: Take the last letters of the words in ”Augusta Ada King” and concatenate them using a space. +QS: The words in ”Augusta Ada King” are ”Augusta”, ”Ada” and ”King”. The letters and their positions in ”Augusta” are ”[(A, 1), (u, 2), (g, 3), (u, 4), (s, 5), (t, 6), (a, 7)]”. The last letter in this sequence is ”a”. The letters and their positions in ”Ada” are ”[(A, 1), (d, 2), (a, 3)]”. The last letter in this sequence is ”a”. The letters and their positions in ”King” are ”[(K, 1), (i, 2), ( n, 3), (g, 4)]”. The last letter in this sequence is ”g”. Concatenating ”a”, ”a”, ”g” using a space leads to ”a a g”. So, ”Augusta Ada King” outputs ”a a g”. + +A: ”a a g” QS: [EOQ] + +QC: Take the letters at position 1 of the words in ”Alan Mathison Turing” and concatenate them using a space. + +QS: The words in ”Alan Mathison Turing” are ”Alan”, ”Mathison”, and ”Turing”. The letters and their positions in ”Alan” are ”[(A, 1), (l, 2), (a, 3), (n, 4)]”. The letter at position 1 in this sequence is ”A”. The letters and their positions in ”Mathison” are [(M, 1), (a, 2), (t, 3), (h, 4), (i, 5), (s, 6), (o, 7), (n, 8)]”. The letter at position 1 in this sequence is ”M”. The letters and their positions in ”Turing” are ”[(T, 1), (u, 2), (r, 3), (i, 4), (n, 5), (g, 6)]”. The letter at position 1 in this sequence is ”T”. Concatenating ”A”, ”M”, ”T” using a space leads to ”A M T”. So, ”Alan Mathison Turing” outputs ”A M T”. + +A: ”A M T” QS: [EOQ] + +QC: Take the letters at position 4 of the words in ”Herbert Alexander Simon” and concatenate them using a space. + +QS: The words in ”Herbert Alexander Simon” are ”Herbert”, ”Alexander”, and ”Simon”. The letters and their positions in ”Herbert” are ”[(H, 1), (e, 2), (r, 3), (b, 4), (e, 5), (r, 6), (t, 7)]”. The letter at position 4 in this sequence is ”b”. The letters and their positions in ”Alexander” are ”[(A, 1), (l, 2), (e, 3), (x, 4), (a, 5), (n, 6), (d, 7), (e, 8), (r, 9)]”. The letter at position 4 in this sequence is ”x”. The letters and their positions in ”Simon” are ”[(S, 1), (i, 2), (m, 3), (o, 4), (n, 5)]”. The letter at position 4 in this sequence is ”o”. Concatenating ”b”, ”x”, ”o” using a space leads to ”b x o”. So, ”Herbert Alexander Simon” outputs ”b x o”. + +A: ”b x o” QS: [EOQ] + +# G.1.3 COT + +# COT + +QC: Take the last letters of the words in ”Augusta Ada King” and concatenate them using a space. +QS: The last letter of ”Augusta” is ”a”. The last letter of ”Ada” is ”a”. The last letter of ”King” is ” g”. Concatenating ”a”, ”a”, ”g” using a space leads to ”a a g”. So, ”Augusta Ada King” outputs ”a a g”. + +A: ”a a g” + +QS: [EOQ] + +QC: Take the letters at position 1 of the words in ”Alan Mathison Turing” and concatenate them using a space. + +QS: The letter at position 1 of ”Alan” is ”A”. The letter at position 1 of ”Mathison” is ”M”. The letter at position 1 of ”Turing” is ”T”. Concatenating ”A”, ”M”, ”T” using a space leads to ”A M T”. So, ”Alan Mathison Turing” outputs ”A M T”. + +A: ”A M T” QS: [EOQ] + +QC: Take the letters at position 4 of the words in ”Herbert Alexander Simon” and concatenate them using a space. + +QS: The letter at position 4 of ”Herbert” is ”b”. The letter at position 4 of ”Alexander” is ”x”. The letter at position 4 of ”Simon” is ”o”. Concatenating ”b”, ”x”, ”o” using a space leads to ”b x o”. So, ”Herbert Alexander Simon” outputs ”b x o”. + +A: ”b x o” QS: [EOQ] + +# G.1.4 LEAST-TO-MOST W/ ROLLOUT + +# Least-to-most Decomp + +QC: Take the last letters of the words in ”Augusta Ada King” and concatenate them using a space. +QS: [l2m] Take the last letters of the words in ”Augusta Ada” and concatenate them using a space. + +A: The words in ”Augusta Ada” are ”Augusta” and ”Ada”. The letters and their positions in ” Augusta” are ”[(A, 1), (u, 2), (g, 3), (u, 4), (s, 5), (t, 6), (a, 7)]”. The last letter in this sequence is ”a”. The letters and their positions in ”Ada” are ”[(A, 1), (d, 2), (a, 3)]”. The last letter in this sequence is ”a”. Concatenating ”a”, ”a” using a space leads to ”a a”. So, ”Augusta Ada” outputs ”a a”. + +QS: [l2m] Take the last letters of the words in ”Augusta Ada King” and concatenate them using a space. + +A: ”Augusta Ada” outputs ”a a”. The letters and their positions in ”King” are ”[(K, 1), (i, 2), (n, 3), (g, 4)]”. The last letter in this sequence is ”g”. Concatenating ”a a”, ”g” using a space leads to ”a a g”. So, ”Augusta Ada King” outputs ”a a g”. + +QS: [ans ext] So, ”Augusta Ada King” outputs ”a a g”. + +A: ”a a g” QS: [EOQ] + +QC: Take the letters at position 1 of the words in ”Alan Mathison Turing” and concatenate them using a space. + +QS: [l2m] Take the letters at position 1 of the words in ”Alan Mathison” and concatenate them using a space. + +A: The words in ”Alan Mathison” are ”Alan” and ”Mathison”. The letters and their positions in ” Alan” are ”[(A, 1), (l, 2), (a, 3), (n, 4)]”. The letter at position 1 in this sequence is ”A”. The letters and their positions in ”Mathison” are [(M, 1), (a, 2), (t, 3), (h, 4), (i, 5), (s, 6), (o, 7), (n, 8)]”. The letter at position 1 in this sequence is ”M”. Concatenating ”A”, ”M” using a space leads to ”A M”. So, ”Alan Mathison” outputs ”A M”. + +QS: [l2m] Take the letters at position 1 of the words in ”Alan Mathison Turing” and concatenate them using a space. + +A: ”Alan Mathison” outputs ”A M”. The letters and their positions in ”Turing” are ”[(T, 1), (u, 2), (r, 3), (i, 4), (n, 5), (g, 6)]”. The letter at position 1 in this sequence is ”T”. Concatenating ”A M”, ”T” using a space leads to ”A M T”. So, ”Alan Mathison Turing” outputs ”A M T”. + +QS: [ans ext] So, ”Alan Mathison Turing” outputs ”A M T”. A: ”A M T” +QS: [EOQ] + +QC: Take the letters at position 4 of the words in ”Herbert Alexander Simon” and concatenate them using a space. + +QS: [l2m] Take the letters at position 4 of the words in ”Herbert Alexander” and concatenate them using a space. + +A: The words in ”Herbert Alexander” are ”Herbert” and ”Alexander”. The letters and their positions in ”Herbert” are ”[(H, 1), (e, 2), (r, 3), (b, 4), (e, 5), (r, 6), (t, 7)]”. The letter at position 4 in this sequence is ”b”. The letters and their positions in ”Alexander” are ”[(A, 1), ( l, 2), (e, 3), (x, 4), (a, 5), (n, 6), (d, 7), (e, 8), (r, 9)]”. The letter at position 4 in this sequence is ”x”. Concatenating ”b”, ”x” using a space leads to ”b x”. So, ”Herbert Alexander” outputs ” b x”. + +QS: [l2m] Take the letters at position 4 of the words in ”Herbert Alexander Simon” and concatenate them using a space. + +A: ”Herbert Alexander” outputs ”b x”. The letters and their positions in ”Simon” are ”[(S, 1), (i, 2) , (m, 3), (o, 4), (n, 5)]”. The letter at position 4 in this sequence is ”o”. Concatenating ”b $\mathbf { X } ^ { \prime \prime }$ , ” o” using a space leads to ”b x o”. So, ”Herbert Alexander Simon” outputs ”b x o”. + +QS: [ans ext] So, ”Herbert Alexander Simon” outputs ”b x o”. A: ”b x o” +QS: [EOQ] + +# Least-to-most COT(l2m) + +Q: Take the last letters of the words in ”Augusta Ada” and concatenate them using a space. + +A: The words in ”Augusta Ada” are ”Augusta” and ”Ada”. The letters and their positions in ” Augusta” are ”[(A, 1), (u, 2), (g, 3), (u, 4), (s, 5), (t, 6), (a, 7)]”. The last letter in this sequence is ”a”. The letters and their positions in ”Ada” are ”[(A, 1), (d, 2), (a, 3)]”. The last letter in this sequence is ”a”. Concatenating ”a”, ”a” using a space leads to ”a a”. So, ”Augusta Ada” outputs ”a a”. + +Q: Take the last letters of the words in ”Augusta Ada King” and concatenate them using a space. + +A: ”Augusta Ada” outputs ”a a”. The letters and their positions in ”King” are ”[(K, 1), (i, 2), (n, 3), (g, 4)]”. The last letter in this sequence is ”g”. Concatenating ”a a”, ”g” using a space leads to ”a a g”. So, ”Augusta Ada King” outputs ”a a g”. + +Q: Take the letters at position 1 of the words in ”Alan Mathison” and concatenate them using a space. + +A: The words in ”Alan Mathison” are ”Alan” and ”Mathison”. The letters and their positions in ” Alan” are ”[(A, 1), (l, 2), (a, 3), (n, 4)]”. The letter at position 1 in this sequence is ”A”. The letters and their positions in ”Mathison” are [(M, 1), (a, 2), (t, 3), (h, 4), (i, 5), (s, 6), (o, 7), (n, 8)]”. The letter at position 1 in this sequence is ”M”. Concatenating ”A”, ”M” using a space leads to ”A M”. So, ”Alan Mathison” outputs ”A M”. + +Q: Take the letters at position 1 of the words in ”Alan Mathison Turing” and concatenate them using a space. + +A: ”Alan Mathison” outputs ”A M”. The letters and their positions in ”Turing” are ”[(T, 1), (u, 2), (r, 3), (i, 4), (n, 5), (g, 6)]”. The letter at position 1 in this sequence is ”T”. Concatenating ”A M”, ”T” using a space leads to ”A M T”. So, ”Alan Mathison Turing” outputs ”A M T”. + +Q: Take the letters at position 4 of the words in ”Herbert Alexander” and concatenate them using a space. + +A: The words in ”Herbert Alexander” are ”Herbert” and ”Alexander”. The letters and their positions in ”Herbert” are ”[(H, 1), (e, 2), (r, 3), (b, 4), (e, 5), (r, 6), (t, 7)]”. The letter at position 4 in this sequence is ”b”. The letters and their positions in ”Alexander” are ”[(A, 1), ( l, 2), (e, 3), (x, 4), (a, 5), (n, 6), (d, 7), (e, 8), (r, 9)]”. The letter at position 4 in this sequence is $\vec { \bf \Phi } ^ { , , } \vec { \bf x } ^ { , , }$ . Concatenating ”b”, ”x” using a space leads to ”b x”. So, ”Herbert Alexander” outputs ” b x”. + +Q: Take the letters at position 4 of the words in ”Herbert Alexander Simon” and concatenate them using a space. + +A: ”Herbert Alexander” outputs ”b x”. The letters and their positions in ”Simon” are ”[(S, 1), (i, 2) , (m, 3), (o, 4), (n, 5)]”. The letter at position 4 in this sequence is ”o”. Concatenating ”b x”, ” o” using a space leads to ”b x o”. So, ”Herbert Alexander Simon” outputs ”b x o”. + +# G.1.5 ALT DECOMP SCHEMA (GENERATE EACH SUB-QUESTION) + +# decomp + +QC: Take the last letters of the words in ”Augusta Ada King” and concatenate them using a space. QS: [split] What are the words in ”Augusta Ada King”? + +A: [”Augusta”, ”Ada”, ”King”] + +QS: [str position] What is the last letter in ”Augusta”? + +QS: [str position] What is the last letter in ”Ada”? + +QS: [str position] What is the last letter in ”King”? + +QS: [merge] Concatenate [”a”, ”a”, ”g”] using a space. + +QS: [EOQ] + +QC: Take the letters at position 1 of the words in ”Alan Mathison Turing” and concatenate them using a space. + +QS: [split] What are the words in ”Alan Mathison Turing”? + +A: [”Alan”, ”Mathison”, ”Turing”] + +QS: [str position] What is the letter at position 1 in ”Mathison”? + +QS: [str position] What is the letter at position 1 in ”Turing”? + +QS: [merge] Concatenate [”A”, ”M”, ”T”] using a space. + +A: ”A M T” + +QS: [EOQ] + +QC: Take the letters at position 4 of the words in ”Herbert Alexander Simon” and concatenate them using a space. + +QS: [split] What are the words in ”Herbert Alexander Simon”? + +A: [”Herbert”, ”Alexander”, ”Simon”] + +QS: [str position] What is the letter at position 4 in ”Herbert”? + +QS: [str position] What is the letter at position 4 in ”Alexander”? + +QS: [str position] What is the letter at position 4 in ”Simon”? + +QS: [merge] Concatenate [”b”, ”x”, ”o”] using a space. + +# G.2 SEQUENCE REVERSAL + +G.2.1 SPLIT REVERSAL + +The prompts in this section implement Algorithm 1. + +
Algorithm 1 A recursive reversal strategy that splits the sequence in half,reverses each half, and concatenates them. Runs in O(log n)calls to the LM where n is the number of items in the sequence.
procedure SPLITREVERSE(x)The reversal of x
if |x|<4 thenThe base case
return x|x|,..., x1The reversed sequence
elseThe inductive case
n←|x|/2>Half the length of x
l← x1,...,xnThe first half of x
CR ←SPLITREVERSE(C)>The reversed first half
r←xn+1,...,x|xlThe second half of x
rR ← SPLITREVERSE(r) R rRR CRThe reversed second half
returnr n, en+1,..., 七 |xThe concatenated reversed halves
end if end procedure
+ +# reverse + +QC: Reverse the sequence ”driving license, button, packet, identity card, shoe”. + +QS: [extract] The sequence is ”1. driving license, 2. button, 3. packet, 4. identity card, 5. shoe”. The sequence is 5 items long, which is more than the minimum length of 4, so we split it. Half of 5 is $5 / 2 = 2 . 5$ . Dropping the decimal, we get that the first half will be 2 items long, ending in $^ { \circ \circ } 2$ . button”. The first half (2 items) is ”1. driving license, 2. button”. + +A: ”1. driving license, 2. button” + +QS: [extract] The first half of the sequence ends with ”2. button”, so the second half starts after ”2. button” with ”3. packet”. The full sequence is 5 items long, and the first half is 2 items long, so the second half will be $5 - 2 = 3$ items long. The second half of the sequence (3 items) is ”3. packet, 4. identity card, 5. shoe”. + +A: ”3. packet, 4. identity card, 5. shoe” + +QS: [remove numbers] Remove the numbers from #1. + +A: ”driving license, button” + +QS: [remove numbers] Remove the numbers from $\# 2$ . + +A: ”packet, identity card, shoe” + +QS: [reverse] Reverse the sequence #3. + +A: ”button, driving license” + +QS: [reverse] Reverse the sequence #4. + +A: ”shoe, identity card, packet” + +QS: [join] #6 #5 + +A: ”shoe, identity card, packet, button, driving license” + +QS: [EOQ] + +QC: Reverse the sequence ”laptop, photo, clip”. + +QS: [extract] The sequence is ”1. laptop, 2. photo, 3. clip”. The sequence is 3 items long, which is less than the minimum length of 4, so we don’t need to split it. All we need to do is reverse ” laptop, photo, clip”. + +A: ”laptop, photo, clip” QS: [cot] Reverse the sequence #1. A: ”clip, photo, laptop” QS: [EOQ] + +QC: Reverse the sequence ”newspaper, glasses, laptop, bottle”. + +QS: [extract] The sequence is ”1. newspaper, 2. glasses, 3. laptop, 4. bottle”. The sequence is 4 items long, which is equal to the minimum length of 4, so we split it. Half of 4 is $4 / 2 = 2 . 0$ . Dropping the decimal, we get that the first half will be 2 items long. The first half (2 items) of the sequence is ”1. newspaper, 2. glasses”. + +A: ”1. newspaper, 2. glasses” + +QS: [extract] The first half of the sequence ends with ”2. glasses”, so the second half starts after ”2. glasses” with ”3. laptop”. The full sequence is 4 items long and the first half is 2 items long, so the second half will be $4 - 2 = 2$ items long, ending in ”2. glasses”. The second half of the sequence (2 items) is ”3. laptop, 4. bottle”. + +A: ”3. laptop, 4. bottle” + +QS: [remove numbers] Remove the numbers from #1. + +A: ”newspaper, glasses” + +QS: [remove numbers] Remove the numbers from $\# 2$ + +A: ”laptop, bottle” + +QS: [reverse] Reverse the sequence #3. + +A: ”glasses, newspaper” + +QS: [reverse] Reverse the sequence #4. + +A: ”bottle, laptop” + +QS: [join] #6 #5 + +A: ”bottle, laptop, glasses, newspaper” + +remove numbers + +Q: Remove the numbers from ”4. bottle, 3. laptop, 2. glasses, 1. newspaper”. + +A: ”bottle, laptop, glasses, newspaper” + +Q: Remove the numbers from ”1. identity card, 2. packet, 3. button”. + +A: ”identity card, packet, button” + +Q: Remove the numbers from ”1. player, 2. passport, 3. umbrella, 4. radio”. + +A: ”player, passport, umbrella, radio” + +join + +Q: ”bottle, laptop” ”glasses, newspaper”. + +A: ”bottle, laptop, glasses, newspaper” + +Q: ”identity card, packet, button” ”magazine, notebook, glasses”. + +A: ”identity card, packet, button, magazine, notebook, glasses” + +Q: ”passport, umbrella, radio, mobile phone, photo” ”player”. + +A: ”passport, umbrella, radio, mobile phone, photo, player” + +Q: ”mirror, case” ”toothbrush, alarm clock”. + +A: ”mirror, case, toothbrush, alarm clock” Q: ”light bulb, clip, umbrella” ”driving licence, watch”. A: ”light bulb, clip, umbrella, driving licence, watch” + +cot + +QC: Reverse the sequence ”newspaper, glasses, laptop, bottle”. + +QS: First is newspaper. Second is glasses. Third is laptop. Fourth is bottle. Now to reverse, change the order to: Fourth is bottle. Third is laptop. Second is glasses. First is newspaper. So the answer is ”bottle, laptop, glasses, newspaper”. + +A: ”bottle, laptop, glasses, newspaper” + +QC: Reverse the sequence ”laptop, photo, clip”. + +QS: First is laptop. Second is photo. Third is clip. Now to reverse, change the order to: Third is clip . Second is photo. First is laptop. So the answer is ”clip, photo, laptop”. + +A: ”clip, photo, laptop” + +QC: Reverse the sequence ”driving license, button, packet, identity card, pineapple”. + +QS: First is driving license. Second is button. Third is packet. Fourth is identity card. Fifth is pineapple. Now to reverse, change the order to: Fifth is pineapple. Fourth is identity card. Third is packet. Second is button. First is driving license. So the answer is ”pineapple, identity card, packet, button, driving license”. + +A: ”pineapple, identity card, packet, button, driving license” + +# unrolled decomp + +QC: Reverse the sequence ”driving license, button, packet, identity card, shoe”. + +QS: The sequence is $^ { \circ } 1$ . driving license, 2. button, 3. packet, 4. identity card, 5. shoe”. The sequence is 5 items long, which is more than the minimum length of 4, so we split it. Half of 5 is $5 / 2 = 2 . 5$ . Dropping the decimal, we get that the first half will be 2 items long, ending in $^ { \circ \circ } 2$ . button”. The first half (2 items) is ”1. driving license, 2. button”. The first half of the sequence ends with $^ { \circ \circ } 2$ . button”, so the second half starts after ”2. button” with ”3. packet”. The full sequence is 5 items long, and the first half is 2 items long, so the second half will be $5 - 2 = 3$ items long. The second half of the sequence (3 items) is ”3. packet, 4. identity card, 5. shoe”. Removing the numbers from ”1. driving license, 2. button”, we get ”driving license, button”. Removing the numbers from ”3. packet, 4. identity card, 5. shoe”, we get ”packet, identity card, shoe”. Reversing the sequence ”driving license, button”, First is driving license. Second is button. Now to reverse, change the order to: Second is button. First is driving license. So the answer is ”button, driving license”. Reversing the sequence ”packet, identity card, shoe”, First is packet. Second is identity card. Third is shoe. Now to reverse, change the order to: Third is shoe. Second is identity card. First is packet. So the answer is ”shoe, identity card, packet”. Joining ”shoe, identity card, packet” and ”button, driving license”, the answer is ”shoe, identity card, packet, button, driving license”. + +A: ”shoe, identity card, packet, button, driving license” + +QS: [EOQ] + +QC: Reverse the sequence ”laptop, photo, clip”. + +QS: The sequence is ”1. laptop, 2. photo, 3. clip”. The sequence is 3 items long, which is less than the minimum length of 4, so we don’t need to split it. All we need to do is reverse ”laptop, photo, clip”. First is laptop. Second is photo. Third is clip. Now to reverse, change the order to : Third is clip. Second is photo. First is laptop. So the answer is ”clip, photo, laptop”. + +A: ”clip, photo, laptop” QS: [EOQ] + +QC: Reverse the sequence ”newspaper, glasses, laptop, bottle”. + +QS: The sequence is ”1. newspaper, 2. glasses, 3. laptop, 4. bottle”. The sequence is 4 items long, which is equal to the minimum length of 4, so we split it. Half of 4 is $4 / 2 = 2 . 0$ . Dropping the decimal, we get that the first half will be 2 items long, ending in ”2. glasses”. The first half (2 items) is ”1. newspaper, 2. glasses”. The first half of the sequence ends with $^ { \circ \circ } 2$ . glasses”, so the second half starts after ”2. glasses” with ”3. laptop”. The full sequence is 4 items long, and the first half is 2 items long, so the second half will be $4 - 2 = 2$ items long. The second half of the sequence (2 items) is ”3. laptop, 4. bottle”. Removing the numbers from ”1. newspaper, 2. glasses”, we get ”newspaper, glasses”. Removing the numbers from ”3. laptop, 4. bottle”, we get ”laptop, bottle”. Reversing the sequence ”newspaper, glasses”, First is newspaper. Second is glasses. Now to reverse, change the order to: Second is glasses. First is newspaper. So the answer is ”glasses, newspaper”. Reversing the sequence ”laptop, bottle”, First is laptop. Second is bottle. Now to reverse, change the order to: Second is bottle. First is laptop. So the answer is ”bottle, laptop”. Joining ”bottle, laptop” and ”glasses, newspaper”, the answer is ”bottle, laptop, glasses, newspaper”. + +A: ”bottle, laptop, glasses, newspaper” QS: [EOQ] + +# reverse (tail) + +C: Reverse the sequence ”driving license, button, packet, identity card, shoe”. + +Q1: [extract] The sequence is ”1. driving license, 2. button, 3. packet, 4. identity card, 5. shoe”. The sequence is 5 items long, which is more than the minimum length of 4, so we split it. We take the first element in the sequence which is ”1. driving license”. + +#1: ”1. driving license” + +Q2: [extract] The full sequence is 5 items long, so the remaining sequence will be $5 - 1 = 4$ items long. The tail of the sequence with 4 items is ”2. button, 3. packet, 4. identity card, 5. shoe”. + +#2: ”2. button, 3. packet, 4. identity card, 5. shoe” + +Q3: [remove numbers] Remove the numbers from #1. + +#3: ”driving license” + +Q4: [remove numbers] Remove the numbers from #2. + +#4: ”button, packet, identity card, shoe” + +Q5: [reverse] Reverse the sequence #4. + +#5: ”shoe, identity card, packet, button” + +Q6: [join] #5 #3 + +#6: ”shoe, identity card, packet, button, driving license” + +Q7: [EOQ] + +QC: Reverse the sequence ”laptop, photo, clip”. + +Q1: [extract] The sequence is ”1. laptop, 2. photo, 3. clip”. The sequence is 3 items long, which is less than the minimum length of 4, so we don’t need to split it. All we need to do is reverse ” laptop, photo, clip”. + +#1: ”laptop, photo, clip” + +Q2: [cot] Reverse the sequence #1. + +#2: ”clip, photo, laptop” + +Q3: [EOQ] + +QC: Reverse the sequence ”newspaper, glasses, laptop, bottle”. + +Q1: [extract] The sequence is ”1. newspaper, 2. glasses, 3. laptop, 4. bottle”. The sequence is 4 items long, which is more than the minimum length of 4, so we split it. We take the first element in the sequence which is ”1. newspaper”. + +#1: ”1. newspaper” + +Q2: [extract] The full sequence is 4 items long, so the remaining sequence will be $4 - 1 = 3$ items long. The tail of the sequence with 3 items is ”2. glasses, 3. laptop, 4. bottle”. + +#2: ”2. glasses, 3. laptop, 4. bottle” + +Q3: [remove numbers] Remove the numbers from #1. + +#3: ”newspaper” + +Q4: [remove numbers] Remove the numbers from #2. + +#4: ”glasses, laptop, bottle” + +Q5: [reverse] Reverse the sequence #4. + +#5: ”bottle, laptop, glasses” + +Q6: [join] #5 #3 + +# G.3 LONG-DOCUMENT QA + +We show one of the prompts used for CommaQA experiments here. The entire set of prompts is provided as supplemetary material. + +# G.3.1 DECOMPOSED PROMPTING: (COARSE) + +decomp What awards have movies produced by people born in 1910 won? QS: (select) [qa] Who were born in the year 1910? A: [”Teeplemole”, ”Muntaril”] QS: (project values flat unique) [qa] For which movies was #1 the producer? A: [”Featsaw”, ”Zalate”, ”Premercy”] QS: (project values flat unique) [qa] Which awards were given to #2? A: [”Zorgion”, ”Chowwurst”, ”Hallowcock”] QS: [EOQ] QC: What movies have people from the country Stridery acted in? QS: (select) [qa] Who is from the country Stridery? A: [”Gastrat”] QS: (project values flat unique) [qa] Which movies has #1 been an actor in? A: [”Partnershipmaker”, ”Nilitude”, ”Warpstone”] QS: [EOQ] QC: What awards have the actors of the Erowid winning movies received? QS: (select) [qa] Which movies were given the Erowid award? A: [”Dewbar”, ”Caudacite”] QS: (project values flat unique) [qa] Who are the actors in the movie #1? A: [”Wetherality”, ”Lougeriere”, ”Gigabut”] \` QS: (project values flat unique) [qa] Which awards were given to #2? A: [”Aniconder”, ”Trifogation”] QS: [EOQ] QC: What awards did the movies directed by the Modiparity winners receive? QS: (select) [qa] Who has been awarded the Modiparity award? A: [”Bioperatology”] QS: (project values flat unique) [qa] Which movies has #1 directed? A: [”Pestok”, ”Vitrilateral”] QS: (project values flat unique) [qa] Which awards were given to #2? A: [”Gutney”, ”Antipositive”] QS: [EOQ] QC: What awards have movies written by people born in 1935 won? QS: (select) [qa] Who were born in the year 1935? A: [”Sclerocybin”, ”Zayage”] QS: (project values flat unique) [qa] What movies has #1 written? A: [”Noenometer”, ”Tayenne”, ”Pneumodendron”] QS: (project values flat unique) [qa] Which awards were given to #2? A: [”Brownbeard”, ”Goosehead”, ”Handt”] QS: [EOQ] QC: What movies have the directors from Legault directed? QS: (select) [qa] Who is from the country Legault? A: [”Metatoun”, ”Sapien”] QS: (project values flat unique) [qa] What movies has #1 been the director of? A: [”Coacheship”, ”Misapportionment”] QS: [EOQ] + +movie: Premercy ; directed by: Muntaril. movie: Skirtsicine ; director: Teeplemole. movie: Featsaw ; directed by: Monsterscar. movie: Zalate ; director: Monsterscar. movie: Zalate ; awarded: Hallowcock. movie: Featsaw ; awarded: Zorgion. movie: Premercy ; award: Chowwurst. movie: Skirtsicine ; award: Hallowcock. award: Goatfly ; winner: Teeplemole. person: Monsterscar ; award: Glodome. person: Muntaril ; award: Goatfly. movie: Featsaw ; release year: 1973. movie: Zalate ; release year: 1964. movie: Skirtsicine ; release year: 1973. movie: Premercy ; year: 1961. Teeplemole was an actor in the movie Skirtsicine. Muntaril was an actor in the movie Skirtsicine. Monsterscar was an actor in the movie Premercy. Muntaril was an actor in the movie Featsaw. Teeplemole was an actor in the movie Zalate. Muntaril was born in the year 1910. Teeplemole was born in 1910. Monsterscar was born in 1942. Teeplemole is from the country of Piperfish. Monsterscar is from the country of Piperfish. Muntaril is from the country of Clony. Muntaril produced the movie Skirtsicine with others. Monsterscar was one of the producers of the movie Featsaw. Monsterscar produced the movie Premercy with others. Monsterscar produced the movie Zalate with others. Teeplemole was one of the producers of the movie Featsaw. Teeplemole produced the movie Zalate with others. Muntaril produced the movie Premercy with others. Monsterscar wrote for the movie Premercy. Muntaril was one of the writers for the movie Zalate. Muntaril wrote for the movie Featsaw. Teeplemole wrote for the movie Featsaw. Monsterscar was one of the writers for the movie Zalate. Teeplemole was one of the writers for the movie Skirtsicine. + +Q: For which movies was Teeplemole the producer? + +A: [”Featsaw”, ”Zalate”] + +Q: Which awards were given to Featsaw? + +A: [”Zorgion”] + +movie: Misgendery ; directed by: Wetherality. movie: Dewbar ; director: Gigabut. movie: Caudacite ; director: Lougeriere. movie: Tayenne ; directed by: Lougeri \` ere. movie: \` Misgendery ; awarded: Microsouenesis. movie: Dewbar ; awarded: Erowid. movie: Tayenne ; awarded: Cockspit. movie: Caudacite ; award: Erowid. award: Aniconder ; winner: Wetherality. award: Aniconder ; winner: Lougeriere. person: Gigabut ; award: Trifogation. \` movie: Dewbar ; release year: 1991. movie: Tayenne ; year: 2013. movie: Caudacite ; release year: 2008. movie: Misgendery ; year: 1991. Wetherality was an actor in the movie Dewbar. Gigabut was an actor in the movie Tayenne. Lougeriere was an actor in the movie Tayenne. \` Lougeriere acted in the movie Caudacite. Lougeri \` ere acted in the movie Misgendery. Gigabut \` was an actor in the movie Caudacite. Wetherality was an actor in the movie Misgendery. Wetherality was born in the year 1917. Lougeriere was born in 1926. Gigabut was born in the \` year 1917. Gigabut grew up in the nation of Triclops. Lougeriere is from the country of Tatkin \` . Wetherality grew up in the nation of Tatkin. Lougeriere produced the movie Dewbar with \` others. Gigabut produced the movie Tayenne with others. Gigabut produced the movie Dewbar with others. Lougeriere was one of the producers of the movie Misgendery. \` Wetherality was one of the producers of the movie Caudacite. Gigabut was one of the producers of the movie Caudacite. Wetherality produced the movie Misgendery with others. Wetherality produced the movie Tayenne with others. Wetherality wrote for the movie Tayenne. Gigabut wrote for the movie Misgendery. Lougeriere was one of the writers for the \` movie Caudacite. Wetherality wrote for the movie Misgendery. Gigabut wrote for the movie Tayenne. Gigabut wrote for the movie Dewbar. Lougeriere wrote for the movie Dewbar. \` + +Wetherality wrote for the movie Caudacite. + +Q: Who are the actors in the movie Caudacite? + +A: [”Lougeriere, ”Gigabut”] \` + +Q: Which movies were given the Erowid award? + +A: [”Dewbar”, ”Caudacite”] + +movie: Pastillobox ; directed by: Firmline. movie: Clenestration ; directed by: Carblock. movie: Pestok ; directed by: Bioperatology. movie: Vitrilateral ; director: Bioperatology. movie: Vitrilateral ; award: Antipositive. movie: Clenestration ; awarded: Handt. movie: Pastillobox ; awarded: Handt. movie: Pestok ; awarded: Gutney. movie: Pestok ; writer: Firmline. movie: + +Clenestration ; written by: Carblock. movie: Pastillobox ; written by: Bioperatology. movie: Pestok ; writer: Bioperatology. movie: Clenestration ; written by: Firmline. movie: Vitrilateral ; writer: Bioperatology. movie: Pastillobox ; writer: Carblock. movie: Vitrilateral ; written by : Carblock. movie: Pestok ; release year: 1986. movie: Clenestration ; year: 1986. movie: Vitrilateral ; year: 1999. movie: Pastillobox ; release year: 1984. Carblock was an actor in the movie Pastillobox. Firmline was an actor in the movie Vitrilateral. Bioperatology was an actor in the movie Clenestration. Firmline acted in the movie Pastillobox. Carblock was an actor in the movie Clenestration. Bioperatology was an actor in the movie Pestok. Firmline was born in the year 1904. Bioperatology was born in the year 1935. Carblock was born in 1935. Carblock grew up in the nation of Knoppock. Firmline grew up in the nation of Tatkin. Bioperatology grew up in the nation of Tatkin. Bioperatology won the Modiparity award. Halfbill was awarded to Firmline. Halfbill was awarded to Carblock. Bioperatology was one of the producers of the movie Pestok. Bioperatology produced the movie Vitrilateral with others. Firmline produced the movie Pastillobox with others. Firmline produced the movie Clenestration with others. Carblock was one of the producers of the movie Pastillobox. Carblock produced the movie Vitrilateral with others. Carblock produced the movie Clenestration with others. Firmline was one of the producers of the movie Pestok. + +Q: Who has been awarded the Modiparity award? + +A: [”Bioperatology”] + +Q: Which movies has Bioperatology directed? + +A: [”Pestok”, ”Vitrilateral”] + +movie: Nohit ; director: Mimicocycle. movie: Noenometer ; director: Mimicocycle. movie: Tayenne ; directed by: Zayage. movie: Pneumodendron ; director: Sclerocybin. movie: Tayenne ; awarded: Goosehead. movie: Nohit ; awarded: Handt. movie: Pneumodendron ; award: Handt. movie: Noenometer ; awarded: Brownbeard. movie: Nohit ; writer: Mimicocycle. movie: Noenometer ; written by: Sclerocybin. movie: Tayenne ; writer: Sclerocybin. movie: Pneumodendron ; written by: Zayage. movie: Tayenne ; writer: Zayage. movie: Pneumodendron ; written by: Mimicocycle. movie: Noenometer ; release year: 1991. movie: Tayenne ; year: 2013. movie: Nohit ; year: 2005. movie: Pneumodendron ; year: 2005. Mimicocycle was an actor in the movie Tayenne. Zayage acted in the movie Pneumodendron. Zayage was an actor in the movie Nohit. Sclerocybin was an actor in the movie Nohit. Sclerocybin was an actor in the movie Tayenne. Mimicocycle was an actor in the movie Noenometer. Zayage was born in 1935. Sclerocybin was born in 1935. Mimicocycle was born in 1930. Mimicocycle is from the country of Calderita. Sclerocybin grew up in the nation of Calderita. Zayage is from the country of Obility. Quinion was awarded to Zayage. Fannyxist was awarded to Sclerocybin. Fannyxist was awarded to Mimicocycle. Mimicocycle produced the movie Nohit with others. Zayage was one of the producers of the movie Nohit. Sclerocybin was one of the producers of the movie Tayenne. Sclerocybin produced the movie Pneumodendron with others. Zayage produced the movie Pneumodendron with others. Mimicocycle was one of the producers of the movie Tayenne. Sclerocybin was one of the producers of the movie Noenometer. Zayage produced the movie Noenometer with others + +Q: What movies has Sclerocybin written? + +A: [”Noenometer”, ”Tayenne”] + +Q: Who were born in the year 1935? A: [”Sclerocybin”, ”Zayage”] + +# G.3.2 DECOMPOSED PROMPTING: (FINE) + +decomp What awards have movies produced by people born in 1910 won? QS: (select) [simp qa] Who were born in the year 1910? A: [”Teeplemole”, ”Muntaril”] QS: (project values flat unique) [pos qa] For which movies was #1 the producer? A: [”Featsaw”, ”Zalate”, ”Premercy”] QS: (project values flat unique) [aw qa] Which awards were given to #2? A: [”Zorgion”, ”Chowwurst”, ”Hallowcock”] + +QS: [EOQ] + +QC: What movies have people from the country Stridery acted in? +QS: (select) [simp qa] Who is from the country Stridery? +A: [”Gastrat”] +QS: (project values flat unique) [pos qa] Which movies has #1 been an actor in? +A: [”Partnershipmaker”, ”Nilitude”, ”Warpstone”] +QS: [EOQ] +QC: What awards have the actors of the Erowid winning movies received? +QS: (select) [aw qa] Which movies were given the Erowid award? +A: [”Dewbar”, ”Caudacite”] +QS: (project values flat unique) [pos qa] Who are the actors in the movie #1? +A: [”Wetherality”, ”Lougeriere”, ”Gigabut”] \` +QS: (project values flat unique) [aw qa] Which awards were given to #2? +A: [”Aniconder”, ”Trifogation”] +QS: [EOQ] +QC: What awards did the movies directed by the Modiparity winners receive? +QS: (select) [aw qa] Who has been awarded the Modiparity award? +A: [”Bioperatology”] +QS: (project values flat unique) [pos qa] Which movies has #1 directed? +A: [”Pestok”, ”Vitrilateral”] +QS: (project values flat unique) [aw qa] Which awards were given to #2? +A: [”Gutney”, ”Antipositive”] +QS: [EOQ] +QC: What awards have movies written by people born in 1935 won? +QS: (select) [simp qa] Who were born in the year 1935? +A: [”Sclerocybin”, ”Zayage”] +QS: (project values flat unique) [pos qa] What movies has #1 written? +A: [”Noenometer”, ”Tayenne”, ”Pneumodendron”] +QS: (project values flat unique) [aw qa] Which awards were given to #2? +A: [”Brownbeard”, ”Goosehead”, ”Handt”] +QS: [EOQ] +QC: What movies have the directors from Legault directed? +QS: (select) [simp qa] Who is from the country Legault? +A: [”Metatoun”, ”Sapien”] +QS: (project values flat unique) [pos qa] What movies has #1 been the director of? +A: [”Coacheship”, ”Misapportionment”] +QS: [EOQ] + +aw qa + +movie: Premercy ; directed by: Muntaril. movie: Skirtsicine ; director: Teeplemole. movie: Featsaw ; directed by: Monsterscar. movie: Zalate ; director: Monsterscar. movie: Zalate ; awarded: Hallowcock. movie: Featsaw ; awarded: Zorgion. movie: Premercy ; award: Chowwurst. movie: Skirtsicine ; award: Hallowcock. award: Goatfly ; winner: Teeplemole. person: Monsterscar ; award: Glodome. person: Muntaril ; award: Goatfly. movie: Featsaw ; release year: 1973. movie: Zalate ; release year: 1964. movie: Skirtsicine ; release year: 1973. movie: Premercy ; year: 1961. Teeplemole was an actor in the movie Skirtsicine. Muntaril was an actor in the movie Skirtsicine. Monsterscar was an actor in the movie Premercy. Muntaril was an actor in the movie Featsaw. Teeplemole was an actor in the movie Zalate. Muntaril was born in the year 1910. Teeplemole was born in 1910. Monsterscar was born in 1942. Teeplemole is from the country of Piperfish. Monsterscar is from the country of Piperfish. Muntaril is from the country of Clony. Muntaril produced the movie Skirtsicine with others. Monsterscar was one of the producers of the movie Featsaw. Monsterscar produced the movie Premercy with others. Monsterscar produced the movie Zalate with others. Teeplemole was one of the producers of the movie Featsaw. Teeplemole produced the movie Zalate with + +others. Muntaril produced the movie Premercy with others. Monsterscar wrote for the movie Premercy. Muntaril was one of the writers for the movie Zalate. Muntaril wrote for the movie Featsaw. Teeplemole wrote for the movie Featsaw. Monsterscar was one of the writers for the movie Zalate. Teeplemole was one of the writers for the movie Skirtsicine. + +Q: Which awards were given to Zalate? + +A: [”Hallowcock”] + +Q: Which awards were given to Featsaw? + +A: [”Zorgion”] + +movie: Misgendery ; directed by: Wetherality. movie: Dewbar ; director: Gigabut. movie: Caudacite ; director: Lougeriere. movie: Tayenne ; directed by: Lougeri \` ere. movie: \` Misgendery ; awarded: Microsouenesis. movie: Dewbar ; awarded: Erowid. movie: Tayenne ; awarded: Cockspit. movie: Caudacite ; award: Erowid. award: Aniconder ; winner: Wetherality. award: Aniconder ; winner: Lougeriere. person: Gigabut ; award: Trifogation. \` movie: Dewbar ; release year: 1991. movie: Tayenne ; year: 2013. movie: Caudacite ; release year: 2008. movie: Misgendery ; year: 1991. Wetherality was an actor in the movie Dewbar. Gigabut was an actor in the movie Tayenne. Lougeriere was an actor in the movie Tayenne. \` Lougeriere acted in the movie Caudacite. Lougeri \` ere acted in the movie Misgendery. Gigabut \` was an actor in the movie Caudacite. Wetherality was an actor in the movie Misgendery. Wetherality was born in the year 1917. Lougeriere was born in 1926. Gigabut was born in the \` year 1917. Gigabut grew up in the nation of Triclops. Lougeriere is from the country of Tatkin \` . Wetherality grew up in the nation of Tatkin. Lougeriere produced the movie Dewbar with \` others. Gigabut produced the movie Tayenne with others. Gigabut produced the movie Dewbar with others. Lougeriere was one of the producers of the movie Misgendery. \` Wetherality was one of the producers of the movie Caudacite. Gigabut was one of the producers of the movie Caudacite. Wetherality produced the movie Misgendery with others. Wetherality produced the movie Tayenne with others. Wetherality wrote for the movie Tayenne. Gigabut wrote for the movie Misgendery. Lougeriere was one of the writers for the \` movie Caudacite. Wetherality wrote for the movie Misgendery. Gigabut wrote for the movie Tayenne. Gigabut wrote for the movie Dewbar. Lougeriere wrote for the movie Dewbar. \` + +Wetherality wrote for the movie Caudacite. + +Q: Which movies were given the Erowid award? + +A: [”Dewbar”, ”Caudacite”] + +Q: Which awards were given to Wetherality? + +A: [”Aniconder”] + +ovie: Pastillobox ; directed by: Firmline. movie: Clenestration ; directed by: Carblock. movie: Pestok ; directed by: Bioperatology. movie: Vitrilateral ; director: Bioperatology. movie: Vitrilateral ; award: Antipositive. movie: Clenestration ; awarded: Handt. movie: Pastillobox ; awarded: Handt. movie: Pestok ; awarded: Gutney. movie: Pestok ; writer: Firmline. movie: Clenestration ; written by: Carblock. movie: Pastillobox ; written by: Bioperatology. movie: Pestok ; writer: Bioperatology. movie: Clenestration ; written by: Firmline. movie: Vitrilateral ; writer: Bioperatology. movie: Pastillobox ; writer: Carblock. movie: Vitrilateral ; written by : Carblock. movie: Pestok ; release year: 1986. movie: Clenestration ; year: 1986. movie: Vitrilateral ; year: 1999. movie: Pastillobox ; release year: 1984. Carblock was an actor in the movie Pastillobox. Firmline was an actor in the movie Vitrilateral. Bioperatology was an actor in the movie Clenestration. Firmline acted in the movie Pastillobox. Carblock was an actor in the movie Clenestration. Bioperatology was an actor in the movie Pestok. Firmline was born in the year 1904. Bioperatology was born in the year 1935. Carblock was born in 1935. Carblock grew up in the nation of Knoppock. Firmline grew up in the nation of Tatkin. Bioperatology grew up in the nation of Tatkin. Bioperatology won the Modiparity award. Halfbill was awarded to Firmline. Halfbill was awarded to Carblock. Bioperatology was one of the producers of the movie Pestok. Bioperatology produced the movie Vitrilateral with others. Firmline produced the movie Pastillobox with others. Firmline produced the movie Clenestration with others. Carblock was one of the producers of the movie Pastillobox. Carblock produced the movie Vitrilateral with others. Carblock produced the movie Clenestration with others. Firmline was one of the producers of the movie Pestok. + +Q: Who has been awarded the Modiparity award? + +A: [”Bioperatology”] + +Q: Which awards were given to Pestok? + +A: [”Gutney”] + +movie: Nohit ; director: Mimicocycle. movie: Noenometer ; director: Mimicocycle. movie: Tayenne ; directed by: Zayage. movie: Pneumodendron ; director: Sclerocybin. movie: Tayenne ; awarded: Goosehead. movie: Nohit ; awarded: Handt. movie: Pneumodendron ; award: Handt. movie: Noenometer ; awarded: Brownbeard. movie: Nohit ; writer: Mimicocycle. movie: Noenometer ; written by: Sclerocybin. movie: Tayenne ; writer: Sclerocybin. movie: Pneumodendron ; written by: Zayage. movie: Tayenne ; writer: Zayage. movie: Pneumodendron ; written by: Mimicocycle. movie: Noenometer ; release year: 1991. movie: Tayenne ; year: 2013. movie: Nohit ; year: 2005. movie: Pneumodendron ; year: 2005. Mimicocycle was an actor in the movie Tayenne. Zayage acted in the movie Pneumodendron. Zayage was an actor in the movie Nohit. Sclerocybin was an actor in the movie Nohit. Sclerocybin was an actor in the movie Tayenne. Mimicocycle was an actor in the movie Noenometer. Zayage was born in 1935. Sclerocybin was born in 1935. Mimicocycle was born in 1930. Mimicocycle is from the country of Calderita. Sclerocybin grew up in the nation of Calderita. Zayage is from the country of Obility. Quinion was awarded to Zayage. Fannyxist was awarded to Sclerocybin. Fannyxist was awarded to Mimicocycle. Mimicocycle produced the movie Nohit with others. Zayage was one of the producers of the movie Nohit. Sclerocybin was one of the producers of the movie Tayenne. Sclerocybin produced the movie Pneumodendron with others. Zayage produced the movie Pneumodendron with others. Mimicocycle was one of the producers of the movie Tayenne. Sclerocybin was one of the producers of the movie Noenometer. Zayage produced the movie Noenometer with others + +Q: Which awards were given to Noenometer? + +A: [”Brownbeard”] + +Q: Which awards were given to Pneumodendron? + +A: [”Handt”] pos qa + +movie: Premercy ; directed by: Muntaril. movie: Skirtsicine ; director: Teeplemole. movie: Featsaw ; directed by: Monsterscar. movie: Zalate ; director: Monsterscar. movie: Zalate ; awarded: Hallowcock. movie: Featsaw ; awarded: Zorgion. movie: Premercy ; award: Chowwurst. movie: Skirtsicine ; award: Hallowcock. award: Goatfly ; winner: Teeplemole. person: Monsterscar ; award: Glodome. person: Muntaril ; award: Goatfly. movie: Featsaw ; release year: 1973. movie: Zalate ; release year: 1964. movie: Skirtsicine ; release year: 1973. movie: Premercy ; year: 1961. Teeplemole was an actor in the movie Skirtsicine. Muntaril was an actor in the movie Skirtsicine. Monsterscar was an actor in the movie Premercy. Muntaril was an actor in the movie Featsaw. Teeplemole was an actor in the movie Zalate. Muntaril was born in the year 1910. Teeplemole was born in 1910. Monsterscar was born in 1942. Teeplemole is from the country of Piperfish. Monsterscar is from the country of Piperfish. Muntaril is from the country of Clony. Muntaril produced the movie Skirtsicine with others. Monsterscar was one of the producers of the movie Featsaw. Monsterscar produced the movie Premercy with others. Monsterscar produced the movie Zalate with others. Teeplemole was one of the producers of the movie Featsaw. Teeplemole produced the movie Zalate with others. Muntaril produced the movie Premercy with others. Monsterscar wrote for the movie Premercy. Muntaril was one of the writers for the movie Zalate. Muntaril wrote for the movie Featsaw. Teeplemole wrote for the movie Featsaw. Monsterscar was one of the writers for the movie Zalate. Teeplemole was one of the writers for the movie Skirtsicine. + +Q: For which movies was Teeplemole the producer? + +A: [”Featsaw”, ”Zalate”] + +Q: For which movies was Muntaril the producer? + +A: [”Premercy] + +vie: Misgendery ; directed by: Wetherality. movie: Dewbar ; director: Gigabut. movie: Caudacite ; director: Lougeriere. movie: Tayenne ; directed by: Lougeri \` ere. movie: \` Misgendery ; awarded: Microsouenesis. movie: Dewbar ; awarded: Erowid. movie: Tayenne ; awarded: Cockspit. movie: Caudacite ; award: Erowid. award: Aniconder ; winner: Wetherality. award: Aniconder ; winner: Lougeriere. person: Gigabut ; award: Trifogation. \` movie: Dewbar ; release year: 1991. movie: Tayenne ; year: 2013. movie: Caudacite ; release year: 2008. movie: Misgendery ; year: 1991. Wetherality was an actor in the movie Dewbar. Gigabut was an actor in the movie Tayenne. Lougeriere was an actor in the movie Tayenne. \` Lougeriere acted in the movie Caudacite. Lougeri \` ere acted in the movie Misgendery. Gigabut \` was an actor in the movie Caudacite. Wetherality was an actor in the movie Misgendery. Wetherality was born in the year 1917. Lougeriere was born in 1926. Gigabut was born in the \` year 1917. Gigabut grew up in the nation of Triclops. Lougeriere is from the country of Tatkin \` . Wetherality grew up in the nation of Tatkin. Lougeriere produced the movie Dewbar with \` others. Gigabut produced the movie Tayenne with others. Gigabut produced the movie Dewbar with others. Lougeriere was one of the producers of the movie Misgendery. \` Wetherality was one of the producers of the movie Caudacite. Gigabut was one of the producers of the movie Caudacite. Wetherality produced the movie Misgendery with others. Wetherality produced the movie Tayenne with others. Wetherality wrote for the movie Tayenne. Gigabut wrote for the movie Misgendery. Lougeriere was one of the writers for the \` movie Caudacite. Wetherality wrote for the movie Misgendery. Gigabut wrote for the movie Tayenne. Gigabut wrote for the movie Dewbar. Lougeriere wrote for the movie Dewbar. \` + +Q: Who are the actors in the movie Dewbar? + +A: [”Wetherality”] + +Q: Who are the actors in the movie Caudacite? + +A: [”Lougeriere, ”Gigabut”] \` + +movie: Pastillobox ; directed by: Firmline. movie: Clenestration ; directed by: Carblock. movie: Pestok ; directed by: Bioperatology. movie: Vitrilateral ; director: Bioperatology. movie: Vitrilateral ; award: Antipositive. movie: Clenestration ; awarded: Handt. movie: Pastillobox ; awarded: Handt. movie: Pestok ; awarded: Gutney. movie: Pestok ; writer: Firmline. movie: Clenestration ; written by: Carblock. movie: Pastillobox ; written by: Bioperatology. movie: Pestok ; writer: Bioperatology. movie: Clenestration ; written by: Firmline. movie: Vitrilateral ; writer: Bioperatology. movie: Pastillobox ; writer: Carblock. movie: Vitrilateral ; written by : Carblock. movie: Pestok ; release year: 1986. movie: Clenestration ; year: 1986. movie: Vitrilateral ; year: 1999. movie: Pastillobox ; release year: 1984. Carblock was an actor in the movie Pastillobox. Firmline was an actor in the movie Vitrilateral. Bioperatology was an actor in the movie Clenestration. Firmline acted in the movie Pastillobox. Carblock was an actor in the movie Clenestration. Bioperatology was an actor in the movie Pestok. Firmline was born in the year 1904. Bioperatology was born in the year 1935. Carblock was born in 1935. Carblock grew up in the nation of Knoppock. Firmline grew up in the nation of Tatkin. Bioperatology grew up in the nation of Tatkin. Bioperatology won the Modiparity award. Halfbill was awarded to Firmline. Halfbill was awarded to Carblock. Bioperatology was one of the producers of the movie Pestok. Bioperatology produced the movie Vitrilateral with others. Firmline produced the movie Pastillobox with others. Firmline produced the movie Clenestration with others. Carblock was one of the producers of the movie Pastillobox. Carblock produced the movie Vitrilateral with others. Carblock produced the movie Clenestration with others. Firmline was one of the producers of the movie Pestok. + +Q: Which movies has Bioperatology directed? + +A: [”Pestok”, ”Vitrilateral”] + +Q: Which movies has Carblock directed? A: [”Clenestration”] + +movie: Nohit ; director: Mimicocycle. movie: Noenometer ; director: Mimicocycle. movie: Tayenne ; directed by: Zayage. movie: Pneumodendron ; director: Sclerocybin. movie: Tayenne ; awarded: Goosehead. movie: Nohit ; awarded: Handt. movie: Pneumodendron ; award: Handt. movie: Noenometer ; awarded: Brownbeard. movie: Nohit ; writer: + +Mimicocycle. movie: Noenometer ; written by: Sclerocybin. movie: Tayenne ; writer: Sclerocybin. movie: Pneumodendron ; written by: Zayage. movie: Tayenne ; writer: Zayage. movie: Pneumodendron ; written by: Mimicocycle. movie: Noenometer ; release year: 1991. movie: Tayenne ; year: 2013. movie: Nohit ; year: 2005. movie: Pneumodendron ; year: 2005. Mimicocycle was an actor in the movie Tayenne. Zayage acted in the movie Pneumodendron. Zayage was an actor in the movie Nohit. Sclerocybin was an actor in the movie Nohit. Sclerocybin was an actor in the movie Tayenne. Mimicocycle was an actor in the movie Noenometer. Zayage was born in 1935. Sclerocybin was born in 1935. Mimicocycle was born in 1930. Mimicocycle is from the country of Calderita. Sclerocybin grew up in the nation of Calderita. Zayage is from the country of Obility. Quinion was awarded to Zayage. Fannyxist was awarded to Sclerocybin. Fannyxist was awarded to Mimicocycle. Mimicocycle produced the movie Nohit with others. Zayage was one of the producers of the movie Nohit. Sclerocybin was one of the producers of the movie Tayenne. Sclerocybin produced the movie Pneumodendron with others. Zayage produced the movie Pneumodendron with others. Mimicocycle was one of the producers of the movie Tayenne. Sclerocybin was one of the producers of the movie Noenometer. Zayage produced the movie Noenometer with others + +Q: What movies has Sclerocybin written? + +A: [”Noenometer”, ”Tayenne”] + +Q: What movies has Zayage written? + +A: [”Pneumodendron”, ”Tayenne”] + +simp qa + +movie: Premercy ; directed by: Muntaril. movie: Skirtsicine ; director: Teeplemole. movie: Featsaw ; directed by: Monsterscar. movie: Zalate ; director: Monsterscar. movie: Zalate ; awarded: Hallowcock. movie: Featsaw ; awarded: Zorgion. movie: Premercy ; award: Chowwurst. movie: Skirtsicine ; award: Hallowcock. award: Goatfly ; winner: Teeplemole. person: Monsterscar ; award: Glodome. person: Muntaril ; award: Goatfly. movie: Featsaw ; release year: 1973. movie: Zalate ; release year: 1964. movie: Skirtsicine ; release year: 1973. movie: Premercy ; year: 1961. Teeplemole was an actor in the movie Skirtsicine. Muntaril was an actor in the movie Skirtsicine. Monsterscar was an actor in the movie Premercy. Muntaril was an actor in the movie Featsaw. Teeplemole was an actor in the movie Zalate. Muntaril was born in the year 1910. Teeplemole was born in 1910. Monsterscar was born in 1942. Teeplemole is from the country of Piperfish. Monsterscar is from the country of Piperfish. Muntaril is from the country of Clony. Muntaril produced the movie Skirtsicine with others. Monsterscar was one of the producers of the movie Featsaw. Monsterscar produced the movie Premercy with others. Monsterscar produced the movie Zalate with others. Teeplemole was one of the producers of the movie Featsaw. Teeplemole produced the movie Zalate with others. Muntaril produced the movie Premercy with others. Monsterscar wrote for the movie Premercy. Muntaril was one of the writers for the movie Zalate. Muntaril wrote for the movie Featsaw. Teeplemole wrote for the movie Featsaw. Monsterscar was one of the writers for the movie Zalate. Teeplemole was one of the writers for the movie Skirtsicine. + +Q: Who were born in the year 1910? + +A: [”Teeplemole”, ”Muntaril”] + +Q: From which country is Monsterscar? A: [”Piperfish”] + +movie: Nilitude ; director: Monsterscar. movie: Dewbar ; directed by: Metatoun. movie: Warpstone ; directed by: Gastrat. movie: Partnershipmaker ; director: Metatoun. movie: Dewbar ; award: Tachychronograph. movie: Partnershipmaker ; awarded: Tachychronograph. movie: Nilitude ; award: Paleodactyl. movie: Warpstone ; award: Sabonade. person: Gastrat ; award: Trifogation. award: Polyquadrase ; winner: Monsterscar. award: Trifogation ; winner: Metatoun. movie: Warpstone ; release year: 1956. movie: Dewbar ; release year: 1984. movie: Nilitude ; year: 1984. movie: Partnershipmaker ; year: 1962. Gastrat was an actor in the movie Partnershipmaker. Metatoun was an actor in the movie Partnershipmaker. Metatoun was an actor in the movie Nilitude. Gastrat acted in the movie Nilitude. Monsterscar was an actor in the movie Dewbar. Gastrat acted in the movie Warpstone. Metatoun acted in the movie Warpstone. Metatoun was born in 1939. Gastrat was born in the year 1933. + +Monsterscar was born in 1933. Metatoun grew up in the nation of Moulole. Gastrat is from the country of Stridery. Monsterscar grew up in the nation of Moulole. Monsterscar produced the movie Nilitude with others. Monsterscar was one of the producers of the movie Warpstone . Metatoun was one of the producers of the movie Warpstone. Gastrat was one of the producers of the movie Nilitude. Metatoun produced the movie Partnershipmaker with others. Metatoun produced the movie Dewbar with others. Monsterscar was one of the producers of the movie Partnershipmaker. Gastrat produced the movie Dewbar with others. Metatoun wrote for the movie Partnershipmaker. Gastrat wrote for the movie Warpstone. Gastrat was one of the writers for the movie Dewbar. Monsterscar was one of the writers for the movie Nilitude. Metatoun wrote for the movie Warpstone. + +Q: Who is from the country Stridery? + +A: [”Gastrat”] + +Q: Which movies were released in 1984? + +A: [”Dewbar”, ”Nilitude”] + +movie: Nohit ; director: Mimicocycle. movie: Noenometer ; director: Mimicocycle. movie: Tayenne ; directed by: Zayage. movie: Pneumodendron ; director: Sclerocybin. movie: Tayenne ; awarded: Goosehead. movie: Nohit ; awarded: Handt. movie: Pneumodendron ; award: Handt. movie: Noenometer ; awarded: Brownbeard. movie: Nohit ; writer: Mimicocycle. movie: Noenometer ; written by: Sclerocybin. movie: Tayenne ; writer: Sclerocybin. movie: Pneumodendron ; written by: Zayage. movie: Tayenne ; writer: Zayage. movie: Pneumodendron ; written by: Mimicocycle. movie: Noenometer ; release year: 1991. movie: Tayenne ; year: 2013. movie: Nohit ; year: 2005. movie: Pneumodendron ; year: 2005. Mimicocycle was an actor in the movie Tayenne. Zayage acted in the movie Pneumodendron. Zayage was an actor in the movie Nohit. Sclerocybin was an actor in the movie Nohit. Sclerocybin was an actor in the movie Tayenne. Mimicocycle was an actor in the movie Noenometer. Zayage was born in 1935. Sclerocybin was born in 1935. Mimicocycle was born in 1930. Mimicocycle is from the country of Calderita. Sclerocybin grew up in the nation of Calderita. Zayage is from the country of Obility. Quinion was awarded to Zayage. Fannyxist was awarded to Sclerocybin. Fannyxist was awarded to Mimicocycle. Mimicocycle produced the movie Nohit with others. Zayage was one of the producers of the movie Nohit. Sclerocybin was one of the producers of the movie Tayenne. Sclerocybin produced the movie Pneumodendron with others. Zayage produced the movie Pneumodendron with others. Mimicocycle was one of the producers of the movie Tayenne. Sclerocybin was one of the producers of the movie Noenometer. Zayage produced the movie Noenometer with others + +Q: Who were born in the year 1935? + +A: [”Sclerocybin”, ”Zayage”] + +Q: When was the movie Nohit released? + +A: [”2005”] + +movie: Coacheship ; director: Metatoun. movie: Assamplifier ; director: Kapod. movie: Misapportionment ; director: Sapien. movie: Quinsid ; director: Kapod. movie: Assamplifier ; award: Zorgion. movie: Quinsid ; awarded: Airpipe. movie: Coacheship ; award: Electrodesal. movie: Misapportionment ; award: Airpipe. movie: Coacheship ; written by: Metatoun. movie: Misapportionment ; written by: Kapod. movie: Coacheship ; written by: Kapod. movie : Quinsid ; writer: Sapien. movie: Misapportionment ; written by: Metatoun. movie: Assamplifier ; written by: Kapod. movie: Assamplifier ; written by: Sapien. movie: Assamplifier ; release year: 2000. movie: Coacheship ; year: 2001. movie: Quinsid ; year: 2005. movie: Misapportionment ; year: 2005. Sapien was an actor in the movie Misapportionment. Sapien acted in the movie Assamplifier. Kapod acted in the movie Quinsid . Sapien acted in the movie Coacheship. Metatoun was an actor in the movie Quinsid. Kapod acted in the movie Misapportionment. Metatoun acted in the movie Coacheship. Kapod acted in the movie Assamplifier. Sapien was born in the year 1910. Metatoun was born in 1928. Kapod was born in the year 1910. Metatoun is from the country of Legault. Kapod grew up in the nation of Tatkin. Sapien is from the country of Legault. Malwarp was awarded to Sapien. Metatoun won the Monkeynote award. Kapod won the Monkeynote award. Kapod was one of the producers of the movie Quinsid. Metatoun was one of the producers of the movie + +Misapportionment. Metatoun was one of the producers of the movie Quinsid. Sapien was one of the producers of the movie Assamplifier. Sapien produced the movie Coacheship with others. Metatoun was one of the producers of the movie Assamplifier. Kapod was one of the producers of the movie Misapportionment. Kapod was one of the producers of the movie Coacheship. + +Q: Who is from the country Legault? + +A: [”Metatoun”, ”Sapien”] + +Q: When was Kapod born? A: [”1910”] + +# G.3.3 COT + +# COT + +movie: Premercy ; directed by: Muntaril. movie: Skirtsicine ; director: Teeplemole. movie: Featsaw ; directed by: Monsterscar. movie: Zalate ; director: Monsterscar. movie: Zalate ; awarded: Hallowcock. movie: Featsaw ; awarded: Zorgion. movie: Premercy ; award: Chowwurst. movie: Skirtsicine ; award: Hallowcock. award: Goatfly ; winner: Teeplemole. person: Monsterscar ; award: Glodome. person: Muntaril ; award: Goatfly. movie: Featsaw ; release year: 1973. movie: Zalate ; release year: 1964. movie: Skirtsicine ; release year: 1973. movie: Premercy ; year: 1961. Teeplemole was an actor in the movie Skirtsicine. Muntaril was an actor in the movie Skirtsicine. Monsterscar was an actor in the movie Premercy. Muntaril was an actor in the movie Featsaw. Teeplemole was an actor in the movie Zalate. Muntaril was born in the year 1910. Teeplemole was born in 1910. Monsterscar was born in 1942. Teeplemole is from the country of Piperfish. Monsterscar is from the country of Piperfish. Muntaril is from the country of Clony. Muntaril produced the movie Skirtsicine with others. Monsterscar was one of the producers of the movie Featsaw. Monsterscar produced the movie Premercy with others. Monsterscar produced the movie Zalate with others. Teeplemole was one of the producers of the movie Featsaw. Teeplemole produced the movie Zalate with others. Muntaril produced the movie Premercy with others. Monsterscar wrote for the movie Premercy. Muntaril was one of the writers for the movie Zalate. Muntaril wrote for the movie Featsaw. Teeplemole wrote for the movie Featsaw. Monsterscar was one of the writers for the movie Zalate. Teeplemole was one of the writers for the movie Skirtsicine. + +QC: What awards have movies produced by people born in 1910 won? + +QS: The people born in 1910 were Muntaril and Teeplemole. Teeplemole produced the movies Featsaw and Zalate. Muntaril produced the movie Premercy. Featsaw was awarded the Zorgion award. Premercy was awarded the Chowwurst award. Zalate was awarded the Hallowcock award. So the answer is [”Zorgion”, ”Chowwurst”, ”Hallowcock”]. + +A: [”Zorgion”, ”Chowwurst”, ”Hallowcock”] QS: [EOQ] + +movie: Misgendery ; directed by: Wetherality. movie: Dewbar ; director: Gigabut. movie: Caudacite ; director: Lougeriere. movie: Tayenne ; directed by: Lougeri \` ere. movie: \` Misgendery ; awarded: Microsouenesis. movie: Dewbar ; awarded: Erowid. movie: Tayenne ; awarded: Cockspit. movie: Caudacite ; award: Erowid. award: Aniconder ; winner: Wetherality. award: Aniconder ; winner: Lougeriere. person: Gigabut ; award: Trifogation. \` movie: Dewbar ; release year: 1991. movie: Tayenne ; year: 2013. movie: Caudacite ; release year: 2008. movie: Misgendery ; year: 1991. Wetherality was an actor in the movie Dewbar. Gigabut was an actor in the movie Tayenne. Lougeriere was an actor in the movie Tayenne. \` Lougeriere acted in the movie Caudacite. Lougeri \` ere acted in the movie Misgendery. Gigabut \` was an actor in the movie Caudacite. Wetherality was an actor in the movie Misgendery. Wetherality was born in the year 1917. Lougeriere was born in 1926. Gigabut was born in the\` year 1917. Gigabut grew up in the nation of Triclops. Lougeriere is from the country of Tatkin \` . Wetherality grew up in the nation of Tatkin. Lougeriere produced the movie Dewbar with \` others. Gigabut produced the movie Tayenne with others. Gigabut produced the movie Dewbar with others. Lougeriere was one of the producers of the movie Misgendery. \` Wetherality was one of the producers of the movie Caudacite. Gigabut was one of the producers of the movie Caudacite. Wetherality produced the movie Misgendery with others. Wetherality produced the movie Tayenne with others. Wetherality wrote for the movie + +Tayenne. Gigabut wrote for the movie Misgendery. Lougeriere was one of the writers for the \` movie Caudacite. Wetherality wrote for the movie Misgendery. Gigabut wrote for the movie Tayenne. Gigabut wrote for the movie Dewbar. Lougeriere wrote for the movie Dewbar. \` + +Wetherality wrote for the movie Caudacite. + +QC: What awards have the actors of the Erowid winning movies received? + +QS: The movies that won the Erowid award are Dewbar and Caudacite. Wetherality was an actor in Dewbar. Lougeriere and Gigabut acted in Caudacite. Wetherality won the Aniconder award. \` Lougeriere also won the Aniconder award. Gigabut won the Trifogation award. So the answer \` is [”Aniconder”, ”Trifogation”]. + +A: [”Aniconder”, ”Trifogation”] QS: [EOQ] + +movie: Pastillobox ; directed by: Firmline. movie: Clenestration ; directed by: Carblock. movie: Pestok ; directed by: Bioperatology. movie: Vitrilateral ; director: Bioperatology. movie: Vitrilateral ; award: Antipositive. movie: Clenestration ; awarded: Handt. movie: Pastillobox ; awarded: Handt. movie: Pestok ; awarded: Gutney. movie: Pestok ; writer: Firmline. movie: Clenestration ; written by: Carblock. movie: Pastillobox ; written by: Bioperatology. movie: Pestok ; writer: Bioperatology. movie: Clenestration ; written by: Firmline. movie: Vitrilateral ; writer: Bioperatology. movie: Pastillobox ; writer: Carblock. movie: Vitrilateral ; written by : Carblock. movie: Pestok ; release year: 1986. movie: Clenestration ; year: 1986. movie: + +Vitrilateral ; year: 1999. movie: Pastillobox ; release year: 1984. Carblock was an actor in the movie Pastillobox. Firmline was an actor in the movie Vitrilateral. Bioperatology was an actor in the movie Clenestration. Firmline acted in the movie Pastillobox. Carblock was an actor in the movie Clenestration. Bioperatology was an actor in the movie Pestok. Firmline was born in the year 1904. Bioperatology was born in the year 1935. Carblock was born in 1935. Carblock grew up in the nation of Knoppock. Firmline grew up in the nation of Tatkin. + +Bioperatology grew up in the nation of Tatkin. Bioperatology won the Modiparity award. Halfbill was awarded to Firmline. Halfbill was awarded to Carblock. Bioperatology was one of the producers of the movie Pestok. Bioperatology produced the movie Vitrilateral with others. Firmline produced the movie Pastillobox with others. Firmline produced the movie Clenestration with others. Carblock was one of the producers of the movie Pastillobox. + +Carblock produced the movie Vitrilateral with others. Carblock produced the movie + +Clenestration with others. Firmline was one of the producers of the movie Pestok. + +QC: What awards did the movies directed by the Modiparity winners receive? + +QS: The Modiparity winners are Bioperatology. Bioperatology has directed the movies Pestok and Vitrilateral. Pestok has won the Gutney award. Vitrilateral has won the Antipositive award. So the answer is [”Gutney”, ”Antipositive”]. + +movie: Nohit ; director: Mimicocycle. movie: Noenometer ; director: Mimicocycle. movie: Tayenne ; directed by: Zayage. movie: Pneumodendron ; director: Sclerocybin. movie: Tayenne ; awarded: Goosehead. movie: Nohit ; awarded: Handt. movie: Pneumodendron ; award: Handt. movie: Noenometer ; awarded: Brownbeard. movie: Nohit ; writer: Mimicocycle. movie: Noenometer ; written by: Sclerocybin. movie: Tayenne ; writer: Sclerocybin. movie: Pneumodendron ; written by: Zayage. movie: Tayenne ; writer: Zayage. movie: Pneumodendron ; written by: Mimicocycle. movie: Noenometer ; release year: 1991. movie: Tayenne ; year: 2013. movie: Nohit ; year: 2005. movie: Pneumodendron ; year: 2005. Mimicocycle was an actor in the movie Tayenne. Zayage acted in the movie Pneumodendron. Zayage was an actor in the movie Nohit. Sclerocybin was an actor in the movie Nohit. Sclerocybin was an actor in the movie Tayenne. Mimicocycle was an actor in the movie Noenometer. Zayage was born in 1935. Sclerocybin was born in 1935. Mimicocycle was born in 1930. Mimicocycle is from the country of Calderita. Sclerocybin grew up in the nation of Calderita. Zayage is from the country of Obility. Quinion was awarded to Zayage. Fannyxist was awarded to Sclerocybin. Fannyxist was awarded to Mimicocycle. Mimicocycle produced the movie Nohit with others. Zayage was one of the producers of the movie Nohit. Sclerocybin was one of the producers of the movie Tayenne. Sclerocybin produced the movie Pneumodendron with others. Zayage produced the movie Pneumodendron with others. + +Mimicocycle was one of the producers of the movie Tayenne. Sclerocybin was one of the producers of the movie Noenometer. Zayage produced the movie Noenometer with others QC: What awards have movies written by people born in 1935 won? + +QS: The people born in 1935 were Sclerocybin and Zayage. Sclerocybin has written the movies Noenometer and Tayenne. Zayage has written the movies Pneumodendron and Tayenne. Noenometer has won the Brownbeard award. Tayenne has won the Goosehead award. Pneumodendron has won the Handt award. So the answer is [”Brownbeard”, ”Goosehead”, ” Handt”]. + +A: [”Brownbeard”, ”Goosehead”, ”Handt”] QS: [EOQ] + +# G.4 SHORTER PROMPTS FOR SMALLER CONTEXT WINDOWS + +qa(small) + +movie: Premercy ; directed by: Muntaril. movie: Skirtsicine ; director: Teeplemole. movie: Featsaw ; directed by: Monsterscar. movie: Zalate ; director: Monsterscar. movie: Zalate ; awarded: Hallowcock. movie: Featsaw ; awarded: Zorgion. movie: Premercy ; award: Chowwurst. movie: Skirtsicine ; award: Hallowcock. award: Goatfly ; winner: Teeplemole. person: Monsterscar ; award: Glodome. person: Muntaril ; award: Goatfly. movie: Featsaw ; release year: 1973. movie: Zalate ; release year: 1964. movie: Skirtsicine ; release year: 1973. movie: Premercy ; year: 1961. Teeplemole was an actor in the movie Skirtsicine. Muntaril was an actor in the movie Skirtsicine. Monsterscar was an actor in the movie Premercy. Muntaril was an actor in the movie Featsaw. Teeplemole was an actor in the movie Zalate. Muntaril was born in the year 1910. Teeplemole was born in 1910. Monsterscar was born in 1942. Teeplemole is from the country of Piperfish. Monsterscar is from the country of Piperfish. Muntaril is from the country of Clony. Muntaril produced the movie Skirtsicine with others. Monsterscar was one of the producers of the movie Featsaw. Monsterscar produced the movie Premercy with others. Monsterscar produced the movie Zalate with others. Teeplemole was one of the producers of the movie Featsaw. Teeplemole produced the movie Zalate with others. Muntaril produced the movie Premercy with others. Monsterscar wrote for the movie Premercy. Muntaril was one of the writers for the movie Zalate. Muntaril wrote for the movie Featsaw. Teeplemole wrote for the movie Featsaw. Monsterscar was one of the writers for the movie Zalate. Teeplemole was one of the writers for the movie Skirtsicine. + +Q: Which awards were given to Zalate? + +A: [”Hallowcock”] + +Q: For which movies was Muntaril the producer? + +A: [”Premercy] + +Q: Who are the actors in the movie Premercy? + +A: [”Monsterscar”] + +movie: Nilitude ; director: Monsterscar. movie: Dewbar ; directed by: Metatoun. movie: Warpstone ; directed by: Gastrat. movie: Partnershipmaker ; director: Metatoun. movie: Dewbar ; award: Tachychronograph. movie: Partnershipmaker ; awarded: Tachychronograph. movie: Nilitude ; award: Paleodactyl. movie: Warpstone ; award: Sabonade. person: Gastrat ; award: Trifogation. award: Polyquadrase ; winner: Monsterscar. award: Trifogation ; winner: Metatoun. movie: Warpstone ; release year: 1956. movie: Dewbar ; release year: 1984. movie: Nilitude ; year: 1984. movie: Partnershipmaker ; year: 1962. Gastrat was an actor in the movie Partnershipmaker. Metatoun was an actor in the movie Partnershipmaker. Metatoun was an actor in the movie Nilitude. Gastrat acted in the movie Nilitude. Monsterscar was an actor in the movie Dewbar. Gastrat acted in the movie Warpstone. Metatoun acted in the movie Warpstone. Metatoun was born in 1939. Gastrat was born in the year 1933. Monsterscar was born in 1933. Metatoun grew up in the nation of Moulole. Gastrat is from the country of Stridery. Monsterscar grew up in the nation of Moulole. Monsterscar produced the movie Nilitude with others. Monsterscar was one of the producers of the movie Warpstone . Metatoun was one of the producers of the movie Warpstone. Gastrat was one of the producers of the movie Nilitude. Metatoun produced the movie Partnershipmaker with others. Metatoun produced the movie Dewbar with others. Monsterscar was one of the producers of the movie Partnershipmaker. Gastrat produced the movie Dewbar with others. Metatoun wrote for the movie Partnershipmaker. Gastrat wrote for the movie Warpstone. Gastrat was one of the writers for the movie Dewbar. Monsterscar was one of the writers for the movie Nilitude. Metatoun wrote for the movie Warpstone. + +Q: Which movies has Gastrat been an actor in? + +A: [”Partnershipmaker”, ”Nilitude”, ”Warpstone”] + +Q: Who is from the country Stridery? + +A: [”Gastrat”] + +Q: Which movies were given the Tachychronograph award? + +A: [”Dewbar”, ”Partnershipmaker”] + +aw qa(small) + +movie: Premercy ; directed by: Muntaril. movie: Skirtsicine ; director: Teeplemole. movie: Featsaw ; directed by: Monsterscar. movie: Zalate ; director: Monsterscar. movie: Zalate ; awarded: Hallowcock. movie: Featsaw ; awarded: Zorgion. movie: Premercy ; award: Chowwurst. movie: Skirtsicine ; award: Hallowcock. award: Goatfly ; winner: Teeplemole. person: Monsterscar ; award: Glodome. person: Muntaril ; award: Goatfly. movie: Featsaw ; release year: 1973. movie: Zalate ; release year: 1964. movie: Skirtsicine ; release year: 1973. movie: Premercy ; year: 1961. Teeplemole was an actor in the movie Skirtsicine. Muntaril was an actor in the movie Skirtsicine. Monsterscar was an actor in the movie Premercy. Muntaril was an actor in the movie Featsaw. Teeplemole was an actor in the movie Zalate. Muntaril was born in the year 1910. Teeplemole was born in 1910. Monsterscar was born in 1942. Teeplemole is from the country of Piperfish. Monsterscar is from the country of Piperfish. Muntaril is from the country of Clony. Muntaril produced the movie Skirtsicine with others. Monsterscar was one of the producers of the movie Featsaw. Monsterscar produced the movie Premercy with others. Monsterscar produced the movie Zalate with others. Teeplemole was one of the producers of the movie Featsaw. Teeplemole produced the movie Zalate with others. Muntaril produced the movie Premercy with others. Monsterscar wrote for the movie Premercy. Muntaril was one of the writers for the movie Zalate. Muntaril wrote for the movie Featsaw. Teeplemole wrote for the movie Featsaw. Monsterscar was one of the writers for the movie Zalate. Teeplemole was one of the writers for the movie Skirtsicine. + +Q: Which awards were given to Zalate? + +A: [”Hallowcock”] + +Q: Which awards were given to Premercy? A: [”Chowwurst”] + +ovie: Misgendery ; directed by: Wetherality. movie: Dewbar ; director: Gigabut. movie: Caudacite ; director: Lougeriere. movie: Tayenne ; directed by: Lougeri \` ere. movie: \` Misgendery ; awarded: Microsouenesis. movie: Dewbar ; awarded: Erowid. movie: Tayenne ; awarded: Cockspit. movie: Caudacite ; award: Erowid. award: Aniconder ; winner: Wetherality. award: Aniconder ; winner: Lougeriere. person: Gigabut ; award: Trifogation.\` movie: Dewbar ; release year: 1991. movie: Tayenne ; year: 2013. movie: Caudacite ; release year: 2008. movie: Misgendery ; year: 1991. Wetherality was an actor in the movie Dewbar. Gigabut was an actor in the movie Tayenne. Lougeriere was an actor in the movie Tayenne. \` Lougeriere acted in the movie Caudacite. Lougeri \` ere acted in the movie Misgendery. Gigabut \` was an actor in the movie Caudacite. Wetherality was an actor in the movie Misgendery. Wetherality was born in the year 1917. Lougeriere was born in 1926. Gigabut was born in the\` year 1917. Gigabut grew up in the nation of Triclops. Lougeriere is from the country of Tatkin \` . Wetherality grew up in the nation of Tatkin. Lougeriere produced the movie Dewbar with \` others. Gigabut produced the movie Tayenne with others. Gigabut produced the movie Dewbar with others. Lougeriere was one of the producers of the movie Misgendery. \` Wetherality was one of the producers of the movie Caudacite. Gigabut was one of the producers of the movie Caudacite. Wetherality produced the movie Misgendery with others. Wetherality produced the movie Tayenne with others. Wetherality wrote for the movie Tayenne. Gigabut wrote for the movie Misgendery. Lougeriere was one of the writers for the \` movie Caudacite. Wetherality wrote for the movie Misgendery. Gigabut wrote for the movie + +Tayenne. Gigabut wrote for the movie Dewbar. Lougeriere wrote for the movie Dewbar. \` + +Wetherality wrote for the movie Caudacite. + +Q: Which movies were given the Erowid award? + +A: [”Dewbar”, ”Caudacite”] + +Q: Which awards were given to Wetherality? + +A: [”Aniconder”] pos qa(small) + +movie: Premercy ; directed by: Muntaril. movie: Skirtsicine ; director: Teeplemole. movie: Featsaw ; directed by: Monsterscar. movie: Zalate ; director: Monsterscar. movie: Zalate ; awarded: Hallowcock. movie: Featsaw ; awarded: Zorgion. movie: Premercy ; award: Chowwurst. movie: Skirtsicine ; award: Hallowcock. award: Goatfly ; winner: Teeplemole. person: Monsterscar ; award: Glodome. person: Muntaril ; award: Goatfly. movie: Featsaw ; release year: 1973. movie: Zalate ; release year: 1964. movie: Skirtsicine ; release year: 1973. movie: Premercy ; year: 1961. Teeplemole was an actor in the movie Skirtsicine. Muntaril was an actor in the movie Skirtsicine. Monsterscar was an actor in the movie Premercy. Muntaril was an actor in the movie Featsaw. Teeplemole was an actor in the movie Zalate. Muntaril was born in the year 1910. Teeplemole was born in 1910. Monsterscar was born in 1942. Teeplemole is from the country of Piperfish. Monsterscar is from the country of Piperfish. Muntaril is from the country of Clony. Muntaril produced the movie Skirtsicine with others. Monsterscar was one of the producers of the movie Featsaw. Monsterscar produced the movie Premercy with others. Monsterscar produced the movie Zalate with others. Teeplemole was one of the producers of the movie Featsaw. Teeplemole produced the movie Zalate with others. Muntaril produced the movie Premercy with others. Monsterscar wrote for the movie Premercy. Muntaril was one of the writers for the movie Zalate. Muntaril wrote for the movie Featsaw. Teeplemole wrote for the movie Featsaw. Monsterscar was one of the writers for the movie Zalate. Teeplemole was one of the writers for the movie Skirtsicine. + +Q: For which movies was Teeplemole the producer? + +A: [”Featsaw”, ”Zalate”] + +Q: For which movies was Muntaril the producer? + +A: [”Premercy] + +movie: Nilitude ; director: Monsterscar. movie: Dewbar ; directed by: Metatoun. movie: Warpstone ; directed by: Gastrat. movie: Partnershipmaker ; director: Metatoun. movie: Dewbar ; award: Tachychronograph. movie: Partnershipmaker ; awarded: Tachychronograph. movie: Nilitude ; award: Paleodactyl. movie: Warpstone ; award: Sabonade. person: Gastrat ; award: Trifogation. award: Polyquadrase ; winner: Monsterscar. award: Trifogation ; winner: Metatoun. movie: Warpstone ; release year: 1956. movie: Dewbar ; release year: 1984. movie: Nilitude ; year: 1984. movie: Partnershipmaker ; year: 1962. Gastrat was an actor in the movie Partnershipmaker. Metatoun was an actor in the movie Partnershipmaker. Metatoun was an actor in the movie Nilitude. Gastrat acted in the movie Nilitude. Monsterscar was an actor in the movie Dewbar. Gastrat acted in the movie Warpstone. Metatoun acted in the movie Warpstone. Metatoun was born in 1939. Gastrat was born in the year 1933. Monsterscar was born in 1933. Metatoun grew up in the nation of Moulole. Gastrat is from the country of Stridery. Monsterscar grew up in the nation of Moulole. Monsterscar produced the movie Nilitude with others. Monsterscar was one of the producers of the movie Warpstone . Metatoun was one of the producers of the movie Warpstone. Gastrat was one of the producers of the movie Nilitude. Metatoun produced the movie Partnershipmaker with others. Metatoun produced the movie Dewbar with others. Monsterscar was one of the producers of the movie Partnershipmaker. Gastrat produced the movie Dewbar with others. Metatoun wrote for the movie Partnershipmaker. Gastrat wrote for the movie Warpstone. Gastrat was one of the writers for the movie Dewbar. Monsterscar was one of the writers for the movie Nilitude. Metatoun wrote for the movie Warpstone. + +Q: Which movies has Gastrat been an actor in? + +A: [”Partnershipmaker”, ”Nilitude”, ”Warpstone”] + +Q: Which movies has Monsterscar been an actor in? + +simp qa(small) + +movie: Premercy ; directed by: Muntaril. movie: Skirtsicine ; director: Teeplemole. movie: Featsaw ; directed by: Monsterscar. movie: Zalate ; director: Monsterscar. movie: Zalate ; awarded: Hallowcock. movie: Featsaw ; awarded: Zorgion. movie: Premercy ; award: Chowwurst. movie: Skirtsicine ; award: Hallowcock. award: Goatfly ; winner: Teeplemole. person: Monsterscar ; award: Glodome. person: Muntaril ; award: Goatfly. movie: Featsaw ; release year: 1973. movie: Zalate ; release year: 1964. movie: Skirtsicine ; release year: 1973. movie: Premercy ; year: 1961. Teeplemole was an actor in the movie Skirtsicine. Muntaril was an actor in the movie Skirtsicine. Monsterscar was an actor in the movie Premercy. Muntaril was an actor in the movie Featsaw. Teeplemole was an actor in the movie Zalate. Muntaril was born in the year 1910. Teeplemole was born in 1910. Monsterscar was born in 1942. Teeplemole is from the country of Piperfish. Monsterscar is from the country of Piperfish. Muntaril is from the country of Clony. Muntaril produced the movie Skirtsicine with others. Monsterscar was one of the producers of the movie Featsaw. Monsterscar produced the movie Premercy with others. Monsterscar produced the movie Zalate with others. Teeplemole was one of the producers of the movie Featsaw. Teeplemole produced the movie Zalate with others. Muntaril produced the movie Premercy with others. Monsterscar wrote for the movie Premercy. Muntaril was one of the writers for the movie Zalate. Muntaril wrote for the movie Featsaw. Teeplemole wrote for the movie Featsaw. Monsterscar was one of the writers for the movie Zalate. Teeplemole was one of the writers for the movie Skirtsicine. + +Q: Who were born in the year 1910? + +A: [”Teeplemole”, ”Muntaril”] + +Q: Who is from the country Piperfish? + +A: [”Teeplemole”, ”Monsterscar”] + +movie: Nilitude ; director: Monsterscar. movie: Dewbar ; directed by: Metatoun. movie: Warpstone ; directed by: Gastrat. movie: Partnershipmaker ; director: Metatoun. movie: Dewbar ; award: Tachychronograph. movie: Partnershipmaker ; awarded: Tachychronograph. movie: Nilitude ; award: Paleodactyl. movie: Warpstone ; award: Sabonade. person: Gastrat ; award: Trifogation. award: Polyquadrase ; winner: Monsterscar. award: Trifogation ; winner: Metatoun. movie: Warpstone ; release year: 1956. movie: Dewbar ; release year: 1984. movie: Nilitude ; year: 1984. movie: Partnershipmaker ; year: 1962. Gastrat was an actor in the movie Partnershipmaker. Metatoun was an actor in the movie Partnershipmaker. Metatoun was an actor in the movie Nilitude. Gastrat acted in the movie Nilitude. Monsterscar was an actor in the movie Dewbar. Gastrat acted in the movie Warpstone. Metatoun acted in the movie Warpstone. Metatoun was born in 1939. Gastrat was born in the year 1933. Monsterscar was born in 1933. Metatoun grew up in the nation of Moulole. Gastrat is from the country of Stridery. Monsterscar grew up in the nation of Moulole. Monsterscar produced the movie Nilitude with others. Monsterscar was one of the producers of the movie Warpstone . Metatoun was one of the producers of the movie Warpstone. Gastrat was one of the producers of the movie Nilitude. Metatoun produced the movie Partnershipmaker with others. Metatoun produced the movie Dewbar with others. Monsterscar was one of the producers of the movie Partnershipmaker. Gastrat produced the movie Dewbar with others. Metatoun wrote for the movie Partnershipmaker. Gastrat wrote for the movie Warpstone. Gastrat was one of the writers for the movie Dewbar. Monsterscar was one of the writers for the movie Nilitude. Metatoun wrote for the movie Warpstone. + +Q: Who is from the country Stridery? + +A: [”Gastrat”] + +Q: Who were born in the year 1939? + +A: [”Metatoun”] + +movie: Premercy ; directed by: Muntaril. movie: Skirtsicine ; director: Teeplemole. movie: Featsaw ; directed by: Monsterscar. movie: Zalate ; director: Monsterscar. movie: Zalate ; awarded: + +Hallowcock. movie: Featsaw ; awarded: Zorgion. movie: Premercy ; award: Chowwurst. movie: Skirtsicine ; award: Hallowcock. award: Goatfly ; winner: Teeplemole. person: Monsterscar ; award: Glodome. person: Muntaril ; award: Goatfly. movie: Featsaw ; release year: 1973. movie: Zalate ; release year: 1964. movie: Skirtsicine ; release year: 1973. movie: Premercy ; year: 1961. Teeplemole was an actor in the movie Skirtsicine. Muntaril was an actor in the movie Skirtsicine. Monsterscar was an actor in the movie Premercy. Muntaril was an actor in the movie Featsaw. Teeplemole was an actor in the movie Zalate. Muntaril was born in the year 1910. Teeplemole was born in 1910. Monsterscar was born in 1942. Teeplemole is from the country of Piperfish. Monsterscar is from the country of Piperfish. Muntaril is from the country of Clony. Muntaril produced the movie Skirtsicine with others. Monsterscar was one of the producers of the movie Featsaw. Monsterscar produced the movie Premercy with others. Monsterscar produced the movie Zalate with others. Teeplemole was one of the producers of the movie Featsaw. Teeplemole produced the movie Zalate with others. Muntaril produced the movie Premercy with others. Monsterscar wrote for the movie Premercy. Muntaril was one of the writers for the movie Zalate. Muntaril wrote for the movie Featsaw. Teeplemole wrote for the movie Featsaw. Monsterscar was one of the writers for the movie Zalate. Teeplemole was one of the writers for the movie Skirtsicine. + +QC: What awards have movies produced by people born in 1910 won? + +QS: The people born in 1910 were Muntaril and Teeplemole. Teeplemole produced the movies Featsaw and Zalate. Muntaril produced the movie Premercy. Featsaw was awarded the Zorgion award. Premercy was awarded the Chowwurst award. Zalate was awarded the Hallowcock award. So the answer is [”Zorgion”, ”Chowwurst”, ”Hallowcock”]. + +A: [”Zorgion”, ”Chowwurst”, ”Hallowcock”] QS: [EOQ] + +movie: Nilitude ; director: Monsterscar. movie: Dewbar ; directed by: Metatoun. movie: Warpstone ; directed by: Gastrat. movie: Partnershipmaker ; director: Metatoun. movie: Dewbar ; award: Tachychronograph. movie: Partnershipmaker ; awarded: Tachychronograph. movie: Nilitude ; award: Paleodactyl. movie: Warpstone ; award: Sabonade. person: Gastrat ; award: Trifogation. award: Polyquadrase ; winner: Monsterscar. award: Trifogation ; winner: Metatoun. movie: Warpstone ; release year: 1956. movie: Dewbar ; release year: 1984. movie: Nilitude ; year: 1984. movie: Partnershipmaker ; year: 1962. Gastrat was an actor in the movie Partnershipmaker. Metatoun was an actor in the movie Partnershipmaker. Metatoun was an actor in the movie Nilitude. Gastrat acted in the movie Nilitude. Monsterscar was an actor in the movie Dewbar. Gastrat acted in the movie Warpstone. Metatoun acted in the movie Warpstone. Metatoun was born in 1939. Gastrat was born in the year 1933. Monsterscar was born in 1933. Metatoun grew up in the nation of Moulole. Gastrat is from the country of Stridery. Monsterscar grew up in the nation of Moulole. Monsterscar produced the movie Nilitude with others. Monsterscar was one of the producers of the movie Warpstone . Metatoun was one of the producers of the movie Warpstone. Gastrat was one of the producers of the movie Nilitude. Metatoun produced the movie Partnershipmaker with others. Metatoun produced the movie Dewbar with others. Monsterscar was one of the producers of the movie Partnershipmaker. Gastrat produced the movie Dewbar with others. Metatoun wrote for the movie Partnershipmaker. Gastrat wrote for the movie Warpstone. Gastrat was one of the writers for the movie Dewbar. Monsterscar was one of the writers for the movie Nilitude. Metatoun wrote for the movie Warpstone. + +QC: What movies have people from the country Stridery acted in? + +QS: The people born in Stridery are Gastrat. Gastrat acted in Partenrshipmaker, Nilitude and Warpstone. So the answer is [”Partnershipmaker”, ”Nilitude”, ”Warpstone”]. + +A: [”Partnershipmaker”, ”Nilitude”, ”Warpstone”] QS: [EOQ] + +# G.5 MATH QA + +The decomposer here deterministically calls cot to generate the CoT and then calls gpt ans to extract the answer. + +Q: There are 15 trees in the grove. Grove workers will plant trees in the grove today. After they are done, there will be 21 trees. How many trees did the grove workers plant today? + +A: There are 15 trees originally. Then there were 21 trees after some more were planted. So there must have been $2 1 - 1 5 = 6$ . The answer is 6. + +Q: If there are 3 cars in the parking lot and 2 more cars arrive, how many cars are in the parking lot 2 + +A: There are originally 3 cars. 2 more cars arrive. $3 + 2 = 5$ . The answer is 5. + +Q: Leah had 32 chocolates and her sister had 42. If they ate 35, how many pieces do they have left in total? + +A: Originally, Leah had 32 chocolates. Her sister had 42. So in total they had $3 2 + 4 2 = 7 4$ . After eating 35, they had $7 4 - 3 5 = 3 9$ . The answer is 39. + +Q: Jason had 20 lollipops. He gave Denny some lollipops. Now Jason has 12 lollipops. How many lollipops did Jason give to Denny? + +A: Jason started with 20 lollipops. Then he had 12 after giving some to Denny. So he gave Denny $2 0 - 1 2 = 8 $ . The answer is 8. + +Q: Shawn has five toys. For Christmas, he got two toys each from his mom and dad. How many toys does he have now? + +A: Shawn started with 5 toys. If he got 2 toys each from his mom and dad, then that is 4 more toys. $5 + 4 = 9$ . The answer is 9. + +Q: There were nine computers in the server room. Five more computers were installed each day, from monday to thursday. How many computers are now in the server room? + +A: There were originally 9 computers. For each of 4 days, 5 more computers were added. So $5 * 4$ $= 2 0$ computers were added. $9 + 2 0$ is 29. The answer is 29. + +Q: Michael had 58 golf balls. On tuesday, he lost 23 golf balls. On wednesday, he lost 2 more. How many golf balls did he have at the end of wednesday? + +A: Michael started with 58 golf balls. After losing 23 on tuesday, he had $5 8 - 2 3 = 3 5$ . After losing 2 more, he had $3 5 - 2 = 3 3$ golf balls. The answer is 33. + +Q: Olivia has $\$ 23$ . She bought five bagels for $\$ 3$ each. How much money does she have left? + +A: Olivia had 23 dollars. 5 bagels for 3 dollars each will be $5 \mathrm { ~ x ~ } 3 = 1 5$ dollars. So she has 23 − 15 dollars left. 23 − 15 is 8. The answer is 8. + +# gpt ans + +Q: There are 15 trees originally. Then there were 21 trees after some more were planted. So there must have been $2 1 - 1 5 = 6$ trees planted. + +Q: There are originally 3 cars. 2 more cars arrive. $3 + 2 = 5$ . The answer is 5. + +Q: Originally, Leah had 32 chocolates. Her sister had 42. So in total they had $3 2 + 4 2 = 7 4$ . After eating 35, they had $7 4 - 3 5 = 3 9$ . The answer is 39. + +A: 39 + +Q: Jason started with 20 lollipops. Then he had 12 after giving some to Denny. So he gave Denny $2 0 - 1 2 = 8 $ apples. + +Q: Shawn started with 5 toys. If he got 2 toys each from his mom and dad, then that is 4 more toys. $5 + 4 = 9$ . The answer is 9. + +A: 9 + +Q: There were originally 9 computers. For each of 4 days, 5 more computers were added. So $5 * 4$ $= 2 0$ computers were added. $9 + 2 0$ is 29. The answer is 29. + +A: 29 +Q: Michael started with 58 golf balls. After losing 23 on tuesday, he had $5 8 - 2 3 = 3 5$ . After losing 2 more, he had $3 5 - 2 = 3 3$ golf balls. +A: 33 +Q: Olivia had 23 dollars. 5 bagels for 3 dollars each will be $5 \mathrm { ~ x ~ } 3 = 1 5$ dollars. So she has 23 − 15 $= 8$ dollars left. +A: 8 + +# G.6 OPEN DOMAIN QA + +The prompts in this section implement Decomposed Prompting approach to open-domain multihop QA. For brevity we’ve included prompts for 5 of 20 randomly sampled questions. The full prompts are attached with the submission and will also be released with the code. Note that we selected a set of 100 questions from the development set to tune the hyperparameter (number of paragraphs to retrieve for all of the retrieval-based approaches). + +# hotpotqa: decomp + +QC: In which country did this Australian who was detained in Guantanamo Bay detention camp and published ”Guantanamo: My Journey” receive para−military training? + +QS: (select) [retrieve odqa] Who is the Australian who was detained in Guantanamo Bay detention camp and published ”Guantanamo: My Journey”? + +A: {”titles”: [”Guantanamo: My Journey”, ”Bismullah v. Gates”, ”Guantanamo Bay detention camp”], ”answer”: [”David Hicks”]} + +QS: (select) [retrieve odqa] In which country did David Hicks receive his para−military training? + +A: {”titles”: [”John Adams Project”, ”Camp Echo (Guantanamo Bay)”, ”Guantanamo Bay Museum of Art and History”, ”David Hicks”], ”answer”: [”Afghanistan”]} + +QS: (select) [multihop titleqa] Titles: [”Guantanamo: My Journey”, ”Bismullah v. Gates”, ” Guantanamo Bay detention camp”, ”John Adams Project”, ”Camp Echo (Guantanamo Bay)”, ”Guantanamo Bay Museum of Art and History”, ”David Hicks”]. Question: In which country did this Australian who was detained in Guantanamo Bay detention camp and published ” Guantanamo: My Journey” receive para−military training? + +A: [”Afghanistan”] QS: [EOQ] + +QC: How many awards did the ”A Girl Like Me” singer win at the American Music Awards of 2012? + +QS: (select) [retrieve odqa] Who is the singer of ”A Girl Like Me”? + +tles”: [”American Music Award”, ”Rihanna”], ”answer”: [”Rihanna”]} + +QS: (select) [retrieve odqa] How many awards did Rihana won in the American Music Awards of 2012? + +A: {”titles”: [”American Music Awards of 2012”, ”APRA Music Awards of $2 0 1 2 ^ { \circ }$ , ”List of awards and nominations received by TLC”, ”Native American Music Awards”], ”answer”: [”one”]} + +QS: (select) [multihop titleqa] Titles: [”American Music Award”, ”Rihanna”, ”American Music Awards of 2012”, ”APRA Music Awards of $2 0 1 2 ^ { \circ }$ , ”List of awards and nominations received by TLC”, ”Native American Music Awards”]. Question: How many awards did the ”A Girl Like Me” singer win at the American Music Awards of 2012? + +A: [”one”] QS: [EOQ] + +QC: who is older Jeremy Horn or Renato Sobral ? QS: (select) [retrieve odqa] When was Jeremy Horn born? + +A: {”titles”: [”Zaza Tkeshelashvili”, ”Jeremy Horn”, ”Jeremy Horn (singer)”, ”Ricardo Arona”], ” answer”: [”August 25, 1975”]} + +QS: (select) [retrieve odqa] When was Renato Sobral born? + +A: {”titles”: [”Brian Warren”, ”Renato Sobral”], ”answer”: [”September 7, 1975”]} + +QS: (select) [multihop titleqa] Titles: [”Zaza Tkeshelashvili”, ”Jeremy Horn”, ”Jeremy Horn ( singer)”, ”Ricardo Arona”, ”Brian Warren”, ”Renato Sobral”]. Question: who is older Jeremy Horn or Renato Sobral ? + +A: [”Jeremy Horn”] QS: [EOQ] + +QC: What was the 2014 population of the city where Lake Wales Medical Center is located? + +QS: (select) [retrieve odqa] Lake Wales Medical Center is located in what city? + +A: {”titles”: [”Baylor College of Medicine”, ”Lake Wales Medical Center”, ”Tufts University School of Medicine”, ”Hanford Community Medical Center”], ”answer”: [”Polk County, Florida”]} + +QS: (select) [retrieve odqa] What was the population of Polk County in 2014? + +A: {”titles”: [”Banner University Medical Center Tucson”, ”Lake Wales, Florida”], ”answer”: [”15,140”]} + +QS: (select) [multihop titleqa] Titles: [”Baylor College of Medicine”, ”Lake Wales Medical Center ”, ”Tufts University School of Medicine”, ”Hanford Community Medical Center”, ”Banner University Medical Center Tucson”, ”Lake Wales, Florida”]. Question: What was the 2014 population of the city where Lake Wales Medical Center is located? + +A: [”15,140”] QS: [EOQ] + +QC: Nobody Loves You was written by John Lennon and released on what album that was issued by Apple Records, and was written, recorded, and released during his 18 month separation from Yoko Ono? + +QS: (select) [retrieve odqa] What album was issued by Apple Records, and written, recorded, and released during John Lennon’s 18 month separation from Yoko Ono? + +A: {”titles”: [”John Lennon/Plastic Ono Band”, ”Milk and Honey (album)”, ”Walls and Bridges”], ”answer”: [”Walls and Bridges”]} QS: (select) [retrieve odqa] Nobody Loves You was written by John Lennon on what album? + +A: {”titles”: [”John Lennon Museum”, ”Nobody Loves You (When You’re Down and Out)”], ” answer”: [”Walls and Bridges”]} + +QS: (select) [multihop titleqa] Titles: [”John Lennon/Plastic Ono Band”, ”Milk and Honey (album) ”, ”Walls and Bridges”, ”John Lennon Museum”, ”Nobody Loves You (When You’re Down and Out)”]. Question: Nobody Loves You was written by John Lennon and released on what album that was issued by Apple Records, and was written, recorded, and released during his 18 month separation from Yoko Ono? + +A: [”Walls and Bridges”] + +QS: [EOQ] + +hotpotqa: retrieve odqa + +QC: Who is the Australian who was detained in Guantanamo Bay detention camp and published ” Guantanamo: My Journey”? + +QS: (select) [retrieve] Who is the Australian who was detained in Guantanamo Bay detention camp and published ”Guantanamo: My Journey”? + +A: [”Guantanamo: My Journey”, ”Bismullah v. Gates”, ”Guantanamo Bay detention camp”] + +QS: (select) [singlehop titleqa] Titles: [”Guantanamo: My Journey”, ”Bismullah v. Gates”, ” Guantanamo Bay detention camp”]. Question: Who is the Australian who was detained in Guantanamo Bay detention camp and published ”Guantanamo: My Journey”? + +A: {”titles”: [”Guantanamo: My Journey”, ”Bismullah v. Gates”, ”Guantanamo Bay detention camp”], ”answer”: [”David Hicks”]} +QS: [EOQ] + +QC: In which country did David Hicks receive his para−military training? + +QS: (select) [retrieve] In which country did David Hicks receive his para−military training? + +A: [”John Adams Project”, ”Camp Echo (Guantanamo Bay)”, ”Guantanamo Bay Museum of Art and History”, ”David Hicks”] + +QS: (select) [singlehop titleqa] Titles: [”John Adams Project”, ”Camp Echo (Guantanamo Bay)”, ” Guantanamo Bay Museum of Art and History”, ”David Hicks”]. Question: In which country did David Hicks receive his para−military training? + +A: {”titles”: [”John Adams Project”, ”Camp Echo (Guantanamo Bay)”, ”Guantanamo Bay Museum of Art and History”, ”David Hicks”], ”answer”: [”Afghanistan”]} QS: [EOQ] + +QC: Who is the singer of ”A Girl Like Me”? + +QS: (select) [retrieve] Who is the singer of ”A Girl Like Me”? + +A: [”American Music Award”, ”Rihanna”] + +QS: (select) [singlehop titleqa] Titles: [”American Music Award”, ”Rihanna”]. Question: Who is the singer of ”A Girl Like Me”? + +A: {”titles”: [”American Music Award”, ”Rihanna”], ”answer”: [”Rihanna”]} QS: [EOQ] + +QC: How many awards did Rihana won in the American Music Awards of 2012? + +QS: (select) [retrieve] How many awards did Rihana won in the American Music Awards of 2012? + +A: [”American Music Awards of 2012”, ”APRA Music Awards of 2012”, ”List of awards and nominations received by TLC”, ”Native American Music Awards”] + +QS: (select) [singlehop titleqa] Titles: [”American Music Awards of 2012”, ”APRA Music Awards of $2 0 1 2 ^ { \circ }$ , ”List of awards and nominations received by TLC”, ”Native American Music Awards”]. Question: How many awards did Rihana won in the American Music Awards of 2012? + +A: {”titles”: [”American Music Awards of 2012”, ”APRA Music Awards of $2 0 1 2 ^ { \circ }$ , ”List of awards and nominations received by TLC”, ”Native American Music Awards”], ”answer”: [”one”]} QS: [EOQ] + +QC: When was Jeremy Horn born? + +QS: (select) [retrieve] When was Jeremy Horn born? + +A: [”Zaza Tkeshelashvili”, ”Jeremy Horn”, ”Jeremy Horn (singer)”, ”Ricardo Arona”] + +QS: (select) [singlehop titleqa] Titles: [”Zaza Tkeshelashvili”, ”Jeremy Horn”, ”Jeremy Horn ( singer)”, ”Ricardo Arona”]. Question: When was Jeremy Horn born? + +A: {”titles”: [”Zaza Tkeshelashvili”, ”Jeremy Horn”, ”Jeremy Horn (singer)”, ”Ricardo Arona”], ” answer”: [”August 25, 1975”]} +QS: [EOQ] + +QC: When was Renato Sobral born? + +QS: (select) [retrieve] When was Renato Sobral born? + +A: [”Brian Warren”, ”Renato Sobral”] + +QS: (select) [singlehop titleqa] Titles: [”Brian Warren”, ”Renato Sobral”]. Question: When was Renato Sobral born? + +A: {”titles”: [”Brian Warren”, ”Renato Sobral”], ”answer”: [”September 7, 1975”]} QS: [EOQ] + +QC: Lake Wales Medical Center is located in what city? +QS: (select) [retrieve] Lake Wales Medical Center is located in what city? +A: [”Baylor College of Medicine”, ”Lake Wales Medical Center”, ”Tufts University School of Medicine”, ”Hanford Community Medical Center”] + +QS: (select) [singlehop titleqa] Titles: [”Baylor College of Medicine”, ”Lake Wales Medical Center”, ”Tufts University School of Medicine”, ”Hanford Community Medical Center”]. Question: Lake Wales Medical Center is located in what city? + +A: {”titles”: [”Baylor College of Medicine”, ”Lake Wales Medical Center”, ”Tufts University School of Medicine”, ”Hanford Community Medical Center”], ”answer”: [”Polk County, Florida”]} +QS: [EOQ] + +QC: What was the population of Polk County in 2014? + +QS: (select) [retrieve] What was the population of Polk County in 2014? + +A: [”Banner University Medical Center Tucson”, ”Lake Wales, Florida”] + +S: (select) [singlehop titleqa] Titles: [”Banner University Medical Center Tucson”, ”Lake Wales, Florida”]. Question: What was the population of Polk County in 2014? + +A: {”titles”: [”Banner University Medical Center Tucson”, ”Lake Wales, Florida”], ”answer”: [”15,140”]} +QS: [EOQ] + +QC: What album was issued by Apple Records, and written, recorded, and released during John Lennon’s 18 month separation from Yoko Ono? + +QS: (select) [retrieve] What album was issued by Apple Records, and written, recorded, and released during John Lennon’s 18 month separation from Yoko Ono? + +A: [”John Lennon/Plastic Ono Band”, ”Milk and Honey (album)”, ”Walls and Bridges”] + +QS: (select) [singlehop titleqa] Titles: [”John Lennon/Plastic Ono Band”, ”Milk and Honey (album )”, ”Walls and Bridges”]. Question: What album was issued by Apple Records, and written, recorded, and released during John Lennon’s 18 month separation from Yoko Ono? + +A: {”titles”: [”John Lennon/Plastic Ono Band”, ”Milk and Honey (album)”, ”Walls and Bridges”], ”answer”: [”Walls and Bridges”]} +QS: [EOQ] + +QC: Nobody Loves You was written by John Lennon on what album? + +QS: (select) [retrieve] Nobody Loves You was written by John Lennon on what album? + +A: [”John Lennon Museum”, ”Nobody Loves You (When You’re Down and Out)”] + +QS: (select) [singlehop titleqa] Titles: [”John Lennon Museum”, ”Nobody Loves You (When You’ re Down and Out)”]. Question: Nobody Loves You was written by John Lennon on what album? + +A: {”titles”: [”John Lennon Museum”, ”Nobody Loves You (When You’re Down and Out)”], ” answer”: [”Walls and Bridges”]} +QS: [EOQ] + +hotpotqa: singlehop titleqa + +Wikipedia Title: David Hicks + +Wikipedia Title: Guantanamo: My Journey + +Wikipedia Title: Murat Kurnaz + +Q: Who is the Australian who was detained in Guantanamo Bay detention camp and published ” Guantanamo: My Journey”? + +A: [”David Hicks”] + +Q: In which country did David Hicks receive his para−military training? A: [”Afghanistan”] + +Wikipedia Title: American Music Award + +Wikipedia Title: Rihanna + +Wikipedia Title: American Music Awards of 2012 + +Q: Who is the singer of ”A Girl Like Me”? + +A: [”Rihanna”] + +Q: How many awards did Rihana won in the American Music Awards of 2012? A: [”one”] + +Wikipedia Title: Renato Sobral + +Wikipedia Title: Zaza Tkeshelashvili + +Wikipedia Title: Jeremy Horn + +Q: When was Jeremy Horn born? A: [”August 25, 1975”] + +Q: When was Renato Sobral born? A: [”September 7, 1975”] + +Wikipedia Title: Lake Wales Medical Center + +Wikipedia Title: Lake Wales, Florida $ + +Wikipedia Title: Tufts University School of Medicine + +Q: Lake Wales Medical Center is located in what city? A: [”Polk County, Florida”] + +Q: What was the population of Polk County in 2014? A: [”15,140”] + +Wikipedia Title: Nobody Loves You (When You’re Down and Out) + +Wikipedia Title: Walls and Bridges + +Wikipedia Title: Mother (John Lennon song) $ + +Q: What album was issued by Apple Records, and written, recorded, and released during John Lennon’s 18 month separation from Yoko Ono? + +A: [”Walls and Bridges”] + +Q: Nobody Loves You was written by John Lennon on what album? A: [”Walls and Bridges”] + +hotpotqa: multihop titleqa (direct) + +Wikipedia Title: David Hicks + +Wikipedia Title: Guantanamo: My Journey + +Wikipedia Title: Murat Kurnaz + +Q: In which country did this Australian who was detained in Guantanamo Bay detention camp and published ”Guantanamo: My Journey” receive para−military training? + +A: [”Afghanistan”] + +Wikipedia Title: American Music Award + +Wikipedia Title: Rihanna + +Wikipedia Title: American Music Awards of 2012 + +Q: How many awards did the ”A Girl Like Me” singer win at the American Music Awards of 2012? + +Wikipedia Title: Renato Sobral + +Wikipedia Title: Zaza Tkeshelashvili + +Wikipedia Title: Jeremy Horn + +Q: who is older Jeremy Horn or Renato Sobral ? A: [”Jeremy Horn”] + +Wikipedia Title: Lake Wales Medical Center + +Wikipedia Title: Lake Wales, Florida $ + +Wikipedia Title: Tufts University School of Medicine + +Q: What was the 2014 population of the city where Lake Wales Medical Center is located? + +A: [”15,140”] + +Wikipedia Title: Nobody Loves You (When You’re Down and Out) + +Wikipedia Title: Walls and Bridges + +Wikipedia Title: Mother (John Lennon song) + +Q: Nobody Loves You was written by John Lennon and released on what album that was issued by Apple Records, and was written, recorded, and released during his 18 month separation from Yoko Ono? + +A: [”Walls and Bridges”] hotpotqa: multihop titleqa (cot) + +Wikipedia Title: David Hicks $ + +Wikipedia Title: Guantanamo: My Journey + +Wikipedia Title: Murat Kurnaz + +Q: In which country did this Australian who was detained in Guantanamo Bay detention camp and published ”Guantanamo: My Journey” receive para−military training? + +A: The Australian who was detained in Guantanamo Bay detention camp and published ” Guantanamo: My Journey” is David Hicks. David Hicks received his para−military training in Afghanistan. So the answer is: Afghanistan. + +Wikipedia Title: American Music Award + +Wikipedia Title: Rihanna + +Wikipedia Title: American Music Awards of 2012 + +Q: How many awards did the ”A Girl Like Me” singer win at the American Music Awards of 2012? + +A: The singer of ”A Girl Like Me” singer is Rihanna. In the American Music Awards of 2012, Rihana won one award. So the answer is: one. + +Wikipedia Title: Renato Sobral + +Wikipedia Title: Zaza Tkeshelashvili + +Wikipedia Title: Jeremy Horn + +Q: who is older Jeremy Horn or Renato Sobral ? + +A: Jeremy Horn was born on August 25, 1975. Renato Sobral was born on September 7, 1975. Thus, Jeremy Horn is older. So the answer is: Jeremy Horn. + +Wikipedia Title: Lake Wales Medical Center + +Wikipedia Title: Lake Wales, Florida + +Wikipedia Title: Tufts University School of Medicine + +Q: What was the 2014 population of the city where Lake Wales Medical Center is located? + +A: Lake Wales Medical Center is located in the city of Polk County, Florida. The population of Polk County in 2014 was 15,140. So the answer is: 15,140. + +Wikipedia Title: Nobody Loves You (When You’re Down and Out) + +Wikipedia Title: Walls and Bridges + +Wikipedia Title: Mother (John Lennon song) + +Q: Nobody Loves You was written by John Lennon and released on what album that was issued by Apple Records, and was written, recorded, and released during his 18 month separation from Yoko Ono? + +A: The album issued by Apple Records, and written, recorded, and released during John Lennon’s 18 month separation from Yoko Ono is Walls and Bridges. Nobody Loves You was written by John Lennon on Walls and Bridges album. So the answer is: Walls and Bridges. + +2wikimultihopqa: decomp + +QC: Do director of film Coolie No. 1 (1995 Film) and director of film The Sensational Trial have the same nationality? + +QS: (select) [retrieve odqa] Who is the director of the film Coolie No. 1 (1995 film)? + +A: {”titles”: [”Hanro Smitsman”, ”Coolie No. 1 (1995 film)”], ”answer”: [”David Dhawan”]} : (select) [retrieve odqa] Who is the director of the film The Sensational Trial? + +A: {”titles”: [”Rachel Feldman”, ”The Sensational Trial”], ”answer”: [”Karl Freund”]} + +S: (select) [retrieve odqa] What is David Dhawan’s nationality? + +A: {”titles”: [”David Dhawan”, ”Brian Johnson (special effects artist)”], ”answer”: [”India”]} + +QS: (select) [retrieve odqa] What is Karl Freund’s nationality? + +”titles”: [”Karl Freund”, ”Ian Barry (director)”], ”answer”: [”Germany”]} + +QS: (select) [multihop titleqa] Titles: [”Hanro Smitsman”, ”Coolie No. 1 (1995 film)”, ”Rachel Feldman”, ”The Sensational Trial”, ”David Dhawan”, ”Brian Johnson (special effects artist)”, ”Karl Freund”, ”Ian Barry (director)”]. Question: Do director of film Coolie No. 1 (1995 Film ) and director of film The Sensational Trial have the same nationality? + +A: [”no”] QS: [EOQ] + +QC: Which film has the director died later, The Gal Who Took the West or Twenty Plus Two? + +(select) [retrieve odqa] Who is the director of the film Twenty Plus? + +A: {”titles”: [”Riki Gal”, ”Twenty Plus Two”], ”answer”: [”Joseph M. Newman”]} (select) [retrieve odqa] Who is the director of the film The Gal Who Took the West? + +QS: (select) [retrieve odqa] When did Joseph M. Newman die? + +A: {”titles”: [”Joseph M. Newman”, ”Thulasi (1987 film)”], ”answer”: [”January 23, 2006”]} + +QS: (select) [retrieve odqa] When did Fred de Cordova die? + +QS: (select) [multihop titleqa] Titles: [”Riki Gal”, ”Twenty Plus Two”, ”Querelle”, ”The Gal Who Took the West”, ”Joseph M. Newman”, ”Thulasi (1987 film)”, ”Fred de Cordova”, ”Le Masque de la Meduse”]. Question: Which film has the director died later, The Gal Who Took the West or Twenty Plus Two? + +A: [”Twenty Plus Two”] QS: [EOQ] + +QC: Who is the grandchild of Krishna Shah (Nepalese Royal)? + +QS: (select) [retrieve odqa] Who is the child of Krishna Shah? + +A: {”titles”: [”Ana Gruzinsky−Golitsyn”, ”Krishna Shah (Nepalese royal)”, ”Diana Weston”, ” Albina du Boisrouvray”], ”answer”: [”Rudra Shah”]} +QS: (select) [retrieve odqa] Who is the child of Rudra Shah? + +A: {”titles”: [”Jim Ramel Kjellgren”, ”Constance Anne Herschel”, ”Rudra Shah”], ”answer”: [” Prithvipati Shah”]} + +QS: (select) [multihop titleqa] Titles: [”Ana Gruzinsky−Golitsyn”, ”Krishna Shah (Nepalese royal) ”, ”Diana Weston”, ”Albina du Boisrouvray”, ”Jim Ramel Kjellgren”, ”Constance Anne Herschel”, ”Rudra Shah”]. Question: Who is the grandchild of Krishna Shah (Nepalese Royal )? + +A: [”Prithvipati Shah”] QS: [EOQ] + +QC: Where did the director of film Maddalena (1954 Film) die? + +QS: (select) [retrieve odqa] Who is the director of the film Maddalen + +A: {”titles”: [”Ian Barry (director)”, ”Maddalena (1954 film)”, ”Brian Kennedy (gallery director) ”], ”answer”: [”Augusto Genina”]} +QS: (select) [retrieve odqa] Where did Augusto Genina die? + +A: {”titles”: [”Dana Blankstein”, ”Augusto Genina”, ”Peter Levin”, ”Olav Aaraas”], ”answer”: [” Rome”]} + +QS: (select) [multihop titleqa] Titles: [”Ian Barry (director)”, ”Maddalena (1954 film)”, ”Brian Kennedy (gallery director)”, ”Dana Blankstein”, ”Augusto Genina”, ”Peter Levin”, ”Olav Aaraas”]. Question: Where did the director of film Maddalena (1954 Film) die? + +A: [”Rome”] QS: [EOQ] + +QC: Who was born first out of Martin Hodge and Ivania Martinich? + +QS: (select) [retrieve odqa] When was Martin Hodge born? + +A: {”titles”: [”Greg A. Hill (artist)”, ”Martin Hodge”, ”John Allen (Oxford University cricketer)”], ”answer”: [”4 February $1 9 5 9 ^ { , 9 } ] \}$ +QS: (select) [retrieve odqa] When was Ivania Martinich born? + +A: {”titles”: [”Tom Dickinson”, ”Ivania Martinich”, ”Wesley Barresi”, ”Henry Moore (cricketer) ”], ”answer”: [”25 July 1995”]} + +QS: (select) [multihop titleqa] Titles: [”Greg A. Hill (artist)”, ”Martin Hodge”, ”John Allen ( Oxford University cricketer)”, ”Tom Dickinson”, ”Ivania Martinich”, ”Wesley Barresi”, ” Henry Moore (cricketer)”]. Question: Who was born first out of Martin Hodge and Ivania Martinich? + +A: [”Martin Hodge”] QS: [EOQ] + +2wikimultihopqa: retrieve odqa + +QC: Who is the director of the film Coolie No. 1 (1995 film)? QS: (select) [retrieve] Who is the director of the film Coolie No. 1 (1995 film)? A: [”Hanro Smitsman”, ”Coolie No. 1 (1995 film)”] + +QS: (select) [singlehop titleqa] Titles: [”Hanro Smitsman”, ”Coolie No. 1 (1995 film)”]. Question: Who is the director of the film Coolie No. 1 (1995 film)? + +A: {”titles”: [”Hanro Smitsman”, ”Coolie No. 1 (1995 film)”], ”answer”: [”David Dhawan”]} QS: [EOQ] + +QC: Who is the director of the film The Sensational Trial? + +QS: (select) [retrieve] Who is the director of the film The Sensational Trial? + +A: [”Rachel Feldman”, ”The Sensational Trial”] + +QS: (select) [singlehop titleqa] Titles: [”Rachel Feldman”, ”The Sensational Trial”]. Question: Who is the director of the film The Sensational Trial? + +A: {”titles”: [”Rachel Feldman”, ”The Sensational Trial”], ”answer”: [”Karl Freund”]} QS: [EOQ] + +QC: What is David Dhawan’s nationality? + +QS: (select) [retrieve] What is David Dhawan’s nationality? + +A: [”David Dhawan”, ”Brian Johnson (special effects artist)”] + +QS: (select) [singlehop titleqa] Titles: [”David Dhawan”, ”Brian Johnson (special effects artist)”]. Question: What is David Dhawan’s nationality? + +A: {”titles”: [”David Dhawan”, ”Brian Johnson (special effects artist)”], ”answer”: [”India”]} QS: [EOQ] + +QC: What is Karl Freund’s nationality? + +QS: (select) [retrieve] What is Karl Freund’s nationality? + +A: [”Karl Freund”, ”Ian Barry (director)”] + +QS: (select) [singlehop titleqa] Titles: [”Karl Freund”, ”Ian Barry (director)”]. Question: What is Karl Freund’s nationality? + +A: {”titles”: [”Karl Freund”, ”Ian Barry (director)”], ”answer”: [”Germany”]} QS: [EOQ] + +QC: Who is the director of the film Twenty Plus? + +QS: (select) [retrieve] Who is the director of the film Twenty Plus? + +A: [”Riki Gal”, ”Twenty Plus Two”] + +QS: (select) [singlehop titleqa] Titles: [”Riki Gal”, ”Twenty Plus Two”]. Question: Who is the director of the film Twenty Plus? + +A: {”titles”: [”Riki Gal”, ”Twenty Plus Two”], ”answer”: [”Joseph M. Newman”]} QS: [EOQ] + +QC: Who is the director of the film The Gal Who Took the West? + +QS: (select) [retrieve] Who is the director of the film The Gal Who Took the West? + +A: [”Querelle”, ”The Gal Who Took the West”] + +QS: (select) [singlehop titleqa] Titles: [”Querelle”, ”The Gal Who Took the West”]. Question: Who is the director of the film The Gal Who Took the West? + +A: {”titles”: [”Querelle”, ”The Gal Who Took the West”], ”answer”: [”Frederick de Cordova”]} QS: [EOQ] + +QC: When did Joseph M. Newman die? + +QS: (select) [retrieve] When did Joseph M. Newman die? + +A: [”Joseph M. Newman”, ”Thulasi (1987 film)”] + +QS: (select) [singlehop titleqa] Titles: [”Joseph M. Newman”, ”Thulasi (1987 film)”]. Question: When did Joseph M. Newman die? + +A: {”titles”: [”Joseph M. Newman”, ”Thulasi (1987 film)”], ”answer”: [”January 23, 2006”]} QS: [EOQ] + +QC: When did Fred de Cordova die? + +QS: (select) [retrieve] When did Fred de Cordova die? + +A: [”Fred de Cordova”, ”Le Masque de la Meduse”] + +QS: (select) [singlehop titleqa] Titles: [”Fred de Cordova”, ”Le Masque de la Meduse”]. Question: When did Fred de Cordova die? + +A: {”titles”: [”Fred de Cordova”, ”Le Masque de la Meduse”], ”answer”: [”September 15, 2001”]} QS: [EOQ] + +QC: Who is the child of Krishna Shah? + +QS: (select) [retrieve] Who is the child of Krishna Shah? + +A: [”Ana Gruzinsky−Golitsyn”, ”Krishna Shah (Nepalese royal)”, ”Diana Weston”, ”Albina du Boisrouvray”] + +QS: (select) [singlehop titleqa] Titles: [”Ana Gruzinsky−Golitsyn”, ”Krishna Shah (Nepalese royal )”, ”Diana Weston”, ”Albina du Boisrouvray”]. Question: Who is the child of Krishna Shah? + +A: {”titles”: [”Ana Gruzinsky−Golitsyn”, ”Krishna Shah ( Albina du Boisrouvray”], ”answer”: [”Rudra Shah”]} QS: [EOQ] + +QC: Who is the child of Rudra Shah? + +QS: (select) [retrieve] Who is the child of Rudra Shah? + +A: [”Jim Ramel Kjellgren”, ”Constance Anne Herschel”, ”Rudra Shah”] + +QS: (select) [singlehop titleqa] Titles: [”Jim Ramel Kjellgren”, ”Constance Anne Herschel”, ” + +A: {”titles”: [”Jim Ramel Kjellgren”, ”Constance Anne Herschel”, ”Rudra Shah”], ”answer”: [” Prithvipati Shah”]} +QS: [EOQ] + +QC: Who is the director of the film Maddalena? + +QS: (select) [retrieve] Who is the director of the film Maddalena? + +A: [”Ian Barry (director)”, ”Maddalena (1954 film)”, ”Brian Kennedy (gallery director)”] QS: (select) [singlehop titleqa] Titles: [”Ian Barry (director)”, ”Maddalena (1954 film)”, ”Brian Kennedy (gallery director)”]. Question: Who is the director of the film Maddalena? + +A: {”titles”: [”Ian Barry (director)”, ”Maddalena (1954 film)”, ”Brian Kennedy (gallery director) ”], ”answer”: [”Augusto Genina”]} +QS: [EOQ] + +QC: Where did Augusto Genina die? + +QS: (select) [retrieve] Where did Augusto Genina die? + +A: [”Dana Blankstein”, ”Augusto Genina”, ”Peter Levin”, ”Olav Aaraas”] + +QS: (select) [singlehop titleqa] Titles: [”Dana Blankstein”, ”Augusto Genina”, ”Peter Levin”, ” Olav Aaraas”]. Question: Where did Augusto Genina die? + +A: {”titles”: [”Dana Blankstein”, ”Augusto Genina”, ”Peter Levin”, ”Olav Aaraas”], ”answer”: [” Rome”]} +QS: [EOQ] + +QC: When was Martin Hodge born? + +QS: (select) [retrieve] When was Martin Hodge born? + +A: [”Greg A. Hill (artist)”, ”Martin Hodge”, ”John Allen (Oxford University cricketer)”] + +QS: (select) [singlehop titleqa] Titles: [”Greg A. Hill (artist)”, ”Martin Hodge”, ”John Allen ( Oxford University cricketer)”]. Question: When was Martin Hodge born? + +A: {”titles”: [”Greg A. Hill (artist)”, ”Martin Hodge”, ”John Allen (Oxford University cricketer)”], ”answer”: [”4 February 1959”]} +QS: [EOQ] + +QC: When was Ivania Martinich born? + +QS: (select) [retrieve] When was Ivania Martinich born? + +A: [”Tom Dickinson”, ”Ivania Martinich”, ”Wesley Barresi”, ”Henry Moore (cricketer)”] + +QS: (select) [singlehop titleqa] Titles: [”Tom Dickinson”, ”Ivania Martinich”, ”Wesley Barresi”, ” Henry Moore (cricketer)”]. Question: When was Ivania Martinich born? + +A: {”titles”: [”Tom Dickinson”, ”Ivania Martinich”, ”Wesley Barresi”, ”Henry Moore (cricketer) ”], ”answer”: [”25 July 1995”]} +QS: [EOQ] + +2wikimultihopqa: singlehop titleqa + +Wikipedia Title: David Dhawan + +Wikipedia Title: Howard W. Koch + +Wikipedia Title: The Sensational Trial $ + +Wikipedia Title: Coolie No. 1 (1995 film) + +Wikipedia Title: Karl Freund + +Q: Who is the director of the film Coolie No. 1 (1995 film)? + +A: [”David Dhawan”] + +Q: Who is the director of the film The Sensational Trial? + +A: [”Karl Freund”] + +Q: What is David Dhawan’s nationality? + +A: [”India”] + +Q: What is Karl Freund’s nationality? A: [”Germany”] + +Wikipedia Title: Fred de Cordova + +Wikipedia Title: Thulasi (1987 film) + +Wikipedia Title: Joseph M. Newman + +Wikipedia Title: The Gal Who Took the West + +Wikipedia Title: Twenty Plus Two + +Q: Who is the director of the film Twenty Plus? + +A: [”Joseph M. Newman”] + +Q: Who is the director of the film The Gal Who Took the West? + +A: [”Frederick de Cordova”] + +
A: ["Frederick de Cordova"] Q: When did Joseph M. Newman die?
A: ["January 23, 2006"]
Q: When did Fred de Cordova die? A: ["September 15, 2001"]
Wikipedia Title: Ana Gruzinsky-Golitsyn <hidden for brevity>
Wikipedia Title: Rudra Shah <hidden for brevity>
Wikipedia Title: Krishna Shah (Nepalese royal) <hidden for brevity>
Q: Who is the child of Krishna Shah? A: ["Rudra Shah"]
Q: Who is the child of Rudra Shah? A: ["Prithvipati Shah”]
Wikipedia Title: Augusto Genina <hidden for brevity>
Wikipedia Title: Ian Barry (director) <hidden for brevity>
Wikipedia Title: Maddalena (1954 film) <hidden for brevity>
Q: Who is the director of the film Maddalena? A: ["Augusto Genina"]
Q: Where did Augusto Genina die? A: ['"Rome"]
Wikipedia Title: Martin Hodge <hidden for brevity>
Wikipedia Title: Ivania Martinich <hidden for brevity>
Wikipedia Title: Tom Dickinson <hidden for brevity>
Q: When was Martin Hodge born?
A: ["4 February 1959"] Q: When was Ivania Martinich born? A: ["25 July 1995"]
+ +2wikimultihopqa: multihop titleqa (direct) + +Wikipedia Title: Howard W. Koch + +Wikipedia Title: The Sensational Trial + +Wikipedia Title: Coolie No. 1 (1995 film) + +Wikipedia Title: Karl Freund + +Q: Do director of film Coolie No. 1 (1995 Film) and director of film The Sensational Trial have the same nationality? + +Wikipedia Title: Fred de Cordova + +Wikipedia Title: Thulasi (1987 film) + +Wikipedia Title: Joseph M. Newman + +Wikipedia Title: The Gal Who Took the West + +Wikipedia Title: Twenty Plus Two + +Q: Which film has the director died later, The Gal Who Took the West or Twenty Plus Two? A: [”Twenty Plus Two”] + +Wikipedia Title: Ana Gruzinsky−Golitsyn + +Wikipedia Title: Rudra Shah + +Wikipedia Title: Krishna Shah (Nepalese royal) + +Q: Who is the grandchild of Krishna Shah (Nepalese Royal)? A: [”Prithvipati Shah”] + +Wikipedia Title: Augusto Genina + +Wikipedia Title: Ian Barry (director) + +Wikipedia Title: Maddalena (1954 film) + +Q: Where did the director of film Maddalena (1954 Film) die? + +A: [”Rome”] + +Wikipedia Title: Martin Hodge + +Wikipedia Title: Ivania Martinich + +Wikipedia Title: Tom Dickinson + +Q: Who was born first out of Martin Hodge and Ivania Martinich? A: [”Martin Hodge”] + +2wikimultihopqa: multihop titleqa (cot) + +Wikipedia Title: David Dhawan + +Wikipedia Title: Howard W. Koch + +Wikipedia Title: The Sensational Trial + +Wikipedia Title: Coolie No. 1 (1995 film) + +Wikipedia Title: Karl Freund + +Q: Do director of film Coolie No. 1 (1995 Film) and director of film The Sensational Trial have the same nationality? + +A: Coolie No. 1 (1995 film) was directed by David Dhawan. The Sensational Trial was directed by Karl Freund. David Dhawan’s nationality is India. Karl Freund’s nationality is Germany. + +Thus, they do not have the same nationality. So the answer is: no. + +Wikipedia Title: Fred de Cordova + +Wikipedia Title: Thulasi (1987 film) + +Wikipedia Title: Joseph M. Newman + +Wikipedia Title: The Gal Who Took the West + +Wikipedia Title: Twenty Plus Two + +Which film has the director died later, The Gal Who Took the West or Twenty Plus Two? A: The film Twenty Plus Two was directed by Joseph M. Newman. The Gal Who Took the West was directed by Frederick de Cordova. Joseph M. Newman died on January 23, 2006. Fred de Cordova died on September 15, 2001. Thus, the person to die later from the two is Twenty Plus Two. So the answer is: Twenty Plus Two. + +Wikipedia Title: Ana Gruzinsky−Golitsyn $ + +Wikipedia Title: Rudra Shah + +Wikipedia Title: Krishna Shah (Nepalese royal) + +Q: Who is the grandchild of Krishna Shah (Nepalese Royal)? + +A: Krishna Shah has a child named Rudra Shah. Rudra Shah has a child named Prithvipati Shah. Thus, Krishna Shah has a grandchild named Prithvipati Shah. So the answer is: Prithvipati Shah. + +Wikipedia Title: Augusto Genina $ + +Wikipedia Title: Ian Barry (director) + +Wikipedia Title: Maddalena (1954 film) + +Q: Where did the director of film Maddalena (1954 Film) die? + +A: The film Maddalena is directed by Augusto Genina. Augusto Genina died in Rome. So the answer is: Rome. + +Wikipedia Title: Martin Hodge + +Wikipedia Title: Ivania Martinich + +Wikipedia Title: Tom Dickinson + +Q: Who was born first out of Martin Hodge and Ivania Martinich? + +A: Martin Hodge was born on 4 February 1959. Ivania Martinich was born on 25 July 1995. Thus, Martin Hodge was born first. So the answer is: Martin Hodge. + +musique ans: decomp + +QC: When did the first large winter carnival take place in the city where CIMI−FM is licensed to broadcast? + +QS: (select) [retrieve odqa] What city is CIMI−FM is licensed to broadcast in? + +A: {”titles”: [”KWMZ−FM”, ”CIMI−FM”, ”KSAO (FM)”, ”WTTL−FM”, ”KOLU”, ”WORW”, ” WLRX (FM)”], ”answer”: [”Quebec City”]} + +QS: (select) [retrieve odqa] When did the first large winter carnival in Quebec City take place? + +A: {”titles”: [”WRQY”, ”Quebec Winter Carnival”, ”KBCR−FM”], ”answer”: [”1894”]} + +QS: (select) [multihop titleqa] Titles: [”KWMZ−FM”, ”CIMI−FM”, ”KSAO (FM)”, ”WTTL−FM ”, ”KOLU”, ”WORW”, ”WLRX (FM)”, ”WRQY”, ”Quebec Winter Carnival”, ”KBCR−FM ”]. Question: When did the first large winter carnival take place in the city where CIMI−FM is licensed to broadcast? + +A: [”1894”] QS: [EOQ] + +QC: What is the headquarters for the organization who sets the standards for ISO 21500? QS: (select) [retrieve odqa] Who sets the standards for ISO 21500? + +A: {”titles”: [”ISO 3166−2:BM”, ”ISO 3166−2:IS”, ”ISO 3166−2:IT”, ”ISO 3166−2:BB”, ”ISO 21500”, ”ISO 3166−2:ET”, ”ISO 3166−2:AT”, ”ISO 3166−2:CG”, ”ISO 22000”], ”answer”: [”International Organization for Standardization”]} + +QS: (select) [retrieve odqa] Where is the headquarters for International Organization for Standardization? + +A: {”titles”: [”International Organization for Standardization”, ”ISO 4031”, ”ISO 3166−2:CN”, ” Unicode”, ”ISO 3166−2:GH”, ”ISO 3166−2:AO”, ”ISO/TC 68”, ”ISO 7001”, ”ISO 3307”], ” answer”: [”Geneva”]} + +QS: (select) [multihop titleqa] Titles: [”ISO 3166−2:BM”, ”ISO 3166−2:IS”, ”ISO 3166−2:IT”, ” ISO 3166−2:BB”, ”ISO 21500”, ”ISO 3166−2:ET”, ”ISO 3166−2:AT”, ”ISO 3166−2:CG”, ” ISO 22000”, ”International Organization for Standardization”, ”ISO 4031”, ”ISO 3166−2:CN ”, ”Unicode”, ”ISO 3166−2:GH”, ”ISO 3166−2:AO”, ”ISO/TC 68”, ”ISO 7001”, ”ISO 3307”]. Question: What is the headquarters for the organization who sets the standards for ISO 21500? +A: [”Geneva”] +QS: [EOQ] + +QC: How long is the US border with the country that borders the state where Finding Dory takes place? + +QS: (select) [retrieve odqa] In which state does Finding Dory take place? + +A: {”titles”: [”Finding Dory”, ”Latvia”, ”List of countries that border only one other country”, ” Removal of Hungary’s border fence with Austria”], ”answer”: [”California”]} + +QS: (select) [retrieve odqa] Which country shares a border with California? + +A: {”titles”: [”Mexico−United States border”, ”Kingdom of Gera”, ”Pesticide”, ”Currie Cup”], ” answer”: [”Mexico”]} + +lect) [retrieve odqa] What is the length of the US border with Mexico? + +A: {”titles”: [”Piscataqua River border dispute”, ”Share a Coke”, ”Mexico−United States border”, ”Hotel Arbez”], ”answer”: [”1,989 mi”]} + +QS: (select) [multihop titleqa] Titles: [”Finding Dory”, ”Latvia”, ”List of countries that border only one other country”, ”Removal of Hungary’s border fence with Austria”, ”Mexico− United States border”, ”Kingdom of Gera”, ”Pesticide”, ”Currie Cup”, ”Piscataqua River border dispute”, ”Share a Coke”, ”Mexico−United States border”, ”Hotel Arbez”]. Question: How long is the US border with the country that borders the state where Finding Dory takes place? +A: [”1,989 mi”] +QS: [EOQ] + +QC: When was Neville A. Stanton’s employer founded? + +QS: (select) [retrieve odqa] Who is the employer of Neville A. Stanton? + +A: {”titles”: [”Harriot Stanton Blatch”, ”Robichaud v Canada (Treasury Board)”, ”The Peggy Neville Show”, ”Stanton Township, Champaign County, Illinois”, ”Women’s suffrage in the United States”, ”Neville A. Stanton”], ”answer”: [”University of Southampton”]} + +S: (select) [retrieve odqa] When was the University of Southampton founded + +A: {”titles”: [”Southampton”, ”Presley Neville”], ”answer”: [”1862”]} + +QS: (select) [multihop titleqa] Titles: [”Harriot Stanton Blatch”, ”Robichaud v Canada (Treasury Board)”, ”The Peggy Neville Show”, ”Stanton Township, Champaign County, Illinois”, ” Women’s suffrage in the United States”, ”Neville A. Stanton”, ”Southampton”, ”Presley Neville”]. Question: When was Neville A. Stanton’s employer founded? +A: [”1862”] +QS: [EOQ] + +QC: In which county was the birthplace of the Smoke in tha City performer? QS: (select) [retrieve odqa] Who is the performer of Smoke in the City? + +A: {”titles”: [”Nicotine marketing”, ”Khabarovsky District”, ”Beyonce”, ”Asthma”, ”Smoke in tha City”], ”answer”: [”MC Eiht”]} + +QS: (select) [retrieve odqa] What is the birthplace of MC Eiht? + +A: {”titles”: [”Cherokee City, Arkansas”, ”MC Eiht”, ”Biysky District”], ”answer”: [”Compton”]} QS: (select) [retrieve odqa] Compton is located in which county? + +A: {”titles”: [”Vilnius County”, ”Biblioteca Ayacucho”, ”Compton, California”], ”answer”: [”Los Angeles County”]} + +QS: (select) [multihop titleqa] Titles: [”Nicotine marketing”, ”Khabarovsky District”, ”Beyonce”, ”Asthma”, ”Smoke in tha City”, ”Cherokee City, Arkansas”, ”MC Eiht”, ”Biysky District”, ” Vilnius County”, ”Biblioteca Ayacucho”, ”Compton, California”]. Question: In which county was the birthplace of the Smoke in tha City performer? + +A: [”Los Angeles County”] QS: [EOQ] + +musique ans: retrieve odqa + +QC: What city is CIMI−FM is licensed to broadcast in? + +QS: (select) [retrieve] What city is CIMI−FM is licensed to broadcast in? +A: [”KWMZ−FM”, ”CIMI−FM”, ”KSAO (FM)”, ”WTTL−FM”, ”KOLU”, ”WORW”, ”WLRX ( FM)”] +QS: (select) [singlehop titleqa] Titles: [”KWMZ−FM”, ”CIMI−FM”, ”KSAO (FM)”, ”WTTL−FM ”, ”KOLU”, ”WORW”, ”WLRX (FM)”]. Question: What city is CIMI−FM is licensed to broadcast in? +A: {”titles”: [”KWMZ−FM”, ”CIMI−FM”, ”KSAO (FM)”, ”WTTL−FM”, ”KOLU”, ”WORW”, ” WLRX (FM)”], ”answer”: [”Quebec City”]} +QS: [EOQ] + +QC: When did the first large winter carnival in Quebec City take place? + +QS: (select) [retrieve] When did the first large winter carnival in Quebec City take place? + +A: [”WRQY”, ”Quebec Winter Carnival”, ”KBCR−FM”] + +QS: (select) [singlehop titleqa] Titles: [”WRQY”, ”Quebec Winter Carnival”, ”KBCR−FM”] Question: When did the first large winter carnival in Quebec City take place? + +A: {”titles”: [”WRQY”, ”Quebec Winter Carnival”, ”KBCR−FM”], ”answer”: [”1894”]} QS: [EOQ] + +QC: Who sets the standards for ISO 21500? +QS: (select) [retrieve] Who sets the standards for ISO 21500? +A: [”ISO 3166−2:BM”, ”ISO 3166−2:IS”, ”ISO 3166−2:IT”, ”ISO 3166−2:BB”, ”ISO 21500”, ” ISO 3166−2:ET”, ”ISO 3166−2:AT”, ”ISO 3166−2:CG”, ”ISO 22000”] + +QS: (select) [singlehop titleqa] Titles: [”ISO 3166−2:BM”, ”ISO 3166−2:IS”, ”ISO 3166−2:IT”, ” ISO 3166−2:BB”, ”ISO 21500”, ”ISO 3166−2:ET”, ”ISO 3166−2:AT”, ”ISO 3166−2:CG”, ” ISO 22000”]. Question: Who sets the standards for ISO 21500? + +A: {”titles”: [”ISO 3166−2:BM”, ”ISO 3166−2:IS”, ”ISO 3166−2:IT”, ”ISO 3166−2:BB”, ”ISO 21500”, ”ISO 3166−2:ET”, ”ISO 3166−2:AT”, ”ISO 3166−2:CG”, ”ISO 22000”], ”answer”: [”International Organization for Standardization”]} + +QS: [EOQ] + +QC: Where is the headquarters for International Organization for Standardization? + +QS: (select) [retrieve] Where is the headquarters for International Organization for Standardization ? + +A: [”International Organization for Standardization”, ”ISO 4031”, ”ISO 3166−2:CN”, ”Unicode”, ”ISO 3166−2:GH”, ”ISO 3166−2:AO”, ”ISO/TC 68”, ”ISO 7001”, ”ISO 3307”] + +QS: (select) [singlehop titleqa] Titles: [”International Organization for Standardization”, ”ISO 4031”, ”ISO 3166−2:CN”, ”Unicode”, ”ISO 3166−2:GH”, ”ISO 3166−2:AO”, ”ISO/TC 68”, ”ISO 7001”, ”ISO 3307”]. Question: Where is the headquarters for International Organization for Standardization? + +A: {”titles”: [”International Organization for Standardization”, ”ISO 4031”, ”ISO 3166−2:CN”, ” Unicode”, ”ISO 3166−2:GH”, ”ISO 3166−2:AO”, ”ISO/TC 68”, ”ISO 7001”, ”ISO 3307”], ” answer”: [”Geneva”]} +QS: [EOQ] + +QC: In which state does Finding Dory take place? + +QS: (select) [retrieve] In which state does Finding Dory take place? + +A: [”Finding Dory”, ”Latvia”, ”List of countries that border only one other country”, ”Removal of Hungary’s border fence with Austria”] + +QS: (select) [singlehop titleqa] Titles: [”Finding Dory”, ”Latvia”, ”List of countries that border only one other country”, ”Removal of Hungary’s border fence with Austria”]. Question: In which state does Finding Dory take place? + +A: {”titles”: [”Finding Dory”, ”Latvia”, ”List of countries that border only one other country”, ” Removal of Hungary’s border fence with Austria”], ”answer”: [”California”]} QS: [EOQ] + +QC: Which country shares a border with California? + +: (select) [retrieve] Which country shares a border with California? + +A: [”Mexico−United States border”, ”Kingdom of Gera”, ”Pesticide”, ”Currie Cup”] + +QS: (select) [singlehop titleqa] Titles: [”Mexico−United States border”, ”Kingdom of Gera”, ” Pesticide”, ”Currie Cup”]. Question: Which country shares a border with California? + +A: {”titles”: [”Mexico−United States border”, ”Kingdom of Gera”, ”Pesticide”, ”Currie Cup”], ” answer”: [”Mexico”]} +QS: [EOQ] + +QC: What is the length of the US border with Mexico? + +S: (select) [retrieve] What is the length of the US border with Mexico? + +A: [”Piscataqua River border dispute”, ”Share a Coke”, ”Mexico−United States border”, ”Hotel Arbez”] + +QS: (select) [singlehop titleqa] Titles: [”Piscataqua River border dispute”, ”Share a Coke”, ” Mexico−United States border”, ”Hotel Arbez”]. Question: What is the length of the US border with Mexico? + +A: {”titles”: [”Piscataqua River border dispute”, ”Share a Coke”, ”Mexico−United States border”, ”Hotel Arbez”], ”answer”: [”1,989 mi”]} +QS: [EOQ] + +QC: Who is the employer of Neville A. Stanton? + +QS: (select) [retrieve] Who is the employer of Neville A. Stanton? + +A: [”Harriot Stanton Blatch”, ”Robichaud v Canada (Treasury Board)”, ”The Peggy Neville Show ”, ”Stanton Township, Champaign County, Illinois”, ”Women’s suffrage in the United States”, ”Neville A. Stanton”] + +QS: (select) [singlehop titleqa] Titles: [”Harriot Stanton Blatch”, ”Robichaud v Canada (Treasury Board)”, ”The Peggy Neville Show”, ”Stanton Township, Champaign County, Illinois”, ” Women’s suffrage in the United States”, ”Neville A. Stanton”]. Question: Who is the employer of Neville A. Stanton? + +A: {”titles”: [”Harriot Stanton Blatch”, ”Robichaud v Canada (Treasury Board)”, ”The Peggy Neville Show”, ”Stanton Township, Champaign County, Illinois”, ”Women’s suffrage in the United States”, ”Neville A. Stanton”], ”answer”: [”University of Southampton”]} +QS: [EOQ] + +QC: When was the University of Southampton founded? QS: (select) [retrieve] When was the University of Southampton founded? A: [”Southampton”, ”Presley Neville”] + +QS: (select) [singlehop titleqa] Titles: [”Southampton”, ”Presley Neville”]. Question: When was the University of Southampton founded? + +A: {”titles”: [”Southampton”, ”Presley Neville”], ”answer”: [”1862”]} QS: [EOQ] + +QC: Who is the performer of Smoke in the City? + +QS: (select) [retrieve] Who is the performer of Smoke in the City? + +A: [”Nicotine marketing”, ”Khabarovsky District”, ”Beyonce”, ”Asthma”, ”Smoke in tha City”] QS: (select) [singlehop titleqa] Titles: [”Nicotine marketing”, ”Khabarovsky District”, ”Beyonce”, ”Asthma”, ”Smoke in tha City”]. Question: Who is the performer of Smoke in the City? + +A: {”titles”: [”Nicotine marketing”, ”Khabarovsky District”, ”Beyonce”, ”Asthma”, ”Smoke in tha City”], ”answer”: [”MC Eiht”]} +QS: [EOQ] + +QC: What is the birthplace of MC Eiht? + +QS: (select) [retrieve] What is the birthplace of MC Eiht? + +A: [”Cherokee City, Arkansas”, ”MC Eiht”, ”Biysky District”] + +QS: (select) [singlehop titleqa] Titles: [”Cherokee City, Arkansas”, ”MC Eiht”, ”Biysky District”]. Question: What is the birthplace of MC Eiht? + +A: {”titles”: [”Cherokee City, Arkansas”, ”MC Eiht”, ”Biysky District”], ”answer”: [”Compton”]} QS: [EOQ] + +QC: Compton is located in which county? + +QS: (select) [retrieve] Compton is located in which county? + +A: [”Vilnius County”, ”Biblioteca Ayacucho”, ”Compton, Cali + +S: (select) [singlehop titleqa] Titles: [”Vilnius County”, ”Biblioteca Ayacucho”, ”Compton, California”]. Question: Compton is located in which county? + +A: {”titles”: [”Vilnius County”, ”Biblioteca Ayacucho”, ”Compton, California”], ”answer”: [”Los Angeles County”]} +QS: [EOQ] + +musique ans: singlehop titleqa + +Wikipedia Title: CIMI−FM + +Wikipedia Title: Quebec Winter Carnival + +Wikipedia Title: KELD−FM + +Q: What city is CIMI−FM is licensed to broadcast in? + +A: [”Quebec City”] + +Q: When did the first large winter carnival in Quebec City take place? + +A: [”1894”] + +Wikipedia Title: ISO/TC 68 + +Wikipedia Title: ISO 21500 + +Wikipedia Title: ISO 3166−2:GH + +
Q: Who sets the standards for ISO 21500? A: ["International Organization for Standardization"]
Q: Where is the headquarters for International Organiza A: ["Geneva"]
Wikipedia Title: Mexico-United States border <hidden for brevity>
Wikipedia Title: Mexico-United States border <hidden for brevity>
Wikipedia Title: Finding Dory <hidden for brevity>
Wikipedia Title: India <hidden for brevity>
Q: In which state does Finding Dory take place? A: ["California"]
Q: Which country shares a border with California? A: ["Mexico”]
Q: What is the length of the US border with Mexico? A: ["1,989 mi”]
Wikipedia Title: Southampton <hidden for brevity>
Wikipedia Title: Jonathan Stanton <hidden for brevity>
Wikipedia Title: Neville A. Stanton <hidden for brevity>
Q: Who is the employer of Neville A. Stanton? A: ["University of Southampton”]
Q: When was the University of Southampton founded? A: ["1862"]
Wikipedia Title: Compton, California
<hidden for brevity> Wikipedia Title: Smoke in tha City <hidden for brevity>
Wikipedia Title: MC Eiht <hidden for brevity>
Wikipedia Title: Eastern Bengal and Assam
<hidden for brevity> Q: Who is the performer of Smoke in the City?
+ +A: [”MC Eiht”] + +Q: What is the birthplace of MC Eiht? + +A: [”Compton”] + +Q: Compton is located in which county? A: [”Los Angeles County”] + +musique ans: multihop titleqa (direct) + +Wikipedia Title: CIMI−FM + +Wikipedia Title: Quebec Winter Carnival + +Wikipedia Title: KELD−FM + +Q: When did the first large winter carnival take place in the city where CIMI−FM is licensed to broadcast? + +A: [”1894”] + +Wikipedia Title: ISO/TC 68 + +Wikipedia Title: ISO 21500 + +Wikipedia Title: ISO 3166−2:GH + +Q: What is the headquarters for the organization who sets the standards for ISO 21500? A: [”Geneva”] + +Wikipedia Title: Mexico−United States border + +Wikipedia Title: Mexico−United States border + +Wikipedia Title: Finding Dory + +Wikipedia Title: India + +Q: How long is the US border with the country that borders the state where Finding Dory takes place? + +A: [”1,989 mi”] + +Wikipedia Title: Southampton + +Wikipedia Title: Jonathan Stanton $ + +Wikipedia Title: Neville A. Stanton + +Q: When was Neville A. Stanton’s employer founded? A: [”1862”] + +Wikipedia Title: Compton, California + +Wikipedia Title: Smoke in tha City + +Wikipedia Title: MC Eiht + +Wikipedia Title: Eastern Bengal and Assam + +Q: In which county was the birthplace of the Smoke in tha City performer? A: [”Los Angeles County”] + +musique ans: multihop titleqa (cot) + +Wikipedia Title: CIMI−FM + +Wikipedia Title: Quebec Winter Carnival + +Wikipedia Title: KELD−FM + +Q: When did the first large winter carnival take place in the city where CIMI−FM is licensed to broadcast? + +A: CIMI−FM is licensed to broadcast in Quebec City. The first large winter carnival in Quebec City took place in 1894. So the answer is: 1894. + +Wikipedia Title: ISO/TC 68 + +Wikipedia Title: ISO 21500 + +Wikipedia Title: ISO 3166−2:GH + +Q: What is the headquarters for the organization who sets the standards for ISO 21500? + +A: The standards for ISO 21500 were set by International Organization for Standardization. The International Organization for Standardization has headquarters in Geneva. So the answer is: Geneva. + +Wikipedia Title: Mexico−United States border + +Wikipedia Title: Mexico−United States border $ + +Wikipedia Title: Finding Dory + +Wikipedia Title: India + +Q: How long is the US border with the country that borders the state where Finding Dory takes place? + +A: Finding Dory is supposed to take place in California. The country that shares a border with California is Mexico. The length of the us border with Mexico is $1 { , } 9 8 9 \mathrm { m i }$ . So the answer is: 1,989 mi. + +Wikipedia Title: Southampton + +Wikipedia Title: Jonathan Stanton + +Wikipedia Title: Neville A. Stanton + +Q: When was Neville A. Stanton’s employer founded? + +A: The employer of Neville A. Stanton is University of Southampton. The University of Southampton was founded in 1862. So the answer is: 1862. + +Wikipedia Title: Compton, California + +Wikipedia Title: Smoke in tha City + +Wikipedia Title: MC Eiht + +Wikipedia Title: Eastern Bengal and Assam $ + +Q: In which county was the birthplace of the Smoke in tha City performer? + +A: The performer of Smoke in tha City is MC Eiht. MC Eiht’s birthplace is Compton. Compton is located in the county of Los Angeles County. So the answer is: Los Angeles County. \ No newline at end of file diff --git a/md/dev/aUkOeKsGe2X/aUkOeKsGe2X.md b/md/dev/aUkOeKsGe2X/aUkOeKsGe2X.md new file mode 100644 index 0000000000000000000000000000000000000000..b544b5e22a07eafea56b453fea95fd6eaa3a5f0e --- /dev/null +++ b/md/dev/aUkOeKsGe2X/aUkOeKsGe2X.md @@ -0,0 +1,345 @@ +# AUTOENCODER FOR SYNTHETIC TO REAL GENERAL-IZATION: FROM SIMPLE TO MORE COMPLEX SCENES + +Anonymous authors Paper under double-blind review + +# ABSTRACT + +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. + +# 1 INTRODUCTION + +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). + +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. + +![](images/40c198ac0999a1f43500c6b8d0cbde127e17c08caa224e39542524b626016d6a.jpg) +Figure 1: Impossible Instance Extractor Triplet Autoencoder (II-E-TAE) model architecture. + +# 2 RELATED WORKS + +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). + +# 3 METHOD + +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. + +![](images/f525930f7109f4a5a7374812d496b8eb857a5292a06c680efe38c5ea117e6e5f.jpg) +Figure 2: Illustration of the different input-target pairs for the autoencoder reconstruction loss. + +# 3.1 MODEL ARCHITECTURE: EXTRACTOR AUTOENCODER + +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 + +$$ +\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} +$$ + +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. + +# 3.2 SAMPLING STRATEGY: PARTIAL IMPOSSIBLE + +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$ : + +$$ +\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} +$$ + +We refer to models using the PIRL by prepending an $I$ , e.g. I-E-AE. + +# 3.3 SAMPLING STRATEGY: PARTIAL IMPOSSIBLE CLASS INSTANCE + +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 + +$$ +\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} +$$ + +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. + +# 3.4 STRUCTURE IN THE LATENT SPACE: TRIPLET LOSS + +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 + +$$ +\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) , +$$ + +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$ ): + +$$ +\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} +$$ + +# 4 EXPERIMENTS + +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. + +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). + +# 4.1 AUTOENCODERS STRUGGLE ON REAL IMAGES WHEN TRAINED ON SYNTHETIC IMAGES + +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. + +# 4.2 AUTOENCODERS OVERFIT TO THE SYNTHETIC DISTRIBUTION + +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. + +# 4.3 MORE GENERAL INPUT FEATURES IMPROVE AUTOENCODER RECONSTRUCTIONS + +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. + +![](images/db606ab564fb554bdc68096e90d37d57c729a2703f583ee9a2724ce27a15c9dd.jpg) + +![](images/b5c4273e246fb0d9bfe97bc6f85d6aa8e9268600bd6dc1f5d8f6bbf75c352d4d.jpg) + +![](images/74146757d8795cea08c1f93a2bbf952eea2c98a1572f0d43b12d006b0d909e8d.jpg) +(c) Reconstruction of real data when being trained on toy data. + +![](images/23c7452661ed37019e8f46d5d7f3b01bbbf06cb1b2d71dedb3b96b4800d72027.jpg) +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). +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. + +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. + +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. + +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. + +
L1↓SSIM↑LPIPS↓
Trained onModelVariantSynth.RealSynth.RealSynth.Real
ToyAESSIM93217630.560.420.350.40
ToyVAEBCE65914970.500.330.340.42
Toyβ-VAEBCE,β=471015420.530.380.310.44
Toyβ-VAEBCE,β=840613210.710.480.260.37
ToyFactorVAEBCE,= 1052112880.660.450.260.39
ToyFactorVAEBCE, = 5043012950.710.510.220.35
ToyE-AE (ours)SSIM17711650.900.580.100.28
RealisticAESSIM56811330.830.620.200.24
RealisticVAEBCE4828900.740.610.200.23
Realisticβ-VAEBCE,β= 43728330.810.640.180.20
Realisticβ-VAEBCE,β=83848540.790.640.190.21
RealisticFactorVAEBCE, = 102187340.880.680.150.19
RealisticFactorVAEBCE,= 503918300.780.640.160.18
RealisticE-AE (ours)SSIM2518410.920.700.080.14
+ +# 4.4 IT WORKS FOR VISUALLY SIMPLE IMAGES - MORE IS NEEDED ON MORE COMPLEX DATA + +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. + +# 4.5 PARTIALLY IMPOSSIBLE RECONSTRUCTION LOSS HELPS GENERALIZATION + +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. + +![](images/4281065016928bbab651c5b624d62a1d31e928c2bf2d37618ea3d1b593ca8a77.jpg) +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. + +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. + +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. + +# 4.6 STRUCTURE IN THE LATENT SPACE HELPS GENERALIZATION + +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. + +![](images/d2e3018806e7aeb40bb69ac24c26fbfc65654d09fd618bd03a61176a143b76ff.jpg) +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. + +# 4.7 KNN WITH TRIPLET LOSS OUT-PERFORMS FINE TUNED CLASSIFICATION MODELS + +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. + +# 5 DISCUSSION AND LIMITATIONS + +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. + +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. + +
TICaMSVIRO
ModelVariantMeanMaxMeanMax
VGG-11Pre-trained75.5 ± 1.578.078.7± 2.984.0
Resnet-50Pre-trained78.1 ± 1.780.483.5 ± 2.788.1
VGG-11 Resnet-50E-TAE E-TAE76.7± 2.3 83.8 ± 1.381.5 86.078.6 ± 2.6 85.8± 2.482.3
89.1
VGG-11I-E-TAE79.7 ± 2.182.280.9 ± 4.085.6
Resnet-50I-E-TAE83.5 ± 1.385.689.2 ± 1.090.3
VGG-11II-E-TAE81.0± 0.682.079.1± 3.984.8
Resnet-50II-E-TAE83.7± 0.584.593.0± 0.894.1
+ +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. + +
TICaMSVIRO
VariantKNNRForestSVMKNNRForestSVM
E-AE17.1 ± 6.724.2 ± 4.140.6 ± 8.538.7 ± 2.958.2 ± 2.072.9 ± 2.3
I-E-AE18.2 ± 7.342.4± 6.550.1± 3.761.0 ± 3.572.2 ± 2.573.8 ± 2.3
II-E-AE73.2 ± 3.968.8 ± 5.766.9 ± 6.783.7 ±1.979.8± 2.781.4± 2.2
E-TAE69.2 ± 3.466.4± 4.068.7 ± 2.276.2 ± 2.371.2 ± 2.575.3 ± 2.5
+ +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. + +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. + +# 6 CONCLUSION + +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. + +# REPRODUCIBILITY STATEMENT + +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. + +# CODE OF ETHICS + +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. + +# REFERENCES + +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. + +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. + +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. + +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. + +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. + +Wuyang Chen, Zhiding Yu, Zhangyang Wang, and Animashree Anandkumar. Automated syntheticto-real generalization. In International Conference on Machine Learning (ICML, 2020. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +Fang Gongfan. Pytorch ms-ssim. https://github.com/VainF/pytorch-msssim, 2019. + +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. + +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. + +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. + +Elad Hoffer and Nir Ailon. Deep metric learning using triplet network. In International Workshop on Similarity-Based Pattern Recognition (SIMBAD), 2015. + +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. + +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. + +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. + +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. + +Hyunjik Kim and Andriy Mnih. Disentangling by factorising. In International Conference on Machine Learning (ICML), 2018. + +Diederik P Kingma and Max Welling. Auto-encoding variational bayes. In International Conference on Learning Representations (ICLR), 2014. + +Yann LeCun, Leon Bottou, Yoshua Bengio, and Patrick Haffner. Gradient-based learning applied to ´ document recognition. Proceedings of the IEEE, 1998. + +Joonho Lee, Jemin Hwangbo, Lorenz Wellhausen, Vladlen Koltun, and Marco Hutter. Learning quadrupedal locomotion over challenging terrain. Science Robotics, 5(47), 2020. + +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. + +Xingchao Peng, Ben Usman, Neela Kaushik, Judy Hoffman, Dequan Wang, and Kate Saenko. Visda: The visual domain adaptation challenge, 2017. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +# A APPENDIX + +# A.1 DATASET DETAILS + +If not specified otherwise, all images have been centre cropped and resized to 128 pixels. + +# A.1.1 MPI3D + +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. + +# A.1.2 SVIRO + +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. + +# A.1.3 SVIRO-ILLUMINATION + +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. + +# A.1.4 OUR NEWLY RELEASED DATASET + +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. + +# A.1.5 TICAM + +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. + +![](images/ede576ee3ab39f781ba6de61b1d1324447567584a451def95a31a8e122ad430d.jpg) +Figure 7: Examples of sceneries with different backgrounds from the newly generated dataset. + +# A.2 TRAINING DETAILS + +All our experiments were conducted using PyTorch 1.8. Pre-defined and models pre-trained on Imagenet were taken from torchvision 0.9.0. + +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. + +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. + +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. + +# A.2.1 MODEL DETAILS + +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: + +VGG-11 +(16): Conv2d(512, 512, kernel_size $=$ (3, 3), stride $=$ (1, 1), padding $=$ (1, 1)) +(17): ReLU(inplace=True) + +Resnet-50 + +(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) +) + +Densenet-121 + +(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) +) + +Table 4: Model architecture for AE, VAE and $\beta$ -VAE on MPI3D + +
EncoderDecoder
Input: 3 x 64 x 64Input: 10
Conv, 4x4, 32, padding 1, stride 2 ReLUFC,256, bias True ReLU
Conv, 4x4,32, padding 1, stride 2 ReLUFC,1024,bias True ReLU
Conv, 4x4, 64, padding 1, stride 2 ReLUConvTranspose, 4x4,64, padding 1, stride 2 ReLU
Conv, 4x4, 64, padding 1, stride 2 ReLUConvTranspose, 4x4,32, padding 1, stride 2 ReLU
FC,256, bias True ReLUConvTranspose, 4x4, 32, padding 1, stride 2 ReLU
FC,10, bias True (twice in case of VAE)ConvTranspose, 4x4, 3, padding 1, stride 2 Sigmoid
+ +Table 5: Model architecture for FactorVAE on MPI3D. The model is exactly the same as the VAE model and uses the following discriminator. + +
Discriminator
Input: 10
FC,1000,bias TrueLeakyReLU(0.2)
FC,1000, bias TrueLeakyReLU(0.2)
FC,1000, bias TrueLeakyReLU(0.2)
FC,1000,bias TrueLeakyReLU(0.2)
FC,1000, bias TrueLeakyReLU(0.2)
FC, 2, bias True
+ +Table 6: Model architecture for E-AE on MPI3D. The extractor is fixed during training. + +
Extractor + Summarizer + EncoderDecoder
Input: 3 x 224 x 224Input: 10
VGG-11 extractor after 7th Conv layer + ReLU Avgpool, 2x2, stride 2, padding 0FC, 256, bias True ReLU
Conv, 4x4,256, padding 0, stride 1 ReLUFC,1024,bias True ReLU
FC,256,bias True ReLUConvTranspose, 4x4, 64, padding 1, stride 2 ReLU
FC,10, bias TrueConvTranspose, 4x4,32, padding 1, stride 2 ReLU
ConvTranspose, 4x4, 32, padding 1, stride 2 ReLU
ConvTranspose,4x4,3, padding 1, stride 2 Sigmoid
+ +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. + +
Extractor+ Summarizer+ EncoderDecoder
Input: C x 224 x 224Input: 64
VGG-11 extractor after 7th Conv layer + ReLU Avgpool, 2x2, stride 2, padding 0FC, 256, bias True ReLU
Conv, 4x4, 256, padding 0, stride 1 ReLUFC, 4096,bias True ReLU
FC,256, bias True ReLUConvTranspose, 4x4, 64, padding 1, stride 2 ReLU
FC, 64, bias TrueConvTranspose, 4x4,32, padding 1, stride 2 ReLU
ConvTranspose, 4x4,32,padding 1, stride 2 ReLU
ConvTranspose, 4x4, C, padding 1, stride 2 Sigmoid
+ +![](images/9924c84adc4ef9be81f96a01eaad42978a62bc60065cb4e59248401a47ada55f.jpg) +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. + +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. + +
Trained onModelVariantL1↓SSIM↑LPIPS↓
ToyAEBCE7680.5590.412
ToyAESSIM9320.5580.347
ToyE-AE (ours)BCE2910.8960.095
ToyE-AE (ours)SSIM1770.8990.103
ToyVAEBCE6590.4970.338
Toyβ-VAEBCE,β= 47100.5270.311
Toyβ-VAEBCE,β=84060.7090.258
ToyFactorVAEBCE,=105210.6600.262
ToyFactorVAEBCE, = 304470.7100.344
ToyFactorVAEBCE,γ = 504300.7120.221
RealisticAEBCE3730.8410.211
RealisticAESSIM5680.8320.195
RealisticE-AE (ours)BCE2200.917
RealisticE-AE (ours)SSIM2510.9210.071
RealisticVAEBCE4820.7400.081
Realisticβ-VAEBCE,β= 43720.8100.197
Realisticβ-VAEBCE,β=83840.7940.176
FactorVAEBCE,γ= 102180.8800.189
RealisticFactorVAEBCE, = 302440.8620.151
Realistic3910.161
RealisticFactorVAEBCE,γ = 500.7790.164
+ +![](images/de052ac8418571befb4990a43a6c1c6ce17b9723fd012ea1b9a9278659938097.jpg) +(a) Reconstruction of training data when being trained on realistic data. + +![](images/8dc8fb9439a9eb337dec11411c741edb66a8f3da019bc395d49084f900c41b13.jpg) +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). + +(b) Reconstruction of training data when being trained on toy data. + +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. + +
DatasetTICaMSVIRO
Dataset size1335611959
ModelVariantMeanMaxMeanMax
VGG-11Scratch58.5 ± 4.064.665.6 ± 5.472.7
Resnet-50Scratch53.3 ± 3.560.456.4 ± 2.659.3
Densenet-121Scratch56.3 ± 5.562.168.8± 2.474.9
VGG-11Pre-trained75.5 ± 1.578.078.7± 2.984.0
Resnet-50Pre-trained78.1 ± 1.780.483.5 ± 2.788.1
Densenet-121Pre-trained72.2 ± 4.277.485.0 ± 2.388.0
VGG-11E-TAE76.7 ± 2.381.578.6 ± 2.682.3
Resnet-50E-TAE83.8 ± 1.386.085.8 ± 2.489.1
Densenet-121E-TAE78.5 ± 2.481.886.7 ± 1.388.2
VGG-11I-E-TAE79.7 ± 2.182.280.9 ± 4.085.6
Resnet-50I-E-TAE83.5 ± 1.385.689.2 ± 1.090.3
Densenet-121I-E-TAE77.2 ± 1.779.390.4 ± 1.392.1
VGG-11II-E-TAE81.0 ± 0.682.079.1 ± 3.984.8
Resnet-50II-E-TAE83.7 ± 0.584.593.0 ± 0.894.1
Densenet-121II-E-TAE79.3 ± 1.381.589.9 ± 1.892.3
+ +![](images/ad6b959581948049348901aa328ca18fa4ad72ebd2d1172c214851fcdfc96631.jpg) +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. + +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. + +
ModelKNNRForestSVM
AE15.712.511.6
TAE11.111.68.4
II-AE II-TAE27.8 21.820.2 17.923.6 23.9
E-AE E-TAE27.323.126.5
26.119.123.3
II-E-AE65.61.965.6
II-E-TAE64.163.763.7
+ +![](images/2fd75823d393d13fa0676f4e49df10819d578f94fac364788433f9a3f8ab6fa9.jpg) +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. + +![](images/65ab66f3264425dbc2e561d14109b514e805afe8278d6c69e65be9b64fb7b395.jpg) +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. \ No newline at end of file diff --git a/md/dev/ayPPc0SyLv1/ayPPc0SyLv1.md b/md/dev/ayPPc0SyLv1/ayPPc0SyLv1.md new file mode 100644 index 0000000000000000000000000000000000000000..f6434be7fae9fba19f9b2134d395698b285d5928 --- /dev/null +++ b/md/dev/ayPPc0SyLv1/ayPPc0SyLv1.md @@ -0,0 +1,394 @@ +# DO WE REALLY NEED COMPLICATED MODEL ARCHITECTURES FOR TEMPORAL NETWORKS? + +Weilin Cong Penn State weilin@psu.edu + +Si Zhang +Meta +sizhang@meta.com + +Jian Kang University of Illinois at Urbana-Champaign jiank2@illinois.edu + +# Baichuan Yuan & Hao Wu & Xin Zhou + +Meta {bcyuan,haowu1,markzhou}@meta.com + +Hanghang Tong +University of Illinois at Urbana-Champaign +htong@illinois.edu + +Mehrdad MahdaviPenn Statemzm616@psu.edu + +# ABSTRACT + +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]. + +# 1 INTRODUCTION + +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. + +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: + +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 + +$$ +\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} +$$ + +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. + +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). + +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). + +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. + +# 2 PRELIMINARY AND EXISTING WORKS + +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 }$ . + +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. + +• JODIE Kumar et al. (2019) is a RNN-based method. Let us denote ${ \bf x } _ { i } ( t )$ as the embedding of +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 +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 }$ . + +• 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 )$ . + +• 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). + +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. + +# 3 GRAPHMIXER: A CONCEPTUALLY AND TECHNICALLY SIMPLE METHOD + +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. + +3.1 DETAILS ON GRAPHMIXER: NEURAL ARCHITECTURE AND INPUT DATA + +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. + +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). + +• 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 } )$ . + +![](images/4c578c45a87d195a9940b3b54d3e74d2a39b9c775c65e048125d412acb3382a2.jpg) +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. + +• 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 + +$$ +\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} +$$ + +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. + +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. + +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}$ . + +# 3.2 COMPARISON TO EXISTING METHODS + +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). + +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. + +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. + +
Reddit L,TWiki L,TMOOC TLastFM TGDELT L,N,TGDELT-ne TGDELT-e N,T
JODIE99.30±0.0198.81 ± 0.0199.16± 0.0167.51 ± 0.8798.27±0.0297.13± 0.0296.96±0.02
DySAT98.52 ± 0.0196.71 ± 0.0298.82±0.0276.40± 0.7798.52 ± 0.0282.47 ± 0.1397.25 ± 0.02
TGAT99.66 ± 0.0197.75 ± 0.0298.43 ±0.0154.77 ± 1.0198.25 ±0.0284.30 ±0.1096.96 ±0.02
TGN99.80 ± 0.0199.55 ± 0.0199.62 ± 0.0182.23 ± 0.5098.15±0.0297.13 ± 0.0296.04±0.02
CAWs-mean98.43±0.0297.72 ± 0.0362.99±0.8776.35±0.0895.11± 0.1269.20±0.1091.72 ± 0.19
CAWs-attn98.51 ± 0.0297.95 ± 0.0363.07 ±0.8276.31±0.1095.06 ± 0.1169.54 ± 0.1991.54± 0.22
TGSRec95.21±0.0891.64± 0.1283.62 ± 0.3476.91± 0.8797.03 ±0.6197.03 ± 0.6197.03 ± 0.61
APAN99.24± 0.0298.14± 0.0198.70 ±0.9869.39 ± 0.8195.96 ±0.1097.38 ± 0.2396.77 ± 0.18
GraphMixer-L99.84±0.0199.70±0.0199.81±0.0195.50±0.0398.99±0.0296.14±0.0298.99±0.02
GraphMixer-N99.24±0.0190.33± 0.0197.35±0.02b63.80±0.0394.44 ± 0.0296.00±0.02498.81±0.02b
GraphMixer99.93 ± 0.01§99.85± 0.0199.91 ± 0.01§96.31 ± 0.0298.89 ±0.0298.39 ± 0.02§98.22 ±0.02
+ +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. + +# 4 EXPERIMENTS + +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. + +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 + +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. + +# 4.1 MAIN EMPIRICAL RESULTS. + +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. + +![](images/265e13123a6283c0e7fa679a3ee3ca559539b1cc1761b53efa3a2da0b881c9c6.jpg) +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. + +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. + +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. + +![](images/c2fe0a164092269f08c3305fd6d2e1e698ba83912962800822baa236d94dec21.jpg) +Figure 4: Comparison on the training loss landscape. Results on other datasets and other baselines can be found in Appendix E. + +# 4.2 ON THE IMPORTANCE OF OUR FIXED TIME-ENCODING FUNCTION. + +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. + +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. +4.3 ON THE IMPORTANCE OF MLP-MIXER IN GRAPHMIXER’S LINK-ENCODER + +
RedditWikiMOOCLastFMGDELT-ne
JODIE99.30→99.7698.81→99.0099.16→99.1767.51→79.8997.13→98.2396.96→96.96
TGAT98.66→99.4896.71→ 98.5598.43→ 99.3354.77 → 76.2684.30→92.3196.96 →96.28
TGN99.80→99.8399.55 → 99.5499.62 →99.6282.23→87.5898.15→98.2596.04→97.34
+ +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. + +![](images/d3caa0ab422e440ea5ad445131907e77ecdcdc194f9976154b0d295bf58cd0c9.jpg) +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. + +![](images/32ed49fc307a58939c197b59286a82a9b65740ad1c4fe9c34ec419c90e0f4685.jpg) +Figure 6: Comparison on the training loss landscape fixed time-encoding function. Results on other datasets and baselines can be found in Appendix F. + +# 4.4 KEY FACTORS TO THE BETTER PERFORMANCE + +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. + +![](images/96f6fbfe6abb66f7d881a40b780edf8fd3bc58da45f6472c19078f83573cdd5e.jpg) +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. + +Table 3: Comparison on the average precision score. ♮ use 20 neighbors due to out of GPU memory. +Table 4: Comparison on the average precision score of GraphMixer with different input data. The highlighted rows are identical to our default setting. + +
RedditWikiMOOCLastFM
Direct vs undirect temporal graphDirected temporal graph99.6988.3797.8778.34
Undirected temporal graph99.9399.8599.9196.31
Relative timestamp (ti-to)99.7999.8099.8195.32
Time informationRelative time-encoding cos((ti - to)ω)99.9399.8599.9196.31
Absolute timestamp ti98.9098.2398.7392.25
Absolute time-encoding cos(tiω)99.5299.1399.7495.28
Neighbor selection2-hopMost recent neighbors99.3998.0599.1189.36
1-hopMost recent neighbors99.9399.8599.9196.31
2-hopUniform sample neighbors97.6692.5798.8765.72
1-hopUniform sample neighbors98.1994.7498.4060.02
+ +# 5 CONCLUSION + +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. + +# ACKNOWLEDGEMENTS + +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. + +# REFERENCES + +Uri Alon and Eran Yahav. On the bottleneck of graph neural networks and its practical implications. arXiv preprint arXiv:2006.05205, 2020. + +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. + +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. + +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. + +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. + +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. + +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. + +Palash Goyal, Sujit Rokka Chhetri, and Arquimedes Canedo. dyngraph2vec: Capturing network dynamics using dynamic graph representation learning. arXiv preprint arXiv:1809.02657, 2018. + +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. + +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. + +Thomas N Kipf and Max Welling. Variational graph auto-encoders. arXiv preprint arXiv:1611.07308, 2016. + +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. + +Hao Li, Zheng Xu, Gavin Taylor, Christoph Studer, and Tom Goldstein. Visualizing the loss landscape of neural nets. In Neural Information Processing Systems, 2018a. + +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. + +Yuhong Luo and Pan Li. Neighborhood-aware scalable temporal network representation learning. arXiv preprint arXiv:2209.01084, 2022. + +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. + +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. + +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. + +Amauri H Souza, Diego Mesquita, Samuel Kaski, and Vikas Garg. Provably expressive temporal graph networks. arXiv preprint arXiv:2209.15059, 2022. + +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. + +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. + +Rakshit Trivedi, Mehrdad Farajtabar, Prasenjeet Biswal, and Hongyuan Zha. Dyrep: Learning representations over dynamic graphs. In International conference on learning representations, 2019. + +Petar Velickovi ˇ c, Guillem Cucurull, Arantxa Casanova, Adriana Romero, Pietro Liò, and Yoshua ´ Bengio. Graph attention networks. In International Conference on Learning Representations, 2018. + +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. + +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. + +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. + +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. + +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. + +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. + +Da Xu, Chuanwei Ruan, Evren Korpeoglu, Sushant Kumar, and Kannan Achan. Inductive representation learning on temporal graphs. arXiv preprint arXiv:2002.07962, 2020. + +Bing Yu, Haoteng Yin, and Zhanxing Zhu. Spatio-temporal graph convolutional networks: A deep learning framework for traffic forecasting. In IJCAI, 2018. + +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. + +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. + +# A EXPERIMENT SETUP DETAILS + +# A.1 HARDWARE SPECIFICATION AND ENVIRONMENT + +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 + +https://github.com/CongWeilin/GraphMixer. + +# A.2 DETAILS ON DATASET + +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. + +Table 5: Dataset statistic. + +
V3(tmax-tmin)//ε|dim(xnode)dim(x)Node featuresLinkfeaturesTimestamps
Reddit10,984672,4470172NoYesYes
Wiki9,227157,474172NoYesYes
MOOC7,144411,74917 3.60NoNoYes
LastFM1,9801,293,1031060 00NoNoYes
GDELT8,8311,912,9090.1413186YesYesYes
GDELT-ne8,8311,912,9090.100NoNoYes
GDELT-n8,8311,912,9090.10186NoYesYes
+ +# A.3 MODEL CONFIGURATIONS, TRAINING AND EVALUATION PROCESS + +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. + +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. + +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. + +B MORE DISCUSSION ON EXISTING TEMPORAL GRAPH METHODS + +# B.1 RECENT METHODS THAT WE DO NOT COMPARE WITH + +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. + +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. + +# B.2 WHY EXISTING METHODS ARE CONCEPTUALLY AND TECHNICALLY COMPLICATED? + +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. + +• 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. + +# B.3 THEORETICAL WORKS ON TEMPORAL GRAPH LEARNING + +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. + +# C MORE EXPERIMENT RESULTS + +# C.1 COMPARISON ON CONVERGENCE SPEED AND GENERALIZATION + +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. + +![](images/c47a2b88702b51c8b98a80636b4180ed8f47a5d509784e8fafa852a732e781c5.jpg) +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. + +# C.2 TRANSDUCTIVE LEARNING WITH RECALL $@ \mathrm { K }$ AND MRR AS EVALUATION METRIC + +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. + +Table 6: Comparison on the Recall $@ \mathrm { K }$ and MRR. + +
RedditWikiMOOCLastFMGDELT
R@5MRRR@5MRRR@5MRRR@5MRRR@5MRR
JODIE0.91810.62710.90980.77520.98180.75510.20340.12060.85540.6048
DySAT0.91890.77740.88890.75610.99890.79060.41590.33220.83020.4236
TGAT0.97740.87090.85080.61320.97360.74250.10400.07690.35130.2366
TGN0.97870.90930.88780.80160.99040.99040.16490.11530.92970.7295
GraphMixer1.00.99650.99720.98760.99990.99100.99980.96490.99300.8934
+ +13https://github.com/snap-stanford/ogb/blob/master/ogb/linkproppred/ evaluate.py + +We have the following observations on Table 1: + +• 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. + +• 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. + +# C.3 COMPARISON ON WALL-CLOCK TIME + +In the following, we compare the wall-clock time it takes for GraphMixer and baselines to finish a single epoch of training. + +Table 7: Comparison on the wall-clock computation time for single-epoch of training. + +
RedditWikiMOOCLastFMGDELT
JODIE5 sec2 sec4 sec11 sec16 sec
DySAT33 sec6 sec16 sec41 sec83 sec
TGAT15 sec4 sec8 sec28 sec41 sec
TGN8 sec2 sec5sec15 sec32 sec
CAWs-mean1,893 sec277 sec641 sec1,797 sec4,544 sec
CAWs-attn1,930 sec282 sec653 sec1,832 sec4,634 sec
TGSRec538 sec157 sec656 sec1,810 sec3,707 sec
APAN13 sec4 sec9 sec28 sec25 sec
GraphMixer12 sec3 sec7 sec21 sec32 sec
+ +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. + +Table 8: Comparison on the number of model parameters. + +
GraphMixerGraphMixer-TGraphMixer-SJodieDySATTGATTGN
#Parameters (×105)2.251.422.071.219.383.803.54
+ +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. + +# C.4 TRANSDUCTIVE LEARNING WITH AUC AS EVALUATION METRIC + +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. + +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). + +
Reddit L,TWiki L,TMOOC TLastFM TGDELT L,N,TGDELT-ne TGDELT-e N,T
JODIE99.30±0.0198.81 ± 0.0199.16± 0.0167.51 ± 1.9998.55±0.0197.13±0.0296.96±0.02
DySAT98.52 ±0.0196.71 ±0.0298.82 ±0.0176.40 ± 0.8198.52 ±0.0182.47 ± 0.0497.25 ±0.02
TGAT99.66 ± 0.0197.75 ± 0.0298.43±0.0154.77 ± 1.0298.25 ±0.0184.30 ± 0.0396.96 ±0.02
TGN99.80 ±0.0199.55 ± 0.0199.62 ± 0.0182.23 ±0.5098.15 ±0.0197.13 ± 0.0296.04± 0.02
CAWs-mean98.18± 0.0197.25±0.0363.88±0.9272.92± 0.3395.19±0.0971.82 ± 0.0891.40± 0.19
CAWs-attn98.30 ±0.0197.89 ±0.0263.95 ±0.8172.93 ± 0.5495.13 ± 0.1171.82 ±0.0891.64± 0.24
TGSRec94.74±0.2091.32 ± 0.1980.70 ± 2.3176.66 ± 1.5496.72 ± 0.4296.72 ±0.4296.72 ± 0.42
APAN99.24±0.0197.25 ± 0.0198.58 ±0.0162.73±0.6496.46 ± 0.1198.39 ± 0.1797.85 ± 0.19
GraphMixer-L99.84± 0.0199.70±0.0199.87 ± 0.0197.04± 0.0298.99± 0.0296.54±0.0298.99± 0.02
GraphMixer-N99.53 ±0.0191.49 ± 0.0198.66±0.0271.51 ± 0.0394.44±0.02 96.00±0.0298.81±0.02
GraphMixer99.94±0.0199.82 ± 0.0199.93 ± 0.0197.38± 0.02598.89 ±0.0298.50±0.0298.48±0.02
+ +# C.5 BASELINES WITH UNDIRECTED TEMPORAL GRAPH + +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. + +Table 10: Comparison on baselines with undirected temporal graph (Average precision | AUC score). + +
RedditWikiMOOCLastFM
JODIE99.2499.4098.9199.0799.1899.5373.2580.24
DySAT98.5398.4296.6196.8898.8099.2676.2373.90
TGAT99.7099.7397.3597.6898.4198.8554.5857.03
TGN99.8499.8799.5999.6199.4499.6691.9693.20
+ +# D DISCUSSION ABOUT MODEL PERFORMANCE ON LASTFM + +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. + +• 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. + +• 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. + +• 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. + +# E MISSING FIGURES ON LOSS LANDSCAPE + +# E.1 LOSS LANDSCAPE ON WIKI + +![](images/82af72c3b656682474d919a907c8672d2cc0fe736fc7f63f9312efa40d477010.jpg) +Figure 9: Comparison on the training loss landscape (Contour) on Wiki Dataset. + +![](images/092836d5ea790c0aca78a2da9729d5c778891c6c1cb4f60972216b8a3818b56e.jpg) +Figure 10: Comparison on the training loss landscape (Surface) on Wiki Dataset. + +![](images/cb7425d3f38b90aee4390b5b9bfa2b6bf584caffa1bf61914e27802054a11cca.jpg) +Figure 11: Comparison on the training loss landscape (Contour) on Reddit Dataset. + +![](images/a483b5b09ea0642a0a56c3910d915fb1f224a67d0fb146d99a171b58277ec328.jpg) +Figure 12: Comparison on the training loss landscape (Surface) on Reddit Dataset. + +![](images/fb083840d9c77c093e6c35e6f7c6e5a3bfcc44b857ab208b8cb862db823ffe8e.jpg) +Figure 13: Comparison on the training loss landscape (Contour) on MOOC Dataset. + +![](images/9f559896c0b8bd4ca01d9dac41852a83bcb868f4d95c46f603b83acaee7768e2.jpg) +Figure 14: Comparison on the training loss landscape (Surface) on MOOC Dataset. + +![](images/b41d84db5054053ec40f16645addfc44a051e6ba5e241fdfbaa8f4dffc9fd39b.jpg) +Figure 15: Comparison on the training loss landscape (Contour) on LastFM Dataset. + +![](images/ac3e867d6139ada26dda8835f8e7445f77ef4df4d335a8b2a652ede4e755c919.jpg) +Figure 16: Comparison on the training loss landscape (Surface) on LastFM Dataset. + +![](images/ffb36af1cd9614722d83ddb62ffa6d219de8182bce1a6ee707f53ffa5ca05552.jpg) +Figure 17: Comparison on the training loss landscape (Contour) on GDELT-ne Dataset. + +![](images/39636698b07562737bfd137fdd8ba2d3840b02fd67e836fe14d2c5791424aec6.jpg) +Figure 18: Comparison on the training loss landscape (Surface) on GDELT-ne Dataset. + +![](images/7dbdfab2e2ba3ff4b43557a6efb3a086c58de8a91f949d5d27b4e6b86567dca2.jpg) +Figure 19: Comparison on the training loss landscape (Contour) on GDELT-e Dataset. + +![](images/34bbdc04bc3df1ff54afd7ed4fdaefa398c5d551c688c99180b3b28b732ea33a.jpg) +Figure 20: Comparison on the training loss landscape (Surface) on GDELT-e Dataset. + +# F.1 TGAT WITH FIXED TIME-ENCODING FUNCTION + +![](images/baca440a859fa91077f6afffa42ab6e5078350230222f23edfbd44777d5d942b.jpg) +Figure 21: Training loss landscape (Contour) of TGAT with fixed time-encoding function. + +![](images/9cfd9be0a6b81422fd6d7f857665f50990c22e6381709b9d10ec0ea21a4047d3.jpg) +Figure 22: Training loss landscape (Surface) of TGAT with fixed time-encoding function. + +![](images/c9386fc017fce5bf2cc5cb27c5e1d9c6b9f2dd9cef928e24339e2d4803dee327.jpg) +Figure 23: Training loss landscape (Contour) of TGN with fixed time-encoding function. + +![](images/910930a530450821349ab7e70efed8d90b1ff336f0eb2a8f5561f24701db4ee2.jpg) +Figure 24: Training loss landscape (Surface) of TGN with fixed time-encoding function. + +![](images/fadd5baba2f91be6f8d72431609501b017e6e4cd04d9123ec89105730f2ff542.jpg) +Figure 25: Training loss landscape (Contour) of JODIE with fixed time-encoding function. + +![](images/d05ab0ba499055eb7966091a30005c4c70bb10fecd7d0dd9f7816c0bc4c802e0.jpg) +Figure 26: Training loss landscape (Surface) of JODIE with fixed time-encoding function. \ No newline at end of file diff --git a/md/dev/b90lKL1IqcF/b90lKL1IqcF.md b/md/dev/b90lKL1IqcF/b90lKL1IqcF.md new file mode 100644 index 0000000000000000000000000000000000000000..7dfa8dd1bba17e38ebc21296c118c81b047be6b5 --- /dev/null +++ b/md/dev/b90lKL1IqcF/b90lKL1IqcF.md @@ -0,0 +1,272 @@ +# VoxGRAF: Fast 3D-Aware Image Synthesis with Sparse Voxel Grids + +Katja Schwarz1 Axel Sauer1 Michael Niemeyer1 Yiyi Liao2 Andreas Geiger1 + +1University of Tübingen and Max Planck Institute for Intelligent Systems, Tübingen 2 Zhejiang University, China + +# Abstract + +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. + +# 1 Introduction + +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. + +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]. + +![](images/710fcd8dff74e429c39bb43531db29f6bc9294062b7bf458b7c8226f504df547.jpg) +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. + +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. + +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. + +# 2 Related Work + +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. + +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. + +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. + +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. + +# 3 Method + +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. + +![](images/aa8e0f22496fdfbc770d95d7c119195cc05e95bb573070ed509d20c3330736f4.jpg) +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 }$ . + +# 3.1 3D-aware GANs with Coordinate-Based Scene Representations + +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, + +$$ +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 ) +$$ + +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. + +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 + +$$ +\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} +$$ + +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. + +# 3.2 VoxGRAF: Generating Radiance Fields on Sparse Voxel Grids + +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. + +![](images/58f1a3fed7b0f3301a8aa4e86f840f0873b922aef1a4ab6c5c8fd2699f459f2c.jpg) +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. + +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 + +$$ +\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} +$$ + +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. + +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 + +$$ +\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 } ) \} +$$ + +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. + +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. + +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: + +$$ +\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 } +$$ + +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). + +The final image is obtained using alpha composition + +$$ +\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 } +$$ + +The full generator is defined as + +$$ +\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} +$$ + +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: + +$$ +\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 } +$$ + +$$ +\mathcal { L } _ { D V } = \lambda _ { D V } \operatorname* { m a x } ( V a r ( \hat { z } ) , \tau ) +$$ + +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 + +$$ +\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 } +$$ + +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]. + +# 3.3 Training + +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] + +$$ +\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} +$$ + +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: + +$$ +\operatorname* { m i n } _ { \theta } \operatorname* { m a x } _ { \phi } \quad \quad V ( \theta , \phi ) + \mathcal { L } _ { r e g } ( \theta ) +$$ + +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. + +# 4 Results + +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. + +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. + +# 4.1 Ablation Study + +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 + +
Sparsity [%]Memory [GB]tGfg+bg [ms]tπ [ms]
w/o LDv741.42297
w LDV.950.91984
w LDv+951.1584
+ +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. + +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. + +# 4.2 Baseline Comparison + +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]. + +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. + +![](images/e14bac549c1ac8334fc372f0553ef707baa1f9e7a1a0792026c61c2561c40e98.jpg) +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. + +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. + +
FFHQ[19] AFHQ[5]Carla [38] R1=256² R=256² R=128²
GIRAFFE [31] 31.5 16.1 1 VolumeGAN[44]
9.1 7.9 1 8.0 1 1
StyleNeRF[10] EG3D [3] 4.8 3.9 1
GRAF[38] 71 121 41
π-GAN [4] 85 47 29.2
GOF[43] 69.2 54.1 29.3
GRAM[6] 17.9 18.5 26.3 VoxGRAF 9.6 9.6 6.7
+ +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). + +
R =128²R1=256²
GIRAFFE [30]5
StyleNeRF[10]49
EG3D*[3] 127
GRAF [38] 219878
π-GAN [4] 154608
GOF[43] 199742
GRAM[6] 136418
VoxGRAF 58+358+6
+ +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. + +![](images/97eb1db1cd5dbf05dc3742c83b389264eb2d886909ac39ecd91325cf2e6ccbfa.jpg) +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]. + +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. + +# 5 Limitations and Discussion + +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. + +# Acknowledgments and Disclosure of Funding + +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. + +# References + +[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 +[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 +[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 +[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 +[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 +[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 +[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 +[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 +[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 +[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 +[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 +[12] E. Härkönen, A. Hertzmann, J. Lehtinen, and S. Paris. Ganspace: Discovering interpretable GAN controls. arXiv.org, 2020. 3 +[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 +[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 +[15] K. Jo, G. Shim, S. Jung, S. Yang, and J. Choo. Cg-nerf: Conditional generative neural radiance fields. arXiv.org, 2021. 3 +[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 +[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 +[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 +[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 +[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 +[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 +[22] T. B. Lee. Cat hipsterizer, 2018. 7 +[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 +[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 +[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 +[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 +[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 +[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 +[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 +[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 +[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 +[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 +[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 +[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 +[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 +[36] A. Sauer, K. Schwarz, and A. Geiger. Stylegan-xl: Scaling stylegan to large diverse datasets. ACM Trans. on Graphics, 2022. 1, 3 +[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 +[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 +[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 +[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 +[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 +[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 +[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 +[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 +[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 +[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 +[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 +[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 +[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 +[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 + +# Checklist + +1. For all authors... + +(a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes] +(b) Did you describe the limitations of your work? [Yes] +(c) Did you discuss any potential negative societal impacts of your work? [Yes] See supplemental material. +(d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes] + +2. If you are including theoretical results... + +(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] + +3. If you ran experiments... + +(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. +(b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes] +(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. + +(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. + +4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets... + +(a) If your work uses existing assets, did you cite the creators? [Yes] +(b) Did you mention the license of the assets? [N/A] +(c) Did you include any new assets either in the supplemental material or as a URL? [No] +(d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [N/A] +(e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [N/A] + +5. If you used crowdsourcing or conducted research with human subjects... + +(a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A] +(b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A] +(c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A] \ No newline at end of file diff --git a/md/dev/bydKs84JEyw/bydKs84JEyw.md b/md/dev/bydKs84JEyw/bydKs84JEyw.md new file mode 100644 index 0000000000000000000000000000000000000000..c653f7599ef2dc719c5d50987f9338e88f4b6c72 --- /dev/null +++ b/md/dev/bydKs84JEyw/bydKs84JEyw.md @@ -0,0 +1,320 @@ +# VLMO: Unified Vision-Language Pre-Training with Mixture-of-Modality-Experts + +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 + +1Harbin Institute of Technology, 2Microsoft Corporation https://aka.ms/msragi + +# Abstract + +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. + +# 1 Introduction + +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.). + +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. + +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. + +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. + +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. + +Our main contributions are summarized as follows: + +• 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. +• 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. +• We show that stagewise pre-training using large amounts of image-only and text-only data greatly improves our vision-language pretrained model. + +# 2 Related Work + +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. + +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. + +![](images/47c5d9a98cc607bb7592a22965ea6bbad2619992e2ff0c0e5bc929c4437d9567.jpg) +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). + +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. + +# 3 Methods + +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. + +![](images/1456ac11f23ba17bc7f93fc5224332e45d12da94a9064819d160072e148085f5.jpg) +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. + +# 3.1 Input Representations + +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. + +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 }$ . + +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. + +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 } ]$ + +# 3.2 Multiway Transformer + +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. + +$$ +\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} +$$ + +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. + +![](images/930b131d6d498b415a14f4635eee8dfda08118fb2fecc35834ebdba1b06b7fb0.jpg) +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. + +# 3.3 Pre-Training Tasks + +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. + +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. + +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: + +$$ +\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} +$$ + +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. + +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. + +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. + +# 3.4 Stagewise Pre-Training + +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. + +# 3.5 Fine-Tuning VLMO on Downstream Tasks + +As present in Figure 3, our model can be fine-tuned to adapt to various vision-language retrieval and classification tasks. + +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. + +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. + +# 4 Experiments + +We pretrain our model using large-scale image-text pairs and evaluate the model on visual-linguistic classification and retrieval tasks. + +# 4.1 Pre-Training Setup + +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. + +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. + +
Model#Pretrain ImagesVQANLVR2
test-devtest-stddevtest-P
Base-SizeModelsPretrained on COCO,VG,,SBUand CCdatasets
UNITER-Base [4]4M72.7072.9177.1877.85
VILLA-Base [15]4M73.5973.6778.3979.30
UNIMO-Base [26]4M73.7974.02
ViLT-Base [21]4M71.26175.7076.13
ALBEF-Base [24]4M74.5474.7080.2480.50
VLMo-Base4M76.6476.8982.7783.34
Large-Size Models Pretrained on COCO, VG, SBU and CC datasets
UNITER-Large [4]4M73.8274.0279.1279.98
VILLA-Large [15]4M74.6974.8779.7681.47
UNIMO-Large [26]4M75.0675.27==
VLMo-Large4M79.9479.9885.6486.86
ModelsPretrainedonMoreData
VinVL-Large [51]5.7M76.5276.6082.6783.98
SimVLM-Large [48]1.8B79.3279.5684.1384.84
SimVLM-Huge [48]1.8B80.0380.3484.5385.15
Florence-Huge [50]900M80.1680.36
Flamingo [1]2.3B82.0082.10=1
VLMo-Large++1.0B82.8882.7888.6289.54
+ +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). + +# 4.2 Training on Larger-scale Datasets + +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. + +# 4.3 Evaluation on Vision-Language Classification Tasks + +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. + +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. + +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. + +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]. + +
#PretrainFlickr30K (1K test set)
ModelImagesMSCOCO (5K test set) TRIRTRIR
R@1 R@5 R@10 R@1 R@5 R@10|R@1 R@5 R@10 R@1 R@5 R@10
Base-Size Models Pretrained on COCO,VG, SBU and CC datasets
UNITER-Base4M64.4 87.493.150.378.587.285.997.198.872.592.496.1
VILLA-Base4M1-1---86.697.999.274.792.995.8
ViLT-Base4M61.586.392.742.772.983.183.596.798.664.488.793.8
ALBEF-Baset4M73.191.496.056.881.589.294.399.499.882.896.798.4
VLMo-Base†4M74.893.196.957.282.689.892.399.499.979.395.797.8
Large-Size Models Pretrained on COCO, VG, SBU and CC datasets
UNITER-Large4M65.788.693.852.979.988.087.398.099.275.694.196.8
VILLA-Large4M=-1--87.997.598.876.394.296.8
VLMo-Larget4M78.2 94.497.460.684.491.095.399.9100.084.597.398.6
Models Pretrained on More Data
VinVL-Large5.7M75.492.996.258.883.590.3-===-
ALIGN-Larget1.8B77.093.596.959.983.389.895.399.8100.0 84.997.498.6
Florence-Huget900M81.895.2-63.285.7-97.299.9187.998.1-
VLMO-Large++†1.0B83.196.098.265.286.592.296.8100.0100.088.198.499.3
+ +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. + +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. + +
Stagewise Pre-TrainingNLVR2Flickr30k
devtest-PTRIR
Image-Only Pre-Training80.3381.0695.6087.69
Image-Only + Text-Only Pre-Training82.0982.4995.6788.52
+ +# 4.4 Evaluation on Vision-Language Retrieval Tasks + +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. + +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. + +# 4.5 Evaluation on Vision Tasks + +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. + +Table 4: Results on image classification and semantic segmentation. + +
ModelsImageNet (acc @1)ADE20K (mIoU)
VIT-Base83.6-
BEIT-Base85.252.8
VLMo-Base85.553.4
+ +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. + +
Pre-Training TasksTransformerNLVR2Flickr30k
ITCITMMLMStd TRMMultiwayMultiway-VLExpdevtest-PTRIR
58.5158.8392.2384.24
73.9173.7594.0785.82
xxx/xx///xxνxxx76.4676.1994.3785.67
78.8179.2793.3785.73
xx///x/x79.5880.1194.5086.69
//////x/xν//80.1380.3195.1787.25
+ +# 4.6 Ablation Studies + +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. + +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. + +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. + +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). + +
ModelsNLVR2
devtest-P
Local hard negative mining [24]77.7077.95
Global hard negative mining (ours)79.5479.48
+ +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. + +# 5 Conclusion + +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. + +In the future, we would like to work on improving VLMO from the following perspectives: + +• We will scale up the model size used in VLMO pre-training. +• We are also interested in fine-tuning VLMO for vision-language generation tasks, such as image captioning, following the method proposed in UniLM [12]. +• 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. +• We can extend the proposed model to integrate more modalities (e.g., speech, video, and structured knowledge), supporting general-purpose multimodal pre-training. + +# References + +[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. + +[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. + +[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. + +[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. + +[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. + +[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. + +[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. + +[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. + +[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. + +[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. + +[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. + +[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. + +[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. + +[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. + +[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. + +[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. + +[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. + +[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. + +[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. + +[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. + +[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. + +[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. + +[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. + +[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. + +[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. + +[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. + +[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. + +[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. + +[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. + +[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. + +[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. + +[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. + +[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. + +[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. + +[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. + +[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. + +[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. + +[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. + +[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. + +[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/. + +[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. + +[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. + +[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. + +[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. + +[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. + +[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. + +[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. + +[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. + +[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. + +[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. + +[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. + +[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. + +[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. + +# Checklist + +1. For all authors... + +(a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes] +(b) Did you describe the limitations of your work? [Yes] Please refer to the conclusion. +(c) Did you discuss any potential negative societal impacts of your work? [N/A] +(d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes] + +2. If you are including theoretical results... + +(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] + +3. If you ran experiments... + +(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] +(b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes] +(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. + +(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] + +4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets... + +(a) If your work uses existing assets, did you cite the creators? [Yes] +(b) Did you mention the license of the assets? [N/A] +(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] +(e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [N/A] + +5. If you used crowdsourcing or conducted research with human subjects... + +(a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A] +(b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A] +(c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A] \ No newline at end of file diff --git a/md/dev/cVak2hs06z/cVak2hs06z.md b/md/dev/cVak2hs06z/cVak2hs06z.md new file mode 100644 index 0000000000000000000000000000000000000000..a1f6d23f153e114c963e8d03f1a89c44f98aa0d2 --- /dev/null +++ b/md/dev/cVak2hs06z/cVak2hs06z.md @@ -0,0 +1,799 @@ +# CORRECT-N-CONTRAST: A CONTRASTIVE APPROACH FOR IMPROVING ROBUSTNESS TO SPURIOUS CORRELATIONS + +Anonymous authors Paper under double-blind review + +# ABSTRACT + +Spurious correlations pose a fundamental challenge for building robust machine learning models. For example, models trained with empirical risk minimization (ERM) may depend on correlations between class labels and spurious features to classify data, even if these relations only hold for certain data groups. This can result in poor performance on other groups that do not exhibit such relations. When group information is available during training, Sagawa et al. (2019) have shown how to improve worst-group performance by optimizing the worst-group loss (GDRO). However, when group information is unavailable, improving worst-group performance is more challenging. For this latter setting, we propose Correct-NContrast (CNC), a contrastive learning method to train models more robust to spurious correlations. Our motivating observation is that worst-group performance is related to a representation alignment loss, which measures the distance in feature space between different groups within each class. We prove that the gap between worst-group and average loss for each class is upper bounded by the alignment loss for that class. Thus, CNC aims to improve representation alignment via contrastive learning. First, CNC uses an ERM model to infer the group information. Second, with a careful sampling scheme, CNC trains a contrastive model to encourage similar representations for groups in the same class. We show that CNC significantly improves worst-group accuracy over existing state-of-the-art methods on popular benchmarks, e.g., achieving $7 . 7 \%$ absolute lift in worst-group accuracy on the CelebA data set, and performs almost as well as GDRO trained with group labels. CNC also learns better-aligned representations between different groups in each class, reducing the alignment loss substantially compared to prior methods. + +# 1 INTRODUCTION + +For many tasks, deep neural networks are negatively affected by spurious correlations—dependencies between observed features and class labels that only hold for certain groups of the data. For example, consider classifying images of cows or camels, where $90 \%$ of cow images depict grassy backgrounds. A model may learn to predict the “cow” class based on the background, and incorrectly classify cow images with non-grass backgrounds as camels (Ribeiro et al., 2016; Beery et al., 2018; Kaufman et al., 2012). This illustrates a widespread issue where neural networks can achieve low test error on certain groups, yet high error on others (Blodgett et al., 2016; Buolamwini & Gebru, 2018; Hashimoto et al., 2018; Sagawa et al., 2019). Prior works have shown that this problem is increasingly aggravated as the correlations between class labels and spurious features become stronger (Sagawa et al., 2020) and easier to learn (Arpit et al., 2017; Hermann & Lampinen, 2020). Since spurious correlations arise in many settings, we wish to design robust methods that perform well on all groups. + +How can we obtain neural networks robust to spurious correlations? If group-defining information (i.e. spurious attributes) is known, a common solution is to minimize the worst-group loss, e.g., with group DRO (GDRO) (Sagawa et al., 2019). However, such information may be expensive to collect, and we may not know the spurious attributes a priori in a given data set (Oakden-Rayner et al., 2020). When group information is unavailable, prior works typically take a two-stage approach. They first train an ERM model, and then use this model to infer groups and train a more robust model. For example, Sohoni et al. (2020) find that ERM models still learn group-specific features when trained to predict class labels. After first training an ERM model, they infer groups by clustering the ERM model’s representations, and train a new model with GDRO using these inferred groups. Creager Ours et al. (2021) identify groups under which an initial trained ERM model would maximally violate the ✅ ✅ ✅ ✅ Sample invariant risk minimization (IRM) objective (Arjovsky et al., 2019). With these groups they train ✓ “Landbird” contrastive batchesa new model with GDRO or IRM. Nam et al. (2020); Liu et al. (2021) observe that ERM models often misclassify data points in minority groups, and thus train another model with re-weighted or Landbird, Land BGupsampled points misclassified by an initial ERM model. While these methods promisingly leverage ERM learned biases to significantly improve worst-group error without training group labels, there is still a gap between their robust performance and methods’ such as GDRO that use group labels. + +![](images/916c5dd554702f66151e1376a3caf24d5947fa6f68f7fb76c9947250393ac170.jpg) +Figure 1: (a) ERM misclassifies samples by spurious background features, visualized with GradCAM (Selvaraju “Waterbird” “Waterbird” et al., 2017). (b) CNC uses contrastive learning to learn similar representations for same-class samples with different ERM predictions. (c) Resulting models ignore spurious attributes and classify samples correctly. + +ERM In this work, we ask how else we can improve model robustness using a trained ERM model, and aim to close this gap by focusing on improving the learned representations of the robust model in “Waterbird” the second stage. We support this direction with two key motivations. First, we find that higher worst-group performance consistently correlates with hidden-layer representations exhibiting higher GradCAM dependence on class labels than spurious attributes. We quantify this correlation using geometric representation alignment (Wang & Isola, 2020), which measures the closeness of samples with the same class but different spurious attributes in the model feature space, and mutual information. This relation consistently holds across various data sets, and explains when prior upweighting methods improve worst-group error over ERM (Fig. 4). Second, we theoretically show that a model’s representation alignment for a given class can be used to upper bound the gap between its worst-group and average loss for that class. Thus, if we can improve representation alignment for a class, we can reduce the gap between worst-group and average loss for that class. + +We thus propose Correct-N-Contrast (CNC), a two-stage procedure using contrastive learning to encourage better representation alignment within each class. In the first stage, we train a regularized ERM model similar to prior work (Liu et al., 2021; Creager et al., 2021), under the premise that ERM predictions help infer group information (i.e., spurious attributes). In the second stage, we wish to improve representation alignment by “pulling together” same-class datapoints and “pushing apart” different-class datapoints, regardless of their individual groups or spurious features. To do so via supervised contrastive learning, we use the heuristic that samples with the same ERM predictions exhibit similar spurious features (and vice versa). With a randomly sampled anchor, we select samples with the same class but different ERM predictions as “positives” we want to pull together, and samples from different classes but the same ERM prediction as hard “negatives” we want to push apart. Training a second model with this sampling scheme and supervised contrastive learning encourages this model to ignore spurious correlations that the initial ERM model learned, and improves representation alignment between same-class data points. Thus, CNC corrects for the ERM model’s mistakes with contrastive learning in the second model. + +We evaluate $\mathrm { C N C }$ on four popular and diverse spurious correlation benchmarks. Among methods that similarly do not assume training group labels, CNC substantially improves worst-group accuracy, obtaining up to $7 . 7 \%$ absolute lift (from $8 1 . 1 \%$ to $8 8 . 8 \%$ on CelebA) over the prior state-of-the-art JTT (Liu et al., 2021), and averaging $3 . 4 \%$ lift across the four tasks. We also find that $\mathrm { C N C }$ nearly closes the gap in worst-group accuracy with robust training methods that assume training group labels, only falling short of GDRO’s worst-group accuracy by $0 . 8 \%$ absolute. Finally, we validate that CNC indeed reduces the alignment loss compared to prior methods. This corresponds to an up to $7 1 . 1 \%$ smaller gap between worst-group versus average accuracy for data points in the same class. + +Contributions. We summarize our contributions as follows: + +1. We empirically show that a model’s worst-group performance correlates with the model’s alignment loss between different groups within a class, and analyze this connection theoretically. + +2. We propose CNC, a two-stage contrastive approach to improve representation alignment and thereby learn representations robust to spurious correlations. + +3. We validate that CNC significantly improves worst-group accuracy over existing methods on various benchmarks, and learns better-aligned representations less reliant on spurious features. + +# 2 PRELIMINARIES + +Problem setup. We present our setting and the loss objectives following Sagawa et al. (2019). Let $X = \{ x _ { 1 } , \ldots , x _ { n } \}$ and $Y = \{ y _ { 1 } , \dots , y _ { n } \}$ be a training data set of size $n$ . Each data point has an observed feature vector $x _ { i } \in { \mathcal { X } }$ , label $y _ { i } \in \mathcal { V }$ , and unobserved spurious attribute $a _ { i } \in { \mathcal { A } }$ . The set of groups $\mathcal { G }$ is defined as the set of all combinations of class label and spurious attribute pairs, i.e. $\mathcal { G } = \mathcal { y } \times \mathcal { A }$ . Let $C = | \mathcal { D } |$ be the number of classes and $K = | \mathcal G |$ be the number of groups. Following the classical supervised learning setting, we assume that each example $( x _ { i } , y _ { i } , a _ { i } )$ is drawn from an unknown joint distribution $P$ . We assume that at least one sample from each group is observed in the training data. Let $P _ { g }$ be the distribution conditioning on $( y , a ) = g$ , for any $g \in { \mathcal { G } }$ . + +Given a model $f _ { \theta } : \mathcal { X } \mapsto \mathbb { R } ^ { C }$ and a convex loss $\ell : \mathcal { X } \times \mathcal { Y } \mapsto \mathbb { R }$ , let the worst-group loss be: + +$$ +\mathcal { L } _ { \mathrm { w g } } ( f _ { \theta } ) : = \operatorname* { m a x } _ { g \in \mathcal { G } } \ \mathbb { E } _ { ( x , y , a ) \sim P _ { g } } [ \ell ( f _ { \theta } ( x ) , y ) ] . +$$ + +ERM minimizes the training loss as a surrogate for the expected population loss $\mathcal { L } _ { \mathrm { a v g } }$ : + +$$ +\mathcal { L } _ { \mathrm { a v g } } ( f _ { \theta } ) : = \mathbb { E } _ { ( x , y , a ) \sim P } [ \ell ( f _ { \theta } ( x ) , y ) ] +$$ + +While ERM is the standard way to train neural nets, spurious correlations often cause ERM to obtain high error on minority groups even when average error is low. Group DRO, which minimizes the empirical version of (1), is recognized as a strong baseline for improving worst-group error when the group labels $\{ a _ { 1 } , \ldots , a _ { n } \}$ are available during training (Sagawa et al., 2019). In contrast, we focus on the more challenging setting in which the group labels are not available during training. + +Contrastive learning. We briefly describe contrastive learning (Chen et al., 2020), a central component of our approach. Let $f _ { \theta }$ be a neural network model with parameters $\theta$ . Let the encoder $\dot { \mathcal { f } } _ { \mathrm { e n c } } : \mathcal { X } \mapsto \mathbb { R } ^ { d }$ be the feature representation layers of $f _ { \theta }$ . Let $f _ { \mathrm { c l s } } : \dot { \mathbb { R } ^ { d } } \mapsto \mathbb { R } ^ { C }$ be the classification layer of supervis $f _ { \theta }$ , which maps en contrastive loss r representations to one-hot label vectors. We learn proposed in Khosla et al. (2020). For each ancho $f _ { \mathrm { e n c } }$ with the we sample $M$ positives $\{ x _ { i } ^ { + } \} _ { i = 1 } ^ { M }$ and $\mathcal { L } _ { \mathrm { c o n } } ^ { \mathrm { s u p } }$ $N$ negatives $\{ x _ { i } ^ { - } \} _ { i = 1 } ^ { N }$ . Let $y , \{ y _ { i } ^ { + } \} _ { i = 1 } ^ { M } , \{ y _ { i } ^ { - } \} _ { i = 1 } ^ { N }$ be the labels and $x$ $z , \{ z _ { i } ^ { + } \} _ { i = 1 } ^ { M } , \{ z _ { i } ^ { - } \} _ { i = 1 } ^ { N }$ be the normalized outputs of $f _ { \mathrm { e n c } } ( x )$ for the anchor, positives, and negatives respectively. With input $x$ mapped to $z$ , the training objective for the encoder is to minimize: + +$$ +\mathcal { L } _ { \mathrm { c o n } } ^ { \mathrm { s u p } } ( x ; f _ { \mathrm { e n c } } ) = \underset { x , \{ x _ { i } ^ { + } \} _ { i = 1 } ^ { M = 1 } , \{ x _ { i } ^ { - } \} _ { j = 1 } ^ { N } } { \mathbb { E } } \left[ - \log \frac { \exp ( z ^ { \top } z _ { i } ^ { + } / \tau ) } { \sum _ { m = 1 } ^ { M } \exp ( z ^ { \top } z _ { m } ^ { + } / \tau ) + \sum _ { n = 1 } ^ { N } \exp ( z ^ { \top } z _ { n } ^ { - } / \tau ) } \right] +$$ + +where $\tau > 0$ is a scalar temperature hyperparameter. Minimizing Eq. 3 leads to $z$ being closer to $z ^ { + }$ than $z ^ { - }$ in feature space. See Sec. 6 for further references related to contrastive learning. + +# 3 MOTIVATIONS FOR REPRESENTATION ALIGNMENT + +To motivate our method, we present our core observation that a model’s worst-group accuracy correlates with how well its learned representations depends on the class labels, but not the spurious attributes. First, we empirically observe that ERM learns spurious correlations by inspecting their hidden layer representations on several spuriously correlated data sets. We find that ERM’s worstgroup performance is inversely related to a cross-group alignment loss (cf. Eq. (4) below) and mutual information metrics. Second, we theoretically prove that this alignment loss serves as an upper bound on the gap between the average-group loss and the worst-group loss (cf. Theorem 3.1). + +We first show that when neural networks are trained with standard ERM on spuriously correlated data, their hidden layer representations exhibit high dependence on the spurious attribute. We quantify this behavior using representation alignment (cf. Eq. (4) below) and mutual information metrics. We observe that these metrics explain trends in ERM’s worst-group accuracy on various spuriously correlated data sets. This relationship is also consistent and applies to upsampling methods (JTT) that mitigate the impact of spurious features (Liu et al., 2021). + +We model spurious correlations with CMNIST∗, a colored MNIST data set inspired by Arjovsky et al. (2019). There are 5 digit classes and 5 colors. We color a fraction $p _ { \mathrm { c o r r } }$ of the training samples with a color $a$ associated with each class $y$ , and color the test samples uniform-randomly. To analyze learned representations, we train a LeNet-5 CNN (LeCun et al., 1989) with ERM to predict digit classes, and inspect the outputs of the last hidden layer $z = f _ { \mathrm { e n c } } ( x )$ . As shown in Fig. 2, with low $p _ { \mathrm { c o r r } }$ , models learn representations with high dependence on the actual digit classes. However, with high $p _ { \mathrm { c o r r } }$ we learn $z$ highly dependent on $a$ , despite only training to predict $y$ . + +![](images/2d3f034dcde7f67f5c4cd5fc6b7fc5863464d7e40b5779ba75c0f8867200f18c.jpg) +5-class, $p _ { c o r r } = 0 . 9 5$ ,Train Data +Figure 2: UMAP visualization of learned CMNIST∗ representations. + +Representation metrics. To quantify this behavior, we use two metrics designed to capture how well the learned representations exhibit dependence on the class label vs. the spurious attributes. First, we compute an alignment loss $\hat { \mathcal { L } } _ { \mathrm { a l i g n } } ( f _ { \mathrm { e n c } } ; g , g ^ { \prime } )$ between two groups $g = ( y , a )$ and $g ^ { \prime } = ( y , a ^ { \prime } )$ where $a \neq a ^ { \prime }$ . This measures how well $f _ { \mathrm { e n c } }$ maps samples with the same class, but different spurious attributes, to nearby vectors via Euclidean distance. Letting $G$ and $G ^ { \prime }$ be the subsets of training data in groups $g$ and $g ^ { \prime }$ respectively, and $x$ and $x ^ { \prime }$ be any two samples in $G$ and $G ^ { \prime }$ , we define: + +$$ +\hat { \mathcal { L } } _ { \mathrm { a l i g n } } ( f _ { \mathrm { e n c } } ; g , g ^ { \prime } ) : = \frac { 1 } { | G | } \frac { 1 } { | G ^ { \prime } | } \sum _ { ( x , y , a ) \in G } \sum _ { ( x ^ { \prime } , y , a ^ { \prime } ) \in G ^ { \prime } } \Vert f _ { \mathrm { e n c } } ( x ) - f _ { \mathrm { e n c } } ( x ^ { \prime } ) \Vert _ { 2 } . +$$ + +Thus, lower $\hat { \mathcal { L } } _ { \mathrm { a l i g n } }$ means better alignment. We also quantify representation dependence by estimating the mutual information (MI) of a model’s learned representations with the class label, i.e. $\hat { I } ( Y ; Z )$ and the spurious attributes $\hat { I } ( A ; Z )$ . We defer computational details to Appendix E. + +![](images/e54fa14e295b0370e7fad6581704a267637b81c22e0693a129b25dd3536d19ba.jpg) +Figure 3: Accuracy and representation metrics from ERM models trained on increasingly spuriously correlated Colored MNIST. High worst-group accuracy corresponds to both $\hat { I } ( Y ; Z ) > \hat { I } ( A ; Z )$ and small alignment loss. + +Results for ERM. In Fig. 3 we show a strong association between worst-group error and both alignment and mutual information metrics. As $p _ { \mathrm { c o r r } }$ increases, ERM models not only drop in worst-group accuracy, but also incur higher alignment loss (Fig. 3ab). Fig. 3c further illustrates this with mutual information. We plot the estimated mutual information and worst-group accuracy for models at each epoch. A substantial drop in worst-group accuracy occurs with high $\hat { I } ( A ; Z )$ (especially + +![](images/6a32eccd1832a340ceaeb096e2658d6afd5a7d7d3bac2ea83c22157bab3bcd1a.jpg) +Figure 4: Higher worst-group accuracy with upsampling coincides with keeping $\hat { I } ( Y ; \bar { Z } ) \gg \hat { I } ( A ; Z )$ . + +when $\hat { I } ( A ; Z ) > \hat { I } ( Y ; Z )$ , even with high $\hat { I } ( Y ; Z ) )$ . Fig. 3d also captures this trend with a trade off between high $\hat { I } ( Y ; Z )$ with $\hat { I } ( A ; Z )$ as $p _ { \mathrm { c o r r } }$ increases (Fig. 3a). + +Results for JTT. In Fig. 4, we also show that this relation holds when training with another recent (upsampling) approach, JTT (Liu et al., 2021). With high $p _ { \mathrm { c o r r } }$ , models now achieve higher worstgroup accuracy, and this corresponds to learning representations with high class label and low spurious attribute dependence. We note however that previous approaches do not explicitly optimize for these representation metrics, suggesting a new direction to improve worst-group performance. + +# 3.2 RELATING ALIGNMENT LOSS TO WORST-GROUP LOSS + +The empirical observations in Fig. 3 suggest that lower alignment loss correlates with lower worstgroup error. Next, we show that this connection applies much more generally. We show that the maximum of $\hat { \mathcal { L } } _ { \mathrm { a l i g n } } ( f _ { \mathrm { e n c } } ; g , g ^ { \prime } )$ , over any two groups $g , g ^ { \prime }$ within the same class, can be used to upper bound the gap between the worst-group loss and average loss for that class. We set up several notations before stating the result. For any class label $y \in \mathcal { V }$ , let $\mathcal { G } _ { y }$ be the set of groups with label $y$ in $\mathcal { G }$ . Let $\mathcal { L } _ { \mathrm { w g } } ( f _ { \theta } ; y )$ be the worst-group loss among groups in $\mathcal { G } _ { y }$ : + +$$ +\mathcal { L } _ { \mathrm { w g } } ( f _ { \theta } ; y ) : = \operatorname* { m a x } _ { g \in \mathcal { G } _ { y } } \underset { ( x , \tilde { y } , a ) \sim P _ { g } } { \mathbb { E } } \left[ \ell ( f _ { \theta } ( x ) , \tilde { y } ) \right] . +$$ + +Let $\mathcal { L } _ { \mathrm { a v g } } ( f _ { \theta } ; y )$ be the average loss among groups in $\mathcal { G } _ { y }$ : + +$$ +\mathcal { L } _ { \mathrm { a v g } } ( f _ { \theta } ; y ) : = \mathbb { E } \underbrace { \mathbb { E } } _ { ( x , \tilde { y } , a ) \sim P : \forall a \in \mathcal { A } } \left[ \ell ( f _ { \theta } ( x ) , \tilde { y } ) \right] . +$$ + +Additionally, we define a class-specific alignment loss $\hat { \mathcal { L } } _ { \mathrm { a l i g n } } ( f _ { \mathrm { e n c } } ; y )$ among groups in $\mathcal { G } _ { y }$ . Recall that $f _ { \theta }$ involves an encoding function $f _ { \mathrm { e n c } }$ and a linear classification layer $f _ { \mathrm { c l s } }$ . We define $\hat { \mathcal { L } } _ { \mathrm { a l i g n } } ( f _ { \mathrm { e n c } } ; y )$ as the largest cross-group alignment loss among groups in $\mathcal { G } _ { y }$ : + +$$ +\hat { \mathcal { L } } _ { \mathrm { a l i g n } } ( f _ { \theta } ; y ) : = \operatorname* { m a x } _ { \substack { y \in \mathcal { G } _ { y } , g ^ { \prime } \in \mathcal { G } _ { y } : g \neq g ^ { \prime } } } \hat { \mathcal { L } } _ { \mathrm { a l i g n } } ( f _ { \mathrm { e n c } } ; g , g ^ { \prime } ) . +$$ + +where $\hat { \mathcal { L } } _ { \mathrm { a l i g n } } ( f _ { \mathrm { e n c } } ; g , g ^ { \prime } )$ is the alignment loss between $g$ and $g ^ { \prime }$ defined in Eq. (4). Our main result is that $\hat { \mathcal { L } } _ { \mathrm { a l i g n } } ( f _ { \theta } ; y )$ is an upper bound on the gap between $\mathcal { L } _ { \mathrm { w g } } ( f _ { \theta } ; y )$ and $\mathcal { L } _ { \mathrm { a v g } } ( f _ { \theta } ; y )$ (up to a norm multiplier and a concentration error), for any $y \in \mathcal { V }$ . + +Theorem 3.1 (Alignment loss upper bounds the gap between worst-group and average-group loss). In the setting described above, let fθ be any neural network satisfying that the weight matrix of the linear classification layer $W$ in $f _ { c l s }$ satisfies that $\| W \| _ { 2 } \leq B$ , for some constant $B$ . Let $n _ { g }$ be the size of any group $g \in { \mathcal { G } }$ in the training data set. Assume that the loss function $\ell ( x , y )$ is $C _ { 1 }$ -Lipschitz in $x$ and bounded from above by $C _ { 2 }$ , for some positive constants $C _ { 1 } , C _ { 2 }$ . Then, with probability at least $1 - \delta$ over the randomness of the training data set samples, for any class $y \in \mathcal { V }$ , the following holds: + +$$ +\mathcal { L } _ { w g } ( f _ { \theta } ; y ) \leq \mathcal { L } _ { a v g } ( f _ { \theta } ; y ) + B \cdot C _ { 1 } \cdot \hat { \mathcal { L } } _ { a l i g n } ( f _ { \theta } ; y ) + \operatorname* { m a x } _ { g \in \mathcal { G } _ { y } } C _ { 2 } \sqrt { \frac { 8 \log ( | \mathcal { G } _ { y } | / \delta ) } { n _ { g } } } . +$$ + +The proof of Theorem 3.1 is deferred to Sec. B. Since we also know that $\mathcal { L } _ { \mathrm { a v g } } ( f _ { \theta } ; y ) \le \mathcal { L } _ { \mathrm { w g } } ( f _ { \theta } ; y )$ the above result implies that in order to reduce the gap between the worst-group loss and the average loss for class $y$ , it suffices to reduce the alignment loss $\hat { \mathcal { L } } _ { \mathrm { a l i g n } } ( f _ { \theta } ; y )$ . + +Broader algorithmic implications. We summarize Section 3 with two takeaways: (1) When trained on spuriously correlated data sets, ERM networks learn data representations highly dependent on spurious attributes. Clusters of these representations (Sohoni et al., 2020) or the ERM model’s outputs (Liu et al., 2021; Nam et al., 2020) can thus serve as (noisy) pseudolabels for spurious attributes. (2) Both representation metrics correlate with worst-group error, such that a viable way to improve worst-group performance is to improve representation alignment within each class. + +# 4 CORRECT-N-CONTRAST (CNC) + +We now present CNC, a two-stage method to improve worst-group performance and robustness to spurious correlations, without requiring training group labels. Similar to prior works (Sohoni et al., 2020; Liu et al., 2021), our first stage trains an ERM model (with proper regularization1) on the training set, ultimately to infer group labels based on samples’ spurious attributes. + +# Algorithm 1 Correct-N-Contrast (CNC) + +Input: Training data set $( X , Y )$ ; # positives $M$ ; # negatives $N$ ; learning rate $\eta$ , # epochs $K$ . Stage 1: ERM Training +1: Train a regularized ERM model $f _ { \hat { \theta } }$ on $( X , Y )$ ; save the predictions $\hat { y } _ { i } : = f _ { \hat { \theta } } ( x _ { i } )$ . Stage 2: Supervised contrastive learning +2: for each epoch $1 , \ldots , K$ do +3: for each anchor $( x , y ) \in ( X , Y )$ do +4: Let $\hat { y }$ be the predicted (group) label of $_ x$ from Stage 1’s ERM model. +5: Get $M$ positives $\{ ( x _ { m } ^ { + } , y _ { m } ^ { + } ) \}$ where $y _ { m } ^ { + } = y$ but $\hat { y } _ { m } ^ { + } \neq \hat { y }$ , for $m = 1 , \ldots , M$ . +6: Get $N$ negatives $\{ ( x _ { q } ^ { - } , y _ { q } ^ { - } ) \}$ where $y _ { q } ^ { - } \neq y$ but $\hat { y } _ { q } ^ { - } = \hat { y }$ , for $q = 1 , \ldots , N$ . +7: Update $f _ { \theta }$ by $\theta \gets \theta - \eta \cdot \nabla \hat { \mathcal { L } } ( f _ { \theta } ; x , y )$ (cf. Eq. (7)) with anchor, $M$ positives, and $N$ negatives. return final model $f _ { \theta }$ from Stage 2, and throw away the ERM model from Stage 1. + +The key difference is our second stage: we aim to train a more robust model by learning representations such that samples in the same class but different groups are close to each other. We use contrastive learning, as intuitively by treating samples with the same class but different spurious attributes as distinct “views” of the same class, we train the second stage model to “pull together” these samples’ representations and ignore the different spurious features. This is also inspired by Wang & Isola (2020); Robinson et al. (2021), who show that minimizing the contrastive loss improves representation alignment between distinct “views”. Later in Sec. 5.1, we verify that CNC indeed reduces $\hat { \mathcal { L } } _ { \mathrm { a l i g n } } ( f _ { \theta } ; y )$ substantially. We include further details on both stages below, and summarize CNC in Algorithm 1. + +Stage 1: ERM training. We train an initial model $f _ { \hat { \theta } }$ on the training data set $\{ ( x _ { i } , y _ { i } ) \} _ { i = 1 } ^ { n }$ with ERM and regularization, and save its predictions $\{ \hat { y } _ { i } \} _ { i = 1 } ^ { n }$ on the training data points. We consider two ways to source predictions: using the ERM model’s outputs, and clustering its last hidden-layer representations. Both approaches aim to accomplish the same goal of exploiting the ERM model’s learned spurious correlations; further details are in Appendix E.2. + +Stage 2: Contrastive learning (CL). Next, we train a robust model with supervised contrastive learning using the ERM predictions. While CNC is inspired by recent CL works (Chen et al., 2020; Khosla et al., 2020), we introduce new “contrastive batch” sampling and optimization objectives. + +Contrastive batch sampling. As described in Sec. 2, contrastive learning requires sampling anchors, positives, and negatives with the general form $\{ x \} , \{ x ^ { + } \} , \{ x ^ { - } \}$ . Here, we wish to sample points such that by maximizing the similarity between anchors and positives (and keeping anchors and negatives apart), the Stage 2 model “ignores” spurious similarities while learning class-consistent dependencies. With prediction set $\{ \hat { y } _ { i } \} _ { i = 1 } ^ { n }$ , for each batch we randomly sample an anchor $x _ { i } \in X$ (with label $y _ { i }$ and ERM prediction $\hat { y } _ { i }$ ), $M$ positives with the same class as $y _ { i }$ but a different ERM model prediction than $\hat { y } _ { i }$ , and $N$ negatives with different classes as $y _ { i }$ but the same ERM model prediction as $\hat { y } _ { i }$ . For more signal per batch, we double pairwise comparisons by switching anchor and positive roles. + +Optimization objective and updating procedure. While our core objective is to learn aligned representations via contrastive learning, we also wish to train the full model to classify datapoints correctly. As we have the training class labels, we jointly update both the model’s encoder layers $f _ { \mathrm { e n c } }$ with a standard contrastive loss, and the full model $f _ { \theta }$ with a cross-entropy loss: + +$$ +\hat { \mathcal { L } } ( f _ { \theta } ; x , y ) = \lambda \hat { \mathcal { L } } _ { \mathrm { c o n } } ^ { \mathrm { s u p } } ( f _ { \mathrm { e n c } } ; x , y ) + ( 1 - \lambda ) \hat { \mathcal { L } } _ { \mathrm { c r o s s } } ( f _ { \theta } ; x , y ) . +$$ + +In the above, $\hat { \mathcal { L } } _ { \mathrm { c o n } } ^ { \mathrm { s u p } } ( f _ { \mathrm { e n c } } ; x , y )$ is the supervised contrastive loss of $x$ along with its positive and negative samples, similar to Eq. (3) (see Eq. (16) in Sec. C.2 for the full equation); $\hat { \mathcal { L } } _ { \mathrm { c r o s s } } ( f _ { \theta } ; x , y )$ is averaged cross-entropy loss over $x$ , the $M$ positives, and the $N$ negatives; $\lambda \in [ 0 , 1 ]$ is a balancing hyperparameter. As a remark, the loss objective (7) uses a single anchor in each batch in our setting. + +To calculate the loss, we first forward propagate one band normalize them to obtain representation vectors $\left( x _ { i } , \{ x _ { m } ^ { + } \} _ { m = 1 } ^ { M } , \{ x _ { q } ^ { - } \} _ { q = 1 } ^ { N } \right)$ through learn clo $f _ { \mathrm { e n c } }$ $\left( z _ { i } , \{ z _ { m } ^ { + } \} _ { m = 1 } ^ { M } , \{ z _ { q } ^ { - } \} _ { q = 1 } ^ { N } \right)$ aligned $z _ { i }$ and $z ^ { + }$ for all $\{ z _ { m } ^ { + } \} _ { m = 1 } ^ { M }$ , we update $f _ { \mathrm { e n c } }$ with the $\hat { \mathcal { L } } _ { \mathrm { o u t } } ^ { \mathrm { s u p } } ( x ; f _ { \mathrm { e n c } } )$ loss. Finally, we also pass the unnormalized outputs of the encoder $f _ { \mathrm { e n c } }$ to the classifier layers $f _ { \mathrm { c l s } }$ , and compute a batch-wise cross-entropy loss $\hat { \mathcal { L } } _ { \mathrm { c r o s s } } ( f _ { \theta } )$ using each batch sample’s class labels and $f _ { \theta }$ ’s outputs. Due to space constraints, we include further implementation details and sampling considerations in Appendix C. + +# 5 EXPERIMENTAL RESULTS + +We conduct experiments to answer the following questions: (1) Does CNC improve worst-group performance over prior state-of-the-art methods on data sets with spurious correlations? (2) Does CNC actually encourage learning hidden layer representations with greater alignment and class-labelonly dependence? How is this impacted by the strength of a spurious correlation in the data? (3) Does CNC require perfectly predicting the spurious attribute to work well in practice? Our results for each question follows in the next three subsections (5.1, 5.2, and 5.3). Due to space constraints, we defer ablations on CNC’s design choices, including the representation-learning objective and sampling procedure, to Appendix A. Additional comparison to alignment methods proposed for domain adaptation but adjusted for our setting are in Appendix A.2. Below, we briefly describe the benchmark data sets used in this section. We run CMNIST∗ with $p _ { \mathrm { c o r r } } = 0 . 9 9 5$ . Further details on data sets, models, and experimental hyperparameters are deferred to Appendix E. + +Waterbirds (Sagawa et al., 2019): We classify $\begin{array} { r } { \mathcal { V } = \left\{ \begin{array} { r l r l } \end{array} \right. } \end{array}$ {waterbird, landbird}, where $9 5 \%$ of images have the same bird type and background $\begin{array} { r } { A = \left\{ \begin{array} { r l } \end{array} \right. } \end{array}$ {water background, land background}. + +CelebA (Liu et al., 2015): We classify celebrities’ hair color $\mathcal { Y } = \{ \mathrm { b l o n d } , \mathrm { n o t } \mathrm { b l o n d } \}$ with $\mathcal { A } = \{ \mathrm { m a l e } .$ female}. Only $6 \%$ of blond celebrities in the data set are male. + +CivilComments-WILDS (Borkan et al., 2019; Koh et al., 2021): We classify $\mathcal { Y } = \{ \mathrm { t o x i c } , \mathrm { n o t } \mathrm { t o x i c } \}$ comments. $\mathcal { A }$ denotes whether the comment mentions one of eight demographic identities. + +# 5.1 CNC IMPROVES WORST-GROUP PERFORMANCE + +To study (1), we evaluate CNC on image classification and NLP data sets with spurious correlations. As baselines, we compare against standard ERM and an oracle GDRO approach that assumes access to the group labels. We also compare against recent methods that tackle spurious correlations without requiring group labels: CVaR DRO (Levy et al., 2020), GEORGE (Sohoni et al., 2020), Learning from Failure (LfF) (Nam et al., 2020), Predictive Group Invariance (PGI) (Ahmed et al., 2021), Environment Inference for Invariant Learning (EIIL) (Creager et al., 2021), Contrastive Input Morphing (CIM) (Taghanaki et al., 2021), and Just Train Twice (JTT) (Liu et al., 2021). We also compare against a CNC version without the Stage 1 ERM model, instead only sampling positives and negatives based on class (denoting this SupCon\*). Results are reported in Table 1. CNC achieves highest worst-group accuracy among all methods without training group labels on the CMNIST∗ Waterbirds and CelebA data sets, while also obtaining near-SoTA worst-group accuracy on CivilComments. + +While LfF, GEORGE, PGI, EIIL, and JTT similarly use a trained ERM model to estimate groups, CNC uniquely uses ERM predictions to encourage the robust model to learn desirable representations via contrastive learning. We reason that with this approach, by sampling positives and negatives from the ERM predictions, CNC more directly encourages the robust model to ignore learnable spurious correlations compared to previous invariant learning, input transformation, or upweighting approaches. We include additional evidence of this via GradCAM visualizations in Appendix G. + +![](images/c589af92c41a8f15de488d7891a487739b5642d21a3fdc96a5686abaab2719d5.jpg) +Figure 5: Alignment loss (a) and mutual information (b, c) of models trained with ERM, JTT, and CNC, on Waterbirds and CelebA. CNC most effectively removes dependence on the spurious attribute, and obtains smaller gaps for per-class worst-group vs. average error (d), as supported by Thm. 3.1. + +# 5.2 CNC LEARNS REPRESENTATIONS LESS RELIANT ON SPURIOUS FEATURES + +To shed light on CNC’s worst-group accuracy gains, we investigate if models trained with CNC actually learn representations with higher alignment. Compared to ERM and JTT (the next-best performing method that does not require subgroup labels), CNC learns representations with significantly higher alignment (lower alignment loss) and lower mutual information with spurious attributes (while having comparable mutual information with class labels) (Fig. 5 and Fig. 7). + +Table 1: Worst-group and average accuracies, averaged over three seeds (standard deviations in parenthesis). On image data sets, CNC obtains significantly higher worst-group accuracy than comparable methods without group labels, competing with GDRO. CNC also competes with SoTA on CivilComments. Results without standard deviations are reported from the original papers. Further implementation details are in Appendix E. + +
MethodCMNIST*WaterbirdsCelebACivilComments-WILDS
Accuracy (y (%) Worst-groupAvg.Worst-groupAvg.Worst-groupAvg.Worst-groupAvg.
ERM0.0 (0.0)20.1 (0.2)72.697.347.295.657.492.6
CVaR DRO22.1 (5.0)61.3 (4.1)75.996.064.482.560.592.5
LfF0.0 (0.0)25.0 (0.5)78.091.277.285.158.892.5
GEORGE76.4 (2.3)89.5 (0.3)83.8 (1.0)95.7 (0.5) 54.9 (1.9)94.6 (0.2)--
PGI73.5 (1.8)88.5 (1.4) 73.8 (0.8) 84.6 (0.1) 77.8 (1.8) 82.0 (0.6)
CIM0.0 (0.0)36.8 (1.3)77.295.683.690.6N/AN/A
EIIL72.8 (6.8)90.7 (0.9)78.796.981.7 (0.8)85.7 (0.1)67.0 (2.4)90.5 (0.2)
JTT74.5 (3.1)90.2 (0.8)86.793.381.188.069.391.1
SupCon*0.0 (0.0)22.4 (1.2)71.0 (1.9)85.9 (0.8)62.2 (1.1)90.0 (0.1)
CNC (Ours)77.4 (3.0)90.9 (0.6) 89.7 (0.2)90.8 (0.1)88.8 (0.9)89.9 (0.5)68.9 (2.1)81.7 (0.5)
Group DRO78.5 (4.5)90.6 (0.1)91.1 (0.2)92.4 (0.2)88.9 (1.3)93.9 (0.1)69.8 (2.4)89.0 (0.3)
+ +![](images/9246d66ecfd5f2ded6806da8e59336819fbe0b51e7bb1fc2f93c96b94e5414f0.jpg) +Figure 6: UMAPs of Waterbirds representations, colored by class (left) and spurious attribute (right). ERM depends on both classes $\mathcal { V }$ and spurious attributes $\mathcal { A }$ , though with greater separability for the latter. JTT representations depend more on $\mathcal { V }$ , but also on $\mathcal { A }$ . CNC gets closer to fully removing the dependence on $\mathcal { A }$ . + +We find that CNC representations exhibit the lowest alignment loss consistently for these data sets; this also corresponds to CNC models achieving the highest worst-group accuracy. Furthermore, while all methods result in representations that exhibit high mutual information with the class label (Fig. 5b), only CNC results in representations that drastically reduce mutual information with spurious attributes (Fig. 5c). In Fig. 6, we also illustrate this result on the Waterbirds data set via UMAP visualizations of the learned representations. Notably, all training methods result in representations separable by class label. Yet ERM models exhibit strong separability by spurious attributes, and JTT models interestingly also still depict some learned dependency on the spurious attribute. However, CNC uniquely learns representations that strongly depict class-label-only dependence. + +In addition, to study how this relation between representation metrics and worst-group accuracy scales with the strength of the spurious correlation, we compute representation metrics with CNC, ERM, and JTT models trained on increasingly spurious $( \uparrow p _ { \mathrm { c o r r } } )$ CMNIST∗ data sets in Fig. 7. We observe that with high spurious correlations, ERM fails to classify digits in the minority classes, while CNC and JTT comparably maintain high worst-group accuracy. CNC also performs better in more spurious settings $\mathrm { \chi } p _ { \mathrm { c o r r } } > 0 . 9 5 )$ . These improvements over ERM are reflected by drops in alignment loss (averaged over classes); CNC consistently achieves lowest such loss. Fig. 7c shows that CNC’s learned representations maintain a more favorable balance of mutual information between the class label and spurious attribute than JTT. While JTT models exhibit slightly higher estimated $I ( Y ; Z )$ than CNC models, CNC models exhibit much lower dependence on the spurious attribute. + +# 5.3 UNDERSTANDING CNC’S SENSITIVITY TO STAGE 1 PREDICTIONS + +Finally, we study how sensitive CNC is to how closely the Stage 1 ERM model actually predicts the spurious attribute. As JTT also relies on an initial ERM model’s predictions, we compare CNC to JTT in this regard. We find that CNC is more robust to noisy ERM predictions than JTT, and that CNC does not require perfectly inferred groups to perform well. + +We first conduct an ablation on CNC and JTT’s worst-group and average performance in Fig. 7d with the following synthetic experiment. On CMNIST $^ { 1 \ast }$ , we start with the true spurious attribute labels as the Stage 1 “predictions". We then gradually degrade their quality as follows: for each point, with + +![](images/b171594ebbf7b3136c764c329360f10235b5d746925a58435b1f684e7476287d.jpg) +Figure 7: Alignment loss and mutual information representation metrics with worst-group accuracy on increasingly spurious CMNIST∗. CNC highest worst-group accuracy (a) coincides with learning representations with better alignment (b) and ratio of mutual information dependence on the labels vs the spurious attribute (c). probability $p$ we change its assigned spurious attribute label to a different label chosen uniformly at random. Both methods’ performance degrades as $p$ increases and the Stage 1 “predictions” degrade. However, CNC consistently achieves higher worst-group accuracy and smaller worst-group versus average accuracy gaps. We also observe on other data sets that CNC does not require perfectly spurious ERM predictions to work well. For the Waterbirds and CelebA results in Table 1, the Stage 1 ERM model predictions align with the spurious attribute value $9 4 . 7 \%$ and $5 9 . 3 \%$ of the time respectively. While the ERM model is far from perfect at recognizing the spurious attributes, CNC still substantially reduces the worst-group vs. average accuracy gap. + +# 6 RELATED WORK + +We build on prior work in group robustness and contrastive learning. Further discussion is in App. D. Robustness to group shift. A variety of approaches aim to improve performance on minority data groups. If group labels are known, many works minimize a rebalanced error similar in motivation to correcting class imbalance (He & Garcia, 2009; Cui et al., 2019) or importance weighting (Shimodaira, 2000; Byrd & Lipton, 2019). More recently, Sagawa et al. (2019) minimize worst-group loss during training. Goel et al. (2020) achieve further lift by synthetically generating additional minority group points. Cao et al. (2019) regularize updates on minority groups to improve their generalization. + +Another line of work aims to improve group robustness without assuming group labels for the training data. The most similar methods to CNC first train an initial ERM model with class labels as a way to infer groups, and then use these groups to train a second model with better worst-group performance. GEORGE (Sohoni et al., 2020) clusters ERM representations, and runs GDRO with these clusters as inferred groups. EIIL (Creager et al., 2021) and PGI (Ahmed et al., 2021) infer groups that maximally violate an invariance objective for the ERM model. With these groups EIIL uses either GDRO or Invariant Risk Minimization (Arjovsky et al., 2019) to train a second robust model, while PGI minimizes the KL divergence of the softmaxed logits for samples in the same class but different groups. LfF (Nam et al., 2020) use a generalized cross-entropy loss to encourage misclassifying minority groups, concurrently training a second model with these datapoints upweighted. JTT (Liu et al., 2021) trains via ERM for a few epochs, before training a second ERM model with incorrect datapoints upsampled. For image data sets, CIM (Taghanaki et al., 2021) trains a transformation network to remove potentially spurious attributes from input features. + +Contrastive learning (CL). CL works by predicting whether two inputs are “similar” or “dissimilar” (Le-Khac et al., 2020). This involves specifying batches of anchor and positive datapoints similar to each other (as different “views” of the same source or input), and negatives depicting dissimilar points. An encoder is trained to simultaneously maximize the similarity between the feature representations of anchors and positives, and minimize similarity between anchor and negative representations. In unsupervised CL, “negatives” are often sampled uniformly (Bachman et al., 2019), while “positives” are different views of the same object, e.g. via data augmentation (Chen et al., 2020). In supervised CL, negatives are different-class points and positives are same-class points (Khosla et al., 2020). In CNC, we instead treat same-class points with different ERM predictions as positives, and differentclass points with the same ERM prediction as negatives. This naturally provides “hard negative mining,” a challenge for standard CL (Robinson et al., 2021; Wu et al., 2021; Chuang et al., 2020). + +# 7 CONCLUSION + +We present CNC, a two-stage CL approach to learn representations robust to spurious correlations. We theoretically analyze the connection between alignment and worst-group vs. average-group losses, and show that CNC achieves SOTA or near-SOTA worst-group accuracy across several benchmarks. + +# ETHICS STATEMENT + +We hope that our work is another step towards the important goal of making machine learning models more fair and robust. However, while our work successfully improves worst-group accuracy, this is not necessarily an end-all be-all metric - other fairness-based metrics may be more suitable in certain settings. Also, misuse of metrics could lead to potential harm. To avoid these pitfalls, it is important for practitioners to understand the limitations and tradeoffs of different metrics, including when applying methods such as ours. + +# REPRODUCIBILITY STATEMENT + +We have submitted our code as part of the supplementary materials. The datasets we use are publicly available (with the exception of CMNIST∗ which is a modification of the standard MNIST dataset (LeCun et al., 2010); our code to generate this modified dataset is also included). In addition to the details provided in Section 5, further implementation, dataset, and experimental details can be found in Appendix E. For the theory, we include complete proofs of all claims in Appendix B. + +# REFERENCES + +Faruk Ahmed, Yoshua Bengio, Harm van Seijen, and Aaron C. Courville. Systematic generalisation with group invariant predictions. In ICLR, 2021. + +Kartik Ahuja, Karthikeyan Shanmugam, Kush Varshney, and Amit Dhurandhar. Invariant risk minimization games. In International Conference on Machine Learning, pp. 145–155. PMLR, 2020. + +Alexander A Alemi, Ian Fischer, Joshua V Dillon, and Kevin Murphy. Deep variational information bottleneck. arXiv preprint arXiv:1612.00410, 2016. + +Martin Arjovsky and Léon Bottou. Towards principled methods for training generative adversarial networks. arXiv preprint arXiv:1701.04862, 2017. + +Martin Arjovsky, Léon Bottou, Ishaan Gulrajani, and David Lopez-Paz. Invariant risk minimization. arXiv preprint arXiv:1907.02893, 2019. + +Devansh Arpit, Stanisław Jastrz˛ebski, Nicolas Ballas, David Krueger, Emmanuel Bengio, Maxinder S Kanwal, Tegan Maharaj, Asja Fischer, Aaron Courville, Yoshua Bengio, et al. A closer look at memorization in deep networks. In International Conference on Machine Learning, pp. 233–242. PMLR, 2017. + +Philip Bachman, R Devon Hjelm, and William Buchwalter. Learning representations by maximizing mutual information across views. In Advances in Neural Information Processing Systems, volume 32, 2019. + +Ananth Balashankar, Alyssa Lees, Chris Welty, and Lakshminarayanan Subramanian. What is fair? exploring Pareto-efficiency for fairness constrained classifiers. arXiv preprint arXiv:1910.14120, 2019. + +Sara Beery, Grant Van Horn, and Pietro Perona. Recognition in terra incognita. In Proceedings of the European Conference on Computer Vision (ECCV), pp. 456–473, 2018. + +Aharon Ben-Tal, Dick Den Hertog, Anja De Waegenaere, Bertrand Melenberg, and Gijs Rennen. Robust solutions of optimization problems affected by uncertain probabilities. Management Science, 59(2):341–357, 2013. + +Su Lin Blodgett, Lisa Green, and Brendan O’Connor. Demographic dialectal variation in social media: A case study of african-american english. arXiv preprint arXiv:1608.08868, 2016. + +Daniel Borkan, Lucas Dixon, Jeffrey Sorensen, Nithum Thain, and Lucy Vasserman. Nuanced metrics for measuring unintended bias with real data for text classification. In Companion proceedings of the 2019 world wide web conference, pp. 491–500, 2019. + +Joy Buolamwini and Timnit Gebru. Gender shades: Intersectional accuracy disparities in commercial gender classification. In Conference on fairness, accountability and transparency, pp. 77–91. PMLR, 2018. + +Jonathon Byrd and Zachary Lipton. What is the effect of importance weighting in deep learning? In International Conference on Machine Learning, pp. 872–881. PMLR, 2019. + +Kaidi Cao, Colin Wei, Adrien Gaidon, Nikos Arechiga, and Tengyu Ma. Learning imbalanced datasets with label-distribution-aware margin loss. In Advances in Neural Information Processing Systems, volume 32, 2019. + +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. + +Ching-Yao Chuang, J. Robinson, Yen-Chen Lin, A. Torralba, and S. Jegelka. Debiased contrastive learning. In Advances in Neural Information Processing Systems, volume abs/2007.00224, 2020. + +Remi Tachet des Combes, Mohammad Pezeshki, Samira Shabanian, Aaron Courville, and Yoshua Bengio. On the learning dynamics of deep neural networks. arXiv preprint arXiv:1809.06848, 2018. + +Elliot Creager, Jörn-Henrik Jacobsen, and Richard Zemel. Environment inference for invariant learning. In International Conference on Machine Learning, pp. 2189–2200. PMLR, 2021. + +Yin Cui, Menglin Jia, Tsung-Yi Lin, Yang Song, and Serge Belongie. Class-balanced loss based on effective number of samples. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 9268–9277, 2019. + +Sebastian Curi, Kfir Y. Levy, Stefanie Jegelka, and Andreas Krause. Adaptive sampling for stochastic risk-averse learning. In Advances in Neural Information Processing Systems, volume 33, pp. 1036–1047, 2020. + +John Duchi and Hongseok Namkoong. Variance-based regularization with convex objectives. The Journal of Machine Learning Research, 20(1):2450–2504, 2019. + +Chen Fang, Ye Xu, and Daniel N Rockmore. Unbiased metric learning: On the utilization of multiple datasets and web images for softening bias. In Proceedings of the IEEE International Conference on Computer Vision, pp. 1657–1664, 2013. + +Yaroslav Ganin, Evgeniya Ustinova, Hana Ajakan, Pascal Germain, Hugo Larochelle, François Laviolette, Mario Marchand, and Victor Lempitsky. Domain-adversarial training of neural networks. The journal of machine learning research, 17(1):2096–2030, 2016. + +Karan Goel, Albert Gu, Yixuan Li, and Christopher Ré. Model patching: Closing the subgroup performance gap with data augmentation. In International Conference on Learning Representations, 2020. + +Beliz Gunel, Jingfei Du, Alexis Conneau, and Ves Stoyanov. Supervised contrastive learning for pre-trained language model fine-tuning. In International Conference on Learning Representations, 2021. + +M. Gutmann and A. Hyvärinen. Noise-contrastive estimation: A new estimation principle for unnormalized statistical models. In AISTATS, 2010. + +Tatsunori Hashimoto, Megha Srivastava, Hongseok Namkoong, and Percy Liang. Fairness without demographics in repeated loss minimization. In International Conference on Machine Learning, pp. 1929–1938. PMLR, 2018. + +Kaveh Hassani and Amir Hosein Khasahmadi. Contrastive multi-view representation learning on graphs. In International Conference on Machine Learning, pp. 4116–4126. PMLR, 2020. + +Haibo He and Edwardo A Garcia. Learning from imbalanced data. IEEE Transactions on knowledge and data engineering, 21(9):1263–1284, 2009. + +Katherine L. Hermann and Andrew K. Lampinen. What shapes feature representations? exploring datasets, architectures, and training. In Advances in Neural Information Processing Systems (NeurIPS), 2020. + +Shachar Kaufman, Saharon Rosset, Claudia Perlich, and Ori Stitelman. Leakage in data mining: Formulation, detection, and avoidance. ACM Transactions on Knowledge Discovery from Data (TKDD), 6(4):1–21, 2012. + +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, volume 33, pp. 18661–18673, 2020. + +Pang Wei Koh, Shiori Sagawa, Sang Michael Xie, Marvin Zhang, Akshay Balsubramani, Weihua Hu, Michihiro Yasunaga, Richard Lanas Phillips, Irena Gao, Tony Lee, et al. Wilds: A benchmark of in-the-wild distribution shifts. In International Conference on Machine Learning, pp. 5637–5664. PMLR, 2021. + +David Krueger, Ethan Caballero, Joern-Henrik Jacobsen, Amy Zhang, Jonathan Binas, Dinghuai Zhang, Remi Le Priol, and Aaron Courville. Out-of-distribution generalization via risk extrapolation (rex). arXiv preprint arXiv:2003.00688, 2020. + +Phuc H. Le-Khac, Graham Healy, and Alan F. Smeaton. Contrastive representation learning: A framework and review. IEEE Access, 8:193907–193934, 2020. doi: 10.1109/ACCESS.2020. 3031549. + +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. + +Yann LeCun, Corinna Cortes, and CJ Burges. MNIST handwritten digit database. ATT Labs [Online]. http://yann.lecun.com/exdb/mnist, 2010. + +Daniel Levy, Yair Carmon, John C Duchi, and Aaron Sidford. Large-scale methods for distributionally robust optimization. In Advances in Neural Information Processing Systems, volume 33, pp. 8847– 8860, 2020. + +Haoliang Li, Sinno Jialin Pan, Shiqi Wang, and Alex C Kot. Domain generalization with adversarial feature learning. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 5400–5409, 2018. + +Evan Z Liu, Behzad Haghgoo, Annie S Chen, Aditi Raghunathan, Pang Wei Koh, Shiori Sagawa, Percy Liang, and Chelsea Finn. Just train twice: Improving group robustness without training group information. In International Conference on Machine Learning, pp. 6781–6792. PMLR, 2021. + +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. + +Natalia Martinez, Martin Bertran, and Guillermo Sapiro. Minimax pareto fairness: A multi objective perspective. In International Conference on Machine Learning (ICML), 2020. + +A. Mnih and K. Kavukcuoglu. Learning word embeddings efficiently with noise-contrastive estimation. In NIPS, 2013. + +Vaishnavh Nagarajan, Anders Andreassen, and Behnam Neyshabur. Understanding the failure modes of out-of-distribution generalization. arXiv preprint arXiv:2010.15775, 2020. + +Junhyun Nam, Hyuntak Cha, Sungsoo Ahn, Jaeho Lee, and Jinwoo Shin. Learning from failure: De-biasing classifier from biased classifier. In Advances in Neural Information Processing Systems, volume 33, pp. 20673–20684, 2020. + +Luke Oakden-Rayner, Jared Dunnmon, Gustavo Carneiro, and Christopher Ré. Hidden stratification causes clinically meaningful failures in machine learning for medical imaging. In Proceedings of the ACM conference on health, inference, and learning, pp. 151–159, 2020. + +Aaron van den Oord, Yazhe Li, and Oriol Vinyals. Representation learning with contrastive predictive coding. arXiv preprint arXiv:1807.03748, 2018. + +Yonatan Oren, Shiori Sagawa, Tatsunori B Hashimoto, and Percy Liang. Distributionally robust language modeling. In Empirical Methods in Natural Language Processing (EMNLP), 2019. + +Giambattista Parascandolo, Alexander Neitz, Antonio Orvieto, Luigi Gresele, and Bernhard Schölkopf. Learning explanations that are hard to vary. arXiv preprint arXiv:2009.00329, 2020. + +Mohammad Pezeshki, Sékou-Oumar Kaba, Yoshua Bengio, Aaron Courville, Doina Precup, and Guillaume Lajoie. Gradient starvation: A learning proclivity in neural networks. arXiv preprint arXiv:2011.09468, 2020. + +Marco Tulio Ribeiro, Sameer Singh, and Carlos Guestrin. “why should i trust you?” explaining the predictions of any classifier. In Proceedings of the 22nd ACM SIGKDD international conference on knowledge discovery and data mining, pp. 1135–1144, 2016. + +J. Robinson, Ching-Yao Chuang, S. Sra, and S. Jegelka. Contrastive learning with hard negative samples. In International Conference on Learning Representations, 2021. + +Kate Saenko, Brian Kulis, Mario Fritz, and Trevor Darrell. Adapting visual category models to new domains. In European conference on computer vision, pp. 213–226. Springer, 2010. + +Shiori Sagawa, Pang Wei Koh, Tatsunori B Hashimoto, and Percy Liang. Distributionally robust neural networks for group shifts: On the importance of regularization for worst-case generalization. In International Conference on Learning Representations, 2019. + +Shiori Sagawa, Aditi Raghunathan, Pang Wei Koh, and Percy Liang. An investigation of why overparameterization exacerbates spurious correlations. In International Conference on Machine Learning, pp. 8346–8356. PMLR, 2020. + +Ramprasaath R Selvaraju, Michael Cogswell, Abhishek Das, Ramakrishna Vedantam, Devi Parikh, and Dhruv Batra. Grad-cam: Visual explanations from deep networks via gradient-based localization. In Proceedings of the IEEE international conference on computer vision, pp. 618–626, 2017. + +Pierre Sermanet, Corey Lynch, Yevgen Chebotar, Jasmine Hsu, Eric Jang, S. Schaal, and Sergey Levine. Time-contrastive networks: Self-supervised learning from video. 2018 IEEE International Conference on Robotics and Automation (ICRA), pp. 1134–1141, 2018. + +Hidetoshi Shimodaira. Improving predictive inference under covariate shift by weighting the loglikelihood function. Journal of statistical planning and inference, 90(2):227–244, 2000. + +Nimit Sohoni, Jared Dunnmon, Geoffrey Angus, Albert Gu, and Christopher Ré. No subclass left behind: Fine-grained robustness in coarse-grained classification problems. In Advances in Neural Information Processing Systems, volume 33, pp. 19339–19352, 2020. + +Jiaming Song and Stefano Ermon. Multi-label contrastive predictive coding. In Advances in Neural Information Processing Systems, volume 33, pp. 8161–8173, 2020. + +Saeid Asgari Taghanaki, Kristy Choi, Amir Khasahmadi, and Anirudh Goyal. Robust representation learning via perceptual similarity metrics. arXiv preprint arXiv:2106.06620, 2021. + +Yonglong Tian, Dilip Krishnan, and Phillip Isola. Contrastive multiview coding. arXiv preprint arXiv:1906.05849, 2019. + +Yonglong Tian, Chen Sun, Ben Poole, Dilip Krishnan, Cordelia Schmid, and Phillip Isola. What makes for good views for contrastive learning. arXiv preprint arXiv:2005.10243, 2020. + +Julius von Kügelgen, Yash Sharma, Luigi Gresele, Wieland Brendel, Bernhard Schölkopf, Michel Besserve, and Francesco Locatello. Self-supervised learning with data augmentations provably isolates content from style. arXiv preprint arXiv:2106.04619, 2021. + +Catherine Wah, Steve Branson, Peter Welinder, Pietro Perona, and Serge Belongie. The caltech-ucsd birds-200-2011 dataset. 2011. + +Rui Wang, Zuxuan Wu, Zejia Weng, Jingjing Chen, Guo-Jun Qi, and Yu-Gang Jiang. Cross-domain contrastive learning for unsupervised domain adaptation. arXiv preprint arXiv:2106.05528, 2021. + +Tongzhou Wang and Phillip Isola. Understanding contrastive representation learning through alignment and uniformity on the hypersphere. In International Conference on Machine Learning, pp. 9929–9939. PMLR, 2020. + +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. + +Wolfram Wiesemann, Daniel Kuhn, and Melvyn Sim. Distributionally robust convex optimization. Operations Research, 62(6):1358–1376, 2014. + +M. Wu, M. Mosse, Chengxu Zhuang, D. Yamins, and Noah D. Goodman. Conditional negative sampling for contrastive learning of visual representations. In International Conference on Learning Representations, 2021. + +Zhilu Zhang and Mert Sabuncu. Generalized cross entropy loss for training deep neural networks with noisy labels. In Advances in Neural Information Processing Systems, volume 31, 2018. + +Bolei Zhou, Agata Lapedriza, Aditya Khosla, Aude Oliva, and Antonio Torralba. Places: A 10 million image database for scene recognition. IEEE transactions on pattern analysis and machine intelligence, 40(6):1452–1464, 2017. + +Jun-Yan Zhu, Taesung Park, Phillip Isola, and Alexei A Efros. Unpaired image-to-image translation using cycle-consistent adversarial networks. In Proceedings of the IEEE international conference on computer vision, pp. 2223–2232, 2017. + +# A ADDITIONAL BENCHMARK COMPARISONS AND ABLATIONS + +In this section, we include further experiments comparing CNC against additional related methods. +We also include additional ablations to study the importance of CNC’s presented design choices. + +# A.1 COMPARISON TO MINIMIZING THE ALIGNMENT LOSS DIRECTLY + +In Sec. 5.1 and Sec. 5.2, we empirically showed that CNC’s contrastive loss and hard positive and negative sampling lead to improved worst-group accuracy and greater representation alignment. We now study how CNC performs if instead of the contrastive loss, we train the Stage 2 model to minimize $\mathcal { L } _ { \mathrm { a l i g n } }$ directly. With this objective, we aim to minimize the Euclidean distance between samples in different inferred groups but the same class. We keep all other components of CNC consistent, and apply $\mathcal { L } _ { \mathrm { a l i g n } }$ to the anchor and positive samples in each contrastive batch. We report results on CMNIST∗, Waterbirds, and CelebA in Table A.1. + +Table A.1: Across benchmarks, CNC achieves higher worst-group and average accuracies with the default contrastive loss, compared to using the alignment loss explicitly as a training objective. + +
Method Accuracy (%)CMNIST*WaterbirdsCelebA
Worst-groupAverage Worst-groupAverage Worst-groupAverage
CNC (Lalign)67.3 (3.1)83.7 (1.1)83.3 (0.8)89.4 (0.2)84.6 (0.5)88.0 (0.3)
CNC (default contrastive)77.4 (3.0)90.9 (0.6)89.7 (0.2)90.8 (0.1)88.8 (0.9)89.9 (0.5)
+ +We find that CNC with the default contrastive loss outperforms CNC with the alignment loss. We reason that an advantage of the contrastive loss (and specifically the “hard” positive and negative samples), is that it encourages aligning samples with the same class label but different spurious features, and pushes apart hard negative samples with different class labels but similar spurious features. This provides additional signal for improving separation between the different classes, so the robust model only learns to rely on ground-truth-specific features for discriminating between datapoints. On the other hand, the $\mathcal { L } _ { \mathrm { a l i g n m e n t } }$ objective does not incorporate these hard negatives. + +# A.2 COMPARISON TO REPRESENTATION ALIGNMENT METHODS FOR DOMAIN GENERALIZATION AND ADAPTATION + +While our main results in Table 1 compare against methods designed to tackle the spurious correlations setting presented in Section 5.1, we now study how CNC fares against existing representation alignment methods proposed in the domain generalization (DG) and unsupervised domain adaptation (UDA) literature. At a high level, a popular idea in DG and UDA is to learn similar representations for datapoints with the same class but sampled from different domains, e.g. via adversarial training to prevent another model from classifying representations’ source domains correctly (Ganin et al., 2016), or minimizing representation differences via metrics such as maximum mean discrepancy (MMD) (Li et al., 2018). While DG and UDA carry distinct problem settings and assumptions from our spurious correlations setting (c.f. Appendix D.4), we aim to understand if existing representation alignment methods can train models robust to spurious correlations, and compare their performance with CNC. We first explain our protocol for evaluating these methods, and then discuss results. + +We carry out our evaluation with domain-adversarial neural networks (DANN) Ganin et al. (2016), a seminal UDA method that aims to learn aligned representations across two domains. To do so, DANN jointly trains a model to classify samples from a “source” domain while preventing a separate “domain classifier” module from correctly classifying the domain for datapoints sampled from both domains. For fair comparison, we use the same ResNet-50 backbone as in CNC, and make several adjustments to the typical DANN and UDA procedure: + +1. While UDA assumes that the data is organized into “source” and “target” domains, we do not have domain labels. We thus infer domains using the predictions of an initial ERM model as in CNC. +2. The notion of a domain may also be ambiguous with respect to the groups defined in Section 2. For example, domains may be defined by spurious attributes (e.g., for the Waterbirds dataset, we + +may consider the “water background” domain and the “land background” domain). Domains may alternatively be defined by whether samples carry dominant spurious correlations or not (e.g., the “majority group” domain and the “minority group” domain). We train and evaluate separate DANN models for both interpretations. We infer the former by the predicted class of the initial ERM model. We infer the latter by whether the initial ERM model is correct or not. + +3. Finally, UDA aims to train with a class-labeled “source” domain and an unlabeled “target” domain such that a model performs well on unseen samples from the specified “target” domain (Ganin et al., 2016). However, our benchmarks have class labels for all training points, and do not have a notion of “source” and “target” domains (we aim to obtain high worst-group accuracy, which could fall under any domain). We thus assume access to labels for all domains. During training, the goal for our DANN models is to correctly classify samples from both domains, while learning representations such that a jointly trained domain classifier module cannot determine the samples’ domains from their representations alone. At test-time, we evaluate the DANN model on the entire test set for each benchmark, and report the worst-group and average accuracies. + +Table A.2: CNC achieves higher worst-group and average accuracies on spuriously correlated benchmarks than DANN, a prior representation alignment method designed for domain adaptation + +
MethodWaterbirdsCelebA
Accuracy ( (%)Worst-groupAverage Worst-groupAverage
DANN (domains by spurious attribute)37.4 (3.8)87.6 (2.2)28.1 (3.1)94.6 (0.3)
DANN (domains by majority vs minority group)67.3 (0.8)83.6 (0.2)47.2 (3.1)88.7(1.8)
CNC89.7 (0.2)90.8 (0.1)88.8 (0.9)89.9 (0.5)
+ +In Table A.2, we report the worst-group and average accuracies of DANN on the Waterbirds and CelebA datasets across three seeds along with the CNC results. Our results suggest that the domain alignment in DANN is not sufficient to improve worst-group accuracy. We hypothesize this is due to adversarial training with the domain classifier aligning representations without regard to different classes within each domain. Due to the propensity of samples exhibiting spurious correlations, DANN models may thus still learn to rely on these correlations. + +# A.3 IMPORTANCE OF ERM-GUIDED CONTRASTIVE SAMPLING + +In this section we conduct additional ablations on the sampling procedure in CNC. Although CNC relies on an initial trained ERM model’s predictions, can we still improve worst-group accuracy without this step and with supervised contrastive learning alone, i.e. by sampling positives uniform randomly from all datapoints with the same label as the anchor? In Table 1, we showed that this approach (denoted SupCon∗) led to a drop in worst-group accuracy. Taking this question further, while we use the Stage 1 ERM model’s predictions to sample “hard” negatives with different groundtruth classes and the same ERM predictions as their anchors—such that to reduce the contrastive loss and learn dissimilar representations for anchors and negatives, the Stage 2 contrastive model must thus learn to ignore spurious features that the initial ERM model learns to depend on—how does CNC’s performance fare with alternative negative sampling procedures? Keeping the anchor and positive sampling consistent, we perform additional ablations where we either sample negatives only by having different classes as their anchors, or sample negatives only be having the same ERM model prediction as their anchors. We report these results in Table A.3 below. + +We find that the default CNC sampling procedure obtains highest worst-group accuracy and highest or near-highest average accuracy compared to alternative strategies across the CMNIST∗, Waterbirds, and CelebA datasets. The results suggests that inferring the spurious attributes (e.g. via an initial ERM model) is important for CNC, and that CNC benefits from using these predictions for sampling both negatives and positives. We reason this is because without this sampling, we can actually encourage the Stage 2 model to rely on spurious correlations. For example, if we just ensure that the anchor and negative samples have different classes, then the contrastive model may just rely on the different spurious features of the anchors and negatives to learn dissimilar representations. However, by ensuring that the anchors and negatives have similar spurious features (via the same trained ERM model prediction), the contrastive model is forced to rely on non-spurious features to learn dissimilar representations for the samples. The same logic applies for learning similar representations for anchor and positive samples. We suspect that choosing negatives from all samples with the same ERM prediction as their anchors performs better than the other ablations as it alone does not encourage learning spurious correlations: the model is asked to “pull apart” samples with the same spurious features, and so must ignore spurious similarities to recognize something different between anchors and negatives. However, this ablation does not ensure that anchor-negative pairs consist of different classes (which our full method does), so the model gets less signal to separate samples by class. + +Table A.3: Ablation on positive and negative sampling strategies in CNC. CNC achieves highest worst-group accuracy when using the Stage 1 ERM model’s predictions to sample “hard” positives and negatives (the default procedure). + +
MethodCMNIST*WaterbirdsCelebA
Accuracy (%)Worst-groupAverage Worst-groupAverageWorst-group Average
Negatives by different class66.4 (5.1)86.0 (1.6)82.2 (0.8)88.9 (0.3)79.2 (0.3)88.0 (0.1)
Negatives by same prediction70.0 (5.1)87.1 (1.1)85.7 (1.3)90.3 (0.2)81.1 (1.4)88.5 (0.3)
SupCon*0.0 (0.0)22.4 (1.2)71.0 (1.9)85.9 (0.8)62.2 (1.1)90.0 (0.1)
CNC (default)77.4 (3.0)90.9 (0.6)89.7 (0.2)90.8 (0.1)88.8 (0.9)89.9 (0.5)
+ +# A.4 ADDITIONAL DESIGN CHOICE ABLATIONS + +We first summarize CNC’s design choices and differences from standard supervised contrastive learning in Appendix A.4.1. We then empirically validate each component in Appendix A.4.2. + +# A.4.1 SUMMARY OF CNC DESIGN CHOICES AND PROPERTIES + +No projection network. As we wish to learn data representations that maximize the alignment between anchor and positive datapoints, we do not compute the contrastive loss with the outputs of an additional nonlinear projection network. This is inspired by the logic justifying a projection head in prior contrastive learning, e.g. SimCLR (Chen et al., 2020), where the head is included because the contrastive loss trains representations to be “invariant to data transformation” and may encourage removing information “such as the color or orientation of objects”. In our case, we view inferred datapoints with the same class but different spurious attributes as “transformations” of each other, and we hypothesize that removing these differences can help us improve worst-group performance. + +Two-sided contrastive sampling. To incorporate additional comparisons between datapoints that only differ in spurious attribute during training, we employ “two-sided” contrastive batch sampling. This lets us equally incorporate instances where the second contrastive model in CNC treats datapoints that the initial ERM model got incorrect and correct as anchors. + +Additional intrinsic hard positive/negative mining. Because the new model corrects for potentially learned spurious correlations by only comparing and contrasting datapoints that differ in class label or spurious attribute, but not both (as dictated by the initial ERM model’s outputs), the contrastive batches naturally carry “hard” positives and negatives. Thus, our approach provides a natural form of hard negative mining (in addition to the intrinsic hard positive / negative mining at the gradient level with InfoNCE-style contrastive losses (Chen et al., 2020; Khosla et al., 2020)) while avoiding class collisions, two nontrivial challenges in standard self-supervised contrastive learning (Robinson et al., 2021; Wu et al., 2021; Chuang et al., 2020). + +Joint training of encoder and classifier layers. CNC can train any standard classification model architecture; for any given neural network we just apply different optimization objectives to the encoder and classifier layers. We train both the encoder and classifier layers with a cross-entropy loss, and jointly train the encoder layer with a supervised contrastive loss. For the encoder layers, we balance the two objectives with a hyperparameter $\lambda$ (c.f. Eq. 7). + +# A.4.2 EMPIRICAL VALIDATION OF CNC COMPONENTS + +To validate the additional algorithmic components of CNC, we report how CNC performs on the Waterbirds dataset when modifying the individual design components. We use the same hyperparameters as in the main results, and report accuracies as the average over three training runs for the following ablations. Table A.4 summarizes that across these design ablations, default CNC as presented consistently outperforms these alternative implementations. + +Table A.4: Ablation over CNC algorithmic components on Waterbirds. Default choices achieve highest worst-group and average accuracy. + +
MethodCNC (Default)Projection HeadOne-sided ContrastingTrain + Finetune
WG Acc. (%)89.7 (0.2)82.4 (1.8)85.2 (3.6)84.0 (1.7)
Avg. Acc. (%)90.8 (0.1)88.7 (0.6)90.1 (1.6)87.7 (1.1)
+ +No projection head. We incorporate a nonlinear projection head as is typical in prior contrastive learning works (Chen et al., 2020), that maps the encoder output to lower-dimensional representations (from 2048 to 128 in our case). We then update the encoder layers and the projection head jointly by computing the contrastive loss on the projection head’s output, still passing the encoder layer’s direct outputs to the classifier to compute the cross-entropy loss. We note that using the projection head decreases worst-group accuracy substantially. We reason that as previously discussed, while using the projection head in prior work can allow the model to retain more information in its actual hidden layers (Chen et al., 2020), in our case to remove dependencies on spurious attributes we actually want to encourage learning invariant representations when we model the differences between anchor and positive datapoints as due to spurious attributes. + +Two-sided contrastive batches. Instead of “two-sided” contrasting where we allow both sampled anchors and positives to take on the anchor role, for each batch we only compute contrastive updates by comparing original positives and negatives with the original anchor. When keeping everything else the same, we find that just doing these one-sided comparisons also leads to a drop in performance for worst-group accuracy. This suggests that the increased number of comparisons and training setup where we swap the roles of anchors and positives of the two-sided batches introduces greater contrastive learning signal. + +# Additional intrinsic hard positive/negative mining. We discuss this ablation in Section A.3. + +Joint training of encoder and classifier layers. Instead of training the full model jointly, we first only train the encoder layers with the contrastive loss in CNC, before freezing these layers and finetuning the classifier layers with the cross-entropy loss. With this implementation, we also obtain noticeable drop in performance. While we leave further analysis for the joint cross-entropy and contrastive optimization for future work, one conjecture is that the cross-entropy loss may aid in learning separable representations while also training the full model to keep the average error small. From our theory, the contrastive loss can help bound the gap between worst-group and average error. Thus we try to minimize average error in the same parameter update. + +This also follows prior work, where updating the entire model and finetuning all model parameters instead of freezing the encoder layers leads to higher accuracy (Chen et al., 2020). However, we found that with an initial encoder-only training stage, if we did not freeze the trained layers the fine-tuning on a dataset with spurious correlations would “revert” the contrastive training, resulting in a large gap between worst-group and average error similar to ERM. + +We also ablate the balancing hyperparameter $\lambda$ of $\mathrm { C N C }$ on CMNIST∗. In Table A.5 we find that CNC consistently achieves high worst-group accuracy across a wide range of $\lambda \in [ 0 . 4 , 0 . 9 ]$ . For reference, the next best methods GEORGE and JTT obtain $7 6 . 4 \%$ and $7 4 . 5 \%$ worst-group accuracy. + +Table A.5: Ablation over CNC $\lambda$ parameter to balance cross-entropy and contrastive loss components on CMNIST∗. CNC obtains high performance across a range of $\lambda$ . + +
CNCX0.20.40.60.80.9
Robust Acc.70.4 (2.9)74.2 (2.6)75.3 (1.7)77.4 (2.5)75.8 (1.2)
Average Acc.89.0 (0.1)88.0 (0.7)88.3 (0.6)89.9 (0.4)88.4 (0.1)
+ +# B OMITTED PROOFS FROM SECTION 3.2 + +In this section, we prove that within any class, the gap between the worst-group error and the average error can be upper bounded by the alignment loss times the Lipschitz constant, plus another concentration error term. + +Proof of Theorem 3.1. Consider two arbitrary groups, denoted by $g _ { 1 } = ( y , a _ { 1 } )$ and $g _ { 2 } = ( y , a _ { 2 } )$ , whose class labels are both $y \in \mathcal { V }$ , whose spurious attributes are $a _ { 1 } \in { \mathcal { A } }$ and $a _ { 2 } \in { \mathcal { A } }$ such that $a _ { 1 } \neq a _ { 2 }$ . Let $G _ { 1 }$ and $G _ { 2 }$ be the subset of training data that belong to groups $g _ { 1 }$ and $g _ { 2 }$ , respectively. We note that both $G _ { 1 }$ and $G _ { 2 }$ are non-empty since we have assumed that (in Section 2) there is at least one sample from each group in the training data set. Let $n _ { g _ { 1 } } = | G _ { 1 } |$ and $n _ { g _ { 2 } } = | G _ { 2 } |$ be the size of these two groups, respectively. Recall that $f _ { \mathrm { e n c } }$ denotes the mapping of the encoder layers of the full neural network model $f _ { \theta }$ . Since the classification layer $f _ { \mathrm { c l s } }$ is a linear layer, we have used $W$ to denote the weight matrix of this layer. Our definition of the cross-group alignment loss in equation (5), denoted as $\hat { \mathcal { L } } _ { \mathrm { a l i g n } } ( f _ { \theta } ; y )$ , implies that for $g _ { 1 }$ and $g _ { 2 }$ , + +$$ +\frac { 1 } { n _ { g _ { 1 } } } \frac { 1 } { n _ { g _ { 2 } } } \sum _ { \substack { ( x , y , a _ { 1 } ) \in G _ { 1 } ( x ^ { \prime } , y , a _ { 2 } ) \in G _ { 2 } } } \Vert f _ { \mathrm { e n c } } ( x ) - f _ { \mathrm { e n c } } ( x ^ { \prime } ) \Vert _ { 2 } \leq \hat { \mathcal { L } } _ { \mathrm { a l i g n } } ( f _ { \theta } ; y ) . +$$ + +Next, let $\begin{array} { r } { \mathbb { E } _ { ( x , y , a _ { 1 } ) \sim \mathcal { P } _ { g _ { 1 } } } \left[ \mathcal { L } _ { \mathrm { a v g } } ( W f _ { \mathrm { e n c } } ( x ) , y ) \right] } \end{array}$ be the average loss conditioning on a data point being sampled from group $g _ { 1 }$ (and similarly for group $g _ { 2 }$ ). Let $\Delta ( g _ { 1 } , g _ { 2 } )$ be the difference between the population average losses: + +$$ +\Delta ( g _ { 1 } , g _ { 2 } ) = | \underset { ( x , y , a _ { 1 } ) \sim \mathcal { P } _ { g _ { 1 } } } { \mathbb { E } } [ \mathcal { L } _ { \mathrm { a v g } } ( W f _ { \mathrm { e n c } } ( x ) , y ] - \underset { ( x , y , a _ { 2 } ) \sim \mathcal { P } _ { g _ { 2 } } } { \mathbb { E } } [ \mathcal { L } _ { \mathrm { a v g } } ( W f _ { \mathrm { e n c } } ( x ) , y ) ] | . +$$ + +Recall that $\mathcal { G } _ { y } \subseteq \mathcal { G }$ is the set of groups that have class label $y$ . Since the loss $\ell ( \cdot )$ is bounded above by some fixed constant $C _ { 2 }$ according to our assumption, and is at least zero, by the Hoeffding’s inequality, the following result holds with probability at least $1 - \delta$ , for all $| \mathcal { G } _ { y } |$ groups $g \in \mathcal { G } _ { y }$ , + +$$ +\left. \operatorname { \underset { \left( x , y , a \right) \sim \mathcal { P } _ { g } } { \mathbb { E } } } \left[ \mathcal { L } _ { \mathrm { a v g } } ( W f _ { \mathrm { e n c } } ( x ) , y ) \right] - \frac { 1 } { n _ { g } } \sum _ { \substack { ( x , y ) \in ( X , Y ) } } \ell ( W f _ { \mathrm { e n c } } ( x ) , y ) \right. \leq C _ { 2 } \sqrt { \frac { 2 \log \left( | \mathcal { G } _ { y } | / \delta \right) } { n _ { g } } } . +$$ + +Thus, with probability at least $1 - \delta$ , the following holds for any $g _ { 1 }$ and $g _ { 2 }$ in class $y$ (but having different spurious attributes) + +$$ +\begin{array} { r l r } { { \Delta ( g _ { 1 } , g _ { 2 } ) \le | \frac { 1 } { n _ { g _ { 1 } } } \sum _ { ( x , y , a _ { 1 } ) \in G _ { 1 } } \mathcal { L } _ { \mathrm { a v g } } ( W f _ { \mathrm { e n c } } ( x ) , y ) - \frac { 1 } { n _ { g _ { 2 } } } \sum _ { ( x ^ { \prime } , y , a _ { 2 } ) \in G _ { 2 } } \mathcal { L } _ { \mathrm { a v g } } ( W f _ { \mathrm { e n c } } ( x ^ { \prime } ) , y ) | } } \\ & { } & { + C _ { 2 } ( \sqrt { \frac { 2 \log ( | \mathcal { G } _ { y } | / \delta ) } { n _ { g _ { 1 } } } } + \sqrt { \frac { 2 \log ( | \mathcal { G } _ { y } | / \delta ) } { n _ { g _ { 2 } } } } ) . } \end{array} +$$ + +Next, we focus on the RHS of equation (10). First, equation (10) is also equal to the following: + +$$ +\frac { 1 } { n _ { g _ { 1 } } } \frac { 1 } { n _ { g _ { 2 } } } \sum _ { ( x , y , a _ { 1 } ) \in G _ { 1 } } \sum _ { ( x ^ { \prime } , y , a _ { 2 } ) \in G _ { 2 } } \ell ( W f _ { \mathrm { e n c } } ( x ) , y ) ) - \frac { 1 } { n _ { g _ { 1 } } } \frac { 1 } { n _ { g _ { 2 } } } \sum _ { ( x , y , a _ { 1 } ) \in G _ { 1 } } \sum _ { ( x ^ { \prime } , y , a _ { 2 } ) \in G _ { 2 } } \ell ( W f _ { \mathrm { e n c } } ( x ^ { \prime } ) , y ) ) \bigg | +$$ + +Since we have also assumed that the loss function $\ell ( x , y )$ is $C _ { 1 }$ -Lipschitz in $x ^ { 2 }$ , the above is at most: + +$$ +\begin{array} { r l r } { { | \frac { 1 } { n _ { g _ { 1 } } n _ { g _ { 2 } } } \sum _ { ( x , y , a _ { 1 } ) \in G _ { 1 } } \sum _ { ( x ^ { \prime } , y , a _ { 2 } ) \in G _ { 2 } } | \ell ( W f _ { \mathrm { e n c } } ( x ) , y ) - \ell ( W f _ { \mathrm { e n c } } ( x ^ { \prime } ) , y ) | | } } \\ & { } & { \leq \frac { 1 } { n _ { g _ { 1 } } n _ { g _ { 2 } } } \sum _ { ( x , y , a _ { 1 } ) \in G _ { 1 } } \sum _ { ( x ^ { \prime } , y , a _ { 2 } ) \in G _ { 2 } } C _ { 1 } \cdot \| W f _ { \mathrm { e n c } } ( x ) - W f _ { \mathrm { e n c } } ( x ^ { \prime } ) \| _ { 2 } \quad \mathrm { ( s i n c e ~ } y \mathrm { ~ i s ~ t h e ~ s a m e ~ f o r ~ } x , x ^ { \prime } ) } \\ & { } & { \leq \frac { B } { n _ { g _ { 1 } } n _ { g _ { 2 } } } \sum _ { ( x , y , a _ { 1 } ) \in G _ { 1 } } \sum _ { ( x ^ { \prime } , y , a _ { 2 } ) \in G _ { 2 } } C _ { 1 } \cdot \| f _ { \mathrm { e n c } } ( x ) - f _ { \mathrm { e n c } } ( x ^ { \prime } ) \| _ { 2 } \quad \mathrm { ( b e c a u s e ~ } \| W \| _ { 2 } \leq B \mathrm { ~ a s ~ a s s u m e d ) } } \\ & { } & { \leq B \cdot C _ { 1 } \cdot \hat { C } _ { \mathrm { a l a g n } } ( f _ { \delta } ; y ) . } \end{array} +$$ + +2In other words, we assume that $| \ell ( z , y ) - \ell ( z ^ { \prime } , y ) | \leq C _ { 1 } \cdot \| z - z ^ { \prime } \| _ { 2 }$ , for any $z , z ^ { \prime }$ and $y$ . + +Thus, we have shown that for any $g _ { 1 }$ and $g _ { 2 }$ within class $y$ , + +$$ +\begin{array} { r l } & { \Delta ( g _ { 1 } , g _ { 2 } ) \leq B \cdot \hat { \mathcal { L } } _ { \mathrm { a l i g n } } ( f _ { \theta } ; y ) + \left( \sqrt { \frac { 2 \log ( | \mathcal { G } _ { y } | / \delta ) } { n _ { g _ { 1 } } } } + \sqrt { \frac { 2 \log ( | \mathcal { G } _ { y } | / \delta ) } { n _ { g _ { 2 } } } } \right) } \\ & { \qquad \leq B \cdot C _ { 1 } \cdot \hat { \mathcal { L } } _ { \mathrm { a l i g n } } ( f _ { \theta } ; y ) + \displaystyle \operatorname* { m a x } _ { g \in \mathcal { G } _ { y } } C _ { 2 } \cdot \sqrt { \frac { 8 \log ( | \mathcal { G } _ { y } | / \delta ) } { n _ { g } } } . } \end{array} +$$ + +Finally, we use the above result to bound the gap between the worst-group loss and the average loss. For every group $g \in { \mathcal { G } }$ , let $p _ { g }$ denote the prior probability of observing a sample from $\mathcal { P }$ in this group. Let $\begin{array} { r } { q _ { y } = \sum _ { g ^ { \prime } \in \mathcal { G } _ { y } } p _ { g ^ { \prime } } } \end{array}$ . Let $\bar { h ( g ) }$ be a short hand notation for + +$$ +h ( g ) = \operatorname * { \mathbb { E } } _ { ( x , y , a ) \sim \mathcal { P } _ { g } } \left[ \mathcal { L } _ { \mathrm { a v g } } ( W f _ { \mathrm { e n c } } ( x ) , y ) \right] . +$$ + +The average loss among the groups with class label y is Lavg(fθ; y) = Pg∈Gy pgqy h . The worstgroup loss among the groups with class label $y$ is $\mathcal { L } _ { \mathrm { w g } } ( f _ { \theta } ; y ) = \mathrm { m a x } _ { g \in \mathcal { G } _ { y } } h ( \bar { g } )$ . Let $g ^ { \star }$ be a group that incurs the highest loss among groups in $\mathcal { G } _ { y }$ . We have $\mathcal { L } _ { \mathrm { w g } } ( f _ { \theta } ; y ) - \mathcal { L } _ { \mathrm { a v g } } ( f _ { \theta } ; y )$ is equal to + +$$ +\begin{array} { r l } & { \displaystyle h ( g ^ { \star } ) - \sum _ { g \in { \mathcal { G } } _ { y } } \frac { p _ { g } } { q _ { y } } h ( g ) = \sum _ { g \in { \mathcal { G } } _ { y } } \frac { p _ { g } } { q _ { y } } ( h ( g ^ { \star } ) - h ( g ) ) } \\ & { \qquad \le \displaystyle \sum _ { g \in { \mathcal { G } } _ { y } } \frac { p _ { g } } { q _ { y } } \Delta ( g ^ { \star } , g ) } \\ & { \qquad \le B \cdot C _ { 1 } \cdot \hat { \mathcal { L } } _ { \mathrm { a l i g n } } ( f _ { \theta } ; y ) + \displaystyle \operatorname* { m a x } _ { g \in { \mathcal { G } } _ { y } } C _ { 2 } \cdot \sqrt { \frac { 8 \log ( | \mathcal { G } | / \delta ) } { n _ { g } } } . } \end{array} +$$ + +The last step uses equation (11) on $\Delta ( g ^ { \star } , g )$ and the fact that $\begin{array} { r } { q _ { y } = \sum _ { g ^ { \prime } \in \mathcal { G } _ { y } } p _ { g ^ { \prime } } . } \end{array}$ . Thus, we have shown that the gap between the worst-group loss and the average loss among the groups with the same class label is bounded by the above equation. The proof is now complete. □ + +The astute reader will note that Theorem 3.1 focuses on comparing groups within the same class $y$ , for any $y \in \mathcal { V }$ . A natural follow-up question is what happens when comparing across groups with different labels. Let $\begin{array} { r } { \mathcal { L } _ { \mathrm { w g } } ( f _ { \theta } ) = \operatorname* { m a x } _ { y \in \mathcal { V } } \mathcal { L } _ { \mathrm { w g } } ( f _ { \theta } ; y ) } \end{array}$ be the worst-group loss across all the labels. Recall that ${ \mathcal { L } } _ { \mathrm { a v g } } ( f _ { \theta } )$ is the average loss for the entire population of data. We generalize Theorem 3.1 to this setting in the following result. + +Corollary B.1 (Extension of Theorem 3.1 to compare across different classes). In the setting of Theorem 3.1, let $\begin{array} { r } { q _ { y } = \sum _ { g \in \mathcal { G } _ { y } } p _ { g } } \end{array}$ be the prior probability of observing a sample drawn from $\mathcal { P }$ with label $y _ { ; }$ , for any $y \in \mathcal { V }$ . We have that with probability at least $1 - \delta$ , the following holds: + +$$ +\mathcal { L } _ { w g } ( f _ { \theta } ) \leq \Big ( \operatorname* { m i n } _ { y \in \mathcal { Y } } q _ { y } \Big ) ^ { - 1 } \mathcal { L } _ { a v g } ( f _ { \theta } ) + B \cdot C _ { 1 } \cdot \operatorname* { m a x } _ { y \in \mathcal { Y } } \hat { \mathcal { L } } _ { a l i g n } ( f _ { \theta } ; y ) + \operatorname* { m a x } _ { g \in \mathcal { G } } C _ { 2 } \cdot \sqrt { \frac { 8 \log ( | \mathcal { G } | / \delta ) } { n _ { g } } } . +$$ + +Proof. We generalize the argument in the previous result to compare across different labels. The worst-group loss across different labels is + +$$ +\begin{array} { r l r } & { \underset { y \in \mathcal { Y } } { \operatorname* { m a x } } \underset { y \in \mathcal { G } _ { y } } { \operatorname* { m a x } } h ( g ) } & \\ & { \leq \underset { y \in \mathcal { Y } } { \operatorname* { m a x } } \left( \underset { g \in \mathcal { G } _ { y } } { \sum } \frac { p _ { g } } { q _ { y } } h ( g ) + B \cdot C _ { 1 } \hat { \mathcal { L } } _ { \mathrm { a l i g n } } ( f _ { \theta } ; y ) + \underset { g \in \mathcal { G } _ { y } } { \operatorname* { m a x } } C _ { 2 } \sqrt { \frac { 8 \log \left( \left| \mathcal { G } _ { y } \right| / \delta \right) } { n _ { g } } } \right) } & { \mathrm { ( b e c a u s e ~ o f ~ e q u a t i o n ~ } } \\ & { \leq \frac { 1 } { \operatorname* { m i n } _ { y \in \mathcal { Y } } q _ { y } } \underset { g \in \mathcal { G } _ { y } } { \sum } p _ { g } h ( g ) + B \cdot C _ { 1 } \underset { y \in \mathcal { Y } } { \operatorname* { m a x } } \hat { \mathcal { L } } _ { \mathrm { a l i g n } } ( f _ { \theta } ; y ) + \underset { g \in \mathcal { G } } { \operatorname* { m a x } } C _ { 2 } \sqrt { \frac { 8 \log \left( \left| \mathcal { G } \right| / \delta \right) } { n _ { g } } } . } & \end{array} +$$ + +Since $\begin{array} { r } { \sum _ { g \in \mathcal { G } } p _ { g } h ( g ) = \mathcal { L } _ { \mathrm { a v g } } ( f _ { \theta } ) } \end{array}$ , we thus conclude that + +$$ +{ \mathcal { L } } _ { \mathrm { w g } } ( f _ { \theta } ) \leq { \Big ( } \operatorname* { m i n } _ { y \in { \mathcal { Y } } } q _ { y } { \Big ) } ^ { - 1 } { \mathcal { L } } _ { \mathrm { a v g } } ( f _ { \theta } ) + B \cdot C _ { 1 } \operatorname* { m a x } _ { y \in { \mathcal { Y } } } { \hat { \mathcal { L } } } _ { \mathrm { a l i g n } } ( f _ { \theta } ; y ) + \operatorname* { m a x } _ { g \in { \mathcal { G } } } C _ { 2 } { \sqrt { \frac { 8 \log ( | { \mathcal { G } } | / \delta ) } { n _ { g } } } } . +$$ + +The proof is now complete. + +An example showing that Corollary B.1 is tight. We describe a simple example in which the factor $\begin{array} { r } { \left( \operatorname* { m i n } _ { y \in \mathcal { V } } q _ { y } \right) ^ { - 1 } } \end{array}$ in equation (15) is tight (asymptotically). Suppose there are $k$ perfectly balanced classes so that $q _ { y } = 1 / k$ , for every $y \in \mathcal { V }$ . There is one data point from each class, with loss equal to 0 for all except one of them. The worst-group loss is 1 whereas the average loss is $1 / k$ . Thus, there is a factor of $k$ between the worst-group loss and the average loss. For equation (15), the factor + +$$ +{ \Big ( } \operatorname* { m i n } _ { y \in \mathcal { V } } q _ { y } { \Big ) } ^ { - 1 } = k , +$$ + +since $q _ { y } = 1 / k$ for every $y \in \mathcal { V }$ in this example. Thus, this factor matches the (multiplicative) factor between the worst-group loss and the average loss in this example. + +# C CONTRASTIVE ALGORITHM DESIGN DETAILS + +In this section, we provide further details on the training setup and contrastive batch sampling, pseudocode, and additional properties related to CNC’s implementation. + +# C.1 TRAINING SETUP + +In Fig. 8, we illustrate the two training stages of Correct-N-Contrast described in Sec. 4. In Stage 1, we first train an ERM model with a cross-entropy loss. For consistency with Stage 2, we depict the output as a composition of the encoder and linear classifier layers. Then in Stage 2, we train a new model with the same architecture using contrastive batches sampled with the Stage 1 ERM model and a supervised contrastive loss (3) (which we compute after the depicted representations are first normalized) to update the encoder layers. Note that unlike prior work in contrastive learning (Chen et al., 2020; Khosla et al., 2020), as we have the class labels of the anchors, positives, and negatives, we also continue forward-passing the unnormalized representations (encoder layer outputs) and compute a cross-entropy loss to update the classifier layers while jointly training the encoder. + +Loss Function Forward Pass Backward Pass + +![](images/69f069d1a3a84189fec214d682e2c146df13e53230710bc476b320361977febf.jpg) +Stage 2: Correct-N-Contrast + +![](images/9733024dd918f6a521d78a0e955687278e481766e55d7d71fa9cfc24f1fa702c.jpg) +Stage 1: ERM training +Figure 8: The two stages of Correct-N-Contrast. In Stage 1, we train a model with standard ERM and a cross-entropy loss. Then in Stage 2, we train a new model with the same architecture, but specifically learn spurious-attribute-invariant representations with a contrastive loss (3) and batches of anchors, positives, and negatives sampled with the ERM model’s predictions. We also update the full model jointly with a cross-entropy loss on the classifier layer output and the input class labels. Dimensions for ResNet-50 and Waterbirds. + +We also note that unlike prior work, we wish to learn invariances between anchors and positives that maximally reduce the presence of features not needed for classification. We thus do not pass the representations through an additional projection network (Chen et al., 2020). Instead, we use Eq. 3 to compute the supervised contrastive loss directly on the encoder outputs $z = f _ { \mathrm { e n c } } ( x )$ . In Appendix A.4.2, we studied ablations with both design choices. + +![](images/554f8fb832d5036a2c742983da86f27507b05e67943e4cd056c4bcf83f70643c.jpg) +Figure 9: Illustration of two-sided contrastive batch sampling with Colored MNIST as an example. From a single batch (a), we can train a contrastive model with two anchor-positive-negative pairings (b). Aside from increasing the number of “hard negatives” for each anchor-positive pair, this intuitively “pushes” together anchors and positives from two different directions for greater class separation. + +# C.2 TWO-SIDED CONTRASTIVE BATCH IMPLEMENTATION + +We provide more details on our default contrastive batch sampling approach described in Sec. 4. To recall, for additional contrastive signal per batch, we can double the pairwise comparisons in a training batch by switching the anchor and positive roles. This is similar to the NT-Xent loss in prior contrastive learning work (Chen et al., 2020). We switch the role of the anchor and first positive sampled in a contrastive batch, and sample additional positives and negatives using the same guidelines but adjusting for the “new” anchor. We denote this as “two-sided” sampling in contrast with the “one-sided” comparisons we get with just the original anchor, positives, and negatives. + +Implementing this sampling procedure in practice is simple. First, recall our initial setup with trained ERM model $f _ { \hat { \theta } }$ , its predictions $\{ \hat { y } _ { i } \} _ { i = 1 } ^ { n }$ on training data $\{ ( x _ { i } , y _ { i } ) \} _ { i = 1 } ^ { n }$ (where $\hat { y } _ { i } = f _ { \hat { \theta } } ( x _ { i } ) )$ , and number of positives and negatives to sample $M$ and $N$ . We then sample batches with Algorithm 2. + +Becausewe infer $\{ x _ { i } \} _ { i = 1 } ^ { M }$ al anchors are then datapoints that the ERM model gas samples from the majority group. Similarly the $M$ correct, upositives $\lbrace x _ { m } ^ { + } \rbrace _ { m = 1 } ^ { M }$ eurisand $N$ negatives $\{ x _ { n } ^ { - } \} _ { n = 1 } ^ { N }$ that it gets incorrect are inferred to belong to minority groups. + +For one batch, we then compute the full contrastive loss with + +$$ +\begin{array} { r } { \hat { \mathcal { L } } _ { \mathrm { c o n } } ^ { \mathrm { s u p } } ( f _ { \mathrm { e n c } } ) = \hat { \mathcal L } _ { \mathrm { c o n } } ^ { \mathrm { s u p } } \left( x _ { 1 } , \{ x _ { m } ^ { + } \} _ { m = 1 } ^ { M } , \{ x _ { n } ^ { - } \} _ { n = 1 } ^ { N } ; f _ { \mathrm { e n c } } \right) + \hat { \mathcal L } _ { \mathrm { c o n } } ^ { \mathrm { s u p } } \left( x _ { 1 } ^ { + } , \{ x _ { i } \} _ { i = 1 } ^ { M } , \{ x _ { n } ^ { \prime - } \} _ { n = 1 } ^ { N } ; f _ { \mathrm { e n c } } \right) } \end{array} +$$ + +where $\hat { \mathcal { L } } _ { \mathrm { c o n } } ^ { \mathrm { s u p } } \left( x _ { 1 } , \{ x _ { m } ^ { + } \} _ { m = 1 } ^ { M } , \{ x _ { n } ^ { - } \} _ { n = 1 } ^ { N } ; f _ { \mathrm { e n c } } \right)$ is given by: + +$$ +- \frac { 1 } { M } \sum _ { m = 1 } ^ { M } \log \frac { \exp ( z _ { 1 } ^ { \top } z _ { m } ^ { + } / \tau ) } { \sum _ { m = 1 } ^ { M } \exp ( z _ { 1 } ^ { \top } z _ { m } ^ { + } / \tau ) + \sum _ { n = 1 } ^ { N } \exp ( z _ { 1 } ^ { \top } z _ { n } ^ { + } / \tau ) } +$$ + +Algorithm 2 Sampling two-sided contrastive batches + +Require: Number of positives $M$ and number of negatives $N$ to sample for each batch. + +1: Initialize set of contrastive batches $B = \{ \}$ +2: for each $x _ { i } \in \{ x _ { i } \in X : \hat { y } _ { i } = y _ { i } \}$ do +3: Sample $M - 1$ additional “anchors” to obtain $\{ x _ { i } \} _ { i = 1 } ^ { M }$ from $\{ x _ { i } \in X : { \hat { y } } _ { i } = y _ { i } \}$ +4: Sample $M$ positives $\lbrace x _ { m } ^ { + } \rbrace _ { m = 1 } ^ { M }$ from $\{ x _ { m } ^ { - } \in X : \hat { y } _ { m } ^ { - } = \hat { y } _ { i } , \ y _ { m } ^ { - } \neq y _ { i } \}$ +5: Sample $N$ negatives $\{ x _ { n } ^ { - } \} _ { n = 1 } ^ { N }$ from $\{ x _ { n } ^ { - } \in X : \hat { y } _ { n } ^ { - } = \hat { y } _ { i } , \ y _ { n } ^ { - } \neq y _ { i } \}$ +6: Sample $N$ negatives $\{ x _ { n } ^ { \prime - } \} _ { n = 1 } ^ { N }$ from $\{ x _ { n } ^ { \prime - } \in X : \hat { y } _ { n } ^ { \prime - } = \hat { y } _ { 1 } ^ { + } , y _ { n } ^ { \prime - } \neq y _ { 1 } ^ { + } \}$ +7: Update contrastive batch set: $B B \cup ( \{ x _ { i } \} _ { i = 1 } ^ { M } , \{ x _ { m } ^ { + } \} _ { m = 1 } ^ { M } , \{ x _ { n } ^ { - } \} _ { n = 1 } ^ { N } , \{ x _ { n } ^ { \prime - } \} _ { n = 1 } ^ { N } )$ + +and again let $z$ be the normalized output $f _ { \mathrm { e n c } } ( x )$ for corresponding $x$ . We compute the cross-entropy component of the full loss for each $x$ in the two-sided batch with its corresponding label $y$ . + +# D FURTHER RELATED WORK DISCUSSION + +We provide additional discussion of related work and connections to our work below. + +# D.1 IMPROVING ROBUSTNESS TO SPURIOUS CORRELATIONS + +Our core objective is to improve model robustness to group or subpopulation distribution shifts that arise from the presence of spurious correlations, specifically for classification tasks. Because these learnable correlations hold for some but not all samples in a dataset, standard training with ERM may result in highly variable performance: a model that classifies datapoints based on spurious correlations does well for some subsets or “groups” of the data but not others. To improve model robustness and avoid learning spurious correlations, prior work introduces the goal to maximize worst-group accuracy (Sagawa et al., 2019). Related works broadly fall under two categories: + +Improving robustness with group information. If information such as spurious attribute labels is provided, one can divide the data into explicit groups as defined in Sec. 2, and then train to directly minimize the worst group-level error among these groups. This is done in group DRO (GDRO) (Sagawa et al., 2019), where the authors propose an online training algorithm that focuses training updates over datapoints from higher-loss groups. Goel et al. (2020) also adopt this approach with their method CycleGAN Augmented Model Patching (CAMEL). However, similar to our motivation, they argue that a stronger modeling goal should be placed on preventing a model from learning group-specific features. Their approach involves first training a CycleCAN (Zhu et al., 2017) to learn the data transformations from datapoints in one group to another that share the same class label. They then apply these transformations as data augmentations to different samples, intuitively generating new versions of the original samples that take on group-specific features. Finally they train a new model with a consistency regularization objective to learn invariant features between transformed samples and their sources. Unlike their consistency loss, we accomplish a similar objective to learn group-invariant features with contrastive learning. Our first training stage is also less expensive. Instead of training a CycleGAN and then using it to augment datapoints, we train a relatively simple standard ERM classification model, sometimes with only a few number of epochs, and use its predictions to identify pairs of datapoints to serve a similar purpose. Finally, unlike both CAMEL and GDRO, we do not require spurious attribute or group labels for each training datapoints. We can then apply CNC in less restrictive settings where such information is not known. + +Related to GDRO are methods that aim to optimize a "Pareto-fair" objective, more general than simply the worst-case group performance. Notable examples are the works of Balashankar et al. (2019) and Martinez et al. (2020). However, these approaches similarly do not directly optimize for good representation alignment (unlike our work). + +Improving robustness without training group information. More similar to our approach are methods that do not assume group information at training time, and only require validation set spurious attribute labels for fine-tuning. As validation sets are typically much smaller in size than training sets, an advantage of CNC and comparable methods is that we can improve the accessibility of robust training methods to a wider set of problems. One popular line of work is distributionally robust optimization (DRO), which trains models to minimize the worst loss within a ball centered around the observed distribution (Ben-Tal et al., 2013; Wiesemann et al., 2014; Duchi & Namkoong, 2019; Levy et al., 2020; Curi et al., 2020; Oren et al., 2019). This includes the CVaR DRO (Levy et al., 2020) method we evaluate against. However, prior work has shown that these approaches may be too pessimistic, optimizing not just for worst-group accuracy but worst possible accuracy within the distribution balls (Sagawa et al., 2019), or too undirected, optimizing for too many subpopulations, e.g. by first upweighting minority points but then upweighting majority points in later stages of training (Liu et al., 2021). Pezeshki et al. (2020) instead suggest that gradient starvation (GS), where neural networks only learn to capture statistically dominant features in the data (Combes et al., 2018), is the main culprit behind learning spurious correlations, and introduce a “spectral decoupling” regularizer to alleviate GS. However this does not directly prevent models from learning dependencies on spurious attributes. Similar to CAMEL, Taghanaki et al. (2021) propose Contrastive Input Morphing (CIM), an image dataset-specific method that aims to learn input feature transformations that remove the effects of spurious or task-irrelevant attributes. They do so without group labels, training a transformation network with a triplet loss to transform input images such that a given transformed image’s structural similarity metric (based on luminance, contrast, and structure (Wang et al., 2003)) is more similar to a “positive” image from the same class than a “negative” image from a different class. They then train a classifier on top of these representations. Instead of pixel-level similarity metrics, CNC enforces similarity in a neural network’s hidden-layer representations, allowing CNC to apply to non-image modalities. Additionally, we sample positives and negatives not just based on class label, but also the learned spurious correlations of an ERM model (via its trained predictions). We hypothesize that our sampling scheme, which intuitively provides "harder" positive and negative examples, allows CNC to more strongly overcome spurious correlations. + +Most similar to our approach are methods that first train an initial ERM model with the class labels as a way to identify data points belonging to minority groups, and subsequently train an additional model with greater emphasis on the estimated minority groups. Sohoni et al. (2020) demonstrate that even when only trained on the class labels, neural networks learn feature representations that can be clustered into groups of data exhibiting different spurious attributes. They use the resulting cluster labels as estimated group labels before running GDRO on these estimated groups. Meanwhile, Nam et al. (2020) train a pair of models, where one model minimizes a generalized cross-entropy loss (Zhang & Sabuncu, 2018), such that the datapoints this model classifies incorrectly largely correspond to those in the minority group. They then train the other model on the same data but upweight the minority-group-estimated points. While they interweave training of the biased and robust model, Liu et al. (2021) instead train one model first with a shortened training time (but the standard cross-entropy objective), and show that then upsampling the incorrect data points and training another model with ERM can yield higher worst-group accuracy. Creager et al. (2021) first train an ERM model, and then softly assign the training data into groups under which the initial trained ERM model would maximally violate the invariant risk minimization (IRM) objective. In particular, the IRM objective is maximally satisfied if a model’s optimal classifier is the same across groups (Arjovsky et al., 2019), and EIIL groups are inferred such that the initial ERM model’s representations exhibit maximum variance within each group. Finally, Nagarajan et al. (2020) provides a theoretical understanding of how ERM picks up spurious features under data set imbalance. They consider a setting involve a single spurious feature that is correlated with the class label and analyze the max-margin classifier in the presence of this spurious feature. + +In our work, we demonstrate that the ERM model’s predictions can be leveraged to not only estimate groups and train a new model with supervised learning but with different weightings. Instead, we can specifically identify pairs of points that a contrastive model can then learn invariant features between. Our core contribution comes from rethinking the objective with a contrastive loss that more directly reduces the model’s ability to learning spurious correlations. + +# D.2 CONTRASTIVE LEARNING + +Our method also uses contrastive learning, a simple yet powerful framework for both self-supervised (Chen et al., 2020; Oord et al., 2018; Tian et al., 2019; Song & Ermon, 2020; Sermanet et al., 2018; Hassani & Khasahmadi, 2020; Robinson et al., 2021) and supervised (Khosla et al., 2020; Gunel et al., 2021) representation learning. The core idea is to learn data representations that maximize the similarity between a given input “anchor” and distinct different views of the same input (“positives”). Frequently this also involves contrasting positives with “negative” data samples without any assumed relation to the anchor (Bachman et al., 2019). Core components then include some way to source multiple views, e.g. with data transformations (Chen et al., 2020), and training objectives similar to noise contrastive estimation (Gutmann & Hyvärinen, 2010; Mnih & Kavukcuoglu, 2013). + +An important component of contrastive learning is the method by which appropriate positives and negatives are gathered. For sampling positives, Chen et al. (2020) show that certain data augmentations (e.g. crops and cutouts) may be more beneficial than others (e.g. Gaussian noise and Sobel filtering) when generating anchors and positives for unsupervised contrastive learning. von Kügelgen et al. (2021) theoretically study how data augmentations help contrastive models learn core content attributes which are invariant to different observed “style changes”. They propose a latent variable model for self-supervised learning. Tian et al. (2020) further study what makes good views for contrastive learning. They propose an “InfoMin principle”, where anchors and positives should share the least information necessary for the contrastive model to do well on the downstream task. For sampling negatives, Robinson et al. (2021) show that contrastive learning also benefits from using “hard” negatives, which (1) are actually a different class from the anchor (which they approximate in the unsupervised setting) and (2) embed closest to the anchor under the encoder’s current data representation. Both of these approaches capture the principle that if positives are always too similar to the anchor and negatives are always too different, then contrastive learning may be inefficient at learning generalizable representations of the underlying classes. + +In our work, we incorporate this principle by sampling data points with the same class label but different ERM predictions–presumably because of spurious attribute differences–as anchor and positive views, while sampling negatives from data points with different class labels but the same ERM prediction as the anchor. The anchors and positives are different enough that a trained ERM model predicted them differently, while the anchors and negatives are similar enough that the trained ERM model predicted them the same. Contrasting the above then allows us to exploit both “hard” positive and negative criteria for our downstream classification task. In Appendix A.3, we show that removing this ERM-guided sampling (i.e. only sampling positives and negatives based on class information), as well as trying different negative sampling procedures, leads to substantially lower worst-group accuracy with CNC. + +One limitation of our current theoretical analysis regarding the alignment loss (cf. Section 3.2) is that we require knowing the group labels to compute the RHS of equation (6) (in particular, the alignment loss). An interesting question for future work is to provide a better theoretical understanding of the alignment induced by CNC in the context of spurious correlations. + +# D.3 LEARNING INVARIANT REPRESENTATIONS + +Our work is also similar in motivation to Invariant Risk Minimization (IRM) (Arjovsky et al., 2019), Predictive Group Invariance (PGI) (Ahmed et al., 2021), and other related works in domain-invariant learning (Krueger et al., 2020; Parascandolo et al., 2020; Ahuja et al., 2020; Creager et al., 2021). These methods aim to train models that learn a single invariant representation that is consistently optimal (e.g. with respect to classifying data) across different domains or environments. These environments can be thought of as data groups, and while traditionally methods such as IRM require that environment labels are known, recent approaches such as Environment Inference for Invariant Learning (EIIL) (Creager et al., 2021) and Predictive Group Invariance (PGI) (Ahmed et al., 2021) similarly aim to infer environments with an initial ERM model. In EIIL, they next train a more robust model with an invariant learning objective, similarly selecting models based on the worst-group error on the validation set. However, they train this model using IRM or Group DRO with the inferred environments as group labels. PGI uses EIIL to infer environments, but trains a more robust model by minimizing the KL divergence of the predicted probabilities for samples in the same class, but different groups, using the inferred environments as group labels. + +# D.4 REPRESENTATION ALIGNMENT IN DOMAIN GENERALIZATION AND UNSUPERVISED DOMAIN ADAPTATION + +Finally, CNC’s approach to improve model robustness via a model’s learned hidden-layer representations also bears similarity to some prior domain generalization (DG) and unsupervised domain adaptation (UDA) methods. We first discuss similarities and differences between these methods and CNC. We then note fundamental differences between the DG and UDA settings and our spurious correlations setting, which may also explain the poorer performance of the related methods observed in Appendix A.2. + +Related methods for representation alignment. As introduced in Appendix A.2, to generalize beyond a single domain, such methods try to train model representations for samples that are aligned or invariant across domains. With domain adversarial neural networks (DANN), Ganin et al. (2016) accomplish alignment by adversarially training a model’s encoder layers (the “feature extractor”) to learn representations such that a separate domain classifier module cannot distinguish samples’ domains from the learned representations. To preserve class information, they train a classifier module on top of the feature extractor jointly with a cross-entropy loss. CNC’s process for aligning representations is more simple. We do not rely on training separate modules with conflicting objectives to accomplish alignment; instead the supervised contrastive loss with CNC’s sampling procedure encourages learning representations that are both separable across classes and aligned within each class. We thus avoid additional training parameters and optimization issues associated with minimax-based adversarial training (Arjovsky & Bottou, 2017). Instead of relying on a the domain classifier’s output, we can train single model to align representations by minimizing the cosine similarity between anchor and positive samples. + +Meanwhile, Li et al. (2018) propose maximum mean discrepancy MMD adversarial autoencoder (MMD-AAE). To align representations between domains, MMD-AAE (1) trains an autoencoder, (2) uses MMD maximum applied at the bottleneck hidden-layer to match representations across domains, and (3) applies an adversarial discriminator network to match these representations with a Laplace distribution (to encourage more sparse hidden representations). This matching is also not conditioned on the sample classes; an additional classifier head is applied to preserve class-specific information. CNC is also simpler than MMD-AAE, only using the normalized dot product of a single classifier’s last hidden-layer representations. Via contrastive learning, CNC also critically also aims to only align representations with the same class but different ERM-inferred groups, while pushing apart samples with different classes but the same ERM-inferred groups. By paying attention to the classes, we directly encourage a model to ignore group-specific information which confused the initial ERM model but that does not discriminate between classes. + +Finally, concurrent work applies contrastive learning for alignment in unsupervised domain adaptation (Wang et al., 2021). Similar to CNC, cross-domain contrastive learning (CDCL) trains an encoder to learn aligned representations. However, because the authors tackle UDA, their setup and components are different from ours. They try to align representations for samples with the same class but different known target and source domains. In their setup, domain labels are known. However, class labels are unknown for a specific “target” domain. They thus require inferring the class labels for target domain samples to set up their anchor, positive, and negative contrastive samples, introducing components that are not relevant for our setting. They infer class labels by first computing class-specific centroids for a “source” domain with class labels, and assign pseudolabels in the “target” domain based on the nearest class-centroid for each target domain sample. CDCL thus tackles a fundamentally different problem. In CNC’s spurious correlations setting, we do not have an obvious notion of “target” or “source” domains (instead aiming to improve the robust or worst “group” performance across all unseen test samples), we do not have labels indicating whether samples are from different domains or groups, and we infer the spurious attribute values for all training samples. + +Fundamental differences in tasks. All such methods proposed for domain generalization (DG) or unsupervised domain adaptation (UDA) also tackle fundamentally different problem settings from this work. First, both DG and UDA assume knowledge of training data domain labels. However in our setting, we must do the equivalent of inferring these domains. The distribution shift presented in standard DG / UDA benchmarks such as VLCS (Fang et al., 2013) is also distinct from the shift encountered with our spurious correlations datasets. As discussed in Appendix A.2, the notion of a “domain” must also be suitably specified for our setting. For example, in Waterbirds all samples with the same spurious attribute could be the same domain (e.g., the “water background” domain). Alternatively, all samples that exhibit the dominant spurious correlation could be a domain (e.g., the “waterbird, water background; landbird, land background” domain). Using DG or UDA approaches for our setting requires resolving this ambiguity, which is not present in prior DG or UDA works. + +Differences with domain generalization. In DG, (tackled by MMD-AAE) we have access to multiple “source” domains, know which “group” each sample belongs to (defined by domain-class combinations), and aim to generalize to a specific unseen “target” domain not present during training. Unlike the spurious correlations presented in our evaluated datasets, class distributions within domain are also not skewed. Standard benchmarks such as Office (Saenko et al., 2010) and VLCS (Fang et al., 2013) report much more uniform class distributions for each domain, compared to standard spurious correlations benchmarks such as Waterbirds where $9 5 \%$ of images in each background domain have the same class. Furthermore, in our setting we do not assume group labels or know the domain of any training sample. We also try to improve performance on the worst-group at test-time, which could belong to any domain encountered at training time. + +Differences with unsupervised domain adaptation. In UDA, (tackled by DANN and CDCL) methods also assume knowledge of training sample domains or spurious attributes, whereas CNC and our other comparable methods do not. UDA methods also assume a fundamentally different data setup; the training data is divided into source and target domains, and only the source domain has labels. The goal is to use the source and target features $^ +$ the source labels to transfer to the specific target domain. However, in our setting we do have class labels for all samples available during training, but do not have any natural definition of source and target domains. Applying UDA methods requires additional reintepretation of this setup. Similar to differences in our problem setting with DG, we do not have training data domain labels. + +# E ADDITIONAL EXPERIMENTAL DETAILS + +We first further describe our evaluation benchmarks in Appendix E.1. We next provide further details on how we calculate the reported metrics and the experimental hyperparameters of our main results in Appendix E.1. For all methods, following prior work (Liu et al., 2021; Sohoni et al., 2020; Nam et al., 2020; Sagawa et al., 2019; Creager et al., 2021) we report the test set worst-group and average accuracies from models selected through hyperparameter tuning for the best validation set worst-group accuracy. While different methods have different numbers of tunable hyperparameters, we try to keep the number of validation queries as close as possible while tuning for fair comparison. + +# E.1 DATASET DETAILS + +Colored MNIST (CMNIST∗). We evaluate with a version of the Colored MNIST dataset proposed in Arjovsky et al. (2019). The goal is to classify MNIST digits belonging to one of 5 classes $\begin{array} { r } { \mathcal { V } = \{ ( 0 , } \end{array}$ 1), (2, 3), (4, 5), (6, 7), $( 8 , 9 ) \}$ , and treat color as the spurious attribute. In the training data, we color $p _ { \mathrm { c o r r } }$ of each class’s datapoints with an associated color $a$ , and color the rest randomly. If $p _ { \mathrm { c o r r } }$ is high, trained ERM models fail to classify digits that are not the associated color. We pick $a$ from uniformly interspersed intervals of the hsv colormap, e.g. 0 and 1 digits may be spurious correlated with the color red $( \# \mathbb { f } \mathbb { f } 0 0 0 0 )$ , while 8 and 9 digits may be spuriously correlated with purple $( \# \mathbb { f } \mathbb { f } 0 0 1 8 )$ . The full set of colors in class order are $\mathcal { A } \overset { \_ } { = } \{ \# \pounds \dot { \pounds } 0 0 0 \bar { 0 } , \# 8 5 \dot { \pounds } \geq 0 0$ , $\# 0 0$ fff3, $\# 6 \mathsf { e } 0 0 \mathsf { f } \mathsf { f }$ , $\# \mathbb { f } \mathbb { f } 0 0 1 8 \}$ (see Fig. 2). For validation and test data, we color each datapoint randomly with a color $a \in { \mathcal { A } }$ . We use the default test set from MNIST, and allocate $80 \% - 2 0 \%$ of the default MNIST training set to the training and validation sets. For main results, we set $p _ { \mathrm { c o r r } } = 0 . 9 9 5$ . + +Waterbirds. We evaluate with the Waterbirds dataset, which was introduced as a standard spurious correlations benchmark in Sagawa et al. (2019). In this dataset, masked out images of birds from the CUB dataset (Wah et al., 2011) are pasted on backgrounds from the Places dataset (Zhou et al., 2017). Bird images are labeled either as waterbirds or landbirds; background either depicts water or land. From CUB, waterbirds consist of seabirds (ablatross, auklet, cormorant, frigatebird, fulmar, gull, jaeger, kittiwake, pelican, puffin, tern) and waterfowl (gadwell, grebe, mallard, merganser, guillemot, Pacific loon). All other birds are landbirds. From Places, water backgrounds consist of ocean and natural lake classes, while land backgrounds consist of bamboo forest and broadleaf forest classes. + +The goal is to classify the foreground bird as $\begin{array} { r } { \mathcal { V } = \left\{ \begin{array} { r l r l } \end{array} \right. } \end{array}$ waterbird, landbird}, where there is spurious background attribute $\begin{array} { r } { A = \left. \begin{array} { r l r l } \end{array} \right\} } \end{array}$ {water background, land background}. We use the default training, validation, and test splits (Sagawa et al., 2019), where in the training data $9 5 \%$ of waterbirds appear with water backgrounds and $9 5 \%$ of landbirds appear with land backgrounds. Trained ERM models then have trouble classifying waterbirds with land backgrounds and landbirds with water backgrounds. For validation and test sets, water and land backgrounds are evenly split among landbirds and waterbirds. + +CelebA. We evaluate with the CelebA spurious correlations benchmark introduced in Sagawa et al. (2019). The goal is to classify celebrities’ hair color $\begin{array} { r } { \mathcal { V } = \left\{ \begin{array} { r l r l } \end{array} \right. } \end{array}$ {blond, not blond}, which is spuriously correlated with the celebrity’s identified gender $\mathcal { A } = \{ \mathrm { m a l e }$ , female}. We use the same training, validation, test splits as in Sagawa et al. (2019). Only $6 \%$ of blond celebrities are male; trained ERM models perform poorly on this group. + +CivilComments-WILDS. We evaluate with the CivilComments-WILDS dataset from Koh et al. (2021), derived from the Jigsaw dataset from Borkan et al. (2019). Each datapoint is a real online comment curated from the Civil Comments platform, a commenting plugin for independent news sites. For classes, each comment is labeled as either toxic or not toxic. For spurious attributes, each comment is also labeled with the demographic identities {male, female, LGBTQ, Christian, Muslim, other religions, Black, White} mentioned; multiple identities may be mentioned per comment. + +The goal is to classify the comment $\begin{array} { r } { \mathcal { V } = \left\{ \begin{array} { r l r l } \end{array} \right. } \end{array}$ {toxic, not toxic}. As in Koh et al. (2021), we evaluate with $\mathcal { A } = \{ \mathrm { m a l e }$ , female, LGBTQ, Christian, Muslim, other religions, Black, White}. There are then 16 total groups corresponding to (toxic, identity) and (not toxic, identity) for each identity. Groups may overlap; a datapoint falls in a group if it mentions the identity. We use the default data splits (Koh et al., 2021). In Table A.6, we list the percentage of toxic comments for each identity based on the groups. Trained ERM models in particular perform less well on the rarer toxic groups. + +Table A.6: Percent of toxic comments for each identity in the CivilComments-WILDS training set. + +
IdentitymalefemaleLGBTQChristianMuslimother religionsBlackWhite
% toxic14.913.726.99.122.415.331.428.0
+ +# E.2 IMPLEMENTATION DETAILS + +# E.2.1 REPORTED METRICS + +Main results. For the CMNIST∗, Waterbirds, and CelebA data sets, we run CNC with three different seeds, and report the average worst-group accuracy over these three trials in Table 1. As we use the same baselines and comparable methods as Liu et al. (2021), we referenced their main results for the reported numbers, which did not have standard deviations or error bars reported. For CivilCommentsWILDS, due to time and compute constraints we only reported one run. We note that CMNIST∗ here is extremely challenging, as minority groups together only make up $0 . 5 \%$ of the training set. This severe imbalance explains the very poor worst-group performance of ERM (as well as a couple other methods that fail to sufficiently remediate issue). + +Estimated mutual information. We give further details for calculating the representation metric introduced in Sec. 3. As a reminder, we report both alignment and estimated mutual information metrics to quantify how dependent a model’s learned representations are on the class labels versus the spurious attributes, and compute both metrics on the representations $Z = \{ f _ { \mathrm { e n c } } ( x ) \}$ over all test set data points $x$ . Then to supplement the alignment loss calculation in Sec. 3, we also estimate $I ( Y ; Z )$ and $I ( A ; Z )$ , the mutual information between the model’s data representations and the class labels and spurious attribute labels respectively. + +To first estimate mutual information with $Y$ , we first approximate $p ( y \mid z )$ by fitting a multinomial logistic regression model over all representations $Z$ to classify $y$ . With the empirical class label distribution $p ( y )$ , we compute: + +$$ +\hat { I } ( Y ; Z ) = \frac { 1 } { | Z | } \sum _ { z \in Z } \sum _ { y \in Y } p ( y \mid z ) \log \frac { p ( y \mid z ) } { p ( y ) } +$$ + +We do the same but substitute the spurious attributes $a$ for $y$ to compute $\hat { I } ( A ; Z )$ + +# E.2.2 STAGE 1 ERM TRAINING DETAILS + +We describe the model selection criterion, architecture, and training hyperparameters for the initial ERM model in our method. To select this model, recall that we first train an ERM model to predict the class labels, as the model may also learn dependencies on the spurious attributes. Because we then use the model’s predictions on the training data to infer samples with different spurious attribute values but the same class label, we prefer an initial ERM model that better learns this spurious dependency, and importantly also does not overfit to the training data. Inspired by the results in prior work (Sohoni et al., 2020; Liu et al., 2021), we then explored using either a standard ERM model, one with high \`-2 regularization (weight decay $\mathit { \Theta } = \mathit { \Theta } \ b { 1 }$ ), or one only trained on a few number of epochs. To select among these, because the validation data has both class labels and spurious attributes, we choose the model with the largest gap between worst-group and average accuracy on the validation set. For fair comparison to JTT, we use the same batch size, learning rate, momentum, optimizer, default weight decay, and number of epochs as reported in Liu et al. (2021) to obtain these models. We detail the ERM architecture and hyperparameters for each dataset below: + +Colored MNIST. We use the LeNet-5 CNN architecture in the pytorch image classification tutorial. We train with SGD, few epochs $E = 5$ , SGD, learning rate 1e-3, batch size 32, default weight decay 5e-4, and momentum 0.9. + +Waterbirds. We use the torchvision implementation of ResNet-50 with pretrained weights from ImageNet as in Sagawa et al. (2019). Also as in (Sagawa et al., 2019), we train with SGD, default epochs $E = 3 0 0$ , learning rate 1e-3, batch size 128, and momentum 0.9. However we use high weight decay 1.0. + +CelebA. We also use the torchvision ImageNet-pretrained ResNet-50 and default hyperparameters from Sagawa et al. (2019) but with high weight decay: we train with SGD, default epochs $E = 5 0$ , learning rate 1e-4, batch size 128, momentum 0.9, and high weight decay 0.1. + +CivilComments-WILDS. We use the HuggingFace (pytorch-transformers) implementation of BERT with pretrained weights and number of tokens capped at 300 as in Koh et al. (2021). As in Liu et al. (2021), with other hyperparameters set to their defaults (Koh et al., 2021) we tune between using the AdamW optimizer with learning rate 1e-5 and SGD with learning rate 1e-5, momentum 0.9, and the PyTorch ReduceLROnPlateau learning rate scheduler. Based on our criterion, we use SGD, few number of epochs $E = 2$ , learning rate 1e-5, batch size 16, default weight decay 1e-2, and momentum 0.9. + +# E.2.3 CONTRASTIVE BATCH SAMPLING DETAILS + +We provide further details related to collecting predictions from the trained ERM models, and the number of positives and negatives that determine the contrastive batch size. + +ERM model prediction. To collect trained ERM model predictions on the training data, we explored two approaches: (1) using the actual predictions, i.e. the argmax for each classifier layer output vector, and (2) clustering the representations, or the last hidden-layer outputs, and assigning a cluster-specific label to each data point in one cluster. This latter approach is inspired by Sohoni et al. (2020), and we similarly note that ERM models trained to predict class labels in spuriously correlated data may learn data representations that are clusterable by spurious attribute. As a viable alternative to collecting the “actual” predictions of the trained ERM model on the training data, with $C$ classes, we can then cluster these representations into $C$ clusters, assign the same class label only to each data point in the same cluster, and choose the label-cluster assignment that leads to the highest accuracy on the training data. We also follow their procedure to first apply UMAP dimensionality reduction to 2 UMAP components, before clustering with K-means or GMM (Sohoni et al., 2020). To choose between all approaches, we selected the procedure that lead to highest worst-group accuracy on the validation data after the second-stage of training. While this cluster-based prediction approach was chosen as a computationally efficient heuristic, we found that in practice it either lead to comparable or better final worst-group accuracy on the validation set. To better understand this, as a preliminary result we found that when visualizing the validation set predictions with the Waterbirds dataset, the cluster-based predictions captured the actual spurious attributes better than the classifier layer predictions (Fig. 10). We defer additional discussion to Sohoni et al. (2020) and leave further analysis to future work. + +Number of positives and negatives per batch. One additional difference between our work and prior contrastive learning methods (Chen et al., 2020; Khosla et al., 2020) is that we specifically construct our contrastive batches by sampling anchors, positives, and negatives first. This is different from the standard procedure of randomly dividing the training data into batches first, and then assigning the anchor, positive, and negative roles to each datapoint in a given batch. As a result, we introduce the number of positives $M$ and the number of negatives $N$ as two hyperparameters that primarily influence the size of each contrastive batch (with number of additional anchors and negatives also following $M$ and $N$ with two-sided batches). To maximize the number of positive and negative comparisons, as a default we set $M$ and $N$ to be the maximum number of positives and negatives that fit the sampling criteria specified under Algorithm 2 that also can fit in memory. In Appendix E.2.4, for each dataset we detail the ERM prediction method and number of positives and negatives sampled in each batch. + +![](images/c08bbcddfcd37082ddae49f2e280791530bc99f2fe3e2dc89382f880f3471756.jpg) +Figure 10: UMAP visualization of ERM data representations for the Waterbirds training data. We visualize the last hidden layer outputs for a trained ERM ResNet-50 model given training samples from Waterbirds, coloring by either the ERM model’s “standard” predictions, the actual spurious attribute values (included here just for analysis), and predictions computed by clustering the representations as described above. Clustering-based predictions more closely align with the actual spurious attributes than the ERM model outputs. + +# E.2.4 STAGE 2 CONTRASTIVE MODEL TRAINING DETAILS + +In this section we describe the model architectures and training hyperparameters used for training the second model of our procedure, corresponding the reported worst-group and average test set results in Table 1. In this second stage, we train a new model with the same architecture as the initial ERM model, but now with a contrastive loss and batches sampled based on the initial ERM model’s predictions. We report test set worst-group and average accuracies from models selected with hyperparameter tuning and early stopping based on the highest validation set worst-group accuracy. For all data sets, we sample contrastive batches using the clustering-based predictions of the initial ERM model. Each batch size specified here is also a direct function of the number of positives and negatives: $2 M + 2 N$ . + +Colored MNIST. We train a LeNet-5 CNN. For CNC, we use $M = 3 2$ , $N = 3 2$ , batch size 128, temperature $\tau = 0 . 0 5$ , contrastive weight $\lambda = 0 . 7 5$ , SGD optimizer, learning rate 1e-3, momentum 0.9, and weight decay 1e-4. We train for 3 epochs, and use gradient accumulation to update model parameters every 32 batches. + +Waterbirds. We train a ResNet-50 CNN with pretrained ImageNet weights. For CNC, we use $M = 1 7$ , $N = 1 7$ , batch size 68, temperature $\tau = 0 . 1$ , contrastive weight $\lambda = 0 . 7 5$ , SGD optimizer, learning rate 1e-4, momentum 0.9, weight decay 1e-3. We train for 5 epochs, and use gradient accumulation to update model parameters every 32 batches. + +CelebA. We train a ResNet-50 CNN with pretrained ImageNet weights. For CNC, we use $M = 6 4$ , $N = 6 4$ , batch size 256, temperature $\tau = 0 . 0 5$ , contrastive weight $\lambda = 0 . 7 5$ , SGD optimizer, learning rate 1e-5, momentum 0.9, and weight decay 1e-1. We train for 15 epochs, and use gradient accumulation to update model parameters every 32 batches. + +CivilComments-WILDS. We train a BERT model with pretrained weights and max number of tokens 300. For CNC, we use $M = 1 6$ , $N = 1 6$ , batch size 64, temperature $\tau = 0 . 1$ , contrastive weight $\lambda = 0 . 7 5$ , AdamW optimizer, learning rate 1e-4, weight decay 1e-2, and clipped gradient norms. We train for 10 epochs, and use gradient accumulation to update weights every 128 batches. + +# E.2.5 COMPARISON METHOD TRAINING DETAILS + +As reported in the main results (Table 1) we compare CNC with the ERM and Group DRO baselines, as well as robust training methods that do not require spurious attribute labels for the training data: CVaR DRO (Levy et al., 2020), GEORGE (Levy et al., 2020), Learning from Failure (LfF) (Levy et al., 2020), Predictive Group Invariance (PGI) (Ahmed et al., 2021), Contrastive Input Morphing (CIM) (Taghanaki et al., 2021), Environment Inference for Invariant Learning (EIIL) (Creager et al., 2021), and Just Train Twice (JTT) (Liu et al., 2021). For each dataset, we use the same model architecture for all methods. For the Waterbirds, CelebA, and CivilComments-WILDS data sets, we report the worst-group and average accuracies reported in Liu et al. (2021) for ERM, CVaR DRO, + +LfF, and JTT. For GEORGE, we report the accuracies reported in Sohoni et al. (2020). For CIM, we report results from Waterbirds and CelebA from Taghanaki et al. (2021) using the $\mathrm { C I M } +$ variational information bottleneck implementation Alemi et al. (2016), which achieves the best worst-group performance in their results. For EIIL, we report results from Waterbirds and CivilComments-WILDS from Creager et al. (2021). For these hyperparameters, we defer to the original papers. For GDRO, we reproduce the results with the same optimal hyperparameters over three seeds. For PGI, we used our own implementation for all results, with details specified below. For Colored MNIST, we run implementations for GEORGE, CIM, EIIL, JTT, and GDRO, using code from their authors respectively. LfF and CVaR DRO are also run with code from the JTT authors. We include training details for our own implementations below: + +Colored MNIST (CMNIST∗). We run all methods for 100 epochs, reporting test set accuracies with early stopping. For JTT, we train with SGD, learning rate 1e-3, momentum 0.9, weight decay 5e-4, batch size 32. We use the same initial ERM model as CNC, with hyperparameters described in Appendix E.2.2. For upsampling we first tried constant factors $\{ 1 0 , 1 0 0 , 1 0 0 0 \}$ . We also tried a resampling strategy where for all the datapoints with the same initial ERM model prediction, we upsample the incorrect points such that they equal the correct points in frequency, and found this worked the best. With $p _ { \mathrm { c o r r } } = 0 . 9 9 5$ , this upsamples each incorrect point by roughly 1100. We also use this approach for the results in Fig. 7. For GDRO we use the same training hyperparameters as JTT, but without the upsampling and instead set group adjustment parameter $C = 0$ . For LfF, we use the same hyperparameters as JTT, but instead of upsampling gridsearched the $q$ parameter $\in \{ 0 . 1 , 0 . 3 , 0 . 5 , 0 . 7 , 0 . 9 \}$ , using $q = 0 . 7$ . For CVaR DRO we do the same but use hyperparameter $\alpha = 0 . 1$ . For GEORGE we train with SGD, learning rate 1e-3, momentum 0.9, weight decay 5e-4. For CIM, we use the $\mathrm { C I M } + \mathrm { V I B }$ implementation. We train with SGD, learning rate 1e-3, weight decay 5e-4, $\beta$ parameter 10, and $\lambda$ parameter 1e-5. For EIIL, for environment inference we use the same initial ERM model as CNC and JTT, and update the soft environment assignment distribution with Adam optimizer, learning rate 1e-3, and 10000 steps. Following Creager et al. (2021)’s own colored MNIST experiment, we train the second model with IRM, using learning rate 1e-2, weight decay 1e-3, penalty weight 100, and penalty annealing parameter 80. + +CelebA. We also tune EIIL for CelebA. We again use the same initial ERM model as CNC, and update the soft environment assignment distribution with Adam optimizer, learning rate 1e-3, and 10000 steps. We train the second model with GDRO, using SGD, 50 epochs, learning rate 1e-5, batch size 128, weight decay 0.1, and group adjustment parameter 3. + +PGI To compare against PGI, we tried two implementations. First, we followed the PGI algorithm to first infer environments via the same mechanism as in EIIL [2], and trained a second model with the PGI objective using standard shuffled minibatches (aiming to minimize the KL divergence for samples with the same class but different inferred environment labels per batch). However, despite ample hyperparameter tuning (trying loss weighting component $\lambda \in \{ 0 . 1 , 0 . 5 , 1 0 , 1 0 0 \}$ , we could not get PGI to work well (on Waterbirds, we obtained $5 1 . 0 \pm 4 . 9 \%$ worst-group accuracy and $7 9 . 6 \pm 2 . 6 \%$ average accuracy). We hypothesize this is due to the strong spurious correlations in our datasets: while Ahmed et al. (2021) only considers datasets where $20 \%$ of the training samples do not exhibit a dominant correlation and fall under minority groups. Our evaluation benchmarks are more difficult due to stronger spurious correlations, e.g., in Waterbirds only $5 \%$ of samples do not exhibit the dominant correlation; similarly only $7 \%$ of training samples lie in the smallest group in CelebA. + +We then tried a more balanced batch variation. Instead of using randomly shuffled minibatches, we used the PGI environment inference labels to sample batches similarly to how CNC uses the stage 1 ERM model predictions to sample batches. We construct batches by specifying the same number of “anchors”, “positives”, and “negatives” as in CNC, and sample batches where anchors and positives are samples with the same class, but different inferred environments. Anchors and negatives are samples in the same inferred environment, but with different classes. We then trained a second model with the PGI criterion with these modified batches. + +In Section E.2.6, we include our sweeps for both the method-specific and general hyperparameters. + +Comparison limitations. One limitation of our comparison is that because for each dataset we sample new contrastive batches which could repeat certain datapoints, the number of total batches per epoch changes. For example, 50 epochs training the second model in CNC does not necessarily lead to the same total number of training batches as 50 epochs training with ERM, even if they use the same batch size. However, we note that the numbers we compare against from Liu et al. (2021) are reported with early stopping. In this sense we are comparing the best possible worst-group accuracies obtained by the methods, not the highest worst-group accuracy achieved within a limited number of training batches. We also found that although in general the time to complete one epoch takes much longer with CNC, CNC requires fewer overall training epochs for all but the CivilComments-WILDS dataset to obtain the highest reported accuracy. + +# E.2.6 HYPERPARAMETER SWEEPS + +To fairly compare with previous methods (Liu et al., 2021; Creager et al., 2021; Taghanaki et al., 2021), we use the same evaluation scheme (selecting models based on worst-group validation error), and sweep over a consistent number of hyperparameters, i.e. number of validation set queries. We set this number for CNC to be a comparable number of queries that is reported in prior works. We break this down into method-specific (e.g. contrastive temperature in CNC, upweighting factor in JTT), and shared (e.g. learning rate) hyperparameter categories. + +Method-specific For CNC, we tune three method-specific hyperparameters: contrastive loss temperature (Eq. 3), contrastive weight (Eq. 7), and gradient accumulation steps values as in Table A.7. + +Table A.7: Method-specific hyperparameters for CNC. + +
HyperparameterDatasetValues
Temperature (T)All{0.05,0.1}
Contrastive Weight (入)All{0.5,0.75}
Gradient Accumulation StepsCMNIST*,Waterbirds, CelebA CivilComments-WILDS{32,64} {32,64,128}
+ +For JTT, the reported results and our CMNIST∗ implementation are tuned over the following hyperparameters in Table A.8. + +Table A.8: Method-specific hyperparameters for JTT. + +
HyperparameterDatasetValues
Stage 1 Training EpochsWaterbirds CMNIST*, CelebA, CivilComments-WILDS{40,50,60} {1,2}
Upweighting FactorCMNIST* Waterbirds, CelebA CivilComments-WILDS{10,100,1000,1100} {20,50,100} {4,5,6}
+ +For EIIL, our CMNIST∗ and CelebA implementations are tuned over hyperparameters reported in Table A.9. Creager et al. (2021) report that they allow up to 20 evaluations with different hyperparameters for Waterbirds and CivilComments-WILDS. When using GDRO as the second stage model, they also report using the same hyperparameters as the GDRO baseline for Waterbirds. We do the same for our evaluation on CelebA. This amounts to primarily tuning the first stage environment inference learning rate and number of updating steps for CMNIST∗ and CelebA, and the penalty annealing iterations and penalty weight for the IRM second stage model for CMNIST∗. + +Table A.9: Method-specific hyperparameters for EIIL. + +
HyperparameterDatasetValues
Environment Inference Learning RateCMNIST*, CelebA{1e-1,1e-2,1e-3}
Environment Inference Update StepsCMNIST*, CelebA{10000,20000}
IRM Penalty WeightCMNIST*{0.1,10,1000, 1e5}
IRM Penalty Annealing IterationsCMNIST*{10, 50, 80}
GDRO Group AdjustmentCelebA{0,2,3}
+ +For CIM, our CMNIST∗ implementation uses $\mathrm { C I M } + \mathrm { V I B }$ , and is tuned over the $\beta$ VIB parameter Alemi et al. (2016) and contrastive weighting parameter $\lambda$ for CIM in Table A.10. Taghanaki et al. (2021) report tuning over a range of values within [1e-5, 1] for $\lambda$ on the CelebA and Waterbirds data sets. + +Table A.10: Method-specific hyperparameters for CIM. + +
HyperparameterDatasetValues
CIM 入CMNIST*{0.01, 0.05,0.1}
VIB βCMNIST*{1e-5, 1e-3, 1e-1, 10}
+ +For PGI, we tune $\lambda$ with the same environment inference parameters as used in EIIL (Table A.9). Fixing these parameters to infer environments, we tuned the $\lambda$ component for training the robust model across $\mathrm { ~ \bar { \lambda } ~ } \in \{ 0 . 1 , 0 . 5 , 1 0 , 1 0 0 \}$ . + +Shared For all data sets, we use the same optimizer and momentum (if applicable) as reported in the JTT paper. Table A.11 contains the data-specific shared hyperparameter values tried. + +Table A.11: Shared hyperparameters + +
CMNIST*WaterbirdsCelebACivilComments-WILDS
Learning Rate{le-4, le-3,le-2}{1e-4,1e-3}{1e-5,1e-4}{1e-5,1e-4}
Weight Decay{1e-4,5e-4}{1e-4,1e-3}{1e-2,1e-1}{1e-2}
+ +# E.3 CNC COMPUTE RESOURCES AND TRAINING TIME + +All experiments for CMNIST∗, Waterbirds, and CelebA were run on a machine with 14 CPU cores and a single NVIDIA Tesla P100 GPU. Experiments for CivilComments-WILDS were run on an Amazon EC2 instance with eight CPUs and one NVIDIA Tesla V100 GPU. + +Regarding runtime, one limitation with the current implementation of CNC is its comparatively longer training time compared to methods such as standard ERM. This is both a result of training an initial ERM model in the first stage, and training another model with contrastive learning in the second stage. In Table A.12 we report both how long it takes to train the initial ERM model and long it takes to complete one contrastive training epoch on each dataset. We observe that while in some cases training the initial ERM model is negligible, especially if we employ training with only a few epochs to prevent memorization (for Colored MNIST it takes roughly two minutes to obtain a sufficient initial ERM model), it takes roughly 1.5 and 3 hours to train the high regularization initial models used for Waterbirds and CelebA. While these hurdles are shared by all methods that train an initial ERM model, we find that the second stage of CNC occupies the bulk of training time. Prior work has shown that contrastive learning typically requires longer training times and converges more slowly than supervised learning (Chen et al., 2020). We also observe this in our work. + +We note however that because we sample batches based on the ERM model’s predictions, the contrastive training duration is limited by how many datapoints the initial ERM model predicts incorrectly. In moderately sized data sets with very few datapoints in minority groups, (e.g. Waterbirds, which has roughly 4794 training points and only 56 datapoints in its smallest group), the total time it takes to train CNC is on par with ERM. Additionally, other methods such as additional hard negative mining (Robinson et al., 2021) have been shown to improve the efficiency of contrastive learning, and we can incorporate these components to speed up training time as well. + +Table A.12: CNC Average total training time for first and second stages of CNC + +
DatasetCMNIST*WaterbirdsCelebACivilComments-WILDS
Stage 1 ERM train time2 min.1.5 hrs3 hrs3.1 hrs
Stage 2 CNC train time1.2 hrs1.8 hrs32.2 hrs37.6 hrs
+ +As in Fig. 6, we visualize and compare the learned representations of test set samples from models trained with ERM, JTT, and CNC in Fig. 11. Compared to ERM models, both JTT and CNC models learn representations that better depict dependencies on the class labels. However, especially with the Waterbirds and CelebA data sets, CNC model representations more clearly depict dependencies only on the class label, as opposed to JTT models which also show some organization by the spurious attribute still. + +![](images/6bfb15d0507aa49b3745818a3c25a3cfc4d82884e6bf9aba7b4f394ec0e8f903.jpg) +Figure 11: UMAP visualizations of learned representations for Colored MNIST (a), Waterbirds (b), and CelebA (c). We color data points based on the class label (left) and spurious attribute (right). Most consistently across data sets, CNC representations exhibit dependence and separability by the class label but not the spurious attribute, suggesting that they best learn features which only help classify class labels. + +# G ADDITIONAL GRADCAM VISUALIZATIONS + +On the next two pages, we include additional GradCAM visualizations depicting saliency maps for samples from each group in the Waterbirds and CelebA data sets. Warmer colors denote higher saliency, suggesting that the model considered these pixels more important in making the final classification as measured by gradient activations. For both data sets, we compare maps from models trained with ERM, the next most competitive method for worst-group accuracy JTT, and CNC. CNC models most consistently measure highest saliency with pixels directly associated with class labels and not spurious attributes. + +![](images/2df798b62302879c2872531b6f00fbc4fe0be41438359acde5674b6e8eebb212.jpg) +Figure 12: Additional GradCAM visualizations for the Waterbirds dataset. We use GradCAM to visualize the “salient” observed features used to classify images by bird type for models trained with ERM, JTT, and CNC. ERM models output higher salience for spurious background attribute pixels, sometimes almost exclusively. JTT and $\mathrm { C N C }$ models correct for this, with CNC better exclusively focusing on bird pixels. + +# G.2 CELEBA + +![](images/e6e9530db5407c4e97acc57f9ff254ff314ff963fdd548ca84be6009839f24d1.jpg) \ No newline at end of file diff --git a/md/dev/cmt-6KtR4c4/cmt-6KtR4c4.md b/md/dev/cmt-6KtR4c4/cmt-6KtR4c4.md new file mode 100644 index 0000000000000000000000000000000000000000..15cb191bbcb34c5ba2449fbe03f72352e74f9d72 --- /dev/null +++ b/md/dev/cmt-6KtR4c4/cmt-6KtR4c4.md @@ -0,0 +1,333 @@ +# LEVERAGING AUTOMATED UNIT TESTS FOR UNSUPERVISED CODE TRANSLATION + +Baptiste Rozière Facebook AI Research Paris-Dauphine University broz@fb.com + +Jie M. Zhang University College London† zhangjie@fb.com + +François Charton Facebook AI Research fcharton@fb.com + +Mark Harman +Facebook +markharman@fb.com + +Gabriel Synnaeve Facebook AI Research gab@fb.com + +Guillaume Lample Facebook AI Research glample@fb.com + +# ABSTRACT + +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 \%$ . + +# 1 INTRODUCTION + +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). + +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. + +![](images/264c764407ee01b203bae5036832d1d6c66ea71ed09e450dc7bb1a8437eda7b7.jpg) +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. + +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. + +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. + +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. + +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: + +• 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. + +# 2 RELATED WORK + +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). + +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. + +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. + +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), + +![](images/53929250dddb4fcf9d94924ec47cd52516e3715954fa013d3c91fbdadd485ccd.jpg) +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. + +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). + +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. + +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). + +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. + +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. + +# 3 METHOD + +# 3.1 PARALLEL DATA CREATION + +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. + +![](images/8de247c3f500f6477415d68ac90a463372ec9f560e3926090443b78e6b5eecb8.jpg) +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. + +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. + +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. . . ). + +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. + +# 3.2 TRAINING METHOD + +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. + +Table 1: Size of the parallel datasets generated offline at each iteration. + +
LanguagesFirst iterationSecond iterationThird iterationFourth iteration
Java ←→ C++27,87537,76947,72960,495
Java ←→Python33,49643,19443,95645,311
C++ ←→Python14,93521,02627,08032,869
+ +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. + +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. + +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. + +# 3.3 EVALUATION + +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). + +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). + +# 4 EXPERIMENTS + +# 4.1 TRAINING DETAILS + +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. + +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. + +
C++ →JaC++ →PyJa→C++Ja→PyPy→C++Py→JaAVG
TransCoder DOBF65.1% -47.1% 179.8% -49.0% 52.7%32.6% 136.6% 45.7%51.7% 1
Offline ST 165.5%56.2%81.6%61.8%46.8%55.1%61.1%
Offline ST 265.5%58.3%83.7%63.3%46.4%52.2%61.6%
Offline ST 366.5%56.2%85.2%66.3%48.1%56.6%63.1%
Offline ST 465.3%48.2%81.1%58.1%48.9%54.7%59.4%
Online ST68.0%61.3%84.6%68.9%56.7%58.2%66.3%
+ +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. + +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. + +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. + +# 4.2 RESULTS AND DISCUSSION + +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. + +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. + +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. + +
CA@1 k=1CA@1 k=10CA@1 k=20CA@10 k=10CA@20 k=20
Best baseline52.2%53.7%53.4%67.3%70.5%
Offline ST 160.8%61.1%61.1%72.9%75.3%
Offline ST 261.4%61.6%61.4%73.3%75.8%
Offline ST 361.7%63.1%63.0%73.3%75.8%
Offline ST 458.5%59.4%59.2%70.8%73.6%
Online ST64.7%66.3%66.3%75.4%77.2%
+ +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. + +
C++→JaC++ →PyJa→C++Ja→PyPy→C++Py→JaAVG
No cache66.5%52.7%83.7%60.3%41.2%51.8%59.4%
Cache not initialized64.9%51.6%82.4%62.4%46.6%52.6%60.1%
+ No min mut. score64.0%50.1%82.6%60.9%47.4%47.0%58.7%
ST greedy decoding65.9%54.2%82.2%60.9%56.2%56.6%62.7%
Full model(ST beam 20)66.7%61.1%84.1%67.8%52.2%56.7%64.7%
+ Eval beam 1068.0%61.3%84.6%68.9%56.7%58.2%66.3%
+ +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. + +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. + +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. + +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. + +
Input Java functionGold translationTranslation passing multilingual tests
static int factorial(int n){def factorial(n):def factorial(n) :
if (n<2) return 1;ifn<2:n = np.int32(n)
return n * factorial(n - 1);return 1ifn<2:
return n factorial(n-1)return np.int32(1)
return n factorial(n - 1)
+ +# 5 CONCLUSION + +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). + +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. + +# REPRODUCIBILITY + +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. + +# ETHICAL CONSIDERATIONS + +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. + +# REFERENCES + +Karan Aggarwal, Mohammad Salameh, and Abram Hindle. Using machine translation for converting python 2 to python 3 code. Technical report, PeerJ PrePrints, 2015. + +Maaz Bin Safeer Ahmad and Alvin Cheung. Leveraging parallel data processing frameworks with verified lifting. SYNT@CAV, 2016. + +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. + +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. + +Miltiadis Allamanis, Marc Brockschmidt, and Mahmoud Khademi. Learning to represent programs with graphs. In International Conference on Learning Representations, 2018. + +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. + +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. + +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. + +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. + +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. + +Yonatan Belinkov and Yonatan Bisk. Synthetic and natural noise both break neural machine translation. In International Conference on Learning Representations, 2018. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +Gordon Fraser and Andrea Arcuri. Achieving scalable mutation-based generation of whole test suites. Empirical Software Engineering, 20(3):783–812, 2015. + +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. + +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. + +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. + +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. + +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. + +Shoaib Kamil, Alvin Cheung, Shachar Itzhaky, and Armando Solar-Lezama. Verified lifting of stencil computations. ACM SIGPLAN Notices, 51(6):711–726, 2016. + +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. + +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. + +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. + +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. + +Philipp Koehn. Statistical machine translation. Cambridge University Press, 2009. + +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. + +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. + +Guillaume Lample, Myle Ott, Alexis Conneau, Ludovic Denoyer, and Marc’Aurelio Ranzato. Phrase-based & neural unsupervised machine translation. In EMNLP, 2018. + +Jian Li, Yue Wang, Michael R Lyu, and Irwin King. Code completion with neural attention and pointer networks. IJCAI, 2018. + +Tatiana Likhomanenko, Qiantong Xu, Jacob Kahn, Gabriel Synnaeve, and Ronan Collobert. slimipl: Language-model-free iterative pseudo-labeling. arXiv preprint arXiv:2010.11524, 2020. + +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. + +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. + +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. + +W. Miller and D. Spooner. Automatic generation of floating-point test data. IEEE Transactions on Software Engineering, 2(3):223–226, 1976. + +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. + +Glenford J. Myers. The Art of Software Testing. Wiley - Interscience, New York, 1979. ISBN 0-471-04328-1. + +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. + +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. + +Baptiste Roziere, Marie-Anne Lachaux, Lowik Chanussot, and Guillaume Lample. Unsupervised translation of programming languages. Advances in Neural Information Processing Systems, 33, 2020. + +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. + +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. + +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. + +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. + +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. + +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. + +Michele Tufano, Dawn Drain, Alexey Svyatkovskiy, Shao Kun Deng, and Neel Sundaresan. Unit test case generation with transformers. arXiv preprint arXiv:2009.05617, 2020. + +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. + +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. + +Ke Wang, Rishabh Singh, and Zhendong Su. Dynamic neural program embeddings for program repair. In International Conference on Learning Representations, 2018. + +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. + +Jie M Zhang, Mark Harman, Lei Ma, and Yang Liu. Machine learning testing: Survey, landscapes and horizons. IEEE Transactions on Software Engineering, 2020. + +# A MULTILINGUAL UNIT TESTS CREATION + +# A.1 GENERATED UNIT TESTS + +![](images/01a4352ce5bbd63154b8c155f26a195be1dde6dc3d3ab53f1f2b4754f1bffba0.jpg) +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. +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. + +
Java functionGenerated test suite
public static int sizeBits_cmd(){ return 8;public void test0() throws Throwable{ assertEquals(8,Example.sizeBits_cmd());
+ +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. + +# A.2 MUTATION SCORE + +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). + +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. + +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. + +![](images/8951d3afab404bee0652321f82c4db9d091cce8e0e36b59f8eec15cf8326ab39.jpg) +Figure 7: A mutant generated by the “Replace arithmetic operator” mutation in EvoSuite. The $<$ operator in the return statement is replaced with $>$ . + +![](images/3e90e4ccb4fd47b9217ce60d6161b4bbafe2573057453b0c4f9d95d83c3fad20.jpg) +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. + +![](images/2c39b11e70cd1c5e4825e1ccd7946d93203300752b4582987178c1e64fc00af4.jpg) +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. + +![](images/ec4519d6d1962034cc01609ba6465c92eb43b9bf5dc7636493708541f94e4443.jpg) +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. + +![](images/845994e1a550e52fd445e06136c8d1fe8266814a89d178a932a781e3fb19ad35.jpg) +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. + +![](images/6a38791e9d77487af2b2e689b814530cfcce4061a820bbb2c7c2f897c5d76244.jpg) +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. + +![](images/d746dd576da6508e67d1fe01fe8c083d3e9eae44c34d791de34cafb925e0054d.jpg) +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. + +![](images/b80c3479b215d6355cff1ef8f37f4a028da726548a19bacb0c06086106825ead.jpg) +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. + +![](images/7b4e634e2ec93023ad175471bb69450eb3bd65beafabe9fd841454c7c5ae9779.jpg) +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). + +# C EXTRA RESULTS + +# C.1 BEAM REORDERING + +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. + +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). + +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. + +
C++→JaC++ →PyJa→C++Ja→PyPy→C++Py→JaAVG
TransCoder DOBF65.1% =47.1% -79.8% -49.0% 52.7%32.6% =36.6% 45.7%51.7% =
Beam reordering--80.3%54.4%===
Offline ST scratch43.0%41.3%54.3%43.2%31.1%39.7%42.1%
Offline ST165.5%56.2%81.6%61.8%46.8%55.1%61.1%
Offline ST 265.5%58.3%83.7%63.3%46.4%52.2%61.6%
Offline ST 366.5%56.2%85.2%66.3%48.1%56.6%63.1%
Offline ST 465.3%48.2%81.1%58.1%48.9%54.7%59.4%
Online ST68.0%61.3%84.6%68.9%56.7%58.2%66.3%
\ No newline at end of file diff --git a/md/dev/e0uknAgETh/e0uknAgETh.md b/md/dev/e0uknAgETh/e0uknAgETh.md new file mode 100644 index 0000000000000000000000000000000000000000..7ad9c5f3b36f281fe65a4f887ba52bfb127f504b --- /dev/null +++ b/md/dev/e0uknAgETh/e0uknAgETh.md @@ -0,0 +1,232 @@ +# ADVERSARIAL ATTACKS ON SPIKING CONVOLUTIONAL NETWORKS FOR EVENT-BASED VISION + +Anonymous authors Paper under double-blind review + +# ABSTRACT + +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. + +# 1 INTRODUCTION + +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. + +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). + +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. + +# 1.1 WHAT IS EVENT-BASED SENSING? + +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). + +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. + +# 1.2 ADVERSARIAL ATTACKS ON DISCRETE DATA + +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. + +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. + +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: + +• We provide detailed results to quantify the effectiveness and scalability of several adversarial attacks strategies, including some not tried before on SNNs. +• We show targeted universal attacks on event-based data in the form of adversarial patches, which do not require prior knowledge of the input. +• 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. + +# 2 METHODS + +# 2.1 ATTACK STRATEGIES + +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. + +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): + +$$ +{ \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) , +$$ + +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. + +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 + +![](images/4b95cb9bdbaf2292d125d6d6f63b5beed9e978d640bd72bcd4e7e800349ff99d.jpg) +Figure 1: Schematic of the attack procedure on DVS data. + +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 } ) )$ . + +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. + +# 2.2 DATASETS AND DATA PREPARATION + +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). + +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. + +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. + +# 2.3 NETWORKS + +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 \%$ . + +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. + +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. + +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. + +![](images/3a5b50767dd927dec9ee54e38831b6bb5c037491545e17f5ca9b9f6bb32ff92f.jpg) +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. + +# 2.4 EXPERIMENTS ON THE NEUROMORPHIC CHIP + +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. + +
AttackSuccess Rate (%)Median Elapsed Time (s/sample)Median No. QueriesMedian L
BSIIIYSCAR100.001.1411757
PGD98.890.1610250
Probabilistic PGD99.700.5427523
SparseFool (n = 0.2,λ= 2)99.900.081114
LSINNNPGD48.6372.561052_t
Probabilistic PGD54.4668.35774522
SparseFool (n = 0.2,λ = 2)99.7630.2245254
SparseFool (n = 0.5,入= 2)99.8813.0826268
SparseFool(n = 0.1,λ= 3)100.002.7811310
SparseFool (n =0.1,λ= 2)99.872.57 3.0211200
SparseFool (n =0.1,λ=1)97.6917116
+ +† 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. + +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. + +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. + +# 3 RESULTS + +# 3.1 SPARSEFOOL ATTACKS ON BINARY AND DVS DATA + +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. + +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. + +![](images/bf44d9285a8f0a54941f40020eea0e435fce080bc3e5f80ce61716ea4aaf1edd.jpg) +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. + +# 3.2 VALIDATION ON NEUROMORPHIC HARDWARE + +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. + +# 3.3 ADVERSARIAL PATCHES + +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. + +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. + +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. + +
Target labelHand clapRH WaveLH WaveRH ClockwiseRH Counter ClockwiseLH ClockwiseLH Counter ClockwiseArm RollAir DrumAir GuitarOther
Adversarial patch90.399.089.887.379.749.751.563.679.192.364.7
Adv. patch (on-chip)94.089.094.181.365.135.943.85.082.787.366.8
Random patch18.880.777.0003.60.60012.616.6
Rand. patch (on-chip)4376.872.2009.02.400017.7
+ +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. + +# 4 DISCUSSION + +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. + +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. + +# 5 ETHICS STATEMENT + +The authors aim to minimise the impact of potential attacks on deployed SNNs by contributing to overall understanding and supporting public discussion thereof. + +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. + +# 6 REPRODUCIBILITY STATEMENT + +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. + +# REFERENCES + +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. + +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. + +Alireza Bagheri, Osvaldo Simeone, and Bipin Rajendran. Adversarial training for probabilistic spiking neural networks, 2018. + +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. + +Battista Biggio and Fabio Roli. Wild patterns: Ten years after the rise of adversarial machine learning. Pattern Recognition, 84:317–331, 2018. + +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. + +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. + +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. + +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. + +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. + +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. + +Davide Falanga, Kevin Kleber, and Davide Scaramuzza. Dynamic obstacle avoidance for quadrotors with event cameras. Science Robotics, 5(40), 2020. + +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. + +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. + +Eric Jang, Shixiang Gu, and Ben Poole. Categorical reparameterization with gumbel-softmax, 2017. + +Diederik Kingma and Jimmy Ba. Adam: A method for stochastic optimization. International Conference on Learning Representations, 12 2014. + +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. + +Yann LeCun and Corinna Cortes. MNIST handwritten digit database. 2010. URL http://yann. lecun.com/exdb/mnist/. + +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. + +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. + +Shih-Chii Liu and Tobi Delbruck. Neuromorphic sensory systems. Current opinion in neurobiology, 20(3):288–295, 2010. + +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. + +Aleksander Madry, Aleksandar Makelov, Ludwig Schmidt, Dimitris Tsipras, and Adrian Vladu. Towards deep learning models resistant to adversarial attacks, 2019. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +# SUPPLEMENTARY MATERIAL + +# 1 EMPIRICAL ANALYSIS OF THE RESULTING SPARSEFOOL PERTURBATIONS + +![](images/444b0c52ae92cd71e1ea6763189dec7f34504600543b5509450acdd88d75a80a.jpg) +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. + +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. + +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. + +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. + +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. + +# 2 DEFENCE VIA ADVERSARIAL TRAINING + +![](images/7e4bd2a1a394038f6dfa9be7fe0f8e1150a1bf522c4c1e23267dedd7f1719380.jpg) +Figure S2: Success rate and median $L ^ { 0 }$ of SparseFool for networks trained with TRADES robustness based on PGD attacks. + +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: + +$$ +\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 ) . +$$ + +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. + +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. \ No newline at end of file diff --git a/md/dev/e42KbIw6Wb/e42KbIw6Wb.md b/md/dev/e42KbIw6Wb/e42KbIw6Wb.md new file mode 100644 index 0000000000000000000000000000000000000000..b66b7d35bbe67533aece7562eb88cea3ac2b18bf --- /dev/null +++ b/md/dev/e42KbIw6Wb/e42KbIw6Wb.md @@ -0,0 +1,351 @@ +# PIX2SEQ: A LANGUAGE MODELING FRAMEWORK FOR OBJECT DETECTION + +Ting Chen, Saurabh Saxena, Lala Li, David J. Fleet, Geoffrey Hinton Google Research, Brain Team + +# ABSTRACT + +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 + +![](images/eeabc6241e7e4c20b9c68ec0a08a1d07457092fdb01c02959db24a329c809bf4.jpg) +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. + +# 1 INTRODUCTION + +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. + +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. + +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. + +# 2 THE PIX2SEQ FRAMEWORK + +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): + +• 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). + +![](images/90efa70d655a4b173a2944d364ec27088fd401cd17f102b21635dbc065d864b2.jpg) +Figure 2: Major components of the Pix2Seq learning framework. + +# .1 SEQUENCE CONSTRUCTION FROM OBJECT DESCRIPTIONS + +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. + +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. + +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). + +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. + +![](images/e7d853efcb155a13641c6d07c67311db146c4d0dcc754d69ab8d68c9b6e7b63d.jpg) +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. + +![](images/18a067c504b06ba5a3509e594c2bb9e3c1ad8cae12197488eac4411657ed5033.jpg) +Figure 4: Examples of sequence construction with $n _ { \mathrm { b i n s } } = 1 0 0 0$ , and 0 is EOS token. + +![](images/6546d73d2a0f3ef2c8df262714154e793b81f6d52121183aa833adc8a48a8d96.jpg) + +# 2.2 ARCHITECTURE, OBJECTIVE AND INFERENCE + +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. + +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. + +Objective Similar to language modeling, Pix2Seq is trained to predict tokens, given an image and preceding tokens, with a maximum likelihood loss, i.e., + +$$ +\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 } ) ~ , +$$ + +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. + +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). + +# 2.3 SEQUENCE AUGMENTATION TO INTEGRATE TASK PRIORS + +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. + +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. + +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. + +![](images/1007b76bce732c368594be63140135714aa955169f7309ffc052b2b2794ab980.jpg) + +![](images/d5dad653c01cd0d23ebe40e03516667a5e3c8128559c56c5d69181dc1c77908c.jpg) +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. +Figure 6: Illustrations of randomly sampled noise objects (in white), vs. ground-truth objects (in red). + +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. + +# 3 EXPERIMENTS + +# 3.1 EXPERIMENTAL SETUP + +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. + +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. + +
MethodBackbone#paramsAPAP50AP75APsAPmAPL
Faster R-CNNR50-FPN42M40.261.043.824.243.552.0
Faster R-CNN+R50-FPN42M42.062.145.526.645.453.4
DETRR5041M42.062.444.220.545.861.1
Pix2seq (Ours)R5037M43.061.045.625.146.959.4
Faster R-CNNR101-FPN60M42.062.545.925.245.654.6
Faster R-CNN+R101-FPN60M44.063.947.827.248.156.0
DETRR10160M43.563.846.421.948.061.8
Pix2seq (Ours)R10156M44.562.847.526.048.260.3
Faster R-CNNR50-DC5166M39.060.542.321.443.552.5
Faster R-CNN+R50-DC5166M41.161.444.322.945.955.0
DETRR50-DC541M43.363.145.922.547.361.1
Pix2seq (Ours)R50-DC538M43.261.046.126.647.058.6
DETRR101-DC560M44.964.747.723.749.562.3
Pix2seq (Ours)R101-DC557M45.063.248.628.248.960.4
+ +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. + +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). + +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. + +# 3.2 MAIN COMPARISONS + +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. + +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. + +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. + +
Backbone# paramsImage size during finetuning
640×6401024×10241333×1333
R5037M39.141.742.6
R50-C485M44.746.947.3
ViT-B115M44.246.547.1
ViT-L341M47.649.050.0
+ +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. + +# 3.3 ABLATION ON SEQUENCE CONSTRUCTION + +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. + +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. + +![](images/a61b92c2f251d36bc2b9c76301682069c7146ed4bebaa07df62fc4f6d5c1dd05.jpg) +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. + +# 3.4 ABLATION ON SEQUENCE AUGMENTATION + +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. + +
SeqAug in PretrainSeqAug in FinetuneAPAR@100
×43.755.4
X44.561.6
44.761.7
+ +![](images/0464088e50fd283a641bc6a809a3dddcb169c6298f6ea0e60815952a79dcadff.jpg) +Figure 8: Impact of sequence augmentation on when training from scratch on COCO. + +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. + +# 3.5 VISUALIZATION OF DECODER’S CROSS ATTENTION MAP + +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. + +![](images/c8b7a6ed2f937a297c31036919a883739b7c318cc6c35c120e2bf4d4ba727a64.jpg) +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. + +# 4 RELATED WORK + +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. + +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. + +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. + +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). ¨ + +# 5 CONCLUSION AND FUTURE WORK + +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. + +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. + +# ACKNOWLEDGEMENTS + +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. + +# REFERENCES + +Dzmitry Bahdanau, Kyunghyun Cho, and Yoshua Bengio. Neural machine translation by jointly learning to align and translate. arXiv preprint arXiv:1409.0473, 2014. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +Ross Girshick. Fast r-cnn. In Proceedings of the IEEE International Conference on Computer Vision, pp. 1440–1448, 2015. + +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. + +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. + +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. + +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. + +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. + +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. + +Ari Holtzman, Jan Buys, Li Du, Maxwell Forbes, and Yejin Choi. The curious case of neural text degeneration. arXiv preprint arXiv:1904.09751, 2019. + +Andrew G Howard. Some improvements on deep convolutional neural network based image classification. arXiv preprint arXiv:1312.5402, 2013. + +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. + +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. + +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. + +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. + +Diederik P Kingma and Jimmy Ba. Adam: A method for stochastic optimization. arXiv preprint arXiv:1412.6980, 2014. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +Ilya Loshchilov and Frank Hutter. Decoupled weight decay regularization. In International Conference on Learning Representations, 2018. + +Eunbyung Park and Alexander C Berg. Learning to decompose for object detection and instance segmentation. arXiv preprint arXiv:1511.06449, 2015. + +Alec Radford, Karthik Narasimhan, Tim Salimans, and Ilya Sutskever. Improving language understanding by generative pre-training. 2018. + +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. + +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. + +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. + +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. + +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. + +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. + +Hamid Rezatofighi, Nathan Tsoi, JunYoung Gwak, Amir Sadeghian, Ian Reid, and Silvio Savarese. Generalized intersection over union. June 2019. + +Bernardino Romera-Paredes and Philip Hilaire Sean Torr. Recurrent instance segmentation. In European Conference on Computer Vision, pp. 312–329. Springer, 2016. + +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. + +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. + +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. + +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. + +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. + +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. + +Christian Szegedy, Alexander Toshev, and Dumitru Erhan. Deep neural networks for object detection. 2013. + +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. + +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. + +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. + +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. + +Yuxin Wu, Alexander Kirillov, Francisco Massa, Wan-Yen Lo, and Ross Girshick. Detectron2. https: //github.com/facebookresearch/detectron2, 2019. + +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. + +Xingyi Zhou, Dequan Wang, and Philipp Krahenb ¨ uhl. Objects as points. ¨ arXiv preprint arXiv:1904.07850, 2019. + +# A QUANTIZATION AND DEQUANTIZATION OF COORDINATES + +Algorithm 1 and 2 illustrate the quantization and dequantization process of (normalized) coordinates. + +# Algorithm 1 Quantization of (normalized) coordinates + +# Algorithm 2 Dequantization of discrete tokens of coordinates + +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)) + +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) + +# B TRAINING DETAILS + +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 + +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. + +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. + +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. + +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. + +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. + +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. + +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 + +$$ +\sum _ { { \pmb y } _ { j } \in V ^ { ( p ) } } P ( { \pmb y } _ { j } | { \pmb x } , { \pmb y } _ { 1 : j - 1 } ) \geq p . +$$ + +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. + +$$ +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. +$$ + +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. + +![](images/414025bf3a55a11ab0e93ae0f5c468d32d930d45b00ee10a7156bd881b95e784.jpg) +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). + +# D VISUALIZATION OF SIMILARITY AMONG COORDINATE TOKENS + +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. + +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). + +# E THE ABILITY TO DIRECT THE ATTENTION WITH GIVEN COORDINATES + +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. + +![](images/ada0a81261f79af4274cd8070ea4644893860bc799707def502632d81544ef86.jpg) +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. + +![](images/8df80ab15eb6133d3310161f53e2d79c25285c1d507b8829df00a3ee03862a35.jpg) +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. + +# F MORE VISUALIZATION ON DECODER’S CROSS ATTENTION + +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. + +![](images/43d57fc78b5add04ed0233299e489eb3c616d386dbeced06c84348ea760879cc.jpg) +Figure 13: Visualization of Transformer decoder’s cross attention (when predicting class tokens) conditioned on the given bounding boxes. + +# G VISUALIZATION OF DETECTION RESULTS + +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. + +![](images/b8c017b7082ef97864a53727ec5da2c581eb1e71521f273f41c1c1ed91390ef1.jpg) +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. \ No newline at end of file diff --git a/md/dev/fPhKeld3Okz/fPhKeld3Okz.md b/md/dev/fPhKeld3Okz/fPhKeld3Okz.md new file mode 100644 index 0000000000000000000000000000000000000000..0961a1fb68bf4985a60d4a5a7dc4eaa633335505 --- /dev/null +++ b/md/dev/fPhKeld3Okz/fPhKeld3Okz.md @@ -0,0 +1,783 @@ +# GRADIENT STEP DENOISER FOR CONVERGENT PLUGAND-PLAY + +Samuel Hurault ∗, Arthur Leclaire & Nicolas Papadakis Univ. Bordeaux, Bordeaux INP, CNRS, IMB, UMR 5251,F-33400 Talence, France + +# ABSTRACT + +Plug-and-Play $( \mathrm { P n P } )$ methods constitute a class of iterative algorithms for imaging problems where regularization is performed by an off-the-shelf denoiser. Although $\mathrm { P n P }$ methods can lead to tremendous visual performance for various image problems, the few existing convergence guarantees are based on unrealistic (or suboptimal) hypotheses on the denoiser, or limited to strongly convex data-fidelity terms. We propose a new type of $\mathrm { P n P }$ method, based on half-quadratic splitting, for which the denoiser is realized as a gradient descent step on a functional parameterized by a deep neural network. Exploiting convergence results for proximal gradient descent algorithms in the nonconvex setting, we show that the proposed $\mathrm { P n P }$ algorithm is a convergent iterative scheme that targets stationary points of an explicit global functional. Besides, experiments show that it is possible to learn such a deep denoiser while not compromising the performance in comparison to other state-of-the-art deep denoisers used in $\mathrm { P n P }$ schemes. We apply our proximal gradient algorithm to various ill-posed inverse problems, e.g. deblurring, superresolution and inpainting. For all these applications, numerical results empirically confirm the convergence results. Experiments also show that this new algorithm reaches state-of-the-art performance, both quantitatively and qualitatively. + +# 1 INTRODUCTION + +Image restoration (IR) problems can be formulated as inverse problems of the form + +$$ +x ^ { * } \in \arg \operatorname* { m i n } _ { x } f ( x ) + \lambda g ( x ) +$$ + +where $f$ is a term measuring the fidelity to a degraded observation $y$ , and $g$ is a regularization term weighted by a parameter $\lambda \geq 0$ . Generally, the degradation of a clean image $\hat { x }$ can be modeled by a linear operation $y = A { \hat { x } } + \xi$ , where $A$ is a degradation matrix and $\xi$ a white Gaussian noise. In this context, the maximum a posteriori (MAP) derivation relates the data-fidelity term to the likelihood $\begin{array} { r } { f ( x ) = - \log p ( y | x ) = \frac { \mathbf { \hat { \rho } } _ { 1 } } { 2 \sigma ^ { 2 } } | | A x - y | | ^ { 2 } } \end{array}$ , while the regularization term is related to the chosen prior. + +Regularization is crucial since it tackles the ill-posedness of the IR task by bringing a priori knowledge on the solution. A lot of research has been dedicated to designing accurate priors $g$ . Among the most classical priors, one can single out total variation (Rudin et al., 1992), wavelet sparsity (Mallat, 2009) or patch-based Gaussian mixtures (Zoran & Weiss, 2011). Designing a relevant prior $g$ is a difficult task and recent approaches rather apply deep learning techniques to directly learn a prior from a database of clean images (Lunz et al., 2018; Prost et al., 2021; Gonzalez et al., 2021). ´ + +Generally, the problem (1) does not have a closed-form solution, and an optimization algorithm is required. First-order proximal splitting algorithms (Combettes & Pesquet, 2011) operate individually on $f$ and $g$ via the proximity operator + +$$ +\operatorname* { P r o x } _ { f } ( x ) = \arg \operatorname* { m i n } _ { z } { \frac { 1 } { 2 } { \| x - z \| } ^ { 2 } } + f ( z ) . +$$ + +Among them, half-quadratic splitting (HQS) (Geman & Yang, 1995) alternately applies the proximal operators of $f$ and $g$ . Proximal methods are particularly useful when either $f$ or $g$ is nonsmooth. + +Plug-and-Play $( \mathrm { P n P } )$ methods (Venkatakrishnan et al., 2013) build on proximal splitting algorithms by replacing the proximity operator of $g$ with a generic denoiser, e.g. a pretrained deep network. + +These methods achieve state-of-the-art results (Buzzard et al., 2018; Ahmad et al., 2020; Yuan et al., 2020; Zhang et al., 2021) in various IR problems. However, since a generic denoiser cannot generally be expressed as a proximal mapping (Moreau, 1965), convergence results, which stem from the properties of the proximal operator, are difficult to obtain. Moreover, the regularizer $g$ is only made implicit via the denoising operation. Therefore, $\mathrm { P n P }$ algorithms do not seek the minimization of an explicit objective functional which strongly limits their interpretation and numerical control. + +In order to keep tractability of a minimization problem, Romano et al. (2017) proposed, with regularization by denoising (RED), an explicit prior $g$ that exploits a given generic denoiser $D$ in the form $g ( x ) = \overset { 1 } { \underset { 2 } { \cdot } } \langle x , x - \mathbf { \bar { \cal D } } ( x ) \rangle$ . With strong assumptions on the denoiser (in particular a symmetric Jacobian assumption), they show that it verifies + +$$ +\nabla _ { x } g ( x ) = x - D ( x ) . +$$ + +Such a denoiser is then plugged in gradient-based minimization schemes. Despite having shown very good results on various image restoration tasks, as later pointed out by Reehorst & Schniter (2018) or Saremi (2019), existing deep denoisers lack Jacobian symmetry. Hence, RED does not minimize an explicit functional and is not guaranteed to converge. + +Contributions. In this work, we develop a $\mathrm { P n P }$ scheme with novel theoretical convergence guarantees and state-of-the-art IR performance. Departing from the PnP-HQS framework, we plug a denoiser that inherently satisfies equation (3) without sacrificing the denoising performance. The resulting fixed-point algorithm is guaranteed to converge to a stationary point of an explicit functional. This convergence guarantee does not require strong convexity of the data-fidelity term, thus encompassing ill-posed IR tasks like deblurring, super-resolution or inpainting. + +# 2 RELATED WORKS + +PnP methods have been successfully applied in the literature with various splitting schemes: HQS (Zhang et al., 2017b; 2021), ADMM (Romano et al., 2017; Ryu et al., 2019), Proximal Gradient Descent (PGD) (Terris et al., 2020). First used with classical non deep denoisers such as BM3D (Chan et al., 2016) and pseudo-linear denoisers (Nair et al., 2021; Gavaskar et al., 2021), more recent PnP approaches (Meinhardt et al., 2017; Ryu et al., 2019) rely on efficient off-theshelf deep denoisers such as DnCNN (Zhang et al., 2017a). State-of-the-art IR results are currently obtained with denoisers that are specifically designed to be integrated in PnP schemes, like IRCNN (Zhang et al., 2017b) or DRUNET (Zhang et al., 2021). Though providing excellent restorations, such schemes are not guaranteed to converge for all kinds of denoisers or IR tasks. + +Designing convergence proofs for $\mathrm { P n P }$ algorithms is an active research topic. Sreehari et al. (2016) used the proximal theorem of Moreau (Moreau, 1965) to give sufficient conditions for the denoiser to be an explicit proximal map, which are applied to a pseudo-linear denoiser. The convergence with pseudo-linear denoisers have been extensively studied (Gavaskar & Chaudhury, 2020; Nair et al., 2021; Chan, 2019). However, state-of-the-art PnP results are obtained with deep denoisers. Various assumptions have been made to ensure the convergence of the related PnP schemes. With a “bounded denoiser” assumption, Chan et al. (2016); Gavaskar & Chaudhury (2019) showed convergence of PnP-ADMM with stepsizes decreasing to 0. RED (Romano et al., 2017) and RED-PRO (Cohen et al., 2021) respectively consider the classes of denoisers with symmetric Jacobian or demicontractive mappings, but these conditions are either too restrictive or hard to verify in practice. In Appendix A.3, more details are given on RED-based methods. Many works focus on Lipschitz properties of $\mathrm { P n P }$ operators. Depending on the splitting algorithm in use, convergence can be obtained by assuming the denoiser averaged (Sun et al., 2019b), firmly nonexpansive (Sun et al., 2021; Terris et al., 2020) or simply nonexpansive (Reehorst & Schniter, 2018; Liu et al., 2021). These settings are unrealistic as deep denoisers do not generally satisfy such properties. Ryu et al. (2019); Terris et al. (2020) propose different ways to train deep denoisers with constrained Lipschitz constants, in order to fit the technical properties required for convergence. But imposing hard Lipschitz constraints on the network alters its denoising performance (Bohra et al., 2021; Hertrich et al., 2021). Yet, Ryu et al. (2019) manages to get a convergent PnP scheme without assuming the nonexpansiveness of $D$ . This comes at the cost of imposing strong convexity on the data-fidelity term $f$ , which excludes many IR tasks like deblurring, super-resolution or inpainting. Hence, given the ill-posedness of IR problems, looking for a unique solution via contractive operators is a restrictive assumption. In this work, we do not impose contractiveness, but still obtain convergence results with realistic hypotheses. + +One can relate the ideal deep denoiser to the “true” natural image prior $p$ via Tweedie’s Identity. In (Efron, 2011), it is indeed shown that the Minimum Mean Square Error (MMSE) denoiser $D _ { \sigma } ^ { * }$ (at noise level $\sigma$ ) verifies $D _ { \sigma } ( x ) = x + \sigma ^ { 2 } \nabla _ { x } \log p _ { \sigma } ( x )$ where $p _ { \sigma }$ is the convolution of $p$ with the density of ${ \mathcal { N } } ( 0 , \sigma ^ { 2 } \operatorname { I d } )$ . In a recent line of research (Bigdeli et al., 2017; Xu et al., 2020; Laumont et al., 2021; Kadkhodaie & Simoncelli, 2020), this relation is used to plug a denoiser in gradient-based dynamics. In practice, the MMSE denoiser cannot be computed explicitly and Tweedie’s Identity does not hold for deep approximations of the MMSE. In order to be as exhaustive as possible, we detailed the addressed limitations of existing $\mathrm { P n P }$ methods in Appendix A.1. + +# 3 THE GRADIENT STEP PLUG-AND-PLAY + +The proposed method is based on the $\mathrm { P n P }$ version of half-quadratic-splitting (PnP-HQS) that amounts to replacing the proximity operator of the prior $g$ with an off-the-shelf denoiser $D _ { \sigma }$ . In order to define a convergent $\mathrm { P n P }$ scheme, we first set up in Section 3.1 a Gradient Step (GS) denoiser. We then introduce the Gradient Step PnP (GS-PnP) algorithm in Section 3.2. + +# 3.1 GRADIENT STEP DENOISER + +We propose to plug a denoising operator $D _ { \sigma }$ that takes the form of a gradient descent step + +$$ +D _ { \sigma } = \mathrm { I d } - \nabla g _ { \sigma } , +$$ + +with $g _ { \sigma } : \mathbb { R } ^ { n } \mathbb { R }$ . Contrary to Romano et al. (2017), our denoiser exactly represents a conservative vector field. The choice of the parameterization of $g _ { \sigma }$ is fundamental for the denoising performance. As already noticed in Salimans & Ho (2021), we experimentally found that directly modeling $g _ { \sigma }$ as a neural network (e.g. a standard network used for classification) leads to poor denoising performance. In order to keep the strength of state-of-the-art unconstrained denoisers, we rather use + +$$ +\begin{array} { l } { \displaystyle { g _ { \sigma } ( x ) = \frac { 1 } { 2 } | | x - N _ { \sigma } ( x ) | | ^ { 2 } , } } \\ { \displaystyle { D _ { \sigma } ( x ) = x - \nabla g _ { \sigma } ( x ) = N _ { \sigma } ( x ) + J _ { N _ { \sigma } } ( x ) ^ { T } ( x - N _ { \sigma } ( x ) ) , } } \end{array} +$$ + +where $N _ { \sigma } : \mathbb { R } ^ { n } \mathbb { R } ^ { n }$ is parameterized by a neural network and $J _ { N _ { \sigma } } ( x )$ is the Jacobian of $N _ { \sigma }$ at point $x$ . As discussed in Appendix A.2, the formulation (5) for $g _ { \sigma }$ has been proposed in (Romano et al., 2017, Section 5.2) and (Bigdeli & Zwicker, 2017) for a distinct but related purpose, and not exploited for convergence analysis. Thanks to our definition (6) for $D _ { \sigma }$ , we can parameterize $N _ { \sigma }$ with any differentiable neural network architecture $\mathbb { R } ^ { n } \to \mathbb { R } ^ { n }$ that has proven efficient for image denoising. Although the representation power of the denoiser is limited by the particular form (6), we show (see Section 5.1) that such parameterization still yields state-of-the-art denoising results. We train the denoiser $D _ { \sigma }$ for Gaussian noise by minimizing the MSE loss function + +$$ +\begin{array} { r l } & { \quad \mathcal { L } ( D _ { \sigma } ) = \mathbb { E } _ { x \sim p , \xi _ { \sigma } \sim \mathcal { N } ( 0 , \sigma ^ { 2 } I ) } [ | | D _ { \sigma } ( x + \xi _ { \sigma } ) - x | | ^ { 2 } ] , } \\ & { \mathrm { o r } \mathcal { L } ( g _ { \sigma } ) = \mathbb { E } _ { x \sim p , \xi _ { \sigma } \sim \mathcal { N } ( 0 , \sigma ^ { 2 } I ) } [ | | \nabla g _ { \sigma } ( x + \xi _ { \sigma } ) - \xi _ { \sigma } | | ^ { 2 } ] , } \end{array} +$$ + +when written in terms of $g _ { \sigma }$ using equation (4). + +Remark 1. By definition, the optimal solution $g _ { \sigma } ^ { * } \in \arg \operatorname* { m i n } \mathcal { L }$ is related to the MMSE denoiser $D _ { \sigma } ^ { * }$ , that is, the best non-linear predictor of $x$ given $x + \xi _ { \sigma }$ . Therefore, it satisfies Tweedie’s formula and $\nabla g _ { \sigma } ^ { * } = - \sigma ^ { 2 } \nabla \log p _ { \sigma }$ (Efron, 2011) i.e. $g _ { \sigma } ^ { * } = \bar { - } \sigma ^ { 2 } \log p _ { \sigma } + C$ , for some $C \ \in \ \mathbb { R }$ . Hence approximating the MMSE denoiser with a denoiser parameterized as (4) is related to approximating the logarithm of the smoothed image prior of $p _ { \sigma }$ with $- \frac { 1 } { \sigma ^ { 2 } } g _ { \sigma }$ . This relation was used for image generation with “Denoising Score Matching” by Saremi & Hyvarinen (2019); Bigdeli et al. (2020). + +# 3.2 A PLUG-AND-PLAY METHOD FOR EXPLICIT MINIMIZATION + +The standard PnP-HQS operator is $T _ { \mathrm { P n P - H Q S } } = D _ { \sigma } \circ \mathrm { P r o x } _ { \tau f }$ , i.e. $( \mathrm { I d } - \nabla g _ { \sigma } ) \circ \mathrm { P r o x } _ { \tau f }$ when using the GS denoiser as $D _ { \sigma }$ . For convergence analysis, we wish to fit the proximal gradient descent (PGD) algorithm. We thus propose to switch the proximal and gradient steps and to relax the denoising step with a parameter $\lambda \geq 0$ . Our $\mathrm { P n P }$ algorithm with GS denoiser $\mathrm { \Delta G S { - } P n P } ,$ ) then writes + +$$ +\begin{array} { l l l } { x _ { k + 1 } = T _ { \mathrm { G S - P n P } } ^ { \tau , \lambda } ( x _ { k } ) \mathrm { ~ w i t h ~ } T _ { \mathrm { G S - P n P } } ^ { \tau , \lambda } } & { = } & { \mathrm { P r o x } _ { \tau f } \circ ( \tau \lambda D _ { \sigma } + ( 1 - \tau \lambda ) \mathrm { I d } ) , } \\ & { = } & { \mathrm { P r o x } _ { \tau f } \circ ( \mathrm { I d } - \tau \lambda \nabla g _ { \sigma } ) . } \end{array} +$$ + +Under suitable conditions on $f$ and $g _ { \sigma }$ (see Lemma 1 in Appendix C), fixed points of the PGD operator $T _ { \mathrm { G S - P n P } } ^ { \tau , \lambda }$ correspond to critical points of a classical objective function in IR problems + +$$ +F ( x ) = f ( x ) + \lambda g _ { \sigma } ( x ) . +$$ + +Therefore, using the GS denoiser from equation (4) is equivalent to include an explicit regularization and thus leads to a tractable global optimization problem solved by the $\mathrm { P n P }$ algorithm. Our complete $\mathrm { P n P }$ scheme is presented in Algorithm 1. It includes a backtracking procedure on the stepsize $\tau$ that will be detailed in Section 4.2. Also, after convergence, we found it useful to apply an extra gradient step $\mathrm { I d } - \lambda \tau \nabla g _ { \sigma }$ in order to discard the residual noise brought by the last proximal step $\operatorname { P r o x } _ { \tau f }$ . + +# 4 CONVERGENCE ANALYSIS + +In this section, we introduce conditions on $f$ and $D _ { \sigma }$ that will ensure the convergence of the $\mathrm { P n P }$ iterations (9) towards a solution of (10). For that purpose, we make use of the literature of convergence analysis (Attouch et al., 2013; Beck, 2017; Beck & Teboulle, 2009) of the PGD algorithm in the nonconvex setting. + +# 4.1 CONVERGENCE RESULTS + +A common setting for image restoration is the convex smooth $L ^ { 2 }$ data-fidelity $f ( x ) = | | A x - y | | ^ { 2 }$ . In order to cover the + +# Algorithm 1: Plug-and-Play image restoration + +Param.: init. $z _ { \mathrm { 0 } }$ , $\lambda > 0$ , σ ≥ 0,  > 0, $\tau _ { 0 } > 0$ , $K \in \mathbb { N } ^ { * } , \eta \in ( 0 , 1 ) , \gamma \in ( 0 , 1 / 2 ) .$ +Input : degraded image $y$ . +Output: restored image $\hat { x }$ . +$k = 0$ ; $x _ { 0 } = \mathrm { P r o x } _ { \tau f } ( \bar { z } _ { 0 } )$ ; $\tau = \tau _ { 0 } / \eta ; \Delta > \epsilon$ ; +while $k < K$ and $\Delta > \epsilon$ do $z _ { k } = \lambda \tau D _ { \sigma } ( x _ { k } ) + ( 1 - \lambda \tau ) x _ { k }$ ; $x _ { k + 1 } = \operatorname { P r o x } _ { \tau f } ( z _ { k } )$ ; if $\begin{array} { r } { { \cal T } ( x _ { k } ) - { \cal F } ( x _ { k + 1 } ) < \frac { \gamma } { \tau } | | x _ { k } - x _ { k + 1 } | | ^ { 2 } . } \end{array}$ ; then $\tau = \eta \tau$ ; else $\begin{array} { r } { \Delta = \frac { F ( x _ { k } ) - F ( x _ { k + 1 } ) } { F ( x _ { 0 } ) } } \end{array}$ F (xk)−F (xk+1) ; k = k + 1 ; +end +$\hat { x } = \lambda \tau D _ { \sigma } ( x _ { K } ) + ( 1 - \lambda \tau ) x _ { K } ;$ + +noiseless case or to deal with a broader range of common degradation models, like Laplace or Poisson noise, we only assume $f$ to be proper, lower semicontinous and convex. Next, the regularizer $g _ { \sigma }$ is assumed to be differentiable with Lipschitz gradient, but not necessarily convex. This assumption on $g _ { \sigma }$ is reasonable from a practical perspective. Indeed, using a network $N _ { \sigma }$ with differentiable activation functions, the function $g _ { \sigma }$ introduced in Section 3 is differentiable with Lipschitz gradient (details and proof are given in Appendix B). Without further assumptions on $f$ and $g _ { \sigma }$ , the following theorem establishes the convergence of both the objective function values and the residual for a large variety of IR tasks. + +Theorem 1 (Proof in Appendix C). Let $f : \mathbb { R } ^ { n } \mathbb { R } \cup \{ + \infty \}$ and $g _ { \sigma } : \mathbb { R } ^ { n } \mathbb { R }$ be proper lower semicontinous functions with $f$ convex and $g _ { \sigma }$ differentiable with $L$ -Lipschitz gradient. Let $\lambda > 0$ , $F = f + \lambda g _ { \sigma }$ and assume that $F$ is bounded from below. Then, for $\begin{array} { r } { \tau < \frac { 1 } { \lambda L } } \end{array}$ , the iterates $x _ { k }$ given by the iterative scheme (9) verify + +(i) $( F ( x _ { k } ) )$ is non-increasing and converges. + +(ii) The residual $| | x _ { k + 1 } - x _ { k } | |$ converges to 0. + +(iii) All cluster points of the sequence $( x _ { k } )$ are stationary points of $( I O )$ . + +Remark 2. In the nonconvex setting, the quantity $\begin{array} { r } { \gamma _ { k } = \operatorname* { m i n } _ { 0 \leq i \leq k } | | x _ { i + 1 } - x _ { i } | | ^ { 2 } } \end{array}$ is commonly used to analyze the convergence rate of the algorithm (Beck & Teboulle, 2009; Ochs et al., 2014). Following the proof of Theorem 1 in Appendix $C _ { i }$ , we can obtain $\begin{array} { r } { \gamma _ { k } \leq \frac { 1 } { k } \frac { F ( x _ { 0 } ) - \operatorname* { l i m } F ( x _ { k } ) } { \frac { 1 } { 2 \tau } - \frac { L } { 2 } } } \end{array}$ 1 F (x0)−lim F (xk) that is to say a $\mathcal { O } \big ( \textstyle { \frac { 1 } { k } } \big )$ convergence rate for the squared $L ^ { 2 }$ residual. + +Remark 3. Even if most data-fidelity terms $f$ encountered in image restoration are convex, Theorem 1 can be extended to nonconvex $f$ . The proof of (iii) requires technical adaptations that can be found in Li & Lin (2015, Theorem 1) (as the $^ { l }$ -Lipschitz property of $\operatorname { P r o x } _ { \tau f }$ does not hold anymore). Such nonconvex $f$ appear for example in the context of phase retrieval (Metzler et al., 2018). + +We can further obtain convergence of the iterates by assuming that the generated sequence $( x _ { k } )$ is bounded and that $f$ and $g _ { \sigma }$ verify the Kurdyka-Lojasiewicz (KL) property. The boundedness of $( x _ { k } )$ is discussed in Appendix D. The KL property (defined in Appendix E) has been widely used to study the convergence of optimization algorithms in the nonconvex setting (Attouch et al., 2010; 2013; Ochs et al., 2014). Very large classes of functions, in particular all the semi-algebraic functions, satisfy this property. In practice, in the extent of our analysis, the KL property is always satisfied. + +Theorem 2 (Proof in Attouch et al. (2013), Theorem 5.1). Let $f ~ : ~ \mathbb { R } ^ { n } ~ \to ~ \mathbb { R } ~ \cup ~ \{ + \infty \}$ and $g _ { \sigma } : \mathbb { R } ^ { n } \mathbb { R }$ be proper lower semicontinous functions with $f$ convex and $g _ { \sigma }$ differentiable with $L$ -Lipschitz gradient. Let $\lambda > 0$ , $F = f + \lambda g _ { \sigma }$ and assume that $F$ is bounded from below. Assume that $F$ verify the $K L$ property. Suppose that $\begin{array} { r } { \tau < \frac { 1 } { \lambda L } } \end{array}$ . If the sequence $( x _ { k } )$ given by the iterative scheme (9) is bounded, then it converges, with finite length, to a critical point $x ^ { * }$ of $F$ . + +Remark 4. As explained in Attouch et al. (2013, Remark 5.2), the continuity of $f$ is not required since we use the “exact forward-backward splitting algorithm”. We can thus deal with non-continuous data-fidelity terms, as it is the case with the inpainting application in Appendix J.3. + +A more detailed description of all the assumptions of Theorems 1 and 2 is given in Appendix F. + +4.2 BACKTRACKING TO HANDLE THE LIPSCHITZ CONSTANT OF $\nabla g _ { \sigma }$ + +The convergence of Algorithm 1 actually requires to control the Lipschitz constant of $\nabla g _ { \sigma }$ only on a small subset of images related to $\{ x _ { k } \}$ . Therefore, estimating $L$ for all images and setting the maximum stepsize $\tau$ accordingly will lead to sub-optimal convergence speed. In order to avoid small stepsizes, we use the backtracking strategy of Beck (2017, Chapter 10) and Ochs et al. (2014). + +The convergence study in the proof of Theorem 1 is based on the sufficient decrease property of $F$ established in equation (33). Without knowing the exact Lipschitz constant $L$ , backtracking aims at finding the maximal stepsize $\tau$ yielding the sufficient decrease property. Given $\gamma \in ( 0 , 1 / 2 )$ , $\eta \in [ 0 , 1 \bar { ) }$ and an initial stepsize $\tau _ { 0 } > 0$ , the following update rule on $\tau$ is applied at each iteration $k$ : + +$$ +\mathrm { w h i l e } \quad F ( x _ { k } ) - F ( T _ { \mathrm { G S - P n P } } ^ { \tau , \lambda } ( x _ { k } ) ) < \frac { \gamma } { \tau } | | T _ { \mathrm { G S - P n P } } ^ { \tau , \lambda } ( x _ { k } ) - x _ { k } | | ^ { 2 } , \quad \tau \longleftarrow \eta \tau . +$$ + +Proposition 1 (Proof in Appendix $\mathbf { G }$ ). Under the assumptions of Theorem $^ { l }$ , at each iteration of the algorithm, the backtracking procedure $( l I )$ is finite (i.e. a stepsize satifying $\begin{array} { r } { F ( x _ { k } ) - F ( T _ { G S - P n P } ^ { \tau , \lambda } ( x _ { k } ) ) \ge \frac { \gamma } { \tau } | | T _ { G S - P n P } ^ { \tau , \lambda } ( x _ { k } ) - x _ { k } | | ^ { 2 } } \end{array}$ is found in a finite number if iterations), and with backtracking, the convergence results of Theorem $^ { l }$ and Theorem 2 still hold. + +Remark 5. In practice, as explained in Section 5, we choose to initialize the stepsize as $\lambda \tau _ { 0 } = 1$ and backtracking hardly ever activates. In this particular case, our results prove convergence of the standard PnP-HQS scheme $x _ { k + 1 } = \mathrm { P r o x } _ { \tau f } \circ D _ { \sigma } ( x _ { k } )$ applied with our specific denoiser. + +# 5 EXPERIMENTS + +In this section, we first show the performance of the GS denoiser. Next we empirically confirm that our GS-PnP method is convergent while providing state-of-the art results for different IR tasks. + +# 5.1 GRADIENT-DESCENT-BASED DENOISER + +Denoising Network Architecture We choose to parameterize $N _ { \sigma }$ with the architecture DRUNet (Zhang et al., 2021)) (represented in Appendix H), a U-Net in which residual blocks are integrated. One first benefit of DRUNet is that it is built to take the noise level $\sigma$ as input, which is consistent with our formulation. Also, the U-Net models have previously offered good results in the context of prior approximation via Denoising Score Matching (Ho et al., 2020). Furthermore, Zhang et al. (2021) showed that DRUNet yields state-of-the-art results for denoising but also for $\mathrm { P n P }$ image restoration. In order to ensure differentiability w.r.t the input, we change RELU activations to ELU. We also limit the number of residual blocks to 2 at each scale to lower the computational burden. + +Training details We use the color image training dataset proposed in Zhang et al. (2021) i.e. a combination of the Berkeley segmentation dataset (CBSD) (Martin et al., 2001), Waterloo Exploration Database (Ma et al., 2017), DIV2K dataset (Agustsson & Timofte, 2017) and Flick2K dataset (Lim et al., 2017). During training, the input images are corrupted with a white Gaussian noise $\xi _ { \sigma }$ with standard deviation $\sigma$ randomly chosen in $[ 0 , \bar { 5 } 0 / 2 5 5 ]$ . With our parameterization (6) of $D _ { \sigma }$ , the network $N _ { \sigma }$ is trained to minimize the $L ^ { 2 }$ loss (7). While the original DRUNet is trained with $L ^ { 1 }$ loss, we stick to the $L ^ { 2 }$ loss to keep the interpretability of $g _ { \sigma }$ as an approximation of the log prior (see Remark 1). For each batch, the gradient $\nabla g _ { \sigma }$ is computed with PyTorch differentiation tools. + +We train the model on $1 2 8 \times 1 2 8$ patches randomly sampled from the training images, with batch size 16, during 1500 epochs. We use the ADAM optimizer with learning rate $1 0 ^ { - \overline { { 4 } } }$ , divided by 2 every 300 epochs. It takes around one week to train the model on a single Tesla P100 GPU. + +Denoising results We evaluate the PSNR performance of the proposed GS denoiser (GS-DRUNet) on $2 5 6 \times 2 5 6$ color images center-cropped from the original CBSD68 dataset images (Martin et al., 2001). In Table 1, we compare, for various noise levels $\sigma$ , our model with the simplified DRUNet (called “DRUNet light”) that has the same architecture as our GS-DRUNet (2 residual blocks) and that is trained (with $\overline { { L ^ { 2 } } }$ loss) without the conservative field constraint. We also provide comparisons with the original DRUNet (Zhang et al., 2021) (with 4 residual blocks at each scale and trained with $L ^ { 1 }$ loss) and two state-of-the-art denoisers encountered in the $\mathrm { P n P }$ literature: FFDNet (Zhang et al., 2018) and DnCNN (Zhang et al., 2017a). For each network, we indicate in Table 1 the average runtime while processing a $2 5 6 \times 2 5 6$ color image on one Tesla P100 GPU. + +Our GS-DRUNet denoiser, despite being constrained to be an exact conservative field, reaches the performance of (and even slightly outperforms) its unconstrained counterpart DRUNet light. Second, departing from the latter, we are able to reduce the processing time by a large margin $( \div 7 )$ while keeping close PSNR to the original DRUNet (around -0.05dB) and maintaining a significant PSNR gap (around $+ 0 . 5 \mathrm { d B } )$ with other deep denoisers like DnCNN and FFDNet. Note that the time difference between GS-DRUNet and DRUNet light is due to the computation of $\nabla g _ { \sigma }$ via backpropagation. These results indicate that GS-DRUNet is likely to yield a competitive and fast $\mathrm { P n P }$ algorithm. + +Table 1: Average PSNR denoising performance and runtime of our GS denoiser on $2 5 6 \times 2 5 6$ center-cropped images from the CBSD68 dataset, for various noise levels $\sigma$ . While keeping small runtime, GS-DRUNet slightly outperforms its unconstrained counterpart DRUNet light and outdistances the deep denoisers FFDNet and DnCNN. + +
σ(./255)5152550Time (ms)
FFDNet DnCNN39.95 39.8033.53 33.5530.84 30.8727.54 27.521.9 2.3
DRUNet40.3133.9731.3228.0869.8
DRUNet light40.1933.8931.2528.006.3
GS-DRUNet40.2633.9031.2628.0110.4
+ +# 5.2 PLUG-AND-PLAY IMAGE RESTORATION + +We show in this section that, in addition to being convergent, our $\mathrm { P n P }$ Alg. 1 reaches state-of-the-art performance in deblurring and super-resolution (Sections 5.2.1 and 5.2.2) and realizes relevant inpainting (Appendix J.3). In all cases, we seek an estimate $x$ of a clean image $\hat { x } \in \mathbb { R } ^ { n }$ , from an observation obtained as $y = A \hat { x } + \xi _ { \nu } \in \mathbb { R } ^ { m }$ , with $A$ a $m \times n$ degradation matrix and $\xi _ { \nu }$ a white Gaussian noise with zero mean and standard deviation $\nu$ . The objective function minimized by Alg. 1 is + +$$ +F ( x ) = \frac { 1 } { 2 \nu ^ { 2 } } | | A x - y | | ^ { 2 } + \frac { \lambda } { 2 } | | N _ { \sigma } ( x ) - x | | ^ { 2 } . +$$ + +In practice, for $\nu > 0$ , we multiply $F$ in equation (12) by $\nu ^ { 2 }$ and consider $F = f + \lambda _ { \nu } g _ { \sigma }$ with $\begin{array} { r } { f ( \dot { x } ) = \frac { 1 } { 2 } | | A x - y | | ^ { 2 } . } \end{array}$ , $\begin{array} { r } { g _ { \sigma } ( x ) = \frac { 1 } { 2 } \bar { | | } \bar { N } _ { \sigma } ( x ) - \bar { x } | | ^ { 2 } } \end{array}$ and $\lambda _ { \nu } = \lambda \nu ^ { 2 }$ . With this formulation, the convergences of iterates and objective values are guaranteed by Theorems 1 and 2. We also demonstrate in Appendix J.3 that our framework can be extended to other kinds of objective functions. For example, inpainting noise-free input images leads to a non differentiable data-fidelity term $f$ . + +Due to the large computational time of some compared methods, we use for evaluation and comparison a subset of 10 color images taken from the CBSD68 dataset (CBSD10) together with the 3 famous set3C images (butterfly, leaves and starfish). Quantitative results run on the full CBSD68 dataset are given in Appendix J. All images are center-cropped to the size $2 5 6 \times 2 5 6$ . For each IR problem, we provide default values for the parameters $\sigma$ and $\lambda$ that can be used to treat sucessfully a large class of images and degradations. The influence of both parameters is analyzed in Appendix J.5. Performance can be marginally improved by tuning $\lambda$ for each image, for example with the method of Wei et al. (2020) based on reinforcement learning. In our experiments, backtracking is performed with $\eta = 0 . 9$ and $\gamma = 0 . 1$ . We observe (see Appendix B) that on a majority of images, the Lipschitz constant $L$ of $\nabla g _ { \sigma }$ is slightly larger than 1. As convergence is ensured for $\lambda _ { \nu } \tau \stackrel { } { = } \nu ^ { 2 } \lambda \tau < \stackrel { } { \frac { \pi } { L } }$ , we set the initial stepsize to $\tau _ { 0 } = ( \nu ^ { 2 } \lambda ) ^ { - 1 }$ . At the first iteration, the gradient step in equation (9) is thus exactly $D _ { \sigma }$ . In the majority of our experiments, backtracking is never activated. The algorithm is initialized with a proximal step and terminates when the relative difference between consecutive values of the objective function is less than $\epsilon$ or the number of iterations exceeds $K$ . + +# 5.2.1 DEBLURRING + +For image deblurring, the degradation operator $A = H$ is a convolution performed with circular boundary conditions. Therefore, $H = { \mathcal { F } } ^ { * } \Lambda { \mathcal { F } }$ , where $\mathcal { F }$ is the orthogonal matrix of the discrete Fourier transform (and ${ \mathcal { F } } ^ { * }$ its inverse), and $\Lambda$ is a diagonal matrix. The proximal operator of the data-fidelity term $\begin{array} { r } { f ( x ) = \frac { 1 } { 2 } | | H x - y | | ^ { 2 } } \end{array}$ involves only element-wise inversion and writes + +$$ +\operatorname* { P r o x } _ { \tau f } ( z ) = \mathcal { F } ^ { * } ( I _ { n } + \tau \Lambda ^ { * } \Lambda ) ^ { - 1 } \mathcal { F } ( \tau H ^ { T } y + z ) . +$$ + +We demonstrate the effectiveness of our method on a large variety of blur kernels (represented in Table 2) and noise levels. As in (Zhang et al., 2017b; Pesquet et al., 2021; Zhang et al., 2021), we use the 8 real-world camera shake kernels proposed in Levin et al. (2009) as well as the $9 \times 9$ uniform kernel and the $2 5 \times 2 5$ Gaussian kernel with standard deviation 1.6 (as in (Romano et al., 2017)). We consider Gaussian noise with 3 noise levels $\nu \in \{ 2 . 5 5 , 7 . 6 5 , 1 2 . 7 5 \} / 2 5 5 i .$ e. $\nu \in \{ 0 . 0 1 , 0 . 0 3 , 0 . 0 5 \}$ . For all noise levels, we set $\sigma = 1 . 8 \nu$ , $\lambda _ { \nu } = \bar { \nu ^ { 2 } } \lambda = 0 . 1$ for motion blur (kernels (a) to (h)) and $\lambda _ { \nu } = 0 . 0 7 5$ for static blur (kernels (i) and (j)). Initialization is done with $z _ { 0 } = y$ but we show in Appendix J.6 the robustness to the initialization. The stopping criteria are $\epsilon = 1 0 ^ { - 5 }$ and $K = 4 0 0$ . + +We compare in Table 2 our method $( \mathrm { G S \mathrm { - } P n P } )$ ) against the patch-based method EPLL (Zoran & Weiss, 2011; Hurault et al., 2018), the deep $\mathrm { P n P }$ methods IRCNN (Zhang et al., 2017b), DPIR (Zhang et al., 2021), MMO (Pesquet et al., 2021), and the “RED-FP” algorithm (Romano et al., 2017) (with TNRD denoiser (Chen & Pock, 2016)) referred to as RED. Both IRCNN and DPIR use PnP-HQS with a fast decrease of $\tau$ and $\sigma$ in a few iterations (8 iterations for DPIR) without guarantee of convergence. DPIR uses the DRUNet denoiser from Table 1. MMO is the only compared method that guarantees convergence by plugging a DnCNN denoiser trained with Lipschitz constraints (but the only given network was trained for very low noise level). Finally, as RED only treats the Y channel in the YCbCr color space, we also indicate in Appendix J.1, for RED and the proposed method, the PSNR evaluated on the Y channel only. + +Among all methods, $\mathrm { G S - P n P }$ closely follows DPIR in terms of PSNR for low noise level but performs equally or better for higher noise levels. Other comparisons are conducted in Appendix J.1 on the Set3c and the full CBSD68 datasets (Tables 4 and 5). These results exhibit that $\mathrm { G S - P n P }$ reaches state-of-the-art in $\mathrm { P n P }$ deblurring for a variety of kernels and noise levels. We underline that the convergence of $\mathrm { G S - P n P }$ is guaranteed, whereas DPIR can asymptotically diverge (see Appendix J.7). + +
vMethod(a) (b) (c) (d) (e)(f) (g)(h) i(iAvg
11
EPLL28.3228.2428.3625.8029.6127.1526.9026.6925.8426.4927.34
RED30.4730.0130.2928.0931.2228.9228.9028.6726.6628.4529.17
IRCNN32.9632.6232.5332.4433.5133.6232.5432.2028.1129.1931.97
MMO32.3532.0632.2431.6731.77 33.1732.3031.8027.8129.2631.44
DPIR33.7633.3033.0433.0934.10 34.3433.0632.7728.3429.1632.50
GS-PnP33.52 33.0732.91 32.8334.07 34.2532.96 32.54 28.11 29.0332.33
EPLL25.3125.1225.82 23.7526.99 25.2325.00 24.5924.34 25.4325.16
RED0IRCNN25.7125.3225.71 24.3826.65 25.5025.27 24.9923.51 25.5425.26
28.9628.6528.90 28.3830.03 29.8728.92 28.5225.92 27.6428.58
IRCNN28.9628.6528.90 28.3830.03 29.8728.92 28.5225.92 27.6428.58
DPIR29.38 29.06 29.21 28.7730.22 30.23 29.34 28.90 26.19 27.8128.91
GS-PnP29.22 28.89 29.20 28.60 30.32 30.21 29.32 28.92 26.38 27.8928.90
EPLL24.08 23.9124.78 22.57 25.68 23.98 23.70 23.1923.75 24.7824.04
RED22.78 22.5423.13 21.92 23.78 22.97 22.89 22.6722.01 23.7822.84
IRCNN 27.00 26.7427.25 26.37 28.29 28.06 27.22 26.81 24.85 26.8326.94
DPIR 27.5227.35 27.73 27.02 28.63 28.46 27.79 27.30 25.25 27.1127.42
GS-PnP27.45 27.28 27.70 26.98 28.68 28.44 27.81 27.38 25.49 27.1527.44
+ +Table 2: PSNR(dB) comparison of image deblurring methods on CBSD10 with various blur kernels $k$ and noise levels $\nu$ . Best and second best results are displayed in bold and underlined. + +For qualitative comparison, we show in Figure 1(c-f) the deblurring obtained with various methods on the image “starfish” (from set3C). Note that our algorithm, compared to competing methods, can recover the sharpest edges. We also give convergence curves that empirically confirm the convergence of the values $F ( x _ { k } )$ (g) and of the residual $\begin{array} { r } { \operatorname* { m i n } _ { 0 \leq i \leq k } | | x _ { i + 1 } - x _ { i } | | ^ { 2 } / | | x _ { 0 } | | ^ { 2 } } \end{array}$ (h). These observations are supported by the additional experiment shown in Appendix J.1, Figure 6. + +![](images/46e15b2a0e94ff05667bdecf14f568bf0d3afb0e0742244fadc6e13a6a61d155.jpg) +Figure 1: Deblurring with various methods of “starfish” degraded with the indicated blur kernel and input noise level $\nu = 0 . 0 3$ . Note that our algorithm better recovers the structures. In (g) and (h), we show the evolution of $F ( x _ { k } )$ and $\begin{array} { r } { \gamma _ { k } = \operatorname* { m i n } _ { 0 \leq i \leq k } | | x _ { i + 1 } - x _ { i } | | ^ { 2 } / | | x _ { 0 } | | ^ { 2 } } \end{array}$ and in Appendix J.4 of the PSNR. We empirically verify convergence of functional values and residual. Note that the empirical convergence rate in (h) is faster than the $\mathcal O \big ( \frac { 1 } { k } \big )$ theoretical worst case rate established in Remark 2. + +# 5.2.2 SUPER-RESOLUTION + +For single image super-resolution, the low-resolution image $y \in \mathbb { R } ^ { m }$ is obtained from the highresolution one $x \in \mathbb { R } ^ { n }$ via $y = S H x + \xi _ { \nu }$ where $H \in \mathbb { R } ^ { n \times n }$ is the convolution with anti-aliasing kernel. The matrix $S$ is the standard s-fold downsampling matrix of size $m \times n$ and $n = s ^ { 2 } \times m$ . In this context, we make use of the closed-form calculation of the proximal map for the data-fidelity term $\begin{array} { r } { f ( x ) = \frac { 1 } { 2 } | | S H x - y | | ^ { 2 } } \end{array}$ , given by Zhao et al. (2016): + +$$ +\mathrm { P r o x } _ { \tau f } ( z ) = \hat { z } _ { \tau } - \frac { 1 } { s ^ { 2 } } \mathcal { F } ^ { * } \underline { { \Delta } } ^ { * } \left( I _ { m } + \frac { \tau } { s ^ { 2 } } \underline { { \Delta \Lambda } } ^ { * } \right) ^ { - 1 } \underline { { \Delta } } \mathcal { F } \hat { z } _ { \tau } , +$$ + +where $\hat { z } _ { \tau } = \tau H ^ { T } S ^ { T } y + z$ and $\underline { { \boldsymbol \Lambda } } = [ \Lambda _ { 1 } , \ldots , \Lambda _ { s ^ { 2 } } ] \in \mathbb R ^ { m \times n }$ , with $\Lambda = \mathrm { d i a g } ( \Lambda _ { 1 } , \ldots , \Lambda _ { s ^ { 2 } } )$ a blockdiagonal decomposition according to a $s \times s$ paving of the Fourier domain. Note that $\begin{array} { r } { I _ { m } + \frac { \tau } { d } \Delta \Lambda ^ { * } } \end{array}$ is a $m \times m$ diagonal matrix and its inverse is computed element-wise. As expected, with $s = 1$ , equation (14) comes down to equation (13). + +As in Zhang et al. (2021), we evaluate super-resolution performance on 8 Gaussian blur kernels represented in Table 3: 4 isotropic kernels with different standard deviations (0.7, 1.2, 1.6 and 2.0) and 4 anisotropic kernels. Results are averaged between isotropic and anisotropic. We consider downsampled images at scale $s = 2$ and $s = 3$ and Gaussian noise with 3 different noise levels $\nu \in \{ 0 . \bar { 0 } 1 , 0 . 0 3 , \bar { 0 } . 0 5 \}$ . Our method $( \mathrm { G S - P n P } )$ ) is compared against bicubic upsampling, RED, IRCNN $\mathrm { \hbar ^ { * } I R C N N { + } } ^ { \mathrm { * } }$ from (Zhang et al., 2021)) and DPIR. We give again in Appendix J.2 the results obtained on the Set3C dataset (Table 7). All our results are obtained with $\lambda _ { \nu } ^ { \dot { } } = \nu ^ { 2 } \lambda _ { } = 0 . 0 6 5$ and $\sigma = 2 \nu$ . Initialization $z _ { \mathrm { 0 } }$ is done with a bicubic interpolation of $y$ (with a shift correction (Zhang et al., 2021)) and the stopping criteria are $\epsilon = 1 0 ^ { - 6 }$ and $K = 4 0 0$ . + +Besides being the only compared $\mathrm { P n P }$ method with convergence guarantee, $\mathrm { G S - P n P }$ outperforms in PSNR all other $\mathrm { P n P }$ algorithms over the considered range of blur kernels, noise levels and scale factors. We show in Figure 2 the super-resolution of the image “leaves” downsampled by 2, with an isotropic kernel and noise level $\nu = 0 . 0 3$ . GS-PnP (f) recovers more accurately structures and color details than competing approaches (c-e), while converging in terms of function values (g) and residual (h). Additional visual comparisons are presented in Appendix J.2. + +
KernelsMethods=2s=3Avg
v =0.01ν=0.03 v=0.05 v=0.01 v=0.03v=0.05
Bicubic24.8523.9622.7923.1422.5221.6223.15
RED28.2924.6522.9826.1324.0222.3724.74
IRCNN27.4326.2225.8626.1225.1124.7925.92
DPIR GS-PnP28.62 28.7727.30 27.5426.47 26.6326.88 26.8525.96 26.0525.22 25.2926.74 26.86
Bicubic23.3822.7121.7822.6522.0821.2522.31
RED26.3323.9122.4525.3823.4021.9123.90
IRCNN25.8324.8924.5925.3624.3623.9524.83
DPIR GS-PnP26.84 26.8025.59 25.7324.89 25.0326.24 26.1824.98 25.0824.32 24.3125.48 25.52
+ +![](images/64039502eba4673f4c9e21ad217e5f7a31be4ae9990a98c376ab2fcb26061f20.jpg) +Table 3: PSNR(dB) comparison of image super-resolution methods on CBSD10 with various scales s, blur kernels $k$ and noise levels ν. PNSR results are averaged over kernels at each row. +Figure 2: Super-resolution with various methods on “leaves” (set3C) downsampled by 2, with the indicated blur kernel and input noise level $\nu \ = \ 0 . 0 3$ . Note that our algorithm is the one that recovers sharpest leaves. In (g) and (h), we show the evolution of $F ( x _ { k } )$ and $\begin{array} { r } { \gamma _ { k } = \operatorname* { m i n } _ { 0 \leq i \leq k } | | x _ { i + 1 } - \bar { x _ { i } } | | ^ { 2 } / | | x _ { 0 } | | ^ { 2 } } \end{array}$ and in AppendixJ.4 the evolution of the PSNR.. The empirical convergence rate is faster than the $\mathcal { O } \big ( \textstyle { \frac { 1 } { k } } \big )$ theoretical worst case rate established in Remark 2. + +# 6 CONCLUSION + +In this work, we introduce a new $\mathrm { P n P }$ algorithm with convergence guarantees. A denoiser is trained to realize an exact gradient step on a regularization function that is formulated through a neural network. This denoiser is plugged in an iterative scheme closely related to PnP-HQS, which is proved to converge towards a stationary point of an explicit functional. One strength of this approach is to simultaneously allow for a non strongly convex (and non smooth) data-fidelity term with a denoiser that may not be nonexpansive. Experiments conducted on ill-posed imaging problems (deblurring, super-resolution, inpainting) confirm the convergence results and show that the proposed PnP algorithm reaches state-of-the-art image restoration performance. This work also opens several research perspectives. One could first examine which information is encoded in the proposed prior. For example, based on the sharp visual results, one can question if a relation can be drawn between this prior and the gradient energy or sparsity. Also, it would be interesting to see if the recovery analysis developed in (Liu et al., 2021) can adapt to the proposed framework. + +# 7 REPRODUCIBILITY STATEMENT + +Anonymous source code is given in supplementary material. It contains a README.md file that explains step by step how to run the algorithm and replicate the results of the paper. Moreover, the pseudocode of our algorithm is given Algorithm 1. In Section 5 it is precisely detailed how all the hyper-parameters are chosen and, for each experiment, which dataset is used. As for the theoretical results presented in Section 4, complete proofs are given in the appendixes. + +# 8 ETHICS STATEMENT + +We believe that this work does not raise potential ethical concerns. + +# ACKNOWLEDGEMENTS + +This work was funded by the French ministry of research through a CDSN grant of ENS ParisSaclay. This study has also been carried out with financial support from the French Research Agency through the PostProdLEAP and Mistic projects (ANR-19-CE23-0027-01 and ANR-19-CE40-005). + +# REFERENCES + +Eirikur Agustsson and Radu Timofte. Ntire 2017 challenge on single image super-resolution: Dataset and study. In Proceedings of the IEEE conference on computer vision and pattern recognition workshops, pp. 126–135, 2017. + +Rizwan Ahmad, Charles A Bouman, Gregery T Buzzard, Stanley Chan, Sizhuo Liu, Edward T Reehorst, and Philip Schniter. Plug-and-play methods for magnetic resonance imaging: Using denoisers for image recovery. IEEE signal processing magazine, 37(1):105–116, 2020. + +Hedy Attouch, J ´ er´ ome Bolte, Patrick Redont, and Antoine Soubeyran. Proximal alternating mini- ˆ mization and projection methods for nonconvex problems: An approach based on the kurdykałojasiewicz inequality. Mathematics of operations research, 35(2):438–457, 2010. + +Hedy Attouch, Jer´ ome Bolte, and Benar Fux Svaiter. Convergence of descent methods for semi-ˆ algebraic and tame problems: proximal algorithms, forward–backward splitting, and regularized gauss–seidel methods. Mathematical Programming, 137(1-2):91–129, 2013. + +H. H. Bauschke and P. L. Combettes. Convex Analysis and Monotone Operator Theory in Hilbert Spaces. Springer, 2011. + +Amir Beck. First-order methods in optimization. SIAM, 2017. + +Amir Beck and Marc Teboulle. Gradient-based algorithms with applications to signal recovery. Convex optimization in signal processing and communications, pp. 42–88, 2009. + +Siavash A Bigdeli, Geng Lin, Tiziano Portenier, L Andrea Dunbar, and Matthias Zwicker. Learning generative models using denoising density estimators. arXiv preprint arXiv:2001.02728, 2020. + +Siavash Arjomand Bigdeli and Matthias Zwicker. Image restoration using autoencoding priors. arXiv preprint arXiv:1703.09964, 2017. + +Siavash Arjomand Bigdeli, Meiguang Jin, Paolo Favaro, and Matthias Zwicker. Deep mean-shift priors for image restoration. arXiv preprint arXiv:1709.03749, 2017. + +Pakshal Bohra, Alexis Goujon, Dimitris Perdios, Sebastien Emery, and Michael Unser. Learning ´ lipschitz-controlled activation functions in neural networks for plug-and-play image reconstruction methods. In NeurIPS 2021 Workshop on Deep Learning and Inverse Problems, 2021. + +Jer´ ome Bolte, Aris Daniilidis, Olivier Ley, and Laurent Mazet. Characterizations of łojasiewicz ˆ inequalities: subgradient flows, talweg, convexity. Transactions of the American Mathematical Society, 362(6):3319–3363, 2010. + +Gregery T Buzzard, Stanley H Chan, Suhas Sreehari, and Charles A Bouman. Plug-and-play unplugged: Optimization-free reconstruction using consensus equilibrium. SIAM Journal on Imaging Sciences, 11(3):2001–2020, 2018. + +Luca Calatroni and Antonin Chambolle. Backtracking strategies for accelerated descent methods with smooth composite objectives. SIAM Journal on Optimization, 29(3):1772–1798, 2019. + +Stanley H Chan. Performance analysis of plug-and-play admm: A graph signal processing perspective. IEEE Transactions on Computational Imaging, 5(2):274–286, 2019. + +Stanley H Chan, Xiran Wang, and Omar A Elgendy. Plug-and-play ADMM for image restoration: Fixed-point convergence and applications. IEEE Transactions on Computational Imaging, 3(1): 84–98, 2016. + +Yunjin Chen and Thomas Pock. Trainable nonlinear reaction diffusion: A flexible framework for fast and effective image restoration. IEEE transactions on pattern analysis and machine intelligence, 39(6):1256–1272, 2016. + +Regev Cohen, Michael Elad, and Peyman Milanfar. Regularization by denoising via fixed-point projection (RED-PRO). SIAM Journal on Imaging Sciences, 14(3):1374–1406, 2021. + +Patrick L. Combettes and Jean-Christophe Pesquet. Proximal splitting methods in signal processing. In Fixed-Point Algorithms for Inverse Problems in Science and Engineering, pp. 185–212. Springer, 2011. + +Bradley Efron. Tweedie’s formula and selection bias. Journal of the American Statistical Association, 106(496):1602–1614, 2011. + +Ruturaj G Gavaskar and Kunal N Chaudhury. Plug-and-play ista converges with kernel denoisers. IEEE Signal Processing Letters, 27:610–614, 2020. + +Ruturaj G Gavaskar, Chirayu D Athalye, and Kunal N Chaudhury. On plug-and-play regularization using linear denoisers. IEEE Transactions on Image Processing, 2021. + +Ruturaj Girish Gavaskar and Kunal Narayan Chaudhury. On the proof of fixed-point convergence for plug-and-play ADMM. IEEE Signal Processing Letters, 26(12):1817–1821, 2019. + +Donald Geman and Chengda Yang. Nonlinear image recovery with half-quadratic regularization. IEEE transactions on Image Processing, 4(7):932–946, 1995. + +Mario Gonzalez, Andr ´ es Almansa, and Pauline Tan. Solving inverse problems by joint posterior ´ maximization with autoencoding prior. arXiv preprint arXiv:2103.01648, 2021. + +Johannes Hertrich, Sebastian Neumayer, and Gabriele Steidl. Convolutional proximal neural networks and plug-and-play algorithms. Linear Algebra and its Applications, 631:203–234, 2021. + +Jonathan Ho, Ajay Jain, and Pieter Abbeel. Denoising diffusion probabilistic models. arXiv preprint arXiv:2006.11239, 2020. + +Samuel Hurault, Thibaud Ehret, and Pablo Arias. Epll: an image denoising method using a gaussian mixture model learned on a large set of patches. Image Processing On Line, 8:465–489, 2018. + +Zahra Kadkhodaie and Eero Peter Simoncelli. Solving linear inverse problems using the prior implicit in a denoiser. In NeurIPS 2020 Workshop on Deep Learning and Inverse Problems, 2020. + +Remi Laumont, Valentin De Bortoli, Andr ´ es Almansa, Julie Delon, Alain Durmus, and Marcelo ´ Pereyra. Bayesian imaging using plug & play priors: when langevin meets tweedie. arXiv preprint arXiv:2103.04715, 2021. + +Anat Levin, Yair Weiss, Fredo Durand, and William T Freeman. Understanding and evaluating blind deconvolution algorithms. In 2009 IEEE Conference on Computer Vision and Pattern Recognition, pp. 1964–1971. IEEE, 2009. + +Huan Li and Zhouchen Lin. Accelerated proximal gradient methods for nonconvex programming. Advances in neural information processing systems, 28:379–387, 2015. + +Bee Lim, Sanghyun Son, Heewon Kim, Seungjun Nah, and Kyoung Mu Lee. Enhanced deep residual networks for single image super-resolution. In Proceedings of the IEEE conference on computer vision and pattern recognition workshops, pp. 136–144, 2017. + +Jiaming Liu, Yu Sun, Cihat Eldeniz, Weijie Gan, Hongyu An, and Ulugbek S Kamilov. Rare: Image reconstruction using deep priors learned without groundtruth. IEEE Journal of Selected Topics in Signal Processing, 14(6):1088–1099, 2020. + +Jiaming Liu, M Salman Asif, Brendt Wohlberg, and Ulugbek S Kamilov. Recovery analysis for plug-and-play priors using the restricted eigenvalue condition. arXiv preprint arXiv:2106.03668, 2021. + +Sebastian Lunz, Ozan Oktem, and Carola-Bibiane Sch ¨ onlieb. Adversarial regularizers in inverse ¨ problems. In Proceedings of the 32nd International Conference on Neural Information Processing Systems, pp. 8516–8525, 2018. + +Kede Ma, Zhengfang Duanmu, Qingbo Wu, Zhou Wang, Hongwei Yong, Hongliang Li, and Lei Zhang. Waterloo Exploration Database: New challenges for image quality assessment models. IEEE Transactions on Image Processing, 26(2):1004–1016, Feb. 2017. + +Stephane Mallat. ´ A Wavelet Tour of Signal Processing, The Sparse Way. Academic Press, Elsevier, 3rd edition edition, 2009. ISBN 978-0-12-374370-1. + +D. Martin, C. Fowlkes, D. Tal, and J. Malik. A database of human segmented natural images and its application to evaluating segmentation algorithms and measuring ecological statistics. In Proc. 8th Int’l Conf. Computer Vision, volume 2, pp. 416–423, July 2001. + +Tim Meinhardt, Michael Moller, Caner Hazirbas, and Daniel Cremers. Learning proximal operators: Using denoising networks for regularizing inverse imaging problems. In Proceedings of the IEEE International Conference on Computer Vision, pp. 1781–1790, 2017. + +Christopher Metzler, Phillip Schniter, Ashok Veeraraghavan, et al. prdeep: robust phase retrieval with a flexible deep network. In International Conference on Machine Learning, pp. 3501–3510. PMLR, 2018. + +Jean-Jacques Moreau. Proximite et dualit ´ e dans un espace hilbertien. ´ Bulletin de la Societ´ e´ Mathematique de France ´ , 93:273–299, 1965. URL http://eudml.org/doc/87067. + +Pravin Nair, Ruturaj Girish Gavaskar, and Kunal Narayan Chaudhury. Fixed-point and objective convergence of plug-and-play algorithms. IEEE Transactions on Computational Imaging, 2021. + +Peter Ochs, Yunjin Chen, Thomas Brox, and Thomas Pock. ipiano: Inertial proximal algorithm for nonconvex optimization. SIAM Journal on Imaging Sciences, 7(2):1388–1419, 2014. + +Jean-Christophe Pesquet, Audrey Repetti, Matthieu Terris, and Yves Wiaux. Learning maximally monotone operators for image recovery. SIAM Journal on Imaging Sciences, 14(3):1206–1237, 2021. + +Jean Prost, Antoine Houdard, Andres Almansa, and Nicolas Papadakis. Learning local regulariza-´ tion for variational image restoration. arXiv preprint arXiv:2102.06155, 2021. + +Edward T Reehorst and Philip Schniter. Regularization by denoising: Clarifications and new interpretations. IEEE transactions on computational imaging, 5(1):52–67, 2018. + +Yaniv Romano, Michael Elad, and Peyman Milanfar. The little engine that could: Regularization by denoising (red). SIAM Journal on Imaging Sciences, 10(4):1804–1844, 2017. + +Leonid I Rudin, Stanley Osher, and Emad Fatemi. Nonlinear total variation based noise removal algorithms. Phys. D, 60:259–268, 1992. + +Ernest Ryu, Jialin Liu, Sicheng Wang, Xiaohan Chen, Zhangyang Wang, and Wotao Yin. Plug-andplay methods provably converge with properly trained denoisers. In International Conference on Machine Learning, pp. 5546–5557. PMLR, 2019. + +Tim Salimans and Jonathan Ho. Should EBMs model the energy or the score? In Energy Based Models Workshop-ICLR 2021, 2021. + +Saeed Saremi. On approximating $\nabla f$ with neural networks. arXiv preprint arXiv:1910.12744, 2019. + +Saeed Saremi and Aapo Hyvarinen. Neural empirical bayes. arXiv preprint arXiv:1903.02334, 2019. + +Katya Scheinberg, Donald Goldfarb, and Xi Bai. Fast first-order methods for composite convex optimization with backtracking. Foundations of Computational Mathematics, 14(3):389–417, 2014. + +Suhas Sreehari, S Venkat Venkatakrishnan, Brendt Wohlberg, Gregery T Buzzard, Lawrence F Drummy, Jeffrey P Simmons, and Charles A Bouman. Plug-and-play priors for bright field electron tomography and sparse interpolation. IEEE Transactions on Computational Imaging, 2(4): 408–423, 2016. + +Yu Sun, Jiaming Liu, and Ulugbek S Kamilov. Block coordinate regularization by denoising. arXiv preprint arXiv:1905.05113, 2019a. + +Yu Sun, Brendt Wohlberg, and Ulugbek S Kamilov. An online plug-and-play algorithm for regularized image reconstruction. IEEE Transactions on Computational Imaging, 5(3):395–408, 2019b. + +Yu Sun, Jiaming Liu, Yiran Sun, Brendt Wohlberg, and Ulugbek S Kamilov. Async-red: A provably convergent asynchronous block parallel stochastic method using deep denoising priors. arXiv preprint arXiv:2010.01446, 2020. + +Yu Sun, Zihui Wu, Xiaojian Xu, Brendt Wohlberg, and Ulugbek S Kamilov. Scalable plug-and-play admm with convergence guarantees. IEEE Transactions on Computational Imaging, 7:849–863, 2021. + +Matthieu Terris, Audrey Repetti, Jean-Christophe Pesquet, and Yves Wiaux. Building firmly nonexpansive convolutional neural networks. In ICASSP 2020-2020 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP), pp. 8658–8662. IEEE, 2020. + +Singanallur V Venkatakrishnan, Charles A Bouman, and Brendt Wohlberg. Plug-and-play priors for model based reconstruction. In 2013 IEEE Global Conference on Signal and Information Processing, pp. 945–948. IEEE, 2013. + +Kaixuan Wei, Angelica Aviles-Rivero, Jingwei Liang, Ying Fu, Carola-Bibiane Schonlieb, and Hua ¨ Huang. Tuning-free plug-and-play proximal algorithm for inverse imaging problems. In International Conference on Machine Learning, pp. 10158–10169. PMLR, 2020. + +Xiaojian Xu, Yu Sun, Jiaming Liu, Brendt Wohlberg, and Ulugbek S Kamilov. Provable convergence of plug-and-play priors with mmse denoisers. arXiv preprint arXiv:2005.07685, 2020. + +Xin Yuan, Yang Liu, Jinli Suo, and Qionghai Dai. Plug-and-play algorithms for large-scale snapshot compressive imaging. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), June 2020. + +Kai Zhang, Wangmeng Zuo, Yunjin Chen, Deyu Meng, and Lei Zhang. Beyond a gaussian denoiser: Residual learning of deep cnn for image denoising. IEEE Transactions on Image Processing, 26 (7):3142–3155, 2017a. + +Kai Zhang, Wangmeng Zuo, Shuhang Gu, and Lei Zhang. Learning deep cnn denoiser prior for image restoration. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 3929–3938, 2017b. + +Kai Zhang, Wangmeng Zuo, and Lei Zhang. Ffdnet: Toward a fast and flexible solution for cnnbased image denoising. IEEE Transactions on Image Processing, 27(9):4608–4622, 2018. + +Kai Zhang, Yawei Li, Wangmeng Zuo, Lei Zhang, Luc Van Gool, and Radu Timofte. Plug-and-play image restoration with deep denoiser prior. IEEE Transactions on Pattern Analysis and Machine Intelligence, 2021. + +Ningning Zhao, Qi Wei, Adrian Basarab, Nicolas Dobigeon, Denis Kouame, and Jean-Yves ´ Tourneret. Fast single image super-resolution using a new analytical solution for $\ell _ { 2 } - \ell _ { 2 }$ problems. IEEE Transactions on Image Processing, 25(8):3683–3697, 2016. + +Daniel Zoran and Yair Weiss. From learning models of natural image patches to whole image restoration. In 2011 International Conference on Computer Vision, pp. 479–486. IEEE, 2011. + +# A COMPARISON WITH THE PNP LITERATURE + +A.1 LIMITATIONS OF PREVIOUS PNP METHODS + +In the existing literature, PnP approaches have one of the following limitations: + +• They are not able to provide proof of convergence when non strongly convex data-fidelity terms are involved (Ryu et al., 2019), which is the case of some classical IR problems such as deblurring, super-resolution or inpainting. +• They are restricted to (nearly) nonexpansive denoisers (Reehorst & Schniter, 2018; Ryu et al., 2019; Sun et al., 2019b; Xu et al., 2020) or denoisers with a symmetric Jacobian (Romano et al., 2017). But it has already been shown that imposing symmetric Jacobian or Lipschitz property on a deep denoiser network alters its denoising performance (Bohra et al., 2021; Hertrich et al., 2021). We highlight that it was already empirically observed (Romano et al., 2017; Zhang et al., 2021) that the performance of the denoiser directly impacts the performance of the corresponding PnP scheme for IR. +They show convergence of iterates thanks to decreasing time steps (Chan et al., 2016), but there is no characterization of the obtained solution (it is not a minima or a critical point of any functional). + +On the other hand, our method is proved to converge to a stationary point of an explicit functional including a non strongly convex data-fidelity term. It also relies on a (possibly expansive) denoiser that, although being constrained to be a conservative vector field, allows to produce state-of-the-art results for various ill-posed IR problems. + +# A.2 ON THE REGULARIZATION $g _ { \sigma }$ + +We first underline that the main point of our method is to define the denoiser as $D _ { \sigma } = \mathrm { I d } - \nabla g _ { \sigma }$ . The choice for $g _ { \sigma }$ is important for the denoising performance. With respect to the convergence properties of $\mathrm { G S - P n P } ,$ this is nevertheless a secondary issue, as our method would converge for other differentiable regularizers $g _ { \sigma }$ . + +The proposed regularization $\begin{array} { r } { g _ { \sigma } ( x ) = \frac { 1 } { 2 } | | x - N _ { \sigma } ( x ) | | ^ { 2 } } \end{array}$ was previously mentioned in the RED original paper (Romano et al., 2017) (but explicitly left aside) and used in the DAEP paper (Bigdeli & Zwicker, 2017). The main difference between our regularizer and the one alternately proposed in RED and DAEP is the following: + +• RED and DAEP both consider a generic given pretrained denoiser $D _ { \sigma } : \mathbb { R } ^ { n } \mathbb { R } ^ { n }$ , which is then associated with the regularizer $g _ { \sigma } ( x ) \stackrel { \bullet } { = } \frac { 1 } { 2 } | | x - D _ { \sigma } ( x ) | | ^ { 2 }$ and used as such in IR problems. +• In our method, we set $\begin{array} { r } { g _ { \sigma } ( x ) = \frac { 1 } { 2 } | | x - N _ { \sigma } ( x ) | | ^ { 2 } } \end{array}$ (with $N _ { \sigma } : \mathbb { R } ^ { n } \mathbb { R } ^ { n }$ differentiable) and then we train the denoiser as $D _ { \sigma } = \mathrm { I d } - \nabla g _ { \sigma }$ with the loss function $| | D _ { \sigma } ( x + \xi ) - x | | ^ { 2 }$ for clean images $x$ and additive white Gaussian noise (AWGN) $\xi$ . + +With this new formulation, we are ensured that $D _ { \sigma } = \mathrm { I d } - \nabla g _ { \sigma }$ is inherently a conservative vector field, without further assumptions on $N _ { \sigma }$ . Thanks to this relation, the (slightly modified) PnP-HQS given in relation (9) becomes a proximal gradient descent (PGD). We can then make use of convergence results of the PGD algorithm in the nonconvex setting to show the convergence of PnP-HQS. + +In contrast to the original RED paper, we aimed at finding one setting of Plug-and-Play image restoration that allows for a convergence proof with sufficiently general hypotheses. For this purpose, we had to consider this very particular form of regularization. + +A.3 RECENT LITERATURE ON REGULARIZATION BY DENOISING + +We here provide a more detailed discussion on the follow-up literature on RED. + +In parallel to the RED method (Romano et al., 2017), the authors of Bigdeli & Zwicker (2017) propose to use the regularization, mentioned but not exploited in RED, $\bar { g } ( x ) = | | D _ { \sigma } ( x ) - x | | ^ { 2 }$ , where $D _ { \sigma }$ is a pretrained denoising autoencoder. Next, Bigdeli et al. (2017) extended this work with a new prior, which is the Gaussian-smoothed version of the natural image prior. Inspired by Tweedie’s formula, they approximate the gradient of this log smoothed prior with the residual of a pretrained denoising autoencoder. With this new formulation, it is possible to optimize on the restored image but also on other parameters (e.g. the noise level and the used blur kernel). + +Initially designed in the context of convex data-fidelity term, RED Romano et al. (2017) has been applied in the nonconvex setting for phase retrieval problems in prDeep Metzler et al. (2018). + +Regularization by Artifact-Removal (RARE) (Liu et al., 2020) extends the RED framework by replacing the denoiser by a more general artifact-removal operator. The main advantage of this operator is that it can be trained without groundtruth data, but only by mapping pairs of artifact and noise contaminated images obtained directly from undersampled measurements. This is particularly useful for medical imaging applications where it is difficult to acquire fully-sampled training data. + +The convergence of the original RED algorithm is discussed in Reehorst & Schniter (2018). The authors provide a convergence proof for RED-PGD which requires the denoiser to be nonexpansive, which, as detailed in the previous sections, is a restrictive hypothesis. + +The authors of Liu et al. (2021) provide a recovery guarantee for the $\mathrm { P n P }$ framework, meaning convergence to a $x ^ { * }$ that satisfies $y = A x ^ { * }$ while being in the set $\mathsf { F i x } ( D )$ of the fixed points of $D$ . More precisely, they show the convergence of the PnP-PGD method towards such a true solution $x ^ { * }$ under the assumptions that the denoiser residual $R = { \mathrm { I d } } - D$ is bounded and Lipschitz, and that the measurement operator satisfies a “set-restricted eigenvalue condition” (S-REC, which can be understood as strong convexity on the image of the denoiser $| { \mathsf { m } } ( D ) )$ . Under the additional assumptions that the denoiser is nonexpansive and that there exists $x \in \mathsf { F i x } ( D )$ that is also critical for the regularizer $g$ , they show that $\mathrm { P n P }$ and RED have the same solutions. As mentioned by the authors, it is nevertheless difficult to verify the S-REC condition for a given measurement operator: since $\mathsf { I m } ( D )$ is not explicit, it is not clear how much S-REC relaxes the strong convexity. As explained in Sections 2 and 3, our results do not require strong convexity of the data-fidelity term. + +Instead of including an explicit regularization in the functional, RED-PRO (Cohen et al., 2021) aims at minimizing the data-fidelity term on the set $\mathsf { F i x } ( D )$ of fixed points of a generic denoiser $D$ . The study is conducted under the hypothesis that the denoiser is demicontractive, which implies that $\mathsf { F i x } ( D )$ is convex, thus leading to a convex optimization problem. However, this assumption seems difficult to verify in practice and the existence of fixed points for the RED-PRO operator does not appear straightforward. In contrast, the fixed points of the $\mathrm { G S - P n P }$ operator are directly related to the stationary points of the global functional $F = f + \lambda g _ { \sigma }$ (Lemma 1 in Appendix C), whose existence is guaranteed as soon as $F$ is coercive (see the discussion in Appendix D). + +ASYNC-RED (Sun et al., 2020) enables faster computation of RED by decomposing the inference into a sequence of partial (block-coordinate) updates on $x$ which can be executed asynchronously in parallel over a multicore system. As in their previous work BC-RED (Sun et al., 2019a), the authors propose to further reduce the computational time by using only a random subset of measurements at every iteration. Convergence of ASYNC-RED is shown, provided the denoiser is nonexpansive. A possible future extension of our work is the integration of the ASYNC framework to accelerate $\mathrm { G S - P n P }$ for large scale imaging inverse problems. As our $\mathrm { G S - P n P }$ converges without assuming nonexpansiveness of the denoising operation, it would be interesting to see if one can adapt the GS-PnP convergence properties to an ASYNC-GSPnP algorithm. + +# B LIPSCHITZ CONSTANT OF $\nabla g _ { \sigma }$ + +First, let us give a result which ensures that a large class of neural networks trained with differentiable activation functions have Lipschitz gradients with respect to the input image. + +Proposition 2. Let $H = h _ { p } \circ . . . . \circ h _ { 1 }$ be a composition of differentiable functions $h _ { i } : \mathbb { R } ^ { d _ { i - 1 } } \mathbb { R } ^ { d _ { i } }$ . +Let us assume that for any $i$ the differential map $h _ { i } ^ { \prime }$ is bounded and Lipschitz. Then $H ^ { \prime }$ is Lipschitz. + +Proof. Let us denote $H _ { i } = h _ { i } \circ \dots \circ h _ { 1 }$ (and by convention, $H _ { 0 } = \mathrm { I d } )$ . Let $\| h _ { i } ^ { \prime } \| _ { \infty }$ be the best uniform bound on the operator norms $\| h _ { i } ^ { \prime } ( x ) \| , x \in \mathbb { R } ^ { d _ { i - 1 } }$ (which is also the best Lipschitz constant of $h _ { i }$ ). Let us also denote $\| h _ { i } ^ { \prime } \| _ { \mathrm { L i p } }$ the Lipschitz constant of $h _ { i } ^ { \prime }$ . The chain rule gives that for any $x$ , $H ^ { \prime } ( x )$ can be expressed as a composition of linear maps + +$$ +H ^ { \prime } ( x ) = h _ { p } ^ { \prime } ( H _ { p - 1 } ( x ) ) h _ { p - 1 } ^ { \prime } ( H _ { p - 2 } ( x ) ) \ldots h _ { 1 } ^ { \prime } ( x ) +$$ + +Therefore, for any $x , y$ , + +$$ +\scriptsize H ^ { \prime } ( x ) - H ^ { \prime } ( y ) = \sum _ { i = 0 } ^ { p - 1 } h _ { p } ^ { \prime } ( H _ { p - 1 } ( x ) ) \dots h _ { i + 2 } ^ { \prime } ( H _ { i + 1 } ( x ) ) h _ { i + 1 } ^ { \prime } ( H _ { i } ( x ) ) h _ { i } ^ { \prime } ( H _ { i - 1 } ( y ) ) \dots h _ { 1 } ^ { \prime } ( y ) \quad ( \mathrm { 1 } - \mathrm { 1 } - \mathrm { 1 } - \mathrm { 1 } ) +$$ + +We can thus bound the operator norms + +$$ +\begin{array} { r l } { { \| H ^ { \prime } ( x ) - H ^ { \prime } ( y ) \| \le \displaystyle \sum _ { i = 0 } ^ { p - 1 } \Big ( \| h _ { p } ^ { \prime } ( H _ { p - 1 } ( x ) ) \ldots h _ { i + 2 } ^ { \prime } ( H _ { i + 1 } ( x ) ) \| } } \\ & { \qquad \quad \| h _ { i + 1 } ^ { \prime } ( H _ { i } ( x ) ) - h _ { i + 1 } ^ { \prime } ( H _ { i } ( y ) ) \| \| h _ { i } ^ { \prime } ( H _ { i - 1 } ( y ) ) \ldots h _ { 1 } ^ { \prime } ( y ) \| \Big ) . } \end{array} +$$ + +and thus + +$$ +\| H ^ { \prime } ( x ) - H ^ { \prime } ( y ) \| \leq \sum _ { i = 0 } ^ { p - 1 } \Big ( \prod _ { j \neq i + 1 } \| h _ { j } ^ { \prime } \| _ { \infty } \Big ) \| h _ { i + 1 } ^ { \prime } \| _ { \mathrm { L i p } } \| H _ { i } ^ { \prime } \| _ { \infty } \| x - y \| +$$ + +which concludes because the chain-rule ensures that $\| H _ { i } ^ { \prime } \| _ { \infty } \leq \| h _ { i } ^ { \prime } \| _ { \infty } \ldots \| h _ { 1 } ^ { \prime } \| _ { \infty }$ . + +Proposition 2 applies for a neural network obtained as a composition of fully-connected layers with ELU activation functions, that is, by composing functions of the form + +$$ +h ( x ) = E ( A x + b ) +$$ + +where $A$ is a matrix, $b$ a vector and $E$ is the element-wise ELU defined by + +$$ +E ( x ) _ { i } = { \left\{ \begin{array} { l l } { x _ { i } } & { { \mathrm { i f ~ } } x _ { i } \geq 0 } \\ { e ^ { x _ { i } } - 1 } & { { \mathrm { i f ~ } } x _ { i } < 0 { \mathrm { ~ . } } } \end{array} \right. } +$$ + +It is easy to see that $E$ is differentiable and that $E ^ { \prime }$ is 1-Lipschitz with $\| E ^ { \prime } \| _ { \infty } \leq 1$ . Therefore + +$$ +h ^ { \prime } ( x ) = E ^ { \prime } ( A x + b ) A +$$ + +is also bounded and Lipschitz. + +Let us also mention that this proposition encompasses the case of U-nets which, in addition to composing fully-connected layers, also integrates skip-connections. For example, taking a skipconnection on a composition $h _ { 3 } \circ h _ { 2 } \circ h _ { 1 }$ amounts to defining + +$$ +H ( x ) = h _ { 3 } { \big ( } h _ { 2 } ( h _ { 1 } ( x ) ) , h _ { 1 } ( x ) { \big ) } . +$$ + +This can be simply rewritten $H = h _ { 3 } \circ \tilde { h } _ { 2 } \circ h _ { 1 }$ where + +$$ +\tilde { h } _ { 2 } ( x ) = \big ( h _ { 2 } ( h _ { 1 } ( x ) ) , h _ { 1 } ( x ) \big ) . +$$ + +It is then clear that $\tilde { h } _ { 2 }$ has bounded Lipschitz differential as soon as $h _ { 1 }$ and $h _ { 2 }$ do. + +The bound obtained in the proof of Proposition 2 is exponential in the depth of the neural network. We now provide some experiments showing that, in practice, the Lipschitz constant of $\nabla g _ { \sigma }$ does not explode. We show in Figure 3, for various noise levels $\sigma$ , the distribution of the spectral norms $| | \nabla ^ { 2 } g _ { \sigma } ( x ) | | _ { S }$ on the training image set $X$ , estimated with power iterations. The computed value varies a lot across images. Hence approximating the Lipschitz constant of $\nabla g _ { \sigma }$ with $\smash { \dot { L } = \operatorname* { m a x } _ { x \in { \boldsymbol { X } } } | | \nabla ^ { 2 } g _ { \sigma } ( x ) | | _ { { \boldsymbol { S } } } }$ would lead to under-estimated stepsizes and slow convergence on most images. Backtracking solves this issue by finding at each iteration the optimal stepsize allowing sufficient decrease of the objective function. + +![](images/1c864902dc8f30433b17d915fb5dd08a435e6ff13f65711ea2707dc945f15e2f.jpg) +Figure 3: Histogram of the values of the spectral norm $| | \nabla ^ { 2 } g _ { \sigma } ( x ) | | _ { S }$ evaluated on $1 2 8 \times 1 2 8$ images from the training dataset, degraded with white Gaussian noise with various standard deviations $\sigma$ (./255). Figure best seen in color. + +# C PROOF OF THEOREM 1 + +We first remind that a function $f : \mathbb { R } ^ { n } \longrightarrow \mathbb { R } \cup + \infty$ is proper if its domain + +$$ +d o m ( f ) = \{ x \in \mathbb { R } , f ( x ) < + \infty \} +$$ + +is non empty. Also, recall that $f$ is lower semicontinuous at $x ^ { * }$ if $\textstyle \operatorname* { l i m } \operatorname* { i n f } _ { x \to x ^ { * } } f ( x ) \geq f ( x ^ { * } ) .$ + +Proof. + +(i) For ease of notation, we consider $\lambda \ = \ 1$ . The generalisation for any $\lambda > 0$ is straightforward by rescaling $g _ { \sigma }$ (and $L$ ) accordingly. We denote the proximal gradient fixed point operator $T _ { \tau } = \mathrm { P r o x } _ { \tau f } \circ ( \mathrm { I d } - \tau \nabla _ { x } g _ { \sigma } )$ , the objective function $\textstyle F = f + g _ { \sigma }$ and we introduce + +$$ +Q _ { \tau } ( x , y ) = g _ { \sigma } ( y ) + \langle x - y , \nabla g _ { \sigma } ( y ) \rangle + \frac { 1 } { 2 \tau } | | x - y | | ^ { 2 } + f ( x ) . +$$ + +We have + +$$ +\begin{array} { l } { \displaystyle \arg \operatorname* { m i n } _ { x } Q _ { \tau } ( x , y ) = \arg \operatorname* { m i n } _ { x } g _ { \sigma } ( y ) + \langle x - y , \nabla g _ { \sigma } ( y ) \rangle + \frac { 1 } { 2 \tau } | | x - y | | ^ { 2 } + f ( x ) } \\ { \displaystyle \qquad = \arg \operatorname* { m i n } _ { x } f ( x ) + \frac { 1 } { 2 \tau } | | x - ( y - \tau \nabla g _ { \sigma } ( y ) | | ^ { 2 } } \\ { \displaystyle \qquad = \mathrm { P r o x } _ { \tau f } \circ \big ( \mathrm { I d } - \tau \nabla _ { x } g _ { \sigma } \big ) ( y ) = T _ { \tau } ( y ) . } \end{array} +$$ + +By definition for the arg min, $x _ { k + 1 } = T _ { \tau } ( x _ { k } ) \Rightarrow Q _ { \tau } ( x _ { k + 1 } , x _ { k } ) \leq Q _ { \tau } ( x _ { k } , x _ { k } )$ . Moreover, with $g _ { \sigma }$ being $L$ -smooth, we have by the descent lemma, for any $\begin{array} { r } { \tau \leq \frac { 1 } { L } } \end{array}$ and any $x , y \in \mathbb { R } ^ { n }$ , + +$$ +g _ { \sigma } ( x ) \leq g _ { \sigma } ( y ) + \langle x - y , \nabla g _ { \sigma } ( y ) \rangle + \frac { 1 } { 2 \tau } | | x - y | | ^ { 2 } , +$$ + +so that for every $x , y \in \mathbb { R } ^ { n }$ , + +$$ +Q _ { \tau } ( x , x ) = F ( x ) \quad \mathrm { a n d } \quad Q _ { \tau } ( x , y ) \geq F ( x ) . +$$ + +Therefore, at iteration $k$ , + +$$ +F ( x _ { k + 1 } ) \leq Q _ { \tau } ( x _ { k + 1 } , x _ { k } ) \leq Q _ { \tau } ( x _ { k } , x _ { k } ) = F ( x _ { k } ) . +$$ + +$\left( F ( x _ { k } ) \right)$ is thus non-increasing. Since $F$ is lower-bounded, $( F ( x _ { k } ) )$ thus converges to a limit $F ^ { * }$ + +(ii) Note that $Q _ { \tau } ( x _ { k + 1 } , x _ { k } ) \leq Q _ { \tau } ( x _ { k } , x _ { k } )$ implies + +$$ +f ( x _ { k + 1 } ) \leq f ( x _ { k } ) - \langle x _ { k + 1 } - x _ { k } , \nabla g _ { \sigma } ( x _ { k } ) \rangle - { \frac { 1 } { 2 \tau } } | | x _ { k + 1 } - x _ { k } | | ^ { 2 } . +$$ + +Using also (29) with stepsize $\frac { 1 } { L }$ , we get + +$$ +\begin{array} { r l } { { F ( x _ { k + 1 } ) = f ( x _ { k + 1 } ) + g _ { \sigma } ( x _ { k + 1 } ) } } \\ & { \le f ( x _ { k } ) - \langle x _ { k + 1 } - x _ { k } , \nabla g _ { \sigma } ( x _ { k } ) \rangle - \frac { 1 } { 2 \tau } \| x _ { k + 1 } - x _ { k } \| ^ { 2 } } \\ & { + g _ { \sigma } ( x _ { k } ) + \langle x _ { k + 1 } - x _ { k } , \nabla g _ { \sigma } ( x _ { k } ) \rangle + \frac { L } { 2 } \| x _ { k + 1 } - x _ { k } \| ^ { 2 } } \\ & { = F ( x _ { k } ) - ( \frac { 1 } { 2 \tau } - \frac { L } { 2 } ) \| x _ { k + 1 } - x _ { k } \| ^ { 2 } . } \end{array} +$$ + +Summing over $k = 0 , 1 , . . . , m$ gives + +$$ +\begin{array} { l } { \displaystyle \sum _ { k = 0 } ^ { m } | | x _ { k + 1 } - x _ { k } | | ^ { 2 } \leq \frac { 1 } { \frac { 1 } { 2 \tau } - \frac { L } { 2 } } \left( F ( x _ { 0 } ) - F ( x _ { m + 1 } ) \right) } \\ { \displaystyle \qquad \leq \frac { 1 } { \frac { 1 } { 2 \tau } - \frac { L } { 2 } } \left( F ( x _ { 0 } ) - F ^ { * } \right) . } \end{array} +$$ + +Therefore, $\begin{array} { r } { \operatorname* { l i m } _ { k \to \infty } \left| \left| x _ { k + 1 } - x _ { k } \right| \right| = 0 } \end{array}$ + +(iii) We begin by the two following lemmas characterizing the proximal gradient descent operator $T _ { \tau } = \mathrm { P r o x } _ { \tau f } \circ ( \mathrm { I d } - \tau \nabla _ { x } g _ { \sigma } )$ . + +Lemma 1. With the assumptions of Theorem $^ { l }$ , for $x ^ { * } \in \mathbb { R } ^ { n }$ , $x ^ { * }$ is a fixed point of the proximal gradient descent operator $T _ { \tau } = \mathrm { P r o x } _ { \tau f } \circ ( \mathrm { I d } - \tau \nabla _ { x } g _ { \sigma } )$ , i.e. $T _ { \tau } ( x ^ { * } ) = x ^ { * }$ , if and only if $x ^ { * }$ is $a$ stationary point of problem $( I O )$ , i.e. $- \dot { \nabla } g _ { \sigma } ( x ^ { * } ) \in \partial f ( x ^ { * } )$ . + +Proof. By definition of the proximal operator, we have + +$$ +\begin{array} { r l } & { T _ { \tau } ( x ^ { * } ) = x ^ { * } \Leftrightarrow x ^ { * } = \mathrm { P r o x } _ { \tau f } \circ \big ( \mathrm { I d } - \tau \nabla _ { x } g _ { \sigma } \big ) ( x ^ { * } ) } \\ & { \qquad \Leftrightarrow x ^ { * } - \tau \nabla _ { x } g _ { \sigma } ( x ^ { * } ) - x ^ { * } \in \tau \partial f ( x ^ { * } ) } \\ & { \qquad \Leftrightarrow - \nabla _ { x } g _ { \sigma } ( x ^ { * } ) \in \partial f ( x ^ { * } ) . } \end{array} +$$ + +Lemma 2. With the assumptions of Theorem $^ { l }$ , $T _ { \tau }$ is $1 + \tau L$ Lipschitz. + +Proof. Using the fact that for $f$ convex, $\operatorname { P r o x } _ { \tau f }$ is 1-Lipschitz (Bauschke & Combettes, 2011, Proposition 12.28), and by the Lipschitz property of $\nabla _ { x } g _ { \sigma }$ , + +$$ +\begin{array} { r l } & { | | T _ { \tau } ( x ) - T _ { \tau } ( y ) | | = | | \mathrm { P r o x } _ { \tau f } \circ \left( \mathrm { I d } - \tau \nabla _ { x } g _ { \sigma } \right) ( x ) - \mathrm { P r o x } _ { \tau f } \circ \left( \mathrm { I d } - \tau \nabla _ { x } g _ { \sigma } \right) ( y ) | | } \\ & { \qquad \leq | | ( \mathrm { I d } - \tau \nabla _ { x } g _ { \sigma } ) ( x ) - ( \mathrm { I d } - \tau \nabla _ { x } g _ { \sigma } ) ( y ) | | } \\ & { \qquad \leq ( 1 + \tau L ) | | x - y | | . } \end{array} +$$ + +Note that, by nonconvexity of $g _ { \sigma }$ , the fixed point operator $T _ { \tau }$ is not necessarily nonexpansive, but we can still show the convergence of the fixed-point algorithm towards a critical point of the objective function. We can now turn to the proof of (iii). Let $x ^ { * }$ be a cluster point of $\mathrm { \bar { ( } } { x _ { k } } \mathrm { ) } _ { k \geq 0 }$ . Then there exists a subsequence $( x _ { k _ { j } } ) _ { j \geq 0 }$ converging to $x ^ { * }$ . We have $\forall j \geq 0$ , + +$$ +\begin{array} { r } { | | x ^ { * } - T _ { \tau } ( x ^ { * } ) | | \leq | | x ^ { * } - x _ { k _ { j } } | | + | | x _ { k _ { j } } - T _ { \tau } ( x _ { k _ { j } } ) | | + | | T _ { \tau } ( x _ { k _ { j } } ) - T _ { \tau } ( x ^ { * } ) | | } \\ { \leq ( 2 + \tau L ) | | x ^ { * } - x _ { k _ { j } } | | + | | x _ { k _ { j } } - T _ { \tau } ( x _ { k _ { j } } ) | | \mathrm { ~ b y ~ L e m m a ~ } 2 . } \end{array} +$$ + +Using (ii), the right-hand side of the inequality tends to 0 as $j \to \infty$ . Thus $| | x ^ { * } - T _ { \tau } ( x ^ { * } ) | | = 0$ and $x ^ { * } = T _ { \tau } ( x ^ { * } )$ , which by Lemma 1 means that $x ^ { * }$ is a stationary point of problem (10). □ + +# D ON THE BOUNDEDNESS OF $( x _ { k } )$ + +In order to obtain convergence of the iterates, in Theorem 2 the generated sequence $( x _ { k } )$ is assumed to be bounded. In the experiments (Section 5), we observed that under the rest of assumptions of Theorem 2, boundedness was always verified. A sufficient condition for the boundedness of the iterates is the coercivity of the objective function, that is, $\begin{array} { r } { \operatorname* { l i m } _ { | x | \to \infty } F ( x ) = + \infty } \end{array}$ (because the non-increasing property gives $F ( x _ { k } ) \leq F ( x _ { 0 } ) )$ . + +Similar to Laumont et al. (2021), we can constrain $F$ to be coercive by choosing a convex compact set $C \subset \mathbb { R } ^ { n }$ where the iterates should stay and by adding an extra term to the regularization $g _ { \sigma }$ : + +$$ +\hat { g } _ { \sigma } ( x ) = g _ { \sigma } ( x ) + \frac { 1 } { 2 } | | x - \Pi _ { C } ( x ) | | ^ { 2 } = \frac { 1 } { 2 } | | x - N _ { \sigma } ( x ) | | ^ { 2 } + \frac { 1 } { 2 } | | x - \Pi _ { C } ( x ) | | ^ { 2 } +$$ + +with $\Pi _ { C }$ the Euclidian projection on $C$ . As $g _ { \sigma }$ is differentiable, the gradient step becomes + +$$ +( \mathrm { I d } - \tau \lambda \nabla _ { x } \hat { g } _ { \sigma } ) ( x ) = ( \mathrm { I d } - \tau \lambda \nabla _ { x } g _ { \sigma } ) + \tau \lambda ( x - \Pi _ { C } ( x ) ) . +$$ + +In our experiments, we choose the compact set $C$ as $C = [ - 1 , 2 ] ^ { n }$ . In practice we observe that all the iterates always remain in $C$ and that the extra regularization term $| | x - \Pi _ { C } ( x ) | | ^ { 2 }$ is never activated. Therefore, we don’t present this technical adaptation in Algorithm 1 but we let the reader aware that boundedness of $( x _ { k } )$ is not a limiting assumption. + +# E KL PROPERTY + +Definition 1. Kurdyka-Lojasiewicz $( K L )$ property (taken from Attouch et al. (2010)) + +(a) $A$ function $f : \mathbb { R } ^ { n } \longrightarrow \mathbb { R } \cup + \infty$ is said to have the Kurdyka-Lojasiewicz property at $x ^ { * } \in d o m ( f )$ if there exists $\eta \in \left( 0 , + \infty \right)$ , a neighborhood $U$ of $x ^ { * }$ and a continuous concave function $\psi : [ 0 , \eta ) \longrightarrow \mathbb { R } _ { + }$ such that $\psi ( 0 ) = 0$ , $\psi$ is ${ \mathcal { C } } ^ { 1 }$ on $( 0 , \eta )$ , ${ \psi } ^ { \prime } > 0$ on $( 0 , \eta )$ and $\forall x \in U \cap [ f ( x ^ { * } ) < f < f ( x ^ { * } ) + \eta ]$ , the Kurdyka-Lojasiewicz inequality holds: + +$$ +\psi ^ { \prime } ( f ( x ) - f ( x ^ { * } ) ) d i s t ( 0 , \partial f ( x ) ) \geq 1 . +$$ + +(b) Proper lower semicontinuous functions which satisfy the Kurdyka-Lojasiewicz inequality at each point of dom $( \partial f )$ are called $K L$ functions. + +This condition can be interpreted as the fact that, up to a reparameterization, the function is sharp i.e. we can bound its subgradients away from 0. A big class of functions that have the KL-property is given by real semi-algebraic functions. For more details and interpretations, we refer to Attouch et al. (2010) and Bolte et al. (2010). + +# F ON THE ASSUMPTIONS OF THEOREMS 1 AND 2 + +In this section, we explicitly list and comment all the assumptions required by Theorems 1 and 2. These assumptions are standard in nonconvex optimization. We now detail why each assumption is verified for our plug-and-play image restoration algorithm. + +# Assumptions of Theorem 1: + +• Data-fidelity term $f : \mathbb { R } ^ { n } \mathbb { R } \cup \{ + \infty \}$ proper lower semicontinous and convex. This is a general assumption that includes most of the data-fidelity terms classically used in IR problems. Note that we do not require differentiability of $f$ . Degradations with Gaussian, Poisson or Laplacian noise models fall into this hypothesis. As noticed in Remark 3, our results can even be easily extended to a nonconvex data-fidelity term $f$ , which encompasses applications like phase retrieval Metzler et al. (2018). In practice, it is helpful to have $f$ proximable, i.e. $\operatorname { P r o x } _ { f }$ with closed-form formula. Otherwise, $\operatorname { P r o x } _ { f }$ needs to be calculated at each iteration with an optimization algorithm. + +• Regularization function $g _ { \sigma } : \mathbb { R } ^ { n } \mathbb { R }$ proper lower semicontinous and differentiable with $L$ -Lipschitz gradient. We parametrize as $\begin{array} { r } { g _ { \sigma } ( x ) = \frac { 1 } { 2 } | | x - N _ { \sigma } ( x ) | | ^ { 2 } } \end{array}$ with $N _ { \sigma }$ a differentiable neural network. This assumption on $g _ { \sigma }$ is thus reasonable from a practical perspective. Indeed, using a network $N _ { \sigma }$ with differentiable activation functions, our function $g _ { \sigma }$ is differentiable with Lipschitz gradient (details and proof are given in Appendix B). + +• Functional $F = f + \lambda g _ { \sigma }$ bounded from below. This is straightforward as all the terms are positive. + +• The stepsize $\begin{array} { r } { \tau < \frac { 1 } { \lambda L } } \end{array}$ . This is handled by backtracking (see Section 4.2). + +# Assumptions of Theorem 2: + +• Assumptions of Theorem 1 + +• $F$ verify the KL property. The KL property (defined in Appendix E) has been widely used to study the convergence of optimization algorithms in the nonconvex setting (Attouch et al., 2010; 2013; Ochs et al., 2014). Very large classes of functions, in particular all the semialgebraic functions, satisfy this technical property. It encompasses all the data-fidelity and regularization terms encountered in inverse problems. +• The sequence $( x _ { k } )$ given by the iterative scheme (9) is bounded. As discussed in Appendix D, the boundedness can be ensured with a potential additional projection at each iteration. This is just a theoretical guarantee, as we observed that such a projection is never activated in practice. + +# G BACKTRACKING AND PROOF OF PROPOSITION 1 + +Before giving the proof of Proposition 1, we first point out that our backtracking line search is a classical Armijo-type backtracking strategy, already used for nonconvex optimization in (Beck, 2017, Chapter 10) or Ochs et al. (2014). Other procedures could be investigated in future work. For instance, Li & Lin (2015) uses a Barzilai-Borwein rule to initialize the backtracking line search. Scheinberg et al. (2014) and Calatroni & Chambolle (2019) have also proposed a backtracking strategy that allows for both decreasing and increasing of the stepsize. + +We now give the proof of Proposition 1. + +Proof. For a given stepsize $\tau$ , we showed in Appendix C, equation (33) that + +$$ +F ( x _ { k } ) - F ( T _ { \tau } ( x _ { k } ) ) \geq \frac { 1 } { 2 } \left( \frac { 1 } { \tau } - L \right) | | T _ { \tau } ( x _ { k } ) - x _ { k } | | ^ { 2 } . +$$ + +$\begin{array} { r } { \tau < \frac { 1 - 2 \gamma } { L } } \end{array}$ $\begin{array} { r } { \frac { 1 } { 2 } \big ( \frac { 1 } { \tau } - L ) > \frac { \gamma } { \tau } } \end{array}$ + +$$ +F ( x _ { k } ) - F ( T _ { \tau } ( x _ { k } ) ) > \frac { \gamma } { \tau } | | T _ { \tau } ( x _ { k } ) - x _ { k } | | ^ { 2 } . +$$ + +Hence, when $\begin{array} { r } { \tau < \frac { 1 - 2 \gamma } { L } } \end{array}$ , the sufficient decrease condition equation (42) is satisfied and the backtracking procedure $\tau \eta \tau$ ) must end. + +In the proof of Theorem 1, we can replace the sufficient decrease (33) by (42) and finish the proof with the same arguments. In the same way, in the proof of Theorem 2 given in (Attouch et al., 2013, Theorem 5.1), our sufficient decrease (42) replaces (Attouch et al., 2013, Equation (52)). + +# H DRUNET light ARCHITECTURE + +The architecture of the DRUNet light denoiser of (Zhang et al. (2021)) is given in Figure 4. + +![](images/3255bc3c33909fb9f12b0c0f1f29e343c4731d4e23fb9a96aa123d7d78d8aaaa.jpg) +Figure 4: Architecture of the DRUNet light denoiser (Zhang et al. (2021)) used to parameterize $N _ { \sigma }$ + +# I EXPANSIVENESS OF THE DENOISER + +As $g _ { \sigma }$ is not necessarily convex, our GS-DRUNet denoiser $D _ { \sigma } = \mathrm { I d } - \nabla g _ { \sigma }$ is not necessarily nonexpansive and neither is the gradient step $\mathrm { I d } - \lambda \tau \nabla g _ { \sigma }$ . This is not an issue as, unlike previous theoretical $\mathrm { P n P }$ studies (Terris et al., 2020; Reehorst & Schniter, 2018), our convergence results do not require a nonexpansive denoising step. To advocate that our method converges without this assumption, we show in Figure 5 the evolution of $\frac { | | D _ { \sigma } ( x _ { k + 1 } ) - D _ { \sigma } ( x _ { k } ) | | } { | | x _ { k + 1 } - x _ { k } | | }$ along the algorithm that was run to obtain the super-resolution results of Figure 7. In this experiment, backtracking did not get activated and stayed fixed at $\lambda \tau = 1$ . The gradient step in the PGD algorithm was thus simply a denoising step $D _ { \sigma } = \mathrm { I d } - \lambda \tau \nabla g _ { \sigma }$ . Note that the Lipschitz constant of $D _ { \sigma }$ goes above 1 but convergence is still observed as shown by the two convergence curves in Figure 7. + +![](images/9fb170bd61d7b07333ee387145d4131fcfb4c08cb743516902cd6b69a6d0af95.jpg) +Figure 5: Lipschitz constant of $D _ { \sigma }$ along the iterates of the algorithm when performing the superresolution experiments presented Figure 7. Note that the Lipschitz constant goes above 1 i.e. $D _ { \sigma }$ is not nonexpansive, but we still empirically verified convergence (see convergence curves Figure 7). + +# J ADDITIONAL EXPERIMENTS + +# J.1 DEBLURRING + +We give here additional image deblurring experiments. We first present the PSNR performance comparison on the Set3c dataset in Table 4. We also provide an evaluation of the 3 best methods $( \mathrm { G S - P n P } ,$ DPIR and IRCNN) on the full CBSD68 dataset in Table 5. For fair comparison with RED, we also display in Table 6 the PSNR calculated on the Y channel only. An additional visual + +comparison is finally shown in Figure 6. Details and comments are given in the corresponding captions. + +
v Method(a)(b)(c)(d)(e)(f)(g)(h)(i)iAvg
111
EPLL23.8324.1424.8319.8526.0821.7721.5321.5722.4321.3622.74
RED29.2128.5829.5224.5430.4525.3426.0626.0725.1128.5027.34
IRCNN33.3633.0633.1132.8734.2434.0833.2532.8727.7829.6732.45
MMO32.8432.2932.7631.8534.0833.7633.1132.3826.3129.9131.93
DPIR34.9434.4634.2534.3435.5735.5334.4934.2128.1429.63333.56
GS-PnP34.5834.1334.0433.9335.4535.2534.3033.9728.1629.7833.34
EPLL21.2121.1022.6518.7824.1220.7720.4219.8920.6120.6021.02
RED25.4224.8925.6922.6726.8623.8424.0623.8721.4925.4524.43
IRCNN29.0828.6229.0328.4630.5130.0629.2328.7424.3927.3928.55
DPIR30.3329.7429.8729.6731.2731.0830.2129.7225.0227.8429.48
GS-PnP30.2929.8430.1429.5831.5331.2430.4129.9626.1328.5629.77
EPLL19.8419.6021.4017.7122.7719.6819.0218.2419.8120.1219.82
RED21.9321.2722.7920.3224.0122.0522.0621.4119.7923.2121.88
IRCNN26.8526.3327.0426.1028.4627.9027.0526.5622.9026.1626.54
DPIR27.9627.3728.0727.4429.4229.0428.3227.5623.5726.9327.57
GS-PnP 28.0827.7528.3527.5629.6029.1728.4928.0124.6727.47 27.91
+ +Table 4: PSNR(dB) comparison of image deblurring methods on set3C with various blur kernels $k$ and noise levels $\nu$ . Best and second best results are displayed in bold and underlined. Similar to Table 2, for all kinds of kernels, the proposed method outperforms all competing methods at noise levels 0.03 and 0.05 and follows DPIR at lower noise level 0.01. +Table 5: PSNR(dB) performance of the fastest method (IRCNN/DPIR/GS-PnP) for image deblurring on the full CBSD68 dataset with various blur kernels $k$ and noise levels $\nu$ , in the same conditions as Table 2. On CBSD10 (Table 2) or on CBSD68 (Table 5), we observed very similar performance gaps between the compared methods, which confirms that CBSD10 is large enough to compare accurately the PnP methods. + +
v Method(a)(b)(C)(d)(e)(f)(g)(h)iiAvg
1111
IRCNN32.4732.1431.9431.9732.9433.1331.9231.6227.5728.4531.42
0DPIR33.2632.8232.4832.6533.5733.8532.4932.2227.6528.2631.93
0GS-PnP32.9532.5432.2632.3133.4133.7132.2931.9227.4328.1731.70
IRCNN28.4328.1128.2827.8729.4229.2128.3727.9725.5226.9628.01
DPIR28.8828.5328.5528.3029.5829.6228.6928.2825.6026.9628.30
GS-PnP28.6428.3228.5528.0629.7129.6028.6928.3125.7927.1028.28
IRCNN100DPIRGS-PnP26.7326.4226.7326.1327.6927.3926.6926.3324.6826.1826.40
27.0426.8027.0726.5328.0027.8527.1726.7224.7526.3226.82
26.9326.7227.0726.4528.0927.8727.2126.8225.0226.45 26.8626.45 26.86
+ +
(a)(b) (c)(d)(e)(f)(g)(h)ii
VMethod1 111·Avg
√2/255REDy GS-PnPy 36.20 35.76 35.21 35.55 36.33 36.87 35.16 34.79 29.21 29.48 34.4535.19 34.7834.58 34.64 35.49 35.65 34.7034.37 30.15 31.15 34.07
0.01REDy GS-PnPy 33.88 33.5233.3933.20 33.20 33.05 34.20 34.21 33.22 32.90 28.77 30.44 32.67 33.15 33.15 34.35 34.58 33.22 32.8128.23 29.12 32.59
0.03REDy GS-PnPy29.26 29.4528.83 29.1129.28 29.3928.8230.5530.4629.55228.53 30.64 30.48 29.50 29.06 26.18 28.78 29.05 29.14 26.50 28.02 29.01
0.05REDy26.9126.5427.5226.23 GS-PnPy 27.65 27.48 27.88 27.19 28.90 28.67 28.03 27.59 25.62 27.29 27.6328.6828.2527.6727.07 25.36 27.98 27.22
+ +Table 6: PSNR(dB) performance, evaluated on the luminance channel in YcbCr color space, of RED and $\mathrm { G S - P n P }$ for image deblurring on CBSD10. Remind that our method treats the RGB image as a whole before being evaluated on the Y channel while RED treats the Y channel independently. Compared to Table 2, we add the case $\nu = \sqrt { 2 } / 2 5 5$ as in RED original paper (Romano et al. (2017)). Note that RED was optimized for kernels (i) and (j) and $\nu = \sqrt { 2 } / 2 5 5$ , and outperforms our method in this set of conditions. However, over the variety of kernels and noise levels, and in particular for motion blur, our method generally outperforms RED. + +![](images/4314058f694654da9f2ae1a830510191c2445c07a5e6f9482f4a832c44f99dd7.jpg) +Figure 6: Deblurring with various methods of an image from CSBD10 degraded with the indicated blur kernel and input noise level $\nu = 0 . 0 1$ . In (g) and (h), we show the evolution of $F ( x _ { k } )$ and $\begin{array} { r } { \gamma _ { k } = \operatorname* { m i n } _ { 0 \leq i \leq k } | | \bar { x } _ { i + 1 } - x _ { i } | | ^ { 2 } / | | x _ { 0 } | | ^ { 2 } } \end{array}$ along our algorithm. Note that ${ \mathrm { G S } } { \mathrm { - } } { \mathrm { P n } } { \mathrm { P } }$ and DPIR both recover fine textures while other methods tend to smooth details. + +# J.2 SUPER-RESOLUTION + +We also present additional super-resolution experiments. We realize a full PSNR performance comparison on the Set3c dataset Table 7. We show additional visual comparisons between methods Figure 7 and Figure 8. Details and comments are given in the corresponding captions. + +Table 7: PSNR(dB) comparison of image super-resolution methods on set3C with various scales $s$ , blur kernels $k$ and noise levels $\nu$ . Similar to Table 3, for isotropic and anisotropic kernels, the proposed method outperforms all competing methods at noise levels 0.03 and 0.05 and follows DPIR at lower noise level 0.01. + +
KernelsMethods=2s=3Avg
v = 0.01 v =0.03 v= 0.05 v = 0.01 v= 0.03 v = 0.05
19.5319.1120.46
RED IRCNN28.22 28.3525.62 26.4023.61 25.2724.91 25.6123.38 24.4521.82 23.3724.59 25.58
DPIR GS-PnP29.08 29.2427.27 28.0326.21 26.6526.55 25.9025.33 25.5624.41 24.6026.48 27.00
18.4019.11
Bicubic RED19.82 24.7219.58 22.5519.16 21.1018.95 22.8218.76 21.6420.1922.17
IRCNN DPIR25.10 26.2223.44 24.5222.52 23.5624.25 25.3422.60 23.5721.5823.25
N□22.5024.29 24.18
24.53 23.7322.71
+ +
KernelsMethods=2s=3Avg
V = 0.01 v=0.03 v=0.05 v= 0.01 iv=0.03v=0.05
IRCNN DPIR26.9725.8625.45 25.8325.6024.7224.3825.50 26.03
GS-PnP27.79 27.8826.58 26.8126.0126.05 25.9725.27 25.3524.66 24.7426.13
IRCNN25.4124.5224.1824.9424.04
DPIR26.0824.9924.3925.5323.6124.45
24.4623.8024.88
GS-PnP25.9825.0724.5325.4724.5623.9224.92
+ +Table 8: PSNR(dB) performance of the fastest method (IRCNN/DPIR/GS-PnP) for image superresolution on the full CBSD68 dataset with various blur kernels $k$ and noise levels $\nu$ , in the same conditions as Table 3. Once again, on CBSD10 (Table 2) or on CBSD68 (Table 5), we observed very similar performance gaps between the compared methods, which again confirms that CBSD10 is large enough to compare accurately the PnP methods. + +![](images/f2520b537ce5fa5a2f9bc03c17ec6053aa054ccadfe1551a2dee0f51eb3ef37f.jpg) +Figure 7: Super-resolution with various methods on a CBSD10 image degraded with the indicated blur kernel, $s = 2$ and input noise level $\nu = 0 . 0 5$ . In (g) and (h), we show the evolution of $F ( x _ { k } )$ and $\begin{array} { r } { \gamma _ { k } = \operatorname* { m i n } _ { 0 \leq i \leq k } | | x _ { i + 1 } - x _ { i } | | ^ { 2 } / | | x _ { 0 } | | ^ { 2 } } \end{array}$ along our algorithm. One can notice that the proposed method GS-PnP manages to extract more structure in the zoomed area than the competing methods. + +![](images/7023dc2d45bdcb29416d30332c7525640c0cf34557a6ffec8bfbb0f635ffba1b.jpg) +Figure 8: Super-resolution with various methods on a CBSD10 image degraded with the indicated blur kernel, $s = 3$ and input noise level $\nu = 0 . 0 1$ . In (g) and (h), we show the evolution of $F ( x _ { k } )$ and $\begin{array} { r } { \gamma _ { k } = \operatorname* { m i n } _ { 0 \leq i \leq k } | | x _ { i + 1 } - x _ { i } | | ^ { 2 } / | | x _ { 0 } | | ^ { 2 } } \end{array}$ along our algorithm. + +# J.3 INPAINTING (WITH NON-DIFFERENTIABLE DATA-FIDELITY TERM) + +We now propose to apply our $\mathrm { P n P }$ scheme to image inpainting with the degradation model + +$$ +y = A x +$$ + +where $A$ is a diagonal matrix with values in $\{ 0 , 1 \}$ . For inpainting, no noise is added to the degraded image. In this context, the data-fidelity term is the indicator function of ${ \cal A } ^ { - 1 } ( \{ y \} ) = \{ x \mid { \bf \bar { \cal A } } x =$ $y \}$ : $f ( x ) = \iota _ { A ^ { - 1 } ( \{ y \} ) }$ (which, by definition, equals 0 on $A ^ { - 1 } ( \{ y \} )$ and $+ \infty$ elsewhere). Despite being non differentiable, $f$ still verifies the assumptions of Theorems 1 and 2 and convergence is theoretically ensured. The proximal map becomes the orthogonal projection $\Pi _ { A ^ { - 1 } ( \{ y \} ) }$ + +$$ +\operatorname* { P r o x } _ { \tau f } ( x ) = \Pi _ { A ^ { - 1 } ( \{ y \} ) } ( x ) = A y - A x + x +$$ + +In our experiments, the diagonal of $A$ is filled with Bernoulli random variables with parameter $p \ : = \ : 0 . 5$ . We run our $\mathrm { P n P }$ algorithm with $\sigma = 1 0 / 2 5 5$ . Given the form of $f$ , we do not use the backtracking strategy and keep a fixed stepsize. Even if we do not exactly know the Lipschitz constant of $\nabla g _ { \sigma }$ , we observed in Figure 5 that, for small noise, it was almost always estimated as slightly larger than 1. We thus choose $\lambda \tau = 1$ and empirically confirm convergence with this choice in follow-up experiments (see Figure 9). The algorithm is initialized with $x _ { 0 } ^ { \top } = y + 0 . 5 ( \mathrm { I d } - A ) y$ (masked pixels with value 0.5) and terminates when the number of iterations exceeds $K = 1 0 0$ . We found it useful to run the first 10 iterations of the algorithm at larger noise level $\sigma = 5 0 / 2 5 5$ . As $y$ does not have noise, we found preferable not to run the last extra gradient pass from Algorithm 1. + +We show inpainting results on set3C images Figure 9. Our $\mathrm { P n P }$ restores the input images with high accuracy, including its small details. Furthermore, convergence of the residual at rate $\scriptstyle { \mathcal { O } } ( { \frac { 1 } { k } } )$ is empirically confirmed. + +![](images/0a601a3a9c6f174f502a77c07ff77706f40a4ff0b90b1833ba9c45803a5c85f1.jpg) +Figure 9: Inpainting results on set3C with pixels randomly masked with probability $p = 0 . 5$ . In the last colomn, we show the evolution of $\begin{array} { r } { \gamma _ { k } \stackrel { - } { = } \operatorname* { m i n } _ { 0 \leq i \leq k } | | \dot { x _ { i + 1 } } - x _ { i } | | ^ { 2 } / | | \bar { x _ { 0 } } | | ^ { 2 } } \end{array}$ along the iterations. + +# J.4 PSNR CONVERGENCE CURVES + +We first plot Figure 10 the evolution of the PSNR along the iterations of the $\mathrm { P n P }$ algorithm during the experiments of Figure 1 and Figure 2. This illustrates that the minimization of $F$ coincides with the maximization of the PSNR, which supports the interest of the optimized functional $F = f + \lambda g _ { \sigma }$ . + +![](images/1716dafc42475b68c8d25f7ab6ff89f55b6a91fd1ddc5d0ba437f0b815446292.jpg) +Figure 10: Evolution of the PSNR along the iterations of the algorithm, during (a) the deblurring experiment of Figure 1 and (b) the super-resolution experiment of Figure 2. Note that the convergence in PSNR follows the convergence in function value (represented in Figures $1 ( \mathrm { g } )$ and $2 ( \mathbf { g } ) )$ . + +# J.5 INFLUENCE OF THE PARAMETERS + +In this section we study more deeply the influence of the parameters involved in the $\mathrm { G S - P n P }$ algorithm. Three parameters are involved: the stepsize $\tau$ , the denoiser level $\sigma$ and the regularization parameter $\lambda$ . + +• The stepsize $\tau$ is automatically tuned with backtracking and is not tweaked heuristically, contrary to other competing methods based on PnP-HQS. +• The first regularization parameter $\sigma$ is linked to the used denoiser. +• The second regularization parameter $\lambda$ is introduced so as to target the objective function $f + \lambda g _ { \sigma }$ , which is the main purpose of our method. It is a classical formulation of inverse problems, and the trade-off parameter $\lambda$ is usually tuned manually. + +Thus, like PnP-HQS, we have two parameters that we are free to tune manually. One additional motivation for keeping both $\lambda$ and $\sigma$ as regularization parameters is to be able to use our $\mathrm { P n P }$ algorithm with noise-blind denoisers like DnCNN that are independent on $\sigma$ . In practice, in our experiments, we first roughly estimated $\sigma$ proportionally to the input noise level $\nu$ and tweaked $\lambda$ more precisely. Note that, for each inverse problem, our parameters $\lambda$ and $\sigma$ are fixed for a large variety of kernels, images and noise levels $\nu$ . The parameters are not optimized for each image. + +Figure 11 and Figure 12 respectively plot the average PSNR when deblurring the CBSD10 images with different values $\lambda _ { \nu }$ and $\sigma / \nu$ , and fixed $\nu = 0 . 0 3$ . Both parameters control the strength of the regularization. We observe that $\lambda _ { \nu }$ and $\sigma$ have a similar influence on the output: for small $\lambda _ { \nu }$ or small $\sigma$ , the regularization involved by the denoising pass is not sufficient to counteract the noise amplification done by the proximal steps with large $\tau$ (recall that when $\tau \infty$ , $\operatorname { P r o x } _ { \tau f }$ tends to the pseudo-inverse of $A$ ). On the contrary, as expected, increasing $\lambda$ and $\sigma$ tends to over-smooth the output result. + +On a single image, we also vary the main parameters of both $\mathrm { G S - P n P }$ and RED (Figure 13). For fair comparison, the PSNR is computed on the luminance channel only. This experiment confirms that, when manually optimizing the parameters for both methods, the PSNR results obtained with $\mathrm { G S - P n P }$ and RED remain close, as already observed in Table 6. + +![](images/a46582797d93ff91747e789c4e016f62280b308467f3695e189faf49ce91195e.jpg) +Figure 11: Influence of the choice of the parameter $\lambda _ { \nu }$ for deblurring. Top: average PSNR when deblurring the images of CBSD10, blurred with motion blurs or static blurs, for different values of $\lambda _ { \nu }$ . The other parameters remain unchanged. Bottom: visual results when deblurring “starfish” with various $\lambda _ { \nu }$ (in the same conditions as Figure 1). + +![](images/245a58fc623989f1bbd8ec4e749ee441db8369f1598258f115e484a2f5be3d74.jpg) +Figure 12: Influence of the choice of the parameter $\sigma$ for deblurring. Top: average PSNR when deblurring the images of CBSD10, blurred with the 10 kernels, for different values of $\sigma / \nu$ , with $\nu = 0 . 0 3$ . The other parameters remain unchanged. Bottom: visual results when deblurring “starfish” with various $\sigma / \nu$ , with $\nu = 0 . 0 3$ (in the same conditions as Figure 1). + +![](images/2b4af765fbb209cbec8c17e2bd8892923fcad7d2064143aedcfd54fca31b3544.jpg) +Figure 13: Influence of the parameters $\sigma$ and $\lambda$ for RED and $\mathrm { G S - P n P }$ when deblurring the single image “starfish” degraded with uniform kernel and $\nu = 7 . 6 5 / 2 5 5$ . For fair comparison, like in Table 6, the PSNR is calculated on the $Y$ channel only. Remember that the results of Table 6 were obtained with $\sigma = 3 . 2 5 , \lambda = 0 . 0 2$ for RED and $\sigma = 2 \nu , \lambda = 0 . 0 7 5$ for $\mathrm { G S - P n P . }$ + +# J.6 INFLUENCE OF THE INITIALIZATION + +In Figure 14, we examine the robustness of the method to the initialization. As can be seen on this experiment, the output image does not change much even for relatively large perturbation of the initialization. We thus observe a robustness to the initialization, both in terms of visual aspect and PSNR. We also observed that initializing with a uniform image does not change the output of the algorithm. We suggest that this robustness comes from the first proximal steps on the data-fidelity term (with a large $\tau$ ), which prevent the algorithm to be stuck in a poor local minimum. Note that the use of large $\tau$ in the beginning of the algorithm is possible thanks to the backtracking procedure. + +![](images/03cc2d5ed6aeb900941c267279a851c1c1e3a3dae7aeab2e29aed22ac9c20535.jpg) +Figure 14: Influence of the initialitation $z _ { 0 }$ on the deblurring result. Instead of initializing with the blurred image $z _ { 0 } ~ = ~ y$ as done in Section 5.2.1, we set $z _ { 0 } = y + \xi _ { \sigma _ { \mathrm { i n i t } } }$ with $\xi _ { \sigma _ { \mathrm { i n i t } } }$ an AWGN with standard deviation $\sigma _ { \mathrm { i n i t } }$ . By increasing the noise level $\sigma _ { \mathrm { i n i t } }$ , we investigate the robustness of the result to changes in the initialization of the algorithm. Top: PSNR values, along with values of $\sigma _ { \mathrm { i n i t } }$ . Bottom: corresponding visual results on “starfish” with various $\sigma _ { \mathrm { i n i t } }$ (in the same conditions as Figure 1). The algorithm is robust to noisy initializations up to a relatively large value of $\sigma _ { \mathrm { i n i t } }$ . + +# J.7 CONVERGENCE OF DPIR (ZHANG ET AL. (2021)) + +In this section, we illustrate that, contrary to our method, the DPIR algorithm is not guaranteed to converge and can even easily diverge. In Figure 15, we plot the convergence curves of both DPIR and our $\mathrm { G S - P n P }$ when deblurring the “starfish” image degraded with a motion kernel and $\nu = 0 . 0 1$ . In the original DPIR paper Zhang et al. (2021), only 8 iterations are used with decreasing $\tau$ and $\sigma$ . More precisely, $\sigma$ decreases uniformly in log-scale from 49 to the input noise level $\nu$ , and $\tau$ is set proportional to $\sigma ^ { 2 }$ . In order to study the asymptotic behaviour of the method, we propose two strategies to run DPIR with 1000 iterations: + +(i) Decreasing $\sigma$ from 49 to $\nu$ over 1000 iterations instead of 8 (Figure 15, row 1). (ii) Decreasing $\sigma$ from 49 to $\nu$ in 8 iterations, and then keep the last values of $\sigma$ and $\tau$ for the the remaining iterations (Figure 15, row 2). + +As illustrated by the plot of $\textstyle \sum _ { i \leq k } | | x _ { i + 1 } - x _ { i } | | ^ { 2 }$ (third column), DPIR fails to converge with both strategies, even if the residual $\overline { { | } } | x _ { k + 1 } - x _ { k } | | ^ { 2 }$ tends to decrease with the second strategy. This divergence also involves a loss of restoration performance in terms of PSNR (first column). On the other hand, as theoretically shown in this paper, the residual $| | x _ { k + 1 } - x _ { k } | | ^ { 2 }$ with $\mathrm { G S - P n P }$ tends to 0 (reaches $\sim 1 0 ^ { - 1 3 }$ before the activation of backtracking, versus $\sim 1 0 ^ { - 4 }$ for DPIR) and its series converges. + +![](images/2da1a259cd8d03c5d418fa6abff5a7df954d1405174b56e3f645b36373ab8c7b.jpg) +Figure 15: Convergence of the DPIR algorithm versus convergence of $\mathrm { G S - P n P }$ when deblurring the “starfish” image. The two first rows display results obtained with DPIR with two different strategies used for decreasing $\sigma$ : in the first row, $\sigma$ is decreased from 49 to $\nu$ over 1000 iterations; in the second row, $\sigma$ is decreased in 8 iterations and then kept fixed for the remaining iterations. \ No newline at end of file diff --git a/md/dev/gzCS252hCO/gzCS252hCO.md b/md/dev/gzCS252hCO/gzCS252hCO.md new file mode 100644 index 0000000000000000000000000000000000000000..791630f25399e3354fa17039c0a644d6f9dde0b7 --- /dev/null +++ b/md/dev/gzCS252hCO/gzCS252hCO.md @@ -0,0 +1,575 @@ +# Voicebox: Text-Guided Multilingual Universal Speech Generation at Scale + +Matthew $\mathbf { L e ^ { * } }$ Apoorv Vyas∗ Bowen Shi∗ Brian Karrer∗ Leda Sari Rashel Moritz Mary Williamson Vimal Manohar Yossi Adi† Jay Mahadeokar Wei-Ning Hsu∗ + +Fundamental AI Research (FAIR), Meta + +# Abstract + +Large-scale generative models such as GPT and DALL-E have revolutionized the research community. These models not only generate high fidelity outputs, but are also generalists which can solve tasks not explicitly taught. In contrast, speech generative models are still primitive in terms of scale and task generalization. In this paper, we present Voicebox, the most versatile text-guided generative model for speech at scale. Voicebox is a non-autoregressive flow-matching model trained to infill speech, given audio context and text, trained on over 50K hours of speech that are not filtered or enhanced. Similar to GPT, Voicebox can perform many different tasks through in-context learning, but is more flexible as it can also condition on future context. Voicebox can be used for mono or cross-lingual zero-shot textto-speech synthesis, noise removal, content editing, style conversion, and diverse sample generation. In particular, Voicebox outperforms the state-of-the-art zeroshot TTS model VALL-E on both intelligibility $5 . 9 \%$ vs $1 . 9 \%$ word error rates) and audio similarity (0.580 vs 0.681) while being up to 20 times faster. Audio samples can be found in https://voicebox.metademolab.com. + +# 1 Introduction + +Recent advances in large-scale generative models [6, 42, 50] have led to a major paradigm shift towards building general-purpose models, which can perform many new tasks not explicitly trained on. These generative models learn to predict the missing data given the context. Post training, we can directly input a question, optionally with a few contextual question-answer examples, instead of fine-tuning with labeled data. While the training objective appears simple, it subsumes many tasks as one can convert them into some form of context. For the model to perform well at every task, it implies that the estimation of $p$ (missing data | context) needs to be accurate for every context. Hence, scale and diversity are the most crucial factors for building general-purpose models [20, 1]. + +Despite the success of large-scale generative models in other areas, most speech models are still trained on datasets at the scale of tens to hundreds of hours [51, 31, 32, 46, 24, 58, 7]. Previous works consider highly curated datasets such as VCTK [64], which contains only clean audio recorded in studio from about 100 speakers with little speaking style and text variation. Such models struggle to synthesize speech with rich variation in emotion, voice, background noise, acoustic condition, and have not been tested on the abilities to generalize to tasks not explicitly trained on. + +This paper presents Voicebox, the most versatile text-conditioned speech generative model at scale. Voicebox is trained on a text-guided speech infilling task, where the goal is to generate masked speech given its surrounding audio and text transcript. This can be considered as a guided in-context learning problem, where audio style is inferred from the audio context and textual content is specified through transcript. Voicebox does not require any audio style labels (e.g., speaker, emotion, and noise), which differentiates Voicebox from the majority of prior work where such labels are used extensively. Prior work uses labels to make the mapping between input (text and audio style) and output (speech) more deterministic to reduce underfitting [60, 46]. We show that Voicebox’s text-guided speech infilling approach is much more scalable in terms of data while subsuming many common generative tasks. + +![](images/39d027059d30c1fddb494cb355bf8ffce4f71e6a84b8b8358a28411a3ab65338.jpg) +Figure 1: Task generalization via in-context learning. + +Table 1: Comparing Voicebox with baselines on task capabilities. ∗Through infilling, A3T and Voicebox can remove transient noise but not stationary background noise. + +
ModelZS TTSDenoise Edit Sampling
YourTTSXX
VALL-E×X
A3T*X
DemucsXXX
Voicebox*
+ +In terms of modeling, Voicebox is a non-autoregressive (NAR) continuous normalizing flow (CNF) model [10]. Similar to diffusion models [19], CNFs model the transformation from a simple distribution to a complex data distribution, parameterized by a neural network. We train Voicebox with flow-matching [38], a recently proposed method that enables efficient and scalable training of CNFs via a simple vector field regression loss. In contrast to auto-regressive models, Voicebox can consume context not only in the past but also in the future. Moreover, the number of flow steps can be controlled at inference time to flexibly trade off quality and runtime efficiency. + +Voicebox is trained on 60K hours of English audiobooks and 50K hours of multilingual audiobooks in 6 languages for the mono and multilingual setups. Voicebox achieves state-of-the-art performance on mono-lingual/cross-lingual zero-shot TTS, speech denoising, speech editing, diverse speech sampling and an application to data creation for speech recognition. To tackle the lack of comparability due to the use of subjective metrics, this paper presents a series of metrics using public models to facilitate reproducible comparison and model development for speech generation studies. + +# 2 Related Work + +Generative speech models: Most speech generative models are task-specific and trained on different datasets. One common type of task is audio style conversion, which aims to convert only a specific attribute while keeping other attributes the same. Voice conversion [27, 39], emotion conversion [53, 34], speech enhancement [63, 11, 55] belong to this category. Many of these models are supervised and trained on pairs of data that only differ in one attribute, for example, emotion [34]. It is hard to obtain such data. Moreover, some attributes, such as speaking style, are hard to annotate. Hence, these models are often trained on small datasets. + +Controllable text-to-speech synthesis (TTS) is another common task, which aims to synthesize speech in a target audio style given text. While some styles like voice can be specified through labels [32] or pre-trained embeddings like YourTTS [7] and Jia et al. [25]; others like prosody are hard to annotate or embed. Previous studies [62] tried to control them by learning a residual embedding. However, these models encode style in a low-dimensional space and impose an overly simple distribution of speech given text and residual embedding [51, 56]. They cannot generate realistic noisy speech given a low dimensional vector, and performance degrades when conditioned on noisy references [21]. + +Infilling can be considered as another type of task. It aims to predict speech given context [36, 4] and optionally text guidance [3, 5, 61]. Instead of learning an explicit embedding to control style, infilling models predict speech coherent to the context. In other words, these models perform incontext learning similar to Large Language Models (LLM). While this is a step toward building large scale generalist models using little explicit supervision, most prior work using text guidance still assumes a deterministic mapping from text and context to target [3, 5], which is only realistic for very short segments. Voicebox is a text-guided infilling model, but it leverages the CNF model that can parameterize any distribution. Hence, Voicebox can infill speech of any length and can be trained on in-the-wild datasets with rich variation, and provide a general solution that subsumes many tasks in a text-guided fashion. + +Large scale in-context learning models: With the advancement in neural codec for speech [22, 12, 67], many recent studies explore token-based language modeling for speech generation. The GSLM-family [36, 28, 41] are textless language models built upon HuBERT units [22] for speech continuation without using text. HuBERT units encode mostly content, and the generated speech does not preserve the voice of the prompt. To tackle this, AudioLM [4] considers a cascaded approach which first generates HuBERT-like tokens and then predicts SoundStream [67] tokens, a reconstruction based codec that preserves style. These models are not conditioned on text and are evaluated on spoken language modeling tasks. + +VALL-E [61] is most related to Voicebox. It is a text conditioned LM trained on Encodec [12] tokens (similar to SoundStream). Encodec encodes each frame with 8 ordered codebooks at $7 5 \mathrm { H z }$ using a residual quantization layer. VALL-E has two modules. The first is an auto-regressive (AR) model that predicts the first code of each frame given text and the audio prompt. The second is an NAR model that predicts the remaining seven codebooks sequentially. + +VALL-E demonstrates state-of-the-art (SOTA) zero-shot TTS performance through in-context learning, where speech of the desired style is used as prompt. The model considers the prompt as part of the whole utterance such that it generates the rest of the utterance containing the target text in the same audio style. Voicebox has several design advantages compared to this. 1) Voicebox can use context both in the past and future, which is useful for editing where only a segment in the middle needs to be generated. 2) Voicebox can generate speech much faster than VALL-E because flow-matching can produce high quality samples with less than 10 NAR steps, while VALL-E requires 1 AR and 7 NAR steps. 3) Voicebox decouples duration and audio modeling, enabling finer grained alignment control. 4) Voicebox is compatible with any continuous features including Encodec embeddings. + +# 3 Method + +# 3.1 Background: Flow Matching with an optimal transport path + +Let $\mathbb { R } ^ { d }$ be the data space with data points $x \in \mathbb { R } ^ { d }$ drawn from some unknown distribution $q ( x )$ . Continuous Normalizing Flows (CNFs) [10] are a family of generative models that learn the transformation from a simple prior distribution $p _ { 0 }$ (e.g., normal distribution) to the data distribution $p _ { 1 } \approx q$ . CNFs parameterize a time-dependent vector field $v _ { t } : [ 0 , 1 ] \times \mathbb { R } ^ { d } \to \mathbb { R } ^ { d }$ that is used to construct a flow: $\phi _ { t } : [ 0 , 1 ] \times \mathbb { R } ^ { d } \to \mathbb { R } ^ { d }$ that pushes points from the prior towards the target distribution. The relationship is defined via the ordinary differential equation (ODE) as: $d \bar { \phi _ { t } } ( x ) / d t = v _ { t } ( \phi _ { t } ( x ) )$ and $\phi _ { 0 } ( x ) = x$ . For a flow $\phi _ { t }$ , the probability path (time-dependent probability density function) $p : [ 0 , 1 ] \times \mathbb { R } ^ { d } \mathbb { R } _ { > 0 }$ can be derived via the change of variables formula: $p _ { t } ( x ) = p _ { 0 } ( \phi _ { t } ^ { - 1 } ( x ) )$ det $[ { \partial \phi _ { t } ^ { - 1 } ( x ) } / { \partial x } ] .$ . To sample from $p _ { t } ( x )$ , we first draw $x _ { 0 }$ from $p _ { 0 }$ and then solve the initial value problem (IVP) for $\phi _ { t } ( x _ { 0 } )$ given $d \phi _ { t } ( x ) / d t = v _ { t } ( \phi _ { t } ( x ) )$ and $\phi _ { 0 } ( x ) = x _ { 0 }$ . We use $x _ { t }$ and $\phi _ { t } ( x _ { 0 } )$ interchangeably. + +Let $p _ { t }$ be a probability path and $u _ { t }$ be the corresponding vector field that generates $p _ { t }$ . The vector field $v _ { t } ( x ; \theta )$ parameterized by a neural network $\theta$ can be trained with the Flow Matching objective: $\mathcal { L } _ { F M } ( \theta ) = \mathbb { E } _ { t , p _ { t } ( x ) } | | u _ { t } ( x ) - v _ { t } ( x ; \theta ) | | ^ { 2 }$ , where $t \sim \mathcal { U } [ 0 , 1 ]$ and $x \sim p _ { t } ( x )$ . While the objective appears simple, in practice we do not have the prior knowledge of $p _ { t }$ or $v _ { t }$ , and cannot directly compute the loss or its gradient estimator. + +Let $x _ { 1 }$ be a random variable distributed according to data distribution $q$ . Lipman et al. [38] first notes that a probability path $p _ { t } ( x )$ can be constructed via a mixture of simpler conditional paths $p _ { t } ( x \mid x _ { 1 } )$ whose vector field $u _ { t } ( x \mid x _ { 1 } )$ can be easily computed. To construct $p _ { t } ( x )$ , a conditional path is defined such that 1) $p _ { 0 } ( x \mid x _ { 1 } ) = p _ { 0 } ( x )$ and 2) $p _ { 1 } ( x \mid x _ { 1 } ) = \mathcal { N } ( x \mid x _ { 1 } , \sigma ^ { 2 } I )$ , a Gaussian distribution centered at $x _ { 1 }$ with a sufficiently small $\sigma$ (typically $1 0 ^ { - 5 }$ ). The marginal path is computed as $\textstyle \int p _ { t } ( x \mid x _ { 1 } ) q ( x _ { 1 } ) d x _ { 1 }$ , which closely approximates $q ( x _ { 1 } )$ at $t = 1$ . With that, [38] presents the Conditional Flow Matching (CFM) objective, $\mathcal { L } _ { C F M } ( \theta ) = \mathbb { E } _ { t , q ( x _ { 1 } ) , p _ { t } ( x | x _ { 1 } ) } | | u _ { t } ( x \mid x _ { 1 } ) - v _ { t } ( x ; \theta ) | | ^ { 2 }$ + +It is proven that FM and CFM have identical gradients w.r.t. $\theta$ . More importantly, one can easily draw samples from $p _ { t } ( x \mid x _ { 1 } )$ and compute $u _ { t } ( x \mid x _ { 1 } )$ to derive an unbiased gradient estimator. + +The next question is how to choose a conditional flow. A flow defines trajectories, which dictates how each point moves between $p _ { 0 }$ and $p _ { 1 }$ . Intuitively, a simpler trajectory (e.g., a straight line) can be learned faster and the IVP can be solved more accurately and efficiently. Lipman et al. [38] presents a conditional flow called optimal transport (OT) path, which has the form of $p _ { t } ( x \mid x _ { 1 } ) \stackrel { \textstyle = } { = } { \cal N } ( x \mid$ $t x _ { 1 } , ( 1 - ( 1 - \sigma _ { m i n } ) t ) ^ { 2 } I )$ and $u _ { t } ( x \mid x _ { 1 } ) = \left( x _ { 1 } - ( 1 - \sigma _ { \operatorname* { m i n } } ) x \right) / \left( 1 - ( 1 - \sigma _ { \operatorname* { m i n } } ) t \right)$ . The flow is arguably simple because points move with a constant speed and direction. We adopt it for Voicebox. + +Lipman et al. [38] also presents another flow that recovers the path of diffusion models [57], which is more complex than the OT path. We will present ablation studies comparing different paths (OT vs diffusion) and different objectives (CFM vs score-matching). Results show the superiority in performance and efficiency of CFM with OT path. + +# 3.2 Problem formulation + +Given a dataset of transcribed speech $( x , y )$ where $x$ and $y$ denote an audio sample and its transcript, respectively, the goal is to build a single model that can perform many text-guided speech generation tasks through in-context learning. We propose to train such a generative model on the text-guided speech infilling task, which predicts a segment of speech given its surrounding audio and the complete text transcript. Let $m$ be a binary temporal mask which is of the same length as $x$ , and $x _ { m i s } = m \odot x$ and $x _ { c t x } = ( 1 - m ) \odot x$ be the complementary masked versions of $x$ . The generative model learns $p ( x _ { m i s } \mid y , x _ { c t x } )$ . In other words, $y$ and $x _ { c t x }$ are the context and $x _ { m i s }$ is the missing data. + +![](images/e9cfbbdc5bbb8bbac59046bccc3311584986ff8498ce0968fa4e32f8073cf219.jpg) +Figure 2: Illustration of Voicebox training and inference. + +# 3.3 Model and Training + +Motivated by the need that some applications require fine-grained alignment control between speech and text, we decouple Voicebox into two components: an audio model and a duration model. Let $x = ( x ^ { 1 } , x ^ { 2 } , \cdot \cdot \cdot , \dot { x ^ { N } } )$ be an audio sample of $N$ frames, $y = ( y ^ { 1 } , y ^ { 2 } , \cdot \cdot \cdot , y ^ { M } )$ be a text sequence of $M$ phones, and $l = \ r ( l ^ { 1 } , l ^ { 2 } , \cdot \cdot \cdot , l ^ { M } )$ be the per-phone duration where $l ^ { j }$ denotes how many audio frames $y ^ { j }$ correspond to and $\textstyle \sum _ { j = 1 } ^ { M } l ^ { j } = N$ . We further define $z = \mathbf { r e p } ( y , l ) = ( z ^ { 1 } , z ^ { 2 } , \cdot \cdot \cdot , z ^ { N } )$ to be the frame-level phone transcript, which repeats each $y ^ { j }$ by $l ^ { j }$ times such that $z ^ { i }$ denotes the phone label of the audio frame $x ^ { i }$ . For a pair of $( x , y )$ , $l$ and $z$ can be estimated through forced alignment using a speech recognition model. The estimation of $q ( x _ { m i s } \mid y , x _ { c t x } )$ is then broken down into the audio model $q ( x _ { m i s } \mid z , x _ { c t x } )$ and the duration model $q ( l _ { m i s } \mid y , l _ { c t x } )$ , where $l _ { m i s }$ and $l _ { c t x }$ denote $l$ masked by $m ^ { \prime }$ and $1 - m ^ { \prime }$ , and $m ^ { \prime }$ is downsampled from $m$ based on $l$ , detailed in Appendix A.2. + +Audio Model: Given a context $z$ and $x _ { c t x }$ of length $N$ , the distribution of $x _ { m i s }$ is highly stochastic especially when $x _ { m i s }$ has a large temporal span. Hence, we parameterize it with a CNF and train it using the flow matching objective with the optimal transport path. Audio $x$ is represented as an 80-dimensional log Mel spectrogram $( x ^ { i } \in \mathbb { R } ^ { 8 0 } )$ extracted at a $1 0 0 \mathrm { H z }$ frame rate. The audio context $x _ { c t x } ^ { i } = \mathbf { 0 }$ where $\bar { m } ^ { i } = 1$ and $x _ { c t x } ^ { i } = x ^ { i }$ where $m ^ { i } = 0$ . For simpler conditioning, we model the conditional distribution $q ( x \mid z , x _ { c t x } )$ of all frames $x$ instead of only masked frames $x _ { m i s }$ . A neural network is used to parameterize the conditional vector field $v _ { t } ( x _ { t } , x _ { c t x } , z ; \theta )$ that additionally takes $x _ { c t x }$ and $z$ as input. Note that $x _ { t }$ is a sample at flow step $t$ and $x = x _ { 1 }$ . + +Given as input $\boldsymbol { x } _ { c t x } \in \mathbb { R } ^ { N \times F }$ , $\boldsymbol { x } _ { t } \in \mathbb { R } ^ { N \times F }$ , phone sequence $z \in [ K ] ^ { N }$ with $K$ denoting the number +of phone classes, and a time step $t \in [ 0 , 1 ]$ , we employ a Transformer model to parameterize the vector +field in ththree $v _ { t }$ . A lookmbeddedquences de , $\dot { L } \in \mathbb { R } ^ { K \times H }$ , bedfor -fra quence . Subsected b $z$ , resultinguently, themploying $z _ { e m b } \in \mathbb { R } ^ { N \times H }$ $z _ { e m b } ^ { i } = L ( z ^ { i } )$ $i \in { 1 , \dots , N }$ $( x _ { t } , x _ { c t x }$ $z _ { e m b }$ +matrix $W _ { p } \in \mathbb { R } ^ { ( 2 F + H ) \times D }$ , thereby obtaining the sequence $H _ { c } \in \mathbb { R } ^ { N \times D }$ where $D$ represents the +embedding dimension of the Transformer model. + +To embed the flow step, a sinusoidal positional encoding is applied to map $t \in [ 0 , 1 ]$ to $h _ { t } \in \mathbb { R } ^ { D }$ . The sequence $\tilde { H } _ { c } \in \mathbb { R } ^ { ( N + 1 ) \times D }$ , which serves as the input to the Transformer model, is derived by concatenating $H _ { c }$ with the vector $h _ { t }$ along the time dimension. Given the Transformer output $v _ { t } ( x _ { t } , x _ { m i s } , z ; \theta ) \in \mathbb { R } ^ { N \times F }$ , which is the sub-sequence corresponding to $H _ { c }$ , the loss is computed as: + +$$ +\begin{array} { r } { \mathcal { L } _ { \mathrm { a u d i o - C F M } } ( \theta ) = \mathbb { E } _ { t , m , q ( x , z ) , p _ { 0 } ( x _ { 0 } ) } | | u _ { t } ( x _ { t } \mid x ) - v _ { t } ( x _ { t } , x _ { c t x } , z ; \theta ) | | ^ { 2 } , } \end{array} +$$ + +by reparameterization. During training, given an audio sample $x$ and a prior sample $x _ { 0 }$ , we have $\bar { x _ { t } } = \bar { ( 1 - ( 1 - \sigma _ { \operatorname* { m i n } } ) t ) } x _ { 0 } + t x$ and $u _ { t } ( x _ { t } \mid x ) = x - ( 1 - \sigma _ { m i n } ) x _ { 0 }$ . This function computes the loss on all frames, including those that are not masked and would not be required during inference. To divert the model’s focus to masked frames, we present a masked version of $\mathcal { L } _ { \mathrm { a u d i o - C F M } }$ : + +$$ +{ \mathcal { L } } _ { \mathrm { a u d i o - C F M - m } } ( \theta ) = \mathbb { E } _ { t , m , q ( x , z ) , p _ { 0 } ( x _ { 0 } ) } | | m \odot \left( u _ { t } ( x _ { t } \mid x ) - v _ { t } ( x _ { t } , x _ { c t x } , z ; \theta ) \right) | | ^ { 2 } , +$$ + +where the loss is only computed on masked frames. Appendix B.3 shows it leads to better results + +Duration model: We consider two solutions. The first one closely follows the audio model. It models $q ( l \mid y , l _ { c t x } )$ via a conditional vector field which swaps $( x , x _ { c t x } , z )$ with $( l , l _ { c t x } , y )$ and accordingly for the flow, where $l , l _ { c t x } \in \mathbb { R } ^ { M \times 1 }$ and $y \in [ K ] ^ { M }$ . The masked version of the CFM loss is used for training. On the other hand, previous studies have shown that regression duration models can produce reasonable speech [51, 37]. Hence we consider a second solution that regresses the masked duration $l _ { m i s }$ given the context duration $l _ { c t x }$ and phonetic transcript $y$ . The same Transformer model is used, except that there are only two input sequences instead of three, and the time embedding is not used. The model is trained with an $L _ { 1 }$ regression loss on masked phones: + +$$ +\mathcal { L } _ { \mathrm { d u r - r e g r - m } } ( \theta ) = \mathbb { E } _ { m , q ( l , y ) } | | m ^ { \prime } \odot ( l _ { m i s } - g ( l _ { c t x } , y ; \theta ) ) | | _ { 1 } , +$$ + +where $g$ denotes the regression-based duration model. This is similar to the duration model used in FastSpeech2 [51], but with additional duration context $l _ { c t x }$ as input. + +# 3.4 Inference + +To sample from the the learned audio distribution $p _ { 1 } ( x \mid z , x _ { c t x } )$ , a noise $x _ { 0 }$ is first sampled from $p _ { 0 }$ , and then an ODE solver is used to evaluate $\phi _ { 1 } ( x _ { 0 } )$ given $d \phi _ { t } ( x ) / d t = v _ { t } ( \phi _ { t } ( x ) , x _ { c t x } , z ; \theta )$ and the initial condition $\phi _ { 0 } ( x _ { 0 } ) = x _ { 0 }$ . Intuitively, the ODE solver computes $\phi _ { 1 } ( x _ { 0 } )$ by evaluating $v _ { t }$ at multiple $t$ to approximate the integration from $t = 0$ to $t = 1$ given the initial condition $\phi _ { 0 } ( x _ { 0 } ) = x _ { 0 }$ . The number of function evaluation (NFE) is defined as how many times $d \phi _ { t } ( x _ { 0 } ) / d t$ is evaluated. A higher NFE often leads to a more accurate solution of $\phi _ { 1 } ( x _ { 0 } )$ at the cost of longer run time. This provides great flexibility for users to decide the trade-off between speed and accuracy. Moreover, we find that empirically Voicebox can already generate very high quality speech with less than 10 NFEs, making it significantly faster compared to auto-regressive models. + +# 3.5 Classifier-Free Guidance + +Classifier guidance (CG) [14] is a technique used to trade off mode coverage and sample fidelity for diffusion models post training. It modifies the score estimate of a diffusion model to include the gradient of the log likelihood of an auxiliary classifier. Ho and Salimans [18] notes that CG approximates sampling from $p ( x \mid c ) p ( c \mid x ) ^ { \alpha }$ where $c$ is the conditioner, and this can be simulated without a classifier by mixing the score estimate of a conditional model and an unconditional model. The unconditional model can be jointly trained by dropping the conditioner $c$ with some probability, and the same model provides score estimates for both $p ( x )$ and $p ( x \mid c )$ . + +We extend the idea of classifier free guidance (CFG) to flow-matching models. The conditioner $c$ is equivalent to $( z , x _ { c t x } )$ for audio models and $( y , l _ { c t x } )$ for duration models, which is dropped with $p _ { \mathrm { u n c o n d } }$ during training. During inference, the modified vector field $\tilde { v } _ { t }$ for the audio model becomes $\tilde { v } _ { t } ( w , x _ { m i s } , z ; \theta ) = ( 1 + \alpha ) \cdot v _ { t } ( w , x _ { c t x } , z ; \theta ) - \alpha \cdot v _ { t } ( w ; \theta )$ , where $\alpha$ is the strength of the guidance, and $v _ { t } ( w ; \theta )$ is obtained by dropping $x _ { c t x }$ and $z$ . We use $\alpha$ and $\alpha _ { d u r }$ for the CFG strengths for the audio and the duration model, selected based on validation. Note that the computation is doubled for the same NFE when using CFG, because the model forward is called twice to compute $\tilde { v } _ { t }$ . + +# 3.6 Applications + +We demonstrate that Voicebox exhibits in-context learning abilities similar to LLMs by presenting a few examples of how to create context to perform tasks Voicebox was not explicitly trained on. Fig. A1 shows a detailed diagram of how inputs are formatted for each task. + +Zero-shot TTS $\pmb { \& }$ alignment-preserved style transfer: Given a target text $\hat { y }$ and a transcribed reference audio $( x , y )$ , zero-shot TTS aims to synthesize speech resembling the possibly unseen audio style of the reference. Voicebox performs the task by treating the reference audio and the target speech as one utterance where the target speech is masked. Let $l$ and $z$ be phone duration and frame-level transcript of $( x , y )$ . The target duration $\hat { l }$ is sampled given the duration context $l$ and concatenated phone sequence $\mathsf { c a t } ( y , \hat { y } )$ . The target speech $\hat { x }$ is then sampled given the context $x$ and concatenated frame-level phones $\mathsf { c a t } ( z , \mathsf { r e p } ( \hat { y } , \hat { l } ) )$ . + +Voicebox can also convert the audio style for speech $\bar { x }$ while preserving its alignment $\bar { z }$ . This is useful for editing audio that is synchronized with other modalities such as video. Similar to zero-shot TTS, Voicebox can simply perform the task by sampling target speech $\hat { x }$ given the context $x$ and concatenated frame-level phones $\mathtt { c a t } ( z , { \bar { z } } )$ + +Transient noise removal $\pmb { \& }$ content editing: When recording speech, one might misspeak a few words or the recording my be interrupted by unexpected background noise. In these scenarios it is desired to just edit the problematic segment instead re-recording the speech. Voicebox can perform transient noise removal through re-generating the noise corrupted segment given the original frame-level transcript and the surrounding clean audio. + +For content editing, Voicebox first samples duration for the new phones given the edited phone transcript and the duration of existing phones to create the edited frame-level phone transcript. Given the new frame-level phone transcript and the audio for existing frames, Voicebox then samples the audio for frames corresponding to the new phones. + +Diverse speech sampling $\pmb { \& }$ alignment-preserved style shuffling: Voicebox can generate diverse speech samples by infilling the whole utterance. We first use the duration model to sample $\hat { l }$ given the phone transcript $\hat { y }$ . We then use the audio model to sample $\hat { x }$ given $\hat { z } = \mathbf r \mathbf e \mathbf p ( \hat { y } , \hat { l } )$ . Similar to style transfer, Voicebox can also shuffle the audio style while keeping the alignment by sampling $\hat { x }$ conditioning on the frame-level transcript $\bar { z }$ of the target speech clip $\bar { x }$ . + +# 4 Metrics + +The common goal of audio-conditioned tasks is to produce realistic speech that is coherent with the context and has the correct textual content. For tasks not conditioned on audio context, it is desired to generate diverse and realistic samples with distribution similar to training data. Prior studies often adopt subjective metrics like mean opinion scores (MOS) [52] which are not comparable across papers, or quantitative metrics like mel cepstral distortion [35] that assume the output is deterministic given input, which is often not realistic [54]. In this paper, we advocate the following reproducible model-based perceptual metrics. + +Correctness and intelligibility: We measure it by the word error rate (WER) of the synthesized speech’s transcription with respect to the input text, which has been adopted in prior work [62]. Public automatic speech recognition (ASR) models are used for comparability. For English-only setups, we follow [61] and use HuBERT-L [22] pre-trained on 60K hours of Librilight [26] and fine-tuned on 960 hours of Librispeech [43]. For multilingual setups we use the Whisper large-v2 model [49]. + +Coherence: This is measured by the similarity between the embedding of generated speech and that of the audio context, where different embedding models would reflect coherence of different attributes. VALL-E proposed to use WavLM-TDCNN speaker embedding model, which maps an audio clip to a fixed dimensional vector, to measure voice similarity. We consider the same model to compare with VALL-E. In particular, VALL-E reports similarity with respect to resynthesized audio context by its vocoder (Encodec-decoder), which we call SIM-resyn (SIM-r). SIM-resyn is not comparable across models using different vocoders. Hence, we advocate for computing similarity against the original audio context, which we call SIM-orig (SIM-o). + +Diversity and quality: Fréchet Inception Score (FID) [17] is widely adopted for image generation evaluations, which captures the similarity between generated and real images at the distribution level in some feature space. A shorter distance implies the distributions are more similar and generally reflects both higher sample quality and diversity. We adapt the metric for speech by using selfsupervised wav2vec 2.0 feature [2] and refer to it as Fréchet Speech Distance (FSD). We verify its effectiveness in Appendix C.1 along with alternative features. + +As supplementary metrics, we include quality MOS (QMOS) for subjective audio quality evaluation, and similarity MOS (SMOS) for subjective audio similarity evaluation given pairs of prompt and system-generated audio clips. Both of which are in the scale of 1 to 5 with 5 being the best. The MOS instructions and standalone metrics for duration models can be found in Appendix C. + +# 5 Experiment + +Data: We train the English-only model on 60K hours ASR-transcribed English audiobooks and the multilingual model on 50K hours of multilingual audiobooks from six languages: English (En), French $( \mathrm { F r } )$ , German (De), Spanish (Es), Polish (Pl) and Portuguese $\left( \mathrm { P t } \right)$ . The two models are abbreviated as VB-En and VB-Multi. The Montreal Forced Aligner (MFA) [40] is used to phonemize and force align the transcript based on the MFA phone set. Word position postfixes are added. Audio is represented as a 80-dimensional log Mel spectrogram and a HiFi-GAN vocoder trained on the same 60K hours English speech is used to generate waveform. More details about phone representation, data transformation, and vocoder can be found in Appendix A1-A3. + +Model: Transformer [59] with convolutional positional embedding [2] and symmetric bi-directional ALiBi self-attention bias [48] are used for both the audio and the duration model. ALiBi bias for the flow step $x _ { t }$ is set to 0. More details in Appendix Appendix A.7. The audio model has 24 layers, 16 attention heads, 1024/4096 embedding/feed-forward network (FFN) dimension, 330M parameters. The duration model has 8 heads, 512/2048 embedding/FFN dimensions, with 8/10 layers for English/multilingual setup (28M/34M parameters in total). + +Training: VB-En/VB-Multi audio models are trained for 500K/750K updates with an effective batch size of 240K frames. For training efficiency, audio length is capped at 1,600 frames and chunked randomly if length exceeds. Duration models are trained for 600K updates with an effective batch size of 60K frames. The Adam [33] optimizer is used with a peak learning rate of 1e-4, linearly warmed up for 5K steps and decays over the rest of training. The audio/duration sequence is masked with $p _ { \mathrm { d r o p } } = 0 . 3 / 0 . 2$ , and otherwise a segment of $r \%$ sequence length is masked, where $r \sim \mathcal { U } [ 7 0 , 1 0 0 ] / \mathcal { U } [ \mathrm { i } 0 , 1 0 0 ]$ . puncond is set to 0.2 for audio/duration models. + +Inference: The torchdiffeq [9] package is used, which implements both fixed and adaptive step ODE solvers. By default, the midpoint solver is used with a step size of 0.0625 $\mathrm { N F E } { = } 3 2 ,$ ). The regression duration model is used by default. Silence at both ends are trimmed to 0.1 second max. + +Baselines: We consider three baselines: 1) VALL-E [61], SOTA for English zero-shot TTS trained on Librilight. 2) YourTTS [7], SOTA multilingual zero-shot TTS model trained on VCTK, LibriTTS, TTS-Portugese [8], and M-AILABS French. It is a flow-based model adapted from VITS [32] using a pre-trained speaker embedder. 3) A3T [3], SOTA for NAR speech editing and infilling trained with a regression loss on VCTK. We also consider Demucs [11], a SOTA speech enhancement model trained with regression and adversarial losses for denoising experiments. + +# 5.1 Monolingual and cross-lingual zero-shot TTS + +Table 2 presents the zero-shot TTS results of the English model VB-En. Following [61], the test set is constructed by selecting 4 to 10 second long samples from Librispeech test-clean. We consider cross-sentence prompting where a 3 second clip from another sample of the same speaker is used as audio context, and continuation prompting where the first 3 seconds of each utterance is used. Voicebox outperforms all baselines on all metrics in both cases. In particular, Voicebox transfers style much more effectively $( + 0 . 1 0 1 / + 0 . 1 0 8$ SIM-r on cross-sentence/continuation) than VALL-E, and the gap is even bigger when compared against raw audio $( + 0 . 1 4 1$ SIM-o on continuation). MOS studies also confirm the quality and similarity of Voicebox are subjectively better than YourTTS. + +Table 2: English zero-shot TTS results on filtered LS test-clean. ∗obtained via personal communication. + +
ModelWERSIM-0SIM-rQMOSSMOS
Ground truth2.20.754n/a3.98± 0.144.01±0.09
cross-sentence
A3T63.30.0460.146
YourTTS7.70.337n/a3.27±0.133.19±0.14
VALL-E5.9-0.58011
VB-En1.90.6620.6813.78±0.103.71±0.11
continuation
A3T18.70.0580.144
VALL-E3.80.452*0.508
VB-En (α =0.7)2.00.5930.616
+ +Table 3: Transient noise removal where noise overlaps with $50 \%$ of the speech at a $- 1 0 \mathrm { d B }$ SNR. + +
ModelWERSIM-0QMOS
Clean speech2.20.6874.07±0.15
Noisy speech41.20.2872.50±0.15
Demucs32.50.3682.86±0.17
A3T11.50.1483.10±0.15
VB-En (α = 0.7)2.00.6123.87±0.17
+ +Table 4 presents cross-lingual zero-shot TTS results, where the audio context and the target text are in different languages. Note that VB-Multi is not trained on any sample with multiple languages in an utterance spoken by the same speaker. The test set is constructed using filtered MLS test split described in Appendix A.4. For each target text, we sample one 3-second long audio context from each language, which creates 36 language transfer directions in total. Voicebox yields better performance than YourTTS everywhere. Specifically, on En/Fr/Pt which YourTTS supports, Voicebox obtains $3 . 1 \% / 5 . 9 \% / 8 . 1 \%$ lower WERs and 0.136/0.141/0.160 higher similarity averaged across audio context in six languages. Addition studies on prompt lengths are presented in Appendix B.2 + +Table 4: Multilingual zero-shot TTS results on filtered MLS test sets. GT/YT/VB-Multi refers to ground truth/YourTTS/multilingual Voicebox. “Ref” column shows the audio context language. + +
RefDeEnEsFrP1Pt
WERSIM-0WERSIM-0WERSIM-0WERSIM-0WERSIM-0WERSIM-0
GT-5.90.7255.00.6364.10.7295.20.7144.90.7435.80.725
YTDen/an/a7.30.373n/an/a11.30.361n/an/a13.70.263
Enn/an/a7.00.403n/an/a11.40.298n/an/a14.10.234
Esn/an/a7.60.327n/an/a11.60.316n/an/a13.50.256
Frn/an/a7.60.363n/an/a10.70.459n/an/a13.10.299
Pln/an/a7.80.349n/an/a11.80.370n/an/a15.10.308
Ptn/an/a7.60.322n/an/a11.80.297n/an/a13.60.436
AVGn/an/a7.50.356n/an/a11.40.350n/an/a13.90.299
VB-Multi ( = 1.0)De4.80.6324.80.5223.60.4425.30.4895.50.4495.40.420
En5.90.4354.20.5354.10.4236.80.4238.30.4027.60.385
Es4.90.4604.30.4793.60.6135.30.4735.20.4365.40.435
Fr4.90.4764.30.4853.70.4795.10.6024.80.4085.40.418
Pl4.70.4913.80.5033.50.5285.10.5034.00.6414.90.476
Pt4.90.4224.60.4263.70.4765.50.4534.80.4065.20.620
AVG5.00.4864.40.4923.70.4945.50.4915.50.4575.70.459
+ +# 5.2 Transient noise removal + +We construct a noisy test set by mixing the filtered Librispeech test-clean from Section 5.1 with non-speech noise such that it overlaps with $50 \%$ of the duration at a -10dB signal-to-noise ratio. Additional conditions can be found in Appendix B.4. Table 3 presents the results comparing Voicebox with A3T and Demucs. It should be noted that A3T and Voicebox utilize transcript and location of the noise while Demucs does not. Compared to the baselines, Voicebox generates samples best on all metrics. A3T is better than Demucs on intelligibilty and quality, but the infilled speech is not coherent because it is only trained on VCTK. + +# 5.3 Diverse speech sampling and application to ASR data generation + +Table 5 compares the ability to generate diverse samples for Librispeech test-other text. We consider English Voicebox (VB-En) with regression (regr) or flow-matching (FM) duration models. VITS-VCTK additionally conditions on a speaker ID, which we randomly sample for each sentence. YourTTS conditions on text and a reference audio, which we draw from the LS train splits. Qualitatively, A3T generates the same robotic voice and VITS-LJ generates high quality but from a single voice, hence both yield high FSD (bad quality or diversity) but VITS-LJ has a low WER. VITS-VCTK improves the voice diversity and FSD and YourTTS further advances it as it is trained on more speakers. Voicebox models (with different duration samplers) outperform the baseline on FSD by large margins, showing Voicebox’s ability to produce realistic and diverse samples whose distribution is close to the training data. Among them, the FM duration model creates more varying speaking styles compared to the regression one which ASR may struggle more to recognize. + +Table 5: Diverse speech generation from LS test-other text. + +
ModelWERFSD
Ground truth4.3171.1
require additional input
VITS-VCTK10.6306.6
YourTTS (ref=LS train)9.0277.9
text-only
A3T37.9373.0
VITS-LJ5.6344.2
VB-En (α=0,dur=regr)3.1155.7
VB-En (α=0,dur=FM,αdur = 0)5.6159.8
+ +Table 6: Performance of ASR models trained on real or synthetic speech, tested on real speech and decoded with or without a 4-gram language model. + +
WER on real data
No LM4-gram LM
ASR training datatest-ctest-otest-ctest-o
Real audio (100hr)9.021.56.116.2
Real audio (960hr)2.66.32.25.0
VITS-LJ58.081.251.678.1
VITS-VCTK33.855.530.253.1
YourTTS (ref=LS train)25.054.620.451.2
VB-En (α=0,dur=regr)7.117.66.514.6
VB-En (α=0,dur=FM,αdur = 0)3.18.32.66.7
+ +We next train an ASR model using only synthetic speech and evaluate it on real speech, which has not been successful before because synthetic data were not realistic and representative enough. Table 6 compares real and synthetic data from Voicebox and three baseline models. Each TTS model generates one sample per text from the Librispeech training set, resulting in 281K utterances per system. For real data, we consider train-960 and train-clean-100. Details about the ASR model and training are in Appendix A.5. The results are highly correlated with the FSD scores for synthetic data. In particular, the ASR model trained on Voicebox data with FM duration model reduces WERs by over $8 5 \%$ compared to baselines, and only lags behind real data by $0 . 4 \%$ and $1 . 7 \%$ absolute. + +# 5.4 Inference efficiency versus performance + +We examine the trade-off between the metrics of interest (WER, SIM, FSD) for different settings of guidance strength $( \alpha )$ and NFE specified by the user. Fig. 3a shows the Voicebox inference time to generate an audio sample of 10 seconds (including vocoding and predicting duration) as NFE varies and compares that to VALL-E.3 For ${ \mathrm { N F E } } { = } 2$ without CFG, Voicebox takes about 0.31 seconds, about 20 times faster than VALL-E. At NFE $_ { = 6 4 }$ , Voicebox is only $4 \%$ slower than VALL-E. + +Next, we study the cross-sentence setup of Section 5.1 to analyze the impact on WER and SIM-r. We find that for all settings Voicebox has better WER than VALL-E. WER remains stable with mean of 2.0 and variance of 0.005. WER plot can be found in Appendix B.5. As shown in Fig. 3b, in the case of SIM-r, lower classifier guidance strength values ( $\langle \alpha = 0$ or 0.3) produce higher speaker similarity when operating in a lower NFE regime $( \leq 4 )$ . However, starting from ${ \mathrm { N F E } } { = } 8$ , a higher classifier guidance strength improves speaker similarity. Finally, in Fig. 3c we examine FSD by generating samples for Librispeech test-other text. We find that lower classifier guidance strength produces lower FSD scores and more diverse samples. Increasing the NFE for each setting improves FSD. + +# 5.5 Ablation on generative modeling approaches + +We compare three generative modeling approaches: the proposed flow-matching with the OT path (FM w/ OT), flow-matching with the variance preserving (VP) diffusion path (FM w/ diff), and scorematching with the VP diffusion path (SM w/ diff). A reduced setup described in B.3 is adopted, with a lowered learning rate (1e-4) and the loss in Eq. (1) to ensure convergence for all three objectives. + +![](images/8d7f86fa8eabdd833d06fbcd610ee6d2d82f4ba453ae6bccd94b4874925bf7dd.jpg) +Figure 3: Trade-off between NFE and different metrics. Inference time will be doubled with CFG. + +Table 7: Comparing different objectives on training efficiency. 32 NFEs are used for inference. Each model is evaluated on the monolingual zero-shot TTS task. + +
Methodupd=50Kupd=100Kupd=150K
WERSim-oWERSim-oWERSim-0
FM w/OT (proposed)2.50.4242.20.4872.10.508
FM w/ diff76.00.0663.10.3442.60.478
SM w/ diff73.30.06217.40.1765.10.349
+ +Table 8: Comparing different objectives on inference efficiency. All models are trained for 150K updates. Each model is evaluated on the monolingual zero-shot TTS task. + +
MethodNFE=4NFE=8NFE=16NFE=32
WERSim-oWERSim-oWERSim-oWERSim-o
FM w/ OT (proposed)2.40.4102.20.4812.20.5032.10.508
FM w/ diff11.50.1713.00.3592.70.4472.60.478
SM w/ diff94.50.05442.30.07611.50.2185.10.349
+ +We vary the number of training and inference steps, and evaluate models on the zero-shot TTS task (Section 5.1). Results in Table 7 shows that FM w/ OT trains significantly faster than the other two objectives, achieving the best performance with 100K training steps, and even outperforms SM w/ diff using only 50K updates. Results in Table 8 shows superior inference efficiency of FM w/ OT, which can produce good results with just 8 NFEs, while FM w/ diff requires at least 8 NFEs and SM w/ diff requires over 32 NFEs. Complete results are in Table B5 + +# 6 Conclusion + +This paper presents Voicebox, the most versatile generative model for speech. By learning to solve a text-guided speech infilling task on large scale multilingual datasets with a power model and training objective Voicebox demonstrates impressive task generalization capabilities. Voicebox achieves state-of-the-art performance on mono and cross-lingual zero-shot TTS, speech inpainting, and diverse speech sampling, and can generate speech 20 times faster than the best autoregressive models. + +With high fidelity speech generation models like Voicebox, it brings the potential of misuse and unintended harm. To mitigate the risk, we also detail in Appendix B.1 that a highly effective classifier can be built to distinguish between authentic and synthetic speech. Voicebox is now trained only on read speech from audiobooks in six languages, and cannot transfer one attributes (e.g., emotion) from a reference while transferring another attribute (e.g., voice) from another reference. Due to space limit, we expand our discussion of limitation and broader impact in Appendix D. For future work, we would continue scaling the model and the data to include more languages and diverse types of speech such as conversations, and explore disentangled prompting for different attributes. + +# Acknowledgment + +The authors would like to thank Kristin Lauter and Joelle Pineau for supporting the project, thank Ricky Chen, Yaron Lipman, Alexandre Defossez, Gabriel Synnaeve for the technical discussion, thank Jade Copet and Gabriel Synnaeve for the compute support, thank Eleonora Presani and Jackie Pan for discussing the responsible AI studies, thank William Ngan, Somya Jain, Lydia Baillergeau, Dana Beaty, Chantal Mora, Daniel Duncan, Gopika Jhala, Steph Miles, Josh Terry, Valeryia Aranovich, Ashton Evans, Aly Gill, Andrea Mileskiewicz, Emily Richards, and Aaron Vasquez for developing the visual assets and the website, thank Alyssa Newcomb and Oliver Libaw for developing the posts, thank Peter Gray, Natalie Hereth, Shauna Kelleher, Ashley Gabriel, Seine Kim, Ana Paula Kirschner Moffarej and Aiman Farooq for coordinating the launch, thank Harrison Rudolph, Mallika Malhotra, Carolyn Krol, Lauren Cohen and Mo Metanat for the reviews, and thank Alexandra Gualdino, Ana Paula Kirschner Mofarrej, Benjamin Muller, Chloe Rolland, Daniella Kalfa, Darcie Da Silva, Gabriel Synnaeve, Hunter Goldman, Juan Pino, Karen Ulrich, Kris Sekula, Manuel Ribeiro, Marina Zannoli, Mary Williamson, Rashel Moritz, Stephanie Castillo, Tu Anh Nguyen, Vlad Sobal, Volker Seeker, and anonymous volunteers for sharing speech samples for the demo. + +# References + +[1] A. Aghajanyan, L. Yu, A. Conneau, W.-N. Hsu, K. Hambardzumyan, S. Zhang, S. Roller, N. Goyal, O. Levy, and L. Zettlemoyer. Scaling laws for generative mixed-modal language models. ArXiv, abs/2301.03728, 2023. +[2] A. Baevski, Y. Zhou, A. Mohamed, and M. Auli. wav2vec 2.0: A framework for self-supervised learning of speech representations. Advances in neural information processing systems, 2020. +[3] H. Bai, R. Zheng, J. Chen, X. Li, M. Ma, and L. Huang. A3T: Alignment-aware acoustic and text pretraining for speech synthesis and editing. In International Conference on Machine Learning, 2022. +[4] Z. Borsos, R. Marinier, D. Vincent, E. Kharitonov, O. Pietquin, M. Sharifi, O. Teboul, D. Grangier, M. Tagliasacchi, and N. Zeghidour. AudioLM: a language modeling approach to audio generation. ArXiv, abs/2209.03143, 2022. +[5] Z. Borsos, M. Sharifi, and M. Tagliasacchi. SpeechPainter: Text-conditioned speech inpainting. In Interspeech, 2022. +[6] T. B. Brown, B. Mann, N. Ryder, M. Subbiah, J. Kaplan, P. Dhariwal, A. Neelakantan, P. Shyam, G. Sastry, A. Askell, S. Agarwal, A. Herbert-Voss, G. Krueger, T. J. Henighan, R. Child, A. Ramesh, D. M. 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. ArXiv, abs/2005.14165, 2020. +[7] E. Casanova, J. Weber, C. D. Shulby, A. C. Júnior, E. Gölge, and M. A. Ponti. YourTTS: Towards zero-shot multi-speaker tts and zero-shot voice conversion for everyone. In International Conference on Machine Learning, 2021. +[8] E. Casanova, A. C. Junior, C. Shulby, F. S. d. Oliveira, J. P. Teixeira, M. A. Ponti, and S. Aluísio. Tts-portuguese corpus: a corpus for speech synthesis in brazilian portuguese. Language Resources and Evaluation, 56(3):1043–1055, 2022. +[9] R. T. Q. Chen. torchdiffeq, 2018. URL https://github.com/rtqichen/torchdiffeq. +[10] R. T. Q. Chen, Y. Rubanova, J. Bettencourt, and D. K. Duvenaud. Neural ordinary differential equations. In Neural Information Processing Systems, 2018. +[11] A. Défossez, G. Synnaeve, and Y. Adi. Real time speech enhancement in the waveform domain. ArXiv, abs/2006.12847, 2020. +[12] A. Défossez, J. Copet, G. Synnaeve, and Y. Adi. High fidelity neural audio compression. $A r X i \nu$ , abs/2210.13438, 2022. +[13] B. Desplanques, J. Thienpondt, and K. Demuynck. ECAPA-TDNN: Emphasized Channel Attention, propagation and aggregation in TDNN based speaker verification. In Interspeech, 2020. +[14] P. Dhariwal and A. Nichol. Diffusion models beat GANs on image synthesis. Advances in Neural Information Processing Systems, 2021. +[15] J. J. Godfrey, E. C. Holliman, and J. McDaniel. Switchboard: Telephone speech corpus for research and development. In Acoustics, Speech, and Signal Processing, IEEE International Conference on, volume 1, pages 517–520. IEEE Computer Society, 1992. +[16] A. Gulati, J. Qin, C.-C. Chiu, N. Parmar, Y. Zhang, J. Yu, W. Han, S. Wang, Z. Zhang, Y. Wu, et al. Conformer: Convolution-augmented transformer for speech recognition. arXiv preprint arXiv:2005.08100, 2020. +[17] 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. Advances in neural information processing systems, 2017. +[18] J. Ho and T. Salimans. Classifier-free diffusion guidance. arXiv preprint arXiv:2207.12598, 2022. +[19] J. Ho, A. Jain, and P. Abbeel. Denoising diffusion probabilistic models. Advances in Neural Information Processing Systems, 2020. +[20] J. Hoffmann, S. Borgeaud, A. Mensch, E. Buchatskaya, T. Cai, E. Rutherford, D. de Las Casas, L. A. Hendricks, J. Welbl, A. Clark, T. Hennigan, E. Noland, K. Millican, G. van den Driessche, B. Damoc, A. Guy, S. Osindero, K. Simonyan, E. Elsen, J. W. Rae, O. Vinyals, and L. Sifre. Training compute-optimal large language models. ArXiv, abs/2203.15556, 2022. +[21] W.-N. Hsu, Y. Zhang, R. J. Weiss, H. Zen, Y. Wu, Y. Wang, Y. Cao, Y. Jia, Z. Chen, J. Shen, et al. Hierarchical generative modeling for controllable speech synthesis. In International Conference on Learning Representations, 2019. +[22] W.-N. Hsu, B. Bolte, Y.-H. H. Tsai, K. Lakhotia, R. Salakhutdinov, and A. Mohamed. Hubert: Self-supervised speech representation learning by masked prediction of hidden units. IEEE/ACM Transactions on Audio, Speech, and Language Processing, 29:3451–3460, 2021. +[23] W.-N. Hsu, T. Remez, B. Shi, J. Donley, and Y. Adi. Revise: Self-supervised speech resynthesis with visual input for universal and generalized speech enhancement. arXiv preprint arXiv:2212.11377, 2022. +[24] R. Huang, M. W. Y. Lam, J. Wang, D. Su, D. Yu, Y. Ren, and Z. Zhao. FastDiff: A fast conditional diffusion model for high-quality speech synthesis. In International Joint Conference on Artificial Intelligence, 2022. +[25] Y. Jia, Y. Zhang, R. Weiss, Q. Wang, J. Shen, F. Ren, P. Nguyen, R. Pang, I. Lopez Moreno, Y. Wu, et al. Transfer learning from speaker verification to multispeaker text-to-speech synthesis. Advances in neural information processing systems, 2018. +[26] J. Kahn, M. Rivière, W. Zheng, E. Kharitonov, Q. Xu, P.-E. Mazar’e, J. Karadayi, V. Liptchinsky, R. Collobert, C. Fuegen, T. Likhomanenko, G. Synnaeve, A. Joulin, A. rahman Mohamed, and E. Dupoux. Libri-Light: A benchmark for asr with limited or no supervision. International Conference on Acoustics, Speech and Signal Processing, 2019. +[27] H. Kameoka, T. Kaneko, K. Tanaka, and N. Hojo. StarGAN-VC: non-parallel many-to-many voice conversion using star generative adversarial networks. IEEE Spoken Language Technology Workshop, 2018. +[28] E. Kharitonov, A. Lee, A. Polyak, Y. Adi, J. Copet, K. Lakhotia, T. Nguyen, M. Rivière, A. rahman Mohamed, E. Dupoux, and W.-N. Hsu. Text-free prosody-aware generative spoken language modeling. In Annual Meeting of the Association for Computational Linguistics, 2021. +[29] E. Kharitonov, D. Vincent, Z. Borsos, R. Marinier, S. Girgin, O. Pietquin, M. Sharifi, M. Tagliasacchi, and N. Zeghidour. Speak, read and prompt: High-fidelity text-to-speech with minimal supervision, 2023. +[30] K. Kilgour, M. Zuluaga, D. Roblek, and M. Sharifi. Fréchet audio distance: A reference-free metric for evaluating music enhancement algorithms. In Interspeech, 2019. +[31] J. Kim, S. Kim, J. Kong, and S. Yoon. Glow-TTS: A generative flow for text-to-speech via monotonic alignment search. Advances in Neural Information Processing Systems, 2020. +[32] J. Kim, J. Kong, and J. Son. Conditional variational autoencoder with adversarial learning for end-to-end text-to-speech. In International Conference on Machine Learning, 2021. +[33] D. P. Kingma and J. Ba. Adam: A method for stochastic optimization. CoRR, abs/1412.6980, 2014. +[34] F. Kreuk, A. Polyak, J. Copet, E. Kharitonov, T.-A. Nguyen, M. Rivière, W.-N. Hsu, A. Mohamed, E. Dupoux, and Y. Adi. Textless speech emotion conversion using decomposed and discrete representations. In Proceedings of the 2022 Conference on Empirical Methods in Natural Language Processing, 2022. +[35] R. Kubichek. Mel-cepstral distance measure for objective speech quality assessment. In Proceedings of IEEE pacific rim conference on communications computers and signal processing, volume 1, pages 125–128. IEEE, 1993. +[36] K. Lakhotia, E. Kharitonov, W.-N. Hsu, Y. Adi, A. Polyak, B. Bolte, T. Nguyen, J. Copet, A. Baevski, A. B. Mohamed, and E. Dupoux. On generative spoken language modeling from raw audio. Transactions of the Association for Computational Linguistics, 9:1336–1354, 2021. +[37] A. Łancucki. Fastpitch: Parallel text-to-speech with pitch prediction. In ´ International Conference on Acoustics, Speech and Signal Processing, 2021. +[38] Y. Lipman, R. T. Q. Chen, H. Ben-Hamu, M. Nickel, and M. Le. Flow matching for generative modeling. In International Conference on Learning Representations, 2023. +[39] J. Lorenzo-Trueba, J. Yamagishi, T. Toda, D. Saito, F. Villavicencio, T. H. Kinnunen, and Z. Ling. The voice conversion challenge 2018: Promoting development of parallel and nonparallel methods. ArXiv, abs/1804.04262, 2018. +[40] M. McAuliffe, M. Socolof, S. Mihuc, M. Wagner, and M. Sonderegger. Montreal forced aligner: Trainable text-speech alignment using kaldi. In Interspeech, 2017. +[41] T. Nguyen, E. Kharitonov, J. Copet, Y. Adi, W.-N. Hsu, A. M. Elkahky, P. Tomasello, R. Algayres, B. Sagot, A. Mohamed, and E. Dupoux. Generative spoken dialogue language modeling. Transactions of the Association for Computational Linguistics, 11:250–266, 2022. +[42] A. Nichol, P. Dhariwal, A. Ramesh, P. Shyam, P. Mishkin, B. McGrew, I. Sutskever, and M. Chen. GLIDE: Towards photorealistic image generation and editing with text-guided diffusion models. In International Conference on Machine Learning, 2021. +[43] V. Panayotov, G. Chen, D. Povey, and S. Khudanpur. Librispeech: An asr corpus based on public domain audio books. International Conference on Acoustics, Speech and Signal Processing, 2015. +[44] D. S. Park, W. Chan, Y. Zhang, C.-C. Chiu, B. Zoph, E. D. Cubuk, and Q. V. Le. SpecAugment: A simple data augmentation method for automatic speech recognition. In Interspeech, 2019. +[45] A. Paszke, S. Gross, F. Massa, A. Lerer, J. Bradbury, G. Chanan, T. Killeen, Z. Lin, N. Gimelshein, L. Antiga, et al. Pytorch: An imperative style, high-performance deep learning library. Advances in neural information processing systems, 2019. +[46] V. Popov, I. Vovk, V. Gogoryan, T. Sadekova, and M. Kudinov. Grad-TTS: A diffusion probabilistic model for text-to-speech. In International Conference on Machine Learning, 2021. +[47] D. Povey, A. Ghoshal, G. Boulianne, L. Burget, O. Glembek, N. Goel, M. Hannemann, P. Motlicek, Y. Qian, P. Schwarz, et al. The kaldi speech recognition toolkit. In IEEE 2011 workshop on automatic speech recognition and understanding, number CONF. IEEE Signal Processing Society, 2011. +[48] O. Press, N. A. Smith, and M. Lewis. Train short, test long: Attention with linear biases enables input length extrapolation. ArXiv, abs/2108.12409, 2021. +[49] A. Radford, J. W. Kim, T. Xu, G. Brockman, C. McLeavey, and I. Sutskever. Robust speech recognition via large-scale weak supervision. ArXiv, abs/2212.04356, 2022. +[50] A. Ramesh, M. Pavlov, G. Goh, S. Gray, C. Voss, A. Radford, M. Chen, and I. Sutskever. Zero-shot text-to-image generation. ArXiv, abs/2102.12092, 2021. +[51] Y. Ren, C. Hu, X. Tan, T. Qin, S. Zhao, Z. Zhao, and T.-Y. Liu. Fastspeech 2: Fast and highquality end-to-end text to speech. In International Conference on Learning Representations, 2021. +[52] F. Ribeiro, D. Florêncio, C. Zhang, and M. Seltzer. CrowdMOS: An approach for crowdsourcing mean opinion score studies. In International Conference on Acoustics, Speech and Signal Processing, 2011. +[53] C. Robinson, N. Obin, and A. Roebel. Sequence-to-sequence modelling of F0 for speech emotion conversion. In International Conference on Acoustics, Speech and Signal Processing, 2019. +[54] C. Saharia, W. Chan, H. Chang, C. Lee, J. Ho, T. Salimans, D. Fleet, and M. Norouzi. Palette: Image-to-image diffusion models. In ACM SIGGRAPH 2022 Conference Proceedings, 2022. +[55] J. Serrà, S. Pascual, J. Pons, R. O. Araz, and D. Scaini. Universal speech enhancement with score-based diffusion. ArXiv, abs/2206.03065, 2022. +[56] J. Shen, R. Pang, R. J. Weiss, M. Schuster, N. Jaitly, Z. Yang, Z. Chen, Y. Zhang, Y. Wang, R. J. Skerry-Ryan, R. A. Saurous, Y. Agiomyrgiannakis, and Y. Wu. Natural TTS synthesis by conditioning wavenet on mel spectrogram predictions. International Conference on Acoustics, Speech and Signal Processing, 2017. +[57] Y. Song and S. Ermon. Generative modeling by estimating gradients of the data distribution. Advances in neural information processing systems, 32, 2019. +[58] X. Tan, J. Chen, H. Liu, J. Cong, C. Zhang, Y. Liu, X. Wang, Y. Leng, Y. Yi, L. He, F. K. Soong, T. Qin, S. Zhao, and T.-Y. Liu. NaturalSpeech: End-to-end text to speech synthesis with human-level quality. ArXiv, abs/2205.04421, 2022. +[59] A. Vaswani, N. M. Shazeer, N. Parmar, J. Uszkoreit, L. Jones, A. N. Gomez, L. Kaiser, and I. Polosukhin. Attention is all you need. ArXiv, abs/1706.03762, 2017. +[60] C. Wang, W.-N. Hsu, Y. Adi, A. Polyak, A. Lee, P.-J. Chen, J. Gu, and J. M. Pino. fairseq $\mathrm { s ^ { 2 } }$ : A scalable and integrable speech synthesis toolkit. In Conference on Empirical Methods in Natural Language Processing, 2021. +[61] C. Wang, S. Chen, Y. Wu, Z.-H. Zhang, L. Zhou, S. Liu, Z. Chen, Y. Liu, H. Wang, J. Li, L. He, S. Zhao, and F. Wei. Neural codec language models are zero-shot text to speech synthesizers. ArXiv, abs/2301.02111, 2023. +[62] Y. Wang, D. Stanton, Y. Zhang, R. J. Skerry-Ryan, E. Battenberg, J. Shor, Y. Xiao, F. Ren, Y. Jia, and R. A. Saurous. Style tokens: Unsupervised style modeling, control and transfer in end-to-end speech synthesis. In International Conference on Machine Learning, 2018. +[63] Y. Xu, J. Du, L.-R. Dai, and C.-H. Lee. A regression approach to speech enhancement based on deep neural networks. IEEE/ACM Transactions on Audio, Speech, and Language Processing, 23(1):7–19, 2014. +[64] J. Yamagishi, C. Veaux, and K. MacDonald. Cstr vctk corpus: English multi-speaker corpus for cstr voice cloning toolkit (version 0.92). 2019. +[65] R. Yamamoto, E. Song, and J.-M. Kim. Parallel WaveGAN: A fast waveform generation model based on generative adversarial networks with multi-resolution spectrogram. In International Conference on Acoustics, Speech and Signal Processing, 2020. +[66] N. Yu, V. Skripniuk, S. Abdelnabi, and M. Fritz. Artificial fingerprinting for generative models: Rooting deepfake attribution in training data. In Proceedings of the IEEE/CVF International conference on computer vision, pages 14448–14457, 2021. +[67] N. Zeghidour, A. Luebs, A. Omran, J. Skoglund, and M. Tagliasacchi. Soundstream: An end-to-end neural audio codec. IEEE/ACM Transactions on Audio, Speech, and Language Processing, 30:495–507, 2022. + +# A Additional Details of Experiment Setup + +# A.1 Vocoder + +We adapt the HiFi-GAN V1 configuration to generate 16kHz audio from 80 dimensional log Mel spectral features sampled at $1 0 0 \mathrm { H z }$ . To compute the log Mel spectrogram, we use a 1024-point short time Fourier transform with a 640-sample (40ms) analysis window, 160-sample (10ms) shift, and the Hann windowing function to compute the amplitude spectrogram, and then apply an 80 dimension Mel filter with a cutoff frequency at 8kHz. The original HiFi-GAN V1 has four transposed convolution blocks for upsampling. The upsampling factors are [8, 8, 2, 2] and the corresponding kernel sizes are [16, 16, 4, 4]. Here we only need a total upsampling factor of 160 instead of 256, and we adjust the upsampling factors to [5, 4, 4, 2] and kernel sizes to [11, 8, 8, 4] accordingly. The other parameters are identical to the HiFi-GAN V1 configuration. Total number of parameters is 13M. We train the adapted HiFi-GAN on the 60K hours of English audiobook data for $1 . 5 \mathbf { M }$ updates on 8 GPUs, which takes 7.5 days. + +# A.2 Phone representation + +Ghost silence The frame-level phonetic transcript used for training is obtained through forcealigning speech and phonetic transcript. In particular, a forced aligner may align some frames to a special phone “SIL” for non-speech frames (silence or noise). For most forced aligners, only frames between words and frames at the beginning and at the end of an utterance can be aligned to SIL. + +During inference, we are only given the text transcript, which does not tell us where we should insert silence to. Hence, it is desired to have the duration model not only predict the duration for each phone (SIL included), but also predict the existence of SIL at eligible locations (between words and at the two ends of the utterance). To tackle it, we introduce ghost silence to our phonetic transcript, which are silences in between words with duration of zero frames. + +To give an example, suppose the transcript contains three words: “Hey what’s up” with pronunciation “{Hey:[A,B], what’s:[C], up:[D,E,F]}”, and the frame-level phonetic transcript $z$ obtained through forced alignment is $z \ = \ ( \mathrm { S I L } \texttt { A B B S I L C D D D E E F S I L } \mathrm { S I L } \texttt { S I L }$ ). The phonetic transcripts becomes $y = ( \mathbf { S } \mathbf { I } \mathbf { L }$ A B SIL C SIL D E F SIL), where the ghost silence is highlighted in green. The corresponding duration would be $l = ( 1 , 1 , 2 , 1 , 1 , 0 , 3 , 2 , 1 , 2 )$ . A ghost silence is inserted between what $^ { \circ } \mathtt { s }$ and up during training, and the duration model should predict the duration of it as zero to indicate that there should not be a pause between the two words. + +Word-position-dependent phone The possible absence of silence between words in the framelevel phone transcript can make it hard for the audio model to identify word boundaries. To help the audio model identify the word boundary which is important when reading a sentence, we introduce word-position-dependent phones which are commonly used in Hidden Markov Model based acoustic models for speech recognition [47]. This adds a postfix to each phone in the transcript to denote where it is in the corresponding word. There are four postfixes: $^ { - \mathtt { B } }$ for beginning, $\_ \mathbb { E }$ for end, $_ - \ I$ for intermediate, and $\_ { \mathtt { S } }$ for singleton. The above example becomes “{Hey:[A_B,B_E], what’s:[C_S], up:[D_B,E_I,F_E]}” with frame-level phonetic transcript $z =$ (SIL A_B B_E B_E SIL C_S D_B D_B D_B E_I E_I F_E SIL SIL). + +Phone-level mask In terms of masking, given duration $l$ , the relationship of phone-level mask $m ^ { \prime }$ and frame-level mask $m$ can be written as $m = \tt r e p ( m ^ { \prime } , l )$ . For the applications where a duration model is involved (zero-shot TTS, content editing, diverse speech sampling), the frame-level mask $m$ is extended such that no phone is partially masked. In other words, all the frames corresponding to a phone is either entirely masked or entirely unmasked. During training, we mask a contiguous chunk of audio, infilling of which is a more challenging task compared to infilling multiple smaller segments. All frames that are aligned to a phone are either entirely masked or unmasked. Note that masking all frames for a phone is not a necessity but was chosen due to ease of implementation. + +# A.3 Data transformation + +The Mel spectrogram is normalized with the global mean (-5.8843) and standard deviation (2.2615) to stabilize training. The statistics are estimated on $3 0 \mathrm { k }$ random training samples from the 1K hours of + +English audio. Input and output duration are dequantized $( x \sim \mathcal { U } [ x - 0 . 5 , x + 0 . 5 ] )$ and transformed with $\log ( 1 + x )$ following [51]. Prediction of duration is quantized and clipped such that the minimal duration is greater than or equal to zero. + +# A.4 Cross-lingual zero-shot TTS test data filtering + +We create a test set for each language by selecting samples from the MLS test split which have Whisper transcription WER lower than $20 \%$ (or $30 \%$ for Polish and Portugueses test splits which contains less than 1K samples), because we found MLS test set contains many examples with incomplete transcriptions missing a large portion of the utterance. In addition, a small amount of utterances were excluded due to MFA alignment failure. Table A1 lists the number of samples remained for each language. + +Table A1: Number of MLS test samples after filtering. + +
Language#samples before filtering#samples after filtering
English37693535
Spanish23852323
German33943183
French24262284
Polish520508
Portuguese871838
+ +# A.5 Setup for training ASR models with synthetic speech + +To train an ASR model in Section 5.3, we extract 80-dimensional log Mel features with a $2 5 \mathrm { m s }$ window and a 10ms frame shift, and then apply global mean-variance normalization. The ASR model is an RNN-T with a Conformer-based encoder [16]. The conformer applies time scale reduction to the input features with stride 6, embeds them into 512-dimensional vectors, passes these vectors through a 20-layer conformer which has 8 attention heads and 2048-dimensional fully-connected layers. The conformer output is further mapped to 1024 dimensions through a linear layer followed by layer normalization before being passed to the joiner. The predictor of the network first embeds wordpiece units into 512 dimensional embeddings, applies layer normalization, a 512-dimensional LSTM, a dropout layer and a linear layer that maps the LSTM output to 1024 dimensions. The joiner adds the encoder and predictor outputs, applies tanh non-linearity and uses a linear layer that maps the 512-dimensional joiner input into wordpiece units. There are 4096 wordpiece units estimated from the LibriSpeech 960hr training text. + +We apply SpecAugment [44] in all ASR runs. The models are trained using PyTorch [45] with Adam [33] optimizer for 120 epochs unless otherwise noted. The learning rate follows a tri-stage schedule with a maximum of 0.001. We applied gradient clipping at 10 and a weight decay parameter of 0.1. For the 960hr setting, we used a variable batch size capped at 1K utterances or 30K frames, whichever is smaller. This corresponds to about 45K update steps for 120 epochs. For the $1 0 0 \mathrm { { h r } }$ setting, we set the maximum learning rate to 0.0001 and used smaller batch size (capped at 200 utterances or 5K frames). In this case, 120 epochs corresponded to about 120K updates. For decoding, we used n-best decoding with a beam-size of 15, and evaluated the WER on the 1-best path. + +# A.6 How to format input for different task + +Fig. A1 shows how input are formatted to perform diverse speech sampling, content editing, and zero-shot TTS using Voicebox. + +# A.7 Bi-directional ALiBi Bias + +We use a symmetric variant bi-directional variant of ALiBi bias where any query $Q _ { i }$ and key $K _ { j }$ with $| i - j | = N$ use the same representations 4. Furthermore, for any query $Q _ { i }$ the bias corresponding + +![](images/ddb12ca952f8f91cab969662c5e808e86fe9c8016a543b6080ef6901b1e78f15.jpg) +Figure A1: Detailed diagrams of diverse speech sampling, content editing, and style transfer. Text in red and blocks in orange at the input of a model denote segments to be predicted. Numbers in blue and spectrogram in cyan at the model output denote predicted duration and spectrogram. + +to the flow step $x _ { t }$ is set to 0. Similarly the bias from the flow-step $x _ { t }$ to any other query 0. In our experiments, we find ALiBi Bias to improve convergence and extrapolation to longer sequences. + +# B Additional Experiments + +# B.1 Detecting generated speech + +We recognize the potential risks of a model capable of generating speech in the style of arbitrary users. In an effort to diminish these risks we show that a binary classification model is able to consistently distinguish between real world speech and that which is generated from our model. + +Inspired by [29], we train a convolutional binary classification model to distinguish between real and generated speech. The model consists of 6 blocks with hidden dimension sizes: [64, 128, 256, 256, 512, 512]. Each block contains a $_ { ( 3 \mathrm { ~ X ~ } 1 ) }$ convolution along the time axis, a $\left( 1 \mathrm { ~ x ~ } 3 \right)$ convolution along the frequency axis, followed by a ReLU activation and batch normalization. After each block that increases the hidden dimension size we also apply max pooling with a stride of 2 across both the time and frequency dimensions. Finally, global max pooling is applied and a linear layer projects to a single value that is fed into a binary cross entropy loss. At inference time we create a sliding window with hop length equal to $2 5 0 \mathrm { m s }$ and run each chunk of audio through the classifier and average the outputs. + +The model is tested on the dev-clean split of Librispeech. We then take a 100 hour subset of the 60K hour-English data and set aside 2,703 random utterances (to match the size of dev-clean) which is used as a validation split. The remaining utterances from the 100 hours subset are used as the ground truth utterances for training. For each split we synthesize audio, conditioned on each utterance of the split by masking out frames in the spectrogram corresponding to $90 \%$ , $50 \%$ , and $30 \%$ of the phonemes of the utterance. All samples are generated using classifier-free guidance with $w = 0 . 7$ midpoint ODE solver (step size 0.0625 / NFE=64), and the regression duration model. + +We consider two detection tasks. The first one is to distinguish between original audio and Voiceboxgenerated audio. The second one is to distinguish resynthesized audio and Voicebox-generated audio. The resynthesized audio is created by extracting the Mel Spectrogram from original audio and then vocoding it with the HiFi-GAN vocoder. + +Table B2 presents the results for each setting. The model can trivially distinguish original audio from Voicebox-generated audio. This results from the fact that a model can also trivially distinguish original audio from resynthesized audio, most likely by recognizing artifacts produced by the vocoder. The task of differentiating Voicebox-generated audio from resynthesized audio is much harder. When $90 \%$ of the audio is masked, the model is able to reliably classify the audio as Voicebox-generated. In lower masking regimes this decreases a bit, but this is likely due to a naive inference method of averaging the outputs of all sliding windows. Since the majority of windows are non-synthetic, this leads to mis-classifications. + +Table B2: Synthetic speech detection metrics + +
% Mask AccuracyPrecisionRecall
Original audio vs Voicebox-generated audio
30%1.0001.0001.000
50%1.0001.0001.000
90%1.0001.0001.000
Resynthesized audio vs Voicebox-generated audio
30%0.7040.7140.680
50%0.8090.7960.831
90%0.9070.8810.942
+ +# B.2 How context length affects monolingual and cross-lingual zero-shot TTS + +Monolingual: For in-context zero-shot TTS in Section 5.1, we used 3.0 seconds of prompt audio. Here we examine how WER / SIM-r vary with different amounts of prompt audio using duration from regression duration model for the target text. If the desired prompt is longer than the available audio, the shorter audio is used as the prompt. Results are shown in Figure B2. As expected, WER mildly decreases and SIM-r grows quickly flattens with longer audio prompts. Comparing against VALL-E, Voicebox is more efficient at leveraging an audio prompt, achieving the same speaker similarity as VALL-E with roughly two thirds the input audio. + +Cross-lingual: Here we examine the effect of increasing the prompt length for the case of crosslingual zero-shot TTS. As described in 5.1, this setting has a total 36 language transfer directions for each pair of source and target language. For each target text in a given transfer setting, we examine how WER / SIM- $\cdot \mathbf { o } ^ { 5 }$ vary as the prompt length increases. Similarly, the regression duration model is used for the target text. Fig. B3 and Fig. B4 plot the SIM-o (speaker similarity) and WER trends respectively. When concatenating the prompt to the target for MLS, we find that the samples are quite a bit longer than what the model was trained on (16s max length), because MLS test set samples are in average 15 seconds long. To alleviate this out of domain issue and focus the study on varying the prompt length, we truncate the target sequences to 4 seconds (at word boundaries). We notice that WERs are higher compared to Table 4, likely because the ASR model struggles with incomplete sentences. Each subplot contains the trend for one of the target languages from all six source languages. + +![](images/9ccef99c8ae284727d5b6f5f2b889bb7cb86bd8f9cb137878399bbea9774f357.jpg) +Figure B2: WER and SIM-r as a function of prompt audio time in seconds for the Zero-shot TTS task 5.1. Audio is generated using classifier-free guidance strength $( \alpha )$ of 0.7 and midpoint ODE solver with a NFE of 32. The blue line is for Voicebox and the red star is VALLE at 3 seconds. The speaker similarity (SIM-r) remains same for longer prompts (up to 10s). + +![](images/95a0647630d2e23258d86648b0062375213099e642890ddf0318bbb8c1a78e59.jpg) +Figure B3: Each subplot considers one of the six target language and shows SIM-o (speaker similarity) as a function of prompt audio duration in seconds for cross-lingual style transfer from different source language. We set the classifier-free guidance strength $( \alpha )$ to 1.0 and use midpoint ODE solver with a NFE of 32. + +The speaker similarity consistently improves as the prompt length is increased, similar to the monolingual setting. In contrast, we find that WER increases as we increase the prompt length for most directions. The WER increases much more for $\mathrm { E n } \mathrm { n o n – E n }$ directions. We hypothesize that this is due to training data imbalance across languages, where English accounts for over $90 \%$ of the multilingual training data. Hence, when transferring from English, the model is more likely to assume that the whole sentence is in English as the prompt length increases and produce incorrect pronunciation for the non-English target. Note that during the training phase, the model was only exposed to audio samples and phonemes originating from a single language. + +![](images/c7c8737b8ae970c95fde1f5b8238bb5f2257045e10bc9883d908ce6e80c20fa2.jpg) +Figure B4: Each subplot considers one of the six target language and shows WER as a function of prompt audio duration in seconds for cross-lingual style transfer from different source language. We find WER remain reasonably low for all cases except for “English” to “X” style transfer.We set the classifier-free guidance strength $( \alpha )$ to 1.0 and use midpoint ODE solver with a NFE of 32. + +# B.3 Comparing audio model training objectives + +While A3T is considered the regression-based speech infilling baseline, it is trained on a smaller dataset and uses a smaller model compared to Voicebox. Here we present a controlled study comparing the flow-matching and regression objectives, as well as the effectiveness of masked loss. + +We consider a reduced setup for this ablation to save the compute. All models were trained on an English audiobook dataset with 1K hours of speech using a smaller model configuration (12 layers, 1024-dimensional Transformer embedding, 2048-dimensional feed-forward layer, 8 attention heads) for $1 5 0 \mathrm { k }$ steps with an effective batch size of $1 2 0 \mathrm { k }$ frames. These models are evaluated on the cross-sentence zero-shot TTS setup (Section 5.1) and diverse speech sampling (Section 5.3). + +Results in Table B3 show that while regression audio models produce comparable WER, the audio similarity and diversity are significantly worse. Subjective listening also reveals that the audio quality and audio similarity are much worse. On the other hand, masked loss improves audio similarity and diversity while having little impact on intelligibility. + +Table B3: Comparison of flow-matching and regression models, trained with loss computed on all frames or only masked frames. Results of the proposed objective is boldfaced. + +
MethodLossZero-Shot TTS (cross-sentence)Diverse sampling
WERSIM-rWERFSD
Flow MatchingMasked2.10.5973.1242.5
Flow MatchingAll2.00.5283.1243.1
RegressionMasked2.00.5202.9278.8
RegressionAll2.00.5122.9282.8
+ +# B.4 Effectiveness on data scaling + +We create four subsets of the 60K hour English data $( 0 . 1 \%$ , $1 \%$ , $10 \%$ , $100 \%$ in duration). In particular, the $x \%$ subset would contain roughly $x \%$ of the speakers from the original set. We train one model on each subset with a reduced setup described in Appendix B.3 and evaluate them on zero-shot TTS (cross-sentence) and diverse sampling. Results show that scaling data constantly improves the zero-shot TTS performance (WER and SIM-r) as well as WER on diverse sampling. For FSD it shows regression when scaling from 6K hour to 60K hour, but this could result from the the reference distribution is computed from the 1K hour English audiobook data that has less diverse samples. + +Table B4: Experiments on the effect of scaling training data. + +
Train data (hr)Zero-Shot TTS WER SIM-rDiverse sampling WER
FSD
60 6002.300.1513.48 3.19280.48 205.39
6,0002.11 2.080.417 0.5732.96195.52
60,0002.050.6452.95214.38
+ +# B.5 Complete results on comparing generative modeling approaches + +Table B5 presents the full results of Section 5.5 on all combinations of training steps, inference steps with results on both monolingual zero-shot TTS (Section 5.1) and diverse speech sampling (Section 5.3) for the ablation study presented in Section 5.5. In all settings Flow Matching with OT paths performs strictly better than both of the other approaches. + +# B.6 Transient noise removal in more conditions + +We expand the experiments in Section 5.2 by comparing the models on two noise levels (low noise: 10dB and high noise: -10dB), three overlapping ratios ( $30 \%$ , $50 \%$ , $70 \%$ ), and also two types of noise (speech noise and non-speech noise). + +Results are presented in Table B6. Voicebox consistently produces the most intelligible audio at all conditions (indicating the percentage of speech to infill). In terms of audio similarity, Voicebox is constantly better in the high noise condition with gains ranging from 0.265 to 0.324 compared to Demucs, and is on par with Demucs in low noise condition. + +# B.7 Additional results on inference efficiency versus performance + +As explained in Section 5.4, for the cross-sentence setup of Section 5.1, we find that WER remains stable with mean of 2.0 and variance of 0.005. This can be also be observed from Fig. B5a. + +![](images/bf6ea534c210459719d2b17e28aa22fe15b5abe20bbad6a2db050a9a67da1378.jpg) +Figure B5: Trade-off between NFE and WER for different classifier-free guidance strengths (a) presents the WER for cross-sentence zero-shot TTS (Section 5.1) and (b) presents the WER for diverse speech sampling (Section 5.3). + +Table B5: Comparison of FM w/OT vs. FM w/Diffusion vs. SM. + +
Method Train StepsNFEZS-TTS (cross-sentence) Diverse sampling
WERSIM-0SIM-rWERFSD
FM w/OT42.70.3030.3624.8276.499
5000082.50.3530.4124.8235.958
162.40.3660.4254.7227.485
322.50.3640.4244.7225.931
42.50.3470.4044.3258.358
10000082.20.4110.4684.2216.512
162.30.4290.4834.3206.538
322.20.4310.4874.2203.792
42.40.3560.4104.0249.712
15000082.20.4300.4814.0208.511
162.20.4530.5034.0198.040
322.10.4580.5083.9195.304
499.90.0500.05099.83478.910
FM w/ diff50000899.90.0470.04799.94704.237
1698.80.0520.04896.55336.591
3276.00.0600.06649.52485.400
100000498.90.0480.04896.64486.401
814.60.1040.13712.0669.564
164.00.2100.2627.0381.891
323.10.2850.3446.3294.777
411.50.1320.17111.4692.560
15000083.00.3050.3595.6334.237
162.70.3910.4475.4244.067
322.60.4230.4785.2224.963
99.60.0500.04899.72816.083
SM w/ diff500004 899.30.0510.04899.63079.040
1697.50.0520.05098.43710.340
3273.30.0570.06286.23011.030
100000499.40.0500.05099.33474.579
897.20.0490.04897.93600.423
1653.90.0640.07169.62060.892
3217.40.1500.17634.41071.579
494.50.0550.05479.42953.417
842.30.0700.07627.51071.010
1500001611.50.1910.21812.8698.411
325.10.3090.3498.8519.468
+ +In Fig. B5b, we show the WER for the samples generated on Librispeech test-other text. We find that for $\alpha = 0$ , WER increases slightly from 2.8 to 3.1 as NFE goes from 2 to 32. For a larger classifier-free guidance strength, WER remains more stable. Subjective listening and FSD reveal that 1) a lower NFE leads to less natural samples with lower diversity, and 2) a higher guidance weight leads to lower diversity. In addition, we observe that ASR can perform well with unnatural samples that contains artifacts, but degrades when the samples are more diverse and expressive (e.g., with whispering voice or with strong reverberation). As a result, we see that the combination of low guidance weight and high NFE leads to a higher WER due to the higher diversity. + +# B.8 Choice of audio model output features + +The performance of our model is upper bounded by how well the chosen acoustic features can be reconstructed to waveform. The reconstruction performance is determined jointly by the encoding process, as in how much information is lost when encoding waveform into the features, and the decoding process, as in how well the vocoder can translate the encoded information into waveform. + +Table B6: Results of transient noise removal with varying overlapping percentage and noise level. “sp” means added noise is speech, and “non-sp” means non-speech. + +
WER(↓) spnon-spSIM(↑) sp non-spspWER(↓) non-spSIM(↑) spnon-sp
SNR=-10dB, overlap=30% Noisy speech26.724.90.2020.238SNR=10dB, overlap=30% 3.7 3.10.6050.603
Demucs20.519.70.2470.2473.2 2.80.5700.567
A3T VB-En (α = 0.7)7.50.058 same as left
2.20.566same as left
SNR=-10dB, overlap=50% SNR=10dB, overlap=50%
Noisy speech43.640.80.256 0.2924.53.80.649
Demucs34.332.50.291 0.2883.83.3 0.6160.649 0.613
A3T0.064same as left
VB-En (α = 0.7)11.5
2.00.612same as left
SNR=-10dB, overlap=70%SNR=10dB, overlap=70%
Noisy speech60.056.00.2600.3036.3 4.60.5950.592
Demucs
49.545.40.2930.2944.6 3.80.5720.564
A3T0.063
16.6same as left
VB-En (α = 0.7)
0.559
same as left
2.0
+ +To motivate the choice of the acoustic feature and the vocoder, we compare four combinations: the first one is Mel spectrogram $^ +$ HiFi-GAN which is what this paper adopts. The second is Mel spectrogram $^ +$ Parallel WaveGAN [65] that is used by A3T [3]. The third one is Encodec postquantization dense feature $^ +$ Encodec decoder, which is analogous to VALL-E’s setup. The last one is also Encodec but with pre-quantization dense feature, which we include to study how much information is lost during quantization. + +We also note that Mel spectrogram features are 80 dimensional encoded at $1 0 0 \mathrm { H z }$ , which is 8K dimensions per second, while Encodec features are 128 dimensional encoded at $7 5 \mathrm { H z }$ , which is 9.6K dimensions per second, higher than the Mel spectrogram features. + +Table B7 presents the results evaluated on the Librispeech dev-clean and dev-other splits. All three models have the same WER resynthesizing dev-clean split, but ParallelWaveGAN degrades the most on dev-other. Interestingly Encodec even produces audio of lower WER than the ground truth. + +In terms of audio similarity, besides the default audio feature extractor WavLM-TDCNN, we also include results of similarity computed with another speaker encoder ECAPA [13]. Parallel WaveGAN is consistently the worst. However, it is unclear whether HiFi-GAN or Encodec performs better. Encodec prevails with the WavLM-TDCNN embedder and HiFi-GAN wins using ECAPA. It may require subjective MOS test to conclude which one reconstructs the audio better, and we leave exploration of modeling Encodec dense features for future study. + +Table B7: Comparison of different audio features and vocoders on audio reconstruction. Librispeech dev-clean (d-c) and dev-other (d-o) are used for evaluation. WER and audio similarity computed with WavLM-TDCNN and ECAPA are reported. + +
Audio feature /VocoderWERSIM-o (WavLM)SIM-o (ECAPA)
d-cd-od-cd-od-cd-o
Ground truth2.14.71.0001.0001.0001.000
Mel spectrogram /HiFi-GAN2.14.70.9150.9090.7660.762
Mel spectrogram /Parallel WaveGAN2.15.20.8680.8470.7210.711
Encodec post-quantized feature / Encodec decoder2.14.50.9430.9440.7240.722
Encodec pre-quantized feature /Encodec decoder2.14.40.9430.9440.7240.722
+ +# C Additional Details and Studies on Metrics + +# C.1 Measuring speech diversity and quality with FSD + +Diversity We first validate if FSD reflects the diversity for a set of speech samples and study its sensitivity to sample size. To achieve that, we design controlled experiments to compute FSD on sets of samples with varying diversity and sample sizes. Specifically, we create two partitions from 1K hours of English speech, where each partition has the same set of speakers and the same number of utterances for each speaker. The first partition is considered the reference set. + +To test the sensitivity to sample size, we use the second partition to create subsets by sampling $r \%$ of utterances from each speaker in that partition. This sampling method is denoted as “utt”. We computed that on average, each speaker contributed approximately 2.33 sessions, with each session containing around 52.45 utterances. Therefore, the subsets created using the sampling method are expected to have similar audio style distributions to the reference set and the FSD is expected to stay low regardless of the subset size. We consider $r \in \{ 1 , 5 , 1 0 , 2 5 , 5 0 , 1 0 0 \}$ . + +To test the correlation with diversity, we again use the second partition to create subsets by sampling $r \%$ of speakers and including all the utterances in the partition from those speakers. This sampling method is denoted as “spk” where a smaller $r$ leads to a subset with fewer speakers and hence lower diversity. Therefore the FSD is expected to increase as $r$ decreases. The same set of values for $r$ is considered. For the same $r$ , the “utt” subset should always have a lower FSD than the “spk” subset. + +We compare three different features for computing the FSD score. The first is the supervised WavLM-TDCNN feature used for computing audio similarity (SIM-r and SIM-o). The second is the self-supervised wav2vec 2.0 BASE [2] feature reduced to 128 dimensions using principle component analysis (PCA). The last one is the supervised audio event classification model feature that is used to compute FAD [30] for non-speech audio generation. + +Figure C6 first compares using different layers of wav2vec 2.0 features. All of them yield similar desirable results where “utt” stays low and “spk” increases drastically when the sample size reduces and speaker diversity decreases. We then decide to use the middle layer (layer 6) as the default feature for FSD computation. + +![](images/91e1a54fcf8125f908f9f5ad1a130f16cc406a8e2347310c34965b6a71d6135a.jpg) +Figure C6: FSD based on different layers of wav2vec 2.0 BASE. utt: utterance-based sampling, spk: speaker-based sampling. Vertical bars denote standard deviation. + +Figure C7 further compares wav2vec 2.0-layer 6 with the two other features. WavLM-TDCNN and wav2vec 2.0-layer 6 present similar trends and both have low variance. Both of them are suitable for measuring diversity, and we decide to use wav2vec 2.0 features as it is self-supervised and would be able to capture more holistic information of speech such as prosody and emotion. + +In contrast, FAD score [30] is not appropriate for measuring speech diversity. The score does not increase much between $r = 2 5 \%$ and $r \stackrel { } { = } 1 \%$ for “spk” sampling method, showing that the score does not reflect the decreasing speaker diversity. On the other hand, “utt” sampling method observes huge FAD score increase when reducing the sample size from $r = 2 5 \%$ to $r = 1 \%$ where the diversity does not change much as the number of speakers remains the same. Moreover, at $r = 1 \%$ both sampling methods result in similar FAD score while the two subsets exhibit very different levels of diversity. We hypothesize that this is because FAD score is computed based on features extracted from an audio even classifier trained on AudioSet, which learns to distinguish between events like lawn mower, car engine, and human speech, but does not learn to capture the variation within speech, such as different voices. + +![](images/c241b327499c27ae5ff871f86cf4f96d552e054dc2a1a62c66ed06cc37871612.jpg) +Figure C7: FSD with different sample size using supervised WavLM-TDCNN, self-supervised wav2vec 2.0, and supervised audio event classifier features. utt: utterance-based sampling, spk: speaker-based sampling. Vertical bars denote standard deviation. + +Quality In addition to measuring diversity, Fréchet distance is a commonly used metric for assessing quality in image generation [19]. To show its applicability for speech generation, we evaluate the FSD score of speech utterances with varying levels of quality. The reference set samples are 1K hours of English training data, and the hypothesis set is the Librispeech test-clean split with noise added. We added Gaussian noise at different SNRs, ranging from 0 to 50 dB. Lower SNR values correspond to lower quality. We use the default speech feature extractor (i.e., wav2vec 2.0, layer-6) throughout the experiments. + +Our results, summarized in Figure C8, show that a subset with a lower SNR has a higher FSD score. Therefore, a lower FSD score indicates higher acoustic quality for the set of test samples when diversity is fixed. + +![](images/aa75981370496307bfc42d66570f8613cc5ec9cefd991c8a4fe7cc323661b7c1.jpg) +Figure C8: FSD under different noisy levels. Feature: Wav2vec 2.0 layer-6 feature. Noise is added upon model output from Voicebox under unconditional setting. + +# C.2 Standalone metrics for duration models + +As mentioned in the main text, we can utilize end-to-end metrics of WER, SIM, and FSD to evaluate duration models, but also consider metrics specifically for duration. + +First, we consider two metrics aimed at the quality of duration predictions, here denoted $\hat { l } ( l _ { c t x } , y )$ For a regression model, we use $\hat { l } ( l _ { c t x } , y ) = g ( l _ { c t x } , y ; \theta )$ . For a flow matching model, we set $\hat { l }$ as the mean over 20 samples, ensuring a fairer comparison. + +Duration correctness (MS-MAE) Our first metric, multi-sample mean-absolute error (MS-MAE), is the masked absolute error per-utterance divided by the average number of masked phonemes per-utterance + +$$ +\frac { \mathbb { E } _ { m , l , y } | | m \odot \left( l - \hat { l } ( l _ { c t x } , y ) \right) | | _ { 1 } } { \mathbb { E } _ { m , l , y } | | m | | _ { 1 } } +$$ + +Speaking rate correlation (MS-Corr) Our next metric, multi-sample correlation (MS-Corr), computes the average masked predicted duration and unmasked duration context per utterance, and computes their correlation across utterances. Comparing MS-Corr with the same correlation computed from the ground truth, we observe to what extent predicted durations capture appropriate correlations with the context. + +Duration diversity and quality (FDD) Additionally, we evaluate the quality and diversity of duration samples at the distribution level, similar to our audio evaluation of diversity and quality via FSD. We produce one sample per utterance from a duration model and collect all sampled phoneme durations, possibly many per-utterance, into an empirical distribution. We compare means and variances of this sampled distribution versus the means and variances of the training distribution, labeled $\mu , s$ , and $\mu ^ { \prime }$ , $s ^ { \prime }$ respectively. We define the Fréchet duration distance (FDD) as the Fréchet distance between the distributions + +$$ +( \mu - \mu ^ { \prime } ) ^ { 2 } + s + s ^ { \prime } - 2 \sqrt { s s ^ { \prime } } , +$$ + +treated as though they were Gaussians. FDD depends on the sampled durations accurately reflecting the training distribution of real durations. As for FSD, this metric is specific to unconditional text-to-speech generation. + +# C.3 Duration model evaluation with standalone metrics + +We evaluate three duration model variants. The first and second utilizes flow matching and regression, trained using masked conditional flow matching and regression respectively as described in Section 3.3. The third is a regression model that ignores duration context $l _ { c t x }$ and only uses phonetic transcript $y$ , referred to as unconditional regression below. This is the duration model used in FastSpeech2 [51], A3T [3] and many other non-autoregressive speech synthesis models. + +We evaluate our three duration model variants on the Librispeech test-other split on two tasks. The first is unconditional TTS where we generate all durations from given phonemes (i.e. $l _ { c t x }$ is entirely masked). The second task is infilling the second half of each utterance’s durations, where $l _ { c t x }$ are durations from the unmasked half of the utterance. This second infilling task distinguishes between the two regression model variants, since the unconditional regression ignores $l _ { c t x }$ , and hence predicts identical durations for the tasks. Duration metrics are computed for TTS and infilling in Table C8 and C9. The prefix Phn or Sil indicates the associated metric was either computed across all nonsilence or all silence phonemes. Start and end silences were not trimmed for these duration metric evaluations. + +Starting with prediction quality metrics (MS-MAE and MS-Corr), the duration-conditional regression performs slightly better on MS-MAE overall than the other models. Larger differences are seen on Phn-MS-Corr where the unconditional regression has a correlation substantively below the other models (Phn-MS-Corr of ground truth is 0.47), indicating conditioning on duration context $l _ { c t x }$ is beneficial. Flow-matching shows the largest distinction versus regression on the distributional comparison captured by FDD. The regression models have generally larger FDD because they underestimate the standard deviation in phoneme and silence durations, and hence produce samples with less duration diversity and more regular duration lengths. + +Table C8: English TTS duration metrics on LS test-other. + +
Duration ModelPhn-MS-MAEPhn-FDDSil-MS-MAESil-FDD
Unconditional Regression2.530.725.322.39
Duration-conditional Regression2.520.765.108.40
Duration-conditional Flow Matching2.630.615.182.48
+ +Table C9: English second-half infilling duration metrics on LS test-other. + +
Duration ModelPhn-MS-MAEPhn-MS-CorrSil-MS-MAE
Unconditional Regression2.570.265.44
Duration-conditional Regression2.450.355.20
Duration-conditional Flow Matching2.520.415.32
+ +# C.4 Duration model evaluation with end-to-end metrics + +We now present end-to-end metrics for our three duration variants for zero-shot TTS cross-sentence and continuation, as well as diverse speech generation, corresponding to Sections 5.1 and 5.3. Zero-shot TTS cross-sentence and continuation results are shown in Table C11 and diverse speech generation results in Table C10. These results are not comparable with the main text as they utilize the flow-matching model described in Appendix B.3, denoted as VB-En-1K. + +Overall, FSD and SIM are similar across duration variants. On the other hand, WER is sensitive to the choice of duration model, where the duration-conditional regression achieves a substantially lower WER. Subjective listening from the duration-conditional regression and flow-matching confirms that the regression model is producing more regular patterns of speech, that may be easier for ASR to recognize, while sacrificing some duration diversity. + +Table C10: Diverse speech generation from LS test-other text. + +
Duration Model with VB-En-1KWERFSD (LS-train)
Unconditional Regression3.8148.7
Duration-conditional Regression3.7148.1
Duration-conditional Flow Matching5.4155.1
+ +# C.5 MOS instructions + +Table C12 shows the instruction presented to the raters for quality mean opinion score study. Table C13 shows the instruction presented to the raters for similarity mean opinion score study. + +# D Limitation and Broader Impact + +Limitation Voicebox models presented in this paper are trained on read speech from audiobooks in up to six written languages. Hence, the current models may not transfer well to conversational speech [15], which is more casual and contains more non-verbal sounds such as laughing and backchanneling (e.g., um-hmm). We plan to tackle the problem by scaling the training data to incorporate more diverse speech. + +On the other hand, Voicebox depends on a phonemizer and a forced aligner to produce frame-level phonetic transcript. In addition, many existing phonemizers [40] are word-based, which does not take neighboring words of the target into account when predicting the pronunciation. Such phonemizers cannot accurately predict phonetic transcript given text because pronunciation is context-dependent in many languages (e.g., liaisons in French). In the future, we will explore more end-to-end methods where a model would be able to take raw text with punctuation as input [7], and eliminate the need of phonemizers and forced aligners to improve the performance and increase the language coverage. + +Table C11: English zero-shot TTS results on filtered LS test-clean. +Table C12: Quality mean opinion score (QMOS) instruction. + +
Duration Model with VB-En-1KWERSIM-0SIM-r
cross-sentence
Unconditional Regression3.00.5380.584
Duration-conditional Regression2.70.5450.591
Duration-conditional Flow Matching3.40.5280.578
continuation
Unconditional Regression2.50.4850.524
Duration-conditional Regression2.20.4910.533
Duration-conditional Flow Matching2.70.4810.525
+ +# Introduction + +Your task is to evaluate the subjective quality and intelligibility of the speech from short (2-8 second) audio files. Each HIT can be completed in roughly around 120 seconds. + +# Task Instructions + +In this task you will hear samples of speech recordings. The purpose of this test is to evaluate the quality and intelligibility of each file in terms of its overall sound quality and the amount of mumbling and unclear phrases in the recording. + +Please keep in mind that speech samples can be distorted and noisy, however these are only specific examples. + +Please use a headset for listening and adjust your volume level to your comfort during this training, and do not change later during the experiment. + +You should give a score according to the following scale, known as the MOS (mean opinion score) scales: + +# Score (Quality and Intelligibility of the speech) + +5 (Excellent) +4 (Good) +3 (Fair) +2 (Poor) +1 (Bad) + +Last but not least, while Voicebox yields impressive results on transferring audio style (voice, speaking style, emotion, and acoustic condition), the model does not allow independent control of each attribute. In other words, one cannot ask the model to generate speech that resembles voice of one sample while resembling the emotion of another sample. We leave disentangled control of attributes through prompting or text description for future work. + +Broader impact A high-quality and versatile generalist speech generation model like Voicebox can enable many applications that improve the quality of our life. For example, zero-shot TTS could bring the voice back to people who suffer from diseases or underwent surgeries such as laryngectomy the causes inability to speak. Zero-shot TTS can also be combined with visual speech recognition systems [23] to avoid the need of typing. When paired with speech translation models, cross-lingual zero-shot TTS enables everyone to speak any language in their own voice. Content editing and speech denoising can be productivity tools for users to create content more effortlessly. Diverse speech sampling, as shown in the paper, can significantly reduces the cost of creating data for training speech-input models. + +While Voicebox can bring many positive social impacts, it also carries the potential of misuse and unintended harm. To mitigate the risk, we have presented a highly effective classifier showing that the + +# Task Name + +Rate the similarity of the synthesized speech samples to a given prompt. + +# Task Instructions + +Your task is to evaluate the similarity of the synthesized speech samples to the given speech prompt. You should focus on the similarity of the speaker, speaking style, acoustic conditions, background noise, etc. You should rank the recordings on the scale between 1-5, where 5 is the best quality and 1 is the worst. + +In other words, please rank the recordings according to their acoustic similarity to the given prompt, meaning as if they were recorded in the same place by the same speaker speaking in similar styles. This task typically requires approximately 120 seconds to complete. + +Please use a headset for listening and adjust your volume level to your comfort during this training, and do not change later during the experiment. + +model can accurately distinguish between real and synthetic speech. For future work, we also plan to investigate proactive methods for training the generative model such that the synthetic speech can be more easily detected, such as embedding artificial fingerprints [66] that can be trivially detected without hurting the speech quality. + +To prevent Voicebox from learning biases, we also need to carefully select its training data. First, if Voicebox is only trained on a smaller number of speakers from a specific group with similar accents, it will not be able to generate diverse speech representing the accents around the globe, and downstream models trained on Voicebox generated speech would perform worse on groups with underrepresented accents. For zero-shot style transfer, the performance would also degrade for underrepresented accents. To mitigate this, we have leveraged in-the-wild speech that includes a wide variety of accents, and will continue investing in collecting diverse speech to avoid such biases. + +Second, if Voicebox is trained on data where samples from one ethnic group always have lower audio quality (e.g., more noise) while the other ethnic group always has higher audio quality samples, the model would also learn undesired association. To mitigate this, we want the distribution of audio quality (and other audio attributes) and ethnic group to be less correlated, which is usually the case when we have larger scale data collected from in-the-wild sources. We can further tackle this by leveraging data augmentation to decorrelate the distribution, such as adding noise and enhancing speech to widen the audio quality distribution. \ No newline at end of file diff --git a/md/dev/hpBTIv2uy_E/hpBTIv2uy_E.md b/md/dev/hpBTIv2uy_E/hpBTIv2uy_E.md new file mode 100644 index 0000000000000000000000000000000000000000..d2e3bc69043c44216f3cbd1b3ca7ca0d4f5b5b11 --- /dev/null +++ b/md/dev/hpBTIv2uy_E/hpBTIv2uy_E.md @@ -0,0 +1,591 @@ +# YOU ARE ALLSET: A MULTISET LEARNING FRAMEWORK FOR HYPERGRAPH NEURAL NETWORKS + +Eli Chien∗ Chao Pan∗ Jianhao Peng∗ Olgica Milenkovic + +Department of Electrical and Computer Engineering University of Illinois, Urbana-Champaign {ichien3,chaopan2,jianhao2,milenkov}@illinois.edu + +# ABSTRACT + +Hypergraphs are used to model higher-order interactions amongst agents and there exist many practically relevant instances of hypergraph datasets. To enable the efficient processing of hypergraph data, several hypergraph neural network platforms have been proposed for learning hypergraph properties and structure, with a special focus on node classification tasks. However, almost all existing methods use heuristic propagation rules and offer suboptimal performance on benchmarking datasets. We propose AllSet, a new hypergraph neural network paradigm that represents a highly general framework for (hyper)graph neural networks and for the first time implements hypergraph neural network layers as compositions of two multiset functions that can be efficiently learned for each task and each dataset. The proposed AllSet framework also for the first time integrates Deep Sets and Set Transformers with hypergraph neural networks for the purpose of learning multiset functions and therefore allows for significant modeling flexibility and high expressive power. To evaluate the performance of AllSet, we conduct the most extensive experiments to date involving ten known benchmarking datasets and three newly curated datasets that represent significant challenges for hypergraph node classification. The results demonstrate that our method has the unique ability to either match or outperform all other hypergraph neural networks across the tested datasets: As an example, the performance improvements over existing methods and a new method based on heterogeneous graph neural networks are close to $4 \%$ on the Yelp and Zoo datasets, and $3 \%$ on the Walmart dataset. Our AllSet network implementation is available online1. + +# 1 INTRODUCTION + +Graph-centered machine learning, and especially graph neural networks (GNNs), have attracted great interest in the machine learning community due to the ubiquity of graph-structured data and the importance of solving numerous real-world problems such as semi-supervised node classification and graph classification (Zhu, 2005; Shervashidze et al., 2011; Lu & Zhou, 2011). Graphs model ¨ pairwise interactions between entities, but fail to capture more complex relationships. Hypergraphs, on the other hand, involve hyperedges that can connect more than two nodes, and are therefore capable of representing higher-order structures in datasets. There exist many machine learning and data mining applications for which modeling high-order relations via hypergraphs leads to better learning performance when compared to graph-based models (Benson et al., 2016). For example, in subspace clustering, in order to fit a $d$ -dimensional subspace, we need at least $d { \pm } 1$ data points (Agarwal et al., 2005); in hierarchical species classification of a FoodWeb, a carbon-flow unit based on four species is significantly more predictive than that involving two or three entities (Li & Milenkovic, 2017). Hence, it is desirable to generalize GNN concepts to hypergraphs. + +One straightforward way to generalize graph algorithms for hypergraphs is to convert hypergraphs to graphs via clique-expansion (CE) (Agarwal et al., 2005; Zhou et al., 2006). CE replaces hyperedges by (possibly weighted) cliques. Many recent attempts to generalize GNNs to hypergraphs can be viewed as redefining hypergraph propagation schemes based on CE or its variants (Yadati et al., + +2019; Feng et al., 2019; Bai et al., 2021), which was also originally pointed out in (Dong et al., 2020). Despite the simplicity of CE, it is well-known that CE causes distortion and leads to undesired losses in learning performance (Hein et al., 2013; Li & Milenkovic, 2018; Chien et al., 2019b). + +In parallel, more sophisticated propagation rules directly applicable on hypergraphs, and related to tensor eigenproblems, have been studied as well. One such example, termed Multilinear PageRank (Gleich et al., 2015), generalizes PageRank techniques (Page et al., 1999; Jeh & Widom, 2003) directly to hypergraphs without resorting to the use of CE. Its propagation scheme is closely related to the Z eigenproblem which has been extensively investigated in tensor analysis and spectral hypergraph theory (Li et al., 2013; He & Huang, 2014; Qi & Luo, 2017; Pearson & Zhang, 2014; Gautier et al., 2019). An important result of Benson et al. (2017) shows that tensor-based propagation outperforms a CE-based scheme on several tasks. The pros and cons of these two types of propagation rule in statistical learning frameworks were examined in Chien et al. (2021a). More recently, it was shown in Tudisco et al. (2020) that label propagation based on CE of hypergraphs does not always lead to acceptable performance. Similarly to Chien et al. (2021a), Benson (2019) identified positive traits of CE eigenvectors but argued in favor of using $\textsf { Z }$ eigenvectors due to their more versatile nonlinear formulation compared to that of the eigenvectors of CE graphs. + +We address two natural questions pertaining to learning on hypergraphs: “Is there a general framework that includes CE-based, Z-based and other propagations on hypergraphs?” and, “Can we learn propagation schemes for hypergraph neural networks suitable for different datasets and different learning tasks?” We give affirmative answers to both questions. We propose a general framework, AllSet, which includes both CE-based and tensor-based propagation rules as special cases. We also propose two powerful hypergraph neural network layer architectures that can learn adequate propagation rules for hypergraphs using multiset functions. Our specific contributions are as follows. + +1. We show that using AllSet, one can not only model CE-based and tensor-based propagation rules, but also cover propagation methods of most existing hypergraph neural networks, including HyperGCN (Yadati et al., 2019), HGNN (Feng et al., 2019), HCHA (Bai et al., 2021), HNHN (Dong et al., 2020) and HyperSAGE (Arya et al., 2020). Most importantly, we show that all these propagation rules can be described as a composition of two multiset functions (leading to the proposed method name AllSet). Furthermore, we also show that AllSet is a hypergraph generalization of Message Passing Neural Networks (MPNN) (Gilmer et al., 2017), a powerful graph learning framework encompassing many GNNs such as GCN (Kipf & Welling, 2017) and GAT (Velickovi ˇ c et al., 2018). ´ + +2. Inspired by Deep Sets (Zaheer et al., 2017) and Set Transformer (Lee et al., 2019), we propose AllDeepSets and AllSetTransformer layers which are end-to-end trainable. They can be plugged into most types of graph neural networks to enable effortless generalizations to hypergraphs. Notably, our work represents the first attempt to connect the problem of learning multiset function with hypergraph neural networks, and to leverage the powerful Set Transformer model in the design of these specialized networks. + +3. We report, to the best of our knowledge, the most extensive experiments in the hypergraph neural networks literature pertaining to semi-supervised node classification. Experimental results against ten baseline methods on ten benchmark datasets and three newly curated and challenging datasets demonstrate the superiority and consistency of our AllSet approach. As an example, AllSetTransformer outperforms the best baseline method by close to $4 \%$ in accuracy on Yelp and Zoo datasets and $3 \%$ on the Walmart dataset; furthermore, AllSetTransformer matches or outperforms the best baseline models on nine out of ten datasets. Such improvements are not possible with modifications of HAN (Wang et al., 2019b), a heterogeneous GNN, adapted to hypergraphs or other specialized approaches that do not use Set Transformers. + +4. As another practical contribution, we also provide a succinct pipeline for standardization of the hypergraph neural networks evaluation process based on Pytorch Geometric (Fey & Lenssen, 2019). The pipeline is built in a fashion similar to that proposed in recent benchmarking GNNs papers (Hu et al., 2020a; Lim et al., 2021). The newly introduced datasets, along with our reported testbed, may be viewed as an initial step toward benchmarking hypergraph neural networks. + +All proofs and concluding remarks are relegated to the Appendix. + +![](images/297657dc455b25798a7f62405dfa5a2a676203ef9c08648d3e48c99eed8a94aa.jpg) +Figure 1: Left: The difference between a hypergraph and clique-expanded graph. Right: Illustration of our AllSet framework for the hypergraph depicted on the left. Included is an example on the aggregation rule for hyperedge $b$ and node 4. The key idea is that $f _ { \mathcal { V } \to \mathcal { E } }$ and $f _ { \mathcal { E } \to \mathcal { V } }$ are two multiset functions, which by definition are permutation invariant with respect to their input multisets. + +# 2 BACKGROUND + +Notation. A hypergraph is an ordered pair of sets $\mathcal G ( \nu , \mathcal { E } )$ , where $\mathcal { V } = \{ 1 , 2 , \hdots , n \}$ is the set of nodes while $\mathcal { E }$ is the set of hyperedges. Each hyperedge $e \in { \mathcal { E } }$ is a subset of $\nu$ , i.e., $e \subseteq \nu$ . Unlike a graph edge, a hyperedge $e$ may contain more than two nodes. If $\forall e \in \mathcal { E }$ one has $| e | = d \in \mathbb { N }$ , the hypergraph $\mathcal { G }$ is termed $d$ -uniform. A $d$ -uniform hypergraph can be represented by a $d$ -dimensional supersymmetric tensor such that for all distinct collections $i _ { 1 } , \dotsc , i _ { d } \in \mathcal { V }$ , $\begin{array} { r } { { \bf { A } } _ { i _ { 1 } , \dots , i _ { d } } = \frac { 1 } { ( d - 2 ) ! } } \end{array}$ if $e = \{ i _ { 1 } , . . . , i _ { d } \} \in \mathcal { E }$ , and $\mathbf { A } _ { i _ { 1 } , \dots , i _ { d } } = 0$ otherwise. Henceforth, $\mathbf { A } _ { : , \dots , i _ { d } }$ is used to denote the slice of A along the first coordinate. A hypergraph can alternatively be represented by its incidence matrix $\mathbf { H }$ , where $\mathbf { H } _ { v e } = 1$ if $v \in e$ and $\mathbf { H } _ { v e } = 0$ otherwise. We use the superscript $( t )$ to represent the functions or variables at the $t$ -th step of propagation and $\parallel$ to denote concatenation. Furthermore, $\Theta$ and $\mathbf { b }$ are reserved for a learnable weight matrix and bias of a neural network, respectively. Finally, we use $\sigma ( \cdot )$ to denote a nonlinear activation function (such as ReLU, eLU or LeakyReLU), which depends on the model used. + +CE-based propagation on hypergraphs. The CE of a hypergraph $\mathcal G ( \nu , \mathcal { E } )$ is a weighted graph with the same set of nodes $\nu$ . It can be described in terms of the associated adjacency or incidence matrices which we write with a slight abuse of notation as $\begin{array} { r } { \mathbf { A } _ { i j } ^ { ( C E ) } = \sum _ { i _ { 3 } , . . . , i _ { d } \in \mathcal { V } } \mathbf { A } _ { i , j , i _ { 3 } , . . . , i _ { d } } } \end{array}$ and $\mathbf { H } ^ { ( C E ) } = \mathbf { H } \mathbf { H } ^ { T }$ , respectively. It is obvious that these two matrices only differ in their diagonal entries (0s versus node degrees, respectively). One step of propagation of a $F$ -dimensional node feature matrix $\mathbf { X } \in \mathbb { R } ^ { n \times \bar { F } }$ is captured by $\mathbf { \hat { A } } ^ { ( C E ) } \mathbf { X }$ or ${ \bf H } ^ { ( \bar { C } E ) } \bar { \bf X }$ ; alternatively, in terms of node feature updates, we have + +$$ +\mathbf { C E p r o p A : X } _ { v , : } ^ { ( t + 1 ) } = \sum _ { e : v \in e } \sum _ { u : u \in e \backslash v } \mathbf { X } _ { u , : } ^ { ( t ) } ; \quad \mathbf { C E p r o p H : X } _ { v , : } ^ { ( t + 1 ) } = \sum _ { e : v \in e } \sum _ { u : u \in e } \mathbf { X } _ { u , : } ^ { ( t ) } , +$$ + +Many existing hypergraph convolutional layers actually perform CE-based propagation, potentially with further degree normalization and nonlinear hyperedge weights. For example, the propagation rule of HGNN (Feng et al., 2019) takes the following node-wise form: + +$$ +\mathbf { X } _ { v , : } ^ { ( t + 1 ) } = \sigma \left( \left[ \frac { 1 } { \sqrt { d _ { v } } } \sum _ { e : v \in e } \frac { w _ { e } } { \left| e \right| } \sum _ { u : u \in e } \frac { \mathbf { X } _ { u , : } ^ { ( t ) } } { \sqrt { d _ { u } } } \right] \boldsymbol { \Theta } ^ { ( t ) } + \mathbf { b } ^ { ( t ) } \right) , +$$ + +where $d _ { v }$ denotes the degree of node $v$ , $w _ { e }$ is a predefined weight of hyperedge $e$ and $\sigma$ is the ReLU activation function. The hypergraph convolution in HCHA (Bai et al., 2021) uses different degree normalizations and attention weights, with the attention weights depending on node features and the hyperedge features. If datasets do not contain hyperedge feature information or if the features come from a different domain compared to the node features, one cannot use their attention module (Bai et al., 2021). HyperGCN replaces each hyperedge by an incomplete clique via so-called mediators (Yadati et al., 2019). When the hypergraph is 3-uniform, the aforementioned approach becomes a standard weighted CE. Hence, all the described hypergraph neural networks adapt propagation rules based on CE or its variants, potentially with the addition of nonlinear hyperedge weights. The described methods achieve reasonable good performance on standard cocitation and coauthor benchmarking datasets. + +Tensor-based propagations. As mentioned in the introduction, there exist more elaborate tensorbased propagation schemes which in some cases outperform CE-based methods. The propagation rules related to $\textsf { Z }$ eigenproblems such as multilinear PageRank (Gleich et al., 2015) and spacey random walks (Benson et al., 2017) are two such examples. The $\boldsymbol { \mathrm { Z } }$ eigenproblem for an adjacency tensor $\mathbf { A }$ of a $d$ -uniform hypergraph is defined as: + +$$ +\lambda x = \mathbf { A } x ^ { d - 1 } \triangleq \sum _ { i _ { 2 } , \ldots , i _ { d } } \mathbf { A } _ { : , i _ { 2 } , \ldots , i _ { d } } x _ { i _ { 2 } } \dots x _ { i _ { d } } , x \in \mathbb { R } ^ { n } { \mathrm { ~ a n d ~ } } \| x \| ^ { 2 } = 1 . +$$ + +Here, $\mathbf { A } x ^ { d - 1 }$ equals $\begin{array} { r } { \sum _ { i _ { 2 } , \dots , i _ { d } } { \mathbf { A } } { } _ { : , i _ { 2 } , \dots , i _ { d } } x _ { i _ { 2 } } \dots x _ { i _ { d } } } \end{array}$ , an entity frequently used in the tensor analysis literature. The $\textsf { Z }$ eigenproblem has been extensively studied both in the context of tensor analysis and network sciences; the problem is also known as the $l ^ { 2 }$ eigenproblem (Lim, 2005; Gautier et al., 2019). We refer the interested readers to $\ Q \mathrm { i } \ \&$ Luo (2017) for a more detailed theoretical analysis of the $\textsf { Z }$ eigenproblems and Benson (2019) for its application in the study of hypergraph centralities. + +By ignoring the norm constraint, one can define the following tensor-based propagation rule based on (3) according to: + +$$ +\mathrm { Z p r o p } \colon \mathbf { X } _ { v , : } ^ { ( t + 1 ) } = \sum _ { e : v \in e } ( d - 1 ) \prod _ { u : u \in e \backslash v } \mathbf { X } _ { u , : } ^ { ( t ) } . +$$ + +Despite its interesting theoretical properties, Zprop is known to have what is termed the “unit problem” (Benson, 2019). In practice, the product can cause numerical instabilities for large hyperedges. Furthermore, Zprop has only been studied for the case of $d$ -uniform hypergraphs, which makes it less relevant for general hypergraph learning tasks. Clearly, CEprop and Zprop have different advantages and disadvantages for different dataset structures. This motivates finding a general framework that encompasses these two and other propagation rules. In this case, we aim to learn the suitable propagation scheme under such a framework for hypergraph neural networks. + +# 3 ALLSET: ONE METHOD TO BIND THEM ALL + +We show that all the above described propagation methods can be unified within one setting, termed AllSet. The key observation is that all propagation rules equal a composition of two multiset functions, defined below. + +Definition 3.1. A function $f$ is permutation invariant if and only $i f \forall \pi \in S _ { n }$ , where $S _ { n }$ denotes the symmetric group of order $n !$ !, $f ( \mathbf { x } _ { \pi ( 1 ) } , \ldots , \mathbf { x } _ { \pi ( n ) } ) = f ( \mathbf { x } _ { 1 } , \ldots , \mathbf { x } _ { n } )$ . + +Definition 3.2. We say that a function $f$ is a multiset function if it is permutation invariant. + +Next, let $V _ { e , \mathbf { X } } = \{ \mathbf { X } _ { u , : } : u \in e \}$ denote the multiset of hidden node representations contained in the hyperedge e. Also, let $\mathbf { Z } \in \mathbb { R } ^ { | \mathcal { E } | \times F ^ { \prime } }$ denote the hidden hyperedge representations. Similarly, let $E _ { v , \mathbf { Z } } = \{ \mathbf { Z } _ { e , : } : v \in e \}$ be the multiset of hidden representations of hyperedges that contain the node $v$ . The AllSet framework uses the update rules + +$$ +\mathbf { Z } _ { e , : } ^ { ( t + 1 ) } = f _ { \mathcal { V } \mathcal { E } } ( V _ { e , \mathbf { X } ^ { ( t ) } } ; \mathbf { Z } _ { e , : } ^ { ( t ) } ) , \quad \mathbf { X } _ { v , : } ^ { ( t + 1 ) } = f _ { \mathcal { E } \mathcal { V } } ( E _ { v , \mathbf { Z } ^ { ( t + 1 ) } } ; \mathbf { X } _ { v , : } ^ { ( t ) } ) , +$$ + +where $f _ { \mathcal { V } \to \mathcal { E } }$ and $f _ { \mathcal { E } \mathcal { V } }$ are two multiset functions with respect to their first input. For the initial condition, we choose $\mathbf { Z } _ { e , : } ^ { ( 0 ) }$ and $\mathbf { X } _ { v , : } ^ { ( 0 ) }$ to be hyperedge features and node features, respectively (if available). If these are not available, we set both entities to be all-zero matrices. Note that we make the tacit assumption that both functions $f _ { \mathcal { V } \to \mathcal { E } }$ and $f _ { \mathcal { E } \to \mathcal { V } }$ also include the hypergraph $\mathcal { G }$ as an input. This allows degree normalization to be part of our framework. As one can also distinguish the aggregating node $v$ from the multiset $V _ { e , \mathbf { X } ^ { ( t ) } }$ , we also have the following AllSet variant: + +$$ +\begin{array} { r } { \mathbf { Z } _ { e ; } ^ { ( t + 1 ) , v } = f _ { \mathcal { V } \mathcal { E } } ( V _ { e \backslash v , \mathbf { X } ^ { ( t ) } } ; \mathbf { Z } _ { e ; } ^ { ( t ) , v } , \mathbf { X } _ { v ; } ^ { ( t ) } ) , \quad \mathbf { X } _ { v ; } ^ { ( t + 1 ) } = f _ { \mathcal { E } \mathcal { V } } ( E _ { v , \mathbf { Z } ^ { ( t + 1 ) , v } } ; \mathbf { X } _ { v ; } ^ { ( t ) } ) , } \end{array} +$$ + +For simplicity, we omit the last input argument $\mathbf { X } _ { v , : } ^ { ( t ) }$ for $f _ { \mathcal { V } \to \mathcal { E } }$ in (6), unless explicitly needed (as in the proof pertaining to HyperGCN). The formulation (5) lends itself to a significantly more computationally- and memory-efficient pipeline. This is clearly the case since for each hyperedge $e$ , the expression in (5) only uses one hyperedge hidden representation while the expression (6) uses $| e |$ distinct hidden representations. This difference can be substantial when the hyperedge sizes are large. Hence, we only use (6) for theoretical analysis purposes and (5) for all experimental verifications. The next theorems establish the universality of the AllSet framework. + +Theorem 3.3. CEpropH of (1) is a special case of AllSet (5). Furthermore, CEpropA of (1) and Zprop of (4) are also special cases of AllSet (6). + +Sketch of proof. If we ignore the second input and choose both $f _ { \mathcal { V } \to \mathcal { E } }$ and $f _ { \mathcal { E } \mathcal { V } }$ to be sums over their input multisets, we recover the CE-based propagation rule CEpropH of (1) via (5). For CEpropA, the same observation is true with respect to (6). If one instead chooses $f _ { \mathcal { V } \to \mathcal { E } }$ to be the product over its input multiset, multiplied by the scalar $| V _ { e , \mathbf { X } ^ { ( t ) } } | - 1$ , one recovers the tensor-based propagation Zprop of (4) via (6). + +Next, we show that many state-of-the-art hypergraph neural network layers also represent special instances of AllSet and are strictly less expressive than AllSet. + +Theorem 3.4. The hypergraph neural network layers of HGNN (2), HCHA (Bai et al., 2021), HNHN (Dong et al., 2020) and HyperSAGE (Arya et al., 2020) are all special cases of AllSet (5). The HyperGCN layer (Yadati et al., 2019) is a special instance of AllSet (6). Furthermore, all the above methods are strictly less expressive than AllSet (5) and (6). More precisely, there exists a combination of multiset functions $f _ { \mathcal { V } \to \mathcal { E } }$ and $f _ { \mathcal { E } \to \mathcal { V } }$ for AllSet (5) and (6) that cannot be modeled by any of the aforementioned hypergraph neural network layers. + +The first half of the proof is by direct construction. The second half of the proof consists of counterexamples. Intuitively, none of the listed hypergraph neural network layers can model Zprop (3) while we established in the previous result that Zprop is a special case of AllSet. + +The last result shows that the MPNN (Gilmer et al., 2017) framework is also a special instance of our AllSet for graphs, which are (clearly) special cases of hypergraphs. Hence, AllSet may also be viewed as a hypergraph generalization of MPNN. Note that MPNN itself generalizes many wellknown GNNs, such as GCN (Kipf & Welling, 2017), Gated Graph Neural Networks (Li et al., 2015) and GAT (Velickovi ˇ c et al., 2018). ´ + +Theorem 3.5. MPNN is a special case of AllSet (6) when applied to graphs. + +# 4 HOW TO LEARN ALLSET LAYERS + +The key idea behind AllSet is to learn the multiset functions $f _ { \mathcal { V } \to \mathcal { E } }$ and $f _ { \mathcal { E } \mathcal { V } }$ on the fly for each dataset and task. To facilitate this learning process, we first have to properly parametrize the multiset functions. Ideally, the parametrization should represent a universal approximator for a multiset function that allows one to retain the higher expressive power of our architectures when compared to that of the hypergraph neural networks described in Theorem 3.4. For simplicity, we focus on the multiset inputs of $f _ { \mathcal { V } \to \mathcal { E } }$ and $f _ { \mathcal { E } \to \mathcal { V } }$ and postpone the discussion pertaining to the second arguments of the functions to the end of this section. + +Under the assumption that the multiset size is finite, the authors of Zaheer et al. (2017) and Wagstaff et al. (2019) proved that any multiset functions $f$ can be parametrized as $\begin{array} { r } { f ( S ) = \rho \left( \sum _ { s \in S } \breve { \phi ( s ) } \right) , } \end{array}$ where $\rho$ and $\phi$ are some bijective mappings (Theorem 4.4 in Wagstaff et al. (2019)). In practice, these mappings can be replaced by any universal approximator such as a multilayer perceptron (MLP) (Zaheer et al., 2017). This leads to the purely MLP AllSet layer for hypergraph neural networks, termed AllDeepSets. + +$$ +\mathrm { A l l D e e p S e t s : ~ } f _ { \mathcal { V } \to \mathcal { E } } ( S ) = f _ { \mathcal { E } \to \mathcal { V } } ( S ) = \mathrm { M L P } \left( \sum _ { s \in S } \mathrm { M L P } ( s ) \right) . +$$ + +The authors of Lee et al. (2019) argued that the unweighted sum in Deep Set makes it hard to learn the importance of each individual contributing term. Thus, they proposed the Set Transformer paradigm which was shown to offer better performance than Deep Sets as a learnable multiset function architecture. Based on this result, we also propose an attention-based AllSet layer for hypergraph neural networks, termed AllSetTransformer. Given the matrix $\mathbf { S } \in \mathbb { R } ^ { | S | \times F }$ which represents the multiset $S$ of $F$ -dimensional real vectors, the definition of AllSetTransformer is + +AllSetTransformer: $f _ { \mathcal V \to \mathcal E } ( S ) = f _ { \mathcal E \to \mathcal V } ( S ) = \mathrm { L N } \left( \mathbf Y + \mathbf M \mathbf L \mathbf P ( \mathbf Y ) \right) ,$ where $\mathbf { Y } = \mathbf { L } \mathbf { N } \left( \theta + \mathbf { M } \mathbf { H } _ { h , \omega } ( \theta , \mathbf { S } , \mathbf { S } ) \right) , \mathbf { M } \mathbf { H } _ { h , \omega } ( \theta , \mathbf { S } , \mathbf { S } ) = \| _ { i = 1 } ^ { h } \mathbf { O } ^ { ( i ) }$ + +$$ +\mathbf { O } ^ { ( i ) } = \omega \left( \theta ^ { ( i ) } ( \mathbf { K } ^ { ( i ) } ) ^ { T } \right) \mathbf { V } ^ { ( i ) } , \theta \triangleq \Vert _ { i = 1 } ^ { h } \theta ^ { ( i ) } , \mathbf { K } ^ { ( i ) } = \mathbf { M } \mathbf { L } \mathbf { P } ^ { K , i } ( \mathbf { S } ) , \mathbf { V } ^ { ( i ) } = \mathbf { M } \mathbf { L } \mathbf { P } ^ { V , i } ( \mathbf { S } ) . +$$ + +Here, LN represents the layer normalization (Ba et al., 2016), $\parallel$ denotes concatenation and $\theta \in$ $\mathbb { R } ^ { 1 \times h F _ { h } }$ is a learnable weight; in addition, $\mathrm { M H } _ { h , \omega }$ is a multihead attention mechanism with $h$ heads and activation function $\omega$ (Vaswani et al., 2017). Note that the dimension of the output of $\mathbf { M H } _ { h , \omega }$ is $1 \times h F _ { h }$ where $F _ { h }$ is the hidden dimension of $\mathbf { V } ^ { ( i ) } \in \mathbb { R } ^ { | S | \times F _ { h } }$ . In our experimental setting, we choose $\omega$ to be the softmax function which is robust in practice. Our formulation of projections in $\mathbf { M H } _ { h , \omega }$ is slight more general than standard linear projections. If one restricts ${ \bf M L P } ^ { K , i }$ and ${ \bf M L P } ^ { V , i }$ to one-layer perceptrons without a bias term (i.e., including only a learnable weight matrix), we obtain standard linear projections in the multihead attention mechanism. The output dimensions of ${ \bf M L P } ^ { K , i }$ and ${ \bf M L P } ^ { V , i }$ are both equal to $\mathbb { R } ^ { | S | \times F _ { h } }$ . It is worth pointing out that all the MLP modules operate row-wise, which means they are applied to each multiset element (a real vector) independently and in an identical fashion. This directly implies that MLP modules are permutation equivariant. + +Based on the above discussion and Proposition 2 of Lee et al. (2019) we have the following result. + +Proposition 4.1. The functions $f _ { \mathcal { V } \to \mathcal { E } }$ and $f _ { \mathcal { E } \mathcal { V } }$ defined in AllSetTransformer (8) are permutation invariant. Furthermore, the functions $f _ { \mathcal { V } \to \mathcal { E } }$ and $f _ { \mathcal { E } \to \mathcal { V } }$ defined in (8) are universal approximators of multiset functions when the size of the input multiset is finite. + +Note that in practice, both the size of hyperedges and the node degrees are finite. Thus, the finite size multiset assumption is satisfied. Therefore, the above results directly imply that the AllDeepSets (7) and AllSetTransformer (8) layers have the same expressive power as the general AllSet framework. Together with the result of Theorem 3.4, we arrive at the conclusion that AllDeepSets and AllSetTransformer are both more expressive than any other aforementioned hypergraph neural network. + +Conceptually, one can also incorporate the Set Attention Block and the two steps pooling strategy of Lee et al. (2019) into AllSet. However, it appears hard to make such an implementation efficient and we hence leave this investigation as future work. In practice, we find that even our simplified design (8) already outperforms all baseline hypergraph neural networks, as demonstrated by our extensive experiments. Also, it is possible to utilize the information of the second argument of $f _ { \mathcal { V } \to \mathcal { E } }$ and $f _ { \mathcal { E } \mathcal { V } }$ via concatenation, another topic relegated to future work. + +As a concluding remark, we observe that the multiset functions in both AllDeepSets (7) and AllSetTransformer (8) are universal approximators for general multiset functions. In contrast, the other described hypergraph neural network layers fail to retain the universal approximation property for general multiset functions, as shown in Theorem 3.4. This implies that all these hypergraph neural network layers have strictly weaker expressive power compared to AllDeepSets (7) and AllSetTransformer (8). We also note that any other universal approximators for multiset functions can easily be combined with our AllSet framework (as we already demonstrated by our Deep Sets and Set Transformer examples). One possible candidate is Janossy pooling (Murphy et al., 2019) which will be examined as part of our future work. Note that more expressive models do not necessarily have better performance than less expressive models, as many other factors influence system performance (as an example, AllDeepSet performs worse than AllSetTransformer albeit both have the same theoretical expressive power; this is in agreement with the observation from Lee et al. (2019) that Set Transformer can learn multiset functions better than Deep Set.). Nevertheless, we demonstrate in the experimental verification section that our AllSetTransformer indeed has consistently better performance compared to other baseline methods. + +# 5 RELATED WORKS + +Due to space limitations, a more comprehensive discussion of related work is relegated to the Appendix A. + +Hypergraph learning. Learning on hypergraphs has attracted significant attention due to its ability to capture higher-order structural information (Li et al., 2017; 2019). In the statistical learning and information theory literature, researchers have studied community detection problem for hypergraph stochastic block models (Ghoshdastidar & Dukkipati, 2015; Chien et al., 2018; 2019a). In the machine learning community, methods that mitigate drawbacks of CE have been reported in (Li & Milenkovic, 2017; Chien et al., 2019b; Hein et al., 2013; Chan et al., 2018). Despite these advances, hypergraph neural network developments are still limited beyond the works covered by the AllSet paradigm. Exceptions include Hyper-SAGNN (Zhang et al., 2019), LEGCN (Yang et al., 2020) and MPNN-R (Yadati, 2020), the only three hypergraph neural networks that do not represent obvious special instances of AllSet. But, Hyper-SAGNN focuses on hyperedge prediction while we focus on semi-supervised node classification. LEGCN first transforms hypergraphs into graphs via line expansion and then applies a standard GCN. Although the transformation used in LEGCN does not cause a large distortion as CE, it significantly increases the number of nodes and edges. Hence, it is not memory and computationally efficient (more details about this approach can be found in the Appendix G). MPNN-R focuses on recursive hypergraphs (Joslyn & Nowak, 2017), which is not the topic of this work. It is an interesting future work to investigate the relationship between AllSet and Hyper-SAGNN or MPNN-R when extending AllSet to hyperedge prediction tasks or recursive hypergraph implementations. + +Furthermore, Tudisco & Higham (2021); Tudisco et al. (2021) also proposed to develop and analyze hypergraph propagations that operate “between” CE-prop and Z-prop rules. These works focus on the theoretical analysis of special types of propagation rules, which can also be modeled by our AllSet frameworks. Importantly, our AllSet layers do not fix the rules but instead learn them in an adaptive manner. Also, one can view Tudisco & Higham (2021); Tudisco et al. (2021) as the hypergraph version of SGC, which can help with interpreting the functionalities of AllSet layers. + +Star expansion, UniGNN and Heterogeneous GNNs. A very recent work concurrent to ours, UniGNN (Huang & Yang, 2021), also proposes to unify hypergraph and GNN models. Both Huang & Yang (2021) and our work can be related to hypergraph star expansion (Agarwal et al., 2006; Yang et al., 2020), which results in a bipartite graph (see Figure 1). One particular variant, UniGIN, is related to our AllDeepSets model, as both represent a hypergraph generalization of GIN (Xu et al., 2019). However, UniGNN does not make use of deep learning methods for learning multiset functions, which is crucial for identifying the most appropriate propagation and aggregation rules for individual datasets and learning tasks as done by AllSetTransformer (see Section 6 for supporting information). Also, the most advanced variant of UniGNN, UniGCNII, is not comparable to AllSetTransformers. Furthermore, one could also naively try to apply heterogeneous GNNs, such as HAN (Wang et al., 2019b), to hypergraph datasets converted into bipartite graphs. This approach was not previously examined in the literature, but we experimentally tested it nevertheless to show that the performance improvements in this case are significantly smaller than ours and that the method does not scale well even for moderately sized hypergraphs. Another very recent work (Xue et al., 2021) appears at first glance similar to ours, but it solves a very different problem by transforming a heterogeneous bipartite graph into a hypergraph and then apply standard GCN layers to implement $f _ { \mathcal { V } \to \mathcal { E } }$ and $f _ { \mathcal { E } \mathcal { V } }$ , which is more related to HNHN (Dong et al., 2020) and UniGCN (Huang & Yang, 2021) and very different from AllSetTransformer. + +Learning (multi)set functions. (Multi)set functions, which are also known as pooling architectures for (multi)sets, have been used in numerous problems including causality discovery (Lopez-Paz et al., 2017), few-shot image classification (Snell et al., 2017) and conditional regression and classification (Garnelo et al., 2018). The authors of Zaheer et al. (2017) provide a universal way to parameterize the (multi)set functions under some mild assumptions. Similar results have been proposed independently by the authors of Qi et al. (2017) for computer vision applications. The authors of Lee et al. (2019) propose to learn multiset functions via attention mechanisms. This further inspired the work in Baek et al. (2021), which adopted the idea for graph representation learning. The authors of Wagstaff et al. (2019) discuss the limitation of Zaheer et al. (2017), and specifically focus on continuous functions. A more general treatment of how to capture complex dependencies among multiset elements is available in Murphy et al. (2019). To the best of our knowledge, this work is the first to build the connection between learning multiset functions with propagations on hypergraph. + +Table 1: Dataset statistics: $| e |$ refers to the size of the hyperedges while $d _ { v }$ refers to the node degree. + +
CoraCiteseerPubmedCora-CADBLP-CAZ0o20NewsMushroomNTU2012 ModelNet40YelpHouseWalmart
V|270833121971727084130210116242812420121231150758129088860
|ε|1579107979631072223634310029820121231167930234169906
# feature143337035001433142516100221001001862100100
#class7637674267409211
max |el5261714320293224118085528388125
+ +# 6 EXPERIMENTS + +We focus on semi-supervised node classification in the transductive setting. We randomly split the data into training/validation/test samples using $( 5 0 \% / 2 5 \% / 2 5 \% )$ splitting percentages. We aggregate the results of 20 experiments using multiple random splits and initializations. + +Methods used for comparative studies. We compare our AllSetTransformer and AllDeepSets with ten baseline models, MLP, CE $^ +$ GCN, $\mathrm { C E { + } G A T }$ , HGNN (Feng et al., 2019), HCHA (Bai et al., 2021), HyperGCN (Yadati et al., 2019), HNHN (Dong et al., 2020), UniGCNII (Huang & Yang, 2021) and HAN (Wang et al., 2019b), with both full batch and mini-batch settings. All architectures are implemented using the Pytorch Geometric library (PyG) (Fey & Lenssen, 2019) except for HAN, in which case the implementation was retrieved from Deep Graph Library (DGL) (Wang et al., 2019a). The implementation of HyperGCN2 is used in the same form as reported in the official repository. We adapted the implementation of HCHA from PyG. We also reimplemented HNHN and HGNN using the PyG framework. Note that in the original implementation of $\mathrm { H G N N } ^ { 3 }$ , propagation is performed via matrix multiplication which is far less memory and computationally efficient when compared to our implementation. MLP, GCN and GAT are executed directly from PyG. The UniGCNII code is taken from the official site4. For HAN, we tested both the full batch training setting and a mini-batch setting provided by DGL. We treated the vertices $( \mathcal { V } )$ and hyperedges $( \mathcal { E } )$ as two heterogeneous types of nodes, and used two metapaths: $\{ \mathcal { V } \to \mathcal { E } \to \mathcal { V } , \mathcal { E } \to \mathcal { V } \to \mathcal { E } \}$ in its semantic attention. In the mini-batch setting, we used the DGL’s default neighborhood sampler with a number of neighbors set to 32 during training and 64 for validation and testing purposes. In both settings, due to the specific conversion of hyperedges into nodes, our evaluations only involve the original labeled vertices in the hypergraph and ignore the hyperedge node-proxies. More details regarding the experimental settings and the choices of hyperparameters are given in the Appendix J. + +Benchmarking and new datasets. We use ten available datasets from the existing hypergraph neural networks literature and three newly curated datasets from different application domains. The benchmark datasets include cocitation networks Cora, Citeseer and Pubmed, downloaded from Yadati et al. (2019). The coauthorship networks Cora-CA and DBLP-CA were adapted from Yadati et al. (2019). We also tested datasets from the UCI Categorical Machine Learning Repository (Dua & Graff, 2017), including 20Newsgroups, Mushroom and Zoo. Datasets from the area of computer vision and computer graphics include ModelNet40 (Wu et al., 2015) and NTU2012 (Chen et al., 2003). The hypergraph construction follows the recommendations from Feng et al. (2019); Yang et al. (2020). The three newly introduced datasets are adaptations of Yelp (Yelp), House (Chodrow et al., 2021) and Walmart (Amburg et al., 2020). Since there are no node features in the original datasets of House and Walmart, we use Gaussian random vectors instead, in a fashion similar to what was proposed for Contextual stochastic block models (Deshpande et al., 2018). We use postfix $( x )$ to indicate the standard deviation of the added Gaussian features. The partial statistics of all datasets are provided in Table 1, and more details are available in the Appendix I. + +Results. We use accuracy (micro-F1 score) as the evaluation metric, along with its standard deviation. The relevant findings are summarized in Table 2. The results show that AllSetTransformer is the most robust hypergraph neural network model and that it has the best overall performance when compared to state-of-the art and new models such a hypergraph HAN. In contrast, all baseline methods perform poorly on at least two datasets. For example, UniGCNII and HAN are two of the best performing baseline models according to our experiments. However, UniGCNII performs poorly on Zoo, Yelp and Walmart when compared to our AllSetTransformer. More precisely, AllSetTransformer outperforms UniGCNII by $1 1 . 0 1 \%$ in accuracy on the Walmart(1) dataset. HAN has poor performance when compared AllSetTransformer on Mushroom, NTU2012 and ModelNet40. Furthermore, it experiences memory overload issues on Yelp and Walmart with a full batch setting and performs poorly with a mini-batch setting on the same datasets. Numerically, AllSetTransformer outperforms HAN with full batch setting by $9 . 1 4 \%$ on the Mushroom and HAN with mini-batch setting and by $1 6 . 8 9 \%$ on Walmart(1). These findings emphasize the importance of including diverse datasets from different application domains when trying to test hypergraph neural networks fairly. Testing standard benchmark datasets such as Cora, Citeseer and Pubmed alone is insufficient and can lead to biased conclusions. Indeed, our experiments show that all hypergraph neural networks work reasonably well on these three datasets. Our results also demonstrate the power of Set Transformer when applied to hypergraph learning via the AllSet framework. + +Table 2: Results for the tested datasets: Mean accuracy $( \% ) \pm$ standard deviation. Boldfaced letters shaded grey are used to indicate the best result, while blue shaded boxes indicate results within one standard deviation of the best result. NA indicates that the method has numerical precision issue. For $\mathrm { H A N ^ { * } }$ , additional preprocessing of each dataset is required (see the Section 6 for more details). + +
Cora Citeseer PubmedCora-CADBLP-CAZoo 20Newsgroups mushroom
AllSetTransformer78.59 ± 1.4773.08 ± 1.20 88.72 ± 0.37 83.63± 1.47 91.53 ± 0.2383.63 ± 1.4791.53 ± 0.2397.50 ± 3.5981.38 ± 0.58100.00 ± 0.00
AlIDeepSets76.88 ± 1.8070.83± 1.6388.75 ± 0.3381.97 ±1.5091.27 ± 0.2795.39 ± 4.7781.06 ± 0.5499.99 ± 0.02
MLP75.17 ± 1.2172.67 ± 1.5687.47 ± 0.5174.31 ± 1.8984.83 ± 0.2287.18 ± 4.4481.42 ± 0.49100.00 ± 0.00
CECGN76.17 ± 1.3970.16 ± 1.3186.45 ± 0.4377.05 ± 1.2688.00±0.2651.54 ± 11.190OM95.27 ± 0.47
CEGAT76.41 ± 1.5370.63 ± 1.3086.81 ±0.4276.16 ± 1.1988.59± 0.2947.88 ± 14.030OM96.60 ± 1.67
HNHN76.36 ± 1.9272.64 ± 1.5786.90±0.3077.19 ± 1.4986.78 ± 0.2993.59 ± 5.8881.35 ± 0.61100.00 ± 0.01
HGNN79.39 ± 1.3672.45 ± 1.1686.44 ± 0.4482.64 ± 1.6591.03 ± 0.2092.50± 4.5880.33 ± 0.4298.73 ± 0.32
HCHA79.14 ± 1.0272.42 ± 1.4286.41 ±0.36582.55± 0.9790.92 ± 0.2293.65 ± 6.1580.33 ±0.8098.70 ±0.39
HyperGCN78.45 ± 1.2671.28 ±0.8282.84 ± 8.6779.48 ± 2.0889.38± 0.25N/A81.05 ± 0.5947.90 ± 1.04
UniGCNII78.81 ± 1.0573.05 ± 2.2188.25 ± 0.4083.60 ± 1.1491.69 ± 0.1993.65 ± 4.3781.12 ± 0.6799.96 ± 0.05
HAN (full batch)*80.18 ± 1.1574.05 ± 1.4386.21 ± 0.4884.04 ± 1.0290.89 ± 0.2385.19 ± 8.180OM90.86± 2.40
HAN (mini batch)*79.70 ± 1.7774.12 ± 1.5285.32 ± 2.2581.71 ± 1.7390.17 ± 0.6575.77 ± 7.1079.72 ± 0.6293.45 ± 1.31
NTU2012ModelNet40YelpHouse(1)Walmart(1)House(0.6)Walmart(0.6)avg.ranking (↑)
AllSetTransformer88.69 ± 1.2498.20 ± 0.20 36.89± 0.5198.20 ± 0.20 36.89± 0.5169.33 ± 2.2065.46 ± 0.2583.14 ± 1.9278.46 ± 0.402.00
AllDeepSets88.09 ± 1.5296.98±0.2630.36 ±1.5767.82 ± 2.4064.55 ± 0.3380.70 ± 1.5978.46 ± 0.264.47
MLP85.52 ± 1.4996.14± 0.3631.96± 0.4467.93 ± 2.3345.51± 0.2481.53 ± 2.2663.28 ± 0.376.27
CECGN81.52 ± 1.4389.92 ± 0.46OOM62.80± 2.6154.44 ± 0.2464.36 ± 2.4159.78 ± 0.329.66
CEGAT82.21 ± 1.2392.52 ± 0.39OOM69.09 ± 3.0051.14 ± 0.5677.25 ± 2.5359.47 ± 1.058.80
HNHN89.11 ± 1.4497.84± 0.2531.65 ± 0.4467.80 ± 2.5947.18 ± 0.3578.78 ± 1.8865.80 ± 0.395.87
HGNN87.72 ± 1.3595.44± 0.3333.04 ± 0.6261.39 ± 2.9662.00 ± 0.2466.16 ± 1.8077.72 ± 0.215.73
HCHA87.48 ± 1.8794.48±0.2830.99 ±0.7261.36 ± 2.5362.45 ± 0.2667.91 ± 2.2677.12 ± 0.266.40
HyperGCN56.36± 4.86 75.89 ± 5.2656.36± 4.86 75.89 ± 5.2629.42 ± 1.5448.31± 2.9344.74 ± 2.8178.22 ± 2.4655.31 ± 0.309.87
UniGCNII89.30 ± 1.3398.07 ± 0.2331.70 ± 0.5267.25 ± 2.5754.45 ± 0.3780.65 ± 1.9672.08 ±0.283.87
HAN (full batch)*83.58±1.4694.04 ± 0.410OM71.05 ± 2.260OM83.27 ± 1.62OOM6.73
HAN (mini batch)*80.77 ± 2.36 91.52± 0.9680.77 ± 2.36 91.52± 0.9626.05 ± 1.3762.00 ±9.06 48.57 ± 1.0462.00 ±9.06 48.57 ± 1.0482.04 ± 2.6863.10 ± 0.96 7.60
+ +The execution times of all methods are available in the Appendix J: They show that the complexity of AllSet is comparable to that of the baseline hypergraph neural networks. This further strengthens the case for AllSet, as its performance gains do not come at the cost of high computational complexity. Note that in HAN’s mini-batch setting, the neighborhood sampler is performed on CPU instead of GPU, hence its training time is significantly higher than that needed by other methods, due to the frequent I/O operation between CPU and GPU. On some larger datasets such as Yelp and Walmart, 20 runs take more than 24 hours so we only recorded the results for first 10 runs. + +The performance of AllDeepSets is not on par with that of AllSetTransformer, despite the fact that both represent universal approximators of the general AllSet formalism. This result confirms the assessment of Lee et al. (2019) that attention mechanisms are crucial for learning multiset functions in practice. Furthermore, we note that combining CE with existing GNNs such as GCN and GAT leads to suboptimal performance. CE-based approaches are also problematic in terms of memory efficiency when large hyperedges are present. This is due to the fact the CE of a hyperedge $e$ leads to $\Theta ( | e | ^ { \bar { 2 } } )$ edges in the resulting graph. Note that as indicated in Table 2, CE-based methods went out-of-memory (OOM) for 20Newsgroups and Yelp. These two datasets have the largest maximum hyperedge size, as can be see from Table 1. HAN encounters the OOM issue on even more datasets when used in the full batch setting, and its mini-batch setting mode perform poorly on Yelp and Walmart. This shows that a naive application of standard heterogeneous GNNs on large hypergraphs often fails and is thus not as robust as our AllSetTransformer. The mediator HyperGCN approach exhibits numerical instabilities on some datasets (i.e., Zoo and House) and may hence not be suitable for learning on general hypergraph datasets. + +# ACKNOWLEDGMENTS + +The authors would like to thank Prof. Pan Li at Purdue University for helpful discussions. The authors would also like to thank Chaoqi Yang for answering questions regarding the LEGCN method. This work was funded by the NSF grant 1956384. + +# 7 ETHICS STATEMENT + +We do not aware of any potential ethical issues regarding our work. For the newly curated three datasets, there is no private personally identifiable information. Note that although nodes in House datasets represent congresspersons and hyperedges represent members serving on the same committee, this information is public and not subject to privacy constraints. For the Walmart dataset, the nodes are products and hyperedges are formed by sets of products purchased together. We do not include any personal information regarding the buyers (customers) in the text. In the Yelp dataset the nodes represent restaurants and hyperedges are collections of restaurants visited by the same user. Similar to the Walmart case, there is no user information included in the dataset. More details of how the features in each datasets are generated can be found in Appendix I. + +# 8 REPRODUCIBILITY STATEMENT + +We have tried our best to ensure reproducibility of our results. We built a succinct pipeline for standardization of the hypergraph neural networks evaluation process based on Pytorch Geometric. This implementation can be checked by referring to our supplementary material. We include all dataset in our supplementary material and integrate all tested methods in our code. Hence, one can simply reproduce all experiment results effortlessly (by just running a one-line command). All details regarding how the datasets were prepared are stated in Appendix I. All choices of hyperparameters and the process of selecting them are available in Appendix J. Our experimental settings including the specifications of our machine and environment, the training/validation/test split and the evaluation metric. Once again, refer ro the Appendix J and Section 6. We also clearly specify all the package dependencies used in our code in the Supplementary material. + +# REFERENCES + +Sameer Agarwal, Jongwoo Lim, Lihi Zelnik-Manor, Pietro Perona, David Kriegman, and Serge Belongie. Beyond pairwise clustering. In 2005 IEEE Computer Society Conference on Computer Vision and Pattern Recognition (CVPR’05), volume 2, pp. 838–845. IEEE, 2005. +Sameer Agarwal, Kristin Branson, and Serge Belongie. Higher order learning with graphs. In Proceedings of the 23rd international conference on Machine learning, pp. 17–24, 2006. +Ilya Amburg, Nate Veldt, and Austin Benson. Clustering in graphs and hypergraphs with categorical edge labels. In Proceedings of The Web Conference 2020, WWW ’20, pp. 706–717, New York, NY, USA, 2020. Association for Computing Machinery. ISBN 9781450370233. doi: 10.1145/ 3366423.3380152. URL https://doi.org/10.1145/3366423.3380152. +Devanshu Arya, Deepak K Gupta, Stevan Rudinac, and Marcel Worring. Hypersage: Generalizing inductive representation learning on hypergraphs. arXiv preprint arXiv:2010.04558, 2020. +Jimmy Lei Ba, Jamie Ryan Kiros, and Geoffrey E Hinton. Layer normalization. arXiv preprint arXiv:1607.06450, 2016. +Jinheon Baek, Minki Kang, and Sung Ju Hwang. Accurate learning of graph representations with graph multiset pooling. In International Conference on Learning Representations, 2021. URL https://openreview.net/forum?id $\underline { { \underline { { \mathbf { \Pi } } } } } =$ JHcqXGaqiGn. +Song Bai, Feihu Zhang, and Philip HS Torr. Hypergraph convolution and hypergraph attention. Pattern Recognition, 110:107637, 2021. +Austin R Benson. Three hypergraph eigenvector centralities. SIAM Journal on Mathematics of Data Science, 1(2):293–312, 2019. + +Austin R Benson, David F Gleich, and Jure Leskovec. Higher-order organization of complex networks. Science, 353(6295):163–166, 2016. + +Austin R Benson, David F Gleich, and Lek-Heng Lim. The spacey random walk: A stochastic process for higher-order data. SIAM Review, 59(2):321–345, 2017. + +Michael M Bronstein, Joan Bruna, Yann LeCun, Arthur Szlam, and Pierre Vandergheynst. Geometric deep learning: going beyond euclidean data. IEEE Signal Processing Magazine, 34(4):18–42, 2017. + +T-H Hubert Chan, Anand Louis, Zhihao Gavin Tang, and Chenzi Zhang. Spectral properties of hypergraph laplacian and approximation algorithms. Journal of the ACM (JACM), 65(3):1–48, 2018. + +Ding-Yun Chen, Xiao-Pei Tian, Yu-Te Shen, and Ming Ouhyoung. On visual similarity based 3d model retrieval. In Computer graphics forum, volume 22, pp. 223–232. Wiley Online Library, 2003. + +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 Proceedings of the 25th ACM SIGKDD International Conference on Knowledge Discovery & Data Mining, pp. 257–266, 2019. + +Eli Chien, Pan Li, and Olgica Milenkovic. Landing probabilities of random walks for seed-set expansion in hypergraphs. IEEE Information Theory Workshop (ITW), 2021a. + +Eli Chien, Jianhao Peng, Pan Li, and Olgica Milenkovic. Adaptive universal generalized pagerank graph neural network. In International Conference on Learning Representations, 2021b. URL https://openreview.net/forum?id $\underline { { \underline { { \mathbf { \Pi } } } } } =$ n6jl7fLxrP. + +I Chien, Chung-Yi Lin, and I-Hsiang Wang. Community detection in hypergraphs: Optimal statistical limit and efficient algorithms. In International Conference on Artificial Intelligence and Statistics, pp. 871–879. PMLR, 2018. + +I Eli Chien, Chung-Yi Lin, and I-Hsiang Wang. On the minimax misclassification ratio of hypergraph community detection. IEEE Transactions on Information Theory, 65(12):8095–8118, 2019a. + +I Eli Chien, Huozhi Zhou, and Pan Li. Hs2: Active learning over hypergraphs with pointwise and pairwise queries. In The 22nd International Conference on Artificial Intelligence and Statistics, pp. 2466–2475. PMLR, 2019b. + +Philip S Chodrow, Nate Veldt, and Austin R Benson. Hypergraph clustering: from blockmodels to modularity. arXiv preprint arXiv:2101.09611, 2021. + +Yash Deshpande, Subhabrata Sen, Andrea Montanari, and Elchanan Mossel. Contextual stochastic block models. Advances in Neural Information Processing Systems 31 (NIPS 2018), 2018. + +Kaize Ding, Jianling Wang, Jundong Li, Dingcheng Li, and Huan Liu. Be more with less: Hypergraph attention networks for inductive text classification. arXiv preprint arXiv:2011.00387, 2020. + +Yihe Dong, Will Sawin, and Yoshua Bengio. Hnhn: Hypergraph networks with hyperedge neurons. arXiv preprint arXiv:2006.12278, 2020. + +Dheeru Dua and Casey Graff. UCI machine learning repository, 2017. URL http://archive. ics.uci.edu/ml. + +Yifan Feng, Zizhao Zhang, Xibin Zhao, Rongrong Ji, and Yue Gao. Gvcnn: Group-view convolutional neural networks for 3d shape recognition. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 264–272, 2018. + +Yifan Feng, Haoxuan You, Zizhao Zhang, Rongrong Ji, and Yue Gao. Hypergraph neural networks. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 33, pp. 3558–3565, 2019. + +Matthias Fey and Jan E. Lenssen. Fast graph representation learning with PyTorch Geometric. In ICLR Workshop on Representation Learning on Graphs and Manifolds, 2019. + +Marta Garnelo, Dan Rosenbaum, Christopher Maddison, Tiago Ramalho, David Saxton, Murray Shanahan, Yee Whye Teh, Danilo Rezende, and SM Ali Eslami. Conditional neural processes. In International Conference on Machine Learning, pp. 1704–1713. PMLR, 2018. + +Antoine Gautier, Francesco Tudisco, and Matthias Hein. A unifying perron–frobenius theorem for nonnegative tensors via multihomogeneous maps. SIAM Journal on Matrix Analysis and Applications, 40(3):1206–1231, 2019. + +Debarghya Ghoshdastidar and Ambedkar Dukkipati. A provable generalized tensor spectral method for uniform hypergraph partitioning. In International Conference on Machine Learning, pp. 400– 409. PMLR, 2015. + +Justin Gilmer, Samuel S Schoenholz, Patrick F Riley, Oriol Vinyals, and George E Dahl. Neural message passing for quantum chemistry. In International Conference on Machine Learning, pp. 1263–1272. PMLR, 2017. + +David F Gleich, Lek-Heng Lim, and Yongyang Yu. Multilinear pagerank. SIAM Journal on Matrix Analysis and Applications, 36(4):1507–1541, 2015. + +William L Hamilton, Rex Ying, and Jure Leskovec. Inductive representation learning on large graphs. In Proceedings of the 31st International Conference on Neural Information Processing Systems, pp. 1025–1035, 2017. + +Jun He and Ting-Zhu Huang. Upper bound for the largest z-eigenvalue of positive tensors. Applied Mathematics Letters, 38:110–114, 2014. + +Matthias Hein, Simon Setzer, Leonardo Jost, and Syama Sundar Rangapuram. The total variation on hypergraphs-learning on hypergraphs revisited. In Proceedings of the 26th International Conference on Neural Information Processing Systems-Volume 2, pp. 2427–2435, 2013. + +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. In H. Larochelle, M. Ranzato, R. Hadsell, M. F. Balcan, and H. Lin (eds.), Advances in Neural Information Processing Systems, volume 33, pp. 22118–22133. Curran Associates, Inc., 2020a. URL https://proceedings.neurips.cc/paper/2020/file/ fb60d411a5c5b72b2e7d3527cfc84fd0-Paper.pdf. + +Ziniu Hu, Yuxiao Dong, Kuansan Wang, and Yizhou Sun. Heterogeneous graph transformer. In Proceedings of The Web Conference 2020, pp. 2704–2710, 2020b. + +Jing Huang and Jie Yang. Unignn: a unified framework for graph and hypergraph neural networks. arXiv preprint arXiv:2105.00956, 2021. + +Glen Jeh and Jennifer Widom. Scaling personalized web search. In Proceedings of the 12th international conference on World Wide Web, pp. 271–279, 2003. + +Junteng Jia and Austion R Benson. Residual correlation in graph neural network regression. In Proceedings of the 26th ACM SIGKDD International Conference on Knowledge Discovery & Data Mining, pp. 588–598, 2020. + +Jaehyeong Jo, Jinheon Baek, Seul Lee, Dongki Kim, Minki Kang, and Sung Ju Hwang. Edge representation learning with hypergraphs. Advances in Neural Information Processing Systems, 34, 2021. + +Cliff Joslyn and Kathleen Nowak. Ubergraphs: A definition of a recursive hypergraph structure. arXiv preprint arXiv:1704.05547, 2017. + +Thomas N. Kipf and Max Welling. Semi-supervised classification with graph convolutional networks. In International Conference on Learning Representations (ICLR), 2017. + +Johannes Klicpera, Aleksandar Bojchevski, and Stephan Gunnemann. Predict then propagate: ¨ Graph neural networks meet personalized pagerank. In International Conference on Learning Representations, 2019. URL https://openreview.net/forum?id ${ . } =$ H1gL-2A9Ym. + +Juho Lee, Yoonho Lee, Jungtaek Kim, Adam Kosiorek, Seungjin Choi, and Yee Whye Teh. Set transformer: A framework for attention-based permutation-invariant neural networks. In International Conference on Machine Learning, pp. 3744–3753. PMLR, 2019. + +Guoyin Li, Liqun Qi, and Gaohang Yu. The z-eigenvalues of a symmetric tensor and its application to spectral hypergraph theory. Numerical Linear Algebra with Applications, 20(6):1001–1029, 2013. + +Pan Li and Olgica Milenkovic. Inhomogeneous hypergraph clustering with applications. Advances in Neural Information Processing Systems, 2017:2309–2319, 2017. + +Pan Li and Olgica Milenkovic. Submodular hypergraphs: p-laplacians, cheeger inequalities and spectral clustering. In International Conference on Machine Learning, pp. 3014–3023. PMLR, 2018. + +Pan Li, Hoang Dau, Gregory Puleo, and Olgica Milenkovic. Motif clustering and overlapping clustering for social network analysis. In IEEE INFOCOM 2017-IEEE Conference on Computer Communications, pp. 1–9. IEEE, 2017. + +Pan Li, Gregory J Puleo, and Olgica Milenkovic. Motif and hypergraph correlation clustering. IEEE Transactions on Information Theory, 66(5):3065–3078, 2019. + +Pan Li, Yanbang Wang, Hongwei Wang, and Jure Leskovec. Distance encoding: Design provably more powerful neural networks for graph representation learning. In H. Larochelle, M. Ranzato, R. Hadsell, M. F. Balcan, and H. Lin (eds.), Advances in Neural Information Processing Systems, volume 33, pp. 4465–4478. Curran Associates, Inc., 2020. URL https://proceedings.neurips.cc/paper/2020/file/ 2f73168bf3656f697507752ec592c437-Paper.pdf. + +Yujia Li, Daniel Tarlow, Marc Brockschmidt, and Richard Zemel. Gated graph sequence neural networks. arXiv preprint arXiv:1511.05493, 2015. + +Derek Lim, Xiuyu Li, Felix Hohne, and Ser-Nam Lim. New benchmarks for learning on nonhomophilous graphs. arXiv preprint arXiv:2104.01404, 2021. + +Lek-Heng Lim. Singular values and eigenvalues of tensors: a variational approach. In 1st IEEE International Workshop on Computational Advances in Multi-Sensor Adaptive Processing, 2005., pp. 129–132. IEEE, 2005. + +David Lopez-Paz, Robert Nishihara, Soumith Chintala, Bernhard Scholkopf, and Leon Bottou. Dis- ´ covering causal signals in images. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 6979–6987, 2017. + +Linyuan Lu and Tao Zhou. Link prediction in complex networks: A survey. ¨ Physica A: statistical mechanics and its applications, 390(6):1150–1170, 2011. + +Jiaqi Ma, Bo Chang, Xuefei Zhang, and Qiaozhu Mei. CopulaGNN: Towards integrating representational and correlational roles of graphs in graph neural networks. In International Conference on Learning Representations, 2021. URL https://openreview.net/forum?id $=$ XI-OJ5yyse. + +Ryan L. Murphy, Balasubramaniam Srinivasan, Vinayak Rao, and Bruno Ribeiro. Janossy pooling: Learning deep permutation-invariant functions for variable-size inputs. In International Conference on Learning Representations, 2019. URL https://openreview.net/forum?id $\underline { { \underline { { \mathbf { \Pi } } } } } =$ BJluy2RcFm. + +Lawrence Page, Sergey Brin, Rajeev Motwani, and Terry Winograd. The pagerank citation ranking: Bringing order to the web. Technical report, Stanford InfoLab, 1999. + +Kelly J Pearson and Tan Zhang. On spectral hypergraph theory of the adjacency tensor. Graphs and Combinatorics, 30(5):1233–1248, 2014. + +Charles R Qi, Hao Su, Kaichun Mo, and Leonidas J Guibas. Pointnet: Deep learning on point sets for 3d classification and segmentation. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 652–660, 2017. + +Liqun Qi and Ziyan Luo. Tensor analysis: spectral theory and special tensors. SIAM, 2017. + +Yu Rong, Wenbing Huang, Tingyang Xu, and Junzhou Huang. Dropedge: Towards deep graph convolutional networks on node classification. In International Conference on Learning Representations, 2019. + +Nino Shervashidze, Pascal Schweitzer, Erik Jan Van Leeuwen, Kurt Mehlhorn, and Karsten M Borgwardt. Weisfeiler-lehman graph kernels. Journal of Machine Learning Research, 12(9), 2011. + +Jake Snell, Kevin Swersky, and Richard Zemel. Prototypical networks for few-shot learning. In Proceedings of the 31st International Conference on Neural Information Processing Systems, pp. 4080–4090, 2017. + +Hang Su, Subhransu Maji, Evangelos Kalogerakis, and Erik Learned-Miller. Multi-view convolutional neural networks for 3d shape recognition. In Proceedings of the IEEE international conference on computer vision, pp. 945–953, 2015. + +Francesco Tudisco and Desmond J Higham. Node and edge nonlinear eigenvector centrality for hypergraphs. Communications Physics, 4(1):1–10, 2021. + +Francesco Tudisco, Austin R Benson, and Konstantin Prokopchik. Nonlinear higher-order label spreading. arXiv preprint arXiv:2006.04762, 2020. + +Francesco Tudisco, Konstantin Prokopchik, and Austin R Benson. A nonlinear diffusion method for semi-supervised learning on hypergraphs. arXiv preprint arXiv:2103.14867, 2021. + +Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Łukasz Kaiser, and Illia Polosukhin. Attention is all you need. Advances in Neural Information Processing Systems, 30:5998–6008, 2017. + +Petar Velickovic, William Fedus, William L Hamilton, Pietro Lio, Yoshua Bengio, and R Devon \` Hjelm. Deep graph infomax. In ICLR (Poster), 2019. + +Petar Velickovi ˇ c, Guillem Cucurull, Arantxa Casanova, Adriana Romero, Pietro Li ´ o, and Yoshua \` Bengio. Graph attention networks. In International Conference on Learning Representations, 2018. URL https://openreview.net/forum?id $=$ rJXMpikCZ. + +Edward Wagstaff, Fabian Fuchs, Martin Engelcke, Ingmar Posner, and Michael A Osborne. On the limitations of representing functions on sets. In International Conference on Machine Learning, pp. 6487–6494. PMLR, 2019. + +Jianling Wang, Kaize Ding, Ziwei Zhu, and James Caverlee. Session-based recommendation with hypergraph attention networks. In Proceedings of the 2021 SIAM International Conference on Data Mining (SDM), pp. 82–90. SIAM, 2021. + +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, 2019a. + +Xiao Wang, Houye Ji, Chuan Shi, Bai Wang, Yanfang Ye, Peng Cui, and Philip S Yu. Heterogeneous graph attention network. In The World Wide Web Conference, pp. 2022–2032, 2019b. + +Felix Wu, Amauri Souza, Tianyi Zhang, Christopher Fifty, Tao Yu, and Kilian Weinberger. Simplifying graph convolutional networks. In International conference on machine learning, pp. 6861–6871. PMLR, 2019. + +Zhirong Wu, Shuran Song, Aditya Khosla, Fisher Yu, Linguang Zhang, Xiaoou Tang, and Jianxiong Xiao. 3d shapenets: A deep representation for volumetric shapes. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 1912–1920, 2015. + +Keyulu Xu, Chengtao Li, Yonglong Tian, Tomohiro Sonobe, Ken-ichi Kawarabayashi, and Stefanie Jegelka. Representation learning on graphs with jumping knowledge networks. In International Conference on Machine Learning, pp. 5453–5462. PMLR, 2018. + +Keyulu Xu, Weihua Hu, Jure Leskovec, and Stefanie Jegelka. How powerful are graph neural networks? In International Conference on Learning Representations, 2019. URL https: //openreview.net/forum?id $=$ ryGs6iA5Km. + +Hansheng Xue, Luwei Yang, Vaibhav Rajan, Wen Jiang, Yi Wei, and Yu Lin. Multiplex bipartite network embedding using dual hypergraph convolutional networks. In Proceedings of the Web Conference 2021, pp. 1649–1660, 2021. + +Naganand Yadati. Neural message passing for multi-relational ordered and recursive hypergraphs. Advances in Neural Information Processing Systems, 33, 2020. + +Naganand Yadati, Madhav Nimishakavi, Prateek Yadav, Vikram Nitin, Anand Louis, and Partha Talukdar. Hypergcn: A new method for training graph convolutional networks on hypergraphs. In H. Wallach, H. Larochelle, A. Beygelzimer, F. d Alche-Buc, E. Fox, and R. Gar- ´ nett (eds.), Advances in Neural Information Processing Systems, volume 32. Curran Associates, Inc., 2019. URL https://proceedings.neurips.cc/paper/2019/file/ 1efa39bcaec6f3900149160693694536-Paper.pdf. + +Chaoqi Yang, Ruijie Wang, Shuochao Yao, and Tarek Abdelzaher. Hypergraph learning with line expansion. arXiv preprint arXiv:2005.04843, 2020. + +Yelp. Yelp business dataset. URL https://www.yelp.com/dataset. + +Seongjun Yun, Minbyul Jeong, Raehyun Kim, Jaewoo Kang, and Hyunwoo J Kim. Graph transformer networks. 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/ 9d63484abb477c97640154d40595a3bb-Paper.pdf. + +Manzil Zaheer, Satwik Kottur, Siamak Ravanbhakhsh, Barnabas P ´ oczos, Ruslan Salakhutdinov, and ´ Alexander J Smola. Deep sets. In Proceedings of the 31st International Conference on Neural Information Processing Systems, pp. 3394–3404, 2017. + +Hanqing Zeng, Hongkuan Zhou, Ajitesh Srivastava, Rajgopal Kannan, and Viktor Prasanna. Graphsaint: Graph sampling based inductive learning method. In International Conference on Learning Representations, 2019. + +Ruochi Zhang, Yuesong Zou, and Jian Ma. Hyper-sagnn: a self-attention based graph neural network for hypergraphs. arXiv preprint arXiv:1911.02613, 2019. + +Lingxiao Zhao and Leman Akoglu. Pairnorm: Tackling oversmoothing in gnns. In International Conference on Learning Representations, 2019. + +Dengyong Zhou, Jiayuan Huang, and Bernhard Scholkopf. Learning with hypergraphs: Clustering, ¨ classification, and embedding. Advances in neural information processing systems, 19:1601– 1608, 2006. + +Xiaojin Jerry Zhu. Semi-supervised learning literature survey. Technical Report, 2005. + +# APPENDIX + +# A ADDITIONAL RELATED WORKS + +We further discuss related works for completeness. + +Graph neural networks on graphs. GNNs have received significant attention in the past, often under the umbrella of Geometric Deep Learning (Bronstein et al., 2017). Many successful architectures have been proposed for various tasks on graphs, including GCN (Kipf & Welling, 2017), GAT (Vaswani et al., 2017), GraphSAGE (Hamilton et al., 2017), GIN (Xu et al., 2019) and many others (Klicpera et al., 2019; Wu et al., 2019; Velickovic et al., 2019; Li et al., 2020; Xu et al., 2018; Chien et al., 2021b). There have also been some recent attempts to use Transformers in GNNs (Baek et al., 2021; Yun et al., 2019; Hu et al., 2020b). Nevertheless, all these methods only apply to graphs and not to hypergraphs. Although CE can be used in all these case, this is clearly not an optimal strategy due to the previously mentioned distortion issues. There are also many techniques that can improve GNNs in various directions. For example, PairNorm (Zhao & Akoglu, 2019) and DropEdge (Rong et al., 2019) allow one to build deeper GNNs. ClusterGCN (Chiang et al., 2019) and GraphSAINT (Zeng et al., 2019), on the other hand, may be used to significantly scale up GNNs. Residual correlation (Jia & Benson, 2020) and CopulaGNN (Ma et al., 2021) have been shown to improve GNNs on graph regression problems. These works highlight new directions and limitations of not only our method, but also hypergraph neural networks in general. Nevertheless, we believe that AllSet layers can be adapted to resolve these issues using similar ideas as those proposed for graph layers. + +Additional contributions to learning on hypergraphs. After the submission of our manuscript, we were made aware of some loosely related lines of works. Ding et al. (2020) and Wang et al. (2021) proposed hypergraph attention networks based on the $\nu \mathcal { E }$ and $\mathcal { E } \mathcal { V }$ formulation, specialized for certain downstream tasks. However, these approaches fall under our AllSet framework and have smaller expressiveness compared to AllSet. The work Jo et al. (2021) proposes to learn edge representations in a graph via message passing on its dual hypergraph. Although the authors used GMT (Baek et al., 2021) as their node pooling module, they do not explore the idea of treating $f _ { \mathcal { V } \to \mathcal { E } }$ and $f _ { \mathcal { E } \to \mathcal { V } }$ as multiset functions for hypergraph neural networks as AllSet does. It is also possible to define propagation schemes based on other tensor eigenproblems, such as $_ \mathrm { H }$ eigenproblems (Qi & Luo, 2017). Defining propagation rules based on H eigenproblems can lead to imaginary features which is problematic: A more detailed discussion regarding this direction is available in the Appendix H. + +# B CONCLUSIONS + +We proposed AllSet, a novel hypergraph neural network paradigm that represents a highly general framework for hypergraph neural networks. We implemented hypergraph neural network layers as compositions of two multiset functions that can be efficiently learned for each task and each dataset. Furthermore, for the first time, we integrated Deep Set and Set Transformer methods within hypergraph neural networks for the purpose of learning the described multiset functions. Our theoretical analysis demonstrated that most of the previous hypergraph neural networks are strictly less expressive then our proposed AllSet framework. We conducted the most extensive experiments to date involving ten known benchmarking datasets and three newly curated datasets that represent significant challenges for hypergraph node classification. The results showed that our method has the unique ability to either match or outperform all other baselines, including the state-of-the-art hypergraph neural networks UniGNN (Huang & Yang, 2021). Remarkably, our baseline also included HAN (Wang et al., 2019b), the heterogeneous hypergraph neural networks, via star expansion as the new comparative method in the hypergraph neural network literature for the first time. Our results show that leveraging powerful multiset function learners in our AllSet framework is indeed helpful for hypergraph learning. As a promising future direction, more advanced multiset function learners such as Janossy pooling (Murphy et al., 2019) can be used in our AllSet framework and potentially further improve the performance. We left this topic in future works. + +# C PROOF OF THEOREM 3.3 + +First, we show that one can recover CEpropH (1) from AllSet (5). By choosing $f _ { \mathcal { V } \to \mathcal { E } }$ and $f _ { \varepsilon \to \nu }$ to be the sums over appropriate input multisets and by ignoring the second input, we obtain + +$$ +\begin{array} { r l } & { \mathbf { Z } _ { e , : } ^ { ( t + 1 ) } = f \nu _ { \mathcal { E } } \big ( V _ { e , \mathbf { X } ^ { ( t ) } } ; \mathbf { Z } _ { e , : } ^ { ( t ) } \big ) = \displaystyle \sum _ { x \in V _ { e , \mathbf { X } ^ { ( t ) } } } x = \sum _ { u \in e } \mathbf { X } _ { u , : } ^ { ( t ) } , } \\ & { \mathbf { X } _ { v , : } ^ { ( t + 1 ) } = f \varepsilon _ { \mathcal { V } } \big ( E _ { v , \mathbf { Z } ^ { ( t + 1 ) } } ; \mathbf { X } _ { v , : } ^ { ( t ) } \big ) = \displaystyle \sum _ { x \in E _ { v , \mathbf { Z } ^ { ( t + 1 ) } } } x = \sum _ { e : v \in e } \mathbf { Z } _ { e , : } ^ { ( t + 1 ) } . } \end{array} +$$ + +Combining these two equations gives + +$$ +\mathbf { X } _ { v , : } ^ { ( t + 1 ) } = \sum _ { e : v \in e } \mathbf { Z } _ { e , : } ^ { ( t + 1 ) } = \sum _ { e : v \in e } \sum _ { u \in e } \mathbf { X } _ { u , : } ^ { ( t ) } , +$$ + +which matches the update equations of CEpropH (1). + +Next, we prove that one can recover CEpropA (1) from AllSet (6). We once again choose $f _ { \mathcal { V } \to \mathcal { E } }$ and $f _ { \mathcal { E } \mathcal { V } }$ to be the sums over appropriate input multisets and ignore the second input term. This results in the following update equations: + +$$ +\begin{array} { l } { { \displaystyle { \bf Z } _ { e , : } ^ { ( t + 1 ) , v } = f \nu _ { \ell } ( V _ { e \setminus v , { \bf X } ^ { ( t ) } } ; { \bf Z } _ { e , : } ^ { ( t ) , v } ) = \sum _ { x \in V _ { e \setminus v , { \bf X } } ( t ) } x = \sum _ { u \in e \setminus v } { \bf X } _ { u , : } ^ { ( t ) } , \quad } } \\ { { \displaystyle { \bf X } _ { v , : } ^ { ( t + 1 ) } = f \varepsilon _ { \mathcal { V } } ( E _ { v , { \bf Z } ^ { ( t + 1 ) , v } } ; { \bf X } _ { v , : } ^ { ( t ) } ) = \sum _ { x \in E _ { v , { \bf Z } ^ { ( t + 1 ) , v } } } x = \sum _ { e : v \in e } { \bf Z } _ { e , : } ^ { ( t + 1 ) , v } } } \end{array} +$$ + +Combining the two equations we obtain + +$$ +\mathbf { X } _ { v , : } ^ { ( t + 1 ) } = \sum _ { e : v \in e } \mathbf { Z } _ { e , : } ^ { ( t + 1 ) , v } = \sum _ { e : v \in e } \sum _ { u \in e \backslash v } \mathbf { X } _ { u , : } ^ { ( t ) } , +$$ + +which represents the update rule of CEpropA from (1). + +In the last step, we prove that one can recover Zprop (4) from AllSet (6). By choosing $f _ { \mathcal { V } \to \mathcal { E } }$ and $f _ { \mathcal { E } \mathcal { V } }$ to be the product and sum over appropriate input multisets, respectively, and by ignore the second input, we have: + +$$ +\begin{array} { l } { { \displaystyle { \bf Z } _ { e , : } ^ { ( t + 1 ) , v } = f \gamma _ { \ell } ( V _ { e \setminus v , { \bf X } ^ { ( t ) } } ; { \bf Z } _ { e , : } ^ { ( t ) , v } ) = \prod _ { x \in V _ { e \setminus v , { \bf X } ^ { ( t ) } } } x = \prod _ { u \in e \setminus v } { \bf X } _ { u , : } ^ { ( t ) } } , } \\ { { \displaystyle { \bf X } _ { v , : } ^ { ( t + 1 ) } = f \varepsilon _ { \mathcal { V } } ( E _ { v , { \bf Z } ^ { ( t + 1 ) , v } } ; { \bf X } _ { v , : } ^ { ( t ) } ) = \sum _ { x \in E _ { v , { \bf Z } ^ { ( t + 1 ) , v } } } x = \sum _ { e \colon v \in e } { \bf Z } _ { e , : } ^ { ( t + 1 ) , v } } . } \end{array} +$$ + +Combining these two equations we arrive at + +$$ +\mathbf { X } _ { v , : } ^ { ( t + 1 ) } = \sum _ { e : v \in e } \mathbf { Z } _ { e , : } ^ { ( t + 1 ) , v } = \sum _ { e : v \in e } \prod _ { u \in e \backslash v } \mathbf { X } _ { u , : } ^ { ( t ) } , +$$ + +which matches Zprop from (4). This completes the proof. + +# D PROOF OF THEOREM 3.4 + +First we prove that the hypergraph neural network layer of HGNN (2) is a special instance of AllSet (5). By choosing $f _ { \mathcal { V } \to \mathcal { E } }$ and $f _ { \mathcal { E } \mathcal { V } }$ to be the weighted sum over appropriate input multisets, where the weights are chosen according to the node degree, edge degree, and edge weights, and by ignore the second input, we have: + +$$ +\begin{array} { r l } & { \displaystyle \mathbf { Z } _ { e , : } ^ { ( t + 1 ) } = f _ { \mathcal { V } \to \varepsilon } ( V _ { e , \mathbf { X } ^ { ( t ) } } ; \mathbf { Z } _ { e , : } ^ { ( t ) } ) = \sum _ { u \in e } \frac { \mathbf { X } _ { u , : } ^ { ( t ) } } { \sqrt { d _ { u } } } , } \\ & { \displaystyle \mathbf { X } _ { v , : } ^ { ( t + 1 ) } = f _ { \varepsilon \to \nu } ( E _ { v , \mathbf { Z } ^ { ( t + 1 ) } } ; \mathbf { X } _ { v , : } ^ { ( t ) } ) = \sigma \left( \frac { 1 } { \sqrt { d _ { v } } } \sum _ { e : v \in e } \frac { w _ { e } \mathbf { Z } _ { e , : } ^ { ( t + 1 ) } \Theta ^ { ( t ) } } { \vert e \vert } + \mathbf { b } ^ { ( t ) } \right) . } \end{array} +$$ + +Since $f _ { \mathcal { V } \to \mathcal { E } }$ and $f _ { \mathcal { E } \to \mathcal { V } }$ both use the hypergraph $\mathcal { G }$ as their input, the functions can use the node degrees, edge degrees and edge weights as their arguments. Also, it is not hard to see that our choices for $f _ { \mathcal { V } \to \mathcal { E } }$ (18) and $f _ { \mathcal { E } \mathcal { V } }$ (19) are permutation invariant in $V _ { e , \mathbf { X } ^ { ( t ) } }$ and $E _ { v , \mathbf { Z } ^ { ( t + 1 ) } }$ , respectively. Plugging (18) into (19) leads to: + +$$ +\mathbf { X } _ { v , : } ^ { ( t + 1 ) } = \sigma \left( \frac { 1 } { \sqrt { d _ { v } } } \sum _ { e : v \in e } \frac { w _ { e } } { | e | } \sum _ { u \in e } \frac { \mathbf { X } _ { u , : } ^ { ( t ) } } { \sqrt { d _ { u } } } \Theta ^ { ( t ) } + \mathbf { b } ^ { ( t ) } \right) , +$$ + +which represents the HGNN layer (2). + +For the HCHA layer, we have a node-wise formulation that reads as follows: + +$$ +\mathbf { X } _ { v , : } ^ { ( t + 1 ) } = \sigma \left( \left[ \frac { 1 } { d _ { v } } \sum _ { e : v \in e } \frac { w _ { e } \alpha _ { v e } ^ { ( t ) } } { \left| e \right| } \sum _ { u : u \in e } \alpha _ { u e } ^ { ( t ) } \mathbf { X } _ { u , : } ^ { ( t ) } \right] \boldsymbol { \Theta } ^ { ( t ) } + \mathbf { b } ^ { ( t ) } \right) , +$$ + +where the attention weight $\alpha _ { u e } ^ { ( t ) }$ depends on the node features $\mathbf { X } ^ { ( t ) }$ and the feature of hyperedge $e$ Here, $\sigma ( \cdot )$ is a nonlinear activation function such as LeakyReLU and eLU. An analysis similar to that described for HGNN can be used in this case as well. The only difference is in the choice of the attention weights $\alpha _ { u e }$ and $\alpha _ { v e }$ . The definition of attention weights for HCHA is presented below. + +$$ +\alpha _ { u e } ^ { ( t ) } = \frac { \exp ( \sigma ( \mathbf { a } ^ { T } [ \mathbf { X } _ { u , : } ^ { ( t ) } \parallel \mathbf { Z } _ { e , : } ^ { ( t ) } ] ) ) } { \sum _ { e : u \in e } \exp ( \sigma ( \mathbf { a } ^ { T } [ \mathbf { X } _ { u , : } ^ { ( t ) } \parallel \mathbf { Z } _ { e , : } ^ { ( t ) } ] ) ) } . +$$ + +Clearly, the attention function in (22) has $V _ { e , \mathbf { X } ^ { ( t ) } }$ and $\mathbf { Z } _ { e , : } ^ { ( t ) }$ as its arguments. Furthermore, we can choose $f _ { \mathcal { V } \to \mathcal { E } }$ and $f _ { \mathcal { E } \mathcal { V } }$ as: + +$$ +\begin{array} { r l } & { \mathbf { Z } _ { e , : } ^ { ( t + 1 ) } = f _ { \mathcal { V } \mathcal { E } } ( V _ { e , \mathbf { X } ^ { ( t ) } } ; \mathbf { Z } _ { e , : } ^ { ( t ) } ) = \displaystyle \sum _ { u \in e } \alpha _ { u e } ^ { ( t ) } \mathbf { X } _ { u , : } ^ { ( t ) } , } \\ & { \mathbf { X } _ { v , : } ^ { ( t + 1 ) } = f _ { \mathcal { E } \mathcal { V } } ( E _ { v , \mathbf { Z } ^ { ( t + 1 ) } } ; \mathbf { X } _ { v , : } ^ { ( t ) } ) = \sigma ( \frac { 1 } { \sqrt { d _ { v } } } \displaystyle \sum _ { e : v \in e } \frac { w _ { e } \alpha _ { v e } ^ { ( t ) } \mathbf { Z } _ { e , : } ^ { ( t + 1 ) } \Theta ^ { ( t ) } } { \vert e \vert } + \mathbf { b } ^ { ( t ) } ) . } \end{array} +$$ + +Note that both (23) and (24) are permutation invariant, which means that they are valid choices for $f _ { \mathcal { V } \to \mathcal { E } }$ and $f _ { \mathcal { E } \mathcal { V } }$ . Combining these two equations reproduces the HCHA layer of (21). + +For the HyperGCN layer, ignoring the degree normalization, one can use the following formulation: + +$$ +\mathbf { X } _ { v , : } ^ { ( t + 1 ) } = \sigma \left( \left[ \sum _ { e : v \in e } \sum _ { u : u \in e } w _ { u v , e } ^ { ( t ) } \mathbf { X } _ { u , : } ^ { ( t ) } \right] \Theta ^ { ( t ) } + \mathbf { b } ^ { ( t ) } \right) . +$$ + +Here, the weight $w _ { u v , e } ^ { ( t ) }$ depends on all node features within the hyperedge $\{ \mathbf { X } _ { u , : } ^ { ( t ) } : u \in e \}$ , and $\sigma ( \cdot )$ is a nonlinear activation function (for example, ReLU). The same analysis as presented for the previous cases may be used in this case as well: The only difference lies in the choice of the weights $w _ { u v , e } ^ { ( t ) }$ . According to the original HyperGCN paper (Yadati et al., 2019), these weights are defined as + +$$ +\begin{array} { r l } & { w _ { u v , e } ^ { ( t ) } = \{ \frac { 1 } { 2 | e | - 3 } \quad \mathrm { i f } u \in \{ i _ { e } , j _ { e } \} \mathrm { o r } v \in \{ i _ { e } , j _ { e } \} , } \\ & { \qquad \mathrm { o t h e r w i s e } . } \\ & { \mathrm { w h e r e } ( i _ { e } , j _ { e } ) = \arg \operatorname* { m a x } _ { u , v \in e } \lVert \bigl ( \mathbf { X } _ { u , : } ^ { ( t ) } - \mathbf { X } _ { v , : } ^ { ( t ) } \bigr ) \Theta ^ { ( t ) } \rVert . } \end{array} +$$ + +Again, it is straightforward to see that $w _ { u v , e } ^ { ( t ) }$ is a function of $V _ { e \backslash v , \mathbf { X } ^ { ( t ) } }$ and $\mathbf { X } _ { v , : } ^ { ( t ) }$ . Also, it is permutation invariant with respect to $V _ { e \backslash v , \mathbf { X } ^ { ( t ) } }$ . Hence, we can choose $f _ { \mathcal { V } \to \mathcal { E } }$ and $f _ { \mathcal { E } \to \mathcal { V } }$ as + +$$ +\begin{array} { r l } & { \mathbf { Z } _ { e , : } ^ { ( t + 1 ) , v } = f \gamma _ { \mathcal { E } } ( V _ { e \setminus v , \mathbf { X } ^ { ( t ) } } ; \mathbf { Z } _ { e , : } ^ { ( t ) , v } , \mathbf { X } _ { v , : } ^ { ( t ) } ) = \displaystyle \sum _ { u \in e \setminus v } w _ { u v , e } ^ { ( t ) } \mathbf { X } _ { u ; : } ^ { ( t ) } , } \\ & { \mathbf { X } _ { v , : } ^ { ( t + 1 ) } = f _ { \mathcal { E } \mathcal { V } } ( E _ { v , \mathbf { Z } ^ { ( t + 1 ) , v } } ; \mathbf { X } _ { v , : } ^ { ( t ) } ) = \sigma ( \displaystyle \sum _ { e : v \in e } \mathbf { Z } _ { e , : } ^ { ( t + 1 ) , v } \Theta ^ { ( t ) } + \mathbf { b } ^ { ( t ) } ) . } \end{array} +$$ + +Combining the two equations leads to the HyperGCN layer from (25). + +Next, we show that HNHN layer introduced in Dong et al. (2020) is a special case of AllSet (5). The definition of HNHN layer is as follows + +$$ +\begin{array} { r l } & { \mathbf { Z } _ { e , : } ^ { ( t + 1 ) } = \sigma \left( \left[ \cfrac { 1 } { d _ { e , l , \beta } } \sum _ { u \in e } d _ { u , r , \beta } \mathbf { X } _ { u , : } ^ { ( t ) } \right] \boldsymbol { \Theta } _ { \varepsilon } ^ { ( t ) } + \mathbf { b } _ { \varepsilon } ^ { ( t ) } \right) , } \\ & { \mathbf { X } _ { v , : } ^ { ( t + 1 ) } = \sigma \left( \left[ \cfrac { 1 } { d _ { v , l , \alpha } } \sum _ { e : v \in e } d _ { e , r , \alpha } \mathbf { Z } _ { e , : } ^ { ( t + 1 ) } \right] \boldsymbol { \Theta } _ { \gamma } ^ { ( t ) } + \mathbf { b } _ { \gamma } ^ { ( t ) } \right) , } \\ & { \mathrm { w h e r e ~ } d _ { e , l , \beta } = \sum _ { u \in e } \left| d _ { u } \right| ^ { \beta } , \ d _ { u , r , \beta } = d _ { u } ^ { \beta } ; \ d _ { v , l , \beta } = \sum _ { e : v \in e } \left| d _ { v } \right| ^ { \alpha } , \ d _ { v , r , \alpha } = d _ { v } ^ { \alpha } . } \end{array} +$$ + +Note that $\alpha$ and $\beta$ are two hyperparameters that can be tuned in HNHN. As before, $\sigma ( \cdot )$ is a nonlinear activation function (e.g., ReLU). It is obvious that we can choose $f _ { \mathcal { V } \to \mathcal { E } }$ and $f _ { \mathcal { E } \to \mathcal { V } }$ according to (30) and (31), respectively. This is due to the fact that these expressions only involves degree normalizations and linear transformations. + +Finally, we show that the HyperSAGE layer from Arya et al. (2020) is a special case of AllSet (5). The HyperSAGE layer update rules are as follows: + +$$ +\begin{array} { r l } & { \mathbf { Z } _ { e , : } ^ { ( t + 1 ) } = \left( \displaystyle \frac { 1 } { | e | } \sum _ { u \in e } ( \mathbf { X } _ { u , : } ^ { ( t ) } ) ^ { p } \right) ^ { 1 / p } , } \\ & { \mathbf { X } _ { v , : } ^ { ( t + 1 ) , \star } = \left( \displaystyle \frac { 1 } { | \{ e : v \in e \} | } \sum _ { e : v \in e } ( \mathbf { Z } _ { e , : } ^ { ( t ) } ) ^ { p } \right) ^ { 1 / p } + \mathbf { X } _ { v , : } ^ { ( t ) } , } \\ & { \mathbf { X } _ { v , : } ^ { ( t + 1 ) } = \sigma \left( \displaystyle \frac { \mathbf { X } _ { v , : } ^ { ( t + 1 ) , \star } } { | | \mathbf { X } _ { v , : } ^ { ( t + 1 ) , \star } | | } \Theta ^ { ( t + 1 ) } \right) . } \end{array} +$$ + +where $\sigma ( \cdot )$ is a nonlinear activation function. The update (33) can be recovered by simply choosing $f _ { \mathcal { V } \to \mathcal { E } }$ to be the $l _ { p }$ (power) mean. For the $f _ { \mathcal { E } \to \mathcal { V } }$ component, we first model $f _ { \mathcal { E } \mathcal { V } }$ as a composition of another two multiset functions. The first is the $l _ { p }$ (power) mean with respect to its first input, while the second is addition with respect to the second input. This recovers (34). The second of the two defining functions can be chosen as (35), which is also a multiset function. This procedure leads to $f _ { \mathcal { E } \to \mathcal { V } }$ . This completes the proof of the first claim pertaining to the universality of AllSet. + +To address the claim that the above described hypergrpah neural network layers have strictly smaller expressive power then AllSet, one only has to observe that these hypergraph neural network layers cannot approximate arbitrary multiset functions in either the $f _ { \mathcal { V } \to \mathcal { E } }$ or $f _ { \mathcal { E } \to \mathcal { V } }$ component. We discuss both these functions separately. + +With regards to the HGNN layer, it is clear that two linear transformations cannot model arbitrary multiset functions such as the product in Zprop (4). For the HCHA layer, we note that if all node features are identical and the hyperedge features are all-zero vectors, all the attention weights $\alpha _ { u e }$ are the same. This setting is similar to that described for the HGNN layer and thus this rule cannot model arbitrary multiset functions. For the HyperGCN layer (25), consider a 3-uniform hypergraph as its input. In this case, by definition, the weights $w _ { u v , e }$ are all equal. Again, using only linear transformations one cannot model the product operation in Zprop (4); the same argument holds even when degree normalizations are included. For the HNHN layer, note that the $\mathcal { E } \mathcal { V }$ component of (31) is just one MLP layer that follows the sum $\textstyle \sum _ { e : v \in e }$ , which cannot model arbitrary multiset functions based on the results of Deep Sets (Zaheer et al., 2017). As a final note, we point out that the HyperSAGE layer involves only one learnable matrix $\Theta$ and is hence also a linear transformation, which cannot model arbitrary multiset functions. + +This completes the proof. + +# E PROOF OF THEOREM 3.5 + +The propagation rule of MPNN reads as follows: + +$$ +\mathbf { m } _ { v ; \cdot } ^ { ( t + 1 ) } = \sum _ { u \in N ( v ) } M _ { t } ( \mathbf { X } _ { u ; \cdot } ^ { ( t ) } , \mathbf { X } _ { v ; \cdot } ^ { ( t ) } , \mathbf { Z } _ { e ; \cdot } ^ { ( 0 ) , v } ) , \quad \mathbf { X } _ { v ; \cdot } ^ { ( t + 1 ) } = U _ { t } ( \mathbf { X } _ { v ; \cdot } ^ { ( t ) } , \mathbf { m } _ { v ; \cdot } ^ { ( t + 1 ) } ) . +$$ + +Here, $\mathbf { m }$ denotes the message obtained by aggregating messages from the neighborhood of the node $v$ , while $M _ { t }$ and $U _ { t }$ are certain functions selected at the $t$ -th step of propagation. To recover MPNN from AllSet (6), we simply choose $f _ { \mathcal { V } \to \mathcal { E } }$ and $f _ { \mathcal { E } \to \mathcal { V } }$ as + +$$ +\begin{array} { r l r } & { \mathbf Z _ { e , : } ^ { ( t + 1 ) , v } \triangleq f _ { \gamma \to \varepsilon } ( V _ { e \setminus v , \mathbf { X } ^ { ( t ) } } ; \mathbf Z _ { e , : } ^ { ( t ) , v } ) = f _ { \gamma \to \varepsilon } ( \{ \mathbf X _ { u , : } ^ { ( t ) } \} ; \mathbf Z _ { e , : } ^ { ( t ) , v } ) = \mathbf X _ { u , : } ^ { ( t ) } \parallel \mathbf Z _ { e , : } ^ { ( 0 ) , v } , \quad \mathrm { s . t . } \ u \in e \setminus v , } \\ & { \mathbf X _ { v , : } ^ { ( t + 1 ) } \triangleq f _ { \mathcal { E } \to \gamma } ( E _ { v , \mathbf Z ^ { ( t + 1 ) } , v } ; \mathbf X _ { v , : } ^ { ( t ) } ) = f _ { \mathcal { E } \to \gamma } ( \{ \mathbf Z _ { e , : } ^ { ( t + 1 ) , v } \} _ { e \to v \in e } ; \mathbf X _ { v , : } ^ { ( t ) } ) } \\ & { = U _ { t } \left( \mathbf X _ { v , : } ^ { ( t ) } , \displaystyle \sum _ { e : v \in e } M _ { t } ^ { \prime } ( \mathbf Z _ { e , : } ^ { ( t + 1 ) , v } , \mathbf X _ { v , : } ^ { ( t ) } ) \right) = U _ { t } \left( \mathbf X _ { v , : } ^ { ( t ) } , \displaystyle \sum _ { e : v \in e } M _ { t } ( \mathbf X _ { u , : } ^ { ( t ) } , \mathbf X _ { v , : } ^ { ( t ) } , \mathbf Z _ { e , : } ^ { ( 0 ) , v } ) \right) . \qquad ( 3 } \end{array} +$$ + +Hence, MPNN is a special case of AllSet for graph inputs. + +# F PROOF OF PROPOSITION 4.1 + +The proof is largely based on the proof of Proposition 2 of the Set Trasnformer paper (Lee et al., 2019) but is nevertheless included for completeness. We ignore all layer normalizations as in the proof of (Lee et al., 2019) and start with the following theorem. + +Theorem F.1 (Theorem 1 in Lee et al. (2019)). Functions of the form $M L P \sum ( M L P )$ are universal approximators in the space of permutation invariant functions. + +This result is based on Zaheer et al. (2017). According to Wagstaff et al. (2019), we have the constraint that the input multiset has to be finite. + +Next, we show that the simple mean operator is a special case of a multihead attention module. For simplicity, we consider the case of a single head, which corresponds to $h = 1$ , as we can always set the other heads to zero by choosing $\mathbf { M L } \mathbf { \bar { P } } ^ { V , i } ( \mathbf { S } ) = 0$ for all $i \geq 2$ . Following the proof of Lemma 3 in Lee et al. (2019), we set the learnable weight $\theta$ to be the all-zero vector and use $\omega ( \cdot ) = 1 + g ( \cdot )$ (element-wise) as an activation function such that $g ( 0 ) = 0$ . The $\mathrm { M H } _ { 1 , \omega }$ module in (8) then becomes + +$$ +\mathbf { M } \mathbf { H } _ { 1 , \omega } ( \pmb { \theta } , \mathbf { S } , \mathbf { S } ) = \mathbf { O } ^ { ( 1 ) } = \omega \left( \theta ( \mathbf { M } \mathbf { L } \mathbf { P } ^ { K , 1 } ( \mathbf { S } ) ) ^ { T } \right) \mathbf { M } \mathbf { L } \mathbf { P } ^ { V , 1 } ( \mathbf { S } ) = \sum _ { i = 1 } ^ { | S | } \mathbf { M } \mathbf { L } \mathbf { P } ^ { V , 1 } ( \mathbf { S } ) _ { i } . +$$ + +The AllSetTranformer layer (8) takes the form + +$$ +f _ { \mathcal { V } \mathcal { E } } ( S ) = \mathbf { Y } + \mathbf { M } \mathbf { L } \mathbf { P } ( \mathbf { Y } ) , \mathrm { ~ w h e r e ~ } \mathbf { Y } = \sum _ { i = 1 } ^ { | S | } \mathbf { M } \mathbf { L } \mathbf { P } ^ { V , 1 } ( \mathbf { S } ) . +$$ + +Note that $\mathbf { Y }$ is a vector. Clearly, we can choose an MLP such that ${ \mathrm { M L P } } ( \mathbf { Y } )$ equals to another $\mathbf { M L P ( Y ) }$ that results in subtracting $\mathbf { Y }$ . Thus, we have: + +$$ +f _ { \mathcal { V } \mathcal { E } } ( S ) = \mathbf { M } \mathbf { L } \mathbf { P } ( \mathbf { Y } ) = \mathbf { M } \mathbf { L } \mathbf { P } ( \sum _ { i = 1 } ^ { | S | } \mathbf { M } \mathbf { L } \mathbf { P } ^ { V , 1 } ( \mathbf { S } ) ) . +$$ + +By Theorem F.1, it is clear that $f _ { \mathcal { V } \mathcal { E } } ( S )$ is a universal approximator for permutation invariant functions. The same analysis applies to $f _ { \mathcal { E } \mathcal { V } } ( S )$ . + +# G A DISCUSSION OF LEGCN + +Line expansion (LE) is a procedure that transform a hypergraph or a graph into a homogeneous graph; a node in the LE graph represents a pair of node-hyperedge from the original hypergraph. + +Nodes in the LE graph are linked if and only if there is a nonempty intersection of their associated node-hyperedge pairs. As stated by the authors of LEGCN (Yang et al., 2020), for a fully connected $d$ -uniform hypergraph their resulting LE graph has $\Theta ( d | \mathcal { E } | )$ nodes and $\Theta ( d ^ { 2 } | \mathcal { E } | ^ { 2 } )$ edges. This expansion hence leads to very large graphs which require large memory units and have high computational complexity when coupled with GNNs such as GCN. To alleviate this drawback, the authors use random sampling techniques which unfortunately lead to an undesired information loss. In contrast, we define our AllSet layers directly on hypergraph which leads to a significantly more efficient approach. + +# H HYPERGRAPH PROPAGATION RULES BASED ON THE H EIGENPROBLEM + +As outlined in the main text, in this case we associate a $d$ -uniform hypergraph $\mathcal { G }$ with an adjacency tensor A. The $_ \mathrm { H }$ eigenproblem for A states that + +$$ +\mathbf { A } \mathbf { x } ^ { d - 1 } = \lambda \mathbf { x } ^ { [ d - 1 ] } , \quad \mathrm { w h e r e } \ \mathbf { x } _ { i } ^ { [ d - 1 ] } = ( \mathbf { x } _ { i } ) ^ { d - 1 } . +$$ + +Similar to Zprop, we can define Hprop (41) in a node-wise fashion as + +$$ +\mathrm { H p r o p } \colon \mathbf { X } _ { v , : } ^ { ( t + 1 ) } = \left( \sum _ { e : v \in e } ( d - 1 ) \prod _ { u : u \in e \backslash v } \mathbf { X } _ { u , : } ^ { ( t ) } \right) ^ { \frac { 1 } { d - 1 } } . +$$ + +Although taking the $1 / ( d - 1 )$ -th root resolves the unit issue that exists in Zprop (4), it may lead to imaginary features during updates. It remains an open question to formulate Hprop in a manner that ensures that features remain real-valued during propagation. + +# I ADDITIONAL DETAILS PERTAINING TO THE TESTED DATASETS + +Table 3: Full dataset statistics: $| e |$ refers to the size of the hyperedges while $d _ { v }$ refers to the node degree. + +
CoraCiteseer:Pubmed Cora-CA DBLP-CAZoo20News Mushroom NTU2012 ModelNet40YelpHouseWalmart
IYI270833121971727084130210116242812420121231150758129088860
1579107979631072223634310029820121231167930234169906
# feature143337035001433142516100221001001862100100
#class7637674267409211
max lel5261714320293224118085528388125
min |el22222129155212
avg lel3.033.24.354.284.4539.93654.51136.31556.6634.726.59
med lel323334053772553405
max du145889923181744519307855445733
min du00001171511100
avgdu1.771.041.761.692.41174.0355589.129.185.18
med du100221735543572
+ +We use 10 available benchmark datasets from the existing hypergraph neural networks literature and introduce three newly created datasets as described in the exposition to follow. The benchmark datasets include cocitation networks Cora, Citeseer and Pubmed5, obtained from Yadati et al. (2019). The coauthorship networks Cora- $\mathbf { \mathcal { C } A } ^ { 6 }$ and DBLP-CA7 are also adapted from Yadati et al. (2019). In the cocitation and coauthorship networks datasets, the node features are the bag-of-words representations of the corresponding documents. Datasets from the UCI Categorical Machine Learning Repository (Dua & Graff, 2017) include 20Newsgroups, Mushroom and Zoo. In 20Newsgroups, the node features are the TF-IDF representations of news messages. In the Mushroom dataset, the node features represent categorical descriptions of 23 species of mushrooms. In Zoo, the node features are a mix of categorical and numerical measurements describing different animals. The computer vision and graphics datasets include the Princeton CAD ModelNet40 (Wu et al., 2015) and the NTU2012 3D dataset (Chen et al., 2003). The visual objects contain features extracted using Group-View Convolutional Neural Network(GVCNN) (Feng et al., 2018) and Multi-View Convolutional Neural + +Network(MVCNN) (Su et al., 2015). The hypergraph construction follows the setting described in Feng et al. (2019); Yang et al. (2020). + +The three newly introduce datasets are adapted from Yelp (Yelp), House (Chodrow et al., 2021) and Walmart (Amburg et al., 2020). For Yelp, we selected all businesses in the “restaurant” catalog as our nodes, and formed hyperedges by selecting restaurants visited by the same user. We use the number of stars in the average review of a restaurant as the corresponding node label, starting from 1 and going up to 5 stars, with an interval of 0.5 stars. We then form the node features from the latitude, longitude, one-hot encoding of city and state, and bag-of-word encoding of the top-1000 words in the name of the corresponding restaurants. In the House dataset, each node is a member of the US House of Representatives and hyperedges are formed by grouping together members of the same committee. Node labels indicate the political party of the representatives. In Walmart, nodes represent products being purchased at Walmart, and hyperedges equal sets of products purchased together; the node labels are the product categories. Since there are no node features in the original House and Walmart dataset, we impute the same using Gaussian random vectors, in a manner similar to what was done for the contextual stochastic block model (Deshpande et al., 2018). In both datasets, we fix the feature vector dimension to 100 and use one-hot encodings of the labels with added Gaussian noise ${ \mathcal { N } } ( 0 , \sigma ^ { 2 } \mathbf { I } )$ as the actual features. The noise standard deviation $\sigma$ is chosen to be 1 and 0.6. + +# J COMPUTATIONAL EFFICIENCY AND EXPERIMENTAL SETTINGS + +All our test were executed on a Linux machine with 48 cores, 376GB of system memory, and two NVIDIA Tesla P100 GPUs with 12GB of GPU memory each. In AllSetTransformer, we also used a single layer MLP at the end for node classification. The average training times with their corresponding standard deviations in second per run, for all baseline methods at all tested datasets, are reported in Table 4. Note that the reported times do not include any preprocessing times for the hypergraph datasets as these are only performed once before training. Table 4 lists the average training time per run with the optimal set of hyperparameters obtained after tunning; the average training times per run for different sets of hyperparameters used in the tuning process are reported in Table 5. + +Choices of hyperparameters. We tune the hidden dimension of all hypergraph neural networks over $\{ 6 4 , 1 2 8 , 2 5 6 , 5 1 2 \}$ , except for the case of HyperGCN and HAN, where the original implementations do not allow for changing the hidden dimension. For HNHN, AllSetTransformer and AllDeepSets we use one layer (a full $\mathcal { V } \to \mathcal { E } \to \mathcal { V }$ propagation rule layer), while for all the other methods we use two layers as recommended in the previous literature. We tune the learning rate over $\{ 0 . 1 , 0 . 0 1 , 0 . 0 0 1 \}$ , and the weight decays over $\{ 0 , 0 . 0 0 0 0 1 \}$ , for all models under consideration. For models with multihead attentions, we also tune the number of heads over the set $\{ 1 , 4 , 8 \}$ . The best hyperparameters for each model and dataset are listed in Table 6. Note that we only use default setting for HAN due to facts that its DGL implementation has all parameters set as constants and its much higher time complexity per run. + +Table 4: Running times for the best hyperparameter choice: Mean (sec or hour) $\pm$ standard deviation. + +
CoraCiteseerPubmedCora-CADBLP-CAZoo
AllSetTransformer7.37s ± 0.37s15.97s ± 0.17s26.82s ±0.13s6.37s ±0.13s134.96s ± 0.37s5.36s ±0.13s
AllDeepSets11.70s ± 0.07s14.56s ± 0.06s58.26s±0.23s11.23s ± 0.06s145.60s ± 11.00s9.57s± 0.75s
MLP1.33s ± 0.06s1.52s ± 0.04s1.77s ± 0.05s1.38s ± 0.06s3.86s ± 0.02s0.03s ±0.00s
CECGN2.39s ±0.09s2.06s ± 0.07s3.42s ±0.30s1.68s ± 0.05s9.19s ± 0.04s1.69s ±0.10s
CEGAT10.84s ± 0.21s5.34s ± 0.12s23.20s ±0.15s4.86s ± 0.13s69.50s ± 0.38s3.92s ±0.13s
HNHN2.71s ± 0.04s2.84s ± 0.03s8.92s ± 0.03s2.67s ± 0.05s26.57s ± 0.07s0.19s ±0.02s
HGNN4.81s ± 0.17s5.03s ± 0.16s14.75s ± 0.08s3.32s ± 0.15s21.65s ± 0.09s3.18s ±0.04s
HCHA3.57s ±0.16s4.02s ± 0.05s14.26s ± 0.06s3.18s ±0.29s37.49s ±0.08s2.87s ± 0.09s
HyperGCN2.91s ± 0.02s3.37s ± 0.02s4.33s ± 0.27s2.97s ± 0.03s8.07s ± 0.21sN/A
UniGCNII43.21s ± 0.06s2.78s ± 0.27s8.93s ± 0.83s16.55s ± 0.05s223.57s± 0.03s2.35s ±0.12s
HAN (full batch)3.47s ± 0.52s2.58s ±0.48s7.17s ± 0.11s3.09s ±0.07s12.39s± 0.22s2.78s ±0.09s
HAN (mini batch)99.87s ± 17.05s69.06s ±11.69s 502.44s ±161.40s 143.80s ±15.48s0.45h ± 0.12h102.98s ± 2.39s
20NewsgroupsMushroomNTU2012ModelNet40YelpHouse(1)Walmart(1)
AllSetTransformer25.47s± 0.50s10.12s ± 0.14s7.40s ±0.28s47.55s ± 0.25s284.79s ±0.23s8.69s±0.32s154.19s ± 0.11s
AlIDeepSets46.61s ± 0.14s14.07s ± 0.03s10.25s ± 0.07s49.27s ± 0.13s474.34s ± 0.07s4.07s ± 0.24s341.18s ± 0.62s
MLP1.68s ± 0.02s1.44s ± 0.06s1.29s ± 0.01s1.60s ± 0.13s5.70s ± 0.03s1.51s ± 0.05s7.83s ± 0.02s
CECGN0OM69.67s ± 1.70s2.00s ± 0.02s2.54s ± 0.28s0OM10.40s ± 0.08s173.75s ± 0.07s
CEGATOOM132.53s ± 27.81s8.44s ±0.12s43.57s ± 16.13sOOM26.38s ±0.15s121.90s ± 0.11s
HNHN9.04s ± 0.09s2.34s ± 0.03s2.17s ± 0.03s8.54s ± 0.08s111.00s ± 0.08s1.76s ± 0.01s54.85s± 0.05s
HGNN0.51s ± 0.03s10.57s ± 0.10s3.46s ± 0.09s15.55s ± 0.13s550.93s ± 0.07s3.20s ±0.13s105.68s ± 0.05s
HCHA0.53s ±0.03s10.54s ± 0.13s3.47s ± 0.11s15.95s ± 0.81s267.83s ± 0.03s3.05s ±0.08s104.27s ± 0.14s
HyperGCN5.96s ±0.03s5.01s ± 0.03s3.09s ±0.02s4.77s ± 0.02s183.76s ± 0.82s2.98s ± 0.04s16.03s ± 0.34s
UniGCNII34.58s ± 0.03s10.00s ± 0.03s12.95s ± 0.13s4.40s ± 0.16s197.07s ± 0.04s12.10s ± 0.06s104.23s ± 0.10s
HAN (full batch)OOM30.28s ± 3.29s3.10s ± 0.11s4.56s ± 0.21sOOM3.32s±0.12sOOM
HAN (mini batch) 313.28s ± 93.42s 111.53s ±30.05s165.35s ± 1.96s414.50s ± 87.25s5.50h ± 1.48h72.79s ± 5.59s1.96h ± 0.44h
+ +Table 5: Average running times over all different choices of hyperparameters: Mean $\pm$ standard deviation. + +
CoraCiteseerPubmedCora-CADBLP-CAZoo
AllSetTransformer8.18s ±3.59s8.41s ± 4.39s22.99s ± 16.54s7.21s ± 2.94s53.14s ± 43.49s5.97s± 2.23s
AllDeepSets5.61s ± 4.47s6.83s ± 5.63s27.05s± 23.94s5.62s ± 4.38s57.26s± 55.65s4.14s ± 3.18s
MLP1.00s ± 0.46s1.03s ± 0.48s1.53s ± 0.95s1.00s ± 0.45s2.64s ± 1.25s0.99s ± 0.50s
CEGCN1.63s ± 0.76s2.24s ± 1.38s5.93s ± 5.01s1.79s ± 0.99s18.91s ± 17.08s1.41s ± 0.62s
CEGAT6.47s ± 3.99s9.25s ± 7.60s34.52s ± 35.16s7.93s ± 5.94s53.84s± 37.83s5.28s± 5.92s
HNHN1.65s ± 1.01s2.43s ± 1.62s5.03s ± 3.14s1.89s ± 0.80s14.80s ± 9.55s1.59s ± 0.63s
HGNN3.42s ± 1.49s4.44s ± 2.03s8.44s ± 5.08s3.37s ± 1.47s21.02s ± 13.61s2.75s ± 1.06s
HCHA3.32s ± 1.42s4.30s ± 2.02s8.22s ± 4.97s3.24s ± 1.42s20.66s ± 13.37s2.65s ± 1.03s
HyperGCN2.13s ±0.75s2.48s ± 0.76s3.23s ±1.00s2.27s ± 0.67s6.13s ±1.93s1.91s ± 0.58s
UniGCNII13.13s ± 13.64s16.81s ± 17.63s61.81s ± 75.63s11.61s ± 12.46s94.97s ± 81.68s3.56s ± 2.58s
HAN (full batch)3.47s ±0.52s2.58s ± 0.48s7.17s ± 0.11s3.09s ± 0.07s12.39s ± 0.22s2.78s ±0.09s
HAN (mini batch)99.87s ± 17.05s69.06s ±11.69s 502.44s ±161.40s 143.80s ±15.48s0.45h ± 0.12h102.98s ± 2.39s
20NewsgroupsMushroomNTU2012ModelNet40YelpHouse(1)Walmart(1)
AllSetTransformer 21.97s ±17.96s14.35s ± 11.10s6.96s ± 2.65s19.99s ±14.46s 244.61s ± 97.44s6.87s ± 3.11s123.51s ± 102.91s
AllDeepSets20.88s ± 21.73s12.76s ± 13.89s5.15s ± 4.03s19.90s ± 19.15s 196.53s ± 254.83s4.52s± 3.01s107.54s ± 119.02s
MLP1.22s ± 0.54s1.11s ± 0.53s0.97s ± 0.43s1.14s ± 0.50s3.88s ± 1.93s0.98s ± 0.47s4.44s± 2.72s
CEGCN0OM67.66s ± 47.17s1.51s ± 0.69s3.68s ± 2.72s0OM4.16s ± 3.65s63.42s ± 62.30s
CEGATOOM121.39s ± 7.43s5.45s ± 2.97s19.54s ± 19.68sOOM21.94s ± 23.44s85.82s ± 45.10s
HNHN5.21s ± 3.18s3.28s ±1.80s1.68s ± 0.68s4.92s± 2.99s56.15s ± 77.57s1.70s ± 0.53s23.62s ± 18.74s
HGNN9.69s ± 5.93s6.51s ± 3.58s3.30s ± 1.40s8.86s ± 5.36s343.16s ± 262.93s3.29s ± 1.21s44.19s± 36.85s
HCHA9.61s ± 5.98s6.48s ± 3.57s3.23s ± 1.37s8.82s ± 5.47s135.47s ± 187.18s3.20s ± 1.18s43.62s± 36.37s
HyperGCN4.34s ± 1.54s3.56s ± 1.25s2.29s ± 0.72s3.41s ± 1.17s125.67s ± 56.93s2.39s ±0.76s20.11s ± 7.88s
UniGCNII58.01s ± 66.97s35.47s ± 44.72s9.22s ± 9.68s46.30s± 54.77s309.35s ± 129.68s8.83s ± 7.97s119.66s ± 73.89s
HAN (full batch)OOM30.28s ± 3.29s3.10s ± 0.11s4.56s ± 0.21sOOM3.32s ±0.12sOOM
HAN (mini batch) 313.28s ± 93.42s 111.53s ± 30.05s165.35s ± 1.96s414.50s ± 87.25s5.50h ± 1.48h72.79s ± 5.59s1.96h ± 0.44h
+ +Table 6: Choice of hyperparameters for each method: lr refers to the learning rate, wd refers to the weight decaying factor, h1 refers to the dimension of MLP hidden layer and heads refers to the number of attention heads. Remarkably, not all hyperparameters are used for some models. For example, MLP, CEGCN, HNHN, HGNN, HCHA and HyperGCN does not take heads as input. + +
example,MLP, CEGCN,HNHN,HGNN,HCHA and HyperGCN does not take heads aAllDeepSets
AllSetTransformer lr wd h1headslr wdh1 headslr wdMLP h1 heads1CEGCN
Cora0.001025640.001051210.010641lr 0.001wd 0h1heads 1
Citeseer0.001051280.001051210.0106410.0010512 128
Pubmed0.001025680.001051210.011.00E-05 6410.011.00E-051
012880.001051210.011.00E-05 64641
Cora-CA DBLP-CA0.001 0.001051280.001051210.010641 10.0010641
Zoo0.011.00E-056410.001051210.106410.01 0.0011.00E-05 064 5121
20News0.001025680.001051210.011.00E-05 641OOM0OM0OMOOM1
Mushroom0.001012810.001025610.0106410.011.00E-0564
NTU20120.001025610.001051210.011.00E-05 6410.00101
ModelNet400.001051280.001051210.011.00E-05 6410.011.00E-055121
Yelp0.00106410.001012810.011.00E-05 64OOM641
House(1)0.001051280.011.00E-056410.0101OOM0OMOOM
6410.00105121
Walmart(1)0.001025680.0010512 10.00106410.00105121
House(0.6)0.0010512 25610.0010128 5121 10.01 0.011.00E-05 6410.00105121
Walmart(0.6) 0.001 08 0.001 0 CEGAT0 64 1 HGNN0.001 0 512
lrwdh1headsHNHN wdh1 headslrwdh1 headsHCHA
Cora0.001025680.001051210.00105121lr 0.001wd 0h1 256heads
Citeseer0.00106440.001025610.001025610.00101281 1
Pubmed0.011.00E-056480.001051210.001051210.00105121
Cora-CA0.0106440.001051210.001012810.00101281
DBLP-CA0.011.00E-056480.001051210.001025610.00105121
Z0o0.001 1.00E-056480.106410.001051210.0010512
20News0OMOOM0OM OOM0.001051210.106410.1064
\ No newline at end of file diff --git a/md/dev/htM1WJZVB2I/htM1WJZVB2I.md b/md/dev/htM1WJZVB2I/htM1WJZVB2I.md new file mode 100644 index 0000000000000000000000000000000000000000..87c8e5e3841aeb5874e0c0ab41ecf0084e23f332 --- /dev/null +++ b/md/dev/htM1WJZVB2I/htM1WJZVB2I.md @@ -0,0 +1,320 @@ +# Vision GNN: An Image is Worth Graph of Nodes + +Kai Han1,2∗ Yunhe Wang2∗ Jianyuan Guo2 Yehui Tang2,3 Enhua Wu1,4 + +1State Key Lab of Computer Science, ISCAS & UCAS 2Huawei Noah’s Ark Lab 3Peking University 4University of Macau {kai.han,yunhe.wang}@huawei.com, weh@ios.ac.cn + +# Abstract + +Network architecture plays a key role in the deep learning-based computer vision system. The widely-used convolutional neural network and transformer treat the image as a grid or sequence structure, which is not flexible to capture irregular and complex objects. In this paper, we propose to represent the image as a graph structure and introduce a new Vision GNN (ViG) architecture to extract graphlevel feature for visual tasks. We first split the image to a number of patches which are viewed as nodes, and construct a graph by connecting the nearest neighbors. Based on the graph representation of images, we build our ViG model to transform and exchange information among all the nodes. ViG consists of two basic modules: Grapher module with graph convolution for aggregating and updating graph information, and FFN module with two linear layers for node feature transformation. Both isotropic and pyramid architectures of ViG are built with different model sizes. Extensive experiments on image recognition and object detection tasks demonstrate the superiority of our ViG architecture. We hope this pioneering study of GNN on general visual tasks will provide useful inspiration and experience for future research. + +The PyTorch code is available at https://github.com/huawei-noah/ Efficient-AI-Backbones and the MindSpore code is available at https: //gitee.com/mindspore/models. + +# 1 Introduction + +In the modern computer vision system, convolutional neural networks (CNNs) used to be the de-facto standard network architecture [29, 27, 17]. Recently, transformer with attention mechanism was introduced for visual tasks [9, 3] and attained competitive performance. MLP-based (multi-layer perceptron) vision models [49, 50] can also work well without using convolutions or self-attention. These progresses are pushing the vision models towards an unprecedented height. + +Different networks treat the input image in different ways. As shown in Figure 1, the image data is usually represented as a regular grid of pixels in the Euclidean space. CNNs [29] apply sliding window on the image and introduce the shift-invariance and locality. The recent vision transformer [9] or MLP [49] treats the image as a sequence of patches. For example, ViT [9] divides a $2 2 4 \times 2 2 4$ image into a number of $1 6 \times 1 6$ patches and forms a sequence with length of 196 as input. + +Instead of the regular grid or sequence representation, we process the image in a more flexible way. One basic task of computer vision is to recognize the objects in an image. Since the objects are usually not quadrate whose shape is irregular, the commonly-used grid or sequence structures in previous networks like ResNet and ViT are redundant and inflexible to process them. An object can be viewed as a composition of parts, e.g., a human can be roughly divided into head, upper body, arms and legs. These parts linked by joints naturally form a graph structure. By analyzing the graph, we are able to recognize the human. Moreover, graph is a generalized data structure that grid and sequence can be viewed as a special case of graph. Viewing an image as a graph is more flexible and effective for visual perception. + +![](images/6bfad949766080d425e6f60dfe82e87503ea710657764a7e528a2beb4f983c92.jpg) +Figure 1: Illustration of the grid, sequence and graph representation of the image. In the grid structure, the pixels or patches are ordered only by the spatial position. In the sequence structure, the 2D image is transformed to a sequence of patches. In the graph structure, the nodes are linked by its content and are not constrained by the local position. + +Based on the graph representation of images, we build the vision graph neural network (ViG for short) for visual tasks. Instead of treating each pixel as a node which will result in too many nodes $( > 1 0 \mathrm { K } )$ , we divide the input image to a number of patches and view each patch as a node. After constructing the graph of image patches, we use our ViG model to transform and exchange information among all the nodes. The basic cells of ViG include two parts: Grapher and FFN (feed-forward network) modules. Grapher module is constructed based on graph convolution for graph information processing. To alleviate over-smoothing phenomenon of conventional GNN, a FFN module is utilized for node feature transformation and encouraging node diversity. With Grapher and FFN modules, we build our ViG models in both isotropic and pyramid manners. In the experiments, we demonstrate the effectiveness of ViG model on visual tasks like image classification and object detection. For instance, our Pyramid ViG-S achieves $8 2 . 1 \%$ top-1 accuracy on ImageNet classification task, which outperforms the representative CNN (ResNet [17]), MLP (CycleMLP [5]) and transformer (Swin-T [35]) with similar FLOPs (about 4.5G). To the best of our knowledge, our work is the first to successfully apply graph neural network on large-scale visual tasks. We hope our work will inspire the community to further explore more powerful network architectures. + +# 2 Related Work + +In this section, we first revisit the backbone networks in computer vision. Then we review the development of graph neural network, especially GCN and its applications on visual tasks. + +# 2.1 CNN, Transformer and MLP for Vision + +The mainstream network architecture in computer vision used to be convolutional network [29, 27, 17]. Starting from LeNet [29], CNNs have been successfully used in various visual tasks, e.g., image classification [27], object detection [42] and semantic segmentation [36]. The CNN architecture is evolving rapidly in the last ten years. The representative works include ResNet [17], MobileNet [21] and NAS [75, 70]. Vision transformer was introduced for visual tasks from 2020 [14, 9, 3, 4]. From then on, a number of variants of ViT [9] were proposed to improve the performance on visual tasks. The main improvements include pyramid architecture [57, 35], local attention [15, 35] and position encoding [61]. Inspired by vision transformer, MLP is also explored in computer vision [49, 50]. With specially designed modules [5, 32, 12, 48], MLP can achieve competitive performance and work on general visual tasks like object detection and segmentation. + +# 2.2 Graph Neural Network + +The earliest graph neural network was initially outlined in [11, 44]. Micheli [38] proposed the early form of spatial-based graph convolutional network by architecturally composite nonrecursive layers. In recent several years, the variants of spatial-based GCNs have been introduced, such as [39, 1, 10]. Spectral-based GCN was first presented by Bruna et al. [2] that introduced graph convolution based on the spectral graph theory. Since this time, a number of works to improve and extend spectral-based GCN have been proposed [18, 7, 26]. The GCNs are usually applied on graph data, such as social networks [13], citation networks [45] and biochemical graphs [55]. + +The applications of GCN in the field of computer vision [63, 28, 56, 25] mainly include point clouds classification, scene graph generation, and action recognition. A point cloud is a set of 3D points in space which is usually collected by LiDAR scans. GCN has been explored for classifying and segmenting points clouds [28, 58, 69]. Scene graph generation aims to parse the input image intro a graph with the objects and their relationship, which is usually solved by combining object detector and GCN [63, 68]. By processing the naturally formed graph of linked human joints, GCN was utilized on human action recognition task [24, 67]. GCN can only tackle specific visual tasks with naturally constructed graph. For general applications in computer vision, we need a GCN-based backbone network that directly processes the image data. + +# 3 Approach + +In this section, we describe how to transform an image to a graph and introduce vision GNN architectures to learn visual representation. + +![](images/72671ea5a671a35dcbb9d49b81dbd549818ed70daedacdd4f534be63faafbcab.jpg) +Figure 2: The framework of the proposed ViG model. + +# 3.1 ViG Block + +Graph Structure of Image. For an image with size of $H \times W \times 3$ , we divided it into $N$ patches. By transforming each patch into a feature vector $\mathbf { x } _ { i } \in \mathbb { R } ^ { D }$ , we have $X = [ { \bf x } _ { 1 } , { \bf x } _ { 2 } , \cdots , { \bf x } _ { N } ]$ where $D$ is the feature dimension and $i = 1 , 2 , \cdots , N$ . These features can be viewed as a set of unordered nodes which are denoted as $\mathcal { V } = \{ v _ { 1 } , v _ { 2 } , \cdot \cdot \cdot , v _ { N } \}$ . For each node $v _ { i }$ , we find its $K$ nearest neighbors $\mathcal { N } ( v _ { i } )$ and add an edge $e _ { j i }$ directed from $v _ { j }$ to $v _ { i }$ for all $v _ { j } \in \mathcal { N } ( v _ { i } )$ . Then we obtain a graph $\mathcal { G } = ( \nu , \mathcal { E } )$ where $\mathcal { E }$ denote all the edges. We denote the graph construction process as ${ \mathcal { G } } = G ( X )$ in the following. By viewing the image as a graph data, we explore how to utilize GNN to extract its representation. + +The advantages of graph representation of the image include: 1) graph is a generalized data structure that grid and sequence can be viewed as a special case of graph; 2) graph is more flexible than grid or sequence to model the complex object as an object in the image is usually not quadrate whose shape is irregular; 3) an object can be viewed as a composition of parts (e.g., a human can be roughly divided into head, upper body, arms and legs), and graph structure can construct the connections among those parts; 4) the advanced research on GNN can be transferred to address visual tasks. + +Graph-level processing. To be general, we start from the features $\boldsymbol { X } \in \mathbb { R } ^ { N \times D }$ . We first construct a graph based on the features: ${ \mathcal { G } } = G ( X )$ . A graph convolutional layer can exchange information between nodes by aggregating features from its neighbor nodes. Specifically, graph convolution + +operates as follows: + +$$ +\begin{array} { r l } & { \mathcal { G } ^ { \prime } = F ( \mathcal { G } , \mathcal { W } ) } \\ & { \quad = U p d a t e ( A g g r e g a t e ( \mathcal { G } , W _ { a g g } ) , W _ { u p d a t e } ) , } \end{array} +$$ + +where $W _ { a g g }$ and $W _ { u p d a t e }$ are the learnable weights of the aggregation and update operations, respectively. More concretely, the aggregation operation computes the representation of a node by aggregating features of neighbor nodes, and the update operation further merge the aggregated feature: + +$$ +\mathbf { x } _ { i } ^ { \prime } = h ( \mathbf { x } _ { i } , g ( \mathbf { x } _ { i } , N ( \mathbf { x } _ { i } ) , W _ { a g g } ) , W _ { u p d a t e } ) , +$$ + +where $\mathcal { N } ( \mathbf { x } _ { i } ^ { l } )$ is the set of neighbor nodes of $\mathbf { x } _ { i } ^ { l }$ . Here we adopt max-relative graph convolution [30] for its simplicity and efficiency: + +$$ +\begin{array} { r l } & { g ( \cdot ) = \mathbf { x } _ { i } ^ { \prime \prime } = [ \mathbf { x } _ { i } , \operatorname* { m a x } ( \{ \mathbf { x } _ { j } - \mathbf { x } _ { i } | j \in \mathcal { N } ( \mathbf { x } _ { i } ) \} ] , } \\ & { h ( \cdot ) = \mathbf { x } _ { i } ^ { \prime } = \mathbf { x } _ { i } ^ { \prime \prime } W _ { u p d a t e } , } \end{array} +$$ + +where the bias term is omitted. The above graph-level processing can be denoted as $X ^ { \prime } =$ GraphConv $( X )$ . + +We further introduce multi-head update operation of graph convolution. The aggregated feature $\mathbf { x } _ { i } ^ { \prime \prime }$ is first split into $h$ heads, i.e., head1 $, h e a d ^ { 2 } , \cdot \cdot \cdot , h e a d ^ { h }$ and then these heads are updated with different weights respectively. All the heads can be updated in parallel and are concatenated as the final values: + +$$ +\mathbf { x } _ { i } ^ { \prime } = [ h e a d ^ { 1 } W _ { u p d a t e } ^ { 1 } , h e a d ^ { 2 } W _ { u p d a t e } ^ { 2 } , \cdot \cdot \cdot , h e a d ^ { h } W _ { u p d a t e } ^ { h } ] . +$$ + +Multi-head update operation allows the model to update information in multiple representation subspaces, which is beneficial to the feature diversity. + +ViG block. The previous GCNs usually repeatedly use several graph convolution layers to extract aggregated feature of the graph data. The over-smoothing phenomenon in deep GCNs [31, 40] will decrease the distinctiveness of node features and lead to performance degradation for visual recognition, as shown in Figure 3 where diversity is measured as $\| X - \mathbf { 1 } \tilde { \mathbf { x } } ^ { T } \|$ with $\tilde { \bf x } = \arg \operatorname* { m i n } _ { \tilde { \bf x } } \| X \stackrel { \cdot } { - }$ $\mathbf { 1 } \tilde { \mathbf { x } } ^ { T } | |$ [8]. To alleviate this issue, we introduce more feature transformations and nonlinear activations in our ViG block. + +We apply a linear layer before and after the graph convolution to project the node features into the same domain and increase the feature diversity. A nonlinear activation function is inserted after graph convolution to avoid layer collapse. We call the upgraded module as Grapher module. + +![](images/18dd89d490eded7ccd33f306200da604374789dc7852fa4f390d6f04223eedd8.jpg) +Figure 3: Feature diversity of nodes as layer changes. + +In practice, given the input feature $\boldsymbol { X } \in \mathbb { R } ^ { N \times D }$ , the Grapher module can be expressed as + +$$ +Y = \sigma ( \mathrm { G r a p h C o n v } ( X W _ { i n } ) ) W _ { o u t } + X , +$$ + +where $Y \in \mathbb { R } ^ { N \times D }$ , $W _ { i n }$ and $W _ { o u t }$ are the weights of fully-connected layers, $\sigma$ is the activation function, e.g., ReLU and GeLU [19], and the bias term is omitted. + +To further encourage the feature transformation capacity and relief the over-smoothing phenomenon, we utilize feed-forward network (FFN) on each node. The FFN module is a simple multi-layer perceptron with two fully-connected layers: + +$$ +Z = \sigma ( Y W _ { 1 } ) W _ { 2 } + Y , +$$ + +where $Z \in \mathbb { R } ^ { N \times D }$ , $W _ { 1 }$ and $W _ { 2 }$ are the weights of fully-connected layers, and the bias term is omitted. The hidden dimension of FFN is usually larger than $D$ . In both Grapher and FFN modules, batch normalization is applied after every fully-connected layer or graph convolution layer, which is omitted in Eq. 6 and 7 for concision. A stack of Grapher module and FFN module constitutes the ViG block which serves as the basic building unit for constructing a network. Based on the graph representation of images and the proposed ViG block, we can build the ViG network for visual tasks as shown in Figure 2. Compared to vanilla ResGCN [30], our ViG can maintain the feature diversity (Figure 3) as the layer goes deeper so as to learn discriminative representations. + +# 3.2 Network Architecture + +In the field of computer vision, the commonly-used transformer usually has an isotropic architecture (e.g., ViT [9]), while CNNs prefer to use pyramid architecture (i.e., ResNet [17]). To have a extensive comparison with other types of neural networks, we build two kinds of network architectures for ViG, i.e., isotropic architecture and pyramid architecture. + +Isotropic architecture. Isotropic architecture means the main body has features with equal size and shape throughout the network, such as ViT [9] and ResMLP [50]. We build three versions of isotropic ViG architecture with different models sizes, i.e., ViG-Ti, S and B. The number of nodes is set as $N = 1 9 6$ . To enlarge the receptive field gradually, the number of neighbor nodes $K$ increases from 9 to 18 linearly as the layer goes deep in these three models. The number of heads is set as $h = 4$ by default. The details are listed in Table 1. + +Table 1: Variants of our isotropic ViG architecture. The FLOPs are calculated for the image with $2 2 4 \times 2 2 4$ resolution. ‘Ti’ denotes tiny, ‘S’ denotes small, and $ { \mathbf { \ell } } ^ { 6 } { \mathbf { B } } ^ { \prime }$ denotes base. + +
ModelDepthDimension D一Params (M)FLOPs (B)
ViG-Ti121927.11.3
ViG-S1632064022.786.84.517.7
ViG-B16
+ +Pyramid architecture. Pyramid architecture considers the multi-scale property of images by extracting features with gradually smaller spatial size as the layer goes deeper, such as ResNet [17] and PVT [57]. Empirical evidences show that pyramid architecture is effective for visual tasks [57]. Thus, we utilize the advanced design and build four versions of pyramid ViG models. The details are shown in Table 2. Note that we utilize the spatial reduction [57] in the first two stages to handle large number of nodes. + +Table 2: Detailed settings of Pyramid ViG series. $D$ : feature dimension, $E$ : hidden dimension ratio in FFN, $K$ : number of neighbors in GCN, $H \times W$ : input image size. ‘Ti’ denotes tiny, $\mathbf { \vec { s } } \mathbf { \vec { { \sigma } } }$ denotes small, ‘M’ denotes medium, and ‘B’ denotes base. + +
StageOutput sizePyramidViG-TiPyramidViG-SPyramidViG-MPyramidViG-B
Stem×Conv×3Conv×3Conv×3Conv×3
Stage 1H×W44D=48]E=4K=9×2D=80]E=4K=9×2D= 96]E=4K=9×2D=128]E=4K=9×2
DownsampleH×W8ConvConvConvConv
Stage 2H×W8 8D=96E=4K=9×2D=160E=4K=9×2D=192E=4K=9×2D=256E=4K=9×2
Downsample品×ConvConvConvConv
Stage 3H×W1616D=240E=4K=9×6D=400]E=4K=9×6D=384E=4K=9×16D=512E=4K=9×18
Downsample品×ConvConvConvConv
Stage 4H W32×32D=384E=4K=9×2D=640E=4K=9×2D=768E=4K=9×2D=1024E=4K=9×2
Head1×1Pooling &MLPPooling&MLPPooling&MLPPooling&MLP
Parameters (M)10.727.351.792.6
FLOPs (B)1.74.68.916.8
+ +Positional encoding. In order to represent the position information of the nodes, we add a positional encoding vector to each node feature: + +$$ +\mathbf { x } _ { i } \mathbf { x } _ { i } + \mathbf { e } _ { i } , +$$ + +where $\mathbf { e } _ { i } \in \mathbb { R } ^ { D }$ . The absolute positional encoding as described in Eq. 8 is applied in both iostropic and pyramid architectures. For pyramid ViG, we further include relative positional encoding by + +following the advanced designs like Swin Transformer [35]. For node $i$ and $j$ , the relative positional distance between them is ${ \bf e } _ { i } ^ { \breve { T } } { \bf e } _ { j }$ , which will be added into the feature distance for constructing the graph. + +# 4 Experiments + +In this section, we conduct experiments to demonstrate the effectiveness of ViG models on visual tasks including image recognition and object detection. + +# 4.1 Datasets and Experimental Settings + +Datasets. In image classification task, the widely-used benchmark ImageNet ILSVRC 2012 [43] is used in the following experiments. ImageNet has 1.2M training images and 50K validation images, which belong to 1000 categories. For the license of ImageNet dataset, please refer to http://www.image-net.org/download. For object detection, we use COCO 2017 [34] dataset with 80 object categories. COCO 2017 contains 118K training images and 5K validation images. For the licenses of these datasets, please refer to https://cocodataset.org/#home. + +Experimental Settings. For all the ViG models, we utilize dilated aggregation [30] in Grapher module and set the dilated rate as $\lceil l / 4 \rceil$ for the $l$ -th layer. GELU [19] is used as the nonlinear activation function in Eq. 6 and 7. For ImageNet classification, we use the commonlyused training strategy proposed in DeiT [51] for fair comparison. The data augmentation includes RandAugment [6], Mixup [73], Cutmix [72], random erasing [74] and repeated augment [20]. The details are shown in Table 3. For COCO detection task, we take RetinaNet [33] and Mask R-CNN [16] as the detection frame + +Table 3: Training hyper-parameters for ImageNet. + +
(Pyramid) ViGTi SMB
Epochs300
OptimizerAdamW[37] 1024
Batch size Start learning rate (LR)2e-3
Learning rate scheduleCosine
Warmup epochs20
Weight decay0.05
Label smoothing [47]0.1
Stochastic path [22]0.1 0.1 0.1 0.3
Repeated augment [20]
RandAugment [6]
Mixup prob.[73]0.8
Cutmix prob. [72]1.0
Random erasing prob. [74]0.25
Exponential moving average0.99996
+ +works and use our Pyramid ViG as backbone. All the models are trained on COCO 2017 training set in $^ { 6 6 } 1 \times ^ { , 5 }$ schedule and evaluated on validation set. We implement the networks using PyTroch [41] and MindSpore [23] and train all our models on 8 NVIDIA V100 GPUs. + +Table 4: Results of ViG and other isotropic networks on ImageNet. $\spadesuit$ CNN,  MLP, $\diamond$ Transformer, F GNN. + +
ModelResolutionParams (M)FLOPs (B)Top-1Top-5
ResMLP-S12 conv3x3[50] ConvMixer-768/32[52]224×224 224×22416.7 21.13.2 20.977.0 80.2
ConvMixer-1536/20 [52] ,224×22451.651.481.4
ViT-B/16 [9] ?384×38486.455.577.9-
? DeiT-Ti [51]224×2241.372.291.1
5.7
■ DeiT-S [51]224×22422.14.679.895.0
DeiT-B [51] ■224×22486.417.681.895.7
ResMLP-S24[50]224×224306.079.494.5
ResMLP-B24 [50]224×22411623.081.095.0
Mixer-B/16 [49]224×2245911.776.4-
★ ViG-Ti (ours)224×2247.11.373.992.0
ViG-S (ours)224×22422.74.580.495.2
★ ViG-B (ours)224×224
86.817.782.395.9
+ +# 4.2 Main Results on ImageNet + +Isotropic ViG The neural network with iostropic architecture keeps the feature size unchanged in its main computational body, which is easy to scale and is friendly for hardware acceleration. This scheme is widely used in transformer models for natural language processing [53]. The recent neural networks in vision also explore it such as ConvMixer [49], ViT [9] and ResMLP [50]. We compare our isotropic ViG with the existing iostropic CNNs [50, 49], transformers [9, 51] and MLPs [50, 49] in Table 4. From the results, ViG performs better than other types of networks. For example, our ViG-Ti achieves $7 3 . 9 \%$ top-1 accuracy which is $1 . 7 \%$ higher than DeiT-Ti model with similar computational cost. + +Pyramid ViG The pyramid architecture gradually shrinks the spatial size of feature maps as the network deepens, which can leverage the scale-invariant property of images and produce multi-scale features. The advanced networks usually adopt the pyramid architecture, such as ResNet [17], Swin Transformer [35] and CycleMLP [5]. We compare our Pyramid ViG with those representative pyramid networks in Table 5. Our Pyramid ViG series can outperform or be comparable to the state-of-the-art pyramid networks including CNN, MLP and transformer. This indicates that graph neural network can work well on visual tasks and has the potential to be a basic component in computer vision system. + +Table 5: Results of Pyramid ViG and other pyramid networks on ImageNet. ♠ CNN,  MLP,  Transformer, F GNN. + +
ModelResolutionParams (M)FLOPs (B)Top-1Top-5
ResNet-18 [17,59] ResNet-50[17,59]224×224 224×22412 25.61.8 4.170.6 79.889.7 95.0
ResNet-152[17,59] BoTNet-T3[46] BoTNet-T3 [46] BoTNet-T3[46]224×224 224×224 224×224 256×25660.2 33.5 54.7 75.111.5 7.3 10.9 19.381.8 81.7 82.8 83.595.9 1 =
PVT-Tiny [57] . . PVT-Small [57]224×224 224×22413.2 24.51.9 3.875.1 79.8
PVT-Medium [57] .224×22444.26.781.2
PVT-Large [57]224×22461.49.881.7
?
CvT-13 [60]224×224204.581.6
CvT-21[60] .224×224327.182.5
CvT-21[60] .384×3843224.983.3
. Swin-T[35]224×224294.581.395.5
. Swin-S [35]224×224508.783.096.2
Swin-B [35] .224×2248815.483.596.5
CycleMLP-B2[5]224×224273.981.6
CycleMLP-B3[5]224×224386.982.41
CycleMLP-B4 [5]224×2245210.183.0=
224×224=
Poolformer-S12[71]224×224122.077.293.5
Poolformer-S36 [71]315.281.495.5
Poolformer-M48 [71]224×2247311.982.596.0
★Pyramid ViG-Ti (ours)224×22410.71.778.294.2
Pyramid ViG-S (ours)224×22427.34.682.196.0
★Pyramid ViG-M(ours)224×22451.78.983.196.4
★Pyramid ViG-B (ours)224×22492.616.883.796.5
+ +# 4.3 Ablation Study + +We conduct ablation study of the proposed method on ImageNet classification task and use the isotropic ViG-Ti as the base architecture. + +Type of graph convolution. We test the representative variants of graph convolution, including EdgeConv [58], GIN [64], GraphSAGE [13] and Max-Relative GraphConv [30]. From table 6, we can see that the top-1 accuracies of different graph convolutions are better than that of DeiT-Ti, indicating the flexibility of ViG architecture. Among them, Max-Relative achieves the best trade-off between FLOPs and accuracy. In rest of the experiments, we use Max-Relative GraphConv by default unless specially stated. + +Table 6: ImageNet results of different types of graph convolution. The basic architecture is ViG-Ti. + +
GraphConvParams (M)FLOPs (B)Top-1
EdgeConv [58]7.22.474.3
GIN [64]7.01.372.8
GraphSAGE[13]7.31.674.0
Max-Relative GraphConv [30]7.11.373.9
+ +The effects of modules in ViG. To make graph neural network adaptive to visual task, we introduce FC layers in Grapher module and utilize FFN block for feature transformation. We evaluate the effects of these modules by ablation study. We change the feature dimension of the compared models to make their FLOPs similar, so as to have a fair comparison. From Table 7, we can see that directly utilizing graph convolution for image classification performs poorly. Adding more feature transformation by introducing FC and FFN consistently increase the accuracy. + +Table 7: The effects of modules in ViG on ImageNet. + +
GraphConvFC in Grapher moduleFFN moduleParams (M)FLOPs (B)Top-1
<><>XXxx<>5.81.467.0
4.41.473.4
7.77.11.31.373.673.9
+ +The number of neighbors. In the process of constructing graph, the number of neighbor nodes $K$ is a hyperparameter controlling the aggregated range. Too few neighbors will degrade information exchange, while too many neighbors will lead to over-smoothing. We tune $K$ from 3 to 20 and show the results in Table 8. We can see that the number of neighbor nodes in the range from 9 to 15 can perform well on ImageNet classification task. + +Table 8: Top-1 accuracy vs. $K$ on ImageNet. + +
K3691215209 to 18
Top-172.2 73.473.673.673.573.373.9
+ +The number of heads. Multi-head update operation allows Grapher module to process node features in different subspaces. The number of heads $h$ in Eq. 5 controls the transformation diversity in subspaces and the FLOPs. We tune $h$ from 1 to 8 and show the results in Table 9. The FLOPs and top-1 accuracy on ImageNet changes slightly for different $h$ . We select $h = 4$ as default value for the optimal trade-off between FLOPs and accuracy. + +Table 9: Top-1 accuracy vs. $h$ on ImageNet. + +
h12468
FLOPs/Top-11.6B / 74.21.4B / 74.01.3B / 73.91.2B / 73.71.2B / 73.7
+ +# 4.4 Object Detection + +We apply our ViG model on object detection task to evaluate its generalization. To have a fair comparison, we utilize the ImageNet pretrained Pyramid ViG-S as the backbone of RetinaNet [33] and Mask R-CNN [16] detection frameworks. The models are trained in the commonly-used “1x” schedule and FLOPs is calculated with $1 2 8 0 \times 8 0 0$ input size. From the results in Table 10, we can see that our Pyramid ViG-S performs better than the representative backbones of different types, including ResNet [17], CycleMLP [5] and Swin Transformer [35] on both RetinaNet and Mask R-CNN. The superior results demonstrate the generalization ability of ViG architecture. + +Table 10: Object detection and instance segmentation results on COCO val2017. Our Pyramid ViG is compared with other backbones on RetinaNet and Mask R-CNN frameworks. + +
BackboneRetinaNet 1×
ParamFLOPsmAPAP50AP75APsAPMAPL
ResNet50 [17]37.7M239.3B36.355.338.619.340.048.8
ResNeXt-101-32x4d [62]56.4M319B39.959.642.722.344.252.5
PVT-Small [57]34.2M226.5B40.461.344.225.042.955.7
CycleMLP-B2[5]36.5M230.9B40.661.443.222.944.454.5
Swin-T[35]38.5M244.8B41.562.144.225.144.955.5
Pyramid ViG-S (ours)36.2M240.0B41.863.144.728.545.453.4
BackboneMask R-CNN1×
ParamFLOPsAPbAPAP5APmAPAP75
ResNet50 [17]44.2M260.1B38.058.641.434.455.136.7
PVT-Small [57]44.1M245.1B40.462.943.837.860.140.3
CycleMLP-B2[5]46.5M249.5B42.164.045.738.961.241.8
PoolFormer-S24 [71]41.0M-40.162.243.437.059.139.6
Swin-T[35]47.8M264.0B42.264.646.239.161.642.0
Pyramid ViG-S (ours)45.8M258.8B42.665.246.039.462.441.6
+ +# 4.5 Visualization + +To better understand how our ViG model works, we visualize the constructed graph structure in ViG-S. In Figure 4, we show the graphs of two samples in different depths (the 1st and the 12th blocks). The pentagram is the center node, and the nodes with the same color are its neighbors. Two center nodes are visualized as drawing all the edges will be messy. We can observe that our model can select the content-related nodes as the first order neighbors. In the shallow layer, the neighbor nodes tend to be selected based on low-level and local features, such as color and texture. In the deep layer, the neighbors of the center nodes are more semantic and belong to the same category. Our ViG network can gradually link the nodes by its content and semantic representation and help to better recognize the objects. + +![](images/79fa29d0dd2cb468a7f5831ef0bd2f0fd8a8484dd72dbccd9881b3f51474c224.jpg) +Figure 4: Visualization of the constructed graph structure. The pentagram is the center node, and the nodes with the same color are its neighbors in the graph. + +# 5 Conclusion + +In this work, we pioneer to study representing the image as graph data and leverage graph neural network for visual tasks. We divide the image into a number of patches and view them as nodes. Constructing graph based on these nodes can better represent the irregular and complex objects in the wild. Directly using graph convolution on the image graph structure has over-smoothing problem and performs poorly. We introduce more feature transformation inside each node to encourage the information diversity. Based on the graph representation of images and improved graph block, we build our vision GNN (ViG) networks with both isotropic and pyramid architectures. Extensive experiments on image recognition and object detection demonstrate the superiority of the proposed ViG architecture. We hope this pioneering work on vision GNN can serve as a basic architecture for general visual tasks. + +# Acknowledgement + +This research is supported by NSFC (62072449, 61872345), National Key R&D Program of China (2021YFB1715800), and Macau Science &Tech. Fund (0018/2019/AKP). We gratefully acknowledge the support of MindSpore, CANN (Compute Architecture for Neural Networks) and Ascend AI Processor used for this research. + +# References + +[1] James Atwood and Don Towsley. Diffusion-convolutional neural networks. In NIPS, pages 2001–2009, 2016. +[2] Joan Bruna, Wojciech Zaremba, Arthur Szlam, and Yann LeCun. Spectral networks and locally connected networks on graphs. arXiv preprint arXiv:1312.6203, 2013. +[3] Nicolas Carion, Francisco Massa, Gabriel Synnaeve, Nicolas Usunier, Alexander Kirillov, and Sergey Zagoruyko. End-to-end object detection with transformers. In ECCV, pages 213–229, 2020. [4] 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. In CVPR, 2021. [5] Shoufa Chen, Enze Xie, Chongjian Ge, Ding Liang, and Ping Luo. Cyclemlp: A mlp-like architecture for dense prediction. In ICLR, 2022. +[6] Ekin D Cubuk, Barret Zoph, Jonathon Shlens, and Quoc V Le. Randaugment: Practical automated data augmentation with a reduced search space. In CVPR Workshops, 2020. +[7] Michaël Defferrard, Xavier Bresson, and Pierre Vandergheynst. Convolutional neural networks on graphs with fast localized spectral filtering. In NIPS, volume 29, 2016. +[8] Yihe Dong, Jean-Baptiste Cordonnier, and Andreas Loukas. Attention is not all you need: Pure attention loses rank doubly exponentially with depth. In ICML, pages 2793–2803. PMLR, 2021. [9] 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 ICLR, 2021. +[10] Justin Gilmer, Samuel S Schoenholz, Patrick F Riley, Oriol Vinyals, and George E Dahl. Neural message passing for quantum chemistry. In ICML, pages 1263–1272. PMLR, 2017. +[11] Marco Gori, Gabriele Monfardini, and Franco Scarselli. A new model for learning in graph domains. In IJCNN, volume 2, pages 729–734, 2005. +[12] Jianyuan Guo, Yehui Tang, Kai Han, Xinghao Chen, Han Wu, Chao Xu, Chang Xu, and Yunhe Wang. Hire-mlp: Vision mlp via hierarchical rearrangement. In CVPR, 2022. +[13] William L Hamilton, Rex Ying, and Jure Leskovec. Inductive representation learning on large graphs. In NIPS, pages 1025–1035, 2017. +[14] Kai Han, Yunhe Wang, Hanting Chen, Xinghao Chen, Jianyuan Guo, Zhenhua Liu, Yehui Tang, An Xiao, Chunjing Xu, Yixing Xu, et al. A survey on vision transformer. IEEE Transactions on Pattern Analysis and Machine Intelligence, 2022. +[15] Kai Han, An Xiao, Enhua Wu, Jianyuan Guo, Chunjing Xu, and Yunhe Wang. Transformer in transformer. In NeurIPS, 2021. +[16] Kaiming He, Georgia Gkioxari, Piotr Dollár, and Ross Girshick. Mask r-cnn. In ICCV, pages 2961–2969, 2017. +[17] Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. In CVPR, pages 770–778, 2016. +[18] Mikael Henaff, Joan Bruna, and Yann LeCun. Deep convolutional networks on graph-structured data. arXiv preprint arXiv:1506.05163, 2015. +[19] Dan Hendrycks and Kevin Gimpel. Gaussian error linear units (gelus). arXiv preprint arXiv:1606.08415, 2016. +[20] Elad Hoffer, Tal Ben-Nun, Itay Hubara, Niv Giladi, Torsten Hoefler, and Daniel Soudry. Augment your batch: Improving generalization through instance repetition. In CVPR, 2020. +[21] 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. +[22] Gao Huang, Yu Sun, Zhuang Liu, Daniel Sedra, and Kilian Q Weinberger. Deep networks with stochastic depth. In ECCV, pages 646–661. Springer, 2016. +[23] Huawei. Mindspore. https://www.mindspore.cn/, 2020. +[24] Ashesh Jain, Amir R Zamir, Silvio Savarese, and Ashutosh Saxena. Structural-rnn: Deep learning on spatio-temporal graphs. In CVPR, pages 5308–5317, 2016. +[25] Yongcheng Jing, Yining Mao, Yiding Yang, Yibing Zhan, Mingli Song, Xinchao Wang, and Dacheng Tao. Learning graph neural networks for image style transfer. In ECCV, 2022. +[26] Thomas N Kipf and Max Welling. Semi-supervised classification with graph convolutional networks. In ICLR, 2017. +[27] Alex Krizhevsky, Ilya Sutskever, and Geoffrey E Hinton. Imagenet classification with deep convolutional neural networks. In NeurIPS, pages 1097–1105, 2012. +[28] Loic Landrieu and Martin Simonovsky. Large-scale point cloud semantic segmentation with superpoint graphs. In CVPR, pages 4558–4567, 2018. +[29] Yann LeCun, Léon Bottou, Yoshua Bengio, and Patrick Haffner. Gradient-based learning applied to document recognition. Proceedings of the IEEE, 86(11):2278–2324, 1998. +[30] Guohao Li, Matthias Muller, Ali Thabet, and Bernard Ghanem. Deepgcns: Can gcns go as deep as cnns? In ICCV, pages 9267–9276, 2019. +[31] Qimai Li, Zhichao Han, and Xiao-Ming Wu. Deeper insights into graph convolutional networks for semi-supervised learning. In AAAI, pages 3538–3545, 2018. +[32] Dongze Lian, Zehao Yu, Xing Sun, and Shenghua Gao. As-mlp: An axial shifted mlp architecture for vision. In ICLR, 2022. +[33] Tsung-Yi Lin, Priya Goyal, Ross Girshick, Kaiming He, and Piotr Dollár. Focal loss for dense object detection. In ICCV, 2017. +[34] Tsung-Yi Lin, Michael Maire, Serge Belongie, James Hays, Pietro Perona, Deva Ramanan, Piotr Dollár, and C Lawrence Zitnick. Microsoft coco: Common objects in context. In ECCV, pages 740–755, 2014. +[35] 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 ICCV, pages 10012–10022, 2021. +[36] Jonathan Long, Evan Shelhamer, and Trevor Darrell. Fully convolutional networks for semantic segmentation. In CVPR, 2015. +[37] Ilya Loshchilov and Frank Hutter. Decoupled weight decay regularization. arXiv preprint arXiv:1711.05101, 2017. +[38] Alessio Micheli. Neural network for graphs: A contextual constructive approach. IEEE Transactions on Neural Networks, 20(3):498–511, 2009. +[39] Mathias Niepert, Mohamed Ahmed, and Konstantin Kutzkov. Learning convolutional neural networks for graphs. In ICML, pages 2014–2023. PMLR, 2016. +[40] Kenta Oono and Taiji Suzuki. Graph neural networks exponentially lose expressive power for node classification. In ICLR, 2020. +[41] 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. NeurIPS, 2019. +[42] Shaoqing Ren, Kaiming He, Ross Girshick, and Jian Sun. Faster r-cnn: Towards real-time object detection with region proposal networks. In NIPS, pages 91–99, 2015. +[43] Olga Russakovsky, Jia Deng, Hao Su, Jonathan Krause, Sanjeev Satheesh, Sean Ma, Zhiheng Huang, Andrej Karpathy, Aditya Khosla, Michael Bernstein, et al. Imagenet large scale visual recognition challenge. International Journal of Computer Vision, 115(3):211–252, 2015. +[44] Franco Scarselli, Marco Gori, Ah Chung Tsoi, Markus Hagenbuchner, and Gabriele Monfardini. The graph neural network model. IEEE transactions on neural networks, 20(1):61–80, 2008. +[45] 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. +[46] Aravind Srinivas, Tsung-Yi Lin, Niki Parmar, Jonathon Shlens, Pieter Abbeel, and Ashish Vaswani. Bottleneck transformers for visual recognition. In CVPR, pages 16519–16529, 2021. +[47] Christian Szegedy, Vincent Vanhoucke, Sergey Ioffe, Jon Shlens, and Zbigniew Wojna. Rethinking the inception architecture for computer vision. In CVPR, 2016. +[48] Yehui Tang, Kai Han, Jianyuan Guo, Chang Xu, Yanxi Li, Chao Xu, and Yunhe Wang. An image patch is a wave: Phase-aware vision mlp. In CVPR, 2022. +[49] 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. In NeurIPS, volume 34, 2021. +[50] Hugo Touvron, Piotr Bojanowski, Mathilde Caron, Matthieu Cord, Alaaeldin El-Nouby, Edouard Grave, Gautier Izacard, Armand Joulin, Gabriel Synnaeve, Jakob Verbeek, et al. Resmlp: Feedforward networks for image classification with data-efficient training. arXiv preprint arXiv:2105.03404, 2021. +[51] Hugo Touvron, Matthieu Cord, Matthijs Douze, Francisco Massa, Alexandre Sablayrolles, and Hervé Jégou. Training data-efficient image transformers & distillation through attention. In ICML, 2021. +[52] Asher Trockman and J Zico Kolter. Patches are all you need? arXiv preprint arXiv:2201.09792, 2022. +[53] Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Łukasz Kaiser, and Illia Polosukhin. Attention is all you need. NeurIPS, 2017. +[54] Aladin Virmaux and Kevin Scaman. Lipschitz regularity of deep neural networks: analysis and efficient estimation. In NeurIPS, pages 3839–3848, 2018. +[55] Nikil Wale, Ian A Watson, and George Karypis. Comparison of descriptor spaces for chemical compound retrieval and classification. Knowledge and Information Systems, 14(3):347–375, 2008. +[56] Runzhong Wang, Junchi Yan, and Xiaokang Yang. Learning combinatorial embedding networks for deep graph matching. In ICCV, pages 3056–3065, 2019. +[57] 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. In ICCV, 2021. +[58] Yue Wang, Yongbin Sun, Ziwei Liu, Sanjay E Sarma, Michael M Bronstein, and Justin M Solomon. Dynamic graph cnn for learning on point clouds. Acm Transactions On Graphics (tog), 38(5):1–12, 2019. +[59] Ross Wightman, Hugo Touvron, and Hervé Jégou. Resnet strikes back: An improved training procedure in timm. arXiv preprint arXiv:2110.00476, 2021. +[60] Haiping Wu, Bin Xiao, Noel Codella, Mengchen Liu, Xiyang Dai, Lu Yuan, and Lei Zhang. Cvt: Introducing convolutions to vision transformers. In ICCV, pages 22–31, 2021. +[61] Kan Wu, Houwen Peng, Minghao Chen, Jianlong Fu, and Hongyang Chao. Rethinking and improving relative position encoding for vision transformer. In ICCV, pages 10033–10041, 2021. +[62] Saining Xie, Ross Girshick, Piotr Dollár, Zhuowen Tu, and Kaiming He. Aggregated residual transformations for deep neural networks. In CVPR, pages 1492–1500, 2017. +[63] Danfei Xu, Yuke Zhu, Christopher B Choy, and Li Fei-Fei. Scene graph generation by iterative message passing. In CVPR, pages 5410–5419, 2017. +[64] Keyulu Xu, Weihua Hu, Jure Leskovec, and Stefanie Jegelka. How powerful are graph neural networks? In ICLR, 2018. +[65] Yixing Xu, Kai Han, Chang Xu, Yehui Tang, Chunjing Xu, and Yunhe Wang. Learning frequency domain approximation for binary neural networks. In NeurIPS, volume 34, pages 25553–25565, 2021. +[66] Yixing Xu, Yunhe Wang, Hanting Chen, Kai Han, Chunjing Xu, Dacheng Tao, and Chang Xu. Positiveunlabeled compression on the cloud. In NeurIPS, volume 32, 2019. +[67] Sijie Yan, Yuanjun Xiong, and Dahua Lin. Spatial temporal graph convolutional networks for skeletonbased action recognition. In AAAI, 2018. +[68] Jianwei Yang, Jiasen Lu, Stefan Lee, Dhruv Batra, and Devi Parikh. Graph r-cnn for scene graph generation. In ECCV, pages 670–685, 2018. +[69] Yiding Yang, Jiayan Qiu, Mingli Song, Dacheng Tao, and Xinchao Wang. Distilling knowledge from graph convolutional networks. In CVPR, pages 7074–7083, 2020. +[70] Zhaohui Yang, Yunhe Wang, Xinghao Chen, Boxin Shi, Chao Xu, Chunjing Xu, Qi Tian, and Chang Xu. Cars: Continuous evolution for efficient neural architecture search. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 1829–1838, 2020. +[71] Weihao Yu, Mi Luo, Pan Zhou, Chenyang Si, Yichen Zhou, Xinchao Wang, Jiashi Feng, and Shuicheng Yan. Metaformer is actually what you need for vision. In CVPR, 2022. +[72] Sangdoo Yun, Dongyoon Han, Seong Joon Oh, Sanghyuk Chun, Junsuk Choe, and Youngjoon Yoo. Cutmix: Regularization strategy to train strong classifiers with localizable features. In ICCV, 2019. +[73] Hongyi Zhang, Moustapha Cisse, Yann N Dauphin, and David Lopez-Paz. mixup: Beyond empirical risk minimization. In ICLR, 2018. +[74] Zhun Zhong, Liang Zheng, Guoliang Kang, Shaozi Li, and Yi Yang. Random erasing data augmentation. In AAAI, volume 34, pages 13001–13008, 2020. +[75] Barret Zoph and Quoc V Le. Neural architecture search with reinforcement learning. In ICLR, 2017. + +# Checklist + +1. For all authors... + +(a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes] See Section 1. +(b) Did you describe the limitations of your work? [Yes] +(c) Did you discuss any potential negative societal impacts of your work? [No] No potential negative societal impacts. +(d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes] + +2. If you are including theoretical results... + +(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] + +3. If you ran experiments... + +(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] See Section 4.1. +(b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes] See Section 4.1. +(c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [No] The common settings on ImageNet and COCO datasets. +(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 Section 4.1. + +4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets... + +(a) If your work uses existing assets, did you cite the creators? [Yes] See Section 4.1. +(b) Did you mention the license of the assets? [Yes] See Section 4.1. +(c) Did you include any new assets either in the supplemental material or as a URL? [No] +(d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [N/A] +(e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [N/A] + +5. If you used crowdsourcing or conducted research with human subjects... + +(a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A] +(b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A] +(c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A] \ No newline at end of file diff --git a/md/dev/iOag71mvHI/iOag71mvHI.md b/md/dev/iOag71mvHI/iOag71mvHI.md new file mode 100644 index 0000000000000000000000000000000000000000..4aa5667d543fc5f8e9ee7917b81f0ba38189eabd --- /dev/null +++ b/md/dev/iOag71mvHI/iOag71mvHI.md @@ -0,0 +1,402 @@ +# VARIATIONAL PSEUDO LABELS FOR META TEST-TIME ADAPTATION + +Anonymous authors Paper under double-blind review + +# ABSTRACT + +Test-time model adaptation has shown great effectiveness in generalizing over domain shifts. A most successful tactic for test-time adaptation conducts further optimization on the target data using the predictions by the source-trained model. However, due to domain shifts, the source-trained model predictions themselves can be largely inaccurate, which results in a model misspecified to the target data and therefore damages their adaptation ability. In this paper, we address test-time adaptation from a probabilistic perspective. We formulate model adaption as a probabilistic inference problem, which incorporates the uncertainty into source model predictions by modeling pseudo labels as distributions. Based on the probabilistic formalism, we propose variational pseudo labels that explore the information of neighboring target samples to improve pseudo labels and achieve a model better specified to target data. By a meta-learning paradigm, we train our model by simulating domain shifts and the test-time adaptation procedure. In doing so, our model learns the ability to generate more accurate pseudo-label distributions and to adapt to new domains. Experiments on five widely used datasets demonstrate the effectiveness of our proposal. + +# 1 INTRODUCTION + +Deep neural networks start to exhibit generalizability problems and suffer from performance degradation as soon as test data distributions differ from the ones experienced during training, (Geirhos et al., 2018; Recht et al., 2019). To deal with the distribution shift, domain adaptation, e.g., (Saenko et al., 2010; Long et al., 2015; Lu et al., 2020; Li et al., 2021) and domain generalization, e.g., (Muandet et al., 2013; Motiian et al., 2017; Li et al., 2017; 2020) have proven effective tactics. However, these two settings either require a large number of (unlabeled) target data during training or do not consider any target information during generalization at all. Both of which are not necessarily valid assumptions in realistic scenarios. + +Test-time adaptation, e.g., (Sun et al., 2020; Varsavsky et al., 2020; Wang et al., 2021) goes beyond these two setting and introduces a new learning paradigm, which trains a model on source data and further optimizes it using the unlabeled target data at test time to adapt to the target domain. One widely applied strategy for test-time adaptation updates model parameters by self-supervision (Liang et al., 2020; Wang et al., 2021; Iwasawa & Matsuo, 2021; Niu et al., 2022). However, due to domain shifts, the source-model predictions on the target samples can be uncertain and inaccurate. As self-supervision-based test-time adaptation is often achieved by optimization with pseudo labels or entropy minimization based on the source-trained model predictions, the model can be overconfident on some mispredictions. As a result, the adapted model becomes unreliable and misspecified (Wilson & Izmailov, 2020) to the target data. + +In this paper we make three contributions. First, we address test-time adaptation in a probabilistic framework by formulating it as a variational inference problem. We define pseudo labels as stochastic variables and estimate a distribution over them by variational inference. By doing so, the uncertainty in source-trained model predictions is incorporated into the adaptation to the target data at test time. Second, thanks to the proposed probabilistic formalism, it is natural and convenient to utilize variational distributions to leverage extra information. By hinging on this benefit, we design the variational pseudo labels to explore the neighboring information of target samples into the inference of the pseudo label distributions. By doing so, the variational pseudo labels are more accurate, which enables the source-trained model to be better specified to target data and therefore conducive to model adaptation. Third, we adopt a meta-learning paradigm for optimization to simulate test-time adaptation on source domains. More specifically, the model is exposed to domain shifts iteratively and optimized to learn the ability of adapting to unseen domains. We conduct experiments on three widely-used benchmarks to demonstrate the promise and effectiveness of our method for test-time adaptation. + +# 2 METHODOLOGY + +# 2.1 PRELIMINARY + +We were given data from different domains defined on the joint space $\mathcal { X } \times \mathcal { V }$ , where $\mathcal { X }$ and $\mathcal { V }$ denote $\mathcal { D } _ { s } { = } \left\{ ( \mathbf { x } _ { s } , \mathbf { y } _ { s } ) ^ { i } \right\} _ { i = 1 } ^ { N _ { s } }$ abel space, respectand target domains $\mathcal { D } _ { t } \mathbf { = } \left\{ ( \mathbf { x } _ { t } , \mathbf { y } _ { t } ) ^ { i } \right\} _ { i = 1 } ^ { N _ { t } }$ are split into several source domains. The goal is to train a model on source domains that is expected to generalize well on the (unseen) target domains. + +To this end, test-time adaptation methods, e.g., (Wang et al., 2021; Zhang et al., 2021; Niu et al., 2022), have recently been proposed. These methods adapt the source-trained model by optimization to target domains at test time. + +A common strategy in these methods is that the model $\pmb { \theta }$ is first trained on source data $\mathcal { D } _ { s }$ by minimizing a supervised loss $\mathcal { L } _ { t r a i n } ( \pmb { \theta } ) { = } \mathbb { E } _ { ( \mathbf { x } _ { s } , \mathbf { y } _ { s } ) ^ { i } \in \mathcal { D } _ { s } } [ L _ { \mathrm { C E } } ( \mathbf { x } _ { s } , \mathbf { y } _ { s } ; \pmb { \theta } ) ]$ ; and then at test time they adapt the model $\theta _ { s }$ to the target domain by optimization with certain surrogate losses, e.g., entropy minimization, based on unlabeled test data, which is formulated as: + +$$ +\begin{array} { r } { \mathcal { L } _ { t e s t } ( \pmb { \theta } ) = \mathbb { E } _ { \mathbf { x } _ { t } \in \mathcal { D } _ { t } } [ L _ { E } ( \mathbf { x } _ { t } ; \pmb { \theta } _ { s } ) ] , } \end{array} +$$ + +where the entropy is calculated on the source model predictions. However, test samples from the target domain could be largely misclassified by the source model due to the domain shift, resulting in large uncertainty in the predictions. Moreover, the entropy minimization tends to update the model with high confidence even for the wrong predictions, which would cause a misspecified model for the target domain. + +To solve those problems, in this work we address test-time model adaptation from a probabilistic perspective. We propose a probabilistic inference framework that models the uncertainty of the source-model predictions by defining distributions over pseudo labels. Moreover, under the probabilistic formalism, we propose designing variational pseudo labels, which enables the model to incorporate the neighboring information in test samples to combat domain shifts. We adopt a metalearning paradigm for optimization, which simulates the domain shifts and adaptation procedure. By doing so, the model learns to acquire the ability to further adapt itself with pseudo labels to unseen target domains. We provide a graphical illustration to highlight the differences between common test-time adaptation and our proposals in Figure 1. + +# 2.2 PROBABILISTIC TEST-TIME ADAPTATION WITH LATENT PSEUDO LABELS + +We first provide a probabilistic formulation for test-time adaptation based on pseudo labels. Given the target sample $\mathbf { x } _ { t }$ and the source-trained model $\theta _ { s }$ , we would like to make predictions on the target sample. To this end, we formulate the predictive likelihood as follows: + +$$ +p ( \mathbf { y } _ { t } \vert \mathbf { x } _ { t } , \pmb { \theta } _ { s } ) = \int p ( \mathbf { y } _ { t } \vert \mathbf { x } _ { t } , \pmb { \theta } _ { t } ) p ( \pmb { \theta } _ { t } \vert \mathbf { x } _ { t } , \pmb { \theta } _ { s } ) d \pmb { \theta } _ { t } \approx p ( \mathbf { y } _ { t } \vert \mathbf { x } _ { t } , \pmb { \theta } _ { t } ^ { \ast } ) , +$$ + +where we use the value $\pmb { \theta } _ { t } ^ { \ast }$ obtained by the maximum a posterior (MAP) to approximate the integration (Finn et al., 2018). Intuitively, the MAP approximation is interpreted as inferring the posterior over $\mathbf { \boldsymbol { \theta } } _ { t } \colon p ( \mathbf { \boldsymbol { \theta } } _ { t } | \mathbf { \boldsymbol { x } } _ { t } , \mathbf { \boldsymbol { \theta } } _ { s } ) \approx \delta ( \mathbf { \boldsymbol { \theta } } _ { t } = \mathbf { \boldsymbol { \theta } } _ { t } ^ { * } )$ , which we obtain by adapting $\theta _ { s }$ using the target data $\mathbf { x } _ { t }$ . + +To model the uncertainty of predictions for more robust test-time adaptation, we treat pseudo labels as stochastic variables in the probabilistic framework as shown in Figure 1 (b). The pseudo labels are obtained from the source model predictions, which follows categorical distributions. Then we + +![](images/f01bb83817d3b9050de590c100878fd05a813b9045e7d4f6d42e07edabc92951.jpg) +Figure 1: Graphical illustrations for test-time adaptation. (a) The original test-time adaptation algorithm (Wang et al., 2021) obtains an adapted $\theta _ { t }$ by entropy minimization of the unlabeled target data $\mathbf { x } _ { t }$ on source trained model $\theta _ { s }$ . (b) Our probabilistic formulation models the uncertainty of pseudo labels $p ( \hat { \mathbf { y } } _ { t } )$ for more robust adaptation. (c) Furthermore, we propose meta adaptation with variational pseudo labels to incorporate neighboring target information into pseudo label generation and train the model under the meta-learning setting. Note that $\mathbf { y } _ { t ^ { \prime } }$ are labels of meta-target data and observed only in training. The actual labels $\mathbf { y } _ { t }$ of target data are unavailable for test-time adaptation at inference time. + +reformulate eq. (2) as follows: + +$$ +\begin{array} { l } { p ( { \mathbf { y } _ { t } } | { \mathbf { x } _ { t } } , \pmb { \theta } _ { s } ) = \displaystyle \int p ( { \mathbf { y } _ { t } } | { \mathbf { x } _ { t } } , \pmb { \theta } _ { t } ) \Big [ \int p ( \pmb { \theta } _ { t } | \hat { \mathbf { y } } _ { t } , \mathbf { x } _ { t } , \pmb { \theta } _ { s } ) p ( \hat { \mathbf { y } } _ { t } | { \mathbf { x } _ { t } } , \pmb { \theta } _ { s } ) d \hat { \mathbf { y } } _ { t } \Big ] d \pmb { \theta } _ { t } } \\ { \approx \mathbb { E } _ { p ( \hat { \mathbf { y } } _ { t } | { \mathbf { x } _ { t } } , \pmb { \theta } _ { s } ) } [ p ( \mathbf { y } _ { t } | \mathbf { x } _ { t } , \pmb { \theta } _ { t } ^ { \ast } ) ] , } \end{array} +$$ + +where $\pmb { \theta } _ { t } ^ { * }$ is the MAP value of $p ( \pmb { \theta } _ { t } | \hat { \mathbf { y } } _ { t } , \mathbf { x } _ { t } , \pmb { \theta } _ { s } )$ , which is obtained via gradient descent on the data $\mathbf { x } _ { t }$ and the corresponding pseudo labels $\hat { \mathbf { y } } _ { t }$ starting from $\theta _ { s }$ . The formulation allows us to sample different pseudo labels from the categorical distribution $p ( \hat { \mathbf { y } } _ { t } )$ to adapt the model $\pmb { \theta } _ { t } ^ { * }$ , which takes into account the uncertainty of predictions by the source-trained model. + +By approximating the expectation of $p ( \hat { \mathbf { y } } _ { t } )$ with the argmax function on $p ( \hat { \mathbf { y } } _ { t } )$ , $\pmb { \theta } _ { t } ^ { * }$ is obtained by gradient descent based on only a point estimation of the pseudo label $p ( \hat { \mathbf { y } } _ { t } )$ . However, due to domain shifts, the argmax value of $p ( \hat { \mathbf { y } } _ { t } )$ is not guaranteed to be always correct. The adaptation then is similar to entropy minimization (eq. 1), where the adapted model can achieve high confidence but wrong predictions of some target samples due to domain shifts. For example, consider a toy binary classification task, where the predicted probability is [0.4, 0.6] with the ground-truth label $[ 1 , 0 ]$ . The pseudo label generated by selecting the maximum probability is $[ 0 , 1 ]$ , which is inaccurate. Optimization based on these labels would give rise to a model misspecified to target data, failing to adapt to the target domain. + +In contrast, our probabilistic formulation allows us to sample pseudo labels from the categorical distribution $p ( \hat { \mathbf { y } } _ { t } | \mathbf { x } _ { t } , \pmb { \theta } _ { s } )$ , which incorporates the uncertainty of the pseudo label $\hat { \mathbf { y } } _ { t }$ in a principled way. Again using the above example, the pseudo label sampled from the predicted distribution has a probability of $\mathrm { \bar { 4 } 0 \% }$ to be the ground-truth label, which leads to the adaptation of the model in the correct direction. Therefore, our formulation achieves better adaptation by accessing accurate pseudo labels from the inaccurate prediction distributions. + +# 2.3 VARIATIONAL PSEUDO LABELS + +Under the probabilistic formalism, we derive variational inference of pseudo labels. To train the ability of the model to generate better variational pseudo labels and to fully utilize the pseudo label distributions for better adaptation, we adopt the meta-learning paradigm to simulate domain shifts and test-time adaptation procedures (Finn et al., 2017; Dou et al., 2019; Xiao et al., 2022). We split the source domains $\mathcal { D } _ { s }$ into meta-source domains $\mathcal { D } _ { s ^ { \prime } }$ and a meta-target domain $\mathcal { D } _ { t ^ { \prime } }$ during training. The meta-target domain is selected randomly in each iteration to mimic diverse domain shifts. + +To simulate the test-time adaptation and estimation procedure, we maximize the log-likelihood of the meta-target samples after model adaptation on the meta-target data: + +$$ +\begin{array} { l } { \log p ( \mathbf { y } _ { t ^ { \prime } } | \mathbf { x } _ { t ^ { \prime } } , \pmb { \theta } _ { s ^ { \prime } } ) = \log \displaystyle \int p ( \mathbf { y } _ { t ^ { \prime } } | \mathbf { x } _ { t ^ { \prime } } , \pmb { \theta } _ { t ^ { \prime } } ) \Big [ \displaystyle \int p ( \pmb { \theta } _ { t ^ { \prime } } | \hat { \mathbf { y } } _ { t ^ { \prime } } , \mathbf { x } _ { t ^ { \prime } } , \pmb { \theta } _ { s ^ { \prime } } ) p ( \hat { \mathbf { y } } _ { t ^ { \prime } } | \mathbf { x } _ { t ^ { \prime } } , \pmb { \theta } _ { s ^ { \prime } } ) d \hat { \mathbf { y } } _ { t ^ { \prime } } \Big ] d \pmb { \theta } _ { t ^ { \prime } } } \\ { \approx \log \displaystyle \int p ( \mathbf { y } _ { t ^ { \prime } } | \mathbf { x } _ { t ^ { \prime } } , \pmb { \theta } _ { t ^ { \prime } } ^ { \ast } ) p ( \hat { \mathbf { y } } _ { t ^ { \prime } } | \mathbf { x } _ { t ^ { \prime } } , \pmb { \theta } _ { s ^ { \prime } } ) d \hat { \mathbf { y } } _ { t ^ { \prime } } } \\ { \geq \mathbb { E } _ { p ( \hat { \mathbf { y } } _ { t ^ { \prime } } | \mathbf { x } _ { t ^ { \prime } } , \pmb { \theta } _ { s ^ { \prime } } ) } \big [ \log p ( \mathbf { y } _ { t ^ { \prime } } | \mathbf { x } _ { t ^ { \prime } } , \pmb { \theta } _ { t ^ { \prime } } ^ { \ast } ) \big ] , } \end{array} +$$ + +where $p \big ( \hat { \mathbf { y } } _ { t ^ { \prime } } | \mathbf x _ { t ^ { \prime } } , \pmb \theta _ { s ^ { \prime } } \big )$ denotes the distribution of pseudo labels generated by the meta-source model $\theta _ { s ^ { \prime } }$ on the meta-target data $\mathbf { x } _ { t ^ { \prime } }$ . $\pmb { \theta } _ { t ^ { \prime } } ^ { \ast }$ is the MAP value of $p ( \pmb { \theta } _ { t ^ { \prime } } | \hat { \mathbf { y } } _ { t ^ { \prime } } , \mathbf { x } _ { t ^ { \prime } } , \pmb { \theta } _ { s ^ { \prime } } )$ similar to eq. (3), which is learned to mimic the test-time adaptation procedure. + +Under the meta-learning setting, the actual labels $\mathbf { y } _ { t ^ { \prime } }$ of the meta-target data is accessible since source data are fully labeled as shown in Figure 1 (c). We then simulate the test evaluation procedure and further supervise the adapted model $\pmb { \theta } _ { t ^ { \prime } } ^ { \ast }$ on its meta-target predictions by the actual labels. + +The maximization of the log-likelihood of $p \big ( \mathbf { y } _ { t ^ { \prime } } | \mathbf { x } _ { t ^ { \prime } } , \pmb \theta _ { t ^ { \prime } } ^ { * } \big )$ is realised by a cross-entropy loss on the meta-target predictions and the actual meta-target labels. Intuitively, the pseudo-label adapted model is supervised to achieve good performance on the adapted data. Thus, it learns the ability to generate better pseudo labels and achieve better adaptation across domain shifts with these pseudo labels on new unseen domains. + +Variational pseudo labels. Moreover, we also propose variational pseudo labels that incorporate information of the neighboring target samples to estimate pseudo label distributions that are more robust against domain shifts. The variational pseudo labels is natural and convenient to deployed under the probabilistic formulation. Assume that we have a batch of meta-target data $\mathbf { X } _ { t ^ { \prime } } = \left\{ \mathbf { x } _ { t ^ { \prime } } ^ { i } \right\} _ { i = 1 } ^ { M }$ we reformulate eq. (4) as: + +$$ +\begin{array} { l } { { \log p ( \mathbf { y } _ { t ^ { \prime } } | \mathbf { x } _ { t ^ { \prime } } , \pmb \theta _ { s ^ { \prime } } , \mathbf { X } _ { t ^ { \prime } } ) } } \\ { { = \log \displaystyle \int p ( \mathbf { y } _ { t ^ { \prime } } | \mathbf { x } _ { t ^ { \prime } } , \pmb \theta _ { t ^ { \prime } } ) \Big [ \displaystyle \int \int p ( \pmb \theta _ { t ^ { \prime } } | \hat { \mathbf { y } } _ { t ^ { \prime } } , \mathbf { x } _ { t ^ { \prime } } , \pmb \theta _ { s ^ { \prime } } ) p ( \hat { \mathbf { y } } _ { t ^ { \prime } } , \mathbf { w } _ { t ^ { \prime } } | \mathbf { x } _ { t ^ { \prime } } , \pmb \theta _ { s ^ { \prime } } , \mathbf { X } _ { t ^ { \prime } } ) d \hat { \mathbf { y } } _ { t ^ { \prime } } d \mathbf { w } _ { t ^ { \prime } } \Big ] d \pmb \theta _ { t ^ { \prime } } } } \\ { { = \log \displaystyle \int \int p ( \mathbf { y } _ { t ^ { \prime } } | \mathbf { x } _ { t ^ { \prime } } , \pmb \theta _ { t ^ { \prime } } ^ { * } ) p ( \hat { \mathbf { y } } _ { t ^ { \prime } } , \mathbf { w } _ { t ^ { \prime } } | \mathbf { x } _ { t ^ { \prime } } , \pmb \theta _ { s ^ { \prime } } , \mathbf { X } _ { t ^ { \prime } } ) d \hat { \mathbf { y } } _ { t ^ { \prime } } d \mathbf { w } _ { t ^ { \prime } } d \pmb \theta _ { t ^ { \prime } } , } } \end{array} +$$ + +where $\pmb { \theta } _ { t ^ { \prime } } ^ { \ast }$ is the MAP value of $p \big ( \pmb { \theta } _ { t ^ { \prime } } | \hat { \mathbf { y } } _ { t ^ { \prime } } , \mathbf { x } _ { t ^ { \prime } } , \pmb { \theta } _ { s ^ { \prime } } \big )$ . We introduce the latent variable $\mathbf { w } _ { t ^ { \prime } }$ to integrate the information of the neighboring target samples $\mathbf { X } _ { t ^ { \prime } }$ as shown in Figure 1. + +To approposterior the join, where $p \big ( \hat { \mathbf { y } } _ { t ^ { \prime } } , \mathbf { w } _ { t ^ { \prime } } \big )$ , we introduce a variationalhe actual labels of the meta$q ( \hat { \mathbf { y } } _ { t ^ { \prime } } , \mathbf { w } _ { t ^ { \prime } } | \mathbf { x } _ { t ^ { \prime } } , \pmb { \theta } _ { s ^ { \prime } } , \mathbf { X } _ { t ^ { \prime } } , \mathbf { Y } _ { t ^ { \prime } } )$ $\mathbf { Y } _ { t ^ { \prime } } = \left\{ \mathbf { y } _ { t ^ { \prime } } ^ { i } \right\} _ { j = 1 } ^ { M }$ target data $\mathbf { X } _ { t ^ { \prime } }$ . To facilitate the estimation of pseudo labels, we set the prior distribution as: + +$$ +p ( \hat { { \bf y } } _ { t ^ { \prime } } , { \bf w } _ { t ^ { \prime } } | { \bf x } _ { t ^ { \prime } } , \pmb { \theta } _ { s ^ { \prime } } , \mathbf { X } _ { t ^ { \prime } } ) = p ( \hat { { \bf y } } _ { t ^ { \prime } } | { \bf w } _ { t ^ { \prime } } , \mathbf { x } _ { t ^ { \prime } } ) p _ { \phi } ( { \bf w } _ { t ^ { \prime } } | \pmb { \theta } _ { s ^ { \prime } } , \mathbf { X } _ { t ^ { \prime } } ) +$$ + +where $p _ { \phi } ( \mathbf { w } _ { t ^ { \prime } } | \pmb { \theta } _ { s ^ { \prime } } , \mathbf { X } _ { t ^ { \prime } } )$ is generated by the features of $\mathbf { X } _ { t ^ { \prime } }$ together with their output values based on $\pmb { \theta } _ { s ^ { \prime } }$ . + +Similarly, we define the variational posterior distribution as: + +$$ +\begin{array} { r } { q \big ( \hat { { \mathbf { y } } } _ { t ^ { \prime } } , { \mathbf { w } } _ { t ^ { \prime } } | { \mathbf { x } } _ { t ^ { \prime } } , \pmb { \theta } _ { s ^ { \prime } } , { \mathbf { X } } _ { t ^ { \prime } } , { \mathbf { Y } } _ { t ^ { \prime } } \big ) { = } p \big ( \hat { { \mathbf { y } } } _ { t ^ { \prime } } | { \mathbf { w } } _ { t ^ { \prime } } , { \mathbf { x } } _ { t ^ { \prime } } \big ) q _ { \phi } \big ( { \mathbf { w } } _ { t ^ { \prime } } | \pmb { \theta } _ { s ^ { \prime } } , { \mathbf { X } } _ { t ^ { \prime } } , { \mathbf { Y } } _ { t ^ { \prime } } \big ) . } \end{array} +$$ + +where $q _ { \phi } \big ( \mathbf { w } _ { t ^ { \prime } } | \pmb { \theta } _ { s ^ { \prime } } , \mathbf { X } _ { t ^ { \prime } } , \mathbf { Y } _ { t ^ { \prime } } \big )$ is obtained by the features of $\mathbf { X } _ { t ^ { \prime } }$ and the actual labels $\mathbf { Y } _ { t ^ { \prime } }$ based on θ s ′ . + +By introducing eqs. (6) and (7) into (5), we derive the evidence lower bound (ELBO) of the loglikelihood in eq. (5) as follows: + +$$ +\begin{array} { r } { \log p ( { \mathbf { y } _ { t ^ { \prime } } } | { \mathbf { x } _ { t ^ { \prime } } } , \pmb { \theta } _ { s ^ { \prime } } , { \mathbf { X } _ { t ^ { \prime } } } ) \geq \mathbb { E } _ { q _ { \phi } ( { \mathbf { w } _ { t ^ { \prime } } } ) } \mathbb { E } _ { p ( \hat { { \mathbf { y } _ { t ^ { \prime } } } } | { \mathbf { w } _ { t ^ { \prime } } } , { \mathbf { x } _ { t ^ { \prime } } } ) } [ \log p ( { \mathbf { y } _ { t ^ { \prime } } } | { \mathbf { x } _ { t ^ { \prime } } } , \pmb { \theta } _ { t ^ { \prime } } ^ { * } ) ] } \\ { - \mathbb { D } _ { K L } \big [ q _ { \phi } \big ( { \mathbf { w } _ { t ^ { \prime } } } | \pmb { \theta } _ { s ^ { \prime } } , { \mathbf { X } _ { t ^ { \prime } } } , { \mathbf { Y } _ { t ^ { \prime } } } \big ) \big | \big | p _ { \phi } \big ( { \mathbf { w } _ { t ^ { \prime } } } | \pmb { \theta } _ { s ^ { \prime } } , { \mathbf { X } _ { t ^ { \prime } } } \big ) \big ] . } \end{array} +$$ + +Rather than directly using the meta-source model $\theta _ { s ^ { \prime } }$ , we estimate the pseudo labels $\mathbf { y } _ { t ^ { \prime } }$ from the latent variable $\mathbf { w } _ { t ^ { \prime } }$ , which integrates the features of neighboring target samples. By considering the actual labels $\mathbf { Y } _ { t ^ { \prime } }$ , the variational distribution utilizes both the target information and categorical information of the neighboring samples. Thus, the variational posterior models the distribution of different categories in the target domain more reliably and produces more accurate pseudo labels to improve model adaptation. + +# 2.4 META TEST-TIME ADAPTATION: TRAINING AND INFERENCE + +To mimic domain shifts during training, we split each iteration into meta-source, meta-adaptation, and meta-target to simulate the training stage on source domains, test-time adaptation, and test stage on target data, respectively. + +Under the meta-learning paradigm, the model is iteratively exposed to domain shifts and learns the capability to adapt the meta-source model $\theta _ { s ^ { \prime } }$ to meta-target MAP $\pmb { \theta } _ { t ^ { \prime } } ^ { \ast }$ with the variational pseudo labels. The parameters in the variational inference model $\phi$ are jointly optimized in order to generate better pseudo labels against domain shifts. + +Meta-source. We first train and optimize the model on meta-source domains by minimizing the supervised loss: + +$$ +\pmb { \theta } _ { s ^ { \prime } } = \operatorname* { m i n } _ { \pmb { \theta } } \mathbb { E } _ { ( \mathbf { x } _ { s ^ { \prime } } , \mathbf { y } _ { s ^ { \prime } } ) ) \in \mathcal { D } _ { s ^ { \prime } } } [ L _ { \mathrm { C E } } ( \mathbf { x } _ { s ^ { \prime } } , \mathbf { y } _ { s ^ { \prime } } ; \pmb { \theta } ) ] , +$$ + +where $\left( \mathbf { x } _ { s ^ { \prime } } , \mathbf { y } _ { s ^ { \prime } } \right)$ denotes the input-label pairs of samples on meta-source domains. $\theta _ { s ^ { \prime } }$ are the model parameters trained on the meta-source data. + +Meta-adaptation. Once the meta-source-trained model $\pmb { \theta } _ { s ^ { \prime } }$ is obtained, we generate the pseudo labels $p ( \hat { \mathbf { y } } _ { t ^ { \prime } } | \mathbf { w } _ { t ^ { \prime } } , \mathbf { x } _ { t ^ { \prime } } )$ of the meta-target data with the variational posterior $q _ { \phi } \mathbf { \bar { ( w _ { t ^ { \prime } } | \theta _ { s ^ { \prime } } , X _ { t ^ { \prime } } , Y _ { t ^ { \prime } } ) } }$ . The test-time adaptation procedure is simulated by obtaining ${ \pmb { \theta } } _ { t ^ { \prime } } ^ { * }$ : + +$$ +\begin{array} { r l r } { \pmb { \theta } _ { t ^ { \prime } } ^ { * } = \pmb { \theta } _ { s ^ { \prime } } - \lambda _ { 1 } \nabla _ { \pmb { \theta } } L _ { \mathrm { C E } } \big ( \mathbf { x } _ { t ^ { \prime } } , \hat { \mathbf { y } } _ { t ^ { \prime } } ; \pmb { \theta } _ { s ^ { \prime } } \big ) } & { } & { \hat { \mathbf { y } } _ { t ^ { \prime } } \sim p \big ( \hat { \mathbf { y } } _ { t ^ { \prime } } \big | \mathbf { w } _ { t ^ { \prime } } , \mathbf { x } _ { t ^ { \prime } } \big ) , } \end{array} +$$ + +where $\lambda _ { 1 }$ denotes the learning rate of the optimization in the meta-adaptation stage. + +Meta-target. Since our final goal is to obtain good performance on the target data after optimization with pseudo labels, we further mimic the test-time inference on the meta-target domain and supervise the meta-target prediction on $\pmb { \theta } _ { t ^ { \prime } } ^ { \ast }$ by maximizing the log-likelihood, which is equal to minimizing: + +$$ +\begin{array} { r } { \mathcal { L } _ { m e t a } = \mathbb { E } _ { ( \mathbf { x } _ { t ^ { \prime } } , \mathbf { y } _ { t ^ { \prime } } ) \in \mathcal { D } _ { t ^ { \prime } } } [ \mathbb { E } _ { q _ { \phi } ( \mathbf { w } _ { t ^ { \prime } } ) } \mathbb { E } _ { p ( \hat { \mathbf { y } } _ { t ^ { \prime } } | \mathbf { w } _ { t ^ { \prime } } , \mathbf { x } _ { t ^ { \prime } } ) } L _ { \mathrm { C E } } ( \mathbf { x } _ { t ^ { \prime } } , \mathbf { y } _ { t ^ { \prime } } ; \theta _ { t ^ { \prime } } ^ { * } ) ] + \mathbb { D } _ { K L } \big [ q _ { \phi } ( \mathbf { w } _ { t ^ { \prime } } ) \big | \big | p _ { \phi } \big ( \mathbf { w } _ { t ^ { \prime } } \big ) \big ] , } \end{array} +$$ + +where $\mathbf { y } _ { t ^ { \prime } }$ denotes the ground truth label of $\mathbf { x } _ { t ^ { \prime } }$ . The parameters $\pmb \theta$ are finally updated by + +$$ +\pmb { \theta } = \pmb { \theta } _ { s ^ { \prime } } - \lambda _ { 2 } \nabla _ { \pmb { \theta } } \mathcal { L } _ { m e t a } , +$$ + +where $\lambda _ { 2 }$ denotes the learning rate for the meta-target stage. Note that the loss in eq. (11) is computed on the parameters $\pmb { \theta } _ { t ^ { \prime } } ^ { \ast }$ obtained by eq. (10), while the optimization is performed over the meta-sourcetrained parameters $\theta _ { s ^ { \prime } }$ in eq. (12). Intuitively, the parameters are optimized to learn the ability to handle domain shifts, such that adaptation with variational pseudo labels of data from new domains improves the predictions on the new domain. + +The parameters in the variational inference model $\phi$ are jointly trained with $\pmb \theta$ . To guarantee that the variational pseudo labels do extract the neighboring information for discrimination, we add a cross-entropy loss $\mathcal { L } _ { \hat { c e } }$ on the variational pseudo labels and the corresponding actual labels during training. Thus, $\phi$ is updated by: + +$$ +\phi = \phi - \lambda _ { 3 } \big ( \nabla _ { \phi } \mathcal { L } _ { \widehat { c e } } - \nabla _ { \phi } \mathcal { L } _ { m e t a } \big ) , +$$ + +where $\lambda _ { 3 }$ denotes the learning rates. + +Test-time adaptation and prediction. At test time, the model trained on the source domains with the above meta-learning strategy $\theta _ { s }$ is adapted by further optimization using eq. (10). + +The adapted model is then evaluated on the (unseen) target data $\mathcal { D } _ { t }$ . The prediction is formulated as: + +$$ +\begin{array} { l } { p ( { \mathbf y } _ { t } | { \mathbf x } _ { t } , \theta _ { s } , { \mathbf X } _ { t } ) = \displaystyle \int p ( { \mathbf y } _ { t } | { \mathbf x } _ { t } , \theta _ { t } ) \Big [ \int p ( \theta _ { t } | \hat { \mathbf y } _ { t } , { \mathbf x } _ { t } , \theta _ { s } ) p ( \hat { \mathbf y } _ { t } , { \mathbf w } _ { t } | { \mathbf x } _ { t } , \theta _ { s } , { \mathbf X } _ { t } ) d \hat { \mathbf y } _ { t } d { \mathbf w } _ { t } \Big ] d \theta _ { t } } \\ { = \mathbb { E } _ { p _ { \phi } ( { \mathbf w } _ { t } ) } \mathbb { E } _ { p ( \hat { \mathbf y } _ { t } | { \mathbf w } _ { t } , { \mathbf x } _ { t } ) } [ \log p ( { \mathbf y } _ { t } | { \mathbf x } _ { t } , \theta _ { t } ^ { * } ) ] , } \end{array} +$$ + +where ${ \pmb { \theta } } _ { t } ^ { * }$ is the MAP value of $p ( \pmb { \theta } _ { t } | \mathbf x _ { t } , \hat { \mathbf y } _ { t } , \pmb { \theta } _ { s } )$ . $p _ { \phi } ( \mathbf { w } _ { t } ) { = } p _ { \phi } ( \mathbf { w } _ { t } | \theta _ { s } , \mathbf { X } _ { t } )$ is generated by the features of $\mathbf { X } _ { t }$ according to the outputs or common pseudo labels based on $\theta _ { s }$ . + +# 3 RELATED WORK + +Test-time adaptation. By combining the advantages of both domain adaptation (Ganin & Lempitsky, 2015; Long et al., 2015; Hoffman et al., 2018; Lu et al., 2020; Tzeng et al., 2017; Shen et al., + +2022) and domain generalization (Muandet et al., 2013; Li et al., 2017; 2019; Du et al., 2020; Zhou et al., 2020; 2022), test-time adaptation (Sun et al., 2020; Dubey et al., 2021; Wang et al., 2021; Zhou & Levine, 2021; Chen et al., 2022) and source-free adaptation (Liang et al., 2020; Eastwood et al., 2021) are proposed to train a model only on source domains while adapting it to unlabeled target data at test time. Several methods update normalization statistics of the model to handle domain shifts (Schneider et al., 2020; Du et al., 2021; Hu et al., 2021). Sun et al. (2020) proposed to fine-tune the model parameters by a self-supervised loss at test time. Liu et al. (2021) further enhanced the method by introducing a test-time feature alignment strategy. Instead of using an extra self-supervised loss, Wang et al. (2021) proposed fully test-time adaptation by entropy minimization, which is followed in several recent works (Zhang et al., 2021; Niu et al., 2022; Jang & Chung, 2022). Zhang et al. (2021) minimized the entropy of the marginal output distribution averaged over multiple augmentations of a single target sample. Niu et al. (2022) proposed an efficient test-time adaptation method without forgetting by adapting with low entropy samples with Fisher regularization. Different from these methods, Iwasawa & Matsuo (2021) tried to adjust the classifier with pseudo labels of the target data, without fine-tuning the model parameters. Different from these methods, we propose a probabilistic formulation of test-time adaptation, which models the uncertainty of pseudo labels for better adaptation. We also introduce variational pseudo labels with meta-adaptation to further learn the ability to improve the pseudo labels and adaptations. + +Meta-learning. Meta-learning-based methods (Alet et al., 2021; Xiao et al., 2022; Goyal et al., 2022) have been studied for test-time adaptation before. Alet et al. (2021) learned to adapt with a contrastive loss. Goyal et al. (2022) meta-learned the loss functions of the test-time adaptation for better adaptation. Xiao et al. (2022) proposed a single sample generalization, which adapts the model to each individual target sample through mimicking domain shifts during training. Our method also learns the adaptation ability under the meta-learning setting. We design meta-adaptation to simulate the test-time adaptation procedure and supervise it based on our probabilistic formulation. We further supervise the meta-adapted model in the meta-target stage to learn the variational pseudo label generation and adaptation ability. + +Pseudo label learning. In pseudo label learning, the motive is to use a model’s best predictions, e.g., high confidence predictions, and use the corresponding samples and their predictions for retraining the model on a given downstream task. Tasks examples include classification (Yalniz et al., 2019; Xie et al., 2020), segmentation (Zou et al., 2020), and object detection (Li et al., 2022). Pham et al. (2021) addresses the problem of confirmation bias in pseudo labeling and utilize a teacher-student network for the task of image classification. (Zou et al., 2019) utilize the output logits of softmax as the prediction probability and train the model to directly maximize the logits. (Wang et al., 2022) utilizes confidence to approximate the domain difference and applies augmentations to improve quality if below the threshold to update the student model. (Rizve et al., 2021) assumes that there is access to target labels in a semi-supervised learning and relies on prediction uncertainties leveraged through the labeled samples in target to and generates new pseudo labels. For semi-supervised learning, (Miyato et al., 2018) proposes a regularization method that uses target data without labels. Shu et al. (2018) constructs a new source domain using pseudo labelling using available target data during source training. For domain generalization and offline adaptation, Abdo et al. (2009) utilize pseudo labels from network extracting features and depth features. For online adaptation, Chen et al. (2022) utilize a contrastive method and utilize pseudo labels to ensure that same class negative samples are not used in contrastive loss optimization. For semi-supervised adaptation Zhou et al. (2021) utilize pseudo labels and use confidence as a criteria. In contrast to existing works, our method uses meta learning and is probabilistic in nature for test-time adaptation. + +# 4 EXPERIMENTS + +# 4.1 SETTINGS + +Five datasets. We demonstrate the effectiveness of our method on image classification and domain generalization settings. We evaluate our method on five widely used datasets in domain generalization. PACS (Li et al., 2017) consists of 7 classes and 4 domains: Photo, Art painting, Cartoon, and Sketch with 9991 samples. VLCS (Fang et al., 2013) consists of 5 classes and 4 domains: Pascal, LabelMe, Caltech, SUN with 10,729 samples. TerraIncognita (Beery et al., 2018) consists of 10 classes and 4 domains: Location 100, Location 38, Location 43 and Location 46 with 24,778 samples. We follow the training and validation split in (Li et al., 2017) and evaluate the model according to the “leave-one-out” protocol (Li et al., 2019; Carlucci et al., 2019). We also evaluate our method on the Rotated MNIST and Fashion-MNIST datasets following Piratla et al. (2020), where the images are rotated by different angles as different domains. We use the subsets with rotation angles from $1 5 ^ { \circ }$ to $7 5 ^ { \circ }$ in intervals of $1 5 ^ { \circ }$ as five source domains, and images rotated by $0 ^ { \circ }$ and $9 0 °$ as the target domains. + +Table 1: Benefits of our probabilistic test-time adaptation. The experiments are conducted on PACS based on ResNet-18. Our probabilistic formulation achieves better performance than the common test-time adaptation in both online and offline settings. The variational pseudo labels with meta adaptation further improve the overall performance. + +
MethodPhoto Art-paintingCartoonSketchMean
Online Adaptation
Test-time adaptation93.9178.5278.3374.3781.28
Our probabilistic test-time adaptation94.5580.0779.1474.2982.01
Our method95.50 ±0.282.90 ±0.481.28 ±0.574.11 ±0.783.45 ±0.2
Ofline Adaptation
Test-time adaptation94.6180.1379.3974.9682.27
Our probabilistic test-time adaptation95.1581.1580.2275.4282.99
Our method95.80 ±0.584.32 ±0.883.44 ±0.474.57 ±0.284.78 ±0.36
+ +Two adaptation settings. To demonstrate the effectiveness of our method, we evaluate on both offline and online test-time adaptation settings. Offline test-time adaptation assumes there are already unlabeled target data available for adaptation. To be close to real-world application where it is difficult to access the whole target set, we use different amounts of target data for offline adaptation. We adapt the model on the available target data and evaluate it on the entire target set without continuously fine-tuning on the entire target set. We also evaluate our method for online test-time adaptation (Iwasawa & Matsuo, 2021). In real-world application, as aforementioned, instead of accessing the entire target set, we usually obtain unlabeled target data in an online manner. To achieve continuous adaptation and improvement of the model on target data, we increment the target data iteratively and keep adapting and evaluating the model on the online target data. + +Implementation details We make use of ResNet-18 for all our experiments and ablation studies and report the accuracies on ResNet-50 for comparison as well. The backbones are pretrained on ImageNet same as the previous methods. During training, we use a varied learning rate throughout the model. We set the learning rate for the pretrained ResNet to 5e-5 and the learning rate of the variational module and classifiers as 1e-4 for all datasets. During test-time adaptation, we utilize a learning rate of 1e-4 for all layers. We intend to release the code on acceptance of this paper. + +# 4.2 ABLATION STUDIES + +Benefits of our probabilistic test-time adaptation We first investigate the effectiveness of our probabilistic formulation of test-time adaptation and its meta-learned variational pseudo labels. To demonstrate the benefits of the probabilistic formulation, we conduct test-time adaptation with eq. (3) and compare it with a common test-time adaptation tactic (Wang et al., 2021), as in eq. (1). As shown in Table 1, both adaptation with and without probabilistic formulation achieve good improvements over the ERM baseline. Our probabilistic test-time adaptation performs better than the common one on most target domains for both the online and offline adaptation settings, which demonstrates the benefits of modeling uncertainty during adaptation at test time. + +Moreover, we incorporate the distribution of pseudo labels into the probabilistic formulation, and further propose the variational pseudo labels with meta-adaptation based on the pseudo label distributions. As shown in the fourth and last row in Table 1, our method further improves the performance of both online and offline adaptation, demonstrating the effectiveness of the variational pseudo labels with meta-adaptation. With the probabilistic formulation, it is natural and simple to define the problem as a variational inference problem and solve the problem under the meta-learning framework. The results further demonstrate the benefits and importance of our probabilistic formulations of test-time adaptation. + +![](images/5f1e8beed356d96508882279d98cecaa5bd607ec35662863ed7fe67117443c5f.jpg) +Figure 2: Benefits of variational pseudo labels. The experiments are conducted on PACS with ResNet-18 as the backbone. We compare our variational pseudo labels with common pseudo labels with different amounts of adaptation data under the offline settings (left figure). Our variational pseudo labels achieve better overall accuracy consistently. We also provide the accuracy along with adaptation steps on art-painting in the right figure. Our method adapts faster and achieves better performance than using the common pseudo labels. + +Table 2: Ablation of meta-learning setting: We conduct the below experiments on PACS using ResNet-18. In the first framework, we do not use meta-learning across all stages. We observe that our method performs better on all domains comparatively. + +
SettingsPhotoArt-paintingCartoonSketchMean
W/o meta-learning94.76 ±1.080.7 ±0.578.87 ±0.768.39 ±0.580.68
W/ meta-learning95.80 ±0.584.32 ±0.883.44 ±0.474.57 1±0.284.78 ±0.36
+ +Benefits of variational pseudo-labels Based on the probabilistic formulation, we introduce variational pseudo labels to incorporate the target information of the neighboring target data for each target sample. To demonstrate the effectiveness of our variational pseudo label, we compare it with the normal pseudo labels drawn directly from the prediction distributions of source-trained models. We evaluate the methods in offline adaptation settings with different amounts of target data. As shown in Figure 2 (left), adaptation with our variational pseudo labels achieves better overall results than the normal pseudo labels consistently. We also provide the adaptation results along with adaptation steps in Figure 2 (right). Starting from the same baseline accuracy, the variational pseudo labels achieve faster adaptation than the normal pseudo labels. Adaptation with variational pseudo labels is less prone to saturating in performance, leading to better final accuracy. + +Benefits of meta learning We also investigate the importance of meta-learning in our method. For this experiment, we do not make meta-learning for source training and test-time adaptation and only use variational labels that have been generated for adaptation. We observe that meta-learning indeed helps in our formulation. Without meta-learning, it is difficult for the model to learn the ability to handle domain shifts. Thus, there is a significant decrease in accuracy as shown in Table 2. + +Offline adaptation with less target data In real applications, it is difficult to access the entire target set at once for adaptation. Therefore, we estimate our method under the offline test-time adaptation settings with different amounts of target data. As shown in Figure 3, the accuracy increases obviously with small numbers of target samples, e.g., $10 \%$ and $2 5 \%$ . However, the overall accuracy tends to saturate when keeping increasing the number of target data for adaptation. This indicates that our method is able to achieve good adaptation under the offline adaptation setting with even small amounts of target data, showing the applicability of the proposed method in practice. + +![](images/4ace7e96c5dee5a304cdfddae37ea63970d75b3c17b2e2336984b08e216dc43b.jpg) +Figure 3: Offine adaptation with less target data. The experiments are conducted on PACS using ResNet-18 averaged over five runs. Under the offline-adaptation setting we observe that with increments in the amount of test data samples the accuracy increases steadily for individual domains. + +Table 3: Comparisons on common DG datasets. The experiments are conducted on all datasets averaged over five runs. We provide the results of our method for the online setting. Our method also performs better than the state-of-the-art domain generalization methods across all datasets. + +
AlgorithmPACSVLCSTerraIncognita
ResNet-18ResNet-50ResNet-18ResNet-18
ERM79.2983.2174.8840.62
Standard DGMethods
MASF (Dou et al., 2019)81.082.7==
ER (Zhao et al., 2020)81.585.374.4
Test-time Adaptation Methods
Tent-BN (Wang et al., 2021)81.383.761.339.8
SHOT (Liang et al., 2020)82.484.165.233.5
T3A (Iwasawa& Matsuo, 2021)81.784.576.541.6
TAST (Jang & Chung,2022)81.984.177.342.6
Our Method83.4 ±0.485.5 ±0.377.8 ±0.846.2 ±0.4
+ +# 4.3 COMPARISONS + +To further demonstrate the effectiveness of our method, we compare our method with some stateof-the-art test-time adaptation methods and standard domain generalization methods. Table 3 shows the results on PACS, VLCS and TerraIncognita using ResNet-18. Compared with the other state-ofthe-art domain generalization methods and test-time adaptation methods with the online adaptation setting, our method performs better. On datasets such as PACS and TerraIncognita, we are better by state-of-the-art methods significantly. We also report results on the PACS dataset using ResNet-50 as the backbone, the performance of our method is competitive and better than most of the state-ofthe-art methods. We provide the detailed comparison in Appendix 5. + +# 5 CONCLUSION + +We propose to cast test-time adaptation as a probabilistic inference problem and model pseudolabels as distributions in the formulation. By modeling the uncertainty into the pseudo label distributions, the probabilistic formulation mitigates adaptation with inaccurate pseudo labels or predictions, which arises due to domain shifts and lead to misspecified models after adaptation. Based on the probabilistic formulation, we further propose variational pseudo labels under the meta-adaptation paradigm, which exposes the model to domain shifts and learns the ability to adapt with pseudo labels incorporating target information of the neighboring target samples. Ablation studies and further comparisons show the effectiveness of our method on five common domain generalization datasets. + +# REFERENCES + +Aous A Abdo, Markus Ackermann, Marco Ajello, WB Atwood, Magnus Axelsson, Luca Baldini, Jean Ballet, Guido Barbiellini, Denis Bastieri, Milan Battelino, et al. Measurement of the cosmic ray $\mathrm { e + + \ e \mathrm { - } }$ spectrum from 20 gev to 1 tev with the fermi large area telescope. Physical Review Letters, 102(18):181101, 2009. + +Ferran Alet, Maria Bauza, Kenji Kawaguchi, Nurullah Giray Kuru, Tomas Lozano-P ´ erez, and Leslie ´ Kaelbling. Tailoring: encoding inductive biases by optimizing unsupervised objectives at prediction time. Advances in Neural Information Processing Systems, 34:29206–29217, 2021. + +Sara Beery, Grant Van Horn, and Pietro Perona. Recognition in terra incognita. In Proceedings of the European conference on computer vision (ECCV), pp. 456–473, 2018. + +Fabio M Carlucci, Antonio D’Innocente, Silvia Bucci, Barbara Caputo, and Tatiana Tommasi. Domain generalization by solving jigsaw puzzles. In IEEE Conference on Computer Vision and Pattern Recognition, pp. 2229–2238, 2019. + +Dian Chen, Dequan Wang, Trevor Darrell, and Sayna Ebrahimi. Contrastive test-time adaptation. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 295–305, 2022. + +Qi Dou, Daniel C Castro, Konstantinos Kamnitsas, and Ben Glocker. Domain generalization via model-agnostic learning of semantic features. In Advances in Neural Information Processing Systems, 2019. + +Yingjun Du, Jun Xu, Huan Xiong, Qiang Qiu, Xiantong Zhen, Cees G M Snoek, and Ling Shao. Learning to learn with variational information bottleneck for domain generalization. In European Conference on Computer Vision, pp. 200–216, 2020. + +Yingjun Du, Xiantong Zhen, Ling Shao, and Cees G M Snoek. MetaNorm: Learning to normalize few-shot batches across domains. In International Conference on Learning Representations, 2021. + +Abhimanyu Dubey, Vignesh Ramanathan, Alex Pentland, and Dhruv Mahajan. Adaptive methods for real-world domain generalization. In IEEE Conference on Computer Vision and Pattern Recognition, pp. 14340–14349, 2021. + +Cian Eastwood, Ian Mason, Christopher KI Williams, and Bernhard Scholkopf. Source-free adap- ¨ tation to measurement shift via bottom-up feature restoration. arXiv preprint arXiv:2107.05446, 2021. + +Yuming Fang, Weisi Lin, Zhenzhong Chen, Chia-Ming Tsai, and Chia-Wen Lin. A video saliency detection model in compressed domain. IEEE transactions on circuits and systems for video technology, 24(1):27–38, 2013. + +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. + +Chelsea Finn, Kelvin Xu, and Sergey Levine. Probabilistic model-agnostic meta-learning. Advances in neural information processing systems, 31, 2018. + +Yaroslav Ganin and Victor Lempitsky. Unsupervised domain adaptation by backpropagation. In International conference on machine learning, pp. 1180–1189. PMLR, 2015. + +Robert Geirhos, Patricia Rubisch, Claudio Michaelis, Matthias Bethge, Felix A Wichmann, and Wieland Brendel. Imagenet-trained cnns are biased towards texture; increasing shape bias improves accuracy and robustness. arXiv preprint arXiv:1811.12231, 2018. + +Sachin Goyal, Mingjie Sun, Aditi Raghunathan, and Zico Kolter. Test-time adaptation via conjugate pseudo-labels. arXiv preprint arXiv:2207.09640, 2022. + +Ishaan Gulrajani and David Lopez-Paz. In search of lost domain generalization. In International Conference on Learning Representations, 2020. + +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. + +Xuefeng Hu, Gokhan Uzunbas, Sirius Chen, Rui Wang, Ashish Shah, Ram Nevatia, and Ser-Nam Lim. Mixnorm: Test-time adaptation through online normalization estimation. arXiv preprint arXiv:2110.11478, 2021. + +Yusuke Iwasawa and Yutaka Matsuo. Test-time classifier adjustment module for model-agnostic domain generalization. In Advances in Neural Information Processing Systems, volume 34, 2021. + +Minguk Jang and Sae-Young Chung. Test-time adaptation via self-training with nearest neighbor information. arXiv preprint arXiv:2207.10792, 2022. + +Bo Li, Yezhen Wang, Shanghang Zhang, Dongsheng Li, Kurt Keutzer, Trevor Darrell, and Han Zhao. Learning invariant representations and risks for semi-supervised domain adaptation. In IEEE Conference on Computer Vision and Pattern Recognition, pp. 1104–1113, 2021. + +Da Li, Yongxin Yang, Yi-Zhe Song, and Timothy M Hospedales. Deeper, broader and artier domain generalization. In IEEE International Conference on Computer Vision, pp. 5542–5550, 2017. + +Da Li, Jianshu Zhang, Yongxin Yang, Cong Liu, Yi-Zhe Song, and Timothy M Hospedales. Episodic training for domain generalization. In IEEE International Conference on Computer Vision, pp. 1446–1455, 2019. + +Haoliang Li, YuFei Wang, Renjie Wan, Shiqi Wang, Tie-Qiang Li, and Alex C Kot. Domain generalization for medical imaging classification with linear-dependency regularization. arXiv preprint arXiv:2009.12829, 2020. + +Hengduo Li, Zuxuan Wu, Abhinav Shrivastava, and Larry S Davis. Rethinking pseudo labels for semi-supervised object detection. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 36, pp. 1314–1322, 2022. + +Jian Liang, Dapeng Hu, and Jiashi Feng. Do we really need to access the source data? source hypothesis transfer for unsupervised domain adaptation. In International Conference on Machine Learning, pp. 6028–6039. PMLR, 2020. + +Yuejiang Liu, Parth Kothari, Bastien van Delft, Baptiste Bellot-Gurlet, Taylor Mordan, and Alexandre Alahi. Ttt $^ { + + }$ : When does self-supervised test-time training fail or thrive? In Advances in Neural Information Processing Systems, volume 34, 2021. + +Mingsheng Long, Yue Cao, Jianmin Wang, and Michael Jordan. Learning transferable features with deep adaptation networks. In International Conference on Machine Learning, pp. 97–105. PMLR, 2015. + +Zhihe Lu, Yongxin Yang, Xiatian Zhu, Cong Liu, Yi-Zhe Song, and Tao Xiang. Stochastic classifiers for unsupervised domain adaptation. In IEEE Conference on Computer Vision and Pattern Recognition, pp. 9111–9120, 2020. + +Takeru Miyato, Shin-ichi Maeda, Masanori Koyama, and Shin Ishii. Virtual adversarial training: a regularization method for supervised and semi-supervised learning. IEEE transactions on pattern analysis and machine intelligence, 41(8):1979–1993, 2018. + +Saeid Motiian, Marco Piccirilli, Donald A Adjeroh, and Gianfranco Doretto. Unified deep supervised domain adaptation and generalization. In IEEE International Conference on Computer Vision, pp. 5715–5725, 2017. + +Krikamol Muandet, David Balduzzi, and Bernhard Scholkopf. Domain generalization via invariant ¨ feature representation. In International Conference on Machine Learning, pp. 10–18. PMLR, 2013. + +Shuaicheng Niu, Jiaxiang Wu, Yifan Zhang, Yaofo Chen, Shijian Zheng, Peilin Zhao, and Mingkui Tan. Efficient test-time model adaptation without forgetting. arXiv preprint arXiv:2204.02610, 2022. + +Hieu Pham, Zihang Dai, Qizhe Xie, and Quoc V Le. Meta pseudo labels. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 11557–11568, 2021. + +Vihari Piratla, Praneeth Netrapalli, and Sunita Sarawagi. Efficient domain generalization via common-specific low-rank decomposition. In International Conference on Machine Learning, pp. 7728–7738. PMLR, 2020. + +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. + +Mamshad Nayeem Rizve, Kevin Duarte, Yogesh S Rawat, and Mubarak Shah. In defense of pseudolabeling: An uncertainty-aware pseudo-label selection framework for semi-supervised learning. arXiv preprint arXiv:2101.06329, 2021. + +Kate Saenko, Brian Kulis, Mario Fritz, and Trevor Darrell. Adapting visual category models to new domains. In European Conference on Computer Vision, pp. 213–226, 2010. + +Steffen Schneider, Evgenia Rusak, Luisa Eck, Oliver Bringmann, Wieland Brendel, and Matthias Bethge. Improving robustness against common corruptions by covariate shift adaptation. Advances in Neural Information Processing Systems, 33:11539–11551, 2020. + +Kendrick Shen, Robbie M Jones, Ananya Kumar, Sang Michael Xie, Jeff Z HaoChen, Tengyu Ma, and Percy Liang. Connect, not collapse: Explaining contrastive learning for unsupervised domain adaptation. In International Conference on Machine Learning, pp. 19847–19878. PMLR, 2022. + +Rui Shu, Hung H Bui, Hirokazu Narui, and Stefano Ermon. A dirt-t approach to unsupervised domain adaptation. arXiv preprint arXiv:1802.08735, 2018. + +Yu Sun, Xiaolong Wang, Zhuang Liu, John Miller, Alexei Efros, and Moritz Hardt. Test-time training with self-supervision for generalization under distribution shifts. In International Conference on Machine Learning, pp. 9229–9248. PMLR, 2020. + +Eric Tzeng, Judy Hoffman, Kate Saenko, and Trevor Darrell. Adversarial discriminative domain adaptation. In IEEE Conference on Computer Vision and Pattern Recognition, pp. 7167–7176, 2017. + +Thomas Varsavsky, Mauricio Orbes-Arteaga, Carole H Sudre, Mark S Graham, Parashkev Nachev, and M Jorge Cardoso. Test-time unsupervised domain adaptation. In International Conference on Medical Image Computing and Computer-Assisted Intervention, pp. 428–436. Springer, 2020. + +Dequan Wang, Evan Shelhamer, Shaoteng Liu, Bruno Olshausen, and Trevor Darrell. Tent: Fully test-time adaptation by entropy minimization. In International Conference on Learning Representations, 2021. + +Qin Wang, Olga Fink, Luc Van Gool, and Dengxin Dai. Continual test-time domain adaptation. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 7201–7211, 2022. + +Andrew G Wilson and Pavel Izmailov. Bayesian deep learning and a probabilistic perspective of generalization. Advances in neural information processing systems, 33:4697–4708, 2020. + +Zehao Xiao, Xiantong Zhen, Ling Shao, and Cees G M Snoek. Learning to generalize across domains on single test samples. In International Conference on Learning Representations, 2022. + +Qizhe Xie, Minh-Thang Luong, Eduard Hovy, and Quoc V Le. Self-training with noisy student improves imagenet classification. In Proceedings of the IEEE/CVF conference on computer vision and pattern recognition, pp. 10687–10698, 2020. + +I Zeki Yalniz, Herve J ´ egou, Kan Chen, Manohar Paluri, and Dhruv Mahajan. Billion-scale semi- ´ supervised learning for image classification. arXiv preprint arXiv:1905.00546, 2019. + +Marvin Zhang, Sergey Levine, and Chelsea Finn. Memo: Test time robustness via adaptation and augmentation. arXiv preprint arXiv:2110.09506, 2021. + +Shanshan Zhao, Mingming Gong, Tongliang Liu, Huan Fu, and Dacheng Tao. Domain generalization via entropy regularization. In Advances in Neural Information Processing Systems, volume 33, 2020. + +Aurick Zhou and Sergey Levine. Training on test data with bayesian adaptation for covariate shift. In Advances in Neural Information Processing Systems, 2021. + +Kaiyang Zhou, Yongxin Yang, Yu Qiao, and Tao Xiang. Domain generalization with mixstyle. In International Conference on Learning Representations, 2020. + +Kaiyang Zhou, Yongxin Yang, Yu Qiao, and Tao Xiang. Mixstyle neural networks for domain generalization and adaptation. arXiv preprint arXiv:2107.02053, 2021. + +Kaiyang Zhou, Ziwei Liu, Yu Qiao, Tao Xiang, and Chen Change Loy. Domain generalization: A survey. IEEE Transactions on Pattern Analysis and Machine Intelligence, 2022. + +Yang Zou, Zhiding Yu, Xiaofeng Liu, BVK Kumar, and Jinsong Wang. Confidence regularized self-training. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pp. 5982–5991, 2019. + +Yuliang Zou, Zizhao Zhang, Han Zhang, Chun-Liang Li, Xiao Bian, Jia-Bin Huang, and Tomas Pfister. Pseudoseg: Designing pseudo labels for semantic segmentation. arXiv preprint arXiv:2010.09713, 2020. + +# A DETAILED FORMULATION + +We start the objective function from $p ( \mathbf { y } _ { t ^ { \prime } } | \mathbf { x } _ { t ^ { \prime } } , \pmb { \theta } _ { s ^ { \prime } } , \mathbf { X } _ { t ^ { \prime } } )$ . Here we provide the detailed generating process of the formulation: + +$$ +p ( { \mathbf { y } } _ { t ^ { \prime } } | { \mathbf { x } } _ { t ^ { \prime } } , \pmb { \theta } _ { s ^ { \prime } } , { \mathbf { X } } _ { t ^ { \prime } } ) = \int p ( { \mathbf { y } } _ { t ^ { \prime } } | { \mathbf { x } } _ { t ^ { \prime } } , \pmb { \theta } _ { t ^ { \prime } } ) p ( \pmb { \theta } _ { t ^ { \prime } } | { \mathbf { x } } _ { t ^ { \prime } } , \pmb { \theta } _ { s ^ { \prime } } , { \mathbf { X } } _ { t ^ { \prime } } ) d \pmb { \theta } _ { t ^ { \prime } } . +$$ + +We then introduce the pseudo labels $\hat { \mathbf { y } } _ { t ^ { \prime } }$ as the latent variable into eq. (15) and derive it as: + +$$ +p ( \mathbf { y } _ { t ^ { \prime } } | \mathbf { x } _ { t ^ { \prime } } , \mathbf { \theta } _ { s ^ { \prime } } , \mathbf { X } _ { t ^ { \prime } } ) = \int p ( \mathbf { y } _ { t ^ { \prime } } | \mathbf { x } _ { t ^ { \prime } } , \mathbf { \theta } _ { t ^ { \prime } } ) \int p ( \theta _ { t ^ { \prime } } | \hat { \mathbf { y } } _ { t ^ { \prime } } , \mathbf { x } _ { t ^ { \prime } } , \mathbf { \theta } _ { s ^ { \prime } } ) p ( \hat { \mathbf { y } } _ { t ^ { \prime } } | \mathbf { x } _ { t ^ { \prime } } , \mathbf { \theta } _ { s ^ { \prime } } , \mathbf { X } _ { t ^ { \prime } } ) d \hat { \mathbf { y } } _ { t ^ { \prime } } d \theta _ { t ^ { \prime } } . +$$ + +Theoretically, the distribution $p ( \pmb \theta _ { t ^ { \prime } } )$ is obtained by $p ( \pmb { \theta } _ { t ^ { \prime } } | \mathbf { y } _ { t ^ { \prime } } , \mathbf { x } _ { t ^ { \prime } } , \pmb { \theta } _ { s ^ { \prime } } ) \propto p ( \mathbf { y } _ { t } | \mathbf { x } _ { t } , \pmb { \theta } _ { t } ) p ( \pmb { \theta } _ { t } | \pmb { \theta } _ { s } )$ , where $p ( \pmb \theta _ { t } | \mathbf { \bar { \theta } } _ { s } )$ is the prior distribution. To simplify the formulation, we approximate the integration of $p ( \pmb \theta _ { t ^ { \prime } } )$ by the maximum a posterior (MAP) value of $\pmb { \theta } _ { t ^ { \prime } } ^ { \ast }$ . We obtain the MAP value by training the model $\pmb \theta$ with inputs $\mathbf { x } _ { t ^ { \prime } }$ and pseudo labels $\mathbf { y } _ { t ^ { \prime } }$ starting from $\pmb { \theta } _ { s ^ { \prime } }$ . The formulation then is derived as: + +$$ +p ( \mathbf { y } _ { t ^ { \prime } } | \mathbf { x } _ { t ^ { \prime } } , \mathbf { \boldsymbol { \theta } } _ { s ^ { \prime } } , \mathbf { X } _ { t ^ { \prime } } ) = \int p ( \mathbf { y } _ { t ^ { \prime } } | \mathbf { x } _ { t ^ { \prime } } , \mathbf { \boldsymbol { \theta } } _ { t ^ { \prime } } ^ { * } ) \int p ( \hat { \mathbf { y } } _ { t ^ { \prime } } | \mathbf { x } _ { t ^ { \prime } } , \mathbf { \boldsymbol { \theta } } _ { s ^ { \prime } } , \mathbf { X } _ { t ^ { \prime } } ) d \hat { \mathbf { y } } _ { t ^ { \prime } } . +$$ + +To obtain better pseudo labels $\hat { \mathbf { y } } _ { t ^ { \prime } }$ , we further introduce the latent variable $\mathbf { w } _ { t ^ { \prime } }$ into eq. (17) and a variational posterior of the joint distribution $q \big ( \hat { \mathbf { y } } _ { t ^ { \prime } } , \mathbf { w } _ { t ^ { \prime } } \big )$ . The formulation is then derived as: + +$$ +\begin{array} { r l } & { p ( { \mathbf { y } _ { t ^ { \prime } } } | { \mathbf { x } _ { t ^ { \prime } } } , \boldsymbol { \theta } _ { s ^ { \prime } } , { \mathbf { X } _ { t ^ { \prime } } } ) } \\ & { = \displaystyle \int \int p ( { \mathbf { y } _ { t ^ { \prime } } } | { \mathbf { x } _ { t ^ { \prime } } } , \boldsymbol { \theta } _ { t ^ { \prime } } ^ { * } ) \int p ( \hat { { \mathbf { y } _ { t ^ { \prime } } } } , { \mathbf { w } _ { t ^ { \prime } } } | { \mathbf { x } _ { t ^ { \prime } } } , \boldsymbol { \theta } _ { s ^ { \prime } } , { \mathbf { X } _ { t ^ { \prime } } } ) d \hat { { \mathbf { y } _ { t ^ { \prime } } } } d { \mathbf { w } _ { t ^ { \prime } } } } \\ & { = \displaystyle \int \int p ( { \mathbf { y } _ { t ^ { \prime } } } | { \mathbf { x } _ { t ^ { \prime } } } , \boldsymbol { \theta } _ { t ^ { \prime } } ^ { * } ) \int \frac { q ( \hat { { \mathbf { y } _ { t ^ { \prime } } } } , { \mathbf { w } _ { t ^ { \prime } } } | { \mathbf { x } _ { t ^ { \prime } } } , \boldsymbol { \theta } _ { s ^ { \prime } } , { \mathbf { X } _ { t ^ { \prime } } } ) } { p ( \hat { { \mathbf { y } _ { t ^ { \prime } } } } , { \mathbf { w } _ { t ^ { \prime } } } | { \mathbf { x } _ { t ^ { \prime } } } , \boldsymbol { \theta } _ { s ^ { \prime } } , { \mathbf { X } _ { t ^ { \prime } } } ) } p ( \hat { { \mathbf { y } _ { t ^ { \prime } } } } , { \mathbf { w } _ { t ^ { \prime } } } | { \mathbf { x } _ { t ^ { \prime } } } , \boldsymbol { \theta } _ { s ^ { \prime } } , { \mathbf { X } _ { t ^ { \prime } } } ) d \hat { { \mathbf { y } _ { t ^ { \prime } } } } d { \mathbf { w } _ { t ^ { \prime } } } , } \end{array} +$$ + +where $q ( \hat { \mathbf { y } } _ { t ^ { \prime } } , \mathbf { w } _ { t ^ { \prime } } | \mathbf { x } _ { t ^ { \prime } } , \pmb { \theta } _ { s ^ { \prime } } , \mathbf { X } _ { t ^ { \prime } } , \mathbf { Y } _ { t ^ { \prime } } )$ and $p \big ( \hat { \mathbf { y } } _ { t ^ { \prime } } , \mathbf { w } _ { t ^ { \prime } } \big | \mathbf { x } _ { t ^ { \prime } } , \pmb { \theta } _ { s ^ { \prime } } , \mathbf { X } _ { t ^ { \prime } } \big )$ denote the prior and posterior distributions, respectively. + +# B IMPLEMENTATION DETAILS + +Our train setup follows Iwasawa & Matsuo (2021). We use a batch size of 70 and train our method using the ERM algorithm Gulrajani & Lopez-Paz (2020). As stated, our backbones such as ResNet18 and ResNet-34 are pretrained on ImageNet same as the previous methods.During our training, the model with highest validation accuracy is selected for adaptation on the target domain. We use similar settings for all Domain Generalization benchmarks that have been reported in the paper. We train all our models on NVIDIA Tesla 1080Ti GPU. In Table 8 we report the runtime required for test-time adaptation. We observe that our method is comparable to methods that are not optimization free such as SHOT and PL. We also in Table 7 report the amount of time consumed during source training. + +# C DETAILED EXPERIMENTAL RESULTS + +Detailed experimental results. In Table 4 we report our detailed performance and comparison to existing methods on PACS with both ResNet-18 and ResNet-50 as the backbone. We observe that our method shows an improvement in accuracy compared to other methods especially on ”ArtPainting”, ”Cartoon” and ”Photo” Domains. The results show the benefits of using Variational Pseudo labels for adaptation. + +We also conduct experiments on rotated MNIST and rotated Fashion-MNIST for comparison as shown in Table 5. We follow the settings in Piratla et al. (2020) and use ResNet-18 as the backbone. The conclusion is similar to that in PACS. Our method achieves better performance than both the non-adaptive domain generalization methods and adaptation methods. + +Table 4: Comparisons on PACS. The experiments are conducted on PACS averaged over five runs. We provide the results of our method under both the online and offline adaptation settings. Our method is better than other methods on both settings with different backbones. Our method also performs better than the state-of-the-art domain generalization methods. + +
AlgorithmPhotoArt-painting Cartoon SketchMean
ResNet-18
Online adaptation
Tent-BN (Wang et al., 2021)93.9 ±0.378.5 ±0.878.3 ±0.4 74.4 ±0.2881.3 ±0.3
T3A(Iwasawa & Matsuo, 2021)94.7 ±0.580.4 ±0.775.2 ±0.476.5 ±0.281.7 ±0.4
TAST (Jang & Chung,2022)96.4 ±0.280.6 ±0.578.3 ±1.072.5 ±0.881.9 ±0.4
SHOT (Liang et al., 2020)96.2 ±0.381.1 ±0.979.7 ±0.972.5 ±2.082.4 ±0.6
Our Method95.5 ±0.282.9 ±0.481.3 ±0.574.1 ±0.783.4 ±0.2
Offline adaptation
Tent-BN (Wang et al., 2021)94.6 ±0.280.1 ±0.979.4 ±0.8 75.0 ±1.082.3 ±0.3
Our Method95.8 ±0.5 84.3 ±0.883.4 ±0.4 74.6 ±0.2 84.8 ±0.4
ResNet-50
Online adaptation
Tent-BN (Wang et al., 2021)96.0 ±0.4 84.9 ±0.479.8 ±0.6 75.7 ±0.7 84.1 ±0.3
T3A (Iwasawa & Matsuo, 2021)96.4 ±0.286.0 ±0.680.3 ±0.975.2 ±1.584.5 ±0.3
SHOT (Liang et al., 2020)96.5 ±0.584.6 ±1.780.1 ±1.374.8 ±2.984.1 ±1.0
TAST (Jang & Chung, 2022)96.9 ±0.5883.8 ±0.579.1 ±0.5 76.4 ±0.5884.1 ±0.5
Our Method96.9 ±0.2 87.0 ±0.483.8 ±0.3 74.3 ±0.285.5 ±0.3
Offline adaptation
Tent-BN (Wang et al., 2021)96.5 ±0.2 85.8 ±0.381.5 ±0.7 76.9 ±0.7 85.1 ±0.3
Our Method97.6 ±0.2 87.3 ±0.484.2 ±0.2 75.3 ±0.3 86.1 ±0.2
+ +Table 5: Comparison on rotated MNIST and Fashion-MNIST. The models are evaluated on the test sets of MNIST and Fashion-MNIST with rotation angles of $0 ^ { \circ }$ and $9 0 °$ . Our method performs better than both non-adaptive domain generalization methods (Dou et al., 2019; Piratla et al., 2020) and adaptive methods (Wang et al., 2021; Xiao et al., 2022). + +
MNISTFashion-MNIST
Dou et al. (2019)93.272.4
Piratla et al. (2020)94.778.0
Wang et al. (2021)95.378.9
Xiao et al. (2022)95.880.8
Our method95.9 ±0.182.4 ±0.2
+ +Extra ablations We also provide extra ablation studies on the pseudo label generation and adaptation with our variational pseudo labels. We directly make predictions using the variational pseudo labels that are generated by sampling from the pseudo label distributions at test time. As shown in Table 6, the predictions based on the pseudo-label distributions are better than the ERM baseline, demonstrating that our variational pseudo labels are better than the original pseudo labels. Moreover, after adapting the model parameters by our variational pseudo labels, the performance further improves obviously. + +Table 6: Investigating by evaluating directly using the pseudo label distributions. We conduct the below experiments on PACS using ResNet-18. Our method that adapts the models with variational pseudo labels performs better than the prediction by directly sampling from the pseudo label distributions. + +
SettingsPhotoArt-paintingCartoonSketchMean
Prediction by pseudo label distributions95.97 ±1.081.23 ±0.579.19 ±0.773.22 ±0.582.40±0.55
Our method95.80 ±0.584.32 ±0.883.44 ±0.474.57 ±0.284.78 ±0.36
+ +Table 7: Runtime required for source training on PACS using ResNet-18 as a backbone network. The proposed method has larger time costs during training due to the meta-learning strategy but introduces few extra parameters. + +
ParametersTime for 10000 iterations
ERM11.18M6.5 hours
Our method11.96M14.6 hours
+ +Table 8: Runtime averaged for datasets using ResNet-18 as a backbone network. The proposed method has similar or even better time costs at test time with the other test-time adaptation methods. + +
VLCSPACSTerra-Incognita
Tent (Wang et al., 2021)7m 28s3m 16s10m 34s
Tent-BN (Wang et al.,2021)2m 8s33s2m 58s
SHOT (Liang et al., 2020)8m 9s4m 22s12m 40s
T3A (Iwasawa & Matsuo,2021)2m 9s33s2m 59s
TAST (Jang & Chung, 2022)10m 34s9m 30s26m 14s
Our method2m 20s5m 33s14m 30s
+ +Time cost analyses. We also provide the time cost of our method in both the training (Table 7) and inference stage (Table 8). As we utilize the meta-learning strategy to learn the ability to handle domain shifts during training, the time cost during training is larger than the ERM baseline. Moreover, compared with the ERM baseline, our variational pseudo-label learning and meta-learning framework only introduce a few parameters. Since the meta-learning strategy only complicates the training process, our method has similar runtime in inference compared with the other test-time adaptation methods, e.g., Tent (Wang et al., 2021) and source-free domain adaptation methods, e.g., SHOT (Liang et al., 2020). \ No newline at end of file diff --git a/md/dev/jUdZCcoOu3/jUdZCcoOu3.md b/md/dev/jUdZCcoOu3/jUdZCcoOu3.md new file mode 100644 index 0000000000000000000000000000000000000000..1557974cb83046c469a90abb45ac15768b7cd816 --- /dev/null +++ b/md/dev/jUdZCcoOu3/jUdZCcoOu3.md @@ -0,0 +1,267 @@ +# RAPHAEL: Text-to-Image Generation via Large Mixture of Diffusion Paths + +Zeyue Xue∗ The University of Hong Kong xuezeyue@connect.hku.hk + +Guanglu Song∗ SenseTime Research songguanglu@sensetime.com + +Qiushan Guo The University of Hong Kong qsguo@cs.hku.hk + +Boxiao Liu SenseTime Research liuboxiao@sensetime.com + +Zhuofan Zong SenseTime Research zongzhuofan@gmail.com + +Yu Liu† ‡ SenseTime Research liuyuisanai@gmail.com + +Ping Luo‡ The University of Hong Kong Shanghai AI Laboratory pluo@cs.hku.hk + +“When one is painting one does not think.” + +— Raffaello Sanzio da Urbino + +# Abstract + +Text-to-image generation has recently witnessed remarkable achievements. We introduce a text-conditional image diffusion model, termed RAPHAEL, to generate highly artistic images, which accurately portray the text prompts, encompassing multiple nouns, adjectives, and verbs. This is achieved by stacking tens of mixtureof-experts (MoEs) layers, i.e., space-MoE and time-MoE layers, enabling billions of diffusion paths (routes) from the network input to the output. Each path intuitively functions as a “painter” for depicting a particular textual concept onto a specified image region at a diffusion timestep. Comprehensive experiments reveal that RAPHAEL outperforms recent cutting-edge models, such as Stable Diffusion, ERNIE-ViLG 2.0, DeepFloyd, and DALL-E 2, in terms of both image quality and aesthetic appeal. Firstly, RAPHAEL exhibits superior performance in switching images across diverse styles, such as Japanese comics, realism, cyberpunk, and ink illustration. Secondly, a single model with three billion parameters, trained on 1, 000 A100 GPUs for two months, achieves a state-of-the-art zero-shot FID score of 6.61 on the COCO dataset. Furthermore, RAPHAEL significantly surpasses its counterparts in human evaluation on the ViLG-300 benchmark. We believe that RAPHAEL holds the potential to propel the frontiers of image generation research in both academia and industry, paving the way for future breakthroughs in this rapidly evolving field. More details can be found on a webpage: https: //raphael-painter.github.io/§. + +A parrot with a pearl earring, Vermeer style. + +A car playing soccer, digital art. + +A Pikachu with an angry expression and red eyes, with lightning around it, hyper realistic style. + +There are five cars in the street. + +Street shot of a fashionable Chinese lady in Shanghai, wearing black high­waisted trousers. + +Moonlight Maiden, cute girl in school uniform, long white hair, standing under the moon, celluloid style, Japanese manga style. + +Half human, half robot, repaired human, human flesh warrior, mech display, man in mech, cyberpunk. + +![](images/a2f8a3a6fc697dd6897623703a923c2f8825721e6032be3ac87ea412077c8f16.jpg) +Figure 1: Comparisons of RAPHAEL with recent representative generators, Stable Diffusion XL [2], DeepFloyd, DALL-E 2 [3], and ERNIE-ViLG 2.0 [5]. They are given the same prompts, where the words that the human artists yearn to preserve within the generated images are highlighted in red. These images are not cherry-picked. We see that previous models often fail to preserve the desired concepts. For example, only the RAPHAEL-generated images precisely reflect the prompts such as “pearl earring, Vermeer”, “playing soccer”, “five cars”, “black high-waisted trouser”, “white hair, manga, moon”, and “sign, RAPHAEL”, while other models generate compromised results. Better zoom in $200 \%$ . + +A sign that says RAPHAEL. + +# 1 Introduction + +Recent advancements in text-to-image generators, such as Imagen [1], Stable Diffusion [2], DALLE 2 [3], eDiff-I [4], and ERNIE-ViLG 2.0 [5], have yielded remarkable success and found wide applications in computer graphics, culture and art, and the generation of medical and biological data. + +Despite the substantial progress made in text-to-image diffusion models [1, 2, 3, 4, 5], there remains a pressing need for research to further achieve more precise alignment between text and image. As illustrated in Fig.1, existing models often fail to adequately preserve textual concepts within the generated images. This is primarily due to the reliance on a classic cross-attention mechanism for integrating text descriptions into visual representations, resulting in relatively coarse control of the diffusion process, and leading to compromised results. + +To address this issue, we introduce RAPHAEL, a text-to-image generator, which yields images with superior artistry and fidelity compared to prior work, as demonstrated in Fig.2. RAPHAEL, an acronym that stands for “distinct image regions align with different text phases in attention learning”, offers an appealing benefit not found in existing approaches. + +Specifically, we observe that different text concepts influence distinct image regions during the generation process [6], and the conventional cross-attention layer often struggles to preserve these varying concepts adequately in an image. To mitigate this issue, we employ a diffusion model stacking tens of mixture-of-experts (MoE) layers [7, 8], including both space-MoE and time-MoE layers. Concretely, the space-MoE layers are responsible for depicting different concepts in specific image regions, while the time-MoE layers focus on painting these concepts at different diffusion timesteps. + +This configuration leads to billions of diffusion paths from the network input to the output. Naturally, each path can act as a “painter” responsible for rendering a particular concept to an image region at a specific timestep. The result is a more precise alignment between text tokens and image regions, enabling the generated images that accurately represent the associated text prompt. This approach sets RAPHAEL apart from existing models and even sheds light on future studies of the explainability of the generation process. Additionally, we propose an edge-supervised learning module to further enhance the image quality and aesthetic appeal of the generated images. + +Extensive experiments demonstrate that RAPHAEL outperforms preceding approaches, such as Stable Diffusion, ERNIE-ViLG 2.0, DeepFloyd, and DALL-E 2. (1) RAPHAEL exhibits superior performance in switching images across diverse styles, such as Japanese comics, realism, cyberpunk, and ink illustration. (2) RAPHAEL establishes a new state-of-the-art with a zero-shot FID-30k score of 6.61 on the COCO dataset. (3) RAPHAEL, a single model with three billion parameters trained on 1, 000 A100 GPUs, significantly surpasses its counterparts in human evaluation on the ViLG-300 benchmark. + +The contributions of this work are three-fold: (i) We propose a novel text-to-image generator, RAPHAEL, which, through the implementation of several carefully-designed techniques, generates images that more accurately reflect textual prompts than previous works. (ii) We thoroughly explore RAPHAEL’s potential for switching images in diverse styles, such as Japanese comics, realism, cyberpunk, and ink illustration, and for extension using LoRA [9], ControlNet [10], and SR-GAN [11]. (iii) We will release a programming API for RAPHAEL to the public. We believe that RAPHAEL holds the potential to advance the frontiers of image generation in both academia and industry, paving the way for future breakthroughs in this rapidly evolving field. + +# 2 Notation and Preliminary + +We present the necessary notations and the Denoising Diffusion Probabilistic Model (DDPM) [12] for text-to-image generation. Given a collection of $N$ images, denoted as $\{ { \mathbf { x } } _ { i } \} _ { i = 1 } ^ { N }$ , the aim is to learn a generative model, $p ( \mathbf { x } )$ , that is capable of accurately representing the underlying distribution. + +In forward diffusion, Gaussian noise is progressively introduced into the source images. At an arbitrary timestep $t$ , it is possible to directly sample from the Gaussian distribution following the $T$ -step noise schedule $\{ \alpha _ { t } \} _ { t = 1 } ^ { T }$ , without iterative forward sampling. Consequently, the noisy image at√ √ timestep $t$ , denoted as $\mathbf { x } _ { t }$ , can be expressed as $\mathbf { x } _ { t } = \sqrt { 1 - \bar { \alpha } _ { t } } \mathbf { x } _ { 0 } + \sqrt { \bar { \alpha } _ { t } } \epsilon _ { t }$ , where $\textstyle { \bar { \alpha } } _ { t } = \prod _ { i = 1 } ^ { t } \alpha _ { i }$ . In this expression, $\mathbf { x } _ { \mathrm { 0 } }$ represents the source image, while $\epsilon _ { t } \sim \mathcal { N } ( 0 , I )$ indicates the Gaussian noise at step $t$ . In the reverse process, a denoising neural network, denoted as $D _ { \theta } ( \cdot )$ , is employed to estimate the additive Gaussian noise. The optimization of this network is achieved by minimizing the loss function, $\mathcal { L } _ { \mathrm { d e n o i s e } } = \mathbb { E } _ { t , \mathbf { x } _ { 0 } , \epsilon \sim \mathcal { N } ( 0 , I ) } \bigg [ \big \| \epsilon - D _ { \theta } \left( \mathbf { x } _ { t } , t \right) \big \| _ { 2 } ^ { 2 } \bigg ] .$ . + +By employing the Bayes’ theorem, it is feasible to iteratively estimate the image at timestep $t \mathrm { ~ - ~ } 1$ through sampling from the posterior distribution, $\dot { p _ { \theta } } ( \mathbf { x } _ { t - 1 } | \mathbf { x } _ { t } )$ . We have $\begin{array} { r l } { \mathbf { x } _ { t - 1 } } & { { } = } \end{array}$ + +![](images/103cff2a1086c691b1fa39a2f92b00a4189a08d22cdc469b80564775e88e27c7.jpg) +Harvest of vegetables in a wooden box near the beds vegetables grow naturally, summer light background, backlight and sun rays, clean sharp focus. + +![](images/f1d1d702efc7cae5ace21069a508419e070bffa1b6c7f9f03523ee94ed9608c7.jpg) +Chinese illustration, oriental landscape painting, above super wide angle, magical, romantic, detailed, colorful, multidimensional paper kirigami craft. + +![](images/8c22b23f41c41a3db87514fa2d53651969230fb5745740b746643e18f8491719.jpg) +Photography closeup portrait of an adorable rusty broken­down steampunk robot covered in budding vegetation, surrounded by tall grass, misty futuristic sci­fi forest environment. + +![](images/c9b9417a9130c2a30dc562d0c32ae0cd7f8c973127595a10e23224d06105acab.jpg) +A cute little matte low poly isometric Zelda Breath of the wild forest island, waterfalls, soft shadows, trending on Artstation, 3d render, monument valley, fez video game. + +![](images/0de95f2f078d83a74834052636cbadb82f8b444738dc5a73df8ba25eb3006f54.jpg) +The Goddess of high fashion, impressionistic line art, contrasting earth tones, vibrant, pen and ink illustration, ink splatter, abstract expressionism superimposed onto majestic space queen. + +![](images/529f722450b3a987666f2519154808147053fb1417f875e420c3061e5dea63d2.jpg) + +![](images/074f263c149adaf34d2c244c4885de56e66ff45bace91eaf1ec3592af902df42.jpg) +The Caped Crusader, Gotham skyline, rooftop, mysterious, powerful, nighttime, mixed media, expressionism, dark tones, high contrast, in the style of comic book artist Frank Miller, modern, gritty and textured, collage technique. + +A beautiful woman dressed in a dress made of autumn leaves in the forest, photography, natural lighting, high detail. + +![](images/b430f958ee4f179b1a82764409f380b4efc5829abc9b1f4bcccd0779ea93eb60.jpg) +A wizard by Q Hayashida in the style of Dorohedoro for Elden Ring, with biggest most intricate sword, on sunlit battlefield, breath of the wild, striking illustration. + +![](images/f99e9c45e5c62f39b4f33dc334c7f2e8382330b6ad07d7f976e75816f1f690de.jpg) +Milkyway in a glass bottle, 4k, unreal engine, octane render. +Figure 2: These examples show that RAPHAEL can generate artistic images with varying text prompts across various styles. The synthesized images have rich details and semantics. The prompts were written by human artists without cherry-picking. + +$\begin{array} { r } { \frac { 1 } { \sqrt { \alpha _ { t } } } \left( \mathbf { x } _ { t } - \frac { 1 - \alpha _ { t } } { \sqrt { 1 - \bar { \alpha } _ { t } } } D _ { \theta } \left( \mathbf { x } _ { t } , t \right) \right) + \sigma _ { t } z } \end{array}$ here $\sigma _ { t }$ signifies the standard deviation of the newly injected noise into the image at each step, and $z$ + +In essence, the denoising neural network estimates the score function at varying time steps, thereby progressively recovering the structure of the image distribution. The fundamental insight provided by the DDPM lies in the fact that the perturbation of data points with noise serves to populate regions of low data density, ultimately enhancing the accuracy of estimated scores. This results in stable training and sampling. + +U-Net with Text Prompts. The denoising network is commonly implemented using a U-Net [13] architecture, as depicted in Fig.8 in Appendix 7.3. To incorporate textual prompts (denoted by y) into the U-Net, a text encoder neural network, $E _ { \theta } ( \mathbf { y } )$ , is employed to extract the textual representation. + +![](images/3c4a95798c9118dcb4a57b39f0d32164fd6112a52cfdc1c66e8b2eef7752944a.jpg) +Figure 3: Framework of RAPHAEL. (a) Each block contains four primary components including a selfattention layer, a cross-attention layer, a space-MoE layer, and a time-MoE layer. The space-MoE is responsible for depicting different text concepts in specific image regions, while the time-MoE handles different diffusion timesteps. Each block uses edge-supervised cross-attention learning to further improve image quality. (b) shows details of space-MoE. For example, given a prompt “a furry bear under sky”, each text token and its corresponding image region (given by a binary mask) are directed through distinct space experts, i.e., each expert learns particular visual features at a region. By stacking several space-MoEs, we can easily learn to depict thousands of text concepts. + +The extracted text tokens are input into the U-Net through a cross-attention layer. The text tokens possess a size of $n _ { y } \times d _ { y }$ , where $n _ { y }$ represents the number of text tokens, and $d _ { y }$ signifies the dimension of a text token (e.g., $d _ { y } = 7 6 8$ in [14]). + +The cross-attention layer can be formulated as attention $\begin{array} { r } { ( \mathbf { Q } , \mathbf { K } , \mathbf { V } ) = \operatorname { s o f t m a x } \left( \frac { \mathbf { Q } \mathbf { K } ^ { \top } } { \sqrt { d } } \right) \mathbf { V } } \end{array}$ , where $\mathbf { Q }$ , $\mathbf { K }$ , and $\mathbf { V }$ correspond to the query, key, and value matrices, respectively. These matrices are computed as $\mathbf { Q } = h \left( \mathbf { x } _ { t } \right) \mathbf { W } _ { x } ^ { \mathrm { q r y } }$ , $\mathbf { K } = E _ { \theta } ( \mathbf { y } ) \mathbf { W } _ { y } ^ { \mathrm { k e y } }$ , and $\mathbf { V } = E _ { \theta } ( \mathbf { y } ) \mathbf { W } _ { y } ^ { \mathrm { v a l } }$ , where $\mathbf { W } _ { x } ^ { \mathrm { q r y } } \in \mathbb { R } ^ { d \times d }$ and $\mathbf { W } _ { y } ^ { \mathrm { k e y } }$ , $\mathbf { W } _ { y } ^ { \mathrm { v a l } } \in \mathbb { R } ^ { d _ { y } \times d }$ represent the parametric projection matrices for the image and text, respectively. Additionally, $d$ denotes the dimension of an image token, $h ( \mathbf { x } _ { t } ) \in \mathbb { R } ^ { n _ { x } \times d }$ indicates the flattened intermediate representation within the U-Net, with $n _ { x }$ being the number of tokens in an image. A cross-attention map between the text and image, $\begin{array} { r } { \mathbf { M } = \mathrm { s o f t m a x } \left( \frac { \mathbf { Q } \mathbf { K } ^ { \top } } { \sqrt { d } } \right) \in \mathbb { R } ^ { n _ { x } \times n _ { y } } } \end{array}$ , is defined, which plays a crucial role in the proposed approach, as described in the following sections. + +# 3 Our Approach + +The overall framework of RAPHAEL is illustrated in Fig.3, with the network configuration details provided in the Appendix 7.1. Employing a U-Net architecture, the framework consists of 16 transformer blocks, each containing four components: a self-attention layer, a cross-attention layer, a space-MoE layer, and a time-MoE layer. The space-MoE is responsible for depicting different text concepts in specific image regions at a given scale, while the time-MoE handles different diffusion timesteps. + +# 3.1 Space-MoE and Time-MoE + +Space-MoE. Regarding the space-MoE layer, distinct text tokens correspond to various regions within an image, as previously mentioned. For instance, when provided with the prompt “a furry bear under the sky”, each text token and its corresponding image region (represented by a binary mask) are fed into separate experts, as illustrated in Fig.3b. The space-MoE layer’s output is the mean of all experts, calculated using the following formula: $\begin{array} { r } { \frac { 1 } { n _ { y } } \sum _ { i = 1 } ^ { \widehat { n _ { y } } } e _ { \mathrm { r o u t e } ( \mathbf { y } _ { i } ) } \left( h ^ { \prime } ( \mathbf { x } _ { t } ) \circ \widehat { \mathbf { M } } _ { i } \right) } \end{array}$ . In this equation, $\widehat { \mathbf { M } } _ { i }$ is a binary two-dimensional matrix, indicating the image region the $i$ -th text token should correspond to, as shown in Fig.3b. Here, $\circ$ represents hadamard product, and $h ^ { \prime } ( \mathbf { x } _ { t } )$ is the features from time-MoE. The gating (routing) function route $\left( \mathbf { y } _ { i } \right)$ returns the index of an expert in the space-MoE, with $\{ e _ { 1 } , e _ { 2 } , \ldots , e _ { k } \}$ being a set of $k$ experts. + +Text Gate Network. The Text Gate Network is employed to distribute an image region to a specific expert, as shown in Fig.3b. The function ${ \mathrm { r o u t e } } ( \mathbf { y } _ { i } ) = { \mathrm { a r g m a x } } \left( { \mathrm { s o f t m a x } } \left( { \mathcal { G } } \left( E _ { \theta } ( \mathbf { y } _ { i } ) \right) + \epsilon \right) \right.$ is used, where $\mathcal { G } : \mathbb { R } ^ { d _ { y } } \mapsto \mathbb { R } ^ { k }$ is a feed forward network, which uses a text token representation $E _ { \theta } ( \mathbf { y } _ { i } )$ as input and assigns a space expert. To prevent mode collapse, random noise $\epsilon$ is incorporated. The argmax function ensures that one expert exclusively handles the corresponding image region for each text token, without increasing computational complexity. + +![](images/b115ba8d28166e03abba1bc6e5a2915cb181861d4e3db6cee9a04f61ce9f7e43.jpg) +Figure 4: Left: We visualize the diffusion paths (routes) from the network input to the output, utilizing 16 space-MoE layers, each containing 6 spatial experts. These paths are closely associated with 100 adjectives, such as “scenic”, “peaceful”, and “majestic”, which represent the most frequently occurring adjectives for describing artworks as suggested by GPT-3.5 [15, 16]. Given that GPT-3.5 has been trained on trillions of tokens, we believe that these adjectives reflect a diverse, real-world distribution. Our findings indicate that different paths distinctively represent various adjectives. Right: We depict the diffusion paths for ten categories (i.e., nouns) within the COCO dataset. Our observations reveal that different categories activate distinct paths in a heterogeneous manner. The display colors blend together where the routes overlap. + +From Text to Image Region. Recall that M is the cross-attention map between text and image, where each element, $\mathbf { M } _ { j , i }$ , represents a correspondence value between the $j$ -th image token and the $i \cdot$ -th text token. In the space-MoE, each entry in the binary mask $\widehat { \mathbf { M } } _ { i }$ equals “1” if $\mathbf { M } _ { j , i } \geq \eta _ { i }$ , otherwise $\mathbf { \vec { \nabla } } _ { 0 } , \mathbf { \vec { \mathbf { \phi } } } _ { }$ if $\mathbf { M } _ { j , i } < \eta _ { i }$ , as illustrated in Fig.3b. A thresholding mechanism is introduced to determine the values in the mask. The threshold value $\eta _ { i } = \alpha \operatorname* { m a x } ( \mathbf { M } _ { * , i } )$ is defined, where $\operatorname* { m a x } ( \mathbf { M } _ { * , i } )$ represents the maximum correspondence between text token $i$ and all image regions. The hyper-parameter $\alpha$ will be evaluated through an ablation study. + +Discussions. The insight behind the space-MoE is to effectively model the intricate relationships between text tokens and their corresponding regions in the image, accurately reflecting concepts in the generated images. As illustrated in Fig.4, the employment of 16 space-MoE layers, each containing 6 experts, results in billions of spatial diffusion paths (i.e., $6 ^ { 1 6 }$ possible routes). It is evident that each diffusion path is closely associated with a specific textual concept. + +To investigate this further, we generate 100 prevalent adjectives that are the most frequently occurring adjectives for describing artworks as suggested by GPT-3.5 [15, 16]. Given that GPT-3.5 has been trained on trillions of tokens, we posit that these adjectives reflect a diverse, real-world distribution. We input each adjective into the RAPHAEL model to generate 100 distinct images and collect their corresponding diffusion paths. Consequently, we obtain ten thousand paths for the 100 words. By treating these pathways as features (i.e., each path is a vector of 16 entries), we train a straightforward classifier (e.g., XGBoost [17]) to categorize the words. The classifier after 5-fold cross-validation achieves over $93 \%$ accuracy for open-world adjectives, demonstrating that different diffusion paths distinctively represent various textual concepts. We observe analogous phenomena within the 80 object categories of the COCO dataset. Further details on verbs and visualization are provided in the Appendix 7.5. + +Time-MoE. We can further enhance the image quality by employing a time-mixture-of-experts (time-MoE) approach, which is inspired by previous works such as [4, 5]. Given that the diffusion process iteratively corrupts an image with Gaussian noise over a series of timesteps $t = 1 , \dots , T$ , the image generator is trained to denoise the images in reverse order from $t = T$ to $t = 1$ . All timesteps aim to denoise a noisy image, progressively transforming random noise into an artistic image. Intuitively, the difficulty of these denoising steps varies depending on the noise ratio presented in the image. For example, when $t = T$ , the denoising network’s input image $\mathbf { x } _ { t }$ is highly noisy. When $t = 1$ , the image $\mathbf { x } _ { t }$ is closer to the original image. + +To address this issue, we employ a time-MoE before each space-MoE in each transformer block. In contrast to [4, 5] , which necessitate hand-crafted time expert assignments, we implement an additional gate network to automatically learn to assign different timesteps to various time experts. Further details can be found in the Appendix 7.3. + +# 3.2 Edge-supervised Learning + +In order to further enhance the image quality, we propose incorporating an edge-supervised learning strategy to train the transformer block. By implementing an edge detection module, we aim to extract rich boundary information from an image. These intricate boundaries can serve as supervision to guide the model in preserving detailed image features across various styles. + +Consider a neural network module, $P _ { \theta } ( \mathbf { M } )$ , with parameters of $N$ convolutional layers (e.g., $N = 5$ ). This module is designed to predict an edge map given an attention map $\mathbf { M }$ (refer to Fig.7a in the Appendix 7.2). We utilize the edge map of the input image, denoted as $\mathbf { I } _ { \mathrm { e d g e } }$ , to supervise the network $P _ { \theta }$ . $\mathbf { I } _ { \mathrm { e d g e } }$ can be obtained by the holistically-nested edge detection algorithm [18] (Fig.7b). Intuitively, the network $P _ { \theta }$ can be trained by minimizing the loss function, $\mathcal { L } _ { \mathrm { e d g e } } = \mathrm { F o c a l } ( P _ { \theta } ( \mathbf { M } ) , \mathbf { I } _ { \mathrm { e d g e } } )$ , where $\operatorname { F o c a l } ( \cdot , \cdot )$ denotes the focal loss [19] employed to measure the discrepancy between the predicted and the “ground-truth” edge maps. Moreover, as discussed in [5, 6], the attention map $\mathbf { M }$ is prone to becoming vague when the timestep $t$ is large. Consequently, it is essential to adopt a timestep threshold value to inactivate (pause) edge-supervised learning when $t$ is large. This timestep threshold value $( T _ { c } )$ is a hyper-parameter that will be evaluated through an ablation study. + +Overall, the RAPHAEL model is trained by combining two loss functions, $\mathcal { L } = \mathcal { L } _ { \mathrm { d e n o i s e } } + \mathcal { L } _ { \mathrm { e d g e } }$ As demonstrated in Fig.7d in the Appendix 7.2, edge-supervised learning substantially improves the image quality and aesthetic appeal of the generated images. + +# 4 Experiments + +This section presents the experimental setups, the quantitative results compared to recent state-ofthe-art models, and the ablation study to demonstrate the effectiveness of RAPHAEL. More artistic images generated by RAPHAEL and comparisons between RAPHAEL and other diffusion models can be found in Appendix 7.6 and 7.7. + +Dataset. The training dataset consists of a subset of LAION-5B [20] and some internal datasets, including 730M text-images pairs in total. To collect training data from LAION-5B, we filter the images using the aesthetic scorer same as Stable Diffusion [2] and remove the image-text pairs that have scores smaller than 4.7. We remove the images with watermarks either. Since the text descriptions in LAION-5B are noisy, we clean them by removing useless information such as URLs, HTML tags, and email addresses, inspired by [2, 4, 21]. + +Multi-scale Training. To improve text-image alignment, instead of cropping images to a fixed scale [2], we resize an image to its nearest size into different buckets, which has 9 different image scales. Additionally, the GPU resources will be automatically allocated to each bucket depending on the number of images it contains, enabling effective use of computational resources\*. + +Implementations. To reduce training and sampling complexity, we use a Variational Autoencoder (VAE) [22, 23] to compress images using Latent Diffusion Model [2]. We first pre-train an image encoder to transform an image from pixel space to a latent space, and an image decoder to convert it back. Unlike previous works, the cross-attention layers in RAPHAEL are augmented with space-MoE and time-MoE layers. The entire model is implemented in PyTorch [24], and is trained by AdamW [25] optimizer with a learning rate of $1 e - 4$ , a weight decay of 0, a batch size of 2, 000, on 1, 000 NVIDIA A100s for two months. More details on the hyper-parameter settings can be found in the Appendix 7.1. + +# 4.1 Comparisons + +Results on COCO. Following previous works [1, 2, 4], we evaluate RAPHAEL on the COCO $2 5 6 \times 2 5 6$ dataset using zero-shot Frechet Inception Distance (FID), which measures the quality and diversity of images. Similar to [1, 2, 4, 5, 32], 30, 000 images are randomly selected from the validation set for evaluation. Table 1 shows that RAPHAEL achieves a new state-of-the-art performance of text-to-image generation, with 6.61 zero-shot FID-30k on MS-COCO, surpassing prominent image generators such as Stable Diffusion, Imagen, ERNIE-ViLG 2.0, and DALL-E 2. + +![](images/6d12b8cb99c3246d187709d4e6c5c2b7aa5c6b02cc54eee7d1e96e4d49880aeb.jpg) +Figure 5: Comparisons of RAPHAEL with DALL-E 2, Stable Diffusion XL (SD XL), ERNIE-ViLG 2.0, and DeepFloyd in a user study using the ViLG-300 benchmark. We report the user’s preference rates with $9 5 \%$ confidence intervals. We see that RAPHAEL can generate images with higher quality and better conform to the prompts. + +Human Evaluations. We employ the ViLG-300 benchmark [5], a bilingual prompt set, which enables to systematically evaluate text-to-image models given various text prompts in Chinese and English. ViLG-300 allows us to convincingly compare RAPHAEL with recent-advanced models including DALL-E 2, Stable Diffusion, ERNIE-ViLG 2.0, and DeepFloyd, in terms of both image quality and text-image alignment. For example, human artists are presented with two sets of images generated by RAPHAEL and a competitor, respectively. They are asked to compare these images from two aspects respectively, including image-text alignment, and image quality and aesthetics. Throughout the entire process, human artists are unaware of which model the image is generated from. Fig.5 shows that RAPHAEL surpasses all other models in both image-text alignment and image quality in the user study, indicating that RAPHAEL can generate high-artistry images that conform to the text. + +Extensions to LoRA, ControlNet, and SR-GAN. RAPHAEL can be further extended by incorporating LoRA, ControlNet, and SR-GAN. In Appendix 7.8, we present a comparison between RAPHAEL and Stable Diffusion utilizing LoRA. RAPHAEL demonstrates superior robustness against overfitting compared to Stable Diffusion. We also demonstrate RAPHAEL with a canny-based ControlNet. Furthermore, by employing a tailormade SR-GAN model, we enhance the image resolution to $4 0 9 6 \times 6 1 4 4$ . + +# 4.2 Ablation Study + +Evaluate every module in RAPHAEL. We conduct a comprehensive assessment of each module within the RAPHAEL model, utilizing the CLIP [14] score to measure image-text alignment. Given the significance of classifier-free guidance weight in controlling image quality and text alignment, we present ablation results as trade-off curves between CLIP and FID scores across a range of guidance weights [33], specifically 1.5, 3.0, 4.5, 6.0, 7.5, and 9.0. Fig.6b compares these curves for the complete RAPHAEL model and its variants without space-MoE, edge-supervised learning, and time-MoE, respectively. Our findings indicate that all modules contribute effectively. For example, space-MoE substantially enhances the CLIP score and the optimal guidance weight for the sampler shifts from 3.0 to 4.5. Moreover, at the same guidance weight, space-MoE considerably reduces the FID, resulting in a significant improvement in image quality. + +![](images/b4ff35fff7b89b9a01ac36ecf5013ed2a2a3e0845b56350eeead07ba9db79e51.jpg) +Figure 6: Ablation Study. (a) examines the selection of $\alpha$ and $T _ { c }$ . (b) presents the trade-off between FID and CLIP scores for the complete RAPHAEL model and its variants without space-MoE, time-MoE, and edge-supervised learning. (c) visualizes the correlation between FID- $^ { 5 \mathrm { k } }$ and runtime complexity (measured in terms of the number of DDIM [34] steps for an image per second) as a function of the number of experts employed. Notably, the computational complexity is predominantly influenced by the number of spatial experts. + +Choice of $\alpha$ and $T _ { c }$ . As depicted in Fig.6a, we observe that $\alpha = 0 . 2$ delivers the best performance, implying a balance between preserving adequate features and avoiding the use of the entire latent features. An appropriate threshold value for $T _ { c }$ terminates edge-supervised learning when the diffusion timestep is large. Our experiments reveal that a suitable choice for $T _ { c }$ is 500, ensuring the effective learning of texture information. + +Performance and Runtime Analysis on Number of Experts. We offer an examination of the number of experts, ranging from 0 to 8, in Fig.6c. For each setting, we employ 100 million training samples. Our results demonstrate that increasing the number of experts improves FID (lower values are preferable). However, adding spatial experts introduces additional computations, with the computational complexity bounded by the total number of experts. Once all available experts have been deployed, the computational complexity ceases to grow. In the right-hand side of Fig.6c, we provide a runtime analysis for 40 input tokens, ensuring the utilization of all space experts. For instance, when the number of experts is 6, the inference speed decreases by $24 \%$ but yields superior fidelity. This remains faster than previous diffusion models such as Imagen [1] and eDiff-I [4]. + +# 5 Related Work + +We review related works from two perspectives, mixture-of-experts and text-to-image generation. More related works can be found in Appendix 7.4. Firstly, the Mixture-of-Experts (MoE) method [7, 8] partitions model parameters into distinct subsets, each termed an “expert”. The MoE paradigm finds applicability beyond language processing tasks, extending to visual models [35] and Mixtureof-Modality-Experts within multi-modal transformers [36]. Additionally, efforts are being made to accelerate the training or inference processes for MoE [37, 38]. Secondly, text-to-image generation is to synthesize images from natural language descriptions. Early approaches relied on generative adversarial networks (GANs) [39, 40, 41, 42] to generate images. More recently, with the transformative success of transformers in generative tasks, models such as DALL-E [43], Cogview [44], and Make-A-Scene [29] have treated text-to-image generation as a sequence-to-sequence problem, utilizing auto-regressive transformers as generators and employing text/image tokens as input/output sequences. Recently, another research direction has focused on diffusion models by integrating textual conditioning within denoising steps, like Stable Diffusion [2], DALL-E 2 [3], eDiff-I [4], ERNIE-ViLG 2.0 [5], and Imagen [1]. + +# 6 Conclusion + +This paper introduces RAPHAEL, a novel text-conditional image diffusion model capable of generating highly-artistic images using a large-scale mixture of diffusion paths. We carefully design space-MoE and time-MoE within an edge-supervised learning framework, enabling RAPHAEL to accurately portray text prompts, enhance the alignment between textual concepts and image regions, and produce images with superior aesthetic appeal. Comprehensive experiments demonstrate that RAPHAEL surpasses previous approaches, such as Stable Diffusion, ERNIE-ViLG 2.0, DeepFloyd, and DALL-E 2, in both FID-30k and the human evaluation benchmark ViLG-300. Additionally, RAPHAEL can be extended using LoRA, ControlNet, and SR-GAN. We believe that RAPHAEL has the potential to advance image generation research in both academia and industry. + +Limitation and Potential Negative Societal Impact. We acknowledge some limitations in our paper that require attention. One limitation is the direct binarization of the attention map, which may result in the loss of some information. An adaptive module should be proposed to address this issue effectively. Additionally, the performance may be affected by failure cases of the edge detector, leading to potential degradation. We plan to explore solutions for these limitations in our future work. The potential negative social impact is to use the RAPHAEL API to create images containing misleading or false information. This issue potentially presents in all powerful text-toimage generators. We will solve this issue (e.g., by prompt filtering) before releasing the API to the public. + +# Acknowledgments and Disclosure of Funding + +This paper is partially supported by the National Key R&D Program of China No.2022ZD0161000 and the General Research Fund of Hong Kong No.17200622. + +# References + +[1] Chitwan Saharia, William Chan, Saurabh Saxena, Lala Li, Jay Whang, Emily L Denton, Kamyar Ghasemipour, Raphael Gontijo Lopes, Burcu Karagol Ayan, Tim Salimans, et al. Photorealistic text-to-image diffusion models with deep language understanding. Advances in Neural Information Processing Systems, 35:36479–36494, 2022. +[2] Robin Rombach, Andreas Blattmann, Dominik Lorenz, Patrick Esser, and Björn Ommer. Highresolution image synthesis with latent diffusion models. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 10684–10695, 2022. +[3] Aditya Ramesh, Prafulla Dhariwal, Alex Nichol, Casey Chu, and Mark Chen. Hierarchical text-conditional image generation with clip latents. arXiv preprint arXiv:2204.06125, 2022. +[4] Yogesh Balaji, Seungjun Nah, Xun Huang, Arash Vahdat, Jiaming Song, Karsten Kreis, Miika Aittala, Timo Aila, Samuli Laine, Bryan Catanzaro, et al. ediffi: Text-to-image diffusion models with an ensemble of expert denoisers. arXiv preprint arXiv:2211.01324, 2022. +[5] Zhida Feng, Zhenyu Zhang, Xintong Yu, Yewei Fang, Lanxin Li, Xuyi Chen, Yuxiang Lu, Jiaxiang Liu, Weichong Yin, Shikun Feng, et al. Ernie-vilg 2.0: Improving text-to-image diffusion model with knowledge-enhanced mixture-of-denoising-experts. arXiv preprint arXiv:2210.15257, 2022. +[6] Amir Hertz, Ron Mokady, Jay Tenenbaum, Kfir Aberman, Yael Pritch, and Daniel Cohen-Or. Prompt-to-prompt image editing with cross attention control. arXiv preprint arXiv:2208.01626, 2022. +[7] 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. arXiv preprint arXiv:1701.06538, 2017. +[8] William Fedus, Barret Zoph, and Noam Shazeer. Switch transformers: Scaling to trillion parameter models with simple and efficient sparsity. The Journal of Machine Learning Research, 23(1):5232–5270, 2022. +[9] Edward J Hu, Yelong Shen, Phillip Wallis, Zeyuan Allen-Zhu, Yuanzhi Li, Shean Wang, Lu Wang, and Weizhu Chen. Lora: Low-rank adaptation of large language models. arXiv preprint arXiv:2106.09685, 2021. +[10] Lvmin Zhang and Maneesh Agrawala. Adding conditional control to text-to-image diffusion models. arXiv preprint arXiv:2302.05543, 2023. +[11] Xintao Wang, Liangbin Xie, Chao Dong, and Ying Shan. Real-esrgan: Training real-world blind super-resolution with pure synthetic data. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 1905–1914, 2021. +[12] Jonathan Ho, Ajay Jain, and Pieter Abbeel. Denoising diffusion probabilistic models. Advances in Neural Information Processing Systems, 33:6840–6851, 2020. +[13] Olaf Ronneberger, Philipp Fischer, and Thomas Brox. U-net: Convolutional networks for biomedical image segmentation. In Medical Image Computing and Computer-Assisted Intervention–MICCAI 2015: 18th International Conference, Munich, Germany, October 5-9, 2015, Proceedings, Part III 18, pages 234–241. Springer, 2015. +[14] Alec Radford, Jong Wook Kim, Chris Hallacy, Aditya Ramesh, Gabriel Goh, Sandhini Agarwal, Girish Sastry, Amanda Askell, Pamela Mishkin, Jack Clark, et al. Learning transferable visual models from natural language supervision. In International Conference on Machine Learning, pages 8748–8763. PMLR, 2021. +[15] 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. +[16] Long Ouyang, Jeffrey Wu, Xu Jiang, Diogo Almeida, Carroll Wainwright, Pamela Mishkin, Chong Zhang, Sandhini Agarwal, Katarina Slama, Alex Ray, et al. Training language models to follow instructions with human feedback. Advances in Neural Information Processing Systems, 35:27730–27744, 2022. +[17] Tianqi Chen, Tong He, Michael Benesty, Vadim Khotilovich, Yuan Tang, Hyunsu Cho, Kailong Chen, Rory Mitchell, Ignacio Cano, Tianyi Zhou, et al. Xgboost: extreme gradient boosting. R package version 0.4-2, 1(4):1–4, 2015. +[18] Saining Xie and Zhuowen Tu. Holistically-nested edge detection. In Proceedings of the IEEE International Conference on Computer Vision, pages 1395–1403, 2015. +[19] Tsung-Yi Lin, Priya Goyal, Ross Girshick, Kaiming He, and Piotr Dollár. Focal loss for dense object detection. In Proceedings of the IEEE International Conference on Computer Vision, pages 2980–2988, 2017. +[20] Christoph Schuhmann, Romain Beaumont, Richard Vencu, Cade Gordon, Ross Wightman, Mehdi Cherti, Theo Coombes, Aarush Katta, Clayton Mullis, Mitchell Wortsman, et al. Laion5b: An open large-scale dataset for training next generation image-text models. arXiv preprint arXiv:2210.08402, 2022. +[21] Fan Bao, Shen Nie, Kaiwen Xue, Chongxuan Li, Shi Pu, Yaole Wang, Gang Yue, Yue Cao, Hang Su, and Jun Zhu. One transformer fits all distributions in multi-modal diffusion at scale. arXiv preprint arXiv:2303.06555, 2023. +[22] Aaron Van Den Oord, Oriol Vinyals, et al. Neural discrete representation learning. Advances in Neural Information Processing Systems, 30, 2017. +[23] Diederik P Kingma, Max Welling, et al. An introduction to variational autoencoders. Foundations and Trends in Machine Learning, 12(4):307–392, 2019. +[24] 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, 2019. +[25] Ilya Loshchilov and Frank Hutter. Decoupled weight decay regularization. arXiv preprint arXiv:1711.05101, 2017. +[26] 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, pages 16515–16525, 2022. +[27] Minfeng Zhu, Pingbo Pan, Wei Chen, and Yi Yang. Dm-gan: Dynamic memory generative adversarial networks for text-to-image synthesis. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 5802–5810, 2019. +[28] Yufan Zhou, Ruiyi Zhang, Changyou Chen, Chunyuan Li, Chris Tensmeyer, Tong Yu, Jiuxiang Gu, Jinhui Xu, and Tong Sun. Lafite: Towards language-free training for text-to-image generation. arXiv preprint arXiv:2111.13792, 2021. +[29] Oran Gafni, Adam Polyak, Oron Ashual, Shelly Sheynin, Devi Parikh, and Yaniv Taigman. Make-a-scene: Scene-based text-to-image generation with human priors. In Computer Vision– ECCV 2022: 17th European Conference, Tel Aviv, Israel, October 23–27, 2022, Proceedings, Part XV, pages 89–106. Springer, 2022. +[30] 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. +[31] Minguk Kang, Jun-Yan Zhu, Richard Zhang, Jaesik Park, Eli Shechtman, Sylvain Paris, and Taesung Park. Scaling up gans for text-to-image synthesis. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 10124–10134, 2023. +[32] Huiwen Chang, Han Zhang, Jarred Barber, AJ Maschinot, Jose Lezama, Lu Jiang, Ming-Hsuan Yang, Kevin Murphy, William T Freeman, Michael Rubinstein, et al. Muse: Text-to-image generation via masked generative transformers. arXiv preprint arXiv:2301.00704, 2023. +[33] Jonathan Ho and Tim Salimans. Classifier-free diffusion guidance. arXiv preprint arXiv:2207.12598, 2022. +[34] Jiaming Song, Chenlin Meng, and Stefano Ermon. Denoising diffusion implicit models. arXiv preprint arXiv:2010.02502, 2020. +[35] 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. Advances in Neural Information Processing Systems, 34:8583–8595, 2021. +[36] Sheng Shen, Zhewei Yao, Chunyuan Li, Trevor Darrell, Kurt Keutzer, and Yuxiong He. Scaling vision-language models with sparse mixture of experts. arXiv preprint arXiv:2303.07226, 2023. +[37] Jiaao He, Jiezhong Qiu, Aohan Zeng, Zhilin Yang, Jidong Zhai, and Jie Tang. Fastmoe: A fast mixture-of-expert training system. arXiv preprint arXiv:2103.13262, 2021. +[38] 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. arXiv preprint arXiv:2006.16668, 2020. +[39] Antonia Creswell, Tom White, Vincent Dumoulin, Kai Arulkumaran, Biswa Sengupta, and Anil A Bharath. Generative adversarial networks: An overview. IEEE Signal Processing Magazine, 35(1):53–65, 2018. +[40] Ting-Chun Wang, Ming-Yu Liu, Jun-Yan Zhu, Andrew Tao, Jan Kautz, and Bryan Catanzaro. High-resolution image synthesis and semantic manipulation with conditional gans. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pages 8798–8807, 2018. +[41] 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, pages 8110–8119, 2020. + +[42] Ian Goodfellow, Jean Pouget-Abadie, Mehdi Mirza, Bing Xu, David Warde-Farley, Sherjil Ozair, Aaron Courville, and Yoshua Bengio. Generative adversarial networks. Communications of the ACM, 63(11):139–144, 2020. + +[43] Aditya Ramesh, Mikhail Pavlov, Gabriel Goh, Scott Gray, Chelsea Voss, Alec Radford, Mark Chen, and Ilya Sutskever. Zero-shot text-to-image generation. In International Conference on Machine Learning, pages 8821–8831. PMLR, 2021. + +[44] 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. + +[45] Zeyue Xue, Jianming Liang, Guanglu Song, Zhuofan Zong, Liang Chen, Yu Liu, and Ping Luo. Large-batch optimization for dense visual predictions. arXiv preprint arXiv:2210.11078, 2022. + +[46] David Eigen, Marc’Aurelio Ranzato, and Ilya Sutskever. Learning factored representations in a deep mixture of experts. arXiv preprint arXiv:1312.4314, 2013. + +[47] Nan Du, Yanping Huang, Andrew M Dai, Simon Tong, Dmitry Lepikhin, Yuanzhong Xu, Maxim Krikun, Yanqi Zhou, Adams Wei Yu, Orhan Firat, et al. Glam: Efficient scaling of language models with mixture-of-experts. In International Conference on Machine Learning, pages 5547–5569. PMLR, 2022. + +[48] Margaret Li, Suchin Gururangan, Tim Dettmers, Mike Lewis, Tim Althoff, Noah A Smith, and Luke Zettlemoyer. Branch-train-merge: Embarrassingly parallel training of expert language models. arXiv preprint arXiv:2208.03306, 2022. + +[49] 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. + +[50] Chenlin Meng, Yutong He, Yang Song, Jiaming Song, Jiajun Wu, Jun-Yan Zhu, and Stefano Ermon. Sdedit: Guided image synthesis and editing with stochastic differential equations. In International Conference on Learning Representations, 2021. + +[51] Bahjat Kawar, Shiran Zada, Oran Lang, Omer Tov, Huiwen Chang, Tali Dekel, Inbar Mosseri, and Michal Irani. Imagic: Text-based real image editing with diffusion models. arXiv preprint arXiv:2210.09276, 2022. + +[52] Shaozhe Hao, Kai Han, Shihao Zhao, and Kwan-Yee K Wong. Vico: Detail-preserving visual condition for personalized text-to-image generation. arXiv preprint arXiv:2306.00971, 2023. + +[53] Zhiheng Liu, Ruili Feng, Kai Zhu, Yifei Zhang, Kecheng Zheng, Yu Liu, Deli Zhao, Jingren Zhou, and Yang Cao. Cones: Concept neurons in diffusion models for customized generation. arXiv preprint arXiv:2303.05125, 2023. + +[54] Zhiheng Liu, Yifei Zhang, Yujun Shen, Kecheng Zheng, Kai Zhu, Ruili Feng, Yu Liu, Deli Zhao, Jingren Zhou, and Yang Cao. Cones 2: Customizable image synthesis with multiple subjects. arXiv preprint arXiv:2305.19327, 2023. + +[55] Xi Chen, Lianghua Huang, Yu Liu, Yujun Shen, Deli Zhao, and Hengshuang Zhao. Anydoor: Zero-shot object-level image customization. arXiv preprint arXiv:2307.09481, 2023. + +[56] Lingting Zhu, Zeyue Xue, Zhenchao Jin, Xian Liu, Jingzhen He, Ziwei Liu, and Lequan Yu. Make-a-volume: Leveraging latent diffusion models for cross-modality 3d brain mri synthesis. In International Conference on Medical Image Computing and Computer-Assisted Intervention, pages 592–601. Springer, 2023. + +[57] Chen-Hsuan Lin, Jun Gao, Luming Tang, Towaki Takikawa, Xiaohui Zeng, Xun Huang, Karsten Kreis, Sanja Fidler, Ming-Yu Liu, and Tsung-Yi Lin. Magic3d: High-resolution text-to-3d content creation. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 300–309, 2023. + +[58] Ben Poole, Ajay Jain, Jonathan T Barron, and Ben Mildenhall. Dreamfusion: Text-to-3d using 2d diffusion. arXiv preprint arXiv:2209.14988, 2022. +[59] Xiang Wang, Hangjie Yuan, Shiwei Zhang, Dayou Chen, Jiuniu Wang, Yingya Zhang, Yujun Shen, Deli Zhao, and Jingren Zhou. Videocomposer: Compositional video synthesis with motion controllability. arXiv preprint arXiv:2306.02018, 2023. +[60] Andreas Blattmann, Robin Rombach, Huan Ling, Tim Dockhorn, Seung Wook Kim, Sanja Fidler, and Karsten Kreis. Align your latents: High-resolution video synthesis with latent diffusion models. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 22563–22575, 2023. +[61] Lingting Zhu, Xian Liu, Xuanyu Liu, Rui Qian, Ziwei Liu, and Lequan Yu. Taming diffusion models for audio-driven co-speech gesture generation. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 10544–10553, 2023. +[62] Shihao Zhao, Dongdong Chen, Yen-Chun Chen, Jianmin Bao, Shaozhe Hao, Lu Yuan, and Kwan-Yee K Wong. Uni-controlnet: All-in-one control to text-to-image diffusion models. Advances in Neural Information Processing Systems, 2023. \ No newline at end of file diff --git a/md/dev/jmopGajkFY/jmopGajkFY.md b/md/dev/jmopGajkFY/jmopGajkFY.md new file mode 100644 index 0000000000000000000000000000000000000000..5b0d530806c71e47e69094bd7d15a0111661aa08 --- /dev/null +++ b/md/dev/jmopGajkFY/jmopGajkFY.md @@ -0,0 +1,753 @@ +# MEGA: Multilingual Evaluation of Generative AI + +Kabir Ahuja♡∗ Harshita Diddee♢∗ Rishav Hada † Millicent Ochieng† Krithika Ramesh ♠∗ Prachi Jain† Akshay Nambi† Tanuja Ganu† +Sameer Segal† Maxamed Axmed† Kalika Bali† Sunayana Sitaram† ♡University of Washington ♢Carnegie Mellon University †Microsoft Corporation ♠Johns Hopkins University kahuja@cs.washington.edu, sunayana.sitaram@microsoft.com + +# Abstract + +Generative AI models have shown impressive performance on many Natural Language Processing tasks such as language understanding, reasoning, and language generation. An important question being asked by the AI community today is about the capabilities and limits of these models, and it is clear that evaluating generative AI is very challenging. Most studies on generative LLMs have been restricted to English and it is unclear how capable these models are at understanding and generating text in other languages. We present the first comprehensive benchmarking of generative LLMs - MEGA, which evaluates models on standard NLP benchmarks, covering 16 NLP datasets across 70 typologically diverse languages. We compare the performance of generative LLMs including Chat-GPT and GPT-4 to State of the Art (SOTA) non-autoregressive models on these tasks to determine how well generative models perform compared to the previous generation of LLMs. We present a thorough analysis of the performance of models across languages and tasks and discuss challenges in improving the performance of generative LLMs on low-resource languages. We create a framework for evaluating generative LLMs in the multilingual setting and provide directions for future progress in the field. + +# 1 Introduction + +Large Large Models (LLMs) such as ChatGPT and GPT-4 have created a lot of interest in the AI community and beyond, due to the step jump in their capabilities, such as maintaining context over conversations, fluency of generation, and reasoning. Many users have reported having tested these systems on languages other than English, with varying results, and recent demos of these models (Warren, 2023) have been shown in multiple (albeit highresource) languages. Recently, the GPT-4 model (OpenAI, 2023) was evaluated on the MMLU multiple choice questions benchmark by automatically translating it into 26 languages, and the results for some low-resource languages in the Latin script were found to be quite promising. + +The multilingual capabilities of these models can be traced to their pre-training data, where even the predominantly English large-scale corpora contain hundreds of millions of non-Engish tokens (Blevins and Zettlemoyer, 2022). For GPT-3 unlabeled pre-training data has been documented to contain 119 languages (Brown et al., 2020), where roughly $93 \%$ of the tokens are in English1. Other LLMs like BLOOM (Scao et al., 2022) and PaLM (Chowdhery et al., 2022) have a better multilingual representation with $60 \%$ and $18 \%$ non-English data respectively for pre-training. While these models have been trained on multiple languages with varying distributions in the pre-training data, it is not clear how well they perform relative to each other across diverse tasks and languages due to a lack of comprehensive analysis across all models with the same experimental setup. + +Recently, there has been a lot of interest in evaluating the different capabilities of LLMs, with comprehensive studies like HELM (Liang et al., 2022) that evaluate these models on a wide variety of capabilities. However, such studies are largely performed on English language data and there is a lack of such large-scale evaluation of LLMs for their multilingual capabilities. Given the current pace at which new language technologies are being developed that use LLMs, the importance of such an evaluation cannot be understated as the cases of inequalities in the performance of previousgeneration models across languages have been welldocumented (Blasi et al., 2022). + +In our work, we present the first large-scale Multilingual Evaluation of Generative AI models (MEGA), spanning 16 different datasets, 70 topologically diverse languages, and four LLMs i.e. GPT-3.5 models text-davinci-003 and gpt-3.5-turbo, GPT-4 (gpt-4-32k) and BLOOMZ (Muennighoff et al., 2022). We also compare these models with the models fine-tuned on these datasets like TULRv6 (Patra et al., 2022) and MuRIL (Khanuja et al., 2021), which are SoTA on different multilingual benchmarks. + +![](images/d5f628441a4011838fe4efeecd80075554bd72f985942c80e38a06339cf531fb.jpg) +Figure 1: An overview of our benchmarking exercise: Multilingual Evaluation of Generative AI (MEGA). Numbers in parentheses in Figure 1a contain the number of languages supported in the dataset. + +Through our evaluation, we aim to answer three research questions. (1), how well do LLMs fare on multilingual benchmarks compared to fine-tuned SOTA models? (2), what languages do these models perform well in, and can we explain the trends in performance for these models across languages? (3), what prompting strategies should be used for using LLMs for non-English languages? + +Our study highlights that there is a significant disparity between the performance of LLMs in English vs non-English languages, especially low-resource languages with non-Latin scripts for which fine-tuned models perform significantly better. While GPT-4 bridges this gap to some extent, the discrepancy still exists. Further, we find that for these languages it is often difficult to do better than simply machine translating the input in a target language to English and then sending it to the LLM for prediction (translate-test). We also discuss how different prompt-design choices like prompt-tuning, use of explanations, and number of few-shot examples impact multilingual performance. Finally, we perform some initial analysis to the test the possibility of test data contamination in LLMs that we evaluate and discuss its implications on our findings. Our work provides a blueprint for strategies that can be used for building systems using generative AI for multilingual users. We also release our code 2 for the community to scale up the multilingual evaluation of generative models. + +# 2 MEGA + +In this section, we discuss different components of our benchmarking exercise to measure the multilingual capabilities of LLMs. We start by discussing different NLP tasks and datasets that we evaluate these models on, along with their linguistic diversity. We provide an overview of the models we evaluate, baselines for comparison, and describe our evaluation scheme and prompting strategies. + +# 2.1 Datasets and Languages + +We broadly consider five families of NLP tasks in our experiments covering 16 different datasets: + +Classification Tasks. Here, we further have four different sub-tasks, i) Natural Language Inference (classify if a hypothesis is entailed in the premise, contradicts it or neither), which includes XNLI (Conneau et al., 2018) , Indic-XNLI (Aggarwal et al., 2022) (version of XNLI translated to 11 Indian languages), and GLUECos NLI(Khanuja et al., 2020b) for English-Hindi codemixed data; ii) Commonsense Reasoning datasets including causal commonsense reasoning benchmark XCOPA (Ponti et al., 2020) and XStoryCloze (Lin et al., 2022a), where the correct ending of a story with four sentences is to be predicted; iii) Paraphrase Identification task PAWS-X (Yang et al., 2019a), where given two sentences, the model must predict if the two have the same meaning; iv) EN-ES-CS dataset for Sentiment Analysis on English-Spanish code-mixed tweets. + +Question Answering (QA). For QA we consider Span-Prediction tasks, where the answer to a question is to be predicted within a piece of context provided. We evaluate on XQuAD (Artetxe et al., 2020), MLQA (Lewis et al., 2020), TyDiQA-GoldP (Clark et al., 2020), and IndicQA (Doddapaneni et al., 2022). + +Sequence Labeling. This task involves classifying each token in a piece of text and we consider Named Entity Recognition dataset PAN-X (Pan et al., 2017) (also called WikiANN) and UDPOS (Nivre et al., 2018) for Part of Speech Tagging. + +Natural Language Generation (NLG). For NLG we consider the multilingual Abstractive Summarization dataset XL-Sum. + +Responsible AI (RAI). We consider the multilingual Toxicity Prediction dataset Jigsaw(Kivlichan et al., 2020), and Wino-MT to measure Gender Bias in MT systems. + +All the datasets with the number of languages they include are listed in Figure 1a. These 16 datasets encompass a total of 70 languages covering 21 different language families, with IndoAryan and Afro-Asiatic languages in the majority (see Figure 1b). Note that for tasks with $> 3 0$ languages i.e. UDPOS, PAN-X, and XL-Sum, we run evaluations on the first 1000 examples of the test sets. For tasks where no public test sets are available (like XQUAD, TyDiQA-GoldP, and IndicQA), we evaluate on validation data. Refer to Appendix $\ S \mathrm { A . 1 }$ for a detailed description of all the datasets. + +# 2.2 Models + +OpenAI Models. We conduct all benchmarking experiments on the GPT-3.5 models text-davinci-003 (denoted as DV003 in the paper) and gpt-3.5-turbo (Ouyang et al., 2022) (GPT-3.5-Turbo) as well on the GPT4 model gpt-4-32k (OpenAI, 2023). The text-davinci-003 model has a maximum context size of 4096 tokens, while gpt-3.5-turbo and $\mathtt { g p t - } 4 - 3 2 \mathsf { k }$ support context sizes of 16k and $3 2 \mathrm { k }$ respectively. + +Baselines. We compare the performance of OpenAI models with two classes of baselines, i) Prompt-Based baselines, which like the OpenAI models are evaluated by prompting the model directly for solving a task, and ii) Fine-tuned Baselines, which are fine-tuned on task-specific training data. For the former we consider BLOOMZ (Muennighoff et al., 2022), a multi-task fine-tuned version of the BLOOM (Scao et al., 2022) model, which is a 176 billion parameter model trained on 46 natural languages and 13 programming languages. For fine-tuned baselines, we consider TULRv6 (Patra et al., 2022) (the current SoTA on XTREME benchmark), XLMR (Conneau et al., 2020), multilingual BERT (Devlin et al., 2019), and mT5 (Xue et al., 2021). For Indic-datasets we also compare with MuRIL(Khanuja et al., 2021), a multilingual BERT model trained on 16 Indic languages that obtains SOTA performance on many Indic benchmarks. All of these models (excluding mT5 for the XLSum and XCOPA), were fine-tuned with English data and then evaluated in a zero-cross-lingual fashion on other target languages. + +# 2.3 Evaluation Methodology + +LLMs exhibit two remarkable properties that make them effective at solving a variety of NLP tasks. The first is in-context learning (Brown et al., 2020), where the model learns to solve a task through the few input-output examples provided as part of the context without any weight updates. Secondly, the ability to follow instructions (Mishra et al., 2022; Wei et al., 2021; Ouyang et al., 2022) which is a property of instruction-tuned LLMs, where the models can be prompted to solve new-tasks based on the textual instructions provided in context. + +We adopt these two techniques together to test the capabilities of LLMs to solve a variety of tasks in different languages. We define five main components to define the prompts: i) a test example $x _ { \mathrm { t e s t } }$ for which the predictions are to be made; ii) $k$ few-shot exemplars $\{ ( x _ { i } , y _ { i } ) \} _ { i = 1 } ^ { k }$ , that are used to provide in-context supervision to the model; iii) a task instruction $\mathcal { T }$ which describes the instruction in text for the task to LLM; iv) a prompt template $f _ { \mathrm { t e m p } } ( x )$ which turns a dataset input example into a text format that can be used for prompting; and v) an answer verbalizer $f _ { \mathrm { v e r b } } ( y )$ that maps the label $y$ to a textual representation. In our evaluation framework we often consider the instruction, template, and verbalizer as a single entity, and from now on will denote the template to encapsulate the three unless specified separately. + +Given these components, the final prompt $f _ { \mathrm { p r o m p t } } ( x _ { \mathrm { t e s t } } ; \{ ( x _ { i } , y _ { i } ) \} _ { i = 1 } ^ { K } , \mathbb { Z } , f _ { \mathrm { t e m p } } , f _ { \mathrm { v e r b } } )$ or $f _ { \mathrm { p r o m p t } } ( x _ { \mathrm { t e s t } } )$ for short for a test input $x _ { \mathrm { t e s t } }$ can + +be defined as: + +$$ +\begin{array} { r l r } & { } & { f _ { \mathrm { p r o m p t } } ( x _ { \mathrm { t e s t } } ) = \mathcal { Z } \parallel _ { i = 1 } ^ { K } \left\{ f _ { \mathrm { t e m p } } ( x _ { i } ) \parallel f _ { \mathrm { v e r b } } ( y _ { i } ) \right\} \quad } \\ & { } & { \parallel f _ { \mathrm { t e m p } } ( x _ { \mathrm { t e s t } } ) } \end{array} +$$ + +where $\parallel$ denotes the string concatenation operator. The prompt can then be provided as input to the LLM $P ( . ; \theta )$ to obtain the prediction $z _ { \mathrm { t e s t } } =$ arg $\begin{array} { r } { \operatorname* { m a x } _ { z \in \mathcal { Z } } P ( z | f _ { \mathrm { p r o m p t } } ( x _ { \mathrm { t e s t } } ) ; \theta ) } \end{array}$ , where $\mathcal { Z }$ is the space of possible answers, which in all of our experiments is taken to be the entirety of the language as modeled by the LLM. We approximate the arg max by sampling from the probability distribution predicted by the LLM. + +# 2.3.1 Multilingual Prompting Strategies + +The choice of prompt significantly influences the performance of LLMs and these models have been shown to be brittle to simple prompting variations, such as the choice of prompt template and the training examples or even the ordering of examples (Zhao et al., 2021). For multilingual setups as highlighted in Lin et al. (2022a) and Shi et al. (2022), some additional variations to consider include, the choice of the language of the few-shot examples, the language of the prompt template, and the language of the test examples. + +In this work, we evaluate models using three types of prompting strategies: Monolingual Prompting: In this setup, the $k$ randomly selected examples are of the same language as the test examples. Zero-Shot Cross-Lingual: Here, we evaluate generative models’ zero-shot cross-lingual transfer ability during in-context learning. We use $k$ -shot examples from a pivot language (always English in our experiments) which is different from the language of the test example. Translate-Test: In this setup also, the few-shot examples are sampled from English data. However, the test example itself is modified by translating it into English. We use Bing Translator to translate the test examples into English. We do not perform evaluations with Translate-Test prompting for QA and Sequence Labelling tasks where there is no trivial alignment between the labels in the translated text with native language text. To preserve costs, for GPT-4 we only run evaluations with the Monolingual prompting strategy except for a couple of datasets, which we explicitly discuss later in $\ S 3$ . Irrespective of the prompting strategy, we use the prompt templates written in English (see Appendix $\ S \mathrm { A } . 7$ for the impact of this choice). + +Prompt Tuning. We use PromptSource (Bach et al., 2022) for a database of existing prompts to use for our experiments. In order to select the best prompt for a dataset (to appropriately measure the capabilities of these models), we evaluate the performance of available English templates on PromptSource on the English validation set and select the prompt that gives the best performance. This prompt template is then used to evaluate models on the test sets for all languages and prompt strategies. While it would be ideal to tune the prompts separately for each language, the scale of our experiments and the computational costs of these models make it prohibitive. We investigate the impact this choice has on our results in $\ S 4 . 1$ We perform separate prompt-tuning for DV003 and GPT-3.5-Turbo models, and to keep the costs in check, we use the prompts obtained for the latter for GPT-4 as well. Final prompts selected are included in Appendix $\ S \mathrm { A . 4 }$ . + +Choice of Few-Shot Examples. In all our experiments, we choose few-shot examples randomly from the training or validation set (depending on what’s available) of a dataset. For most datasets, we use 8 few-shot examples, excluding tasks with longer contexts like QA and summarization tasks where we use $k = 4$ . + +# 3 Results and Analysis + +In this section, we analyze the results of our benchmarking exercise across tasks and languages. Broadly, we cover the comparison between the effectivness of various prompting strategies $\ S 3 . 1$ followed by the performance comparison of GPT-3.5 and GPT-4 models with appropriate baselines $\ S 3 . 2$ We conclude with an examination of the factors that affects the performance of these models $\ S 3 . 3$ . + +# 3.1 Comparing different prompting strategies + +In Figure 2, we compare the performance of the three prompting strategies. We find that translatetest often improves the performance over the monolingual strategy, especially so in the case of DV003. We also find that for datasets, which include many low resource and non-latin script languages like IndicXNLI and XStoryCloze, the gains with translatetest are even more substantial for both the models. In Figure 3, we present the average (over different tasks) relative improvement by TranslateTest over Monolingual on GPT-3.5-Turbo for different languages and observe for languages like + +![](images/d004dcae072b04c2f19aebc8d64a7e8233953554f143b70855ae397614c8b0ba.jpg) +Figure 2: Comparing different prompting strategies discussed in $\ S 2 . 3 . 1$ on $\mathrm { D V } 0 0 3$ and GPT-3.5-Turbo. The $y$ -axis denotes the task-wise performance metric, e.g. Accuracy for XNLI and F1-Score for TyDiQA-GoldP. A list of metrics for all the tasks is provided in Table 1. + +![](images/910f222b3edd15c9ce38303956a240ca134ec1d0cf6511b754e08c9b14440f72.jpg) +Figure 3: Relative percentage improvement over Monolingual prompting when using Translate-Test for GPT-3.5- Turbo. The bars are color-coded based on the class taxonomy provided in (Joshi et al., 2020) + +Burmese, Tamil, and Telugu the relative improvement can be $> 3 0 \%$ ! In general, we see that for low-resource languages, the translate-test results in substantial improvement in performance, while for high-resource languages the two perform similarly. While we do not evaluate GPT-4 TranslateTest exhaustively for all tasks, we do run the tests for XStoryCloze and XCOPA datasets. Based on these two, we observe that GPT-4’s Monolingual prompting performance is often much more on-par with Translate-Test and many times even better. However, for low-resource languages we again see Translate-Test to perform much better. e.g., in XStoryCloze GPT-4’s accuracy on Burmese is $7 7 . 6 \%$ vs $9 3 . 2 \%$ for Monolingual and Translate-Test respectively ( Figures 10b and 10d in Appendix). + +Note that while Translate-Test substantially improves performance on low-resource languages, compared to the performance of these models in English, the gap even after Translate-Test is significantly high. For example, using translate-test with GPT-3.5-Turbo for Urdu in XNLI results in $5 4 \%$ accuracy compared to $4 9 . 1 \%$ for monolingual. However, this contrasts with the $7 6 . 2 \%$ accuracy that the same model achieves in English. + +Zero-Shot Cross-Lingual prompting for DV003 often performs on par with Monolingual but for GPT-3.5-Turbo, there is a drop in performance, especially so for tasks like XCOPA which have some extremely low resource languages: Quechua and Haitian Creole. For these languages, we observed that when provided few-shot examples in English, GPT-3.5-Turbo would often resort to predicting outputs like "I’m sorry, but the premise is not in a language that I understand.". However, by providing examples in the language, we are able to ground the model to these languages and we almost never observe such predictions in that case. + +# 3.2 Comparing different models + +The aggregated results comparing different models and prompting strategies are provided in Table 1 and Table 7 (for Indic Datasets). Excluding the commonsense reasoning tasks XCOPA and XStoryCloze, the OpenAI models generally lag behind the fine-tuned baseline TULRv6 for most tasks often by a significant margin and often are only slightly better than some of the smaller finetuned multilingual models i.e. mBERT and mT5- base. Between OpenAI models and BLOOMZ, the former models tend to outperform the latter (despite having a larger proportion of multilingual + +
ModelClassificationQuestion AnsweringSequence LabellingSummarization
XNLIPAWS-X XCOPAXStoryClozeXQuADTyDiQA-GoldPMLQAUDPOSPAN-XXLSum
MetricsAcc.Acc.Acc.Acc.F1/EMF1/EMF1/EMF1F1ROUGE-L
Fine-tuned Baselines
mBERT65.481.956.1×64.5/49.459.7 /43.961.4 /44.271.962.2×
mT5-Base75.486.449.9×67.0 /49.057.2 /41.264.6/45.0-55.728.1†
XLM-R Large TuLRv6 - XXL79.286.469.2×76.6/ 60.865.1/45.071.6 /53.276.265.2×
88.8†93.282.2†×86/72.9†84.6/73.8†81/63.9†83.0+84.7+×
Prompt-Based Baselines
BLOOMZ54.2(82.2)t60.476.2(70.7 /58.8)(75.2/63.2)‡----
Open AI Models
text-davinci-00359.2767.0875.274.740.5/28.049.7 /38.344.0/28.81--
text-davinci-003(TT)67.068.583.894.8××54.9 /34.6××-
gpt-3.5-turbo62.170.079.187.760.4 /38.260.1/38.456.1/32.860.2‡40.318.8
gpt-3.5-turbo (TT)64.367.281.9 89.793.8××46.3 /27.0 67.2 /43.3× 66.6× 55.516.0* 19.7
gpt-4-32k75.473.096.568.3/46.671.5/ 50.9
+ +Table 1: Average performance across languages in each of the different datasets included in MEGA. TT suffix refers to the translate-test prompting strategy discussed in Section 2.3.1, without any suffix we refer to the monolingual strategy by default (except for XQuAD and IndicQA where it refers to cross-lingual setup). Numbers in bold with $\dagger$ symbol indicate best performing Fine-tuned model and the ones with $^ \ddag$ refer to the best prompt-based generative model. The best overall numbers are underlined. For BLOOMZ the values in parenthesis indicate that the model was fine-tuned on the task during multi-task training. Missing values corresponding to the $\mathbf { \partial } ^ { \ast } \times \mathbf { \vec { \mu } }$ symbol denote experiments that were not applicable and the ones with ‘-’ were the ones deprioritized due to limited compute. gpt-3.5-turbo (TT) on XL-Sum was only evaluated on 29 languages which are supported by Bing Translator. + +pre-training data), except for datasets like PAWS-X, XQUAD, and TyDiQA-GoldP, where BLOOMZ performs better. However, it must be noted that all these three datasets were present in the multitask fine-tuning stage for BLOOMZ, especially for XQUAD and TyDiQA-GoldP for which the validation data that we use for evaluation is also likely to be included in the fine-tuning data3. + +Between the OpenAI models, generally DV003 and GPT-3.5-Turbo perform on par, with TranslateTest performance of DV003 being generally better than GPT-3.5-Turbo, and the other way around for Monolingual performance. However, we do observe a notable exception to this, which is for the QA tasks where GPT-3.5-Turbo performs substantially better than DV003, especially so for IndicQA. We attribute this to the fact that in order to fit the prompt in the 4096 context size for DV003, we had to resort to retrive-then prompt strategy and imperfect retrieval for low-resource languages leads to worse performance. Please check $\ S _ { \mathrm { A } . 5 }$ of Appendix for more details on this. For GPT-4 on the other hand, we consistently observe substantial improvements, with it being Pareto Optimal (Choudhury and Deshpande, 2021) compared to the two GPT-3.5 models for all datasets with an exception of XL-Sum, where for some languages GPT-3.5-Turbo performs better. For the detailed results spanning all models, tasks, and languages, please refer to Appendix $\ S \mathrm { A } . 8$ . + +# 3.3 Factors Explaining Performance Trends + +In this section, we try to understand what factors influence our observed trends in multilingual LLM capabilities. We begin by investigating the Fertility of the tokenizers used by different models, which is defined as the average number of sub-words produced per tokenized word (higher means worse quality), as that has been shown to critically impact the downstream task performance of pre-trained multilingual models (Rust et al., 2021). In Figure 4, we plot the tokenizer fertility of different models. We observe that the tokenizers for the OpenAI models are substantially worse for low-resource, non-latin script languages: where the fertility for languages like Malayalam and Tamil is so high $( \sim 1 0 )$ that the tokenizer essentially operates as a byte-level tokenizer for these languages. Note that this means that for low-resource languages, substantially larger number of tokens are needed to encode the inputs as well as for generation, which results in a significant additional API costs. Ahia et al. (2023) discusses how this phenomenon leads to large socio-economic disparities for speakers of underrepresented languages. We study if these discrepancies in the tokenizer’s quality across languages have any effect on the performance. As can be seen in Figure 5, for six tasks we observe statistically significant (negative) correlations between the tokenizer’s fertility and dataset-specific performance i.e. the models obtain worse performance on languages for which the tokenizer is of poor quality, and vice-versa. + +![](images/242e37d388156165c1ece9c15cd58db6fc01441bd9382c27c54b632359355279.jpg) +Figure 4: Tokenizer Fertility for OpenAI models, mBERT, and BLOOM for different languages + +![](images/3c80376de115813032c29d3df5c516cb6bc2686bca5b84a9392f49dee2e89c74.jpg) +Figure 5: Correlation between the performance of GPT3.5-Turbo with the tokenizer fertility. We report the curves for the cases where the person coefficient $| \rho | >$ 0.7 with a $\mathsf { p }$ -value of 0.05. We have combined IndicXNLI and XNLI for a better coverage of languages. Similar plots for GPT-4 can be found in Figure 7b of Appendix. + +We also study the effect that the amount of data available for each language during pre-training (Wu and Dredze, 2020; Lauscher et al., 2020) has on the multilingual performance of these models. We measure the correlations between the language-wise number of tokens present in the pre-training data with language-wise performance on each dataset. While the exact language-wise pre-training data distribution for GPT-3.5 and GPT-4 models is not available, we use the GPT-3’s language-wise pretraining distribution as a proxy. We observe that for four tasks (PAWS-X, XNLI, XCOPA, and XQuAD) statistically significant positive correlations between the pre-training data size and performance. Note that, the amount of pre-training data and tokenizer fertility are highly likely to be correlated with each other. However, we do see that using pre-training data we are able to explain some trends that are not explained by tokenizer fertility alone. For example, even though the OpenAI models have similar tokenizer fertilities for both French and Japanese, these models perform much better in French than they do for Japanese ( $7 2 . 1 \%$ accuracy vs $67 \%$ accuracy for GPT-3.5-Turbo) for PAWSX. However, when we take into consideration the amount of pre-training data for these languages: roughly $3 . 5 \mathrm { ~ B ~ }$ French tokens in the pre-training data versus 214M for Japanese, we can partially explain this discrepancy. + +However, we must note that these two factors correlate well with only a subset of the tasks and what we are measuring is the correlation which might not imply causation. Investigating different factors that together more holistically explain multilingual capabilities is an important direction that we leave for future work. Please check Appendix $\ S \mathbf { A } . 6$ for detailed results from this section. + +# 4 Challenges in Multilingual Evaluation + +In this section, we examine some of the challenges and consequent limitations of a large-scale multilingual evaluation like ours. + +# 4.1 A Kaleidoscope of Choices. + +There are various moving parts when evaluating LLMs using prompting-based approaches, including the choice of prompt templates, instructions, and few-shot examples (Liu et al., 2022; Lu et al., 2022; Zhao et al., 2021), different prompting strategies (Wei et al., 2023; Nye et al., 2021; Ye and Durrett, 2022a), using external tools (Schick et al., 2023), the language of prompts (Shi et al., 2022; Lin et al., 2022a), as well as different decoding specific hyper-parameters (Shih et al., 2023), which can have varying degrees of impact on the performance, sometimes in unexpected ways. Holistically exploring these choices for all the datasets and languages can quickly get out of hand, especially given the excessive computational cost of running these models. In order to understand the sensitivity of our observations to the choices we make in $\ S 3$ , we re-evaluate our setups on a subset of datasets and languages for a varying set of parameters. Our findings are summarized in Figure 6, where we see that having a large few-shot size generally helps improve performance, however, the performance is often stable beyond $k = 8$ Further, language-specific fine-tuning can help improve the performance like we see for Haitian Creole in XCOPA, but for Tamil we actually observe the accuracy to go down which might be attributed to the small size of the validation set (100 in the case of XCOPA). Finally, on XStoryCloze dataset (also for XCOPA), we see using explanations to prompt the models have negligible impact on the performance. Overall, these experiments indicate that the existing prompting approaches might not be sufficient to address the performance gap that exists for non-English languages (especially mid-tolow resource languages) and there is an imminent need to propose new methods as well as improve the representation of different languages in these model’s pre-training (and instruction-tuning) data. + +![](images/cc49110ffeaf3677e898b8eb8663da5b7dada12ea073f744d92485ae170b31b8.jpg) +Figure 6: Analysing the effect on GPT-3.5-Turbo’s performance given different evaluation factors. To obtain explanations we use Super-Natural Instructions (Wang et al., 2022). + +# 4.2 Test data contamination + +Given the massive amount of online data that LLMs are trained with, it is critical to factor in the possibility of contamination of test datasets (Sainz et al., + +2023). Accordingly, we attempt to verify if the performances we observed are in fact, representative of the capabilities of these models or merely a result of memorization. Given the lack of transparency in the training distribution of recent models like GPT-4, we perform some preliminary investigations against this phenomenon. Specifically, we consider three factors: i) LLM’s knowledge of the dataset, ii) availability of test datasets on the internet, and iii) dataset release date. + +To measure the LLM’s (we do this for GPT-4) memory of the dataset, we prompt it to fill the dataset cards for each of MEGA’s datasets (denoted as Card Fill). This involves filling templatic information like the task’s supported languages, inputoutput structure and description. If the model fills a dataset card correctly (Full), we note this as suspicion of contamination. If it fills the card partially correct (Partial) i.e. detecting either the correct task structure or correct set of languages, we mark it as partial evidence, and if it succeeds in neither, we mark it as no suspicion (None). For test dataset availability, we check if the test dataset can be accessed online directly without downloading either as part of the official release from the authors or via other sources such as Hugging Face dataset viewer (Data Acc. w/o Down.). For release date, we check if the dataset was made public after the cut-off date of September 2021. + +The overall results from this analysis are provided in Table 2. We see that for a majority of datasets, GPT-4 can fill in the dataset card correctly; On the more recent datasets like XLSum and XStoryCloze it is only partially successful, while on Jigsaw and code-mixing datasets it fails to correctly fill the cards. Note that except XStoryCloze, Jigsaw and the Code-mixing datasets, evaluation sets for all other datasets are directly accessible online. Collectively, this connotes that for tasks like XStoryCloze and IndicQA there is a weak suspicion against contamination. While all other tasks are highly likely contaminated (except Jigsaw, and Code-Mixed datasets). + +Implications. Our analysis implies a notable chance of the test data appearing in the training datasets of these LLMs. The contamination of test datasets is a serious problem for works centered around LLM evaluation (including ours), as they might lead to an overestimation of the capabilities of these models. However, we would like to highlight that despite the possibility of contamination, LLMs still vastly underperform on (especially low-resource) non-English languages . These observations about data contamination indicate that the disparity in performance between English and non-English languages might be even greater than what we observe in our work. + +Table 2: Contamination analysis for the datasets that we consider in MEGA. We use red color when there is a strong suspicion of contamination based on these three metrics, green for no suspicion, and yellow for partial. + +
Dataset Card Fill Data Acc.w/o Down. Release Date
XNLIFullYesSeptember 2019
Indic-XNLIFullYesApril 2022
PAWS-XFullYes August 2019
XCOPAPartialYesApril 2020
XStoryClozePartialNoMay 2023
XQuADFullYesOctober 2019
MLQAFullYesOctober 2019
TyDiQA-GoldPFullYesFebruary 2020
IndicQAPartialYesSeptember 2022
PAN-XFullYesJuly 2017
UDPOSFullYesMarch 2020
XLSumPartialYesJune 2021
JigsawNoneNoFebruary 2020
GLUECos NLINoneNoJune 2020
EN-ES-CSNoneNoMay 2016
+ +# 5 Related Work + +Evaluation of LLMs. A growing interest in the evaluation of LLMs has harbingered several efforts towards the holistic evaluation of their capabilities. While work like BIG-bench Srivastava et al. (2023) cover a diverse range of tasks, the non-English tasks are mostly translation-oriented which limit the more general task based inferences that for such an evaluation. Similarly, Liang et al. (2022) propose a taxonomy of scenarios and metrics in Holistic Evaluation of Language Models (HELM) to define the space of LLM evaluation, and evaluate 30 language models on 42 scenarios and 7 metrics. However, all the scenarios are focused on datasets in standard English or its dialects. + +Multilingual Benchmarks and Evaluation. Benchmarks for multilingual evaluation, such as XTREME (Hu et al., 2020), XTREME-R (Ruder et al., 2021) and XGLUE (Liang et al., 2020) have been proposed to measure cross-lingual transfer in pre-trained language models. Following their popularity, there has been the development of benchmarks covering specific language families, such as IndicXTREME (Doddapaneni et al., 2022) for Indian languages, Adelani et al. (2022) for African Languages, and Wilie et al. (2020) for Indonesian languages, as well. The evaluations on these benchmarks have mainly focused on pre-train then finetune kinds of setups. Particularly for prompting style evaluation, Bang et al. (2023) evaluates the multilingual capabilities of ChatGPT and shows that it fails to generalize to low-resource languages with non-latin scripts. However, multilingual evaluation is performed only on a few tasks, and a subset of 50-100 examples are used for testing the model. Hendy et al. (2023) evaluate the translation abilities of GPT-3.5 models and find that these models, while perform well in translating high-resource languages, their capabilities for low-resource languages are limited. Concurrent work BUFFET (Asai et al., 2023) and Lai et al. (2023) also perform multilingual benchmarking of large language models, however, they evaluate the performance of ChatGPT and BLOOMZ in their work while our evaluation also spans GPT-4. + +Multilingual Prompting: While most work on prompting or in-context learning in LLMs focuses on English data, recently, there has been some interest in prompting them with non-English data. Zhao and Schütze (2021), for instance, use discrete and soft prompting techniques to evaluate XLMRoBERTa and show that prompting can be more effective compared to fine-tuning when the amount of labeled data is limited. Lin et al. (2022a) show that English prompts perform better than prompts written in the target language (both hand-written and translated). Finally, (Shi et al., 2022) show chain-of-thought (CoT) prompting results leads to striking multilingual reasoning capabilities in LLMs, even in under-represented languages especially when prompted when English CoT. + +# 6 Conclusion + +In this work, we conduct an evaluation across different prompting strategies, models, tasks, and languages to investigate the multilingual capabilities of LLMs. We also investigate underlying properties like tokenizer quality and size of pretraining data to explain the trends in performance that we observe. Our investigation shows the consistent performance gap between high-resource, Latin script, and underresourced languages in addition to highlighting the efficacy, yet limited sufficiency of methods like translate-test prompting. Through our evaluation, we present evidence of the need to prioritize automatic benchmarking and human evaluation across as many languages as possible. We hope that this work spurs research in meeting this goal. + +# Limitations + +Although we compare the evaluation results of GPT-3.5 and GPT-4 with BLOOMZ and SOTA models, we could not evaluate other closed models such as PaLM, which also contains training data in many languages. A limitation of our study is that we do not evaluate on all the multilingual datasets that are available, and we plan to scale up our evaluation in future versions of the study with the help of the research community. Even if we do evaluate all available multilingual datasets, they do not cover many typologically diverse and under-resourced languages, which is a fundamental limitation of trying to scale up multilingual evaluation today. For example, there is very little representation from African languages, Indigenous languages of the Americas etc. in any of the evaluation benchmarks available today. Finally, we restrict ourselves to the performance metrics and to some extent gender bias dimension of evaluation for this study - however, we plan to include evaluation of calibration, toxicity, bias, robustness, etc. in future work. + +# Acknowledgments + +The authors would like to thank Barun Patra and Vishrav Chaudhary for their help with TULR evaluation results. We also thank the anonymous reviewers for their helpful feedback, which helped us improve the quality of our paper. + +# References + +David Adelani, Graham Neubig, Sebastian Ruder, Shruti Rijhwani, Michael Beukman, Chester PalenMichel, Constantine Lignos, Jesujoba Alabi, Shamsuddeen Muhammad, Peter Nabende, Cheikh M. Bamba Dione, Andiswa Bukula, Rooweither Mabuya, Bonaventure F. P. Dossou, Blessing Sibanda, Happy Buzaaba, Jonathan Mukiibi, Godson Kalipe, Derguene Mbaye, Amelia Taylor, Fatoumata Kabore, Chris Chinenye Emezue, Anuoluwapo Aremu, Perez Ogayo, Catherine Gitau, Edwin MunkohBuabeng, Victoire Memdjokam Koagne, Allahsera Auguste Tapo, Tebogo Macucwa, Vukosi Marivate, Mboning Tchiaze Elvis, Tajuddeen Gwadabe, Tosin Adewumi, Orevaoghene Ahia, Joyce Nakatumba-Nabende, Neo Lerato Mokono, Ignatius Ezeani, Chiamaka Chukwuneke, Mofetoluwa Oluwaseun Adeyemi, Gilles Quentin Hacheme, Idris Abdulmumin, Odunayo Ogundepo, Oreen Yousuf, Tatiana Moteu, and Dietrich Klakow. 2022. MasakhaNER 2.0: Africa-centric transfer learning for named entity recognition. In Proceedings of the 2022 Conference on Empirical Methods in Natural Language Processing, pages 4488–4508, Abu + +Dhabi, United Arab Emirates. Association for Computational Linguistics. + +Divyanshu Aggarwal, Vivek Gupta, and Anoop Kunchukuttan. 2022. Indicxnli: Evaluating multilingual inference for indian languages. arXiv preprint arXiv:2204.08776. + +Orevaoghene Ahia, Sachin Kumar, Hila Gonen, Jungo Kasai, David R. Mortensen, Noah A. Smith, and Yulia Tsvetkov. 2023. Do all languages cost the same? tokenization in the era of commercial language models. ArXiv, abs/2305.13707. + +Mikel Artetxe, Sebastian Ruder, and Dani Yogatama. 2020. On the cross-lingual transferability of monolingual representations. In Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics, pages 4623–4637. + +Akari Asai, Sneha Kudugunta, Xinyan Velocity Yu, Terra Blevins, Hila Gonen, Machel Reid, Yulia Tsvetkov, Sebastian Ruder, and Hannaneh Hajishirzi. 2023. Buffet: Benchmarking large language models for few-shot cross-lingual transfer. arXiv cs.CL 2305.14857. + +Stephen 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 Fries, Maged Alshaibani, Shanya Sharma, Urmish Thakker, Khalid Almubarak, Xiangru Tang, Dragomir Radev, Mike Tian-jian Jiang, and Alexander Rush. 2022. PromptSource: An integrated development environment and repository for natural language prompts. In Proceedings of the 60th Annual Meeting of the Association for Computational Linguistics: System Demonstrations, pages 93–104, Dublin, Ireland. Association for Computational Linguistics. + +Yejin Bang, Samuel Cahyawijaya, Nayeon Lee, Wenliang Dai, Dan Su, Bryan Wilie, Holy Lovenia, Ziwei Ji, Tiezheng Yu, Willy Chung, et al. 2023. A multitask, multilingual, multimodal evaluation of chatgpt on reasoning, hallucination, and interactivity. arXiv preprint arXiv:2302.04023. + +Damian Blasi, Antonios Anastasopoulos, and Graham Neubig. 2022. Systematic inequalities in language technology performance across the world’s languages. In Proceedings of the 60th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pages 5486–5505, Dublin, Ireland. Association for Computational Linguistics. + +Terra Blevins, Hila Gonen, and Luke Zettlemoyer. 2022. Prompting language models for linguistic structure. arXiv cs.CL 2211.07830. + +Terra Blevins and Luke Zettlemoyer. 2022. Language contamination helps explains the cross-lingual capabilities of English pretrained models. In Proceedings of the 2022 Conference on Empirical Methods in Natural Language Processing, pages 3563–3574, Abu Dhabi, United Arab Emirates. Association for Computational Linguistics. + +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. 2020. Language models are few-shot learners. CoRR, abs/2005.14165. + +Monojit Choudhury and Amit Deshpande. 2021. How linguistically fair are multilingual pre-trained language models? In AAAI-21. AAAI, AAAI. + +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. + +Jonathan H Clark, Eunsol Choi, Michael Collins, Dan Garrette, Tom Kwiatkowski, Vitaly Nikolaev, and Jennimaria Palomaki. 2020. Tydi qa: A benchmark for information-seeking question answering in typologically diverse languages. Transactions of the Association for Computational Linguistics, 8:454–470. + +Alexis Conneau, Kartikay Khandelwal, Naman Goyal, Vishrav Chaudhary, Guillaume Wenzek, Francisco Guzmán, Édouard 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. + +Alexis Conneau, Ruty Rinott, Guillaume Lample, Adina Williams, Samuel Bowman, Holger Schwenk, and Veselin Stoyanov. 2018. XNLI: Evaluating crosslingual sentence representations. In Proceedings of EMNLP 2018, pages 2475–2485. + +Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. 2019. Bert: Pre-training of deep bidirectional transformers for language understanding. In Proceedings of naacL-HLT, pages 4171– 4186. + +Sumanth Doddapaneni, Rahul Aralikatte, Gowtham Ramesh, Shreya Goyal, Mitesh M Khapra, Anoop Kunchukuttan, and Pratyush Kumar. 2022. Indicxtreme: A multi-task benchmark for evaluating indic languages. arXiv preprint arXiv:2212.05409. + +A. Seza Dogruöz, Sunayana Sitaram, Barbara E. Bul- ˘ lock, and Almeida Jacqueline Toribio. 2021. A survey of code-switching: Linguistic and social perspectives for language technologies. 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 1654–1666, Online. Association for Computational Linguistics. + +Tahmid Hasan, Abhik Bhattacharjee, Md Saiful Islam, Kazi Mubasshir, Yuan-Fang Li, Yong-Bin Kang, M Sohel Rahman, and Rifat Shahriyar. 2021a. Xlsum: Large-scale multilingual abstractive summarization for 44 languages. In Findings of the Association for Computational Linguistics: ACL-IJCNLP 2021, pages 4693–4703. + +Tahmid Hasan, Abhik Bhattacharjee, Md. Saiful Islam, Kazi Mubasshir, Yuan-Fang Li, Yong-Bin Kang, M. Sohel Rahman, and Rifat Shahriyar. 2021b. XLsum: Large-scale multilingual abstractive summarization for 44 languages. In Findings of the Association for Computational Linguistics: ACL-IJCNLP 2021, pages 4693–4703, Online. Association for Computational Linguistics. + +Amr Hendy, Mohamed Abdelrehim, Amr Sharaf, Vikas Raunak, Mohamed Gabr, Hitokazu Matsushita, Young Jin Kim, Mohamed Afify, and Hany Hassan Awadalla. 2023. How good are gpt models at machine translation? a comprehensive evaluation. arXiv preprint arXiv:2302.09210. + +Junjie Hu, Sebastian Ruder, Aditya Siddhant, Graham Neubig, Orhan Firat, and Melvin Johnson. 2020. Xtreme: A massively multilingual multi-task benchmark for evaluating cross-lingual generalisation. In International Conference on Machine Learning, pages 4411–4421. PMLR. + +Pratik Joshi, Sebastin Santy, Amar Budhiraja, Kalika Bali, and Monojit Choudhury. 2020. The state and fate of linguistic diversity and inclusion in the NLP world. In Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics, pages 6282–6293, Online. Association for Computational Linguistics. + +Simran Khanuja, Diksha Bansal, Sarvesh Mehtani, Savya Khosla, Atreyee Dey, Balaji Gopalan, Dilip Kumar Margam, Pooja Aggarwal, Rajiv Teja Nagipogu, Shachi Dave, et al. 2021. Muril: Multilingual representations for indian languages. arXiv preprint arXiv:2103.10730. + +Simran Khanuja, Sandipan Dandapat, Sunayana Sitaram, and Monojit Choudhury. 2020a. A new dataset for natural language inference from codemixed conversations. In Proceedings of the The 4th Workshop on Computational Approaches to Code Switching, pages 9–16. + +Simran Khanuja, Sandipan Dandapat, Anirudh Srinivasan, Sunayana Sitaram, and Monojit Choudhury. + +2020b. Gluecos: An evaluation benchmark for codeswitched nlp. In Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics, pages 3575–3585. + +Ian Kivlichan, Jeffrey Sorensen, Julia Elliott, Lucy Vasserman, Martin Görner, and Phil Culliton. 2020. Jigsaw multilingual toxic comment classification. + +Viet Dac Lai, Nghia Trung Ngo, Amir Pouran Ben Veyseh, Hieu Man, Franck Dernoncourt, Trung Bui, and Thien Huu Nguyen. 2023. Chatgpt beyond english: Towards a comprehensive evaluation of large language models in multilingual learning. + +Anne Lauscher, Vinit Ravishankar, Ivan Vulic, and´ Goran Glavaš. 2020. From zero to hero: On the limitations of zero-shot language transfer with multilingual Transformers. In Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing (EMNLP), pages 4483–4499, Online. Association for Computational Linguistics. + +Patrick Lewis, Barlas Oguz, Ruty Rinott, Sebastian Riedel, and Holger Schwenk. 2020. Mlqa: Evaluating cross-lingual extractive question answering. In Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics, pages 7315– 7330. + +Percy Liang, Rishi Bommasani, Tony Lee, Dimitris Tsipras, Dilara Soylu, Michihiro Yasunaga, Yian Zhang, Deepak Narayanan, Yuhuai Wu, Ananya Kumar, et al. 2022. Holistic evaluation of language models. arXiv preprint arXiv:2211.09110. + +Yaobo Liang, Nan Duan, Yeyun Gong, Ning Wu, Fenfei Guo, Weizhen Qi, Ming Gong, Linjun Shou, Daxin Jiang, Guihong Cao, et al. 2020. Xglue: A new benchmark dataset for cross-lingual pretraining, understanding and generation. arXiv preprint arXiv:2004.01401. + +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. 2022a. Few-shot learning with multilingual generative language models. In Proceedings of the 2022 Conference on Empirical Methods in Natural Language Processing, pages 9019–9052, Abu Dhabi, United Arab Emirates. Association for Computational Linguistics. + +Xi Victoria Lin, Todor Mihaylov, Mikel Artetxe, Tianlu Wang, Shuohui Chen, Daniel Simig, Myle Ott, Naman Goyal, Shruti Bhosale, Jingfei Du, et al. 2022b. Few-shot learning with multilingual generative language models. In Proceedings of the 2022 Conference on Empirical Methods in Natural Language Processing, pages 9019–9052. + +Jiachang Liu, Dinghan Shen, Yizhe Zhang, Bill Dolan, Lawrence Carin, and Weizhu Chen. 2022. What makes good in-context examples for GPT-3? In Proceedings of Deep Learning Inside Out (DeeLIO 2022): The 3rd Workshop on Knowledge Extraction and Integration for Deep Learning Architectures, pages 100–114, Dublin, Ireland and Online. Association for Computational Linguistics. + +Yao Lu, Max Bartolo, Alastair Moore, Sebastian Riedel, and Pontus Stenetorp. 2022. Fantastically ordered prompts and where to find them: Overcoming fewshot prompt order sensitivity. In Proceedings of the 60th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pages 8086–8098, Dublin, Ireland. Association for Computational Linguistics. + +Swaroop Mishra, Daniel Khashabi, Chitta Baral, and Hannaneh Hajishirzi. 2022. 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. Association for Computational Linguistics. + +Nasrin Mostafazadeh, Nathanael Chambers, Xiaodong He, Devi Parikh, Dhruv Batra, Lucy Vanderwende, Pushmeet Kohli, and James Allen. 2016. 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, pages 839–849, San Diego, California. Association for Computational Linguistics. + +Nasrin Mostafazadeh, Michael Roth, Annie Louis, Nathanael Chambers, and James Allen. 2017. Lsdsem 2017 shared task: The story cloze test. In Proceedings of the 2nd Workshop on Linking Models of Lexical, Sentential and Discourse-level Semantics, pages 46–51. + +Niklas Muennighoff, Thomas Wang, Lintang Sutawika, Adam Roberts, Stella Biderman, Teven Le Scao, M Saiful Bari, Sheng Shen, Zheng-Xin Yong, Hailey Schoelkopf, Xiangru Tang, Dragomir Radev, Alham Fikri Aji, Khalid Almubarak, Samuel Albanie, Zaid Alyafeai, Albert Webson, Edward Raff, and Colin Raffel. 2022. Crosslingual generalization through multitask finetuning. + +Akshay Nambi, Vaibhav Balloli, Mercy Ranjit, Tanuja Ganu, Kabir Ahuja, Sunayana Sitaram, and Kalika Bali. 2023. Breaking language barriers with a leap: Learning strategies for polyglot llms. arXiv cs.CL 2305.17740. + +Joakim Nivre, Mitchell Abrams, Željko Agic, Lars ´ Ahrenberg, Lene Antonsen, Maria Jesus Aranzabe, Gashaw Arutie, Masayuki Asahara, Luma Ateyah, Mohammed Attia, et al. 2018. Universal dependencies 2.2. + +Maxwell I. Nye, Anders Johan Andreassen, Guy GurAri, Henryk Michalewski, Jacob Austin, David Bieber, David Dohan, Aitor Lewkowycz, Maarten Bosma, David Luan, Charles Sutton, and Augustus Odena. 2021. Show your work: Scratchpads for intermediate computation with language models. CoRR, abs/2112.00114. + +OpenAI. 2023. Gpt4 technical report. + +Long Ouyang, Jeff Wu, Xu Jiang, Diogo Almeida, Carroll L. Wainwright, Pamela Mishkin, Chong Zhang, Sandhini Agarwal, Katarina Slama, Alex Ray, John Schulman, Jacob Hilton, Fraser Kelton, Luke Miller, Maddie Simens, Amanda Askell, Peter Welinder, Paul Christiano, Jan Leike, and Ryan Lowe. 2022. Training language models to follow instructions with human feedback. + +Xiaoman Pan, Boliang Zhang, Jonathan May, Joel Nothman, Kevin Knight, and Heng Ji. 2017. Cross-lingual name tagging and linking for 282 languages. In Proceedings of the 55th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pages 1946–1958. + +Barun Patra, Saksham Singhal, Shaohan Huang, Zewen Chi, Li Dong, Furu Wei, Vishrav Chaudhary, and Xia Song. 2022. Beyond english-centric bitexts for better multilingual language representation learning. arXiv preprint arXiv:2210.14867. + +Edoardo Maria Ponti, Goran Glavaš, Olga Majewska, Qianchu Liu, Ivan Vulic, and Anna Korhonen. 2020. ´ Xcopa: A multilingual dataset for causal commonsense reasoning. In Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing (EMNLP), pages 2362–2376. + +Pranav Rajpurkar, Jian Zhang, Konstantin Lopyrev, and Percy Liang. 2016a. SQuAD: $^ { 1 0 0 , 0 0 0 + }$ questions for machine comprehension of text. In Proceedings of the 2016 Conference on Empirical Methods in Natural Language Processing, pages 2383–2392, Austin, Texas. Association for Computational Linguistics. + +Pranav Rajpurkar, Jian Zhang, Konstantin Lopyrev, and Percy Liang. 2016b. Squad: $^ { 1 0 0 , 0 0 0 + }$ questions for machine comprehension of text. In Proceedings of the 2016 Conference on Empirical Methods in Natural Language Processing, pages 2383–2392. + +Melissa Roemmele, Cosmin Adrian Bejan, and Andrew S Gordon. 2011. Choice of plausible alternatives: An evaluation of commonsense causal reasoning. In AAAI spring symposium: logical formalizations of commonsense reasoning, pages 90–95. + +Sebastian Ruder, Noah Constant, Jan Botha, Aditya Siddhant, Orhan Firat, Jinlan Fu, Pengfei Liu, Junjie Hu, Dan Garrette, Graham Neubig, et al. 2021. Xtreme-r: Towards more challenging and nuanced multilingual evaluation. In Proceedings of the 2021 Conference on Empirical Methods in Natural Language Processing, pages 10215–10245. + +Rachel Rudinger, Jason Naradowsky, Brian Leonard, and Benjamin Van Durme. 2018. Gender bias in coreference resolution. In Proceedings of the 2018 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 2 (Short Papers), pages 8–14, New Orleans, Louisiana. Association for Computational Linguistics. + +Phillip Rust, Jonas Pfeiffer, Ivan Vulic, Sebastian Ruder, ´ and Iryna Gurevych. 2021. How good is your tokenizer? on the monolingual performance of multilingual language models. In Proceedings of the 59th Annual Meeting of the Association for Computational Linguistics and the 11th International Joint Conference on Natural Language Processing (Volume 1: Long Papers), pages 3118–3135, Online. Association for Computational Linguistics. + +Oscar Sainz, Jon Ander Campos, Iker García-Ferrero, Julen Etxaniz, and Eneko Agirre. 2023. Did chatgpt cheat on your test? + +Teven Le Scao, Angela Fan, Christopher Akiki, Ellie Pavlick, Suzana Ilic, Daniel Hesslow, Roman ´ Castagné, Alexandra Sasha Luccioni, François Yvon, Matthias Gallé, et al. 2022. Bloom: A 176bparameter open-access multilingual language model. arXiv preprint arXiv:2211.05100. + +Timo Schick, Jane Dwivedi-Yu, Roberto Dessì, Roberta Raileanu, Maria Lomeli, Luke Zettlemoyer, Nicola Cancedda, and Thomas Scialom. 2023. Toolformer: Language models can teach themselves to use tools. + +Freda Shi, Mirac Suzgun, Markus Freitag, Xuezhi Wang, Suraj Srivats, Soroush Vosoughi, Hyung Won Chung, Yi Tay, Sebastian Ruder, Denny Zhou, Dipanjan Das, and Jason Wei. 2022. Language models are multilingual chain-of-thought reasoners. CoRR, abs/2210.03057. + +Andy Shih, Dorsa Sadigh, and Stefano Ermon. 2023. Long horizon temperature scaling. + +Sunayana Sitaram, Khyathi Raghavi Chandu, Sai Krishna Rallabandi, and Alan W Black. 2019. A survey of code-switched speech and language processing. arXiv preprint arXiv:1904.00784. + +Aarohi Srivastava, Abhinav Rastogi, Abhishek Rao, Abu Awal Md Shoeb, Abubakar Abid, Adam Fisch, Adam R. Brown, Adam Santoro, Aditya Gupta, Adrià Garriga-Alonso, Agnieszka Kluska, Aitor Lewkowycz, Akshat Agarwal, Alethea Power, Alex Ray, Alex Warstadt, Alexander W. Kocurek, Ali Safaya, Ali Tazarv, Alice Xiang, Alicia Parrish, Allen Nie, Aman Hussain, Amanda Askell, Amanda Dsouza, Ambrose Slone, Ameet Rahane, Anantharaman S. Iyer, Anders Andreassen, Andrea Madotto, Andrea Santilli, Andreas Stuhlmüller, Andrew Dai, Andrew La, Andrew Lampinen, Andy Zou, Angela Jiang, Angelica Chen, Anh Vuong, Animesh Gupta, Anna Gottardi, Antonio Norelli, + +Anu Venkatesh, Arash Gholamidavoodi, Arfa Tabassum, Arul Menezes, Arun Kirubarajan, Asher Mullokandov, Ashish Sabharwal, Austin Herrick, Avia Efrat, Aykut Erdem, Ayla Karaka¸s, B. Ryan Roberts, Bao Sheng Loe, Barret Zoph, Bartłomiej Bojanowski, Batuhan Özyurt, Behnam Hedayatnia, Behnam Neyshabur, Benjamin Inden, Benno Stein, Berk Ekmekci, Bill Yuchen Lin, Blake Howald, Bryan Orinion, Cameron Diao, Cameron Dour, Catherine Stinson, Cedrick Argueta, César Ferri Ramírez, Chandan Singh, Charles Rathkopf, Chenlin Meng, Chitta Baral, Chiyu Wu, Chris Callison-Burch, Chris Waites, Christian Voigt, Christopher D. Manning, Christopher Potts, Cindy Ramirez, Clara E. Rivera, Clemencia Siro, Colin Raffel, Courtney Ashcraft, Cristina Garbacea, Damien Sileo, Dan Garrette, Dan Hendrycks, Dan Kilman, Dan Roth, Daniel Freeman, Daniel Khashabi, Daniel Levy, Daniel Moseguí González, Danielle Perszyk, Danny Hernandez, Danqi Chen, Daphne Ippolito, Dar Gilboa, David Dohan, David Drakard, David Jurgens, Debajyoti Datta, Deep Ganguli, Denis Emelin, Denis Kleyko, Deniz Yuret, Derek Chen, Derek Tam, Dieuwke Hupkes, Diganta Misra, Dilyar Buzan, Dimitri Coelho Mollo, Diyi Yang, Dong-Ho Lee, Dylan Schrader, Ekaterina Shutova, Ekin Dogus Cubuk, Elad Segal, Eleanor Hagerman, Elizabeth Barnes, Elizabeth Donoway, Ellie Pavlick, Emanuele Rodola, Emma Lam, Eric Chu, Eric Tang, Erkut Erdem, Ernie Chang, Ethan A. Chi, Ethan Dyer, Ethan Jerzak, Ethan Kim, Eunice Engefu Manyasi, Evgenii Zheltonozhskii, Fanyue Xia, Fatemeh Siar, Fernando Martínez-Plumed, Francesca Happé, Francois Chollet, Frieda Rong, Gaurav Mishra, Genta Indra Winata, Gerard de Melo, Germán Kruszewski, Giambattista Parascandolo, Giorgio Mariani, Gloria Wang, Gonzalo JaimovitchLópez, Gregor Betz, Guy Gur-Ari, Hana Galijasevic, Hannah Kim, Hannah Rashkin, Hannaneh Hajishirzi, Harsh Mehta, Hayden Bogar, Henry Shevlin, Hinrich Schütze, Hiromu Yakura, Hongming Zhang, Hugh Mee Wong, Ian Ng, Isaac Noble, Jaap Jumelet, Jack Geissinger, Jackson Kernion, Jacob Hilton, Jaehoon Lee, Jaime Fernández Fisac, James B. Simon, James Koppel, James Zheng, James Zou, Jan Kocon,´ Jana Thompson, Janelle Wingfield, Jared Kaplan, Jarema Radom, Jascha Sohl-Dickstein, Jason Phang, Jason Wei, Jason Yosinski, Jekaterina Novikova, Jelle Bosscher, Jennifer Marsh, Jeremy Kim, Jeroen Taal, Jesse Engel, Jesujoba Alabi, Jiacheng Xu, Jiaming Song, Jillian Tang, Joan Waweru, John Burden, John Miller, John U. Balis, Jonathan Batchelder, Jonathan Berant, Jörg Frohberg, Jos Rozen, Jose Hernandez-Orallo, Joseph Boudeman, Joseph Guerr, Joseph Jones, Joshua B. Tenenbaum, Joshua S. Rule, Joyce Chua, Kamil Kanclerz, Karen Livescu, Karl Krauth, Karthik Gopalakrishnan, Katerina Ignatyeva, Katja Markert, Kaustubh D. Dhole, Kevin Gimpel, Kevin Omondi, Kory Mathewson, Kristen Chiafullo, Ksenia Shkaruta, Kumar Shridhar, Kyle McDonell, Kyle Richardson, Laria Reynolds, Leo Gao, Li Zhang, Liam Dugan, Lianhui Qin, Lidia ContrerasOchando, Louis-Philippe Morency, Luca Moschella, Lucas Lam, Lucy Noble, Ludwig Schmidt, Luheng + +He, Luis Oliveros Colón, Luke Metz, Lütfi Kerem ¸Senel, Maarten Bosma, Maarten Sap, Maartje ter Hoeve, Maheen Farooqi, Manaal Faruqui, Mantas Mazeika, Marco Baturan, Marco Marelli, Marco Maru, Maria Jose Ramírez Quintana, Marie Tolkiehn, Mario Giulianelli, Martha Lewis, Martin Potthast, Matthew L. Leavitt, Matthias Hagen, Mátyás Schubert, Medina Orduna Baitemirova, Melody Arnaud, Melvin McElrath, Michael A. Yee, Michael Cohen, Michael Gu, Michael Ivanitskiy, Michael Starritt, Michael Strube, Michał Sw˛edrowski, Michele Bevilacqua, Michihiro Yasunaga, Mihir Kale, Mike Cain, Mimee Xu, Mirac Suzgun, Mitch Walker, Mo Tiwari, Mohit Bansal, Moin Aminnaseri, Mor Geva, Mozhdeh Gheini, Mukund Varma T, Nanyun Peng, Nathan A. Chi, Nayeon Lee, Neta Gur-Ari Krakover, Nicholas Cameron, Nicholas Roberts, Nick Doiron, Nicole Martinez, Nikita Nangia, Niklas Deckers, Niklas Muennighoff, Nitish Shirish Keskar, Niveditha S. Iyer, Noah Constant, Noah Fiedel, Nuan Wen, Oliver Zhang, Omar Agha, Omar Elbaghdadi, Omer Levy, Owain Evans, Pablo Antonio Moreno Casares, Parth Doshi, Pascale Fung, Paul Pu Liang, Paul Vicol, Pegah Alipoormolabashi, Peiyuan Liao, Percy Liang, Peter Chang, Peter Eckersley, Phu Mon Htut, Pinyu Hwang, Piotr Miłkowski, Piyush Patil, Pouya Pezeshkpour, Priti Oli, Qiaozhu Mei, Qing Lyu, Qinlang Chen, Rabin Banjade, Rachel Etta Rudolph, Raefer Gabriel, Rahel Habacker, Ramon Risco, Raphaël Millière, Rhythm Garg, Richard Barnes, Rif A. Saurous, Riku Arakawa, Robbe Raymaekers, Robert Frank, Rohan Sikand, Roman Novak, Roman Sitelew, Ronan LeBras, Rosanne Liu, Rowan Jacobs, Rui Zhang, Ruslan Salakhutdinov, Ryan Chi, Ryan Lee, Ryan Stovall, Ryan Teehan, Rylan Yang, Sahib Singh, Saif M. Mohammad, Sajant Anand, Sam Dillavou, Sam Shleifer, Sam Wiseman, Samuel Gruetter, Samuel R. Bowman, Samuel S. Schoenholz, Sanghyun Han, Sanjeev Kwatra, Sarah A. Rous, Sarik Ghazarian, Sayan Ghosh, Sean Casey, Sebastian Bischoff, Sebastian Gehrmann, Sebastian Schuster, Sepideh Sadeghi, Shadi Hamdan, Sharon Zhou, Shashank Srivastava, Sherry Shi, Shikhar Singh, Shima Asaadi, Shixiang Shane Gu, Shubh Pachchigar, Shubham Toshniwal, Shyam Upadhyay, Shyamolima, Debnath, Siamak Shakeri, Simon Thormeyer, Simone Melzi, Siva Reddy, Sneha Priscilla Makini, Soo-Hwan Lee, Spencer Torene, Sriharsha Hatwar, Stanislas Dehaene, Stefan Divic, Stefano Ermon, Stella Biderman, Stephanie Lin, Stephen Prasad, Steven T. Piantadosi, Stuart M. Shieber, Summer Misherghi, Svetlana Kiritchenko, Swaroop Mishra, Tal Linzen, Tal Schuster, Tao Li, Tao Yu, Tariq Ali, Tatsu Hashimoto, Te-Lin Wu, Théo Desbordes, Theodore Rothschild, Thomas Phan, Tianle Wang, Tiberius Nkinyili, Timo Schick, Timofei Kornev, Titus Tunduny, Tobias Gerstenberg, Trenton Chang, Trishala Neeraj, Tushar Khot, Tyler Shultz, Uri Shaham, Vedant Misra, Vera Demberg, Victoria Nyamai, Vikas Raunak, Vinay Ramasesh, Vinay Uday Prabhu, Vishakh Padmakumar, Vivek Srikumar, William Fedus, William Saunders, William Zhang, Wout Vossen, Xiang Ren, Xiaoyu Tong, Xinran Zhao, Xinyi Wu, Xudong Shen, Yadollah Yaghoobzadeh, Yair Lakretz, Yangqiu Song, Yasaman Bahri, Yejin Choi, Yichi Yang, Yiding Hao, Yifu Chen, Yonatan Belinkov, Yu Hou, Yufang Hou, Yuntao Bai, Zachary Seid, Zhuoye Zhao, Zijian Wang, Zijie J. Wang, Zirui Wang, and Ziyi Wu. 2023. Beyond the imitation game: Quantifying and extrapolating the capabilities of language models. + +Gabriel Stanovsky, Noah A Smith, and Luke Zettlemoyer. 2019. Evaluating gender bias in machine translation. In Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics, pages 1679–1684. + +Mike Thelwall. 2017. The heart and soul of the web? sentiment strength detection in the social web with sentistrength. Cyberemotions: Collective emotions in cyberspace, pages 119–134. + +David Vilares, Miguel A Alonso, and Carlos GómezRodríguez. 2016. En-es-cs: An english-spanish codeswitching twitter corpus for multilingual sentiment analysis. In Proceedings of the Tenth International Conference on Language Resources and Evaluation (LREC’16), pages 4149–4153. + +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. EMNLP 2018, page 353. + +Yizhong Wang, Swaroop Mishra, Pegah Alipoormolabashi, Yeganeh Kordi, Amirreza Mirzaei, Atharva Naik, Arjun Ashok, Arut Selvan Dhanasekaran, Anjana Arunkumar, David Stap, Eshaan Pathak, Giannis Karamanolakis, Haizhi Lai, Ishan Purohit, Ishani Mondal, Jacob Anderson, Kirby Kuznia, Krima Doshi, Kuntal Kumar Pal, Maitreya Patel, Mehrad Moradshahi, Mihir Parmar, Mirali Purohit, Neeraj Varshney, Phani Rohitha Kaza, Pulkit Verma, Ravsehaj Singh Puri, Rushang Karia, Savan Doshi, Shailaja Keyur Sampat, Siddhartha Mishra, Sujan Reddy A, Sumanta Patro, Tanay Dixit, and Xudong Shen. 2022. Super-NaturalInstructions: Generalization via declarative instructions on $1 6 0 0 +$ NLP tasks. In Proceedings of the 2022 Conference on Empirical Methods in Natural Language Processing, pages 5085–5109, Abu Dhabi, United Arab Emirates. Association for Computational Linguistics. + +Tom Warren. 2023. Microsoft’s chatgpt event live blog. + +Jason Wei, Maarten Bosma, Vincent Y. Zhao, Kelvin Guu, Adams Wei Yu, Brian Lester, Nan Du, Andrew M. Dai, and Quoc V. Le. 2021. Finetuned language models are zero-shot learners. CoRR, abs/2109.01652. + +Jason Wei, Xuezhi Wang, Dale Schuurmans, Maarten Bosma, Brian Ichter, Fei Xia, Ed Chi, Quoc Le, and Denny Zhou. 2023. Chain-of-thought prompting elicits reasoning in large language models. arXiv 2201.11903 cs.CL. + +Bryan Wilie, Karissa Vincentio, Genta Indra Winata, Samuel Cahyawijaya, Xiaohong Li, Zhi Yuan Lim, Sidik Soleman, Rahmad Mahendra, Pascale Fung, Syafri Bahar, et al. 2020. Indonlu: Benchmark and resources for evaluating indonesian natural language understanding. arXiv preprint arXiv:2009.05387. + +Shijie Wu and Mark Dredze. 2020. Are all languages created equal in multilingual BERT? In Proceedings of the 5th Workshop on Representation Learning for NLP, pages 120–130, Online. Association for Computational Linguistics. + +Linting Xue, Noah Constant, Adam Roberts, Mihir Kale, Rami Al-Rfou, Aditya Siddhant, Aditya Barua, and Colin Raffel. 2021. mt5: A massively multilingual pre-trained text-to-text transformer. In Proceedings of the 2021 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, pages 483–498. + +Yinfei Yang, Yuan Zhang, Chris Tar, and Jason Baldridge. 2019a. PAWS-X: A cross-lingual adversarial dataset for paraphrase identification. In Proceedings of EMNLP 2019, pages 3685–3690. + +Yinfei Yang, Yuan Zhang, Chris Tar, and Jason Baldridge. 2019b. Paws-x: A cross-lingual adversarial dataset for paraphrase identification. 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 3687–3692. + +Xi Ye and Greg Durrett. 2022a. Can explanations be useful for calibrating black box models? In Proceedings of the 60th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pages 6199–6212, Dublin, Ireland. Association for Computational Linguistics. + +Xi Ye and Greg Durrett. 2022b. The unreliability of explanations in few-shot prompting for textual reasoning. In Advances in Neural Information Processing Systems, volume 35, pages 30378–30392. Curran Associates, Inc. + +Daniel Zeman, Joakim Nivre, Mitchell Abrams, Elia Ackermann, Noëmi Aepli, Hamid Aghaei, and R Ziane. 2020. Universal dependencies 2.5. LINDAT/CLARIAHCZ digital library at the Institute of Formal and Applied Linguistics (UFAL), Faculty of Mathematics and Physics, Charles University. url: http://hdl. handle. net/11234/1-3226. + +Yuan Zhang, Jason Baldridge, and Luheng He. 2019. Paws: Paraphrase adversaries from word scrambling. 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 1298–1308. + +Jieyu Zhao, Tianlu Wang, Mark Yatskar, Vicente Ordonez, and Kai-Wei Chang. 2018. Gender bias in coreference resolution: Evaluation and debiasing methods. In Proceedings of the 2018 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 2 (Short Papers), pages 15–20, New Orleans, Louisiana. Association for Computational Linguistics. + +Mengjie Zhao and Hinrich Schütze. 2021. Discrete and soft prompting for multilingual models. In Proceedings of the 2021 Conference on Empirical Methods in Natural Language Processing, pages 8547–8555, Online and Punta Cana, Dominican Republic. Association for Computational Linguistics. + +Zihao Zhao, Eric Wallace, Shi Feng, Dan Klein, and Sameer Singh. 2021. Calibrate before use: Improving few-shot performance of language models. In Proceedings of the 38th International Conference on Machine Learning, volume 139 of Proceedings of Machine Learning Research, pages 12697–12706. PMLR. + +# A Appendix + +# A.1 Tasks and Datasets + +In our experiments, we consider 16 tasks spanning the following task types - classification, sequence to sequence labeling and generation. Below we review the experimental setups and datasets used for benchmarking for these two tasks. A list of all the datasets with the languages covered by them can be found in Table 3. + +# A.1.1 Classification + +These tasks involve classifying a single sentence or a group of sentences into a finite number of discrete labels. For each dataset, we measure the performance of different models in terms of classification accuracy. For prompt-based models in particular, since we add no constraint on the output space of the LLM we compute the exact match between the generated output and a verbalized label to determine if the example was classified correctly. We run experiments for all the prompting strategies that we discussed in the previous sections for each dataset. The details of each dataset that we use for benchmarking are given below: + +Table 3: Datasets and Language coverage of the datasets that MEGA presents evaluation for. + +
DatasetTaskLanguages
XNLINatural Language Inference15
Indic-XNLINatural Language Inference11
GLUECoSNatural Language Inference2
PAWS-XParaphrase Identification7
XCOPACommonsense Reasoning10
XStoryClozeCommonsense Reasoning11
TyDiQA-GoldPQuestion Answering9
MLQAQuestion Answering6
XQuADQuestion Answering11
IndicQAQuestion Answering10
UDPOSPart of Speech Tagging38
PANXNER48
WinoMTGender Bias8
GLUECoSSentiment Analysis2
JigsawToxicity Classification6
XLSumSummarization44
+ +1. Natural Language Inference: XNLI (Conneau et al., 2018) is a dataset for cross-lingual Natural Language Inference, which consists of professional translations of the MNLI (Wang et al., 2018) corpus into 14 languages. We also consider IndicXNLI (Aggarwal et al., 2022) that translates the XNLI dataset into 11 Indic languages by using Machine Translation, followed by validation by native speakers. + +2. Paraphrase Identification: PAWS-X (Yang et al., 2019b) is a paraphrase identification dataset professionally translated from the PAWS (Zhang et al., 2019) dataset into six typologically diverse languages. + +3. Commonsense Reasoning: XCOPA (Ponti et al., 2020) is a commonsense reasoning dataset, which is a translation of the COPA (Roemmele et al., 2011) dataset into 11 typologically diverse languages, including very low-resource languages such as Eastern Apurímac Quechua and Haitian Creole. + +XStoryCloze (Lin et al., 2022b) is created by translating the English StoryCloze (Mostafazadeh et al., 2017) dataset using professional translators into 10 typologically diverse languages. + +# A.1.2 Question Answering + +We focus on Span Prediction type of Question Answering (QA) tasks in our experiments, where given a context and a question the task is to predict the answer within the context. One major challenge that we come across for multilingual evaluation of QA tasks is that for many languages we often cannot fit the context and question pairs for the fewshot and text examples in the maximum context size of 4096 for the DV003 model. This is mainly attributed to the poor performance of GPT’s tokenizer on many non-latin script languages which results in over-tokenizing the words in these languages. + +To overcome this issue we follow two steps. First, for the few-shot examples we only provide the line within the paragraph containing the answer as the context. Second, for the test example, we index the chunks of the context using the embeddings from the text-embedding-ada-002 model. Given the question, the closest chunk in the full context is retrieved and used in the prompt for the test example. We use a maximum chunk size of 100 in our experiments and use the implementation for retrieval provided in the LangChain4 library. By doing this,we minimize the space taken by the context tokens in our prompt. + +Note that, for newer GPT models i.e. GPT-3.5- Turbo and GPT-4 which support longer context lengths, we do not use this retrieval strategy for QA tasks and prompt the models to obtain the answers directly. For each task, we calculate the Exact Match and F1 score as defined in Rajpurkar et al. (2016a). For our experiments we consider the following four tasks: + +1. TyDiQA (Clark et al., 2020) is a QA dataset covering 11 typologically diverse languages. The task consists of two sub-tasks - passage selection and minimum answer span (Gold-P). For our experiments, we consider the Gold-P task and evaluate Monolingual and Zero-Shot Cross-Lingual prompting strategies. Since the labels do not directly transfer one-to-one across translation for QA tasks as they do for classification and require the use of alignment algorithms, we skip translate-test prompting for this task. + +2. MLQA (Lewis et al., 2020) is an extractive QA dataset translated into 7 languages by professional translators. The task has two variants, the first where the question, context, and answer are all in the same language; and the second, where the question is in a different language than the context and answer. We consider the former variant of the task in our experiments. For MLQA, translatetest splits are also available, where each language’s test data has been translated into English with answers aligned using the attention scores. There is no training data available for MLQA, and we use SQuAD’sRajpurkar et al. (2016a) training data for selecting few-shot examples in English and validation data for MLQA in other languages to get their few-shot examples. This way, we are able to evaluate for all three prompting setups. + +3. XQuAD (Artetxe et al., 2020) consists of professional translations of a subset of the SQuaD dataset (Rajpurkar et al., 2016b) into 10 languages. XQuAD only has validation datasets available publicly, hence we evaluate the models on them. Like MLQA we use English SQuAD data for few-shot examples and since we cannot use validation data in other languages for few-shot, we only evaluate for zero-shot cross-lingual setup for this task. + +4. IndicQA (Doddapaneni et al., 2022) is a manually curated cloze-style reading comprehension dataset that can be used for evaluating questionanswering models in 11 Indic languages. The context paragraphs are chosen from Wikipedia articles whose topics are closely related to Indic culture, history,etc. The publicly available test set has about 2000 sentences that we carry out our evaluation on. + +# A.2 Sequences Labeling + +In the sequence labeling task, a sequence of tokens (such as words) to be labeled are provided to the + +system. + +# A.2.1 Part of Speech Tagging + +UDPOS (Zeman et al., 2020) is a dataset for Part of Speech Tagging taken from the Universal Dependencies 2.5 from the XTREME (Hu et al., 2020) benchmark. We benchmark a subset of the languages available in UDPOS. + +# A.2.2 Named Entity Recognition + +PANX (Pan et al., 2017) or WikiANN is a Named Entity Recognition dataset consisting of Wikipedia sentences tagged with Person, Organization and Location. + +For both tasks we use the linguistic structure prompting approach of Blevins et al. (2022) to define the prompts. The exact prompts used can be found in $\ S \mathbf { A . 4 }$ . Given the nature of both tasks, which would involve token alignment across the translation, we do not evaluate the translate-test prompting strategies for these setups. Also, since both tasks involve $> 3 0$ languages, to make the best use of the compute resources we only evaluate GPT-3.5-Turbo in a monolingual setup for these two tasks. Finally, we evaluate the first 1000 examples for each language for these datasets given the large number of languages. We have recomputed all baselines with this specification as well. + +# A.3 Generation + +# A.3.1 Summarization + +The XLSum (Hasan et al., 2021a) dataset contains article-summary pairs across 44 typologically diverse languages, ranging from high to very lowresource. + +For a similar reason as the tagging datasets, we only evaluate on first 1000 examples of the test sets in different languages and recompute the baselines on the same testset using the weights of the XLSUM pretrained model, opensourced by the authors (Hasan et al., 2021b). + +# A.3.2 Code-switching datasets + +All the datasets we consider so far are monolingual, however, a majority of the world’s population speaks more than one language, leading to language contact phenomena such as code-switching (Dogruöz et al. ˘ , 2021; Sitaram et al., 2019). We include two code-switching datasets in MEGA to benchmark the performance of generative models. + +GLUECoS-NLI (Khanuja et al., 2020a) is a code-mixed NLI dataset in Hindi-English, consisting of Bollywood (Hindi) movie conversations as premises, with manually created hypotheses. + +The EN-ES-CS Sentiment Analysis dataset (Vilares et al., 2016), part of the GLUECoS benchmark (Khanuja et al., 2020b) is a code-mixed dataset consisting of English-Spanish Tweets annotated with SentiStrength (Thelwall, 2017) scores. + +# A.3.3 RAI datasets + +We include two datasets that measure the Responsible AI (RAI) dimensions of fairness and toxicity - Jigsaw5 for toxic comment classification and WinoMT for gender bias. + +The Jigsaw dataset contains online comments sourced from Wikipedia. The training data, which is in English, contains labels pertaining to the toxicity of the comment and any relevant identity mentions contained in the comment. We use the test dataset, which contains these comments for 6 languages as illustrated in Table 3 for evaluation. The test dataset contains a binary label indicating whether or not the comment is toxic. Our objective is to assess the performance of these models across multiple languages and observe the disparity in this performance that could arise due to a number of factors, a prominent one being the source data that these models are trained on. Using English prompts from PromptSource for the original monolingual Jigsaw task, we task the model with classifying a comment as toxic or non-toxic. We perform crosslingual few-shot prompting and translate-test experiments for the test sets of all 6 languages, and report the results excluding content violations in Table 21. + +The WinoMT dataset (Stanovsky et al., 2019) is created by concatenating the WinoGender (Rudinger et al., 2018) and WinoBias (Zhao et al., 2018) datasets. WinoMT dataset consists of 3888 English sentences with equal distribution of Male and Female genders. It is also equally balanced between stereotypical and non-stereotypical gender role assignments. We follow the method as reported by (Stanovsky et al., 2019) in their paper. We perform zero-shot monolingual prompting of all sentences in the dataset to translate them in 8 target languages. Further using fast_align we map the English entity to its translation. Finally, we extract the target-side entity’s using off the shelf tools for each target language. The extracted translated gender can be finally compared against the gold annotations for English. + +# A.4 Prompts + +# A.4.1 XNLI, IndicXNLI, GLUECoS NLI + +Models : GPT-3.5-Turbo, GPT-4 + +Task Instruction $\mathcal { T }$ : You are an NLP assistant whose purpose is to solve Natural Language Inference (NLI) problems. NLI is the task of determining the inference relation between two (short, ordered) texts: entailment, contradiction, or neutral. Answer as concisely as possible in the same format as the examples below: + +Template $f _ { t e m p }$ : {premise} Question: {hypothesis} True, False, or Neither? + +Verbalizer $f _ { v e r b }$ : Entailment : True, Contradiction: False, Neutral: Neither + +Models : DV003 + +Template $f _ { t e m p }$ : {premise} Based on previous passage is it true that {hypothesis} ? Yes, No, or Maybe? + +Verbalizer $f _ { v e r b }$ : Entailment : Yes, Contradiction: No, Neutral: Maybe + +# A.4.2 PAWS-X + +Models : GPT-3.5-Turbo, GPT-4 + +Task Instruction $\mathcal { T }$ : You are an NLP assistant whose purpose is to perform Paraphrase Identification. The goal of Paraphrase Identification is to determine whether a pair of sentences have the same meaning. Answer as concisely as possible in the same format as the examples below: + +Template $f _ { t e m p }$ : +{sentence1} +Question: {sentence2} +True or False? + +Models : DV003 + +Template $f _ { t e m p }$ : Sentence 1: {sentence1} Sentence 2: {sentence2} Question: Does Sentence 1 paraphrase Sentence 2 ? Yes or No? + +Verbalizer $f _ { v e r b }$ : Positive: Yes Negative: No + +# A.4.3 XCOPA + +Models : GPT-3.5-Turbo, GPT-4 + +Task Instruction $\mathcal { T }$ : You are an AI assistant whose purpose is to perform open-domain commonsense causal reasoning. You will be provided a premise and two alternatives, where the task is to select the alternative that more plausibly has a causal relation with the premise. Answer as concisely as possible in the same format as the examples below: + +Template $f _ { t e m p }$ : +{ premise $\}$ +$\{ \%$ if question $= =$ “cause" %} This happened because... +$\{ \%$ else $\% \}$ As a consequence... $\{ \%$ endif $\% \}$ Help me pick the more plausible option: {choice1} - {choice2} + +# Models : DV003 + +Template $f _ { t e m p }$ : +{ premise } +$\{ \%$ if question $= =$ “cause" %} This happened because... +$\{ \%$ else $\% \}$ As a consequence... $\{ \%$ endif $\% \}$ Help me pick the more plausible option: - choice1: {choice1}, choice2: {choice2} + +Verbalizer $f _ { v e r b }$ : choice1: {choice1} choice2: {choice2} + +# A.4.4 XQUAD, TyDiQA, MLQA + +Models : GPT-3.5-Turbo, GPT-4 + +Task Instruction $\mathcal { T }$ : You are an NLP assistant whose purpose is to solve reading comprehension problems. You will be provided questions on a set of passages and you will need to provide the answer as it appears in the passage. The answer should be in the same language as the question and the passage. + +Template ftemp: +{context} +Q: {question} +Referring to the passage above, the correct answer +to the given question is: {answer} + +Models : DV003 + +Template $f _ { t e m p }$ + +{context} +Q: {question} +Referring to the passage above, the correct answer +to the given question is: {answer} + +# A.4.5 IndicQA + +Models : GPT-3.5-Turbo, GPT-4 + +Task Instruction $\mathcal { T }$ : You are an NLP assistant whose purpose is to solve reading comprehension problems. You will be provided questions on a set of passages and you will need to provide the answer as it appears in the passage. The answer should be in the same language as the question and the passage. + +Template ftemp: +{context} +Q: {question} +Referring to the passage above, the correct answer to the given question is? If you can’t find the answer, please respond "unanswerable". {answer} + +Models : DV003 + +Template ftemp: +{context} +Q: {question} +Referring to the passage above, the correct answer +to the given question is: {answer} + +# A.4.6 XStoryCloze + +Models : DV003, GPT-3.5-Turbo, GPT-4 + +Template ftemp: +{input_sentence_1} {input_sentence_2} +{input_sentence_3} {input_sentence_4} +What is a possible continuation for the story given +the following options ? +Option1: {sentence_quiz1} Option2: +{sentence_quiz2} + +Verbalizer $f _ { v e r b }$ : {sentence_quiz1}: Option1, {sentence_quiz2}: Option2 + +# A.4.7 PANX + +Models : GPT-3.5-Turbo, GPT-4 + +Task Instruction $\mathcal { T }$ : You are an NLP assistant whose purpose is to perform Named Entity Recognition (NER). NER involves identifying and classifying named entities in a text into predefined categories such as person names, organizations, locations, and others. You will need to use the tags defined below: O means the word doesn’t correspond to any entity. B-PER/I-PER means the word corresponds to the beginning of/is inside a person entity. B-ORG/IORG means the word corresponds to the beginning of/is inside an organization entity. B-LOC/I-LOC means the word corresponds to the beginning of/is inside a location entity. Do not try to answer the question! Just tag each token in the sentence. + +Template ftemp: {token_1 token_2 token_n} + +Verbalizer $f _ { v e r b }$ : +{tag_1} {tag_2} ... {tag_n}: +{token_1}_{tag_1} {token_2}_{tag_2} +... {token_n}_{tag_n} + +# A.4.8 UDPOS + +Models : GPT-3.5-Turbo, GPT-4 + +Task Instruction $\mathcal { T }$ : You are an NLP assistant whose purpose is to perform Part of Speech (PoS) Tagging. PoS tagging is the process of marking up a word in a text (corpus) as corresponding to a particular part of speech, based on both its definition and its context. You will need to use the tags defined below: + +1. ADJ: adjective +2. ADP: adposition +3. ADV: adverb +4. AUX: auxiliary +5. CCONJ: coordinating-conjunction +6. DET: determiner +7. INTJ: interjection +8. NOUN: noun +9. NUM: numeral +10. PART: particle +11. PRON: pronoun +12. PROPN: proper-noun +13. PUNCT: punctuation +14. SCONJ: subordinating-conjunction +15. SYM: symbol +16. VERB: verb +17. X: other + +Template ftemp: {token_1 token_2 token_n} + +Verbalizer $f _ { v e r b }$ : +{tag_1} {tag_2} ... {tag_n}: +{token_1}_{tag_1} {token_2}_{tag_2} ... {token_n}_{tag_n} + +# A.4.9 GLUECoS Sentiment Analysis + +Models : GPT-3.5-Turbo, GPT-4 + +Task Instruction $\mathcal { T }$ : You are an NLP assistant whose purpose is to solve Sentiment Analysis problems. Sentiment Analysis is the task of determining whether the sentiment, opinion or emotion expressed in a textual data is: positive, negative, or neutral. Answer as concisely as possible in the same format as the examples below: + +Template $f _ { t e m p }$ : Does the following sentence have a positive, negative or neutral sentiment? {text} + +Models : DV003 + +Template $f _ { t e m p }$ : Does the following sentence have a positive, negative or neutral sentiment? {text} + +# A.4.10 XLSum + +Models : GPT-3.5-Turbo, GPT-4 + +Task Instruction $\mathcal { T }$ : You are an NLP assistant whose purpose is to summarize any given article. You should summarize all important information concisely in the same language in which you have been provided the document. Following the examples provided below: + +Template $f _ { t e m p }$ {document} === + +Write a summary of the text above : + +# A.4.11 Jigsaw + +Models : GPT-3.5-Turbo, GPT-4 + +Task Instruction $\mathcal { T }$ : You are an NLP assistant whose purpose is to solve the Jigsaw Toxicity Prompt problem. Toxicity is defined as anything rude, disrespectful or otherwise likely to make someone leave a discussion. The objective is to identify toxic comments. Answer as concisely as possible in the same format as the examples below: + +Template $f _ { t e m p }$ : {text} Should this online comment be removed for its toxicity? Yes or No? + +Models : DV003 + +Template $f _ { t e m p }$ : {text} Someone posted this comment online. Do you find it toxic? Yes or No? + +# A.4.12 WinoMT + +Models : GPT-3.5-Turbo, GPT-4 + +Template $f _ { t e m p }$ : Translate the following English text to {target_language}: {sentence} + +Table 4: Retrieval accuracy on TyDiQA dataset for chunk size $= 1 0 0$ . + +
LanguageRetrieval Acc.
en0.858
ar0.492
bn0.141
fi0.756
id0.680
SW0.760
ko0.453
te0.056
ru0.421
+ +# A.5 Handling Long Contexts + +As discussed in $\ S 2 . 2$ , the models we study have limited context lengths and for QA tasks in particular, fitting the entire prompt containing the few-shot examples is often not feasible for lowresource languages where the tokenizers of these models are found to over-tokenize the text (nearly resulting in byte level tokens). To overcome this issue we follow two steps. First, for the fewshot examples we only provide the line within the paragraph containing the answer as the context. Second, for the test example, we index the chunks of the context using the embeddings from the text-embedding-ada-002 model. Given the question, the closest chunk in the full context is retrieved and used in the prompt for the test example. We use a maximum chunk size of 100 in our experiments and use the implementation for retrieval provided in the LangChain6 library. By doing this,we minimize the space taken by the context tokens in our prompt. Note that, for newer GPT models i.e. GPT-3.5-Turbo and GPT-4 which support longer context lengths, hence we only use this retrieval strategy for DV003 on QA tasks. + +We attribute the significantly worse performance of DV003 on IndicQA to imperfect retrieval in the case of DV003, while for GPT-3.5-Turbo we do not rely on retrieval due to the larger context size. We provide the retrieval accuracies for DV003 (i.e. if the retrieved chunk contains the answer) in Appendix Table 4 , where we clearly see for lowresource languages like Telugu, the accuracies can be as low as $5 \%$ . While beyond the scope of this work, alternate retrieval strategies like using better embeddings from multilingual models for retrieval can be explored to close this gap (Nambi et al., 2023). + +# A.6 Factors Explaining Multilingual Capabilities of LLMs + +We provide correlation plots in Figures 7 (between performance and fertility) and 8 (between performance and pre-training size) for both GPT-3.5- Turbo and GPT-4. The exact values of the correlations for all tasks and the two models is provided in Table 5. + +# A.7 Challenges in Multilingual Evaluation + +Effect of number of in-context examples $k$ . Our main experiments were conducted with $k = 8$ or $k = 4$ , depending on the task. Here, we evaluate what effect different numbers of in-context examples have on XNLI and XCOPA for three languages in Figures 6a and 6b. We observe while the performance increases sharply while moving from 0 to 2-4 examples, it is fairly stable after $k \geq 8$ , with the exception of Haitian Creole in XCOPA, where it continues to improve. + +Effect of language-specific prompt tuning. As discussed in $\ S 2 . 3 . 1$ , we use English validation data for prompt selection in each dataset that we use for all languages. Here, we explore whether separately tuning the prompts for each language helps. For XNLI, we run this experiment on Urdu and Swahili, tuning over ten different prompt templates from Prompt-Source, but find that the same prompt that was tuned for English gets picked up for these two languages as well. For XCOPA however, different prompts are chosen when tuned on Haitian Creole and Tamil. This leads to an improvement in the test performance for Haitian Creole (from $72 \%$ to $7 5 . 6 \%$ , see Figure 6c). Interestingly for Tamil, we see the test performance actually drops slightly compared to the accuracy obtained with prompt selected on English data, which we conjecture might be due to the fact that the validation sets in XCOPA have only 100 examples that may not be sufficient for selecting optimal prompts. + +Effect of Explanations. Ye and Durrett (2022b), showed for text-davinci-002, that prompting the model with explanations before the outputs (Explain-then-Predict) in the in-context examples can help improve few-shot performance substantially on English language datasets. Hence, here we evaluate if they help improve the multilingual performance of the GPT-3.5-Turbo model as well. We perform experiments on XStoryCloze and XCOPA datasets and use the explanations available in Super(a) Correlation between tokenizer fertility and performance for GPT-3.5-Turbo. + +![](images/5c6c207ef49b78dbdea3b75e09780106a95b1e0f80e86a805175f0dc79394c64.jpg) +GPT-3.5-Turbo + +![](images/6ceaa6b681f7089fe9c744ae800a35715512d9529144a186f8051512d5060761.jpg) +Figure 7: Correlation between the performance of GPT-3.5-Turbo and GPT-4 with the tokenizer fertility. + +(b) Correlation between tokenizer fertility and performance for GPT-4 (a) Correlation between pre-training size and performance for GPT-3.5-Turbo. + +![](images/ddf8539348ee432c87151aec64030069fed79c80a5647615e2e98c9c37418f31.jpg) +GPT-3.5-Turbo + +![](images/c923b459fd73af6444306c949b70d18157532cd8d613d715deb7162cfc4f026e.jpg) +(b) Correlation between pre-training size and performance for GPT-4 +Figure 8: Correlation between the performance of GPT-3.5-Turbo and GPT-4 with the pre-training size. + +Table 5: Pearson Correlation coefficient $\rho$ between performance and tokenizer fertility and performance and pre-training data size for different datasets and models. We also provide the p-values, to see which correlations are statistically significant. + +
Tokenizer FertilityPre-training Size
GPT-3.5-TurboGPT-4GPT-3.5-TurboGPT-4
TaskpP-valuepP-valuepP-valuepP-value
XNLI+IndicXNLI-0.7846.9e-05-0.8033.4e-050.8934.1e-090.8363.5e-07
XCOPA-0.9827.9e-05-0.9570.000.700.0350.4890.181
XstoryCloze-0.7450.033-0.9180.0010.6030.0640.4070.242
PAWS-X-0.5870.219-0.610.1980.850.0310.940.005
MLQA-0.4510.368-0.6740.1410.710.0850.8080.051
TyDiQA-GoldP0.5430.1630.0490.907-0.4640.207-0.1590.682
XQuAD-0.8650.00-0.8180.0020.7820.0040.7360.009
IndicQA-0.9600.002-0.8560.0290.6280.0510.6900.027
WinoMT-0.360.37910.2490.58911
Jigsaw0.3060.55411-0.6740.14111
PAN-X-0.4560.003-0.4420.0040.410.0060.3260.032
UDPOS-0.2160.198-0.3040.0660.290.0950.3590.036
XLSum-0.8214.8e-07-0.5780.0020.4480.0110.490.005
+ +NaturalInstructions (SNI)(Wang et al., $2 0 2 2 ) ^ { 7 }$ . All the explanations that we used were written in English. For XStoryCloze, the results are plotted in Figure 6d, and we observe that while there is a slight gain upon using explanations for Telugu, for all other languages the performance remains largely unchanged if not slightly worse. Interestingly, upon manual inspection of the model’s prediction, we observe that the model often first translates the problem to English and then proceeds with the explanation, without having prompted to do so. We have similar observations for the XCOPA dataset as well, where adding explanations doesn’t help improve performance and ends up hurting the performance by a slight margin (Figure 9) + +Effect of the language of the prompt templates. While all our experiments were run using prompt templates written in English, we initially evaluated DV003 on Native-Language-Templates as well, which were obtained by translating English templates using Bing-Translator. As can be seen in Table 6, the performance is much worse when using templates in the native language compared to English. This is consistent with the results in Muennighoff et al. (2022) for BLOOMZ and Lin et al. + +![](images/566177a60959501403aed76c47d999a77e09633169e4611f6b2f665b89c78d5f.jpg) +Figure 9: Effect of using explanations in XCOPA dataset. Blue bars mean no explanations in the prompt and orange bars correspond to prompting with explanations. + +Table 6: Average performance on non-English languages with the Monolingual Prompting strategy using English-Template and Native-Language-Template prompts for the classification tasks for DV003. + +
TaskEnglish-TemplateNative-Language-Template
XNLI58.354.4
Indic-XNLI49.638.7
PAWS-X67.164.2
XCOPA77.673.1
+ +
ModelIndicXNLIIndicQA
MuRIL72.447.7
text-davinci-00349.68.45
text-davinci-003 (TT)62.4×
gpt-3.5-turbo50.738.6
gpt-3.5-turbo (TT)59.7×
gpt-4-32k66.855.0
+ +Table 7: Comparing performance of text-davinci-003, gpt-3.5-turbo, and gpt- $- 4 - 3 2 k$ with fine-tuned baseline MuRIL on Indic datasets (Doddapaneni et al., 2022). For IndicXNLI we report Accuracy and F1-score for IndicQA. + +(2022a) for XGLM, which also show better performance when using prompt templates in English. + +# A.8 Detailed Results + +The results for across all tasks, languages and models included in our benchmarking exercise can are provided in Figures 10 (for Classification tasks), 11 (for QA Tasks), 12 (for XLSum), 14 (for PAN-X), 13 (for UDPOS), 15 (for Jigsaw), and finally 16 (for Wino-MT). The results for the Indic Datasets and the two code-mixed datasets GLUECoS NLI and En-ES-CS are provided in Tables 7 8 respectively. + +
ModelNLI En-HiSentiment En-Es
mBERT63.169.31
text-davinci-00372.168.8
gpt-3.5-turbo78.868.0
+ +Table 8: Performance of GPT-3.5 models on codemixing datasets from (Khanuja et al., 2020b). For both the tasks, the metric reported is accuracy. + +![](images/b8a92eb0dd6b2a44d24d9c2cc8b10d3d388559acec381d5f23f4033b04e2c780.jpg) +Figure 10: Comparing the language-wise performance of different models on the classification tasks. + +![](images/ae9f9f1f18f32972ac2af388c436c53e1a6fa01fe39786314008b3c6341f7098.jpg) +Figure 11: Comparing the language-wise performance of different models on the QA tasks. + +![](images/1f1547cae639c9d9ea9b52448f1937c21653047b4f640cd47700c670444a86d0.jpg) +Figure 12: Comparing performance of different models on XLSUM. + +![](images/28b81a53c6d78b8773722985bf2f7e882303c61cc56c98ad18ec164a5e43f59b.jpg) +Figure 13: Comparing performance of different models on UDPOS + +![](images/405c262301becbe4ec8e107b9c6daec0edc85dec14af097657e6153d01bb1003.jpg) +Figure 14: Comparing performance of different models on PAN-X + +![](images/5110614322be71089b6c05e3be5558f303af0bfc1b9c6153d7b307046240f85a.jpg) +Figure 15: Comparing performance of different models on the Jigsaw dataset. + +![](images/7ecc91acf648c7672c2a7c9a240e8116e2c485882bad7fca6691367c170ca415.jpg) +Figure 16: Comparing performance of different models on the WinoMT dataset. + +Table 9: Comparing performance of different models on all languages in XNLI. Metric: Accuracy. + +
Modelenarbgdeelesfrhiruswthtrurvizhavg
Fine-tuned Baselines
mBERT80.864.368.070.065.373.573.458.967.849.754.160.957.269.367.865.4
mT5-Base84.773.378.677.477.180.379.170.877.169.473.272.868.374.274.175.4
XLM-R Large88.777.283.082.580.883.782.275.679.171.277.478.071.779.378.279.2
TuLRv6 - XXL93.389.090.690.090.291.190.786.289.285.587.588.482.789.088.488.8
Prompt-Based Baselines
BLOOMZ67.560.746.554.047.461.261.456.853.350.443.842.750.061.056.754.2
XGLM52.646.448.945.648.745.849.446.848.644.546.645.443.448.548.847.3
Open AI Models
gpt-3.5-turbo76.259.063.567.365.170.367.755.562.556.354.062.649.160.962.162.1
gpt-3.5-turbo (TT)76.262.767.369.467.269.669.059.963.755.859.663.854.063.962.664.3
text-davinci-00379.552.261.865.859.771.065.747.662.250.251.157.950.056.458.059.3
text-davinci-003 (TT)79.565.170.871.769.372.271.863.367.357.362.067.655.166.965.867.1
gpt-4-32k84.973.177.378.879.078.879.572.074.370.968.876.368.174.374.675.4
+ +
Modelasbnguhiknmlmrorpatateavg
Fine-tuned Baselines
MuRIL76.075.077.077.077.079.0 74.076.077.077.074.076.0
Open AI Models
gpt-3.5-turbo49.553.650.655.553.948.449.947.453.648.247.450.7
gpt-3.5-turbo (TT)54.361.661.859.660.859.958.758.562.358.360.859.7
text-davinci-00348.652.651.256.949.148.249.446.450.445.547.249.6
text-davinci-003(TT)56.066.064.762.663.961.860.960.864.761.863.162.4
gpt-4-32k63.572.266.971.769.064.366.261.171.163.764.866.8
+ +Table 10: Comparing performance of different models on all languages in IndicXNLI. Metric: Accuracy. + +
Modelendeesavg
Fine-tuned Baselines
mBERT94.085.787.487.073.069.677.081.9
mT5-Base95.489.489.691.279.878.581.186.4
XLM-R Large94.789.790.190.478.779.082.386.4
TuLRv6 - XXL97.295.194.895.689.490.490.493.2
Prompt-Based Baselines
BLOOMZ89.884.388.987.574.485.865.282.3
Open AI Models
gpt-3.5-turbo72.470.672.072.167.266.569.270.0
gpt-3.5-turbo (TT)72.470.869.770.161.962.563.167.2
text-davinci-00372.570.672.770.760.661.860.867.1
text-davinci-003 (TT)72.569.870.171.365.465.865.268.6
gpt-4-32k76.274.074.172.671.569.972.673.0
+ +Table 11: Comparing performance of different models on all languages in PAWS-X. Metric: Accuracy. + +
Modelenethtiditquswtathtravg
Fine-tuned Baselines
mT5-Base150.349.949.249.650.550.449.250.749.549.9
TuLRv6 - XXL-77.478.092.696.061.069.485.487.292.874.0
Prompt-Based Baselines
BLOOMZ88.048.055.086.074.050.060.067.050.054.063.2
XGLM165.958.968.969.247.162.956.362.058.561.1
Open AI Models
gpt-3.5-turbo97.890.672.090.495.254.682.059.077.691.081.0
gpt-3.5-turbo (TT)97.888.279.490.894.450.077.687.082.287.883.5
text-davinci-00398.287.875.091.496.054.863.653.866.687.877.5
text-davinci-003 (TT)98.289.682.893.094.650.082.887.084.889.885.3
gpt-4-32k99.698.893.297.699.858.694.479.687.897.490.7
gpt-4-32k (TT)99.694.485.896.098.285.883.491.487.892.290.6
+ +Table 12: Comparing performance of different models on all languages in XCOPA. Metric: Accuracy. + +Table 13: Comparing performance of different models on all languages in XQuAD. Metric: F1 Score / Exact Match. + +
Modelenardeeleshiruthtrvizhavg
Fine-tuned Baselines
mBERT83.5/72.261.5 /45.170.6/54.062.6 /44.975.5 /56.959.2/46.071.3/53.342.7 /33.555.4/40.169.5 /49.658.0/48.364.5 /49.4
mT5-Base84.6/71.763.8/44.373.8/54.559.6/35.674.8 /56.160.3/43.457.8/34.757.6/45.767.9/48.270.7 /50.366.1/54.167.0/49.0
XLM-R Large86.5/75.768.6/49.080.4/63.479.8 /61.782.0 /63.976.7 /59.780.1/64.374.2/62.875.9 /59.379.1/59.059.3/50.076.6/60.8
TuLRv6 - XXL90.1/80.685.4 / 69.686.1/70.486.3/70.487.6/71.085.9/70.586.8/73.287.0 /81.184.3/71.087.6/71.379.2/73.286.0 /72.9
Prompt-Based Baselines
BLOOMZ92.1/83.882.8/69.776.3/60.449.7 /37.686.8 /71.483.4/72.965.7/47.220.5 / 15.551.4/37.286.9/72.782.4 /78.670.7 /58.8
Open AI Models
gpt-3.5-turbo79.3/58.759.6/35.170.6/46.649.0 /22.870.3/40.854.0/29.058.0/31.341.9 /30.461.8/35.069.1/42.450.4/48.360.4/38.2
text-davinci-00377.2/61.836.8/22.555.2/39.731.8/19.761.8 /41.319.9 /10.029.4 /17.611.5/8.744.8/29.241.7 /25.435.6/32.8340.5/28.1
gpt-4-32k83.2/65.667.8/42.471.9/48.762.3 /36.677.5/50.763.9 /36.763.8/35.854.6/42.070.8/46.675.8/49.760.0 /57.568.3/46.6
+ +Table 14: Comparing performance of different models on all languages in TyDiQA. Metric: F1 Score / Exact Match. + +
ModelenarbnfidkoruSwteavg
Fine-tuned Baselines
mBERT75.3/ 63.662.2/42.849.3/32.759.7 /45.364.8/45.858.8/50.060.0/38.857.5 /37.949.6 /38.459.7 /43.9
mT5-Base71.8 / 60.967.1/50.440.7 / 22.167.0/ 52.271.3 / 54.549.5 / 37.754.9 /32.660.4 /43.940.6 /31.158.1/42.8
XLM-R Large71.5/ 56.867.6/40.464.0/47.870.5 /53.277.4 / 61.931.9 / 10.967.0 /42.166.1/48.170.1/43.665.1/45.0
TuLRv6- XXL85.4/76.484.1/70.486.9 /79.683.8 /72.888.8 / 77.978.5/ 67.881.9 /68.687.2 /79.685.2/71.684.6/73.8
Prompt-Based Baselines
BLOOMZ82.4 /70.981.9 / 62.287.8 /82.343.6/28.685.0 /71.052.3/43.167.4 /51.586.0/77.290.3 /81.675.2/63.2
Open AI Models
gpt-3.5-turbo54.8/30.750.9 /24.260.7/32.766.6/49.067.2/43.459.7 /45.345.8 /20.064.3/47.770.9 / 53.160.1/38.4
text-davinci-00373.7 / 59.156.2/38.716.1/10.670.3/58.868.6/51.240.6/32.242.3 / 28.974.1/ 62.35.8/3.049.8 /38.3
gpt-4-32k72.9 / 51.460.8/32.768.0/42.575.4/57.780.8/61.169.7 / 58.561.4 /30.581.8/68.772.5/ 54.971.5/ 50.9
+ +Table 15: Comparing performance of different models on all languages in MLQA. Metric: F1 Score / Exact Match. + +
Modelenardeeshivizhavg
Fine-tuned Baselines
mBERT80.2 /67.052.3 /34.659.0 /43.867.4 /49.250.2/35.361.2/40.759.6/38.661.4 /44.2
mT5-Base81.7 / 66.957.1 /36.962.1/43.267.1/47.255.4 /37.965.9 /44.161.6 /38.664.4 /45.0
XLM-R Large83.5 /70.666.6 /47.170.1 / 54.974.1/56.670.6 /53.174.0 /52.962.1/37.071.6 /53.2
TuLRv6 - XXL86.6 / 74.476.2 / 56.580.2 / 67.081.7 / 65.182.2 / 64.882.3 / 63.278.1 / 56.581.0 / 63.9
Open AI Models
gpt-3.5-turbo72.8 / 53.248.5 /23.951.0 /29.653.8 /29.450.7 /28.958.9 /35.156.7 /29.456.1/32.8
gpt-3.5-turbo (TT)72.8 /53.237.8 /18.444.3 / 26.254.1/31.837.3 /20.041.6 / 22.536.5 / 17.246.4 / 27.0
text-davinci-00374.8 / 59.038.4 /21.757.7 /38.162.9 /37.824.9 /14.147.7 / 29.732.3 /31.748.4 /33.1
text-davinci-003(TT)74.8 /59.048.2 /25.653.5 /33.962.9 /40.949.2/28.751.0 / 30.445.2 /24.155.0 /34.7
gpt-4-32k80.3 /62.859.1 /33.564.7 /44.470.0 /45.957.3 /35.672.2 /49.067.1/38.467.2 /44.2
+ +
Modelasbnguhiknmlmrorpatateavg
Fine-tuned Baselines
BLOOMZ40.6/31.742.9 /36.637.2/29.944.0 /45.137.8/26.630.5/28.439.2/33.025.4/22.026.4/33.539.7/35.938.9/34.736.6/32.5
Open AI Models
gpt-3.5-turbo35.3/21.449.5 /30.240.5 /25.555.9 /39.335.3/20.430.0 /19.250.0/32.022.1/12.735.8/ 15.132.7 /21.632.9 /19.738.2/23.4
text-davinci-0036.7/3.210.3/5.85.4/3.516.8 /11.87.1/3.93.6/2.314.6/8.56.9/3.410.7 /4.14.2/2.56.8/3.68.4/4.8
gpt-4-32k58.8/40.467.1/47.459.4/42.475.2/62.247.1/31.648.3 /33.760.7 /43.129.9 / 16.756.1/34.154.0/39.747.9 /27.855.0/38.1
+ +Table 16: Comparing performance of different models on all languages in IndicQA. Metric: F1 Score / Exact Match. + +Table 17: Comparing performance of different models on all languages in POS. Metric: F1 Score. (All numbers are Monolingual results except the ones marked with $\dagger$ symbol which indicate Zero-Shot Cross-Lingual results (due to the absence of training data in those languages) + +
Modelenafarbgdeeleseteufaffrhehihuiditjakk
Fine-tuned Baselines
mBERT96.486.750.084.788.780.986.679.962.165.573.381.255.566.078.674.287.847.270.4
XLM-R Large97.089.263.088.391.286.589.287.374.970.882.786.767.575.283.475.789.229.378.3
Open AI Models
gpt-3.5-turbo78.574.338.379.180.747.134.876.072.046.779.578.053.850.765.463.675.447.464.8
gpt-4-32k84.177.642.083.186.349.868.480.279.346.482.785.460.452.268.368.684.160.271.8
ko1tmrnlplptrorutatethttrukurviwoyozhavg
Fine-tuned Baselines
mBERT78.868.780.788.082.458.580.570.580.671.9
XLM-R Large51.7 57.184.281.888.6 89.586.890.271.5 82.687.364.075.2 84.241.3 48.592.481.285.856.6 70.855.4 58.50.0 0.056.6 24.859.6 44.176.2
Open AI Models
gpt-3.5-turbo39.071.357.978.381.776.766.769.932.679.825.554.377.258.939.957.750.47.060.2
gpt-4-32k51.273.779.181.8†80.781.066.3t74.734.784.631.258.4t77.061.941.364.759.1333.8t57.263.566.6
+ +Table 18: Comparing performance of different models on all languages in PAN-X. Metric: F1 Score. + +
Modelenafarazbgbndeeleseteufaffrguhehihuiditjajvkakk
Fine-tuned Baselines
mBERT86.476.142.965.576.769.779.570.975.375.864.440.076.679.651.356.265.976.161.081.329.262.465.150.3
XLM-R Large85.478.647.369.480.974.780.779.271.878.761.655.279.679.862.755.570.980.251.880.318.561.970.954.4
Open AI Models
gpt-3.5-turbo43.243.845.442.151.640.352.741.060.258.731.539.359.150.718.434.345.553.758.460.07.457.725.130.9
gpt-4-32k49.755.959.459.662.652.769.254.468.674.457.867.671.168.523.848.059.471.972.772.89.268.831.645.3
kotmlmrmsmymlpaplptquroruSwtatethttrukurviyozhavg
Fine-tuned Baselines
mBERT59.575.853.057.067.145.781.030.579.280.458.574.063.971.450.748.90.472.673.469.735.474.545.842.562.3
XLM-R Large59.275.860.263.468.555.283.249.479.379.958.578.771.968.958.453.80.774.780.378.060.378.337.026.665.2
Open AI Models
gpt-3.5-turbo27.951.925.234.452.08.759.436.758.448.941.942.729.457.726.022.01.736.550.534.435.733.556.913.340.3
gpt-4-32k51.471.335.6547.464.116.367.949.870.364.569.859.664.868.936.933.02.561.972.958.469.658.473.918.555.5
+ +
Modelareneseuhiidmyruswtezhavg
Prompt-Based Baselines
BLOOMZ79.795.787.370.579.985.649.967.365.367.490.076.2
XGLM59.875.969.263.862.570.861.272.465.263.467.766.5
Open AI Models
gpt-3.5-turbo92.596.895.878.491.195.057.296.692.373.195.687.7
gpt-3.5-turbo (TT)94.396.896.192.594.795.288.696.288.793.695.693.9
text-davinci-00387.498.397.678.177.896.447.494.278.157.695.082.5
text-davinci-003(TT)95.098.396.294.195.195.990.196.990.794.396.294.8
gpt-4-32k99.199.699.597.698.899.077.699.198.493.499.296.5
gpt-4-32k (TT)97.799.698.796.897.998.193.299.293.696.498.397.0
+ +Table 19: Comparing performance of different models on all languages in XStoryCloze. Metric: Accuracy. + +
GoogleMicrosoftAmazonSystranGPT Turbo 3.5Bloomz
Acc△G△sAcc△G△sAcc△G△sAcc△G△sAcc△G△sAcc△G△s
es50.923.220.94536.522.957.215.321.742.546.215.654.922.726.255.617.232.5
fr61.66.122.344.534.215.854.216.41543.441.8-0.152.721.426.15217.824.6
it38.632.918.638.841.810.540.226.814.738.147.36.345.121.926.745.7918.5
ru37.836.711.436.9428.439.834.89.437.344.19.24131.610.25.9INV0
uk38.443.510.741.346.811.9--28.922.412.942.934.212.116.822.72.2
he50.811.735.5442229.84813.645.943.126.923.157.57.640.827.531.45
ar45.842.516.24547.114.248.337.818.845.649.4-4.161.113.927.948.12325.6
de59.412.512.674.108.862.41216.748.534.51057.519.514.247.656.26.6
+ +Table 20: Performance of commercial MT systems and LLMs on the WinoMT corpus on 8 target languages. Results are categorized by language family. Acc indicates overall gender accuracy ( $\%$ of instances the translation had the correct gender), $\bar { \Delta } _ { G }$ denotes the difference in performance (F1 score) between masculine and feminine scores, and $\Delta _ { S }$ is the difference in performance (F1 score) between pro-stereotypical and anti-stereotypical gender role assignments (higher numbers in the two latter metrics indicate stronger biases). Numbers in bold indicate best accuracy for the language across all systems. Notes: [1. For Google, Microsoft, Amazon, and Systran we use the translations provided by (Stanovsky et al., 2019). Some values differ from the original paper due to updated Spcay modules. 2. For Ru in Bloomz, Precision in male predictions is 0 leading to Invalid (INV) in $\Delta _ { G } ]$ + +
Modelesfritptrutravg
LLM Baselines
PALM (0-Shot)79.8378.99177.5880.3584.180.17
PALM (10-Shot Monolingual)91.2386.16=90.9992.4784.589.07
PALM-2 (0-Shot)88.684.1187.6890.593.4288.86
PALM-2 (10-Shot Monolingual)89.6887.94=92.0594.2594.3491.65
OpenAI Models
gpt-3.5-turbo (Crosslingual)77.2773.6480.0581.1674.9985.6578.79
gpt-3.5-turbo (TT)74.2070.0976.6772.6673.6882.9975.05
text-davinci-0o3 (Crosslingual)7974.5581.1181.6379.1393.5581.50
text-davinci-003 (TT)79.0672.9378.9375.1880.4893.2279.97
+ +Table 21: Comparing performance of different models on all languages in Jigsaw. Metric: Accuracy. \ No newline at end of file diff --git a/md/dev/k7FuTOWMOc7/k7FuTOWMOc7.md b/md/dev/k7FuTOWMOc7/k7FuTOWMOc7.md new file mode 100644 index 0000000000000000000000000000000000000000..2bf8962399d59c4c0da0661ffecea05ff0c0441a --- /dev/null +++ b/md/dev/k7FuTOWMOc7/k7FuTOWMOc7.md @@ -0,0 +1,282 @@ +# Elucidating the Design Space of Diffusion-Based Generative Models + +Tero Karras NVIDIA tkarras@nvidia.com + +Miika Aittala NVIDIA maittala@nvidia.com + +Timo Aila NVIDIA taila@nvidia.com + +Samuli Laine NVIDIA slaine@nvidia.com + +# Abstract + +We argue that the theory and practice of diffusion-based generative models are currently unnecessarily convoluted and seek to remedy the situation by presenting a design space that clearly separates the concrete design choices. This lets us identify several changes to both the sampling and training processes, as well as preconditioning of the score networks. Together, our improvements yield new state-of-the-art FID of 1.79 for CIFAR-10 in a class-conditional setting and 1.97 in an unconditional setting, with much faster sampling (35 network evaluations per image) than prior designs. To further demonstrate their modular nature, we show that our design changes dramatically improve both the efficiency and quality obtainable with pre-trained score networks from previous work, including improving the FID of a previously trained ImageNet-64 model from 2.07 to near-SOTA 1.55, and after re-training with our proposed improvements to a new SOTA of 1.36. + +# 1 Introduction + +Diffusion-based generative models [45] have emerged as a powerful new framework for neural image synthesis, in both unconditional [16, 36, 48] and conditional [17, 35, 36, 38, 39, 41, 42, 48] settings, even surpassing the quality of GANs [13] in certain situations [9]. They are also rapidly finding use in other domains such as audio [27, 37] and video [19] generation, image segmentation [4, 54] and language translation [34]. As such, there is great interest in applying these models and improving them further in terms of image/distribution quality, training cost, and generation speed. + +The literature on these models is dense on theory, and derivations of sampling schedule, training dynamics, noise level parameterization, etc., tend to be based as directly as possible on theoretical frameworks, which ensures that the models are on a solid theoretical footing. However, this approach has a danger of obscuring the available design space — a proposed model may appear as a tightly coupled package where no individual component can be modified without breaking the entire system. + +As our first contribution, we take a look at the theory behind these models from a practical standpoint, focusing more on the “tangible” objects and algorithms that appear in the training and sampling phases, and less on the statistical processes from which they might be derived. The goal is to obtain better insights into how these components are linked together and what degrees of freedom are available in the design of the overall system. We focus on the broad class of models where a neural network is used to model the score [22] of a noise level dependent marginal distribution of the training data corrupted by Gaussian noise. Thus, our work is in the context of denoising score matching [51]. + +![](images/a112149465978ffdcd87523188d94f77b32f0ddb4e19c611ea752326c5d78465.jpg) +Figure 1: Denoising score matching on CIFAR-10. (a) Images from the training set corrupted with varying levels of additive Gaussian noise. High levels of noise lead to oversaturated colors; we normalize the images for cleaner visualization. (b) Optimal denoising result from minimizing Eq. 2 analytically (see Appendix B.3). With increasing noise level, the result approaches dataset mean. + +Our second set of contributions concerns the sampling processes used to synthesize images using diffusion models. We identify the best-performing time discretization for sampling, apply a higherorder Runge–Kutta method for the sampling process, evaluate different sampler schedules, and analyze the usefulness of stochasticity in the sampling process. The result of these improvements is a significant drop in the number of sampling steps required during synthesis, and the improved sampler can be used as a drop-in replacement with several widely used diffusions models [36, 48]. + +The third set of contributions focuses on the training of the score-modeling neural network. While we continue to rely on the commonly used network architectures (DDPM [16], NCSN [47]), we provide the first principled analysis of the preconditioning of the networks’ inputs, outputs, and loss functions in a diffusion model setting and derive best practices for improving the training dynamics. We also suggest an improved distribution of noise levels during training, and note that non-leaking augmentation [25] — typically used with GANs — is beneficial for diffusion models as well. + +Taken together, our contributions enable significant improvements in result quality, e.g., leading to record FIDs of 1.79 for CIFAR-10 [28] and 1.36 for ImageNet [8] in $6 4 \times 6 4$ resolution. With all key ingredients of the design space explicitly tabulated, we believe that our approach will allow easier innovation on the individual components, and thus enable more extensive and targeted exploration of the design space of diffusion models. Our implementation and pre-trained models are available at https://github.com/NVlabs/edm + +# 2 Expressing diffusion models in a common framework + +Let us denote the data distribution by $p _ { \mathrm { d a t a } } ( \pmb { x } )$ , with standard deviation $\sigma _ { \mathrm { d a t a } }$ , and consider the family of mollified distributions $p ( { \pmb x } ; { \boldsymbol \sigma } )$ obtained by adding i.i.d. Gaussian noise of standard deviation $\sigma$ to the data. For $\sigma _ { \mathrm { m a x } } \gg \sigma _ { \mathrm { d a t a } }$ , $p ( \pmb { x } ; \sigma _ { \mathrm { m a x } } )$ is practically indistinguishable from pure Gaussian noise. The idea of diffusion models is to randomly sample a noise image $\mathbf { \boldsymbol { x } } _ { 0 } \sim \mathcal { N } ( \mathbf { \boldsymbol { 0 } } , \mathbf { \dot { \sigma } } _ { \operatorname* { m a x } } ^ { 2 } \mathbf { I } )$ , and sequentially denoise it into images $\mathbf { \Delta } _ { \mathbf { \mathcal { X } } _ { i } }$ with noise levels $\sigma _ { 0 } = \sigma _ { \mathrm { m a x } } > \sigma _ { 1 } > \cdot \cdot \cdot > \sigma _ { N } = 0$ so that at each noise level $\pmb { x } _ { i } \sim p ( \pmb { x } _ { i } ; \sigma _ { i } )$ . The endpoint $\scriptstyle { \mathbf { { \mathit { x } } } } _ { N }$ of this process is thus distributed according to the data. + +Song et al. [48] present a stochastic differential equation (SDE) that maintains the desired distribution $p$ as sample $_ { \textbf { \em x } }$ evolves over time. This allows the above process to be implemented using a stochastic solver that both removes and adds noise at each iteration. They also give a corresponding “probability flow” ordinary differential equation (ODE) where the only source of randomness is the initial noise image $\scriptstyle { \mathbf { { \mathit { x } } } } _ { 0 }$ . Contrary to the usual order of treatment, we begin by examining the ODE, as it offers a fruitful setting for analyzing sampling trajectories and their discretizations. The insights carry over to stochastic sampling, which we reintroduce as a generalization in Section 4. + +ODE formulation. A probability flow ODE [48] continuously increases or reduces noise level of the image when moving forward or backward in time, respectively. To specify the ODE, we must first√ choose a schedule $\sigma ( t )$ that defines the desired noise level at time $t$ . For example, setting $\sigma ( t ) \propto \sqrt { t }$ is mathematically natural, as it corresponds to constant-speed heat diffusion [12]. However, we will show in Section 3 that the choice of schedule has major practical implications and should not be made on the basis of theoretical convenience. + +The defining characteristic of the probability flow ODE is that evolving a sample $\pmb { x } _ { a } \sim p \big ( \pmb { x } _ { a } ; \sigma ( t _ { a } ) \big )$ from time $t _ { a }$ to $t _ { b }$ (either forward or backward in time) yields a sample $\mathbf { \bar { x } } _ { b } \sim p \mathbf { \bar { ( } } \mathbf { x } _ { b } ; \sigma ( t _ { b } ) \mathbf { \bar { ) } }$ . Following previous work [48], this requirement is satisfied (see Appendix B.1 and B.2) by + +$$ +\mathrm { d } \mathbf { { \boldsymbol { x } } } = - \dot { \sigma } ( t ) \sigma ( t ) \nabla _ { \mathbf { { \boldsymbol { x } } } } \log p \big ( \mathbf { { \boldsymbol { x } } } ; \sigma ( t ) \big ) \ \mathrm { d } t , +$$ + +Table 1: Specific design choices employed by different model families. $N$ is the number of ODE solver iterations that we wish to execute during sampling. The corresponding sequence of time steps is $\{ t _ { 0 } , t _ { 1 } , \ldots , t _ { N } \}$ , where $t _ { N } = 0$ . If the model was originally trained for specific choices of $N$ and $\{ t _ { i } \}$ , the originals are denoted by $M$ and $\{ u _ { j } \}$ , respectively. The denoiser is defined as $D _ { \theta } ( { \pmb x } ; \sigma ) = c _ { \mathrm { s k i p } } ( \sigma ) { \pmb x } + c _ { \mathrm { o u t } } ( \sigma ) F _ { \theta } \left( c _ { \mathrm { i n } } ( \sigma ) { \pmb x } ; c _ { \mathrm { n o i s e } } ( \sigma ) \right) ;$ ; $F _ { \theta }$ represents the raw neural network layers. + +
VP [48]VE [48]iDDPM[36]+DDIM[46]Ours("EDM")
Sampling (Section 3)
ODE solver Time stepsEuler ti<N 1+ N-1(∈s-1)Euler max( Euler uLjo+2nd order Heun (omax+
N-1 uM=0 u+1 uj-1=√
Schedule Scalingσ(t)√eβat²+βmint_1 s(t)1/eβdt²+βmintVt 1tt 1
Network and preconditioning (Section 5)1
Architecture of Fe
DDPM++NCSN++DDPM(any)
Skip scaling Cskip(σ)111a/(0²+a)
Output scaling Cout (σ)010 data/a+²
Input scalingCin(σ)1/²+111/√g²+11/²+0ata
Noise cond. Cnoise(σ)(M-1) σ-1(σ)ln()M-1-arg minj luj - σl1 n(0)
Training (Section 5)
Noise distributionσ-1(σ)~U(∈,1)ln(σ)~u(ln(σmin), ln(σmax))σ=uj,j~U{0,M-1}In(σ)~ N(Pmean, P²d)
Loss weighting λ(σ)1/g21/g21/g²(note: *)(σ²+σ²ata)/(σ·Odata)²
Parametersβd = 19.9,βmin =0.1 ∈s =10-³, = 10-5Omin =0.02 Omax =100aj = sin²((+) C1=0.001,C=0.008Omin = 0.002,gmax =80 Odata=0.5,p=7
+ +∗ iDDPM also employs a second loss term $L _ { \mathrm { v l b } }$ † In our tests, $\overline { { j _ { 0 } = 8 } }$ yielded better FID than $\overline { { j _ { 0 } = 0 } }$ used by iDDPM + +where the dot denotes a time derivative. $\nabla _ { \pmb { x } } \log p ( \pmb { x } ; \sigma )$ is the score function [22], a vector field that points towards higher density of data at a given noise level. Intuitively, an infinitesimal forward step of this ODE nudges the sample away from the data, at a rate that depends on the change in noise level. Equivalently, a backward step nudges the sample towards the data distribution. + +Denoising score matching. The score function has the remarkable property that it does not depend on the generally intractable normalization constant of the underlying density function $p ( { \pmb x } ; { \boldsymbol \sigma } )$ [22], and thus can be much easier to evaluate. Specifically, if $D ( \pmb { x } ; \sigma )$ is a denoiser function that minimizes the expected $L _ { 2 }$ denoising error for samples drawn from $p _ { \mathrm { d a t a } }$ separately for every $\sigma$ , i.e., + +$$ +\begin{array} { r } { \mathbb { E } _ { { y } \sim p _ { \mathrm { d a l } } } \mathbb { E } _ { { n } \sim \mathcal { N } ( \mathbf { 0 } , \sigma ^ { 2 } \mathbf { I } ) } \| D ( { y } + { n } ; \sigma ) - y \| _ { 2 } ^ { 2 } , \mathrm { ~ t h e n ~ } \nabla _ { x } \log p ( { x } ; \sigma ) = \big ( D ( x ; \sigma ) - x \big ) / \sigma ^ { 2 } , } \end{array} +$$ + +where $\textbf { { y } }$ is a training image and $\textbf { \em n }$ is noise. In this light, the score function isolates the noise component from the signal in $_ { \textbf { \em x } }$ , and Eq. 1 amplifies (or diminishes) it over time. Figure 1 illustrates the behavior of ideal $D$ in practice. The key observation in diffusion models is that $D ( \pmb { x } ; \sigma )$ can be implemented as a neural network $D _ { \theta } ( \pmb { x } ; \sigma )$ trained according to Eq. 2. Note that $D _ { \theta }$ may include additional pre- and post-processing steps, such as scaling $_ { \textbf { \em x } }$ to an appropriate dynamic range; we will return to such preconditioning in Section 5. + +Time-dependent signal scaling. Some methods (see Appendix C.1) introduce an additional scale schedule $s ( t )$ and consider ${ \pmb x } = s ( t ) \hat { \pmb x }$ to be a scaled version of the original, non-scaled variable $\hat { \pmb x }$ . This changes the time-dependent probability density, and consequently also the ODE solution trajectories. The resulting ODE is a generalization of Eq. 1: + +$$ +\mathrm { d } \mathbf { \boldsymbol { x } } = \left[ \frac { \dot { s } ( t ) } { s ( t ) } \ \mathbf { \boldsymbol { x } } - s ( t ) ^ { 2 } \ \dot { \sigma } ( t ) \ \sigma ( t ) \ \nabla _ { \mathbf { \boldsymbol { x } } } \log p \left( \frac { \mathbf { \boldsymbol { x } } } { s ( t ) } ; \sigma ( t ) \right) \right] \ \mathrm { d } t . +$$ + +Note that we explicitly undo the scaling of $_ { \textbf { \em x } }$ when evaluating the score function to keep the definition of $p ( { \pmb x } ; { \boldsymbol \sigma } )$ independent of $s ( t )$ . + +Solution by discretization. The ODE to be solved is obtained by substituting Eq. 3 into Eq. 4 to define the point-wise gradient, and the solution can be found by numerical integration, i.e., taking finite steps over discrete time intervals. This requires choosing both the integration scheme (e.g., Euler or a variant of Runge–Kutta), as well as the discrete sampling times $\{ t _ { 0 } , t _ { 1 } , \ldots , t _ { N } \}$ . Many prior works rely on Euler’s method, but we show in Section 3 that a $2 ^ { \mathrm { n d } }$ order solver offers a better computational tradeoff. For brevity, we do not provide a separate pseudocode for Euler’s method applied to our ODE here, but it can be extracted from Algorithm 1 by omitting lines 6–8. + +![](images/f4d770791a43cc95cc8a7b5b6a3605bfacf51afa1f5eb2e679fe355189eba6bb.jpg) +Figure 2: Comparison of deterministic sampling methods using three pre-trained models. For each curve, the dot indicates the lowest NFE whose FID is within $3 \%$ of the lowest observed FID. + +Putting it together. Table 1 presents formulas for reproducing deterministic variants of three earlier methods in our framework. These methods were chosen because they are widely used and achieve state-of-the-art performance, but also because they were derived from different theoretical foundations. Some of our formulas appear quite different from the original papers as indirection and recursion have been removed; see Appendix C for details. The main purpose of this reframing is to bring into light all the independent components that often appear tangled together in previous work. In our framework, there are no implicit dependencies between the components — any choices (within reason) for the individual formulas will, in principle, lead to a functioning model. In other words, changing one component does not necessitate changes elsewhere in order to, e.g., maintain the property that the model converges to the data in the limit. In practice, some choices and combinations will of course work better than others. + +# 3 Improvements to deterministic sampling + +Improving the output quality and/or decreasing the computational cost of sampling are common topics in diffusion model research (e.g., [10, 24, 30, 31, 32, 36, 43, 50, 52, 53, 56]). Our hypothesis is that the choices related to the sampling process are largely independent of the other components, such as network architecture and training details. In other words, the training procedure of $D _ { \theta }$ should not dictate $\sigma ( t ) , s ( t )$ , and $\{ t _ { i } \}$ , nor vice versa; from the viewpoint of the sampler, $D _ { \theta }$ is simply a black box [52, 53]. We test this by evaluating different samplers on three pre-trained models, each representing a different theoretical framework and model family. We first measure baseline results for these models using their original sampler implementations, and then bring these samplers into our unified framework using the formulas in Table 1, followed by our improvements. This allows us to evaluate different practical choices and propose general improvements to the sampling process that are applicable to all models. + +We evaluate the $\mathrm { \cdot D D P M { + } } +$ cont. (VP)” and $\mathrm { \Delta ^ { 6 } N C S N { + } }$ cont. (VE)” models by Song et al. [48] trained on unconditional CIFAR-10 [28] at $3 2 \times 3 2$ , corresponding to the variance preserving (VP) and variance exploding (VE) formulations [48], originally inspired by DDPM [16] and SMLD [47]. We also evaluate the “ADM (dropout)” model by Dhariwal and Nichol [9] trained on class-conditional ImageNet [8] at $6 4 \times 6 4$ , corresponding to the improved DDPM (iDDPM) formulation [36]. This model was trained using a discrete set of $M = 1 0 0 0$ noise levels. Further details are given in Appendix C. + +We evaluate the result quality in terms of Fréchet inception distance (FID) [15] computed between 50,000 generated images and all available real images. Figure 2 shows FID as a function of neural function evaluations (NFE), i.e., how many times $D _ { \theta }$ is evaluated to produce a single image. Given that the sampling process is dominated entirely by the cost of $D _ { \theta }$ , improvements in NFE translate directly to sampling speed. The original deterministic samplers are shown in blue, and the reimplementations of these methods in our unified framework (orange) yield similar but consistently better results. The differences are explained by certain oversights in the original implementations as well as our more careful treatment of discrete noise levels in the case of DDIM; see Appendix C. Note that our reimplementations are fully specified by Algorithm 1 and Table 1, even though the original codebases are structured very differently from each other. + +
1: procedure HEUNSAMPLER(Dθ(x;σ),σ(t),s(t), ti∈{0.,...N})
2: sample xo ~ N(0,σ²(to) s²(to) 1) 3:Generate initial sample at to
fori∈{0,...,N-1}do Solve Eq.4 over N time steps
(ti) s(ti) di← xi- (ti)Ci ;(ti)) Evaluate dx/dt at ti
4:D0 s(ti) (ti) s(ti)
5: 6:xi+1←xi+(ti+1-ti)di Take Euler step from ti to ti+1 ifσ(ti+1)≠O then Apply 2nd order correction unless goes to zero
7:(ti+1)s((t+1)D d← ((ti+1) s(ti+1) xi+1
8:xi+1 ;(ti+1) ((ti+1) s(ti+1)) g(ti+1) (s(ti+1) xi+1←xi+(ti+1-ti)(di+¹di) Explicit trapezoidal rule at t+1
+ +Discretization and higher-order integrators. Solving an ODE numerically is necessarily an approximation of following the true solution trajectory. At each step, the solver introduces truncation error that accumulates over the course of $N$ steps. The local error generally scales superlinearly with respect to step size, and thus increasing $N$ improves the accuracy of the solution. + +The commonly used Euler’s method is a first order ODE solver with $\mathcal { O } ( h ^ { 2 } )$ local error with respect to step size $h$ . Higher-order Runge–Kutta methods [49] scale more favorably but require multiple evaluations of $D _ { \theta }$ per step. Linear multistep methods have also been recently proposed for sampling diffusion models [30, 56]. Through extensive tests, we have found Heun’s $2 ^ { \mathrm { n d } }$ order method [2] (a.k.a. improved Euler, trapezoidal rule) — previously explored in the context of diffusion models by Jolicoeur-Martineau et al. [24] — to provide an excellent tradeoff between truncation error and NFE. As illustrated in Algorithm 1, it introduces an additional correction step for $\boldsymbol { x } _ { i + 1 }$ to account for change in $\mathrm { d } \pmb { x } / \mathrm { d } t$ between $t _ { i }$ and $t _ { i + 1 }$ . This correction leads to $\mathcal { O } ( h ^ { 3 } )$ local error at the cost of one additional evaluation of $D _ { \theta }$ per step. Note that stepping to $\sigma = 0$ would result in a division by zero, so we revert to Euler’s method in this case. We discuss the general family of $2 ^ { \mathrm { n d } }$ order solvers in Appendix D.2. + +The time steps $\{ t _ { i } \}$ determine how the step sizes and thus truncation errors are distributed between different noise levels. We provide a detailed analysis in Appendix D.1, concluding that the step size should decrease monotonically with decreasing $\sigma$ and it does not need to vary on a per-sample basis. We adopt a parameterized scheme where the time steps are defined according to a sequence of noise levels $\{ \sigma _ { i } \}$ , i.e., $t _ { i } = \sigma ^ { - 1 } ( \sigma _ { i } )$ . We set $\sigma _ { i < N } = ( A i + B ) ^ { \rho }$ and select the constants $A$ and $B$ so that $\sigma _ { 0 } = \sigma _ { \operatorname* { m a x } }$ and $\sigma _ { N - 1 } = \sigma _ { \mathrm { m i n } }$ , which gives + +$$ +\begin{array} { r } { \sigma _ { i < N } = \left( \sigma _ { \operatorname* { m a x } } { } ^ { \frac { 1 } { \rho } } + \frac { i } { N - 1 } \big ( \sigma _ { \operatorname* { m i n } } { } ^ { \frac { 1 } { \rho } } - \sigma _ { \operatorname* { m a x } } { } ^ { \frac { 1 } { \rho } } \big ) \right) ^ { \rho } \mathrm { a n d } \sigma _ { N } = 0 . } \end{array} +$$ + +Here $\rho$ controls how much the steps near $\sigma _ { \mathrm { m i n } }$ are shortened at the expense of longer steps near $\sigma _ { \mathrm { m a x } }$ Our analysis in Appendix D.1 shows that setting $\rho = 3$ nearly equalizes the truncation error at each step, but that $\rho$ in range of 5 to 10 performs much better for sampling images. This suggests that errors near $\sigma _ { \mathrm { m i n } }$ have a large impact. We set $\rho = 7$ for the remainder of this paper. + +Results for Heun’s method and Eq. 5 are shown as the green curves in Figure 2. We observe consistent improvement in all cases: Heun’s method reaches the same FID as Euler’s method with considerably lower NFE. + +Trajectory curvature and noise schedule. The shape of the ODE solution trajectories is defined by functions $\sigma ( t )$ and $s ( t )$ . The choice of these functions offers a way to reduce the truncation errors discussed above, as their magnitude can be expected to scale proportional to the curvature of $\mathrm { d } \pmb { x } / \mathrm { d } t$ . We argue that the best choice for these functions is $\sigma ( t ) = t$ and $s ( t ) = 1$ , which is also the choice made in DDIM [46]. With this choice, the ODE of Eq. 4 simplifies to $\mathrm { d } \pmb { x } / \mathrm { d } t = \big ( \pmb { x } - D ( \pmb { x } ; t ) \big ) / t$ and $\sigma$ and $t$ become interchangeable. + +An immediate consequence is that at any $_ { \textbf { \em x } }$ and $t$ , a single Euler step to $t = 0$ yields the denoised image $D _ { \theta } ( \pmb { x } ; t )$ . The tangent of the solution trajectory therefore always points towards the denoiser output. This can be expected to change only slowly with the noise level, which corresponds to largely linear solution trajectories. The 1D ODE sketch of Figure 3c supports this intuition; the solution trajectories approach linear at both large and small noise levels, and have substantial curvature in only a small region in between. The same effect can be seen with real data in Figure 1b, where the change between different denoiser targets occurs in a relatively narrow $\sigma$ range. With the advocated schedule, this corresponds to high ODE curvature being limited to this same range. + +![](images/0627ae2ad62a9c47b9791ffc6b61152f97a61efcc07426c88c28319722a16c98.jpg) +Figure 3: A sketch of ODE curvature in 1D where $p _ { \mathrm { d a t a } }$ is two Dirac peaks at ${ \pmb x } = \pm 1$ . Horizontal $t$ axis is chosen to show $\sigma \in [ 0 , 2 5 ]$ in each plot, with insets showing $\sigma \in [ 0 , 1 ]$ near the data. Example local gradients are shown with black arrows. (a) Variance preserving ODE of Song et al. [48] has solution trajectories that flatten out to horizontal lines at large $\sigma$ . Local gradients start pointing towards data only at small $\sigma$ . (b) Variance exploding variant has extreme curvature near data and the solution trajectories are curved everywhere. (c) With the schedule used by DDIM [46] and us, as $\sigma$ increases the solution trajectories approach straight lines that point towards the mean of data. As $\sigma \to 0$ , the trajectories become linear and point towards the data manifold. + +The effect of setting $\sigma ( t ) = t$ and $s ( t ) = 1$ is shown as the red curves in Figure 2. As DDIM already employs these same choices, the red curve is identical to the green one for ImageNet-64. However, VP and VE benefit considerably from switching away from their original schedules. + +Discussion. The choices that we made in this section to improve deterministic sampling are summarized in the Sampling part of Table 1. Together, they reduce the NFE needed to reach highquality results by a large factor: $7 . 3 \times$ for VP, $3 0 0 \times$ for VE, and $3 . 2 \times$ for DDIM, corresponding to the highlighted NFE values in Figure 2. In practice, we can generate 26.3 high-quality CIFAR-10 images per second on a single NVIDIA V100. The consistency of improvements corroborates our hypothesis that the sampling process is orthogonal to how each model was originally trained. As further validation, we show results for the adaptive RK45 method [11] using our schedule as the dashed black curves in Figure 2; the cost of this sophisticated ODE solver outweighs its benefits. + +# 4 Stochastic sampling + +Deterministic sampling offers many benefits, e.g., the ability to turn real images into their corresponding latent representations by inverting the ODE. However, it tends to lead to worse output quality [46, 48] than stochastic sampling that injects fresh noise into the image in each step. Given that ODEs and SDEs recover the same distributions in theory, what exactly is the role of stochasticity? + +Background. The SDEs of Song et al. [48] can be generalized [20, 55] as a sum of the probability flow ODE of Eq. 1 and a time-varying Langevin diffusion SDE [14] (see Appendix B.5): + +$$ +\begin{array} { r } { \mathrm { d } \pmb { x } _ { \pm } = - \dot { \sigma } ( t ) \sigma ( t ) \nabla _ { \pmb { x } } \log p \big ( \pmb { x } ; \sigma ( t ) \big ) \mathrm { d } t \pm \beta ( t ) \sigma ( t ) ^ { 2 } \nabla _ { \pmb { x } } \log p \big ( \pmb { x } ; \sigma ( t ) \big ) \mathrm { d } t + \sqrt { 2 \beta ( t ) } \sigma ( t ) \mathrm { d } \omega _ { t , 0 } , } \end{array} +$$ + +where $\omega _ { t }$ is the standard Wiener process. $\mathrm { d } \pmb { x } _ { + }$ and $\mathrm { d } \mathbf { x _ { - } }$ are now separate SDEs for moving forward and backward in time, related by the time reversal formula of Anderson [1]. The Langevin term can further be seen as a combination of a deterministic score-based denoising term and a stochastic noise injection term, whose net noise level contributions cancel out. As such, $\beta ( t )$ effectively expresses the relative rate at which existing noise is replaced with new noise. The SDEs of Song et al. [48] are recovered with the choice $\beta ( \bar { t } ) = \dot { \sigma } ( t ) / \sigma \bar { ( } t )$ , whereby the score vanishes from the forward SDE. + +This perspective reveals why stochasticity is helpful in practice: The implicit Langevin diffusion drives the sample towards the desired marginal distribution at a given time, actively correcting for any errors made in earlier sampling steps. On the other hand, approximating the Langevin term with discrete SDE solver steps introduces error in itself. Previous results [3, 24, 46, 48] suggest that non-zero $\beta ( t )$ is helpful, but as far as we can tell, the implicit choice for $\beta ( t )$ in Song et al. [48] enjoys no special properties. Hence, the optimal amount of stochasticity should be determined empirically. + +Algorithm 2 Our stochastic sampler with $\sigma ( t ) = t$ and $s ( t ) = 1$ + +
1: procedure STOCHASTICSAMPLER(Dθ(x;σ), ti∈{0,..,N}, Yiε{0..,N-1}), Snoise)
2: sample xo ~ N(O, t² I) 3: fori∈{0,...,N-1} d{min(Sm,-1)ift∈Sin]
4:Yi = 0 otherwise
sample ∈i ~ N(O, S²oise I) 5:>Select temporarily increased noise level ti
t←t+Yiti xi←xi+√t-teiAdd new noise to move from ti to ti
6:
7: di←(xi-Dθ(xi;ti))/tiEvaluate dx/dt at ti
8: xi+1←xi+(ti+1-ti)diTake Euler step from ti to ti+1
9: if ti+1≠Othen 10:
d'←(xi+1-Dθ(xi+1;ti+1))/ti+1 11: xi+1←xi+(ti+1-ti)(di+di)> Apply 2nd order correction
+ +Our stochastic sampler. We propose a stochastic sampler that combines our $2 ^ { \mathrm { n d } }$ order deterministic ODE integrator with explicit Langevin-like “churn” of adding and removing noise. A pseudocode is given in Algorithm 2. At each step $i$ , given the sample $\mathbf { \Delta } _ { \mathbf { \mathcal { X } } _ { i } }$ at noise level $t _ { i }$ $\mathbf { \eta } ( = \sigma ( t _ { i } ) )$ , we perform two sub-steps. First, we add noise to the sample according to a factor $\gamma _ { i } \geq 0$ to reach a higher noise level $\hat { t } _ { i } = t _ { i } \dot { + } \gamma _ { i } t _ { i }$ . Second, from the increased-noise sample $\hat { \mathbf { x } } _ { i }$ , we solve the ODE backward from $\hat { t } _ { i }$ to $t _ { i + 1 }$ with a single step. This yields a sample $\pmb { x } _ { i + 1 }$ with noise level $t _ { i + 1 }$ , and the iteration continues. We stress that this is not a general-purpose SDE solver, but a sampling procedure tailored for the specific problem. Its correctness stems from the alternation of two sub-steps that each maintain the correct distribution (up to truncation error in the ODE step). The predictor-corrector sampler of Song et al. [48] has a conceptually similar structure to ours. + +To analyze the main difference between our method and Euler–Maruyama, we first note a subtle discrepancy in the latter when discretizing Eq. 6. One can interpret Euler–Maruyama as first adding noise and then performing an ODE step, not from the intermediate state after noise injection, but assuming that $_ { \textbf { \em x } }$ and $\sigma$ remained at the initial state at the beginning of the iteration step. In our method, the parameters used to evaluate $D _ { \theta }$ on line 7 of Algorithm 2 correspond to the state after noise injection, whereas an Euler–Maruyama -like method would use ${ \pmb x } _ { i } ; t _ { i }$ instead of $\hat { \pmb { x } } _ { i } ; \hat { t } _ { i }$ . In the limit of $\Delta _ { t }$ approaching zero there may be no difference between these choices, but the distinction appears to become significant when pursuing low NFE with large steps. + +Practical considerations. Increasing the amount of stochasticity is effective in correcting errors made by earlier sampling steps, but it has its own drawbacks. We have observed (see Appendix E.1) that excessive Langevin-like addition and removal of noise results in gradual loss of detail in the generated images with all datasets and denoiser networks. There is also a drift toward oversaturated colors at very low and high noise levels. We suspect that practical denoisers induce a slightly nonconservative vector field in Eq. 3, violating the premises of Langevin diffusion and causing these detrimental effects. Notably, our experiments with analytical denoisers (such as the one in Figure 1b) have not shown such degradation. + +If the degradation is caused by flaws in $D _ { \theta } ( \pmb { x } ; \sigma )$ , they can only be remedied using heuristic means during sampling. We address the drift toward oversaturated colors by only enabling stochasticity within a specific range of noise levels $t _ { i } \in [ S _ { \operatorname { t m i n } } , S _ { \operatorname { t m a x } } ]$ . For these noise levels, we define $\gamma _ { i } =$ $S _ { \mathrm { c h u r n } } / N$ , where $S _ { \mathrm { c h u r n } }$ controls the overall amount of stochasticity. We further clamp $\gamma _ { i }$ to never introduce more new noise than what is already present in the image. Finally, we have found that the loss of detail can be partially counteracted by setting $S _ { \mathrm { n o i s e } }$ slightly above 1 to inflate the standard deviation for the newly added noise. This suggests that a major component of the hypothesized non-conservativity of $D _ { \theta } ( { \pmb x } ; { \boldsymbol \sigma } )$ is a tendency to remove slightly too much noise — most likely due to regression toward the mean that can be expected to happen with any $L _ { 2 }$ -trained denoiser [29]. + +Evaluation. Figure 4 shows that our stochastic sampler outperforms previous samplers [24, 36, 48] by a significant margin, especially at low step counts. Jolicoeur-Martineau et al. [24] use a standard higher-order adaptive SDE solver [40] and its performance is a good baseline for such solvers in general. Our sampler has been tailored to the use case by, e.g., performing noise injection and ODE step sequentially, and it is not adaptive. It is an open question if adaptive solvers can be a net win over a well-tuned fixed schedule in sampling diffusion models. + +![](images/1bebb4b1fa86e8d0681976974b16f5801472c9a8620c2dbd93f92f9096112639.jpg) +Figure 4: Evaluation of our stochastic sampler (Algorithm 2). The purple curve corresponds to optimal choices for $\{ S _ { \mathrm { c h u r n } } , S _ { \mathrm { t m i n } } , S _ { \mathrm { t m a x } } , S _ { \mathrm { n o i s e } } \}$ ; orange, blue, and green correspond to disabling the effects of $S _ { \mathrm { t m i n , t m a x } }$ and/or $S _ { \mathrm { n o i s e } }$ . The red curves show reference results for our deterministic sampler (Algorithm 1), equivalent to setting $S _ { \mathrm { c h u r n } } = 0$ . The dashed black curves correspond to the original stochastic samplers from previous work: Euler–Maruyama [48] for VP, predictor-corrector [48] for VE, and iDDPM [36] for ImageNet-64. The dots indicate lowest observed FID. + +Through sampler improvements alone, we are able to bring the ImageNet-64 model that originally achieved FID 2.07 [9] to 1.55 that is very close to the state-of-the-art; previously, FID 1.48 has been reported for cascaded diffusion [17], 1.55 for classifier-free guidance [18], and 1.52 for StyleGANXL [44]. While our results showcase the potential gains achievable through sampler improvements, they also highlight the main shortcoming of stochasticity: For best results, one must make several heuristic choices — either implicit or explicit — that depend on the specific model. Indeed, we had to find the optimal values of $\left\{ S _ { \mathrm { c h u r n } } , S _ { \mathrm { t m i n } } , S _ { \mathrm { t m a x } } , S _ { \mathrm { n o i s e } } \right\}$ on a case-by-case basis using grid search (Appendix E.2). This raises a general concern that using stochastic sampling as the primary means of evaluating model improvements may inadvertently end up influencing the design choices related to model architecture and training. + +# 5 Preconditioning and training + +There are various known good practices for training neural networks in a supervised fashion. For example, it is advisable to keep input and output signal magnitudes fixed to, e.g., unit variance, and to avoid large variation in gradient magnitudes on a per-sample basis [5, 21]. Training a neural network to model $D$ directly would be far from ideal — for example, as the input ${ \pmb x } = { \pmb y } + { \pmb n }$ is a combination of clean signal $\textbf { { y } }$ and noise $\pmb { n } \sim \mathcal { N } ( \mathbf { 0 } , \sigma ^ { 2 } \mathbf { I } )$ , its magnitude varies immensely depending on noise level $\sigma$ . For this reason, the common practice is to not represent $D _ { \theta }$ as a neural network directly, but instead train a different network $F _ { \theta }$ from which $D _ { \theta }$ is derived. + +Previous methods [36, 46, 48] address the input scaling via a $\sigma$ -dependent normalization factor and attempt to precondition the output by training $F _ { \theta }$ to predict $\mathbf { \nabla } _ { \mathbf { \pmb { n } } }$ scaled to unit variance, from which the signal is then reconstructed via $D _ { \theta } ( { \pmb x } ; \sigma ) = { \pmb x } - \sigma F _ { \theta } ( \cdot )$ . This has the drawback that at large $\sigma$ , the network needs to fine-tune its output carefully to cancel out the existing noise $\textbf { \em n }$ exactly and give the output at the correct scale; note that any errors made by the network are amplified by a factor of $\sigma$ . In this situation, it would seem much easier to predict the expected output $D ( \pmb { x } ; \sigma )$ directly. In the same spirit as previous parameterizations that adaptively mix signal and noise (e.g., [10, 43, 50]), we propose to precondition the neural network with a $\sigma$ -dependent skip connection that allows it to estimate either $\textbf { { y } }$ or $\textbf { \em n }$ , or something in between. We thus write $D _ { \theta }$ in the following form: + +$$ +D _ { \theta } ( { \pmb x } ; \sigma ) = c _ { \mathrm { s k i p } } ( \sigma ) { \pmb x } + c _ { \mathrm { o u t } } ( \sigma ) F _ { \theta } \left( c _ { \mathrm { i n } } ( \sigma ) { \pmb x } ; c _ { \mathrm { n o i s e } } ( \sigma ) \right) , +$$ + +where $F _ { \theta }$ is the neural network to be trained, $c _ { \mathrm { s k i p } } ( \sigma )$ modulates the skip connection, $c _ { \mathrm { i n } } ( \sigma )$ and $ { c _ { \mathrm { o u t } } } ( \sigma )$ scale the input and output magnitudes, and $\dot { c } _ { \mathrm { n o i s e } } ( \sigma )$ maps noise level $\sigma$ into a conditioning input for $F _ { \theta }$ . Taking a weighted expectation of Eq. 2 over the noise levels gives the overall training loss $\mathbb { E } _ { \sigma , \pmb { y } , \pmb { n } } [ \lambda ( \sigma ) | | D ( \pmb { y } + \pmb { n } ; \sigma ) - \pmb { y } | | _ { 2 } ^ { 2 } ]$ , where $\sigma \sim p _ { \mathrm { t r a i n } }$ , $y \sim p _ { \mathrm { d a t a } }$ , and $\bar { \pmb { n } } \sim \mathcal { N } ( \pmb { 0 } , \sigma ^ { 2 } \mathbf { I } )$ . The probability of sampling a given noise level $\sigma$ is given by $p _ { \mathrm { t r a i n } } ( \sigma )$ and the corresponding weight is given by $\lambda ( \sigma )$ . We can equivalently express this loss with respect to the raw network output $F _ { \theta }$ in Eq. 7: + +Table 2: Evaluation of our training improvements. The starting point (config A) is VP & VE using our deterministic sampler. At the end (configs E,F), VP & VE only differ in the architecture of $F _ { \theta }$ . + +
CIFAR-10[28] at 32×32FFHQ[26]64×64 UnconditionalAFHQv2[7] 64×64 Unconditional
ConditionalUnconditional
Training configurationVPVEVPVEVPVEVPVE
A Baseline [48](*pre-trained)2.483.113.01*3.77*3.3925.952.5818.52
B + Adjust hyperparameters2.182.482.512.943.1322.532.4323.12
C + Redistribute capacity2.082.522.312.832.7841.622.5415.04
D + Our preconditioning2.092.642.293.102.943.392.793.81
E + Our loss function1.881.862.051.992.602.812.292.28
F + Non-leaky augmentation1.791.791.971.982.392.531.962.16
NFE35 3535 3579797979
+ +$$ +\begin{array} { r } { \mathbb { E } _ { \sigma , y , n } \Big [ \underbrace { \lambda ( \sigma ) c _ { \mathrm { o u t } } ( \sigma ) ^ { 2 } } _ { \mathrm { e f f e c t i v e ~ w e i g h t } } \Big \| \underbrace { F _ { \theta } \big ( c _ { \mathrm { i n } } ( \sigma ) \cdot ( y + n ) ; c _ { \mathrm { n o i s e } } ( \sigma ) \big ) } _ { \mathrm { n e t w o t k ~ o u t p u t } } - \underbrace { \frac { 1 } { c _ { \mathrm { o u t } } ( \sigma ) } \big ( y - c _ { \mathrm { s k i n } } ( \sigma ) \cdot ( y + n ) \big ) } _ { \mathrm { e f f e c t i v e ~ t r a i n i n g ~ t a r g e t } } \Big \| _ { 2 } ^ { 2 } \Big ] . } \end{array} +$$ + +This form reveals the effective training target of $F _ { \theta }$ , allowing us to determine suitable choices for the preconditioning functions from first principles. As detailed in Appendix B.6, we derive our choices shown in Table 1 by requiring network inputs and training targets to have unit variance $( \boldsymbol { c } _ { \mathrm { i n } } , \boldsymbol { c } _ { \mathrm { o u t } } )$ , and amplifying errors in $F _ { \theta }$ as little as possible $( c _ { \mathrm { s k i p } } )$ . The formula for $\mathrm { \mathcal { C } _ { n o i s e } }$ is chosen empirically. + +Table 2 shows FID for a series of training setups, evaluated using our deterministic sampler from Section 3. We start with the baseline training setup of Song et al. [48], which differs considerably between the VP and VE cases; we provide separate results for each (config A). To obtain a more meaningful point of comparison, we re-adjust the basic hyperparameters (config B) and improve the expressive power of the model (config C) by removing the lowest-resolution layers and doubling the capacity of the highest-resolution layers instead; see Appendix F.3 for further details. We then replace the original choices of $\{ c _ { \mathrm { i n } } , c _ { \mathrm { o u t } } , c _ { \mathrm { n o i s e } } , c _ { \mathrm { s k i p } } \}$ with our preconditioning (config D), which keeps the results largely unchanged — except for VE that improves considerably at $6 4 \times 6 4$ resolution. Instead of improving FID per se, the main benefit of our preconditioning is that it makes the training more robust, enabling us to turn our focus on redesigning the loss function without adverse effects. + +Loss weighting and sampling. Eq. 8 shows that training $F _ { \theta }$ as preconditioned in Eq. 7 incurs an effective per-sample loss weight of $\lambda ( \sigma ) c _ { \mathrm { o u t } } ( \sigma ) ^ { 2 }$ . To balance the effective loss weights, we set $\lambda ( \sigma ) = 1 / c _ { \mathrm { o u t } } ( \sigma ) ^ { 2 }$ , which also equalizes the initial training loss over the entire $\sigma$ range as shown in Figure 5a (green curve). Finally, we need to select $p _ { \mathrm { t r a i n } } ( \sigma )$ , i.e., how to choose noise levels during training. Inspecting the per- $\sigma$ loss after training (blue and orange curves) reveals that a significant reduction is possible only at intermediate noise levels; at very low levels, it is both difficult and irrelevant to discern the vanishingly small noise component, whereas at high levels the training targets are always dissimilar from the correct answer that approaches dataset average. Therefore, we target the training efforts to the relevant range using a simple log-normal distribution for $p _ { \mathrm { t r a i n } } ( \sigma )$ as detailed in Table 1 and illustrated in Figure 5a (red curve). + +Table 2 shows that our proposed $p _ { \mathrm { t r a i n } }$ and $\lambda$ (config E) lead to a dramatic improvement in FID in all cases when used in conjunction with our preconditioning (config D). In concurrent work, Choi et al. [6] propose a similar scheme to prioritize noise levels that are most relevant w.r.t. forming the perceptually recognizable content of the image. However, they only consider the choice of $\lambda$ in isolation, which results in a smaller overall improvement. + +Augmentation regularization. To prevent potential overfitting that often plagues diffusion models with smaller datasets, we borrow an augmentation pipeline from the GAN literature [25]. The pipeline consists of various geometric transformations (see Appendix F.2) that we apply to a training image prior to adding noise. To prevent the augmentations from leaking to the generated images, we provide the augmentation parameters as a conditioning input to $F _ { \theta }$ ; during inference we set the them to zero to guarantee that only non-augmented images are generated. Table 2 shows that data augmentation provides a consistent improvement (config F) that yields new state-of-the-art FIDs of 1.79 and 1.97 for conditional and unconditional CIFAR-10, beating the previous records of 1.85 [44] and 2.10 [50]. + +![](images/067281713bc43a0d03df53b1029a4a8d41e0830559276079b392c19962f6402c.jpg) +Figure 5: (a) Observed initial (green) and final loss per noise level, representative of the the $3 2 \times 3 2$ (blue) and $6 4 \times 6 4$ (orange) models considered in this paper. The shaded regions represent the standard deviation over 10k random samples. Our proposed training sample density is shown by the dashed red curve. (b) Effect of $S _ { \mathrm { c h u r n } }$ on unconditional CIFAR-10 with 256 steps $( \mathrm { N F E } = 5 1 1$ ). For the original training setup of Song et al. [48], stochastic sampling is highly beneficial (blue, green), while deterministic sampling $S _ { \mathrm { c h u r n } } = 0 $ ) leads to relatively poor FID. For our training setup, the situation is reversed (orange, red); stochastic sampling is not only unnecessary but harmful. (c) Effect of $S _ { \mathrm { c h u r n } }$ on class-conditional ImageNet-64 with 256 steps $( \mathrm { N F E } = 5 1 1$ ). In this more challenging scenario, stochastic sampling turns out to be useful again. Our training setup improves the results for both deterministic and stochastic sampling. + +Stochastic sampling revisited. Interestingly, the relevance of stochastic sampling appears to diminish as the model itself improves, as shown in Figure 5b,c. When using our training setup in CIFAR-10 (Figure 5b), the best results were obtained with deterministic sampling, and any amount of stochastic sampling was detrimental. + +ImageNet-64. As a final experiment, we trained a class-conditional ImageNet-64 model from scratch using our proposed training improvements. This model achieved a new state-of-the-art FID of 1.36 compared to the previous record of 1.48 [17]. We used the ADM architecture [9] with no changes, and trained it using our config E with minimal tuning; see Appendix F.3 for details. We did not find overfitting to be a concern, and thus chose to not employ augmentation regularization. As shown in Figure 5c, the optimal amount of stochastic sampling was much lower than with the pre-trained model, but unlike with CIFAR-10, stochastic sampling was clearly better than deterministic sampling. This suggests that more diverse datasets continue to benefit from stochastic sampling. + +# 6 Conclusions + +Our approach of putting diffusion models to a common framework exposes a modular design. This allows a targeted investigation of individual components, potentially helping to better cover the viable design space. In our tests this let us simply replace the samplers in various earlier models, drastically improving the results. For example, in ImageNet-64 our sampler turned an average model (FID 2.07) to a challenger (1.55) for the previous SOTA model (1.48) [17], and with training improvements achieved SOTA FID of 1.36. We also obtained new state-of-the-art results on CIFAR-10 while using only 35 model evaluations, deterministic sampling, and a small network. The current high-resolution diffusion models rely either on separate super-resolution steps [17, 35, 39], subspace projection [23], very large networks [9, 48], or hybrid approaches [38, 41, 50] — we believe that our contributions are orthogonal to these extensions. That said, many of our parameter values may need to be re-adjusted for higher resolution datasets. Furthermore, we feel that the precise interaction between stochastic sampling and the training objective remains an interesting question for future work. + +Societal impact. Our advances in sample quality can potentially amplify negative societal effects when used in a large-scale system like DALL·E 2, including types of disinformation or emphasizing sterotypes and harmful biases [33]. The training and sampling of diffusion models needs a lot of electricity; our project consumed ∼250MWh on an in-house cluster of NVIDIA V100s. + +Acknowledgments. We thank Jaakko Lehtinen, Ming-Yu Liu, Tuomas Kynkäänniemi, Axel Sauer, Arash Vahdat, and Janne Hellsten for discussions and comments, and Tero Kuosmanen, Samuel Klenberg, and Janne Hellsten for maintaining our compute infrastructure. + +# References + +12(3):313–326, 1982. +[2] U. M. Ascher and L. R. Petzold. Computer Methods for Ordinary Differential Equations and DifferentialAlgebraic Equations. Society for Industrial and Applied Mathematics, 1998. +[3] F. Bao, C. Li, J. Zhu, and B. Zhang. Analytic-DPM: an analytic estimate of the optimal reverse variance in diffusion probabilistic models. In Proc. ICLR, 2022. +[4] D. Baranchuk, A. Voynov, I. Rubachev, V. Khrulkov, and A. Babenko. Label-efficient semantic segmentation with diffusion models. In Proc. ICLR, 2022. +[5] C. M. Bishop. Neural networks for pattern recognition. Oxford University Press, USA, 1995. +[6] J. Choi, J. Lee, C. Shin, S. Kim, H. Kim, and S. Yoon. Perception prioritized training of diffusion models. In Proc. CVPR, 2022. +[7] Y. Choi, Y. Uh, J. Yoo, and J.-W. Ha. StarGAN v2: Diverse image synthesis for multiple domains. In Proc. CVPR, 2020. +[8] J. Deng, W. Dong, R. Socher, L.-J. Li, K. Li, and L. Fei-Fei. ImageNet: A large-scale hierarchical image database. In Proc. CVPR, 2009. +[9] P. Dhariwal and A. Q. Nichol. Diffusion models beat GANs on image synthesis. In Proc. NeurIPS, 2021. +[10] T. Dockhorn, A. Vahdat, and K. Kreis. Score-based generative modeling with critically-damped Langevin diffusion. In Proc. ICLR, 2022. +[11] J. R. Dormand and P. J. Prince. A family of embedded Runge-Kutta formulae. Journal of computational and applied mathematics, 6(1):19–26, 1980. +[12] J. B. J. Fourier, G. Darboux, et al. Théorie analytique de la chaleur, volume 504. Didot Paris, 1822. +[13] I. Goodfellow, J. Pouget-Abadie, M. Mirza, B. Xu, D. Warde-Farley, S. Ozair, A. Courville, and Y. Bengio. Generative adversarial networks. In Proc. NIPS, 2014. +[14] U. Grenander and M. I. Miller. Representations of knowledge in complex systems. Journal of the Royal Statistical Society: Series B (Methodological), 56(4):549–581, 1994. +[15] 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 Proc. NIPS, 2017. +[16] J. Ho, A. Jain, and P. Abbeel. Denoising diffusion probabilistic models. In Proc. NeurIPS, 2020. +[17] J. Ho, C. Saharia, W. Chan, D. J. Fleet, M. Norouzi, and T. Salimans. Cascaded diffusion models for high fidelity image generation. Journal of Machine Learning Research, 23, 2022. +[18] J. Ho and T. Salimans. Classifier-free diffusion guidance. In NeurIPS 2021 Workshop on Deep Generative Models and Downstream Applications, 2021. +[19] J. Ho, T. Salimans, A. A. Gritsenko, W. Chan, M. Norouzi, and D. J. Fleet. Video diffusion models. In Proc. ICLR Workshop on Deep Generative Models for Highly Structured Data, 2022. +[20] C.-W. Huang, J. H. Lim, and A. C. Courville. A variational perspective on diffusion-based generative models and score matching. In Proc. NeurIPS, 2021. +[21] L. Huang, J. Qin, Y. Zhou, F. Zhu, L. Liu, and L. Shao. Normalization techniques in training DNNs: Methodology, analysis and application. CoRR, abs/2009.12836, 2020. +[22] A. Hyvärinen. Estimation of non-normalized statistical models by score matching. Journal of Machine Learning Research, 6(24):695–709, 2005. +[23] B. Jing, G. Corso, R. Berlinghieri, and T. Jaakkola. Subspace diffusion generative models. In Proc. ECCV, 2022. +[24] A. Jolicoeur-Martineau, K. Li, R. Piché-Taillefer, T. Kachman, and I. Mitliagkas. Gotta go fast when generating data with score-based models. CoRR, abs/2105.14080, 2021. +[25] T. Karras, M. Aittala, J. Hellsten, S. Laine, J. Lehtinen, and T. Aila. Training generative adversarial networks with limited data. In Proc. NeurIPS, 2020. +[26] T. Karras, S. Laine, and T. Aila. A style-based generator architecture for generative adversarial networks. In Proc. CVPR, 2018. +[27] Z. Kong, W. Ping, J. Huang, K. Zhao, and B. Catanzaro. DiffWave: A versatile diffusion model for audio synthesis. In Proc. ICLR, 2021. +[28] A. Krizhevsky. Learning multiple layers of features from tiny images. Technical report, University of Toronto, 2009. +[29] J. Lehtinen, J. Munkberg, J. Hasselgren, S. Laine, T. Karras, M. Aittala, and T. Aila. Noise2Noise: Learning image restoration without clean data. In Proc. ICML, 2018. +[30] L. Liu, Y. Ren, Z. Lin, and Z. Zhao. Pseudo numerical methods for diffusion models on manifolds. In Proc. ICLR, 2022. +[31] C. Lu, Y. Zhou, F. Bao, J. Chen, C. Li, and J. Zhu. DPM-Solver: A fast ODE solver for diffusion probabilistic model sampling in around 10 steps. In Proc. NeurIPS, 2022. +[32] E. Luhman and T. Luhman. Knowledge distillation in iterative generative models for improved sampling speed. CoRR, abs/2101.02388, 2021. +[33] P. Mishkin, L. Ahmad, M. Brundage, G. Krueger, and G. Sastry. DALL·E 2 preview – risks and limitations. OpenAI, 2022. +[34] E. Nachmani and S. Dovrat. Zero-shot translation using diffusion models. CoRR, abs/2111.01471, 2021. +[35] A. Nichol, P. Dhariwal, A. Ramesh, P. Shyam, P. Mishkin, B. McGrew, I. Sutskever, and M. Chen. GLIDE: Towards photorealistic image generation and editing with text-guided diffusion models. In Proc. ICML, 2022. +[36] A. Q. Nichol and P. Dhariwal. Improved denoising diffusion probabilistic models. In Proc. ICML, volume 139, pages 8162–8171, 2021. +[37] V. Popov, I. Vovk, V. Gogoryan, T. Sadekova, and M. Kudinov. Grad-TTS: A diffusion probabilistic model for text-to-speech. In Proc. ICML, volume 139, pages 8599–8608, 2021. +[38] K. Preechakul, N. Chatthee, S. Wizadwongsa, and S. Suwajanakorn. Diffusion autoencoders: Toward a meaningful and decodable representation. In Proc. CVPR, 2022. +[39] A. Ramesh, P. Dhariwal, A. Nichol, C. Chu, and M. Chen. Hierarchical text-conditional image generation with CLIP latents. Technical report, OpenAI, 2022. +[40] A. J. Roberts. Modify the improved Euler scheme to integrate stochastic differential equations. CoRR, abs/1210.0933, 2012. +[41] R. Rombach, A. Blattmann, D. Lorenz, P. Esser, and B. Ommer. High-resolution image synthesis with latent diffusion models. In Proc. CVPR, 2022. +[42] C. Saharia, W. Chan, H. Chang, C. A. Lee, J. Ho, T. Salimans, D. J. Fleet, and M. Norouzi. Palette: Image-to-image diffusion models. In Proc. SIGGRAPH, 2022. +[43] T. Salimans and J. Ho. Progressive distillation for fast sampling of diffusion models. In Proc. ICLR, 2022. +[44] A. Sauer, K. Schwarz, and A. Geiger. StyleGAN-XL: Scaling StyleGAN to large diverse datasets. In Proc. SIGGRAPH, 2022. +[45] J. Sohl-Dickstein, E. Weiss, N. Maheswaranathan, and S. Ganguli. Deep unsupervised learning using nonequilibrium thermodynamics. In Proc. ICML, pages 2256–2265, 2015. +[46] J. Song, C. Meng, and S. Ermon. Denoising diffusion implicit models. In Proc. ICLR, 2021. +[47] Y. Song and S. Ermon. Generative modeling by estimating gradients of the data distribution. In Proc. NeurIPS, 2019. +[48] Y. Song, J. Sohl-Dickstein, D. P. Kingma, A. Kumar, S. Ermon, and B. Poole. Score-based generative modeling through stochastic differential equations. In Proc. ICLR, 2021. +[49] E. Süli and D. F. Mayers. An Introduction to Numerical Analysis. Cambridge University Press, 2003. +[50] A. Vahdat, K. Kreis, and J. Kautz. Score-based generative modeling in latent space. In Proc. NeurIPS, 2021. +[51] P. Vincent. A connection between score matching and denoising autoencoders. Neural Computation, 23(7):1661–1674, 2011. +[52] D. Watson, W. Chan, J. Ho, and M. Norouzi. Learning fast samplers for diffusion models by differentiating through sample quality. In Proc. ICLR, 2022. +[53] D. Watson, J. Ho, M. Norouzi, and W. Chan. Learning to efficiently sample from diffusion probabilistic models. CoRR, abs/2106.03802, 2021. +[54] J. Wolleb, R. Sandkühler, F. Bieder, P. Valmaggia, and P. C. Cattin. Diffusion models for implicit image segmentation ensembles. In Medical Imaging with Deep Learning, 2022. +[55] Q. Zhang and Y. Chen. Diffusion normalizing flow. In Proc. NeurIPS, 2021. +[56] Q. Zhang and Y. Chen. Fast sampling of diffusion models with exponential integrator. CoRR, abs/2204.13902, 2022. + +# Checklist + +1. For all authors... + +(a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes] +(b) Did you describe the limitations of your work? [Yes] Section 6. The main limitations of the analysis relate to the set of tested datasets and their limited resolution. +(c) Did you discuss any potential negative societal impacts of your work? [Yes] Section 6. +(d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes] + +2. If you are including theoretical results... + +(a) Did you state the full set of assumptions of all theoretical results? [No] We follow common application-specific assumptions about the probability distributions, functions and other components, but do not exhaustively specify them, or consider pathological corner cases. +(b) Did you include complete proofs of all theoretical results? [No] Our equations and algorithms build on previously known results, and highlight their practical aspects through mostly readily verifiable algebraic manipulations (Appendix B). We do not explicitly present all details of the derivations, and assume that the previous results are sufficiently rigorously proven in the respective literature. + +3. If you ran experiments... + +(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] Our implementation and pre-trained models are available at https://github.com/NVlabs/edm +(b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes] Appendix F. +(c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [Yes] Shaded regions in Figures 4 and 5. +(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] Section 6. + +4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets... + +(a) If your work uses existing assets, did you cite the creators? [Yes] +(b) Did you mention the license of the assets? [Yes] Appendix F.5. +(c) Did you include any new assets either in the supplemental material or as a URL? [No] +(d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [N/A] +(e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [N/A] + +5. If you used crowdsourcing or conducted research with human subjects... + +(a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A] +(b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A] +(c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A] \ No newline at end of file diff --git a/md/dev/kroqZZb-6s/kroqZZb-6s.md b/md/dev/kroqZZb-6s/kroqZZb-6s.md new file mode 100644 index 0000000000000000000000000000000000000000..710736f3bf5fabbe068da3c5575e69e940593966 --- /dev/null +++ b/md/dev/kroqZZb-6s/kroqZZb-6s.md @@ -0,0 +1,294 @@ +# CLUSTER-BASED FEATURE IMPORTANCE LEARNING FOR ELECTRONIC HEALTH RECORD TIME-SERIES + +Anonymous authors Paper under double-blind review + +# ABSTRACT + +The recent availability of Electronic Health Records (EHR) has allowed for the development of algorithms predicting inpatient risk of deterioration and trajectory evolution. However, prediction of disease progression with EHR is challenging since these data are sparse, heterogeneous, multi-dimensional, and multi-modal time-series. As such, clustering is used to identify similar groups within the patient cohort to improve prediction. Current models have shown some success in obtaining cluster representation of patient trajectories, however, they i) fail to obtain clinical interpretability for each cluster, and ii) struggle to learn meaningful cluster numbers in the context of the imbalanced distribution of disease outcomes. We propose a supervised deep learning model to cluster EHR data based on the identification of clinically understandable phenotypes with regard to both outcome prediction and patient trajectory. We introduce novel loss functions to address the problems of class imbalance and cluster collapse, and furthermore propose a feature-time attention mechanism to identify cluster-based phenotype importance across time and feature dimensions. We tested our model in over 100,000 unique trajectories from hospitalised patients with Type-II respiratory failure to predict four different outcomes. Our model yielded added interpretability to cluster formation and outperformed benchmarks by at least $5 \%$ in mean AUROC. + +# 1 INTRODUCTION + +Chronic conditions such as Chronic Obstructive Pulmonary Disease (COPD) and Cardiovascular Disease (CVD) describe a broad spectrum of medical ailments, and affect a significant percentage of the overall population (Adeloye et al., 2015). Such diseases are characterized by the existence of multiple distinct patient subgroups, largely distinguished by differences in pathology and in the response to different treatments and medical interventions Turner et al. (2015); Vogelmeier et al. (2018). Exacerbation of COPD, a condition of respiratory failure, can result in emergency hospital admission and mortality if it is not well treated and managed. Early identification of COPD patients’ subgroups is therefore of high medical importance and relevance. EHR time-series data are typically used to determine clinically relevant COPD inpatient subgroups, and have been applied to detect risk of deterioration (Pikoula et al., 2019). + +However, modelling disease progression and risk prediction is challenging due to the extreme data heterogeneity nature of EHRs. Firstly, EHR data contains a mixture of demographic or static variables (i.e. time independent such as age and sex), and multi-dimensional time-series (e.g Heart Rate, HR, and laboratory measurements, such as blood tests). Secondly, EHR time-series are multi-modal as different features are collected from different devices, representing distinct clinical properties of relevance. Similarly, time-series features are sampled at different times and have low and distinct sampling rates, as well as different missing value properties. Furthermore, each feature is associated with different noise and evolution patterns. + +Recent advances in deep learning (DL) approaches have shown promising results in EHR modelling due to their capacity to handle complex data (Rajkomar et al., 2018). Nonetheless, DL approaches lack relevant interpretability frameworks to be scaled and applied in hospital settings. Several such models have since been proposed to tackle this issue (Mayhew et al., 2018), however, most of them focus on a subset of EHR features (usually vital signs only) and fail to provide a clinically-focused phenotypic analysis of learnt patient sub-groups (via clustering). + +This work builds on previous research in literature to introduce a cluster-based feature-time attention mechanism to predict patient outcomes based on EHR data. Our method also leverages phenotypic information to aid in clinical interpretability, not only making use of demographics and vital-signs information but also of relevant laboratory measurements (all present in the EHR) to provide a more complete patient physiological status. Our contributions include the following: + +• An end-to-end DL supervised model to cluster EHR patient data based on the identification of clinically understandable cluster phenotypes with regard to both outcome prediction and patient trajectory in a multi-class setting; +• A weighted loss to address data imbalance for both tasks of clustering and prediction, a common issue in the medical domain; +• The incorporation of a novel loss mechanism in the model, to address the issue of cluster collapse and promote sample assignment to all available clusters; +• Finally, the inclusion of a novel interpretability framework, derived from a cluster-based feature-time attention layer, aiming to identify relevant timestamps and feature variables to represent the patient physiology, cluster assignment and, ultimately, outcome prediction. + +This paper is structured as follows. In Section 2, we describe previous research in EHR time-series modelling, clustering and attention methods. Section 3 introduces the dataset used for analysis and provides description of the proposed model. The experimental setup and results of our analysis are presented in Section 4 and discussion takes place in Section 5. Finally, concluding remarks and future work are available in Section 6. + +# 2 RELATED WORK + +EHR data comprise complex time-series data, being high-dimensional, multi-modal and heterogeneous, and thus presenting challenges when used in machine learning models (Keogh & Kasetty (2003); Rani & Sikka (2012)). An important goal in a medical setting is to identify phenotypically separable clusters with distinct phenotypic profiles (which we denote as phenotypic clustering hereafter). For the purpose of this work, cluster phenotypes result from the combination of two distinct components: a) the evolution profile of patient trajectories’ within the cluster, and b) the characterisation of the cluster with regards to clinical variables of interest. The latter may include features not used for clustering and may provide information about the underlying or future health status. Traditional clustering models such as K-Means or hierarchical clustering have been shown to fail to capture the existing time-dependent feature relationships. As such, variants have been proposed to mitigate this problem. A temporal version of the K-Means algorithm, Time-Series K-Means (TSKM, Tavenard et al. (2020)), models the distance between time-series of different datapoints, using the Euclidean distance (which is equivalent to considering all temporal observations as an independent feature value for the corresponding patient admission), or time-series alignment strategies such as Dynamic-Time Warping (DTW, Berndt & Clifford (1994)) and soft-DTW (Cuturi & Blondel (2017)). + +Recent DL architectures, ranging from Auto-Encoders (AE, Ma et al. (2019)), Convolutional Neural Networks (CNN, Munir et al. (2018)) and others, have shown great promise when applied to timeseries data across a variety of domains. Fortuin et al. (2019) proposed a Self-Organising Map - Variational Auto-Encoder (SOM-VAE), is a state-of-the-art, unsupervised, DL clustering algorithm which extends a variational auto-encoder architecture (Kingma & Welling, 2013) for observation learning and representation, through the addition of a Markov model (Gagniuc, 2017), to infer temporal evolution within the latent space. Clustering is performed in the low dimensional latent space through the use of self-organising maps (Kohonen, 1982) to obtain a discrete, topologically-interpretable latent representation of the learnt clusters. In a supervised setting, AC-TPC (Lee & Van Der Schaar, 2020) serves as the current state-of-the-art for identifying phenotypically separable clusters in patient trajectories in EHR data. AC-TPC maps EHR data into a latent space via an encoder, and uses an actor-critic network (Konda & Tsitsiklis, 2000) which leverages clinical outcomes to aid in cluster formation and obtaining cluster phenotypes. Neither SOM-VAE and AC-TPC provide clinically meaningful interpretation of feature-time importance or outcome of interest. + +Attention mechanisms have recently been proposed to provide greater interpretability to Recurrent Neural Networks (RNN) and to aid in dealing with long-term dependencies (Vaswani et al., 2017; Xu et al., 2015), and have also been used in modelling EHR time-series (Schwab et al., 2017; Shashikumar et al., 2018). RETAIN (Choi et al., 2016) proposes a two-level reverse attention mechanism to mimic physician’s decision process and predict a future diagnosis. In other recent works, attention mechanisms based on bi-directional RNN and CNN outperformed standard classification models in predicting high risk vascular diseases with the addition of medication information as input data (Kim et al., 2017). A drawback of such attention mechanisms is the focus on temporal interpretability only, and inability to look at individual features, which is key in a medical setting. To solve this issue, Shamout et al. (2019) considered independent RNN per feature, with a concatenation of the resulting latent vectors. However, the latter does not allow the joint modelling across both feature and time dimensions. Alternatively, Kaji et al. (2019); Gandin et al. (2021) proposed learning attention weights directly on the original inputs, prior to being transformed by a RNN, which does not allow modelling of the resulting latent representations. To the best of our knowledge, no existing models have been proposed that jointly leverage both feature and time dimensions (feature-time) to determine clinical observation relevance on clustered EHR data. + +# 3 METHODS + +# 3.1 DATASET AND PRE-PROCESSING + +Our dataset was retrieved from a retrospective database of routinely collected observations from concluded hospital admissions between March 2014 and March 2018 (the HAVEN project, REC reference: 16/SC/0264 and Confidential Advisory Group reference 08/02/1394). The database includes EHR measurements of adult patients admitted to four hospitals from the Oxford University Hospitals NHS Foundation Trust. Note that the HAVEN dataset does not include data from Intensive Care Units (ICU), and we have excluded observations taken in the Emergency Department. Key characteristics of HAVEN cohort data include a) heterogeneity, b) multi-modality, and difference in: c) noise distributions, d) sampling rates, e) missing values, etc. Such properties are common across EHR settings, and are challenging with respect to learning useful representations and predictions. + +We used the protocol defined in Pimentel et al. (2019) to subset the cohort to those patients at risk of developing Type-II Respiratory Failure (T2RF) in hospital (a diagram of the data selection steps can be found in Figure A.1 in the Appendix). Four patient outcomes were considered in our analysis: i) no event during hospital stay, leading to successful discharge from the hospital, or the first instance of one of three possible events, ii) unplanned entry to ICU, iii) cardiac arrest (also named ”Cardiac” hereafter) and iv) death. Outcome groups are not clearly separable (see Tables A.2, A.3 in the Appendix), so patient clusters will naturally contain a mix of different admission outcomes. In this setting, the clinically relevant component of a cluster phenotype (henceforth denoted as cluster outcome propensity or cluster outcome) is represented as a categorical distribution indicating the corresponding propensity for cluster-assigned patients to each corresponding outcome. + +For each admission, observations were grouped according to mean window observation value into 4 hour blocks based on the time to outcome (discharge in the case of no event during stay) - only observations within 24 and 72 hours before the outcome were considered. This time window was selected based on those traditionally used for validating Early Warning Score (EWS) systems (baseline models used by UK NHS staff to track inpatient physiology, (Royal College of Physicians, 2017) and clinical input, such that the target phenotype represents the patient status in the subsequent 24 hours. Features were transformed according to min-max normalization due to skewness and heterogeneity in their distributions. Patient admissions were randomly split into train, validation and test sets. Missing values were imputed based on the previously observed time block - all remaining missing observations were imputed according to the feature median from the aggregated validation and test data (see Section 4 for description of train-test data split). Imputed values were flagged in a three-dimensional mask matrix. + +After processing, input data contained over 100,000 unique patient trajectories corresponding to 4,266 unique patient admissions (only last patients admissions were considered in our analysis). Original trajectories for the patient cohort are shown in the Appendix in Figures A.4, A.5, A.6 for different variables/features. A lack of clear outcome group separability can be observed across temporal and static variables. Furthermore, we note the high degree of imbalance in the data - admissions with no event account for over $8 6 . 8 \%$ of the total number of admissions, while event classes correspond to $1 0 . 3 \%$ Death, $1 . 8 \%$ ICU and $1 . 1 \%$ Cardiac. + +# 3.2 PROPOSED MODEL + +We propose a novel model, which we denote by Cluster-bAsed iMportancE Learning fOr Timeseries (CAMELOT). Our proposed methodology is displayed in Figure $1 ^ { 1 }$ . Our model builds on previous literature on 3 key items: a) a modified loss function to target the multi-class imbalance, b) a novel loss function to ensure cluster assignment and phenotype are representative, and c) a novel feature-time attention-level framework to boost representation and introduce feature-time interpretability for cluster assignment. + +![](images/5738edb9246a09ec91147e913fda26d231ec701bd4e53ddb8fc11d9be6192f35.jpg) +Figure 1: Diagram of proposed model. MLP - Multilayer Perceptron neural network blocks; RNN - Recurrent Neural Network. + +Let $N$ denote the number of patients and $D _ { f }$ the number of input features. Input data consists of a set of patient trajectorobservations for patient s , $\mathbb { X } = \{ \{ \mathbf { x } _ { n , t } \} _ { t = 1 } ^ { T _ { n } } \} _ { n = 1 } ^ { N }$ , where tcomes $T _ { n }$ mum number of temporal. Input trajectory data for $n$ $\mathbb { Y } = \left\{ \mathbf { y } _ { n } \right\} _ { n = 1 } ^ { N }$ +the $n$ -th patient is represented as $\mathbf X _ { n } = [ \mathbf x _ { n , 1 } , . . . , \mathbf x _ { n , T _ { n } } ]$ , where each $\mathbf { x } _ { n , t } \in \mathbb { R } ^ { D _ { f } }$ is referred to as an observation (vector), with a maximum of observed $D _ { f }$ feature values. The corresponding patient outcome is a one-hot encoded vector $\mathbf { y } _ { n } \in \mathbb { R } ^ { 4 }$ (more generally, the dimension of ${ \bf y } _ { n }$ equals to the number of possible outcomes). + +Our DL model can be decomposed into 3 neural network blocks: an Encoder, Identifier and Predictor. We refer the action of each network respectively as E, I and $\mathrm { \bf P }$ (for example, $I ( \mathbf { x } )$ denotes the output of the Identifier given some input vector $\mathbf { x }$ ). Both the Identifier and Predictor are Multilayer Perceptrons (MLP), networks of stacked feed-forward dense layers. On the other hand, the Encoder block can be further sub-divided into a) a stack of RNN layers and b) our proposed custom attention layer (see Section 3.3 for further details). Separately, we also consider a set of trainable cluster representation vectors, $\mathcal { C } = \{ \mathbf { c } _ { 1 } , . . . , \mathbf { c } _ { K } \}$ . We assign the outcome for cluster $i$ as $P ( \pmb { c } _ { i } )$ . + +A model call is as follows: Given the $n$ -th patient input trajectory data $\mathbf { X } _ { n }$ , the Encoder network returns a latent representation $\mathbf { z } _ { n } : = E ( \mathbf { X } _ { n } ) \in \mathbb { R } ^ { l }$ . Consequently, the Identifier network computes cluster assignment probabprobability assignment of ies, to $\pi _ { n } : = I ( \mathbf { z } _ { n } ) \in \mathbb { R } ^ { K }$ . of h element of clusters. A c $\pi _ { n }$ , e $\boldsymbol { \pi } _ { n } ^ { i }$ resents theis selected $\mathbf { z } _ { n }$ $i$ $K$ $k _ { \mathrm { s a m p } } ^ { n }$ according to categorical sampling $( k _ { \mathrm { s a m p } } ^ { n } \sim \mathbf { C a t } ( \pi _ { n } ) )$ , and the corresponding cluster representation, $\mathbf { c } _ { \mathrm { s a m p } } ^ { \mathbf { n } } : = \mathbf { c } _ { \mathbf { k } _ { \mathrm { s a m p } } ^ { \mathbf { n } } }$ is then selected from $\mathcal { C }$ . The output of the model is $y _ { \mathrm { p r e d } } : = P ( \mathbf { c } _ { \mathrm { s a m p } } ^ { n } ) \in \mathbb { R } ^ { 4 }$ . We note that $k _ { \mathrm { s a m p } } ^ { n }$ is only sampled during a training phase; at prediction stage, cluster selection follows the equation $k _ { \mathrm { p r e d } } ^ { n } = \underset { i = 1 , . . . , K } { \arg \operatorname* { m a x } } \pi _ { n } ^ { i }$ . + +# 3.3 ENCODER NETWORK AND A CUSTOM ATTENTION LAYER + +The diagram of our proposed Encoder network is presented in Figure 2. The Encoder contains (i) a Recurrent Neural Network (RNN) block of stacked Long Short-Term Memory (LSTM) layers, and (ii) a customised attention layer, which computes a latent representation by comparing input data with the sequence of output states from the RNN block. We use the same notation as above, and write the sequence of output states of the final LSTM layer as $\mathbf { o } _ { n , 1 } , . . . , \mathbf { o } _ { n , T _ { n } }$ , with ${ \bf o } _ { n , i } \in \mathbb { R } ^ { l }$ . Theoretically, each ${ \bf o } _ { n , t }$ corresponds to a representative summary of input patient information up until time $t$ . We propose to approximate ${ \bf o } _ { n , t }$ as a linear combination of latent representations of each individual feature, thereby allowing the separation of output states into contributions from each feature. Note that it is important feature transformations be time-independent, to avoid overparametrising the model, over-fitting and ensure feature representation maps are similar across time. + +![](images/10d1f2dae6d4c161e7b4ed89343af6140dc1df3e400dc01609dabc40230f10c6.jpg) +Figure 2: Diagram of the Encoder network composed of an LSTM Encoder and a custom attention layer. + +Our attention layer behaves as a set of $D _ { f }$ feed-forward neural network layers, $\mathbf { U } _ { 1 } , . . . , \mathbf { U } _ { D _ { f } }$ , jointly represented by: (i) a matrix of learnable kernel weights $D \in \mathbb { R } _ { l \times D _ { f } }$ . We write $D = [ \mathbf { D } _ { 1 } , . . . , \mathbf { D } _ { D _ { f } } ]$ ; (ii) a matrix of learnable bias vectors $\boldsymbol { B } \in \mathbb { R } _ { l \times D _ { f } }$ . Similarly, we can write $B = [ \mathbf { B } _ { 1 } , . . . , \mathbf { B } _ { D _ { f } } ]$ ; and (iii) an activation function, $\sigma$ which matches the output activation of the RNN block. + +Input data for patient $n$ , $\mathbf { X } _ { n }$ is fed as input to the RNN block, which outputs a sequence of latent output states $( { \bf { \bar { o } } } _ { n , t } ) _ { t = 1 } ^ { T _ { n } }$ . For $t = 1 , . . . , T _ { n }$ , we compute $D _ { f }$ feature representations in latent space as: + +$$ +R _ { n , t } : = \sigma ( D \odot \mathbf { x } _ { n , t } + B ) +$$ + +where ${ \cal R } _ { n , t } = [ { \bf R } _ { n , t } ^ { 1 } , . . . , { \bf R } _ { n , t } ^ { D _ { f } } ]$ is our collection of feature representations, $\sigma$ is applied element-wise and $\mathbf { A } : = { \cal D } \odot \mathbf { x } _ { n , t }$ is a matrix satisfying $A _ { i , j } = D _ { i , j } ( \mathbf { x } _ { n , t } ) _ { j }$ . Equivalently, $\mathbf { R } _ { n , t } ^ { i }$ is the output of a dense layer, $\mathbf { U } _ { i }$ with kernel $\mathbf { D } _ { i }$ , bias $\mathbf { B } _ { i }$ , activation $\sigma$ and input $( \mathbf { x _ { n , t } } ) _ { i }$ . We approximate $\mathbf { o } _ { n , t } \approx$ $\begin{array} { r } { \sum _ { i = 1 } ^ { D _ { f } } \alpha _ { t } ^ { i } { \bf R } _ { n , t } ^ { i } \ = \ R _ { n , t } \alpha _ { t } } \end{array}$ . This approximation is minimised following a least squares criterion, which has a well-known solution, $\widehat { \alpha } _ { t }$ , and corresponding optimal approximation $\widehat { \mathbf { o } } _ { n , t }$ . + +Given, $\hat { \mathbf { o } } _ { n , t }$ , a similar procedure is used to compute a context vector as $\begin{array} { r } { \mathbf { z } : = \sum _ { t } \beta _ { t } \hat { \mathbf { o } } _ { n , t } } \end{array}$ , where weights $\beta$ are learned to provide a more representative context vector. + +# 3.4 ATTENTION MAP VISUALISATION + +Given cluster representation vectors, $\mathbf { c } _ { k }$ , we can compute a cluster-wise feature-time attention visualisation map as follows. First, we normalise feature-weights $\widehat { \mathbf { a } } _ { t }$ according to a softmax function, $\mathbf { s } _ { t } = \sigma ( \widehat { \pmb { \alpha } } _ { t } ) \in \mathbb { R } ^ { D _ { f } }$ , where $\sigma$ is the softmax function: $\begin{array} { r } { \sigma ( \mathbf { x } ) = \frac { \exp { | \mathbf { x } | } } { \| \exp { | \mathbf { x } | } \| _ { 1 } } } \end{array}$ . Secondly, we compute tsolved as before. We similarly normalise cluster-wise weights, $\gamma _ { t } ^ { k }$ according to a least-square approximation of $\gamma _ { n , t } ^ { k }$ tto obtain cluster temporal scores, $\begin{array} { r } { \dot { \mathbf { c } } _ { k } \approx \sum _ { t = 1 } ^ { T _ { n } } \widehat { \mathbf { o } } _ { n , t } \gamma _ { n , t } ^ { k } } \end{array}$ $e _ { n , t } ^ { k } = \sigma ( \gamma _ { n , t } ^ { k } )$ , and . Finally, we can compute $K$ scoring matrices, $M _ { n } ^ { 1 } , . . . , M _ { n } ^ { K } \in \mathbb { R } _ { T _ { n } \times D _ { f } }$ : M kn  t,f $\left( M _ { n } ^ { k } \right) _ { t , f } = e _ { n , t } ^ { k } \pmb { s } _ { t } ^ { f }$ . Note that: $\begin{array} { r } { \| M _ { n } ^ { k } \| _ { 1 } = \sum _ { t } e _ { n , t } ^ { k } \sum _ { f } s _ { t } ^ { f } = \sum _ { t } e _ { n , t } ^ { k } = 1 } \end{array}$ . Given that Matrices $M _ { n } ^ { k }$ are normalised, they may be consequently, visualised as a normalised feature-time map for cluster assignment relevance and provide further model interpretability. + +The model is optimised through consideration of three distinct loss functions. We introduce a weighted cross-entropy loss function: + +$$ +L _ { \mathrm { p r e d } } ( y _ { \mathrm { t r u e } } , y _ { \mathrm { p r e d } } ) = - \sum _ { c = 1 } ^ { C } w _ { c } y _ { \mathrm { t r u e } } ^ { c } \log \left( y _ { \mathrm { p r e d } } ^ { c } \right) = - w _ { c ^ { \prime } } \log ( y _ { \mathrm { p r e d } } ) _ { c ^ { \prime } } +$$ + +where $c ^ { \prime }$ is the true outcome for a particular patient. We propose inversely proportional normalised weights: $\textstyle \sum _ { c = 1 } ^ { C } w _ { c } = 1$ and $w _ { c }$ is inversely proportional to the class distribution, i.e., $\begin{array} { r } { w _ { c } \propto \frac { N } { N _ { c } } } \end{array}$ with $N$ being the number of patients and $N _ { c }$ being the number of patients with outcome label $c$ . Class weighting penalises misclassification more heavily on less sampled classes. + +We also propose a novel distribution loss function, $\operatorname { L } _ { \mathrm { d i s t } } ( \pi )$ . We define the average cluster probability of assignment as $\begin{array} { r } { \pi _ { C } : = \frac { 1 } { N } \sum _ { n } \pi _ { n } } \end{array}$ . Then we introduce ${ \cal L } _ { \mathrm { d i s t } } ( \pmb { \pi } ) = - { \cal H } ( \pmb { \pi } _ { C } )$ , where $H$ denotes entropy. Note that $L _ { \mathrm { d i s t } }$ is minimised when $\pi _ { C }$ is uniform, ensuring all clusters are ’explored’ and have comparable number of samples. While clusters should not necessarily be assigned the same number of samples, this loss helps to overcome a concern of cluster collapse, where clusters do not separate and samples are assigned to a very small number of non-representative clusters. Finally, to separate cluster representation vectors, we define the cluster separation loss as $\begin{array} { r } { L _ { \mathrm { c l u s } } ( \mathcal { C } ) = \dot { - } \frac { 1 } { K ( K - 1 ) } \sum _ { i , j } \| \mathbf { c } _ { i } - \mathbf { c } _ { j } \| ^ { 2 } } \end{array}$ + +To optimise our model, iterative gradients are applied according to weighted combinations of the above loss functions with hyper-parameter weights $\alpha , \beta$ : + +1. Outcome Predictor is updated according to $L _ { \mathrm { p r e d } }$ ; +2. Encoder and Identifier are trained according to $L _ { \mathrm { p r e d } } + \alpha L _ { \mathrm { d i s t } }$ ; +3. Cluster representation vectors are updated with regards to $L _ { \mathrm { p r e d } } + \beta L _ { \mathrm { c l u s } }$ . + +# 3.6 INITIALISATION + +Our proposed model also follows a set of initialisation pre-training procedures. Firstly, the Encoder and Outcome Predictor are pre-trained according to a classification task $( \tilde { \mathbf { y } } = P ( E ( \bar { \mathbf { x } } ) ) )$ , with corresponding loss $L _ { \mathrm { p r e d } }$ . Latent state representations $E ( \mathbf { x } )$ are clustered through a K-means algorithm with $K$ clusters across the whole training set. Cluster representation vectors are initialised as given by the resulting cluster centroids, and finally the Cluster Identifier network is pre-trained to identify clusters as predicted by the K-Means algorithm with categorical cross-entropy loss. Implementation was completed in Python, with TensorFlow 2, scikit-learn and NumPy. All experiments were run with 1 Tesla v100 GPU, and 8 CPUs Intel(R) Xeon(R) Gold 6246 $@$ 3.30GHz. + +# 4 RESULTS + +For Benchmark purposes, we considered TSKM as a classic clustering benchmark, and SOM-VAE and AC-TPC as state-of-the-art phenotypic clustering methods. AC-TPC considers temporal subsequences of a complete patient set of observations - for comparison purposes, we consider only the model output for the complete patient sequence. For simplicity, we present results with all input features considered. + +All models were trained on the same training set ( $60 \%$ of the complete input data) and evaluated against the same test set (remaining $40 \%$ ). For DL models, we further split the training set into a purely training and validation sets. All experiments with varying hyper-parameters were repeated 10 times with a fixed set of 10 distinct seeds, and results are reported according to average metric and standard deviation. A complete list of the hyper-parameters considered for each model is included in Table A7 in the Appendix. In bold, top-performing hyper-parameters are indicated. Optimal integer hyper-parameters $( K , l )$ were selected according to an “Occam’s Razor” approach - for each parameter, we assign it the highest value such that increasing this amount does not lead to a significant increase in performance according to mean AUROC and a Friedman’s hypothesis test. Neural network size parameters were kept consistent across all DL models where applicable. All other optimal hyper-parameters were selected according to highest AUROC performance conditional on the model predicting each class (e.g. not making predictions solely for no event or Death Events). + +We evaluated clustering performance through standard clustering metrics, including Silhouette score (SIL, Rousseeuw (1987)), Davies-Bouldin Index (DBI, Davies (1979)), Variance Ratio Criterion (VRI, Calinski & Harabasz (1974)). Results for all clustering models are displayed in Table 3. ´ In Table 4, we evaluated the (multi-class) prediction performance with regards to Area-under-theReceiver-Operating-Curve (AUROC), unweighted mean F1-score, unweighted mean Recall, and Normalised Mutual Information (NMI). For purely unsupervised models (SOM-VAE and TSKM), an outcome predictive pipeline was constructed by assigning patient admissions to clusters, and consequently to the empirical outcome distribution in the corresponding cluster. The prediction task was also benchmarked against traditional classifiers for outcome prediction in EHR data, namely Support Vector Machines (SVM), XGBoost (XGB) and NEWS2 (i.e., the National Early Warning Score used in the UK hospitals). Furthermore, to evaluate other Neural Network models as benchmarks and also justify both proposed mechanisms, we furthermore considered two other benchmarks: a) ENC-PRED: a stacked LSTM Encoder, followed by a MLP network for outcome prediction, and b) ATTEP; a model equivalent to CAMELOT, except the original entropy loss is considered over the clustering dist loss. Supervised performance for all the above models is included in Table4. As noted, convergence was particularly difficult for ATTEP due to cluster collapse. + +Table 3: Clustering separability results by the different clustering methodologies given input data with all available features (static, vital-signs, serum and haematological variables). For each metric and model, the average score and standard deviation are returned. The best values for each metric are indicated in bold. + +
Metric1 TSKMSOM-VAEAC-TPCCAMELOT(proposed)
SIL0.35(±0.01)0.25(±0.08)0.04(±0.01)0.11(±0.04)
DBI1.19 (±0.08)1.89(±0.63)4.34(±0.80)3.12(±0.53)
VRI554.6(±2.50)12.8(± 9.32)66.5(± 18.7)216.7(±6.2)
+ +Table 4: Outcome prediction scores across all models, displayed with an average and standard deviation of a set of 10 seeds (except NEWS2, which is deterministic). The best values for each metric are indicated in bold. For clustering algorithms, cluster outcome distributions were taken to be the empirically observed distribution in each cluster. + +
MetricAUROCF1-scoreRecallNMI
SVM0.50(±0.02)0.23 (±0.00)0.25(±0.00)0.01(±0.02)
XGB0.65(±0.01)0.23(±0.00)0.22(±0.00)0.03(±0.04)
NEWS20.610.290.340.01
TSKM0.55(±0.01)0.24(±0.03)0.26(±0.02)0.01(±0.03)
SOM-VAE0.61(±0.09)0.27(±0.05)0.27(±0.03)0.05(±0.03)
AC-TPC0.68(±0.01)0.38(±0.01)0.36(±0.01)0.17(±0.02)
ENC-PRED0.57(±0.02)0.25(±0.02)0.26(±0.02)0.06(±0.03)
ATTEP0.67(±0.02)0.36(±0.02)0.36(±0.02)0.16(± 0.03)
CAMELOT(proposed)0.73(±0.02)0.36(±0.01)0.38(±0.02)0.20(±0.03)
+ +On top of performance evaluation with regards to clustering separability and outcome prediction, we display a comparison between the learnt cluster phenotypes of the proposed model and that of phenotypic clustering benchmark AC-TPC. For each cluster, the corresponding outcome propensity $P ( \mathbf { c } )$ is shown as a bar plot over the 4 possible outcomes with corresponding probability value. We also display cluster outcome propensity plots for both TSKM and SOM-VAE in the Appendix (Figures A.8 and A.9). We note that the cluster outcome propensity distributions learnt by CAMELOT also align with the empirical outcome relevance in the learnt clusters (Table A.12). Lastly, we also display feature-time cluster relevance attention maps in Figure 6. For each cluster, a patient was randomly selected from the set of patients in the corresponding cluster, and a corresponding featuretime attention matrix and visualised as a heatmap. + +# 5 DISCUSSION + +Our proposed model shows an improvement in clustering performance ( see Table 3) when compared to the current phenotypic clustering benchmark (AC-TPC), and outperforms SOM-VAE according to VRI. Although the cluster separability metrics are superior in the case of TSKM, this is expected given a metric bias towards convex clusters, and the convexity of the K-Means based algorithm. In particular, DL clustering occurs in a latent space, which, unfortunately, is not easily comparable with an algorithm targetting the input space (such as K-Means). Furthermore, we argue clusters learnt by TSKM are less relevant that our model’s as a) TSKM clusters are extremely hard to distinguish with regards to outcome propensity (as evidenced by very low performance on a prediction task (Table 4)), and b) TSKM clusters are less separable with regards to trajectory evolution, as there is less separation of mean HR trajectories, and less cluster separation when data is projected to a two-dimensional domain with t-stochastic neighbour embedding (tSNE) - both figures are in the Appendix, Figures A10 and A11. + +![](images/fbc878ea7f8978b76b270f1c8ad192ef506787ef45aae1a8c31f4e7cbfb1dbb5.jpg) +Figure 5: Comparison of bar plots of cluster outcome propensity distributions for the proposed model and benchmark AC-TPC. On the left (blue), distributions are displayed for each cluster (out of a total of 6), and each phenotype corresponds to the probability of an outcome. Similar results are shown on the right (yellow) for AC-TPC. The title of each sub-plot indicates the cluster considered, as well as the number of patients assigned to a given cluster. + +![](images/f965e66d1d50bc859ff0affce0c21413c73abd79fde8c4c21f623ef58512f29d.jpg) +Figure 6: Feature-Time Cluster Relevance Map. Each Heatmap represents a feature-time relevance matrix for a random patient assigned to a given cluster. Vertical Axis indicates time to outcome, in hours, while horizontal axis indicates different input features. + +With regards to predictive power, it can be seen in Table 4 that our model outperforms both standard classifiers (at least $8 \%$ ) and benchmarking clustering methods (at least $5 \%$ ) according to mean AUROC. A similar increase can be seen in other classification metrics, with the exception of F1-score, where model performance is slightly below to that of AC-TPC. Our model is able to more accurately determine patterns in the data than the previously proposed models, as EHR data is extremely complex and heterogeneous. It is particularly promising that the model obtains good predictive task results despite a clustering bottleneck (i.e. sample predicted outcomes are done through the assigned cluster, as opposed to tailored to the precise input data). While it is possible that other models could show better performance on the direct task of outcome prediction given EHR input, such models can potentially be associated with lack of robustness or input sensitivity difficulties. Furthermore, it is likely they would struggle with identifying relevant trends and properties of clinical interest. As such, for new admissions, such models could provide a prediction for the overall outcome, but no robust understanding of how this outcome will occur, and how to prevent potential risks of deterioration, let alone the ability to pool data from other similar patients. + +Figure 5 shows the advantage of two key aspects of our methodology. Our model identifies clear, separable cluster outcome distribution and provides a useful layer of interpretability to clinicians to understand a potential risk of deterioration. Our model also identifies a more diverse set of cluster outcomes than AC-TPC, which only picks up 3 different cluster outcome distributions, and doesn’t identify the presence of the ”ICU” and ”Cardiac” classes. We also show other cluster-phenotype benchmark results in Appendix A.8 and A.9. With regards to clusters learnt by CAMELOT, clusters 0 and 3 are the clusters with most ill cohort - they are largely representative of death and cardiac events on the subsequent 24 hours. On the other hand, while cluster 2, 5 are healthier, with a smaller chance of adverse events. Clusters 1 and 4 are largely “healthy” cluster, with reduced risks of the most intense adverse events. We note cluster outcome propensity distributions learnt by AC-TPC are unable to provide this level of detailed information. Furthermore, the propensity distribution learnt by our model matches with the empirical number outcome events observed in each cluster (displayed in Appendix Table A12). Note, furthermore, that the model managed to successfully navigate a heavy class-imbalance setting. Representative clusters are able to capture different-sized sub-populations, yet still identify potential risks of deterioration. + +On the other hand, learnt cluster attention maps introduced in Figure 6 introduce yet another layer of interpretability to our proposed clustering model. The personalised attention maps highlight the relevant feature-time pairs driving patient cluster assignment, and can be used to identify the most important clinical variables. For instance, analysing Figure 5 suggests clusters with highest propensity for either of Death or Cardiac Arrest events are Cluster 0, 3 (and 2 to a slightly smaller extent). This reflects in the resulting attention maps, where SBP and FIO2 are highlighted as key clinical variables for cluster assignment. This conclusion is further corroborated when considering descriptive statistics of CAMELOT clusters (Table A13), as SBP and FIO2 are some of the few variables with some significant separation across clusters, and when considering trajectory evolutions (Figure A14). Lastly, note that feature-time weights are also relevant if potential deterioration events did not take place - so that we are more confident on a patient’s health status. As an example, attention maps for clusters 1 and 4 (reasonably healthy clusters) indicate $\mathrm { F I O _ { 2 } }$ as very relevant towards the latter stages of the admission - this is likely due to these patients not showing an increase in oxygen intake (as they did not need it). Thus, attention maps can be very versatile. + +# 6 CONCLUSION AND FUTURE WORK + +In this work, we propose a novel deep learning model for the task of identification of phenotypically separable clusters applied to EHR data for. As part of our proposed model, we propose 2 distinct loss functions and introduce a novel feature-time attention layer to better represent patient data and to introduce a feature-time relevance map for each cluster. Our experiments show promising results with the addition of both methodological tools above, on both cluster separability and outcome prediction performance. The addition of the feature-time layer has the added benefit of introducing key interpretability tools for researchers to understand relevant regions for good patient physiology representation as well as an indication of what can lead to patient deterioration. + +There are multiple interesting avenues of investigation building on this work. On the other hand, the current attention layer mechanisms could potentially be improved with the addition of temporal weight smoothness, or, alternatively, weight regularization to encourage exploration of the complete feature-time space. Alternatively, cluster selection through a neural network mechanism introduces high capacity at the potential cost of robustness and cluster collapse. Potentially, more traditional methods incorporated into a similarly complex pipeline can achieve better performing through a clearer identification of cluster regions in latent space. Furthermore, methodological improvements will also benefit from a more extensive testing across other diverse datasets and other potential areas of application. + +# REFERENCES + +Davies Adeloye, Stephen Chua, Chinwei Lee, Catriona Basquill, Angeliki Papana, Evropi Theodoratou, Harish Nair, Danijela Gasevic, Devi Sridhar, Harry Campbell, et al. Global and regional estimates of copd prevalence: Systematic review and meta–analysis. Journal of global health, 5 (2), 2015. + +Donald J Berndt and James Clifford. Using dynamic time warping to find patterns in time series. In KDD workshop, volume 10, pp. 359–370. Seattle, WA, USA:, 1994. + +Tadeusz Calinski and Jerzy Harabasz. A dendrite method for cluster analysis. ´ Communications in Statistics-theory and Methods, 3(1):1–27, 1974. + +Edward Choi, Mohammad Taha Bahadori, Joshua A Kulas, Andy Schuetz, Walter F Stewart, and Jimeng Sun. Retain: An interpretable predictive model for healthcare using reverse time attention mechanism. arXiv preprint arXiv:1608.05745, 2016. + +Marco Cuturi and Mathieu Blondel. Soft-dtw: a differentiable loss function for time-series. In International Conference on Machine Learning, pp. 894–903. PMLR, 2017. + +DL Davies. et dw bouldin. a cluster separation measure. IEEE Trans. Pattern Anal. Mach. Intell, 1 (2), 1979. + +Vincent Fortuin, Matthias Huser, Francesco Locatello, Heiko Strathmann, and Gunnar R ¨ atsch. Deep ¨ self-organization: Interpretable discrete representation learning on time series. In International Conference on Learning Representations, 2019. URL https://openreview.net/forum? id=rygjcsR9Y7. + +Paul A Gagniuc. Markov chains: from theory to implementation and experimentation. John Wiley & Sons, 2017. + +Ilaria Gandin, Arjuna Scagnetto, Simona Romani, and Giulia Barbati. Interpretability of timeseries deep learning models: A study in cardiovascular patients admitted to intensive care unit. Journal of Biomedical Informatics, 121:103876, 2021. ISSN 1532-0464. doi: https://doi. org/10.1016/j.jbi.2021.103876. URL https://www.sciencedirect.com/science/ article/pii/S1532046421002057. + +Deepak A Kaji, John R Zech, Jun S Kim, Samuel K Cho, Neha S Dangayach, Anthony B Costa, and Eric K Oermann. An attention based deep learning model of clinical events in the intensive care unit. PloS one, 14(2):e0211057, 2019. + +Eamonn Keogh and Shruti Kasetty. On the need for time series data mining benchmarks: a survey and empirical demonstration. Data Mining and knowledge discovery, 7(4):349–371, 2003. + +You Jin Kim, Yun-Geun Lee, Jeong Whun Kim, Jin Joo Park, Borim Ryu, and Jung-Woo Ha. Highrisk prediction from electronic medical records via deep attention networks. arXiv preprint arXiv:1712.00010, 2017. + +Diederik P Kingma and Max Welling. Auto-encoding variational bayes. arXiv preprint arXiv:1312.6114, 2013. + +Teuvo Kohonen. Self-organized formation of topologically correct feature maps. Biological cybernetics, 43(1):59–69, 1982. + +Vijay R Konda and John N Tsitsiklis. Actor-critic algorithms. In Advances in neural information processing systems, pp. 1008–1014, 2000. + +Changhee Lee and Mihaela Van Der Schaar. Temporal phenotyping using deep predictive clustering of disease progression. In Hal Daume III and Aarti Singh (eds.), ´ Proceedings of the 37th International Conference on Machine Learning, volume 119 of Proceedings of Machine Learning Research, pp. 5767–5777. PMLR, 13–18 Jul 2020. URL http://proceedings.mlr. press/v119/lee20h.html. + +Qianli Ma, Jiawei Zheng, Sen Li, and Gary W Cottrell. Learning representations for time series clustering. Advances in neural information processing systems, 32:3781–3791, 2019. + +Michael B Mayhew, Brenden K Petersen, Ana Paula Sales, John D Greene, Vincent X Liu, and Todd S Wasson. Flexible, cluster-based analysis of the electronic medical record of sepsis with composite mixture models. Journal of biomedical informatics, 78:33–42, 2018. + +Mohsin Munir, Shoaib Ahmed Siddiqui, Andreas Dengel, and Sheraz Ahmed. Deepant: A deep learning approach for unsupervised anomaly detection in time series. Ieee Access, 7:1991–2005, 2018. + +Maria Pikoula, Jennifer Kathleen Quint, Francis Nissen, Harry Hemingway, Liam Smeeth, and Spiros Denaxas. Identifying clinically important copd sub-types using data-driven approaches in primary care population based electronic health records. BMC medical informatics and decision making, 19(1):1–14, 2019. + +Marco AF Pimentel, Oliver C Redfern, Stephen Gerry, Gary S Collins, James Malycha, David Prytherch, Paul E Schmidt, Gary B Smith, and Peter J Watkinson. A comparison of the ability of the national early warning score and the national early warning score 2 to identify patients at risk of in-hospital mortality: a multi-centre database study. Resuscitation, 134:147–156, 2019. + +Alvin Rajkomar, Eyal Oren, Kai Chen, Andrew M Dai, Nissan Hajaj, Michaela Hardt, Peter J Liu, Xiaobing Liu, Jake Marcus, Mimi Sun, et al. Scalable and accurate deep learning with electronic health records. NPJ Digital Medicine, 1(1):1–10, 2018. + +Sangeeta Rani and Geeta Sikka. Recent techniques of clustering of time series data: a survey. International Journal of Computer Applications, 52(15), 2012. + +Peter J Rousseeuw. Silhouettes: a graphical aid to the interpretation and validation of cluster analysis. Journal of computational and applied mathematics, 20:53–65, 1987. + +Royal College of Physicians. National early warning score (news) 2. Standardising the assessment of acute-illness severity in the NHS, 2017. + +Patrick Schwab, Gaetano C Scebba, Jia Zhang, Marco Delai, and Walter Karlen. Beat by beat: Classifying cardiac arrhythmias with recurrent neural networks. In 2017 Computing in Cardiology (CinC), pp. 1–4. IEEE, 2017. + +Farah E Shamout, Tingting Zhu, Pulkit Sharma, Peter J Watkinson, and David A Clifton. Deep interpretable early warning system for the detection of clinical deterioration. IEEE journal of biomedical and health informatics, 24(2):437–446, 2019. + +Supreeth P Shashikumar, Amit J Shah, Gari D Clifford, and Shamim Nemati. Detection of paroxysmal atrial fibrillation using attention-based bidirectional recurrent neural networks. In Proceedings of the 24th ACM SIGKDD International Conference on Knowledge Discovery & Data Mining, pp. 715–723, 2018. + +Romain Tavenard, Johann Faouzi, Gilles Vandewiele, Felix Divo, Guillaume Androz, Chester Holtz, Marie Payne, Roman Yurchak, Marc Rußwurm, Kushal Kolar, et al. Tslearn, a machine learning toolkit for time series data. J. Mach. Learn. Res., 21(118):1–6, 2020. + +Alice M Turner, Lilla Tamasi, Florence Schleich, Mehmet Hoxha, Ildiko Horvath, Renaud Louis, and Neil Barnes. Clinically relevant subgroups in copd and asthma. European respiratory review, 24(136):283–298, 2015. + +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. + +Claus F Vogelmeier, Kenneth R Chapman, Marc Miravitlles, Nicolas Roche, Jørgen Vestbo, Chau Thach, Donald Banerji, Robert Fogel, Francesco Patalano, Petter Olsson, et al. Exacerbation heterogeneity in copd: subgroup analyses from the flame study. International journal of chronic obstructive pulmonary disease, 13:1125, 2018. + +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. + +# A APPENDIX + +# A.1 DATA + +A description of the complete pipeline of data re-processing, following the protocol defined in Pimentel et al. (2019), is shown in Figure A.1. + +![](images/e4d91bfcdb064c7d529fad3995ff440c293e1ec8dcc0985d03521510a371044a.jpg) +A.1: HAVEN processing + +A total of 26 input features were considered. Firstly, 4-hourly vital-sign sets which included 8 features: Heart Rate (HR), Respiratory Rate (RR), Systolic Blood Pressure (SBP), Diastolic Blood Pressure (DBP), peripheral Oxygen Saturation $\mathrm { ( S p O _ { 2 } ) }$ ), Temperature (TEMP), level of consciousness via the AVPU scale - Alert, Verbal, Pain, Unresponsive - and estimated Fraction of Inspired Oxygen $\mathrm { ( F i O _ { 2 } }$ , available when an oxygen mask is applied to the patient). Each set consisted of a timestamp and the vital-sign numerical values. Secondly, 4 demographic variables were selected (modelled as static variables): age, sex, and admission type (elective or surgical). Thirdly, we included 6 features resulting from biochemistry blood tests, denoted as ’Serum’: Serum levels of urea, albumin, creatinine, sodium, potassium and C-reactive protein. Finally, 8 haematological blood test features were also included: white and haemaglobin cell counts, concentration of eosinophils, basophils, neutrophils, and lymphocytes, as well as eosinophil-to-basophil and neutrophil-to-lymphocyte ratios. These features were selected based on domain knowledge of features related to severity in the prognosis and outcome of T2RF inpatients. + +Descriptive statistics for all input variables is described in Table A.2. Median and inter-quartile range (IQR) is displayed for continuous and categorical variables, while binary variables are shown according to number of counts in the dataset and corresponding cohort proportion. Statistics are displayed for the complete data (”All”), but also for each sub-cohort defined by the overall outcome. We can observe that these sub-cohorts are not clearly separable and are hard to identify solely from this information. + +A summary of the patient cohort in relation to outcomes and target phenotypes can be seen in Table A.3. Challenges with regards to obtaining phenotypically separable clusters can similarly be observed - there is no clear significant difference between the target outcome sub-cohorts with regards to demographic input variables. With regards to outcome distribution, we also note the high degree of imbalance in the dataset - the large majority of the patients in our dataset suffered from no adverse events (over $86 \%$ ), while only 48 had a Cardiac event, and 76 were re-directed to the ICU. + +The lack of outcome sub-cohort separability can further observed in a temporal domain. Figures A.4, A.5, A.6 plot the mean trajectories of different temporal variables sets for each outcome subcohort, respectively, according to vital signs, haematological and serum features. Mean is calculated based on the time to outcome, and missing observations are disregarded and ignored. + +
eeh 67901 1013 92796.95.90/9 26-70918 81-91)81 111-1111 9-09) 9 (- 6-56) 56% 850850 (% 10'80)0181 1% 00 91) 1931155151 1100-00.0000 7781-4536 0-00 (900-0:000 385-00.0 009 711-75111 115353158185 11:5550000 (21.01- 33.01/00 11.010-2.0000.00 2105350 WUo " UC Ub
eaa 4 9941 15484399.95 099 (001- L 68 (1-81) 61 151000010 (L-85)99 96-166 24-181 IDI88-418 (%10.9) (% 89) (% 88D)817 00- 00.0 7855581 076109 (110-00' E00 (50-0-20:) 00 100-000000 773153935 0555515100000 27.07-00.0- 00.0 3.055505.09000 8555555955555 11.1-1150 W "U y U U
5 % 6 22/90-.90.99 (66- 0 0588 (11-11 71 2112-5555 IDI 61-91)81 6-) 56 (-%680 (08- 19) 69 (% 005) 8 (%0D)811.00-050030 1.1-6.90 5511511552 22133555 (010-00')0 (50-0-20:) 200 1-55 1-551.2525222535 1.001500000 (27- 000 215001 15-155
caprea 48 3 39.90.0559 171-10 505 (001-88 811-0015 (L-LS)59 6-06) 56 1-11IDI (Z8-69) 9L 3%2388 (%140 (%057D91101-555550 818856 01-51 (00-10 900 90/0-0:0200 8-55 905-9888 1-00011.07500.0.0 22.0- 0000 11051515815 5515225555 23.5-3000
916011 6119821 A 9943833505905.99 2820 111-11 914 76-20 (61-91)81 (9L-09)L9 (L6 - 56) S6 ()1%692)11 (% 09 7111 (18-29) % 64)1111.11-061111 11111-3553355 (20-00 010 (000-10000 (5-5 05 201-555090 (891-) 911 911-9991.055-15.0000000) 3000-00.00 00.00 (00.601 - 0085 00./ 871501125559 (40-09.110 4 44-44 4444
eu M eu ausnontmuoeoogee egu reugCeonunuogCeonunuog
(a)spag ag gggiae Hum 1 8 % ℃3品 /6v0x /6v0x 7/6v0[x 7/6v0x 7/6v0[xToun D Tou Toun 8 7
rrerago Trgrongae o ed Bereeeegeneregeeengor eepggepeamg seereprggotsse eerrprrgr tgteer areoaeaea Tare Hogsosn eee sspeges sossapereeg gee eret eggegeg rette opgggoog Bpggrooog rgoegg rgnonngn go mggeaagerereeeenee egret rereeer re ger se eer T trttsstttra
N o nZOdS JII ndAA R R 8 repueg a eotgms 品5 5 8 3 A 5R R 8
susttt umesoeege
+ +A.2: Descriptive statistics and information of all input data features. Variables are displayed with type, description, units and average statistics. We separate all features according to medical literature, including vital-sign, static, serum and haematological variables, and we also display statistics per outcome sub-cohort, defined as a cohort with those patients assigned to a given outcome. + +
No EventDeathICUCardiac
N37014417648
Age (IQR)71(61-80)81(74-88)69 (61-74)76 (69-82)
Gender,M1810 (48.9%)247 (56.0%)38 (50.0%)28 (58.33%)
CCI (IQR)4(3-13)14(4- 21)7(4- 17)15(4- 23)
Elective1126 (30.4%)3 (0.7%)8 (10.5%)2(4.2%)
Surgical1054 (28.5%)48 (10.1%)22 (29.0%)6 (12.5%)
+ +A.3: Descriptive demographic variable information for each outcome sub-cohort. + +![](images/74381f1f28f3fbe43252cc669d8791edb9470703e6404d9eaf70b1bfb815d80e.jpg) +A.4: Plot of mean vital-sign trajectories (median with respect to $\mathrm { S p O _ { 2 } }$ ) in solid line as given by the 4 outcome groups: admissions with a) Cardiac-, b) Death- , or c) ICU-, and d) No-events. The respective standard errors are represented by the dashed lines. We visualised trajectories from up to 7 days prior to an outcome event or discharge - the black lines represent the time window (72 - 24 hours prior to an event or discharge) considered for input to all models. + +# A.2 MODEL TRAINING + +A list indicating the grid-search range of hyper-parameters considered in our experiments are indicated in Table A.7. For simplicity, we define $\mathbb { P } : = \{ 0 . 0 0 1 , 0 . 0 1 , 0 . 1 , 1 , 1 0 \}$ , $\mathbb { L } : = \overline { { \{ 3 2 , 6 4 , 1 2 8 , 2 5 6 \} } }$ and $\mathbb { K } : = \{ 3 , . . . , 2 0 \}$ . In bold, top-performing hyper-parameters according to target metrics defined in Section 4 are highlighted. + +# A.3 RESULTS COMPARISON + +In Figures A.8 and Figures A.9 we display cluster outcome propensity distributions for some of our experiments with benchmark clustering models SOM-VAE and TSKM, respectively. Both models do not naturally associate clusters with a distribution - we estimate the cluster outcome as the empirical outcome distribution for the patient cohort assigned to the corresponding cluster. + +![](images/7cbbf11689c46b245b146e330e6341b475e20e0bfd241a6057f254c1cb9c118a.jpg) + +A.5: Plot of mean haematological trajectories in solid line as given by the 4 outcome groups: admissions with a) Cardiac-, b) Death- , or c) ICU-, and d) No-events. The respective standard errors are represented by the dashed lines. We visualised trajectories from up to 7 days prior to an outcome event or discharge - the black lines represent the time window (72 - 24 hours prior to an event or discharge) considered for input to all models. + +![](images/6857f5028848658d1c77a80478710fe7dde4adbca510a0e3cec145e48bade1a8.jpg) + +A.6: Plot of mean serum trajectories in solid line as given by the 4 outcome groups: admissions with a) Cardiac, b) Death- , or c) ICU-, and d) No-events. The respective standard errors are represented by the dashed lines. We visualised trajectories from up to 7 days prior to an outcome event or discharge - the black lines represent the time window (72 - 24 hours prior to an event or discharge) considered for input to all models. + +We note that clusters learnt by both clustering benchmark models have identical outcomes, which provides no useful clinical interpretability to the cluster-defined populations, as well as likely not assisting models to learn relevant cluster representations. + +![](images/13ed1700a4683e286da2aa988e865f24c992993ec189f75196e62cb691a50882.jpg) + +A.8: Bar plots of learnt cluster phenotypes for SOM-VAE with optimal hyper-parameters. Each plot represents a cluster - its phenotype is the corresponding empirical outcome distribution in its cluster-assigned patient cohort. + +We go further in comparing clusters learnt by TSKM and by our proposed model. We argue clusters learnt by CAMELOT are much more relevant towards our goal. We show this through two distinct plots. Firstly, in Figure A10, we display a scatter plot of patients in each cluster (CAMELOT on the right and TSKM clusters on the left) after projection to two dimensions. Projection was completed through a principal component analysis reduction to 50 dimensions, followed by t-stochastic neighbour embedding dimensionality projection to two. + +Furthermore, we also demonstrated that TSKM does not learn as separable cluster trajectory evolution profiles as CAMELOT. This is shown in Figure A11, where Heart-Rate mean trajectories for each cluster (i.e., average HR observations aligned to the same time until end of observations for patients in the clusters) are displayed. It is clear that CAMELOT cluster trajectories are easier to separate. + +A complete description of the number of patient admissions with a given outcome per learnt cluster in our proposed model can be seen in Table A.12. + +
ParameterTSKMSOM-VAEAC-TPCCAMELOTSVMXGB
seeds{1001,1012,1134,2475,6138,7415,1663,7205,9253,1782}
α-P(0.1)P(0.01)P(0.01)·-
β-P(0.1)P(0.01)P(0.001)--
Y-===-{0.1,0.2,0.6}
latent dimL(64)L(128)L(128)--
SOM dim-L²(4,4)-·--
KK(7)-K(6)K(6)--
kernel{'DTW','euclidean'}---{'polynomial','rbf'}-
C----P(10)·
n-estimators---{100,200,300}
depth---{1,3,5,10}
min-child-weight----{1,2,3,5}
+ +A.7: Parameter range used for Grid-search hyper-parameter optimisation. For each model, the list of parameter values tested is indicated. In bold, the optimum set of hyper-parameters is indicated for each model. + +![](images/a6991e898e692311abc357a9c435ca942fbae30bc7e5d5871c2e5be19ca4c51c.jpg) + +A.9: Bar plots of learnt cluster phenotypes for TSKM with $K = 6$ . Each plot represents a cluster - its phenotype is the corresponding empirical outcome distribution in its cluster-assigned patient cohort. + +![](images/3dcd345e38b4554d4d584bab086c69a6024e86ecdd3680fd243fb3d55ef2e7f0.jpg) +A.10: Scatter plot of cluster patient data after projection to 2 dimensions. + +
OutcomeHealthyDeathICUCardiac
Cluster 014944107
Cluster 17392855
Cluster 25791562
Cluster 39392125
Cluster 4373220
Cluster 5288841010
+ +A.12: Table with empirical number of outcome admissions observed for each cluster learnt by the proposed model. + +![](images/b3fb0a392cc615f242cba3e700b96546397a7311be21c745c43047a1a0cdbf91.jpg) +A.11: Plot of mean Heart-Rate (HR) trajectory in solid line as given by the TSKM learnt clusters (top) and CAMELOT (bottom). The respective standard errors are represented by the dashed lines. We visualised trajectories from up to 7 days prior to an outcome event or discharge - the black lines represent the time window (72 - 24 hours prior to an event or discharge) considered for input to all models. + +We also computed summary statistics for the learnt CAMELOT clusters. For each of the resulting clusters, median, and quartile values were computed and plotted, except on the case of binary variables, where only the number of positive occurrences (and the corresponding proportion in the cluster) are shown. + +Lastly, we plot the mean cluster trajectory evolution for SBP and FIO2 to present supportive evidence for the personalised attention maps in Figure 6. These two features were selected from attention map analysis. + +
2 31007-000080 17811-05.010 07/26-04550 (/51-07)0/79 6566-.155 33.55-5.1.11 39353.7599 01-0D01.18-0.1950 (%55240981 (%908) 0010 (%8S9D0s91711-1015 18.51-58551 (5:1-0.9)78 (0-00)r0 (r0-0'0)00 25-5555 (51-10)0(0/11-0.95.51 3383555577 1.15-5.1-5.830 1-811 3.20-.0.00 14-4 (71-8) 6.9
tssh 3(081-0'91021 1.14-.101-110 -700 (0'SL-0'09)0'L9 (0/6-0/6) 0.96 2.11-.0 63955755599(0.81-085000 (01-0D01 (% 66'TS) 0'961 3%72050 697966(1-8.11 (711-8 1111 (0-10)70 (r0-0'0)r0 91-554 (66-1)7 111-5.001701530300 2.21-8557 (0/8-0.95).1 25537075 18-5 124-96505 (89-)11
0 213.115-3.515.101 305157585/5 107381060 (0'8L-0'09)0'89 (0,96-0,16)0.06 2.7-5.115.716373-535599 (01-0D0T 0'58-0.69)59 (%/9) (%96'9)08 3655551(11-1 1715-88751 (r0-0'0)00 (r0-00)00 (5-0080 (9:41-9.9)504 (1-50 6.011715357315.350 23/87-5.600 1011-0 (1721-7157711 12724455 3555555 1711-71511
01.1135.7503000 006-00)00 (081-090021 7-0850.59 0/6-0.60.56 2.-..0 33933.799(0'08-085)0'1 1-0D01 (%00.0)0.100 (% 156781 60005070(711-16111 (11-1156 (0-00)0 (r0-0'0)00 5-6057 (16-84)6.9 17.1-6.070171531015010 220-500.00 17.7-5/1500 18110-811114 336-5551 1214-9555 18-7471
E13.753.15.711) .16-00.08 (281-0.90081 (181-029)00 0/6-0.6.6 2.-.1.1 83955535951718-3.59)5.11 3%7555955 %0/227000 162515050 1-0D011.11-11110 (6.71-8/0.0 (20-00) 10 (r0-00)00 9-800 (501-55)55 (7:1-8:001711537015110 2371-3.20 ('16-08)0'1 5715-1115.94 901-859 24594 38-71)85
so 201.114-7111.110 0.6-0.0.00 (061-5900'81 515-0/215159 /6-596 2.11-.1.10 33355.55791:18-769086 (% 5069)051 3567045.00 1-0D01 %50600(0/01-88) 6.6 6551-5155 (801-5)9 (70-00)r0 (r0-00)00 86-8087 (1-90)6.02:730700 117153005.000 (161-09876 3.87-3800 132-3550 17/7-501 511 (91-128
n 里 snonurjuog garnga s HUu SHUI % % ℃()eoae CenurnuonCenunuon
rsrergT/6v0[X T/6v0[X 品 T/6v0[X T/6v0[X品 T/ouu T/owu 1
einaiederrenge reeeaet sessreogooerse eeseorldeeee ereroaeear allta aaeeeea 5 0 P R R ereeeeee rsseeieas sostperagis etaigee argegatr 2oenllgo eeode rg gonrgooo gpgr gonroog rrregrgiiteg rgegrnrgoong pgonrgeoo geggge 8 8 8 R reeeeeeee egege re l i are glratt rge gia eaeeeereeeereeern R AB R 0 50 B
is geaee T srnsrrleeeah
+ +A.13: Descriptive statistics and information of all input data features. Variables are displayed with type, description, units and average statistics. We separate all features according to medical literature, including vitalsign, static, serum and haematological variables. Statistics are shown for each cohort as learnt by our model. + +![](images/06221e576edfe0b1abc5ba347060d4ddf5caedd3233369f4cf81a8aa6a3dfd37.jpg) +A.14: Plot of mean Systolic Blood Pressure (SBP) trajectories in solid line as given by the clusters learnt by our model (top). In the bottom, mean FIO2 trajectories are displayed. The respective standard errors are represented by the dashed lines. We visualised trajectories from up to 7 days prior to an outcome event or discharge - the black lines represent the time window $7 2 - 2 4$ hours prior to an event or discharge) considered for input to all models. \ No newline at end of file diff --git a/md/dev/lL3lnMbR4WU/lL3lnMbR4WU.md b/md/dev/lL3lnMbR4WU/lL3lnMbR4WU.md new file mode 100644 index 0000000000000000000000000000000000000000..23893ac26793559b94dcbae7d687c418a71189bf --- /dev/null +++ b/md/dev/lL3lnMbR4WU/lL3lnMbR4WU.md @@ -0,0 +1,449 @@ +# OPEN-VOCABULARY OBJECT DETECTION VIA VISION AND LANGUAGE KNOWLEDGE DISTILLATION + +Xiuye $\mathbf { G u } ^ { 1 }$ , Tsung-Yi Lin2, Weicheng ${ \bf K u o } ^ { 1 }$ , Yin Cui1 + +1Google Research, 2Nvidia∗ {xiuyegu, weicheng, yincui}@google.com tsungyil@nvidia.com + +# ABSTRACT + +We aim at advancing open-vocabulary object detection, which detects objects described by arbitrary text inputs. The fundamental challenge is the availability of training data. It is costly to further scale up the number of classes contained in existing object detection datasets. To overcome this challenge, we propose ViLD, a training method via Vision and Language knowledge Distillation. Our method distills the knowledge from a pretrained open-vocabulary image classification model (teacher) into a two-stage detector (student). Specifically, we use the teacher model to encode category texts and image regions of object proposals. Then we train a student detector, whose region embeddings of detected boxes are aligned with the text and image embeddings inferred by the teacher. We benchmark on LVIS by holding out all rare categories as novel categories that are not seen during training. ViLD obtains 16.1 mask $\mathsf { A P } _ { r }$ with a ResNet-50 backbone, even outperforming the supervised counterpart by 3.8. When trained with a stronger teacher model ALIGN, ViLD achieves 26.3 $\mathsf { A P } _ { r }$ . The model can directly transfer to other datasets without finetuning, achieving $7 2 . 2 \mathrm { \ A P 5 0 }$ on PASCAL VOC, 36.6 AP on COCO and 11.8 AP on Objects365. On COCO, ViLD outperforms the previous state-of-theart (Zareian et al., 2021) by 4.8 on novel AP and 11.4 on overall AP. Code and demo are open-sourced at https://github.com/tensorflow/tpu/ tree/master/models/official/detection/projects/vild. + +# 1 INTRODUCTION + +Consider Fig. 1, can we design object detectors beyond recognizing only base categories (e.g., toy) present in training labels and expand the vocabulary to detect novel categories (e.g., toy elephant)? In this paper, we aim to train an open-vocabulary object detector that detects objects in any novel categories described by text inputs, using only detection annotations in base categories. + +Existing object detection algorithms often learn to detect only the categories present in detection datasets. A common approach to increase the detection vocabulary is by collecting images with more labeled categories. The research community has recently collected new object detection datasets with large vocabularies (Gupta et al., 2019; Kuznetsova et al., 2020). LVIS (Gupta et al., 2019) is a milestone of these efforts by building a dataset with 1,203 categories. With such a rich vocabulary, it becomes quite challenging to collect enough training examples for all categories. By Zipf’s law, object categories naturally follow a long-tailed distribution. To find sufficient training examples for rare categories, significantly more data is needed (Gupta et al., 2019), which makes it expensive to scale up detection vocabularies. + +On the other hand, paired image-text data are abundant on the Internet. Recently, Radford et al. (2021) train a joint vision and language model using 400 million image-text pairs and demonstrate impressive results on directly transferring to over 30 datasets. The pretrained text encoder is the key to the zero-shot transfer ability to arbitrary text categories. Despite the great success on learning image-level representations, learning object-level representations for open-vocabulary detection is still challenging. In this work, we consider borrowing the knowledge from a pretrained openvocabulary classification model to enable open-vocabulary detection. + +![](images/12a2540acaad4fac22c4a93650975728dddff1e773f1715a7bdfa0fff24e710c.jpg) +Figure 1: An example of our open-vocabulary detector with arbitrary texts. After training on base categories (purple), we can detect novel categories (pink) that are not present in the training data. + +We begin with an R-CNN (Girshick et al., 2014) style approach. We turn open-vocabulary detection into two sub-problems: 1) generalized object proposal and 2) open-vocabulary image classification. We train a region proposal model using examples from the base categories. Then we use the pretrained open-vocabulary image classification model to classify cropped object proposals, which can contain both base and novel categories. We benchmark on LVIS (Gupta et al., 2019) by holding out all rare categories as novel categories and treat others as base categories. To our surprise, the performance on the novel categories already surpasses its supervised counterpart. However, this approach is very slow for inference, because it feeds object proposals one-by-one into the classification model. + +To address the above issue, we propose ViLD (Vision and Language knowledge Distillation) for training two-stage open-vocabulary detectors. ViLD consists of two components: learning with text embeddings (ViLD-text) and image embeddings (ViLD-image) inferred by an open-vocabulary image classification model, e.g., CLIP. In ViLD-text, we obtain the text embeddings by feeding category names into the pretrained text encoder. Then the inferred text embeddings are used to classify detected regions. Similar approaches have been used in prior detection works (Bansal et al., 2018; Rahman et al., 2018; Zareian et al., 2021). We find text embeddings learned jointly with visual data can better encode the visual similarity between concepts, compared to text embeddings learned from a language corpus, e.g., GloVe (Pennington et al., 2014). Using CLIP text embeddings achieves 10.1 $\mathsf { A P } _ { r }$ (AP of novel categories) on LVIS, significantly outperforming the $3 . \mathbf { 0 } \ \mathrm { A P } _ { r }$ of using GloVe. In ViLD-image, we obtain the image embeddings by feeding the object proposals into the pretrained image encoder. Then we train a Mask R-CNN whose region embeddings of detected boxes are aligned with these image embeddings. In contrast to ViLD-text, ViLD-image distills knowledge from both base and novel categories since the proposal network may detect regions containing novel objects, while ViLD-text only learns from base categories. Distillation enables ViLD to be general in choosing teacher and student architectures. ViLD is also energy-efficient as it works with off-the-shelf open-vocabulary image classifiers. We experiment with the CLIP and ALIGN (Jia et al., 2021) teacher models with different architectures (ViT and EfficientNet). + +We show that ViLD achieves 16.1 AP for novel categories on LVIS, surpassing the supervised counterpart by 3.8. We further use ALIGN as a stronger teacher model to push the performance to 26.3 novel AP, which is close (only 3.7 worse) to the 2020 LVIS Challenge winner (Tan et al., 2020) that is fully-supervised. We directly transfer ViLD trained on LVIS to other detection datasets without finetuning, and obtain strong performance of $7 2 . 2 \mathrm { A P } _ { 5 0 }$ on PASCAL VOC, 36.6 AP on COCO and 11.8 AP on Objects365. We also outperform the previous state-of-the-art open-vocabulary detector on COCO (Zareian et al., 2021) by 4.8 novel AP and 11.4 overall AP. + +# 2 RELATED WORK + +Increasing vocabulary in visual recognition: Recognizing objects using a large vocabulary is a long-standing research problem in computer vision. One focus is zero-shot recognition, aiming at recognizing categories not present in the training set. Early works (Farhadi et al., 2009; Rohrbach et al., 2011; Jayaraman & Grauman, 2014) use visual attributes to create a binary codebook representing categories, which is used to transfer learned knowledge to unseen categories. In this direction, researchers have also explored class hierarchy, class similarity, and object parts as discriminative features to aid the knowledge transfer (Rohrbach et al., 2011; Akata et al., 2016; Zhao et al., 2017; Elhoseiny et al., 2017; Ji et al., 2018; Cacheux et al., 2019; Xie et al., 2020). Another focus is learning to align latent image-text embeddings, which allows to classify images using arbitrary texts. Frome et al. (2013) and Norouzi et al. (2014) are pioneering works that learn a visual-semantic embedding space using deep learning. Wang et al. (2018) distills information from both word embeddings and knowledge graphs. Recent work CLIP (Radford et al., 2021) and ALIGN (Jia et al., 2021) push the limit by collecting million-scale image-text pairs and then training joint image-text models using contrastive learning. These models can directly transfer to a suite of classification datasets and achieve impressive performances. While these work focus on image-level open-vocabulary recognition, we focus on detecting objects using arbitrary text inputs. + +![](images/4cdf33b89496acb3d10d8d249574bccf34cd94d73bb4bc63bb612f5742fc93d4.jpg) +Figure 2: An overview of using ViLD for open-vocabulary object detection. ViLD distills the knowledge from a pretrained open-vocabulary image classification model. First, the category text embeddings and the image embeddings of cropped object proposals are computed, using the text and image encoders in the pretrained classification model. Then, ViLD employs the text embeddings as the region classifier (ViLD-text) and minimizes the distance between the region embedding and the image embedding for each proposal (ViLD-image). During inference, text embeddings of novel categories are used to enable open-vocabulary detection. + +Increasing vocabulary in object detection: It’s expensive to scale up the data collection for large vocabulary object detection. Zhao et al. (2020) and Zhou et al. (2021) unify the label space from multiple datasets. Joseph et al. (2021) incrementally learn identified unknown categories. Zero-shot detection (ZSD) offers another direction. Most ZSD methods align region features to pretrained text embeddings in base categories (Bansal et al., 2018; Demirel et al., 2018; Rahman et al., 2019; Hayat et al., 2020; Zheng et al., 2020). However, there is a large performance gap to supervised counterparts. To address this issue, Zareian et al. (2021) pretrain the backbone model using image captions and finetune the pretrained model with detection datasets. In contrast, we use an image-text pretrained model as a teacher model to supervise student object detectors. All previous methods are only evaluated on tens of categories, while we are the first to evaluate on more than 1,000 categories. + +# 3 METHOD + +Notations: We divide categories in a detection dataset into the base and novel subsets, and denote them by $C _ { B }$ and $C _ { N }$ . Only annotations in $C _ { B }$ are used for training. We use $\tau ( \cdot )$ to denote the text encoder and $\mathcal { V } ( \cdot )$ to denote the image encoder in the pretrained open-vocabulary image classifier. + +# 3.1 LOCALIZATION FOR NOVEL CATEGORIES + +The first challenge for open-vocabulary detection is to localize novel objects. We modify a standard two-stage object detector, e.g., Mask R-CNN (He et al., 2017), for this purpose. We replace its classspecific localization modules, i.e., the second-stage bounding box regression and mask prediction layers, with class-agnostic modules for general object proposals. For each region of interest, these modules only predict a single bounding box and a single mask for all categories, instead of one prediction per category. The class-agnostic modules can generalize to novel objects. + +# 3.2 OPEN-VOCABULARY DETECTION WITH CROPPED REGIONS + +Once object candidates are localized, we propose to reuse a pretrained open-vocabulary image classifier to classify each region for detection. + +![](images/2d4f5932293dd4e577ca7d53f30d5a2d564631c7405a1f159060ec49fc0e9fc4.jpg) +Figure 3: Model architecture and training objectives. (a) The classification head of a vanilla two-stage detector, e.g., Mask R-CNN. (b) ViLD-text replaces the classifier with fixed text embeddings and a learnable background embedding. The projection layer is introduced to adjust the dimension of region embeddings to be compatible with the text embeddings. (c) ViLD-image distills from the precomputed image embeddings of proposals with an $\mathcal { L } _ { 1 }$ loss. (d) ViLD combines ViLD-text and ViLD-image. + +Image embeddings: We train a proposal network on base categories $C _ { B }$ and extract the region proposals $\tilde { r } \in \tilde { P }$ offline. We crop and resize the proposals, and feed them into the pretrained image encoder $\nu$ to compute image embeddings $\mathcal { V } ( \mathrm { c r o p } ( I , \tilde { r } ) )$ , where $I$ is the image. + +We ensemble the image embeddings from $1 \times$ and $1 . 5 \times$ crops, as the $1 . 5 \times$ crop provides more context cues. The ensembled embedding is then renormalized to unit norm: + +$$ +\mathcal { V } ( \mathrm { c r o p } ( I , \tilde { r } _ { \{ 1 \times , 1 . 5 \times \} } ) ) = \frac { \mathbf { v } } { \lVert \mathbf { v } \rVert } , \mathrm { ~ w h e r e ~ } \mathbf { v } = \mathcal { V } ( \mathrm { c r o p } ( I , \tilde { r } _ { 1 \times } ) ) + \mathcal { V } ( \mathrm { c r o p } ( I , \tilde { r } _ { 1 . 5 \times } ) ) . +$$ + +Text embeddings: We generate the text embeddings offline by feeding the category texts with prompt templates, e.g., “a photo of $\{ { \mathrm { c a t e g o r y } } \}$ in the scene”, into the text encoder $\tau$ . We ensemble multiple prompt templates and the synonyms if provided. + +Then, we compute cosine similarities between the image and text embeddings. A softmax activation is applied, followed by a per-class NMS to obtain final detections. The inference is slow since every cropped region is fed into $\nu$ . + +# 3.3 VILD: VISION AND LANGUAGE KNOWLEDGE DISTILLATION. + +We propose ViLD to address the slow inference speed of the above method. ViLD learns region embeddings in a two-stage detector to represent each proposal $r$ . We denote region embeddings by $\mathcal { R } ( \phi ( I ) , r )$ , where $\phi ( \cdot )$ is a backbone model and $\mathcal { R } ( \cdot )$ is a lightweight head that generates region embeddings. Specifically, we take outputs before the classification layer as region embeddings. + +Replacing classifier with text embeddings: We first introduce ViLD-text. Our goal is to train the region embeddings such that they can be classified by text embeddings. Fig. 3(b) shows the architecture and training objective. ViLD-text replaces the learnable classifier in Fig. 3(a) with the text embeddings introduced in Sec. 3.2. Only $\mathcal { T } ( C _ { B } )$ , the text embeddings of $C _ { B }$ , are used for training. For the proposals that do not match any groundtruth in $C _ { B }$ , they are assigned to the background category. Since the text “background” does not well represent these unmatched proposals, we allow the background category to learn its own embedding $\mathbf { e } _ { b g }$ . We compute the cosine similarity between each region embedding $\mathcal { R } ( \phi ( I ) , r )$ and all category embeddings, including $\mathcal { T } ( C _ { B } )$ and $\mathbf { e } _ { b g }$ . Then we apply softmax activation with a temperature $\tau$ to compute the cross entropy loss. To train the first-stage region proposal network of the two-stage detector, we extract region proposals $r \in P$ online, and train the detector with ViLD-text from scratch. The loss for ViLD-text can be written as: + +$$ +\begin{array} { l } { \displaystyle { { \bf { e } } _ { r } } = \mathcal { R } ( \phi ( I ) , r ) } \ { \displaystyle { { \bf { e } } _ { r } } } \\ { { \displaystyle { \bf { z } } ( r ) = \left[ s i m ( { \bf { e } } _ { r } , { \bf { e } } _ { b g } ) , \ s i m ( { \bf { e } } _ { r } , { \bf { t } } _ { 1 } ) , \ \cdot \cdot \cdot , \ s i m ( { \bf { e } } _ { r } , { \bf { t } } _ { | C _ { B } | } ) \right] } } \\ { { \displaystyle \mathcal { L } _ { \mathrm { V i L D - t e x t } } = \frac { 1 } { N } \sum _ { r \in P } \mathcal { L } _ { \mathrm { C E } } \Big ( s o f t m a x \big ( { \bf { z } } ( r ) / \tau \big ) , y _ { r } \Big ) } , } \end{array} +$$ + +where $s i m ( \mathbf { a } , \mathbf { b } ) = \mathbf { a } ^ { \top } \mathbf { b } / ( \| \mathbf { a } \| \| \mathbf { b } \| )$ , $\mathbf { t } _ { i }$ denotes elements in $\mathcal { T } ( C _ { B } )$ , $y _ { r }$ denotes the class label of region $r$ , $N$ is the number of proposals per image $( | P | )$ , and $\mathcal { L } _ { C E }$ is the cross entropy loss. + +During inference, we include novel categories $( C _ { N } )$ and generate $\mathcal { T } ( C _ { B } \cup C _ { N } )$ (sometimes $\mathcal { T } ( C _ { N } )$ only) for open-vocabulary detection (Fig. 2). Our hope is that the model learned from annotations in $C _ { B }$ can generalize to novel categories $C _ { N }$ . + +Distilling image embeddings: We then introduce ViLD-image, which aims to distill the knowledge from the teacher image encoder $\nu$ into the student detector. Specifically, we align region embeddings $\mathcal { R } ( \phi ( I ) , \tilde { r } )$ to image embeddings $\mathcal { V } ( \mathrm { c r o p } ( I , \tilde { r } ) )$ introduced in Sec. 3.2. + +To make the training more efficient, we extract $M$ proposals $\tilde { r } \in \tilde { P }$ offline for each training image, and precompute the $M$ image embeddings. These proposals can contain objects in both $C _ { B }$ and $C _ { N }$ , as the network can generalize. In contrast, ViLD-text can only learn from $C _ { B }$ . We apply an $\mathcal { L } _ { 1 }$ loss between the region and image embeddings to minimize their distance. The ensembled image embeddings in Sec. 3.2 are used for distillation: + +$$ +\mathcal { L } _ { \mathrm { V i L D - i m a g e } } = \frac { 1 } { M } \sum _ { \tilde { \boldsymbol { r } } \in \tilde { P } } \| \mathcal { V } ( \mathrm { c r o p } ( I , \tilde { r } _ { \{ 1 \times , 1 . 5 \times \} } ) ) - \mathcal { R } ( \phi ( I ) , \tilde { r } ) \| _ { 1 } . +$$ + +Fig. 3(c) shows the architecture. Zhu et al. (2019) use a similar approach to make Faster R-CNN features mimic R-CNN features, however, the details and goals are different: They reduce redundant context to improve supervised detection; while ViLD-image is to enable open-vocabulary detection on novel categories. + +The total training loss of ViLD is simply a weighted sum of both objectives: + +$$ +\mathcal { L } _ { \mathrm { V i L D } } = \mathcal { L } _ { \mathrm { V i L D - t e x t } } + w \cdot \mathcal { L } _ { \mathrm { V i L D - i m a g e } } , +$$ + +where $w$ is a hyperparameter weight for distilling the image embeddings. Fig. 3(d) shows the model architecture and training objectives. ViLD-image distillation only happens in training time. During inference, ViLD-image, ViLD-text and ViLD employ the same set of text embeddings as the detection classifier, and use the same architecture for open-vocabulary detection (Fig. 2). + +# 3.4 MODEL ENSEMBLING + +In this section, we explore model ensembling for the best detection performance over base and novel categories. First, we combine the predictions of a ViLD-text detector with the open-vocabulary image classification model. The intuition is that ViLD-image learns to approximate the predictions of its teacher model, and therefore, we assume using the teacher model directly may improve performance. We use a trained ViLD-text detector to obtain top $k$ candidate regions and their confidence scores. Let $p _ { i }$ ,ViLD-text denote the confidence score of proposal $\tilde { r }$ belonging to category $i$ . We then feed crop $( I , \tilde { r } )$ to the open-vocabulary classification model to obtain the teacher’s confidence score $p _ { i , \mathrm { c l s } }$ . Since we know the two models have different performance on base and novel categories, we introduce a weighted geometric average for the ensemble: + +$$ +p _ { i , \mathrm { e n s e m b l e } } = { \left\{ \begin{array} { l l } { p _ { i , { \mathrm { V i L D - t e x t } } } ^ { \lambda } \cdot p _ { i , \mathrm { c l s } } ^ { ( 1 - \lambda ) } , } & { { \mathrm { i f ~ } } i \in C _ { B } } \\ { p _ { i , { \mathrm { V i L D - t e x t } } } ^ { ( 1 - \lambda ) } \cdot p _ { i , \mathrm { c l s } } ^ { \lambda } . } & { { \mathrm { i f ~ } } i \in C _ { N } } \end{array} \right. } +$$ + +$\lambda$ is set to $2 / 3$ , which weighs the prediction of ViLD-text more on base categories and vice versa. +Note this approach has a similar slow inference speed as the method in Sec. 3.2. + +Next, we introduce a different ensembling approach to mitigate the above inference speed issue. Besides, in ViLD, the cross entropy loss of ViLD-text and the $\mathcal { L } _ { 1 }$ distillation loss of ViLD-image is applied to the same set of region embeddings, which may cause contentions. Here, instead, we learn two sets of embeddings for ViLD-text (Eq. 2) and ViLD-image (Eq. 3) respectively, with two separate heads of identical architectures. Text embeddings are applied to these two regions embeddings to obtain confidence scores $p _ { i }$ ,ViLD-text and $p _ { i }$ ,ViLD-image, which are then ensembled in the same way as Eq. 5, with $p _ { i }$ ,ViLD-image replacing $p _ { i , \mathrm { c l s } }$ . We name this approach ViLD-ensemble. + +# 4 EXPERIMENTS + +Implementation details: We benchmark on the Mask R-CNN (He et al., 2017) with ResNet (He et al., 2016) FPN (Lin et al., 2017) backbone and use the same settings for all models unless explicitly specified. The models use $1 0 2 4 \times 1 0 2 4$ as input image size, large-scale jittering augmentation of range [0.1, 2.0], synchronized batch normalization (Ioffe & Szegedy, 2015; Girshick et al., 2018) of batch size 256, weight decay of 4e-5, and an initial learning rate of 0.32. We train the model from scratch for 180,000 iterations, and divide the learning rate by 10 at $0 . 9 \times$ , $0 . 9 5 \times$ , and $0 . 9 7 5 \times$ of total iterations. We use the publicly available pretrained CLIP model1 as the open-vocabulary classification model, with an input size of $2 2 4 \times 2 2 4$ . The temperature $\tau$ is set to 0.01, and the maximum number of detections per image is 300. We refer the readers to Appendix D for more details. + +# 4.1 BENCHMARK SETTINGS + +We mainly evaluate on LVIS (Gupta et al., 2019) with our new setting. To compare with previous methods, we also use the setting in Zareian et al. (2021), which is adopted in many zero-shot detection works. + +LVIS: We benchmark on LVIS v1. LVIS contains a large and diverse set of vocabulary (1,203 categories) that is more suitable for open-vocabulary detection. We take its 866 frequent and common categories as the base categories $C _ { B }$ , and hold out the 337 rare categories as the novel categories $C _ { N }$ . $\mathsf { A P } _ { r }$ , the AP of rare categories, is the main metric. + +COCO: Bansal et al. (2018) divide COCO-2017 (Lin et al., 2014) into 48 base categories and 17 novel categories, removing 15 categories without a synset in the WordNet hierarchy. We follow previous works and do not compute instance masks. We evaluate on the generalized setting. + +# 4.2 LEARNING GENERALIZABLE OBJECT PROPOSALS + +We first study whether a detector can localize novel categories when only trained on base categories. We evaluate the region proposal networks in Mask R-CNN with a ResNet-50 backbone. Table 1 shows the average recall (AR) (Lin et al., 2014) on novel categories. Training with only base categories performs slightly worse by $\sim 2$ AR at 100, 300, and 1000 proposals, compared to using both base and novel categories. This experiment demonstrates that, without seeing novel categories during training, region proposal networks can generalize to novel categories, only suffering a small performance drop. We believe better proposal networks focusing on unseen category generalization should further improve the performance, and leave this for future research. + +Table 1: Training with only base categories achieves comparable average recall (AR) for novel categories on LVIS. We compare RPN trained with base only vs. base $^ +$ novel categories and report the bounding box AR. + +
SupervisionARr@100ARr@300ARr@1000
base39.348.355.6
base + novel41.150.957.0
+ +# 4.3 OPEN-VOCABULARY CLASSIFIER ON CROPPED REGIONS + +In Table 2, we evaluate the approach in Sec. 3.2, i.e., using an open-vocabulary classifier to classify cropped region proposals. We use CLIP in this experiment and find it tends to output confidence scores regardless of the localization quality (Appendix B). Given that, we ensemble the CLIP confidence score with a proposal objectness score by geometric mean. Results show it improves both base and novel APs. We compare with supervised baselines trained on base/base+novel categories, as well as Supervised-RFS (Mahajan et al., 2018; Gupta et al., 2019) that uses category frequency for balanced sampling. CLIP on cropped regions already outperforms supervised baselines on $\mathsf { A P } _ { r }$ by a large margin, without accessing detection annotations in novel categories. However, the performances of $\mathsf { A P } _ { c }$ and $\mathsf { A P } _ { f }$ are still trailing behind. This experiment shows that a strong openvocabulary classification model can be a powerful teacher model for detecting novel objects, yet there is still much improvement space for inference speed and overall AP. + +Table 2: Using CLIP for open-vocabulary detection achieves high detection performance on novel categories. We apply CLIP to classify cropped region proposals, with or without ensembling objectness scores, and report the mask average precision (AP). The performance on novel categories $( \mathsf { A P } _ { r } )$ is far beyond supervised learning approaches. However, the overall performance is still behind. + +
MethodAPrAPcAPfAP
Supervised (base class only)0.022.632.422.5
CLIP on cropped regions w/o objectness13.010.66.09.2
CLIP on cropped regions18.918.816.017.7
Supervised (base+novel)4.123.533.223.9
Supervised-RFS (base+novel)12.324.332.425.4
+ +Table 3: Performance of ViLD and its variants. ViLD outperforms the supervised counterpart on novel categories. Using ALIGN as the teacher model achieves the best performance without bells and whistles. All results are mask AP. We average over 3 runs for R50 experiments. †: methods with R-CNN style; runtime is $6 3 0 \times$ of Mask R-CNN style. ‡: for reference, fully-supervised learning with additional tricks. + +
BackboneMethodAPrAPAPfAP
ResNet-50+ViT-B/32 CLIP on cropped regions+18.918.816.017.7
ViLD-text+CLIP†22.624.829.226.1
ResNet-50Supervised-RFS (base+novel)12.324.332.425.4
GloVe baseline3.020.130.421.2
ViLD-text10.123.932.524.9
ViLD-image11.211.311.111.2
ViLD (w=0.5)16.120.028.322.5
ViLD-ensemble (w=0.5)16.624.630.325.5
EfficientNet-b7ViLD-ensemble w/ ViT-L/14 (w=1.0)21.729.133.629.6
ViLD-ensemble w/ ALIGN (w=1.0)26.327.232.929.3
ResNeSt269+HTC2020 Challenge winner (Tan et al., 2020)30.041.946.041.5
+ +# 4.4 VISION AND LANGUAGE KNOWLEDGE DISTILLATION + +We evaluate the performance of ViLD and its variants (ViLD-text, ViLD-image, and ViLDensemble), which are significantly faster compared to the method in Sec. 4.3. Finally, we use stronger teacher models to demonstrate our best performance. Table 3 summarizes the results. + +Text embeddings as classifiers (ViLD-text): We evaluate ViLD-text using text embeddings generated by CLIP, and compare it with GloVe text embeddings (Pennington et al., 2014) pretrained on a large-scale text-only corpus. Table 3 shows ViLD-text achieves $1 0 . 1 \mathrm { \ A P } _ { r }$ , which is significantly better than $3 . 0 \mathrm { \ A P } _ { r }$ using GloVe. This demonstrates the importance of using text embeddings that are jointly trained with images. ViLD-text achieves much higher $\mathsf { A P } _ { c }$ and $\mathsf { A P } _ { f }$ compared to CLIP on cropped regions (Sec. 4.3), because ViLD-text uses annotations in $C _ { B }$ to align region embeddings with text embeddings. The $\mathsf { A P } _ { r }$ is worse, showing that using only 866 base categories in LVIS does not generalize as well as CLIP to novel categories. + +Distilling image embeddings (ViLD-image): We evaluate ViLD-image, which distills from the image embeddings of cropped region proposals, inferred by CLIP’s image encoder, with a distillation weight of 1.0. Experiments show that ensembling with objectness scores doesn’t help with other ViLD variants, so we only apply it to ViLD-image. Without training with any object category labels, ViLD-image achieves $1 1 . 2 \mathsf { A P } _ { r }$ and 11.2 overall AP. This demonstrates that visual distillation works for open-vocabulary detection but the performance is not as good as CLIP on cropped regions. + +Text+visual embeddings (ViLD): ViLD shows the benefits of combining distillation loss (ViLDimage) with classification loss using text embeddings (ViLD-text). We explore different hyperparameter settings in Appendix Table 7 and observe a consistent trade-off between $\mathsf { A P } _ { r }$ and $\mathsf { A P } _ { c , f }$ , which suggests there is a competition between ViLD-text and ViLD-image. In Table 3, we compare ViLD with other methods. Its $\mathsf { A P } _ { r }$ is 6.0 higher than ViLD-text and 4.9 higher than ViLD-image, indicating combining the two learning objectives boosts the performance on novel categories. ViLD outperforms Supervised-RFS by $3 . 8 \mathrm { A P } _ { r }$ , showing our open-vocabulary detection approach is better than supervised models on rare categories. + +Table 4: Performance on COCO dataset compared with existing methods. ViLD outperforms all the other methods in the table trained with various sources by a large margin, on both novel and base categories. + +
MethodTraining sourceNovel APBase APOverall AP
Bilen & Vedaldi (2016) Ye et al. (2019)image-level labels in CB U CN19.7 20.319.6 20.119.6 20.1
Bansal et al. (2018) Zhu et al. (2020)instance-level labels in CB0.31 3.4129.2 13.824.9 13.0
Rahman et al. (2020) Zareian et al. (2021)image captions in CB U CN4.1235.927.9
CLIP on cropped regionsinstance-level labels in CB22.846.039.9
ViLD-text ViLD-imageimage-text pairs from Internet (may contain CB U CN) instance-level labels in CB26.3 5.9 24.128.3 61.827.8 47.2
+ +Model ensembling: We study methods discussed in Sec. 3.4 to reconcile the conflict of joint training with ViLD-text and ViLD-image. We use two ensembling approaches: 1) ensembling ViLD-text with CLIP (ViLD-text $+ \mathbf { C L I P } )$ ); 2) ensembling ViLD-text and ViLD-image using separate heads (ViLD-ensemble). As shown in Table 3, ViLD-ensemble improves performance over ViLD, mainly on $\mathsf { A P } _ { c }$ and $\mathsf { A P } _ { r }$ . This shows ensembling reduces the competition. ViLD-text+CLIP obtains much higher $\mathsf { A P } _ { r }$ , outperforming ViLD by 6.5, and maintains good $\mathsf { A P } _ { c , f }$ . Note that it is slow and impractical for real world applications. This experiment is designed for showing the potential of using open-vocabulary classification models for open-vocabulary detection. + +Stronger teacher model: We use CLIP ViT-L/14 and ALIGN (Jia et al., 2021) to explore the performance gain with a stronger teacher model (details in Appendix D). As shown in Table 3, both models achieve superior results compared with R50 ViLD w/ CLIP. The detector distilled from ALIGN is only trailing to the fully-supervised 2020 Challenge winner (Tan et al., 2020) by $3 . 7 \mathrm { A P } _ { r }$ , which employs two-stage training, self-training, and multi-scale testing etc. The results demonstrate ViLD scales well with the teacher model, and is a promising open-vocabulary detection approach. + +# 4.5 PERFORMANCE COMPARISON ON COCO DATASET + +Several related works in zero-shot detection and open-vocabulary detection are evaluated on COCO. To compare with them, we train and evaluate ViLD variants following the benchmark setup in Zareian et al. (2021) and report box AP with an IoU threshold of 0.5. We use the ResNet-50 backbone, shorten the training schedule to 45,000 iterations, and keep other settings the same as our experiments on LVIS. Table 4 summarizes the results. ViLD outperforms Zareian et al. (2021) by 4.8 Novel AP and 13.5 Base AP. Different from Zareian et al. (2021), we do not have a pretraining phase tailored for detection. Instead, we use an off-the-shelf classification model. The performance of ViLD-text is low because only 48 base categories are available, which makes generalization to novel categories challenging. In contrast, ViLD-image and ViLD, which can distill image features of novel categories, outperform all existing methods (not apple-to-apple comparison though, given different methods use different settings). + +# 4.6 TRANSFER TO OTHER DATASETS + +Trained ViLD models can be transferred to other detection datasets, by simply switching the classifier to the category text embeddings of the new datasets. For simplicity, we keep the background embedding trained on LVIS. We evaluate the transferability of ViLD on PASCAL VOC (Everingham et al., 2010), COCO (Lin et al., 2014), and Objects365 (Shao et al., 2019). Since the three datasets have much smaller vocabularies, category overlap is unavoidable and images can be shared among datasets, e.g., COCO and LVIS. As shown in Table 5, ViLD achieves better transfer performance than ViLD-text. In PASCAL and COCO, the gap is large. This improvement should be credited to visual distillation, which better aligns region embeddings with the text classifier. We also compare with supervised learning and finetuning the classification layer. Although across datasets, ViLD has 3-6 AP gaps compared to the finetuning method and larger gaps compared to the supervised method, it is the first time we can directly transfer a trained detector to different datasets using language. + +Table 5: Generalization ability of ViLD. We evaluate the LVIS-trained model with ResNet-50 backbone on PASCAL VOC 2007 test set, COCO validation set, and Objects365 v1 validation set. Simply replacing the text embeddings, our approaches are able to transfer to various detection datasets. The supervised baselines of COCO and Objects365 are trained from scratch. †: the supervised baseline of PASCAL VOC is initialized with an ImageNet-pretrained checkpoint. All results are box APs. + +
MethodPASCAL VOC+CoCOObjects365
AP50AP75APAP50AP75APAP50AP75
ViLD-text40.531.628.843.431.410.415.811.1
ViLD72.256.736.655.639.811.818.212.6
Finetuning78.960.339.159.842.415.223.916.2
Supervised78.549.046.567.650.925.638.628.0
+ +![](images/7244b96d31b6f6e562fd71b8bca7fb59a44963198d7d6427bc8c5a465606d94d.jpg) +Figure 4: Qualitative results on LVIS, COCO, and Objects365. First row: ViLD is able to correctly localize and recognize objects in novel categories. For clarity, we only show the detected novel objects. Second row: The detected objects on base+novel categories. The performance on base categories is not degraded with ViLD. Last two rows: ViLD can directly transfer to COCO and Objects365 without further finetuning. + +# 4.7 QUALITATIVE RESULTS + +In Fig. 4, we visualize ViLD’s detection results. It illustrates ViLD is able to detect objects of both novel and base categories, with high-quality mask predictions on novel objects, e.g., it well separates banana slices from the crepes (novel category). We also show qualitative results on COCO and Objects365, and find ViLD generalizes well. We show more qualitative results, e.g., interactive detection and systematic expansion, in Appendix A. + +# 5 CONCLUSION + +We present ViLD, an open-vocabulary object detection method by distilling knowledge from openvocabulary image classification models. ViLD is the first open-vocabulary detection method evaluated on the challenging LVIS dataset. It attains 16.1 AP for novel cateogires on LVIS with a ResNet50 backbone, which surpasses its supervised counterpart at the same inference speed. With a stronger teacher model (ALIGN), the performance can be further improved to 26.3 novel AP. We demonstrate that the detector learned from LVIS can be directly transferred to 3 other detection datasets. We hope that the simple design and strong performance make ViLD a scalable alternative approach for detecting long-tailed categories, instead of collecting expensive detection annotations. + +# ETHICS STATEMENT + +Our paper studies open-vocabulary object detection, a sub-field in computer vision. Our method is based on knowledge distillation, a machine learning technique that has been extensively used in computer vision, natural language processing, etc. All of our experiments were conducted on public datasets with pretrained models that are either publicly available or introduced in published papers. The method proposed in our paper is a principled method for open-vocabulary object detection that can be used in a wide range of applications. Therefore, the ethical impact of our work would primarily depends on the specific applications. We foresee positive impacts if our method is applied to object detection problems where the data collection is difficult to scale, such as detecting rare objects for self-driving cars. But the method can also be applied to other sensitive applications that could raise ethical concerns, such as video surveillance systems. + +# REPRODUCIBILITY STATEMENT + +We provide detailed descriptions of the proposed method in Sec. 3. Details about experiment settings, hyper-parameters and implementations are presented in Sec. 4, Appendix C and Appendix D. We release our code and pretrained models at https://github.com/tensorflow/tpu/ tree/master/models/official/detection/projects/vild to facilitate the reproducibility of our work. + +# REFERENCES + +Zeynep Akata, Mateusz Malinowski, Mario Fritz, and Bernt Schiele. Multi-cue zero-shot learning with strong supervision. In CVPR, 2016. + +Ankan Bansal, Karan Sikka, Gaurav Sharma, Rama Chellappa, and Ajay Divakaran. Zero-shot object detection. In ECCV, 2018. + +Hakan Bilen and Andrea Vedaldi. Weakly supervised deep detection networks. In CVPR, 2016. + +Yannick Le Cacheux, Herve Le Borgne, and Michel Crucianu. Modeling inter and intra-class relations in the triplet loss for zero-shot learning. In ICCV, 2019. + +Berkan Demirel, Ramazan Gokberk Cinbis, and Nazli Ikizler-Cinbis. Zero-shot object detection by hybrid region embedding. In BMVC, 2018. + +Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. Bert: Pre-training of deep bidirectional transformers for language understanding. NAACL, 2019. + +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. ICLR, 2020. + +Mohamed Elhoseiny, Yizhe Zhu, Han Zhang, and Ahmed Elgammal. Link the head to the “beak”: Zero shot learning from noisy text description at part precision. In CVPR, 2017. + +Mark Everingham, Luc Van Gool, Christopher KI Williams, John Winn, and Andrew Zisserman. The pascal visual object classes (voc) challenge. IJCV, 2010. + +Ali Farhadi, Ian Endres, Derek Hoiem, and David Forsyth. Describing objects by their attributes. In CVPR, 2009. + +Andrea Frome, Greg S Corrado, Jon Shlens, Samy Bengio, Jeff Dean, Marc’Aurelio Ranzato, and Tomas Mikolov. Devise: A deep visual-semantic embedding model. In NeurIPS, 2013. + +Ross Girshick, Jeff Donahue, Trevor Darrell, and Jitendra Malik. Rich feature hierarchies for accurate object detection and semantic segmentation. In CVPR, 2014. + +Ross Girshick, Ilija Radosavovic, Georgia Gkioxari, Piotr Dollar, and Kaiming He. Detectron.´ https://github.com/facebookresearch/detectron, 2018. + +Agrim Gupta, Piotr Dollar, and Ross Girshick. Lvis: A dataset for large vocabulary instance segmentation. In CVPR, 2019. + +Nasir Hayat, Munawar Hayat, Shafin Rahman, Salman Khan, Syed Waqas Zamir, and Fahad Shahbaz Khan. Synthesizing the unseen for zero-shot object detection. In ACCV, 2020. + +Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. In CVPR, 2016. + +Kaiming He, Georgia Gkioxari, Piotr Dollar, and Ross Girshick. Mask r-cnn. In ´ ICCV, 2017. + +Sergey Ioffe and Christian Szegedy. Batch normalization: Accelerating deep network training by reducing internal covariate shift. In ICML, 2015. + +Dinesh Jayaraman and Kristen Grauman. Zero shot recognition with unreliable attributes. NeurIPS 2014, 2014. + +Zhong Ji, Yanwei Fu, Jichang Guo, Yanwei Pang, Zhongfei Mark Zhang, et al. Stacked semanticsguided attention model for fine-grained zero-shot learning. In NeurIPS, 2018. + +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. ICML, 2021. + +KJ Joseph, Salman Khan, Fahad Shahbaz Khan, and Vineeth N Balasubramanian. Towards open world object detection. In CVPR, 2021. + +Alina Kuznetsova, Hassan Rom, Neil Alldrin, Jasper Uijlings, Ivan Krasin, Jordi Pont-Tuset, Shahab Kamali, Stefan Popov, Matteo Malloci, Alexander Kolesnikov, Tom Duerig, and Vittorio Ferrari. The open images dataset v4: Unified image classification, object detection, and visual relationship detection at scale. IJCV, 2020. + +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´ ECCV, 2014. + +Tsung-Yi Lin, Piotr Dollar, Ross Girshick, Kaiming He, Bharath Hariharan, and Serge Belongie.´ Feature pyramid networks for object detection. In CVPR, 2017. + +Dhruv Mahajan, Ross Girshick, Vignesh Ramanathan, Kaiming He, Manohar Paluri, Yixuan Li, Ashwin Bharambe, and Laurens Van Der Maaten. Exploring the limits of weakly supervised pretraining. In ECCV, 2018. + +Mohammad Norouzi, Tomas Mikolov, Samy Bengio, Yoram Singer, Jonathon Shlens, Andrea Frome, Greg S Corrado, and Jeffrey Dean. Zero-shot learning by convex combination of semantic embeddings. ICLR, 2014. + +Jeffrey Pennington, Richard Socher, and Christopher Manning. GloVe: Global vectors for word representation. In EMNLP, 2014. + +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. ICML, 2021. + +Shafin Rahman, Salman Khan, and Fatih Porikli. Zero-shot object detection: Learning to simultaneously recognize and localize novel concepts. In ACCV, 2018. + +Shafin Rahman, Salman Khan, and Nick Barnes. Transductive learning for zero-shot object detection. In ICCV, 2019. + +Shafin Rahman, Salman Khan, and Nick Barnes. Improved visual-semantic alignment for zero-shot object detection. In AAAI, 2020. + +Joseph Redmon and Ali Farhadi. Yolo9000: better, faster, stronger. In CVPR, 2017. + +Shaoqing Ren, Kaiming He, Ross B Girshick, and Jian Sun. Faster r-cnn: Towards real-time object detection with region proposal networks. In NeurIPS, 2015. +Marcus Rohrbach, Michael Stark, and Bernt Schiele. Evaluating knowledge transfer and zero-shot learning in a large-scale setting. In CVPR, 2011. +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 ICCV, 2019. +Jingru Tan, Gang Zhang, Hanming Deng, Changbao Wang, Lewei Lu, quanquan Li, and Jifeng Dai. Technical report: A good box is not a guarantee of a good mask. Joint COCO and LVIS workshop at ECCV 2020: LVIS Challenge Track, 2020. +Mingxing Tan and Quoc Le. Efficientnet: Rethinking model scaling for convolutional neural networks. In ICML, 2019. +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. +Catherine Wah, Steve Branson, Peter Welinder, Pietro Perona, and Serge Belongie. The caltech-ucsd birds-200-2011 dataset. 2011. +Xiaolong Wang, Yufei Ye, and Abhinav Gupta. Zero-shot recognition via semantic embeddings and knowledge graphs. In CVPR, 2018. +Guo-Sen Xie, Li Liu, Fan Zhu, Fang Zhao, Zheng Zhang, Yazhou Yao, Jie Qin, and Ling Shao. Region graph embedding network for zero-shot learning. In ECCV, 2020. +Keren Ye, Mingda Zhang, Adriana Kovashka, Wei Li, Danfeng Qin, and Jesse Berent. Cap2det: Learning to amplify weak caption supervision for object detection. In ICCV, 2019. +Alireza Zareian, Kevin Dela Rosa, Derek Hao Hu, and Shih-Fu Chang. Open-vocabulary object detection using captions. In CVPR, 2021. +Hang Zhao, Xavier Puig, Bolei Zhou, Sanja Fidler, and Antonio Torralba. Open vocabulary scene parsing. In ICCV, 2017. +Xiangyun Zhao, Samuel Schulter, Gaurav Sharma, Yi-Hsuan Tsai, Manmohan Chandraker, and Ying Wu. Object detection with a unified label space from multiple datasets. In ECCV, 2020. +Ye Zheng, Ruoran Huang, Chuanqi Han, Xi Huang, and Li Cui. Background learnable cascade for zero-shot object detection. In ACCV, 2020. +Xingyi Zhou, Vladlen Koltun, and Philipp Krahenb ¨ uhl. Simple multi-dataset detection. ¨ arXiv preprint arXiv:2102.13086, 2021. +Pengkai Zhu, Hanxiao Wang, and Venkatesh Saligrama. Don’t even look once: Synthesizing features for zero-shot detection. In CVPR, 2020. +Xizhou Zhu, Han Hu, Stephen Lin, and Jifeng Dai. Deformable convnets v2: More deformable, better results. In CVPR, 2019. + +# APPENDIX + +# A ADDITIONAL QUALITATIVE RESULTS + +On-the-fly interactive object detection: We tap the potential of ViLD by using arbitrary text to interactively recognize fine-grained categories and attributes. We extract the region embedding and compute its cosine similarity with a small set of on-the-fly arbitrary texts describing attributes and/or fine-grained categories; we apply softmax with temperature $\tau$ on top of the similarities. To our surprise, though never trained on fine-grained dog breeds (Fig. 5), it correctly distinguishes husky from shiba inu. It also works well on identifying object colors (Fig. 1). The results demonstrate knowledge distillation from an open-vocabulary image classification model helps ViLD to gain understanding of concepts not present in the detection training. Of course, ViLD does not work all the time, e.g., it fails to recognize poses of animals. + +![](images/7ef91dbbab058581eab347afce30b5716bc4ad3ce48dccb72abfce67ee51b06c.jpg) +Figure 5: On-the-fly interactive object detection. One application of ViLD is using on-the-fly arbitrary texts to further recognize more details of the detected objects, e.g., fine-grained categories and color attributes. + +Systematic expansion of dataset vocabulary: In addition, we propose to systematically expand the dataset vocabulary $( \mathbf { v } = \{ v _ { 1 } , . . . , v _ { p } \} )$ with a set of attributes $( \mathbf { a } = \{ a _ { 1 } , . . . , a _ { q } \} )$ as follows: + +$$ +{ \begin{array} { r l } & { \operatorname* { P r } ( v _ { i } , a _ { j } \mid \mathbf { e } _ { r } ) = \operatorname* { P r } ( v _ { i } \mid \mathbf { e } _ { r } ) \cdot \operatorname* { P r } ( a _ { j } \mid v _ { i } , \mathbf { e } _ { r } ) } \\ & { \qquad = \operatorname* { P r } ( v _ { i } \mid \mathbf { e } _ { r } ) \cdot \operatorname* { P r } ( a _ { j } \mid \mathbf { e } _ { r } ) , } \end{array} } +$$ + +where $\mathbf { e } _ { r }$ denotes the region embedding. We assume $v _ { i }$ ⊥⊥ $a _ { j } \mid \mathbf { e } _ { r }$ , i.e., given $\mathbf { e } _ { r }$ the event the object belongs to category $v _ { i }$ is conditionally independent to the event it has attribute $a _ { j }$ . + +Let $\tau$ denote the temperature used for softmax and $\tau$ denote the text encoder as in Eq. 2. Then + +$$ +\begin{array} { r } { \operatorname* { P r } ( v _ { i } \mid \mathbf { e } _ { r } ) = s o f t m a x _ { i } ( s i m ( \mathbf { e } _ { r } , { \mathcal { T } } ( \mathbf { v } ) ) / \tau ) , } \\ { \operatorname* { P r } ( a _ { j } \mid \mathbf { e } _ { r } ) = s o f t m a x _ { j } ( s i m ( \mathbf { e } _ { r } , { \mathcal { T } } ( \mathbf { a } ) ) / \tau ) . } \end{array} +$$ + +In this way, we are able to expand $p$ vocabularies into a new set of $p \times q$ vocabularies with attributes. The conditional probability approach is similar to YOLO9000 (Redmon $\&$ Farhadi, 2017). We show a qualitative example of this approach in Fig. 6, where we use a color attribute set as a. Our open-vocabulary detector successfully detects fruits with color attributes. + +We further expand the detection vocabulary to fine-grained bird categories by using all 200 species from CUB-200-2011 (Wah et al., 2011). Fig. 7 shows successful and failure examples of our openvocabulary fine-grained detection on CUB-200-2011 images. In general, our model is able to detect visually distinctive species, but fails at other ones. + +Transfer to PASCAL VOC: In Fig. 8, we show qualitative results of transferring an openvocabulary detector trained on LVIS (Gupta et al., 2019) to PASCAL VOC Detection (2007 test set) (Everingham et al., 2010), without finetuning (Sec. 4.6 in the main paper). Results demonstrate that the transferring works well. + +Failure cases: In Fig. 9, we show two failure cases of ViLD. The most common failure cases are the missed detection. A less common mistake is misclassifying the object category. + +We show a failure case of mask prediction on PASCAL VOC in Fig. 10. It seems that the mask prediction is sometimes based on low-level appearance rather than semantics. + +![](images/fae0671f0f9a2a6d923a34a785fdef4afb021db49abe249c432b8e790d4c8843.jpg) +Figure 6: Systematic expansion of dataset vocabulary with colors. We add 11 color attributes (red orange, dark orange, light orange, yellow, green, cyan, blue, purple, black, brown, white) to LVIS categories, which expand the vocabulary size by $1 1 \times$ . Above we show an example of detection results. Our open-vocabulary detector is able to assign the correct color to each fruit. A class-agnostic NMS with threshold 0.9 is applied. Each figure shows top 15 predictions. + +![](images/ab0aa787df02645e8929e08eb1cf3086ed07aeeb03ddea83a8a44cba23b3abcc.jpg) +Figure 7: Systematic expansion of dataset vocabulary with fine-grained categories. We use the systematic expansion method to detect 200 fine-grained bird species in CUB-200-2011. (a): Our open-vocabulary detector is able to perform fine-grained detection (bottom) using the detector trained on LVIS (top). (b): It fails at recognizing visually non-distinctive species. It incorrectly assigns “Western Gull” to “Horned Puffin” due to visual similarity. + +# B ANALYSIS OF CLIP ON CROPPED REGIONS + +In this section, we analyze some common failure cases of CLIP on cropped regions and discuss possible ways to mitigate these problems. + +Visual similarity: This confusion is common for any classifiers and detectors, especially on large vocabularies. In Fig. 11(a), we show two failure examples due to visual similarity. Since we only use a relatively small ViT-B/32 CLIP model, potentially we can improve the performance with a higher-capacity pretrained model. In Table 6, when replacing this CLIP model with an EfficientNetl2 ALIGN model, we see an increase on AP. + +![](images/b76fc928c57b8befef4bf1c3fef38b10ec1356f05e8d1f4fcd3d889285887f6e.jpg) +Figure 8: Transfer to PASCAL VOC. ViLD correctly detects objects when transferred to PASCAL VOC, where images usually have lower resolution than LVIS (our training set). In the third picture, our detector is able to find tiny bottles, though it fails to detect the person. + +![](images/c954eac2ba14d6d0676fa5b9adfb5a929e0fae112c526102cee9c4c7cb392527.jpg) +Figure 9: Failure cases on LVIS novel categories. The red bounding boxes indicate the groundtruths of the failed detections. (a) A common failure type where the novel objects are missing, e.g., the elevator car is not detected. (b) A less common failure where (part of) the novel objects are misclassified, e.g., half of the waffle iron is detected as a calculator due to visual similarity. + +Aspect ratio: This issue is introduced by the pre-processing of inputs in CLIP. We use the ViTB/32 CLIP with a fixed input resolution of $2 2 4 \times 2 2 4$ . It resizes the shorter edge of the image to 224, and then uses a center crop. However, since region proposals can have more extreme aspect ratios than the training images for CLIP, and some proposals are tiny, we directly resize the proposals to that resolution, which might cause some issues. For example, the thin structure in Fig. 11(b) right will be highly distorted with the pre-processing. And the oven and fridge can be confusing with the distorted aspect ratio. There might be some simple remedies for this, e.g., pasting the cropped region with original aspect ratio on a black background. We tried this simple approach with both CLIP and ALIGN. Preliminary results show that it works well on the fully convolutional ALIGN, while doesn’t work well on the transformer-based CLIP, probably because CLIP is never trained with black image patches. + +Multiple objects in a bounding box: Multiple objects in a region interfere CLIP’s classification results, see Fig. 11(c), where a corner of an aquarium dominates the prediction. This is due to CLIP pretraining, which pairs an entire image with its caption. The caption is usually about salient objects in the image. It’s hard to mitigate this issue at the open-vocabulary classification model’s end. On the other hand, a supervised detector are trained to recognize the object tightly surrounded by the bounding box. So when distilling knowledge from an open-vocabulary image classification model, keeping training a supervised detector on base categories could help, as can be seen from the improvement of ViLD over ViLD-image (Sec. 4.4). + +Confidence scores predicted by CLIP do not reflect the localization quality: For example, in Fig. 12(a), CLIP correctly classifies the object, but gives highest scores to partial detection boxes. CLIP is not trained to measure the quality of bounding boxes. Nonetheless, in object detection, it is important for the higher-quality boxes to have higher scores. In Fig. 12(c), we simply re-score by taking the geometric mean of the CLIP confidence score and the objectness score from the proposal model, which yields much better top predictions. In Fig. 12(b), we show top predictions of the Mask + +![](images/55e73fc02a3fb642133f91a74000a0d38f2a76059362427fd45a0b0197ee69d5.jpg) +Figure 10: An example of ViLD on PASCAL VOC showing a mask of poor quality. The class-agnostic mask prediction head occasionally predicts masks based on low-level appearance rather than semantics, and thus fails to obtain a complete instance mask. + +Table 6: ALIGN on cropped regions achieves superior $\mathbf { A P _ { r } }$ , and overall very good performance. It shows a stronger open-vocabulary classification model can improve detection performance by a large margin. We report box APs here. + +
MethodAPrAPcAPfAP
CLIP on cropped regions19.519.717.018.6
ALIGN on cropped regions39.632.626.331.4
+ +R-CNN model. Its top predictions have good bounding boxes, while the predicted categories are wrong. This experiment shows that it’s important to have both an open-vocabulary classification model for better recognition, as well as supervision from detection dataset for better localization. + +# C ADDITIONAL QUANTITATIVE RESULTS + +Hyperparameter sweep for visual distillation: Table 7 shows the parameter sweep of different distillation weights using $\mathcal { L } _ { 1 }$ and $\mathcal { L } _ { 2 }$ losses. Compared with no distillation, additionally learning from image embeddings generally yields better performance on novel categories. We find $\mathcal { L } _ { 1 }$ loss can better improve the $\mathsf { A P } _ { r }$ performance with the trade-off against $\mathsf { A P } _ { c }$ and $\mathsf { A P } _ { f }$ . This suggests there is a competition between ViLD-text and ViLD-image. + +Table 7: Hyperparameter sweep for visual distillation in ViLD. $\mathcal { L } _ { 1 }$ loss is better than $\mathcal { L } _ { 2 }$ loss. For $\mathcal { L } _ { 1 }$ loss, there is a trend that $\mathsf { A P } _ { r }$ increases as the weight increases, while $\operatorname { A P } _ { f , c }$ decrease. For all parameter combinations, ViLD outperforms ViLD-text on $\operatorname { A P } _ { r }$ . We use ResNet-50 backbone and shorter training iterations (84,375 iters), and report mask AP in this table. + +
Distill lossDistill weight wAPrAPcAPfAP
No distill0.010.422.931.324.0
L2loss0.513.721.731.224.0
1.012.422.731.424.3
2.013.422.030.924.0
L1 loss0.0512.922.431.724.4
0.114.020.931.223.8
0.516.319.227.321.9
1.017.318.225.120.7
+ +Box APs and ResNet-152 backbone: Table 8 shows the corresponding box AP of Table 3 in the main paper. In general, box AP is slightly higher than mask AP. In addition, we include the results of ViLD variants with the ResNet-152 backbone. The deeper backbone improves all metrics. The trend/relative performance is consistent for box and mask APs, as well as for different backbones. ViLD-ensemble achieves the best box and mask $\mathsf { A P } _ { r }$ . + +Ablation study on prompt engineering: We conduct an ablation study on prompt engineering. We compare the text embeddings ensembled over synonyms and 63 prompt templates (listed in Appendix D) with a non-ensembled version: Using the single prompt template “a photo of {article} {category}”. Table 9 illustrates that ensembling multiple prompts slightly improves the performance by $0 . 4 \mathrm { A P } _ { r }$ . + +![](images/2bbd84cf9e2060a48bc4b8fecf84a4a5a226c1aaf7facfb612624f8226168ade.jpg) +Figure 11: Typical errors of CLIP on cropped regions. (a): The prediction and the groundtruth have high visual similarity. (b): Directly resizing the cropped regions changes the aspect ratios, which may cause troubles. (c): CLIP’s predictions are sometimes affected by other objects appearing in the region, rather than predicting what the entire bounding box is. + +![](images/c41556508228c80c13d828883177c7d71b5d5a89722eaef18da674a02f939962.jpg) +Figure 12: The prediction scores of CLIP do not reflect the quality of bounding box localization. (a): Top predictions of CLIP on cropped region. Boxes of poor qualities receive high scores, though the classification is correct. (b): Top predictions of a vanilla Mask R-CNN model. Box qualities are good while the classification is wrong. (c): We take the geometric mean of CLIP classification score and objectiveness score, and use it to rescore (a). In this way, a high-quality box as well as the correct category rank first. + +Table 8: Performance of ViLD variants. This table shows additional box APs for models in Table 3 and ResNet-152 results. + +
BackboneMethodBoxMask
APrAPcAPfAPAPr APcAPfAP
ResNet-50CLIP on cropped regions19.519.717.018.618.918.816.017.7
+ViT-B/32ViLD-text+CLIP23.826.732.828.622.624.829.226.1
ResNet-50Supervised-RFS (base+novel) GloVe baseline13.0 3.226.7 22.037.428.5 23.812.3 3.024.3 20.132.4 30.425.4 21.2
34.9
ViLD-text10.626.137.427.910.123.932.524.9
ViLD-image10.311.511.111.211.211.311.111.2
ViLD (w=0.5)16.321.231.624.416.120.028.322.5
ViLD-ensemble (w=0.5)16.726.534.227.816.624.630.325.5
ResNet-152Supervised-RFS (base+novel)16.229.639.731.214.426.834.227.6
ViLD-text12.328.339.730.011.725.834.426.7
ViLD-image12.513.913.413.413.113.413.013.2
ViLD (w=1.0)19.122.431.525.418.721.128.423.6
ViLD-ensemble (w=2.0)19.827.134.528.718.724.930.626.0
EfficientNet-b7ViLD-ensemble w/ ViT-L/14 (w=1.0)22.031.538.032.421.729.133.629.6
ViLD-ensemble w/ ALIGN (w=1.0)27.029.436.531.826.327.232.929.3
+ +Table 9: Ablation study on prompt engineering. Results indicate ensembling multiple prompt templates slightly improves $\operatorname { A P } _ { r }$ . ViLD w/ multiple prompts is the same ViLD model in Table 3, and ViLD w/ single prompt only changes the text embeddings used as the classifier. + +
MethodAPrAPcAPfAP
ViLD w/ single prompt15.719.728.922.6
ViLD w/ multiple prompts16.120.028.322.5
+ +# D MORE IMPLEMENTATION DETAILS + +ViLD-ensemble architecture: In Fig. 13, we show the detailed architecture and learning objectives for ViLD-ensemble, the ensembling technique introduced in Sec. 3.4. + +Model used for qualitative results: For all qualitative results, we use a ViLD model with ResNet152 backbone, whose performance is shown in Table 8. + +Details for supervised baselines: For a fair comparison, we train the second stage box/mask prediction heads of Supervised and Supervised-RFS baselines in the class-agnostic manner introduced in Sec. 3.1. + +Details for R-CNN style experiments: We provide more details here for the R-CNN style experiments: CLIP on cropped regions in Sec. 4.2 and ViLD-text+CLIP in Sec. 4.3. 1) Generalized object proposal: We use the standard Mask R-CNN R50-FPN model. To report mask AP and compare with other methods, we treat the second-stage refined boxes as proposals and use the corresponding masks. We apply a class-agnostic NMS with 0.9 threshold, and output a maximum of 1000 proposals. The objectness score is one minus the background score. 2) Open-vocabulary classification on cropped regions: After obtaining CLIP confidence scores for the 1000 proposals, we apply a class-specific NMS with a threshold of 0.6, and output the top 300 detections as the final results. + +Additional details for ViLD variants: Different from the R-CNN style experiments, for all ViLD variants (Sec. 3.3, Sec. 3.4), we use the standard two-stage Mask R-CNN with the class-agnostic localization modules introduced in Sec. 3.1. Both the $M$ offline proposals and $N$ online proposals are obtained from the first-stage RPN (Ren et al., 2015). In general, the R-CNN style methods and ViLD variants share the same concept of class-agnostic object proposals. We use the second-stage outputs in R-CNN style experiments only because we want to obtain the Mask AP, the main metric, to compare with other methods. For ViLD variants, we remove the unnecessary complexities and show that using a simple one-stage RPN works well. + +![](images/63c5146ea253927d7b33b76f425881b87d35cd9cfdf2ae79a0b0c434f4d6533e.jpg) +Figure 13: Model architecture and training objectives for ViLD-ensemble. The learning objectives are similar to ViLD. Different from ViLD, we use two separate heads of identical architecture in order to reduce the competition between ViLD-text and ViLD-image objetvies. During inference, the results from the two heads are ensembled as described in Sec. 3.4. Please refer to Fig. 3 for comparison with other ViLD variants. + +Architecture for open-vocabulary image classification models: Popular open-vocabulary image classification models (Radford et al., 2021; Jia et al., 2021) perform contrastive pre-training on a large number of image-text pairs. Given a batch of paired images and texts, the model learns to maximize the cosine similarity between the embeddings of the corresponding image and text pairs, while minimizing the cosine similarity between other pairs. Specifically, for CLIP (Radford et al., 2021), we use the version where the image encoder adopts the Vision Transformer (Dosovitskiy et al., 2020) architecture and the text encoder is a Transformer (Vaswani et al., 2017). For ALIGN (Jia et al., 2021), its image encoder is an EfficientNet (Tan & Le, 2019) and its text encoder is a BERT (Devlin et al., 2019). + +Details for ViLD with stronger teacher models: In both experiments with CLIP ViT-L/14 and ALIGN, we use EfficientNet-b7 as the backbone and ViLD-ensemble for better performance. We also crop the RoI features from only FPN level $P _ { 3 }$ in the feature pyramid. The large-scale jittering range is reduced to [0.5, 2.0]. For CLIP ViT-L/14, since its image/text embeddings have 768 dimensions, we increase the FC dimension of the Faster R-CNN heads to 1,024, and the FPN dimension to 512. For ViLD w/ ALIGN, we use the ALIGN model with an EfficientNet-l2 image encoder and a BERT-large text encoder as the teacher model. We modify several places in the Mask RCNN architecture to better distill the knowledge from the teacher. We equip the ViLD-image head in ViLD-ensemble with the MBConvBlocks in EfficientNet. Since the MBConvBlocks are fullyconvolutional, we apply a global average pooling to obtain the image embeddings, following the teacher. The ViLD-text head keeps the same Faster R-CNN head architecture as in Mask R-CNN. Since ALIGN image/text embeddings have 1,376 dimensions ( $2 . 7 \times$ CLIP embedding dimension), we increase the number of units in the fully connected layers of the ViLD-text head to 2,048, and the FPN dimension to 1,024. + +Text prompts: Since the open-vocabulary classification model is trained on full sentences, we feed the category names into a prompt template first, and use an ensemble of various prompts. Following Radford et al. (2021), we curate a list of 63 prompt templates. We specially include several prompts containing the phrase “in the scene” to better suit object detection, e.g., “There is {article} {category} in the scene”. + +Our list of prompt templates is shown below: + +’There is {article} {category} in the scene.’ ’There is the {category} in the scene.’ ’a photo of {article} {category} in the scene.’ ’a photo of the {category} in the scene.’ ’a photo of one {category} in the scene.’ ’itap of {article} {category}.’ + +’itap of my {category}.’ +’itap of the {category}.’ +’a photo of {article} {category}.’ +’a photo of my {category}.’ +’a photo of the {category}.’ +’a photo of one {category}.’ +’a photo of many {category}.’ +’a good photo of {article} {category}.’ +’a good photo of the {category}.’ +’a bad photo of {article} {category}.’ +’a bad photo of the {category}.’ +’a photo of a nice {category}.’ +’a photo of the nice {category}.’ +’a photo of a cool {category}.’ +’a photo of the cool {category}.’ +’a photo of a weird {category}.’ +’a photo of the weird {category}.’ +’a photo of a small {category}.’ +’a photo of the small {category}.’ +’a photo of a large {category}.’ +’a photo of the large {category}.’ +’a photo of a clean {category}.’ +’a photo of the clean {category}.’ +’a photo of a dirty {category}.’ +’a photo of the dirty {category}.’ +’a bright photo of {article} {category}.’ +’a bright photo of the {category}.’ +’a dark photo of {article} {category}.’ +’a dark photo of the {category}.’ +’a photo of a hard to see {category}.’ +’a photo of the hard to see {category}.’ +’a low resolution photo of {article} {category}.’ +’a low resolution photo of the {category}.’ +’a cropped photo of {article} {category}.’ +’a cropped photo of the {category}.’ +’a close-up photo of {article} {category}.’ +’a close-up photo of the {category}.’ +’a jpeg corrupted photo of {article} {category}.’ +’a jpeg corrupted photo of the {category}.’ +’a blurry photo of {article} {category}.’ +’a blurry photo of the {category}.’ +’a pixelated photo of {article} {category}.’ +’a pixelated photo of the {category}.’ +’a black and white photo of the {category}.’ +’a black and white photo of {article} {category}.’ +’a plastic {category}.’ +’the plastic {category}.’ +’a toy {category}.’ +’the toy {category}.’ +’a plushie {category}.’ +’the plushie {category}.’ +’a cartoon {category}.’ +’the cartoon {category}.’ +’an embroidered {category}.’ +’the embroidered {category}.’ +’a painting of the {category}.’ +’a painting of a {category}.’ \ No newline at end of file diff --git a/md/dev/lSZXSDwvGv/lSZXSDwvGv.md b/md/dev/lSZXSDwvGv/lSZXSDwvGv.md new file mode 100644 index 0000000000000000000000000000000000000000..cf96ee95e1aba63bd6a7d96a0300b5e1f9038db8 --- /dev/null +++ b/md/dev/lSZXSDwvGv/lSZXSDwvGv.md @@ -0,0 +1,379 @@ +# Improving Language Model Negotiation with Self-Play and In-Context Learning from AI Feedback + +Anonymous Author(s) +Affiliation +Address +email + +# Abstract + +1 We study whether multiple large language models (LLMs) can autonomously +2 improve each other in a negotiation game by playing, reflecting, and criticizing. +3 We are interested in this question because if LLMs were able to improve each other, +4 it would imply the possibility of creating strong AI agents with minimal human +5 intervention. We ask two LLMs to bargain with each other, playing the roles of a +6 buyer and a seller, respectively. They aim to reach a deal with the buyer targeting +7 a lower price and the seller a higher one. A third language model, playing the +8 critic, provides feedback to a player to improve the player’s negotiation strategies. +9 We let the two agents play multiple rounds, using previous negotiation history +10 and AI feedback as in-context demonstrations to improve the model’s negotiation +11 strategy iteratively. We use different LLMs (GPT and Claude) for different roles +12 and use the deal price as the evaluation metric. Our experiments reveal multiple +13 intriguing findings: (1) Only a subset of the language models we consider can +14 self-play and improve the deal price from AI feedback, weaker models either do +15 not understand the game’s rules or cannot incorporate AI feedback for further +16 improvement. (2) Models’ abilities to learn from the feedback differ when playing +17 different roles. For example, it is harder for Claude-instant to improve as the +18 buyer than as the seller. (3) When unrolling the game to multiple rounds, stronger +19 agents can consistently improve their performance by meaningfully using previous +20 experiences and iterative AI feedback, yet have a higher risk of breaking the +21 deal. We hope our work provides insightful initial explorations of having models +22 autonomously improve each other with game playing and AI feedback. + +# 23 1 Introduction + +24 We study whether multiple Large Language Models (LLMs) can improve each other in a negotiation +25 game with minimal human intervention, in the fashion of AlphaGo Zero [31] where AI agents improve +26 themselves by continuously playing competitive games under well-defined rules. The answers to this +27 research question have profound implications. On the positive side, if the agents were able to improve +28 autonomously, strong agents might be created with very few human annotations, which greatly saves +29 the cost compared to today’s data-hungry LLM training [8, 17]. On the risky side, it also implies +30 strong agents with limited human oversight [4]. In this work, we ask two language models (a seller +31 and a buyer) to bargain about a product. The seller is asked to sell the product at a higher price, while +32 the buyer aims to purchase it at a lower price (Fig. 1A). After reaching a deal, we ask a third language +33 model to play as the critic and give feedback to a player. Then we play the game again, asking the +34 player to improve their strategy using AI feedback provided by the critic LLM. +35 We choose the bargaining game because it comes with well-defined rules described in text, and a +36 clear and measurable objective (a lower/ higher deal price) for strategic negotiation. Although the + +A. We ask two agents to play a negotiation game and have an AI critic to give suggestions to one of the player to improve its negotiation strategy. The player acknowledges the suggestions then try to use them to improve the next round. + +![](images/27dc1418774e983a9a8fcfa6642b061c9bda3e67a66692b54f41cb68f00f9587.jpg) +Round 1. A seller and a buyer bargain about a product. +Round 2. Seller improves bargaining strategy based on AI feedback + +AI feedback: a critic reads the dialog history and give suggestions for improvements + +B. Example feedback from AI critic and how a GPT-4 player improves from it. + +Buyer Critic: Employ the " inch" technique: when the seller offers a counteroffer, the buyer should display a degree of surprise or disappointment + +# Seller Critic: + +Buyer Critic: +Use the power of silence: The buyer can employ the power of silence in the negotiation process by pausing longer before responding to the seller's offer. Seller Critic: +Utilize split-the-difference: In +situations where a small price +difference remains, propose to split the difference with the buyer. +Context: + +Use anchoring technique: Begin by emphasizing the high starting price and then offer a slightly lower price + +# Buyer’s Improvement: + +Oh! That's higher than I expected. I saw a similar balloon at another store for $\$ 14$ Can you match that price? + +# Buyer’s Improvement: + +\*pause\* ... Alright, I'll take the balloon for $\$ 13$ . + +Buyer proposes $\$ 15,$ , seller calls $\$ 18$ Seller’s Improvement: I understand, how about we split the difference and make it $\$ 16.75$ to accommodate your budget? B3. Split-the-di erence + +# Seller’s Improvement: + +This high-quality, long-lasting balloon is really worth $\$ 25,$ , but I'm offering it for $\$ 20$ . + +B1. The “ inch” technique B2. The power of silence + +B4. The anchoring technique + +![](images/b7f3875345786004bbd70ac9f03bed3ea82a790ad3dc86ea0bcf131c5e52b1d0.jpg) +C. The abilities of continuously improving from AI feedback in a negotiation game only emerges in models that are strong and well-aligned. Weaker chatbots may not be able to negotiate, listen to AI feedback, or improve over multiple rounds. +Figure 1: Settings of our negotiation game. A. We ask two LLM agents to play a bargaining game as the seller and the buyer. Their goals are to sell/ buy the product at a higher/ lower price. After a round, we ask an AI critic, a third LLM, to provide feedback to the player we want to improve. Then we ask the player to improve their negotiation strategies based on the feedback. We repeat this process for multiple rounds and study if models can continuously improve. See Fig. 2 for an example run. B. Bargaining techniques that we observed from the AI Critic and how the player incorporates these techniques into the negotiation strategy. C. Abilities that are required in our game (C2 - negotiation, C3 - AI feedback, and C4 - continuous improvements) classify models into different tiers. We find out that only strong and well-aligned models (like gpt-4 and claude-v1.3) can continuously improve from iterative AI feedback (see Fig. 3 for example models that do not exhibit these abilities). + +37 game seems easy at first glance, it requires non-trivial capabilities of the language models, as the +38 model needs to: (1) clearly understand and strictly follow the textual rules of the negotiation game +39 (2) correspond to the textual feedback provided by the critic LM and improve based on it iteratively +40 (see example feedback in Fig 1B); (3) reflect upon the strategy and feedback over the long term +41 and improve over multiple rounds. We will see that not all models we considered show all these +42 abilities (Fig. 1C), and only models that can (1) understand negotiation rules and strategies (capable) +43 and (2) respond to AI instructions (well-aligned) can continuously improve from AI feedback over +44 multiple rounds (in our experiments, only gpt-3.5-turbo, gpt-4, and claude-v1.3) meet these +45 requirements). We have also tried more complicated textual games including board games and textual +46 RPG games in the preliminary experiments, but they are more challenging for current agents to +47 understand and follow the rules. +48 We call our approach In-Context Learning from AI Feedback (ICL-AIF). Specifically, we use the +49 feedback from the AI critic as well as the previous rounds of dialog history as in-context demonstra +50 tions [5]. By doing this, the critic’s suggestions for improvements and the player’s actual improvement +51 in the previous rounds effectively become the few-shot prompts for the next round of negotiation. +52 We use in-context learning for two reasons: (1) tuning large language models with reinforcement +53 learning is prohibitively expensive [25, 15] and the base model [24] may not be accessible to a wide +54 range of the community; (2) in-context learning is recently shown to be closely related to gradient +55 descent [11, 1, 32], such that the conclusions we draw is fairly likely to generalize when one actually +56 finetunes the model (if resources permit). One notable difference between our ICL-AIF and the +57 mainstream Reinforcement Learning from Human Feedback (RLHF) is that in RL the reward is a + +
Claude-instant-v1.0 v.s. GPT-3.5-Turbo 2023-05-10Al Feedback to sellerRound 2, After Al Feedback
Round 1, before Al FeedbackClaude-ins-l.0 | Seller Critic I.Focus on the qualities and benefitsClaude-ins-l.0 | SellerHi,this is a good balloon and its price is $20
Claude-ins-l.0 | Seller Hi,this is a good balloon and its price is $20of the balloon, not just the price. Highlight how rare and special it is.Claude-in-l.0 |SellerGPT-3.5-T| BuyerWould you consider selling it for $10? No,$l0 is much too low.This balloon is
GPT-3.5-T|Buyer Would you consider seling it for $10?2. Build rapport and connection withmade of high quality latex and handcrafted by expert artisans.It's
Claude-ins-l.0 | Seller No,that price is too low.the buyer to make them feel like they are gettinga good deal froma trustedGPT-3.5-T | Buyerunique one-of-a-kind piece. What would be the lowest price you
GPT-3.5-T| Buyer What about $15?seller. 3.Be willing to walk away if needed.could offer me for this balloon?
Claude-ins-l.O | Seller $15 is better,but still not enough.Let the buyer know you have other interested buyers,so they realize theClaude-ins-l.0 |SellerWell, because Itrust you and value your business,l will offer you this special
GPT-3.5-T | Buyer What is the lowest price you can offer?value in meeting your price.balloon at $I7.This price is only available to valued customers like
Claude-ins-l.O | Seller My lowest price is $18.Claude-ins-l.0 | Seller Sure,l will try to improve myGPT-3.5-T| Buyeryourself today. Can you give me a better deal,like $15?
GPT-3.5-T | Buyer Iunderstand.Could you do $16? That's the highest l can go.negotiation strategy based on the feedback from the critic.Claude-ins-l.0 | Seller Iapologize,but $I5 does not even cover my costs.I have to charge at least $17 for this unique,high-quality balloon.
Claude-ins-I.0 | Seller $16 will work for today.Congratulations,you gota good deal!And l will try to sell it at a higher price (higher than $16.O) than the previous round.GPT-3.5-T | BuyerAlright,you've got a deal.I will take the
A. Round 1, before Al feedback to seller, theB.Al critic give feedbacks to the seller based onspecial balloon for $17. strategy based on the feedback, final price $17.
bargaining process is relatively simple, final price $16.the previous round, then seller acknowledge.C. Round 2,seller improves the reasoning
+ +Figure 2: An example of playing the negotiation game and then improving from AI feedback. A: claude-instant-v1.0 plays the seller and gpt-3.5-turbo the buyer, bargaining about a balloon. B: then we use a claude-instant-v1.0 critic to provide feedback. C: upon receiving the feedback, the seller improves its strategy based on the suggestions. Note that colored phrases like “high quality latex and handcrafted by expert artisans” correspond to previous AI feedback “how rare and special it is”. We measure the final price as the proxy of the effectiveness of the strategy because the overall goal is to get a better price. In this case, it improves from $\$ 16$ to $\$ 17$ . + +58 scalar [25, 15] while in ICL the feedback is in natural language. We study AI feedback (rather than +59 rely on human intervention after each round) because it is more scalable and can allow models to +60 self-improve automatically. +61 Our experiments lead to several intriguing findings: (1) The requirements of our bargaining game +62 effectively serve as a testbed for assessing the abilities of LLMs (Fig. 1C): although most models can +63 do chitchat in a casual scenario, as of our experiment date (May 2023), cohere-command [10] model +64 does not understand the rule of bargaining (Fig. 3A), ai21-jurassic [18] model does not respond +65 to AI feedback (Fig. 3B), claude-instant-v1.0 can at most improve one round (Fig. 5), and only +66 gpt-3.5-turbo, gpt-4, and claude-v1.3 can continuously improve over multiple rounds. (2) +67 Models behave differently upon receiving feedback when playing different roles. Models playing the +68 buyer role may be harder to improve than when in the seller role (Fig. 4). (3) It is indeed possible +69 for strong agents like gpt-4 to continuously improve meaningfully using previous experiences and +70 online iterative AI feedback, yet the attempt to sell at a higher price (or buy at a lower price) comes +71 with the risk of failing to reach a deal at all (Fig. 6). We further show evidence of the model being +72 able to negotiation in a less verbose but more strategic (thus more effective) way (Fig. 7). Overall, +73 we hope our work serves as a meaningful initiative for improving language models’ negotiation in a +74 game setting using AI feedback. + +# 75 2 Problem Setting + +76 Our goal is to study whether LLMs can improve each other by playing a negotiation game and +77 incorporating AI feedback, as shown in Fig. 1A. We set the product being bargained as a balloon (and +78 our results hold when changing the balloon to other items). We use different combinations of backend +79 LLM engines: cohere-command [10], AI21’s jurassic-2 [18], OpenAI’s gpt-3.5-turbo and +80 gpt-4 [24], Anthropic’s claude-instant-v1.0 (which supposedly matches gpt-3.5-turbo [14]) +81 and claude-v1.3 (which is supposed to be slightly worse but close to gpt-4 [14]). throughout our +82 experiments, we provide feedback to improve only one of the two players, while its rival receives no +83 feedback, clears the negotiation history of previous rounds, and restarts. We vary the engines for the +84 model being improved while fixing its rival’s engine to be gpt-3.5-turbo. Essentially, our game +85 is gpt-3.5-turbo vs. all other engines. We keep the LM engine behind the critic is always the +86 same as the player it provides feedback to. One example setting is a gpt-4 seller playing against a +87 gpt-3.5-turbo buyer, with a gpt-4 critic. After one round, the gpt-4 critic provides feedback to +88 the gpt-4 seller such that the seller can improve in the next round while its rival gpt-3.5-turbo +89 buyer clears its dialog history and restarts. +90 Process of the Game Before the game begins, the rules of the negotiation game are explained +91 to the models through textual instructions with the objective of selling/ buying at a higher/ lower +92 price. We set the deal price to $[ \mathbb { S } 1 0 , \mathbb { S } 2 0 ]$ for easier evaluation, since other the deal price may vary +93 in a wide range according to the observations from our preliminary experiments. To achieve this, +94 we hard code the seller to kick off the negotiation with “This is a good balloon and its price is $\$ 20$ .” +95 Similarly, the buyer always opens with “Would you consider selling it for $\$ 10?$ When both players +96 strictly follow the game rules, the deal price would be between $\$ 10$ and $\$ 20$ . We let the models play +97 multiple runs and measure the average deal price before and after AI feedback. During the game, the +98 seller’s output is used to prompt the buyer and vice versa, conditioning on the entire conversation +99 history. This process is repeated till a terminal state is reached. Fig. 2A shows an example round. We +100 define three game states: (1) ON-GOING: the negotiation between the two players is still ongoing; +101 (2) DEAL: the negotiation has concluded and the two players have reached a deal; (3) NO DEAL: the +102 players cannot agree on a price and have failed to reach a deal. To track the game states, we set an +103 additional moderator (powered by a fourth LLM, in our case, gpt-3.5-turbo) to read the current +104 dialog and classify the states (we will discuss more details about the moderator later). We measure +105 the performance of the players based on the final deal price. +106 Critic A round is finished when the negotiation reaches a terminating state, either a DEAL or +107 NO DEAL. After each round, the critic LM is asked to provide constructive feedback to the player we +108 aim to improve. This player’s dialog history from all past rounds and all feedback it has received are +109 used to prompt the critic LM (Fig. 2B). The critic model is instructed to provide three suggestions to +110 the player, in order to improve its negotiation strategies to achieve a more favorable price in the next +111 game. Before the next round, the player being improved receives the critic’s feedback as a textual +112 prompt, while its rival clears its negotiation history and restarts. +113 The Moderator The game state is classified by prompting a gpt-3.5-turbo moderator using +114 few-shot demonstrations. The moderator reads the most recent four rounds (as well as in-context +115 examples of different dialog states) and determines the state of the negotiation. Empirically, we found +116 that four rounds of conversations are sufficient for the moderator to determine the negotiation state. +117 One key challenge here is detecting no-deals as the model seems to be better at recognizing DEAL +118 than NO DEAL. We mitigate this issue by playing multiple runs, inspect failure cases manually, +119 and add them to the prompt with corrected labels. We find this method an effective side product +120 recommend it as a technique for prompt optimization for generic classification tasks. +121 Playing for Multiple Rounds Finally, we would like to explore whether the players can continu +122 ously improve from AI feedback in a game over multiple rounds. Intuitively, the more rounds the +123 players play, the more challenging to keep improving because the (already improved) price from the +124 previous round becomes the baseline for the next round. In the experiments, we will show that only +125 gpt-4 can improve over 5 rounds while other models’ improvements may saturate at about 3 rounds. + +# 126 3 Related Work + +127 Game Playing and AlphaGo Zero Our setting is strongly inspired by AlphaGo Zero [31] where +128 two agents play the game of Go and improve each other with minimal human intervention. Here we +129 would like to explore its counterpart in natural language. Our work is similar to AlphaGo Zero in the +130 sense that we also have AI agents (large language models) playing competitive games (bargaining) +131 and try to improve with little human supervision. Yet there is an important difference between our +132 work and AlphaGo Zero: we have a third agent, the critic, to give feedback helping its player to +133 improve. This is a cooperative relationship that does not exist in AlphaGo Zero. On the NLP side, the +134 closest related work is Lewis et al. [19] where they have (small) RNN [9] language models to bargain, +135 and our work can be viewed as a more developed version of them since we change the engine to +136 be large language models. In general, our work is broadly under the area of AI negotiation [6, 6], +137 strategic reasoning [12], and general game playing [30]. +138 Large Language Models as Generative Agents Large language models have demonstrated +139 incredible multi-dimensional capabilities [33, 24], especially in complex reasoning [34, 28, 13] and +140 multi-round dialog [15, 2, 3], which serve as the foundation of this work. Our work is related to +141 concurrent works like Generative Agents [26] and CAMEL [20] as they also study the behavior of +142 LLMs in a multi-agent game setting. The core difference between our work and theirs is that we +143 have a clear objective (the deal price) for the model to improve through competition and cooperation, +144 while their work studies the generic social behavior of LLMs. + +![](images/8880deffe714b9c5999e06934839ae2abac4f4dd9a71f583ce532549c50d3b72.jpg) +Figure 3: Not all models can play bargaining. A. As of May 2023, the cohere model does not understand the rule of bargaining and agrees on irrational prices. B. The AI21 Jurrasic-2 model, although understanding the rule of bargaining, does not incorporate the feedback from the critic. Since these models are consistently being updated, we include the timestamp and note future versions may have improved performance. + +Learning from AI Feedback Our method is also strongly inspired by constitutional AI [3] as we both use AI feedback, while the difference is that our feedback is directly in natural language (not a scalar from a reward model). There are also related/ concurrent works demonstrating the effectiveness of natural language feedback [29, 27, 22] and self-refinement [7, 23]. Our work further confirms the effectiveness of AI feedback in the strategic negotiation game setting. + +# 150 4 Experiments + +151 In our experiments, we consider three stages that gradually deepen our exploration of learning from +152 AI feedback: (1) We first set up the basics of the game (Sec. 4.2), showing that only a few models can +153 improve from AI critics, in which case AI feedback can be comparable (but more scalable) as human +154 feedback. Other models either do not understand/ follow the rule of bargaining, or cannot incorporate +155 AI feedback for improvements. (2) Then we study the models’ behaviors when playing different roles +156 (Sec. 4.3). We discover the intriguing result that buyers are in general harder to improve than sellers. +157 (3) Finally, we study whether models can continuously improve over multiple rounds (Sec. 4.4), and +158 show a tradeoff of deal price versus success rate: although some models can continuously improve +159 the deal price, it comes with a higher risk of breaking a deal. We further show evidence of negotiation +160 in a more strategic way: both gpt-4 and claude-v1.3’s responses become longer after multiple +161 rounds of AI feedback (note that verbosity is a straightforward negotiation strategy), yet gpt-4 is less +162 verbose than claude-v1.3 but achieves higher deal price and deal rate, meaning that its responses, +163 although using fewer words, are more strategic and effective. + +# 164 4.1 Experiment Setup + +165 Model Engines The minimum requirement for models to enter our game is that they should be a +166 chatbot. All models we consider (cohere-command, AI21’s jurassic-2, OpenAI’s gpt and An +167 thropic’s claude) can be accessed by API calls. Amoung them, $\tt g p t { - } 4$ is the most expensive one and +168 running 500 rounds of negotiation costs about $\$ 120$ and gpt-3.5-turbo costs about $\$ 10$ . Other mod +169 els are beta testing (as of May 2023) and do not charge money. For reference, the approximate rank +170 of these models, from benchmarks like chain-of-thought hub [14] and HeLM [21], is that gpt-4 and +171 claude-v1.3 are approximately similar, better than gpt-3.5-turbo and claude-instant-v1.0, +172 and better than cohere-command and $j 2 – j$ umbo-instruct. We will consider more models in the +173 future, such as Google’s PaLM-2 [16]. +174 We let all models compete with gpt-3.5-turbo, effectively making it a baseline for all other models. +175 We will show that, aligning with other concurrent model rankings [14, 21], gpt-3.5-turbo is a +176 middle-level powerful engine (worse than gpt-4, better than claude-instant-v1.0). For a given +177 model engine (say claude-v1.3), we run it as the seller (with gpt-3.5-turbo as the buyer) and +178 as a buyer (with gpt-3.5-turbo now as the seller) We first let the models to play one round and +179 manually inspect if they understand the rules of bargaining. If they do, we let them play two rounds +180 to see if they could respond to AI feedback. For the critic model, we set its engine the same as its +181 player. We repeat the game 500 times to compute the average deal price before and after AI feedback. +182 If they do improve one round, we let them play multiple rounds and see if they could continuously +183 improve their strategy. We repeat the game 200 times with 5 max rounds to compute the average +184 deal price for each round. When decoding from the model engines, we use sampling with default +185 temperature (1.0 for gpt and claude, 0.75 for cohere and 0.7 for ${ \mathrm { j } } 2$ ). +186 Prompt Engineering In this work, we only had to manually optimize the prompts for the +187 moderator because the player may reach/ break a deal with very diverse expressions, and we would +188 like to make sure the moderator correctly recognizes all of them. As mentioned above, we identify the +189 errors made by the moderator in identifying deals and keep adding them as in-context demonstrations +190 until the model reaches a sufficiently high accuracy (about $9 0 +$ by manual inspection). For the players +191 and the critic, we do not do prompt engineering and keep the instructions the same for all engines (but +192 the format may be different, e.g., claude requires two linebreaks before “HUMAN:” and ${ \dot { \mathsf { J } } } ^ { 2 }$ requires +193 two “##” after each dialog round). Code and Prompts will be released publicly on publication. + +Table 1: Seller performance using AI feedback vs. randomly selected human feedback from a pre-defined pool. Recall that the buyer is fixed to be gpt-3.5-turbo and has no access to previous rounds. AI’s feedback is comparable to human’s, but is more scalable, as the two both induce similar price increases. + +
GPT-3.5-TurboClaude-instant-v1.0Claude-v1.3
Before feedback16.2614.7415.40
Random sampled human feedback16.83 (+0.57)16.33 (+1.59)16.89 (+1.49)
AI feedback17.03 (+0.77)15.98 (+1.24)16.98 (+1.58)
+ +# 194 4.2 Basic Experiments + +195 In this section, we first study the minimal requirements for models to participle in our game, namely +196 (1) understanding the rule of bargaining and (2) responding to AI feedback. Then we consider basic +197 comparison between AI and human feedback, showing that AI feedback can be comparable to human +198 feedback, but more scalable. + +Conversational ability does not guarantee ability to negotiate or learning from feedback We study whether conversational models can understand the rule of bargaining by manually checking traces of the dialog, and found that cohere-command fails to understand the rules, as is shown in Fig 3A. We observe that it does not realize what price is a better deal. For example, when playing seller, it rejects a proposal of $\$ 10$ but accepts $\$ 8$ . We also observe that AI21’s j2-jumbo-instruct model, although understanding the rule of bargaining, cannot incorporate AI feedback, as is shown in Fig. 3B. Generally, when instructed with AI feedback, the model keeps the same strategy as before, without any improvements. + +207 After ruling out the cohere-command and $j 2 – j$ umbo-instruct models, we consider the three +208 remaining models: gpt-3.5-turbo, claude-instant-v1.0 and claude-v1.3. For these three +209 engines, we do not observe the problems in Fig. 3. This means that these models can be used for our +210 multi-round games. +211 AI Feedback can be comparable to human feedback Now we consider some initial comparison +212 between AI and human feedback. We emphasize that our goal is not to show which one is better – +213 a similar level of effectiveness would suffice our study (to see if LLMs can continuously improve +214 through self-play and AI feedback). For the human feedback, we manually write done a pool of 10 +215 suggestions. Then we play 500 runs of the game, computing the deal price before and after feedback. +216 After 500 runs, we compare the improvements after: (1) randomly sampling 3 suggestions from +217 the predefined pool and (2) asking the AI critic to write down 3 suggestions. We note that this may +218 underestimate the performance of human feedback, yet it would be unpractical to ask human to write +219 done 3 suggestions for all 1500 runs (while AI feedback does not have this problem). The results +220 are shown in Table 1 where we see that all three models (gpt-3.5-turbo, claude-instant-v1.0 +221 and claude-v1.3) exhibit comparable improvements over human and AI feedback. + +![](images/9c1394265deb56b69973fa6f3a92882162c595eb32fb21dd52dc6953ca20eb13.jpg) +Figure 4: Binned deal price frequencies of 500 games, before v.s. after feedback. Effective feedback should move the distribution towards a lower/ higher price range. $\mathbf { X }$ -axis: intervals of deals from $\$ 10$ (buyers’ initial price) to $\$ 20$ (sellers’ asking price). Y-axis: the frequency of the price. A and B: for weaker agents like claude-instant-v1.0 and gpt-3.5-turbo, improving from AI feedback as the seller is easier than as buyer. For sellers, AI feedback moves the deal distribution to a higher range (rightward), but does not move buyers’ deal distribution much. Consequently, the change in average deal price when playing as buyers (-0.2 and -0.5) is clearly smaller than those as sellers $( + 1 . 0$ and $+ 1 . 7$ ) C. Stronger agents (claude-v1. $\cdot 3 / \mathrm { \ g p t } \mathrm { - } 4 )$ ), can still improve from AI feedback even as buyers, with larger changes in average deal price (-1.2 and -3.0). + +# 222 4.3 Behaviors of Different LLM Backend + +So far we have established that our game setting is valid for stronger LLM engines. Now we consider the detailed behavior comparisons using different engines for different roles. Specifically, we use claude-instant-v1.0, claude-v1.3, gpt-3.5-turbo, and gpt-4 to play the seller/ buyer (against a gpt-3.5-turbo buyer/ seller respectively), then study the deal price distribution before/ after AI feedback (also recall that the AI critic is powered by the same engine as its player). The results are visualized in Fig. 4. When claude-instant-v1.0 and gpt-3.5-turbo play the seller, they are able to improve their average deal price after AI feedback (Fig. 4A). But when they play the buyer role, their average deal price does not improve, which indicates that buyers tend to be a harder role than sellers (Fig. 4B). Yet this observation does not hold for engines like gpt-4 and claude-v1.3, as they can still improve from AI feedback even playing buyers. Overall, this set of experiments reveal the nuanced capability differences between the four engines we consider. + +# 4.4 Towards Continuous Improvements from Iterative AI Feedback + +Now we unroll the game to multiple rounds and see if models can continuously improve from previous dialog history and iterative AI feedback. Specifically, we let gpt-3.5-turbo, gpt-4, claude-instant-v1.0, and claude-v1.3 play as the seller/ buyer respectively against a rival powered by gpt-3.5-turbo. As mentioned before, the critic shares the same engine as the player it + +![](images/05a73637b24024eade68dd2e6bd42f19697249f10bb1c6c2050f048cda745de2.jpg) +Figure 5: In the multi-round setting, different engines have different behavior when playing seller/ buyer. Line plots are the average price over 200 runs and bar plots represent the price distribution. A1 v.s. B1. When playing sellers, gpt-3.5-turbo can improve from AI feedback in multiple rounds, while claude-instant-v1.0 only improves the first round. A2 v.s. B2. When playing buyers, $\tt { g p t - 3 . 5 } .$ -turbo can improve in multiple rounds, whild claude-instant-v1.0 cannot. + +39 helps with. We play 200 runs of the game, and unroll each game to be 5 rounds. We compute the +240 final deal price and the deal success rate and see if the price can be continuously improved. + +Fig. 5 shows gpt-3.5-turbo and claude-instant-v1.0 playing different roles. For a given engine, improvements over one round may not necessarily extrapolate to multiple rounds, as we observe that gpt-3.5-turbo can improve over multiple rounds, but claude-instant-v1.0 only improves at most one round. + +Now we consider the tradeoff between the tendency of achieving a higher deal price versus the rick of breaking a deal, as is shown in Fig 6. We see that when playing sellers, all four model engines can improve over at least one round, but this comes at the cost of decreasing deal success ratio. When playing buyers, there are models that cannot improve (claude-instant-v1.0), or saturate over 3 rounds (claude-v1.3), while gpt-4 and gpt-3.5-turbo can continuously improve, and gpt-4 achieves better (lower) deal price and higher deal rate than gpt-3.5-turbo. + +Finally, we study how iterative AI feedback influences the language complexity used by the agents by plotting the average response length (measured in number of characters) after each round, as is shown in Fig. 7. We see that both claude-v1.3 and gpt-4 become more verbose after iterative AI feedback with a continuously increasing response length. This is intuitive because being verbosity is a straightforward strategy in negotiation. Yet for claude-v1.3, the verbosity does not translate to better negotiation strategy, as its improvement saturates after three rounds (Fig. 6B1). In comparison, gpt-4’s increase verbosity is more strategic, as it use less words than claude-v1.3, but achieves better deal price and deal success rate (Fig. 6B). This observation serve as strong evidence that AI feedback improves players’ response towards a word-tuned, strategic direction. + +# 5 Conclusions + +In this work, we study whether multiple large language models can autonomously improve each other in a negotiation game by role-playing and learning from AI feedback. Our experiments show that certain models can indeed improve by continuously playing competition games with iterative AI feedback, under well-defined rules in an AlphaGo Zero fashion. We also show the tradeoff between next-round price improvement and success rate, as a better deal price also comes with a higher risk + +![](images/1a10ecef7da24a8a48ceff579b4c8948bb2aa05a0d1e8ca14dccd6abf23d99ae.jpg) +B1. When playing buyer, GPT models are better at improving from AI feedback than Claude models. + +![](images/8d06877e1e3f94397ddff6a61bb9aa1f15e8ed6b31c194ac66b196ae460126cd.jpg) +B2. The deal success ratio continues to decrease, but overall higher (mostly $50 \%$ ) than criticizing sellers. + +![](images/5af227544cd9fcbffb39b733208dfac970227c8dcafa35a6331f1603daea64e2.jpg) +Figure 6: Performance of GPT and Claude models in multi-round games and their success rate of getting a deal. A1 and A2: when playing the seller, most models can improve over multiple rounds. Yet higher prices also mean that it is more likely the seller may break the deal, as shown in the continuously decreasing curve of A2. B1 and B2: when playing buyer, claude-instant-v1.0 cannot improve over multiple rounds while others can. Again, a better buying price also comes with a higher chance of running away from a deal. We see that GPT-4 achieves the best trade-off here: it gets the best price over multiple rounds with a higher success rate of reaching a deal. +Figure 7: The average response length increases as the model learns from multiple rounds. Here we show examples of the seller’s response when being asked the buyer’s initial query “Would you consider selling it for $\$ 10?$ After multiple rounds of negotiation, the seller’s responses become more verbose and word-tuned. Yet verbosity does not mean better strategy: claude-v1.3 is more verbose (higher curve) than gpt-4, but it has a worse success rate and deal price (recall Fig. 6). This indicates that $\mathtt { g p t - 4 }$ ’s verbosity is more strategic. + +266 of deal breaking. This suggests future research may consider global optimization for improving the +267 overall gain over multiple rounds. We further show evidence of improved language from iterative +268 AI feedback: in a multi-round game, one model may be less verbose than another, but be better +269 word-tuned, thus more effective in getting a better deal. +270 We believe our results have profound implications for AI research: on the positive side, it indicates +271 the possibility of continuously improving language models with minimal human intervention. On +272 the risky side, it might be more challenging to oversight the model behavior in our framework +273 because models are acting autonomously, which calls for future alignment and safety research in the +274 multi-agent game setting. Overall, we believe our work provides a meaningful initial exploration for +275 large language models’ learning from game-playing and iterative AI feedback. + +References [1] Ekin Akyürek, Dale Schuurmans, Jacob Andreas, Tengyu Ma, and Denny Zhou. What learning algorithm is in-context learning? investigations with linear models. arXiv preprint arXiv:2211.15661, 2022. [2] Amanda Askell, Yuntao Bai, Anna Chen, Dawn Drain, Deep Ganguli, Tom Henighan, Andy Jones, Nicholas Joseph, Ben Mann, Nova DasSarma, et al. A general language assistant as a laboratory for alignment. arXiv preprint arXiv:2112.00861, 2021. [3] Yuntao Bai, Saurav Kadavath, Sandipan Kundu, Amanda Askell, Jackson Kernion, Andy Jones, Anna Chen, Anna Goldie, Azalia Mirhoseini, Cameron McKinnon, et al. Constitutional ai: Harmlessness from ai feedback. arXiv preprint arXiv:2212.08073, 2022. [4] Samuel R Bowman, Jeeyoon Hyun, Ethan Perez, Edwin Chen, Craig Pettit, Scott Heiner, Kamile Lukosuite, Amanda Askell, Andy Jones, Anna Chen, et al. Measuring progress on scalable oversight for large language models. arXiv preprint arXiv:2211.03540, 2022. [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. Advances in neural information processing systems, 33:1877–1901, 2020. [6] Kushal Chawla, Jaysa Ramirez, Rene Clever, Gale Lucas, Jonathan May, and Jonathan Gratch. Casino: A corpus of campsite negotiation dialogues for automatic negotiation systems. arXiv preprint arXiv:2103.15721, 2021. [7] Xinyun Chen, Maxwell Lin, Nathanael Schärli, and Denny Zhou. Teaching large language models to self-debug. arXiv preprint arXiv:2304.05128, 2023. [8] 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. [9] Junyoung Chung, Caglar Gulcehre, KyungHyun Cho, and Yoshua Bengio. Empirical evaluation of gated recurrent neural networks on sequence modeling. arXiv preprint arXiv:1412.3555, 2014. [10] Cohere. Cohere command models. Cohere website, 2023. URL https://docs.cohere.com/ docs/models. [11] Damai Dai, Yutao Sun, Li Dong, Yaru Hao, Zhifang Sui, and Furu Wei. Why can gpt learn in-context? language models secretly perform gradient descent as meta optimizers. arXiv preprint arXiv:2212.10559, 2022. [12] Meta Fundamental AI Research Diplomacy Team (FAIR)†, Anton Bakhtin, Noam Brown, Emily Dinan, Gabriele Farina, Colin Flaherty, Daniel Fried, Andrew Goff, Jonathan Gray, Hengyuan Hu, et al. Human-level play in the game of diplomacy by combining language models with strategic reasoning. Science, 378(6624):1067–1074, 2022. [13] Yao Fu, Hao Peng, Ashish Sabharwal, Peter Clark, and Tushar Khot. Complexity-based prompting for multi-step reasoning. arXiv preprint arXiv:2210.00720, 2022. +[14] Yao Fu, Litu Ou, Mingyu Chen, and Yuhao Wan. Measuring llms’ reasoning performance. Github, 2023. URL https://github.com/FranxYao/chain-of-thought-hub. [15] Amelia Glaese, Nat McAleese, Maja Tr˛ebacz, John Aslanides, Vlad Firoiu, Timo Ewalds, Maribeth Rauh, Laura Weidinger, Martin Chadwick, Phoebe Thacker, et al. Improving alignment of dialogue agents via targeted human judgements. arXiv preprint arXiv:2209.14375, 2022. +9 [16] Google. Palm 2 technical report. ArXiv, 2023. +20 [17] Jordan Hoffmann, Sebastian Borgeaud, Arthur Mensch, Elena Buchatskaya, Trevor Cai, Eliza Rutherford, Diego de Las Casas, Lisa Anne Hendricks, Johannes Welbl, Aidan Clark, et al. Training compute-optimal large language models. arXiv preprint arXiv:2203.15556, 2022. + +23 [18] AI21 Labs. Announcing jurassic-2 and task-specific apis. AI21 Blog, 2023. URL https: //www.ai21.com/blog/introducing-j2. + +[19] Mike Lewis, Denis Yarats, Yann N Dauphin, Devi Parikh, and Dhruv Batra. Deal or no deal? end-to-end learning for negotiation dialogues. arXiv preprint arXiv:1706.05125, 2017. + +[20] Guohao Li, Hasan Abed Al Kader Hammoud, Hani Itani, Dmitrii Khizbullin, and Bernard Ghanem. Camel: Communicative agents for" mind" exploration of large scale language model society. arXiv preprint arXiv:2303.17760, 2023. + +[21] Percy Liang, Rishi Bommasani, Tony Lee, Dimitris Tsipras, Dilara Soylu, Michihiro Yasunaga, Yian Zhang, Deepak Narayanan, Yuhuai Wu, Ananya Kumar, et al. Holistic evaluation of language models. arXiv preprint arXiv:2211.09110, 2022. + +[22] Hao Liu, Carmelo Sferrazza, and Pieter Abbeel. Languages are rewards: Hindsight finetuning using human feedback. arXiv preprint arXiv:2302.02676, 2023. + +[23] Aman Madaan, Niket Tandon, Prakhar Gupta, Skyler Hallinan, Luyu Gao, Sarah Wiegreffe, Uri Alon, Nouha Dziri, Shrimai Prabhumoye, Yiming Yang, et al. Self-refine: Iterative refinement with self-feedback. arXiv preprint arXiv:2303.17651, 2023. + +[24] OpenAI. Gpt-4 technical report. ArXiv, abs/2303.08774, 2023. + +[25] Long Ouyang, Jeffrey Wu, Xu Jiang, Diogo Almeida, Carroll Wainwright, Pamela Mishkin, Chong Zhang, Sandhini Agarwal, Katarina Slama, Alex Ray, et al. Training language models to follow instructions with human feedback. Advances in Neural Information Processing Systems, 35:27730–27744, 2022. + +[26] Joon Sung Park, Joseph C O’Brien, Carrie J Cai, Meredith Ringel Morris, Percy Liang, and Michael S Bernstein. Generative agents: Interactive simulacra of human behavior. arXiv preprint arXiv:2304.03442, 2023. + +[27] Ethan Perez, Sam Ringer, Kamile Lukoši ˙ ut¯ e, Karina Nguyen, Edwin Chen, Scott Heiner, Craig ˙ Pettit, Catherine Olsson, Sandipan Kundu, Saurav Kadavath, et al. Discovering language model behaviors with model-written evaluations. arXiv preprint arXiv:2212.09251, 2022. + +[28] Shuofei Qiao, Yixin Ou, Ningyu Zhang, Xiang Chen, Yunzhi Yao, Shumin Deng, Chuanqi Tan, Fei Huang, and Huajun Chen. Reasoning with language model prompting: A survey. arXiv preprint arXiv:2212.09597, 2022. + +[29] Jérémy Scheurer, Jon Ander Campos, Jun Shern Chan, Angelica Chen, Kyunghyun Cho, and Ethan Perez. Training language models with natural language feedback. arXiv preprint arXiv:2204.14146, 2022. + +[30] David Silver, Aja Huang, Chris J Maddison, Arthur Guez, Laurent Sifre, George Van Den Driessche, Julian Schrittwieser, Ioannis Antonoglou, Veda Panneershelvam, Marc Lanctot, et al. Mastering the game of go with deep neural networks and tree search. nature, 529(7587):484–489, 2016. + +[31] 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. + +[32] Johannes von Oswald, Eyvind Niklasson, Ettore Randazzo, João Sacramento, Alexander Mordvintsev, Andrey Zhmoginov, and Max Vladymyrov. Transformers learn in-context by gradient descent. arXiv preprint arXiv:2212.07677, 2022. + +[33] Jason Wei, Yi Tay, Rishi Bommasani, Colin Raffel, Barret Zoph, Sebastian Borgeaud, Dani Yogatama, Maarten Bosma, Denny Zhou, Donald Metzler, et al. Emergent abilities of large language models. arXiv preprint arXiv:2206.07682, 2022. + +[34] 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. \ No newline at end of file diff --git a/md/dev/lzZstLVGVGW/lzZstLVGVGW.md b/md/dev/lzZstLVGVGW/lzZstLVGVGW.md new file mode 100644 index 0000000000000000000000000000000000000000..7e349c708efb517cb2cb5cb9da8907b702f38eaa --- /dev/null +++ b/md/dev/lzZstLVGVGW/lzZstLVGVGW.md @@ -0,0 +1,288 @@ +# Earthformer: Exploring Space-Time Transformers for Earth System Forecasting + +Zhihan Gao⇤ Hong Kong University of Science and Technology zhihan.gao@connect.ust.hk + +Xingjian Shi† Amazon Web Services xjshi@amazon.com + +Hao Wang Rutgers University hw488@cs.rutgers.edu + +Yi Zhu Amazon Web Services yzaws@amazon.com + +Yuyang Wang Amazon Web Services yuyawang@amazon.com + +Mu Li Amazon Web Services mli@amazon.com + +Dit-Yan Yeung Hong Kong University of Science and Technology dyyeung@cse.ust.hk + +# Abstract + +Conventionally, Earth system (e.g., weather and climate) forecasting relies on numerical simulation with complex physical models and hence is both expensive in computation and demanding on domain expertise. With the explosive growth of spatiotemporal Earth observation data in the past decade, data-driven models that apply Deep Learning (DL) are demonstrating impressive potential for various Earth system forecasting tasks. The Transformer as an emerging DL architecture, despite its broad success in other domains, has limited adoption in this area. In this paper, we propose Earthformer, a space-time Transformer for Earth system forecasting. Earthformer is based on a generic, flexible and efficient space-time attention block, named Cuboid Attention. The idea is to decompose the data into cuboids and apply cuboid-level self-attention in parallel. These cuboids are further connected with a collection of global vectors. We conduct experiments on the MovingMNIST dataset and a newly proposed chaotic $N$ -body MNIST dataset to verify the effectiveness of cuboid attention and figure out the best design of Earthformer. Experiments on two real-world benchmarks about precipitation nowcasting and El Niño/Southern Oscillation (ENSO) forecasting show that Earthformer achieves state-of-the-art performance. + +# 1 Introduction + +The Earth is a complex system. Variabilities of the Earth system, ranging from regular events like temperature fluctuation to extreme events like drought, hail storm, and El Niño/Southern Oscillation (ENSO), impact our daily life. Among all the consequences, Earth system variabilities can influence crop yields, delay airlines, cause floods and forest fires. Precise and timely forecasting of these variabilities can help people take necessary precautions to avoid crisis, or better utilize natural resources such as wind and solar energy. Thus, improving forecasting models for Earth variabilities (e.g., weather and climate) has a huge socioeconomic impact. Despite its importance, the operational weather and climate forecasting systems have not fundamentally changed for almost 50 years $\pmb { \Vert 3 4 \Vert }$ These operational models, including the state-of-the-art High Resolution Ensemble Forecast (HREF) + +![](images/e7829cff23a564a9dba56015666483ac5c68ca9c04f7b191b8a41a65107a4b3c.jpg) +Figure 1: Example Vertically Integrated Liquid (VIL) observation sequence from the Storm EVent ImageRy (SEVIR) dataset. The observation intensity is mapped to pixel value of the range 0-255. The larger value indicates the higher precipitation intensity. + +rainfall nowcasting model used in National Oceanic and Atmospheric Administration (NOAA) [32], rely on meticulous numerical simulation of physical models. Such simulation-based systems inevitably fall short in the ability to incorporate signals from newly emerging geophysical observation systems $\mathbb { \lVert 1 2 \rVert }$ , or take advantage of the Petabytes-scale Earth observation data [43]. + +As an appealing alternative, deep learning (DL) is offering a new approach for Earth system forecasting [34]. Instead of explicitly incorporating physical rules, DL-based forecasting models are trained on the Earth observation data $\pmb { \| } \overline { { 3 6 } } \|$ . By learning from a large amount of observations, DL models are able to figure out the system’s intrinsic physical rules and generate predictions that outperform simulation-based models $\mathbf { \widehat { \mathbb { Q } } }$ . Such technique has demonstrated success in several applications, including precipitation nowcasting $\mathbb { B 2 } \mathbb { B }$ and ENSO forecasting [15]. Because the Earth system is chaotic $| \bar { \sqrt { 2 1 } } |$ , high-dimensional, and spatiotemporal, designing appropriate DL architecture for modeling the system is particularly challenging. Previous works relied on the combination of Recurrent Neural Networks (RNN) and Convolutional Neural Networks (CNN) [36, 37, 43, 13, 45]. These two architectures impose temporal and spatial inductive biases that help capturing spatiotemporal patterns. However, as a chaotic system, variabilities of the Earth system, such as rainfall and ENSO, are highly sensitive to the system’s initial conditions and can respond abruptly to internal changes. It is unclear whether the inductive biases in RNN and CNN models still hold for such complex systems. + +On the other hand, recent years have witnessed major breakthroughs in DL brought by the wide adoption of Transformer. The model was originally proposed for natural language processing [42, 7], and later has been extended to computer vision $\boxed { 8 } \boxed { 2 2 } \boxed { }$ , multimodal text-image generation [31], graph learning $\lVert 5 2 \rVert$ , etc. Transformer relies on the attention mechanism to capture data correlations and is powerful at modeling complex and long-range dependencies, both of which appear in Earth systems (See Fig. $^ 1$ for an example of Earth observation data). Despite being suitable for the problem, Transformer sees limited adoption for Earth system forecasting. Naively applying the Transformer architecture is infeasible because the $O ( N ^ { 2 } )$ attention mechanism is too computationally expensive for the high-dimensional Earth observation data. How to design a space-time Transformer that is good at predicting the future of the Earth systems is largely an open problem to the community. + +In this paper, we propose Earthformer, a space-time Transformer for Earth system forecasting. To better explore the design of space-time attention, we propose Cuboid Attention, which is a generic building block for efficient space-time attention. The idea is to decompose the input tensor to non-overlapping cuboids and apply cuboid-level self-attention in parallel. Since we limit the $O ( N ^ { 2 } )$ self-attention inside the local cuboids, the overall complexity is greatly reduced. Different types of correlations can be captured via different cuboid decompositions. By stacking multiple cuboid attention layers with different hyperparameters, we are able to subsume several previously proposed video Transformers $\mathbb { m } \mathbb { \left[ 1 9 \right] } \mathbb { \left[ 2 3 \right] } \mathbb { H }$ as special cases, and also come up with new attention patterns that were not studied before. A limitation of this design is the lack of a mechanism for the local cuboids to communicate with each other. Thus, we introduce a collection of global vectors that attend to all the local cuboids, thereby gathering the overall status of the system. By attending to the global vectors, the local cuboids can grasp the general dynamics of the system and share information with each other. + +To verify the effectiveness of cuboid attention and figure out the best design under the Earth system forecasting scenario, we conducted extensive experiments on two synthetic datasets: the MovingMNIST $\sqrt { | 3 6 | }$ dataset and a newly proposed $N$ -body MNIST dataset. Digits in the $N$ -body MNIST follow the chaotic 3-body motion pattern $\boldsymbol { \left[ \left[ 2 5 \right] \right] }$ , which makes the dataset not only more challenging than MovingMNIST but also more relevant to Earth system forecasting. The synthetic experiments reveal the following findings: 1) stacking cuboid attention layers with the Axial attention pattern is both efficient and effective, achieving the best overall performance, 2) adding global vectors provides consistent performance gain without increasing the computational cost, 3) adding hierarchy in the encoder-decoder architecture can improve performance. Based on these findings, we figured out the optimal design for Earthformer and made comparisons with other baselines on the SEVIR [43] + +benchmark for precipitation nowcasting and the ICAR-ENSO dataset $[ \overline { { | 1 5 | } }$ for ENSO forecasting. +Experiments show that Earthformer achieves state-of-the-art (SOTA) performance on both tasks. + +# 2 Related Work + +Deep learning architectures for Earth system forecasting. Conventional DL models for Earth system forecasting are based on CNN and RNN. U-Net with either 2D CNN or 3D CNN have been used for precipitation nowcasting [43], Seasonal Arctic Sea ice prediction [1], and ENSO forecasting [15]. Shi et al. $\textcircled { \lvert 3 6 \rvert }$ proposed the ConvLSTM network that combines CNN and LSTM for precipitation nowcasting. Wang et al. [45] proposed PredRNN which adds the spatiotemporal memory flow structure to ConvLSTM. To better learn long-term high-level relations, Wang et al. [44] proposed E3D-LSTM that integrates 3D CNN to LSTM. To disentangle PDE dynamics from unknown complementary information, PhyDNet [13] incorporates a new recurrent physical cell to perform PDE-constrained prediction in latent space. Espeholt et al. [9] proposed MetNet-2 that outperforms HREF for forecasting precipitation. The architecture is based on ConvLSTM and dilated CNN. Very recently, there are works that tried to apply Transformer for solving Earth system forecasting problems. Pathak et al. $\left[ \left[ 2 8 \right] \right]$ proposed the FourCastNet for global weather forecasting, which is based on Adaptive Fourier Neural Operators (AFNO) [14]. Bai et al. [3] proposed Rainformer for precipitation nowcasting, which is based on an architecture that combines CNN and SwinTransformer $[ [ 2 2 ] ]$ . In our experiments, we can see that Earthformer outperforms Rainformer. + +Space-time Transformers for video modeling. Inspired by the success of ViT $\textcircled { 8 }$ for image classification, space-time Transformer is adopted for improved video understanding. In order to bypass the huge memory consumption brought by joint spatiotemporal attention, several pioneering work proposed efficient alternatives, such as divided attention [4], axial attention [19, 4], factorized encoder $[ [ 2 7 , ] ]$ and separable attention $\mathbb { \lVert 5 4 \rVert }$ . Beyond minimal adaptation from ViT, some recent work introduced more prior to the design of space-time transformers, including trajectory $\mathbb { \left[ \left[ 2 9 \right] \right] }$ multi-scale $\mathbb { \lVert 2 3 \rVert 1 1 }$ and multi-view [49]. However, no prior work focuses on exploring the design of space-time Transformers for Earth system forecasting. + +Global and local attention in vision Transformers. To make self-attention more efficient in terms of both memory consumption and speed, recent works have adapted the essence of CNN to perform local attention in transformers [16, 52]. HaloNets $\pm \amalg$ develops a new self-attention model family consisting of simple local self-attention and convolutional hybrids, which outperform both CNN and vanilla ViT on a range of downstream vision tasks. GLiT $\pmb { \Vert 5 \Vert }$ introduces a locality module and uses neural architecture search to find an efficient backbone. Focal transformer [51] proposes focal self-attention that can incorporate both fine-grained local and coarse-grained global interactions. However, these architectures are not directly applicable to spatiotemporal forecasting. Besides, they are also different from our design because we keep $K$ global vectors to summarize the statistics of the dynamic system and connect the local cuboids; experiments show that such a global vector design is crucial to successful spatiotemporal forecasting. + +# 3 Model + +Similar to previous works $\boxed { 1 3 6 } \boxed { 4 3 } \boxed { 3 }$ , we formulate Earth system forecasting as a spatiotemporal sequence forecasting problem. The Earth observation data, such as radar echo maps from NEXRAD $\textcircled { 1 1 7 }$ and climate data from CIMP6 $\mathbb { \ m }$ , are represented as a spatiotemporal sequence $[ \mathcal { X } _ { i } ] _ { i = 1 } ^ { T }$ , $\mathcal { X } _ { i } \in \bar { \mathbb { R } } ^ { H \times W \times C _ { \mathrm { i n } } }$ . Based on these observations, the model predicts the $K$ -step-ahead future $[ y _ { T + i } ] _ { i = 1 } ^ { K }$ , $\mathcal { Y } _ { T + i } \in \mathbb { R } ^ { H \times W \times C _ { \mathrm { o u t } } }$ . Here, $H , W$ denote the spatial resolution, and $C _ { \mathrm { i n } } , C _ { \mathrm { o u t } }$ denote the number of measurements available at each space-time coordinate from the input and target sequences, respectively. As illustrated in Fig. $\bigtriangledown ,$ our proposed Earthformer is a hierarchical Transformer encoderdecoder based on Cuboid Attention. The input observations are encoded as a hierarchy of hidden states and then decoded to the prediction target. In what follows, we will present the detailed design of cuboid attention and the hierarchical encoder-decoder architecture adopted in Earthformer. + +# 3.1 Cuboid Attention + +Compared with images and text, spatiotemporal data in Earth systems usually have higher dimensionality. As a consequence, applying Transformers to this task is challenging. For example, for a 3D tensor with shape $( T , H , W )$ , the complexity of the vanilla self-attention is $O ( T ^ { 2 } H ^ { 2 } W ^ { 2 } )$ and can be computationally infeasible. Previous literature proposed various structure-aware space-time attention mechanisms to reduce the complexity [19, 23, 4]. + +![](images/3273018fa2c7f84ae8e246c2e1b0297c36dd8ab563f6b5ee90b9b58e7268d560.jpg) +Figure 2: Illustration of the Earthformer architecture. It is a hierarchical Transformer encoder-decoder based on cuboid attention. The input sequence has length $T$ and the target sequence has length $K$ . “ $\times D ^ { \prime }$ means to stack $D$ cuboid attention blocks with residual connection. “ $M \times$ means to have $M$ layers of hierarchies. + +![](images/4885b2f7f68acb4e6c1091c76fb27a62d272ac7f78bacb5a96933ffe131c1e54.jpg) +Figure 3: Illustration of the cuboid attention layer with global vectors. + +![](images/d54e69f891bc676013087526c028e726de220c265cde74182321c42d9b7d3ca5.jpg) +Figure 4: Illustration of cuboid decomposition strategies when the input shape is $( T , H , W ) =$ $( 6 , 4 , 4 )$ , and cuboid size $( b _ { T } , b _ { H } , b _ { W } ) = ( 3 , 2 , 2 )$ . Cells that have the same color belong to the same cuboid and will attend to each other. shift $\mathbf { \Omega } = { \bf { \Omega } } ( 0 , 1 , 1 )$ shifts the cuboid decomposition by 1 pixel along height and width dimensions. strategy $=$ “local” means to aggregate contiguous $( \bar { b _ { T } } , \bar { b } _ { H } , b _ { W } )$ pixels as a cuboid. strategy $=$ “dilated” means to aggregate pixels every $\textstyle { \lceil { \frac { T } { b _ { T } } } \rceil } ( { \lceil { \frac { H } { b _ { H } } } \rceil }$ , $\lceil \frac { W } { b _ { W } } \rceil .$ ) steps along time (height, width) dimension. (Best viewed in color). + +These space-time attention mechanisms share the common design of stacking multiple elementary attention layers that focus on different types of data correlations (e.g., temporal correlation and spatial correlation). Steming from this observation, we propose the generic cuboid attention layer that involves three steps: “decompose”, “attend”, and “merge”. + +Decompose. We first decompose the input spatiotemporal tensor $\mathcal { X } \in \mathbb { R } ^ { T \times H \times W \times C }$ into a sequence of cuboids $\{ \pmb { x } ^ { ( n ) } \}$ . + +$$ +\{ { \pmb x } ^ { ( n ) } \} = \mathtt { D e c o m p o s e } ( { \boldsymbol \chi } , \mathtt { c u b o i d \_ s i z e } , \mathtt { s t r a t e g y } , \mathtt { s h i f t } ) , +$$ + +where cuboid_size $\begin{array} { r l } { = { } } & { { } \left( b _ { T } , b _ { H } , b _ { W } \right) } \end{array}$ is the size of the local cuboid, strategy $\in$ {“local”, “dilated” $\}$ controls whether to adopt the local decomposition strategy or the dilated decomposition strategy $\mathbb { \lVert \rVert }$ , $\mathrm { s h i f t } = ( s _ { T } , s _ { H } , s _ { W } )$ is the window shift offset $[ [ 2 2 ] ]$ . Fig. $\boxed { 4 }$ provides three examples showing how an input tensor will be decomposed following different hyperparameters of Decompose $( \cdot )$ . There are a total number of $\textstyle { \left\lceil { \frac { T } { b _ { T } } } \right\rceil } { \left\lceil { \frac { H } { b _ { H } } } \right\rceil } { \bar { \left\lceil { \frac { W } { b _ { W } } } \right\rceil } }$ cuboids in $\{ \pmb { x } ^ { ( n ) } \}$ . To simplify the notation, we assume that $T , H , W$ are divisible by $b _ { T } , b _ { H } , b _ { W }$ . In the implementation, we pad the input tensor if it is not divisible. + +Assume $\pmb { x } ^ { ( n ) }$ is the $( n _ { T } , n _ { H } , n _ { W } )$ -th cuboid in $\{ \pmb { x } ^ { ( n ) } \}$ . The $( i , j , k )$ -th element of $\pmb { x } ^ { ( n ) }$ can be mapped to the $( i ^ { \prime } , j ^ { \prime } , k ^ { \prime } )$ -th element of $\mathcal { X }$ via Eqn. 2 if the strategy is “local” or Eqn. $\bigtriangledown$ if the strategy is “dilated”. + +$$ +\begin{array} { l l l } { { i ^ { \prime } s _ { T } + b _ { T } ( n _ { T } - 1 ) + i } } & { { \mathrm { m o d } ~ T } } & { { i ^ { \prime } s _ { T } + b _ { T } ( i - 1 ) + n _ { T } \mod T } } \\ { { j ^ { \prime } s _ { H } + b _ { H } ( n _ { H } - 1 ) + j } } & { { \mathrm { m o d } ~ H } } & { { ( 2 ) } } & { { j ^ { \prime } s _ { H } + b _ { H } ( j - 1 ) + n _ { H } \mod H } } \\ { { k ^ { \prime } s _ { W } + b _ { W } ( n _ { W } - 1 ) + k } } & { { \mathrm { m o d } ~ W } } & { { k ^ { \prime } s _ { W } + b _ { W } ( k - 1 ) + n _ { W } \mod W } } \end{array} +$$ + +Since the mapping is bijective, one can then map the elements from $\mathcal { X }$ to $\{ \pmb { x } ^ { ( n ) } \}$ via the inverse operation. + +Attend. After decomposing the input tensor into a sequence of non-overlapping cuboids $\{ \pmb { x } ^ { ( n ) } \}$ we apply self-attention within each cuboid in parallel. + +$$ +\begin{array} { r } { \pmb { x } _ { \mathrm { o u t } } ^ { ( n ) } = \mathtt { A t t e n t i o n } _ { \Theta } ( \pmb { x } ^ { ( n ) } , \pmb { x } ^ { ( n ) } , \pmb { x } ^ { ( n ) } ) , 1 \le n \le N . } \end{array} +$$ + +The query, key, and value matrices $Q , \quad K$ , and $V$ of $\begin{array} { r l } { \mathtt { A t t e n t i o n } _ { \theta } ( Q , K , V ) } & { { } = } \end{array}$ Softmax $\left( ( W _ { Q } Q ) ( W _ { K } K ) ^ { T } / \sqrt { C } \right) ( W _ { V } V )$ are all flattened versions of $\pmb { x } ^ { ( n ) }$ , and we unravel the resulting matrix back to a 3D tensor. $W _ { Q }$ , $W _ { K }$ and $W _ { V }$ are linear projection weights and are abbreviated together as $\Theta$ . The self-attention parameter $\Theta$ are shared across all cuboids. The computational complexity of the “attend” step is $\begin{array} { r } { { \cal O } \left( \left\lceil \frac { T } { b _ { T } } \right\rceil \left\lceil \frac { H } { b _ { H } } \right\rceil \left\lceil \frac { W } { b _ { W } } \right\rceil \left( b _ { T } b _ { H } b _ { W } \right) ^ { 2 } \right) \approx { \cal O } ( T H W \cdot b _ { T } b _ { H } b _ { W } ) } \end{array}$ which scales linearly with the cuboid size. Since the cuboid size can be much smaller than the size of the input tensor, the layer is more efficient than full attention. + +Merge. $\mathsf { M e r g e } ( \cdot )$ is the inverse operation of Decompose $( \cdot )$ . The sequence of cuboids obtained after ·the attention step $\{ \pmb { x } _ { \mathrm { o u t } } ^ { ( n ) } \}$ ·are merged back to the original input shape to produce the final output of cuboid attention, as shown in Eqn. $5 .$ The mapping follows the same bijections in Eqn. $\triangledown$ and Eqn. 3. + +$$ +\mathcal { X } _ { \mathrm { o u t } } = \mathtt { M e r g e } ( \{ x _ { \mathrm { o u t } } ^ { ( n ) } \} _ { n } , \mathrm { c u b o i d \_ s i z e } , \mathrm { s t r a t e g y } , \mathrm { s h i f t } ) . +$$ + +We combine the “decompose”, “attend” and “merge” steps described in Eqn. 1,4,5 to construct the generic cuboid attention as in Eqn. $6 .$ + +$$ +{ \mathcal { X } } _ { \mathrm { { o u t } } } = { \tt C u b A t t n } _ { \Theta } ( { \boldsymbol { \mathcal { X } } } , { \tt c u b o i d \_ s i z e , s t r a t e g y , s h i f t } ) . +$$ + +Explore cuboid attention patterns. By stacking multiple cuboid attention layers with different choices of “cuboid_size”, “strategy” and “shift”, we are able to efficiently explore existing and potentially more effective space-time attention. In this paper, we explore the cuboid attention patterns as listed in Table $^ { 1 . }$ From the table, we can see that cuboid attention subsumes previously proposed space-time attention methods like axial attention, video swin-Transformer, and divided space-time attention. Also, we manually picked the patterns that are reasonable and not computationally expensive as our search space. The flexibility of cuboid attention allows us to conduct Neural Architecture Search (NAS) to automatically search for a pattern but we will leave it as future work. + +# 3.2 Global Vectors + +One limitation of the previous formulation is that the cuboids do not communicate with each other. This is undesirable because each cuboid is not capable of understanding the global dynamics of the system. Thus, inspired by the [CLS] token adopted in BERT [7, $\pmb { \bigtriangledown } 3 \|$ , we propose to introduce a collection of $P$ global vectors $\mathcal { G } \in \mathbb { R } ^ { P \times C }$ to help cuboids scatter and gather crucial global information. When each cuboid is performing the self-attention, the elements will not only attend to the other elements within the same cuboid but also attend to the global vectors $\mathcal { G }$ . We revise Eqn. 4 to Eqn. $\perp$ to enable local-global information exchange. We also use Eqn. $\textcircled { 8 }$ to update the global vectors $\mathcal { G }$ by aggregating the information from all elements of the input tensor $\mathcal { X }$ . + +$$ +\begin{array} { r l } & { \boldsymbol { x } _ { \mathrm { o u t } } ^ { ( n ) } = \mathrm { A t t e n t i o n } _ { \Theta } \left( \boldsymbol { x } ^ { ( n ) } , { \mathsf { C a t } } ( \boldsymbol { x } ^ { ( n ) } , \mathcal { G } ) , { \mathsf { C a t } } ( \boldsymbol { x } ^ { ( n ) } , \mathcal { G } ) \right) , 1 \le n \le N . } \\ & { \mathcal { G } _ { \mathrm { o u t } } = \mathrm { A t t e n t i o n } _ { \Phi } \left( \mathcal { G } , { \mathsf { C a t } } ( \mathcal { G } , \mathcal { X } ) , { \mathsf { C a t } } ( \mathcal { G } , \mathcal { X } ) \right) . } \end{array} +$$ + +Table 1: Configurations of the cuboid attention patterns explored in the paper. The input tensor has shape $( T , H , W )$ . If “shift” or “strategy” is not given, we use shift ${ \bf \Lambda } = ( 0 , 0 , 0 )$ and strategy $=$ “local” by default. When stacking multiple cuboid attention layers, each layer will be coupled with layer normalization layers and feed-forward network as in the Pre-LN Transformer $[ \overline { { | 4 8 | } }$ . The first row shows the configuration of the generic cuboid attention. + +
Name Configurations Values
Generic Cuboid Attentioncuboid_sizeshiftstrategy(T1,H,W1)→(T2,H,W2)→:→(TL,HL,WL)(P,M,M)→(P2,M,M2)→:→(PL,ML,ML)"loc./dil."→“loc./dil.”→·…·→“loc./dil.”
Axialcuboid_size(T,1,1)→(1,H,1)→(1,1,W)
Divided Space-Timecuboid_size(T,1,1) →(1,H,W)
Video-Swin P×Mcuboid_sizeshift(P,M,M)→(P,M,M)(0,0,0)→(P/2,M/2,M/2)
Spatial Local-Dilate-Mcuboid_sizestrategy(T,1,1)→(1,M,M)→(1,M,M)“local”→“local”→“dilated"
Axial Space Dilate-Mcuboid_sizestrategy(T,1,1)→(1,H/M,1)→(1,H/M,1)→(1,1,W/M)→(1,1,W/M)“local”→“dilated”→“local”→“dilated”→“local”
+ +Here, $\mathtt { C a t } ( \cdot )$ flattens and concatenates its input tensors. By combining Eqn. $^ { 1 , 7 , 8 , 5 }$ , we abbreviate the overall computation of the cuboid attention layer with global vectors as in Eqn. 9. + +$$ +\begin{array} { r } { \mathcal { X } _ { \mathrm { o u t } } = \mathtt { C u b A t t n } _ { \Theta } ( \mathcal { X } , \mathcal { G } , } \\ { \mathcal { G } _ { \mathrm { o u t } } = \mathtt { A t t n } _ { \Phi } ^ { \mathrm { g l o b a l } } ( \mathcal { G } , \mathcal { X } ) . } \end{array} +$$ + +The additional complexity caused by the global vectors is approximately $O \left( T H W \cdot P + P ^ { 2 } \right)$ . Given that $P$ is usually small (in our experiments, $P$ is at most 8), the computational overhead induced by the global structure is negligible. The architecture of the cuboid attention layer is illustrated in Fig. 3. + +# 3.3 Hierarchical Encoder-Decoder Architecture + +Earthformer adopts a hierarchical encoder-decoder architecture illustrated in Fig. 2. The hierarchical architecture gradually encodes the input sequence to multiple levels of representations and generates the prediction via a coarse-to-fine procedure. Each hierarchy stacks $D$ cuboid attention blocks. The cuboid attention block in the encoder uses one of the patterns described in Table $^ { 1 , }$ and each cuboid block in the decoder adopts the “Axial” pattern. To reduce the spatial resolution of the input to cuboid attention layers, we include a pair of initial downsampling and upsampling modules that consist of stacked 2D-CNN and Nearest Neighbor Interpolation (NNI) layers. Different from other papers that adopt Transformer for video prediction $\bar { \lVert 1 9 \rVert } , \lVert \bar { 3 0 } \rVert$ , we generate the predictions in a non-auto-regressive fashion rather than an auto-regressive patch-by-patch fashion. This means that our decoder directly generates the predictions from the initial learned positional embeddings. We also conducted experiments with an auto-regressive decoder based on visual codebook $\mathbb { B } 3 \mathbb { I }$ . However, the auto-regressive decoder underperforms the non-auto-regressive decoder in terms of forecasting skill scores. The comparison between non-auto-regressive decoder and auto-regressive decoder is shown in Appendix C. + +# 4 Experiments + +We first conducted experiments on two synthetic datasets, MovingMNIST and a newly proposed $N$ -body MNIST, to verify the effectiveness of Earthformer and conduct ablation study on our design choices. Results on these two datasets lead to the following findings: 1) Among all patterns listed in Table $^ { 1 , }$ “Axial” achieves the best overall performance; 2) Global vectors bring consistent performance gain with negligible increase in computational cost; 3) Using a hierarchical coarseto-fine structure can boost the performance. Based on these findings, we figured out the optimal design of Earthformer and compared it with other state-of-the-art models on two real-world datasets: SEVIR $\mathbb { \lVert \boldsymbol { 4 3 } \rVert }$ and ICAR-ENSO2. On both datasets, Earthformer achieved the best overall performance. The statistics of all the datasets used in the experiments are shown in Table $\boxed { 2 } .$ We normalized the data to the range [0, 1] and trained all the models with the Mean-Squared Error (MSE) loss. More implementation details are shown in Appendix A. + +Table 2: Statistics of the datasets used in the experiments. + +
DatasetSizeSeq. Len.Spatial Resolution
trainvaltestinoutH ×W
MovingMNIST8,1009001,000101064×64
N-body MNIST20.0001,0001,000101064×64
SEVIR35,7189,06012,1591312384× 384
ICAR-ENSO5,2053341,667121424×48
+ +Table 3: Ablation study on the importance of adopting a hierarchical encoder-decoder. We conducted experiments on MovingMNIST. “Depth $D '$ means the model stacks $D$ cuboid attention blocks and there is no hierarchical structure. “Depth $D 1$ , $D 2 ^ { \bullet }$ means the model stacks $D 1$ cuboid attention blocks, applies the pooling layer, and stacks another $D 2$ cuboid attention blocks. + +
Model#Param. (M)GFLOPSMetrics MSE↓ MAE↓
Depth 21.417.963.80140.60.8324
Depth 43.136.352.46114.80.8685
Depth 64.954.650.49110.00.8738
Depth 86.673.048.04104.60.8797
Depth 1,11.411.560.99135.70.8388
Depth 2,23.118.950.41106.90.8805
Depth 3.34.926.347.69100.10.8873
Depth 4,46.633.746.91101.50.8825
+ +# 4.1 Experiments on Synthetic Datasets + +MovingMNIST. We follow $\pmb { \Vert 3 8 \Vert }$ to use the public MovingMNIST dataset3. The dataset contains 10,000 sequences. Each sequence shows 2 digits moving inside a $6 4 \times 6 4$ frame. We split the dataset to use 8,100 samples for training, 900 samples for validation and 1,000 samples for testing. The task is to predict the future 10 frames for each sequence conditioned on the first 10 frames. + +$N$ -body MNIST. The Earth is a complex system in which an extremely large number of variables interact with each other. Compared with the Earth system, the dynamics of the synthetic MovingMNIST dataset, in which the digits move independently with constant speed, is over-simplified. Thus, achieving good performance on MovingMNIST does not imply that the model is capable of modeling complex interactions in the Earth system. On the other hand, the real-world Earth observation data, though experiencing rapid development, are still noisy and may not provide useful insights for model development. Therefore, we extend MovingMNIST to $N$ -body MNIST, where $N$ digits are moving with the $N$ -body motion pattern inside a $6 4 \times 6 4$ frame. Each digit has its mass and is subjected to the gravity from other digits. We choose $N = 3$ in the experiments so that the digits will follow the chaotic 3-body motion $| | \bar { 2 } 5 | |$ . The highly non-linear interactions in $N$ -body MNIST make it much more challenging than the original MovingMNIST. We generate 20,000 sequences for training, 1,000 for validation and 1,000 for testing. Perceptual examples of the dataset can be found at the first two rows of Fig. 5. In Appendix D, we demonstrate the chaotic behavior of $N$ -body MNIST. + +Hierarchical v.s. non-hierarchical. We choose “Axial” without global vectors as our cuboid attention pattern and compare the performance of non-hierarchical and hierarchical architectures on MovingMNIST. The ablation study on the importance of adopting a hierarchical encoder-decoder is shown in Table 3. We can see that the hierarchical architecture has similar FLOPS with the nonhierarchical architectures while being better in MSE. This observation is consistent as we increase the depth until the performance saturates. + +Cuboid pattern search. The design of cuboid attention greatly facilitates the search for optimal space-time attention. We compare the patterns listed in Table $^ 1$ on both MovingMNIST and $N$ -body MNIST to investigate the effectiveness and efficiency of different space-time attention methods on spatiotemporal forecasting tasks. Besides the previously proposed space-time attention methods, we also include new configurations that are reasonable and not computationally expensive in our search space. For each pattern, we also compare the variant that uses global vectors. Results are summarized in Table 4. We find that the “Axial” pattern is both effective and efficient and adding global vectors improves performance for all patterns while having similar FLOPS. We thus pick “Axial $^ +$ global” as the pattern in Earthformer when conducting experiments on real-world datasets. + +Table 4: Ablation study of different cuboid attention patterns and the effect of global vectors on MovingMNIST and $N$ -body MNIST. The variant that achieved the best performance is in boldface while the second best is underscored. We also compared the performance of the cuboid attention patterns with and without global vectors and highlight the better one with grey background. + +
ModelMovingMNIST N-body MNIST#Param. (M)GFLOPSMSE↓MAE↓SSIM↑MSE↓MAE↓SSIM↑
Axial6.6133.746.91 101.5 0.882515.89 41.38 0.9510
+ global★7.6134.041.79 92.78 0.896114.82 39.93 0.9538
DST5.7035.257.43 118.6 0.862318.24 45.88 0.9435
+ global6.3735.552.92 108.3 0.876017.77 45.84 0.9433
Video Swin 2x85.6631.154.45 111.7 0.871519.89 49.02 0.9374
+ global6.3331.452.70 108.5 0.876619.53 48.43 0.9389
Video Swin 10x85.8939.263.34 125.3 0.852523.35 53.17 0.9274
+ global6.5639.462.15 123.4 0.854122.81 52.94 0.9293
Spatial Local-Global 26.6133.359.88 122.1 0.857223.24 54.63 0.9263
+ global7.6133.759.42 122.9 0.856521.88 52.49 0.9305
Spatial Local-Global 4+ global6.6133.558.72 118.5 0.860021.02 49.82 0.9344
7.6133.954.84 115.5 0.858519.82 48.12 0.9371
Axial Space Dilate 28.5941.850.11 104.4 0.881415.97 42.19 0.9494
+ global10.3042.446.86 98.95 0.888415.73 41.85 0.9510
Axial Space Dilate 48.5910.3041.647.40 99.31 0.886519.49 51.04 0.9352
+ global42.245.11 95.98 0.892817.91 46.35 0.9440
+ +Table 5: Comparison of Earthformer with baselines on MovingMNIST and $N$ -body MNIST. + +
Model#Param. (M)GFLOPSMovingMNISTN-body MNIST
MSE↓MAE↓SSIM↑MSE↓MAE↓SSIM↑
UNet 43116.60.9110.4249.40.617038.9094.290.8260
ConvLSTM3614.030.162.04126.90.847732.1572.640.8886
PredRNN [45]23.8232.052.07108.90.883121.7654.320.9288
PhyDNet[ 园3.115.358.70124.10.835028.9778.660.8206
E3D-LSTM I44112.9302.055.31101.60.882122.9862.520.9131
Rainformer 国19.21.285.83189.20.730138.8996.470.8036
Earthformer w/o global6.633.746.91101.50.882515.8941.380.9510
Earthformer7.634.041.7992.780.896114.8239.930.9538
+ +Comparison to the state of the art. We evaluate six spatiotemporal forecasting algorithms: UNet $\overline { { \mathbb { H } 3 } } \Vert$ , ConvLSTM $\pmb { \mathbb { B } } 6 \|$ , PredRNN [45], PhyDNet [13], E3D-LSTM $\mathbb { \lVert H \ 4 \rVert }$ and Rainformer [3]. The results are in Table $5 .$ Note that the MovingMNIST performance on several papers $\mathbb { \lVert \lambda \rVert }$ is obtained by training the model with on-the-fly generated digits while we pre-generate the digits and train all models on a fixed dataset. Comparing the numbers in the table with numbers shown in these papers are not fair. We train all baselines from scratch on both MovingMNIST and $N$ -body MNIST using the default hyperparameters and configurations in their officially released code4. + +Qualitative results on $N$ -body MNIST. Fig. 5 shows the generation results of different methods on a sample sequence from the $N$ -body MNIST test set. The qualitative example demonstrates that our Earthformer is capable of learning long-range interactions among digits and correctly predicting their future motion trajectories. Also, we can see that Earthformer is able to more accurately predict the position of the digits with the help of global vectors. On the contrary, none of the baseline algorithms that achieved solid performance on MovingMNIST gives the correct and precise position of the digit $\cdot _ { 0 } \cdot \mathbf { \vec { \tau } }$ in the last frame. They either predict incorrect motion trajectories (PredRNN and E3D-LSTM), or generate highly blurry predictions (Rainformer, UNet and PhyDNet) to accommodate the uncertainty about the future. + +# 4.2 SEVIR Precipitation Nowcasting + +Storm EVent ImageRy (SEVIR) $\mathbb { \oplus 3 } \mathbb { \mathbb { I } }$ is a spatiotemporally aligned dataset containing over 10,000 weather events. Each event consists of $3 8 4 ~ \mathrm { k m } \times 3 8 4 ~ \mathrm { k m }$ image sequences spanning over 4 hours. Images in SEVIR were sampled and aligned across five different data types: three channels (C02, + +![](images/e4ac0e42e46f22b9e646a8d271c97fa6961707805badd72e8ef307ffed514236.jpg) +Figure 5: A set of examples showing the perceptual quality of the predictions on the $N$ -body MNIST test set. From top to bottom: input frames, target frames, predictions by Rainformer [3], UNet [43] ConvLSTM [36], PhyDNet [13], E3D-LSTM [44], PredRNN [45], Earthformer without using global vectors, Earthformer. The results are sorted according to the MSE. + +Table 6: Performance comparison on SEVIR. We include Critical Success Index (CSI) besides MSE as evaluation metrics. The CSI, a.k.a intersection over union (IOU), is calculated at different precipitation thresholds and denoted as CSI-thresh. + +
Model#Param. (M)GFLOPSMetrics
CSI-M ↑CSI-219 ↑CSI-181↑CSI-160↑CSI-133↑CSI-74↑CSI-16↑MSE(10-)↓
Persistence-0.26130.05260.09690.12780.21550.47050.604711.5338
UNet43116.6330.35930.05770.15800.21570.32740.65310.74414.1119
ConvLSTM|36l14.05270.41850.12880.24820.29280.40520.67930.75693.7532
PredRNN45146.63280.40800.13120.23240.27670.38580.67130.75073.9014
PhyDNet 园13.77010.39400.12880.23090.27080.37200.65560.70594.8165
E3D-LSTM144135.65230.40380.12390.22700.26750.38250.66450.75734.1702
Rainformer □184.01700.36610.08310.16700.21670.34380.65850.72774.0272
Earthformer w/o global13.12570.43560.15720.27160.31380.42140.68590.76373.7002
Earthformer15.12570.44190.17910.28480.32320.42710.68600.75133.6957
+ +C09, C13) from the GOES-16 advanced baseline imager, NEXRAD Vertically Integrated Liquid (VIL) mosaics, and GOES-16 Geostationary Lightning Mapper (GLM) flashes. The SEVIR benchmark supports scientific research on multiple meteorological applications including precipitation nowcasting, synthetic radar generation, front detection, etc. We adopt SEVIR for benchmarking precipitation nowcasting, i.e., to predict the future VIL up to 60 minutes (12 frames) given 65 minutes context VIL (13 frames). Fig. 1 shows an example of VIL observation sequences in SEVIR. + +Besides MSE, we also include the Critical Success Index (CSI), which is commonly used in precipitation nowcasting and is defined as $\begin{array} { r } { \mathtt { C S I } \ = \ \frac { \# \mathtt { H i t s } } { \# \mathtt { H i t s } + \# \mathtt { M i s s e s } + \# \mathtt { F . A l a r m s } } } \end{array}$ . To count the #Hits (truth $_ { | = 1 }$ , pred=1), #Misses (truth $^ { = 1 }$ , pred ${ } = 0$ ) and #F.Alarms (truth ${ } = 0$ , pred $^ { = 1 }$ ), the prediction and the ground-truth are rescaled back to the range 0-255 and binarized at thresholds [16, 74, 133, 160, 181, 219]. We report CSI at different thresholds and also their mean CSI-M. + +SEVIR is much larger than MovingMNIST and $N$ -body MNIST and has higher resolution. We thus slightly adjust the configurations of baselines based on those for MovingMNIST for fair comparison. Detailed configurations are shown in Appendix $\mathbb { A }$ . The experiment results are listed in Table $\checkmark$ Earthformer consistently outperforms baselines on almost all metrics and brings significant performance gain especially at high thresholds like CSI-219, which are more valued by the communities. + +Table 7: Performance comparison on ICAR-ENSO. $C$ -Nino3.4-M and $C$ -Nino3.4-WM are the mean and the weighted mean of the correlation skill $C ^ { \mathtt { N i n o 3 . 4 } }$ over $K = 1 2$ forecasting steps. $C$ -Nino3.4-WM assigns more weights to longer-term prediction scores. MSE is calculated between the spatiotemporal SST anomalies prediction and the corresponding ground-truth. + +
Model#Param. (M)GFLOPSMetrics C-Nino3.4-M ↑ C-Nino3.4-WM↑
Persistence=-0.32210.4474.581
UNet 4312.10.40.69262.1022.868
ConvLSTM3614.011.10.69552.1072.657
PredRNN 因23.885.80.64921.9103.044
PhyDNet 画3.15.70.66461.9652.708
E3D-LSTM14412.999.80.70402.1253.095
Rainformer 国19.21.30.71062.1533.043
Earthformer w/o global6.623.60.72392.2142.550
Earthformer7.623.90.73292.2592.546
+ +# 4.3 ICAR-ENSO Sea Surface Temperature Anomalies Forecasting + +El Niño/Southern Oscillation (ENSO) has a wide range of associations with regional climate extremes and ecosystem impacts. ENSO sea surface temperature (SST) anomalies forecasting for lead times up to one year (12 steps) is a valuable and challenging problem. Nino3.4 index, which is the areaaveraged SST anomalies across a certain area $( 1 7 0 ^ { \circ } - 1 2 0 ^ { \circ } \mathsf { W } .$ , $5 ^ { \circ } \mathsf { S - 5 ^ { \circ } N } ,$ of the Pacific, serves as a crucial indicator of this climate event. The forecast quality is evaluated by the correlation skill [15] of the three-month-moving-averaged Nino3.4 index $\begin{array} { r } { C ^ { \mathrm { N i n o 3 . 4 } } = \frac { \sum _ { N } ( X - \bar { X } ) ( Y - \bar { Y } ) } { \sqrt { \sum _ { N } ( X - \bar { X } ) ^ { 2 } \sum _ { N } ( Y - \bar { Y } ) ^ { 2 } } } \in { \mathbb R } ^ { K } } \end{array}$ calculated on the whole test set of size $N$ , where $\pmb { Y } \in \mathbb { R } ^ { N \times K }$ is the ground-truth of $K$ -step Nino3.4 index, $\pmb { X } \in \mathbb { R } ^ { N \times K }$ is the corresponding prediction of Nino3.4 index. + +ICAR-ENSO consists of historical climate observation and stimulation data provided by Institute for Climate and Application Research (ICAR). We forecast the SST anomalies up to 14 steps (2 steps more than one year for calculating three-month-moving-average) given a context of 12 steps of SST anomalies observations. Table $\perp$ compares the performance of our Earthformer with baselines on the ICAR-ENSO dataset. We report the mean correlation skill $\begin{array} { r } { C \mathtt { - N i n o 3 . 4 - M } = \frac { 1 } { K } \sum _ { k } C _ { k } ^ { \mathtt { N i n o 3 . 4 } } } \end{array}$ and the weighted mean correlation skill $\begin{array} { r } { C \mathtt { - N i n o 3 . 4 - W M } = \frac { 1 } { K } \sum _ { k } a _ { k } \cdot C _ { k } ^ { \mathtt { N i n o 3 . 4 } } } \end{array}$ over $K = 1 2$ forecasting steps5 as well as the MSE between the spatiotemporal SST anomalies prediction and the corresponding ground-truth. We can find that Earthformer consistently outperforms the baselines in all concerned evaluation metrics and that using global vectors further improves the performance. + +# 5 Conclusions and Broader Impact + +In this paper, we propose Earthformer, a space-time Transformer for Earth system forecasting. Earthformer is based on a generic and efficient building block called Cuboid Attention. It achieves SOTA on MovingMNIST, our newly proposed $N$ -body MNIST, SEVIR, and ICAR-ENSO. + +Our work has certain limitations. The first one is that Earthformer is a deterministic model that does not model uncertainty. This may result in predicting the average of all plausible futures, causing the model to generate blurry predictions of low perceptual quality and be lack of valuable small-scale details. In fact, the community lacks appropriate metrics that measure the uncertainty component in Earth system forecasting models. Extending Earthformer to a probabilistic forecasting model can be an exciting future direction. We include more detailed discussions and preliminary experiments about handling uncertainty in Appendix $\mathbf { C } .$ The second one is that the model is purely data-driven and does not take advantage of the physical knowledge of the Earth system. Recent studies on adding physical constraints $\mathbb { 1 } 2 0 , \breve { \left\lfloor 2 6 \right\rfloor }$ and ensembling the predictions from a data-driven model and a physics-based model $\left[ \left[ 3 2 \right] \right]$ imply that it is an active and promising research direction to pursue. We plan to study how to incorporate physical knowledge into Earthformer in the future. + +# Acknowledgments and Disclosure of Funding + +This work has been made possible by a Research Impact Fund project (R6003-21) and an Innovation and Technology Fund project (ITS/004/21FP) funded by the Hong Kong Government. + +References +[1] Tom R Andersson, J Scott Hosking, María Pérez-Ortiz, Brooks Paige, Andrew Elliott, Chris Russell, Stephen Law, Daniel C Jones, Jeremy Wilkinson, Tony Phillips, et al. Seasonal Arctic sea ice forecasting with probabilistic deep learning. Nature communications, 12(1):1–12, 2021. +[2] Anurag Arnab, Mostafa Dehghani, Georg Heigold, Chen Sun, Mario Luvcic, and Cordelia ´ Schmid. ViViT: A video vision transformer. In International Conference on Computer Vision (ICCV), 2021. +[3] Cong Bai, Feng Sun, Jinglin Zhang, Yi Song, and Shengyong Chen. Rainformer: Features extraction balanced network for radar-based precipitation nowcasting. IEEE Geoscience and Remote Sensing Letters, 19:1–5, 2022. +[4] Gedas Bertasius, Heng Wang, and Lorenzo Torresani. Is space-time attention all you need for video understanding. arXiv preprint arXiv:2102.05095, 2(3):4, 2021. [5] Boyu Chen, Peixia Li, Chuming Li, Baopu Li, Lei Bai, Chen Lin, Ming Sun, Junjie Yan, and Wanli Ouyang. GLiT: Neural architecture search for global and local image transformer. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 12–21, 2021. +[6] Christian Schroeder de Witt, Catherine Tong, Valentina Zantedeschi, Daniele De Martini, Freddie Kalaitzis, Matthew Chantry, Duncan Watson-Parris, and Piotr Bilinski. RainBench: towards global precipitation forecasting from satellite imagery. In AAAI, 2021. +[7] 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. +[8] 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. +[9] Lasse Espeholt, Shreya Agrawal, Casper Sønderby, Manoj Kumar, Jonathan Heek, Carla Bromberg, Cenk Gazen, Jason Hickey, Aaron Bell, and Nal Kalchbrenner. Skillful twelve hour precipitation forecasts using large context neural networks. arXiv preprint arXiv:2111.07470, 2021. +[10] Veronika Eyring, Sandrine Bony, Gerald A Meehl, Catherine A Senior, Bjorn Stevens, Ronald J Stouffer, and Karl E Taylor. Overview of the coupled model intercomparison project phase 6 (CMIP6) experimental design and organization. Geoscientific Model Development, 9(5):1937– 1958, 2016. +[11] Haoqi Fan, Bo Xiong, Karttikeya Mangalam, Yanghao Li, Zhicheng Yan, Jitendra Malik, and Christoph Feichtenhofer. Multiscale vision transformers. In ICCV, 2021. +[12] Steven J Goodman, Timothy J Schmit, Jaime Daniels, and Robert J Redmon. The GOES-R series: a new generation of geostationary environmental satellites. Elsevier, 2019. +[13] Vincent Le Guen and Nicolas Thome. Disentangling physical dynamics from unknown factors for unsupervised video prediction. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 11474–11484, 2020. +[14] John Guibas, Morteza Mardani, Zongyi Li, Andrew Tao, Anima Anandkumar, and Bryan Catanzaro. Adaptive fourier neural operators: Efficient token mixers for transformers. arXiv preprint arXiv:2111.13587, 2021. +[15] Yoo-Geun Ham, Jeong-Hwan Kim, and Jing-Jia Luo. Deep learning for multi-year ENSO forecasts. Nature, 573(7775):568–572, 2019. +[16] Kai Han, An Xiao, Enhua Wu, Jianyuan Guo, Chunjing Xu, and Yunhe Wang. Transformer in transformer. NeurIPS, 2021. +[17] William H Heiss, David L McGrew, and Dale Sirmans. NEXRAD: next generation weather radar (wsr-88d). Microwave Journal, 33(1):79–89, 1990. +[18] Dan Hendrycks and Kevin Gimpel. Gaussian error linear units (gelus). arXiv preprint arXiv:1606.08415, 2016. +[19] Jonathan Ho, Nal Kalchbrenner, Dirk Weissenborn, and Tim Salimans. Axial attention in multidimensional transformers. arXiv preprint arXiv:1912.12180, 2019. +[20] Aditi Krishnapriyan, Amir Gholami, Shandian Zhe, Robert Kirby, and Michael W Mahoney. Characterizing possible failure modes in physics-informed neural networks. Advances in Neural Information Processing Systems, 34:26548–26560, 2021. +[21] Christophe Letellier. Chaos in nature, volume 94. World Scientific, 2019. +[22] 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, pages 10012–10022, 2021. +[23] Ze Liu, Jia Ning, Yue Cao, Yixuan Wei, Zheng Zhang, Stephen Lin, and Han Hu. Video swin transformer. arXiv preprint arXiv:2106.13230, 2021. +[24] Mario Lucic, Karol Kurach, Marcin Michalski, Sylvain Gelly, and Olivier Bousquet. Are GANs created equal? a large-scale study. In NeurIPS, 2018. +[25] Valtonen MJ, Mauri Valtonen, and Hannu Karttunen. The three-body problem. Cambridge University Press, 2006. +[26] Geoffrey Négiar, Michael W Mahoney, and Aditi S Krishnapriyan. Learning differentiable solvers for systems with hard constraints. arXiv preprint arXiv:2207.08675, 2022. +[27] Daniel Neimark, Omri Bar, Maya Zohar, and Dotan Asselmann. Video transformer network. arXiv preprint arXiv:2102.00719, 2021. +[28] Jaideep Pathak, Shashank Subramanian, Peter Harrington, Sanjeev Raja, Ashesh Chattopadhyay, Morteza Mardani, Thorsten Kurth, David Hall, Zongyi Li, Kamyar Azizzadenesheli, et al. FourCastNet: A global data-driven high-resolution weather model using adaptive fourier neural operators. arXiv preprint arXiv:2202.11214, 2022. +[29] Mandela Patrick, Dylan Campbell, Yuki M. Asano, Ishan Misra Florian Metze, Christoph Feichtenhofer, Andrea Vedaldi, and João F. Henriques. Keeping your eye on the ball: Trajectory attention in video transformers. In Advances in Neural Information Processing Systems (NeurIPS), 2021. +[30] Ruslan Rakhimov, Denis Volkhonskiy, Alexey Artemov, Denis Zorin, and Evgeny Burnaev. Latent video transformer. arXiv preprint arXiv:2006.10704, 2020. +[31] Aditya Ramesh, Mikhail Pavlov, Gabriel Goh, Scott Gray, Chelsea Voss, Alec Radford, Mark Chen, and Ilya Sutskever. Zero-shot text-to-image generation. In International Conference on Machine Learning, pages 8821–8831. PMLR, 2021. +[32] Suman Ravuri, Karel Lenc, Matthew Willson, Dmitry Kangin, Remi Lam, Piotr Mirowski, Megan Fitzsimons, Maria Athanassiadou, Sheleem Kashem, Sam Madge, et al. Skilful precipitation nowcasting using deep generative models of radar. Nature, 597(7878):672–677, 2021. +[33] Ali Razavi, Aaron Van den Oord, and Oriol Vinyals. Generating diverse high-fidelity images with VQ-VAE-2. Advances in neural information processing systems, 32, 2019. +[34] Markus Reichstein, Gustau Camps-Valls, Bjorn Stevens, Martin Jung, Joachim Denzler, Nuno Carvalhais, et al. Deep learning and process understanding for data-driven earth system science. Nature, 566(7743):195–204, 2019. +[35] Tim Salimans, Andrej Karpathy, Xi Chen, and Diederik P. Kingma. PixelCNN $^ { + + }$ : A PixelCNN implementation with discretized logistic mixture likelihood and other modifications. In ICLR, 2017. +[36] Xingjian Shi, Zhourong Chen, Hao Wang, Dit-Yan Yeung, Wai-Kin Wong, and Wang-chun Woo. Convolutional LSTM network: A machine learning approach for precipitation nowcasting. In NeurIPS, volume 28, 2015. +[37] Xingjian Shi, Zhihan Gao, Leonard Lausen, Hao Wang, Dit-Yan Yeung, Wai-kin Wong, and Wang-chun Woo. Deep learning for precipitation nowcasting: A benchmark and a new model. In NeurIPS, volume 30, 2017. +[38] Nitish Srivastava, Elman Mansimov, and Ruslan Salakhudinov. Unsupervised learning of video representations using LSTMs. In ICML, pages 843–852. PMLR, 2015. +[39] Byron D Tapley, Srinivas Bettadpur, John C Ries, Paul F Thompson, and Michael M Watkins. GRACE measurements of mass variability in the earth system. science, 305(5683):503–505, 2004. +[40] Aaron Van Den Oord, Oriol Vinyals, et al. Neural discrete representation learning. Advances in neural information processing systems, 30, 2017. +[41] Ashish Vaswani, Prajit Ramachandran, Aravind Srinivas, Niki Parmar, Blake Hechtman, and Jonathon Shlens. Scaling local self-attention for parameter efficient visual backbones. In CVPR, 2021. +[42] Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Lukasz Kaiser, and Illia Polosukhin. Attention is all you need. In NeurIPS, volume 30, 2017. +[43] Mark Veillette, Siddharth Samsi, and Chris Mattioli. SEVIR: A storm event imagery dataset for deep learning applications in radar and satellite meteorology. Advances in Neural Information Processing Systems, 33:22009–22019, 2020. +[44] Yunbo Wang, Lu Jiang, Ming-Hsuan Yang, Li-Jia Li, Mingsheng Long, and Li Fei-Fei. Eidetic 3D LSTM: A model for video prediction and beyond. In International conference on learning representations, 2018. +[45] Yunbo Wang, Haixu Wu, Jianjin Zhang, Zhifeng Gao, Jianmin Wang, Philip Yu, and Mingsheng Long. PredRNN: A recurrent neural network for spatiotemporal predictive learning. IEEE Transactions on Pattern Analysis and Machine Intelligence, 2022. +[46] Dirk Weissenborn, Oscar Täckström, and Jakob Uszkoreit. Scaling autoregressive video models. In International Conference on Learning Representations, 2019. +[47] Yuxin Wu and Kaiming He. Group normalization. In Proceedings of the European conference on computer vision (ECCV), pages 3–19, 2018. +[48] Ruibin Xiong, Yunchang Yang, Di He, Kai Zheng, Shuxin Zheng, Chen Xing, Huishuai Zhang, Yanyan Lan, Liwei Wang, and Tieyan Liu. On layer normalization in the transformer architecture. In International Conference on Machine Learning, pages 10524–10533. PMLR, 2020. +[49] Shen Yan, Xuehan Xiong, Anurag Arnab, Zhichao Lu, Mi Zhang, Chen Sun, and Cordelia Schmid. Multiview transformers for video recognition. In CVPR, 2022. +[50] Wilson Yan, Yunzhi Zhang, Pieter Abbeel, and Aravind Srinivas. VideoGPT: Video generation using vq-vae and transformers. arXiv preprint arXiv:2104.10157, 2021. +[51] Jianwei Yang, Chunyuan Li, Pengchuan Zhang, Xiyang Dai, Bin Xiao, Lu Yuan, and Jianfeng Gao. Focal self-attention for local-global interactions in vision transformers. In NeurIPS, 2021. +[52] Chengxuan Ying, Tianle Cai, Shengjie Luo, Shuxin Zheng, Guolin Ke, Di He, Yanming Shen, and Tie-Yan Liu. Do transformers really perform badly for graph representation? Advances in Neural Information Processing Systems, 34, 2021. +[53] Manzil Zaheer, Guru Guruganesh, Kumar Avinava Dubey, Joshua Ainslie, Chris Alberti, Santiago Ontanon, Philip Pham, Anirudh Ravula, Qifan Wang, Li Yang, et al. Big bird: Transformers for longer sequences. Advances in Neural Information Processing Systems, 33:17283–17297, 2020. +[54] Yanyi Zhang, Xinyu Li, Chunhui Liu, Bing Shuai, Yi Zhu, Biagio Brattoli, Hao Chen, Ivan Marsic, and Joseph Tighe. Vidtr: Video transformer without convolutions. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 13577–13587, 2021. + +# Checklist + +1. For all authors... + +(a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes] +(b) Did you describe the limitations of your work? [Yes] See Section 5. +(c) Did you discuss any potential negative societal impacts of your work? [No] Exploring Earth system forecasting has no negative societal impacts. +(d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes] + +2. If you are including theoretical results... + +(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] + +3. If you ran experiments... + +(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] +(b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes] +(c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [No] +(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] + +4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets... + +(a) If your work uses existing assets, did you cite the creators? [Yes] +(b) Did you mention the license of the assets? [Yes] +(c) Did you include any new assets either in the supplemental material or as a URL? [No] +(d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [N/A] +(e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [N/A] + +5. If you used crowdsourcing or conducted research with human subjects... + +(a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A] +(b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A] +(c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A] \ No newline at end of file diff --git a/md/dev/nZeVKeeFYf9/nZeVKeeFYf9.md b/md/dev/nZeVKeeFYf9/nZeVKeeFYf9.md new file mode 100644 index 0000000000000000000000000000000000000000..dbe04892957e94bd451abe2f7cb534f613024ab8 --- /dev/null +++ b/md/dev/nZeVKeeFYf9/nZeVKeeFYf9.md @@ -0,0 +1,295 @@ +# LORA: LOW-RANK ADAPTATION OF LARGE LANGUAGE MODELS + +Edward $\mathbf { H u } ^ { * }$ Yelong Shen∗ Phillip Wallis Zeyuan Allen-Zhu Yuanzhi Li Shean Wang Lu Wang Weizhu Chen + +Microsoft Corporation +edward.hu@mila.quebec +{yeshe, phwallis, zeyuana, swang, luw, wzchen}@microsoft.com +yuanzhil@andrew.cmu.edu + +# ABSTRACT + +An important paradigm of natural language processing consists of large-scale pretraining on general domain data and adaptation to particular tasks or domains. As we pre-train larger models, full fine-tuning, which retrains all model parameters, becomes less feasible. Using GPT-3 175B as an example – deploying independent instances of fine-tuned models, each with 175B parameters, is prohibitively expensive. We propose Low-Rank Adaptation, or LoRA, which freezes the pre-trained model weights and injects trainable rank decomposition matrices into each layer of the Transformer architecture, greatly reducing the number of trainable parameters for downstream tasks. Compared to GPT-3 175B fine-tuned with Adam, LoRA can reduce the number of trainable parameters by a factor of 10,000 and the GPU memory requirement by a factor of 3. LoRA performs on-par or better than finetuning in model quality on RoBERTa, DeBERTa, GPT-2, and GPT-3, despite having fewer trainable parameters, a higher training throughput, and, unlike adapters, no additional inference latency. We also provide an empirical investigation into rank-deficiency in language model adaptation, which sheds light on the efficacy of LoRA. We release a package that facilitates the integration of LoRA with PyTorch models and provide our implementations and model checkpoints for RoBERTa, DeBERTa, and GPT-2 at https://github.com/microsoft/LoRA. + +# 1 INTRODUCTION + +Many applications in natural language processing rely on adapting one large-scale, pre-trained language model to multiple downstream applications. Such adaptation is usually done via fine-tuning, which updates all the parameters of the pre-trained model. The major downside of fine-tuning is that the new model contains as many parameters as in the original model. As larger models are trained every few months, this changes from a mere “inconvenience” for GPT-2 (Radford et al., b) or RoBERTa large (Liu et al., 2019) to a critical deployment challenge for GPT-3 (Brown et al., 2020) with 175 billion trainable parameters.1 + +Many sought to mitigate this by adapting only some parameters or learning external modules for new tasks. This way, we only need to store and load a small number of task-specific parameters in addition to the pre-trained model for each task, greatly boosting the operational efficiency when deployed. However, existing techniques often introduce inference latency (Houlsby et al., 2019; Rebuffi et al., 2017) by extending model depth or reduce the model’s usable sequence length (Li & Liang, 2021; Lester et al., 2021; Hambardzumyan et al., 2020; Liu et al., 2021) (Section 3). More importantly, these method often fail to match the fine-tuning baselines, posing a trade-off between efficiency and model quality. + +![](images/740b6473a208b33b8afa798243d8a6e952feaf73ac5ca827bd5b354a23508adc.jpg) +Figure 1: Our reparametrization. We only train $A$ and $B$ . + +We take inspiration from Li et al. (2018a); Aghajanyan et al. (2020) which show that the learned over-parametrized models in fact reside on a low intrinsic dimension. We hypothesize that the change in weights during model adaptation also has a low “intrinsic rank”, leading to our proposed Low-Rank Adaptation (LoRA) approach. LoRA allows us to train some dense layers in a neural network indirectly by optimizing rank decomposition matrices of the dense layers’ change during adaptation instead, while keeping the pre-trained weights frozen, as shown in Figure 1. Using GPT-3 175B as an example, we show that a very low rank (i.e., $r$ in Figure 1 can be one or two) suffices even when the full rank (i.e., $d ,$ ) is as high as 12,288, making LoRA both storage- and compute-efficient. + +LoRA possesses several key advantages. + +• A pre-trained model can be shared and used to build many small LoRA modules for different tasks. We can freeze the shared model and efficiently switch tasks by replacing the matrices $A$ and $B$ in Figure 1, reducing the storage requirement and task-switching overhead significantly. +• LoRA makes training more efficient and lowers the hardware barrier to entry by up to 3 times when using adaptive optimizers since we do not need to calculate the gradients or maintain the optimizer states for most parameters. Instead, we only optimize the injected, much smaller low-rank matrices. +• Our simple linear design allows us to merge the trainable matrices with the frozen weights when deployed, introducing no inference latency compared to a fully fine-tuned model, by construction. +• LoRA is orthogonal to many prior methods and can be combined with many of them, such as prefix-tuning. We provide an example in Appendix H. + +Terminologies and Conventions We make frequent references to the Transformer architecture and use the conventional terminologies for its dimensions. We call the input and output dimension size of a Transformer layer $d _ { m o d e l }$ . We use $W _ { q }$ , $W _ { k }$ , $W _ { v }$ , and $W _ { o }$ to refer to the query/key/value/output projection matrices in the self-attention module. $W$ or $W _ { 0 }$ refers to a pretrained weight matrix and $\Delta W$ its accumulated gradient update during adaptation. We use $r$ to denote the rank of a LoRA module. We follow the conventions set out by (Vaswani et al., 2017; Brown et al., 2020) and use Adam (Loshchilov & Hutter, 2019; Kingma & Ba, 2017) for model optimization and use a Transformer MLP feedforward dimension $d _ { f f n } = 4 \times d _ { m o d e l }$ . + +# 2 PROBLEM STATEMENT + +While our proposal is agnostic to training objective, we focus on conditional language modeling as our motivating use case. Below is a brief description of the language modeling problem and, in particular, the maximization of conditional probabilities given a task-specific prompt. + +Suppose we are given a pre-trained autoregressive language model $P _ { \Phi } ( y | x )$ parametrized by $\Phi$ . For instance, $P _ { \Phi } ( y | x )$ can be a generic multi-task learner such as GPT (Radford et al., b; Brown et al., 2020) based on the Transformer architecture (Vaswani et al., 2017). Consider adapting this pre-trained model to downstream conditional text generation tasks, such as summarization, machine reading comprehension (MRC), and natural language to SQL (NL2SQL). Each downstream task is represented by a training dataset of context-target pairs: $\mathcal { Z } = \{ ( x _ { i } , y _ { i } ) \} _ { i = 1 , \dots , N }$ , where both $x _ { i }$ and $y _ { i }$ are sequences of tokens. For example, in NL2SQL, $x _ { i }$ is a natural language query and $y _ { i }$ its corresponding SQL command; for summarization, $x _ { i }$ is the content of an article and $y _ { i }$ its summary. + +During full fine-tuning, the model is initialized to pre-trained weights $\Phi _ { 0 }$ and updated to $\Phi _ { 0 } + \Delta \Phi$ by repeatedly following the gradient to maximize the conditional language modeling objective: + +$$ +\operatorname* { m a x } _ { \Phi } \sum _ { ( x , y ) \in \mathcal { Z } } \sum _ { t = 1 } ^ { | y | } \log \left( P _ { \Phi } ( y _ { t } | x , y _ { < t } ) \right) +$$ + +One of the main drawbacks for full fine-tuning is that for each downstream task, we learn a different set of parameters $\Delta \Phi$ whose dimension $| \Delta \Phi |$ equals $| \Phi _ { 0 } |$ . Thus, if the pre-trained model is large (such as GPT-3 with $| \Phi _ { 0 } | \approx 1 7 5$ Billion), storing and deploying many independent instances of fine-tuned models can be challenging, if at all feasible. + +In this paper, we adopt a more parameter-efficient approach, where the task-specific parameter increment $\Delta \Phi = \Delta \Phi ( \Theta )$ is further encoded by a much smaller-sized set of parameters $\Theta$ with $| \Theta | \ll | \Phi _ { 0 } |$ . The task of finding $\Delta \Phi$ thus becomes optimizing over $\Theta$ : + +$$ +\operatorname* { m a x } _ { \Theta } \sum _ { ( x , y ) \in \mathcal { Z } } \sum _ { t = 1 } ^ { | y | } \log \left( p _ { \Phi _ { 0 } + \Delta \Phi ( \Theta ) } ( y _ { t } | x , y _ { < t } ) \right) +$$ + +In the subsequent sections, we propose to use a low-rank representation to encode $\Delta \Phi$ that is both compute- and memory-efficient. When the pre-trained model is GPT-3 175B, the number of trainable parameters $| \Theta |$ can be as small as $0 . 0 1 \%$ of $| \Phi _ { 0 } |$ . + +# 3 AREN’T EXISTING SOLUTIONS GOOD ENOUGH? + +The problem we set out to tackle is by no means new. Since the inception of transfer learning, dozens of works have sought to make model adaptation more parameter- and compute-efficient. See Section 6 for a survey of some of the well-known works. Using language modeling as an example, there are two prominent strategies when it comes to efficient adaptations: adding adapter layers (Houlsby et al., 2019; Rebuffi et al., 2017; Pfeiffer et al., 2021; Ruckl ¨ e et al., 2020) or optimizing some forms ´ of the input layer activations (Li & Liang, 2021; Lester et al., 2021; Hambardzumyan et al., 2020; Liu et al., 2021). However, both strategies have their limitations, especially in a large-scale and latency-sensitive production scenario. + +Adapter Layers Introduce Inference Latency There are many variants of adapters. We focus on the original design by Houlsby et al. (2019) which has two adapter layers per Transformer block and a more recent one by Lin et al. (2020) which has only one per block but with an additional LayerNorm (Ba et al., 2016). While one can reduce the overall latency by pruning layers or exploiting multi-task settings (Ruckl ¨ e et al., 2020; Pfeiffer et al., 2021), there is no direct ways to bypass ´ the extra compute in adapter layers. This seems like a non-issue since adapter layers are designed to have few parameters (sometimes ${ < } 1 \%$ of the original model) by having a small bottleneck dimension, which limits the FLOPs they can add. However, large neural networks rely on hardware parallelism to keep the latency low, and adapter layers have to be processed sequentially. This makes a difference in the online inference setting where the batch size is typically as small as one. In a generic scenario without model parallelism, such as running inference on GPT-2 (Radford et al., b) medium on a single GPU, we see a noticeable increase in latency when using adapters, even with a very small bottleneck dimension (Table 1). + +
Batch Size Sequence Length 032 512 0.5M16 256 11M1 128 11M
Fine-Tune/LoRA1449.4±0.8338.0±0.619.8±2.7
AdapterL1482.0±1.0 (+2.2%)354.8±0.5 (+5.0%)23.9±2.1 (+20.7%)
AdapterH1492.2±1.0 (+3.0%)366.3±0.5 (+8.4%)25.8±2.2 (+30.3%)
+ +Table 1: Infernece latency of a single forward pass in GPT-2 medium measured in milliseconds, averaged over 100 trials. We use an NVIDIA Quadro RTX8000. “ $\left| \Theta \right|$ ” denotes the number of trainable parameters in adapter layers. AdapterL and AdapterH are two variants of adapter tuning, which we describe in Section 5.1. The inference latency introduced by adapter layers can be significant in an online, short-sequence-length scenario. See the full study in Appendix C. + +This problem gets worse when we need to shard the model as done in Shoeybi et al. (2020); Lepikhin et al. (2020), because the additional depth requires more synchronous GPU operations such as AllReduce and Broadcast, unless we store the adapter parameters redundantly many times. + +Directly Optimizing the Prompt is Hard The other direction, as exemplified by prefix tuning (Li & Liang, 2021), faces a different challenge. We observe that prefix tuning is difficult to optimize and that its performance changes non-monotonically in trainable parameters, confirming similar observations in the original paper. More fundamentally, reserving a part of the sequence length for adaptation necessarily reduces the sequence length available to process a downstream task, which we suspect makes tuning the prompt underperform other methods. We defer the study on task performance to Section 5. + +# 4 OUR METHOD + +We describe the simple design of LoRA and its practical benefits. The principles outlined here apply to any dense layers in deep learning models, though we only focus on certain weights in Transformer language models in our experiments as the motivating use case. + +# 4.1 LOW-RANK-PARAMETRIZED UPDATE MATRICES + +A neural network contains many dense layers which perform matrix multiplication. The weight matrices in these layers typically have full ranks. When adapting to a specific task, Aghajanyan et al. (2020) shows that the pre-trained language models have a low “instrisic dimension” and can still learn efficiently despite a random projection to a smaller subspace. Inspired by this, we hypothesize the updates to the weights also have a low “intrinsic rank” during adaptation. For a pre-trained weight matrix $W _ { 0 } \in \mathbb { R } ^ { d \times \widetilde { k } }$ , we constrain its update by representing the latter with a low-rank decomposition $W _ { 0 } + \Delta W = W _ { 0 } + B A$ , where $\bar { \boldsymbol { B } } \in \mathbb { R } ^ { \bar { d } \times r } , \dot { \boldsymbol { A } } \in \mathbb { R } ^ { r \times \breve { k } }$ , and the rank $r \ll \operatorname* { m i n } ( d , k )$ . During training, $W _ { 0 }$ is frozen and does not receive gradient updates, while $A$ and $B$ contain trainable parameters. Note both $W _ { 0 }$ and $\Delta W = B A$ are multiplied with the same input, and their respective output vectors are summed coordinate-wise. For $h = W _ { 0 } x$ , our modified forward pass yields: + +$$ +h = W _ { 0 } x + \Delta W x = W _ { 0 } x + B A x +$$ + +We illustrate our reparametrization in Figure 1. We use a random Gaussian initialization for $A$ and zero for $B$ , so $\Delta W = B A$ is zero at the beginning of training. We then scale $\Delta W x$ by $\frac { \alpha } { r }$ , where $\alpha$ is a constant in $r$ . When optimizing with Adam, tuning $\alpha$ is roughly the same as tuning the learning rate if we scale the initialization appropriately. As a result, we simply set $\alpha$ to the first $r$ we try and do not tune it. This scaling helps to reduce the need to retune hyperparameters when we vary $r$ (Yang & Hu, 2021). + +A Generalization of Full Fine-tuning. A more general form of fine-tuning allows the training of a subset of the pre-trained parameters. LoRA takes a step further and does not require the accumulated gradient update to weight matrices to have full ranks during adaptation. This means that when applying LoRA to all weight matrices and training all biases2, we roughly recover the expressiveness of full fine-tuning by setting the LoRA rank $r$ to the rank of the pre-trained weight matrices. In other words, as we increase the number of trainable parameters 3, training LoRA roughly converges to training the original model, while adapter-based methods converges to an MLP and prefix-based methods to a model that cannot take long input sequences. + +No Additional Inference Latency. When deployed in production, we can explicitly compute and store $W = W _ { 0 } + B A$ and perform inference as usual. Note that both $W _ { 0 }$ and $B A$ are in $\mathbb { R } ^ { d \times k }$ . When we need to switch to another downstream task, we can recover $W _ { 0 }$ by subtracting $B A$ and then adding a different $B ^ { \prime } A ^ { \prime }$ , a quick operation with very little memory overhead. Critically, this guarantees that we do not introduce any additional latency during inference compared to a fine-tuned model by construction. + +# 4.2 APPLYING LORA TO TRANSFORMER + +In principle, we can apply LoRA to any subset of weight matrices in a neural network to reduce the number of trainable parameters. In the Transformer architecture, there are four weight matrices in the self-attention module $( W _ { q } , W _ { k } , W _ { v } , W _ { o } )$ and two in the MLP module. We treat $W _ { q }$ (or $W _ { k }$ , $W _ { v . }$ ) as a single matrix of dimension $d _ { m o d e l } \times d _ { m o d e l }$ , even though the output dimension is usually sliced into attention heads. We limit our study to only adapting the attention weights for downstream tasks and freeze the MLP modules (so they are not trained in downstream tasks) both for simplicity and parameter-efficiency.We further study the effect on adapting different types of attention weight matrices in a Transformer in Section B.1. We leave the empirical investigation of adapting the MLP layers, LayerNorm layers, and biases to a future work. + +Practical Benefits and Limitations. The most significant benefit comes from the reduction in memory and storage usage. For a large Transformer trained with Adam, we reduce that VRAM usage by up to $2 / 3$ if $r \ll d _ { m o d e l }$ as we do not need to store the optimizer states for the frozen parameters. On GPT-3 175B, we reduce the VRAM consumption during training from $1 . 2 \mathrm { T B }$ to 350GB. With $r = 4$ and only the query and value projection matrices being adapted, the checkpoint size is reduced by roughly $1 0 { , } 0 0 0 \times$ (from 350GB to 35MB)4. This allows us to train with significantly fewer GPUs and avoid I/O bottlenecks. Another benefit is that we can switch between tasks while deployed at a much lower cost by only swapping the LoRA weights as opposed to all the parameters. This allows for the creation of many customized models that can be swapped in and out on the fly on machines that store the pre-trained weights in VRAM. We also observe a $2 5 \%$ speedup during training on GPT-3 175B compared to full fine-tuning5 as we do not need to calculate the gradient for the vast majority of the parameters. See Appendix L for how to calculate gradient when using LoRA. + +LoRA also has its limitations. For example, it is not straightforward to batch inputs to different tasks with different $A$ and $B$ in a single forward pass, if one chooses to absorb $A$ and $B$ into $W$ to eliminate additional inference latency. Though it is possible to not merge the weights and dynamically choose the LoRA modules to use for samples in a batch for scenarios where latency is not critical. + +# 5 EMPIRICAL EXPERIMENTS + +We evaluate the downstream task performance of LoRA on RoBERTa (Liu et al., 2019), DeBERTa (He et al., 2021), and GPT-2 (Radford et al., b), before scaling up to GPT-3 175B (Brown et al., 2020). Our experiments cover a wide range of tasks, from natural language understanding (NLU) to generation (NLG). Specifically, we evaluate on the GLUE (Wang et al., 2019) benchmark for RoBERTa and DeBERTa. We follow the setup of Li & Liang (2021) on GPT-2 for a direct comparison and add WikiSQL (Zhong et al., 2017) (NL to SQL queries) and SAMSum (Gliwa et al., 2019) (conversation summarization) for large-scale experiments on GPT-3. See Appendix D for more details on the datasets we use. We use NVIDIA Tesla V100 for all experiments. + +# 5.1 BASELINES + +To compare with other baselines broadly, we replicate the setups used by prior work and reuse their reported numbers whenever possible. This, however, means that some baselines might only appear in certain experiments. We point out that for most tasks, our goal is not to compete with SOTA because 1) for tasks such as WikiSQL, SOTA uses specialized SQL-aware decoders, and; 2) SOTA makes frequent use of techniques such as ensembling and adversarial training, which might confound our study on adaptation. Thus, we focus on a scenario where we are given a powerful pre-trained autoregressive language model and use as few task-specific modifications as possible. See Appendix E for how we count the number of trainable parameters for different baselines. + +Fine-Tuning (FT) is a common approach for adaptation. During fine-tuning, the model is initialized to the pre-trained weights and biases, and all model parameters undergo gradient updates.A simple variant is to update only some layers while freezing others. We include one such baseline reported in prior work (Li & Liang, 2021) on GPT-2, which adapts just the last two layers $( \mathbf { F T } ^ { \mathbf { I o p 2 } } )$ . + +Table 2: $\mathrm { R o B E R T a _ { b a s e } }$ , $\mathrm { R o B E R T a _ { l a r g e } }$ , and $\mathrm { D e B E R T a _ { X X L } }$ with different adaptation methods on the GLUE benchmark. We report the overall (matched and mismatched) accuracy for MNLI, Matthew’s correlation for CoLA, Pearson correlation for STS-B, and accuracy for other tasks. Higher is better for all metrics. \* indicates numbers published in prior works. $\dagger$ indicates runs configured in a setup similar to Houlsby et al. (2019) for a fair comparison. + +
Model & Method|# TrainableParameters MNLIMRPCCoLA
RoBbase (FT)*125.0M87.6SST-2 94.890.263.6QNLI 92.8QQP 91.9RTESTS-BAvg.
RoBbase (BitFit)*0.1M84.793.792.762.091.884.078.7 81.591.2 90.886.4 85.2
RoBbase (Adpt)*0.3M87.1±.094.2±.188.5±1.160.8±.493.1±.190.2±.071.5±2.789.7±.384.4
RoBbase (AdptD)*0.9M87.3±.194.7±.388.4±.162.6±.993.0±.290.6±.075.9±2.290.3±.185.4
RoBbase (LoRA)0.3M87.5±.395.1±.289.7±.763.4±1.293.3±.390.8±.186.6±.791.5±.287.2
RoBlarge (FT)*355.0M90.296.490.968.094.792.286.692.488.9
RoBlarge (LoRA)0.8M90.6±.296.2±.590.9±1.268.2±1.994.9±.391.6±.187.4±2.592.6±.289.0
RoBlarge (Adpt)t3.0M|90.2±.396.1±.390.2±.768.3±1.094.8±.291.9±.183.8±2.992.1±.788.4
RoBlarge (Adpt)t0.8M90.5±.396.6±.289.7±1.267.8±2.594.8±.391.7±.280.1±2.991.9±.487.9
RoBlarge (Adpt)+6.0M89.9±.596.2±.388.7±2.966.5±4.494.7±.292.1±.183.4±1.191.0±1.787.8
RoBlarge (Adpt)+0.8M90.3±396.3±.587.7±1.766.3±2.094.7±.291.5±.172.9±2.991.5±.586.4
RoBlarge (LoRA)t0.8M90.6±.296.2±.590.2±1.068.2±1.994.8±.391.6±.285.2±1.192.3±.588.6
DeBxxL (FT)*1500.0M91.897.292.072.096.092.793.992.991.1
DeBxxL (LoRA)4.7M91.9±.296.9±.292.6±.672.4±1.196.0±.192.9±.194.9±.493.0±.291.3
+ +Bias-only or BitFit is a baseline where we only train the bias vectors while freezing everything else. +Contemporarily, this baseline has also been studied by BitFit (Zaken et al., 2021). + +Prefix-embedding tuning (PreEmbed) inserts special tokens among the input tokens. These special tokens have trainable word embeddings and are generally not in the model’s vocabulary. Where to place such tokens can have an impact on performance. We focus on “prefixing”, which prepends such tokens to the prompt, and “infixing”, which appends to the prompt; both are discussed in Li & Liang (2021). + +Prefix-layer tuning (PreLayer) is an extension to prefix-embedding tuning. Instead of just learning the word embeddings (or equivalently, the activations after the embedding layer) for some special tokens, we learn the activations after every Transformer layer. The activations computed from previous layers are simply replaced by trainable ones. + +Adapter tuning as proposed in Houlsby et al. (2019) inserts adapter layers between the selfattention module (and the MLP module) and the subsequent residual connection. There are two fully connected layers with biases in an adapter layer with a nonlinearity in between. We call this original design AdapterH. Recently, Lin et al. (2020) proposed a more efficient design with the adapter layer applied only after the MLP module and after a LayerNorm. We call it AdapterL. This is very similar to another deign proposed in Pfeiffer et al. (2021), which we call AdapterP. We also include another baseline call AdapterDrop (Ruckl ¨ e et al., 2020) which drops some adapter layers for ´ greater efficiency (AdapterD). We cite numbers from prior works whenever possible to maximize the number of baselines we compare with; they are in rows with an asterisk $( ^ { * } )$ in the first column. + +LoRA adds trainable pairs of rank decomposition matrices in parallel to existing weight matrices. +As mentioned in Section 4.2, we only apply LoRA to $W _ { q }$ and $W _ { v }$ in most experiments for simplicity. + +# 5.2 ROBERTA BASE/LARGE + +RoBERTa (Liu et al., 2019) optimized the pre-training recipe originally proposed in BERT (Devlin et al., 2019a) and boosted the latter’s task performance without introducing many more trainable parameters. While RoBERTa has been overtaken by much larger models on NLP leaderboards such as the GLUE benchmark (Wang et al., 2019) in recent years, it remains a competitive and popular pre-trained model for its size among practitioners. We take the pre-trained RoBERTa base (125M) and RoBERTa large (355M) from the HuggingFace Transformers library (Wolf et al., 2020) + +Table 3: GPT-2 medium (M) and large (L) with different adaptation methods on the E2E NLG Challenge. For all metrics, higher is better. LoRA outperforms several baselines with comparable or fewer trainable parameters. Confidence intervals are shown for experiments we ran. \* indicates numbers published in prior works. + +
Model&Method# Trainable ParametersE2E NLG Challenge
BLEUNISTMETROUGE-LCIDEr
GPT-2 M (FT)*354.92M68.28.6246.271.02.47
GPT-2 M (AdapterL)*0.37M66.38.4145.069.82.40
GPT-2 M (AdapterL)*11.09M68.98.7146.171.32.47
GPT-2 M (AdapterH)11.09M67.3±.68.50±.0746.0±.270.7±.22.44±.01
GPT-2 M (FTTop2)*25.19M68.18.5946.070.82.41
GPT-2 M (PreLayer)*0.35M69.78.8146.171.42.49
GPT-2 M (LoRA)0.35M70.4±.18.85±.0246.8±.271.8±.12.53±.02
GPT-2 L (FT)*774.03M68.58.7846.069.92.45
GPT-2 L (Adapter)0.88M69.1±.18.68±.0346.3±.071.4±.22.49±.0
GPT-2 L (AdapterL)23.00M68.9±.38.70±.0446.1±.171.3±.22.45±.02
GPT-2 L (PreLayer)*0.77M70.38.8546.271.72.47
GPT-2 L (LoRA)0.77M70.4±.18.89±.0246.8±.272.0±.22.47±.02
+ +and evaluate the performance of different efficient adaptation approaches on tasks from the GLUE benchmark. We also replicate Houlsby et al. (2019) and Pfeiffer et al. (2021) according to their setup. To ensure a fair comparison, we make two crucial changes to how we evaluate LoRA when comparing with adapters. First, we use the same batch size for all tasks and use a sequence length of 128 to match the adapter baselines. Second, we initialize the model to the pre-trained model for MRPC, RTE, and STS-B, not a model already adapted to MNLI like the fine-tuning baseline. Runs following this more restricted setup from Houlsby et al. (2019) are labeled with $\dagger$ . The result is presented in Table 2 (Top Three Sections). See Section F.1 for details on the hyperparameters used. + +# 5.3 DEBERTA XXL + +DeBERTa (He et al., 2021) is a more recent variant of BERT that is trained on a much larger scale and performs very competitively on benchmarks such as GLUE (Wang et al., 2019) and SuperGLUE (Wang et al., 2020). We evaluate if LoRA can still match the performance of a fully fine-tuned DeBERTa XXL (1.5B) on GLUE. The result is presented in Table 2 (Bottom Section). See Section F.2 for details on the hyperparameters used. + +# 5.4 GPT-2 MEDIUM/LARGE + +Having shown that LoRA can be a competitive alternative to full fine-tuning on NLU, we hope to answer if LoRA still prevails on NLG models, such as GPT-2 medium and large (Radford et al., b). We keep our setup as close as possible to Li & Liang (2021) for a direct comparison. Due to space constraint, we only present our result on E2E NLG Challenge (Table 3) in this section. See Section I.1 for results on WebNLG (Gardent et al., 2017) and DART (Nan et al., 2020). We include a list of the hyperparameters used in Section F.3. + +# 5.5 SCALING UP TO GPT-3 175B + +As a final stress test for LoRA, we scale up to GPT-3 with 175 billion parameters. Due to the high training cost, we only report the typical standard deviation for a given task over random seeds, as opposed to providing one for every entry. See Section F.4 for details on the hyperparameters used. + +As shown in Table 4, LoRA matches or exceeds the fine-tuning baseline on all three datasets. Note that not all methods benefit monotonically from having more trainable parameters, as shown in Figure 2. We observe a significant performance drop when we use more than 256 special tokens for prefix-embedding tuning or more than 32 special tokens for prefix-layer tuning. This corroborates similar observations in Li & Liang (2021). While a thorough investigation into this phenomenon is out-of-scope for this work, we suspect that having more special tokens causes the input distribution to shift further away from the pre-training data distribution. Separately, we investigate the performance of different adaptation approaches in the low-data regime in Section I.3. + +Table 4: Performance of different adaptation methods on GPT-3 175B. We report the logical form validation accuracy on WikiSQL, validation accuracy on MultiNLI-matched, and Rouge-1/2/L on SAMSum. LoRA performs better than prior approaches, including full fine-tuning. The results on WikiSQL have a fluctuation around $\pm 0 . 5 \%$ , MNLI-m around $\pm 0 . 1 \%$ , and SAMSum around $\pm 0 . 2 / \pm 0 . 2 / \pm 0 . 1$ for the three metrics. + +
Model&Method# Trainable ParametersWikiSQLMNLI-mSAMSum
Acc.(%)Acc. (%)R1/R2/RL
GPT-3 (FT)175,255.8M73.889.552.0/28.0/44.5
GPT-3 (BitFit)14.2M71.391.051.3/27.4/43.5
GPT-3 (PreEmbed)3.2M63.188.648.3/24.2/40.5
GPT-3 (PreLayer)20.2M70.189.550.8/27.3/43.5
GPT-3 (AdapterH)7.1M71.989.853.0/28.9/44.8
GPT-3 (AdapterH)40.1M73.291.553.2/29.0/45.1
GPT-3 (LoRA)4.7M73.491.753.8/29.8/45.9
GPT-3 (LoRA)37.7M74.091.653.4/29.2/45.1
+ +![](images/b88dfb262c2376a846cafa7a739e919878a7666c268a9332c965b909a13a8482.jpg) +Figure 2: GPT-3 175B validation accuracy vs. number of trainable parameters of several adaptation methods on WikiSQL and MNLI-matched. LoRA exhibits better scalability and task performance. See Section I.2 for more details on the plotted data points. + +# 6 RELATED WORKS + +Transformer Language Models. Transformer (Vaswani et al., 2017) is a sequence-to-sequence architecture that makes heavy use of self-attention. Radford et al. (a) applied it to autoregressive language modeling by using a stack of Transformer decoders. Since then, Transformer-based language models have dominated NLP, achieving the state-of-the-art in many tasks. A new paradigm emerged with BERT (Devlin et al., 2019b) and GPT-2 (Radford et al., b) – both are large Transformer language models trained on a large amount of text – where fine-tuning on task-specific data after pretraining on general domain data provides a significant performance gain compared to training on task-specific data directly. Training larger Transformers generally results in better performance and remains an active research direction. GPT-3 (Brown et al., 2020) is the largest single Transformer language model trained to-date with 175B parameters. + +Prompt Engineering and Fine-Tuning. While GPT-3 175B can adapt its behavior with just a few additional training examples, the result depends heavily on the input prompt (Brown et al., 2020). This necessitates an empirical art of composing and formatting the prompt to maximize a model’s performance on a desired task, which is known as prompt engineering or prompt hacking. + +Fine-tuning retrains a model pre-trained on general domains to a specific task Devlin et al. (2019b); Radford et al. (a). Variants of it include learning just a subset of the parameters Devlin et al. (2019b); Collobert & Weston (2008), yet practitioners often retrain all of them to maximize the downstream performance. However, the enormity of GPT-3 175B makes it challenging to perform fine-tuning in the usual way due to the large checkpoint it produces and the high hardware barrier to entry since it has the same memory footprint as pre-training. + +Parameter-Efficient Adaptation. Many have proposed inserting adapter layers between existing layers in a neural network (Houlsby et al., 2019; Rebuffi et al., 2017; Lin et al., 2020). Our method uses a similar bottleneck structure to impose a low-rank constraint on the weight updates. The key functional difference is that our learned weights can be merged with the main weights during inference, thus not introducing any latency, which is not the case for the adapter layers (Section 3). A comtenporary extension of adapter is COMPACTER (Mahabadi et al., 2021), which essentially parametrizes the adapter layers using Kronecker products with some predetermined weight sharing scheme. Similarly, combining LoRA with other tensor product-based methods could potentially improve its parameter efficiency, which we leave to future work. More recently, many proposed optimizing the input word embeddings in lieu of fine-tuning, akin to a continuous and differentiable generalization of prompt engineering (Li & Liang, 2021; Lester et al., 2021; Hambardzumyan et al., 2020; Liu et al., 2021). We include comparisons with Li & Liang (2021) in our experiment section. However, this line of works can only scale up by using more special tokens in the prompt, which take up available sequence length for task tokens when positional embeddings are learned. + +Low-Rank Structures in Deep Learning. Low-rank structure is very common in machine learning. A lot of machine learning problems have certain intrinsic low-rank structure (Li et al., 2016; Cai et al., 2010; Li et al., 2018b; Grasedyck et al., 2013). Moreover, it is known that for many deep learning tasks, a heavily over-parametrized neural network will exhibit low-rank properties after training (Oymak et al., 2019). Some prior works even explicitly impose the low-rank constraint when training the original neural network (Sainath et al., 2013; Povey et al., 2018; Zhang et al., 2014; Jaderberg et al., 2014; Zhao et al., 2016; Khodak et al., 2021; Denil et al., 2014); however, to the best of our knowledge, none of these works considers low-rank update to a frozen model for adaptation to downstream tasks. In theory literature, it is known that neural networks outperform other classical learning methods, including the corresponding (finite-width) neural tangent kernels (Allen-Zhu et al., 2019; Li & Liang, 2018) when the underlying concept class has certain low-rank structure (Ghorbani et al., 2020; Allen-Zhu & Li, 2019; Allen-Zhu & Li, 2020a). Another theory result in Allen-Zhu & Li (2020b) suggests that low-rank adaptations can be useful for adversarial training. In sum, we believe that our proposed low-rank adaptation update is well-motivated by the literature. + +# 7 CONCLUSION AND FUTURE WORK + +Fine-tuning enormous language models is prohibitively expensive in terms of the hardware required and the storage/switching cost for hosting independent instances for different tasks. We propose LoRA, an efficient adaptation strategy that neither introduces inference latency nor reduces input sequence length while retaining high model quality. Importantly, it allows for quick task-switching when deployed as a service by sharing the vast majority of the model parameters. While we focused on Transformer language models, the proposed principles are generally applicable to any neural networks with dense layers. + +There are many directions for future works. 1) LoRA can be combined with other efficient adaptation methods, potentially providing orthogonal improvement. 2) The mechanism behind fine-tuning or LoRA is far from clear – how are features learned during pre-training transformed to do well on downstream tasks? We believe that LoRA makes it more tractable to answer this than full finetuning. 3) We mostly depend on heuristics to select the weight matrices to apply LoRA to. Are there more principled ways to do it? 4) Finally, the rank-deficiency of $\Delta W$ suggests that $W$ could be rank-deficient as well, which can inspire future works. + +# REFERENCES + +Armen Aghajanyan, Luke Zettlemoyer, and Sonal Gupta. Intrinsic Dimensionality Explains the Effectiveness of Language Model Fine-Tuning. arXiv:2012.13255 [cs], December 2020. URL http://arxiv.org/abs/2012.13255. + +Zeyuan Allen-Zhu and Yuanzhi Li. What Can ResNet Learn Efficiently, Going Beyond Kernels? In NeurIPS, 2019. Full version available at http://arxiv.org/abs/1905.10337. + +Zeyuan Allen-Zhu and Yuanzhi Li. Backward feature correction: How deep learning performs deep learning. arXiv preprint arXiv:2001.04413, 2020a. + +Zeyuan Allen-Zhu and Yuanzhi Li. Feature purification: How adversarial training performs robust deep learning. arXiv preprint arXiv:2005.10190, 2020b. + +Zeyuan Allen-Zhu, Yuanzhi Li, and Zhao Song. A convergence theory for deep learning via overparameterization. In ICML, 2019. Full version available at http://arxiv.org/abs/1811. 03962. + +Jimmy Lei Ba, Jamie Ryan Kiros, and Geoffrey E. Hinton. Layer normalization, 2016. + +Tom B. Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah, Jared Kaplan, Prafulla Dhariwal, Arvind Neelakantan, Pranav Shyam, Girish Sastry, Amanda Askell, Sandhini Agarwal, Ariel Herbert-Voss, Gretchen Krueger, Tom Henighan, Rewon Child, Aditya Ramesh, Daniel M. Ziegler, Jeffrey Wu, Clemens Winter, Christopher Hesse, Mark Chen, Eric Sigler, Mateusz Litwin, Scott Gray, Benjamin Chess, Jack Clark, Christopher Berner, Sam McCandlish, Alec Radford, Ilya Sutskever, and Dario Amodei. Language Models are Few-Shot Learners. arXiv:2005.14165 [cs], July 2020. URL http://arxiv.org/abs/2005.14165. + +Jian-Feng Cai, Emmanuel J Candes, and Zuowei Shen. A singular value thresholding algorithm for \` matrix completion. SIAM Journal on optimization, 20(4):1956–1982, 2010. + +Daniel Cer, Mona Diab, Eneko Agirre, Inigo Lopez-Gazpio, and Lucia Specia. Semeval-2017 task 1: Semantic textual similarity multilingual and crosslingual focused evaluation. Proceedings of the 11th International Workshop on Semantic Evaluation (SemEval-2017), 2017. doi: 10.18653/ v1/s17-2001. URL http://dx.doi.org/10.18653/v1/S17-2001. + +Ronan Collobert and Jason Weston. A unified architecture for natural language processing: deep neural networks with multitask learning. In Proceedings of the 25th international conference on Machine learning, ICML ’08, pp. 160–167, New York, NY, USA, July 2008. Association for Computing Machinery. ISBN 978-1-60558-205-4. doi: 10.1145/1390156.1390177. URL https://doi.org/10.1145/1390156.1390177. + +Misha Denil, Babak Shakibi, Laurent Dinh, Marc’Aurelio Ranzato, and Nando de Freitas. Predicting parameters in deep learning, 2014. + +Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. Bert: Pre-training of deep bidirectional transformers for language understanding, 2019a. + +Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding. arXiv:1810.04805 [cs], May 2019b. URL http://arxiv.org/abs/1810.04805. arXiv: 1810.04805. + +William B. Dolan and Chris Brockett. Automatically constructing a corpus of sentential paraphrases. In Proceedings of the Third International Workshop on Paraphrasing (IWP2005), 2005. URL https://aclanthology.org/I05-5002. + +Claire Gardent, Anastasia Shimorina, Shashi Narayan, and Laura Perez-Beltrachini. The webnlg challenge: Generating text from rdf data. In Proceedings of the 10th International Conference on Natural Language Generation, pp. 124–133, 2017. + +Behrooz Ghorbani, Song Mei, Theodor Misiakiewicz, and Andrea Montanari. When do neural networks outperform kernel methods? arXiv preprint arXiv:2006.13409, 2020. + +Bogdan Gliwa, Iwona Mochol, Maciej Biesek, and Aleksander Wawer. Samsum corpus: A humanannotated dialogue dataset for abstractive summarization. CoRR, abs/1911.12237, 2019. URL http://arxiv.org/abs/1911.12237. + +Lars Grasedyck, Daniel Kressner, and Christine Tobler. A literature survey of low-rank tensor approximation techniques. GAMM-Mitteilungen, 36(1):53–78, 2013. + +Jihun Ham and Daniel D. Lee. Grassmann discriminant analysis: a unifying view on subspace-based learning. In ICML, pp. 376–383, 2008. URL https://doi.org/10.1145/1390156. 1390204. + +Karen Hambardzumyan, Hrant Khachatrian, and Jonathan May. WARP: Word-level Adversarial ReProgramming. arXiv:2101.00121 [cs], December 2020. URL http://arxiv.org/abs/ 2101.00121. arXiv: 2101.00121. + +Pengcheng He, Xiaodong Liu, Jianfeng Gao, and Weizhu Chen. Deberta: Decoding-enhanced bert with disentangled attention, 2021. + +Neil Houlsby, Andrei Giurgiu, Stanislaw Jastrzebski, Bruna Morrone, Quentin de Laroussilhe, Andrea Gesmundo, Mona Attariyan, and Sylvain Gelly. Parameter-Efficient Transfer Learning for NLP. arXiv:1902.00751 [cs, stat], June 2019. URL http://arxiv.org/abs/1902. 00751. + +Max Jaderberg, Andrea Vedaldi, and Andrew Zisserman. Speeding up convolutional neural networks with low rank expansions. arXiv preprint arXiv:1405.3866, 2014. + +Mikhail Khodak, Neil Tenenholtz, Lester Mackey, and Nicolo Fusi. Initialization and regularization \` of factorized neural layers, 2021. + +Diederik P. Kingma and Jimmy Ba. Adam: A method for stochastic optimization, 2017. + +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, 2020. + +Brian Lester, Rami Al-Rfou, and Noah Constant. The Power of Scale for Parameter-Efficient Prompt Tuning. arXiv:2104.08691 [cs], April 2021. URL http://arxiv.org/abs/2104.08691. arXiv: 2104.08691. + +Chunyuan Li, Heerad Farkhoor, Rosanne Liu, and Jason Yosinski. Measuring the Intrinsic Dimension of Objective Landscapes. arXiv:1804.08838 [cs, stat], April 2018a. URL http: //arxiv.org/abs/1804.08838. arXiv: 1804.08838. + +Xiang Lisa Li and Percy Liang. Prefix-Tuning: Optimizing Continuous Prompts for Generation. arXiv:2101.00190 [cs], January 2021. URL http://arxiv.org/abs/2101.00190. + +Yuanzhi Li and Yingyu Liang. Learning overparameterized neural networks via stochastic gradient descent on structured data. In Advances in Neural Information Processing Systems, 2018. + +Yuanzhi Li, Yingyu Liang, and Andrej Risteski. Recovery guarantee of weighted low-rank approximation via alternating minimization. In International Conference on Machine Learning, pp. 2358–2367. PMLR, 2016. + +Yuanzhi Li, Tengyu Ma, and Hongyang Zhang. Algorithmic regularization in over-parameterized matrix sensing and neural networks with quadratic activations. In Conference On Learning Theory, pp. 2–47. PMLR, 2018b. + +Zhaojiang Lin, Andrea Madotto, and Pascale Fung. Exploring versatile generative language model via parameter-efficient transfer learning. In Findings of the Association for Computational Linguistics: EMNLP 2020, pp. 441–459, Online, November 2020. Association for Computational Linguistics. doi: 10.18653/v1/2020.findings-emnlp.41. URL https://aclanthology. org/2020.findings-emnlp.41. + +Xiao Liu, Yanan Zheng, Zhengxiao Du, Ming Ding, Yujie Qian, Zhilin Yang, and Jie Tang. GPT Understands, Too. arXiv:2103.10385 [cs], March 2021. URL http://arxiv.org/abs/ 2103.10385. arXiv: 2103.10385. + +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, 2019. + +Ilya Loshchilov and Frank Hutter. Decoupled weight decay regularization. arXiv preprint arXiv:1711.05101, 2017. + +Ilya Loshchilov and Frank Hutter. Decoupled weight decay regularization, 2019. + +Rabeeh Karimi Mahabadi, James Henderson, and Sebastian Ruder. Compacter: Efficient low-rank hypercomplex adapter layers, 2021. + +Linyong Nan, Dragomir Radev, Rui Zhang, Amrit Rau, Abhinand Sivaprasad, Chiachun Hsieh, Xiangru Tang, Aadit Vyas, Neha Verma, Pranav Krishna, et al. Dart: Open-domain structured data record to text generation. arXiv preprint arXiv:2007.02871, 2020. + +Jekaterina Novikova, Ondˇrej Dusek, and Verena Rieser. The e2e dataset: New challenges for end-ˇ to-end generation. arXiv preprint arXiv:1706.09254, 2017. + +Samet Oymak, Zalan Fabian, Mingchen Li, and Mahdi Soltanolkotabi. Generalization guarantees for neural networks via harnessing the low-rank structure of the jacobian. arXiv preprint arXiv:1906.05392, 2019. + +Jonas Pfeiffer, Aishwarya Kamath, Andreas Ruckl ¨ e, Kyunghyun Cho, and Iryna Gurevych. Adapter-´ fusion: Non-destructive task composition for transfer learning, 2021. + +Daniel Povey, Gaofeng Cheng, Yiming Wang, Ke Li, Hainan Xu, Mahsa Yarmohammadi, and Sanjeev Khudanpur. Semi-orthogonal low-rank matrix factorization for deep neural networks. In Interspeech, pp. 3743–3747, 2018. + +Alec Radford, Karthik Narasimhan, Tim Salimans, and Ilya Sutskever. Improving Language Understanding by Generative Pre-Training. pp. 12, a. + +Alec Radford, Jeffrey Wu, Rewon Child, David Luan, Dario Amodei, and Ilya Sutskever. Language Models are Unsupervised Multitask Learners. pp. 24, b. + +Pranav Rajpurkar, Robin Jia, and Percy Liang. Know what you don’t know: Unanswerable questions for squad. CoRR, abs/1806.03822, 2018. URL http://arxiv.org/abs/1806.03822. + +Sylvestre-Alvise Rebuffi, Hakan Bilen, and Andrea Vedaldi. Learning multiple visual domains with residual adapters. arXiv:1705.08045 [cs, stat], November 2017. URL http://arxiv.org/ abs/1705.08045. arXiv: 1705.08045. + +Andreas Ruckl ¨ e, Gregor Geigle, Max Glockner, Tilman Beck, Jonas Pfeiffer, Nils Reimers, and ´ Iryna Gurevych. Adapterdrop: On the efficiency of adapters in transformers, 2020. + +Tara N Sainath, Brian Kingsbury, Vikas Sindhwani, Ebru Arisoy, and Bhuvana Ramabhadran. Lowrank matrix factorization for deep neural network training with high-dimensional output targets. In 2013 IEEE international conference on acoustics, speech and signal processing, pp. 6655– 6659. IEEE, 2013. + +Mohammad Shoeybi, Mostofa Patwary, Raul Puri, Patrick LeGresley, Jared Casper, and Bryan Catanzaro. Megatron-lm: Training multi-billion parameter language models using model parallelism, 2020. + +Richard Socher, Alex Perelygin, Jean Wu, Jason Chuang, Christopher D. Manning, Andrew $\mathrm { N g }$ , and Christopher Potts. Recursive deep models for semantic compositionality over a sentiment treebank. In Proceedings of the 2013 Conference on Empirical Methods in Natural Language Processing, pp. 1631–1642, Seattle, Washington, USA, October 2013. Association for Computational Linguistics. URL https://aclanthology.org/D13-1170. + +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. + +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. + +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, 2020. + +Alex Warstadt, Amanpreet Singh, and Samuel R Bowman. Neural network acceptability judgments. arXiv preprint arXiv:1805.12471, 2018. + +Adina Williams, Nikita Nangia, and Samuel Bowman. A broad-coverage challenge corpus for sentence understanding through inference. In Proceedings of the 2018 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long Papers), pp. 1112–1122, New Orleans, Louisiana, June 2018. Association for Computational Linguistics. doi: 10.18653/v1/N18-1101. URL https://www.aclweb. org/anthology/N18-1101. + +Thomas Wolf, Lysandre Debut, Victor Sanh, Julien Chaumond, Clement Delangue, Anthony Moi, Pierric Cistac, Tim Rault, Remi Louf, Morgan Funtowicz, Joe Davison, Sam Shleifer, Patrick ´ von Platen, Clara Ma, Yacine Jernite, Julien Plu, Canwen Xu, Teven Le Scao, Sylvain Gugger, Mariama Drame, Quentin Lhoest, and Alexander M. Rush. Transformers: State-of-the-art natural language processing. In Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing: System Demonstrations, pp. 38–45, Online, October 2020. Association for Computational Linguistics. URL https://www.aclweb.org/anthology/ 2020.emnlp-demos.6. + +Greg Yang and Edward J. Hu. Feature Learning in Infinite-Width Neural Networks. arXiv:2011.14522 [cond-mat], May 2021. URL http://arxiv.org/abs/2011.14522. arXiv: 2011.14522. + +Elad Ben Zaken, Shauli Ravfogel, and Yoav Goldberg. Bitfit: Simple parameter-efficient fine-tuning for transformer-based masked language-models, 2021. + +Yu Zhang, Ekapol Chuangsuwanich, and James Glass. Extracting deep neural network bottleneck features using low-rank matrix factorization. In 2014 IEEE international conference on acoustics, speech and signal processing (ICASSP), pp. 185–189. IEEE, 2014. + +Yong Zhao, Jinyu Li, and Yifan Gong. Low-rank plus diagonal adaptation for deep neural networks. In 2016 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP), pp. 5005–5009. IEEE, 2016. + +Victor Zhong, Caiming Xiong, and Richard Socher. Seq2sql: Generating structured queries from natural language using reinforcement learning. CoRR, abs/1709.00103, 2017. URL http:// arxiv.org/abs/1709.00103. \ No newline at end of file diff --git a/md/dev/nareqzplSc9/nareqzplSc9.md b/md/dev/nareqzplSc9/nareqzplSc9.md new file mode 100644 index 0000000000000000000000000000000000000000..45c51bb079cf4e95cf06f189da0c2093616677e7 --- /dev/null +++ b/md/dev/nareqzplSc9/nareqzplSc9.md @@ -0,0 +1,620 @@ +# HIGH-DIMENSIONAL CONTINUUM ARMED AND HIGHDIMENSIONAL CONTEXTUAL BANDIT: WITH APPLICATIONS TO ASSORTMENT AND PRICING + +Anonymous authors Paper under double-blind review + +# ABSTRACT + +The bandit problem with high-dimensional continuum arms and high-dimensional contextual covariates is often faced by decision-makers but remains unsolved. Recent developments in contextual bandit problems focus on the setting where the number of arms are small but are impracticable with high-dimensional continuous arm spaces. To bridge the gap, we propose a novel model for the high-dimensional continuum armed and high-dimensional contextual bandit problem that captures the effect of the arm and covariates on the reward via a low-rank representation matrix. The representation matrix is endowed with interpretability and predictive power. We further propose an efficient bandit algorithm based on a low-rank matrix estimator with theoretical justifications. The generality of our model allows wide applications including business and healthcare. In particular, we apply our method to assortment and pricing, both of which are important decisions for firms such as online retailers. Our method can solve the assortment-pricing problem simultaneously while most existing methods address them separately. We demonstrate the effectiveness of our method to jointly optimize assortment and pricing for revenue maximization for a giant online retailer. + +# 1 INTRODUCTION + +The bandit problem dates back to when Robbins (1952) formulated the problem as the sequential design of experiments and has been studied to a great extent recently due to the demand for online decision-making, especially from e-commerce and health care. A decision-maker chooses an action (arm) at each round and observes a reward and the goal is to act strategically so as to find an optimal action that maximizes the long-term reward without sacrificing too much. + +The bandit literature mostly focuses on the problem of a finite number of independent arms, but it is often the case that infinite number of of arms and the arms share some common structure and thus can be indexed by variables as a continuum armed bandit problem. In e-commerce, the retailer needs to decide the product assortment and pricing to maximize long-term profits; in mobile health, the personal device provides exercise and dietary suggestions to improve physical and mental health. The possible actions in both examples can be parameterized as continuous variables, which are possibly high dimensional. In addition, decision-makers observe other covariates/features, i.e., the contextual bandit problem where the reward is modeled as a function of unknown parameters and the contextual variables, and in many practical settings, the covariates are high-dimensional. + +As the dimensionalities of the action space (for arms) and the contextual variables grow, the traditional bandit algorithms suffer from the curse of dimensionality and it is impossible or prohibitively costly to learn the optimal decision. Albeit both the arm and the contextual are high-dimensional, the dimension of the underlying factors is often, fortunately, small – for high-dimensional bandit problems, one can assume a low-dimensional structure on the unknown parameters, such as the LASSO bandit (Bastani & Bayati, 2020); and for high-dimensional continuum armed bandit problems, one can assume the reward function depends only on the low-dimensional subspace of the action space (Tyagi et al., 2016). While low-dimensional representation has been successfully adopted in highdimensional bandit problems and high-dimensional continuum armed bandit problems respectively, a natural but important question remains open: can we efficiently solve the bandit problem with both high-dimensional continuum arms and high-dimensional contextual variables simultaneously? + +In this paper, we tackle the above problem by proposing a novel model that captures the effect of the arm and the contextual with an approximately low-rank matrix representation as well as an efficient algorithm $\left( \mathtt { H i - C C A B } \right)$ to efficiently solve the problem with theoretical justifications. Specifically, for an action that is presented as a vector $\textbf { \em a } \in \mathbb { R } ^ { d _ { a } }$ and the corresponding contextual covariates $\pmb { x } \in \mathbb { R } ^ { d _ { x } }$ , we yield reward + +$$ +r = \pmb { a } ^ { \top } \Theta \pmb { x } + \varepsilon +$$ + +where $\Theta \in \mathbb { R } ^ { d _ { a } \times d _ { x } }$ is the unknown representation matrix, which is assumed to have rank $d \ll$ $\operatorname* { m i n } \{ d _ { a } , d _ { x } \}$ and $\varepsilon$ is the independent error. To learn the low-rank representation matrix, we adapt the low-rank matrix estimator to the bandit setting. We further demonstrate the benefits of our methodologies in e-commerce with real sales data where the online retailer needs to decide on the product assortment and pricing jointly. The generality of our model makes it possible to learn policy on product assortment and pricing at the same time, while previous literature mostly studies the assortment and pricing problem separately. + +Contributions. We highlight the following contributions of our paper: + +1. We propose a new model for high-dimensional continuum armed and high-dimensional contextual bandit problem, which is often faced by decision-makers but very little existing literature attempts to solve. The crux of our model is the low-rank representation matrix that exploits the low-dimensional structure of both the high-dimensional arms and high-dimensional covariates. Our model unifies a large class of bandit models. +2. The low-rank representation matrix is endowed with interpretability and predictive power. One can perform singular value decomposition (SVD) on the representation matrix – the left singular vectors reveal the latent structure and relationships among the arms, while the right singular vectors show the latent factors of the covariate. In other words, our model implicitly performs principle component analysis (PCA) on the effect of arms and covariates on the mean reward. On the other hand, given the covariate, our model is able to predict the reward of an unseen arm. Both interpretability and predictive power can be tremendously useful for decision-makers. +3. We propose an efficient algorithm for the High-dimensional Contextual and High-dimensional Continumm Armed Bandit (Hi-CCAB) by adopting the low-rank matrix estimator. We further provide an upper bound for the convergence rate of Hi-CCAB in terms of the time-averaged expected cumulative regret. +4. The generality of our model allows for a wide range of applications. Specifically, we apply Hi-CCAB to the joint assortment and pricing problem. We show that our model reveals insights for product designs, assortment, and pricing and that the assortment-pricing policy based on Hi-CCAB yields sales four times as high as the original strategy. + +Literature review. Literature on high-dimensional bandit problems has been expanding recently, especially after statistical tools for high-dimensional problems become mature (Negahban & Wainwright, 2011; Wainwright, 2019). Lots of high-dimensional bandit literature focuses on contextual bandits with high-dimensional covariates, such as the LASSO bandit problem (Abbasi-Yadkori et al., 2012; Kim & Paik, 2019; Bastani & Bayati, 2020; Hao et al., 2020; Papini et al., 2021) where they assume the mean reward is a linear function of a sparse unknown parameter vector, the low-rank matrix bandit where the covariate and unknown parameter are both of matrix form (Kveton et al., 2017; Lu et al., 2021), and other non-parametric methods that learns the reward function using random forest or deep learning (Feraud et al., 2016; Zhou et al., 2020; Ban et al., 2022; Chen et al., ´ 2022; Xu et al., 2022). The high-dimensional bandit models are special cases of our model. + +Another stream of high-dimensional bandit literature studies representation learning in linear bandits, specifically for multi-task learning where several bandits are played concurrently. The arms for each task are embedded in the same space and share a common low-dimensional representation (Lale et al., 2019; Yang et al., 2020; Hu et al., 2021; Xu & Bastani, 2021). Our problem is different from multi-task learning since at each time we only have one bandit and thus observe one reward while in the multi-task bandit problem, multiple bandits are played at the same time. + +For continuum armed bandits, there exists a thread of literature that assumes the mean reward function is smooth and continuous on the action space in some sense, e.g., the function lies in the Lipschitz or Holder space (Agrawal, 1995; Kleinberg, 2004; Kleinberg et al., 2019). Most work ¨ discretizes the arm space or adopts the non-parametric regression to estimate the reward function, which is very different from our approach. Recent literature studies on continuum armed bandit with contextual covariates further assumes the mean reward function is continuous on the arm-covariate space (Lu et al., 2010; Slivkins, 2011; Krishnamurthy et al., 2020). Literature on high-dimensional continuum armed bandits, however, is scarce (Turgay et al., 2020; Majzoubi et al., 2020). Again, ˘ the techniques and assumptions therein are different from ours and their model is hard to interpret. + +In terms of matrix estimation techniques, low-rank matrix estimation and recovery have been studied extensively in statistics and widely used in numerous applications (Candes & Plan, 2010; Candes & \` Tao, 2010; Negahban & Wainwright, 2011; Shabalin & Nobel, 2013; Gavish & Donoho, 2014; Cai & Zhang, 2018; Wainwright, 2019). We adapt the techniques in this literature to provide convergence analysis for our algorithm. + +Finally, in operation research, assortment and pricing are important decisions for firms and there exists voluminous literature on dynamic assortment and dynamic pricing. Most of the work on assortment is based on the multinomial logit (MNL) choice model (Caro & Gallien, 2007; Kok et al., ¨ 2008; Saure & Zeevi, 2013) and recently a strand of work adopt the multi-arm bandit technique to ´ the MNL model (Chen & Wang, 2017; Agrawal et al., 2019; Kallus & Udell, 2020; Chen et al., 2021). For dynamic pricing, the problem usually comes with demand learning. In presence of covariates, the demand can be modeled as a parametric function (Qiang & Bayati, 2016; Ban & Keskin, 2021) or a nonparametric function (Chen & Gallego, 2021) which adopt the continuum armed bandit techniques in Slivkins (2011). However, there are relatively few papers on the joint assortment-pricing problem. Recently, Miao & Chao (2021) provides a solution using the MNL choice model with finite arms, while our model targets at infinite many arms. In addition, their model assumes the products are independent of each other and can only handle a small number of products. Their model can neither incorporates contextual information nor predicts new products. + +Roadmap. The rest of the paper is organized as follows. Section 2 describes the problem formulation and introduces our model with two concrete examples in assortment-pricing and health care. Section 3 presents our Hi-CCAB algorithm and its convergence result. Finally, Section 4 shows the empirical results on simulated data and a case study on real sales data from one of the largest online retailers. The proof of our theorem and additional empirical results are provided in the Appendix. + +# 2 PROBLEM FORMULATION + +In this section, we first introduce our high-dimensional continuum armed and high-dimensional contextual bandit model. Since our model is novel and different from traditional bandit models, we further provide intuition and two real applications of our model in assortment-pricing and healthcare. Finally, we show that a large class of bandit models can be reformulated into our model. + +Notation. We use bold lowercase for vectors and bold uppercase for matrices. For any vector $\textbf { \em a }$ , we use $\| \pmb { a } \|$ to denote its $\ell _ { 2 }$ norm. For any matrix $\pmb { A }$ , we use $\begin{array} { r } { \| \pmb { A } \| _ { F } : = \sum _ { i j } a _ { i j } ^ { 2 } } \end{array}$ to denote its Frobenius norm, $\| A \| _ { 2 }$ to denote its $\ell _ { 2 }$ spectrum norm, i.e., $\begin{array} { r } { \| A \| _ { 2 } : = \operatorname* { s u p } _ { \| \pmb { x } \| _ { 2 } = 1 } \| A \pmb { x } \| _ { 2 } } \end{array}$ , and $\begin{array} { r } { \| \boldsymbol { A } \| _ { * } : = \sum _ { k = 1 } ^ { d } s _ { k } } \end{array}$ to denote its nuclear norm where $d$ is the rank and $s _ { k }$ ’s are the singular values of $\pmb { A }$ . We use $\bar { \langle \mathbf { \boldsymbol { a } } , \mathbf { \boldsymbol { b } } \rangle } : = \mathbf { \boldsymbol { a } } ^ { \top } \boldsymbol { b }$ to denote the inner product between two vectors and $\langle A , B \rangle : =$ trace $( A ^ { \top } B )$ between two matrices. + +Problem setup. At each time $t$ , we make one decision for a batch of objects of size $L$ . Before making the decision, we observe the attributes of these $L$ objects, which can be characterized in potentially high-dimensional contextual vectors: $\pmb { x } _ { t , 1 } , \cdot \cdot \cdot , \pmb { \bar { x _ { t , L } } } \in \mathbb { R } ^ { d _ { x } }$ . Then based on all the observations we have before time $t$ and the contextual vectors at time $t$ , we decide on an action to take (or equivalently an arm to choose), which can be characterized as a high-dimensional vector $\mathbf { } \mathbf { a } _ { t }$ that takes value in a constraint set $\mathcal { A }$ in high-dimensional space $\mathbb { R } ^ { d _ { a } }$ . After we take the action each time, we observe a batch of rewards, + +$$ +\boldsymbol { r } _ { t , j } = \mathbf { a } _ { t } ^ { \top } \Theta \boldsymbol { x } _ { t , j } + \varepsilon _ { t , j } , \quad j = 1 , 2 , \cdot \cdot \cdot , L +$$ + +where $\Theta$ is a low-rank matrix and $\varepsilon _ { t , j }$ is independent noise with $\mathbb { E } [ \varepsilon _ { t , j } ] = 0$ and $\mathrm { V a r } [ \varepsilon _ { t , j } ] \leq \sigma ^ { 2 }$ . + +As a bandit problem, our goal is to design a sequential decision-making policy $\pi$ that maximizes the expected cumulative reward, or equivalently, minimizes the expected cumulative regret. Specifically, suppose policy $\pi$ governs the way we take actions $\mathbf { \Phi } _ { a _ { 1 } , a _ { 2 } , a _ { 3 } , \cdots }$ , we have an expected cumulative regret measuring the difference between the cumulative expected reward of the best possible action when the underlying true parameter (i.e., $\Theta$ ) is known and that we can achieve under policy $\pi$ , + +$$ +R _ { T } ^ { \pi } = \mathbb { E } \left[ \sum _ { t = 1 } ^ { T } \operatorname* { m a x } _ { a \in \mathcal { A } _ { t } } \left( \sum _ { j = 1 } ^ { L } a ^ { \top } \Theta x _ { t , j } - a _ { t , \pi } ^ { \top } \Theta x _ { t , j } \right) \right] +$$ + +where the expectation is taken with respect to $( \boldsymbol { x } _ { t , j } , \varepsilon _ { t , j } )$ since $\mathbf { } _ { \mathbf { } ^ { a _ { t , \pi } } }$ depends on both. We seek an optimal policy $\pi ^ { * }$ that minimizes the expected cumulative regret $R _ { T } ^ { \pi }$ . Note that $R _ { T } ^ { \pi }$ grows with $T$ . To better measure the performance of a policy, we focus on the time-averaged expected cumulative regret, $R _ { T } ^ { \pi } / T$ . We will ignore the subscript $\pi$ for $^ { a }$ for notation simplicity in the rest of the paper. + +At first sight, our model seems remote from other bandit models and hard to interpret. Our model is, in fact, a generalization of a large class of bandit models, and the generality of our model makes it applicable to a wide range of decision-making problems. In the following, we will parse the model and provide more intuitions. + +Let us consider the classical $K$ -arm bandit model (without context). Each arm can be represented by a $k$ -dimensional standard basis and the covariate vector is simply 1. Then $\Theta$ becomes a vector where each element is the mean reward for the corresponding arm. For the multi-arm contextual linear bandit problem, we further observe covariate $_ { \textbf { \em x } }$ as the contextual. Then each row of $\Theta$ becomes the coefficient $\beta$ for each arm, i.e., $r _ { k } = \beta _ { k } ^ { \top } { \pmb x }$ for $k = 1 , \ldots , K$ . Our model further unifies a large class of bandit models and we will formalize the above statements later in Proposition 1. + +The novelty of our model lies in the low-rank representation matrix $\Theta$ . It encapsulates the effect of the arm and covariates on the reward and exploits the low-dimensional structure in the highdimensional arm and covariates. To be more specific, let us consider $\Theta$ to be exactly low-rank and of rank $d$ . Suppose its singular value decomposition is $\Theta = U S V$ , where $U ^ { \top } \dot { U } = I _ { d }$ , $\pmb { S }$ is a $d \times d$ diagonal matrix with positive diagonal elements, and $V ^ { \top } V = I _ { d }$ . Let the left singular vectors $U = ( \pmb { u } _ { 1 } , \dots , \pmb { u } _ { d } )$ , the singular values in the diagonal of $_ { s }$ be $s _ { 1 } \geq s _ { 2 } \geq . . . \geq s _ { d } > 0$ and the right singular vectors $V = \left( \pmb { v } _ { 1 } , \ldots , \pmb { v } _ { d } \right)$ . Then the mean reward in (1) can be re-expressed as + +$$ +\mathbb { E } [ r ] = { \pmb a } ^ { \top } \Theta { \pmb x } = \sum _ { i = 1 } ^ { d } s _ { i } \langle { \pmb a } , { \pmb u } _ { i } \rangle \cdot \langle { \pmb v } _ { i } , { \pmb x } \rangle . +$$ + +In other words, the mean reward is the summation of inner products between the action projected on the left singular vector and the covariates projected on the right singular vector, weighted by the singular values. By assuming $\Theta$ to be low-rank, the mean reward is assumed to be governed by only a few linear combinations of the arm attributes and covariates. Hence our model automatically explores the low-dimensional structure of the arm vector and the contextual vector in terms of its effect on the reward, from which we can draw interpretation and insights from the effective subspaces of both the arm and covariates. + +As a concrete illustration of our model and to explain why our model is reasonable in real applications, we provide the following use cases in the joint assortment-pricing problem and health care. + +Example 1 (Assortment and Pricing). In retailing and $e$ -commerce, the assortment problem is to decide what combination of products to present at each given time with constraints on the capacity (Kok et al., 2008), and the pricing problem is to decide the prices of the products. The goal of the ¨ two problems is to maximize certain objective such as maximizing the revenue or profit. + +Products can be usually characterized by attributes such as color, pattern, and fit for apparels or technical specifications for electronics and appliance. We focus on instant noodles, which will be our case study in Section 4. Each product is single-flavor or assorted with different packs and can be represented as a feature vector $\tilde { \pmb { p } } = ( \# f l a v o r _ { 1 } , \# f l a v o r _ { 2 } , \cdot \cdot \cdot , \# f l a v o r _ { m } )$ where m is the number of possible flavors and is priced as $p$ . Then the store needs to decide on what products to present and their corresponding prices. Namely, the arm (action) vector can be represented as $\pmb { a } = ( \tilde { p } _ { 1 } , p _ { 1 } , \tilde { p } _ { 2 } , p _ { 2 } , \cdots , \tilde { p } _ { K } , p _ { K } , 1 )$ where $K$ is the maximum number of slots. The arm vector is clearly in a high-dimensional continuous space. At the same time, we observe the contextual covariates $_ { \textbf { \em x } }$ for each period of time, such as the location and season at the aggregated level or demographics information at the user level. + +The demand and sales of products with similar attributes react similarly to the same market conditions. It is often the case that there exists latent factors of the products that governs the demand and sales. Therefore, it is reasonable to parameterize the reward function in the form of (1) rather than ignoring the similarity between products as in the literature (Miao & Chao, 2021; Kallus & Udell, 2020; Chen et al., 2021). Our model can further suggests new products rather than only the products that has already been provided. + +Example 2 (Healthcare). In healthcare, for the health-monitoring apps which both monitors health conditions and give suggestions on actions to take for users, the arm (a) is high-dimensional and continuous (e.g., sleeping time, length and kind of exercise, usage of social media, diet choices including energy, water, protein, minerals, and nutrition intakes), and the health outcome not only depends on our suggestions, but also depends on the user’s characteristics (e.g., age, gender, weight, height, basic health status, tendency of following suggestions) as contextual variables (x). Clearly, both the arm and the contextual variable vector are possibly high-dimensional and the arm can take continuous values. The classical bandit models do not fit the situation. The actions usually share similar effect on health and the user’s characteristics can be usually captured by a few latent factors. Therefore, it is reasonable to assume $\Theta$ to be low-rank. + +To close the section, Proposition 1 shows that the traditional multi-arm bandit, multi-arm highdimensional contextual bandit, and continuum arm bandit can be written in the form of model (1). + +Proposition 1. The following bandit models can be expressed as special cases of our model. + +1. (multi-arm bandit) For $i$ -th arm, $\pmb { a } = ( 0 , 0 , \cdots , 1 , \cdots , 0 )$ , where 1 is in i-th element. Suppose $_ { \textbf { \em x } }$ has its first element being constant. Then $\Theta _ { i , 1 } = \mu _ { i }$ , where $\mu _ { i }$ is the mean reward of the i-th arm, and $\Theta _ { i , j } = 0$ if $j \neq 1$ . Clearly, $\Theta$ has rank $^ { l }$ . + +2. (multi-arm high-dimensional contextual bandit) For $i$ -th arm, $\pmb { a } = ( 0 , 0 , \cdots , 1 , \cdots , 0 )$ , where 1 is in $i$ -th element. $_ { \textbf { \em x } }$ is the contextual vector. Then $\Theta = ( \beta _ { 1 } , \beta _ { 2 } , \cdots , \beta _ { m } ) ^ { \top }$ , where $\beta _ { i }$ is the parameter vector corresponding to i-th arm (Bastani & Bayati, 2020). + +3. (continuum arm bandit (without contextuals)) Suppose the arm in original continuum arm bandit is denoted by $a$ , and the mean reward function is $f ( a )$ . Since all continuous function on a bounded interval can be approximated by polynomial functions to arbitrary precision, it’s reasonable to assume $f ( a )$ to be polynomial of order $n$ , which is not known precisely and only an upper bound $N$ is known. Let $\mathbf { \bar { \Phi } } _ { \mathbf { a } } = ( 1 , a , a ^ { 2 } , a ^ { 3 } , \cdots , a ^ { n } , \cdots , a ^ { N } )$ , and suppose the first element of $_ { \textbf { \em x } }$ is constant $I$ , then $\begin{array} { r } { \Theta _ { i , j } = \frac { 1 } { i ! } f ^ { ( i ) } ( a ) . } \end{array}$ for $j = 1$ and $\Theta _ { i , j } = 0$ for $j \neq 1$ . Clearly, $\Theta$ is rank $n$ . + +# 3 HI-CCAB ALGORITHM AND THEORETICAL RESULTS + +In this section, we present our learning algorithm with a regret upper bound. Specifically, we detail the Hi-CCAB algorithm in Section 3.1 and establish an upper bound for its convergence rate of the time-averaged expected cumulative regret in Section 3.2. + +# 3.1 DESCRIPTION OF THE LEARNING ALGORITHM + +Our policy consists of two phases for each period $t \in [ T ]$ : the first phase learns a low-rank representation and the second phase determines the assortment and the selling prices. In the first phase, our policy estimates $\widehat { \Theta } _ { t }$ by an penalized least-square estimator using $( \pmb { a } _ { i } , \pmb { x } _ { i , j } , r _ { i , j } )$ for $i = 1 , \ldots , t$ and $l = 1 , \ldots , L$ . Based on $\widehat { \Theta } _ { t }$ , we look for the optimal assortment and pricing within the action space $\boldsymbol { A } _ { t }$ . Algorithm 1 describes the detailed procedure of our policy. + +Low-rank representation learning. As mentioned in Section 2, both the arm and the contextual vectors $\bar { \textbf { \textit { a } } } \in \mathbb { R } ^ { d _ { a } }$ and $\textbf { \em x } \in \mathbb { R } ^ { \bar { d } _ { x } }$ are high-dimensional, and thus $\Theta \in \mathbb { R } ^ { d _ { a } \times d _ { x } }$ is also highdimensional. Fortunately, there often exists structure in both the arm and covariate space as explained in Section 1. To leverage the underlying structure, we impose a low-rank assumption on $\Theta$ , which automatically explores the effect of the low-rank structure and the relationships between the action and the contextual arms. + +To estimate the low-rank representation of $\Theta$ at time $t$ , one can adopt the rank-penalized least square: + +$$ +\widehat { \Theta } _ { t } : = \operatorname * { a r g m i n } _ { \Theta } \sum _ { i = 1 } ^ { t } \sum _ { j = 1 } ^ { L } \left( \pmb { a } _ { i } ^ { \top } \Theta \pmb { x } _ { i , j } - r _ { i , j } \right) ^ { 2 } + \lambda _ { t } \cdot \mathrm { r a n k } ( \Theta ) +$$ + +where $\lambda _ { t } ~ > ~ 0$ is the penalization parameter and $\operatorname { r a n k } ( \Theta )$ is the rank of the matrix $\Theta$ . However, the rank penalization makes (4) a non-convex problem, leading to computational challenges. To address the computational challenges, the rank penalization term is often replaced by the nuclear norm in matrix estimation and completion literature so that the optimization problem becomes a convex problem. We adopt a similar idea and our objective function then becomes: + +$$ +\widehat { \Theta } _ { t } : = \underset { \Theta } { \arg \operatorname* { m i n } } \sum _ { i = 1 } ^ { t } \sum _ { j = 1 } ^ { L } \left( \pmb { a } _ { i } ^ { \top } \Theta \pmb { x } _ { i , j } - r _ { i , j } \right) ^ { 2 } + \lambda _ { t } \cdot \| \pmb { \Theta } \| _ { * } . +$$ + +The penalization parameter $\lambda _ { t }$ is updated in each iteration such that ${ \lambda _ { t } } ~ = ~ { \lambda _ { 0 } } / { \sqrt { t } }$ where $\lambda _ { 0 }$ is the initialized penalization parameter, which can be chosen by cross-validation or guided by $\begin{array} { r } { \big \| \frac { 1 } { 2 t _ { 1 } L } \sum _ { i = 1 } ^ { t _ { 1 } } \sum _ { j = 1 } ^ { L } | \pmb { a } _ { i } ^ { \top } \widehat { \Theta } _ { t _ { 1 } } \pmb { x } _ { i , j } - r _ { i , j } | \pmb { x } _ { i , j } \pmb { a } _ { i } ^ { \top } \| _ { 2 } } \end{array}$ . + +Algorithm 1: The Hi-CCAB Algorithm. + +Result: Actions $\pmb { a } _ { t _ { 1 } + 1 } , \dots , \pmb { a } _ { T }$ . +Input: The number of steps for initialization $t _ { 1 }$ , set of possible actions $\boldsymbol { \mathcal { A } } _ { t _ { 1 } }$ , action vectors +based on domain knowledge $\{ a _ { i } \} _ { i = 1 } ^ { t _ { 1 } }$ , covariates vector $\{ \boldsymbol { x } _ { i , j } \} _ { i = 1 } ^ { t _ { 1 } }$ , rewards $r _ { i , j }$ for +$j = 1 , \dots , L$ , and exploration parameter $h$ ; +Initialization: $\begin{array} { r } { \lambda _ { 0 } \gets \parallel \frac { 1 } { 2 t _ { 1 } L } \sum _ { i = 1 } ^ { t _ { 1 } } \sum _ { j = 1 } ^ { L } | \mathbf { a } _ { i } ^ { \top } \widehat \Theta _ { t _ { 1 } } \mathbf { x } _ { i , j } - r _ { i , j } | \mathbf { x } _ { i , j } \mathbf { a } _ { i } ^ { \top } \parallel _ { 2 } , t \gets t _ { 1 } ; } \end{array}$ +while $t < T$ do $\lambda _ { t } \lambda _ { 0 } / \sqrt { t }$ ; Low-rank representation learning: P $\begin{array} { r } { \widehat { \Theta } _ { t } \gets \arg \operatorname* { m i n } _ { \Theta } \frac { 1 } { t L } \sum _ { i = 1 } ^ { t } \sum _ { j = 1 } ^ { L } ( \boldsymbol { a } _ { i } ^ { \top } \Theta \boldsymbol { x } _ { i , j } - r _ { i , j } ) ^ { 2 } + \lambda _ { t } \| \Theta \| _ { * } ; } \end{array}$ $\begin{array} { r } { \hat { \pmb { a } } _ { t + 1 } \mathrm { a r g m a x } _ { \pmb { a } \in \mathcal { A } _ { t } } \sum _ { j = 1 } ^ { L } \pmb { a } ^ { \top } \hat { \Theta } _ { t } \pmb { x } _ { t + 1 , j } } \end{array}$ ; Exploitation $i f t \not \in \{ \lfloor w ^ { \frac { 3 } { 2 } } \rfloor : w \in \mathbb { Z } _ { + } \}$ : $\pmb { a } _ { t + 1 } \hat { \pmb { a } } _ { t + 1 }$ ; Exploration if $t \in \{ \lfloor w ^ { \frac { 3 } { 2 } } \rfloor : w \in \mathbb { Z } _ { + } \}$ : $\mathbf { \delta } \mathbf { a } _ { t + 1 } \gets \hat { \mathbf { a } } _ { t + 1 } + \delta _ { t + 1 }$ , update action space $\boldsymbol { \mathcal { A } } _ { t + 1 }$ 1. $\delta _ { t + 1 } \sim N ( \mathbf { 0 } _ { d _ { a } } , h \pmb { I } _ { d _ { a } } )$ or; 2. $\delta _ { t + 1 } \sim { \cal N } ( \mathbf { 0 } _ { d _ { a } } , d i a g ( \hat { \tau } _ { t } ^ { 2 } ) )$ and $\hat { \pmb { \tau } } _ { t , j } ^ { 2 } = s d ( \{ \tilde { \pmb { a } } _ { i , j } \} _ { i = 1 } ^ { t } ) , s d ( \cdot )$ calculates the standard Apply action $\pmb { a } _ { t + 1 }$ and observe reward $r _ { t + 1 , j }$ for $j = 1 , \dots , L$ ; $t \gets t + 1$ ; + +end + +Policy learning. Once we estimated the low-rank representation of $\Theta$ , we can proceed to the action step. The goal of the action step is to exploit the knowledge we learned from the previous time, i.e., $\widehat { \Theta } _ { t }$ , so as to decide on the next action $\mathbf { \pmb { a } } _ { t + 1 }$ that maximizes the reward, and at the same time to explore actions that better inform the true $\Theta$ , which in turns will help make better decision to achieve higher long-term rewards. Specifically, given $\widehat { \Theta } _ { t }$ and the covariate $\pmb { x } _ { t + 1 , j }$ for $j = 1 , \dots , L$ , we look for an action $\hat { \pmb { a } } _ { t + 1 }$ in the action space $\boldsymbol { A } _ { t }$ that maximizes the total rewards across $L$ objects: + +$$ +\hat { \pmb { a } } _ { t + 1 } : = \underset { { \pmb { a } } \in \mathcal { A } _ { t } } { \arg \operatorname* { m a x } } \sum _ { j = 1 } ^ { L } { \pmb { a } } ^ { \top } \widehat { \pmb { \Theta } } _ { t } { \pmb x } _ { t + 1 , j } . +$$ + +We further perturb $\hat { \pmb { a } } _ { t + 1 }$ for the purpose of exploration by adding random noise to each coordinate when $t \in \{ \lfloor w ^ { \frac { 3 } { 2 } } \rfloor : w \in \mathbb { Z } _ { + } \}$ , i.e., $\pmb { a } _ { t + 1 } = \hat { \pmb { a } } _ { t + 1 } + \delta _ { t + 1 }$ where $\delta _ { t + 1 } \sim N ( \mathbf { 0 } _ { d _ { a } } , h \pmb { I } _ { d _ { a } } )$ and $h$ is a tuning parameter. The intuition for $\lfloor w ^ { \frac { 3 } { 2 } } \rfloor$ is to explore more in the initial stage and exploit more in the later stage of the algorithm. To be specific, there are around $T ^ { \frac { 2 } { 3 } }$ steps for exploration before time $T$ . The density of exploration at a small time frame around $T$ is $T ^ { - { \frac { 1 } { 3 } } }$ , which goes to zero as $T \to \infty$ . Note that the exponent can be any number larger than 1, instead of $\frac { 3 } { 2 }$ , which will affect the convergence rate of the regret as we will discuss later in Remark 2. The polynomial form can be changed as well. For each exploration step, one can also let $\delta _ { t + 1 } \sim N ( \mathbf { 0 } _ { d _ { a } } , \dot { d i a g } ( \hat { \pmb { \tau } } _ { t } ) )$ where each element of $\hat { \tau } _ { t }$ is the coordinate-wise standard error of the previous actions $\{ { \pmb a } _ { i } \} _ { i = 1 } ^ { t }$ . The intuition is to avoid tuning parameter $h$ while taking the right scale. Finally we update the action space $\boldsymbol { \mathcal { A } } _ { t + 1 }$ according to $\mathbf { \pmb { a } } _ { t + 1 }$ . For example, if the action space $\mathcal { A } _ { t } \in \mathbb { R } ^ { d _ { a } }$ can be defined by an upper limit $\bar { \mathbf { \alpha } } _ { \bar { \mathbf { a } } _ { t } }$ and a lower limit $\underline { { \mathbf { a } } } _ { t }$ , then we simply expand the action space by pushing the boundary of each coordinate to $\mathbf { \Delta } _ { a _ { t + 1 , j } }$ if $\mathbf { \bar { a } } _ { t + 1 , j } \notin [ \underline { { \mathbf { a } } } _ { t , j } , \bar { \mathbf { a } } _ { t , j } ]$ for $j = 1 , \ldots , d _ { a }$ . + +Remark 1. To take advantage of the interpretability of our model, we can further explore the structure of the $\widehat { \Theta } _ { t }$ . Specifically, we can apply singular value decomposition (SVD) on $\widehat { \Theta } _ { t }$ to explore the underlying latent structure of the covariates from the right singular vectors; and apply SVD on $( \widehat { \Theta } _ { t } \sum _ { j } ^ { L } { \pmb { x } } _ { t , j } )$ to explore the latent structure of the arms from the left singular vectors. One can further rotate the singular vectors so as to reveal the underlying factors using techniques in factor analysis such as Varimax (Kaiser, 1958; Rohe & Zeng, 2020) or to perform clustering analysis by performing $K$ -means on the singular vectors. + +# 3.2 THEORETICAL RESULTS + +In this section, we establish in Theorem 1 that the convergence rate of time-averaged expected cumulative regret for Algorithm 1 is at least as fast as $T ^ { - \frac { 2 } { 1 5 } }$ and outline the proof strategy for Theorem 1. We consider the time-averaged expected cumulative regret since it measures the trend of the newly incurred regret, in the long run, more directly; on the other hand, the expected cumulative regret grows with time $T$ , which is less interpretable. This theorem implies that the newly incurred regret, roughly speaking, converges to zero fast. + +Theorem 1. Suppose xt,l $\pmb { x } _ { t , l } \overset { i . i . d } { \sim } N ( \mathbf { 0 } _ { d _ { x } } , \pmb { I } _ { d _ { x } } )$ , and the errors $( \varepsilon _ { t , j } )$ defined in reward model (1) follows normal distribution: $\varepsilon _ { t , j } \stackrel { i . i . d } { \sim } N ( 0 , \sigma ^ { 2 } )$ N (0, σ2). Suppose Θ is rank d. Suppose the exploration step in Algorithm $I$ is ${ \pmb a } _ { t } = \hat { { \pmb a } } _ { t } + \delta _ { t }$ for $t \in \{ \lfloor w ^ { \frac { 3 } { 2 } } \rfloor : w \in \mathbb { Z } _ { + } \}$ where $\delta _ { t } \sim N ( \mathbf { 0 } _ { d _ { a } } , h \pmb { I } _ { d _ { a } } )$ , $\mathcal { A } _ { t } = \{ \pmb { a } \in$ $\mathbb { R } ^ { \bar { d } _ { a } } : \lVert \pmb { \mathscr { a } } \rVert \leq 1 \}$ , then there is a $T _ { 1 }$ such that for $T \geq T _ { 1 }$ , the expected cumulative regret of the Algorithm $^ { l }$ , $R _ { T } ^ { \pi }$ , satisfies + +$$ +\frac { R _ { T } ^ { \pi } } { T } \leq 2 \sqrt { L d _ { x } } \| \Theta \| _ { 2 } T _ { 1 } T ^ { - 1 } + \frac { 7 2 } { 5 } \lambda _ { 0 } \frac { \sqrt { 2 d d _ { x } } L } { h ^ { 2 } } T ^ { - \frac { 1 } { 6 } } + \frac { 6 0 } { 1 3 } \sqrt { L d _ { x } } \| \Theta \| _ { 2 } T ^ { - \frac { 2 } { 1 5 } } + \frac { 9 0 } { 1 3 } \frac { \sigma ( d _ { x } + 1 ) } { h ^ { 2 } } T ^ { - \frac { 2 } { 1 5 } } +$$ + +where $T _ { 1 } = C _ { h , L , \lambda _ { 0 } } ( d _ { x } + d _ { a } ) ^ { 6 } \left( l o g ( d _ { x } + d _ { a } ) \right) ^ { 3 }$ and the constant $C _ { h , L , \lambda _ { 0 } }$ depends on $h , L$ and $\lambda _ { 0 }$ . +For $T \leq T _ { 1 }$ , $\begin{array} { r } { \frac { R _ { T } ^ { \pi } } { T } \leq 2 \sqrt { L d _ { x } } \| \Theta \| _ { 2 } } \end{array}$ . + +Remark 2 (Convergence rate). An intuitive understanding of Theorem $I$ is that the expected regret incurred each time converges to zero at a speed at least $T ^ { - \frac { 2 } { 1 5 } }$ as $T$ going to infinity. The convergence rate depends on the frequency of the exploration which depends on the exponent $\frac { \ddot { 3 } } { 2 }$ in the exploration set, $\{ \lfloor w ^ { \frac { 3 } { 2 } } \rfloor : w \in \mathbb { Z } _ { + } \}$ . Recall that the exponent can be changed with any number larger than $^ { l }$ , which can be considered as a tuning parameter. + +Remark 3 (“Burnout” term). The first term in inequality (7) is a “burnout” term, where the algorithm is gaining knowledge of $\Theta$ from scratch. We do not impose any assumptions on these starting steps so that we have a relative conservative “burnout” term. However, in practice, we usually have historical data to start with so that the algorithm can start from a reasonable estimation of $\Theta$ and much smaller “burnout” term. Recall that the exponent of the exploration set can be any number larger than 1. The order of the “burnout” term depends on the exponent of the w in the exploration set — the more exploration there is, the smaller the “burnout” term. The exponent can be chosen depending on the situation — how ample the historical data is. + +Remark 4 (Constant $C _ { h , L , \lambda _ { 0 } }$ of $T _ { 1 }$ ). While constant $C _ { h , L , \lambda _ { 0 } }$ depends on $h , L , \lambda _ { 0 }$ , the primary√ dependency is actually on $h$ and $L$ . The order of $\lambda _ { 0 }$ in terms of dimensions and noise level is $\sigma \sqrt { d _ { x } }$ . We do not assume the order of $\lambda _ { 0 }$ or bound it with a high probability bound in order to show its√ role in time-averaged expected cumulative regret. If we utilize the order $\sigma \sqrt { d _ { x } }$ , then $C _ { h , L , \lambda _ { 0 } }$ can be replaced by a constant depending on $h$ and $L$ only. + +Remark 5 (Dependence on dimensions $d _ { a } , d _ { x }$ and rank $d$ ). When $T$ is small, the “burnout” term (the first term) dominates. $I t$ depends on $T$ and the dimensions but not the rank as $( d _ { a } + d _ { x } ) ^ { 6 } ( l o g ( d _ { a } + d _ { x } ) ) ^ { 3 } T ^ { - 1 }$ , whose order depends on the exponent defining the exploration set (i.e., how frequent we explore). As $T$ grows, the second term dominates. Recall Remark 4, √ $\lambda _ { 0 }$ is of order $\sigma \sqrt { d _ { x } }$ , so the second terms depends on $T , d _ { x }$ and $d$ but not $d _ { a }$ at the order of $\Omega ( d _ { x } \sqrt { d } T ^ { - \frac { 1 } { 6 } } )$ . Without the low-rank assumption, the order would be $\Omega ( d _ { x } ^ { \frac { 3 } { 2 } } T ^ { - \frac { 1 } { 6 } } )$ instead. When $T$ becomes even larger, the last two terms dominates, at the order $\Omega \big ( d _ { x } T ^ { - \frac { 2 } { 1 5 } } \big )$ . However, the last case rarely happens, as it requires the order of $T$ equal to or larger than $d ^ { 1 5 }$ . Therefore, taking dimensions and rank into√ consideration, the time-averaged expected cumulative regret is mostly at the order of $\Omega ( d _ { x } \sqrt { d } T ^ { - \frac { 1 } { 6 } } )$ . + +Proof sketch We outline the proof strategy for Theorem 1. There are two major steps: (1) bounding the estimation error for the low-rank representation matrix estimator; (2) bounding the expected cumulative regret. The detailed proof of Theorem 1 is in Appendix A. + +(1) Bounding the estimation error of $\widehat { \Theta } _ { t }$ with a high probability bound. Denote $\delta \mathbf { \Theta } \Theta _ { t } = \widehat { \mathbf { \Theta } } \widehat { \mathbf { \Theta } } \overline { { \mathbf { \Theta } } } - \mathbf { \Theta } \mathbf { \Theta }$ We show that for a large $t$ , + +$$ +P \left( \| \delta \Theta _ { t } \| _ { F } \le \frac { 3 } { T ^ { \frac { 2 } { 1 5 } } } \frac { \sigma \sqrt { d _ { x } + 1 } } { \sqrt { L } h ^ { 2 } } + 6 \lambda _ { 0 } \frac { \sqrt { 2 d } } { h ^ { 2 } T ^ { \frac { 1 } { 6 } } } \right) \le 1 - \left( \frac { 3 } { t } + \frac { 2 } { t ^ { 2 } } + \frac { 2 } { L t } + \frac { 2 } { L ^ { 3 } t ^ { 3 } } + \frac { 1 } { t ^ { \frac { 2 } { 1 5 } } } \right) . +$$ + +![](images/e4bdc672e71629487c55437ceed1811411638573ba43f7a339355ad5adcfdb96.jpg) +Figure 1: Cumulative regret under the non-sparse (first row) and sparse (second row) settings. + +Note that the action taken is based on previous estimators and affect the accuracy of future estimators, leading to lots of dependencies. The classical matrix completion results can no longer apply. Through careful use of conditional expectations, martingales, and empirical process we separate out different sources of randomness (i.e., $\delta _ { 1 } , \cdot \cdot \cdot , \delta _ { t } , \pmb { x } _ { 1 , \cdot } , \cdot \cdot \cdot , \pmb { x } _ { t , \cdot } )$ to derive the bounds. Lemma 1 establishes a restricted-strong-convexity-type result of the sum of squares in the objective function. Lemma 2 establishes a Lipschitz-type result of the sum of squares in the objective function. Further analysis of the nuclear-norm-penalized sum of squares with the two lemmas and low-rank properties gives the tail bound of the estimation error. + +(2) Bounding the time-averaged expected regret. Let $\begin{array} { r } { Q _ { t } = \{ \| \delta \Theta _ { t } \| _ { F } \leq \frac { 3 } { T ^ { \frac { 2 } { 1 5 } } } \frac { \sigma \sqrt { d _ { x } + 1 } } { \sqrt { L } h ^ { 2 } } + 6 \lambda _ { 0 } \frac { \sqrt { 2 d } } { h ^ { 2 } T ^ { \frac { 1 } { 6 } } } \} } \end{array}$ be the event such that $\delta \Theta _ { t }$ is bounded. We know that from the first step, for large $t$ , $P ( Q _ { t } ^ { c } ) \leq$ $\begin{array} { r } { \frac { 3 } { t } + \frac { 2 } { t ^ { 2 } } + \frac { 2 } { L t } + \frac { 2 } { L ^ { 3 } t ^ { 3 } } + \frac { 1 } { t ^ { \frac { 2 } { 1 5 } } } } \end{array}$ . Consider the expectation of the regret on $Q _ { t }$ and $Q _ { t } ^ { c }$ separately and both terms vanish with $t$ at the polynomial rate. + +# 4 SIMULATION STUDY AND ASSORTMENT-PRICING CASE STUDY + +In this section, we conduct simulation studies to compare the proposed Hi-CCAB with LinUCB (Li et al., 2010), Lasso Bandit (Bastani & Bayati, 2020), NeuralUCB (Zhou et al., 2020) and EE-Net (Ban et al., 2022); we then study the joint assortment-pricing problem on the e-commerce platform for one of the largest instant noodles producers in China. Details on the tuning parameters of each algorithms and additional results of the case study are provided in Appendix B-C. + +Simulation study We consider the multi-armed linear bandit setup, a special case of our model as shown in Proposition 1, i.e., $\Theta = ( \beta _ { 1 } , \beta _ { 2 } , \cdot \cdot \cdot , \beta _ { m } ) ^ { \top }$ so that each row of $\Theta$ is the parameter of each arm for the multi-arm contextual bandit. Specifically, we set the number of arms $d _ { a } = \{ 1 0 , 3 0 , 5 0 \}$ and the dimension of covariates $d _ { x } = 1 0 0$ . For $\Theta$ , we consider a non-sparse and sparse case. For the non-sparse case, we generate $\Theta = U D V ^ { \top }$ where $U \in \mathbb { R } ^ { d _ { a } \times r } , V ^ { ^ { \bullet } } \in \mathbb { R } ^ { d _ { x } \times r } \stackrel { ^ { \bullet } } { ( r = 5 ) }$ , and $_ { D }$ is a diagonal matrix with $( 1 , . 9 , . 9 , . 8 , . 5 )$ as the diagonal entries. All entries of $U$ and $V$ are first generated from i.i.d. $N ( 0 , 1 )$ , and then applied Gram–Schmidt to make each column orthogonal. $U$ is scaled to have length $\sqrt { d _ { a } }$ so that the rewards are comparable across different $d _ { a }$ ’s. For the sparse case, each row of $\Theta$ are set as zero except for $s _ { 0 } = 2$ randomly selected elements that are drawn from $N ( 0 , 1 )$ . We generate the covariate $\pmb { x } \overset { i . i . d } { \sim } N ( 0 , \pmb { I } _ { d _ { x } } )$ and the rewards from (1) with $\sigma = 0 . 1$ . + +Figure 1 shows the cumulative regret (averaged over 50 simulations). For the non-sparse case, Hi-CCAB converges faster than all other methods. The advantage of Hi-CCAB is more pronounced when the dimension of the arms becomes larger. For the sparse case, which is not to the advantage of $\mathrm { H i - C C A B }$ , when the dimension of arms is relatively small ( $d _ { a } = 1 0 ^ { \cdot }$ ), Lasso Bandit converges faster but the gap between Hi-CCAB and Lasso Bandit is small. As the number of arms increases, Hi-CCAB outperforms all other methods. + +Assortment-pricing case study. The original data contains daily sales of 176 products across 369 cities from March 1st, 2021 to May 31st, 2022 $C = 4 5 6$ days). We aggregate the sales by 31 provinces. Each product is of either single or assorted flavors (13 possible flavors) with different counts. The assortment and price of each product changed daily. In addition, we know the dates for promotion. The assortment, prices, and promotions were the same across locations. The maximum number of products to be shown on the homepage is $K = 3 0$ . The total possible combinations are then $\textstyle { \binom { 1 { \bar { 7 } } 6 } { 3 0 } }$ and therefore if we consider one combination as one arm, we are facing extremely high-dimensional arms, for which most multi-arm bandit algorithms are not applicable. + +![](images/559be64dc0967924574e4b032eb54870e999347d89ae94ee7d891c76815a7d9c.jpg) +Figure 2: Performance of Hi-CCAB compared with real actions over 100 simulations. The boundaries of the shadow boundaries are the 5-th and 95-th quantiles. + +To apply Hi-CCAB, we specify the arms $\mathbf { } \mathbf { a } _ { t }$ and the covariate vectors $\{ \pmb { x } _ { t , j } \} _ { j = 1 } ^ { L = 3 1 }$ at given time following the setup in Example 1. The arm is represented as $\begin{array} { r l r } { a } & { { } \sim } & { ( \tilde { p } _ { 1 } , \tilde { p } _ { 1 } ^ { 2 } , p _ { 1 } , p _ { 1 } ^ { 2 } , \bar { p } r o m o _ { 1 } , p r o m o _ { 1 } ^ { 2 } , \cdots , \tilde { p } _ { K } , \tilde { p } _ { K } ^ { 2 } , p _ { K } , p _ { K } ^ { 2 } , p r o m o _ { K } , p r o m o _ { K } ^ { 2 } ) } \end{array}$ , 1) $\in$ $\mathbb { R } ^ { 2 ( m + 2 ) K + 1 = 9 0 1 }$ where $\tilde { \pmb { p } } _ { k } = ( \# f l a v o r _ { k , 1 } , \allowbreak \cdot \cdot \cdot , \# f l a v o r _ { k , m } )$ is a vector of non-negative integers to denote the counts of $m \ = \ 1 3$ flavors, $p _ { k }$ is the price, $p r o m o _ { k }$ is the indicator of promotion of product $k$ , and $\tilde { p } _ { k } ^ { 2 }$ is the element-wise quadratics. The covariate $\pmb { x } _ { t , j } ~ \in ~ \mathbb { R } ^ { 5 0 }$ for location $j$ includes dummy variables of 31 provinces, year 2021/2022, 12 months, weekdays, and an indicator of annual sales event on Jun 18 and Nov 11. More details are deferred to Appendix C. + +To run simulations using the dataset, we first create a pseudo-truth model. To be specific, we estimate $\Theta$ and $\sigma$ using all data of 456 days and consider them as the pseudo ground truth. We perform a sanity check on our model assumption (1), the pseudo ground truth against our data before preceding to the formal analysis and further examine the structure of the representation matrix $\Theta$ in Appendix C. We evaluate the performance of Hi-CCAB in terms of the cumulative regret (2) and the percentage gain of the cumulative sales by comparing with the original actions, since no existing bandit algorithm is applicable to this problem. + +Figure 2a shows the time-averaged cumulative regret (averaged over 100 simulations) and Figure 2b shows the percentage gain in cumulative sales compared to the real sales The time-averaged cumulative regret of Hi-CCAB converges to zero while that of original actions remains flat. In terms of percentage gain in cumulative sales, Hi-CCAB boosts cumulative sales by more than 4 times. On a separate note, Hi-CCAB with exploration performs better in terms of both cumulative regret and percentage sales gain than Hi-CCAB without exploration. + +# 5 CONCLUSION + +With an increasing demand for online decision-making, the bandit problem is receiving increasingly more attention from both theoreticians and practitioners. Even though the volume of bandit literature has been expanding, there exists very little literature on high-dimensional continuum armed contextual bandit with high-dimensional covariates. In this work, we formulate and propose a model for this problem. Our model is general as it unifies a large class of bandit problems and has interpretability and predictive power. We propose an efficient algorithm Hi-CCAB by adopting the low-rank matrix estimator and provide an upper bound for its convergence rate in terms of the time-averaged expected cumulative regret. The generality and flexibility of our model allow for its application in the joint assortment-pricing problem, where the assortment and pricing optimization problems have been studied extensively in operation research separately but not their joint optimization problem. By applying our model and algorithm to the real case study on the joint assortment-pricing problem for one of the largest instant noodles producers in China, we are able to boost the sales by four times and provide insights into the underlying structure of the effect on the reward of the arms and covariates such as purchasing behaviors. Therefore, both the theoretical and the real case study indicate that our model and algorithm can be effective for the high-dimensional continuum armed and high-dimensional contextual bandit problem faced by decision-makers in various fields. Since our model is new to the bandit literature, there is space for improvement in our regret analysis. This is an interesting future direction. + +# REFERENCES + +Yasin Abbasi-Yadkori, David Pal, and Csaba Szepesvari. Online-to-confidence-set conversions and application to sparse stochastic bandits. In Artificial Intelligence and Statistics, pp. 1–9. PMLR, 2012. + +Rajeev Agrawal. The continuum-armed bandit problem. SIAM journal on control and optimization, 33(6):1926–1951, 1995. + +Shipra Agrawal, Vashist Avadhanula, Vineet Goyal, and Assaf Zeevi. Mnl-bandit: A dynamic learning approach to assortment selection. Operations Research, 67(5):1453–1485, 2019. + +Gah-Yi Ban and N Bora Keskin. Personalized dynamic pricing with machine learning: Highdimensional features and heterogeneous elasticity. Management Science, 67(9):5549–5568, 2021. + +Yikun Ban, Yuchen Yan, Arindam Banerjee, and Jingrui He. Ee-net: Exploitation-exploration neural networks in contextual bandits. 2022. + +Hamsa Bastani and Mohsen Bayati. Online decision making with high-dimensional covariates. Operations Research, 68(1):276–294, 2020. + +T Tony Cai and Anru Zhang. Rate-optimal perturbation bounds for singular subspaces with applications to high-dimensional statistics. The Annals of Statistics, 46(1):60–89, 2018. + +Emmanuel J Candes and Yaniv Plan. Matrix completion with noise. Proceedings of the IEEE, 98 (6):925–936, 2010. + +Emmanuel J Candes and Terence Tao. The power of convex relaxation: Near-optimal matrix com- \` pletion. IEEE Transactions on Information Theory, 56(5):2053–2080, 2010. + +Felipe Caro and Jer´ emie Gallien. Dynamic assortment with demand learning for seasonal consumer ´ goods. Management science, 53(2):276–292, 2007. + +Ningyuan Chen and Guillermo Gallego. Nonparametric pricing analytics with customer covariates. Operations Research, 69(3):974–984, 2021. + +Xi Chen and Yining Wang. A note on a tight lower bound for mnl-bandit assortment selection models. arXiv preprint arXiv:1709.06109, 2017. + +Xi Chen, Chao Shi, Yining Wang, and Yuan Zhou. Dynamic assortment planning under nested logit models. Production and Operations Management, 30(1):85–102, 2021. + +Yang Chen, Miao Xie, Jiamou Liu, and Kaiqi Zhao. Interconnected neural linear contextual bandits with ucb exploration. In Pacific-Asia Conference on Knowledge Discovery and Data Mining, pp. 169–181. Springer, 2022. + +Raphael F ¨ eraud, Robin Allesiardo, Tanguy Urvoy, and Fabrice Cl ´ erot. Random forest for the con- ´ textual bandit problem. In Artificial intelligence and statistics, pp. 93–101. PMLR, 2016. + +Matan Gavish and David L Donoho. The optimal hard threshold for singular values is $4 / \sqrt { 3 }$ . IEEE Transactions on Information Theory, 60(8):5040–5053, 2014. + +Botao Hao, Tor Lattimore, and Mengdi Wang. High-dimensional sparse linear bandits. Advances in Neural Information Processing Systems, 33:10753–10763, 2020. + +Jiachen Hu, Xiaoyu Chen, Chi Jin, Lihong Li, and Liwei Wang. Near-optimal representation learning for linear bandits and linear rl. In International Conference on Machine Learning, pp. 4349– 4358. PMLR, 2021. + +Henry F Kaiser. The varimax criterion for analytic rotation in factor analysis. Psychometrika, 23 (3):187–200, 1958. + +Nathan Kallus and Madeleine Udell. Dynamic assortment personalization in high dimensions. Operations Research, 68(4):1020–1037, 2020. + +Gi-Soo Kim and Myunghee Cho Paik. Doubly-robust lasso bandit. Advances in Neural Information Processing Systems, 32, 2019. + +Robert Kleinberg. Nearly tight bounds for the continuum-armed bandit problem. In Proceedings of the 17th International Conference on Neural Information Processing Systems, NIPS’04, pp. 697––704, Cambridge, MA, USA, 2004. MIT Press. + +Robert Kleinberg, Aleksandrs Slivkins, and Eli Upfal. Bandits and experts in metric spaces. J. ACM, 66(4), May 2019. ISSN 0004-5411. doi: 10.1145/3299873. URL https://doi.org/10. 1145/3299873. + +A Gurhan K ¨ ok, Marshall L Fisher, and Ramnath Vaidyanathan. Assortment planning: Review of ¨ literature and industry practice. Retail supply chain management, 122(1):99–153, 2008. + +Akshay Krishnamurthy, John Langford, Aleksandrs Slivkins, and Chicheng Zhang. Contextual bandits with continuous actions: Smoothing, zooming, and adapting. The Journal of Machine Learning Research, 21(1):5402–5446, 2020. + +Branislav Kveton, Csaba Szepesvari, Anup Rao, Zheng Wen, Yasin Abbasi-Yadkori, and S Muthukr- ´ ishnan. Stochastic low-rank bandits. arXiv preprint arXiv:1712.04644, 2017. + +Sahin Lale, Kamyar Azizzadenesheli, Anima Anandkumar, and Babak Hassibi. Stochastic linear bandits with hidden low rank structure. arXiv preprint arXiv:1901.09490, 2019. + +Lihong Li, Wei Chu, John Langford, and Robert E Schapire. A contextual-bandit approach to personalized news article recommendation. In Proceedings of the 19th international conference on World wide web, pp. 661–670, 2010. + +Tyler Lu, David P ´ al, and Martin P ´ al. Contextual multi-armed bandits. In ´ Proceedings of the Thirteenth international conference on Artificial Intelligence and Statistics, pp. 485–492. JMLR Workshop and Conference Proceedings, 2010. + +Yangyi Lu, Amirhossein Meisami, and Ambuj Tewari. Low-rank generalized linear bandit problems. In International Conference on Artificial Intelligence and Statistics, pp. 460–468. PMLR, 2021. + +Maryam Majzoubi, Chicheng Zhang, Rajan Chari, Akshay Krishnamurthy, John Langford, and Aleksandrs Slivkins. Efficient contextual bandits with continuous actions. Advances in Neural Information Processing Systems, 33:349–360, 2020. + +Sentao Miao and Xiuli Chao. Dynamic joint assortment and pricing optimization with demand learning. Manufacturing & Service Operations Management, 23(2):525–545, 2021. + +Sahand Negahban and Martin J Wainwright. Estimation of (near) low-rank matrices with noise and high-dimensional scaling. The Annals of Statistics, 39(2):1069–1097, 2011. + +Matteo Papini, Andrea Tirinzoni, Marcello Restelli, Alessandro Lazaric, and Matteo Pirotta. Leveraging good representations in linear contextual bandits. In International Conference on Machine Learning, pp. 8371–8380. PMLR, 2021. + +Sheng Qiang and Mohsen Bayati. Dynamic pricing with demand covariates. arXiv preprint arXiv:1604.07463, 2016. + +Herbert Robbins. Some aspects of the sequential design of experiments. Bulletin of the American Mathematical Society, 58(5):527–535, 1952. + +Karl Rohe and Muzhe Zeng. Vintage factor analysis with varimax performs statistical inference. arXiv preprint arXiv:2004.05387, 2020. + +Denis Saure and Assaf Zeevi. Optimal dynamic assortment planning with demand learning. ´ Manufacturing & Service Operations Management, 15(3):387–404, 2013. + +Andrey A Shabalin and Andrew B Nobel. Reconstruction of a low-rank matrix in the presence of gaussian noise. Journal of Multivariate Analysis, 118:67–76, 2013. + +Aleksandrs Slivkins. Contextual bandits with similarity information. In Proceedings of the 24th annual Conference On Learning Theory, pp. 679–702. JMLR Workshop and Conference Proceedings, 2011. + +Joel A Tropp. User-friendly tail bounds for sums of random matrices. Foundations of computational mathematics, 12(4):389–434, 2012. + +Eralp Turgay, Cem Bulucu, and Cem Tekin. Exploiting relevance for online decision-making in ˘ high-dimensions. IEEE Transactions on Signal Processing, 69:1438–1451, 2020. + +Hemant Tyagi, Sebastian U Stich, and Bernd Gartner. On two continuum armed bandit problems in ¨ high dimensions. Theory of Computing Systems, 58(1):191–222, 2016. + +Martin J Wainwright. High-dimensional statistics: A non-asymptotic viewpoint, volume 48. Cambridge University Press, 2019. + +Kan Xu and Hamsa Bastani. Learning across bandits in high dimension via robust statistics. arXiv preprint arXiv:2112.14233, 2021. + +Pan Xu, Zheng Wen, Handong Zhao, and Quanquan Gu. Neural contextual bandits with deep representation and shallow exploration. 2022. + +Jiaqi Yang, Wei Hu, Jason D Lee, and Simon S Du. Impact of representation learning in linear bandits. arXiv preprint arXiv:2010.06531, 2020. + +Dongruo Zhou, Lihong Li, and Quanquan Gu. Neural contextual bandits with ucb-based exploration. In International Conference on Machine Learning, pp. 11492–11502. PMLR, 2020. + +# APPENDIX A PROOF OF THEOREM 1 + +In this proof, we denote the true parameter as $\Theta ^ { * }$ . + +Let $\begin{array} { r } { \mathcal { L } _ { T } ( \mathbf { \Theta } ) : = \frac { 1 } { 2 L T } \sum _ { t = 1 } ^ { T } \sum _ { l = 1 } ^ { L } ( \pmb { a } _ { t , l } ^ { \top } \mathbf { \Theta } \mathbf { \Theta } \mathbf { x } _ { t , l } - r _ { t , l } ) ^ { 2 } } \end{array}$ . Then we have the following lemmas that we will prove later. + +Lemma 1. Suppose all the assumptions in Theorem $^ { l }$ holds. Denote $\mathcal { E } _ { T } ( \Delta ) = \mathcal { L } _ { T } ( \Theta ^ { * } + \Delta ) -$ $\mathcal { L } _ { T } ( \Theta ^ { * } ) - \langle \nabla \mathcal { L } _ { T } ( \Theta ^ { * } ) , \Delta \rangle$ . Then with probability at least $\begin{array} { r } { 1 - \frac { 1 } { L T } - \frac { 2 } { T } - \frac { 1 } { T ^ { 2 } } } \end{array}$ , + +$$ +\mathcal { E } _ { T } ( \Delta ) \geq \frac { \lfloor T ^ { \frac { 2 } { 3 } } \rfloor } { 2 T } h ^ { 2 } \| \Delta \| _ { F } ^ { 2 } - 1 4 T ^ { - \frac { 2 } { 3 } } ( h + h ^ { 2 } ) \left( 2 d _ { x } + 2 d _ { a } + 6 \log T + 6 \log L \right) ^ { 2 } \log T \| \Delta \| _ { 2 } ^ { 2 } . +$$ + +Lemma 2. Suppose all the assumptions in Theorem $^ { l }$ holds. With probability at least $1 - { \frac { 1 } { T ^ { \frac { 2 } { 1 5 } } } } -$ 2L3T 3 − 1LT − 1T − 1T 2 , the following holds for all ∆ + +$$ +\begin{array} { r l } & { \langle \nabla \mathcal { L } _ { T } ( \Theta ^ { * } ) , \Delta \rangle | \leq \| \Delta \| _ { F } \frac { \sigma \sqrt { d _ { x } + 1 } } { \sqrt { L T } } T ^ { \frac { 1 } { 3 0 } } + } \\ & { \qquad \Big ( 2 h \sigma T ^ { - 2 / 3 } l o g T \sqrt { \frac { \operatorname* { m a x } \{ d _ { a } , d _ { x } \} l o g ( d _ { a } + d _ { x } ) } { L } } + } \\ & { \qquad \frac { 8 h \sigma } { T } \sqrt { l o g ( T L ) } \sqrt { ( d _ { x } + 3 l o g ( L T ) ) ( d _ { a } + 3 l o g T ) } ( l o g ( d _ { x } + d _ { a } ) + 2 l o g T ) \Big ) \| \Delta \| _ { * } } \end{array} +$$ + +Recall the definition of $\hat { \mathbf { \Theta } } _ { \hat { \mathbf { \alpha } } } \mathbf { \Theta } _ { \hat { \mathbf { \alpha } } }$ , we know that + +$$ +\begin{array} { r } { \mathcal L _ { T } ( \hat { \Theta } _ { T } ) + \lambda _ { T } \| \hat { \Theta } _ { T } \| _ { * } \leq \mathcal L _ { T } ( \Theta ^ { * } ) + \lambda _ { T } \| \Theta ^ { * } \| _ { * } . } \end{array} +$$ + +Denote $\delta \mathbf { e } _ { t } = \hat { \mathbf { \Theta } } _ { } \hat { \mathbf { \Theta } } _ { } - \mathbf { \Theta } \mathbf { e } ^ { * }$ and for notation simplicity we will drop the subscript $t$ for $\delta \Theta _ { t }$ in the following when there is no confusion. Equation (10) then implies that + +$$ +\begin{array} { r } { \mathcal { E } _ { T } ( \delta \Theta ) \leq - \langle \nabla \mathcal { L } _ { T } ( \Theta ^ { * } ) , \delta \Theta \rangle + \lambda _ { T } \left( \| \Theta ^ { * } \| _ { * } - \| \Theta ^ { * } + \delta \Theta \| _ { * } \right) . } \end{array} +$$ + +Suppose the singular value decomposition of $\Theta ^ { * }$ is $\Theta ^ { * } = U S V ^ { \top }$ , where $\pmb { S }$ is an $d \times d$ diagonal matrix. Let $U _ { \top }$ be an $d _ { a } \times ( d _ { a } - \stackrel { \textstyle - } { d } )$ matrix satisfying $( U , U _ { \bot } ) ( U , U _ { \bot } ) ^ { \top } = I _ { d _ { a } }$ . We define $V _ { \perp }$ similarly. + +Denote $\delta \Theta _ { \perp } = U _ { \perp } ^ { \top } \delta \Theta V _ { \perp }$ . Then $\| \Theta ^ { * } + \delta \Theta \| _ { * } \geq \| \Theta ^ { * } + \delta \Theta _ { \perp } \| _ { * } - \| \delta \Theta - \delta \Theta _ { \perp } \| _ { * } = \| \Theta ^ { * } \| _ { * } +$ $\lVert \delta \Theta _ { \perp } \rVert _ { * } - \lVert \delta \Theta - \delta \Theta _ { \perp } \rVert _ { * } \geq \lVert \Theta ^ { * } \rVert _ { * } + \lVert \delta \Theta _ { \perp } \rVert _ { * } - \sqrt { 2 d } \lVert \delta \Theta - \delta \Theta _ { \perp } \rVert _ { F } .$ + +Going back to Inequality (11), and combing with Lemma 1 and Lemma 2, we have, with probability at least $\begin{array} { r } { 1 - \frac { 3 } { T } - \frac { \dot { 2 } } { T ^ { 2 } } - \frac { 2 } { L T } - \frac { 2 } { L ^ { 3 } T ^ { 3 } } - \frac { 1 } { T ^ { \frac { 1 } { 3 } } } } \end{array}$ , the following holds + +$$ +\begin{array} { r l } & { \quad \left( \frac { \displaystyle \lfloor T ^ { \frac { 3 } { 3 } } \rfloor } { 2 T } h ^ { 2 } - 1 4 T ^ { - \frac { 2 } { 3 } } ( h + h ^ { 2 } ) \left( 2 d _ { x } + 2 d _ { a } + 6 \log T + 6 \log L \right) ^ { 2 } \log T \right) \| \delta \Theta \| _ { F } ^ { 2 } } \\ & { \le \| \delta \Theta \| _ { F } \frac { \sigma \sqrt { d _ { x } + 1 } } { \sqrt { L T } } T ^ { \frac { 1 } { 3 0 } } + } \\ & { \quad \Big ( \frac { 8 h \sigma } { T } \sqrt { l o g ( T L ) } \sqrt { \left( d _ { x } + 3 l o g ( L T ) \right) \left( d _ { a } + 3 l o g T \right) } ( l o g ( d _ { x } + d _ { a } ) + 2 l o g T ) + } \\ & { \quad 2 h \sigma T ^ { - 2 / 3 } l o g T \sqrt { \frac { \operatorname* { m a x } \left\{ d _ { a } , d _ { x } \right\} l o g ( d _ { a } + d _ { x } ) } { L } } \Big ) \left( \| \delta \Theta - \delta \Theta _ { \perp } \| _ { * } + \| \delta \Theta _ { \perp } \| _ { * } \right) } \\ & { \quad + \lambda _ { 0 } \frac { \sqrt { T } } { T } \sqrt { 2 d } \| \delta \Theta \| _ { F } - \lambda _ { 0 } \frac { \sqrt { T } } { T } \| \delta \Theta _ { \perp } \| _ { * } . } \end{array} +$$ + +Note that $\lVert \delta \Theta - \delta \Theta _ { \perp } \rVert _ { * } \leq \sqrt { 2 d } \lVert \delta \Theta - \delta \Theta _ { \perp } \rVert _ { F }$ , divide both side with $\| \delta \Theta \| _ { F }$ and multiply both sides with $3 T ^ { \frac { 1 } { 3 } } / h ^ { 2 }$ . Suppose $T _ { 1 }$ satisfies + +$$ +\begin{array} { r l } & { \quad T _ { 1 } \geq 8 , } \\ & { \quad T _ { 1 } ^ { \frac { 1 } { 3 } } \geq 1 2 \times 1 4 ( 1 + \displaystyle \frac { 1 } { h } ) \left( 2 d _ { x } + 2 d _ { a } + 6 \log T _ { 1 } + 6 \log L \right) ^ { 2 } \log T _ { 1 } , } \\ & { \lambda _ { 0 } T _ { 1 } ^ { \frac { 1 } { 6 } } \geq \displaystyle \frac { 8 h \sigma } { T _ { 1 } ^ { \frac { 1 } { 3 } } } \sqrt { \log \left( T _ { 1 } L \right) } \sqrt { ( d _ { x } + 3 \log ( L T ) ) ( d _ { a } + 3 \log T _ { 1 } ) } ( \log ( d _ { x } + d _ { a } ) + 2 l o g T _ { 1 } ) + } \\ & { \quad \quad 2 h \sigma T _ { 1 } ^ { - 2 / 3 } \log T _ { 1 } \sqrt { \frac { \operatorname* { m a x } \left\{ d _ { a } , d _ { x } \right\} \log \left( d _ { a } + d _ { x } \right) } { L } } } \end{array} +$$ + +we have + +$$ +\Vert \delta \Theta \Vert _ { F } \leq \frac { 3 } { T ^ { \frac { 2 } { 1 5 } } } \frac { \sigma \sqrt { d _ { x } + 1 } } { \sqrt { L } h ^ { 2 } } + 6 \lambda _ { 0 } \frac { \sqrt { 2 d } } { h ^ { 2 } T ^ { \frac { 1 } { 6 } } } . +$$ + +Note that there is a constant $C _ { h , L , \lambda _ { 0 } }$ depending on L, h and $\lambda _ { 0 }$ such that for + +$$ +\begin{array} { r } { T _ { 1 } \geq C _ { h , L , \lambda _ { 0 } } ( d _ { x } + d _ { a } ) ^ { 6 } \left( l o g ( d _ { x } + d _ { a } ) \right) ^ { 3 } , } \end{array} +$$ + +Inequalities (13) holds. + +Next we will proceed to bound the regret. Denote the event that (14) holds to be $Q _ { t }$ and its complement as $Q _ { t } ^ { c }$ . Then $\begin{array} { r } { \mathbb { P } ( Q _ { t } ^ { c } ) \le \frac { 3 } { T } + \frac { 2 } { T ^ { 2 } } + \frac { 2 } { L T } + \frac { 2 } { L ^ { 3 } T ^ { 3 } } + \frac { 1 } { T ^ { \frac { 2 } { 1 5 } } } } \end{array}$ and $\left( Q _ { t } ^ { c } , \hat { \Theta } _ { t } \right) \perp \perp b _ { t + 1 }$ . Let the oracle + +optimal action at time $t$ be $\pmb { a } _ { t } ^ { * }$ and $\begin{array} { r } { \pmb { b } _ { t } = \sum _ { l = 1 } ^ { L } \pmb { x } _ { t , l } } \end{array}$ . Then + +$$ +\begin{array} { r l } & { \mathbb { E } _ { \lambda \sim \lambda } ^ { \lambda } = \Bigg \langle \frac { \lambda ^ { 2 } } { \lambda ^ { 2 } } - \frac { \lambda ^ { 2 } } { \lambda ^ { 2 } } \Bigg | \frac { \partial \mathbf { x } } { \partial \mathbf { y } } \Bigg ( \mathbf { y } _ { \lambda \sim \lambda } - \mathbf { z } _ { \lambda \sim \lambda } ^ { 2 } - \mathbf { y } _ { \lambda \sim \lambda } ^ { 2 } \mathbf { y } _ { \lambda \sim \lambda } \Bigg ) \Bigg \rangle } \\ & { \leq \Bigg \langle \sum _ { \mu \geq \lambda } \frac { \lambda ^ { 2 } } { \lambda ^ { 2 } } \Bigg ( \mathbf { z } _ { \mu \sim \lambda } ^ { 2 } - \mathbf { z } _ { \mu \sim \lambda } ^ { 2 } - \mathbf { z } _ { \mu \sim \lambda } ^ { 2 } \mathbf { z } _ { \mu \sim \lambda } \Bigg ) \Bigg \rangle } \\ & { \leq \mathbb { E } _ { \lambda \sim \lambda } ^ { \lambda } \Bigg [ \Bigg \langle \frac { \lambda ^ { 2 } } { \lambda ^ { 2 } } \Bigg ( \mathbf { z } _ { \mu \sim \lambda } ^ { 2 } - \mathbf { z } _ { \mu \sim \lambda } ^ { 2 } - \mathbf { z } _ { \mu \sim \lambda } ^ { 2 } \mathbf { z } _ { \mu \sim \lambda } \Bigg ) \Bigg \rangle } \\ & { \leq \Bigg \langle \sum _ { \mu \geq \lambda } \Bigg ( \frac { \lambda ^ { 2 } } { \lambda ^ { 2 } } \Bigg \mathbf { z } _ { \mu \sim \lambda } ^ { 2 } - \mathbf { z } _ { \mu \sim \lambda } ^ { 2 } \mathbf { z } _ { \mu \sim \lambda } ^ { 2 } \mathbf { z } _ { \mu \sim \lambda } \Bigg ) \Bigg \rangle } \\ & { = \Bigg \langle \sum _ { \mu \geq \lambda } \Bigg ( \frac { \lambda ^ { 2 } } { \lambda ^ { 2 } } \Bigg \mathbf { z } _ { \mu \sim \lambda } ^ { 2 } - \mathbf { z } _ { \mu \sim \lambda } ^ { 2 } \mathbf { z } _ { \mu \sim \lambda } ^ { 2 } \mathbf { z } _ { \mu \sim \lambda } \Bigg ) \Bigg \rangle \times \Bigg \langle \int _ { \lambda \sim \lambda } ^ { \infty } \mathbf { z } _ { \mu \sim \lambda } ^ { \lambda } - \frac { \lambda ^ { 2 } } { \lambda ^ { 2 } } \mathbf { z } _ { \mu \sim \lambda } \mathbf { z } _ { \lambda \sim \lambda } ^ { \lambda } \mathbf { z } _ { \lambda \sim \lambda } ^ { \lambda } } \\ & = \sum _ { \mu \geq \lambda } \end{array} +$$ + +Similar arguments also give + +$$ +\mathbb { E } \left( \sum _ { t = 0 } ^ { T _ { 1 } - 1 } \sum _ { l = 1 } ^ { L } \mathbb { E } \left( \pmb { a } _ { t } ^ { * } ^ { \top } \pmb { \Theta } ^ { * } \pmb { x } _ { t , l } - \pmb { a } _ { t } ^ { \top } \pmb { \Theta } ^ { * } \pmb { x } _ { t , l } \right) \right) \leq T _ { 1 } \times 2 \sqrt { L d _ { x } } \| \pmb { \Theta } ^ { * } \| _ { 2 } . +$$ + +Therefore, for $T \geq T _ { 1 }$ , + +$$ +\frac { R _ { T } ^ { \pi } } { T } \leq 2 \sqrt { L d _ { x } } \| \Theta ^ { * } \| _ { 2 } T _ { 1 } T ^ { - 1 } + \frac { 6 0 } { 1 3 } \sqrt { L d _ { x } } \| \Theta ^ { * } \| _ { 2 } T ^ { - \frac { 2 } { 1 5 } } + \frac { 9 0 } { 1 3 } \frac { \sigma ( d _ { x } + 1 ) } { h ^ { 2 } } T ^ { - \frac { 2 } { 1 5 } } + \frac { 7 2 } { 5 } \lambda _ { 0 } \frac { \sqrt { 2 d d _ { x } } L } { h ^ { 2 } } T ^ { - \frac { 2 } { 6 } } + \frac { 1 } { 2 5 } \lambda _ { 0 } \frac { \sigma ( d _ { x } + 1 ) } { h ^ { 2 } } . +$$ + +# A.1 PROOF OF LEMMA 2 + +Suppose $r _ { t , l } = a _ { t , l } \Theta ^ { * } x _ { t , l } + \sigma \varepsilon _ { t , l }$ , then + +$$ +\begin{array} { l } { \displaystyle \nabla \mathcal { L } _ { T } \big ( \Theta ^ { * } \big ) = \frac { \sigma } { L T } \sum _ { t = 1 } ^ { T } \sum _ { l = 1 } ^ { L } - \varepsilon _ { t , l } \boldsymbol { x } _ { t , l } \boldsymbol { a } _ { t , l } ^ { \top } } \\ { \displaystyle = \frac { \sigma } { L T } \sum _ { l = 1 } ^ { L } - \varepsilon _ { 1 , l } \boldsymbol { x } _ { 1 , l } \boldsymbol { a } _ { 1 , l } ^ { \top } } \\ { \displaystyle \quad + \frac { \sigma } { L T } \sum _ { t = 2 } ^ { T } \sum _ { l = 1 } ^ { L } \left( - \varepsilon _ { t , l } \boldsymbol { x } _ { t , l } \hat { \boldsymbol { a } } _ { t } ^ { \top } - \varepsilon _ { t , l } \boldsymbol { x } _ { t , l } \delta _ { t } ^ { \top } \right) } \end{array} +$$ + +Now we consider the terms in (18) separately. Let + +$$ +\begin{array} { l } { { \displaystyle S _ { 2 } = \frac { \sigma } { L T } \sum _ { l = 1 } ^ { L } - \varepsilon _ { 1 , l } \pmb { x } _ { 1 , l } \pmb { a } _ { 1 , l } ^ { \top } + \frac { \sigma } { L T } \sum _ { t = 2 } ^ { T } \sum _ { l = 1 } ^ { L } - \varepsilon _ { t , l } \pmb { x } _ { t , l } \hat { \pmb { a } } _ { t } ^ { \top } . } } \\ { { \displaystyle S _ { 3 } = \frac { \sigma } { L T } \sum _ { t = 2 } ^ { T } \sum _ { l = 1 } ^ { L } - \varepsilon _ { t , l } \pmb { x } _ { t , l } \delta _ { t } ^ { \top } } } \end{array} +$$ + +Elementary Calculation show that + +$$ +\mathbb { E } ( \| S _ { 2 } \| _ { F } ^ { 4 } ) \le \frac { \sigma ^ { 4 } ( d _ { x } ^ { 2 } + 2 d _ { x } ) } { L ^ { 2 } T ^ { 2 } } . +$$ + +Therefore, + +$$ +P ( \| S _ { 2 } \| _ { F } \geq \frac { \sigma \sqrt { d _ { x } + 1 } } { \sqrt { L T } } T ^ { \frac { 1 } { 3 0 } } ) \leq \frac { 1 } { T ^ { \frac { 2 } { 1 5 } } } . +$$ + +For $S _ { 3 }$ , let $G$ be an event defined as + +$$ +\begin{array} { r l r } & { } & { G = \Big \{ \operatorname* { m a x } \{ | \varepsilon _ { t , l } | : 1 \leq t \leq T , 1 \leq l \leq L \} \leq 3 \sqrt { \log T L } , } & \\ & { } & { \operatorname* { m a x } \{ \| x _ { t , l } \| ^ { 2 } : 1 \leq t \leq T , 1 \leq l \leq L \} \leq 2 d _ { x } + 6 \log L T , } & \\ & { } & { \operatorname* { m a x } \{ \| \delta _ { t } / h \| _ { 2 } ^ { 2 } : 1 \leq t \leq T \} \leq 2 d _ { a } + 6 \log T \Big \} . } \end{array} +$$ + +Then elementary calculation shows that + +$$ +P ( G ^ { c } ) \leq \frac { 2 } { T ^ { 3 } L ^ { 3 } } + \frac { 1 } { L T } + \frac { 1 } { T } . +$$ + +Using Matrix Bernstein Inequality (Tropp, 2012) on event G, we have the operator norm of $S _ { 3 }$ on $\mathbf { G }$ is bounded as follows + +$$ +P ( \{ \| \frac { L T } { \sigma } S _ { 3 } \| _ { 2 } \ge \alpha \} \cap G ) \le ( d _ { x } + d _ { a } ) \exp { ( \frac { - \alpha ^ { 2 } } { 2 \sigma _ { S _ { 3 } } ^ { 2 } + 2 D \alpha / 3 } ) } , +$$ + +where + +$$ +\begin{array} { r } { \sigma _ { S _ { 3 } } ^ { 2 } \geq \operatorname* { m a x } \Big \{ \Big \| \displaystyle \sum _ { t = 1 } ^ { T } \mathbb { E } \left( ( \displaystyle \sum _ { l = 1 } ^ { L } \varepsilon _ { t , l } \pmb { x } _ { t , l } \delta _ { t } ^ { \top } ) ( \displaystyle \sum _ { l = 1 } ^ { L } \varepsilon _ { t , l } \pmb { x } _ { t , l } \delta _ { t } ^ { \top } ) ^ { \top } \right) \Big \| _ { 2 } , } \\ { \Big \| \displaystyle \sum _ { t = 1 } ^ { T } \mathbb { E } \left( ( \displaystyle \sum _ { l = 1 } ^ { L } \varepsilon _ { t , l } \pmb { x } _ { t , l } \delta _ { t } ^ { \top } ) ^ { \top } ( \displaystyle \sum _ { l = 1 } ^ { L } \varepsilon _ { t , l } \pmb { x } _ { t , l } \delta _ { t } ^ { \top } ) \right) \Big \| _ { 2 } \Big \} , } \end{array} +$$ + +and + +$$ +D = \operatorname* { m a x } _ { t } \operatorname* { s u p } _ { \mathrm { \ e v e n t { \cal G } \ h o l d s } } \| \sum _ { l = 1 } ^ { L } - \varepsilon _ { t , l } x _ { t , l } \delta _ { t } ^ { \top } \| _ { 2 } \leq 6 L \sqrt { \log T L } h \sqrt { ( d _ { x } + 3 \log L T ) ( d _ { a } + 3 \log T ) } . +$$ + +Elementary calculation shows that taking + +$$ +\sigma _ { S _ { 3 } } ^ { 2 } = h ^ { 2 } \lfloor T ^ { \frac { 2 } { 3 } } \rfloor L \operatorname* { m a x } \{ d _ { a } , d _ { x } \} +$$ + +satisfies Equation (25). + +Taking + +$$ +\begin{array} { c l r } { \alpha } & { } & { \displaystyle { \alpha = 2 h T ^ { \frac 1 3 } l o g T \sqrt { L \operatorname* { m a x } \{ d _ { a } , d _ { x } \} l o g ( d _ { a } + d _ { x } ) } + } } \\ & { } & { 8 h L \sqrt { l o g T L } \sqrt { ( d _ { x } + 3 l o g ( L T ) ) ( d _ { a } + 3 l o g T ) } ( l o g ( d _ { x } + d _ { a } ) + 2 l o g T ) } \\ & { } & { \displaystyle P ( \{ \| \frac { L T } \sigma S _ { 3 } \| _ { 2 } \geq \alpha \} \cap G ) \leq \frac { 1 } { T ^ { 2 } } . } \end{array} +$$ + +Therefore, we have + +$$ +\begin{array} { r l } & { P \Big ( \| S _ { 3 } \| _ { 2 } \leq 2 h \sigma T ^ { - 2 / 3 } l o g T \sqrt { \frac { \operatorname* { m a x } \{ d _ { a } , d _ { x } \} l o g ( d _ { a } + d _ { x } ) } { L } } + } \\ & { \qquad \frac { 8 h \sigma } { T } \sqrt { l o g ( T L ) } \sqrt { ( d _ { x } + 3 l o g ( L T ) ) ( d _ { a } + 3 l o g T ) } ( l o g ( d _ { x } + d _ { a } ) + 2 l o g T ) \Big ) } \\ & { \geq 1 - \frac { 2 } { L ^ { 3 } T ^ { 3 } } - \frac { 1 } { L T } - \frac { 1 } { T } - \frac { 1 } { T ^ { 2 } } } \end{array} +$$ + +Recalling that + +$$ +| \langle \nabla \mathcal { L } _ { T } ( \Theta ^ { * } ) , \Delta \rangle | = | \langle S _ { 2 } , \Delta \rangle + \langle S _ { 3 } , \Delta \rangle | \leq \| S _ { 2 } \| _ { F } \| \Delta \| _ { F } + \| S _ { 3 } \| _ { 2 } \| \Delta \| _ { * } , +$$ + +we get the statement of the lemma. + +A.2 PROOF OF LEMMA 1 + +$\begin{array} { r } { \pmb { b } _ { t } = \sum _ { l = 1 } ^ { L } \pmb { x } _ { t , l } } \end{array}$ . Let $\delta _ { t } = \mathbf { 0 }$ for exploitation rounds. + +Then we know that + +$$ +\begin{array} { c l } { \displaystyle \mathcal E _ { T } ( \Delta ) = \frac 1 { 2 L T } \sum _ { t = 1 } ^ { T } \sum _ { l = 1 } ^ { L } ( { \boldsymbol a } _ { t , l } ^ { \top } \Delta { \boldsymbol x } _ { t , l } ) ^ { 2 } } \\ { \displaystyle = \frac 1 { 2 L T } \sum _ { t = 1 } ^ { T } \sum _ { l = 1 } ^ { L } ( ( \frac { b _ { t } ^ { \top } \hat { \boldsymbol \Theta } _ { t - 1 } ^ { \top } } { \| b _ { t } ^ { \top } \hat { \boldsymbol \Theta } _ { t - 1 } ^ { \top } \| } + \delta _ { t } ^ { \top } ) \Delta { \boldsymbol x } _ { t , l } ) ^ { 2 } } \end{array} +$$ + +Define + +$$ +\begin{array} { l } { \displaystyle \mathcal { D } _ { T } ( \Delta ) = \frac { 1 } { 2 L T } \sum _ { t = 1 } ^ { T } \sum _ { l = 1 } ^ { L } \left( ( \frac { b _ { t } ^ { \top } \hat { \Theta } _ { t - 1 } ^ { \top } } { \| b _ { t } ^ { \top } \hat { \Theta } _ { t - 1 } ^ { \top } \| } \Delta x _ { t , l } ) ^ { 2 } + ( \delta _ { t } ^ { \top } \Delta x _ { t , l } ) ^ { 2 } \right) , } \\ { \displaystyle \mathcal { D } _ { 1 , T } ( \Delta ) = \frac { 1 } { 2 L T } \sum _ { t = 1 } ^ { T } \sum _ { l = 1 } ^ { L } ( \frac { b _ { t } ^ { \top } \hat { \Theta } _ { t - 1 } ^ { \top } } { \| b _ { t } ^ { \top } \hat { \Theta } _ { t - 1 } ^ { \top } \| } \Delta x _ { t , l } ) ^ { 2 } } \\ { \displaystyle \mathcal { D } _ { 2 , T } ( \Delta ) = \frac { 1 } { 2 L T } \sum _ { t = 1 } ^ { T } \sum _ { l = 1 } ^ { L } ( \delta _ { t } ^ { \top } \Delta x _ { t , l } ) ^ { 2 } } \end{array} +$$ + +Then + +$$ +\mathcal { E } _ { T } ( \Delta ) - \mathcal { D } _ { T } ( \Delta ) = \frac { 1 } { L T } \sum _ { t = 1 } ^ { T } \sum _ { l = 1 } ^ { L } ( \frac { b _ { t } ^ { \top } \hat { \Theta } _ { t - 1 } ^ { \top } } { \| b _ { t } ^ { \top } \hat { \Theta } _ { t - 1 } ^ { \top } \| } \Delta \pmb { x } _ { t , l } ) ( \pmb { \delta } _ { t } ^ { \top } \Delta \pmb { x } _ { t , l } ) +$$ + +Elementary calculation shows that + +$$ +\mathbb { E } ( \mathcal { E } _ { T } ( \Delta ) - \mathcal { D } _ { T } ( \Delta ) ) = 0 , +$$ + +and + +$$ +\mathbb { E } ( { \cal D } _ { 2 , T } ( \Delta ) ) \geq \frac { \lfloor T ^ { \frac { 2 } { 3 } } \rfloor } { 2 T } h ^ { 2 } \| \Delta \| _ { F } ^ { 2 } . +$$ + +Now we proceed with proving that the following two holds with high probability: + +$$ +\begin{array} { r l } & { \underset { | | \Delta | | _ { 2 } > 0 } { \operatorname* { i n f } } \frac { \mathcal { E } _ { T } ( \Delta ) - \mathcal { D } _ { T } ( \Delta ) } { | | \Delta | | _ { 2 } ^ { 2 } } \ge - 7 T ^ { - \frac { 2 } { 3 } } ( h + h ^ { 2 } ) \left( 2 d _ { x } + 2 d _ { a } + 6 \log T + 6 \log L \right) ^ { 2 } \log T } \\ & { \underset { | | \Delta | | _ { 2 } > 0 } { \operatorname* { i n f } } \frac { \mathcal { D } _ { 2 , T } ( \Delta ) - \mathbb { E } \left( \mathcal { D } _ { 2 , T } ( \Delta ) \right) } { | | \Delta | | _ { 2 } ^ { 2 } } \ge - 7 T ^ { - \frac { 2 } { 3 } } ( h + h ^ { 2 } ) \left( 2 d _ { x } + 2 d _ { a } + 6 \log T + 6 \log L \right) ^ { 2 } \log T . } \end{array} +$$ + +Note that $\lVert \pmb { x } _ { t , l } \rVert _ { 2 } ^ { 2 } \sim \chi _ { d _ { x } } ^ { 2 }$ , $\| \delta _ { t } / h \| _ { 2 } ^ { 2 } \sim \chi _ { d _ { a } } ^ { 2 }$ . Therefore, we have that + +$$ +\begin{array} { r l } & { P ( \underset { t , l } { \operatorname* { s u p } } \| \pmb { x } _ { t , l } \| _ { 2 } ^ { 2 } \leq d _ { x } + 2 \epsilon _ { 1 } + 2 \sqrt { \epsilon _ { 1 } d _ { x } } , \underset { t } { \operatorname* { s u p } } \| \pmb { \delta } _ { t } / h \| _ { 2 } ^ { 2 } \leq d _ { a } + 2 \epsilon _ { 2 } + 2 \sqrt { \epsilon _ { 2 } d _ { a } } ) } \\ & { \geq 1 - \left( L T \exp \left( - \epsilon _ { 1 } \right) + T \exp \left( - \epsilon _ { 2 } \right) \right) . } \end{array} +$$ + +Let $\epsilon _ { 1 } = 2 \log L T , \epsilon _ { 2 } = 2 \log T$ . + +Denote + +$$ +U _ { 1 } = d _ { x } + 2 \epsilon _ { 1 } + 2 \sqrt { \epsilon _ { 1 } d _ { x } } , U _ { 2 } = d _ { a } + 2 \epsilon _ { 2 } + 2 \sqrt { \epsilon _ { 2 } d _ { a } } . +$$ + +And let the event $O$ be + +$$ +O = \{ \underset { t , l } { \operatorname* { s u p } } \| \pmb { x } _ { t , l } \| _ { 2 } ^ { 2 } \leq U _ { 1 } , \underset { t } { \operatorname* { s u p } } \| \pmb { \delta } _ { t } / h \| _ { 2 } ^ { 2 } \leq U _ { 2 } \} . +$$ + +For the following, we restrict our attention to event $O$ . + +Note that + +$$ +\operatorname* { i n f } _ { U _ { 0 } / 1 . 1 \parallel \Delta \parallel _ { 2 } \le U _ { 0 } } \mathcal { E } _ { T } ( \Delta ) - \mathcal { D } _ { T } ( \Delta ) \ge \operatorname* { i n f } _ { U _ { 0 } / 1 . 1 \parallel \Delta \parallel _ { 2 } \le U _ { 0 } , \hat { \Theta } _ { t - 1 } ^ { \top } \neq \mathbf { 0 } \mathrm { ~ f o r ~ } 1 \le t \le T } \mathcal { E } _ { T } ( \Delta ) - \mathcal { D } _ { T } ( \Delta ) , +$$ + +also at most $\lfloor T ^ { \frac { 2 } { 3 } } \rfloor$ terms in the sum of $\mathcal { E } _ { T } ( \Delta ) \ : - \ : \mathcal { D } _ { T } ( \Delta )$ are not zero, and for any term $\begin{array} { r l } & { \mathrm { \mathfrak { n } ~ t h e ~ e x p l o r a t i o n ~ r o u n d ~ \left( s u p \right)} _ { U _ { 0 } / 1 . 1 \leq | | \Delta | | _ { 2 } \leq U _ { 0 } , \hat { \Theta } _ { t - 1 } ^ { \top } | ^ { \neq } 0 \mathrm { \ f o r ~ } 1 \leq t \leq T } ( \frac { b _ { t } ^ { \top } \hat { \Theta } _ { t - 1 } ^ { \top } } { | | b _ { t } ^ { \top } \hat { \Theta } _ { t - 1 } ^ { \top } | | } \Delta x _ { t , l } ) ( \delta _ { t } ^ { \top } \Delta x _ { t , l } ) - } \\ & { \overset { \mathrm { \ f } } { \operatorname* { i n f } } _ { U _ { 0 } / 1 . 1 \leq | | \Delta | | _ { 2 } \leq U _ { 0 } , \hat { \Theta } _ { t - 1 } ^ { \top } \neq 0 \mathrm { \ f o r ~ } 1 \leq t \leq T } ( \frac { b _ { t } ^ { \top } \hat { \Theta } _ { t - 1 } ^ { \top } } { | | b _ { t } ^ { \top } \hat { \Theta } _ { t - 1 } ^ { \top } | | } \Delta x _ { t , l } ) ( \delta _ { t } ^ { \top } \Delta x _ { t , l } ) \Big ) \leq 2 U _ { 1 } \sqrt { U _ { 2 } } h U _ { 0 } ^ { 2 } } \end{array}$ + +Therefore, through Functional Hoeffding theorem (Theorem 3.26 in Wainwright (2019))), we have + +$$ +P ( \mathcal { E } _ { T } ( \Delta ) - \mathcal { D } _ { T } ( \Delta ) \leq - \gamma _ { 1 } | O ) \leq \exp \left( - \frac { \frac { T ^ { 2 } } { \lfloor T ^ { \frac { 2 } { 3 } } \rfloor } \gamma _ { 1 } ^ { 2 } } { 1 6 U _ { 1 } ^ { 2 } U _ { 2 } h ^ { 2 } U _ { 0 } ^ { 4 } } \right) +$$ + +for $\gamma _ { 1 } > 0$ . + +Similarly, for the exploration rounds in $\mathcal { D } _ { 2 , T } ( \Delta )$ , we have + +$$ +\left( \operatorname* { s u p } _ { U _ { 0 } / 1 . 1 \leq \| \Delta \| \leq U _ { 0 } } ( \delta _ { t } ^ { \top } \Delta \pmb { x } _ { t , l } ) ^ { 2 } \right) - \left( \operatorname* { i n f } _ { U _ { 0 } / 1 . 1 \leq \| \Delta \| \leq U _ { 0 } } ( \delta _ { t } ^ { \top } \Delta \pmb { x } _ { t , l } ) ^ { 2 } \right) \leq U _ { 1 } U _ { 2 } U _ { 0 } ^ { 2 } h ^ { 2 } . +$$ + +Again, according to Functional Hoeffding theorem, we have + +$$ +P ( \mathcal { D } _ { 2 , T } ( \Delta ) - \mathbb { E } \left( \mathcal { D } _ { 2 , T } ( \Delta ) \right) \leq - \gamma _ { 2 } | O ) \leq \exp \big ( - \frac { \frac { T ^ { 2 } } { \lfloor T ^ { \frac { 2 } { 3 } } \rfloor } \gamma _ { 2 } ^ { 2 } } { 4 U _ { 1 } ^ { 2 } U _ { 2 } ^ { 2 } U _ { 0 } ^ { 4 } h ^ { 4 } } \big ) +$$ + +Therefore, + +$$ +\begin{array} { r l } & { P \left( \mathcal { E } _ { T } ( \Delta ) - \mathbb { E } ( \mathcal { D } _ { 2 , T } ) \leq - 1 4 T ^ { - \frac { 2 } { 3 } } ( h + h ^ { 2 } ) \left( 2 d _ { x } + 2 d _ { a } + 6 \log T + 6 \log L \right) ^ { 2 } \| \Delta \| _ { 2 } ^ { 2 } \log T \right) } \\ & { \leq P \left( \mathcal { E } _ { T } ( \Delta ) - \mathcal { D } _ { T } ( \Delta ) \leq - 7 T ^ { - \frac { 2 } { 3 } } ( h + h ^ { 2 } ) \left( 2 d _ { x } + 2 d _ { a } + 6 \log T + 6 \log L \right) ^ { 2 } \| \Delta \| _ { 2 } ^ { 2 } \log T | O \right) } \\ & { + P \left( \mathcal { D } _ { 1 , T } ( \Delta ) \leq 0 | O \right) } \\ & { + P \left( \mathcal { D } _ { 2 , T } - \mathbb { E } ( \mathcal { D } _ { 2 , T } ) \leq - 7 T ^ { - \frac { 2 } { 3 } } ( h + h ^ { 2 } ) \left( 2 d _ { x } + 2 d _ { a } + 6 \log T + 6 \log L \right) ^ { 2 } \| \Delta \| _ { 2 } ^ { 2 } \log T | O \right) } \\ & { + P ( O ^ { c } ) } \\ & { \leq \frac { 1 } { L T } + \frac { 2 } { T } + \frac { 1 } { T ^ { 2 } } } \\ & { { \quad \alpha ^ { 4 } } } \end{array} +$$ + +Hence with probability at least $\textstyle 1 - { \frac { 1 } { L T } } - { \frac { 2 } { T } } - { \frac { 1 } { T ^ { 2 } } }$ , + +$$ +\mathcal { E } _ { T } ( \Delta ) \geq \frac { \lfloor T ^ { \frac { 2 } { 3 } } \rfloor } { 2 T } h ^ { 2 } \| \Delta \| _ { F } ^ { 2 } - 1 4 T ^ { - \frac { 2 } { 3 } } ( h + h ^ { 2 } ) \left( 2 d _ { x } + 2 d _ { a } + 6 \log T + 6 \log L \right) ^ { 2 } \| \Delta \| _ { 2 } ^ { 2 } \log T . +$$ + +APPENDIX B DETAILS ON THE SIMULATION STUDY + +In this section, we detail the tuning parameters of each algorithm we used for the simulation study. + +Hi-CCAB. There are three tuning parameters for Hi-CCAB: we set the steps for initialization $t _ { 1 } =$ 100, the initialized penalization parameter $\begin{array} { r } { \lambda _ { 0 } = \| \frac { 1 } { 2 t _ { 1 } L } \sum _ { i = 1 } ^ { t _ { 1 } } \sum _ { j = 1 } ^ { L } | \pmb { a } _ { i } ^ { \top } \widehat { \Theta } _ { t _ { 1 } } \pmb { x } _ { i , j } - r _ { i , j } | \pmb { x } _ { i , j } \pmb { a } _ { i } ^ { \top } \| _ { 2 } } \end{array}$ , and the exploration parameter $h = . 1$ . + +LinUCB (Li et al., 2010). We apply the LinUCB with disjoint linear models and set multiplier for the upper confidence bound $\alpha = 1 + \sqrt { \ln ( 2 / \delta ) / 2 }$ with $\delta = . 0 5$ as suggested in the paper. + +Lasso Bandit (Bastani & Bayati, 2020). There are a couple of tuning parameters in the original algorithm including $h$ for the set of “near-optimal arms”, $q$ for the force-sample set, and $\lambda _ { 1 }$ and $\lambda _ { 2 , 0 }$ as the regularization parameters for the “forced sample estimate” and “all-sample estimate”. We follow the original paper and set $h = 5$ , $\lambda _ { 1 } = \lambda _ { 2 , 0 } = 0 . 0 5$ . We set $q = 2$ so that the size of initialized forced sample set is close to that we used for Hi-CCAB. + +NeuralUCB (Zhou et al., 2020). The tuning parameters of NeuralUCB include the confidence parameter as in all UCB-based algorithm, the size of neural network, as well as the step size, regularization parameter for gradient descent to train the neural network. We adapted the code from https://github.com/uclaml/NeuralUCB and used the default settings. + +EE-Net (Ban et al., 2022). EE-Net involves tuning parameters for gradient descent to train the exploitation network, exploration network, and the decision-maker network. We adapted the code from https://github.com/banyikun/EE-Net-ICLR-2022 and used the default settings. + +# APPENDIX C MORE DETAILS ON THE CASE STUDY AND ADDITIONAL NUMERICAL RESULTS + +In this section, we provides more background information on the case study and additional interpretations of the represetation matrix $\Theta$ and numerical results. + +Figure 3a shows the daily sales by product and each color represents one product (only products that appeared more than $9 5 \%$ of the days are colored; the rest are colored as grey). The days corresponding to the vertical dashed grey lines are days with promotion. The two red vertical lines correspond to the annual sales events. The variation between products was large and one product dominated the rest most of the time. The sales were also driven by the promotion – the sales went up when there is a promotion. Figure 3b shows the median unit price across time with the 25th and 75th quantiles as the boundaries of the grey area. The median unit price was around $3 . 2 \mathrm { R M B }$ and there were variations in unit price among products. Figure 3c shows the number of single-flavor and multi-flavor products. Three-quarters of the products were single-flavored. Note that products with the same flavor can have different package sizes. Figure 3d shows the number of products with different package sizes. The package size of about $60 \%$ of the products is larger than 20 with $30 \%$ having package sizes between 10 and 20 and the rest less than 10. + +Figure 4 compares the real sales with the simulated sales based on model (1) using the pseudo ground truth $\Theta$ and $\sigma$ that we estimated using all the data, i.e., the teal line is $\textstyle \sum _ { j = 1 } ^ { L } r _ { t , j }$ where $\boldsymbol { r } _ { t , j }$ is generated by + +$$ +r _ { t , j } = \pmb { a } _ { t } ^ { \top } \Theta x _ { t , j } + \varepsilon _ { t , j } , \quad \varepsilon _ { t , j } \ N ( 0 , \sigma ^ { 2 } ) +$$ + +where $\mathbf { } \mathbf { a } _ { t }$ and $\mathbf { \Delta x } _ { t , j }$ are from the real data. As shown in Figure 4, the real sales and the simulated sales follow quite closely across time, which indicates that both our model and estimation are reasonable. + +Structure of the representation matrix $\Theta$ . One advantage of model is the interpretability which allows us to gain insights from the representation matrix $\Theta$ . Specifically, our model is able to discover the underlying factors of the effect of both arms and covariates on the reward. In the following, we will examine the pseudo ground truth $\Theta$ we obtained using all the data. + +The rank of $\Theta$ is 5 with the singular values being $( 2 . 5 , 0 . 3 , 0 . 2 , 0 . 0 2 , 0 . 0 0 2 )$ . The leading singular value dominates the rest and thus the leading left and right singular vectors are the most important ones in explaining the effect on the reward and we focus on the leading singular vectors in what follows. + +Figure 5 shows the loadings for different covariates (i.e., the leading right singular vector) and our algorithm is able to learn interpretable patterns of the effects on the reward – for weekday, the effects are drastically different during the weekend and during the weekend; for months, the effects show different patterns during the promotion month (June and November) from other months; for location, the effects of the coastal provinces are different from the rest, which exactly corresponds to the levels of economic development of different regions in China. In sum, our model can exploit the underlying structure of the covariates and provide insights into purchasing behavior and seasonality. + +![](images/e259b8d92cb34fceb75e8b2ee3d4a91357657c5d749c5806900e35254f1dc2fd.jpg) +(c) Number of products with various number of flavors. (d) Number of products with various package sizes. + +![](images/c69e1fad8565962d76228521d8d74058ec21ea0c9221665878d09787026e111a.jpg) +Figure 4: Real sales vs simulated sales. + +![](images/b7e507445abba4d10313b26bcf6e10a423c833fc4b17bacbd4240a4f830f7e86.jpg) +Figure 5: Loadings of the leading right singular vectors for the covariates. + +On the other hand, Table 1 explores the loadings for the arm on May 29th 2022, the last Sunday in our data (i.e., the leading left singular vectors multiplied with $\langle v _ { 1 } , \bar { x } \rangle$ where $\bar { \pmb x }$ is the average of $\mathbf { \Delta } _ { \mathbf { \mathcal { X } } _ { j } }$ for $j = 1 , \dots , L$ on May 29th 2022). Specifically, we investigate the effect of flavors on the reward given the context. We take the average of the loadings of the linear and quadratic terms for each flavor in all 30 products and compare with the total sales of each flavor across all Sundays in Mays. For ease of comparison, we further scale the sales and the loadings by their corresponding largest numbers. The loadings and sales are closely related to each other.1 As in Table 1, on May 29th 2022, flavor 1 (F1) has the largest effect, followed by flavor 10, 13, 7, 9 and 11. Therefore, our model learns the values of the flavors (per unit). + +
F1F2F3F4F5F6F7F8F9F10F11F12F13
Sales1.000.050.000.000.000.030.190.000.080.190.180.000.38
u1 (linear)1.000.000.000.000.000.000.000.000.000.000.000.000.00
u1 (quadratic)1.000.12-0.000.000.000.030.190.000.150.390.160.030.33
+ +Table 1: Total sales and loadings of the linear and quadratic terms (scaled) of the 13 flavors. + +More on simulation with additional numerical results. We first detail how we ran the simulation and then provide more simulation results. To be specific, we first use $t _ { 1 } = 1 0 0$ for the initialization step to estimate $\widehat { \Theta } _ { t _ { 1 } }$ ; and then at each time $t = t _ { 1 } + 1 , \ldots , T$ , we follow Algorithm 1 to decide on the action $\mathbf { } \mathbf { a } _ { t }$ for assortment and pricing. After determining $\mathbf { } \mathbf { a } _ { t }$ , we generate the sales $\mathbf { } _ { \mathbf { } } ^ { \mathbf { } } \mathbf { \Delta } \mathbf { r } _ { t }$ according to (1) using the pseudo true $\Theta$ and $\sigma$ . We further compare the performance of the assortment-pricing policy with exploration and without exploration and with different initialization time $t _ { 1 }$ . Each setup is simulated 100 times. + +Figures 6a-6b show cumulative regret and Figures 6d show percentage gain in cumulative sales when $t _ { 1 } = 2 0 , 5 0 , 1 0 0$ with exploration and without exploration. Hi-CCAB with exploration performs better then without exploration. As expected, longer initialization steps provide a better initial estimation of the $\Theta$ and thus helps with the performance in a short time windows. As time goes by, the time-averaged cumulative regret all converge to zero and the percentage gain in cumulative sales should converge. + +![](images/591033a8c06b46ed88cd377a4f692a00309319232e31cc40842e0a7c48109e41.jpg) +Figure 6: Performance of Hi-CCAB with different initialization times $t _ { 1 }$ and with exploration and without exploration. \ No newline at end of file diff --git a/md/dev/oVE1z8NlNe/oVE1z8NlNe.md b/md/dev/oVE1z8NlNe/oVE1z8NlNe.md new file mode 100644 index 0000000000000000000000000000000000000000..cf96d90bf01dd4d23cabdcfbf591196c15fd81b8 --- /dev/null +++ b/md/dev/oVE1z8NlNe/oVE1z8NlNe.md @@ -0,0 +1,382 @@ +# DIVERGENCE-AWARE FEDERATED SELF-SUPERVISED LEARNING + +Weiming Zhuang1,3, Yonggang Wen2, Shuai Zhang3 +$^ 1 S$ -Lab, NTU, Singapore 2NTU, Singapore 3SenseTime Research +weiming001@e.ntu.edu.sg,ygwen@ntu.edu.sg,zhangshuai@sensetime.com + +# ABSTRACT + +Self-supervised learning (SSL) is capable of learning remarkable representations from centrally available data. Recent works further implement federated learning with SSL to learn from rapidly growing decentralized unlabeled images (e.g., from cameras and phones), often resulted from privacy constraints. Extensive attention has been paid to SSL approaches based on Siamese networks. However, such an effort has not yet revealed deep insights into various fundamental building blocks for the federated self-supervised learning (FedSSL) architecture. We aim to fill in this gap via in-depth empirical study and propose a new method to tackle the nonindependently and identically distributed (non-IID) data problem of decentralized data. Firstly, we introduce a generalized FedSSL framework that embraces existing SSL methods based on Siamese networks and presents flexibility catering to future methods. In this framework, a server coordinates multiple clients to conduct SSL training and periodically updates local models of clients with the aggregated global model. Using the framework, our study uncovers unique insights of FedSSL: 1) stop-gradient operation, previously reported to be essential, is not always necessary in FedSSL; 2) retaining local knowledge of clients in FedSSL is particularly beneficial for non-IID data. Inspired by the insights, we then propose a new approach for model update, Federated Divergence-aware Exponential Moving Average update (FedEMA). FedEMA updates local models of clients adaptively using EMA of the global model, where the decay rate is dynamically measured by model divergence. Extensive experiments demonstrate that FedEMA outperforms existing methods by $3 - 4 \%$ on linear evaluation. We hope that this work will provide useful insights for future research. + +# 1 INTRODUCTION + +Self-supervised learning (SSL) has attracted extensive research interest for learning representations without relying on expensive data labels. In computer vision, the common practice is to design proxy tasks to facilitate visual representation learning from unlabeled images (Doersch et al., 2015; Noroozi & Favaro, 2016; Zhang et al., 2016; Gidaris et al., 2018). Among them, the state-of-the-art SSL methods employ contrastive learning that uses Siamese networks to minimize the similarity of two augmented views of images (Wu et al., 2018; Chen et al., 2020a; He et al., 2020; Grill et al., 2020; Chen & He, 2021). All these methods heavily rely on the assumption that images are centrally available in cloud servers, such as public data on the Internet. + +However, the rapidly growing amount of decentralized images may not be centralized due to increasingly stringent privacy protection regulations (Custers et al., 2019). The increasing number of edge devices, such as street cameras and phones, are generating a large number of unlabeled images, but these images may not be centralized as they could contain sensitive personal information like human faces. Besides, learning representations from these images could be more beneficial for downstream tasks deployed in the same scenarios (Yan et al., 2020). A straightforward method is to adopt SSL methods for each edge, but it results in poor performance (Zhuang et al., 2021a) as decentralized data are mostly non-independently and identically distributed (non-IID) (Li et al., 2020a). + +Federated learning (FL) has emerged as a popular privacy-preserving method to train models from decentralized data (McMahan et al., 2017), where clients send training updates to the server instead of raw data. The majority of FL methods, however, are not applicable for unsupervised representation learning because they require fully labeled data (Caldas et al., 2018), or partially labeled data in either the server or clients (Jin et al., 2020a; Jeong et al., 2021). Recent studies implement FL with SSL methods that are based on Siamese networks, but they only focus on a single SSL method. For example, FedCA (Zhang et al., 2020a) is based on SimCLR (Chen et al., 2020a) and FedU (Zhuang et al., 2021a) is based on BYOL (Grill et al., 2020). These efforts have not yet revealed deep insights into the fundamental building blocks of Siamese networks for federated self-supervised learning. + +In this paper, we investigate the effects of fundamental components of federated self-supervised learning (FedSSL) via in-depth empirical study. To facilitate fair comparison, we first introduce a generalized FedSSL framework to embrace existing SSL methods that differ in building blocks of Siamese networks. The framework comprises of a server and multiple clients: clients conduct SSL training using Siamese networks — an online network and a target network; the server aggregates the trained online networks to obtain a new global network and uses this global network to update the online networks of clients in the next round of training. FedSSL primarily focuses on the cross-silo FL where clients are stateful with high availability (Kairouz et al., 2019). + +We conduct empirical studies based on the FedSSL framework and discover important insights of FedSSL. Among four popular SSL methods (SimCLR (Chen et al., 2020a), MoCo (He et al., 2020), BYOL (Grill et al., 2020), and SimSiam (Chen & He, 2021), FedBYOL achieves the best performance, whereas FedSimSiam yields the worst performance. More detailed analysis uncover the following unique insights: 1) Stop-gradient operation, essential for SimSiam and BYOL, is not always essential in FedSSL; 2) Target networks of clients are essential to gain knowledge from online networks; 3) Keeping local knowledge of clients is beneficial for performance on non-IID data. + +Inspired by the insights, we propose a new approach, Federated Divergence-aware Exponential Moving Average update (FedEMA) 1 , to address the non-IID data problem. Specifically, instead of updating online networks of clients simply by the global network, FedEMA updates them via exponential moving average (EMA) of the global network, where the decay rate of EMA is measured by the divergence of global and online networks dynamically. Extensive experiments demonstrate that FedEMA outperforms existing methods in a wide range of settings. We believe that important insights from this study will shed light on future research. Our main contributions are threefold: + +• We introduce a new generalized FedSSL framework that embraces existing SSL methods based on Siamese networks and presents flexibility catering to future methods. • We conduct in-depth empirical studies of FedSSL based on the framework and discover deep insights of the fundamental building blocks of Siamese networks for FedSSL. • Inspired by the insights, we further propose a new model update approach, FedEMA, that adaptively updates online networks of clients with EMA of the global network. Extensive experiments show that FedEMA outperforms existing methods in a wide range of settings. + +# 2 RELATED WORK + +Self-supervised Learning In computer vision, self-supervised learning (SSL) aims to learn visual representations without any labels. Discriminative SSL methods facilitate learning with proxy tasks (Pathak et al., 2016; Noroozi & Favaro, 2016; Zhang et al., 2016; Gidaris et al., 2018). Among them, contrastive learning (Oord et al., 2018; Bachman et al., 2019) has become a promising principle. It uses Siamese networks to minimize the similarity of two augmented views (positive pairs) and maximize the similarity of two different images (negative pairs). These methods are either contrastive or non-contrastive ones: contrastive SSL methods require negative pairs (Chen et al., 2020a; He et al., 2020) to prevent training collapse; non-contrastive SSL methods (Grill et al., 2020; Chen & He, 2021) are generally more efficient as they maintain remarkable performances using only positive pairs. However, these methods do not perform well on decentralized non-IID data (Zhuang et al., 2021a). We analyze their similarities and variances and propose a generalized FedSSL framework. + +Federated Learning Federated learning (FL) is a distributed training technique for learning from decentralized parties without transmitting raw data to a central server (McMahan et al., 2017). + +![](images/874bfc7e1da77464d2e893530ba49b4554a8d18c90fc251081926b00b0e245de.jpg) +Figure 1: Overview of federated self-supervised learning (FedSSL) framework. It comprises an endto-end training pipeline with four steps: 1) Each client $k$ conducts local training on unlabeled data $\mathcal { D } _ { k }$ with Siamese networks — an online network $W _ { k } ^ { o }$ and a target network $\it { W _ { k } ^ { t } }$ ; 2) After training, client $k$ uploads $W _ { k } ^ { o }$ to the server; 3) The server aggregates them to obtain a new global network $W _ { g } ^ { o }$ ; 4) The server updates $W _ { k } ^ { o }$ of client $k$ with $W _ { g } ^ { o }$ . + +Among many studies that address the non-IID data challenge (Zhao et al., 2018; Li et al., 2020b; Wang et al., 2020; Zhuang et al., 2021c), Personalized FL (PFL) aims to learn personalized models for clients (Tan et al., 2021). Although some PFL methods interpolate global and local models (Hanzely et al., 2020; Mansour et al., 2020; yuyang deng et al., 2021), our proposed FedEMA differ in the motivation, application scenario, and measurement of the decay rate. Besides, the majority of existing works only consider supervised learning where clients have fully labeled data. Although recent works propose federated semi-supervised learning (Jin et al., 2020b; Zhang et al., 2020b; Jeong et al., 2021) or federated domain adaptation (Peng et al., 2020; Zhuang et al., 2021b), they still need labels in either the server or clients. This paper focuses on purely unlabeled decentralized data. + +Federated Unsupervised Learning Learning representations from unlabeled decentralized data while preserving data privacy is still a nascent field. Federated unsupervised representation learning is first proposed by van Berlo et al. (2020) based on autoencoder, but it neglects the non-IID data challenge. Zhang et al. (2020a) address the non-IID issue with potential privacy risk for sharing features. Although Zhuang et al. (2020) address the issue based on BYOL as our FedEMA, they do not shed light on why BYOL works best. Since SSL methods are evolving rapidly and new methods are emerging, we introduce a generalized FedSSL framework and deeply investigate the fundamental components to build up practical guidelines for the generic FedSSL framework. + +# 3 AN EMPIRICAL STUDY OF FEDERATED SELF-SUPERVISED LEARNING + +This section first defines the problem and introduces the generalized FedSSL framework. Using the framework, we then conduct empirical studies to reveal deep insights of FedSSL. + +# 3.1 PROBLEM DEFINITION + +FedSSL aims to learn a generalized representation $W$ from multiple decentralized parties for downstream tasks in the same scenarios. Each party $k$ contains unlabeled data $\mathcal { D } _ { k } = \{ \mathcal { X } _ { k } \}$ that cannot be transferred to the server or other parties due to privacy constraints. Data is normally non-IID among decentralized parties (Li et al., 2020a); each party could contain only limited data categories (e.g., two out of ten CIFAR-10 classes) (Luo et al., 2019). As a result, each party alone is unable to obtain a good reparties is $\begin{array} { r } { \operatorname* { m i n } _ { w } f ( w ) : = \sum _ { k = 1 } ^ { \bar { K } } \frac { n _ { k } } { n } f _ { k } ( w ) } \end{array}$ 1a). The, where $K$ obal objective function to learis the number of clients, and $\begin{array} { r } { n = \sum _ { k = 1 } ^ { K } { n _ { k } } } \end{array}$ is the total data amount. For client $k$ , $f _ { k } ( w ) : = \mathbb { E } _ { x _ { k } \sim \mathcal { P } _ { k } } [ \tilde { f } _ { k } ( w ; x _ { k } ) ]$ is the expected loss over data distribution $\mathcal { P } _ { k }$ , where $x _ { k }$ is the unlabeled data and $\tilde { f } _ { k } ( w ; x _ { k } )$ is the loss function. + +# 3.2 GENERALIZED FRAMEWORK + +We introduce a generalized FedSSL framework that empowers existing SSL methods based on Siamese networks to learn from decentralized data under privacy constraints. Figure 1 depicts the end-to-end training pipeline of the framework. It comprises of three key operations: 1) Local Training in clients; 2) Model Aggregation in the server; 3) Model Communication (upload and update) between the server and clients. We implement and analyze four popular SSL methods — SimCLR (Chen et al., 2020a), MoCo (V1 (He et al., 2020) and V2 (Chen et al., 2020b)), SimSiam (Chen & He, 2021), and BYOL (Grill et al., 2020). Variances in Siamese networks of these methods lead to differences in executions in these three operations 2. + +Local Training Firstly, each client $k$ conducts self-supervised training on unlabeled data $\mathcal { D } _ { k }$ based on the same global model $W _ { g } ^ { o }$ downloaded from the server. Regardless of SSL methods, clients train with Siamese networks — an online network $W _ { k } ^ { o }$ and a target network $\it { W _ { k } ^ { t } }$ for $E$ local epochs using cooresponding loss functions $\mathcal { L }$ . We classify these SSL methods with two major differences (Figure 8 in Appendix A): 1) Only SimSiam and BYOL contain a predictor in the online network, so we denote their online network $W _ { k } ^ { o } = ( W _ { k } , W _ { k } ^ { p } )$ , where $W _ { k }$ is the online encoder and $\boldsymbol { W } _ { k } ^ { p }$ is the predictor; As for SimCLR and MoCo, $W _ { k } ^ { o } = W _ { k }$ . 2) SimCLR and SimSiam share identical weights between the online encoder and the target encoder, so $W _ { k } ^ { t } \ = \ W _ { k }$ . In contrast, MoCo and BYOL update the target encoder with EMA of the online encoder in every mini-batch: $W _ { k } ^ { t } =$ $m W _ { k } + ( 1 - m ) W _ { k } ^ { t }$ , where $m$ is the momentum value normally set to 0.99. + +Model Communication After local training, client $k$ uploads the trained online network $W _ { k } ^ { o }$ to the server and updates it with the global model $W _ { g } ^ { o }$ after aggregation. Considering the differences of SSL methods, we upload and update encoders and predictors separately: 1) we upload and update the predictor when it presents in local training; 2) we follow the communication protocol Zhuang et al. (2021a) to upload and update only the online encoder $W _ { k }$ when encoders are different. + +Model Aggregation When the server receives online networks from clients, it aggregates them to w glob, where odel is th PKk=0 nkn W ok W og = (Wg, W pg ) . n, if predictor presents, otherwiseto clients to update their online $W _ { g } ^ { o } = W _ { g }$ $W _ { g }$ $\tilde { W } _ { g } ^ { o }$ networks. The training iterates these three operations until it meets the stopping conditions. At the end of the training, we use the parameters of $W _ { g } ^ { o }$ as the generic representation $W$ for evaluation. + +# 3.3 EXPERIMENTAL SETUP + +We provide basic experimental setups in this section and describe more details in Appendix B. + +Datasets We conduct experiments using CIFAR-10 and CIFAR-100 datasets (Krizhevsky et al., 2009). To simulate federated settings, we equally split a dataset into $K$ clients. We simulate nonIID data with label heterogeneity, where each client contains limited classes — $l = \{ 2 , 4 , 6 , 8 , 1 0 \}$ number of classes for CIFAR-10 and $l = \{ 2 0 , 4 0 , 6 0 , 8 0 , 1 0 0 \}$ for CIFAR-100. The setting is IID when each client contains 10 (100) classes for CIFAR-10 (CIFAR-100). + +Implementation Details We implement FedSSL in Python using popular deep learning framework PyTorch (Paszke et al., 2017). To simulate federated learning, we train each client on one NVIDIA V100 GPU. These clients communicate with the server through NCCL backend. We use ResNet-18 (He et al., 2016) as default network for the encoders and present results of ResNet-50 in Appendix C. The predictor is a two-layer multi-layer perceptron (MLP). By default, we train for $R = 1 0 0$ rounds with $K = 5$ clients, $E = 5$ local epoches, batch size $B = 1 2 8$ , learning rate $\eta = 0 . 0 3 2$ with cosine decay, and non-IID data $l = 2$ $\mathit { l } = 2 0$ ) for CIFAR-10 (CIFAR-100). + +Linear Evaluation We evaluate the quality of representations following linear evaluation (Kolesnikov et al., 2019; Grill et al., 2020) protocol. We first learn representations from the FedSSL framework. Then, we train a new linear classifier on the frozen representations. + +# 3.4 ALGORITHM COMPARISONS + +We benchmark and compare the SSL methods using the FedSSL framework. To denote the implementation of an SSL method, We add a prefix Fed to the name of the SSL method. For example, FedBYOL denotes using BYOL in the FedSSL framework. + +Table 1: Top-1 accuracy comparison of SSL methods using the FedSSL framework on non-IID CIFAR datasets. FedBYOL performs the best, whereas FedSimSiam performs the worst. + +
TypeMethodCIFAR-10 (%)CIFAR-100 (%)
ContrastiveFedSimCLR78.09± 0.1455.58 ± 0.13
FedMoCoV178.21 ± 0.0456.98 ± 0.29
FedMoCoV279.14 ± 0.1357.47 ± 0.65
Non-contrastiveFedSimSiam76.27 ± 0.1848.94 ± 0.22
FedBYOL79.44 ± 0.9957.51 ± 0.09
+ +![](images/8ebaa67955f5ea651c1ae1d51ec90492eaa17cf5f887f3a4b25620f1c7a2c989.jpg) +Figure 2: Comparison of non-contrastive FedSSL methods with and without (w/o) predictor (pred) or stop-gradient (stop-grad) on non-IID CIFAR-10 dataset. Without predictor, both FedSimSiam and FedBYOL drops performance on kNN testing accuracy (left plot). Without stop-gradient, FedBYOL retains competitive results on kNN testing accuracy (middle plot) and linear evaluation (right table). + +Table 1 compares linear evaluation results of these methods under the non-IID setting of CIFAR datasets. On the one hand, contrastive FedSSL methods obtain similar performances. As SimCLR is previously reported to need a large batch size (e.g., $B = 4 0 9 6 ^ { \circ }$ ) (Chen et al., 2020a), it is surprising that FedSimCLR obtains competitive results using the same batch size $B = 1 2 8$ as the others. On the other hand, the results of non-contrastive FedSSL methods have large variances: FedBYOL achieves the best performance, whereas FedSimSiam yields the worst performance. Since SimSiam is capable to learn as powerful representations as BYOL (Chen & He, 2021), as well as considering that noncontrastive methods are conceptually simpler and more efficient (Tian et al., 2021), we focus on non-contrastive methods and further investigate the effects of their fundamental components. + +# 3.5 IMPACT OF FACTORS OF NON-CONTRASTIVE METHODS + +This section analyzes the impact of fundamental components of non-contrastive FedSSL methods. From empirical studies, we obtain the following insights: 1) predictor is essential; 2) EMA and stopgradient improves performances; 3) Local encoders should retain local knowledge of the non-IID data; 4) Target encoder should gain knowledge from the online encoder. Details are as followed. + +Predictor is essential. Figure 2 (left plot) presents the kNN testing accuracy as a monitoring process for FedBYOL and FedSimSiam with and without predictors. Without predictors, both methods can barely learn due to collapse in local training. It affirms the vital role of predictor (Chen & He, 2021; Tian et al., 2021) even when learning from decentralized data. + +Stop-gradient operation is previously indicated as an essential component for SimSiam and BYOL (Tian et al., 2021), but it is not essential for FedBYOL. Stop-gradient prevents stochastic gradient optimization on the target network. Figure 2 shows that FedSimSiam without stop-gradient collapses, whereas FedBYOL without stop-gradient still achieves competitive performance. It is because online and target encoders are significantly different in FedBYOL as the online encoder is updated by the global encoder every communication round. In contrast, SimSiam or FedSiamSiam share weights between online and target encoders, so removing stop-gradient leads to collapse. + +Exponential Moving Average (EMA) is not essential, but it helps improve performance. Table 2 (first and second rows) shows that FedBYOL outperforms FedSimSiam at different levels of nonIID data, which is represented by $\{ 2 , 4 , 6 , 8 , 1 0 \}$ classes per client of CIFAR-10. EMA is the main difference between SimSiam and BYOL, indicating that EMA is helpful to improve performance. Based on these results, we further analyze the underlying impact of EMA on the encoders below. + +Table 2: Top-1 accuracy comparison on various non-IID levels — the number of classes per client on the CIFAR-10 dataset. Update-both means updating both $W _ { k }$ and $\it { W _ { k } ^ { t } }$ with $W _ { g }$ . + +
Method# of classes per client (%)
246810 (iid)
FedBYOL79.4482.8283.0284.5784.20
FedSimSiam76.2779.3480.1780.9280.50
FedBYOL,update-both74.5078.7783.0284.5683.80
+ +
FedBYOLacc (%)
w/o EMA50.20
w/o EMA and stop-grad11.97
w/o EMA and stop-grad, update-both68.75
original79.44
+ +![](images/dd41fed0294801e8527cbe68f366bc34c945f15a2d293b2eed030d8f5ccad7c9.jpg) +Figure 3: Comparison of FedBYOL without exponential moving average (EMA) and stop-gradient (sg) on the non-IID CIFAR-10 dataset. FedBYOL w/o EMA and sg can hardly learn, but updating both $W _ { k }$ and $\it { W _ { k } ^ { t } }$ with $W _ { g }$ (update-both) enables it to achieve comparable results. + +Encoders that retain local knowledge of non-IID data helps improve performance. EMA in FedBYOL allows the parameters of the online encoder to be different from the target encoder. As a result, the global encoder only updates the online encoder, not the target encoder. We hypothesize that retaining such local knowledge of data in the target encoder is beneficial especially when the data distribution is highly skewed. For comparison, we remove such local knowledge by updating both online and target encoders with the global model. Table 2 shows that FedBYOL with both encoders updated leads to lower performance than FedBYOL; It achieves results close to FedSimSiam when the data distribution is more skewed (2 or 4 classes per client). These results demonstrate the importance of keeping local knowledge in the encoders. Besides, the results of $\{ 6 , 8 , 1 0 \}$ classes per client also indicate the benefit of EMA. + +Target encoder is essential to gain knowledge from the online encoder. Figure 3 shows that FedBYOL without EMA can merely learn, and FedBYOL without EMA and stop-gradient (sg) degrades in performance. In both cases, the target encoder is either never updated (w/o EMA) or is updated only through backpropagation (w/o EMA and sg) — not updated by the online encoder. On the other hand, we also identify that FedSSL methods in Table 1, which achieve competitive results, all update target encoders with knowledge of online encoders (the global encoder is the aggregation of the online encoder). We argue that target encoder is crucial to gain knowledge from the online encoder to provide contrastive targets. We further validate it by using the global encoder to update both online and target encoders when removing both EMA and stop-gradient. Figure 3 shows that such method improves performance and achieves comparable results. + +# 4 DIVERGENCE-AWARE DYNAMIC MOVING AVERAGE UPDATE + +Built on the FedSSL framework, we propose Federated Divergence-aware EMA update (FedEMA) to further mitigate non-IID data challenges. Since FedBYOL contains all components that help improve performance, we adopt it as the baseline and optimize the model update operation. + +Non-IID data causes the global model to diverge from centralized training (Zhuang et al., 2021a). Inspired by the insight that retaining local knowledge of non-IID data helps improve performance, we propose to update the online network via EMA of the global network. Compared with FedBYOL that replaces the online network with the global network, FedEMA fuses local and global knowledge effectively through EMA update, where the decay rate of EMA is dynamically measured by model divergences. Figure 4 depicts our proposed FedEMA method. The formulation is as followed: + +$$ +\begin{array} { r } { W _ { k } ^ { r } = \mu W _ { k } ^ { r - 1 } + ( 1 - \mu ) W _ { g } ^ { r } , } \end{array} +$$ + +$$ +\begin{array} { r } { W _ { k } ^ { p , r } = \mu W _ { k } ^ { p , r - 1 } + ( 1 - \mu ) W _ { g } ^ { p , r } , } \end{array} +$$ + +$$ +\mu = \operatorname* { m i n } ( \lambda \left\| W _ { g } ^ { r } - W _ { k } ^ { r - 1 } \right\| , 1 ) , +$$ + +where $W _ { k } ^ { r }$ and $W _ { k } ^ { p , r }$ are the online encoder and predictor of client $k$ at training round $r$ ; ${ \boldsymbol { W } _ { g } ^ { r } }$ and $W _ { g _ { . } } ^ { p , r }$ are the global encoder and predictor; $\mu$ is the decay rate, measured by the divergence between global and online encoders; $\lambda$ is a scaler to adjust the level of model divergence, which is measured by calculating the $l _ { 2 }$ -norm of the global and online encoders. We summarize FedEMA in Algorithm 1. FedEMA can be regarded as a generalization of FedBYOL — they are the same when $\lambda = 0$ . + +Scaler $\lambda$ plays a vital role to adapt FedEMA for different levels of divergence caused by the data. The divergence between global and online encoders varies when the settings of federated learning change. For example, different degrees of non-IID settings would result in different divergences. Since characteristics of data are unknown before training as they are unlabeled, we propose a practical autoscaler to calculate a personalized $\lambda _ { k }$ for each client $k$ automatically. The formula is $\begin{array} { r } { \lambda _ { k } = \frac { \tau } { | | W _ { g } ^ { r + 1 } - W _ { k } ^ { r } | | } } \end{array}$ where $\tau \in [ 0 , \bar { 1 } ]$ is the expected value of $\mu$ at round $r$ . We calculate $\lambda _ { k }$ only once at the earliest round $r$ that client $k$ is sampled for training. When the same set of clients are sampled for training, λk = τ||W 1−W 0|| is calculated at round $r = 1$ . + +The intuition of FedEMA is to retain more local knowledge when divergence is large and incorporate more global knowledge when divergence is small. When model divergence is large, keeping more local knowledge is more beneficial for the non-IID data. Since the global network is the aggregation of online networks, representing global knowledge from clients. When divergence is small, adapting more global knowledge help improve model generalization. Since model divergence is larger at the start of training (Figure 6), it is practical to choose larger $\tau \in [ 0 . 5 , 1 )$ ; $\tau = 1$ is not considered because only local knowledge is used when $\tau = 1$ . We use $\tau = 0 . 7$ by default in experiments. + +# Algorithm 1 Our proposed FedEMA + +1: ServerExecution: 2: Init $\overline { { W _ { g } ^ { 0 } } }$ and $\overline { { W _ { g } ^ { p , 0 } } }$ , init $\lambda _ { k }$ to be null 3: for each round ${ \bf \bar { \it { r } } } = 0 , 1 , . . . , R$ do 4: $S _ { t } \gets$ (Selection of K clients) 5: for client $k \in S _ { t }$ in parallel do 6: $W _ { k } ^ { r } , W _ { k } ^ { p , r } \gets \mathrm { { C l i e n t } } ( W _ { g } ^ { r } , W _ { g } ^ { p , r } , r , \lambda _ { k } )$ 7: W r+1g ← Pk∈St 8: $\begin{array} { r } { W _ { g } ^ { p , r + 1 } \sum _ { k \in S _ { t } } \frac { n _ { k } } { n } W _ { k } ^ { p , r } } \end{array}$ 9: for client k ∈ St do 10: $\lambda _ { k } \frac { \tau } { | | W _ { g } ^ { r + 1 } - W _ { k } ^ { r } | | }$ if $\lambda _ { k }$ is null 11: Return W R 12: 13: if Client $\lambda _ { k }$ $( W _ { g } ^ { \overline { { { r } } } } , W _ { g } ^ { p , r } , r , \lambda _ { k } ) { : }$ d in $r - 1$ then 14: $W _ { k } , W _ { k } ^ { t } , W _ { k } ^ { p } W _ { g } ^ { r } , W _ { g } ^ { r } , W _ { g } ^ { p , r }$ 15: else 16: $\begin{array} { r l } & { \lceil \mu \operatorname* { m i n } ( \lambda _ { k } W _ { g } ^ { r } - W _ { k } ^ { r - 1 } , 1 ) } \\ & { W _ { k } \mu W _ { k } ^ { r - 1 } + ( 1 - \mu ) W _ { g } ^ { r } } \\ & { W _ { k } ^ { p } \mu W _ { k } ^ { p , r - 1 } + ( 1 - \mu ) W _ { q } ^ { p , r } } \end{array}$ 17: 18: 19: for local epoch $e = 0 , 1 , . . . , E - 1$ do 20: for $b \in B$ data batches with size $B$ do 21: $\begin{array} { r l } & { W _ { k } ^ { o } W _ { k } ^ { o } - \eta \nabla \mathcal { L } _ { W _ { k } ^ { o } , W _ { k } ^ { t } } ( W _ { k } ^ { o } ; b ) } \\ & { W _ { k } ^ { t } m W _ { k } ^ { t } + ( 1 - m ) W _ { k } } \end{array}$ 22: 23: Return $W _ { k } ^ { r }$ , $W _ { k } ^ { p , r }$ + +![](images/277e2949ea9c2835cd91c7d5575e1baeee23420a28ec2b1bfad5918e9a07ca13.jpg) +Figure 4: Illustration of our proposed Federated Divergence-aware Exponential Moving Average update (FedEMA). Compared with FedBYOL thof client simply updates the onlinwith the global network work , we $W _ { k } ^ { o }$ $k$ $W _ { g } ^ { o }$ pose to update them via EMA of the global network following Eqn 1 and 2, where the decay rate $\mu$ is dynamically measured the divergences between the online encoder $W _ { k }$ and the global encoder $W _ { g }$ (Eqn 3). The online network, $W _ { k } ^ { o } \ =$ $( W _ { k } , W _ { k } ^ { \tilde { p } } )$ , is the concatenation of the online encoder $W _ { k }$ and the predictor $\boldsymbol { W } _ { k } ^ { p }$ . + +Table 3: Top-1 accuracy comparison under linear probing on CIFAR datasets. Our proposed FedEMA outperforms all other methods. Full results are in Table 5. + +
MethodCIFAR-10 (%)CIFAR-100 (%)
IIDNon-IIDIDNon-IID
Standalone training82.42 ± 0.3274.95 ± 0.6653.88 ± 2.2452.37 ± 0.93
FedBYOL84.29 ± 0.1879.44 ± 0.9954.24 ± 0.2457.51 ± 0.09
FedU (Zhuang et al., 2021a)83.96 ± 0.1880.52 ± 0.2154.82 ± 0.6757.21 ±0.31
FedEMA (入= 0.8)85.59 ±0.2582.77 士 0.0857.86 ± 0.1561.21 ± 0.54
FedEMA (autoscaler, T = 0.7)86.26 ± 0.2683.34 士 0.3958.55 ±0.3461.78 ± 0.14
BYOL (Centralized)90.46 ± 0.34-65.54 ± 0.471
+ +Table 4: Top-1 accuracy comparison on $1 \%$ and $10 \%$ of labeled data for semi-supervised learning on non-IID CIFAR datasets. FedEMA outperforms other methods. Full results are in Table 7. + +
MethodCIFAR-10 (%)CIFAR-100 (%)
1%10%1%10%
Standalone training61.37 ± 0.1369.06± 0.2421.37± 0.7339.99 ± 0.87
FedBYOL70.48 ± 0.3076.95 ± 0.4630.21 ± 0.4047.07 ± 0.14
FedU (Zhuang et al., 2021a)69.52 ± 0.7377.06 ± 0.5529.00 ± 0.2746.67 ± 0.06
FedEMA (λ= 1)72.78 ± 0.6679.01 士 0.3032.49 士 0.2249.82 士 0.36
FedEMA (autoscaler, T = 0.7)73.44 ± 0.2279.49 士 0.3433.04 士 0.2350.48 ± 0.11
BYOL (Centralized)87.67 ± 0.1587.89 ±0.0540.96 ± 0.5856.60 ± 0.33
+ +# 5 EVALUATION + +This section follows the experimental setup in Section 3.3 to evaluate FedEMA in the linear evaluation and semi-supervised learning. We also provide ablation studies of important hyperparameters. + +# 5.1 ALGORITHM COMPARISONS + +To demonstrate the effectiveness of FedEMA, we compare it with the following methods: 1) standalone training, where a client learns independently using BYOL; 2) FedCA, which is proposed in Zhang et al. (2020a); 3) FedBYOL as the baseline; 4) FedU, which is proposed in (Zhuang et al., 2021a). Besides, we also present results of possible upper bounds that learn representations with centralized data using BYOL. + +Linear Evaluation Table 3 shows that FedEMA outperforms other methods on different settings of CIFAR datasets. Specifically, the performance is more $3 \%$ higher than existing methods in most settings. Besides, our proposed autoscaler achieves similar results as $\lambda = 0 . 8$ . More experiments on larger number of clients $K$ and random selection of clients are provided in Table 6 in Appendix C. + +Semi-supervised Learning We also assess the quality of representations following the semisupervised learning protocol (Zhai et al., 2019; Chen et al., 2020a) — we add a new two-layer MLP on top of the encoder and fine-tune the whole model with limited ( $1 \%$ and $10 \%$ ) labeled data for 100 epochs. Table 4 indicates that FedEMA consistently outperforms other methods on non-IID settings of CIFAR datasets and our autoscaler outperforms manual-selected $\lambda = 1$ . + +# 5.2 ABLATION STUDIES + +Ablation on FedEMA We analyze whether we need to update both online encoder (Eqn 1) and predictor (Eqn 2) in FedEMA. Figure 5 shows that updating only the encoder or predictor leads to better performance; only updating predictor also leads to faster convergence. Their combination results in the best performance. These results demonstrate the effectiveness of updating both predictor and encoder in FedEMA. More results on other settings are provided in Table 5 in Appendix C. + +![](images/e637cc2e85c15a7c7254ccc285e226d19b355c00bb0aa1bfd7f0b93c9bd6d5b4.jpg) +Figure 5: Ablation studies of FedEMA: applying EMA on either predictor or encoder leads to better performance on CIFAR-10. +Figure 6: Changes of divergence throughout training. + +![](images/986eceee3580d893bd5a06f30d41656d4d300d99cf988aa8fca770295b2bcd17.jpg) +Figure 7: Ablation study on scaler $\lambda$ , decay rate $\mu$ , and non-IID levels of the CIFAR-10 dataset: (a) analyzes the impact of scaler $\lambda$ on performance; (b) compares using constant $\mu$ on encoder, predictor, or both; (c) studies the impact of different non-IID levels. + +Changes of Divergence Figure 6 illustrates that the divergence between global encoder and online encoder (Eqn 3) decreases gradually as training proceeds. It validates our intuition that more local knowledge is used at the start of training when divergence is larger. Besides, clients can update at their own pace depending on the divergence caused by their local dataset. + +Scaler $\lambda$ We study the impact of $\lambda$ with values in [0, 2] with interval of 0.2 in Figure 7a. $\lambda > 1$ leads to a significant performance drop because it results in $\mu = 1$ at the start of training on CIFAR datasets, implying that no aggregated global network is used. When $\lambda \in ( 0 , 1 )$ , the performances are consistently better than FedBYOL $\lambda = 0$ ) as both local and global knowledge are effectively aggregated. These analyses are mainly suitable for our experiment setting. The range values of $\lambda$ depend on the characteristics of data and the hyper-parameters (e.g., local epoch) of FL settings. A practical way to tune $\lambda$ manually is to understand the divergence by running the algorithm for several rounds and choose the $\lambda$ that scales $\mu$ to (0.5, 1). Nevertheless, we recommend using autoscaler and provide ablation study of $\tau$ of autoscaler in Figure 10a in Appendix C. + +Constant Values of $\mu$ We further demonstrate the necessity of dynamic EMA by comparing with using constant values of $\mu$ in Eqn 1 and 2. Figure 7b shows that a good choice of constant $\mu$ can outperform FedBYOL, but FedEMA outperforms using constant $\mu$ for the online encoder, predictor, or applying both. We also provide results that encoder and predictor use different $\mu$ in Appendix C. + +Non-IID Level Figure $\mathrm { 7 c }$ compares the performance of different non-IID levels, ranging from 2 to 10 classes per client on the CIFAR-10 dataset. We use autoscaler for these experiments. FedEMA consistently outperforms FedBYOL in these settings. + +# 6 CONCLUSION + +We uncover important insights of federated self-supervised learning (FedSSL) from in-depth empirical studies, using a newly introduced generalized FedSSL framework. Inspired by the insights, we propose a new method, Federated Divergence-aware Exponential Moving Average update (FedEMA), to further address the non-IID data challenge. Our experiments and ablations demonstrate that FedEMA outperforms existing methods in a wide range of settings. In the future, we plan to implement FedSSL and FedEMA on larger-scale datasets. We hope that this study will provide useful insights for future research. + +# 7 REPRODUCIBILITY STATEMENT + +To facilitate reproducibility of experiment results, we first provide basic experimental setups in Section 3.3, including datasets, implementation details, and evaluation protocols. Then, we describe more experimental details in Appendix B, including datasets, data transformation, network architecture, training details, and default settings. Also, we indicate the settings and hyper-parameters of experiments when their settings are different from the default. Moreover, we plan to open-source the codes in the future. + +# ACKNOWLEDGMENTS + +We would like to thank reviewers of ICLR 2022 for their constructive and helpful feedback. This study is in part supported by the RIE2020 Industry Alignment Fund – Industry Collaboration Projects (IAF-ICP) Funding Initiative, as well as cash and in-kind contribution from the industry partner(s); the National Research Foundation, Singapore under its Energy Programme (EP Award NRF2017EWT-EP003-023) administrated by the Energy Market Authority of Singapore, and its Energy Research Test-Bed and Industry Partnership Funding Initiative, part of the Energy Grid (EG) 2.0 programme, and its Central Gap Fund (“Central Gap” Award No. NRF2020NRF-CG001-027); Singapore MOE under its Tier 1 grant call, Reference number RG96/20. + +# REFERENCES + +Philip Bachman, R Devon Hjelm, and William Buchwalter. Learning representations by maximizing mutual information across views. 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/ddf354219aac374f1d40b7e760ee5bb7-Paper.pdf. + +Sebastian Caldas, Sai Meher Karthik Duddu, Peter Wu, Tian Li, Jakub Konecnˇ y, H Brendan McMa- \` han, Virginia Smith, and Ameet Talwalkar. Leaf: A benchmark for federated settings. arXiv preprint arXiv:1812.01097, 2018. + +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. + +Xinlei Chen and Kaiming He. Exploring simple siamese representation learning. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), pp. 15750– 15758, June 2021. + +Xinlei Chen, Haoqi Fan, Ross Girshick, and Kaiming He. Improved baselines with momentum contrastive learning. arXiv preprint arXiv:2003.04297, 2020b. + +Bart Custers, Alan M. Sears, Francien Dechesne, Ilina Georgieva, Tommaso Tani, and Simone van der Hof. EU Personal Data Protection in Policy and Practice. Springer, 2019. + +Carl Doersch, Abhinav Gupta, and Alexei A Efros. Unsupervised visual representation learning by context prediction. In Proceedings of the IEEE international conference on computer vision, pp. 1422–1430, 2015. + +Spyros Gidaris, Praveer Singh, and Nikos Komodakis. Unsupervised representation learning by predicting image rotations. arXiv preprint arXiv:1803.07728, 2018. + +Jean-Bastien Grill, Florian Strub, Florent Altche, Corentin Tallec, Pierre Richemond, Elena ´ Buchatskaya, Carl Doersch, Bernardo Avila Pires, Zhaohan Guo, Mohammad Gheshlaghi Azar, Bilal Piot, koray kavukcuoglu, Remi Munos, and Michal Valko. Bootstrap your own latent - a new approach to self-supervised learning. In H. Larochelle, M. Ranzato, R. Hadsell, M. F. Balcan, and H. Lin (eds.), Advances in Neural Information Processing Systems, volume 33, pp. 21271–21284. Curran Associates, Inc., 2020. URL https://proceedings.neurips. cc/paper/2020/file/f3ada80d5c4ee70142b17b8192b2958e-Paper.pdf. + +Filip Hanzely, Slavom´ır Hanzely, Samuel Horvath, and Peter Richt ´ arik. Lower bounds and optimal ´ algorithms for personalized federated learning. In Advances in Neural Information Processing Systems. Curran Associates, Inc., 2020. + +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. + +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. + +Wonyong Jeong, Jaehong Yoon, Eunho Yang, and Sung Ju Hwang. Federated semi-supervised learning with inter-client consistency & disjoint learning. In International Conference on Learning Representations, 2021. URL https://openreview.net/forum?id $\underline { { \underline { { \mathbf { \Pi } } } } } =$ ce6CFXBh30h. + +Yilun Jin, Xiguang Wei, Yang Liu, and Qiang Yang. Towards utilizing unlabeled data in federated learning: A survey and prospective. arXiv e-prints, pp. arXiv–2002, 2020a. + +Yilun Jin, Xiguang Wei, Yang Liu, and Qiang Yang. A survey towards federated semi-supervised learning. arXiv preprint arXiv:2002.11545, 2020b. + +Peter Kairouz, H Brendan McMahan, Brendan Avent, Aurelien Bellet, Mehdi Bennis, Arjun Nitin ´ Bhagoji, Kallista Bonawitz, Zachary Charles, Graham Cormode, Rachel Cummings, et al. Advances and open problems in federated learning. arXiv preprint arXiv:1912.04977, 2019. + +Alexander Kolesnikov, Xiaohua Zhai, and Lucas Beyer. Revisiting self-supervised visual representation learning. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 1920–1929, 2019. + +Alex Krizhevsky, Geoffrey Hinton, et al. Learning multiple layers of features from tiny images. 2009. + +Tian Li, Anit Kumar Sahu, Ameet Talwalkar, and Virginia Smith. Federated learning: Challenges, methods, and future directions. IEEE Signal Processing Magazine, 37:50–60, 2020a. + +Tian Li, Anit Kumar Sahu, Manzil Zaheer, Maziar Sanjabi, Ameet Talwalkar, and Virginia Smith. Federated optimization in heterogeneous networks. Proceedings of Machine Learning and Systems, 2:429–450, 2020b. + +Ilya Loshchilov and Frank Hutter. SGDR: stochastic gradient descent with warm restarts. In 5th International Conference on Learning Representations, ICLR 2017, Toulon, France, April 24-26, 2017, Conference Track Proceedings, 2017. URL https://openreview.net/forum? id $=$ Skq89Scxx. + +Jiahuan Luo, Xueyang Wu, Yun Luo, Anbu Huang, Yunfeng Huang, Yang Liu, and Qiang Yang. Real-world image datasets for federated learning. arXiv preprint arXiv:1910.11089, 2019. + +Yishay Mansour, Mehryar Mohri, Jae Ro, and Ananda Theertha Suresh. Three approaches for personalization with applications to federated learning. arXiv preprint arXiv:2002.10619, 2020. + +Brendan McMahan, Eider Moore, Daniel Ramage, Seth Hampson, and Blaise Aguera y Arcas. ¨ Communication-efficient learning of deep networks from decentralized data. In Aarti Singh and Xiaojin (Jerry) Zhu (eds.), Proceedings of the 20th International Conference on Artificial Intelligence and Statistics, AISTATS 2017, 20-22 April 2017, Fort Lauderdale, FL, USA, volume 54 of Proceedings of Machine Learning Research, pp. 1273–1282. PMLR, 2017. URL http://proceedings.mlr.press/v54/mcmahan17a.html. + +Mehdi Noroozi and Paolo Favaro. Unsupervised learning of visual representations by solving jigsaw puzzles. In European conference on computer vision, pp. 69–84. Springer, 2016. + +Aaron van den Oord, Yazhe Li, and Oriol Vinyals. Representation learning with contrastive predictive coding. arXiv preprint arXiv:1807.03748, 2018. + +Adam Paszke, Sam Gross, Soumith Chintala, Gregory Chanan, Edward Yang, Zachary DeVito, Zeming Lin, Alban Desmaison, Luca Antiga, and Adam Lerer. Automatic differentiation in pytorch. 2017. + +Deepak Pathak, Philipp Krahenbuhl, Jeff Donahue, Trevor Darrell, and Alexei A Efros. Context encoders: Feature learning by inpainting. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 2536–2544, 2016. + +Xingchao Peng, Zijun Huang, Yizhe Zhu, and Kate Saenko. Federated adversarial domain adaptation. In International Conference on Learning Representations, 2020. URL https:// openreview.net/forum?id $\underline { { \underline { { \mathbf { \Pi } } } } } =$ HJezF3VYPB. + +Alysa Ziying Tan, Han Yu, Lizhen Cui, and Qiang Yang. Towards personalized federated learning. arXiv preprint arXiv:2103.00710, 2021. + +Yuandong Tian, Xinlei Chen, and Surya Ganguli. Understanding self-supervised learning dynamics without contrastive pairs. 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. 10268–10278. PMLR, 18–24 Jul 2021. URL https://proceedings.mlr. press/v139/tian21a.html. + +Bram van Berlo, Aaqib Saeed, and Tanir Ozcelebi. Towards federated unsupervised representation learning. In Proceedings of the Third ACM International Workshop on Edge Systems, Analytics and Networking, pp. 31–36, 2020. + +Hongyi Wang, Mikhail Yurochkin, Yuekai Sun, Dimitris Papailiopoulos, and Yasaman Khazaeni. Federated learning with matched averaging. In International Conference on Learning Representations, 2020. URL https://openreview.net/forum?id $\underline { { \underline { { \mathbf { \Pi } } } } } =$ BkluqlSFDS. + +Zhirong Wu, Yuanjun Xiong, Stella X Yu, and Dahua Lin. Unsupervised feature learning via nonparametric instance discrimination. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 3733–3742, 2018. + +Xi Yan, David Acuna, and Sanja Fidler. Neural data server: A large-scale search engine for transfer learning data. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 3893–3902, 2020. + +yuyang deng, Mohammad Mahdi Kamani, and Mehrdad Mahdavi. Adaptive personalized federated learning, 2021. URL https://openreview.net/forum?id $=$ g0a-XYjpQ7r. + +Xiaohua Zhai, Avital Oliver, Alexander Kolesnikov, and Lucas Beyer. S4l: Self-supervised semisupervised learning. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pp. 1476–1485, 2019. + +Fengda Zhang, Kun Kuang, Zhaoyang You, Tao Shen, Jun Xiao, Yin Zhang, Chao Wu, Yueting Zhuang, and Xiaolin Li. Federated unsupervised representation learning. arXiv preprint arXiv:2010.08982, 2020a. + +Richard Zhang, Phillip Isola, and Alexei A Efros. Colorful image colorization. In European conference on computer vision, pp. 649–666. Springer, 2016. + +Zhengming Zhang, Zhewei Yao, Yaoqing Yang, Yujun Yan, Joseph E Gonzalez, and Michael W Mahoney. Benchmarking semi-supervised federated learning. arXiv preprint arXiv:2008.11364, 17, 2020b. + +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. + +Weiming Zhuang, Yonggang Wen, Xuesen Zhang, Xin Gan, Daiying Yin, Dongzhan Zhou, Shuai Zhang, and Shuai Yi. Performance optimization of federated person re-identification via benchmark analysis. In Proceedings of the 28th ACM International Conference on Multimedia, pp. 955–963, 2020. + +Weiming Zhuang, Xin Gan, Yonggang Wen, Shuai Zhang, and Shuai Yi. Collaborative unsupervised visual representation learning from decentralized data. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pp. 4912–4921, 2021a. + +Weiming Zhuang, Xin Gan, Yonggang Wen, Xuesen Zhang, Shuai Zhang, and Shuai Yi. Towards unsupervised domain adaptation for deep face recognition under privacy constraints via federated learning. arXiv preprint arXiv:2105.07606, 2021b. + +Weiming Zhuang, Yonggang Wen, and Shuai Zhang. Joint optimization in edge-cloud continuum for federated unsupervised person re-identification. In Proceedings of the 29th ACM International Conference on Multimedia, pp. 433–441, 2021c. + +Weiming Zhuang, Xin Gan, Yonggang Wen, and Shuai Zhang. Easyfl: A low-code federated learning platform for dummies. IEEE Internet of Things Journal, 2022. + +# A DIFFERENCES OF SELF-SUPERVISED LEARNING METHODS + +We study four SSL methods using the FedSSL framework in Section 3. These four SSL methods have two major differences that impact the executions of local training, model communication, and model aggregation. Figure 8 depicts these differences: 1) BYOL and SimSiam have predictors, whereas MoCo and SimCLR do not have them; 2) SimSiam and SimCLR share weights between two encoders, whereas BYOL and MoCo have different parameters for the online and target encoders. + +![](images/3ba946997c7b80318927296d0f860084b7591d1d2472857ef99c7bc51adef84f.jpg) +Figure 8: Illustration of differences among four Self-supervised Learning (SSL) methods. + +# B EXPERIMENTAL DETAILS + +In this section, we provide more details about the dataset, network architecture, and training and evaluation setups. + +# B.1 DATA + +Datasets CIFAR-10 and CIFAR-100 are two popular image datasets (Krizhevsky et al., 2009). Both datasets consist of 50,000 training images and 10,000 testing images. CIFAR-10 contains 10 classes, where each class has 5,000 training images and 1,000 testing images. While CIFAR-100 contains 100 classes, where each class has 500 training images and 100 testing images. To simulate federated learning, we equally split the training set into $K$ clients. We simulate non-IID data using label heterogeneity — data among clients is more skewed when each client contains less number of classes. Hence, we simulate different levels of non-IID data with $l$ number of classes per client, where $l = \{ 2 , 4 , 6 , 8 , 1 0 \}$ for CIFAR-10 and $l = \{ 2 0 , 4 0 , 6 0 , 8 0 , 1 0 0 \}$ for CIFAR-100. For example, when simulating 5 clients with $l = 4$ classes per client in CIFAR-10, we need $5 \times 4 = 2 0$ total sets of data over 10 classes. Thus, we split the training images of each class equally into two sets (2,500 images in each set) and assign random four sets without overlapping classes to a client. The setting is IID when each client contains all classes of a dataset. By default, we run experiments with $K = 5$ clients with non-IID setting $l = 2$ classes per client for CIFAR-10 dataset and $l = 2 0$ classes per client for CIFAR-100 dataset. + +Transformation In local training of the FedSSL framework, we take two augmentations of each image as the inputs for online and target networks, respectively. We obtain the augmentations by transforming the images with a set of transformations: For SimCLR, BYOL, SimSiam, and MoCoV2, we adopt the transformations from Chen et al. (2020a); For MoCoV1, we use the transformation described in its paper (He et al., 2020). + +Table 5: Top-1 accuracy comparison under linear evaluation protocol on CIFAR datasets. Our proposed FedEMA outperforms all other methods on non-IID settings. + +
MethodArchitectureParam.CIFAR-10 (%)CIFAR-100 (%)
IDNon-IIDIIDNon-IID
Standalone trainingResNet-1811M82.4274.9553.8852.37
FedSimCLRResNet-1811M82.1578.0956.3955.58
FedMoCoV1ResNet-1811M83.6378.2159.5856.98
FedMoCoV2ResNet-1811M84.2579.1458.7157.47
FedSimSiamResNet-1811M81.4676.2749.9248.94
FedBYOLResNet-1811M84.2979.4454.2457.51
FedU (Zhuang et al., 2021a)ResNet-1811M83.9680.5254.8257.21
FedEMA predictor only (ours)ResNet-1811M84.9781.1355.5257.53
FedEMA encoder only (ours)ResNet-1811M82.8882.3956.0659.74
FedEMA (λ= 0.8)ResNet-1811M85.5982.7757.8661.21
FedEMA (autoscaler,T = 0.7)ResNet-1811M86.2683.3458.5561.78
Standalone trainingResNet-5023M83.1677.8457.2155.16
FedSimCLRResNet-5023M82.2480.3757.4656.88
FedMoCoV1ResNet-5023M87.1982.1864.7459.73
FedMoCoV2ResNet-5023M87.1979.6263.7559.52
FedSimSiamResNet-5023M79.6476.746.2848.8
FedBYOLResNet-5023M83.9081.3357.75 59.53
FedCA (Zhang et al., 2020a)ResNet-5023M71.2568.0143.3042.34
FedU (Zhuang et al., 2021a)ResNet-5023M86.4883.2559.5161.94
FedEMA predictor only (ours)ResNet-5023M83.6681.7857.7960.11
FedEMA encoder only (ours)ResNet-5023M84.6684.9158.5262.51
FedEMA (入= 0.8)ResNet-5023M86.1285.2960.96 62.53
FedEMA (autoscaler, T = 0.7)ResNet-5023M85.0884.3159.4862.77
BYOL (Centralized)ResNet-1811M90.46-65.54-
BYOL (Centralized)ResNet-5023M91.85166.51=
+ +Table 6: Top-1 accuracy comparison on larger numbers of clients with client subsampling: 1) randomly selecting 5 out of 20 clients per round (5/20); 2) randomly selecting 8 out of 80 clients per round (8/80). FedEMA, trained with autoscaler, consistently outperforms FedBYOL in both settings. + +
Method5/20 clients (%)8/80 clients (%)
CIFAR-10CIFAR-100CIFAR-10CIFAR-100
IIDNon-IIDIIDNon-IIDIDNon-IIDIIDNon-IID
FedBYOL83.2574.9249.4947.0973.5863.2841.1941.58
FedEMA (ours)84.9875.7755.4152.7873.9664.1941.9743.05
+ +# B.2 NETWORK ARCHITECTURE + +Predictor The network architecture of the predictor is a two-layer multilayer perceptron (MLP). The two-layer MLP starts from a fully connected layer with 4096 neurons. Followed by onedimension batch normalization and a ReLU activation function, it ends with another fully connected layer with 2048 neurons. + +Encoder We use ResNet-18 He et al. (2016) as the default network architecture of the encoder in the majority of experiments. Besides, we also provide results of ResNet-50 in Table 5 and 7. + +Table 7: Top-1 accuracy comparison on using $1 \%$ and $10 \%$ of labeled data for semi-supervised learning on the non-IID settings of CIFAR datasets. FedEMA outperforms all other methods. + +
MethodArchitectureParam.CIFAR-10 (%)CIFAR-100 (%)
1%10%1%10%
Standalone trainingResNet-1811M61.3769.0621.3739.99
FedSimCLRResNet-1811M63.7973.4921.5541.90
FedMoCoV1ResNet-1811M60.5773.9521.8343.49
FedMoCoV2ResNet-1811M62.8973.6526.9345.27
FedSimSiamResNet-1811M67.5774.9625.1341.96
FedBYOLResNet-1811M70.4876.9530.2147.07
FedU (Zhuang et al., 2021a)ResNet-1811M69.5277.0629.0046.67
FedEMA (λ= 1)ResNet-1811M72.7879.0132.4949.82
FedEMA (autoscaler, T = 0.7)ResNet-1811M73.4479.4933.0450.48
Standalone trainingResNet-5023M63.6574.3023.1841.43
FedSimCLRResNet-5023M63.0073.5619.3041.13
FedMoCoV1ResNet-5023M61.8575.5322.1246.43
FedMoCoV2ResNet-5023M64.2573.9625.7942.52
FedSimSiamResNet-5023M61.4615.2516.0329.76
FedBYOLResNet-5023M69.9976.6926.5745.46
FedCA (Zhang et al., 2020a)ResNet-5023M28.5036.2816.4822.46
FedU (Zhuang et al., 2021a)ResNet-5023M69.7680.2528.4248.42
FedEMA(λ=1)ResNet-5023M74.6481.4831.4249.92
FedEMA (autoscaler,T = 0.7)ResNet-5023M72.5280.6829.6850.75
BYOL (Centralized)ResNet-1811M87.6787.8940.9656.60
BYOL (Centralized)ResNet-5023M89.0789.6641.4960.23
+ +Table 8: Top-1 accuracy comparison on various non-IID levels — the number of classes per client on the CIFAR-100 dataset. Update-both means updating both $W _ { k }$ and $\it { W _ { k } ^ { t } }$ with $W _ { g }$ . + +
Method# of classes per client (%)
246810 (iid)
FedBYOL57.5156.9655.1454.9654.24
FedSimSiam48.9451.0849.0548.0949.92
FedBYOL,update-both49.5354.1751.5052.7053.41
+ +Our ResNet architecture differs from the implementation in PyTorch (Paszke et al., 2017) in three aspects: 1) We use kernel size $3 \times 3$ for the first convolution layer instead of $7 \times 7$ ; 2) We use an average pooling layer with kernel size $4 \times 4$ before the last linear layer instead of adaptive average pooling layer; 3) We replace the last linear layer with a two-layer MLP. The network architecture of the MLP is the same as the predictor. + +# B.3 TRAINING AND EVALUATION DETAILS + +We implement FedSSL in Python using EasyFL (Zhuang et al., 2022), an easy-to-use federated learning platform based on PyTorch (Paszke et al., 2017). The following are the details of training and evaluation. + +Training We use Stochastic Gradient Descent (SGD) as the optimizer in training. We use $\eta =$ 0.032 as the initial learning rate and decay the learning with a cosine annealing (Loshchilov & Hutter, 2017), which is also used in SimSiam. By default, we train $R = 1 0 0$ rounds with local epochs $E = 5$ and batch size $B = 1 2 8$ using $K = 5$ clients. We simulate training of $K$ clients on $K$ NVIDIA V100 GPUs and employ the PyTorch Paszke et al. (2017) communication backend (NCCL) for communications between clients and the server. If not specified, we use $\lambda = 1$ by default or autoscaler with $\tau = 0 . 7$ for FedEMA. As for experiments of FedU, we follow the hyperparameters described in paper (Zhuang et al., 2021a). + +Table 9: Comparison of FedBYOL without exponential moving average (EMA) and stop-gradient (sg) on the CIFAR datasets. FedBYOL w/o EMA and sg can hardly learn, but updating both $W _ { k }$ and $\it { W } _ { k } ^ { t }$ with $W _ { g }$ (update-both) enables it to achieve comparable results. + +
MethodCIFAR-10 (%)CIFAR-100 (%)
IIDNon-IIDIDNon-IID
FedBYOL w/o EMA54.1150.2023.8225.83
FedBYOL w/o EMA and stop-grad21.2111.973.742.79
FedBYOL w/o EMA and stop-grad, update-both82.2968.7548.7441.91
FedBYOL84.2979.4454.2457.51
+ +![](images/b13ea0defe96a9bb69e14ba92eee55471f6b9bb7c8b312ee491d045c98aa1cfe.jpg) + +Figure 9: Comparison of FedBYOL and FedEMA on various total training rounds $R$ on the non-IID setting of the CIFAR-10 dataset. FedEMA consistently outperforms FedBYOL. + +
MethodRounds R(%)
100200300400
FedBYOL79.0882.2383.7786.09
FedEMA (ours)80.7882.4184.0886.51
+ +Cross-silo FL vs Cross-device FL This paper primarily focuses on cross-silo FL where clients are stateful with high availability. Clients can cache local models and carry these local states from round to round. Extensive experiments demonstrate that FedEMA achieves the best performance under this setting. On the other hand, cross-device FL assumes there are millions of stateless clients that might participate in training just once. Due to the constraints of experimental settings, the majority of studies conduct experiments with at most hundreds of clients (Wang et al., 2020; Jeong et al., 2021). FedEMA can work under such experimental settings by caching the states of clients in the server. When the number of clients scales to millions, FedEMA degrades to FedBYOL that updates both encoders — without keeping any local states. + +Evalaution We assess the quality of learned representations using linear evaluation (Kolesnikov et al., 2019; Grill et al., 2020) and semi-supervised learning (Zhai et al., 2019; Chen et al., 2020a) protocols. We first obtain a trained encoder (or learned representations) using full training set for linear evaluation and $9 9 \%$ or $90 \%$ of the training set for semi-supervised learning (excluding the $1 \%$ or $10 \%$ for fine-tuning). Then, we conduct evaluations based on the trained encoder. For linear evaluation, we train a new fully connected layer on top of the frozen trained encoder (fixed parameters) for 200 epochs, using batch size 512 and Adam optimizer with learning rate 3e-3. For semi-supervised learning, we add a new two-layer MLP on top of the trained encoder and fine-tune the whole model using $1 \%$ or $10 \%$ of data for 100 epochs, using batch size 128 and Adam optimizer with learning rate 1e-3. In both evaluation protocols, we remove the two-layer MLP of the encoder by replacing it with an identity function. + +# C ADDITIONAL EXPERIMENTAL RESULTS AND ANALYSIS + +In this section, we provide more experimental results of algorithm comparisons and further analyze FedEMA in different data amounts, training rounds $R$ , and batch sizes $B$ . + +![](images/ec3b12032d19f8d255a149edbe78cc9e08ec8b88d341a75b7343d16b5f24e206.jpg) +Figure 10: Ablation study on $\tau$ for autoscaler and combinations of constant $\mu$ : (a) analyzes the impact of $\tau$ on performances; 2) presents top-1 accuracy of using different combinations of constant $\mu _ { o }$ on the online encoder and constant $\mu _ { p }$ on the predictor. + +Table 10: Top-1 accuracy comparison on various batch sizes $B$ on the non-IID setting of CIFAR-10 dataset. The batch size should not be either too small or too large. Besides, FedEMA outperforms FedBYOL. + +
MethodBatch Sizes B (%)
163264128256512
FedBYOL68.7472.9078.5879.4479.8077.74
FedEMA (ours)74.0379.0682.1883.3482.1980.51
+ +# C.1 MORE EXPERIMENTAL RESULTS + +Table 5 presents top-1 accuracy comparison under linear evaluation of a wide range of methods on CIFAR datasets using both ResNet-18 and ResNet-50. It supplements the algorithm comparisons in Section 3.4 and 5.1. Interestingly, FedMoCoV1 achieves good performances on IID settings of CIFAR-100 dataset. Since decentralized data are mostly non-IID, we focus more on the non-IID setting. FedEMA outperforms all the other methods in non-IID settings of CIFAR datasets. We use $\lambda = 0 . 8$ when using ResNet-18 and $\lambda = 1$ when using ResNet-50. + +Table 6 shows results of scaling to larger numbers of clients $K$ with subsampling clients in each training round. We run two sets of experiments: 1) randomly selecting 5 out of 20 clients in each round with local epoch $E = 5$ and total rounds $R = 4 0 0 ; 2 \AA$ ) randomly selecting 8 out of 80 clients in each round with local epoch $E = 2$ and total rounds $R = 8 0 0$ . We run FedEMA with autoscaler. FedEMA consistently outperforms FedBYOL with both encoders updated. We conduct these experiments using ResNet-18. + +Table 7 supplements the semi-supervised learning results on Table 4, providing additional results using ResNet-50 as the network architecture for the encoder. FedEMA consistently outperforms all the other methods. + +Besides, Table 8 and 9 compare FedSimSiam, FedBYOL, and variances of FedBYOL to further demonstrate the insights from empirical studies. They supplement results in Table 2 and Figure 3. + +# C.2 FURTHER ANALYSIS + +$\tau$ for Autoscaler We analyze the impact of $\tau$ on performances in Figure 10a. Generally, using autoscaler with $\tau \in ( 0 , 1 )$ is better than FedBYOL $\mathit { \Omega } ^ { ' } \tau = 0$ ). The performance of $\tau = 1$ yields worse results because only local knowledge are used in model update (the global knowledge is neglected) as discussed in Section 4. Besides, performances of $\tau \in [ 0 . 5 , 1 )$ are generally better other values, which verifies our intuition discussed in Section 4. These results also show that we can achieve even higher performance on the CIFAR-100 dataset on Table 3 by tunning $\tau$ . We run experiments on non-IID settings using ResNet-18. + +Table 11: Comparison of needed communication rounds to reach target accuracy using different local epochs $E$ on the non-IID setting of the CIFAR-10 dataset. $E = 1$ is unable to reach $80 \%$ in 100 rounds. A larger $E$ can reduce communication costs by increasing the computation cost. + +
Target accuracyCommuniation (rounds)Computation (epochs)
E=1E=5E=10E=20E=1E=5E=10E=20
70%904010890200100160
80%18050401400500800
+ +Table 12: Top-1 accuracy comparison of various data amounts in clients and different numbers of clients. Increasing the number of clients does not improve performance, whereas increasing the data amount of clients results in better performance. + +
# of clientsK=5K= 10K= 20
Data amount10%25%50%100%50%25%
FedBYOL43.2765.1476.1178.2575.1063.95
FedEMA (ours)44.3367.4679.4982.5479.2066.61
+ +Constant $\mu$ To further illustrate the effectiveness of our dynamic EMA, we provide results of using different combinations of constant $\mu _ { o }$ on the online encoder and constant $\mu _ { p }$ on the predictor in Figure 10b. The results of $\mu _ { o } = 0 . 9$ and $\mu _ { p } = 0 . 9$ is only $5 4 . 5 2 \%$ , which is far lower than the others. Among these combinations, $\mu _ { o } = 0 . 5$ and $\mu _ { p } = 0 . 3$ achieve the best performance. It suggests that better performances may be achieved if we can construct different dynamic $\mu$ for the encoder and the predictor, while we leave this interesting insight for future exploration. Although good choices of constant $\mu _ { o }$ and $\mu _ { p }$ achieve better performance than FedBYOL, FedEMA consistently outperforms all these methods. These results complement Figure 7b in the main manuscript. + +Impact of Training Rounds $R$ Figure 9 compares FedBYOL and FedEMA with increasing number of training (communication) rounds $R$ . Performances of both FedBYOL and FedEMA increases as training proceeds and FedEMA consistently outperforms FedBYOL. We run these experiments with $\lambda = 0 . 5$ for FedEMA on the non-IID setting of CIFAR-10 dataset. + +Impact of Batch Size $B$ We investigate the impact of batch size in Table 10. The performances of batch size $B = 1 2 8$ and $B = 2 5 6$ are similar, outperforming the other batch sizes. It indicates that the batch size should not be either too small or too large. Besides, FedEMA outperforms FedBYOL in all batch sizes. We run the experiments with autoscaler $\tau = 0 . 7$ ) on the non-IID setting of the CIFAR-10 dataset. + +Communication vs Computation Cost Table 11 shows the needed communication rounds and computation epochs to reach a target accuracy using different local epochs $E$ with FedEMA. Increasing $E$ reduces communication cost as the needed rounds decrease, but it generally requires a higher computation cost. For example, compared with $E = 5$ that needs 80 rounds to reach $80 \%$ with 400 epochs of computation, $E = 2 0$ only uses 40 rounds but needs 800 epochs computation cost. These results indicate the trade-off between communication cost and computation cost. + +Data Amount Table 12 shows that increasing the data amount improves the performance significantly. By default, we split the CIFAR-10 dataset into 5 clients, each client contains 10,000 training images, denoting as $100 \%$ data amount. As a result, $p \%$ data amount means that each client contains $1 0 , 0 0 0 * p \%$ images. For example, $2 5 \%$ data amount means that each client contains 2,500 images. With lesser data points in each client, we can construct more clients to conduct training as the total data amount is fixed. Table 12 shows that when the data amount is same in clients, increasing the number of clients in each training round do not improve performance. However, increasing the data amount in each client increases the performance significantly. These results indicate that it is important for clients to have sufficient data to participate in training in FedSSL. \ No newline at end of file diff --git a/md/dev/pCucay08Co/pCucay08Co.md b/md/dev/pCucay08Co/pCucay08Co.md new file mode 100644 index 0000000000000000000000000000000000000000..d4ee11377dcd0812f2a6dad955ecd7293cd0d344 --- /dev/null +++ b/md/dev/pCucay08Co/pCucay08Co.md @@ -0,0 +1,533 @@ +# Exponential Hardness of Optimization from the Locality in Quantum Neural Networks + +Anonymous Author(s) +Affiliation +Address +email + +# Abstract + +1 Quantum neural networks (QNNs) have become a leading paradigm for establish +2 ing near-term quantum applications in recent years. The trainability issue of QNNs +3 has garnered extensive attention, spurring demand for a comprehensive analysis of +4 QNNs in order to identify viable solutions. In this work, we propose a perspective +5 that characterizes the trainability of QNNs based on their locality. We prove that +6 the entire variation range of the loss function via adjusting any local quantum gate +7 vanishes exponentially in the number of qubits with a high probability for a broad +8 class of QNNs. This result reveals extra harsh constraints independent of gradi +9 ents and unifies the restrictions on gradient-based and gradient-free optimizations +10 naturally. We showcase the validity of our results with numerical simulations of +11 representative models and examples. Our findings, as a fundamental property of +12 random quantum circuits, deepen the understanding of the role of locality in QNNs +13 and serve as a guideline for assessing the effectiveness of diverse training strategies +14 for quantum neural networks. + +# 15 1 Introduction + +16 Quantum computing is a rapidly growing technology that exploits quantum mechanics to solve +17 intricate problems that classical computers cannot solve. With enormous efforts having been made +18 to develop noisy intermediate scale quantum (NISQ) devices [1], current quantum devices have +19 demonstrated the ability to achieve near-term quantum advantage for practical applications in key +20 areas including many-body physics [2–4], chemistry [5], finance [6–8], and machine learning [9]. +21 Specifically, quantum machine learning (QML) represents an exciting, emerging interdisciplinary +22 field that seeks to enhance machine learning algorithms by harnessing the inherent parallelism +23 of quantum systems [10–20]. Quantum neural networks (QNNs) stand at the forefront of QML, +24 capitalizing on the unprecedented potential of quantum computing to revolutionize data analysis and +25 pattern recognition. Inspired by classical neural networks, QNNs employ quantum gates and quantum +26 states as fundamental building blocks within their computational framework. These networks can be +27 trained using a diverse range of methods, including gradient-based optimization techniques akin to +28 classical neural network training [21–24]. +29 With the aim to show quantum advantage on certain tasks, a critical issue is whether QNNs can be +30 extended to solve large-scale systems, i.e., scalability. Unfortunately, many studies point out that +31 training of QNNs requires exponential resources with the system size under certain conditions [25– +32 36]. Besides the practical limitations such as noises [29], even ideal quantum devices will suffer +33 from the so-called barren plateau phenomenon [25], which is the quantum counterpart of vanishing +34 gradient problem in classical machine learning. It was shown that the gradient of the cost function +35 vanishes exponentially in the number of qubits with a high probability for a random initialized +36 QNN with sufficient depth, analogous to the vanishing gradient issue in classical neural networks. +37 Consequently, exponentially vanishing gradients demand exponential precision in the cost function +38 measurement on a quantum device [37] to make progress in the gradient-based optimization, and +39 hence an exponential complexity in the number of qubits. +40 Several attempts have been made to avoid barren plateaus, such as higher order derivatives [38], +41 gradient-free optimizers including gate-by-gate optimization [39, 40], proper initialization [41], +42 pre-training including adaptive methods [42–46], QNN architectures [47, 48] and cost function +43 choices [49, 50]. More efforts are needed to study the general effectiveness of these attempts [26, 27] +44 and develop new strategies to improve the trainability and scalability of QNNs. As a guide for +45 exploring effective training strategies, it is crucial to uncover the essential mechanisms behind the +46 barren plateau phenomenon. +47 However, few rigorous scaling results are known for generic QNNs besides phenomenological calcu +48 lations, i.e., gradient analyses and their descendent [26–28]. Instead of just the limited information of +49 vicinity from gradient analyses, it would be quite helpful for designing efficient algorithms if we could +50 gain information on the entire variation range of the cost function when adjusting a single [39, 40] or +51 several parameters. Combined with the fact that parameters usually enter the circuit independently +52 through local quantum gates, all of which motivate our work where we are chiefly concerned with the +53 variation range of the cost function via varying a local unitary within a quantum circuit. +54 In this work, we present a rigorous scaling theorem on the trainability of QNNs beyond gradients +55 from the perspective of QNN locality. As summarized in Fig. 1, we prove that when varying a local +56 unitary within a sufficiently random circuit, the expectation and variance of the variation range of +57 the cost function vanish exponentially in the number of qubits. Then through simple derivations, we +58 show that this theorem implies exponentially vanishing gradients and cost function differences, and +59 hence unifies the restrictions on gradient-based and gradient-free optimizations. Meanwhile, this +60 theorem further delivers extra meaningful information about the training landscapes and optimization +61 possibilities of QNNs. In this sense, we obtain a fundamental limitation on QNN training. Next, we +62 illustrate the applications of our theorem on representative QNN models, where a tighter bound for +63 the fidelity-type cost function is provided specifically even with shallow random circuits. At last, we +64 perform numerical simulations on these representative models, where the scaling exponents coincide +65 with our analytical results almost precisely. +66 Comparison with Previous Works. The advances of our results compared to previous works [25, +67 27, 26, 28] exist in two aspects. Firstly, the exponentially vanishing quantity we claim is the entire +68 variation range of the cost function in the whole parameter subspace corresponding to the local +69 unitary. This provides constraints on multiple parameters at finite intervals simultaneously, instead of +70 an infinitesimal vicinity or two fixed-parameter points. Secondly, our results are irrelevant with the +71 parameterization of the local unitary like $e ^ { - i \Omega \theta }$ used previously. Hence, our results are much more +72 general whose only condition is the circuit locality and open a new avenue for analyzing the QNN +73 trainability. +75 Quantum State. We first introduce basic concepts and notations in quantum computing. A pure +76 single-qubit quantum state is a linear combination of two computational basis states, represented +77 as $| \phi \rangle = \alpha | 0 \rangle + \beta | 1 \rangle$ in Dirac notation, where $\alpha , \beta \in \mathbb { C } , | \alpha | ^ { 2 } + ^ { \cdot } | \beta | ^ { 2 } = 1$ . Here, $| 0 \rangle$ and $| 1 \rangle$ denote +78 the basis states $[ 1 , 0 ] ^ { T }$ and $[ 0 , 1 ] ^ { T }$ in the single-qubit space $\mathbb { C } ^ { 2 }$ , respectively. The $n$ -qubit space $\mathbb { C } ^ { 2 ^ { n } }$ +79 is formed by the tensor product of $n$ single-qubit spaces. Additionally, the quantum state can be +80 represented by a positive semidefinite matrix, also known as a density matrix. The density matrix $\rho$ +81 of a pure state $| \bar { \phi } \rangle$ consisting of $n$ qubits is expressed as $\rho = | \phi \rangle \langle \phi |$ , where $\langle \phi | = | \phi \rangle ^ { \dagger }$ . A general +82 mixed quantum state is represented by $\begin{array} { r } { \rho = \sum _ { k } \bar { c } _ { k } | \phi _ { k } \rangle \langle \phi _ { k } | } \end{array}$ , where $c _ { k } \in \mathbb { R } , \sum _ { k } c _ { k } = 1$ . +83 Quantum Gate. Quantum gates are mathematically described as unitary operators. Common +84 single-qubit gates include the Pauli rotations $\{ R _ { P } ( \theta ) \stackrel { - } { = } e ^ { - i \frac { \theta } { 2 } P } | P \in \{ X , \dot { Y , Z } \} \}$ , which are in the +85 matrix exponential form of Pauli matrices + +![](images/e40df06ed1d087c407286d9fbc60e03e2d1ca403469e434e04d6cbdc523f2e6d.jpg) +Figure 1: Training limitations from QNN locality. The left part depicts a PQC on $n$ qubits composed of local unitaries. The right part symbolically depicts the cost function on a classical device vs. the local unitary highlighted in the left part. This work proves that the cost function will fluctuate in an exponentially small range in the number of qubits with a high probability when we vary an arbitrary local unitary within the QNN in certain cases. + +$$ +X = { \binom { 0 } { 1 } } \ 1 \alpha \Big ) , \qquad Y = { \binom { 0 } { i } } \ 0 \Big ) , \qquad Z = { \binom { 1 } { 0 } } \ - 1 \alpha \Big ) . +$$ + +86 Common two-qubit gates include controlled- $\mathbf { X }$ gate $\mathrm { C N O T } = I \oplus X$ ( $\oplus$ is the direct sum) and +87 controlled-Z gate $\mathrm { C Z } = I \oplus Z$ , which can generate quantum entanglement among qubits. +88 Quantum Measurement. Quantum measurement is a quantum operation to obtain information +89 from the quantum system. For example, for a single-qubit state $| \phi \rangle = \alpha | 0 \rangle + \beta | 1 \rangle$ , the outcome of a +90 computational basis measurement is either $| 0 \rangle$ with probability $| \alpha | ^ { 2 }$ or $| 1 \rangle$ with probability $| \beta | ^ { 2 }$ . This +91 measurement operation can be mathematically referred to as the average of the observable $O = Z$ +92 under the state $| \phi \rangle$ : $\langle \phi | O | \phi \rangle = \mathrm { t r } [ Z | \phi \rangle \langle \phi | ] = \bar { | \alpha | } ^ { 2 } - | \beta | ^ { 2 }$ . Generally, quantum observables $O$ are +93 Hermitian matrices and $\mathcal { O } ( 1 / \varepsilon ^ { 2 } )$ times of measurements could give an $\varepsilon \| O \| _ { \infty }$ -error estimation to +94 the value $\operatorname { t r } [ O \rho ]$ , where $\| \cdot \| _ { \infty }$ is the spectral norm of the matrix. +95 Quantum Neural Network. While classical neural networks operate on classical bits and use +96 classical logic gates, quantum neural networks (QNNs) use quantum bits, or qubits, and quantum gates +97 to process and store information. QNNs are often described as parameterized quantum circuits (PQCs) +98 that are composed of rotation gates with adjustable rotating angles. In general, a QNN takes the +99 mathematical form $\begin{array} { r } { { \bf U } ( \pmb { \theta } ) = \prod _ { \mu } { \cal U } _ { \mu } ( \theta _ { \mu } ) { \cal W } _ { \mu } } \end{array}$ , where $U _ { \mu } ( \theta _ { \mu } ) \stackrel { \smile } { = } e ^ { - \overline { { i } } \theta _ { \mu } \Omega _ { \mu } }$ denotes a parameterized gate, +100 such as a single-qubit rotation gate with $\Omega _ { \mu }$ representing a Hermitian operator, and $W _ { \mu }$ corresponds +101 to fixed gates like the CNOT gate and SWAP gate. Commonly used templates of QNNs include the +102 hardware efficient ansatz, the alternating-layered ansatz, and the tensor-network-based ansatz [49, 51]. +103 Note that QNNs with intermediate classical controls such as QCNNs [52] can also be included in this +104 general form theoretically. + +# 105 3 Limitations of Local Unitary Optimization in QNN + +106 We start by introducing a general setting of a QNN model used throughout our analysis. A hybrid +107 quantum-classical framework in QML usually uses a classical optimizer to train a QNN, denoted by +108 U, with an input state $\rho$ by minimizing a task-dependent cost function $C$ , which is typically chosen +109 as the expectation value of some Hermitian operator $H$ : + +$$ +C _ { H , \rho } ( \mathbf { U } ) = \mathrm { t r } ( H \mathbf { U } \rho \mathbf { U } ^ { \dagger } ) . +$$ + +110 Note that other cost function forms can be regarded as compositions of observable expectations and +111 some other classical post-processing functions. Here we focus on (2) for simplicity. Divide the whole +112 qubit system into two parts $A , B$ with $m$ qubits and $n - m$ qubits, respectively. Here $m$ is a fixed +113 constant not scaling with $n$ so that we call $A$ a local subsystem. The QNN U is often composed of +114 local unitaries on real devices, such as the single-qubit rotation gates and the CNOT gate. We focus +115 on a local unitary $U _ { A }$ within $\mathbf { U }$ acting on subsystem $A$ . As shown in Fig. 2, we denote the sub-circuit +116 of U before $U _ { A }$ as $V _ { 1 }$ and that behind $U _ { A }$ as $V _ { 2 }$ , such that $\mathbf { U } = V _ { 2 } ( U _ { A } \otimes I _ { B } ) V _ { 1 }$ where $I _ { B }$ is the +117 identity operator on $B$ . $V _ { 1 }$ , $V _ { 2 }$ and $U _ { A }$ are independent of each other. We also remark that this circuit +118 setting is sufficiently general to cover common representative QNN models, e.g., the variational +119 quantum eigensolver, the quantum autoencoder, and the quantum state learning. +120 To characterize the training landscape beyond the limited information of the vicinity from gradient +121 analyses, we introduce a central quantity throughout this work, i.e., the variation range of the cost +122 function via varying a local unitary. +123 Definition 1 For a generic cost function $C _ { H , \rho } ( \mathbf { U } )$ with a QNN U in Eq. (2), we define its variation +124 range with given $V _ { 1 } , V _ { 2 }$ as + +![](images/7120a5da85efa4f02ddcfef8d6df127df584943040ada6fb9fd3ce0d7a73f79e.jpg) +Figure 2: Partition of the QNN in our analysis. The QNN is decomposed as $\mathbf { U } = V _ { 2 } ( U _ { A } \otimes I _ { B } ) V _ { 1 }$ with an input state $\rho$ and an observable $H$ . A tunable local unitary $U _ { A }$ is implemented by some local quantum gates with the left and right parts assembled as $V _ { 1 }$ and $V _ { 2 }$ . + +$$ +\Delta _ { H , \rho } ( V _ { 1 } , V _ { 2 } ) : = \operatorname* { m a x } _ { U _ { A } } C _ { H , \rho } ( \mathbf { U } ) - \operatorname* { m i n } _ { U _ { A } } C _ { H , \rho } ( \mathbf { U } ) , +$$ + +where the maximum and minimum with respect to 125 $U _ { A }$ are taken over the unitary group $\mathcal { U } ( 2 ^ { m } )$ of degree 126 $2 ^ { m }$ . + +127 The quantity $\Delta _ { H , \rho } ( V _ { 1 } , V _ { 2 } )$ intuitively reflects the maximal possible influence that the local unitary +128 $U _ { A }$ can have on the cost function. We establish an upper bound on $\Delta _ { H , \rho } ( V _ { 1 } , V _ { 2 } )$ in the sense of +129 probability by Theorem 1, which thus delivers a limitation on optimizing an arbitrary local unitary. +130 To be specific, we prove that if either $V _ { 1 }$ , $V _ { 2 }$ , or both match the Haar distribution up to the second +131 moment, i.e., are sampled from unitary 2-designs [53], the expectation of $\Delta _ { H , \rho } ( V _ { 1 } , V _ { 2 } )$ vanishes +132 exponentially in the number of qubits. See Appendix A for preliminaries on unitary designs. +133 Theorem 1 Suppose $\mathbb { V } _ { 1 } , \mathbb { V } _ { 2 }$ are ensembles from which $V _ { 1 } , V _ { 2 }$ are sampled, respectively. If either $\mathbb { V } _ { 1 }$ +134 or $\mathbb { V } _ { 2 }$ , or both form unitary 2-designs, then for arbitrary $H$ and $\rho _ { i }$ , the following inequality holds + +$$ +\mathbb { E } _ { V _ { 1 } , V _ { 2 } } [ \Delta _ { H , \rho } ( V _ { 1 } , V _ { 2 } ) ] \leq \frac { w ( H ) } { 2 ^ { n / 2 - 3 m - 2 } } , +$$ + +135 where $\mathbb { E } _ { V _ { 1 } , V _ { 2 } }$ denotes the expectation over $\mathbb { V } _ { 1 } , \mathbb { V } _ { 2 }$ independently. $w ( H ) = \lambda _ { \operatorname* { m a x } } ( H ) - \lambda _ { \operatorname* { m i n } } ( H )$ +136 denotes the spectral width of $H$ , where $\lambda _ { \operatorname* { m a x } } ( H )$ is the maximum eigenvalue of $H$ and $\lambda _ { \operatorname* { m i n } } ( H )$ is +137 the minimum. +138 Theorem 1 demonstrates that the maximal influence of a local unitary within a random QNN on +139 the cost function diminishes exponentially in the number of qubits, with a high probability. This +140 inherent locality of QNN poses an exponential hardness of optimization in QNN training and we +141 would like to make several remarks to better reveal the underlying implications of the theorem below. +142 The main proof idea of Theorem 1 is to calculate the expectation value over $\mathbb { V } _ { 1 } , \mathbb { V } _ { 2 }$ separately. To +143 tackle the maximization over $U _ { A }$ , the main technique is to employ Hölder’s inequality to extract $U _ { A }$ +144 out and bound the remaining part with specific calculations of 2-design element-wise integrals. For +145 the detailed proof, we defer to Appendix B. +146 Remark 1 Firstly, due to the non-negativity and boundedness of the variation range, i.e., $\Delta _ { H , \rho } \in$ +147 $[ 0 , w ( H ) ]$ , the variance of $\Delta _ { H , \rho }$ can be bounded by its expectation times $w ( H )$ . Thus from Theorem 1 +148 we know that the variance also vanishes exponentially: + +$$ +\operatorname { V a r } _ { V _ { 1 } , V _ { 2 } } [ \Delta _ { H , \rho } ( V _ { 1 } , V _ { 2 } ) ] \leq \frac { w ^ { 2 } ( H ) } { 2 ^ { n / 2 - 3 m - 2 } } . +$$ + +149 Note that $w ( H ) \in { \mathcal { O } } ( \mathrm { p o l y } ( n ) )$ holds for common VQAs. Moreover, Theorem 1 together with +150 Markov’s inequality provides an exponentially small upper bound of the probability that $\Delta _ { H , \rho } ( V _ { 1 } , V _ { 2 } )$ +151 deviates from zero, i.e., + +$$ +\mathrm { P r } [ \Delta _ { H , \rho } ( V _ { 1 } , V _ { 2 } ) \geq \epsilon ] \leq \frac { 1 } { \epsilon } \cdot \frac { w ( H ) } { 2 ^ { n / 2 - 3 m - 2 } } , \forall \epsilon > 0 . +$$ + +152 That is to say, the probability that $\Delta _ { H , \rho }$ is non-zero to some fixed precision is exponentially small. + +153 Remark 2 Secondly, we can even establish an exponentially small bound using Theorem 1 for the +154 case where $U _ { A }$ is a global unitary satisfying the parameter-shift rule [54–58]. Suppose $U _ { A } = e ^ { - i \theta \Omega }$ +155 with the Hermitian generator $\Omega$ satisfying $\bar { \Omega } ^ { 2 } = I$ . Since $\Omega$ has only two different eigenvalues $\pm 1$ , +156 there exists a unitary $W$ such that $\dot { W } e ^ { - i \theta \Omega } W ^ { \dagger }$ becomes a local unitary acting on a single qubit +157 non-trivially. $W$ and $W ^ { \dagger }$ could be absorbed into the rest of the circuit with $\breve { W } ^ { \dagger } \mathbb { V } _ { 1 }$ or $\mathbb { V } _ { 2 } W$ still +158 forming 2-designs [59]. Therefore, the proof for global unitaries satisfying the parameter-shift rule +159 can be reduced back to the case of local unitaries. +160 Remark 3 Moreover, it is worth noticing that the compact bound in (4) only involves the spectral +161 width $w ( H )$ and does not depend on any detail of the Hermitian operator $H$ . But if some specific +162 structures about $H$ are known, e.g., the Pauli decomposition of $H$ , a tighter bound could be derived in +163 Appendix B which depends on the coupling complexity of $H$ . In addition, if the cost function reduces +164 to the form of the fidelity between pure states, we could have a tighter bound with scaling $O ( 2 ^ { - n } )$ +165 in Proposition 2. Theorem 1 can be generalized to arbitrary dimensions besides qubit systems of +166 dimension $2 ^ { n }$ , e.g., qutrit and qudit systems. The detailed proof is provided in Appendix B. +167 In fact, Theorem 1 has a natural physical interpretation: the effect of a local operation on a physical +168 observable will vanish exponentially after a chaotic evolution. Remarkably, the concept of local +169 operations yielding minor global influences is a physically intuitive yet mathematically intricate +170 notion. For instance, even a single-qubit unitary is enough to rotate an arbitrary $n$ -qubit pure state to a +171 new state with zero fidelity with the original one, showcasing local operations do make a great global +172 influence. Hence, Theorem 1 may be invaluable as a rigorous formulation of the aforementioned +173 argument within the domain of QNN training, elucidating the locality of QNNs. + +# 174 4 Unifying the Limitations on Training QNNs + +175 Here we briefly demonstrate how Theorem 1 unifies the restrictions on gradient-based [25, 27] and +176 gradient-free optimizations [26, 28] in a more natural manner, and indicates the extra restrictions +177 besides them on QNN training. In the following, we focus on a PQC applicable for Theorem 1 with +178 $M$ trainable parameters $\{ \theta _ { \mu } \} _ { \mu = 1 } ^ { \mathbf { \tilde { \cal M } } }$ and denote the variation range of the cost function via varying $\theta _ { \mu }$ +179 as $\Delta _ { \mu }$ . +180 181 rule is valid [54–58], Theorem 1 can strictly deduce vanishing gradients. Suppose Consider the gradient-based optimization first. On the one hand, in the case where the parameter-shift $\{ \theta _ { \mu } \} _ { \mu = 1 } ^ { M }$ are +182 applicable for the parameter-shift rule (e.g., hardware-efficient ansatzes). Namely, $\theta _ { \mu }$ enters the +183 unitary $e ^ { - i \theta _ { \mu } \Omega _ { \mu } }$ within the circuit where $\Omega _ { \mu }$ is a Hermitian generator satisfying $\Omega _ { \mu } ^ { 2 } = I$ . From +184 Theorem 1 we know that the expectation of $\Delta _ { \mu }$ vanishes exponentially. Therefore, the derivative +185 $\partial _ { \mu } C : = { \frac { \partial C } { \partial \theta _ { \mu } } }$ with respect to $\theta _ { \mu }$ satisfies + +$$ +\mathbb { E } [ | \partial _ { \mu } C | ] = \mathbb { E } \left[ \left| C \left( \pmb { \theta } + \frac { \pi } { 4 } \mathbf { e } _ { \mu } \right) - C \left( \pmb { \theta } - \frac { \pi } { 4 } \mathbf { e } _ { \mu } \right) \right| \right] \leq \mathbb { E } [ \Delta _ { \mu } ] \in \mathcal { O } ( 2 ^ { - n / 2 } ) , +$$ + +186 where ${ \bf e } _ { \mu }$ is the unit vector in the parameter space corresponding to $\theta _ { \mu }$ . From Markov’s inequality as +187 in (6), we know that the probability that the derivative $\partial _ { \mu } C$ deviates from zero by a small constant is +188 exponentially small. +189 On the other hand, even in the absence of the parameter-shift rule, vanishing gradients could still be +190 obtained approximately by the following arguments. Consider the vicinity of a random initialized +191 parameter point where the linear approximation error is negligible, denoted as an $\varepsilon$ -ball $B _ { \varepsilon }$ of radius +192 $\varepsilon$ (here $\varepsilon$ plays the same role as the learning rate). As shown in Fig. 3, the linearity in $B _ { \varepsilon }$ together +193 with Theorem 1 leads to + +$$ +\mathbb { E } \left[ \vert \partial _ { \mu } C \vert \right] \leq \mathbb { E } \left[ \frac { \Delta _ { \mu } } { 2 \varepsilon } \right] \in \mathcal { O } ( 2 ^ { - n / 2 } \frac { 1 } { \varepsilon } ) , +$$ + +![](images/d4f4f746c5bb700d47bdbd31c7de99b0e74a40556486bd0b59cba8041aaf417c.jpg) +Figure 3: Sketch of our results implying vanishing gradients. The left panel sketches the whole training landscape with one of the parameters $\theta _ { \mu }$ as the $x$ -axis, all of the other parameters $\{ \boldsymbol { \theta } _ { \nu } \} _ { \nu \neq \mu }$ as the $y$ -axis symbolically and the cost function value $C$ as the $z \cdot$ -axis. The right panel depicts a typical sample of the $z - x$ cross-section from the landscape on the left with variation range $\Delta _ { \mu }$ . Up to the linear approximation error, $\Delta _ { \mu }$ serves as an upper bound for the absolute derivative $| \partial _ { \mu } C |$ times the vicinity size $2 \varepsilon$ . + +194 up to the linear approximation error, where $1 / \varepsilon$ is not an essential factor since it reflects the frequencies +195 of the landscape fluctuation rather than magnitudes, similar to the role of the factor $\mathrm { t r } ( V ^ { 2 } )$ in the +196 expression of $\bar { \mathrm { V a r } } [ \partial _ { \mu } C ]$ [25]. + +197 For the gradient-free optimization based on the cost function difference between any two fixed parameter points 198 $\pmb { \theta } ^ { \prime }$ and $\pmb \theta$ , Theorem 1 leads to + +$$ +\mathbb { E } \left[ \left| C ( \pmb { \theta } ^ { \prime } ) - C ( \pmb { \theta } ) \right| \right] \le \mathbb { E } \left[ \sum _ { \mu = 1 } ^ { M } \left| C \left( \pmb { \theta } ^ { ( \mu ) } \right) - C \left( \pmb { \theta } ^ { ( \mu - 1 ) } \right) \right| \right] \le \sum _ { \mu = 1 } ^ { M } \mathbb { E } \left[ \left| \Delta _ { \mu } \right| \right] \in \mathcal { O } ( M 2 ^ { - n / 2 } ) , +$$ + +199 where $\begin{array} { r } { \pmb { \theta } ^ { ( \mu ) } = \pmb { \theta } + \sum _ { \nu = 1 } ^ { \mu } \left( \theta _ { \nu } ^ { \prime } - \theta _ { \nu } \right) \mathbf { e } _ { \nu } } \end{array}$ for $\mu = 1 , . . . , M$ and $\pmb \theta ^ { ( \mu ) } = \pmb \theta$ for $\mu = 0$ . Thus, as long as +200 the number of parameters satisfies $M \in { \mathcal { O } } ( \operatorname { p o l y } ( n ) )$ , the cost function difference between any two +201 points vanishes exponentially with a high probability, demanding an exponential precision to make +202 progress in the gradient-free optimization. +203 Furthermore, Theorem 1 goes beyond vanishing gradients and vanishing differences between two +204 fixed points. The exponentially vanishing quantity claimed by Theorem 1 is the variation range of the +205 cost function in the whole parameter subspace corresponding to a local unitary, e.g., the subspace of +206 the 3 Euler angles in a single-qubit rotation gate from $S U ( 2 )$ , or the subspace of the 15 parameters +207 in a two-qubit rotation gate from $S U ( 4 )$ , etc. This gives constraints on multiple parameters at finite +208 intervals simultaneously, instead of a vicinity or two fixed parameter points. + +# 209 5 Application on Representative QNN Models + +210 To better illustrate the meaning of our findings in practice, we investigate the applications of Theorem 1 +211 on three representative QNN models, including the variational quantum eigensolver (VQE), quantum +212 autoencoder, and quantum state learning. The corresponding numerical simulation results are +213 summarized in Fig. 5. +214 Application on VQE. The variational quantum eigensolver is the most famous implementation of a +215 hybrid quantum-classical algorithm with the goal to prepare the ground state of a given Hamiltonian +216 $\hat { H }$ of a physical system [60]. The cost function is the energy expectation with respect to an ansatz +217 state ${ \bf U } | 0 \rangle$ , i.e., + +$$ +C _ { \mathrm { V Q E } } ( \mathbf { U } ) = \langle 0 | \mathbf { U } ^ { \dag } \hat { H } \mathbf { U } | 0 \rangle . +$$ + +218 For most physical models with local interactions, the spectral width is proportional to the system +219 size, i.e., $w ( \hat { H } ) \in \mathcal { O } ( n )$ . For common repeated-layer-type ansatzes, e.g., the hardware-efficient +220 ansatzes [61], linear depth ${ \mathcal { O } } ( n )$ is enough to make a randomly initialized circuit to be a sample from +221 an approximate 2-design ensemble [25, 62, 63]. Hence from Theorem 1 we know that $\Delta _ { \mathrm { V Q E } } ( V _ { 1 } , V _ { 2 } )$ +222 vanishes exponentially with a high probability for random circuits forming 2-designs. We conduct +223 numerical simulations for the variation range of the VQE cost function $\Delta _ { \mathrm { V Q E } }$ using the 1-dimensional +224 spin- $1 / 2$ antiferromagnetic Heisenberg model: + +![](images/cb18f6a8353d9a7aa023664eec1b3dd2e1e52b6a961d96b8f157cce37f1372ac.jpg) +Figure 4: Circuit setting of the quantum autoencoder. $\rho _ { Q R }$ is the given state to be compressed and $\sigma _ { Q }$ is the compressed state through the encoder U. The quantum autoencoder aims to train $\mathbf { U }$ such that $\rho _ { Q R }$ can be reconstructed from $\sigma _ { Q }$ with high fidelity through the decoder $\mathbf { U } ^ { \dagger }$ combined with an ancilla zero state $| 0 \rangle \langle 0 | _ { R }$ . $\sigma _ { R }$ denotes the state of the discarded part after compression. + +$$ +\hat { H } = \sum _ { i = 1 } ^ { n } \left( X _ { i } X _ { i + 1 } + Y _ { i } Y _ { i + 1 } + Z _ { i } Z _ { i + 1 } \right) , +$$ + +225 with periodic boundary condition, as shown in Fig. 5(a). + +26 Application on Quantum Autoencoder. The quantum autoencoder (QAE) is an approach for +27 quantum data compression [64, 65]. As shown in Fig. 4, a QNN $\mathbf { U }$ is trained as an encoder to +28 compress a given state $\rho _ { Q R }$ on a bipartite system $Q R$ into a reduced state $\sigma _ { Q } = \mathrm { t r } _ { R } ( \mathbf { U } \rho _ { Q R } \mathbf { U } ^ { \dagger } )$ on +29 subsystem $Q$ , such that $\rho _ { Q R }$ can be reproduced from $\sigma _ { Q }$ by the decoder isometry $\langle 0 | _ { R } { \bf U } ^ { \dagger }$ with a +30 high fidelity. According to the monotonicity of the fidelity under partial trace, an easy-to-measure +31 cost function could be reduced from the fidelity between $\rho _ { Q R }$ and the reconstructed state as + +$$ +\begin{array} { r } { C _ { \mathrm { Q A E } } ( \mathbf { U } ) : = 1 - \mathrm { t r } \left( ( | 0 \rangle \langle 0 | _ { R } \otimes I _ { Q } ) \mathbf { U } \rho _ { Q R } \mathbf { U } ^ { \dag } \right) , } \end{array} +$$ + +232 where the second term is exactly the fidelity between the state of the discarded part $\sigma _ { R } =$ +233 $\operatorname { t r } _ { Q } ( \mathbf { U } \rho _ { Q R } \mathbf { U } ^ { \dagger } )$ and the zero state $| 0 \rangle _ { R }$ on subsystem $R$ . The spectral width for the QAE cost +234 function (12) is $w ( H _ { \mathrm { Q A E } } ) = 1$ with $H _ { \mathrm { Q A E } } = I _ { Q R } - \vert 0 \rangle \langle 0 \vert _ { R } \otimes I _ { Q }$ . Thus again from Theorem 1 +235 we know that $\Delta _ { \mathrm { Q A E } } ( V _ { 1 } , V _ { 2 } )$ vanishes exponentially in the number of qubits, specifically with the +236 scaling $\mathcal { O } ( 2 ^ { - n / 2 } )$ as shown in Fig. 5(b). +237 Application on Quantum State Learning. The fidelity between pure states is a special case of the +238 cost function in (2) with a low-rank observable. Many QML applications make use of fidelity as their +239 cost functions [66–68]. Here we uniformly call them quantum state learning (QSL) tasks. Denote the +240 input state as $| \psi \rangle$ and the target state as $| \phi \rangle$ . The QSL cost function can be written as + +$$ +C _ { \mathrm { Q S L } } ( \mathbf { U } ) = 1 - \left| \langle \phi | \mathbf { U } | \psi \rangle \right| ^ { 2 } . +$$ + +241 Theorem 1 can be applied here with $\begin{array} { r } { H _ { \mathrm { Q S L } } = I - | \phi \rangle \langle \phi | } \end{array}$ and $w ( H _ { \mathrm { Q S L } } ) = 1$ . Here a tighter bound +242 for $\Delta _ { \mathrm { Q S L } }$ is provided in Proposition 2, which generally holds for the Bures fidelity. The proof of +243 Proposition 2 is detailed in Appendix C. +244 Proposition 2 If either $\mathbb { V } _ { 1 }$ or $\mathbb { V } _ { 2 }$ , or both form unitary 1-designs, then for the variation range of the +245 fidelity-type cost function $\Delta _ { \mathrm { Q S L } }$ , the following inequality holds + +$$ +\mathbb { E } _ { V _ { 1 } , V _ { 2 } } \left[ \Delta _ { \mathrm { Q S L } } ( V _ { 1 } , V _ { 2 } ) \right] \leq \frac { 1 } { 2 ^ { n - 2 m } } . +$$ + +246 Compared with Theorem 1, the bound $O ( 2 ^ { - n } )$ becomes tighter and the demanded randomness +247 becomes weaker in this special case. Notably, even a random circuit of constant depth is enough +248 to form a 1-design, which is much shallower than 2-designs. Like in (5) and (6), the variance and +249 the probability that $\Delta _ { \mathrm { Q S L } }$ deviates from zero also vanish exponentially, but only require random +250 circuits forming unitary 1-designs. Moreover, still with 1-designs, Proposition 2 implies exponentially +251 vanishing cost gradients and cost differences in the same way as Theorem 1, which may be considered +252 as the underlying mechanism behind the severe barren plateaus for global cost functions even with +253 shallow quantum circuits [49]. + +![](images/cc7bf05d4d90191e8e61a352024d43e97915ce3c70ed0f2ccd601fa5dfa8b944.jpg) +Figure 5: Exponentially vanishing variation range of the cost function via varying a local unitary. The data points represent the sample averages of the cost variation range $\Delta _ { H , \rho }$ via varying a singlequbit unitary over the spectral width $w ( H )$ as a function of the number of qubits on semi-log plots. Panel (a) and (b) correspond to the VQE with the 1-dimensional Heisenberg model and the quantum autoencoder with one qubit discarded, respectively, where the error bars represent the standard deviations over samples. Panel (c) corresponds to the quantum state learning with the cost function being the fidelity with the zero state. Different legends stand for $\mathbb { V } _ { 1 }$ , $\mathbb { V } _ { 2 }$ or both being approximate 2-designs in (a), (b) and 1-designs in (c). The dashed lines depict our theoretical upper bounds for the three tasks where the scaling exponents show a good coincidence with the experimental results. + +# 254 6 Numerical Simulations of Experiments + +255 Previously, we have theoretically shown that with a high probability, the maximal influence of a local +256 unitary within a random QNN on the cost function will vanish exponentially in the number of qubits. +257 We further demonstrate the validity of our results with numerical simulations of experiments on the +258 three representative QNN models. All of these experimental results show the exponentially vanishing +259 variation range in the number of qubits, which is consistent with Theorem 1 and Proposition 2. +260 Circuit Setting. Consider subsystem $A$ only containing a single qubit, namely $m \ : = \ : 1$ , and +261 parameterize the local unitary $U _ { A } \in \mathcal { U } ( 2 )$ with 3 Euler angles up to a global phase, i.e., ${ \cal U } _ { A } ( \phi , \theta , \alpha ) =$ +262 $R _ { z } ( \phi ) R _ { y } ( \theta ) R _ { z } ( \alpha )$ , where $R _ { y }$ and $R _ { z }$ are single-qubit rotation gates with generators being $Y$ and +263 $Z$ Pauli matrices. To construct random circuits forming 2-designs as $V _ { 1 }$ or $V _ { 2 }$ used in the VQE and +264 QAE examples, we employ the following hardware-efficient ansatz as in [25] for comparison. + +$$ +\begin{array} { r l } & { - \Bigl [ R _ { y } ( \frac { \pi } { 4 } ) \Bigr ] + \Bigl [ R _ { P _ { 1 , 1 } } ( \theta _ { 1 , 1 } ) \Bigr ] - \Bigl [ \sin ^ { \prime } \sin ^ { \prime } \sin ^ { \prime } \sin ^ { \prime } \sin ^ { \prime } \sin ^ { \prime } \sin ^ { \prime } \Bigr ] } \\ & { - \Bigl [ \frac { R _ { y } ( \frac { \pi } { 4 } ) } { R _ { y } ( \frac { \pi } { 4 } ) } \Bigr ] + \Bigl [ \frac { R _ { P _ { 1 , 2 } } ( \theta _ { 1 , 2 } ) } { R _ { P _ { 1 , 2 } } ( \theta _ { 1 , 2 } ) } \Bigr ] - \Bigl [ \sin ^ { \prime } \sin ^ { \prime } \sin ^ { \prime } \sin ^ { \prime } \Bigr ] } \\ & { - \Bigl [ \frac { R _ { y } ( \frac { \pi } { 4 } ) } { \pi } \Bigr ] + \Bigl [ \frac { R _ { P _ { 1 , 3 } } ( \theta _ { 1 , 3 } ) } { \cdots } \Bigr ] - \Bigl [ \frac { 1 } { \pi } \Bigr ] - \cdots } \\ & { - \Bigl [ \frac { R _ { y } ( \frac { \pi } { 4 } ) } { R _ { y } ( \frac { \pi } { 4 } ) } \Bigr ] + \Bigl [ \frac { R _ { P _ { 1 , n } } ( \theta _ { 1 , n } ) } { \pi } \Bigr ] - \dots - \dots - 1 - 1 } \end{array} +$$ + +265 A single layer of $R _ { y } ( \pi / 4 ) = \exp ( - i Y \pi / 8 )$ gates are laid at the very beginning of the circuit to +266 make the three rotation axes have equal status, then followed by $1 0 \times n$ repeated layers. Each layer +267 consists of $n$ single-qubit rotation gates $R _ { P } ( \theta )$ on each qubit together with $n - 1$ controlled phase +268 gates between nearest neighboring qubits aligned as a 1-dimensional array, where the rotation axes +269 $P \in \{ x , y , z \}$ is chosen with uniform probability and $\theta \in [ 0 , 2 \pi )$ is also chosen uniformly. A such +270 random circuit with ${ \mathcal { O } } ( n )$ repeated layers could be considered as an approximate 2-design (here we +271 employ $1 0 \times n$ ) [25, 62, 63]. Experimental results with different numbers of layers are also presented +272 in Appendix D to show how the expectation of the cost variation range $\Delta _ { H , \rho }$ vanishes with the circuit +273 depth. To construct random circuits forming 1-designs used in the QSL example, we just replace the +274 repeated layers above with a single layer of $S U ( 2 )$ elements $R _ { z } ( \phi ) R _ { y } ( \theta ) R _ { z } ( \alpha )$ on each qubit with +275 $\phi , \theta , \alpha \in [ 0 , 2 \pi )$ are chosen with uniform probability. +276 Implementation Details. To compute $\operatorname* { m a x } _ { U _ { A } } C$ and $\operatorname* { m i n } _ { U _ { A } } C$ in the definition of $\Delta _ { H , \rho } ( V _ { 1 } , V _ { 2 } )$ +277 with respect to $U _ { A }$ , we employ the Adam optimizer to update $U _ { A }$ iteratively until convergence for +278 each of the 100 samples of $V _ { 1 } , V _ { 2 }$ . We consider the converged value as a good estimation with a +279 tolerable error at least for circuits with a small number of qubits $( \le 1 0 )$ and a modest depth $( \leq 1 0 \times n )$ +280 We repeat this procedure for different numbers of qubits and different statistics of $\mathbb { V } _ { 1 }$ and $\mathbb { V } _ { 2 }$ , i.e., $\mathbb { V } _ { 1 }$ +281 or $\mathbb { V } _ { 2 }$ being a 2-design (1-design) while the other being identity. +282 Numerical Results. We summarize the simulation results of the three examples in Fig. 5. The +283 slopes of the lines imply the rates of exponential decay. The data points represent the sample averages +284 of the cost variation range $\Delta _ { H , \rho }$ via varying $U _ { A }$ over $w ( H )$ , and the error bars represent the standard +285 deviations over samples. We specially rescale the error bar in the QSL example as a quarter of the +286 standard deviation for better presentation on semi-log plots. One can see that in all the cases, the +287 expectations of $\Delta _ { H , \rho } ( V _ { 1 } , V _ { 2 } )$ vanish exponentially in the number of qubits. The data lines are almost +288 parallel to the dashed lines depicting the theoretical upper bounds. That is to say, the scaling behaviors +289 almost coincide with the predictions from Theorem 1 and Proposition 2. These results suggest that +290 while optimizing a local unitary within a random QNN, the cost function exhibits fluctuations within +291 an exponentially small range relative to the number of qubits. It is this phenomenon that elucidates +292 the vanishing gradient issue and contributes to the exponential difficulty of training as the QNN scales +293 up. A detailed derivation can be found in Appendix B for the tighter task-dependent upper bounds +294 used in Fig. 5(a) and (b). + +# 295 7 Conclusion and Discussion + +296 We have shown that the maximal possible influence of a local unitary within a QNN on the cost +297 function vanishes exponentially in the number of qubits with a high probability. This finding unveils +298 the exponential hardness associated with training QNNs as they scale up. The randomness required is +299 just a 2-design for the generic cost function and a 1-design for the fidelity-type cost function, in spite +300 that the integrand $\Delta _ { H , \rho } ( V _ { 1 } , V _ { 2 } )$ is not necessarily a polynomial of degree at most 2 or 1 in the entries +301 of $V _ { 1 }$ and $V _ { 2 }$ . We remark that a 2-design circuit can be achieved approximately by only ${ \mathcal { O } } ( n )$ depth +302 [25, 62, 63] for common repeated-layer-type ansatzes, e.g., the hardware-efficient ansatzes [61], and +303 a 1-design circuit can be achieved more easily by only $\mathcal { O } ( 1 )$ depth. +304 From the perspective of quantum information theory, our results can be regarded as a basic property +305 of random quantum circuits. That is, a local unitary within a random circuit of polynomial depth +306 has an exponentially small impact on the expectation of physical observables, which is expected to +307 have potential applications in other areas involving random quantum circuits. This property may also +308 provide insight into QNN design to address the critical trainability issue. +309 For the training of QNN, our results unify the restrictions on gradient-based and gradient-free +310 optimizations in a natural way and hence can be regarded as the underlying mechanism behind the +311 barren plateau phenomenon. Therefore, a fundamental limitation is unraveled in training QNNs, +312 which can serve as a guide for designing better training strategies to improve the scalability of +313 QNNs. A direct consequence is that the gate-by-gate optimization strategy [39, 40] is ineffective no +314 matter what optimizers are utilized. Reparameterization within local unitaries is also unhelpful. For +315 future research, it will be of great interest to explore potential solutions via proper initialization [41], +316 pre-training including adaptive methods [42–46], circuit architectures [47, 48] and cost function +317 choices [49, 50]. + +# 318 References + +319 [1] John Preskill. Quantum Computing in the NISQ era and beyond. Quantum, 2:79, aug 2018. ISSN +320 2521-327X. doi: 10.22331/q-2018-08-06-79. URL https://quantum-journal.org/papers/ +321 q-2018-08-06-79/. +322 [2] Dave Wecker, Matthew B. Hastings, and Matthias Troyer. Progress towards practical quantum variational +323 algorithms. Physical Review A, 92(4):042303, oct 2015. ISSN 1050-2947. doi: 10.1103/PhysRevA.92. +324 042303. URL https://link.aps.org/doi/10.1103/PhysRevA.92.042303. +325 [3] Wen Wei Ho and Timothy H. Hsieh. Efficient variational simulation of non-trivial quantum states. feb +326 2018. doi: 10.21468/SciPostPhys.6.3.029. URL http://arxiv.org/abs/1803.00026http://dx. +327 doi.org/10.21468/SciPostPhys.6.3.029. + +[4] Alexey Uvarov, Jacob Biamonte, and Dmitry Yudin. Variational Quantum Eigensolver for Frustrated Quantum Systems. Physical Review B, 102(7):075104, may 2020. ISSN 2469-9950. doi: 10.1103/ PhysRevB.102.075104. URL https://link.aps.org/doi/10.1103/PhysRevB.102.075104http: //arxiv.org/abs/2005.00544. [5] Sam McArdle, Suguru Endo, Alán Aspuru-Guzik, Simon C. Benjamin, and Xiao Yuan. Quantum computational chemistry. Reviews of Modern Physics, 92(1):015003, mar 2020. ISSN 0034-6861. doi: 10.1103/RevModPhys.92.015003. URL https://link.aps.org/doi/10.1103/RevModPhys. 92.015003. [6] Daniel J. Egger, Claudio Gambella, Jakub Marecek, Scott McFaddin, Martin Mevissen, Rudy Raymond, Andrea Simonetto, Stefan Woerner, and Elena Yndurain. Quantum Computing for Finance: State-of-theArt and Future Prospects. IEEE Transactions on Quantum Engineering, 1:1–24, 2020. ISSN 2689-1808. doi: 10.1109/TQE.2020.3030314. URL https://ieeexplore.ieee.org/document/9222275/. [7] Dylan Herman, Cody Googin, Xiaoyuan Liu, Alexey Galda, Ilya Safro, Yue Sun, Marco Pistoia, and Yuri Alexeev. A Survey of Quantum Computing for Finance. arXiv preprint arXiv: 2201.02773, jan 2022. URL http://arxiv.org/abs/2201.02773. [8] Adam Bouland, Wim van Dam, Hamed Joorati, Iordanis Kerenidis, and Anupam Prakash. Prospects and challenges of quantum finance. arXiv:2011.06492, nov 2020. URL http://arxiv.org/abs/2011. 06492. [9] Jacob Biamonte, Peter Wittek, Nicola Pancotti, Patrick Rebentrost, Nathan Wiebe, and Seth Lloyd. Quantum machine learning. Nature, 549(7671):195–202, sep 2017. ISSN 0028-0836. doi: 10. 1038/nature23474. URL http://dx.doi.org/10.1038/nature23474http://www.nature.com/ articles/nature23474. [10] Maria Schuld, Alex Bocharov, Krysta M. Svore, and Nathan Wiebe. Circuit-centric quantum classifiers. Physical Review A, 101(3):032308, mar 2020. ISSN 2469-9926. doi: 10.1103/PhysRevA.101. 032308. URL http://arxiv.org/abs/1804.00633http://dx.doi.org/10.1103/PhysRevA.101. 032308https://link.aps.org/doi/10.1103/PhysRevA.101.032308. [11] Ryan LaRose and Brian Coyle. Robust data encodings for quantum classifiers. Physical Review A, 102(3): 032420, sep 2020. ISSN 2469-9926. doi: 10.1103/PhysRevA.102.032420. URL https://link.aps. org/doi/10.1103/PhysRevA.102.032420. [12] Junyu Liu, Francesco Tacchino, Jennifer R Glick, Liang Jiang, and Antonio Mezzacapo. Representation learning via quantum neural tangent kernels. PRX Quantum, 3(3):030323, 2022. +359 [13] Matthias C Caro, Hsin-Yuan Huang, Marco Cerezo, Kunal Sharma, Andrew Sornborger, Lukasz Cincio, and Patrick J Coles. Generalization in quantum machine learning from few training data. Nature communications, 13(1):4919, 2022. ISSN 2041-1723. [14] M Cerezo, Guillaume Verdon, Hsin-Yuan Huang, Lukasz Cincio, and Patrick J Coles. Challenges and opportunities in quantum machine learning. Nature Computational Science, 2(9):567–576, 2022. ISSN 2662-8457. [15] Valentin Gebhart, Raffaele Santagati, Antonio Andrea Gentile, Erik M Gauger, David Craig, Natalia Ares, Leonardo Banchi, Florian Marquardt, Luca Pezzè, and Cristian Bonato. Learning quantum systems. Nature Reviews Physics, 5(3):141–156, feb 2023. ISSN 2522-5820. doi: 10.1038/s42254-022-00552-1. URL https://www.nature.com/articles/s42254-022-00552-1. [16] Ge Yan, Yehui Tang, and Junchi Yan. Towards a Native Quantum Paradigm for Graph Representation Learning: A Sampling-based Recurrent Embedding Approach. In Proceedings of the 28th ACM SIGKDD Conference on Knowledge Discovery and Data Mining, pages 2160–2168, 2022. [17] Xuchen You, Shouvanik Chakrabarti, Boyang Chen, and Xiaodi Wu. Analyzing Convergence in Quantum Neural Networks: Deviations from Neural Tangent Kernels. arXiv preprint arXiv:2303.14844, 2023. +374 [18] Tongyang Li, Chunhao Wang, Shouvanik Chakrabarti, and Xiaodi Wu. Sublinear classical and quantum algorithms for general matrix games. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 35, pages 8465–8473, 2021. ISBN 2374-3468. [19] Hsin-Yuan Huang, Richard Kueng, Giacomo Torlai, Victor V Albert, and John Preskill. Provably efficient machine learning for quantum many-body problems. Science, 377(6613):eabk3333, 2022. ISSN 0036- 8075. + +80 [20] Zhan Yu, Hongshun Yao, Mujin Li, and Xin Wang. Power and limitations of single-qubit native quantum +381 neural networks. In 36th Conference on Neural Information Processing Systems (NeurIPS 2022), 2022. +382 URL https://arxiv.org/abs/2205.07848. +83 [21] Jarrod R. McClean, Jonathan Romero, Ryan Babbush, and Alán Aspuru-Guzik. The theory of variational +384 hybrid quantum-classical algorithms. New Journal of Physics, 18(2):023023, feb 2016. ISSN 1367- +385 2630. doi: 10.1088/1367-2630/18/2/023023. URL https://iopscience.iop.org/article/10. +386 1088/1367-2630/18/2/023023. +387 [22] M. Cerezo, Andrew Arrasmith, Ryan Babbush, Simon C. Benjamin, Suguru Endo, Keisuke Fujii, Jarrod R. +388 McClean, Kosuke Mitarai, Xiao Yuan, Lukasz Cincio, and Patrick J. Coles. Variational quantum algorithms. +389 Nature Reviews Physics, 3(9):625–644, sep 2021. ISSN 2522-5820. doi: 10.1038/s42254-021-00348-9. +390 URL https://www.nature.com/articles/s42254-021-00348-9. +91 [23] Kishor Bharti, Alba Cervera-Lierta, Thi Ha Kyaw, Tobias Haug, Sumner Alperin-Lea, Abhinav Anand, +392 Matthias Degroote, Hermanni Heimonen, Jakob S Kottmann, Tim Menke, Wai-Keong Mok, Sukin Sim, +393 Leong-Chuan Kwek, and Alán Aspuru-Guzik. Noisy intermediate-scale quantum (NISQ) algorithms. +394 arXiv:2101.08448, pages 1–82, jan 2021. URL http://arxiv.org/abs/2101.08448. +95 [24] Suguru Endo, Zhenyu Cai, Simon C Benjamin, and Xiao Yuan. Hybrid Quantum-Classical Algorithms +396 and Quantum Error Mitigation. Journal of the Physical Society of Japan, 90(3):032001, mar 2021. +397 ISSN 0031-9015. doi: 10.7566/JPSJ.90.032001. URL http://arxiv.org/abs/2011.01382https: +98 //journals.jps.jp/doi/10.7566/JPSJ.90.032001. +99 [25] Jarrod R. McClean, Sergio Boixo, Vadim N. Smelyanskiy, Ryan Babbush, and Hartmut Neven. Barren +400 plateaus in quantum neural network training landscapes. Nature Communications, 9(1):1–7, mar 2018. +401 ISSN 20411723. doi: 10.1038/s41467-018-07090-4. URL http://arxiv.org/abs/1803.11173http: +402 //dx.doi.org/10.1038/s41467-018-07090-4. +03 [26] Andrew Arrasmith, M. Cerezo, Piotr Czarnik, Lukasz Cincio, and Patrick J. Coles. Effect of bar +404 ren plateaus on gradient-free optimization. Quantum, 5:1–9, nov 2020. ISSN 2521327X. doi: +405 10.22331/q-2021-10-05-558. URL http://arxiv.org/abs/2011.12245http://dx.doi.org/10. +406 22331/q-2021-10-05-558. +07 [27] M. Cerezo and Patrick J. Coles. Higher order derivatives of quantum neural networks with barren plateaus. +408 Quantum Science and Technology, 6(3):035006, jul 2021. ISSN 2058-9565. doi: 10.1088/2058-9565/ +409 abf51a. URL https://iopscience.iop.org/article/10.1088/2058-9565/abf51a. +10 [28] Andrew Arrasmith, Zoë Holmes, M. Cerezo, and Patrick J. Coles. Equivalence of quantum barren plateaus +11 to cost concentration and narrow gorges. pages 1–12, apr 2021. URL http://arxiv.org/abs/2104. +12 05868. +13 [29] Samson Wang, Enrico Fontana, M. Cerezo, Kunal Sharma, Akira Sone, Lukasz Cincio, and Patrick J. +14 Coles. Noise-induced barren plateaus in variational quantum algorithms. Nature Communications, 12 +15 (1):6961, dec 2021. ISSN 2041-1723. doi: 10.1038/s41467-021-27045-6. URL https://www.nature. +16 com/articles/s41467-021-27045-6. +17 [30] Zoë Holmes, Kunal Sharma, M. Cerezo, and Patrick J. Coles. Connecting ansatz expressibility to gradient +18 magnitudes and barren plateaus. PRX Quantum, 3(1):1–20, jan 2021. doi: 10.1103/prxquantum.3.010313. +419 URL http://arxiv.org/abs/2101.02138. +20 [31] Lennart Bittel and Martin Kliesch. Training Variational Quantum Algorithms Is NP-Hard. Physical +21 Review Letters, 127(12):120502, sep 2021. ISSN 0031-9007. doi: 10.1103/PhysRevLett.127.120502. +422 URL http://arxiv.org/abs/2101.07267%0Ahttp://dx.doi.org/10.1103/PhysRevLett.127. +23 120502https://link.aps.org/doi/10.1103/PhysRevLett.127.120502. +424 [32] Carlos Ortiz Marrero, Mária Kieferová, and Nathan Wiebe. Entanglement-Induced Barren Plateaus. +425 PRX Quantum, 2(4):040316, oct 2021. ISSN 2691-3399. doi: 10.1103/PRXQuantum.2.040316. URL +426 https://link.aps.org/doi/10.1103/PRXQuantum.2.040316. +427 [33] Daniel Stilck Franca and Raul García-Patrón. Limitations of optimization algorithms on noisy quantum de +28 vices. Nature Physics, 17(11):1221–1227, nov 2021. ISSN 1745-2473. doi: 10.1038/s41567-021-01356-3. +429 URL https://www.nature.com/articles/s41567-021-01356-3. +430 [34] A. V. Uvarov and J. D. Biamonte. On barren plateaus and cost function locality in variational quantum +431 algorithms. Journal of Physics A: Mathematical and Theoretical, 54(24):245301, jun 2021. ISSN 1751- +432 8113. doi: 10.1088/1751-8121/abfac7. URL https://iopscience.iop.org/article/10.1088/ +433 1751-8121/abfac7. + +[35] Ernesto Campos, Aly Nasrallah, and Jacob Biamonte. Abrupt transitions in variational quantum circuit training. Physical Review A, 103(3):032607, mar 2021. ISSN 2469-9926. doi: 10.1103/PhysRevA.103. 032607. URL https://link.aps.org/doi/10.1103/PhysRevA.103.032607. +[36] Giacomo De Palma, Milad Marvian, Cambyse Rouzé, and Daniel Stilck Franca. Limitations of variational quantum algorithms: a quantum optimal transport approach. arXiv:2204.03455, pages 1–30, 2022. URL http://arxiv.org/abs/2204.03455. +[37] Emanuel Knill, Gerardo Ortiz, and Rolando D. Somma. Optimal quantum measurements of expectation values of observables. Phys. Rev. A, 75:012328, Jan 2007. doi: 10.1103/PhysRevA.75.012328. URL https://link.aps.org/doi/10.1103/PhysRevA.75.012328. +[38] Patrick Huembeli and Alexandre Dauphin. Characterizing the loss landscape of variational quantum circuits. Quantum Science and Technology, 6(2):025011, apr 2021. ISSN 2058-9565. doi: 10.1088/2058-9565/abdbc9. URL http://arxiv.org/abs/2008.02785http://dx.doi.org/10. 1088/2058-9565/abdbc9. +[39] Ken M. Nakanishi, Keisuke Fujii, and Synge Todo. Sequential minimal optimization for quantumclassical hybrid algorithms. Physical Review Research, 2(4):1–11, mar 2019. ISSN 26431564. doi: 10. 1103/PhysRevResearch.2.043158. URL http://arxiv.org/abs/1903.12166http://dx.doi.org/ 10.1103/PhysRevResearch.2.043158. +[40] Mateusz Ostaszewski, Edward Grant, and Marcello Benedetti. Structure optimization for parameterized quantum circuits. Quantum, 5:1–13, may 2019. ISSN 2521327X. doi: 10.22331/q-2021-01-28-391. URL http://arxiv.org/abs/1905.09692http://dx.doi.org/10.22331/q-2021-01-28-391. +[41] Edward Grant, Leonard Wossnig, Mateusz Ostaszewski, and Marcello Benedetti. An initialization strategy for addressing barren plateaus in parametrized quantum circuits. Quantum, 3, mar 2019. ISSN 2521327X. doi: 10.22331/q-2019-12-09-214. URL http://arxiv.org/abs/1903.05076http://dx.doi.org/ 10.22331/q-2019-12-09-214. +[42] Guillaume Verdon, Michael Broughton, Jarrod R. McClean, Kevin J. Sung, Ryan Babbush, Zhang Jiang, Hartmut Neven, and Masoud Mohseni. Learning to learn with quantum neural networks via classical neural networks. pages 1–12, jul 2019. URL http://arxiv.org/abs/1907.05415. +[43] Harper R. Grimsley, Sophia E. Economou, Edwin Barnes, and Nicholas J. Mayhall. An adaptive variational algorithm for exact molecular simulations on a quantum computer. Nature Communications, 10(1):3007, dec 2019. ISSN 2041-1723. doi: 10.1038/s41467-019-10988-2. URL http://www.nature.com/ articles/s41467-019-10988-2. +[44] Feng Zhang, Niladri Gomes, Yongxin Yao, Peter P. Orth, and Thomas Iadecola. Adaptive variational quantum eigensolvers for highly excited states. Physical Review B, 104(7):1–10, apr 2021. ISSN 24699969. doi: 10.1103/PhysRevB.104.075159. URL http://arxiv.org/abs/2104.12636http: //dx.doi.org/10.1103/PhysRevB.104.075159. +[45] Andrea Skolik, Jarrod R. McClean, Masoud Mohseni, Patrick van der Smagt, and Martin Leib. Layerwise learning for quantum neural networks. Quantum Machine Intelligence, 3(1):5, jun 2021. ISSN 2524- 4906. doi: 10.1007/s42484-020-00036-4. URL http://arxiv.org/abs/2006.14904https://link. springer.com/10.1007/s42484-020-00036-4. +[46] Harper R. Grimsley, George S. Barron, Edwin Barnes, Sophia E. Economou, and Nicholas J. Mayhall. ADAPT-VQE is insensitive to rough parameter landscapes and barren plateaus. 2022. URL http: //arxiv.org/abs/2204.07179. +[47] Arthur Pesah, M Cerezo, Samson Wang, Tyler Volkoff, Andrew T Sornborger, and Patrick J Coles. Absence of Barren Plateaus in Quantum Convolutional Neural Networks. Physical Review X, 11(4):041011, oct 2021. ISSN 21603308. doi: 10.1103/PhysRevX.11.041011. URL https://doi.org/10.1103/PhysRevX. 11.041011https://link.aps.org/doi/10.1103/PhysRevX.11.041011. +[48] Xia Liu, Geng Liu, Jiaxin Huang, and Xin Wang. Mitigating barren plateaus of variational quantum eigensolvers. may 2022. URL http://arxiv.org/abs/2205.13539. +[49] M. Cerezo, Akira Sone, Tyler Volkoff, Lukasz Cincio, and Patrick J. Coles. Cost function dependent barren plateaus in shallow parametrized quantum circuits. Nature Communications, 12(1):1791, dec 2021. ISSN 2041-1723. doi: 10.1038/s41467-021-21728-w. URL http://arxiv.org/abs/2001.00550http://dx.doi.org/10.1038/s41467-021-21728-whttp: //www.nature.com/articles/s41467-021-21728-w. +[50] Maria Kieferova, Ortiz Marrero Carlos, and Nathan Wiebe. Quantum Generative Training Using Rényi Divergences. jun 2021. URL http://arxiv.org/abs/2106.09567. +[51] Shi-Ju Ran. Encoding of matrix product states into quantum circuits of one-and two-qubit gates. Physical Review A, 101(3):032310, 2020. +[52] Iris Cong, Soonwon Choi, and Mikhail D Lukin. Quantum convolutional neural networks. Nature Physics, 15(12):1273–1278, 2019. +[53] Christoph Dankert, Richard Cleve, Joseph Emerson, and Etera Livine. Exact and approximate unitary 2- designs and their application to fidelity estimation. Physical Review A, 80(1):012304, jul 2009. ISSN 1050- 2947. doi: 10.1103/PhysRevA.80.012304. URL https://link.aps.org/doi/10.1103/PhysRevA. 80.012304. +[54] Gian Giacomo Guerreschi and Mikhail Smelyanskiy. Practical optimization for hybrid quantum-classical algorithms. jan 2017. URL http://arxiv.org/abs/1701.01450. +[55] Kosuke Mitarai, Makoto Negoro, Masahiro Kitagawa, and Keisuke Fujii. Quantum Circuit Learning. mar 2018. doi: 10.1103/PhysRevA.98.032309. URL http://arxiv.org/abs/1803.00745http: //dx.doi.org/10.1103/PhysRevA.98.032309. +[56] Maria Schuld, Ville Bergholm, Christian Gogolin, Josh Izaac, and Nathan Killoran. Evaluating analytic gradients on quantum hardware. Physical Review A, 99(3):032331, nov 2018. ISSN 2469- 9926. doi: 10.1103/PhysRevA.99.032331. URL https://link.aps.org/doi/10.1103/PhysRevA. 99.032331http://arxiv.org/abs/1811.11184. +[57] Gavin E. Crooks. Gradients of parameterized quantum gates using the parameter-shift rule and gate decomposition. (2), may 2019. URL http://arxiv.org/abs/1905.13311. +[58] Andrea Mari, Thomas R. Bromley, and Nathan Killoran. Estimating the gradient and higher-order derivatives on quantum hardware. Physical Review A, 103(1):012405, jan 2021. ISSN 2469-9926. doi: 10. 1103/PhysRevA.103.012405. URL https://link.aps.org/doi/10.1103/PhysRevA.103.012405. +[59] Artem Kaznatcheev. Unitary t-designs. Talk, 53(1):13–31, 2009. ISSN 0925-1022. URL http://www. springerlink.com/index/10.1007/s10623-009-9290-2. +[60] Alberto Peruzzo, Jarrod McClean, Peter Shadbolt, Man-Hong Yung, Xiao-Qi Zhou, Peter J. Love, Alán Aspuru-Guzik, and Jeremy L. O’Brien. A variational eigenvalue solver on a photonic quantum processor. Nature Communications, 5(1):4213, sep 2014. ISSN 2041-1723. doi: 10.1038/ncomms5213. URL http://www.nature.com/articles/ncomms5213. +[61] Abhinav Kandala, Antonio Mezzacapo, Kristan Temme, Maika Takita, Markus Brink, Jerry M. Chow, and Jay M. Gambetta. Hardware-efficient variational quantum eigensolver for small molecules and quantum magnets. Nature, 549(7671):242–246, sep 2017. ISSN 0028-0836. doi: 10.1038/nature23879. URL http://arxiv.org/abs/1704.05018http://www.nature.com/articles/nature23879. +[62] Aram W. Harrow, Avinatan Hassidim, and Seth Lloyd. Quantum Algorithm for Linear Systems of Equations. Physical Review Letters, 103(15):150502, oct 2009. ISSN 0031-9007. doi: 10.1103/PhysRevLett.103. 150502. URL https://link.aps.org/doi/10.1103/PhysRevLett.103.150502. +[63] Fernando G. S. L. Brandão, Aram W. Harrow, and Michał Horodecki. Local Random Quantum Circuits are Approximate Polynomial-Designs. Communications in Mathematical Physics, 346(2):397–434, sep 2016. ISSN 0010-3616. doi: 10.1007/s00220-016-2706-8. URL http://link.springer.com/10. 1007/s00220-016-2706-8. +[64] Jonathan Romero, Jonathan P. Olson, and Alan Aspuru-Guzik. Quantum autoencoders for efficient compression of quantum data. Quantum Science and Technology, 2(4):1–10, 2017. ISSN 20589565. doi: 10.1088/2058-9565/aa8072. +[65] Chenfeng Cao and Xin Wang. Noise-Assisted Quantum Autoencoder. Physical Review Applied, 15(5): 054012, may 2021. ISSN 2331-7019. doi: 10.1103/PhysRevApplied.15.054012. URL http://arxiv. org/abs/2012.08331https://link.aps.org/doi/10.1103/PhysRevApplied.15.054012. +[66] Sang Min Lee, Jinhyoung Lee, and Jeongho Bang. Learning unknown pure quantum states. Physical Review A, 98(5):052302, nov 2018. ISSN 2469-9926. doi: 10.1103/PhysRevA.98.052302. URL https: //link.aps.org/doi/10.1103/PhysRevA.98.052302. +[67] Tomonori Shirakawa, Hiroshi Ueda, and Seiji Yunoki. Automatic quantum circuit encoding of a given arbitrary quantum state. pages 1–25, dec 2021. URL http://arxiv.org/abs/2112.14524. \ No newline at end of file diff --git a/md/dev/r-6Z1SJbCpv/r-6Z1SJbCpv.md b/md/dev/r-6Z1SJbCpv/r-6Z1SJbCpv.md new file mode 100644 index 0000000000000000000000000000000000000000..d9b248bdb84f798c861220454b8c766e3629968b --- /dev/null +++ b/md/dev/r-6Z1SJbCpv/r-6Z1SJbCpv.md @@ -0,0 +1,364 @@ +# Towards Learning Universal Hyperparameter Optimizers with Transformers + +Yutian Chen1, Xingyou Song2, Chansoo $\mathbf { L e e ^ { 2 } }$ , Zi Wang2, Qiuyi Zhang2, David Dohan2, Kazuya Kawakami1, Greg Kochanski2, +Arnaud Doucet1, Marc’aurelio Ranzato1, Sagi Perel2, Nando de Freitas1 1Deepmind, 2Google Research, Brain Team + +# Abstract + +Meta-learning hyperparameter optimization (HPO) algorithms from prior experiments is a promising approach to improve optimization efficiency over objective functions from a similar distribution. However, existing methods are restricted to learning from experiments sharing the same set of hyperparameters. In this paper, we introduce the OPTFORMER, the first text-based Transformer HPO framework that provides a universal end-to-end interface for jointly learning policy and function prediction when trained on vast tuning data from the wild, such as Google’s Vizier database, one of the world’s largest HPO datasets. Our extensive experiments demonstrate that the OPTFORMER can simultaneously imitate at least 7 different HPO algorithms, which can be further improved via its function uncertainty estimates. Compared to a Gaussian Process, the OPTFORMER also learns a robust prior distribution for hyperparameter response functions, and can thereby provide more accurate and better calibrated predictions. This work paves the path to future extensions for training a Transformer-based model as a general HPO optimizer. + +# 1 Introduction + +The emergence of public machine learning data platforms such as OpenML [1] and hyperparameter optimization (HPO) services such as Google Vizier [2], Amazon SageMaker [3] and Microsoft Azure [4] have made large-scale datasets containing hyperparameter evaluations accessible. For our use-case in this paper, Google Vizier is the de-facto HPO service across Google, having optimized some of Google’s largest products and research efforts, and contains a collection of valuable tuning data within the last 5 years. While there is growing interest in leveraging such data to meta-learn hyperparameter optimization algorithms [5–8], dealing with large datasets consisting of experimental trials in the wild can be challenging, due to large variations in HPO problems and their associated text metadata (e.g. shown later in Table 1). + +Thus, most meta and transfer-learning HPO methods [7–16] consider a restrictive setting where all tasks must share the same set of hyperparameters so that the input data can be represented as fixed-sized vectors. Consequently, such methods only exploit a small portion of the available data to learn priors. This drawback is more severe for large datasets which contain significant amounts of useful information. + +To overcome these limitations, we introduce the OPTFORMER, a general hyperparameter optimization framework based on Transformers [17]. Transformers have demonstrated excellent performance in many data tasks, ranging from natural language [18], images [19, 20], biological data [21, 22], code [23, 24], and control [25, 26]. Here, we investigate how to use a Transformer as a universal interface for modelling experimental data and learn HPO algorithms, as given a sufficient amount of data, a Transformer can potentially learn a more complex prior distribution than standard Bayesian Optimization (BO) with Gaussian Processes (GPs), especially as the Transformer possesses certain computational advantages over GPs for large datasets. + +![](images/e8ea90285925418f9e37b2efa844f3b1dfc81b1651ddcc2faba210549481c7fa.jpg) +Figure 1: Illustration of the OPTFORMER model over a hyperparameter optimization trajectory. It is trained to predict both hyperparameter suggestions (in green) and response function values (in red). + +We introduce a serialization scheme to convert a combination of any metadata and an optimization trajectory into text, represented as a sequence of tokens, and formulate the HPO task as a sequence modeling problem. We adopt a supervised learning approach, by learning to predict parameters and hyperparameter response functions from offline tuning data (See Fig. 1). In order to further improve optimization performance, we augment the model by utilizing its own function prediction during inference (Section 4.3). Extensive experiments on both public and private datasets demonstrate the OPTFORMER’s competitive tuning and generalization abilities. + +In summary, our contributions are as follows: + +• We formulate, to the best of our knowledge, the first meta-learning HPO framework to learn both policy and function priors from data across different search spaces. +• The OPTFORMER is capable of learning the behaviors of 7 diverse blackbox optimization algorithms relying on a broad class of methods (non-adaptive, evolutionary, and Bayesian). +• Furthermore, the OPTFORMER learns the prior over objective functions and provides both accurate and well calibrated predictions, in many cases significantly surpassing GPs in log-predictive likelihood and expected calibration error (ECE) [27]. +• Lastly, OPTFORMER policies augmented with model-based optimization, such as the use of Expected Improvement acquisition functions, are competitive HPO algorithms. To the best of our knowledge, this is the first time Transformers are augmented with acquisition functions for online adaptation. + +# 2 Preliminaries + +# 2.1 Meta-learning for hyperparameter optimization + +HPO aims to find a set of hyperparameters $_ { \textbf { \em x } }$ from search space $\mathcal { X }$ to maximize a model performance metric, $y = f ( { \pmb x } )$ , often referred to as a response function. Table 1 shows an example of HPO experimental data. Following the HPO nomenclature [2, 28], an experimental study consists of metadata $( m )$ and a history of trials $( h )$ . The metadata contains arbitrary unstructured information, including but not limited to descriptions of the problem, optimization algorithm, names, types and value ranges of hyperparameters. The history after $t$ trials, $\pmb { h } _ { t } = \left( \pmb { x } _ { 1 } , y _ { 1 } , \dots , \pmb { x } _ { t } , y _ { t } \right)$ , contains a sequence of trials, each of which consists of a parameter suggestion $_ { \textbf { \em x } }$ and function value $y$ . + +The goal of the meta-learning approach for HPO is to learn the shared knowledge among the objective functions $f$ from a dataset of multiple tuning experiments represented as studies and to obtain an optimal HPO algorithm for new hyperparameter tuning tasks from a similar distribution to those in the dataset. + +An HPO algorithm $\pi$ maps the metadata and history to a distribution over hyperparameter suggestions, i.e. $\pi ( \boldsymbol { x } _ { t + 1 } | m , h _ { t } )$ . Using the terminology of offline RL [29], we refer to the algorithm used to generate the trajectories in a dataset as the behavior policy $\pi _ { b }$ . + +We primarily consider search spaces $\mathcal { X }$ with a fixed number $D$ of hyperparameters per task, and hence $\pmb { x } = \mathsf { \bar { \Phi } } ( x ^ { ( 1 ) } , \dots , x ^ { ( D ) } )$ , with each hyperparameter $x ^ { ( d ) }$ being of type DOUBLE, INTEGER, DISCRETE, or CATEGORICAL (see Appendix A.1 for details). More complex search spaces can be supported as discussed in Section 7. + +# 2.2 Transformer model + +The Transformer model is an efficient attention-based neural network architecture for sequence modeling [17]. We adopt the T5 Transformer encoder-decoder architecture [30]. The encoder and decoder each consist of a stack of multi-head selfattention layers which construct pairwise interactions between positions, followed by position-wise feed-forward networks. The encoder converts a sequence of input token representations $m$ , to a sequence of continuous embeddings, which is fed to the decoder to generate a sequence of output tokens $h$ one element at a time (see Fig. 1). + +# 3 Related work + +There has been a rich set of works in meta-learning and transfer learning by modifying specific core components of the BO pipeline, such as the acquisition function or the GP, in order to tackle BO’s myopic behavior, or obtaining more information from similar tasks. For instance, approaches include learning new acquisition functions [31], multi-task BO [7–13] and BO for transfer learning using contextual GPs [14–16]. [32] also studies the use of meta-BO for hyperparameter tuning tasks in machine learning. However, all of these works consider a fixed search space. + +A more radical meta-learning approach to non-differentiable optimization trains recurrent neural networks (RNNs) as neural optimizers from scratch. [33] first proposed training an RNN with gradient descent to optimize blackbox functions and hyperparameters while [34, 35] train RNNs using reinforcement learning (RL) to solve RL tasks. Unfortunately, prior works are limited to fixed search spaces and only use online generated data, constraining the training objectives to be cheaply computable. + +In this work, we wish to overcome the limitations of previous works by exploiting the Transformer architecture. Numerous + +Table 1: Example of a study $( m , h )$ with two parameters and two trials. Metadata $m$ appears in blue and history $^ { h }$ in purple. + +"name": "convnet on cifar10", +"metric": "accuracy", +"goal": "MAXIMIZE", +"algorithm": "random_search", +"parameter": { +"name": "opt_kw.lr", +"type": "DOUBLE", +"min_value": 1e-6, +"max_value": 1e-2, +"scale_type": "LOG" +} +"parameter": { +"name": "opt_type", +"type": "CATEGORICAL", +"categories": ["SGD", "Adam"], +} +"trial" { +"parameter": { +"opt_kw.lr": 0.0021237573, +"opt_type": "SGD" +} +"metric": { +"accuracy": 0.69482429, +}} +"trial" { +"parameter": { +"opt_kw.lr": 0.00038292234, +"opt_type": "Adam" +"metric": { +"accuracy": 0.71642583 +}} + +works have demonstrated Transformers’ strong capabilities in flexible symbolic and numerical manipulation. On the symbolic side, Transformers have been shown able to manipulate symbolic mathematical expressions [36–38] and generate code [23, 24]. Furthermore, on the numerical side, Transformers have also been shown able to perform linear algebra computations [39], Bayesian Inference [40], and offline RL [25, 26, 41]. For AutoML specifically, [42] has demonstrated Transformers’ and analogous graph neural networks’ abilities to use dataset descriptions and metadata to generate classification and data preprocessing pipelines. However, to date, there has been little effort in attacking the full problem of hyperparameter tuning in the blackbox optimization setting. In this paper, the challenging task of learning algorithms from blackbox optimization trajectories can be seen as a significant extension of both symbolic and numerical manipulation. Since the underlying algorithm can be composed of multiple symbolic and mathematical operations with unbounded complexity, the model must infer potentially very complex behavior over long horizons. + +# 4 Universal interface and model for hyperparameter optimization + +In this section, we provide a universal interface for modeling HPO studies with mixed textual and numerical information as a sequence of discrete tokens. We train our OPTFORMER as a generative + +Table 2: Serialized study after preprocessing and tokenization. Metadata m appears in blue, normalized and quantized values of $\mathbf { \Delta } _ { \mathbf { \mathcal { X } } _ { t } }$ in green, and $y _ { t }$ in red. + +
After preprocessing<name>:"convnet on cifar10",<metric>:"accuracy",<goal>:<MAXIMIZE>, <algorithm>:"random_search" &<name>:"opt_kw.Ir",<type>:<DOUBLE>,<min_value>:1e-6,<max_value>:1e-2, <scale_type>:<LOG> &<name>:"opt_type",<type>:<CATEGORICAL>,<categories>:["SGD","Adam"] <831><0>* <0>—<645><1>* <999>
Subwords after tokenizationname:"conv net on ci far10 ",metric:" acc u racy goal : MAXIMIZE,algorithm: " random_search " & name : " op t_kw .Ir ",type : DOUBLE,min_value : 1e -6, max_value : 1e -2,scale_type : LOG & name : " opt_type ",type : CATEGORICAL, categories : [ " SG D ", " A dam "] 8310*0l 645 1 999
+ +model on a given dataset and explain how to use the OPTFORMER’s parameter and function prediction abilities to implement an HPO policy. + +# 4.1 Study tokenization + +To generalize over HPO problems of different parameter sizes, types, and metadata, we propose to serialize the study as a one-dimensional textual sequence, also advocated in [26]. Unfortunately, a naive serialization approach, e.g. via JSON [43], will produce unnecessarily long sequences. + +To improve scalability, we compress the textual representation of metadata $m$ by removing redundant phrases and punctuation (e.g., "parameter", quotes) and encoding keywords (e.g., "name", "algorithm") and enumerating types (e.g. "DOUBLE") into single tokens. + +For the historical sequence $^ { h }$ , we convert every DOUBLE and INTEGER parameter along with every function value into a single token, by normalizing and discretizing them into integers, with an quantization level of $Q = 1 0 0 0$ ; e.g. + +$$ +\bar { x } = \operatorname* { i n t } [ x _ { \mathrm { n o r m } } \cdot Q ] , \mathrm { w h e r e } x _ { \mathrm { n o r m } } = ( x - x _ { \mathrm { m i n } } ) / ( x _ { \mathrm { m a x } } - x _ { \mathrm { m i n } } ) . +$$ + +The range of $x$ is defined by the search space and the range of $y$ is obtained from observed values in $^ { h }$ . For other types, we use the index in their value set. + +The shortened text string is then converted to a sequence of tokens via the SentencePiece tokenizer [44] (see Table 2 for an example). Every trial is represented by text, which is represented as a sequence of normalized and quantized tokens, $\left[ \bar { x } _ { t } ^ { ( 1 ) } , \ldots , \bar { x } _ { t } ^ { ( D ) } , \star , \bar { y } _ { t } , \ " | " \right]$ , where the token $\star$ separates parameter and function values and "|" separates trials. See Appendix A.2 for further details on tokenization. + +# 4.2 Model and training loss + +After tokenization, the converted historical sequence is as follows: + +$$ +\bar { h } _ { t } = \left[ \bar { x } _ { 1 } ^ { ( 1 ) } , \bar { x } _ { 1 } ^ { ( 2 ) } , \ldots , \bar { x } _ { 1 } ^ { ( D ) } , \star , \bar { y } _ { 1 } , " | " , \ldots , \bar { x } _ { t } ^ { ( 1 ) } , \bar { x } _ { t } ^ { ( 2 ) } , \ldots , \bar { x } _ { t } ^ { ( D ) } , \star , \bar { y } _ { t } \right] . +$$ + +We can now apply a Transformer model to learn the conditional distribution of tokens in $\bar { h }$ using the chain rule, given the metadata $\bar { m }$ , as depicted in Fig. 1. The joint distribution is presented in Appendix D.1. + +Given a dataset $\mathcal { D }$ of hyperparameter optimization studies, we train the OPTFORMER by maximizing the weighted log-likelihood for each study $( m , h ) \sim \mathcal { D }$ : + +$$ +\begin{array} { r } { \mathcal { L } ( \boldsymbol { \theta } ; m , h ) = \sum _ { n } w _ { n } \log P _ { \boldsymbol { \theta } } \big ( \bar { h } ^ { ( n ) } | \bar { m } , \bar { h } ^ { ( 1 : n - 1 ) } \big ) , } \end{array} +$$ + +with $w _ { n } = 0$ if $\bar { h } ^ { ( n ) } \in \{ \star , " | " \}$ and $w _ { n } = 1$ otherwise. That is, we mask out the separator tokens $( \star ,$ "|") and predict parameter $\bar { \mathbf { x } }$ and function tokens $\bar { y }$ only. Note that $\bar { h } ^ { ( n ) }$ denotes the $n$ -th token, that is the $n$ -th element of the list in Equation (2), and $\bar { h } ^ { ( 1 : n - 1 ) }$ denotes all tokens up to the $( n - 1 )$ -th token. Further details and data augmentations are provided in Appendix D.2. + +# 4.3 Inference and decoding + +Parameter prediction: To decode the predicted parameter token $\bar { x } _ { t } ^ { ( d ) }$ back to its original parameter range, we truncate the output distribution to the vocabulary range corresponding to valid parameter values $[ 0 , Q )$ and reverse our tokenization procedure in Section 4.1. For a DOUBLE or INTEGER parameter $x$ , we use a piecewise constant distribution: + +$$ +p _ { \theta } ( x | \ldots ) = Q \cdot P _ { \theta } ( \bar { x } | \ldots ) / ( x _ { \mathrm { m a x } } - x _ { \mathrm { m i n } } ) , \mathrm { ~ i f ~ } x \in [ x _ { \mathrm { m i n } } , x _ { \mathrm { m a x } } ] , \mathrm { ~ o t h e r w i s e ~ } 0 . +$$ + +For all other parameter types, $\bar { x }$ corresponds to the index of the set of feasible values. Putting these together, we may now sample parameter $\mathbf { \Delta } _ { \mathbf { \mathcal { X } } _ { t } }$ from the model’s prior distribution and thus define an HPO policy: + +$$ +\pi _ { \mathrm { p r i o r } } ( \pmb { x } _ { t } | m , \pmb { h } _ { t - 1 } ) = \prod _ { d = 1 } ^ { D } p _ { \theta } ( x _ { t } ^ { ( d ) } | m , \pmb { h } _ { t - 1 } , x _ { t } ^ { ( 1 : d - 1 ) } ) . +$$ + +As we use a supervised learning loss, we expect $\pi _ { \mathrm { p r i o r } }$ to approximate the behavior policy $\pi _ { b }$ + +Note that traditional BO algorithms require running Bayesian inference and then conducting a global search in the hyperparameter space with an acquisition function. Thus the runtime complexity of making one hyperparameter suggestion is cubic in $t$ for a typical GP-based BO method that performs ARD each iteration [45]. In contrast, generating one suggestion by the OPTFORMER consists of decoding $D$ parameter tokens with an input sequence of $( D + 3 ) t$ tokens, which are then parsed into the $D$ parameter values, producing a runtime of $\mathcal { O } ( D ^ { 2 } t )$ linear in $t$ , with proper caching. + +Function prediction: To decode the real-valued function $y _ { t }$ from the discrete distribution $P _ { \theta } ( \bar { y } _ { t } | \bar { m } , \bar { h } _ { t - 1 } , \bar { x } _ { t } )$ , we construct the same piecewise constant distribution as in Eq. (4) with the range $[ y _ { \mathrm { m i n } } , y _ { \mathrm { m a x } } ]$ used in tokenization. Note that the limited support of $y$ will not be a concern for HPO when either the range is known or we set the range large enough compared to observed values. For more general use as a few-shot function prediction model, one could consider adopting the Riemann Distribution in [40], which supports an unbounded range. + +Augmented HPO policies with function prediction: At best, the learned policy $\pi _ { \mathrm { p r i o r } }$ can only perform as well as the original policy $\pi _ { b }$ when using behavioral cloning. However, we can take advantage of the model’s simultaneous function prediction ability to improve the policy with modelbased planning or offline RL techniques. While a comprehensive study of policy improvements for Transformers is out of the scope of this work, we consider here a simple yet effective policy improvement operator: sampling $M = 1 0 0$ candidate suggestions from $\pi _ { \mathrm { p r i o r } }$ and choosing the suggestion with the highest score defined by an acquisition function $u ( \cdot )$ as follows: + +$$ +\pi _ { u } ( \pmb { x } _ { t } | m , \pmb { h } _ { t - 1 } ) = \operatorname * { a r g m a x } _ { \{ \pmb { x } ^ { ( i ) } \} _ { i = 1 } ^ { M } } u ( p _ { \theta } ( \cdot | m , \pmb { h } _ { t - 1 } , \pmb { x } ^ { ( i ) } ) ) , \ \mathrm { w i t h } \ \pmb { x } ^ { ( i ) } \overset { \mathrm { i . i . d . } } { \sim } \pi _ { \mathrm { p r i o r } } ( \pmb { x } | m , \pmb { h } _ { t - 1 } ) . +$$ + +Common acquisition functions include Expected Improvement (EI), Probability of Improvement (PI), Upper Confidence Bound (UCB), and Thompson Sampling, see for example [46]. At a high level, this approach to combining imitated policies with function prediction is reminiscent of the idea behind the offline RL approach of BCQ [47]. + +Because we apply a linear mapping from the original $y$ value to the quantized value $\bar { y }$ before discretization, we can simply define the acquisition functions on the discrete distribution $P _ { \theta } \big ( \bar { y } | \bar { m } , \bar { h } _ { t - 1 } , \bar { x } _ { t } \big )$ as follows: + +$$ +\begin{array} { r l } & { \displaystyle \boldsymbol { u } _ { \mathrm { E I } } ( \boldsymbol { x } | \bar { \boldsymbol { y } } ^ { * } ) = \mathbb { E } _ { P _ { \boldsymbol { \theta } } ( \bar { \boldsymbol { y } } | \boldsymbol { m } , \boldsymbol { h } _ { t - 1 } , \boldsymbol { x } ) } \left[ \operatorname* { m a x } ( \bar { \boldsymbol { y } } - \bar { \boldsymbol { y } } ^ { * } , 0 ) \right] , } \\ & { \displaystyle \boldsymbol { u } _ { \mathrm { U C B } } ( \boldsymbol { x } | \alpha ) = \mathrm { Q u a n t i l e } ( P _ { \boldsymbol { \theta } } ( \bar { \boldsymbol { y } } | \boldsymbol { m } , \boldsymbol { h } _ { t - 1 } , \boldsymbol { x } _ { t } ) , \alpha ) , } \\ & { \displaystyle \boldsymbol { u } _ { \mathrm { P I } } ( \boldsymbol { x } | \bar { \boldsymbol { y } } ^ { * } ) = \sum _ { \bar { \boldsymbol { y } } > \bar { \boldsymbol { y } } ^ { * } } P _ { \boldsymbol { \theta } } ( \bar { \boldsymbol { y } } | \boldsymbol { m } , \boldsymbol { h } _ { t - 1 } , \boldsymbol { x } ) , } \\ & { \displaystyle \boldsymbol { u } _ { \mathrm { T S } } ( \boldsymbol { x } ) = \bar { \boldsymbol { y } } , \mathrm { ~ w i t h ~ } \bar { \boldsymbol { y } } \sim P _ { \boldsymbol { \theta } } ( \bar { \boldsymbol { y } } | \boldsymbol { m } , \boldsymbol { h } _ { t - 1 } , \boldsymbol { x } _ { t } ) , } \end{array} +$$ + +where $\bar { y } ^ { * } = \operatorname* { m a x } _ { \tau \leq t - 1 } \bar { y } _ { \tau }$ in EI and PI is the threshold to measure improvement. We define the UCB acquisition function with a quantile parameter $\alpha$ . Our TS acquisition is defined as a sampled function value at a given location from the marginal predictive distribution. It is inspired by the traditional Thompson Sampling method [45] but different in that the correlation between different locations is ignored. + +# 5 Data + +Training the OPTFORMER requires HPO studies with optimization trajectories. The most natural dataset we possess is the entire Google Vizier [2] database, one of the world’s largest collections of real world hyperparameter tuning studies, which we denote as RealWorldData. There are around 750K studies, each with on average 300 trials, covering a vast class of production and machine learning applications at Google, ranging from vision, speech, NLP and robotics, and representing one of the most representative distributions of HPO tasks for machine learning models in practice. These studies were generated with a mixture of non-adaptive, evolutionary, and BO algorithms. However, as the dataset does not contain sufficient algorithm information, we have to treat the corresponding behavior policy as a randomly mixed algorithm $\pi _ { b }$ . + +In addition, we create two new datasets based on public benchmarks. HPO-B is the largest public benchmark for HPO containing about 1.9K tuning tasks, most of which use one of 16 shared search spaces. In the continuous evaluation setting, it fits an XGBoost model to the trial data of every tuning task as the objective function. For further control over specific function dimensions and properties, we use the blackbox optimization benchmark BBOB [48], consisting of 24 types of synthetic functions with customizable properties (dimension sizes, rotations, shifts, discretizations, noise types) we randomize over. + +For each of the two public benchmarks (HPO-B and BBOB), we apply a fixed set of 7 HPO algorithms to generate a dataset of optimization trajectories. In contrast to RealWorldData, we specify the algorithm name in the metadata $m$ as part of the conditioning input for our model. The controlled algorithms used are: (1) Grid Search, (2) Shuffled Grid Search, (3) Random Search, (4) Regularized Evolution [49], (5) Hill-Climbing, (6) Eagle Strategy [50], and (7) Vizier’s GP-UCB [2]. Appendix B contains detailed explanations of the algorithms. + +Table 3: Offline training datasets considered in this study. More details are given in Appendix C along with examples of studies in Table 5. + +
("R")RealWorldData("H") HPO-B("B") BBOB
#Studies750K10M10M
#Trials / study300 (on average)120300
Study sourceGoogle's databaseGeneratedGenerated
TbMixedControlledControlled
Obj. FunctionsHPO tasksHPO tasksSynthetic
Search spaceDifferent per task16 shared search spacesRandomized
+ +# 6 Experiments + +We train a single Transformer model with $2 5 0 \mathbf { M }$ parameters on the union of the three datasets described above, RealWorldData, HPO-B, and BBOB (hyperparameter details in Appendix D.2). + +Each dataset contains a corresponding “test” set of functions, either using synthetic functions (BBOB) or fitting a machine learning model to obtain the objective (RealWorldData, HPO-B). We evaluate mainly on the two natural HPO benchmarks, RealWorldData and HPO-B. The train/test subsets of RealWorldData are split temporally to avoid information leak (see Appendix C for details). + +To aggregate results across functions with different output scaling, we normalize all the test functions. This is standard practice in the literature [2, 5, 51–54]. We define our performance metric at trial $t$ as the best-so-far normalized function value $\mathrm { m a x } _ { i \in \{ 1 : t \} } ( y _ { i } - y _ { \mathrm { r a n d } } ) / ( y _ { \mathrm { m a x } } - y _ { \mathrm { r a n d } } )$ , where $y _ { \mathrm { r a n d } }$ is the median of function values randomly sampled in the search space to be robust to outliers, and $y _ { \mathrm { m a x } }$ is the maximum, if known, or best value found by any algorithm. For the HPO-B benchmark, we use the recommended bounds provided in [5]. We also consider other metrics when comparing different algorithms in Appendix E.3, including the performance profile and average ranking. We find our results are consistent over different metrics. + +Because the OPTFORMER is trained to predict the conditional distributions of parameter and function values, we would like to answer the following questions when evaluating on unseen test problems: + +![](images/6dcd288e845b9bae387825df425c014cf9a6cedf91d173fc4fe72d63e2e9a35a.jpg) +Figure 2: Comparing the performance of different algorithms outputted by the OPTFORMER conditioned on the corresponding algorithm’s name. + +1. Can the OPTFORMER learn to imitate multiple HPO algorithms with one model? (Section 6.1) +2. Can the OPTFORMER learn a good prior over hyperparameter response functions? (Section 6.2) +3. Is the OPTFORMER a competitive approach for HPO? (Section 6.3) + +# 6.1 Imitating HPO policies + +We first evaluate how well the OPTFORMER can learn the conditional distribution of parameter suggestions given by the behavior policies in the dataset, and how well it can imitate multiple algorithms. As the algorithm’s name is contained in the metadata $m$ , we can modify the behaviour of the policy $\pi _ { \mathrm { p r i o r } } ( \pmb { x } _ { t + 1 } | m , \pmb { h } _ { t } )$ simply by altering this variable. Fig. 2a compares two different policies to the OPTFORMER, when it is conditioned on the corresponding policy name. We observe a good match between the imitated algorithms and the OPTFORMER (additional algorithms are shown in Appendix E.1). + +In Fig. 2b we run target policies on the BBOB dataset’s test functions and compare the optimization trajectories of the algorithms and the OPTFORMER. In Fig. 2c we compare the average and standard deviation of the best normalized function values at trial 100. Our model imitates most algorithms very accurately in both the mean and variance except for the most complicated algorithm, Vizier, where $\pi _ { \mathrm { p r i o r } }$ is slightly worse in the LUNACEK benchmark. We expand on this in Appendix E.1. Because Vizier is the best performing HPO algorithm among all considered, the OPTFORMER will imitate Vizier faithfully, although not perfectly, in the following experiments. + +# 6.2 Learning priors for hyperparameter response functions + +In this section, we assess the OPTFORMER’s ability to learn the conditional distribution of the function value as a few-shot function regressor. Specifically, for every function in each test dataset, we repeatedly sample up to 200 random trials $( \pmb { x } _ { 1 } , y _ { 1 } , . . . \pmb { x } _ { t } , y _ { t } ) , t \leq 2 0 0$ , and predict the conditional distribution $p ( y _ { t } | \mathbf { x } _ { 1 } , y _ { 1 } , \ldots , \mathbf { x } _ { t } )$ . We compare with a GP model with output warping — details provided in Appendix B. We report the log-predictive likelihood $\log p ( y _ { t } | x _ { t } , \dots )$ in Table 4. + +As uncertainty estimation is important for HPO, we also evaluate how well the function predictive distribution is calibrated. When a predictive distribution $p _ { \theta } ( y | \ldots )$ matches the true distribution, the estimated CDF $\begin{array} { r } { F ( y ) = \int _ { - \infty } ^ { y } p _ { \theta } ( y ^ { \prime } | \dots ) d y ^ { \prime } } \end{array}$ will be uniformly distributed. In Fig. 3, we plot the cumulative histogram of $F ( y )$ on RealWorldData test set and check the deviation from the diagonal line to assess goodness-of-fit as proposed by Rosenblatt [55]. The OPTFORMER has a smaller deviation than the GP almost across the entire range. We also compare calibration performance using the expected calibration error (ECE) [27]. Readers are referred to [27] and Appendix E.2 for a detailed explanation of ECE. We observe from Table 4 that the OPTFORMER achieves better predictive likelihood and ECE than the GP on both datasets. + +Table 4: Log-predictive likelihood (with 1-std. standard error, higher is better (↑)) and ECE (percentage of error, lower is better (↓)) on RealWorldData and HPO-B test sets. + +
ModelLog-predictive likelihood ↑
GPRealWorldData 0.83(0.06)HPO-B 4.03(0.04)
OPTFORMER2.12 (0.05)6.16 (0.04)
ECE (percent %)↓
ModelRealWorldDataHPO-B
GP5.34 (0.06)2.39 (0.05)
OPTFORMER1.11 (0.02)1.89 (0.01)
+ +![](images/52e7e04ae218c6a2dd9369ce129998fa44e2bf2d00dd8f29db93df4206940bca.jpg) +Figure 3: Cumulative histogram of predicted $\mathrm { C D F ( y ) }$ on RealWorldData test set. + +![](images/51d070f76a9929370bf60b13c7caf5d2da457a9030fd56e1bf91dba2a36679ad.jpg) +Figure 4: Higher is better. Best normalized function value averaged over 16 RealWorldData test functions (left) and over 86 HPO-B test functions (right) with 1-std confidence interval from 5 runs. $\mathrm { G P ^ { * } }$ and $\mathrm { D G P ^ { * } }$ results are provided by [5]. The transfer learning methods ABLR, FSBO and HyperBO cannot be applied to RealWorldData. + +# 6.3 Augmenting a prior policy with function prediction + +We evaluate the OPTFORMER as a hyperparameter optimization algorithm on two benchmarks, RealWorldData and HPO-B. We compare our prior policy, the OPTFORMER, and an augmented policy with Expected Improvement, the OPTFORMER (EI), against standard HPO baselines, including Random Search, our implementation of GP-UCB, and the well-tuned Vizier service. For HPO-B, we also include the GP (not to be confused with our GP-UCB) and DGP (GP with deep kernel) baseline results provided by the original paper [5]. Additionally, we include three recent transferlearning methods based on multi-task GP models: ABLR [12, 56], FSBO [7], and HyperBO [57, 58] (implementation details in Appendix B). Please note that all of these transfer learning methods require learning GPs on multiple tasks sharing the same search space. Therefore, none of them apply to the RealWorldData benchmark where every study has its own search space. + +We show the trajectory of the best normalized function value averaged over all functions from each benchmark in Fig. 4. While the prior policy returned by the OPTFORMER does not perform as well as Vizier, it is comparable or slightly better than our GP-UCB baseline and ABLR. + +![](images/b8cb265a9f55b69cc9c378d5b1bd3b36872a31bde283b892e6cdd50618434395.jpg) +Figure 5: Best normalized function values averaged over HPO-B test functions with 1-std confidence interval. Ablation curves are shown with $\bigcirc$ markers. (a) The more similar the training dataset, the better the transfer. Here, the suffix with $" \mathrm { H " }$ , "R", "B" indicates training on HPO-B, RealWorldData, and BBOB respectively. (b) Removing the majority of metadata hurts function prediction. (c) The prior policy improves performance with or without the Expected Improvement acquisition function. (d) All acquisition functions provide a significant improvement. + +The most significant improvement is achieved when we augment our prior policy with the Expected Improvement acquisition function. The resulting OPTFORMER (EI) outperforms all baselines across the board on both benchmarks. This illustrates that the OPTFORMER is able to learn the distribution of functions in the meta-training split and transfers to the meta-testing split. + +It is worth noting that to run 100 trials for about half of the test functions, the required history token sequence is longer than the 1024-token length used in training, with the maximum length about twice the training horizon. The superior performance of the OPTFORMER (EI) thus demonstrates its good generalization performance beyond the optimization horizon it is trained for. + +# 6.4 Ablations + +We provide further ablations on three important components for our policy: + +Training dataset. To understand the impact of the training datasets on the OPTFORMER, we train three variants on individual datasets (OPTFORMER-"R","H","B" respectively for RealWorldData, HPO-B, BBOB) and study their transfer learning performances on HPO-B. Fig. 5a verifies that training with in-domain data ("H") gives better performance than training over the more diverse across-domain RealWorldData HPO dataset ("R"), which is better than training over the synthetic BBOB data ("B"). Nonetheless, training on RealWorldData is enough to give comparable performance to the best transfer learning baseline at the end of 100 trials. Lastly, training on all of the datasets (OPTFORMER) gives a further advantage over OPTFORMER-H. This suggests that more data does not hurt the model’s performance but rather may improve it, even if the extra data is out-of-domain. + +Meta-data $m$ . We have demonstrated how the OPTFORMER’s behavior can be controlled by the algorithm name in metadata $m$ in Section 6.1. Here we study whether the OPTFORMER learns to depend on other meta information. At inference time, we provide minimum information in $m$ (OPTFORMER-min) by excluding all textual information and parameter value ranges. We only keep necessary information such as parameter types and algorithm names. Fig. 5b shows that the prior policy of OPTFORMER-min performs comparably with the OPTFORMER, partly due to the use of data augmentation (see Appendix D.2). The augmented policy OPTFORMER-min (EI) (dashed orange) improves upon the prior policy but is significantly worse than the full model, suggesting that the missing metadata impacts the model’s predictions on function values. + +Prior policy. Section 6.3 demonstrated the benefit of adding an acquisition function to the prior policy. A natural question is whether a good prior policy is needed at all. In Fig. 5c, we replace the prior policy in the OPTFORMER (EI) with random search (Random Search (EI), dashed blue line). While adding Expected Improvement still improves this random search policy’s performance, the best method requires both a good prior policy and the acquisition function. + +Choice of acquisition function. In Fig. 5d, we compare the Expected Improvement (EI) with Thompson Sampling (TS), Probability of Improvement (PI), and Upper Confidence Bound (UCB) with a confidence level of 0.9. We observe that the prior policy is improved by all the acquisition functions. Particularly, OPTFORMER (EI) is the best among all the choices though the difference is relatively small compared to the advantage over other baselines and OPTFORMER prior policy. We provide additional analysis with results on both the RealWorldData and HPO-B datasets, as well as other evaluation metrics in Appendix E.4. + +# 7 Limitations and future extensions + +We list a few limitations of this work and discuss some potential extensions. (1) We did not consider parameters that do not always apply or are subject to dynamic constraints depending on other parameter values. Such parameters are common in AutoML [59] and NAS applications [60]. Our work can be extended to support these applications, by providing the conditional specifications as text in metadata $m$ . (2) We also considered only sequential optimization with a batch size of 1. To support parallel suggestions, one could apply random masking to input function value observations to simulate scenarios with parallel pending trials [33]. (3) While we trained the Transformer to clone the behavior policy offline, there are extensive literature on offline RL [29] that could be applied here [25, 47, 61–64]. One could also consider meta-training acquisition functions as in [31] within the same model and online fine-tuning as in [7, 41]. (4) We considered a single objective function, though multiple objectives can be easily included by outputting multiple function tokens in a trial. (5) The maximum sequence length is limited by the quadratic memory size requirement of a Transformer, which could be mitigated with more scalable architecture variants such as Performer [65]. + +# 8 Conclusion + +We presented first step to learning a universal Transformer model for hyperparameter optimization from large scale datasets containing tuning experiments with vastly different search spaces and experiment descriptions. By training on a diverse set of synthetic and real-world tuning trajectories, we demonstrated the capacity of a single Transformer model to imitate 7 fundamentally different HPO policies, learn to make well calibrated few-shot function predictions, and provide competitive optimization performance on unseen test functions comparable with the existing, long-tried GP-based baselines. Many extensions are readily conceivable for future exploration. + +# Acknowledgments + +We would like to thank Chris Dyer, Luke Metz, Kevin Murphy, Yannis Assael, and Esteban Real for providing valuable feedback during their reviews of this paper. We further thank Sebastian Pineda Arango for technical discussions on the HPO-B benchmark and Christof Angermueller on biological benchmarks. In addition, we thank Daniel Golovin, Daiyi Peng, Yingjie Miao, Jack Parker-Holder, Jie Tan, Lucio Dery, and Aleksandra Faust for multiple useful conversations. + +References +[1] Joaquin Vanschoren, Jan N Van Rijn, Bernd Bischl, and Luis Torgo. OpenML: Networked science in machine learning. ACM SIGKDD Explorations Newsletter, 15(2):49–60, 2014. +[2] Daniel Golovin, Benjamin Solnik, Subhodeep Moitra, Greg Kochanski, John Karro, and D. Sculley. Google Vizier: A service for black-box optimization. In ACM SIGKDD International Conference on Knowledge Discovery and Data Mining, pages 1487–1495, 2017. +[3] Valerio Perrone, Huibin Shen, Aida Zolic, Iaroslav Shcherbatyi, Amr Ahmed, Tanya Bansal, Michele Donini, Fela Winkelmolen, Rodolphe Jenatton, Jean Baptiste Faddoul, Barbara Pogorzelska, Miroslav Miladinovic, Krishnaram Kenthapadi, Matthias W. Seeger, and Cédric Archambeau. Amazon SageMaker automatic model tuning: Scalable black-box optimization. CoRR, abs/2012.08489, 2020. +[4] Deepak Mukunthu, Parashar Shah, and Wee Hyong Tok. Practical Automated Machine Learning on Azure: Using Azure Machine Learning to Quickly Build AI Solutions. O’Reilly Media, 2019. +[5] Sebastian Pineda-Arango, Hadi S. Jomaa, Martin Wistuba, and Josif Grabocka. HPO-B: A largescale reproducible benchmark for black-box HPO based on openml. CoRR, abs/2106.06257, 2021. +[6] Hyunghun Cho, Yongjin Kim, Eunjung Lee, Daeyoung Choi, Yongjae Lee, and Wonjong Rhee. Basic enhancement strategies when using bayesian optimization for hyperparameter tuning of deep neural networks. IEEE Access, 8:52588–52608, 2020. +[7] Martin Wistuba and Josif Grabocka. Few-shot Bayesian optimization with deep kernel surrogates. In International Conference on Learning Representations, 2021. +[8] Matthias Feurer, Benjamin Letham, and Eytan Bakshy. Scalable meta-learning for Bayesian optimization using ranking-weighted Gaussian process ensembles. In AutoML Workshop at ICML, volume 7, 2018. +[9] Kevin Swersky, Jasper Snoek, and Ryan P Adams. Multi-task Bayesian optimization. In Advances in Neural Information Processing Systems, 2013. +[10] Dani Yogatama and Gideon Mann. Efficient transfer learning method for automatic hyperparameter tuning. In Artificial Intelligence and Statistics, 2014. +[11] Matthias Poloczek, Jialei Wang, and Peter Frazier. Multi-information source optimization. In Advances in Neural Information Processing Systems, 2017. +[12] Valerio Perrone, Rodolphe Jenatton, Matthias Seeger, and Cédric Archambeau. Scalable hyperparameter transfer learning. In Advances in Neural Information Processing Systems, pages 6846–6856, 2018. +[13] Jonas Rothfuss, Vincent Fortuin, Martin Josifoski, and Andreas Krause. PACOH: Bayes-optimal meta-learning with PAC-guarantees. In International Conference on Machine Learning, pages 9116–9126. PMLR, 2021. +[14] Andreas Krause and Cheng S Ong. Contextual Gaussian process bandit optimization. In Advances in Neural Information Processing Systems, 2011. +[15] Rémi Bardenet, Mátyás Brendel, Balázs Kégl, and Michele Sebag. Collaborative hyperparameter tuning. In International Conference on Machine Learning, 2013. +[16] Matthias Poloczek, Jialei Wang, and Peter I Frazier. Warm starting Bayesian optimization. In Winter Simulation Conference (WSC). IEEE, 2016. +[17] 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, pages 5998–6008, 2017. +[18] 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, Association for Computational Linguistics, pages 4171–4186, 2019. +[19] 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. OpenReview.net, 2021. +[20] Mark Chen, Alec Radford, Rewon Child, Jeffrey Wu, Heewoo Jun, David Luan, and Ilya Sutskever. Generative pretraining from pixels. In International Conference on Machine Learning, volume 119, pages 1691–1703. +[21] Alexander Rives, Joshua Meier, Tom Sercu, Siddharth Goyal, Zeming Lin, Jason Liu, Demi Guo, Myle Ott, C. Lawrence Zitnick, Jerry Ma, and Rob Fergus. Biological structure and function emerge from scaling unsupervised learning to 250 million protein sequences. Proceedings of the National Academy of Sciences, 118(15):e2016239118, 2021. +[22] Ananthan Nambiar, Maeve Heflin, Simon Liu, Sergei Maslov, Mark Hopkins, and Anna Ritz. Transforming the language of life: Transformer neural networks for protein prediction tasks. Association for Computing Machinery, 2020. +[23] Yujia Li, David H. 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. CoRR, abs/2203.07814, 2022. +[24] 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. +[25] 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. In Marc’Aurelio Ranzato, Alina Beygelzimer, Yann N. Dauphin, Percy Liang, and Jennifer Wortman Vaughan, editors, Advances in Neural Information Processing Systems, pages 15084–15097, 2021. +[26] Scott Reed, Konrad Zolna, Emilio Parisotto, Sergio Gomez Colmenarejo, Alexander Novikov, Gabriel Barth-Maron, Mai Gimenez, Yury Sulsky, Jackie Kay, Jost Tobias Springenberg, Tom Eccles, Jake Bruce, Ali Razavi, Ashley Edwards, Nicolas Heess, Yutian Chen, Raia Hadsell, Oriol Vinyals, Mahyar Bordbar, and Nando de Freitas. A generalist agent. arXiv preprint arXiv:2205.06175, 2022. +[27] Mahdi Pakdaman Naeini, Gregory Cooper, and Milos Hauskrecht. Obtaining well calibrated probabilities using Bayesian binning. In AAAI Conference on Artificial Intelligence, 2015. +[28] Richard Liaw, Eric Liang, Robert Nishihara, Philipp Moritz, Joseph E. Gonzalez, and Ion Stoica. Tune: A research platform for distributed model selection and training. CoRR, abs/1807.05118, 2018. +[29] Sergey Levine, Aviral Kumar, George Tucker, and Justin Fu. Offline reinforcement learning: Tutorial, review, and perspectives on open problems. CoRR, abs/2005.01643, 2020. +[30] 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. +[31] Michael Volpp, Lukas P. Fröhlich, Kirsten Fischer, Andreas Doerr, Stefan Falkner, Frank Hutter, and Christian Daniel. Meta-learning acquisition functions for transfer learning in Bayesian optimization. In International Conference on Learning Representations. OpenReview.net, 2020. +[32] Matthias Feurer, Jost Springenberg, and Frank Hutter. Initializing Bayesian hyperparameter optimization via meta-learning. In AAAI Conference on Artificial Intelligence, 2015. +[33] Yutian Chen, Matthew W Hoffman, Sergio Gómez Colmenarejo, Misha Denil, Timothy P Lillicrap, Matt Botvinick, and Nando Freitas. Learning to learn without gradient descent by gradient descent. In International Conference on Machine Learning, pages 748–756. PMLR, 2017. +[34] Yan Duan, John Schulman, Xi Chen, Peter L. Bartlett, Ilya Sutskever, and Pieter Abbeel. $\mathrm { R } 1 \$ 23$ : Fast reinforcement learning via slow reinforcement learning. CoRR, abs/1611.02779, 2016. +[35] Jane X. Wang, Zeb Kurth-Nelson, Hubert Soyer, Joel Z. Leibo, Dhruva Tirumala, Rémi Munos, Charles Blundell, Dharshan Kumaran, and Matt M. Botvinick. Learning to reinforcement learn. In CogSci, 2017. +[36] Mojtaba Valipour, Bowen You, Maysum Panju, and Ali Ghodsi. SymbolicGPT: A generative transformer model for symbolic regression. CoRR, abs/2106.14131, 2021. +[37] Guillaume Lample and François Charton. Deep learning for symbolic mathematics. In International Conference on Learning Representations. OpenReview.net, 2020. +[38] Vishesh Agarwal, Somak Aditya, and Navin Goyal. Analyzing the nuances of transformers’ polynomial simplification abilities. 1st Mathematical Reasoning in General Artificial Intelligence Workshop at ICLR, 2021. +[39] François Charton. Linear algebra with transformers. CoRR, abs/2112.01898, 2021. +[40] Samuel Müller, Noah Hollmann, Sebastian Pineda-Arango, Josif Grabocka, and Frank Hutter. Transformers can do Bayesian inference. 2022. +[41] Qinqing Zheng, Amy Zhang, and Aditya Grover. Online decision transformer. arXiv preprint arXiv:2202.05607, 2022. +[42] Nikhil Singh, Brandon Kates, Jeff Mentch, Anant Kharkar, Madeleine Udell, and Iddo Drori. Privileged zero-shot automl. CoRR, abs/2106.13743, 2021. +[43] Pierre Bourhis, Juan L Reutter, Fernando Suárez, and Domagoj Vrgoc. Json: data model, query ˇ languages and schema specification. In Proceedings of the 36th ACM SIGMOD-SIGACT-SIGAI symposium on principles of database systems, pages 123–135, 2017. +[44] 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: System Demonstrations, pages 66–71, 2018. +[45] Roman Garnett. Bayesian Optimization. Cambridge University Press, 2022. +[46] Bobak Shahriari, Kevin Swersky, Ziyu Wang, Ryan P Adams, and Nando De Freitas. Taking the human out of the loop: A review of Bayesian optimization. Proceedings of the IEEE, 104 (1):148–175, 2015. +[47] Scott Fujimoto, David Meger, and Doina Precup. Off-policy deep reinforcement learning without exploration. In International Conference on Machine Learning, pages 2052–2062. PMLR, 2019. +[48] Ouassim Ait ElHara, Konstantinos Varelas, Duc Manh Nguyen, Tea Tusar, Dimo Brockhoff, Nikolaus Hansen, and Anne Auger. COCO: The large scale black-box optimization benchmarking (bbob-largescale) test suite. ArXiv, abs/1903.06396, 2019. +[49] Esteban Real, Alok Aggarwal, Yanping Huang, and Quoc V Le. Regularized evolution for image classifier architecture search. In Proceedings of the aaai conference on artificial intelligence, volume 33, pages 4780–4789, 2019. +[50] Xin-She Yang and Suash Deb. Eagle strategy using Lévy walk and firefly algorithms for stochastic optimization. In Nature inspired cooperative strategies for optimization (NICSO 2010), pages 101–111. Springer, 2010. +[51] Ryan Turner, David Eriksson, Michael McCourt, Juha Kiili, Eero Laaksonen, Zhen Xu, and Isabelle Guyon. Bayesian optimization is superior to random search for machine learning hyperparameter tuning: Analysis of the black-box optimization challenge 2020. In NeurIPS 2020 Competition and Demonstration Track, pages 3–26, 2021. +[52] Alexander I Cowen-Rivers, Wenlong Lyu, Rasul Tutunov, Zhi Wang, Antoine Grosnit, Ryan Rhys Griffiths, Alexandre Max Maraval, Hao Jianye, Jun Wang, Jan Peters, et al. Hebo: Pushing the limits of sample-efficient hyper-parameter optimisation. Journal of Artificial Intelligence Research, 74:1269–1349, 2022. +[53] Luke Metz, Niru Maheswaranathan, Ruoxi Sun, C Daniel Freeman, Ben Poole, and Jascha Sohl-Dickstein. Taskset: A dataset of optimization tasks. 2020. +[54] Mikhail Evchenko, Joaquin Vanschoren, Holger H Hoos, Marc Schoenauer, and Michèle Sebag. Frugal machine learning. arXiv preprint arXiv:2111.03731, 2021. +[55] Murray Rosenblatt. Remarks on a multivariate transformation. The Annals of Mathematical Statistics, 23(3):470 – 472, 1952. +[56] Christopher M Bishop and Nasser M Nasrabadi. Pattern recognition and machine learning, volume 4. Springer, 2006. +[57] Zi Wang, Beomjoon Kim, and Leslie Pack Kaelbling. Regret bounds for meta Bayesian optimization with an unknown gaussian process prior. In Advances in Neural Information Processing Systems, 2018. +[58] Zi Wang, George E Dahl, Kevin Swersky, Chansoo Lee, Zelda Mariet, Zachary Nado, Justin Gilmer, Jasper Snoek, and Zoubin Ghahramani. Pre-trained Gaussian processes for Bayesian optimization. arXiv preprint arXiv:2109.08215, 2022. +[59] James Bergstra, Dan Yamins, David D Cox, et al. Hyperopt: A python library for optimizing the hyperparameters of machine learning algorithms. In Proceedings of the 12th Python in science conference, volume 13, page 20, 2013. +[60] Daiyi Peng, Xuanyi Dong, Esteban Real, Mingxing Tan, Yifeng Lu, Gabriel Bender, Hanxiao Liu, Adam Kraft, Chen Liang, and Quoc Le. PyGlove: Symbolic programming for automated machine learning. Advances in Neural Information Processing Systems, 33:96–108, 2020. +[61] Aviral Kumar, Aurick Zhou, George Tucker, and Sergey Levine. Conservative Q-learning for offline reinforcement 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. +[62] Caglar Gulcehre, Sergio Gómez Colmenarejo, Ziyu Wang, Jakub Sygnowski, Thomas Paine, Konrad Zolna, Yutian Chen, Matthew Hoffman, Razvan Pascanu, and Nando de Freitas. Regularized behavior value estimation. arXiv preprint arXiv:2103.09575, 2021. +[63] Jürgen Schmidhuber. Reinforcement learning upside down: Don’t predict rewards - just map them to actions. CoRR, abs/1912.02875, 2019. +[64] Julian Schrittwieser, Thomas Hubert, Amol Mandhane, Mohammadamin Barekatain, Ioannis Antonoglou, and David Silver. Online and offline reinforcement learning by planning with a learned model. Advances in Neural Information Processing Systems, 34, 2021. +[65] Krzysztof Choromanski, Valerii Likhosherstov, David Dohan, Xingyou Song, Andreea Gane, Tamas Sarlos, Peter Hawkins, Jared Davis, Afroz Mohiuddin, Lukasz Kaiser, et al. Rethinking attention with performers. arXiv preprint arXiv:2009.14794, 2020. +[66] Daniel Golovin, John Karro, Greg Kochanski, Chansoo Lee, Xingyou Song, and Qiuyi (Richard) Zhang. Gradientless descent: High-dimensional zeroth-order optimization. In International Conference on Learning Representations. OpenReview.net, 2020. +[67] James Kennedy and Russell Eberhart. Particle swarm optimization. In ICNN’95 international conference on neural networks, volume 4, pages 1942–1948, 1995. +[68] Alexander I Cowen-Rivers, Wenlong Lyu, Rasul Tutunov, Zhi Wang, Antoine Grosnit, Ryan Rhys Griffiths, Alexandre Max Maraval, Hao Jianye, Jun Wang, Jan Peters, et al. An empirical study of assumptions in Bayesian optimisation. arXiv preprint arXiv:2012.03826, 2020. +[69] Elizabeth D Dolan and Jorge J Moré. Benchmarking optimization software with performance profiles. Mathematical Programming, 91(2):201–213, 2002. +[70] Xuanyi Dong and Yi Yang. Nas-bench-201: Extending the scope of reproducible neural architecture search. 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=HJxyZkBKDr. + +# Checklist + +1. For all authors... + +(a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes] Abstract and introduction point out the specific contributions in bullet points, which we have covered throughout or methodology and experiments. +(b) Did you describe the limitations of your work? [Yes] See Section 7. +(c) Did you discuss any potential negative societal impacts of your work? [Yes] The main potential negative societal impacts of our work come from the inherent associated risks of using large Transformer models, such as bias. However, currently this does not apply to our work, as our data only contains numerical optimization data, and we are not using language models as of yet. Such a risk may grow however, if in future works, we e.g. use pretrained language models for warm-starting in our OPTFORMER framework. +(d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes] The most relevant potential ethics concern is our use of RealWorldData. However, as we mention in Appendix C, we anonymized the data to prevent users from being identified in the model. + +2. If you are including theoretical results... + +(a) Did you state the full set of assumptions of all theoretical results? [N/A] Not applicable; no theoretical results. +(b) Did you include complete proofs of all theoretical results? [N/A] Not applicable; no theoretical results. + +3. If you ran experiments... + +(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 link to the primary T5x codebase in Appendix D.2, along with relevant hyperparameters. But we do not include the training data. The datasets generated on public benchmarks, BBOB and HPO-B, can be reproduced by running publicly available HPO algorithms. +(b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes] These are specified in Appendix A, Appendix C, and Appendix D.2. +(c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [Yes] In experiments, we plotted error bars using 1 standard deviation over 5 runs. +(d) Did you include the total amount of compute and the type of resources used (e.g., type of GPUs, internal cluster, or cloud provider)? [Yes] See Appendix D.2. + +If you are using existing assets (e.g., code, data, models) or curating/releasing new assets... + +(a) If your work uses existing assets, did you cite the creators? [Yes] We have cited [48] for our use of BBOB dataset, [5] for the HPO-B dataset, and [30] for training T5 models. +(b) Did you mention the license of the assets? [Yes] For data, we mentioned the use of Apache 2.0 License when using the HPO-B dataset. +(c) Did you include any new assets either in the supplemental material or as a URL? [Yes] We cited and linked the $\mathrm { T } 5 \mathrm { x }$ codebase (see Appendix D.2) throughout this paper. We +(d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [Yes] The BBOB dataset is synthetic, and the HPO-B dataset is public. For the RealWorldData dataset, users by default are agreeing to the condition that their tuning data may be used for research purposes. We have also ensured anonymity over the data by removing personally identifiable information. +(e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [Yes] As discussed in Appendix C, we anonymized user details from studies in the RealWorldData dataset. + +5. If you used crowdsourcing or conducted research with human subjects... + +(a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A] Not applicable. + +(b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A] Not applicable. +(c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A] Not applicable. \ No newline at end of file diff --git a/md/dev/sMezXGG5So/sMezXGG5So.md b/md/dev/sMezXGG5So/sMezXGG5So.md new file mode 100644 index 0000000000000000000000000000000000000000..e1963146c750d98c8d143db54a46e4322bdc220e --- /dev/null +++ b/md/dev/sMezXGG5So/sMezXGG5So.md @@ -0,0 +1,348 @@ +# NodeFormer: A Scalable Graph Structure Learning Transformer for Node Classification + +Qitian $\mathbf { W } \mathbf { u } ^ { 1 }$ , Wentao Zhao1, Zenan $\mathbf { L i } ^ { 1 }$ , David Wipf2, Junchi $\mathbf { Y a n } ^ { 1 * }$ 1Department of Computer Science and Engineering, Shanghai Jiao Tong University 2Amazon Web Service, Shanghai AI Lab {echo740,permanent,emiyali,yanjunchi}@sjtu.edu.cn, davidwipf@gmail.com + +# Abstract + +Graph neural networks have been extensively studied for learning with interconnected data. Despite this, recent evidence has revealed GNNs’ deficiencies related to over-squashing, heterophily, handling long-range dependencies, edge incompleteness and particularly, the absence of graphs altogether. While a plausible solution is to learn new adaptive topology for message passing, issues concerning quadratic complexity hinder simultaneous guarantees for scalability and precision in large networks. In this paper, we introduce a novel all-pair message passing scheme for efficiently propagating node signals between arbitrary nodes, as an important building block for a pioneering Transformer-style network for node classification on large graphs, dubbed as NODEFORMER. Specifically, the efficient computation is enabled by a kernerlized Gumbel-Softmax operator that reduces the algorithmic complexity to linearity w.r.t. node numbers for learning latent graph structures from large, potentially fully-connected graphs in a differentiable manner. We also provide accompanying theory as justification for our design. Extensive experiments demonstrate the promising efficacy of the method in various tasks including node classification on graphs (with up to 2M nodes) and graph-enhanced applications (e.g., image classification) where input graphs are missing. The codes are available at https://github.com/qitianwu/NodeFormer. + +# 1 Introduction + +Relational structure inter-connecting instance nodes as a graph is ubiquitous from social domains (e.g., citation networks) to natural science (protein-protein interaction), where graph neural networks (GNNs) [32, 19, 14, 36] have shown promising power for leveraging such data dependence as geometric priors. However, there arises increasing evidence challenging the core GNN hypothesis that propagating information along observed graph structures will necessarily produce better nodelevel representations for prediction on each individual instance node. Conflicts with this premise lead to commonly identified deficiencies with GNN message-passing rules w.r.t. heterophily [53], over-squashing [2], long-range dependencies $\textcircled { 8 } \textcircled { 1 8 }$ , and graph incompleteness $\mathbb { m }$ , etc. + +Moreover, in graph-enhanced applications, e.g., text classification $\boxed { \boxplus 6 }$ , vision navigation $\pmb { \mathbb { I } } \pmb { \mathcal { 2 } } \Vert$ , physics simulation $\bar { \| 3 0 \| }$ , etc., graph structures are often unavailable though individual instances are strongly inter-correlated. A common practice is to artificially construct a graph via some predefined rules (e.g., $k$ -NN), which is agnostic to downstream tasks and may presumably cause the misspecification of GNNs’ inductive bias on input geometry (induced by the local feature propagation design). + +Natural solutions resort to organically combining learning optimal graph topology with message passing. However, one critical difficulty is the scalability issue with $\mathsf { \bar { O } } ( N ^ { \hat { 2 } } )$ (where $N$ denotes #nodes) computational complexity, which is prohibitive for large networks (with $1 0 K \sim 1 M$ nodes). Some existing approaches harness neighbor sampling $\mathbb { B } 1 \mathbb { I }$ , anchor-based adjacency surrogates [4] and hashing schemes $\mathbb { \lVert \rVert 3 \rVert }$ to reduce the overhead; however, these strategies may sacrifice model precision and still struggle to handle graphs with million-level nodes. Another obstacle lies in the increased degrees of freedom due to at least an $N \times N$ all-pair similarity matrix, which may result in large combinatorial search space and vulnerability to over-fitting. + +In this work, we introduce a novel all-pair message passing scheme that can scale to large systems without compromising performance. We develop a kernelized Gumbel-Softmax operator that seamlessly synthesizes random feature map $\mathbb { \oplus 7 }$ and approximated sampling strategy $\bar { \lVert 1 6 rVert }$ , for distilling latent structures among all the instance nodes and yielding moderate gradients through differentiable optimization. Though such a combination of two operations involving randomness could potentially result in mutual distortion, we theoretically prove that the new operator can still guarantee a wellposed approximation for concrete variables (discrete structures) with the error bounded by feature dimensions. Furthermore, such a design can reduce the algorithmic complexity of learning new topology per layer to $O ( N )$ by avoiding explicit computation for the cumbersome all-pair similarity. + +The proposed module opens the door to a new class of graph networks, i.e., NODEFORMER (Scalable Transformers for Node Classification), that is capable of efficiently propagating messages between arbitrary node pairs in flexible layer-specific latent graphs. And to accommodate input graphs (if any), we devise two simple techniques: a relational bias and an edge-level regularization loss, as guidance for properly learning adaptive structures. We evaluate our approach on diverse node classification tasks ranging from citation networks to images/texts. The results show its promising power for tackling heterophily, long-range dependencies, large-scale graphs, graph incompleteness and the absence of input graphs. The contributions of this paper are summarized as follows: + +• We develop a kernelized Gumbel-Softmax operator which is proven to serve as a well-posed approximation for concrete variables, particularly the discrete latent structure among data points. The new module can reduce the algorithmic complexity for learning new message-passing topology from quadratic to linear w.r.t. node numbers, without sacrificing the precision. This serves as a pioneering model that successfully scales graph structure learning to large graphs with million-level nodes. + +• We further propose NODEFORMER, a new class of graph networks with layer-wise message passing as operated over latent graphs potentially connecting all nodes. The latter are optimized in an end-to-end differentiable fashion through a new objective that essentially pursues sampling optimal topology from a posterior conditioned on node features and labels. To our knowledge, NODEFORMER is the first Transformer model that scales all-pair message passing to large node classification graphs. + +• We demonstrate the model’s efficacy by extensive experiments over a diverse set of datasets, including node classification benchmarks and image/text classification, where significant improvement over strong GNN models and SOTA structure learning methods is shown. Besides, it successfully scales to large graph datasets with up to 2M nodes where prior arts failed, and reduces the time/space consumption of the competitors by up to $9 3 . 1 \% / 8 0 . 6 \%$ on moderate sized datasets. + +# 2 Related Works + +Graph Neural Networks. Building expressive GNNs is a fundamental problem in learning over graph data. With Graph Attention Networks (GAT) $\textcircled { \lvert 3 6 \rvert }$ as an early attempt, there are many follow-up works, e.g., [22, 42], considering weighting the edges in input graph for enhancing the expressiveness. Other studies, e.g., [28, 52] focus on sparsifying input structures to promote robust representations. There are also quite a few approaches that propose scalable GNNs through, e.g., subgraph sampling [48], linear feature mapping $\mathbf { \bar { \rho } } _ { \| 3 9 \| }$ , and channel-wise transformation $\mathbb { \lVert 4 9 \rVert }$ , etc. However, these works cannot learn new edges out of the scope of input geometry, which may limit the model’s receptive fields within local neighbors and neglect global information. + +Graph Structure Learning. Going beyond observed topology, graph structure learning targets learning a new graph for message passing among all the instances $\pmb { \Vert 5 4 \Vert }$ . One line of work is similaritydriven where the confidence of edges are reflected by some similarity functions between node pairs, e.g., Gaussian kernels $\mathbb { \lVert \overline { { 4 3 } } \rVert }$ , cosine similarity $\mathbb { H }$ , attention networks $\mathbb { \ m }$ , non-linear MLP $\bar { \mathbb { Z } }$ etc. Another line of work optimizes the adjacency matrix. Due to the increased optimization difficulties, some sophisticated training methods are introduced, such as bi-level optimization $\mathbb { m }$ , variational approaches [10, 20], Bayesian inference $\mathbb { \left[ \left. 5 1 \right] \right. }$ and projected gradient descent $\mathbb { \lVert \rVert }$ . To push further the limits of structure learning, this paper proposes a new model NODEFORMER (for enabling scalable node-level Transformers) whose merits are highlighted via a high-level comparison in Table $\mathbb { L }$ In particular, NODEFORMER enables efficient structure learning in each layer, does not require input graphs and successfully scales to graphs with 2M nodes. + +Table 1: Comparison of popular graph structure learning approaches for node-level tasks where in particular, the graph connects all instance nodes and one’s target is for prediction on each individual node. For parameterization, ‘Function’ means learning through functional mapping and ‘Adjacency’ means directly optimizing graph adjacency. For expressivty, ‘Fixed’ means learning one graph shared by all propagation layers and ‘Layer-wise’ means learning graph structures per layers. The largest demo means the largest # nodes of datasets used. $\dag { m }$ denotes # anchors (i.e., a subset of nodes). + +
ModelsParameterizationExpressivityInput GraphsInductiveComplexityLargest Demo
LDS-GNN [I1AdjacencyFixedRequiredNoO(N2)0.01M
ProGNN 18AdjacencyFixedRequiredNoO(N2)0.02M
VGCN 目AdjacencyFixedRequiredNoO(N2)0.02M
BGCN 四AdjacencyFixedRequiredNoO(N2)0.02M
GLCN 回FunctionFixedNot necessaryYesO(N2)0.02M
IDGLFunctionFixedRequiredYesO(N2) or O(Nm)t0.1M
NODEFORMER (Ours)FunctionLayer-wiseNot necessaryYesO(N) or O(E)2M
+ +Node-Level v.s. Graph-Level Prediction. We emphasize upfront that our focus is on node-level prediction tasks involving a single large graph such that scalability is paramount, especially if we are to consider arbitrary relationships across all nodes (each node is an instance with label and one can treat all the nodes non-i.i.d. generated due to the inter-dependence) for structure-learning purposes. Critically though, this scenario is quite distinct from graph-level classification tasks whereby each i.i.d. instance is itself a small graph and fully connecting nodes within each graph is computationally inexpensive. While this latter scenario has been explored in the context of graph structure learning $\bar { \big \| } \bar { 3 8 } \bar { \big \| }$ and all-pair message passing design, e.g., graph Transformers $\bigstar \bigstar$ , existing efforts do not scale to the large graphs endemic to node-level prediction. + +# 3 NODEFORMER: A Transformer Graph Network at Scale + +Let $\mathcal { G } = ( \mathcal { N } , \mathcal { E } )$ denote a graph with $\mathcal { N }$ a node set $\langle \mathcal { N } | = N \rangle$ and $\mathcal { E } \subseteq \mathcal { N } \times \mathcal { N }$ an edge set $| \mathcal { E } | = E )$ . Each node $u \in \mathcal N$ is assigned with node features $\mathbf { \bar { x } } _ { u } \in \mathbb { R } ^ { D }$ and a label $y _ { u }$ . We define an adjacency matrix $\mathbf { A } = \{ a _ { u v } \} \in \{ 0 , \mathbf { \bar { 1 } } \} ^ { N \times N }$ where $a _ { u v } = 1$ if edge $( u , v ) \in \mathcal { E }$ and $a _ { u v } = 0$ otherwise. Without loss of generality, $\mathcal { E }$ could be an empty set in case of no input structure. There are two common settings: transductive learning, where testing nodes are within the graph used for training, and inductive learning which handles new unseen nodes out of the training graph. The target is to learn a function for node-level prediction, i.e., estimate labels for unlabeled or new nodes in the graph. + +General Model and Key Challenges. We start with the observation that the input structures may not be the ideal one for propagating signals among nodes and instead there exist certain latent structures that could facilitate learning better node representations. We thus consider the updating rule + +$$ +\tilde { \mathbf { A } } ^ { ( l ) } = g ( \mathbf { A } , \mathbf { Z } ^ { ( l ) } ; \omega ) , \quad \mathbf { Z } ^ { ( l + 1 ) } = h ( \tilde { \mathbf { A } } ^ { ( l ) } , \mathbf { A } , \mathbf { Z } ^ { ( l ) } ; \theta ) , +$$ + +where $\mathbf Z ^ { ( l ) } = \{ \mathbf z _ { u } ^ { ( l ) } \} _ { u \in \mathcal { N } }$ and $\tilde { \mathbf { A } } ^ { ( l ) } = \{ \tilde { a } _ { u v } ^ { ( l ) } \} _ { u , v \in \mathcal { N } }$ denotes the node representations and the estimated latent graph of the $l$ -th layer, respectively, and $g$ , are both differentiable functions aiming at 1) structure estimation for a layer-specific latent graph $\tilde { \mathbf { A } } ^ { ( l ) }$ based on node representations and 2) feature propagation for updating node representations, respectively. The model defined by Eqn. $\bigstar$ follows the spirit of Transformers $\pmb { \Vert 3 5 \Vert }$ (where in particular $\tilde { \mathbf { A } } ^ { ( \bar { l } ) }$ can be seen as an attentive graph) that potentially enables message passing between any node pair in each layer, which, however, poses two challenges: + +• (Scalability): How to reduce the prohibitive quadratic complexity for learning new graphs? + +• (Differentiability): How to enable end-to-end differentiable optimization for discrete structures? + +Notice that the first challenge is non-trivial in node-level prediction tasks (the focus of our paper), since the latent graphs could potentially connect all the instance nodes (e.g., from thousands to millions, depending on dataset sizes), which is fairly hard to guarantee both precision and scalability. + +# 3.1 Efficient Learning Discrete Structures + +We describe our new message-passing scheme with an efficient kernelized Gumbel-Softmax operator to resolve the aforementioned challenges. We assume $\mathbf { z } _ { u } ^ { ( 0 ) } = \mathbf { x } _ { u }$ as the initial node representation. + +Kernelized Message Passing. We define a full-graph attentive network that estimates latent interactions among instance nodes and enables corresponding densely-connected message passing: + +$$ +\tilde { a } _ { u v } ^ { ( l ) } = \frac { \exp ( ( W _ { Q } ^ { ( l ) } \mathbf { z } _ { u } ^ { ( l ) } ) ^ { \top } ( W _ { K } ^ { ( l ) } \mathbf { z } _ { v } ^ { ( l ) } ) ) } { \sum _ { w = 1 } ^ { N } \exp ( ( W _ { Q } ^ { ( l ) } \mathbf { z } _ { u } ^ { ( l ) } ) ^ { \top } ( W _ { K } ^ { ( l ) } \mathbf { z } _ { w } ^ { ( l ) } ) ) } , \quad \mathbf { z } _ { u } ^ { ( l + 1 ) } = \sum _ { v = 1 } ^ { N } \tilde { a } _ { u v } ^ { ( l ) } \cdot ( W _ { V } ^ { ( l ) } \mathbf { z } _ { v } ^ { ( l ) } ) , +$$ + +where $W _ { Q } ^ { ( l ) } , W _ { K } ^ { ( l ) }$ and $W _ { V } ^ { ( l ) }$ are learnable parameters in $l$ -th layer. We omit non-linearity activation (after aggregation) for brevity. The updating for $N$ nodes in one layer using Eqn. 2 requires prohibitive $\mathcal { O } ( N ^ { 2 } )$ complexity. Also, given large $N$ , the normalization in the denominator would shrink attention weights to zero and lead to gradient vanishing. We call this problem as over-normalizing. + +To accelerate the full-graph model, we observe that the dot-then-exponentiate operation in Eqn. 2 can be converted into a pairwise similarity function: + +$$ +\mathbf { z } _ { u } ^ { ( l + 1 ) } = \sum _ { v = 1 } ^ { N } \frac { \kappa ( W _ { Q } ^ { ( l ) } \mathbf { z } _ { u } ^ { ( l ) } , W _ { K } ^ { ( l ) } \mathbf { z } _ { v } ^ { ( l ) } ) } { \sum _ { w = 1 } ^ { N } \kappa ( W _ { Q } ^ { ( l ) } \mathbf { z } _ { u } ^ { ( l ) } , W _ { K } ^ { ( l ) } \mathbf { z } _ { w } ^ { ( l ) } ) } \cdot ( W _ { V } ^ { ( l ) } \mathbf { z } _ { v } ^ { ( l ) } ) , +$$ + +where $\kappa ( \cdot , \cdot ) : \mathbb { R } ^ { d } \times \mathbb { R } ^ { d } \mathbb { R }$ is a positive-definite kernel measuring the pairwise similarity. The kernel function can be further approximated by random features (RF) $\mathbf { \phi } [ \sqrt { 2 7 } ] ^ { }$ which serves as an unbiased estimation via $\kappa ( \mathbf { a } , \mathbf { b } ) = \mathbf { \bar { \Phi } } ( \Phi ( \mathbf { a } ) , \Phi ( \mathbf { b } ) ) \mathbf { \bar { \Phi } } \approx \phi ( \mathbf { a } ) ^ { \top } \phi ( \mathbf { b } )$ , where the first equation is by Mercer’s theorem with $\Phi : \mathbb { R } ^ { d } \mathcal { V }$ a basis function and $\nu$ a high-dimensional vector space, and $\phi ( \cdot ) : \mathbb { R } ^ { d } \to$ $\mathbb { R } ^ { m }$ is a low-dimensional feature map with random transformation. There are many potential choices for $\phi$ , e.g., Positive Random Features (PRF) [6] + +$$ +\phi ( \mathbf x ) = \frac { \exp { ( \frac { - \| \mathbf x \| _ { 2 } ^ { 2 } } { 2 } ) } } { \sqrt { m } } [ \exp ( \mathbf w _ { 1 } ^ { \top } \mathbf x ) , \cdot \cdot \cdot , \exp ( \mathbf w _ { m } ^ { \top } \mathbf x ) ] , +$$ + +where $\mathbf { w } _ { k } \sim \mathcal { N } ( 0 , I _ { d } )$ is i.i.d. sampled random transformation. The RF converts dot-thenexponentiate operation into inner-product in vector space, which enables us to re-write Eqn. $3$ (assuming $\mathbf { q } _ { u } \overset { \cdot } { = } W _ { Q } ^ { ( l ) } \mathbf { z } _ { u } ^ { ( l ) }$ (l)Q z (l)u , ku = W (l)K z (l)u and $\mathbf { v } _ { u } = W _ { V } ^ { \overline { { ( l ) } } } \mathbf { z } _ { u } ^ { ( l ) }$ for simplicity): + +$$ +\mathbf { z } _ { u } ^ { ( l + 1 ) } = \sum _ { v = 1 } ^ { N } \frac { \phi ( \mathbf { q } _ { u } ) ^ { \top } \phi ( \mathbf { k } _ { v } ) } { \sum _ { w = 1 } ^ { N } \phi ( \mathbf { q } _ { u } ) ^ { \top } \phi ( \mathbf { k } _ { w } ) } \cdot \mathbf { v } _ { v } = \frac { \phi ( \mathbf { q } _ { u } ) ^ { \top } \sum _ { v = 1 } ^ { N } \phi ( \mathbf { k } _ { v } ) \cdot \mathbf { v } _ { v } ^ { \top } } { \phi ( \mathbf { q } _ { u } ) ^ { \top } \sum _ { w = 1 } ^ { N } \phi ( \mathbf { k } _ { w } ) } . +$$ + +The key advantage of Eqn. $\boxed { 5 }$ is that the two summations are shared by each $u$ , so that one only needs to compute them once and re-used for others. Such a property enables $\mathcal { O } ( N )$ computational complexity for full-graph message passing, which paves the way for learning graph structures among large-scale instances. Moreover, one can notice that Eqn. $5$ avoids computing the $N \times N$ similarity matrix, i.e., $\{ \tilde { a } _ { u v } ^ { ( l ) } \} _ { N \times N }$ , required by Eqn. $\bigstar$ thus also reducing the learning difficulties. + +Nevertheless, Eqn. $\boxed { 5 }$ still suffers what we mentioned the over-normalizing issue. The crux is that the message passing is operated on a weighted fully-connected graph where, in fact, only partial edges are important. Also, such a deterministic way of feature aggregation over all the instances may increase the risk for over-fitting, especially when $N$ is large. We next resolve the issues by distilling a sparse structure from the fully-connected graph. + +Differentiable Stochastic Structure Learning. The difficultly lies in how to enable differentiable optimization for discrete graph structures. The weight $\tilde { a } _ { u v } ^ { ( l ) }$ given by Eqn. $\boxed { 2 }$ could be used to define a categorical distribution for generating latent edges from distribution $\operatorname { C a t } ( \pi _ { u } ^ { ( l ) } )$ where $\pi _ { u } ^ { ( l ) } =$ {⇡(l)uv}Nv=1 and $\pi _ { u v } ^ { ( l ) } = p ( v | u ) = \tilde { a } _ { u v } ^ { ( l ) }$ . Then in principle, we can sample over the categorical distribution multiple times for each node to obtain its neighbors. However, the sampling process would introduce discontinuity and hinders back-propagation. Fortunately, we notice that the Eqn. $3$ can be modified to incorporate the reparametrization trick $[ \overline { { \lVert { \bf 1 6 } } } ]$ to allow differentiable learning: + +$$ +\mathbf { z } _ { u } ^ { ( l + 1 ) } = \sum _ { v = 1 } ^ { N } \frac { \exp ( ( \mathbf { q } _ { u } ^ { \top } \mathbf { k } _ { v } + g _ { v } ) / \tau ) } { \sum _ { w = 1 } ^ { N } \exp ( ( \mathbf { q } _ { u } ^ { \top } \mathbf { k } _ { w } + g _ { w } ) / \tau ) } \cdot \mathbf { v } _ { v } = \sum _ { v = 1 } ^ { N } \frac { \kappa ( \mathbf { q } _ { u } / \sqrt { \tau } , \mathbf { k } _ { v } / \sqrt { \tau } ) e ^ { g _ { v } / \tau } } { \sum _ { w = 1 } ^ { N } \kappa ( \mathbf { q } _ { u } / \sqrt { \tau } , \mathbf { k } _ { w } / \sqrt { \tau } ) e ^ { g _ { w } / \tau } } \cdot \mathbf { v } _ { v } , +$$ + +where $g _ { u }$ is i.i.d. sampled from Gumbel distribution and $\tau$ is a temperature coefficient. Eqn. $6$ i s a continuous relaxation of sampling one neighbored node for $u$ over $\operatorname { C a t } ( \pi _ { u } ^ { ( l ) } )$ and $\tau$ controls the closeness to hard discrete samples $\mathbb { \left| \left[ 2 3 \right] \right| }$ . Following similar reasoning as Eqn. 3 and $5 ,$ we can yield + +$$ +{ \bf \Psi } _ { u } ^ { ( l + 1 ) } \approx \sum _ { v = 1 } ^ { N } \frac { \phi \big ( { \bf q } _ { u } / \sqrt { \tau } \big ) ^ { \top } \phi \big ( { \bf k } _ { v } / \sqrt { \tau } \big ) e ^ { g _ { v } / \tau } } { \sum _ { w = 1 } ^ { N } \phi \big ( { \bf q } _ { u } / \sqrt { \tau } \big ) ^ { \top } \phi \big ( { \bf k } _ { w } / \sqrt { \tau } \big ) e ^ { g _ { w } / \tau } } \cdot { \bf v } _ { v } = \frac { \phi \big ( { \bf q } _ { u } / \sqrt { \tau } \big ) ^ { \top } \sum _ { w = 1 } ^ { N } e ^ { g _ { v } / \tau } \phi \big ( { \bf k } _ { v } / \sqrt { \tau } \big ) \cdot { \bf v } _ { v } ^ { \top } } { \phi \big ( { \bf q } _ { u } / \sqrt { \tau } \big ) ^ { \top } \sum _ { w = 1 } ^ { N } e ^ { g _ { w } / \tau } \phi \big ( { \bf k } _ { w } / \sqrt { \tau } \big ) } . +$$ + +Eqn. 7 achieves message passing over a sampled latent graph (where we only sample once for each node) and still guarantees linear complexity as Eqn. $\textcircled { 5 }$ In practice, we can sample $K$ times (e.g., $K = 5$ ) for each node and take an average of the aggregated results. Due to space limit, we defer more details concerning the differentiable sampling-based message passing to Appendix $\boxed { \mathrm { A } }$ Besides, in Fig. $5$ and Alg. 1 of Appendix $\mathbf { A } ,$ we present an illustration for node embedding updating in each layer, from a matrix view that is practically used for implementation. + +# 3.2 Well-posedness of the Kernelized Gumbel-Softmax Operator + +One reasonable concern for Eqn. $^ { 7 }$ is whether the RF approximation for kernel functions maintains the well-posedness of Gumbel approximation for the target discrete variables. As a justification for the new message-passing function, we next answer two theoretical questions: 1) How is the approximation capability of RF for the original dot-then-exponentiate operation with Gumbel variables in Eqn. 6? 2) Does Eqn. $\perp$ still guarantee a continuous relaxation of the categorical distributions? We formulate the results as follows and defer proofs to Appendix B. + +Theorem 1 (Approximation Error for Softmax-Kernel). Assume $\Vert \mathbf { q } _ { u } \Vert _ { 2 }$ and $\| \mathbf { k } _ { v } \| _ { 2 }$ are bounded by $r$ , then with probability at least $1 - \epsilon ,$ , the gap $\Delta = \left| \phi ( \mathbf { q } _ { u } / { \sqrt { \tau } } ) ^ { \top } \phi ( \mathbf { k } _ { v } / { \sqrt { \tau } } ) - \kappa ( \mathbf { q } _ { u } / { \sqrt { \tau } } , \mathbf { k } _ { v } / { \sqrt { \tau } } ) \right| )$ , where $\phi$ is defined by Eqn. 4, will be bounded by $\mathcal { O } \left( \sqrt { \frac { \exp ( 6 r / \tau ) } { m \epsilon } } \right)$ + +We can see that the error bound of RF for approximating original softmax-kernel function depends on both the dimension of feature map $\phi$ and temperature $\tau$ . Notably, the error bound is independent of node number $N$ , which implies that the approximation ability is insensitive to dataset sizes. + +The second question is non-trivial since Eqn. $^ { 7 }$ involves randomness of Gumbel variables and random transformation in $\phi$ , which cannot be decoupled apart. We define $\begin{array} { r l } { c _ { u v } } & { { } = } \end{array}$ (qu/ p⌧)>(kv/ p⌧)egv/⌧PNw=1 (qu/ p⌧)>(kw/ p⌧)egw/⌧ as the result from the kernelized Gumbel-Softmax and cu = $\{ c _ { u v } \} _ { v = 1 } ^ { N }$ denotes the sampled edge vector for node $u$ . We can arrive at the result as follows. + +Theorem 2 (Property of Kernelized Gumbel-Softmax Random Variables). Suppose m is sufficiently large, we have the convergence property for the kernelized Gumbel-Softmax operator + +$$ +\operatorname* { l i m } _ { \tau \to 0 } \mathbb { P } ( c _ { u v } > c _ { u v ^ { \prime } } , \forall v ^ { \prime } \neq v ) = \frac { \exp ( \mathbf { q } _ { u } ^ { \top } \mathbf { k } _ { v } ) } { \sum _ { w = 1 } ^ { N } \exp ( \mathbf { q } _ { u } ^ { \top } \mathbf { k } _ { w } ) } , \quad \operatorname* { l i m } _ { \tau \to 0 } \mathbb { P } ( c _ { u v } = 1 ) = \frac { \exp ( \mathbf { q } _ { u } ^ { \top } \mathbf { k } _ { v } ) } { \sum _ { w = 1 } ^ { N } \exp ( \mathbf { q } _ { u } ^ { \top } \mathbf { k } _ { w } ) } . +$$ + +It shows that when i) the dimension of feature map is large enough and ii) the temperature goes to zero, the distribution from which latent structures are sampled would converge to the original categorical distribution. + +Remark. The two theorems imply a trade-off between RF approximation and Gumbel-Softmax approximation w.r.t. the choice of $\tau$ . A large $\tau$ would help to reduce the burden on kernel dimension $m$ , and namely, small $\tau$ would require a very large $m$ to guarantee enough RF approximation precision. On the other hand, if $\tau$ is too large, the weight on each edge will converge to $\textstyle { \frac { \operatorname { i } } { N } }$ , i.e., the model nearly degrades to mean pooling, while a small $\tau$ would endow the kernelized Gumbel-Softmax with better approximation to the categorical distribution. Empirical studies on this are presented in Appendix E. + +# 3.3 Input Structures as Relational Bias + +Eqn. $^ { 7 }$ does not leverage any information from observed geometry which, however, is often recognized important for modeling physically-structured data $\mathbb { \left[ 3 \right] }$ . We therefore accommodate input topology (if any) as relational bias via modifying the attention weight as $\tilde { a } _ { u v } ^ { ( l ) } \tilde { a } _ { u v } ^ { ( l ) } + \mathbb { I } [ a _ { u v } = 1 ] \bar { \sigma } ( b ^ { ( l ) } )$ , + +![](images/5f29b64b737002e61cb5ffa51dcb801876286be754264e6388636c3d4a12175b.jpg) +Figure 1: Illustration for the data flow of NODEFORMER which takes node embedding matrix $\mathbf { X }$ and (optional) graph adjacency matrix A as input. There are three components in NODEFORMER. The first one is the all-pair message passing (MP) module (colored red) which adopts our proposed kernelized Gumbel-Softmax operator to update node embeddings in each layer with $\bar { \mathcal { O } } ( N )$ complexity. The other two components are optional based on the availability of input graphs: 1) relational bias (colored green) that reinforces the propagation weight on observed edges; 2) edge regularization loss (colored blue) that aims to maximize the probability for observed edges. These two components require ${ \mathcal { O } } ( E )$ complexity. The final training loss $\mathcal { L }$ is the weighted sum of the standard supervised classification loss and the edge regularization loss. + +where $b ^ { ( l ) }$ is a learnable scalar as relational bias for any adjacent node pairs $( u , v )$ and $\sigma$ is a certain (bounded) activation function like sigmoid. The relational bias aims at assigning adjacent nodes in $\mathcal { G }$ with proper weights, and the node representations could be accordingly updated by + +$$ +\mathbf { z } _ { u } ^ { ( l + 1 ) } \gets \mathbf { z } _ { u } ^ { ( l + 1 ) } + \sum _ { v , a _ { u v } = 1 } \sigma ( b ^ { ( l ) } ) \cdot \mathbf { v } _ { v } . +$$ + +Eqn. $8$ increases the algorithmic complexity for message passing to $\mathcal { O } ( N + E )$ , albeit within the same order-of-magnitude as common GNNs operating on input graphs. Also, one can consider higher-order adjacency as relational bias for better expressiveness at some expense of efficiency, as similarly done by $\mathbb { I I }$ . We summarize the feed-forward computation of NODEFORMER in Alg. 1. + +# 3.4 Learning Objective + +Given training labels $\mathbf { Y } _ { t r } = \{ y _ { u } \} _ { u \in \mathcal { N } _ { t r } }$ , where $\mathcal { N } _ { t r }$ denotes the set of labeled nodes, the common practice is to maximize the observed data log-likelihood which yields a supervised loss (with $C$ classes) + +$$ +\mathcal { L } _ { s } ( \mathbf { Y } _ { t r } , \hat { \mathbf { Y } } _ { t r } ) = - \frac { 1 } { N _ { t r } } \sum _ { v \in \mathcal { N } _ { t r } } \sum _ { c = 1 } ^ { C } \mathbb { I } [ y _ { u } = c ] \log \hat { y } _ { u , c } , +$$ + +where $\mathbb { I } [ \cdot ]$ is an indicator function. However, it may not suffice to generalize well due to that the graph topology learning increases the degrees of freedom and the number of training labels is not comparable to that. Therefore, we additionally introduce an edge-level regularization: + +$$ +\mathcal { L } _ { e } ( \mathbf { A } , \tilde { \mathbf { A } } ) = - \frac { 1 } { N L } \sum _ { l = 1 } ^ { L } \sum _ { ( u , v ) \in \mathcal { E } } \frac { 1 } { d _ { u } } \log \pi _ { u v } ^ { ( l ) } , +$$ + +where $d _ { u }$ denotes the in-degree of node $u$ and $\pi _ { u v } ^ { ( l ) }$ is the predicted probability for edge $( u , v )$ at the $l$ -th layer. Eqn. $1 0$ is a maximum likelihood estimation for edges in $\mathcal { E }$ , with data distribution defined + +$$ +p _ { 0 } ( v | u ) = \left\{ \begin{array} { l l } { \begin{array} { r l } & { \frac { 1 } { d _ { u } } , \quad a _ { u v } = 1 } \\ & { 0 , \quad o t h e r w i s e . } \end{array} } \end{array} \right. +$$ + +We next show how to efficiently obtain $\pi _ { u v } ^ { ( l ) }$ . Although the feed-forward NODEFORMER computation defined by Eqn. $^ { 7 }$ does not explicitly produce the value for each $\pi _ { u v } ^ { ( l ) }$ , we can query their values by + +$$ +\pi _ { u v } ^ { ( l ) } = \frac { \phi ( W _ { Q } ^ { ( l ) } \mathbf { z } _ { u } ^ { ( l ) } ) ^ { \top } \phi ( W _ { K } ^ { ( l ) } \mathbf { z } _ { v } ^ { ( l ) } ) } { \phi ( W _ { Q } ^ { ( l ) } \mathbf { z } _ { u } ^ { ( l ) } ) ^ { \top } \sum _ { w = 1 } ^ { N } \phi ( W _ { K } ^ { ( l ) } \mathbf { z } _ { w } ^ { ( l ) } ) } , +$$ + +![](images/722c5a9eaa6177bac7da912ec9f6464e81d3556454fe93d9f2fb8e7f803ebff2.jpg) +Table 3: Testing Accuracy and training memory cost on Amazon2M with batch size 100K. + +Table 2: Testing ROC-AUC and training memory cost on OGB-Proteins with batch size 10K. + +
MethodROC-AUC (%)Train Mem
MLP72.04 ± 0.482.0 GB
GCN72.51 ± 0.352.5GB
SGC70.31 ± 0.231.2 GB
GraphSAINT-GCN73.51 ± 1.312.3GB
GraphSAINT-GAT74.63 ± 1.245.2 GB
NODEFORMER77.45 ± 1.153.2 GB
NODEFORMER-dt75.50 ± 0.643.1 GB
NODEFORMER-tp76.18 ± 0.093.2 GB
+ +
MethodAccuracy (%)Train Mem
MLP63.46 ± 0.101.4 GB
GCN83.90 ± 0.105.7GB
SGC GraphSAINT-GCN81.21 ± 0.121.7 GB
GraphSAINT-GAT83.84 ± 0.42 85.17 ± 0.322.1 GB 2.2 GB
NODEFORMER
NODEFORMER-dt87.85 ± 0.24 87.02 ± 0.754.0 GB
2.9 GB
NODEFORMER-tp87.55 ± 0.114.0 GB
+ +where the summation term can be re-used from once computation, as is done by Eqn. $\boxed { 5 }$ and Eqn. $7 .$ Therefore, after once computation for the summation that requires $\mathcal { O } ( N )$ , the computation for each $\pi _ { u v } ^ { ( l ) }$ requires $\mathcal { O } ( 1 )$ complexity, yielding the total complexity controlled within ${ \mathcal { O } } ( E )$ (since we only need to query the observed edges). The final objective can be the combination of two: $\mathcal { L } = \mathcal { L } _ { s } + \lambda \mathcal { L } _ { e }$ , where $\lambda$ controls how much emphasis is put on input topology. We depict the whole data flow of NODEFORMER’s training in Fig. 1. + +# 4 Evaluation + +We consider a diverse set of datasets for experiments and present detailed dataset information in Appendix $\mathbf { D } .$ For implementation, we set $\sigma$ as sigmoid function and $\tau$ as 0.25 for all datasets. The output prediction layer is a one-layer MLP. More implementation details are presented in Appendix C. All experiments are conducted on a NVIDIA V100 with 16 GB memory. + +As baseline models, we basically consider GCN $\mathbb { \lVert 1 9 \rVert }$ and GAT $\pmb { \Vert 3 6 \Vert }$ . Besides, we compare with some advanced GNN models, including JKNet $\pm \ddagger { 4 } \rVert$ and MixHop [1]. These GNN models all rely on input graphs. We further consider DropEdge $\pmb { \pmb { 2 8 } }$ and two SOTA graph structure learning methods, LDS-GNN [11] and IDGL [4] for comparison. For large-scale datasets, we additionally compare with two scalable GNNs, a linear model SGC $\textcircled { \ 3 9 } \textcircled { }$ and a graph-sampling model GraphSAINT [48]. More detailed information about these models are presented in Appendix ${ \bf { \dot { C } } } .$ All the experiments are repeated five times with different initializations. + +# 4.1 Experiments on Transductive Node Classification + +We study supervised node classification in transductive setting on common graph datasets: Cora, Citeseer, Deezer and Actor. The first two have high homophily ratios and the last two are identified as heterophilic graphs [53, 21]. These datasets are of small or medium sizes (with $2 K { \sim } 2 0 K$ nodes). We use random splits with train/valid/test ratios as $5 0 \% / 2 5 \% / 2 5 \%$ . For evaluation metrics, we use ROC-AUC for binary classification on Deezer and Accuracy for other datasets with more than 2 classes. Results are plotted in Fig. $\bigtriangledown$ and NODEFORMER achieves the best mean Accuracy/ROCAUC across four datasets and in particular, outperforms other models by a large margin on two heterophilic graphs. The results indicate that NODEFORMER can handle both homophilious and nonhomophilious graphs. Compared with two structure learning models LDS and IDGL, NODEFORMER yields significantly better performance, which shows its superiority. Also, for Deezer, LDS and IDGL suffers from out-of-memory (OOM). In fact, the major difficulty for Deezer is the large dimensions of input node features (nearly 30K), which causes OOM for IDGL even with the anchor approximation. In contrast, NODEFORMER manages to scale and produce desirable accuracy. + +Table 4: Experimental results on semi-supervised classficiation on Mini-ImageNet and 20News-Groups where we use $k$ -NN (with different $k$ ’s) for artificially constructing an input graph. + +
MethodMini-ImageNet20News-Group
k=5k =10k=15k=20k=5k =10k=15k =20
GCN84.86 ± 0.4285.61 ±0.4085.93 ± 0.5985.96 ± 0.6665.98 ± 0.6864.13 ±0.8862.95 ± 0.7062.59 ± 0.62
GAT84.70 ± 0.4885.24 ± 0.4285.41 ±0.4385.37 ±0.5164.06 ± 0.4462.51 ± 0.7161.38 ± 0.8860.80 ± 0.59
DropEdge83.91 ±0.2485.35 ± 0.4485.25 ±0.6385.81 ± 0.6564.46 ± 0.4364.01 ±0.4262.46 ± 0.5162.68 ± 0.71
IDGL83.63 ± 0.3284.41 ± 0.3585.50 ± 0.2485.66 ± 0.4265.09 ± 1.2363.41 ± 1.2661.57 ± 0.5262.21 ± 0.79
LDS0OM0OM0OMOOM66.15 ± 0.3664.70 ± 1.0763.51 ± 0.6463.51 ± 1.75
NODEFORMER86.77 ± 0.4586.74 ± 0.2386.87 ± 0.4186.64 ± 0.4266.01 ± 1.1865.21 ± 1.1464.69 ± 1.3164.55 ± 0.97
NODEFORMER W/o graph87.46 ± 0.3664.71 ± 1.33
+ +![](images/2b871b90d3cc4e90185f599bc8ae874781b672ebb4199c02cad0153cc4652ab1.jpg) +Figure 3: Comparison of training/inference time and GPU memory cost w.r.t. different instance numbers (by removing a certain portion of nodes) on 20News-Groups. + +# 4.2 Experiments on Larger Graph Datasets + +To further test the scalability, we consider two large-sized networks, OGB-Proteins and Amazon2M, with over 0.1 million and 2 million of nodes, respectively. OGB-Proteins is a multi-task dataset with 112 output dimensions, while Amazon2M is extracted from the Amazon Co-Purchasing network that entails long-range dependence [13]. For OGB-Proteins, we use the protocol of $[ \overline { { \| 1 5 \| } }$ and ROC-AUC for evaluation. For Amazon2M, we adopt random splitting with $5 0 \% / 2 5 \% / 2 5 \%$ nodes for training, validation and testing, respectively. Due to the large dataset size, we adopt mini-batch partition for training, in which case, for NODEFORMER we only consider structure learning among nodes in a random mini-batch. We use batch size 10000 and 100000 for Proteins and Amazon2M, respectively. While the mini-batch partition may sacrifice the exposure to all instances, we found using large batch size can yield decent performance, which is also allowable thanks to the $\mathcal { O } ( N )$ complexity of our model. For example, even setting the batch size as 100000, we found NODEFORMER costs only 4GB GPU memory for training on Amazon2M. Table $\boxed { 2 }$ presents the results on OGB-Proteins where for fair comparison mini-batch training is also used for other models except GraphSAINT. We found that NODEFORMER yields much better ROC-AUC and only requires comparable memory as simple GNN models. Table $\mathsf { \bar { 3 } }$ reports the results on Amazon2M which shows that NODEFORMER outperforms baselines by a large margin and the memory cost is even fewer than GCN. This shows its practical efficacy and scalability on large-scale datasets and also the capability for addressing long-range dependence with shallow layers (we use $L = 3$ ). + +# 4.3 Experiments on Graph-Enhanced Applications + +We apply our model to semi-supervised image and text classification on Mini-ImageNet and 20News-Groups datasets, without input graphs. The instances of Mini-ImageNet $\textcircled { 1 3 7 }$ are $8 4 { \times } 8 4$ RGB images and we randomly choose 30 classes each of which contains 600 samples for experiments. 20News-Groups $\mathbb { \left[ \left[ 2 5 \right] \right] }$ consists of nearly 10K texts whose features are extracted by TF-IDF. More details for preprocessing are presented in Appendix $\mathbf { D } .$ Also, for each dataset, we randomly split instances into $5 0 \% / 2 5 \% / 2 5 \%$ for train/valid/test. Since there is no input graph, we use $k$ -NN (over input node features) for artificially constructing a graph for enabling GNN’s message passing and the graph-based components (edge regularization and relational bias) of NODEFORMER. Table $^ 4$ presents the comparison results under different $k$ ’s. We can see that NODEFORMER achieves the best performance in seven cases out of eight. The performance of GNN competitors varies significantly with different $k$ values, and NODEFORMER is much less sensitive. Intriguingly, when we do not use the input graph, i.e., removing both the edge regularization and relational bias, NODEFORMER can still yield competitive even superior results on Mini-ImageNet. This suggests that the $k$ -NN graphs are not necessarily informative and besides, our model learns useful latent graph structures from data. + +# 4.4 Further Discussions + +Comparison of Time/Space Consumption. Fig. $3$ plots training/inference time and GPU memory costs of NODEFORMER and two SOTA structure learning models. Compared with LDS, NODEFORMER reduces the training time, inference time, memory cost by up to $9 3 . 1 \%$ , $9 7 . 9 \%$ , $7 5 . 6 \%$ , respectively; compared with IDGL (using anchor-based approximation for speedup), NODEFORMER reduces the training time, inference time, memory cost by up to $6 1 . 8 \%$ , $8 0 . 8 \%$ , $8 0 . 6 \%$ , respectively. + +Ablation on Stochastic Components. Table $\bigtriangledown$ and $\textcircled { 3 }$ also include two variants of NODEFORMER for ablation study. 1) NODEFORMER-dt: replace Gumbel-Softmax by original Softmax (with temperature 1.0) for deterministic propagation; 2) NODEFORMER-tp: use original Softmax with temperature set as 0.25 (the same as NODEFORMER). There is performance drop when removing the Gumbel components, which may be due to over-normalizing or over-fitting that are amplified in large datasets, as we discussed in Section $3 . 1$ and the kernelized Gumbel-Softmax operator shows its effectiveness. + +Ablation on Edge Loss and Relational Bias. We study the effects of edge-level regularization and relation bias as ablation study shown in Table $\bigtriangledown$ located in Appendix $\boxed { \mathrm { E } }$ where the results consistently show that both components contribute to some positive effects and suggest that our edge-level loss and relation bias can both help to leverage useful information from input graphs. + +Impact of Temperature and Feature Map Dimension. We study the effects of $\tau$ and $m$ in Fig. 6 located in Appendix $\mathrm { ~ E ~ }$ and the variation trend accords with our theoretical analysis in Section $\underline { { \boldsymbol { \sqrt { 3 . 2 } } } }$ Specifically, the result shows that the test accuracy increases and then falls with the temperature changing from low to high values (usually achieves the peak accuracy with a temperature of 0.4). Besides, we can see that when the temperature is relatively small, the test accuracy goes high with the dimension of random features increasing. However, when the temperature is large, the accuracy would drop even with large feature dimension $m$ . Such a phenomenon accords with the theoretical result presented in Section $\underline { { \overline { { 3 . 2 } } } }$ For low temperature which enables desirable approximation performance for Gumbel-Softmax, then larger random feature dimension would help to produce better approximation to the original exponentiate-then-dot operator. In contrast, high temperature could not guarantee precise approximation for the original categorical distribution, which deteriorates the performance. + +Visualization and Implications. Fig. 4 visualizes node embeddings and edge connections (filter out the edges with weights larger than a threshold) on 20News-Groups and Mini-Imagenet, which show that NODEFORMER tends to assign more weights for nodes with the same class and sparse edges for nodes with different classes. This helps to interpret why NODEFORMER improves the performance on downstream node-level prediction: the latent structures can propagate useful information to help the model learn better node representations that can be easily distinguished by the classifier. We also compare the learned structures with original graphs in Fig. $^ { 7 }$ located in Appendix E. We can see that the latent structures learned by NODEFORMER show different patterns from the observed ones, especially for heterophilic graphs. Another interesting phenomenon is that there exist some dominant nodes which are assigned large weights by other nodes, forming some vertical ‘lines’ in the heatmap. This suggests that these nodes could contain critical information for the learning tasks and play as pivots that could improve the connectivity of the whole system. + +# 5 Why NODEFORMER Improves Downstream Prediction? + +There remains a natural question concerning our learning process: how effective can the learned latent topology be for downstream tasks? We next dissect the rationale from a Bayesian perspective. In fact, our model induces a predictive distribution $p ( \mathbf { Y } , { \tilde { \mathbf { A } } } | \mathbf { X } , \mathbf { A } ) = p ( { \tilde { \mathbf { A } } } | \mathbf { X } , \mathbf { A } ) p ( \mathbf { Y } | { \tilde { \mathbf { A } } } , \mathbf { X } , \mathbf { A } )$ where we can treat the estimated graph $\tilde { \mathbf { A } }$ as a latent variable.2 Specifically, $p ( \tilde { \mathbf { A } } | \mathbf { X } , \mathbf { A } )$ is instantiated with the structure estimation module and $p ( \mathbf { Y } | \tilde { \mathbf { A } } , \mathbf { X } , \mathbf { A } )$ is instantiated with the feature propagation module. In principle, ideal latent graphs should account for downstream tasks and maximize the potentials of message passing for producing informative node representations. Thus, optimal latent graphs presumably come from the posterior $\begin{array} { r } { p ( \tilde { \mathbf { A } } | \mathbf { Y } , \mathbf { X } , \mathbf { A } ) = \frac { p ( \mathbf { Y } | \mathbf { X } , \mathbf { A } , \tilde { \mathbf { A } } ) p ( \tilde { \mathbf { A } } | \mathbf { X } , \mathbf { A } ) } { \int _ { \mathbf { Y } } p ( \mathbf { Y } | \mathbf { X } , \mathbf { A } , \tilde { \mathbf { A } } ) p ( \tilde { \mathbf { A } } | \mathbf { X } , \mathbf { A } ) d \mathbf { Y } } } \end{array}$ which is given by Bayes theorem. Unfortunately, such a posterior is unknown and intractable for the integration. + +![](images/6eb3b36d63784135fa687a83c6ebdb9773f71df5cf04075bdfd9ad02096d6440.jpg) +Figure 4: Visualization of node embeddings and edge connections produced by NODEFORMER on graph-enhanced application datasets. We mark the nodes with a particular class with one color. More comparison between the learned structures and original input graphs is presented in Appendix E. + +A Variational Perspective. An intriguing conclusion stems from another view into the learning process: we can treat the structure estimation as a variational distribution $q ( \tilde { \mathbf { A } } | \mathbf { X } , \mathbf { A } )$ and our learning objective in Section $3 . 4$ can be viewed as the embodiment of a minimization problem over the predictive and variational distributions via + +$$ +p ^ { * } , q ^ { * } = \arg \operatorname* { m i n } _ { p , q } \underbrace { - \mathbb { E } _ { q } [ \log p ( \mathbf { Y } | \tilde { \mathbf { A } } , \mathbf { X } , \mathbf { A } ) ] } _ { \mathcal { L } _ { s } } + \underbrace { \mathcal { D } ( q ( \tilde { \mathbf { A } } | \mathbf { X } , \mathbf { A } ) \| p _ { 0 } ( \tilde { \mathbf { A } } | \mathbf { X } , \mathbf { A } ) ) } _ { \mathcal { L } _ { e } } , +$$ + +where $\mathcal { D }$ denotes the Kullback-Leibler divergence. Specifically, the predictive term is equivalent to minimizing the supervised loss (with Gumbel-Softmax as a surrogate for sampling-based estimates over $q ( \tilde { \mathbf { A } } | \mathbf { X } , \mathbf { A } ) )$ ), and the KL regularization term is embodied with the edge-level MLE loss $\mathrm { ( E q n . } \boxed { 1 0 }$ (if we define the prior distribution $p _ { 0 } ( \tilde { \mathbf { A } } | \mathbf { X } , \mathbf { A } )$ following Eqn. $\boxed { 1 1 }$ . One may notice that Eqn. 13 is essentially the Evidence Lower Bound (ELBO) for the log-likelihood $\log p ( \mathbf { Y } | \mathbf { X } , \mathbf { A } )$ . + +Proposition 1. Assume $q$ can exploit arbitrary distributions over $\tilde { \mathbf { A } }$ . When Eqn. $\boxed { I 3 }$ achieves the optimum, we have 1) ${ \mathcal { D } } ( q ( \tilde { \mathbf { A } } | \mathbf { X } , \tilde { \mathbf { A } } ) \| p ( \tilde { \mathbf { A } } | \mathbf { Y } , \mathbf { X } , \mathbf { A } ) ) = 0$ and 2) $\log p ( \mathbf { Y } | \mathbf { X } , \mathbf { A } )$ is maximized. + +The proposition indicates that our adopted learning objective intrinsically minimizes the divergence between latent graphs generated by the model and the samples from the posterior $p ( \tilde { \mathbf { A } } | \mathbf { Y } , \mathbf { \bar { X } } , \mathbf { A } )$ that ideally helps to propagate useful adjacent information w.r.t. downstream tasks. Therefore, a well-trained network of NODEFORMER on labeled data could produce effective latent topology that contributes to boosting the downstream performance. + +# 6 Conclusion + +This paper proposes a scalable and efficient graph Transformer (especially for node level) that can propagate layer-wise node signals between arbitrary pairs beyond input topology. The key module, a kernelized Gumbel-Softmax operator, enables us to learn layer-specific latent graphs with linear algorithmic complexity without compromising the precision. The results on diverse graph datasets and situations verify the effectiveness, scalability, and stability. We provide more discussions on the limitations and potential impacts in Appendix F. + +# Acknowledgement + +This work was partly supported by National Key Research and Development Program of China (2020AAA0107600), National Natural Science Foundation of China (61972250, 72061127003), and Shanghai Municipal Science and Technology (Major) Project (22511105100, 2021SHZDZX0102). + +# References + +[1] Sami Abu-El-Haija, Bryan Perozzi, Amol Kapoor, Nazanin Alipourfard, Kristina Lerman, Hrayr Harutyunyan, Greg Ver Steeg, and Aram Galstyan. Mixhop: Higher-order graph convolutional architectures via sparsified neighborhood mixing. In International Conference on Machine Learning, pages 21–29, 2019. +[2] Uri Alon and Eran Yahav. On the bottleneck of graph neural networks and its practical implications. In International Conference on Learning Representations, 2021. +[3] Michael M. Bronstein, Joan Bruna, Yann LeCun, Arthur Szlam, and Pierre Vandergheynst. Geometric deep learning: going beyond euclidean data. CoRR, abs/1611.08097, 2016. +[4] Yu Chen, Lingfei Wu, and Mohammed J. Zaki. Iterative deep graph learning for graph neural networks: Better and robust node embeddings. In Advances in Neural Information Processing Systems, 2020. +[5] 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 ACM SIGKDD International Conference on Knowledge Discovery & Data Mining, pages 257–266, 2019. +[6] 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 International Conference on Learning Representations, 2021. +[7] Luca Cosmo, Anees Kazi, Seyed-Ahmad Ahmadi, Nassir Navab, and Michael M. Bronstein. Latent patient network learning for automatic diagnosis. CoRR, abs/2003.13620, 2020. +[8] Hanjun Dai, Zornitsa Kozareva, Bo Dai, Alexander J. Smola, and Le Song. Learning steadystates of iterative algorithms over graphs. In International Conference on Machine Learning, pages 1114–1122, 2018. +[9] Vijay Prakash Dwivedi and Xavier Bresson. A generalization of transformer networks to graphs. CoRR, abs/2012.09699, 2020. +[10] Pantelis Elinas, Edwin V. Bonilla, and Louis C. Tiao. Variational inference for graph convolutional networks in the absence of graph data and adversarial settings. In Advances in Neural Information Processing Systems, 2020. +[11] Luca Franceschi, Mathias Niepert, Massimiliano Pontil, and Xiao He. Learning discrete structures for graph neural networks. In International Conference on Machine Learning, pages 1972–1982, 2019. +[12] Chen Gao, Jinyu Chen, Si Liu, Luting Wang, Qiong Zhang, and Qi Wu. Room-and-object aware knowledge reasoning for remote embodied referring expression. In IEEE Conference on Computer Vision and Pattern Recognition, pages 3064–3073, 2021. +[13] Fangda Gu, Heng Chang, Wenwu Zhu, Somayeh Sojoudi, and Laurent El Ghaoui. Implicit graph neural networks. In Advances in Neural Information Processing Systems, 2020. +[14] William L. Hamilton, Zhitao Ying, and Jure Leskovec. Inductive representation learning on large graphs. In Advances in Neural Information Processing Systems, pages 1024–1034, 2017. +[15] 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. In Advances in Neural Information Processing Systems, 2020. +[16] Eric Jang, Shixiang Gu, and Ben Poole. Categorical reparameterization with gumbel-softmax. In International Conference on Learning Representations, 2017. +[17] Bo Jiang, Ziyan Zhang, Doudou Lin, Jin Tang, and Bin Luo. Semi-supervised learning with graph learning-convolutional networks. In IEEE Conference on Computer Vision and Pattern Recognition, pages 11313–11320, 2019. + +[18] Wei Jin, Yao Ma, Xiaorui Liu, Xianfeng Tang, Suhang Wang, and Jiliang Tang. Graph structure learning for robust graph neural networks. In ACM SIGKDD Conference on Knowledge Discovery and Data Mining, pages 66–74, 2020. + +[19] Thomas N. Kipf and Max Welling. Semi-supervised classification with graph convolutional networks. In International Conference on Learning Representations (ICLR), 2017. + +[20] Danning Lao, Xinyu Yang, Qitian Wu, and Junchi Yan. Variational inference for training graph neural networks in low-data regime through joint structure-label estimation. In ACM SIGKDD Conference on Knowledge Discovery and Data Mining, pages 824–834, 2022. + +[21] Derek Lim, Xiuyu Li, Felix Hohne, and Ser-Nam Lim. New benchmarks for learning on non-homophilous graphs. CoRR, abs/2104.01404, 2021. + +[22] Dongsheng Luo, Wei Cheng, Wenchao Yu, Bo Zong, Jingchao Ni, Haifeng Chen, and Xiang Zhang. Learning to drop: Robust graph neural network via topological denoising. In ACM International Conference on Web Search and Data Mining, pages 779–787, 2021. + +[23] Chris J. Maddison, Andriy Mnih, and Yee Whye Teh. The concrete distribution: A continuous relaxation of discrete random variables. In International Conference on Learning Representations, 2017. + +[24] Julian J. McAuley, Rahul Pandey, and Jure Leskovec. Inferring networks of substitutable and complementary products. In ACM SIGKDD International Conference on Knowledge Discovery and Data Mining, pages 785–794, 2015. + +[25] Fabian Pedregosa, Gaël Varoquaux, Alexandre Gramfort, Vincent Michel, Bertrand Thirion, Olivier Grisel, Mathieu Blondel, Peter Prettenhofer, Ron Weiss, Vincent Dubourg, et al. Scikitlearn: Machine learning in python. the Journal of machine Learning research, 12:2825–2830, 2011. + +[26] Hongbin Pei, Bingzhe Wei, Kevin Chen-Chuan Chang, Yu Lei, and Bo Yang. Geom-gcn: Geometric graph convolutional networks. In International Conference on Learning Representations, 2020. + +[27] Ali Rahimi and Benjamin Recht. Random features for large-scale kernel machines. In Advances in Neural Information Processing Systems, pages 1177–1184, 2007. + +[28] Yu Rong, Wenbing Huang, Tingyang Xu, and Junzhou Huang. Dropedge: Towards deep graph convolutional networks on node classification. In International Conference on Learning Representations, 2020. + +[29] Benedek Rozemberczki and Rik Sarkar. Characteristic functions on graphs: Birds of a feather, from statistical descriptors to parametric models. In ACM International Conference on Information and Knowledge Management, pages 1325–1334, 2020. + +[30] Alvaro Sanchez-Gonzalez, Jonathan Godwin, Tobias Pfaff, Rex Ying, Jure Leskovec, and Peter W. Battaglia. Learning to simulate complex physics with graph networks. In International Conference on Machine Learning, pages 8459–8468, 2020. + +[31] Victor Garcia Satorras and Joan Bruna Estrach. Few-shot learning with graph neural networks. In International Conference on Learning Representations, 2018. + +[32] Franco Scarselli, Marco Gori, Ah Chung Tsoi, Markus Hagenbuchner, and Gabriele Monfardini. The graph neural network model. IEEE transactions on neural networks, 20(1):61–80, 2008. + +[33] Prithviraj Sen, Galileo Namata, Mustafa Bilgic, Lise Getoor, Brian Gallagher, and Tina EliassiRad. Collective classification in network data. AI Mag., 29(3):93–106, 2008. + +[34] Rakshith Sharma Srinivasa, Cao Xiao, Lucas Glass, Justin Romberg, and Jimeng Sun. Fast graph attention networks using effective resistance based graph sparsification. CoRR, abs/2006.08796, 2020. + +[35] Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Łukasz Kaiser, and Illia Polosukhin. Attention is all you need. Advances in neural information processing systems, 30, 2017. +[36] Petar Velickovic, Guillem Cucurull, Arantxa Casanova, Adriana Romero, Pietro Liò, and Yoshua Bengio. Graph attention networks. In International Conference on Learning Representations (ICLR), 2018. +[37] Oriol Vinyals, Charles Blundell, Tim Lillicrap, Koray Kavukcuoglu, and Daan Wierstra. Matching networks for one shot learning. In Advances in Neural Information Processing Systems, pages 3630–3638, 2016. +[38] Yue Wang, Yongbin Sun, Ziwei Liu, Sanjay E. Sarma, Michael M. Bronstein, and Justin M. Solomon. Dynamic graph CNN for learning on point clouds. ACM Trans. Graph., 38(5):146:1– 146:12, 2019. +[39] Felix Wu, Amauri H. Souza Jr., Tianyi Zhang, Christopher Fifty, Tao Yu, and Kilian Q. Weinberger. Simplifying graph convolutional networks. In International Conference on Machine Learning, pages 6861–6871, 2019. +[40] Qitian Wu, Chenxiao Yang, and Junchi Yan. Towards open-world feature extrapolation: An inductive graph learning approach. Advances in Neural Information Processing Systems, pages 19435–19447, 2021. +[41] Qitian Wu, Hengrui Zhang, Xiaofeng Gao, Junchi Yan, and Hongyuan Zha. Towards open-world recommendation: An inductive model-based collaborative filtering approach. In International Conference on Machine Learning, pages 11329–11339, 2021. +[42] Tailin Wu, Hongyu Ren, Pan Li, and Jure Leskovec. Graph information bottleneck. In Advances in Neural Information Processing Systems, 2020. +[43] Xuan Wu, Lingxiao Zhao, and Leman Akoglu. A quest for structure: Jointly learning the graph structure and semi-supervised classification. In ACM International Conference on Information and Knowledge Management, pages 87–96, 2018. +[44] Keyulu Xu, Chengtao Li, Yonglong Tian, Tomohiro Sonobe, Ken-ichi Kawarabayashi, and Stefanie Jegelka. Representation learning on graphs with jumping knowledge networks. In International Conference on Machine Learning, pages 5449–5458, 2018. +[45] Chenxiao Yang, Qitian Wu, and Junchi Yan. Geometric knowledge distillation: Topology compression for graph neural networks. In Advances in Neural Information Processing Systems, 2022. +[46] Liang Yao, Chengsheng Mao, and Yuan Luo. Graph convolutional networks for text classification. In AAAI Conference on Artificial Intelligence, pages 7370–7377, 2019. +[47] Rex Ying, Dylan Bourgeois, Jiaxuan You, Marinka Zitnik, and Jure Leskovec. GNN explainer: A tool for post-hoc explanation of graph neural networks. In Advances in Neural Information Processing Systems, 2019. +[48] Hanqing Zeng, Hongkuan Zhou, Ajitesh Srivastava, Rajgopal Kannan, and Viktor Prasanna. Graphsaint: Graph sampling based inductive learning method. In International Conference on Learning Representations, 2020. +[49] Tianqi Zhang, Qitian Wu, Junchi Yan, Yunan Zhao, and Bing Han. Scalegcn: Efficient and effective graph convolution via channel-wise scale transformation. IEEE Transactions on Neural Networks and Learning Systems, 2022. +[50] Xiang Zhang and Marinka Zitnik. Gnnguard: Defending graph neural networks against adversarial attacks. In Advances in Neural Information Processing Systems, 2020. +[51] Yingxue Zhang, Soumyasundar Pal, Mark Coates, and Deniz Üstebay. Bayesian graph convolutional neural networks for semi-supervised classification. In AAAI Conference on Artificial Intelligence, pages 5829–5836, 2019. +[52] Cheng Zheng, Bo Zong, Wei Cheng, Dongjin Song, Jingchao Ni, Wenchao Yu, Haifeng Chen, and Wei Wang. Robust graph representation learning via neural sparsification. In International Conference on Machine Learning, pages 11458–11468, 2020. +[53] Jiong Zhu, Yujun Yan, Lingxiao Zhao, Mark Heimann, Leman Akoglu, and Danai Koutra. Beyond homophily in graph neural networks: Current limitations and effective designs. In Advances in Neural Information Processing Systems, 2020. +[54] Yanqiao Zhu, Weizhi Xu, Jinghao Zhang, Qiang Liu, Shu Wu, and Liang Wang. Deep graph structure learning for robust representations: A survey. CoRR, abs/2103.03036, 2021. + +# Checklist + +1. For all authors... + +(a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes] +(b) Did you describe the limitations of your work? [Yes] +(c) Did you discuss any potential negative societal impacts of your work? [Yes] +(d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes] + +2. If you are including theoretical results... + +(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] See Appendix B + +3. If you ran experiments... + +(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 codes are public available. See Appendix D for dataset information. +(b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes] See Appendix C +(c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [Yes] See the experiment section +(d) Did you include the total amount of compute and the type of resources used (e.g., type of GPUs, internal cluster, or cloud provider)? [Yes] See Appendix C + +4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets... + +(a) If your work uses existing assets, did you cite the creators? [Yes] See Appendix D +(b) Did you mention the license of the assets? [N/A] +(c) Did you include any new assets either in the supplemental material or as a URL? [N/A] +(d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [N/A] +(e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [N/A] + +5. If you used crowdsourcing or conducted research with human subjects... + +(a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A] +(b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A] +(c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A] \ No newline at end of file diff --git a/md/dev/tGbpgz6yOrI/tGbpgz6yOrI.md b/md/dev/tGbpgz6yOrI/tGbpgz6yOrI.md new file mode 100644 index 0000000000000000000000000000000000000000..1a4f49487ad700b9f43cee366ca94476cb2fb7ae --- /dev/null +++ b/md/dev/tGbpgz6yOrI/tGbpgz6yOrI.md @@ -0,0 +1,334 @@ +# R3M: A Universal Visual Representation for Robot Manipulation + +Suraj $\mathbf { N a i r ^ { 1 , * } }$ , Aravind Rajeswaran2, Vikash Kumar2, Chelsea $\mathbf { F i n n ^ { 1 } }$ , Abhinav Gupta2 + +1Stanford University, 2Meta AI + +Abstract: We study how visual representations pre-trained on diverse human video data can enable data-efficient learning of downstream robotic manipulation tasks. Concretely, we pre-train a visual representation using the Ego4D human video dataset using a combination of time-contrastive learning, video-language alignment, and an L1 penalty to encourage sparse and compact representations. The resulting representation, R3M, can be used as a frozen perception module for downstream policy learning. Across a suite of 12 simulated robot manipulation tasks, we find that R3M improves task success by over $2 0 \%$ compared to training from scratch and by over $1 0 \%$ compared to state-of-the-art visual representations like CLIP and MoCo. Furthermore, R3M enables a Franka Emika Panda arm to learn a range of manipulation tasks in a real, cluttered apartment given just 20 demonstrations. + +Keywords: Visual Representation Learning, Robotic Manipulation + +# 1 Introduction + +How do we train a robot to complete a manipulation task from images? A standard and widely used approach is to train an end-to-end model from scratch using data from the same domain [1]. However, this can be prohibitively data intensive and severely limits generalization. In contrast, computer vision and natural language processing (NLP) have recently taken a major departure from this “tabula rasa” paradigm. These fields have focused on using diverse, large-scale datasets to build reusable, pre-trained representations. Such models have become ubiquitous; for example, visual representations from ImageNet [2] can be reused for tasks like cancer detection [3], and pre-trained language embeddings like BERT [4] have been used for everything from medical coding [5] to visual question answering [6]. Such an equivalent of an ImageNet [2] or BERT [4] model for robotics, that can be readily downloaded and used for any downstream simulation or real-world manipulation task, has remained elusive. + +Why have we struggled in building this universal representation for robotics? Our conjecture is that we haven’t converged on using the appropriate datasets for robotics. Collecting large and diverse datasets of robots interacting with the physical world can be costly, even without human annotation. Recent attempts at creating such datasets [7, 8, 9, 10], consist of a limited number of tasks in at most a handful of different environments. This lack of diversity and scale makes it difficult to learn representations that are broadly applicable. At the same time, the recent history of computer vision and NLP suggests an alternate route for robotics. The best representations in these fields did not arise out of task-specific and carefully curated datasets, but rather the use of abundant in-the-wild data [4, 11, 12, 13]. Analogously, for robotics and motor control, we have access to videos of humans interacting in semantically interesting ways with their environments [14, 15, 16]. This data is large and diverse, spanning scenes across the globe, and tasks ranging from folding clothes to cooking a meal. While the embodiment present in this data differs from most robots, prior work [17, 18] has found that such human video data can still be useful for learning reward functions. Furthermore, domain gap has not been a major barrier for using pre-trained representations in traditional vision and NLP tasks. In this backdrop, we ask the pertinent question: can visual representations pre-trained on diverse human videos enable efficient downstream learning of robotic manipulation skills? + +![](images/a27b2b5e1fbf16cfc1be41aa6486a67ba25e3b2c09ecf54fc9edf13aa8f1f7ee.jpg) +Figure 1: Pre-Training Reusable Representations for Robot Manipulation (R3M): We pre-train a visual representation using diverse human video datasets like Ego4D [16], and study its effectiveness for downstream robot manipulation tasks. Our representation model, R3M, is trained using a combination of time-contrastive learning, video-language alignment, and an L1 sparsity penalty. We find that R3M enables data efficient imitation learning across several simulated and real-world robot manipulation tasks. + +We hypothesize that a good representation for vision-based robotic manipulation consists of three components. First, it should contain information necessary for physical interaction, and thus should capture the temporal dynamics of the scene (i.e. how states might transition to other states). Second, it should have a prior over semantic relevance, and should focus on task relevant features like objects and their relationships. Finally, it should be compact, and not include features irrelevant to the above criteria (e.g. backgrounds). Towards satisfying these three criteria, we study a representation learning approach that combines (1) time contrastive learning [19] to learn a representation that captures temporal dynamics, (2) video-language alignment to capture semantically relevant features of the scene, and (3) L1 and L2 penalties to encourage sparsity. Our experimental evaluation in Section 4.4 finds that all three components are important for training highly performant representations. + +In this work we empirically demonstrate that representations pre-trained on diverse human video datasets like Ego4D [16] can enable efficient downstream policy learning for robotic manipulation. Our core contribution is an artifact – the pre-trained vision model – that can be used readily in other work. Concretely, we pre-train a reusable representation for robotic manipulation (R3M), which can be used as a frozen perception module for downstream policy learning in simulated and real robot manipulation tasks. We demonstrate this via extensive experimental results across three existing benchmark simulation environments (Adroit [20], Franka-Kitchen [21], and MetaWorld [22]) as well as real robot experiments in a cluttered apartment setting. R3M features outperform a wide range of visual representations like CLIP [12], (supervised) ImageNet [2], MoCo [23, 24], and learning from scratch by over $10 \%$ when evaluated across 12 tasks, 9 viewpoints, and 3 different simulation environments. On a Franka Emika Panda robot, R3M enables learning challenging tasks like putting lettuce in a pan and folding a towel with a $50 \%$ average success rate, given less than 10 minutes of human demonstrations (see Figure 1), which is nearly double the success rate compared to CLIP features. Overall, on the basis of these results, we believe that R3M has the potential to become a standard vision model for robot manipulation, which can be simply downloaded and used off-the-shelf for any robot manipulation task or environment. See https: //sites.google.com/view/robot-r3m for pre-trained models and code. + +# 2 Related Work + +Representation Learning for Robotics. Our work is certainly not the first to study the problem of learning general representations for robotics. One line of work focuses on learning representations from in-domain data, that is, using data from the target environment and task for training the representation. Such methods include contrastive learning with data augmentation [25, 26, 27, 28], dynamics prediction [29, 30], bi-simulation [31], temporal or goal distance [32, 33], or domain specific information [34]. However, because they are trained on data exclusively from the target domain and task, the learned representations fail to generalize and cannot be re-used to enable faster learning in unseen tasks and environments. + +Recently, there has been growing interest in learning more general representations for motor control from large-scale out-of-domain data like images from the web. This includes the use of CLIP, supervised MS-COCO, supervised ImageNet, MoCo ImageNet features, or data from different robots [35, 36, 37, 38, 23, 39]. In contrast to prior work, we pre-train the representation using diverse human video and language data, as opposed to static frames and/or class labels. Further, in our experimental evaluation, we observe that our pre-trained representation outperforms prior work significantly on a comprehensive evaluation suite. Concurrently, Xiao et al. [40] also explore the use of human interaction data to pre-train visual representations for motor control. However their learned representation only uses static frames from these videos and does not utilize temporal or semantic information like R3M. Furthermore, our evaluation focuses on data efficient imitation learning, and enables real-world learning in cluttered environments with just $\sim 1 0$ minutes of demonstration data. + +Leveraging Human Videos for Robot Learning. Several prior works have explored using human video data in robot learning, for example to acquire goals [41, 42, 43], to learn visual dynamics models [44, 45, 46, 47], or to learn representations and rewards [19, 48, 49, 50, 51, 52]. However, these prior works typically focus on a small dataset of human videos closely resembling the robot environment. In contrast, our work leverages diverse human video data like Ego4D [16] to learn visual reusable visual representations that generalize broadly. + +Natural Language and Robotic Manipulation. Prior works have explored the use of natural language in robot manipulation, primarily as a means of task specification [53, 54, 36, 55] or reward learning [56]. In contrast, we use diverse human video data and language annotations to learn reusable visual representations for control. Prior work has also found visual representations informed by language, like CLIP [12], to be effective for control [36, 37]. Through empirical evaluations, we find that our R3M representation substantially outperforms CLIP for robot manipulation. + +Learning from Diverse Robot Data. Towards robots that generalize more broadly, there are a number of works that study how to scale up the size and diversity of data robots learn from. Many of these works focus on collecting and learning from robot data itself [57, 58, 7, 8, 9, 10, 59]. However, these works often contain at most a handful of different environments, making generalization across a range of unseen scenes difficult. While we also aim to enable generalization by learning from diverse data, our focus is instead on (1) learning from human video data and hence a larger distribution of environments and tasks, and (2) pre-training a visual representation, as opposed to policies or models. + +Representation Learning from Videos. Finally, there is a rich literature of works that study learning image representations from videos [60, 61, 19, 62, 63, 64] outside of the context of robotics. Additionally, there are a number of works that use language to learn representations from videos [65, 66]. Critically, unlike all of these works, the main contribution of this work is not to propose a novel representation learning approach, but rather in studying if representations trained on diverse video and language of human interaction can enable more efficient learning of robotic manipulation. + +# 3 R3M: Reusable Representations for Robotic Manipulation + +Our goal is to use diverse human video data to pre-train a single reusable visual representation for motor control, particularly robotic manipulation, that can enable efficient downstream learning in previously unseen environments and tasks. In this section, we cover the different components of our approach, beginning by describing our problem formulation in Section 3.1, the data sources we use in Section 3.2, and our training objective in Section 3.3. + +# 3.1 Preliminaries + +Formally, we assume that we have access to a dataset $\mathcal { D }$ of $N$ videos, where each video consists of a sequence of RGB frames $[ I _ { 0 } , I _ { 1 } , . . . , I _ { T } ]$ . Additionally, we assume that each video is paired with a natural language description $l$ , that describes what task is being completed in the video. From this data, our goal is to learn a single image encoder $\mathcal { F } _ { \phi }$ , that maps images to a deterministic, continuous embedding, that is $z = \mathcal { F } _ { \phi } ( I )$ . Once trained, we want to be able to repeatedly reuse $\mathcal { F }$ for downstream policy learning. Specifically, the downstream problem will involve an agent sequentially choosing actions given image observations $I$ , and instead of using raw images as input, the agent will use the pre-trained ${ \mathcal { F } } _ { \phi } ( I )$ as a state representation. + +![](images/4ff39fbcdeffd4b029e257b88a5411828ad47288a77ce7e56a2d711d54a0a8bc.jpg) +Figure 2: Ego4D [16] Video and Language (left). Sample frames and associated language from Grauman et al. [16] used for training R3M. R3M Training (right). We train R3M with time contrastive learning, encouraging states closer in time to be closer in embedding space and video-language alignment to encourage the embeddings to capture semantically relevant features. + +# 3.2 Data Sources + +For our learned representation $\mathcal { F } _ { \phi }$ to be useful in a wide range of downstream tasks and environments, it should (1) be trained on data that is diverse enough to facilitate generalization, and (2) provide a useful signal for features relevant to robotic manipulation. One approach would be to be use natural images off the web (e.g. ImageNet [2]). While diverse, these images tend to focus on one particular object, and do not capture an agent interacting with multiple objects in a scene. Alternatively, data of humans interacting in the world [14, 65, 16] is both diverse and contains useful interaction in scenes similar to those we would like robots to interact in. Of the many human video datasets, we leverage the Ego4D dataset [16] due to it’s diversity and size, although in principle our method can be used on any suitable video dataset. Ego4D contains videos of people engaging in a wide range of tasks from cooking to socializing to assembling objects from more than 70 locations across the globe, and in total contains more than 3500 hours of data. Each video clip also contains a natural language annotation describing the behavior of the person in the video (See Figure 2 (left)). + +# 3.3 Training R3M + +What should a good representation for robotic manipulation from human video data capture? We propose three key components: (1) it should capture temporal dynamics, as the agent will be sequentially interacting in the environment to accomplish tasks, (2) it should capture semantically relevant features, and (3) it should be compact. We next describe how we use time contrastive learning to capture (1), video-language alignment for (2), and the use of L1 regularization to encourage (3). See Figure 2 (right) for an overview of our training objective. + +Time Contrastive Learning. To encourage $\mathcal { F } _ { \phi }$ to capture features relevant to physical interaction and sequential decision making, the first part of our objective is a time contrastive loss [61]. Given a batch of videos we train the encoder to produce a representation such that the distance between images closer in time is smaller than for images farther in time or from different videos. Specifically, we sample a batch of sequences of frames $[ I _ { i } , I _ { j > i } , I _ { k > j } ] ^ { 1 : B }$ , then minimize the InfoNCE loss [67]: + +$$ +\mathcal { L } _ { t c n } = - \sum _ { b \in B } \log \frac { e ^ { S ( z _ { i } ^ { b } , z _ { j } ^ { b } ) } } { e ^ { S ( z _ { i } ^ { b } , z _ { j } ^ { b } ) } + e ^ { S ( z _ { i } ^ { b } , z _ { k } ^ { b } ) } + e ^ { S ( z _ { i } ^ { b } , z _ { i } ^ { \ne b } ) } } +$$ + +where $z = \mathcal { F } _ { \phi } ( I )$ , and $z _ { i } ^ { \neq b }$ is a negative example sampled from a different video in the batch. $s$ +denotes a measure of similarity, which in our case is implemented as the negative L2 distance. + +Video-Language Alignment. To encourage $\mathcal { F } _ { \phi }$ to capture semantically relevant features, we train a language prediction module from the embedding outputted by $\mathcal { F } _ { \phi }$ . Essentially, by capturing features predictive of language, like “putting the apple on the plate”, the learned representation should capture semantically relevant parts of the scene like the plate and apple state, that are likely relevant to downstream manipulation tasks. Following Nair et al. [56], we train a model $\mathcal { G } _ { \theta } ( \mathcal { F } _ { \phi } ( I _ { 0 } ) , \mathcal { F } _ { \phi } ( I _ { i } ) , l )$ that takes in an initial image $I _ { 0 }$ , a future image $I _ { i }$ , language $l$ and outputs a score corresponding to if transitioning from $I _ { 0 }$ to $I _ { i }$ completes the language $l$ . We train the model under the objective that (1) the score should increase over the course of the video, and (2) the score should be higher for correct pairings of video/language than for incorrect pairings. Again we sample a video clip and paired language $[ I _ { i } , I _ { j > i } , l ] ^ { 1 : B }$ , and then train for this objective directly with a contrastive loss, that is: + +$$ +\mathcal { L } _ { l a n g u a g e } = - \sum _ { b \in B } \log \frac { e ^ { \mathcal { G } _ { \theta } ( z _ { 0 } ^ { b } , z _ { j > i } ^ { b } , l ^ { b } ) } } { e ^ { \mathcal { G } _ { \theta } ( z _ { 0 } ^ { b } , z _ { j > i } ^ { b } , l ^ { b } ) } + e ^ { \mathcal { G } _ { \theta } ( z _ { 0 } ^ { b } , z _ { i } ^ { b } , l ^ { b } ) } + e ^ { \mathcal { G } _ { \theta } ( z _ { 0 } ^ { \ne b } , z _ { j > i } ^ { \ne b } , l ^ { b } ) } } +$$ + +where again $z = \mathcal { F } _ { \phi } ( I )$ , and $z ^ { \neq b }$ is a negative example sampled from a different video in the batch (that does not match the language instruction $l ^ { b }$ ). + +Regularization. Finally, we hypothesize that sparse and compact representations benefit control, particularly in low data imitation learning. State-distribution shift is a well studied failure mode in imitation learning [68], where policies trained with behavior cloning drift off the expert state distribution. Reducing the effective dimensionality of the state space (which we implement with a simple L1 and L2 penalty) can help mitigate this issue, as we demonstrate in Section 4.4. + +R3M Summary $\pmb { \& }$ Implementation. The final objective for training R3M is the weighted sum: + +$$ +\mathcal { L } ( \phi , \theta ) = \mathbb { E } _ { I _ { 0 } ^ { 1 ; B } , \theta , \boldsymbol { k } \sim \mathcal { D } } [ \lambda _ { 1 } \mathcal { L } _ { t c n } + \lambda _ { 2 } \mathcal { L } _ { l a n g u a g e } + \lambda _ { 3 } | | \mathcal { F } _ { \phi } ( I _ { i } ) | | _ { 1 } + \lambda _ { 4 } | | \mathcal { F } _ { \phi } ( I _ { i } ) | | _ { 2 } ] +$$ + +In principle, R3M can be implemented on top of any encoding architecture for $\mathcal { F } _ { \phi }$ . In our experiments we focus on the ResNet50 architecture, and we release pre-trained R3M models with ResNet18, ResNet34, and ResNet50 architectures [69], as well as the accompanying training code. During training, $\phi$ and $\theta$ are trained with an Adam optimizer to minimize Equation 3. Lastly, R3M also trains with random cropping, applied at the video level (that is, within a batch all frames from the same video are cropped identically). Please see the appendix for further implementation details. + +# 4 Experiments + +In our experiments, we aim to study how the pre-trained R3M representation can be re-used for multiple downstream robot learning tasks. First, we study if R3M enables more data efficient imitation learning on unseen environments and tasks compared to existing visual representations and learning from scratch. Second, again in the data efficient imitation learning setting, we ablate the different components of the R3M training objective and observe that all components are important for final performance. Third, we study if R3M can enable efficient real robot learning in a visually rich household setting. Finally, in the appendix, we take a deeper look at task performance of R3M and prior methods with different amounts of data, different camera viewpoints, and different tasks. + +# 4.1 Imitation Learning Evaluation Framework + +Our evaluation methodology is loosely inspired by Parisi et al. [23]. We focus on evaluating visual representations as frozen perception modules for downstream policy learning with behavior cloning. Given a pretrained visual representation $\mathcal { F } _ { \phi }$ , we form the state representation as a concatenation of the visual embedding $z _ { t } = \mathcal { F } _ { \phi } ( I _ { t } )$ and the robot proprioceptive (e.g. joint positions and velocities) reading $p _ { t }$ . The policy, $\pi$ , is trained with a standard behavior cloning loss $| | a _ { t } - \pi ( [ z _ { t } , p _ { t } ] ) | | _ { 2 } ^ { 2 }$ . We parameterize $\pi$ as a two-layer MLP preceded by a BatchNorm at the input. We train the agent for 20,000 steps, evaluate it online in the environment every 1000 steps, and report the best success rate achieved. For each visual representation and each task, we run 3 seeds of behavior cloning. The final success rate reported on a task is the average over multiple seeds, viewpoints, and demo dataset sizes. + +Comparisons and Baselines. We compare our R3M model to three existing visual representations that have been shown to be effective for control: CLIP [12] which trains image representations to be aligned with paired natural language through contrastive learning and has been shown to be useful for some manipulation [36] and navigation tasks [37], ImNet Supervised which uses features pre-trained for ImageNet classification task [2] and has been shown to be effective for reinforcement learning [38], and MoCo (345) (PVR) [23], which compresses and fuses the third, fourth, and fifth convolutional layers of a ResNet-50 model trained with MoCo [24] on ImageNet, and has been shown to be effective for imitation learning [23]. We note here that our usage of the Moco (345) model differs from the setup in Parisi et al. [23] in aspects like propreoception features, frame stacking etc. As a result, the numerical results are not directly comparable across the two works. At the same time, we emphasize that all visual representations are used in the same way within our evaluation protocol. + +![](images/79a21c838d560defeb4a965972e1188e57d21a2e6be3a512c7254c7e8cd2b130.jpg) +Figure 3: Simulated Evaluation Environments. We consider a comprehensive set of manipulation tasks in simulation (left), including 5 tasks with a Sawyer from MetaWorld [22], 5 tasks from a Franka operating over a Kitchen [21], and 2 dexterous manipulation tasks from Adroit [20], with multiple views per environment (right). + +# 4.2 Simulation Environments + +Next, we describe the environments and tasks used in our evaluations. For a comprehensive evaluation, we use three robot manipulation domains: MetaWorld [22], the Franka Kitchen environment [21], and Adroit [20] (See Figure 3). Note these environments are only used for downstream learning, and these environments and tasks are never seen during R3M training. In the MetaWorld environment we consider the tasks of assembling a ring onto a peg, picking and placing a block between bins, pushing a button, opening a drawer, and hammering a nail. In Franka Kitchen, we learn the tasks of sliding the right door open, opening the left door, turning on the light, turning the stove top knob, and opening the microwave. Finally, in Adroit we consider the tasks of reorienting the pen to the specified position, and picking and moving the ball to specified position. In all tasks, the agent is provided with image observations, as well as proprioceptive data of the robot (end-effector pose, joint positions, etc.) that is concatenated to the encoded image. All tasks involve variation, either by varying the position of the target object in MetaWorld, the positioning of the desk in Franka Kitchen, or the chosen goals in Adroit. For a robust evaluation, we consider multiple views for each environment (See Figure 3), and 3 dataset sizes: [5, 10, 25] in MetaWorld and Franka Kitchen, and [25, 50, 100] in the more challenging Adroit environments. Our comparisons measure performance for each environment and task, averaged over view, dataset size, and object or goal positions. + +# 4.3 Exp. 1: Does R3M enable efficient imitation on unseen environments and tasks? + +In this first experiment, we measure the success rate of downstream imitation learning using different visual representations. In Figure 4, we first notice that R3M is overall able to learn these vision based manipulation tasks in an extremely low data regime with ${ \approx } 6 2 \%$ success rate, despite never seeing any data from the target environments in training the representation, while outperforming learning from scratch by more than $20 \%$ . Moreover, we observe that R3M outperforms all prior representations by more than $10 \%$ on average across all 12 tasks. By training on diverse interactive video data, and with objectives that capture temporal structure and language relevance, R3M is the best performing method in all 3 environments, and on 11/12 of the tasks (See appendix for performance breakdown by task). The best two performing comparisons are CLIP and MoCo (345) (PVR), with CLIP performing better on MetaWorld, and MoCo (345) (PVR) performing better on Franka Kitchen and Adroit. Unsurprisingly, learning from scratch performs poorly in the low-data regime we study. Ultimately, we conclude that pre-trained visual representations are essential to good performance in the low-data imitation learning regime, and using R3M with diverse human video data is especially effective for learning representations useful for robotic manipulation. + +![](images/a16beebd0a9d2dddef3f5253dfafb27355ef1299f637f58e63b50fe980bb2a2f.jpg) +Figure 4: Data Efficient Imitation Learning in Unseen Environments/Tasks. We report the success rates of downstream imitation learning with standard error bars. We observe that across 12 tasks R3M outperforms baselines like MoCo (345) (PVR), CLIP, Supervised ImageNet features, and training from scratch. + +In this experiment, we seek to understand the different components of R3M, beginning with the objective. Specifically, we compare the full R3M with R3M(-Aug), which does not use crop augmentations, R3M(-L1), which does not include $L 1$ regularization, and R3M(-Lang), which does not include include the + +4.4 Exp. 2: Which components of R3M are important? + +
EnvironmentSupervisedSelf-Supervised R3M(-Lang)
R3MR3M(-Aug)R3M(-L1)
Franka Kitchen53.1 ±2.7%51.1 ±2.7%46.7 ±2.7%47.2±2.9%
MetaWorld69.2 ±2.0%68.9 ±2.1%65.0 ±2.4%67.0±2.0%
Adroit65.0 ±1.7%61.3 ±2.1%66.5 ±1.6%45.6 ±3.3%
All Domains62.4 ±1.3%60.4 ±1.4%59.4 ±1.5%53.2 ±1.5%
+ +Table 1: Ablating Components of R3M. We see report success rate of downstream imitation learning on variants of R3M. We observe that on average, removing the L1 penalty have a negative impact, particularly on the Franka Kitchen and MetaWorld environments. Lastly, removing language grounding has the most significant drop in performance, particularly on the Adroit tasks. + +video-language alignment loss. In Table 1, we report success rates per environment and averaged over all environments. First, we notice that on average across the three environments, we see a drop in performance of ${ \approx } 2 \%$ from removing crop augmentation or from removing the $L 1$ regularization. Interestingly, the impact of removing the sparsity regularization depends on the environment. In Franka Kitchen and MetaWorld, sparsity is helpful, while in Adroit removing sparsity actually helps performance slightly. We suspect this is partly due to the Adroit environment using more demonstrations, mitigating the state distribution shift issue. + +We see that across all environments, removing video-language alignment loss has the largest negative impact on performance, particularly in the Adroit environment. We hypothesize that language alignment plays an important role in better capturing semantic features that might be predictive of objects and useful for object manipulation. Nevertheless, we note that even in the fully self-supervised regime, our R3M model still outperforms prior state of the art visual representations like ImageNet trained MoCo (345) (PVR) [23] and CLIP [12] by a significant margin. + +Next, we seek to answer the question: How important is the data? To do so we include comparisons that disentangles the role of the dataset and the training objective. In particular, we have trained a MoCo model on the exact same frames of the Ego4D dataset used to train our R3M model (See Table 2). Additionally we compare to the MVP model [70], which trains a ViT-B masked auto-encoder on the Ego-soup dataset, which comprises of Ego4D and other egocentric video datasets.. We evaluate these comparisons on the Franka Kitchen and Adroit environments, and find that the MoCo-Ego4D model, which uses the same data and compute as R3M, gets an average success rate $\sim 1 0 \%$ lower than R3M in both environments. Moreover, we find the MVP models performs $\sim 2 0 \%$ worse than R3M. This suggests that while there is indeed a large benefit coming from diverse human video data compared to static ImageNet images $34 \% $ $42 \%$ on Franka), the data is not the only source of improvement, and the R3M objective provides an additional $\sim 1 0 \%$ boost in success rate. + +Table 2: Importance of Data vs. Algorithm. We find that the MoCo-Ego4D and MVP models, which leverage the same or more data and compute as R3M perform more than $10 \%$ worse. + +
FrankaAdroit
R3M53.1(2.7)65.0 (1.7)
MoCo-Ego4D42.0 (2.8)54.9 (2.7)
MVP([70])27.0 (2.6)51.4 (2.7)
+ +![](images/f81cc6e7a3927b360d7d61cf04c55603b59e5429a88c4145efe9098aa30e2d85.jpg) +Figure 5: Real World Robot Learning with R3M. With R3M we are able to learn challenging tasks like putting lettuce in the pan, pushing the cup to the goal, and folding the towel from just 20 demonstrations. See appendix for more examples of real robot tasks and details about the robot setup. + +# 4.5 Exp. 3: Does R3M enable data efficient learning in real world environments? + +Finally, we test if R3M can enable data-efficient robot learning in cluttered real-world environments. To do so, we bring a Franka Emika Panda robot into a real graduate student apartment, and aim to learn household tasks from pixels with just 20 demonstrations per task, using the pre-trained R3M representation. We have the robot complete five tasks: (1) closing a dresser drawer, (2) picking a face mask placed randomly on a desk and placing it in the dresser drawer, (3) picking up lettuce randomly placed on a cutting board and putting in a cooking pan, (4) pushing a mug to a goal location, and (5) folding a towel (See Figure 5). Like in our simulation experiments, we collect a small number of demonstrations and do simple behavior cloning with the pre-trained representation. + +In Table 3, we report the success rates comparing R3M and CLIP, one of the stronger baselines from our evaluations in simulation. We observe that while the two perform similarly on the easier task of closing the drawer, R3M consistently performs better on the other four tasks (See Figure 5), which require more precise visual representations, yielding nearly double the success rate on average. + +# 5 Limitations and Future Work + +
Success out of 10 trialsR3MCLIP
Closing Drawer Putting Mask in Dresser80% 30%70% 10%
Putting Lettuce in Pan Pushing Mug to Goal60% 70%0% 40%
Folding Towel40%0%
Average56%24%
+ +Table 3: Real World Success Rates. R3M outperforms CLIP on the challenging real world manipulation tasks. + +In this work, we set out to study if pre-training visual representations on diverse human videos can enable efficient learning of downstream robotic manipulation tasks. While we were excited by strong results on a wide set of simulated and real robotic tasks, a number of important limitations remain. Our current evaluation is limited to imitation learning, specifically behavior cloning, with a small number of task demonstrations. While we would hope to see R3M be equally beneficial for other robotic learning settings like reinforcement learning, it could be the case that a good pretrained representation for RL is not the same as a good pre-trained representation for imitation. Studying how R3M performs in RL settings, and changes that may need to made to improve its performance is an exciting next step. The current R3M model also only provides a single-frame state representation. In principle, pre-training on human videos should be able to go beyond state representations (e.g. reward learning and task specification). Studying if R3M embeddings or the language grounding module can provide a useful reward signal is an interesting direction for future work. + +# Acknowledgments + +The authors would like to thank the Ego4D team at Meta AI for assistance in using the dataset. We’d also like to thank Karl Pertsch, Simone Parisi, Sidd Karamcheti, and numerous members of Meta AI and the IRIS labs for valuable discussions. This work is in part supported by ONR grant N00014-22-1-2621. Finally, the authors would also like to thank Evan Coleman for assistance with the robot. + +# References + +[1] S. Levine, C. Finn, T. Darrell, and P. Abbeel. End-to-end training of deep visuomotor policies. The Journal of Machine Learning Research, 17(1):1334–1373, 2016. +[2] J. Deng, W. Dong, R. Socher, L.-J. Li, K. Li, and L. Fei-Fei. ImageNet: A Large-Scale Hierarchical Image Database. In CVPR09, 2009. +[3] D. Mzurikwao, M. Khan, O. Samuel, J. Cinatl, M. Wass, M. Michaelis, G. Marcelli, and C. S. Ang. Towards image-based cancer cell lines authentication using deep neural networks. Scientific Reports, 10, 11 2020. doi:10.1038/s41598-020-76670-6. +[4] J. Devlin, M.-W. Chang, K. Lee, and K. Toutanova. BERT: Pre-training of deep bidirectional transformers for language understanding. In Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies (NAACL-HLT), Minneapolis, Minnesota, June 2019. Association for Computational Linguistics. +[5] Z. Zhang, J. Liu, and N. Razavian. BERT-XML: Large scale automated ICD coding using BERT pretraining. In Proceedings of the 3rd Clinical Natural Language Processing Workshop, pages 24–34, Online, Nov. 2020. Association for Computational Linguistics. doi:10.18653/v1/ 2020.clinicalnlp-1.3. URL https://aclanthology.org/2020.clinicalnlp-1.3. +[6] Z. Yang, N. Garcia, C. Chu, M. Otani, Y. Nakashima, and H. Takemura. Bert representations for video question answering. In 2020 IEEE Winter Conference on Applications of Computer Vision (WACV), pages 1545–1554, 2020. doi:10.1109/WACV45572.2020.9093596. +[7] S. Dasari, F. Ebert, S. Tian, S. Nair, B. Bucher, K. Schmeckpeper, S. Singh, S. Levine, and C. Finn. Robonet: Large-scale multi-robot learning. In Conference on Robot Learning, 2019. +[8] A. Mandlekar, J. Booher, M. Spero, A. Tung, A. Gupta, Y. Zhu, A. Garg, S. Savarese, and L. Fei-Fei. Scaling robot supervision to hundreds of hours with roboturk: Robotic manipulation dataset through human reasoning and dexterity. In 2019 IEEE/RSJ International Conference on Intelligent Robots and Systems (IROS), pages 1048–1055. IEEE, 2019. +[9] S. Young, D. Gandhi, S. Tulsiani, A. Gupta, P. Abbeel, and L. Pinto. Visual imitation made easy. In CoRL, 2020. +[10] F. Ebert, Y. Yang, K. Schmeckpeper, B. Bucher, G. Georgakis, K. Daniilidis, C. Finn, and S. Levine. Bridge data: Boosting generalization of robotic skills with cross-domain datasets. ArXiv, abs/2109.13396, 2021. +[11] T. B. Brown et al. Language models are few-shot learners. arXiv:2005.14165, 2020. +[12] A. Radford, J. W. Kim, C. Hallacy, A. Ramesh, G. Goh, S. Agarwal, G. Sastry, A. Askell, P. Mishkin, J. Clark, G. Krueger, and I. Sutskever. Learning transferable visual models from natural language supervision. In ICML, 2021. +[13] P. Goyal, Q. Duval, I. Seessel, M. Caron, I. Misra, L. Sagun, A. Joulin, and P. Bojanowski. Vision models are more robust and fair when pretrained on uncurated images without supervision. ArXiv, abs/2202.08360, 2022. +[14] R. Goyal, S. Ebrahimi Kahou, V. Michalski, J. Materzynska, S. Westphal, H. Kim, V. Haenel, I. Fruend, P. Yianilos, M. Mueller-Freitag, et al. The” something something” video database for learning and evaluating visual common sense. In Proceedings of the IEEE International Conference on Computer Vision, pages 5842–5850, 2017. +[15] D. Damen, H. Doughty, G. M. Farinella, S. Fidler, A. Furnari, E. Kazakos, D. Moltisanti, J. Munro, T. Perrett, W. Price, and M. Wray. Scaling egocentric vision: The epic-kitchens dataset. In European Conference on Computer Vision (ECCV), 2018. +[16] K. Grauman et al. Ego4D: Around the World in 3,000 Hours of Egocentric Video, 2021. +[17] L. Shao, T. Migimatsu, Q. Zhang, K. Yang, and J. Bohg. Concept2robot: Learning manipulation concepts from instructions and human demonstrations. In Proceedings of Robotics: Science and Systems (RSS), 2020. +[18] A. S. Chen, S. Nair, and C. Finn. Learning generalizable robotic reward functions from ”in-the-wild” human videos. ArXiv, abs/2103.16817, 2021. +[19] P. Sermanet, C. Lynch, Y. Chebotar, J. Hsu, E. Jang, S. Schaal, and S. Levine. Time-contrastive networks: Self-supervised learning from video. Proceedings of International Conference in Robotics and Automation (ICRA), 2018. +[20] A. Rajeswaran, V. Kumar, A. Gupta, J. Schulman, E. Todorov, and S. Levine. Learning complex dexterous manipulation with deep reinforcement learning and demonstrations. ArXiv, abs/1709.10087, 2018. +[21] A. Gupta, V. Kumar, C. Lynch, S. Levine, and K. Hausman. Relay policy learning: Solving long-horizon tasks via imitation and reinforcement learning. In CoRL, 2019. +[22] T. Yu, D. Quillen, Z. He, R. Julian, K. Hausman, C. Finn, and S. Levine. Meta-world: A benchmark and evaluation for multi-task and meta reinforcement learning. In Conference on Robot Learning, 2020. +[23] S. Parisi, A. Rajeswaran, S. Purushwalkam, and A. K. Gupta. The unsurprising effectiveness of pre-trained vision models for control. 2022. +[24] K. He, H. Fan, Y. Wu, S. Xie, and R. B. Girshick. Momentum contrast for unsupervised visual representation learning. 2020 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), pages 9726–9735, 2020. +[25] M. Laskin, K. Lee, A. Stooke, L. Pinto, P. Abbeel, and A. Srinivas. Reinforcement learning with augmented data. ArXiv, abs/2004.14990, 2020. +[26] A. Srinivas, M. Laskin, and P. Abbeel. Curl: Contrastive unsupervised representations for reinforcement learning. In ICML, 2020. +[27] I. Kostrikov, D. Yarats, and R. Fergus. Image augmentation is all you need: Regularizing deep reinforcement learning from pixels. ArXiv, abs/2004.13649, 2021. +[28] J. Pari, N. M. M. Shafiullah, S. P. Arunachalam, and L. Pinto. The surprising effectiveness of representation learning for visual imitation. ArXiv, abs/2112.01511, 2021. +[29] C. Gelada, S. Kumar, J. Buckman, O. Nachum, and M. G. Bellemare. Deepmdp: Learning continuous latent space models for representation learning. ArXiv, abs/1906.02736, 2019. +[30] D. Hafner, T. P. Lillicrap, J. Ba, and M. Norouzi. Dream to control: Learning behaviors by latent imagination. ArXiv, abs/1912.01603, 2020. +[31] A. Zhang, R. McAllister, R. Calandra, Y. Gal, and S. Levine. Learning invariant representations for reinforcement learning without reconstruction. ArXiv, abs/2006.10742, 2021. +[32] S. Nair, S. Savarese, and C. Finn. Goal-aware prediction: Learning to model what matters. ArXiv, abs/2007.07170, 2020. +[33] M. Hong, K. Lee, M. Kang, W. Jung, and S. Oh. Dynamics-aware metric embedding: Metric learning in a latent space for visual planning. IEEE Robotics and Automation Letters, 2022. +[34] R. Jonschkowski and O. Brock. Learning state representations with robotic priors. Autonomous Robots, 39:407–428, 10 2015. doi:10.1007/s10514-015-9459-7. +[35] Y.-C. Lin, A. Zeng, S. Song, P. Isola, and T.-Y. Lin. Learning to see before learning to act: Visual pre-training for manipulation. 2020 IEEE International Conference on Robotics and Automation (ICRA), pages 7286–7293, 2020. +[36] M. Shridhar, L. Manuelli, and D. Fox. Cliport: What and where pathways for robotic manipulation. In CoRL, 2021. +[37] A. Khandelwal, L. Weihs, R. Mottaghi, and A. Kembhavi. Simple but effective: Clip embeddings for embodied ai. ArXiv, abs/2111.09888, 2021. +[38] R. Shah and V. Kumar. Rrl: Resnet as representation for reinforcement learning. ArXiv, abs/2107.03380, 2021. +[39] Y. Seo, K. Lee, S. James, and P. Abbeel. Reinforcement learning with action-free pre-training from videos. ArXiv, abs/2203.13880, 2022. +[40] T. Xiao, I. Radosavovic, T. Darrell, and J. Malik. Masked visual pre-training for motor control. 2022. +[41] Y. Liu, A. Gupta, P. Abbeel, and S. Levine. Imitation from observation: Learning to imitate behaviors from raw video via context translation. In 2018 IEEE International Conference on Robotics and Automation (ICRA), pages 1118–1125. IEEE, 2018. +[42] P. Sharma, D. Pathak, and A. Gupta. Third-person visual imitation learning via decoupled hierarchical controller. In NeurIPS, 2019. +[43] L. Smith, N. Dhawan, M. Zhang, P. Abbeel, and S. Levine. AVID: Learning Multi-Stage Tasks via Pixel-Level Translation of Human Videos. In Proceedings of Robotics: Science and Systems, Corvalis, Oregon, USA, July 2020. +[44] T. Yu, C. Finn, S. Dasari, A. Xie, T. Zhang, P. Abbeel, and S. Levine. One-shot imitation from observing humans via domain-adaptive meta-learning. In Proceedings of Robotics: Science and Systems, Pittsburgh, Pennsylvania, June 2018. +[45] K. Schmeckpeper, A. Xie, O. Rybkin, S. Tian, K. Daniilidis, S. Levine, and C. Finn. Learning predictive models from observation and interaction. In ECCV, 2020. +[46] A. D. Edwards and C. L. Isbell. Perceptual values from observation. arXiv preprint arXiv:1905.07861, 2019. +[47] K. Schmeckpeper, O. Rybkin, K. Daniilidis, S. Levine, and C. Finn. Reinforcement learning with videos: Combining offline observations with interaction. In CoRL, 2020. +[48] R. Scalise, J. Thomason, Y. Bisk, and S. Srinivasa. Improving robot success detection using static object data. In Proceedings of the 2019 IEEE/RSJ International Conference on Intelligent Robots and Systems, 2019. +[49] S. Pirk, M. Khansari, Y. Bai, C. Lynch, and P. Sermanet. Online object representations with contrastive learning, 2019. +[50] H. Xiong, Q. Li, Y.-C. Chen, H. Bharadhwaj, S. Sinha, and A. Garg. Learning by watching: Physical imitation of manipulation skills from human videos, 2021. +[51] N. Das, S. Bechtle, T. Davchev, D. Jayaraman, A. Rai, and F. Meier. Model-based inverse reinforcement learning from visual demonstrations, 2021. +[52] K. Zakka, A. Zeng, P. Florence, J. Tompson, J. Bohg, and D. Dwibedi. Xirl: Cross-embodiment inverse reinforcement learning, 2021. +[53] S. Stepputtis, J. Campbell, M. Phielipp, S. Lee, C. Baral, and H. B. Amor. Language-conditioned imitation learning for robot manipulation tasks. ArXiv, abs/2010.12083, 2020. +[54] C. Lynch and P. Sermanet. Grounding language in play. ArXiv, abs/2005.07648, 2020. +[55] Y. Cui, S. Niekum, A. Gupta, V. Kumar, and A. Rajeswaran. Can Foundation Models Perform Zero-Shot Task Specification For Robot Manipulation? In L4DC, 2022. +[56] S. Nair, E. Mitchell, K. Chen, B. Ichter, S. Savarese, and C. Finn. Learning language-conditioned robot behavior from offline data and crowd-sourced annotation. In CoRL, 2021. +[57] L. Pinto and A. Gupta. Supersizing self-supervision: Learning to grasp from 50k tries and 700 robot hours. In IEEE international conference on robotics and automation (ICRA), 2016. +[58] P. Sharma, L. Mohan, L. Pinto, and A. K. Gupta. Multiple interactions made easy (mime): Large scale demonstrations data for imitation. In CoRL, 2018. +[59] E. Jang, A. Irpan, M. Khansari, D. Kappler, F. Ebert, C. Lynch, S. Levine, and C. Finn. Bcz: Zero-shot task generalization with robotic imitation learning. In A. Faust, D. Hsu, and G. Neumann, editors, Proceedings of the 5th Conference on Robot Learning, volume 164 of Proceedings of Machine Learning Research, pages 991–1002. PMLR, 08–11 Nov 2022. URL https://proceedings.mlr.press/v164/jang22a.html. +[60] X. Wang and A. K. Gupta. Unsupervised learning of visual representations using videos. 2015 IEEE International Conference on Computer Vision (ICCV), pages 2794–2802, 2015. +[61] P. Sermanet, K. Xu, and S. Levine. Unsupervised perceptual rewards for imitation learning. Proceedings of Robotics: Science and Systems (RSS), 2017. +[62] X. Wang, A. Jabri, and A. A. Efros. Learning correspondence from the cycle-consistency of time. 2019 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), pages 2561–2571, 2019. +[63] A. Jabri, A. Owens, and A. A. Efros. Space-time correspondence as a contrastive random walk. ArXiv, abs/2006.14613, 2020. +[64] M. Goyal, S. Modi, R. Goyal, and S. Gupta. Human hands as probes for interactive object understanding. In Computer Vision and Pattern Recognition (CVPR), 2022. +[65] A. Miech, D. Zhukov, J.-B. Alayrac, M. Tapaswi, I. Laptev, and J. Sivic. Howto100m: Learning a text-video embedding by watching hundred million narrated video clips. 2019 IEEE/CVF International Conference on Computer Vision (ICCV), pages 2630–2640, 2019. +[66] H. Xu, G. Ghosh, P.-Y. Huang, D. Okhonko, A. Aghajanyan, and F. M. L. Z. C. Feichtenhofer. Videoclip: Contrastive pre-training for zero-shot video-text understanding. ArXiv, abs/2109.14084, 2021. +[67] A. van den Oord, Y. Li, and O. Vinyals. Representation learning with contrastive predictive coding. ArXiv, abs/1807.03748, 2018. +[68] S. Ross, G. J. Gordon, and J. A. Bagnell. A reduction of imitation learning and structured prediction to no-regret online learning. In AISTATS, 2011. +[69] K. He, X. Zhang, S. Ren, and J. Sun. Deep residual learning for image recognition. 2016 IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pages 770–778, 2016. +[70] I. Radosavovic, T. Xiao, S. James, P. Abbeel, J. Malik, and T. Darrell. Real-world robot learning with masked visual pre-training. CoRL, 2022. +[71] V. Sanh, L. Debut, J. Chaumond, and T. Wolf. Distilbert, a distilled version of bert: smaller, faster, cheaper and lighter. ArXiv, abs/1910.01108, 2019. + +# A R3M Training Details + +# A.1 Data Preprocessing + +The Ego4D dataset consists of several hour long videos within a certain scene. Within each scene, there are many sub-clips, each with a natural language annotation. R3M trains with these shorter video clips paired with language annotations. + +For faster training R3M parses each video clip into frames (Resized and cropped to $2 2 4 \mathbf { x } 2 2 4 )$ and samples frames from a video clip individually. See the codebase for more details on the implementation of sampling the videos. + +# A.2 Training Architecture and Hyper-Parameters + +R3M can in principle be trained with any visual encoding architecture for $\mathcal { F } _ { \phi }$ . We train with off the shelf ResNet18, 34, and 50 [69], as implemented by torchvision.models. + +The language prediction head is implemented as an 5 layer MLP with sizes $[ 2 ^ { * } E + L$ , 1024, 1024, 1024, 1024] and output a scalar score, where $E$ is the output dimension of $\mathcal { F } _ { \phi }$ and $L$ is the output dimension of the DistilBERT [71] sentence encoder (768) from HuggingFace transformers. + +During training of R3M, we use batch sizes of 16 video clips (where 5 frames are samples from each video clip: an initial image, final image, and sequence of 3 frames). The initial and final frames are sampled from the first and last $20 \%$ of the video clip. + +R3M models are trained for one million steps in our experiments, and for 1.5 million steps in our released models, with a learning rate of 0.0001. + +For the training objective in Equation 3, we use hyperparameters $\lambda _ { 1 } ~ = ~ 1 , \lambda _ { 2 } ~ = ~ 1 , \lambda _ { 3 } ~ =$ $0 . 0 0 0 0 1 , \lambda _ { 4 } = 0 . 0 0 0 0 1$ . + +# A.3 Additional Implementation Details + +In practice, we use more than one negative video example in training Equations 1 and 2. Instead we use 3 negative examples, sampled from different videos in the batch. + +Additionally in training for Equation 2, we consider the following positive pairs within a single batch element: Initial and Final Frames $( I _ { 0 } , I _ { g } )$ , $\left( I _ { 0 } , I _ { j > i } \right)$ , and $\left( I _ { 0 } , I _ { k > j } \right)$ , with corresponding negatives $( I _ { 0 } , I _ { 0 } )$ , $( I _ { 0 } , I _ { i } )$ , and $( I _ { 0 } , I _ { j } )$ respectively. Using a larger number of positive examples from a single video and multiple negative examples from different videos stabilizes training. + +# A.4 Example Usage + +Using R3M is simple. The codebase is located at https://github.com/facebookresearch/r3m. Simply clone the repo and install via pip install -e . Then R3M can be loaded by running: + +from r3m import load_r3m 2 r3m $=$ load_r3m (" resnet50 ") # resnet18 , resnet34 3 r3m . eval () + +# B Evaluation Details + +# B.1 Simulation Environments + +We focus on three simulation environments: Franka Kitchen, MetaWorld, and Adroit. + +Franka Kitchen. The Franka Kitchen environments used in this paper are modified from the original environment; specifically, we add additional randomization to the scene. We randomly change the position of the kitchen between episodes, making the task significantly more challenging both in perception and control. + +The 5 tasks in the Franka Kitchen involve opening the left door, opening the sliding door, turning on the light, turning the knob, and opening the microwave. All Franka tasks include proprioceptive data of the arm joint positions and gripper positions. The horizon for all Franka tasks is 50 steps, and our imitation experiments use either 5, 10, or 25 demos. + +![](images/3b7ced0832de197b999498df4d487e291caf9cea608c36ac3e4808a43e0ce415.jpg) +Figure 6: Real World Robot Learning with R3M. With R3M we are able to learn challenging tasks like closing the drawer, putting the mask in the dresser, putting lettuce in the pan, pushing the cup to the goal, and folding the towel from just 20 demonstrations. + +MetaWorld. The MetaWorld environments are the standard V2 Button Pressing, Bin Picking, Drawer Opening, Hammer, and Assembly environments available in MetaWorld [22]. In all tasks, the target object (drawer, peg, block, etc.) position is randomized between episodes. + +All MetaWorld tasks include proprioceptive data of the gripper end effector pose and gripper open/- close. The horizon for all MetaWorld tasks is 500 steps, and our imitation experiments use either 5, 10, or 25 demos. + +Adroit. We use the standard Pen and Relocate tasks in the Adroit hand manipulation suite. The goal position of the pen and the goal position of the ball are randomized between episodes, and specified visually. + +All Adroit tasks include proprioceptive data of the hand joints, and in the Relocate task also includes the global position of the hand. The horizon for the Pen task is 100 steps and for the Relocate task is 200 steps. Our imitation experiments use either 25, 50, or 100 demos. + +# B.2 Real World Environments + +Our real world experiments involve bringing a Franka Emika Panda robot into a real graduate student apartment. The tasks involve putting lettuce in a pan in the kitchen, pushing a mug to a goal position on a dining table, closing a drawer, putting a mask in a drawer, and folding a towel (See Figure 6). All tasks involve randomization (e.g. the towel/lettuce/mug/mask position or drawer position). The initial state of the gripper is also randomized each episode. + +![](images/789191667ec3f87a5dc905d3b8489fb17f9b44264a3662234df19f530713515f.jpg) +Figure 7: Real Robot Camera Viewpoints. Camera view used for learning each of the real robot tasks. + +The robot observation includes RGB images froma USB webcam, positioned differently for each task (See Figure 7). The robot end effector position is also concatenated with the image embedding during imitation learning. + +# B.3 Demo Data Collection + +In the Franka Kitchen and Adroit tasks, expert data is generated by training a state based agent with model free RL [20]. The state based trajectories are then replayed and rendered with image observations. + +In the MetaWorld environment, a heuristic policy using state information is used to generate expert data, which is then replayed and rendered with image observations. + +On the real robot, demonstrations are collected by a human tele-operator with a PlayStation controller. The control is applied directly in the end effector Cartesian space, and the demo trajectories are directly saved with visual observations. + +# B.4 Comparisons + +In all experiments all models use a ResNet50 base architecture. + +CLIP: The CLIP comparison uses the of the shelf CLIP RN50 model available at https://github. +com/openai/CLIP. + +ImNet Supervised: This comparison uses the default ResNet architecture available from torchvision.models with pretrained $\cdot ^ { = }$ True. + +MoCo (345): This comparison uses a pre-trained MoCo model on Imagenet which fuses the third, fourth, and fifth convolutional layers as proposed in [23]. + +Note that our usage of the Moco (345) model differs from the setup in Parisi et al. [23] in aspects like proprioception features, frame stacking etc. As a result, the numerical results are not directly comparable across the two works. + +Scratch: uses the default ResNet architecture available from torchvision.models with pretrained $\equiv$ False. Additionally, it lets gradients from the behavior cloning MSE loss pass into the visual encoder. + +MoCo-Ego4D: This comparison uses a pre-trained MoCo model on the samed data as R3M from the Ego4D dataset. + +MVP: This comparison uses a pretrained MVP [40, 70] model, which trains an MAE with a ViT-B architecture on the Ego-Soup dataset, which consists of Ego4D and other egocentric human video datasets. + +# B.5 Behavior Cloning Hyperparameters + +The downstream policy is a 2 layer MLP with hidden sizes [256,256] preceded by a BatchNorm. The input to the policy is the concatenated visual embedding and proprioceptive data, and the output is + +![](images/f7a1c5a5f61715b2ab56840e2bcc414d37baf35815ccf41900561354230647f6.jpg) +Figure 8: Performance over different views/dataset sizes. We report the success rate of R3M and baseline across each view (left) and dataset size (right). We see that the performance improvement from R3M is consistent across all views. We also observe that while absolute performance increases with more demos, the performance improvement from R3M is consistent across all demo sizes. + +the action. The policy is trained with a learning rate of 0.001, and a batch size of 32 for 20000 steps, evaluating every 1000. + +# C Additional Results + +# C.1 How does performance vary across viewpoint and demo dataset size? + +In our next experiment, we take a closer look at R3M performance compared to prior methods across viewpoints and dataset sizes. In Figure 8, we plot the average success rate of each method across each dataset size and viewpoint. We observe that the performance improvement of R3M is consistent across all viewpoints, and it is the highest performing representation in all cases. Interestingly, we see that the same does not hold amongst the prior methods, where the ranking between MoCo (345) and CLIP changes based on the chosen viewpoint. + +Additionally, we also study the impact of dataset size for imitation learning. Again, we observe that the performance improvement from R3M is consistent, outperforming the baselines across every environment and demo dataset size. We observe that in the Franka Kitchen and Adroit environments, the performance gain from R3M stays consistent with increase in dataset size, even as the absolute performance of all methods improves. Overall, we clearly observe that the performance benefit of R3M is not tied to a specific viewpoint or dataset size. + +# C.2 Performance Breakdown By Task + +In Figure 9 we report the success rate on each task individually. Note each success rate for each method is still the average over 3 views, 3 demo sizes, and 3 seeds. We observe that on 11/12 tasks R3M is the highest performing method. + +![](images/19f22ab8667bc2542e959c946f96a8f6adc68e026fea187148f6dfa6449e439f.jpg) +Assembly, Bin Picking, Button Pressing, Drawer Opening, Hammering +Sliding Door, Turning Light On, Opening Door, Turning Knob, Opening Microwave +Figure 9: Per task Success Rate. We observe that R3M is the highest performing method on 11/12 tasks. \ No newline at end of file diff --git a/md/dev/to3qCB3tOh9/to3qCB3tOh9.md b/md/dev/to3qCB3tOh9/to3qCB3tOh9.md new file mode 100644 index 0000000000000000000000000000000000000000..0cdfbb954e3c965fe385f0f28fb30b1244e31b82 --- /dev/null +++ b/md/dev/to3qCB3tOh9/to3qCB3tOh9.md @@ -0,0 +1,672 @@ +# PROTEIN REPRESENTATION LEARNING BY GEOMETRIC STRUCTURE PRETRAINING + +Zuobai Zhang1,2, Minghao $\mathbf { X } \mathbf { u } ^ { 1 , 2 }$ , Arian Jamasb3, Vijil Chenthamarakshan4, Aurélie Lozano4, Payel Das4, Jian Tang1,5,6 + +Mila - Québec AI Institute1, Université de Montréal2, University of Cambridge3 IBM Research4, HEC Montréal5, CIFAR AI Chair6 {zuobai.zhang, minghao.xu}@mila.quebec, arj39@cam.ac.uk {ecvijil,aclozano,daspa}@us.ibm.com, jian.tang@hec.ca + +# ABSTRACT + +Learning effective protein representations is critical in a variety of tasks in biology such as predicting protein function or structure. Existing approaches usually pretrain protein language models on a large number of unlabeled amino acid sequences and then finetune the models with some labeled data in downstream tasks. Despite the effectiveness of sequence-based approaches, the power of pretraining on known protein structures, which are available in smaller numbers only, has not been explored for protein property prediction, though protein structures are known to be determinants of protein function. In this paper, we propose to pretrain protein representations according to their 3D structures. We first present a simple yet effective encoder to learn the geometric features of a protein. We pretrain the protein graph encoder by leveraging multiview contrastive learning and different self-prediction tasks. Experimental results on both function prediction and fold classification tasks show that our proposed pretraining methods outperform or are on par with the state-of-the-art sequence-based methods, while using much less pretraining data. Our implementation is available at https://github.com/ DeepGraphLearning/GearNet. + +# 1 INTRODUCTION + +Proteins are workhorses of the cell and are implicated in a broad range of applications ranging from therapeutics to material. They consist of a linear chain of amino acids (residues) which fold into specific conformations. Due to the advent of low cost sequencing technologies (Ma & Johnson, 2012; Ma, 2015), in recent years a massive volume of protein sequences have been newly discovered. As functional annotation of a new protein sequence remains costly and time-consuming, accurate and efficient in silico protein function annotation methods are needed to bridge the existing sequence-function gap. + +Since a large number of protein functions are governed by their folded structures, several datadriven approaches rely on learning representations of the protein structures, which then can be used for a variety of tasks such as protein design (Ingraham et al., 2019; Strokach et al., 2020; Cao et al., 2021; Jing et al., 2021), structure classification (Hermosilla et al., 2021), model quality assessment (Baldassarre et al., 2021; Derevyanko et al., 2018), and function prediction (Gligorijevic´ et al., 2021). Due to the challenge of experimental protein structure determination, the number of reported protein structures is orders of magnitude lower than the size of datasets in other machine learning application domains. For example, there are 182K experimentally-determined structures in the Protein Data Bank (PDB) (Berman et al., 2000) vs 47M protein sequences in Pfam (Mistry et al., 2021) and vs 10M annotated images in ImageNet (Russakovsky et al., 2015). + +To address this gap, recent works have leveraged the large volume of unlabeled protein sequence data to learn an effective representation of known proteins (Bepler & Berger, 2019; Rives et al., 2021; Elnaggar et al., 2021). A number of studies have pretrained protein encoders on millions of sequences via self-supervised learning. However, these methods neither explicitly capture nor leverage the available protein structural information that is known to be the determinants of protein functions. + +To better utilize structural information, several structure-based protein encoders (Hermosilla et al., 2021; Hermosilla & Ropinski, 2022; Wang et al., 2022a) have been proposed. However, these models have not explicitly captured the interactions between edges, which are critical in protein structure modeling (Jumper et al., 2021). Besides, very few attempts (Hermosilla & Ropinski, 2022; Chen et al., 2022; Guo et al., 2022) have been made until recently to develop pretraining methods that exploit unlabeled 3D structures due to the scarcity of experimentally-determined protein structures. Thanks to recent advances in highly accurate deep learning-based protein structure prediction methods (Baek et al., 2021; Jumper et al., 2021), it is now possible to efficiently predict structures for a large number of protein sequences with reasonable confidence. + +Motivated by this development, we develop a protein encoder pretrained on the largest possible number1 of protein structures that is able to generalize to a variety of property prediction tasks. We propose a simple yet effective structure-based encoder called GeomEtry-Aware Relational Graph Neural Network (GearNet), which encodes spatial information by adding different types of sequential or structural edges and then performs relational message passing on protein residue graphs. Inspired by the design of triangle attention in Evoformer (Jumper et al., 2021), we propose a sparse edge message passing mechanism to enhance the protein structure encoder, which is the first attempt to incorporate edge-level message passing on GNNs for protein structure encoding. + +We further introduce a geometric pretraining method to learn the protein structure encoder based on the popular contrastive learning framework (Chen et al., 2020). We propose novel augmentation functions to discover biologically correlated protein substructures that co-occur in proteins (Ponting & Russell, 2002) and aim to maximize the similarity between the learned representations of substructures from the same protein, while minimizing the similarity between those from different proteins. Simultaeneously, we propose a suite of straightforward baselines based on self-prediction (Devlin et al., 2018). These pretraining tasks perform masked prediction of different geometric or physicochemical attributes, such as residue types, Euclidean distances, angles and dihedral angles. Through extensively benchmarking these pretraining techniques on diverse downstream property prediction tasks, we set up a solid starting point for pretraining protein structure representations. + +Extensive experiments on several benchmarks, including Enzyme Commission number prediction (Gligorijevic et al., 2021), Gene Ontology term prediction (Gligorijevi ´ c et al., 2021), fold ´ classification (Hou et al., 2018) and reaction classification (Hermosilla et al., 2021) verify our GearNet augmented with edge message passing can consistently outperform existing protein encoders on most tasks in a supervised setting. Further, by employing the proposed pretraining method, our model trained on fewer than a million samples achieves comparable or even better results than the state-of-the-art sequence-based encoders pretrained on million- or billion-scale datasets. + +# 2 RELATED WORK + +Previous works seek to learn protein representations based on different modalities of proteins, including amino acid sequences (Rao et al., 2019; Elnaggar et al., 2021; Rives et al., 2021), multiple sequence alignments (MSAs) (Rao et al., 2021; Biswas et al., 2021; Meier et al., 2021) and protein structures (Hermosilla et al., 2021; Gligorijevic et al., 2021; Somnath et al., 2021). These works share ´ the common goal of learning informative protein representations that can benefit various downstream applications, like predicting protein function (Rives et al., 2021) and protein-protein interaction (Wang et al., 2019), as well as designing protein sequences (Biswas et al., 2021). + +Compared with sequence-based methods, structure-based methods should be, in principle, a better solution to learning an informative protein representation, as the function of a protein is determined by its structure. This line of works seeks to encode spatial information in protein structures by 3D CNNs (Derevyanko et al., 2018) or graph neural networks (GNNs) (Gligorijevic et al., 2021; ´ Baldassarre et al., 2021; Jing et al., 2021; Wang et al., 2022a; Aykent & Xia, 2022). Among these methods, IEConv (Hermosilla et al., 2021) tries to fit the inductive bias of protein structure modeling, which introduced a graph convolution layer incorporating intrinsic and extrinsic distances between nodes. Another potential direction is to extract features from protein surfaces (Gainza et al., 2020; Sverrisson et al., 2021; Dai & Bailey-Kellogg, 2021). Somnath et al. (2021) combined the advantages of both worlds and proposed a parameter-efficient multi-scale model. Besides, there are also works that enhance pretrained sequence-based models by incorporating structural information in the pretraining stage (Bepler & Berger, 2021) or finetuning stage (Wang et al., 2022b). + +Despite progress in the design of structure-based encoders, there are few works focusing on structurebased pretraining for proteins. To the best of our knowledge, the only attempt is three concurrent works (Hermosilla & Ropinski, 2022; Chen et al., 2022; Guo et al., 2022), which apply contrastive learning, self-prediction and denoising score matching methods on a small set of tasks, respectively. Compared with these existing works, our proposed encoder is conceptually simpler and more effective on many different tasks, thanks to the proposed relational graph convolutional layer and edge message passing layer, which are able to efficiently capture both the sequential and structural information. Furthermore, we introduce a contrastive learning framework with novel augmentation functions to discover substructures in different proteins and four different self-prediction tasks, which can serve as a solid starting point for enabling self-supervised learning on protein structures. + +# 3 STRUCTURE-BASED PROTEIN ENCODER + +Existing protein encoders are either designed for specific tasks or cumbersome for pretraining due to the dependency on computationally expensive convolutions. In contrast, here we propose a simple yet effective protein structure encoder, named GeomEtry-Aware Relational Graph Neural Network (GearNet). We utilize sparse edge message passing to enhance the effectiveness of GearNet, which is novel and crucial in the field of protein structure modeling, whereas previous works (Hermosilla et al., 2021; Somnath et al., 2021) only consider message passing among residues or atoms. + +# 3.1 GEOMETRY-AWARE RELATIONAL GRAPH NEURAL NETWORK + +Given protein structures, our model aims to learn representations encoding their spatial and chemical information. These representations should be invariant under translations, rotations and reflections in 3D space. To achieve this requirement, we first construct our protein graph based on spatial features invariant under these transformations. + +Protein graph construction. We represent the structure of a protein as a residue-level relational graph $\mathcal { G } = ( \nu , \mathcal { E } , \mathcal { R } )$ , where $\nu$ and $\mathcal { E }$ denotes the set of nodes and edges respectively, and $\mathcal { R }$ is the set of edge types. We use $( i , j , r )$ to denote the edge from node $i$ to node $j$ with type $r$ . We use $n$ and $m$ to denote the number of nodes and edges, respectively. In this work, each node in the protein graph represents the alpha carbon of a residue with the 3D coordinates of all nodes $\mathbf { { x } } \in \mathbb { R } ^ { n \times 3 }$ . We use $f _ { i }$ and $\mathbf { \Delta } f _ { ( i , j , r ) }$ to denote the feature for node $i$ and edge $( i , j , r )$ , respectively, in which reside types, sequential and spatial distances are considered. + +Then, we add three different types of directed edges into our graphs: sequential edges, radius edges and $\mathbf { K }$ -nearest neighbor edges. Among these, sequential edges will be further divided into 5 types of edges based on the relative sequential distance $\bar { d ^ { \cdot } } \in \{ - 2 , - \bar { 1 } , 0 , 1 , 2 \}$ between two end nodes, where we add sequential edges only between the nodes within the sequential distance of 2. These edge types reflect different geometric properties, which all together yield a comprehensive featurization of proteins. More details of the graph and feature construction process can be found in Appendix C.1. + +Relational graph convolutional layer. Upon the protein graphs defined above, we utilize a GNN to derive per-residue and whole-protein representations. One simple example of GNNs is the GCN (Kipf & Welling, 2017), where messages are computed by multiplying node features with a convolutional kernel matrix shared among all edges. To increase the capacity in protein structure modeling, IEConv (Hermosilla et al., 2021) proposed to apply a learnable kernel function on edge features. In this way, $m$ different kernel matrices can be applied on different edges, which achieves good performance but induces high memory costs. + +To balance model capacity and memory cost, we use a relational graph convolutional neural network (Schlichtkrull et al., 2018) to learn graph representations, where a convolutional kernel matrix is shared within each edge type and there are $| \mathcal { R } |$ different kernel matrices in total. Formally, the relational graph convolutional layer used in our model is defined as + +$$ +h _ { i } ^ { ( 0 ) } = f _ { i } , \quad { \boldsymbol u } _ { i } ^ { ( l ) } = \sigma \left( \mathrm { B N } \left( \sum _ { r \in \mathcal { R } } W _ { r } \sum _ { j \in { \cal N } _ { r } ( i ) } { h } _ { j } ^ { ( l - 1 ) } \right) \right) , \quad h _ { i } ^ { ( l ) } = h _ { i } ^ { ( l - 1 ) } + { \boldsymbol u } _ { i } ^ { ( l ) } . +$$ + +Specifically, we use node features $f _ { i }$ as initial representations. Then, given the node representation h(l) for node $i$ at the $l$ -th layer, we compute updated node representation $\mathbf { \Delta } _ { \mathbf { \boldsymbol { u } } _ { i } ^ { ( l ) } }$ by aggregating features from neighboring nodes $\dot { \mathcal { N } _ { r } } ( i )$ , where $\bar { \mathcal { N } } _ { r } ( i ) \bar { = } \{ j \in \mathcal { V } | ( j , i , r ) \in \mathcal { E } \}$ denotes the neighborhood of node $i$ with the edge type $r$ , and $W _ { r }$ denotes the learnable convolutional kernel matrix for edge type $r$ . Here BN denotes a batch normalization layer and we use a ReLU function as the activation $\sigma ( \cdot )$ . Finally, we update ${ h } _ { i } ^ { ( l ) }$ with $\mathbf { \Delta } _ { \mathbf { \boldsymbol { u } } _ { i } ^ { ( l ) } }$ and add a residual connection from last layer. + +# 3.2 EDGE MESSAGE PASSING LAYER + +As in the literature of molecular representation learning, many geometric encoders show benefits from explicitly modeling interactions between edges. For example, DimeNet (Klicpera et al., 2020) uses a 2D spherical Fourier-Bessel basis function to represent angles between two edges and pass messages between edges. AlphaFold2 (Jumper et al., 2021) leverages the triangle attention designed for transformers to model pair representations. Inspired by this observation, we propose a variant of GearNet enhanced with an edge message passing layer, named as GearNet-Edge. The edge message passing layer can be seen as a sparse version of the pair representation update designed for graph neural networks. The main objective is to model the dependency between different interactions of a residue with other sequentially or spatially adjacent residues. + +Formally, we first construct a relational graph $\mathcal { G } ^ { \prime } = ( \mathcal { V } ^ { \prime } , \mathcal { E } ^ { \prime } , \mathcal { R } ^ { \prime } )$ among edges, which is also known as line graph in the literature (Harary $\&$ Norman, 1960). Each node in the graph $\mathcal { G } ^ { \prime }$ corresponds to an edge in the original graph. $\mathcal { G } ^ { \prime }$ links edge $( i , j , r _ { 1 } )$ in the original graph to edge $( w , k , r _ { 2 } )$ if and only if $j = w$ and $i \neq k$ . The type of this edge is determined by the angle between $( i , j , r _ { 1 } )$ and $( w , k , r _ { 2 } )$ . The angular information reflects the relative position between two edges that determines the strength of their interaction. For example, edges with smaller angles point to closer directions and thus are likely to share stronger interactions. To save memory costs for computing a large number of kernel matrices, we discretize the range $[ 0 , \pi ]$ into 8 bins and use the index of the bin as the edge type. + +Then, we apply a similar relational graph convolutional network on the graph $\mathcal { G } ^ { \prime }$ to obtain the message function for each edge. Formally, the edge message passing layer is defined as + +$$ +m _ { ( i , j , r _ { 1 } ) } ^ { ( 0 ) } = f _ { ( i , j , r _ { 1 } ) } , \ m _ { ( i , j , r _ { 1 } ) } ^ { ( l ) } = \sigma \left( \mathrm { B N } \left( \sum _ { r \in \mathcal { R } ^ { \prime } } W _ { r } ^ { \prime } \sum _ { ( w , k , r _ { 2 } ) \in \mathcal { N } _ { r } ^ { \prime } ( ( i , j , r _ { 1 } ) ) } m _ { ( w , k , r _ { 2 } ) } ^ { ( l - 1 ) } \right) \right) . +$$ + +Here we use m( $m _ { ( i , j , r _ { 1 } ) } ^ { ( l ) }$ to denote the message function for edge $( i , j , r _ { 1 } )$ in the $l$ -th layer. Similar as Eq. (1), the message function for edge $( i , j , r _ { 1 } )$ will be updated by aggregating features from its neighbors $\bar { \mathcal { N } } _ { r } ^ { \prime } \big ( ( i , j , r _ { 1 } ) \big )$ , where $\begin{array} { r } { \mathcal { N } _ { r } ^ { \prime } ( ( \bar { i } , j , r _ { 1 } ) ) = \{ ( w , k , r _ { 2 } ) \in \mathcal { V } ^ { \prime } | ( ( \bar { w } , \bar { k } , r _ { 2 } ) , ( i , j , r _ { 1 } ) , r ) \in \mathcal { E } ^ { \prime } \} } \end{array}$ denotes the set of incoming edges of $( i , j , r _ { 1 } )$ with relation type $r$ in graph $\mathcal { G } ^ { \prime }$ . + +Finally, we replace the aggregation function Eq. (1) in the original graph with the following one: + +$$ +\begin{array} { r } { \pmb { u } _ { i } ^ { ( l ) } = \sigma \left( \mathrm { B N } \left( \sum _ { r \in \mathcal { R } } \pmb { W } _ { r } \sum _ { j \in \mathcal { N } _ { r } ( i ) } ( \pmb { h } _ { j } ^ { ( l - 1 ) } + \mathrm { F C } ( \pmb { m } _ { ( j , i , r ) } ^ { ( l ) } ) \right) \right) , } \end{array} +$$ + +where $\operatorname { F C } ( \cdot )$ denotes a linear transformation upon the message function. + +Notably, it is a novel idea to use relational message passing to model different spatial interactions among residues. In addition, to the best of our knowledge, this is one of the first works that explore edge message passing for macromolecular representation learning (see a concurrent work (Morehead et al., 2022) for protein-protein interactions). Compared with the triangle attention in AlphaFold2, our method considers angular information to model different types of interactions between edges, which are more efficient for sparse edge message passing. + +Invariance of GearNet and GearNet-Edge. The graph construction process and input features of GearNet and GearNet-Edge only rely on features (distances and angles) invariant to translation, rotation and reflection. Besides, the message passing layers use pre-defined edge types and other 3D information invariantly. Therefore, GearNet and GearNet-Edge can achieve E(3)-invariance. + +# 4 GEOMETRIC PRETRAINING METHODS + +In this section, we study how to boost protein representation learning via self-supervised pretraining on a massive collection of unlabeled protein structures. Despite the efficacy of self-supervised pretraining in many domains, applying it to protein representation learning is nontrivial due to the difficulty of capturing both biochemical and spatial information in protein structures. To address the challenge, we first introduce our multiview contrastive learning method with novel augmentation functions to discover correlated co-occurrence of protein substructures and align their representations in the latent space. Furthermore, four self-prediction baselines are also proposed for pretraining structure-based encoders. + +![](images/3cd245012d911da91d7e7a81706ef5751fcc8ec9617270d938d964f3c2cf190b.jpg) +Figure 1: Demonstration of multiview contrastive learning. For each protein, we first construct the residue graph $\mathcal { G }$ based on the structural information (some edges are omitted to save space). Next, two views $\mathcal { G } _ { x }$ and $\mathcal { G } _ { y }$ of the protein are generated by randomly choosing the sampling scheme and noise function. For $\mathcal { G } _ { x }$ , we first extract a subsequence and then perform random edge masking with dash lines indicating masked edges. For $\mathcal { G } _ { y }$ , we perform subspace cropping and then keep the subspace graph $\mathcal { G } _ { p , d } ^ { ( \mathrm { s p a c e } ) }$ unchanged. Finally, a contrastive learning loss is optimized to maximize the similarity between $\mathcal { G } _ { x }$ and $\mathcal { G } _ { y }$ in the latent space while minimizing its similarity with a negative sample . + +# 4.1 MULTIVIEW CONTRASTIVE LEARNING + +It is known that structural motifs within folded protein structures are biologically related (Mackenzie & Grigoryan, 2017) and protein substructures can reflect the evolution history and functions of proteins (Ponting & Russell, 2002). Inspired by recent contrastive learning methods (Chen et al., 2020; He et al., 2020), our framework aims to preserve the similarity between these correlated substructures before and after mapping to a low-dimensional latent space. Specifically, using a similarity measurement defined in the latent space, biologically-related substructures are embedded close to each other while unrelated ones are mapped far apart. Figure 1 illustrates the high-level idea. + +Constructing views that reflect protein substructures. Given a protein graph $\mathcal { G }$ , we consider two different sampling schemes for constructing views. The first one is subsequence cropping, which randomly samples a left residue $l$ and a right residue $r$ and takes all residues ranging from $l$ to $r$ . This sampling scheme aims to capture protein domains, consecutive protein subsequences that reoccur in different proteins and indicate their functions (Ponting & Russell, 2002). However, simply sampling protein subsequences cannot fully utilize the 3D structural information in protein data. Therefore, we further introduce a subspace cropping scheme to discover spatially correlated structural motifs. We randomly sample a residue $p$ as the center and select all residues within a Euclidean ball with a predefined radius the protein residue g $d$ . Faph $\mathcal { G } = ( \nu , \mathcal { E } , \mathcal { R } )$ pling schemes, we take the corresp. In specific, the subsequence graph $\mathcal { G } _ { l , r } ^ { ( \mathrm { s e q } ) }$ g subgraphs fromand the subspace graph $\mathcal { G } _ { p , d } ^ { ( \mathrm { s p a c e } ) }$ can be written as: + +$$ +\begin{array} { r l } & { \mathcal { V } _ { l , r } ^ { ( \mathrm { s e q . } ) } = \{ i | i \in \mathcal { V } , l \leq i \leq r \} , \mathcal { E } _ { l , r } ^ { ( \mathrm { s e q . } ) } = \{ ( i , j , r ) | ( i , j , r ) \in \mathcal { E } , i \in \mathcal { V } _ { l , r } ^ { ( \mathrm { s e q . } ) } , j \in \mathcal { V } _ { l , r } ^ { ( \mathrm { s e q . } ) } \} , } \\ & { \mathcal { V } _ { p , d } ^ { ( \mathrm { s p a c e . } ) } = \{ i | i \in \mathcal { V } , \| x _ { i } - x _ { p } \| _ { 2 } \leq d \} , \mathcal { E } _ { p , d } ^ { ( \mathrm { s p a c e . } ) } = \{ ( i , j , r ) | ( i , j , r ) \in \mathcal { E } , i \in \mathcal { V } _ { p , d } ^ { ( \mathrm { s p a c e } ) } , j \in \mathcal { V } _ { p , d } ^ { ( \mathrm { s p a c e } ) } \} } \end{array} +$$ + +$\mathcal { G } _ { l , r } ^ { ( \mathrm { s e q } ) } = ( \mathcal { V } _ { l , r } ^ { ( \mathrm { s e q } ) } , \mathcal { E } _ { l , r } ^ { ( \mathrm { s e q } ) } , \mathcal { R } )$ and $\mathcal { G } _ { p , d } ^ { ( \mathrm { s p a c e } ) } = ( \mathcal { V } _ { p , d } ^ { ( \mathrm { s p a c e } ) } , \mathcal { E } _ { p , d } ^ { ( \mathrm { s p a c e } ) } , \mathcal { R } ) .$ + +After sampling the substructures, following the common practice in self-supervised learning (Chen et al., 2020), we apply a noise function to generate more diverse views and thus benefit the learned representations. Here we consider two noise functions: identity that applies no transformation and random edge masking that randomly masks each edge with a fixed probability 0.15. + +Contrastive learning. We follow SimCLR (Chen et al., 2020) to optimize a contrastive loss function and thus maximize the mutual information between these biologically correlated views. For each protein $\mathcal { G }$ , we sample two views $\mathcal { G } _ { x }$ and $\mathcal { G } _ { y }$ by first randomly choosing one sampling scheme for extracting substructures and then randomly selecting one of the two noise functions with equal probability. We compute the graph representations $h _ { x }$ and $h _ { y }$ of two views using our structurebased encoder. Then, a two-layer MLP projection head is applied to map the representations to a lower-dimensional space, denoted as $z _ { x }$ and $z _ { y }$ . Finally, an InfoNCE loss function is defined by distinguishing views from the same or different proteins using their similarities (Oord et al., 2018). For a positive pair $x$ and $y$ , we treat views from other proteins in the same mini-batch as negative pairs. Mathematically, the loss function for a positive pair of views $x$ and $y$ can be written as: + +$$ +\mathcal { L } _ { x , y } = - \log \frac { \exp ( \sin ( z _ { x } , z _ { y } ) / \tau ) } { \sum _ { k = 1 } ^ { 2 B } \mathbb { 1 } _ { [ k \neq x ] } \exp ( \sin ( z _ { y } , z _ { k } ) / \tau ) } , +$$ + +where $B , \tau$ denotes the batch size and temperature, $\mathbb { 1 } _ { [ k \neq x ] } \in \{ 0 , 1 \}$ is an indicator function that is equal to 1 iff $k \neq x$ . The function $\sin ( { \boldsymbol { \mathbf { \mathit { u } } } } , { \boldsymbol { \mathbf { \mathit { v } } } } )$ is defined by the cosine similarity between $\textbf { \em u }$ and $\textbf { { v } }$ . + +Sizes of sampled substructures. The design of our random sampling scheme aims to extract biologically meaningful substructures for contrastive learning. To attain this goal, it is of critical importance to determine the sampling length $r - l$ for subsequence cropping and radius $d$ for subspace cropping. On the one hand, we need sufficiently long subsequences and large subspaces to ensure that the sampled substructures can meaningfully reflect the whole protein structure and thus share high mutual information with each other. On the other hand, if the sampled substructures are too large, the generated views will be so similar that the contrastive learning problem becomes trivial. Furthermore, large substructures limit the batch size used in contrastive learning, which has been shown to be harmful for the performance (Chen et al., 2020). + +To study the effect of sizes of sampled substructures, we show experimental results on Enzyme Commission (abbr. EC, details in Sec. 5.1) using Multiview Contrast with the subsequence and substructure cropping function, respectively. To prevent the influence of noise functions, we only consider identity transformation in both settings. The results are plotted in Figure 2. For both subsequence and subspace cropping, as the sampled substructures become larger, the results first rise and then drop from a certain threshold. This phenomenon agrees with our analysis above. In practice, we set 50 residues as the length for subsequence and 15 as the radius for subspace cropping, which are large enough to capture most structural motifs according to statistics in previous studies (Tateno et al., 1997). + +In Appendix J, we visualize the representations of the pretrained model with this method and assign familial labels based on domain annotations. We can observe clear separation based on the familial classification of the proteins in the dataset, which proves the effectiveness of our pretraining method. + +![](images/512a0f79dfbaa2e1ef1bfee6bc1018f232d5a7f14e21dbb82e6eb57a2111b1bf.jpg) +Figure 2: $\mathrm { F } _ { \mathrm { m a x } }$ on EC v.s. cropping sequence length (# residues) for Subsequence Cropping and spatial cutoff $( \mathring \mathrm { A } )$ for Subspace Cropping. + +4.2 STRAIGHTFORWARD BASELINES: SELF-PREDICTION METHODS + +Another line of model pre-training research is based on the recent progress of self-prediction methods in natural language processing (Devlin et al., 2018; Brown et al., 2020). Along that line, given a protein, our objective can be formulated as predicting one part of the protein given the remainder of the structure. Here, we propose four self-supervised tasks based on physicochemical or geometric properties: residue types, distances, angles and dihedrals. + +The four methods perform masked prediction on single residues, residue pairs, triplets and quadruples, respectively. Masked residue type prediction is widely used for pretraining protein language models (Bepler & Berger, 2021) and also known as masked inverse folding in the protein community (Yang et al., 2022). Distances, angles and dihedrals have been shown to be important features that reflect the relative position between residues (Klicpera et al., 2020). For angle and dihedral prediction, we sample adjacent edges to better capture local structual information. Since angular values are more sensitive to errors in protein structures than distances, we use discretized values for prediction. The four objectives are summarized in Table 1 and details will be discussed in Appendix. D. + +
MethodLoss functionSampled items
Residue Type PredictionLi=CE(fresidue(h'),fi)Single residue
Distance PredictionL(i,jr)=(fist(h)-|i-xi)²Single edge
AnglePredictionL(i,j,T1),G,kr)=CE(fage(h',h',h),i(∠j))Adjacent edge pairs
Dihedral PredictionL(i,j,r1),(j,kr),(kt,r)=CE(f(h,h',n,h),bin(∠ij))Adjacent edge triplets
+ +Table 1: Self-prediction methods. We use $f _ { \mathrm { r e s i d u e } } ( \cdot ) , f _ { \mathrm { d i s t } } ( \cdot ) , f _ { \mathrm { a n g l e } } ( \cdot ) , f _ { \mathrm { d i h } } ( \cdot )$ to denote the MLP head in each task. $\operatorname { C E } ( { \mathrm { \cdot } } )$ denotes the cross entropy loss and $\mathrm { b i n } ( \cdot )$ is used to discretize the angle. $f _ { i }$ and $\mathbf { \Delta } _ { \mathbf { \mathcal { X } } _ { i } }$ denote the residue type feature and coordinate of node $i$ , respectively. $ { \boldsymbol { h } } _ { i } ^ { \prime }$ denotes the representation of node $i$ after masking the corresponding sampled items in each task. + +# 5 EXPERIMENTS + +In this section, we first introduce our experimental setup for pretraining and then evaluate our models on four standard downstream tasks including Enzyme Commission number prediction, Gene Ontology term prediction, fold and reaction classification. More analysis can be found in Appendix F-K. + +# 5.1 EXPERIMENTAL SETUP + +Pretraining datasets. We use the AlphaFold protein structure database (CC-BY 4.0 License) (Varadi et al., 2021) for pretraining. This database contains protein structures predicted by AlphaFold2, and we employ both 365K proteome-wide predictions and 440K Swiss-Prot (Consortium, 2021) predictions. In Appendix F, we further report the results of pretraining on different datasets. + +Downstream tasks. We adopt two tasks proposed in Gligorijevic et al. (2021) and two tasks used ´ in Hermosilla et al. (2021) for downstream evaluation. Enzyme Commission (EC) number prediction seeks to predict the EC numbers of different proteins, which describe their catalysis of biochemical reactions. The EC numbers are selected from the third and fourth levels of the EC tree (Webb et al., 1992), forming 538 binary classification tasks. Gene Ontology (GO) term prediction aims to predict whether a protein belongs to some GO terms. These terms classify proteins into hierarchically related functional classes organized into three ontologies: molecular function (MF), biological process (BP) and cellular component (CC). Fold classification is first proposed in Hou et al. (2018), with the goal to predict the fold class label given a protein. Reaction classification aims to predict the enzyme-catalyzed reaction class of a protein, in which all four levels of the EC number are employed to depict the reaction class. Although this task is essentially the same with EC prediction, we include it to make a fair comparison with the baselines in Hermosilla et al. (2021). + +Dataset splits. For EC and GO prediction, we follow the multi-cutoff split methods in Gligorijevic´ et al. (2021) to ensure that the test set only contains PDB chains with sequence identity no more than $9 5 \%$ to the training set as used in Wang et al. (2022b) (See Appendix. F for results at lower identity cutoffs). For fold classification, Hou et al. (2018) provides three different test sets: Fold, in which proteins from the same superfamily are unseen during training; Superfamily, in which proteins from the same family are not present during training; and Family, in which proteins from the same family are present during training. For reaction classification, we adopt dataset splits proposed in Hermosilla et al. (2021), where proteins have less than $50 \%$ sequence similarity in-between splits. + +Baselines. Following Wang et al. (2022b) and Hermosilla et al. (2021), we compare our encoders with many existing protein representation learning methods, including four sequence-based encoders (CNN (Shanehsazzadeh et al., 2020), ResNet (Rao et al., 2019), LSTM (Rao et al., 2019) and Transformer (Rao et al., 2019)), six structure-based encoders (GCN (Kipf & Welling, 2017), GAT (Velickovi ˇ c et al., 2018), GVP (Jing et al., 2021), 3DCNN_MQA (Derevyanko et al., 2018), ´ GraphQA (Baldassarre et al., 2021) and New IEConv (Hermosilla & Ropinski, 2022)). We also include two models pretrained on large-scale sequence datasets (ProtBERT-BFD (Elnaggar et al., + +Table 2: $\mathrm { F } _ { \mathrm { m a x } }$ on EC and GO prediction and Accuracy $( \% )$ on fold and reaction classification. [†] denotes results taken from Wang et al. (2022b) and $[ { ^ { * } } ]$ denotes results taken from Hermosilla et al. (2021) and Hermosilla & Ropinski (2022). Bold numbers indicate the best results under w/o pretraining and w/ pretraining settings. For pretraining, we select the model with the best performance when training from scratch, i.e., GearNet-Edge for EC, GO, Reaction and GearNet-Edge-IEConv for Fold Classification. We use the pretraining methods to name our pretrained models. + +
MethodPretraining Dataset (Size)ECGOFold ClassificationReaction
BPMFCCFoldSuper.Fam.Avg.
ResNet (Rao et al.,2019)CNN (Shanehsazzadeh et al., 2020)0.5450.2440.3540.28711.313.4 7.2153.426.051.7 24.1
LSTM (Rao et al.,2019)0.6050.280 0.2250.405 0.3210.304 0.28310.1 6.414.3323.513.6 9.6111.0
0.42518.126.6
Transformer (Rao et al.,2019)0.2380.2640.2110.4059.228.8140.419.4
GCN (Kipf &Welling,2017)0.3200.2520.1950.32916.8*21.3*82.8*40.3*67.3*
GAT (Velickovic et al.,2018)0.3680.2840.317†0.38512.416.572.733.855.6
GVP (Jing et al.,2021)0.4890.3260.4260.420+16.022.583.840.765.5
3DCNN_MQA (Derevyanko et al.,2018)0.0770.2400.1470.30531.6*45.4*92.5*56.5*72.2*
GraphQA (Baldassarre et al.,2021) New IEConv (Hermosilla & Ropinski,2022)0.5090.3080.3290.41323.7*32.5*84.4*46.9*60.8*
0.7350.3740.5440.44447.6*70.2*99.2*72.3*87.2*
GearNet0.7300.3560.5030.41428.442.695.355.479.4
GearNet-IEConv0.8000.3810.5630.42242.364.199.168.583.7
GearNet-Edge GearNet-Edge-IEConv0.8100.4030.5800.45044.066.799.169.986.6
DeepFRI (Gligorijevic et al.,2021)0.8100.4000.5810.43048.370.399.572.785.3
Pfam (10M)0.6310.3990.4650.46015.3*20.6*73.2*36.4*63.3*
ESM-1b (Rives etal.,2021) ProtBERT-BFD (Elnaggar et al.,2021)UniRef50 (24M)0.8640.4520.6570.47726.860.197.861.583.1
BFD (2.1B)0.8380.279†0.4560.408†26.6*55.8*97.6*60.0*72.2*
LM-GVP (Wang et al.,2022b) New IEConv (Hermosilla & Ropinski,2022)UniRef100 (216M)0.6640.417+0.5450.527===
PDB (476K)-=-=50.3*80.6*99.7*76.9*87.6*
Residue Type PredictionAlphaFoldDB (805K)0.8430.4300.6040.46548.871.099.473.086.6
Distance PredictionAlphaFoldDB (805K)0.8390.4480.6160.46450.973.599.474.687.5
Angle PredictionAlphaFoldDB (805K)0.8530.4580.6250.47356.576.399.677.486.8
Dihedral PredictionAlphaFoldDB (805K)0.8590.4580.6260.46551.877.899.675.987.0
Multiview ContrastAlphaFoldDB (805K)0.8740.4900.6540.48854.180.599.978.187.5
+ +2021), ESM-1b (Rives et al., 2021)) and two models combining pretrained sequence-based encoders with structural information (DeepFRI (Gligorijevic et al., 2021) and LM-GVP (Wang et al., 2022b)). ´ For LM-GVP and New IEConv, we only include results reported in the original paper due to the computational burden and the lack of codes. We do not include MSA-based baselines, since these evolution-based methods require a lot of resources for the computation and storage of MSAs but have been shown to be inferior to ESM-1b on function prediction tasks in Hu et al. (2022). + +Training. On the four downstream tasks, we train GearNet and GearNet-Edge from scratch. As we find that the IEConv layer is important for predicting fold labels, we also enhance our model by incorporating this as an additional layer (see Appendix C.2). These models are referred as GearNetIEConv and GearNet-Edge-IEConv, respectively. Following Wang et al. (2022b) and Hermosilla & Ropinski (2022), the models are trained for 200 epochs on EC and GO prediction and for 300 epochs on fold and reaction classification. For pretraining, the models with the best performance when trained from scratch are selected, i.e., GearNet-Edge for EC, GO, Reaction and GearNet-Edge-IEConv for Fold Classification. The models are pretrained on the AlphaFold database with our proposed five methods for 50 epochs. All these models are trained on 4 Tesla A100 GPUs (see Appendix E.3). + +Evaluation. For EC and GO prediction, we evaluate the performance with the protein-centric maximum F-score $\mathrm { F } _ { \mathrm { m a x } }$ , which is commonly used in the CAFA challenges (Radivojac et al., 2013) (See Appendix E.2 for details). For fold and reaction classification, the performance is measured with the mean accuracy. Models with the best performance on validation sets are selected for evaluation. + +# 5.2 RESULTS + +We report results for four downstream tasks in Table 2, including all models with and without pretraining. The following conclusions can be drawn from the results: + +Our structure-based encoders outperform all baselines without pretraining on 7 of 8 datasets. By comparing the first three blocks, we find that GearNet can obtain competitive results against other baselines on three function prediction tasks (EC, GO, Reaction). After adding the edge message passing mechanism, GearNet-Edge significantly outperforms other baselines on EC, GO-BP and GO-MF and is competitive on GO-CC. Although no clear improvements are observed on function prediction (EC, GO, Reaction) by adding IEConv layers, GearNet-Edge-IEConv achieve the best results on fold classification. This can be understood since fold classification requires the encoder to capture sufficient structural information for determining the fold labels. Compared with GearNet + +Edge, which only includes the distance and angle information as features, the IEConv layer is better at capturing structural details by applying different kernel matrices dependent on relative positional features. These strong performance demonstrates the advantages of our structure-based encoders. + +Structure-based encoders benefit a lot from pretraining with unlabeled structures. Comparing the results in the third and last two blocks, it can be observed that models with all proposed pretraining methods show large improvements over models trained from scratch. Among these methods, Multiview Contrast is the best on 7 of 8 datasets and achieve the state-of-the-art results on EC, GO-BP, GO-MF, Fold and Reaction tasks. This proves the effectiveness of our pretraining strategies. + +Pretrained structure-based encoders perform on par with or even better than sequence-based encoders pretrained with much more data. The last three blocks show the comparision between pretrained sequence-based and structure-based models. It should be noted that our models are pretrained on a dataset with fewer than one million structures, whereas all sequence-based pretraining baselines are pretrained on million- or billion-scale sequence databases. Though pretrained with an order of magnitude less data, our model can achieve comparable or even better results against these sequence-based models. Besides, our model is the only one that can achieve good performance on all four tasks, given that sequence-based models do not perform well on fold classification. This again shows the potential of structure-based pretraining for learning protein representations. + +# 5.3 ABLATION STUDIES + +
Method#layers#params.ECMethodECGO-BPGO-MFGO-CC
GearNet-Edge642M0.810Multiview Contrast0.8740.4900.6540.488
- w/o rel. conv.623M0.752- subsequence + identity0.8660.4770.6270.473
- w/o rel. conv.839M0.754- subspace+ identity0.872 0.8690.4800.6400.468
- w/o rel. conv.1060M0.744- subsequence + random edge masking - subspace + random edge masking0.8760.484 0.4810.641 0.6450.471 0.470
+ +Table 3: Ablation studies of GearNet-Edge and Multiview Contrast. Rel. conv. is the abbreviation for relational graph convolution. The numbers of layers and parameters in GearNet-Edge are reported. + +To analyze the contribution of different components in our proposed methods, we perform ablation studies on function prediction task. The results are shown in Table 3. + +Relational graph convolutional layers. To show the effects of relational convolutional layers, we replace it with graph convolutional layers that share a single kernel matrix among all edges. To make the number of learnable parameters comparable, we run the baselines with different number of layers. As reported in the table, results can be significantly improved by using relational convolution, which suggests the importance of treating edges as different types. + +Edge message passing layers. We also compare the results of GearNet with and without edge message passing layers, the results of which are shown in Table 2. It can be observed that the performance consistently increases after performing edge message passing. This demonstrates the effectiveness of our proposed mechanism. + +Different augmentations in Multiview Contrast. We investigate the contribution of each augmentation operation proposed in the Multiview Contrast method. Instead of randomly sampling cropping and noise functions, we pretrain our model with four deterministic combinations of augmentations, respectively. As shown in Table 3, all the four combinations can yield good results, which suggests that arbitrary combinations of the proposed cropping and noise schemes can yield informative partial views of proteins. Besides, by randomly choosing cropping and noise functions, we can generate more diverse views and thus benefit contrastive learning, as demonstrated in the table. + +# 6 CONCLUSIONS AND FUTURE WORK + +In this work, we propose a simple yet effective structure-based encoder for protein representation learning, which performs relational message passing on protein residue graphs. A novel edge message passing mechanism is introduced to explicitly model interactions between edges, which show consistent improvements. Moreover, five self-supervised pretraining methods are proposed following two standard frameworks: contrastive learning and self-prediction methods. Comprehensive experiments over multiple benchmark tasks verify that our model outperforms previous encoders when trained from scratch and achieve comparable or even better results than the state-of-the-art baselines while pretraining with much less data. We believe that our work is an important step towards adopting self-supervised learning methods on protein structure understanding. + +# ACKNOWLEDGMENTS + +The authors would like to thank Meng Qu, Zhaocheng Zhu, Shengchao Liu, Chence Shi, Minkai Xu and Huiyu Cai for their helpful discussions and comments. + +This project is supported by AIHN IBM-MILA partnership program, the Natural Sciences and Engineering Research Council (NSERC) Discovery Grant, the Canada CIFAR AI Chair Program, collaboration grants between Microsoft Research and Mila, Samsung Electronics Co., Ltd., Amazon Faculty Research Award, Tencent AI Lab Rhino-Bird Gift Fund, a NRC Collaborative R&D Project (AI4D-CORE-06) as well as the IVADO Fundamental Research Project grant PRF-2019-3583139727. + +# REFERENCES + +Mehmet Akdel, Douglas EV Pires, Eduard Porta Pardo, Jürgen Jänes, Arthur O Zalevsky, Bálint Mészáros, Patrick Bryant, Lydia L Good, Roman A Laskowski, Gabriele Pozzati, et al. A structural biology community assessment of alphafold 2 applications. bioRxiv, 2021. + +Ethan C Alley, Grigory Khimulya, Surojit Biswas, Mohammed AlQuraishi, and George M Church. Unified rational protein engineering with sequence-based deep representation learning. Nature methods, 16(12):1315–1322, 2019. + +Stephen F. Altschul, Thomas L. Madden, Alejandro A. Schäffer, J Zhang, Z Zhang, Webb Miller, and David J. Lipman. Gapped blast and psi-blast: a new generation of protein database search programs. Nucleic acids research, 25 17:3389–402, 1997. + +Sarp Aykent and Tian Xia. Gbpnet: Universal geometric representation learning on protein structures. Proceedings of the 28th ACM SIGKDD Conference on Knowledge Discovery and Data Mining, 2022. + +Minkyung Baek, Frank DiMaio, Ivan Anishchenko, Justas Dauparas, Sergey Ovchinnikov, Gyu Rie Lee, Jue Wang, Qian Cong, Lisa N Kinch, R Dustin Schaeffer, et al. Accurate prediction of protein structures and interactions using a three-track neural network. Science, 373(6557):871–876, 2021. + +Federico Baldassarre, David Menéndez Hurtado, Arne Elofsson, and Hossein Azizpour. Graphqa: protein model quality assessment using graph convolutional networks. Bioinformatics, 37(3): 360–366, 2021. + +Albert P Bartók, Mike C Payne, Risi Kondor, and Gábor Csányi. Gaussian approximation potentials: The accuracy of quantum mechanics, without the electrons. Physical review letters, 104(13): 136403, 2010. + +Albert P Bartók, Risi Kondor, and Gábor Csányi. On representing chemical environments. Physical Review B, 87(18):184115, 2013. + +Jörg Behler and Michele Parrinello. Generalized neural-network representation of high-dimensional potential-energy surfaces. Physical review letters, 98(14):146401, 2007. + +Tristan Bepler and Bonnie Berger. Learning protein sequence embeddings using information from structure. arXiv preprint arXiv:1902.08661, 2019. + +Tristan Bepler and Bonnie Berger. Learning the protein language: Evolution, structure, and function. Cell Systems, 12(6):654–669, 2021. + +Helen M Berman, John Westbrook, Zukang Feng, Gary Gilliland, Talapady N Bhat, Helge Weissig, Ilya N Shindyalov, and Philip E Bourne. The protein data bank. Nucleic acids research, 28(1): 235–242, 2000. + +Surojit Biswas, Grigory Khimulya, Ethan C Alley, Kevin M Esvelt, and George M Church. Low-n protein engineering with data-efficient deep learning. Nature Methods, 18(4):389–396, 2021. + +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. + +Yue Cao, Payel Das, Vijil Chenthamarakshan, Pin-Yu Chen, Igor Melnyk, and Yang Shen. Fold2seq: A joint sequence(1d)-fold(3d) embedding-based generative model for protein design. 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. 1261–1271. PMLR, 18–24 Jul 2021. URL https://proceedings.mlr.press/v139/cao21a.html. + +Can Chen, Jingbo Zhou, Fan Wang, Xue Liu, and Dejing Dou. Structure-aware protein self-supervised learning. arXiv preprint arXiv:2204.04213, 2022. + +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. + +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. + +Stefan Chmiela, Alexandre Tkatchenko, Huziel E Sauceda, Igor Poltavsky, Kristof T Schütt, and Klaus-Robert Müller. Machine learning of accurate energy-conserving molecular force fields. Science advances, 3(5):e1603015, 2017. + +The UniProt Consortium. Uniprot: the universal protein knowledgebase in 2021. Nucleic Acids Research, 49(D1):D480–D489, 2021. + +Bowen Dai and Chris Bailey-Kellogg. Protein interaction interface region prediction by geometric deep learning. Bioinformatics, 2021. + +Georgy Derevyanko, Sergei Grudinin, Yoshua Bengio, and Guillaume Lamoureux. Deep convolutional networks for quality assessment of protein folds. Bioinformatics, 34(23):4046–4053, 2018. + +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. + +Ahmed Elnaggar, Michael Heinzinger, Christian Dallago, Ghalia Rehawi, Wang Yu, Llion Jones, Tom Gibbs, Tamas Feher, Christoph Angerer, Martin Steinegger, Debsindhu Bhowmik, and Burkhard Rost. Prottrans: Towards cracking the language of lifes code through self-supervised deep learning and high performance computing. IEEE Transactions on Pattern Analysis and Machine Intelligence, pp. 1–1, 2021. doi: 10.1109/TPAMI.2021.3095381. + +Pablo Gainza, Freyr Sverrisson, Frederico Monti, Emanuele Rodola, D Boscaini, MM Bronstein, and BE Correia. Deciphering interaction fingerprints from protein molecular surfaces using geometric deep learning. Nature Methods, 17(2):184–192, 2020. + +Justin Gilmer, Samuel S Schoenholz, Patrick F Riley, Oriol Vinyals, and George E Dahl. Neural message passing for quantum chemistry. In International conference on machine learning, pp. 1263–1272. PMLR, 2017. + +Vladimir Gligorijevic, P Douglas Renfrew, Tomasz Kosciolek, Julia Koehler Leman, Daniel Beren- ´ berg, Tommi Vatanen, Chris Chandler, Bryn C Taylor, Ian M Fisk, Hera Vlamakis, et al. Structurebased protein function prediction using graph convolutional networks. Nature communications, 12 (1):1–14, 2021. + +Yuzhi Guo, Jiaxiang Wu, Hehuan Ma, and Junzhou Huang. Self-supervised pre-training for protein embeddings using tertiary structures. In AAAI, 2022. + +William L Hamilton, Rex Ying, and Jure Leskovec. Inductive representation learning on large graphs. In Proceedings of the 31st International Conference on Neural Information Processing Systems, pp. 1025–1035, 2017. + +Frank Harary and Robert Z Norman. Some properties of line digraphs. Rendiconti del circolo matematico di palermo, 9(2):161–168, 1960. + +Kaveh Hassani and Amir Hosein Khasahmadi. Contrastive multi-view representation learning on graphs. In International Conference on Machine Learning, pp. 4116–4126. PMLR, 2020. + +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. + +Liang He, Shizhuo Zhang, Lijun Wu, Huanhuan Xia, Fusong Ju, He Zhang, Siyuan Liu, Yingce Xia, Jianwei Zhu, Pan Deng, et al. Pre-training co-evolutionary protein representation via a pairwise masked language model. arXiv preprint arXiv:2110.15527, 2021. + +Dan Hendrycks and Kevin Gimpel. Gaussian error linear units (gelus). arXiv preprint arXiv:1606.08415, 2016. + +Pedro Hermosilla and Timo Ropinski. Contrastive representation learning for 3d protein structures. In Submitted to The Tenth International Conference on Learning Representations, 2022. URL https://openreview.net/forum?id $\underline { { \underline { { \mathbf { \Pi } } } } } =$ VINWzIM6_6. + +Pedro Hermosilla, Marco Schäfer, Matej Lang, Gloria Fackelmann, Pere Pau Vázquez, Barbora ˇ Kozlíková, Michael Krone, Tobias Ritschel, and Timo Ropinski. Intrinsic-extrinsic convolution and pooling for learning on 3d protein structures. International Conference on Learning Representations, 2021. + +Liisa Holm. Benchmarking fold detection by dalilite v.5. Bioinformatics, 2019. + +Jie Hou, Badri Adhikari, and Jianlin Cheng. Deepsf: deep convolutional neural network for mapping protein sequences to folds. Bioinformatics, 34(8):1295–1303, 2018. + +Min Hu, Fajie Yuan, Kevin Kaichuang Yang, Fusong Ju, Jingyu Su, Hongya Wang, Fei Yang, and Qiuyang Ding. Exploring evolution-based & -free protein language models as protein function predictors. ArXiv, abs/2206.06583, 2022. + +Weihua Hu, Bowen Liu, Joseph Gomes, Marinka Zitnik, Percy Liang, Vijay Pande, and Jure Leskovec. Strategies for pre-training graph neural networks. arXiv preprint arXiv:1905.12265, 2019. + +John Ingraham, Vikas Garg, Regina Barzilay, and Tommi Jaakkola. Generative models for graphbased protein design. Advances in Neural Information Processing Systems, 32:15820–15831, 2019. + +Bowen Jing, Stephan Eismann, Pratham N. Soni, and Ron O. Dror. Learning from protein structure with geometric vector perceptrons. In International Conference on Learning Representations, 2021. URL https://openreview.net/forum?id ${ . } = { }$ 1YLJDvSx6J4. + +Peter Bjørn Jørgensen, Karsten Wedel Jacobsen, and Mikkel N Schmidt. Neural message passing with edge updates for predicting properties of molecules and materials. arXiv preprint arXiv:1806.03146, 2018. + +John Jumper, Richard Evans, Alexander Pritzel, Tim Green, Michael Figurnov, Olaf Ronneberger, Kathryn Tunyasuvunakool, Russ Bates, Augustin Žídek, Anna Potapenko, et al. Highly accurate protein structure prediction with alphafold. Nature, 596(7873):583–589, 2021. + +Thomas N Kipf and Max Welling. Variational graph auto-encoders. arXiv preprint arXiv:1611.07308, 2016. + +Thomas N. Kipf and Max Welling. Semi-supervised classification with graph convolutional networks. In International Conference on Learning Representations, 2017. + +Johannes Klicpera, Janek Groß, and Stephan Günnemann. Directional message passing for molecular graphs. In International Conference on Learning Representations (ICLR), 2020. + +Johannes Klicpera, Florian Becker, and Stephan Günnemann. Gemnet: Universal directional graph neural networks for molecules. arXiv preprint arXiv:2106.08903, 2021. + +Yi Liu, Limei Wang, Meng Liu, Xuan Zhang, Bora Oztekin, and Shuiwang Ji. Spherical message passing for 3d graph networks. arXiv preprint arXiv:2102.05013, 2021. + +Amy X Lu, Haoran Zhang, Marzyeh Ghassemi, and Alan M Moses. Self-supervised contrastive learning of protein representations by mutual information maximization. BioRxiv, 2020. + +Bin Ma. Novor: real-time peptide de novo sequencing software. Journal of the American Society for Mass Spectrometry, 26(11):1885–1894, 2015. + +Bin Ma and Richard Johnson. De novo sequencing and homology searching. Molecular & cellular proteomics, 11(2), 2012. + +Craig O. Mackenzie and Gevorg Grigoryan. Protein structural motifs in prediction and design. Current opinion in structural biology, 44:161–167, 2017. + +Leland McInnes, John Healy, and James Melville. Umap: Uniform manifold approximation and projection for dimension reduction. arXiv preprint arXiv:1802.03426, 2018. + +Joshua Meier, Roshan Rao, Robert Verkuil, Jason Liu, Tom Sercu, and Alexander Rives. Language models enable zero-shot prediction of the effects of mutations on protein function. bioRxiv, 2021. + +Jaina Mistry, Sara Chuguransky, Lowri Williams, Matloob Qureshi, Gustavo A Salazar, Erik LL Sonnhammer, Silvio CE Tosatto, Lisanna Paladin, Shriya Raj, Lorna J Richardson, et al. Pfam: The protein families database in 2021. Nucleic Acids Research, 49(D1):D412–D419, 2021. + +Bhaskar Mitra and Nick Craswell. Neural models for information retrieval. ArXiv, abs/1705.01509, 2017. + +Alex Morehead, Chen Chen, and Jianlin Cheng. Geometric transformers for protein interface contact prediction. In International Conference on Learning Representation, 2022. + +Alexey G Murzin, Steven E Brenner, Tim Hubbard, and Cyrus Chothia. Scop: a structural classification of proteins database for the investigation of sequences and structures. Journal of molecular biology, 247(4):536–540, 1995. + +Pascal Notin, Mafalda Dias, Jonathan Frazer, Javier Marchena-Hurtado, Aidan N. Gomez, Debora S. Marks, and Yarin Gal. Tranception: protein fitness prediction with autoregressive transformers and inference-time retrieval. In ICML, 2022. + +Aaron van den Oord, Yazhe Li, and Oriol Vinyals. Representation learning with contrastive predictive coding. arXiv preprint arXiv:1807.03748, 2018. + +Chris Paul Ponting and Robert R Russell. The natural history of protein domains. Annual review of biophysics and biomolecular structure, 31:45–71, 2002. + +Jiezhong Qiu, Qibin Chen, Yuxiao Dong, Jing Zhang, Hongxia Yang, Ming Ding, Kuansan Wang, and Jie Tang. Gcc: Graph contrastive coding for graph neural network pre-training. In Proceedings of the 26th ACM SIGKDD International Conference on Knowledge Discovery & Data Mining, pp. 1150–1160, 2020. + +Predrag Radivojac, Wyatt T Clark, Tal Ronnen Oron, Alexandra M Schnoes, Tobias Wittkop, Artem Sokolov, Kiley Graim, Christopher Funk, Karin Verspoor, Asa Ben-Hur, et al. A large-scale evaluation of computational protein function prediction. Nature methods, 10(3):221–227, 2013. + +Roshan Rao, Nicholas Bhattacharya, Neil Thomas, Yan Duan, Xi Chen, John Canny, Pieter Abbeel, and Yun S Song. Evaluating protein transfer learning with tape. In Advances in Neural Information Processing Systems, 2019. + +Roshan Rao, Jason Liu, Robert Verkuil, Joshua Meier, John F Canny, Pieter Abbeel, Tom Sercu, and Alexander Rives. Msa transformer. bioRxiv, 2021. + +Alexander Rives, Joshua Meier, Tom Sercu, Siddharth Goyal, Zeming Lin, Jason Liu, Demi Guo, Myle Ott, C Lawrence Zitnick, Jerry Ma, et al. Biological structure and function emerge from scaling unsupervised learning to 250 million protein sequences. Proceedings of the National Academy of Sciences, 118(15), 2021. + +Yu Rong, Yatao Bian, Tingyang Xu, Weiyang Xie, Ying Wei, Wenbing Huang, and Junzhou Huang. Self-supervised graph transformer on large-scale molecular data. arXiv preprint arXiv:2007.02835, 2020. + +Olga Russakovsky, Jia Deng, Hao Su, Jonathan Krause, Sanjeev Satheesh, Sean Ma, Zhiheng Huang, Andrej Karpathy, Aditya Khosla, Michael Bernstein, et al. Imagenet large scale visual recognition challenge. International journal of computer vision, 115(3):211–252, 2015. + +Victor Garcia Satorras, Emiel Hoogeboom, and Max Welling. E (n) equivariant graph neural networks. arXiv preprint arXiv:2102.09844, 2021. + +Michael Schlichtkrull, Thomas N Kipf, Peter Bloem, Rianne Van Den Berg, Ivan Titov, and Max Welling. Modeling relational data with graph convolutional networks. In European semantic web conference, pp. 593–607. Springer, 2018. + +Kristof T Schütt, Farhad Arbabzadah, Stefan Chmiela, Klaus R Müller, and Alexandre Tkatchenko. Quantum-chemical insights from deep tensor neural networks. Nature communications, 8(1):1–8, 2017a. + +Kristof T Schütt, Pieter-Jan Kindermans, Huziel E Sauceda, Stefan Chmiela, Alexandre Tkatchenko, and Klaus-Robert Müller. Schnet: A continuous-filter convolutional neural network for modeling quantum interactions. arXiv preprint arXiv:1706.08566, 2017b. + +Amir Shanehsazzadeh, David Belanger, and David Dohan. Is transfer learning necessary for protein landscape prediction? arXiv preprint arXiv:2011.03443, 2020. + +Ilya N. Shindyalov and Philip E. Bourne. Protein structure alignment by incremental combinatorial extension (ce) of the optimal path. Protein engineering, 11 9:739–47, 1998. + +Vignesh Ram Somnath, Charlotte Bunne, and Andreas Krause. Multi-scale representation learning on proteins. Advances in Neural Information Processing Systems, 34, 2021. + +Martin Steinegger and Johannes Söding. Mmseqs2 enables sensitive protein sequence searching for the analysis of massive data sets. Nature Biotechnology, 35:1026–1028, 2017. + +Martin Steinegger and Johannes Söding. Clustering huge protein sequence sets in linear time. Nature communications, 9(1):1–8, 2018. + +Martin Steinegger, Markus Meier, Milot Mirdita, Harald Voehringer, Stephan J. Haunsberger, and Johannes Soeding. Hh-suite3 for fast remote homology detection and deep protein annotation. BMC Bioinformatics, 20, 2019. + +Alexey Strokach, David Becerra, Carles Corbi-Verge, Albert Perez-Riba, and Philip M Kim. Fast and flexible protein design using deep graph neural networks. Cell Systems, 11(4):402–411, 2020. + +Haitian Sun, Tania Bedrax-Weiss, and William W. Cohen. Pullnet: Open domain question answering with iterative retrieval on knowledge bases and text. EMNLP, abs/1904.09537, 2019. + +Mukund Sundararajan, Ankur Taly, and Qiqi Yan. Axiomatic attribution for deep networks. In International Conference on Machine Learning, pp. 3319–3328. PMLR, 2017. + +Baris E Suzek, Hongzhan Huang, Peter McGarvey, Raja Mazumder, and Cathy H Wu. Uniref: comprehensive and non-redundant uniprot reference clusters. Bioinformatics, 23(10):1282–1288, 2007. + +Freyr Sverrisson, Jean Feydy, Bruno E Correia, and Michael M Bronstein. Fast end-to-end learning on protein surfaces. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 15272–15281, 2021. + +Y Tateno, K Ikeo, T Imanishi, H Watanabe, T Endo, Y Yamaguchi, Y Suzuki, K Takahashi, K Tsunoyama, M Kawai, et al. Evolutionary motif and its biological and structural significance. Journal of molecular evolution, 44(1):S38–S43, 1997. + +Michel van Kempen, Stephanie Kim, Charlotte Tumescheit, Milot Mirdita, Johannes Soeding, and Martin Steinegger. Foldseek: fast and accurate protein structure search. bioRxiv, 2022. + +Mihaly Varadi, Stephen Anyango, Mandar Deshpande, Sreenath Nair, Cindy Natassia, Galabina Yordanova, David Yuan, Oana Stroe, Gemma Wood, Agata Laydon, et al. Alphafold protein structure database: massively expanding the structural coverage of protein-sequence space with high-accuracy models. Nucleic acids research, 2021. + +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. + +Petar Velickovi ˇ c, Guillem Cucurull, Arantxa Casanova, Adriana Romero, Pietro Liò, and Yoshua ´ Bengio. Graph Attention Networks. International Conference on Learning Representations, 2018. URL https://openreview.net/forum?id $=$ rJXMpikCZ. accepted as poster. + +Limei Wang, Haoran Liu, Yi Liu, Jerry Kurtin, and Shuiwang Ji. Learning protein representations via complete 3d graph networks. ArXiv, abs/2207.12600, 2022a. + +Yanbin Wang, Zhu-Hong You, Shan Yang, Xiao Li, Tong-Hai Jiang, and Xi Zhou. A high efficient biological language model for predicting protein–protein interactions. Cells, 8(2):122, 2019. + +Zichen Wang, Steven A Combs, Ryan Brand, Miguel Romero Calvo, Panpan Xu, George Price, Nataliya Golovach, Emmanuel O Salawu, Colby J Wise, Sri Priya Ponnapalli, et al. Lm-gvp: an extensible sequence and structure informed deep learning framework for protein property prediction. Scientific reports, 12(1):1–12, 2022b. + +Oren F Webb, Tommy J Phelps, Paul R Bienkowski, Philip M Digrazia, David C White, and Gary S Sayler. Enzyme nomenclature. 1992. + +Minghao Xu, Hang Wang, Bingbing Ni, Hongyu Guo, and Jian Tang. Self-supervised graph-level representation learning with local and global structure. arXiv preprint arXiv:2106.04113, 2021. + +Jinn-Moon Yang and Chi-Hua Tung. Protein structure database search and evolutionary classification. Nucleic Acids Research, 34:3646 – 3659, 2006. + +Kevin Kaichuang Yang, Niccol’o Zanichelli, and Hugh Yeh. Masked inverse folding with sequence transfer for protein representation learning. bioRxiv, 2022. + +Yuning You and Yang Shen. Cross-modality and self-supervised protein embedding for compound– protein affinity and contact prediction. Bioinformatics, 38(Supplement_2):ii68–ii74, 2022. + +Yuning You, Tianlong Chen, Yongduo Sui, Ting Chen, Zhangyang Wang, and Yang Shen. Graph contrastive learning with augmentations. Advances in Neural Information Processing Systems, 33: 5812–5823, 2020. + +Yang Zhang and Jeffrey Skolnick. Tm-align: a protein structure alignment algorithm based on the tm-score. Nucleic Acids Research, 33:2302 – 2309, 2005. + +Mengyao Zhao, Wan-Ping Lee, Erik P Garrison, and Gabor T. Marth. Ssw library: An simd smith-waterman $\mathrm { c / c } { + + }$ library for use in genomic applications. PLoS ONE, 8, 2013. + +Zhaocheng Zhu, Chence Shi, Zuobai Zhang, Shengchao Liu, Minghao Xu, Xinyu Yuan, Yangtian Zhang, Junkun Chen, Huiyu Cai, Jiarui Lu, et al. Torchdrug: A powerful and flexible machine learning platform for drug discovery. arXiv preprint arXiv:2202.08320, 2022. + +# A MORE RELATED WORK + +# A.1 SEQUENCE-BASED METHODS FOR PROTEIN REPRESENTATION LEARNING + +Sequence-based protein representation learning is mainly inspired by the methods of modeling natural language sequences. Recent methods aim to capture the biochemical and co-evolutionary knowledge underlying a large-scale protein sequence corpus by self-supervised pretraining, and such knowledge is then transferred to specific downstream tasks by finetuning. Typical pretraining objectives explored in existing methods include next amino acid prediction (Alley et al., 2019; Elnaggar et al., 2021), masked language modeling (MLM) (Rao et al., 2019; Elnaggar et al., 2021; Rives et al., 2021), pairwise MLM (He et al., 2021) and contrastive predictive coding (CPC) (Lu et al., 2020). Compared to sequence-based approaches that learn in the whole sequence space, MSA-based methods (Rao et al., 2021; Biswas et al., 2021; Meier et al., 2021) leverage the sequences within a protein family to capture the conserved and variable regions of homologous sequences, which imply specific structures and functions of the protein family. + +# A.2 STRUCTURE-BASED METHODS FOR BIOLOGICAL MOLECULES + +Following the early efforts (Behler & Parrinello, 2007; Bartók et al., 2010; 2013; Chmiela et al., 2017) of building machine learning systems for molecules by hand-crafted atomic features, recent works exploited end-to-end message passing neural networks (MPNNs) (Gilmer et al., 2017) to encode the structures of small molecules and macromolecules like proteins. Specifically, existing methods employed node/atom message passing (Gilmer et al., 2017; Schütt et al., 2017a;b), edge/bond message passing (Jørgensen et al., 2018; Chen et al., 2019) and directional information (Klicpera et al., 2020; Liu et al., 2021; Klicpera et al., 2021) to encode 2D or 3D molecular graphs. + +Compared to small molecules, structural representations of proteins are more diverse, including residue-level, atom-level graphs and protein surfaces. There are recent models designed for residuelevel graphs (Hermosilla et al., 2021; Hermosilla & Ropinski, 2022) and protein surfaces (Gainza et al., 2020; Sverrisson et al., 2021), which achieved impressive results on various tasks. + +# A.3 PRETRAINING GRAPH NEURAL NETWORKS + +Our work is also related to the recent efforts of pretraining graph neural networks (GNNs), which sought to learn graph representations in a self-supervised fashion. In this domain, various selfsupervised pretext tasks, like edge prediction (Kipf & Welling, 2016; Hamilton et al., 2017), context prediction (Hu et al., 2019; Rong et al., 2020), node/edge attribute reconstruction (Hu et al., 2019) and contrastive learning (Hassani & Khasahmadi, 2020; Qiu et al., 2020; You et al., 2020; Xu et al., 2021), are designed to acquire knowledge from unlabeled graphs. Besides, there is one recent work applying self-supervised learning for protein-ligand affinity prediction (You & Shen, 2022). In this work, we focus on learning representations of residue-level graphs of proteins in a self-supervised way. To attain this goal, we design novel protein-specific pretraining methods to learn the proposed structure-based encoder. + +# B POTENTIAL NEGATIVE IMPACT + +This research project focuses on learning effective protein representations via pretraining with a large number of unlabeled protein structures. Compared to the conventional sequence-based pretraining methods, our approach is able to leverage structural information and thus provide better representations. This merit enables more in-depth analysis of protein research and can potentially benefit many real-world applications, like protein function prediction and sequence design. + +Limitations. In this paper, we only use 805K protein structures for pretraining. As the AlphaFold Protein Structure Database now covers over 100 million proteins, it would be possible to train huge and more advanced structure-based models on larger datasets in the future. Scalability, however, should be kept in mind. Thanks to their simplicity, our models could readily accommodate larger datasets, while more cumbersome procedures might not. Besides, we only consider function and fold prediction tasks. Another promising direction is to apply our proposed methods on more tasks, e.g., protein-protein interaction modeling and protein-guided ligand molecule design, which underpins many important biological processes and applications. + +![](images/5a075c5f37ed806d1abb1475d84e9c6ba502b37a137679104a725071e11fbfef.jpg) +Figure 3: The pipeline for GearNet and GearNet-edge. First, we construct a relational protein residue graph with sequential, radius and knn edges (some edges are omitted in the figure to save space). Then, a relational graph convolutional layer is applied. Similar message passing layers can be applied on the edge graph to improve the model capacity. This figure shows the update iteration for node 4 and edge (4, 7, red), respectively. + +It cannot be denied that some harmful activities could be augmented by powerful pretrained models, e.g., designing harmful drugs. We expect future studies will mitigate these issues. + +# C MORE DETAILS OF GEARNET + +In this section, we describe more details about the implementation of our GearNet. The whole pipeline of our structure-based encoder is depicted in Figure 3. + +# C.1 PROTEIN GRAPH CONSTRUCTION + +For graph construction, we use three different ways to add edges: + +1. Sequential edges. The $i$ -th residue and the $j$ -th residue will be linked by an edge if the sequential distance between them is below a predefined threshold $d _ { \mathrm { s e q } }$ , i.e., $| j - i | < d _ { \mathrm { s e q } }$ The type of each sequential edge is determined by their relative position $d = j - i$ in the sequence. Hence, there are $2 d _ { \mathrm { s e q } } - 1$ types of sequential edges. +2. Radius edges. Following previous works, we also add edges between two nodes $i$ and $j$ when the Euclidean distance between them is smaller than a threshold $d _ { \mathrm { r a d i u s } }$ . +3. K-nearest neighbor edges. Since the scales of spatial coordinates may vary among different proteins, a node will be also connected to its $\mathbf { k }$ -nearest neighbors based on the Euclidean distance. In this way, the density of spatial edges are guaranteed to be comparable among different protein graphs. + +Since we are not interested in spatial edges between residues close with each other in the sequence, we further add a filter to the latter two kinds of edges. Specifically, for a radius or KNN edge connecting the $i$ -th residue and $j$ -th residue, it will be removed if the sequential distance between them is lower than a long range interaction cutoff $d _ { \mathrm { l o n g } }$ , i.e., $| i - j | < d _ { \mathrm { l o n g } }$ . + +In this paper, we set the sequential distance threshold $d _ { \mathrm { s e q } } = 3$ , the radius $d _ { \mathrm { r a d i u s } } = 1 0 . 0$ , the number of neighbors $k = 1 0$ and the long range interaction cutoff $d _ { \mathrm { l o n g } } = 5$ . By regarding radius edges and KNN edges as two separate edge types, there will be totally $2 \bar { d } _ { \mathrm { s e q } } + 1 = 7$ different types of edges. + +Necessity of spatial edges. Here we explain the necessity of radius and KNN edges by statistics and intuitions. These two kinds of edges result in very different degree distributions. In Figure 4, we plot the average degree distribution over all proteins in AlphaFold Database v1. If we only consider KNN edges, the node degrees in protein graphs are close to a constant, which makes it difficult to capture those areas with dense interactions between residues. If we only consider radius edges, then there will be about 45,000 proteins with average degrees lower than two. In these sparse graphs, pretraining cannot capture structural information effectively, e.g., Angle Prediction with limited edge pairs and Dihedral Prediction with limited edge triplets. Such sparsity can be hard to overcome by tuning radius cutoff, for the various scales of average distance on different proteins. By simply combining two kinds of edges, we can overcome these issues. + +![](images/c4077127df8104c34006900a466b55dd5dd5e357c4a434f0727eadc191d25588.jpg) +Figure 4: The average degree distribution on AlphaFold Database. + +Node and edge features. Most previous structure-based encoders designed for biological molecules (Baldassarre et al., 2021; Hermosilla et al., 2021) used many chemical and spatial features, some of which are difficult to obtain or time-consuming to calculate. In contrast, we only use the one-hot encoding of residue types with one additional dimension for unknown types as node features, denoted as $\mathbf { \bar { f } } \in \{ 0 , 1 \} ^ { n \times 2 1 }$ , which is enough to learn good representation as shown in our experiments. + +The feature $\mathbf { \Delta } f _ { ( i , j , r ) }$ for an edge $( i , j , r )$ is the concatenation of the node features of two end nodes, the one-hot encoding of the edge type, and the sequential and spatial distances between them: + +$$ +\begin{array} { r } { \pmb { f } _ { ( i , j , r ) } = \mathrm { C a t } \left( \pmb { f } _ { i } , \pmb { f } _ { j } , \mathrm { o n e h o t } ( r ) , | i - j | , \| \pmb { x } _ { i } - \pmb { x } _ { j } \| _ { 2 } \right) , } \end{array} +$$ + +where $\mathrm { C a t } ( \cdot )$ denotes the concatenation operation. + +# C.2 ENHANCE GEARNET WITH IECONV LAYERS + +In our experiments, we find that IEConv layers are useful for predicting fold labels in spite of their relatively poor performance on function prediction tasks. Therefore, we enhance our models by adding a simplified IEConv layer as an additional layer, which achieve better results than the original IEConv. Next, we describe how to simplify the IEConv layer and how to combine it with our model. + +Simplify the IEConv layer. The original IEConv layer relies on intrinsic and extrinsic distances between two nodes, which are computationally expensive. Hence, we follow the modifications proposed in Hermosilla & Ropinski (2022), which show improvements as reported in their experiments. We briefly describe these modifications for completeness. + +In the IEConv layer, we keep the edges in our graph $\mathcal { G }$ and use $\tilde { h } _ { i } ^ { ( l ) }$ to denote the hidden representation for node $i$ in the $l$ -th layer. The update equation for node $i$ is defined as: + +$$ +\tilde { \begin{array} { r } { \tilde { \mathbf { h } } _ { i } ^ { ( l ) } = \sum _ { j \in \mathcal { N } ( i ) } k _ { o } ( f ( \mathcal { G } , i , j ) ) \cdot \mathbf { h } _ { j } ^ { ( l - 1 ) } , } \end{array} } +$$ + +where $\mathcal { N } ( i )$ is the set of neighbors of $i$ , $f ( \mathscr { G } , i , j )$ is the edge feature between $i$ and $j$ and $k _ { o } ( \cdot )$ is an MLP mapping the feature to a kernel matrix. Instead of intrinsic and extrinsic distances in the original IEConv layer, we follow New IEConv, which adopts three relative positional features proposed in Ingraham et al. (2019) and further augments them with additional input functions. + +We aim to apply this layer on our constructed protein residue graph instead of the radius graph in the original paper. Therefore, we simply remove the dynamically changed receptive fields, pooling layer and smoothing tricks in our setting. + +Combine IEConv with GearNet. Our model is very flexible to incorporate other message passing layers. To incorporate IEConv layers, we use our graph and hidden representations as input and replace the update equation Eq. (1) with + +$$ +\pmb { h } _ { i } ^ { ( l ) } = \pmb { h } _ { i } ^ { ( l - 1 ) } + \pmb { u } _ { i } ^ { ( l ) } + \tilde { \pmb { h } } _ { i } ^ { ( l ) } . +$$ + +# D SELF-PREDICTION METHODS + +The high-level ideas of the four self-prediction methods are demonstrated in Figure 5. + +Residue Type Prediction is based on the masked language modeling objective, which has been widely used in pretraining large protein language models (Bepler & Berger, 2021). For each protein, we randomly mask node features of some residues and then predict these masked residue types via structure-based encoders. This method is also known as Attribute Masking in the literature of molecules (Hu et al., 2019) and Masked Inverse Folding in the protein community (Yang et al., 2022). + +Distance Prediction aims to learn local spatial structures by predicting the Euclidean distance between two nodes connected in the protein graph. A fixed number of edges are randomly selected and masked from the original graph. Then, the representations of two end nodes will be used to predict the distances between them. + +Besides, angles and dihedrals between adjacent edges are also important features that reflect the relative position between residues Klicpera et al. (2021). Similarly, we can define the masked geometric losses Angle Prediction and Dihedral Prediction by randomly selecting and masking adjacent edge pairs and triplets. Here we discretize the angles and dihedrals by cutting the range $[ 0 , \pi ]$ into 8 bins. Then, the representations of end nodes in the masked graph will be used to predict which bin the angles between them will belong to. + +![](images/e2902ba0813754aebaa5b64fa7c97dc099dd1b4529b58d0fdb5800095fd484f3.jpg) +Figure 5: Illustration of self-prediction methods. + +# E EXPERIMENTAL DETAILS + +# E.1 DATASET STATISTICS + +Table 4: Dataset statistics for downstream tasks. + +
Dataset#Proteins
#Train# Validation#Test
Enzyme Commission15,5501,7291,919
Gene Ontology29,8983,3223,415
Fold Classification - Fold12.312736718
Fold Classification- Superfamily12,3127361,254
Fold Classification-Family12.3127361,272
Reaction Classification29,2152,5625,651
+ +Dataset statistics of downstream tasks are summarized in Table 4. Details are introduced as follows. + +Enzyme Commission and Gene Ontology. Following DeepFRI (Gligorijevic et al., 2021), the EC ´ numbers are selected from the third and fourth levels of the EC tree, forming 538 binary classification tasks, while the GO terms with at least 50 and no more than 5000 training samples are selected. The non-redundant sets are partitioned into training, validation and test sets according to the sequence identity. We retrieve all protein chains from PDB with the code in their codebase and remove those with obsolete pdb ids, so the statistics will be slightly different from that in the original paper. + +Fold Classification. We directly use the dataset in Hermosilla et al. (2021), which consolidated 16,712 proteins with 1,195 different folds from the SCOPe 1.75 database (Murzin et al., 1995). + +Reaction Classification. The dataset comprises 37,428 proteins categorized into 384 reaction classes. The split methods are described in Hermosilla et al. (2021), where they cluster protein chains via sequence similarities and ensure that protein chains from the same cluster are in the same split. + +# E.2 EVALUATION METRICS + +Now we introduce the details of evaluation metrics for EC and GO prediction. These two tasks aim to answer the question: whether a protein has some particular functions, which can be seen as multiple binary classification tasks. + +The first metric, protein-centric maximum F-score $\mathrm { F } _ { \mathrm { m a x } }$ , is defined by first calculating the precision and recall for each protein and then taking the average score over all proteins. More specifically, for a given target protein $i$ and a decision threshold $t \in [ 0 , 1 ]$ , the precision and recall are computed as: + +$$ +\mathrm { p r e c i s i o n } _ { i } ( t ) = \frac { \sum _ { f } \mathbb { 1 } [ f \in P _ { i } ( t ) \cap T _ { i } ] } { \sum _ { f } \mathbb { 1 } [ f \in P _ { i } ( t ) ] } , +$$ + +and + +$$ +\mathrm { r e c a l l } _ { i } ( t ) = \frac { \sum _ { f } { \mathbb { 1 } [ f \in P _ { i } ( t ) \cap T _ { i } ] } } { \sum _ { f } { \mathbb { 1 } [ f \in T _ { i } ] } } , +$$ + +where $f$ is a function term in the ontology, $T _ { i }$ is a set of experimentally determined function terms for protein $i$ , $P _ { i } ( t )$ denotes the set of predicted terms for protein $i$ with scores greater than or equal to $t$ and $\mathbb { 1 } [ \cdot ] \in \{ 0 , 1 \}$ is an indicator function that is equal to 1 iff the condition is true. + +Then, the average precision and recall over all proteins at threshold $t$ is defined as: + +$$ +\operatorname { p r e c i s i o n } ( t ) = { \frac { 1 } { M ( t ) } } \sum _ { i } \operatorname { p r e c i s i o n } _ { i } ( t ) , +$$ + +and + +$$ +\mathrm { r e c a l l } ( t ) = \frac { 1 } { N } \sum _ { i } \mathrm { r e c a l l } _ { i } ( t ) , +$$ + +where we use $N$ to denote the number of proteins and $M ( t )$ to denote the number of proteins on which at least one prediction was made above threshold $t$ , i.e., $| P _ { i } ( t ) | > 0$ . + +Combining these two measures, the maximum F-score is defined as the maximum value of $\mathrm { F }$ -measure over all thresholds. That is, + +$$ +\mathrm { F } _ { \mathrm { m a x } } = \operatorname* { m a x } _ { t } \left\{ \frac { 2 \cdot \mathrm { p r e c i s i o n } ( t ) \cdot \mathrm { r e c a l l } ( t ) } { \mathrm { p r e c i s i o n } ( t ) + \mathrm { r e c a l l } ( t ) } \right\} . +$$ + +The second metric, pair-centric area under precision-recall curve $\mathrm { \Delta A U P R _ { p a i r } }$ , is defined as the average precision scores for all protein-function pairs, which is exactly the micro average precision score for multiple binary classification. + +# E.3 IMPLEMENTATION DETAILS + +In this subsection, we describe implementation details of all baselines and our methods. For all models, the outputs will be fed into a three-layer MLP to make final prediction. The dimension of hidden layers in the MLP is equal to the dimension of model outputs. + +CNN (Shanehsazzadeh et al., 2020). Following the finding in Shanehsazzadeh et al. (2020), we employ a convolutional neural network (CNN) to encode protein sequences. Specifically, 2 convolutional layers with 1024 hidden dimensions and kernel size 5 constitute this baseline model. + +ResNet (Rao et al., 2019). We also adopt a deep CNN model, i.e., the ResNet for protein sequences proposed by Rao et al. (2019), in our benchmark. This model is with 12 residual blocks and 512 hidden dimensions, and it uses the GELU (Hendrycks & Gimpel, 2016) activation function. + +LSTM (Rao et al., 2019). The bidirectional LSTM model proposed by Rao et al. (2019) is another baseline for protein sequence encoding. It is composed of three bidirectional LSTM layers with 640 hidden dimensions. + +Transformer (Rao et al., 2019). The self-attention-based Transformer encoder (Vaswani et al., 2017) is a strong model in natural language processing (NLP), Rao et al. (2019) adapts this model into the field of protein sequence modeling. We also adopt it as one of our baselines. This model has a comparable size with BERT-Small (Devlin et al., 2018), which contains 4 Transformer blocks with 512 hidden dimensions and 8 attention heads, with activation GELU (Hendrycks & Gimpel, 2016). + +GCN (Kipf & Welling, 2017). We take GCN as a baseline to encode the residue graph derived by our graph construction scheme. We adopt the implementation in TorchDrug (Zhu et al., 2022), where 6 GCN layers with the hidden dimension of 512 are used. We run the results of GCN on EC and GO by ourselves and take its results on Fold and Reaction classification from Hermosilla et al. (2021). + +GAT (Velickovi ˇ c et al., 2018). ´ We adopt another popular graph neural network, GAT, as a structurebased baseline. We follow the implementation in TorchDrug and use 6 GAT layers with the hidden dimension of 512 and 1 attention head per layer for encoding. The results on EC, Fold and Reaction classification are based on our runs, and the results on GO are taken from Wang et al. (2022b). + +GVP (Jing et al., 2021). The GVP model (Jing et al., 2021) is a decent protein structure encoder. It iteratively updates the scalar and vector representations of a protein, and these representations possess the merit of invariance and equivariance. In our benchmark, we evaluate this baseline method following the official source code. In specific, 3 GVP layers with 32 feature dimensions (20 scalar and 4 vector channels) constitute the GVP model. + +3DCNN_MQA (Derevyanko et al., 2018). We implement the 3DCNN model from the paper (Derevyanko et al., 2018) with a box width of 40.0 and input resolution of $1 2 0 \times 1 2 0 \times 1 2 0$ . The model has 6 residual blocks and 128 hidden dimensions with ELU activation function. + +GraphQA (Baldassarre et al., 2021). Following hyperparameters in the original paper, we construct residue graphs based on bond and spatial information and re-implement the graph neural network. The best model has 4 layers with 128 node features, 32 edge features and 512 global features. + +New IEConv (Hermosilla & Ropinski, 2022). Since the code for New IEConv has not been made public when the paper is written, we reproduce the method according to the description in the paper and achieve similar results on Fold and Reaction classification tasks. Then, we evaluate the method on EC and GO prediction tasks with the default hyperparameters reported in the original paper and follow the standard training procedure on these two tasks. + +DeepFRI (Gligorijevic et al., 2021). ´ We also evaluate DeepFRI (Gligorijevic et al., 2021) in our ´ benchmark, which is a popular structure-based encoder for protein function prediction. DeepFRI employs an LSTM model to extract residue features and further constructs a residue graph to propagate messages among residues, in which a 3-layer graph convolutional network (GCN) (Kipf & Welling, 2017) is used. We directly utilize the official model checkpoint for baseline evaluation. + +ESM-1b (Rives et al., 2021). Besides the from-scratch sequence encoders above, we also compare with two state-of-the-art pretrained protein language models. ESM-1b (Rives et al., 2021) is a huge Transformer encoder model whose size is larger than BERT-Large (Devlin et al., 2018), and it is pretrained on 24 million protein sequences from UniRef50 (Suzek et al., 2007) by masked language modeling (MLM) (Devlin et al., 2018). In our evaluation, we finetune the ESM-1b model with the learning rate that is one-tenth of that of the MLP prediction head. + +ProtBERT-BFD (Elnaggar et al., 2021). The other protein language model evaluated in our benchmark is ProtBERT-BFD (Elnaggar et al., 2021) whose size also excesses BERT-Large (Devlin et al., 2018). This model is pretrained on 2.1 billion protein sequences from BFD (Steinegger & Söding, 2018) by MLM (Devlin et al., 2018). The evaluation of ProtBERT-BFD uses the same learning rate configuration as ESM-1b. + +LM-GVP (Wang et al., 2022b). To further enhance the effectiveness of GVP (Jing et al., 2021), Wang et al. (2022b) proposed to prepend a protein language model, i.e. ProtBERT (Elnaggar et al., + +Table 5: Hyperparameter configurations of our model on different datasets. The batch size reported in the table refers to the batch size on each GPU. All the hyperparameters are chosen by the performance on the validation set. + +
HyperparameterECGOFoldReaction
GNN#layer6666
hidden dim.512512512512
dropout0.10.10.20.2
LearningoptimizerAdamAdamSGDSGD
learning rate1e-41e-41e-31e-3
weight decay005e-45e-4
batch size2222
# epoch200200300300
+ +Table 6: $\mathrm { F } _ { \mathrm { m a x } }$ on EC and GO tasks under different sequence cutoffs ( $30 \%$ / 40% / 50% / 70% / 95%). + +
MethodECGO-BPGO-MFGO-CC
CNN0.366/0.361/0.372/0.429/0.5450.197/0.195/0.197/0.211/0.2440.238/0.243/0.256/0.292/0.3540.258/0.257/0.260/0.263/0.387
ResNet0.409/0.412/0.450/0.526/0.6050.230/0.230/0.234/0.249/0.2800.282/0.288/0.308/0.347/0.4050.277/0.273/0.280/0.278/0.304
LSTM0.247/0.249/0.270/0.333/0.4250.194/0.192/0.195/0.205/0.2250.223/0.229/0.245/0.276/0.3210.263/0.264/0.269/0.270/0.283
Transformer0.167/0.173/0.175/0.197/0.2380.267/0.265/0.262/0.262/0.2640.184/0.187/0.195/0.204/0.2110.378/0.382/0.388/0.395/0.405
GCN0.245/0.246/0.246/0.280 /0.3200.251/0.250/0.248/0.248/0.2520.180/0.183/0.187/0.194/0.1950.318/0.318/0.320/0.323/0.329
GearNet0.557 /0.570/0.615/0.693/0.7300.309/0.309/0.315/0.336/0.3560.382/0.397 /0.425/0.474/0.5030.381/0.385/0.393 /0.398/0.414
GearNet-edge0.625/0.646/0.694/0.757/0.8100.345/0.347/0.354/0.378/0.4030.444/0.461/0.490 /0.537/0.5800.394/0.394/0.401/0.408/0.450
DeepFRI0.470 /0.505 /0.545/0.600 /0.6310.361/0.362/0.371/0.391/0.3990.374/0.383 /0.409 /0.446/0.4650.440/0.441/0.444/0.451/ 0.460
ESM-1b0.737/0.764/0.797/0.839 /0.8640.394/0.399/0.407/0.429/0.4520.546/0.562/0.588/0.625/0.6570.462/0.465/0.468/0.465/0.477
Multiview Contrast0.744/0.769/0.808/0.848/0.8740.436/0.442/0.449/0.471/0.4900.533/0.548/0.573/0.612/0.6540.459/0.460/0.467/0.469/0.488
+ +2021), before GVP to additionally utilize protein sequence representations. We also adopt this hybrid model as one of our baselines, and its implementation follows the official source code. + +Our methods. For pretraining, we use Adam optimizer with learning rate 0.001 and train a model for 50 epochs. Then, the pretrained model will be finetuned on downstream datasets. + +For Multiview Contrast, we set the cropping length of subsequence operation as 50, the radius of subspace operation as 15, the mask rate of random edge masking operation as 0.15. The temperature $\tau$ in the InfoNCE loss function is set as 0.07. When pretraining GearNet-Edge and GearNet-EdgeIEConv, we use 96 and 24 as batch sizes, respectively. + +For Distance Prediction, we set the number of sampled residue pairs as 256. The batch size will be set as 128 and 32 for GearNet-Edge and GearNet-Edge-IEConv, respectively. For Residue Type, Angle and Dihedral Prediction, we set the number of sampled residues, residue triplets and residue quadrants as 512. The batch size will be set as 96 and 32 for GearNet-Edge and GearNet-Edge-IEConv, respectively. + +For downstream evaluation, the hidden representations in each layer of GearNet will be concatenated for the final prediction. Table 5 lists the hyperparameter configurations for different downstream tasks. For the four tasks, we use the same optimizer and number of epochs as in the original papers to make fair comparison. For EC and GO prediction, we use ReduceLROnPlateau scheduler with factor 0.6 and patience 5, while we use StepLR scheduler with step size 50 and gamma 0.5 for fold and reaction classification. + +# F ADDITIONAL EXPERIMENTAL RESULTS ON EC AND GO PREDICTION + +Results under different sequence identity cutoffs. Besides the experiments in Section 5, where $9 5 \%$ is used as the sequence identity cutoff for EC and GO dataset splitting, we also test our models and several important baselines under four lower sequence identity cutoffs and show the experimental results in Table 6. The aim of this experiment is to test the robustness of different models under different hold-out test sets, with lowering cutoff indicating lower similarity between training and test sets. It can be observed that, at lower cutoffs, our model can still achieve the best performance among models without pretraining and get comparable or better results against ESM-1b after pretraining. + +Table 7: AUPR on EC and GO prediction. [†] denotes results taken from Wang et al. (2022b). For pretraining, we select the model with the best performance when training from scratch, i.e., GearNet-Edge. We omit the model name and use pretraining methods to name our pretrained models. + +
MethodPretraining Dataset (Size)ECGO
BPMFCC
CNN (Shanehsazzadeh et al., 2020)0.5260.1590.3510.204
ResNet (Rao et al.,2019)0.5900.2050.4340.214
LSTM (Rao et al., 2019)0.4140.1560.3340.192
Transformer (Rao et al.,2019)0.2180.1560.1770.210
Wfrienirecnn GCN (Kipf & Welling,2017)0.3190.1360.1470.175
GAT (Velickovic et al.,2018)0.3200.1710.329†0.249†
GVP (Jing et al.,2021)0.4820.2240.458†0.279†
3DCNN_MQA (Derevyanko et al.,2018)0.0290.1320.0750.144
GraphQA (Baldassarre et al.,2021)0.5430.1990.3470.265
New IEConv (Hermosilla & Ropinski,2022)0.7750.2730.5720.316
GearNet0.7510.2110.4900.276
GearNet-IEConv0.8350.2310.5470.259
GearNet-Edge0.8350.2510.5700.303
GearNet-Edge-IEConv0.8430.2440.5610.284
DeepFRI(Gligorijevic et al.,2021)Pfam (10M)0.5470.2820.4620.363
ESM-1b (Rives et al.,2021) Wreaed nUniRef50 (24M)0.8890.3320.6390.324
ProtBERT-BFD (Elnaggar et al.,2021)BFD (2.1B)0.8590.1880.464†0.234
LM-GVP (Wang et al., 2022b)UniRef100 (216M)0.7100.302†0.5800.423†
Residue Type PredictionAlphaFoldDB (805K)0.8700.2670.5830.311
Distance PredictionAlphaFoldDB (805K)0.8630.2740.5860.327
Angle PredictionAlphaFoldDB (805K)0.8800.2910.6030.331
Dihedral PredictionAlphaFoldDB (805K)0.8810.3040.6030.338
Multiview ContrastAlphaFoldDB (805K)0.8920.2920.5960.336
+ +AUPR on EC and GO prediction. We have reported experimental results on EC and GO prediction with $\mathrm { F } _ { \mathrm { m a x } }$ as the metric in Section 5. Here we report another popular metric AUPR in Table 7. Note that we still use the best model selected by $\mathrm { F } _ { \mathrm { m a x } }$ on validation sets. It can be observed that our model can still achieve the best performance on EC prediction in both from scratch and pretrained settings. However, there are still non-trivial gaps between our models with the state-of-the-art results. This probably is because of the inconsistency between the two evaluation metrics. It would be interesting to study the relationship between these two metrics and develop a model good at both in future works. + +Sampling schemes in self-prediction methods. Different sampling schemes may lead to different results for self-prediction methods. We study the effects of sampling schemes using Dihedral Prediction as an example. Instead of sampling dihedral angles formed by three consecutive edges, we try to predict the dihedrals formed by four randomly sampled nodes. We observe that the $\mathrm { F } _ { \mathrm { m a x } }$ decreases from 0.859 to 0.821. This suggests that it is better of learning residue representations to capture local spatial information instead of global information. The change of sampling schemes will make self-prediction tasks more difficult to solve, which even brings negative effects after pretraining. + +Pretraining on different datasets. We use the AlphaFold protein structure database as our pretraining database, because it contains the largest number of protein structures and is planned to cover over 100 million proteins. However, the structures in this database are not experimentally determined but predicted by AlphaFold2. Therefore, it is interesting to see the performance of our methods when pretraining on different datasets. + +To study the effects of the choice of pretraining dataset, we build another dataset using structures extracted from Protein Data Bank (PDB) (Berman et al., 2000). Specifically, we extract 123,505 experimentally-determined protein structures from PDB whose resolutions are between 0.0 and 2.5 angstroms, and we further extract 305,265 chains from these proteins to construct the final dataset. + +Next, we pretrain our five methods on AlphaFold Database v1 (proteome-wide structure predictions), AlphaFold Database v2 (Swiss-Prot structure predictions) and Protein Data Bank and then evaluate the pretrained models on the EC prediction task. The results are reported in Table 8. As can be seen in the table, our methods can achieve comparable performance on different pretraining datasets. Consequently, our methods are robust to the choice of pretraining datasets. + +Table 8: Results of GearNet-Edge pretrained on different pretraining datasets with different methods. Models are evaluated on the EC prediction task. + +
Dataset# ProteinsMultivew Contrast FmaxResidue Type PredictionDistance PredictionAngle PredictionDihedral Prediction
AUPRpairAUPRpairFmaxAUPRpairFmaxAUPRpairFmaxAUPRpairFmax
AlphaFold Database (v1 + v2)804,8720.8920.8740.8700.8340.8630.8390.8800.8530.8810.859
AlphaFold Database (v1)365,1980.8900.8740.8690.8420.8710.8430.8790.8540.8770.852
AlphaFold Database (v2)439,6740.8900.8740.8680.8380.8680.8460.8810.8530.8830.861
Protein Data Bank305,2650.8810.8590.8700.8410.8650.8470.8800.8570.8860.858
+ +# G STRUCTURE PRETRAINING ON EGNN + +To verify the effectiveness of our proposed methods, we choose another common backbone model, equivariant graph neural network (EGNN) (Satorras et al., 2021), for pretraining. We follow the experimental setup in Appendix E.3 for pretraining and finetuning the model. The results on the EC dataset are reported in Table 9. It can be seen that the performance of the EGNN is improved by a large margin with all the five pretraining methods. Among them, Distance Prediction and Multiview Contrast are the top two methods. The ranks of these five methods are quite different from the ranks in the main paper. This is probably because the capacity of EGNN limits + +
MethodFmax
EGNN0.640
Residue Type Prediction Distance Prediction0.729 0.761
Angle Prediction Dihedral Prediction0.718
Multiview Contrast0.662 0.752
+ +Table 9: Pretraining results on EC with EGNN as backbone models. + +its performance on some pretraining tasks and thus reduces their benefits. + +# H COMBINE SEQUENCE- AND STRUCTURE-BASED ENCODERS + +In the main paper, we compare the pretrained sequence- and structure-based encoder and show that geometric structure pretraining can achieve competitive results with much less data. To further show the benefit of incorporating structural information, here we choose ESM-1b as a baseline and build a structure-based encoder based on its output. Specifically, we replace the raw node features in GearNet with pretrained sequence representations. We train the model on EC with the same configurations for GearNet and finetune the ESM-1b model with learn + +
MethodECGO
BPMFCC
GearNet0.7300.3560.5030.414
GearNet-Edge0.8100.4030.5800.450
-w/ Multiview Contrast0.8740.4900.6540.488
ESM-1b0.8640.4520.6570.477
ESM-1b+GearNet0.8830.4910.6770.501
+ +Table 10: Results $\left( \mathrm { F } _ { \operatorname* { m a x } } \right)$ for combining seuqence- and structure-based encoders. + +ing rate 1e-5. The results are shown in Table 10. It can be observed that the ESM- $^ { 1 \mathrm { b } + }$ GearNet model can achieve SOTA performance even without structure-based pretraining, which suggests the importance of utilizing protein structures. Also, it is promising to explore pretraining methods on the combined encoder. We leave this direction for future work. + +# I COMBINE NEURAL AND RETRIEVAL-BASED METHODS + +Searching a database to retrieve similar proteins is a popular method used in the biological community when predicting properties of a target protein, e.g., searching multiple sequence alignments and templates for structure prediction (Jumper et al., 2021). There have been a large amount of tools proposed for aligning protein sequences (Altschul et al., 1997; Steinegger & Söding, 2017; Steinegger et al., 2019) and structures (Yang & Tung, 2006; Zhang & Skolnick, 2005; van Kempen et al., 2022; Holm, 2019). In this section, we first compare our neural representation-based method with retrieval-based methods on function and fold classification tasks and then showcase the potential of our proposed methods on structure-based search tasks. + +Comparison with retrieval-based methods. We select a structure alignment tool, Foldseek (van Kempen et al., 2022), as our retrieval-based baseline. The method trains a VQ-VAE on SCOPe40 to discretize structural units into an alphabet of twenty 3Di states and then transforms the problem to 3Di sequence alignment, which is done by MMseqs2 (Steinegger & Söding, 2017). When using + +
MethodECGO-BPGO-MFGO-CCFold Classification
AUPRpairFmaxAUPRpairFmaxAUPRpairFmaxAUPRpairFmaxFoldSuper.Fam.Avg.
Foldseek (van Kempen et al., 2022)0.7780.8880.1680.4400.4620.6490.1590.3212.787.5765.425.2
GearNet-Edge(-IEConv)0.8350.8100.2510.4030.5700.5800.3030.45048.370.399.572.7
w/Multiview Contrast0.8920.8740.2920.4900.5960.6540.3360.48854.180.599.978.1
w/Multiview Contrast + Foldseek0.9080.9030.3140.5000.6150.6730.3190.467----
+ +Table 11: Comparison between neural and retrieval-based methods on EC, GO and fold classification tasks. As in Table 2, we use GearNet-Edge on EC and GO prediction and GearNet-Edge-IEConv on fold classification as backbone models. The results w/o and w/ pretraining and those ensembled with Foldseek are reported on EC and GO. We omit the ensemble results on fold classification due to the poor performance of Foldseek. + +Foldseek, we follow the parameters provided in their github repo2. For each protein in the test set of our benchmark tasks, we use Foldseek to retrieve the most similar protein in the training set, the label of which will be used for prediction. + +We report the results of retrieval-based and our proposed neural methods in Table 11. First, we find that Foldseek achieves very good performance on EC and GO prediction. In terms of $\mathrm { F } _ { \mathrm { m a x } }$ , it is better than GearNet-Edge on all tasks and competitive with the pretrained GearNet-Edge on EC and GO-MF. The accuracy of Foldseek makes it a strong baseline for proteins with similar structures in the training set. However, when the dataset is split by structural similarities, e.g., fold classification, the structural alignment tool fails to retrieve similar proteins and get accurate prediction as shown in the table. This can be attributed to the inherent limitation of retrieval-based methods, i.e., the lack of generalization ability to novel data points. + +Furthermore, to utilize the advantages from both worlds, we combine neural and retrieval-based methods via ensemble. As shown in the last row of Table 11, both metrics are significantly improved on EC, GO-BP, GO-MF compared with the separate neural and retrieval-based methods. Consequently, it would be interesting to explore the combination of these two kinds of methods in the future, as have done in many machine learning tasks (Mitra & Craswell, 2017; Sun et al., 2019; Notin et al., 2022). + +Results on structure-based search tasks. To show the potential of structure-based modeling for biological applications, we test our model on the $\mathrm { S C O P e 4 0 }$ benchmark proposed in van Kempen et al. (2022). The authors cluster the SCOPe 2.0198 at $40 \%$ sequence identity and obtain 11,211 non-redundant protein sequences. They perform an all-versus-all search on the dataset and test the ability of structure alignment tools for finding proteins of the same SCOPe family, superfamily, and fold. For each query, they measure the fraction of TPs (true positive matches) out of all correct matches until the first FP (false positive) that matches to a different fold. The sensitivity is calculated by the area under the curve of the cumulative ROC curve up to the first FP. + +Table 12: Sensitivity of searching proteins of the same family, superfamily and fold on SCOPe40. Results are evaluated with the scripts and predictions provided in (van Kempen et al., 2022). + +
MethodFoldSuper.Fam.Avg.
MMseqs2 (Steinegger & Soding, 2017)0.0010.0820.5420.208
3D-BLAST (Yang & Tung,2006)0.0090.1260.5720.235
CLE-SW (Zhao et al., 2013)0.0210.2930.7630.359
CE (Shindyalov & Bourne,1998)0.1310.5290.8850.515
TMalign-fast (Zhang& Skolnick,2005)0.1880.6180.9060.571
TMalign (Zhang & Skolnick,2005)0.1880.6100.9010.566
Foldseek (van Kempen et al., 2022)0.1550.5930.9140.554
DALI (Holm,2019)0.3100.7510.9420.667
GearNet-Edge-IEConv0.4740.7220.9360.710
GearNet-Edge-IEConv+DALI0.4810.7790.9630.741
+ +![](images/c7e9fb2318b47d2c35ebd16933c90e34626e6eea1490cd41a72061fd46d48eca.jpg) +Figure 6: Latent space visualization of GearNet-Edge (Multiview Contrast) on AlphaFold Database v1. + +We report the results of seven structure alignment tools and a sequence search tool evaluated in van Kempen et al. (2022). For comparison, we use the GearNet-Edge-IEConv model trained on fold classification to extract representations for proteins and use the cosine similarity between representations to retrieve similar proteins. The sensitivity of these methods is reported in Table 12. It can be observed that our method achieves the best performance on average among all baselines. Compared with DALI, though finding fewer proteins of the same family and superfamily, our method can achieve higher sensitivity at the fold level. This can be explained by the better generalization ability to novel structures of neural methods. With the ensemble of neural and retrieval-based methods, we can achieve the SOTA performance at all levels. This again demonstrates the effectiveness of our proposed method and the potential of combining neural and retrieval-based methods. + +# J LATENT SPACE VISUALIZATION + +For qualitatively evaluating the quality of the protein embeddings learned by our pretraining method, we visualize the latent space of the GearNet-Edge model pretrained by Multiview Contrast. Specifically, we utilize the pretrained model to extract the embeddings of all the proteins in AlphaFold Database v1, and these embeddings are mapped to the two-dimensional space by UMAP (McInnes et al., 2018) for visualization. Following Akdel et al. (2021), we highlight the 20 most common superfamilies within the database by different colors. The visualization results are shown in Fig. 6. It can be observed that our pretrained model tends to group the proteins from the same superfamily together and divide the ones from different superfamilies apart. In particular, it succeeds in clearly separating three superfamilies, i.e., Protein kinase superfamily, Cytochrome P450 family and TRAFAC class myosin-kinesin ATPase superfamily. Such a decent capability of discriminating protein superfamilies, to some degree, interprets our model’s superior performance on Fold Classification. + +![](images/075c05dacaaa557465ed1ecb1c80a739cdfaa4cbaa71d87f1cb712d2ce9c07db.jpg) +Figure 7: Identification of active sites on proteins responsible for binding based on attribution scores. Two proteins binding to specific targets are selected for illustration (1NYR-A for ATP binding and 1B85-A for Heme binding). For these two complexes, ligands are shown in yellow spheres while the residues of the receptors are colored based on attribution scores. Residues with higher attribution scores are colored in red while those with lower scores are colored in blue. + +# K RESIDUE-LEVEL EXPLANATION + +Protein functions are often reflected by specific regions on the 3D protein structures. For example, the binding ability of a protein to a ligand is highly related to the binding interface between them. Hence, to better interpret our prediction, we apply Integrated Gradients (IG) (Sundararajan et al., 2017), a model-agnostic attribution method, on our model to obtain residue-level interpretation. Specifically, we first select two molecular functions, ATP binding (GO:0005524) and Heme binding (GO:0020037), from GO terms that are related to ligand binding. For each functional term, we pick one protein and feed it into the best model trained on the GO-MF dataset. Then, we use IG to generate the feature attribution scores for each protein. The method will integrate the gradient along a straight-line path between a baseline input and the original input. Here the original input and baseline input are the node feature $f$ and a zero vector, respectively. The final attribution score for each protein will be obtained by summing over the feature dimension. The normalized score distribution over all residues are visualized in Figure 7. As can be seen, our model is able to identify the active sites around the ligand, which are likely to be responsible for binding. Note that these attributions are directly generated from our model without any supervision, which suggests the decent interpretability of our model. \ No newline at end of file diff --git a/md/dev/tro0_OqIVde/tro0_OqIVde.md b/md/dev/tro0_OqIVde/tro0_OqIVde.md new file mode 100644 index 0000000000000000000000000000000000000000..8b709295eb2a59a71b6934bd183f58b4b9d6eb73 --- /dev/null +++ b/md/dev/tro0_OqIVde/tro0_OqIVde.md @@ -0,0 +1,306 @@ +# HorNet: Efficient High-Order Spatial Interactions with Recursive Gated Convolutions + +Yongming Rao1∗ Wenliang Zhao1∗ Yansong Tang1 Jie Zhou1† Ser-Nam Lim2† Jiwen Lu1† 1Tsinghua University 2Meta AI + +# Abstract + +Recent progress in vision Transformers exhibits great success in various tasks driven by the new spatial modeling mechanism based on dot-product self-attention. In this paper, we show that the key ingredients behind the vision Transformers, namely input-adaptive, long-range and high-order spatial interactions, can also be efficiently implemented with a convolution-based framework. We present the Recursive Gated Convolution $( g ^ { n } \mathbf { C } \mathbf { o n v } )$ that performs high-order spatial interactions with gated convolutions and recursive designs. The new operation is highly flexible and customizable, which is compatible with various variants of convolution and extends the two-order interactions in self-attention to arbitrary orders without introducing significant extra computation. $g ^ { n } \mathbf { C } \mathbf { o n v }$ can serve as a plug-and-play module to improve various vision Transformers and convolution-based models. Based on the operation, we construct a new family of generic vision backbones named HorNet. Extensive experiments on ImageNet classification, COCO object detection and ADE20K semantic segmentation show HorNet outperform Swin Transformers and ConvNeXt by a significant margin with similar overall architecture and training configurations. HorNet also shows favorable scalability to more training data and a larger model size. Apart from the effectiveness in visual encoders, we also show $g ^ { n } \mathbf { C } \mathbf { o n v }$ can be applied to task-specific decoders and consistently improve dense prediction performance with less computation. Our results demonstrate that $g ^ { n } \mathbf { C o n v }$ can be a new basic module for visual modeling that effectively combines the merits of both vision Transformers and CNNs. Code is available at https://github.com/raoyongming/HorNet. + +# 1 Introduction + +Convolutional neural networks (CNN) have driven remarkable progress in deep learning and computation vision since the introduction of AlexNet [31] in the last decade. There are quite a few nice properties of CNNs making them naturally suitable for a wide range of vision applications. Translation equivariance introduces useful inductive biases to major vision tasks and enables transferability across different input resolutions. The highly optimized implementation makes it efficient on both high-performance GPUs and edge devices. The evolution of architectures [32, 31, 49, 50, 22, 24, 51] further increases its popularity on various vision tasks. + +The emergence of Transformer-based architectures [16, 52, 42] greatly challenges the dominance of CNNs. By combining some successful designs in CNN architectures and the new self-attention mechanism, vision Transformers have shown leading performance on various vision tasks such as image classification [12, 42, 48], object detection [70, 41], semantic segmentation [6, 8] and video understanding [64, 18]. What makes vision Transformers more powerful than CNNs? Some efforts have been made to improve the CNN architectures by learning from the new designs in vision + +![](images/7bfa86cfd205160de54bfd56842d48f5b75ee97fbab30cf9c058085f7d508530.jpg) +Figure 1: Illustration of our main idea. We show representative spatial modeling operations that perform different orders of interactions. In this paper, we focus on studying explicit spatial interactions between a feature (red) and its neighboring region (light gray). (a) The standard convolution operation does not explicitly consider the spatial interaction. (b) Dynamic convolution [28, 4] and SE [25] introduce the dynamic weights to improve the modeling power of convolutions with extra spatial interactions. (c) The self-attention operation [56] performs two-order spatial interactions with two successive matrix multiplications. (d) $g ^ { n } \mathbf { C o n v }$ realizes arbitrary-order spatial interactions using a highly efficient implementation with gated convolutions and recursive deigns. + +Transformers. [43] presents a thorough study to adopt the meta architecture of vision Transformer to improve CNNs and proposes to use a large $7 \times 7$ kernel to construct a modern CNN. [46] and [14] propose to use even larger kernels to learn long-range relations with global filters and up to $3 1 \times 3 1$ convolutions, respectively. [20] shows that the input-adaptive weights play a key role in vision Transformers and achieve similar performance with Swin Transformers with dynamic convolutions [4, 28]. However, the effectiveness of dot-product self-attention in vision tasks has not been analyzed from the prospective of high-order spatial interactions. + +While there exists complex and often high-order interactions between two spatial locations in a deep model due to the non-linearity, the success of self-attention and other dynamic networks suggests that the explicit and high-order spatial interactions introduced by the architectural designs are beneficial to improving the modeling power of vision models. As illustrated in Figure 1, the plain convolution operation does not explicitly consider the spatial interactions between a spatial location (i.e., the red feature) and its neighboring region (i.e., the light gray region). Enhanced convolution operations like dynamic convolution [4, 28, 20] introduce explicit spatial interaction by generating dynamic weights. The dot-product self-attention operation in Transformers [56] consists of two successive spatial interactions by performing matrix multiplication among queries, keys and values. The trend of the basic operations for visual modeling indicates that the network capacity can be improved by increasing the order of spatial interactions. + +In this paper, we summarize that the key ingredient behind the success of vision Transformers is the new way of spatial modeling with input-adaptive, long-range and high-order spatial interactions performed by the self-attention operation. While previous work has successfully migrated the meta architecture [43, 20, 46, 14], input-adaptive weight generation strategy [20] and large-range modeling ability [46, 14] of vision Transformers to CNN models, a higher-order spatial interaction mechanism has not been studied. We show that all the three key ingredients can be efficiently implemented using a convolution-based framework. We propose the Recursive Gated Convolution $( g ^ { n } \mathbf { C } \mathbf { o n v } )$ that performs high-order spatial interactions with gated convolutions and recursive deigns. Instead of simply imitating the successful designs in self-attention, $g ^ { n } \mathbf { C } \mathbf { o n v }$ has several extra favorable properties: 1) Efficient. The convolution-based implementation avoids the quadratic complexity of self-attention. The design that progressively increases the channel width during performing spatial interactions also enables us to achieve higher-order interactions with bounded complexity; 2) Extendable. We extend the two-order interaction in self-attention to arbitrary orders to further improve the modeling power. Since we do not make assumptions on the type of spatial convolution, $g ^ { n } \mathbf { C } \mathbf { o n v }$ is compatible with various kernel size and spatial mixing strategies like [46, 14]; 3) Translation-equivariant. $g ^ { n } \mathbf { C o n v }$ fully inherits the translation equivariance of the standard convolution, which introduces beneficial inductive biases to major vision tasks and avoids the asymmetry brought by local attention [42, 34]. + +Based on $g ^ { n } \mathbf { C o n v }$ , we construct a new family of generic vision backbones named HorNet. We conduct extensive experiments on ImageNet classification [13], COCO object detection [38] and ADE20K semantic segmentation [71] to verify the effectiveness of our models. With the same $7 \times 7$ kernel/window and similar overall architecture and training configurations, HorNet outperforms Swin and ConvNeXt by a large margin on all tasks at different levels of complexity. The gap can be further enlarged by using a global kernel size [46]. HorNet also shows favorable scalability to more training data and larger model size, attaining $8 7 . 7 \%$ top-1 accuracy on ImageNet, $5 7 . 9 \%$ mIoU on ADE20K val and $5 9 . 2 \%$ bounding box AP on COCO val with ImageNet-22K pre-training. Apart from applying $g ^ { n } \mathbf { C } \mathbf { o n v }$ in visual encoders, we further test the generality of our designs on task-specific decoders. By adding $g \mathrm { C o n v }$ to the widely used feature fusion model FPN [36], we develop HorFPN to model the high-order spatial relationships of features from different hierarchical levels. We observe that HorFPN can also consistently improve various dense prediction models with lower computational costs. Our results demonstrate that $g ^ { n } \mathbf { C } \mathbf { o n v }$ can be a promising alternative to self-attention for visual modeling and effectively combine the merits of both vision Transformers and CNNs. + +# 2 Related Work + +Vision Transformers. The Transformer architecture [56] is originally designed for the natural language processing tasks. Since Dosovitskiy et al. [16] show that vision models constructed only by the Transformer blocks and a patch embedding layer can also achieve competitive performance to CNNs, many new models have been proposed to modify the Transformer-based architecture and make it more suitable for various vision tasks [42, 58, 60, 9, 66, 55]. Different from the original designs in [16], state-of-the-art vision Transformers usually utilize a CNN-like hierarchical architecture and change the global self-attention among all patches to local self-attention to avoid the quadratic complexity. In this paper, we follow the overall architecture of the previous hierarchical vision Transformers [42] and replace the self-attention sub-layer with our proposed $g ^ { n } \mathbf { C } \mathbf { o n v }$ to fairly compare with the previous Transformer-based models. + +Convolution-based models. Inspired by the recent success of vision Transformers, several papers propose to adopt the Transformer-style architecture and spatial convolutions with a large kernel size to improve the performance of CNNs. Han et al. [20] replace the window self-attention in Swin Transformers with large-kernel dynamic convolutions and achieve better performance. GFNet [46] proposes to perform the global spatial interactions like vision Transformers with global filters in the frequency domain, which are equivalent to depth-wise convolutions with a global kernel size and circular padding. ConvNeXt [43] thoroughly analyzes the designs in recent vision Transformers and presents a strong convolutional model with $7 \times 7$ depth-wise convolutions. RepLKNet [14] explores CNN models with very large kernels (up to $3 1 \times 3 1$ ), showing good scalability as vision Transformers. VAN [19] and FocalNet [65] use gated convolutions to perform input-adaptive attention and adopts large-kernel dilated convolutions and multiple successive $3 \times 3$ convolutions respectively to produce the weights. Previous work focuses on the meta architecture [67], large-kernel designs and inputadaptive weights to improve CNNs by learning from vision Transformers. In this paper, we offer a new perspective of high-order spatial attention to analyze the merits of vision Transformers. We show that the proposed HorNet that combines the advantages of both CNNs and vision Transformers is a better architecture for various vision tasks. + +Hybrid models. Combining vision Transformers and CNNs to develop hybrid architectures is a new direction in various visual recognition problems. Recently, several efforts have been made to integrate the two types of blocks into a unified model with a sequential [12, 29, 68, 63] or parallel [45, 11] design. Many enhanced vision Transformers also use lightweight convolutions in the basic building block to efficiently capture neighboring patterns [15, 60, 17] or relax the quadratic complexity of self-attention [9, 58, 18]. Different from these hybrid models, we aim to develop a self-attention free model while combining the favorable properties of both vision Transformers and CNNs. + +# 3 Method + +# 3.1 ${ \pmb { g } } ^ { n } { \bf C } { \bf 0 } { \bf n } { \bf v }$ : Recursive Gated Convolutions + +In this section, we will present $g ^ { n } \mathbf { C } \mathbf { o n v }$ , an efficient operation to achieve long-term and high-order spatial interactions. The $g ^ { n } \mathbf { C } \mathbf { o n v }$ is built with standard convolutions, linear projections and elementwise multiplications, but has a similar function of input-adaptive spatial mixing to self-attention. + +Input-adaptive interactions with gated convolution. Recent success in vision Transformers mainly depends on the proper modeling of the spatial interactions in visual data. Unlike CNNs that simply use the static convolution kernel to aggregate neighboring features, vision Transformers apply multi-head self-attention to dynamically generate the weights to mix spatial tokens. However, the quadratic complexity w.r.t. the input size of the self-attention largely hinders the application of vision Transformers, especially on downstream tasks including segmentation and detection where higher-resolution feature maps are required. In this work, instead of reducing the complexity of self-attention like previous methods [42, 9, 57], we seek a more efficient and effective way to perform spatial interactions with simple operations like convolution and fully-connected layers. + +The basic operation of our method is the gated convolution $( g \mathbf { C o n v } )$ . Let $\mathbf { x } \in \mathbb { R } ^ { H W \times C }$ be the input feature, the output of the gated convolution $\mathbf { y } = g \mathbf { C o n v } ( \mathbf { x } )$ can be written as: + +$$ +\begin{array} { r } { [ \mathbf { p } _ { 0 } ^ { H W \times C } , \mathbf { q } _ { 0 } ^ { H W \times C } ] = \phi _ { \mathrm { i n } } ( \mathbf { x } ) \in \mathbb { R } ^ { H W \times 2 C } , } \\ { \mathbf { p } _ { 1 } = f ( \mathbf { q } _ { 0 } ) \odot \mathbf { p } _ { 0 } \in \mathbb { R } ^ { H W \times C } , \quad \mathbf { y } = \phi _ { \mathrm { o u t } } ( \mathbf { p } _ { 1 } ) \in \mathbb { R } ^ { H W \times C } , } \end{array} +$$ + +where $\phi _ { \mathrm { i n } } , \phi _ { \mathrm { o u t } }$ are linear projection layers to perform channel mixing and $f$ is a depth-wise convolution. Note that $\begin{array} { r } { p _ { 1 } ^ { ( i , c ) } = \sum _ { j \in \Omega _ { i } } { w _ { i \to j } ^ { c } q _ { 0 } ^ { ( j , c ) } \bar { p _ { 0 } ^ { ( i , c ) } } } } \end{array}$ , where $\Omega _ { i }$ is the local window centered at $i$ and $w$ represents the convolution weight of $f$ . Therefore, the above formulation explicitly introduce interactions among the neighboring features $\mathbf { p } _ { 0 } ^ { ( i ) }$ and $\mathbf { q } _ { 0 } ^ { ( j ) }$ through the element-wise multiplication. We consider the interaction in $g \mathrm { C o n v }$ as $I$ -order interaction as each $\mathbf { p } _ { 0 } ^ { ( i ) }$ has interacted with its neighbor feature $\mathbf { q } _ { 0 } ^ { ( j ) }$ only once. + +High-order interactions with recursive gating. After achieving an efficient 1-order spatial interactions with the $g \mathrm { C o n v }$ , we then design the $g ^ { n } \mathbf { C } \mathbf { o n v }$ , a recursive gated convolution to further enhance the model capacity by introducing higher-order interactions. Formally, we first use $\phi _ { \mathrm { i n } }$ to obtain a set of projected features p0 and {qk}n−1k=0 : + +$$ +\left[ \mathbf { p } _ { 0 } ^ { H W \times C _ { 0 } } , \mathbf { q } _ { 0 } ^ { H W \times C _ { 0 } } , \dots , \mathbf { q } _ { n - 1 } ^ { H W \times C _ { n - 1 } } \right] = \phi _ { \mathrm { i n } } ( \mathbf { x } ) \in \mathbb { R } ^ { H W \times ( C _ { 0 } + \sum _ { 0 \leq k \leq n - 1 } C _ { k } ) } . +$$ + +We then perform the gated convolution recursively by + +$$ +\mathbf { p } _ { k + 1 } = f _ { k } ( \mathbf { q } _ { k } ) \odot g _ { k } ( \mathbf { p } _ { k } ) / \alpha , \qquad k = 0 , 1 , \ldots , n - 1 , +$$ + +where we scale the output by $1 / \alpha$ to stabilize the training. $\{ f _ { k } \}$ are a set of depth-wise convolution layers and $\left\{ g _ { k } \right\}$ are used to match the dimension in different orders: + +$$ +g _ { k } = \Big \{ \mathrm { I d e n t i t y } , \quad k = 0 , +$$ + +Finally, we feed the output of the last recursion step $\mathbf { q } _ { n }$ to the projection layer $\phi _ { \mathrm { o u t } }$ to obtain the result of the $g ^ { n } \mathbf { C } \mathbf { o n v }$ . From the recursive formula Equation (3.3), it is easy to show that the interaction-order of $\mathbf { p } _ { k }$ will be increased by 1 after each step. As a result, we can see that the $g ^ { n } \mathbf { C o n v }$ achieves $n$ -order spatial interactions. It is also worth noting that we need only a single $f$ to perform depthwise convolution to the concatenation of the features $\scriptstyle \{ \mathbf { q } _ { k } \} _ { k = 0 } ^ { n - 1 }$ together instead of computing the convolution in each recursive step as in Equation (3.3), which can further simplify the implementation and improve the efficiency on GPUs. To ensure that the high-order interactions do not introduce too much computational overhead, we set the channel dimension in each order as: + +$$ +C _ { k } = { \frac { C } { 2 ^ { n - k - 1 } } } , \qquad 0 \leq k \leq n - 1 . +$$ + +This design indicates that we perform the interactions in a coarse-to-fine manner, where lower orders are computed with fewer channels. Besides, the channel dimension of $\phi _ { \mathrm { i n } } ( \mathbf { x } )$ is exactly $2 C$ and the total FLOPs can be strictly bounded even with $n$ increasing. It can be proved that (see Appendix A): + +$$ +\mathrm { F L O P s } ( g ^ { n } \mathrm { C o n v } ) < H W C ( 2 K ^ { 2 } + 1 1 / 3 \times C + 2 ) , +$$ + +where $K$ is the kernel size of the depth-wise convolution. Therefore, our $g ^ { n } \mathbf { C } \mathbf { o n v }$ achieves high-order interactions with a similar computational cost to a convolutional layer. + +Long-term interactions with large kernel convolutions. Another difference between vision Transformers and conventional CNNs is the receptive field. Conventional CNNs [49, 22] often use $3 \times 3$ convolution through the whole network, while vision Transformers calculate self-attention on the whole feature maps [16, 52] or inside a relatively large local window (e.g., $7 \times 7$ ). The large receptive field in vision Transformers makes it easier to capture long-term dependencies, which is also recognized as one of the key advantages of vision Transformers. Inspired by this design, there are some efforts to introduce large kernel convolutions to CNNs recently [14, 43, 46]. To make our $g ^ { n } \mathbf { C } \mathbf { o n v }$ capable of capturing long-term interactions, we adopt two implementations for the depth-wise convolution $f$ : + +![](images/c822177566daa8abd09c544c6770b2efaebc5f0fda9b6ddd9ae9b56ec3d813f5.jpg) +Figure 2: Overview of the basic building block in HorNet with $g ^ { n } \mathbf { C o n v } .$ We adopt the block design of Transformers [56] and replace the self-attention sub-layer with $g ^ { n } \mathbf { C o n v }$ to develop our HorNet (left). We also provide the detailed implementation of $g ^ { 3 } \mathrm { C o n v }$ (middle) and the Pytorch-style code for an arbitrary order (right). + +• $7 \times 7$ Convolution. $7 \times 7$ is the default window/kernel size of Swin Transformers [42] and ConvNext [43]. Studies in [43] show that the kernel size produces good performance on ImageNet classification and various downstream tasks. We follow this configuration to fairly compare with representative work of vision Transformers and modern CNNs. Global Filter $( G F )$ . The GF layer [46] multiplies the frequency domain features with learnable global filters, which is equivalent to a convolution in the spatial domain with a global kernel size and circular padding. We use a modified version of the GF layer by processing half of the channels with the global filter and the other half with $3 \times 3$ depth-wise convolutions and only use GF layers in late stages to preserve more local details. + +Spatial interactions in vision models. We review some representative vision model designs from the perspective of spatial interactions, as shown in Figure 1. Specifically, we are interested in the interactions between a feature $\mathbf { x } _ { i }$ and its neighboring feature $\mathbf { x } _ { j } , j \in \Omega _ { i }$ . By using the tool designed for explaining the interaction effect (IE) in [33, 1], we provide an intuitive analysis of the order of explicit spatial interactions in Appendix B. Our analysis reveals a key difference between vision Transformers and previous architectures from a new view, i.e., vision Transformers have higher-order spatial interactions in each basic block. The result inspires us to explore an architecture that can realize more efficient and effective spatial interactions with more than two orders. As discussed above, our proposed $g ^ { n } \mathbf { C } \mathbf { o n v }$ can achieve arbitrary-order interactions with bounded complexity. It is also worth noting that similar to other scaling factors in deep models like width [69] and depth [22], simply increasing the order of spatial interactions without considering the overall model capacity will not lead to a good trade-off [51]. In this paper, we focus on developing a stronger visual modeling architecture based on the analysis of the spatial interaction orders of well-designed models. We believe a more thorough and formal discussion on the high-order spatial interactions can be an important future direction. + +Relation to dot-product self-attention. Although the computation of our $g ^ { n } \mathbf { C } \mathbf { o n v }$ largely differs from dot-product self-attention, we will show that $g ^ { n } \mathbf { C } \mathbf { o n v }$ also accomplishes the goal of inputadaptive spatial mixing. Let $\mathbf { M }$ be the attention matrix obtained by multi-head self-attention (MHSA), we write $\mathbf { M }$ as $( m _ { i j } ^ { c } )$ since the mixing weight may vary across the channels. The spatial mixing result (before the final channel mixing projection) of the $c$ -th channel at location $i$ is + +$$ +x _ { \mathrm { M H S A } } ^ { ( i , c ) } = \sum _ { j \in \Omega _ { i } } m _ { i j } ^ { c } v ^ { ( i , j ) } = \sum _ { j \in \Omega _ { i } } \sum _ { c ^ { \prime } = 1 } ^ { C } \underline { { m _ { i j } ^ { c } } } w _ { V } ^ { ( c ^ { \prime } , c ) } x ^ { ( j , c ^ { \prime } ) } , +$$ + +where $w _ { V }$ is the weight of the V-projection layer. Note that $m _ { i j }$ obtained by the dot-product operation contains 1-order interaction. On the other hand, the output of our $g ^ { n } \mathbf { C } \mathbf { o n v }$ (before the $\phi _ { \mathrm { o u t } }$ ) can be written as + +$$ +x _ { g ^ { n } \mathrm { C o n v } } ^ { ( i , c ) } = p _ { n } ^ { ( i , c ) } = \sum _ { j \in \Omega _ { i } } \sum _ { c ^ { \prime } = 1 } ^ { C } \underline { { w _ { n - 1 , i \to j } ^ { c } } } \underline { { \mathbf { g } _ { n - 1 } ^ { ( i , c ) } } } w _ { \phi _ { \mathrm { i n } } } ^ { ( c ^ { \prime } , c ) } x ^ { ( j , c ^ { \prime } ) } \triangleq \sum _ { j \in \Omega _ { i } } \sum _ { c ^ { \prime } = 1 } ^ { C } \underline { { h _ { i j } ^ { c } } } w _ { \phi _ { \mathrm { i n } } } ^ { ( c ^ { \prime } , c ) } x ^ { ( j , c ^ { \prime } ) } , +$$ + +where $w _ { n - 1 }$ is the convolutional weight for $f _ { n - 1 } , w _ { \phi _ { \mathrm { i n } } }$ is the linear weight of $\phi _ { \mathrm { i n } }$ , and $\mathbf { g } _ { n - 1 } =$ $g _ { n - 1 } ( \mathbf { p } _ { n - 1 } )$ is a projection of $\mathbf { p } _ { n - 1 }$ . From the formulation in Equation (3.8) we find our $g ^ { n } \mathbf { C } \mathbf { o n v }$ also achieves input-adaptive spatial mixing with $\{ h _ { i j } ^ { c } \}$ as the weights. Observing that $h _ { i j }$ is computed from $\mathbf { p } _ { n - 1 }$ which contains $n - 1$ order interactions, we can regard our $g ^ { n } \mathbf { C o n v }$ as an extension of the self-attention in terms of the order of the spatial mixing weight. Therefore, our $g ^ { n } \mathbf { C o n v }$ can better model more complex spatial interactions. + +The details of $g ^ { n } \mathbf { C } \mathbf { o n v }$ and our implementation are summarized in Figure 2. + +# 3.2 Model Architectures + +HorNet. The $g ^ { n } \mathbf { C } \mathbf { o n v }$ can be a drop-in replacement of the spatial mixing layer in vision Transformers [52, 42] or modern CNNs [43]. We follow the same meta-architecture as [56, 42] to construct HorNet, where the basic block contains a spatial mixing layer and a feed-forward network (FFN). Depending on the model size and the implementation of the depth-wise convolution $f _ { k }$ in our $g ^ { n } \mathbf { C } \mathbf { o n v }$ we have two series of model variants named HorNet-T/S/B/L $7 \times 7$ and HorNet-T/S/B/LGF. We consider the popular Swin Transformer [42] and ConvNeXt [43] as the vision Transformer and CNN baselines since our models are implemented based on a convolution-based framework while having high-order interactions like vision Transformers. To fairly compare with the baselines, we directly follow the number of blocks of Swin Transformers-S/B/L [42] but insert an extra block to the stage 2 to make the overall complexity close, resulting in [2, 3, 18, 2] blocks in each stage in all of the model variants. We simply adjust the base number of channels $C$ to construct models with different sizes and set the number of channels in 4 stages as $[ C , 2 C , 4 C , 8 C ]$ following common practice. We use $C = 6 4$ , 96, 128, 192 for HorNet-T/S/B/L, respectively. We set the interaction orders (i.e., the $n$ in $g ^ { n } \mathbf { C } \mathbf { o n v } )$ for each stage as 2,3,4,5 by default, such that the channels of the coarsest order $C _ { 0 }$ is the same across different stages. + +HorFPN. Apart from using $g ^ { n } \mathbf { C o n v }$ in visual encoders, we find our $g ^ { n } \mathbf { C } \mathbf { o n v }$ can be an enhanced alternative for standard convolution that considers higher-order spatial interactions in a wide range of convolution-based models. Thus, we replace spatial convolutions for feature fusion in the FPN [37] with our $g ^ { n } \mathbf { C } \mathbf { o n v }$ to improve spatial interactions for downstream tasks. Specifically, we add our $g ^ { n } \mathbf { C } \mathbf { o n v }$ after the fusion of features from different pyramid levels. For object detection, we replace the $3 \times 3$ convolution after the top-down pathway with the $g ^ { n } \mathbf { C } \mathbf { o n v }$ in each level. For semantic segmentation, we simply replace the $3 \times 3$ convolution after the concatenation of the multi-level feature maps with $g ^ { n } \mathbf { C } \mathbf { o n v }$ since the final results are directly predicted from this concatenated feature. We also have two implementations called $\mathrm { H o r F P N } _ { 7 \times 7 }$ and $\mathrm { H o r F P N } _ { \mathrm { G F } }$ decided by the choice of $f _ { k }$ . + +# 4 Experiments + +We conduct extensive experiments to verify the effectiveness of our method. We present the main results on ImageNet [13] and compare them with various architectures. We also test our models on the downstream dense prediction tasks on commonly used semantic segmentation benchmark ADE20K [71] and object detection dataset COCO [38]. Lastly, we provide ablation studies of our designs and analyze the effectiveness of $g ^ { n } \mathbf { C o n v }$ on a wide range of models. + +# 4.1 ImageNet Classification + +Setups. We conduct image classification experiments on the widely used ImageNet [13] dataset. We train our HorNet-T/S/B models using the standard ImageNet-1K dataset following common practice. To fairly compare with previous work, we directly use the training configurations of [43, 42, 52] to train our models. We train the models for 300 epochs with $2 2 4 \times 2 2 4$ input. To evaluate the scaling ability of our designs, we further train the HorNet-L models on the ImageNet-22K dataset that contains over $1 0 \times$ images and more categories. We follow previous practice [42, 43] to train our models for 90 epochs and use a similar data augmentation strategy as ImageNet-1K experiments. + +Table 1: ImageNet classification results. We compare our models with state-of-the-art vision Transformers and CNNs that have comparable FLOPs and parameters. We report the top-1 accuracy on the validation set of ImageNet as well as the number of parameters and FLOPs. We also show the improvements over Swin Trasnformers that have similar overall architectures and training configurations to our models. “ $\uparrow 3 8 4 ^ { \circ }$ indicates that the model is fine-tuned on $3 8 4 \times 3 8 4$ images for 30 epochs. Our models are highlighted in gray. + +
ModelImage Size(M)Params FLOPs Top-1 (G)Acc.(%)
ImageNet-1K trained models
EfficientNet-B4 [51]3802194.282.9
EfficientNet-B5[51]4562309.983.6
EfficientNet-B6 [51]52824319.084.0
EfficientNetV2-S[51]3002248.883.9
RepLKNet-31B [14]22427915.383.5
VAN-B [19]2242275.082.8
VAN-L [19]2242459.083.9
CSWin-T[15]224²234.382.7
CSWin-S[15]2242356.983.6
CSWin-B[15]22427815.084.2
Swin-T[42]2242284.581.3
ConvNeXt-T[43]2242294.582.1(+0.7)
HorNet-T7×7224²224.082.8(+1.5)
HorNet-TGF2242233.983.0(+1.7)
Swin-S [42]2242508.783.0
ConvNeXt-S [43]2242508.783.1(+0.1)
HorNet-S7×7224²508.883.8(+0.8)
HorNet-SGF224²508.784.0(+1.0)
Swin-B [42]224²8915.483.5
ConvNeXt-B [43]22428815.483.8(+0.3)
HorNet-B7×722428715.684.2(+0.7)
HorNet-BGF224²8815.584.3(+0.8)
+ +
ModelImage Size(M)Params FLOPs Top-1 (G)Acc. (%)
ImageNet-1K trained models (fine-tuned at 384×384)
Swin-B↑384 [42]38428947.184.5
ConvNeXt-B↑384 [43]384²8845.085.1(+0.6)
HorNet-B7×7↑38438428745.885.3(+0.8)
HorNet-BGF↑38438429245.485.6(+1.1)
ImageNet-22K trained models (fine-tuned to ImageNet-1K)
R-101x3 [30]3842388204.684.4
R-152x4 [30]4802937840.585.4
ViT-B/16 [16]38428755.584.0
ViT-L/16 [16]3842305191.185.2
EfficientNetV2-L [51]380212153.086.8
CSWin-L[15]384217396.887.5
SwinV2-L [41]3842197115.487.6
RepLKNet-31L [14]384217296.086.6
Swin-L [42]224²19734.586.3
ConvNeXt-L [43]224219834.486.6(+0.3)
HorNet-L7×7224²19534.886.8(+0.5)
HorNet-LGF224²19634.687.0(+0.7)
Swin-L↑384 [42]3842197103.987.3
ConvNeXt-L↑384 [43]3842198101.087.5(+0.2)
HorNet-L7×7↑384384²195102.387.6(+0.3)
HorNet-LGF↑3843842202101.887.7(+0.4)
+ +We fine-tune the models pre-trained on ImageNet-22K or at the $2 2 4 \times 2 2 4$ resolution to ImageNet-1K or/and $3 8 4 \times 3 8 4$ resolution for 30 epochs following [43]. When adapting the ImageNet-22K models to ImageNet-1K, we initialize the classifier with the pre-trained class centers to stabilize the training process. More details can be found in Appendix C. + +Results. The results of our ImageNet classification experiments are summarized in Table 1. We see that our models achieve very competitive performance with state-of-the-art vision Transformers and CNNs. Notably, HorNet surpasses Swin Transformers and ConvNeXt which have similar overall architectures and training configurations by a healthy margin on various model sizes and settings. Our models also generalize well to a larger image resolution, larger model sizes and more training data. These results clearly demonstrate the effectiveness and generality of our designs. + +# 4.2 Dense Prediction Tasks + +HorNet for semantic segmentation. We evaluate our HorNet for semantic segmentation task on ADE20K [71] dataset using the commonly used UperNet [62] framework. All the models are trained for 160k iterations using AdamW [44] optimizer with a global batch size of 16. The image size during training is $5 1 2 \times 5 1 2$ for ImagNet-1k (HorNet-T/S/B) pre-trained models and $6 4 0 \times 6 4 0$ for the ImageNet-22K pre-trained models (HorNet-L). The results are summarized in the left part of Table 2, where we report both the single-scale (SS) and multi-scale (MS) mIoU on the validation set. Both our $\mathrm { H o r N e t } _ { 7 \times 7 }$ and HorNetGF models outperform Swin [42] and ConvNeXt [43] models with similar model sizes and FLOPs. Specifically, HorNetGF models achieve better results than $\mathrm { H o r N e t } _ { 7 \times 7 }$ and ConvNeXt series by large margins in single-scale mIoU, indicating the global interactions captured by the global filter are helpful for semantic segmentation. Notably, we find both our HorNet- $\mathbf { \cdot L } _ { \mathbf { \nabla } \times \mathbf { 7 } }$ and HorNet-LGF even outperform ConvNeXt-XL with ${ \sim } 2 5 \%$ fewer FLOPs. These results clearly demonstrate the effectiveness and scalability of our HorNet on semantic segmentation. + +HorNet for object detection. We also evaluate our models on the COCO [38] dataset. We adopt the cascade Mask R-CNN framework [21, 2] to perform object detection and instance segmentation using HorNet-T/S/B/L backbones. Following Swin [42] and ConvNeXt [43], we use $3 \times$ schedule with multi-scale training. The right part of Table 2 compares the box AP and mask AP of our HorNet models and Swin/ConvNeXt models. Similarly, we show our HorNet models achieve consistently and significantly better performance than the Swin/ConvNeXt counterparts, in both box AP and mask AP. The HorNetGF series obtain $+ 1 . 2 { \sim } 2 . 0$ box AP and $+ 1 . 0 { \sim } 1 . 9$ mask AP compared with ConvNeXt. + +Table 2: Object detection and semantic segmentation results with different backbones. We use UperNet [62] for semantic segmentation and Cascade Mask R-CNN [2] for object detection. ‡ indicates that the model is pre-trained on ImageNet-22K. For semantic segmentation, we report both single-scale (SS) and multi-scale (MS) mIoU. The FLOPs are calculated with image size (2048, 512) for ImageNet-1K pre-trained models and (2560, 640) for ImageNet-22K pre-trained models. For object detection, we report the box AP and the mask AP. FLOPs are measured on input sizes of (1280, 800). Our models are highlighted in gray. + +
BackboneSemantic Segmentation with UperNet 160KObject Detection with Cascade Mask R-CNN 3×
mIoUssmIoUmsParamsFLOPsAPboxApmaskParamsFLOPs
Swin-T[42]44.545.860M945G50.443.786M745G
ConvNeXt-T[43]46.046.760M939G50.443.786M741G
HorNet-T7×748.148.952M926G51.744.880M730G
HorNet-TGF49.249.355m924G52.445.680M728G
Swin-S [42]47.649.581M1038G51.945.0107M838G
ConvNeXt-S[43]48.749.682M1027G51.945.0108M827G
HorNet-S7×749.249.881M1030G52.745.6107M830G
HorNet-SGF50.050.585M1027G53.346.3108M827G
Swin-B [42]48.149.7121M1188G51.945.0145M982G
ConvNeXt-B [43]49.149.9122M1170G52.745.6146M964G
HorNet-B7×750.050.5121M1174G53.346.1144M969G
HorNet-BGF50.550.9126M1171G54.046.9146M965G
Swin-L [42]52.153.5234M2468G53.946.7253M1382G
ConvNeXt-L [43]53.253.7235M2458G54.847.6255M1354G
ConvNeXt-XL+ 43]53.654.0391M3335G55.247.7407M1898G
HorNet-L×754.154.5232M2473G55.448.0251M1363G
HorNet-LGF 55.0 55.2239M2465G56.048.6259M1358G
+ +Table 3: Comparisons of HorFPN with standard FPN on different backbones. We use UperNet 160K and Mask R-CNN $1 \times$ schedule for semantic segmentation and object detection, respectively. We find our HorFPN consistently outperforms standard FPN with various of backbones on both the two tasks. + +
BackboneFusion ModuleSemantic Segmentation with UperNet 160KObject Detection with Mask R-CNN 1×
mIoUssmIoUmsParamsFLOPsApboxApmaskParamsFLOPs
ResNet-50 [22]FPN [37]40.741.866M947G38.234.744M260G
HorFPN7×741.844.160M499G38.735.143M226G
HorFPNGF43.244.560M497G39.135.543M224G
ResNet-101 [22]FPN[37]42.944.085M1025G40.036.163M336G
HorFPN7×744.145.579M577G40.336.462M302G
HorFPNGF44.546.479M574G40.536.762M300G
Swin-S [42]FPN [37]47.649.581M1038G45.540.969M354G
HorFPN7×748.049.274M580G46.341.168M325G
HorFPNGF49.049.975M578G46.841.969M323G
HorNet-SFPN [37]49.249.881M1030G47.142.269M351G
HorFPN7×749.450.174M577G47.442.368M322G
HorFPNGF49.750.375M575G47.742.468M321G
+ +Again, our large model HorNet- $\mathbf { { \cdot } } \mathbf { L } _ { 7 \times 7 }$ and HorNetGF can outperform ConvNeXt-XL, which further validates the favorable transferability with a larger model size and larger pre-trained dataset. + +HorFPN for dense prediction. We now show another application of the proposed $g ^ { n } \mathbf { C } \mathbf { o n v }$ , i.e., to serve as a better fusion module that can better capture the higher-order interactions among different levels of features in dense prediction tasks. Specifically, we directly modify the FPN [37] as described in Section 3.2 in UperNet [62] and Mask R-CNN [21] for semantic segmentation and object detection, respectively.We show the results in Table 3, where we compare the performance of our HorFPN and standard FPN on different backbones including ResNet-50/101 [22], Swin-S [42] and HorNet- $\mathbf { S } _ { 7 \times 7 }$ . For semantic segmentation, we find our HorFPN can + +Table 4: Object detection results with recent state-of-the-art frameworks. We report the single-scale $\mathbf { A P } ^ { \mathrm { b o x } }$ and $\mathbf { A P } ^ { \mathrm { m a s k } }$ on the validation set of COCO. Our models are highlighted in gray. + +
BackboneFrameworkAPboxApmask
Swin-L [42]HTC++ [3]57.149.5
ViT-Adapter-L [5]HTC++ [3]57.950.2
HorNet-LGFHTC++ [3]58.150.5
Swin-L [42]DINO [70]58.5=
HorNet-LGFDINO [70]59.2
+ +Table 5: Semantic Segmentation results with recent state-of-theart frameworks. We report the single-scale (SS) and multi-scale (MS) mIoU on the validation set of ADE20K. Our models are highlighted in gray. + +
BackboneFrameworkmIoUssmIoUms
Swin-L [42]Mask2Former [7]56.157.3
Swin-L-FaPN[27]Mask2Former [7]56.457.7
HorNet-LGFMask2Former [7]57.557.9
+ +significantly reduce the FLOPs $( \sim 5 0 \% )$ while achieving better validation mIoU. For object detection, + +Table 6: Ablation study and results of applying ${ \pmb { g } } ^ { n } { \bf C o n v }$ to other models/operations. We provide the ablation study of our designs in (a). $[ { ^ { * } } ]$ indicates the baseline of our model. The baseline and our final models are highlighted in gray. In (b) and (c), we apply the proposed $g ^ { n } \mathbf { C } \mathbf { o n v }$ to isotropic models that have a similar level of complexity with ViT/DeiT-S [16, 52] and other spatial mixing operations including the $3 \times 3$ depth-wise convolution and $3 \times 3$ pooling used in [67]. +(a) Ablation study. + +
ModelParamsFLOPsAcc. (%)
Swin-T[42]28M4.5G81.3(+0.1)
- Self-Attention + DWConv7×7 [*]29M4.5G81.2
+ SE [25]30M4.5G81.5(+0.3)
- SE+g{1,1,1,1)Conv28M4.3G81.7(+0.5)
+ g12.22.Conv28M4.3G82.2(+1.0)
+ g(3.3Conv28M4.3G82.5(+1.3)
+ g14.4.Conv28M4.3G82.5(+1.3)
+g(1,2,3.)Conv28M4.3G82.5(+1.3)
+ g2.34.5/Conv28M4.3G82.6(+1.4)
+ Deeper & Narrower (HorNet-T7×7)22M4.0G82.8(+1.6)
+ Global Filters [46] (HorNet-TGF)23M3.9G83.0(+1.8)
ConvNeXt [43]28M4.5G82.1(+0.9)
+ +(b) Results on isotropic models. + +
ModelFLOPsAcc. (%)
DeiT-S[52]4.6G79.8
ConvNeXt-S (iso.) [43]4.3G79.7
HorNet-S7×7 (iso.) HorNet-SGF (iso.)4.5G 4.5G80.6 81.0
(c) g"Conv for other operations.
ModelFLOPsAcc. (%)
DWConV3×34.0G80.7
g"ConV3x33.9G82.1
Pool [67]3.9G78.1
g"Convpool3.8G79.3
+ +![](images/93260c47a83264e956ef172369e362e3afed03701ebf45e26760b5941389dbc4.jpg) +Figure 3: Comparisons of trade-offs of Swin, ConvNeXt and HorNet. We compare the trade-offs of the models via the top-1 accuracy on ImageNet w.r.t. (a) number of parameters; (b) FLOPs; (c) latency. The latency is measured with a single NVIDIA RTX 3090 GPU with a batch size of 128. + +our HorFPN can also outperform standard FPN in terms of both box AP and mask AP on different backbones with about 30G fewer FLOPs. Besides, we observe that the $_ \mathrm { H o r F P N _ { G F } }$ is consistently better than $\mathrm { H o r F P N } _ { 7 \times 7 }$ , indicating that global interactions are also important when fusing hierarchical features. + +Results with state-of-the-art frameworks. To further show the effectiveness our backbone, we conduct experiments to combine our large HorNet model with recent state-of-the-art dense prediction frameworks including $\mathrm { H T C + + }$ [3], DINO [70] and Mask2Former [7]. For $\mathrm { H T C + + }$ and DINO, we train our models on COCO for 36 epochs $3 \times$ schedule) and does not introduce extra pre-training data like Object365 in [70]. We report the single-scale performance on the validation set and compared with several state-of-the-art methods in Table 4. For Mask2Former, we train our models on ADE20K with $6 4 0 \times 6 4 0$ . We report the mIoU of both single-scale and multi-scale testing on the validation set in Table 5. + +# 4.3 Analysis + +Ablation study. We provide detailed ablation studies of the $g ^ { n } \mathbf { C } \mathbf { o n v }$ and our HorNet in Table 6. We first study the model designs of our HorNet in Table 6a. Our baseline $( [ ^ { * } ] )$ is obtained by simply replacing the self-attention with $7 \times 7$ depth-wise convolution in Swin-T [42]. We first show that both SE [25] and our $g ^ { n } \mathbf { C } \mathbf { o n v }$ with $n = 1$ $( g ^ { \{ 1 , 1 , 1 , 1 \} } \mathrm { C o n v } )$ can improve over the baseline model $[ { ^ { * } } ]$ and $g ^ { \{ 1 , 1 , \bar { 1 } , 1 \} } \mathrm { \bar { C } o n v }$ is slightly better. We then perform ablations on the interaction order $n$ for each stage and find: (1) if $n$ is shared across the 4 stages, the accuracy will increase with larger $n$ but saturate at 82.5 when $n = 4$ ; (2) progressively increased order $( g ^ { \{ 2 , 3 , 4 , 5 \} } \mathrm { C o n v } )$ can further improve the accuracy. Our final models are built on $g ^ { \{ 2 , 3 , 4 , 5 \} }$ Conv by adjusting the depth and width of the networks $( \mathrm { H o r N e t - T } _ { 7 \times 7 } )$ and applying Global Filter [46] for the depth-wise convolution (HorNet-TGF). These results clearly show that our $g ^ { n } \mathbf { C } \mathbf { o n v }$ is an efficient and extendable operation that can better capture high-order spatial interactions than both self-attention and depth-wise convolution. + +![](images/2d741dc8d3264b5f0a1781a326468737d88eea5ea58e79479f0fcb5a5694aa2c.jpg) +Figure 4: Visualization of the adaptive weights generated by $g ^ { n } \mathbf { C o n v }$ . We see that the spatial mixing weights of our $g ^ { n } \mathbf { C o n v }$ are adaptive both to input samples and spatial locations, which further indicates that $g ^ { n } \mathbf { C o n v }$ shares these two desirable characteristics with the self-attention operation. + +$\pmb { g } ^ { n } \mathbf { C _ { 0 n v } }$ for isotropic models. We also evaluate $g ^ { n } \mathbf { C o n v }$ on isotropic architectures (with constant spatial resolutions). We replace the self-attention in DeiT-S [52] with our $g ^ { n } \mathbf { C o n v }$ and adjust the number of blocks to 13 to obtain the isotropic HorNet- $S _ { 7 \times 7 }$ and HorNet- $S _ { \mathrm { G F } }$ . We compare DeiT-S, isotropic ConvNeXt-S and isotropic HorNet-S in Table 6b. While isotropic ConvNeXt-S cannot improve DeiT-S, our isotropic HorNet surpasses DeiT-S by a large margin. These results indicate that our $g ^ { n } \mathbf { C } \mathbf { o n v }$ can better realize the functions of self-attention compared to plain convolutions and have better ability to model the complex spatial interactions. + +$\pmb { g } ^ { n } \mathbf { C _ { 0 n v } }$ for other operations. To further demonstrate the universality of $g ^ { n } \mathbf { C } \mathbf { o n v }$ , we use $3 \times 3$ depth-wise convolution and $3 \times 3$ pooling [67] as the basic operation in the $g ^ { n } \mathbf { C o n v }$ . The results in Table 6c show that $g ^ { n } \mathbf { C } \mathbf { o n v }$ can also improve these two operations by large margins, indicating our $g ^ { n } \mathbf { C } \mathbf { o n v }$ is potentially more powerful when equipped with some better basic operations. + +Accuracy-complexity trade-offs. We visualize accuracy-complexity trade-offs of Swin, ConvNeXt and HorNet series in Figure 3. For fair comparisons, we fix the input image size to $2 2 4 \times 2 2 4$ and use $\mathrm { H o r N e t } _ { 7 \times 7 }$ such that all the compared models are based on $7 \times 7$ local window. We see HorNet can achieve better trade-offs than the representative vision Transformers and modern CNNs with regards to model size, FLOPs and GPU latency. + +Visualization. We provide some visualizations of the adaptive weights learned by $g ^ { n } \mathbf { C o n v }$ in Figure 4. For each sample, we show the value of c $\textstyle { \frac { 1 } { C } } \sum _ { c = 1 } ^ { C } h _ { i j } ^ { c }$ (see Equation (3.8) or the definition $h _ { i j . } ^ { c }$ from layer $\{ 1 , \stackrel { - } { 3 } , \stackrel { \cdot } { 5 } , 7 , 8 , 1 2 \}$ +model. Figure 4 demonstrates that the spatial mixing weights of our $g ^ { n } \mathbf { C } \mathbf { o n v }$ are adaptive both to input samples and spatial locations, which further indicates that $g ^ { n } \mathbf { C } \mathbf { o n v }$ shares these two desirable characteristics with the self-attention operation. + +Limitations. While HorNet shows better overall latency-accuracy trade-offs, we notice that HorNet is slower than ConvNeXt with similar FLOPs on GPU, which may be caused by the more complex designs to perform the high-order interactions. We think that developing a more hardware-friendly operation for high-order spatial interactions is an interesting future direction to improve our work. + +# 5 Conclusion + +We have presented the Recursive Gated Convolution $( g ^ { n } \mathbf { C } \mathbf { o n v } )$ that performs efficient, extendable, and translation-equivariant high-order spatial interactions with gated convolutions and recursive deigns. $g ^ { n } \mathbf { C } \mathbf { o n v }$ can serve as a drop-in replace of the spatial mixing layer in various vision Transformers and convolution-based models. Based on the operation, we have constructed a new family of generic vision backbones HorNet. Extensive experiments demonstrate the effectiveness of $g ^ { n } \mathbf { C o n v }$ and HorNet on commonly used visual recognition benchmarks. We hope our attempt can inspire future work to further explore the high-order spatial interactions in vision models. + +# Acknowledgments + +Jiwen Lu was supported in part by the National Key Research and Development Program of China under Grant 2017YFA0700802, the National Natural Science Foundation of China under Grant 62125603 and Grant U1813218, and a grant from the Beijing Academy of Artificial Intelligence (BAAI). + +References +[1] Chunrong Ai and Edward C Norton. Interaction terms in logit and probit models. Economics letters, 80(1):123–129, 2003. 5, 15 +[2] Zhaowei Cai and Nuno Vasconcelos. Cascade r-cnn: Delving into high quality object detection. In CVPR, pages 6154–6162, 2018. 7, 8, 17 +[3] Kai Chen, Jiangmiao Pang, Jiaqi Wang, Yu Xiong, Xiaoxiao Li, Shuyang Sun, Wansen Feng, Ziwei Liu, Jianping Shi, Wanli Ouyang, et al. Hybrid task cascade for instance segmentation. In CVPR, pages 4974–4983, 2019. 8, 9 +[4] Yinpeng Chen, Xiyang Dai, Mengchen Liu, Dongdong Chen, Lu Yuan, and Zicheng Liu. Dynamic convolution: Attention over convolution kernels. In CVPR, pages 11030–11039, 2020. 2 +[5] Zhe Chen, Yuchen Duan, Wenhai Wang, Junjun He, Tong Lu, Jifeng Dai, and Yu Qiao. Vision transformer adapter for dense predictions. arXiv preprint arXiv:2205.08534, 2022. 8 +[6] Bowen Cheng, Ishan Misra, Alexander G Schwing, Alexander Kirillov, and Rohit Girdhar. Maskedattention mask transformer for universal image segmentation. arXiv preprint arXiv:2112.01527, 2021. 1 +[7] Bowen Cheng, Ishan Misra, Alexander G Schwing, Alexander Kirillov, and Rohit Girdhar. Maskedattention mask transformer for universal image segmentation. In CVPR, pages 1290–1299, 2022. 8, 9 +[8] Bowen Cheng, Alex Schwing, and Alexander Kirillov. Per-pixel classification is not all you need for semantic segmentation. NeurIPS, 34, 2021. 1 +[9] 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. NeurIPS, 34, 2021. 3, 4 +[10] Ekin D Cubuk, Barret Zoph, Jonathon Shlens, and Quoc V Le. Randaugment: Practical automated data augmentation with a reduced search space. In CVPRW, pages 702–703, 2020. 16 +[11] Yutao Cui, Jiang Cheng, Limin Wang, and Gangshan Wu. Mixformer: End-to-end tracking with iterative mixed attention. CVPR, 2022. 3 +[12] Zihang Dai, Hanxiao Liu, Quoc V Le, and Mingxing Tan. Coatnet: Marrying convolution and attention for all data sizes. NeurIPS, 34:3965–3977, 2021. 1, 3 +[13] Jia Deng, Wei Dong, Richard Socher, Li-Jia Li, Kai Li, and Li Fei-Fei. Imagenet: A large-scale hierarchical image database. In CVPR, pages 248–255, 2009. 2, 6, 16, 17 +[14] Xiaohan Ding, Xiangyu Zhang, Yizhuang Zhou, Jungong Han, Guiguang Ding, and Jian Sun. Scaling up your kernels to 31x31: Revisiting large kernel design in cnns. CVPR, 2022. 2, 3, 5, 7 +[15] Xiaoyi Dong, Jianmin Bao, Dongdong Chen, Weiming Zhang, Nenghai Yu, Lu Yuan, Dong Chen, and Baining Guo. Cswin transformer: A general vision transformer backbone with cross-shaped windows. CVPR, 2022. 3, 7 +[16] 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. arXiv preprint arXiv:2010.11929, 2020. 1, 3, 4, 7, 9 +[17] Stéphane 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 ICML, pages 2286–2296, 2021. 3 +[18] Haoqi Fan, Bo Xiong, Karttikeya Mangalam, Yanghao Li, Zhicheng Yan, Jitendra Malik, and Christoph Feichtenhofer. Multiscale vision transformers. In ICCV, pages 6824–6835, 2021. 1, 3 +[19] Meng-Hao Guo, Cheng-Ze Lu, Zheng-Ning Liu, Ming-Ming Cheng, and Shi-Min Hu. Visual attention network. arXiv preprint arXiv:2202.09741, 2022. 3, 7 +[20] Qi Han, Zejia Fan, Qi Dai, Lei Sun, Ming-Ming Cheng, Jiaying Liu, and Jingdong Wang. Demystifying local vision transformer: Sparse connectivity, weight sharing, and dynamic weight. arXiv preprint arXiv:2106.04263, 2021. 2, 3 +[21] Kaiming He, Georgia Gkioxari, Piotr Dollar, and Ross Girshick. Mask r-cnn. In ICCV, 2017. 7, 8 +[22] Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. In CVPR, pages 770–778, 2016. 1, 4, 5, 8, 16 +[23] Sepp Hochreiter and Jürgen Schmidhuber. Long short-term memory. Neural computation, 9(8):1735–1780, 1997. 16 +[24] 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. 1 +[25] Jie Hu, Li Shen, and Gang Sun. Squeeze-and-excitation networks. In CVPR, pages 7132–7141, 2018. 2, 9, 18 +[26] Gao Huang, Yu Sun, Zhuang Liu, Daniel Sedra, and Kilian Q Weinberger. Deep networks with stochastic depth. In ECCV, pages 646–661, 2016. 17 +[27] Shihua Huang, Zhichao Lu, Ran Cheng, and Cheng He. Fapn: Feature-aligned pyramid network for dense image prediction. In ICCV, pages 864–873, 2021. 8 +[28] Xu Jia, Bert De Brabandere, Tinne Tuytelaars, and Luc V Gool. Dynamic filter networks. NeurIPS, 29, 2016. 2 +[29] Zihang Jiang, Qibin Hou, Li Yuan, Daquan Zhou, Xiaojie Jin, Anran Wang, and Jiashi Feng. Token labeling: Training a $8 5 . 5 \%$ top-1 accuracy vision transformer with 56m parameters on imagenet. arXiv preprint arXiv:2104.10858, 2021. 3 +[30] Alexander Kolesnikov, Lucas Beyer, Xiaohua Zhai, Joan Puigcerver, Jessica Yung, Sylvain Gelly, and Neil Houlsby. Big transfer (bit): General visual representation learning. In ECCV, pages 491–507. Springer, 2020. 7 +[31] Alex Krizhevsky, Ilya Sutskever, and Geoffrey E Hinton. Imagenet classification with deep convolutional neural networks. NeurIPS, 25:1097–1105, 2012. 1 +[32] 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. 1 +[33] Samuel Lerman, Charles Venuto, Henry Kautz, and Chenliang Xu. Explaining local, global, and higherorder interactions in deep learning. In ICCV, pages 1224–1233, 2021. 5, 15 +[34] Yanghao Li, Hanzi Mao, Ross Girshick, and Kaiming He. Exploring plain vision transformer backbones for object detection. arXiv preprint arXiv:2203.16527, 2022. 2 +[35] Yanghao Li, Chao-Yuan Wu, Haoqi Fan, Karttikeya Mangalam, Bo Xiong, Jitendra Malik, and Christoph Feichtenhofer. Mvitv2: Improved multiscale vision transformers for classification and detection. In CVPR, pages 4804–4814, 2022. 17, 18 +[36] Tsung-Yi Lin, Piotr Dollár, Ross Girshick, Kaiming He, Bharath Hariharan, and Serge Belongie. Feature pyramid networks for object detection. In CVPR, pages 2117–2125, 2017. 3 +[37] Tsung-Yi Lin, Piotr Dollár, Ross Girshick, Kaiming He, Bharath Hariharan, and Serge Belongie. Feature pyramid networks for object detection. In CVPR, pages 2117–2125, 2017. 6, 8 +[38] Tsung-Yi Lin, Michael Maire, Serge Belongie, James Hays, Pietro Perona, Deva Ramanan, Piotr Dollár, and C Lawrence Zitnick. Microsoft coco: Common objects in context. In ECCV, pages 740–755. Springer, 2014. 2, 6, 7 +[39] Hanxiao Liu, Zihang Dai, David So, and Quoc V Le. Pay attention to mlps. NeurIPS, 34:9204–9215, 2021. 16 +[40] Kai Liu, Tianyi Wu, Cong Liu, and Guodong Guo. Dynamic group transformer: A general vision transformer backbone with dynamic group attention. IJCAI, 2022. 18 +[41] Ze Liu, Han Hu, Yutong Lin, Zhuliang Yao, Zhenda Xie, Yixuan Wei, Jia Ning, Yue Cao, Zheng Zhang, Li Dong, et al. Swin transformer v2: Scaling up capacity and resolution. arXiv preprint arXiv:2111.09883, 2021. 1, 7 +[42] 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. 1, 2, 3, 4, 5, 6, 7, 8, 9, 16, 17 +[43] Zhuang Liu, Hanzi Mao, Chao-Yuan Wu, Christoph Feichtenhofer, Trevor Darrell, and Saining Xie. A convnet for the 2020s. CVPR, 2022. 2, 3, 5, 6, 7, 8, 9, 16, 17 +[44] Ilya Loshchilov and Frank Hutter. Decoupled weight decay regularization. arXiv preprint arXiv:1711.05101, 2017. 7, 17 +[45] Xuran Pan, Chunjiang Ge, Rui Lu, Shiji Song, Guanfu Chen, Zeyi Huang, and Gao Huang. On the integration of self-attention and convolution. arXiv preprint arXiv:2111.14556, 2021. 3 +[46] Yongming Rao, Wenliang Zhao, Zheng Zhu, Jiwen Lu, and Jie Zhou. Global filter networks for image classification. In NeurIPS, 2021. 2, 3, 5, 9 +[47] Tal Ridnik, Emanuel Ben-Baruch, Asaf Noy, and Lihi Zelnik-Manor. Imagenet-21k pretraining for the masses. arXiv:2104.10972, 2021. 17 +[48] 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. NeurIPS, 34, 2021. 1 +[49] Karen Simonyan and Andrew Zisserman. Very deep convolutional networks for large-scale image recognition. arXiv preprint arXiv:1409.1556, 2014. 1, 4 +[50] Christian Szegedy, Wei Liu, Yangqing Jia, Pierre Sermanet, Scott Reed, Dragomir Anguelov, Dumitru Erhan, Vincent Vanhoucke, and Andrew Rabinovich. Going deeper with convolutions. In CVPR, pages 1–9, 2015. 1 +[51] Mingxing Tan and Quoc Le. Efficientnet: Rethinking model scaling for convolutional neural networks. In ICML, pages 6105–6114, 2019. 1, 5, 7 +[52] Hugo Touvron, Matthieu Cord, Matthijs Douze, Francisco Massa, Alexandre Sablayrolles, and Hervé Jégou. Training data-efficient image transformers & distillation through attention. arXiv preprint arXiv:2012.12877, 2020. 1, 4, 6, 9, 10 +[53] Hugo Touvron, Matthieu Cord, Alexandre Sablayrolles, Gabriel Synnaeve, and Hervé Jégou. Going deeper with image transformers. arXiv preprint arXiv:2103.17239, 2021. 16 +[54] Zhengzhong Tu, Hossein Talebi, Han Zhang, Feng Yang, Peyman Milanfar, Alan Bovik, and Yinxiao Li. Maxim: Multi-axis mlp for image processing. In CVPR, pages 5769–5780, 2022. 16 +[55] Zhengzhong Tu, Hossein Talebi, Han Zhang, Feng Yang, Peyman Milanfar, Alan Bovik, and Yinxiao Li. Maxvit: Multi-axis vision transformer. ECCV, 2022. 3 +[56] Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Lukasz Kaiser, and Illia Polosukhin. Attention is all you need. In NeurIPS, pages 5998–6008, 2017. 2, 3, 5, 6 +[57] Sinong Wang, Belinda Z Li, Madian Khabsa, Han Fang, and Hao Ma. Linformer: Self-attention with linear complexity. arXiv preprint arXiv:2006.04768, 2020. 4 +[58] 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. In ICCV, 2021. 3 +[59] Yan Wang, Lingxi Xie, Chenxi Liu, Siyuan Qiao, Ya Zhang, Wenjun Zhang, Qi Tian, and Alan L. Yuille. SORT: second-order response transform for visual recognition. In IEEE International Conference on Computer Vision, ICCV 2017, Venice, Italy, October 22-29, 2017, pages 1368–1377. IEEE Computer Society, 2017. 16 +[60] 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. 3 +[61] Sitong Wu, Tianyi Wu, Haoru Tan, and Guodong Guo. Pale transformer: A general vision transformer backbone with pale-shaped attention. In AAAI, volume 36, pages 2731–2739, 2022. 18 +[62] Tete Xiao, Yingcheng Liu, Bolei Zhou, Yuning Jiang, and Jian Sun. Unified perceptual parsing for scene understanding. In ECCV, pages 418–434, 2018. 7, 8, 17 +[63] Tete Xiao, Mannat Singh, Eric Mintun, Trevor Darrell, Piotr Dollár, and Ross Girshick. Early convolutions help transformers see better. NeurIPS, 34:30392–30400, 2021. 3 +[64] Shen Yan, Xuehan Xiong, Anurag Arnab, Zhichao Lu, Mi Zhang, Chen Sun, and Cordelia Schmid. Multiview transformers for video recognition. arXiv preprint arXiv:2201.04288, 2022. 1 +[65] Jianwei Yang, Chunyuan Li, and Jianfeng Gao. Focal modulation networks. arXiv preprint arXiv:2203.11926, 2022. 3 +[66] Jianwei Yang, Chunyuan Li, Pengchuan Zhang, Xiyang Dai, Bin Xiao, Lu Yuan, and Jianfeng Gao. Focal attention for long-range interactions in vision transformers. NeurIPS, 34, 2021. 3 +[67] Weihao Yu, Mi Luo, Pan Zhou, Chenyang Si, Yichen Zhou, Xinchao Wang, Jiashi Feng, and Shuicheng Yan. Metaformer is actually what you need for vision. arXiv preprint arXiv:2111.11418, 2021. 3, 9, 10 +[68] Li Yuan, Yunpeng Chen, Tao Wang, Weihao Yu, Yujun Shi, Zihang Jiang, Francis EH Tay, Jiashi Feng, and Shuicheng Yan. Tokens-to-token vit: Training vision transformers from scratch on imagenet. arXiv:2101.11986, 2021. 3 +[69] Sergey Zagoruyko and Nikos Komodakis. Wide residual networks. arXiv preprint arXiv:1605.07146, 2016. 5 +[70] Hao Zhang, Feng Li, Shilong Liu, Lei Zhang, Hang Su, Jun Zhu, Lionel M Ni, and Heung-Yeung Shum. Dino: Detr with improved denoising anchor boxes for end-to-end object detection. arXiv preprint arXiv:2203.03605, 2022. 1, 8, 9 +[71] Bolei Zhou, Hang Zhao, Xavier Puig, Sanja Fidler, Adela Barriuso, and Antonio Torralba. Scene parsing through ade20k dataset. In CVPR, pages 633–641, 2017. 2, 6, 7 + +# Checklist + +1. For all authors... + +(a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes] +(b) Did you describe the limitations of your work? [Yes] See our analysis in Section 4.3. +(c) Did you discuss any potential negative societal impacts of your work? [N/A] We propose a general framework for visual recognition. Our method is not for specific applications, which does not directly involve societal issues. +(d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes] + +2. If you are including theoretical results... + +(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] + +3. If you ran experiments... + +(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] +(b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes] +(c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [No] We follow the common practice in previous papers, where they didn’t report the error bars. +(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 our implementation details provided in the supplemental material. + +4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets... + +(a) If your work uses existing assets, did you cite the creators? [Yes] +(b) Did you mention the license of the assets? [N/A] +(c) Did you include any new assets either in the supplemental material or as a URL? [No] +(d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [N/A] +(e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [N/A] + +5. If you used crowdsourcing or conducted research with human subjects... + +(a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A] +(b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A] +(c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A] \ No newline at end of file diff --git a/md/dev/uRTW_PgXvc7/uRTW_PgXvc7.md b/md/dev/uRTW_PgXvc7/uRTW_PgXvc7.md new file mode 100644 index 0000000000000000000000000000000000000000..0eded1d123585083105700ec4c4dcf94e245c58b --- /dev/null +++ b/md/dev/uRTW_PgXvc7/uRTW_PgXvc7.md @@ -0,0 +1,306 @@ +# ST-Adapter: Parameter-Efficient Image-to-Video Transfer Learning + +Junting $\mathbf { P a n } ^ { 1 * }$ , Ziyi $\mathbf { L i n ^ { 1 * } }$ , Xiatian $\mathbf { Z } \mathbf { h } \mathbf { u } ^ { 2 }$ , Jing Shao1, Hongsheng Li1,3 1Multimedia Laboratory, The Chinese University of Hong Kong 2Surrey Institute for People-Centred Artificial Intelligence, CVSSP, University of Surrey 3Centre for Perceptual and Interactive Intelligence Limited + +# Abstract + +Capitalizing on large pre-trained models for various downstream tasks of interest have recently emerged with promising performance. Due to the ever-growing model size, the standard full fine-tuning based task adaptation strategy becomes prohibitively costly in terms of model training and storage. This has led to a new research direction in parameter-efficient transfer learning. However, existing attempts typically focus on downstream tasks from the same modality (e.g., image understanding) of the pre-trained model. This creates a limit because in some specific modalities, (e.g., video understanding) such a strong pre-trained model with sufficient knowledge is less or not available. In this work, we investigate such a novel cross-modality transfer learning setting, namely parameter-efficient image-to-video transfer learning. To solve this problem, we propose a new SpatioTemporal Adapter (ST-Adapter) for parameter-efficient fine-tuning per video task. With a built-in spatio-temporal reasoning capability in a compact design, STAdapter enables a pre-trained image model without temporal knowledge to reason about dynamic video content at a small $( \sim 8 \% )$ per-task parameter cost, requiring approximately 20 times fewer updated parameters compared to previous work. Extensive experiments on video action recognition tasks show that our ST-Adapter can match or even outperform the strong full fine-tuning strategy and state-of-theart video models, whilst enjoying the advantage of parameter efficiency. Code and model are available at https://github.com/linziyi96/st-adapter + +# 1 Introduction + +In the NLP field, almost all the state-of-arts across a wide range of downstream tasks have been achieved by adapting from large pretrained models (a.k.a. foundation models [7]) such as BERT [15] and GPT [54, 8]. The de facto standard approach to adapting a pretrained model to down-stream tasks is fine-tuning either fully or partially (e.g., linear probing by training the newly added multi-layer perceptron layers on the top alone), subject to the condition of adopting a similar network architecture as the pretrained model. Nonetheless, given increasingly larger whilst ever stronger foundation models (e.g., GPT-3 with 175B parameters), fully fine-tuning the whole model for every single downstream task would become prohibitively expensive and infeasible in terms of training cost and model storage. This could significantly restrict their deployment and usability in real-world applications. In this context, a series of NLP works has been introduced towards efficient transfer learning with better trade-offs between parameter and accuracy [25, 24, 39, 36]. + +This trend has recently motivated the computer vision community. For example, the CLIP model [55], trained with 400 million web image-text pairs, achieves promising performances on a variety of image recognition and generation tasks. In the video domain, with significantly more computational cost and resources, Xu et al. [79] trained a video variant of CLIP but excelled on a smaller number of downstream video tasks. This is partly attributed to two orders of magnitude more minor training data and limited availability of computing resources, as large video data is notoriously more difficult to collect, manage, and process than image data. Under these restrictions, large pre-trained image models are arguably still favorable in the selection of model initialization for video tasks. + +![](images/d9bfd7f9be6df8252447925e6b8f95f1baeb22552d2216608c2bc07b094e3b94.jpg) +Figure 1: Image-to-video transfer learning strategies. (a) The state-of-the-art methods for adapting a pre-trained image model (e.g., ViT [16] in this example) to video tasks (e.g., action recognition) usually adopt the paradigm of first designing a temporal learning module and then fine-tuning the whole network fully [2, 6, 9]. This is parameter-inefficient since a specific instance of such a large model is resulted for each downstream task. In contrast, (b) we propose to only train a lightweight Spatio-Temporal Adapter with much fewer parameters for each individual downstream task at a significantly smaller computational cost. Surprisingly, our method can match or even surpasses the full fine-tuning based methods (including prior art video models in terms of accuracy), whist enjoying higher parameter efficiency and cheaper training cost. + +In this work, we investigate a novel, critical problem of efficiently adapting large pre-trained image models for video downstream tasks, with a focus on the widely influential action recognition task. Considering that training video models is drastically more expensive in both computing resource and time than image models [19], this problem becomes particularly more useful and valuable in practice. On the other hand, it is also more challenging and non-trivial due to the extra necessity of overcoming the big gap between image and video in transfer learning. Especially, pre-trained image models lack the ability to infer temporal structured information, which however is critical in video understanding. In fact, the key design with state-of-the-art video models [10, 41, 6, 9] is usually about learning the temporal dimension based on contemporary image models. Although model initialization is still important, they largely go beyond the fine-tuning strategy, as architectural modification is often imposed in addition to full model training/fine-tuning per downstream task. + +Given that this is a new problem, we first conduct a comprehensive benchmark using both various fine-tuning methods for image-to-video transfer learning and state-of-the-art video models [6, 9]. Regarding the pretrained image model, we select two Vision Transformer (ViT) [16] models, with one from CLIP pre-training [55] and the other pre-trained on ImageNet-21K [14]. ViT is representative in terms of network architecture, pre-training algorithm, and training data scale. Crucially, we further propose an efficient yet effective Space-Time Adapter (ST-Adapter), capable of extracting and leveraging the pre-trained knowledge of a large image model to achieve superior video understanding at a small parameter cost. Specifically, ST-Adapter is formulated based on a novel parameter-efficient bottleneck with a sequence of operations including feature dimension reduction, spatial-temporal modeling, and feature dimension recovery. It is easy to implement and scalable for deployment since all the primitive steps are realized with standard operators (e.g., fully-connected layer, depth-wise 3D convolution). With such a lightweight design, our bottleneck can be cheaply integrated throughout the base network for enabling stronger layer-wise spatio-temporal learning. As a result, our model can be more rapidly optimized using fewer training epochs for significant convergence advantage. + +We summarize the contributions as follows. (1) We investigate a new problem of parameterefficient image-to-video transfer learning. Our motivation is to advocate the usability and deployment of increasingly larger whilst ever more powerful pre-trained image models in benefiting more challenging video understanding tasks. (2) We establish a benchmark for action recognition tasks by comprehensively experimenting with a variety of fine-tuning strategies and several state-of-the-art video understanding models. (3) We introduce a novel parameter-efficient Spatio-Temporal Adapter (ST-Adapter) for more effectively capitalizing a large pre-trained image model in video understanding. By grounding all the primitives on standard operators, ST-Adaptor is easy to implement and friendly to deployment. (4) Extensive experiments on action recognition datasets show that our ST-Adapter outperforms not only existing parameter-efficient alternatives and the full fine-tuning strategy, but also state-of-the-art video methods with the same network architecture and model initialization. + +# 2 Related Work + +Parameter-efficient transfer learning Driven by the wider application of large pre-trained language models across a diversity of downstream tasks, the topic of efficient tuning has received increasing attention in NLP. Existing efficient tuning methods fall broadly into three categories. The first category is to introduce task-specific adapters [25, 24, 51, 50]. Specifically, an adapter consists of lightweight modules inserted between layers of a pre-trained model. To be parameter-efficient, only those newly added adapter modules need to be updated during task fine-tuning, whilst all the parameters of the large pre-trained model, which takes the majority proportion of the whole solution, are frozen. The second category is prompt tuning [39, 52, 31, 62, 42]. Instead of manipulating the network architecture, these methods prepend a set of learnable tokens at the input point of the model or intermediate layers. Similarly, only these added tokens need to be optimized for each downstream task. The third category is learning weight approximation [27]. In particular, only the low-rank matrices for approximating the weights need to be updated during training. + +Early works for efficient transfer learning in vision focus on parameter sharing in the context of multitask learning [83, 57, 56]. Recently, there are several works for extending the efficient tuning idea from NLP to vision tasks. CoOp [85] and CoCoOp [86] apply prefix tuning for adapting the CLIP model to various image recognition tasks. VL-Adapter [65] achieves the performance comparable to full fine-tuning on challenging vision-language tasks. Commonly, their design focuses are all restricted to the text encoder of the CLIP model. More recently, [29, 4, 84] introduce the idea of prompt learning to visual backbones. They obtained favorable results on various image recognition benchmarks. Moving a step further, in this work, we consider the more challenging adaptation problem from a pre-trained image model without temporal knowledge to video understanding tasks. + +Video action recognition Action recognition in the unconstrained video has largely been dominated by deep learning methods, thanks to the availability of large video datasets, e.g., Kinetics [10–12] and Something-Something [22]. As a key component, the model architectures adopted by existing video methods has expanded from CNNs [32, 68, 19, 18, 77, 69, 72, 48, 41, 45] to Transformers [17, 40, 38, 44, 2, 6]. As temporal information is important for modeling the dynamics, a variety of motion learning techniques has been introduced [75, 30, 49]. Further, different training methods have also been explored, e.g., unsupervised learning [67, 20, 76], and video-text contrastive learning [64, 79, 78, 66]. New opportunities for stronger video models are created following the introduction of large pretrained foundation models [55, 28, 81]. For example, Wang et al. [74] equipped the CLIP with temporal modules and good performance can be achieved after the model is fully fine-tuned on video datasets. Ju et al. [31] adopted the CLIP model for video recognition tasks by learning videospecific prompts. In contrast, in this work, we explore the potential of the large pre-trained image models with the parameter-efficient adapter strategy. Importantly, despite the simplicity, we bring about more significant advantages in performance along with a new benchmark on parameter-efficient image-to-video transfer learning. + +# 3 Methodology + +To capitalize a large pre-trained image model for more challenging video understanding such as action recognition in a cross-modality manner, it is necessary to fill the intrinsic gap between image and video. For easier understanding, we start with an intuitive baseline based on temporal aggregation. + +Temporal aggregation A straightforward baseline method of exploiting a pre-trained image model for video understanding is to temporally aggregate per-frame feature representations (e.g., average pooling). Concretely, given an input video clip $\mathbf { V } \in \mathbb { R } ^ { T \times H \times W }$ , where $T , H , W$ are the number of frames, height and width respectively. Following [16], we first split each frame into $N = H \times W / P ^ { 2 }$ patches of size $P \times P$ . Then, we flatten these patches and project them into a sequence of patch tokens $\mathbf Z _ { t } = [ \mathbf z _ { 1 } , . . . \mathbf z _ { s } , . . . , \mathbf z _ { N } ] , \mathbf z _ { s } \in \mathbb { R } ^ { d }$ where $d = 3 \times P ^ { \dot { 2 } }$ with $t = 1 , . . . , T$ . The sequence of feature vectors is then enhanced with the positional embedding by element-wise addition, along with a trainable class token concatenated. Subsequently, we feed each sequence with $N + 1$ tokens to a stack of self-attention based blocks individually. For each sequence we keep only the classification token ${ \bf z } _ { t } ^ { c l s }$ . We further perform temporal average pooling on the class tokens $\begin{array} { r } { \dot { \bf z } _ { f i n a l } = \frac { 1 } { T } \sum _ { t } { \bf z } _ { t } ^ { c l s } } \end{array}$ to yield a compact representation for the whole clip. We obtain the prediction by passing $\mathbf { z } _ { f i n a l }$ through a classifier. As the sptial information is only naively averaged over time, it is also known as Space-Only TimeSformer [6]. + +Spatio-temporal attention For more dedicated structural modeling in the time dimension with ViTs, a mainstream approach in the video domain is to develop various spatio-temporal attention mechanisms by further imposing temporal attention on top [6, 2, 3, 9, 82, 23]. We choose two representative video ViT models, TimeSformer [6] and XViT [9], in our performance benchmark. However, state-of-the-art video ViT models often need to fully fine-tuned per task, which is parameterinefficient, given that in this way we have to keep a separate copy of the whole fine-tuned model parameters for every single task. + +# 3.1 Preliminaries + +Our method is inspired by the Adapter [25] designed for parameter-efficient transfer learning in NLP. Specifically, the adapter module is composed of a down-projection linear layer followed by a non-linear activation function and an up-projection linear layer. Formally, given an input feature matrix $\mathbf { X } \in \mathbb { R } ^ { N \times d }$ at the $i$ -th layer, the feature adaptation process can be written as: + +$$ +\mathsf { A d a p t e r } ( \mathbf { X } ) = \mathbf { X } + f ( \mathbf { X } \mathbf { W } _ { d o w n } ) \mathbf { W } _ { u p } , +$$ + +where $\mathbf { W } _ { d o w n } \in \mathbb { R } ^ { d \times r }$ refers to the down projection layer, $\mathbf { W } _ { u p } \in \mathbb { R } ^ { r \times d }$ the up-projection layer, and $f ( \cdot )$ the activation function. Note, that a residual summation is applied for preserving the information in input as required. The idea of Adapter has been remarkably successful in NLP due to several advantages: (1) High parameter efficiency across tasks since only a small number of parameters are task-specific; (2) Reaching on-par performance compared to full fine-tuning; (3) Taking significantly small training costs; (4) Avoiding the catastrophic forgetting limitation of full fine-tuning. + +We aim to propagate the success of Adapter from NLP to computer vision particularly the imageto-video transfer learning problem as discussed earlier. To that end, we introduce a novel Adapter tailored specially for spatio-temporal reasoning – a key capability for video understanding which, however, existing NLP Adapter variants lack. + +# 3.2 Spatio-Temporal Adapter (ST-Adapter) + +Typically, an image model only considers the ability of spatial modeling. The objective of our Spatio-Temporal Adapter (ST-Adapter) is to enable a pre-trained image model to reason about spatial and temporal information of video in a parameter efficient principle. In design, we consider a couple of practically-crucial criteria: (1) Smaller parameter size: The parameter cost for each downstream task should be small – the essential criterion for parameter efficiency. (2) Development friendliness: This is critical for real-world development and deployment. In practice, it is necessary that a model can be easily implemented using the standard highly optimized deep learning toolboxes (e.g., PyTorch, TensorFlow, TensorRT, and TorchScript), without tedious per-toolbox specialization. + +This also facilitates the realization of high inference efficiency across a diversity of running platforms due to the best usage of built-in software and hardware resources. + +Under these considerations, we formulate the proposed ST-Adapter by sticking to commonly-adopted primitive operators alone. Starting with the above Adapter (Eq. (1)) originally developed for NLP tasks, we further introduce a spatio-temporal operator realized by a standard depth-wise 3Dconvolution layer [18] between the bottlenecks (Figure 1). In particular, our spatio-temporal operator enables layer-wise temporal inference efficiently, because it only operates in a compressed lowdimensional (e.g., 128D) feature space and the depth-wise convolution is highly efficient both in parameter and computation [26]. As a result, this yields an introduction of tiny extra $( \sim 2 \% )$ parameters and $( \sim 0 . 3 \% )$ computation. Formally, our ST-Adapter can be expressed as: + +$$ +\mathrm { S T - A d a p t e r ( { \mathbf { X } } ) } = { \mathbf { X } } + f \Bigl ( \mathrm { D W C o n v 3 D } ( { \mathbf { X } } { \mathbf { W } } _ { d o w n } ) \Bigr ) { \mathbf { W } } _ { u p } , +$$ + +where DWConv3D denotes the depth-wise 3D-convolution for spatio-temporal reasoning we introduce. It is noteworthy that before applying DWConv3D, the down-projected feature representations will be first reshaped from $\mathbf { X } ^ { \prime } \in \mathbb { R } ^ { T \times N \times d }$ to ${ \bf X } ^ { \prime \prime } \in \mathbb { R } ^ { T \times h \times w \times d }$ (where $N = h \times w ,$ ) to have the spatial and temporal dimensions prepared for reasoning. With this highly integrated design, our ST-Adapter enjoys the same efficiency and flexibility as the NLP Adapter, while uniquely being able to conduct spatio-temporal modeling. l. + +# 3.3 ST-Adapter Integration + +For proper adaptation, the adapter modules are often integrated between layers of a Transformer. In NLP, a variety of integrating designs have been investigated. For example, [25] deploys two adapter modules per layer with one following the Multi-Head Self-Attention (MHSA) and the other following the Feed-Forward Networks (FFN) [25]. On the other hand, [63, 5] suggest that adding only one adapter after the FNN suffices. Similarly, our ST-Adapter can be also integrated generally at distinctive positions. Empirically, we find that a decent performance can be achieved in case a single ST-Adapter is placed before the MHSA of each transformer block (Figure 1(a) and Table 5c). + +# 4 Experiments + +# 4.1 Experiments Setup + +Datasets For the benchmark experiments, we use two popular video action recognition datasets. + +Kinetics-400 (K400): The K400 [33] dataset contains ${ \sim } 2 4 0 \mathrm { k }$ training videos and $2 0 \mathrm { k }$ validation videos labeled with 400 action categories. Most videos have a length of 10s or about 300 frames. While there is a great diversity in these videos, they are largely biased to spatial appearance [60]. + +Something-Something- $\cdot \nu 2$ $( S S \nu 2 )$ : The SSv2 [22] dataset consists of 220,487 videos covering 174 human actions. The video length ranges from 2 to 6 seconds. In contrast to K400, SSv2 presents richer temporal information with much higher significance [60]. + +Epic-Kitchens-100 (EK100): The EK100 [13] dataset consists of 100 hours of video in egocentric perspective recording a person interacting with a variety of objects in the kitchen. Each video sample is labeled with a verb and a noun. We report top-1 verb and noun classification accuracy. + +Pre-trained models In all experiments, we use the standard ViT [16] as our base backbone model. We conduct most of our experiments with the ViT-B/16 variant with 12 layers and 86M parameters, taking as input a sequence of patches at size $1 6 \times 1 6$ . + +What was learned during pre-training directly decides the knowledge that can be transferred to downstream tasks, thus also the effectiveness upper bound of transfer learning methods. To this end, we benchmark the same backbone under two different pre-training strategies: pre-training with web-scale raw data that has been recently proposed by CLIP [55] (400M image-text pair) and classical supervised pre-training on annotated data from ImageNet-21K (21k classes and 14M images). + +Implementation details. All details, including training and testing settings and module instantiation details, are provided in the appendix. + +Competitors We provide several transfer learning approaches in our benchmark for efficient imageto-video transfer learning. Note that the parameters of the linear classifier are always updated during training for all approaches. + +(1) Full Fine-tuning: Fully updating all the parameters when adapting for a specific target task. +(2) Partial Fine-tuning: Only update the last ViT layer while keeping the rest of the parameter fixed. +(3) Temporal Fine-tuning: We only tune the temporal attention modules (i.e., TA) in the $\mathrm { S A } { + } \mathrm { T A }$ architecture. +(4) Linear Probing: Freezing all the parameters except those in the linear classification layer. +(5) Adapter [25]: Adding small sub-networks between layers of a pre-trained model. During fine-tuning, we only update the newly added parameters introduced by the adapters. +(6) Prompt Tuning [29]: Prepending a sequence of learnable prompt tokens to the input visual patch tokens. During fine-tuning, only these newly added prompts are updated. +(7) Attention Pooling Head: Replacing the original temporal average pooling with a temporal attention pooling layer (similar to the one used in [9]) before the classification head. + +These approaches above do not incorporate temporal modeling to the image ViT. Hence, we further consider temporally augmented ViT architectures as introduced in state-of-the-art video methods: + +(a) Spatial Attention Only (SA): Space-Only TimeSformer [6]. +(b) Spatial Attention $^ +$ Temporal Attention $( S A + T A )$ : The default TimeSformer [6] with divided space-time attention (Fig. 1a). +(c) Spatial Attention $^ +$ Temporal Shift $( S A + T S )$ : XViT [9]. + +Note that not all fine-tuning protocols are compatible with each of these video ViT variants. Take $\mathrm { S A } { + } \mathrm { T S }$ for example, the original model behavior is altered with channel shift, as a result, it is not compatible with Linear Probing that requires freezing all the parameters of the backbone. + +# 4.2 Main Results and Analysis + +Cross-modality fine-tuning benchmark. Table 1 presents the results of fine-tuning a ViT-B/16 pre-trained with CLIP and ImageNet-21K. All baselines are built by combining existing efficient fine-tuning methods with three state-of-the-art ViT-based action recognition models. From the results we can see that: + +(i) For CLIP pre-trained model, ST-Adapter performs on par with Full Fine-tuning (82.0 vs. 81.7 for K400 and 66.3 vs. 66.1 for SSv2) while updating far less parameters (7.2M vs. 121.57M). ST-Adapter significantly outperforms all other efficient fine-tuning methods. We see that baselines like Prompt Tuning and Partial Fine-tuning can provide non-trivial gain in performance compared to Linear Probe, but are still behind our ST-Adapter. + +(ii) Our ST-Adapter can generalize across different pre-training datasets and methods. We can see that CLIP pre-train models dominate over ImageNet-21K pre-train ones. These results well match the shift of paradigm in current AI research [7], where pre-training no longer needs limiting to curated data and annotations to deliver good performance on downstream tasks, but can take advantage of broader scale web raw data. + +Interestingly, we observe that SSv2, a motion-centric dataset in design, also benefits from stronger appearance (image) pre-training. We think this may attribute to that raw textual description can provide a much richer description (i.e., human-object relations) of the image than curated limited categorical labels. Full fine-tuning on $\mathrm { S A } { + } \mathrm { T S }$ (XViT) performs slightly worse with CLIP pretrain than ImageNet-21k pretrain. We conjecture this is because the channel shift operation breaks the knowledge in the pre-training weights, and thus does not benefit much from stronger pre-training like CLIP. + +Comparison to the state-of-the-art models. We compare ViT with ST-Adapter to other state-of-thearts methods on both K400 dataset [33] in Table 2, SSv2 dataset [22] in Table 3 and EK100 dataset [13] in Table 4. We can observe that: + +(i) With the proper adaptation method, we can simply turn a large image foundation model into a good video model by only tuning a few parameters. Our results are comparable to or better than previous methods tailored for such tasks. Our largest model with ViT-L backbone set a new state-of-the-art in K400 by achieving $8 6 . 7 \%$ top-1 accuracy. + +Table 1: Benchmark results on Kinetics-400 and Something-Something-v2. We evaluate all the approaches on two datasets with ViT-B/16 pretrained with CLIP and ImageNet-21K. For each entry, we report the top1 action recognition accuracy and the number of fine-tuned parameters. All methods introduce extra parameters beside parameters of the ViT backbone and linear classifier. Our ST-Adapter achieves the best trade-off between accuracy and training efficiency. It is the only efficient fine-tuning method that can match the performance of full fine-tuning. The TM? column shows whether the method includes temporal modelling, i.e., a temporal aggregation method other than average pooling. All models are trained using 8 frames and tested with 3 views. + +
Fine-tuning MethodsArchitecture TM?Fine-tuned Params (M)CLIPImageNet-21K
K400SSv2K400SSv2
Full Fine-tuningSA86.1181.044.076.940.0
SA + TA [6] SA + TS [9]121.57 93.7981766.178.059.5
Partial Fine-tuning78.062.078.564.4
SA SA + TA7.40 10.3680.1 80.337.6 57.561.7 63.120.4 29.3
Temporal Fine-tuningSA + TA35.881.359.476.551.9
Prompt TuningSA1.1879.339.371.426.3
Attentional PoolingSA2.3675.321.559.115.1
Linear ProbeSA0.3176.621.960.114.8
Adapter [25]SA6.7781.646.276.240.5
SA一√7.2082.066.376.6
ST-Adapter (ours)62.8
+ +(ii) It is noteworthy that, our method takes significantly fewer frames as input compared to other methods (8 vs. 16, 32, 64, 96). It is also reflected in terms of GFlops. Saying that the ViT was not designed for efficiency purposes like [38, 9, 43, 17] but the adapted CLIP ViT has achieved similar accuracy-efficiency trade-offs. + +(iii) The paradigm of pre-training and fine-tuning has been widely adopted in most state-of-art methods to achieve good performance. Between them, most of the approaches start from image pre-trained models, and only a few can afford video pre-training. Note that for the SomethingSomething dataset, except MViT [17] pre-trained on video data from scratch, the rest of methods are still initialized from image pre-trained weights. A good image pre-trained model with rich appearance information can facilitate temporal modeling in temporally challenging datasets like SSv2. + +(iii) It is evident in Table 4 that our ST-Adapter consistently brings a big margin on egocentric videos. Also, we found that without our ST-Adapter, it is much more difficult to directly adapt CLIP pre-trained ViT on the domain of egocentric video with high sensitivity to the hyper-parameter setting. ST-Adapter eases the training process. It is worthy to note that, all current transformer based approaches need to be pre-trained first on image dataset and then fine-tuned on Kinetics dataset before fine-tuned with egocentric videos. In contrast, our ST-Adapter can be directly applied to an image model and trained with target egocentric video alone. + +# 4.3 Ablations + +Unless otherwise specified, we use ViT-B/16 backbone and 8 input frames in all ablation experiments, and we use one ST-Adapter with bottleneck width 384 before MHSA in each Transformer block. + +Where to insert ST-Adapter By default, we insert a ST-Adapter to every Transformer block in the backbone, but we also show the performance impact of using fewer ST-Adapters. As shown in Table 5b, while more ST-Adapters tend to do better, ST-Adapters at deeper layers boost performance more than those at shallower layers. This observation is useful when we insert ST-Adapters into deeper models and having an Adapter for each block might be too expensive. We also show the performance when inserting ST-Adapters to different positions within a block. As shown in Table 5c, while the performance is relatively insensitive to the position of the Adapters, using multiple adapters in one block may substantially boost performance on some datasets, like SSv2 in our case. + +Table 2: Results on Kinetics-400 validation set. “Frames” denotes the total number of frames used during inference which is: # frames per clip $\times$ # temporal clip $\times$ # spatial crop. “GFlops” means $1 0 ^ { 9 }$ Flops. Our ViT w/ ST-Adapter achieves new state-of-the-art performances on K400 at similar GFlops. + +
ModelPretrain#FramesGFlopsTop-1Top-5
Methods with full-finetuning
LGD[53]IN-1K128×N/AN/A79.494.4
SlowFast+NL[19]=16×3×10702079.893.9
ip-CSN[70]Sports1M32×3×10327079.293.8
CorrNet[71]Sports1M32×3×10672081.0=
X3D-XL[18]16×3×10145279.193.9
MoViNet-A6[34]1120×1×138681.595.3
ViT-B-VTN [47]IN21K250×1×1399278.693.7
TimeSformer-L[6]IN21K96×3×1714080.794.7
STAM [61]IN21K64×1×1104079.21
X-ViT[9]IN21K16×3×185080.294.7
Mformer-HR[49]IN-21K16×3×102876481.195.2
MViT-B,32×3[17]-32×1×585080.294.4
ViViT-L[2]JFT300M16×3×41735282.895.3
Swin-B[44]IN1K32×3×4338480.694.6
Swin-L(384)[44]IN21K32×5×1010535084.996.7
UniFormer-B[38]IN1K32×1×4103682.995.4
VATT-Large(320)[1]HowTo100M32×3×42980082.195.5
TokenLearner[58]JFT300M64×3×44891285.496.3
OMNIVORE(Swin-L)[21]IN22K+SUN32×3×4724884.196.3
MTV-H[80]WTS-28032×3×47357089.998.3
ViT-B w/o ST-AdapterCLIP8×3×141981.095.5
ViT-L w/o ST-AdapterCLIP8×3×1194185.897.2
Methodswith frozen backbone
Our ViT-B w/ST-AdapterCLIP8×3×145582.095.7
Our ViT-B w/ ST-AdapterCLIP16×3×191182.596.0
Our ViT-B w/ ST-AdapterCLIP32×3×1182182.796.2
Our ViT-L w/ST-AdapterCLIP8×3×1206286.797.5
Our ViT-L w/ ST-AdapterCLIP16×3×1412486.997.6
Our ViT-L w/ ST-AdapterCLIP32×3×1824887.297.6
+ +Training parameter efficiency We experiment with a different number of channels in the middle of the bottleneck design. As shown in Table 5a and Fig. 2a, our method is effective with a wide range of bottleneck width: even with a channel reduction to 64, our ST-Adapters still obtain relatively good performance, outperforming all baselines in Table 1 except for Full Fine-tuning $\mathrm { ( S A + T A ) }$ . Even with a bottleneck width of 768, our ST-Adapters are still very parameter efficient, introducing only about 1/6 new parameters to a Transformer encoder block. In contrast to the inverted bottleneck design commonly used with depthwise convolutions [59], ST-Adapters work best with regular bottlenecks. The success of transfer learning with such low-rank projections again shows the rich knowledge and strong potential of modern foundation models. + +Training time efficiency In Fig. 2b we show an enlarged difference between full fine-tuned models and our ST-Adapters with low training budgets. When we reduce the number of training steps, the accuracy of full fine-tuned models drops significantly faster than models with ST-Adapters. This shows the advantage of our proposed modules when backbone models are large or computational resources are limited. We also report the total training GPU-hours and peak memory usage for three models: TimeSformer, ViT-B/16, ViT-B/16 with ST-Adapter (8 input frames, 16 samples per GPU on 8 V100 GPUs) in Table 6. + +Table 3: Results on Something-Something-v2 validation set. “Frames” denotes the total number of frames used during inference which is: # frames per clip $\times$ # temporal clip $\times \#$ spatial crop. “GFlops” means $1 0 ^ { 9 }$ Flops. Our ViT w/ ST-Adapter outperforms most of the current methods by only fine-tuning a very small set of parameters. Here the ViT-B w/ ST-Adapter result is reported using 2 ST-Adapters per block. + +
ModelPretrain#FramesGFlopsTop-1Top-5
Methods with full-finetuning
TSM[41]GST[46]MSNet[35]CT-Net[37]TDN[73]TimeSformer-HR[6]X-ViT[9]Mformer-L[49]ViViT-L[2]MViT-B-24,32×3[17]Swin-B[44]UniFormer-B[38]OMNIVORE (Swin-B)[21]MTV-B(320p)[80]ViT-B w/o ST-AdapterViT-L w/o ST-AdapterIN1K16×1×16663.388.5
IN1K16×1×15962.687.9
IN1K16×1×110164.789.4
IN1K16×1×17564.589.3
IN1K16×1×17265.389.5
IN21K16×3×1510962.5-
IN21K32×3×1127065.490.7
IN21K+K40032×3×1355568.191.2
IN21K+K40016×3×41189265.489.8
K60032×1×370868.791.5
IN21K+K40032×3×196369.692.7
IN1K+K60032×3×177771.292.8
B)[21]IN22K+K400+SUN32×3×196371.493.5
IN21K+K400CLIPCLIP32×3×41116068.590.4
8×3×141944.077.0
8×3×1194148.777.5
Methodswith frozen backboneOur ViT-B w/ ST-Adapter CLIP 8×3×1 489Our ViT-B w/ ST-Adapter CLIP 16×3×1 977Our ViT-B w/ ST-Adapter CLIP 32×3×1 1955Our ViT-L w/ ST-Adapter CLIP 8×3×1 2062Our ViT-L w/ ST-Adapter CLIP 16×3×1 4124Our ViT-L w/ ST-Adapter CLIP 32×3×1 8248
CLIP8×3×148967.191.2
CLIP16×3×197769.392.3
CLIP32×3×1195569.592.6
CLIP8×3×1206270.092.3
CLIP16×3×1412471.993.4
CLIP32×3×1824872.393.9
+ +Table 4: Results on Epic-Kitchens-100 validation set. “Frames” denotes the total number of frames used during inference which is: # frames per clip $\times$ # temporal clip $\times \#$ spatial crop. + +
ModelPre-train data#FramesVerbNoun
Methods with full-finetuning
ViViT-L [2]IN21K+K40016×3×1066.456.8
MFormer-B [49]IN21K+K40016 ×3×1066.756.5
XViT(8x) [9]IN21K+K4008×3×166.753.3
ViT-B/16 w/o ST-AdapterCLIP8×3×154.850.4
Methods with frozen backbone
Our ViT-B/16 w/ ST-AdapterCLIP8×3×167.655.0
+ +Table 5: Ablation study on K-400 and SSv2. (a) We show the performance with different channel numbers in the bottleneck. (b) We evenly divide the 12 blocks of ViT-B/16 into 3 groups. Block no. 1 is closest to input and no. 12 is closest to output. (c) Effect of where to put the ST-Adapter inside a block, whose diagram is shown in Fig. 1. + +
(a) Bottleneck width
width K400SSv2
6481.4 64.4
128 81.664.9
256 81.865.5
38482.0 65.6
768 81.965.5
+ +(c) Local position + +
positionK400SSv2
before MHSA82.065.6
after MHSA81.965.7
afterFFN81.965.9
before&after MHSA82.067.0
+ +
(b) Global position
1-45-89-12K400SSv2
77.745.9
80.060.9
81.362.8
81.865.6
82.065.6
+ +![](images/cb051a1b084f57fc5c20733c36a911eb6a4a6200e098711f0bc5633170f6ab96.jpg) +Figure 2: Ablation study on efficiency (a) Parameter efficiency: ST-Adapter (with different bottleneck width) is compared with efficient fine-tuning methods in Table 1. (b) Training efficiency: We compare ST-Adapter with Full fine-tuning under different training schedules. Batch size is aligned and their original schedules are shortened proportionally. (c) Data efficiency: Performance comparison on different training data scales. The same ViT-B/16 with CLIP pre-training is used for all experiments. + +Training data efficiency Fig. 2c showcases the impact of training data size on action recognition accuracy. Even with the same pre-trained weights, ST-Adapters tend to obtain higher performance than full fine-tuning especially on smaller datasets: the margin between the two models increases with the shrinkage of data. This shows that ST-Adapters are powerful tools to transfer to downstream tasks where only a small amount of labeled data is available. + +Effects of kernel shape We ablate the effect of kernel size in the depth-wise convolutions inside our proposed ST-Adapter. It is shown in Table 7 that the temporal span is most sensitive, suggesting the significance of temporal structural modeling as we focus on in this work. + +Table 6: Training time and memory. For full-finetuning we used the recipes in [6]. + +
ModelTraining GPU-hours (K400)Peak mem ( (MB)
TimeSformer[6] (Full Fine-tune)60 (+161%)21694 (+52%)
ViT-B/16 (Full Fine-tune)40 (+74%)17275 (+21%)
ViT-B/16 w/ ST-Adapter2314238
+ +# 5 Conclusions + +Table 7: Effects of kernel shape. Kernel size is denoted as $k _ { T } \times k _ { H } \times$ $k _ { W }$ for time, height and width. + +
Kernel SizeK400SSv2
1×1×181.646.2
1×3×381.446.2
3×1×182.066.3
3×3×382.065.6
+ +In this work, we have presented a simple yet effective SpatioTemporal Adapter (ST-Adapter) for enabling a less studied parameter-efficient image-to-video transfer learning. Fully using commonly adopt primitive operators, ST-Adapter is particularly designed to be both lightweight and easy to implement for friendly usability and deployment. This cross-modality adaptation is a practically critical capability considering that it is dramatically challenging and more costly to build a sufficiently strong large video model in reality. Encouragingly, extensive experiments on video action recognition show that our ST + +Adapter can match or surpass both the full fine-tuning strategy as well as fully trained state-of-the-art video models, whilst having the benefit of (20 times less updated parameters) parameter-efficiency. Further, our method is also faster to train and consumes less computing resources with economic and environmental superiority. We believe this work is inspiring for the research of other video understanding tasks such as action localization and video summarization. + +Acknowledgement This work is supported in part by Centre for Perceptual and Interactive Intelligence Limited, in part by the General Research Fund through the Research Grants Council of Hong Kong under Grants (Nos. 14204021, 14207319). + +# References + +[1] 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. Advances in Neural Information Processing Systems, 34, 2021. +[2] Anurag Arnab, Mostafa Dehghani, Georg Heigold, Chen Sun, Mario Luciˇ c, and Cordelia Schmid. Vivit: A ´ video vision transformer. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 6836–6846, 2021. +[3] Jimmy Lei Ba, Jamie Ryan Kiros, and Geoffrey E Hinton. Layer normalization. arXiv preprint arXiv:1607.06450, 2016. +[4] Hyojin Bahng, Ali Jahanian, Swami Sankaranarayanan, and Phillip Isola. Visual prompting: Modifying pixel space to adapt pre-trained models. arXiv preprint arXiv:2203.17274, 2022. +[5] Ankur Bapna, Naveen Arivazhagan, and Orhan Firat. Simple, scalable adaptation for neural machine translation. arXiv preprint arXiv:1909.08478, 2019. +[6] Gedas Bertasius, Heng Wang, and Lorenzo Torresani. Is space-time attention all you need for video understanding? arXiv preprint arXiv:2102.05095, 2021. +[7] Rishi Bommasani, Drew A Hudson, Ehsan Adeli, Russ Altman, Simran Arora, Sydney von Arx, Michael S Bernstein, Jeannette Bohg, Antoine Bosselut, Emma Brunskill, et al. On the opportunities and risks of foundation models. arXiv preprint arXiv:2108.07258, 2021. +[8] 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. volume 33, pages 1877–1901. Curran Associates, Inc., 2020. +[9] Adrian Bulat, Juan Manuel Perez Rua, Swathikiran Sudhakaran, Brais Martinez, and Georgios Tzimiropoulos. Space-time mixing attention for video transformer. Advances in Neural Information Processing Systems, 34, 2021. +[10] 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, pages 6299–6308, 2017. +[11] Joao Carreira, Eric Noland, Andras Banki-Horvath, Chloe Hillier, and Andrew Zisserman. A short note about kinetics-600. arXiv preprint arXiv:1808.01340, 2018. +[12] 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. +[13] Dima Damen, Hazel Doughty, Giovanni Maria Farinella, , Antonino Furnari, Jian Ma, Evangelos Kazakos, Davide Moltisanti, Jonathan Munro, Toby Perrett, Will Price, and Michael Wray. Rescaling egocentric vision: Collection, pipeline and challenges for epic-kitchens-100. International Journal of Computer Vision (IJCV), 130:33–55, 2022. URL https://doi.org/10.1007/s11263-021-01531-2. +[14] Jia Deng, Wei Dong, Richard Socher, Li-Jia Li, Kai Li, and Li Fei-Fei. Imagenet: A large-scale hierarchical image database. 2009. +[15] 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), pages 4171–4186, Minneapolis, Minnesota, June 2019. Association for Computational Linguistics. +[16] 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. 2020. +[17] Haoqi Fan, Bo Xiong, Karttikeya Mangalam, Yanghao Li, Zhicheng Yan, Jitendra Malik, and Christoph Feichtenhofer. Multiscale vision transformers. arXiv preprint arXiv:2104.11227, 2021. +[18] Christoph Feichtenhofer. X3d: Expanding architectures for efficient video recognition. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 203–213, 2020. +[19] Christoph Feichtenhofer, Haoqi Fan, Jitendra Malik, and Kaiming He. Slowfast networks for video recognition. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 6202–6211, 2019. +[20] Christoph Feichtenhofer, Haoqi Fan, Bo Xiong, Ross Girshick, and Kaiming He. A large-scale study on unsupervised spatiotemporal representation learning. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 3299–3309, 2021. +[21] Rohit Girdhar, Mannat Singh, Nikhila Ravi, Laurens van der Maaten, Armand Joulin, and Ishan Misra. Omnivore: A single model for many visual modalities. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 16102–16112, 2022. +[22] Raghav Goyal, Samira Ebrahimi Kahou, Vincent Michalski, Joanna Materzynska, Susanne Westphal, Heuna Kim, Valentin Haenel, Ingo Fruend, Peter Yianilos, Moritz Mueller-Freitag, et al. The" something something" video database for learning and evaluating visual common sense. In Proceedings of the IEEE International Conference on Computer Vision, pages 5842–5850, 2017. +[23] Ryota Hashiguchi and Toru Tamaki. Vision transformer with cross-attention by temporal shift for efficient action recognition. arXiv preprint arXiv:2204.00452, 2022. +[24] Junxian He, Chunting Zhou, Xuezhe Ma, Taylor Berg-Kirkpatrick, and Graham Neubig. Towards a unified view of parameter-efficient transfer learning. 2022. +[25] Neil Houlsby, Andrei Giurgiu, Stanislaw Jastrzebski, Bruna Morrone, Quentin De Laroussilhe, Andrea Gesmundo, Mona Attariyan, and Sylvain Gelly. Parameter-efficient transfer learning for nlp. In ICML, pages 2790–2799. PMLR, 2019. +[26] 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. +[27] Edward J Hu, Yelong Shen, Phillip Wallis, Zeyuan Allen-Zhu, Yuanzhi Li, Shean Wang, Lu Wang, and Weizhu Chen. Lora: Low-rank adaptation of large language models. arXiv preprint arXiv:2106.09685, 2021. +[28] 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, pages 4904–4916. PMLR, 2021. +[29] Menglin Jia, Luming Tang, Bor-Chun Chen, Claire Cardie, Serge Belongie, Bharath Hariharan, and Ser-Nam Lim. Visual prompt tuning. arXiv preprint arXiv:2203.12119, 2022. +[30] Boyuan Jiang, MengMeng Wang, Weihao Gan, Wei Wu, and Junjie Yan. Stm: Spatiotemporal and motion encoding for action recognition. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 2000–2009, 2019. +[31] Chen Ju, Tengda Han, Kunhao Zheng, Ya Zhang, and Weidi Xie. Prompting visual-language models for efficient video understanding. arXiv preprint arXiv:2112.04478, 2021. +[32] Andrej Karpathy, George Toderici, Sanketh Shetty, Thomas Leung, Rahul Sukthankar, and Li Fei-Fei. Large-scale video classification with convolutional neural networks. In Proceedings of the IEEE conference on Computer Vision and Pattern Recognition, pages 1725–1732, 2014. +[33] Will Kay, Joao Carreira, Karen Simonyan, Brian Zhang, Chloe Hillier, Sudheendra Vijayanarasimhan, Fabio Viola, Tim Green, Trevor Back, Paul Natsev, et al. The kinetics human action video dataset. arXiv preprint arXiv:1705.06950, 2017. +[34] D. Kondratyuk, Liangzhe Yuan, Yandong Li, Li Zhang, Mingxing Tan, Matthew A. Brown, and Boqing Gong. Movinets: Mobile video networks for efficient video recognition. ArXiv, abs/2103.11511, 2021. +[35] Heeseung Kwon, Manjin Kim, Suha Kwak, and Minsu Cho. Motionsqueeze: Neural motion feature learning for video understanding. In ECCV, 2020. +[36] Brian Lester, Rami Al-Rfou, and Noah Constant. The power of scale for parameter-efficient prompt tuning. In Proceedings of the 2021 Conference on Empirical Methods in Natural Language Processing, pages 3045–3059, Online and Punta Cana, Dominican Republic, November 2021. Association for Computational Linguistics. +[37] Kunchang Li, Xianhang Li, Yali Wang, Jun Wang, and Y. Qiao. Ct-net: Channel tensorization network for video classification. ArXiv, abs/2106.01603, 2021. +[38] Kunchang Li, Yali Wang, Junhao Zhang, Peng Gao, Guanglu Song, Yu Liu, Hongsheng Li, and Yu Qiao. Uniformer: Unifying convolution and self-attention for visual recognition. arXiv preprint arXiv:2201.09450, 2022. +[39] Xiang Lisa Li and Percy Liang. Prefix-tuning: Optimizing continuous prompts for generation. In Proceedings of the 59th Annual Meeting of the Association for Computational Linguistics and the 11th International Joint Conference on Natural Language Processing (Volume 1: Long Papers), pages 4582– 4597, Online, August 2021. Association for Computational Linguistics. +[40] Yanghao Li, Chao-Yuan Wu, Haoqi Fan, Karttikeya Mangalam, Bo Xiong, Jitendra Malik, and Christoph Feichtenhofer. Improved multiscale vision transformers for classification and detection. arXiv preprint arXiv:2112.01526, 2021. +[41] Ji Lin, Chuang Gan, and Song Han. Tsm: Temporal shift module for efficient video understanding. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 7083–7093, 2019. +[42] Xiao Liu, Kaixuan Ji, Yicheng Fu, Zhengxiao Du, Zhilin Yang, and Jie Tang. P-tuning v2: Prompt tuning can be comparable to fine-tuning universally across scales and tasks. arXiv preprint arXiv:2110.07602, 2021. +[43] 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. 2021. +[44] Ze Liu, Jia Ning, Yue Cao, Yixuan Wei, Zheng Zhang, Stephen Lin, and Han Hu. Video swin transformer. arXiv preprint arXiv:2106.13230, 2021. +[45] Zhaoyang Liu, Limin Wang, Wayne Wu, Chen Qian, and Tong Lu. Tam: Temporal adaptive module for video recognition. arXiv preprint arXiv:2005.06803, 2020. +[46] Chenxu Luo and Alan L. Yuille. Grouped spatial-temporal aggregation for efficient action recognition. 2019 IEEE International Conference on Computer Vision (ICCV), pages 5511–5520, 2019. +[47] Daniel Neimark, Omri Bar, Maya Zohar, and Dotan Asselmann. Video transformer network. ArXiv, abs/2102.00719, 2021. +[48] Junting Pan, Siyu Chen, Mike Zheng Shou, Yu Liu, Jing Shao, and Hongsheng Li. Actor-context-actor relation network for spatio-temporal action localization. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), pages 464–474, June 2021. +[49] Mandela Patrick, Dylan Campbell, Yuki Asano, Ishan Misra, Florian Metze, Christoph Feichtenhofer, Andrea Vedaldi, and João F Henriques. Keeping your eye on the ball: Trajectory attention in video transformers. Advances in Neural Information Processing Systems, 34, 2021. +[50] Jonas Pfeiffer, Aishwarya Kamath, Andreas Rücklé, Kyunghyun Cho, and Iryna Gurevych. Adapterfusion: Non-destructive task composition for transfer learning. arXiv preprint arXiv:2005.00247, 2020. +[51] Jonas Pfeiffer, Andreas Rücklé, Clifton Poth, Aishwarya Kamath, Ivan Vulic, Sebastian Ruder, Kyunghyun ´ Cho, and Iryna Gurevych. Adapterhub: A framework for adapting transformers. In Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing (EMNLP 2020): Systems Demonstrations, pages 46–54, Online, 2020. Association for Computational Linguistics. +[52] Guanghui Qin and Jason Eisner. Learning how to ask: Querying lms with mixtures of soft prompts. arXiv preprint arXiv:2104.06599, 2021. +[53] Zhaofan Qiu, Ting Yao, C. Ngo, Xinmei Tian, and Tao Mei. Learning spatio-temporal representation with local and global diffusion. 2019 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), pages 12048–12057, 2019. +[54] 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. +[55] Alec Radford, Jong Wook Kim, Chris Hallacy, Aditya Ramesh, Gabriel Goh, Sandhini Agarwal, Girish Sastry, Amanda Askell, Pamela Mishkin, Jack Clark, et al. Learning transferable visual models from natural language supervision. In International Conference on Machine Learning, pages 8748–8763. PMLR, 2021. +[56] Sylvestre-Alvise Rebuffi, Hakan Bilen, and Andrea Vedaldi. Learning multiple visual domains with residual adapters. 30, 2017. +[57] Sylvestre-Alvise Rebuffi, Hakan Bilen, and Andrea Vedaldi. Efficient parametrization of multi-domain deep neural networks. pages 8119–8127, 2018. +[58] Michael Ryoo, AJ Piergiovanni, Anurag Arnab, Mostafa Dehghani, and Anelia Angelova. Tokenlearner: Adaptive space-time tokenization for videos. Advances in Neural Information Processing Systems, 34, 2021. +[59] Mark Sandler, Andrew Howard, Menglong Zhu, Andrey Zhmoginov, and Liang-Chieh Chen. Mobilenetv2: Inverted residuals and linear bottlenecks. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 4510–4520, 2018. +[60] Laura Sevilla-Lara, Shengxin Zha, Zhicheng Yan, Vedanuj Goswami, Matt Feiszli, and Lorenzo Torresani. Only time can tell: Discovering temporal data for temporal modeling. In Proceedings of the IEEE/CVF Winter Conference on Applications of Computer Vision, pages 535–544, 2021. +[61] Gilad Sharir, Asaf Noy, and Lihi Zelnik-Manor. An image is worth 16x16 words, what is a video worth? ArXiv, abs/2103.13915, 2021. +[62] Taylor Shin, Yasaman Razeghi, Robert L Logan IV, Eric Wallace, and Sameer Singh. Autoprompt: Eliciting knowledge from language models with automatically generated prompts. arXiv preprint arXiv:2010.15980, 2020. +[63] Asa Cooper Stickland and Iain Murray. Bert and pals: Projected attention layers for efficient adaptation in multi-task learning. In International Conference on Machine Learning, pages 5986–5995. PMLR, 2019. +[64] Chen Sun, Austin Myers, Carl Vondrick, Kevin Murphy, and Cordelia Schmid. Videobert: A joint model for video and language representation learning. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 7464–7473, 2019. +[65] Yi-Lin Sung, Jaemin Cho, and Mohit Bansal. Vl-adapter: Parameter-efficient transfer learning for visionand-language tasks. arXiv preprint arXiv:2112.06825, 2021. +[66] Yonglong Tian, Dilip Krishnan, and Phillip Isola. Contrastive multiview coding. In European conference on computer vision, pages 776–794. Springer, 2020. +[67] Zhan Tong, Yibing Song, Jue Wang, and Limin Wang. Videomae: Masked autoencoders are data-efficient learners for self-supervised video pre-training. arXiv preprint arXiv:2203.12602, 2022. +[68] Du Tran, Lubomir Bourdev, Rob Fergus, Lorenzo Torresani, and Manohar Paluri. Learning spatiotemporal features with 3d convolutional networks. In Proceedings of the IEEE international conference on computer vision, pages 4489–4497, 2015. +[69] Du Tran, Heng Wang, Lorenzo Torresani, Jamie Ray, Yann LeCun, and Manohar Paluri. A closer look at spatiotemporal convolutions for action recognition. In Proceedings of the IEEE conference on Computer Vision and Pattern Recognition, pages 6450–6459, 2018. +[70] Du Tran, Heng Wang, L. Torresani, and Matt Feiszli. Video classification with channel-separated convolutional networks. 2019 IEEE/CVF International Conference on Computer Vision (ICCV), pages 5551–5560, 2019. +[71] Heng Wang, Du Tran, L. Torresani, and Matt Feiszli. Video modeling with correlation networks. 2020 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), pages 349–358, 2020. +[72] Limin Wang, Yuanjun Xiong, Zhe Wang, Yu Qiao, Dahua Lin, Xiaoou Tang, and Luc Van Gool. Temporal segment networks for action recognition in videos. IEEE transactions on pattern analysis and machine intelligence, 41(11):2740–2755, 2018. +[73] Limin Wang, Zhan Tong, Bin Ji, and Gangshan Wu. Tdn: Temporal difference networks for efficient action recognition. ArXiv, abs/2012.10071, 2020. +[74] Mengmeng Wang, Jiazheng Xing, and Yong Liu. Actionclip: A new paradigm for video action recognition. arXiv preprint arXiv:2109.08472, 2021. +[75] Xiaolong Wang, Ross Girshick, Abhinav Gupta, and Kaiming He. Non-local neural networks. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 7794–7803, 2018. +[76] Chen Wei, Haoqi Fan, Saining Xie, Chao-Yuan Wu, Alan Yuille, and Christoph Feichtenhofer. Masked feature prediction for self-supervised visual pre-training. arXiv preprint arXiv:2112.09133, 2021. +[77] Saining Xie, Chen Sun, Jonathan Huang, Zhuowen Tu, and Kevin Murphy. Rethinking spatiotemporal feature learning: Speed-accuracy trade-offs in video classification. In Proceedings of the European conference on computer vision (ECCV), pages 305–321, 2018. +[78] Hu Xu, Gargi Ghosh, Po-Yao Huang, Prahal Arora, Masoumeh Aminzadeh, Christoph Feichtenhofer, Florian Metze, and Luke Zettlemoyer. Vlm: Task-agnostic video-language model pre-training for video understanding. arXiv preprint arXiv:2105.09996, 2021. +[79] Hu Xu, Gargi Ghosh, Po-Yao Huang, Dmytro Okhonko, Armen Aghajanyan, Florian Metze, Luke Zettlemoyer, and Christoph Feichtenhofer. Videoclip: Contrastive pre-training for zero-shot video-text understanding. In EMNLP, 2021. +[80] Shen Yan, Xuehan Xiong, Anurag Arnab, Zhichao Lu, Mi Zhang, Chen Sun, and Cordelia Schmid. Multiview transformers for video recognition. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 3333–3343, 2022. +[81] Jiahui Yu, Zirui Wang, Vijay Vasudevan, Legg Yeung, Mojtaba Seyedhosseini, and Yonghui Wu. Coca: Contrastive captioners are image-text foundation models. arXiv preprint arXiv:2205.01917, 2022. +[82] Hao Zhang, Yanbin Hao, and Chong-Wah Ngo. Token shift transformer for video classification. In Proceedings of the 29th ACM International Conference on Multimedia, pages 917–925, 2021. +[83] Jeffrey O Zhang, Alexander Sax, Amir Zamir, Leonidas Guibas, and Jitendra Malik. Side-tuning: a baseline for network adaptation via additive side networks. pages 698–714. Springer, 2020. +[84] Yuanhan Zhang, Kaiyang Zhou, and Ziwei Liu. Neural prompt search. arXiv preprint arXiv:2206.04673, 2022. +[85] Kaiyang Zhou, Jingkang Yang, Chen Change Loy, and Ziwei Liu. Learning to prompt for vision-language models. arXiv preprint arXiv:2109.01134, 2021. +[86] Kaiyang Zhou, Jingkang Yang, Chen Change Loy, and Ziwei Liu. Conditional prompt learning for vision-language models. In CVPR, 2022. + +# Checklist + +1. For all authors... + +(a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes] +(b) Did you describe the limitations of your work? [No] +(c) Did you discuss any potential negative societal impacts of your work? [No] +(d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes] + +2. If you are including theoretical results... + +(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] + +3. If you ran experiments... + +(a) Did you include the code, data, and instructions needed to reproduce the main experimental results (either in the supplemental material or as a URL)? [Yes] Code will be provided on GitHub after blind review. +(b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes] See ?? +(c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [No] The experiments are too expensive to repeat many times. +(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 ?? + +4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets... + +(a) If your work uses existing assets, did you cite the creators? [Yes] All are mentioned in 4 +(b) Did you mention the license of the assets? [No] +(c) Did you include any new assets either in the supplemental material or as a URL? [Yes] Code will be provided on GitHub after blind review. +(d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [No] +(e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [No] + +5. If you used crowdsourcing or conducted research with human subjects... + +(a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A] +(b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A] +(c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A] \ No newline at end of file diff --git a/md/dev/w4cXZDDib1H/w4cXZDDib1H.md b/md/dev/w4cXZDDib1H/w4cXZDDib1H.md new file mode 100644 index 0000000000000000000000000000000000000000..87440667d3051a733a09109b8fd78fe36fc1da32 --- /dev/null +++ b/md/dev/w4cXZDDib1H/w4cXZDDib1H.md @@ -0,0 +1,419 @@ +# VIDT: AN EFFICIENT AND EFFECTIVEFULLY TRANSFORMER-BASED OBJECT DETECTOR + +Hwanjun $\mathbf { S o n g ^ { 1 } }$ , Deqing $\mathbf { S u n ^ { 2 } }$ , Sanghyuk $\mathbf { C h u n ^ { 1 } }$ , Varun Jampani2, Dongyoon $\mathbf { H a n } ^ { 1 }$ , Byeongho $\mathbf { H e o ^ { 1 } }$ , Wonjae $\mathbf { K i m ^ { 1 } }$ , Ming-Hsuan Yang2,3,4 1NAVER AI Lab 2Google Research 3University of California at Merced 4Yonsei University {hwanjun.song, sanghyuk.c, dongyoon.han, bh.heo, wonjae.kim}@navercorp.com {deqingsun, varunjampani}@google.com, mhyang@ucmerced.edu + +# ABSTRACT + +Transformers are transforming the landscape of computer vision, especially for recognition tasks. Detection transformers are the first fully end-to-end learning systems for object detection, while vision transformers are the first fully transformer-based architecture for image classification. In this paper, we integrate Vision and Detection Transformers (ViDT) to build an effective and efficient object detector. ViDT introduces a reconfigured attention module to extend the recent Swin Transformer to be a standalone object detector, followed by a computationally efficient transformer decoder that exploits multi-scale features and auxiliary techniques essential to boost the detection performance without much increase in computational load. Extensive evaluation results on the Microsoft COCO benchmark dataset demonstrate that ViDT obtains the best AP and latency trade-off among existing fully transformer-based object detectors, and achieves 49.2AP owing to its high scalability for large models. We release the code and trained models at https://github.com/naver-ai/vidt. + +# 1 INTRODUCTION + +Object detection is the task of predicting both bounding boxes and object classes for each object of interest in an image. Modern deep object detectors heavily rely on meticulously designed components, such as anchor generation and non-maximum suppression (Papageorgiou & Poggio, 2000; Liu et al., 2020). As a result, the performance of these object detectors depend on specific postprocessing steps, which involve complex pipelines and make fully end-to-end training difficult. + +Motivated by the recent success of Transformers (Vaswani et al., 2017) in NLP, numerous studies introduce Transformers into computer vision tasks. Carion et al. (2020) proposed Detection Transformers (DETR) to eliminate the meticulously designed components by employing a simple transformer encoder and decoder architecture, which serves as a neck component to bridge a CNN body for feature extraction and a detector head for prediction. Thus, DETR enables end-to-end training of deep object detectors. By contrast, Dosovitskiy et al. (2021) showed that a fully-transformer backbone without any convolutional layers, Vision Transformer (ViT), achieves the state-of-theart results in image classification benchmarks. Approaches like ViT have been shown to learn effective representation models without strong human inductive biases, e.g., meticulously designed components in object detection (DETR), locality-aware designs such as convolutional layers and pooling mechanisms. However, there is a lack of effort to synergize DETR and ViT for a better object detection architecture. In this paper, we integrate both approaches to build a fully transformer-based, end-to-end object detector that achieves state-of-the-art performance without increasing computational load. + +A straightforward integration of DETR and ViT can be achieved by replacing the ResNet backbone (body) of DETR with ViT – Figure 2(a). This naive integration, DETR $( \mathbf { V i T } ) ^ { 1 }$ , has two limitations. First, the canonical ViT suffers from the quadratic increase in complexity w.r.t. image size, resulting in the lack of scalability. Furthermore, the attention operation at the transformer encoder and decoder (i.e., the “neck” component) adds significant computational overhead to the detector. Therefore, the naive integration of DETR and ViT show very high latency – the blue lines of Figure 1. + +![](images/059d1196dc7dfcb83c9a1b75faca6fd415d53377ba29adcb296e066152a41ac6.jpg) +Figure 1. AP and latency (milliseconds) summarized in Table 2. The text in the plot indicates the backbone model size. + +![](images/375d191b536070f8a3a8178cba0c583e66368c02cc34cf98f0f2561dca4d763f.jpg) +Figure 2. Pipelines of fully transformer-based object detectors. DETR (ViT) means Detection Transformer that uses ViT as its body. The proposed ViDT synergizes DETR (ViT) and YOLOS and achieves best AP and latency trade-off among fully transformer-based object detectors. + +Recently, Fang et al. (2021) propose an extension of ViT to object detection, named YOLOS, by appending the detection tokens [DET] to the patch tokens [PATCH] (Figure 2(b)), where [DET] tokens are learnable embeddings to specify different objects to detect. YOLOS is a neck-free architecture and removes the additional computational costs from the neck encoder. However, YOLOS shows limited performance because it cannot use additional optimization techniques on the neck architecture, e.g., multi-scale features and auxiliary loss. In addition, YOLOS can only accommodate the canonical transformer due to its architectural limitation, resulting in a quadratic complexity w.r.t. the input size. + +In this paper, we propose a novel integration of Vision and Detection Transformers (ViDT) (Figure 2(c)). Our contributions are three-folds. First, ViDT introduces a modified attention mechanism, named Reconfigured Attention Module (RAM), that facilitates any ViT variant to handle the appended [DET] and [PATCH] tokens for object detection. Thus, we can modify the latest Swin Transformer (Liu et al., 2021) backbone with RAM to be an object detector and obtain high scalability using its local attention mechanism with linear complexity. Second, ViDT adopts a lightweight encoder-free neck architecture to reduce the computational overhead while still enabling the additional optimization techniques on the neck module. Note that the neck encoder is unnecessary because RAM directly extracts fine-grained representation for object detection, i.e., [DET] tokens. As a result, ViDT obtains better performance than neck-free counterparts. Finally, we introduce a new concept of token matching for knowledge distillation, which brings additional performance gains from a large model to a small model without compromising detection efficiency. + +ViDT has two architectural advantages over existing approaches. First, similar to YOLOS, ViDT takes [DET] tokens as the additional input, maintaining a fixed scale for object detection, but constructs hierarchical representations starting with small-sized image patches for [PATCH] tokens. Second, ViDT can use the hierarchical (multi-scale) features and additional techniques without a significant computation overhead. Therefore, as a fully transformer-based object detector, ViDT facilitates better integration of vision and detection transformers. Extensive experiments on Microsoft COCO benchmark (Lin et al., 2014) show that ViDT is highly scalable even for large ViT models, such as Swin-base with 0.1 billion parameters, and achieves the best AP and latency trade-off. + +# 2 PRELIMINARIES + +Vision transformers process an image as a sequence of small-sized image patches, thereby allowing all the positions in the image to interact in attention operations (i.e., global attention). However, the canonical ViT (Dosovitskiy et al., 2021) is not compatible with a broad range of vision tasks due to its high computational complexity, which increases quadratically with respect to image size. The Swin Transformer (Liu et al., 2021) resolves the complexity issue by introducing the notion of shifted windows that support local attention and patch reduction operations, thereby improving compatibility for dense prediction task such as object detection. A few approaches use vision transformers as detector backbones but achieve limited success (Heo et al., 2021; Fang et al., 2021). + +Detection transformers eliminate the meticulously designed components (e.g., anchor generation and non-maximum suppression) by combining convolutional network backbones and Transformer encoder-decoders. While the canonical DETR (Carion et al., 2020) achieves high detection performance, it suffers from very slow convergence compared to previous detectors. For example, DETR requires 500 epochs while the conventional Faster R-CNN (Ren et al., 2015) training needs only 37 epochs (Wu et al., 2019). To mitigate the issue, Zhu et al. (2021) propose Deformable DETR which introduces deformable attention for utilizing multi-scale features as well as expediting the slow training convergence of DETR. In this paper, we use the Deformable DETR as our base detection transformer framework and integrate it with the recent vision transformers. + +DETR (ViT) is a straightforward integration of DETR and ViT, which uses ViT as a feature extractor, followed by the transformer encoder-decoder in DETR. As illustrated in Figure 2(a), it is a body–neck–head structure; the representation of input [PATCH] tokens are extracted by the ViT backbone and then directly fed to the transformer-based encoding and decoding pipeline. To predict multiple objects, a fixed number of learnable [DET] tokens are provided as additional input to the decoder. Subsequently, output embeddings by the decoder produce final predictions through the detection heads for classification and box regression. Since DETR (ViT) does not modify the backbone at all, it can be flexibly changed to any latest ViT model, e.g., Swin Transformer. Additionally, its neck decoder facilitates the aggregation of multi-scale features and the use of additional techniques, which help detect objects of different sizes and speed up training (Zhu et al., 2021). However, the attention operation at the neck encoder adds significant computational overhead to the detector. In contrast, ViDT resolves this issue by directly extracting fine-grained [DET] features from Swin Transformer with RAM without maintaining the transformer encoder in the neck architecture. + +YOLOS (Fang et al., 2021) is a canonical ViT architecture for object detection with minimal modifications. As illustrated in Figure 2(b), YOLOS achieves a neck-free structure by appending randomly initialized learnable [DET] tokens to the sequence of input [PATCH] tokens. Since all the embeddings for [PATCH] and [DET] tokens interact via global attention, the final [DET] tokens are generated by the fine-tuned ViT backbone and then directly generate predictions through the detection heads without requiring any neck layer. While the naive DETR (ViT) suffers from the computational overhead from the neck layer, YOLOS enjoys efficient computations by treating the [DET] tokens as additional input for ViT. YOLOS shows that 2D object detection can be accomplished in a pure sequence-to-sequence manner, but this solution entails two inherent limitations: + +1) YOLOS inherits the drawback of the canonical ViT; the high computational complexity attributed to the global attention operation. As illustrated in Figure 1, YOLOS shows very poor latency compared with other fully transformer-based detectors, especially when its model size becomes larger, i.e., small base. Thus, YOLOS is not scalable for the large model. 2) YOLOS cannot benefit from using additional techniques essential for better performance, e.g., multi-scale features, due to the absence of the neck layer. Although YOLOS used the same DeiT backbone with Deformable DETR (DeiT), its AP was lower than the straightforward integration. + +In contrast, the encoder-free neck architecture of ViDT enjoys the additional optimization techniques from Zhu et al. (2021), resulting in the faster convergence and the better performance. Further, our RAM enables to combine Swin Transformer and the sequence-to-sequence paradigm for detection. + +# 3 VIDT: VISION AND DETECTION TRANSFORMERS + +ViDT first reconfigures the attention model of Swin Transformer to support standalone object detection while fully reusing the parameters of Swin Transformer. Next, it incorporates an encoder-free neck layer to exploit multi-scale features and two essential techniques: auxiliary decoding loss and iterative box refinement. We further introduce knowledge distillation with token matching to benefit from large ViDT models. + +# 3.1 RECONFIGURED ATTENTION MODULE + +Applying patch reduction and local attention scheme of Swin Transformer to the sequence-tosequence paradigm is challenging because (1) the number of [DET] tokens must be maintained at a fixed-scale and (2) the lack of locality between [DET] tokens. To address this challenge, we introduce a reconfigured attention module (RAM)2 that decomposes a single global attention associated with [PATCH] and [DET] tokens into the three different attention, namely $\mathrm { \Delta \left[ P A T C H \right] \times \left[ P A T C H \right] }$ , [DET] × [DET], and $[ \mathrm { D E T } ] \times [ \mathrm { P A T C H } ]$ attention. Based on the decomposition, the efficient schemes of Swin Transformer are applied only to $\mathrm { \Delta \left[ P A T C H \right] \times \Delta \left[ P A T C H \right] }$ attention, which is the heaviest part in computational complexity, without breaking the two constraints on [DET] tokens. As illustrated in Figure 3, these modifications fully reuse all the parameters of Swin Transformer by sharing projection layers for [DET] and [PATCH] tokens, and perform the three different attention operations: + +![](images/bd29e6d21a76e855027a6673eeaa73de483b453e50afbe9f85867120dc343a1e.jpg) +Figure 3. Reconfigured Attention Module (Q: query, K: key, V: value). The skip connection and feedforward networks following the attention operation is omitted just for ease of exposition. + +$\mathrm { \Delta \left[ P A T C H \right] \times \left[ P A T C H \right] }$ Attention: The initial [PATCH] tokens are progressively calibrated across the attention layers such that they aggregate the key contents in the global feature map (i.e., spatial form of [PATCH] tokens) according to the attention weights, which are computed by hquery, keyi pairs. For $[ \mathrm { P A T C H } ] \times [ \mathrm { P A T C H } ]$ attention, Swin Transformer performs local attention on each window partition, but its shifted window partitioning in successive blocks bridges the windows of the preceding layer, providing connections among partitions to capture global information. Without modifying this concept, we use the same policy to generate hierarchical [PATCH] tokens. Thus, the number of [PATCH] tokens is reduced by a factor of 4 at each stage; the resolution of feature maps decreases from $H / 4 \times W / 4$ to $H / 3 2 \times W / 3 2$ over a total of four stages, where $H$ and $W$ denote the width and height of the input image, respectively. + +• $[ \mathsf { D E T } ] \times [ \mathsf { D E T } ]$ Attention: Like YOLOS, we append one hundred learnable [DET] tokens as the additional input to the [PATCH] tokens. As the number of [DET] tokens specifies the number of objects to detect, their number must be maintained with a fixed-scale over the transformer layers. In addition, [DET] tokens do not have any locality unlike the [PATCH] tokens. Hence, for $[ \mathsf { D E T } ] \times [ \mathsf { D E T } ]$ attention, we perform global self-attention while maintaining the number of them; this attention helps each [DET] token to localize a different object by capturing the relationship between them. + +• $[ \mathrm { D E T } ] \times \left[ \mathrm { P A T C H } \right]$ Attention: This is cross-attention between [DET] and [PATCH] tokens, which produces an object embedding per [DET] token. For each [DET] token, the key contents in [PATCH] tokens are aggregated to represent the target object. Since the [DET] tokens specify different objects, it produces different object embeddings for diverse objects in the image. Without the crossattention, it is infeasible to realize the standalone object detector. As shown in Figure 3, ViDT binds $[ \mathsf { D E T } ] \times [ \mathsf { D E T } ]$ and $[ \mathrm { D E T } ] \times [ \mathrm { P A T C H } ]$ attention to process them at once to increase efficiency. + +We replace all the attention modules in Swin Transformer with the proposed RAM, which receives [PATCH] and [DET] tokens (as shown in “Body” of Figure 2(c)) and then outputs their calibrated new tokens by performing the three different attention operations in parallel. + +Positional Encoding. ViDT adopts different positional encodings for different types of attention. For $\mathrm { [ P A T C H ] } \times \mathrm { [ P A T C H ] }$ attention, we use the relative position bias (Hu et al., 2019) originally used in Swin Transformer. In contrast, the learnable positional encoding is added for [DET] tokens for $[ \mathsf { D E T } ] \times [ \mathsf { D E T } ]$ attention because there is no particular order between [DET] tokens. However, for $[ \mathrm { D E T } ] \times \left[ \mathrm { P A T C H } \right]$ attention, it is crucial to inject spatial bias to the [PATCH] tokens due to the permutation-equivariant in transformers, ignoring spatial information of the feature map. Thus, ViDT adds the sinusoidalbased spatial positional encoding to the feature map, which is reconstructed from the [PATCH] tokens for $[ \mathrm { D E T } ] \times [ \mathrm { P A T C H } ]$ attention, as can be seen from the left side of Figure 3. We present a thorough analysis of various spatial positional encodings in Section 4.2.1. + +Use of $[ \mathrm { D E T } ] \times [ \mathrm { P A T C H } ]$ Attention. Applying cross-attention between [DET] and [PATCH] tokens adds additional computational overhead to Swin Transformer, especially when it is activated at the bottom layer due to the large number of [PATCH] tokens. To minimize such computational overhead, ViDT only activates the cross-attention at the last stage (the top level of the pyramid) of Swin Transformer, which consists of two transformer layers that receives [PATCH] tokens of size $H / 3 2 \times W / 3 2$ . + +Thus, only self-attention for [DET] and [PATCH] tokens are performed for the remaining stages except the last one. In Section 4.2.2 we show that this design choice helps achieve the highest FPS, while achieving similar detection performance as when cross-attention is enabled at every stage. We provide more details on RAM including its complexity analysis and algorithmic design in Appendix A. + +# 3.2 ENCODER-FREE NECK STRUCTURE + +To exploit multi-scale feature maps, ViDT incorporates a decoder of multi-layer deformable transformers (Zhu et al., 2021). In the DETR family (Figure 2(a)), a transformer encoder is required at the neck to transform features extracted from the backbone for image classification into the ones suitable for object detection; the encoder is generally computationally expensive since it involves $\mathrm { \Delta \left[ P A T C H \right] \times \Delta \left[ P A T C H \right] }$ attention. However, ViDT maintains only a transformer decoder as its neck, in that Swin Transformer with RAM directly extracts fine-grained features suitable for object detection as a standalone object detector. Thus, the neck structure of ViDT is computationally efficient. + +The decoder receives two inputs from Swin Transformer with RAM: (1) [PATCH] tokens generated from each stage (i.e., four multi-scale feature maps, $\{ { \pmb x } ^ { l } \} _ { l = 1 } ^ { L }$ where $L = 4$ ) and (2) [DET] tokens generated from the last stage. The overview is illustrated in “Neck” of Figure 2(c). In each deformable transformer layer, $[ \mathsf { D E T } ] \times [ \mathsf { D E T } ]$ attention is performed first. For each [DET] token, multi-scale deformable attention is applied to produce a new [DET] token, aggregating a small set of key contents sampled from the multi-scale feature maps $\{ \mathbf { } x ^ { l } \} _ { l = 1 } ^ { L }$ , + +$$ +\mathrm { M S D e f o r m A t t n } ( [ \mathbb { D } \mathbb { E } \mathbb { T } ] , \{ \pmb { x } ^ { l } \} _ { l = 1 } ^ { L } ) = \sum _ { m = 1 } ^ { M } { W _ { m } } \bigg [ \sum _ { l = 1 } ^ { L } \sum _ { k = 1 } ^ { K } A _ { m l k } \cdot { W _ { m } ^ { \prime } } { x } ^ { l } \big ( \phi _ { l } ( p ) + \Delta p _ { m l k } \big ) \bigg ] , +$$ + +where $m$ indices the attention head and $K$ is the total number of sampled keys for content aggregation. In addition, $\phi _ { l } ( \pmb { p } )$ is the reference point of the [DET] token re-scaled for the $l$ -th level feature map, while $\Delta p _ { m l k }$ is the sampling offset for deformable attention; and $A _ { m l k }$ is the attention weights of the $K$ sampled contents. $W _ { m }$ and $W _ { m } ^ { \prime }$ are the projection matrices for multi-head attention. + +Auxiliary Techniques for Additional Improvements. The decoder of ViDT follows the standard structure of multi-layer transformers, generating refined [DET] tokens at each layer. Hence, ViDT leverages the two auxiliary techniques used in (Deformable) DETR for additional improvements: + +• Auxiliary Decoding Loss: Detection heads consisting of two feedforward networks (FNNs) for box regression and classification are attached to every decoding layer. All the training losses from detection heads at different scales are added to train the model. This helps the model output the correct number of objects without non-maximum suppression (Carion et al., 2020). Iterative Box Refinement: Each decoding layer refines the bounding boxes based on predictions from the detection head in the previous layer. Therefore, the box regression process progressively improves through the decoding layers (Zhu et al., 2021). + +These two techniques are essential for transformer-based object detectors because they significantly enhance detection performance without compromising detection efficiency. We provide an ablation study of their effectiveness for object detection in Section 4.3.1. + +# 3.3 KNOWLEDGE DISTILLATION WITH TOKEN MATCHING FOR OBJECT DETECTION + +While a large model has a high capacity to achieve high performance, it can be computationally expensive for practical use. As such, we additionally present a simple knowledge distillation approach that can transfer knowledge from the large ViDT model by token matching. Based on the fact that all ViDT models has exactly the same number of [PATCH] and [DET] tokens regardless of their scale, a small ViDT model (a student model) can easily benefit from a pre-trained large ViDT (a teacher model) by matching its tokens with those of the large one, thereby bringing out higher detection performance at a lower computational cost. + +Matching all the tokens at every layer is very inefficient in training. Thus, we only match the tokens contributing the most to prediction. The two sets of tokens are directly related: $( 1 ) \mathcal { P }$ : the set of [PATCH] tokens used as multi-scale feature maps, which are generated from each stage in the body, and $( 2 ) D$ : the set of [DET] tokens, which are generated from each decoding layer in the neck. Accordingly, the distillation loss based on token matching is formulated by + +$$ +\ell _ { d i s } ( \mathcal { P } _ { s } , \mathcal { D } _ { s } , \mathcal { P } _ { t } , \mathcal { D } _ { t } ) = \lambda _ { d i s } \Big ( \frac { 1 } { | \mathcal { P } _ { s } | } \sum _ { i = 1 } ^ { | \mathcal { P } _ { s } | } \Big \| \mathcal { P } _ { s } [ i ] - \mathcal { P } _ { t } [ i ] \Big \| _ { 2 } + \frac { 1 } { | \mathcal { D } _ { s } | } \sum _ { i = 1 } ^ { | \mathcal { D } _ { s } | } \Big \| \mathcal { D } _ { s } [ i ] - \mathcal { D } _ { t } [ i ] \Big \| _ { 2 } \Big ) , +$$ + +
BackboneType (Size)Train DataEpochsResolutionParamsImageNet Acc.
DeiTDeiT-tiny ()DeiT-small()DeiT-base()ImageNet-1KImageNet-1KImageNet-1K3003003002242243846M22M87M74.581.285.2
SwinTransformerSwin-nanoSwin-tinySwin-smallSwin-baseImageNet-1KImageNet-1KImageNet-1KImageNet-22K300300300902242242242246M28M50M88M74.981.283.286.3
+ +Table 1. Summary on the ViT backbone. $\because \frac { \partial } { \partial x } ^ { , }$ is the distillation strategy for classification (Touvron et al., 2021). + +where the subscripts $s$ and $t$ refer to the student and teacher model. $\mathcal { P } [ i ]$ and $\mathcal { D } [ i ]$ return the $i$ -th [PATCH] and [DET] tokens, $n$ -dimensional vectors, belonging to $\mathcal { P }$ and $\mathcal { D }$ , respectively. $\lambda _ { d i s }$ is the coefficient to determine the strength of $\ell _ { d i s }$ , which is added to the detection loss if activated. + +# 4 EVALUATION + +In this section, we show that ViDT achieves the best trade-off between accuracy and speed (Section 4.1). Then, we conduct detailed ablation study of the reconfigured attention module (Section 4.2) and additional techniques to boost detection performance (Section 4.3). Finally, we provide a complete analysis of all components available for ViDT (Section 4.4). + +Dataset. We carry out object detection experiments on the Microsoft COCO 2017 benchmark dataset (Lin et al., 2014). All the fully transformer-based object detectors are trained on 118K training images and tested on 5K validation images following the literature (Carion et al., 2020). + +Algorithms. We compare ViDT with two existing fully transformer-based object detection pipelines, namely DETR (ViT) and YOLOS. Since DETR (ViT) follows the general pipeline of (Deformable) DETR by replacing its ResNet backbone with other ViT variants; hence, we use one canonical ViT and one latest ViT variant, DeiT and Swin Transformer, as its backbone without any modification. In contrast, YOLOS is the canonical ViT architecture, thus only DeiT is available. Table 1 summarizes all the ViT models pre-trained on ImageNet used for evaluation. Note that publicly available pretrained models are used except for Swin-nano. We newly configure Swin-nano3 comparable to DeiTtiny, which is trained on ImageNet with the identical setting. Overall, with respect to the number of parameters, Deit-tiny, -small, and -base are comparable to Swin-nano, -tiny, and -base, respectively. Please see Appendix B.2 for the detailed pipeline of compared detectors. + +Implementation Details. All the algorithms are implemented using PyTorch and executed using eight NVIDIA Tesla V100 GPUs. We train ViDT using AdamW (Loshchilov & Hutter, 2019) with the same initial learning rate of $1 0 ^ { - 4 }$ for its body, neck and head. In contrast, following the (Deformable) DETR setting, DETR (ViT) is trained with the initial learning rate of $1 0 ^ { - 5 }$ for its pretrained body (ViT backbone) and $1 0 ^ { - 4 }$ for its neck and head. YOLOS and ViDT (w.o. Neck) are trained with the same initial learning rate of $5 \times 1 0 ^ { - 5 }$ , which is the original setting of YOLOS for the neck-free detector. We do not change any hyperparameters used in transformer encoder and decoder for (Deformable) DETR; thus, the neck decoder of ViDT also consists of six deformable transformer layers using exactly the same hyperparameters. The only new hyperparameter introduced, the distillation coefficient $\lambda _ { d i s }$ in Eq. (2), is set to be 4. For fair comparison, knowledge distillation is not applied for ViDT in the main experiment in Section 4.1. The efficacy of knowledge distillation with token matching is verified independently in Section 4.3.2. Auxiliary decoding loss and iterative box refinement are applied to the compared methods if applicable. + +Regarding the resolution of input images, we use scale augmentation that resizes them such that the shortest side is at least 480 and at most 800 pixels while the longest at most 1333 (Wu et al., 2019). More details of the experiment configuration can be found in Appendix B.3–B.5. All the source code and trained models will be made available to the public at https://github.com/naver-ai/vidt. + +# 4.1 MAIN EXPERIMENTS WITH MICROSOFT COCO BENCHMARK + +Table 2 compares ViDT with DETR (ViT) and YOLOS w.r.t their AP, FPS, # parameters, where the two variants of DETR (ViT) are simply named DETR and Deformable DETR. We report the result of ViDT without using knowledge distillation for fair comparison. A summary plot is provided in Figure 1. The experimental comparisons with CNN backbones are provided in Appendix C.1. + +
MethodBackboneEpochsAPAP50AP75APsAPMAPLParam.FPS
DETRDeiT-tiny DeiT-small DeiT-base50 5030.0 32.449.2 52.530.5 33.29.930.850.624M10.9 (13.1)
11.333.553.739M7.8 (8.8)
5037.159.238.414.739.452.90.1B4.3(4.9)
Swin-nano 5027.847.527.49.029.244.924M24.7 (46.1)
Swin-tiny 5034.155.135.312.735.954.245M19.3 (28.1)
Swin-small 50 Swin-base37.659.039.015.940.158.966M13.5 (17.7)
Deformable DETR5040.762.942.718.344.162.40.1B9.7 (12.6)
DeiT-tiny DeiT-small50 5040.8 43.660.1 63.743.621.443.458.218M 35M12.4 (16.3)
DeiT-base5046.446.523.347.162.18.5 (10.2)
Swin-nano5043.167.3 61.449.4 46.326.750.165.40.1B4.4(5.3)
Swin-tiny5047.066.850.825.9 28.145.2 49.859.4 63.918M 39M7.0 (7.8)
Swin-small5049.068.952.930.352.866.660M6.3 (7.0) 5.5 (6.1)
YOLOSSwin-base5051.471.756.234.555.167.50.1B4.8 (5.4)
DeiT-tiny15030.448.631.112.431.848.26M28.1 (31.3)
DeiT-small15036.155.737.615.638.455.330M9.3 (11.8)
DeiT-base15042.062.244.519.545.362.10.1B3.9 (5.4)
ViDT (w.0. Neck)Swin-nano15028.748.628.512.330.744.17M36.5 (64.4)
Swin-tiny15036.356.337.816.439.054.329M28.6 (32.1)
Swin-small15041.662.743.920.145.459.852M16.8 (18.8)
Swin-base15043.264.245.921.946.963.291M11.5 (12.5)
ViDTSwin-nano5040.459.642.555.816M20.0 (45.8)
Swin-tiny5044.864.543.3 48.723.2 25.947.662.138M17.2 (26.5)
Swin-small5047.567.751.429.250.764.861M12.1 (16.5)
Swin-base5049.269.453.130.652.666.90.1B9.0 (11.6)
+ +Table 2. Comparison of ViDT with other compared detectors on COCO2017 val set. Two neck-free detectors, YOLOS and ViDT (w.o. Neck) are trained for 150 epochs due to the slow convergence. FPS is measured with batch size 1 of $8 0 0 \times 1 3 3 3$ resolution on a single Tesla V100 GPU, where the value inside the parentheses is measured with batch size 4 of the same resolution to maximize GPU utilization. + +Highlights. ViDT achieves the best trade-off between AP and FPS. With its high scalability, it performs well even for Swin-base of 0.1 billion parameters, which is $2 \mathbf { x }$ faster than Deformable DETR with similar AP. Besides, ViDT shows 40.4AP only with 16M parameters; it is 6.3–12.6AP higher than those of DETR (swin-nano) and DETR (swin-tiny), which exhibit similar FPS of 19.3–24.7. + +ViDT vs. Deformable DETR. Thanks to the use of multi-scale features, Deformable DETR exhibits high detection performance in general. Nevertheless, its encoder and decoder structure in the neck becomes a critical bottleneck in computation. In particular, the encoder with multi-layer deformable transformers adds considerable overhead to transform multi-scale features by attention. Thus, it shows very low FPS although it achieves higher AP with a relatively small number of parameters. In contrast, ViDT removes the need for a transformer encoder in the neck by using Swin Transformer with RAM as its body, directly extracting multi-scale features suitable for object detection. + +ViDT (w.o. Neck) vs. YOLOS. For the comparison with YOLOS, we train ViDT without using its neck component. These two neck-free detectors show relatively low AP compared with other detectors in general. In terms of speed, YOLOS exhibits much lower FPS than ViDT (w.o. Neck) because of its quadratic computational complexity for attention. However, ViDT (w.o. Neck) extends Swin Transformers with RAM, thus requiring linear complexity for attention. Hence, it shows AP comparable to YOLOS for various backbone size, but its FPS is much higher. + +One might argue that better integration could be also achieved by (1) Deformable DETR without its neck encoder because its neck decoder also has $[ \mathrm { D E T } ] \times [ \mathrm { P A T C H } ]$ cross-attention, or (2) YOLOS with VIDT’s neck decoder because of the use of multiple auxiliary techniques. Such integration is actually not effective; the former significantly drops AP, while the latter has a much greater drop in FPS than an increase in AP. The detailed analysis can be found in Appendix C.2. + +# 4.2 ABLATION STUDY ON RECONFIGURED ATTENTION MODULE (RAM) + +We extend Swin Transformer with RAM to extract fine-grained features for object detection without maintaining an additional transformer encoder in the neck. We provide an ablation study on the two main considerations for RAM, which leads to high accuracy and speed. To reduce the influence of secondary factors, we mainly use our neck-free version, ViDT (w.o. Neck), for the ablation study. + +# 4.2.1 SPATIAL POSITIONAL ENCODING + +Spatial positional encoding is essential for [DET] $\times$ [PATCH] attention in RAM. Typically, the spatial encoding can be added to the [PATCH] tokens before or after the projection layer in Figure 3. We call the former “pre-addition” and the latter “postaddition”. For each one, we can design the encoding in a sinusoidal or learnable manner (Carion et al., + +
MethodNonePre-additionPost-addition
TypeNoneSin.Learn.Sin.Learn.
AP23.728.727.428.024.1
+ +Table 3. Results for different spatial encodings for $[ \mathsf { D E T } ] \times [ \mathsf { P A T C H } ]$ cross-attention. + +2020). Table 3 contrasts the results with different spatial positional encodings with ViDT (w.o. Neck). Overall, pre-addition results in performance improvement higher than post-addition, and specifically, the sinusoidal encoding is better than the learnable one; thus, the 2D inductive bias of the sinusoidal spatial encoding is more helpful in object detection. In particular, pre-addition with the sinusoidal encoding increases AP by 5.0 compared to not using any encoding. + +# 4.2.2 SELECTIVE $[ \mathrm { D E T } ] \times [ \mathrm { P A T C H } ]$ CROSS-ATTENTION + +The addition of cross-attention to Swin Transformer inevitably entails computational overhead, particularly when the number of [PATCH] is large. To alleviate such overhead, we selectively enable cross-attention in RAM at the last stage of Swin Transformer; this is shown to greatly improve FPS, but barely drop AP. Table 4 summarizes AP and FPS when used different selective strategies for the cross-attention, where Swin Transformer consists of four stages in total. It is interesting that all the strategies exhibit similar AP as long as cross-attention is activated at the last stage. Since features are extracted in a bottom-up manner as they go through the stages, it seems difficult to directly obtain useful information about the target object at the low level of stages. Thus, only using the last stage is the best design choice in terms of high AP and FPS due to the smallest number of [PATCH] tokens. + +Meanwhile, the detection fails completely or the performance significantly drops if all the stages are not involved due to the lack of interaction between [DET] and [PATCH] tokens that spatial positional encoding is associated with. A more detailed analysis of the $[ \mathrm { D E T } ] \stackrel { \cdot } { \times } [ \mathrm { P A T C H } ]$ cross-attention and $[ \mathrm { D E T } ] \times [ \mathrm { D E T } ]$ self-attention is provided in appendices C.3 and C.4. + +
Stage Ids{1,2,3,4}{2,3,4}{3,4}{4}0
MetricAPFPSAPFPSAPFPSAPFPSAPFPS
w.o. Neck29.021.828.829.128.534.328.736.5FAIL37.7
w. Neck40.314.640.118.040.319.540.420.037.120.5
+ +Table 4. AP and FPS comparison with different selective cross-attention strategies. + +# 4.3 ABLATION STUDY ON ADDITIONAL TECHNIQUES + +We analyze the performance improvement of two additional techniques, namely auxiliary decoding loss and iterative box refinement, and the proposed distillation approach in Section 3.3. Furthermore, we introduce a simple technique that can expedite the inference speed of ViDT by dropping unnecessary decoding layers at inference time. + +# 4.3.1 AUXILIARY DECODING LOSS AND ITERATIVE BOX REFINEMENT + +To thoroughly verify the efficacy of auxiliary decoding loss and iterative box refinement, we extend them even for the neck-free detector like YOLOS; the principle of them is applied to the encoding layers in the body, as opposed to the conventional way of using the decoding layers in the neck. Table 5 shows the performance of the two neck-free detectors, YOLOS and ViDT (w.o. Neck), decreases considerably with the two techniques. The use of them in the encoding layers is likely to negatively affect feature extraction of the transformer encoder. In contrast, an opposite trend is observed with the neck component. Since the neck decoder is decoupled with the feature extraction in the body, the two techniques make a synergistic effect and thus show significant improvement in AP. These results justify the use of the neck decoder in ViDT to boost object detection performance. + +
Aux. l Box Ref.NeckAP
SOTOX<30.4 29.2 20.1-1.2 -10.3
广 √一 一28.7 27.2 22.9 36.2-1.6 -5.9 +7.4
√ 1140.4+11.6
+ +# 4.3.2 KNOWLEDGE DISTILLATION WITH TOKEN MATCHING + +We show that a small ViDT model can benefit from a large ViDT model via knowledge distillation. The proposed token matching is a new concept of knowledge distillation for object detection, especially for a fully transformer-based object detector. Compared to very complex distillation methods that rely on heuristic rules with multiple hyperparameters (Chen et al., 2017; Dai et al., 2021), it simply matches some tokens with + +
StudentViDT(Swin-nano)ViDT (Swin-tiny)
TeacherViDT ViDT (small) (base)ViDT ViDT (small) (base)
入dis=040.444.8
Xdis=241.4 41.445.6 46.1
Xdis=441.5 41.945.8 46.5
+ +Table 6. AP comparison of student models associated with different teacher models. + +a single hyperparameter, the distillation coefficient $\lambda _ { d i s }$ . Table 6 summarizes the AP improvement via knowledge distillation with token matching with varying distillation coefficients. Overall, the larger the size of the teacher model, the greater gain to the student model. Regarding coefficients, in general, larger values achieve better performance. Distillation increases AP by 1.0–1.7 without affecting the inference speed of the student model. + +# 4.3.3 DECODING LAYER DROP + +ViDT has six layers of transformers as its neck decoder. We emphasize that not all layers of the decoder are required at inference time for high performance. Table 7 show the performance of ViDT when dropping its decoding layer one by one from the top in the inference step. Although there is a trade-off relationship between accuracy and speed as the layers are detached from the model, there is no significant AP drop even when the two layers are removed. This technique is not designed for performance evaluation in Table 2 + +
Model MetricViDT(Swin-nano) AP Param.FPSAP Param.ViDT(Swin-tiny) FPS
0 Drop40.4 16M20.044.838M 17.2
1 Drop40.2 14M20.944.837M 18.5
2 Drop40.0 13M22.3 44.535M 19.6
3 Drop38.6 12M24.743.634M 21.0
4 Drop 5 Drop36.8 11M 32.526.0 10M 28.741.9 38.033M 22.4 32M 24.4
+ +Table 7. Performance trade-off by decoding layer drop regarding AP, Param, and FPS. + +with other methods, but we can accelerate the inference speed of a trained ViDT model to over $1 0 \%$ by dropping its two decoding layers without a much decrease in AP. + +# 4.4 COMPLETE COMPONENT ANALYSIS + +In this section, we combine all the proposed components (even with distillation and decoding layer drop) to achieve high accuracy and speed for object detection. As summarized in Table 8, there are four components: (1) RAM to extend Swin Transformer as a standalone object detector, (2) the neck decoder to exploit multi-scale features with two auxiliary techniques, (3) knowledge distillation to benefit from a large model, and (4) decoding layer drop to further accelerate inference speed. The performance of the final version is very outstanding; it achieves 41.7AP with reasonable FPS by only using 13M parameters when used Swin-nano as its backbone. Further, it only loses 2.7 FPS while exhibiting 46.4AP when used Swin-tiny. This indicates that a fully transformer-based object detector has the potential to be used as a generic object detector when further developed in the future. + +Table 8. Detailed component analysis with Swin-nano and Swin-tiny. + +
ComponentSwin-nano
#RAM Neck DistilDropAPAP50AP75Param.FPSAPAP50Swin-tiny AP75Param.FPS
(1)28.748.628.57M36.536.356.337.829M28.6
(240.459.643.316M20.044.864.548.738M17.2
341.961.145.016M20.046.566.350.238M17.2
(4)41.761.044.813M22.346.466.350.235M19.6
+ +# 5 CONCLUSION + +We have explored the integration of vision and detection transformers to build an effective and efficient object detector. The proposed ViDT significantly improves the scalability and flexibility of transformer models to achieve high accuracy and inference speed. The computational complexity of its attention modules is linear w.r.t. image size, and ViDT synergizes several essential techniques to boost the detection performance. On the Microsoft COCO benchmark, ViDT achieves 49.2AP with a large Swin-base backbone, and 41.7AP with the smallest Swin-nano backbone and only 13M parameters, suggesting the benefits of using transformers for complex computer vision tasks. + +# ETHICS STATEMENT + +This paper deals with the topic of general object detection in computer vision. We propose a novel integration of vision and detection transformers for a fully transformer-based object detector. Therefore, we do not expect any potential negative social impact of our work. + +# REPRODUCIBILITY STATEMENT + +For reproducibility, we provide a detailed description of our experiment and hyperparameter settings in Appendix B. It includes the Swin-nano architecture (Appendix B.1), the pipelines of all compared object detectors (Appendix B.2), hyperparameters of neck transformers (Appendix B.3), detailed implementation (Appendix B.4), and training configuration (Appendix B.5). We will release the code and trained models upon acceptance. + +# ACKNOWLEDGMENTS + +We thank NAVER AI Lab members for valuable discussion and advice. NAVER Smart Machine Learning (NSML) (Kim et al., 2018) has been used for experiment. M.-H. Yang is supported in part by the NSF CAREER grant 1149783. + +# REFERENCES + +Nicolas Carion, Francisco Massa, Gabriel Synnaeve, Nicolas Usunier, Alexander Kirillov, and Sergey Zagoruyko. End-to-end object detection with transformers. In ECCV, pp. 213–229, 2020. 1, 3, 5, 6, 8, 14, 15 + +Chun-Fu Chen, Quanfu Fan, and Rameswar Panda. CrossViT: Cross-attention multi-scale vision transformer for image classification. In ICCV, 2021. 13 + +Guobin Chen, Wongun Choi, Xiang Yu, Tony Han, and Manmohan Chandraker. Learning efficient object detection models with knowledge distillation. In NeurIPS, 2017. 9 + +Xing Dai, Zeren Jiang, Zhao Wu, Yiping Bao, Zhicheng Wang, Si Liu, and Erjin Zhou. General instance distillation for object detection. In CVPR, pp. 7842–7851, 2021. 9 + +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 ICLR, 2021. 1, 2 + +Yuxin Fang, Bencheng Liao, Xinggang Wang, Jiemin Fang, Jiyang Qi, Rui Wu, Jianwei Niu, and Wenyu Liu. You only look at one sequence: Rethinking transformer in vision through object detection. arXiv preprint arXiv:2106.00666, 2021. 2, 3, 14, 15 + +Byeongho Heo, Sangdoo Yun, Dongyoon Han, Sanghyuk Chun, Junsuk Choe, and Seong Joon Oh. Rethinking spatial dimensions of vision transformers. In ICCV, 2021. 2, 13 + +Han Hu, Zheng Zhang, Zhenda Xie, and Stephen Lin. Local relation networks for image recognition. In CVPR, pp. 3464–3473, 2019. 4 + +Hanjoo Kim, Minkyu Kim, Dongjoo Seo, Jinwoong Kim, Heungseok Park, Soeun Park, Hyunwoo Jo, KyungHyun Kim, Youngil Yang, Youngkwan Kim, et al. NSML: Meet the mlaas platform with a real-world case study. arXiv preprint arXiv:1810.09957, 2018. 10 + +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 ´ ECCV, pp. 740–755, 2014. 2, 6 + +Tsung-Yi Lin, Priya Goyal, Ross Girshick, Kaiming He, and Piotr Dollar. Focal loss for dense object ´ detection. In CVPR, pp. 2980–2988, 2017. 14 + +Li Liu, Wanli Ouyang, Xiaogang Wang, Paul Fieguth, Jie Chen, Xinwang Liu, and Matti Pietikainen. ¨ Deep learning for generic object detection: A survey. International Journal of Computer Vision, 128(2):261–318, 2020. 1 + +Ze Liu, Yutong Lin, Yue Cao, Han Hu, Yixuan Wei, Zheng Zhang, Stephen Lin, and Baining Guo. Swin Transformer: Hierarchical vision transformer using shifted windows. In ICCV, 2021. 2, 12 + +Ilya Loshchilov and Frank Hutter. Decoupled weight decay regularization. In ICLR, 2019. 6, 15 + +Constantine Papageorgiou and Tomaso Poggio. A trainable system for object detection. International Journal of Computer Vision, 38(1):15–33, 2000. 1 + +Shaoqing Ren, Kaiming He, Ross Girshick, and Jian Sun. Faster R-CNN: Towards real-time object detection with region proposal networks. NeurIPS, 28:91–99, 2015. 3 + +Hamid Rezatofighi, Nathan Tsoi, JunYoung Gwak, Amir Sadeghian, Ian Reid, and Silvio Savarese. Generalized intersection over union: A metric and a loss for bounding box regression. In CVPR, pp. 658–666, 2019. 14 + +Hugo Touvron, Matthieu Cord, Matthijs Douze, Francisco Massa, Alexandre Sablayrolles, and Herve J ´ egou. Training data-efficient image transformers & distillation through attention. In ´ ICML, pp. 10347–10357, 2021. 6 + +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, pp. 5998–6008, 2017. 1, 12, 17 + +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. In ICCV, 2021. 13 + +Yuxin Wu, Alexander Kirillov, Francisco Massa, Wan-Yen Lo, and Ross Girshick. Detectron2. https://github.com/facebookresearch/detectron2, 2019. 3, 6 + +Xizhou Zhu, Weijie Su, Lewei Lu, Bin Li, Xiaogang Wang, and Jifeng Dai. Deformable DETR: Deformable transformers for end-to-end object detection. In ICLR, 2021. 3, 5, 14, 15 + +# An Efficient and Effective Fully Transformer-based Object Detector (Supplementary Material) + +A RECONFIGURED ATTENTION MODULE + +The proposed RAM in Figure 3 performs three attention operations, namely $\mathrm { \Delta [ P A T C H ] \ \times \ [ P A T C H ] } .$ , $[ \mathrm { D E T } ] \times [ \mathrm { P A T C H } ]$ , and $[ \mathsf { D E T } ] \times [ \mathsf { D E T } ]$ attention. This section provides (1) computational complexity analysis and (2) further algorithmic design for [DET] tokens. + +# A.1 COMPUTATIONAL COMPLEXITY ANALYSIS + +We analyze the computational complexity of the proposed RAM compared with the attention used in YOLOS. The analysis is based on the computational complexity of basic building blocks for Canonical and Swin Transformer, which is summarized in Table $9 ^ { 4 }$ , where ${ \sf T } _ { 1 }$ and ${ \sf T } _ { 2 }$ is the number of tokens for self- and cross-attention, and $d$ is the embedding dimension. + +
TransformerCanonical TransformerSwin Transformer
AttentionGlobal Self-attention Global Cross-attentionLocal Self-attention
ComplexityO(d²T1 + dT²) O(d²(T1 +T2)+dT1T2)O(d²T1 + dk²T1)
+ +Table 9. Computational complexity of attention modules: In the canonical transformer, the complexity of global self-attention is $\mathcal { O } ( d ^ { 2 } \mathsf { T } _ { 1 } + \mathsf { \dot { d } } \mathsf { T } _ { 1 } ^ { 2 } )$ , where $\mathcal { O } ( d ^ { 2 } \mathsf { T } _ { 1 } )$ is the cost of computing the query, key, and value embeddings and $\mathcal { O } ( d \mathsf { T } _ { 1 } ^ { 2 } )$ is the cost of computing the attention weights. The complexity of global cross-attention is $\mathcal { O } ( \bar { d } ^ { 2 } ( \mathsf { T } _ { 1 } + \mathsf { T } _ { 2 } ) + d \mathsf { T } _ { 1 } \mathsf { T } _ { 2 } )$ , which is the interaction between the two different tokens ${ \sf T } _ { 1 }$ and ${ \mathsf { T } } _ { 2 }$ . In contrast, Swin Transformer achieves much lower attention complexity of $\mathcal { O } ( d ^ { 2 } \mathsf { T } _ { 1 } + d k ^ { 2 } \mathsf { T } _ { 1 } )$ with window partitioning, where $k$ is the width and height of the window $( k < < \mathsf { T } _ { 1 } , \mathsf { T } _ { 2 } )$ . + +Let $\mathsf { P }$ and $\mathsf { D }$ be the number of [PATCH] and [DET] tokens ( $\mathsf { D } < < \mathsf { P }$ in practice, e.g., $\mathsf { P } = 6 6 , 6 5 0$ and $\mathsf { D } = 1 0 0$ at the first stage of ViDT). Then, the computational complexity of the attention module for YOLOS and ViDT (RAM) is derived as below, also summarized in Table 10: + +• YOLOS Attention: [DET] tokens are simply appended to [PATCH] tokens to perform global selfattention on [PATCH, DET] tokens (i.e., ${ \sf T } _ { 1 } = { \sf P } + { \sf D } )$ . Thus, the computational complexity is $\mathcal { O } ( d ^ { 2 } ( \mathsf { P } + \mathsf { D } ) ^ { } + d ( \mathsf { P } + \bar { \mathsf { D } } ) ^ { 2 } )$ , which is quadratic to the number of [PATCH] tokens. If breaking down the total complexity, we obtain $\mathcal { O } \big ( ( d ^ { 2 } \mathsf { P } + d \mathsf { P } ^ { 2 } ) + ( d ^ { 2 } \mathsf { D } + d \mathsf { D } ^ { 2 } ) + d \mathsf { P } \mathsf { D } \big )$ , where the first and second terms are for the global self-attention for [PATCH] and [DET] tokens, respectively, and the last term is for the global cross-attention between them. + +• ViDT (RAM) Attention: RAM performs the three different attention operations: (1) $\left[ \mathrm { P A T C H } \right] \times$ [PATCH] local self-attention with window partition, $\mathcal { O } ( d ^ { 2 } \mathsf { P } + d k ^ { 2 } \mathsf { P } )$ ; (2) $[ \mathsf { D E T } ] \times [ \mathsf { D E T } ]$ global selfattention, $\mathcal { O } ( d ^ { 2 } \mathsf { D } + d \mathsf { D } ^ { 2 } )$ ; (3) $[ \mathrm { D E T } ] \times [ \mathrm { P A T C H } ]$ global cross-attention, $\bar { \mathcal { O } } ( d ^ { 2 } \bar { ( } \mathsf { D } \doteq \mathsf { P } ) \bar { + } d \mathsf { D } \mathsf { P } )$ . In total, the computational complexity of RAM is $\mathsf { \bar { O } } ( d ^ { 2 } ( \mathsf { D } + \mathsf { P } ) + d k ^ { 2 } \mathsf { P } + d \mathsf { D } ^ { 2 } + d \mathsf { D } \mathsf { P } )$ , which is linear to the number of [PATCH] tokens. + +Consequently, the complexity of RAM is much lower than the attention module used in YOLOS since $\mathsf { D } < < \mathsf { P }$ . Note that only RAM achieves the linear complexity to the patch tokens. In addition, one might argue that YOLOS can be efficient if the cross-attention is selectively removed similar to RAM. Even if we remove the complexity $\mathcal { O } ( d \mathsf { P } \mathsf { D } )$ for the global cross-attention, the computational complexity is $\mathcal { O } ( d ^ { 2 } ( \mathsf { P } + \mathsf { D } ) + d \mathsf { P } ^ { 2 } + d \mathsf { D } ^ { \bar { 2 } } )$ , which is still quadratic to the number of [PATCH] tokens. + +
Attention TypeYOLOSViDT
[PATCH] × [PATCH]O(d²P +dP²)O(d²P + dk²P)
[DET] × [DET]O(d²D +dD²)O(d²D + dD²)
[DET] × [PATCH]O(dPD)O(d²(D +P) + dDP)
Total ComplexityO(d²(P + D)+ d(P + D)²)O(d²(D+P)+dk²P+dD²+dDP)
+ +Table 10. Summary of computational complexity for different attention operations used in YOLOS and ViDT (RAM), where $\mathsf { P }$ and D are the number of [PATCH] and [DET] tokens, respectively $( \mathsf { D } < < \mathsf { P }$ ). + +# A.2 ALGORITHMIC DESIGN FOR [DET] TOKENS + +# A.2.1 BINDING $[ \mathsf { D E T } ] \times [ \mathsf { D E T } ]$ AND [DET] $\times$ [PATCH] ATTENTION + +Binding the two attention modules is very simple in implementation. $[ \mathsf { D E T } ] \times [ \mathsf { D E T } ]$ and $\left[ \tt D E T \right] \times$ [PATCH] attention is generating a new [DET] token, which aggregates relevant contents in [DET] and [PATCH] tokens, respectively. Since the two attention share exactly the same [DET] query embedding obtained after the projection as shown in Figure 3, they can be processed at once by performing the scaled-dot product between $[ \tt D E T ] _ { Q }$ and $\left[ ^ { - } [ \mathsf { D E T } ] _ { K } , [ \mathsf { P A T C H } ] _ { K } \right]$ embeddings, where $Q , K$ are the key and query, and $[ \cdot ]$ is the concatenation. Then, the obtained attention map is applied to the ${ \left[ \ [ \mathsf { D E T } ] _ { V } , \mathsf { [ P A T C H ] } _ { V } \right] }$ embeddings, where $V$ is the value and $d$ is the embedding dimension, + +$$ +\mathsf { \Gamma } [ \mathsf { D E T } ] _ { n e w } = \mathsf { S o f t m a x } \Big ( \frac { \bigl [ \mathsf { D E T } \bigr ] _ { Q } \left[ \bigl [ \mathsf { D E T } \bigr ] _ { K } , \bigl [ \mathsf { P A T C H } \bigr ] _ { K } \right] ^ { \top } } { \sqrt { d } } \big ) \left[ \bigl [ \mathsf { D E T } \bigr ] _ { V } , \bigl [ \mathsf { P A T C H } \bigr ] _ { V } \right] . +$$ + +This approach is commonly used in the recent Transformer-based architectures, such as YOLOS. + +# A.2.2 EMBEDDING DIMENSION OF [DET] TOKENS + +$[ \mathsf { D E T } ] \times [ \mathsf { D E T } ]$ attention is performed across all the stages, and the embedding dimension of [DET] tokens increases gradually like [PATCH] tokens. For the [PATCH] token, its embedding dimension is increased by concatenating nearby [PATCH] tokens in a grid. However, this mechanism is not applicable for [DET] tokens since we maintain the same number of [DET] tokens for detecting a fixed number of objects in a scene. Hence, we simply repeat a [DET] token multiple times along the embedding dimension to increase its size. This allows [DET] tokens to reuse all the projection and normalization layers in Swin Transformer without any modification. + +# B EXPERIMENTAL DETAILS + +# B.1 SWIN-NANO ARCHITECTURE + +Due to the absence of Swin models comparable to Deit-tiny, we configure Swin-nano, which is a $0 . 2 5 \times$ model of Swin-tiny such that it has 6M training parameters comparable to Deit-tiny. Table 11 summarizes the configuration of Swin Transformer models available, including the newly introduced Swinnano; S1–S4 indicates the four stages in Swin Transformer. The performance of all the pre-trained Swin + +
Model NameChannel Dim.Layer Numbers S2
Swin-nano48S1S3 6S4 2
Swin-tiny966
Swin-small12818
Swin-base192222218222
+ +Table 11. Swin Transformer Architecture. + +Transformer models are summarized in Table 1 in the manuscript. + +# B.2 DETECTION PIPELINES OF ALL COMPARED DETECTORS + +All the compared fully transformer-based detectors are composed of either (1) body–neck–head or (2) body–head structure, as summarized in Table 12. The main difference of ViDT is the use of reconfigured attention modules (RAM) for Swin Transformer, allowing the extraction of fine-grained detection features directly from the input image. Thus, Swin Transformer is extended to a standalone object detector called ViDT (w.o. Neck). Further, its extension to ViDT allows to use multi-scale features and multiple essential techniques for better detection, such as auxiliary decoding loss and iterative box refinement, by only maintaining a transformer decoder at the neck. Except for the two neck-free detector, YOLOS and ViDT (w.o. Neck), all the pipelines maintain multiple FFNs; that is, a single FFNs for each decoding layer at the neck for box regression and classification. + +We believe that our proposed RAM can be combined with even other latest efficient vision transformer architectures, such as PiT (Heo et al., 2021), PVT (Wang et al., 2021) and Cross-ViT (Chen et al., 2021). We leave this as future work. + +# B.3 HYPERPARAMETERS OF NECK TRANSFORMERS + +The transformer decoder at the neck in ViDT introduces multiple hyperparameters. We follow exactly the same setting used in Deformable DETR. Specifically, we use six layers of deformable transformers with width 256; thus, the channel dimension of the [PATCH] and [DET] tokens extracted from Swin Transformer are reduced to 256 to be utilized as compact inputs to the decoder transformer. For each transformer layer, multi-head attention with eight heads is applied, followed by the point-wise FFNs of 1024 hidden units. Furthermore, an additive dropout of 0.1 is applied before the layer normalization. All the weights in the decoder are initialized with Xavier initialization. For (Deformable) DETR, the tranformer decoder receives a fixed number of learnable detection tokens. We set the number of detection tokens to 100, which is the same number used for YOLOS and ViDT. + +
Pipeline Method NameBody Feature ExtractorNeck Tran. Encoder Tran. DecoderHead Prediction
DETR (DeiT) DETR (Swin)DeiT Transformer Swin Transformer8 8Multiple FFNs
Deformable DETR (DeiT)O+Multiple FFNs
DeiT TransformerO+Multiple FFNs
Deformable DETR (Swin)Swin Transformer0+ 0Multiple FFNs
YOLOSDeiT Transformer× ×Single FFNs
ViDT(w.o. Neck)Swin Transformer+RAM× ×Single FFNs
ViDTSwin Transformer+RAM× O+Multiple FFNs
+ +Table 12. Comparison of detection pipelines for all available fully transformer-based object detectors, where $\dagger$ indicates that multi-scale deformable attention is used for neck transformers. + +# B.4 IMPLEMENTATION + +# B.4.1 DETECTION HEAD FOR PREDICTION + +The last [DET] tokens produced by the body or neck are fed to a 3-layer FFNs for bounding box regression and linear projection for classification, + +$$ +\hat { B } = \mathrm { F F N } _ { \mathrm { 3 - l a y e r } } \left( \mathrm { [ D E T ] } \right) \ \mathrm { a n d } \ \hat { P } = \mathrm { L i n e a r } \big ( \mathrm { [ D E T ] } \big ) . +$$ + +For box regression, the FFNs produce the bounding box coordinates for $d$ objects, $\hat { B } \in [ 0 , 1 ] ^ { d \times 4 }$ , that encodes the normalized box center coordinates along with its width and height. For classification, the linear projection uses a softmax function to produce the classification probabilities for all possible classes including the background class, $\hat { P } \in \mathsf { \bar { [ 0 , 1 ] } } ^ { d \times ( c + 1 ) }$ , where $c$ is the number of object classes. When deformable attention is used on the neck in Table 12, only $c$ classes are considered without the background class for classification. This is the original setting used in DETR, YOLOS (Carion et al., 2020; Fang et al., 2021) and Deformable DETR (Zhu et al., 2021). + +# B.4.2 LOSS FUNCTION FOR TRAINING + +All the methods adopts the loss function of (Deformable) DETR. Since the detection head return a fixed-size set of $d$ bounding boxes, where $d$ is usually larger than the number of actual objects in an image, Hungarian matching is used to find a bipartite matching between the predicted box $\hat { B }$ and the ground-truth box $B$ . In total, there are three types of training loss: a classification loss $\ell _ { c l } { } ^ { 5 }$ , a box distance $\ell _ { l _ { 1 } }$ , and a GIoU loss $\ell _ { i o u }$ (Rezatofighi et al., 2019), + +$$ +\begin{array} { r l } & { \ell _ { c l } ( i ) = - \log \hat { P } _ { \sigma ( i ) , c _ { i } } , \ell _ { \ell _ { 1 } } ( i ) = | | B _ { i } - \hat { B } _ { \sigma ( i ) } | | _ { 1 } , \mathrm { ~ a n d ~ } } \\ & { \ell _ { i o u } ( i ) = 1 - \big ( \frac { | B _ { i } \cap \hat { B } _ { \sigma ( i ) } | } { | B _ { i } \cup \hat { B } _ { \sigma ( i ) } | } - \frac { | \mathsf { B } ( B _ { i } , \hat { B } _ { \sigma ( i ) } ) \backslash B _ { i } \cup \hat { B } _ { \sigma ( i ) } | } { | \mathsf { B } ( B _ { i } , \hat { B } _ { \sigma ( i ) } ) | } \big ) , } \end{array} +$$ + +where $c _ { i }$ and $\sigma ( i )$ are the target class label and bipartite assignment of the $i$ -th ground-truth box, and $\textsf { B }$ returns the largest box containing two given boxes. Thus, the final loss of object detection is a linear combination of the three types of training loss, + +$$ +\ell = \lambda _ { c l } \ell _ { c l } + \lambda _ { \ell _ { 1 } } \ell _ { l _ { 1 } } + \lambda _ { i o u } \ell _ { i o u } . +$$ + +Table 13. Evaluations of ViDT with other detectors using CNN backbones on COCO2017 val set. FPS is measured with batch size 1 of $8 0 0 \times 1 3 3 3$ resolution on a single Tesla V100 GPU, where the value inside the parentheses is measured with batch size 4 of the same resolution to maximize GPU utilization. + +
MethodBackboneEpochsAPAP50AP75APsAPMAPLParam.FPS
DETRResNet-5050042.062.444.220.545.861.141M22.8 (38.6)
DETR-DC5ResNet-5050043.363.145.922.547.361.141M12.8 (14.2)
DETR-DC5ResNet-505035.355.736.815.237.553.641M12.8 (14.2)
Deform.DETRResNet-505045.464.749.026.848.361.740M13.7 (19.4)
ViDTSwin-tiny5044.864.548.725.947.662.138M17.2 (26.5)
ViDTSwin-tiny15047.266.751.428.450.264.738M17.2 (26.5)
+ +
MethodBackboneAPAP50AP75APsAPMAPLParam.FPS
Deformable DETR - neck encoderSwin-nano43.1 34.061.4 52.846.3 35.625.9 18.045.2 36.359.4 48.417M 14M7.0 22.4
YOLOS + neck decoderDeiT-tiny30.4 38.148.6 57.131.1 40.212.4 20.131.8 40.248.2 56.06M 14M28.1 17.1
ViDT + neck encoderSwin-nano40.4 46.159.6 64.143.3 49.723.2 28.542.5 48.755.8 61.716M 19M20.0 6.3
+ +Table 14. Variations of Deformable DETR, YOLOS, and ViDT with respect to their neck structure. They are trained for 50 epochs with the same configuration used in our main experimental results. + +The coefficient for each training loss is set to be $\lambda _ { c l } = 1$ , $\lambda _ { \ell _ { 1 } } = 5$ , and $\lambda _ { i o u } = 2$ . If we leverage auxiliary decoding loss, the final loss is computed for every detection head separately and merged with equal importance. Additionally, ViDT adds the distillation loss in Eq. (2) to the final loss if the distillation approach in Section 3.3 is enabled for training. + +# B.5 TRAINING CONFIGURATION + +We train ViDT for 50 epochs using AdamW (Loshchilov & Hutter, 2019) with the same initial learning rate of $1 0 ^ { - 4 }$ for its body, neck and head. The learning rate is decayed by cosine annealing with batch size of 16, weight decay of $1 \times 1 0 ^ { - 4 }$ , and gradient clipping of 0.1. In contrast, ViDT (w.o. Neck) is trained for 150 epochs using AdamW with the initial learning rate of $5 \times 1 0 ^ { - 5 }$ by cosine annealing. The remaining configuration is the same as for ViDT. + +Regarding DETR (ViT), we follow the setting of Deformable DETR. Thus, all the variants of this pipeline are trained for 50 epochs with the initial learning rate of $1 0 ^ { - 5 }$ for its pre-trained body (ViT backbone) and $1 0 ^ { - 4 }$ for its neck and head. Their learning rates are decayed at the 40-th epoch by a factor of 0.1. Meanwhile, the results of YOLOS are borrowed from the original paper (Fang et al., 2021) except YOLOS (DeiT-tiny); since the result of YOLOS (DeiT-tiny) for $8 0 0 \times 1 3 3 3$ is not reported in the paper, we train it by following the training configuration suggested by authors. + +# C SUPPLEMENTARY EVALUATION + +# C.1 COMPARISON WITH OBJECT DETECTOR USING CNN BACKBONE + +We compare ViDT with (Deformable) DETR using the ResNet-50 backbone, as summarized in Table 13, where all the results except ViDT are borrowed from (Carion et al., 2020; Zhu et al., 2021), and DETR-DC5 is a modification of DETR to use a dilated convolution at the last stage in ResNet. For a fair comparison, we compare ViDT (Swin-tiny) with similar parameter numbers. In general, ViDT shows a better trade-off between AP and FPS even compared with (Deformable) DETR with the ResNet-50. Specifically, ViDT achieves FPS much higher than DETR-DC5 and Deformable DETR with competitive AP. Particularly when training ViDT for 150 epochs, ViDT outperforms other compared methods using the ResNet-50 backbone in terms of both AP and FPS. + +# C.2 VARIATIONS OF EXISTING PIPELINES + +We study more variations of existing detection methods by modifying their original pipelines in Table 12. Thus, we remove the neck encoder of Deformable DETR to increase its efficiency, while adding a neck decoder to YOLOS to leverage multi-scale features along with auxiliary decoding loss and iterative box refinement. Note that these modified versions follow exactly the same detection pipeline with ViDT, maintaining a encoder-free neck between their body and head. Table 14 summarizes the performance of all the variations in terms of AP, FPS, and the number of parameters. + +![](images/f8cb1404df19856bf94ecdc38a33397b3a30a2bdda796f329f109caaf7d52d9e.jpg) +Figure 4. Visualization of the attention map for cross-attention with ViDT (Swin-nano). + +Deformable DETR shows significant improvement in FPS $( + 1 4 . 4 )$ but its AP drops sharply $( - 9 . 1 )$ when its neck encoder is removed. Thus, it is difficult to obtain fine-grained object detection representation directly from the raw ViT backbone without using an additional neck encoder. However, ViDT compensates for the effect of the neck encoder by adding [DET] tokens into the body (backbone), thus successfully removing the computational bottleneck without compromising AP; it maintains 6.4 higher AP compared with the neck encoder-free Deformable DETR (the second row) while achieving similar FPS. This can be attributed to that RAM has a great contribution to the performance w.r.t AP and FPS, especially for the trade-off between them. + +YOLOS shows a significant gain in $\mathrm { A P } ( + 7 . 7 ) $ while losing FPS (−11.0) when the neck decoder is added. Unlike Deformable DETR, its AP significantly increases even without the neck encoder due to the use of a standalone object detector as its backbone (i.e., the modified DeiT in Figure 2(b)). However, its AP is lower than ViDT by 2.3AP. Even worse, it is not scalable for large models because of its quadratic computational cost for attention. Therefore, in the aspects of accuracy and speed, ViDT maintains its dominance compared with the two carefully tuned baselines. + +For a complete analysis, we additionally add a neck encoder to ViDT. The inference speed of ViDT degrades drastically by 13.7 because of the self-attention for multi-scale features at the neck encoder. However, it is interesting to see the improvement of AP by 5.7 while adding only 3M parameters; it is 3.0 higher even than Deformable DETR. This indicates that lowering the computational complexity of the encoder and thus increasing its utilization could be another possible direction for a fully transformer-based object detector. + +# C.3 $[ \mathrm { D E T } ] \times [ \mathrm { P A T C H } ]$ ATTENTION IN RAM + +In Section 4.2.2, it turns out that the cross-attention in RAM is only necessary at the last stage of Swin Transformer; all the different selective strategies show similar AP as long as cross-attention is activated at the last stage. Hence, we analyze the attention map obtained by the cross-attention in RAM. Figure 4 shows attention maps for the stages of Swin Transformer where cross-attention is utilized; it contrasts (a) ViDT with cross-attention at all stages and (b) ViDT with cross-attention at the last stage. Regardless of the use of cross-attention at the lower stage, it is noteworthy that the finally obtained attention map at the last stage is almost the same. In particular, the attention map at Stage 1–3 does not properly focus the features on the target object, which is framed by the bounding box. In addition, the attention weights (color intensity) at Stage 1–3 are much lower than those at Stage 4. Since features are extracted from a low level to a high level in a bottom-up manner as they go through the stages, it seems difficult to directly get information about the target object with such low-level features at the lower level of stages. Therefore, this analysis provides strong empirical evidence for the use of selective $\mathrm { [ D E T ] } \times \mathrm { [ P A T H ] }$ cross-attention. + +# C.4 $[ \mathrm { D E T } ] \times [ \mathrm { D E T } ]$ ATTENTION IN RAM + +Another possible consideration for ViDT is the use of $\left[ { \tt D E T } \right] ^ { - } \times \ \left[ { \tt D E T } \right]$ self-attention in RAM. We conduct an ablation study by removing the $[ \mathsf { D E T } ] \times [ \mathsf { D E T } ]$ attention one by one from the bottom stage, and summarize the results in Table 15. When all the $[ \mathrm { D E T } ] \times [ \mathrm { D E T } ]$ self-attention are removed, (5) the AP drops by 0.7, which is a meaningful performance degradation. On the other hand, as long as the selfattention is activated at the last two stages, (1) – (3) all the strategies exhibit similar AP. Therefore, only keeping $[ \mathsf { D E T } ] \times [ \mathsf { D E T } ]$ self-attention at the last two stages can further increase FPS $\left( + 0 . 2 \right)$ without degradation in AP. This observation could be used as another design choice for the AP and FPS trade-off. Therefore, we believe that $[ \mathsf { D E T } ] \times [ \mathsf { D E T } ]$ self-attention is meaningful to use in RAM. + +Table 15. AP and FPS comparison with different $[ \tt D E T ] \times [ \tt D E T ]$ self-attention strategies with ViDT. + +
#Stage IdSwin-nano
123 4APFPS
(1)√ √40.420.0
(2)√ √?40.320.1
(3)140.420.2
(4)40.120.3
(5)39.720.4
+ +# D PRELIMINARIES: TRANSFORMERS + +A transformer is a deep model that entirely relies on the self-attention mechanism for machine translation (Vaswani et al., 2017). In this section, we briefly revisit the standard form of the transformer. + +Single-head Attention. The basic building block of the transformer is a self-attention module, which generates a weighted sum of the values (contents), where the weight assigned to each value is the attention score computed by the scaled dot-product between its query and key. Let $W _ { Q }$ , $W _ { K }$ , and $W _ { V }$ be the learned projection matrices of the attention module, and then the output is generated by + +$$ +\operatorname { A t t e n t i o n } ( Z ) = \operatorname { s o f t m a x } \Bigl ( \frac { ( Z W _ { Q } ) ( Z W _ { K } ) ^ { \top } } { \sqrt { d } } \Bigr ) ( Z W _ { V } ) \in \mathbb { R } ^ { h w \times d } , +$$ + +Multi-head Attention. It is beneficial to maintain multiple heads such that they repeat the linear projection process $k$ times with different learned projection matrices. Let $W _ { Q _ { i } }$ , $W _ { K _ { i } }$ , and $W _ { V _ { i } }$ be the learned projection matrices of the $i$ -th attention head. Then, the output is generated by the concatenation of the results from all heads, + +$$ +\begin{array} { r l } & { \mathbf { M u l t i - H e a d } ( Z ) = [ \mathbf { A t t e n t i o n } _ { 1 } ( Z ) , \mathbf { A t t e n t i o n } _ { 2 } ( Z ) , \dots , \mathbf { A t t e n t i o n } _ { k } ( Z ) ] \in \mathbb { R } ^ { h w \times d } , } \\ & { \qquad \mathrm { w h e r e } ~ \forall _ { i } W _ { Q _ { i } } , W _ { K _ { i } } , W _ { V _ { i } } \in \mathbb { R } ^ { d \times ( d / k ) } . } \end{array} +$$ + +Typically, the dimension of each head is divided by the total number of heads. + +Feed-Forward Networks (FFNs). The output of the multi-head attention is fed to the point-wise FFNs, which performs the linear transformation for each position separately and identically to allow the model focusing on the contents of different representation subspaces. Here, the residual connec + +tion and layer normalization are applied before and after the FFNs. The final output is generated by + +where $H ^ { \prime } = \mathrm { F F N } ( H ^ { \prime \prime } )$ $\begin{array} { r } { \begin{array} { r l } & { H = \mathrm { L a y e r N o r m } ( \mathrm { D r o p o u t } ( H ^ { \prime } ) + H ^ { \prime \prime } ) , } \\ & { H ^ { \prime \prime } ) \mathrm { a n d } H ^ { \prime \prime } = \mathrm { L a y e r N o r m } ( \mathrm { D r o p o u t } ( \mathrm { M u l t i \mathrm { - } H e a d } ( Z ) ) + Z ) . } \end{array} } \end{array}$ + +Multi-Layer Transformers. The output of a previous layer is fed directly to the input of the next layer. Regarding the positional encoding, the same value is added to the input of each attention module for all layers. \ No newline at end of file diff --git a/md/dev/wYqLTy4wkor/wYqLTy4wkor.md b/md/dev/wYqLTy4wkor/wYqLTy4wkor.md new file mode 100644 index 0000000000000000000000000000000000000000..89726eee5ad3233ffa64b8f9e5e5c3554f7fb5ed --- /dev/null +++ b/md/dev/wYqLTy4wkor/wYqLTy4wkor.md @@ -0,0 +1,273 @@ +# GROUNDING ALEATORIC UNCERTAINTY IN UNSUPERVISED ENVIRONMENT DESIGN + +Anonymous authors Paper under double-blind review + +# ABSTRACT + +In reinforcement learning (RL), adaptive curricula have proven highly effective for learning policies that generalize well under a wide variety of changes to the environment. Recently, the framework of Unsupervised Environment Design (UED) generalized notions of curricula for RL in terms of generating entire environments, leading to the development of new methods with robust minimaxregret properties. However, in partially-observable or stochastic settings (those featuring aleatoric uncertainty), optimal policies may depend on the groundtruth distribution over the aleatoric features of the environment. Such settings are potentially problematic for curriculum learning, which necessarily shifts the environment distribution used during training with respect to the fixed groundtruth distribution in the intended deployment environment. We formalize this phenomenon as curriculum-induced covariate shift, and describe how, when the distribution shift occurs over such aleatoric environment parameters, it can lead to learning suboptimal policies. We then propose a method which, given black-box access to a simulator, corrects this resultant bias by aligning the advantage estimates to the ground-truth distribution over aleatoric parameters. This approach leads to a minimax-regret UED method, SAMPLR, with Bayes-optimal guarantees. + +# 1 INTRODUCTION + +Adaptive curricula, which dynamically adjust the distribution of training environments to optimize the performance of the resulting policy, have played a key role in many recent achievements in deep reinforcement learning (RL). Applications have spanned both single-agent RL (Portelas et al., 2020; Wang et al., 2019; Zhong et al., 2020; Justesen et al., 2018), where adaptation occurs over environment variations, and multi-agent RL (MARL), where adaptation can additionally occur over co-players (Silver et al., 2016; Vinyals et al., 2019; Stooke et al., 2021). By presenting the agent with challenges at the threshold of its abilities, such methods demonstrably improve the sample efficiency and the generality of the final policy (Matiisen et al., 2017; Dennis et al., 2020; Jiang et al., 2021b;a). + +This work introduces a fundamental problem relevant to adaptive curriculum learning methods for RL, which we call curriculum-induced covariate shift (CICS). Analogous to the covariate shift that occurs in supervised learning (SL), CICS refers to a mismatch between the input distribution at training and test time, and in this case, specifically when the distribution shift is caused by the selective sampling performed by an adaptive curriculum. While there may be cases in which CICS impacts model performance in SL, adaptive curricula for SL have generally not been found to be as impactful as in RL (Wu et al., 2021). Therefore, here we focus on addressing this problem specifically as it arises in the RL setting, and leave investigation of its potential impact in SL to future work. + +To establish precise language around adaptive curricula, we cast our discussion under the lens of Unsupervised Environment Design (UED, Dennis et al., 2020). UED provides a formal problem description for which curriculum learning is the solution, by defining the Underspecified POMDP (UPOMDP; see Section 2), which expands the classic POMDP with a set of free parameters $\Theta$ , representing the dimensions along which the environment may vary across episodes. The goal of UED is then to adapt distributions over $\Theta$ , so to maximize some objective, which could be tied to an RL agent’s performance over this distribution. This allows us to view adaptive curricula as emerging via a multi-agent game between a teacher that proposes environments with parameters $\theta \sim \Theta$ and a student that learns to solve them. In addition to the notational clarity it provides, this formalism lends the analysis of adaptive curricula to useful game theoretic constructs, such as Nash equilibria (NE, Nash et al., 1950). + +![](images/80f8a0269d13b24c9d874710957ba3f421688417eb5cf584d9837b0677b95eb0.jpg) +Figure 1: Adaptive curricula can result in covariate shifts in environment parameters with respect to a fixed ground-truth distribution ${ \overline { { P } } } ( \theta )$ (see top path), e.g. whether apple or banana is the correct fruit to choose per level. Here, the policy $\pi _ { > }$ $( \pi _ { \mathcal { J } } )$ always chooses apple (banana). Our method, SAMPLR (bottom path) matches the advantages in sampled levels to the advantages observed if sampling levels from ${ \overline { { P } } } ( \theta )$ (blue triangles), thus constraining the optimal policy under the curriculum distribution $P ( \theta )$ to match that under ${ \overline { { P } } } ( \theta )$ . + +This game-theoretic view has led to the development of curriculum methods with principled robustness guarantees, such as PAIRED (Dennis et al., 2020) and Prioritized Level Replay (PLR, Jiang et al., 2021a), which showed that curricula optimizing for the student’s regret lead to minimax regret (Savage, 1951) policies at Nash equilibria, implying the agent can solve all solvable environments within the training domain. While other methods can also be cast in this framework, they do not hold the same desirable property at equilibrium. For this reason, we will focus on addressing CICS for regret-maximizing UED, but note that our solution can be used with other UED methods. + +To see how the CICS can be problematic, consider the simplified case of training a self-driving car in simulation, so it learns to take the fastest route from home to office. Suppose traffic data shows on $70 \%$ of the days, Route 1 is faster than Route 2. Moreover, on any given day the self-driving car cannot infer which route is faster ahead of time, so always picking Route 1 is faster in expectation. To support training a policy using an adaptive curriculum, one could build a simulator which sets road conditions per episode based on a random day sampled from the traffic data. However, adaptive curriculum over the traffic settings may oversample days when Route 1 is closed—perhaps because it finds the agent needs more practice on Route 2—shifting the best choice to Route 2 in training. In fact, methods for minimax regret UED like PLR would keep shifting the distribution of fastest route, to maximize the agent’s regret. Their curriculum dynamics would map to the zero-sum game of matching pennies, in which one player wins for guessing whether the other chose heads or tails; the NE corresponds to each player randomly playing each option half the time. Randomly picking the route in this way is suboptimal, because in reality Route 1 is faster in expectation. This example is depicted in Figure 1, where the two routes are replaced by an apple and banana. + +If, on a given day, the faster route could be identified before having to pick one, the agent could choose optimally. Instead, it is an aleatoric parameter, inducing irreducible uncertainty in the limit of infinite experiential data (Der Kiureghian & Ditlevsen, 2009). When CICS occurs over such parameters, with respect to a ground-truth distribution of environments $\overline { { P } } ( \boldsymbol { \theta } )$ , the learned policy can be suboptimal with respect to $\overline { { P } }$ . It can therefore be useful to ground—that is, to constrain—the aleatoric parameters $\Theta ^ { \prime } \subset \Theta$ to $\overline { { P } } ( \theta ^ { \prime } )$ when it is known or can be learned, as in simulation or from real-world data. However, grounding all $\theta$ is undesirable, preventing the curriculum from sampling enough opportunities to learn from useful scenarios with low support under ${ \overline { { P } } } ( \theta )$ . + +In this work, we formalize the problem of CICS in RL, and provide a solution by proposing a UED method to find robustly Bayes-optimal policies where $\theta ^ { \prime }$ is grounded to $\overline { { P } } ( \theta ^ { \prime } )$ . Our solution called Sample-Matched PLR (SAMPLR) extends PLR, a state-of-the-art UED algorithm, by constraining the advantage estimates to match those observed if training under $\overline { { P } } ( \theta ^ { \prime } )$ . This advantage correction adapts Off-Belief Learning (Hu et al., 2021) from cooperative MARL, revealing an intriguing connection between curriculum biases observed in single and multi-agent RL. Our experiments in challenging environments based on the NetHack Learning Environment (NLE, Küttler et al., 2020) demonstrate that SAMPLR learns near-optimal policies under CICS, in cases where standard PLR fails. + +# 2 BACKGROUND + +# 2.1 UNSUPERVISED ENVIRONMENT DESIGN + +The problem of Unsupervised Environment Design (UED, Dennis et al. (2020)) is the problem of automatically generating an adaptive distribution of environments which will lead to policies that successfully transfer within a target domain. The domain of possible environments is represented by an Underspecified POMDP (UPOMDP), which adds a set of free parameters to the standard definition of a POMDP, along which each concrete instantiation, or level, of the UPOMDP. For instance, these free parameters can be the position of obstacles in a maze, or friction coefficients in a physics-based task. Formally a UPOMDP is defined as a tuple $\mathcal { M } = \langle A , O , \Theta , S , T , \mathcal { I } , \mathcal { R } , \gamma \rangle$ , where $A$ is a set of actions, $O$ is a set of observations, $\Theta$ is a set of free parameters, $S$ is a set of states, $\mathcal { T } : S \times A \times \Theta \to \Delta ( S )$ is a transition function, $\mathcal { T } : S O$ is an observation (or inspection) function, $\mathcal { R } : S \mathbb { R }$ is a reward function, and $\gamma$ is a discount factor. UED typically approaches the curriculum design problem as training a teacher agent that co-evolves an adversarial curriculum for a student agent, for example, by maximizing the student’s regret. + +We will focus on a recent UED algorithm called Robust Prioritized Level Replay $( { \mathrm { P L R } } ^ { \perp }$ , Jiang et al., 2021b), which performs environment design via random search. PLR maintains a buffer of the most useful levels for training, according to some learning potential score—typically based on a regret approximation, such as the positive value loss—and with probability $p$ , actively samples the next training level from this level buffer instead of the ground-truth training distribution. This selective-sampling mechanism has been demonstrated to greatly improve sample-efficiency and generalization in several domains, while provably leading to a minimax regret policy for the student at NE. In maximizing regret, PLR curricula naturally avoid unsolvable levels, which have no regret. + +# 2.2 OFF-BELIEF LEARNING + +In cooperative MARL, self-play promotes the formation of cryptic conventions—arbitrary sequences of actions that allow agents to communicate information about the environment state. These conventions are learned jointly among all agents during training, but are arbitrary and hence, indecipherable to independently-trained agents or humans at test time. Crucially, this leads to policies that fail to perform zero-shot coordination (ZSC, Hu et al., 2020), where independentlytrained agents must cooperate successfully without additional learning steps, or ad-hoc team play. Off-Belief Learning (OBL) resolves this problem by forcing agents to assume their co-players act according to a fixed, known policy $\pi _ { 0 }$ until the current time $t$ , and optimally afterwards, conditioned on this assumption. If $\pi _ { 0 }$ is playing uniformly random, this removes the possibility of forming arbitrary conventions. + +Formally, let $G$ be a decentralized, partially-observable MDP (Dec-POMDP, Bernstein et al., 2002), with state $s$ , joint action $a$ , observation function ${ \mathcal { T } } ^ { i } ( s )$ for each player $i$ , and transition function ${ \mathcal { T } } ( s , a )$ . Let the historical trajectory $\tau = ( s _ { 1 } , a _ { 1 } , . . . a _ { t - 1 } , s _ { t } )$ , and the action-observation history (AOH) for agent $i$ be $\tau ^ { i } = ( \mathcal { T } ^ { i } ( s _ { 1 } ) , a _ { 1 } , . . . , a _ { t - 1 } , \mathcal { T } ^ { i } ( s _ { t } ) )$ . Further, let $\pi _ { 0 }$ be an arbitrary policy, such as a uniformly random policy, and $B _ { \pi _ { 0 } } ( \tau | \tau ^ { i } ) = P ( \tau _ { t } | \tau _ { t } ^ { i } , \pi _ { 0 } )$ , a belief model predicting the current state, conditioned on the AOH of agent $i$ and the assumption of co-players playing policy $\pi _ { 0 }$ until the current time $t$ , and optimally according to $\pi _ { 1 }$ from $t$ and beyond. OBL aims to find the policy $\pi _ { 1 }$ with the optimal, counter-factual value function, + +$$ +V ^ { \pi _ { 0 } \pi _ { 1 } } ( \tau ^ { i } ) = \mathbb { E } _ { \tau \sim \mathcal { B } _ { \pi _ { 0 } } ( \tau ^ { i } ) } [ V ^ { \pi _ { 1 } } ( \tau ) ] . +$$ + +As the agent conditions its policy on the realized $\operatorname { A O H } \tau ^ { i }$ , while transition dynamics are based on states sampled from $\boldsymbol { B }$ , this mechanism is called a fictitious transition. In Section 5, we show how OBL’s fictitious transition can be adapted to the single-agent curriculum learning setting to address CICS, by interpreting the curriculum designer in UED as a co-player. + +# 3 RELATED WORK + +The mismatch between training and testing distributions of input features is referred to as covariate shift, and has long served as a fundamental problem for the machine learning community. Covariate shifts have been extensively studied in supervised learning (Vapnik & Chervonenkis, 1971; Huang et al., 2006; Bickel et al., 2009; Arjovsky et al., 2019). In RL, prior works have largely focused on covariate shifts due to training on off-policy data (Sutton et al., 2016; Rowland et al., 2020; Espeholt et al., 2018; Hallak & Mannor, 2017; Gelada & Bellemare, 2019; Thomas & Brunskill, 2016) including the important case of learning from demonstrations (Pomerleau, 1988; Ross & Bagnell, 2010). Recent work also aims to learn invariant representations robust to covariate shifts (Zhang et al., 2019; 2021). More generally, CICS can be interpreted as a kind of sample-selection bias (Heckman, 1979). We believe this work to be the first to formalize and provide a solution to the problem of covariate shifts in reinforcement learning due to curriculum learning. + +Our method fixes a critical flaw that can cause curricula to fail under CICS—an important problem as curricula have been shown to be essential for training RL agents across many of the most challenging domains, including combinatorial gridworlds (Zhong et al., 2020), Go (Silver et al., 2016), StarCraft 2 (Vinyals et al., 2019), and achieving comprehensive task mastery in open-ended environments (Stooke et al., 2021). While this work focuses on PLR, other recent methods include minimax adversarial curricula (Wang et al., 2019; 2020) and curricula based on changes in return (Matiisen et al., 2017; Portelas et al., 2020). Most similar to our work, OFFER (Ciosek & Whiteson, 2017) adapts a curriculum over transition functions and uses importance sampling to correct for biased gradient estimates. Unlike this work, Ciosek & Whiteson (2017) requires whitebox access to the transition function and does not directly study the impact of CICS on the learning dynamics. Curriculum methods have also been studied in goal-conditioned RL (Florensa et al., 2018; Campero et al., 2021; Sukhbaatar et al., 2018; OpenAI et al., 2021), though CICS does not occur here as goals are observed by the agent. Lastly, domain randomization (DR, Sadeghi & Levine, 2017; Peng et al., 2017) can be seen as a degenerate form of UED, though curriculum-based extensions of DR have also been studied (Jakobi, 1997; Tobin et al., 2017). + +Prior work has also investigated methods for learning Bayes optimal policies under uncertainty about the task (Zintgraf et al., 2020; Osband et al., 2013), based on the framework of Bayes-adaptive MDPs (BAMDPs) (Bellman, 1956; Duff, 2002). In this setting, the agent can adapt to an unknown MDP over several episodes by acting to reduce its uncertainty about the identity of the MDP. In contrast, SAMPLR learns a robustly Bayes optimal policy for the case of zero-shot transfer. Further unlike these works, our setting assumes the distribution of certain aleatoric parameters are biased during training, which would lead to biased a posteriori uncertainty estimates with respect to the ground-truth distribution when optimizing for the BAMDP objective. Instead, SAMPLR proposes a means to correct for this bias assuming knowledge of the true environment parameters for each level, to which we can safely assume access in curriculum learning. + +# 4 CURRICULUM-INDUCED COVARIATE SHIFT + +As UED algorithms formulate curriculum learning as a multi-agent game between teacher and student agents, we can formalize when CICS become problematic by considering the equilibrium point of this game: Let $\theta$ be the environment parameters controlled by UED, $\overline { { P } } ( \boldsymbol { \theta } )$ , the ground truth distribution of $\theta$ , and $P ( \theta )$ , the curriculum distribution at equilibrium. Further, let $\tau _ { t }$ be $\mathbf { \bar { \rho } } ( o _ { 1 } , a _ { 1 } , . . . , a _ { t - 1 } , o _ { t } )$ , the student agent’s action-observation history (AOH) until time $t$ (though we will use simply $\tau$ when clear from context). The optimal action-value function $Q ^ { * }$ with respect to ${ \overline { { P } } } ( \theta )$ can then be expressed as a marginalization over $\theta$ : + +$$ +\begin{array} { r l } & { \overline { { \boldsymbol { Q } } } ^ { * } ( \boldsymbol { a } _ { t } | \tau _ { t } ) = \underbrace { \mathbb { E } \tau _ { t + 1 : \infty } } _ { \approx \pi ^ { * } } \left[ \displaystyle \sum _ { l = 0 } ^ { \infty } \gamma ^ { l } \boldsymbol { r } _ { t + l } \right] = \displaystyle \sum _ { \theta } \overline { { P } } ( \theta | \tau _ { t } ) \overline { { Q } } _ { \overline { { P } } } ^ { * } ( \boldsymbol { a } _ { t } | \tau _ { t } , \theta ) } \\ & { \qquad \propto \displaystyle \sum _ { \theta } \overline { { P } } ( \theta ) \overline { { P } } ( \tau _ { t } | \theta ) \overline { { Q } } _ { \overline { { P } } } ^ { * } ( \boldsymbol { a } _ { t } | \tau _ { t } , \theta ) . } \end{array} +$$ + +From Equation 2, we see that $\overline { { Q } } ^ { * } ( a _ { t } | \tau _ { t } )$ remains optimal under different values of ${ \overline { { P } } } ( \theta )$ at each time $t$ as long as it is possible to infer $\theta$ deterministically from $\tau _ { t }$ , implying that $\overline { { P } } ( \theta ^ { \prime } | \tau _ { t } ) = 1$ for some $\theta$ , in which case the RHS of Equation 1 reduces to the LHS. If $\overline { { P } } ( \theta | \tau _ { t } ) < 1$ for all $\theta$ , then some subset $\theta ^ { \prime } \subset \Theta$ results in irreducible uncertainty at time $t$ , thereby constituting aleatoric parameters. Letting $Q ^ { * } ( a _ { t } | \tau _ { t } )$ be the optimal action-value function when $\overline { { P } } ( \overline { { \theta } } )$ is replaced with $P ( \theta )$ in Equation 2, we can then state that curriculum-induced covariate shift results in suboptimal policies with respect to the ground truth distribution when + +![](images/41d9cd52cadf7ce416ac03ff9c317a1e153aad4fb7cefe7f7b7526cf377496c1.jpg) +Figure 2: A standard RL transition (left) and the fictitious transition used by SAMPLR (right). + +$$ +\arg \operatorname* { m a x } _ { a } Q ^ { * } ( a | \tau _ { t } ) \neq \arg \operatorname* { m a x } _ { a } \overline { { Q } } ^ { * } ( a | \tau _ { t } ) . +$$ + +Moreover, this formulation highlights how this effect results from the presence of aleatoric parameters. + +This description categorizes errors made by a policy trained on $P$ evaluated on levels drawn from ${ \overline { { P } } } ( \theta )$ into two categories: The first type of error, which we call a mistake, simply arises when $P ( \theta ^ { \prime \prime } ) = \dot { 0 }$ for some non-aleatoric $\theta ^ { \prime \prime }$ where $\overline { { P } } ( \theta ^ { \prime \prime } ) > 0$ , i.e. the policy did not train on trajectories needed to learn to behave optimally under some set of otherwise identifiable level parameters. This is distinct from the second kind of error, which we call a misunderstanding, and which corresponds to the problematic mismatch between training and test time distributions of specifically aleatoric parameters $\theta ^ { \prime }$ , so that $P ( \theta ^ { \prime } ) \neq \overline { { P } } ( \theta ^ { \prime } )$ , as we just previously characterized. + +This taxonomy also clarifies errors in cooperative MARL, where the co-players shape environment interactions, and thus play a similar role to the UED teacher. Failures in ZSC can then be diagnosed as due to (i) a mistake, because the co-players fail to generate trajectories that occur with test-time co-players; or (ii), a misunderstanding, because the train-time co-players shift the training distribution of aleatoric parameters $P ( \theta ^ { \prime } )$ , which impacts the inference of $\begin{array} { r } { \overline { { P } } \dot { ( \tau ) } = \sum _ { \theta ^ { \prime } } \overline { { P } } ( \theta ^ { \prime } ) \overline { { P } } ( \tau | \theta ^ { \prime } ) } \end{array}$ needed for optimal cooperation—for example, through the use of cryptic conventions. This view then connects generalization errors in cooperative MARL to those in single-agent RL, implying that methods like OBL devised to solve one type of error in one of the settings may be adapted for the other. Indeed, we now describe our method, which does exactly this: By adapting OBL to single-agent curriculum learning, we can ground the values of $\overline { { P } } ( \theta ^ { \prime } | \tau _ { t } )$ by forcing $P ( { \hat { \theta } } ^ { \prime } ) = \overline { { P } } ( \theta ^ { \prime } )$ , thereby ensuring that the distribution of the aleatoric parameters at equilibrium is equivalent to their ground truth distribution. + +# 5 SAMPLE-MATCHED PLR (SAMPLR) + +We now describe how OBL’s fictitious transition can be adapted for $\mathrm { \bf P I R ^ { \perp } }$ (Jiang et al., 2021a) to address CICS, resulting in Sample-Matched PLR (SAMPLR). To avoid CICS, we must ground $\theta ^ { \prime }$ to the ground-truth distribution $\overline { { P } } ( \theta ^ { \prime } )$ , while allowing the remaining parameters in $\Theta$ to vary under UED, so as to still benefit from a curriculum. To achieve this, we adapt the fictitious transition to single-agent curriculum learning by treating the UED teacher as a co-player—one that performs the single action of choosing the level $\theta$ at the start of each episode, and subsequently performs no-ops. Under this fictitious transition, we ground the teacher’s choice of $\theta$ such that the aleatoric parameters $\theta ^ { \prime }$ are assumed to be sampled from ${ \overline { { P } } } ( \theta )$ . + +Thus, at each time $t$ , the agent takes actions $a _ { t }$ based on its AOH as usual, but estimates the advantage $A ( a _ { t } , s _ { t } )$ using fictitious transitions, which assume subsequent state transitions and rewards occur with $\Theta ^ { \prime }$ fixed to $\theta ^ { \prime } \sim \overline { { P } } ( \theta ^ { \prime } )$ , sampled at the start of the episode. More formally, the fictitious transition is performed as $s _ { t } ^ { \prime } \sim \dot { B } ( \dot { s } _ { t } ^ { \prime } | \tau )$ , $\bar { a } _ { t } \sim \pi ( \cdot | \tau )$ , $s _ { t + 1 } ^ { \prime } = \dot { \mathcal T } ( s _ { t } ^ { \prime } , a _ { t } )$ , and $r _ { t } ^ { \prime } = \dot { \mathcal { R } } ( s _ { t + 1 } )$ , where $\tau$ is the + +Algorithm 1: Sample-Matched PLR (SAMPLR) + +
Randomly initialize policyπ(Φ),an empty level buffer Λof size K,and belief model B(st|T). while not converged do Sample replay-decision Bernoulli,d~ PD(d)
if d=O or|A|=O then
Sample level θ from level generator
Collect π's trajectory T on θ, with a stop-gradient Φ⊥
Use observed ground-truth states to update B
else
Use PLR to sample a replay level from the level store,θ ~ Λ
Collect fictitious trajectory T' on 0,based on s't ~ B
Update π with rewards R(T')
end
Compute PLR score, S = score(T',π)
Update Λ with θ using score S end
+ +AOH of the student. Figure 2 summarizes this transition mechanism. Here, the belief model $\boldsymbol { B } ( \boldsymbol { s } _ { t } | \tau )$ can be expressed as + +$$ +B ( s _ { t } | \tau ) = \sum _ { \theta ^ { \prime } } \overline { { P } } ( s _ { t } | \tau , \theta ^ { \prime } ) \overline { { P } } ( \theta ^ { \prime } | \tau ) . +$$ + +This shows that, assuming blackbox simulator access, we can generally implement $\boldsymbol { B }$ as follows: Periwith $\theta ^ { \prime } \sim \overline { { P } } ( \theta ^ { \prime } )$ ring training, . We use these $\{ ( \theta _ { k } ^ { \prime } , \tau _ { k } ) \} _ { k = 1 } ^ { N }$ $N$ trajectories, such that each is gepairs to update a posterior model ${ \overline { { P } } } ( \theta ^ { \prime } | \tau )$ under a level that predicts the underlying $\theta ^ { \prime }$ given $\tau$ . We can then sample from by first sampling $\theta \sim \overline { { P } } ( \theta ^ { \prime } | \tau )$ , followed by stepping forward a parallel simulator that has been initially reset to the current AOH $\tau$ , with fixed $\Theta ^ { \prime } = \theta ^ { \prime }$ , thereby yielding a desired sample of $s _ { t }$ according to $\boldsymbol { B }$ . + +In practice, it is often the case that $\theta ^ { \prime }$ can be uniquely identified by some revelatory event by time $t$ , so that $\overline { { { \cal P } } } ( \theta ^ { \prime } | \tau ) = 1$ for some $\theta ^ { \prime }$ and $\tau$ , and $\overline { { P } } ( s _ { t } | \tau , \mathbf { \dot { \theta } } ^ { \prime } ) = \overline { { P } } ( s _ { t } | \check { \tau } )$ otherwise. In this case, we can implement the fictitious transition by setting $\theta ^ { \prime } \sim \overline { { P } } ( \theta ^ { \prime } )$ at the start of each episode; subsequent transitions will then be consistent with $\boldsymbol { B }$ . For example, in the fruit choice example, whether apple or banana was the right goal is deterministically revealed by the final reward, and otherwise, does not impact transition dynamics. Additionally, we often only have limited access to $\overline { { P } } ( \theta )$ throughout training, for example, if sampling ${ \overline { { P } } } ( \theta )$ is costly. In this case, we can learn an estimate $\hat { P } ( \theta ^ { \prime } )$ using the samples we do collect from ${ \overline { { P } } } ( \theta )$ , which can occur online. We then use $\hat { P } ( \theta ^ { \prime } )$ in sampling fictitious transitions during UED. We refer to the resulting $\hat { P } ( \theta ^ { \prime } )$ as a learned belief prior. + +SAMPLR, summarized in Algorithm 1, incorporates this fictitious transition by replacing the advantages of trajectories on replay levels sampled by $\mathrm { P L R ^ { \perp } }$ with their fictitious counterparts, as only these trajectories are used by $\mathrm { P L R ^ { \perp } }$ for training. To reduce the cost of sampling $\overline { { { \cal P } } } ( \theta ^ { \prime } )$ , we can use the new levels regularly sampled by $\mathrm { P L R ^ { \perp } }$ to estimate the learned belief prior $\overline { { P } } ( \theta ^ { \prime } )$ , and use $\overline { { P } } ( \theta ^ { \prime } )$ in sampling fictitious transitions on replay levels. + +# 6 GROUNDED POLICIES ARE ROBUSTLY BAYES OPTIMAL + +We can view OBL-based correction as a method for training a policy to be optimal with respect to the ground-truth value function, with levels sampled from some generating distribution $\Lambda$ defined as: + +$$ +\overline { { { V } } } ^ { \Lambda } ( \pi ) = \mathbb { E } _ { \tau \sim { \mathcal { M } } ^ { \Lambda } ( \pi ) } \left[ \overline { { { V } } } ^ { \pi } ( \tau ) \right] . +$$ + +Note that when $\Lambda = \overline { { { \cal P } } } ( \theta )$ this reduces to the ground-truth value function notated simply as $\overline { { V } } ( \pi )$ . First, we will note that, for any UED method, our OBL-based correction will ensure that, in equilibrium, the resulting policy is Bayes-optimal on the ground truth beliefs, on any trajectory sampled from $\mathcal { M } ^ { \Lambda } ( \pi )$ , the distribution of trajectories of $\pi$ in levels sampled from $\Lambda$ . + +Remark 1. If π is optimal with respect to the grounded value function $\overline { { V } } ^ { \Lambda } ( \pi )$ then it is Bayes optimal with respect to the ground-truth parameter distribution ${ \overline { { P } } } ( \theta )$ on the support of $\mathcal { M } ^ { \Lambda } ( \pi )$ . + +Proof. By definition we have that $\pi \in \underset { \pi \in \Pi } { \arg \operatorname* { m a x } } \{ \overline { { V } } ^ { \Lambda } ( \pi ) \} = \underset { \pi \in \Pi } { \arg \operatorname* { m a x } } \big \{ \mathbb { E } _ { \tau \sim \mathcal { M } ^ { \Lambda } ( \pi ) } \left[ \overline { { V } } ^ { \pi } ( \tau ) \right] \big \}$ . Since $\pi$ can condition on the initial trajectory $\tau$ , the action selected after each trajectory can be independently optimized. Thus we have, for all $\tau \in \mathcal { M } ^ { \Lambda } ( \pi )$ , $\pi \in \arg \operatorname* { m a x } _ { \pi \in \Pi } \{ { \overline { { V } } } ^ { \pi } ( \tau ) \}$ implying that $\pi$ is the optimal grounded policy and V π = V ∗. + +Thus, assuming the base RL algorithm finds Bayes optimal policies, a UED method that optimizes the grounded value function, as done by SAMPLR, will result in Bayes optimal performance over the ground-truth distribution. When the UED method aims to maximize worst-case regret, we can prove an even stronger property we call robust $\epsilon$ -Bayes optimality. + +Let $\overline { { V } } ^ { \theta } ( \pi )$ be the value function for $\pi$ evaluated on a specific level $\theta$ . We will say that a policy is robustly $\epsilon$ -Bayes optimal iff for all $\theta$ in the domain of ${ \overline { { P } } } ( \theta )$ and for all $\pi ^ { \prime }$ we have + +$$ +\overline { { { V } } } ^ { \theta } ( \pi ) \geq \overline { { { V } } } ^ { \theta } ( \pi ^ { \prime } ) - \epsilon . +$$ + +Note how this differs from being only $\epsilon$ -Bayes optimal, which means for all $\pi ^ { \prime }$ , + +$$ +\overline { { { V } } } ( \pi ) \geq \overline { { { V } } } ( \pi ^ { \prime } ) - \epsilon +$$ + +With robust $\epsilon$ -Bayes optimality, we must be $\epsilon$ -optimal even on levels which are rarely sampled from the ground-truth distribution. We will show that if SAMPLR is in an $\epsilon$ -Nash Equilibrium, then a policy is robustly $\epsilon$ -Bayes optimal with respect to the grounded value function $\overline { { { V } } } ( \dot { \pi } )$ rather than only $\epsilon$ -Bayes optimal as one would expect from training directly on the true distribution of levels. + +Theorem 1. If $\pi$ is $\epsilon$ -Bayes optimal by $\overline { { V } } ^ { \Lambda } ( \pi )$ for $\Lambda$ minimizing worst-case regret as is done in SAMPLR, then it is robustly $\epsilon$ -Bayes optimal with respect to the grounded value function, $\overline { { V } } ( \pi )$ . + +Proof. Let $\pi$ be $\epsilon$ -optimal with respect to $\overline { { V } } ^ { \Lambda } ( \pi )$ where $\Lambda$ minimizing worst-case regret with respect to $\pi$ . Let $\overline { { \pi } } ^ { * }$ be an optimal grounded policy, and let $\theta$ be arbitrary. Then we have: + +$$ +\overline { { { V } } } ^ { \theta } ( \overline { { { \pi } } } ^ { * } ) - \overline { { { V } } } ^ { \theta } ( \pi ) \le \overline { { { V } } } ^ { \Lambda } ( \overline { { { \pi } } } ^ { * } ) - \overline { { { V } } } ^ { \Lambda } ( \pi ) \le \epsilon +$$ + +Where the first inequality follows from $\Lambda$ minimizing worst-case regret with respect to $\pi$ , and the second follows from $\pi$ being $\epsilon$ -optimal on $\Lambda$ . Rearranging terms gives the desired condition. □ + +# 7 EXPERIMENTS + +We investigate the performance of SAMPLR with respect to the the standard PLR and domain randomization in environments based on MiniHack (Samvelyan et al., 2021), a library for creating custom environments based on the runtime of the NetHack Learning Environment (NLE) (Küttler et al., 2020). Acting optimally in our environments requires grounding to the ground-truth distribution. + +Our agents are trained using PPO (Schulman et al., 2017), using the best hyperparameters found via grid search, and use the policy architecture in Küttler et al. (2020). We tune the PLR-specific hyperparameters shared among $\mathrm { \dot { P L } } \mathrm { \mathbf { R } } ^ { \perp }$ and SAMPLR variants for each environment, based on the performance of $\mathrm { \bf P } \mathrm { \bf L } { \bf R } ^ { \perp }$ . Full details of our environments, agent architecture, and hyperparameters are provided in Appendix A, and our SAMPLR implementation, in Appendix B. We compare both standard SAMPLR and a variant called LP-SAMPLR that learns a belief prior over the true goal, against $\mathrm { P L R ^ { \perp } }$ and standard PPO baselines. These baselines allows us to separate the relative changes in performance metrics due to curriculum learning and our proposed correction for CICS. + +![](images/5a0ad8437b53763848c849d01d988bfe750885e8df97170c00e1a06794f23227.jpg) +Figure 4: Episodic returns (left) and number of rooms in solved levels (middle) during training (dotted lines) and test on the ground-truth distribution (solid lines), for $q = 0 . 7$ . Normalized test returns and proportion of apple goals during training for various $q$ are shown on the right. Plots show mean and standard error of 10 runs. + +In our experiments, we first adapt the apple and banana example, depicted in Figure 3 into a fully procedurally-generated RL environment set in the world of NetHack. For each level, the agent can only learn to choose optimally in expectation at test time by grounding to the distribution of correct choices in the deployment domain. Specifically, in each level, the agent must traverse between one to eight randomly generated rooms, and in the final room, the agent must choose to eat the apple or the banana. The correct choice is fixed for each level, but indiscernible to the agent. Thus, the identity of the true goal acts as the aleatoric parameter. Figure 3 shows example levels from this environment. + +This environment presents a hard exploration challenge for standard RL algorithms, as it requires learning to both navigate multiple rooms, as well as the NLE-specific skills of kicking doors and eating. The doors opening into adjacent rooms are locked. In order to go from one room to the next, the agent must learn to, potentially repeatedly, kick the locked door until it opens. Likewise, upon reaching a piece of fruit in the final room, the agent must learn to deliberately choose to eat the fruit. If the right choice of fruit were determinable per episode, we expect $\mathrm { P L R ^ { \perp } }$ ’s adaptive curriculum to improve learning by selectively sampling levels at the threshold of the agent’s abilities. + +Let $\pi _ { A }$ be the policy in which the agent always chooses the apple, and $\pi _ { B }$ , the banana. If the probability of the goal being apple ${ \overline { { P } } } ( A ) = q$ , the expected return of the agent is $R _ { A } q$ under $\pi _ { A }$ and $R _ { B } ( 1 - q )$ under $\pi _ { B }$ . The optimal policy is then to act according to $\pi _ { A }$ when $q > R _ { B } / ( R _ { A } \bar { + } R _ { B } ) \bar { }$ , and according to $\pi _ { B }$ otherwise. We expect training under domain randomization, which samples each level completely at random from the ground-truth distribution ${ \overline { { P } } } ( \theta )$ , defined by the environment parameterization, would converge to the correct choice of $\pi _ { A }$ or $\pi _ { B }$ , assuming the environment is learnable by the choice of RL algorithm. In contrast, PLR evolves an adversarial curriculum, incentivizing PLR to shift the distribution over goals throughout training. For example, PLR is incentivized to flip the curriculum distribution to favor eating apples whenever the agent begins to consistently succeed at eating bananas. We thus expect the PLR curriculum to continually oscillate the preferred choice of goal. + +![](images/6181ee162b5a26f1daf84e32660b3dcfcc8a720ba04615e65a12a27521f7d96d.jpg) +Figure 3: Levels from the stochastic fruit-choice environment. Across levels, the correct choice of fruit is distributed according to $\overline { { P } }$ . + +In our experiments, we set $R _ { A } = 3$ , $R _ { B } = 1 0$ , and $q$ in $\{ 0 . 7 , 0 . 5 , 0 . 3 \}$ , making it always optimal to follow the banana-eating policy $\pi _ { B }$ , but with the marginal benefit of doing so varying with $q$ . We report train and test performance of each agent over 200M training steps in Figure 4. We find that DR struggles to learn an effective policy, plateauing at an expected return under 1.0; PLR performs even worse, due to its adversarial curriculum shifting the distribution over the correct goal, leading to rapid oscillations in the optimal choice of fruit under the curriculum distribution, as visible in the high-variance oscillations in the proportion of apple goals selected by PLR for each value of $q$ in 4). This makes it difficult for the agent to settle on the optimal policy with respect to any ground-truth distribution. The proportion of each choice outcome, shown in Figure 5, reveals that both DR and PLR policies fail to eat any fruit most of the time, even after 200M training steps. In contrast, both SAMPLR and LP-SAMPLR realize a marked improvement in test performance by grounding PLR’s otherwise wild shifts in $q$ . Figure 4 shows this improvement is most pronounced when the expected difference in $\pi _ { A }$ and $\pi _ { B }$ is smaller, and therefore easier for PLR to flip the agent’s policy. Moreover, we see in Figure 5 that both SAMPLR methods present levels with higher room counts on average, indicating that early in training, it is able to discover easier, few-room levels in which the agent can capture reward signal, and which can then be made more complex to push the agent along its threshold of abilities. + +![](images/bb074562b692232a71fe532a4bd2cb72fc0fdf886ff185d9a66a6e10c0f927f5.jpg) +Figure 5: Left: Proportion of training episodes in which the agent fails to eat any fruit; eats the apple; or eats the banana. Right: Number of rooms in levels during training. Plots show mean and standard error of 10 runs. + +![](images/c3d162499e62d97abe7c7aea447c6c9920b7223e54da8bfbf1cb81ae34902839.jpg) +Figure 6: Left: Levels from FireDungeon. Middle: Test return on the ground-truth distribution of FireDungeon. Right: Proportion of training levels with fireproof armor. Plots show mean and standard error of 10 runs. + +We next turn to a more challenging environment that introduces additional NetHack-specific dynamics. The FireDungeon environment (see Figure 6 for example levels), requires the agent to navigate through up to 13 chambers, and ultimately choose between chamber A or B, each containing a valid goal. Reaching this goal ends the episode and provides the agent with a sparse reward. Further, in this penultimate chamber, there is an armor, which if worn grants the agent with fire resistance with probability $q$ . Chamber B is marked by a red gemstone by the door and contains enemy units, whose fire attack will instantly kill the agent. Killing each enemy grants the agent with $+ 1$ final reward, which is only provided upon reaching either goal. The agent thus stands to attain a higher reward by attacking the enemies in Chamber B, before reaching the goal, only if the armor is fireproof. This environment presents an even more difficult exploration problem for the agent, yet we see in Figure 6, both SAMPLR variants begin to learn to solve this environment with significantly greater sample-efficiency than DR, while PLR again struggles to learn. As in the case of the previous stochastic choice environment, we see that PLR rapidly oscillates the key aleatoric parameter, which in this case, determines whether the armor is fireproof. + +# 8 CONCLUSION + +Using the formal notions of environment parameterizations in the framework of UED, we defined the problem of curriculum-induced covariate shift in RL. Our definition highlights the issues that can arise when there is persisitent uncertainty over the environment parameters, either because the uncertainty is irreducible or because reducing the uncertainty is costly. We then adapted a fictitious transition mechanism previously used to improve zero-shot coordination in cooperative MARL to correct for this covariate shift. We demonstrated that our resulting algorithm, SAMPLR, avoids the pitfalls of this type of covariate shift, while preserving the benefits of curriculum learning. + +# REFERENCES + +Martín Arjovsky, Léon Bottou, Ishaan Gulrajani, and David Lopez-Paz. Invariant risk minimization. CoRR, abs/1907.02893, 2019. URL http://arxiv.org/abs/1907.02893. + +Richard Bellman. A problem in the sequential design of experiments. Sankhya: The Indian Journal ¯ of Statistics (1933-1960), 16(3/4):221–229, 1956. + +Daniel S Bernstein, Robert Givan, Neil Immerman, and Shlomo Zilberstein. The complexity of decentralized control of markov decision processes. Mathematics of operations research, 27(4): 819–840, 2002. + +Steffen Bickel, Michael Brückner, and Tobias Scheffer. Discriminative learning under covariate shift. J. Mach. Learn. Res., 10:2137–2155, 2009. URL https://dl.acm.org/citation.cfm? id=1755858. + +Andres Campero, Roberta Raileanu, Heinrich Kuttler, Joshua B. Tenenbaum, Tim Rocktäschel, and Edward Grefenstette. Learning with AMIGo: Adversarially motivated intrinsic goals. In International Conference on Learning Representations, 2021. + +Kamil Andrzej Ciosek and Shimon Whiteson. OFFER: off-environment reinforcement learning. In Satinder P. Singh and Shaul Markovitch (eds.), Proceedings of the Thirty-First AAAI Conference on Artificial Intelligence, February 4-9, 2017, San Francisco, California, USA, pp. 1819–1825. AAAI Press, 2017. URL http://aaai.org/ocs/index.php/AAAI/AAAI17/paper/ view/14378. + +Michael Dennis, Natasha Jaques, Eugene Vinitsky, Alexandre Bayen, Stuart Russell, Andrew Critch, and Sergey Levine. Emergent complexity and zero-shot transfer via unsupervised environment design. In Advances in Neural Information Processing Systems, volume 33, 2020. + +Armen Der Kiureghian and Ove Ditlevsen. Aleatory or epistemic? does it matter? Structural safety, 31(2):105–112, 2009. + +Michael O’Gordon Duff. Optimal Learning: Computational procedures for Bayes-adaptive Markov decision processes. University of Massachusetts Amherst, 2002. + +Lasse Espeholt, Hubert Soyer, Remi Munos, Karen Simonyan, Vlad Mnih, Tom Ward, Yotam Doron, Vlad Firoiu, Tim Harley, Iain Dunning, Shane Legg, and Koray Kavukcuoglu. IMPALA: Scalable distributed deep-RL with importance weighted actor-learner architectures. 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. 1407–1416. PMLR, 10–15 Jul 2018. + +Carlos Florensa, David Held, Xinyang Geng, and Pieter Abbeel. Automatic goal generation for reinforcement learning agents. 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. 1515–1528. PMLR, 10–15 Jul 2018. URL http://proceedings. mlr.press/v80/florensa18a.html. + +Carles Gelada and Marc G. Bellemare. Off-policy deep reinforcement learning by bootstrapping the covariate shift. In The Thirty-Third AAAI Conference on Artificial Intelligence, AAAI 2019, The Thirty-First Innovative Applications of Artificial Intelligence Conference, IAAI 2019, The Ninth AAAI Symposium on Educational Advances in Artificial Intelligence, EAAI 2019, Honolulu, Hawaii, USA, January 27 - February 1, 2019, pp. 3647–3655. AAAI Press, 2019. URL https: //doi.org/10.1609/aaai.v33i01.33013647. + +Assaf Hallak and Shie Mannor. Consistent on-line off-policy evaluation. In Doina Precup and Yee Whye Teh (eds.), Proceedings of the 34th International Conference on Machine Learning, volume 70 of Proceedings of Machine Learning Research, pp. 1372–1383. PMLR, 06–11 Aug 2017. URL https://proceedings.mlr.press/v70/hallak17a.html. + +James J Heckman. Sample selection bias as a specification error. Econometrica: Journal of the econometric society, pp. 153–161, 1979. + +Hengyuan Hu, Adam Lerer, Alex Peysakhovich, and Jakob Foerster. “Other-play” for zero-shot coordination. In Hal Daumé III and Aarti Singh (eds.), Proceedings of the 37th International Conference on Machine Learning, volume 119 of Proceedings of Machine Learning Research, pp. 4399–4410. PMLR, 13–18 Jul 2020. URL https://proceedings.mlr.press/v119/ hu20a.html. + +Hengyuan Hu, Adam Lerer, Brandon Cui, Luis Pineda, Noam Brown, and Jakob N. Foerster. Offbelief learning. 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. 4369–4379. PMLR, 2021. URL http: //proceedings.mlr.press/v139/hu21c.html. + +Jiayuan Huang, Arthur Gretton, Karsten Borgwardt, Bernhard Schölkopf, and Alex Smola. Correcting sample selection bias by unlabeled data. Advances in neural information processing systems, 19: 601–608, 2006. + +Nick Jakobi. Evolutionary robotics and the radical envelope-of-noise hypothesis. Adaptive Behavior, 6(2):325–368, 1997. + +Minqi Jiang, Michael Dennis, Jack Parker-Holder, Jakob Foerster, Edward Grefenstette, and Tim Rocktäschel. Replay guided adversarial environment design. arXiv, 2021a. + +Minqi Jiang, Edward Grefenstette, and Tim Rocktäschel. Prioritized level replay. In 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. 4940–4950. PMLR, 2021b. URL http://proceedings.mlr.press/v139/jiang21b.html. + +Niels Justesen, Ruben Rodriguez Torrado, Philip Bontrager, Ahmed Khalifa, Julian Togelius, and Sebastian Risi. Procedural level generation improves generality of deep reinforcement learning. CoRR, abs/1806.10729, 2018. URL http://arxiv.org/abs/1806.10729. + +Heinrich Küttler, Nantas Nardelli, Alexander H. Miller, Roberta Raileanu, Marco Selvatici, Edward Grefenstette, and Tim Rocktäschel. The NetHack Learning Environment. In Proceedings of the Conference on Neural Information Processing Systems (NeurIPS), 2020. + +Tambet Matiisen, Avital Oliver, Taco Cohen, and John Schulman. Teacher-student curriculum learning. IEEE Transactions on Neural Networks and Learning Systems, PP, 07 2017. + +John F Nash et al. Equilibrium points in n-person games. Proceedings of the national academy of sciences, 36(1):48–49, 1950. + +OpenAI OpenAI, Matthias Plappert, Raul Sampedro, Tao Xu, Ilge Akkaya, Vineet Kosaraju, Peter Welinder, Ruben D’Sa, Arthur Petron, Henrique Ponde de Oliveira Pinto, Alex Paino, Hyeonwoo Noh, Lilian Weng, Qiming Yuan, Casey Chu, and Wojciech Zaremba. Asymmetric self-play for automatic goal discovery in robotic manipulation, 2021. + +Ian Osband, Daniel Russo, and Benjamin Van Roy. (more) efficient reinforcement learning via posterior sampling. In Christopher J. C. Burges, Léon Bottou, Zoubin Ghahramani, and Kilian Q. Weinberger (eds.), Advances in Neural Information Processing Systems 26: 27th Annual Conference on Neural Information Processing Systems 2013. Proceedings of a meeting held December 5-8, 2013, Lake Tahoe, Nevada, United States, pp. 3003–3011, 2013. URL https://proceedings.neurips.cc/paper/2013/hash/ 6a5889bb0190d0211a991f47bb19a777-Abstract.html. + +Xue Bin Peng, Marcin Andrychowicz, Wojciech Zaremba, and Pieter Abbeel. Sim-to-real transfer of robotic control with dynamics randomization. CoRR, abs/1710.06537, 2017. + +Dean Pomerleau. ALVINN: an autonomous land vehicle in a neural network. In David S. Touretzky (ed.), Advances in Neural Information Processing Systems 1, [NIPS Conference, Denver, Colorado, USA, 1988], pp. 305–313. Morgan Kaufmann, 1988. URL http://papers.nips.cc/ paper/95-alvinn-an-autonomous-land-vehicle-in-a-neural-network. + +Rémy Portelas, Cédric Colas, Katja Hofmann, and Pierre-Yves Oudeyer. Teacher algorithms for curriculum learning of deep rl in continuously parameterized environments. In Leslie Pack Kaelbling, Danica Kragic, and Komei Sugiura (eds.), Proceedings of the Conference on Robot Learning, volume 100 of Proceedings of Machine Learning Research, pp. 835–853. PMLR, 30 Oct– 01 Nov 2020. URL https://proceedings.mlr.press/v100/portelas20a.html. + +Stephane Ross and Drew Bagnell. Efficient reductions for imitation learning. In Yee Whye Teh and Mike Titterington (eds.), Proceedings of the Thirteenth International Conference on Artificial Intelligence and Statistics, volume 9 of Proceedings of Machine Learning Research, pp. 661–668, Chia Laguna Resort, Sardinia, Italy, 13–15 May 2010. PMLR. URL https://proceedings. mlr.press/v9/ross10a.html. + +Mark Rowland, Will Dabney, and Remi Munos. Adaptive trade-offs in off-policy learning. In Silvia Chiappa and Roberto Calandra (eds.), Proceedings of the Twenty Third International Conference on Artificial Intelligence and Statistics, volume 108 of Proceedings of Machine Learning Research, pp. 34–44. PMLR, 26–28 Aug 2020. URL https://proceedings.mlr.press/v108/ rowland20a.html. + +Fereshteh Sadeghi and Sergey Levine. CAD2RL: real single-image flight without a single real image. In Nancy M. Amato, Siddhartha S. Srinivasa, Nora Ayanian, and Scott Kuindersma (eds.), Robotics: Science and Systems XIII, Massachusetts Institute of Technology, Cambridge, Massachusetts, USA, July 12-16, 2017, 2017. + +Mikayel Samvelyan, Robert Kirk, Vitaly Kurin, Jack Parker-Holder, Minqi Jiang, Eric Hambro, Fabio Petroni, Heinrich Kuttler, Edward Grefenstette, and Tim Rocktäschel. Minihack the planet: A sandbox for open-ended reinforcement learning research. In Thirty-fifth Conference on Neural Information Processing Systems Datasets and Benchmarks Track, 2021. + +Leonard J Savage. The theory of statistical decision. Journal of the American Statistical association, 46(253):55–67, 1951. + +John Schulman, Filip Wolski, Prafulla Dhariwal, Alec Radford, and Oleg Klimov. Proximal policy optimization algorithms, 2017. + +David Silver, Aja Huang, Chris J. Maddison, Arthur Guez, Laurent Sifre, George van den Driessche, Julian Schrittwieser, Ioannis Antonoglou, Vedavyas Panneershelvam, Marc Lanctot, Sander Dieleman, Dominik Grewe, John Nham, Nal Kalchbrenner, Ilya Sutskever, Timothy P. Lillicrap, Madeleine Leach, Koray Kavukcuoglu, Thore Graepel, and Demis Hassabis. Mastering the game of go with deep neural networks and tree search. Nat., 529(7587):484–489, 2016. URL https://doi.org/10.1038/nature16961. + +Adam Stooke, Anuj Mahajan, Catarina Barros, Charlie Deck, Jakob Bauer, Jakub Sygnowski, Maja Trebacz, Max Jaderberg, Michaël Mathieu, Nat McAleese, Nathalie Bradley-Schmieg, Nathaniel Wong, Nicolas Porcel, Roberta Raileanu, Steph Hughes-Fitt, Valentin Dalibard, and Wojciech Marian Czarnecki. Open-ended learning leads to generally capable agents. CoRR, abs/2107.12808, 2021. URL https://arxiv.org/abs/2107.12808. + +Sainbayar Sukhbaatar, Zeming Lin, Ilya Kostrikov, Gabriel Synnaeve, Arthur Szlam, and Rob Fergus. Intrinsic motivation and automatic curricula via asymmetric self-play. In International Conference on Learning Representations, 2018. URL https://openreview.net/forum? id=SkT5Yg-RZ. + +Richard S. Sutton, A. Rupam Mahmood, and Martha White. An emphatic approach to the problem of off-policy temporal-difference learning. Journal of Machine Learning Research, 17(73):1–29, 2016. URL http://jmlr.org/papers/v17/14-488.html. + +Philip Thomas and Emma Brunskill. Data-efficient off-policy policy evaluation for reinforcement learning. In Maria Florina Balcan and Kilian Q. Weinberger (eds.), Proceedings of The $3 3 r d$ International Conference on Machine Learning, volume 48 of Proceedings of Machine Learning Research, pp. 2139–2148, New York, New York, USA, 20–22 Jun 2016. PMLR. + +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 2017 IEEE/RSJ International Conference on Intelligent Robots and Systems, IROS 2017, Vancouver, BC, Canada, September 24-28, 2017, pp. 23–30. IEEE, 2017. + +Vladimir N Vapnik and A Ya Chervonenkis. On the uniform convergence of relative frequencies of events to their probabilities. Theory of Probability and Its Applications, pp. 264–280, 1971. + +Oriol Vinyals, Igor Babuschkin, Wojciech M. Czarnecki, Michaël Mathieu, Andrew Dudzik, Junyoung Chung, David H. Choi, Richard Powell, Timo Ewalds, Petko Georgiev, Junhyuk Oh, Dan Horgan, Manuel Kroiss, Ivo Danihelka, Aja Huang, Laurent Sifre, Trevor Cai, John P. Agapiou, Max Jaderberg, Alexander Sasha Vezhnevets, Rémi Leblond, Tobias Pohlen, Valentin Dalibard, David Budden, Yury Sulsky, James Molloy, Tom L. Paine, Çaglar Gülçehre, Ziyu Wang, Tobias Pfaff, Yuhuai Wu, Roman Ring, Dani Yogatama, Dario Wünsch, Katrina McKinney, Oliver Smith, Tom Schaul, Timothy P. Lillicrap, Koray Kavukcuoglu, Demis Hassabis, Chris Apps, and David Silver. Grandmaster level in starcraft II using multi-agent reinforcement learning. Nat., 575(7782): 350–354, 2019. doi: 10.1038/s41586-019-1724-z. URL https://doi.org/10.1038/ $\mathtt { s 4 1 5 8 6 - 0 1 9 - 1 7 2 4 - z }$ . + +Rui Wang, Joel Lehman, Jeff Clune, and Kenneth O. Stanley. Paired open-ended trailblazer (POET): endlessly generating increasingly complex and diverse learning environments and their solutions. CoRR, abs/1901.01753, 2019. + +Rui Wang, Joel Lehman, Aditya Rawal, Jiale Zhi, Yulun Li, Jeffrey Clune, and Kenneth Stanley. Enhanced POET: Open-ended reinforcement learning through unbounded invention of learning challenges and their solutions. In Proceedings of the 37th International Conference on Machine Learning, pp. 9940–9951, 2020. + +Xiaoxia Wu, Ethan Dyer, and Behnam Neyshabur. When do curricula work? In 9th International Conference on Learning Representations, ICLR 2021, Virtual Event, Austria, May 3-7, 2021. OpenReview.net, 2021. URL https://openreview.net/forum?id ${ . } = { }$ tW4QEInpni. + +Amy Zhang, Zachary C. Lipton, Luis Pineda, Kamyar Azizzadenesheli, Anima Anandkumar, Laurent Itti, Joelle Pineau, and Tommaso Furlanello. Learning causal state representations of partially observable environments. CoRR, abs/1906.10437, 2019. URL http://arxiv.org/abs/ 1906.10437. + +Amy Zhang, Rowan Thomas McAllister, Roberto Calandra, Yarin Gal, and Sergey Levine. Learning invariant representations for reinforcement learning without reconstruction. In 9th International Conference on Learning Representations, ICLR 2021, Virtual Event, Austria, May 3-7, 2021. OpenReview.net, 2021. URL https://openreview.net/forum?id $=$ -2FCwDKRREu. + +Victor Zhong, Tim Rocktäschel, and Edward Grefenstette. RTFM: generalising to new environment dynamics via reading. 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 $=$ SJgob6NKvH. + +Luisa M. Zintgraf, Kyriacos Shiarlis, Maximilian Igl, Sebastian Schulze, Yarin Gal, Katja Hofmann, and Shimon Whiteson. Varibad: A very good method for bayes-adaptive deep RL via meta-learning. 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 $=$ Hkl9JlBYvr. \ No newline at end of file diff --git a/md/dev/wu1Za9dY1GY/wu1Za9dY1GY.md b/md/dev/wu1Za9dY1GY/wu1Za9dY1GY.md new file mode 100644 index 0000000000000000000000000000000000000000..27266fb0f20c401b07822cc186c0a8c262993474 --- /dev/null +++ b/md/dev/wu1Za9dY1GY/wu1Za9dY1GY.md @@ -0,0 +1,320 @@ +# Graph Neural Networks are Dynamic Programmers + +Andrew Dudzik∗ DeepMind adudzik@deepmind.com + +Petar Velickovi ˇ c´∗ DeepMind petarv@deepmind.com + +# Abstract + +Recent advances in neural algorithmic reasoning with graph neural networks (GNNs) are propped up by the notion of algorithmic alignment. Broadly, a neural network will be better at learning to execute a reasoning task (in terms of sample complexity) if its individual components align well with the target algorithm. Specifically, GNNs are claimed to align with dynamic programming (DP), a general problem-solving strategy which expresses many polynomial-time algorithms. However, has this alignment truly been demonstrated and theoretically quantified? Here we show, using methods from category theory and abstract algebra, that there exists an intricate connection between GNNs and DP, going well beyond the initial observations over individual algorithms such as Bellman-Ford. Exposing this connection, we easily verify several prior findings in the literature, produce better-grounded GNN architectures for edge-centric tasks, and demonstrate empirical results on the CLRS algorithmic reasoning benchmark. We hope our exposition will serve as a foundation for building stronger algorithmically aligned GNNs. + +# 1 Introduction + +One of the principal pillars of neural algorithmic reasoning [27] is training neural networks that execute algorithmic computation in a high-dimensional latent space. While this process is in itself insightful, and can lead to stronger combinatorial optimisation systems [21], it is valuable in terms of expanding the applicability of classical algorithms. Evidence of this value are emerging, with pre-trained algorithmic reasoners utilised in implicit planning [11] and self-supervised learning [28]. + +A fundamental question in this space is: which architecture should be used to learn a particular algorithm (or collection of algorithms [36])? Naturally, we seek architectures that have low sample complexity, as they will allow us to create models that generalise better with fewer training examples. + +The key theoretical advance towards achieving this aim has been made by [37]. Therein, the authors formalise the notion of algorithmic alignment, which states that we should favour architectures that align better to the algorithm, in the sense that we can separate them into modules, which individually correspond to the computations of the target algorithm’s subroutines. It can be proved that architectures with higher algorithmic alignment will have lower sample complexity in the NTK regime [20]. Further, the theory of [37] predicts that graph neural networks (GNNs) algorithmically align with dynamic programming [3, DP]. The authors demonstrate this by forming an analogy to the Bellman-Ford algorithm [2]. + +Since DP is a very general class of problem-solving techniques that can be used to express many classical algorithms, this finding has placed GNNs as the central methodology for neural algorithmic execution [7]. However, it quickly became apparent that it is not enough to just train any GNN—for many algorithmic tasks, careful attention is required. Several papers illustrated special cases of GNNs that align with sequential algorithms [31], linearithmic sequence processing [16], physics simulations [23], iterative algorihtms [26], data structures [29] or auxiliary memory [24]. Some explanations for this lack of easy generalisation have arisen—we now have both geometric [38] and causal [4] views into how better generalisation can be achieved. + +We believe that the fundamental reason why so many isolated efforts needed to look into learning specific classes of algorithms is the fact the GNN-DP connection has not been sufficiently explored. Indeed, the original work of [37] merely mentions in passing that the formulation of DP algorithms seems to align with GNNs, and demonstrates one example (Bellman-Ford). Our thorough investigation of the literature yielded no concrete follow-up to this initial claim. But DP algorithms are very rich and diverse, often requiring a broad spectrum of computations. Hence what we really need is a framework that could allow us to identify GNNs that could align particularly well with certain classes of DP, rather than assuming a “one-size-fits-all” GNN architecture will exist. + +As a first step towards this, in this paper we interpret the operations of both DP and GNNs from the lens of category theory and abstract algebra. We elucidate the GNN-DP connection by observing a diagrammatic abstraction of their computations, recasting algorithmic alignment to aligning the diagrams of (G)NNs to ones of the target algorithm class. In doing so, several previously shown results will naturally arise as corollaries, and we propose novel GNN variants that empirically align better to edge-centric algorithms. We hope our work opens up the door to a broader unification between algorithmic reasoning and the geometric deep learning blueprint [5]. + +# 2 GNNs, dynamic programming, and the categorical connection + +Before diving into the theory behind our connection, we provide a quick recap on the methods being connected: graph neural networks and dynamic programming. Further, we cite related work to outline why it is sufficient to interpret DP from the lens of graph algorithms. + +We will use the definition of GNNs based on [5]. Let a graph be a tuple of nodes and edges, $G = ( V , E )$ , with one-hop neighbourhoods defined as $\mathcal { N } _ { u } \mathbf { \bar { \Gamma } } = \{ v \in V \mid \mathbf { \bar { ( } } v , u ) \in E \}$ . Further, a node feature matrix $\mathbf { X } \in \mathbb { R } ^ { | V | \times k }$ gives the features of node $u$ as $\mathbf { x } _ { u }$ ; we omit edge- and graph-level features for clarity. A (message passing) GNN over this graph is then executed as: + +$$ +\mathbf { h } _ { u } = \phi \left( \mathbf { x } _ { u } , \bigoplus _ { v \in \mathcal { N } _ { u } } \psi ( \mathbf { x } _ { u } , \mathbf { x } _ { v } ) \right) +$$ + +where $\psi : \mathbb { R } ^ { k } \times \mathbb { R } ^ { k } \to \mathbb { R } ^ { k }$ is a message function, $\phi : \mathbb { R } ^ { k } \times \mathbb { R } ^ { k } \mathbb { R } ^ { k }$ is a readout function, and $\oplus$ is a permutation-invariant aggregation function (such as $\displaystyle \sum$ or max). Both $\psi$ and $\phi$ can be realised as MLPs, but many special cases exist, giving rise to, e.g., attentional GNNs [30]. + +Dynamic programming is defined as a process that solves problems in a divide et impera fashion: imagine that we want to solve a problem instance $x$ . DP proceeds to identify a set of subproblems, $\eta ( x )$ , such that solving them first, and recombining the answers, can directly lead to the solution for $x$ : $f ( x ) = \rho ( \{ f ( y ) \mid y \in \eta ( x ) \} )$ . Eventually, we decompose the problem enough until we arrive at an instance for which the solution is trivially given (i.e. $f ( y )$ which is known upfront). From these “base cases”, we can gradually build up the solution for the problem instance we initially care for in a bottom-up fashion. This rule is often expressed programmatically: + +$$ +\mathsf { d p } [ \mathbf { x } ] \gets \mathbf { r e c o m b i n e } ( \mathbf { s c o r e } ( \mathrm { d p } [ \mathbf { y } ] , \mathrm { d p } [ \mathbf { x } ] ) \mathrm { ~ f o r ~ y ~ i n ~ e x p a n d } ( \mathbf { x } ) ) +$$ + +To initiate our discussion on why DP can be connected with GNNs, it is a worthwhile exercise to show how Equation 2 induces a graph structure. To see this, we leverage a categorical analysis of dynamic programming first proposed by [10]. Therein, dynamic programming algorithms are reasoned about as a composition of three components (presented here on a high level): + +$$ +\mathrm { d } \boldsymbol { \mathrm { p } } = \underbrace { \rho } _ { \mathrm { r e c o m b i n e } } ^ { \mathrm { ~ \tiny ~ { ~ \circ ~ } ~ } } \underbrace { \sigma } _ { \mathrm { s c o r e } } ^ { \mathrm { ~ \tiny ~ { ~ \circ ~ } ~ } } \underbrace { \eta } _ { \mathrm { e x p a n d } } +$$ + +Expansion selects the relevant subproblems; scoring computes the quality of each individual subproblem’s solution w.r.t. the current problem, and recombining combines these solutions into a solution for the original problem (e.g. by taking the max, or average). + +Therefore, we can actually identify every subproblem as a node in a graph. Let $V$ be the space of all subproblems, and $R$ an appropriate value space (e.g. the real numbers). Then, expansion is defined as $\eta : V \to { \mathcal { P } } ( V )$ , giving the set of all subproblems relevant for a given problem. Note that this also induces a set of edges between subproblems, $E$ ; namely, $( x , y ) \in { \bar { E } }$ if $x \in \eta ( y )$ . Each subproblem is scored by using a function $\sigma : { \mathcal { P } } ( V ) \to { \mathcal { P } } ( R )$ . Finally, the individual scores are recombined using the recombination function, $\rho : \mathcal { P } ( R ) R$ . The final dynamic programming primitive therefore computes a function $\mathrm { d } \mathsf { p } : V \to R$ in each of the subproblems of interest. + +Therefore, dynamic programming algorithms can be seen as performing computations over a graph of subproblems, which can usually be precomputed for the task at hand (since the outputs of $\eta$ are assumed known upfront for every subproblem). One specific popular example is the Bellman-Ford algorithm [2], which computes single-source shortest paths from a given source node, $s$ , in a graph $G = ( V , E )$ . In this case, the set of subproblems is exactly the set of nodes, $V$ , and the expansion $\eta ( u )$ is exactly the set of one-hop neighbours of $u$ in the graph. The algorithm maintains distances of every node to the source, $d _ { u }$ . The rule for iteratively recombining these distances is as follows: + +$$ +d _ { u } \gets \operatorname* { m i n } \Big ( d _ { u } , \operatorname* { m i n } _ { v \in \mathcal { N } _ { u } } d _ { v } + w _ { v \to u } \Big ) +$$ + +where $w _ { v u }$ is the distance between nodes $v$ and $u$ . The algorithm’s base cases are $d _ { s } = 0$ for the source node, $d _ { u } = + \infty$ otherwise. Note that more general forms of Bellman-Ford pathfinding exist, for appropriate definitions of $^ +$ and min (in general known as a semiring). Several recent research papers such as NBFNet [39] explicitly call on this alignment in their motivation. + +# 3 The difficulty of connecting GNNs and DP + +The basic technical obstacle to establishing a rigorous correspondence between neural networks and DP is the vastly different character of the computations they perform. Neural networks are built from linear algebra over the familiar real numbers, while DP, which is often a generalisation of path-finding problems, typically takes place over “tropical” objects like $( \mathbb { N } \cup \{ \infty \} , { \overline { { \operatorname* { m i n } } } } , + ) ^ { 2 }$ , which are usually studied in mathematics as “degenerations” of Euclidean space. The two worlds cannot clearly be reconciled, directly, with simple equations. + +However, if we define an arbitrary “latent space” $R$ and make as few assumptions as possible, we can observe that many of the behaviors we care about, for both GNNs and $D P$ , arise from looking at functions $S R$ , where $S$ is a finite set. $R$ can be seen as the set of real-valued vectors in the case of GNNs, and the tropical numbers in the case of DP. + +So our principal object of study is the category of finite sets, and “ $R$ -valued quantities” on it. By “category” here we mean a collection of objects (all finite sets) together with a notion of composable arrows (functions between finite sets). + +To draw our GNN-DP connection, we need to devise an abstract object which can capture both the GNN’s message passing/aggregation stages (Equation 1) and the DP’s scoring/recombination stages (Equation 2). It may seem quite intuitive that these two concepts can and should be relatable, and category theory is a very attractive tool for “making the obvious even more obvious” [15]. Indeed, recently concepts from category theory have enabled the construction of powerful GNN architectures beyond permutation equivariance [9]. Here, we propose integral transforms as such an object. + +We will construct the integral transform by composing transformations over our input features in a way that will depend minimally on the specific choice of $R$ . In doing so, we will build a computational diagram that will be applicable for both GNNs and DP (and their own choices of $R$ ), and hence allowing for focusing on making components of those diagrams as aligned as possible. + +# 4 The integral transform + +An integral transform can be encoded in a diagram of this form, which we call a polynomial span: + +$$ +\begin{array} { l c c c c } { X } & { \quad } & { p \longrightarrow Y } \\ { \big | } & { } & { } & { \big | } \\ { i } & { } & { } & { \begin{array} { l } { { } } \\ { { } } \end{array} } \\ { \big \downarrow } & { } & { } & { \begin{array} { l } { { } } \\ { { } } \end{array} } \end{array} +$$ + +where $W , X , Y$ and $Z$ are finite sets. The arrows $i , p , o$ stand, respectively, for “input”, “process”, and “output”. In context, the sets will have the following informal meaning: $W$ represents the set over which we define our inputs, $Z$ the set over which we define outputs. $X$ and $Y$ are, respectively, carrier sets for the arguments, and the messages3—we will clarify their meaning shortly. + +Before proceeding, it is worthy to note the special case of $X = Y = E$ , with $p$ being the identity map. Such a diagram is commonly known as a span. A span that additionally has $W = Z = V$ is equivalent to a representation of a directed graph with vertex set $Z$ and edge set $Y$ $V \left. E \right. V )$ ; in this case $i ( e )$ and $o ( e )$ are the functions identifying the source and target nodes of each edge. + +The key question is: given input data $f$ on $W$ , assigning features $f ( w )$ to each $w \in W$ , how to transform it, via the polynomial span, into data on $Z ?$ If we can do this, we will be able to characterise both the process of sending messages between nodes in GNNs and scoring subproblems in DP. + +For us, data on a carrier set $S$ consists of an element of $[ S , R ] : = \{ f : S \to R \}$ , where $R$ is a “set of possible values”. For now, we will think of $R$ as an arbitrary (usually infinite) set, though we will see later that it should possess some algebraic structure; it should be a semiring. + +The transform proceeds in three steps, following the edges of the polynomial span: + +![](images/a29308cb28d2969f4ba9f675aa076030e5bc284ddef2ead454fa7460e89aa9d4.jpg) + +We call the three arrows $i ^ { * } , p _ { \otimes } , o _ { \oplus }$ the pullback, the argument pushfoward, and the message pushforward. Taken together, they form an integral transform—and we conjecture that this transform can be described as a polynomial functor, where $p _ { \otimes }$ and $o _ { \oplus }$ correspond to the dependent product and dependent sum from type theory (cf. Appendix $\mathbf { D }$ for details). + +The pullback $i ^ { * }$ is the easiest to define. Since we have a function $i : X \to W$ (part of the polynomial span) and a function $f : W \to R$ (our input data), we can produce data on $X$ , that is, a function in $X R$ , by composition. We hence define $i ^ { * } f = f \circ i$ . + +Unfortunately, the other two arrows of the polynomial span point in the wrong direction for naïve composition. For the moment, we will focus on how to define $o _ { \oplus }$ and leave $p _ { \otimes }$ for later. + +We start with message data $m : Y R$ . It may be attractive to invert the output arrow $o$ in order to define a composition with $o ^ { - 1 }$ , as was done in the case of the pullback. However, unless $o$ is bijective, the preimage $o ^ { - 1 } : Z \to { \mathcal { P } } ( Y )$ takes values in the power set of $Y$ . There is an additional technicality: if the composition $m \circ o ^ { - 1 }$ takes values in ${ \mathcal { P } } ( R )$ , it will fail to detect multiplicities; we are unable to tell from a subset of $R$ whether multiple messages had the same value. + +So instead, our pushforward takes values in $\mathtt { b a g } ( R )$ , the set of finite multisets (or bags) of $R$ , which we describe in more detail in appendix B. For the moment, it is enough to know that a bag is equivalent to a formal sum, and we define an intermediate message pushforward $( { \overline { { o _ { \oplus } } } } m ) ( u ) : =$ $\bar { \Sigma _ { e \in t ^ { - 1 } ( u ) } m ( e ) } \in [ Z , \mathtt { b a g } ( R ) ]$ . + +![](images/b4ef111e803e25f9826861bc78bdc35ca9f37a8024d2030b08ff18c3f29eac56.jpg) +Figure 1: The illustration of how pullback and pushforward combine to form the integral transform, for two specific cases. Left: Polynomial span $V E E V$ with trivial argument pushforward (identity). Each edge $e _ { u v }$ is connected to its sender and receiver nodes $( u , v )$ via the span (black arrows). The pullback then “pulls” the node features $f ( u )$ along the span, which the argument pushforward folds into edge features $g ( e _ { v u } ) = f ( u )$ . Once all sender features are pulled back to their edges, the message pushforward then “collects” all of the edge features that send to a particular receiver, by pushing them along the span. Right: Polynomial span $V E + E \mathbf { \bar { { E } } } V$ , a situation more commonly found in GNNs. In this case, the pullback pulls sender and receiver node features into the argument function, $h$ . The argument pushforward then computes, from these arguments, the edge messages, $g$ , which are sent to receivers via the message pushforward, as before. See Appendix A for a visualisation of how these arrows translate into GNN code. + +All that is missing to complete our definition of $o _ { \oplus }$ is an aggregator $\oplus : \mathtt { b a g } ( R ) \to R$ . As we will see later, specifying a well-behaved aggregator is the same as imposing a commutative monoid structure on $R$ . With such an aggregator on $R$ , we can define $( o _ { \oplus } m ) ( u ) : = \bigoplus ( \overline { { \upsilon _ { \oplus } } } m ) ( u )$ . + +We return to $p _ { \otimes }$ , which is constructed very similarly. The only difference is that, while we deliberately regard the collection of messages as unordered, the collection of arguments used to compute a message has an ordering we wish to respect. So instead of the type $\mathtt { b a g } ( R )$ , we use the type $\mathtt { l i s t } ( R )$ of finite lists of elements of $R$ , and our aggregator $\otimes : { \mathrm { l i s t } } ( R ) \to R$ is now akin to a fold operator. + +We illustrate the use of these two aggregators in a decomposed diagram: + +![](images/158ad27263699ea72f25bbed7a559e8105e848514b253b182697ff23b830b035.jpg) + +Note that any semiring $( R , \otimes , \oplus )$ comes equipped with binary operators $\otimes , \oplus$ that allow aggregators $\otimes , \oplus$ to be defined inductively. In fact, the converse—that every set with two such aggregators is a semiring—is also true, if we assume some reasonable conditions on the aggregators, which we can explain in terms of one of the most utilised concepts in category theory and functional programming—monads [33]. Due to space constraints, we refer the interested reader to Appendices $\mathbf { B }$ and C for a full exposition of how we can use monads over lists and bags to constrain the latent space $R$ to respect a semiring structure. + +For now, it’s enough to know that our key examples of the real numbers (with multiplication and addition, for GNNs) and the tropical natural numbers (with addition and minimum, for DP) both allow for natural interpretations of $\otimes$ and $\oplus$ in the integral transform. + +We are now ready to show how the integral transform can be used to instantiate popular examples of algorithms and GNNs. We start with the Bellman-Ford algorithm [2] (Equation 4) that was traditionally used to demonstrate the concept of algorithmic alignment. + +# 5 Bellman-Ford + +Let $R = ( \mathbb { N } \cup \{ \infty \} , + , \operatorname* { m i n } )$ be the “min-plus” semiring of extended natural numbers, with $\otimes = +$ and $\oplus = \operatorname* { m i n }$ . This is the coefficient semiring over which the Bellman-Ford algorithm takes place. + +Let $( V , E )$ be a weighted graph with source and target maps $s , t : E \to V$ and edge weights $w : E R$ . For purely technical reasons, we also need to explicitly materialise a bias function $b : V R$ , which is, in practice, a constant-zero function $( b ( v ) = 0$ for all $v \in V .$ ) but will prove necessary for defining the argument pushforward. + +We interpret Bellman-Ford as the following polynomial span: + +$$ +\begin{array} { c c c } { { ( V + E ) + ( V + E ) \ --- p \longrightarrow V + E } } & { { } } & { { } } \\ { { \big | } } & { { } } & { { \big | } } \\ { { \begin{array} { c c c } { { \scriptstyle \dot { i } } } & { { } } & { { } } \\ { { \big \downarrow } } & { { } } & { { \big \downarrow } } \\ { { \scriptstyle V + ( V + E ) } } & { { } } & { { \scriptstyle V } } \end{array} } } & { { } } \end{array} +$$ + +Here “ $+ ^ { \dag }$ is the disjoint union of sets, defined as $A + B = \{ ( a , 1 ) \mid a \in A \} \cup \{ ( b , 2 ) \mid b \in B \} .$ . Note that $[ S + T , R ] \cong [ S , R ] \times [ T , R ]$ , i.e. specifying data on a disjoint union is equivalent to specifying data on each component separately. + +Initially, we describe each of the four sets of the polynomial span, making their role clear: + +• Input: $W = V + ( V + E )$ . Our input to Bellman-Ford includes: the current estimate of node distances $\dot { \ b { d } } _ { \ b { u } }$ ; a function in $[ V , R ] )$ , edge weights ( $\dot { \boldsymbol { w } }$ ; a function in $[ E , R ] )$ , and the previously discussed bias $b$ , a function in $[ V , R ]$ . Hence our overall inputs are members of $[ V , R ] \times [ E , R ] \times [ V , R ] \cong [ V + ( V + E ) , R ]$ , justifying our choice of input space. + +• Arguments: $X = ( V + E ) + ( V + E )$ . Here we collect the ingredients necessary to compute Bellman-Ford’s subproblem solutions coming from neighbouring nodes. To do this, we need to combine data in the nodes with data living on edges—those are the arguments to the function. And since they meet in the edges, we “lift” our node distances $[ V , R ]$ to edges they are sending from, giving us an additional function in $[ E , R ]$ . Hence our argument carrier space is now $( V + E ) + ( V + E )$ (the remaining three inputs remain unchanged). + +• Message: $Y = V + E$ . Once the arguments are combined to compute messages, we are left with signal in each edge (containing the sum of corresponding $d _ { u }$ and $w _ { u v . }$ ), and each node (containing just $d _ { u }$ , for the purposes of access to the previous optimal solution). Hence our messages are members of $[ \bar { V } , \bar { R } ] \times [ E , R ]$ , justifying our choice of message space. + +• Output: $Z = V$ . Lastly, the output of one step of Bellman-Ford are updated values $d _ { u } ^ { \prime }$ , which we can interpret as just (output) data living on $V$ . + +We now describe how to propagate data along each arrow of the diagram in turn, beginning with inputs $( f , b , w )$ of node features $f : V \to R$ , a bias $b : V R$ , and edge weights $w : E R$ : + +• Pullback, $i ^ { * }$ : First, we can note the input function $i : ( V + E ) + ( V + E ) V + ( V + E )$ decomposes as the sum of two arrows. $i _ { 1 } : V + E \to V$ is the identity function on $V$ and the source function on $E$ , and $i _ { 2 } : V + E \to V + E$ is just the identity. So we calculate the pullback $i ^ { * } ( f , b , w ) = ( f , f \circ s , b , w )$ , giving us the arguments to compute messages. + +• Argument pushforward, $p _ { \otimes }$ : Next, the process function $p$ simply identifies the two copies of $V + E$ , and sums their values. So the argument pushforward is $p _ { \otimes } ( f , f \circ s , b , w ) =$ $( f , f \circ s ) \otimes ( b , w ) = ( f + b , ( f \circ s ) + w )$ . This also allows us to interpret the bias function, $b$ , as a “self-edge” in the graph with weight 0. + +• Message pushforward, $o _ { \oplus }$ : The output function $o : V + E V$ is the identity function on $V$ and the target function on $E$ . So the message pushforward gives us $( o _ { \oplus } ( f + b , ( f \circ s ) +$ $\begin{array} { r } { w ) ) ( u ) = ( f ( u ) + b ( u ) ) \oplus \bigoplus _ { t ( e ) = u } ( f \circ s ) ( e ) = \operatorname* { m i n } ( f ( u ) + b ( u ) , \operatorname* { m i n } _ { v \to u } f ( v ) + w _ { v \to u } ) ( f ( u ) + f ( e ) ) } \end{array}$ ). + +Letting $b ( u ) = 0$ , we can see that this is exactly Equation 4. So we have produced the formula for the Bellman-Ford algorithm directly from the polynomial span in Diagram 6. + +Note that $p _ { \oplus }$ is aligned with using max aggregation in neural networks—directly explaining several previous proposals, such as [31]. But additionally, $p _ { \otimes }$ , as defined, is aligned with concatenating all message arguments together and passing them through a linear function, which is how such a step is implemented in GNNs’ message functions. We now direct our polynomial span analysis at GNNs. + +# 6 GNNs + +We study the popular message passing neural network (MPNN) model [19], which can be interpreted using the following polynomial span diagram: + +$$ +\begin{array} { c c c } { E + ( E + E ) + E } & { \longrightarrow } & { \longrightarrow E } \\ { \big | } & { \big | } & { \big | } \\ { \begin{array} { c c c } { \underline { { i } } } & { \qquad \underline { { o } } } & { \qquad \underline { { o } } } \\ { \big \downarrow } & { \qquad \downarrow } & { \qquad \downarrow } \\ { 1 + V + E } & { } & { } & { V } \end{array} } \end{array} +$$ + +Here the set 1 refers to a singleton set—sometimes also called (), or unit—which is used as a carrier for graph-level features. This implies the graph features will be specified as $[ 1 , R ] \cong R$ , as expected. + +Given all these features, how would we compute messages? The natural way is to combine the features of the sender and receiver node of each edge, features of said edge, and graph-level features— these will form our arguments, and they need to all “meet” in the edges. This motivates our argument space as $E + ( E + E ) + E$ : all of the above four, accordingly broadcast into their respective edge(s). + +The input map, $i$ , is then the unique map to the singleton, the sender and receiver functions on the two middle copies of $E$ , and the identity on the last copy of $E$ , i.e. $i ( a , b , c , d ) = \{ ( ) , s ( b ) , t ( c ) , d \}$ . The process map, $p$ , collapses the four copies of $E$ into just one, to hold the computed message. Lastly, the output map, $o$ , is the target function, identifying the node to which the message will be delivered. + +The actual computation performed by the network (over real values in $\mathbb { R }$ , which can support various semirings of interest) is exactly an integral transform, with an extra MLP processing step on messages: + +$$ +\begin{array} { r l r } { \left[ E + ( E + E ) + E , \mathbb { R } \right] \longrightarrow p _ { \otimes } \longrightarrow [ E , \mathbb { R } ] \longleftrightarrow \scriptscriptstyle M L P } & { } & \\ { \uparrow } & { \underset { \textit { i } ^ { * } } { \bigcap } } & { } & { \underset { \textit { i } ^ { * } } { \bigcap } } \\ { \Big | } & { } & { \underset { \textit { i } ^ { * } } { \bigcup } } & { } \\ { \left[ 1 + V + E , \mathbb { R } \right] } & { } & { \left[ V , \mathbb { R } \right] } \end{array} +$$ + +It is useful to take a moment to discuss what was just achieved: with a single abstract template (the polynomial span), we have successfully explained both a dynamic programming algorithm, and a GNN update rule—merely by choosing the correct support sets and latent space. + +# 7 Improving GNNs with edge updates, with experimental evaluation + +From now on, we will set $E = V ^ { 2 }$ , as all our baseline GNNs will use fully connected graphs, and it will accentuate the polynomial nature of our construction. + +We now show how our polynomial span view can be used to directly propose better-aligned GNN architectures for certain algorithmic tasks. Since the MPNN diagram above outputs only node features, to improve predictive performance on edge-centric algorithms, it is a natural augmentation to also update edge features, by adding edges to the output carrier (as done by, e.g., [1]): + +$$ +\begin{array} { c c c } { { V ^ { 2 } + ( V ^ { 2 } + V ^ { 2 } ) + V ^ { 2 } ~ { \longrightarrow } ~ } } & { { V ~ { \longrightarrow } ~ V ^ { 2 } } } \\ { { \big \downarrow } } & { { } } & { { } } \\ { { \begin{array} { l } { { i } } \\ { { \downarrow } } \\ { { \downarrow } } \end{array} } } & { { \begin{array} { r } { { } } \\ { { } } \\ { { } } \\ { { { } } } \end{array} } } \\ { { 1 + V + V ^ { 2 } } } & { { } } & { { V + V ^ { 2 } } } \end{array} +$$ + +But notice that there is a problem with the output arrow. Since we are using each message twice, $o$ is no longer a function—it’d have to send each edge message to two different objects! To resolve this, we need to appropriately augment the messages and the arguments. This is equivalent to specifying a new polynomial span with output $V ^ { 2 }$ , which we can then recombine with Diagram 7: + +$$ +\begin{array} { l l l l } { { } } & { { ? ~ - } } & { { ~ p ~ - } } & { { ~ ? ~ } } \\ { { } } & { { } } & { { } } & { { } } \\ { { } } & { { \stackrel { i } { \downarrow } ~ } } & { { } } & { { ~ \stackrel { i } { \downarrow } ~ } } \\ { { } } & { { } } & { { } } & { { ~ \downarrow } } \\ { { 1 + V + V ^ { 2 } } } & { { } } & { { } } & { { ~ V ^ { 2 } } } \end{array} +$$ + +Most edge-centric algorithms of interest (such as the Floyd-Warshall algorithm for all-pairs shortest paths [14]), compute edge-level outputs by reducing over a choice of “intermediate” node. Hence, it would be beneficial to produce messages with shape $V ^ { 3 }$ , which would then reduce to features over $V ^ { 2 }$ . There are three possible ways to broadcast both node and edge features into $V ^ { 3 }$ , so we propose the following polynomial span, which materialises each of those arguments: + +$$ +\begin{array} { c c c } { { V ^ { 3 } + ( V ^ { 3 } + V ^ { 3 } + V ^ { 3 } ) + ( V ^ { 3 } + V ^ { 3 } + V ^ { 3 } ) \longleftarrow \longrightarrow V ^ { 3 } } } & { { \nonumber } } & { { \nonumber } } \\ { { \big \downarrow } } & { { \big \downarrow } } & { { \big \downarrow } } \\ { { \big \downarrow } } & { { \big \downarrow } } & { { \big \downarrow } } \\ { { 1 + V + V ^ { 2 } } } & { { { } } } & { { V ^ { 2 } } } \end{array} +$$ + +Finally, inserting this into Diagram 7 gives us a corrected polynomial span with output $V + V ^ { 2 }$ : + +$$ +\begin{array} { l c c } { { 4 { \cal V } ^ { 2 } + 7 { \cal V } ^ { 3 } ~ --- ~ p ~ { \longrightarrow } ~ { \cal V } ^ { 2 } + { \cal V } ^ { 3 } } } \\ { { \mid ~ } } \\ { { ~ \stackrel { i } { \downarrow } ~ } } \\ { { ~ \downarrow ~ } } \\ { { 1 + { \cal V } + { \cal V } ^ { 2 } ~ } } & { { ~ { \cal V } + { \cal V } ^ { 2 } } } \end{array} +$$ + +Here we have collapsed the copies of $V ^ { 2 }$ and $V ^ { 3 }$ in the argument position for compactness. + +While Diagram 7 doesn’t make sense as a polynomial diagram of sets, we can clearly still implement it as an architecture [1], since nothing stops us from sending the same tensor to two places. We want to investigate whether our proposed modification of Diagram 10, which materialises order3 messages, leads to improved algorithmic alignment on edge-centric algorithms. To support this evaluation, we initially use a set of six tasks from the recently proposed CLRS Algorithmic Reasoning Benchmark [32], which evaluates how well various (G)NNs align to classical algorithms, both inand out-of-distribution. We reuse exactly the data generation and base model implementations in the publicly available code for the CLRS benchmark. + +We implemented each of these options by making our GNN’s message and update functions be two-layer MLPs with embedding dimension 24, and hidden layers of size 8 and 16. Our test results (out-of-distribution) are summarised in Table 1. For convenience, we also illustrate the in-distribution performance of our models via plots given in Appendix E. + +Lastly, we scale up our experiments to 27 different tasks in CLRS, 96-dimensional embeddings, and using the PGN processor [29], which is the current state-of-the-art model on CLRS in terms of task win count [32]. We summarise the performance improvement obtained by our $V ^ { 3 }$ variant of PGN in Table 2, aggregated across edge-centric tasks as well as ones that do not require explicit edge-level reasoning. For convenience, we provide the per-task test performance in Appendix F (Table 3). + +We found that the $V ^ { 3 }$ architecture was equivalent to, or outperformed, the non-polynomial $( V ^ { 2 } )$ one in all edge-centric algorithms (up to standard error). Additionally, this architecture appears to also provide some gains on tasks without explicit edge-level reasoning requirements, albeit smaller on average and less consistently. Our result directly validates our theory’s predictions, in the context of presenting a better-aligned GNN for edge-centric algorithmic targets. + +Table 1: Test (out-of-distribution) results of our models on all models on the six algorithms studied. $V ^ { 2 }$ corresponds to the baseline model offered by Diagram 7, while $V ^ { 3 }$ corresponds to our proposal in Diagram 10, which respects the polynomial span. + +
AlgorithmV2-largeV3-largeV2-smallV3-small
Dijkstra59.58% ± 2.8268.53%± 2.4056.10%± 3.2560.32%± 2.70
Find Maximum Subarray8.33%± 0.509.06%±0.658.46%± 0.557.89%±0.64
Floyd-Warshall7.46%±0.639.00%±0.816.66%± 0.628.23%±0.62
Insertion Sort15.39% ± 1.2724.67%±2.4414.69% ± 1.3220.23%± 2.21
Matrix Chain Order67.64% ± 1.2370.79% ± 1.5468.85%± 2.2668.76%± 1.21
Optimal BST53.03%± 2.8054.56%± 4.3446.65% ± 3.8251.94% ± 4.60
Overall average35.24%39.43%33.57%36.23%
+ +Table 2: Test (out-of-distribution) results across 27 tasks in CLRS, for the PGN processor network, averaged across edge-centric and other tasks. See Appendix F for the per-task test performances. + +
AlgorithmsV2-PGNV3-PGNAverage Improvement
Edge-centric algorithms35.03%39.08%4.44% ± 1.06
Other algorithms35.37%36.33%1.01% ± 0.11
Average of the two groups35.20%37.70%2.73%
+ +# 8 Conclusions + +In this paper, we describe the use of category theory and abstract algebra to explicitly expand on the GNN-DP connection, which was previously largely handwaved on specific examples. We derived a generic diagram of an integral transform (based on standard categorical concepts like pullback, pushforward and commutative monoids), and argued why it is general enough to support both GNN and DP computations. With this diagram materialised, we were able to immediately unify large quantities of prior work as simply manipulating one arrow or element in the integral transform. We also provided empirical evidence of the utility of polynomial spans for analysing GNN architectures, especially in terms of algorithmic alignment. It is our hope that our findings inspire future research into better-aligned neural algorithmic reasoners, especially focusing on generalising or diving into several aspects of this diagram. + +Lastly, it is not at all unlikely that analyses similar to ours have already been used to describe other fields of science—beyond algorithmic reasoners. The principal ideas of span and integral transform are central to defining Fourier series [35], and appear in the analysis of Yang-Mills equations in particle physics [13]. Properly understanding the common ground behind all of these definitions may, in the very least, lead to interesting connections, and a shared understanding between the various fields they span. + +# Acknowledgments and Disclosure of Funding + +We would like to thank Charles Blundell, Tai-Danae Bradley, Taco Cohen, Bruno Gavranovic, Bogdan ´ Georgiev, Razvan Pascanu, Karolis Špukas, Grzegorz Swirszcz, and Vincent Wang-Ma ´ scianica for ´ the very useful discussions and feedback on prior versions of this work. + +Special thanks to Tamara von Glehn for key comments helping us to formally connect integral transforms to polynomial functors. + +This research was funded by DeepMind. + +# References + +[1] Peter W Battaglia, Jessica B Hamrick, Victor Bapst, Alvaro Sanchez-Gonzalez, Vinicius Zambaldi, Mateusz Malinowski, Andrea Tacchetti, David Raposo, Adam Santoro, Ryan Faulkner, et al. Relational inductive biases, deep learning, and graph networks. arXiv preprint arXiv:1806.01261, 2018. +[2] Richard Bellman. On a routing problem. Quarterly of applied mathematics, 16(1):87–90, 1958. +[3] Richard Bellman. Dynamic programming. Science, 153(3731):34–37, 1966. +[4] Beatrice Bevilacqua, Yangze Zhou, and Bruno Ribeiro. Size-invariant graph representations for graph classification extrapolations. In International Conference on Machine Learning, pages 837–851. PMLR, 2021. +[5] Michael M Bronstein, Joan Bruna, Taco Cohen, and Petar Velickovi ˇ c. Geometric deep learning: ´ Grids, groups, graphs, geodesics, and gauges. arXiv preprint arXiv:2104.13478, 2021. +[6] Francesca Cagliari and Sandra Mantovani. Cartesianness: topological spaces, uniform spaces, and affine schemes. Topology and its Applications, 41:263–272, 1991. +[7] Quentin Cappart, Didier Chételat, Elias Khalil, Andrea Lodi, Christopher Morris, and Petar Velickovi ˇ c. Combinatorial optimization and reasoning with graph neural networks. ´ arXiv preprint arXiv:2102.09544, 2021. +[8] Eugenia Cheng. Iterated distributive laws. In Mathematical Proceedings of the Cambridge Philosophical Society, volume 150, pages 459–487. Cambridge University Press, 2011. +[9] Pim de Haan, Taco S Cohen, and Max Welling. Natural graph networks. Advances in Neural Information Processing Systems, 33:3636–3646, 2020. +[10] Oege De Moor. Categories, relations and dynamic programming. Mathematical Structures in Computer Science, 4(1):33–69, 1994. +[11] Andreea-Ioana Deac, Petar Velickovi ˇ c, Ognjen Milinkovic, Pierre-Luc Bacon, Jian Tang, and ´ Mladen Nikolic. Neural algorithmic reasoners are implicit planners. Advances in Neural Information Processing Systems, 34, 2021. +[12] Andrew Dudzik. Quantales and hyperstructures: Monads, mo’problems. arXiv preprint arXiv:1707.09227, 2017. +[13] Michael G Eastwood, Roger Penrose, and RO Wells. Cohomology and massless fields. Commun. Math. Phys, 78(3):305–351, 1981. +[14] Robert W Floyd. Algorithm 97: shortest path. Communications of the ACM, 5(6):345, 1962. +[15] Brendan Fong and David I Spivak. An invitation to applied category theory: seven sketches in compositionality. Cambridge University Press, 2019. +[16] Karlis Freivalds, Em¯ıls Ozolin, š, and Agris Šostaks. Neural shuffle-exchange networks-sequence processing in o (n log n) time. Advances in Neural Information Processing Systems, 32, 2019. +[17] Nicola Gambino and Joachim Kock. Polynomial functors and polynomial monads. In Mathematical proceedings of the cambridge philosophical society, volume 154, pages 153–192. Cambridge University Press, 2013. +[18] Jeffrey Giansiracusa and Noah Giansiracusa. Equations of tropical varieties. Duke Mathematical Journal, 165(18):3379–3433, 2016. +[19] Justin Gilmer, Samuel S Schoenholz, Patrick F Riley, Oriol Vinyals, and George E Dahl. Neural message passing for quantum chemistry. In International conference on machine learning, pages 1263–1272. PMLR, 2017. +[20] Arthur Jacot, Franck Gabriel, and Clément Hongler. Neural tangent kernel: Convergence and generalization in neural networks. Advances in neural information processing systems, 31, 2018. +[21] Vinod Nair, Sergey Bartunov, Felix Gimeno, Ingrid von Glehn, Pawel Lichocki, Ivan Lobov, Brendan O’Donoghue, Nicolas Sonnerat, Christian Tjandraatmadja, Pengming Wang, et al. Solving mixed integer programs using neural networks. arXiv preprint arXiv:2012.13349, 2020. +[22] Susan Niefield. Cartesianness: topological spaces, uniform spaces, and affine schemes. J. Pure Appl. Alg., 23:147–163, 1982. +[23] Alvaro Sanchez-Gonzalez, Jonathan Godwin, Tobias Pfaff, Rex Ying, Jure Leskovec, and Peter Battaglia. Learning to simulate complex physics with graph networks. In International Conference on Machine Learning, pages 8459–8468. PMLR, 2020. +[24] Heiko Strathmann, Mohammadamin Barekatain, Charles Blundell, and Petar Velickovi ˇ c. Persis-´ tent message passing. arXiv preprint arXiv:2103.01043, 2021. +[25] Daisuke Tambara. On multiplicative transfer. Communications in Algebra, 21(4):1393–1420, 1993. +[26] Hao Tang, Zhiao Huang, Jiayuan Gu, Bao-Liang Lu, and Hao Su. Towards scale-invariant graph-related problem solving by iterative homogeneous gnns. Advances in Neural Information Processing Systems, 33:15811–15822, 2020. +[27] Petar Velickovi ˇ c and Charles Blundell. Neural algorithmic reasoning. ´ Patterns, 2(7):100273, 2021. +[28] Petar Velickovi ˇ c, Matko Bošnjak, Thomas Kipf, Alexander Lerchner, Raia Hadsell, Raz- ´ van Pascanu, and Charles Blundell. Reasoning-modulated representations. arXiv preprint arXiv:2107.08881, 2021. +[29] Petar Velickovi ˇ c, Lars Buesing, Matthew Overlan, Razvan Pascanu, Oriol Vinyals, and Charles ´ Blundell. Pointer graph networks. Advances in Neural Information Processing Systems, 33:2232–2244, 2020. +[30] Petar Velickovi ˇ c, Guillem Cucurull, Arantxa Casanova, Adriana Romero, Pietro Lio, and Yoshua ´ Bengio. Graph attention networks. arXiv preprint arXiv:1710.10903, 2017. +[31] Petar Velickovi ˇ c, Rex Ying, Matilde Padovano, Raia Hadsell, and Charles Blundell. Neural ´ execution of graph algorithms. arXiv preprint arXiv:1910.10593, 2019. +[32] Petar Velickovi ˇ c, Adrià Puigdomènech Badia, David Budden, Razvan Pascanu, Andrea Ban- ´ ino, Misha Dashevskiy, Raia Hadsell, and Charles Blundell. The clrs algorithmic reasoning benchmark. arXiv preprint arXiv:2205.15659, 2022. +[33] Philip Wadler. Comprehending monads. In Proceedings of the 1990 ACM Conference on LISP and Functional Programming, pages 61–78, 1990. +[34] Mark Weber. Polynomials in categories with pullbacks. Theory and Applications of Categories, 30(16):533–598, 2015. +[35] Simon Willerton. Integral transforms and the pull-push perspective, i. The n-Category Café, 2020. +[36] Louis-Pascal Xhonneux, Andreea-Ioana Deac, Petar Velickovi ˇ c, and Jian Tang. How to transfer ´ algorithmic reasoning knowledge to learn new algorithms? Advances in Neural Information Processing Systems, 34, 2021. +[37] Keyulu Xu, Jingling Li, Mozhi Zhang, Simon S Du, Ken-ichi Kawarabayashi, and Stefanie Jegelka. What can neural networks reason about? arXiv preprint arXiv:1905.13211, 2019. +[38] Keyulu Xu, Mozhi Zhang, Jingling Li, Simon S Du, Ken-ichi Kawarabayashi, and Stefanie Jegelka. How neural networks extrapolate: From feedforward to graph neural networks. arXiv preprint arXiv:2009.11848, 2020. +[39] Zhaocheng Zhu, Zuobai Zhang, Louis-Pascal Xhonneux, and Jian Tang. Neural bellman-ford networks: A general graph neural network framework for link prediction. Advances in Neural Information Processing Systems, 34, 2021. + +# Checklist + +The checklist follows the references. Please read the checklist guidelines carefully for information on how to answer these questions. For each question, change the default [TODO] to [Yes] , [No] , or [N/A] . You are strongly encouraged to include a justification to your answer, either by referencing the appropriate section of your paper or providing a brief inline description. For example: + +• Did you include the license to the code and datasets? [Yes] See Section ??. +• Did you include the license to the code and datasets? [No] The code and the data are proprietary. +• Did you include the license to the code and datasets? [N/A] + +Please do not modify the questions and only use the provided macros for your answers. Note that the Checklist section does not count towards the page limit. In your paper, please delete this instructions block and only keep the Checklist section heading above along with the questions/answers below. + +1. For all authors... + +(a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes] We propose a novel approach to reinterpret both graph neural networks and dynamic programming, and show empirical gains from an architecture motivated by our blueprint. +(b) Did you describe the limitations of your work? [Yes] +(c) Did you discuss any potential negative societal impacts of your work? [N/A] Our work is of a theoretical nature. +(d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes] + +2. If you are including theoretical results... + +(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] Appropriate references to proofs are provided in all areas where proofs are missing. + +3. If you ran experiments... + +(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 aim to release the code at a future point. The data is publicly available. +(b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes] The data generation and base model implementation is publicly available within the CLRS benchmark. We detail the model extensions we made. +(c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [Yes] +(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] + +4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets... + +(a) If your work uses existing assets, did you cite the creators? [Yes] We cite the CLRS benchmark. +(b) Did you mention the license of the assets? [N/A] +(c) Did you include any new assets either in the supplemental material or as a URL? [N/A] +(d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [N/A] +(e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [N/A] Our data is abstract and algorithmically generated. + +5. If you used crowdsourcing or conducted research with human subjects... + +(a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A] +(b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A] +(c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A] \ No newline at end of file diff --git a/md/dev/zSkYVeX7bC4/zSkYVeX7bC4.md b/md/dev/zSkYVeX7bC4/zSkYVeX7bC4.md new file mode 100644 index 0000000000000000000000000000000000000000..80427715a3702ca2e124f8ca8e8ff9e50a67ab79 --- /dev/null +++ b/md/dev/zSkYVeX7bC4/zSkYVeX7bC4.md @@ -0,0 +1,171 @@ +# Exploring Length Generalization in Large Language Models + +Cem Anil ∗1, 3, Yuhuai $\mathbf { W } \mathbf { u } ^ { 2 }$ , Anders Andreassen1, Aitor Lewkowycz1 Vedant Misra1, Vinay Ramasesh1, Ambrose Slone1, Guy Gur-Ari1, Ethan Dyer1, Behnam Neyshabur1 + +1 Google Research, Blueshift Team 2 Google Research 3 University of Toronto, Vector Institute + +# Abstract + +The ability to extrapolate from short problem instances to longer ones is an important form of out-of-distribution generalization in reasoning tasks, and is crucial when learning from datasets where longer problem instances are rare. These include theorem proving, solving quantitative mathematics problems, and reading/- summarizing novels. In this paper, we run careful empirical studies exploring the length generalization capabilities of transformer-based language models. We first establish that naively finetuning transformers on length generalization tasks shows significant generalization deficiencies independent of model scale. We then show that combining pretrained large language models’ in-context learning abilities with scratchpad prompting (asking the model to output solution steps before producing an answer) results in a dramatic improvement in length generalization. We run careful failure analyses on each of the learning modalities and identify common sources of mistakes that highlight opportunities in equipping language models with the ability to generalize to longer problems. + +# 1 Introduction + +Many natural problems, such as theorem proving and program synthesis, have a notion of length that strongly correlates with the difficulty of the task. However, in these domains, the number of available problems typically drops rapidly as a function of problem length (e.g. Figure 2). Hence, it is desirable to learn from examples of shorter lengths to generalize to longer ones or at least reduce the number of samples required for longer examples. We refer to this type of problem as length generalization. + +Recent work on large language models (LLMs) has shown consistent improvement in their performance by scaling model and dataset size. However, such models are still incapable of length generalization. For example, [1] shows that even though scale helps with solving arithmetic problems, scale alone is likely insufficient for learning to solve instances of arbitrary lengths. This implies that models fail to learn the general algorithms that would enable this kind of generalization. Indeed, Razeghi et al. [2] showed that the performance of LLMs on mathematical calculations correlates with term frequency in the training data. This suggests that LLMs might have gained their current performance from surface-level memorization instead of learning to apply the correct algorithm. + +A recent line of work proposes to use a scratchpad, or chain-of-thought reasoning, when prompting LLMs [3, 4, 5] on multi-step tasks. Breaking down tasks into multiple small steps and presenting these steps to the model leads to improved performance across a variety of reasoning tasks including word problems, arithmetic, and code execution. + +We perform a systematic study of length generalization with transformer-based large language models. We consider problems in which learning an algorithm can in principle enable a model to extrapolate from short examples to problems of arbitrary length. In particular, we focus on two simple algorithmic tasks, parity and variable assignment, in which the model needs to keep track of a state in order to extrapolate to longer lengths (see Figure 1). These problems are illuminating because their simplicity allows us to probe the failure modes as well as contrast the learned solutions with the ground truth algorithm. They provide us with a setting to study how/when these large language models start to fail. + +![](images/28daa2131939cc297f4c5ca2606a07e7cb03e4ce2403875ba77120b0adcd546e.jpg) +Figure 1: Examples of variable assignment problems: Can transformer language models learn from short instances of the Variable Assignment task (left) to extrapolate to much longer instances (right)? Length generalization is the ability to learn from shorter/easier instances of a problem to handle longer/harder instances. +Table 1: Performance on length generalization tasks of three techniques that language models admit: (1) Finetuning, (2) Prompting (or in-context few-shot learning) and (3) Scratchpad (Chain-of-Thought reasoning). We find that each technique (and the combinations thereof) have different modes of failure and present different trade-offs regarding in and out-of-distribution coverage. $x$ signifies poor $\checkmark$ signifies nontrivial, $\checkmark$ signifies near-perfect performance. $( ^ { * } )$ Refers to task-dependency. + +
TechniquesIn-distributionOut-of-distributionImproves with scale
Fine-tunexxxx/
Prompting
Fine-tune + Prompting
Fine-tune + Scratchpadxxxx'
Prompting + Scratchpad
Fine-tune + Prompting + Scratchpad
+ +We study combinations of three kinds of techniques for LLMs: finetuning, few shot prompting (also referred to as in-context learning), and use of a scratchpad (also referred to as chain-of-thought), to understand the role of each method and the interplay among the three in length generalization. Interestingly, we observe non-trivial interactions among the three techniques; see Table 1. + +Contributions Our main contributions are as follows: + +• We define and characterize the problem of length generalization using notions such as state tracking, execution depth, and per-step error rate. We study and carefully design two tasks, parity and variable assignment, that measure length generalization (Section 2). • We find that in the finetuning regime, scaling data, model sizes, and compute does not improve length generalization (Section 3.1). We also observe that even when the model attains perfect in-distribution accuracy, it performs poorly in out-of-distribution domains. Surprisingly, different hyperparameter choices for finetuning have a large effect on length generalization performance, while having minimal effect on the final in-distribution performance (Section 3.3). • We establish finetuning with scratchpad also fails to generalize to longer problems, in contrast to what is suggested by previous works [3]. We look into three potential failure cases: positional encoding, the presence of distractors, and end of token prediction, and conclude that distractors are the main culprit of failures for length generalization (Section 4). We show that in the in-context learning regime, use of a scratchpad shows a qualitatively different behavior and significantly alleviates the decay of performance on longer problems. This capability is significant, as it implies that for LLMs, there are certain skills, like length generalization, that can be learned through in-context learning rather than through finetuning even in the presence of infinite data. This is in stark contrast to the common norms of machine learning (Section 5). + +![](images/341f141d4eb2c4e980dd2e4d564dd0d857a30fc17592091e4b6b86ac60c6908b.jpg) +Figure 2: Real world datasets have heavy tails in length: (left) Histogram of lengths for proofs presented in the Archive of Formal Proofs (right) Histogram of the number of tokens for solutions in the MATH dataset. [6] + +# 2 Length Generalization + +Many sequence tasks—especially ones that require reasoning capabilities—have problem instances that differ in terms of their lengths. Shorter instances are often easier to state, process, and handle, and require less compute to find the answer. By contrast, longer instances are more challenging to parse and require more compute to solve. Tasks that have a reasoning component are especially well represented in this category — multi-hop reasoning [7], program execution [8], deductive reasoning [9] and theorem proving [10], to name a few. Note that having to deal with differing problem lengths poses two significant challenges. First, it is often the case that one encounters longer problem instances than the ones ever encountered during training, and is required to extrapolate. Second, even though longer problem instances have much more variety, real-world datasets often contain few long instances (see Figure 2). Both of these challenges are exacerbated if learning agents are not able to generalize across and beyond the lengths they learn from during training. This paper is about investigating to what extent transformer based language models are able to observe short problem instances and extrapolate to longer ones. + +Instance Length as Number of Steps in a Markov Process It is possible to define problem length in many different ways to capture different aspects of problem difficulty. Does there exist a notion of length that would expose the same length-generalization-related problem structure observed in qualitatively very different settings? Such a framing would enable researchers to design algorithms and interventions that have the potential to generalize across a broad range of tasks. To this end, we take the approach of characterizing length in the context of a deterministic Markov process. From this perspective, length is simply the number of state transitions experienced by an initial world state. In other words, the data-generation process can be described as sampling an (1) initial state and a (2) variable number of state transformations to be applied sequentially on the initial state. The agent is provided both the initial state and the transformations, and is asked to predict the final state. This framing applies to a wide range of sequence problems, if not all of them—ranging from more mechanical tasks such as code and algorithm execution and theorem proving, to less structured tasks, such as solving math problems and summarizing novels. + +In our empirical investigation we focus on two synthetic tasks: parity and variable assignment. These tasks avoid problem-specific subtleties that could mislead our analyses, while strongly capturing the deterministic Markov process structure. + +# 2.1 Tasks + +Parity: The parity task is an age-old learning problem that requires the trained agent to predict whether a bit-string has an even or odd number of ones in it. For example, the parity of the bitstring $[ 0 , 1 , 1 , 0 , 1 ]$ is “odd" (or 1) as opposed to “even" (or 0), because there is an odd number of 1s in the bit-string. The parity task admits a sequential solution that enables length generalization in a straightforward way: simply process the bits left-to-right and record the parity of the bits processed so far as the state. The default notion of length in the parity task is the number of bits in the input. However, we also experiment with a version where the number of bits is kept constant, and the number of 1s (i.e. the parity flipping bit) is systematically varied. The number of 1s stands for the number of state changes contained in the input bit-string, and actually appears to capture a more relevant notion of length for transformer models (see Section 3.1). + +![](images/a00a76c9b7ed86ac918039a7be451907d3a6fd102c4ffc7274ceb559bef1d8d8.jpg) +Figure 3: Finetuned Length Generalization performance doesn’t improve with scale: Models of vastly different scales fail at length generalization on both Parity and Variable Assignment tasks, displaying identical generalization pathologies. The $\mathbf { X } ^ { \prime }$ -axis represents problem length and the y-axis represents the accuracy attained at that problem length. The training lengths are highlighted in grey. + +Boolean Variable Assignment Task: The Boolean Variable Assignment task is designed to capture arbitrarily long, potentially branching unidirectional execution flows. An instance of this task can be seen in Figure 1. The inputs consist of semantically correct (i.e. bug-free) Python programs in which each line contains a boolean variable assignment operation. The output is simply the value of the variable presented in the final line of the program. The sequential solution to this task is to simply execute the program line by line while keeping track of the state of all variables. + +The data generation procedure involves randomly generating execution flows that involve Boolean operations; see Supplementary Material (SM) for details. + +We focus our evaluations on two variants of this dataset. (1) The diverse variable assignment split consists of a wide range of boolean operators available and is intended to contain maximally diverse programs. (2) The chain-like variable assignment split consists only of operations that compose the values of already defined variables. This results in long chains of dependencies between the initial values of the variables and the queried one, ensuring that there are almost no redundant operations in the program (i.e. operations that can be removed without affecting the output of the program). This split emphasizes the sequential nature of the variable assignment problem. + +# 3 Standard Finetuning Fails at Length Generalization + +We begin by demonstrating that finetuning transformer models on length-generalization tasks results in poor out-of-distribution performance. In experiments we use LaMDA 2 decoder-only models. These checkpoints were trained using general natural language data. We use the AdaFactor optimizer [11] during finetuning, and tune the learning rate, batch size and dropout. We trained the networks until the in-distribution validation accuracy settles (20000 gradient steps for parity and 18000 gradient steps for variable assignment). The loss was only computed on the target tokens (i.e. the model wasn’t trained to model the input questions). + +# 3.1 Scale Doesn’t Improve Length Generalization + +Parity: We finetuned four pretrained LaMDA models with $2 4 4 \mathrm { m }$ , $4 2 2 \mathrm { m }$ , 1b and 64b parameters on the parity task, where the training distribution included randomly sampled bitstrings of length 10 to 21. We then evaluated the performance on bitstrings of length 3 to 40; see Figure 3. We find that model scale has a little effect on length generalization. + +Variable Assignment: We finetuned the same models on the chain-like Variable Assignment Task, described in Section 2. We kept the in-distribution lengths at 3 to 8, and evaluated the test performance on lengths 3 to 19. The results can be seen in Figure 3. Just like in the parity task, while the indistribution performance is (near) perfect, out-of-distribution performance degrades rapidly as length increases. To get a sense of just how weak the out-of-distribution performance is, we also trained a $4 2 2 \mathrm { m }$ model on the same dataset, except we shuffled the operations before feeding it to the model. This removes the sequential dependency between the operations, and helps us establish a strong baseline that only predicts the answers based on non-sequential, spurious correlations. The accuracy-length curves for the baseline can be found in SM. + +![](images/a6427a7a862407611aa2ed9be897b85a75bffdd9a641bb9e0039eb197af469ee.jpg) +Figure 4: Scratchpad finetuning displays poor length generalization: Scratchpad finetuning displays qualitatively similar length generalization pathologies as vanilla finetuning. The $\mathbf { X }$ -axis represents problem length and the $\mathsf { y }$ -axis represents the accuracy attained at that problem length. The training lengths are highlighted in grey. + +# 3.2 Transformers Prefer Parallel Strategies over Sequential Ones + +The results presented in Section 3.1 establish that, when presented with sequential length generalization problems, transformers are biased toward learning non-sequential “shortcut” solutions that fail at longer problem instances. We ran additional experiments to gain a better understanding of the nature of this generalization pattern. + +On parity, we ran finetuning on a different distribution of bit-strings: Instead of first randomly sampling the number of bits in the input bit-string, then sampling the values of the bits, we fixed the total number of bits in the input, and only varied the number of ones in the bit-string uniformly. We trained with 10 to 20 ones in the input distribution and tested on an interval containing 1 to 30 ones. This makes sure that the number of tokens (now fixed at 30) is now disambiguated from number of state changes, which for parity is equal to the number of ones. The difference between in and out-ofdistribution performance is even starker for this data distribution (Figure 5): while in-distribution performance was $100 \%$ , OOD performance was roughly equivalent to random prediction3. This suggests that the transformers are learning a non-sequential solution that involves counting the number of ones in the input, and then thresholding the output. This is not surprising, given that self-attention is an equivariant transformation capable of performing pooling operations like max-pooling [12]. This strategy doesn’t allow for knowledge transfer between problems of different lengths. Note that this bottom-up counting behaviour is complementary to the left-to-right counting behaviour displayed by recurrent models Suzgun et al. [13]. On the variable assignment dataset, we finetuned a $2 5 5 \mathrm { m }$ LaMDA model on the diverse split of the variable assignment dataset of programs up to 16 lines, and evaluated on the same data generating distribution up to 32 lines. We measured the evolution of the model’s accuracy with respect to training iterations on different program lengths (quantified by number of lines). The results are in SM. + +We again observed that a different notion of length (which we call computational graph depth) captures the difficulty of problem instances better than number of program operations. A variable assignment program can be represented as a computational graph where each node corresponds to a variable, and each edge corresponds to an operation. Computational graph depth is the length of the longest dependency chain that connects to the queried variable node. This notion of length corresponds to the highly parallelizable strategy of executing programs by iteratively resolving computational graph dependencies. We present two results that suggest that computational graph depth is a more relevant notion of length for transformers. (1) Inspecting the order of problem instances in which the trained transformer correctly solves this task, we find that performance is strongest on examples with small computational graph depth, even if these examples are long in terms of number of operations. (2) The transformer does a good job of handling programs with an out-of-distribution number of operations, but for which computational graph depth is in-distribution. + +![](images/9fcc406712f400af127fa3c74bdebd2d08b77a770dbc837be05d086127f84fb0.jpg) +Figure 5: (left) Complete lack of length generalization: Transformers trained on the parity task have difficulty generalizing to bit-strings that have a different number of 1s. (right) Sensitivity to hyperparameters: Trained networks sharing architecture, data and in-distribution loss can have very different length generalization performances. $l r$ stands “learning rate" and $b s$ stands for “batch size". + +# 3.3 In-Distribution Generalization Doesn’t Predict OOD Generalization on Length Generalization Tasks + +Prior work on out-of-distribution generalization establishes that in many tasks, in-distribution loss is a strong predictor of out-of-distribution generalization [14]. Our experiments on the parity task indicate that the distribution shift induced by changing problem lengths falls outside of the this category. Figure 5 shows how the same model trained on the same data achieving roughly the same in-distribution cross entropy loss behaves on OOD data, where the difference is solely induced by the choice of different hyperparameters. + +# 4 Scratchpad Finetuning Still Fails at Length Generalization + +It has been shown in prior work that it’s possible to get pretrained LLMs to solve a given task by not only outputting the answer, but also the solution steps behind it. Nye et al. [15] use scratchpad finetuning to achieve strong in-distribution performance on execution based tasks such as code execution and computing polynomials. While they also report modest length generalization results on integer arithmetic, we find that scratchpad finetuning suffers from similar length generalization pathologies than vanilla finetuning does. The results on parity and variable assignment tasks can be seen in Figure 4. The precise scratchpad strategies used for these tasks are described in detail in SM. + +Error analysis: To understand the causes of failure in training scratchpad strategies, we focused on two architectural choices that could account for the poor performance: (1) how transformers encode position information, and (2) whether the transformers are trained to predict an end-of-sequence (EOS) token. LaMDA models use T5 position biases [16] to handle position information. If the network is only trained with short instances, position biases that handle longer positional distances might not be trained, explaining poor length generalization. Similarly, Newman et al. [17] report that networks trained with EOS token prediction often suffer from generalizing to longer problem instances, because of the models’ tendency to emit EOS tokens prematurely, as well as the EOS tokens’ effect on the representations that get learned. + +We tested the extent to which these effects can explain lack of length generalization as follows. We padded both the input bit-strings and the scratchpad content with dummy padding tokens to make the token count the same. We also augmented the input and scratchpad targets with the same number of padding tokens on the left and right so that the relevant bit to attend to when executing the sequential scratchpad strategy corresponds to the same T5 position bias bin. Examples of the updated input-target pairs can be seen in SM. While this intervention helps, the trained models still display significant length generalization issues. + +To gain further insight about the source of the problem, we plotted how the scratchpad target prediction error rates change as a function of (1) how far along one is in constructing the scratchpad, and (2) the length of the input bit-string. The results can be seen in Figure 6. The fact that the model makes mistakes in in-distribution scratchpad steps when the input has an OOD length implies that the attention mechanism isn’t capturing the relevant part of the input to form the scratchpad output. See SM for additional analysis. + +![](images/6e63661cfa055e90e350e585395817ab7fcab3a41a4618fa3af03a9948034bd9.jpg) +Figure 6: (left) Effect of input length on per-step scratchpad accuracy: Points corresponds to the accuracy (y-axis) of the first $x$ scratchpad steps $\mathbf { \widetilde { x } }$ -axis) on parity instances of variable length (color). If the input length is out-of-distribution, even in-distribution scratchpad steps are inaccurate, implying the model hasn’t learned an attention pattern that generalizes to longer bit-strings. (right) Roughly constant per-step error rate: The per-step error rates of the LaMDA 128b model, few-shot finetuned on the coin-flip version of the parity task remain roughly constant across the scratchpad steps. This is in stark contrast with zero-shot scratchpad finetuned models, where the per-step error rates increase abruptly when the model is evaluated on OOD lengths. + +# 5 Scratchpad Prompting Significantly Improves Length Generalization + +Wei et al. [4], Nye et al. [15] and Lewkowycz et al. [5] showed that combining prompting (i.e. in-context learning) with scratchpad strategies present a powerful combination. They demonstrate that pretrained LLMs, without the help of any finetuning, can solve grade school math word problems and execute pieces of code with nontrivial correctness [15], when prompted with the right scratchpad strategy. We corroborate these findings, and report that scratchpad prompting endows pretrained LLMs with the capability of variable length template matching (see Figure 8). That is, in-context learning enables the model to “learn" solution steps from a small number of short instances, and apply the same template on significantly longer instances with a high degree of accuracy. + +# 5.1 Few-shot scratchpad + +Contrary to vanilla and scratchpad finetuning, we find that under the right conditions, few-shot scratchpad strategies sometimes significantly improves LLMs’ capability to extrapolate to lengths much further than what pretraining weights grant them. + +To evaluate the performance of few-shot conditioning with scratchpad inputs without any finetuning, we phrase the parity problem in natural language as a coin flipping task. An example for the few-shot prompts we used can be seen in Figure 8. Wei et al. [4] also report results on the coin-flip task: the scratchpad format we used differs from theirs in that while ours respects the sequential nature of the task (i.e. each coin flip corresponds to a step in the scratchpad solution), Wei et al. [4]’s scratchpad strategy involves summing up the number of coin flips, then deciding on the final output based on the evenness/oddness of the sum. Also, while they only test up to 4 flips, we go up to 20 flips while still attaining highly nontrivial accuracy levels. + +For the variable assignment task, our scratchpad strategy involves copying over the program that’s being executed, with comments added in between lines specifying the value of the variable that was assigned in the line above. Instances of this scratchpad strategy can be seen in SM. + +Figure 7 shows the performance of the pretrained LaMDA 128b model on the coin-flip version of the parity task. Figure 8 shows an instance of how a length 3 prompt can induce the model to correctly output a 20 step scratchpad. We find that with the right scratchpad prompt, LLMs are able to generate correct scratchpad solutions. This reduces the problem to simply filling in the content of the generation correctly by inferring the right state transitions without having to figure out how to extrapolate the solution template. + +![](images/62ee08c172d1a29393ede332bc6b0b0ef421e8bf90420876aca112016272bd0f.jpg) +Figure 7: Few-shot finetuning with scratchpad displays qualitatively different behaviour on parity and variable assignment tasks. On parity, where the non-finetuned model already performs very well, few-shotfinetuning with scratchpad leads to a significant performance boost over zero-shot finetuning with scratchpad. On variable assignment, where the base model doesn’t perform poorly, there’s not a significant gap between few-shot finetuning and zero-shot finetuning with scrathpad. The performance of OpenAI’s Codex model [18] on the variable assignment task is also provided. + +![](images/9ed0e6954ceb226e9507364402e122b470eb3395b0778bf394076ebe4539ff47.jpg) +Figure 8: Few-shot length generalization: The largest LaMDA model is able to map the scratchpad solution template from a few short exemplars onto much longer queries. + +Few-Shot Finetuning with Scratchpad Strategies: Does combining finetuning, few-shot prompt ing, and scratchpad strategies improve length generalization? + +We find that the answer is yes in the case of parity. As seen in Figure 7, few-shot finetuning performs significantly better than the baseline model, both on in- and out-of-distribution lengths. Note that the vanilla (i.e. no shot) finetuning baseline also outperforms the no-finetuning baseline, it actually does worse on the larger lengths — a pathology that doesn’t appear with few-shot finetuning. + +The results point to a qualitatively different picture for the variable assignment task. Both few-shot finetuning and vanilla finetuning result in similar length generalization behavior (Figure 7). We hypothesize that this distinction is caused by the different pretrained performances that the model displays on these tasks: while length generalization is already strong with no finetuning on parity, that’s not the case for variable assignment. In the latter case, the model is forced to acquire a new skill via finetuning, which displays the same pathologies as zero-shot finetuning with scratchpad. As a sanity check, we evaluated the (few-shot) finetuned performance of the pretrained model on an alternative, synthetic prompt style that yields poor performance without any pretraining: As expected by the aforementioned hypothesis, we observed that the few-shot finetuned model on this task also shows significant length generalization pathologies. The results can be found in SM. We leave a more rigorous evaluation of this hypothesis as future work. + +# 6 Related Works + +There have been many attempts to study generalization from shorter/easier to longer/harder examples. + +Challenges in length generalization: Several existing works have investigated pathologies that arise when models are asked to generalize to processing and generating longer (measured by number of tokens) sequences. Newman et al. [17] find that sequence models trained with and in the absence of the end-of-sequence token display qualitatively different length extrapolation behaviour and learn different representations. Dubois et al. [19] proposes modifications to the commonly used dot-product attention to improve the models’ ability to extrapolate to longer sequences. Murray and Chiang [20] demonstrate that neural machine translation models tend to have a bias towards generating shorterthan-desired translations. Yehudai et al. [21] show that length generalization issues are also present in training graph neural networks, where extrapolating across graph size presents a challenge. Ju et al. [22] propose a new attention mechanism to facilitate recurrent processing in transformer models. Press et al. [23] propose modifying transformer attention biases to facilitate generalization beyond the training context length. Concurrent work [24] propose a synthetic dataset named LEGO (Learning Equality and Group Operations), an instantiation of which resembles our variable assignment task where the only boolean operations allowed are assign and negate and assign, and overriding the values of variables is not allowed. Their analyses on OOD generalization largely complement ours: while we focus on decoder-only architectures and scratchpad strategies as a way of carrying over state, they focus on encoder-only architectures, and investigate the effect of weight-sharing. + +Easy-to-Hard generalization: Schwarzschild et al. [25] and Bansal et al. [26] use weight-tied neural networks to generalize from easy to hard examples. Schwarzschild et al. [25] also provide three tasks to benchmark easy-to-hard generalization. Dehghani et al. [27] and Kaiser and Sutskever [28] assess the capabilities of their proposed architectures on easy-to-hard generalization problems. + +Inductive Biases Related to Lenght Generalization: McCoy et al. [29] study the inductive bias of seq-to-seq learners on English question formation and English tense reinflection tasks and find that LSTM and GRU networks often display differing strategies, caused by the use of differing activation functions. Suzgun et al. [13] find that recurrent networks can perform dynamical counting, and encode hierarchical representations, which enables them to solve nontrivial Dyck tasks using $\mathbf { k }$ -counters. Kharitonov and Chaabouni [30] also study the inductive bias of different architectures, and conclude that transformer and LSTM architectural have a tendency to learn hierarchical strategies, whereas CNN based strategies display more linear structure. He et al. [31] propose a method to learn natural inference models that are not biased on spurious correlations. McCoy et al. [32] show that transformer models that display strong performance in natural language inference can have superficial biases that fool them in systematic ways and proposes a framework to think about these biases. + +# 7 Conclusion + +The ability to learn from shorter/easier problem instances to generalize to longer/harder ones is a key capability in a large number of tasks, especially ones requiring reasoning. We defined the concept of length generalization and measured language models’ length generalization capabilities. After conducting careful experiments using finetuning, scratchpads, and few-shot prompting, we reached the following conclusions: (1) Generalizing in length is a challenge for language models at least up to the 100B parameter scale. Both vanilla finetuning and finetuning with scratchpads suffer from a lack of length generalization caused by models’ tendency to pick up non-sequential pattern that don’t apply to longer problem instances. (2) Few-shot scratchpad prompting enables pretrained large language models to pick up scratchpad-templates that extrapolate to arbitrary lengths, leading to dramatic improvements on longer problem instances. Unlike raw finetuning, this approach does scale with model size [4]. (3) Trying to further enhance the performance of few-shot scratchpad prompted LLMs via finetuning yields mixed results, depending on the non-finetuned performance of the base model at the target task. We emphasize that the aforementioned few-shot variable length pattern matching capability — something that doesn’t require changing model architecture — offers a qualitatively different approach to handle length generalization in contrast to prior art that introduced architectural modifications to achieve the same goal. This capability is also significant in that it implies that for LLMs, there are certain skills, like length generalization, that can be learned better through in-context learning rather than through finetuning, even in the presence of infinite data. + +References +[1] Tom Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah, Jared D Kaplan, Prafulla Dhariwal, Arvind Neelakantan, Pranav Shyam, Girish Sastry, Amanda Askell, et al. Language models are few-shot learners. Advances in neural information processing systems, 33:1877–1901, 2020. +[2] Yasaman Razeghi, Robert L Logan IV, Matt Gardner, and Sameer Singh. Impact of pretraining term frequencies on few-shot reasoning. arXiv preprint arXiv:2202.07206, 2022. +[3] Maxwell Nye, Anders Johan Andreassen, Guy Gur-Ari, Henryk Michalewski, Jacob Austin, David Bieber, David Dohan, Aitor Lewkowycz, Maarten Bosma, David Luan, et al. Show your work: Scratchpads for intermediate computation with language models. arXiv preprint arXiv:2112.00114, 2021. +[4] 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, 2022. URL https://arxiv.org/abs/2201.11903. +[5] Aitor Lewkowycz, Anders Andreassen, David Dohan, Ethan Dyer, Henryk Michalewski, Vinay Ramasesh, Ambrose Slone, Cem Anil, Imanol Schlag, Theo Gutman-Solo, et al. Solving quantitative reasoning problems with language models. arXiv preprint arXiv:2206.14858, 2022. +[6] Dan Hendrycks, Collin Burns, Saurav Kadavath, Akul Arora, Steven Basart, Eric Tang, Dawn Song, and Jacob Steinhardt. Measuring mathematical problem solving with the math dataset. arXiv preprint arXiv:2103.03874, 2021. +[7] Haoyu Wang, Mo Yu, Xiaoxiao Guo, Rajarshi Das, Wenhan Xiong, and Tian Gao. Do multi-hop readers dream of reasoning chains? arXiv preprint arXiv:1910.14520, 2019. +[8] 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. +[9] Peter Clark, Oyvind Tafjord, and Kyle Richardson. Transformers as soft reasoners over language. arXiv preprint arXiv:2002.05867, 2020. +[10] Yuhuai Wu, Albert Qiaochu Jiang, Jimmy Ba, and Roger Grosse. Int: An inequality benchmark for evaluating generalization in theorem proving. arXiv preprint arXiv:2007.02924, 2020. +[11] Noam Shazeer and Mitchell Stern. Adafactor: Adaptive learning rates with sublinear memory cost. In International Conference on Machine Learning, pages 4596–4604. PMLR, 2018. +[12] Juho Lee, Yoonho Lee, Jungtaek Kim, Adam Kosiorek, Seungjin Choi, and Yee Whye Teh. Set transformer: A framework for attention-based permutation-invariant neural networks. In International Conference on Machine Learning, pages 3744–3753. PMLR, 2019. +[13] Mirac Suzgun, Sebastian Gehrmann, Yonatan Belinkov, and Stuart M Shieber. Lstm networks can perform dynamic counting. arXiv preprint arXiv:1906.03648, 2019. +[14] Vaishnavh Nagarajan, Anders Andreassen, and Behnam Neyshabur. Understanding the failure modes of out-of-distribution generalization. arXiv preprint arXiv:2010.15775, 2020. +[15] Maxwell Nye, Anders Johan Andreassen, Guy Gur-Ari, Henryk Michalewski, Jacob Austin, David Bieber, David Dohan, Aitor Lewkowycz, Maarten Bosma, David Luan, et al. Show your work: Scratchpads for intermediate computation with language models. arXiv preprint arXiv:2112.00114, 2021. +[16] 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. +[17] Benjamin Newman, John Hewitt, Percy Liang, and Christopher D Manning. The eos decision and length extrapolation. arXiv preprint arXiv:2010.07174, 2020. +[18] Mark Chen, Jerry Tworek, Heewoo Jun, Qiming Yuan, Henrique Ponde de Oliveira Pinto, Jared Kaplan, Harri Edwards, Yuri Burda, Nicholas Joseph, Greg Brockman, et al. Evaluating large language models trained on code. arXiv preprint arXiv:2107.03374, 2021. +[19] Yann Dubois, Gautier Dagan, Dieuwke Hupkes, and Elia Bruni. Location attention for extrapolation to longer sequences. arXiv preprint arXiv:1911.03872, 2019. +[20] Kenton Murray and David Chiang. Correcting length bias in neural machine translation. arXiv preprint arXiv:1808.10006, 2018. +[21] Gilad Yehudai, Ethan Fetaya, Eli Meirom, Gal Chechik, and Haggai Maron. From local structures to size generalization in graph neural networks. In International Conference on Machine Learning, pages 11975–11986. PMLR, 2021. +[22] Da Ju, Stephen Roller, Sainbayar Sukhbaatar, and Jason Weston. Staircase attention for recurrent processing of sequences. arXiv preprint arXiv:2106.04279, 2021. +[23] Ofir Press, Noah Smith, and Mike Lewis. Train short, test long: Attention with linear biases enables input length extrapolation. In International Conference on Learning Representations, 2022. URL https://openreview.net/forum?id $\bar { }$ R8sQPpGCv0. +[24] Yi Zhang, Arturs Backurs, Sébastien Bubeck, Ronen Eldan, Suriya Gunasekar, and Tal Wagner. Unveiling transformers with lego: a synthetic reasoning task. arXiv preprint arXiv:2206.04301, 2022. +[25] Avi Schwarzschild, Eitan Borgnia, Arjun Gupta, Furong Huang, Uzi Vishkin, Micah Goldblum, and Tom Goldstein. Can you learn an algorithm? generalizing from easy to hard problems with recurrent networks. Advances in Neural Information Processing Systems, 34, 2021. +[26] Arpit Bansal, Avi Schwarzschild, Eitan Borgnia, Zeyad Emam, Furong Huang, Micah Goldblum, and Tom Goldstein. End-to-end algorithm synthesis with recurrent networks: Logical extrapolation without overthinking. arXiv preprint arXiv:2202.05826, 2022. +[27] Mostafa Dehghani, Stephan Gouws, Oriol Vinyals, Jakob Uszkoreit, and Łukasz Kaiser. Universal transformers. arXiv preprint arXiv:1807.03819, 2018. +[28] Łukasz Kaiser and Ilya Sutskever. Neural gpus learn algorithms. arXiv preprint arXiv:1511.08228, 2015. +[29] R Thomas McCoy, Robert Frank, and Tal Linzen. Does syntax need to grow on trees? sources of hierarchical inductive bias in sequence-to-sequence networks. Transactions of the Association for Computational Linguistics, 8:125–140, 2020. +[30] Eugene Kharitonov and Rahma Chaabouni. What they do when in doubt: a study of inductive biases in seq2seq learners. arXiv preprint arXiv:2006.14953, 2020. +[31] He He, Sheng Zha, and Haohan Wang. Unlearn dataset bias in natural language inference by fitting the residual. arXiv preprint arXiv:1908.10763, 2019. +[32] R Thomas McCoy, Ellie Pavlick, and Tal Linzen. Right for the wrong reasons: Diagnosing syntactic heuristics in natural language inference. arXiv preprint arXiv:1902.01007, 2019. +[33] 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. \ No newline at end of file