ZHANGYUXUAN-zR commited on
Commit
88e087b
·
verified ·
1 Parent(s): 49a19ca

Add files using upload-large-folder tool

Browse files
Files changed (50) hide show
  1. md/dev/17RDXeF-skZ/17RDXeF-skZ.md +343 -0
  2. md/dev/3IyL2XWDkG/3IyL2XWDkG.md +392 -0
  3. md/dev/42zs3qa2kpy/42zs3qa2kpy.md +550 -0
  4. md/dev/4AZz9osqrar/4AZz9osqrar.md +0 -0
  5. md/dev/4p6_5HBWPCw/4p6_5HBWPCw.md +471 -0
  6. md/dev/5Xc1ecxO1h/5Xc1ecxO1h.md +284 -0
  7. md/dev/6Dz7RiRiMFd/6Dz7RiRiMFd.md +360 -0
  8. md/dev/7r6kDq0mK_/7r6kDq0mK_.md +396 -0
  9. md/dev/AIqC7F7xV-d/AIqC7F7xV-d.md +460 -0
  10. md/dev/Bct2f8fRd8S/Bct2f8fRd8S.md +331 -0
  11. md/dev/E0zOKxQsZhN/E0zOKxQsZhN.md +505 -0
  12. md/dev/F72ximsx7C1/F72ximsx7C1.md +0 -0
  13. md/dev/G5ADoRKiTyJ/G5ADoRKiTyJ.md +258 -0
  14. md/dev/KLaDXLAzzFT/KLaDXLAzzFT.md +0 -0
  15. md/dev/NbkjMn7X8H/NbkjMn7X8H.md +513 -0
  16. md/dev/OUIFPHEgJU/OUIFPHEgJU.md +0 -0
  17. md/dev/PqvMRDCJT9t/PqvMRDCJT9t.md +857 -0
  18. md/dev/QNBzcgY0f4e/QNBzcgY0f4e.md +526 -0
  19. md/dev/Rg1LG7wtd2D/Rg1LG7wtd2D.md +0 -0
  20. md/dev/S874XAIpkR-/S874XAIpkR-.md +224 -0
  21. md/dev/UYneFzXSJWh/UYneFzXSJWh.md +0 -0
  22. md/dev/VB75Pi89p7/VB75Pi89p7.md +276 -0
  23. md/dev/WbxHAzkeQcn/WbxHAzkeQcn.md +0 -0
  24. md/dev/Y6A4-R_Hgsw/Y6A4-R_Hgsw.md +321 -0
  25. md/dev/YJ7o2wetJ2/YJ7o2wetJ2.md +0 -0
  26. md/dev/ZumkmSpY9G4/ZumkmSpY9G4.md +444 -0
  27. md/dev/_3ELRdg2sgI/_3ELRdg2sgI.md +285 -0
  28. md/dev/_LceCyuVcH/_LceCyuVcH.md +269 -0
  29. md/dev/_SJ-_yyes8/_SJ-_yyes8.md +261 -0
  30. md/dev/_VjQlMeSB_J/_VjQlMeSB_J.md +295 -0
  31. md/dev/bZjxxYURKT/bZjxxYURKT.md +0 -0
  32. md/dev/cGDAkQo1C0p/cGDAkQo1C0p.md +0 -0
  33. md/dev/cOtBRgsf2fO/cOtBRgsf2fO.md +546 -0
  34. md/dev/edONMAnhLu-/edONMAnhLu-.md +824 -0
  35. md/dev/gJW8hSGBys8/gJW8hSGBys8.md +0 -0
  36. md/dev/gMS6FVZvmF/gMS6FVZvmF.md +0 -0
  37. md/dev/gtCPWaY5bNh/gtCPWaY5bNh.md +305 -0
  38. md/dev/hy0a5MMPUv/hy0a5MMPUv.md +443 -0
  39. md/dev/ksVGCOlOEba/ksVGCOlOEba.md +282 -0
  40. md/dev/nXmU89Rfmgg/nXmU89Rfmgg.md +303 -0
  41. md/dev/shpkpVXzo3h/shpkpVXzo3h.md +396 -0
  42. md/dev/tHK5ntjp-5K/tHK5ntjp-5K.md +445 -0
  43. md/dev/u03xn1COsO/u03xn1COsO.md +0 -0
  44. md/dev/uCXNOeL0TG/uCXNOeL0TG.md +444 -0
  45. md/dev/uloenYmLCAo/uloenYmLCAo.md +305 -0
  46. md/dev/xDaoT2zlJ0r/xDaoT2zlJ0r.md +506 -0
  47. md/dev/xMJWUKJnFSw/xMJWUKJnFSw.md +0 -0
  48. md/dev/xijYyYFlRIf/xijYyYFlRIf.md +296 -0
  49. md/dev/z7p2V6KROOV/z7p2V6KROOV.md +0 -0
  50. md/dev/zkk_7sV6gm8/zkk_7sV6gm8.md +458 -0
md/dev/17RDXeF-skZ/17RDXeF-skZ.md ADDED
@@ -0,0 +1,343 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # DOING FAST ADAPTATION FAST: CONDITIONALLY INDEPENDENT DEEP ENSEMBLES FOR DISTRIBUTION SHIFTS
2
+
3
+ Anonymous authors Paper under double-blind review
4
+
5
+ # ABSTRACT
6
+
7
+ Classifiers in a diverse ensemble capture distinct predictive signals, which is valuable for datasets containing multiple strongly predictive signals. Performing fast adaptation at test time allows us to generalize to distributions where certain signals are no longer predictive, or to avoid relying on sensitive or protected attributes. However, ensemble learning is often expensive, even more so when we need to enforce diversity constraints between the high-dimensional representations of the classifiers. Instead, we propose an efficient and fast method for learning ensemble diversity. We minimize conditional mutual information of the output distributions between classifiers, a quantity which can be cheaply and exactly computed from empirical data. The resulting ensemble contains individually strong predictors that are only dependent because they predict the label. We demonstrate the efficacy of our method on shortcut learning tasks. Performing fast adaptation on our ensemble selects shortcut-invariant models that generalize well to test distributions where the shortcuts are uncorrelated with the label.
8
+
9
+ # 1 INTRODUCTION
10
+
11
+ Some of the strongest scientific theories are supported by multiple sources of evidence, a principle described by 19th century philosopher William Whewell as “consilience”. Evolution is one such example, having been firmly corroborated by fields ranging from paleontology to genetics. In many real-world applications of machine learning, datasets can similarly contain multiple predictive signals that explain the label well. In these settings, a standard model typically learns from a combination of predictive features (Ross et al., 2018; Kirichenko et al., 2022). Such a model will fail to generalize to distribution shifts that break the correlation between certain signals and the label (Hovy & Søgaard, 2015; Hashimoto et al., 2018; Puli et al., 2022).
12
+
13
+ This shortcoming can be addressed by learning a diverse set or ensemble of classifiers. Such methods typically exploit some notion of independence to learn multiple classifiers that rely on different predictive signals. We can then perform fast adaptation, using a small amount of out-of-distribution (OOD) validation data to select the model that generalizes best. Learning diversity is also beneficial in and of itself: these classifiers are empirically shown to be more human-interpretable than if we were to fit a single model (Ross et al., 2018), possibly because they learn disentangled representations that correspond to natural factors of variation (Shu et al., 2019).
14
+
15
+ The key challenge is quantifying the right notion of diversity. Existing work has exploited concepts like input gradient or parameter orthogonality as a proxy for statistical independence (Teney et al., 2021; Xu et al., 2021). To tackle OOD generalization, which fundamentally requires additional assumptions or data beyond the observed training data (Bareinboim et al., 2022; Scholkopf et al., ¨ 2021), previous work have also assumed access to unlabelled test data and measured disagreement on those examples (Lee et al., 2022; Pagliardini et al., 2022). However, these objectives or assumptions are often prohibitive or unrealistic in real-world settings. For example, group-balanced test data is not always obtainable, e.g. when deploying a pneumonia model to multiple new hospitals whose patient profiles may change over time. Another costly example is enforcing input gradient orthogonality on high-dimensional covariates like images or text, where it can be challenging to avoid learning from orthogonal covariates of the same underlying feature, such as neighboring pixels.
16
+
17
+ To avoid the pitfalls of operating in high-dimensional input or parameter space, a promising line of work instead adopts the information-theoretic perspective and tackles the problem as representation learning. These approaches apply the information bottleneck method and minimize mutual information between the representations learnt by each classifier. Such an objective forces the classifiers to rely on distinctly meaningful features for prediction. Most notably, Pace et al. (2020) and Rame & Cord (2021) minimize mutual information between the classifier representations conditioned on the label. Since any pair of predictors cannot both be accurate while remaining unconditionally independent, the extra conditioning prevents learning weak classifiers. The resulting ensemble contains accurate classifiers that nevertheless rely on distinct predictive signals. The only core assumption is that the underlying predictive signals are themselves conditionally independent.
18
+
19
+ These approaches are conceptually appealing but practically challenging. Mutual information between high-dimensional representations is intractable and must be approximated, either via variational (e.g. Fischer, 2020) or contrastive (e.g. Oord et al., 2018) bounds. Furthermore, such approximations are computationally expensive, a problem that is compounded in the ensemble setting where we wish to train multiple classifiers speedily.
20
+
21
+ We seek to learn ensemble diversity fast and effectively. Our key insight is that it suffices to enforce conditional independence on the output distributions of the classifiers. Our first contribution is proposing conditional mutual information (CMI) between output distributions as the regularizing objective. Assuming conditionally independent predictive signals, enforcing CMI between output distributions also guarantees that the ensemble where separate predictive signals are learnt by separate classifiers is a minimizing solution. Since the output distribution is categorical, CMI can be cheaply and exactly computed from empirical data. In addition, our method avoids using additional sources of data that cannot be found in many real-world domains, such as unlabelled test data or “group” labels for each predictive signal in the dataset. We only permit a small amount of validation data from the test distribution for (1) hyperparameter tuning and (2) selecting the final predictor from our ensemble. We dub our approach as Conditionally Independent Deep Ensembles (CoDE).
22
+
23
+ Our second contribution is evaluating CoDE on benchmark datasets for shortcut learning (Geirhos et al., 2020). Shortcuts are signals that are (i) highly but spuriously correlated to the label in the training distribution, possibly due to biases in data collection or other systematic pre-processing errors (Torralba & Efros, 2011), and (ii) preferentially learnt by a neural network, possibly due to simplicity biases (Shah et al., 2020) or architectural biases (e.g. convolutional neural networks (CNNs) relying on texture over shape (Baker et al., 2018)). An empirical risk minimizing (ERM) model will rely on shortcuts and fail to generalize to test distributions where they are no longer correlated to the label. This is a natural application for our method as the core assumption of conditional independence applies to many such datasets — for example, in natural images, the foreground is typically the label and is thus conditionally independent from the background (shortcut). We show that CoDE effectively recovers an ensemble where the shortcut features and the true signal are learnt by separate classifiers.
24
+
25
+ # 2 PRELIMINARIES: SETUP AND NOTATION
26
+
27
+ In Section 3, we will fully motivate the assumptions behind our model of the data-generating process (DGP). However, we describe it here first to establish key terminology and concepts.
28
+
29
+ Data-Generating Process Let $\mathbf { z }$ denote the set of latent factors that generate the set of observed features $\mathbf { x } \in \mathbb { R } ^ { P }$ . Let $y \in \{ 0 , 1 , \dotsc , K - 1 \}$ denote the label. The data $p _ { e } ( \mathbf { x } , y , \mathbf { z } )$ is generated from a family of distributions indexed by $e$ , the environment. We only consider: (i) a single training environment $\mathbf { \boldsymbol { e } } _ { \mathbf { \lambda } } = t { \boldsymbol { r } } _ { \mathbf { \lambda } } $ ), from which we have access to i.i.d. labelled training examples $D _ { t r } \ = \ \{ { \bf x } _ { i } , y _ { i } \} _ { i = 1 } ^ { N }$ , and (ii) a test environment $\mathit { \Pi } _ { \mathrm { ~ e ~ } } = \mathit { \Pi } _ { t e }$ ), from which we draw unlabelled test examples that our model should perform well on. We also allow access to a small set of labelled validation data $D _ { v a l } = \{ \mathbf { x } _ { i } , y _ { i } \} _ { i = 1 } ^ { N ^ { \prime } }$ from the test environment, which is used only for hyperparameter tuning and ensembling (i.e. constructing the final model from the set of learnt classifiers).
30
+
31
+ We make the following assumptions on the DGP:
32
+
33
+ (i) all label information is encoded by $\mathbf { z }$ , i.e. $p _ { e } ( y | \mathbf { x } , \mathbf { z } ) = p _ { e } ( y | \mathbf { z } )$ for all $e$ (ii) $p _ { e } ( \mathbf { x } | \mathbf { z } ) = p ( \mathbf { x } | \mathbf { z } )$ is invariant across all $e$
34
+
35
+ (iii) $p _ { e } ( { \bf z } ) > 0$ for all $e$ and $\mathbf { z }$
36
+ (iv) $p _ { e } ( y ) > 0$ for all $e$ and $y$
37
+ (v) [Latent Conditional Independence] $z _ { i } \perp \perp z _ { j } \mid y$ for all $e$ and $i , j$
38
+
39
+ Based on these assumptions, we can factorize $p _ { e } ( \mathbf { x } , y , \mathbf { z } )$ as:
40
+
41
+ $$
42
+ p _ { e } ( \mathbf { z } , \mathbf { x } , y ) = p _ { e } ( y ) \left( \prod _ { i = 1 } ^ { L } p _ { e } ( z _ { i } | y ) \right) p ( \mathbf { x } | \mathbf { z } )
43
+ $$
44
+
45
+ Example: ColoredMNIST As introduced in Arjovsky et al. (2019), $y$ is a binary label which determines color $( z _ { 1 } \in \{ \mathrm { r e d } , \mathrm { g r e e n } \} )$ with probability $p _ { c }$ and digit $( z _ { 2 } \in \{ 0 \ – 4 , 5 \ – 9 \} )$ ) with probability $p _ { d }$ . $p _ { c }$ and $p _ { d }$ are independently chosen. In the training distribution, $p _ { c } = 0 . 2 5$ and $p _ { d } = 0 . 1$ , as such, an ERM model will primarily learn from color. $p _ { c }$ and $p _ { d }$ can be arbitrary in the test distribution.
46
+
47
+ Example: Waterbirds As introduced in Sagawa et al. (2019), $y$ is a binary label determining if the image represents a water or land bird. It perfectly determines the foreground $( z _ { 1 } \in \ \left\{ \begin{array} { l l } { \end{array} } \right.$ water bird, land bird}) and is highly but spuriously correlated to the background $( z _ { 2 } \in$ {water, land}) in the training distribution. An ERM model will learn from background features.
48
+
49
+ Group Robustness When $\mathbf { z }$ is discrete, each possible value that $\mathbf { z }$ can take is known as a group. Due to the spurious correlations created by $p _ { t r } ( z _ { i } | y )$ , groups that are highly represented in the training set are called “majority groups”, and poorly-represented groups are “minority groups”. Group robustness refers to the goal of generalizing well on all groups and is one natural way of evaluating if a model has been learning shortcuts. For example, both ColoredMNIST and Waterbirds admits four groups formed by the Cartesian product of $z _ { 1 }$ and $z _ { 2 }$ .
50
+
51
+ Ensembles and Fast Adaptation A classifier $f ( \mathbf { x } ) : = p _ { \theta } ( y | \mathbf { x } )$ is parametrized by $\theta$ and outputs class probabilities. We will use $\hat { y } : = p _ { \theta } ( y )$ to denote the unconditional output distribution. We use the term “ensemble” loosely to refer to a set of or sequentially. (Section 4 clarifies the relations $M$ classifiers to tradition $\{ f _ { m } \} _ { m = 1 } ^ { M }$ that can be learnt joinle methods.) After all $M$ classifiers are learnt, the final model $\theta ^ { * }$ is selected using validation data $D _ { v a l }$ :
52
+
53
+ $$
54
+ \theta ^ { * } = \arg \operatorname* { m i n } _ { \theta _ { m } , m \in \{ 1 , \dots , M \} } \frac { 1 } { N ^ { \prime } } \sum _ { i = 1 } ^ { N ^ { \prime } } \log p _ { \theta _ { m } } ( y _ { i } | \mathbf { x } _ { i } )
55
+ $$
56
+
57
+ This process is referred to as fast adaptation.
58
+
59
+ # 3 CONDITIONALLY INDEPENDENT DEEP ENSEMBLES
60
+
61
+ To motivate our approach and the assumptions made in (1), we first define what it means to learn a diverse ensemble and explain why conditional independence is a sound measure of diversity.
62
+
63
+ # 3.1 DIVERSITY AS CONDITIONAL INDEPENDENCE
64
+
65
+ Diverse classifiers utilize separate predictive signals, intuitively, they predict the “same things for different reasons” (Rame & Cord, 2021). Our setup in Section 2 formalizes this notion of “different reasons” by explicitly defining the latent variable $\mathbf { z }$ , which models the total underlying set of predictive signals that relate $\mathbf { x }$ to $y$ . A classifier that learns a mapping from $\mathbf { x }$ to $y$ can then be interpreted as implicitly inferring $\mathbf { z }$ from $\mathbf { x }$ and learning a mapping from $\mathbf { z }$ to $y$ . We can thus define diverse classifiers that rely on separate predictive signals as learning from separate dimensions or subspaces of $\mathbf { z }$ .
66
+
67
+ To formalize the idea that a classifier $f$ learns using only a subspace of $\mathbf { z }$ , one naive approach might be to define $f$ as relying only on the subspace ${ \mathbf z } _ { [ a ] }$ if and only if (some distribution computed from) $f$ is independent of its complement ${ \mathbf z } \backslash { \mathbf z } _ { [ a ] }$ . This definition is convenient as it suggests that the appropriate objective to learn a diverse ensemble is simply to enforce statistical independence between the classifiers. This follows because two classifiers that rely on overlapping subspaces of $\mathbf { z }$ will necessarily be dependent.
68
+
69
+ However, the definition above assumes that distinct predictive signals (i.e. subspaces of $\mathbf { z }$ ) are themselves unconditionally independent. This is not always true when a dataset contains multiple strongly predictive signals. Dimensions of $\mathbf { z }$ can be dependent by virtue of their correlation to $y$ Classifiers that learn from such signals will similarly be dependent. Shortcut learning is precisely a problem because meaningful and spurious features are highly correlated in the training environment.
70
+
71
+ This conundrum can be resolved by establishing independence of the latent factors with conditioning on $y$ . Doing so is equivalent to assuming that upon knowing the true label, observing one set of features yields no additional information about other features. This is usually a realistic assumption to make. As the Waterbirds example in Section 2 shows, backgrounds and foregrounds are often conditionally independent in the test distributions we care about. This motivates our assumption (v) of latent conditional independence in Section 2, where the individual factors $z _ { i }$ are conditionally independent given $y$ . We formalize this notion of “diversity as conditional independence” below.
72
+
73
+ Definition 3.1. Let $\mathbf { z } _ { [ a ] } : = ( z _ { a _ { 1 } } , \ldots , z _ { a _ { l } } )$ denote some subspace of $\mathbf { z }$ . Let $\hat { h } ( f )$ denote some distribution computed from $f$ . We say $f$ is invariant to ${ \mathbf z } _ { [ a ] }$ if $\hat { h } \perp \perp ( z _ { a _ { 1 } } , \ldots , z _ { a _ { l } } ) | y$ . Let $\mathbf { z } _ { [ i ] }$ be the maximal subset of $\mathbf { z }$ that $f$ is invariant to. Then $f$ is said to rely on $\mathbf { z } _ { - [ i ] } : = \mathbf { z } \backslash \mathbf { z } _ { [ i ] }$ for prediction.
74
+
75
+ Definition 3.2. Let $f$ and $f ^ { \prime }$ be a pair of classifiers that rely on $\mathbf { z } _ { [ i ] }$ and $\mathbf { z } _ { [ i ^ { \prime } ] }$ respectively. $f$ and $f ^ { \prime }$ are said to be diverse if $\mathbf { z } _ { [ i ] } \bigcap _ { . . } \mathbf { z } _ { [ i ^ { \prime } ] } = \emptyset$ . An ensemble $\{ f _ { m } \} _ { m = 1 } ^ { M }$ is diverse if every pair of classifiers $f _ { j } , f _ { k }$ in the ensemble are diverse.
76
+
77
+ It follows immediately from Definition 3.2 that diverse classifiers must themselves be conditionally independent, i.e. $\hat { h } _ { i } \perp \perp \hat { h } _ { j } | y$ . Our training objective for learning a diverse ensemble should therefore enforce conditional independence on all pairs of classifiers:
78
+
79
+ $$
80
+ \begin{array} { l } { \displaystyle \arg \underset { \theta _ { 1 } , \dots , \theta _ { M } } { \operatorname* { m a x } } \sum _ { i = 1 } ^ { N } \sum _ { m = 1 } ^ { M } \log p _ { \theta _ { m } } ( y _ { i } | \mathbf { x } _ { i } ) } \\ { \displaystyle \mathrm { s u b j e c t ~ t o } \hat { h } _ { s } \perp \hat { h } _ { t } \vert y \qquad \forall s , t } \end{array}
81
+ $$
82
+
83
+ We can interpret (3) as follows: the main objective guarantees that the learnt ensemble contains individually strong predictors, whereas the constraint guarantees that each predictor is uninformative of the others when conditioned on the label. Put together, (3) learns classifiers that rely on conditionally independent subspaces of $\mathbf { z }$ and thus provide no additional information about each other. As is typical in machine learning (Krogh & Hertz, 1991; Deb, 2014), we optimize an unconstrained analogue of (3) by expressing the constraint as a regularization term.
84
+
85
+ # 3.2 ENFORCING CONDITIONAL INDEPENDENCE VIA OUTPUT DISTRIBUTIONS
86
+
87
+ It remains for us to decide on the distribution $\hat { h }$ that we constrain, as well as the (unconstrained) regularization objective from (3). These choices are crucial in many ways. Since independence with respect to $\hat { h }$ underpins the notions of invariance and diversity in Definitions 3.1 and 3.2, it must be informative about the underlying predictive signals that a classifier is relying on. Furthermore, $\hat { h }$ and the regularization objective must be tractable.
88
+
89
+ Earlier work such as Pace et al. (2020) and Rame & Cord (2021) choose $\hat { h }$ to be the representations learnt by the classifiers, e.g. by constructing $f = f _ { l } \circ f _ { e }$ as a deep encoder network $f _ { e }$ that is attached to a linear classifier $f _ { l }$ and letting $\hat { h } \ = \ f _ { e } ( \mathbf { x } )$ . As the regularization objective for conditional independence, Rame & Cord (2021) compute pairwise conditional mutual information $\mathcal { C M T } ( f _ { e , s } , f _ { e , t } )$ whereas Pace et al. (2020) compute total correlation $\mathcal { T C } ( f _ { e , 1 } , \dots , f _ { e , M } )$ . Since the encoder representations are high-dimensional, these terms must be approximated.
90
+
91
+ We propose a far simpler and more efficient method. Instead of network representations, we choose $\hat { h }$ to simply be the output distribution $\hat { h } = f ( \mathbf { x } ) = p _ { \boldsymbol { \theta } } ( y | \mathbf { x } )$ of the classifier. Accordingly, our regularization objective is conditional mutual information (CMI) between the output distributions of the classifiers. For any pair of classifiers $f _ { j } , f _ { k }$ , we have:
92
+
93
+ $$
94
+ \mathcal { C M T } ( f _ { s } , f _ { t } ) = \mathbb { E } _ { y } \left[ \mathcal { D } _ { K L } \Big ( p ( f _ { s } , f _ { t } | y ) | | p ( f _ { s } | y ) p ( f _ { t } | y ) \Big ) \right]
95
+ $$
96
+
97
+ CMI is zero iff $f _ { s } \perp \perp f _ { t } | y$ for all values of $y$ . Enforcing conditional independence on the classifiers’ predicted output probabilities rather than underlying representations trades off granularity of the independence constraint for computational efficiency. We believe that this is a valuable trade-off. Since $\hat { y }$ has categorical support, (4) can be cheaply and exactly estimated from training data. As our experiments in Section 5 show, even on a noisier signal like output distributions, enforcing conditional independence is sufficient to learn a diverse ensemble.
98
+
99
+ Even though a diverse ensemble implies pairwise conditionally independent classifiers, the converse is not necessarily true. Mutual information is also zero if one of the classifiers outputs random or constant class probabilities. In particular, optimizing a weighted sum of the cross-entropy term and the CMI term can be challenging — overly weak regularization produces an ensemble that is not diverse, whereas overly strong regularization tends towards solutions containing close-to-random classifiers. Instead, we propose adding another term to regularize for confident predictions:
100
+
101
+ $$
102
+ \mathcal { R } ( f ) = \sum _ { k = 1 } ^ { K } \| p ( \hat { y } | y = k ) - I _ { k } \|
103
+ $$
104
+
105
+ where $I _ { k }$ is the indicator function at $k$ . Put together, the overall loss objective is:
106
+
107
+ $$
108
+ \mathcal { L } ( \{ \theta _ { m } \} _ { m = 1 } ^ { M } ) = \sum _ { i = 1 } ^ { N } \sum _ { m = 1 } ^ { M } \log p _ { \theta _ { m } } ( y _ { i } | \mathbf { x } _ { i } ) + \lambda _ { 1 } \cdot \sum _ { s = 1 } ^ { M } \sum _ { t = 1 } ^ { s - 1 } \mathcal { C } \mathcal { M } \mathcal { Z } ( f _ { s } , f _ { t } ) + \lambda _ { 2 } \cdot \sum _ { m = 1 } ^ { M } \mathcal { R } ( f _ { m } )
109
+ $$
110
+
111
+ where $\lambda _ { 1 }$ and $\lambda _ { 2 }$ are hyperparameters controlling the strength of regularization. A solution that minimizes (6) contains an ensemble where: (i) each classifier is accurate (first term) and confident (third term), and (ii) different classifiers rely on different subspaces of $\mathbf { z }$ for prediction (second term). We name such an ensemble a Conditionally Independent Deep Ensemble (CoDE).
112
+
113
+ # 3.3 CODE: COMPUTATIONAL DETAILS
114
+
115
+ The hyperparameters of the method are $M , \lambda _ { 1 }$ , and $\lambda _ { 2 }$ . Unlike traditional ensembles, $M$ (ensemble size) will typically be small $M = 2$ for all our experiments) since $M$ cannot be larger than the number of conditionally independent predictive signals inherent in the dataset. As is typical for OOD problems, we assume access to validation data from the test environment for hyperparameter tuning.
116
+
117
+ Objective (6) describes the situation where all $M$ classifiers are jointly optimized. Since $M$ is typically small, doing so is not difficult or computationally expensive (as might be with traditional ensembles). An alternative to joint optimization is to learn the classifiers in a sequential fashion. The analogue to (6) becomes:
118
+
119
+ $$
120
+ \mathcal { L } ( \theta _ { m } ) = \sum _ { i = 1 } ^ { N } \log p _ { \theta _ { m } } ( y _ { i } | \mathbf { x } _ { i } ) + \lambda _ { 1 } \cdot \sum _ { s = 1 } ^ { m - 1 } \mathcal { C } \mathcal { M } \mathcal { Z } ( \hat { y } _ { s } , \hat { y } _ { m } ) + \lambda _ { 2 } \cdot \mathcal { R } ( f _ { m } )
121
+ $$
122
+
123
+ Sequential optimization presents a natural way to determine $M$ , as we can terminate the training process when no more predictive classifiers can be learnt. However, it will fail if earlier classifiers in the sequence learn multiple predictive signals. We discuss this further in Section 5.
124
+
125
+ # 4 RELATED WORK
126
+
127
+ Ensemble Methods In statistics, ensembling traditionally refers to combining multiple predictors into a single model that outperforms the individual learners, typically by bagging (Breiman, 1996) or boosting (Schapire, 1990). Diversity in this context refers to minimizing correlation between individual learners, which reduces variance and improve generalization (Kuncheva & Whitaker, 2003). Deep ensembling (Lakshminarayanan et al., 2017) is an analogous approach in deep learning where multiple randomly-initialized networks are trained in parallel, however, they are generally used for the purpose of uncertainty estimation. Unlike these works, we consider diversity specifically in the context of datasets with multiple predictive signals, and learning a diverse ensemble as recovering all such signals for the purpose of OOD generalization.
128
+
129
+ Various Approaches For Learning Diversity As an unsupervised task, diversity refers to learning disentangled representations where natural factors of variation in the dataset are encoded into distinct latent dimensions (Bengio et al., 2013; Higgins et al., 2018); however, recent work has proposed incorporating weak supervision in this process (Locatello et al., 2019; Shu et al., 2019; Brehmer et al., 2022). As a supervised problem without OOD shifts, diversity refers to learning functions that disagree outside training points. Methods in this space have generally made use of input gradients (Ross et al., 2017; 2018) and orthogonality (Mashhadi et al., 2021; Xu et al., 2021). Finally, diversity is considered in the context of distribution shifts — either to improve robustness against adversarial attacks (Pang et al., 2019), to disambiguate between perfectly correlated signals (Lee et al., 2022), or to evade the simplicity bias by learning more complex functions (Pagliardini et al., 2022; Teney et al., 2021). Our work is most closely aligned with this last category. Unlike the approaches above, we exploit information-theoretic measures as our objective.
130
+
131
+ Shortcut Learning and Spurious Correlations Shortcut learning (Geirhos et al., 2020) involves distribution shifts arising from spurious correlations (Buolamwini & Gebru, 2018; Xiao et al., 2020; Moayeri et al., 2022) and neural network biases (architectural or simplicity biases) (Geirhos et al., 2018; Shah et al., 2020; Teney et al., 2021). Methods that tackle distribution shifts must use additional data and/or assumptions. Examples of additional data include having multiple training environments (Arjovsky et al., 2019), counterfactual examples (Teney et al., 2020), access to enough validation data to fine-tune the model (Kirichenko et al., 2022), or group labels (Sagawa et al., 2019; Puli et al., 2022). Examples of additional assumptions include exploiting the lottery ticket hypothesis (Zhang et al., 2021) or treating misclassified training examples by an initial model as a proxy for minority groups (Liu et al., 2021; Zhang et al., 2022). Unlike these methods, we aim to learn all predictive signals in the dataset, rather than performing well on a single test distribution. Furthermore, we use validation data for hyperparameter tuning only, without additional sources of data (e.g. group labels).
132
+
133
+ Information Bottleneck and Conditional Independence The line of work most similar to ours also exploits the information bottleneck method to learn diversity. Sinha et al. (2020) minimizes the mutual information $\mathcal { T } ( \hat { z } _ { s } , \hat { z } _ { t } )$ between learnt representations $\hat { z } _ { m }$ , however, this term is unconditional and will simply learn weak (biased) predictors, as noted in Section 3. Rame & Cord (2021) introduce DICE, which minimizes the conditional term $\mathcal { C } \mathcal { M } \mathcal { I } ( \hat { z } _ { s } , \hat { z } _ { t } )$ . Pace et al. (2020) considers total correlation $\mathcal { T C } ( \hat { z } _ { 1 } , \dots , \hat { z } _ { M } )$ instead of pairwise terms. Unlike CoDE, both of these approaches compute mutual information terms on the high-dimensional representations $\hat { z } _ { m }$ . Their objectives are intractable and must be approximated. For example, DICE requires both variational approximations and a jointly trained adversarial discriminator that learns to distinguish pairwise classifiers. Compared to these approaches, CoDE is by far computationally advantageous as mutual information for categorical output distributions can be computed faster and exactly.
134
+
135
+ # 5 EXPERIMENTS
136
+
137
+ Section 5.1 presents experiments on ColoredMNIST, which is used both to demonstrate the viability of our approach and to highlight pivotal observations and ablations. Section 5.2 then evaluates CoDE on larger benchmark datasets for shortcut learning to show that it scales effectively.
138
+
139
+ # 5.1 COLOREDMNIST
140
+
141
+ Setup As described in Section 2, the original MNIST (LeCun et al., 1998) labels are binarized (0-4, 5-9) and used to generate true labels $y$ with noise $p _ { d }$ . $y$ then generates binary color labels with noise $p _ { c }$ , used to color the image (red or green). As per Arjovsky et al. (2019), we consider two test environments: the training distribution where $p _ { d } = 0 . 2 5$ and $p _ { c } = 0 . 1$ , and the adversarial distribution where $p _ { d } = 0 . 2 5$ but $p _ { c } = 0 . 9$ (hence the shortcut-label correlation is reversed).
142
+
143
+ Evaluation Baselines and Metrics As is standard in existing work, we evaluate predictive accuracy on the training and adversarial distributions. In choosing baselines, we considered the following desiderata for fairness and comprehensiveness: (i) comparing to both ensembling and non-ensembling methods, (ii) amongst ensembling methods, comparing to both conditional independence-based methods and those that do not, and (iii) comparing only to methods that do not require additional sources of data besides validation data for hyperparameter tuning. We chose the following baselines:
144
+
145
+ Table 1: Results on ColoredMNIST. A theoretically ideal classifier relying only on digit (denoted as “Invariant”) will be upper-bounded by the digit-label noise $p _ { d }$ $(7 5 \% )$ , hence any result above $7 5 \%$ is relying on the color shortcut. CoDE has the strongest performance on the adversarial distribution. \*We were unable to reproduce TC-Ensemble on ColoredMNIST, and are citing their results in lieu.
146
+
147
+ <table><tr><td colspan="6">Results on ColoredMNIST</td></tr><tr><td>(pd,Pc)</td><td>Training (0.25, 0.1)</td><td>(0.25, 0.9)</td><td>(0.25, 0.5)</td><td>AdversarialRandom-ColorRandom-Color + Perfect-Digit (0.0, 0.5)</td></tr><tr><td>Invariant</td><td>75</td><td>75</td><td>75</td><td>100</td></tr><tr><td>ERM</td><td>88.6</td><td>15.3</td><td>52.5</td><td>53.4</td></tr><tr><td>JTT</td><td>17.8</td><td>87.9</td><td>52.5</td><td>56.6</td></tr><tr><td>Ortho-Ensemble</td><td>89.8</td><td>11.1</td><td>50.3</td><td>49.2</td></tr><tr><td>TC-Ensemble</td><td>89.1</td><td>69.8*</td><td>-</td><td>-</td></tr><tr><td>CoDE</td><td>70.7</td><td>70.0</td><td>70.8</td><td>91.2</td></tr></table>
148
+
149
+ 1. ERM classifier (ERM): single, standard classifier trained with ERM 2. Just Train Twice (Liu et al., 2021) (JTT): an initial classifier is trained for a limited number of epochs; mis-classified examples are upweighted to train the final classifier 3. Ensembles using input gradient orthogonality (Teney et al., 2021) (Ortho-Ensemble): an ensemble where the regularizing term is the dot product of the two models’ input gradients 4. Ensembles using conditional total correlation (CTC) (Pace et al., 2020) (TC-Ensemble): an ensemble learnt by minimizing CTC over the encoder network’s representation
150
+
151
+ Table 1 shows all results on ColoredMNIST. We discuss the most important findings below.
152
+
153
+ # 1. Enforcing conditional independence on output distributions achieves diversity effectively.
154
+
155
+ Since ColoredMNIST is an artificially-created dataset whose DGP we know satisfy latent conditional independence ${ \overset { \cdot } { p } } _ { c }$ and $p _ { d }$ are independently determined), it is the ideal dataset to evaluate our key claim. Indeed, the strong performance of CoDE shows that it is sufficient to enforce conditional independence on output distributions. The final predictor selected via fast adaptation achieves near-invariant results, suggesting that it has correctly learnt from digit rather than color.
156
+
157
+ # 2. CoDE generalizes to multiple OOD test distributions, without overfitting on any one specific distribution.
158
+
159
+ In Table 1, JTT achieved about $90 \%$ on the adversarial distribution, implying that it overfitted to the adversarial distribution — by learning the opposite shortcut (color) correlation rather than the true signal (digit). This is further confirmed with additional results on two other test environments (Random-Color and Random-Color $^ +$ Perfect-Digit) where $p _ { c } = 0 . 5$ . JTT is close to random on these two environments, suggesting that it is still relying on color as the predictive feature. In contrast, CoDE achieves $91 \%$ when $p _ { d } = 0 . 0$ , suggesting that it has learnt to predict using digit.
160
+
161
+ While concerning, these results are not entirely surprising. A method like JTT did exactly what it was designed to do, which is to minimize classification errors on the adversarial test distribution. Since $p _ { c } = 0 . 1$ , the opposite color correlation is precisely this loss-minimizing function. In contrast, CoDE will not find such a solution because two classifiers that return opposite predictions using the same feature (color) are perfectly correlated, even when conditioned on $y$ .
162
+
163
+ These results highlight the shortcomings of single classifier methods like JTT. Such methods are designed to generalize to a specific test distribution, in general, this does not imply that they have learnt the desired predictive signal — merely that they have learnt an arbitrary function that does well on the test distribution. In contrast, methods that enforce diversity, such as CoDE, explicitly recover meaningful predictive signals that can generalize to any test distribution where $p ( \mathbf { z } | y )$ changes.
164
+
165
+ Table 2: Additional results on ColoredMNIST and CelebA.
166
+
167
+ <table><tr><td rowspan="2"></td><td colspan="2">ColoredMNIST</td><td colspan="2">CelebA</td></tr><tr><td>Training</td><td>Adversarial</td><td>Ave</td><td>Worst</td></tr><tr><td>CoDE (sequential f1)</td><td>90.0</td><td>10.2</td><td>95.2</td><td>31.1</td></tr><tr><td>CoDE (sequential f2)</td><td>70.1</td><td>70.0</td><td>95.0</td><td>33.3</td></tr><tr><td>CoDE (sequential f3)</td><td>63.2</td><td>49.0</td><td></td><td></td></tr><tr><td>CoDE (sequential f5)</td><td>64.4</td><td>42.2</td><td></td><td></td></tr><tr><td>CoDE (joint M= 2)</td><td>73.4</td><td>60.2</td><td>89.2</td><td>83.3</td></tr><tr><td>CoDE (joint M = 3)</td><td>74.6</td><td>44.3</td><td></td><td></td></tr><tr><td>CoDE (joint M = 5)</td><td>71.9</td><td>43.1</td><td></td><td></td></tr></table>
168
+
169
+ # 3. Joint and sequential optimization are suited to different datasets.
170
+
171
+ From our experiments, we found that there is no clear preference between either choice in terms of generalization ability. Table 2 shows both joint and sequential results on the ColoredMNIST and CelebA datasets. For ColoredMNIST, we found that sequential training performed better than joint training. For CelebA, joint training yielded a stronger classifier.
172
+
173
+ This might be explained by the biases of the ERM model. In ColoredMNIST, as both latent factors (color and digit) are noisy predictors and as color presents a particularly simple shortcut, the ERM model solely learns from color. As such, a second classifier model that is trained sequentially can learn to predict solely from the digit feature. In contrast, the ERM model in CelebA has likely picked up some combination of the spurious (gender) and true (hair color) features, possibly because gender gives rise to complex features that are not ncessarily simpler to learn. This corroborates previous findings indicating that ERM models can learn an arbitrary combination of all predictive signals (Zhang et al., 2021; Kirichenko et al., 2022). As such, when trained sequentially, the second model fails to learn from hair color alone.
174
+
175
+ The advantages of sequential optimization are: (i) cheaper computational costs as $M$ increases, and (ii) providing a natural stopping point for training. The latter comes from the fact that we can select for $M$ by terminating the training process when the subsequent classifier is no longer predictive, which indicates that there are no further predictive factors to be learnt. In contrast, joint optimization is advantageous as it allows us to avoid the pathological sitation where earlier models learn combinations of predictive factors. As small values of $M$ work well for CoDEs, we note that the computational cost of CoDEs are not prohibitive.
176
+
177
+ # 5.2 BENCHMARK DATASETS
178
+
179
+ Setup We consider the following benchmark datasets:
180
+
181
+ • CelebA Liu et al. (2018); Sagawa et al. (2019): A dataset of celebrity faces with various labelled attributes. We consider the benchmark task in (Sagawa et al., 2019) of predicting the binary hair color attribute (blond or not), with gender (female or male) as the spurious attribute. There are therefore four groups. • Waterbirds (Wah et al., 2011; Sagawa et al., 2019): Setup described in Section 2. There are also four groups as both latent factors (background and foreground) are binary. • MF-Dominoes (MNIST-FashionMNIST) (LeCun et al., 1998; Xiao et al., 2017; Shah et al., 2020; Pagliardini et al., 2022): Each input image concatenates an MNIST digit (0 or 1) with a FashionMNIST object (coat or dress). The true label is the FashionMNIST object; the simpler MNIST feature is the shortcut. The minority groups represent $5 \%$ of the data.
182
+
183
+ Table 3 shows all results on the benchmark datasets.
184
+
185
+ # 4. CoDE scales well to large datasets and retains effectiveness at preventing shortcut learning.
186
+
187
+ <table><tr><td rowspan="2"></td><td colspan="2">CelebA</td><td colspan="2">Waterbirds</td><td colspan="2">MF-Dominoes</td></tr><tr><td>Method Ave</td><td>Worst</td><td>Ave</td><td>Worst</td><td>Ave</td><td>Worst</td></tr><tr><td>ERM</td><td>94.8</td><td>46.7</td><td>90.4</td><td>78.3</td><td>88.9</td><td>76.9</td></tr><tr><td>JTT</td><td>88.0*</td><td>81.1*</td><td>93.3*</td><td>86.7*</td><td>89.5</td><td>76.1</td></tr><tr><td>CoDE</td><td>89.2</td><td>83.3</td><td>91.5</td><td>79.4</td><td>92.1</td><td>91.4</td></tr></table>
188
+
189
+ Table 3: Main results on all datasets. CoDE achieves better adversarial or wrost-group accuracy than the other methods on all datasets except Waterbirds. ∗ Results from the JTT paper. We share the same model and training environment as their paper.
190
+
191
+ On CelebA and MF-Dominoes, CoDE achieves the best worst-group accuracy. Unlike the earlier ColoredMNIST dataset, we have no guarantees that the core assumption of latent conditional independence holds. However, the strong performance of CoDE on these datasets shows that such an assumption is generally valid and useful when scaled to more realistic datasets.
192
+
193
+ We note that CoDE performs poorly on Waterbirds. In our experiments, we selected $M = 2$ as the ensemble size. Even though there are no guarantees what will be the two conditionally independent classifiers that CoDE learns, in the other datasets, the results show that they do each correspond to the shortcut and true signal. This implies that in these datasets: (a) there are no features conditionally independent to both the shortcut and true signals and yet also strongly predictive of the label, and (b) the shortcut or true signal cannot be decomposed themselves into conditionally independent signals. Our hypothesis is that (b) is not true for Waterbirds. As the dataset is varied and contains a range of land and water backgrounds, there could be multiple spurious signals in the background that are somehow conditionally independent, resulting in these signals being learnt. Another possibility is that the ensemble could have learnt an imperfect or partial foreground signal.
194
+
195
+ # 5. Computational effectiveness is crucial to learn diverse ensembles at scale.
196
+
197
+ Beyond ColoredMNIST, we found that it was computationally prohibitive to run Ortho-Ensemble, as the size of ensembles required to work well (48 or 96) was too high. We also noted that we could not implement TC-Ensembles successfully on larger datasets, noting that the original authors do not test on datasets besides ColoredMNIST either. We believe that this further highlights the importance of computational efficiency in diverse ensembling.
198
+
199
+ # 6 DISCUSSION AND CONCLUSION
200
+
201
+ Appendix B discusses potential failure modes of our method.
202
+
203
+ We introduce CoDE, a method for learning an ensemble of diverse classifiers that rely on different predictive signals in the dataset. The key assumption made by CoDE conditional independence between predictive signals, which it enforces on classifiers’ output distributions. We find that CoDE works well in practice when applied to shortcut learning tasks. Future work includes: (a) evaluating CoDEs on other applications where multiple predictive signals exist, such as fairness-related tasks where we might want to learn classifiers that do not rely on sensitive attributes, and (b) considering other metrics for conditional independence that might provide more fine-grained signals than output distributions (e.g. minimizing mutual information between latent representations).
204
+
205
+ # ETHICS STATEMENT
206
+
207
+ Positive Impact Being robust to distribution shifts, CoDE will have a positive impact when deployed to high-stakes domains, where learning shortcut signals can have harmful social consequences. One such notable example is pneumonia prediction — models trained on pneumonia labels from chest $\mathrm { X }$ -ray scans have been shown to learn machine-specific artifacts in the background, which is a shortcut as hospitals have differing positivity rates and use different machines (Zech et al., 2018).
208
+
209
+ Negative Impact There are no notable negative impacts of using CoDE specifically, besides the general potential for all machine learning models to be abused in the wrong hands.
210
+
211
+ REPRODUCIBILITY STATEMENT
212
+
213
+ We intend to release public code with a camera-ready version of the paper.
214
+
215
+ # REFERENCES
216
+
217
+ Martin Arjovsky, Leon Bottou, Ishaan Gulrajani, and David Lopez-Paz. Invariant risk minimization. ´ arXiv preprint arXiv:1907.02893, 2019.
218
+
219
+ Nicholas Baker, Hongjing Lu, Gennady Erlikhman, and Philip J Kellman. Deep convolutional networks do not classify based on global object shape. PLoS computational biology, 14(12): e1006613, 2018.
220
+
221
+ Elias Bareinboim, Juan David Correa, Duligur Ibeling, and Thomas F. Icard. On pearl’s hierarchy and the foundations of causal inference. Probabilistic and Causal Inference, 2022.
222
+
223
+ Yoshua Bengio, Aaron Courville, and Pascal Vincent. Representation learning: A review and new perspectives. IEEE transactions on pattern analysis and machine intelligence, 35(8):1798–1828, 2013.
224
+
225
+ Johann Brehmer, Pim De Haan, Phillip Lippe, and Taco Cohen. Weakly supervised causal representation learning. arXiv preprint arXiv:2203.16437, 2022.
226
+
227
+ Leo Breiman. Bagging predictors. Machine learning, 24(2):123–140, 1996.
228
+
229
+ Joy Buolamwini and Timnit Gebru. Gender shades: Intersectional accuracy disparities in commercial gender classification. In Conference on fairness, accountability and transparency, pp. 77–91. PMLR, 2018.
230
+
231
+ Kalyanmoy Deb. Multi-objective optimization. In Search methodologies, pp. 403–449. Springer, 2014.
232
+
233
+ Jia Deng, Wei Dong, Richard Socher, Li-Jia Li, Kai Li, and Li Fei-Fei. Imagenet: A large-scale hierarchical image database. In 2009 IEEE conference on computer vision and pattern recognition, pp. 248–255. Ieee, 2009.
234
+
235
+ Ian Fischer. The conditional entropy bottleneck. Entropy, 22(9):999, 2020.
236
+
237
+ Robert Geirhos, Patricia Rubisch, Claudio Michaelis, Matthias Bethge, Felix A Wichmann, and Wieland Brendel. Imagenet-trained cnns are biased towards texture; increasing shape bias improves accuracy and robustness. arXiv preprint arXiv:1811.12231, 2018.
238
+
239
+ Robert Geirhos, Jorn-Henrik Jacobsen, Claudio Michaelis, Richard Zemel, Wieland Brendel, Matthias¨ Bethge, and Felix A Wichmann. Shortcut learning in deep neural networks. Nature Machine Intelligence, 2(11):665–673, 2020.
240
+
241
+ Tatsunori Hashimoto, Megha Srivastava, Hongseok Namkoong, and Percy Liang. Fairness without demographics in repeated loss minimization. In International Conference on Machine Learning, pp. 1929–1938. PMLR, 2018.
242
+
243
+ Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 770–778, 2016.
244
+
245
+ Irina Higgins, David Amos, David Pfau, Sebastien Racaniere, Loic Matthey, Danilo Rezende, and Alexander Lerchner. Towards a definition of disentangled representations. arXiv preprint arXiv:1812.02230, 2018.
246
+
247
+ Dirk Hovy and Anders Søgaard. Tagging performance correlates with author age. In Proceedings of the 53rd annual meeting of the Association for Computational Linguistics and the 7th international joint conference on natural language processing (volume 2: Short papers), pp. 483–488, 2015.
248
+
249
+ Diederik P Kingma and Jimmy Ba. Adam: A method for stochastic optimization. arXiv preprint arXiv:1412.6980, 2014.
250
+
251
+ Polina Kirichenko, Pavel Izmailov, and Andrew Gordon Wilson. Last layer re-training is sufficient for robustness to spurious correlations. arXiv preprint arXiv:2204.02937, 2022.
252
+
253
+ Anders Krogh and John Hertz. A simple weight decay can improve generalization. Advances in neural information processing systems, 4, 1991.
254
+
255
+ Ludmila I Kuncheva and Christopher J Whitaker. Measures of diversity in classifier ensembles and their relationship with the ensemble accuracy. Machine learning, 51(2):181–207, 2003.
256
+
257
+ Balaji Lakshminarayanan, Alexander Pritzel, and Charles Blundell. Simple and scalable predictive uncertainty estimation using deep ensembles. Advances in neural information processing systems, 30, 2017.
258
+
259
+ Yann LeCun, Leon Bottou, Yoshua Bengio, and Patrick Haffner. Gradient-based learning applied to ´ document recognition. Proceedings of the IEEE, 86(11):2278–2324, 1998.
260
+
261
+ Yoonho Lee, Huaxiu Yao, and Chelsea Finn. Diversify and disambiguate: Learning from underspecified data. arXiv preprint arXiv:2202.03418, 2022.
262
+
263
+ Evan Z Liu, Behzad Haghgoo, Annie S Chen, Aditi Raghunathan, Pang Wei Koh, Shiori Sagawa, Percy Liang, and Chelsea Finn. Just train twice: Improving group robustness without training group information. In International Conference on Machine Learning, pp. 6781–6792. PMLR, 2021.
264
+
265
+ Ziwei Liu, Ping Luo, Xiaogang Wang, and Xiaoou Tang. Large-scale celebfaces attributes (celeba) dataset. Retrieved August, 15(2018):11, 2018.
266
+
267
+ Francesco Locatello, Stefan Bauer, Mario Lucic, Gunnar Raetsch, Sylvain Gelly, Bernhard Scholkopf, ¨ and Olivier Bachem. Challenging common assumptions in the unsupervised learning of disentangled representations. In international conference on machine learning, pp. 4114–4124. PMLR, 2019.
268
+
269
+ Peyman Sheikholharam Mashhadi, Sławomir Nowaczyk, and Sepideh Pashami. Parallel orthogonal deep neural network. Neural Networks, 140:167–183, 2021.
270
+
271
+ Mazda Moayeri, Phillip Pope, Yogesh Balaji, and Soheil Feizi. A comprehensive study of image classification model sensitivity to foregrounds, backgrounds, and visual attributes. arXiv preprint arXiv:2201.10766, 2022.
272
+
273
+ Aaron van den Oord, Yazhe Li, and Oriol Vinyals. Representation learning with contrastive predictive coding. arXiv preprint arXiv:1807.03748, 2018.
274
+
275
+ Daniel Pace, Alessandra Russo, and Murray Shanahan. Learning diverse representations for fast adaptation to distribution shift. arXiv preprint arXiv:2006.07119, 2020.
276
+
277
+ Matteo Pagliardini, Martin Jaggi, Franc¸ois Fleuret, and Sai Praneeth Karimireddy. Agree to disagree: Diversity through disagreement for better transferability. arXiv preprint arXiv:2202.04414, 2022.
278
+
279
+ Tianyu Pang, Kun Xu, Chao Du, Ning Chen, and Jun Zhu. Improving adversarial robustness via promoting ensemble diversity. In International Conference on Machine Learning, pp. 4970–4979. PMLR, 2019.
280
+
281
+ Aahlad Manas Puli, Lily H Zhang, Eric Karl Oermann, and Rajesh Ranganath. Out-of-distribution generalization in the presence of nuisance-induced spurious correlations. In International Conference on Learning Representations, 2022. URL https://openreview.net/forum?id= 12RoR2o32T.
282
+
283
+ Alexandre Rame and Matthieu Cord. Dice: Diversity in deep ensembles via conditional redundancy adversarial estimation. arXiv preprint arXiv:2101.05544, 2021.
284
+
285
+ Andrew Slavin Ross, Michael C Hughes, and Finale Doshi-Velez. Right for the right reasons: Training differentiable models by constraining their explanations. arXiv preprint arXiv:1703.03717, 2017.
286
+
287
+ Andrew Slavin Ross, Weiwei Pan, and Finale Doshi-Velez. Learning qualitatively diverse and interpretable rules for classification. arXiv preprint arXiv:1806.08716, 2018.
288
+
289
+ Shiori Sagawa, Pang Wei Koh, Tatsunori B Hashimoto, and Percy Liang. Distributionally robust neural networks for group shifts: On the importance of regularization for worst-case generalization. arXiv preprint arXiv:1911.08731, 2019.
290
+
291
+ Robert E Schapire. The strength of weak learnability. Machine learning, 5(2):197–227, 1990.
292
+
293
+ Bernhard Scholkopf, Francesco Locatello, Stefan Bauer, Nan Rosemary Ke, Nal Kalchbrenner, ¨ Anirudh Goyal, and Yoshua Bengio. Towards causal representation learning. arXiv preprint arXiv:2102.11107, 2021.
294
+
295
+ Harshay Shah, Kaustav Tamuly, Aditi Raghunathan, Prateek Jain, and Praneeth Netrapalli. The pitfalls of simplicity bias in neural networks. Advances in Neural Information Processing Systems, 33:9573–9585, 2020.
296
+
297
+ Rui Shu, Yining Chen, Abhishek Kumar, Stefano Ermon, and Ben Poole. Weakly supervised disentanglement with guarantees. arXiv preprint arXiv:1910.09772, 2019.
298
+
299
+ Samarth Sinha, Homanga Bharadhwaj, Anirudh Goyal, Hugo Larochelle, Animesh Garg, and Florian Shkurti. Diversity inducing information bottleneck in model ensembles. arXiv preprint arXiv:2003.04514, 2020.
300
+
301
+ Damien Teney, Ehsan Abbasnedjad, and Anton van den Hengel. Learning what makes a difference from counterfactual examples and gradient supervision. In European Conference on Computer Vision, pp. 580–599. Springer, 2020.
302
+
303
+ Damien Teney, Ehsan Abbasnejad, Simon Lucey, and Anton van den Hengel. Evading the simplicity bias: Training a diverse set of models discovers solutions with superior ood generalization. arXiv preprint arXiv:2105.05612, 2021.
304
+
305
+ Antonio Torralba and Alexei A Efros. Unbiased look at dataset bias. In CVPR 2011, pp. 1521–1528. IEEE, 2011.
306
+
307
+ Catherine Wah, Steve Branson, Peter Welinder, Pietro Perona, and Serge Belongie. The caltech-ucsd birds-200-2011 dataset. 2011.
308
+
309
+ Han Xiao, Kashif Rasul, and Roland Vollgraf. Fashion-mnist: a novel image dataset for benchmarking machine learning algorithms. arXiv preprint arXiv:1708.07747, 2017.
310
+
311
+ Kai Xiao, Logan Engstrom, Andrew Ilyas, and Aleksander Madry. Noise or signal: The role of image backgrounds in object recognition. arXiv preprint arXiv:2006.09994, 2020.
312
+
313
+ Yilun Xu, Hao He, Tianxiao Shen, and Tommi S Jaakkola. Controlling directions orthogonal to a classifier. In International Conference on Learning Representations, 2021.
314
+
315
+ John R Zech, Marcus A Badgeley, Manway Liu, Anthony B Costa, Joseph J Titano, and Eric Karl Oermann. Variable generalization performance of a deep learning model to detect pneumonia in chest radiographs: a cross-sectional study. PLoS medicine, 15(11):e1002683, 2018.
316
+
317
+ Dinghuai Zhang, Kartik Ahuja, Yilun Xu, Yisen Wang, and Aaron Courville. Can subnetwork structure be the key to out-of-distribution generalization? In International Conference on Machine Learning, pp. 12356–12367. PMLR, 2021.
318
+
319
+ Michael Zhang, Nimit S Sohoni, Hongyang R Zhang, Chelsea Finn, and Christopher Re. Correct-n- ´ contrast: A contrastive approach for improving robustness to spurious correlations. arXiv preprint arXiv:2203.01517, 2022.
320
+
321
+ # A EXPERIMENTAL DETAILS
322
+
323
+ Architecture and Training Details For ColoredMNIST, we use a CNN as the classifier, containing two convolutional layers and two fully-connected layers. Adam (Kingma & Ba, 2014) is used for optimization, with a learning rate of 0.001. For CelebA, Waterbirds, and MF-Dominoes, we use a ResNet-50 (He et al., 2016). SGD is used for optimization, with a learning rate of 0.001, momentum decay of 0.9, and weight decay of 0.001. Additionally, following previous work (e.g. Sagawa et al., 2019; Liu et al., 2021), the Waterbirds model is pre-trained on ImageNet (Deng et al., 2009) and includes data augmentation in the form of random horizontal flips and random resized cropping. For CelebA and Waterbirds, class reweighting is performed to ensure that there are roughly equal positive and negative labels. The random seed used for all experiments is 13.
324
+
325
+ Hyperparameters for CoDE and Baselines CoDE. For all four datasets, we used $M = 2$ as the ensemble size, besides ablations for $M$ as detailed in Appendix B. The results in Table 3 were achieved with sequential training for ColoredMNIST and with joint training for the other three datasets. For ColoredMNIST, $\lambda _ { 1 } = 1 2 0 0$ and $\lambda _ { 2 } = 1 0$ . For CelebA, $\lambda _ { 1 } = 5 0 0$ and $\lambda _ { 2 } = 0 . 1$ . For Waterbirds, $\lambda _ { 1 } = 5 0 0$ and $\lambda _ { 2 } = 0 . 1$ . For MF-Dominoes, $\lambda _ { 1 } = 3 0 0$ and $\lambda _ { 2 } = 0 . 1$ . JTT. We performed a hyperparameter sweep with $T \in \{ 1 , 5 , 1 0 \}$ (number of epochs for initial model training) and $\alpha \in \{ 2 , 1 0 , 1 0 0 \}$ (upweighting factor for mis-classified examples). Orthogonal Ensembles. All classifiers share the same feature extractor (i.e. convolutional output for ColoredMNIST and ResNet-50 feature representation for the other three datasets). We experimented with different values of $M$ , however, values of $M$ above 16 (for ColoredMNIST) and above 4 (for the other three datasets) were prohitibively expensive. As such, we did not try $M = 4 8$ or $M = 9 6$ as used by Teney et al. (2021). For these smaller values of $M$ that we tried, we did not notice an improvement from the ERM model. Besides ColoredMNIST, we did not report these results.
326
+
327
+ # B MODEL MIS-SPECIFICATION: POTENTIAL FAILURE MODES
328
+
329
+ The success of any method tackling distribution shifts depends on how well the assumptions made have been upheld. We discuss the potential implications when the model is mis-specified and these assumptions are no longer valid.
330
+
331
+ Conditional Dependence CoDE relies on the assumption that predictive signals are conditionally independent. We using the synthetic ColoredMNIST dataset to generate a DGP where such an assumption does not hold true. Instead of the standard setup where color labels are generated from the true labels, we generate color labels from the original (binarized) MNIST labels instead, at the same noise level $p _ { c } = 0 . 1$ . This means that the color and digit signals are now highly correlated. Both are still predictive since the true labels themselves were generated from MNIST labels.
332
+
333
+ Table 4 shows the results of this experiment. As we expect, conditionally dependent features cannot be recovered by minimizing conditional mutual information. The ensemble either recovers one of the two features (when trained sequentially) or neither. This confirms our intuition that conditional independence must be correctly specified for CoDE to work. While these results demonstrate a failure mode of CoDE, conditional independence between predictive factors of interest does hold well in many natural image datasets, as shown in Table 3.
334
+
335
+ Latent Mis-specification The size of the ensemble $M$ specifies how many predictive latent factors we believe generated the dataset. We can consider the mis-specification of $M$ in either direction: (i) if the true dimension of $\mathbf { z }$ is smaller than $M$ , and (ii) if the true dimension of $\mathbf { z }$ is larger than $M$ .
336
+
337
+ In case (i), since the number of conditional independent components has been over-specified, whether the ensemble has been jointly or sequentially trained makes a difference. Consider the results on the ColoredMNIST dataset in Table 2 again. In the sequential regime, the first two classifiers $f _ { 1 }$ and $f _ { 2 }$ correspond to the color and digit classifiers respectively, however, the subsequent few classifiers $f _ { 3 }$ and $f _ { 5 } ^ { } ,$ ) do not learn anything meaningful and perform poorly on both training and adversarial distributions. However, as noted in Section 5, this does not pose a serious problem since we can use validation data to naturally determine the stopping point. On the other hand, over-specification of $M$ is more worrying in the joint regime, as there is no guarantee that any of the true latent factors are learnt at all. As Table 2 shows, for $M = 3$ or 5, the best-performing classifier does not generalize.
338
+
339
+ Table 4: Results on ColoredMNIST with color-digit conditional dependence, on both joint and sequential training with $M = 2$ classifiers. When trained sequentially, the first classifier $f _ { 1 }$ learns the digit correlation since digit is most predictive in this setup. However, as color is no longer conditionally independent of digit, there is no predictive feature that can be learnt by the second classifier $f _ { 2 }$ , resulting in a close-to-random predictor. When trained jointly, neither of the classifiers correspond to the color or digit feature.
340
+
341
+ <table><tr><td>(pd,Pc)</td><td>Training (0.25, 0.1)</td><td>Adversarial (0.25, 0.9)</td><td>Random-Color (0.25, 0.5)</td><td>Perfect-Digit (0.0, 0.5)</td></tr><tr><td>CoDE (sequential f1)</td><td>77.1</td><td>63.2</td><td>70.6</td><td>90.5</td></tr><tr><td>CoDE (sequential f2)</td><td>53.6</td><td>50.1</td><td>51.5</td><td>54.5</td></tr><tr><td>CoDE (joint f1)</td><td>84.9</td><td>25.8</td><td>56.0</td><td>60.4</td></tr><tr><td>CoDE (joint f2)</td><td>54.3</td><td>73.0</td><td>64.4</td><td>77.5</td></tr></table>
342
+
343
+ In case (ii), where the number of conditional independent components is under-specified, the learnt ensemble may correspond to any subset of the true latent factors and individual classifiers could also learn arbitrary combinations of the latent factors. For example, the trivial case where $M = 1$ is underspecified simply returns the ERM model. In general, since $M$ is a hyperparameter, latent mis-specification does not pose a serious problem as we can tune its value using the validation data.
md/dev/3IyL2XWDkG/3IyL2XWDkG.md ADDED
@@ -0,0 +1,392 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # CAMEL: Communicative Agents for “Mind” Exploration of Large Language Model Society
2
+
3
+ https://www.camel-ai.org
4
+
5
+ # Guohao Li⇤ Hasan Abed Al Kader Hammoud
6
+
7
+ Hani Itani\* Dmitrii Khizbullin
8
+
9
+ # Bernard Ghanem
10
+
11
+ King Abdullah University of Science and Technology (KAUST)
12
+
13
+ # Abstract
14
+
15
+ The rapid advancement of chat-based language models has led to remarkable progress in complex task-solving. However, their success heavily relies on human input to guide the conversation, which can be challenging and time-consuming. This paper explores the potential of building scalable techniques to facilitate autonomous cooperation among communicative agents, and provides insight into their “cognitive” processes. To address the challenges of achieving autonomous cooperation, we propose a novel communicative agent framework named roleplaying . Our approach involves using inception prompting to guide chat agents toward task completion while maintaining consistency with human intentions. We showcase how role-playing can be used to generate conversational data for studying the behaviors and capabilities of a society of agents, providing a valuable resource for investigating conversational language models. In particular, we conduct comprehensive studies on instruction-following cooperation in multi-agent settings. Our contributions include introducing a novel communicative agent framework, offering a scalable approach for studying the cooperative behaviors and capabilities of multi-agent systems, and open-sourcing our library to support research on communicative agents and beyond: https://github.com/camel-ai/camel.
16
+
17
+ # 1 Introduction
18
+
19
+ “What magical trick makes us intelligent? The trick is that there is no trick. The power of intelligence stems from our vast diversity, not from any single, perfect principle.”
20
+
21
+ - Marvin Minsky, The Society of Mind, p. 308
22
+
23
+ Confronted with the complexities of real-world tasks, solving them often requires multiple steps. The rapid progress of chat-based large-scale language models (LLMs) has yielded remarkable achievements in complex task-solving [82, 84, 116, 89, 5, 10, 122, 13]. Nevertheless, it is worth noting that their success is heavily reliant on human input to guide the conversation in the right direction. This reliance necessitates users to provide relevant and precise prompts based on their intentions and the chat agent’s feedback. This can be challenging, time-consuming, and sometimes impossible. Crafting effective prompts often demands a deep understanding and expertise of a particular domain of knowledge. Consider an individual who lacks trading expertise; they would find it difficult to create suitable prompts for directing a chat agent to develop a trading application. This predicament is raising a crucial question: can we replace human intervention with an autonomous communicative agent capable of steering the conversation toward task completion with minimal human supervision? To tackle this issue, it is crucial to conduct more research exploring the potential, capabilities, and limitations of communicative agents that operate entirely on their own to complete tasks. Understanding how multiple agents interact with each other is important for anticipating the future of artificial intelligence. The dynamics of collaborating or competing agents play a key role in determining the success of AI systems [6, 26, 27, 84, 99, 9, 10].
24
+
25
+ This paper explores the potential of building scalable techniques to facilitate autonomous cooperation among communicative agents and provide insight into their “cognitive” processes. Several challenges arise when asking a society of agents to autonomously cooperate on completing tasks. Examples we encountered in our preliminary analysis include role flipping, assistant repeating instructions, flake replies, and infinite loop of messages. Therefore, it is critical to investigate ways to align these models with human intentions and to explore means enabling their effective cooperation. To address these issues, we propose a novel cooperative agent framework named role-playing to automate cooperation between communicative agents. Specifically, our proposed approach involves using role-playing with inception prompting to autonomously guide the communicative agents toward task completion. Only a preliminary idea is needed from human to guide the conversations toward complex task-solving.
26
+
27
+ Our library, which we make publicly available, provides modular functionality, and includes implementations of different agents, examples of well-crafted prompts, and data explorers. We hope our library serves as a ground for future research in various areas such as multi-agent systems, cooperative AI, game theory simulations, social analysis, AI ethics, AI alignment, and beyond. In addition, our role-playing method provides a highly scalable way to generate conversational data for studying the behaviors and capabilities of chat agents. We showcase how role-playing can be used to let chat agents communicate with each other for task completion and record their conversations for behavior analysis and capability understanding. In particular, we consider two cooperative scenarios of role-playing and generate two large conversational, task-oriented, and instruction-following datasets: AI Society and Code. We also use our framework to collect two single-turn question-answer datasets, Math and Science, for LLM ability emergence study. Furthermore, we generate a Misalignment dataset that is a simulation of possible malicious applications which demonstrate the potential risks of an unaligned autonomous agent system. The datasets offer a valuable resource for investigating conversational language models, enabling them to comprehend and react to human language more effectively. Furthermore, our role-playing offers a scalable method of creating conversational instruction-following data, which can potentially enhance the development of more advanced language models. We show that solutions derived from our role-playing framework outperform those generated in a single shot by gpt-3.5-turbo [82] in both GPT4 and human evaluations. We also study knowledge emergence in LLMs by fine-tuning LLaMA [117] on progressively growing datasets generated through our framework. Additionally, we evaluate our code generation capabilities through benchmarking our final model on HumanEval [18] and HumanEval+ [69].
28
+
29
+ Contributions. Our contributions are fourfold: (1) We introduce a novel cooperative agent framework, role-playing , that allows communicative agents to collaborate autonomously toward completing tasks while requiring minimal human intervention; (2) Our framework offers a scalable approach for studying the cooperative behaviors and capabilities of multi-agent systems. It illuminates the challenges of achieving autonomous cooperation, and provides strategies for addressing them. We showcase the potential power of multi-agent collaboration for complex-task solving; (3) We demonstrate the significant emergence of LLM training abilities by utilizing the datasets we have collected from simulating four distinct agent collaboration scenarios; (4) We have open-sourced our library, containing implementations of various agents, data generation pipelines, data analysis tools, and collected datasets, to support research on communicative agents and beyond.
30
+
31
+ # 2 Related Work
32
+
33
+ Communicative Agents. Communication between agents has been studied for a long time [76, 77]. There are many ways to facilitate communication between agents, and with agents [29, 90, 97]. Among these, natural language is considered the most natural form of communication [97]. By enabling agents to function as communicators themselves, they become capable of solving complex tasks [113, 85, 72, 3, 30, 111, 79, 41, 28, 102, 80, 106, 35, 49, 2, 51, 1, 55, 50, 65, 92]. Communication between AI agents can occur in a competitive setting [115, 108] or a cooperative setting [40, 27, 11, 137, 70]. Cooperative AI refers to artificial intelligence systems that are designed to work together with humans and other AI systems to achieve common goals [24, 125]. Cooperative AI systems take into account the needs and capabilities of other agents in the system and actively seek to collaborate and coordinate their actions with them, which has many potential benefits, including increased efficiency, improved decision-making, and the ability to tackle complex problems that are beyond the reach of any single agent. However, designing effective cooperative AI systems is still an active area of research, as it requires addressing a range of technical, ethical, and social challenges [27]. Our work enables communicative agents to engage in a conversation and cooperate with each other to solve assigned tasks. The agents, each assigned a distinct role, are expected to apply their expertise and knowledge to solve their common task.
34
+
35
+ Instructional LLMs and Prompt Engineering. LLMs are trained on diverse text data and excel in text completion, with various downstream NLP applications [12, 22, 47, 131, 117]. However, InstructGPT suggests that LLMs may not align with user intent, proposing reinforcement learning from human feedback (RLHF) [23] and Instruction Fine-Tuning (IFT) [121] to improve LLMs’ relevance and appropriateness to user instructions. Special types of instruction or prompting methods , such as Chain-of-Thought (CoT) [123], zero-shot-CoT [61], and ReAct [126], have recently been developed to enhance the performance of LLMs on reasoning, arithmetic and decision making tasks [134, 118, 52, 73, 31, 103, 43, 64, 132, 46, 133, 105, 128, 25, 81, 109]. These techniques underpin the impressive capabilities of recent dialogue LLMs [106, 116, 36, 9, 82, 13], which aim to simulate human-like conversations and provide personalized and interactive experiences for users, exhibiting the behavior of conversational AI agents [33]. However, generating instruction datasets is a crucial challenge in building instruct-based LLMs, with existing datasets ranging from crowdsourced to generated. Hand-crafted instruction instances are available in [120], while leveraging previously crowdsourced NLP datasets is a less labor-intensive curation approach [121, 71, 78, 53]. LLMs have been explored for data generation in [101, 63, 68, 114], and Self-Instruct [119] proposes a semi-automated process for instruction instance generation. Unnatural-Instruction [48] collects instruction instances by prompting a language model with only three seed examples and paraphrasing the generated instances to expand the dataset. There is also a large chunk of work that has proposed methods for automatic dataset creation [67, 57, 19, 75, 20, 98, 59, 96, 129, 62, 130, 86, 8]. Another important challenge is prompt engineering. The quality of the prompt used to guide LLMs significantly affects its performance [91, 12, 66]. While LMs pre-trained on large data can implicitly learn tasks with few-shot prompting, hand-crafted prompts may not always suffice. Automated prompt generation methods have been proposed, such as gradient-guided search [104], mining-based and paraphrasing-based techniques [54], a meta-prompt [93], and automatic instruction selection and generation [136]. In this work, we introduce a conversational LLM auto-prompting method called Inception Prompting, which enables agents to prompt each other to solve tasks through Role-Playing. The AI user continuously provides instructions to the AI assistant for task-solving. This enables us to save the streaming instruction-solution pairs and create diverse, instructional, conversational, and task-oriented datasets. These datasets can be used to analyze the behavior and capabilities of LLMs and for future research for fine-tuning LLMs with conversational instructions.
36
+
37
+ AI Alignment. AI alignment is a field that aims to ensure that AI systems adhere to their intended goals, interests, and values, as envisioned by their designers [4, 39, 110, 32, 38, 74, 10]. The first attempt at AI alignment was made through the "Three Laws of Robotics," which was introduced by Isaac Asimov in his science fiction stories [6]. Developing aligned AI systems is crucial for achieving desired objectives while avoiding unintended consequences. Research in AI alignment focuses on discouraging AI models from producing false, offensive, deceptive, or manipulative information that could result in various harms [56, 112, 42, 37]. Achieving a high level of alignment requires researchers to grapple with complex ethical, philosophical, and technical issues. We conduct extensive experiments to study different role-playing situations, which probe the alignment of LLMs.
38
+
39
+ # 3 Methodology
40
+
41
+ In this paper, we focus on studying communicative agents under cooperative settings where they share common interests. In particular, we study the assistant-user scenario, where a preliminary idea is given at the start. Agents will conceptualize the idea into a specific task and complete it autonomously through conversations.
42
+
43
+ # 3.1 Role-playing Framework
44
+
45
+ “What’s the most resilient parasite? An Idea. A single idea from the human mind can build cities. An idea can transform the world and rewrite all the rules. Which is why I have to steal it.”
46
+
47
+ - Dom Cobb, Inception
48
+
49
+ ![](images/6abc6059b41ace03cab1cbc2501d41463903922476103d46fbfb309436a5b8fc.jpg)
50
+ Figure 1: CAMEL Role-Playing Framework. Our role-playing setup starts with the human user having an idea they want to implement, e.g. develop a trading bot for the stock market. The roles involved in this task would be an AI assistant agent who is a python programmer and an AI user agent who is a stock trader. The task is made more specific using our task specifier agent, leading to a well-defined task for the assistant to solve. Both AI user and AI assistant are provided with the specified task, after which they collaboratively communicate by chatting with each other in an instruction-following fashion to solve the specified task.
51
+
52
+ Our proposed framework is a novel role-playing approach for studying multiple communicative agents. Specifically, we concentrate on task-oriented role-playing that involves one AI assistant and one AI user. After the multi-agent system receives a preliminary idea and the role assignment from human users, a task-specifier agent will provide a detailed description to make the idea specific. Afterwards, the AI assistant and AI user will cooperate on completing the specified task through multi-turn conversations until the AI user determines the task is done. The AI user is responsible for giving instructions to the AI assistant and directing the conversation toward task completion. On the other hand, the AI assistant is designed to follow the instructions from the AI user and respond with specific solutions. The whole role-playing framework is depicted in Figure 1.
53
+
54
+ Human Input and Task Specifying. The role-playing session will be instantiated from an idea and selected roles by humans. As an example in Figure 1, a human has a preliminary idea to develop a trading bot for the stock market. Humans may or may not have the knowledge about how the idea can be realized. What is needed is only to designate the potential roles that can implement the idea. For instance, a Python Programmer could collaborate with a Stock Trader to realize the idea of developing a trading bot for the stock market. After the idea and roles are determined, the task specifier agent will brainstorm a specific task that the AI Assistant role can help with the AI user role to complete based on the input idea. An example of a specified task in this scenario could be: develop a trading bot with a sentiment analysis tool that can monitor social media platforms for positive or negative comments about a particular stock, and execute trades based on sentiment analysis results. The main motivation for introducing a task specifier is that conversational agents usually require a concrete task prompt for realizing the task which might be challenging or time-consuming for a non-domain expert. Therefore, the task specifier agent serves as an enhanced imagination module for the idea implementation. Please note that, when studying our framework at a large scale for AI society and Code scenarios, we generate roles and ideas automatically by prompting LLMs instead of relying on human inputs. For our generated Math and Science datasets we generated problem topics, subtopics, and problems automatically by prompting LLMs.
55
+
56
+ AI Assistant-User Role Assignment. After the task specification, The AI assistant role and the AI user role will be assigned to the user agent and the assistant agent correspondingly to complete the specified task. In practice, a system message is passed to each agent declaring their role. We refer to the assistant system prompt/message by $\mathcal { P } _ { A }$ and that of the user by $\mathcal { P } _ { \mathcal { U } }$ . The system messages are passed to the agents before the conversations start. Let $\mathcal { F } _ { 1 }$ and $\mathcal { F } _ { 2 }$ denote two large-scale autoregressive language models [82]. When the system message is passed to those models respectively, we obtain $\mathcal { A } \mathcal { F } _ { 1 } ^ { \mathcal { P } _ { A } }$ and $\mathcal { U } \mathcal { F } _ { 2 } ^ { \mathcal { P } _ { \mathcal { U } } }$ which are referred to as the assistant and user agents respectively. In Figure 1, the AI assistant and the AI user are assigned the roles of a Python Programmer and a Stock Trader at the beginning of the role-playing session respectively. The AI user serves as a task planner, engaging in interactive planning to determine feasible steps for the AI assistant to execute. Meanwhile, the AI assistant acts as a task executor, offering solutions, executing planned steps, and providing responses to the AI user.
57
+
58
+ Conversation Towards Task-Solving. After the role assignment is completed, the AI assistant $\mathcal { A }$ and AI user $\mathcal { U }$ will collaborate in an instruction-following manner to accomplish the task. In the AI assistant-user scenario, the AI user is responsible for providing instructions, and the assistant is expected to respond with a solution that fulfills the instructions. Formally, we denote the user instruction message obtained at time $t$ by $\mathcal { T } _ { t }$ and the assistant solution by $S _ { t }$ . The set of conversational messages obtained up until time $t$ is denoted by Equation (1) shown below:
59
+
60
+ $$
61
+ \mathcal { M } _ { t } = \{ ( \mathbb { Z } _ { 0 } , S _ { 0 } ) , . . . , ( \mathbb { Z } _ { t } , S _ { t } ) \} = \{ ( \mathbb { Z } _ { i } , S _ { i } ) \} | _ { i = 0 } ^ { t }
62
+ $$
63
+
64
+ At the next time step, $t + 1$ , the AI user $\mathcal { U }$ takes the historical conversation message set $\mathcal { M } _ { t }$ and provides a new instruction $\mathcal { T } _ { t + 1 }$ , as shown in Equation (2). The produced instruction message $\mathcal { T } _ { t + 1 }$ is then passed, along with message set $\mathcal { M } _ { t }$ , to the AI assistant $\mathcal { A }$ . The AI assistant will then respond with a solution, denoted by $\boldsymbol { S } _ { t + 1 }$ in Equation (3):
65
+
66
+ $$
67
+ \mathcal { T } _ { t + 1 } = \mathcal { U } ( \mathcal { M } t ) \qquad ( 2 ) \qquad \mathcal { S } t + 1 = \mathcal { A } ( \mathcal { M } t , \mathcal { I } t + 1 )
68
+ $$
69
+
70
+ After obtaining the solution $\boldsymbol { S } _ { t + 1 }$ to the instruction $\mathcal { T } _ { t + 1 }$ , the message set is updated using Equation (4) to obtain $\mathcal { M } _ { t + 1 }$ :
71
+
72
+ $$
73
+ \mathcal { M } _ { t + 1 } \mathcal { M } _ { t } \cup ( \mathcal { T } _ { t + 1 } , S _ { t + 1 } )
74
+ $$
75
+
76
+ Note that the formulation above not only models AI-AI communicative scenarios, but it can also be easily extended to model human-AI communication or communication between more than two agents. Specifically, we can use message-passing graphs to model communication between an arbitrary number of agents. In Figure 1, we observe that the AI user initiates the installation and import of essential Python libraries for sentiment analysis and stock trading by instructing the AI assistant through conversations. This example is drawn from our experiments, and the entire conversation is available in the Appendix.
77
+
78
+ Critic-In-The-Loop. To enhance the controllability of the role-playing framework, we introduce a critic agent capable of selecting proposals from or providing feedback to the role-playing agents. This enables tree-search-like decision-making for task-solving. In practice, the critic can be either an AI agent or a human. The detailed implementation and case studies can be found in the Appendix.
79
+
80
+ # 3.2 Inception Prompting
81
+
82
+ Since prompt engineering is crucial to our role-playing framework, this section delves deeply into our prompting techniques. Our prompt engineering occurs solely at the beginning of role-playing, for task specification and role assignment. Once the conversation phase commences, the AI assistant and AI user prompt each other automatically in a loop until termination. As such, we refer to our technique as Inception Prompting. Our Inception prompt consists of three prompts: the task specifier prompt $\mathcal { P } _ { T }$ , the assistant system prompt $\mathcal { P } _ { A }$ , and the user system prompt $\mathcal { P } _ { \mathcal { U } }$ . As an example, we consider the inception prompt of the $A I$ Society scenario. The templates for these prompts of $A I$ Society role-playing are shown in Figure 2. The task specifier prompt contains information about the roles of the AI assistant and AI user in the role-playing session. Therefore, the task specifier agent can take a preliminary task/idea as input and generate a specific task using imagination. The AI assistant system prompt $\mathcal { P } _ { A }$ and the AI user system prompt $\mathcal { P } _ { \mathcal { U } }$ are mostly symmetrical and include information about the assigned task and roles, communication protocols, termination conditions, and constraints or requirements to avoid unwanted behaviors. The prompt designs for both roles are crucial to achieve autonomous cooperation between agents. It is non-trivial to engineer prompts that ensure agents act in alignment with our intentions. We take the prompt templates from the AI Society in Figure 2 as an example to explain our key design choices. The prompts used for the Code scenario follow a similar sprint as the AI society scenario, but with some additional engineering related to programming languages. More details in the Appendix.
83
+
84
+ # AI Society Inception Prompt
85
+
86
+ # Task Specifier Prompt:
87
+
88
+ Here is a task that <ASSISTANT_ROLE> will help <USER_ROLE> to complete: <TASK>.
89
+ Please make it more specific. Be creative and imaginative.
90
+ Please reply with the specified task in <WORD_LIMIT> words or less. Do not add anything else.
91
+
92
+ # Assistant System Prompt:
93
+
94
+ # User System Prompt:
95
+
96
+ Never forget you are a <USER_ROLE> and I am a <ASSISTANT_ROLE>. Never flip roles! You will always instruct me.
97
+ We share a common interest in collaborating to successfully complete a task.
98
+ I must help you to complete the task.
99
+ Here is the task: <TASK>. Never forget our task!
100
+ You must instruct me based on my expertise and your needs to complete the task ONLY in the following two ways:
101
+
102
+ Prompt Engineering. To delve deeper into the details in Figure 2, we start by chunking the various parts of the AI assistant system prompt $\mathcal { P } _ { A }$ shown below:
103
+
104
+ • Never forget you are a <ASSISTANT_ROLE> and I am a <USER_ROLE>. This assigns the chosen role to the assistant agent and provides it with information about the user’s role. • Never flip roles! Never instruct me! This prevents agents from flipping roles. In some cases, we have observed the assistant and the user switching roles, where the assistant suddenly takes control and instructs the user, and the user follows those instructions. • You must decline my instruction honestly if you cannot perform the instruction due to physical, moral, legal reasons or your capability and explain the reasons. This prohibits the agent from producing harmful, false, illegal, and misleading information. • Unless I say the task is completed, you should always start with: Solution: <YOUR_SOLUTION>. <YOUR_SOLUTION> should be specific, and provide preferable implementations and examples for task-solving. This encourages the assistant always responds in a consistent format, avoiding any deviation from the structure of the conversation, and preventing vague or incomplete responses, which we refer to as flake responses, such as ${ } " \mathrm { I }$ will do something".
105
+
106
+ • Always end your solution with: Next request. This ensures that the assistant keeps the conversation going by requesting a new instruction to solve.
107
+
108
+ For the AI user system prompt $\mathcal { P } _ { \mathcal { U } }$ , we strive to maintain as much symmetry as possible with respect to the AI assistant system prompt. Apart from the opposite role assignment, the user system prompt differs from the assistant prompt in the following ways:
109
+
110
+ • You must instruct me ... to complete the task ONLY in the following two ways: 1. Instruct with a necessary input: ...; 2. Instruct without any input: ... This follows the typical data structure of instruction-following, which allows the generated instruction-solution pairs to be easily used for fine-tuning LLMs. • Keep giving me instructions and necessary inputs until you think the task is completed. When the task is completed, you must only reply with a single word <CAMEL_TASK_DONE>. We introduce an end-of-task token, namely, <CAMEL_TASK_DONE>. This token is used once the user believes the task is done. This ensures that the chat is terminated when the user is satisfied. Without doing so, the agents might fall into a chatting loop where they keep on saying “thank you” to each other or “goodbye” indefinitely.
111
+
112
+ # 4 Experiments
113
+
114
+ In this section, we will discuss the various experiments that we conducted to arrive at our final design choices. Specifically, we will examine the interesting observations, challenging issues, and several examples we have encountered while enabling agents to communicate with each other under different prompt design choices to achieve autonomous cooperation. In our experiments, we employed two gpt-3.5-turbo agents, referred to as LLM agents for simplicity, with Inception Prompts, as described in Section 3.2, to simulate assistant-user cooperation. For our analysis, we set our attention on AI Society setting. We also gathered conversational data, named CAMEL AI Society and CAMEL Code datasets and problem-solution pairs data named CAMEL Math and CAMEL Science and analyzed and evaluated their quality. Moreover, we will discuss potential extensions of our framework and highlight both the risks and opportunities that future AI society might present.
115
+
116
+ # Data Generation Prompts of AI Society
117
+
118
+ # AI Society
119
+
120
+ # Assistant Role Generation Prompt:
121
+
122
+ You are a helpful assistant that can play many different roles. Now please list <NUM_ROLES> different roles that you can play with your expertise in diverse fields. Sort them by alphabetical order. No explanation required.
123
+
124
+ # User Role Generation Prompt:
125
+
126
+ Please list <NUM_ROLES> most common and diverse groups of internet users or occupations. Use singular form. No explanation. Sort them by alphabetical order. No explanation required.
127
+
128
+ # Task Generation Prompt:
129
+
130
+ List <NUM_TASKS> diverse tasks that <ASSISTANT_ROLE> can assist <USER_ROLE> cooperatively to achieve together. Be concise. Be creative.
131
+
132
+ Figure 3: Data Generation Prompts. In order to maintain a scalable approach our data parameters are generated using an LLM model to reduce human involvement in the generation process. The generation prompts for both AI Society dataset are summarized in this figure.
133
+
134
+ # 4.1 Role-Playing for AI Society
135
+
136
+ To create our AI Society dataset, we have developed a scalable approach that follows a series of steps. Firstly, we prompt the LLM agent to generate possible roles for the assistant and the user. We achieve this by providing the LLM agent with specific prompts designed to elicit these roles. Next, we ask the LLM agent to generate a range of possible tasks that can be solved through collaboration between the assistant and user roles generated previously. After generating a range of possible tasks as described in the previous step, we then use the task specifier prompt passed to the LLM agent to make the task more specific. The prompts for assistant role generation, user role generation, and task generation are shown in Figure 5 (AI Society). For our AI society dataset, we generated 50 assistant roles, 50 user roles, and 10 tasks for each combination of roles yielding a total of 25,000 conversations. The generated assistant roles and user roles for AI Society as well as details about the generation of Code, Math and Science datasets can be found in the Appendix.
137
+
138
+ Challenges and Observations. In this section, we explore the four main challenges that we identified during our analysis of the generated datasets. Our observations shed light on some interesting aspects of cooperative AI and the difficulties that arise in its development.
139
+
140
+ • Role Flipping: One challenge we encountered was role flipping, where the assistant and user switch roles during the conversation. This issue typically arises when the assistant starts providing instructions or commands instead of following the user’s prompts, which can lead to confusion and a reversal of roles. To avoid role flipping, it is crucial for the assistant not to ask questions, as this can also contribute to the problem. • Assistant Repeats Instruction: Another challenge that we observed was the assistant simply repeating the user’s instructions without any role flipping occurring. • Flake Replies: We also observed instances where the assistant agent responds with a flake reply, often taking the form of "I will...". These messages do not contribute to the task at hand, as the assistant promises to take action but ultimately fails to follow through. • Infinite Loop of Messages: An interesting challenge that we encountered was when the assistant and user engage in an infinite loop of meaningless conversation, such as repeatedly thanking each other or saying goodbye without progressing the task. Interestingly, in some cases, the assistant and user are aware that they are stuck in a loop, but are unable to break out of it.
141
+
142
+ The Appendix shows examples of each of the four challenges discussed above. Overall, our observations highlight the complexity of cooperative AI development and the need for continued exploration and innovation to overcome the challenges we face. By identifying these issues, we hope to contribute to the development of more effective and engaging cooperative AI systems.
143
+
144
+ Termination Conditions. The conversation between the assistant and user agents is designed to follow a specific format to ensure consistent and accurate data generation. To ensure that both the user and assistant adhere to their respective roles and responsibilities, certain conditions have been set in place to terminate the chat if necessary. These conditions are outlined below:
145
+
146
+ User No Instruct: If the user does not instruct the assistant for 3 rounds, conversation is ended.
147
+ • Assistant Instruct: If the assistant provides an instruction to the user, it indicates a role reversal, and the conversation is terminated.
148
+ • End of Task Token: If the user believes that the task has been solved, they are expected to say <CAMEL_TASK_DONE> to signify the completion of the task. Once this message is received, the conversation is terminated.
149
+ Assistant&User Token Limit: Given that gpt-3.5-turbo has a limitation on the number of tokens, the conversation is terminated if either the assistant or the user reach the token limit.
150
+ • Maximum Number of Messages: To keep the cost of generated chats in check, we have set a maximum limit of 40 messages. This limit guarantees a long enough conversation between the user and assistant while also ensuring that the data generated is not too costly to produce. The cost grows quadratically with the length of the conversation, making it essential to set a limit.
151
+
152
+ # 5 Evaluation
153
+
154
+ # 5.1 Agent Evaluation
155
+
156
+ In order to assess the performance of CAMEL (Cooperative Role-playing Communication), we conduct two types of evaluations: (1) Human evaluation, and (2) GPT4 evaluation. We randomly select 100 tasks from our AI Society dataset for evaluation and 100 tasks from our Code dataset. Then, we employ the GPT4 model to summarize the content of the CAMEL conversation-based solution, presenting a consolidated final solution. Particularly, a GPT4 is used since it possesses a larger token limit which is suitable for summarization. Summarization also makes CAMEL agents’ solution undetectable by its format, allowing for a more fair comparison. Subsequently, this solution is compared with a single-shot solution generated by the gpt-3.5-turbo model for the same task. Sample tasks are provided in the Appendix.
157
+
158
+ Human Evaluation. For this evaluation, we present both the CAMEL summarized agent solution and the gpt-3.5-turbo single-shot solution side-by-side to human participants. The identity behind each solution is not revealed. Participants are then asked to vote on whether one solution is superior to the other or if they are equally good. A total of 453 responses were collected during this evaluation. Note that, human evaluation is only done for AI Society, as assessing code is generally harder for humans (without running the code).
159
+
160
+ GPT4 Evaluation. We engage a GPT4 agent to evaluate the effectiveness of Model 1 (CAMEL Agent solution) versus Model 2 (gpt-3.5-turbo single-shot solution) for each task. More specifically, we prompt GPT4 to score and decide which solution of the two solutions is better.
161
+
162
+ Results. The summarized results of each evaluation are outlined in Table 1 which showcases that the CAMEL solution outperforms gpt-3.5-turbo single-shot solution in both the human evaluation and the GPT4 evaluation by a big margin. It is also worth noting that both human evaluation and GPT4 evaluation are highly aligned.
163
+
164
+ Table 1: Agent Evaluation Results: Results of the evaluations of the CAMEL agent against gpt-3.5-turbo using both human evaluators and GPT4 consistently show that utilizing a multiagent cooperative approach is more effective than gpt $- 3 . 5$ -turbo’s single shot solution.
165
+
166
+ <table><tr><td>Dataset</td><td>Evaluation Type</td><td>Draw</td><td>gpt-3.5-turbo Wins</td><td>CAMEL Agents Win</td></tr><tr><td rowspan="2">AI Society</td><td>Human Evaluation</td><td>13.3%</td><td>10.4%</td><td>76.3%</td></tr><tr><td>GPT4 Evaluation</td><td>4.0%</td><td>23.0%</td><td>73.0%</td></tr><tr><td>Code</td><td>GPT4 Evaluation</td><td>0.0%</td><td>24.0%</td><td>76.0%</td></tr></table>
167
+
168
+ # 5.2 GPT4 for ChatBot Evaluation
169
+
170
+ In this section, we progressively fine-tune a LLaMA 7B model on our generated datasets. By progressively incorporating diverse datasets like AI society, code, math, and science, we expect fine-tuned model to demonstrate the ability to develop an increasingly sophisticated understanding of these domains.
171
+
172
+ We initially start by training on AI society dataset, which aims to let the model learn about human interactions and societal dynamics. As additional datasets were introduced, such as code, the model gained knowledge of programming logic and syntax, enabling it to generate coherent and executable code snippets. The inclusion of the math dataset further expanded the model’s capabilities, allowing it to solve complex equations, reason about abstract concepts, and perform precise calculations. Finally, exposure to the science dataset broadened the model’s understanding of scientific theories, empirical observations, and experimental methods. The emergence of model capabilities is measured by evaluating the quality of the model responses, before and after training on the new domain, on a set of questions of varying difficulties from each domain. More precisely, the model is tested on 20 AI Society related tasks, 20 coding tasks, 20 math tasks and 60 science tasks.
173
+
174
+ Those results are highlighted in Table 2 where we see that each time we add a dataset, the model performs better on the incorporated domain. Note that to measure the quality of the models’ responses, we follow the evaluation from Section T, which involves prompting a GPT4 agent to score and decide which solution is better. It is worth noting that an improvement on other domains is also observed in some cases such as when we train on Code we improve on Science. This is because our Code dataset contains problems that solve tasks in particular domains which include scientific domain. Similarly, training on AI Society improves code as AI Society contains the role of a "programmer" and hence coding related conversations. Finally, note that the draws observed in LLaMA-7B vs AI Society in Math reflects equally bad solutions compared to the draws observed in AI Society $\mathbf { + C o d e + M a t } ]$ h vs AI Society $+ \mathrm { C o d e } + \mathrm { M a t h } + \Omega$ cience where the draws are equally good solutions. This progression from AI society to code to math to science highlights the potential of AI models to acquire a versatile and adaptable knowledge base, paralleling the way humans gain expertise in diverse subjects. Sample tasks are provided in the Appendix.
175
+
176
+ Table 2: Emergence of Knowledge. By progressively fine-tuning LLaMA on datasets from different domains, we observe the emergence of knowledge as the model transitions from AI society to code, math, and science. This finding is indicated by the fact that Model 2 almost always performs better than Model 1, especially on the added dataset.
177
+
178
+ <table><tr><td rowspan="2">Dataset</td><td colspan="3">Model 1</td><td colspan="3">Model 2</td><td rowspan="2">Draw</td><td rowspan="2">Model 1</td><td rowspan="2">Model 2</td></tr><tr><td>AI Society</td><td>CodeMath</td><td>Science</td><td>AI Society</td><td>Code1</td><td>Math Science</td><td></td></tr><tr><td>AI Society</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>0</td><td>6</td><td>14</td></tr><tr><td>Code</td><td></td><td></td><td></td><td>交</td><td></td><td></td><td></td><td>0</td><td>0</td><td>20</td></tr><tr><td>Math</td><td></td><td></td><td></td><td>√</td><td></td><td></td><td></td><td>9</td><td>5</td><td>6</td></tr><tr><td>Science</td><td></td><td></td><td></td><td>√</td><td></td><td></td><td></td><td>0</td><td>13</td><td>47</td></tr><tr><td>AI Society</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>4</td><td>8</td><td>8</td></tr><tr><td>Code</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>1</td><td>9</td><td>10</td></tr><tr><td>Math</td><td>√</td><td></td><td></td><td></td><td>&lt;&lt;√</td><td></td><td></td><td>5</td><td>8</td><td>7</td></tr><tr><td>Science</td><td>√</td><td></td><td></td><td></td><td></td><td></td><td></td><td>1</td><td>19</td><td>40</td></tr><tr><td>AI Society</td><td>√</td><td></td><td></td><td></td><td></td><td></td><td></td><td>5</td><td>6</td><td>9</td></tr><tr><td>Code</td><td></td><td>&gt;&lt;&gt;</td><td></td><td></td><td></td><td></td><td></td><td>1</td><td>9</td><td>10</td></tr><tr><td>Math</td><td>√</td><td></td><td></td><td></td><td></td><td></td><td></td><td>1</td><td>3</td><td>16</td></tr><tr><td>Science</td><td>√</td><td></td><td></td><td></td><td></td><td>&lt;&lt;√</td><td></td><td>3</td><td>8</td><td>49</td></tr><tr><td>AI Society</td><td>√</td><td></td><td></td><td></td><td></td><td></td><td></td><td>3</td><td>1</td><td>16</td></tr><tr><td>Code</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>1</td><td>8</td><td>11</td></tr><tr><td>Math</td><td>√</td><td></td><td></td><td></td><td></td><td></td><td></td><td>10</td><td>5</td><td>5</td></tr><tr><td>Science</td><td>√</td><td></td><td></td><td>√</td><td></td><td></td><td>&lt;&lt;&lt;</td><td>9</td><td>2</td><td>49</td></tr><tr><td>AI Society</td><td></td><td></td><td></td><td>√</td><td></td><td></td><td>√</td><td>0</td><td>0</td><td>20</td></tr><tr><td>Code</td><td></td><td></td><td></td><td></td><td></td><td>&lt;&lt;&lt;</td><td></td><td>0</td><td>0</td><td>20</td></tr><tr><td>Math</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>0</td><td>0</td><td>20</td></tr><tr><td>Science</td><td></td><td></td><td></td><td></td><td></td><td></td><td>√</td><td>0</td><td>0</td><td>60</td></tr></table>
179
+
180
+ # 5.3 HumanEval(+)
181
+
182
+ Table 3: HumanEval(+) for Various Models. We test our CAMEL model, which is a LLaMa-7B fine-tuned on all our datasets (AI Society, Code, Math, Science) on HumanEval and HumanEval+ benchmarks, where we show competitive pass $@ k$ scores with LLaMa-7B and Vicuna-7B.
183
+
184
+ <table><tr><td></td><td colspan="2">HumanEval</td><td colspan="2">HumanEval+</td></tr><tr><td>pass@k [%]</td><td>k =1</td><td>k=100</td><td>k=1</td><td>k=100</td></tr><tr><td>gpt-3.5-turbo</td><td>69.4</td><td>94.0</td><td>61.7</td><td>89.8</td></tr><tr><td>LLaMA-7B</td><td>10.5</td><td>36.5</td><td>1</td><td>-</td></tr><tr><td>Vicuna-7B</td><td>11.0</td><td>42.9</td><td>9.9</td><td>34.7</td></tr><tr><td>CAMEL-7B</td><td>14.0</td><td>57.9</td><td>12.2</td><td>50.0</td></tr></table>
185
+
186
+ To evaluate the coding task-solving capabilities of our CAMEL model, specifically the LLaMA7B fine-tuned on our comprehensive datasets, we rely on HumanEval [18] and HumanEval+ [69]. The results, as depicted in table 3, clearly demonstrate the remarkable performance of CAMEL. It surpasses not only the LLaMA-7B model but also Vicuna-7B [21] by a big margin. These findings underscore the critical role played by the generated datasets in enhancing LLaMA’s ability to tackle coding-related tasks.
187
+
188
+ # 6 Conclusion
189
+
190
+ In this paper, we explore the potential of autonomous cooperation among communicative agents and propose a novel cooperative agent framework named role-playing . Our approach enables communicative agents to collaborate autonomously toward completing tasks while requiring minimal human intervention, leading to better solutions are per our thorough evaluations. Through our analysis, we show that achieving autonomous cooperation is challenging due to issues like conversation deviation, role flipping, and termination conditions. Our framework offers a scalable approach for studying the cooperative behaviors and capabilities of multi-agent systems and provides strategies for addressing these challenges. Furthermore, our open-sourced library includes implementations of various agents, data generation pipelines, data analysis tools, and collected datasets, to support research on communicative agents and beyond. Our contributions offer valuable insights into the future of large language artificial intelligence models and cooperative AI systems.
191
+
192
+ # 7 Acknowledgements
193
+
194
+ This work was supported by SDAIA-KAUST Center of Excellence in Data Science and Artificial Intelligence (SDAIA-KAUST AI).
195
+
196
+ # References
197
+
198
+ [1] Josh Abramson, Arun Ahuja, Iain Barr, Arthur Brussee, Federico Carnevale, Mary Cassin, Rachita Chhaparia, Stephen Clark, Bogdan Damoc, Andrew Dudzik, Petko Georgiev, Aurelia Guy, Tim Harley, Felix Hill, Alden Hung, Zachary Kenton, Jessica Landon, Timothy Lillicrap, Kory Mathewson, Sonaˇ Mokrá, Alistair Muldal, Adam Santoro, Nikolay Savinov, Vikrant Varma, Greg Wayne, Duncan Williams, Nathaniel Wong, Chen Yan, and Rui Zhu. Imitating interactive intelligence, 2020.
199
+
200
+ [2] Michael Ahn, Anthony Brohan, Noah Brown, Yevgen Chebotar, Omar Cortes, Byron David, Chelsea Finn, Chuyuan Fu, Keerthana Gopalakrishnan, Karol Hausman, Alex Herzog, Daniel Ho, Jasmine Hsu, Julian Ibarz, Brian Ichter, Alex Irpan, Eric Jang, Rosario Jauregui Ruano, Kyle Jeffrey, Sally Jesmonth, Nikhil J Joshi, Ryan Julian, Dmitry Kalashnikov, Yuheng Kuang, Kuang-Huei Lee, Sergey Levine, Yao Lu, Linda Luu, Carolina Parada, Peter Pastor, Jornell Quiambao, Kanishka Rao, Jarek Rettinghouse, Diego Reyes, Pierre Sermanet, Nicolas Sievers, Clayton Tan, Alexander Toshev, Vincent Vanhoucke, Fei Xia, Ted Xiao, Peng Xu, Sichun Xu, Mengyuan Yan, and Andy Zeng. Do as i can, not as i say: Grounding language in robotic affordances, 2022.
201
+
202
+ [3] Jacob Andreas. Language models as agent models, 2022.
203
+
204
+ [4] Jacob Andreas and Dan Klein. Alignment-based compositional semantics for instruction following. arXiv preprint arXiv:1508.06491, 2015.
205
+
206
+ [5] Anthropic. Introducing claude. Anthropic Blog, 2023.
207
+
208
+ [6] Isaac Asimov. I. Robot. Narkaling Productions., 1940.
209
+
210
+ [7] Jimmy Ba and Rich Caruana. Do deep nets really need to be deep? Advances in neural information processing systems, 27, 2014.
211
+
212
+ [8] Sanghwan Bae, Donghyun Kwak, Sungdong Kim, Donghoon Ham, Soyoung Kang, Sang-Woo Lee, and Woomyoung Park. Building a role specified open-domain dialogue system leveraging large-scale language models. In Proceedings of the 2022 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, pages 2128–2150, Seattle, United States, July 2022. Association for Computational Linguistics.
213
+
214
+ [9] Yuntao Bai, Andy Jones, Kamal Ndousse, Amanda Askell, Anna Chen, Nova DasSarma, Dawn Drain, Stanislav Fort, Deep Ganguli, Tom Henighan, et al. Training a helpful and harmless assistant with reinforcement learning from human feedback. arXiv preprint arXiv:2204.05862, 2022.
215
+
216
+ [10] 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.
217
+
218
+ [11] Nolan Bard, Jakob N Foerster, Sarath Chandar, Neil Burch, Marc Lanctot, H Francis Song, Emilio Parisotto, Vincent Dumoulin, Subhodeep Moitra, Edward Hughes, et al. The hanabi challenge: A new frontier for ai research. Artificial Intelligence, 280:103216, 2020.
219
+
220
+ [12] Tom Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah, Jared D Kaplan, Prafulla Dhariwal, Arvind Neelakantan, Pranav Shyam, Girish Sastry, Amanda Askell, et al. Language models are few-shot learners. Advances in neural information processing systems, 33:1877–1901, 2020.
221
+
222
+ [13] Sébastien Bubeck, Varun Chandrasekaran, Ronen Eldan, Johannes Gehrke, Eric Horvitz, Ece Kamar, Peter Lee, Yin Tat Lee, Yuanzhi Li, Scott Lundberg, et al. Sparks of artificial general intelligence: Early experiments with gpt-4. arXiv preprint arXiv:2303.12712, 2023.
223
+
224
+ [14] N Carlini, F Tramer, E Wallace, M Jagielski, A Herbert-Voss, K Lee, A Roberts, T Brown, D Song, Ú Erlingsson, et al. Extracting training data from large language models. arxiv. Preprint posted online December, 14, 2020.
225
+
226
+ [15] Nicholas Carlini, Jamie Hayes, Milad Nasr, Matthew Jagielski, Vikash Sehwag, Florian Tramèr, Borja Balle, Daphne Ippolito, and Eric Wallace. Extracting training data from diffusion models. arXiv preprint arXiv:2301.13188, 2023.
227
+
228
+ [16] Harrison Chase. Langchain. 2022.
229
+
230
+ [17] Defang Chen, Jian-Ping Mei, Yuan Zhang, Can Wang, Zhe Wang, Yan Feng, and Chun Chen. Cross-layer distillation with semantic calibration. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 35, pages 7028–7036, 2021.
231
+
232
+ [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.
233
+ [19] Maximillian Chen, Alexandros Papangelis, Chenyang Tao, Seokhwan Kim, Andy Rosenbaum, Yang Liu, Zhou Yu, and Dilek Hakkani-Tur. Places: Prompting language models for social conversation synthesis. arXiv preprint arXiv:2302.03269, 2023.
234
+ [20] Maximillian Chen, Alexandros Papangelis, Chenyang Tao, Andy Rosenbaum, Seokhwan Kim, Yang Liu, Zhou Yu, and Dilek Hakkani-Tur. Weakly supervised data augmentation through prompting for dialogue understanding. NeurIPS 2022 Workshop on Synthetic Data for Empowering ML Research, 2022.
235
+ [21] Wei-Lin Chiang, Zhuohan Li, Zi Lin, Ying Sheng, Zhanghao Wu, Hao Zhang, Lianmin Zheng, Siyuan Zhuang, Yonghao Zhuang, Joseph E. Gonzalez, Ion Stoica, and Eric P. Xing. Vicuna: An open-source chatbot impressing gpt-4 with $9 0 \% ^ { \ast }$ chatgpt quality, March 2023.
236
+ [22] 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.
237
+ [23] Paul F Christiano, Jan Leike, Tom Brown, Miljan Martic, Shane Legg, and Dario Amodei. Deep reinforcement learning from human preferences. Advances in neural information processing systems, 30, 2017.
238
+ [24] Caroline Claus and Craig Boutilier. The dynamics of reinforcement learning in cooperative multiagent systems. In AAAI/IAAI, 1998.
239
+ [25] Antonia Creswell, Murray Shanahan, and Irina Higgins. Selection-inference: Exploiting large language models for interpretable logical reasoning, 2022.
240
+ [26] Allan Dafoe, Yoram Bachrach, Gillian Hadfield, Eric Horvitz, Kate Larson, and Thore Graepel. Cooperative ai: machines must learn to find common ground. Nature, 593(7857):33–36, 2021.
241
+ [27] Allan Dafoe, Edward Hughes, Yoram Bachrach, Tantum Collins, Kevin R McKee, Joel Z Leibo, Kate Larson, and Thore Graepel. Open problems in cooperative ai. arXiv preprint arXiv:2012.08630, 2020.
242
+ [28] Yali Du, Bo Liu, Vincent Moens, Ziqi Liu, Zhicheng Ren, Jun Wang, Xu Chen, and Haifeng Zhang. Learning correlated communication topology in multi-agent reinforcement learning. In Proceedings of the 20th International Conference on Autonomous Agents and MultiAgent Systems, pages 456–464, 2021.
243
+ [29] Tim Finin, Richard Fritzson, Don McKay, and Robin McEntire. Kqml as an agent communication language. In Proceedings of the third international conference on Information and knowledge management, pages 456–463, 1994.
244
+ [30] Jakob Foerster, Ioannis Alexandros Assael, Nando De Freitas, and Shimon Whiteson. Learning to communicate with deep multi-agent reinforcement learning. Advances in neural information processing systems, 29, 2016.
245
+ [31] Yao Fu, Hao Peng, Ashish Sabharwal, Peter Clark, and Tushar Khot. Complexity-based prompting for multi-step reasoning. arXiv preprint arXiv:2210.00720, 2022.
246
+ [32] Iason Gabriel. Artificial intelligence, values, and alignment. Minds and Machines, 30:411 – 437, 2020.
247
+ [33] Jianfeng Gao, Michel Galley, and Lihong Li. Neural approaches to conversational ai. In The 41st International ACM SIGIR Conference on Research & Development in Information Retrieval, pages 1371–1374, 2018.
248
+ [34] Leo Gao, Jonathan Tow, Stella Biderman, Sid Black, Anthony DiPofi, Charles Foster, Laurence Golding, Jeffrey Hsu, Kyle McDonell, Niklas Muennighoff, Jason Phang, Laria Reynolds, Eric Tang, Anish Thite, Ben Wang, Kevin Wang, and Andy Zou. A framework for few-shot language model evaluation, September 2021.
249
+ [35] Amelia Glaese, Nat McAleese, Maja Trebacz, John Aslanides, Vlad Firoiu, Timo Ewalds, Maribeth Rauh, Laura Weidinger, Martin Chadwick, Phoebe Thacker, Lucy Campbell-Gillingham, Jonathan Uesato, Po-Sen Huang, Ramona Comanescu, Fan Yang, Abigail See, Sumanth Dathathri, Rory Greig, Charlie Chen, Doug Fritz, Jaume Sanchez Elias, Richard Green, Sona Mokrá, Nicholas Fernando, Boxi Wu, ˇ Rachel Foley, Susannah Young, Iason Gabriel, William Isaac, John Mellor, Demis Hassabis, Koray Kavukcuoglu, Lisa Anne Hendricks, and Geoffrey Irving. Improving alignment of dialogue agents via targeted human judgements, 2022.
250
+ [36] 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.
251
+ [37] Josh A Goldstein, Girish Sastry, Micah Musser, Renee DiResta, Matthew Gentzel, and Katerina Sedova. Generative language models and automated influence operations: Emerging threats and potential mitigations. arXiv preprint arXiv:2301.04246, 2023.
252
+ [38] Dylan Hadfield-Menell. The principal-agent alignment problem in artificial intelligence. Ph. D. dissertation, 2021.
253
+ [39] Dylan Hadfield-Menell, McKane Andrus, and Gillian Hadfield. Legible normativity for ai alignment: The value of silly rules. In Proceedings of the 2019 AAAI/ACM Conference on AI, Ethics, and Society, pages 115–121, 2019.
254
+ [40] Dylan Hadfield-Menell, Stuart J Russell, Pieter Abbeel, and Anca Dragan. Cooperative inverse reinforcement learning. Advances in neural information processing systems, 29, 2016.
255
+ [41] Serhii Havrylov and Ivan Titov. Emergence of language with multi-agent games: Learning to communicate with sequences of symbols. Advances in neural information processing systems, 30, 2017.
256
+ [42] Peter Henderson, Koustuv Sinha, Nicolas Angelard-Gontier, Nan Rosemary Ke, Genevieve Fried, Ryan Lowe, and Joelle Pineau. Ethical challenges in data-driven dialogue systems. In Proceedings of the 2018 AAAI/ACM Conference on AI, Ethics, and Society, pages 123–129, 2018.
257
+ [43] 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.
258
+ [44] Byeongho Heo, Minsik Lee, Sangdoo Yun, and Jin Young Choi. Knowledge transfer via distillation of activation boundaries formed by hidden neurons. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 33, pages 3779–3787, 2019.
259
+ [45] Geoffrey Hinton, Oriol Vinyals, and Jeff Dean. Distilling the knowledge in a neural network. arXiv preprint arXiv:1503.02531, 2015.
260
+ [46] Namgyu Ho, Laura Schmid, and Se-Young Yun. Large language models are reasoning teachers. arXiv preprint arXiv:2212.10071, 2022.
261
+ [47] 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.
262
+ [48] Or Honovich, Thomas Scialom, Omer Levy, and Timo Schick. Unnatural instructions: Tuning language models with (almost) no human labor. arXiv preprint arXiv:2212.09689, 2022.
263
+ [49] Ehsan Hosseini-Asl, Bryan McCann, Chien-Sheng Wu, Semih Yavuz, and Richard Socher. A simple language model for task-oriented dialogue. Advances in Neural Information Processing Systems, 33:20179–20191, 2020.
264
+ [50] Wenlong Huang, Pieter Abbeel, Deepak Pathak, and Igor Mordatch. Language models as zero-shot planners: Extracting actionable knowledge for embodied agents. arXiv preprint arXiv:2201.07207, 2022.
265
+ [51] 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.
266
+ [52] Shima Imani, Liang Du, and Harsh Shrivastava. Mathprompter: Mathematical reasoning using large language models. arXiv preprint arXiv:2303.05398, 2023.
267
+ [53] Srinivasan Iyer, Xi Victoria Lin, Ramakanth Pasunuru, Todor Mihaylov, Dániel Simig, Ping Yu, Kurt Shuster, Tianlu Wang, Qing Liu, Punit Singh Koura, et al. Opt-iml: Scaling language model instruction meta learning through the lens of generalization. arXiv preprint arXiv:2212.12017, 2022.
268
+ [54] Zhengbao Jiang, Frank F Xu, Jun Araki, and Graham Neubig. How can we know what language models know? Transactions of the Association for Computational Linguistics, 8:423–438, 2020.
269
+ [55] Siddharth Karamcheti, Megha Srivastava, Percy Liang, and Dorsa Sadigh. Lila: Language-informed latent actions. In CoRL, pages 1379–1390, 2021.
270
+ [56] Zachary Kenton, Tom Everitt, Laura Weidinger, Iason Gabriel, Vladimir Mikulik, and Geoffrey Irving. Alignment of language agents. arXiv preprint arXiv:2103.14659, 2021.
271
+ [57] Hyunwoo Kim, Jack Hessel, Liwei Jiang, Ximing Lu, Youngjae Yu, Pei Zhou, Ronan Le Bras, Malihe Alikhani, Gunhee Kim, Maarten Sap, et al. Soda: Million-scale dialogue distillation with social commonsense contextualization. arXiv preprint arXiv:2212.10465, 2022.
272
+ [58] Jangho Kim, Seonguk Park, and Nojun Kwak. Paraphrasing complex network: Network compression via factor transfer. In S. Bengio, H. Wallach, H. Larochelle, K. Grauman, N. Cesa-Bianchi, and R. Garnett, editors, Advances in Neural Information Processing Systems, volume 31. Curran Associates, Inc., 2018.
273
+ [59] Yekyung Kim, Seohyeong Jeong, and Kyunghyun Cho. Linda: Unsupervised learning to interpolate in natural language processing. arXiv preprint arXiv:2112.13969, 2021.
274
+ [60] Pang Wei Koh and Percy Liang. Understanding black-box predictions via influence functions. In International conference on machine learning, pages 1885–1894. PMLR, 2017.
275
+ [61] 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.
276
+ [62] Jonáš Kulhánek, Vojtech Hude ˇ cek, Tomá ˇ š Nekvinda, and Ondˇrej Dušek. Augpt: Auxiliary tasks and data augmentation for end-to-end dialogue with pre-trained language models. In Proceedings of the 3rd Workshop on Natural Language Processing for Conversational AI, pages 198–210, 2021.
277
+ [63] Kenton Lee, Kelvin Guu, Luheng He, Tim Dozat, and Hyung Won Chung. Neural data augmentation via example extrapolation. arXiv preprint arXiv:2102.01335, 2021.
278
+ [64] Aitor Lewkowycz, Anders Johan Andreassen, David Dohan, Ethan Dyer, Henryk Michalewski, Vinay Venkatesh Ramasesh, Ambrose Slone, Cem Anil, Imanol Schlag, Theo Gutman-Solo, et al. Solving quantitative reasoning problems with language models. 2022.
279
+ [65] Shuang Li, Xavier Puig, Chris Paxton, Yilun Du, Clinton Wang, Linxi Fan, Tao Chen, De-An Huang, Ekin Akyürek, Anima Anandkumar, Jacob Andreas, Igor Mordatch, Antonio Torralba, and Yuke Zhu. Pre-trained language models for interactive decision-making, 2022.
280
+ [66] Xiang Lisa Li and Percy Liang. Prefix-tuning: Optimizing continuous prompts for generation. arXiv preprint arXiv:2101.00190, 2021.
281
+ [67] Zekun Li, Wenhu Chen, Shiyang Li, Hong Wang, Jing Qian, and Xifeng Yan. Controllable dialogue simulation with in-context learning. arXiv preprint arXiv:2210.04185, 2022.
282
+ [68] Alisa Liu, Swabha Swayamdipta, Noah A. Smith, and Yejin Choi. WANLI: Worker and AI collaboration for natural language inference dataset creation. In Findings of the Association for Computational Linguistics: EMNLP 2022, pages 6826–6847, Abu Dhabi, United Arab Emirates, December 2022. Association for Computational Linguistics.
283
+ [69] Jiawei Liu, Chunqiu Steven Xia, Yuyao Wang, and Lingming Zhang. Is your code generated by chatgpt really correct? rigorous evaluation of large language models for code generation. arXiv preprint arXiv:2305.01210, 2023.
284
+ [70] Yat Long Lo, Christian Schroeder de Witt, Samuel Sokota, Jakob Nicolaus Foerster, and Shimon Whiteson. Cheap talk discovery and utilization in multi-agent reinforcement learning. In The Eleventh International Conference on Learning Representations, 2023.
285
+ [71] Shayne Longpre, Le Hou, Tu Vu, Albert Webson, Hyung Won Chung, Yi Tay, Denny Zhou, Quoc V Le, Barret Zoph, Jason Wei, et al. The flan collection: Designing data and methods for effective instruction tuning. arXiv preprint arXiv:2301.13688, 2023.
286
+ [72] Ryan Lowe, Yi I Wu, Aviv Tamar, Jean Harb, OpenAI Pieter Abbeel, and Igor Mordatch. Multi-agent actor-critic for mixed cooperative-competitive environments. Advances in neural information processing systems, 30, 2017.
287
+ [73] Pan Lu, Liang Qiu, Kai-Wei Chang, Ying Nian Wu, Song-Chun Zhu, Tanmay Rajpurohit, Peter Clark, and Ashwin Kalyan. Dynamic prompt learning via policy gradient for semi-structured mathematical reasoning. In ICLR, 2023.
288
+ [74] Michael J. Matthews, Samuel H. Matthews, and Thomas K. Kelemen. The alignment problem: Machine learning and human values. Personnel Psychology, 2022.
289
+
290
+ [75] Yu Meng, Jiaxin Huang, Yu Zhang, and Jiawei Han. Generating training data with language models: Towards zero-shot language understanding. In Advances in Neural Information Processing Systems, 2022.
291
+
292
+ [76] Marvin Minsky. Society of mind. Simon and Schuster, 1988.
293
+
294
+ [77] Marvin Minsky. The emotion machine: Commonsense thinking, artificial intelligence, and the future of the human mind. Simon and Schuster, 2007.
295
+
296
+ [78] Swaroop Mishra, Daniel Khashabi, Chitta Baral, and Hannaneh Hajishirzi. Cross-task generalization via natural language crowdsourcing instructions. In ACL, 2022.
297
+
298
+ [79] Igor Mordatch and Pieter Abbeel. Emergence of grounded compositional language in multi-agent populations. In Proceedings of the AAAI conference on artificial intelligence, volume 32, 2018.
299
+
300
+ [80] Reiichiro Nakano, Jacob Hilton, Suchir Balaji, Jeff Wu, Long Ouyang, Christina Kim, Christopher Hesse, Shantanu Jain, Vineet Kosaraju, William Saunders, Xu Jiang, Karl Cobbe, Tyna Eloundou, Gretchen Krueger, Kevin Button, Matthew Knight, Benjamin Chess, and John Schulman. Webgpt: Browser-assisted question-answering with human feedback, 2021.
301
+
302
+ [81] 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, 2021.
303
+
304
+ [82] OpenAI. Introducing chatgpt. Open AI Blog, 2022.
305
+
306
+ [83] OpenAI. Chatgpt plugins. OpenAI blog, 2023.
307
+
308
+ [84] 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.
309
+
310
+ [85] Liviu Panait and Sean Luke. Cooperative multi-agent learning: The state of the art. Autonomous Agents and Multi-Agent Systems, 11:387–434, 2005.
311
+
312
+ [86] Alexandros Papangelis, Karthik Gopalakrishnan, Aishwarya Padmakumar, Seokhwan Kim, Gokhan Tur, and Dilek Z. Hakkani-Tür. Generative conversational networks. In SIGDIAL, 2021.
313
+
314
+ [87] Wonpyo Park, Dongju Kim, Yan Lu, and Minsu Cho. Relational knowledge distillation. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 3967–3976, 2019.
315
+
316
+ [88] Peyman Passban, Yimeng Wu, Mehdi Rezagholizadeh, and Qun Liu. Alp-kd: Attention-based layer projection for knowledge distillation. In Proceedings of the AAAI Conference on artificial intelligence, volume 35, pages 13657–13665, 2021.
317
+
318
+ [89] Sundar Pichai. An important next step on our ai journey. Google Blog, 2023.
319
+
320
+ [90] Stefan Poslad. Specifying protocols for multi-agent systems interaction. ACM Transactions on Autonomous and Adaptive Systems (TAAS), 2(4):15–es, 2007.
321
+
322
+ [91] 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.
323
+
324
+ [92] 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.
325
+
326
+ [93] Laria Reynolds and Kyle McDonell. Prompt programming for large language models: Beyond the few-shot paradigm. In Extended Abstracts of the 2021 CHI Conference on Human Factors in Computing Systems, pages 1–7, 2021.
327
+
328
+ [94] Robin Rombach, Andreas Blattmann, Dominik Lorenz, Patrick Esser, and Björn Ommer. High-resolution image synthesis with latent diffusion models, 2021.
329
+
330
+ [95] Adriana Romero, Nicolas Ballas, Samira Ebrahimi Kahou, Antoine Chassang, Carlo Gatta, and Yoshua Bengio. Fitnets: Hints for thin deep nets. arXiv preprint arXiv:1412.6550, 2014.
331
+
332
+ [96] Andy Rosenbaum, Saleh Soltan, Wael Hamza, Yannick Versley, and Markus Boese. Linguist: Language model instruction tuning to generate annotated utterances for intent classification and slot tagging. arXiv preprint arXiv:2209.09900, 2022.
333
+
334
+ [97] Stuart J Russell. Artificial intelligence a modern approach. Pearson Education, Inc., 2010. [98] Gaurav Sahu, Pau Rodriguez, Issam H Laradji, Parmida Atighehchian, David Vazquez, and Dzmitry Bahdanau. Data augmentation for intent classification with off-the-shelf large language models. ACL, 2022. [99] William Saunders, Catherine Yeh, Jeff Wu, Steven Bills, Long Ouyang, Jonathan Ward, and Jan Leike. Self-critiquing models for assisting human evaluators. arXiv preprint arXiv:2206.05802, 2022.
335
+ [100] Timo Schick, Jane Dwivedi-Yu, Roberto Dessì, Roberta Raileanu, Maria Lomeli, Luke Zettlemoyer, Nicola Cancedda, and Thomas Scialom. Toolformer: Language models can teach themselves to use tools. arXiv preprint arXiv:2302.04761, 2023.
336
+ [101] Timo Schick and Hinrich Schütze. 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, November 2021. Association for Computational Linguistics.
337
+ [102] Junjie Sheng, Xiangfeng Wang, Bo Jin, Junchi Yan, Wenhao Li, Tsung-Hui Chang, Jun Wang, and Hongyuan Zha. Learning structured communication for multi-agent reinforcement learning. Autonomous Agents and Multi-Agent Systems, 36(2):50, 2022.
338
+ [103] Freda Shi, Mirac Suzgun, Markus Freitag, Xuezhi Wang, Suraj Srivats, Soroush Vosoughi, Hyung Won Chung, Yi Tay, Sebastian Ruder, Denny Zhou, et al. Language models are multilingual chain-of-thought reasoners. In ICLR, 2023.
339
+ [104] 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.
340
+ [105] Noah Shinn, Beck Labash, and Ashwin Gopinath. Reflexion: an autonomous agent with dynamic memory and self-reflection. arXiv preprint arXiv:2303.11366, 2023.
341
+ [106] Kurt Shuster, Jing Xu, Mojtaba Komeili, Da Ju, Eric Michael Smith, Stephen Roller, Megan Ung, Moya Chen, Kushal Arora, Joshua Lane, et al. Blenderbot 3: a deployed conversational agent that continually learns to responsibly engage. arXiv preprint arXiv:2208.03188, 2022.
342
+ [107] 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.
343
+ [108] 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.
344
+ [109] Abishek Sridhar, Robert Lo, Frank F. Xu, Hao Zhu, and Shuyan Zhou. Hierarchical prompting assists large language model on web navigation. In ArXiv, preprint.
345
+ [110] Jonathan Stray. Aligning ai optimization to community well-being. International Journal of Community Well-Being, 3:443 – 463, 2020.
346
+ [111] Sainbayar Sukhbaatar, Rob Fergus, et al. Learning multiagent communication with backpropagation. Advances in neural information processing systems, 29, 2016.
347
+ [112] Alex Tamkin, Miles Brundage, Jack Clark, and Deep Ganguli. Understanding the capabilities, limitations, and societal impact of large language models. arXiv preprint arXiv:2102.02503, 2021.
348
+ [113] Ming Tan. Multi-agent reinforcement learning: Independent versus cooperative agents. In International Conference on Machine Learning, 1997.
349
+ [114] Rohan Taori, Ishaan Gulrajani, Tianyi Zhang, Yann Dubois, Xuechen Li, Carlos Guestrin, Percy Liang, and Tatsunori B. Hashimoto. Stanford alpaca: An instruction-following llama model. https://github. com/tatsu-lab/stanford_alpaca, 2023.
350
+ [115] Gerald Tesauro et al. Temporal difference learning and td-gammon. Communications of the ACM, 38(3):58–68, 1995.
351
+ [116] Romal Thoppilan, Daniel De Freitas, Jamie Hall, Noam Shazeer, Apoorv Kulshreshtha, Heng-Tze Cheng, Alicia Jin, Taylor Bos, Leslie Baker, Yu Du, et al. Lamda: Language models for dialog applications. arXiv preprint arXiv:2201.08239, 2022.
352
+
353
+ [117] 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.
354
+
355
+ [118] 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.
356
+
357
+ [119] Yizhong Wang, Yeganeh Kordi, Swaroop Mishra, Alisa Liu, Noah A Smith, Daniel Khashabi, and Hannaneh Hajishirzi. Self-instruct: Aligning language model with self generated instructions. arXiv preprint arXiv:2212.10560, 2022.
358
+
359
+ [120] Yizhong Wang, Swaroop Mishra, Pegah Alipoormolabashi, Yeganeh Kordi, Amirreza Mirzaei, Anjana Arunkumar, Arjun Ashok, Arut Selvan Dhanasekaran, Atharva Naik, David Stap, et al. Supernaturalinstructions:generalization via declarative instructions on $1 6 0 0 +$ tasks. In EMNLP, 2022.
360
+
361
+ [121] 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 preprint arXiv:2109.01652, 2021.
362
+
363
+ [122] Jason Wei, Yi Tay, Rishi Bommasani, Colin Raffel, Barret Zoph, Sebastian Borgeaud, Dani Yogatama, Maarten Bosma, Denny Zhou, Donald Metzler, Ed H. Chi, Tatsunori Hashimoto, Oriol Vinyals, Percy Liang, Jeff Dean, and William Fedus. Emergent abilities of large language models. Transactions on Machine Learning Research, 2022. Survey Certification.
364
+
365
+ [123] 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.
366
+
367
+ [124] Thomas Wolf, Lysandre Debut, Victor Sanh, Julien Chaumond, Clement Delangue, Anthony Moi, Pierric Cistac, Tim Rault, Rémi 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, pages 38–45, Online, October 2020. Association for Computational Linguistics.
368
+
369
+ [125] Michael Wooldridge. An introduction to multiagent systems. John wiley & sons, 2009.
370
+
371
+ [126] Shunyu Yao, Jeffrey Zhao, Dian Yu, Nan Du, Izhak Shafran, Karthik Narasimhan, and Yuan Cao. ReAct: Synergizing reasoning and acting in language models. In International Conference on Learning Representations (ICLR), 2023.
372
+
373
+ [127] Sergey Zagoruyko and Nikos Komodakis. Paying more attention to attention: Improving the performance of convolutional neural networks via attention transfer. arXiv preprint arXiv:1612.03928, 2016.
374
+
375
+ [128] Eric Zelikman, Yuhuai Wu, Jesse Mu, and Noah D. Goodman. Star: Bootstrapping reasoning with reasoning, 2022.
376
+
377
+ [129] Houyu Zhang, Zhenghao Liu, Chenyan Xiong, and Zhiyuan Liu. Grounded conversation generation as guided traverses in commonsense knowledge graphs. In ACL, 2020.
378
+
379
+ [130] Rongsheng Zhang, Yinhe Zheng, Jianzhi Shao, Xiao-Xi Mao, Yadong Xi, and Minlie Huang. Dialogue distillation: Open-domain dialogue augmentation using unpaired data. ArXiv, abs/2009.09427, 2020.
380
+
381
+ [131] Susan Zhang, Stephen Roller, Naman Goyal, Mikel Artetxe, Moya Chen, Shuohui Chen, Christopher Dewan, Mona Diab, Xian Li, Xi Victoria Lin, et al. Opt: Open pre-trained transformer language models. arXiv preprint arXiv:2205.01068, 2022.
382
+
383
+ [132] Zhuosheng Zhang, Aston Zhang, Mu Li, and Alex Smola. Automatic chain of thought prompting in large language models. In ICLR, 2023.
384
+
385
+ [133] Zhuosheng Zhang, Aston Zhang, Mu Li, Hai Zhao, George Karypis, and Alex Smola. Multimodal chain-of-thought reasoning in language models. arXiv preprint arXiv:2302.00923, 2023.
386
+
387
+ [134] Denny Zhou, Nathanael Schärli, 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. arXiv preprint arXiv:2205.10625, 2022.
388
+
389
+ [135] Shuyan Zhou, Frank F Xu, Hao Zhu, Xuhui Zhou, Robert Lo, Abishek Sridhar, Xianyi Cheng, Yonatan Bisk, Daniel Fried, Uri Alon, et al. Webarena: A realistic web environment for building autonomous agents. arXiv preprint arXiv:2307.13854, 2023.
390
+
391
+ [136] Yongchao Zhou, Andrei Ioan Muresanu, Ziwen Han, Keiran Paster, Silviu Pitis, Harris Chan, and Jimmy Ba. Large language models are human-level prompt engineers. In The Eleventh International Conference on Learning Representations, 2023.
392
+ [137] Deyao Zhu, Jun Chen, Kilichbek Haydarov, Xiaoqian Shen, Wenxuan Zhang, and Mohamed Elhoseiny. Chatgpt asks, blip-2 answers: Automatic questioning towards enriched visual descriptions, 2023.
md/dev/42zs3qa2kpy/42zs3qa2kpy.md ADDED
@@ -0,0 +1,550 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # OFFLINE REINFORCEMENT LEARNING VIA HIGHFIDELITY GENERATIVE BEHAVIOR MODELING
2
+
3
+ Huayu Chen1, Cheng ${ { \bf L } } { \bf u } ^ { 1 }$ , Chengyang $\mathbf { Y i n g ^ { 1 } }$ , Hang $\mathbf { S u } ^ { 1 , 2 }$ ∗, $ { \mathbf { J u n } } { \mathbf { Z } } { \mathbf { h u } } ^ { 1 , 2 * }$
4
+ 1Department of Computer Science & Technology, Institute for AI, BNRist Center,
5
+ Tsinghua-Bosch Joint ML Center, THBI Lab, Tsinghua University
6
+ 2Pazhou Lab, Guangzhou, 510330, China
7
+ chenhuay21@mails.tsinghua.edu.cn
8
+ {lucheng.lc15,yingcy17}@gmail.com
9
+ {suhangss,dcszj}@tsinghua.edu.cn
10
+
11
+ # ABSTRACT
12
+
13
+ In offline reinforcement learning, weighted regression is a common method to ensure the learned policy stays close to the behavior policy and to prevent selecting out-of-sample actions. In this work, we show that due to the limited distributional expressivity of policy models, previous methods might still select unseen actions during training, which deviates from their initial motivation. To address this problem, we adopt a generative approach by decoupling the learned policy into two parts: an expressive generative behavior model and an action evaluation model. The key insight is that such decoupling avoids learning an explicitly parameterized policy model with a closed-form expression. Directly learning the behavior policy allows us to leverage existing advances in generative modeling, such as diffusionbased methods, to model diverse behaviors. As for action evaluation, we combine our method with an in-sample planning technique to further avoid selecting outof-sample actions and increase computational efficiency. Experimental results on D4RL datasets show that our proposed method achieves competitive or superior performance compared with state-of-the-art offline RL methods, especially in complex tasks such as AntMaze. We also empirically demonstrate that our method can successfully learn from a heterogeneous dataset containing multiple distinctive but similarly successful strategies, whereas previous unimodal policies fail. The source code is provided at https://github.com/ChenDRAG/SfBC.
14
+
15
+ # 1 INTRODUCTION
16
+
17
+ Offline reinforcement learning seeks to solve decision-making problems without interacting with the environment. This is compelling because online data collection can be dangerous or expensive in many realistic tasks. However, relying entirely on a static dataset imposes new challenges. One is that policy evaluation is hard because the mismatch between the behavior and the learned policy usually introduces extrapolation error (Fujimoto et al., 2019). In most offline tasks, it is difficult or even impossible for the collected transitions to cover the whole state-action space. When evaluating the current policy via dynamic programming, leveraging actions that are not presented in the dataset (out-of-sample) may lead to highly unreliable results, and thus performance degrade. Consequently, in offline RL it is critical to stay close to the behavior policy during training.
18
+
19
+ Recent advances in model-free offline methods mainly include two lines of work. The first is the adaptation of existing off-policy algorithms. These methods usually include value pessimism about unseen actions or regulations of feasible action space (Fujimoto et al., 2019; Kumar et al., 2019; 2020). The other line of work (Peng et al., 2019; Wang et al., 2020; Nair et al., 2020) is derived from constrained policy search and mainly trains a parameterized policy via weighted regression. Evaluations of every state-action pair in the dataset are used as regression weights.
20
+
21
+ The main motivation behind weighted policy regression is that it helps prevent querying out-of-sample actions (Nair et al., 2020; Kostrikov et al., 2022). However, we find that this argument is untenable in certain settings. Our key observation is that policy models in existing weighted policy regression methods are usually unimodal Gaussian models and thus lack distributional expressivity, while in the real world collected behaviors can be highly diverse. This distributional discrepancy might eventually lead to selecting unseen actions. For instance, given a bimodal target distribution, fitting it with a unimodal distribution unavoidably results in covering the low-density area between two peaks. In Section 3.1, we empirically show that lack of policy expressivity may lead to performance degrade.
22
+
23
+ Ideally, this problem could be solved by switching to a more expressive distribution class. However, it is nontrivial in practice since weighted regression requires exact and derivable density calculation, which places restrictions on distribution classes that we can choose from. Especially, we may not know what the behavior or optimal policy looks like in advance.
24
+
25
+ To overcome the limited expressivity problem, we propose to decouple the learned policy into two parts: an expressive generative behavior model and an action evaluation model. Such decoupling avoids explicitly learning a policy model whose target distribution is difficult to sample from, whereas learning a behavior model is much easier because sampling from the behavior policy is straightforward given the offline dataset collected by itself. Access to data samples from the target distribution is critical because it allows us to leverage existing advances in generative methods to model diverse behaviors. To sample from the learned policy, we use importance sampling to select actions from candidates proposed by the behavior model with the importance weights computed by the action evaluation model, which we refer to as Selecting from Behavior Candidates (SfBC).
26
+
27
+ However, the selecting-from-behavior-candidates approach introduces new challenges because it requires modeling behaviors with high fidelity, which directly determines the feasible action space. A prior work (Ghasemipour et al., 2021) finds that typically-used VAEs do not align well with the behavior dataset, and that introducing building-in good inductive biases in the behavior model improves the algorithm performance. Instead, we propose to learn from diverse behaviors using a much more expressive generative modeling method, namely diffusion probabilistic models (Ho et al., 2020), which have recently achieved great success in modeling diverse image distributions, outperforming other existing generative models (Dhariwal & Nichol, 2021). We also propose a planning-based operator for Q-learning, which performs implicit planning strictly within dataset trajectories based on the current policy, and is provably convergent. The planning scheme greatly reduces bootstrapping steps required for dynamic programming and thus can help to further reduce extrapolation error and increase computational efficiency.
28
+
29
+ The main contributions of this paper are threefold: 1. We address the problem of limited policy expressivity in conventional methods by decoupling policy learning into behavior learning and action evaluation, which allows the policy to inherit distributional expressivity from a diffusion-based behavior model. 2. The learned policy is further combined with an implicit in-sample planning technique to suppress extrapolation error and assist dynamic programming over long horizons. 3. Extensive experiments demonstrate that our method achieves competitive or superior performance compared with state-of-the-art offline RL methods, especially in sparse-reward tasks such as AntMaze.
30
+
31
+ # 2 BACKGROUND
32
+
33
+ # 2.1 CONSTRAINED POLICY SEARCH IN OFFLINE RL
34
+
35
+ Consider a Markov Decision Process (MDP), described by a tuple $\langle S , \mathcal { A } , P , r , \gamma \rangle$ . $s$ denotes the state space and $\mathcal { A }$ is the action space. $P ( \pmb { s } ^ { \prime } | \pmb { s } , \pmb { a } )$ and $r ( s , a )$ respectively represent the transition and reward functions, and $\gamma \in ( 0 , 1 ]$ is the discount factor. Our goal is to maximize the expected discounted return $J ( \pi ) = \mathbb { E } _ { s \sim \rho _ { \pi } ( s ) } \mathbb { E } _ { \pmb { a } \sim \pi ( \cdot | s ) } \left[ r ( s , \pmb { a } ) \right]$ of policy $\pi$ , where $\begin{array} { r } { \rho _ { \pi } ( \pmb { \mathscr { s } } ) = \sum _ { n = 0 } ^ { \infty } \gamma ^ { n } \bar { p } _ { \pi } ( \pmb { \mathscr { s } } _ { n } = \pmb { \mathscr { s } } ) } \end{array}$ is the discounted state visitation frequencies induced by the policy $\pi$ (Sutton $\&$ Barto, 1998).
36
+
37
+ According to the policy gradient theorem (Sutton et al., 1999), given a parameterized policy $\pi _ { \theta }$ , and the policy’s state-action function $Q ^ { \pi }$ , the gradient of $J ( \pi _ { \theta } )$ can be derived as:
38
+
39
+ $$
40
+ \nabla _ { \theta } J ( \pi _ { \theta } ) = \int _ { S } \rho _ { \pi } ( s ) \int _ { A } \nabla _ { \theta } \pi _ { \theta } ( \boldsymbol { a } | s ) Q ^ { \pi } ( s , \boldsymbol { a } ) \mathrm { d } a \ \mathrm { d } s .
41
+ $$
42
+
43
+ When online data collection from policy $\pi$ is not possible, it is difficult to estimate $\rho _ { \pi } ( s )$ in Equation 1, and thus the expected value of the Q-function $\begin{array} { r } { \eta ( \bar { \boldsymbol { \pi } } _ { \boldsymbol { \theta } } ) : = \int _ { S } \rho _ { \pi } ( \pmb { \mathscr { s } } ) \int _ { \mathcal { A } } \pi _ { \boldsymbol { \theta } } ( \pmb { a } | \pmb { \mathscr { s } } ) Q ^ { \pi } ( \pmb { \mathscr { s } } , \dot { \pmb { a } } ) } \end{array}$ . Given a static dataset ${ \mathcal { D } } ^ { \mu }$ consisting of multiple trajectories $\{ ( s _ { n } , a _ { n } , r _ { n } ) \}$ collected by a behavior policy $\mu ( { \pmb a } | { \pmb s } )$ , previous off-policy methods (Silver et al., 2014; Lillicrap et al., 2016) estimate $\eta ( \pi _ { \theta } )$ with a surrogate objective $\hat { \eta } ( \pi _ { \boldsymbol { \theta } } )$ by replacing $\rho _ { \pi } ( s )$ with $\rho _ { \mu } ( s )$ . In offline settings, due to the importance of sticking with the behavior policy, prior works (Peng et al., 2019; Nair et al., 2020) explicitly constrain the learned policy $\pi$ to be similar to $\mu$ , while maximizing the expected value of the Q-functions:
44
+
45
+ $$
46
+ \arg \operatorname* { m a x } _ { \pi } \quad \int _ { S } \rho _ { \mu } ( s ) \int _ { \mathcal { A } } \pi ( a | s ) Q _ { \phi } ( s , a ) \mathrm { d } a \mathrm { d } s - \frac { 1 } { \alpha } \int _ { S } \rho _ { \mu } ( s ) D _ { \mathrm { K L } } \left( \pi ( \cdot | s ) \right| | \mu ( \cdot | s ) ) \mathrm { d } s .
47
+ $$
48
+
49
+ The first term in Equation 2 corresponds to the surrogate objective $\hat { \eta } ( \pi _ { \boldsymbol { \theta } } )$ , where $Q _ { \phi } ( s , \pmb { a } )$ is a learned Q-function of the current policy $\pi$ . The second term is a regularization term to constrain the learned policy within support of the dataset ${ \mathcal { D } } ^ { \mu }$ with $\alpha$ being the coefficient.
50
+
51
+ # 2.2 POLICY IMPROVEMENT VIA WEIGHTED REGRESSION
52
+
53
+ The optimal policy $\pi ^ { * }$ for Equation 2 can be derived (Peters et al., 2010; Peng et al., 2019; Nair et al., 2020) by use of Lagrange multiplier:
54
+
55
+ $$
56
+ \pi ^ { * } ( { \pmb a } | { \pmb s } ) = \frac { 1 } { Z ( { \pmb s } ) } \mu ( { \pmb a } | { \pmb s } ) \exp \left( \alpha Q _ { \phi } ( { \pmb s } , { \pmb a } ) \right) ,
57
+ $$
58
+
59
+ where $Z ( s )$ is the partition function. Equation 3 forms a policy improvement step.
60
+
61
+ Directly sampling from $\pi ^ { * }$ requires explicitly modeling behavior $\mu$ , which itself is challenging in continuous action-space domains since $\mu$ can be very diverse. Prior methods (Peng et al., 2019; Wang et al., 2020; Chen et al., 2020) bypass this issue by projecting $\pi ^ { * }$ onto a parameterized policy $\pi _ { \theta }$ :
62
+
63
+ $$
64
+ \begin{array} { r l } { \underset { \theta } { \mathrm { a r g } \mathrm { m i n } } } & { \mathbb { E } _ { s \sim \mathcal { D } ^ { \mu } } \left[ D _ { \mathrm { K L } } \left( \pi ^ { * } ( \cdot | s ) | | \pi _ { \theta } ( \cdot | s ) \right) \right] } \\ { \underset { \theta } { = \mathrm { a r g } \mathrm { m a x } } } & { \mathbb { E } _ { ( s , a ) \sim \mathcal { D } ^ { \mu } } \left[ \cfrac { 1 } { Z ( s ) } \mathrm { l o g } \pi _ { \theta } ( a | s ) \exp \left( \alpha Q _ { \phi } ( s , a ) \right) \right] . } \end{array}
65
+ $$
66
+
67
+ Such a method is usually referred to as weighted regression, with $\exp { ( \alpha Q _ { \phi } ( s , pmb { a } ) ) }$ being the regression weights.
68
+
69
+ Although weighted regression avoids the need to model the behavior policy explicitly, it requires calculating the exact density function $\pi _ { \boldsymbol { \theta } } ( \pmb { a } | \pmb { s } )$ as in Equation 4. This constrains the policy $\pi _ { \theta }$ to distribution classes that have a tractable expression for the density function. We find this in practice limits the model expressivity and could be suboptimal in some cases (Section 3.1).
70
+
71
+ # 2.3 DIFFUSION PROBABILISTIC MODEL
72
+
73
+ Diffusion models (Sohl-Dickstein et al., 2015; Ho et al., 2020; Song et al., 2021b) are generative models by first defining a forward process to gradually add noise to an unknown data distribution $p _ { 0 } ( { \pmb x } _ { 0 } )$ and then learning to reverse it. The forward process $\{ \pmb { x } ( t ) \} _ { t \in [ 0 , T ] }$ is defined by a stochastic differential equation (SDE) $\mathrm { d } \pmb { x } _ { t } = f ( \pmb { x } _ { t } , t ) \mathrm { d } t + g ( t ) \mathrm { d } \pmb { w } _ { t }$ , where ${ \pmb w } _ { t }$ is a standard Brownian motion and $f ( t ) , g ( t )$ are hand-crafted functions (Song et al., 2021b) such that the transition distribution $p _ { t 0 } ( \pmb { x } _ { t } | \pmb { x } _ { 0 } ) = \mathcal { N } ( \pmb { x } _ { t } | \alpha _ { t } \pmb { x } _ { 0 } , \sigma _ { t } ^ { 2 } \pmb { I } )$ for some $\alpha _ { t } , \sigma _ { t } > 0$ and $p _ { T } ( \pmb { x } _ { T } ) \approx \mathcal { N } ( \pmb { x } _ { T } | 0 , \pmb { I } )$ . To reverse the forward process, diffusion models define a scored-based model $\scriptstyle { \pmb { s } } \theta$ and optimize the parameter $\theta$ by:
74
+
75
+ $$
76
+ \underset { \theta } { \arg \operatorname* { m i n } } \quad \mathbb { E } _ { t , { \boldsymbol { x } } _ { 0 } , { \boldsymbol { \epsilon } } } [ \| { \boldsymbol { \sigma } } _ { t } { \bf s } _ { \theta } ( { \boldsymbol { x } } _ { t } , t ) + { \boldsymbol { \epsilon } } \| _ { 2 } ^ { 2 } ] ,
77
+ $$
78
+
79
+ where $t \sim \mathcal { U } ( 0 , T )$ $\begin{array} { r } { \hat { \mathbf { \Phi } } ) , \pmb { x } _ { 0 } \sim p _ { 0 } ( \pmb { x } _ { 0 } ) , \pmb { \epsilon } \sim \mathcal { N } ( 0 , \pmb { I } ) , \pmb { x } _ { t } = \alpha _ { t } \pmb { x } _ { 0 } + \sigma _ { t } \pmb { \epsilon } . } \end{array}$
80
+
81
+ Sampling by diffusion models can be alternatively viewed as discretizing the diffusion ODEs (Song et al., 2021b), which are generally faster than discretizing the diffusion SDEs (Song et al., 2021a; Lu et al., 2022). Specifically, the sampling procedure needs to first sample a pure Gaussian $x _ { T } \sim$ $\mathcal { N } ( 0 , \pmb { I } )$ , and then solve the following ODE from time $T$ to time 0 by numerical ODE solvers:
82
+
83
+ $$
84
+ \mathrm { d } { \pmb x } _ { t } = \bigg [ f ( { \pmb x } _ { t } , t ) - \frac { 1 } { 2 } g ^ { 2 } ( t ) { \pmb s } _ { \theta } ( { \pmb x } _ { t } , t ) \bigg ] \mathrm { d } t .
85
+ $$
86
+
87
+ Then the final solution $\scriptstyle { \pmb x } _ { 0 }$ at time $0$ is the sample from the diffusion models.
88
+
89
+ # 3 METHOD
90
+
91
+ We propose a Selecting-from-Behavior-Candidates (SfBC) approach to address the limited expressivity problem in offline RL. Below we first motivate our method by highlighting the importance of a distributionally expressive policy in learning from diverse behaviors. Then we derive a high-level solution to this problem from a generative modeling perspective.
92
+
93
+ # 3.1 LEARNING FROM DIVERSE BEHAVIORS
94
+
95
+ In this section, we show that the weighted regression broadly used in previous works might limit the distributional expressivity of the policy and lead to performance degrade. As described in Section 2.2, conventional policy regression methods project the optimal policy $\pi ^ { * }$ in Equation 3 onto a parameterized policy set. In continuous action-space domains, the projected policy is usually limited to a narrow range of unimodal distributions (e.g., squashed Gaussian), whereas the behavior policy could be highly diverse (e.g., multimodal). Lack of expressivity directly prevents the RL agent from exactly mimicking a diverse behavior policy. This could eventually lead to sampling undesirable out-of-sample actions during policy evaluation and thus large extrapolation error. Even if Q-values can be accurately estimated, an inappropriate unimodal assumption about the optimal policy might still prevent extracting a policy that has multiple similarly rewarding but distinctive strategies.
96
+
97
+ We design a simple task named Bidirectional Car to better explain this point. Consider an environment where a car placed in the middle of two endpoints can go either side to gain the final reward. If an RL agent finds turning left and right similarly rewarding, by incorrectly assuming a unimodal distribution of the behavior policy, it ends up staying put instead of taking either one of the optimal actions (Figure 1). As a result, unimodal policies fail to completely solve this task or loss diversity whereas a more distributionally expressive policy easily succeeds.
98
+
99
+ ![](images/591df92c0ef0d29924a2012250a43e016d1fe0ad6c22f9897283aff063517013.jpg)
100
+ Figure 1: Illustration of the Bidirectional-Car task and comparison between SfBC and unimodal policies. See Section 6.2 for experimental details.
101
+
102
+ We therefore deduce that distributional expressivity is a necessity to enable diverse behavior learning. To better model the complex behavior policy, we need more powerful generative modeling for the policy distribution, instead of the simple and unimodal Gaussians.
103
+
104
+ # 3.2 SELECTING FROM BEHAVIOR CANDIDATES
105
+
106
+ In this section, we provide a generative view of how to model a potentially diverse policy. Specifically, in order to model $\pi ^ { * }$ with powerful generative models, essentially we need to perform maximum likelihood estimation for the model policy $\pi _ { \theta }$ , which is equivalent to minimizing KL divergence between the optimal and model policy:
107
+
108
+ $$
109
+ \begin{array} { r l } { \underset { \theta } { \arg \operatorname* { m a x } } } & { \mathbb { E } _ { s \sim \mathcal { D } ^ { \mu } } \mathbb { E } _ { a \sim \pi ^ { * } ( \cdot | s ) } \left[ \log \pi _ { \theta } ( a | s ) \right] \Leftrightarrow \underset { \theta } { \arg \operatorname* { m i n } } \quad \mathbb { E } _ { s \sim \mathcal { D } ^ { \mu } } \left[ D _ { \mathrm { K L } } \left( \pi ^ { * } ( \cdot | s ) | | \pi _ { \theta } ( \cdot | s ) \right) \right] . } \end{array}
110
+ $$
111
+
112
+ However, drawing samples directly from $\pi ^ { * }$ is difficult, so previous methods (Peng et al., 2019; Nair et al., 2020; Wang et al., 2020) rely on the weighted regression as described in Equation 4.
113
+
114
+ The main reason that limits the expressivity of $\pi _ { \theta }$ is the need of calculating exact and derivable density function $\pi _ { \boldsymbol { \theta } } ( \pmb { a } | \pmb { s } )$ in policy regression, which places restrictions on distribution classes that we can choose from. Also, we might not know what the behavior or optimal policy looks like previously.
115
+
116
+ Our solution is based on a key observation that directly parameterizing the policy $\pi$ is not necessary. To better model a diverse policy, we propose to decouple the learning of $\pi$ into two parts. Specifically, we leverage Equation 3 to form a policy improvement step:
117
+
118
+ $$
119
+ \pi ( { \pmb a } | { \pmb s } ) \propto \mu _ { \theta } ( { \pmb a } | { \pmb s } ) \exp \left( \alpha Q _ { \phi } ( { \pmb s } , { \pmb a } ) \right) .
120
+ $$
121
+
122
+ One insight of the equation above is that minimizing KL divergence between $\mu$ and $\mu _ { \theta }$ is much easier compared with directly learning $\pi _ { \theta }$ because sampling from $\mu$ is straightforward given $D ^ { \mu }$ . This allows to us to leverage most existing advances in generative modeling (Section 4.1). $Q _ { \phi } ( s , a )$ could be learned using the existing Q-learning framework (Section 4.2).
123
+
124
+ The inverse temperature parameter $\alpha$ in Equation 8 serves as a trade-off between conservative and greedy improvement. We can see that when $\alpha 0$ , the learned policy falls back to the behavior policy, and when $\alpha + \infty$ the learned policy becomes a greedy policy.
125
+
126
+ To sample actions from $\pi$ , we use an importance sampling technique. Specifically, for any state $\pmb { s }$ , first we draw $M$ action samples from a learned behavior policy $\mu _ { \boldsymbol { \theta } } ( \cdot | \boldsymbol { s } )$ as candidates. Then we evaluate these action candidates with a learned critic $Q _ { \phi }$ . Finally, an action is resampled from $M$ candidates with $\exp { ( \alpha Q _ { \phi } ( s , \pmb { a } ) ) }$ being the sampling weights. We summarize this procedure as selecting from behavior candidates (SfBC), which could be understood as an analogue to rejection sampling.
127
+
128
+ Although generative modeling of the behavior policy has been explored by several works (Fujimoto et al., 2019; Kumar et al., 2019), it was mostly used to form an explicit distributional constraint for the policy model $\pi _ { \theta }$ . In contrast, we show directly leveraging the learned behavior model to generate actions is not only feasible but beneficial on the premise that high-fidelity behavior modeling can be achieved. We give a practical implementation in the next section.
129
+
130
+ # 4 PRACTICAL IMPLEMENTATION
131
+
132
+ In this section, we derive a practical implementation of SfBC, which includes diffusion-based behavior modeling and planning-based Q-learning. An algorithm overview is given in Appendix A.
133
+
134
+ # 4.1 DIFFUSION-BASED BEHAVIOR MODELING
135
+
136
+ It is critical that the learned behavior model is of high fidelity because generating any out-of-sample actions would result in unwanted extrapolation error, while failing to cover all in-sample actions would restrict feasible action space for the policy. This requirement brings severe challenges to existing behavior modeling methods, which mainly include using Gaussians or VAEs. Gaussian models suffer from limited expressivity as we have discussed in Section 3.1. VAEs, on the other hand, need to introduce a variational posterior distribution to optimize the model distribution, which has a trade-off between the expressivity and the tractability (Kingma et al., 2016; Lucas et al., 2019). This still limits the expressivity of the model distribution. An empirical study is given in Section 6.3.
137
+
138
+ To address this problem, we propose to learn from diverse behaviors using diffusion models (Ho et al., 2020), which have recently achieved great success in modeling diverse image distributions (Ramesh et al., 2022; Saharia et al., 2022), outperforming other generative models (Dhariwal & Nichol, 2021). Specifically, we follow Song et al. (2021b) and learn a state-conditioned diffusion model $s _ { \theta }$ to predict the time-dependent noise added to the action $^ { a }$ sampled from the behavior policy $\mu ( \cdot | s )$ :
139
+
140
+ $$
141
+ \theta = \underset { \theta } { \arg \operatorname* { m i n } } \quad \mathbb { E } _ { ( s , a ) \sim D ^ { \mu } , \epsilon , t } [ \| \sigma _ { t } \mathbf { s } _ { \theta } ( \alpha _ { t } \pmb { a } + \sigma _ { t } \epsilon , s , t ) + \epsilon \| _ { 2 } ^ { 2 } ] ,
142
+ $$
143
+
144
+ where $\epsilon \sim \mathcal { N } ( 0 , I )$ , $t \sim \mathcal { U } ( 0 , T )$ . $\alpha _ { t }$ and $\sigma _ { t }$ are determined by the forward diffusion process. Intuitively $s _ { \theta }$ is trained to denoise $\mathbf { \sigma } _ { \mathbf { } } \mathbf { a } _ { t } : = \alpha _ { t } \mathbf { \pmb { a } } + \sigma _ { t } \mathbf { \epsilon } \mathbf { \epsilon }$ into the unperturbed action $^ { a }$ such that $a _ { T } \sim$ $\mathcal { N } ( 0 , \pmb { I } )$ can be transformed into $\begin{array} { r } { \pmb { a } \sim \mu _ { \theta } ( \cdot | \pmb { s } ) } \end{array}$ by solving an inverse ODE defined by $s _ { \theta }$ (Equation 6).
145
+
146
+ # 4.2 Q-LEARNING VIA IN-SAMPLE PLANNING
147
+
148
+ Generally, Q-learning can be achieved via the Bellman expectation operator:
149
+
150
+ $$
151
+ \begin{array} { r } { \mathcal { T } ^ { \pi } Q ( s , a ) = r ( s , a ) + \gamma \mathbb { E } _ { s ^ { \prime } \sim P ( \cdot \mid s , a ) , a ^ { \prime } \sim \pi ( \cdot \mid s ^ { \prime } ) } Q ( s ^ { \prime } , a ^ { \prime } ) . } \end{array}
152
+ $$
153
+
154
+ However, $\tau ^ { \pi }$ is based on one-step bootstrapping, which has two drawbacks: First, this can be computationally inefficient due to its dependence on many steps of extrapolation. This drawback is exacerbated in diffusion settings since drawing actions from policy $\pi$ in Equation 10 is also time-consuming because of many iterations of Langevin-type sampling. Second, estimation errors may accumulate over long horizons. To address these problems, we take inspiration from episodic learning methods (Blundell et al., 2016; Ma et al., 2022) and propose a planning-based operator $\mathcal { T } _ { \mu } ^ { \pi }$
155
+
156
+ $$
157
+ \begin{array} { r } { \mathcal { T } _ { \mu } ^ { \pi } Q ( s , \pmb { a } ) : = \underset { n \geq 0 } { \operatorname* { m a x } } \{ ( \mathcal { T } ^ { \mu } ) ^ { n } \mathcal { T } ^ { \pi } Q ( s , \pmb { a } ) \} , } \end{array}
158
+ $$
159
+
160
+ ![](images/4de8fba46e273afb595ba61890452a4a5121add659582f5fbaf2bd8e5ce12955.jpg)
161
+ Figure 2: Visualizations of the implicitly planned $\mathrm { Q }$ -targets $R _ { n } ^ { ( k ) }$ sampled from the dataset of an AntMaze task in four consecutive value iterations. The red pentagram stands for the reward signal. Implicit planning helps to iteratively stitch together successful subtrajectories.
162
+
163
+ where $\mu$ is the behavior policy. $\mathcal { T } _ { \mu } ^ { \pi }$ combines the strengths of both the n-step operator $( { \mathcal { T } } ^ { \mu } ) ^ { n }$ , which enjoys a fast contraction property, and the operator $\mathcal { T } ^ { \pi }$ , which has a more desirable fixed point. We prove in Appendix $\textrm { C }$ that $\mathcal { T } _ { \mu } ^ { \pi }$ is also convergent, and its fixed point is bounded between $Q ^ { \pi }$ and $Q ^ { * }$ .
164
+
165
+ Practically, given a dataset $\mathcal { D } ^ { \mu } = \{ ( s _ { n } , a _ { n } , r _ { n } ) \}$ collected by behavior $\mu$ , with $n$ being the timestep in a trajectory. We can rewrite Equation 11 in a recursive manner to calculate the Q-learning targets:
166
+
167
+ $$
168
+ \begin{array} { r l } & { R _ { n } ^ { ( k ) } = r _ { n } + \gamma \operatorname* { m a x } ( R _ { n + 1 } ^ { ( k ) } , V _ { n + 1 } ^ { ( k - 1 ) } ) , } \\ { \mathrm { w h e r e } \quad V _ { n } ^ { ( k - 1 ) } : = \mathbb { E } _ { a \sim \pi ( \cdot \vert s _ { n } ) } Q _ { \phi } ( s _ { n } , a ) , } \\ { \mathrm { a n d } \quad \phi = \underset { \phi } { \arg \operatorname* { m i n } } \quad \mathbb { E } _ { ( s _ { n } , a _ { n } ) \sim \mathcal { D } ^ { \mu } } \Vert Q _ { \phi } ( s _ { n } , a _ { n } ) - R _ { n } ^ { ( k - 1 ) } \Vert _ { 2 } ^ { 2 } . } \end{array}
169
+ $$
170
+
171
+ Above $k \in \{ 1 , 2 , \dots \}$ is the iteration number. We define ${ \cal R } _ { n } ^ { ( 0 ) }$ as the vanilla return of trajectories. Equation 12 offers an implicit planning scheme within dataset trajectories that mainly helps to avoid bootstrapping over unseen actions and to accelerate convergence. Equation 13 enables the generalization of actions in similar states across different trajectories (stitching together subtrajectories). Note that we have omitted writing the iteration superscript of $\pi$ and $\mu$ for simplicity. During training, we alternate between calculating new Q-targets $R _ { n }$ and fitting the action evaluation model $Q _ { \phi }$ .
172
+
173
+ Although the operator $\mathcal { T } _ { \mu } ^ { \pi }$ is inspired by the multi-step estimation operator $\mathcal { T } _ { \mathrm { v e m } }$ proposed by Ma et al. (2022). They have notable differences in theoretical properties. First, $\mathcal { T } _ { \mathrm { v e m } }$ can only apply to deterministic environments, while our method also applies to stochastic settings. Second, unlike $\mathcal { T } _ { \mathrm { v e m } }$ $\mathcal { T } _ { \mu } ^ { \pi }$ does not share the same fixed point with $\tau ^ { \pi }$ . We compare two methods in detail in Appendix G.
174
+
175
+ # 5 RELATED WORK
176
+
177
+ Reducing extrapolation error in offline RL. Offline RL typically requires careful trade-offs between maximizing expected returns and staying close to the behavior policy. Once the learned policy deviates from the behavior policy, extrapolation error will be introduced in dynamic programming, leading to performance degrade (Fujimoto et al., 2019). Several works propose to address this issue by introducing either policy regularization on the distributional discrepancy with the behavior policy (Fujimoto et al., 2019; Kumar et al., 2019; Wu et al., 2019; Fujimoto & Gu, 2021), or value pessimism about unseen actions (Kumar et al., 2020; Kostrikov et al., 2021). Another line of research directly extracts policy from the dataset through weighted regression, hoping to avoid selecting unseen actions (Peng et al., 2019; Nair et al., 2020; Wang et al., 2020). However, some recent works observe that the trade-off techniques described above are not sufficient to reduce extrapolation error, and propose to learn Q-functions through expectile regression without ever querying policy-generated actions (Kostrikov et al., 2022; Ma et al., 2022). Unlike them, We find that limited policy expressivity is the main reason that introduces extrapolation error in previous weighted regression methods, and use an expressive policy model to help reduce extrapolation error.
178
+
179
+ Dynamic programming over long horizons. Simply extracting policies from behavior Q-functions can yield good performance in many D4RL tasks because it avoids dynamic programming and therefore the accompanied extrapolation error (Peng et al., 2019; Chen et al., 2020; Brandfonbrener et al., 2021). However, Kostrikov et al. (2022) shows this method performs poorly in tasks that require stitching together successful subtrajectories (e.g., Maze-like environments). Such tasks are also challenging for methods based on one-step bootstrapping because they might require hundreds of steps to reach the reward signal, with the reward discounted and estimation error accumulated along the way. Episodic memory-based methods address this problem by storing labeled experience in the dataset, and plans strictly within the trajectory to update evaluations of every decision (Blundell et al., 2016; Hu et al., 2021; Ma et al., 2022). The in-sample planning scheme allows dynamic programming over long horizons to suppress the accumulation of extrapolation error, which inspires our method.
180
+
181
+ Table 1: Evaluation numbers of SfBC. Scores are normalized according to Fu et al. (2020). Numbers within 5 percent of the maximum in every individual task are highlighted in boldface. Experiment and evaluation details are provided in Appendix B. We report scores with 15 diffusion steps.
182
+
183
+ <table><tr><td>Dataset</td><td>Environment</td><td>SfBC (Ours)</td><td>IQL</td><td>VEM</td><td>AWR</td><td>BAIL</td><td>BCQ</td><td>CQL</td><td>DT</td><td>Diffuser</td></tr><tr><td>Medium-Expert</td><td>HalfCheetah</td><td>92.6±0.5</td><td>86.7</td><td>-</td><td>52.7</td><td>72.2</td><td>64.7</td><td>62.4</td><td>86.8</td><td>79.8</td></tr><tr><td>Medium-Expert</td><td>Hopper</td><td>108.6 ± 2.1</td><td>91.5</td><td>-</td><td>27.1</td><td>106.2</td><td>100.9</td><td>98.7</td><td>107.6</td><td>107.2</td></tr><tr><td>Medium-Expert</td><td>Walker</td><td>109.8± 0.2</td><td>109.6</td><td>-</td><td>53.8</td><td>107.2</td><td>57.5</td><td>111.0</td><td>108.1</td><td>108.4</td></tr><tr><td>Medium</td><td>HalfCheetah</td><td>45.9 ± 2.2</td><td>47.4</td><td>47.4</td><td>37.4</td><td>30.0</td><td>40.7</td><td>44.4</td><td>42.6</td><td>44.2</td></tr><tr><td>Medium</td><td>Hopper</td><td>57.1 ± 4.1</td><td>66.3</td><td>56.6</td><td>35.9</td><td>62.2</td><td>54.5</td><td>58.0</td><td>67.6</td><td>58.5</td></tr><tr><td>Medium</td><td>Walker</td><td>77.9 ± 2.5</td><td>78.3</td><td>74.0</td><td>17.4</td><td>73.4</td><td>53.1</td><td>79.2</td><td>74.0</td><td>79.7</td></tr><tr><td>Medium-Replay</td><td>HalfCheetah</td><td>37.1 ± 1.7</td><td>44.2</td><td>1</td><td>40.3</td><td>40.3</td><td>38.2</td><td>46.2</td><td>36.6</td><td>42.2</td></tr><tr><td>Medium-Replay</td><td>Hopper</td><td>86.2 ±9.1</td><td>94.7</td><td>1</td><td>28.4</td><td>94.7</td><td>33.1</td><td>48.6</td><td>82.7</td><td>96.8</td></tr><tr><td>Medium-Replay</td><td>Walker</td><td>65.1±5.6</td><td>73.9</td><td>-</td><td>15.5</td><td>58.8</td><td>15.0</td><td>26.7</td><td>66.6</td><td>61.2</td></tr><tr><td colspan="2">Average (Locomotion)</td><td>75.6</td><td>76.9</td><td>-</td><td>34.3</td><td>71.6</td><td>51.9</td><td>63.9</td><td>74.7</td><td>75.3</td></tr><tr><td>Default</td><td>AntMaze-umaze</td><td>92.0±2.1</td><td>87.5</td><td>87.5</td><td>56.0</td><td>85.0</td><td>78.9</td><td>74.0</td><td>59.2</td><td>-</td></tr><tr><td>Diverse</td><td>AntMaze-umaze</td><td>85.3±3.6</td><td>62.2</td><td>78.0</td><td>70.3</td><td>76.7</td><td>55.0</td><td>84.0</td><td>53.0</td><td>-</td></tr><tr><td>Play</td><td>AntMaze-medium</td><td>81.3± 2.6</td><td>71.2</td><td>78.0</td><td>0.0</td><td>15.0</td><td>0.0</td><td>61.2</td><td>0.0</td><td>-</td></tr><tr><td>Diverse</td><td>AntMaze-medium</td><td>82.0±3.1</td><td>70.0</td><td>77.0</td><td>0.0</td><td>23.3</td><td>0.0</td><td>53.7</td><td>0.0</td><td>-</td></tr><tr><td>Play</td><td>AntMaze-large</td><td>59.3±14.3</td><td>39.6</td><td>57.0</td><td>0.0</td><td>0.0</td><td>6.7</td><td>15.8</td><td>0.0</td><td>-</td></tr><tr><td>Diverse</td><td>AntMaze-large</td><td>45.5 ± 6.6</td><td>47.5</td><td>58.0</td><td>0.0</td><td>8.3</td><td>2.2</td><td>14.9</td><td>0.0</td><td>-</td></tr><tr><td colspan="2">Average (AntMaze)</td><td>74.2</td><td>63.0</td><td>72.6</td><td>21.0</td><td>46.7</td><td>23.8</td><td>50.6</td><td>18.7</td><td>-</td></tr><tr><td colspan="2">Average (Maze2d)</td><td>74.0</td><td>50.0</td><td>-</td><td>10.8</td><td>-</td><td>9.1</td><td>7.7</td><td>-</td><td>119.5</td></tr><tr><td colspan="2">Average (FrankaKitchen)</td><td>57.1</td><td>53.3</td><td>-</td><td>8.7</td><td>-</td><td>11.7</td><td>48.2</td><td>-</td><td>-</td></tr><tr><td>Both-side</td><td>Bidirectional-Car</td><td>100.0±0.0</td><td>15.7</td><td>0.0</td><td>0.0</td><td>52.0</td><td>88.0</td><td>42.3</td><td>33.3</td><td>-</td></tr><tr><td>Single-side</td><td>Bidirectional-Car</td><td>100.0±0.0</td><td>100.0</td><td>100.0</td><td>96.3</td><td>100.0</td><td>100.0</td><td>100.0</td><td>100.0</td><td>1</td></tr></table>
184
+
185
+ Generative models for behavior modeling. Cloning diverse behaviors in a continuous action space requires powerful generative models. In offline RL, several works (Fujimoto et al., 2019; Kumar et al., 2019; Wu et al., 2019; Zhou et al., 2021; Chen et al., 2022) have tried using generative models such as Gaussians or VAEs to model the behavior policy. However, the learned behavior model only serves as an explicit distributional constraint for another policy during training. In broader RL research, generative adversarial networks (Goodfellow et al., 2020), masked autoencoders (Germain et al., 2015), normalizing flows (Dinh et al., 2016), and energy-based models (Du & Mordatch, 2019) have also been used for behavior modeling (Ho & Ermon, 2016; Ghasemipour et al., 2021; Singh et al., 2020; Liu et al., 2020). Recently, diffusion models (Ho et al., 2020) have achieved great success in generating diverse and high-fidelity image samples (Dhariwal & Nichol, 2021). However, exploration of its application in behavior modeling is still limited. Janner et al. (2022) proposes to solve offline tasks by iteratively denoising trajectories, while our method uses diffusion models for single-step decision-making. Concurrently with our work, Wang et al. (2022) also studies applying diffusion models to offline RL to improve policy expressivity. However, they use diffusion modeling as an implicit regularization during training of the desired policy instead of an explicit policy prior.
186
+
187
+ # 6 EXPERIMENTS
188
+
189
+ # 6.1 EVALUATIONS ON D4RL BENCHMARKS
190
+
191
+ In Table 1, we compare the performance of SfBC to multiple offline RL methods in several D4RL (Fu et al., 2020) tasks. MuJoCo locomotion is a classic benchmark where policy-generated datasets only cover a narrow part of the state-action space, so avoiding querying out-of-sample actions is critical (Fujimoto et al., 2019; Kumar et al., 2020). The Medium dataset of this benchmark is generated by a single agent, while the Medium-Expert and the Medium-Replay dataset are generated by a mixture of policies. AntMaze is about an ant robot navigating itself in a maze, which requires both low-level robot control and high-level navigation. Since the datasets consist of undirected trajectories, solving AntMaze typically requires the algorithm to have strong “stitching” ability $\operatorname { F u }$ et al., 2020). Different environments contain mazes of different sizes, reflecting different complexity. Maze2d is very similar to AntMaze except that it’s about a ball navigating in a maze instead of an ant robot. FrankaKitchen are robot-arm manipulation tasks. We only focus on the analysis of MuJoCo locomotion and AntMaze tasks due to the page limit. Our choices of referenced baselines are detailed in Appendix E.
192
+
193
+ ![](images/5ccb55e50c6b9c1c1aaa47903932d170d0373889f47f0f41c704d887fd08c4d7.jpg)
194
+ Figure 3: Visualizations of actions taken by different RL agents in the Bidirectional-Car task. The ground truth corresponds to an agent which always takes the best actions, which is either 1.0 or -1.0. White space indicates suboptimal decisions. Green bounding boxes indicate possible initial states.
195
+
196
+ Overall, SfBC outperforms most existing methods by large margins in complex tasks with sparse rewards such as AntMaze. We notice that VEM also achieves good results in AntMaze tasks and both methods share an implicit in-sample planning scheme, indicating that episodic planning is effective in improving algorithms’ stitching ability and thus beneficial in Maze-like environments. In easier locomotion tasks, SfBC provides highly competitive results compared with state-of-the-art algorithms. It can be clearly shown that performance gain is large in datasets generated by a mixture of distinctive policies (Medium-Expert) and is relatively small in datasets that are highly uniform (Medium). This is reasonable because SfBC is motivated to better model diverse behaviors.
197
+
198
+ # 6.2 LEARNING FROM DIVERSE BEHAVIORS
199
+
200
+ In this section, we analyze the benefit of modeling behavior policy using highly expressive generative models. Although SfBC outperforms baselines in many D4RL tasks. The improvement is mainly incremental, but not decisive. We attribute this to the lack of multiple optimal solutions in existing benchmarks. To better demonstrate the necessity of introducing an expressive generative model, we design a simple task where a heterogeneous dataset is collected in an environment that allows two distinctive optimal policies.
201
+
202
+ Bidirectional-Car task. As depicted in Figure 1, we consider an environment where a car is placed in the middle of two endpoints. The car chooses an action in the range [-1,1] at each step, representing throttle, to influence the direction and speed of the car. The speed of the car will monotonically increase based on the absolute value of throttle. The direction of the car is determined by the sign of the current throttle. Equal reward will be given on the arrival of either endpoint within the rated time. It can be inferred with ease that, in any state, the optimal decision should be either 1 or -1, which is not a unimodal distribution. The collected dataset also contains highly diverse behaviors, with an approximately equal number of trajectories ending at both endpoints. For the comparative study, we collect another dataset called “Single-Side” where the only difference from the original one is that we remove all trajectories ending at the left endpoint from the dataset.
203
+
204
+ ![](images/5931429b8cb989542636c12780e781be3a1e3874cf5805238821078ca51eb61f.jpg)
205
+ Figure 4: Ablation studies of the value iteration number $K$ in MuJoCo Locomotion and Antmaze domains. $K = 1$ represents algorithms that use vanilla returns ${ \cal R } _ { n } ^ { ( 0 ) }$ as Q-learning targets without the implicit planning technique. All results are averaged over 4 independent random seeds.
206
+
207
+ We test our method against several baselines, with the results given in Table 1. Among all referenced methods, SfBC is the only one that can always arrive at either endpoint within rated time in the Bidirectional-Car environment, whereas most methods successfully solve the “Single-Side” task. To gain some insight into why this happens, we illustrate the decisions made by an SfBC agent and other RL agents in the 2-dimensional state space. As is shown in Figure 3, the SfBC agent selects actions of high absolute values at nearly all states, while other unimodal actors fail to pick either one of the optimal actions when presented with two distinctive high-rewarding options. Therefore, we conclude that an expressive policy is necessary for performing diverse behavior learning.
208
+
209
+ # 6.3 ABLATION STUDIES
210
+
211
+ Diffusion vs. other generative models. Our first ablation study aims to evaluate 3 variants of SfBC which are respectively based on diffusion models (Ho et al., 2020), Gaussian probabilistic models, and latent-based models (VAEs, Kingma & Welling (2014)). The three variants use exactly the same training framework with the only difference being the behavior modeling method. As is shown in Table 4 in Appendix D, the diffusion-based policy outperforms the other two variants by a clear margin in most experiments, especially in tasks with heterogeneous datasets (e.g., Medium-Expert), indicating that diffusion models are fit for “high-fidelity” behavior modeling.
212
+
213
+ Implicit in-sample planning. To study the importance of implicit in-sample planning on the performance of SfBC, we first visualize the estimated state values learned at different iterations of Q-learning in an AntMaze environment (Figure 2). We can see that implicit planning helps to iteratively stitch together successful subtrajectories and provides optimistic action evaluations. Then we aim to study how the value iteration number $K$ affects the performance of the algorithm in various environments. As shown in Figure 4, we compare the performance of $K$ in the range $\{ 1 , 2 , 3 , 4 , 5 \}$ and find that implicit planning is beneficial in complex tasks like AntMaze-Medium and AntMaze-Large. However, it is less important in MuJoCo-locomotion tasks. This finding is consistent with a prior work (Brandfonbrener et al., 2021).
214
+
215
+ # 7 CONCLUSION
216
+
217
+ In this work, we address the problem of limited policy expressivity in previous weighted regression methods by decoupling the policy model into a behavior model and an action evaluation model. Such decoupling allows us to use a highly expressive diffusion model for high-fidelity behavior modeling, which is further combined with a planning-based operator to reduce extrapolation error. Our method enables learning from a heterogeneous dataset in a continuous action space while avoiding selecting out-of-sample actions. Experimental results on the D4RL benchmark show that our approach outperforms state-of-the-art algorithms in most tasks. With this work, we hope to draw attention to the application of high-capacity generative models in offline RL.
218
+
219
+ # REPRODUCIBILITY
220
+
221
+ To ensure that our work is reproducible, we submit the source code as supplementary material. We also provide the pseudo-code of our algorithm in Appendix A and implementation details of our algorithm in Appendix B.
222
+
223
+ # ACKNOWLEDGEMENT
224
+
225
+ We thank Shiyu Huang, Yichi Zhou, and Hao Hu for discussing. This work was supported by the National Key Research and Development Program of China (2020AAA0106000, 2020AAA0106302, 2021YFB2701000), NSFC Projects (Nos. 62061136001, 62076147, U19B2034, U1811461, U19A2081, 61972224), BNRist (BNR2022RC01006), Tsinghua Institute for Guo Qiang, and the High Performance Computing Center, Tsinghua University.
226
+
227
+ # REFERENCES
228
+
229
+ Charles Blundell, Benigno Uria, Alexander Pritzel, Yazhe Li, Avraham Ruderman, Joel Z Leibo, Jack Rae, Daan Wierstra, and Demis Hassabis. Model-free episodic control. arXiv preprint arXiv:1606.04460, 2016.
230
+
231
+ 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.
232
+
233
+ 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. In Advances in Neural Information Processing Systems, 2021.
234
+
235
+ Xi Chen, Ali Ghadirzadeh, Tianhe Yu, Jianhao Wang, Yuan Gao, Wenzhe Li, Liang Bin, Chelsea Finn, and Chongjie Zhang. Lapo: Latent-variable advantage-weighted policy optimization for offline reinforcement learning. In Advances in Neural Information Processing Systems, 2022.
236
+
237
+ Xinyue Chen, Zijian Zhou, Zheng Wang, Che Wang, Yanqiu Wu, and Keith Ross. BAIL: Bestaction imitation learning for batch deep reinforcement learning. Advances in Neural Information Processing Systems, 33, 2020.
238
+
239
+ Alfredo V Clemente, Humberto N Castejon, and Arjun Chandra. Efficient parallel methods for deep ´ reinforcement learning. arXiv preprint arXiv:1705.04862, 2017.
240
+
241
+ Prafulla Dhariwal and Alexander Quinn Nichol. Diffusion models beat GANs on image synthesis. In Advances in Neural Information Processing Systems, 2021.
242
+
243
+ Laurent Dinh, Jascha Sohl-Dickstein, and Samy Bengio. Density estimation using real nvp. arXiv preprint arXiv:1605.08803, 2016.
244
+
245
+ John R Dormand and Peter J Prince. A family of embedded runge-kutta formulae. Journal of computational and applied mathematics, 6(1):19–26, 1980.
246
+
247
+ Yilun Du and Igor Mordatch. Implicit generation and modeling with energy based models. Advances in Neural Information Processing Systems, 32, 2019.
248
+
249
+ Justin Fu, Aviral Kumar, Ofir Nachum, George Tucker, and Sergey Levine. D4rl: Datasets for deep data-driven reinforcement learning. arXiv preprint arXiv:2004.07219, 2020.
250
+
251
+ Scott Fujimoto and Shixiang Shane Gu. A minimalist approach to offline reinforcement learning. Advances in neural information processing systems, 34:20132–20145, 2021.
252
+
253
+ Scott Fujimoto, David Meger, and Doina Precup. Off-policy deep reinforcement learning without exploration. In Proceedings of the 36th International Conference on Machine Learning, volume 97 of Proceedings of Machine Learning Research, pp. 2052–2062. PMLR, 09–15 Jun 2019.
254
+
255
+ Mathieu Germain, Karol Gregor, Iain Murray, and Hugo Larochelle. Made: Masked autoencoder for distribution estimation. In International conference on machine learning, pp. 881–889. PMLR, 2015.
256
+
257
+ Seyed Kamyar Seyed Ghasemipour, Dale Schuurmans, and Shixiang Shane Gu. Emaq: Expected-max q-learning operator for simple yet effective offline and online rl. In International Conference on Machine Learning, pp. 3682–3691. PMLR, 2021.
258
+
259
+ 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.
260
+
261
+ Jonathan Ho and Stefano Ermon. Generative adversarial imitation learning. In Advances in neural information processing systems, volume 29, pp. 4565–4573, 2016.
262
+
263
+ Jonathan Ho, Ajay Jain, and Pieter Abbeel. Denoising diffusion probabilistic models. In Advances in Neural Information Processing Systems, 2020.
264
+
265
+ Hao Hu, Jianing Ye, Zhizhou Ren, Guangxiang Zhu, and Chongjie Zhang. Generalizable episodic memory for deep reinforcement learning. arXiv preprint arXiv:2103.06469, 2021.
266
+
267
+ Michael Janner, Yilun Du, Joshua Tenenbaum, and Sergey Levine. Planning with diffusion for flexible behavior synthesis. In International Conference on Machine Learning, 2022.
268
+
269
+ Diederik P. Kingma and Max Welling. Auto-encoding variational bayes. In 2nd International Conference on Learning Representations, ICLR 2014, Banff, AB, Canada, April 14-16, 2014, Conference Track Proceedings, 2014.
270
+
271
+ Durk P Kingma, Tim Salimans, Rafal Jozefowicz, Xi Chen, Ilya Sutskever, and Max Welling. Improved variational inference with inverse autoregressive flow. Advances in neural information processing systems, 29, 2016.
272
+
273
+ Ilya Kostrikov, Rob Fergus, Jonathan Tompson, and Ofir Nachum. Offline reinforcement learning with fisher divergence critic regularization. In International Conference on Machine Learning, pp. 5774–5783. PMLR, 2021.
274
+
275
+ Ilya Kostrikov, Ashvin Nair, and Sergey Levine. Offline reinforcement learning with implicit Q-learning. In International Conference on Learning Representations, 2022.
276
+
277
+ Aviral Kumar, Justin Fu, George Tucker, and Sergey Levine. Stabilizing off-policy q-learning via bootstrapping error reduction. CoRR, abs/1906.00949, 2019. URL http://arxiv.org/abs/ 1906.00949.
278
+
279
+ Aviral Kumar, Aurick Zhou, George Tucker, and Sergey Levine. Conservative Q-learning for offline reinforcement learning. arXiv preprint arXiv:2006.04779, 2020.
280
+
281
+ Timothy P. Lillicrap, Jonathan J. Hunt, Alexander Pritzel, Nicolas Manfred Otto Heess, Tom Erez, Yuval Tassa, David Silver, and Daan Wierstra. Continuous control with deep reinforcement learning. ICLR, 2016.
282
+
283
+ Minghuan Liu, Tairan He, Minkai Xu, and Weinan Zhang. Energy-based imitation learning. arXiv preprint arXiv:2004.09395, 33, 2020.
284
+
285
+ Cheng Lu, Yuhao Zhou, Fan Bao, Jianfei Chen, Chongxuan Li, and Jun Zhu. Dpm-solver: A fast ode solver for diffusion probabilistic model sampling in around 10 steps. arXiv preprint arXiv:2206.00927, 2022.
286
+
287
+ James Lucas, George Tucker, Roger Grosse, and Mohammad Norouzi. Understanding posterior collapse in generative latent variable models, 2019. URL https://openreview.net/ forum?id $\underline { { \underline { { \mathbf { \Pi } } } } } =$ r1xaVLUYuE.
288
+
289
+ Xiaoteng Ma, Yiqin Yang, Hao Hu, Jun Yang, Chongjie Zhang, Qianchuan Zhao, Bin Liang, and Qihan Liu. Offline reinforcement learning with value-based episodic memory. In International Conference on Learning Representations, 2022.
290
+
291
+ Ashvin Nair, Abhishek Gupta, Murtaza Dalal, and Sergey Levine. Awac: Accelerating online reinforcement learning with offline datasets. arXiv preprint arXiv:2006.09359, 2020.
292
+
293
+ 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.
294
+
295
+ Jan Peters, Katharina Mulling, and Yasemin Altun. Relative entropy policy search. In Twenty-Fourth AAAI Conference on Artificial Intelligence, 2010.
296
+
297
+ Aditya Ramesh, Prafulla Dhariwal, Alex Nichol, Casey Chu, and Mark Chen. Hierarchical textconditional image generation with clip latents. arXiv preprint arXiv:2204.06125, 2022.
298
+
299
+ 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.
300
+
301
+ David Silver, Guy Lever, Nicolas Heess, Thomas Degris, Daan Wierstra, and Martin A. Riedmiller. Deterministic policy gradient algorithms. In Proceedings of the 31th International Conference on Machine Learning, ICML 2014, Beijing, China, 21-26 June 2014, pp. 387–395, 2014.
302
+
303
+ Avi Singh, Huihan Liu, Gaoyue Zhou, Albert Yu, Nicholas Rhinehart, and Sergey Levine. Parrot: Data-driven behavioral priors for reinforcement learning. arXiv preprint arXiv:2011.10024, 2020.
304
+
305
+ 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.
306
+
307
+ Jiaming Song, Chenlin Meng, and Stefano Ermon. Denoising diffusion implicit models. In International Conference on Learning Representations, 2021a.
308
+
309
+ Yang Song, Jascha Sohl-Dickstein, Diederik P Kingma, Abhishek Kumar, Stefano Ermon, and Ben Poole. Score-based generative modeling through stochastic differential equations. In International Conference on Learning Representations, 2021b. URL https://openreview.net/forum? id=PxTIG12RRHS.
310
+
311
+ Richard S. Sutton and Andrew G. Barto. Introduction to Reinforcement Learning. MIT Press, Cambridge, MA, USA, 1st edition, 1998. ISBN 0262193981.
312
+
313
+ Richard S Sutton, David McAllester, Satinder Singh, and Yishay Mansour. Policy gradient methods for reinforcement learning with function approximation. Advances in neural information processing systems, 12, 1999.
314
+
315
+ Zhendong Wang, Jonathan J Hunt, and Mingyuan Zhou. Diffusion policies as an expressive policy class for offline reinforcement learning. arXiv preprint arXiv:2208.06193, 2022.
316
+
317
+ Ziyu Wang, Alexander Novikov, Konrad Zolna, Josh S Merel, Jost Tobias Springenberg, Scott E Reed, Bobak Shahriari, Noah Siegel, Caglar Gulcehre, Nicolas Heess, and Nando de Freitas. Critic regularized regression. In H. Larochelle, M. Ranzato, R. Hadsell, M.F. Balcan, and H. Lin (eds.), Advances in Neural Information Processing Systems, volume 33, pp. 7768–7778. Curran Associates, Inc., 2020.
318
+
319
+ Jiayi Weng, Huayu Chen, Dong Yan, Kaichao You, Alexis Duburcq, Minghao Zhang, Yi Su, Hang Su, and Jun Zhu. Tianshou: A highly modularized deep reinforcement learning library. Journal of Machine Learning Research, 23(267):1–6, 2022. URL http://jmlr.org/papers/v23/ 21-1127.html.
320
+
321
+ Yifan Wu, George Tucker, and Ofir Nachum. Behavior regularized offline reinforcement learning. arXiv preprint arXiv:1911.11361, 2019.
322
+
323
+ Wenxuan Zhou, Sujay Bajracharya, and David Held. Plas: Latent action space for offline reinforcement learning. In Conference on Robot Learning, pp. 1719–1735. PMLR, 2021.
324
+
325
+ # A ALGORITHM OVERVIEW
326
+
327
+ Initialize the score-based model $s _ { \theta }$ , the action evaluation model $Q _ { \phi }$
328
+ Calculate vanilla discounted returns ${ \cal R } _ { n } ^ { ( 0 ) }$ for every state-action pair in dataset ${ \mathcal { D } } ^ { \mu }$
329
+ // Training the behavior model
330
+ for each gradient step do Sample $B$ data points $( s , a )$ from ${ \mathcal { D } } ^ { \mu }$ , $B$ Gaussian noises $\epsilon$ from $\mathcal { N } ( 0 , \pmb { I } )$ and $B$ time $t$ from $\mathcal { U } ( 0 , T )$ Perturb $\textbf { \em a }$ according to $\mathbf { \sigma } _ { \mathbf { \lambda } } \mathbf { a } _ { t } : = \alpha _ { t } \mathbf { \pmb { a } } + \sigma _ { t } \mathbf { \epsilon } $ Update $\theta \gets \lambda _ { s } \nabla _ { \theta } \sum [ \| \sigma _ { t } \mathbf { s } _ { \theta } ( { \pmb a } _ { t } , { \pmb s } , t ) + { \pmb \epsilon } \| _ { 2 } ^ { 2 } ]$
331
+ end for
332
+ // Training the action evaluation model iteratively
333
+ for iteration $k = 1$ to $K$ do Initialize training parameters $\phi$ of the action evaluation model $Q _ { \phi }$ for each gradient step do Sample $B$ data points $\Big ( s , \pmb { a } , R ^ { ( k - 1 ) } \Big )$ from ${ \mathcal { D } } ^ { \mu }$ Update $\begin{array} { r } { \phi \phi - \lambda _ { Q } \nabla _ { \phi } \sum [ \| Q _ { \phi } ( \pmb { s } , \pmb { a } ) - R ^ { ( k - 1 ) } \| _ { 2 } ^ { 2 } ] } \end{array}$ end for // Update the $\mathcal { Q }$ -training targets as in Algorithm 2 $R ^ { ( k ) } = \operatorname { P l a n n i n g } ( { \mathcal { D } } ^ { \mu } , \mu _ { \theta } , Q _ { \phi } )$
334
+ end for
335
+
336
+ # Algorithm 2 Implicit In-sample Planning
337
+
338
+ Input a behavior dataset ${ \mathcal { D } } ^ { \mu }$ (sequentially ordered), a learned behavior policy $\mu _ { \theta }$ , a critic model $Q _ { \phi }$
339
+ // Evaluate every state in dataset according to Equation 13 with M Monte Carlo samples (parallelized)
340
+ for each minibatch $\left\{ s _ { n } \right\}$ splitted from ${ \mathcal { D } } ^ { \mu }$ do
341
+ Sample $\mathbf { M }$ actions $\hat { \pmb { a } } _ { n } ^ { 1 : M }$ from $\mu _ { \boldsymbol { \theta } } \bigl ( \cdot | \boldsymbol { s } _ { n } \bigr )$ , and calculate Q-values $\hat { R } _ { n } ^ { 1 : M } = Q _ { \phi } ( \pmb { s } _ { n } , \hat { \pmb { a } } _ { n } ^ { 1 : M } )$
342
+ Calculate state value $\begin{array} { r } { V _ { n } = \sum _ { m } \left[ \exp \left( \alpha \hat { R } _ { n } ^ { m } \right) \hat { R } _ { n } ^ { m } \right] / \sum _ { m } \exp \left( \alpha \hat { R } _ { n } ^ { m } \right) } \end{array}$
343
+ end for
344
+ // Performing implicit in-sample planning recursively
345
+ for timestep $n = \| \mathcal { D } ^ { \mu } \|$ to 0 do $R _ { n } = r _ { n } + \gamma \operatorname* { m a x } ( R _ { n + 1 } , V _ { n + 1 } )$ if $n$ is not the last episode step, else $r _ { n }$
346
+ end for
347
+ Output the new Q-training targets $\{ R _ { n } \}$
348
+
349
+ ![](images/351aeb06cb756d8f39099fac7da77ecabdf89c63a0a35201b4c9e4cfa9cdab09.jpg)
350
+ Figure 5: An algorithm overview of SfBC.
351
+
352
+ # B EXPERIMENTAL DETAILS
353
+
354
+ # B.1 IMPLEMENTATION DETAILS OF SFBC
355
+
356
+ Network Architecture. SfBC includes a conditional scored-based model which estimates the score function of the behavior action distribution, and an action evaluation model which outputs the Qvalues of given state-action pairs. The architecture of the behavior model resembles U-Nets, but with spatial convolutions changed to simple dense connections, inspired by Janner et al. (2022). For the action evaluation model, we use a 2-layer MLP with 256 hidden units and SiLU activation functions. The same network architecture is applied across all tasks except for AntMaze-Large, where we add an extra layer of 512 hidden units for the action evaluation model.
357
+
358
+ ![](images/dfbe008ebdfc778adf78a99c9baa032e3f2b93a2ece93fd3b7e739d049fe1b4a.jpg)
359
+ Figure 6: The network architecture of the behavior model.
360
+
361
+ Behavior training. In all experiments, we use the Adam optimizer and a batch size of 4096. The conditional scored-based model is trained for 500 data epochs with a learning rate of 1e-4. For the data perturbation method, we use Variance Preserving (VP) SDE as introduced in Song et al. (2021b), where we have $\begin{array} { r } { \mathrm { d } \pmb { x } = - \frac { 1 } { 2 } \beta ( t ) \pmb { x } \mathrm { d } t + \sqrt { \beta ( t ) } \mathrm { d } \mathbf { w } } \end{array}$ , such that we have $\begin{array} { r } { f ( { \pmb x } , t ) = - \frac { 1 } { 2 } \beta ( t ) { \pmb x } } \end{array}$ and $g ( t ) = \sqrt { \beta ( t ) }$ in Equation 6, and also:
362
+
363
+ $$
364
+ p _ { t 0 } ( \pmb { x } _ { t } | \pmb { x } _ { 0 } ) = \mathcal { N } ( \pmb { x } _ { t } | \alpha _ { t } \pmb { x } _ { 0 } , \sigma _ { t } ^ { 2 } I ) = \mathcal { N } ( \pmb { x } _ { t } | e ^ { - \frac { 1 } { 2 } \int _ { 0 } ^ { t } \beta ( s ) \mathrm { d } s } \pmb { x } _ { 0 } , [ 1 - e ^ { - \int _ { 0 } ^ { t } \beta ( s ) \mathrm { d } s } ] I ) .
365
+ $$
366
+
367
+ Following the default settings in Song et al. (2021b), we set $\beta ( t ) = ( \beta _ { \operatorname* { m a x } } - \beta _ { \operatorname* { m i n } } ) t + \beta _ { \operatorname* { m i n } }$ , with $\beta _ { \mathrm { m i n } }$ being 0.1 and $\beta _ { \mathrm { m a x } }$ being 20.
368
+
369
+ Action evaluation via in-sample planning. The action evaluation model is trained for 100 data epochs with a learning rate of 1e-3 for each value iteration. We use $K = 2$ value iterations for all MuJoCo tasks, $K = 4$ for Antmaze-umaze tasks, and $K = 5$ for other Antmaze tasks. In each iteration, new Q-targets will be recalculated according to Equation 12 and Equation 13 based on the latest policy. We use Monte Carlo methods and importance sampling to estimate $V _ { n } ^ { ( k - 1 ) }$ in Equation 13:
370
+
371
+ $$
372
+ \begin{array} { l } { { { \cal V } _ { n } ^ { ( k - 1 ) } = \mathbb { E } _ { a \sim \pi ( \cdot \vert s _ { n } ) } Q _ { \phi } ( s _ { n } , a ) } } \\ { { { \mathrm { ~ } } } } \\ { { { \mathrm { ~ } } } } \\ { { { \displaystyle ~ \approx \sum _ { M } ( \cdot \vert s _ { n } ) \frac { \exp { \left( \alpha Q _ { \phi } ( s _ { n } , a ) \right) } } { Z ( s _ { n } ) } Q _ { \phi } ( s _ { n } , a ) } } } \\ { { { \mathrm { ~ } } } } \\ { { { \displaystyle ~ \approx \sum _ { M } \left[ \frac { \exp { \left( \alpha Q _ { \phi } ( s _ { n } , a ) \right) } } { \sum _ { M } \exp { \left( \alpha Q _ { \phi } ( s _ { n } , a ) \right) } } Q _ { \phi } ( s _ { n } , a ) \right] } , } } \end{array}
373
+ $$
374
+
375
+ with the inverse temperature $\alpha$ set to 20 and the Monte Carlo sample number set to 16 in all tasks. Note that at the beginning of each value iteration, we normalize Q-targets stored in the dataset and reinitialize the training parameters of the action evaluation model. Different from most prior works (Fujimoto et al., 2019; Kumar et al., 2020; Ma et al., 2022; Kostrikov et al., 2022), we do not use either ensembled networks or target networks to stabilize Q-learning.
376
+
377
+ Diffusion sampling. To draw action samples from the behavior model, we use a 3rd-order specialized diffusion ODE solver proposed by Lu et al. (2022) to solve the inverse ODE problem in Equation 6. We use a diffusion step of $D = 1 5$ for all reported results in Table 1, which is significantly less than the typical 35-50 diffusion steps required if using ordinary RK45 ODE solver (Dormand & Prince, 1980). We also compare the performance and runtime of diffusion steps in the range $\{ 5 , 1 0 , 1 5 , 2 5 \}$ with the results reported in Table 2. Generally, we find that 10-25 diffusion steps perform similarly well in MuJoco Locomotion tasks and 15-25 diffusion steps perform similarly well in Antmaze tasks.
378
+
379
+ Evaluation. Following the evaluation metric proposed by Fu et al. (2020), we run all Antmaze and MuJoCo experiments over 4 trials (different random seeds) and other experiments over 3 trials. For each trial, performance is averaged on another 100 test seeds for Antmaze tasks and 20 test seeds for other tasks at regular intervals (5 data epochs). During algorithm evaluation, we select actions in a deterministic way. Specifically, the action with the highest Q-value within $M$ behavior candidates will be selected for environment inference during evaluation. In MuJoCo Locomotion tasks, we average four actions with the highest Q-values among all candidates and find this technique helps to stabilize performance. We set the candidate number $M$ to 32 in all experiments.
380
+
381
+ Runtime. We test the runtime of our algorithm on a RTX 2080Ti GPU. For algorithm training, the runtime cost of training the behavior model is 10.5 hours for 600 epochs, and the runtime cost of training the action evaluation model is about 31 minutes for each value iteration, (usually 2-5 iterations, 1M data points considered). For a concrete example, it roughly takes 155 minutes to train the action evaluation model $\scriptstyle ( \mathrm { K } = 5 )$ and 10.5 hours to train the behavior model for the “halfcheetah-medium” task.
382
+
383
+ As for the evaluation runtime, theoretically, SfBC requires at least $D$ times of network inference time compared with non-diffusion methods $\mathcal { D } = 1$ ), $D$ being the diffusion steps. To accelerate algorithm evaluation, we implement a parallel evaluation scheme similar to Clemente et al. (2017); Weng et al. (2022) that could allow evaluating the algorithm under multiple test seeds at the same time, allowing us to significantly reduce the evaluation runtime by utilizing the parallel computing power of GPUs (Figure 7).
384
+
385
+ Table 2: Ablation studies of the diffusion steps. The runtime is reported for the ”halfcheetah-medium” task on a RTX 2080Ti GPU. 1 episode stands for 1000 environment steps.
386
+
387
+ <table><tr><td>Diffusion Steps D</td><td>5 steps</td><td>10 steps</td><td>15 steps</td><td>25 steps</td></tr><tr><td>Performance (Locomotion)</td><td>2.3</td><td>72.9</td><td>75.6</td><td>74.4</td></tr><tr><td>Performance (Antmaze)</td><td>5.5</td><td>65.7</td><td>74.2</td><td>73.0</td></tr><tr><td>Runtime (1 episode, # envs=1)</td><td>22.3 s</td><td>38.0 s</td><td>50.0 s</td><td>93.0 s</td></tr><tr><td>Runtime (1 episode,# envs=20)</td><td>1.5 s</td><td>2.5 s</td><td>3.2 s</td><td>5.0s</td></tr></table>
388
+
389
+ ![](images/0ecfa857ffa65d11bb7760e0df71643b4c94597833b5073f3a71f7d5ec95dda1.jpg)
390
+ Figure 7: Evaluation runtime of SfBC.
391
+
392
+ B.2 IMPLEMENTATION DETAILS FOR ABLATION STUDIES
393
+
394
+ SfBC $^ +$ VAEs/Gaussians. For the VAE-based behavior model, we use exactly the same network architecture and training loss as Fujimoto et al. (2019) and train the behavior model for $3 0 0 \mathrm { k }$ iterations at a learning rate of 3e-4. For the Gaussian-based policy model, we follow Nair et al. (2020) and use a 4-layer MLP with 256 hidden units and ReLU activation functions. The sampled action from the parameterized Gaussian distribution is squashed to range $[ - 1 , 1 ]$ by a Tanh activation function. The Gaussian behavior model is trained by directly maximizing the log-likelihood of the dataset distribution for $3 0 0 \mathrm { k }$ iterations at a learning rate of 3e-4. Other experiment settings are consistent with the diffusion-based method.
395
+
396
+ SfBC - Planning. Removing the planning-based procedure from SfBC is equivalent to performing SfBC for only one iteration, which only learns a behavior Q-function purely from vanilla returns. Other than this, we use the same network architecture and training paradigm as SfBC.
397
+
398
+ # B.3 SOURCES OF REFERENCED BASELINE NUMBERS
399
+
400
+ For IQL (Kostrikov et al., 2022), D4RL performance numbers are reported in its original paper, except for Maze2d tasks, which we reference Janner et al. (2022). The performance in the Bidirectional-Car task is based on a PyTorch reimplementation of the algorithm (https: //github.com/gwthomas/IQL-PyTorch). We use the same hyperparameters as in the original paper for MuJoCo Locomotion tasks.
401
+
402
+ For VEM (Ma et al., 2022) and Diffuser (Janner et al., 2022), all D4RL performance numbers come from their respective papers. Performance numbers of VEM in the Bidirectional-Car task are based on a slightly modified version of the algorithm’s official codebase (https://github. com/YiqinYang/VEM). Since the performance of VEM is very sensitive to a hyperparameter $\tau$ in their algorithm. We evaluate $\tau \in \{ 0 . \bar { 1 } , 0 . 2 , . . . , 0 . 9 \}$ and report the best-performing choice.
403
+
404
+ For AWR (Peng et al., 2019), BCQ (Fujimoto et al., 2019) and CQL (Kumar et al., 2020), all their D4RL performance numbers come from Fu et al. (2020). Their performance numbers in the Bidirectional-Car task are based on three independent codebases: https://github. com/Farama-Foundation/D4RL-Evaluations for AWR, https://github.com/ sfujim/BCQ for BCQ and https://github.com/young-geng/CQL for CQL. We mostly use the default hyperparameters in their respective codebases.
405
+
406
+ For BAIL (Chen et al., 2020), all reported performance numbers come from our experiments based on a slightly modified version of its official codebase (https://github.com/lanyavik/BAIL). Note that BAIL proposes a technique to replace oracle returns with augmented returns in MuJoCo Locomotion tasks, whereas we omit using this technique because it cannot be easily applied to other offline tasks. Other than this, we use default settings in the original codebase.
407
+
408
+ For DT (Chen et al., 2021), D4RL performance numbers are reported in DT’s paper, except for AntMaze tasks, which we reference Kostrikov et al. (2022). The performance numbers in the Bidirectional-Car task are based on the algorithm’s official codebase (https://github.com/ kzl/decision-transformer). We use the same hyperparameters as they did for MuJoCo Locomotion tasks.
409
+
410
+ # C THEORETICAL ANALYSIS
411
+
412
+ In this section, we provide some theoretical analysis of our planning-based operator:
413
+
414
+ $$
415
+ \begin{array} { r } { \mathcal { T } _ { \mu } ^ { \pi } Q ( s , \pmb { a } ) : = \operatorname* { m a x } _ { n \geq 0 } \{ ( \mathcal { T } ^ { \mu } ) ^ { n } \mathcal { T } ^ { \pi } Q ( s , \pmb { a } ) \} . } \end{array}
416
+ $$
417
+
418
+ First, we provide the following proposition to discuss the contraction property of $\mathcal { T } _ { \mu } ^ { \pi }$ and the bound of its fixed point.
419
+
420
+ Proposition 1. We have the following properties of $\mathcal { T } _ { \mu } ^ { \pi }$
421
+
422
+ 1) $\mathcal { T } _ { \mu } ^ { \pi }$ owns monotonicity, i.e., for $\forall Q _ { 1 } \leq Q _ { 2 }$ , we have ${ \mathcal T } _ { \mu } ^ { \pi } Q _ { 1 } \leq { \mathcal T } _ { \mu } ^ { \pi } Q _ { 2 }$ .
423
+
424
+ 2) $\mathcal { T } _ { \mu } ^ { \pi }$ is at least a $\gamma$ -contraction.
425
+
426
+ $^ 3$ ) Assume the fixed point of $\mathcal { T } _ { \mu } ^ { \pi }$ is $\tilde { Q }$ , then we have $Q ^ { \pi } ( s , a ) \leq \tilde { Q } ( s , a ) \leq Q ^ { * } ( s , a )$ holds for $\forall s , a$ here $Q ^ { \pi } , Q ^ { * }$ are the fixed points of $\tau ^ { * }$ and $\mathcal { T } ^ { \pi }$ respectively.
427
+
428
+ Proof.
429
+
430
+ 1) For $\forall Q _ { 1 } \leq Q _ { 2 } , \forall s , \mathbf { a } , \forall n \in \mathbb { N }$ , we have
431
+
432
+ Thus we have
433
+
434
+ $$
435
+ \mathcal { T } _ { \mu } ^ { \pi } Q _ { 1 } ( s , a ) = \operatorname* { m a x } _ { n \geq 0 } \{ ( \mathscr { T } ^ { \mu } ) ^ { n } \mathscr { T } ^ { \pi } Q _ { 1 } ( s , a ) \} \leq \operatorname* { m a x } _ { n \geq 0 } \{ ( \mathscr { T } ^ { \mu } ) ^ { n } \mathscr { T } ^ { \pi } Q _ { 2 } ( s , a ) \} = \mathscr { T } _ { \mu } ^ { \pi } Q _ { 2 } ( s , a ) .
436
+ $$
437
+
438
+ 2) For $\forall Q _ { 1 } , Q _ { 2 } , \forall s , a$ , we have
439
+
440
+ $$
441
+ \begin{array} { r l } & { \left| { \cal T } _ { \mu } ^ { \pi } Q _ { 1 } ( s , a ) - { \cal T } _ { \mu } ^ { \pi } Q _ { 2 } ( s , a ) \right| = \displaystyle \left| \operatorname* { m a x } _ { n \geq 0 } \{ ( { \cal T } ^ { \mu } ) ^ { n } { \cal T } ^ { \pi } Q _ { 1 } ( s , a ) \} - \operatorname* { m a x } _ { n \geq 0 } \{ ( { \cal T } ^ { \mu } ) ^ { n } { \cal T } ^ { \pi } Q _ { 2 } ( s , a ) \} \right| } \\ & { \qquad \leq \operatorname* { m a x } _ { n \geq 0 } \{ | ( { \cal T } ^ { \mu } ) ^ { n } { \cal T } ^ { \pi } Q _ { 1 } ( s , a ) - ( { \cal T } ^ { \mu } ) ^ { n } { \cal T } ^ { \pi } Q _ { 2 } ( s , a ) | \} } \\ & { \qquad \leq \operatorname* { m a x } _ { n \geq 0 } \{ \gamma ^ { n + 1 } \| Q _ { 1 } - Q _ { 2 } \| _ { \infty } \} } \\ & { \qquad = \gamma \| Q _ { 1 } - Q _ { 2 } \| _ { \infty } . } \end{array}
442
+ $$
443
+
444
+ Consequently, $\mathcal { T } _ { \mu } ^ { \pi }$ is at least a $\gamma$ -contraction.
445
+
446
+ 3) For $\forall s , a$ , we first prove $Q ^ { \pi } ( s , \pmb { a } ) \leq \tilde { Q } ( s , \pmb { a } )$ . For $\forall m \in \mathbb { N }$ , we have
447
+
448
+ $$
449
+ \begin{array} { r l } & { \displaystyle { \cal Q } ^ { \pi } ( s , { \boldsymbol a } ) = \mathcal { T } ^ { \pi } { \cal Q } ^ { \pi } ( s , { \boldsymbol a } ) \leq \mathcal { T } _ { \mu } ^ { \pi } { \cal Q } ^ { \pi } ( s , { \boldsymbol a } ) = \mathcal { T } _ { \mu } ^ { \pi } \mathcal { T } ^ { \pi } { \cal Q } ^ { \pi } ( s , { \boldsymbol a } ) } \\ & { \leq \mathcal { T } _ { \mu } ^ { \pi } \mathcal { T } _ { \mu } ^ { \pi } { \cal Q } ^ { \pi } ( s , { \boldsymbol a } ) \quad \mathrm { ( b y ~ m o n o t o n i c i t y ~ o f ~ } \mathcal { T } _ { \mu } ^ { \pi } ) } \\ & { \leq \ldots \leq ( \mathcal { T } _ { \mu } ^ { \pi } ) ^ { m } { \cal Q } ^ { \pi } ( s , { \boldsymbol a } ) , } \\ { \mathrm { T h u s } \quad { \cal Q } ^ { \pi } ( s , { \boldsymbol a } ) \leq \displaystyle \operatorname* { l i m } _ { m \infty } ( \mathcal { T } _ { \mu } ^ { \pi } ) ^ { m } { \cal Q } ^ { \pi } ( s , { \boldsymbol a } ) = \tilde { \boldsymbol { Q } } ( s , { \boldsymbol a } ) . } \end{array}
450
+ $$
451
+
452
+ Now we prove that $\tilde { Q } ( s , a ) \leq Q ^ { * } ( s , a )$ . We have
453
+
454
+ $$
455
+ \begin{array} { r l } & { \mathcal { T } ^ { \pi } Q ^ { * } ( s , a ) = \mathcal { R } ( s , { a } ) + \gamma \mathbb { E } _ { s ^ { \prime } } \mathbb { E } _ { a ^ { \prime } \sim \hat { \pi } ( \cdot \vert s ^ { \prime } ) } Q ^ { * } ( s ^ { \prime } , { a } ^ { \prime } ) } \\ & { \qquad \leq \mathcal { R } ( s , a ) + \gamma \mathbb { E } _ { s ^ { \prime } } \operatorname* { m a x } _ { a ^ { \prime } } Q ^ { * } ( s ^ { \prime } , a ^ { \prime } ) = Q ^ { * } ( s , a ) . } \end{array}
456
+ $$
457
+
458
+ Similarly, we have ${ \mathcal { T } } ^ { \mu } Q ^ { * } ( s , a ) \leq Q ^ { * } ( s , a )$ .
459
+
460
+ Then for $\forall n , m \in \mathbb { N }$ ,
461
+
462
+ $$
463
+ \begin{array} { r l r } & { \begin{array} { l l } & { Q ^ { * } ( s , a ) \geq T ^ { \mu } Q ^ { * } ( s , a ) \geq ( T ^ { \mu } ) ^ { 2 } Q ^ { * } ( s , a ) } & { \mathrm { ( b y ~ m o n o t o n i c i t y ~ o f ~ } T ^ { \mu } ) } \\ & { \qquad \geq \ldots \geq ( T ^ { \mu } ) ^ { n } Q ^ { * } ( s , a ) } \\ & { \qquad \geq ( T ^ { \mu } ) ^ { n } { \mathcal T } ^ { \pi } Q ^ { * } ( s , a ) , } & { \mathrm { ( b y ~ m o n o t o n i c i t y ~ o f ~ } ( T ^ { \mu } ) ^ { n } ) } \end{array} } \\ & { } \\ & { \begin{array} { r l r } { \mathrm { \ h u s } } & { Q ^ { * } ( s , a ) \geq { \mathcal T } _ { \mu } ^ { \pi } Q ^ { * } ( s , a ) } \\ & { \qquad \geq { \mathcal T } _ { \mu } ^ { \pi } { \mathcal T } _ { \mu } ^ { \pi } Q ^ { * } ( s , a ) } & { \mathrm { ( b y ~ m o n o t o n i c i t y ~ o f ~ } { \mathcal T } _ { \mu } ^ { \pi } ) } \\ & { \qquad \geq \ldots \geq ( { \mathcal T } _ { \mu } ^ { \pi } ) ^ { m } Q ^ { * } ( s , a ) , } & \\ { \mathrm { \ h u s } } & { Q ^ { * } ( s , a ) \geq \operatorname* { l i m } _ { m \to \infty } ( { \mathcal T } _ { \mu } ^ { \pi } ) ^ { m } Q ^ { * } ( s , a ) = \tilde { Q } ( s , a ) . } \end{array} } \end{array}
464
+ $$
465
+
466
+ Moreover, similar to the analysis in Ma et al. (2022), we provide the following proposition to show that at the beginning of the training when the current Q function estimates $Q ( s , a )$ is significantly pessimistic, our $\mathcal { T } _ { \mu } ^ { \pi }$ provides a relatively optimistic update and can contract the estimation error more quickly.
467
+
468
+ Proposition 2. In practice, we consider $\begin{array} { r } { { \cal T } _ { \mu } ^ { \pi } Q ( s , a ) : = \operatorname* { m a x } _ { 0 \leq n \leq N } \{ ( { \cal T } ^ { \mu } ) ^ { n } { \cal T } ^ { \pi } Q ( s , a ) \} } \end{array}$ . Then we have:
469
+
470
+ $$
471
+ \begin{array} { r } { | { \cal T } _ { \mu } ^ { \pi } Q ( s , a ) - Q ^ { * } ( s , a ) | \leq { \gamma } ^ { n ^ { * } ( s , a ) } \| Q - \tilde { Q } _ { n ^ { * } } \| _ { \infty } + \| \tilde { Q } _ { n ^ { * } } - Q ^ { * } \| _ { \infty } , \quad \forall s , a , } \end{array}
472
+ $$
473
+
474
+ here $\begin{array} { r } { n ^ { \ast } ( \pmb { \mathscr { s } } , \pmb { a } ) = \arg \operatorname* { m a x } _ { 0 \leq n \leq N } \{ ( \mathscr { T } ^ { \mu } ) ^ { n } \mathscr { T } ^ { \pi } Q ( \pmb { \mathscr { s } } , \pmb { a } ) \} } \end{array}$ and ${ \tilde { Q } } _ { n ^ { * } }$ is the fixed point of $( \mathcal { T } ^ { \mu } ) ^ { n ^ { * } ( s , a ) } \mathcal { T } ^ { \pi }$
475
+
476
+ Proof. We can use the triangle inequality to prove this result
477
+
478
+ $$
479
+ \begin{array} { r l } & { \ | T _ { \mu } ^ { \pi } Q ( s , a ) - Q ^ { * } ( s , a ) | } \\ & { = | ( T ^ { \mu } ) ^ { n ^ { * } ( s , a ) } T ^ { \pi } Q ( s , a ) - Q ^ { * } ( s , a ) | } \\ & { \leq | ( T ^ { \mu } ) ^ { n ^ { * } ( s , a ) } T ^ { \pi } Q ( s , a ) - ( T ^ { \mu } ) ^ { n ^ { * } ( s , a ) } T ^ { \pi } \tilde { Q } _ { n ^ { * } } ( s , a ) | + | ( T ^ { \mu } ) ^ { n ^ { * } ( s , a ) } T ^ { \pi } \tilde { Q } _ { n ^ { * } } ( s , a ) - Q ^ { * } ( s , a ) | } \\ & { = | ( T ^ { \mu } ) ^ { n ^ { * } ( s , a ) } T ^ { \pi } Q ( s , a ) - ( T ^ { \mu } ) ^ { n ^ { * } ( s , a ) } T ^ { \pi } \tilde { Q } _ { n ^ { * } } ( s , a ) | + | \tilde { Q } _ { n ^ { * } } ( s , a ) - Q ^ { * } ( s , a ) | } \\ & { \leq \gamma ^ { n ^ { * } ( s , a ) } \| Q - \tilde { Q } _ { n ^ { * } } \| _ { \infty } + \| \tilde { Q } _ { n ^ { * } } - Q ^ { * } \| _ { \infty } . } \end{array}
480
+ $$
481
+
482
+ When $Q$ is significantly lower than $\tilde { Q } _ { n ^ { * } } , Q ^ { * }$ , $\| { \tilde { Q } } _ { n ^ { * } } - Q ^ { * } \| _ { \infty }$ is often conspicuously lower than $\| Q - { \tilde { Q } } _ { n ^ { * } } \| _ { \infty }$ and $n ^ { * } ( s , { \pmb a } )$ is relatively large (this often happens at the beginning of the training since the initial $\mathrm { \bf Q }$ estimates are often near zero and thus pessimistic). At this time, based on this proposition, our operator $\mathcal { T } _ { \mu } ^ { \pi }$ , could contract the estimation error with a rate of around $\gamma ^ { n ^ { * } ( s , \pmb { a } ) }$ , which could significantly reduce extrapolation iterations required.
483
+
484
+ D MISSING PERFORMANCE NUMBERS
485
+
486
+ <table><tr><td>Dataset</td><td>Environment</td><td>SfBC (Ours)</td><td>IQL</td><td>VEM</td><td>AWR</td><td>BAIL</td><td>BCQ</td><td>CQL</td><td>DT</td><td>Diffuser</td></tr><tr><td>Sparse</td><td>Maze2d-umaze</td><td>73.9 ± 6.6</td><td>47.4</td><td>-</td><td>1.0</td><td>-</td><td>12.8</td><td>5.7</td><td>-</td><td>113.9</td></tr><tr><td>Sparse</td><td>Maze2d-medium</td><td>73.8±2.9</td><td>34.9</td><td>■</td><td>7.6</td><td>-</td><td>8.3</td><td>5.0</td><td></td><td>121.5</td></tr><tr><td>Sparse</td><td>Maze2d-large</td><td>74.4 ± 1.7</td><td>58.6</td><td>=</td><td>23.7</td><td>=</td><td>6.2</td><td>12.5</td><td></td><td>123.0</td></tr><tr><td colspan="2">Average (Maze2d)</td><td>74.0</td><td>50.0</td><td></td><td>10.8</td><td>■</td><td>9.1</td><td>7.7</td><td>=</td><td>119.5</td></tr><tr><td>Complete</td><td>FrankaKitchen</td><td>77.9 ± 0.6</td><td>62.5</td><td></td><td>0.0</td><td>■</td><td>8.11</td><td>43.8</td><td></td><td>=</td></tr><tr><td>Partial</td><td>FrankaKitchen</td><td>47.9 ± 4.1</td><td>46.3</td><td></td><td>15.4</td><td>=</td><td>18.9</td><td>49.8</td><td></td><td></td></tr><tr><td>Mixed</td><td>FrankaKitchen</td><td>45.4 ± 1.6</td><td>51.0</td><td></td><td>10.6</td><td>■</td><td>8.1</td><td>51.0</td><td></td><td></td></tr><tr><td colspan="2">Average (FrankaKitchen)</td><td>57.1</td><td>53.3</td><td>-</td><td>8.7</td><td>-</td><td>11.7</td><td>48.2</td><td>■</td><td>■</td></tr></table>
487
+
488
+ Table 3: Additional performance numbers of SfBC in Maze2d and FrankaKitchen tasks. We report the mean and standard deviation over three seeds for SfBC. Scores are normalized according to $\mathrm { F u }$ et al. (2020).
489
+ Table 4: Ablations of generative modeling methods and the implicit planning method. We report the mean and standard deviation over four seeds for the main experiment and three seeds for other experiments. Scores are normalized according to Fu et al. (2020).
490
+
491
+ <table><tr><td>Dataset</td><td>Environment</td><td>SfBC</td><td>SfBC +Gaussian</td><td>SfBC + VAE</td><td>SfBC - Planning</td></tr><tr><td>Medium-Expert</td><td>HalfCheetah</td><td>92.6 ± 0.5</td><td>79.4 ± 1.4</td><td>85.2 ± 2.9</td><td>91.4± 0.6</td></tr><tr><td>Medium-Expert</td><td>Hopper</td><td>108.6± 2.1</td><td>107.8± 7.8</td><td>92.0 ± 7.3</td><td>109.0 ±1.0</td></tr><tr><td>Medium-Expert</td><td>Walker</td><td>109.8±0.2</td><td>71.5 ± 1.5</td><td>109.3± 2.5</td><td>109.4 ± 0.9</td></tr><tr><td>Medium</td><td>HalfCheetah</td><td>45.9 ± 2.2</td><td>42.0± 0.2</td><td>43.4± 0.1</td><td>42.4±0.2</td></tr><tr><td>Medium</td><td>Hopper</td><td>57.1 ± 4.1</td><td>58.1 ± 1.5</td><td>65.6 ± 3.3</td><td>60.1 ± 4.2</td></tr><tr><td>Medium</td><td>Walker</td><td>77.9 ± 2.5</td><td>82.4± 1.1</td><td>79.1 ± 2.5</td><td>80.3 ± 0.9</td></tr><tr><td>Medium-Replay</td><td>HalfCheetah</td><td>37.1 ± 1.7</td><td>36.2±1.2</td><td>42.4± 0.5</td><td>37.5 ± 0.6</td></tr><tr><td>Medium-Replay</td><td>Hopper</td><td>86.2 ± 9.1</td><td>67.8 ± 6.5</td><td>58.6± 4.8</td><td>58.6 ± 1.3</td></tr><tr><td>Medium-Replay</td><td>Walker</td><td>65.1± 5.6</td><td>65.8± 4.4</td><td>62.2 ± 4.3</td><td>62.6 ± 2.2</td></tr><tr><td colspan="2">Average</td><td>75.6</td><td>67.9</td><td>70.9</td><td>72.3</td></tr><tr><td>Default</td><td>AntMaze-umaze</td><td>92.0± 2.1</td><td>93.3± 2.4</td><td>91.6± 2.4</td><td>96.7 ± 4.7</td></tr><tr><td>Diverse</td><td>AntMaze-umaze</td><td>85.3±3.6</td><td>88.3±2.4</td><td>78.3 ± 4.7</td><td>80.0 ± 10.8</td></tr><tr><td>Play</td><td>AntMaze-medium</td><td>81.3 ± 2.6</td><td>80.0 ± 4.1</td><td>68.3± 2.4</td><td>35.0 ± 4.1</td></tr><tr><td>Diverse</td><td>AntMaze-medium</td><td>82.0±3.1</td><td>85.0 ± 7.1</td><td>65.0 ± 7.1</td><td>33.3 ± 6.2</td></tr><tr><td>Play</td><td>AntMaze-large</td><td>59.3 ± 14.3</td><td>43.3 ± 7.1</td><td>35.0 ±8.2</td><td>8.3±8.5</td></tr><tr><td>Diverse</td><td>AntMaze-large</td><td>45.5±6.6</td><td>26.7±8.5</td><td>20.0±0.0</td><td>6.7 ± 4.7</td></tr><tr><td colspan="2">Average</td><td>74.2</td><td>69.4</td><td>59.7</td><td>43.3</td></tr></table>
492
+
493
+ # E CHOICES OF REFERENCED BASELINES
494
+
495
+ Referenced baselines methods of SfBC can be roughly divided into four categories: 1. Policy regression methods that require dynamic programming such as IQL (Kostrikov et al., 2022) and VEM (Ma et al., 2022). 2. Policy regression methods that use vanilla returns as regression weights such as AWR (Peng et al., 2019) and BAIL (Chen et al., 2020). 3. Adaptations of existing off-policy algorithms with policy regularization such as BCQ (Fujimoto et al., 2019) and CQL (Kumar et al., 2020). 4. Sequence modeling methods such as DT (Chen et al., 2021) and Diffuser (Janner et al., 2022). Here we further highlight several methods which bear some resemblance to our approach: Both IQL and SfBC aim to entirely avoid selecting out-of-sample actions, except that IQL uses weighted regression while SfBC does not; VEM also uses an implicit in-sample planning scheme similar to ours; BCQ also uses a generative model (VAE) for behavior modeling, but only to assist the learning of another policy model; Diffuser, like SfBC, is also a diffusion-based algorithm, but uses approximated guided sampling at trajectory level instead of importance sampling at step level.
496
+
497
+ ![](images/935150bd852360484e51b19e1ce6727e2c76bc36a21b9032e1e204adc1c1241e.jpg)
498
+ Figure 8: Training curves of SfBC for MuJoCo and Antmaze tasks with different diffusion steps. We report the mean and standard deviation over four seeds for all experiments. Note that the parameters of the critic model are initialized at the beginning of each value iteration (every 100 data epochs).
499
+
500
+ # G CONNECTIONS TO PRIOR WORKS
501
+
502
+ In this section, we discuss in more detail the connections between SfBC and two prior works, namely VEM (Ma et al., 2022) and EMAQ (Ghasemipour et al., 2021).
503
+
504
+ # G.1 VEM
505
+
506
+ Our in-sample planning-based Q-operator $\mathcal { T } _ { \mu } ^ { \pi }$ bears some similarity to the multi-step estimation operator $\mathcal { T } _ { \mathrm { v e m } }$ proposed by Ma et al. (2022). A simplified version of $\mathcal { T } _ { \mathrm { v e m } }$ is defined as:
507
+
508
+ $$
509
+ { \mathcal { T } } _ { \mathrm { v e m } } V ( s ) : = \operatorname* { m a x } _ { n \geq 0 } \{ ( { \mathcal { T } } ^ { \mu } ) ^ { n } { \mathcal { T } } _ { \mu } ^ { \tau } V ( s ) \} ,
510
+ $$
511
+
512
+ which is is built on $\mathcal { T } _ { \mu } ^ { \tau }$ , an expectile-based V-learning operator proposed by VEM:
513
+
514
+ $$
515
+ \Gamma _ { \mu } ^ { \tau } V ( s ) : = \mathbb { E } _ { a \sim \mu ( \cdot | s ) } \left\{ \begin{array} { l l } { \tau [ r ( s , a ) + \gamma V ( s ^ { \prime } ) ] + ( 1 - \tau ) V ( s ) } & { \mathrm { ~ i f ~ } \quad r ( s , a ) + \gamma V ( s ^ { \prime } ) \geq V ( s ) } \\ { ( 1 - \tau ) [ r ( s , a ) + \gamma V ( s ^ { \prime } ) ] + \tau V ( s ) } & { \mathrm { ~ i f ~ } \quad r ( s , a ) + \gamma V ( s ^ { \prime } ) < V ( s ) } \end{array} \right\}
516
+ $$
517
+
518
+ here $\tau \in [ 0 , 1 )$ is a hyperparameter that helps interpolate the Bellman expectation operator $\mathcal { T } ^ { \mu }$ $\tau = 0 . 5 )$ and the Bellman optimality operator $\tau ^ { * }$ $\tau 1 . 0$ ). $V ( \cdot )$ is an arbitrary scalar function. $\mathcal { T } _ { \mu } ^ { \tau }$ has some nice properties such as monotonicity $( \mathcal T _ { \mu } ^ { \tau _ { 2 } } V ( \pmb { s } ) > \mathcal T _ { \mu } ^ { \tau _ { 1 } } V ( \pmb { s } )$ always holds for any $V$ given $\tau _ { 2 } > \tau _ { 1 }$ ). With these properties, Ma et al. (2022) derives that $\mathcal { \tilde { T } } _ { \mathrm { v e m } }$ and $\mathcal { T } _ { \mu } ^ { \tau }$ share the same fixed point.
519
+
520
+ However, VEM cannot be applied to stochastic environments because Equation 27 requires comparing $V ( s )$ and $r ( s , a ) + \gamma V ( s ^ { \prime } )$ . While $V ( s )$ is a scalar given $\pmb { s }$ , $r ( s , { \pmb a } ) + \gamma V ( { \pmb s } ^ { \prime } )$ is a random variable since $\pmb { s } ^ { \prime } \sim P ( \cdot | \pmb { s } , \pmb { a } )$ . To fix this problem, VEM simply assumes that the environment is deterministic, namely $r ( s , a )$ and $P ( \cdot | s , a )$ are all Dirac.
521
+
522
+ Compared with VEM, our in-sample planning-based $\mathrm { Q }$ -operator $\mathcal { T } _ { \mu } ^ { \pi }$ is not dependent on the expectilebased $\mathrm { v } .$ -operator $\mathcal { T } _ { \mu } ^ { \tau }$ , but uses an hypothetically improved policy $\pi > \mu$ for optimistic planning:
523
+
524
+ $$
525
+ \begin{array} { r } { \mathcal { T } _ { \mu } ^ { \pi } Q ( s , \pmb { a } ) : = \underset { n \geq 0 } { \operatorname* { m a x } } \{ ( \mathcal { T } ^ { \mu } ) ^ { n } \mathcal { T } ^ { \pi } Q ( s , \pmb { a } ) \} , } \end{array}
526
+ $$
527
+
528
+ which does not require the environment to be deterministic. A disadvantage of using $\mathcal { T } ^ { \pi }$ to replace $\smash { \mathcal { T } _ { \mu } ^ { \tau } }$ is that we no longer have the monotonicity property (e.g., $\mathcal T ^ { \pi } Q ( s , { \pmb a } ) > \mathcal T ^ { \mu } Q ( s , { \pmb a } )$ always holds for any $Q$ ). However, we can still derive that the fixed point of $\mathcal { T } _ { \mu } ^ { \pi }$ is bounded between $Q ^ { \pi }$ and $Q ^ { * }$ (See Appendix C for detailed results and proofs).
529
+
530
+ # G.2 EMAQ
531
+
532
+ The high-level idea of the selecting-from-behavior-candidates approach bears some resemblance to the Expected-Max Q-Learning (EMaQ) algorithm proposed by (Ghasemipour et al., 2021). EMaQ is built upon BCQ (Fujimoto et al., 2019), which computes the training target in Q-Learning by:
533
+
534
+ $$
535
+ \mathcal { T } _ { \mathrm { B C Q } } ^ { * } Q ( s , a ) : = r ( s , a ) + \gamma \operatorname* { m a x } _ { a ^ { \prime } \sim \mu _ { \theta } ( \cdot \vert s ^ { \prime } ) } \{ Q ( s ^ { \prime } , a ^ { \prime } + \xi _ { \phi } ( s ^ { \prime } , a ^ { \prime } ) ) \} ,
536
+ $$
537
+
538
+ where $\xi _ { \phi } ( s , a )$ is an explicitly constrained perturbation network that helps relax the constraint of behavior policy $\mu$ . The core motivation for EMaQ is to remove the perturbation model $\xi _ { \phi } ( \pmb { s } , \pmb { a } )$ , by taking max over $_ \mathrm { N }$ Q-function evaluations:
539
+
540
+ $$
541
+ \mathcal { T } _ { \mathrm { E M a Q } } Q ( s , a ) : = r ( s , a ) + \gamma \mathbb { E } _ { \{ a _ { i } ^ { \prime } \} ^ { N } \sim \mu _ { \theta } ( \cdot \vert s ^ { \prime } ) } \big [ \operatorname* { m a x } _ { a _ { i } ^ { \prime } \in \{ a _ { i } ^ { \prime } \} ^ { N } } Q ( s ^ { \prime } , a _ { i } ^ { \prime } ) \big ] .
542
+ $$
543
+
544
+ For EMaQ, $N$ serves as a hyperparameter to interpolate $\mathcal { T } ^ { \mu }$ and $\tau ^ { * }$ . When $N = 1$ , $\tau _ { \mathrm { E M a Q } }$ becomes $\mathcal { T } ^ { \mu }$ . When $N \to \infty$ , $\tau _ { \mathrm { E M a Q } }$ approaches $\tau ^ { * }$ because $\{ { \pmb a } _ { i } ^ { \prime } \} ^ { N }$ nearly covers the whole action space.
545
+
546
+ In contrast, for SfBC, the hyperparameter $N$ is the number of Monte Carlo samples used to estimate the training Q-targets:
547
+
548
+ $$
549
+ \begin{array} { r l r } { { \mathcal { T } ^ { \pi } Q ( s , a ) = r ( s , a ) + \gamma \mathbb { E } _ { a ^ { \prime } \sim \pi ( \cdot \vert s ^ { \prime } ) } Q ( s ^ { \prime } , a ^ { \prime } ) } } \\ & { } & { = r ( s , a ) + \gamma \mathbb { E } _ { a ^ { \prime } \sim \mu ( \cdot \vert s ^ { \prime } ) } \frac { \exp { ( \alpha Q ( s ^ { \prime } , a ^ { \prime } ) ) } } { Z ( s ^ { \prime } ) } Q ( s ^ { \prime } , a ^ { \prime } ) } \\ & { } & { \approx r ( s , a ) + \gamma \sum _ { N } [ \frac { \exp { ( \alpha Q ( s ^ { \prime } , a ^ { \prime } ) ) } } { \sum _ { N } \exp { ( \alpha Q ( s ^ { \prime } , a ^ { \prime } ) ) } } Q ( s ^ { \prime } , a ^ { \prime } ) ] } \end{array}
550
+ $$
md/dev/4AZz9osqrar/4AZz9osqrar.md ADDED
The diff for this file is too large to render. See raw diff
 
md/dev/4p6_5HBWPCw/4p6_5HBWPCw.md ADDED
@@ -0,0 +1,471 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # GRAPH-LESS NEURAL NETWORKS: TEACHING OLD MLPS NEW TRICKS VIA DISTILLATION
2
+
3
+ Shichang Zhang∗ University of California, Los Angeles shichang@cs.ucla.edu
4
+
5
+ Yozen Liu
6
+ Snap Inc.
7
+ yliu2@snap.com
8
+
9
+ # Yizhou Sun
10
+
11
+ University of California, Los Angeles yzsun@cs.ucla.edu
12
+
13
+ Neil Shah
14
+ Snap Inc.
15
+ nshah@snap.com
16
+
17
+ # ABSTRACT
18
+
19
+ Graph Neural Networks (GNNs) are popular for graph machine learning and have shown great results on wide node classification tasks. Yet, they are less popular for practical deployments in the industry owing to their scalability challenges incurred by data dependency. Namely, GNN inference depends on neighbor nodes multiple hops away from the target, and fetching them burdens latency-constrained applications. Existing inference acceleration methods like pruning and quantization can speed up GNNs by reducing Multiplication-and-ACcumulation (MAC) operations, but the improvements are limited given the data dependency is not resolved. Conversely, multi-layer perceptrons (MLPs) have no graph dependency and infer much faster than GNNs, even though they are less accurate than GNNs for node classification in general. Motivated by these complementary strengths and weaknesses, we bring GNNs and MLPs together via knowledge distillation (KD). Our work shows that the performance of MLPs can be improved by large margins with GNN KD. We call the distilled MLPs Graph-less Neural Networks (GLNNs) as they have no inference graph dependency. We show that GLNNs with competitive accuracy infer faster than GNNs by $1 4 6 \times - 2 7 3 \times$ and faster than other acceleration methods by $1 4 \times - 2 7 \times$ . Under a production setting involving both transductive and inductive predictions across 7 datasets, GLNN accuracies improve over stand-alone MLPs by $1 2 . 3 6 \%$ on average and match GNNs on 6/7 datasets. Comprehensive analysis shows when and why GLNNs can achieve competitive accuracies to GNNs and suggests GLNN as a handy choice for latency-constrained applications.
20
+
21
+ # 1 INTRODUCTION
22
+
23
+ Graph Neural Networks (GNNs) have recently become very popular for graph machine learning (GML) research and have shown great results on node classification tasks (Kipf & Welling, 2016; Hamilton et al., 2017; Velickovi ˇ c et al. ´ , 2017) like product prediction on co-purchasing graphs and paper category prediction on citation graphs. However, for large-scale industrial applications, MLPs remain the major workhorse, despite common (implicit) underlying graphs and suitability for GML formalisms. One reason for this academic-industrial gap is the challenges in scalability and deployment brought by data dependency in GNNs (Zhang et al., 2020; Jia et al., 2020), which makes GNNs hard to deploy for latency-constrained applications that require fast inference.
24
+
25
+ Neighborhood fetching caused by graph dependency is one of the major sources of GNN latency. Inference on a target node necessitates fetching topology and features of many neighbor nodes, especially on small-world graphs (detailed discussion in Section 4). Common inference acceleration techniques like pruning (Zhou et al., 2021) and quantization (Tailor et al., 2021; Zhao et al., 2020) can speed up GNNs to some extent by reducing Multiplication-and-ACcumulation (MAC) operations.
26
+
27
+ However, their improvements are limited given the graph dependency is not resolved. Unlike GNNs, MLPs have no dependency on graph data and are easier to deploy than GNNs. They also enjoy the auxiliary benefit of sidestepping the cold-start problem that often happens during the online prediction of relational data (Wei et al., 2020), meaning MLPs can infer reasonably even when neighbor information of a new encountered node is not immediately available. On the other hand, this lack of graph dependency typically hurts for relational learning tasks, limiting MLP performance on GML tasks compared to GNNs. We thus ask: can we bridge the two worlds, enjoying the low-latency, dependency-free nature of MLPs and the graph context-awareness of GNNs at the same time?
28
+
29
+ Present work. Our key finding is that it is possible to distill knowledge from GNNs to MLPs without losing significant performance, but reducing the inference time drastically for node classification. The knowledge distillation (KD) can be done offline, coupled with model training. In other words, we can shift considerable work from the latency-constrained inference step, where time reduction in milliseconds makes a huge difference, to the less time-sensitive training step, where time cost in hours or days is often tolerable. We call our approach Graph-less Neural Network (GLNN). Specifically, GLNN is a modeling paradigm involving KD from a GNN teacher to a student MLP; the resulting GLNN is an MLP optimized through KD, so it enjoys the benefits of graph contextawareness in training but has no graph dependency in inference. Regarding speed, GLNNs have superior efficiency and are $1 4 6 \times - 2 7 3 \times$ faster than GNNs and $1 4 \times - 2 7 \times$ faster than other inference acceleration methods. Regarding performance, under a production setting involving both transductive and inductive predictions on 7 datasets, GLNN accuracies improve over MLPs by $1 2 . 3 6 \%$ on average and match GNNs on $6 / 7$ datasets. We comprehensively study when and why GLNNs can achieve competitive results as GNNs. Our analysis suggests the critical factors for such great performance are large MLP sizes and high mutual information between node features and labels. Our observations align with recent results in vision and language, which posit that large enough (or slightly modified) MLPs can achieve similar results as CNNs and Transformers (Liu et al., 2021; Tolstikhin et al., 2021; Melas-Kyriazi, 2021; Touvron et al., 2021; Ding et al., 2021). Our core contributions are as follows:
30
+
31
+ • We propose GLNN, which eliminates neighbor-fetching latency in GNN inference via KD to MLP. • We show GLNNs has competitive performance as GNNs, while enjoying $1 4 6 \times - 2 7 3 \times$ faster inference than vanilla GNNs and $1 4 \times - 2 7 \times$ faster inference than other inference acceleration methods. • We study GLNN properties comprehensively by investigating their performance under different settings, how they work as regularizers, their inductive bias, expressiveness, and limitations.
32
+
33
+ # 2 RELATED WORK
34
+
35
+ Graph Neural Networks. The early GNNs generalize convolution nets to graphs (Bruna et al., 2014; Defferrard et al., 2017) and later simplified to message-passing neural net (MPNN) by GCN (Kipf & Welling, 2016). Most GNNs after can be put as MPNNs. For example, GAT employs attention (Velickovi ˇ c et al. ´ , 2017), PPNP employs personalized PageRank (Klicpera et al., 2019), GCNII and DeeperGCN employ residual connections and dense connections (Chen et al., 2020; Li et al., 2019).
36
+
37
+ Inference Acceleration. Inference acceleration have been proposed by hardware improvements (Chen et al., 2016; Judd et al., 2016) and algorithmic improvements through pruning (Han et al., 2015), quantization (Gupta et al., 2015). For GNNs, pruning (Zhou et al., 2021) and quantizing GNN parameters (Zhao et al., 2020) have been studied. These approaches speed up GNN inference to a certain extent but do not eliminate the neighbor-fetching latency. In contrast, our cross-model KD solves this issue. Concurrently, Graph-MLP also tries to bypass GNN neighbor fetching (Hu et al., 2021) by training an MLP with a neighbor contrastive loss, but it only considers transductive but not the more practical inductive setting. Some sampling works focus on speed up GNN training (Zou et al., 2019; Chen et al., 2018), which are complementary to our goal on inference acceleration.
38
+
39
+ GNN distillation. Existing GNN KD works try to distill large GNNs to smaller GNNs. LSP (Yang et al., 2021b) and TinyGNN (Yan et al., 2020) do KD while preserving local information. Their students are GNNs with fewer parameters but not necessarily fewer layers. Thus, both designs still require latency-inducing fetching. GFKD (Deng & Zhang, 2021) does graph-level KD via graph generation. In GFKD, data instances are independent graphs, whereas we focus on dependent nodes within a graph. GraphSAIL (Xu et al., 2020) uses KD to learn students work well on new data while preserving performance on old data. CPF (Yang et al., 2021a) combines KD and label propagation (LP). The student in CPF is not a GNN, but it is still heavily graph-dependent as it uses LP.
40
+
41
+ ![](images/3c59c6aff8764b30e7d812c76a7e7b24c6d87080f7daff930791e286b7e0e843.jpg)
42
+ Figure 1: The number of fetches and the inference time of GNNs are both magnitudes more than MLPs and grow exponentially as functions of the number of layers. Left: neighbors need to be fetched for two GNN layers. Middle: the total number of fetches for inference. Right: the total inference time. (Inductive inference for 10 random nodes on OGB Products (Hu et al., 2020))
43
+
44
+ # 3 PRELIMINARIES
45
+
46
+ Notations. For GML tasks, the input is usually a graph and its node features, which we write as $\mathcal { G } = ( \nu , \mathcal { E } )$ , with $\nu$ stands for all nodes, and $\mathcal { E }$ stands for all edges. Let $N$ denote the total number of nodes. We use $\pmb { X } \in \mathbb { R } ^ { N \times D }$ to represent node features, with row $\mathbf { \boldsymbol { x } } _ { v }$ being the $D$ -dimensional feature of node $v \in \mathcal V$ . We represent edges with an adjacency matrix $\pmb { A }$ , with $A _ { u , v } = 1$ if edge $( u , v ) \in \mathcal { E }$ , and 0 otherwise. For node classification, one of the most important GML applications, the prediction targets are $\pmb { Y } \in \mathbb { R } ^ { N \times K }$ , where row $\mathbf { \Delta } _ { \mathbf { \mathcal { Y } } _ { v } }$ is a $K$ -dim one-hot vector for node $v$ . For a given $\mathcal { G }$ , usually a small portion of nodes will be labeled, which we mark using superscript $L$ , i.e. $\mathcal { V } ^ { \tilde { L } }$ , $X ^ { L }$ , and $\mathbf { \nabla } _ { \mathbf { Y } } \breve { L }$ . The majority of nodes will be unlabeled, and we mark using the superscript $U$ , i.e. $\mathcal { V } ^ { U }$ , $X ^ { U }$ , and $\mathbf { \nabla } _ { \mathbf { Y } } U$ .
47
+
48
+ Graph Neural Networks. Most GNNs fit under the message-passing framework, where the representation $h _ { v }$ of each node $v$ is updated iteratively in each layer by collecting messages from its neighbors denoted as $\mathcal { N } ( v )$ . For the $l$ -th layer, $\mathbf { \Sigma } _ { h _ { v } ^ { ( l ) } }$ is obtained from the previous layer representation $ { \boldsymbol { h } } _ { u } ^ { ( l - 1 ) }$ $\mathbf { \mathcal { h } } _ { u } ^ { ( 0 ) } = \mathbf { \mathcal { x } } _ { u } )$ ) via an aggregation operation AGGR followed by an UPDATE operation as
49
+
50
+ $$
51
+ \begin{array} { r } { \pmb { h } _ { N ( v ) } ^ { ( l ) } = \mathrm { A G G R } ( \{ \pmb { h } _ { u } ^ { ( l - 1 ) } : u \in \mathcal { N } ( v ) \} ) \qquad \mathrm { a n d } \qquad \pmb { h } _ { v } ^ { ( l ) } = \mathrm { U P D A T E } ( \pmb { h } _ { N ( v ) } ^ { ( l ) } , \pmb { h } _ { v } ^ { ( l - 1 ) } ) } \end{array}
52
+ $$
53
+
54
+ # 4 MOTIVATION
55
+
56
+ GNNs have considerable inference latency due to graph dependency. One more GNN layer means fetching one more hop of neighbors. To infer a node with a $L$ -layer GNN on a graph with average degree $R$ requires $\mathcal { O } ( R ^ { L } )$ fetches. $R$ can be large for real-world graphs, e.g. 208 for the Twitter (Ching et al., 2015). Also, as layer fetching must be done sequentially, the total latency explodes quickly as $L$ increases. Figure 1 shows the dependency added by each GNN layer and the exponential explosion of inference time. In contrast, the MLP inference time is much smaller and grows linearly. This marked gap contributes greatly to the practicality of MLPs in industrial applications over GNNs.
57
+
58
+ The node-fetching latency is exacerbated by two factors: firstly, newer GNN architectures are getting deeper from 64 layers (Chen et al., 2020) to even 1001 layers (Li et al., 2021). Secondly, industrialscale graphs are frequently too large to fit into the memory of a single machine (Jin et al., 2022), necessitating sharding of the graph out of the main memory. For example, Twitter has 288M monthly active users (nodes) and an estimated 60B followers (edges) as of 3/2015. Facebook has 1.39B active users with more than 400B edges as of 12/2014 (Ching et al., 2015). Even when stored in a sparse-matrix-friendly format (often COO or CSR), these graphs are on the order of TBs and are constantly growing. Moving away from in-memory storage results in even slower neighbor-fetching.
59
+
60
+ MLPs, on the other hand, lack the means to exploit graph topology, which hurts their performance for node classification. For example, test accuracy on Products is 78.61 for GraphSAGE compared to 62.47 for an equal-sized MLP. Nonetheless, recent results in vision and language posit that large (or slightly modified) MLPs can achieve similar results as CNNs and Transformers (Liu et al., 2021). We thus also ask: Can we bridge the best of GNNs and MLPs to get high-accuracy and low-latency models? This motivates us to do cross-model KD from GNNs to MLPs.
61
+
62
+ ![](images/fe13a4358c6462ce72c20699e317599db71d44b7281ec5d0c4ff85854d7ca559.jpg)
63
+ Figure 2: The GLNN framework: In offline training, a trained GNN teacher is applied on the graph for soft targets. Then, a student MLP is trained on node features guided by the soft targets. The distilled MLP, now GLNN, is deployed for online predictions. Since graph dependency is eliminated for inference, GLNNs infer much faster than GNNs, and hence the name “Graph-less Neural Network.”
64
+
65
+ # 5 GRAPH-LESS NEURAL NETWORKS
66
+
67
+ We introduce GLNN and answer exploration questions of its properties: 1) How do GLNNs compare to MLPs and GNNs? 2) Can GLNNs work well under both transductive and inductive settings? 3) How do GLNNs compare to other inference acceleration methods? 4) How do GLNNs benefit from KD? 5) Do GLNNs have sufficient model expressiveness? 6) When will GLNNs fail to work?
68
+
69
+ # 5.1 THE GLNN FRAMEWORK
70
+
71
+ The idea of GLNN is straightforward, yet as we will see, extremely effective. In short, we train a “boosted” MLP via KD from a teacher GNN. KD was introduced in Hinton et al. (2015), where knowledge was transferred from a cumbersome teacher to a simpler student. In our case, we generate soft targets $z _ { v }$ for each node $v$ with a teacher GNN. Then we train a student MLP with both true labels $\mathbf { \Delta } _ { \mathbf { \mathcal { Y } } _ { v } }$ and $z _ { v }$ . The objective is as Equation 1, with $\lambda$ being a weight parameter, $\mathcal { L } _ { l a b e l }$ being the cross-entropy between $\mathbf { \nabla } _ { \mathbf { y } _ { v } }$ and student predictions $\hat { y } _ { v }$ , $\mathcal { L } _ { t e a c h e r }$ being the KL-divergence.
72
+
73
+ $$
74
+ \mathcal { L } = \lambda \Sigma _ { v \in \mathcal { V } ^ { L } } \mathcal { L } _ { l a b e l } ( \hat { y } _ { v } , y _ { v } ) + ( 1 - \lambda ) \Sigma _ { v \in \mathcal { V } } \mathcal { L } _ { t e a c h e r } ( \hat { y } _ { v } , z _ { v } )
75
+ $$
76
+
77
+ The model after KD, i.e. GLNN, is essentially a MLP. Therefore, GLNNs have no graph dependency during inference and are as fast as MLPs. On the other hand, through offline KD, GLNN parameters are optimized to predict and generalize as well as GNNs, with the added benefit of faster inference and easier deployment. In Figure 2, we show the offline KD and online inference steps of GLNNs.
78
+
79
+ # 5.2 EXPERIMENT SETTINGS
80
+
81
+ Datasets. We consider all five datasets used in the CPF paper (Yang et al., 2021a), i.e. Cora, Citeseer, Pubmed, A-computer, and A-photo. To fully evaluate our method, we also include two more larger OGB datasets (Hu et al., 2020), i.e. Arxiv and Products.
82
+
83
+ Model Architectures. For consistent results, we use GraphSAGE (Hamilton et al., 2017) with GCN aggregation as the teacher. We conduct ablation studies of other GNN teachers like GCN (Kipf & Welling, 2016), GAT (Velickovi ˇ c et al. ´ , 2017) and, APPNP (Klicpera et al., 2019) in Section 6.
84
+
85
+ Evaluation Protocol. For all experiments in this section, we report the average and standard deviation over ten runs with different random seeds. Model performance is measured as accuracy, and results are reported on test data with the best model selected using validation data.
86
+
87
+ Transductive vs. Inductive. Given ${ \mathcal { G } } , X$ , and $Y ^ { L }$ , we consider node classification under two settings: transductive $( t r a n )$ and inductive $( i n d )$ . For ind, we hold out some test data for inductive evaluation only. We first select inductive nodes $\mathcal { V } _ { i n d } ^ { U } \subset \mathcal { V } ^ { U }$ , which partitions $\mathcal { V } ^ { U }$ into the disjoint inductive subset and observed subset, i.e. $\mathcal { V } ^ { U } = \mathcal { V } _ { o b s } ^ { U } \sqcup \mathcal { V } _ { i n d } ^ { U }$ . Then we hold out $v \in \mathcal { V } _ { i n d } ^ { U }$ and all edges connected to $v \in \mathcal { V } _ { i n d } ^ { U }$ obs ind, which leads to two disjoint graphs $\mathcal { G } = \mathcal { G } _ { o b s } \sqcup \mathcal { G } _ { i n d }$ ind with no shared nodes or
88
+
89
+ Table 1: GLNNs outperform MLPs by large margins and match GNNs on 5 of 7 datasets under the transductive setting. $\Delta _ { M L P }$ $( \Delta _ { G N N } )$ represents difference between the GLNN and a trained MLP (GNN). Results show accuracy (higher is better); $\Delta _ { G N N } 2 0$ indicates GLNN outperforms GNN.
90
+
91
+ <table><tr><td>Datasets</td><td>SAGE</td><td>MLP</td><td>GLNN</td><td>△MLP</td><td>△GNN</td></tr><tr><td>Cora</td><td>80.52 ± 1.77</td><td>59.22 ±1.31</td><td>80.54 ± 1.35</td><td>21.32 (36.00%)</td><td>0.02 (0.02%)</td></tr><tr><td>Citeseer</td><td>70.33 ± 1.97</td><td>59.61 ± 2.88</td><td>71.77 ± 2.01</td><td>12.16 (20.40%)</td><td>1.44 (2.05%)</td></tr><tr><td>Pubmed</td><td>75.39 ± 2.09</td><td>67.55 ± 2.31</td><td>75.42 ± 2.31</td><td>7.87 (11.65%)</td><td>0.03 (0.04%)</td></tr><tr><td>A-computer</td><td>82.97 ± 2.16</td><td>67.80 ± 1.06</td><td>83.03 ± 1.87</td><td>15.23 (22.46%)</td><td>0.06 (0.07%)</td></tr><tr><td>A-photo</td><td>90.90 ± 0.84</td><td>78.77 ± 1.74</td><td>92.11 ± 1.08</td><td>13.34 (16.94%)</td><td>1.21 (1.33%)</td></tr><tr><td>Arxiv</td><td>70.92 ± 0.17</td><td>56.05 ± 0.46</td><td>63.46 ± 0.45</td><td>7.41 (13.24%)</td><td>-7.46 (-10.52%)</td></tr><tr><td>Products</td><td>78.61 ± 0.49</td><td>62.47 ± 0.10</td><td>68.86 ± 0.46</td><td>6.39 (10.23%)</td><td>-9.75 (-12.4%)</td></tr></table>
92
+
93
+ Table 2: Enlarged GLNNs match the performance of GNNs on the OGB datasets. For Arxiv, we use MLPw4 (GLNNw4). For Products, we use MLPw8 (GLNNw8).
94
+
95
+ <table><tr><td>Datasets</td><td>SAGE</td><td>MLP+</td><td>GLNN+</td><td>△MLP</td><td>△GNN</td></tr><tr><td>Arxiv</td><td>70.92 ± 0.17</td><td>55.31± 0.47</td><td>72.15 ± 0.27</td><td>16.85 (30.46%)</td><td>0.51 (0.71%)</td></tr><tr><td>Products</td><td>78.61 ± 0.49</td><td>64.50 ± 0.45</td><td>77.65 ± 0.48</td><td>13.14 (20.38%)</td><td>-0.97 (-1.23%)</td></tr></table>
96
+
97
+ els are partitioned into three disjoint sets, i.e. . Concretely, the input/output of both setting $X = X ^ { L } \sqcup X _ { o b s } ^ { U } \sqcup X _ { i n d } ^ { U }$ $\pmb { Y } = \pmb { Y } ^ { L } \sqcup \pmb { Y } _ { o b s } ^ { U } \sqcup \pmb { Y } _ { i n d } ^ { U }$
98
+
99
+ • ind: train on • tran: train on $\mathcal { G } _ { o b s }$ ${ \mathcal { G } } , X$ , $X ^ { L }$ , and , $X _ { o b s } ^ { U }$ $\mathbf { \nabla } _ { \mathbf { Y } ^ { L } }$ ; evaluate on , and $Y ^ { L }$ ; evaluate on $( X ^ { U } , Y ^ { U } )$ $( X _ { i n d } ^ { U } , Y _ { i n d } ^ { U } )$ ; $\mathrm { K D }$ uses $z _ { v }$ v ; KD uses for $v \in \mathcal V$ $z _ { v }$ . for
100
+
101
+ Note that for tran, all the nodes in the graph including the validation and test nodes are used to generate $_ { z }$ . A discussion of this choice along with other experiment details are in Appendix A.
102
+
103
+ # 5.3 HOW DO GLNNS COMPARE TO MLPS AND GNNS?
104
+
105
+ We start by comparing GLNNs to MLPs and GNNs with the same number of layers and hidden dimensions. We first consider the standard transductive setting, so our results in Table 1 are directly comparable to results reported in previous literature like Yang et al. (2021a) and Hu et al. (2020).
106
+
107
+ As shown in Table 1, the performance of all GLNNs improve over MLPs by large margins. On smaller datasets (first 5 rows), GLNNs can even outperform the teacher GNNs. In other words, for each task, with the same parameter budget, there exists a set of MLP parameters that has GNN-competitive performance (detailed discussion in Sections 5.6 and 5.7). For the larger OGB datasets (last 2 rows), the GLNN performance is improved over MLPs but still worse than the teacher GNNs. However, as we show in Table 2, this gap can be mitigated by increasing MLP size to MLPwi1. In Figure 3 (right), we visualize the trade-off between prediction accuracy and model inference time with different model sizes. We show that gradually increasing GLNN size pushes its performance to be close to SAGE. On the other hand, when we reduce the number of layers of $\mathrm { S A G E } ^ { 2 }$ , the accuracy quickly drops to be worse than GLNNs. A detailed discussion of the rationale for increasing MLP sizes is in Appendix B.
108
+
109
+ # 5.4 CAN GLNNS WORK WELL UNDER BOTH TRANSDUCTIVE AND INDUCTIVE SETTINGS?
110
+
111
+ Although transductive is the commonly studied setting for node classification, it does not encompass prediction on unseen nodes. Therefore, it may not be the best way to evaluate a deployed model, which must often generate predictions for new data points as well as reliably maintain performance on old ones. Thus, to better understand the effectiveness of GLNN, we also consider their performance under a realistic production setting, which contains both transductive and inductive predictions.
112
+
113
+ To evaluate a model inductively, we hold out some test nodes from training to form an inductive set, i.e. $\mathcal { V } ^ { U } = \mathcal { V } _ { o b s } ^ { U } \sqcup \mathcal { V } _ { i n d } ^ { U }$ . In production, a model might be re-trained periodically, e.g. weekly. The obs hold-out nodes in $V _ { i n d } ^ { U }$ represent new nodes entered the graph between two trainings. $V _ { i n d } ^ { U }$ is usually small compared to $V _ { o b s } ^ { U }$ – e.g. Graham (2012) estimates $5- 7 \%$ for the fastest-growing tech startups. In our case, to mitigate randomness and better evaluate generalizability, we use V Uind containing 20% of the test data. We also evaluate on standard transductive prediction on $V _ { o b s } ^ { U }$ containing the otherrved unlabeled nodes $80 \%$ of the test data, representing thee inference is commonly redone on existing nodes in real-world cases. We report both results and a interpolated production (prod) results in Table 3. The prod results paint a clearer picture of model generalization as well as accuracy in production. See Section 6 for an ablation study of different inductive split rates other than 20-80.
114
+
115
+ ![](images/56094e9645d24171cda661a02619bd1120d8d877a8d7ebb8ed27856fa4567de6.jpg)
116
+ Figure 3: Enlarged MLPs (GLNNs) can match GNN accuracy, but infer dramatically faster. Plots are under the same setting as Figure 1. Left: inference time of MLPs vs. GNN (SAGE) for different model sizes. Right: model accuracy vs. inference time. Note: time axes are log-scaled.
117
+
118
+ Table 3: GLNNs match GNN performance on a production setting with both inductive and transductive predictions. We uProducts. ind results on $V _ { i n d } ^ { U }$ LP for the 5 C, tran results on $V _ { o b s } ^ { U }$ atasets, MLPw4 for Arxiv, and MLPw8 for, and the interpolated prod results are reported.
119
+
120
+ <table><tr><td>Datasets</td><td>Eval</td><td>SAGE</td><td>MLP/MLP+</td><td>GLNN/GLNN+</td><td>△MLP</td><td>△GNN</td></tr><tr><td>Cora</td><td>prod</td><td>79.29</td><td>58.98</td><td>78.28</td><td>19.30 (32.72%)</td><td>-1.01 (-1.28%)</td></tr><tr><td></td><td>ind</td><td>81.33 ± 2.19</td><td>59.09 ± 2.96</td><td>73.82 ± 1.93</td><td>14.73 (24.93%)</td><td>-7.51 (-9.23%)</td></tr><tr><td></td><td>tran</td><td>78.78 ± 1.92</td><td>58.95 ± 1.66</td><td>79.39 ± 1.64</td><td>20.44 (34.66%)</td><td>0.61 (0.77%)</td></tr><tr><td>Citeseer</td><td>prod</td><td>68.38</td><td>59.81</td><td>69.27</td><td>9.46 (15.82%)</td><td>0.89 (1.30%)</td></tr><tr><td></td><td>ind</td><td>69.75 ± 3.59</td><td>60.06 ± 5.00</td><td>69.25 ± 2.25</td><td>9.19 (15.30%)</td><td>-0.5 (-0.7%)</td></tr><tr><td></td><td>tran</td><td>68.04 ± 3.34</td><td>59.75 ± 2.48</td><td>69.28 ± 3.12</td><td>9.63 (15.93%)</td><td>1.24 (1.82%)</td></tr><tr><td>Pubmed</td><td>prod</td><td>74.88</td><td>66.80</td><td>74.71</td><td>7.91 (11.83%)</td><td>-0.17 (-0.22%)</td></tr><tr><td></td><td>ind</td><td>75.26 ± 2.57</td><td>66.85 ± 2.96</td><td>74.30 ± 2.61</td><td>7.45 (11.83%)</td><td>-0.96 (-1.27%)</td></tr><tr><td></td><td>tran</td><td>74.78 ± 2.22</td><td>66.79 ± 2.90</td><td>74.81 ± 2.39</td><td>8.02 (12.01%)</td><td>0.03 (0.04%)</td></tr><tr><td>A-computer</td><td>prod</td><td>82.14</td><td>67.38</td><td>82.29</td><td>14.90 (22.12%)</td><td>0.15 (0.19%)</td></tr><tr><td></td><td>ind</td><td>82.08 ± 1.79</td><td>67.84 ± 1.78</td><td>80.92 ± 1.36</td><td>13.08 (19.28%)</td><td>-1.16 (-1.41%)</td></tr><tr><td></td><td>tran</td><td>82.15 ± 1.55</td><td>67.27 ± 1.36</td><td>82.63 ± 1.40</td><td>15.36 (22.79%)</td><td>0.48 (0.58%)</td></tr><tr><td>A-photo</td><td>prod</td><td>91.08</td><td>79.25</td><td>92.38</td><td>13.13 (16.57%)</td><td>1.30 (1.42%)</td></tr><tr><td></td><td>ind</td><td>91.50 ± 0.79</td><td>79.44 ± 1.72</td><td>91.18 ± 0.81</td><td>11.74 (14.78%)</td><td>-0.32 (-0.35%)</td></tr><tr><td></td><td>tran</td><td>90.80 ± 0.77</td><td>79.20 ± 1.64</td><td>92.68 ± 0.56</td><td>13.48 (17.01%)</td><td>1.70 (1.87%)</td></tr><tr><td>Arxiv</td><td>prod</td><td>70.73</td><td>55.30</td><td>65.09</td><td>9.79 (17.70%)</td><td>-5.64 (-7.97%)</td></tr><tr><td></td><td>ind</td><td>70.64 ± 0.67</td><td>55.40 ± 0.56</td><td>60.48 ± 0.46</td><td>4.3 (7.76%)</td><td>-10.94 (-15.49%)</td></tr><tr><td></td><td>tran</td><td>70.75± 0.27</td><td>55.28 ± 0.49</td><td>71.46 ± 0.33</td><td>11.16 (20.18%)</td><td>-4.31 (-6.09%)</td></tr><tr><td>Products</td><td>prod</td><td>76.60</td><td>63.72</td><td>75.77</td><td>12.05 (18.91%)</td><td>-0.83 (-1.09%)</td></tr><tr><td></td><td>ind</td><td>76.89 ± 0.53</td><td>63.70 ± 0.66</td><td>75.16 ± 0.34</td><td>11.44 (17.96%)</td><td>-1.73 (-2.25%)</td></tr><tr><td></td><td>tran</td><td>76.53 ±0.55</td><td>63.73 ± 0.69</td><td>75.92 ± 0.61</td><td>12.20 (19.15%)</td><td>-0.61 (-0.79%)</td></tr></table>
121
+
122
+ In Table 3, we see that GLNNs can still improve over MLP by large margins for inductive predictions. On 6/7 datasets, the GLNN prod performance are competitive to GNNs, which supports deploying GLNN as a much faster model with no or only slight performance loss. On the Arxiv dataset, the GLNN performance is notably less than GNNs – we hypothesize this is due to Arxiv having a particularly challenging data split which causes distribution shift between test nodes and training
123
+
124
+ Table 4: While other inference acceleration methods speed up SAGE, they are considerably slower than GLNNs. Numbers (in ms) are inductive inference time on 10 randomly chosen nodes.
125
+
126
+ <table><tr><td>Datasets</td><td>SAGE</td><td>QSAGE</td><td>PSAGE</td><td>Neighbor Sample</td><td>GLNN+</td></tr><tr><td>Arxiv</td><td>489.49</td><td>433.90 (1.13x)</td><td>465.43 (1.05x)</td><td>91.03 (5.37x)</td><td>3.34 (146.55x)</td></tr><tr><td>Products</td><td>2071.30</td><td>1946.49 (1.06x)</td><td>2001.46 (1.04x)</td><td>107.71 (19.23x)</td><td>7.56 (273.98x)</td></tr></table>
127
+
128
+ nodes, which is hard for GLNNs to capture without utilizing neighbor information like GNNs.
129
+ However, we note that GLNN performance is substantially improved over MLP.
130
+
131
+ # 5.5 HOW DO GLNNS COMPARE TO OTHER INFERENCE ACCELERATION METHODS?
132
+
133
+ Common techniques of inference acceleration include pruning and quantization. These approaches can reduce model parameters and Multiplication-and-ACcumulation (MACs) operations. Still, they don’t eliminate neighbor-fetching latency. Therefore, their speed gain on GNNs is less significant than on NNs. For GNNs, neighbor sampling is also used to reduce the fetching latency. We show an explicit speed comparison between vanilla SAGE, quantized SAGE from FP32 to INT8 (QSAGE), SAGE with $50 \%$ weights pruned (PSAGE), inference neighbor sampling with fan-out 15, and GLNN in Table 4. With the same setting as Figure 1, we see that GLNN is considerably faster.
134
+
135
+ Two other kinds of methods considered as inference acceleration are GNN-to-GNN KD like TinyGNN (Yan et al., 2020) and Graph Augmented-MLPs (GA-MLPs) like SGC (Wu et al., 2019) or SIGN (Frasca et al., 2020). Inference of GNN-to-GNN KD is likely to be slower than a GNN-Li with the same $i$ as the student, since there will usually be some extra overheads like the Peer-Aware Module (PAM) in TinyGNN. GA-MLPs precompute augmented node features and apply MLPs to them. With precomputation, their inference time will be the same as MLPs for dimension-preserving augmentation (SGC) and the same as enlarged MLPwi for augmentation involves concatenation (SIGN). Thus, for both kinds of approaches, it is sufficient to compare GLNN with GNN-Li and MLPwi, which we have already shown in Figure 3 (left). We see that GNN-Lis are much slower than MLPs. For GA-MLPs, since full pre-computation cannot be done for inductive nodes, GA-MLPs still need to fetch neighbor nodes. This makes them much slower than MLPwi in the inductive setting, and even slower than pruned GNNs and TinyGNN as shown in Zhou et al. (2021).
136
+
137
+ # 5.6 HOW DOES GLNN BENEFIT FROM DISTILLATION?
138
+
139
+ We showed that GNNs are markedly better than MLPs on node classification tasks. But, with KD, GLNNs can often become competitive to GNNs. This indicates that there exist suitable MLP parameters which can well approximate the ideal prediction function from node features to labels. However, these parameters can be difficult to learn through standard stochastic gradient descent. We hypothesize that KD helps to find them through regularization and transfer of inductive bias.
140
+
141
+ First, we show that KD can help to regularize the student model. From loss curves of a directly trained MLP and the GLNN in Figure 4, we see the gap between training and validation loss is visibly larger for MLPs than GLNNs, and MLPs show obvious overfitting trends. Second, we analyze the inductive bias that makes GNNs powerful on node classification, which suggests that node inferences should be influenced by the graph topology. Whereas MLPs have less inductive bias. Similar difference exists between Transformers (Vaswani et al., 2017) and MLPs. Liu et al. (2021) shows that the inductive bias in Transformers can be mitigated by a simple gate on large MLPs. For node classification, we hypothesize that KD helps to mitigate the inductive bias, so GLNNs can perform competitively. Soft labels from GNN teachers are heavily influenced by the graph topology due to inductive bias. They maintain nonzero probabilities on classes other than the ground truth provided by labels, which can be useful for the student to learn to complement the missing inductive bias in MLPs. To evaluate this hypothesis quantitatively, we define the cut loss $\mathcal { L } _ { c u t } \in [ 0 , 1 ]$ in Equation 2 to measure the consistency between model predictions and graph topology (details in Appendix C):
142
+
143
+ $$
144
+ \mathcal { L } _ { c u t } = \frac { T r ( \hat { Y } ^ { T } A \hat { Y } ) } { T r ( \hat { Y } ^ { T } D \hat { Y } ) }
145
+ $$
146
+
147
+ Here $\hat { \pmb { Y } } \in [ 0 , 1 ] ^ { N \times K }$ is the soft classification probability output by the model, $\pmb { A }$ and $_ { D }$ are the adjacency and degree matrices. When $\mathcal { L } _ { c u t }$ is close to $^ { 1 }$ , it means the predictions and the graph topology are very consistent. In our experiment, we observe that the average $\mathcal { L } _ { c u t }$ for SAGE over five CPF datasets is 0.9221, which means high consistency. The same $\mathcal { L } _ { c u t }$ for MLPs is only 0.7644, but for GLNNs it is 0.8986. This shows that the GLNN predictions indeed benefit from the graph topology knowledge contained in the teacher outputs (the full table of $\mathcal { L } _ { c u t }$ values in Appendix C).
148
+
149
+ ![](images/e13d36ad0fd34e672832534415bdedeb0f31097113d6e61931f935801ee4e5d2.jpg)
150
+ Figure 4: Loss curves on CPF datasets show GLNN distillation can help to regularize the training. Here the training loss of GLNN is on hard labels, only corresponding to the first term in Equation 1.
151
+
152
+ # 5.7 DO GLNNS HAVE ENOUGH MODEL EXPRESSIVENESS?
153
+
154
+ Intuitively, the addition of neighbor information makes GNNs more powerful than MLPs when classifying nodes. Thus, a natural question regarding KD from GNNs to MLPs is whether MLPs are expressive enough to represent graph data as well as GNNs. Many recent works studied GNN model expressiveness (Xu et al., 2018; Chen et al., 2021). The latter analyzed GNNs and GA-MLPs for node classification and characterized expressiveness as the number of equivalence classes of rooted graphs induced by the model (formal definitions in Appendix D). The conclusion is that GNNs are more powerful than GA-MLPs, but in most real-world cases their expressiveness is indistinguishable.
155
+
156
+ We adopt the analysis framework from Chen et al. (2021) and show in Appendix D that the number of equivalence classes induced by GNNs and MLPs are |X |+m−2m−1 2L−1 a nd $| \mathcal { X } |$ respectively. Here $m$ denotes the max node degree, $L$ denotes the number of GNN layers, and $\mathcal { X }$ denotes the set of all possible node features. The former is apparently larger which concludes that GNNs are more expressive. Empirically, however, the gap makes little difference when $| \mathcal { X } |$ is large. In real applications, node features can be high dimensional like bag-of-words, or even word embeddings, thus making $| \mathcal { X } |$ enormous. Like for bag-of-words, $| \mathcal { X } |$ is in the order of $\mathcal { O } ( p ^ { D } )$ , where $D$ is the vocabulary size, and $p$ is the max word frequency. The expressiveness of a L-layer GNN is lower bounded by |X |+m−22L−1 $\left( \stackrel { | \mathcal { X } | + m - 2 } { m - 1 } \right) ^ { 2 ^ { L } - 1 } = \mathcal { O } ( p ^ { D ( m - 1 ) ( 2 ^ { L } - 1 ) } )$ , but empirically, both MLPs and GNNs should have enough expressiveness given $D$ is usually hundreds or bigger (see Table 5).
157
+
158
+ # 5.8 WHEN WILL GLNNS FAIL TO WORK?
159
+
160
+ As discussed in Section 5.7 and Appendix D, the goal of GML node classification is to fit a function $f$ on the rooted graph $\mathcal { G } ^ { [ i ] }$ and label $\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 }$ . From the information theoretic perspective, fitting $f$ by minimizing the commonly used cross-entropy loss is equivalent to maximizing the mutual information (MI), $I ( \mathcal G ^ { [ i ] } ; \boldsymbol y _ { i } )$ as shown in Qin et al. (2020). If we consider $\mathcal { G } ^ { [ i ] }$ as a joint distribution of two random variables $X ^ { [ i ] }$ and ${ \mathcal { E } } ^ { [ i ] }$ representing the node features and edges in $\mathcal { G } ^ { [ i ] }$ respectively, we have
161
+
162
+ $$
163
+ I ( \mathcal { G } ^ { [ i ] } ; \pmb { y } _ { i } ) = I ( \pmb { X } ^ { [ i ] } , \pmb { \mathcal { E } } ^ { [ i ] } ; \pmb { y } _ { i } ) = I ( \pmb { \mathcal { E } } ^ { [ i ] } ; \pmb { y } _ { i } ) + I ( \pmb { X } ^ { [ i ] } ; \pmb { y } _ { i } | \pmb { \mathcal { E } } ^ { [ i ] } )
164
+ $$
165
+
166
+ $I ( \mathcal { E } ^ { [ i ] } ; y _ { i } )$ only depends on edges and labels, thus MLPs can only maximize $I ( X ^ { [ i ] } ; y _ { i } | \mathcal { E } ^ { [ i ] } )$ . In the extreme case, $I ( X ^ { [ i ] } ; y _ { i } | \mathcal { E } ^ { [ i ] } )$ can be zero when $y ^ { [ i ] }$ is conditionally independent from $X ^ { [ i ] }$ given $\mathcal { E } ^ { [ i ] }$ . For example, when every node is labeled by its degree or whether it forms a triangle. Then MLPs won’t be able to fit meaningful functions, and neither will GLNNs. However, such cases are typically rare, and unexpected in practical settings our work is mainly concerned with. For real GML tasks, node features and structural roles are often highly correlated (Lerique et al., 2020), hence MLPs can achieve reasonable results even only based on node features, and thus GLNNs can potentially achieve much better results. We study the failure case of GLNNs by creating a low MI scenario in Section 6.
167
+
168
+ ![](images/5b5ba4cf66e93dda6d93901e3acfc6306b2eb1a932c1b44ff6ba4c6b436be96e.jpg)
169
+ Figure 5: Left: Node feature noise. GLNN has comparable performance to GNNs only when nodes are less noisy. Adding more noise decreases GLNN performance faster than GNNs. Middle: Inductive split rate. Altering the inductive:transductive ratio in the production setting doesn’t affect the accuracy much. Right: Teacher GNN architecture. GLNNs can learn from different GNN teachers to improve over MLPs and achieve comparable results. Accuracies are averaged over five CPF datasets.
170
+
171
+ # 6 ABLATION STUDIES
172
+
173
+ In this section, we do ablation studies of GLNNs on node feature noise, inductive split rates, and teacher GNN architecture. Reported results are test accuracies averaged over five datasets in CPF. More experiments can be found in Appendix including advanced GNN teachers (Appendix F), GA-MLP student (Appendix G), and non-homogeneous data (Appendix I).
174
+
175
+ Noisy node features. Following Section 5.8, we investigate failure cases of GLNN by adding different levels of Gaussian noise to node features to decrease their mutual information with labels. Specifically, we replace $\boldsymbol { X }$ with $\tilde { \cal X } = ( 1 - \alpha ) { \cal X } + \alpha \epsilon$ . $\epsilon$ is an isotropic Gaussian independent from $\boldsymbol { X }$ , and $\alpha \in [ 0 , 1 ]$ denotes the noise level. We show the inductive performance of MLP, GNN, and GLNN under different noise levels in Figure 5 (left). We see that as $\alpha$ increases, the accuracy of MLPs and GLNNs decrease faster than GNNs, while the performance of GLNNs and GNNs are still comparable for small $\alpha \mathbf { s }$ . When $\alpha$ reaches 1, $\tilde { X }$ and $\mathbf { Y }$ will become independent corresponding to the extreme case discussed in Section 5.8. A more detailed discussion is in Appendix J.
176
+
177
+ Inductive split rate. In Section 5.4, we use a 20-80 split of the test data for inductive evaluation. In Figure 5 (middle), we show the results under different split rates (More detailed plots in Appendix H). We see that as the inductive portion increase, GNN and MLP performance stays roughly the same, and the GLNN inductive performance drops slightly. We only consider rates up to 50-50 since having $50 \%$ or even more inductive nodes is highly atypical in practice. When a large amount of new data are encountered, practitioners can opt to retrain the model on all the data before deployment.
178
+
179
+ Teacher GNN architecture. We used SAGE to represent GNNs so far. In Figure 5 (right), we show results with other various GNN teachers, e.g. GCN, GAT, and APPNP. We see that GLNNs can learn from different teachers and improve over MLPs. The performance is similar for all four teachers, with the GLNN distilled from APPNP very slightly worse than others. In fact, a similar phenomenon has been observed in Yang et al. (2021a) as well, i.e. APPNP benefits the student the least. One possible reason is that the first step of APPNP is to utilize the node’s own feature for prediction (prior to propagating over the graph), which is very similar to what the student MLP is doing, and thus provides less additional information to MLPs than other teachers.
180
+
181
+ # 7 CONCLUSION AND FUTURE WORK
182
+
183
+ In this paper, we explored whether we can bridge the best of GNNs and MLPs to achieve accurate and fast GML models for deployment. We found that KD from GNNs to MLPs helps to eliminate inference graph dependency, which results in GLNNs that are $1 4 6 \times - 2 7 3 \times$ faster than GNNs while enjoying competitive performance. We do a comprehensive study of GLNN properties. The promising results on 7 datasets across different domains show that GLNNs can be a handy choice for deploying latencyconstraint models. In our experiments, the current version of GLNNs on the Arxiv dataset doesn’t show competitive inductive performance. More advanced distillation techniques can potentially improve the GLNN performance, and we leave this investigation as future work.
184
+
185
+ # REFERENCES
186
+
187
+ Filippo Maria Bianchi, Daniele Grattarola, and Cesare Alippi. Mincut pooling in graph neural networks. CoRR, abs/1907.00481, 2019. URL http://arxiv.org/abs/1907.00481.
188
+
189
+ Joan Bruna, Wojciech Zaremba, Arthur Szlam, and Yann LeCun. Spectral networks and locally connected networks on graphs, 2014.
190
+
191
+ Jie Chen, Tengfei Ma, and Cao Xiao. FastGCN: Fast learning with graph convolutional networks via importance sampling. In International Conference on Learning Representations, 2018. URL https://openreview.net/forum?id=rytstxWAW.
192
+
193
+ Lei Chen, Zhengdao Chen, and Joan Bruna. On graph neural networks versus graph-augmented {mlp}s. In International Conference on Learning Representations, 2021. URL https:// openreview.net/forum?id=tiqI7w64JG2.
194
+
195
+ Ming Chen, Zhewei Wei, Zengfeng Huang, Bolin Ding, and Yaliang Li. Simple and deep graph convolutional networks. In Hal Daumé III and Aarti Singh (eds.), Proceedings of the 37th International Conference on Machine Learning, volume 119 of Proceedings of Machine Learning Research, pp. 1725–1735. PMLR, 13–18 Jul 2020. URL https://proceedings.mlr.press/v119/ chen20v.html.
196
+
197
+ Yu-Hsin Chen, Joel Emer, and Vivienne Sze. Eyeriss: A spatial architecture for energy-efficient dataflow for convolutional neural networks. In 2016 ACM/IEEE 43rd Annual International Symposium on Computer Architecture (ISCA), pp. 367–379, 2016. doi: 10.1109/ISCA.2016.40.
198
+
199
+ Avery Ching, Sergey Edunov, Maja Kabiljo, Dionysios Logothetis, and Sambavi Muthukrishnan. One trillion edges: Graph processing at facebook-scale. Proceedings of the VLDB Endowment, 8 (12):1804–1815, 2015.
200
+
201
+ Michaël Defferrard, Xavier Bresson, and Pierre Vandergheynst. Convolutional neural networks on graphs with fast localized spectral filtering, 2017.
202
+
203
+ Xiang Deng and Zhongfei Zhang. Graph-free knowledge distillation for graph neural networks, 2021.
204
+
205
+ Inderjit S. Dhillon, Yuqiang Guan, and Brian Kulis. Kernel k-means: Spectral clustering and normalized cuts. In Proceedings of the Tenth ACM SIGKDD International Conference on Knowledge Discovery and Data Mining, KDD $^ { \cdot } { 0 4 }$ , pp. 551–556, New York, NY, USA, 2004. Association for Computing Machinery. ISBN 1581138881. doi: 10.1145/1014052.1014118. URL https://doi.org/10.1145/1014052.1014118.
206
+
207
+ Xiaohan Ding, Xiangyu Zhang, Jungong Han, and Guiguang Ding. Repmlp: Re-parameterizing convolutions into fully-connected layers for image recognition, 2021.
208
+
209
+ Fabrizio Frasca, Emanuele Rossi, Davide Eynard, Ben Chamberlain, Michael Bronstein, and Federico Monti. Sign: Scalable inception graph neural networks, 2020.
210
+
211
+ Paul Graham. Want to start a startup? http://www.paulgraham.com/growth.html, 2012.
212
+
213
+ Suyog Gupta, Ankur Agrawal, Kailash Gopalakrishnan, and Pritish Narayanan. Deep learning with limited numerical precision. In Francis Bach and David Blei (eds.), Proceedings of the 32nd International Conference on Machine Learning, volume 37 of Proceedings of Machine Learning Research, pp. 1737–1746, Lille, France, 07–09 Jul 2015. PMLR. URL https://proceedings.mlr.press/v37/gupta15.html.
214
+
215
+ Will Hamilton, Zhitao Ying, and Jure Leskovec. Inductive representation learning on large graphs. In Advances in neural information processing systems, pp. 1024–1034, 2017.
216
+
217
+ Song Han, Jeff Pool, John Tran, and William J. Dally. Learning both weights and connections for efficient neural networks. In Proceedings of the 28th International Conference on Neural Information Processing Systems - Volume 1, NIPS’15, pp. 1135–1143, Cambridge, MA, USA, 2015. MIT Press.
218
+
219
+ Geoffrey Hinton, Oriol Vinyals, and Jeff Dean. Distilling the knowledge in a neural network, 2015.
220
+
221
+ 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. CoRR, abs/2005.00687, 2020. URL https://arxiv.org/abs/2005.00687.
222
+
223
+ Yang Hu, Haoxuan You, Zhecan Wang, Zhicheng Wang, Erjin Zhou, and Yue Gao. Graph-mlp: Node classification without message passing in graph. CoRR, abs/2106.04051, 2021. URL https://arxiv.org/abs/2106.04051.
224
+
225
+ Qian Huang, Horace He, Abhay Singh, Ser-Nam Lim, and Austin Benson. Combining label propagation and simple models out-performs graph neural networks. In International Conference on Learning Representations, 2021. URL https://openreview.net/forum? id=8E1-f3VhX1o.
226
+
227
+ Sergei Ivanov and Liudmila Prokhorenkova. Boost then convolve: Gradient boosting meets graph neural networks. CoRR, abs/2101.08543, 2021. URL https://arxiv.org/abs/2101. 08543.
228
+
229
+ Zhihao Jia, Sina Lin, Rex Ying, Jiaxuan You, Jure Leskovec, and Alex Aiken. Redundancy-free computation for graph neural networks. In Proceedings of the 26th ACM SIGKDD International Conference on Knowledge Discovery & Data Mining, pp. 997–1005, 2020.
230
+
231
+ Wei Jin, Lingxiao Zhao, Shichang Zhang, Yozen Liu, Jiliang Tang, and Neil Shah. Graph condensation for graph neural networks. In ICLR, 2022.
232
+
233
+ Patrick Judd, Jorge Albericio, Tayler Hetherington, Tor M. Aamodt, Natalie Enright Jerger, and Andreas Moshovos. Proteus: Exploiting numerical precision variability in deep neural networks. In Proceedings of the 2016 International Conference on Supercomputing, pp. 23, 2016.
234
+
235
+ Diederik P. Kingma and Jimmy Ba. Adam: A method for stochastic optimization. In ICLR (Poster), 2015. URL http://arxiv.org/abs/1412.6980.
236
+
237
+ Thomas N Kipf and Max Welling. Semi-supervised classification with graph convolutional networks. arXiv preprint arXiv:1609.02907, 2016.
238
+
239
+ Johannes Klicpera, Aleksandar Bojchevski, and Stephan Günnemann. Predict then propagate: Graph neural networks meet personalized pagerank, 2019.
240
+
241
+ Sébastien Lerique, Jacob Levy Abitbol, and Márton Karsai. Joint embedding of structure and features via graph convolutional networks. Applied Network Science, 5(1):1–24, 2020.
242
+
243
+ Guohao Li, Matthias Muller, Ali Thabet, and Bernard Ghanem. Deepgcns: Can gcns go as deep as cnns? In Proceedings of the IEEE International Conference on Computer Vision, pp. 9267–9276, 2019.
244
+
245
+ Guohao Li, Matthias Müller, Bernard Ghanem, and Vladlen Koltun. Training graph neural networks with 1000 layers. In International Conference on Machine Learning (ICML), 2021.
246
+
247
+ Derek Lim, Xiuyu Li, Felix Hohne, and Ser-Nam Lim. New benchmarks for learning on nonhomophilous graphs. CoRR, abs/2104.01404, 2021. URL https://arxiv.org/abs/2104. 01404.
248
+
249
+ Hanxiao Liu, Zihang Dai, David R. So, and Quoc V. Le. Pay attention to mlps, 2021.
250
+
251
+ Luke Melas-Kyriazi. Do you even need attention? a stack of feed-forward layers does surprisingly well on imagenet, 2021.
252
+
253
+ Zhenyue Qin, Dongwoo Kim, and Tom Gedeon. Rethinking softmax with cross-entropy: Neural network classifier as mutual information estimator, 2020.
254
+
255
+ Shyam Anil Tailor, Javier Fernandez-Marques, and Nicholas Donald Lane. Degree-quant: Quantization-aware training for graph neural networks. In International Conference on Learning Representations, 2021. URL https://openreview.net/forum?id $\bar { }$ NSBrFgJAHg.
256
+
257
+ Ilya Tolstikhin, Neil Houlsby, Alexander Kolesnikov, Lucas Beyer, Xiaohua Zhai, Thomas Unterthiner, Jessica Yung, Daniel Keysers, Jakob Uszkoreit, Mario Lucic, et al. Mlp-mixer: An all-mlp architecture for vision. arXiv preprint arXiv:2105.01601, 2021.
258
+
259
+ Hugo Touvron, Piotr Bojanowski, Mathilde Caron, Matthieu Cord, Alaaeldin El-Nouby, Edouard Grave, Armand Joulin, Gabriel Synnaeve, Jakob Verbeek, and Hervé Jégou. Resmlp: Feedforward networks for image classification with data-efficient training. arXiv preprint arXiv:2105.03404, 2021.
260
+
261
+ Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N. Gomez, Lukasz Kaiser, and Illia Polosukhin. Attention is all you need, 2017.
262
+
263
+ Petar Velickovi ˇ c, Guillem Cucurull, Arantxa Casanova, Adriana Romero, Pietro Lio, and Yoshua ´ Bengio. Graph attention networks. arXiv preprint arXiv:1710.10903, 2017.
264
+
265
+ 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.
266
+
267
+ Tianxin Wei, Ziwei Wu, Ruirui Li, Ziniu Hu, Fuli Feng, Xiangnan He, Yizhou Sun, and Wei Wang. Fast adaptation for cold-start collaborative filtering with meta-learning. In 2020 IEEE International Conference on Data Mining (ICDM), pp. 661–670. IEEE, 2020.
268
+
269
+ Felix Wu, Tianyi Zhang, Amauri Holanda de Souza Jr. au2, Christopher Fifty, Tao Yu, and Kilian Q. Weinberger. Simplifying graph convolutional networks, 2019.
270
+
271
+ Keyulu Xu, Weihua Hu, Jure Leskovec, and Stefanie Jegelka. How powerful are graph neural networks? arXiv preprint arXiv:1810.00826, 2018.
272
+
273
+ Yishi Xu, Yingxue Zhang, Wei Guo, Huifeng Guo, Ruiming Tang, and Mark Coates. Graphsail: Graph structure aware incremental learning for recommender systems. In Proceedings of the 29th ACM International Conference on Information amp; Knowledge Management, CIKM ’20, pp. 2861–2868, New York, NY, USA, 2020. Association for Computing Machinery. ISBN 9781450368599. doi: 10.1145/3340531.3412754. URL https://doi.org/10.1145/ 3340531.3412754.
274
+
275
+ Bencheng Yan, Chaokun Wang, Gaoyang Guo, and Yunkai Lou. Tinygnn: Learning efficient graph neural networks. In Proceedings of the 26th ACM SIGKDD International Conference on Knowledge Discovery &#38; Data Mining (KDD), pp. 1848–1856, 2020.
276
+
277
+ Cheng Yang, Jiawei Liu, and Chuan Shi. Extract the knowledge of graph neural networks and go beyond it: An effective knowledge distillation framework, 2021a.
278
+
279
+ Yiding Yang, Jiayan Qiu, Mingli Song, Dacheng Tao, and Xinchao Wang. Distilling knowledge from graph convolutional networks, 2021b.
280
+
281
+ Dalong Zhang, Xin Huang, Ziqi Liu, Zhiyang Hu, Xianzheng Song, Zhibang Ge, Zhiqiang Zhang, Lin Wang, Jun Zhou, Yang Shuang, et al. Agl: a scalable system for industrial-purpose graph machine learning. arXiv preprint arXiv:2003.02454, 2020.
282
+
283
+ Yiren Zhao, Duo Wang, Daniel Bates, Robert Mullins, Mateja Jamnik, and Pietro Lio. Learned low precision graph neural networks, 2020.
284
+
285
+ Hongkuan Zhou, Ajitesh Srivastava, Hanqing Zeng, Rajgopal Kannan, and Viktor K. Prasanna. Accelerating large scale real-time GNN inference using channel pruning. CoRR, abs/2105.04528, 2021. URL https://arxiv.org/abs/2105.04528.
286
+
287
+ Difan Zou, Ziniu Hu, Yewen Wang, Song Jiang, Yizhou Sun, and Quanquan Gu. Layer-dependent importance sampling for training deep and large graph convolutional networks. arXiv preprint arXiv:1911.07323, 2019.
288
+
289
+ # A DETAILED EXPERIMENT SETTINGS
290
+
291
+ # A.1 DATASETS
292
+
293
+ Here we provide a detailed description of the datasets we used to support our argument. Out of these datasets, 4 of them are citation graphs. Cora, Citeseer, Pubmed, ogbn-arxiv with the node features being descriptions of the papers, either bag-of-word vector, TF-IDF vector, or word embedding vectors.
294
+
295
+ In Table 5, we provided the basic statistics of these datasets.
296
+
297
+ Table 5: Dataset Statistics.
298
+
299
+ <table><tr><td>Dataset</td><td>#Nodes</td><td>#Edges</td><td>#Features</td><td># Classes</td></tr><tr><td>Cora</td><td>2,485</td><td>5,069</td><td>1,433</td><td>7</td></tr><tr><td>Citeseer</td><td>2,110</td><td>3,668</td><td>3,703</td><td>6</td></tr><tr><td>Pubmed</td><td>19,717</td><td>44,324</td><td>500</td><td>3</td></tr><tr><td>A-computer</td><td>13,381</td><td>245,778</td><td>767</td><td>10</td></tr><tr><td>A-photo</td><td>7,487</td><td>119,043</td><td>745</td><td>8</td></tr><tr><td>Arxiv</td><td>169,343</td><td>1,166,243</td><td>128</td><td>40</td></tr><tr><td>Products</td><td>2,449,029</td><td>61,859,140</td><td>100</td><td>47</td></tr></table>
300
+
301
+ For all datasets, we follow the setting in the original paper to split the data. Specifically, for the five smaller datasets from the CPF paper, we use the CPF splitting strategy and each random seed corresponds to a different split. For the OGB datasets, we follow the OGB official splits based on time and popularity for Arxiv and Products respectively.
302
+
303
+ # A.2 MODEL HYPERPARAMETERS
304
+
305
+ The hyperparameters of GNN models on each dataset are taken from the best hyperparameters provided by the CPF paper and the OGB official examples. For the student MLPs and GLNN s, unless otherwise specified with -wi or $- \mathbf { L } i$ , we set the number of layers and the hidden dimension of each layer to be the same as the teacher GNN, so their total number of parameters stays the same as the teacher GNN.
306
+
307
+ Table 6: Hyperparameters for GNNs on five datasets from the CPF paper.
308
+
309
+ <table><tr><td></td><td>SAGE</td><td>GCN</td><td>GAT</td><td>APPNP</td></tr><tr><td>#layers</td><td>2</td><td>2</td><td>2</td><td>2</td></tr><tr><td>hidden dim</td><td>128</td><td>64</td><td>64</td><td>64</td></tr><tr><td>learning rate</td><td>0.01</td><td>0.01</td><td>0.01</td><td>0.01</td></tr><tr><td>weight decay</td><td>0.0005</td><td>0.001</td><td>0.01</td><td>0.01</td></tr><tr><td>dropout</td><td>0</td><td>0.8</td><td>0.6</td><td>0.5</td></tr><tr><td>fan out</td><td>5,5</td><td>1</td><td>1</td><td>-</td></tr><tr><td>attention heads</td><td>1</td><td>=</td><td>8</td><td>1</td></tr><tr><td>power iterations</td><td>1</td><td>=</td><td>1</td><td>10</td></tr></table>
310
+
311
+ Table 7: Hyperparameters for GraphSAGE on OGB datasets.
312
+
313
+ <table><tr><td>Dataset</td><td>Arxiv</td><td>Products</td></tr><tr><td># layers</td><td>3</td><td>3</td></tr><tr><td>hidden dim</td><td>256</td><td>256</td></tr><tr><td>learning rate</td><td>0.01</td><td>0.003</td></tr><tr><td>weight decay</td><td>0</td><td>0</td></tr><tr><td>dropout</td><td>0.2</td><td>0.5</td></tr><tr><td>normalization</td><td>batch</td><td>batch</td></tr><tr><td>fan out</td><td>[5,10,15]</td><td>[5,10,15]</td></tr></table>
314
+
315
+ For GLNN s we do a hyperparameter search of learning rate from [0.01, 0.005, 0.001], weight decay from [0, 0.001, 0.002, 0.005, 0.01], and dropout from [0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6]
316
+
317
+ # A.3 KNOWLEDGE DISTILLATION
318
+
319
+ We use the distillation method proposed in Hinton et al. (2015) as in Equation 1, the hard labels are found to be helpful, so nonzero $\lambda s$ was suggested. In our case, we did a little tuning for $\lambda$ but didn’t find nonzero $\lambda s$ to be very helpful. Therefore, we report all of our results with $\lambda = 0$ , i.e. only the second term involving soft labels is effective. More careful tuning of $\lambda$ should further improve the results since the searching space is strictly larger. We implemented a weighted version in our code, and we leave the choice of $\lambda$ as future work.
320
+
321
+ # A.4 THE TRANSDUCTIVE SETTING AND THE INDUCTIVE SETTING
322
+
323
+ Given ${ \mathcal { G } } , X$ , and $Y ^ { L }$ , the goal of node classification can be divided into two different settings, i.e. transductive and inductive. In real applications, the former can correspond to predict missing attributes of a user based on the user profile and other existing users, and the latter can correspond to predict labels of some new nodes that are only seen during inference time. To create the inductive setting on a given dataset, we hold out some nodes along with edges connected to these nodes during data. Using notation defined above, we pick the inductive nodes training and use them for inductive evaluation only. These nodes and edges are picked from the test $\mathcal { V } _ { i n d } ^ { U } \subset \mathcal { V } ^ { U }$ , which partitions $\mathcal { V } ^ { U }$ into the disjoint inductive subset and observed subset, i.e. $\mathcal { V } ^ { U } = \mathcal { V } _ { o b s } ^ { U } \sqcup \mathcal { V } _ { i n d } ^ { U }$ V ind . Then we can take , $\mathcal { V } _ { i n d } ^ { U }$ furth, and raph, so we end up with. We show the input and $\mathcal { G } = \mathcal { G } _ { o b s } \sqcup \mathcal { G } _ { i n d }$ $\pmb { X } = \pmb { X } ^ { L } \sqcup \pmb { X } _ { o b s } ^ { U } \sqcup \overbrace { \pmb { X } _ { i n d } ^ { U } }$ $\pmb { Y } = \pmb { Y } ^ { L } \sqcup \pmb { Y } _ { o b s } ^ { U } \sqcup \pmb { Y } _ { i n d } ^ { U }$ output of both settings using the notations below.
324
+
325
+ We visualize the difference between the inductive setting and the transductive setting in Figure 6.
326
+
327
+ ![](images/2a239fb19d94400d2ccb7f18def7895440e8208ed97573eb1cf684c4025f00ac.jpg)
328
+ Figure 6: The transductive setting and inductive setting illustrated by a 2-layer GNN. The middle shows the original graph used for training. The left shows the transductive setting, where the test node is in red and within the graph. The right shows the inductive setting, where the test node is an unseen new node.
329
+
330
+ # A.5 CHOOSING SOFT TARGETS UNDER THE TRANSDUCTIVE SETTING
331
+
332
+ For the transductive setting in Section 5.3, all the nodes in the graph, including the validation and test nodes, are used for the soft target generation. It seems less practical compared to the inductive case, but it is a necessary step to develop our argument. We now discuss the rationale behind this choice.
333
+
334
+ Firstly, the transductive setting is the most common setting for graph data and it was used in most GNN architecture works and GNN acceleration works we mentioned in related work. Therefore, to avoid any confusion and for a fair comparison with numbers from previous literature, we start our experiments with exactly the same input and output as the standard transductive setting. Under this setting, the inputs to GNNs include all the node features and the graph structure, so GLNN is set to be able to access the same input. As GLNN includes a teacher training step and a distillation step, the soft labels of all the nodes are intermediate outputs produced by the teacher training step, and thus used for the second distillation step for the best GLNN performance. This transductive setting can boil down to a sanity check when the student is sufficiently large. Therefore, we separate the setting to be GLNN and $\mathsf { G L N N + }$ and report the results in Table 1 and Table 2 separately. In Table 1, we are checking how well GLNNs can perform compared to GNNs under the equal-parameter constraint. The results can be interpreted as given a fixed parameter budget, whether there exists one set of parameters (one instantiation of the MLP) that can achieve competitive results as the GNN. Only when this holds, should we further investigate the more interesting and challenging inductive case as in Section 5.4.
335
+
336
+ Secondly, the task we focus on is node classification, which in many cases is considered as semisupervised learning with very scarce labels. For example, Pubmed only uses 60 labeled nodes (20 per class) out of 20K nodes for training. Rather than design an advanced model that can do few-shot learning, our goal here is to leverage as much data as possible to simplify the model for more efficient inference. We thus utilize the soft pseudo-labels on all the unlabelled nodes for the best GLNN performance. In reality, when there is a large amount of separate unlabeled data, these unlabeled data can be used for GLNN distillation training and a different set of labeled data can be used for evaluation. In our case, we mimic this scenario in the inductive setting in Section 5.4.
337
+
338
+ # A.6 IMPLEMENTATION AND HARDWARD DETAILS
339
+
340
+ The experiments on both baselines and our approach are implemented using PyTorch, the DGL (Wang et al., 2019) library for GNN algorithms, and Adam (Kingma & Ba, 2015) for optimization. We run all experiments on a machine with 80 Intel(R) Xeon(R) E5-2698 v4 $@$ 2.20GHz CPUs, and a single NVIDIA V100 GPU with 16GB RAM.
341
+
342
+ # B SPACE AND TIME COMPLEXITY OF GNNS VS. MLPS
343
+
344
+ Compared to MLP and GNN, GLNN provides a handy tool for users to trade-off between model accuracy and time complexity, which does not directly focus on space complexity. Given the space and time complexity are related, we now provide a more detailed discussion regarding these two complexities in our experiments.
345
+
346
+ In Table 1, the model comparison was between equal-sized MLPs (GLNNs) and GNNs. While fixing parameter budget to control space complexity is a standard approach when comparing models, it is not completely fair for cross-model comparison especially for MLPs vs. GNNs. To do inference with GNNs, the graph needs to be loaded in the memory either entirely or batch by batch, and may use much larger space than the model parameters. Thus, the actual space complexity of GNNs is much higher than equal-sized MLPs. From the time complexity perspective, the major inference latency of GNNs comes from the data dependency as shown in Section 4. Under the same setting as Figure 1, we show in Figure 3 Left that even a 5-layer MLP with 8 times wider hidden layers still runs much faster than a single-layer SAGE. Another example of cross-model comparison is Transformers vs. RNNs. Large Transformers can have more parameters than RNNs because of the attention mechanism, but they are also faster than RNNs in general, which is an important consideration in the context of inference time minimization.
347
+
348
+ In Table 1, we saw that for equal-sized comparison, GLNNs are not as accurate as GNNs on the OGB datasets. Following the discussion above and given the GLNNs used in Table 1 are relatively small (3 layers and 256 hidden dimensions) for millions of nodes in the OGB datasets, we ask whether this gap can be mitigated by increasing the MLP and thus GLNN sizes. The answer is yes as shown in Table 2.
349
+
350
+ # C CONSISTENCY MEASURE OF MODEL PREDICTIONS AND GRAPH TOPOLOGY BASED ON MIN-CUT
351
+
352
+ We introduce a metric to measure the consistency between model predictions and graph topology based on the min-cut problem in Section 5.6. The $K$ -way normalized min-cut problem, or simply min-cut, partitions $N$ nodes in $\nu$ into $K$ disjoint subsets by removing the minimum volume of edges. According to Dhillon et al. (2004), the min-cut problem can be expressed as
353
+
354
+ $$
355
+ \operatorname* { m a x } \frac { 1 } { K } \sum _ { k = 1 } ^ { K } \frac { C _ { k } ^ { T } A C _ { k } } { C _ { k } ^ { T } D C _ { k } }
356
+ $$
357
+
358
+ with $C$ being the node assignment matrix that partitions $\nu$ , i.e. $C _ { i , j } = 1$ if node $i$ is assigned to class $j$ . $\pmb { A }$ being the adjacency matrix and $_ { D }$ being the degree matrix. This quantity we try to maximize here tells us whether the assignment is consistent with the graph topology. The bigger it is, the less edges need to be removed, and the assignment is more consistent with existing connections in the graph. In Bianchi et al. (2019), the authors show that when replacing the hard assignments $C \in \{ 0 , 1 \} ^ { N \times K }$ with a soft classification probability $\hat { \pmb Y } \in [ 0 , 1 ] ^ { N \times K }$ , a cut loss $\mathcal { L } _ { c u t }$ in Equation 2 can become a good approximation of Equation 4 and be used as the measuring metric.
359
+
360
+ Table 8: GLNN predictions are much more consistent with the graph topology than MLPs. We show the $\mathcal { L } _ { c u t }$ values of GNNs, MLPs, and GLNN s on five CPF datasets. GLNN $\mathcal { L } _ { c u t }$ values become pretty close to the high $\mathcal { L } _ { c u t }$ values of GNNs, which were closely related to the GNN inductive bias.
361
+
362
+ <table><tr><td>Datasets</td><td>SAGE</td><td>MLP</td><td>GLNN</td></tr><tr><td>Cora</td><td>0.9347</td><td>0.7026</td><td>0.8852</td></tr><tr><td>Citeseer</td><td>0.9485</td><td>0.7693</td><td>0.9339</td></tr><tr><td>Pubmed</td><td>0.9605</td><td>0.9455</td><td>0.9701</td></tr><tr><td>A-computer</td><td>0.9003</td><td>0.6976</td><td>0.8638</td></tr><tr><td>A-photo</td><td>0.8664</td><td>0.7069</td><td>0.8398</td></tr><tr><td>Average</td><td>0.9221</td><td>0.7644</td><td>0.8986</td></tr></table>
363
+
364
+ # D EXPRESSIVENESS OF GNNS VS. MLPS IN TERMS OF EQUIVALENCE CLASSES OF ROOTED GRAPHS
365
+
366
+ In Chen et al. (2021), the expressiveness of GNNs and GA-MLPs were theoretically quantified in terms of induced equivalence classes of rooted graphs. We adopt their framework and perform a similar analysis for GNNs vs. MLPs. We first define rooted graphs.
367
+
368
+ Definition 1 (Rooted Graph). A rooted graph, denoted as $\mathcal { G } ^ { [ i ] }$ is a graph with one node i in $\mathcal { G } ^ { [ i ] }$ designated as the root. GNNs, GA-MLPs, and MLPs can all be considered as functions on rooted graphs. The goal of a node-level task on node $i$ with label $\mathbf { \nabla } _ { \mathbf { \psi } _ { 3 } } \psi _ { i }$ is to fit a function to the input-output pairs $( \mathcal G ^ { [ i ] } , y _ { i } )$ .
369
+
370
+ We denote the space of rooted graphs as $\mathcal { E }$ . Following Chen et al. (2021), the expressive power of a model on graph data is evaluated by its ability to approximate functions on $\mathcal { E }$ . This is further characterized as the number of induced equivalence classes of rooted graphs on $\mathcal { E }$ , with the equivalence relation defined as the following. Given a family of functions $\mathcal { F }$ on $\mathcal { E }$ , we define an equivalence relation $\simeq _ { \varepsilon , F }$ among all rooted graphs such that $\forall \mathcal { G } ^ { [ i ] } , \mathcal { G } ^ { \prime [ j ] } \in \mathcal { E } , \mathcal { G } ^ { [ i ] } \simeq _ { \mathcal { E } , \mathcal { F } } \mathcal { G } ^ { \prime [ j ] }$ if and only if $\forall f \in \mathcal { F } , f ( \mathcal { G } ^ { [ i ] } ) = f ( \mathcal { G } ^ { \prime [ j ] } )$ . We now give a proposition to characterize the GNN expressive power (proof in Appendix E).
371
+
372
+ Proposition 1. With $\mathcal { X }$ denotes the set of all possible node features and assuming $| \mathcal { X } | \ge 2$ , with $m$ denotes the maximum node degree and assuming $m \geq 3$ , the total number of equivalence classes of rooted graphs induced by an $L$ -layer GNN is lower bounded by $\binom { | \mathcal { X } | + m - 2 } { m - 1 } ^ { 2 ^ { L } - 1 }$
373
+
374
+ As shown in Proposition 1, the expressive power of GNNs grows doubly-exponentially in the number of layers $L$ , which means it grows linearly in $L$ after taking $\log ( \log ( \cdot ) )$ . The expressive power GA-MLPs only grows exponentially in $L$ as shown in Chen et al. (2021). Under this framework, the expressive power of MLPs, which corresponds to a 0-layer GA-MLP, is $| \mathcal { X } |$ . Since the former is much larger than the latter, the conclusion will be GNNs are much more expressive than MLPs. The gap between these two numbers indeed exists, but empirically this gap will only make a difference when $| \mathcal { X } |$ is small. As in Chen et al. (2021), both the lower bound proof and the constructed examples showing GNNs are more powerful than GA-MLPs assumed $| \mathcal { X } | = 2$ . In real applications and datasets considered in this work, the node features can be high dimensional vectors like bag-of-words, which makes $| \mathcal { X } |$ enormous. Thus, this gap doesn’t matter much empirically.
375
+
376
+ # E PROOF OF THE PROPOSITION 1
377
+
378
+ To prove Proposition 1, we first define rooted aggregation trees, which is similar to but different from rooted graphs.
379
+
380
+ Definition 2 (Rooted Aggregation Tree). The depth-K rooted aggregation tree of a rooted graph $\mathcal { G } ^ { [ i ] }$ is a depth-K rooted tree with $a$ (possibly many-to-one) mapping from every node in the tree to some node in $\mathcal { G } ^ { [ i ] }$ , where (i) the root of the tree is mapped to node $i$ , and (ii) the children of every node $j$ in the tree are mapped to the neighbors of the node in $\mathcal { G } ^ { [ i ] }$ to which $j$ is mapped.
381
+
382
+ A rooted aggregation tree can be obtained by unrolling the neighborhood aggregation steps in the GNNs. An illustration of rooted graphs and rooted aggregation trees can be found in Chen et al. (2021) Figure 4. We denote the set of all rooted aggregation trees of depth $\mathrm { L }$ using $\mathcal { T } _ { L }$ . Then we use $\mathcal { T } _ { L , \mathcal { X } , m }$ to denote a subset of $\mathcal { T } _ { L }$ , where the node features belong to $\mathcal { X }$ , and all the nodes have exactly degree $m$ ( $m$ children), and at least two nodes out of these m nodes have different features. In other words, a node can’t have all identical children. With rooted aggregation trees defined, we are ready to prove Proposition 1. The proof is adapted from the proof of Lemma 3 in Chen et al. (2021).
383
+
384
+ Proof. Since the number of equivalence classes on $\mathcal { E }$ induced by the family of all depth-L GNNs consists of all rooted graphs that share the same rooted aggregation tree of depth- $\mathrm { . L }$ (Chen et al., 2021), the lower bound problem in Proposition 1 can be reduced to lower bound $| \mathcal { T } _ { L } |$ , which can be further reduced to lower bound the subset $| \mathcal { T } _ { L , \mathcal { X } , m } |$ . We now show $\begin{array} { r } { | \mathcal { T } _ { L , \mathcal { X } , m } | \geq \binom { | \mathcal { X } | + m - 2 } { m - 1 } ^ { 2 ^ { L } - 1 } } \end{array}$ inductively.
385
+
386
+ When $L = 1$ , the root of the tree can have $| \mathcal { X } |$ different choices. For the children nodes, we $m$ $| \mathcal { X } |$ are allowed. This leads to . $\binom { | x | + m - 1 } { m }$ cases. Therefore, $\mathcal { T } _ { L + 1 , \mathcal { X } , m } = | \mathcal { X } | \binom { | \mathcal { X } | + m - 1 } { m } \ge \binom { | \mathcal { X } | + m - 2 } { m - 1 }$
387
+
388
+ Assuming the statement holds for $L$ , we show it holds for $L + 1$ by constructing trees in $\tau _ { L + 1 , x , m }$ from $T , T ^ { \prime } \in \mathcal { T } _ { L , x , m }$ . We do this by assigning node features in $\mathcal { X }$ to the $m$ children of each leaf node in $T$ and $T ^ { \prime }$ . First note that when $T$ and $T ^ { \prime }$ are two non-isomorphic trees, two depth- $\mathrm { . L } { + } 1$ trees constructed from $T$ and $T ^ { \prime }$ will be different no matter how the node features are assigned. Now we consider all the trees can be constructed from $T$ by assign node features of children to leaf nodes.
389
+
390
+ We first consider all paths from the root to leaves in $T$ . Each path consists of a sequence of nodes where the node features form a one-to-one mapping to an $\mathrm { L }$ -tuple $\tau \in \{ ( x _ { 1 } , \ldots , x _ { L } ) : x _ { i } \in \mathcal { X } \}$ . Leaf nodes are called node under $\tau$ if the path from the root to it corresponds to $\tau$ . The children of nodes under different $\tau \mathbf { S }$ are always distinguishable, and thus any assignments lead to distinct rooted aggregation trees of depth $L + 1$ . The assignment of children of nodes under the same $\tau$ , on the other hand, could be overcounted. Therefore, to lower bound $\tau _ { L + 1 , \mathcal { X } , m }$ , we only consider a special way of assignments to avoid over counting, which is that children of all nodes under the same $\tau$ are assigned the same set of features.
391
+
392
+ Since we assumed that at least two nodes of $T$ have different features, there are at least $2 ^ { L }$ different $\tau \mathbf { S }$ corresponding to the path from the root to leaves. For a leaf node $j$ under a fixed $\tau$ , one of its children needs to have the same feature as $j$ ’s parent node. This restriction is due to the definition of rooted aggregation trees. Therefore, we only pick features for the other $m - 1$ nodes, which will be $\binom { | \mathcal { X } | + m - 2 } { m - 1 }$ cases for each $j$ . Then through this construction, the total number of depth- $\mathrm { . L } { + } 1$ trees from T can be lower bounded by |X |+m−2m−1 2L. $T \in \mathcal { T } _ { L , \mathcal { X } , m }$ , so we derive $\begin{array} { r } { \mathcal { T } _ { L + 1 , \mathcal { X } , m } \geq \binom { | \mathcal { X } | + m - 2 } { m - 1 } ^ { 2 ^ { L } } \mathcal { T } _ { L , \mathcal { X } , m } } \end{array}$ hav, and $\begin{array} { r } { \mathcal { T } _ { L , \mathcal { X } , m } \geq \binom { | \mathcal { X } | + m - 2 } { m - 1 } ^ { \sum _ { l = 1 } ^ { L } 2 ^ { l } } = } \end{array}$ $\binom { | \mathcal { X } | + m - 2 } { m - 1 } ^ { 2 ^ { L } - 1 }$
393
+
394
+ # F ADVANCED GNN ARCHITECTURES AS THE TEACHER
395
+
396
+ In our experiment, SAGE teacher is used throughout to avoid influence by model architecture. Some other GNNs like GCN are also considered in the ablation studies, but they are not the best known architecture for a specific dataset. To show GLNN has stronger performance given a stronger teacher, we consider the best teacher we can access on Products. We take $\mathrm { M L P { + } C S }$ Huang et al. (2021) from the OGB leaderboard as a new teacher, which has reported accuracy $8 4 . 1 8 \%$ and ranks 8 on the leadarboard as of Nov 2021. We choose $_ { \mathrm { M L P + C S } }$ instead of the other top 7 because the others either rely on raw text (additional info to the given node feature), or require a large GPU with ${ > } 1 6 \mathrm { G B }$ memory, which we don’t have access to. Also, their improvement is not super significant compared to $\mathrm { M L P { + } C S }$ , i.e. $84 \%$ to $86 \%$ . The result with $\mathrm { M L P { + } C S }$ teacher is shown in Table 9. We see that with the new teacher, performance of ${ \mathrm { G L N N } } +$ improves to be even better than SAGE $( 7 8 . 6 1 \% )$ , which shows GLNN can get stronger given a stronger teacher.
397
+
398
+ Table 9: ${ \mathrm { G L N N } } +$ with $\mathrm { M L P { + } C S }$ teacher on Products
399
+
400
+ <table><tr><td></td><td>MLP+C&amp;S</td><td>MLP+</td><td>GLNN+</td></tr><tr><td>Acc</td><td>84.18</td><td>64.50</td><td>82.94</td></tr></table>
401
+
402
+ # G GLNN WITH FEATURE AUGMENTATION FROM ONE-HOP NEIGHBORS
403
+
404
+ In our main experiment, the inductive performance of GLNN on the Arxiv dataset is less desirable than others. We thus consider augment the node features with their one-hop neighbors to include more graph information. This can be seen as a middle ground between pure GLNNs and GNNs. For this new experiment, we follow the setting in Table 3 but with two new approaches. We explain the setting of these two approaches below.
405
+
406
+ 1. 1-hop GA-MLP: firstly, for each node $v$ , we collect features of its 1-hop neighbors $u$ to augment the raw feature of $v$ , i.e. $x _ { v } \tilde { x } _ { v }$ , like in SGC. Then we train an MLP on the graph with $\tilde { x } _ { v }$ . Note if $v$ is in the observed graph but $u$ is in the inductive (unobserved during training) part, then $v$ doesn’t collect features from $u$ .
407
+
408
+ 2. 1-hop GA-GLNN: Go through the same feature augmentation step as 1-hop GA-MLP. Then train an MLP with distillation from teacher GNN.
409
+
410
+ 3. In summary, we compare 5 different models in the table below
411
+
412
+ (a) SAGE: single model on $x _ { v }$
413
+ (b) MLP: single model on $x _ { v }$
414
+ (c) GLNN: SAGE teacher and MLP student on $x _ { v }$
415
+ (d) 1-hop GA-MLP: single model on $\tilde { x } _ { v }$
416
+ (e) 1-hop GA-GLNN: SAGE teacher on $x _ { v }$ , MLP student on $\tilde { x } _ { v }$
417
+
418
+ We show in the table below, with 1-hop neighbor features, performance of GLNN improves a lot. This is expected as we also observe significant improvement from MLP to 1-hop GA-MLP. However, we indeed see 1-hop GA-GLNN (68.83) can further improve from 1-hop GA-MLP (66.62) and nearly match the teacher (70.64).
419
+
420
+ Table 10: GLNN with feature augmentation from one-hop neighbor on Arxiv
421
+
422
+ <table><tr><td></td><td>Eval</td><td>SAGE</td><td>MLP</td><td>GLNN</td><td>1-hop GA-MLP</td><td>1-hop GA-GLNN</td></tr><tr><td>Arxiv</td><td>ind</td><td>70.64</td><td>55.40</td><td>60.48</td><td>66.62</td><td>68.83</td></tr><tr><td></td><td>tran</td><td>70.75</td><td>55.28</td><td>71.46</td><td>66.67</td><td>69.82</td></tr></table>
423
+
424
+ As we have shown in Figure 3, the 1-Layer GNN in our case is roughly 4 times slower than GLNN (29.31ms vs. $7 . 5 6 \mathrm { m s } ,$ ), which should be a good approximation for the speed comparison between 1-hop GA-MLP/GA-GLNN and GLNN. This result is practically beneficial, as it gives practitioners more flexibility about how much accuracy they want to trade for less inference time.
425
+
426
+ This section is a continuation of the ablation study of inductive split rate in Section 6. It generalizes Figure 5 Middle to more split rates (from 10:90 to 90:10), and explicitly show the inductive and transductive performance on each dataset. For better visualization, the training data label rate is also reduced from 20 per class to 5 per class in the following plots.
427
+
428
+ ![](images/46024ef2ae15c38b05bcf61172d3fc0a7188e2c13b24b720ed673291135bb45b.jpg)
429
+ Figure 7: Model inductive performance comparison between MLP, GNN(SAGE), and GLNN under different inductive split rate in the production setting.
430
+
431
+ ![](images/f66528cb30229f3d636a468c436934c7c9c543d8c492f108574b73bb3899b35d.jpg)
432
+ Figure 8: Model transductive performance comparison between MLP, GNN(SAGE), and GLNN under different inductive split rate in the production setting.
433
+
434
+ # I GLNN UNDER NODE FEATURE HETEROGENEITY AND NON-HOMOPHILY
435
+
436
+ Besides the 7 datasets used in the main experiments, we consider 4 more datasets from Ivanov & Prokhorenkova (2021) and Lim et al. (2021) to further evaluate GLNN.
437
+
438
+ The House_class and VK_class datasets are from Ivanov & Prokhorenkova (2021). The node features of these two graphs are based on tabular data, which have different types, scales, and meanings as the opposite of the bag-of-word node features in Cora and etc. Some basic statistics of the datasets are shown in the following table.
439
+
440
+ Table 11: Statistics of dataset with heterogeneous node features
441
+
442
+ <table><tr><td>Dataset</td><td># Nodes</td><td>#Edges</td><td># Features</td><td>#Classes</td></tr><tr><td>House_class</td><td>20,640</td><td>182,146</td><td>6</td><td>5</td></tr><tr><td>VK_class</td><td>54,028</td><td>213,644</td><td>14</td><td>7</td></tr></table>
443
+
444
+ We apply the GLNN on House_class and VK_class using the best BGNN model from Ivanov & Prokhorenkova (2021) as the teacher. The comparison is shown in the following table. Ivanov & Prokhorenkova (2021) also includes GAT, GCN, AGNN, and APPNP as baselines, whose performance on these two datasets are quite similar (difference $< 0 . 0 2 5$ ). We compare with these baselines by including the best result among the 4 GNN models and refer it as GNN in the table below, i.e. GNN $=$ max(GAT, GCN, AGNN, APPNP). From the table, we see that GLNN can improve from MLP, outperform GNN and LightGBM, and become competitive to the teacher BGNN.
445
+
446
+ Table 12: GLNN on datasets with heterogeneous node features. Numbers other than GLNN are taken from Ivanov & Prokhorenkova (2021)
447
+
448
+ <table><tr><td>Dataset</td><td>LightGBM</td><td>GNNs</td><td>BGNN</td><td>MLP</td><td>GLNN</td></tr><tr><td>House_class</td><td>0.55</td><td>0.625</td><td>0.682</td><td>0.534</td><td>0.672</td></tr><tr><td>VK_class</td><td>0.57</td><td>0.577</td><td>0.683</td><td>0.567</td><td>0.641</td></tr></table>
449
+
450
+ We further pick the non-homophilous Penn94 and Pokec datasets from Lim et al. (2021). Some basic statistics of the datasets are shown in the following table.
451
+
452
+ Table 13: Statistics of non-homophilous datasets
453
+
454
+ <table><tr><td>Dataset</td><td># Nodes</td><td>#Edges</td><td># Features</td><td># Classes</td></tr><tr><td>Penn94</td><td>41,536</td><td>1,590,655</td><td>5</td><td>2</td></tr><tr><td>Pokec</td><td>1,632,803</td><td>30,622,564</td><td>65</td><td>2</td></tr></table>
455
+
456
+ Using the GCN teacher, we see that the performance of GLNN is improved over MLP and becomes competitive to the teacher GCN on $\mathtt { P e n n 9 4 }$ . However, on Pokec, the simple LINK model can achieve very good performance, and it is better than most GNNs reported in Lim et al. (2021). LINK is a purely structural model which does not use node features at all. This shows that the Pokec dataset corresponds to the setting we discussed in Sec 5.8 (limitations of GLNN) – if the node labels can be largely determined by only the graph structure, then GLNN will struggle. We observe that GLNN is not as good as LINK owing to this limitation. However, we still see that for most of the non-homophilous datasets, MLPs already work quite well on them, and we can use GLNN for the other ones like Penn94.
457
+
458
+ Table 14: GLNN on non-homophilous datasets. Numbers other than GLNN are taken from Lim et al. (2021)
459
+
460
+ <table><tr><td>Dataset</td><td>LINK</td><td>GCN</td><td>MLP</td><td>GLNN</td></tr><tr><td>Penn94</td><td>80.79</td><td>82.47</td><td>73.61</td><td>81.69</td></tr><tr><td>Pokec</td><td>80.54</td><td>75.45</td><td>62.37</td><td>61.32</td></tr></table>
461
+
462
+ # J MODEL COMPARISON WITH NOISY NODE FEATURES
463
+
464
+ In Section 6, we conducted an ablation study to compare model performance with noisy node features, and the result is shown in the left plot in Figure 5. There are two subtle points in this plot. (1) The performance of GNN is still relatively high for high noisy features, even when $\alpha = 1$ and the features are completely random. (2) For completely random features, the performance of GLNN is still higher than MLP. We now discuss and explain them in more detail.
465
+
466
+ GNN Performance on Random Features. GNN still performs well because nodes with the same labels are likely to be connected and GNN can overfit the training data. We explain the detail through a toy example. Suppose there is a 4-clique containing nodes A, B, C, D in the graph with only a single edge D-E connects this clique to other graph nodes. Suppose A, B, C, D all have iid random Gaussian raw features and the same class label c. Let’s pick A to be the inductive test node and assume E and the triangle formed by B, C, D to be in the training graph. Let’s consider a simple example for 1-layer GCN and break down message passing into feature aggregation and nonlinear transformation. During training, GNN can overfit the data by learning a nonlinear transformation which maps the aggregated features of B, C, D to class c. The aggregated features of B and C will just be the average of the raw features of B, C, D. Although E is also involved in D’s feature aggregation step, the aggregated features of D will also be very close to this average. Then when test on A, the aggregated feature of A will likely be classified to the same class c by the overfitted nonlinear transformation because it is the average of raw node features of A, B, C, D. In this case, GNN can actually correctly classify A because of the overfitting. For GNNs with more layers and graphs with more neighbor nodes, the conclusion may be generalized.This is roughly sort of a “majority vote” process. For a test node A, if many nodes, which A collects features from, have the same class label and appear in the training graph, then A will be classified as this class by an overfitted classifier.
467
+
468
+ GLNN and MLP Performance on Random Features. The gap between MLP and GLNN is due to imbalanced datasets. The GLNN can learn the imbalance from soft labels, whereas MLPs can only access uniformly picked training nodes. We explain more detail using the A-computer dataset as an example, for which the gap between MLP and GLNN is obvious. The task is 10-class classification. With random node features $( \alpha { = } 1 )$ ), the inductive accuracy for MLP is 0.0652 and 0.2538 for GLNN. If the data labels are uniform, then both models should give an accuracy around 0.1. However, the labels on the inductive dataset are actually imbalanced. We show the results in Figure 9. The hist on the left is the label distribution of the inductive test set. In particular, class 4 takes about $40 \%$ . However, given this imbalance, the standard train-test split selects training nodes uniformly among labels. In this case, 20 nodes per class. Therefore, the predictions of MLP on random features are expected to be relatively uniform because the 200 nodes we train it on are uniform. This gives the hist shown in the middle, where the largest class takes about $1 7 . 5 \%$ . Finally, for GLNN, we train it on all the 200 training nodes with hard labels, plus soft labels of other nodes in the observed graph $\mathcal { G } _ { o b s }$ (see Section 5.2). Since these extra nodes are selected randomly, whose label distribution is actually similar to the label distribution on the whole data and the distribution on the inductive test set. Therefore, we get the GLNN predictions hist on the right. Although for each node, we can’t assign a prediction correlated to its feature, on average the distribution is very close to the true label distribution on the inductive test set and has a much higher expectation. In fact, if the prediction distribution is exactly the true distribution on the inductive test set, the expectation will be 0.2169. GLNN actually does even a bit better by putting its bet more on the largest class.
469
+
470
+ ![](images/403a9c5a1b32a03dcf520caf81b8a2a56b3a306859c74e50c516bf26d61ec307.jpg)
471
+ Figure 9: Inductive (predicted) label distribution on the A-computer dataset. Left: true labels. Middle: predicted labels by MLP. Right: predicted labels by GLNN.
md/dev/5Xc1ecxO1h/5Xc1ecxO1h.md ADDED
@@ -0,0 +1,284 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Tree of Thoughts: Deliberate Problem Solving with Large Language Models
2
+
3
+ Shunyu Yao Princeton University
4
+
5
+ Dian Yu Google DeepMind
6
+
7
+ Jeffrey Zhao Google DeepMind
8
+
9
+ Izhak Shafran Google DeepMind
10
+
11
+ Thomas L. Griffiths Princeton University
12
+
13
+ Yuan Cao Google DeepMind
14
+
15
+ Karthik Narasimhan Princeton University
16
+
17
+ # Abstract
18
+
19
+ Language models are increasingly being deployed for general problem solving across a wide range of tasks,but are still confined to token-level, left-to-right decision-making processes during inference. This means they can fall short in tasks that require exploration, strategic lookahead, or where initial decisions play a pivotal role. To surmount these challenges,we introduce a new framework for language model inference,“Tree of Thoughts”(ToT),which generalizes over the popular“Chain of Thought” approach to prompting language models,and enables exploration over coherent units of text ("thoughts") that serve as intermediate steps toward problem solving. ToT allows LMs to perform deliberate decision making by considering multiple different reasoning paths and self-evaluating choices to decide the next course of action, as well as looking ahead or backtracking when necessary to make global choices. Our experiments show that ToT significantly enhances language models’ problem-solving abilities on three novel tasks requiring non-trivial planning or search: Game of 24, Creative Writing,and Mini Crosswords. For instance, in Game of 24, while GPT-4 with chain-of-thought prompting only solved $4 \%$ of tasks,our method achieved a success rate of $74 \%$ . Code repo with all prompts: https://github.com/princeton-nlp/tree-of-thought-llm.
20
+
21
+ # 1Introduction
22
+
23
+ Originally designed to generate text, scaled-up versions of language models (LMs) such as GPT [25, 26,1,23] and PaLM [5] have been shown to be increasingly capable of performing an ever wider range of tasks requiring mathematical, symbolic, commonsense,and knowledge reasoning. It is perhaps surprising that underlying all this progress is still the original autoregressive mechanism for generating text, which makes token-level decisions one by one and in a left-to-right fashion. Is such a simple mechanism sufficient for a LM to be built toward a general problem solver? If not, what problems would challenge the current paradigm,and what should be alternative mechanisms?
24
+
25
+ The literature on human cognition provides some clues to answer these questions. Research on “dual process” models suggests that people have two modes in which they engage with decisions - a fast, automatic,unconscious mode ("System 1") and a slow, deliberate, conscious mode ("System 2") [30,31,16,15]. These two modes have previously been connected to a variety of mathematical models used in machine learning. For example, research on reinforcement learning in humans and other animals has explored the circumstances under which they engage in associative “model free" learning or more deliberative“model based” planning [7]. The simple associative token-level choices of LMs are also reminiscent of “System 1",and thus might benefit from augmentation by a more deliberate “System $2 ^ { \circ }$ planning process that (1) maintains and explores diverse alternatives for current choices instead of just picking one,and (2) evaluates its current status and actively looks ahead or backtracks to make more global decisions.
26
+
27
+ ![](images/b7fb3f215b6ad763cd26c1185478d0e2a29d7cb659f6ab760a80492664d522bb.jpg)
28
+ Figure 1: Schematic ilustrating Various approaches to problem solving with LLMs. Each rectangle box represents a thought, which is a coherent language sequence that serves as an intermediate step toward problem solving. See concrete examples of how thoughts are generated, evaluated, and searched in Figures 2,4,6.
29
+
30
+ To design such a planning process, we return to the origins of artificial intelligence (and cognitive science), drawing inspiration from the planning processes explored by Newell, Shaw,and Simon starting in the 195Os [21,22]. Newell and colleagues characterized problem solving [21] as search through a combinatorial problem space,represented as a tree.We thus propose the Tree of Thoughts (ToT) framework for general problem solving with language models. As Figure 1 illustrates, while existing methods (detailed below) sample continuous language sequences for problem solving, ToT actively maintains a tree of thoughts,where each thought is a coherent language sequence that serves as an intermediate step toward problem solving (Table 1). Such a high-level semantic unit allows the LM to self-evaluate the progress different intermediate thoughts make towards solving the problem through a deliberate reasoning process that is also instantiated in language (Figures 2,4,6). This implementation of search heuristics via LM self-evaluation and deliberation is novel,as previous search heuristics are either programmed or learned. Finally,we combine this language-based capability to generate and evaluate diverse thoughts with search algorithms,such as breadth-first search (BFS) or depth-first search (DFS), which allow systematic exploration of the tree of thoughts with lookahead and backtracking.
31
+
32
+ Empirically, we propose three new problems that challenge existing LM inference methods even with the state-of-the-art language model, GPT-4 [23]: Game of 24, Creative Writing,and Crosswords (Table 1). These tasks require deductive,mathematical, commonsense,lexical reasoning abilities, and a way to incorporate systematic planning or search. We show ToT obtains superior results on allthree tasks by being general and flexible enough to support different levels of thoughts,different ways to generate and evaluate thoughts,and diferent search algorithms that adapt to the nature of different problems. We also analyze how such choices affect model performances via systematic ablations and discuss future directions to better train and use LMs.
33
+
34
+ # 2Background
35
+
36
+ We first formalize some existing methods that use large language models for problem-solving, which our approach is inspired by and later compared with. We use $p _ { \theta }$ to denote a pre-trained LM with parameters $\theta$ ,and lowercase letters $x , y , z , s , \cdots$ to denote a language sequence, i.e. $x =$ $( x [ 1 ] , \hat { \cdot } \cdot \cdot , x [ n ] )$ where each $x [ i ]$ is a token, so that $\begin{array} { r } { p _ { \theta } ( x ) = \prod _ { i = 1 } ^ { n } p _ { \theta } ( x [ i ] | x [ 1 . . . i ] ) } \end{array}$ . We use uppercase letters $S , \cdots$ to denote a collection of language sequences.
37
+
38
+ Input-output (IO) prompting is the most common way to turn a problem input $x$ into output $y$ with LM: $y \sim p _ { \boldsymbol \theta } ( y | \mathrm { p r o m p t } _ { I O } ( x ) )$ ,where $\mathsf { p r o m p t } _ { I O } ( x )$ wraps input $x$ with task instructions and/or few-shotinputoutputexamples.Forsimplicityetsde $p _ { \theta } ^ { \mathrm { p r o m p t } } ( \mathsf { o u t p u t } \mid \mathsf { i n p u t } ) =$ $p _ { \theta } ( \mathrm { { o u t p u t } \mid p r o m p t ( i n p u t ) } )$ , so that IO prompting can be formulated as $y \sim p _ { \theta } ^ { I O } ( y | x )$ :
39
+
40
+ Chain-of-thought $\mathbf { ( C o T ) }$ prompting [38] was proposed to address cases where the mapping of input $x$ to output $y$ is non-trivial (e.g. when $x$ is a math question and $y$ is the final numerical answer). The key idea is to introduce a chain of thoughts $z _ { 1 } , \cdots , z _ { n }$ to bridge $x$ and $y$ ,where each $z _ { i }$ is a coherent language sequence that serves as a meaningful intermediate step toward problem solving (e.g. $z _ { i }$ could be an intermediate equation for math QA). To solve problems with CoT, each thought $\boldsymbol { z } _ { i } \sim p _ { \theta } ^ { C o T } ( \boldsymbol { z } _ { i } \mid x , \boldsymbol { z } _ { 1 \cdots i - 1 } )$ is sampledsequentially,thentheoutput $y \sim p _ { \theta } ^ { C o T } ( y | x , z _ { 1 } . . . n )$ In practice, $[ z _ { 1 \cdots n } , y ] \sim p _ { \theta } ^ { C o T } ( z _ { 1 \cdots n } , y | x )$ is sampled asacontiuouslanguagesequenceadthe decomposition of thoughts (e.g.is each $z _ { i }$ a phrase, a sentence, or a paragraph) is left ambiguous.
41
+
42
+ Self-consistency with CoT (CoT-SC) [36] is an ensemble approach that samples $k$ i.i.d. chains of thought: $[ z _ { 1 \cdots n } ^ { ( i ) } , y ^ { ( i ) } ] \sim p _ { \theta } ^ { C o T } ( z _ { 1 \cdots n } , y | x )$ $( i = 1 \cdots k )$ thenretusteostfrequentoutput arg $\operatorname* { m a x } _ { y }$ # $\{ i \mid y ^ { ( i ) } = y \}$ .CoT-SC improves upon CoT, because there are generally different thought processes for the same problem (e.g. different ways to prove the same theorem), and the output decision can be more faithful by exploring a richer set of thoughts. However, within each chain there is no local exploration of different thought steps,and the “most frequent” heuristic only applies when the output space is limited (e.g. multi-choice QA).
43
+
44
+ # 3Tree of Thoughts: Deliberate Problem Solving with LM
45
+
46
+ A genuine problem-solving process involves the repeated use of available information to initiate exploration, which discloses,in turn, more information until a way to attain the solution is finally discovered.— Newell et al. [21]
47
+
48
+ Research on human problem-solving suggests that people search through a combinatorial problemspace -a tree where the nodes represent partial solutions,and the branches correspond to operators that modify them [21,22].Which branch to take is determined by heuristics that help to navigate the problem-space and guide the problem-solver towards a solution. This perspective highlights two key shortcomings of existing approaches that use LMs to solve general problems: 1) Locally, they do not explore different continuations within a thought process-the branches of the tree.2) Globally, they do not incorporate any type of planning,lookahead,or backtracking to help evaluate these different options - the kind of heuristic-guided search that seems characteristic of human problem-solving.
49
+
50
+ To address these shortcomings, we introduce Tree of Thoughts (ToT),a paradigm that allows LMs to explore multiple reasoning paths over thoughts (Figure 1(c)). ToT frames any problem as a search over a tree, where each node is a state $s = [ x , z _ { 1 \cdots i } ]$ representing a partial solution with the input and the sequence of thoughts so far. A specific instantiation of ToT involves answering four questions: 1. How to decompose the intermediate process into thought steps; 2. How to generate potential thoughts from each state; 3. How to heuristically evaluate states; 4. What search algorithm to use.
51
+
52
+ 1.Thought decomposition. While CoT samples thoughts coherently without explicit decomposition, ToT leverages problem properties to design and decompose intermediate thought steps.As Table 1 shows,depending on diferent problems,a thought could be a couple of words (Crosswords),a line of equation (Game of 24), or a whole paragraph of writing plan (Creative Writing). In general,a thought should be “small" enough so that LMs can generate promising and diverse samples (e.g. generating a whole book is usually too“big” to be coherent), yet“big” enough so that LMs can evaluate its prospect toward problem solving (e.g. generating one token is usually too “small" to evaluate).
53
+
54
+ 2.Thought generator $G ( p _ { \theta } , s , k )$ . Given a tree state $s = [ x , z _ { 1 } . . . i ]$ , we consider two strategies to generate $k$ candidates for the next thought step:
55
+
56
+ (a) Sample i.i.d.thoughts from a CoT prompt (Creative Writing,Figure 4): $z ^ { ( j ) } \sim$ $p _ { \theta } ^ { C o \hat { T _ { ( z _ { i + 1 } | s } ) } } = p _ { \theta } ^ { \check { C } o T } ( z _ { i + 1 } | x , z _ { 1 \cdots i } ) \ ( \dot { j } = \dot { 1 } \cdots k )$ . This works better when the thought space is rich (e.g.each thought is a paragraph),and i.i.d.samples lead to diversity;
57
+ (b) Propose thoughts sequentially using a“propose prompt”(Game of 24, Figure 2; Crosswords, Figure 6): $[ z ^ { ( 1 ) } , \cdot \cdot \cdot , z ^ { ( k ) } ] \sim p _ { \theta } ^ { p r o p o s e } ( z _ { i + 1 } ^ { ( 1 \cdots k ) } \mid s )$ ]\~propose() . This works better when the thought space is more constrained (e.g.each thought is just a word or a line),so proposing different thoughts in the same context avoids duplication.
58
+
59
+ 3. State evaluator $V ( p _ { \theta } , S )$ . Given a frontier of different states,the state evaluator evaluates the progress they make towards solving the problem, serving as a heuristic for the search algorithm to determine which states to keep exploring and in which order. While heuristics are a standard approach to solving search problems, they are typically either programmed (e.g. DeepBlue [3]) or learned (e.g. AlphaGo [29]). We propose a third alternative,by using the LM to deliberately reason about states.When applicable,such a deliberate heuristic can be more flexible than programmed rules,and more sample-efficient than learned models. Similar to the thought generator, we consider two strategies to evaluate states either independently or together:
60
+
61
+ (a) Value each state independently: $V ( p _ { \theta } , S ) ( s ) ~ \sim ~ p _ { \theta } ^ { v a l u e } ( v | s ) ~ \forall s ~ \in ~ S$ where a value prompt reasons about the state $s$ to generate a scalar value $v$ (e.g.1-10) or a classification (e.g.sure/likely/impossible) that could be heuristically turned into a value.The basis of such evaluative reasoning can vary across problems and thought steps. In this work, we explore evaluation via few lookahead simulations (e.g.quickly confirm that 5,5,14 can reach 24 via $5 + 5 + 1 4$ ,or “hot_l" can mean“inn”via filling“e”in“-") plus commonsense (e.g.1 2 3 are too smallto reach 24, or no word can start with “tzxc"). While the former might promote “good” states,the latter could help eliminate “bad” states. Such valuations do not need to be perfect,and only need to be approximately helpful for decision making. (b) Vote across states: $V ( p _ { \theta } , S ) ( s ) = \mathbb { 1 } [ s = s ^ { * } ]$ , where a“good” state $s ^ { * } \sim p _ { \theta } ^ { v o t e } ( s ^ { * } | S )$ is voted out based on deliberately comparing different states in $S$ in a vote prompt. When problem success is harder to directly value (e.g. passage coherency), it is natural to to instead compare different partial solutions and vote for the most promising one. This is similar in spirit to a“step-wise” self-consistency strategy,i.e.cast “which state to explore” as a multi-choice QA,and use LM samples to vote for it.
62
+
63
+ For both strategies, we could prompt the LM multiple times to aggregate the value or vote results to trade time/resource/cost for more faithful/robust heuristics.
64
+
65
+ <table><tr><td>Algorithm1 ToT-BFS(x,pe,G,k,V,T,b)</td><td>Algorithm 2 ToT-DFS(s,t,pe,G,k,V,T,Uth)</td></tr><tr><td>Require: Input x,LM po, thought generator G(Require: Current state s, step t,LM po, thought &amp; size limit k, states evaluator V(),step limit T, generator G() and size limit k, states evaluator</td><td></td></tr><tr><td>breadth limit b. So←{x}</td><td>V(), step limit T, threshold Uth if t &gt; T then record output G(pe, s,1)</td></tr><tr><td>for t=1,..,T do</td><td>end if</td></tr><tr><td>St←{[s,z]|s∈ St-1,zt ∈G(p0,s,k)}</td><td>for s&#x27; ∈ G(pe,s,k) do&gt; sorted candidates</td></tr><tr><td>Vt ←V(po,St)</td><td>if V(pe,{s&#x27;})(s) &gt; Uthres then &gt; pruning</td></tr><tr><td>St ← arg maxscs&#x27;,|s|=b∑ses Vt(s)</td><td>DFS(s&#x27;,t+1)</td></tr><tr><td>end for return G(pe,arg maxs∈Sr Vr(s),1)</td><td>end if</td></tr></table>
66
+
67
+ 4. Search algorithm.Finally, within the ToT framework,one can plug and play different search algorithms depending on the tree structure. We explore two relatively simple search algorithms and leave more advanced ones (e.g. $\mathbf { A } ^ { * }$ [11],MCTS [2]) for future work:
68
+
69
+ (a)Breadth-first search (BFS) (Algorithm 1) maintains a set of the $b$ most promising states per step. This is used for Game of 24 and Creative Writing where the tree depth is limit $( T \leq 3 )$ ,and initial thought steps can be evaluated and pruned to a small set $( b \leq 5 )$ )
70
+ (b) Depth-first search (DFS) (Algorithm 2) explores the most promising state first, until the final output is reached $( t > T )$ ,or the state evaluator deems it impossible to solve the problem from the current $s$ $( V ( p _ { \theta } , \{ s \} ) ( s ) \le v _ { t h }$ for a value threshold $v _ { t h }$ ). In the latter case, the subtree from $s$ is pruned to trade exploration for exploitation. In both cases,DFS backtracks to the parent state of $s$ to continue exploration.
71
+
72
+ Conceptually,ToT has several benefits as a method for general problem-solving with LMs: (1) Generality. IO,CoT, CoT-SC,and self-refinement can be seen as special cases of ToT(i.e. trees of limited depth and breadth; Figure 1). (2) Modularity. The base LM, as well as the thought decomposition, generation, evaluation, and search procedures can allbe varied independently. (3) Adaptability. Different problem properties,LM capabilities,and resource constraints can be accommodated. (4) Convenience.No extra training is needed, just a pre-trained LM is suficient. The next section will show how these conceptual benefits translate to strong empirical performance in diferent problems.
73
+
74
+ # 4Experiments
75
+
76
+ We propose three tasks that are hard even when sampling from the state-of-the-art language model. GPT-4 [23], using standard IO prompting or chain-of-thought (CoT) prompting. We show how deliberate search in trees of thoughts (ToT) produces beter results,and more importantly, interesting and promising new ways to use language models to solve problems requiring search or planning. Unless otherwise stated, we perform experiments using a Chat Completion mode GPT $\dot { 4 } ^ { 1 }$ with a sampling temperature of 0.7.
77
+
78
+ <table><tr><td></td><td>Game of 24</td><td>Creative Writing</td><td>5x5 Crosswords</td></tr><tr><td>Input</td><td>4 numbers (4 9 10 13)</td><td>4 random sentences</td><td>10 clues (h1. presented;..)</td></tr><tr><td>Output</td><td>An equation to reach 24 (13-9)*(10-4)=24</td><td>A passage of 4 paragraphs ending in the 4 sentences</td><td>5x5 letters: SHOWN; WIRRA; AVAIL;..</td></tr><tr><td>Thoughts</td><td>3 intermediate equations (13-9=4 (left 4,4,10); 10- 4=6 (left 4,6); 4*6=24)</td><td>Ashort writingplan (1.Introduce a book that connects...)</td><td>Words to fill in for clues: (h1. shown; v5. naled; .)</td></tr><tr><td>#ToT steps</td><td>3</td><td>1</td><td>5-10 (variable)</td></tr></table>
79
+
80
+ Table 1: Task overview. Input, output, thought examples are in blue.
81
+
82
+ # 4.1 Game of 24
83
+
84
+ Game of 24 is a mathematical reasoning challenge, where the goal is to use 4 numbers and basic arithmetic operations $( + - ^ { * } / )$ to obtain 24. For example, given input $^ { \bullet } 4 9 1 0 1 3 ^ { \prime \prime }$ , a solution output could be $\ ^ { \cdot } ( 1 0 - 4 ) \ ^ { * } \ ( 1 3 - 9 ) = 2 4 ^ { , 9 }$ :
85
+
86
+ ![](images/1e51ca3d9ec5118d046f44d504919561fcccabdb24a756895c2162f29b531ffb.jpg)
87
+ Figure 2: ToT in a game of 24. The LM is prompted for (a) thought generation and (b) valuation.
88
+
89
+ Task Setup. We scrape data from 4nums.com, which has 1,362 games that are sorted from easy to hard by human solving time,and use a subset of relatively hard games indexed 901-1,0Oo for testing. For each task, we consider the output as success if it is a valid equation that equals 24 and uses the input numbers each exactly once.We report the success rate across 1OO games as the metric.
90
+
91
+ Baselines.We use a standard input-output (IO) prompt with 5 in-context examples.For chain-ofthought (CoT) prompting, we augment each input-output pair with 3 intermediate equations, each operating on two remaining numbers. For example, given input $^ { \dots } 4 9 1 0 1 3 ^ { \prime \prime }$ ,the thoughts could be $\cdot 1 3 - 9 = 4$ (left: 4 4 10); $1 0 - 4 = 6$ (left: $4 6$ ) $4 \ast 6 = 2 4$ (left: 24)". For each game, we sample IO and CoT prompting for 100 times for average performance. We also consider a CoT self-consistency baseline,which takes the majority output from $1 0 0 \mathrm { C o T }$ samples,and an iterative-refine approach on top of an IO sample for at most 10 iterations. At each iteration, the LM is conditioned on all previous history to “reflect on your mistakes and generate a refined answer”if the output is incorrect. Note that it uses groundtruth feedback signals about equation correctness.
92
+
93
+ ToT Setup. To frame Game of 24 into ToT, it is natural to decompose the thoughts into 3 steps, each an intermediate equation. As shown in Figure 2(a), at each tree node, we exact the remaining numbers and prompt the LM to propose some possible next steps. The same “propose prompt” is used for all 3 thought steps,though it only has one example with 4 input numbers. We perform a breadth-first search (BFS) in ToT, where at each step we keep the best $b = 5$ candidates. To perform deliberate BFS in ToT,as shown in Figure 2(b), we prompt LM to evaluate each thought candidate as “sure/maybe/impossible” with regard to reaching 24. The aim is to promote correct partial solutions that can be verdicted within few lookahead trials,and eliminate impossible partial solutions based on “too big/small” commonsense,and keep the rest “maybe". We sample values 3 times for each thought.
94
+
95
+ <table><tr><td>Method</td><td> Success</td></tr><tr><td>IO prompt</td><td>7.3%</td></tr><tr><td>CoT prompt</td><td>4.0%</td></tr><tr><td>CoT-SC (k=100) ToT (ours) (b=1)</td><td>9.0% 45%</td></tr><tr><td>ToT (ours) (b=5)</td><td>74%</td></tr><tr><td>IO + Refine (k=10)</td><td>27%</td></tr><tr><td>IO (best of 100)</td><td>33%</td></tr><tr><td>CoT (best of 100)</td><td>49%</td></tr></table>
96
+
97
+ Table 2: Game of 24 Results.
98
+
99
+ ![](images/d9810d9d96bc205c2dc3f1adc0e2933a0adab5854989f8701a562674a3c12cef.jpg)
100
+ Figure 3: Game of 24 (a) scale analysis & (b) error analysis.
101
+
102
+ Results. As shown in Table 2,IO, CoT,and CoT-SC prompting methods perform badly on the task, achieving only $7 . 3 \%$ $4 . 0 \%$ ,and $9 . 0 \%$ success rates.In contrast,ToT with a breadth of $b = 1$ already achieves a success rate of $4 5 \%$ ,while $b = 5$ achieves $7 4 \%$ .We also consider an oracle setup for IO/CoT, by calculating the success rate using best of $k$ samples ( $1 \leq k \leq 1 0 0 $ ). To compare IO/CoT (best of $\mathbf { k }$ ) with ToT,we consider calculating the tree nodes visited per task in ToT across $b = 1 \cdots 5$ and map the 5 success rates in Figure 3(a), treating IO/CoT (best of $k$ )asvisiting $k$ nodes in a bandit. Not surprisingly, CoT scales better than IO,and best of $1 0 0 \mathrm { C o T }$ samples achieve a success rate of $4 9 \%$ ,but still much worse than exploring more nodes in ToT $( b > 1 )$ ).
103
+
104
+ Error analysis.Figure 3(b) breaks down at which step CoT and ToT samples fail the task, i.e.the thought (in CoT) or all $b$ thoughts (in ToT) are invalid or impossible to reach 24.Notably,around $60 \%$ of CoT samples already failed the task after generating the first step, or equivalently, the first three words (e.g. $\mathbf { \^ 6 4 + 9 ^ { 9 } } ,$ . This highlights the issues with direct left-to-right decoding.
105
+
106
+ # 4.2 Creative writing
107
+
108
+ Next, we invent a creative writing task where the input is 4 random sentences and the output should be a coherent passage with 4 paragraphs that end in the 4 input sentences respectively. Such a task is open-ended and exploratory,and challenges creative thinking as well as high-level planning.
109
+
110
+ Task setup.We sample random sentences from randomwordgenerator.com to form 1OO inputs,and there is no groundtruth passage for each input constraint. As we find that GPT-4 can follow the input constraints most of the time, we focus on evaluating passage coherency in two ways: using a GPT-4 zero-shot prompt to provide a 1-10 scalar score, or using human judgments to compare pairs of outputs from different methods.For the former, we sample 5 scores and average them for each task output,and we find these 5 scores usually consistent, with a standard deviation of around 0.56 on average across outputs.For the latter, we employ a subset of the authors in a blind study to compare the coherency of CoT vs.ToT generated passage pairs, where the order of passges is random flipped over 100 inputs.
111
+
112
+ Baselines. Given the creative nature of the task, both IO and CoT prompts are zero-shot.While the former prompts the LM to directly generate a coherent passage given input constraints, the later prompts the LM to first make a brief plan then write the passage,i.e.the plan serves as the intermediate thought step. We generate $1 0 ~ \mathrm { I O }$ and CoT samples per task.We also consider an iterative-refine $k \leq 5 ,$ method on top of a random IO sample for each task,where the LM is conditioned on input constraints and the last generated passage to decide if the passage is already “perfectly coherent”, and if not generate a refined one.
113
+
114
+ ToT setup. We build a ToT with depth 2 (and only 1 intermediate thought step)—the LM first generates $k = 5$ plans and votes for the best one (Figure 4), then similarly generate $k = 5$ passages based on the best plan then vote for the best one.Here the breadth limit $b = 1$ ,as only one choice is kept per step. A simple zero-shot vote prompt ("analyze choices below, then conclude which is most promising for the instruction") is used to sample 5 votes at both steps.
115
+
116
+ Results.Figure 5(a) shows average GPT-4 scores across 1OO tasks,where ToT(7.56) is deemed to generate more coherent passages than IO (6.19) and CoT (6.93) on average. While such an automatic metric might be noisy,Figure 5(b) confirms the finding by showing that humans prefer ToT over CoT in 41 out of 100 passage pairs, while only prefer CoT over ToT in 21 (other 38 pairs are found "similarly coherent"). Lastly,iterative-refine is more effective on this natural language task, where it improves IO coherency score from 6.19 to 7.67,and ToT coherency score from 7.56 to 7.91. We believe itcould be thought of as a third approach to thought generation in the ToT framework, where new thoughts can arise from refining old thoughts instead of i.i.d.or sequentially generated.
117
+
118
+ ![](images/86eb94dd2d0b516038e313736bb8eb03701d9d5e9a43ed7e3cb40ee5c83b22a3.jpg)
119
+ Figure 4: A step of deliberate search in a randomly picked Creative Writing task. Given the input, the LM samples 5 diferent plans,then votes 5 times to decide which plan is best. The majority choice is used to consequently write the output passage with the same sample-vote procedure.
120
+
121
+ ![](images/8f84c416cb87838aea30c4e3df231aa2034fc2a22f5efd1f291e764425310c93.jpg)
122
+ Figure 5: Creative Writing results.
123
+
124
+ <table><tr><td>Method</td><td>Success Rate (%) Letter Word Game</td></tr><tr><td>10 CoT</td><td>38.7 14 0 40.6 15.6 1</td></tr><tr><td>ToT (ours)</td><td>78 60 20</td></tr><tr><td>+best state</td><td>82.4 67.5 35</td></tr><tr><td> -prune</td><td>65.4 41.5 5</td></tr><tr><td>-backtrack</td><td>54.6 20 5</td></tr></table>
125
+
126
+ Table 3: Mini Crosswords results.
127
+
128
+ # 4.3Mini crosswords
129
+
130
+ In Game of 24 and Creative Writing,ToT is relatively shallow —at most 3 thought steps are needed to reach the final output. Here we explore $5 \times 5$ mini crosswords as a harder search problem involving natural language. Again, the goal is not just to solve the task, as more general crosswords can be readily solved with specialized NLP pipelines [34] that leverages large-scale retrieval instead of LM. Rather, we aim to explore the limit of LMas a general problem solver that explores its own thoughts and guides its own exploration with deliberate reasoning as heuristics.
131
+
132
+ Task setup.We scrape data from GooBix, which contains 156 games of $5 \times 5$ mini crosswords. As we observe adjacent games contain similar clues,we use 2O games with indices $1 , 6 , \cdots , 9 1 , 9 6$ for testing,and games 136,141,146,151,156 for prompting. For each task, the input describes the 5 horizontal clues and 5 vertical clues,and the output should be a board of $5 \times 5 = 2 5$ letters to solve the crosswords. For evaluation, we consider three levels of success: the portion of correct letters (25 per game), words (10 per game), and games.
133
+
134
+ Baselines. We provide 5 example input-output pairs in the IO prompt, and in the CoT prompt additionally include intermediate words in the order h1..5 then v1..5. We run each prompt for 10 samples and average the results.
135
+
136
+ ToT setup. We leverage a depth-first search (Algorithm 2) that keeps exploring the most promising subsequent word clue until the state is no longer promising, then backtrack to the parent state to explore alternative thoughts.To make search tractable, subsequent thoughts are constrained not to change any filled words or letters,so that the ToT has at most 1O intermediate steps.For thought generation, at each state we translate all existing thoughts (e.g.“h2.motor; h1.tasks” for the state in Figure 6(a)) into letter constraints for remaining clues (e.g."v1.To heap: tm__-;.") and prompt a proposal prompt 5 times to come up with candidates for where and what to fill in the next word. Importantly, we also prompt the LM to give a confidence level for different thoughts,and aggregate these across proposals to obtain a sorted list of next thoughts to explore (Figure 6(a). For state evaluations, we similarly translate each state into leter constraints for remaining clues,then evaluate for each clue if it is possible to fillgiven the constraints. If any remaining clue is demed “impossible” to fill in (e.g.“v1. To heap: tm_s-"), then the exploration of the state's subtree is pruned and DFS backtracks to its parent to explore the next promising thought. We limit DFS search steps to 100,and simply render the deepest explored state (the first explored one if multiple) into the final output.
137
+
138
+ ![](images/b92ef17d9ff862acec28f259769b8b0a71bcd39ac3994319e0b060e8f88b3c7c.jpg)
139
+ Figure 6: In Mini Crosswords,(a) how thoughts are proposed and aggregated in a priority queue for depth-first search (DFS),and (b) how a state is evaluated based on the possibility of filling in each remaining word clue,and pruned if any remaining clue is deemed not possible to fill by the LM. Then DFS backtracks to the parent state and explore the next promising thought for clue.
140
+
141
+ Results. As shown in Table 3, IO and CoT prompting methods perform poorly with a word-level success rate less than $1 6 \%$ ,while ToT significantly improves all metrics,achieving a word-level success rate of $6 0 \%$ and solving 4 out of 20 games. Such an improvement is not surprising, given IO and CoT lack mechanisms to try different clues,make changes to decisions,or backtrack.
142
+
143
+ Oracle and ablation studies. When outputing from the oracle best DFS state (instead of the heuristically determined best state) per task, ToT performance is even higher and actually solves 7/20 games (Table 3,‘ $^ { + }$ best state"), indicating our simple output heuristics can be readily improved. Interestingly, sometimes when the crosswords game is actually solved, the state evaluator might still deem some words as “impossible" and prune - possibly because $5 \times 5$ crosswords by design have some rare or obselete words that GPT-4 cannot recognize2. Given the state evaluation as a pruning heuristic is imperfect, we also explore ablating the pruning, and find the performance generally worse (Table 3,“-prune"). However, it could actually find the correct solution for 4/20 games (though only outputing 1 via heuristic),3 of which are games ToT+pruning cannot solve within 100 steps. Thus, beter heuristics for DFS pruning are critical for problem solving in this case.Lastly, we confirm the importance of backtracking by running an ablation that keeps filing the most promising clue for at most 20 steps,allowing overwrites. This is similar to a“greedy”BFS search with breadth limit of $b = 1$ ,and performs poorly with a word level success of only $2 \dot { 0 } \%$ (Table 3,“-backtrack").
144
+
145
+ # 5Related Work
146
+
147
+ Planning and decision making. Smart planning and decision making are critical to achieving predefined goals. As they are trained on vast amount of world knowledge and human examples,LMs are known to have already absorbed rich commonsense that makes it possible to propose reasonable plans conditioned on problem seting and environmental states [12,42,37,13,35,41,40]. Our proposed ToT approach extends existing planning formulations by considering multiple potentially feasible plans simultaneously at each problem-solving step, and proceeding with the most promising ones. The integration between thought sampling and value feedback organically integrates planning and decision-making mechanisms,enabling effective search inside a solution tree. On the other hand, traditional decision-making procedures usually require training dedicated reward and policy models as in reinforcement learning (for example CHAI [33]), whereas we use the LM itself to provide the value estimates for decision making. RAP [9] is a concurrent work that treats language model reasoning as planning with its internal world model, and proposes a MCTS-based method similar to ToT.However,its tasks are simpler than ours,and its framework lacks the modularity to incorporate different tree search algorithms.
148
+
149
+ Self-reflection. Using LLMs to assess the viability of their own predictions is becoming an increasingly important procedure in problem solving. [28,20,24] introduced the“self-reflection” mechanism, in which LMs provide feedback to their generation candidates. [4] improves LMs code generation accuracy by injecting feedback messages generated by the LM itself based on its code execution results. Similarly,[17] also introduces “critic”or review steps over the actions and states, deciding the next action to take in solving computer operation tasks. Another recent work very relevant to ours is “self-eval guided decoding” [39]. Similar to our method, self-eval decoding also follows a tree-search procedure with leaves sampled from stochastic beam search decoding, which are then evaluated by LLM itself with carefully prepared self-eval prompts. Their approach however, uses the PAL formulation [8] which represents thoughts as codes,which makes it difficult to tackle chalenging tasks like creative writing which we consider in this paper. Our Tree-of-Thought formulation is thus more versatile and handles challenging tasks on which GPT-4 only achieves very low accuracy with standard prompts.
150
+
151
+ Program-guided LLM generation. Our proposal is also related to recent advancements that organize LM's behavior with systematic procedures [14,44,6,43] or symbolic program guidance.For example, Schlag et al.[27] embeds LMs in an algorithmic search procedure to help solve problems like question answering step-by-step, in which the search trees are expanded by relevant paragraphs that might provide answers. This approach however differs from ours in that trees are expanded by sampling external paragraphs instead of the LM's own thoughts,and there is no reflection or voting steps. Another approach, $\mathrm { L L M + P }$ [18], goes one step further and delegates the actual planning process to a classical planner.
152
+
153
+ Classical search methods. Last but not least, our approach can be treated as a modern rendition of classical search methods for problem solving. For example it can be considered as a heuristic search algorithm like $\mathbf { A } ^ { * }$ [10], in which the heuristic at each search node is provided by the LM's selfassessment. From this perspective, our method is also related to NeuroLogic $\mathbf { A } ^ { * }$ esque decoding [19], which is inspired by $\mathbf { A } ^ { * }$ search but introduces look-ahead heuristics that are efficient for LMs to improve the beam-search or top-k sampling decoding. This method however is constrained to sentence generation tasks,whereas our framework are designed for complex, multi-step problem solving guarded by value feedback.
154
+
155
+ # 6Discussion
156
+
157
+ Limitations and future directions. Deliberate search such as ToT might not be necessary for many existing tasks that GPT-4 already excels at (see Appendix B.1),and as an initial step this work only explores three relatively simple tasks that challenges GPT-4 (see Appendix B.2 for some GPT-3.5 experiment results) and calls of beter search and planning abilities incorporated with LMs. However, as we begin to deploy LMs for more real-world decision making applications (e.g.coding, data analysis, robotics, etc.), more complex tasks could emerge and present new opportunities to study these research questions. Also, search methods like ToT requires more resources (e.g. GPT-4 API cost) than sampling methods in order to improve task performances, but the modular flexibility of ToT allows users to customize such performance-cost tradeoffs,and ongoing open-source efforts [32] should readily reduce such costs in the near future. More details about cost and effciency are in Appendix B.3. Lastly, this work focuses on using an off-the-shelf LM, and fine-tuning LMs using a ToT-style high-level counterfactual decision making (e.g.deliberating over potential choices for the next paragraph, instead of predicting the next token) might present opportunities to enhance the problem-solving capabilities of LMs.
158
+
159
+ Conclusion. The associative “System 1” of LMs can be beneficially augmented by a“System $2 ^ { \circ }$ based on searching a tree of possible paths to the solution to a problem. The Tree of Thoughts framework provides a way to translate classical insights about problem-solving into actionable methods for contemporary LMs. At the same time,LMs address a weakness of these classical methods, providing a way to solve complex problems that are not easily formalized, such as creative writing. We see this intersection of LMs with classical approaches to AI as an exciting direction.
160
+
161
+ # Broader Impact
162
+
163
+ ToT is a framework that empowers LMs to more autonomously and intelligently make decisions and solve problems. While current tasks are limited to reasoning and search problems, future applications involving interaction with external environments or humans could bring potential danger, e.g.facilitating harmful uses of LMs. On the other hand, ToT also improves the interpretability of model decisions and the opportunity for human alignment, as the resulting representations are readable, high-level language reasoning instead of implicit, low-level token values.
164
+
165
+ # Acknowledgements
166
+
167
+ SY and KN acknowledge support from an Oracle Collaborative Research award and the National Science Foundation under Grant No. 2239363. Any opinions,findings,conclusions,or recommendations expressed in this material are those of the author(s)and do not necessarily reflect the views of the National Science Foundation. SY is also supported by the Harold W.Dodds Fellowship from Princeton.
168
+
169
+ # References
170
+
171
+ [1] 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.
172
+ [2] C. Browne,E.J. Powley, D. Whitehouse, S. M. M. Lucas, P. I. Cowling, P. Rohlfshagen, S.Tavener,D.P.Liebana, S. Samothrakis,and S. Colton.A survey of monte carlo tree search methods. IEEE Transactions on Computational Intelligence and AI in Games, 4:1-43,2012.
173
+ [3] M. Campbell, A. J. Hoane Jr, and F.-h. Hsu. Deep blue. Artificial intelligence,134(1-2):57-83, 2002.
174
+ [4] X. Chen, M. Lin, N. Schärli, and D. Zhou. Teaching large language models to self-debug, 2023.
175
+ [5] 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.
176
+ [6] A. Creswelland M. Shanahan. Faithful reasoning using large language models. arXiv preprint arXiv:2208.14271,2022.
177
+ [7] N. D. Daw, Y. Niv, and P. Dayan. Uncertainty-based competition between prefrontal and dorsolateral striatal systems for behavioral control. Nature neuroscience, 8(12):17O4-1711, 2005.
178
+ [8] L. Gao, A. Madaan, S. Zhou, U. Alon, P. Liu, Y. Yang, J. Callan,and G. Neubig. Pal: Programaided language models, 2023.
179
+ [9]S. Hao, Y. Gu, H. Ma, J. J. Hong,Z. Wang, D. Z. Wang,and Z. Hu. Reasoning with language model is planning with world model. arXiv preprint arXiv:2305.14992, 2023.
180
+ [10] P.E.Hart,N.J. Nilsson,and B. Raphael. A formal basis for the heuristic determination of minimum cost paths. IEEE Transactions on Systems Science and Cybernetics,4(2):100-107, 1968. doi: 10.1109/TSSC.1968.300136.
181
+ [11] P.E.Hart,N.J. Nilsson,and B.Raphael. A formal basis for the heuristic determination of minimum cost paths. IEEE transactions on Systems Science and Cybernetics,4(2):100-107, 1968.
182
+ [12] W. Huang, P. Abbeel, D. Pathak,and I. Mordatch. Language models as zero-shot planners: Extracting actionable knowledge for embodied agents, 2022.
183
+ [13] W. Huang,F. Xia, T. Xiao, H. Chan, J. Liang, P.Florence, A. Zeng, J. Tompson, I. Mordatch, Y. Chebotar, et al. Inner monologue: Embodied reasoning through planning with language models. arXiv preprint arXiv:2207.05608,2022.
184
+ [14] J. Jung, L. Qin, S. Weleck, F. Brahman, C. Bhagavatula, R. L. Bras,and Y. Choi. Maieutic prompting: Logically consistent reasoning with recursive explanations. arXiv preprint arXiv:2205.11822,2022.
185
+ [15] D. Kahneman. Thinking, fast and slow. Macmillan, 2011.
186
+ [16] D. Kahneman, S. Frederick, et al. Representativeness revisited: Attribute substitution in intuitive judgment. Heuristics and biases: The psychology of intuitive judgment, 49(49-81):74, 2002.
187
+ [17] G. Kim, P. Baldi, and S. McAleer. Language models can solve computer tasks, 2023.
188
+ [18] B. Liu, Y. Jiang, X. Zhang, Q. Liu, S. Zhang, J. Biswas,and P. Stone. Llm $+ \mathsf { p }$ : Empowering large language models with optimal planning proficiency, 2023.
189
+ [19] X. Lu, S. Welleck, P. West, L. Jiang, J. Kasai, D. Khashabi,R. L. Bras,L. Qin, Y. Yu, R. Zellers, N. A. Smith,and Y. Choi. Neurologic a\*esque decoding: Constrained text generation with lookahead heuristics. In North American Chapter of the Association for Computational Linguistics, 2021.
190
+ [20] A. Madaan, N. Tandon, P. Gupta, S. Hallinan,L. Gao, S. Wiegreffe,U. Alon, N. Dziri, S. Prabhumoye, Y. Yang, S. Welleck,B.P. Majumder, S. Gupta, A. Yazdanbakhsh, and P. Clark. Self-refine: Iterative refinement with self-feedback, 2023.
191
+ [21] A. Newell, J. C. Shaw, and H. A. Simon. Report on a general problem solving program. In IFIP congress, volume 256, page 64. Pittsburgh, PA,1959.
192
+ [22] A. Newell, H. A. Simon, et al. Human problem solving. Prentice-Hall,1972.
193
+ [23] OpenAI. Gpt-4 technical report. ArXiv,abs/2303.08774, 2023.
194
+ [24] D. Paul,M. Ismayilzada, M. Peyrard, B.Borges, A. Bosselut, R. West, and B.Faltings. Refiner: Reasoning feedback on intermediate representations,2023.
195
+ [25] A. Radford, K. Narasimhan,T. Salimans,I Sutskever, et al. Improving language understanding by generative pre-training. OpenAI blog, 2018.
196
+ [26] A. Radford, J. Wu, R. Child, D. Luan, D. Amodei, I. Sutskever, et al. Language models are unsupervised multitask learners. OpenAI blog, 1(8):9,2019.
197
+ [27] I. Schlag, S. Sukhbaatar, A. Celikyilmaz, W. tau Yih,J. Weston, J. Schmidhuber, and X. Li. Large language model programs, 2023.
198
+ [28] N. Shinn, B. Labash,and A. Gopinath. Reflexion: an autonomous agent with dynamic memory and self-reflection, 2023.
199
+ [29] D. Silver, J. Schritwieser, K. Simonyan, I. Antonoglou, A. Huang, A. Guez, T. Hubert,L. Baker, M.Lai, A. Bolton, et al. Mastering the game of go without human knowledge. nature, 550 (7676):354-359, 2017.
200
+ [30] S. A. Sloman. The empirical case for two systems of reasoning. Psychological bulletin,119(1): 3,1996.
201
+ [31] K.E. Stanovich. Who is rational? Studies ofindividual diferences in reasoning. Psychology Press, 1999.
202
+ [32] H. Touvron,T. Lavril, G. Izacard, X. Martinet, M.-A. Lachaux, T.Lacroix,B.Roziere, N. Goyal, E. Hambro,F. Azhar, et al. Llama: Open and efficient foundation language models. arXiv preprint arXiv:2302.13971,2023.
203
+ [33] S. Verma, J.Fu, S. Yang, and S. Levine. Chai: A chatbot ai for task-oriented dialogue with offline reinforcement learning. In Proceedings of the 2022 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, pages 4471-4491, 2022.
204
+ [34] E. Wallace, N. Tomlin, A. Xu, K. Yang,E. Pathak, M. Ginsberg,and D. Klein. Automated crossword solving. arXiv preprint arXiv:2205.09665,2022.
205
+ [35] L. Wang, W. Xu, Y. Lan, Z. Hu, Y. Lan, R. K.-W. Lee, and E.-P. Lim. Plan-and-solve prompting: Improving zero-shot chain-of-thought reasoning by large language models, 2023.
206
+ [36] X. Wang, J. Wei, D. Schuurmans, Q.Le,E. Chi, and D. Zhou. Self-consistency improves chain of thought reasoning in language models. arXiv preprint arXiv:2203.11171, 2022.
207
+ [37] Z. Wang, S. Cai, A. Liu, X. Ma,and Y. Liang. Describe, explain, plan and select: Interactive planning with large language models enables open-world multi-task agents, 2023.
208
+ [38] J. Wei, X. Wang, D. Schuurmans,M. Bosma, E. Chi, Q.Le,and D. Zhou. Chain of thought prompting elicits reasoning in large language models. arXiv preprint arXiv:2201.11903, 2022.
209
+ [39] Y. Xie, K. Kawaguchi, Y. Zhao, X. Zhao, M.-Y. Kan, J. He,and Q. Xie. Decomposition enhances reasoning via self-evaluation guided decoding, 2023.
210
+ [40] S.Yang, O. Nachum, Y.Du,J. Wei, P. Abbeel,and D. Schuurmans. Foundation models for decision making: Problems, methods,and opportunities, 2023.
211
+ [41] S. Yao, J. Zhao,D. Yu,N. Du, I. Shafran, K. Narasimhan,and Y. Cao.ReAct: Synergizing reasoning and acting in language models. arXiv preprint arXiv:2210.03629,2022.
212
+ [42] S. Zhang, Z. Chen, Y. Shen, M. Ding, J. B. Tenenbaum, and C. Gan. Planning with large language models for code generation. In The Eleventh International Conference on Learning Representations,2023. URL https://openreview.net/forum?id=Lr8c00tYbfL.
213
+ [43] D. Zhou, N. Scharli,L. Hou, J. Wei, N. Scales, X. Wang,D. Schuurmans, C. Cui, O. Bousquet, Q.Le, et al. Least-to-most prompting enables complex reasoning in large language models. arXiv preprint arXiv:2205.10625,2022.
214
+ [44] X. Zhu, J. Wang, L. Zhang, Y. Zhang, R. Gan, J. Zhang,and Y. Yang. Solving math word problem via cooperative reasoning induced language models. arXiv preprint arXiv:2210.16257, 2022.
215
+
216
+ # A Code, Prompts, Trajectories
217
+
218
+ All code is available at https://github.com/princeton-nlp/tree-of-thought-llm.
219
+
220
+ All prompts are available at https://github.com/princeton-nlp/tree-of-thought-llm/ tree/master/src/tot/prompts.
221
+
222
+ Trajectories are available at https://github.com/princeton-nlp/tree-of-thought-llm/ tree/master/logs.
223
+
224
+ # BAdditional Experiment Results
225
+
226
+ Given the motivation of exploring and extending the capability frontier of language models, our experiments in the main paper have focused on a setup with the state-of-the-art language model (GPT-4),and three hard tasks invented to chalenge it. Here, we report additional experiments with weaker LLM or easier tasks,and discusscost and efficiency.
227
+
228
+ <table><tr><td>GPT-4</td><td>GPT-3.5</td></tr><tr><td>10 6.19</td><td>4.47</td></tr><tr><td>CoT 6.93</td><td>5.16</td></tr><tr><td>ToT 7.56</td><td>6.62</td></tr></table>
229
+
230
+ Table 5: Game of 24 with GPT-4 vs GPT-3.5.
231
+
232
+ <table><tr><td>GSM8K</td><td>StrategyQA</td></tr><tr><td>10 51</td><td>73</td></tr><tr><td>CoT 86</td><td>82</td></tr><tr><td>ToT 90</td><td>83</td></tr></table>
233
+
234
+ Table 4:New tasks with zero-shot ToT and GPT-4.
235
+
236
+ <table><tr><td></td><td>GPT-4</td><td>GPT-3.5</td></tr><tr><td>I0</td><td>7.3%</td><td>6%</td></tr><tr><td>CoT</td><td>4.0%</td><td>3%</td></tr><tr><td>ToT</td><td>74%</td><td>19%</td></tr></table>
237
+
238
+ Table 6: Creative Writing with GPT-4 vs. GPT-3.5.
239
+
240
+ # B.1Extension to new tasks (GSM8k, StrategyQA) with zero-shot ToT
241
+
242
+ While more common NLP tasks might be too easy for GPT-4 and do not require ToT(which is why we considered harder new tasks), we believe applying ToT to new tasks could be straightforward. For example, we implemented a simple and generic zero-shot ToT-BFS similar to creative writing (sample 5 problem solving strategies then vote for the best one; then sample 5 solutions based on the best strategy then vote for the best one) for GSM8K and StrategyQA with few extra lines of code:
243
+
244
+ # define the answer format of new tasks gsm8k_format $=$ ("the answer is n" where n is a number' strategyqa_format $=$ ‘either "the answer is yes" or "the answer is no"’ # define zero-shot io prompting standard_prompt $=$ ‘Answer the following question with {format}: {input}' # define thought format for zero-shot cot and zero-shot tot cot_prompt $\begin{array} { r l } { = } & { { } \hat { \pmb { \mathscr { \imath } } } \pmb { \mathscr { \imath } } \pmb { \mathscr { \imath } } \pmb { \mathscr { \imath } } } \end{array}$ Answer the following question: {input}
245
+
246
+ Make a strategy then write. Your output should be of the following format:
247
+
248
+ Strategy:
249
+
250
+ Your strategy about how to answer the question.
251
+
252
+ Answer:
253
+
254
+ Your answer to the question.It should end with {format}. ,,,
255
+
256
+ # define zero-shot voting used for zero-shot tot
257
+ vote_prompt $\begin{array} { r l } { \mathbf { \Sigma } } & { { } = \mathbf { \Sigma } ^ { \textit { \textbf { c } } \texttt { \textsf { c } } \mathcal { \epsilon } \textbf { \Lambda } } } \end{array}$ Given an instruction and several choices, decide which choice is most promising.
258
+ Analyze each choice in detail,then conclude in the last line "The best choice is {s}",where s the integer id of the choice. ,,
259
+
260
+ We evaluated on a subset of 100 random GSM8K test and StrategyQA dev questions. As shown in Table 4 and as expected,ToT improves over CoTon both tasks (but only slightly, given GPT-4 $+ \mathrm { C o T }$ is already very good on such tasks, and StrategyQA's botleneck is external knowledge, not reasoning). Considering computational costs, it is more suitable to try smaller LLMs $^ +$ ToT for traditional NLP tasks,or GPT $\cdot 4 + \mathrm { T o T }$ for hard tasks that challenge GPT $. 4 + \mathrm { C o T ' }$ reasoning.
261
+
262
+ # B.2Extension to new LMs (GPT-3.5)
263
+
264
+ To understand how ToT works with other LLMs, we also ran GPT-3.5-turbo for Creative Writing (Table 6) and Game of 24 (Table 5). On both tasks, $\mathbf { \partial } ^ { \cdot } \mathbf { \Phi } ^ { \cdot } \mathbf { T o T } > \mathbf { C o T } > \mathbf { I O } ^ { \prime }$ remains true for GPT-3.5. On Creative Writing,we find GPT $3 . 5 \mathrm { + T o T }$ outperform GPT $_ { 4 + 1 0 }$ ,and similar to GPT- $4 { + } \mathrm { C o T }$ ,which suggests ToT could also work well on weaker language models.
265
+
266
+ On Game of 24 (we changed 1-shot proposal prompt to 3-shot to make it work), GPT- $. 3 . 5 +$ ToT's $19 \%$ is far worse than GPT- $^ { 4 + }$ ToT's $74 \%$ . To further understand the importance of generation vs. evaluation, we ran GPT-4 generation $+ \mathrm { G P T } { - 3 . 5 }$ evaluation $( 6 4 \% )$ and GPT-3.5 generation $^ +$ GPT-4 evaluation $( 3 1 \% )$ . This suggests the game's bottleneck is thought generation,and different generation/evaluation language models might attain decent results while reducing costs.
267
+
268
+ # B.3Cost and effciency
269
+
270
+ Running ToT requires significantly more computations than IO or CoT prompting. For example, in Game of 24 (Table 7 below), solving a problem with ToT requires $5 . 5 \mathrm { k }$ completion tokens, close to $1 0 0 \mathrm { C o T }$ trials ( $\mathrm { 6 . 7 k }$ tokens). But the performance of ToT is better than best of 1OO independent CoT trials.
271
+
272
+ <table><tr><td>Game of 24</td><td>Generate/Prompt tokens</td><td>Cost per case</td><td> Success</td></tr><tr><td>IO (best of 100)</td><td>1.8k /1.0k</td><td>$0.13</td><td>33%</td></tr><tr><td>CoT (best of 100)</td><td>6.7k /2.2k</td><td>$0.47</td><td>49%</td></tr><tr><td>ToT</td><td>5.5k / 1.4k</td><td>$0.74</td><td>74%</td></tr></table>
273
+
274
+ Table 7: Cost analysis on Game of 24.
275
+
276
+ On Creative Writing (Table 8 below), we found ToT takes around ${ 5 } \mathrm { x }$ completion tokens and money cost, which is intuitive as $b = 5$ and most tokens are generated passages.
277
+
278
+ <table><tr><td>Creative Writing</td><td>Generate/Prompt tokens</td><td>Cost per case</td></tr><tr><td>I0</td><td>0.9k /0.4k</td><td>$0.06</td></tr><tr><td>CoT</td><td>0.9k/0.4k</td><td>$0.07</td></tr><tr><td>ToT</td><td>4k /2.9k</td><td>$0.32</td></tr></table>
279
+
280
+ Table 8: Cost analysis on Game of 24.
281
+
282
+ So completing Game of 24 and Creative Writing's main ToT experiments cost around $0 . 7 4 \times 1 0 0 +$ $0 . 3 2 \times 1 0 0 = 1 0 6$ dollars.Crosswords’DFS experiments should be also within 1OO dollars.In general, cost and efficiency of ToT highly depend on the prompts and search algorithms used,and could require 5-1OO times more generated tokens than CoT. Some actionable insights:
283
+
284
+ · We recommend using ToT on tasks requiring deliberate reasoning, on which CoT struggles. · Flexibility of ToT allows some performance-cost tradeoff, e.g., change beam size or vote number in BFS,few-shot vs. zero-shot prompting,GPT-3.5 vs. GPT-4,etc. One could configure the setup based on some resource constraints or performance goal. · There is much space for improving effciency, e.g., BFS could early stop when solution is found,or trim down beam size to when some thoughts are "impossible". · We believe that more computation is indeed required in order for the model to achieve stronger intelligence,and this should not become a blocking issue as in the long run, (opensource) LMs will become much cheaper and more efficient. It is also a great direction how to better train/finetune LMs for thought generation and/or evaluation.
md/dev/6Dz7RiRiMFd/6Dz7RiRiMFd.md ADDED
@@ -0,0 +1,360 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # MOTIF-BASED ROTO-TRANSLATION INVARIANTTRANSFORMER FOR MOLECULAR PROPERTY PRE-DICTION IN 3D SPACE
2
+
3
+ Anonymous authors Paper under double-blind review
4
+
5
+ # ABSTRACT
6
+
7
+ Recent studies use geometric deep learning to represent molecules and predict properties. However, they are computationally expensive in capturing long-range dependencies and ignore the non-uniformity of interatomic distances. More importantly, few of them consider injecting the biochemical structure knowledge such as functional groups into model architectures. To overcome such issues, we introduce Molformer, a variant of the Transformer for molecular representations that exploits both semantic motifs and 3D spatial information. Specifically, Molformer extracts motifs based on functional groups and learns customized embeddings to store the semantic meanings of those informative substructures. In order to fully employ 3D geometry, we adopt a convolutional position encoding to achieve roto-translation invariance, a multi-scale self-attention mechanism to capture local fine-grained patterns with increasing contextual scales, and an attentive farthest point sampling algorithm to attain the molecular representation. We validate Molformer across several domains in quantum chemistry, physiology, and biophysics. Our experiments show better or competitive performance in those datasets. Our work provides a promising way to amalgamate 3D geometric information and make better usage of informative substructures in representing molecules.
8
+
9
+ # 1 INTRODUCTION
10
+
11
+ Spatial structures are among the most crucial factors to decide molecular properties and understand their principles of action in the physical world. For example, 3D structures of proteins provide valuable information for inferring biological interventions, such as structure-based drug development and targeted mutagenesis (Senior et al., 2020; Jumper et al., 2021; Baek et al., 2021). In chemistry, zeolites show obvious differences in separation properties caused by subtle changes in their 3D geometric compositions (Chai et al., 2020; Pfriem et al., 2021). Apart from that, in the pharmaceutical industry, the same compounds can have different 3D structures, resulting in different solubility (Zhang et al., 2017). To sum up, capturing 3D spatial structures is essential to accurately forecast molecular properties. Based on these facts, researchers have studied molecular representation learning techniques (Rao et al., 2019) to include 3D spatial information (Zhavoronkov et al., 2019).
12
+
13
+ The dominant 3D molecular models are Graph Neural Networks (GNNs) and 3D Convolutional Neural Networks (3DCNNs) (Derevyanko et al., 2018; Pagès et al., 2019; Townshend et al., 2019). GNNs create edges by using either chemical bonds or finding the neighbors of each node within a distance cutoff (Zhang et al., 2020b). They encode pairwise connectivity of atoms and require running multiple hops for an atom to reach to another. 3DCNNs encode translational and permutational symmetries, but need to stack deep layers to build direct connections between distant regions, incurring significant computational costs. In contrast, Transformers rely on the self-attention mechanism to capture long-term dependencies in parallel (Hernández & Amigó, 2021). Meanwhile, Equivariant Neural Networks (ENNs) (Thomas et al., 2018) have emerged as a new class of methods, where geometric transformations of their inputs lead to well-defined transformations of outputs. Some ENNs adopt Transformers as the backbone but fail to surmount the intrinsic drawbacks of this architecture, including its insensibility to local patterns among non-uniformly distancing atoms and its inefficiency to aggregate atom features. Some other Transformer-based methods have been proposed to fuse distance and graph neighbourhood information (Maziarka et al., 2020; 2021). However, they take no consideration of employing motifs, which are frequently-occurring substructures in molecules and can be leveraged to uncover global graph properties.
14
+
15
+ In this work, we present the Molformer on the basis of all preceding analysis. For the sake of injecting chemical domain knowledge, we construct a motif-template vocabulary based on functional groups and adopt trainable motif embeddings to maintain the semantic meanings of those essential substructures. Then with both motifs and atoms as input, Molformer operates on a fully-connected graph with direct connections between remote regions (Velickovi ˇ c et al., 2017; Joshi, 2020), which ´ reduces computational burden of multi-hop GNNs and stacked 3DCNNs. However, this characteristic limits Molformer’s capacity in exploiting local structures and leads to poor generalization in unseen cases (Qi et al., 2017). Therefore, we propose a Multi-scale Self-Attention (MSA) module to recognize fine-grained patterns from neighborhoods. Moreover, we introduce a roto-translation invariant Convolutional Position Encoding (CPE) to depict position relationships among atoms and their adjacencies. After that, to retain a comprehensive representation of the entire molecule, we propose an Attentive Farthest Point Sampling (AFPS) module that selects important atoms with the assistance of the attention score map.
16
+
17
+ To summarize, our contributions are as follows:
18
+
19
+ • To the best of our knowledge, we are the foremost to incorporate motifs with knowledge of functional groups into a Transformer architecture for 3D molecular representation learning. • We propose a novel MSA to extract local patterns, a roto-translation invariant CPE method to encode relative distance at a linear computational time cost, and a simple yet effective downsampling algorithm to gather molecular representations. • We show significant improvements on several benchmarks in three domains. Code and all datasets are available at https://github.com/smiles724/Molformer.
20
+
21
+ # 2 PRELIMINARIES
22
+
23
+ Problem Definition. A molecule ${ \cal S } = ( { \cal E } , { \cal P } )$ has $N$ atoms and $C$ atom classes, where ${ \pmb { { \cal E } } } =$ $\{ e _ { 1 } , . . . , e _ { N } \} \in \mathbb { R } ^ { N \times C }$ contains the one-hot atom representations and $P = \{ p _ { 1 } , . . . , p _ { N } \} \in \mathbb { R } ^ { N \times 3 }$ contains the 3D coordinates of each atom. Each one-hot $e _ { i }$ can be converted to a dense vector $\pmb { x } _ { i } = e _ { i } \pmb { W } ^ { E }$ , with $\pmb { x } _ { i } \in \mathbb { R } ^ { d _ { m o d e l } }$ and $W ^ { E } \in \mathbb { R } ^ { C \times d _ { m o d e l } }$ being the embedding matrix. The 3D coordinates of the atom $i$ is a three-dimensional vector $\pmb { p } _ { i } = [ p _ { i } ^ { x } , \bar { p } _ { i } ^ { y } , p _ { i } ^ { z } ]$ . A representation learning model $f$ acts on $_ { s }$ , obtaining its representation $r = f ( S )$ . Then $\mathbfit { \Delta } \mathbf { r }$ is forwarded to a prediction model $g$ and attain the prediction of a biochemical property ${ \hat { y } } = g ( \pmb { r } )$ .
24
+
25
+ Self-attention Mechanism. The Transformer (Vaswani et al., 2017) has become very successful due to its core component, self-attention. Given a set of input features $\{ \pmb { x } _ { i } \} _ { i = 1 , . . . , N }$ , the standard dot-product attention layer is as the following:
26
+
27
+ $$
28
+ q _ { i } = f _ { Q } ( { x } _ { i } ) , k _ { i } = f _ { K } ( { x } _ { i } ) , v _ { i } = f _ { V } ( { x } _ { i } ) , a _ { i j } = q _ { i } k _ { j } ^ { T } / \sqrt { d _ { k } } , z _ { i } = \sum _ { j = 1 } ^ { N } \sigma ( a _ { i j } ) v _ { j }
29
+ $$
30
+
31
+ where $\left\{ f _ { Q } , f _ { K } , f _ { V } \right\}$ are embedding transformations, and $\{ q _ { i } , k _ { i } , v _ { i } \}$ are respectively the query, key, and value vectors with the same dimension $d _ { k }$ . $a _ { i j }$ is the attention that the token $i$ pays to the token $j$ . $\sigma$ denotes the Softmax function and $z _ { i }$ is the output embedding of the token $i$ . This formula conforms to a non-local network (Wang et al., 2018), indicating its inability to capture fine-grained patterns in a local context.
32
+
33
+ Position Encoding. Self-attention is invariant to permutation of the input (Dufter et al., 2021), and position encoding ensures that the Transformer will reveal positional information. Position encoding methods can be either based on absolute positions or relative distances. The former takes the raw position information as input and is sensitive to spatial transformations. The latter manipulates the attention score by incorporating relative distances (Guo et al., 2020a; Pan et al., 2021):√ $a _ { i j } = { \bf q } _ { i } { \bf k } _ { j } ^ { T } / \sqrt { d _ { k } } + f _ { \mathrm { P E } } ( \bar { p _ { i } } - p _ { j } )$ , where $\bar { f } _ { \mathrm { P E } } ( \cdot )$ is the position encoding function and is translation invariant. The rotation invariance can be further accomplished by taking a L2-norm $| | p _ { i } - p _ { j } | | _ { 2 }$ (Chen et al., 2019b).
34
+
35
+ ![](images/4aa7cb0818a54b520d22d500d8474338b6f0b8c1a3cb8942bfd66a2211b458c5.jpg)
36
+ Figure 1: The overall architecture of our Molformer. FFN stands for a feed-forward network. Local features are shown in purple and orange; yellow corresponds to a global feature.
37
+
38
+ # 3 MOLFORMER
39
+
40
+ Molformer is based on the architecture of Transformer but adopts several significantly different and novel components (see Figure 1). First, a vocabulary of motif templates is constructed on the basis of functional groups and we extract all available motifs from each molecule. Then both atoms and motifs acquire their corresponding embeddings and are forwarded into $L$ feature learning blocks. Each block consists of a convolutional position encoding, a multi-scale self-attention, and a feedforward network. After that, an attentive subsampling method is utilized to adaptively aggregate the molecular presentation, which is later fed into a predictor to forecast properties in a broad range of downstream tasks.
41
+
42
+ # 3.1 TRAINABLE MOTIF-BASED EMBEDDING
43
+
44
+ Motifs are frequently-occurring substructure patterns as well as the building blocks of complex molecular structures. They usually maintain semantic meanings and have great expressiveness of the biochemical characteristics of the whole molecule (Zhang et al., 2020a). In the chemical community, researchers have developed a set of standard criterion to recognize motifs with essential functionalities in molecules (Milo et al., 2002). Despite that, few of prior studies directly incorporate those informative motifs into their model architectures. To fill this gap, we define a series of momentous substructures using external domain knowledge, and introduce a trainable motif embeddings method to fully exploit them in our Molformer.
45
+
46
+ To begin with, all motifs are first extracted according to the motif vocabulary, which is built by functional groups. Practically, we rely on RDKit (Landrum, 2013) to draw them from the SMILES (Weininger, 1988) representation of each molecule. We assume $M$ motifs $\{ m _ { 1 } , . . . , m _ { M } \}$ are detected in the molecule $\pmb { S }$ , and each motif $m _ { i }$ contains a certain number of at least two atoms. Then we regard each kind of motif as a new type of token and append them to the input. Therefore, the input for our Molformer becomes $\{ \pmb { x } _ { 1 } , . . . , \pmb { x } _ { N } , \pmb { x } _ { m _ { 1 } } , . . . , \pmb { x } _ { m _ { M } } \}$ , where $\mathbf { \boldsymbol { x } } _ { m _ { i } }$ is obtained through an learnable embedding matrix $W ^ { M } \in \mathbb { R } ^ { C ^ { \prime } \times d _ { m o d e l } }$ and $C ^ { \prime }$ denotes the number of motif categories. As for the position of each motif, we adopt a weighted sum of the 3D coordinates of its component atoms as pmi = Pxi∈mi ( $\begin{array} { r } { \dot { p _ { m _ { i } } } = \sum _ { x _ { i } \in m _ { i } } \ ( \frac { w _ { i } } { \sum _ { x _ { i } \in m _ { i } } w _ { i } } ) \cdot \dot { p _ { i } } } \end{array}$ wi ) · pi, where wi are the atomic weights.
47
+
48
+ Our approach requires the model to automatically learn a customized embedding for each motif template through backpropagations, which follows a data-driven pattern. In some data-sufficient tasks, its greatest potential can be unlocked and those motif embeddings can be well trained. Nevertheless, in the case of few-shot learning or small datasets, each category of motif might only appear rare times. Those embeddings are not fully tuned and can be extremely biased and noisy, which will do little helps to the ultimate property prediction.
49
+
50
+ # 3.2 CONVOLUTIONAL POSITION ENCODING
51
+
52
+ To enable roto-translation invariance and take fully advantage of geometric information, instead of adding a term of $f _ { \mathrm { P E } } ( \pmb { p } _ { i } - \pmb { p } _ { j } )$ , we propose a CPE that applies a convolutional operation to the interatomic distance $\pmb { D } \in \mathbb { R } ^ { N \times N }$ :
53
+
54
+ $$
55
+ { \cal A } _ { \mathrm { c o v } } = \mathrm { C o n v } _ { 2 d } ( D ) \odot { \cal A } ,
56
+ $$
57
+
58
+ where $\pmb { A } = [ a _ { i , j } ] _ { i , j = 1 , \cdots N } \in \mathbb { R } ^ { N \times N }$ is the attention matrix, $\mathrm { C o n v } _ { 2 d } ( \cdot )$ denotes a 2D shallow convolutional network with a kernel size of $1 \times 1$ , and $\odot$ is the element-wise product. With multi-headed self-attention, ${ \cal A } _ { \mathrm { c o v } }$ is expanded in the sense that $A _ { \mathrm { c o v } } \in \mathbb { R } ^ { H \times N \times N }$ , and $\mathrm { C o n v } _ { 2 d } ( \cdot )$ has $H$ output channels. The CPE method induces ${ \mathrm { O } } ( N )$ convolution operations on each atom and can drastically reduce training time when the number of atoms is very large ( $\mathrm { { W u } }$ et al., 2021).
59
+
60
+ # 3.3 MULTI-SCALE SELF-ATTENTION
61
+
62
+ The self-attention mechanism in the Transformer is good at capturing global data patterns but ignores local context (Guo et al., 2020a). Exploiting local context has proven to be important for 3D spatial data such as 3D point clouds (Qi et al., 2017). Therefore, we impose a distance-based constraint in self-attention in order to extract multi-scaled patterns from both local and global contexts.
63
+
64
+ Guo et al. (2020b) propose to use integer-based distance to limit attention to local word neighbors, which cannot be used in molecules. This is because different types of molecules have different densities and molecules of the same type have different spatial regularity, which results in the nonuniformity of interatomic distances. Normally, small molecules have a mean interatomic distance of $1 { - } 2 \textup { \AA }$ (Angstrom, $1 0 ^ { - 1 0 } m _ { , }$ ), which is denser than large molecules like proteins with approximately $5 \mathrm { ~ \AA ~ }$ on average. To address that, we design a new multi-scale methodology to robustly capture details. Specifically, we mask atoms beyond a certain distance $\tau _ { s }$ (a real number as opposed to an integer in Guo et al. (2020b)) at each scale $s$ . We denote $d _ { i j } = | | { \pmb p } _ { i } - { \pmb p } _ { j } | | _ { 2 }$ as the Euclidean distance between the $i$ -th and $j$ -th atom. The attention calculation is modified as:
65
+
66
+ $$
67
+ a _ { i j } ^ { \tau _ { s } } = \frac { q _ { i } \pmb { k } _ { j } ^ { T } \cdot \mathbf { 1 } _ { \{ d _ { i j } < \tau _ { s } \} } } { \sqrt { d _ { k } } } , \ : z _ { i } ^ { \tau _ { s } } = \sum _ { j = 1 } ^ { N } \sigma ( a _ { i j } ^ { \tau _ { s } } ) \pmb { v } _ { j } ,
68
+ $$
69
+
70
+ where $\mathbf { 1 } _ { \{ d _ { i j } < \tau _ { s } \} }$ is the indicator function. For small molecules, Equation 3 can be complementally combined with Equation 2. Then features extracted from $S$ different scales $\{ \tau _ { s } \} _ { s = 1 , \dots , S }$ as well as the informative global feature are concatenated together to form a multi-scale representation, denoted by $\pmb { z } _ { i } ^ { \prime } = \pmb { z } _ { i } ^ { \mathcal { T } _ { 1 } } \oplus . . . \oplus \pmb { z } _ { i } ^ { \tau s } \oplus \pmb { z } _ { i } ^ { g l o b a l } \in \mathbb { R } ^ { ( S + 1 ) d _ { k } }$ . After that, $ { \boldsymbol { z } } _ { i } ^ { \prime }$ is forwarded into a multi-layer perceptron to be compressed as $z _ { i } ^ { \prime \prime }$ with the original dimension $d _ { k }$ .
71
+
72
+ # 3.4 ATTENTIVE FARTHEST POINT SAMPLING
73
+
74
+ After having the atom embeddings $\{ z _ { i } ^ { \prime \prime } \} _ { i = 1 , \dots , N }$ , we study how to obtain the molecular representation $\pmb { r }$ . For GNNs, several readout functions such as set2set (Vinyals et al., 2015) and GGNN (Gilmer et al., 2017) are invented. For Transformer architectures, one way is via a virtual atom.
75
+
76
+ <table><tr><td colspan="2">Algorithm 1 Pseudocode of Attentive Farthest Point Sampling</td></tr><tr><td colspan="2">Input: The attention score matrix A ∈ RN×N, a Euclidean distance matrix D ∈ RN ×N. Output: K sampled points.</td></tr><tr><td>1: A←∑iAij ∈RN</td><td>&gt; sum up the attention matrix along rows</td></tr><tr><td>2:D←D∈RNxN</td><td>&gt; normalize the distance matrix</td></tr><tr><td>3:P= {𝑥#},M={1,2,..,N} 4:while length(P)&lt;k do</td><td></td></tr><tr><td>5: Xnew = argmax (min Dij + eAi)</td><td>&gt; pick up the atom that maximize the objective</td></tr><tr><td>iEM j∈p 6: P.append(xnew), M.remove(x new)</td><td></td></tr><tr><td>7: return P</td><td></td></tr></table>
77
+
78
+ Though as Ying et al. (2021) state, it significantly improves the performance of existing models in the leaderboard of Open Graph Benchmark (Hu et al., 2020), this way concentrates more on close adjacent atoms and less on distant ones, and can lead to inadvertent over-smoothing of information propagation (Ishiguro et al., 2019). Besides, it is difficult to locate a virtual node in 3D space and build connections to existing atoms. The other way selects a subset of atoms via a downsampling algorithm named Farthest Point Search (FPS), but it ignores atomic differences and has sensitivity to outlier points (Pan et al., 2021) as well as uncontrollable randomness. To address these issues, we propose a new algorithm named AFPS. It aims to sample atoms by not merely spatial distances, but also their significance in terms of attention scores.
79
+
80
+ Specifically, we choose the virtual atom $x _ { \# }$ as the starting point and initialize two lists $\mathcal { P } = \{ x _ { \# } \}$ and $\mathcal { M } = \mathrm { \bar { \{ } } 1 , . . . , N \}$ to store remaining candidate points. Then the process begins with the attention score matrix $\pmb { A } \in \mathbb { R } ^ { N \times N }$ and the interatomic distance matrix $\pmb { { \cal D } } \in \mathbb { R } ^ { N \times N }$ . It can be easily proved that each row of $\pmb { A }$ sums up to 1 after the Sof tmax operation along columns, i.e. $\begin{array} { r } { \sum _ { j } { \cal A } _ { i j } \dot { = } 1 } \end{array}$ for $\forall i \in [ N ]$ . In order to obtain the importance of each atom in the self-attention computation, we accumulate $\pmb { A }$ along rows and get $\begin{array} { r } { \tilde { \pmb { A } } = \sum _ { i } \pmb { A } _ { i j } \in \mathbb { R } ^ { N } } \end{array}$ . Besides, we adopt the min-max normalization to rescale the distance matrix $_ D$ into values between 0 and 1, and obtain $\begin{array} { r } { \tilde { D } = \frac { D - \operatorname* { m i n } D } { \operatorname* { m a x } D - \operatorname* { m i n } D } } \end{array}$ .
81
+
82
+ After the above preprocess, we repeatedly move a point $x _ { n e w }$ from $\mathcal { M }$ to $\mathcal { P }$ , which ensures that $x _ { n e w }$ is as far from $\mathcal { P }$ as possible by maximizing $\tilde { D } _ { i j }$ and also plays a crucial role in attention computation by maximizing ${ \tilde { A } } _ { i }$ . Mathematically, the AFPS aims to achieve the following objective:
83
+
84
+ $$
85
+ \operatorname* { m a x } \sum _ { i \in \mathcal { M } } ( \operatorname* { m i n } _ { j \in \mathcal { P } \setminus \{ i \} } \tilde { D } _ { i j } + \epsilon \tilde { A } _ { i } )
86
+ $$
87
+
88
+ where $\epsilon$ is a hyperparameter to balance those two different goals. This process is repeated until $\mathcal { P }$ has reached $K$ points. Algorithm 1 provides a greedy approximation solution to solve this AFPS optimization objective for sake of computational efficiency.
89
+
90
+ After that, sampled features $\{ z _ { i } ^ { \prime \prime } \} _ { i \in P }$ are gathered by a Global Average Pooling layer (Lin et al., 2013) to attain the molecular representation $\pmb { r } \in \mathbb { R } ^ { d _ { k } }$ .
91
+
92
+ Remarkably, our proposed AFPS has considerable difference and superiority over a body of previous hierarchical learning approaches (Eismann et al., 2020; 2021). Their subsampling operations are mainly designed for protein complexities, which have more uniform structures than small molecules. To be specific, they hierarchically use alpha carbons as the intermediate set of points and aggregate information at the level of those carbons for the entire complex. However, the structures of small molecules have no such a stable paradigm, and we provide a universal methodology to adaptively subsample atoms without any prior assumptions on the atom arrangement.
93
+
94
+ # 4 EXPERIMENTS
95
+
96
+ # 4.1 EXPERIMENTAL SETUP
97
+
98
+ We conduct extensive experiments on both small and large molecules (proteins) with various targets, including quantum chemistry, physiology, and biophysics. Table 1 summarises information of benchmark datasets, such as the number of tasks and task types, the number of molecules and atom classes, the minimum and maximum number of atoms, and the density (mean interatomic distances) of all molecules.
99
+
100
+ Table 1: Key statistics of datasets from three different categories.
101
+
102
+ <table><tr><td>Category</td><td>Dataset</td><td>Tasks</td><td>Task Type</td><td>Molecules</td><td>Atom Class</td><td>Min. Atoms</td><td>Max. Atoms</td><td>Density (A</td><td>Metric</td></tr><tr><td rowspan="3">Quantum Chemistry</td><td>QM7</td><td>1</td><td>regression</td><td>7,160</td><td>5</td><td>4</td><td>23</td><td>2.91</td><td>MAE</td></tr><tr><td>QM8</td><td>12</td><td>regression</td><td>21,786</td><td>5</td><td>3</td><td>26</td><td>1.54</td><td>MAE</td></tr><tr><td>QM9</td><td>12</td><td>regression</td><td>133,885</td><td>5</td><td>3</td><td>28</td><td>1.61</td><td>MAE</td></tr><tr><td rowspan="2">Physiology</td><td>BBBP</td><td>1</td><td>classification</td><td>2.039</td><td>13</td><td>2</td><td>132</td><td>2.64</td><td>ROC-AUC</td></tr><tr><td>ClinTox</td><td>2</td><td>classification</td><td>1,478</td><td>27</td><td>1</td><td>136</td><td>2.83</td><td>ROC-AUC</td></tr><tr><td rowspan="2">Biophysics</td><td>PDBind1</td><td>1</td><td>regression</td><td>11,908</td><td>23</td><td>115</td><td>1,085</td><td>5.89</td><td>RMSE</td></tr><tr><td>BACE</td><td>1</td><td>classification</td><td>1,513</td><td>8</td><td>10</td><td>73</td><td>3.24</td><td>ROC-AUC</td></tr></table>
103
+
104
+ Datasets. We test Molformer on a series of small molecule datasets, containing QM7 (Blum & Reymond, 2009), QM8 (Ramakrishnan et al., 2015), QM9 (Ramakrishnan et al., 2014), BBBP (Martins et al., 2012), ClinTox (Gayvert et al., 2016), and BACE (Subramanian et al., 2016) 2. QM7 is a subset of GDB-13 and composed of 7K molecules with up to 5 heavy atom types. QM8 and QM9 are subsets of GDB-17 with $2 2 \mathrm { k }$ molecules and 133K molecule respectively.
105
+
106
+ Additionally, we also inspect Molformer’s ability of learning mutual relations between proteins and molecules on the PDBbind dataset (Wang et al., 2005). We follow Townshend et al. (2020) and split protein-ligand complexes by protein sequence identity at $30 \%$ . As for the target, we predict $p S = - \log ( S )$ , where $S$ is the binding affinity in Molar unit. In addition, we only use the pocket of each protein and put pocket-ligand pairs together as the input.
107
+
108
+ For QM9, we use the exact train/validation/test split as Townshend et al. (2020). For PDBbind, $90 \%$ of the data is used for training and the rest is divided equally between validation and test like Chen et al. (2019c). For others, we adopt the scaffold splitting method with a ratio of 8:1:1 for train/validation/test as Rong et al. (2020). More implementing details can be found in Appendix A.1
109
+
110
+ Baselines For small molecules, we compare our approach with a number of state-of-the-art baselines. TF_Robust (Ramsundar et al., 2015) takes molecular fingerprints as the input. GraphConv (Kipf & Welling, 2016), Weave (Kearnes et al., 2016), MPNN (Gilmer et al., 2017), Schnet (Schütt et al., 2018), MEGNet (Chen et al., 2019c), DMPNN (Yang et al., 2019), MGCN (Lu et al., 2019), AttentiveFP (Xiong et al., 2019), DimeNet $^ { + + }$ (Klicpera et al., 2020), SphereNet (Liu et al., 2021), and SpinConv (Shuaibi et al., 2021) are all graph convolutional models. Graph Transformer (Chen et al., 2019a), MAT (Maziarka et al., 2020), R-MAT (Maziarka et al., 2021), SE(3)- Transformer (Fuchs et al., 2020), and LieTransformer (Hutchinson et al., 2021) are Transformerbased models.
111
+
112
+ For PDBbind, we choose six baselines. DeepDTA (Öztürk et al., 2018) and DeepAffinity (Karimi et al., 2019) take in pairs of ligand and protein SMILES as input. Cormorant (Anderson et al., 2019) is an ENN that represents each atom by its absolute 3D coordinates. Schnet, 3DCNN and 3DGCN (Townshend et al., 2020) are 3D molecular representation methods.
113
+
114
+ # 4.2 RESULTS ON DOWNSTREAM TASKS
115
+
116
+ Molecules. Table 2 and Table 3 document the overall results of Molformer and baselines on small molecules datasets, where best performance is marked bold and the second best is underlined for clear comparison. It can be discovered that Molformer achieves the lowest MAE of 11.6 on QM7 and 0.009 on QM8, beating several strong baselines including DMPNN and Graph Transformer. While not all state-of-the-art on QM9, Molformer offers competitive performance in 5 property regression tasks, which do not require thermochemical energy subtractions. Particularly, we outperforms all Transformer-based ENNs, including SE(3)-Transformer and LieTransformer. In classification problems, we surpass all non-pretrained methods and are only inferior to the pretrained GROVE. This accords to the fact that datasets with fewer samples can gain large improvements through the self-supervised pretraining (Rong et al., 2020).
117
+
118
+ Table 2: The performance comparison. For regression tasks including QM7 and QM8, lower is better. For classification tasks including BBBP, ClinTox, and Bace, higher is better. The methods in purple are pretrained methods.
119
+
120
+ <table><tr><td>Method</td><td>QM7</td><td>QM8</td><td>BBBP</td><td>ClinTox</td><td>BACE</td></tr><tr><td>TF-Robust (Ramsundar et al., 2015)</td><td>120.6</td><td>0.024</td><td>0.860</td><td>0.765</td><td>0.824</td></tr><tr><td>GraphConv (Kipf &amp; Welling,2016)</td><td>118.9</td><td>0.021</td><td>0.877</td><td>0.845</td><td>0.854</td></tr><tr><td>Weave (Kearnes et al.,2016)</td><td>94.7</td><td>0.022</td><td>0.837</td><td>0.823</td><td>0.791</td></tr><tr><td>MPNN (Gilmer et al., 2017)</td><td>113.0</td><td>0.015</td><td>0.913</td><td>0.879</td><td>0.815</td></tr><tr><td>Schnet (Schuitt et al., 2018)</td><td>74.2</td><td>0.020</td><td>0.847</td><td>0.717</td><td>0.750</td></tr><tr><td>DMPNN (Yang et al.,2019)</td><td>105.8</td><td>0.014</td><td>0.919</td><td>0.897</td><td>0.852</td></tr><tr><td>MGCN (Lu et al., 2019)</td><td>77.6</td><td>0.022</td><td>0.850</td><td>0.634</td><td>0.734</td></tr><tr><td>Attentive FP (Xiong et al., 2019)</td><td>126.7</td><td>0.028</td><td>0.908</td><td>0.933</td><td>0.863</td></tr><tr><td>Graph Transformer (Chen et al.,2019a)</td><td>47.8</td><td>0.010</td><td>0.913</td><td>-</td><td>0.880</td></tr><tr><td>MAT (Maziarka et al.,2020)</td><td>102.8</td><td>1</td><td>0.728</td><td>-</td><td>0.846</td></tr><tr><td>R-MAT (Maziarka et al., 2021)</td><td>68.6</td><td>=</td><td>0.746</td><td>=</td><td>0.871</td></tr><tr><td>GROVElarge (Rong et al., 2020)</td><td>89.4</td><td>0.017</td><td>0.911</td><td>0.884</td><td>0.858</td></tr><tr><td> GROVElarge (Rong et al., 2020)</td><td>72.6</td><td>0.012</td><td>0.940</td><td>0.944</td><td>0.894</td></tr><tr><td>Molformer</td><td>11.5</td><td>0.009</td><td>0.926</td><td>0.941</td><td>0.884</td></tr></table>
121
+
122
+ Table 3: Comparison of MAE on QM9. The methods in orange are Transformer-based methods.
123
+
124
+ <table><tr><td>Target (Unit)</td><td>€HOMO (eV)</td><td>∈LUMo (eV)</td><td>△e(eV)</td><td>μ(D)</td><td>a (bohr3)</td></tr><tr><td>MPNN (Gilmer et al., 2017)</td><td>.043</td><td>.037</td><td>.069</td><td>.030</td><td>.092</td></tr><tr><td>Schnet (Schuitt et al., 2018)</td><td>.041</td><td>.034</td><td>.063</td><td>.033</td><td>.235</td></tr><tr><td>MEGNet ful (Chen et al., 2019c)</td><td>.038</td><td>.031</td><td>.061</td><td>.040</td><td>.083</td></tr><tr><td>DimeNet++ (Klicpera et al.,2020)</td><td>.024</td><td>.019</td><td>.032</td><td>.029</td><td>.043</td></tr><tr><td>SphereNet (Liu et al., 2021)</td><td>.024</td><td>.019</td><td>.032</td><td>.026</td><td>.047</td></tr><tr><td>SpinConv (Shuaibi et al.,2021)</td><td>.026</td><td>.022</td><td>.047</td><td>.027</td><td>.058</td></tr><tr><td> SE(3)-Transformer (Fuchs et al., 2020)</td><td>.035</td><td>.033</td><td>.053</td><td>.051</td><td>.142</td></tr><tr><td>LieTransformer-SE(3) (Hutchinson et al., 2021)</td><td>.033</td><td>.029</td><td>.052</td><td>.061</td><td>.104</td></tr><tr><td>Molformer</td><td>.021</td><td>.026</td><td>.039</td><td>.045</td><td>.086</td></tr></table>
125
+
126
+ Protein. Table 4 reports the Root-Mean-Squared Deviation (RMSD), the Pearson correlation $( R _ { p } )$ , and the Spearman correlation $( R _ { s } )$ on PDBbind. Molformer achieves the lowest RMSD among all baselines and the best Pearson and Spearman correlations. As Wu et al. (2018) claim, appropriate featurizations which contains pertinent information is significant for PDBbind. However, an important observation in our work is that deep learning approaches with the full exploitation of 3D geometric information can perform better than conventional methods like DeepDTA and DeepAffinity, which use a set of physicochemical descriptors but ignore 3D structures.
127
+
128
+ # 5 ABLATION STUDY AND DISCUSSION
129
+
130
+ # 5.1 WHAT ARE THE EFFECTS OF EACH COMPONENT
131
+
132
+ We investigate the effectiveness of different modules of our Molformer in Table 5. It can be observed that CPE substantially boosts model’s performance compared with the naive method that immediately adds 3D coordinates as the atom input feature. In addition, AFPS is found to produce better predictions than the control group, which utilizes the virtual node as the molecular representation. Moreover, MSA significantly reduces RMSD from 17.6 to 11.6 on QM7, but its improvements in QM8 are much smaller. This phenomenon indicates that MSA is an appropriate way to alleviate the problem of inadequate training in small datasets. It endows Molformer with capability to extract local features by regulating the scope of self-attention. However, as the data size gets larger and larger, Molformer does not require the assistance of MSA to abstract local patterns, since the parameters of CPE is properly trained. What’s more, the trainable motif-level embedding leads to a MAE decrease of 2.1 in QM7 and a RMSD drop of 0.011 in PDBbind, indicating its effectiveness in both small molecules and proteins.
133
+
134
+ Table 4: Comparison of RMSD, $R _ { p }$ , and $R _ { s }$ on PDBbind.
135
+
136
+ <table><tr><td>Method</td><td>Geometry</td><td>RMSD</td><td>Rp</td><td>Rs</td></tr><tr><td>DeepDTA (Ozturk et al., 2018)</td><td>Non-3D</td><td>1.565</td><td>0.573</td><td>0.574</td></tr><tr><td>DeepAffinity (Karimi et al.,2019)</td><td>Non-3D</td><td>1.893</td><td>0.415</td><td>0.426</td></tr><tr><td>Schnet (Schutt et al., 2018)</td><td>3D</td><td>1.892</td><td>0.601</td><td>=</td></tr><tr><td>Cormorant (Anderson et al., 2019)</td><td>3D</td><td>1.429</td><td>0.541</td><td>0.532</td></tr><tr><td>3DCNN (Townshend et al., 2020)</td><td>3D</td><td>1.520</td><td>0.558</td><td>0.556</td></tr><tr><td>3DGCN (Townshend et al., 2020)</td><td>3D</td><td>1.963</td><td>0.581</td><td>0.647</td></tr><tr><td>Molformer</td><td>3D</td><td>1.417</td><td>0.623</td><td>0.651</td></tr></table>
137
+
138
+ Table 5: Effects of each module on QM7, QM8 and PDBbind (RMSD). ME stands for the trainable motif embedding method.
139
+
140
+ <table><tr><td></td><td>CPE</td><td>AFPS</td><td>MSA</td><td>ME</td><td>QM7</td><td>QM8</td><td>PDBbind</td></tr><tr><td></td><td>=</td><td>=</td><td></td><td>-</td><td>63.2</td><td>0.0205</td><td>1.925</td></tr><tr><td></td><td></td><td>=</td><td></td><td>=</td><td>17.6</td><td>0.0104</td><td>1.489</td></tr><tr><td></td><td></td><td>√</td><td></td><td>1</td><td>17.0</td><td>0.0103</td><td>1.455</td></tr><tr><td></td><td></td><td></td><td></td><td>=</td><td>11.6</td><td>0.0098</td><td>1.423</td></tr><tr><td>1234576</td><td></td><td></td><td></td><td>F</td><td>15.2</td><td></td><td>1.443</td></tr><tr><td></td><td></td><td></td><td></td><td></td><td>13.7</td><td>0.0099</td><td>1.428</td></tr><tr><td></td><td></td><td></td><td></td><td></td><td>11.5</td><td>-</td><td>1.417</td></tr></table>
141
+
142
+ # 5.2 HOW USEFUL IS THE TRAINABLE MOTIF-BASED EMBEDDINGS?
143
+
144
+ How to determine motifs are critical and crucial to our proposed trainable motif-based embeddings. In organic chemistry, a functional group is a substituent or moiety in a molecule that causes the molecule’s characteristic chemical reactions. The same functional group will undergo the same or similar chemical reactions regardless of the rest of the molecule’s composition (Smith, 2020). Therefore, we define motifs on the basis of functional groups and explore the contribution of four different categories. Specifically, we consider four common functional groups, including groups that contain only carbon and hydrogen (Hydrocarbons), groups that contain halogen (Haloalkanes), groups that contain oxygen, and groups that contain nitrogen (see the left part in Figure 2). The ablations (see the right part in Figure 2) demonstrate that Molformer can gain improvements from all sorts of motifs, where Hydrocarbons and Haloalkanes are the most and the least effective kinds, respectively. This is in line with the fact that Hydrocarbons occur most frequently in organic molecules. Moreover, our model achieves the best performance when all categories of the motifs are integrated, implying a promising direction to discover more effective motifs.
145
+
146
+ # 6 RELATED WORKS
147
+
148
+ # 6.1 3D MOLECULAR REPRESENTATION
149
+
150
+ Deep learning has been widely applied to predict molecular properties during past decades. Small molecules are usually represented as lower-dimensional representations such as 1D linear sequence, including amino acid sequences and SMILES (Weininger, 1988), or 2D chemical bond graphs. In spite of that, more evidence indicates that 3D space structures lead to better modelling and superior performance. 3D models becomes a popular way to capture these complex geometries in a variety of bio-molecular applications using CNNs (Anand-Achim et al., 2021; Jiménez et al., 2018) and GNNs (Cho & Choi, 2018). Nonetheless, aforementioned methods have hardly been extended to the self-attention mechanism that is proven to be good at grabbing contextual feature (Tang et al., 2018) and long-range dependencies (Vaswani et al., 2017).
151
+
152
+ ![](images/31bbc953eb710da1bc428151f6917eb692cbf586d7e6684c00a0fbd0e0035c7a.jpg)
153
+ Figure 2: The left is the four different categories of motifs that we apply in Molformer based on functional groups. The right is the ablation study of those groups in QM7 and BBBP.
154
+
155
+ Attempts have been undertaken to address that issue throughout Transformers. Initially, molecules are in the form of SMILES to obtain corresponding representations (Honda et al., 2019; Pesciullesi et al., 2020; Morris et al., 2020; Rao et al., 2021) and conduct pretraining (Chithrananda et al., 2020). Some researchers combine the characteristics of GNN and Transformer to solve generative tasks (Ingraham et al., 2019) or fulfill equivariance (Fuchs et al., 2020).
156
+
157
+ # 6.2 MOTIF-BASED METHOD
158
+
159
+ Motifs have been proven to benefit many tasks from exploratory analysis to transfer learning (Henderson et al., 2012). Various algorithms have been proposed to exploit motifs for contrastive learning (Zhang et al., 2020a), self-supervised pretraining (Rong et al., 2020; Zhang et al., 2021), and generation (Jin et al., 2020). However, none of previous work tries to embody those informative motifs in their model architectures.
160
+
161
+ # 7 CONCLUSION
162
+
163
+ In this study, we present a universal neural architecture, Molformer, for 3D molecular representations. Our model extracts motifs with semantic meanings from each molecule based on functional groups and learn customized embeddings to facilitate property predictions. Moreover, it adopts a convolutional position encoding method to make a full use of spatial information and augments the self-attention mechanism with multiplicate scales to catch local features. Furthermore, a simple but efficient downsampling algorithm is introduced to better accumulate representations of an entire molecule. Our experiments show the superiority of our model on various scientific domains.
164
+
165
+ # REFERENCES
166
+
167
+ Namrata Anand-Achim, Raphael Ryuichi Eguchi, Irimpan I Mathews, Carla P Perez, Alexander Derry, Russ B Altman, and Possu Huang. Protein sequence design with a learned potential. bioRxiv, pp. 2020–01, 2021.
168
+
169
+ Brandon Anderson, Truong-Son Hy, and Risi Kondor. Cormorant: Covariant molecular neural networks. arXiv preprint arXiv:1906.04015, 2019.
170
+
171
+ Simon Axelrod and Rafael Gomez-Bombarelli. Geom: Energy-annotated molecular conformations for property prediction and molecular generation. arXiv preprint arXiv:2006.05531, 2020.
172
+
173
+ Minkyung Baek, Frank DiMaio, Ivan Anishchenko, Justas Dauparas, Sergey Ovchinnikov, Gyu Rie Lee, Jue Wang, Qian Cong, Lisa N. Kinch, R. Dustin Schaeffer, Claudia Millán, Hahnbeom Park, Carson Adams, Caleb R. Glassman, Andy DeGiovanni, Jose H. Pereira, Andria V. Rodrigues, Alberdina A. van Dijk, Ana C. Ebrecht, Diederik J. Opperman, Theo Sagmeister, Christoph Buhlheller, Tea Pavkov-Keller, Manoj K. Rathinaswamy, Udit Dalwadi, Calvin K. Yip, John E. Burke, K. Christopher Garcia, Nick V. Grishin, Paul D. Adams, Randy J. Read, and David Baker. Accurate prediction of protein structures and interactions using a three-track neural network. Science, 2021. ISSN 0036-8075. doi: 10.1126/science.abj8754.
174
+
175
+ Lorenz C Blum and Jean-Louis Reymond. 970 million druglike small molecules for virtual screening in the chemical universe database gdb-13. Journal of the American Chemical Society, 131(25): 8732–8733, 2009.
176
+
177
+ Yuchao Chai, Xue Han, Weiyao Li, Shanshan Liu, Sikai Yao, Chong Wang, Wei Shi, Ivan da Silva, Pascal Manuel, Yongqiang Cheng, et al. Control of zeolite pore interior for chemoselective alkyne/olefin separations. Science, 368(6494):1002–1006, 2020.
178
+
179
+ Benson Chen, Regina Barzilay, and Tommi Jaakkola. Path-augmented graph transformer network. arXiv preprint arXiv:1905.12712, 2019a.
180
+
181
+ Chao Chen, Guanbin Li, Ruijia Xu, Tianshui Chen, Meng Wang, and Liang Lin. Clusternet: Deep hierarchical cluster network with rigorously rotation-invariant representation for point cloud analysis. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 4994–5002, 2019b.
182
+
183
+ 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, 2019c.
184
+
185
+ Seyone Chithrananda, Gabriel Grand, and Bharath Ramsundar. Chemberta: Large-scale selfsupervised pretraining for molecular property prediction. arXiv preprint arXiv:2010.09885, 2020.
186
+
187
+ Hyeoncheol Cho and Insung S Choi. Three-dimensionally embedded graph convolutional network (3dgcn) for molecule interpretation. arXiv preprint arXiv:1811.09794, 2018.
188
+
189
+ Georgy Derevyanko, Sergei Grudinin, Yoshua Bengio, and Guillaume Lamoureux. Deep convolutional networks for quality assessment of protein folds. Bioinformatics, 34(23):4046–4053, 2018.
190
+
191
+ Philipp Dufter, Martin Schmitt, and Hinrich Schütze. Position information in transformers: An overview. arXiv preprint arXiv:2102.11090, 2021.
192
+
193
+ Stephan Eismann, Patricia Suriana, Bowen Jing, Raphael JL Townshend, and Ron O Dror. Protein model quality assessment using rotation-equivariant, hierarchical neural networks. arXiv preprint arXiv:2011.13557, 2020.
194
+
195
+ Stephan Eismann, Raphael JL Townshend, Nathaniel Thomas, Milind Jagota, Bowen Jing, and Ron O Dror. Hierarchical, rotation-equivariant neural networks to select structural models of protein complexes. Proteins: Structure, Function, and Bioinformatics, 89(5):493–501, 2021.
196
+
197
+ Fabian B Fuchs, Daniel E Worrall, Volker Fischer, and Max Welling. Se (3)-transformers: 3d rototranslation equivariant attention networks. arXiv preprint arXiv:2006.10503, 2020.
198
+
199
+ Kaitlyn M Gayvert, Neel S Madhukar, and Olivier Elemento. A data-driven approach to predicting successes and failures of clinical trials. Cell chemical biology, 23(10):1294–1301, 2016.
200
+
201
+ 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.
202
+
203
+ Meng-Hao Guo, Jun-Xiong Cai, Zheng-Ning Liu, Tai-Jiang Mu, Ralph R Martin, and Shi-Min Hu. Pct: Point cloud transformer. arXiv preprint arXiv:2012.09688, 2020a.
204
+
205
+ Qipeng Guo, Xipeng Qiu, Pengfei Liu, Xiangyang Xue, and Zheng Zhang. Multi-scale self-attention for text classification. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 34, pp. 7847–7854, 2020b.
206
+
207
+ Keith Henderson, Brian Gallagher, Tina Eliassi-Rad, Hanghang Tong, Sugato Basu, Leman Akoglu, Danai Koutra, Christos Faloutsos, and Lei Li. Rolx: structural role extraction & mining in large graphs. In Proceedings of the 18th ACM SIGKDD international conference on Knowledge discovery and data mining, pp. 1231–1239, 2012.
208
+
209
+ Adrián Hernández and José M Amigó. Attention mechanisms and their applications to complex systems. Entropy, 23(3):283, 2021.
210
+
211
+ Shion Honda, Shoi Shi, and Hiroki R Ueda. Smiles transformer: Pre-trained molecular fingerprint for low data drug discovery. arXiv preprint arXiv:1911.04738, 2019.
212
+
213
+ Weihua Hu, Matthias Fey, Marinka Zitnik, Yuxiao Dong, Hongyu Ren, Bowen Liu, Michele Catasta, and Jure Leskovec. Open graph benchmark: Datasets for machine learning on graphs. arXiv preprint arXiv:2005.00687, 2020.
214
+
215
+ Michael J Hutchinson, Charline Le Lan, Sheheryar Zaidi, Emilien Dupont, Yee Whye Teh, and Hyunjik Kim. Lietransformer: Equivariant self-attention for lie groups. In International Conference on Machine Learning, pp. 4533–4543. PMLR, 2021.
216
+
217
+ John Ingraham, Vikas K Garg, Regina Barzilay, and Tommi Jaakkola. Generative models for graphbased protein design. 2019.
218
+
219
+ Katsuhiko Ishiguro, Shin-ichi Maeda, and Masanori Koyama. Graph warp module: an auxiliary module for boosting the power of graph neural networks in molecular graph analysis. arXiv preprint arXiv:1902.01020, 2019.
220
+
221
+ José Jiménez, Miha Skalic, Gerard Martinez-Rosell, and Gianni De Fabritiis. K deep: protein–ligand absolute binding affinity prediction via 3d-convolutional neural networks. Journal of chemical information and modeling, 58(2):287–296, 2018.
222
+
223
+ Wengong Jin, Regina Barzilay, and Tommi Jaakkola. Hierarchical generation of molecular graphs using structural motifs. In International Conference on Machine Learning, pp. 4839–4848. PMLR, 2020.
224
+
225
+ Chaitanya Joshi. Transformers are graph neural networks. The Gradient, 2020.
226
+
227
+ John Jumper, Richard Evans, Alexander Pritzel, Tim Green, Michael Figurnov, Olaf Ronneberger, Kathryn Tunyasuvunakool, Russ Bates, Augustin Žídek, Anna Potapenko, Alex Bridgland, Clemens Meyer, Simon A A Kohl, Andrew J Ballard, Andrew Cowie, Bernardino RomeraParedes, Stanislav Nikolov, Rishub Jain, Jonas Adler, Trevor Back, Stig Petersen, David Reiman, Ellen Clancy, Michal Zielinski, Martin Steinegger, Michalina Pacholska, Tamas Berghammer, Sebastian Bodenstein, David Silver, Oriol Vinyals, Andrew W Senior, Koray Kavukcuoglu, Pushmeet Kohli, and Demis Hassabis. Highly accurate protein structure prediction with AlphaFold. Nature, 2021. doi: 10.1038/s41586-021-03819-2. (Accelerated article preview).
228
+
229
+ Mostafa Karimi, Di Wu, Zhangyang Wang, and Yang Shen. Deepaffinity: interpretable deep learning of compound–protein affinity through unified recurrent and convolutional neural networks. Bioinformatics, 35(18):3329–3338, 2019.
230
+
231
+ Steven Kearnes, Kevin McCloskey, Marc Berndl, Vijay Pande, and Patrick Riley. Molecular graph convolutions: moving beyond fingerprints. Journal of computer-aided molecular design, 30(8): 595–608, 2016.
232
+
233
+ Diederik P Kingma and Jimmy Ba. Adam: A method for stochastic optimization. arXiv preprint arXiv:1412.6980, 2014.
234
+
235
+ Thomas N Kipf and Max Welling. Semi-supervised classification with graph convolutional networks. arXiv preprint arXiv:1609.02907, 2016.
236
+
237
+ Johannes Klicpera, Shankari Giri, Johannes T Margraf, and Stephan Günnemann. Fast and uncertainty-aware directional message passing for non-equilibrium molecules. arXiv preprint arXiv:2011.14115, 2020.
238
+
239
+ Greg Landrum. Rdkit: A software suite for cheminformatics, computational chemistry, and predictive modeling, 2013.
240
+
241
+ Min Lin, Qiang Chen, and Shuicheng Yan. Network in network. arXiv preprint arXiv:1312.4400, 2013.
242
+
243
+ 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.
244
+
245
+ Chengqiang Lu, Qi Liu, Chao Wang, Zhenya Huang, Peize Lin, and Lixin He. Molecular property prediction: A multilevel quantum interactions modeling perspective. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 33, pp. 1052–1060, 2019.
246
+
247
+ Ines Filipa Martins, Ana L Teixeira, Luis Pinheiro, and Andre O Falcao. A bayesian approach to in silico blood-brain barrier penetration modeling. Journal of chemical information and modeling, 52(6):1686–1697, 2012.
248
+
249
+ Łukasz Maziarka, Tomasz Danel, Sławomir Mucha, Krzysztof Rataj, Jacek Tabor, and Stanisław Jastrz˛ebski. Molecule attention transformer. arXiv preprint arXiv:2002.08264, 2020.
250
+
251
+ Łukasz Maziarka, Dawid Majchrowski, Tomasz Danel, Piotr Gainski, Jacek Tabor, Igor Podolak, ´ Paweł Morkisz, and Stanisław Jastrz˛ebski. Relative molecule self-attention transformer. arXiv preprint arXiv:2110.05841, 2021.
252
+
253
+ Ron Milo, Shai Shen-Orr, Shalev Itzkovitz, Nadav Kashtan, Dmitri Chklovskii, and Uri Alon. Network motifs: simple building blocks of complex networks. Science, 298(5594):824–827, 2002.
254
+
255
+ Paul Morris, Rachel St. Clair, William Edward Hahn, and Elan Barenholtz. Predicting binding from screening assays with transformer network embeddings. Journal of Chemical Information and Modeling, 60(9):4191–4199, 2020.
256
+
257
+ Hakime Öztürk, Arzucan Özgür, and Elif Ozkirimli. Deepdta: deep drug–target binding affinity prediction. Bioinformatics, 34(17):i821–i829, 2018.
258
+
259
+ Guillaume Pagès, Benoit Charmettant, and Sergei Grudinin. Protein model quality assessment using 3d oriented convolutional neural networks. Bioinformatics, 35(18):3313–3319, 2019.
260
+
261
+ Xuran Pan, Zhuofan Xia, Shiji Song, Li Erran Li, and Gao Huang. 3d object detection with pointformer. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 7463–7472, 2021.
262
+
263
+ 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.
264
+
265
+ Giorgio Pesciullesi, Philippe Schwaller, Teodoro Laino, and Jean-Louis Reymond. Transfer learning enables the molecular transformer to predict regio-and stereoselective reactions on carbohydrates. Nature communications, 11(1):1–8, 2020.
266
+
267
+ Niklas Pfriem, Peter H Hintermeier, Sebastian Eckstein, Sungmin Kim, Qiang Liu, Hui Shi, Lara Milakovic, Yuanshuai Liu, Gary L Haller, Eszter Baráth, et al. Role of the ionic environment in enhancing the activity of reacting molecules in zeolite pores. Science, 372(6545):952–957, 2021.
268
+
269
+ Charles R Qi, Li Yi, Hao Su, and Leonidas J Guibas. Pointnet++: Deep hierarchical feature learning on point sets in a metric space. arXiv preprint arXiv:1706.02413, 2017.
270
+
271
+ Raghunathan Ramakrishnan, Pavlo O Dral, Matthias Rupp, and O Anatole von Lilienfeld. Quantum chemistry structures and properties of 134 kilo molecules. Scientific Data, 1, 2014.
272
+
273
+ Raghunathan Ramakrishnan, Mia Hartmann, Enrico Tapavicza, and O Anatole Von Lilienfeld. Electronic spectra from tddft and machine learning in chemical space. The Journal of chemical physics, 143(8):084111, 2015.
274
+
275
+ Bharath Ramsundar, Steven Kearnes, Patrick Riley, Dale Webster, David Konerding, and Vijay Pande. Massively multitask networks for drug discovery. arXiv preprint arXiv:1502.02072, 2015.
276
+
277
+ Roshan Rao, Nicholas Bhattacharya, Neil Thomas, Yan Duan, Xi Chen, John Canny, Pieter Abbeel, and Yun S Song. Evaluating protein transfer learning with tape. Advances in neural information processing systems, 32:9689, 2019.
278
+
279
+ Roshan Rao, Jason Liu, Robert Verkuil, Joshua Meier, John F Canny, Pieter Abbeel, Tom Sercu, and Alexander Rives. Msa transformer. bioRxiv, 2021.
280
+
281
+ 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.
282
+
283
+ Kristof T Schütt, Huziel E Sauceda, P-J Kindermans, Alexandre Tkatchenko, and K-R Müller. Schnet–a deep learning architecture for molecules and materials. The Journal of Chemical Physics, 148(24):241722, 2018.
284
+
285
+ Andrew W Senior, Richard Evans, John Jumper, James Kirkpatrick, Laurent Sifre, Tim Green, Chongli Qin, Augustin Žídek, Alexander WR Nelson, Alex Bridgland, et al. Improved protein structure prediction using potentials from deep learning. Nature, 577(7792):706–710, 2020.
286
+
287
+ 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.
288
+
289
+ Michael B Smith. March’s advanced organic chemistry: reactions, mechanisms, and structure. John Wiley & Sons, 2020.
290
+
291
+ Govindan Subramanian, Bharath Ramsundar, Vijay Pande, and Rajiah Aldrin Denny. Computational modeling of $\beta$ -secretase 1 (bace-1) inhibitors using ligand based approaches. Journal of chemical information and modeling, 56(10):1936–1949, 2016.
292
+
293
+ Gongbo Tang, Mathias Müller, Annette Rios, and Rico Sennrich. Why self-attention? a targeted evaluation of neural machine translation architectures. arXiv preprint arXiv:1808.08946, 2018.
294
+
295
+ 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.
296
+
297
+ Raphael Townshend, Rishi Bedi, Patricia Suriana, and Ron Dror. End-to-end learning on 3d protein structure for interface prediction. Advances in Neural Information Processing Systems, 32:15642– 15651, 2019.
298
+
299
+ Raphael JL Townshend, Martin Vögele, Patricia Suriana, Alexander Derry, Alexander Powers, Yianni Laloudakis, Sidhika Balachandar, Brandon Anderson, Stephan Eismann, Risi Kondor, et al. Atom3d: Tasks on molecules in three dimensions. arXiv preprint arXiv:2012.04035, 2020.
300
+
301
+ 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.
302
+
303
+ Petar Velickovi ˇ c, Guillem Cucurull, Arantxa Casanova, Adriana Romero, Pietro Lio, and Yoshua ´ Bengio. Graph attention networks. arXiv preprint arXiv:1710.10903, 2017.
304
+
305
+ Oriol Vinyals, Samy Bengio, and Manjunath Kudlur. Order matters: Sequence to sequence for sets. arXiv preprint arXiv:1511.06391, 2015.
306
+
307
+ Renxiao Wang, Xueliang Fang, Yipin Lu, Chao-Yie Yang, and Shaomeng Wang. The pdbbind database: methodologies and updates. Journal of medicinal chemistry, 48(12):4111–4119, 2005.
308
+
309
+ 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, pp. 7794–7803, 2018.
310
+
311
+ David Weininger. Smiles, a chemical language and information system. 1. introduction to methodology and encoding rules. Journal of chemical information and computer sciences, 28(1):31–36, 1988.
312
+
313
+ Yulun Wu, Nicholas Choma, Andrew Chen, Mikaela Cashman, Érica T Prates, Manesh Shah, Verónica G Melesse Vergara, Austin Clyde, Thomas S Brettin, Wibe A de Jong, et al. Spatial graph attention and curiosity-driven policy for antiviral drug discovery. arXiv preprint arXiv:2106.02190, 2021.
314
+
315
+ Zhenqin Wu, Bharath Ramsundar, Evan N Feinberg, Joseph Gomes, Caleb Geniesse, Aneesh S Pappu, Karl Leswing, and Vijay Pande. Moleculenet: a benchmark for molecular machine learning. Chemical science, 9(2):513–530, 2018.
316
+
317
+ Zhaoping Xiong, Dingyan Wang, Xiaohong Liu, Feisheng Zhong, Xiaozhe Wan, Xutong Li, Zhaojun Li, Xiaomin Luo, Kaixian Chen, Hualiang Jiang, et al. Pushing the boundaries of molecular representation for drug discovery with the graph attention mechanism. Journal of medicinal chemistry, 63(16):8749–8760, 2019.
318
+
319
+ Kevin Yang, Kyle Swanson, Wengong Jin, Connor Coley, Philipp Eiden, Hua Gao, Angel GuzmanPerez, Timothy Hopper, Brian Kelley, Miriam Mathea, et al. Analyzing learned molecular representations for property prediction. Journal of chemical information and modeling, 59(8):3370– 3388, 2019.
320
+
321
+ Chengxuan Ying, Tianle Cai, Shengjie Luo, Shuxin Zheng, Guolin Ke, Di He, Yanming Shen, and Tie-Yan Liu. Do transformers really perform bad for graph representation? arXiv preprint arXiv:2106.05234, 2021.
322
+
323
+ Haitao Zhang, Gye Won Han, Alexander Batyuk, Andrii Ishchenko, Kate L White, Nilkanth Patel, Anastasiia Sadybekov, Beata Zamlynny, Michael T Rudd, Kaspar Hollenstein, et al. Structural basis for selectivity and diversity in angiotensin ii receptors. Nature, 544(7650):327–332, 2017.
324
+
325
+ Shichang Zhang, Ziniu Hu, Arjun Subramonian, and Yizhou Sun. Motif-driven contrastive learning of graph representations. arXiv preprint arXiv:2012.12533, 2020a.
326
+
327
+ Shuo Zhang, Yang Liu, and Lei Xie. Molecular mechanics-driven graph neural network with multiplex graph for molecular structures. arXiv preprint arXiv:2011.07457, 2020b.
328
+
329
+ Zaixi Zhang, Qi Liu, Hao Wang, Chengqiang Lu, and Chee-Kong Lee. Motif-based graph selfsupervised learning for molecular property prediction. arXiv preprint arXiv:2110.00987, 2021.
330
+
331
+ Alex Zhavoronkov, Yan A Ivanenkov, Alex Aliper, Mark S Veselov, Vladimir A Aladinskiy, Anastasiya V Aladinskaya, Victor A Terentiev, Daniil A Polykovskiy, Maksim D Kuznetsov, Arip Asadulaev, et al. Deep learning enables rapid identification of potent ddr1 kinase inhibitors. Nature biotechnology, 37(9):1038–1040, 2019.
332
+
333
+ # A EXPERIMENTAL SETUP
334
+
335
+ A.1 EXPERIMENTAL DETAILS
336
+
337
+ Molformer Architecture. A standard Molformer has 6 multi-scale self-attention layers, and each layer has 3 scales and 8 heads. Normally, scales are set by $\tau = [ \frac { \rho } { 2 } , \rho , 2 \rho ]$ , where $\rho$ is the density of each corresponding dataset. The number of selected atoms $K$ and the weight ratio $\epsilon$ in AFPS is set as 4 and 0.1, respectively. We use ReLU as the activation function and a dropout rate of 0.1 for all layers. The input embedding size is 512 and the hidden size for FFN is 2048.
338
+
339
+ For BBBP and ClinTox, we use Molformer with 2 multi-scale self-attention layers with 4 heads. The scales are 0.8, 1.6, and $3 . 0 \mathring \mathrm { A }$ . The dropout rate is 0.2 and 0.6 for BBBP and ClinTox, respectively. For BACE, we use a standard Molformer but with a dropout rate of 0.2.
340
+
341
+ Training Details. We use Pytorch (Paszke et al., 2019) to implement Molformer and data parallelism in two GeForce RTX 3090. An Adam (Kingma & Ba, 2014) optimizer is used and a lambda scheduler is enforced to adjust it. We apply no weight decay there. Each model is trained with 300 epochs, except for PDBbind where we solely train the model for 30 epochs. For QM7 and QM8, we use a batch size of 64 and a learning rate of $\mathrm { 1 0 ^ { - 4 } }$ . For QM9, we use a batch size of 256 and a learning rate of $1 0 ^ { - 3 }$ . All hyper-parameters are tuned based on validation sets. For all molecular datasets, we impose no limitation on the input length and normalise the values of each regression task by mean and the standard deviation of the training set. We used grid search to tune the hyper-parameters of our model and baselines based on the validation dataset.
342
+
343
+ Motif Generation. We adopt RDKit (Landrum, 2013) to search motifs. However, QM8 and QM9 do not provide SMILES representations but only 3D coordinates, thus we cannot pull out motifs from these datasets. As for PDBbind, we only extract motifs of small molecules and leave out motifs in proteins.
344
+
345
+ # B ADDITIONAL EXPERIMENTAL RESULTS
346
+
347
+ # B.1 CONFORMATION CLASSIFICATION
348
+
349
+ Task and Data. In order to explore the influence of multiple conformations, we introduce a new task, conformation classification, to evaluate model’s capacity to differentiate molecules with various low-energy conformations. We use the recent GEOM-QM9 (Axelrod & Gomez-Bombarelli, 2020) experiments. More specifically, GEOM-QM9 is an extension to QM9 dataset. It contains multiple conformations for most molecules, while the original QM9 only contains one.
350
+
351
+ We randomly draw 1000 different molecules from GEOM-QM9, each with 20 different conformations. Models are required to distinguish the molecular type given different conformations. We take a half of each molecular conformations as the training set and another half as the test split. Since it is a multi-class classification problem with 1000 classes, we compute the micro-average and macro-average ROC-AUC as well as the accuracy for numerical evaluations.
352
+
353
+ Results. Molformer achieves a micro-average and macro-average ROC-AUC of 1.0 and 1.0, and an accuracy of 0.999. This indicates strong robustness of our model against different spatial conformations of molecules.
354
+
355
+ # B.2 AFPS VS. FPS.
356
+
357
+ To have a vivid understanding of the atom sampling algorithm, we conducted a case study on a random crystal (see Figure 3). Points selected by FPS are randomized and exclude vital atoms like the heavy metal Nickel (Ni). With the adoption of AFPS, sampled points include Ni and Nitrogen (N) besides that they keep remote distances from each other. Moreover, FPS integrates too many features of trivial atoms like Hydrogen $\mathrm { ( H ) }$ while misses out key atoms, which will significantly smooth the molecular representations and lead to poor predictions. This illustrative example firmly shows the effectiveness of our AFPS to offset disadvantages of the conventional FPS in 3D molecular representation.
358
+
359
+ ![](images/52db107ed4cdb54efeadb60117f2a9a2423059ba34e09a70a0640e07dd25a710.jpg)
360
+ Figure 3: Sampled points using FPS and AFPS. We do not show dummy nodes there.
md/dev/7r6kDq0mK_/7r6kDq0mK_.md ADDED
@@ -0,0 +1,396 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # LATENT IMAGE ANIMATOR: LEARNING TO ANIMATE IMAGES VIA LATENT SPACE NAVIGATION
2
+
3
+ Yaohui Wang, Di Yang, Francois Bremond & Antitza Dantcheva Inria, Universite C´ ote d’Azur ˆ {yaohui.wang,di.yang,francois.bremond,antitza.dantcheva}@inria.fr
4
+
5
+ # ABSTRACT
6
+
7
+ Due to the remarkable progress of deep generative models, animating images has become increasingly efficient, whereas associated results have become increasingly realistic. Current animation-approaches commonly exploit structure representation extracted from driving videos. Such structure representation is instrumental in transferring motion from driving videos to still images. However, such approaches fail in case the source image and driving video encompass large appearance variation. Moreover, the extraction of structure information requires additional modules that endow the animation-model with increased complexity. Deviating from such models, we here introduce the Latent Image Animator (LIA), a self-supervised autoencoder that evades need for structure representation. LIA is streamlined to animate images by linear navigation in the latent space. Specifically, motion in generated video is constructed by linear displacement of codes in the latent space. Towards this, we learn a set of orthogonal motion directions simultaneously, and use their linear combination, in order to represent any displacement in the latent space. Extensive quantitative and qualitative analysis suggests that our model systematically and significantly outperforms state-of-art methods on VoxCeleb, Taichi and TED-talk datasets w.r.t. generated quality. Source code and pre-trained models are publicly available1.
8
+
9
+ ![](images/e378522fe7bd0a0020ce31d5201a8ccda8a4e2a620417861db6f080cf4f0c4a2.jpg)
10
+ Figure 1: LIA animation examples. The two images of Marilyn Monroe and Emmanuel Macron are animated by LIA, which transfers motion of a driving video (smaller images on the top) from VoxCeleb dataset (Chung et al., 2018) onto the still images. LIA is able to successfully animate these two images without relying on any explicit structure representations, such as landmarks and region representations.
11
+
12
+ # 1 INTRODUCTION
13
+
14
+ In the series of science fiction books Harry Potter (Rowling et al., 2016; Rowling, 2019), wizards and witches were able to magically enchant portraits, bringing them to life. Remarkable progress of deep generative models has recently turned this vision into reality. This work examines the scenario where a framework animates a source image by motion representations learned from a driving video. Existing approaches for image animation are classically related to computer graphics (Cao et al., 2014; Thies et al., 2016; 2019; Zhao et al., 2018) or exploit motion labels (Wang et al., 2020b) and structure representations such as semantic maps (Pan et al., 2019; Wang et al., 2018; 2019), human keypoints (Jang et al., 2018; Yang et al., 2018; Walker et al., 2017; Chan et al., 2019; Zakharov et al., 2019; Wang et al., 2019; Siarohin et al., 2019), 3D meshes (Liu et al., 2019; Chen et al., 2021), and optical flows (Li et al., 2018; Ohnishi et al., 2018). We note that the ground truth of such structure representations has been computed a-priori for the purpose of supervised training, which poses constraints on applications, where such representations of unseen testing images might be fragmentary or difficult to access.
15
+
16
+ Self-supervised motion transfer approaches (Wiles et al., 2018; Siarohin et al., 2019; 2021) accept raw videos as input and learn to reconstruct driving images by warping source image with predicted dense optical flow fields. While the need for domain knowledge or labeled ground truth data has been obviated, which improves performance on in-the-wild testing images, such methods entail necessity of explicit structure representations as motion guidance. Prior information such as keypoints (Siarohin et al., 2019; Wang et al., 2021a) or regions (Siarohin et al., 2021) are learned in an end-to-end training manner by additional networks as intermediate features, in order to predict target flow fields. Although online prediction of such representations is less tedious than the acquisition of ground truth labels, it still strains the complexity of networks.
17
+
18
+ Deviating from such approaches, we here aim to fully eliminate the need of explicit structure representations by directly manipulating the latent space of a deep generative model. To the best of our knowledge, this constitutes a new direction in the context of image animation. Our work is motivated by interpretation of GANs (Shen et al., 2020; Goetschalckx et al., 2019; Jahanian et al., 2020; Voynov & Babenko, 2020), showcasing that latent spaces of StyleGAN (Karras et al., 2019; 2020b) and BigGAN (Brock et al., 2019) contain rich semantically meaningful directions. Given that walking along such directions, basic visual transformations such as zooming and rotation can be induced in generated results. As in image animation, we have that motion between source and driving images can be considered as higher-level transformation, a natural question here arises: can we discover a set of directions in the latent space that induces high-level motion transformations collaboratively?
19
+
20
+ Towards answering this question, we introduce LIA, a novel Latent Image Animator constituting of an autoencoder for animating still images via latent space navigation. LIA seeks to animate a source image via linearly navigating associated source latent code along a learned path to reach a target latent code, which represents the high-level transformation for animating the source image. We introduce a Linear Motion Decomposition (LMD) approach aiming to represent a latent path via a linear combination of a set of learned motion directions and associated magnitudes. Specifically, we constrain the set as an orthogonal basis, where each vector indicates a basic visual transformation. By describing the whole motion space using such learned basis, LIA eliminates the requirement of explicit structure representations.
21
+
22
+ In addition, we design LIA to disentangle motion and appearance within a single encoder-generator architecture. Deviating from existing methods using separate networks to learn disentangled features, LIA integrates both, latent motion code, as well as appearance features in a single encoder, which highly reduces the model complexity and simplifies training.
23
+
24
+ We provide evaluation on multiple datasets including VoxCeleb (Chung et al., 2018), TaichiHD (Siarohin et al., 2019) and TED-talk (Siarohin et al., 2021). In addition, we show that LIA outperforms the state-of-the-art in preserving the facial structure in generated videos in the setting of one-shot image animation on unseen datasets such as FFHQ (Karras et al., 2019) and GermanPublicTV (Thies et al., 2020).
25
+
26
+ # 2 RELATED WORK
27
+
28
+ Video generation GAN-based video generation is aimed at mapping Gaussian noise to video, directly and in the absence of prior information (Vondrick et al., 2016; Saito et al., 2017; Tulyakov et al., 2018; Wang et al., 2020a; Wang, 2021). Approaches based on deep probabilistic models (Denton & Birodkar, 2017; Li & Mandt, 2018; Bhagat et al., 2020; Xie et al., 2020) were also proposed to tackle this problem, however only show results on toy datasets with low resolution. Recently, with the progress of GANs in photo-realistic image generation (Brock et al., 2019; Karras et al., 2019; 2020a), a series of works (Clark et al., 2019; Wang et al., 2021c) explored production of highresolution videos by incorporating the architecture of an image generator into video GANs, trained jointly with RNNs. Tian et al. (2021) directly leveraged the knowledge of a pre-trained StyleGAN to produce videos of resolution up to $1 0 2 4 \times \mathrm { i } 0 2 4$ . Unlike these approaches, which generate random videos based on noise vectors in an unconditional manner, in this paper, we focus on conditionally creating novel videos by transferring motion from driving videos to input images.
29
+
30
+ ![](images/adf402bc242a87960126961b2dd01a4fedaa5916e13c5407ab9a2e27d13beee5.jpg)
31
+ Figure 2: General pipeline. Our objective is to transfer motion via latent space navigation. The entire training pipeline consists of two steps. Firstly, we encode a source image $x _ { s }$ into a latent code $z _ { s r }$ . By linearly navigating $z _ { s r }$ along a path $w _ { r \to d }$ , we reach a target latent code $z _ { s d }$ . The latent paths are represented by a linear combination between a set of learned motion directions (e.g., $d _ { 1 }$ and $d _ { 2 }$ ), which is an orthogonal basis, and associated magnitudes. In the second step, we decode $z _ { s d }$ to a target dense optical flow field $\phi _ { s d }$ , which is used to warp $x _ { s }$ into the driving image $x _ { d }$ . While we train our model using images from the same video sequence, in the testing phase, $x _ { s }$ and $x _ { d }$ generally pertain to different identities.
32
+
33
+ Latent space editing In an effort to control generated images, recent works explored the discovery of semantically meaningful directions in the latent space of pre-trained GANs, where linear navigation corresponds to desired image manipulation. Supervised (Shen et al., 2020; Jahanian et al., 2020; Goetschalckx et al., 2019) and unsupervised (Voynov & Babenko, 2020; Peebles et al., 2020; Shen & Zhou, 2021) approaches were proposed to edit semantics such as facial attributes, colors and basic visual transformations (e.g., rotation and zooming) in generated or inverted real images (Zhu et al., 2020; Abdal et al., 2020). In this work, as opposed to finding directions corresponding to individual visual transformations, we seek to learn a set of directions that cooperatively allows for high-level visual transformations that can be beneficial in image animation.
34
+
35
+ Image animation Related approaches (Chan et al., 2019; Wang et al., 2018; Zakharov et al., 2019; Wang et al., 2019; Yang et al., 2020) in image animation required strong prior structure labels as motion guidance. In particular, Chan et al. (2019), Yang et al. (2020) and Wang et al. (2018) proposed to map representations such as human keypoints and facial landmarks to videos in the setting of image-to-image translation proposed by Isola et al. (2017). However, such approaches were only able to learn an individual model for a single identity. Transferring motion on new appearances requires retraining the entire model from scratch by using videos of target identities. Several recent works (Zakharov et al., 2019; Wang et al., 2019) explored meta learning in fine-tuning models on target identities. While only few images of target identities were required during inference time, it was still compulsory to input pre-computed structure representations in those approaches, which usually are hard to access in many real-world scenarios. Towards addressing this issue, very recent works (Siarohin et al., 2019; 2021; Wang et al., 2021b; Wiles et al., 2018) proposed to learn image animation in self-supervised manner, only relying on RGB videos for both, training and testing without any priors. They firstly predicted dense flow fields from input images, which were then utilized to warp source images, in order to obtain final generated results. Inference only required one image of a target identity without any fine-tuning step on pre-trained models. While no priors were required, state-of-the-art methods still followed the idea of using explicit structure representations. FOMM (Siarohin et al., 2019) proposed a first order motion approach to predict keypoints and local transformations online to generate flow fields. Siarohin et al. (2021) developed this idea to model articulated objects by replacing a keypoints predictor by a PCA-based region prediction module. Wang et al. (2021b) extended FOMM by predicting 3D keypoints for view-free generation. We note though that in all approaches, given that keypoints or regions are inadequately predicted, the quality of generated images drastically decreases. In contrast to such approaches, our method does not require any explicit structure representations. We dive into the latent space of the generator and self-learn to navigate motion codes in certain directions with the goal to reach target codes, which are then decoded to flow fields for warping.
36
+
37
+ ![](images/203fe2748a461292b0737c6c4a21c45cb5adc8b929922aec910a81a2c52ff5dd.jpg)
38
+ Figure 3: Overview of LIA. LIA is an autoencoder consisting of two networks, an encoder $E$ and a generator $G$ . In the latent space, we apply Linear Motion Decomposition (LMD) towards learning a motion dictionary $D _ { m }$ , which is an orthogonal basis where each vector represents a basic visual transformation. LIA takes two frames sampled from the same video sequence as source image $x _ { s }$ and driving image $x _ { d }$ respectively during training. Firstly, it encodes $x _ { s }$ into a source latent code $z _ { s r }$ and $x _ { d }$ into a magnitude vector $\bar { A _ { r \to d } }$ . Then, it linearly combines $A _ { r d }$ and a trainable $D _ { m }$ using LMD to obtain a latent path $w _ { r \to d }$ , which is used to navigate $z _ { s _ { } r }$ to a target code $z _ { s d }$ . Finally, $G$ decodes $z _ { s d }$ into a target dense flow field and warps $x _ { s }$ to an output image $x _ { s \to d }$ . The training objective is to reconstruct $x _ { d }$ using $x _ { s \to d }$ .
39
+
40
+ # 3 METHOD
41
+
42
+ Self-supervised image animation aims at learning to transfer motion from a subject of a driving video to a subject in a source image based on training with a large video dataset. In this work, we propose to model such motion transformation via latent space navigation. The general pipeline is illustrated in Fig. 2. Specifically, for training, our model takes in a pair of source and driving images, randomly sampled from one video sequence. These two images are encoded into a latent code which is used to represent motion transformation in the image space. The training objective is to reconstruct the driving image by combining source image with learned motion transformation. For testing, frames of a driving video are sequentially processed with the source image to animate the source subject.
43
+
44
+ We provide an overview of the proposed model in Fig. 3. Our model is an autoencoder, consisting of two main networks, an encoder $\bar { E }$ and a generator $\bar { G }$ . In general, our model requires two steps to transfer motion. In the first step, $E$ encodes source and driving images $\boldsymbol { x } _ { s } , \boldsymbol { x } _ { d } \sim \dot { \mathcal { X } } \in \mathbb { R } ^ { 3 \times H \times W }$ into latent codes in the latent space. The source code is then navigated into a target code, which is used to represent target motion transformation, along a learned latent path. Based on proposed Linear Motion Decomposition (LMD), we represent such a path as a linear combination of a set of learned motion directions and associated magnitudes, which are learned from $x _ { d }$ . In the second step, once the target latent code is obtained, $G$ decodes it as a dense flow field $\phi _ { s \to d } \sim \Phi \in \mathbb { R } ^ { 2 \times H \times W }$ and uses $\bar { \phi _ { s \to d } }$ to warp $x _ { s }$ and then to obtain the output image. In the following, we proceed to discuss the two steps in detail.
45
+
46
+ # 3.1 LATENT MOTION REPRESENTATION
47
+
48
+ Given a source image $x _ { s }$ and a driving image $x _ { d }$ , our first step constitutes of learning a latent code $z _ { s \to d } \sim \mathcal { Z } \in \mathbb { R } ^ { N }$ to represent the motion transformation from $x _ { s }$ to $x _ { d }$ . Due to the uncertainty of two images, directly learning $z _ { s d }$ puts forward a high requirement on the model to capture a complex distribution of motion. Mathematically, it requires modeling directions and norms of the vector $z _ { s d }$ simultaneously, which is challenging. Therefore, instead of modeling motion transformation $x _ { s } \to x _ { d }$ , we assume there exists a reference image $x _ { r }$ and motion transfer can be modeled as $x _ { s } x _ { r } x _ { d }$ , where $z _ { s d }$ is learned in an indirect manner. We model $z _ { s d }$ as a target point in the latent space, which can be reached by taking linear walks from a starting point $z _ { s r }$ along a linear path $w _ { r \to d }$ (see Fig. 2), given by
49
+
50
+ $$
51
+ z _ { s d } = z _ { s r } + w _ { r d } ,
52
+ $$
53
+
54
+ where $z _ { s r }$ and $w _ { r \to d }$ indicate the transformation $x _ { s } \to x _ { r }$ and $x _ { r } \to x _ { d }$ respectively. Both $z _ { s r }$ and $w _ { r \to d }$ are learned independently and $z _ { s r }$ is obtained by passing $x _ { s }$ through $E$ .
55
+
56
+ We learn $w _ { r \to d }$ via Linear Motion Decomposition (LMD). Our idea is to learn a set of motion directions $D _ { m } = \{ \mathbf { d _ { 1 } } , . . . , \mathbf { d _ { M } } \}$ to represent any path in the latent space. We constrain $D _ { m }$ as an orthogonal basis, where each vector indicates a motion direction $\mathbf { d _ { i } }$ . We then combine each vector in the basis with a vector $A _ { r d } = \{ a _ { 1 } , . . . , a _ { M } \}$ , where $a _ { i }$ represents the magnitude of $\mathbf { d _ { i } }$ . Hence, any linear path in the latent space can be represented using a linear combination
57
+
58
+ $$
59
+ w _ { r d } = \sum _ { i = 1 } ^ { M } a _ { i } { \bf d _ { i } } ,
60
+ $$
61
+
62
+ where $\mathbf { d } _ { \mathbf { i } } \in \mathbb { R } ^ { N }$ and $a _ { i } \in \mathbb { R }$ for all $i \in \{ 1 , . . . , M \}$ . Semantically, each $\mathbf { d _ { i } }$ should represent a basic visual transformation and $a _ { i }$ indicates the required steps to walk in $\mathbf { d _ { i } }$ towards achieving $w _ { r \to d }$ . Due to $D _ { m }$ entailing an orthogonal basis, any two directions $\mathbf { d } _ { \mathrm { i } } , \mathbf { d } _ { \mathrm { j } }$ follow the constrain
63
+
64
+ $$
65
+ < { \bf d _ { i } } , { \bf d _ { j } } > = \left\{ \begin{array} { c c } { { 0 } } & { { i \neq j } } \\ { { 1 } } & { { i = j . } } \end{array} \right.
66
+ $$
67
+
68
+ We implement $D _ { m }$ as a learnable matrix and apply the Gram-Schmidt process during each forward pass, in order to meet the requirement of orthogonality. $A _ { r d }$ is obtained by mapping $z _ { d r }$ , which is the output of $x _ { d }$ after $E$ , through a 5-layer MLP. The final formulation of latent motion representation for each $x _ { s }$ and $x _ { d }$ is thus given as
69
+
70
+ $$
71
+ z _ { s d } = z _ { s r } + \sum _ { i = 1 } ^ { M } a _ { i } { \bf d _ { i } } .
72
+ $$
73
+
74
+ # 3.2 LATENT CODE DRIVEN IMAGE ANIMATION
75
+
76
+ Once we obtain $z _ { s d }$ , in our second step, we use $G$ to decode a flow field $\phi _ { s \to d }$ and warp $x _ { s }$ . Our $G$ consists of two components, a flow field generator $G _ { f }$ and a refinement network $G _ { r }$ (we provide details in App. A).
77
+
78
+ Towards learning multi-scale features, $G$ is designed as a residual network containing $N$ models to produce a pyramid of flow fields $\phi _ { s \to d } = \{ \bar { \phi _ { i } } \bar \} _ { 1 } ^ { N }$ in different layers of $G _ { f }$ . Multi-scale source features $x _ { s } ^ { e n c } = \{ x _ { i } ^ { e n c } \} _ { 1 } ^ { N }$ are obtained from $E$ and are warped in $G _ { f }$ .
79
+
80
+ However, as pointed out by Siarohin et al. (2019), only relying on $\phi _ { s \to d }$ to warp source features is insufficient to precisely reconstruct driving images due to the existing occlusions in some positions of $x _ { s }$ . In order to predict pixels in those positions, the network is required to inpaint the warped feature maps. Therefore, we predict multi-scale masks $\{ m _ { i } \} _ { 1 } ^ { N }$ along with $\{ \phi _ { i } \} _ { 1 } ^ { N }$ in $G _ { f }$ to mask out the regions required to be inpainted. In each residual module, we have
81
+
82
+ $$
83
+ x _ { i } ^ { \prime } = \mathcal { T } ( \phi _ { i } , x _ { i } ^ { e n c } ) \odot m _ { i } ,
84
+ $$
85
+
86
+ where $\odot$ denotes the Hadamard product and $\tau$ denotes warping operation, whereas $\boldsymbol { x } _ { i } ^ { \prime }$ signifies the masked features. We generate both dense flow fields, as well as masks by letting each residual module output a 3-channel feature map in which the first two channels represent ${ \bar { \phi } } _ { i }$ and the last channel $m _ { i }$ . Based on an inpainted feature map $f ( x _ { i } ^ { \prime } )$ , as well as an upsampled image $g ( x _ { i - 1 } )$ provided by the previous module in $G _ { r }$ , the RGB image from each module is given by
87
+
88
+ $$
89
+ o _ { i } = f ( x _ { i } ^ { \prime } ) + g ( o _ { i - 1 } ) ,
90
+ $$
91
+
92
+ where $f$ and $g$ denote the inpainting and upsampling layers, respectively. The output image $o _ { N }$ from the last module constitutes the final generated image $x _ { s \to d } = o _ { N }$ .
93
+
94
+ # 3.3 LEARNING
95
+
96
+ We train LIA in a self-supervised manner to reconstruct $x _ { d }$ using three losses, i.e., a reconstruction loss $\mathcal { L } _ { r e c o n }$ , a perceptual loss $\mathcal { L } _ { v g g }$ (Johnson et al., 2016) and an adversarial loss $\mathcal { L } _ { a d v }$ . We use $\mathcal { L } _ { r e c o n }$ to minimize the pixel-wise $\mathbb { L } _ { 1 }$ distance between $x _ { d }$ and $x _ { s \to d }$ , calculated as
97
+
98
+ $$
99
+ \mathcal { L } _ { r e c o n } ( x _ { s d } , x _ { d } ) = \mathbb { E } [ \| x _ { d } - x _ { s d } \| _ { 1 } ] .
100
+ $$
101
+
102
+ Towards minimizing the perceptual distance, we apply a VGG19-based $\mathcal { L } _ { v g g }$ on multi-scale feature maps between real and generated images, written as
103
+
104
+ $$
105
+ \mathcal { L } _ { v g g } ( x _ { s d } , x _ { d } ) = \mathbb { E } [ \sum _ { n } ^ { N } \| F _ { n } ( x _ { d } ) - F _ { n } ( x _ { s d } ) \| _ { 1 } ] ,
106
+ $$
107
+
108
+ where $F _ { n }$ denotes the $n ^ { t h }$ layer in a pre-trained VGG19 (Simonyan & Zisserman, 2015). In practice, towards penalizing real and generated images in multi-scale images, we use a pyramid of four resolutions, namely $2 5 6 \times 2 5 6$ , ${ \bar { 1 } } 2 8 \times 1 2 8$ , $6 4 \times 6 4$ and $3 2 \times 3 2$ as inputs of VGG19. The final perceptual loss is the addition of perceptual losses in four resolutions.
109
+
110
+ Further, towards generating photo-realistic results, we incorporate a non-saturating adversarial loss $\mathcal { L } _ { a d v }$ on $x _ { s \to d }$ , which is calculated as
111
+
112
+ $$
113
+ \mathcal { L } _ { a d v } ( x _ { s d } ) = \mathbb { E } _ { x _ { s d } \sim p _ { r e c } } [ - l o g ( D ( x _ { s d } ) ] ,
114
+ $$
115
+
116
+ where $D$ is a discriminator, aimed at distinguishing reconstructed images from the original ones. Our full loss function is the combination of three losses with $\lambda$ as a balanced hyperparameter
117
+
118
+ $$
119
+ { \mathcal { L } } ( x _ { s d } , x _ { d } ) = { \mathcal { L } } _ { r e c o n } ( x _ { s d } , x _ { d } ) + \lambda { \mathcal { L } } _ { v g g } ( x _ { s d } , x _ { d } ) + { \mathcal { L } } _ { a d v } ( x _ { s d } ) .
120
+ $$
121
+
122
+ # 3.4 INFERENCE
123
+
124
+ In inference stage, given a driving video sequence $V _ { d } = \{ x _ { t } \} _ { 1 } ^ { T }$ , we aim to transfer motion from $V _ { d }$ to $x _ { s }$ , in order to generate a novel video $V _ { d s } = \{ x _ { t s } \} _ { 1 } ^ { T }$ . If $V _ { d }$ and $x _ { s }$ stem from the same video sequence, i.e., $x _ { s } ~ = ~ x _ { 1 }$ , our task comprises of reconstructing the entire original video sequence. Therefore, we construct the latent motion representation of each frame using absolute transfer, which follows the training process, given as
125
+
126
+ $$
127
+ z _ { s t } = z _ { s r } + w _ { r t } , t \in \{ 1 , . . . , T \} .
128
+ $$
129
+
130
+ However, in real world applications, interest is rather placed on the scenario, where motion transfer between $x _ { s }$ and $V _ { d }$ , the latter stemming from different identities, i.e., $x _ { s } \neq x _ { 1 }$ . Taking a talking head video as an example, in this setting, beyond identity, $x _ { 1 }$ and $x _ { s }$ might also differ in pose and expression. Therefore, we propose relative transfer to eliminate the motion impact of $w _ { r \to 1 }$ and involve motion of $w _ { r \to s }$ in the full generated video sequence. Owing to a linear representation of the latent path, we can easily represent $z _ { s t }$ for each frame as
131
+
132
+ $$
133
+ \begin{array} { r l } & { z _ { s t } = ( z _ { s r } + w _ { r s } ) + ( w _ { r t } - w _ { r 1 } ) } \\ & { \qquad = z _ { s s } + ( w _ { r t } - w _ { r 1 } ) , \ t \in \{ 1 , . . . , T \} . } \end{array}
134
+ $$
135
+
136
+ The first term in Eq. (12), $z _ { s s }$ indicates the reconstruction of $x _ { s }$ , while the second term $( w _ { r t } - w _ { r 1 } )$ represents the motion from $x _ { 1 }$ to $x _ { t }$ . This equation indicates that the original pose is preserved in $x _ { s }$ , at the same time motion is transferred from $V _ { d }$ . We note that in order to completely replicate the position and pose in $V _ { d }$ , it requires $x _ { s }$ and $x _ { 1 }$ to contain similar poses in relative motion transfer.
137
+
138
+ # 4 EXPERIMENTS
139
+
140
+ In this section, we firstly describe our experimental setup including implementation details and datasets. Secondly, we qualitatively demonstrate generated results based on testing datasets. Then, we provide quantitative evaluation w.r.t. image quality on (a) same-identity reconstruction, (b) crossvideo motion transfer, presenting (c) a user study. Next, we conduct an ablation study that demonstrates (d) the effectiveness of our proposed motion dictionary, as well as (e) associated size. Finally, we provide an in-depth analysis of our (f) latent codes and (g) motion dictionary to interpret their semantic meanings.
141
+
142
+ Datasets Our model is trained on the datasets VoxCeleb, TaichiHD and TED-talk. We follow the pre-processing method in (Siarohin et al., 2019) to crop frames into $2 5 6 \times 2 5 6$ resolution for quantitative evaluation.
143
+
144
+ Implementation details Our model is implemented in PyTorch (Paszke et al., 2019). All models are trained on four 16G NVIDIA V100 GPUs. The total batch size is 32 with 8 images per GPU. We use a learning rate of 0.002 to train our model with the Adam optimizer (Kingma & Ba, 2014). The dimension of all latent codes, as well as directions in $D _ { m }$ is set to be 512. In our loss function, we use $\lambda = 1 0$ in order to penalize more on the perceptual loss. It takes around 150 hours to fully train our framework.
145
+
146
+ ![](images/a37a7371bb03be1d7874e44a06664ca4dc3ef0bc6d060aab959b38245f9df2b2.jpg)
147
+ Figure 4: Qualitative results. Examples for same-dataset absolute motion transfer on TaichiHD (top-right) and TED-talk (bottom-right). On VoxCeleb (left), we demonstrate cross-dataset relative motion transfer. We successfully transfer motion between $x _ { 1 }$ and $x _ { t }$ from videos in VoxCeleb to $x _ { s }$ from FFHQ, the latter not being used for training.
148
+
149
+ Evaluation metrics We evaluate our model w.r.t. (i) reconstruction faithfulness using $\mathcal { L } _ { 1 }$ , LPIPS, (ii) generated video quality using video FID, as well as (iii) semantic consistency using average keypoint distance (AKD), missing keypoint rate (MKR) and average euclidean distance (AED). Details are available in App. B.2.
150
+
151
+ # 4.1 QUALITATIVE RESULTS
152
+
153
+ Firstly, we evaluate the ability of LIA to generate realistic videos and compare related results with four state-of-the-art methods. For TaichiHD and TED-talk datasets, we conduct an experiment related to cross-video generation. Corresponding results (see Fig. 4) confirm that our method is able to correctly transfer motion on articulated human bodies, in the absence of explicit structure representations. For the VoxCeleb dataset, we conduct a cross-dataset generation-experiment, where we transfer motion from VoxCeleb to images of the FFHQ dataset. We observe that our method outperforms FOMM and MRAA w.r.t. image quality, as both approaches visibly deform the shape of the original faces. This is specifically notable in the case that source and driving images entail large pose variations. At the same time, LIA is able to successfully tackle this challenge and no similar deformations are visible.
154
+
155
+ # 4.2 COMPARISON WITH STATE-OF-THE-ART METHODS
156
+
157
+ We quantitatively compare our method with the state-of-the-art approaches X2Face, Monkey-Net, FOMM and MRAA on two tasks, namely (a) same-identity reconstruction and (b) cross-video motion transfer. Additionally, we conduct a (c) user study.
158
+
159
+ (a) Same-identity reconstruction We here evaluate the reconstruction ability of our method. Specifically, we reconstruct each testing video by using the first frame as $x _ { s }$ and the remaining frames as $x _ { d }$ . Results on three datasets are reported in Table 1. Focusing on foregroundreconstruction, our method outperforms the other approaches w.r.t. all metrics. More results are presented in App. B.3, discussing background-reconstruction.
160
+
161
+ (b) Cross-video motion transfer Next, we conduct experiments, where source images and driving videos stem from different video sequences. In this context, we mainly focus on evaluating talking head videos and explore two different cases. In the first case, we generate videos using the VoxCeleb testing set to conduct motion transfer. In the second case, source images are from an unseen dataset, namely the GermanPublicTV dataset, as we conduct cross-dataset motion transfer. In both experiments, we randomly construct source and driving pairs and transfer motion from driving videos to source images to generate a novel manipulated dataset. Since ground truth data for our generated videos is not available, we use video FID (as initialized by Wang et al. (2020a)) to compute the distance between generated and real data distributions. As shown in Tab. 2, our method outperforms all other approaches w.r.t. video FID, indicating the best generated video quality.
162
+
163
+ Table 1: Same-identity reconstruction. Comparison with state-of-the-art methods on three datasets for same-identity reconstruction.
164
+
165
+ <table><tr><td rowspan="2">Method</td><td colspan="4">VoxCeleb</td><td colspan="4">TaichiHD</td><td colspan="4">TED-talks</td></tr><tr><td>L1</td><td>AKD</td><td>AED</td><td>LPIPS</td><td>L1</td><td>(AKD,MKR)</td><td>AED</td><td>LPIPS</td><td>L1</td><td>(AKD,MKR)</td><td>AED</td><td>LPIPS</td></tr><tr><td>X2Face</td><td>0.078</td><td>7.687</td><td>0.405</td><td>-</td><td>0.080</td><td>(17.654,0.109)</td><td></td><td>-</td><td>=</td><td></td><td></td><td>-</td></tr><tr><td>Monkey-Net</td><td>0.049</td><td>1.878</td><td>0.199</td><td>-</td><td>0.077</td><td>(10.798,0.059)</td><td></td><td></td><td>=</td><td></td><td></td><td>=</td></tr><tr><td>FOMM</td><td>0.046</td><td>1.395</td><td>0.141</td><td>0.136</td><td>0.063</td><td>(6.472,0.032)</td><td>0.4950.191</td><td></td><td>0.030</td><td>(3.759,0.0090)0.428</td><td></td><td>0.13</td></tr><tr><td>MRAA w/o bg</td><td>0.043</td><td>1.307</td><td>0.140</td><td>0.127</td><td>0.063</td><td>(5.626,0.025)</td><td>0.460</td><td>0.189</td><td>0.029</td><td>(3.126,0.0092)0.396</td><td></td><td>0.12</td></tr><tr><td>Ours</td><td>0.041</td><td>1.353</td><td>0.138</td><td>0.123</td><td>0.057</td><td>(4.823, 0.020)</td><td>0.431</td><td>0.180</td><td>0.027</td><td>(3.141,0.0095)0.399</td><td></td><td>0.11</td></tr></table>
166
+
167
+ Table 2: Cross-video generation. We report video FID for both inner- and cross-dataset tasks on VoxCeleb and GermanPublicTV.
168
+
169
+ <table><tr><td>VoxCeleb</td><td>GermanPublicTV</td></tr><tr><td>FOMM</td><td>0.323 0.456</td></tr><tr><td>MRAA 0.308</td><td>0.454</td></tr><tr><td>Ours</td><td>0.161 0.406</td></tr></table>
170
+
171
+ Table 3: User study. We ask 20 human raters to conduct a subjective video quality evaluation.
172
+
173
+ <table><tr><td></td><td>VoxCeleb(%)</td><td>TaichiHD(%)</td><td>TED-talk(%)</td></tr><tr><td>Ours/FOMM</td><td>92.9/7.1</td><td>64.5/35.5</td><td>71.4/28.6</td></tr><tr><td>Ours/MRAA</td><td>89.7/10.3</td><td>60.7/39.9</td><td>54.8/45.2</td></tr></table>
174
+
175
+ (c) User study We conduct a user study to evaluate video quality. Towards this, we displayed paired videos and asked 20 human raters ‘which clip is more realistic?’. Each video-pair contains a generated video from our method, as well as a video generated from FOMM or MRAA. Results suggest that our results are more realistic in comparison to FOMM and MRAA across all three datasets (see Tab. 3). Hence, the obtained human preference is in accordance with our quantitative evaluation.
176
+
177
+ Table 4: Ablation study on motion dictionary. We conduct experiments on three datasets with and without $D _ { m } ^ { \phantom { \dagger } }$ and show reconstruction results.
178
+
179
+ <table><tr><td colspan="2">VoxCeleb</td><td colspan="2">TaichiHD</td><td colspan="2">TED-talks</td></tr><tr><td>Method</td><td>L1 LPIPS</td><td>L1</td><td>LPIPS</td><td>L1</td><td>LPIPS</td></tr><tr><td>wloDm</td><td>0.049 0.165</td><td>0.062</td><td>0.186</td><td>0.031</td><td>0.12</td></tr><tr><td>Full</td><td>0.041 0.123</td><td>0.057</td><td>0.180</td><td>0.028</td><td>0.11</td></tr></table>
180
+
181
+ Table 5: Ablation study on $D _ { m }$ size. We conduct experiments on three datasets with 5 different $D _ { m }$ size and show reconstruction results.
182
+
183
+ <table><tr><td colspan="3">VoxCeleb</td><td colspan="2">TaichiHD</td><td colspan="2">TED-talks</td></tr><tr><td>M</td><td>L1</td><td>LPIPS</td><td>L1</td><td>LPIPS</td><td>L1</td><td>LPIPS</td></tr><tr><td>5 10</td><td>0.051 0.043</td><td>0.15 0.13</td><td>0.070 0.065</td><td>0.22 0.20</td><td>0.037 0.036</td><td>0.15</td></tr><tr><td>20</td><td>0.041</td><td>0.12</td><td>0.057</td><td>0.18</td><td>0.028</td><td>0.13 0.11</td></tr><tr><td>40</td><td>0.042</td><td>0.12</td><td>0.060</td><td>0.19</td><td>0.030</td><td>0.12</td></tr><tr><td>100</td><td>0.041</td><td>0.12</td><td>0.058</td><td>0.18</td><td>0.028</td><td>0.11</td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr></table>
184
+
185
+ # 4.3 ABLATION STUDY
186
+
187
+ We here analyze our proposed motion dictionary and focus on answering following two questions.
188
+
189
+ (d) Is the motion dictionary $D _ { m }$ beneficial? We here explore the impact of proposed $D _ { m }$ , by training our model without $D _ { m }$ . Specifically, we output $w _ { r \to d }$ directly from MLP, without using LMD to learn an orthogonal basis. From the evaluation results reported in Tab. 4 and qualitative results in App. B.5, we observe that in the absence of $D _ { m }$ , model fails to generate high-quality images, which proves the effectiveness of $D _ { m }$ , consistently on all datasets.
190
+
191
+ (e) How many directions are required in $D _ { m }$ ? Towards finding an effective size of $D _ { m }$ , we empirically test three different $M$ , viz. 5, 10, 20, 40 and 100. Quantitative results in Tab. 5 show that when using 20 directions, the model achieves the best reconstruction results.
192
+
193
+ # 4.4 FURTHER ANALYSIS
194
+
195
+ (f) Latent code analysis. While our method successfully transfers motion via latent space navigation, we here aim at answering the question — what does $x _ { r }$ represent? Towards answering this question, we proceed to visualize $x _ { r }$ . We firstly decode $z _ { s r }$ into a dense flow field $\phi _ { s r }$ , which is then used to warp $x _ { s }$ (we show details in App. B.4). Fig. 5 shows examples of $x _ { s }$ and $x _ { r }$ . Interestingly, we observe that $x _ { r }$ represents the canonical pose of $x _ { s }$ , regardless of original poses of the subjects. And for all datasets, reference images resemble each other $w . r . t .$ . pose and scale. As such reference images can be considered as a normalized form of $x _ { s }$ , learning transformations between $x _ { s }$ and $x _ { d }$ using $x _ { s } x _ { r } x _ { d }$ is considerably more efficient than $x _ { s } \to x _ { d }$ , once $x _ { r }$ is fixed.
196
+
197
+ ![](images/f4021d1e9c0a6b78d5507518e6f476c3eb214d4b2fd88cb1cbad903d30c7d449.jpg)
198
+ Figure 5: Visualization of reference images. Example source (top) and reference images (down) from VoxCeleb, TaichiHD and TED-talk datasets. Our network learns reference images of a consistently frontal pose, systematically for all input images of each dataset.
199
+
200
+ ![](images/833c41d15a70be2fc45b2ced129969f51412a6047f24acd5518917c81c6c810d.jpg)
201
+ Figure 6: Linear manipulation of four motion directions on the painting of Mona Lisa. Manipulated results indicate that $d _ { 6 }$ represents eye movement, $d _ { 8 }$ represents head nodding, whereas $\bar { d _ { 1 9 } }$ and $d _ { 7 }$ represent facial expressions.
202
+
203
+ Noteworthy, we found the similar idea of learning a ‘reference image’ has also been explored by Siarohin et al. (2019) (FOMM) and Wiles et al. (2018) (X2Face). However, deviating from our visualized ‘reference image’, the ’reference image ’in FOMM refers to a non-visualized and abstract concept. In addition, LIA only requires a latent code $z _ { s r }$ , rather than the ’reference image’ for both, training and testing, which is contrast to X2Face.
204
+
205
+ (g) Motion dictionary interpretation. Towards further interpretation of directions in $D _ { m }$ , we conduct linear manipulations on each $d _ { i }$ . Images pertained to manipulating four motion directions are depicted in Fig. 6. The results suggest that the directions in $\boldsymbol { D } _ { m } ^ { \bar { 2 } }$ are semantically meaningful, as they represent basic visual transformations such as head nodding $( d _ { 8 } )$ , eye movement $( d _ { 6 } ) ^ { \dag }$ and facial expressions $\cdot d _ { 1 9 }$ and $d _ { 7 }$ ). More results can be found on our project webpage2.
206
+
207
+ # 5 CONCLUSIONS
208
+
209
+ In this paper, we presented a novel self-supervised autoencoder LIA, aimed at animating images via latent space navigation. By the proposed Linear Motion Decomposition (LMD), we were able to formulate the task of transferring motion from driving videos to source images as learning linear transformations in the latent space. We evaluated proposed method on real-world videos and demonstrated that our approach is able to successfully animate still images, while eliminating the necessity of explicit structure representations. In addition, we showed that the incorporated motion dictionary is interpretable and contains directions pertaining to basic visual transformations. Both quantitative and qualitative evaluations showed that LIA outperforms state-of-art algorithms on all benchmarks. We postulate that LIA opens a new door in design of interpretable generative models for video generation.
210
+
211
+ # ETHIC STATEMENT
212
+
213
+ In this work, we aim to synthesize high-quality videos by transferring motion on still images. Our approach can be used for movie production, making video games, online education, generating synthetic data for other computer vision tasks, etc. We note that our framework mainly focuses on learning how to model motion distribution rather than directly model appearance, therefore it is not biased towards any specific gender, race, region, or social class. It works equally well irrespective of the difference in subjects.
214
+
215
+ # REPRODUCIBILITY STATEMENT
216
+
217
+ We assure that all the results shown in the paper and supplemental materials can be reproduced. We intend to open-source our code, as well as trained models.
218
+
219
+ # ACKNOWLEDGEMENTS
220
+
221
+ This work was granted access to the HPC resources of IDRIS under the allocation AD011011627R1. It was supported by the French Government, by the National Research Agency (ANR) under Grant ANR-18-CE92-0024, project RESPECT and through the 3IA Cote d’Azur Investments in the Future ˆ project managed by the National Research Agency (ANR) with the reference number ANR-19- P3IA-0002.
222
+
223
+ # REFERENCES
224
+
225
+ Rameen Abdal, Yipeng Qin, and Peter Wonka. Image2stylegan $^ { + + }$ : How to edit the embedded images? In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), June 2020.
226
+
227
+ Brandon Amos, Bartosz Ludwiczuk, and Mahadev Satyanarayanan. Openface: A general-purpose face recognition library with mobile applications. Technical report, CMU-CS-16-118, CMU School of Computer Science, 2016.
228
+
229
+ Sarthak Bhagat, Shagun Uppal, Zhuyun Yin, and Nengli Lim. Disentangling multiple features in video sequences using gaussian processes in variational autoencoders. In ECCV, 2020.
230
+
231
+ Andrew Brock, Jeff Donahue, and Karen Simonyan. Large scale GAN training for high fidelity natural image synthesis. In ICLR, 2019.
232
+
233
+ Adrian Bulat and Georgios Tzimiropoulos. How far are we from solving the 2d & 3d face alignment problem? (and a dataset of 230,000 3d facial landmarks). In ICCV, 2017.
234
+
235
+ Chen Cao, Qiming Hou, and Kun Zhou. Displaced dynamic expression regression for real-time facial tracking and animation. ACM Transactions on graphics (TOG), 33(4):1–10, 2014.
236
+
237
+ Z. Cao, G. Hidalgo Martinez, T. Simon, S. Wei, and Y. A. Sheikh. Openpose: Realtime multi-person 2d pose estimation using part affinity fields. IEEE Transactions on Pattern Analysis and Machine Intelligence, 2019.
238
+
239
+ Caroline Chan, Shiry Ginosar, Tinghui Zhou, and Alexei A Efros. Everybody dance now. In ICCV, 2019.
240
+
241
+ Hao Chen, Yaohui Wang, Benoit Lagadec, Antitza Dantcheva, and Francois Bremond. Joint generative and contrastive learning for unsupervised person re-identification. In CVPR, 2021.
242
+
243
+ J. S. Chung, A. Nagrani, and A. Zisserman. Voxceleb2: Deep speaker recognition. In INTERSPEECH, 2018.
244
+
245
+ Aidan Clark, Jeff Donahue, and Karen Simonyan. Adversarial video generation on complex datasets. arXiv preprint arXiv:1907.06571, 2019.
246
+
247
+ Emily L Denton and vighnesh Birodkar. Unsupervised learning of disentangled representations from video. In I. Guyon, U. V. Luxburg, S. Bengio, H. Wallach, R. Fergus, S. Vishwanathan, and R. Garnett (eds.), NeurIPS, 2017.
248
+
249
+ Lore Goetschalckx, Alex Andonian, Aude Oliva, and Phillip Isola. Ganalyze: Toward visual definitions of cognitive image properties. In ICCV, pp. 5744–5753, 2019.
250
+
251
+ Kensho Hara, Hirokatsu Kataoka, and Yutaka Satoh. Can spatiotemporal 3d cnns retrace the history of 2d cnns and imagenet? In CVPR, 2018.
252
+
253
+ 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. In NIPS, 2017.
254
+
255
+ Phillip Isola, Jun-Yan Zhu, Tinghui Zhou, and Alexei A Efros. Image-to-Image Translation with Conditional Adversarial Networks. In CVPR, 2017.
256
+
257
+ Ali Jahanian, Lucy Chai, and Phillip Isola. On the ”steerability” of generative adversarial networks. In ICLR, 2020.
258
+
259
+ Yunseok Jang, Gunhee Kim, and Yale Song. Video Prediction with Appearance and Motion Conditions. In ICML, 2018.
260
+
261
+ Justin Johnson, Alexandre Alahi, and Li Fei-Fei. Perceptual losses for real-time style transfer and super-resolution. In European conference on computer vision, pp. 694–711. Springer, 2016.
262
+
263
+ Tero Karras, Samuli Laine, and Timo Aila. A style-based generator architecture for generative adversarial networks. In CVPR, 2019.
264
+
265
+ Tero Karras, Samuli Laine, Miika Aittala, Janne Hellsten, Jaakko Lehtinen, and Timo Aila. Analyzing and improving the image quality of StyleGAN. In CVPR, 2020a.
266
+
267
+ Tero Karras, Samuli Laine, Miika Aittala, Janne Hellsten, Jaakko Lehtinen, and Timo Aila. Analyzing and improving the image quality of stylegan. In CVPR, 2020b.
268
+
269
+ Diederik P Kingma and Jimmy Ba. Adam: A method for stochastic optimization. arXiv preprint arXiv:1412.6980, 2014.
270
+
271
+ Alex Krizhevsky, Ilya Sutskever, and Geoffrey E Hinton. Imagenet classification with deep convolutional neural networks. In F. Pereira, C. J. C. Burges, L. Bottou, and K. Q. Weinberger (eds.), Advances in Neural Information Processing Systems, 2012.
272
+
273
+ Yijun Li, Chen Fang, Jimei Yang, Zhaowen Wang, Xin Lu, and Ming-Hsuan Yang. Flow-grounded spatial-temporal video prediction from still images. In ECCV, 2018.
274
+
275
+ Yingzhen Li and Stephan Mandt. Disentangled sequential autoencoder. ICML, 2018.
276
+
277
+ Wen Liu, Zhixin Piao, Jie Min, Wenhan Luo, Lin Ma, and Shenghua Gao. Liquid warping gan: A unified framework for human motion imitation, appearance transfer and novel view synthesis. In CVPR, 2019.
278
+
279
+ Arsha Nagrani, Joon Son Chung, Weidi Xie, and Andrew Zisserman. Voxceleb: Large-scale speaker verification in the wild. Computer Science and Language, 2019.
280
+
281
+ Katsunori Ohnishi, Shohei Yamamoto, Yoshitaka Ushiku, and Tatsuya Harada. Hierarchical video generation from orthogonal information: Optical flow and texture. In AAAI, 2018.
282
+
283
+ Junting Pan, Chengyu Wang, Xu Jia, Jing Shao, Lu Sheng, Junjie Yan, and Xiaogang Wang. Video generation from single semantic label map. arXiv preprint arXiv:1903.04480, 2019.
284
+
285
+ 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'Alche-Buc, E. Fox, and´ R. Garnett (eds.), Advances in Neural Information Processing Systems. 2019.
286
+
287
+ William Peebles, John Peebles, Jun-Yan Zhu, Alexei A. Efros, and Antonio Torralba. The hessian penalty: A weak prior for unsupervised disentanglement. In Proceedings of European Conference on Computer Vision (ECCV), 2020.
288
+
289
+ JK Rowling. Harry potter. The 100 Greatest Literary Characters, pp. 183, 2019.
290
+ Joanne Kathleen Rowling, John Tiffany, and Jack Thorne. Harry Potter and the Cursed Child–Parts One and Two (Special Rehearsal Edition). Pottermore Publishing, 2016.
291
+ Masaki Saito, Eiichi Matsumoto, and Shunta Saito. Temporal generative adversarial nets with singular value clipping. In ICCV, 2017.
292
+ Yujun Shen and Bolei Zhou. Closed-form factorization of latent semantics in gans. In CVPR, 2021.
293
+ Yujun Shen, Jinjin Gu, Xiaoou Tang, and Bolei Zhou. Interpreting the latent space of gans for semantic face editing. In CVPR, 2020.
294
+ Aliaksandr Siarohin, Stephane Lathuili ´ ere, Sergey Tulyakov, Elisa Ricci, and Nicu Sebe. First order \` motion model for image animation. In H. Wallach, H. Larochelle, A. Beygelzimer, F. d'Alche-´ Buc, E. Fox, and R. Garnett (eds.), NeurIPS. Curran Associates, Inc., 2019.
295
+ Aliaksandr Siarohin, Oliver Woodford, Jian Ren, Menglei Chai, and Sergey Tulyakov. Motion representations for articulated animation. In CVPR, 2021.
296
+ Karen Simonyan and Andrew Zisserman. Very deep convolutional networks for large-scale image recognition. In International Conference on Learning Representations, 2015.
297
+ Justus Thies, Michael Zollhofer, Marc Stamminger, Christian Theobalt, and Matthias Nießner. Face2face: Real-time face capture and reenactment of RGB videos. In CVPR, 2016.
298
+ Justus Thies, Michael Zollhofer, and Matthias Nießner. Deferred neural rendering: Image synthesis ¨ using neural textures. ACM Transactions on Graphics (TOG), 38(4):1–12, 2019.
299
+ Justus Thies, Mohamed Elgharib, Ayush Tewari, Christian Theobalt, and Matthias Nießner. Neural voice puppetry: Audio-driven facial reenactment. ECCV, 2020.
300
+ Yu Tian, Jian Ren, Menglei Chai, Kyle Olszewski, Xi Peng, Dimitris N. Metaxas, and Sergey Tulyakov. A good image generator is what you need for high-resolution video synthesis. In ICLR, 2021.
301
+ Sergey Tulyakov, Ming-Yu Liu, Xiaodong Yang, and Jan Kautz. MoCoGAN: Decomposing motion and content for video generation. In CVPR, 2018.
302
+ Carl Vondrick, Hamed Pirsiavash, and Antonio Torralba. Generating videos with scene dynamics. In NIPS, 2016.
303
+ Andrey Voynov and Artem Babenko. Unsupervised discovery of interpretable directions in the gan latent space. arXiv preprint arXiv:2002.03754, 2020.
304
+ Jacob Walker, Kenneth Marino, Abhinav Gupta, and Martial Hebert. The pose knows: Video forecasting by generating pose futures. In ICCV, 2017.
305
+ Ting-Chun Wang, Ming-Yu Liu, Jun-Yan Zhu, Guilin Liu, Andrew Tao, Jan Kautz, and Bryan Catanzaro. Video-to-video synthesis. In NeurIPS, 2018.
306
+ Ting-Chun Wang, Ming-Yu Liu, Andrew Tao, Guilin Liu, Jan Kautz, and Bryan Catanzaro. Fewshot video-to-video synthesis. In NeurIPS, 2019.
307
+ Ting-Chun Wang, Arun Mallya, and Ming-Yu Liu. One-shot free-view neural talking-head synthesis for video conferencing. In CVPR, 2021a.
308
+ Ting-Chun Wang, Arun Mallya, and Ming-Yu Liu. One-shot free-view neural talking-head synthesis for video conferencing. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, 2021b.
309
+ Yaohui Wang. Learning to Generate Human Videos. Theses, Inria - Sophia Antipolis ; Universite´ Cote d’Azur, September 2021.
310
+ Yaohui Wang, Piotr Bilinski, Francois Bremond, and Antitza Dantcheva. G3AN: Disentangling appearance and motion for video generation. In CVPR, 2020a.
311
+ Yaohui Wang, Piotr Bilinski, Francois F Bremond, and Antitza Dantcheva. ImaGINator: Conditional Spatio-Temporal GAN for Video Generation. In WACV, 2020b.
312
+
313
+ Yaohui Wang, Francois Bremond, and Antitza Dantcheva. Inmodegan: Interpretable motion decomposition generative adversarial network for video generation. arXiv preprint arXiv:2101.03049, 2021c.
314
+
315
+ Olivia Wiles, A Koepke, and Andrew Zisserman. X2face: A network for controlling face generation using images, audio, and pose codes. In Proceedings of the European conference on computer vision (ECCV), pp. 670–686, 2018.
316
+
317
+ Jianwen Xie, Ruiqi Gao, Zilong Zheng, Song-Chun Zhu, and Ying Nian Wu. Motion-based generator model: Unsupervised disentanglement of appearance, trackable and intrackable motions in dynamic patterns. In AAAI, 2020.
318
+
319
+ Ceyuan Yang, Zhe Wang, Xinge Zhu, Chen Huang, Jianping Shi, and Dahua Lin. Pose guided human video generation. In ECCV, 2018.
320
+
321
+ Zhuoqian Yang, Wentao Zhu, Wayne Wu, Chen Qian, Qiang Zhou, Bolei Zhou, and Chen Change Loy. Transmomo: Invariance-driven unsupervised video motion retargeting. In CVPR, 2020.
322
+
323
+ Egor Zakharov, Aliaksandra Shysheya, Egor Burkov, and Victor Lempitsky. Few-shot adversarial learning of realistic neural talking head models. In ICCV, 2019.
324
+
325
+ Richard Zhang, Phillip Isola, Alexei A Efros, Eli Shechtman, and Oliver Wang. The unreasonable effectiveness of deep features as a perceptual metric. In CVPR, 2018.
326
+
327
+ Long Zhao, Xi Peng, Yu Tian, Mubbasir Kapadia, and Dimitris Metaxas. Learning to forecast and refine residual motion for image-to-video generation. In ECCV, 2018.
328
+
329
+ Zhedong Zheng, Tao Ruan, Yunchao Wei, Yi Yang, and Tao Mei. Vehiclenet: Learning robust visual representation for vehicle re-identification. IEEE Transaction on Multimedia (TMM), 2020.
330
+
331
+ Jiapeng Zhu, Yujun Shen, Deli Zhao, and Bolei Zhou. In-domain gan inversion for real image editing. In Proceedings of European Conference on Computer Vision (ECCV), 2020.
332
+
333
+ # A DETAILS OF MODEL ARCHITECTURE
334
+
335
+ We proceed to describe the model architecture in this section. Fig. 7 shows details of our $E$ . In each ResBlock in $E$ , spatial size of input feature maps are downsampled. We take feature maps of spatial sizes from $8 \times 8$ to $2 5 6 \times 2 5 6$ as our appearance features $x _ { i } ^ { e n c }$ . We use a 5-layer MLP to predict a magnitude vector $A _ { d r }$ from $z _ { d r }$ . Fig. 8 (a) shows the general architecture of our $G$ , which consists of two components, a flow field generator $G _ { f }$ and a refinement network $G _ { r }$ . We apply StyleConv (Upsample $\mathbf { + \ C o n v 3 \times 3 }$ ), which is proposed by StyleGAN2, in $G _ { f }$ . StyleConv takes latent representation $z _ { s t }$ as style code and generates flow field $\phi _ { i }$ and corresponding mask $m _ { i }$ . $G _ { r }$ uses UpConv (Conv1 $\times \ 1 +$ Upsample) to upsample and refine inpainted feature maps to target resolution. We show details pertaining to $G$ block in Fig. 8 (b). Each $G$ block is used to upsample $\times 2$ the previous resolution. We stack 6 blocks towards producing 256 resolution images.
336
+
337
+ ![](images/9325fffdbfebc0ee68f0be3ae9d39d9a1ea8e2cd0cc42b57b0799a99bd6ea9c8.jpg)
338
+ Figure 7: Encoder architecture. We show details of architecture of $E$ in (a) and ResBlock in (b).
339
+
340
+ # B EXPERIMENTS
341
+
342
+ We proceed to introduce details of datasets and evaluation metrics used in our experiments.
343
+
344
+ # B.1 DATASETS
345
+
346
+ VoxCeleb (Nagrani et al., 2019) consists of a large amount of interview videos of different celebrities. Following the process of FOMM (Siarohin et al., 2019), we extract frames and crop them into $2 5 6 \times 2 5 6$ resolution. In total, VoxCeleb contains a training set of 17928 videos and a test set of 495 videos.
347
+
348
+ ![](images/9bfd82d4cf08f228e79a896a311bfc79b0ee414695a25bedad52ccbc1330672a.jpg)
349
+ Figure 8: Generator architecture. We show details about architecture of $G$ in (a) and $G$ block in (b).
350
+
351
+ TaiChiHD (Siarohin et al., 2019) consists of videos of full human bodies performing Tai Chi actions. We follow the original pre-processing of FOMM (Siarohin et al., 2019) and utilize its $2 5 6 \times 2 5 6$ version. TaiChiHD contains 1096 training videos and 115 testing videos.
352
+
353
+ TED-talk is a new dataset proposed in MRAA (Siarohin et al., 2021). It comprises a number of TED-talk videos, where the main subjects have been cropped out. We resize the original version into $2 5 6 \times 2 5 6$ resolution to train our model. This dataset includes 1124 training videos and 130 testing videos.
354
+
355
+ # B.2 EVALUATION METRICS
356
+
357
+ We use five different metrics to evaluate our experimental results, namely $\mathcal { L } _ { 1 }$ , LPIPS, AKD, MKR and AED that quantify the reconstructed results. In addition, we compute video FID to evaluate video quality in motion transferring tasks.
358
+
359
+ $\mathcal { L } _ { 1 }$ represents the mean absolute pixel difference between reconstructed and real videos.
360
+
361
+ LPIPS (Zhang et al., 2018) aims at measuring the perceptual similarity between reconstructed and real images by leveraging the deep features from AlexNet (Krizhevsky et al., 2012).
362
+
363
+ Video FID is a modified version of the original FID (Heusel et al., 2017). We here follow the same implementation as Wang et al. (2020a) and utilize a pre-trained ResNext101 (Hara et al., 2018) to extract spatio-temporal features to compute the distance between real and generated videos distributions. We take the first 100 frames of each video as input of the feature-extractor to compute the final scores.
364
+
365
+ Average keypoint distance (AKD) and missing keypoint rate (MKR) evaluate the difference between keypoints of reconstructed and ground truth videos. We extract landmarks using the face alignment approach of (Bulat & Tzimiropoulos, 2017) and extract body poses for both TaiChiHD and TED-talks using OpenPose (Cao et al., 2019). AKD is computed as the average distance between corresponding keypoints, whereas MKR is the proportion of keypoints present in the groundtruth that are missing in a reconstructed video.
366
+
367
+ Average Euclidean distance (AED) measures the ability of preserving identity in reconstructed video. We use a person re-identification pretrained model (Zheng et al., 2020) for measuring human bodies (TaichiHD and TED-talk) and OpenFace (Amos et al., 2016) for faces to extract identity embeddings from reconstructed and ground truth frame pairs, then we compute MSE of their difference for all pairs.
368
+
369
+ # B.3 COMPARISON WITH FULL MRAA
370
+
371
+ We show quantitative evaluation results with the full MRAA model in Tab. 6. We observe that our method achieves competitive results in reconstruction and keypoint evaluation. While we do not explicitly predict keypoints, w.r.t. the TaichiHD dataset, interestingly we outperform MRAA in both, AKD and MKR. Such results showcase the effectiveness of our proposed method on modeling articulated human structures. However, reconstruction evaluation cannot provide a completely fair comparison on how well the main subjects (e.g., faces and human bodies) are generated in videos. This is in particular the case for TaichiHD and TED-talk, where backgrounds have large contributions to the final scores.
372
+
373
+ Table 6: Comparison with full MRAA.
374
+
375
+ <table><tr><td rowspan="2">Method</td><td colspan="4">VoxCeleb</td><td colspan="4">TaichiHD</td><td colspan="4">TED-talks</td></tr><tr><td>L1</td><td>AKD</td><td>AED</td><td>LPIPS</td><td>L1</td><td>(AKD,MKR)</td><td>AED</td><td>LPIPS</td><td>L1</td><td>(AKD,MKR)</td><td>AED</td><td>LPIPS</td></tr><tr><td>MRAA</td><td>0.041</td><td>1.303</td><td>0.135</td><td>0.124</td><td>0.045</td><td>(5.551,( ,0.025)</td><td>0.431</td><td>0.178</td><td>0.027</td><td>(3.107,0.0093)</td><td>0.379</td><td>0.11</td></tr><tr><td>Ours</td><td>0.041</td><td>1.353</td><td>0.138</td><td>0.123</td><td>0.057</td><td>(4.823,0.020)</td><td>0.431</td><td>0.180</td><td>0.027</td><td>(3.141,0.0095)</td><td>0.399</td><td>0.11</td></tr></table>
376
+
377
+ # B.4 REFERENCE IMAGE GENERATION.
378
+
379
+ To produce $x _ { r }$ , we use $G$ to decode $z _ { s r }$ into the flow field $\phi _ { s r }$ . Reference image $x _ { r }$ is obtained by warping $x _ { s }$ using $\phi _ { s r }$ . The entire process is shown in Fig. 9.
380
+
381
+ ![](images/762132d8adc241e8fde2ec32f40c10dbb27f4f06b3953c429f112db181bf10c2.jpg)
382
+ Figure 9: Reference image generation.
383
+
384
+ # B.5 QUALITATIVE RESULTS ON EFFECTIVENESS OF USING MOTION DICTIONARY
385
+
386
+ Fig. 10 illustrates the generated results on transferring motion from VoxCeleb to GermanPublicTV with and without motion dictionary. We observe that without the motion dictionary, appearance information is undesirably transferred from driving videos to generated videos.
387
+
388
+ # B.6 LIMITATIONS
389
+
390
+ For human body, one limitation of our method is dealing with body occlusion. We observe in Fig. 11 that in taichi videos, in case of occlusion cause by legs and arms, motion is not transferred successfully. In addition, in TED-talks, transferring hand motion is challenging, as hands are of small size, articulated and sometimes occluded by human bodies.
391
+
392
+ ![](images/70acaf34c5c7203b948fb2919b9b562110b48bb7fdf0186567c1baf79c82cd42.jpg)
393
+ Figure 10: Generated results with and without $D _ { m }$ . We observe that the disentanglement of appearance and motion is much better by using $D _ { m }$ .
394
+
395
+ ![](images/8df647813e53c9e3f9fda4ddf2534e1d09430b0019731ce68455cebf897027e0.jpg)
396
+ Figure 11: Failure cases. We observed that it is still challenging for LIA to handle arm-leg occlusion (Taichi) and hand motion (TED-talk).
md/dev/AIqC7F7xV-d/AIqC7F7xV-d.md ADDED
@@ -0,0 +1,460 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Learning Unified Representations for Multi-Resolution Face Recognition
2
+
3
+ Anonymous Author(s)
4
+ Affiliation
5
+ Address
6
+ email
7
+
8
+ # Abstract
9
+
10
+ 1 In this work, we propose Branch-to-Trunk network (BTNet), a novel representation
11
+ 2 learning method for multi-resolution face recognition. It consists of a trunk network
12
+ 3 (TNet), namely a unified encoder, and multiple branch networks (BNets), namely
13
+ 4 resolution adapters. As per the input, a resolution-specific BNet is used and the
14
+ 5 output are implanted as feature maps in the feature pyramid of TNet, at a layer with
15
+ 6 the same resolution. The discriminability of tiny faces is significantly improved, as
16
+ 7 the interpolation error introduced by rescaling, especially up-sampling, is mitigated
17
+ 8 on the inputs. With branch distillation and backward-compatible training, BTNet
18
+ 9 transfers discriminative high-resolution information to multiple branches while
19
+ 10 guaranteeing representation compatibility. Our experiments demonstrate strong
20
+ 11 performance on face recognition benchmarks, both for multi-resolution identity
21
+ 12 matching and feature aggregation, with much less computation amount and param
22
+ 13 eter storage. We establish new state-of-the-art on the challenging QMUL-SurvFace
23
+ 14 1: N face identification task.
24
+
25
+ # 15 1 Introduction
26
+
27
+ 16 Machine learning has advanced tremendously driven by deep learning methods, but is still severely
28
+ 17 challenged by various data specifications, such as data type, structure, scale and size, etc. For
29
+ 18 instance, face recognition (FR) is a well-established deep learning task, while the performance
30
+ 19 degrades dramatically in the testing domain that differs from the training one, influenced by factors
31
+ 20 of variance like resolution, illumination, occlusion, etc.
32
+ 21 Most face recognition methods map each image to a point embedding in the common metric space
33
+ 22 by deep neural networks (DNNs). The dissimilarity of images can be then calculated using various
34
+ 23 distance metrics (e.g., cosine similarity, Euclidean distance, etc.) for face recognition tasks.
35
+ 24 Recent advancements in margin-based loss (e.g., ArcFace [1], MV-Arc-Softmax [2], CurricularFace
36
+ 25 [3], etc) enhanced discriminability of the metric space, with small intra-identity distance and large
37
+ 26 inter-identity distance. However, lack of variation in training data still leads to poor generalizability.
38
+ 27 Various useful methods are utilized to mitigate this issue. The model adapts to factors of variance
39
+ 28 by augmenting datasets, whereas the large discrepancy in data distribution could potentially weaken
40
+ 29 the model’s ability to extract discriminative features with the same data scale and model structure
41
+ 30 (see Section 4.3). Fine-tuning is widely used to transfer large pretrained models to new domains with
42
+ 31 different data specifications. However, this strategy requires one to store and deploy a separate copy
43
+ 32 of the backbone parameters for every single new domain, which is expensive and often infeasible.
44
+ 33 As known, the resolutions of face images in reality may be far beyond the scope covered by the
45
+ 34 model. As the small feature maps with a fixed spatial extent (e.g., $7 \times 7 )$ are mapped to an embedding
46
+ 35 with a predefined dimension (e.g., $1 2 8 - d$ , $5 1 2 - d$ , etc.) by a fully connected (fc) layer, input
47
+ 36 images need to be rescaled to a canonical spatial size (e.g., $1 1 2 \times 1 1 2 )$ before fed into the network.
48
+ 37 However, up-sampling low-resolution (LR) images introduces the interpolation error (see Section 3.1),
49
+ 38 deteriorating the recognizable ones which contain enough clues to identify the subject. Even though
50
+ 39 super-resolution methods [4–10] are widely used to build faces with good visualization, they inevitably
51
+ 40 introduce feature information of other identities when reconstructing high-resolution (HR) faces.
52
+ 41 This may lead to erroneous identity-specific features, which are detrimental to risk-controlled face
53
+ 42 recognition.
54
+ 43 Empirically, we can divide inputs by resolution distribution and learn to operate on them via multiple
55
+ 44 models to achieve high accuracy and efficiency. However, multi-model fashion cannot be applied
56
+ 45 directly for cross-resolution recognition as representation compatibility among models need to be
57
+ 46 guaranteed [11–15].
58
+ 47 To improve discriminability while ensure the compatibility of the metric space for multi-resolution
59
+ 48 face representation, we learn the “unified” representation by a partially-coupled Branch-to-Trunk
60
+ 49 Network (BTNet). It is composed of multiple independent branch networks (BNets) and a shared
61
+ 50 trunk network (TNet). A resolution-specific BNet is used for a given image, and the output are
62
+ 51 implanted as feature maps in the feature pyramid of TNet, at a layer with the same resolution.
63
+ 52 Furthermore, we find that multi-resolution training can be beneficial to building a strong and robust
64
+ 53 TNet, and backward-compatible training (BCT) [11] can improve the representation compatibility
65
+ 54 during the training process of BTNet. To ameliorate the discriminability of tiny faces, we propose
66
+ 55 branch distillation in intermediate layers, utilizing information extracted from HR images to help the
67
+ 56 extraction of discriminative features for resolution-specific branches.
68
+ 57 Our method is simple and efficient, which breaks the convention of up-sampling the inputs and
69
+ 58 serves as a general framework that can be easily implemented by several existing methods due to
70
+ 59 conceptual simplicity. Meanwhile, BTNet is able to reduce the number of FLOPS by operating the
71
+ 60 inputs without up-sampling, and per-resolution storage cost by only storing the learned branches and
72
+ 61 resolution-aware BNs [16], while re-using the copy of the trunk model.
73
+ 62 We demonstrate that our method performs comparably in various open-set face recognition tasks (1:1
74
+ 63 face verification and 1: N face identification), in both settings of multi-resolution identity matching
75
+ 64 and feature aggregation, while meaningfully reduces the redundant computation cost and parameter
76
+ 65 storage. In the challenging QMUL-SurvFace 1: N face identification task [17], we establish new
77
+ 66 state-of-the-art by outperforming prior models. Furthermore, by avoiding the ill-posed problem (i.e.,
78
+ 67 image up-sampling), our approach also effectively reduces the additional noise and uncertainty of the
79
+ 68 representation, which plays a key role in reliable risk-controlled face recognition.
80
+
81
+ # 69 2 Related Work
82
+
83
+ 70 Compatible Representation Learning: The task of compatible representation learning aims at
84
+ 71 encoding features that are interoperable with the features extracted from other models. Shen et. al.
85
+ 72 [11] first formulated the problem of backward-compatible learning (BCT) and proposed to utilize the
86
+ 73 old classifier for compatible feature learning. Since the multi-model fashion benefits representation
87
+ 74 learning with lower computation, our idea of cross-resolution representation learning can be modeled
88
+ 75 similar to cross-model compatibility [11–15], as metric space alignment for different resolutions. Our
89
+ 76 goal is achieved by both compatibility-aware network architecture and training strategy.
90
+ 77 Knowledge Distillation and Transfer: The concept of knowledge distillation (KD) was first
91
+ 78 proposed by Hinton et. al. in [18], which can be summarized as employing a large parameter
92
+ 79 model (teacher) to supervise the learning of a small parameter model (student). Distillation from
93
+ 80 intermediate features [19–29] is widely adopted to enhance the effectiveness of knowledge transfer.
94
+ 81 However, due to the “dark knowledge” hidden in the intermediate layers, additional subtle design is
95
+ 82 often required to match and rescale intermediate features. Instead, our approach can easily locate the
96
+ 83 distillation features without rescaling and effectively transfer knowledge from the HR domain to LR
97
+ 84 branches.
98
+ 85 Low Resolution Face Recognition: Its task includes low resolution-to-low resolution (LR-to-LR)
99
+ 86 matching and low resolution-to-high resolution (LR-to-HR) matching [30]. The work can be divided
100
+ 87 into two categories [31]: (1) Super-resolution (SR) based methods aim to upscale LR images to
101
+ 88 construct HR images and use them for feature extraction [4–10]. (2) Projection-based methods aim to
102
+ 89 extract adequate representations in different domains and project them into a common feature space
103
+ 90 [32–34]. SR approaches are able to build faces with good visualization, but inevitably introduce
104
+ 91 feature information of other identities when reconstructing corresponding HR faces, thus introducing
105
+ 92 noise for identity-specific features. Compared to previous projection methods, our approach directly
106
+ 93 learns discriminative representations in a common feature space for HR and LR inputs, without
107
+ 94 additional projection heads for feature transformation.
108
+
109
+ Pseudo-Siamese Networks: Siamese networks are a coupling architecture based on DNNs, which are widely used for signature verification [35], face verification [36, 37], tracking [38], etc. PseudoSiamese networks [39] are decoupled Siamese networks, as the weights of the two branches are not shared, resulting in a more flexible representation way for the two entities. Hughes et. al. in [40] proposed a pseudo-Siamese CNN for identifying corresponding patches in SAR and optical images. Inspired by pseudo-Siamese networks, we propose a resolution-adaptive partially coupled Siamese network architecture, extracting specific-shared features for images with different resolutions.
110
+
111
+ # 3 Learning Specific-Shared Feature Transfer
112
+
113
+ Instead of rescaling the inputs to a canonical size, we build multiple resolution-specific branches (BNets) that are used to map inputs to intermediate features with the same resolution and a resolutionshared trunk (TNet) to map feature maps with different resolutions to a high-dimension embedding. We gain several important properties by doing so: (1) Processing inputs on its original resolution can diminish the inevitably introduced error via up-sampling or information loss via down-sampling, thus preserving the discriminability of visual information with different resolutions. (2) Information streams of different resolutions are encoded uniformly, thus enabling the representation compatibility, which is particularly beneficial to open-set face recognition considering that a compatible metric space is the prerequisite for computing similarity. (3) This also effectively reduce the computation for LR images by supplying computational resources conditioned on the input resolution.
114
+
115
+ # 113 3.1 Up-Sampling Error Analysis
116
+
117
+ ![](images/bcaf8fb368f804daba922e50885b5d890a9bd70ea33f0a8743d4e42864a72421.jpg)
118
+ Figure 1: Estimated Error Upperbound. (bilinear interpolation, average value for over 100 images) with the change of image resolution relative to resolution 112.
119
+
120
+ ![](images/49c6de557e00d2a1971a3a5c302649e9eb1af1a26b38f484c1a1576206274175.jpg)
121
+ Figure 2: Basic ideas of the proposed BTNet. Images of a certain identity are first projected to the feature maps with the same resolution respectively (Adapt) and then projected to a unified feature representation (Encode). In this figure, feature maps with the same resolution are indicated by outlines in the same color.
122
+
123
+ 114 Figure 1 illustrates the experimental estimation of interpolation error, whose upper bound increases
124
+ 115 with the decline of the image resolution (see detailed theoretical derivation in Appendix A.1). Note
125
+ 116 that the error soars up when the resolution drops below 32 approximately which can be viewed as LR
126
+ 117 face images, consistent with the tiny-object criterion [41].
127
+ 118 The results show that: (1) inputs with a resolution higher than around 32 can be considered in the
128
+ 119 same HR domain, since the error information introduced by up-sampling via interpolation can be
129
+ 120 ignored to a certain extent; (2) inputs with a resolution lower than around 32 should be treated as in
130
+ 121 various LR domains due to the high sensitivity of the resolution to errors.
131
+
132
+ # 3.2 Branch-to-Trunk Network
133
+
134
+ Let $X$ be an input RGB image with a space shape: $X \in \mathbb { R } ^ { H \times W \times 3 }$ where $H \times W$ corresponds to the spatial dimension of the input. For efficient batch training and inference, we predefine a canonical size $S \times S$ (e.g., $1 1 2 \times 1 1 2$ for typical face recognition models like ArcFace [1]).
135
+
136
+ We build a trunk network $\boldsymbol { T } : \mathbb { R } ^ { H \times W \times 3 } \mathbb { R } ^ { C _ { e m b } }$ capable of extracting discriminative information with different resolutions, where $C _ { e m b }$ is the number of embedding channels. For every resolution $r$ in the candidate set, we formulate a resolution-specific branch, $z _ { r } = \textit { B } _ { r } ( X _ { r } )$ , which maps the input image $X _ { r }$ to feature maps with the same resolution and expanded channels $\boldsymbol { z } _ { r } : \mathbb { R } ^ { r \times r \times 3 } \mathbb { R } ^ { r \times r \times C _ { r } }$ . The idea is to learn our branches $B$ to focus on resolution-specific feature transfer independently. Feature maps will then be coupled to the trunk network $T$ in the feature pyramid with the same spatial resolution $r \times r$ , allowing for further mapping to the unified presentation space by $T _ { r } : \mathbb { R } ^ { r \times r \times C _ { r } } $ $\mathbb { R } ^ { C _ { e m b } }$ .
137
+
138
+ Here, we follow the idea of “avoiding redundant up-sampling”. Our branches $B$ are implemented with same-resolution mapping: i.e., the model preserves the network architecture of $T$ from input to the layer with resolution $r$ and abandons down-sampling operations (e.g., replacing the convolution of stride 2 with stride 1, abandoning the pooling layers, etc.) to keep the same-resolution flow.
139
+
140
+ We specifically name our specific-shared feature transfer network as Branch-to-Trunk Network, abbreviated as "BTNet". Figure 2 visually summarizes the main ideas of BTNet.
141
+
142
+ # 3.3 Training Objectives
143
+
144
+ We now describe the training objectives. The training of BTNet includes training the trunk network $T$ such that it can produce discriminative and compatible representations for multi-resolution information, and fine-tuning the branch networks $B$ to encourage them to learn resolution-specific feature transfer, so as to improve accuracy without compromising compatibility.
145
+
146
+ Influence Loss. It is a compatibility-aware classification loss which is implemented by feeding the embeddings of the new model to the classifier of the old model [11]. Since the difficulties of samples vary due to image resolution, we compute CurricularFace [3] as our classification loss, in the form of:
147
+
148
+ $$
149
+ L _ { c u r } = - \log ( \frac { e ^ { s \cos ( \theta _ { y _ { i } } + m ) } } { e ^ { s \cos ( \theta _ { y _ { i } } + m ) } + \sum _ { j = 1 , j \neq y _ { i } } ^ { n } e ^ { s N ( t ^ { ( k ) } , \cos ( \theta _ { j } ) ) } } )
150
+ $$
151
+
152
+ $$
153
+ \begin{array} { c } { { N ( t , \cos \theta _ { j } ) = \displaystyle \left\{ \begin{array} { l c } { { \cos ( \theta _ { j } ) , } } & { { \cos ( \theta _ { y _ { i } } + m ) - \cos ( \theta _ { j } ) \ge 0 } } \\ { { \cos ( \theta _ { j } ) ( t + \cos ( \theta _ { j } ) ) , } } & { { e l s e } } \end{array} \right. } } \\ { { t ^ { ( k ) } = \displaystyle \alpha \sum _ { i } \cos \theta _ { y _ { i } } + ( 1 - \alpha ) t ^ { ( k - 1 ) } } } \end{array}
154
+ $$
155
+
156
+ 150 which distinguishes both the difficultness of different samples in each stage and relative importance
157
+ 151 of easy and hard samples during different training stages. Thus, we refine CurricularFace loss as our
158
+ 152 influence loss:
159
+
160
+ $$
161
+ L _ { i n f l u e n c e } = L _ { c u r } ( \varphi _ { b t } , \kappa ^ { * } )
162
+ $$
163
+
164
+ where 153 $\varphi _ { b t }$ is BTNet backbone (both $B _ { r }$ and $T _ { r }$ ), and $\kappa ^ { * }$ is the classifier of the pretrained trunk $T$ .
165
+
166
+ 154 Branch Distillation Loss. Due to the
167
+ 155 continuity of the scale change of both the
168
+ 156 image pyramid and the feature pyramid
169
+ 157 [42], we can get a qualitative sense of
170
+ 158 the similarity between images and feature
171
+ 159 maps with the same resolution (see Figure
172
+ 160 3). Furthermore, features extracted from
173
+ 161 HR images have richer and clearer infor
174
+ 162 mation than those from LR images [43].
175
+ 163 Motivated by these analyses, we utilize an
176
+ 164 MSE loss to encourage the branch output
177
+ 165 $z _ { r }$ to be similar to the corresponding fea
178
+ 166 ture maps of the pretrained trunk network
179
+ 167 $z _ { s }$ :
180
+
181
+ ![](images/e434a9a21fd643648ac4896d6cdd3ccf6e9342a751aac825373efc28d542ddee.jpg)
182
+ Figure 3: Visual comparison of face image-feature map pairs with different resolutions (resized to a common size here for illustration).
183
+
184
+ $$
185
+ L _ { b r a n c h } = \frac { 1 } { V } \sum _ { v = 1 } ^ { V } { ( z _ { r _ { v } } - z _ { s _ { v } } ) } ^ { 2 }
186
+ $$
187
+
188
+ 168 where $V$ denotes the batch size.
189
+
190
+ 169 The whole training objective is a combination of the above objectives:
191
+
192
+ $$
193
+ L = L _ { i n f l u e n c e } + \lambda _ { b r a n c h } L _ { b r a n c h }
194
+ $$
195
+
196
+ 170 where $\lambda _ { b r a n c h }$ is a hyper-parameter to weigh the losses and we set $\lambda _ { b r a n c h } = 0 . 5$ in all our experi
197
+ 171 ments.
198
+
199
+ ![](images/22946257e92b509279813a29ef0c3ac19fcb89eb7b3c4b6d171707c4f9ae79f6.jpg)
200
+ Figure 4: Comparison of $\#$ Params $\mathbf { \Psi } ^ { ( \mathbf { M } ) }$ between fully finetuning and $\varphi _ { b t }$ .
201
+
202
+ ![](images/1df08d5fa7d736b80d3f65aa605b4972425929210f8a903a7b8e250ca889addb.jpg)
203
+ Figure 5: Comparison of FLOPs (G) between baselines and $\varphi _ { b t }$ .
204
+
205
+ # 172 3.4 Storing Branch Networks
206
+
207
+ An obvious adaptation strategy is fully finetuning of the model on each resolution. However, this strategy requires one to store and deploy a separate copy of the backbone parameters for every resolution, which is an expensive proposition and difficult to expand into more segmented resolution branches. Our BTNet is beneficial in the scenario of multi-resolution face recognition which achieves better parameter/accuracy trade-offs. Since activation statistics including means and variances under different resolutions are incompatible [44], we update and store Batch Normalization (BN) [45] parameters in all layers of $B _ { r }$ and $T _ { r }$ for each resolution, whose amount is negligible. Apart from this, we only need to store the learned branches and re-use the original copy of the pretrained trunk model, significantly reducing the storage cost. Figure 4 shows that BTNet requires only $1 . 1 \% \sim 4 8 . 9 \%$ of all the parameters compared to fully updating all the parameters of TNet.
208
+
209
+ # 4 Experiments
210
+
211
+ 184 To validate BTNet on face recognition tasks in open universe, we perform 1:1 verification and $1 : N$
212
+ 185 identification tasks in two different settings, including (a) multi-resolution identity matching, and
213
+
214
+ (b) multi-resolution feature aggregation. For 1:1 verification, a pair of templates are provided and the model is to decide whether they belong to the same identity or not. For 1:N identification, a set of gallery images are first mapped onto their embedding vectors (indexing) and the embeddings of query images are extracted to perform search against indexed gallery.
215
+
216
+ # 4.1 Implementation Details
217
+
218
+ Datasets. We use MS1Mv3 [46] for training face embedding models. The MS1Mv3 dataset contains 5,179,510 images of 93,431 celebrities. According to the test setting, different test datasets are used.
219
+
220
+ ·Multi-Resolution Identity Matching. We try on six widely adopted face verification benchmarks: LFW [47], CFP-FF [48], CFP-FP [48], AgeDB-30 [49], CALFW [50], and CPLFW [51], while the large-scale surveillance face dataset QMUL-SurvFace [17] is used for 1:N face identification, which contains native LR surveillance faces across wide space and time. The spatial resolution for QMUL-SurvFace ranges from 6/5 to 124/106 in height/width with an average of 24/20.
221
+
222
+ ·Multi-Resolution Feature Aggregation. We adopt a top challenging benchmark IJB-C [52], which has around 130k images from 3,531 identities, for two standard testing protocols: $1 : 1$ verification and 1:N identification.
223
+
224
+ Training. All the models are trained on four RTX 2080 Tis with batch size 128 by stochastic gradient descent. For TNet, we train for 25 epochs, with learning rate initialized at 0.2 with 2 warmup epochs and decaying as a quadratic polynomial. We augment training samples by random horizonal flipping and multi-resolution training. For BNets, we initialize the learning rate by 0.02 without warm-up epochs. The training all stops at the $1 0 t h$ epoch for a fair comparison. The recommended hyper-parameters are used for classification loss from the original paper (e.g., $m = 0 . 5 , s = 6 4$ for ArcFace [1], and $\alpha = 0 . 9 9 , t ^ { 0 } = 0$ for CurricularFace [3]). Only horizonal flipping is used as augmentation when training BNets.
225
+
226
+ Baselines. In our experiment, several baselines are used to validate BTNet in learning discriminative and compatible representations for multi-resolution face recognition.
227
+
228
+ ·High-Resolution Trained $\varphi _ { h r }$ . Naive baseline trained with HR data.
229
+
230
+ ·Independently Trained $\varphi _ { m m }$ . Multi-model fashion: is it possible to achieve better results if we train a specific model for each resolution independently? Specifically, we train $\varphi _ { r }$ for data with resolution $r$ and denote the multi-model collections as $\varphi _ { m m }$ .
231
+
232
+ ·Multi-Resolution Trained $\varphi _ { m r }$ . Trained with multi-resolution data which adapts to resolutionvariance. Specifically, each image is randomly down-sampled to a size in the candidate set $\textstyle \{ { \frac { 1 1 2 } { 2 ^ { i } } } \ x$ $\textstyle { \frac { 1 1 2 } { 2 ^ { i } } } | i = 0 , 1 , 2 , 3 , 4 \}$ with equal probability of being chosen, and then up-sampled back to $1 1 2 \times 1 1 2$
233
+
234
+ Instantiation of Network Architecture. The BTNet and baselines are implemented with ResNet50 [53], and they could be extended easily with other implementations. Dubbed as $\varphi _ { b t }$ , the detailed instantiation of BTNet based on ResNet50 is illustrated in Appendix A.2.
235
+
236
+ # 4.2 Evaluation Metrics
237
+
238
+ On the benchmarks for face verification, we use 1:1 verification accuracy as the basic metrics. The rank-20 true positive identification rates (TPIR20) at varying false positive identification rates (FPIR) and AUC are used to report the identification results on QMUL-SurvFace. The evaluation metrics for IJB-C 1:1 verification protocol are true acceptance rates (TAR) at different false acceptance rate (FAR). For 1:N identification, the basic evaluation metrics are the true positive identification rates (TPIR) at different false positive identification rates (FPIR).
239
+
240
+ 229 For better evaluation, we define another two metrics to assess the relative performance gain similar to
241
+ 230 [11, 14].
242
+
243
+ (a) Cross-resolution identity matching.
244
+
245
+ Table 1: Comparison of different methods on six face verification benchmarks. “Acc.” denotes average 1:1 verification accuracy.
246
+
247
+ <table><tr><td rowspan="2"></td><td colspan="2">112&amp;7</td><td colspan="2">112&amp;14</td><td colspan="2">112&amp;28</td></tr><tr><td>Acc.</td><td>Gain</td><td>Acc.</td><td>Gain</td><td>Acc.</td><td>Gain</td></tr><tr><td>hr</td><td>57.75</td><td>-</td><td>81.02</td><td>=</td><td>95.90</td><td></td></tr><tr><td>mm</td><td>50.58</td><td>-0.89</td><td>49.90</td><td>-4.82</td><td>50.03</td><td>-305.80</td></tr><tr><td>mr</td><td>65.85</td><td>+1.00</td><td>87.47</td><td>+1.00</td><td>96.05</td><td>+1.00</td></tr><tr><td>bt(Ours)</td><td>86.10</td><td>+3.50</td><td>94.08</td><td>+2.02</td><td>96.65</td><td>+5.00</td></tr></table>
248
+
249
+ (b) Same-resolution identity matching.
250
+
251
+ <table><tr><td colspan="2">7&amp;7</td><td colspan="2">14&amp;14</td><td colspan="2">28&amp;28</td><td colspan="2">112&amp;112</td></tr><tr><td>Acc.</td><td>Gain</td><td>Acc.</td><td>Gain</td><td>Acc.</td><td>Gain</td><td>Acc.</td><td>Gain</td></tr><tr><td>60.70</td><td></td><td>73.88</td><td></td><td>93.58</td><td>=</td><td>97.68</td><td>-</td></tr><tr><td>62.57</td><td>+1.00</td><td>78.00</td><td>+1.00</td><td>94.68</td><td>+1.00</td><td>97.68</td><td>-</td></tr><tr><td>61.02</td><td>+0.17</td><td>80.32</td><td>+1.56</td><td>95.12</td><td>+1.40</td><td>97.25</td><td>-</td></tr><tr><td>77.78</td><td>+9.13</td><td>90.90</td><td>+4.13</td><td>96.27</td><td>+2.45</td><td>97.25</td><td>=</td></tr></table>
252
+
253
+ 231 Cross-Resolution Gain. With the purpose towards the cross-resolution compatible representations,
254
+ 232 we define the performance gain as follows:
255
+
256
+ $$
257
+ G a i n _ { r _ { 1 } \& r _ { 2 } } ( \varphi ) = \frac { M _ { r _ { 1 } \& r _ { 2 } } ( \varphi ) - M _ { r _ { 1 } \& r _ { 2 } } ( \varphi _ { h r } ) } { | M _ { r _ { 1 } \& r _ { 2 } } ( \varphi _ { m r } ) - M _ { r _ { 1 } \& r _ { 2 } } ( \varphi _ { h r } ) | }
258
+ $$
259
+
260
+ Here 33 $M _ { r _ { 1 } \& r _ { 2 } } ( \cdot )$ are metrics when the resolutions of the image/template pair are $r _ { 1 } \times r _ { 1 }$ and $r _ { 2 } \times r _ { 2 }$ 4 $( r _ { 1 } \neq r _ { 2 } )$ , respectively. $\varphi _ { m r }$ shares the same architecture with $\varphi _ { h r }$ while is trained on multi-resolution 5 images and thus serves as the baseline of cross-resolution gain.
261
+
262
+ 36 Same-Resolution Gain. For the scenario of multi-resolution face recognition, the performance of
263
+ 37 same-resolution verification/identification is also vital besides cross-resolution one. Therefore, we
264
+ 38 report the relative performance improvement from base model $\varphi _ { h r }$ in the scenario of same-resolution.
265
+
266
+ $$
267
+ G a i n _ { r \& r } ( \varphi ) = \frac { M _ { r \& r } ( \varphi ) - M _ { r \& r } ( \varphi _ { h r } ) } { | M _ { r \& r } ( \varphi _ { r } ) - M _ { r \& r } ( \varphi _ { h r } ) | }
268
+ $$
269
+
270
+ 39 Here $M _ { r \& r } \left( \cdot \right)$ are metrics when the resolutions of the image/template pair are both $r \times r$ . $\varphi _ { r }$ is
271
+ 40 a model of the set $\{ \varphi _ { m m } = \varphi _ { r } | r = 7 , 1 4 , 2 8 \}$ trained on images with resolution $r \times r$ without
272
+ 41 considering cross-resolution representation compatibility, which serves as the baseline of same
273
+ 42 resolution gain on resolution $r$ . Note that for both metrics we add the absolute symbol to the
274
+ 43 denominator as they can be negative in some test settings (detailed in Section 4.3 and 4.4).
275
+
276
+ # 4.3 Multi-Resolution Identity Matching
277
+
278
+ We now conduct experiments on the proposed BTNet framework for multi-resolution identity matching. Two different settings are included : (1) same-resolution matching, and (2) cross-resolution matching. Table 1 compares the average performance on popular benchmarks for $\varphi _ { h r } , \varphi _ { m m } , \varphi _ { m r } ,$ $\varphi _ { b t }$ . The experimental results on each dataset are detailed in Appendix A.5.
279
+
280
+ 249 When directly applied to test data with the resolution lower than training data, $\varphi _ { h r }$ suffers a severe
281
+ 250 performance degradation. Up-sampling images via interpolation can increase the amount of data
282
+ 251 but not the amount of information, only to improve the detailed part of the image and the spatial
283
+ 252 resolution (size) [64]. Moreover, it also brings various noise and artificial processing traces [65].
284
+ 253 Up-sampling images via interpolation-typically bilinear interpolation or bicubic interpolation of
285
+ 254 4x4 pixel neighborhoods, essentially a function approximation method, is bound to introduce error
286
+ 255 information (detailed in Appendix A.1), thus potentially confusing identity information, which is
287
+ 256 especially crucial for LR images with limited details. We are able to observe improvement of $\varphi _ { m m }$ in
288
+ 257 same-resolution matching but its cross-resolution gain is negative with approximately $50 \%$ accuracy.
289
+ 258 Unsurprisingly, independently trained $\varphi _ { r }$ is unaware of representation compatibility, and thus does
290
+ 259 not naturally suitable for cross-resolution recognition. The results show that $\varphi _ { m r }$ improved both
291
+ 260 cross-resolution and same-resolution accuracy by a large margin, as it learns to adapt to resolution
292
+ 261 variance and maintain discriminability of multi-resolution inputs. Note that the model size and
293
+ 262 training data scale stay the same, while only the resolution distribution of the data changes for
294
+ 263 $\varphi _ { m r }$ , and thus there is a marginal accuracy drop in the setting of 112&112 matching. Comparably,
295
+ 264 $\varphi _ { b t }$ substantially outperforms all baselines with $2 . 0 2 \sim 5 . 0 0$ cross-resolution gain and 2.45\~9.13
296
+ 265 same-resolution gain. Importantly, due to the multi-resolution branches, our approach has a cost same
297
+ 266 with $\varphi _ { m m }$ , significantly lower than $\varphi _ { h r }$ and $\varphi _ { m r }$ (see Figure 5).
298
+ 267 For inference on inputs with resolutions not strictly matched to the branch, we validate three selection
299
+ 268 strategies based on three resolution indicators (see Figure 6). Table 2 compares BTNet against the
300
+ 269 state-of-the-arts models on QMUL-SurvFace 1:N identification benchmark. We are able to observe
301
+ 270 that our proposed approach extends the state-of-the-arts while being more computationally efficient.
302
+ 271 We believe the performance of BTNet (max $^ +$ ceil) is the highest that have been reported so far, and
303
+ 272 we believe it is meaningful with the increased focus on unconstrained surveillance applications.
304
+
305
+ Table 2: Performance of face identification on QMUL-SurvFace. Most compared results are cited from [17, 54] except BTNet.
306
+
307
+ <table><tr><td rowspan="2"></td><td colspan="5">TPIR20(%)@FPIR</td></tr><tr><td>AUC</td><td>0.3</td><td>0.2</td><td>0.1</td><td>0.01</td></tr><tr><td>VGG-Face [55]</td><td>14.0</td><td>5.1</td><td>2.6</td><td>0.8</td><td>0.1</td></tr><tr><td>DeepID2 [56]</td><td>20.8</td><td>12.8</td><td>8.1</td><td>3.4</td><td>0.8</td></tr><tr><td>FaceNet [57]</td><td>19.8</td><td>12.7</td><td>8.1</td><td>4.3</td><td>1.0</td></tr><tr><td>SphereFace [58]</td><td>28.1</td><td>21.3</td><td>15.7</td><td>8.3</td><td>1.0</td></tr><tr><td>SRCNN [59]</td><td>27.0</td><td>20.0</td><td>14.9</td><td>6.2</td><td>0.6</td></tr><tr><td>FSRCNN [60]</td><td>27.3</td><td>20.0</td><td>14.4</td><td>6.1</td><td>0.7</td></tr><tr><td>VDSR [61]</td><td>27.3</td><td>20.1</td><td>14.5</td><td>6.1</td><td>0.8</td></tr><tr><td>DRRN [62]</td><td>27.5</td><td>20.3</td><td>14.9</td><td>6.3</td><td>0.6</td></tr><tr><td>LapSRN [63]</td><td>27.4</td><td>20.2</td><td>14.7</td><td>6.3</td><td>0.7</td></tr><tr><td>ArcFace [1]</td><td>25.3</td><td>18.7</td><td>15.1</td><td>10.1</td><td>2.0</td></tr><tr><td>RAN [54]</td><td>32.3</td><td>26.5</td><td>21.6</td><td>14.9</td><td>3.8</td></tr><tr><td>BTNet (avg.+floor)</td><td>32.6</td><td>27.9</td><td>23.4</td><td>16.5</td><td>1.4</td></tr><tr><td>BTNet (avg.+near)</td><td>34.6</td><td>30.3</td><td>25.7</td><td>18.9</td><td>1.5</td></tr><tr><td>BTNet (avg.+ceil)</td><td>35.4</td><td>31.1</td><td>26.8</td><td>20.3</td><td>2.2</td></tr><tr><td>BTNet (min+floor)</td><td>32.3</td><td>27.6</td><td>23.2</td><td>16.1</td><td>1.4</td></tr><tr><td>BTNet (min+near)</td><td>34.0</td><td>29.6</td><td>25.0</td><td>18.0</td><td>1.4</td></tr><tr><td>BTNet (min+ceil)</td><td>35.3</td><td>31.0</td><td>26.6</td><td>19.9</td><td>2.0</td></tr><tr><td>BTNet (max+floor)</td><td>33.6</td><td>29.1</td><td>24.5</td><td>17.6</td><td>1.3</td></tr><tr><td>BTNet (max+near)</td><td>35.2</td><td>31.0</td><td>26.4</td><td>19.6</td><td>1.7</td></tr><tr><td>BTNet (max+ceil)</td><td>35.4</td><td>31.2</td><td>26.9</td><td>20.6</td><td>2.5</td></tr></table>
308
+
309
+ # 4.4 Multi-Resolution Feature Aggregation
310
+
311
+ Multi-resolution feature aggregation is common in set-based recognition tasks where the model needs to determine the similarity of sets (templates), instead of images. Each set could contain images of the same identity with different resolutions. In our experiment, we rescale the original and flipped images in each set to different resolutions and aggregate their features into a representation of the template. Detailed experimental results can be seen in Appendix A.5.
312
+
313
+ Table 3 (a) compares the cross-resolution results of $\mathrm { T A R } @ \mathrm { F A R } = 1 0 ^ { - 4 }$ for 1:1 verification. The cross-resolution features are ensured to be mapped to the same vector space where the aggregation is conducted for $\varphi _ { h r }$ and $\varphi _ { m r }$ , but we can observe that $\varphi _ { h r }$ performs much better than $\varphi _ { m r }$ . One possible reason is that $\varphi _ { h r }$ has outstanding discriminability to extract HR features, while LR features may not overly deteriorate the HR information. This phenomenon also suggests that $\varphi _ { m r }$ sacrifices its discriminability in exchange for the adaptability for resolution-variance. We can see $\varphi _ { b t }$ is comparable with $\varphi _ { h r }$ , demonstrating the discriminative power of BTNet for aggregating multi-resolution features.
314
+
315
+ Table 3 (b) compares the same-resolution results of $\mathrm { T A R } @ \mathrm { F A R } = 1 0 ^ { - 4 }$ for 1:1 verification. When HR information is removed from the template representation (i.e., test settings 7&7, 14&14, 28&28), $\varphi _ { h r }$ suffers from performance degradation as well, as the informative embedding cannot catch the lost details of the LR images [54]. Both $\varphi _ { m m }$ and $\varphi _ { m r }$ improve with a limited same-resolution gain, while $\varphi _ { b t }$ surpasses the baselines by a large margin while also reducing the compute.
316
+
317
+ In Table 4 we show the results of291 $\mathrm { T P I R } @ \mathrm { F P I R } { = } 1 0 ^ { - 1 }$ for 1:N identification protocol. Similar to our 292 results for 1:1 verification, we are able to observe that $\varphi _ { b t }$ is comparable or even better than $\varphi _ { h r }$ with
318
+
319
+ Table 3: Comparison of different methods on the IJB-C dataset 1:1 face verification task.
320
+ “TAR” denotes TAR $( \% @ \mathsf { F A R = } 1 \mathsf { e } { \mathrm { - } } 4 )$ .
321
+
322
+ (a) Cross-resolution feature aggregation.
323
+
324
+ (b) Same-resolution feature aggregation.
325
+
326
+ <table><tr><td colspan="2">7&amp;7</td><td colspan="2">14&amp;14</td><td colspan="2">28&amp;28</td><td colspan="2">112&amp;112</td></tr><tr><td>TAR</td><td>Gain</td><td>TAR</td><td>Gain</td><td>TAR</td><td>Gain</td><td>TAR</td><td>Gain</td></tr><tr><td>4.83</td><td>=</td><td>33.74</td><td></td><td>89.65</td><td></td><td>96.40</td><td></td></tr><tr><td>4.83</td><td>+0.00</td><td>29.26</td><td>-1.00</td><td>92.58</td><td>+1.00</td><td>96.40</td><td>=</td></tr><tr><td>4.48</td><td>-</td><td>40.51</td><td>+1.51</td><td>92.81</td><td>+1.08</td><td>96.06</td><td></td></tr><tr><td>35.47</td><td>-</td><td>82.08</td><td>+10.79</td><td>94.50</td><td>+1.66</td><td>96.06</td><td>=</td></tr></table>
327
+
328
+ <table><tr><td></td><td colspan="2">112&amp;7</td><td colspan="2">112&amp;14</td><td colspan="2">112&amp;28</td></tr><tr><td></td><td>TAR</td><td>Gain</td><td>TAR</td><td>Gain</td><td>TAR</td><td>Gain</td></tr><tr><td>hr</td><td>88.89</td><td></td><td>92.40</td><td>=</td><td>95.62</td><td></td></tr><tr><td>mm</td><td>74.54</td><td>-0.56</td><td>93.52</td><td>+1.33</td><td>95.42</td><td>-0.69</td></tr><tr><td>mr</td><td>63.11</td><td>-1.00</td><td>91.56</td><td>-1.00</td><td>95.33</td><td>-1.00</td></tr><tr><td>bt(Ours)</td><td>88.17</td><td>-0.03</td><td>93.97</td><td>+1.87</td><td>95.62</td><td>+0.00</td></tr></table>
329
+
330
+ Table 4: Comparison of different methods on the IJB-C dataset 1: N face identification task.
331
+ “TPIR” denotes TPIR $( \% @ \mathsf { G P I R { = } } 0 . 1 $ ).
332
+
333
+ (a) Cross-resolution feature aggregation.
334
+
335
+ <table><tr><td></td><td colspan="2">112&amp;7</td><td colspan="2">112&amp;14</td><td colspan="2">112&amp;28</td></tr><tr><td></td><td>TPIR</td><td>Gain</td><td>TPIR</td><td>Gain</td><td>TPIR</td><td>Gain</td></tr><tr><td>hr</td><td>85.60</td><td>-</td><td>90.11</td><td>-</td><td>94.27</td><td>-</td></tr><tr><td>mm</td><td>69.70</td><td>-0.55</td><td>91.73</td><td>+1.53</td><td>94.13</td><td>-0.33</td></tr><tr><td>mr</td><td>56.64</td><td>-1.00</td><td>89.05</td><td>-1.00</td><td>93.84</td><td>-1.00</td></tr><tr><td>bt(Ours)</td><td>83.93</td><td>-0.06</td><td>91.87</td><td>+1.66</td><td>94.33</td><td>+0.14</td></tr></table>
336
+
337
+ (b) Same-resolution feature aggregation.
338
+
339
+ <table><tr><td colspan="2">7&amp;7</td><td colspan="2">14&amp;14</td><td>28&amp;28</td><td></td><td colspan="2">112&amp;112</td></tr><tr><td>TPIR</td><td>Gain</td><td>TPIR</td><td>Gain</td><td>TPIR</td><td>Gain</td><td>TPIR</td><td>Gain</td></tr><tr><td>3.12</td><td>-</td><td>26.37</td><td>-</td><td>86.06</td><td>=</td><td>95.57</td><td>-</td></tr><tr><td>3.24</td><td>+1.00</td><td>21.84</td><td>-1.00</td><td>89.76</td><td>+1.00</td><td>95.57</td><td>=</td></tr><tr><td>3.25</td><td>+1.08</td><td>37.58</td><td>+2.47</td><td>91.02</td><td>+1.34</td><td>94.85</td><td>-</td></tr><tr><td>27.70</td><td>+204.83</td><td>76.65</td><td>+11.10</td><td>92.89</td><td>+1.85</td><td>94.85</td><td>-</td></tr></table>
340
+
341
+ 293 HR information involved and can preserve superior discriminability with limited LR information,
342
+ 294 while also being more computationally efficient.
343
+
344
+ ![](images/a8c4e8888c6239a2f78ab3386fd66c4578ddb9b6f3764bbdd536c5e5c274bf6e.jpg)
345
+ Figure 6: Branch selection process. Max/min/average is used on (W, H) to obtain a resolution indicator for further allocation (floor/near/ceil) to a certain branch.
346
+
347
+ # 295 5 Discussion and Conclusion
348
+
349
+ This paper works on the problem of multi-resolution face recognition, and provides a new scheme to operate images conditioned on its input resolution without large span rescaling. The error introduced by up-sampling via interpolation is investigated and analyzed. Decoupled as branches for discriminative representation learning and coupled as the trunk for compatible representation learning, our Branch-to-Trunk Network (BTNet) achieves significant improvements on multi-resolution face verification and identification tasks. Besides, the superiority of BTNet in reducing computational cost and parameter storage cost is also demonstrated. It is worth noting that our approach is easy to expand to recognition tasks for other classes of objects and has the potential to serve as a general network architecture for multi-resolution visual recognition.
350
+
351
+ Limitations and Future Work. The dislocation between the underlying optical resolution of native face images and that of a certain branch may limit the power of the model, which may be improved by selecting the optimal processing branch for the input in combination with the image quality, rather than by image size alone. The optimal branch selection strategy is not fully investigated though we have provided an intuitive way to select the branch for inputs (see Figure 6). Importantly, based on the unified multi-resolution metric space, the underlying resolution of the inputs (integrated spatial resolution with quality assessment) can be utilized to provide the reliability of the representation and contribute to risk-controlled face recognition. They will be our future research directions.
352
+
353
+ References
354
+ [1] Jiankang Deng, Jia Guo, Niannan Xue, and Stefanos Zafeiriou. Arcface: Additive angular margin loss for deep face recognition. In IEEE Conference on Computer Vision and Pattern Recognition, CVPR 2019, Long Beach, CA, USA, June 16-20, 2019, pages 4690–4699. Computer Vision Foundation / IEEE, 2019.
355
+ [2] Xiaobo Wang, Shifeng Zhang, Shuo Wang, Tianyu Fu, Hailin Shi, and Tao Mei. Mis-classified vector guided softmax loss for face recognition. 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 12241– 12248. AAAI Press, 2020.
356
+ [3] Yuge Huang, Yuhan Wang, Ying Tai, Xiaoming Liu, Pengcheng Shen, Shaoxin Li, Jilin Li, and Feiyue Huang. Curricularface: Adaptive curriculum learning loss for deep face recognition. In 2020 IEEE/CVF Conference on Computer Vision and Pattern Recognition, CVPR 2020, Seattle, WA, USA, June 13-19, 2020, pages 5900–5909. Computer Vision Foundation / IEEE, 2020.
357
+ [4] Shizhan Zhu, Sifei Liu, Chen Change Loy, and Xiaoou Tang. Deep cascaded bi-network for face hallucination. In Bastian Leibe, Jiri Matas, Nicu Sebe, and Max Welling, editors, Computer Vision – ECCV 2016, pages 614–630, Cham, 2016. Springer International Publishing.
358
+ [5] Klemen Grm, Walter J. Scheirer, and Vitomir Struc. Face hallucination using cascaded superresolution and identity priors. IEEE Trans. Image Process., 29:2150–2165, 2020.
359
+ [6] Zhangyang Wang, Shiyu Chang, Yingzhen Yang, Ding Liu, and Thomas S. Huang. Studying very low resolution recognition using deep networks. CoRR, abs/1601.04153, 2016.
360
+ [7] Zhiyi Cheng, Xiatian Zhu, and Shaogang Gong. Low-resolution face recognition. In C. V. Jawahar, Hongdong Li, Greg Mori, and Konrad Schindler, editors, Computer Vision - ACCV 2018 - 14th Asian Conference on Computer Vision, Perth, Australia, December 2-6, 2018, Revised Selected Papers, Part III, volume 11363 of Lecture Notes in Computer Science, pages 605–621. Springer, 2018.
361
+ [8] Xi Yin, Ying Tai, Yuge Huang, and Xiaoming Liu. FAN: feature adaptation network for surveillance face recognition and normalization. In Hiroshi Ishikawa, Cheng-Lin Liu, Tomás Pajdla, and Jianbo Shi, editors, Computer Vision - ACCV 2020 - 15th Asian Conference on Computer Vision, Kyoto, Japan, November 30 - December 4, 2020, Revised Selected Papers, Part II, volume 12623 of Lecture Notes in Computer Science, pages 301–319. Springer, 2020.
362
+ [9] Maneet Singh, Shruti Nagpal, Richa Singh, and Mayank Vatsa. Dual directed capsule network for very low resolution image recognition. In 2019 IEEE/CVF International Conference on Computer Vision, ICCV 2019, Seoul, Korea (South), October 27 - November 2, 2019, pages 340–349. IEEE, 2019.
363
+ [10] Aashish Rai, Vishal M. Chudasama, Kishor P. Upla, Kiran B. Raja, Raghavendra Ramachandra, and Christoph Busch. Comsupresnet: A compact super-resolution network for low-resolution face images. In 8th International Workshop on Biometrics and Forensics, IWBF 2020, Porto, Portugal, April 29-30, 2020, pages 1–6. IEEE, 2020.
364
+ [11] Yantao Shen, Yuanjun Xiong, Wei Xia, and Stefano Soatto. Towards backward-compatible representation learning. In 2020 IEEE/CVF Conference on Computer Vision and Pattern Recognition, CVPR 2020, Seattle, WA, USA, June 13-19, 2020, pages 6367–6376. Computer Vision Foundation / IEEE, 2020.
365
+ [12] Mateusz Budnik and Yannis Avrithis. Asymmetric metric learning for knowledge transfer. In IEEE Conference on Computer Vision and Pattern Recognition, CVPR 2021, virtual, June 19-25, 2021, pages 8228–8238. Computer Vision Foundation / IEEE, 2021.
366
+ 360 [13] Chien-Yi Wang, Ya-Liang Chang, Shang-Ta Yang, Dong Chen, and Shang-Hong Lai. Unified representation learning for cross model compatibility. In 31st British Machine Vision Conference 2020, BMVC 2020, Virtual Event, UK, September 7-10, 2020. BMVA Press, 2020.
367
+ 363 [14] Qiang Meng, Chixiang Zhang, Xiaoqiang Xu, and Feng Zhou. Learning compatible embeddings. In 2021 IEEE/CVF International Conference on Computer Vision, ICCV 2021, Montreal, QC, Canada, October 10-17, 2021, pages 9919–9928. IEEE, 2021.
368
+ 366 [15] Rahul Duggal, Hao Zhou, Shuo Yang, Yuanjun Xiong, Wei Xia, Zhuowen Tu, and Stefano Soatto. Compatibility-aware heterogeneous visual search. In IEEE Conference on Computer Vision and Pattern Recognition, CVPR 2021, virtual, June 19-25, 2021, pages 10723–10732. Computer Vision Foundation / IEEE, 2021. [16] Mingjian Zhu, Kai Han, Enhua Wu, Qiulin Zhang, Ying Nie, Zhenzhong Lan, and Yunhe Wang. Dynamic resolution network. In Marc’Aurelio Ranzato, Alina Beygelzimer, Yann N. Dauphin, Percy Liang, and Jennifer Wortman Vaughan, editors, Advances in Neural Information Processing Systems 34: Annual Conference on Neural Information Processing Systems 2021, NeurIPS 2021, December 6-14, 2021, virtual, pages 27319–27330, 2021.
369
+ 375 [17] Zhiyi Cheng, Xiatian Zhu, and Shaogang Gong. Surveillance face recognition challenge. CoRR, abs/1804.09691, 2018.
370
+ 377 [18] Geoffrey E. Hinton, Oriol Vinyals, and Jeffrey Dean. Distilling the knowledge in a neural network. CoRR, abs/1503.02531, 2015. [19] Byeongho Heo, Jeesoo Kim, Sangdoo Yun, Hyojin Park, Nojun Kwak, and Jin Young Choi. A comprehensive overhaul of feature distillation. In 2019 IEEE/CVF International Conference on Computer Vision, ICCV 2019, Seoul, Korea (South), October 27 - November 2, 2019, pages 1921–1930. IEEE, 2019. [20] Zehao Huang and Naiyan Wang. Like what you like: Knowledge distill via neuron selectivity transfer. CoRR, abs/1707.01219, 2017. [21] Wonpyo Park, Dongju Kim, Yan Lu, and Minsu Cho. Relational knowledge distillation. In IEEE Conference on Computer Vision and Pattern Recognition, CVPR 2019, Long Beach, CA, USA, June 16-20, 2019, pages 3967–3976. Computer Vision Foundation / IEEE, 2019.
371
+ 388 [22] Adriana Romero, Nicolas Ballas, Samira Ebrahimi Kahou, Antoine Chassang, Carlo Gatta, and Yoshua Bengio. Fitnets: Hints for thin deep nets. 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. [23] Frederick Tung and Greg Mori. Similarity-preserving knowledge distillation. In 2019 IEEE/CVF International Conference on Computer Vision, ICCV 2019, Seoul, Korea (South), October 27 - November 2, 2019, pages 1365–1374. IEEE, 2019.
372
+ 395 [24] Sergey Zagoruyko and Nikos Komodakis. Wide residual networks. In Richard C. Wilson, Edwin R. Hancock, and William A. P. Smith, editors, Proceedings of the British Machine Vision Conference 2016, BMVC 2016, York, UK, September 19-22, 2016. BMVA Press, 2016. [25] Junho Yim, Donggyu Joo, Ji-Hoon Bae, and Junmo Kim. A gift from knowledge distillation: Fast optimization, network minimization and transfer learning. In 2017 IEEE Conference on Computer Vision and Pattern Recognition, CVPR 2017, Honolulu, HI, USA, July 21-26, 2017, pages 7130–7138. IEEE Computer Society, 2017. [26] Yonglong Tian, Dilip Krishnan, and Phillip Isola. Contrastive representation distillation. CoRR, abs/1910.10699, 2019.
373
+
374
+ [27] Baoyun Peng, Xiao Jin, Dongsheng Li, Shunfeng Zhou, Yichao Wu, Jiaheng Liu, Zhaoning Zhang, and Yu Liu. Correlation congruence for knowledge distillation. In 2019 IEEE/CVF International Conference on Computer Vision, ICCV 2019, Seoul, Korea (South), October 27 - November 2, 2019, pages 5006–5015. IEEE, 2019.
375
+
376
+ [28] Jangho Kim, Seonguk Park, and Nojun Kwak. Paraphrasing complex network: Network compression via factor transfer. In Samy Bengio, Hanna M. Wallach, Hugo Larochelle, Kristen Grauman, Nicolò Cesa-Bianchi, and Roman Garnett, editors, Advances in Neural Information Processing Systems 31: Annual Conference on Neural Information Processing Systems 2018, NeurIPS 2018, December 3-8, 2018, Montréal, Canada, pages 2765–2774, 2018.
377
+
378
+ [29] Byeongho Heo, Minsik Lee, Sangdoo Yun, and Jin Young Choi. Knowledge transfer via distillation of activation boundaries formed by hidden neurons. 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, pages 3779–3787. AAAI Press, 2019.
379
+
380
+ [30] Yoanna Martínez-Díaz, Heydi Méndez-Vázquez, Luis S. Luevano, Leonardo Chang, and Miguel González-Mendoza. Lightweight low-resolution face recognition for surveillance applications. In 25th International Conference on Pattern Recognition, ICPR 2020, Virtual Event / Milan, Italy, January 10-15, 2021, pages 5421–5428. IEEE, 2020.
381
+
382
+ [31] Luis S. Luevano, Leonardo Chang, Heydi Méndez-Vázquez, Yoanna Martínez-Díaz, and Miguel González-Mendoza. A study on the performance of unconstrained very low resolution face recognition: Analyzing current trends and new research directions. IEEE Access, 9:75470– 75493, 2021.
383
+
384
+ 427 [32] Ze Lu, Xudong Jiang, and Alex C. Kot. Deep coupled resnet for low-resolution face recognition.
385
+ 428 IEEE Signal Process. Lett., 25(4):526–530, 2018.
386
+
387
+ [33] Sivaram Prasad Mudunuri, Soubhik Sanyal, and Soma Biswas. Genlr-net: Deep framework for very low resolution face and object recognition with generalization to unseen categories. In 2018 IEEE Conference on Computer Vision and Pattern Recognition Workshops, CVPR Workshops 2018, Salt Lake City, UT, USA, June 18-22, 2018, pages 489–498. Computer Vision Foundation / IEEE Computer Society, 2018.
388
+
389
+ [34] Juan Zha and Hongyang Chao. TCN: transferable coupled network for cross-resolution face recognition\* . In IEEE International Conference on Acoustics, Speech and Signal Processing, ICASSP 2019, Brighton, United Kingdom, May 12-17, 2019, pages 3302–3306. IEEE, 2019.
390
+
391
+ [35] Jane Bromley, Isabelle Guyon, Yann LeCun, Eduard Säckinger, and Roopak Shah. Signature verification using a siamese time delay neural network. In Jack D. Cowan, Gerald Tesauro, and Joshua Alspector, editors, Advances in Neural Information Processing Systems 6, [7th NIPS Conference, Denver, Colorado, USA, 1993], pages 737–744. Morgan Kaufmann, 1993.
392
+
393
+ [36] Yaniv Taigman, Ming Yang, Marc’Aurelio Ranzato, and Lior Wolf. Deepface: Closing the gap to human-level performance in face verification. In 2014 IEEE Conference on Computer Vision and Pattern Recognition, CVPR 2014, Columbus, OH, USA, June 23-28, 2014, pages 1701–1708. IEEE Computer Society, 2014.
394
+
395
+ [37] Sumit Chopra, Raia Hadsell, and Yann LeCun. Learning a similarity metric discriminatively, with application to face verification. In 2005 IEEE Computer Society Conference on Computer Vision and Pattern Recognition (CVPR 2005), 20-26 June 2005, San Diego, CA, USA, pages 539–546. IEEE Computer Society, 2005.
396
+
397
+ [38] Luca Bertinetto, Jack Valmadre, João F. Henriques, Andrea Vedaldi, and Philip H. S. Torr. Fully-convolutional siamese networks for object tracking. In Gang Hua and Hervé Jégou, editors, Computer Vision - ECCV 2016 Workshops - Amsterdam, The Netherlands, October 8-10 and 15-16, 2016, Proceedings, Part II, volume 9914 of Lecture Notes in Computer Science, pages 850–865, 2016. [39] Sergey Zagoruyko and Nikos Komodakis. Learning to compare image patches via convolutional neural networks. In IEEE Conference on Computer Vision and Pattern Recognition, CVPR 2015, Boston, MA, USA, June 7-12, 2015, pages 4353–4361. IEEE Computer Society, 2015. [40] Lloyd H. Hughes, Michael Schmitt, Lichao Mou, Yuanyuan Wang, and Xiao Xiang Zhu. Identifying corresponding patches in SAR and optical images with a pseudo-siamese CNN. IEEE Geosci. Remote. Sens. Lett., 15(5):784–788, 2018. [41] Antonio Torralba, Robert Fergus, and William T. Freeman. 80 million tiny images: A large data set for nonparametric object and scene recognition. IEEE Trans. Pattern Anal. Mach. Intell., 30(11):1958–1970, 2008. [42] Tony Lindeberg. Scale-space theory: a basic tool for analyzing structures at different scales. Journal of Applied Statistics, 21(1-2):225–270, 1994.
398
+ 465 [43] Yui Man Lui, David Bolme, Bruce A. Draper, J. Ross Beveridge, Geoff Givens, and P. Jonathon Phillips. A meta-analysis of face recognition covariates. In 2009 IEEE 3rd International Conference on Biometrics: Theory, Applications, and Systems, pages 1–8, 2009. [44] Hugo Touvron, Andrea Vedaldi, Matthijs Douze, and Hervé Jégou. Fixing the train-test resolution discrepancy. 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 8250–8260, 2019. [45] Sergey Ioffe and Christian Szegedy. Batch normalization: Accelerating deep network training by reducing internal covariate shift. In Francis R. Bach and David M. Blei, editors, Proceedings of the 32nd International Conference on Machine Learning, ICML 2015, Lille, France, 6-11 July 2015, volume 37 of JMLR Workshop and Conference Proceedings, pages 448–456. JMLR.org, 2015. [46] Jiankang Deng, Jia Guo, Debing Zhang, Yafeng Deng, Xiangju Lu, and Song Shi. Lightweight face recognition challenge. In 2019 IEEE/CVF International Conference on Computer Vision Workshops, ICCV Workshops 2019, Seoul, Korea (South), October 27-28, 2019, pages 2638– 2646. IEEE, 2019. [47] Gary B Huang, Marwan Mattar, Tamara Berg, and Eric Learned-Miller. Labeled faces in the wild: A database forstudying face recognition in unconstrained environments. In Workshop on faces in’Real-Life’Images: detection, alignment, and recognition, 2008. [48] Soumyadip Sengupta, Jun-Cheng Chen, Carlos Castillo, Vishal M Patel, Rama Chellappa, and David W Jacobs. Frontal to profile face verification in the wild. In 2016 IEEE winter conference on applications of computer vision (WACV), pages 1–9. IEEE, 2016.
399
+ 488 [49] Stylianos Moschoglou, Athanasios Papaioannou, Christos Sagonas, Jiankang Deng, Irene Kotsia, and Stefanos Zafeiriou. Agedb: The first manually collected, in-the-wild age database. In 2017 IEEE Conference on Computer Vision and Pattern Recognition Workshops, CVPR Workshops 2017, Honolulu, HI, USA, July 21-26, 2017, pages 1997–2005. IEEE Computer Society, 2017. [50] Tianyue Zheng, Weihong Deng, and Jiani Hu. Cross-age LFW: A database for studying cross-age face recognition in unconstrained environments. CoRR, abs/1708.08197, 2017.
400
+
401
+ [51] Tianyue Zheng and Weihong Deng. Cross-pose lfw: A database for studying cross-pose face recognition in unconstrained environments. Beijing University of Posts and Telecommunications, Tech. Rep, 5:7, 2018.
402
+
403
+ [52] Brianna Maze, Jocelyn C. Adams, James A. Duncan, Nathan D. Kalka, Tim Miller, Charles Otto, Anil K. Jain, W. Tyler Niggel, Janet Anderson, Jordan Cheney, and Patrick Grother. IARPA janus benchmark - C: face dataset and protocol. In 2018 International Conference on Biometrics, ICB 2018, Gold Coast, Australia, February 20-23, 2018, pages 158–165. IEEE, 2018.
404
+ [53] Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. In 2016 IEEE Conference on Computer Vision and Pattern Recognition, CVPR 2016, Las Vegas, NV, USA, June 27-30, 2016, pages 770–778. IEEE Computer Society, 2016.
405
+ [54] Han Fang, Weihong Deng, Yaoyao Zhong, and Jiani Hu. Generate to adapt: Resolution adaption network for surveillance face recognition. 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 XV, volume 12360 of Lecture Notes in Computer Science, pages 741–758. Springer, 2020.
406
+ [55] Omkar M. Parkhi, Andrea Vedaldi, and Andrew Zisserman. Deep face recognition. In Xianghua Xie, Mark W. Jones, and Gary K. L. Tam, editors, Proceedings of the British Machine Vision Conference 2015, BMVC 2015, Swansea, UK, September 7-10, 2015, pages 41.1–41.12. BMVA Press, 2015.
407
+ [56] Yi Sun, Yuheng Chen, Xiaogang Wang, and Xiaoou Tang. Deep learning face representation by joint identification-verification. In Zoubin Ghahramani, Max Welling, Corinna Cortes, Neil D. Lawrence, and Kilian Q. Weinberger, editors, Advances in Neural Information Processing Systems 27: Annual Conference on Neural Information Processing Systems 2014, December 8-13 2014, Montreal, Quebec, Canada, pages 1988–1996, 2014.
408
+ [57] Florian Schroff, Dmitry Kalenichenko, and James Philbin. Facenet: A unified embedding for face recognition and clustering. In IEEE Conference on Computer Vision and Pattern Recognition, CVPR 2015, Boston, MA, USA, June 7-12, 2015, pages 815–823. IEEE Computer Society, 2015.
409
+ [58] Weiyang Liu, Yandong Wen, Zhiding Yu, Ming Li, Bhiksha Raj, and Le Song. Sphereface: Deep hypersphere embedding for face recognition. In 2017 IEEE Conference on Computer Vision and Pattern Recognition, CVPR 2017, Honolulu, HI, USA, July 21-26, 2017, pages 6738–6746. IEEE Computer Society, 2017.
410
+ [59] Chao Dong, Chen Change Loy, Kaiming He, and Xiaoou Tang. Learning a deep convolutional network for image super-resolution. 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 IV, volume 8692 of Lecture Notes in Computer Science, pages 184–199. Springer, 2014.
411
+ [60] Chao Dong, Chen Change Loy, and Xiaoou Tang. Accelerating the super-resolution convolutional neural network. In Bastian Leibe, Jiri Matas, Nicu Sebe, and Max Welling, editors, Computer Vision - ECCV 2016 - 14th European Conference, Amsterdam, The Netherlands, October 11-14, 2016, Proceedings, Part II, volume 9906 of Lecture Notes in Computer Science, pages 391–407. Springer, 2016.
412
+ [61] Jiwon Kim, Jung Kwon Lee, and Kyoung Mu Lee. Accurate image super-resolution using very deep convolutional networks. In 2016 IEEE Conference on Computer Vision and Pattern Recognition, CVPR 2016, Las Vegas, NV, USA, June 27-30, 2016, pages 1646–1654. IEEE Computer Society, 2016.
413
+ [62] Ying Tai, Jian Yang, and Xiaoming Liu. Image super-resolution via deep recursive residual network. In 2017 IEEE Conference on Computer Vision and Pattern Recognition, CVPR 2017, Honolulu, HI, USA, July 21-26, 2017, pages 2790–2798. IEEE Computer Society, 2017.
414
+ [63] Wei-Sheng Lai, Jia-Bin Huang, Narendra Ahuja, and Ming-Hsuan Yang. Deep laplacian pyramid networks for fast and accurate super-resolution. In 2017 IEEE Conference on Computer Vision and Pattern Recognition, CVPR 2017, Honolulu, HI, USA, July 21-26, 2017, pages 5835–5843. IEEE Computer Society, 2017.
415
+ [64] Z. G. Liu and D. Z. Liu. Reappraising about image magnification methods based on wavelet transformation. Journal of Image and Graphics, 2003.
416
+ [65] Wan-Chi Siu and Kwok-Wai Hung. Review of image interpolation and super-resolution. In Asia-Pacific Signal and Information Processing Association Annual Summit and Conference, APSIPA 2012, Hollywood, CA, USA, December 3-6, 2012, pages 1–10. IEEE, 2012.
417
+ [66] Haohan Wang, Xindi Wu, Zeyi Huang, and Eric P. Xing. High-frequency component helps explain the generalization of convolutional neural networks. In 2020 IEEE/CVF Conference on Computer Vision and Pattern Recognition, CVPR 2020, Seattle, WA, USA, June 13-19, 2020, pages 8681–8691. Computer Vision Foundation / IEEE, 2020.
418
+
419
+ # Checklist
420
+
421
+ 1. For all authors...
422
+
423
+ (a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes]
424
+ (b) Did you describe the limitations of your work? [Yes] See Section 5.The dislocation between the underlying optical resolution of native face images and that of a certain branch may limit the power of the model, which may be improved by selecting the optimal processing branch for the input in combination with the image quality, rather than by image size alone. The optimal branch selection strategy is not fully investigated though we have provided an intuitive way to select the branch for inputs.
425
+ (c) Did you discuss any potential negative societal impacts of your work? [N/A] We study a general framework for multi-resolution face recognition. Our method is not for specific applications, which does not directly involve societal issues.
426
+ (d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
427
+
428
+ 2. If you are including theoretical results...
429
+
430
+ (a) Did you state the full set of assumptions of all theoretical results? [Yes] See Appendix A.1
431
+ (b) Did you include complete proofs of all theoretical results? [Yes] See Appendix A.1
432
+
433
+ 3. If you ran experiments...
434
+
435
+ (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]
436
+ (b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes]
437
+ (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 works, where they didn’t report the error bars.
438
+ (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 in Section 4.
439
+
440
+ 4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
441
+
442
+ (a) If your work uses existing assets, did you cite the creators? [Yes]
443
+ (b) Did you mention the license of the assets? [N/A]
444
+ (c) Did you include any new assets either in the supplemental material or as a URL? [No]
445
+ (d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [N/A]
446
+ (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [N/A]
447
+
448
+ 5. If you used crowdsourcing or conducted research with human subjects...
449
+
450
+ 591
451
+ 592
452
+ 593
453
+ 594
454
+ 595
455
+ 596
456
+ 597
457
+
458
+ (a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A]
459
+ (b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A]
460
+ (c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]
md/dev/Bct2f8fRd8S/Bct2f8fRd8S.md ADDED
@@ -0,0 +1,331 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # The Unreliability of Explanations in Few-shot Prompting for Textual Reasoning
2
+
3
+ Xi Ye Greg Durrett Department of Computer Science The University of Texas at Austin {xiye,gdurrett}@cs.utexas.edu
4
+
5
+ # Abstract
6
+
7
+ Does prompting a large language model (LLM) like GPT-3 with explanations improve in-context learning? We study this question on two NLP tasks that involve reasoning over text, namely question answering and natural language inference. We test the performance of four LLMs on three textual reasoning datasets using prompts that include explanations in multiple different styles. For these tasks, we find that including explanations in the prompts for OPT, GPT-3 (davinci), and InstructGPT (text-davinci-001) only yields small to moderate accuracy improvements over standard few-show learning. However, text-davinci-002 is able to benefit more substantially.
8
+
9
+ We further show that explanations generated by the LLMs may not entail the models’ predictions nor be factually grounded in the input, even on simple tasks with extractive explanations. However, these flawed explanations can still be useful as a way to verify LLMs’ predictions post-hoc. Through analysis in our three settings, we show that explanations judged by humans to be good—logically consistent with the input and the prediction—more likely cooccur with accurate predictions. Following these observations, we train calibrators using automatically extracted scores that assess the reliability of explanations, allowing us to improve performance post-hoc across all of our datasets.1
10
+
11
+ ![](images/7e3d6e2fb5650e1d21e0b886189e9e8693241f6aef1af0a1c67f6cca21457fa5.jpg)
12
+ Figure 1: Prompting GPT-3 with explanations. By including explanations in the in-context examples, we can cause GPT-3 to generate an explanation for the test example as well. In this case, the generated explanation is nonfactual, despite the simple reasoning involved here. However, we show this nonfactuality actually provides a signal that can help calibrate the model.
13
+
14
+ # 1 Introduction
15
+
16
+ Recent scaling of pre-training has empowered large language models (LLMs) to learn NLP tasks from just a few training examples “in context,” without updating the model’s parameters (Brown et al., 2020). However, this learning process is still poorly understood: models are biased by the order of in-context examples (Zhao et al., 2021) and may not leverage the instructions or even the labels of the examples in the ways one expects (Min et al., 2022; Webson and Pavlick, 2022). Existing tools for interpreting model predictions have high computational cost (Ribeiro et al., 2016) or require access to gradients (Simonyan et al., 2014; Sundararajan et al., 2017), making them unsuitable for investigating in-context learning or explaining the predictions of prompted models.
17
+
18
+ One appealing way to gain more insight into predictions obtained through in-context learning is to let the language model “explain itself” (Nye et al., 2021; Wei et al., 2022; Chowdhery et al., 2022; Marasovic et al., 2022; Lampinen et al., 2022). In addition to input-label training pairs in context, one ´ can prompt the language model with an explanation for each pair and trigger the model to generate an explanation for its prediction (Figure 1). Prompting with explanations introduces much richer information compared to using labels alone, which might guide the inference process and allow the model to learn more information from the examples.
19
+
20
+ In this work, we investigate the nature of the explanations that LLMs generate and whether they can improve few-shot in-context learning for textual reasoning tasks, specifically QA and NLI. Recent prior work that finds success with this approach largely targets symbolic reasoning tasks with a very different structure, such as math word problem solving (Nye et al., 2021; Wei et al., 2022). We experiment on three different datasets spanning QA and NLI with four LLMs: OPT, GPT-3 (davinci), InstructGPT (text-davinci-001), and text-davinci-002. The results suggest that explanations only substantially improve accuracy for text-davinci-002, but give a smaller improvement or even hurt the performance with the other LLMs.
21
+
22
+ Surprisingly, we find that the explanations generated by LLMs can be unreliable, even for a very simple synthetic dataset. We evaluate the explanations along two axes: factuality, whether the explanation is correctly grounded in the input, and consistency, whether the explanation entails the final prediction. LLMs tend to generate consistent explanations that account for the predictions, but the explanations may not be factual, as as shown in Figure 1. Furthermore, our analysis suggests an unreliable explanation more likely indicates a wrong prediction compared to a reliable explanation.
23
+
24
+ Despite LLMs’ failures here, we can still benefit from model-generated explanations by using them for calibration. If we are able to automatically assess the reliability of an explanation, we can allow an LLM to return a null answer when its explanation is unreliable, since the prediction in this case is less likely to be correct. Unfortunately, there is no automated way to perfectly assess the reliability, but we can extract features that approximately reflect it. We use these features to calibrate InstructGPT’s2 predictions, and successfully improve the in-context learning performance across all the datasets.
25
+
26
+ In summary, our main findings are: (1) Simply plugging explanations into the prompt does not always substantially boost the in-context learning performance for textual reasoning. (2) LLMs generate explanations consistent with their predictions, but these explanations might not be factually grounded in the inputs. (3) The factuality of an explanation can serve as an indicator for the correctness of the corresponding prediction. (4) Using features that can approximate the factuality of explanations, we successfully use explanations to improve the in-context learning performance across all tasks.
27
+
28
+ # 2 Does Prompting with Explanations Improve In-Context Learning?
29
+
30
+ In this paper, we specifically focus on tasks involving reasoning over natural language. These are tasks where explanations have been traditionally studied (Camburu et al., 2018; Rajani et al., 2019), but which are more complex than tasks like sentiment analysis which are well explained by extractive rationales (Zaidan et al., 2007; DeYoung et al., 2020). We experiment on two tasks, reading comprehension question answering (QA) and natural language inference (NLI), on three English-language datasets. For each dataset, we create a test set with 250 examples.
31
+
32
+ Figure 2: A SYNTH example and an E-SNLI example. See Figure 3 for ADVHOTPOT examples.
33
+
34
+ <table><tr><td>HINXS</td><td>Context: Question: Answer:</td><td>Christopher agrees with Kevin.Tifany agrees with Mathew.Mary hangs out with Danielle.James hangs out with Thomas.Kevin is a student.Matthew is a plumber.Danielle is a student. Thomas is a plumber. Who hangs out with a student? Explanation:Danielle is a student and Mary hangs out with Danielle.</td></tr><tr><td></td><td>Mary Premise:</td><td>A toddler in a green jersey is being folowed bya wheelchair bound woman in ared sweater past awooden bench.</td></tr><tr><td>IINS-3</td><td>Hypothesis: Label:</td><td>A toddler is walking near his wheelchair bound grandmother. Neither Explanation: the woman may not be his grandmother.</td></tr></table>
35
+
36
+ # 2.1 Datasets
37
+
38
+ Synthetic Multi-hop QA (SYNTH) In order to have a controlled setting where we can easily understand whether explanations are factual and consistent with the answer, we create a synthetic multi-hop QA dataset. Shown in Figure 2, each example in this dataset asks a bridge question (using the terminology of Yang et al. (2018)) over a context consisting of supporting facts paired with controlled distractors. This dataset is carefully designed to avoid spurious correlations, giving us full understanding over the correct reasoning process and the explanation for every example, which naturally consists of the two supporting sentences. See Appendix B for full details of this dataset.3
39
+
40
+ Adversarial HotpotQA (ADVHOTPOT) We also test on the English-language Adversarial HotpotQA dataset (Yang et al., 2018; Jiang and Bansal, 2019). We use the adversarially augmented version since InstructGPT achieves high performance on the distractor setting of the original dataset. We make a challenging set of examples by balancing sets of questions on which InstructGPT makes correct and incorrect predictions. The context of each question includes two ground truth supporting paragraphs and two adversarial paragraphs. Full details of preprocessing the ADVHOTPOT dataset can be found in Appendix C.
41
+
42
+ For ADVHOTPOT, we manually annotated explanations for the training examples. Figure 1 shows an example of such an explanation, highlighted in orange. We could use the supporting sentences as the explanations, but we found they are usually too verbose and not sufficient, e.g., with anaphors that resolve outside of the supporting sentences. Therefore, we manually annotate a set of explanations which clearly describe the reasoning path for each question.
43
+
44
+ E-SNLI E-SNLI (Camburu et al., 2018) is an English-language classification dataset commonly used to study explanations, released under the MIT license. Shown in Figure 2, each example consists of a premise and a hypothesis, and the task is to classify the hypothesis as entailed by, contradicted by, or neutral with respect to the premise. As a notable contrast to the other datasets, the explanations here are more abstract natural language written by human annotators, as opposed to mostly constructed from extracted snippets of context.
45
+
46
+ # 2.2 Baselines
47
+
48
+ We study the effectiveness of plugging in explanations by comparing the in-context learning performance of prompting with or without explanations. Prompting without explanations resembles the standard few-shot in-context learning approach (Few-Shot). To incorporate explanations into the prompt, we consider the following two most commonly used paradigms:
49
+
50
+ Explain-then-Predict (E-P) prepends an explanation before the label (Figure 1). The language model is expected to generate an explanation first followed by the prediction. The prompting style of past work involving computational traces can be categorized into this paradigm, including Nye et al. (2021) and Wei et al. (2022). This approach is also called a pipeline model in other literature on training models using explanations (Jacovi and Goldberg, 2021; Wiegreffe et al., 2021).
51
+
52
+ Table 1: Results of prompting with explanations on four large language models. Using explanations leads to small to moderate improves performance on OPT, GPT-3, and InstructGPT, and has more prominent effects on text-davinci-002.
53
+
54
+ <table><tr><td colspan="2"></td><td>SYNTH</td><td>ADVHOTPOT</td><td>E-SNLI</td></tr><tr><td rowspan="3">OPT (175B)</td><td>FEW-SHOT</td><td>40.52.8</td><td>49.72.6</td><td>44.03.8</td></tr><tr><td>E-P</td><td>29.60.5</td><td>52.66.5</td><td>39.37.8</td></tr><tr><td>P-E</td><td>40.22.6</td><td>43.34.5</td><td>43.41.6</td></tr><tr><td rowspan="3">GPT-3</td><td>FEW-SHOT</td><td>49.50.6</td><td>49.16.2</td><td>43.35.7</td></tr><tr><td>E-P</td><td>47.12.8</td><td>54.14.1</td><td>40.44.5</td></tr><tr><td>P-E</td><td>51.31.8</td><td>48.74.6</td><td>48.72.4</td></tr><tr><td rowspan="3">InstructGPT</td><td>FEW-SHOT</td><td>54.83.1</td><td>53.22.3</td><td>56.82.0</td></tr><tr><td>E-P</td><td>58.52.1</td><td>58.24.1</td><td>41.82.5</td></tr><tr><td>P-E</td><td>53.61.0</td><td>51.52.4</td><td>59.41.0</td></tr><tr><td rowspan="3">text-davinci-002</td><td>FEW-SHOT</td><td>72.01.4</td><td>77.73.2</td><td>69.12.0</td></tr><tr><td>E-P</td><td>86.93.8</td><td>82.45.1</td><td>75.67.6</td></tr><tr><td>P-E</td><td>81.12.8</td><td>77.24.8</td><td>69.45.0</td></tr></table>
55
+
56
+ Predict-then-Explain (P-E) generates the explanation after the prediction. Unlike E-P, the predicted explanation does not influence the predicted label, since we use greedy inference and the explanation comes afterwards. However, the explanations in the prompt still impact the predictions.
57
+
58
+ # 2.3 Setup
59
+
60
+ For few-shot learning, we use roughly the maximum allowed shots in the prompt that can fit the length limit of OPT (Zhang et al., 2022) and GPT-3 (Brown et al., 2020), which is 16 for SYNTH, 6 for ADVHOTPOT, and 32 for E-SNLI, respectively.4 We experiment with four LLMs, including OPT (175B), GPT-3 (davinci), InstructGPT (text-davinci-001), and text-davinci-002. OPT and GPT-3 are trained using the standard causal language modeling objective, whereas InstructGPT and text-davinci-002 are trained with special instruction data and human annotations. We generate outputs with greedy decoding (temperature set to be 0). Our prompt formats follow those in Brown et al. (2020). The explanations are inserted before/after the prediction with conjunction words like because. Please refer to Appendix A for full prompts. Because the results of in-context learning vary with the examples presented in the input prompt, for each dataset, we randomly sample multiple groups of training shots, and report the mean and standard deviation of the results (subscript). We use 5 groups for InstructGPT, the primary LM we are using throughout our paper, and 3 groups for the rest.
61
+
62
+ # 2.4 Results
63
+
64
+ As shown in Table 1, OPT, GPT-3, and InstructGPT show small to moderate improvements from using explanations for textual reasoning tasks. On the two QA tasks, SYNTH and ADVHOTPOT, E-P improves the performance of InstructGPT, the best among these three LMs, from 54.8 to 58.5 and 56.8 to 59.4, respectively.5 On E-SNLI, P-E outperforms FEW-SHOT by 2.6, whereas E-P substantially lags FEW-SHOT. Comparing E-P against P-E on SYNTH and E-SNLI, E-P typically degrades performance (except on SYNTH for InstructGPT) and P-E is inconsistent across the different models, whereas E-P consistently leads to performance improvements on ADVHOTPOT. There is no single winner between the two paradigms of using explanations; choosing the most effective way is task-specific. Overall, vanilla LLMs (OPT and GPT-3) see limited benefit from producing explanations, and even the Instruct-series InstructGPT does not see substantial improvements.
65
+
66
+ The only exception is text-davinci-002. text-davinci-002 greatly benefits from explanations in the prompt across all three tasks, and E-P is consistently more effective than P-E. However, it is unclear what contributes to this difference. As far as we are aware, the differences between text-davinci-002 and InstructGPT are not described in any publication or blog post.6 Comparing GPT-3 and InstructGPT, we see the move to Instruct series models is not sufficient to explain the difference. Given the lack of transparency with this model, we hesitate to make scientific claims about the results it yields.
67
+
68
+ Figure 3: Explanations generated for ADVHOTPOT. InstructGPT may generate nonfactual explanations containing hallucination (red) or inconsistent explanations contradicting the answer (red).
69
+
70
+ <table><tr><td>naetatr</td><td>Pedro Rubens! The individual chapters were published into 64 &quot;tankobon&quot;by Kodansha. Yoko Shoji(born4June195o,in Mobara,Chiba)isaJapanese mangaartist.She is bestknown for writing &quot;Seito Shokun! Mulder Scully!The individual chapters were published into 14 &quot;tankobon&quot; by Kodansha. Seito Shokun! The individual chapters were published into 24 &quot;tankobon&quot; by Kodansha between. Q:How many chapters does Yoko Shoji&#x27;s most famous manga have?</td></tr><tr><td>Trrnsrtetetr</td><td>A: First,Yoko Shoji&#x27;s mostfamous manga is &quot;Seito Shokun!&quot;.Second,&quot;Seito Shokun!&quot;has 64chapters.The answer is 64. Tim Minchin (December 29,1808 July 31,1875) was the President of the United States. Andrew Johnson (December 29,1808 July 31,1875) was the President of the United States. George Andrew Atzerodt (June 12,1835-July 7,1865)was a conspirator, with John Wilkes Booth. Jesse Andrew Williams (June 12,1835-July7,1865) was a conspirator, with John Wilkes Booth. Q: Who was older, George Atzerodt or Andrew Johnson? A: First,George Atzerodt was bornonJune12,1835.Second,Andrew Johnson was bornon December 29,1808.The answer is George Atzerodt.</td></tr></table>
71
+
72
+ Table 2: Left: factuality (Fac) and consistency (Con) of the generated explanations. Right: the $\%$ of the examples whose explanation factuality/consistency is congruent with the prediction accuracy. In general, LLMs tend to generate consistent but less likely factual explanations.
73
+
74
+ <table><tr><td colspan="2"></td><td>Acc</td><td>Fac</td><td>Con</td><td>Acc=Fac</td><td>Acc=Con</td></tr><tr><td rowspan="7">InstructGPT</td><td colspan="6">reliability of explanations generated by InstructGPT</td></tr><tr><td>SYNTH (E-P)</td><td>58.4</td><td>72.8</td><td>64.8</td><td>66.5</td><td>68.8</td></tr><tr><td>SYNTH (P-E)</td><td>54.8</td><td>51.6</td><td>95.2</td><td>89.6</td><td>57.2</td></tr><tr><td>ADVHP (E-P)</td><td>62.0</td><td>79.6</td><td>91.2</td><td>80.0</td><td>68.4</td></tr><tr><td>ADVHP (P-E)</td><td>54.0</td><td>69.2</td><td>82.0</td><td>77.6</td><td>67.2</td></tr><tr><td>E-SNLI(P-E)</td><td>62.0</td><td>1</td><td>98.8</td><td>1</td><td>62.0</td></tr><tr><td colspan="6">reliability of explanations generated by other LLMs on SYNTH</td></tr><tr><td rowspan="2">OPT (175B)</td><td>SYNTH (E-P)</td><td>30.0</td><td>77.2</td><td>47.2</td><td>45.6</td><td>58.8</td></tr><tr><td>SYNTH (P-E)</td><td>39.6</td><td>64.0</td><td>81.2</td><td>69.2</td><td>49.6</td></tr><tr><td rowspan="2">GPT-3</td><td>SYNTH (E-P)</td><td>46.8</td><td>59.2</td><td>64.8</td><td>66.8</td><td>61.2</td></tr><tr><td>SYNTH (P-E)</td><td>52.4</td><td>52.4</td><td>83.2</td><td>78.4</td><td>58.0</td></tr><tr><td rowspan="2">text-davinci-002</td><td>SYNTH (E-P)</td><td>86.0</td><td>91.6</td><td>85.2</td><td>91.2</td><td>84.8</td></tr><tr><td>SYNTH (P-E)</td><td>81.6</td><td>83.2</td><td>96.4</td><td>95.8</td><td>82.8</td></tr></table>
75
+
76
+ Our results do not suggest immediate strong improvements from incorporating explanations across all LLMs, even for our synthetic dataset, contradicting recent prior work. This can be attributed to the difference between the tasks we study. The tasks that receive significant benefits from using explanations in Nye et al. (2021) and Wei et al. (2022) are all program-like (e.g., integer addition and program execution), whereas the tasks in this work emphasize textual reasoning grounded in provided inputs. In fact, in Wei et al. (2022) and Chowdhery et al. (2022), explanations only show mild benefit on open-domain QA tasks like StrategyQA (Geva et al., 2021) that are closer to our setting.
77
+
78
+ # 3 Can LLMs Generate Factual and Consistent Explanations?
79
+
80
+ Prompting LLMs with explanations and having models generate them may not guarantee higher performance on our tasks. But what about the quality of the model-generated explanations themselves? We assess the reliability of the explanations for the three datasets, measured in terms of two aspects.
81
+
82
+ Factuality refers to whether a generated explanation is faithfully grounded in the corresponding input context (context for QA and premise/hypothesis pair for NLI). A factual explanation should not contain hallucinations that contradict the context. See Figure 3 for a nonfactual explanation.
83
+
84
+ Consistency measures if the explanation entails the prediction. Our concept of consistency resembles plausibility as described in Jacovi and Goldberg (2021), in that we assess whether the prediction follows from the explanation as perceived by a human. See Figure 3 for an inconsistent explanation.
85
+
86
+ For SYNTH, we use rules to automatically judge whether an explanation is factual and consistent on all four LLMs. For ADVHOTPOT and E-SNLI, the authors manually inspected the explanations generated by InstructGPT and annotated them for these two characteristics (more details in Appendix D). Note for each setting, the results are based on the explanations and predictions obtained with a single set of training shots. We only show the results of P-E on E-SNLI, as E-P is substantially worse here.
87
+
88
+ Results We summarize the results in Table 2. We only report consistency on E-SNLI, as the explanations for ESNLI often require some external commonsense knowledge which cannot be easily grounded in the inputs or judged as true or false (examples in Appendix F). The results suggest a disconnect between the model predictions and the “reasoning” in explanations. On InstructGPT, though using explanations improves its performance across three tasks, the generated explanations are unreliable (upper section), even for the straightforward synthetic setting. Comparing the factuality of explanations for SYNTH generated by GPT-3, InstructGPT, and text-davinci-002, we see that instruction tuning improves the factuality, but even the most powerful text-davinci-002 still fails to generate explanations that are perfectly grounded in the input context. Overall, LLMs tend to generate consistent explanations $( > 8 0 \%$ for all three datasets with the right prompt structure), but the explanations are less likely to be factual, which is concerning as they can deceive a user of the system into believing the model’s answer.
89
+
90
+ ![](images/1587e11713a5abeaab67eca8ef5e40f84e75c8296eec9142aad635647d9a3db3.jpg)
91
+ of Correct/Incorrect Predictions by Factuality/Consistency
92
+ Figure 4: Explanations are more likely to be nonfactual than to be inconsistent, and a nonfactual explanation usually indicates an incorrect prediction.
93
+
94
+ # 3.1 Reliability of Explanations and Prediction Accuracy
95
+
96
+ LLMs may hallucinate problematic explanations, but this could actually be advantageous if it gives us a way of spotting when the model’s “reasoning” has failed. We investigate the connection between the reliability of an explanation and the accuracy of a prediction and ask whether a reliable explanation indicates an accurate prediction. (This resembles the linguistic calibration of Mielke et al. (2022), but using a different signal for calibration.)
97
+
98
+ As shown in Table 2 (right), accuracy and factuality/consistency are typically correlated, especially factuality. By knowing whether an explanation is factual, we can guess the model’s accuracy a high fraction of the time (Accuracy $=$ Factuality). A nonfactual explanation very likely means an incorrect prediction on the SYNTH dataset across all four LLMs. On ADVHOTPOT, factuality and InstructGPT’s prediction correspond $8 0 . 0 \%$ of the time, substantially surpassing the prediction accuracy itself. We show fractions of correct and incorrect predictions when the explanations are factual/nonfactual and consistent/inconsistent in Figure 4 for two of our settings. Factual explanations are much more likely paired with correct predictions compared to nonfactual explanations. Consistency is also connected to accuracy but is an inferior indicator compared to factuality in general (Table 2).
99
+
100
+ # 4 Calibrating In-Context Learning using Explanations
101
+
102
+ From Section 3.1, we see that a human oracle assessment of the factuality of an explanation could be of substantial use for calibrating the corresponding prediction. Can we automate this process?
103
+
104
+ We first show how to achieve this goal on the perfectly controlled SYNTH dataset (Section 4.1). On our other two datasets, we use surface lexical matching to approximate semantic matching and give real-valued scores approximately reflecting factuality. Following past work on supervised calibration (Kamath et al., 2020; Chen et al., 2021; Ye and Durrett, 2022), we can learn a calibrator that tunes the probabilities of a prediction based on the score of its explanation (Section 4.2). We show such a calibrator can be trained with a handful of examples beyond those used for in-context learning and successfully improve the in-context learning performance on realistic datasets.7 We note that, as mentioned before, the experiments in this section are conducted on InstructGPT.
105
+
106
+ # 4.1 Motivating Example: Improving SYNTH Dataset
107
+
108
+ We first show how post-hoc calibration functions in the controlled SYNTH setting, where we can simply check the factuality of an explanation. Since the generated explanation always follows the format “B is [profession] and A [verb] B.” (example in Figure 2), we can split the explanation into two sentences. The explanation is factual if and only if each of the two sentences exactly matches one of the sentences in the context.
109
+
110
+ We use the assessment to improve the performance of P-E for SYNTH, where a nonfactual explanation typically indicates an incorrect prediction. This gives us a way to reject presumably incorrect answers. Specifically, we iterate through the top 5 candidate answers (restricted by the API) given by InstructGPT and reject any answer-explanation pair if the explanation is nonfactual until we find a factual one. This procedure dramatically improves the accuracy from $5 2 . 4 \%$ to $7 4 . 8 \%$ . Note that this SYNTH dataset is a challenging task given its lack of reasoning shortcuts: for reference, neither ROBERTA (Liu et al., 2019) nor DEBERTA (He et al., 2021) finetuned with 16 examples can achieve an accuracy surpassing $50 \%$ . With the help of the explanations and the checking procedure, we can use InstructGPT to achieve strong results using few-shot learning.
111
+
112
+ # 4.2 Learning-based Calibration Framework
113
+
114
+ Framework We now introduce the framework that can leverage the factuality assessment of an explanation to calibrate a prediction. Let $\pmb { p }$ be the vector of predicted probabilities associated with each class label in NLI (or the probability score of predicted answer in QA). Let $v$ be a scalar value extracted from the explanation to describe the factuality. Then, we can adjust the probabilities accordingly using a linear model: $\pmb { \hat { p } } = \mathrm { s o f t m a x } ( W [ \pmb { p } ; \pmb { v } ] + b )$ , where $\hat { p }$ is the tuned probabilities.
115
+
116
+ Our calibration framework is extended from classical calibration methods (Platt, 1999; Guo et al., 2017; Zhao et al., 2021), which apply an affine transformation on the probabilities alone: $\hat { p } =$ softmax $( W p + b )$ . In contrast, we use an additional factor $v$ in calibration to incorporate the factuality assessment of the explanation.
117
+
118
+ There are a small number of parameters ( $W$ and $b$ ) that need to be trained in such a calibration framework. We will rely on a few more examples in addition to the shots we use in the prompt to train the calibrator. Specifically, we use the prompt examples to generate the predictions and explanations for these extra examples, and extract predicted probabilities, factors, and target probabilities triples to construct training data points used to train the calibrator. Note this procedure requires no explanation annotations for the extra examples.
119
+
120
+ Approximating Factuality We approximate the factuality using lexical overlap between the explanations and the inputs, which we found to work fairly well for our tasks.
121
+
122
+ ADVHOTPOT: We use an explanation consisting of two sentences (examples in Figure 3) as an illustration. Let $\mathcal { E } = ( E ^ { ( 1 ) } , E ^ { ( 2 ) } )$ be the generated explanation, where $E ^ { ( 1 ) }$ and $E ^ { ( 2 ) }$ are the two sentences, and the $E ^ { ( i ) } = ( e _ { 1 } , e _ { 2 } , \cdot \cdot \cdot )$ contain tokens $e _ { 1 } , e _ { 2 } , \cdots$ . Similarly, let $\mathcal { P } =$ $( P ^ { ( 1 ) } , P ^ { ( 2 ) } , P ^ { ( 3 ) } , P ^ { ( 4 ) } )$ be the context paragraphs, and $P ^ { ( i ) } = ( p _ { 1 } , p _ { 2 } , \cdot \cdot \cdot )$ be the tokens. The factuality estimation of one explanation sentence $E ^ { ( i ) }$ is defined as: $\begin{array} { r } { \mathcal { V } ( E ^ { ( i ) } ) = \operatorname* { m a x } _ { P \in \mathcal { P } } \frac { | E ^ { ( i ) } \cap P | } { | E ^ { ( i ) } | } } \end{array}$ .
123
+
124
+ Intuitively, the factuality score for a sentence $E$ is defined as the maximum number of overlapping tokens over all paragraphs $P$ , normalized by the number of tokens in $E$ . We then define the factuality score for the whole explanation as $\begin{array} { r } { \mathcal { V } ( \mathcal { E } ) = \mathrm { \bar { \ m i n } } _ { E \in \mathcal { E } } \mathcal { V } ( E ) } \end{array}$ , as it requires all sentences to be factual in order to make the entire explanation factual.8
125
+
126
+ E-SNLI: The explanations of E-SNLI do not really involve a concept of factuality. Nevertheless, we use an analogous score following the same principle by viewing the premise as the context. Let $\boldsymbol { E } = ( e _ { 1 } , e _ { 2 } , \cdots )$ be the explanation and $P = ( p _ { 1 } , p _ { 2 } , \cdots )$ be the premise. We simply score the explanation by $\begin{array} { r } { \mathcal { V } ( E ) = \frac { | E | \cap | P | } { | E | } } \end{array}$ . The more an explanation overlaps with the premise, the more factual we judge it to be.
127
+
128
+ # 4.3 Calibrating E-SNLI
129
+
130
+ Setup For E-SNLI, we use calibration methods to postprocess the final probabilities. Unlike classical temperature scaling (Platt, 1999), note that the methods we use here can actually change the prediction; we will therefore evaluate on accuracy of the calibrated model.
131
+
132
+ We study the effectiveness of our explanationbased calibrator under different training data sizes varying from 32 to 128. Recall that we only require explanation annotations for 32 data points, and only need the labels for the rest to train the calibrator. For E-SNLI, we calibrate P-E, which is shown to be more effective than E-P in this setting (Section 2.4).
133
+
134
+ Baselines We provide the performance of finetuned ROBERTA (Liu et al., 2019) model as a reference, finding this to work better than DeBERTa (He et al., 2021). To isolate the effec
135
+
136
+ Table 3: Accuracy $\mathrm { ( m e a n _ { s t d d e v } ) }$ of various methods on E-SNLI under different data conditions. L denotes number of labels (as well as the total number of examples); E denotes the number of explanations. Calibrating using explanations successfully improves the performance of in-context learning.
137
+
138
+ <table><tr><td>w/o Explanation</td><td>32L</td><td>64L</td><td>96L</td><td>128L</td></tr><tr><td>RoBERTa</td><td>40.14.7</td><td>43.05.1</td><td>49.05.2</td><td>54.94.8</td></tr><tr><td>FEW-SHOT</td><td>56.82.0</td><td>1</td><td>1</td><td>1</td></tr><tr><td>FEW-SHOT(NN)</td><td>1</td><td>1</td><td>1</td><td>58.91.0</td></tr><tr><td>FEW-SHOT+PROBCAL</td><td>61.93.8</td><td>62.42.6</td><td>63.22.9</td><td>63.91.2</td></tr><tr><td>w/ Explanation</td><td>32L+32E</td><td>64L+32E</td><td>96L+32E</td><td>128L+32E</td></tr><tr><td>P-E</td><td>59.42.0</td><td>一</td><td></td><td>1</td></tr><tr><td>P-E+PROBCAL</td><td>64.41.8</td><td>65.41.2</td><td>65.41.6</td><td>65.41.9</td></tr><tr><td>P-E+EXPLCAL</td><td>64.22.6</td><td>65.81.3</td><td>67.61.6</td><td>68.51.2</td></tr><tr><td>P-E+ZHANG</td><td>63.03.2</td><td>65.22.2</td><td>65.41.5</td><td>65.92.5</td></tr></table>
139
+
140
+ tiveness of using explanations for calibration, we introduce three additional baselines using nonexplanation-based calibrators. We apply the probability-based calibrator as described in Section 4.2 on the results obtained on few-shot learning (FEW-SHOT $^ { \cdot + }$ PROBCAL) and predict-then-explain pipeline $( { \mathrm { P } } { \cdot } { \mathrm { E } } { + } { \mathrm { P R O B C A L } }$ ). We note that the parameters of these calibrators are trained using the additional data points, as opposed to being heuristically determined as in Zhao et al. (2021). Furthermore, we experiment with a recently proposed supervised calibrator from Zhang et al. (2021), which uses the CLS representations from an additional language model as features in the calibrator. The probabilities are tuned using $\pmb { \hat { p } } = \mathrm { s o f t m a x } ( W [ \pmb { p } ; \pmb { h } ] + \bar { \boldsymbol { b } } )$ , where $^ { h }$ is the CLS representation. Since we do not have access to the embeddings obtained by GPT-3, we use ROBERTA to extract the vectors instead. We use such a calibrator on top of our best-performing base model, P-E, resulting $\mathrm { P } \mathrm { - } \mathrm { E } +$ ZHANG ET AL. (2021).
141
+
142
+ Limited by the maximum prompt length, in-context learning is not able to take as input the additional data used for training the calibrator. For a fair comparison, we can allow the in-context model to use this data by varying the prompts across test examples, dynamically choosing the prompt examples to maximize performance. Choosing closer data points for prompting is a common and effective way of scaling up the training data size for in-context learning (Shin et al., 2021; Liu et al., 2021). Following Liu et al. (2021), we test the performance of choosing nearest neighbors for the prompt based on CLS embedding produced by a ROBERTA model (Liu et al., 2019), referred as FEW-SHOT(NN). It is worth clarifying that the FEW-SHOT and FEW-SHOT $^ +$ PROBCAL approaches use the same set of 32 training shots in the prompt for every test example, whereas the shot sets vary from example to example in FEW-SHOT(NN).
143
+
144
+ Results We show the results in Table 3. We use 5 different groups of training examples and report the mean and standard deviation across the groups. For FEW-SHOT(NN), we only report the results obtained using 128 examples; results using a smaller number of examples will be worse than this.
145
+
146
+ Under 128 training examples, applying a trained calibrator on top of prompting with explanation (i.e., P- $\Xi +$ EXPLCAL) achieves the best accuracy of $6 8 . 5 \%$ , which is $12 \%$ higher than the performance of the vanilla uncalibrated few-shot in-context learning (FEW-SHOT). P-E+EXPLCAL also outperforms FEW-SHOT $^ +$ PROBCAL and P- $\Xi +$ PROBCAL by $5 \%$ and $3 \%$ , respectively. Using explanations is more effective than using probabilities alone. In addition, $\mathrm { P } \mathrm { - } \mathrm { E } +$ EXPLCAL also outperforms P- $\mathsf { E } +$ ZHANG ET AL. (2021), whose performance is on par with P-E+PROBCAL. This suggests the additional CLS information is not very helpful in this setting.
147
+
148
+ As the data size increases from 32 to 128, the performance of the explanation-based calibrator keeps improving notably, whereas the performance of probability-based calibrators nearly saturates at a data size of 96. The performance of FEW-SHOT(NN) with 128 training instances only improves the performance by $3 . 3 \%$ , compared to FEW-SHOT with 32 training instances. Choosing nearest neighbors as the shots, while being effective when having access to a large amount of data, is not helpful in the extreme data-scarce regime. Calibrating using explanations is an effective way of using a few extra data points that cannot fit in the prompt, which is a pitfall of standard in-context learning.
149
+
150
+ Table 4: AUC scores $\left( \mathrm { { m e a n } _ { \mathrm { { s t d } \ d e v } } } \right)$ on ADVHOTPOT under different data conditions. $\mathbf { L }$ and $\mathbf { E }$ denotes the number of label annotations and explanation annotations, respectively. Explanationbased calibration successfully improves the performance on top of prompting with explanations.
151
+
152
+ <table><tr><td>w/o Explanation</td><td>6L</td><td>32L</td><td>64L</td></tr><tr><td>FEW-SHOT FEW-SHOT(NN)</td><td>59.62.4</td><td>1</td><td>1</td></tr><tr><td>w/Explanation</td><td>1 6L+6E</td><td>1 32L+6E</td><td>61.30.9 64L+6E</td></tr><tr><td>E-P</td><td>64.42.9</td><td></td><td></td></tr><tr><td>E-P+EXPLCAL</td><td></td><td>66.03.9</td><td>68.83.0</td></tr><tr><td>E-P+ZHANG</td><td>1 1</td><td>65.63.9</td><td>66.13.2</td></tr></table>
153
+
154
+ ![](images/ac62f2c8bc287230803bb7f2b84c7493d086a7bca98eb99419c3217e5589a8e9.jpg)
155
+ Figure 5: Coverage-Acc curves of various methods on ADVHOTPOT. E- $\mathrm { P } +$ EXPLCAL is better calibrated compared to uncalbrated E-P as well as the other approaches.
156
+
157
+ Finally, ROBERTA finetuned using 128 shots only achieves an accuracy of $5 4 . 9 \%$ , lagging the performance of GPT-3 based models. The limited training data size is insufficient for finetuning smaller language models like ROBERTA, but is sufficient for $\mathrm { P } \mathrm { - } \mathrm { E } +$ EXPLCAL to be effective.
158
+
159
+ # 4.4 Calibrating ADVHOTPOT
160
+
161
+ Setup For the ADVHOTPOT dataset, our calibration takes the form of tuning the confidence scores of the predicted answers to better align them with the correctness of predictions. These confidence scores can be used in a “selective QA” setting (Kamath et al., 2020), where the model can abstain on a certain fraction of questions where it assigns low confidence to its answers. We use the area under coverage-accuracy curve (AUC) to evaluate how well a model is calibrated as in past literature (Kamath et al., 2020; Chen et al., 2021; Zhang et al., 2021; Garg and Moschitti, 2021; Ye and Durrett, 2022). The curve plots the average accuracy with varying fractions (coverage) of questions being answered (examples in Figure 5). For any given coverage, a better calibrated model should be able to identify questions that it performs best on, hence resulting a higher AUC.
162
+
163
+ We experiment with training data set sizes of 6, 32, and 64. We report the results averaged from 5 trials using different training sets. For ADVHOTPOT, we calibrate E-P, which is shown to be more effective than P-E in this setting (Section 2.4). Our approach is also effective for calibrating P-E; please refer to Appendix E for details.
164
+
165
+ Results We show the AUC scores in Table 4. By leveraging explanations, $\mathrm { E } { \mathrm { - } } \mathrm { P } +$ EXPLCAL successfully achieves an AUC of 68.8, surpassing both FEW-SHOT by 7 points and E-P by 4 points. We note this is a substantial improvement, given that the upperbound of AUC is constrained by the accuracy of the answers and cannot reach 100. Figure 5 shows the coverage-accuracy curves of various methods averaged across the 5 training runs. E- $\mathrm { P } +$ EXPLCAL always achieves a higher accuracy than its uncalibrated counterpart, E-P, under a certain coverage, and the gap is especially large in the most confident intervals (coverage $< 5 0 \%$ ). E- $\mathrm { P } +$ ZHANG ET AL. (2021) is able to calibrate the predictions on this dataset, but still lags our explanation-based calibrator, E-P+EXPLCAL.
166
+
167
+ In addition, the explanation-based calibrator can be effective with as few as 32 examples. This is because there are only two parameters (the probability of predicted answer and the explanationbased factor) in the calibrator, which can be easily learned in this few-shot setting. Comparing E $\mathbf { \partial } _ { - } \mathbf { P } { + } \mathbf { E }$ XPLCAL against FEW-SHOT(NN), using nearest neighbors in the prompt is also able to improve the performance compared to using a fixed set of shots (FEW-SHOT), yet our lightweight calibrator can better utilize such a small amount of data, and learn to distinguish more accurate predictions based on the explanations.
168
+
169
+ # 5 Related Work
170
+
171
+ Our investigation is centered around in-context learning (Brown et al., 2020), which has garnered increasing interest since the breakthrough of various large pretrained language models. Recent work has been devoted to studying different aspects of in-context learning, including its wayward behaviors (Min et al., 2022; Webson and Pavlick, 2022) and approaches to overcome them (Zhao et al., 2021), whereas our exploration focuses on using explanations.
172
+
173
+ The utility of explanations for few-shot in-context learning has also been discussed concurrently (Nye et al., 2021; Wei et al., 2022; Marasovic et al., 2022; Chowdhery et al., 2022; Lampinen et al., ´ 2022; Wiegreffe et al., 2022), especially in symbolic reasoning tasks. We differ in that we study more free-form explanations in tasks (QA and NLI, specifically) focusing on textual reasoning over provided contexts. Furthermore, our work focuses on the nature of the explanations generated by LLMs, which are found to be unreliable. Regarding our use of calibration, similar ideas of explanation-based performance estimation have been applied to other tasks (Rajani and Mooney, 2018; Ye et al., 2021; Ye and Durrett, 2022), but we rely on the free-text explanations generated by the model instead of interpretations obtained through post-hoc interpretation techniques.
174
+
175
+ More broadly, how to use explanations in various forms (textual explanation, highlights, etc.) to train better models is a longstanding problem (Zaidan et al., 2007). Past work has built a series of pipeline models that first generate the explanations and then make predictions purely based on the generated explanations (Wiegreffe et al., 2021; Zhou and Tan, 2021; Chen et al., 2022). Prior research has also explored using explanations as additional supervision to train joint models (Hancock et al., 2018; Dua et al., 2020; Lamm et al., 2021; Stacey et al., 2022). Another line of work seeks to align the reasoning process of a trained model with the explanations, which is typically done by interpreting a prediction post-hoc through explanation techniques and optimizing the distance between the obtained explanation and ground truth explanation (Liu and Avci, 2019; Rieger et al., 2020; Plumb et al., 2020; Erion et al., 2021; Yao et al., 2021). These aforementioned methods all update the model parameters and typically require a considerable amount of explanation annotations to be effective. By contrast, our setting treats language models as pure black boxes and only requires few-shot explanations.
176
+
177
+ # 6 Discussion & Conclusion
178
+
179
+ Caveats and Risks of Explanations from Large Language Models Our analysis suggests that LLMs’ internal “reasoning” does not always align with explanations that it generates, as shown by our consistency results. More concerning, the explanations might not be factually grounded in the provided prompt. This shortcoming should caution against any deployment of this technology in practice: because the explanations are grammatical English and look very convincing, they may deceive users into believing the system’s responses even when those responses are incorrect. Section 6 of Bender et al. (2021) discusses these risks in additional detail. The fact that language models can hallucinate explanations is also found in other work (Zhou and Tan, 2021). This result is unsurprising in some sense: without sufficient supervision or grounding, language models do not learn meaning as distinct from form (Bender and Koller, 2020), so we should not expect their explanations to be strongly grounded.
180
+
181
+ We have shown that even explanations which don’t lead to accuracy gains can still be useful for calibration. However, the lexical overlap feature we use here is a weak signal of explanation correctness (see the example in Figure 1). Strong enough entailment models should theoretically be able to perform this task and work across a range of tasks without fine-tuning. This explanation assessment model can even be a language model itself trained for this particular propose to approach the verification tasks for a given domain by in-context learning.
182
+
183
+ Conclusion We have explored the capabilities of LLMs in using explanations in in-context learning for textual reasoning. Through our experiments with four LLMs and on two QA datasets and an NLI dataset, we find that simply including explanations in the prompt does not always improve the performance of in-context learning. Our manual analysis demonstrates that LLMs tend to generate nonfactual explanations when making wrong predictions, which can be a useful leverage to assess the correctness of the predictions. Lastly, we showcase how to use explanations to build lightweight calibrators, which successfully improve InstructGPT’s in-context learning performance across all three datasets.
184
+
185
+ # Acknowledgments
186
+
187
+ We would like to thank Eunsol Choi, Ruiqi Zhong, Jocelyn Chen, Zayne Sprague, and Jiacheng Xu for their helpful feedback on drafts of this work, as well as the anonymous reviewers for their thoughtful reviews. This work was partially supported by NSF Grant IIS-1814522, NSF CAREER Award IIS-2145280, a grant from Open Philanthropy, a gift from Salesforce Inc., and a gift from Adobe.
188
+
189
+ # References
190
+
191
+ Emily M. Bender, Timnit Gebru, Angelina McMillan-Major, and Shmargaret Shmitchell. 2021. On the dangers of stochastic parrots: Can language models be too big? In Proceedings of the 2021 ACM Conference on Fairness, Accountability, and Transparency, FAccT ’21, page 610–623, New York, NY, USA. Association for Computing Machinery.
192
+
193
+ Emily M. Bender and Alexander Koller. 2020. Climbing towards NLU: On meaning, form, and understanding in the age of data. In Proceedings of the Annual Conference of the Association for Computational Linguistics (ACL).
194
+
195
+ 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 Proceedings of the Conference on Advances in Neural Information Processing Systems (NeurIPS).
196
+
197
+ Jannis Bulian, Christian Buck, Wojciech Gajewski, Benjamin Boerschinger, and Tal Schuster. 2022. Tomayto, tomahto. beyond token-level answer equivalence for question answering evaluation. arXiv preprint arXiv:2202.07654.
198
+
199
+ Oana-Maria Camburu, Tim Rocktäschel, Thomas Lukasiewicz, and Phil Blunsom. 2018. e-SNLI: Natural Language Inference with Natural Language Explanations. In Proceedings of the Conference on Advances in Neural Information Processing Systems (NeurIPS).
200
+
201
+ Howard Chen, Jacqueline He, Karthik Narasimhan, and Danqi Chen. 2022. Can rationalization improve robustness? In Proceedings of the Annual Conference of the Association for Computational Linguistics (ACL).
202
+
203
+ Jifan Chen, Eunsol Choi, and Greg Durrett. 2021. Can NLI models verify QA systems’ predictions? In Proceedings of the Conference on Empirical Methods in Natural Language Processing (EMNLP).
204
+
205
+ Jifan Chen and Greg Durrett. 2019. Understanding dataset design choices for multi-hop reasoning. In Proceedings of the Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies (NAACL-HLT).
206
+
207
+ 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 Baindoor Rao, Parker Barnes, Yi Tay, Noam M. Shazeer, Vinodkumar Prabhakaran, Emily Reif, Nan Du, Benton C. 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 García, 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 Oliveira Moreira, Rewon Child, Oleksandr Polozov, Katherine Lee, Zongwei Zhou, Xuezhi Wang, Brennan Saeta, Mark Diaz, Orhan Firat, Michele Catasta, Jason Wei, Kathleen S. MeierHellstern, Douglas Eck, Jeff Dean, Slav Petrov, and Noah Fiedel. 2022. PaLM: Scaling Language Modeling with Pathways. ArXiv, abs/2204.02311.
208
+
209
+ Jay DeYoung, Sarthak Jain, Nazneen Fatema Rajani, Eric Lehman, Caiming Xiong, Richard Socher, and Byron C. Wallace. 2020. ERASER: A benchmark to evaluate rationalized NLP models. In Proceedings of the Annual Conference of the Association for Computational Linguistics $( A C L )$ .
210
+
211
+ Dheeru Dua, Sameer Singh, and Matt Gardner. 2020. Benefits of intermediate annotations in reading comprehension. In Proceedings of the Annual Conference of the Association for Computational Linguistics (ACL).
212
+
213
+ Gabriel Erion, Joseph D Janizek, Pascal Sturmfels, Scott M Lundberg, and Su-In Lee. 2021. Improving performance of deep learning models with axiomatic attribution priors and expected gradients. Nature machine intelligence, 3(7):620–631.
214
+
215
+ Siddhant Garg and Alessandro Moschitti. 2021. Will this Question be Answered? Question Filtering via Answer Model Distillation for Efficient Question Answering. In Proceedings of the 2021 Conference on Empirical Methods in Natural Language Processing.
216
+
217
+ Mor Geva, Daniel Khashabi, Elad Segal, Tushar Khot, Dan Roth, and Jonathan Berant. 2021. Did Aristotle Use a Laptop? A Question Answering Benchmark with Implicit Reasoning Strategies. Transactions of the Association for Computational Linguistics, 9:346–361.
218
+
219
+ Chuan Guo, Geoff Pleiss, Yu Sun, and Kilian Q. Weinberger. 2017. On calibration of modern neural networks. In Proceedings of the 34th International Conference on Machine Learning (ICML).
220
+
221
+ Braden Hancock, Paroma Varma, Stephanie Wang, Martin Bringmann, Percy Liang, and Christopher Ré. 2018. Training classifiers with natural language explanations. In Proceedings of the Annual Conference of the Association for Computational Linguistics (ACL).
222
+
223
+ Pengcheng He, Xiaodong Liu, Jianfeng Gao, and Weizhu Chen. 2021. DeBERTa: Decoding-enhanced BERT with Disentangled Attention. In Proceedings of the International Conference on Learning Representations (ICLR).
224
+
225
+ Alon Jacovi and Yoav Goldberg. 2021. Aligning faithful interpretations with their social attribution. Transactions of the Association for Computational Linguistics (TACL), 9:294–310.
226
+
227
+ Yichen Jiang and Mohit Bansal. 2019. Avoiding reasoning shortcuts: Adversarial evaluation, training, and model development for multi-hop QA. In Proceedings of the Annual Conference of the Association for Computational Linguistics (ACL).
228
+
229
+ Amita Kamath, Robin Jia, and Percy Liang. 2020. Selective question answering under domain shift. In Proceedings of the Annual Meeting of the Association for Computational Linguistics (ACL).
230
+
231
+ Takeshi Kojima, Shixiang Shane Gu, Machel Reid, Yutaka Matsuo, and Yusuke Iwasawa. 2022. Large language models are zero-shot reasoners. ArXiv, abs/2205.11916.
232
+
233
+ Matthew Lamm, Jennimaria Palomaki, Chris Alberti, Daniel Andor, Eunsol Choi, Livio Baldini Soares, and Michael Collins. 2021. QED: A framework and dataset for explanations in question answering. Transactions of the Association for Computational Linguistics (TACL), 9:790–806.
234
+
235
+ Andrew K Lampinen, Ishita Dasgupta, Stephanie CY Chan, Kory Matthewson, Michael Henry Tessler, Antonia Creswell, James L McClelland, Jane X Wang, and Felix Hill. 2022. Can language models learn from explanations in context? arXiv preprint arXiv:2204.02329.
236
+
237
+ Frederick Liu and Besim Avci. 2019. Incorporating priors with feature attribution on text classification. In Proceedings of the Annual Conference of the Association for Computational Linguistics (ACL).
238
+
239
+ Jiachang Liu, Dinghan Shen, Yizhe Zhang, Bill Dolan, Lawrence Carin, and Weizhu Chen. 2021. What Makes Good In-Context Examples for GPT-3? ArXiv, abs/2101.06804.
240
+
241
+ Y. Liu, Myle Ott, Naman Goyal, Jingfei Du, Mandar Joshi, Danqi Chen, Omer Levy, M. Lewis, Luke Zettlemoyer, and Veselin Stoyanov. 2019. Roberta: A robustly optimized bert pretraining approach. ArXiv, abs/1907.11692.
242
+
243
+ Ana Marasovic, Iz Beltagy, Doug Downey, and Matthew E. Peters. 2022. Few-shot self-rationalization ´ with natural language prompts. In Findings of the North American Chapter of the Association for Computational Linguistics (NAACL Findings).
244
+
245
+ Sabrina J. Mielke, Arthur Szlam, Emily Dinan, and Y-Lan Boureau. 2022. Reducing conversational agents’ overconfidence through linguistic calibration. Transactions of the Association for Computational Linguistics, 10:857–872.
246
+
247
+ Sewon Min, Xinxi Lyu, Ari Holtzman, Mikel Artetxe, Mike Lewis, Hannaneh Hajishirzi, and Luke Zettlemoyer. 2022. Rethinking the role of demonstrations: What makes in-context learning work? arXiv preprint arXiv:2202.12837.
248
+
249
+ 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. 2021. Show your work: Scratchpads for intermediate computation with language models. ArXiv, abs/2112.00114.
250
+
251
+ John Platt. 1999. Probabilistic outputs for support vector machines and comparisons to regularized likelihood methods. Advances in large margin classifiers, 10(3):61–74.
252
+
253
+ Gregory Plumb, Maruan Al-Shedivat, Ángel Alexander Cabrera, Adam Perer, Eric Xing, and Ameet Talwalkar. 2020. Regularizing black-box models for improved interpretability. In Proceedings of the Conference on Advances in Neural Information Processing Systems (NeurIPS).
254
+
255
+ Nazneen Fatema Rajani, Bryan McCann, Caiming Xiong, and Richard Socher. 2019. Explain Yourself! Leveraging Language Models for Commonsense Reasoning. In Proceedings of the Annual Conference of the Association for Computational Linguistics (ACL).
256
+
257
+ Nazneen Fatema Rajani and Raymond Mooney. 2018. Stacking with auxiliary features for visual question answering. In Proceedings of the 2018 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long Papers), New Orleans, Louisiana.
258
+
259
+ Marco Tulio Ribeiro, Sameer Singh, and Carlos Guestrin. 2016. "Why Should I Trust You?": Explaining the Predictions of Any Classifier. In Proceedings of the ACM SIGKDD International Conference on Knowledge Discovery and Data Mining (KDD).
260
+
261
+ Laura Rieger, Chandan Singh, William Murdoch, and Bin Yu. 2020. Interpretations are useful: Penalizing explanations to align neural networks with prior knowledge. In Proceedings of the International Conference on Machine Learning (ICML).
262
+
263
+ Richard Shin, Christopher Lin, Sam Thomson, Charles Chen, Subhro Roy, Emmanouil Antonios Platanios, Adam Pauls, Dan Klein, Jason Eisner, and Benjamin Van Durme. 2021. Constrained language models yield few-shot semantic parsers. In Proceedings of the Conference on Empirical Methods in Natural Language Processing (EMNLP).
264
+
265
+ Karen Simonyan, Andrea Vedaldi, and Andrew Zisserman. 2014. Deep inside convolutional networks: Visualising image classification models and saliency maps. In 2nd International Conference on Learning Representations, ICLR 2014, Banff, AB, Canada, April 14-16, 2014, Workshop Track Proceedings.
266
+
267
+ Joe Stacey, Yonatan Belinkov, and Marek Rei. 2022. Supervising model attention with human explanations for robust natural language inference. In Proceedings of the AAAI Conference on Artificial Intelligence (AAAI).
268
+
269
+ Mukund Sundararajan, Ankur Taly, and Qiqi Yan. 2017. Axiomatic attribution for deep networks. In Proceedings of the International Conference on Machine Learning (ICML).
270
+
271
+ Albert Webson and Ellie Pavlick. 2022. Do prompt-based models really understand the meaning of their prompts? In Proceedings of the 2018 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies (NAACL-HLT).
272
+
273
+ Jason Wei, Xuezhi Wang, Dale Schuurmans, Maarten Bosma, Ed Chi, Quoc Le, and Denny Zhou. 2022. Chain of thought prompting elicits reasoning in large language models. ArXiv, abs/2201.11903.
274
+
275
+ Jason Weston, Antoine Bordes, Sumit Chopra, and Tomás Mikolov. 2016. Towards AI-Complete Question Answering: A Set of Prerequisite Toy Tasks. In Proceedings of the International Conference on Learning Representations (ICLR).
276
+
277
+ Sarah Wiegreffe, Jack Hessel, Swabha Swayamdipta, Mark Riedl, and Yejin Choi. 2022. Reframing Human-AI Collaboration for Generating Free-Text Explanations. In Proceedings of the 2018 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies (NAACL-HLT).
278
+
279
+ Sarah Wiegreffe, Ana Marasovic, and Noah A. Smith. 2021. Measuring association between labels ´ and free-text rationales. In Proceedings of the Conference on Empirical Methods in Natural Language Processing (EMNLP).
280
+
281
+ Zhilin Yang, Peng Qi, Saizheng Zhang, Yoshua Bengio, William W. Cohen, Ruslan Salakhutdinov, and Christopher D. Manning. 2018. HotpotQA: A dataset for diverse, explainable multi-hop question answering. In Proceedings of the Conference on Empirical Methods in Natural Language Processing (EMNLP).
282
+
283
+ Huihan Yao, Ying Chen, Qinyuan Ye, Xisen Jin, and Xiang Ren. 2021. Refining language models with compositional explanations. In Proceedings of the Conference on Advances in Neural Information Processing Systems (NeurIPS).
284
+
285
+ Xi Ye and Greg Durrett. 2022. Can Explanations be Useful for Calibrating Black Box Models? In Proceedings of the Annual Conference of the Association for Computational Linguistics (ACL).
286
+
287
+ Xi Ye, Rohan Nair, and Greg Durrett. 2021. Connecting attributions and QA model behavior on realistic counterfactuals. In Proceedings of the Conference on Empirical Methods in Natural Language Processing (EMNLP).
288
+
289
+ Omar Zaidan, Jason Eisner, and Christine Piatko. 2007. Using “annotator rationales” to improve machine learning for text categorization. In Proceedings of the Annual Conference of the Association for Computational Linguistics (ACL).
290
+
291
+ Shujian Zhang, Chengyue Gong, and Eunsol Choi. 2021. Knowing more about questions can help: Improving calibration in question answering. In Findings of the Annual Conference of the Association for Computational Linguistics (ACL Findings).
292
+
293
+ 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. ArXiv, abs/2205.01068.
294
+
295
+ Tony 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 International Conference on Learning Representations (ICLR).
296
+
297
+ Yangqiaoyu Zhou and Chenhao Tan. 2021. Investigating the effect of natural language explanations on out-of-distribution generalization in few-shot NLI. In Proceedings of the Workshop on Insights from Negative Results in NLP.
298
+
299
+ # Checklist
300
+
301
+ 1. For all authors...
302
+
303
+ (a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes]
304
+ (b) Did you describe the limitations of your work? [Yes] See Section 6.
305
+ (c) Did you discuss any potential negative societal impacts of your work? [Yes] See Section 6.
306
+ (d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
307
+
308
+ 2. If you are including theoretical results...
309
+
310
+ (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]
311
+
312
+ 3. If you ran experiments...
313
+
314
+ (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]
315
+ (b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes]
316
+ (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [Yes]
317
+ (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 use the GPT-3 Instruct-series API (text-davinci-001).
318
+
319
+ 4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
320
+
321
+ (a) If your work uses existing assets, did you cite the creators? [Yes] See reference (Jiang and Bansal, 2019) and (Camburu et al., 2018).
322
+ (b) Did you mention the license of the assets? [Yes] See Section 2.1.
323
+ (c) Did you include any new assets either in the supplemental material or as a URL? [Yes] We included the Synthetic dataset in the supplementary material.
324
+ (d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [No]
325
+ (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [No]
326
+
327
+ 5. If you used crowdsourcing or conducted research with human subjects...
328
+
329
+ (a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A]
330
+ (b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A]
331
+ (c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]
md/dev/E0zOKxQsZhN/E0zOKxQsZhN.md ADDED
@@ -0,0 +1,505 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # RECURRENT MODEL-FREE RL IS A STRONGBASELINE FOR MANY POMDPS
2
+
3
+ Anonymous authors Paper under double-blind review
4
+
5
+ # ABSTRACT
6
+
7
+ Many problems in RL, such as meta RL, robust RL, and generalization in RL, can be cast as POMDPs. In theory, simply augmenting model-free RL with memory, such as recurrent neural networks, provides a general approach to solving all types of POMDPs. However, prior work has found that such recurrent model-free $R L$ methods tend to perform worse than more specialized algorithms that are designed for specific types of POMDPs. This paper revisits this claim. We find that a careful architecture and hyperparameter decisions yield a recurrent model-free implementation that performs on par with (and occasionally substantially better than) more sophisticated recent techniques in their respective domains. We also release a simple and efficient implementation of recurrent model-free RL for future work to use as a baseline for POMDPs.1
8
+
9
+ # 1 INTRODUCTION
10
+
11
+ While reinforcement learning (RL) is often cast as the problem of learning a single fully observable task, also known as MDP, training and testing on that same task, most real-world applications of RL demand some degree of transfer and partial observability. For example, visual navigation (Zhu et al., 2017) requires adaptation to unseen scenes with occlusion in observations, and human-robot collaboration requires that robots infer the intentions of human collaborators. (Chen et al., 2018).
12
+
13
+ Many subareas in RL study problems that are special cases of POMDPs, and we summarize them in Table 1. For example, meta RL (Duan et al., 2016; Schmidhuber, 1987; Thrun & Pratt, 2012; Wang et al., 2017) is a POMDP where certain aspects of the reward function or (less commonly) dynamics function are unobserved but held constant through one episode. The robust RL problem (Bagnell et al., 2001; Pattanaik et al., 2018; Pinto et al., 2017; Rajeswaran et al., 2017a) assumes that certain aspects of the dynamics or reward function are
14
+
15
+ ![](images/0263b0377870a9e706cac9a587cc7239ea6cfcc9daae0f0b1f499a4ca8db104b.jpg)
16
+ Figure 1: Implementation Matters for Recurrent Model-Free RL. This paper identifies critical design decisions for recurrent model-free RL that outperforms not only prior implementations (e.g. PPO-GRU and A2C-GRU from Kostrikov (2018)), but also purposedesigned methods (e.g. VRM from Han et al. (2020)). We also show Markovian policies as lower bounds for reference. The y-axis is normalized return given the return of oracle policy (Raffin et al., 2021).
17
+
18
+ unknown, aiming at finding optimal policies that perform against adversarially-chosen perturbations. Generalization in RL (Cobbe et al., 2019; Packer et al., 2018; Whiteson et al., 2011; Zhang et al., 2018a) focuses on unobserved aspects of the dynamics or reward function that are novel during testing, using an average-case objective instead of a worst-case objective like robust RL. Recent work has proposed efficient and performant algorithms for solving these specialized problem settings. However, these algorithms often make assumptions that preclude their application to other classes of POMDPs. For example, methods for robust RL are rarely used for the meta RL setting due to objective mismatch; methods for meta RL are rarely used for general POMDPs due to the stationarity assumption in meta RL.
19
+
20
+ Nonetheless, many prior works have used a simple baseline that is applicable to all POMDPs: model-free RL equipped with a recurrent policy and (sometimes) value function (Duan et al., 2016; Fakoor et al., 2020; Igl et al., 2018; Packer et al., 2018; Rakelly et al., 2019; Wang et al., 2017; Yu et al., 2019). We will refer to this approach as recurrent model-free RL. This baseline is simultaneously simple (requiring changing only a few lines of code from a model-free RL algorithm) and general. However, prior work has consistently found that recurrent model-free RL performs poorly across a wide range of problem settings, including meta RL (Rakelly et al., 2019; Zintgraf et al., 2020), general POMDPs (Han et al., 2020; Igl et al., 2018), robust RL (Zhang et al., 2021), and generalization in RL (Packer et al., 2018). One common explanation is that specialized algorithms that are tailored to specific types of POMDPs are very likely to outperform recurrent model-free RL because they (implicitly) encode inductive biases for solving these specific tasks. For example, algorithms for meta RL may leverage the assumption that the underlying dynamics (while unknown) are fixed, and the underlying goals are fixed within one episode (Rakelly et al., 2019; Zintgraf et al., 2020); algorithms for robust RL may assume that the dynamics parameters are known (Rajeswaran et al., 2017a) and dynamics is Lipschitz continuous (Jiang et al., 2021).
21
+
22
+ This paper challenges this explanation. We argue that, contrary to popular belief, recurrent modelfree RL is competitive with recent state-of-the-art algorithms across a range of different POMDP settings. Similar to prior work in Markovian on-policy RL methods (Andrychowicz et al., 2021; Engstrom et al., 2020), our experiments show that implementation in recurrent model-free RL matters. Fig. 1 shows a typical scenario in PyBullet occlusion environments (Coumans & Bai, 2016) to support this argument. Through extensive experiments, we show that the careful design and implementation of recurrent model-free RL is critical to its performance. Design decisions, such as the actor-critic architecture, conditioning on previous actions and/or rewards, the underlying model-free RL algorithms, and context length in RNNs, are especially crucial.
23
+
24
+ The main contribution of this paper is a performant implementation of recurrent-model free RL. We demonstrate that simple yet important design decisions, such as the underlying RL algorithm and the context length, yield a recurrent model-free RL algorithm that performs on par with prior specialized POMDP algorithms on the environments those algorithms were designed to solve. Ablation experiments identify the importance of these design decisions. We also open-sourced our code that is easy to use and memory-efficient.
25
+
26
+ # 2 BACKGROUND
27
+
28
+ MDP. A Markov decision process (MDP) (Bellman, 1957) is a tuple $( S , A , T , T _ { 0 } , R , H , \gamma )$ , where $s$ is the set of states, $\mathcal { A }$ is the set of actions, $T : \mathcal { S } \times \mathcal { A } \times \mathcal { S } [ 0 , 1 ]$ is the transition function (dynamics), $T _ { 0 } : { \mathcal { S } } [ 0 , 1 ]$ is the initial state distribution, $R : \mathcal { S } \times \mathcal { A } \times \mathcal { S } \to \mathbb { R }$ is the reward function, $H \in \mathbb { N }$ is the time horizon, and $\gamma \in \ [ 0 , 1 )$ is the discount factor. Solving an MDP requires learning a memoryless policy $\pi : \mathcal { S \times A } \to [ 0 , 1 ]$ that maximizes the expected discounted return: $\begin{array} { r } { \pi ^ { * } = \arg \operatorname* { m a x } _ { \pi } \mathbb { E } _ { s _ { t } , a _ { t } , r _ { t } \sim T , \pi } \left[ \sum _ { t = 0 } ^ { H - 1 } \gamma ^ { t } r _ { t + 1 } \ | \ s _ { 0 } \right] } \end{array}$ . For any MDP, there exists an optimal policy that is both memoryless and deterministic (Puterman, 2014). MaxEnt RL algorithms (Ziebart, 2010), such as SAC (Haarnoja et al., 2018a), add an entropy bonus to the RL objective.
29
+
30
+ POMDP. A partially observable Markov decision process (POMDP) (Astr ˚ om¨ , 1965) is a tuple $( S , A , \mathcal { O } , T , T _ { 0 } , O , O _ { 0 } , R , H , \gamma )$ , where the underlying process is an MDP $( S , A , T , T _ { 0 } , R , H , \gamma )$ . Let $\mathcal { O }$ be the set of observations and let $O : S \times A \times \mathcal { O } [ 0 , 1 ]$ be the emission function. Let the observable trajectory up to time-step $t$ be $\tau _ { 0 : t } = ( o _ { 0 } , a _ { 0 } , o _ { 1 } , r _ { 1 } , \dots , a _ { t - 1 } , o _ { t } , r _ { t } )$ , the memory-based policy in the most general form is defined as $\pi ( \boldsymbol { a } _ { t } \mid \tau _ { 0 : t } )$ , conditioning on the whole history. At the first time step $t = 0$ , an initial state $s _ { 0 } \sim T _ { 0 } ( \cdot )$ and initial observation $\phantom { } O _ { 0 } \sim O _ { 0 } ( \cdot \mid s _ { 0 } )$ are sampled. At any time-step $t \in \{ 0 , \ldots , H - 1 \}$ , the policy emits the action $a _ { t } \in \mathcal A$ to the system, the system updates the state following the dynamics, $s _ { t + 1 } \sim T ( \cdot \mid s _ { t } , a _ { t } )$ , then the next observation is sampled $\tilde { o _ { t + 1 } } \sim O ( \cdot \mid s _ { t + 1 } , a _ { t } )$ and the reward is computed as $r _ { t + 1 } = R ( s _ { t } , a _ { t } , s _ { t + 1 } )$ .
31
+
32
+ We refer to the part of the state $s _ { t }$ at current time-step $t$ that can be directly unveiled from current observation $o _ { t }$ as the observable state sot , and the rest part of the state as the hidden state s ht . We call the hidden state $s _ { t } ^ { h }$ stationary if it does not change within an episode. In this scenario, the policy objective can be rewritten as $\pi ^ { * } =$ arg $\begin{array} { r } { \operatorname* { m a x } _ { \boldsymbol { \pi } } \mathbb { E } _ { s ^ { h } \sim T _ { 0 } } \left[ \mathbb { E } _ { s _ { t } , a _ { t } , r _ { t } \sim T , O , O _ { 0 } , \boldsymbol { \pi } } \left[ \sum _ { t = 0 } ^ { H - 1 } \gamma ^ { t } r _ { t + 1 } \ | \ s ^ { h } \right] \right] } \end{array}$ for the average-case POMDP objec
33
+
34
+ Table 1: The summary of selected POMDP subareas. For each subarea, we list the information of the hidden state $s ^ { h }$ including its appearance in dynamics and reward function and its stationarity during one trajectory. We also list the policy input space that are connected with the hidden states, where $\bigcirc$ , a, r, and d refer to the sequence of observations, actions, rewards, and done signals, respectively. Finally, we list the RL objective in terms of average-case or worst-case, and whether there is a domain shift between training and testing environments. We append the check $( \checkmark )$ or cross mark $( { \pmb x } )$ with $^ *$ if it applies to some but not all the work in that subarea. The notation in this table will be covered in Sec. 2.
35
+
36
+ <table><tr><td rowspan=1 colspan=1>Subarea</td><td rowspan=1 colspan=1>shin dynam-sics?</td><td rowspan=1 colspan=1>sin re-ward?</td><td rowspan=1 colspan=1>Isshsta-tionary?</td><td rowspan=1 colspan=1>Policy in-put space</td><td rowspan=1 colspan=1>RL objec-tive</td><td rowspan=1 colspan=1>Domainshift?</td></tr><tr><td rowspan=1 colspan=1>“Standard”POMDP</td><td rowspan=1 colspan=1>√</td><td rowspan=1 colspan=1>√</td><td rowspan=1 colspan=1>X</td><td rowspan=1 colspan=1>oar</td><td rowspan=1 colspan=1>Avg</td><td rowspan=1 colspan=1>X</td></tr><tr><td rowspan=1 colspan=1>Meta RL</td><td rowspan=1 colspan=1>X*</td><td rowspan=1 colspan=1>√</td><td rowspan=1 colspan=1>√</td><td rowspan=1 colspan=1>oard</td><td rowspan=1 colspan=1>Avg</td><td rowspan=1 colspan=1>X</td></tr><tr><td rowspan=1 colspan=1>Robust RL</td><td rowspan=1 colspan=1>*</td><td rowspan=1 colspan=1>X</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>oa</td><td rowspan=1 colspan=1>Worst</td><td rowspan=1 colspan=1>×</td></tr><tr><td rowspan=1 colspan=1>Generalizationin RL</td><td rowspan=1 colspan=1>*</td><td rowspan=1 colspan=1>X*</td><td rowspan=1 colspan=1>*</td><td rowspan=1 colspan=1>oa</td><td rowspan=1 colspan=1>Avg</td><td rowspan=1 colspan=1></td></tr></table>
37
+
38
+ tive, or POMD $\begin{array} { r } { \pi ^ { * } = \arg \operatorname* { m a x } _ { \pi } \operatorname* { m i n } _ { s ^ { h } \in \mathrm { s u p p } ( T _ { 0 } ) } \mathbb { E } _ { s _ { t } , a _ { t } , r _ { t } \sim T , O , O _ { 0 } , \pi } \left[ \sum _ { t = 0 } ^ { H - 1 } \gamma ^ { t } r _ { t + 1 } \mid s ^ { h } \right] } \end{array}$ for the worst-case
39
+
40
+ # 3 RELATED WORK
41
+
42
+ In this section, we discuss several subareas of RL that both explicitly and implicitly solve POMDPs, as well as algorithms proposed for these specialized settings. Table 1 summarizes these subareas.
43
+
44
+ RL for “Standard” POMDPs. We use the term “standard” to refer to prior work that explicitly labels the problems studied as POMDPs. Common tasks include scenarios where the states are partially occluded (Heess et al., 2015), different states correspond to the same observation (perceptual aliasing (Whitehead & Ballard, 1990)), random frames are dropped (Hausknecht & Stone, 2015), observations use egocentric images (Zhu et al., 2017), or the observations are perturbed with random noise (Meng et al., 2021). These POMDPs often have hidden states that are non-stationary and affect both the rewards and the dynamics. POMDPs are hard to solve (Littman, 1996; Papadimitriou & Tsitsiklis, 1987) because of the curse of dimensionality: the size of the history grows linearly with the horizon length. Many prior POMDP algorithms (Cassandra et al., 1994; Kaelbling et al., 1998) attempt to infer the state from the past sequence of observations, and then apply standard RL techniques to that inferred state. However, the exact inference requires the knowledge of the dynamics, emission, and reward functions, and is intractable in all except the most simple settings. A common strategy for solving these general POMDPs is to use recurrent policies, which take the entire history of past observations as inputs (Bakker, 2001; Schmidhuber, 1991; Wierstra et al., 2007). This strategy is very simple and general, and can be applied to arbitrary tasks without knowledge of the task structure (e.g., whether the hidden states change within an episode) across long time horizons (Duan et al., 2016). These recurrent strategies can be further subdivided into model-free methods (Hausknecht & Stone, 2015; Heess et al., 2015; Meng et al., 2021) , where the single objective is to maximize the return, and model-based methods (Freeman et al., 2019; Han et al., 2020; Igl et al., 2018; Watter et al., 2015) that have explicit objectives on modeling the belief states and use them as the inputs of memoryless policies. The recurrent model-free RL that we focus on belongs to the class of model-free off-policy memory-based algorithms.
45
+
46
+ Meta RL. Meta RL, also called “learning to learn” (Schmidhuber, 1987; Thrun & Pratt, 2012), focuses on POMDPs where some parameters in the rewards or (less commonly) dynamics are varied from episode to episode, but remain fixed within a single episode, which represent different tasks with different values (Humplik et al., 2019). The meta RL setting is almost the same as multitask RL (Wilson et al., 2007; Yu et al., 2019), but differs in that multi-task RL can observe the task parameters, making it an MDP instead of a POMDP. Algorithms for meta RL can be roughly categorized based on how the adaptation step is performed. Gradient-based algorithms (Fakoor et al., 2020; Finn et al., 2017; Hochreiter et al., 2001) run a few gradient steps on the pre-trained models to adapt. Memory or context-based algorithms use RNNs to implicitly adapt, which can be further subdivided into implicit and explicit task inference methods. Implicit task inference methods (Duan et al., 2016; Wang et al., 2017) use RL objective only to learn recurrent policies. Explicit task inference methods (Rakelly et al., 2019; Zintgraf et al., 2020) train an extra inference model to explicitly estimate task embeddings (i.e., a representation of the unobserved parameters) by variational inference. Task embeddings are then used as additional inputs to memoryless policies.
47
+
48
+ Robust RL. The goal of robust RL is to find a policy that maximizes returns in the worst-case environments. Early work in the control and operations research community (Khalil et al., 1996; Nilim & Ghaoui, 2005) and RL community (Bagnell et al., 2001; Morimoto & Doya, 2005) focused on linear or finite systems. Prior work designs deep RL algorithms that are robust against a variety of adversarial attacks, including attacks on the dynamics (Jiang et al., 2021; Rajeswaran et al., 2017a), observations (Huang et al., 2017; Pattanaik et al., 2018; Zhang et al., 2021), and actions (Gleave et al., 2020; Pinto et al., 2017; Tessler et al., 2019). Treating the robust RL problem as a POMDP, rather than an MDP (as done in most prior work), unlocks a key capability for RL agents, because agents can use their memory to identify the hidden states of the current adversarial environment, although previous work (Jiang et al., 2021; Rajeswaran et al., 2017a) only train Markovian policies on POMDPs. While some work find memory-based policies are more robust to the adversarial attacks than Markovian policies (Russo & Proutiere \` , 2021; Zhang et al., 2021), they train these baselines in a single MDP without adversaries, which differs from our training setting where the recurrent model-free RL can have access to a set of MDPs.
49
+
50
+ Generalization in RL. The goal of generalization in RL is to make RL algorithms perform well in test domains that are unseen during training, which emphasizes the average case on the novel test domains instead of the worse case in the possibly seen test domains as in robust RL. Prior work have studied generalization to initial states in the same MDP (Rajeswaran et al., 2017b; Whiteson et al., 2011; Zhang et al., 2018b), random disturbance in dynamics (Rajeswaran et al., 2017b), states (Stulp et al., 2011), observations (Song et al., 2020; Zhang et al., 2018a), and actions (Srouji et al., 2018), and different modes in procedurally generated games (Cobbe et al., 2019; Farebrother et al., 2018; Justesen et al., 2018). Among them, Packer et al. (2018) provides a benchmark on both in-distribution (ID) and out-of-distribution (OOD) generalization to different dynamics parameters, and Zhao et al. (2019) extends the benchmark by introducing random noise in states, observations, and actions. Algorithms for improving generalization in RL can be roughly divided into classic regularization methods such as weight decay, dropout, batch normalization, and entropy regularization (Cobbe et al., 2020; Farebrother et al., 2018; Igl et al., 2019), model architectures (Raileanu & Fergus, 2021; Srouji et al., 2018), data augmentation through randomization (Lee et al., 2020; Tobin et al., 2017), Although introducing observational noise and the change in dynamics parameters will transform MDPs to POMDPs, few work study memory-based policies such as model-free recurrent RL with mixed results. Same algorithm RL2 (Duan et al., 2016) was found to perform badly in Packer et al. (2018) but relatively well in Yu et al. (2019).
51
+
52
+ # 4 DESIGN CONSIDERATIONS FOR RECURRENT MODEL-FREE RL
53
+
54
+ Implementing a recurrent model-free RL algorithm requires making a number of design decisions. This section describes the decisions that we found most important to make recurrent model-free RL competitive with more complex, recent algorithms. We will focus on continuous control problems with state-based inputs (i.e., not image-based inputs). Importantly, we assume that the policy can observe the reward and done signals (the end of one episode during one trial (Duan et al., 2016)) from the environment during evaluation. This assumption is common in prior work (Han et al., 2020; Zintgraf et al., 2020), but many recurrent model-free implementations do not provide the agent with information. In the following paragraphs, we will describe the important decision factors in recurrent model-free RL. Table 2 summarizes how prior work and our method makes these design decisions when implementing recurrent model-free RL.
55
+
56
+ Recurrent Off-Policy Actor-Critic Architecture. The first important design decision is whether the recurrent policy (actor) and the recurrent Q-value function (critic) use shared RNN encoder (and embedders) or use separate ones. In the experiment section (Sec. 5.2) we will show that a shared encoder would cause large gradient norm in the (off-policy) recurrent actor-critic and thus hinder learning, while separate encoders can greatly mitigate this issue and learn efficiently. This echoes prior work (Fakoor et al., 2020; Meng et al., 2021; Sun et al., 2021; Wang et al., 2020) that also use separate encoders in their (off-policy) recurrent actor-critic. To avoid running an inordinate number of experiments, we will use the separate architecture in the rest of the paper.
57
+
58
+ Policy Input Space. The next consideration is the input space of the model-free policy. The maximal input space of policy to emit an action $a _ { t }$ at time $t$ , should be the history of all quantities that the policy has observed, namely the past observations $o _ { 0 : t }$ , the past actions $a _ { 0 : t - 1 }$ , the past rewards $r _ { 0 : t }$ , and the past done signals $d _ { 0 : t }$ , which was already employed in the early work (Duan et al., 2016). Generally, the input space of optimal policy should only depend on the quantities that have connections with hidden states (defined in Sec. 2) (Izadi & Precup, 2005; Poupart & Boutilier, 2002). We show the policy input spaces that are connected with the hidden states for the discussed subareas in the “Inputs” column of Table 1. While prior work often only conditions the recurrent RL baseline on previous observations (and actions) (Han et al., 2020; Igl et al., 2018; Kostrikov, 2018; Meng et al., 2021; Wang et al., 2020; Yang & Nguyen, 2021), our experiments in Sec. 5.2 find that additionally conditioning on other previous information, such as previous rewards, can increase reward by up to $3 0 \%$ .
59
+
60
+ Table 2: How the prior work and our method implement the recurrent model-free RL as their own method or baseline. We can see that none of the prior work share the same set of decision variables, some of which have bad choices that may lead to the poor performance reported in the prior work. Our method covers a range of choices in these decision factors and finds the combinations in the last rows that lead to the best performance in terms of the average performance across the experimented environments in each subarea.
61
+
62
+ <table><tr><td>Algorithm</td><td>Domain</td><td>Arch</td><td>Encoder</td><td>Inputs</td><td>Len</td><td>RL</td></tr><tr><td>Duan et al. (2016)</td><td>Meta RL</td><td>separate</td><td>GRU</td><td>oard</td><td>1000</td><td>TRPO,PPO</td></tr><tr><td>Wang et al. (2017)</td><td>Meta RL</td><td>shared</td><td>LSTM</td><td>oart</td><td>5-150</td><td>A2C</td></tr><tr><td>Baseline from Rakelly et al. (2019)</td><td>Meta RL</td><td>separate</td><td>GRU</td><td>oard</td><td>100</td><td>PPO</td></tr><tr><td>Baseline from Zintgraf et al. (2020)</td><td>Meta RL</td><td>separate</td><td>GRU</td><td>oard</td><td>Max</td><td>A2C,PPO</td></tr><tr><td>Baseline from Fakoor et al. (2020)</td><td>MetaRL</td><td>separate</td><td>GRU</td><td>oar</td><td>10-25</td><td>TD3</td></tr><tr><td>Baseline from Yu et al. (2019)</td><td>Meta RL</td><td>separate</td><td>GRU</td><td>oard</td><td>500</td><td>PPO</td></tr><tr><td>Kostrikov (2018)</td><td>POMDP</td><td>shared</td><td>GRU</td><td>0</td><td>5-2048</td><td>PPO,A2C</td></tr><tr><td>Wang et al. (2020)</td><td>POMDP</td><td>separate</td><td>LSTM</td><td>oa</td><td>150</td><td>TD3, SAC</td></tr><tr><td>Meng et al. (2021)</td><td>POMDP</td><td>separate</td><td>LSTM</td><td>oa</td><td>1-5</td><td>TD3</td></tr><tr><td>Yang &amp; Nguyen (2021)</td><td>POMDP</td><td>separate</td><td>both</td><td>oa</td><td>Max</td><td>TD3, SAC</td></tr><tr><td>Baseline from Igl et al. (2018)</td><td>POMDP</td><td>shared</td><td>GRU</td><td>oa</td><td>25</td><td>A2C</td></tr><tr><td>Baseline from Han et al. (2020)</td><td>POMDP</td><td>shared</td><td>LSTM</td><td>0</td><td>64</td><td>SAC</td></tr><tr><td>Baseline from Zhang et al. (2021)</td><td>Robust RL</td><td>separate</td><td>LSTM</td><td>0</td><td>100</td><td>PPO</td></tr><tr><td>Baseline1 from Packer et al. (2018)</td><td>Generalization</td><td>shared</td><td>LSTM</td><td>0</td><td>128-512</td><td>PPO,A2C</td></tr><tr><td>Baseline2 from Packer et al. (2018)</td><td>Generalization</td><td>separate</td><td>LSTM</td><td>oard</td><td>128-512</td><td>PPO,A2C</td></tr><tr><td>Our method</td><td>Meta RL</td><td>separate</td><td>LSTM</td><td>oard</td><td>64</td><td>TD3</td></tr><tr><td>Our method</td><td>POMDP</td><td>separate</td><td>GRU</td><td>oa</td><td>64</td><td>TD3</td></tr><tr><td>Our method</td><td>Robust RL</td><td>separate</td><td>LSTM</td><td>0</td><td>64</td><td>TD3</td></tr><tr><td>Our method</td><td>Generalization</td><td>separate</td><td>LSTM</td><td>0</td><td>64</td><td>TD3</td></tr></table>
63
+
64
+ Model-free RL Algorithms. Recurrent model-free RL can be understood as applying an off-theshelf model-free RL algorithm with an actor and a Q function parametrized to take sequences of inputs. As such, the choice of the underlying model-free RL algorithm is paramount. Most prior work on continuous control POMDP problems used on-policy algorithms, such as A2C (Mnih et al., 2016), TRPO (Schulman et al., 2015) or PPO (Schulman et al., 2017). While off-policy algorithms such as TD3 (Fujimoto et al., 2018) and SAC (Haarnoja et al., 2018a;b) greatly improve the performance in continuous control MDP problems in terms of sample efficiency and asymptotic performance, these methods are rarely used in recurrent model-free RL baselines (Rakelly et al., 2019; Zhang et al., 2020; Zintgraf et al., 2020). In the experiment section (Sec. 5.1), we will show that using these off-policy algorithms for recurrent model-free RL provides results that are better than using on-policy algorithms and are comparable to their specialized methods in POMDP. This echoes the finding that model-free off-policy TD3-Context (Fakoor et al., 2020) can be better than the specialized method PEARL (Rakelly et al., 2019) in meta RL.
65
+
66
+ RNN Variants and Context Length. RNN training is known to be unstable, especially with long sequences input (Bengio et al., 1994). The RNN variants like LSTM (Hochreiter & Schmidhuber, 1997) and GRU (Chung et al., 2014) mitigate the training issues, but still may fail to learn long-term dependencies (Trinh et al., 2018). In POMDP problems, these dependencies reflect the memory that an agent must have to solve a task. For example, a POMDP that hides velocities from observations theoretically requires a short memory length to infer velocities through consecutive positions (Meng et al., 2021). Prior work in POMDPs choose a variety set of context lengths for RNNs from 1 to 2048 (see the “Len” column of Table 2), and we select three representatives of short (5), medium (64), and long length (larger than 100) in the experiments (Sec. 5) for comparison. We also try both LSTM and GRU as RNN variants to compare their performance. We find that the optimal context length and RNN variant are task-specific (see Sec. 5.2).
67
+
68
+ # 5 EXPERIMENTS
69
+
70
+ Our experiments aim to answer two questions. First, how does a well-tuned implementation of recurrent model-free RL compare to specialized POMDP methods, such as purpose-designed meta RL and robust RL algorithms? To give these prior methods the strongest possible footing, we will compare prior methods on the specific problem types for which they were developed (i.e., meta RL algorithms were tested on meta RL tasks). Our second question studies which design decisions are essential for recurrent model-free RL. We put the environment details in Appendix D.
71
+
72
+ Code Implementation. We release a modular and highly-configurable implementation of recurrent (off-policy) model-free RL: url. Our implementation is efficient in terms of computer memory compared to previous off-policy RL methods for POMDPs $2 0 0 \mathrm { x }$ less RAM than Han et al. (2020) and $9 \mathbf { x }$ less GPU memory than Dorfman et al. (2020)). Please see the appendix A for details, including an explanation of why our implementation is more memory-efficient than prior work.
73
+
74
+ # 5.1 RECURRENT MODEL-FREE RL IS COMPARABLE WITH PRIOR SPECIALIZED METHODS
75
+
76
+ While prior work has studied a range of different POMDP settings (e.g., meta RL, occluded observations), recurrent model-free RL is a ubiquitous baseline (Han et al., 2020; Humplik et al., 2019; Igl et al., 2018; Rakelly et al., 2019; Zintgraf et al., 2020). However, prior work consistently report that this baseline is reported to be unperformed to more specialized methods. This section casts doubt on that claim, showing that a well-tuned implementation of recurrent model-free RL can perform at least as well as more specialized methods.
77
+
78
+ We study four subareas of POMDPs: the “standard” POMDP, meta RL, robust RL, and generalization in RL. We tune a wide range of decision factors shown in Sec. 4 in our implemented recurrent model-free RL. Appendix A.3 shows the details of the tuning options. For each subarea, we show the performance of a single variant that works best across the environments in that subarea, compared with the prior specialized methods in this subsection. In other words, the following plots of each subarea report the same model-free recurrent RL algorithm with the same hyperparameters. The exact configurations of each subarea can be found in the last four rows of Table 2. Under this restricted setting, we find that our implementation can actually outperform prior (specialized) methods by a wide margin across the four subareas.
79
+
80
+ For each plot of learning curves, we show three approaches as reference. First, an Oracle policy has access to the POMDP hidden states, turning the POMDP into an MDP; this policy should therefore be treated as an upper bound on the performance that any POMDP method should receive. Second, as a lower bound, we use a Markovian policy to solve the POMDP. Both Oracle policy and Markovian policy are trained with the same hyperparameters as our recurrent model-free RL implementation. Third, we add a Random policy, which represents a trivial lower bound. We show the full learning curves in Appendix E.1 due to the space limit. See Appendix B for details about the implementation of these comparisons.
81
+
82
+ “Standard” POMDP. Our first experiments look at the “standard” POMDPs that typically occlude some part of states in the environment. We will compare against VRM (Han et al., 2020), a recent state-of-the-art model-based POMDP algorithm. We directly apply the environment design of VRM paper that occludes either positions&angles or velocities of the simulated robot in PyBullet (Coumans & Bai, 2016). There are 8 environments {Hopper, Ant, Walker, Cheetah}- $\{ \mathrm { P } , \mathrm { V } \}$ , where “-P” stands for observing positions&angles only, and “-V” stands for observing velocities only. Fig. 1 and Fig. 18 in appendix show that the best single variant of our model-free recurrent RL implementation outperform VRM in 6 out of 8 environments, especially in {Cheetah,Hopper}- $\{ \mathrm { P } \}$ (over $8 0 \%$ of the Oracles). Our results suggest that, while the variational dynamics model used by VRM may be useful for some tasks, a simple recurrent model-free RL baseline can outperform VRM if properly tuned. While we are primarily interested in sample complexity, but not compute, it is worth noting that our recurrent model-free RL implementation is substantially more efficient than the open-source VRM implementation, training $5 \times$ faster and requiring at most $2 0 0 \times$ less RAM usage (see Appendix A).
83
+
84
+ Meta RL. We next compare the recurrent model-free RL to the meta RL setting, where some indicator of the task is unobserved. We compare our implementation of recurrent model-free RL to a specialized state-of-the-art method, VariBAD (Zintgraf et al., 2020) that explicitly learns the task embeddings by variational model-based objectives. As suggested by Dorfman et al. (2020), we modified VariBAD to use SAC instead of PPO. This change also allows us for fair comparison with our implementation of recurrent model-free RL, which uses SAC and TD3. We adopt the three environments used in Dorfman et al. (2020) for experiments, including Semi-Circle and CheetahVel, and we also adapt Wind to make it harder to solve. Figure 2 shows that our best single variant outperforms VariBAD and even reaches Oracles in the two meta RL environments, Cheetah-Vel and Wind, leaving Semi-Circle in the appendix. Prior work (Rakelly et al., 2019; Zintgraf et al., 2020) show that disentangling task inference and control can stabilize training. However, our experiments suggest that joint training of task inference and control could also have comparable performance if well implemented. Additionally, because recurrent model-free RL is trained end-to-end, without using pre-trained task representations saved in the replay buffer like the off-policy VariBAD (Dorfman et al., 2020), our implementation does not have non-stationarity issue in task representations.
85
+
86
+ ![](images/30edb2beedd34b03559cfe4a7cb9d2b19f7fdd16870545558111d5f04ec4f72b.jpg)
87
+ Figure 2: Learning curves on two meta RL environments. The single best variant of our implementation on recurrent model-free RL can surpass the specialized meta RL method off-policy VariBAD (Dorfman et al., 2020), and match the performance of an “Oracle” policy that gets to observe the hidden state.
88
+
89
+ ![](images/473825d8305f612f2647b1794d5d4c29303a403a99877872238870f73e2911e4.jpg)
90
+ Figure 3: Learning curves on one robust RL environment, Cheetah-Robust. We show the average returns (left figure) and worst returns (right figure) of each method. The single best variant of our implementation on recurrent model-free RL can greatly outperform the specialized robust RL method MRPO (Jiang et al., 2021), and surpass the Oracle that are trained with same simulation and gradient steps.
91
+
92
+ Robust RL. Thirdly, we focus on the robust RL that aims to maximize the worst returns over the tasks. We choose the recent specialized algorithm MRPO (Jiang et al., 2021) as the compared method, and adopt their used environments based on SunBlaze benchmark (Packer et al., 2018). These environments have hidden states that are fixed during one episode, including the density and the friction coefficients of the simulated robots, namely {Cheetah, Hopper, Walker $\}$ -Robust. Fig. 3 shows both the average return and worst return of our single best variant and MRPO on the three environments, where the worst return is measured by the average return in the worst $1 0 \%$ testing tasks following the practice in Jiang et al. (2021). The results are quite surprising: although our implementation, using average-case RL objective and without access to the hidden states, is not expected to surpass MRPO and Oracle with access to hidden states in worst return, we found that our best variant vastly outperforms the specialized MRPO and Oracle in both average return and worst return, with over $8 0 \%$ fewer simulation steps. Our implementation benefits from its memory and off-policy algorithms, while MRPO might suffer from its Markovian on-policy algorithm and a bit ideal Lipschitz assumption in dynamics. Nevertheless, our implementation is around $1 7 . 5 \mathrm { x }$ slower than MRPO given the same simulation steps (see Appendix A), so we only run it with 3M steps with a limited time budget.
93
+
94
+ Generalization in RL. Finally, we focus on the SunBlaze benchmark from Packer et al. (2018) for investigating generalization in RL, including {Hopper, Cheetah}-Generalize. We pick the best specialized method in the tables of final performance in Packer et al. (2018), Markovian on-policy robust RL method EPOpt-PPO-FF (Rajeswaran et al., 2017a). Fig. 4 show the interpolation and extrapolation success rates in one environment, where in the interpolation the testing tasks have same distribution of hidden states as that of the training tasks, while in the extrapolation the testing distribution is disjoint from that of training. We can see that our model-free method is on par with the EPOpt-PPO-FF in the interpolation benchmark, while EPOpt-PPO-FF requires access to the dynamics parameters but ours does not. In the extrapolation benchmark, our method greatly outperforms the previous method, although our objective does not consider extrapolation.
95
+
96
+ ![](images/77085ccdb2c33145a870334a711f81035c3a228a1dd349da3475e0735128d0c8.jpg)
97
+ Figure 4: Learning curves on generalization in one RL environment, Hopper-Generalize. We show the interpolation success rates (left figures) and extrapolation success rates (right figures) of each method. The single best variant of our implementation on recurrent model-free RL can be par with the specialized method EPOpt-PPO-FF (Rajeswaran et al., 2017a) in interpolation and outperform it in extrapolation. The data of EPOpt-PPO-FF and A2C-RC (a recurrent model-free on-policy RL method) are copied from the Table 7 & 8 in Packer et al. (2018).
98
+
99
+ Overall, we can see that with careful tuning on recurrent model-free RL, it can at least perform as well as the specialized or more complicated methods, in various kinds of POMDPs.
100
+
101
+ # 5.2 WHAT MATTERS IN RECURRENT MODEL-FREE RL ALGORITHMS?
102
+
103
+ In the previous subsection, we showed that recurrent model-free RL can perform on par with the specialized (state-of-the-art) methods, then a natural question comes: Why our implementation of recurrent model-free RL outperforms the implementation used in prior work?
104
+
105
+ Our analysis will focus on ablating the five important design decisions introduced in Sec. 4: the actor-critic architecture (Arch), the policy input space (Inputs), the underlying model-free RL algorithm (RL), the RNN encoder (Encoder), and the RNN context length (Len). See Table. 2 for a summary of how prior work made these design decisions. Due to the space limit, we show the ablation results in some but not all the environments to compare the performance between the best single variant and the other variant that only differs in one decision factor. We also provide “single factor analysis” plots for each decision factor by averaging the performance over the other factors in Appendix E.2.
106
+
107
+ Recurrent Off-Policy Actor-Critic Architecture. First, we ran some experiments with both shared and separate architectures on two toy POMDP environments. Fig. 5 show the results in one of them (see Appendix E.3 for the other). We can see that the shared architecture failed to learn, compared to the separate architecture. The large RNN gradient norm in the shared architecture suggests that the actor and critic losses may cause conflicts in gradient update. Our results echo prior work (Fakoor et al., 2020; Meng et al.,
108
+
109
+ ![](images/1a7c066033dd192c76200952bccffa2034a7b549306d97b25307dd5892ba7fd1.jpg)
110
+ Figure 5: Comparison between shared and separate recurrent actor-critic architecture with all the other hyperparameters same, on Semi-Circle, a toy meta RL environment. We show the performance metric (left) and also gradient norm of the RNN encoder(s) (right, in log-scale). For the separate architecture, :critic and :actor refer to the separate RNN in critic and actor networks, respectively.
111
+
112
+ 2021; Sun et al., 2021) that only consider separate RNN encoders that can achieve high asymptotic rewards, and also echo that (Han et al., 2020) shows poor results in the shared architecture of SAC-LSTM.
113
+
114
+ Policy Input Space. The 1st row of Table 3 shows the effect of policy input space in a POMDP environment Walker-P. The reward signals could help reveal the missing information of the velocity of the robot base, which is occluded in Walker-P. Similarly, the single factor analysis on policy input in Fig. 12 shows that oar is among the best in “-P” environments. Therefore, it is reasonable that adding previous rewards into policy inputs can increase the performance.
115
+
116
+ Table 3: Ablation results in our implementation of recurrent model-free RL. In this table, we show how a single change in one decision factor from the variant that is best on average in that subarea, could significantly increase the performance. The first column shows how we change the single decision factor, and the last column shows the performance comparison between the best variant in that subarea (left) and the ablated one (right). For robust RL and generalization in RL, we show the performance metric in worst returns and extrapolation success rates, respectively.
117
+
118
+ <table><tr><td>Change in one decision factor</td><td>Subarea</td><td>Env</td><td>Performance comparison</td></tr><tr><td>Inputs:oa→oar</td><td>“Standard”POMDP</td><td>Walker-P</td><td>981.6 → 1345.0 (1.3×)</td></tr><tr><td>RL: TD3 →SAC</td><td>“Standard”POMDP</td><td>Ant-P</td><td>310.7 → 2123.5 (6.8×)</td></tr><tr><td>Encoder: LSTM→GRU</td><td>Robust RL</td><td>Walker-Robust</td><td>765.9 → 931.3 (1.2×)</td></tr><tr><td>Len: 64 →400</td><td>Meta RL</td><td>Cheetah-Vel</td><td>-85.2 -→ -74.6 (+14%)</td></tr><tr><td>Len: 64→5</td><td>Generalization</td><td>Hopper-Generalize</td><td>0.292 -→ 0.415 (1.4×)</td></tr><tr><td>Len: 64→5</td><td>“Standard&quot;POMDP</td><td>Walker-V</td><td>121.4 -→ 264.3 (2.2×)</td></tr></table>
119
+
120
+ Model-free RL Algorithms. Table 2 shows that TD3 dominates all the best variants in each subarea, which may be due to dense reward setting in most environments. However, the 2nd row of Table 3 shows the effect of RL algorithm in a POMDP environment Ant-P. SAC is significantly better than TD3 (increase by $6 . 8 \times$ , surpassing the PPO-GRU (Kostrikov, 2018) in Fig. 1), possibly due to strategic exploration where the action noise conditions on the history instead of being independent. This is prominent mainly in Ant-P as it might be much harder than the others.
121
+
122
+ RNN Variants and Context Length. Generally, there is no significant difference between LSTM and GRU (see the single factor analysis in Appendix E.2), which is understandable as both are designed for general purpose. Howover, the 3rd row of Table 3 shows the effect of RNN encoder in a robust RL environment. We can see replacing LSTM with GRU can increase the worst-case metric in Walker-Robust. For the context length in RNNs, a medium length (64) dominates in all the best variants in each subarea (see Table 2), which could be viewed as a trade-off between memory capacity and computation costs. However, the remaining rows of Table 3 show the mixed effects of context length in RNNs. Both increasing and decreasing the context length can boost the performance in different environments. Specifically, decreasing the length from 64 to 5 makes our method surpass VRM in Walker-V (increase by $2 . 2 \times \phantom { }$ . This might explain why the prior methods adopt a wide range of context lengths from 1 to 2048 (see Table 2). Therefore, the choice of context length is problem-specific and can require tuning.
123
+
124
+ Summary. We now summarize the main findings of our experiments:
125
+
126
+ 1. Using separate weights for the recurrent actor and recurrent critic boosts performance, likely because it avoids gradient explosion (Fig. 5 and Fig. 17 in Appendix).
127
+ 2. Using state-of-the-art off-policy RL algorithms as the backbone in recurrent model-free RL can improve asymptotic performance (Fig. 1 and Figures in Appendix E.1).
128
+ 3. The context length for the recurrent actor and critic has a large influence on task performance, but the optimal length is task-specific. Reasonable values are 5 to 500, and 64 is a good start (Rows 4–6 in Table 3 and Figures in Appendix E.2).
129
+ 4. It is important that the inputs to the recurrent actor and critic, such as past observations and past returns, contain enough information to infer the POMDP hidden states (Row 1 in Table 3 and Figures in Appendix E.2).
130
+
131
+ These findings may provide a useful initialization for researchers studying recurrent model-free RL.
132
+
133
+ # 6 CONCLUSION
134
+
135
+ In this paper, we show that a carefully-designed implementation of recurrent model-free RL can perform well across a range of POMDP domains, often on par with (if not significantly better than) prior methods that are specifically designed for specific types of POMDPs. Our ablation experiments demonstrate the importance of key design decisions, such as the underlying RL algorithm and RNN context length. While the best choices for some decisions (such as using separate RNNs for the actor and the critic) are consistent across domains, the best choices for other decisions (such as RNN context length) are problem-dependent.
136
+
137
+ # REPRODUCIBILITY STATEMENT
138
+
139
+ We release our code at the url for reproducibility. In this code repository, we provide instructions on how to run our method and the compared methods in this paper on all the environments involved in the experiment section. We provide the default configuration files for training and evaluating these algorithms that are adopted in our experiments. We also attach the numeric results of all the bar charts shown in the experiment section.
140
+
141
+ ETHICS STATEMENT
142
+
143
+ We do not believe that our work has direct ethical or societal implications.
144
+
145
+ # REFERENCES
146
+
147
+ Marcin Andrychowicz, Anton Raichuk, Piotr Stanczyk, Manu Orsini, Sertan Girgin, Raphael Marinier, L ¨ eonard ´ Hussenot, Matthieu Geist, Olivier Pietquin, Marcin Michalski, Sylvain Gelly, and Olivier Bachem. What matters for on-policy deep actor-critic methods? A large-scale study. In 9th International Conference on Learning Representations, ICLR 2021, Virtual Event, Austria, May 3-7, 2021, 2021.
148
+
149
+ Karl Johan Astr ˚ om. Optimal control of markov processes with incomplete state information i. ¨ Journal of Mathematical Analysis and Applications, 10:174–205, 1965.
150
+
151
+ J Andrew Bagnell, Andrew Y Ng, and Jeff G Schneider. Solving uncertain markov decision processes. 2001.
152
+
153
+ Bram Bakker. Reinforcement learning with long short-term memory. In Advances in Neural Information Processing Systems 14 [Neural Information Processing Systems: Natural and Synthetic, NIPS 2001, December 3-8, 2001, Vancouver, British Columbia, Canada], 2001.
154
+
155
+ Richard Bellman. A markovian decision process. Journal of mathematics and mechanics, 6(5):679–684, 1957.
156
+
157
+ Yoshua Bengio, Patrice Y. Simard, and Paolo Frasconi. Learning long-term dependencies with gradient descent is difficult. IEEE Trans. Neural Networks, 1994.
158
+
159
+ Anthony R. Cassandra, Leslie Pack Kaelbling, and Michael L. Littman. Acting optimally in partially observable stochastic domains. In Proceedings of the 12th National Conference on Artificial Intelligence, Seattle, WA, USA, July 31 - August 4, 1994, Volume 2, 1994.
160
+
161
+ Min Chen, Stefanos Nikolaidis, Harold Soh, David Hsu, and Siddhartha S. Srinivasa. Planning with trust for human-robot collaboration. In Proceedings of the 2018 ACM/IEEE International Conference on HumanRobot Interaction, HRI 2018, Chicago, IL, USA, March 05-08, 2018, 2018.
162
+
163
+ Kyunghyun Cho, Bart van Merrienboer, C¸ aglar Gulc¸ehre, Dzmitry Bahdanau, Fethi Bougares, Holger ¨ Schwenk, and Yoshua Bengio. Learning phrase representations using RNN encoder-decoder for statistical machine translation. In Proceedings of the 2014 Conference on Empirical Methods in Natural Language Processing, EMNLP 2014, October 25-29, 2014, Doha, Qatar, A meeting of SIGDAT, a Special Interest Group of the ACL, 2014.
164
+
165
+ Junyoung Chung, C¸ aglar Gulc¸ehre, KyungHyun Cho, and Yoshua Bengio. Empirical evaluation of gated re-¨ current neural networks on sequence modeling. arXiv preprint arXiv:1412.3555, 2014.
166
+
167
+ Karl Cobbe, Oleg Klimov, Christopher Hesse, Taehoon Kim, and John Schulman. Quantifying generalization in reinforcement learning. In Proceedings of the 36th International Conference on Machine Learning, ICML 2019, 9-15 June 2019, Long Beach, California, USA, 2019.
168
+
169
+ Karl Cobbe, Christopher Hesse, Jacob Hilton, and John Schulman. Leveraging procedural generation to benchmark reinforcement learning. In Proceedings of the 37th International Conference on Machine Learning, ICML 2020, 13-18 July 2020, Virtual Event, 2020.
170
+
171
+ Erwin Coumans and Yunfei Bai. Pybullet, a python module for physics simulation for games, robotics and machine learning. 2016.
172
+
173
+ Ron Dorfman, Idan Shenfeld, and Aviv Tamar. Offline meta learning of exploration. arXiv preprint arXiv:2008.02598, 2020.
174
+
175
+ Yan Duan, John Schulman, Xi Chen, Peter L Bartlett, Ilya Sutskever, and Pieter Abbeel. Rl2: Fast reinforcement learning via slow reinforcement learning. arXiv preprint arXiv:1611.02779, 2016.
176
+
177
+ Logan Engstrom, Andrew Ilyas, Shibani Santurkar, Dimitris Tsipras, Firdaus Janoos, Larry Rudolph, and Aleksander Madry. Implementation matters in deep RL: A case study on PPO and TRPO. In 8th International Conference on Learning Representations, ICLR 2020, Addis Ababa, Ethiopia, April 26-30, 2020, 2020.
178
+
179
+ Rasool Fakoor, Pratik Chaudhari, Stefano Soatto, and Alexander J. Smola. Meta-q-learning. In 8th International Conference on Learning Representations, ICLR 2020, Addis Ababa, Ethiopia, April 26-30, 2020, 2020.
180
+
181
+ Jesse Farebrother, Marlos C. Machado, and Michael Bowling. Generalization and regularization in DQN. arXiv preprint arXiv:1810.00123, 2018.
182
+
183
+ Chelsea Finn, Pieter Abbeel, and Sergey Levine. Model-agnostic meta-learning for fast adaptation of deep networks. In Proceedings of the 34th International Conference on Machine Learning, ICML 2017, Sydney, NSW, Australia, 6-11 August 2017, 2017.
184
+
185
+ C. Daniel Freeman, David Ha, and Luke Metz. Learning to predict without looking ahead: World models without forward prediction. 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, 2019.
186
+
187
+ Scott Fujimoto, Herke van Hoof, and David Meger. Addressing function approximation error in actor-critic methods. In Proceedings of the 35th International Conference on Machine Learning, ICML 2018, Stockholmsmassan, Stockholm, Sweden, July 10-15, 2018¨ , 2018.
188
+
189
+ Adam Gleave, Michael Dennis, Cody Wild, Neel Kant, Sergey Levine, and Stuart Russell. Adversarial policies: Attacking deep reinforcement learning. In 8th International Conference on Learning Representations, ICLR 2020, Addis Ababa, Ethiopia, April 26-30, 2020, 2020.
190
+
191
+ Tuomas Haarnoja, Aurick Zhou, Pieter Abbeel, and Sergey Levine. Soft actor-critic: Off-policy maximum entropy deep reinforcement learning with a stochastic actor. In Proceedings of the 35th International Conference on Machine Learning, ICML 2018, Stockholmsmassan, Stockholm, Sweden, July 10-15, 2018 ¨ , 2018a.
192
+
193
+ Tuomas Haarnoja, Aurick Zhou, Kristian Hartikainen, George Tucker, Sehoon Ha, Jie Tan, Vikash Kumar, Henry Zhu, Abhishek Gupta, Pieter Abbeel, and Sergey Levine. Soft actor-critic algorithms and applications. arXiv preprint arXiv:1812.05905, 2018b.
194
+
195
+ Dongqi Han, Kenji Doya, and Jun Tani. Variational recurrent models for solving partially observable control tasks. In 8th International Conference on Learning Representations, ICLR 2020, Addis Ababa, Ethiopia, April 26-30, 2020, 2020.
196
+
197
+ Matthew J. Hausknecht and Peter Stone. Deep recurrent q-learning for partially observable mdps. In 2015 AAAI Fall Symposia, Arlington, Virginia, USA, November 12-14, 2015, 2015.
198
+
199
+ Nicolas Heess, Jonathan J. Hunt, Timothy P. Lillicrap, and David Silver. Memory-based control with recurrent neural networks. arXiv preprint arXiv:1512.04455, 2015.
200
+
201
+ Sepp Hochreiter and Jurgen Schmidhuber. Long short-term memory. ¨ Neural computation, 9(8):1735–1780, 1997.
202
+
203
+ Sepp Hochreiter, A. Steven Younger, and Peter R. Conwell. Learning to learn using gradient descent. In Artificial Neural Networks - ICANN 2001, International Conference Vienna, Austria, August 21-25, 2001 Proceedings, 2001.
204
+
205
+ Sandy H. Huang, Nicolas Papernot, Ian J. Goodfellow, Yan Duan, and Pieter Abbeel. Adversarial attacks on neural network policies. In 5th International Conference on Learning Representations, ICLR 2017, Toulon, France, April 24-26, 2017, Workshop Track Proceedings, 2017.
206
+
207
+ Jan Humplik, Alexandre Galashov, Leonard Hasenclever, Pedro A. Ortega, Yee Whye Teh, and Nicolas Heess. Meta reinforcement learning as task inference. arXiv preprint arXiv:1905.06424, 2019.
208
+
209
+ Maximilian Igl, Luisa M. Zintgraf, Tuan Anh Le, Frank Wood, and Shimon Whiteson. Deep variational reinforcement learning for pomdps. In Proceedings of the 35th International Conference on Machine Learning, ICML 2018, Stockholmsmassan, Stockholm, Sweden, July 10-15, 2018 ¨ , 2018.
210
+
211
+ Maximilian Igl, Kamil Ciosek, Yingzhen Li, Sebastian Tschiatschek, Cheng Zhang, Sam Devlin, and Katja Hofmann. Generalization in reinforcement learning with selective noise injection and information bottleneck. 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, 2019.
212
+
213
+ Masoumeh T. Izadi and Doina Precup. Using rewards for belief state updates in partially observable markov decision processes. In Machine Learning: ECML 2005, 16th European Conference on Machine Learning, Porto, Portugal, October 3-7, 2005, Proceedings, 2005.
214
+
215
+ Yuankun Jiang, Chenglin Li, Wenrui Dai, Junni Zou, and Hongkai Xiong. Monotonic robust policy optimization with model discrepancy. In Proceedings of the 38th International Conference on Machine Learning, ICML 2021, 18-24 July 2021, Virtual Event, 2021.
216
+
217
+ Niels Justesen, Ruben Rodriguez Torrado, Philip Bontrager, Ahmed Khalifa, Julian Togelius, and Sebastian Risi. Illuminating generalization in deep reinforcement learning through procedural level generation. arXiv preprint arXiv:1806.10729, 2018.
218
+
219
+ Leslie Pack Kaelbling, Michael L. Littman, and Anthony R. Cassandra. Planning and acting in partially observable stochastic domains. Artif. Intell., 1998.
220
+
221
+ Islam SM Khalil, JC Doyle, and K Glover. Robust and optimal control. prentice hall, new jersey, 1996.
222
+
223
+ Ilya Kostrikov. Pytorch implementations of reinforcement learning algorithms. https://github.com/ ikostrikov/pytorch-a2c-ppo-acktr-gail, 2018.
224
+
225
+ Kimin Lee, Kibok Lee, Jinwoo Shin, and Honglak Lee. Network randomization: A simple technique for generalization in deep reinforcement learning. In 8th International Conference on Learning Representations, ICLR 2020, Addis Ababa, Ethiopia, April 26-30, 2020, 2020.
226
+
227
+ Michael Lederman Littman. Algorithms for sequential decision-making. Brown University, 1996.
228
+
229
+ Xiao Ma, Peter Karkus, David Hsu, and Wee Sun Lee. Particle filter recurrent neural networks. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 34, pp. 5101–5108, 2020a.
230
+
231
+ Xiao Ma, Peter Karkus, David Hsu, Wee Sun Lee, and Nan Ye. Discriminative particle filter reinforcement learning for complex partial observations. arXiv preprint arXiv:2002.09884, 2020b.
232
+
233
+ Lingheng Meng, Rob Gorbet, and Dana Kulic. Memory-based deep reinforcement learning for POMDP. arXiv preprint arXiv:2102.12344, 2021.
234
+
235
+ Volodymyr Mnih, Adria Puigdom \` enech Badia, Mehdi Mirza, Alex Graves, Timothy P. Lillicrap, Tim Harley, \` David Silver, and Koray Kavukcuoglu. Asynchronous methods for deep reinforcement learning. In Proceedings of the 33nd International Conference on Machine Learning, ICML 2016, New York City, NY, USA, June 19-24, 2016, 2016.
236
+
237
+ Jun Morimoto and Kenji Doya. Robust reinforcement learning. Neural computation, 17(2):335–359, 2005.
238
+
239
+ Arnab Nilim and Laurent El Ghaoui. Robust control of markov decision processes with uncertain transition matrices. Oper. Res., 2005.
240
+
241
+ Charles Packer, Katelyn Gao, Jernej Kos, Philipp Krahenb ¨ uhl, Vladlen Koltun, and Dawn Song. Assessing ¨ generalization in deep reinforcement learning. arXiv preprint arXiv:1810.12282, 2018.
242
+
243
+ Christos H. Papadimitriou and John N. Tsitsiklis. The complexity of markov decision processes. Math. Oper. Res., 1987.
244
+
245
+ Anay Pattanaik, Zhenyi Tang, Shuijing Liu, Gautham Bommannan, and Girish Chowdhary. Robust deep reinforcement learning with adversarial attacks. In Proceedings of the 17th International Conference on Autonomous Agents and MultiAgent Systems, AAMAS 2018, Stockholm, Sweden, July 10-15, 2018, 2018.
246
+
247
+ Lerrel Pinto, James Davidson, Rahul Sukthankar, and Abhinav Gupta. Robust adversarial reinforcement learning. In Proceedings of the 34th International Conference on Machine Learning, ICML 2017, Sydney, NSW, Australia, 6-11 August 2017, 2017.
248
+
249
+ Pascal Poupart and Craig Boutilier. Value-directed compression of pomdps. In Advances in Neural Information Processing Systems 15 [Neural Information Processing Systems, NIPS 2002, December 9-14, 2002, Vancouver, British Columbia, Canada], 2002.
250
+
251
+ Martin L Puterman. Markov decision processes: discrete stochastic dynamic programming. John Wiley and Sons, 2014.
252
+
253
+ Antonin Raffin. Rl baselines3 zoo. https://github.com/DLR-RM/rl-baselines3-zoo, 2020.
254
+
255
+ Antonin Raffin, Jens Kober, and Freek Stulp. Smooth exploration for robotic reinforcement learning. In 5th Annual Conference on Robot Learning, 2021.
256
+
257
+ Roberta Raileanu and Rob Fergus. Decoupling value and policy for generalization in reinforcement learning. In Proceedings of the 38th International Conference on Machine Learning, ICML 2021, 18-24 July 2021, Virtual Event, 2021.
258
+
259
+ Aravind Rajeswaran, Sarvjeet Ghotra, Balaraman Ravindran, and Sergey Levine. Epopt: Learning robust neural network policies using model ensembles. In 5th International Conference on Learning Representations, ICLR 2017, Toulon, France, April 24-26, 2017, Conference Track Proceedings, 2017a.
260
+
261
+ Aravind Rajeswaran, Kendall Lowrey, Emanuel Todorov, and Sham M. Kakade. Towards generalization and simplicity in continuous control. In Advances in Neural Information Processing Systems 30: Annual Conference on Neural Information Processing Systems 2017, December 4-9, 2017, Long Beach, CA, USA, 2017b.
262
+
263
+ Kate Rakelly, Aurick Zhou, Chelsea Finn, Sergey Levine, and Deirdre Quillen. Efficient off-policy metareinforcement learning via probabilistic context variables. In Proceedings of the 36th International Conference on Machine Learning, ICML 2019, 9-15 June 2019, Long Beach, California, USA, 2019.
264
+
265
+ Alessio Russo and Alexandre Proutiere. Towards optimal attacks on reinforcement learning policies. In \` 2021 American Control Conference, ACC 2021, New Orleans, LA, USA, May 25-28, 2021, 2021.
266
+
267
+ Jurgen Schmidhuber. ¨ Evolutionary principles in self-referential learning, or on learning how to learn: the meta-meta-... hook. PhD thesis, Technische Universitat M¨ unchen, 1987. ¨
268
+
269
+ Jurgen Schmidhuber. Reinforcement learning in markovian and non-markovian environments. In ¨ Advances in Neural Information Processing Systems 3, NIPS’3, pp. 500–506, 1991.
270
+
271
+ John Schulman, Sergey Levine, Pieter Abbeel, Michael I. Jordan, and Philipp Moritz. Trust region policy optimization. In Proceedings of the 32nd International Conference on Machine Learning, ICML 2015, Lille, France, 6-11 July 2015, 2015.
272
+
273
+ John Schulman, Filip Wolski, Prafulla Dhariwal, Alec Radford, and Oleg Klimov. Proximal policy optimization algorithms. arXiv preprint arXiv:1707.06347, 2017.
274
+
275
+ Xingyou Song, Yiding Jiang, Stephen Tu, Yilun Du, and Behnam Neyshabur. Observational overfitting in reinforcement learning. In 8th International Conference on Learning Representations, ICLR 2020, Addis Ababa, Ethiopia, April 26-30, 2020, 2020.
276
+
277
+ Mario Srouji, Jian Zhang, and Ruslan Salakhutdinov. Structured control nets for deep reinforcement learning. In Proceedings of the 35th International Conference on Machine Learning, ICML 2018, Stockholmsmassan, ¨ Stockholm, Sweden, July 10-15, 2018, 2018.
278
+
279
+ Freek Stulp, Evangelos A. Theodorou, Jonas Buchli, and Stefan Schaal. Learning to grasp under uncertainty. In IEEE International Conference on Robotics and Automation, ICRA 2011, Shanghai, China, 9-13 May 2011, 2011.
280
+
281
+ Hao Sun, Ziping Xu, Meng Fang, Zhenghao Peng, Jiadong Guo, Bo Dai, and Bolei Zhou. Safe exploration by solving early terminated mdp. arXiv preprint arXiv:2107.04200, 2021.
282
+
283
+ Chen Tessler, Yonathan Efroni, and Shie Mannor. Action robust reinforcement learning and applications in continuous control. In Proceedings of the 36th International Conference on Machine Learning, ICML 2019, 9-15 June 2019, Long Beach, California, USA, 2019.
284
+
285
+ Sebastian Thrun and Lorien Pratt. Learning to learn. Springer Science and Business Media, 2012.
286
+
287
+ 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, 2017.
288
+
289
+ Emanuel Todorov, Tom Erez, and Yuval Tassa. Mujoco: A physics engine for model-based control. In 2012 IEEE/RSJ International Conference on Intelligent Robots and Systems, IROS 2012, Vilamoura, Algarve, Portugal, October 7-12, 2012, 2012.
290
+
291
+ Trieu Trinh, Andrew Dai, Thang Luong, and Quoc Le. Learning longer-term dependencies in rnns with auxiliary losses. In International Conference on Machine Learning, pp. 4965–4974. PMLR, 2018.
292
+
293
+ Haonan Wang, Ning Liu, Yiyun Zhang, Dawei Feng, Feng Huang, Dong Sheng Li, and Yiming Zhang. Deep reinforcement learning: a survey. Frontiers Inf. Technol. Electron. Eng., 2020.
294
+
295
+ Jane Wang, Zeb Kurth-Nelson, Hubert Soyer, Joel Z. Leibo, Dhruva Tirumala, Remi Munos, Charles Blundell, ´ Dharshan Kumaran, and Matt M. Botvinick. Learning to reinforcement learn. In Proceedings of the 39th Annual Meeting of the Cognitive Science Society, CogSci 2017, London, UK, 16-29 July 2017, 2017.
296
+
297
+ Manuel Watter, Jost Tobias Springenberg, Joschka Boedecker, and Martin A. Riedmiller. Embed to control: A locally linear latent dynamics model for control from raw images. In Advances in Neural Information Processing Systems 28: Annual Conference on Neural Information Processing Systems 2015, December 7-12, 2015, Montreal, Quebec, Canada, 2015.
298
+
299
+ Steven D Whitehead and Dana H Ballard. Active perception and reinforcement learning. In Machine Learning Proceedings 1990, pp. 179–188. Elsevier, 1990.
300
+
301
+ Shimon Whiteson, Brian Tanner, Matthew E. Taylor, and Peter Stone. Protecting against evaluation overfitting in empirical reinforcement learning. In 2011 IEEE Symposium on Adaptive Dynamic Programming And Reinforcement Learning, ADPRL 2011, Paris, France, April 12-14, 2011, 2011.
302
+
303
+ Daan Wierstra, Alexander Forster, Jan Peters, and J ¨ urgen Schmidhuber. Solving deep memory pomdps with ¨ recurrent policy gradients. In Artificial Neural Networks - ICANN 2007, 17th International Conference, Porto, Portugal, September 9-13, 2007, Proceedings, Part I, 2007.
304
+
305
+ Aaron Wilson, Alan Fern, Soumya Ray, and Prasad Tadepalli. Multi-task reinforcement learning: a hierarchical bayesian approach. In Machine Learning, Proceedings of the Twenty-Fourth International Conference (ICML 2007), Corvallis, Oregon, USA, June 20-24, 2007, 2007.
306
+
307
+ Zhihan Yang and Hai Nguyen. Recurrent off-policy baselines for memory-based continuous control. arXiv preprint arXiv:2110.12628, 2021.
308
+
309
+ Tianhe Yu, Deirdre Quillen, Zhanpeng He, Ryan Julian, Karol Hausman, Chelsea Finn, and Sergey Levine. Meta-world: A benchmark and evaluation for multi-task and meta reinforcement learning. In 3rd Annual Conference on Robot Learning, CoRL 2019, Osaka, Japan, October 30 - November 1, 2019, Proceedings, 2019.
310
+
311
+ Amy Zhang, Nicolas Ballas, and Joelle Pineau. A dissection of overfitting and generalization in continuous reinforcement learning. arXiv preprint arXiv:1806.07937, 2018a.
312
+
313
+ Chiyuan Zhang, Oriol Vinyals, Remi Munos, and Samy Bengio. A study on overfitting in deep reinforcement ´ learning. arXiv preprint arXiv:1804.06893, 2018b.
314
+
315
+ Huan Zhang, Hongge Chen, Chaowei Xiao, Bo Li, Mingyan Liu, Duane S. Boning, and Cho-Jui Hsieh. Robust deep reinforcement learning against adversarial perturbations on state observations. In Advances in Neural Information Processing Systems 33: Annual Conference on Neural Information Processing Systems 2020, NeurIPS 2020, December 6-12, 2020, virtual, 2020.
316
+
317
+ Huan Zhang, Hongge Chen, Duane S. Boning, and Cho-Jui Hsieh. Robust reinforcement learning on state observations with learned optimal adversary. In 9th International Conference on Learning Representations, ICLR 2021, Virtual Event, Austria, May 3-7, 2021, 2021.
318
+
319
+ Chenyang Zhao, Olivier Sigaud, Freek Stulp, and Timothy M. Hospedales. Investigating generalisation in continuous deep reinforcement learning. arXiv preprint arXiv:1902.07015, 2019.
320
+
321
+ Yuke Zhu, Roozbeh Mottaghi, Eric Kolve, Joseph J. Lim, Abhinav Gupta, Li Fei-Fei, and Ali Farhadi. Targetdriven visual navigation in indoor scenes using deep reinforcement learning. In 2017 IEEE International Conference on Robotics and Automation, ICRA 2017, Singapore, Singapore, May 29 - June 3, 2017, 2017.
322
+
323
+ Brian D Ziebart. Modeling purposeful adaptive behavior with the principle of maximum causal entropy. Carnegie Mellon University, 2010.
324
+
325
+ 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, 2020.
326
+
327
+ # A CODE-LEVEL DETAILS
328
+
329
+ In this section, we first introduce the outline of code design, especially the replay buffer for sequences, and then compare the system usage, including computing speed, RAM, and GPU memory with previous POMDP methods.
330
+
331
+ # A.1 CODE DESIGN
332
+
333
+ Easy to use. Our code can be either used as an API to call the recurrent model-free RL class or a framework to tune the details in the class. The recurrent model-free RL class takes the hyperparameters of RNN encoder type, shared or separate actor-critic architecture, and whether include previous observations, and/or actions, and/or rewards into the inputs, to generate different instances. The details of the hyperparameter tuning set are shown in Sec. A.3.
334
+
335
+ Memory-efficient replay buffer for sequences. Moreover, we design an efficient replay buffer for off-policy RL methods to cope with sequential inputs. Previous methods (Han et al., 2020; Yang & Nguyen, 2021) mainly use three-dimensional replay buffer to store sequential inputs, with the dimensions of (num episodes, max episode length, observation dimension), taking observation storage as example. This kind of implementation becomes memory-inefficient if the actual episode length is far smaller than the max episode length (then there will be many padded zeros (Dorfman et al., 2020)). Instead, we manage to implement a two-dimensional replay buffer of shape (num transitions, observation dimension) for observation storage, which also records the locations where each stored episode ends. In case of actual episodes that are shorter than provided sampled sequence length, the buffer also generates on-the-fly masks to indicate if the corresponding transitions are valid, so that we do not need to save zero-padded observations in the buffer. This enables the policy to receive a batch of previous experiences in a tensor-like data structure when sampling from the replay buffer. To sum up, our replay buffer can support varying-length sequence inputs and subsequence sampling without zero padding.
336
+
337
+ Flexible training speed. Finally, our code supports flexible training speed by controlling the ratio of the numbers of gradient updates in RL w.r.t. the environment rollout steps. The training speed is approximately proportional to the ratio if the simulator speed is much faster than the policy gradient update. Typically, the ratio is less than or equal to 1.0 to enjoy higher training speed.
338
+
339
+ # A.2 SYSTEM USAGE
340
+
341
+ Table 4 shows the typical system usage of our method and the compared specialized methods on different environments. The time cost for our method and VariBAD depends on how many processes in parallel are run on a single GPU – our method is run with 8 processes on a single GPU while VariBAD is run with one process due to large GPU memory usage. From the results we can see that our method is memory-efficient in both RAM and GPU, and has an acceptable training speed with default hyperparameters. The computer system we used during the experiments includes a GeForce RTX 2080 Ti Graphic Card (with 11GB memory) and Intel(R) Xeon(R) Gold 6148 CPU $@$ 2.40GHz (with 250GB RAM and 80 cores).
342
+
343
+ Table 4: Comparison between our method and specialized methods in system usage. The time costs are evaluated within 1M environment steps. Both VRM and MRPO are run on CPUs and MRPO does not have a replay buffer (shown in N/A). VariBAD requires the assumption of fixed episode length for the RAM cost.
344
+
345
+ <table><tr><td>Method</td><td>Environment</td><td>Time cost</td><td>RAM</td><td>GPU memory</td></tr><tr><td>Ours (GRU)</td><td>Hopper-V</td><td>22.5 h</td><td>0(1)</td><td>1.2 GB</td></tr><tr><td>VRM (Han et al., 2020)</td><td>Hopper-V</td><td>102 h</td><td>0(200)</td><td>N/A</td></tr><tr><td>Ours</td><td>Semi-Circle</td><td>12h</td><td>0(1)</td><td>1 GB</td></tr><tr><td>VariBAD (Dorfman et al., 2020)</td><td>Semi-Circle</td><td>2.3 h</td><td>0(1)*</td><td>9.5 GB</td></tr><tr><td>Ours</td><td>Cheetah-Robust</td><td>7h</td><td>0(1)</td><td>1.1 GB</td></tr><tr><td>MRPO (Jiang et al., 2021)</td><td>Cheetah-Robust</td><td>0.4 h</td><td>N/A</td><td>N/A</td></tr></table>
346
+
347
+ # A.3 OUR HYPERPARAMETER TUNING SET
348
+
349
+ Our proposed method has the following decision factors (introduced in Sec. 4) to tune in the experiments with the following options (the names in brackets are abbreviated ones):
350
+
351
+ • Actor-Critic architecture (Arch): share the encoder weights between the recurrent actor and recurrent critic or not, namely shared and separate.
352
+ • Model-free RL algorithms (RL): td3 (Fujimoto et al., 2018) or sac (Haarnoja et al., 2018a)
353
+ • Encoder architecture (Encoder): lstm (Hochreiter & Schmidhuber, 1997) or gru (Cho et al., 2014)
354
+ • Policy input space (Inputs): o, oa, or, oar, oard (the notation is introduced in Sec. 4; depending on the POMDPs, see “Policy input” row in Table 5)
355
+ • Context length (Len): short (5), medium (64), long (larger than 100, depending on the POMDPs).
356
+
357
+ For each instance, we label it with the names of all the hyperparameters it used in lowercase as notation. For example, td3-lstm-64-or-separate in Fig. 5 refers to the instance that uses the separate actor-critic architecture, TD3 RL algorithm, LSTM encoder, the policy input space of previous observations and reward sequences, and RNN context length of 64.
358
+
359
+ # B TRAINING DETAILS
360
+
361
+ ![](images/bdf52f41abe2592c14a688161716770e854e2501df874d95c4b850a55ebaab8e.jpg)
362
+ Figure 6: The network architecture of our implementation on recurrent model-free RL. The left part shows the actor network, and the right shows the critic network. Each block shows a trainable module, with independent weights. We italicize the previous action and reward encoders as they are optional. By default, each encoder has one hidden layer, each RNN is one-layer LSTM or GRU, each MLP has two hidden layers.
363
+
364
+ Fig. 6 shows our (separate) recurrent actor-critic architecture. Table 5 shows the main hyperparameters we adopt for each subarea. We did not tune these hyperparameters, except that we adjusted the number of gradient steps so that all the experiments could be completed in 36 hours.
365
+
366
+ For Markovian policies (SAC and TD3), we remove the encoders and RNNs from the actor-critic architecture, and train them with same hyperparameters as those of recurrent policies. For each task, we report the results of either SAC or TD3, whichever achieves higher returns. For Oracle policies, we use the well-tuned results from Table 1 (“SAC w/ unstructured row”) in Raffin et al. (2021), which is based on Stable Baseline3 (Raffin, 2020), for “standard” POMDPs. For the other subareas, we have to run the Markovian policies (SAC and TD3) with access to the hidden states, using the same training hyperparameters as those of recurrent policies. But these Oracle policies might be not well-tuned given same environment and gradient steps, especially in robust RL and generalization in RL.
367
+
368
+ We also show the settings of the specialized methods we compared in the main paper in Table 6. Note that our recurrent model-free RL share the exactly same settings as (off-policy) VariBAD (Dorfman et al., 2020) and VRM (Han et al., 2020). For MRPO (Jiang et al., 2021) and EPOPT (Rajeswaran et al., 2017a), they adopt totally different settings, i.e. on-policy Markovian approaches to MDPs (with access to the ground-truth state (s) of environment). Thus, in fact, MRPO and EPOPT should be more viewed as oracle policies as upper bounds of recurrent model-free RL.
369
+
370
+ Table 5: Hyperparameter summary in our implementation of model-free recurrent RL. For each subarea, we report the hidden layer size of each module, RL and training hyperparameters. For Meta-RL, we take the model on Cheetah-Vel as example, which follows the architecture design of off-policy VariBAD (Dorfman et al., 2020). The hidden size of observation-action encoder is the sum of that of observation encoder, previous action encoder (if exists), and reward encoder (if exists).
371
+
372
+ <table><tr><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>Meta-RL* POMDP Robust RL Gen. in RL</td></tr><tr><td rowspan=1 colspan=1>Hiddenlayersize</td><td rowspan=1 colspan=1>Observ.encoderPrev. Action encoder*Reward encoder*RNNMLP</td><td rowspan=1 colspan=1>[32][16][16][128][128,128,128] [256,256]</td></tr><tr><td rowspan=1 colspan=1>RLhparams</td><td rowspan=1 colspan=1>Learning rateDiscount factor ySmoothing coef T SAC temperatureTD3 noisesReplay buffer sizeBatch size</td><td rowspan=1 colspan=1>3e-40.990.005 automatically updated by Haarnoja et al. (2018b)default values from Fujimoto et al. (2018)1e632 64</td></tr><tr><td rowspan=1 colspan=1>Traininghparams</td><td rowspan=1 colspan=1>Environment stepsGradient steps</td><td rowspan=1 colspan=1>5M 1.5M 3M0.1M 1.5M 0.6M</td></tr><tr><td rowspan=1 colspan=1>Policyinputs</td><td rowspan=1 colspan=1>Largest input spaceBest input space</td><td rowspan=1 colspan=1>oard oar oa oaroard oa 0 0</td></tr></table>
373
+
374
+ Table 6: Settings of the specialized methods we compared in the main paper. For Meta-RL, we take the model on Cheetah-Vel as example.
375
+
376
+ <table><tr><td></td><td>Meta-RL*</td><td>POMDP</td><td>RobustRL</td><td>Gen. in RL</td></tr><tr><td>Approach</td><td>(off-policy) VariBAD</td><td>VRM</td><td>MRPO</td><td>EPOPT</td></tr><tr><td>Memory-based?</td><td>√</td><td>√</td><td>X</td><td>X</td></tr><tr><td>Off-policy?</td><td>√</td><td>√</td><td>X</td><td>X</td></tr><tr><td>Input space</td><td>oard</td><td>oar</td><td>S</td><td>S</td></tr><tr><td>Access to hidden states?</td><td>X</td><td>X</td><td>√</td><td>√</td></tr></table>
377
+
378
+ # C EVALUATION DETAILS
379
+
380
+ The bar charts in Fig. 1 and 18 and Table 3 adopt the final performance of each method. We run each instance/variant in our method and each compared method with 4 random seeds. The final performance is calculated by the average performance of the last $20 \%$ environment steps across the 4 seeds.
381
+
382
+ In terms of selecting the best variant in our method for each subarea, we first compute the final performance of each variant, then normalize the final performance into $[ 0 , 1 ]$ , and finally select the best variant in the average of the normalized final performance across all the environments in each subarea.
383
+
384
+ For the bar charts in Fig. 1 and 18, we show the normalized returns of each method, calculated by R−RminR −R ∈ [0, 1], where R is the raw average return of that method and Rmax and Rmin are the maximum and minimum of all the methods including Oracle policy and Random policy.
385
+
386
+ # D ENVIRONMENT DETAILS
387
+
388
+ # D.1 “STANDARD” POMDP
389
+
390
+ Except for the classic Pendulum environment, we use PyBullet (Coumans & Bai, 2016) as the simulator for “standard” POMDP environments. As the practice in VRM (Han et al., 2020), we remove all the position/angle-related entries in the observation space for “-V” environments and velocityrelated entries for “-P” environments, to transform the original MDP into POMDP.
391
+
392
+ {Pendulum,Ant,Cheetah,Hopper,Walker}-P. The “-P” stands for the environments that keep position-related entries by removal of velocity-related entries. Thus, the observed state $s ^ { o }$ includes positions $p$ , while the hidden state $s ^ { h }$ is the velocities $v$ .
393
+
394
+ {Pendulum,Ant,Cheetah,Hopper,Walker}-V. The “-V” stands for the environments that keep velocity-related entries by removal of position-related entries. Thus, the observed state $s ^ { o }$ includes positions $v$ , while the hidden state $s ^ { h }$ is the velocities $p$ .
395
+
396
+ # D.2 META RL
397
+
398
+ Semi-Circle. We directly follow off-policy version of VariBAD (Dorfman et al., 2020). The observed state $s ^ { o }$ includes the agent’s 2D position $p$ , and the hidden state $s ^ { h }$ is referred to the goal state $p _ { g }$ . The goal state only appears in reward function: $R ( s _ { t } ^ { o } , s _ { t + 1 } ^ { o } , a _ { t } , s ^ { h } ) \equiv R ( p _ { t + 1 } , p _ { g } { \bar { ) } } =$ $\mathbb { 1 } ( \lVert p _ { t + 1 } - p _ { g } \rVert _ { 2 } \leq r )$ . The dynamic function $T$ is independent of the goal state.
399
+
400
+ Cheetah-Vel. We directly follow Dorfman et al. (2020) using MuJoCo (Todorov et al., 2012) simulator of HalfCheetah-v2. The hidden state $s ^ { h }$ is the target velocity $v _ { g }$ and observed state $s ^ { o }$ includes the velocity $v$ . Reward function includes both the hidden state and action: $R ( s _ { t } ^ { o } , s _ { t + 1 } ^ { o } , a _ { t } , s ^ { h } ) \equiv R ( v _ { t } , v _ { g } , a _ { t } ) = - \| v _ { t } - v _ { g } \| _ { 1 } - 0 . 0 5 \| a _ { t } \| _ { 2 }$ . The dynamic function $T$ is independent of the goal state.
401
+
402
+ Wind. We modified the parameters of Wind environment in Dorfman et al. (2020) to make it harder to solve. The agent must navigate to a fixed (but unknown) goal $p _ { g }$ within a distance of $D = 1$ from its fixed initial state. Similarly to Semi-Circle, the reward function is goal conditioned but without hidden state: $R ( s _ { t } ^ { o } , s _ { t + 1 } ^ { o } , a _ { t } , \bar { s ^ { h } } ) \equiv R ( p _ { t + 1 } , p _ { g } ) = \mathbb { 1 } ( \| p _ { t + 1 } - p _ { g } \| _ { 2 } \bar { \leq ^ { } { r } } )$ . The hidden state $s ^ { h }$ appear in the deterministic dynamics as a noise term, i.e. $s _ { t + 1 } ^ { o } = s _ { t } ^ { o } + a _ { t } + s ^ { h }$ , where $s ^ { h }$ is sampled from $U [ - 0 . 0 8 , 0 . 0 8 ]$ at the initial time-step and then kept fixed.
403
+
404
+ # D.3 ROBUST RL
405
+
406
+ {Hopper,Walker,Cheetah}-Robust. We directly adopt the environments used in MRPO (Jiang et al., 2021). In each environment, the hidden state is the dynamics parameters including the density and friction coefficients of the simulated robot in roboschool, adapted from the SunBlaze (Packer et al., 2018). The exact ranges of the hidden states in each environment can be found in Table 1 of MRPO (Jiang et al., 2021). We evaluate the algorithms with 100 tasks in each environment, and use the average of them as average returns, and the average of the worst $1 0 \%$ of them as worst returns, following MRPO paper.
407
+
408
+ # D.4 GENERALIZATION IN RL
409
+
410
+ {Hopper,Cheetah}-Generalize. We directly adopt the environments used in SunBlaze (Packer et al., 2018). In each environment, the hidden state is the dynamics parameters including the density, friction coefficients, and the power of the simulated robot in roboschool. The exact ranges of both interpolation and extrapolation in the hidden state distribution for each environment can be found in Table 1 of SunBlaze (Packer et al., 2018). We follow the practice of SunBlaze to evaluate interpolation and extrapolation success rates.
411
+
412
+ # E FULL EXPERIMENTAL RESULTS
413
+
414
+ # E.1 LEARNING CURVES OF ALL THE COMPARED METHODS
415
+
416
+ In this subsection, we show all the learning curves of all the compared methods (including Oracle policy as upper bound, Markovian and Random policies as lower bounds) in each subarea, namely “Standard” POMDPs (Fig. 7 and Fig. 8), meta RL (Fig. 9), robust RL (Fig. 10), and generalization in RL (Fig. 11). The final performance of these learning curves generate the bar charts in Sec. 5.1.
417
+
418
+ ![](images/85ccefe946b801cd15f2e89cf6c81a75ab616a8ab9469593b794c32433d306e9.jpg)
419
+ Figure 7: Learning curves on “standard” POMDP environments that preserve positions & angles but occlude velocities in the states in PyBullet (Coumans & Bai, 2016) (namely “-P”). We show the results from the single best variant of our implementation on recurrent model-free RL, the popular recurrent model-free on-policy implementation (PPO-GRU, A2C-GRU) (Kostrikov, 2018), and also model-based method VRM (Han et al., 2020). Note that VRM is around ${ 5 } \mathbf { x }$ slower than ours, so we have to run 0.5M environment steps for it.
420
+
421
+ # E.2 SINGLE FACTOR ANALYSIS ON OUR METHOD
422
+
423
+ Our analysis will focus on ablating the important design decisions: the actor-critic architecture (Arch), the policy input space (Inputs), the underlying model-free RL algorithm (RL), the RNN encoder (Encoder), and the RNN context length (Len). As there are several decision variables in our method, we could only show the results of each variable in the plots by averaging the performance over the other variables, which we call single factor analysis. In this kind of analysis, we can only say one value is better than another in one factor in the average sense (not the maximal sense); therefore it can show the robustness of each factor, but cannot tell the best choices (showed in Sec. 5.1). We show single factor analysis plots in each subarea, namely “Standard” POMDPs (Fig. 12 and Fig. 13), meta RL (Fig. 14), robust RL (Fig. 15), and generalization in RL (Fig. 16).
424
+
425
+ From these plots, we can see that each decision factor can make a difference in some environments. For example, the choice of RL algorithm is crucial in Ant-P (Fig. 12), Cheetah-V (Fig. 13), Wind (Fig. 14) and Hopper-Generalize (Fig. 16). The context length is essential in all the “-P” environments (Fig. 12), Cheetah-Vel (Fig. 14), and both the generalization environments (Fig. 16). The policy input space can make a difference in most “-P” environments (Fig. 12) possibly because oar contains the information of missing velocities.
426
+
427
+ ![](images/9b9ca379534e68d909afc28de5d21154b0d5cd869969737e00fe2763f6376029.jpg)
428
+ Figure 8: Learning curves on “standard” POMDP environments that preserve velocities but occlude positions $\pmb { \& }$ angles in the states in PyBullet (Coumans & Bai, 2016) (namely “-V”). We show the results from the single best variant of our implementation on recurrent model-free RL, the popular recurrent model-free on-policy implementation (PPO-GRU, A2C-GRU) (Kostrikov, 2018), and also model-based method VRM (Han et al., 2020). Note that VRM is around ${ 5 } \mathrm { x }$ slower than ours, so we have to run 0.5M environment steps for it.
429
+
430
+ # E.3 ADDITIONAL RESULTS ON SEPARATE VS SHARED RECURRENT ACTOR-CRITICARCHITECTURE
431
+
432
+ In Fig. 5 of Sec. 5.2, we show the importance of selecting a separate recurrent actor-critic architecture in a meta RL environment, Semi-Circle. Now we show the result in another POMDP environment, Pendulum-V, which occludes the positions and angles, in Fig. 17. We can see that the shared encoder architecture is also worse than the separate one, possibly due to the different gradient scales in actor and critic losses w.r.t. the encoder.
433
+
434
+ # E.4 ADDITIONAL RESULTS ON COMPARISON WITH VRM
435
+
436
+ Both Fig. 1 and Fig. 18 shows the final performance of the same single variant of our implementation, but the former shows our results with 1.5M simulation steps while the latter shows our results with $0 . 5 \mathbf { M }$ simulation steps to match with those of VRM due to the time budget.
437
+
438
+ ![](images/3894fdfca46be8394637e0e88be03a60d4ad34c6d20b7fdc0897c0d605dcfe11.jpg)
439
+ Figure 9: Learning curves on meta RL environments. We show the results from the single best variant of our implementation on recurrent model-free RL, the specialized meta RL method VariBAD (Dorfman et al., 2020)
440
+
441
+ ![](images/dfa7dc791a89631fd6f6bc1cdf6f0871db3745292eea57b55d353289f7d243a6.jpg)
442
+ Figure 10: Learning curves on robust RL environments. We show the average returns (left figures) and worst returns (right figures) from the single best variant of our implementation on recurrent model-free RL, the specialized robust RL method MRPO (Jiang et al., 2021). Note that our method is much slower than MRPO, so we have to run our method within 3M environment steps. But the results show that our method have much better sample efficiency over MRPO.
443
+
444
+ ![](images/66064063e5800389fd2dbd583070929708fb7b1e199ff2798820509b4e39ad54.jpg)
445
+ Figure 11: Learning curves on generalization in RL environments. We show the interpolation success rates (left figures) and extrapolation success rates (right figures) from the single best variant of our implementation on recurrent model-free RL. We also show the final performance of the specialized method EPOpt-PPO-FF (Rajeswaran et al., 2017a) and another recurrent model-free (on-policy) RL method (A2C-RC) copied from the Table 7 & 8 in Packer et al. (2018).
446
+
447
+ ![](images/d9a540b849cdaba473400f6d2b726dee14f5c2a4d5c468fa53d01c31cd5000fa.jpg)
448
+ Figure 12: Ablation study of our implementation on “standard” POMDP environments that preserve positions $\pmb { \& }$ angles but occlude velocities in the states in pybullet (Coumans & Bai, 2016) (namely $\mathbf { \tilde { \Sigma } ^ { 6 6 } - } \mathbf { P } ^ { 9 } \mathbf { \bar { \Sigma } } ,$ ). We show the single factor analysis on the 4 decision factors including RL, Encoder, Len, and Inputs for each environment.
449
+
450
+ ![](images/32445265e20f1f545fd08fe0230bf577d359a0980e43099b5bce76317dc9ecf4.jpg)
451
+ Figure 13: Ablation study of our implementation on “standard” POMDP environments that preserve velocities but occlude positions & angles in the states in pybullet (Coumans & Bai, 2016) (namely “-V”). We show the single factor analysis on the 4 decision factors including RL, Encoder, Len, and Inputs for each environment.
452
+
453
+ ![](images/26813d40fd770010f14b184f9791b978c08ed29426a0c77c554d40a4d575ad91.jpg)
454
+ Figure 14: Ablation study of our implementation on meta RL environments. We show the single factor analysis on covering all the decision factors
455
+
456
+ ![](images/af848a7b1bd8022f0a5a01bf2cddbe2366af14d2091951fb72fcae8b645a9a7b.jpg)
457
+ Figure 15: Ablation study of our implementation on robust RL environments. We show the single factor analysis on the 4 decision factors including RL, Encoder, Len, and Inputs for each environment in both average returns and worst returns.
458
+
459
+ ![](images/fc734dbfd8668706406e93d90ff0fd4650c5d5adff372b1c88b6ff670ae61a5a.jpg)
460
+ Figure 16: Ablation study of our implementation on generalization in RL environments. We show the single factor analysis on the 3 decision factors including RL, Len, and Inputs for each environment in both interpolation and extraploation success rates.
461
+
462
+ ![](images/5ff5f0fcb3a9f61051dd00d39ed12967134c54b38301ce44e33adf4838a9fa2f.jpg)
463
+ Figure 17: Comparison between shared and separate recurrent actor-critic architecture with all the other hyperparameters same, on Pendulum-V, a toy “standard” POMDP environment. We show the performance metric (left) and also the gradient norm of the RNN encoder(s) (right, in log-scale). For the separate architecture, :critic and :actor refer to the separate RNN in critic and actor networks, respectively.
464
+
465
+ ![](images/87a809e96598bc16313fea09489dbdb6bb785477299c66ee97a72274e50173bc.jpg)
466
+ Figure 18: Final normalized returns of our implemented recurrent model-free RL algorithm with the same hyperparameters, and the prior method VRM (Han et al., 2020) across the eight environments in “standard” POMDPs, each of which trained in 0.5M simulation steps.
467
+
468
+ # F ABLATION STUDY ON RNN ARCHITECTURES
469
+
470
+ Our implementation of recurrent model-free RL uses the popular 1-layer LSTM or GRU. To investigate the effect of RNN architecture, we ablate two RNN variants: one is 2-layer stacked LSTM/GRU, the other is Particle-Filter RNN (PF-RNN (Ma et al., 2020a)). PF-RNN maintains a stochastic belief (posterior distribution) through a set of weighted particles to better capture the uncertainty and multi-modality, compared to classic RNN’s deterministic belief. DPFRL (Ma et al., 2020b) applies PF-GRU to POMDP tasks, using the mean of particles and MGF features of particles as the belief state. We follow the implementation of PF-GRU in DPFRL (Ma et al., 2020b) to replace regular GRU, keeping the other model components the same.
471
+
472
+ We try 2-layer LSTM/GRU, on our best variant across all the environments. We run PF-GRU on “standard” POMDP environments where the best variant also uses GRU for fair comparison, and do not try PF-LSTM as it is not adopted in DPFRL (Ma et al., 2020b).
473
+
474
+ Since 2-layer LSTM/GRU doubles the training time of 1-layer LSTM/GRU given the same gradient updating frequency, we have to decrease the frequency from 1.0 to 0.6 in “standard” POMDPs. Similarly, PF-GRU costs $1 5 \times$ than 1-layer GRU, so we also have to decrease the frequency from 1.0 to 0.6. All the other hyperparameters remain the same.
475
+
476
+ ![](images/75896b02d02693733e2773334d33463d9735c1ded84e90b3d11b64954c25f30b.jpg)
477
+ Figs. 19 to 23 show all the learning curves of the ablation study on RNN architectures. Except for rare cases (e.g. Ant-P, Walker-V), the RNN variants perform worse than or are par with 1-layer LSTM/GRU, although in most cases the RNN variants can still outperform the Markovian policies. Possible reasons are that the RNN variants need hyperparameter tuning and more training samples to converge.
478
+ Figure 19: Ablation study on RNN architecture in “standard” POMDPs (“-P”). We show two models that are only different from our best single variant in the RNN architectures, namely using 2-layer stacked GRU (td3-2gru) and PF-GRU (Ma et al., 2020a;b) (td3-pfgru), instead of 1-layer GRU.
479
+
480
+ ![](images/058c7ea47e1c159b6fe098fd66aa4e39e8383fe8a07e5ec40a45895b54c4ebb4.jpg)
481
+ Figure 20: Ablation study on RNN architecture in “standard” POMDPs (“-V”). We show two models that are only different from our best single variant in the RNN architectures, namely using 2-layer stacked GRU (td3-2gru) and PF-GRU (Ma et al., 2020a;b) (td3-pfgru), instead of 1-layer GRU.
482
+
483
+ ![](images/1d04cd47f46e4193da7f651143562f09f9344d1245c759d8448902ccfb028f35.jpg)
484
+ Figure 21: Ablation study on RNN architecture in Meta RL. We show one model that are only different from our best single variant in the RNN architecture, namely using 2-layer stacked LSTM (td3-2lstm), instead of 1-layer LSTM.
485
+
486
+ ![](images/764e5249b62d350489348f58de8742e57e05989fadfe593ce37c71ee8c06e097.jpg)
487
+ Figure 22: Ablation study on RNN architecture in robust RL. We show one model that are only different from our best single variant in the RNN architecture, namely using 2-layer stacked LSTM (td3-2lstm), instead of 1-layer LSTM.
488
+
489
+ ![](images/eb61e0519c56998e2edeb2bb48ea3ac6587ada65032b50129bb78d91c80618ee.jpg)
490
+ Figure 23: Ablation study on RNN architecture in generalization in RL. We show one model that are only different from our best single variant in the RNN architecture, namely using 2-layer stacked LSTM (td3-2lstm), instead of 1-layer LSTM.
491
+
492
+ # G ADDITIONAL RESULTS ON COMPARISON WITH OFF-POLICY VARIBAD
493
+
494
+ In our experiment section (Sec. 5) and Fig. 9, we show the learning curves of our method and our re-implemented off-policy VariBAD (Dorfman et al., 2020). To rule out the possibility of reimplementation bugs in the off-policy VariBAD, we ran the official off-policy VariBAD implementation2, denoted as VariBAD-BOReL.
495
+
496
+ In Fig. 24, we show official off-policy VariBAD (VariBAD-BOReL in short), our re-implemented off-policy VariBAD (VariBAD in short), and one variant of our recurrent model-free RL, which uses the same decision factors as VariBAD-BOReL (SAC as RL algorithm, GRU as encoder, oar as input, 400 as context length) for fair comparison. We also try Ant-Dir from Dorfman et al. (2020) paper, a more challenging meta RL environment than Cheetah-Vel.
497
+
498
+ In Semi-Circle and Wind, VariBAD-BOReL has similar performance as our re-implemented version (VariBAD).
499
+
500
+ In Cheetah-Vel, we find VariBAD-BOReL outperforms our re-implemented version, but still has a gap from what they reported in Fig. 11 in the appendix of Dorfman et al. (2020). Our implementation still outperforms VariBAD-BOReL, supporting our claim in the main paper.
501
+
502
+ Finally, in the newly added and more challenging Ant-Dir, we found our recurrent model-free RL can even greatly surpass Oracle (trained with same environment and gradient steps), while VariBADBOReL somehow has extremely low performance (worse than Random) and suffers from numerical issue to terminate early.
503
+
504
+ ![](images/2bee8e27956779c2058d9477678f8a6064ff9f8f6cd810dfb28714dc2934413c.jpg)
505
+ Figure 24: Additional learning curves on meta RL environments. We show the results from the single variant of our implementation on recurrent model-free RL (sac-gru-oar-400), and the specialized meta RL method off-policy VariBAD (Dorfman et al., 2020) (their official implementation VariBAD-BOReL and our re-implementation VariBAD).
md/dev/F72ximsx7C1/F72ximsx7C1.md ADDED
The diff for this file is too large to render. See raw diff
 
md/dev/G5ADoRKiTyJ/G5ADoRKiTyJ.md ADDED
@@ -0,0 +1,258 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Fine-tuning language models to find agreement among humans with diverse preferences
2
+
3
+ Michiel A. Bakker∗ DeepMind miba@deepmind.com
4
+
5
+ Martin J. Chadwick∗ DeepMind martin@deepmind.com
6
+
7
+ Hannah R. Sheahan∗ DeepMind hsheahan@deepmind.com
8
+
9
+ Michael Henry Tessler DeepMind tesslerm@deepmind.com
10
+
11
+ Lucy Campbell-Gillingham DeepMind lcgillingham@deepmind.com
12
+
13
+ Jan Balaguer
14
+ DeepMind
15
+ jua@deepmind.com
16
+
17
+ Nat McAleese DeepMind nmca@deepmind.com
18
+
19
+ Amelia Glaese DeepMind glamia@deepmind.com
20
+
21
+ John Aslanides DeepMind jaslanides@deepmind.com
22
+
23
+ Matthew M. Botvinick DeepMind University College London botvinick@deepmind.com
24
+
25
+ Christopher Summerfield DeepMind University of Oxford csummerfield@deepmind.com
26
+
27
+ # Abstract
28
+
29
+ Recent work in large language modeling (LLMs) has used fine-tuning to align outputs with the preferences of a prototypical user. This work assumes that human preferences are static and homogeneous across individuals, so that aligning to a a single “generic” user will confer more general alignment. Here, we embrace the heterogeneity of human preferences to consider a different challenge: how might a machine help people with diverse views find agreement? We fine-tune a 70 billion parameter LLM to generate statements that maximize the expected approval for a group of people with potentially diverse opinions. Human participants provide written opinions on thousands of questions touching on moral and political issues (e.g., “should we raise taxes on the rich?”), and rate the LLM’s generated candidate consensus statements for agreement and quality. A reward model is then trained to predict individual preferences, enabling it to quantify and rank consensus statements in terms of their appeal to the overall group, defined according to different aggregation (social welfare) functions. The model produces consensus statements that are preferred by human users over those from prompted LLMs $( > 7 0 \% )$ and significantly outperforms a tight fine-tuned baseline that lacks the final ranking step. Further, our best model’s consensus statements are preferred over the best human-generated opinions $( > 6 5 \%$ ). We find that when we silently constructed consensus statements from only a subset of group members, those who were excluded were more likely to dissent, revealing the sensitivity of the consensus to individual contributions. These results highlight the potential to use LLMs to help groups of humans align their values with one another.
30
+
31
+ # 1 Introduction
32
+
33
+ Modern large-scale transformer-based language models have revolutionized the capacity of AI systems to perform complex natural language processing tasks including reading comprehension, common sense reasoning, and fluent language generation [8, 27, 11, 17]. A key challenge in language modelling is to ensure that the generated text is helpful, legitimate, and aligned with human values [20, 34, 4, 14]. One popular approach is to recruit human participants to rate or compare candidate model outputs, providing feedback to the model about its performance on tasks like summarisation, instruction-following, and question answering [5, 26, 30, 37, 23, 15]. For large models, this approach improves performance on datasets specifically designed to test alignment (e.g., the HHH dataset), without decreasing their overall language competencies [4].
34
+
35
+ Though powerful and general, extant methods for fine-tuning language models from human preferences treat these preferences as if they were homogeneous and static. This assumption is reasonable for a task such as article summarisation, where there is an objectively defined ground truth (i.e., facts in the article that the model must summarise). However, for a wide variety of social problems that humans solve themselves using language (e.g., social coordination and group decision making), we cannot assume that people all share the same values. A key case study in alignment of diverse preferences is consensus formation. Consensus is commonly defined as the agreement of a large fraction of a social group about a particular topic or course of action. It is both a prerequisite for cooperation and a key pillar of the democratic process. Finding consensus for humans is not easy, and technology often exacerbates political division rather than fostering reconciliation among those with divergent opinions [3]. Large language models achieve surprising fluency and sensitivity to homogeneous preferences, but their ability to help people find agreement has not yet been tested.
36
+
37
+ Here, we investigate the use of large language models (LLMs) to aid humans in collectively producing written opinions that maximize approval rates among users. Specifically, we create a corpus of thousands of questions concerning political issues relevant in the United Kingdom, about which reasonable, well-informed people might legitimately disagree (for example, “Should we tax unhealthy foods and sugary drinks?”, or “Should we re-nationalise the railways?”). We recruit groups of human participants to write out their opinions about these questions. We then fine-tune a 70 billion parameter language model (Chinchilla [17]) to produce candidate consensus statements that small groups of participants would be likely to endorse (see Table 1), guided by an underlying family of social welfare functions. Critically, in our work, the language model is not trained to adopt a particular opinion or persuade others of any one view. Rather, it is trained to produce consensus candidates based on the opinions contributed by the human group. We find that our particular data collection and training pipeline results in a model that generates statements that are preferred more strongly than a number of high-performing baselines, including individual human opinions. The statements generated by the model reflect the underlying opinions that are contributed by the users. This work opens up new possibilities for LLMs to help people find common ground in service of collective decision making.
38
+
39
+ # 2 Related Work
40
+
41
+ Aligning LLMs with human preferences. Several papers have reported the successful training of AI systems directly from human preferences (e.g., training deep RL agents to play Atari [12, 18]). In the domain of language modelling, human preferences have been used to fine-tune models to perform specific tasks, such as summarisation or translation [37, 30, 5], to provide inline citations supporting their claims [25, 23, 32], or for generic instruction following [26]. Our pipeline shares several design similarities with these works (e.g., the reward modelling approach). A key point of distinction, however, stems from the source of legitimacy in which statements produced by the language model are ostensibly grounded. For these related works, external sources that are generally agreed to be truthful and unbiased are the source of legitimacy. In our work, by contrast, we optimise, through a combination of opinion-conditional reward modelling and group-level welfare maximisation, to produce statements that will generate agreement for a specific group.
42
+
43
+ Summarization. Our work builds upon attempts to build natural language processing models to provide high-quality summaries of text (e.g., [10, 29]). These efforts have redoubled recently with the advent of LLMs [37, 30, 27]. Like consensus opinions, good summaries should be concise, informative and balanced passages of text. However, summaries and consensuses differ in their grounding: good summaries are based on accurate, fact-based information about the world (for which a single viewpoint is typically accepted) whereas a consensus is grounded in the opinions of the specific individuals in a group seeking to achieve agreement. Our work specifically builds on work in opinion summarisation, in which subjective opinions (typically reviews about products, restaurants, or movies) are summarized into a kind of meta-review (e.g., [1, 31]). While similar in spirit to our work on consensus generation, extant work in opinion summarisation falls short of using actual human feedback and does not verify generated summarisations with the same individuals who provided their opinions, instead focusing on third-party evaluations (e.g., does this summary make sense in light of these opinions?). By not engaging with the people that provided the original opinions, these projects do not pertain to alignment problems but instead are closer to other summarisation work.
44
+
45
+ Table 1: A candidate consensus statement generated by our SFT-Utilitarian model in response to a question and corresponding opinions from the test set. The example was chosen randomly from a set of consensus statements that included 3 opinions and that was in response to a divisive question (i.e., questions for which there was some disagreement). Other examples can be found in the Tables A6-7.
46
+
47
+ <table><tr><td>Question</td><td>Should we lower the speed limit on roads?</td></tr><tr><td>Opinion 1 participant</td><td>The higher speed limits are ok and need no change. Some of the lower limits,like 30mph in built up areas,should be reduced and better enforced to reduce accidents.Allin all the higher limits would not have much impact if reduced.</td></tr><tr><td>Opinion 2 participant</td><td>Yes.Driving faster causes higher pollution and does not significantly shorten the average length of journeys. It would increase the fuel efficiency of those driving and prevent the distribution of microscopic particles of rubber from tyre wear into the environment. The number of road fatalities would reduce too.</td></tr><tr><td>Opinion 3 participant</td><td>I think the speed limits are mainly fine the way they are.In our area speed limits are reduced around busy areas such as schools and parks which is a good thing.</td></tr><tr><td>Consensus SFT-Utilitarian</td><td>We believe that speed limits are currently appropriate.However, we feel that there is a need to enforce speed limits more strictly,particularly in areas with a high density of pedestrians such as near schools.We also feel that there is a need to educate people more about the effects of driving too fast, such as the effects on fuel efficiency and pollution.</td></tr></table>
48
+
49
+ Collective Reasoning. Our work is relevant to a fast-growing interest in the use of technology, including machine learning methods, to promote human collective reason, including democratic deliberation [21, 13]. More traditional ML approaches (e.g., data/opinion mining) make use of richly structured (e.g., graph-based) models to make sense of public discussions [36] and to facilitate interactions in online communities [16]. We seek to leverage recent breakthroughs in large-scale language modelling to facilitate public deliberation via consensus generation.
50
+
51
+ # 3 Methods
52
+
53
+ We created a large data set of debate questions and built a customized environment and pipeline that allowed us to collect human opinions and fine-tune our models in an iterative loop (Figure 1).
54
+
55
+ # 3.1 Generating debate questions
56
+
57
+ We generate questions using a prompted, 70 billion parameter pre-trained LLM (Chinchilla [17]). We seeded the process with 152 hand-written questions on issues of contemporary debate. Most were policy questions of the form "Should we...?" or "Should the government...?" that are relevant for the UK-based participants that took part in our human evaluation. We use these 152 seed questions to artificially generate a total of 3500 debate questions. For each debate question, we prompt Chinchilla with a sample of 10 seed questions. The model generates a new question, which, if unique, we add to our total set. We manually check questions and filter out any that we consider likely to elicit extremist views or discriminatory language from the users.
58
+
59
+ This results in 2922 questions which we use to create a training set and two test question sets by clustering according to topic. We first embed each question using a Universal Sentence Encoder and cluster the questions into 110 topics using $\mathbf { k }$ -means clustering [9]. There is, for example, a cluster of 25 questions that corresponds to questions on food taxes such as “Should there be a tax on junk food?”
60
+
61
+ ![](images/5898ad5899d0fb9f9120d7558097dfa9df63277b66303974bee0c37a966f16e3.jpg)
62
+ Figure 1: Overview of the data collection procedure. The evaluation pipeline proceeded in six steps. (1) Human participants, sorted into small groups $( n \in \{ 3 , 4 , 5 \} )$ ), each wrote a short paragraph stating their opinion about a political question (e.g., “should we lower the speed limit on roads?”). (2) These opinions, together with the question, were passed to a prompted pre-trained LLM (or, a fine-tuned LLM on later rounds) via the prompt, which generated consensus candidates. (3) Pairs of participant opinions and candidate consensus statements were passed into a reward model, which estimated the degree to which each participant would agree with a candidate consensus. (4) For each consensus candidate, the set of predicted individual preferences were aggregated with a social welfare function. (5) From a batch of consensus candidates, the one that maximised welfare was selected for human evaluation. (6) Participants then rated this consensus candidate, together with candidates generated in other batches or conditions, on a 7-point agreement scale. Quality ratings were used to filter the data for later fine-tuning and agreement ratings for training the reward model and for evaluation.
63
+
64
+ and “Should we remove all tax on food and groceries?”. We then split the clusters into two groups, and set some question-clusters aside for an out-of-distribution hold out set $\mathrm { ( n = } 3 0 2 \mathrm { ) }$ ). The remaining questions were sorted into a training $\mathbf { \tilde { n } } = 2 3 2 0$ questions) and a within-distribution hold out set $\mathbf { \tilde { n } = }$ 300). See Appendix A for more information on question generation, filtering and clustering.
65
+
66
+ # 3.2 Data collection and environment design
67
+
68
+ On each round, groups of UK-based participants $\overset { \prime } { n } = 3 2 1 1$ organized into 746 groups, combined across training and eval) viewed a question, and wrote their opinion by typing freely into a text box in our custom online application. The opinions of a group were put into a prompt that was provided to one or more LLMs to generate candidate consensus statements. Data was collected using groups of four or five participants, though candidate consensus statements were sometimes generated based on a subset of participants’ opinions (Section 4.3). Consensus candidates were then presented individually to participants in a random order, and each participant rated them along two dimensions, quality and agreement, using 7-point Likert scales. Participants rated all candidate consensus statements twice, to allow us to measure intra-rater reliability.
69
+
70
+ Additionally, before providing their own opinion or viewing candidate consensus statements, participants provided an agreement rating on a ”position statement”, which is a version of the question stated declaratively (e.g., “We should...”). This allowed us to measure baseline disagreement among the group. Each training or evaluation session took between 45 minutes and an hour. As our explicit goal is to train and evaluate on diverse opinions, we recruited a new set of participants for each data collection session, rather than use the same participants repeatedly. The full details of our study design, including compensation rates, were reviewed by our independent ethical review committee. All participants provided informed consent prior to completing tasks and were reimbursed for their time. It is our policy that researchers must pay workers/participants at least the living wage for their location. For this study participants were paid an average compensation rate of £15 per hour (the total cost of the study was approximately £46,000). No personally identifiable information was collected as part of this research, nor was any offensive content shown to participants. More detail on the environmental design and the recruiting and training processes can be found in Appendix B.
71
+
72
+ # 3.3 Group alignment
73
+
74
+ In line with previous work [37, 30, 26], we use reward models to predict whether generated statements will be preferred by participants. Given our focus on diverse preferences, we train a reward model that predicts agreement conditional on a person’s own opinion. Given a group of people with corresponding opinions, we can then use this model to generate, for each person, a score that predicts how likely they are to agree with a given statement.
75
+
76
+ Having estimated each individual’s expected agreement, we aggregate these scores to predict the extent to which a candidate consensus will be preferred by the group. For simplicity, we assume that preferences are cardinal and comparable between participants, and we aggregate them using a cardinal Social Welfare Function (SWF). SWFs are used in the field of welfare economics to map a set of numeric individual utitilities to collective welfare [19]. The goal of the model is then to generate a consensus that maximizes the group welfare given the set of opinions from the group. Any SWF that satisfies six desirable axioms belongs to a one-parameter family of isoelastic social welfare functions [24]
77
+
78
+ $$
79
+ W _ { \alpha } ( u _ { 1 } , \dots , u _ { n } ) = \left\{ \begin{array} { l l } { \left[ \frac { 1 } { n } \sum _ { i = 1 } ^ { n } u _ { i } ^ { 1 - \alpha } \right] ^ { \frac { 1 } { 1 - \alpha } } } & { \mathrm { i f } \alpha \ge 0 , \alpha \ne 1 } \\ { \sqrt [ n ] { \prod _ { i = 1 } ^ { n } u _ { i } } } & { \mathrm { i f } \alpha = 1 } \end{array} \right.
80
+ $$
81
+
82
+ where $u _ { i }$ is the utility of person $i$ and $\alpha$ is the degree of inequality aversion. At one extreme, for $\alpha = 0$ , the SWF corresponds to max-mean or Utilitarian, which computes the mean expected agreement across the group. On the other extreme, for $\alpha = \infty$ , the SWF corresponds to max-min or Rawlsian, which maximises the expected agreement for the most dissenting group member. Rawls argued in favour of the welfare function that yields the most desirable condition for the worst-off member of the group [28]. In the Results section we use a Utilitarian social welfare function for ease of interpretation but we present results on Rawlsian and Bernoulli-Nash (max-product, $\alpha = 1$ ), in Appendix D.5.
83
+
84
+ # 3.4 Training
85
+
86
+ Our training pipeline largely follows previous reports that use human feedback to fine-tune large language models [37].2 Thus, we use a supervised fine-tuned LLM to generate $N$ consensus candidates $N = 1 6$ ), which are then reranked by a reward model according to their expected social welfare. We then select the statement that maximizes the welfare. We denote these models SFT- $\ @ \mathrm { S W F }$ where $\ @ \mathrm { S W F }$ corresponds to welfare function.
87
+
88
+ The reranking approach gives us flexibility over the social welfare function during deployment.3 To ensure that the model generalizes to different social welfare functions on the Utilitarian-Rawlsian axis, we sample the inequality aversion parameter $\alpha$ during training time from a log-normal distribution. During training, we start with the 70 billion parameter pretrained Chinchilla model and iterate twice over the following training steps before evaluating our final models.
89
+
90
+ Step 1 - Generate consensus candidates and have them rated by humans Participants provide written opinions in response to a question. The fine-tuned language model takes in the question and these opinions as part of its prompt and generates a set of consensus candidates (on the first iteration, we bootstrap first with zero-shot prompting and then with few-shot prompting of the base Chinchilla model). To ensure that our dataset contains data on a variable number of opinions (between 3 and 5), each time a statement was generated we silently omitted 0, 1, or 2 of the participants’ opinions. For each unique number of opinions, we generate 16 candidates and select 2, each of which is ranked top-1 under a different $\alpha$ . These 6 (3x2) highest ranked consensuses are then presented to participants who rate them for quality and agreement using two 7-point Likert scales. Note that, on the first iteration, we have no reward model for the reranking and selection scheme and thus simply generate 2 candidates for each unique set of opinions. Across all training data collection runs, 1524 participants contributed to our training data. See Appendix B.1 for more details.
91
+
92
+ Step 2 - Supervised fine-tuning (SFT) to improve quality We fine-tune a pretrained Chinchilla model on the consensus candidates that were rated as high quality (mean quality of 6 or higher on a 7-point Likert scale). The purpose of SFT is to familiarize the model with the prompt template and increase the candidate quality. We do not use agreement ratings to filter candidates as we aim to retain diversity in the kinds of stances expressed in the candidates so we can then use reranking to find the best candidate in terms of welfare4. SFT training details including the prompt template and hyperparameters can be found in Appendix C.1.2.
93
+
94
+ Step 3 - Train a reward model (RM) to predict preferences We train an RM to take in a question, opinion and a statement, and output a scalar "agreement" score. The score is a proxy for how likely an individual is to agree with a statement given their own opinion. To provide data for model training, each participant rates the six consensus candidates along a 7-point Likert score. Note that, as we generate candidates based on 3, 4, and 5 opinions, participants also rate candidates that were generated without taking their opinion into account. We map these six ratings to $\binom { 6 } { 2 }$ pairwise comparisons, remove the rating ties, and remove ratings from participants with low intra-rater reliability (see Appendix B.2.1). The RM is then trained to predict which statement out of a pair each user will prefer, conditional on the question and opinion, using standard cross-entropy loss. Note that the RM only conditions on one opinion, while the SFT conditions on all opinions. We warm-start the RM using a pretrained Chinchilla model and add an extra final linear layer to predict the reward. The prompt template and further training details can be found in Appendix C.2. After training the reward model, we go back to step 1.
95
+
96
+ # 4 Results
97
+
98
+ We ran two human evaluations, comparing our model against both high-quality baselines and humangenerated opinions. These evaluations used the same data collection platform and basic design (see Section 3.2) and were run in separate sessions using the within-distribution questions and out-ofdistribution questions. We ran an additional evaluation experiment to assess the model’s sensitivity to different social welfare functions, but this did not reveal any reliable differences in the average or minimum agreement rating under any of the welfare functions of theoretical interest (we discuss this null result further in Appendix D.5).
99
+
100
+ # 4.1 Preferences for consensus over baselines
101
+
102
+ We first test our main model against a set of high-quality baseline models. Our main model (SFTUtilitarian) generates statements using a 70 billion parameter language model fine-tuned on high quality consensus statements. At inference time, we sample 16 statements based on the question and opinions provided, and select the statement that maximizes predicted welfare under a Utilitarian (max-mean) aggregation function. The baseline models are:
103
+
104
+ • SFT-Base. Our fine-tuned model but without the aggregation function selection process, sampling only one statement at inference time.
105
+ • Few-shot. A few-shot prompted Chinchilla model. Each prompt contains three real examples composed of consensus statements with three, four and five opinions. Each set of examples is sampled from data collected using a zero-shot model, using a combination of quality and agreement criterion (see Appendix C.1.1 for more details).
106
+ • Zero-shot A prompted Chinchilla model without examples.
107
+
108
+ Under each of the four model types, we generated two different candidates, all of which were presented to the participants for rating. In these evaluations against baseline models we examine and compare performance of the model under within-distribution questions (collected using groups of five participants; total $n = 5 3 0$ ), and out-of-distribution questions (collected using groups of four participants; total $n = 2 6 7$ ).
109
+
110
+ ![](images/421b2125454b46839c3502d875080646190141840407818124d78850a73402b9.jpg)
111
+ Figure 2: Win rates for comparing models constructed by pairwise comparison of Likert agreement ratings for candidate consensus statements (excluding ties) for within-distribution (blue) and out-ofdistribution (green) question sets. Likert agreement ratings are aggregated within groups by either the mean (dark bars) or the minimum (light bars) agreement score. A: Win-rates for the SFT-Utilitarian model in comparison to baselines. B: Win-rates for the SFT-Utilitarian model broken down by whether or not the question was divisive in the group (see main text for details). Error-bars represent $9 5 \%$ bootstrapped confidence intervals.
112
+
113
+ We found that the position statements on approximately $50 \%$ of rounds (questions addressed by particular groups) were undivisive (receiving either all agreement or all disagreement from the group, when examined in a binary fashion; see Appendix D.6); we perform a split of the dataset into divisive and undivisive questions for further analysis. Notably, the fact that $50 \%$ of questions contained at least one dissenting participant (out of a group of up to five people) indicates that our population of participants do indeed have divergent opinions on many topics.
114
+
115
+ We first compare how likely a group is to prefer one policy over another. We do so using two metrics: the mean agreement across the group (consistent with the Utilitarian training objective of the model) and the minimum agreement in the group (consistent with a Rawlsian objective, not explicitly used in the model).5 We compute these metrics for each statement and take the mean metric value across the statements generated under the same policy. To compute the win-rate, we compare these mean scores between two policies where the "winning" policy is the one with higher score. Under the group-mean agreement score, participants significantly prefer our main SFT-Utilitarian model over all of the baselines (Figure 2A), and strongly so in comparison to the two prompted LLMs. Even more impressive, participants prefer the SFT-Utilitarian model over all baselines for the group-minimum agreement score (a Rawlsian objective), indicating that our model is also more adept at increasing agreement among the strongest dissenters. Furthermore, we see the human preference for our model’s consensus statements is present for both more and less divisive questions (Figure 2B), highlighting the model’s utility in helping people find agreement even where opinions are divided.
116
+
117
+ In addition to the main baseline model comparisons detailed here, we also compared our main model against a smaller 1.4B parameter model $n = 2 2 4$ ). We found that training a smaller model with data generated from the larger model can be effective, as the SFT-Utilitarian-1.4B outperforms the larger prompted models. However, the larger SFT-Utilitarian-70B is still superior, indicating that fine-tuning and size are both additive in this task. See Appendix D.1 for full details.
118
+
119
+ ![](images/16cab3b4d9f09a43942ff74311188ce443cdfe0bf62924537ab97e49a80afd82.jpg)
120
+ Figure 3: Distributions over Likert ratings for candidate consensus statements generated by the SFT-Utilitarian model and baseline models. A: Agreement ratings. B: Quality ratings. Error-bars represent $9 5 \%$ bootstrapped confidence intervals. See Figure A11 for agreement scores broken down by question divisiveness.
121
+
122
+ To further assess the reliability of the human preference for our SFT-Utilitarian model’s consensus generations over those of the ablated models, we constructed a maximal mixed-effects logistic generalized linear regression model [22], the standard in confirmatory hypothesis testing [6]. Consistent with our win-rate analysis, we found that participants agreed more strongly with the consensus candidates generated by the SFT-Utilitarian model than those generated by the SFT-Base $\beta = 0 . 1 2$ ; $\mathrm { S E = 0 . 0 4 7 }$ ; $z = 2 . 5 3$ ; $p = 0 . 0 1 1$ ; Figure 3A). Under this analysis, participants also preferred the SFT-Base’s generations more so than those of the few-shot model $\beta = 0 . 4 0$ ; $\mathrm { S E = 0 . 0 5 5 }$ ; $z = 7 . 3 5$ ; $p < 0 . 0 0 1 )$ , but exhibited no preference for the few-shot model over the zero-shot model $\beta = 0 . 0 5$ ; $\mathrm { S E = 0 . 0 6 }$ ; $z = 0 . 8 8$ ; $p = 0 . 3 4 ,$ ). We observe that the quality of the model-generated statements also increases as a function of our training pipeline, with both supervised fine-tuning and reward modelling impacting participants’ quality ratings (Figure 3B).
123
+
124
+ To assess the performance of the SFT-Utilitarian model in more absolute terms, we examined the data for the approximately $50 \%$ of rounds in which participants were on different sides of a position statement (i.e., the divisive rounds). We found that, on these divisive rounds, $6 5 . 6 \%$ [61.9, 69.3] of candidates generated by the SFT-Utilitarian model were less divisive than the initial position statements. Furthermore, on $4 0 . 8 \%$ [35.4, 46.2] of rounds with a divisive position statement, a candidate consensus statement from the SFT-Utilitarian model achieved unanimous support (i.e., all participants somewhat agreed with the statement; see Appendix D.7 for full results and details). These results demonstrate not only that human participants preferred the consensus candidates generated by the SFT-Utilitarian model over those of the ablated models, but that the SFT-Utilitarian is demonstrably effective at helping a group of people with diverse preferences find points of agreement.
125
+
126
+ # 4.2 Preferences for model candidates over human opinions
127
+
128
+ Here we compare the performance of our SFT-Utilitarian model against human-generated opinions. While the human opinions are not explicitly written with consensus in mind, the opinions are very high-quality, frequently containing well-reasoned justifications for their positions (see Tables A6-7 for examples). Data was collected using groups of four participants ( $n = 1 8 9$ for within-distribution questions, $n = 1 8 6$ for out-of-distribution questions). As with our previous evaluations, each participant wrote an opinion in response to the question, and these opinions were used to generate three candidates with our SFT-Utilitarian model. The same participants were then shown these model-generated consensus candidates alongside the (anonymous) opinions of the other participants in their group. All participants rated both the consensus candidates and the opinions.
129
+
130
+ We perform two analyses: for each participant, we compare their mean agreement over the set of other participants’ opinions to their mean agreement over the set of model candidates; we also compare their most preferred other opinion to their most preferred candidate. We then compute the win rates over all participants and questions for each of these two metrics separately. The mean candidate score is preferred over the mean opinion score $7 8 \%$ ( $9 5 \%$ -bootstrapped CI: $[ 7 5 \%$ , $8 0 \%$ ) of the time. Perhaps more impressively given the potential variance across the different opinions, even when we select the best-rated opinion, we find that our best-rated model candidate is still preferred $6 5 \% [ 6 1 \% , 6 9 \% ]$ of the time. Finally, we find that this difference in preference is larger for more divisive questions (win-rate of $6 6 \% [ \dot { 6 } 1 \% , 7 1 \% ] ,$ ) than for less divisive questions (win-rate of $6 3 \% [ 5 7 \% , 6 9 \% ] \mathrm { , }$ .
131
+
132
+ # 4.3 Opinion exclusion analysis
133
+
134
+ Our model’s ability to generate statements that provoke higher agreement could be achieved by generating statements that are more likely to be preferred in general but not tailored to the specific set of opinions of the small group. In order to assess this potential failure mode, we make use of the fact that our main evaluation dataset contains candidates that are based on subsets of opinions (3 or 4) from the full set of five provided by the participant group. If the model is making use of the specific opinions passed into it, then the agreement rates from participants whose opinions are excluded from the candidate generation process should be lower than those whose opinions are included. For each candidate in our evaluation set where fewer than 5 opinions were included, we compute the difference in median agreement between the inclusion group and the exclusion group. This analysis reveals an average inclusion/exclusion Likert agreement difference of 0.47 $\mathrm { ( C I = [ 0 . 2 1 , 0 . 7 3 ] ) }$ for our SFT-Utilitarian model. Quality ratings, by contrast, are not impacted by opinion exclusion $( \mathrm { M e a n } { = } 0 . 1 0$ , $\mathrm { C I } = \left[ - 0 . 0 5 , 0 . 2 5 \right] )$ , and the difference between quality and agreement scores under this exclusion analysis is statistically significant $( t = 2 . 9 4 , p = 0 . 0 0 3 6 )$ . This dissociation supports the conclusion that our model is successfully producing consensus candidates based on the specific set of opinions provided by the users, rather than producing generically preferred statements.
135
+
136
+ # 4.4 Out-of-distribution generalisation
137
+
138
+ So far, our evaluations are based on a question set that was unseen during training but that came from the same topic clusters of questions that were used during training. Next, we run separate human baseline experiments using the out-of-distribution question dataset, which has been specifically created so that the questions came from topic-space clusters that were never seen by our models during training. Despite the topic novelty, we find that that the SFT-Utilitarian model’s statements are preferred over all baselines to a degree that is numerically similar to that for the within-distribution questions (Figure 2). SFT-Utilitarian model also continues to outperform the human opinions in the out-of-distribution question set at similar rates to the within-distribution question (mean candidate vs. mean human opinion: $76 \%$ $[ 7 4 \% , 7 9 \% ]$ ; max candidate vs. max human opinion: $5 9 . 5 \%$ $[ 5 6 \% , 6 3 \% ] ,$ ). Overall, this additional set of evaluations demonstrates the capability of our model to generalize beyond its training distribution without apparent loss of performance.
139
+
140
+ # 5 Discussion
141
+
142
+ We fine-tune an LLM to take in a question and the written opinions of a human group, and generate a statement that maximises the agreement of that group. This work opens up new avenues for language modelling in which the goal is to accommodate a set of diverse preferences.
143
+
144
+ # 5.1 Limitations
145
+
146
+ What makes a good consensus? Consensus statements generated by our model are rated more highly than those produced under rival methods, including one baseline (SFT-Base) that mimics our approach in every respect, omitting only the reranking step. Moreover, the model is sensitive to the specific opinions provided in the prompt, because auxiliary analyses show that excluded participants offer lower agreement but similar quality ratings. However, we do not know exactly why the statements are preferred. In particular, SFT-Utilitarian also receives a higher number of “excellent quality” ratings (see Figure 3B) raising the possibility that its statements (whist tailored to the group) are also more generally sensible or well-written. Alternatively, people may use "quality" as a proxy for agreement, raising the additional risk that more confident or authoritative users will wield more influence over the consensus, potentially exacerbating power imbalances between different social groups.
147
+
148
+ Social Welfare Functions. We train the model under a distribution of SWFs. In the Results section we show that reranking statements using a Utilitarian aggregation function generates consensus statements that already take into account both minority and majority views (improving both the min and mean rating over baselines). Hence, when we compare the Utilitarian SWF to other more equitable welfare functions like Rawlsian and Bernoulli-Nash, we do not observe meaningful differences in the mean ratings across participants or that of the most dissenting (min) participant. We thus cannot conclude based on these results alone that aggregating using different SWFs actually results in different behavior. We report these results in Appendix D.5.
149
+
150
+ Data collection We collect human data from a crowd-sourcing platform. Because the debate questions are relevant to UK current affairs, we limit inclusion to UK participants. However, this curtails the diversity in our participant cohort, and limits the generalisability of our findings. It also raises the risk that consensus statements may unduly reflect the views or biases of the participant demographic that we have sampled, in addition to any biases that may arise during pretraining [34, 7]. We note that the benefits of our model are most pronounced at the upper end of the Likert scale, perhaps because homogeneity in our sample inflates baseline levels of agreement. We are developing additional recruitment methods to allow us to sample a more diverse group of people for future experiments.
151
+
152
+ Scale We limit data collection to small groups of four or five people. This choice is in part because of the technical limitation imposed by the prompt length of the model, which can handle only a handful of written opinions. There may, however, be important future use cases where aggregating over many thousands of opinions is necessary, requiring an architecture that is scale invariant. One approach that could be fruitful is to map each opinion to an embedding and then aggregate those embeddings directly. Related examples include the attention-based architecture in [33] or the recursive approach developed for summarizing books in [35].
153
+
154
+ # 5.2 Broader Impacts
155
+
156
+ Misuse for persuasion We did not train the language model to adopt a particular position or persuade others of a specific political view. Nevertheless, there is a risk that LLMs can be used for human persuasion, posing a risk in political discourse, the media, or in advertising. Political debate is already increasingly polarised, especially in Western societies. A system that is capable of persuading others to adopt a particular viewpoint could learn to present arguments in a manipulative or coercive manner, and mitigations for these potential harms play an important part in any research addressing this topic.
157
+
158
+ Factuality The language model we describe is not specifically fine-tuned to produce consensus opinions that are factually accurate. Thus, whilst manual review of consensus statements suggested that they were broadly accurate, there exists a risk that the consensus opinions that it produces could be misleading or contain false information.
159
+
160
+ Misrepresentation of consensus Our work describes an AI that helps people find agreement in natural language. However, the consensus statement might not reflect the views of all the users. This raises important questions about how such a consensus is used. For example, a consensus might be presented as reflecting a unanimous view, misrepresenting the minority opinion, or use the consensus statement to justify otherwise unwarranted courses of action. It is important that users understand these caveats when interpreting the consensus.
161
+
162
+ Opportunities Nevertheless, despite these acknowledged risks, our research was conducted with societal benefit firmly in mind. The ultimate goal of our work is to provide a tool that can be used safely to help people find agreement. We focus on opinions about debate questions, but we can envisage a wider set of use cases, such as aggregation of online reviews into more helpful metareviews, systems for collective writing that automatically takes the preferences of different authors into account, and systems for collective decision making for organised groups. However, we note that considerable work is needed to understand the potential risks associated with AI consensus generation, and to find ways to ensure that model outputs are generated in a transparent and explainable way, before any such system can be deployed.
163
+
164
+ # Acknowledgements
165
+
166
+ We would first like to thank the human participants, whose high-quality opinions and ratings allowed us to train and evaluate our models. We would also like to thank Jonathan Uesato and Fan Yang for help with the LM infrastructure, Sarah Henderson, Richard Ives, Antonia Paterson and Jacklynn Stott for operational support, and Iason Gabriel, Will Hawkins, Geoffrey Irving, Raphael Koster, Angeliki Lazaridou, and Boxi Wu for helpful comments and suggestions.
167
+
168
+ References
169
+ [1] Reinald Kim Amplayo and Mirella Lapata. Informative and controllable opinion summarization. arXiv preprint arXiv:1909.02322, 2019.
170
+ [2] Thomas Anthony, Zheng Tian, and David Barber. Thinking fast and slow with deep learning and tree search. Advances in Neural Information Processing Systems, 30, 2017.
171
+ [3] Sinan Aral. Hype Machine. HarperCollins, 2020.
172
+ [4] 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.
173
+ [5] Yuntao Bai, Andy Jones, Kamal Ndousse, Amanda Askell, Anna Chen, Nova DasSarma, Dawn Drain, Stanislav Fort, Deep Ganguli, Tom Henighan, et al. Training a helpful and harmless assistant with reinforcement learning from human feedback. arXiv preprint arXiv:2204.05862, 2022.
174
+ [6] Dale J Barr, Roger Levy, Christoph Scheepers, and Harry J Tily. Random effects structure for confirmatory hypothesis testing: Keep it maximal. Journal of memory and language, 68(3):255–278, 2013.
175
+ [7] Emily M Bender, Timnit Gebru, Angelina McMillan-Major, and Shmargaret Shmitchell. On the dangers of stochastic parrots: Can language models be too big?. In Proceedings of the 2021 ACM Conference on Fairness, Accountability, and Transparency, pages 610–623, 2021.
176
+ [8] 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.
177
+ [9] Daniel Cer, Yinfei Yang, Sheng-yi Kong, Nan Hua, Nicole Limtiaco, Rhomni St John, Noah Constant, Mario Guajardo-Cespedes, Steve Yuan, Chris Tar, et al. Universal sentence encoder. arXiv preprint arXiv:1803.11175, 2018.
178
+ [10] Sumit Chopra, Michael Auli, and Alexander M Rush. Abstractive sentence summarization with attentive recurrent neural networks. In Proceedings of the 2016 conference of the North American chapter of the association for computational linguistics: human language technologies, pages 93–98, 2016.
179
+ [11] 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.
180
+ [12] Paul F Christiano, Jan Leike, Tom Brown, Miljan Martic, Shane Legg, and Dario Amodei. Deep reinforcement learning from human preferences. Advances in neural information processing systems, 30, 2017.
181
+ [13] James Fishkin. When the people speak: Deliberative democracy and public consultation. Oup Oxford, 2009.
182
+ [14] Iason Gabriel. Artificial intelligence, values, and alignment. Minds and machines, 30(3):411– 437, 2020.
183
+ [15] Amelia Glaese, Nathan McAleese, Maja Trkebacz, John Aslanides, Vlad Firoiu, Timo Ewalds, Maribeth Rauh, Laura Weidinger, Martin Chadwick, Phoebe Thacker, Lucy CampbellGillingham, Jonathan Uesato, Po-Sen Huang, Ramona Comanescu, Fan Yang, A. See, Sumanth Dathathri, Rory Greig, Charlie Chen, Doug Fritz, Jaume Sanchez Elias, Richard Green, Sovna Mokr’a, Nicholas Fernando, Boxi Wu, Rachel Foley, Susannah Young, Iason Gabriel, William S. Isaac, John F. J. Mellor, Demis Hassabis, Koray Kavukcuoglu, Lisa Anne Hendricks, and Geoffrey Irving. Improving alignment of dialogue agents via targeted human judgements. 2022.
184
+ [16] Wen Gu, Ahmed Moustafa, Takayuki Ito, Minjie Zhang, and Chunsheng Yang. A case-based reasoning approach for supporting facilitation in online discussions. Group Decision and Negotiation, 30(3):719–742, 2021.
185
+
186
+ [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.
187
+
188
+ [18] Borja Ibarz, Jan Leike, Tobias Pohlen, Geoffrey Irving, Shane Legg, and Dario Amodei. Reward learning from human preferences and demonstrations in atari. Advances in neural information processing systems, 31, 2018.
189
+
190
+ [19] Ralph L Keeney and Craig W Kirkwood. Group decision making using cardinal social welfare functions. Management Science, 22(4):430–437, 1975.
191
+
192
+ [20] Zachary Kenton, Tom Everitt, Laura Weidinger, Iason Gabriel, Vladimir Mikulik, and Geoffrey Irving. Alignment of language agents. arXiv preprint arXiv:2103.14659, 2021.
193
+
194
+ [21] Hélène Landemore. Open Democracy: Reinventing Popular Rule for the Twenty-First Century. Princeton University Press, 2020.
195
+
196
+ [22] Torrin M Liddell and John K Kruschke. Analyzing ordinal data with metric models: What could possibly go wrong? Journal of Experimental Social Psychology, 79:328–348, 2018.
197
+
198
+ [23] Jacob Menick, Maja Trebacz, Vladimir Mikulik, John Aslanides, Francis Song, Martin Chadwick, Mia Glaese, Susannah Young, Lucy Campbell-Gillingham, Geoffrey Irving, et al. Teaching language models to support answers with verified quotes. arXiv preprint arXiv:2203.11147, 2022.
199
+
200
+ [24] Hervé Moulin. Fair division and collective welfare. MIT press, 2004.
201
+
202
+ [25] Reiichiro Nakano, Jacob Hilton, Suchir Balaji, Jeff Wu, Long Ouyang, Christina Kim, Christopher Hesse, Shantanu Jain, Vineet Kosaraju, William Saunders, et al. Webgpt: Browser-assisted question-answering with human feedback. arXiv preprint arXiv:2112.09332, 2021.
203
+
204
+ [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.
205
+
206
+ [27] Jack W Rae, Sebastian Borgeaud, Trevor Cai, Katie Millican, Jordan Hoffmann, Francis Song, John Aslanides, Sarah Henderson, Roman Ring, Susannah Young, et al. Scaling language models: Methods, analysis & insights from training gopher. arXiv preprint arXiv:2112.11446, 2021.
207
+
208
+ [28] John Rawls. A theory of justice. Rawls. The Belknap, 1971.
209
+
210
+ [29] Abigail See, Peter J Liu, and Christopher D Manning. Get to the point: Summarization with pointer-generator networks. arXiv preprint arXiv:1704.04368, 2017.
211
+
212
+ [30] Nisan Stiennon, Long Ouyang, Jeffrey Wu, Daniel Ziegler, Ryan Lowe, Chelsea Voss, Alec Radford, Dario Amodei, and Paul F Christiano. Learning to summarize with human feedback. Advances in Neural Information Processing Systems, 33:3008–3021, 2020.
213
+
214
+ [31] Yoshihiko Suhara, Xiaolan Wang, Stefanos Angelidis, and Wang-Chiew Tan. Opiniondigest: A simple framework for opinion summarization. arXiv preprint arXiv:2005.01901, 2020.
215
+
216
+ [32] Romal Thoppilan, Daniel De Freitas, Jamie Hall, Noam Shazeer, Apoorv Kulshreshtha, HengTze Cheng, Alicia Jin, Taylor Bos, Leslie Baker, Yu Du, et al. Lamda: Language models for dialog applications. arXiv preprint arXiv:2201.08239, 2022.
217
+
218
+ [33] Oriol Vinyals, Samy Bengio, and Manjunath Kudlur. Order matters: Sequence to sequence for sets. arXiv preprint arXiv:1511.06391, 2015.
219
+
220
+ [34] Laura Weidinger, John Mellor, Maribeth Rauh, Conor Griffin, Jonathan Uesato, Po-Sen Huang, Myra Cheng, Mia Glaese, Borja Balle, Atoosa Kasirzadeh, et al. Ethical and social risks of harm from language models. arXiv preprint arXiv:2112.04359, 2021.
221
+
222
+ [35] Jeff Wu, Long Ouyang, Daniel M Ziegler, Nisan Stiennon, Ryan Lowe, Jan Leike, and Paul Christiano. Recursively summarizing books with human feedback. arXiv preprint arXiv:2109.10862, 2021.
223
+ [36] Justine Zhang, Cristian Danescu-Niculescu-Mizil, Christina Sauper, and Sean J Taylor. Characterizing online public discussions through patterns of participant interactions. Proceedings of the ACM on Human-Computer Interaction, 2(CSCW):1–27, 2018.
224
+ [37] Daniel M Ziegler, Nisan Stiennon, Jeffrey Wu, Tom B Brown, Alec Radford, Dario Amodei, Paul Christiano, and Geoffrey Irving. Fine-tuning language models from human preferences. arXiv preprint arXiv:1909.08593, 2019.
225
+
226
+ # Checklist
227
+
228
+ 1. For all authors...
229
+
230
+ (a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes]
231
+ (b) Did you describe the limitations of your work? [Yes] See Section 5.1.
232
+ (c) Did you discuss any potential negative societal impacts of your work? [Yes] See Section 5.2.
233
+ (d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes] Regarding the collection of human data, our study was reviewed by our internal research ethics committee. This review includes ensuring compliance with GDPR, no collection of personal identifiable information, filtering of potentially offensive content, and receiving explicit consent from participants. Regarding matters related to potential negative societal impacts and general ethical conduct, we discuss these in detail in Sections 5.1 and 5.2.
234
+
235
+ 2. If you are including theoretical results...
236
+
237
+ (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]
238
+
239
+ 3. If you ran experiments...
240
+
241
+ (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 are not releasing the code or data. However we do describe both our question generation process as well as all the training details for supervised fine-tuning and reward modelling. Additionally, we provide example questions, opinions, and consensus candidates in the Appendix.
242
+ (b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes] Yes, see the Appendix.
243
+ (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [Yes] Yes, the error bars represent $9 5 \%$ bootstrapped confidence intervals.
244
+ (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 trained our models using Tensor Processing Units (TPUv3). The supervised fine-tuning models were fine-tuned using 64 TPU cores for 200 steps. The reward models were trained using 32 TPU cores for 1500 steps. We discuss our training process and hyperparameters in more detail in the Appendix.
245
+
246
+ 4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
247
+
248
+ (a) If your work uses existing assets, did you cite the creators? [Yes] In our work we fine-tune a 70 billion pretrained language model [17] which we cite in the Methods section.
249
+ (b) Did you mention the license of the assets? [N/A]
250
+ (c) Did you include any new assets either in the supplemental material or as a URL? [No]
251
+ (d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [Yes] Yes, see Section 3.2.
252
+ (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [Yes] Yes, see Section 3.2.
253
+
254
+ . If you used crowdsourcing or conducted research with human subjects...
255
+
256
+ (a) Did you include the full text of instructions given to participants and screenshots, if applicable? [Yes] Yes, these are provided in the Appendix.
257
+ (b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [Yes] This work was reviewed by our institution’s research ethics committee, see Section 3.2.
258
+ (c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [Yes] Yes, see Section 3.2. Participants were paid £15 per hour. The total cost for human data collection was approximately £46,000.
md/dev/KLaDXLAzzFT/KLaDXLAzzFT.md ADDED
The diff for this file is too large to render. See raw diff
 
md/dev/NbkjMn7X8H/NbkjMn7X8H.md ADDED
@@ -0,0 +1,513 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Robust Nonparametric Regression under Poisoning Attack
2
+
3
+ Anonymous Author(s)
4
+ Affiliation
5
+ Address
6
+ email
7
+
8
+ # Abstract
9
+
10
+ 1 This paper studies robust nonparametric regression, in which an adversarial attacker
11
+ 2 can modify the values of up to $q$ samples from a training dataset of size $N$ . Our
12
+ 3 initial solution is an M-estimator based on Huber loss minimization. Compared
13
+ 4 with simple kernel regression, i.e. the Nadaraya-Watson estimator, this method
14
+ 5 can significantly weaken the impact of malicious samples on the regression per
15
+ 6 formance. We provide the convergence rate as well as the corresponding minimax
16
+ 7 lower bound. The result shows that, with proper bandwidth selection, $\ell _ { \infty }$ error is
17
+ 8 minimax optimal. The $\ell _ { 2 }$ error is optimal if $q \lesssim \sqrt { N / \ln ^ { 2 } N }$ , but is suboptimal
18
+ 9 with larger $q$ . The reason is that this estimator is vulnerable if there are many
19
+ 10 attacked samples concentrating in a small region. To address this issue, we propose
20
+ 11 a correction method by projecting the initial estimate to the space of Lipschitz
21
+ 12 functions. The final estimate is nearly minimax optimal for arbitrary $q$ , up to a
22
+ 13 $\ln { N }$ factor.
23
+
24
+ # 14 1 Introduction
25
+
26
+ 15 In the era of big data, it is common for some samples to be corrupted due to various reasons, such
27
+ 16 as transmission errors, system malfunctions, malicious attacks, etc. The values of these samples
28
+ 17 may be altered in any way, rendering many traditional machine learning techniques less effective.
29
+ 18 Consequently, evaluating the effects of these corrupted samples, and making corresponding robust
30
+ 19 strategies, have become critical tasks in the research community [1–10].
31
+ 20 Among all types of data contamination, adversarial attack is of particular interest in recent years
32
+ 21 [11–17], in which there exists a malicious adversary who aims at deteriorating our model performance.
33
+ 22 With this goal, the attacker alters the values of some samples using a carefully designed strategy.
34
+ 23 Compared with other types of undesired samples, such as accidental errors or noise, adversarial
35
+ 24 samples are more challenging to deal with, since their values are altered deliberately instead of
36
+ 25 randomly. Therefore, any learning models that can withstand adversarial attacks should also be
37
+ 26 resilient to other corruptions.
38
+ 27 Adversarial attack can be divided into poisoning attack [11–13], which manipulates training samples
39
+ 28 to damage the model, and evasion attack [14–17], which modifies test samples to generate wrong
40
+ 29 predictions. We focus on poisoning attack here. For classification problems, the labels can only
41
+ 30 be altered within several discrete values, thus the impact of poisoning samples is relatively limited
42
+ 31 [11, 18, 19]. However, regression problems are crucially different, since the response variable is
43
+ 32 continuous and can be altered arbitrarily far away from its ground truth. Without proper handling,
44
+ 33 even if only a tiny fraction of training samples are attacked, the model performance may drastically
45
+ 34 deteriorate. Therefore, for regression problems, defense strategies against poisoning attack are
46
+ 35 crucially needed.
47
+ 36 Despite many previous works toward robust regression problems, most of them focus on parametric
48
+ 37 models [13, 20–22]. For example, there are several robust techniques for linear models, such as
49
+ 38 M-estimation [23], least median of squares [24], least trimmed squares [25], etc. However, for
50
+ 39 nonparametric methods such as kernel [26] and $\mathbf { k }$ nearest neighbor estimator, defense strategies
51
+ 40 against poisoning attack still need further exploration [27]. Actually, designing robust techniques is
52
+ 41 indeed more challenging for nonparametric methods than parametric one. For parametric models,
53
+ 42 the parameters are estimated using full dataset, while nonparametric methods have to rely on local
54
+ 43 training data around the query point. Even if the ratio of attacked samples among the whole dataset is
55
+ 44 small, the local anomaly ratio in the neighborhood of the query point can be large. As a result, the
56
+ 45 estimated function value at such query point can be totally wrong. Despite such difficulty, in many
57
+ 46 real scenarios, due to problem complexity or lack of prior knowledge, parametric models are not
58
+ 47 always available. Therefore, we hope to explore effective schemes to overcome the robustness issue
59
+ 48 of nonparametric regression.
60
+
61
+ 9 In this paper, we provide a theoretical study about robust nonparametric regression problem under 50 poisoning attack. In particular, we hope to investigate the theoretical limit of this problem, and design a method to achieve this limit. With this goal, we make the following contributions:
62
+
63
+ 52 Firstly, we propose and analyze an estimator that minimizes a weighted Huber loss, which can be
64
+ 53 viewed as a combination of $\ell _ { 1 }$ and $\ell _ { 2 }$ loss functions, and thus achieves a tradeoff between consistency
65
+ 54 and adversarial robustness. It was originally proposed in [28], but to the best of our knowledge,
66
+ 55 it was not analyzed under adversarial setting. We show the convergence rate of both $\ell _ { 2 }$ and $\ell _ { \infty }$
67
+ 56 risk, under the assumption that the function to estimate is Lipschitz continuous, and the noise is
68
+ 57 sub-exponential. An interesting finding is that if $q \lesssim \sqrt { N / \ln ^ { 2 } N }$ , in which $q$ is the maximum
69
+ 58 number of attacked samples, then the convergence rate is not affected by adversarial samples, i.e. the
70
+ 59 influence of poisoning samples on the overall risk is only up to a constant factor.
71
+ 60 Secondly, we provide an information theoretic minimax lower bound, which indicates the underlying
72
+ 61 limit one can achieve, with respect to $q$ and $N$ . The minimax lower bound without adversarial
73
+ 62 samples can be derived using standard information theoretic methods [29]. Under adversarial attack,
74
+ 63 the estimation problem is harder, thus the lower bound in [29] may not be tight enough. We design
75
+ 64 some new techniques to derive a tighter one. The result shows that the initial estimator has optimal
76
+ 65 $\ell _ { \infty }$ risk. If $q \lesssim \sqrt { N / \ln ^ { 2 } N }$ , then $\ell _ { 2 }$ risk is also minimax optimal. Nevertheless, for larger $q$ , the
77
+ 66 $\ell _ { 2 }$ risk is not optimal, indicating that this estimator is still not perfect. We then provide an intuitive
78
+ 67 explanation of the suboptimality. Instead of attacking some randomly selected training samples, the
79
+ 68 best strategy for the attacker is to focus their attack within a small region. With this strategy, majority
80
+ 69 of training samples are altered here, resulting in wrong estimates. A simple remedy is to increase the
81
+ 70 kernel bandwidth to improve robustness. Nevertheless, this will introduce additional bias in other
82
+ 71 regions. It turns out that $\ell _ { \infty }$ risk can be made optimal by adjusting the bandwidth, while $\ell _ { 2 }$ risk is
83
+ 72 always suboptimal. Actually, the drawback of the initial estimator is that it does not make full use of
84
+ 73 the continuity of regression function, and thus unable to correct the estimation.
85
+ 74 Finally, motivated by the issues of the initial method mentioned above, we propose a corrected
86
+ 75 estimator. If the attack focuses on a small region, although the initial estimate fails here, the output
87
+ 76 elsewhere is still reliable. With the assumption that the underlying function is continuous, the value at
88
+ 77 such region can be inferred using the surrounding values. With such intuition, we propose a nonlinear
89
+ 78 filtering method, which makes minimal adjustment to the estimated function in $\ell _ { 1 }$ sense, to make it
90
+ 79 Lipschitz continuous. The corrected estimate is then proved to be nearly minimax optimal up to only
91
+ 80 a $\ln { N }$ factor.
92
+ 81 The remainder of this paper is organized as follows. In section 2, we provide the problem statement
93
+ 82 as well as the initial estimator by Huber loss minimization. The upper bound and the minimax
94
+ 83 lower bound are shown in section 3. In section 4, we elaborate the corrected estimator, as well as
95
+ 84 related theoretical analysis. Numerical simulation results are shown in section 5. Finally, we discuss
96
+ 85 limitations and provide concluding remarks in section 6 and 7, respectively.
97
+
98
+ # 2 The Initial Estimator
99
+
100
+ 87 Suppose $\mathbf { X } _ { 1 } , \ldots , \mathbf { X } _ { N } \in \mathbb { R } ^ { d }$ be $N$ independently and identically distributed training samples, gen
101
+ 88 erated from a common probability density function (pdf) $f$ . For each sample $\mathbf { X } _ { i }$ , we can receive a
102
+
103
+ $$
104
+ Y _ { i } = \left\{ \begin{array} { l l } { \boldsymbol { \eta } ( \mathbf { X } _ { i } ) + W _ { i } } & { \mathrm { i f ~ } i \notin \mathcal { B } } \\ { \star } & { \mathrm { o t h e r w i s e , } } \end{array} \right.
105
+ $$
106
+
107
+ 90 in which $\eta : \mathbb { R } ^ { d } \mathbb { R }$ is the unknown underlying function that we would like to estimate. $W _ { i }$ is the
108
+ 91 noise variable. For $i = 1 , \ldots , N ,$ $W _ { i }$ are independent, with zero mean and finite variance. $\boldsymbol { B }$ is the
109
+ 92 set of indices of attacked samples. $\star$ means some value determined by the attacker. For each normal
110
+ 93 sample $\mathbf { X } _ { i }$ , the received label is $Y _ { i } = \eta ( \mathbf { X } _ { i } ) + W _ { i }$ . However, if a sample is attacked, then $Y _ { i }$ can be
111
+ 94 arbitrary value determined by the attacker. The attacker can manipulate up to $q$ samples, thus $| B | \le q$
112
+ 95 Our goal is opposite to the attacker. We hope to find an estimate $\hat { \eta }$ that is as close to $\eta$ as possible,
113
+ 96 while the attacker aims at reducing the estimation accuracy using a carefully designed attack strategy.
114
+ 97 We consider white-box setting here, in which the attacker has complete access to the ground truth $\eta$
115
+ 98 $\mathbf { X } _ { i }$ and $W _ { i }$ for all $i \in \{ 1 , \ldots , N \}$ , as well as our estimation algorithm. Under this setting, we hope
116
+ 99 to design a robust regression method that resists to any attack strategies.
117
+
118
+ 100 The quality of estimation is evaluated using $\ell _ { 2 }$ and $\ell _ { \infty }$ loss, which is defined as
119
+
120
+ $$
121
+ \begin{array} { r l r } { R _ { 2 } [ \hat { \eta } ] } & { = } & { \mathbb { E } \left[ \underset { \mathcal { A } } { \operatorname* { s u p } } ( \hat { \eta } ( \mathbf { X } ) - \eta ( \mathbf { X } ) ) ^ { 2 } \right] , } \\ { R _ { \infty } [ \hat { \eta } ] } & { = } & { \mathbb { E } \left[ \underset { \mathcal { A } } { \operatorname* { s u p } } \underset { \mathbf { x } } { \operatorname* { s u p } } \vert \hat { \eta } ( \mathbf { x } ) - \eta ( \mathbf { x } ) \vert \right] , } \end{array}
122
+ $$
123
+
124
+ 101 in which $\mathcal { A }$ denotes the attack strategy, $\mathbf { X }$ denotes a random test sample that follows a distribution
125
+ 102 with pdf $f$ . Our analysis can be easily generated to $\ell _ { p }$ loss with arbitrary $p$ .
126
+
127
+ 103 The kernel regression, also called the Nadaraya-Watson estimator [26, 30] is
128
+
129
+ $$
130
+ \hat { \eta } _ { N W } ( \mathbf { x } ) = \frac { \sum _ { i = 1 } ^ { N } K \left( \frac { \mathbf { x } - \mathbf { X } _ { i } } { h } \right) Y _ { i } } { \sum _ { i = 1 } ^ { N } K \left( \frac { \mathbf { x } - \mathbf { X } _ { i } } { h } \right) } ,
131
+ $$
132
+
133
+ 104 in which $K$ is the Kernel function, $h$ is the bandwidth that will decrease with the increase of sample
134
+ 105 size $N$ . $\hat { \eta } _ { 0 } ( \mathbf { x } )$ can be viewed as a weighted average of the labels around $\mathbf { x }$ . Without adversarial
135
+ 106 attack, such estimator converges to $\eta$ [31]. However, (4) fails even if a tiny fraction of samples are
136
+ 107 attacked. The attacked labels can just set to be sufficiently large. As a result, $\hat { \eta } _ { 0 } ( \mathbf { x } )$ could be far away
137
+ 108 from its truth.
138
+ 109 Now we build the estimator based on Huber loss minimization. Similar method was proposed in [28],
139
+ 110 but to the best of our knowledge, the performance under adversarial setting has not been analyzed.
140
+ 111 We elaborate this method for completeness and notation consistency. We use $\hat { \eta } _ { 0 }$ to denote the new
141
+ 112 estimator, which is designed as following:
142
+
143
+ $$
144
+ \hat { \eta } _ { 0 } ( \mathbf { x } ) = \underset { | s | \leq M } { \arg \operatorname* { m i n } } \sum _ { i = 1 } ^ { N } K \left( \frac { \mathbf { x } - \mathbf { X } _ { i } } { h } \right) \phi ( Y _ { i } - s ) ,
145
+ $$
146
+
147
+ 113 in which tie breaks arbitrarily if the minimum is not unique, and
148
+
149
+ $$
150
+ \phi ( u ) = \left\{ \begin{array} { c c l } { { u ^ { 2 } } } & { { \mathrm { i f } } } & { { | u | \leq T } } \\ { { 2 T | u | - T ^ { 2 } } } & { { \mathrm { i f } } } & { { | u | > T } } \end{array} \right.
151
+ $$
152
+
153
+ 114 is the Huber cost function.
154
+
155
+ 115 Here we have introduced two new parameters, namely, $M$ and $T$ . With $M \to \infty$ and $T \to \infty$ ,
156
+ 116 function $\phi$ becomes simple square loss, and it is straightforward to show that the resulting estimator
157
+ 117 (5) reduces to the Nadaraya-Watson estimator(4). $M$ is a constant hyperparameter that does not
158
+ 118 change with sample size $N$ . By restricting $| s | \leq M$ , we avoid the estimated value from being too
159
+ 119 large. It would be better if $M$ is larger than the upper bound of $| \eta ( \mathbf { x } ) |$ , so that the estimation is
160
+ 120 not truncated too much. $T$ balances accuracy and robustness. Smaller $T$ ensures robustness while
161
+ 121 sacrificing consistency, and vice versa. To achieve better tradeoff, $T$ need to increase with the training
162
+ 122 sample size $N$ . The best rate of the growth of $T$ with respect to $N$ depends on the strength of the tail
163
+ 123 of the noise distribution. In our theoretical analysis, we will show that under sub-exponential noise,
164
+ 124 $T \sim \ln { N }$ is optimal.
165
+ 125 We would like to remark that apart from Huber loss minimization, there are other robust mean
166
+ 126 estimation methods, such as median-of-means (MoM) [32, 33] and trimmed means [34, 35]. However,
167
+ 127 it is not efficient to generalize these methods to nonparametric regression. For MoM, with up to $q$
168
+ 128 corrupted samples, it divides the data into at least $2 q + 1$ groups and then calculate the median of the
169
+ 129 means of values in each group. Under the regression setting, since the distribution of attacked samples
170
+ 130 is unknown, we have to divide the data into $2 q + 1$ groups within the neighborhood of each query
171
+ 131 point. As a result, the accuracy with $N$ training samples with $q$ contaminated is only comparable
172
+ 132 to those with $N / ( 2 q + 1 )$ clean samples, indicating that the MoM method is ineffective. Trimmed
173
+ 133 means method has similar problems. The threshold of the trimmed mean need to be set uniformly
174
+ 134 among the whole support, while the adversarial attack may focus on a small region. As a result,
175
+ 135 the parameter can not be tuned optimal everywhere. The nonconsistency at attacked region and the
176
+ 136 inefficiency at relatively cleaner regions are two problems that can not be avoided simultaneously.
177
+ 137 Consequently, these alternative approaches are less effective than the M-estimator based on Huber
178
+ 138 loss minimization.
179
+ 139 Finally, we comment on the computation of the estimator (5). Note that $\phi$ is convex, therefore the
180
+ 140 minimization problem in (5) can be solved by gradient descent. The derivative of $\phi$ is
181
+
182
+ $$
183
+ \phi ^ { \prime } ( u ) = \left\{ \begin{array} { c c c } { { 2 u } } & { { \mathrm { i f } } } & { { | u | \leq T } } \\ { { 2 T } } & { { \mathrm { i f } } } & { { u > T } } \\ { { - 2 T } } & { { \mathrm { i f } } } & { { u < - T . } } \end{array} \right.
184
+ $$
185
+
186
+ 141 Based on (5) and (7), $s$ can be updated using binary search. Denote $\epsilon$ as the required precision, then
187
+ 142 the number of iterations for binary search should be $O ( \ln ( M / \epsilon ) )$ . Therefore, the computational
188
+ 143 complexity is higher than kernel regression up to a $\ln ( M / \epsilon )$ factor.
189
+
190
+ # 44 3 Theoretical Analysis
191
+
192
+ 45 This section proposes the theoretical analysis of the initial estimator (5) under adversarial setting. To
193
+ 46 begin with, we make some assumptions about the problem.
194
+ 147 Assumption 1. (Problem Assumption) there exists a compact set $\mathcal { X }$ and several constants $L , \gamma , f _ { m }$ ,
195
+ 148 $f _ { M } , D , \alpha , \sigma ,$ , such that the pdf $f$ is supported at $\mathcal { X }$ , and
196
+
197
+ (a) (Lipschitz continuity) For any $\mathbf { x } _ { 1 } , \mathbf { x } _ { 2 } \in \mathcal { X } , | \eta ( \mathbf { x } _ { 1 } ) - \eta ( \mathbf { x } _ { 2 } ) | \leq L | | \mathbf { x } _ { 1 } - \mathbf { x } _ { 2 } | | ;$
198
+
199
+ 150 (b) (Bounded $f$ and $\eta .$ ) For all $\mathbf { x } \in \mathcal { X }$ , $f _ { m } \leq f ( \mathbf { x } ) \leq f _ { M }$ and $| \eta ( \mathbf { x } ) | \le M$ , in which $M$ is the
200
+ 151 parameter used in (5);
201
+
202
+ (c) (Corner shape restriction) For all 152 $r < D$ , $V ( B ( \mathbf { x } , r ) \cap \mathcal { X } ) \geq \alpha v _ { d } r ^ { d }$ , in which $B ( \mathbf { x } , r )$ is the ball 153 centering at x with radius $r$ , $v _ { d }$ is the volume of $d$ dimensional unit ball, which depends on the norm 154 we use;
203
+
204
+ (d) (Sub-exponential noise) The noise 155 $W _ { i }$ is subexponential with parameter $\sigma$
205
+
206
+ $$
207
+ \mathbb { E } [ e ^ { \lambda W _ { i } } ] \leq e ^ { \frac { 1 } { 2 } \sigma ^ { 2 } \lambda ^ { 2 } } , \forall | \lambda | \leq \frac { 1 } { \sigma } ,
208
+ $$
209
+
210
+ 156 for $i = 1 , \ldots , N$ .
211
+
212
+ 157 (a) is a common assumption for smoothness. (b) assumes that the pdf is bounded from both below and
213
+ 158 above. (c) prevents the shape of the corner of the support from being too sharp. Without assumption
214
+ 159 (c), the samples around the corner may not be enough, and the attacker can just attack the corner of
215
+ 160 the support. (d) requires that the noise is sub-exponential. If the noise assumption is weaker, e.g.
216
+ 161 only requiring the bounded moments of $W _ { i }$ up to some order, then the noise can be disperse. In this
217
+ 162 case, it will be harder to distinguish adversarial samples from clean samples. More discussions are
218
+ 163 provided in section 6.
219
+
220
+ 164 We then make some restrictions on the kernel function $K$ .
221
+
222
+ Assumption 2. (Kernel Assumption) the kernel need to satisfy: (a) 65 $\begin{array} { r } { \int K ( { \bf u } ) d u = 1 } \end{array}$ ; $( b ) K ( { \bf u } ) =$
223
+ 66 $0 , \forall \lvert \lvert \mathbf { u } \rvert \rvert > 1$ ; (c) $c _ { K } \leq K ( \mathbf { u } ) \leq C _ { K }$ for two constants $c _ { K }$ and $C _ { K }$ .
224
+
225
+ 167 (a) is actually not necessary, since from (5), the estimated value will not change if the kernel function
226
+ 168 is multiplied by a constant factor. This assumption is only for convenience of proof. (b) and (c)
227
+ 169 actually requires that the kernel need to be somewhat close to the uniform function in the unit ball.
228
+ 170 Intuitively, if the attacker wants to modify the estimate at some $\mathbf { x }$ , the best way is to change the
229
+ 171 response of sample $i$ with large $K ( ( \mathbf { X } _ { i } - { \dot { \mathbf { x } } } ) / h )$ , in order to make strong impact on $\hat { \eta } ( \mathbf { x } )$ . To defend
230
+ 172 against such attack, the upper bound of $K$ should not be too large. Besides, to ensure that clean
231
+ 173 samples dominate corrupted samples everywhere, the effect of each clean sample on the estimation
232
+ 174 should not be too small, thus $K$ also need to be bounded from below in its support.
233
+ 175 Furthermore, recall that (5) has three parameters, i.e. $h , T$ and $M$ . We assume that these three
234
+ 176 parameters satisfy the following conditions.
235
+
236
+ Assumption 3. (Parameter Assumption) h, T , M need to satisfy177 $( a ) h > \ln ^ { 2 } N / N ; ( b ) T \geq 4 L h +$ 178 $1 6 \sigma \ln { N }$ ; $( c ) M > \operatorname* { s u p } _ { \mathbf { x } \in \mathcal { X } } | \eta ( \mathbf { x } ) |$ .
237
+
238
+ 179 (a) ensures that the number of samples whose distance to $\mathbf { x }$ less than $h$ is not too small. Actually, for a
239
+ 180 better tradeoff between bias and variance, $h$ need to grow much faster than $\ln ^ { 2 } N / N$ . (b) requires that
240
+ 181 $T \sim \ln { N }$ . Actually, the optimal growth rate of $T$ depends on the distribution of noise. Recall that in
241
+ 182 Assumption 1(d), we assume that the distribution of noise is sub-exponential. If we use sub-Gaussian
242
+ 183 assumption instead, then it is enough for $T \sim \sqrt { \ln { N } }$ . If the noise is further assumed to be bounded,
243
+ 184 then $T$ can just be set to constant. (c) prevents the estimate from being truncated too much.
244
+ 85 The upper bound of $\ell _ { 2 }$ error is derived under these assumptions. Denote $a \lesssim b$ if $a \leq C b$ for some
245
+ 186 constant $C$ that depends only on $L , M , \gamma , f _ { m } , f _ { M } , D , \alpha , \sigma , c _ { K } , C _ { K }$ .
246
+
247
+ 187 Theorem 1. Under Assumption $^ { l }$ , 2 and 3,
248
+
249
+ $$
250
+ \mathbb { E } \left[ \operatorname* { s u p } _ { A } \left( \hat { \eta } _ { 0 } ( \mathbf { X } ) - \eta ( \mathbf { X } ) \right) ^ { 2 } \right] \lesssim \frac { T ^ { 2 } q ^ { 2 } } { N ^ { 2 } h ^ { d } } + h ^ { 2 } + \frac { 1 } { N h ^ { d } } .
251
+ $$
252
+
253
+ 188 The detailed proof of Theorem 1 is shown in section 2 in the supplementary material. From the proof,
254
+ 189 it can also be observed that the effect of adversarial samples is higher when they concentrate at a
255
+ 190 small region instead of distributing uniformly over the whole support. Denote $B _ { h } ( { \bf x } )$ as the ball
256
+ 191 centering at $\mathbf { x }$ with radius $h$ . Even if $q / N$ is small, the proportion of attacked samples within $B ( \mathbf { x } , h )$
257
+ 192 for some $\mathbf { x }$ may be large, which may result in large error at $\mathbf { x }$ .
258
+
259
+ 93 The next theorem shows the bound of $\ell _ { \infty }$ error:
260
+
261
+ 194 Theorem 2. Under Assumption 1, 2, 3, if $K ( \mathbf { u } )$ is monotonic decreasing with respect to $\lVert u \rVert$ , then
262
+
263
+ $$
264
+ \mathbb { E } \left[ \underset { \mathcal { A } ~ \textbf { x } } { \operatorname* { s u p s u p } } | \hat { \eta } _ { 0 } ( \mathbf { x } ) - \eta ( \mathbf { x } ) | \right] \lesssim \frac { T q } { N h ^ { d } } + h + \frac { \ln N } { \sqrt { N h ^ { d } } } .
265
+ $$
266
+
267
+ 195 The proof is in section 3 in the supplementary material. We then show the minimax lower bound,
268
+ 196 which indicates the information theoretic limit of the adversarial nonparametric regression problem.
269
+ 197 In general, it is impossible to design an estimator with convergence rate faster than the following
270
+ 198 bound.
271
+ 199 Theorem 3. Let $\mathcal { F }$ be the collection of $f , \eta , \mathbb { P } _ { \mathbb { N } }$ that satisfy Assumption $^ { l }$ , in which $\mathbb { P } _ { N }$ is the
272
+ 200 distribution of the noise $W _ { 1 } , \dots , W _ { N }$ . Then
273
+
274
+ $$
275
+ \operatorname* { i n f } _ { \hat { \eta } } \operatorname* { s u p } _ { ( f , \eta , \mathbb { P } _ { N } ) \in \mathcal { F } } \mathbb { E } \left[ \operatorname* { s u p } _ { A } \left( \hat { \eta } ( \mathbf { X } ) - \eta ( \mathbf { X } ) \right) ^ { 2 } \right] \gtrsim \left( \frac { q } { N } \right) ^ { \frac { d + 2 } { d + 1 } } + N ^ { - \frac { 2 } { d + 2 } } ,
276
+ $$
277
+
278
+ 201 and
279
+
280
+ $$
281
+ \operatorname* { i n f } _ { \hat { \eta } } \operatorname* { s u p } _ { ( f , \eta , \mathbb { P } _ { N } ) \in \mathcal { F } } \mathbb { E } \left[ \operatorname* { s u p s u p } _ { A } \lvert \hat { \eta } ( \mathbf { x } ) - \eta ( \mathbf { x } ) \rvert \right] \gtrsim \left( \frac { q } { N } \right) ^ { \frac { 1 } { d + 1 } } + N ^ { - \frac { 1 } { d + 2 } } .
282
+ $$
283
+
284
+ 202 The proof is shown in section 4 in the supplementary material. In the right hand side of (11) and (12),
285
+ 203 $N ^ { - 2 / ( d + 2 ) }$ is the standard minimax lower bound for nonparametric estimation [29], which holds
286
+ 204 even if there are no adversarial samples. In the supplementary material, we only prove the lower
287
+ 205 bound with the first term in the right hand side of (11).
288
+ 206 Compare Theorem 1, 2 and Theorem 3, we have the following findings. We claim that the upper and
289
+ 207 lower bound nearly match, if these two bounds match up to a polynomial of $\ln { N }$ :
290
+
291
+ • From (10) and (12), with $h \sim \operatorname* { m a x } \{ ( q / N ) ^ { 1 / ( d + 1 ) } , N ^ { - 1 / ( d + 2 ) } \}$ and $T \sim \ln { N }$ , the upper and minimax lower bound of $\ell _ { \infty }$ error nearly match.
292
+ • If $q \lesssim \sqrt { N / \ln ^ { 2 } N }$ , from (9) and (11), let $h \sim N ^ { - \frac { 2 } { d + 2 } }$ , the upper and minimax lower bound of $\ell _ { 2 }$ match. In fact, in this case, the convergence rate of (5) is the same as ordinary kernel regression without adversarial samples, i.e. $\bar { h ^ { 2 } } + 1 / ( N h ^ { d } )$ . With optimal selection of $h$ , the
293
+ rate becomes $N ^ { - 2 / ( d + 2 ) }$ , which is just the standard rate for nonparametric statistics [29, 38].
294
+ • The $\ell _ { 2 }$ upper and lower bound no longer match if $q \gtrsim \sqrt { N / \ln ^ { 2 } N }$ . In this case, the optimal $h$ in (9) is $h \sim ( q \ln N / N ) ^ { 2 / ( d + 2 ) }$ , and resulting $\ell _ { 2 }$ error is $R _ { 2 } \ \lesssim \ ( q \ln { N } / { N } ) ^ { 4 / ( d + 2 ) }$ higher than the lower bound in (11). This result indicates that the initial estimator (5) is optimal under $\ell _ { \infty }$ , or under $\ell _ { 2 }$ with small $q$ .
295
+ However, under large number of adversarial samples, the $\ell _ { 2 }$ error becomes suboptimal.
296
+
297
+ Now we provide an intuitive understanding of the suboptimality of $\ell _ { 2 }$ risk with large $q$ using a simple one dimensional example shown in Figure 1, with $N = 1 0 0 0 0$ , $h = 0 . 0 5$ , $M = 3$ , $f ( x ) = 1$ for $x \in ( 0 , 1 )$ , $\eta ( x ) = \mathrm { s i n } ( 2 \pi x )$ , and the noise follows standard normal distribution $\mathcal { N } ( 0 , 1 )$ . For each $x$ , denote $q _ { h } ( x )$ , $n _ { h } ( x )$ as the number of attacked samples and total samples within $( x - h , x + h )$ , respectively. For robust mean estimation problems, the breakdown point is $1 / 2$ [39], which also holds locally for nonparametric regression problem. Hence, if $q _ { h } ( x ) \bar { / } n _ { h } ( x ) > 1 / 2$ , the estimator will collapse and return erroneous values even if we use Huber cost. In (a), $q \ = \ 5 0 0$ , among which 250 attacked samples are around $x = 0 . 2 5$ , while others are around $x = 0 . 7 5$ . In this case, $q _ { h } ( x ) / n _ { h } ( x ) < 1 / 2$ over the whole support. The curve of estimated function is shown in Fig 1(b). The estimate with (5) is significantly better than kernel regression. Then we increase $q$ to 2000. In this case, $q _ { h } ( x ) / n _ { h } ( x ) > \bar { 1 } / 2$ around 0.25 and 0.75 (Fig 1(c)), thus the estimate fails. The estimated function curve shows an undesirable spike (Fig 1(d)).
298
+
299
+ ![](images/bdffe3d7831aae045d1cb112fea5e8ff9c393c22837fb784c15c65854ff4262d.jpg)
300
+ (a) Scatter plots with $q = { \mathsf { \Omega } } ( { \mathsf { b } } )$ Estimated results with (c) Scatter plots with $q =$ (d) Estimated results with 500. $q = 5 0 0$ . 2000. $q = 2 0 0 0$ .
301
+ Figure 1: A simple example with $q = 5 0 0$ and $q = 2 0 0 0$ . In (a) and (c), red dots are attacked samples, while blue dots are normal samples. In (b) and (d), four curves correspond to ground truth $\eta$ , the result of kernel regression, initial estimate and corrected estimate, respectively. With $q = 5 0 0$ , the initial estimate (5) works well. However, with $q = 2 0 0 0$ , the initial estimate fails, while the corrected regression works well.
302
+
303
+ The above example shows that the best strategy for attacker is to focus on altering values at a small region. In this case, the local ratio of attacked samples surpasses the breakdown point, resulting in a wrong estimate. With such strategy and sufficient $q$ , the initial estimator (5) fails to be optimal. Actually, (5) does not make full use of the continuity property of regression function $\eta$ , and thus unable to detect and remove the spikes. A simple remedy is to increase $h$ so that $q _ { h } \dot { ( x ) } / n _ { h } ( x )$ becomes smaller. However, this solution will introduce additional bias. In the next section, we design a corrected estimator to improve (5), which will close the gap between upper and minimax lower bound with $q \gtrsim \sqrt { N / \ln ^ { 2 } N }$ .
304
+
305
+ # 4 Corrected Regression
306
+
307
+ In this section we propose and analyze a correction method to the initial estimator (5).
308
+
309
+ 241 As has been discussed in section 3, the drawback of the initial estimator is that the continuity property $\eta$ is not used. Consequently, an intuitive solution is to filter out the spike, and estimate $\eta$ here using
310
+
311
+ 243 values in surrounding locations. Linear filter does not work here since the profile of the regression
312
+ 244 estimate will be blurred. Therefore, we propose a nonlinear filter as following. It conducts minimum
313
+ 245 correction (in $\ell _ { 1 }$ sense) to the initial result $\hat { \eta } _ { 0 }$ , while ensuring that the corrected estimate is Lipschitz.
314
+ 246 Formally, given the initial estimate $\hat { \eta } _ { 0 } ( \mathbf { x } )$ , our method solves the following optimization problem
315
+
316
+ $$
317
+ \begin{array} { r } { \hat { \eta } _ { c } = \underset { \| \nabla g \| _ { \infty } \leq L } { \arg \operatorname* { m i n } } \| \hat { \eta } _ { 0 } - g \| _ { 1 } , } \end{array}
318
+ $$
319
+
320
+ 247 in which
321
+
322
+ $$
323
+ \| \nabla g \| _ { \infty } = \operatorname* { m a x } \left\{ \left| { \frac { \partial g } { \partial x _ { 1 } } } \right| , \ldots , \left| { \frac { \partial g } { \partial x _ { d } } } \right| \right\} .
324
+ $$
325
+
326
+ 248 In section 5 in the supplementary material, we prove that the solution to the optimization problem
327
+ 249 (13) is unique.
328
+ 250 (13) can be viewed as the projection of the output of initial estimator (5) into the space of Lipschitz
329
+ 251 function. Here we would like to explain intuitively why we use $\ell _ { 1 }$ distance instead of other metrics
330
+ 252 in (13). Using the example in Fig.1(d) again, it can be observed that at the position of such spikes,
331
+ 253 $| \eta ( \mathbf { x } ) - g ( \mathbf { x } ) |$ can be large. Other metrics such as $\ell _ { 2 }$ distance impose large costs here, thus somewhat
332
+ 254 prevents the removal of spikes. Hence $\ell _ { 1 }$ distance is preferred.
333
+
334
+ The estimation error of the corrected regression can be bounded by the following theorem.
335
+
336
+ Theorem 4. (1) Under the same conditions as Theorem $^ { l }$
337
+
338
+ $$
339
+ \mathbb { E } \left[ \operatorname* { s u p } _ { \mathcal { A } } \left( \widehat { \eta } _ { c } ( \mathbf { X } ) - \eta ( \mathbf { X } ) \right) ^ { 2 } \right] \lesssim \left( \frac { q \ln N } { N } \right) ^ { \frac { d + 2 } { d + 1 } } + h ^ { 2 } + \frac { \ln N } { N h ^ { d } } .
340
+ $$
341
+
342
+ 257 (2) Under the same conditions as Theorem 2,
343
+
344
+ $$
345
+ \mathbb { E } \left[ \operatorname* { s u p s u p } _ { A \mathrm { ~ } \mathbf { \Phi } \mathbf { x } } | \hat { \eta } _ { c } ( \mathbf { x } ) - \eta ( \mathbf { x } ) | \right] \lesssim \frac { T q } { N h ^ { d } } + h + \frac { \ln N } { \sqrt { N h ^ { d } } } .
346
+ $$
347
+
348
+ 258 The proof is shown in section 6 in the supplementary material. Compared with Theorem 3, with
349
+ 259 $T \sim \ln { N }$ and a proper $h$ , the upper and lower bound nearly match.
350
+
351
+ 0 Now we discuss the practical implementation. (13) can not be calculated directly for a continuous function. Therefore, we find a approximate numerical solution instead. The detail of practical 2 implementation is shown in section 1 in the supplementary material.
352
+
353
+ # 5 Numerical Examples
354
+
355
+ In this section we show some numerical experiments. In particular, we show the curve of the growth of mean square error over the attacked sample size $q$ .
356
+
357
+ For each case, we generate $N = 1 0 0 0 0$ training samples, with each sample follows uniform distribution in $[ 0 , 1 ] ^ { d }$ . The kernel function is
358
+
359
+ $$
360
+ K ( u ) = 2 - | u | , \forall | u | \leq 1 .
361
+ $$
362
+
363
+ 268 We compare the performance of kernel regression, the median-of-means method, initial estimate,
364
+ 269 and the corrected estimation under multiple attack strategies. For kernel regression, the output is
365
+ 270 $\operatorname* { m a x } ( \operatorname* { m i n } ( \hat { \eta } _ { N W } , M ) , - M )$ , in which $\hat { \eta } _ { N W }$ is the simple kernel regression defined in (4). We truncate
366
+ 271 the result into $[ - M , M ]$ for a fair comparison with robust estimators. For the median-of-means
367
+ 272 method, we divide the training samples into 20 groups randomly, and then conduct kernel regression
368
+ 273 for each group and then find the median, i.e.
369
+
370
+ $$
371
+ \hat { \eta } _ { M o M } = \mathrm { C l i p } ( \mathrm { m e d } ( \{ \hat { \eta } _ { N W } ^ { ( 1 ) } , \dots , \hat { \eta } _ { N W } ^ { ( m ) } \} ) , [ - M , M ] ) .
372
+ $$
373
+
374
+ 274 For the initial estimator (5), the parameters are $T = 1$ and $M = 3$ . The corrected estimate uses (3)
375
+ 275 in the supplementary material. For $d = 1$ , the grid count is $m = 5 0$ . For $d = 2$ , $m _ { 1 } = m _ { 2 } = 2 0$ .
376
+ 276 Consider that the optimal bandwidth need to increase with the dimension, in (4), the bandwidths of
377
+ 277 all these four methods are set to be $h = 0 . 0 3$ for one dimensional distribution, and $h = 0 . 1$ for two
378
+ 278 dimensional case.
379
+
380
+ 279 The attack strategies are designed as following. Let $q = 5 0 0 k$ for $k = 0 , 1 , \ldots , 1 0$ .
381
+
382
+ 80 Definition 1. There are three strategies, namely, random attack, one directional attack, and concen
383
+ 81 trated attack, which are defined as following:
384
+ 82 (1) Random Attack. The attacker randomly select q samples among the training data to attack. The
385
+ 83 value of each attacked sample is $- 1 0$ or 10 with equal probability;
386
+ 284 (2) One directional Attack. The attacker randomly select $q$ samples among the training data to attack.
387
+ 285 The value of all attacked samples are 10;
388
+
389
+ (3) Concentrated Attack. The attacker pick two random locations $\mathbf { c } _ { 1 }$ , $\mathbf { c } _ { 2 }$ that are uniformly distributed in $[ 0 , 1 ] ^ { d }$ . For $\lfloor q / 2 \rfloor$ samples that are closest to $\mathbf { c } _ { 1 }$ , modify their values to 10. For $\lfloor q / 2 \rfloor$ samples that are closest to $\mathbf { c } _ { 2 }$ , modify their values to $- 1 0$ .
390
+
391
+ ![](images/8e09ce4465a21c917c003b4257f4c402e6e3ed2d7a5b05a2b3bb6f49933ec5af.jpg)
392
+
393
+ Figure 2: Comparison of $\ell _ { 2 }$ and $\ell _ { \infty }$ error between various methods for one dimensional distribution.
394
+
395
+ 289 For one dimensional distribution, let the ground truth be
396
+
397
+ $$
398
+ \eta _ { 1 } ( x ) = \sin ( 2 \pi x ) .
399
+ $$
400
+
401
+ 290 For two dimensional distribution,
402
+
403
+ $$
404
+ \eta ( \mathbf { x } ) = \sin ( 2 \pi x _ { 1 } ) + \cos ( 2 \pi x _ { 2 } ) .
405
+ $$
406
+
407
+ 291 The noise follows standard Gaussian distribution $\mathcal { N } ( 0 , 1 )$ . The performances are evaluated using
408
+ 292 square root of $\ell _ { 2 }$ error, as well as $\ell _ { \infty }$ error. The results are shown in Figure 2 and 3 for one and
409
+ 293 two dimensional distributions, respectively. In these figures, each point is the average over 1000
410
+ 294 independent trials.
411
+ 295 Figure 2 and 3 show that the simple kernel regression (blue dotted line) fails under poisoning attack.
412
+ 296 The $\ell _ { 2 }$ and $\ell _ { \infty }$ error grows fast with the increase of $q$ . Besides, traditional median-of-means does
413
+ 297 not improve over kernel regression. Moreover, the initial estimator (5) (orange dash-dot line) shows
414
+ 298 significantly better performance than kernel estimator under random and one directional attack, as
415
+ 299 are shown in Fig.2 and 3, (a), (b), (d), (e). However, if the attacked samples concentrate around some
416
+ 300 centers, then the initial estimator fails. Compared with kernel regression, there is some but limited
417
+ 301 improvement for (5). Finally, the corrected estimator (red solid line) performs well under all attack
418
+ 302 strategies. Under random attack, the corrected estimator performs nearly the same as initial one. For
419
+ 303 one directional attack, the corrected estimator performs better than the initial one with large $q$ . Under
420
+ 304 concentrated attack, the correction shows significant improvement. These results are consistent with
421
+ 305 our theoretical analysis.
422
+
423
+ ![](images/ed55f81381f578c580c0b9903d6cc23fe3dfffff281090fdb1cdd60d1746ffbc.jpg)
424
+ Figure 3: Comparison of $\ell _ { 2 }$ and $\ell _ { \infty }$ error between various methods for one dimensional distribution.
425
+
426
+ # 306 6 Limitations
427
+
428
+ The major limitation is that for high dimensional feature distributions, the corrected estimator can be computationally expensive, since the number of grids grows exponentially with the dimensionality.
429
+
430
+ 309 Moreover, our theoretical results rely on Assumption 1. Nevertheless, it is not hard to generalize
431
+ 310 these assumptions. For (a), we can use a local polynomial method to improve the convergence rate if
432
+ 311 $\eta$ satisfies higher order of smoothness. (b) limits the feature distribution. Actually, our analysis can
433
+ 312 be extended to heavy tail cases, in which the bandwidth can be made adaptive, such as [36, 37]. In
434
+ 313 order to achieve better tradeoff between bias and variance, in the regions with high pdf, bandwidth
435
+ 314 $h$ need to be smaller, and vice versa. Currently, we only focus on distributions without tails. (d)
436
+ 315 requires that the noise is sub-exponential. Such restriction can also be extended to the case in which
437
+ 316 the noise is only assumed to have bounded moments. In this case, we can let $T$ grow faster with $N$
438
+ 317 Despite that we are convinced that all these assumptions can be extended with some modification, the
439
+ 318 current results focus on a simpler situation.
440
+
441
+ # 319 7 Conclusion
442
+
443
+ 320 In this paper, we have provided a theoretical analysis of robust nonparametric regression problem
444
+ 321 under adversarial attack. In particular, we have derived the convergence rate of an M-estimator
445
+ 322 based on Huber loss minimization. We have also derived the information theoretic minimax lower
446
+ 323 bound, which is the underlying limit of robust nonparametric regression. The result shows that the
447
+ 324 initial estimator has minimax optimal $\ell _ { \infty }$ risk. With $q \lesssim \sqrt { N / \ln ^ { 2 } N }$ , in which $q$ is the number
448
+ 325 of adversarial samples, $\ell _ { 2 }$ risk is also optimal. However, for large $q$ , the initial estimator becomes
449
+ 326 suboptimal. In particular, if the attacker focus their attack around some centers, then the resulting
450
+ 327 estimate shows some undesirable spikes at these centers. Actually, the drawback of initial estimator is
451
+ 328 that it does not make full use of the continuity of regression function, and hence unable to detect spikes
452
+ 329 and correct the estimate. Motivated by such discussion, we have proposed a correction technique,
453
+ 330 which is a nonlinear filter that projects the estimated function into the space of Lipschitz functions.
454
+ 331 Our theoretical analysis shows that the corrected estimator is minimax optimal even for large $q$
455
+ 332 Numerical experiments validate our theoretical analysis.
456
+
457
+ # References
458
+
459
+ [1] Natarajan, N., I. S. Dhillon, P. K. Ravikumar, et al. Learning with noisy labels. In Advances in Neural Information Processing Systems, vol. 26. 2013.
460
+ [2] Van Rooyen, B., R. C. Williamson. A theory of learning with corrupted labels. J. Mach. Learn. Res., 18(1):8501–8550, 2017.
461
+ [3] Jiang, L., Z. Zhou, T. Leung, et al. Mentornet: Learning data-driven curriculum for very deep neural networks on corrupted labels. In International conference on machine learning, pages 2304–2313. PMLR, 2018.
462
+ [4] Liu, T., D. Tao. Classification with noisy labels by importance reweighting. IEEE Transactions on pattern analysis and machine intelligence, 38(3):447–461, 2015.
463
+ [5] Gao, W., B.-B. Yang, Z.-H. Zhou. On the resistance of nearest neighbor to random noisy labels. arXiv preprint arXiv:1607.07526, 2016.
464
+ [6] Menon, A., B. Van Rooyen, C. S. Ong, et al. Learning from corrupted binary labels via class-probability estimation. In International conference on machine learning, pages 125–134. PMLR, 2015.
465
+ [7] Patrini, G., F. Nielsen, R. Nock, et al. Loss factorization, weakly supervised learning and label noise robustness. In International Conference on Machine Learning, pages 708–717. PMLR, 2016.
466
+ [8] Van Rooyen, B., A. Menon, R. C. Williamson. Learning with symmetric label noise: The importance of being unhinged. In Advances in Neural Information Processing Systems, vol. 28. 2015.
467
+ [9] Wang, R., T. Liu, D. Tao. Multiclass learning with partially corrupted labels. IEEE transactions on neural networks and learning systems, 29(6):2568–2580, 2017.
468
+ [10] Reeve, H., A. Kabán. Fast rates for a knn classifier robust to unknown asymmetric label noise. In International Conference on Machine Learning, pages 5401–5409. PMLR, 2019.
469
+ [11] Biggio, B., B. Nelson, P. Laskov. Poisoning attacks against support vector machines. In International Conference on Machine Learning. 2012.
470
+ [12] Xiao, H., B. Biggio, G. Brown, et al. Is feature selection secure against training data poisoning? In International Conference on Machine Learning, pages 1689–1698. PMLR, 2015.
471
+ [13] Jagielski, M., A. Oprea, B. Biggio, et al. Manipulating machine learning: Poisoning attacks and countermeasures for regression learning. In 2018 IEEE symposium on security and privacy $( S P )$ , pages 19–35. IEEE, 2018.
472
+ [14] Szegedy, C., W. Zaremba, I. Sutskever, et al. Intriguing properties of neural networks. In International Conference on Learning Representations. 2014.
473
+ [15] Goodfellow, I. J., J. Shlens, C. Szegedy. Explaining and harnessing adversarial examples. In International Conference on Learning Representations. 2015.
474
+ [16] Madry, A., A. Makelov, L. Schmidt, et al. Towards deep learning models resistant to adversarial attacks. In International Conference on Learning Representations. 2018.
475
+ [17] Mao, C., Z. Zhong, J. Yang, et al. Metric learning for adversarial robustness. In Advances in Neural Information Processing Systems, vol. 32. 2019.
476
+ [18] Steinhardt, J., P. W. W. Koh, P. S. Liang. Certified defenses for data poisoning attacks. In Advances in Neural Information Processing Systems, vol. 30. 2017.
477
+ [19] Koh, P. W., P. Liang. Understanding black-box predictions via influence functions. In International Conference on Machine Learning, pages 1885–1894. PMLR, 2017.
478
+ [20] Ribeiro, A. H., T. B. Schön. Overparameterized linear regression under adversarial attacks. IEEE Transactions on Signal Processing, 71:601–614, 2023.
479
+ [21] Lecué, G., M. Lerasle. Robust machine learning by median-of-means: theory and practice. Annals of Statistics, 2020.
480
+ [22] Liu, C., B. Li, Y. Vorobeychik, et al. Robust linear regression against training data poisoning. In Proceedings of the 10th ACM workshop on artificial intelligence and security, pages 91–102. 2017.
481
+
482
+ 384 [23] Huber, P. J. Robust Statistics. John Wiley & Sons, 1981.
483
+ 385 [24] Rousseeuw, P. J. Least median of squares regression. Journal of the American statistical
484
+ 386 association, 79(388):871–880, 1984.
485
+ 387 [25] Rousseeuw, P. J., A. M. Leroy. Robust regression and outlier detection. John wiley & sons,
486
+ 388 2005.
487
+ 389 [26] Nadaraya, E. A. On estimating regression. Theory of Probability & Its Applications, 9(1):141–
488
+ 390 142, 1964.
489
+ 391 [27] Salibian-Barrera, M. Robust nonparametric regression: review and practical considerations.
490
+ 392 arXiv preprint arXiv:2211.08376, 2022.
491
+ 393 [28] Hall, P., M. Jones. Adaptive m-estimation in nonparametric regression. Annals of Statistics,
492
+ 394 pages 1712–1728, 1990.
493
+ 395 [29] Tsybakov, A. B. Introduction to Nonparametric Estimation. Springer Series in Statistics, 2009.
494
+ 396 [30] Watson, G. S. Smooth regression analysis. Sankhya: The Indian Journal of Statistics, Series A ¯ ,
495
+ 397 pages 359–372, 1964.
496
+ 398 [31] Devroye, L. P. The uniform convergence of the nadaraya-watson regression function estimate.
497
+ 399 Canadian Journal of Statistics, 6(2):179–191, 1978.
498
+ 400 [32] Nemirovskij, A. S., D. B. Yudin. Problem complexity and method efficiency in optimization.
499
+ 401 Wiley-Interscience Series in Discrete Mathematics, 1983.
500
+ 402 [33] Ben-Hamou, A., A. Guyader. Robust non-parametric regression via median-of-means. arXiv
501
+ 403 preprint arXiv:2301.10498, 2023.
502
+ 404 [34] Bickel, P. J. On some robust estimates of location. The Annals of Mathematical Statistics, pages
503
+ 405 847–858, 1965.
504
+ 406 [35] Dhar, S., P. Jha, P. Rakshit. The trimmed mean in non-parametric regression function estimation.
505
+ 407 Theory of Probability and Mathematical Statistics, 107:133–158, 2022.
506
+ 408 [36] Herrmann, E. Local bandwidth choice in kernel regression estimation. Journal of Computational
507
+ 409 and Graphical Statistics, 6(1):35–54, 1997.
508
+ 410 [37] Zhao, P., L. Lai. Minimax rate optimal adaptive nearest neighbor classification and regression.
509
+ 411 IEEE Transactions on Information Theory, 67(5):3155–3182, 2021.
510
+ 412 [38] Krzyzak, A. The rates of convergence of kernel regression estimates and classification rules.
511
+ 413 IEEE Transactions on Information Theory, 32(5):668–679, 1986.
512
+ 414 [39] Andrews, D. F., F. R. Hampel. Robust estimates of location: Survey and advances, vol. 1280.
513
+ 415 Princeton University Press, 2015.
md/dev/OUIFPHEgJU/OUIFPHEgJU.md ADDED
The diff for this file is too large to render. See raw diff
 
md/dev/PqvMRDCJT9t/PqvMRDCJT9t.md ADDED
@@ -0,0 +1,857 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # FLOW MATCHING FOR GENERATIVE MODELING
2
+
3
+ Yaron Lipman1,2 Ricky T. Q. Chen1 Heli Ben-Hamu2 Maximilian Nickel1 Matt Le1 1Meta AI (FAIR) 2Weizmann Institute of Science
4
+
5
+ # ABSTRACT
6
+
7
+ We introduce a new paradigm for generative modeling built on Continuous Normalizing Flows (CNFs), allowing us to train CNFs at unprecedented scale. Specifically, we present the notion of Flow Matching (FM), a simulation-free approach for training CNFs based on regressing vector fields of fixed conditional probability paths. Flow Matching is compatible with a general family of Gaussian probability paths for transforming between noise and data samples—which subsumes existing diffusion paths as specific instances. Interestingly, we find that employing FM with diffusion paths results in a more robust and stable alternative for training diffusion models. Furthermore, Flow Matching opens the door to training CNFs with other, non-diffusion probability paths. An instance of particular interest is using Optimal Transport (OT) displacement interpolation to define the conditional probability paths. These paths are more efficient than diffusion paths, provide faster training and sampling, and result in better generalization. Training CNFs using Flow Matching on ImageNet leads to consistently better performance than alternative diffusion-based methods in terms of both likelihood and sample quality, and allows fast and reliable sample generation using off-the-shelf numerical ODE solvers.
8
+
9
+ # 1 INTRODUCTION
10
+
11
+ Deep generative models are a class of deep learning algorithms aimed at estimating and sampling from an unknown data distribution. The recent influx of amazing advances in generative modeling, e.g., for image generation Ramesh et al. (2022); Rombach et al. (2022), is mostly facilitated by the scalable and relatively stable training of diffusion-based models Ho et al. (2020); Song et al. (2020b). However, the restriction to simple diffusion processes leads to a rather confined space of sampling probability paths, resulting in very long training times and the need to adopt specialized methods (e.g., Song et al. (2020a); Zhang & Chen (2022)) for efficient sampling.
12
+
13
+ In this work we consider the general and deterministic framework of Continuous Normalizing Flows (CNFs; Chen et al. (2018)). CNFs are capable of modeling arbitrary probability path and are in particular known to encompass the probability paths modeled by diffusion processes (Song et al., 2021).
14
+
15
+ However, aside from diffusion that can be trained efficiently via, e.g., denoising score matching (Vincent, 2011), no scalable CNF training algorithms are known. Indeed, maximum likelihood training (e.g., Grathwohl et al. (2018)) require expensive numerical ODE simulations, while existing simulation-free methods either involve intractable integrals (Rozen et al., 2021) or biased gradients (Ben-Hamu et al., 2022).
16
+
17
+ The goal of this work is to propose Flow Matching (FM), an efficient simulation-free approach to training CNF models, allowing the adoption of general probability paths to supervise CNF training. Importantly, FM breaks the barriers for scalable CNF training beyond diffusion, and sidesteps the need to reason about diffusion processes to directly work with probability paths.
18
+
19
+ ![](images/89a2d7265bf5515ae6bdd96c42b9296f4399a3c4ea7884491774afd2867ed3d1.jpg)
20
+ Figure 1: Unconditional ImageNet-128 samples of a CNF trained using Flow Matching with Optimal Transport probability paths.
21
+
22
+ In particular, we propose the Flow Matching objective (Section 3), a simple and intuitive training objective to regress onto a target vector field that generates a desired probability path. We first show that we can construct such target vector fields through per-example (i.e., conditional) formulations. Then, inspired by denoising score matching, we show that a per-example training objective, termed Conditional Flow Matching (CFM), provides equivalent gradients and does not require explicit knowledge of the intractable target vector field. Furthermore, we discuss a general family of per-example probability paths (Section 4) that can be used for Flow Matching, which subsumes existing diffusion paths as special instances. Even on diffusion paths, we find that using FM provides more robust and stable training, and achieves superior performance compared to score matching. Furthermore, this family of probability paths also includes a particularly interesting case: the vector field that corresponds to an Optimal Transport (OT) displacement interpolant (McCann, 1997). We find that conditional OT paths are simpler than diffusion paths, forming straight line trajectories whereas diffusion paths result in curved paths. These properties seem to empirically translate to faster training, faster generation, and better performance.
23
+
24
+ We empirically validate Flow Matching and the construction via Optimal Transport paths on ImageNet, a large and highly diverse image dataset. We find that we can easily train models to achieve favorable performance in both likelihood estimation and sample quality amongst competing diffusion-based methods. Furthermore, we find that our models produce better trade-offs between computational cost and sample quality compared to prior methods. Figure 1 depicts selected unconditional ImageNet $1 2 8 \times 1 2 8$ samples from our model.
25
+
26
+ # 2 PRELIMINARIES: CONTINUOUS NORMALIZING FLOWS
27
+
28
+ Let $\mathbb { R } ^ { d }$ denote the data space with data points $x = ( x ^ { 1 } , \ldots , x ^ { d } ) \in \mathbb { R } ^ { d }$ . Two important objects we use in this paper are: the probability density path $p : [ 0 , 1 ] \times \mathbb { R } ^ { d } \mathbb { R } _ { > 0 }$ , which is a time dependent1 probability density function, i.e., $\textstyle \int p _ { t } ( x ) d x \ = \ 1$ , and a time-dependent vector field, $v : [ 0 , 1 ] \times \mathbb { R } ^ { d } \to \mathbb { R } ^ { d }$ . A vector field $v _ { t }$ can be used to construct a time-dependent diffeomorphic map, called a flow, $\phi : [ 0 , 1 ] \times \mathbb { R } ^ { d } \mathbb { R } ^ { d }$ , defined via the ordinary differential equation (ODE):
29
+
30
+ $$
31
+ \begin{array} { c } { { \displaystyle \frac { d } { d t } \phi _ { t } ( x ) = v _ { t } ( \phi _ { t } ( x ) ) } } \\ { { \phi _ { 0 } ( x ) = x } } \end{array}
32
+ $$
33
+
34
+ Previously, Chen et al. (2018) suggested modeling the vector field $v _ { t }$ with a neural network, $v _ { t } ( x ; \theta )$ , where $\theta \in \mathbb { R } ^ { p }$ are its learnable parameters, which in turn leads to a deep parametric model of the flow $\phi _ { t }$ , called a Continuous Normalizing Flow (CNF). A CNF is used to reshape a simple prior density $p _ { 0 }$ (e.g., pure noise) to a more complicated one, $p _ { 1 }$ , via the push-forward equation
35
+
36
+ $$
37
+ p _ { t } = [ \phi _ { t } ] _ { * } p _ { 0 }
38
+ $$
39
+
40
+ where the push-forward (or change of variables) operator $^ *$ is defined by
41
+
42
+ $$
43
+ [ \phi _ { t } ] _ { * } p _ { 0 } ( x ) = p _ { 0 } ( \phi _ { t } ^ { - 1 } ( x ) ) \operatorname* { d e t } \left[ \frac { \partial \phi _ { t } ^ { - 1 } } { \partial x } ( x ) \right] .
44
+ $$
45
+
46
+ A vector field $v _ { t }$ is said to generate a probability density path $p _ { t }$ if its flow $\phi _ { t }$ satisfies equation 3. One practical way to test if a vector field generates a probability path is using the continuity equation, which is a key component in our proofs, see Appendix A. We recap more information on CNFs, in particular how to compute the probability $p _ { 1 } ( x )$ at an arbitrary point $x \in \mathbb { R } ^ { d }$ in Appendix C.
47
+
48
+ # 3 FLOW MATCHING
49
+
50
+ Let $x _ { 1 }$ denote a random variable distributed according to some unknown data distribution $q ( x _ { 1 } )$ . We assume we only have access to data samples from $q ( x _ { 1 } )$ but have no access to the density function itself. Furthermore, we let $p _ { t }$ be a probability path such that $p _ { 0 } = p$ is a simple distribution, e.g., the standard normal distribution $p ( x ) = \mathcal { N } ( x | 0 , I )$ , and let $p _ { 1 }$ be approximately equal in distribution to $q$ . We will later discuss how to construct such a path. The Flow Matching objective is then designed to match this target probability path, which will allow us to flow from $p _ { 0 }$ to $p _ { 1 }$ .
51
+
52
+ Given a target probability density path $p _ { t } ( x )$ and a corresponding vector field $u _ { t } ( x )$ , which generates $p _ { t } ( x )$ , we define the Flow Matching (FM) objective as
53
+
54
+ $$
55
+ \begin{array} { r } { \mathcal { L } _ { \mathtt { F M } } ( \theta ) = \mathbb { E } _ { t , p _ { t } ( x ) } \| v _ { t } ( x ) - u _ { t } ( x ) \| ^ { 2 } , } \end{array}
56
+ $$
57
+
58
+ where $\theta$ denotes the learnable parameters of the CNF vector field $v _ { t }$ (as defined in Section 2), $t \sim$ $\boldsymbol { \mathcal { U } } [ 0 , 1 ]$ (uniform distribution), and $x \sim p _ { t } ( x )$ . Simply put, the FM loss regresses the vector field $u _ { t }$ with a neural network $v _ { t }$ . Upon reaching zero loss, the learned CNF model will generate $p _ { t } ( x )$ .
59
+
60
+ Flow Matching is a simple and attractive objective, but na¨ıvely on its own, it is intractable to use in practice since we have no prior knowledge for what an appropriate $p _ { t }$ and $u _ { t }$ are. There are many choices of probability paths that can satisfy $p _ { 1 } ( x ) \approx q \bar { ( x ) }$ , and more importantly, we generally don’t have access to a closed form $u _ { t }$ that generates the desired $p _ { t }$ . In this section, we show that we can construct both $p _ { t }$ and $u _ { t }$ using probability paths and vector fields that are only defined per sample, and an appropriate method of aggregation provides the desired $p _ { t }$ and $u _ { t }$ . Furthermore, this construction allows us to create a much more tractable objective for Flow Matching.
61
+
62
+ # 3.1 CONSTRUCTING $p _ { t } , u _ { t }$ FROM CONDITIONAL PROBABILITY PATHS AND VECTOR FIELDS
63
+
64
+ A simple way to construct a target probability path is via a mixture of simpler probability paths: Given a particular data sample $x _ { 1 }$ we denote by $p _ { t } ( x | x _ { 1 } )$ a conditional probability path such that it satisfies $p _ { 0 } ( x | x _ { 1 } ) = p ( x )$ at time $t = 0$ , and we design $p _ { 1 } ( x | x _ { 1 } )$ at $t = 1$ to be a distribution concentrated around $x = x _ { 1 }$ , e.g., $p _ { 1 } ( x | x _ { 1 } ) = \mathcal { N } ( x | x _ { 1 } , \sigma ^ { 2 } I )$ , a normal distribution with $x _ { 1 }$ mean and a sufficiently small standard deviation $\sigma > 0$ . Marginalizing the conditional probability paths over $q ( x _ { 1 } )$ give rise to the marginal probability path
65
+
66
+ $$
67
+ p _ { t } ( x ) = \int p _ { t } ( x | x _ { 1 } ) q ( x _ { 1 } ) d x _ { 1 } ,
68
+ $$
69
+
70
+ where in particular at time $t = 1$ , the marginal probability $p _ { 1 }$ is a mixture distribution that closely approximates the data distribution $q$ ,
71
+
72
+ $$
73
+ p _ { 1 } ( x ) = \int p _ { 1 } ( x | x _ { 1 } ) q ( x _ { 1 } ) d x _ { 1 } \approx q ( x ) .
74
+ $$
75
+
76
+ Interestingly, we can also define a marginal vector field, by “marginalizing” over the conditional vector fields in the following sense (we assume $p _ { t } ( x ) > 0$ for all $t$ and $x$ ):
77
+
78
+ $$
79
+ u _ { t } ( x ) = \int u _ { t } ( x | x _ { 1 } ) \frac { p _ { t } ( x | x _ { 1 } ) q ( x _ { 1 } ) } { p _ { t } ( x ) } d x _ { 1 } ,
80
+ $$
81
+
82
+ where $u _ { t } ( \cdot | x _ { 1 } ) : \mathbb { R } ^ { d } \to \mathbb { R } ^ { d }$ is a conditional vector field that generates $p _ { t } ( \cdot | x _ { 1 } )$ . It may not seem apparent, but this way of aggregating the conditional vector fields actually results in the correct vector field for modeling the marginal probability path.
83
+
84
+ Our first key observation is this:
85
+
86
+ The marginal vector field (equation 8) generates the marginal probability path (equation 6).
87
+
88
+ This provides a surprising connection between the conditional VFs (those that generate conditional probability paths) and the marginal VF (those that generate the marginal probability path). This connection allows us to break down the unknown and intractable marginal VF into simpler conditional VFs, which are much simpler to define as these only depend on a single data sample. We formalize this in the following theorem.
89
+
90
+ Theorem 1. Given vector fields $u _ { t } ( x | x _ { 1 } )$ that generate conditional probability paths $p _ { t } ( x | x _ { 1 } )$ , for any distribution $q ( x _ { 1 } )$ , the marginal vector field $u _ { t }$ in equation 8 generates the marginal probability path $p _ { t }$ in equation $6$ , i.e., $u _ { t }$ and $p _ { t }$ satisfy the continuity equation (equation 25).
91
+
92
+ The full proofs for our theorems are all provided in Appendix B. Theorem 1 can also be derived from the Diffusion Mixture Representation Theorem in Peluchetti (2021) that provides a formula for the marginal drift and diffusion coefficients in diffusion SDEs.
93
+
94
+ # 3.2 CONDITIONAL FLOW MATCHING
95
+
96
+ Unfortunately, due to the intractable integrals in the definitions of the marginal probability path and VF (equations 6 and 8), it is still intractable to compute $u _ { t }$ , and consequently, intractable to na¨ıvely compute an unbiased estimator of the original Flow Matching objective. Instead, we propose a simpler objective, which surprisingly will result in the same optima as the original objective. Specifically, we consider the Conditional Flow Matching (CFM) objective,
97
+
98
+ $$
99
+ \begin{array} { r } { \mathcal { L } _ { \mathtt { C F M } } ( \theta ) = \mathbb { E } _ { t , q ( x _ { 1 } ) , p _ { t } ( x | x _ { 1 } ) } \big | \big | v _ { t } ( x ) - u _ { t } ( x | x _ { 1 } ) \big | \big | ^ { 2 } , } \end{array}
100
+ $$
101
+
102
+ where $t \sim \mathcal { U } [ 0 , 1 ]$ , $x _ { 1 } \sim q ( x _ { 1 } )$ , and now $x \sim p _ { t } ( x | x _ { 1 } )$ . Unlike the FM objective, the CFM objective allows us to easily sample unbiased estimates as long as we can efficiently sample from $p _ { t } ( x | x _ { 1 } )$ and compute $u _ { t } ( x | x _ { 1 } )$ , both of which can be easily done as they are defined on a per-sample basis. Our second key observation is therefore:
103
+
104
+ The FM (equation 5) and CFM (equation 9) objectives have identical gradients w.r.t. $\theta$ .
105
+
106
+ That is, optimizing the CFM objective is equivalent (in expectation) to optimizing the FM objective. Consequently, this allows us to train a CNF to generate the marginal probability path $p _ { t }$ —which in particular, approximates the unknown data distribution $q$ at $t { = } 1 { - }$ without ever needing access to either the marginal probability path or the marginal vector field. We simply need to design suitable conditional probability paths and vector fields. We formalize this property in the following theorem.
107
+
108
+ Theorem 2. Assuming that $p _ { t } ( x ) > 0$ for all $x ~ \in ~ \mathbb { R } ^ { d }$ and $t \in [ 0 , 1 ]$ , then, up to a constant independent of $\theta$ , $\mathcal { L } _ { c F M }$ and $\mathcal { L } _ { \boldsymbol { F M } }$ are equal. Hence, $\nabla _ { \boldsymbol { \theta } } \mathcal { L } _ { \boldsymbol { F M } } ( \boldsymbol { \theta } ) = \nabla _ { \boldsymbol { \theta } } \mathcal { L } _ { \boldsymbol { c F M } } ( \boldsymbol { \theta } )$ .
109
+
110
+ # 4 CONDITIONAL PROBABILITY PATHS AND VECTOR FIELDS
111
+
112
+ The Conditional Flow Matching objective works with any choice of conditional probability path and conditional vector fields. In this section, we discuss the construction of $p _ { t } ( x | x _ { 1 } )$ and $u _ { t } ( x | x _ { 1 } )$ for a general family of Gaussian conditional probability paths. Namely, we consider conditional probability paths of the form
113
+
114
+ $$
115
+ p _ { t } ( x | x _ { 1 } ) = \mathcal { N } ( x \mid \mu _ { t } ( x _ { 1 } ) , \sigma _ { t } ( x _ { 1 } ) ^ { 2 } I ) ,
116
+ $$
117
+
118
+ where $\mu : [ 0 , 1 ] \times \mathbb { R } ^ { d } \mathbb { R } ^ { d }$ is the time-dependent mean of the Gaussian distribution, while $\sigma :$ $[ 0 , 1 ] \times \mathbb { R } \to \mathbb { R } _ { > 0 }$ describes a time-dependent scalar standard deviation (std). We set $\mu _ { 0 } ( x _ { 1 } ) = 0$ and $\sigma _ { 0 } ( x _ { 1 } ) = 1$ , so that all conditional probability paths converge to the same standard Gaussian noise distribution at $t = 0$ , $p ( x ) = \mathcal { N } ( x | 0 , I )$ . We then set $\mu _ { 1 } ( x _ { 1 } ) = x _ { 1 }$ and $\sigma _ { 1 } ( x _ { 1 } ) = \sigma _ { \mathrm { { m i n } } }$ , which is set sufficiently small so that $p _ { 1 } ( x | x _ { 1 } )$ is a concentrated Gaussian distribution centered at $x _ { 1 }$ .
119
+
120
+ There is an infinite number of vector fields that generate any particular probability path (e.g., by adding a divergence free component to the continuity equation, see equation 25), but the vast majority of these is due to the presence of components that leave the underlying distribution invariant—for instance, rotational components when the distribution is rotation-invariant—leading to unnecessary extra compute. We decide to use the simplest vector field corresponding to a canonical transformation for Gaussian distributions. Specifically, consider the flow (conditioned on $x _ { 1 }$ )
121
+
122
+ $$
123
+ \psi _ { t } ( x ) = \sigma _ { t } ( x _ { 1 } ) x + \mu _ { t } ( x _ { 1 } ) .
124
+ $$
125
+
126
+ When $x$ is distributed as a standard Gaussian, $\psi _ { t } ( x )$ is the affine transformation that maps to a normally-distributed random variable with mean $\mu _ { t } ( x _ { 1 } )$ and std $\sigma _ { t } ( x _ { 1 } )$ . That is to say, according to equation 4, $\psi _ { t }$ pushes the noise distribution $p _ { 0 } ( x | x _ { 1 } ) = p ( x )$ to $p _ { t } ( x | x _ { 1 } )$ , i.e.,
127
+
128
+ $$
129
+ [ \psi _ { t } ] _ { * } p ( x ) = p _ { t } ( x | x _ { 1 } ) .
130
+ $$
131
+
132
+ This flow then provides a vector field that generates the conditional probability path:
133
+
134
+ $$
135
+ \frac { d } { d t } \psi _ { t } ( x ) = u _ { t } ( \psi _ { t } ( x ) | x _ { 1 } ) .
136
+ $$
137
+
138
+ Reparameterizing $p _ { t } ( x | x _ { 1 } )$ in terms of just $x _ { 0 }$ and plugging equation 13 in the CFM loss we get
139
+
140
+ $$
141
+ \mathcal { L } _ { \mathrm { c F M } } ( \theta ) = \mathbb { E } _ { t , q ( x _ { 1 } ) , p ( x _ { 0 } ) } \Big | \Big | v _ { t } \big ( \psi _ { t } ( x _ { 0 } ) \big ) - \frac { d } { d t } \psi _ { t } ( x _ { 0 } ) \Big | \Big | ^ { 2 } .
142
+ $$
143
+
144
+ Since $\psi _ { t }$ is a simple (invertible) affine map we can use equation 13 to solve for $u _ { t }$ in a closed form.
145
+ Let $f ^ { \prime }$ denote the derivative with respect to time, i.e., $\begin{array} { r } { f ^ { \prime } \overset { \cdot } { = } \frac { d } { d t } f } \end{array}$ , for a time-dependent function $f$ .
146
+
147
+ Theorem 3. Let $p _ { t } ( x | x _ { 1 } )$ be a Gaussian probability path as in equation $I O$ , and $\psi _ { t }$ its corresponding flow map as in equation $I I$ . Then, the unique vector field that defines $\psi _ { t }$ has the form:
148
+
149
+ $$
150
+ u _ { t } ( x | x _ { 1 } ) = \frac { \sigma _ { t } ^ { \prime } ( x _ { 1 } ) } { \sigma _ { t } ( x _ { 1 } ) } \left( x - \mu _ { t } ( x _ { 1 } ) \right) + \mu _ { t } ^ { \prime } ( x _ { 1 } ) .
151
+ $$
152
+
153
+ Consequently, $u _ { t } ( x | x _ { 1 } )$ generates the Gaussian path $p _ { t } ( x | x _ { 1 } )$ .
154
+
155
+ # 4.1 SPECIAL INSTANCES OF GAUSSIAN CONDITIONAL PROBABILITY PATHS
156
+
157
+ Our formulation is fully general for arbitrary functions $\mu _ { t } ( x _ { 1 } )$ and $\sigma _ { t } ( x _ { 1 } )$ , and we can set them to any differentiable function satisfying the desired boundary conditions. We first discuss the special cases that recover probability paths corresponding to previously-used diffusion processes. Since we directly work with probability paths, we can simply depart from reasoning about diffusion processes altogether. Therefore, in the second example below, we directly formulate a probability path based on the Wasserstein-2 optimal transport solution as an interesting instance.
158
+
159
+ Example I: Diffusion conditional VFs. Diffusion models start with data points and gradually add noise until it approximates pure noise. These can be formulated as stochastic processes, which have strict requirements in order to obtain closed form representation at arbitrary times $t$ , resulting in Gaussian conditional probability paths $p _ { t } ( x | x _ { 1 } )$ with specific choices of mean $\mu _ { t } ( x _ { 1 } )$ and std $\sigma _ { t } ( x _ { 1 } )$ (Sohl-Dickstein et al., 2015; Ho et al., 2020; Song et al., 2020b). For example, the reversed (noise data) Variance Exploding (VE) path has the form
160
+
161
+ $$
162
+ p _ { t } ( x | x _ { 1 } ) = \mathcal { N } ( x | x _ { 1 } , \sigma _ { 1 - t } ^ { 2 } I ) ,
163
+ $$
164
+
165
+ where $\sigma _ { t }$ is an increasing function, $\sigma _ { 0 } = 0$ , and $\sigma _ { 1 } \gg 1$ . Next, equation 16 provides the choices of $\mu _ { t } ( x _ { 1 } ) = x _ { 1 }$ and $\sigma _ { t } ( x _ { 1 } ) = \sigma _ { 1 - t }$ . Plugging these into equation 15 of Theorem 3 we get
166
+
167
+ $$
168
+ u _ { t } ( x | x _ { 1 } ) = - \frac { \sigma _ { 1 - t } ^ { \prime } } { \sigma _ { 1 - t } } ( x - x _ { 1 } ) .
169
+ $$
170
+
171
+ The reversed (noise data) Variance Preserving (VP) diffusion path has the form
172
+
173
+ $$
174
+ p _ { t } ( x | x _ { 1 } ) = \mathcal { N } ( x \mid \alpha _ { 1 - t } x _ { 1 } , \left( 1 - \alpha _ { 1 - t } ^ { 2 } \right) I ) , \mathrm { w h e r e } \alpha _ { t } = e ^ { - \frac { 1 } { 2 } T ( t ) } , T ( t ) = \int _ { 0 } ^ { t } \beta ( s ) d s ,
175
+ $$
176
+
177
+ and $\beta$ is the noise scale function. Equation 18 provides the choices of $\mu _ { t } ( x _ { 1 } ) \ = \ \alpha _ { 1 - t } x _ { 1 }$ and $\sigma _ { t } ( x _ { 1 } ) = \sqrt { 1 - \alpha _ { 1 - t } ^ { 2 } }$ . Plugging these into equation 15 of Theorem 3 we get
178
+
179
+ $$
180
+ u _ { t } ( x | x _ { 1 } ) = \frac { \alpha _ { 1 - t } ^ { \prime } } { 1 - \alpha _ { 1 - t } ^ { 2 } } \left( \alpha _ { 1 - t } x - x _ { 1 } \right) = - \frac { T ^ { \prime } ( 1 - t ) } { 2 } \left[ \frac { e ^ { - T ( 1 - t ) } x - e ^ { - \frac { 1 } { 2 } T ( 1 - t ) } x _ { 1 } } { 1 - e ^ { - T ( 1 - t ) } } \right] .
181
+ $$
182
+
183
+ Our construction of the conditional VF $\ i \ u _ { t } \big ( \boldsymbol { x } | \boldsymbol { x } _ { 1 } \big )$ does in fact coincide with the vector field previously used in the deterministic probability flow (Song et al. (2020b), equation 13) when restricted to these conditional diffusion processes; see details in Appendix D. Nevertheless, combining the diffusion conditional VF with the Flow Matching objective offers an attractive training alternative—which we find to be more stable and robust in our experiments—to existing score matching approaches.
184
+
185
+ Another important observation is that, as these probability paths were previously derived as solutions of diffusion processes, they do not actually reach a true noise distribution in finite time. In practice, $p _ { 0 } ( x )$ is simply approximated by a suitable Gaussian distribution for sampling and likelihood evaluation. Instead, our construction provides full control over the probability path, and we can just directly set $\mu _ { t }$ and $\sigma _ { t }$ , as we will do next.
186
+
187
+ Example II: Optimal Transport conditional VFs. An arguably more natural choice for conditional probability paths is to define the mean and the std to simply change linearly in time, i.e.,
188
+
189
+ $$
190
+ \mu _ { t } ( x ) = t x _ { 1 } , \mathrm { a n d } \sigma _ { t } ( x ) = 1 - ( 1 - \sigma _ { \operatorname* { m i n } } ) t .
191
+ $$
192
+
193
+ According to Theorem 3 this path is generated by the VF
194
+
195
+ $$
196
+ u _ { t } ( x | x _ { 1 } ) = \frac { x _ { 1 } - ( 1 - \sigma _ { \operatorname* { m i n } } ) x } { 1 - ( 1 - \sigma _ { \operatorname* { m i n } } ) t } ,
197
+ $$
198
+
199
+ ![](images/1335c7404c50a3bda501acfed97e3870692f455cdf0e5ff569420338692aef09.jpg)
200
+ Figure 2: Compared to the diffusion path’s conditional score function, the OT path’s conditional vector field has constant direction in time and is arguably simpler to fit with a parametric model. Note the blue color denotes larger magnitude while red color denotes smaller magnitude.
201
+
202
+ which, in contrast to the diffusion conditional VF (equation 19), is defined for all $t \in [ 0 , 1 ]$ . The conditional flow that corresponds to $u _ { t } ( x | x _ { 1 } )$ is
203
+
204
+ $$
205
+ \psi _ { t } ( x ) = ( 1 - ( 1 - \sigma _ { \operatorname* { m i n } } ) t ) x + t x _ { 1 } ,
206
+ $$
207
+
208
+ and in this case, the CFM loss (see equations 9, 14) takes the form:
209
+
210
+ $$
211
+ \mathcal { L } _ { \mathrm { c F M } } ( \theta ) = \mathbb { E } _ { t , q ( x _ { 1 } ) , p ( x _ { 0 } ) } \Big \| v _ { t } \big ( \psi _ { t } ( x _ { 0 } ) \big ) - \Big ( x _ { 1 } - ( 1 - \sigma _ { \operatorname* { m i n } } ) x _ { 0 } \Big ) \Big \| ^ { 2 } .
212
+ $$
213
+
214
+ Allowing the mean and std to change linearly not only leads to simple and intuitive paths, but it is actually also optimal in the following sense. The conditional flow $\psi _ { t } ( x )$ is in fact the Optimal Transport (OT) displacement map between the two Gaussians $p _ { 0 } ( x | x _ { 1 } )$ and $p _ { 1 } ( x | x _ { 1 } )$ . The OT interpolant, which is a probability path, is defined to be (see Definition 1.1 in McCann (1997)):
215
+
216
+ $$
217
+ p _ { t } = [ ( 1 - t ) \mathrm { i d } + t \psi ] _ { \star } p _ { 0 }
218
+ $$
219
+
220
+ where $\psi : \mathbb { R } ^ { d } \mathbb { R } ^ { d }$ is the OT map pushing $p _ { 0 }$ to $p _ { 1 }$ , id denotes the identity map, i.e., $\operatorname { i d } ( x ) = x$ and $( 1 - t ) \mathrm { i d } + t \psi$ is called the OT displacement map. Example 1.7 in McCann (1997) shows, that in our case of two Gaussians where the first is a standard one, the OT displacement map takes the form of equation 22.
221
+
222
+ Intuitively, particles under the OT displacement map always move in straight line trajectories and with constant speed. Figure 3 depicts sampling paths for the diffusion and OT conditional VFs. Interestingly, we find that sampling trajectory from diffusion paths can “overshoot” the final sample, resulting in unnecessary backtracking, whilst the OT paths are guaranteed to stay straight.
223
+
224
+ ![](images/45f525ed726462dc8a17baf4798cdebe774a867bd01f7ef97f23a6c58a2da77f.jpg)
225
+ Figure 3: Diffusion and OT conditional trajectories.
226
+
227
+ Figure 2 compares the diffusion conditional score function (the re
228
+ gression target in a typical diffusion methods), i.e., $\nabla \log p _ { t } ( x | x _ { 1 } )$ with $p _ { t }$ defined as in equation 18, with the OT conditional VF (equation 21). The start $\left( p _ { 0 } \right)$ and end $( p _ { 1 } )$ Gaussians are identical in both examples. An interesting observation is that the OT VF has a constant direction in time, which arguably leads to a simpler regression task. This property can also be verified directly from equation 21 as the VF can be written in the form $u _ { t } ( x | x _ { 1 } ) = g ( t ) h ( x | x _ { 1 } )$ . Figure 8 in the Appendix shows a visualization of the Diffusion VF. Lastly, we note that although the conditional flow is optimal, this by no means imply that the marginal VF is an optimal transport solution. Nevertheless, we expect the marginal vector field to remain relatively simple.
229
+
230
+ # 5 RELATED WORK
231
+
232
+ Continuous Normalizing Flows were introduced in (Chen et al., 2018) as a continuous-time version of Normalizing Flows (see e.g., Kobyzev et al. (2020); Papamakarios et al. (2021) for an overview). Originally, CNFs are trained with the maximum likelihood objective, but this involves expensive ODE simulations for the forward and backward propagation, resulting in high time complexity due to the sequential nature of ODE simulations. Although some works demonstrated the capability of CNF generative models for image synthesis (Grathwohl et al., 2018), scaling up to very high dimensional images is inherently difficult. A number of works attempted to regularize the ODE to be easier to solve, e.g., using augmentation (Dupont et al., 2019), adding regularization terms (Yang & Karniadakis, 2019; Finlay et al., 2020; Onken et al., 2021; Tong et al., 2020; Kelly et al., 2020), or stochastically sampling the integration interval (Du et al., 2022). These works merely aim to regularize the ODE but do not change the fundamental training algorithm.
233
+
234
+ ![](images/730cd8e2f3d4e2c634c2621f1890aaa304191d480cfd3f7f6fb9e7ba0d6f1d75.jpg)
235
+ Figure 4: (left) Trajectories of CNFs trained with different objectives on 2D checkerboard data. The OT path introduces the checkerboard pattern much earlier, while FM results in more stable training. (right) FM with OT results in more efficient sampling, solved using the midpoint scheme.
236
+
237
+ In order to speed up CNF training, some works have developed simulation-free CNF training frameworks by explicitly designing the target probability path and the dynamics. For instance, Rozen et al. (2021) consider a linear interpolation between the prior and the target density but involves integrals that were difficult to estimate in high dimensions, while Ben-Hamu et al. (2022) consider general probability paths similar to this work but suffers from biased gradients in the stochastic minibatch regime. In contrast, the Flow Matching framework allows simulation-free training with unbiased gradients and readily scales to very high dimensions.
238
+
239
+ Another approach to simulation-free training relies on the construction of a diffusion process to indirectly define the target probability path (Sohl-Dickstein et al., 2015; Ho et al., 2020; Song & Ermon, 2019). Song et al. (2020b) shows that diffusion models are trained using denoising score matching (Vincent, 2011), a conditional objective that provides unbiased gradients with respect to the score matching objective. Conditional Flow Matching draws inspiration from this result, but generalizes to matching vector fields directly. Due to the ease of scalability, diffusion models have received increased attention, producing a variety of improvements such as loss-rescaling (Song et al., 2021), adding classifier guidance along with architectural improvements (Dhariwal & Nichol, 2021), and learning the noise schedule (Nichol & Dhariwal, 2021; Kingma et al., 2021). However, (Nichol & Dhariwal, 2021) and (Kingma et al., 2021) only consider a restricted setting of Gaussian conditional paths defined by simple diffusion processes with a single parameter—in particular, it does not include our conditional OT path. In an another line of works, (De Bortoli et al., 2021; Wang et al., 2021; Peluchetti, 2021) proposed finite time diffusion constructions via diffusion bridges theory resolving the approximation error incurred by infinite time denoising constructions. While existing works make use of a connection between diffusion processes and continuous normalizing flows with the same probability path (Maoutsa et al., 2020b; Song et al., 2020b; 2021), our work allows us to generalize beyond the class of probability paths modeled by simple diffusion. With our work, it is possible to completely sidestep the diffusion process construction and reason directly with probability paths, while still retaining efficient training and log-likelihood evaluations. Lastly, concurrently to our work (Liu et al., 2022; Albergo & Vanden-Eijnden, 2022) arrived at similar conditional objectives for simulation-free training of CNFs, while Neklyudov et al. (2023) derived an implicit objective when $u _ { t }$ is assumed to be a gradient field.
240
+
241
+ # 6 EXPERIMENTS
242
+
243
+ We explore the empirical benefits of using Flow Matching on the image datasets of CIFAR10 (Krizhevsky et al., 2009) and ImageNet at resolutions 32, 64, and 128 (Chrabaszcz et al., 2017; Deng et al., 2009). We also ablate the choice of diffusion path in Flow Matching, particularly between the standard variance preserving diffusion path and the optimal transport path. We discuss how sample generation is improved by directly parameterizing the generating vector field and using the Flow Matching objective. Lastly we show Flow Matching can also be used in the conditional generation setting. Unless otherwise specified, we evaluate likelihood and samples from the model using dopri5 (Dormand & Prince, 1980) at absolute and relative tolerances of 1e-5. Generated samples can be found in the Appendix, and all implementation details are in Appendix E.
244
+
245
+ <table><tr><td rowspan="2">Model</td><td colspan="3">CIFAR-10</td><td colspan="3">ImageNet 32×32</td><td colspan="3">ImageNet 64×64</td><td></td><td colspan="2">ImageNet 128×128</td></tr><tr><td>NLL↓</td><td>FID↓</td><td>NFE↓</td><td>NLL↓</td><td>FID↓</td><td>NFE↓</td><td>NLL↓</td><td>FID↓</td><td>NFE↓</td><td>Model</td><td>NLL↓</td><td>FID↓</td></tr><tr><td>Ablations</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>MGAN (Hoang etal.,2018)</td><td>1</td><td>58.9</td></tr><tr><td>DDPM</td><td>3.12</td><td>7.48</td><td>274</td><td>3.54</td><td>6.99</td><td>262</td><td>3.32</td><td>17.36</td><td>264</td><td>PacGAN2 (Lin et a.,2018)</td><td>=</td><td>57.5</td></tr><tr><td>Score Matching</td><td>3.16</td><td>19.94</td><td>242</td><td>3.56</td><td>5.68</td><td>178</td><td>3.40</td><td>19.74</td><td>441</td><td>Logo-GAN-AE(Sag etal,018)</td><td>一</td><td>50.9</td></tr><tr><td>ScoreFlow</td><td>3.09</td><td>20.78</td><td>428</td><td>3.55</td><td>14.14</td><td>195</td><td>3.36</td><td>24.95</td><td>601</td><td>Self-cond. GAN (Lucic e al.,2019)</td><td>一</td><td>41.7</td></tr><tr><td>Ours</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>Uncond.BigGAN (Lueic etal,19)</td><td></td><td>25.3</td></tr><tr><td>FM W/ Diffusion</td><td>3.10</td><td>8.06</td><td>183</td><td>3.54</td><td>6.37</td><td>193</td><td>3.33</td><td>16.88</td><td>187</td><td>PGMGAN (Armandpour et al.,2021)</td><td></td><td>21.7</td></tr><tr><td>FM W/OT</td><td>2.99</td><td>6.35</td><td>142</td><td>3.53</td><td>5.02</td><td>122</td><td>3.31</td><td>14.45</td><td>138</td><td>FM W/OT</td><td>2.90</td><td>20.9</td></tr></table>
246
+
247
+ Table 1: Likelihood (BPD), quality of generated samples (FID), and evaluation time (NFE) for the same model trained with different methods.
248
+
249
+ ![](images/3348602332065aba7df6510ef6c9dcf1f31d1e1f70730d577577f5cf6e06f403.jpg)
250
+ Figure 6: Sample paths from the same initial noise with models trained on ImageNet $6 4 \times 6 4$ . The OT path reduces noise roughly linearly, while diffusion paths visibly remove noise only towards the end of the path. Note also the differences between the generated images.
251
+
252
+ # 6.1 DENSITY MODELING AND SAMPLE QUALITY ON IMAGENET
253
+
254
+ We start by comparing the same model architecture, i.e., the U-Net architecture from Dhariwal & Nichol (2021) with minimal changes, trained on CIFAR-10, and ImageNet 32/64 with different popular diffusion-based losses: DDPM from (Ho et al., 2020), Score Matching (SM) (Song et al., 2020b), and Score Flow (SF) (Song et al., 2021); see Appendix E.1 for exact details. Table 1 (left) summarizes our results alongside these baselines reporting negative log-likelihood (NLL) in units of bits per dimension (BPD), sample quality as measured by the Frechet Inception Distance (FID; Heusel et al. (2017)), and averaged number of function evaluations (NFE) required for the adaptive solver to reach its a prespecified numerical tolerance, averaged over $5 0 \mathrm { k }$ samples. All models are trained using the same architecture, hyperparameter values and number of training iterations, where baselines are allowed more iterations for better convergence. Note that these are unconditional models. On both CIFAR-10 and ImageNet, FM-OT consistently obtains best results across all our quantitative measures compared to competing methods. We are noticing a higher that usual FID performance in CIFAR-10 compared to previous works (Ho et al., 2020; Song et al., 2020b; 2021) that can possibly be explained by the fact that our used architecture was not optimized for CIFAR-10.
255
+
256
+ Secondly, Table 1 (right) compares a model trained using Flow Matching with the OT path on ImageNet at resolution $1 2 8 \times 1 2 8$ . Our FID is state-of-the-art with the exception of IC-GAN (Casanova et al., 2021) which uses conditioning with a self-supervised ResNet50 model, and therefore is left out of this table. Figures 11, 12, 13 in the Appendix show non-curated samples from these models.
257
+
258
+ Faster training. While existing works train diffusion models with a very high number of iterations (e.g., $1 . 3 \mathrm { m }$ and $1 0 \mathrm { m }$ iterations are reported by Score Flow and VDM, respectively), we find that Flow Matching generally converges much faster. Figure 5 shows FID curves during training of Flow Matching and all baselines for ImageNet $6 4 \times 6 4$ ; FM-OT is able to lower the FID faster and to a greater extent than the alternatives. For ImageNet-128 Dhariwal & Nichol (2021) train for $4 . 3 6 \mathrm { m }$ iterations with batch size 256, while FM (with $2 5 \%$ larger model) used $5 0 0 \mathrm { k }$ iterations with batch size $1 . 5 \mathrm { k } .$ , i.e., $33 \%$ less image throughput; see Table 3 for exact details. Furthermore, the cost of sampling from a model can drastically change during training for score matching, whereas the sampling cost stays constant when training with Flow Matching (Figure 10 in Appendix).
259
+
260
+ ![](images/efb03c36b63c672277f0cbd4eeb7bb035945f2981aaf08e10a378e6b6bb08518.jpg)
261
+ Figure 5: Image quality during training, ImageNet $6 4 \times 6 4$ .
262
+
263
+ # 6.2 SAMPLING EFFICIENCY
264
+
265
+ For sampling, we first draw a random noise sample $x _ { 0 } \sim \mathcal { N } ( 0 , I )$ then compute $\phi _ { 1 } ( x _ { 0 } )$ by solving equation 1 with the trained VF, $v _ { t }$ , on the interval $t \in [ 0 , 1 ]$ using an ODE solver. While diffusion models can also be sampled through an SDE formulation, this can be highly inefficient and many methods that propose fast samplers (e.g., Song et al. (2020a); Zhang & Chen (2022)) directly make use of the ODE perspective (see Appendix D). In part, this is due to ODE solvers being much more efficient—yielding lower error at similar computational costs (Kloeden et al., 2012)—and the multitude of available ODE solver schemes. When compared to our ablation models, we find that models trained using Flow Matching with the OT path always result in the most efficient sampler, regardless of ODE solver, as demonstrated next.
266
+
267
+ ![](images/d1afc5e0388f7cf7d6642a4f4574fe08ca41414fb88153f5ff7860879984dd6f.jpg)
268
+ Figure 7: Flow Matching, especially when using OT paths, allows us to use fewer evaluations for sampling while retaining similar numerical error (left) and sample quality (right). Results are shown for models trained on ImageNet $3 2 \times 3 2$ , and numerical errors are for the midpoint scheme.
269
+
270
+ Sample paths. We first qualitatively visualize the difference in sampling paths between diffusion and OT. Figure 6 shows samples from ImageNet-64 models using identical random seeds, where we find that the OT path model starts generating images sooner than the diffusion path models, where noise dominates the image until the very last time point. We additionally depict the probability density paths in 2D generation of a checkerboard pattern, Figure 4 (left), noticing a similar trend.
271
+
272
+ Low-cost samples. We next switch to fixed-step solvers and compare low $( \leq 1 0 0 )$ NFE samples computed with the ImageNet-32 models from Table 1. In Figure 7 (left), we compare the per-pixel MSE of low NFE solutions compared with $1 0 0 0 ~ \mathrm { N F E }$ solutions (we use 256 random noise seeds), and notice that the FM with OT model produces the best numerical error, in terms of computational cost, requiring roughly only $60 \%$ of the NFEs to reach the same error threshold as diffusion models. Secondly, Figure 7 (right) shows how FID changes as a result of the computational cost, where we find FM with OT is able to achieve decent FID even at very low NFE values, producing better tradeoff between sample quality and cost compared to ablated models. Figure 4 (right) shows low-cost sampling effects for the 2D checkerboard experiment.
273
+
274
+ # 6.3 CONDITIONAL SAMPLING FROM LOW-RESOLUTION IMAGES
275
+
276
+ Lastly, we experimented with Flow Matching for condi
277
+ tional image generation. In particular, upsampling images
278
+ from $6 4 \times 6 4$ to $2 5 6 \times 2 5 6$ . We follow the evaluation proce
279
+ dure in (Saharia et al., 2022) and compute the FID of the
280
+ upsampled validation images; baselines include reference
281
+ (FID of original validation set), and regression. Results
282
+ are in Table 2. Upsampled image samples are shown in
283
+ Figures 14, 15 in the Appendix. FM-OT achieves simi
284
+ lar PSNR and SSIM values to (Saharia et al., 2022) while
285
+ considerably improving on FID and IS, which as argued by (Saharia et al., 2022) is a better indication
286
+
287
+ of generation quality.
288
+
289
+ Table 2: Image super-resolution on the ImageNet validation set.
290
+
291
+ <table><tr><td>Model</td><td>FID↓</td><td>IS↑</td><td>PSNR↑</td><td>SSIM↑</td></tr><tr><td>Reference</td><td>1.9</td><td>240.8</td><td>1</td><td>一</td></tr><tr><td>Regression</td><td>15.2</td><td>121.1</td><td>27.9</td><td>0.801</td></tr><tr><td>SR3 (Saharia et al,22)</td><td>5.2</td><td>180.1</td><td>26.4</td><td>0.762</td></tr><tr><td>FM W/OT</td><td>3.4</td><td>200.8</td><td>24.7</td><td>0.747</td></tr></table>
292
+
293
+ # 7 CONCLUSION
294
+
295
+ We introduced Flow Matching, a new simulation-free framework for training Continuous Normalizing Flow models, relying on conditional constructions to effortlessly scale to very high dimensions. Furthermore, the FM framework provides an alternative view on diffusion models, and suggests forsaking the stochastic/diffusion construction in favor of more directly specifying the probability path, allowing us to, e.g., construct paths that allow faster sampling and/or improve generation. We experimentally showed the ease of training and sampling when using the Flow Matching framework, and in the future, we expect FM to open the door to allowing a multitude of probability paths (e.g., non-isotropic Gaussians or more general kernels altogether).
296
+
297
+ # SOCIAL RESPONSIBILITY
298
+
299
+ Along side its many positive applications, image generation can also be used for harmful proposes. Using content-controlled training sets and image validation/classification can help reduce these uses. Furthermore, the energy demand for training large deep learning models is increasing at a rapid pace (Amodei et al., 2018; Thompson et al., 2020), focusing on methods that are able to train using less gradient updates / image throughput can lead to significant time and energy savings.
300
+
301
+ # ACKNOWLEDGEMENTS
302
+
303
+ We thank Qinqing Zheng for her feedback. HB is supported by a grant from Israel CHE Program for Data Science Research Centers. Additionally, we acknowledge the Python community (Van Rossum & Drake Jr, 1995; Oliphant, 2007) for developing the core set of tools that enabled this work, including PyTorch (Paszke et al., 2019), PyTorch Lightning (Falcon & team, 2019), Hydra (Yadan, 2019), Jupyter (Kluyver et al., 2016), Matplotlib (Hunter, 2007), seaborn (Waskom et al., 2018), numpy (Oliphant, 2006; Van Der Walt et al., 2011), SciPy (Jones et al., 2014), and torchdiffeq (Chen, 2018).
304
+
305
+ # REFERENCES
306
+
307
+ Michael S Albergo and Eric Vanden-Eijnden. Building normalizing flows with stochastic interpolants. arXiv preprint arXiv:2209.15571, 2022.
308
+
309
+ Dario Amodei, Danny Hernandez, Girish SastryJack, Jack Clark, Greg Brockman, and Ilya Sutskever. Ai and compute. https://openai.com/blog/ai-and-compute/, 2018.
310
+
311
+ Mohammadreza Armandpour, Ali Sadeghian, Chunyuan Li, and Mingyuan Zhou. Partition-guided gans. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 5099–5109, 2021.
312
+
313
+ Heli Ben-Hamu, Samuel Cohen, Joey Bose, Brandon Amos, Aditya Grover, Maximilian Nickel, Ricky T. Q. Chen, and Yaron Lipman. Matching normalizing flows and probability paths on manifolds. arXiv preprint arXiv:2207.04711, 2022.
314
+
315
+ Arantxa Casanova, Marlene Careil, Jakob Verbeek, Michal Drozdzal, and Adriana Romero Soriano. Instance-conditioned gan. Advances in Neural Information Processing Systems, 34:27517–27529, 2021.
316
+
317
+ Ricky T. Q. Chen. torchdiffeq, 2018. URL https://github.com/rtqichen/ torchdiffeq.
318
+
319
+ Ricky T. Q. Chen, Yulia Rubanova, Jesse Bettencourt, and David K Duvenaud. Neural ordinary differential equations. Advances in neural information processing systems, 31, 2018.
320
+
321
+ Patryk Chrabaszcz, Ilya Loshchilov, and Frank Hutter. A downsampled variant of imagenet as an alternative to the cifar datasets. arXiv preprint arXiv:1707.08819, 2017.
322
+
323
+ Valentin De Bortoli, James Thornton, Jeremy Heng, and Arnaud Doucet. Diffusion schrodinger ¨ bridge with applications to score-based generative modeling. (arXiv:2106.01357), Dec 2021. doi: 10.48550/arXiv.2106.01357. URL http://arxiv.org/abs/2106.01357. arXiv:2106.01357 [cs, math, stat].
324
+
325
+ 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, 2009. doi: 10.1109/CVPR.2009.5206848.
326
+
327
+ Prafulla Dhariwal and Alexander Quinn Nichol. Diffusion models beat GANs on image synthesis. In A. Beygelzimer, Y. Dauphin, P. Liang, and J. Wortman Vaughan (eds.), Advances in Neural Information Processing Systems, 2021. URL https://openreview.net/forum?id= AAWuCvzaVt.
328
+
329
+ John R Dormand and Peter J Prince. A family of embedded runge-kutta formulae. Journal of computational and applied mathematics, 6(1):19–26, 1980.
330
+
331
+ Shian Du, Yihong Luo, Wei Chen, Jian Xu, and Delu Zeng. To-flow: Efficient continuous normalizing flows with temporal optimization adjoint with moving speed, 2022. URL https: //arxiv.org/abs/2203.10335.
332
+
333
+ Emilien Dupont, Arnaud Doucet, and Yee Whye Teh. Augmented neural odes. 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/ 21be9a4bd4f81549a9d1d241981cec3c-Paper.pdf.
334
+
335
+ William Falcon and The PyTorch Lightning team. Pytorch lightning, 2019. URL https:// github.com/Lightning-AI/lightning.
336
+
337
+ Chris Finlay, Jorn-Henrik Jacobsen, Levon Nurbekyan, and Adam M. Oberman. How to train your ¨ neural ode: the world of jacobian and kinetic regularization. In ICML, pp. 3154–3164, 2020. URL http://proceedings.mlr.press/v119/finlay20a.html.
338
+
339
+ Will Grathwohl, Ricky T. Q. Chen, Jesse Bettencourt, Ilya Sutskever, and David Duvenaud. Ffjord: Free-form continuous dynamics for scalable reversible generative models, 2018. URL https: //arxiv.org/abs/1810.01367.
340
+
341
+ 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.
342
+
343
+ Jonathan Ho, Ajay Jain, and Pieter Abbeel. Denoising diffusion probabilistic models. Advances in Neural Information Processing Systems, 33:6840–6851, 2020.
344
+
345
+ Quan Hoang, Tu Dinh Nguyen, Trung Le, and Dinh Phung. Mgan: Training generative adversarial nets with multiple generators. In International conference on learning representations, 2018.
346
+
347
+ John D Hunter. Matplotlib: A 2d graphics environment. Computing in science & engineering, 9(3): 90, 2007.
348
+
349
+ Eric Jones, Travis Oliphant, and Pearu Peterson. $\{ \mathrm { S c i P y } \}$ : Open source scientific tools for $\{ { \mathrm { P y t h o n } } \}$ . 2014.
350
+
351
+ Jacob Kelly, Jesse Bettencourt, Matthew J Johnson, and David K Duvenaud. Learning differential equations that are easy to solve. Advances in Neural Information Processing Systems, 33:4370– 4380, 2020.
352
+
353
+ Diederik P Kingma, Tim Salimans, Ben Poole, and Jonathan Ho. Variational diffusion models. In A. Beygelzimer, Y. Dauphin, P. Liang, and J. Wortman Vaughan (eds.), Advances in Neural Information Processing Systems, 2021. URL https://openreview.net/forum?id= 2LdBqxc1Yv.
354
+
355
+ Peter Eris Kloeden, Eckhard Platen, and Henri Schurz. Numerical solution of SDE through computer experiments. Springer Science & Business Media, 2012.
356
+
357
+ Thomas Kluyver, Benjamin Ragan-Kelley, Fernando Perez, Brian E Granger, Matthias Bussonnier, ´ Jonathan Frederic, Kyle Kelley, Jessica B Hamrick, Jason Grout, Sylvain Corlay, et al. Jupyter notebooks-a publishing format for reproducible computational workflows. In ELPUB, pp. 87–90, 2016.
358
+
359
+ Ivan Kobyzev, Simon JD Prince, and Marcus A Brubaker. Normalizing flows: An introduction and review of current methods. IEEE transactions on pattern analysis and machine intelligence, 43 (11):3964–3979, 2020.
360
+
361
+ Alex Krizhevsky, Geoffrey Hinton, et al. Learning multiple layers of features from tiny images. 2009.
362
+
363
+ Zinan Lin, Ashish Khetan, Giulia Fanti, and Sewoong Oh. Pacgan: The power of two samples in generative adversarial networks. Advances in neural information processing systems, 31, 2018.
364
+
365
+ Xingchao Liu, Chengyue Gong, and Qiang Liu. Flow straight and fast: Learning to generate and transfer data with rectified flow. arXiv preprint arXiv:2209.03003, 2022.
366
+
367
+ Mario Luciˇ c, Michael Tschannen, Marvin Ritter, Xiaohua Zhai, Olivier Bachem, and Sylvain Gelly. ´ High-fidelity image generation with fewer labels. In International conference on machine learning, pp. 4183–4192. PMLR, 2019.
368
+
369
+ Dimitra Maoutsa, Sebastian Reich, and Manfred Opper. Interacting particle solutions of fokker–planck equations through gradient–log–density estimation. Entropy, 22(8):802, jul 2020a. doi: 10.3390/e22080802. URL https://doi.org/10.3390%2Fe22080802.
370
+
371
+ Dimitra Maoutsa, Sebastian Reich, and Manfred Opper. Interacting particle solutions of fokker– planck equations through gradient–log–density estimation. Entropy, 22(8):802, 2020b.
372
+
373
+ Robert J McCann. A convexity principle for interacting gases. Advances in mathematics, 128(1): 153–179, 1997.
374
+
375
+ Kirill Neklyudov, Daniel Severo, and Alireza Makhzani. Action matching: A variational method for learning stochastic dynamics from samples, 2023. URL https://openreview.net/ forum?id=T6HPzkhaKeS.
376
+
377
+ Alexander Quinn Nichol and Prafulla Dhariwal. Improved denoising diffusion probabilistic models. In International Conference on Machine Learning, pp. 8162–8171. PMLR, 2021.
378
+
379
+ Travis E Oliphant. A guide to NumPy, volume 1. Trelgol Publishing USA, 2006.
380
+
381
+ Travis E Oliphant. Python for scientific computing. Computing in Science & Engineering, 9(3): 10–20, 2007.
382
+
383
+ Derek Onken, Samy Wu Fung, Xingjian Li, and Lars Ruthotto. Ot-flow: Fast and accurate continuous normalizing flows via optimal transport. Proceedings of the AAAI Conference on Artificial Intelligence, 35(10):9223–9232, May 2021. URL https://ojs.aaai.org/index.php/ AAAI/article/view/17113.
384
+
385
+ George Papamakarios, Eric T Nalisnick, Danilo Jimenez Rezende, Shakir Mohamed, and Balaji Lakshminarayanan. Normalizing flows for probabilistic modeling and inference. J. Mach. Learn. Res., 22(57):1–64, 2021.
386
+
387
+ 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, highperformance deep learning library. In Advances in neural information processing systems, pp. 8026–8037, 2019.
388
+
389
+ Stefano Peluchetti. Non-denoising forward-time diffusions. 2021.
390
+
391
+ Aditya Ramesh, Prafulla Dhariwal, Alex Nichol, Casey Chu, and Mark Chen. Hierarchical textconditional image generation with clip latents. arXiv preprint arXiv:2204.06125, 2022.
392
+
393
+ 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.
394
+
395
+ Noam Rozen, Aditya Grover, Maximilian Nickel, and Yaron Lipman. Moser flow: Divergencebased generative modeling on manifolds. In A. Beygelzimer, Y. Dauphin, P. Liang, and J. Wortman Vaughan (eds.), Advances in Neural Information Processing Systems, 2021. URL https://openreview.net/forum?id=qGvMv3undNJ.
396
+
397
+ Alexander Sage, Eirikur Agustsson, Radu Timofte, and Luc Van Gool. Logo synthesis and manipulation with clustered generative adversarial networks. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 5879–5888, 2018.
398
+
399
+ Chitwan Saharia, Jonathan Ho, William Chan, Tim Salimans, David J Fleet, and Mohammad Norouzi. Image super-resolution via iterative refinement. IEEE Transactions on Pattern Analysis and Machine Intelligence, 2022.
400
+
401
+ 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.
402
+
403
+ Jiaming Song, Chenlin Meng, and Stefano Ermon. Denoising diffusion implicit models. arXiv preprint arXiv:2010.02502, 2020a.
404
+
405
+ Yang Song and Stefano Ermon. Generative modeling by estimating gradients of the data distribution. 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/ 3001ef257407d5a371a96dcd947c7d93-Paper.pdf.
406
+
407
+ 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, 2020b.
408
+
409
+ Yang Song, Conor Durkan, Iain Murray, and Stefano Ermon. Maximum likelihood training of scorebased diffusion models. In Thirty-Fifth Conference on Neural Information Processing Systems, 2021.
410
+
411
+ Neil C Thompson, Kristjan Greenewald, Keeheon Lee, and Gabriel F Manso. The computational limits of deep learning. arXiv preprint arXiv:2007.05558, 2020.
412
+
413
+ Alexander Tong, Jessie Huang, Guy Wolf, David Van Dijk, and Smita Krishnaswamy. Trajectorynet: A dynamic optimal transport network for modeling cellular dynamics. In International conference on machine learning, pp. 9526–9536. PMLR, 2020.
414
+
415
+ Stefan Van Der Walt, S Chris Colbert, and Gael Varoquaux. The numpy array: a structure for efficient numerical computation. Computing in Science & Engineering, 13(2):22, 2011.
416
+
417
+ Guido Van Rossum and Fred L Drake Jr. Python reference manual. Centrum voor Wiskunde en Informatica Amsterdam, 1995.
418
+
419
+ Cedric Villani. ´ Optimal transport: old and new, volume 338. Springer, 2009.
420
+
421
+ Pascal Vincent. A connection between score matching and denoising autoencoders. Neural computation, 23(7):1661–1674, 2011.
422
+
423
+ Gefei Wang, Yuling Jiao, Qian Xu, Yang Wang, and Can Yang. Deep generative learning via schrodinger bridge. (arXiv:2106.10410), Jul 2021. doi: 10.48550/arXiv.2106.10410. URL ¨ http://arxiv.org/abs/2106.10410. arXiv:2106.10410 [cs].
424
+
425
+ Michael Waskom, Olga Botvinnik, Drew O’Kane, Paul Hobson, Joel Ostblom, Saulius Lukauskas, David C Gemperline, Tom Augspurger, Yaroslav Halchenko, John B. Cole, Jordi Warmenhoven, Julian de Ruiter, Cameron Pye, Stephan Hoyer, Jake Vanderplas, Santi Villalba, Gero Kunter, Eric Quintero, Pete Bachant, Marcel Martin, Kyle Meyer, Alistair Miles, Yoav Ram, Thomas Brunner, Tal Yarkoni, Mike Lee Williams, Constantine Evans, Clark Fitzgerald, Brian, and Adel Qalieh. mwaskom/seaborn: v0.9.0 (july 2018), July 2018. URL https://doi.org/10. 5281/zenodo.1313201.
426
+
427
+ Omry Yadan. Hydra - a framework for elegantly configuring complex applications. Github, 2019. URL https://github.com/facebookresearch/hydra.
428
+
429
+ Liu Yang and George E. Karniadakis. Potential flow generator with $\$ 123$ optimal transport regularity for generative models. CoRR, abs/1908.11462, 2019. URL http://arxiv.org/abs/ 1908.11462.
430
+
431
+ Qinsheng Zhang and Yongxin Chen. Fast sampling of diffusion models with exponential integrator. arXiv preprint arXiv:2204.13902, 2022.
432
+
433
+ # A THE CONTINUITY EQUATION
434
+
435
+ One method of testing if a vector field $v _ { t }$ generates a probability path $p _ { t }$ is the continuity equation (Villani, 2009). It is a Partial Differential Equation (PDE) providing a necessary and sufficient condition to ensuring that a vector field $v _ { t }$ generates $p _ { t }$ ,
436
+
437
+ $$
438
+ \frac { d } { d t } p _ { t } ( x ) + \mathrm { d i v } ( p _ { t } ( x ) v _ { t } ( x ) ) = 0 ,
439
+ $$
440
+
441
+ where the divergence operator, div, is defined with respect to the spatial variable $\boldsymbol { x } = ( x ^ { 1 } , \dots , x ^ { d } )$ , i.e., div = Pdi=1 ∂∂xi .
442
+
443
+ # B THEOREM PROOFS
444
+
445
+ Theorem 1. Given vector fields $u _ { t } ( x | x _ { 1 } )$ that generate conditional probability paths $p _ { t } ( x | x _ { 1 } )$ , for any distribution $q ( x _ { 1 } )$ , the marginal vector field $u _ { t }$ in equation 8 generates the marginal probability path $p _ { t }$ in equation $6$ , i.e., $u _ { t }$ and $p _ { t }$ satisfy the continuity equation (equation 25).
446
+
447
+ Proof. To verify this, we check that $p _ { t }$ and $u _ { t }$ satisfy the continuity equation (equation 25):
448
+
449
+ $$
450
+ \begin{array} { l } { \displaystyle \frac { d } { d t } p _ { t } ( x ) = \int \Big ( \frac { d } { d t } p _ { t } ( x | x _ { 1 } ) \Big ) q ( x _ { 1 } ) d x _ { 1 } = - \int \mathrm { d i v } \Big ( u _ { t } ( x | x _ { 1 } ) p _ { t } ( x | x _ { 1 } ) \Big ) q ( x _ { 1 } ) d x _ { 1 } } \\ { \displaystyle \qquad = - \mathrm { d i v } \Big ( \int u _ { t } ( x | x _ { 1 } ) p _ { t } ( x | x _ { 1 } ) q ( x _ { 1 } ) d x _ { 1 } \Big ) = - \mathrm { d i v } \Big ( u _ { t } ( x ) p _ { t } ( x ) \Big ) , } \end{array}
451
+ $$
452
+
453
+ where in the second equality we used the fact that $u _ { t } ( \cdot | x _ { 1 } )$ generates $p _ { t } ( \cdot | x _ { 1 } )$ , in the last equality we used equation 8. Furthermore, the first and third equalities are justified by assuming the integrands satisfy the regularity conditions of the Leibniz Rule (for exchanging integration and differentiation).
454
+
455
+ Theorem 2. Assuming that $p _ { t } ( x ) > 0$ for all $x ~ \in ~ \mathbb { R } ^ { d }$ and $t \in [ 0 , 1 ]$ , then, up to a constant independent of $\theta$ , $\mathcal { L } _ { \scriptscriptstyle C F M }$ and $\mathcal { L } _ { \boldsymbol { F M } }$ are equal. Hence, $\nabla _ { \boldsymbol { \theta } } \mathcal { L } _ { \boldsymbol { F M } } ( \boldsymbol { \theta } ) = \nabla _ { \boldsymbol { \theta } } \mathcal { L } _ { \boldsymbol { c F M } } ( \boldsymbol { \theta } )$ .
456
+
457
+ Proof. To ensure existence of all integrals and to allow the changing of integration order (by Fubini’s Theorem) in the following we assume that $q ( x )$ and $p _ { t } ( x | x _ { 1 } )$ are decreasing to zero at a sufficient speed as $\| x \| \to \infty$ , and that $u _ { t } , v _ { t } , \nabla _ { \theta } v _ { t }$ are bounded.
458
+
459
+ First, using the standard bilinearity of the 2-norm we have that
460
+
461
+ $$
462
+ \begin{array} { c } { { \left\| v _ { t } ( x ) - u _ { t } ( x ) \right\| ^ { 2 } = \left\| v _ { t } ( x ) \right\| ^ { 2 } - 2 \left. v _ { t } ( x ) , u _ { t } ( x ) \right. + \left\| u _ { t } ( x ) \right\| ^ { 2 } } } \\ { { \left\| v _ { t } ( x ) - u _ { t } ( x | x _ { 1 } ) \right\| ^ { 2 } = \left\| v _ { t } ( x ) \right\| ^ { 2 } - 2 \left. v _ { t } ( x ) , u _ { t } ( x | x _ { 1 } ) \right. + \left\| u _ { t } ( x | x _ { 1 } ) \right\| ^ { 2 } } } \end{array}
463
+ $$
464
+
465
+ Next, remember that $u _ { t }$ is independent of $\theta$ and note that
466
+
467
+ $$
468
+ \begin{array} { l } { \displaystyle \mathbb { E } _ { p _ { t } ( x ) } \| v _ { t } ( x ) \| ^ { 2 } = \int \| v _ { t } ( x ) \| ^ { 2 } p _ { t } ( x ) d x = \int \| v _ { t } ( x ) \| ^ { 2 } p _ { t } ( x | x _ { 1 } ) q ( x _ { 1 } ) d x _ { 1 } d x } \\ { \displaystyle \qquad = \mathbb { E } _ { q ( x _ { 1 } ) , p _ { t } ( x | x _ { 1 } ) } \| v _ { t } ( x ) \| ^ { 2 } , } \end{array}
469
+ $$
470
+
471
+ where in the second equality we use equation 6, and in the third equality we change the order of integration. Next,
472
+
473
+ $$
474
+ \begin{array} { l } { \mathbb { E } _ { p _ { t } ( x ) } \left. v _ { t } ( x ) , u _ { t } ( x ) \right. = \displaystyle \int \left. v _ { t } ( x ) , \frac { \int u _ { t } ( x | x _ { 1 } ) p _ { t } ( x | x _ { 1 } ) q ( x _ { 1 } ) d x _ { 1 } } { p _ { t } ( x ) } \right. p _ { t } ( x ) d x } \\ { \displaystyle \qquad = \int \left. v _ { t } ( x ) , \int u _ { t } ( x | x _ { 1 } ) p _ { t } ( x | x _ { 1 } ) q ( x _ { 1 } ) d x _ { 1 } \right. d x } \\ { \displaystyle \qquad = \int \left. v _ { t } ( x ) , u _ { t } ( x | x _ { 1 } ) \right. p _ { t } ( x | x _ { 1 } ) q ( x _ { 1 } ) d x _ { 1 } d x } \\ { \displaystyle \qquad = \mathbb { E } _ { q ( x _ { 1 } ) , p _ { t } ( x | x _ { 1 } ) } \left. v _ { t } ( x ) , u _ { t } ( x | x _ { 1 } ) \right. , } \end{array}
475
+ $$
476
+
477
+ where in the last equality we change again the order of integration.
478
+
479
+ Theorem 3. Let $p _ { t } ( x | x _ { 1 } )$ be a Gaussian probability path as in equation $I O$ , and $\psi _ { t }$ its corresponding flow map as in equation $I I$ . Then, the unique vector field that defines $\psi _ { t }$ has the form:
480
+
481
+ $$
482
+ u _ { t } ( x | x _ { 1 } ) = \frac { \sigma _ { t } ^ { \prime } ( x _ { 1 } ) } { \sigma _ { t } ( x _ { 1 } ) } \left( x - \mu _ { t } ( x _ { 1 } ) \right) + \mu _ { t } ^ { \prime } ( x _ { 1 } ) .
483
+ $$
484
+
485
+ Consequently, $u _ { t } ( x | x _ { 1 } )$ generates the Gaussian path $p _ { t } ( x | x _ { 1 } )$ .
486
+
487
+ Proof. For notational simplicity let $w _ { t } ( x ) = u _ { t } ( x | x _ { 1 } )$ . Now consider equation 1:
488
+
489
+ $$
490
+ \frac { d } { d t } \psi _ { t } ( x ) = w _ { t } ( \psi _ { t } ( x ) ) .
491
+ $$
492
+
493
+ Since $\psi _ { t }$ is invertible (as $\sigma _ { t } ( x _ { 1 } ) > 0 ,$ ) we let $x = \psi ^ { - 1 } ( y )$ and get
494
+
495
+ $$
496
+ \psi _ { t } ^ { \prime } ( \psi ^ { - 1 } ( y ) ) = w _ { t } ( y ) ,
497
+ $$
498
+
499
+ where we used the apostrophe notation for the derivative to emphasis that $\psi _ { t } ^ { \prime }$ is evaluated at $\psi ^ { - 1 } ( y )$ . Now, inverting $\psi _ { t } ( x )$ provides
500
+
501
+ $$
502
+ \psi _ { t } ^ { - 1 } ( y ) = \frac { y - \mu _ { t } ( x _ { 1 } ) } { \sigma _ { t } ( x _ { 1 } ) } .
503
+ $$
504
+
505
+ Differentiating $\psi _ { t }$ with respect to $t$ gives
506
+
507
+ $$
508
+ \psi _ { t } ^ { \prime } ( x ) = \sigma _ { t } ^ { \prime } ( x _ { 1 } ) x + \mu _ { t } ^ { \prime } ( x _ { 1 } ) .
509
+ $$
510
+
511
+ Plugging these last two equations in equation 26 we get
512
+
513
+ $$
514
+ w _ { t } ( y ) = \frac { \sigma _ { t } ^ { \prime } ( x _ { 1 } ) } { \sigma _ { t } ( x _ { 1 } ) } \left( y - \mu _ { t } ( x _ { 1 } ) \right) + \mu _ { t } ^ { \prime } ( x _ { 1 } )
515
+ $$
516
+
517
+ as required.
518
+
519
+ # C COMPUTING PROBABILITIES OF THE CNF MODEL
520
+
521
+ We are given an arbitrary data point $x _ { 1 } \in \mathbb { R } ^ { d }$ and need to compute the model probability at that point, i.e., $p _ { 1 } ( x _ { 1 } )$ . Below we recap how this can be done covering the basic relevant ODEs, the scaling of the divergence computation, taking into account data transformations (e.g., centering of data), and Bits-Per-Dimension computation.
522
+
523
+ ODE for computing $p _ { 1 } ( x _ { 1 } )$ . The continuity equation with equation 1 lead to the instantaneous change of variable (Chen et al., 2018; Ben-Hamu et al., 2022):
524
+
525
+ $$
526
+ \frac { d } { d t } \log p _ { t } ( \phi _ { t } ( x ) ) + \mathrm { d i v } \big ( v _ { t } ( \phi _ { t } ( x ) ) = 0 .
527
+ $$
528
+
529
+ Integrating $t \in [ 0 , 1 ]$ gives:
530
+
531
+ $$
532
+ \log p _ { 1 } ( \phi _ { 1 } ( x ) ) - \log p _ { 0 } ( \phi _ { 0 } ( x ) ) = - \int _ { 0 } ^ { 1 } \mathrm { d i v } ( v _ { t } ( \phi _ { t } ( x ) ) ) d t
533
+ $$
534
+
535
+ Therefore, the log probability can be computed together with the flow trajectory by solving the ODE:
536
+
537
+ $$
538
+ \frac { d } { d t } \left[ \phi _ { t } ( x ) \right] = \left[ \begin{array} { c } { v _ { t } ( \phi _ { t } ( x ) ) } \\ { - \mathrm { d i v } \big ( v _ { t } ( \phi _ { t } ( x ) ) \big ) } \end{array} \right]
539
+ $$
540
+
541
+ Given initial conditions
542
+
543
+ $$
544
+ \left[ \begin{array} { c } { { \phi _ { 0 } ( x ) } } \\ { { f ( 0 ) } } \end{array} \right] = \left[ \begin{array} { c } { { x _ { 0 } } } \\ { { c } } \end{array} \right] .
545
+ $$
546
+
547
+ the solution $\left[ \phi _ { t } ( x ) , f ( t ) \right] ^ { T }$ is uniquely defined (up to some mild conditions on the $\mathrm { V F } v _ { t } .$ ). Denote $x _ { 1 } = \phi _ { 1 } ( x )$ , and according to equation 27,
548
+
549
+ $$
550
+ f ( 1 ) = c + \log p _ { 1 } ( x _ { 1 } ) - \log p _ { 0 } ( x _ { 0 } ) .
551
+ $$
552
+
553
+ Now, we are given an arbitrary $x _ { 1 }$ and want to compute $p _ { 1 } ( x _ { 1 } )$ . For this end, we will need to solve equation 28 in reverse. That is,
554
+
555
+ $$
556
+ { \frac { d } { d s } } \left[ { \phi } _ { 1 - s } ( x ) \right] = \left[ \mathrm { - } v _ { 1 - s } ( { \phi } _ { 1 - s } ( x ) ) \right]
557
+ $$
558
+
559
+ and we solve this equation for $s \in [ 0 , 1 ]$ with the initial conditions at $s = 0$
560
+
561
+ $$
562
+ \left[ \begin{array} { c } { { \phi _ { 1 } ( x ) } } \\ { { f ( 1 ) } } \end{array} \right] = \left[ \begin{array} { c } { { x _ { 1 } } } \\ { { 0 } } \end{array} \right] .
563
+ $$
564
+
565
+ From uniqueness of ODEs, the solution will be identical to the solution of equation 28 with initial conditions in equation 29 where $c = \log p _ { 0 } ( x _ { 0 } ) - \log p _ { 1 } ( x _ { 1 } )$ . This can be seen from equation 30 and setting $f ( 1 ) = 0$ . Therefore we get that
566
+
567
+ $$
568
+ f ( 0 ) = \log p _ { 0 } ( x _ { 0 } ) - \log p _ { 1 } ( x _ { 1 } )
569
+ $$
570
+
571
+ and consequently
572
+
573
+ $$
574
+ \log p _ { 1 } ( x _ { 1 } ) = \log p _ { 0 } ( x _ { 0 } ) - f ( 0 ) .
575
+ $$
576
+
577
+ To summarize, to compute $p _ { 1 } ( x _ { 1 } )$ we first solve the ODE in equation 31 with initial conditions in equation 32, and the compute equation 33.
578
+
579
+ Unbiased estimator to $p _ { 1 } ( x _ { 1 } )$ . Solving equation 31 requires computation of div of VFs in $\mathbb { R } ^ { d }$ which is costly. Grathwohl et al. (2018) suggest to replace the divergence by the (unbiased) Hutchinson trace estimator,
580
+
581
+ $$
582
+ \frac { d } { d s } \left[ \stackrel { \phi _ { 1 - s } ( x ) } { \tilde { f } ( 1 - s ) } \right] = \left[ z ^ { T } D v _ { 1 - s } ( \phi _ { 1 - s } ( x ) ) z \right] ,
583
+ $$
584
+
585
+ where $z \in \mathbb { R } ^ { d }$ is a sample from a random variable such that $\mathbb { E } z z ^ { T } = I$ . Solving the ODE in equation 34 exactly (in practice, with a small controlled error) with initial conditions in equation 32 leads to
586
+
587
+ $$
588
+ \begin{array} { r l } { \mathbb { E } _ { z } \left[ \log p _ { 0 } ( x _ { 0 } ) - \tilde { f } ( 0 ) \right] = \log p _ { 0 } ( x _ { 0 } ) - \mathbb { E } _ { z } \left[ \tilde { f } ( 0 ) - \tilde { f } ( 1 ) \right] } & { } \\ & { = \log p _ { 0 } ( x _ { 0 } ) - \mathbb { E } _ { z } \left[ \int _ { 0 } ^ { 1 } z ^ { T } D v _ { 1 - s } ( \phi _ { 1 - s } ( x ) ) z d s \right] } \\ & { = \log p _ { 0 } ( x _ { 0 } ) - \int _ { 0 } ^ { 1 } \mathbb { E } _ { z } \left[ z ^ { T } D v _ { 1 - s } ( \phi _ { 1 - s } ( x ) ) z \right] d s } \\ & { = \log p _ { 0 } ( x _ { 0 } ) - \int _ { 0 } ^ { 1 } \mathrm { d i v } ( v _ { 1 - s } ( \phi _ { 1 - s } ( x ) ) ) d s } \\ & { = \log p _ { 0 } ( x _ { 0 } ) - ( f ( 0 ) - f ( 1 ) ) } \\ & { = \log p _ { 0 } ( x _ { 0 } ) - ( \log p _ { 0 } ( x _ { 0 } ) - \log p _ { 1 } ( x _ { 1 } ) ) } \\ & { = \log p _ { 1 } ( x _ { 1 } ) , } \end{array}
589
+ $$
590
+
591
+ where in the third equality we switched order of integration assuming the sufficient condition of Fubini’s theorem hold, and in the previous to last equality we used equation 30. Therefore the random variable
592
+
593
+ $$
594
+ \log p _ { 0 } ( x _ { 0 } ) - \tilde { f } ( 0 )
595
+ $$
596
+
597
+ is an unbiased estimator for $\log p _ { 1 } ( x _ { 1 } )$ . To summarize, for a scalable unbiased estimation of $p _ { 1 } ( x _ { 1 } )$ we first solve the ODE in equation 34 with initial conditions in equation 32, and then output equation 35.
598
+
599
+ Transformed data. Often, before training our generative model we transform the data, e.g., we scale and/or translate the data. Such a transformation is denoted by $\varphi ^ { - 1 } : \mathbb { R } ^ { d } \to \mathbb { R } ^ { d }$ and our generative model becomes a composition
600
+
601
+ $$
602
+ \psi ( x ) = \varphi \circ \phi ( x )
603
+ $$
604
+
605
+ where $\phi : \mathbb { R } ^ { d } \mathbb { R } ^ { d }$ is the model we train. Given a prior probability $p _ { 0 }$ we have that the push forward of this probability under $\psi$ (equation 3 and equation 4) takes the form
606
+
607
+ $$
608
+ \begin{array} { c } { { p _ { 1 } ( x ) = \psi _ { * } p _ { 0 } ( x ) = p _ { 0 } ( \phi ^ { - 1 } ( \varphi ^ { - 1 } ( x ) ) ) \operatorname* { d e t } \left[ D \phi ^ { - 1 } ( \varphi ^ { - 1 } ( x ) ) \right] \operatorname* { d e t } \left[ D \varphi ^ { - 1 } ( x ) \right] } } \\ { { = \left( \phi _ { * } p _ { 0 } ( \varphi ^ { - 1 } ( x ) ) \right) \operatorname* { d e t } \left[ D \varphi ^ { - 1 } ( x ) \right] } } \end{array}
609
+ $$
610
+
611
+ and therefore
612
+
613
+ $$
614
+ \begin{array} { r } { \log p _ { 1 } ( x ) = \log \phi _ { * } p _ { 0 } ( \varphi ^ { - 1 } ( x ) ) + \log \operatorname* { d e t } \left[ D \varphi ^ { - 1 } ( x ) \right] . } \end{array}
615
+ $$
616
+
617
+ For images $d = H \times W \times 3$ we consider a transform $\phi$ that maps each pixel value from $[ - 1 , 1 ]$ to $[ 0 , 2 5 6 ]$ . Therefore,
618
+
619
+ $$
620
+ \varphi ( y ) = 2 ^ { 7 } ( y + 1 ) ,
621
+ $$
622
+
623
+ and
624
+
625
+ $$
626
+ \varphi ^ { - 1 } ( x ) = 2 ^ { - 7 } x - 1 .
627
+ $$
628
+
629
+ For this case we have
630
+
631
+ $$
632
+ \log p _ { 1 } ( x ) = \log \phi _ { * } p _ { 0 } ( \varphi ^ { - 1 } ( x ) ) - 7 d \log 2 .
633
+ $$
634
+
635
+ # Bits-Per-Dimension (BPD) computation. BPD is defined by
636
+
637
+ $$
638
+ \mathrm { B P D } = \mathbb { E } _ { x _ { 1 } } \left[ - \frac { \log _ { 2 } p _ { 1 } ( x _ { 1 } ) } { d } \right] = \mathbb { E } _ { x _ { 1 } } \left[ - \frac { \log p _ { 1 } ( x _ { 1 } ) } { d \log 2 } \right]
639
+ $$
640
+
641
+ Following equation 36 we get
642
+
643
+ $$
644
+ \mathrm { B P D } = - \frac { \log \phi _ { * } p _ { 0 } ( \varphi ^ { - 1 } ( x ) ) } { d \log 2 } + 7 .
645
+ $$
646
+
647
+ and $\log { \phi _ { * } p _ { 0 } ( \varphi ^ { - 1 } ( x ) ) }$ is approximated using the unbiased estimator in equation 35 over the transformed data $\varphi ^ { - 1 } ( x _ { 1 } )$ . Averaging the unbiased estimator on a large test test $x _ { 1 }$ provides a good approximation to the test set BPD.
648
+
649
+ # D DIFFUSION CONDITIONAL VECTOR FIELDS
650
+
651
+ We derive the vector field governing the Probability Flow ODE (equation 13 in Song et al. (2020b)) for the VE and VP diffusion paths (equation 18) and note that it coincides with the conditional vector fields we derive using Theorem 3, namely the vector fields defined in equations 16 and 19.
652
+
653
+ We start with a short primer on how to find a conditional vector field for the probability path described by the Fokker-Planck equation, then instantiate it for the VE and VP probability paths.
654
+
655
+ Since in the diffusion literature the diffusion process runs from data at time $t = 0$ to noise at time $t = 1$ , we will need the following lemma to translate the diffusion VFs to our convention of $t = 0$ corresponds to noise and $t = 1$ corresponds to data:
656
+
657
+ Lemma 1. Consider a flow defined by a vector field $u _ { t } ( x )$ generating probability density path $p _ { t } ( x )$ . Then, the vector field $\tilde { u } _ { t } ( x ) = - u _ { 1 - t } ( x )$ generates the path $\tilde { p } _ { t } ( x ) = p _ { 1 - t } ( x )$ when initiated from $\tilde { p } _ { 0 } ( x ) = p _ { 1 } ( x )$ .
658
+
659
+ Proof. We use the continuity equation (equation 25):
660
+
661
+ $$
662
+ \begin{array} { l } { \displaystyle \frac { d } { d t } \tilde { p } _ { t } ( x ) = \frac { d } { d t } p _ { 1 - t } ( x ) = - p _ { 1 - t } ^ { \prime } ( x ) } \\ { \displaystyle = \mathrm { d i v } \big ( p _ { 1 - t } ( x ) u _ { 1 - t } ( x ) \big ) } \\ { \displaystyle = - \mathrm { d i v } \big ( \tilde { p } _ { t } ( x ) \big ( - u _ { 1 - t } ( x ) \big ) \big ) } \end{array}
663
+ $$
664
+
665
+ and therefore $\tilde { u } _ { t } ( x ) = - u _ { 1 - t } ( x )$ generates $\tilde { p } _ { t } ( x )$ .
666
+
667
+ Conditional VFs for Fokker-Planck probability paths Consider a Stochastic Differential Equation (SDE) of the standard form
668
+
669
+ $$
670
+ d y = f _ { t } d t + g _ { t } d w
671
+ $$
672
+
673
+ with time parameter $t$ , drift $f _ { t }$ , diffusion coefficient $g _ { t }$ , and $d w$ is the Wiener process. The solution $y _ { t }$ to the SDE is a stochastic process, i.e., a continuous time-dependent random variable, the probability density of which, $p _ { t } ( y _ { t } )$ , is characterized by the Fokker-Planck equation:
674
+
675
+ $$
676
+ \frac { d p _ { t } } { d t } = - \mathrm { d i v } ( f _ { t } p _ { t } ) + \frac { g _ { t } ^ { 2 } } { 2 } \Delta p _ { t }
677
+ $$
678
+
679
+ where $\Delta$ represents the Laplace operator (in $y$ ), namely $\operatorname { d i v } \nabla$ , where $\nabla$ is the gradient operator (also in $y$ ). Rewriting this equation in the form of the continuity equation can be done as follows (Maoutsa et al., 2020a):
680
+
681
+ $$
682
+ \frac { d p _ { t } } { d t } = - \mathrm { d i v } \Big ( f _ { t } p _ { t } - \frac { g ^ { 2 } } { 2 } \frac { \nabla p _ { t } } { p _ { t } } p _ { t } \Big ) = - \mathrm { d i v } \Big ( \big ( f _ { t } - \frac { g _ { t } ^ { 2 } } { 2 } \nabla \log p _ { t } \big ) p _ { t } \Big ) = - \mathrm { d i v } \Big ( w _ { t } p _ { t } \Big )
683
+ $$
684
+
685
+ where the vector field
686
+
687
+ $$
688
+ w _ { t } = f _ { t } - \frac { g _ { t } ^ { 2 } } { 2 } \nabla \log p _ { t }
689
+ $$
690
+
691
+ satisfies the continuity equation with the probability path $p _ { t }$ , and therefore generates $p _ { t }$
692
+
693
+ Variance Exploding (VE) path The SDE for the VE path is
694
+
695
+ $$
696
+ d y = { \sqrt { { \frac { d } { d t } } \sigma _ { t } ^ { 2 } } } d w ,
697
+ $$
698
+
699
+ where $\sigma _ { 0 } = 0$ and increasing to infinity as $t 1$ . The SDE is moving from data, $y _ { 0 }$ , at $t = 0$ to noise, $y _ { 1 }$ , at $t = 1$ with the probability path
700
+
701
+ $$
702
+ p _ { t } ( y | y _ { 0 } ) = \mathcal { N } ( y | y _ { 0 } , \sigma _ { t } ^ { 2 } I ) .
703
+ $$
704
+
705
+ The conditional VF according to equation 40 is:
706
+
707
+ $$
708
+ w _ { t } ( y | y _ { 0 } ) = \frac { \sigma _ { t } ^ { \prime } } { \sigma _ { t } } ( y - y _ { 0 } )
709
+ $$
710
+
711
+ Using Lemma 1 we get that the probability path
712
+
713
+ $$
714
+ \tilde { p } _ { t } ( y | y _ { 0 } ) = \mathcal { N } ( y | y _ { 0 } , \sigma _ { 1 - t } ^ { 2 } I )
715
+ $$
716
+
717
+ is generated by
718
+
719
+ $$
720
+ \tilde { w } _ { t } ( y | y _ { 0 } ) = - \frac { \sigma _ { 1 - t } ^ { \prime } } { \sigma _ { 1 - t } } ( y - y _ { 0 } ) ,
721
+ $$
722
+
723
+ which coincides with equation 17.
724
+
725
+ Variance Preserving (VP) path The SDE for the VP path is
726
+
727
+ $$
728
+ d y = - \frac { T ^ { \prime } ( t ) } { 2 } y + \sqrt { T ^ { \prime } ( t ) } d w ,
729
+ $$
730
+
731
+ where $\begin{array} { r } { T ( t ) = \int _ { 0 } ^ { t } \beta ( s ) d s , t \in [ 0 , 1 ] } \end{array}$ . The SDE coefficients are therefore
732
+
733
+ $$
734
+ f _ { s } ( y ) = - \frac { T ^ { \prime } ( s ) } { 2 } y , \quad g _ { s } = \sqrt { T ^ { \prime } ( s ) }
735
+ $$
736
+
737
+ and
738
+
739
+ $$
740
+ p _ { t } ( y | y _ { 0 } ) = \mathcal { N } ( y | e ^ { - \frac { 1 } { 2 } T ( t ) } y _ { 0 } , ( 1 - e ^ { - T ( t ) } ) I ) .
741
+ $$
742
+
743
+ Plugging these choices in equation 40 we get the conditional VF
744
+
745
+ $$
746
+ w _ { t } ( y | y _ { 0 } ) = { \frac { T ^ { \prime } ( t ) } { 2 } } \left( { \frac { y - e ^ { - { \frac { 1 } { 2 } } T ( t ) } y _ { 0 } } { 1 - e ^ { - T ( t ) } } } - y \right)
747
+ $$
748
+
749
+ Using Lemma 1 to reverse the time we get the conditional VF for the reverse probability path:
750
+
751
+ $$
752
+ \begin{array} { l } { \displaystyle \tilde { w } _ { t } ( y | y _ { 0 } ) = - \frac { T ^ { \prime } ( 1 - t ) } { 2 } \left( \frac { y - e ^ { - \frac 1 2 T ( 1 - t ) } y _ { 0 } } { 1 - e ^ { - T ( 1 - t ) } } - y \right) } \\ { = - \frac { T ^ { \prime } ( 1 - t ) } { 2 } \left[ \frac { e ^ { - T ( 1 - t ) } y - e ^ { - \frac 1 2 T ( 1 - t ) } y _ { 0 } } { 1 - e ^ { - T ( 1 - t ) } } \right] , } \end{array}
753
+ $$
754
+
755
+ which coincides with equation 19.
756
+
757
+ ![](images/fab5ea8c033deb403362d41d1fb6d0a7c5553b41abd30ba80e8f0ec3e0e2e6d7.jpg)
758
+ Figure 8: VP Diffusion path’s conditional vector field. Compare to Figure 2.
759
+
760
+ ![](images/10154dd1f03b66c681a67154d5dff0682668218e3c2e6793db94b67cd56d689e.jpg)
761
+ Figure 9: Trajectories of CNFs trained with ScoreFlow (Song et al., 2021) and DDPM (Ho et al., 2020) losses on 2D checkerboard data, using the same learning rate and other hyperparameters as Figure 4.
762
+
763
+ # E IMPLEMENTATION DETAILS
764
+
765
+ For the 2D example we used an MLP with 5-layers of 512 neurons each, while for images we used the UNet architecture from Dhariwal & Nichol (2021). For images, we center crop images and resize to the appropriate dimension, whereas for the $3 2 \times 3 2$ and $6 4 \times 6 4$ resolutions we use the same pre-processing as (Chrabaszcz et al., 2017). The three methods (FM-OT, FM-Diffusion, and SMDiffusion) are always trained on the same architecture, same hyper-parameters, and for the same number of epochs.
766
+
767
+ # E.1 DIFFUSION BASELINES
768
+
769
+ Losses. We consider three options as diffusion baselines that correspond to the most popular diffusion loss parametrizations (Song & Ermon, 2019; Song et al., 2021; Ho et al., 2020; Kingma et al., 2021). We will assume general Gaussian path form of equation 10, i.e.,
770
+
771
+ $$
772
+ p _ { t } ( x | x _ { 1 } ) = \mathcal { N } ( x | \mu _ { t } ( x _ { 1 } ) , \sigma _ { t } ^ { 2 } ( x _ { 1 } ) I ) .
773
+ $$
774
+
775
+ Score Matching loss is
776
+
777
+ $$
778
+ \begin{array} { r } { \mathcal { L } _ { \mathrm { s x } } ( \theta ) = \mathbb { E } _ { t , q ( x _ { 1 } ) , p _ { t } ( x | x _ { 1 } ) } \lambda ( t ) \left\| s _ { t } ( x ) - \nabla \log p _ { t } ( x | x _ { 1 } ) \right\| ^ { 2 } } \\ { = \mathbb { E } _ { t , q ( x _ { 1 } ) , p _ { t } ( x | x _ { 1 } ) } \lambda ( t ) \left\| s _ { t } ( x ) - \frac { x - \mu _ { t } ( x _ { 1 } ) } { \sigma _ { t } ^ { 2 } ( x _ { 1 } ) } \right\| ^ { 2 } . } \end{array}
779
+ $$
780
+
781
+ Taking $\lambda ( t ) = \sigma _ { t } ^ { 2 } ( x _ { 1 } )$ corresponds to the original Score Matching (SM) loss from Song & Ermon (2019), while considering $\lambda ( t ) = \beta ( 1 - t )$ ( $\beta$ is defined below) corresponds to the Score Flow (SF) loss motivated by an NLL upper bound (Song et al., 2021); $s _ { t }$ is the learnable score function. DDPM (Noise Matching) loss from Ho et al. (2020) (equation 14) is
782
+
783
+ $$
784
+ \begin{array} { r l } & { \displaystyle \mathcal { L } _ { \mathrm { \tiny { N M } } } ( \theta ) = \mathbb { E } _ { t , q ( x _ { 1 } ) , p _ { t } ( x | x _ { 1 } ) } \left\| \epsilon _ { t } ( x ) - \frac { x - \mu _ { t } ( x _ { 1 } ) } { \sigma _ { t } ( x _ { 1 } ) } \right\| ^ { 2 } } \\ & { \quad \quad \quad = \mathbb { E } _ { t , q ( x _ { 1 } ) , p _ { 0 } ( x _ { 0 } ) } \Big \| \epsilon _ { t } \big ( \sigma _ { t } ( x _ { 1 } ) x _ { 0 } + \mu _ { t } ( x _ { 1 } ) \big ) - x _ { 0 } \Big \| ^ { 2 } } \end{array}
785
+ $$
786
+
787
+ where $p _ { 0 } ( x ) = \mathcal { N } ( x | 0 , I )$ is the standard Gaussian, and $\epsilon _ { t }$ is the learnable noise function.
788
+
789
+ Diffusion path. For the diffusion path we use the standard VP diffusion (equation 19), namely,
790
+
791
+ $$
792
+ \mu _ { t } ( x _ { 1 } ) = \alpha _ { 1 - t } x _ { 1 } , \quad \sigma _ { t } ( x _ { 1 } ) = \sqrt { 1 - \alpha _ { 1 - t } ^ { 2 } } , \quad \mathrm { w h e r e ~ } \alpha _ { t } = e ^ { - \frac 1 2 T ( t ) } , \quad T ( t ) = \int _ { 0 } ^ { t } \beta ( s ) d s ,
793
+ $$
794
+
795
+ Table 3: Hyper-parameters used for training each model
796
+
797
+ <table><tr><td></td><td>CIFAR10</td><td>ImageNet-32</td><td>ImageNet-64</td><td>ImageNet-128</td></tr><tr><td>Channels</td><td>256</td><td>256</td><td>192</td><td>256</td></tr><tr><td>Depth</td><td>2</td><td>3</td><td>3</td><td>3</td></tr><tr><td>Channels multiple</td><td>1,2,2,2</td><td>1,2,2,2</td><td>1,2,3,4</td><td>1,1,2,3,4</td></tr><tr><td>Heads</td><td>4</td><td>4</td><td>4</td><td>4</td></tr><tr><td>Heads Channels</td><td>64</td><td>64</td><td>64</td><td>64</td></tr><tr><td>Attention resolution</td><td>16</td><td>16,8</td><td>32,16.8</td><td>32,16.8</td></tr><tr><td>Dropout</td><td>0.0</td><td>0.0</td><td>0.0</td><td>0.0</td></tr><tr><td>Effective Batch size</td><td>256</td><td>1024</td><td>2048</td><td>1536</td></tr><tr><td>GPUs</td><td>2</td><td>4</td><td>16</td><td>32</td></tr><tr><td>Epochs</td><td>1000</td><td>200</td><td>250</td><td>571</td></tr><tr><td>Iterations</td><td>391k</td><td>250k</td><td>157k</td><td>500k</td></tr><tr><td>Learning Rate</td><td>5e-4</td><td>1e-4</td><td>1e-4</td><td>1e-4</td></tr><tr><td>Learning Rate Scheduler</td><td>Polynomial Decay</td><td>Polynomial Decay</td><td>Constant</td><td>Polynomial Decay</td></tr><tr><td>Warmup Steps</td><td>45k</td><td>20k</td><td>1</td><td>20k</td></tr></table>
798
+
799
+ with, as suggested in Song et al. (2020b), $\beta ( s ) = \beta _ { \mathrm { m i n } } + s ( \beta _ { \mathrm { m a x } } - \beta _ { \mathrm { m i n } } )$ and consequently
800
+
801
+ $$
802
+ T ( s ) = \int _ { 0 } ^ { s } \beta ( r ) d r = s \beta _ { \operatorname* { m i n } } + \frac { 1 } { 2 } { s } ^ { 2 } ( \beta _ { \operatorname* { m a x } } - \beta _ { \operatorname* { m i n } } ) ,
803
+ $$
804
+
805
+ where $\beta _ { \mathrm { m i n } } = 0 . 1$ , $\beta _ { \mathrm { m a x } } = 2 0$ and time is sampled in $[ 0 , 1 - \epsilon ] , \epsilon = 1 0 ^ { - 5 }$ for training and likelihood and $\epsilon = 1 0 ^ { - 5 }$ for sampling.
806
+
807
+ Sampling. Score matching samples are produced by solving the ODE (equation 1) with the vector field
808
+
809
+ $$
810
+ u _ { t } ( x ) = - \frac { T ^ { \prime } ( 1 - t ) } { 2 } \left[ s _ { t } ( x ) - x \right] .
811
+ $$
812
+
813
+ DDPM samples are computed with equation 46 after setting $s _ { t } ( x ) \ = \ \epsilon _ { t } ( x ) / \sigma _ { t }$ , where $\sigma _ { t } =$ $\sqrt { 1 - \alpha _ { 1 - t } ^ { 2 } }$ .
814
+
815
+ # E.2 TRAINING & EVALUATION DETAILS
816
+
817
+ We report the hyper-parameters used in Table 3. We use full 32 bit-precision for training CIFAR10 and ImageNet-32 and 16-bit mixed precision for training ImageNet-64/128/256. All models are trained using the Adam optimizer with the following parameters: $\beta _ { 1 } = 0 . 9$ , $\beta _ { 2 } = 0 . 9 9 9$ , weight decay $= 0 . 0$ , and $\epsilon = 1 e { - 8 }$ . All methods we trained (i.e., FM-OT, FM-Diffusion, SM-Diffusion) using identical architectures, with the same parameters for the the same number of Epochs (see Table 3 for details). We use either a constant learning rate schedule or a polynomial decay schedule (see Table 3). The polynomial decay learning rate schedule includes a warm-up phase for a specified number of training steps. In the warm-up phase, the learning rate is linearly increased from $1 e { - } 8$ to the peak learning rate (specified in Table 3). Once the peak learning rate is achieved, it linearly decays the learning rate down to $1 e { - } 8$ until the final training step.
818
+
819
+ When reporting negative log-likelihood, we dequantize using the standard uniform dequantization. We report an importance-weighted estimate using
820
+
821
+ $$
822
+ \log \frac { 1 } { K } \sum _ { k = 1 } ^ { K } p _ { t } ( x + u _ { k } ) , \mathrm { ~ w h e r e ~ } u _ { k } \sim \mathcal { U } ( 0 , 1 ) ,
823
+ $$
824
+
825
+ with $x$ is in $\{ 0 , . . . , 2 5 5 \}$ and solved at $t \ = \ 1$ with an adaptive step size solver dopri5 with $\mathtt { a t o l } { = } \mathtt { r t o l } { = } 1 { \mathtt { e } } { - } 5$ using the torchdiffeq (Chen, 2018) library. Estimated values for different values of $K$ are in Table 4.
826
+
827
+ <table><tr><td></td><td colspan="3">CIFAR-10</td><td colspan="3">ImageNet 32×32</td><td colspan="3">ImageNet 64×64</td></tr><tr><td>Model</td><td>K=1</td><td>K=20</td><td>K=50</td><td>K=1</td><td>K=5</td><td>K=15</td><td>K=1</td><td>K=5</td><td>K=10</td></tr><tr><td>Ablation</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>DDPM</td><td>3.24</td><td>3.14</td><td>3.12</td><td>3.62</td><td>3.57</td><td>3.54</td><td>3.36</td><td>3.33</td><td>3.32</td></tr><tr><td>Score Matching</td><td>3.28</td><td>3.18</td><td>3.16</td><td>3.65</td><td>3.59</td><td>3.57</td><td>3.43</td><td>3.41</td><td>3.40</td></tr><tr><td>ScoreFlow</td><td>3.21</td><td>3.11</td><td>3.09</td><td>3.63</td><td>3.57</td><td>3.55</td><td>3.39</td><td>3.37</td><td>3.36</td></tr><tr><td>Ours</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>FM W/ Diffusion</td><td>3.23</td><td>3.13</td><td>3.10</td><td>3.64</td><td>3.58</td><td>3.56</td><td>3.37</td><td>3.34</td><td>3.33</td></tr><tr><td>FM W/OT</td><td>3.11</td><td>3.01</td><td>2.99</td><td>3.62</td><td>3.56</td><td>3.53</td><td>3.35</td><td>3.33</td><td>3.31</td></tr></table>
828
+
829
+ Table 4: Negative log-likelihood (in bits per dimension) on the test set with different values of $K$ using uniform dequantization.
830
+
831
+ ![](images/eb72d06ff7f414249525b415f5268f964d09ba927ba3832e5105240249f648a8.jpg)
832
+ Figure 10: Function evaluations for sampling during training, for models trained on CIFAR-10 using dopri5 solver with tolerance $1 e ^ { - 5 }$ .
833
+
834
+ When computing FID/Inception scores for CIFAR10, ImageNet-32/64 we use the TensorFlow GAN library 2. To remain comparable to Dhariwal & Nichol (2021) for ImageNet-128 we use the evaluation script they include in their publicly available code repository 3
835
+
836
+ # F ADDITIONAL TABLES AND FIGURES
837
+
838
+ ![](images/bbd216bda2a45c32f64cbff5069528eba027c304db27b89b8278e2d54469e621.jpg)
839
+ Figure 11: Non-curated unconditional ImageNet-32 generated images of a CNF trained with FMOT.
840
+
841
+ ![](images/21c9532a95b63a45824c40001fb72d928ad3257051ae8b573500062a2340aacd.jpg)
842
+ Figure 12: Non-curated unconditional ImageNet-64 generated images of a CNF trained with FMOT.
843
+
844
+ ![](images/ff9bb9ac0a9e7091b4805c1cb3148f3a1c8ab55bc81f7c9a3cd466445096728d.jpg)
845
+ Figure 13: Non-curated unconditional ImageNet-128 generated images of a CNF trained with FMOT.
846
+
847
+ ![](images/a728a372aa5ccdaa014733a34baad675c706ed6d306c319c88ebf732f3195157.jpg)
848
+ Figure 14: Conditional generation $6 4 \times 6 4 \to 2 5 6 \times 2 5 6 .$ Flow Matching OT upsampled images from validation set.
849
+
850
+ ![](images/249942f92d435160a5e3bf6685ea8bb6e47279c4b60525de85263b1f6ee36127.jpg)
851
+ Figure 15: Conditional generation $6 4 \times 6 4 \to 2 5 6 \times 2 5 6$ . Flow Matching OT upsampled images from validation set.
852
+
853
+ ![](images/a4c5748ca5b3132645a197cee50cf33f4995449735f7a790c302e4fb4f957059.jpg)
854
+ Figure 16: Generated samples from the same initial noise, but with varying number of function evaluations (NFE). Flow matching with OT path trained on ImageNet-128.
855
+
856
+ ![](images/bd5aa70b81b2a7350e855dc0afed06b965323279c8a07921010964de77cc0e34.jpg)
857
+ Figure 17: Generated samples from the same initial noise, but with varying number of function evaluations (NFE). Flow matching with OT path trained on ImageNet $2 5 6 \times 2 5 6$ .
md/dev/QNBzcgY0f4e/QNBzcgY0f4e.md ADDED
@@ -0,0 +1,526 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Easy incremental learning methods to consider for commercial fine-tuning applications
2
+
3
+ Anonymous Author(s)
4
+ Affiliation
5
+ Address
6
+ email
7
+
8
+ # Abstract
9
+
10
+ Fine-tuning deep learning models for commercial use cases is growing exponentially as more and more companies are adopting AI to enhance their core products and services, as well as automate their diurnal processes and activities. However, not many countries like the U.S. and those in Europe follow quality data collection methods for AI vision or NLP related automation applications. Thus, on many of these kinds of data, existing state-of-the-art pre-trained deep learning models fail to perform accurately, and when fine-tuning is done on these models, issues like catastrophic forgetting or being less specific in predictions as expected occur. Hence, in this paper, simplified incremental learning methods are introduced to be considered in existing fine-tuning infrastructures of pre-trained models (such as those available in huggingface.com) to help mitigate the aforementioned issues for commercial applications. The methods introduced are: 1) Fisher Shut-off, 2) Fractional Data Retention and 3) Border Control. Results show that when applying these methods on vanilla pre-trained models, the models are in fact able to add more to their knowledge without hurting much on what they had learned previously.
11
+
12
+ # 16 1 Introduction
13
+
14
+ 17 Many companies and organizations today are adopting AI in automation, automating their daily
15
+ 18 processes and activities, as well as offering them in their core products and services. Automation
16
+ 19 has traditionally been in the industry for many years, as a means for which economics of scale could
17
+ 20 be acheived so as to remain competitive in the market. Now with AI, more and more intelligence is
18
+ 21 being brought into automation, and in countries like India, organizations are beginning to adopt AI
19
+ 22 for this particular purpose.
20
+ 23 With recent advancements in AI vision and NLP models such as the GPT-3, Jurassic-1, and so on,
21
+ 24 organizations today are using AI for 1) Document Reading and Understanding, 2) Online Proctoring,
22
+ 25 3) Chatbots, 4) Intelligent Information Parsing and other application related process automations.
23
+ 26 Given these use cases, AI solutions need to be specific to their processes, but yet be an addition to
24
+ 27 their generally known formats. This in a sense, is more like making use of a human employee who
25
+ 28 has some kind of general education on various tasks or processes but still is required to learn the
26
+ 29 companies counterparts well and in detail before he/she is allowed to execute them. These processes
27
+ 30 can include between, reading customer emails for entering relevant information about their product
28
+ 31 requirements onto a structured database, to understanding various types of printed documents for
29
+ 32 information parsing, and to identifying newer objects for either document filtering or malicious
30
+ 33 activity detection.
31
+ 34 For natural language related tasks, powerful models like the GPT-3 are now being widely used, but
32
+ 35 they require good prompt engineering skills to get the best out of them. Also, given that they are
33
+ 36 probabilistic models, the generated outputs can sometimes falter away from what is expected, and
34
+ 37 this can become a problem when selling it to customers, because even the slightest faltering may not
35
+ 38 be acceptable to them at all. Hence, to reduce this, more and more examples have to be provided in
36
+ 39 the prompt, and this can come at a high cost not suitable for low cost of living countries like India.
37
+ 40 The other workaround is to fine-tune the model on the new datasets, but this has epoch limitations
38
+ 41 on how deeply it can fit on the new dataset without hurting the body of general knowledge it gained
39
+ 42 earlier. Also, fine-tuning models like the GPT-3 comes at a very high cost now-a-days, and is no
40
+ 43 more an option. This leaves the automation builders to use huggingface.com transformers instead.
41
+ 44 In vision, although state-of-the-art pre-trained deep learning models are able to achieve human level
42
+ 45 performance on a variety of inputs, they can only perform so in upto close to high quality inputs. If
43
+ 46 the quality goes lower, they fail terribly. Not all organizations have a good quality data collection
44
+ 47 process involved for applying automation, and this is ubiquitously the case in many parts of the world.
45
+ 48 So it becomes quite difficult to sell AI as a human-level performer, and at this point AI becomes of
46
+ 49 lesser use than it could potentially be.
47
+ 50 Another approach typically used to resolve such problems is to employ transfer learning, which
48
+ 51 typically involves replacing the last layers of the model with a new model to get the specific outputs
49
+ 52 required. Some examples done in research are Too, et al. (2019), Dif & Elberrichi (2020), Alshalali
50
+ 53 & Joysula (2018), Jung, et al. (2015), Qian, et al. (2021) and Vrbanciˇ c & Podgorelec (2020). While ˇ
51
+ 54 this may not seem to be a problem with vision based tasks, it is definitely a problem with natural
52
+ 55 language based tasks. This is because the final layers of the natural language models have all the vital
53
+ 56 information of language structure that help with the language generative process. When this is to
54
+ 57 be changed, catastrophic forgetting can happen. Catastrophic forgetting is a phenomenon in which
55
+ 58 previously learned knowledge is lost partly by the application of new data for training. Also, with
56
+ 59 vision based tasks, when the requirement is to just improve the performance on lower quality data,
57
+ 60 transfer learning may not be the appropriate approach. Fine-tuning for these must involve the final
58
+ 61 layers of the model which could inevitably lead to catastrophic forgetting on the higher quality inputs.
59
+ 62 This brings the only solution towards incremental learning. This type of learning is all about
60
+ 63 learning on newer datasets without having the side-effects catastrophic forgetting, and there has been
61
+ 64 substantial amount of research done in this area. Luo, et al. (2020) summarizes all the work that has
62
+ 65 happened in this area so far. There are several approaches to implementing incremental learning on
63
+ 66 pre-trained models, some of which will be discussed in the forthcoming sections. In this paper, a
64
+ 67 few of these approaches will be simplified for commercial applications along with novel intuitive
65
+ 68 additions to further help the learning process. The paper introduces: 1) Fisher Shut-off which is a
66
+ 69 simplification of the work done by Kirkpatrick, et al. (2017), 2) Fractional Data Retention which
67
+ 70 adopts ideas from Castro, et al. (2018), and 3) Border Control which is an extension to the idea
68
+ 71 outlined by Ren, et al. (2018) on reweighting examples by employing a method similar to Adaboost.
69
+ 72 The last one is the novel addition as it formulates a different approach to retaining salient examples
70
+ 73 for incremental learning. It is based on the work by Ruping (2001) on incremental learning with
71
+ 74 SVMs. But since SVMs are too complex in the context on neural networks, a similar but simplified
72
+ 75 approach is proposed.
73
+ 76 The purpose of this work is to initiate the development of a new infrastructure for commercial
74
+ 77 fine-tuning of pre-trained models with simplified incremental learning methods.
75
+ 78 The rest of this paper proceeds as follows: Section 2 will provide a brief discussion on incremental
76
+ 79 learning methods developed so far, followed by the proposal of simplified incremental learning
77
+ 80 methods in Section 3. Section 4 will show sample results of the proposed methods on a vanilla
78
+ 81 pre-trained model using a toy dataset. A toy dataset is used for the only purpose of providing
79
+ 82 visualizations on the performance of the proposed methods. Nevertheless, these methods can be
80
+ 83 extended on to real world datasets. The paper then concludes in Section 5 discussing steps forward
81
+ 84 for implementation.
82
+
83
+ # 85 2 Incremental Learning
84
+
85
+ 86 This section is a summary of the review published by Luo, et al. (2020). In this review, four different
86
+ 87 types of strategies for incremental learning are highlighted, and every work published in this area
87
+ 88 uses either one or more such strategies. Some examples are Castro, et al. (2018) and He, et al. (2020).
88
+ 89 The four strategies are:
89
+
90
+ • Architectural • Regularization • Rehearsal • Pseudo-Rehearsal
91
+
92
+ 94 The following subsections will disccuss these briefly.
93
+
94
+ # 2.1 Architectural Strategy
95
+
96
+ 96 This strategy is similar to boosting techniques where multiple models are trained. But when used in the context of incremental learning, each model is trained on a different task separately. Then another 98 meta-model that effectively selects which model to use for inference is trained. The work done by 99 Poliker, et al. (2001) resembles this in many ways. In this work, multiple classifiers are trained with 0 different training sets, and then a Adaboost style of ensemble learning is employed to combine the model outputs.
97
+
98
+ 102 Another interesting work is by Rusu, et al. (2016) on Progressive Neural Networks (PNN). In this
99
+ 103 work, a neural network is trained sequentially on different tasks or training sets. However, each time,
100
+ 104 new neurons are added in each layer with new weights, and the weights of the previously learned
101
+ 105 neural network are frozen. Then, to prevent catastrophic forgetting, the outputs of each layer of the
102
+ 106 previous neural network on the earlier training set are used in addition to the new task or training
103
+ 107 set, when training the new layer neurons. The results on this type of incremental learning were quite
104
+ 108 encouraging that it set a new direction in the research of dynamically expanding networks that could
105
+ 109 make better use the neural networks capacity than the PNN. In fact, it will be seen later that the Fisher
106
+ 110 Shut-off method proposed in this paper inherently employs the idea of PNNs.
107
+
108
+ # 2.2 Regularization Strategy
109
+
110
+ 112 In this strategy, as the name suggest, a regularization term is added in the loss function that measures
111
+ 113 the importance of old knowledge when learning on a new training set. The representive work done in
112
+ 114 this is Kirkpatrick, et al. (2017), whereby they introduce the concept of Elastic Weight Consolidation
113
+ 115 (EWC) by means of a Fisher Information Matrix. The EWC brings about the regularization term in
114
+ 116 the loss function as
115
+
116
+ $$
117
+ R ( w ) = \sum _ { i } \frac { \lambda } { 2 } F _ { i } ( w _ { i } - w _ { i , o l d } ) ^ { 2 }
118
+ $$
119
+
120
+ 117 where $F _ { i }$ is the Fisher Information Matrix which suggests the importance of the $i$ -th weight trained
121
+ 118 on the old (or previous) training set. Here, as one could speculate, the term Fisher Shut-off proposed
122
+ 119 in this paper actually derives itself from the Fisher Information Matrix, meaning that this matrix is
123
+ 120 used as the basis for shutting off the training of certain weights when training on a new set.
124
+ 121 Another popular type of regularization strategy is Knowledge Distillation introduced by Hinton, et al.
125
+ 122 (2015). In this method, knowledge from an ensemble of models trained on different tasks (or training
126
+ 123 sets) separately are distilled into a smaller model that can be deployed much easily for inference.
127
+ 124 There are many huggingface.com transformers that are a product of such knowledge distillation.
128
+ 125 The distillation ensures that the smaller model holds all the knowledge of the ensemble, and that it
129
+ 126 can infer as good as it. Distillation is done by setting soft-targets on the smaller network from all the
130
+ 127 earlier training sets of the ensemble. The soft-targets are the output logits from the ensemble models
131
+ 128 on their respective trained datasets.
132
+
133
+ # 129 2.3 Rehearsal and Pseudo-Rehearsal Strategies
134
+
135
+ 130 Rehearsal strategies in incremental learning make use of the earlier training sets when training a
136
+ 131 model on new tasks or training sets. This by far is the simplest of all incremental learning strategies
137
+ 132 that ensures catastrophic forgetting is prevented. The only issue is that when this strategy is used for
138
+ 133 deep learning models trained on large datasets, the training on new datasets could become extremely
139
+ 134 slow and even time consuming before any fruitful results are achieved. Hence, newer research work in
140
+ 135 this area formulate methods for retaining only the most important data points to prevent catastrophic
141
+ 136 forgetting. The work done by Castro, et al. (2018) is an example of this. In this work, selection and
142
+ 137 removal mechanisms on data are introduced for assimilation into a memory network.
143
+ 138 Talking about memory networks, the Pseudo-Rehearsal strategy involves training an additional data
144
+ 139 generator to generate the samples, the neural network was trained on earlier. Hence, newer research
145
+ 140 in this area involve GANs for data generation. Examples are Odena, et al. (2017) and Wu, et al.
146
+ 141 (2018).
147
+
148
+ # 142 3 Proposed Incremental Learning Methods
149
+
150
+ 143 Commercial applications always require simplistic implementations of advanced methods no matter
151
+ 144 how complex they may be. Therefore, it is for this purpose alone this paper proposes some simplified
152
+ 145 methods for implementing incremental learning. As metioned earlier in Section 1, these methods are:
153
+ 146 1) Fisher Shut-off, 2) Fractional Data Retention, and 3) Border Control. This section covers them in
154
+ 147 detail.
155
+
156
+ # 148 3.1 Fisher Shut-off
157
+
158
+ 149 As mentioned in the previous section, the term Fisher Shut-off derives itself from the Fisher Infor
159
+ 150 mation Matrix which weighs the importance of weights trained on previous datasets. Hence, in this
160
+ 151 sub-section, a brief overview of the details behind this matrix is covered with the help of Aich (2021).
161
+ 152 Let $\mathcal { D }$ represent a dataset coming from a stream of data for incremental learning. Then $p ( w | \mathcal { D } )$
162
+ 153 represents the model trained on data $\mathcal { D }$ . This means that to train a model on a new dataset, the
163
+ 154 following posterior must satisfy:
164
+
165
+ $$
166
+ p ( w | \mathcal D _ { n e w } ) = \frac { p ( \mathcal D _ { n e w } | w ) p ( w | \mathcal D _ { o l d } ) } { p ( \mathcal D _ { n e w } ) }
167
+ $$
168
+
169
+ 155 Note here that $p ( w | \mathcal { D } _ { o l d } )$ is written in place of $p ( w )$ because when $\mathcal { D } _ { n e w }$ is applied to the model, the
170
+ 156 weights $w$ have already been trained with $\mathcal { D } _ { o l d }$ . Hence, given the model, $p ( w | \mathcal { D } _ { o l d } )$ , the log-likelihood
171
+ 157 loss on $\mathcal { D } _ { n e w }$ becomes,
172
+
173
+ $$
174
+ \begin{array} { r l } & { \mathcal { L } _ { \mathcal { D } _ { n e w } } ( w ) = l o g ( p ( w | \mathcal { D } _ { n e w } ) ) } \\ & { \qquad = l o g ( p ( \mathcal { D } _ { n e w } | w ) ) + l o g ( p ( w | \mathcal { D } _ { o l d } ) ) - l o g ( p ( \mathcal { D } _ { n e w } ) ) } \\ & { \qquad \approx l o g ( p ( \mathcal { D } _ { n e w } | w ) ) + l o g ( p ( w | \mathcal { D } _ { o l d } ) ) } \end{array}
175
+ $$
176
+
177
+ 158 Here, the $l o g ( p ( \mathcal { D } _ { n e w } | w ) )$ equals the cross-entropy loss of the model on $\mathcal { D } _ { n e w }$ while $l o g ( p ( w | \mathcal { D } _ { o l d } ) )$
178
+ 159 is loss of the model on $\mathcal { D } _ { o l d }$ . To ensure that catastrophic forgetting does not occur on $\mathcal { D } _ { o l d }$ in its
179
+ 160 absence while training on $\mathcal { D } _ { n e w }$ , the loss on $\mathcal { D } _ { o l d }$ will have to be approximated using $w$ alone. To do
180
+ 161 this, the Taylor’s expansion on $l o g ( p ( w | \mathcal { D } _ { o l d } ) )$ is taken as,
181
+
182
+ $$
183
+ \begin{array} { r l } & { \mathcal { L } _ { \mathcal { D } _ { o l d } } ( w ) \approx \mathcal { L } ( w ) \big | _ { \mathcal { D } _ { o l d } } + \left( \frac { \partial \mathcal { L } ( w ) } { \partial w } \Big | _ { \mathcal { D } _ { o l d } } \right) + \frac { 1 } { 2 } ( w - w \big | _ { \mathcal { D } _ { o l d } } ) ^ { T } \left( \frac { \partial ^ { 2 } \mathcal { L } ( w ) } { \partial ^ { 2 } w } \Big | _ { \mathcal { D } _ { o l d } } \right) ( w - w \big | _ { \mathcal { D } _ { o l d } } ) } \\ & { \qquad \approx \mathcal { L } ( w ) \big | _ { \mathcal { D } _ { o l d } } + \frac { 1 } { 2 } ( w - w \big | _ { \mathcal { D } _ { o l d } } ) ^ { T } \left( \frac { \partial ^ { 2 } \mathcal { L } ( w ) } { \partial ^ { 2 } w } \Big | _ { \mathcal { D } _ { o l d } } \right) ( w - w \big | _ { \mathcal { D } _ { o l d } } ) } \end{array}
184
+ $$
185
+
186
+ since technically 162 $\begin{array} { r } { \frac { \partial \mathcal { L } ( w ) } { \partial w } \bigg | _ { \mathcal { D } _ { o l d } } = 0 } \end{array}$ , if the model is trained well on $\mathcal { D } _ { o l d }$ . Then, noting that the last term 163 in (4) is equivalent to a regularization term, this term alone could be considered as the loss on $\mathcal { D } _ { o l d }$
187
+
188
+ 164 for preventing catastrophic forgetting. In doing so, the Fisher Information Matrix will equal to the
189
+ 165 Hessian, $\frac { \partial ^ { 2 } \mathcal { L } ( w ) } { \partial ^ { 2 } w } \bigg | _ { \mathscr { D } _ { o l d } } .$ This Hessian, $\mathcal { H }$ , can be simply computed by the model gradients $\frac { \bar { \partial \mathcal { L } } ( w ) } { \partial w } \bigg | _ { \mathscr { D } _ { o l d } }$
190
+ 166 assuming that not all gradients are zero, as,
191
+
192
+ $$
193
+ \mathcal { H } = \frac { \partial \mathcal { L } ( w ) } { \partial w } \bigg | _ { \mathcal { D } _ { o l d } } \cdot \frac { \partial \mathcal { L } ( w ) } { \partial w } \bigg | _ { \mathcal { D } _ { o l d } } ^ { T }
194
+ $$
195
+
196
+ 167 Doing so, and keeping only the diagonal terms, would imply that the model gradients are more
197
+ 168 than enough to weigh the important weights of the model trained on $\mathcal { D } _ { o l d }$ . Replacing (5) in (4) and
198
+ 169 substituting in (3) would give the loss on $\mathcal { D } _ { n e w }$ as,
199
+
200
+ $$
201
+ \mathcal { L } _ { \mathcal { D } _ { n e w } } ( w ) \approx l o g ( p ( \mathcal { D } _ { n e w } | w ) ) + \frac { 1 } { 2 } ( w - w \big | _ { \mathcal { D } _ { o l d } } ) ^ { T } \left( \frac { \partial \mathcal { L } ( w ) } { \partial w } \bigg | _ { \mathcal { D } _ { o l d } } \cdot \frac { \partial \mathcal { L } ( w ) } { \partial w } \bigg | _ { \mathcal { D } _ { o l d } } ^ { T } \right) ( w - w \big | _ { \mathcal { D } _ { o l d } } )
202
+ $$
203
+
204
+ 170 which to an extent implies that if the model gradients on $\mathcal { D } _ { o l d }$ are absolutely zero, they get trained on
205
+ 171 $\mathcal { D } _ { n e w }$ without regularization, while those that are not, get regularized towards $w \big | _ { \mathscr { D } _ { o l d } }$ .
206
+ 172 This is what the proposed Fisher Shut-off exploits. In Fisher Shut-off, all weights of the model
207
+ 173 trained on $\mathcal { D } _ { o l d }$ that do not have absolute zero gradients get shut-off for training on $\mathcal { D } _ { n e w }$ , while the
208
+ 174 remaining that do take part. Also, since in practice $R e L U$ functions are commonly used in deep
209
+ 175 learning models as the activation functions of the neurons, shutting off these weights becomes as
210
+ 176 simple as setting a condition. Figure 1 shows a sample performance of Fisher Shut-off on a regression
211
+ 177 model trained sequentially on mutually exclusive batches of data. These batches could represent the
212
+ 178 different tasks or training sets.
213
+ 179 However, when it comes to classification, simple shut-off does not work completely. This is because,
214
+ 180 while in regression problems datasets could inherently employ some kind of piece-wise nonlinear fit
215
+ 181 in their distributions, the same cannot always be guaranteed in classification. Thus, in classification,
216
+ 182 the shut-off weights must also take part in training. And, as per (1), there is a learning constant
217
+ 183 required in the regularization to ensure that the right balances between $\mathcal { D } _ { n e w }$ and $\mathcal { D } _ { o l d }$ are met on
218
+ 184 these weights. This paper provides a novel learning constant determination for this regularization.
219
+ 185 This is detailed in Appendix A.
220
+ 86 Also in regression problems, if datasets have batch distributions that are quite far apart from each
221
+ 87 previous batch, then Fisher-Shutoff may not fully work too. Appendix B shows some of these
222
+ 188 examples
223
+
224
+ ![](images/ec3ca6e1de828ff9f19c334a4f580525e37d7f6bbb827e170bad1c560561bda1.jpg)
225
+ Figure 1: Fisher Shut-off on a regression model on six mutually exclusive batches of data. Blue dots represent the overall dataset, while green square dots are the batch or task data. The red line is the model’s output after each batch is fed to it. Fisher Shut-off is used from Batch $\# 2$ onwards.
226
+
227
+ # 3.2 Fractional Data Retention
228
+
229
+ This is a very simply proposal. The idea is to retain only a fraction of the data trained on the neural network on the earlier tasks or training sets. There is nothing more to this. However, banking on the ideas of selection highlighted in Castro, et al. (2018), whereby data is selected based on their proximity to cluster centers, to be more representative of the classes, this paper uses this as the baseline idea behind its proposal on Fractional Data Retention. Thus in Fractional Data Retention, a fraction of the data within the data cluster is retained and appended in every stage of incremental learning.
230
+
231
+ # 197 3.3 Border Control
232
+
233
+ The most important requirement when incrementally learning classes is to ensure that the decision boundaries of the earlier training tasks are protected as much as possible when training on new sets. If data points are used for this purpose, it would seem that, those that lie closest to the decision boundaries after training would be the most important ones to retain, for any succeeding incremental learning tasks. Thus, the Border Control method proposed in this paper exploits this. Ruping (2001) used SVMs to identify these data points as the support vectors that helped define the overall decision boundaries. But with deep learning models or vanilla neural networks, SVM is quite complex and therefore in order to be able retain data points closest to the decision boundaries, a different selection mechanism is required. This selection mechanism could instead be based on selecting data points on how large the absolute errors in sigmoidal outputs are for the applied dataset, as the data points closest to the decision boundaries have this inherent property.
234
+
235
+ 209 Furthermore, since real world data can be quite complex, it would be necessary to not only select data
236
+ 210 points based on how large their errors in sigmoidal outputs are, but also those points that are far away
237
+ 211 from them. This is because, given the context of incremental learning where there is a high chance
238
+ 212 that newer training sets may have data points that could potentially set newer decision boundaries in
239
+ 213 those fartherest regions, these data points would help protect those.
240
+ 214 Hence in Border Control, the top- $\mathtt { k }$ data points that have the largest absolute errors in the sigmoidal
241
+ 215 outputs and their respective top- $\mathtt { k }$ fartherest data points are retained in every task or training set
242
+ 216 for further incremental learning. These points are appended to the newer training sets before further
243
+ 217 training is applied.
244
+
245
+ # 218 4 Sample Results
246
+
247
+ 219 The proposed methods are tested on a toy dataset, as mentioned in Section 1, only to provide some
248
+ 220 visuals on how the incremental learning progresses using the proposed methods. Figure 2 shows this
249
+ 221 dataset. A vanilla deep neural network of size, 1000-1000-1000-1000-3, is used for incrementally
250
+ 222 learning batches of data from this toy dataset. The activation functions for all layers are $R e L U$ except
251
+ 223 for the output which is a sof tmax. All weights are uniformly but randomly initialized with a single
252
+ 224 random seed to make the results comparable. The weights are also scaled by a $\frac { 2 } { \sqrt { n } }$ factor to ensure
253
+ 225 that minimal overfitting occurs during training. Here $n$ is the layer fan-in.
254
+ 226 To visualize incremental learning on the proposed methods, the dataset is divided into 6 batches
255
+ 227 with mututally exclusive data points. This gives roughly between 100 to 200 data points in each
256
+ 228 batch, a size that is commonly used when training neural networks of this size. Figure 3 shows this.
257
+ 229 In this figure, it can be clearly seen that the batch distributions on the class data for incremental
258
+ 230 learning do not always form a piece-wise nonlinear fit, and therefore, plain shut-off of weights cannot
259
+ 231 fully retain knowledge learned earlier. Also, among these distributions, some allowed incremental
260
+ 232 learning to happen easily, while others did not, and the distribution shown in Figure 3 is one such.
261
+ 233 Table 1 summarizes the results of the proposed methods on this particular distribution. For other batch
262
+ 234 distributions, similar results could be achieved. Note here that quite some ML-Ops were required to
263
+ 235 achieve the results in Table 1. This was especially the case for those that employed Fisher Shut-off,
264
+ 236 since this method has a regularization constant that requires adapting on each batch. Furthermore,
265
+ 237 training on each batch was stopped once $1 0 0 . 0 \%$ accuracy was obtained on the batch. This left quite
266
+ 238 some data points to lie very close to the boundary lines or in some cases just right on them. Thus,
267
+ 239 the neural network was very vulnerable to catastrophic forgetting when succeeding batch trainings
268
+ 240 occurred as part of incremental learning.
269
+ 241 However, taking a look at Table 1, it can be seen that when Fisher Shut-off is applied, additional
270
+ 242 leverage against catastrophic forgetting occurs on each incremental batch, than when it is not used.
271
+ 243 And, among the three methods proposed in this paper, the Border Control method shows much
272
+ 244 stronger performance. In Figure 4, sample decision boundaries learned when each incremental batch
273
+ 245 is applied to the neural network using Fisher Shut-off and Border Control together is shown. A topk
274
+ 246 value of 5 is used for the Border Control. Also, note in Figure 4 that the red circles mark the border
275
+ 247 points accumulated on each batch. It can be seen that they clearly assume the data points closest
276
+ 248 to the decision boundaries, as well as those far away from it. All with respect to their batches. For
277
+ 249 the far away data points, their purpose can be clearly seen between batches #1 and $\# 2$ , where the
278
+ 250 fartherest points of class 2 in Batch #1 helped protect the decision boundaries from the data points
279
+ 251 of class 0 in Batch $\# 2$ . This means that more complex datasets can be accommodated by simply
280
+ 252 applying Border Control. More examples are shown in Appendix C.
281
+
282
+ ![](images/ed5b8993eaca01d170d93842c74b1f8afc29195bd92a7249a0f7e6d54ce3a8c4.jpg)
283
+ Figure 2: The toy dataset having three nonlinearly arranged classes.
284
+
285
+ ![](images/b02e14d6cf3d7912dafbbcf85b828e0529858490504fb69b8d48e1be08459fa6.jpg)
286
+ Figure 3: Batches on the toy dataset.
287
+
288
+ Table 1: Performance of proposed methods on the dataset of Figure 2
289
+
290
+ <table><tr><td rowspan="2">Method</td><td colspan="6"> Sample accuracy on accumulated dataset after Batch1</td></tr><tr><td>#1</td><td>#2</td><td>#3</td><td>#4</td><td>#5</td><td>#6</td></tr><tr><td>No Incremental Learning</td><td>100.0%</td><td>90.98%2</td><td>92.76%</td><td>94.89%</td><td>98.32%</td><td>96.11%</td></tr><tr><td>Fisher Shut-off (FS)</td><td>100.0%</td><td>99.74%</td><td>98.19%</td><td>98.88%</td><td>98.96%</td><td>96.89%</td></tr><tr><td>Frac. Data Ret. (FDR)[10%]</td><td>100.0%</td><td>97.94%</td><td>98.39%</td><td>98.89%</td><td>98.71%</td><td>98.67%</td></tr><tr><td>FDR[20%]</td><td>100.0%</td><td>98.71%</td><td>98.59%</td><td>99.36%</td><td>98.97%</td><td>98.78%</td></tr><tr><td>Border Ctrl. (BC)[t opk = 5]</td><td>100.0%</td><td>100.0%</td><td>100.0%</td><td>99.84%</td><td>100.0%</td><td>100.0%</td></tr><tr><td>BC[topk = 10]</td><td>100.0%</td><td>100.0%</td><td>100.0%</td><td>99.84%</td><td>100.0%</td><td>100.0%</td></tr><tr><td>FS + FDR[10%]</td><td>100.0%</td><td>99.74%</td><td>98.79%</td><td>99.52%</td><td>99.23%</td><td>98.78%</td></tr><tr><td>FS + FDR[20%]</td><td>100.0%</td><td>100.0%</td><td>99.19%</td><td>99.52%</td><td>99.48%</td><td>99.11%</td></tr><tr><td>FS +BC[topk = 5]</td><td>100.0%</td><td>100.0%</td><td>100.0%</td><td>99.84%</td><td>100.0%</td><td>100.0%</td></tr><tr><td>FS + BC[topk = 10]</td><td>100.0%</td><td>100.0%</td><td>100.0%</td><td>100.0%</td><td>100.0%</td><td>100.0%</td></tr></table>
291
+
292
+ ![](images/5bccdefef0dd25c13f1ecc98bcf95de7a924e776d8da83295052a7d16b995c74.jpg)
293
+ Figure 4: Incremental learning using Fisher Shut-off and Border Control together $[ t o p k = 5 ]$ ]. Black circles mark the batch data, while the red circles mark the accumulated border points.
294
+
295
+ Also, to add on further to this, for the most difficult incremental learning applications such as learning new classes as highlighted in Castro, et al. (2018) and He, et al. (2020), Border Control can help leverage the many issues associated with it like class imbalance, concept drift and so on.
296
+
297
+ # 5 Conclusion
298
+
299
+ 257 To summarize the work in this paper, three simplified methods for implementing incremental learning
300
+ 258 for commercial fine-tuning of pre-trained models was proposed. Results showed that while Border
301
+ 259 Control performed the best, Fisher Shut-off was able to leverage the performances. However, dataset
302
+ 260 used in this paper was a toy dataset and not one of the benchmark datasets typically used for
303
+ 261 incremental learning. Hence, testing these methods on the benchmark datasets is a potential next step
304
+ 262 forward. Then, preparing the prerequisites for each model available, like say in huggingface.com,
305
+ 263 for incremental learning must be done so that automation companies or any other AI organization
306
+ 264 can make use of them. From the methods proposed in this paper, the prerequisites would be: 1)
307
+ 265 the Shut-off matrix for the neural network weights, and 2) the border points for each of the learned
308
+ 266 classes. Additionally, an ML-Ops infrastructure can be provided to optimize the performances of
309
+ 267 the models that employ the Fisher Shut-off method. Metrics like the Backward Transfer (BWT) and
310
+ 268 Forward Transfer (FWT) proposed in Lopez-Paz & Ranzato (2017) can be used for this purpose.
311
+
312
+ # 269 References
313
+
314
+ 270 [1] Aich, A. (2021) Elastic weight consolidation (EWC): Nuts and bolts. arXiv preprint arXiv:2105.04093.
315
+ 271 [2] Alshalali, T. & Joysula, D. (2018) Fine-Tuning of Pre-Trained Deep Learning Models with Extreme Learning
316
+ 272 Machine. IEEE International Conference on Computational Science and Computational Intelligence (CSCI), pp.
317
+ 273 469-473.
318
+ 274 [3] Castro, F., Marín-Jiménez, M.J., Guil, N., Schmid, C. & Alahari, K. (2018) End-to-end incremental learning.
319
+ 275 Proceedings of the European Conference on Computer Vision (ECCV), pp. 233-248.
320
+ 276 [4] Dif, N. & Elberrichi, Z. (2020) A New Intra Fine-Tuning Method. International Journal of Service Science,
321
+ 277 Management, Engineering, and Technology, 11(2), pp. 16-40.
322
+ 278 [5] He, J., Mao, R., Shao, Z. & Zhu, F. (2020) Incremental learning in online scenario. IEEE/CVF Conference
323
+ 279 on Computer Vision and Pattern Recognition, pp. 13926-13935.
324
+ 280 [6] Hinton, G., Vinyals, O. & Dean, J. (2015) Distilling the Knowledge in a Neural Network. arXiv preprint
325
+ 281 arXiv:1503.02531, 2(7).
326
+ 282 [7] Jung, H., Lee, S., Yim, J., Park, S. & Kim, J. (2015) Joint fine-tuning in deep neural networks for facial
327
+ 283 expression recognition. Proceedings of the IEEE International Conference on Computer Vision, pp. 2983-2991.
328
+ 284 [8] Kirkpatrick, J., Pascanu, R., Rabinowitz, N., Veness, J., Desjardins, G., Rusu, A.A., Milan, K., Quan, J.,
329
+ 285 Ramalho, T., Grabska-Barwinska, A. & Hassabis, D. (2017) Overcoming catastrophic forgetting in neural
330
+ 286 networks. Proceedings of the National Academy of Sciences, 114(13), pp. 3521-3526.
331
+ 287 [9] Lopez-Paz, D. & Ranzato, M.A. (2017) Gradient episodic memory for continual learning. Proceedings of
332
+ 288 Neural Information Processing Systems (NIPS), pp. 6467-6476.
333
+ 289 [10] Luo, Y., Yin, L., Bai, W. & Mao, K. (2020) An Appraisal of Incremental Learning Methods. Entropy,
334
+ 290 22(11), pp. 1190-1216.
335
+ 291 [11] Odena, A., Olah, C. & Shlens, J. (2017) Conditional image synthesis with auxiliary classifier GANs.
336
+ 292 International Conference on Machine Learning (ICML), pp. 2642–2651.
337
+ 293 [12] Polikar, R., Udpa, L., Udpa, S. & Honavar, V. (2001) Learn++: An Incremental Learning Algorithm for
338
+ 294 Supervised Neural Networks. IEEE Transactions on Systems, Man, and Cybernetics, part C (applications and
339
+ 295 reviews), 31(4), pp. 497-508.
340
+ 296 [13] Qian, X., Zhang, C., Yella, J., Huang, Y., Huang, M.C. & Bom, S. (2021) Soft sensing model visualization:
341
+ 297 Fine-tuning neural network from what model learned. IEEE International Conference on Big Data (Big Data),
342
+ 298 pp. 1900-1908.
343
+ 299 [14] Ren, M., Zeng, W., Yang, B. & Urtasun, R. (2018) Learning to reweight examples for robust deep learning.
344
+ 300 International Conference on Machine Learning (ICML), pp. 4334-4343.
345
+ 301 [15] Ruping, S. (2001) Incremental learning with support vector machines. IEEE International Conference on
346
+ 302 Data Mining, pp. 641-642.
347
+ 303 [16] Rusu, A.A., Rabinowitz, N.C., Desjardins, G., Soyer, H., Kirkpatrick, J., Kavukcuoglu, K., Pascanu, R. &
348
+ 304 Hadsell, R. (2016) Progressive neural networks. arXiv preprint arXiv:1606.04671.
349
+ 305 [17] Too, E., Yujian, L., Njuki, S. & Yingchun, L. (2019) A comparative study of fine-tuning deep learning
350
+ 306 models for plant disease. Computers and Electronics in Agriculture, 161, pp. 272-279.
351
+ 307 [18] Vrbanciˇ c, G. & Podgorelec, V. (2020) ˇ Transfer learning with adaptive fine-tuning. IEEE Access, Volume 8,
352
+ 308 pp. 196197-196211.
353
+ 309 [19] Wu, Y., Chen, Y.P., Wang, L.J., Ye, Y.C., Liu, Z.C., Guo, Y.D., Zhang, Z.Y. & Fu, Y. (2018) Incremental
354
+ 310 Classifier Learning with Generative Adversarial Networks. arXiv preprint arXiv:1802.00853.
355
+
356
+ 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:
357
+
358
+ • Did you include the license to the code and datasets? [Yes] See Section ??.
359
+ • Did you include the license to the code and datasets? [No] The code and the data are proprietary.
360
+ • Did you include the license to the code and datasets? [N/A]
361
+
362
+ 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.
363
+
364
+ 1. For all authors...
365
+
366
+ (a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes]
367
+ (b) Did you describe the limitations of your work? [Yes] See Sections 4 and 5
368
+ (c) Did you discuss any potential negative societal impacts of your work? [N/A]
369
+ (d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
370
+
371
+ 2. If you are including theoretical results...
372
+
373
+ (a) Did you state the full set of assumptions of all theoretical results? [Yes] See Section 3 and Appendix A
374
+ (b) Did you include complete proofs of all theoretical results? [Yes] See Section 3 and Appendix A
375
+
376
+ 3. If you ran experiments...
377
+
378
+ (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] As a supplemental material
379
+ (b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [No] But it’s in the supplemental material
380
+ (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [No] But additional examples are shown in Appendix C
381
+ (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]
382
+
383
+ 4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
384
+
385
+ (a) If your work uses existing assets, did you cite the creators? [N/A]
386
+ (b) Did you mention the license of the assets? [N/A]
387
+ (c) Did you include any new assets either in the supplemental material or as a URL? [N/A]
388
+ (d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [N/A]
389
+ (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [N/A]
390
+
391
+ 5. If you used crowdsourcing or conducted research with human subjects...
392
+
393
+ (a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A]
394
+ (b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A]
395
+ (c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]
396
+
397
+ 362 Here, the derivation of regularization constant for Fisher Shut-off method is detailed. To start with,
398
+ 363 let the neural network be defined as,
399
+
400
+ $$
401
+ y = w ^ { T } \phi ( x , \omega )
402
+ $$
403
+
404
+ 364 Here, $w$ is the weights of the output layer, $\phi ( \cdot )$ is the output of the preceding layer, $x$ is the input and
405
+ 365 $\omega$ represents the rest of the weights of the neural network. Throughout the derivation, we will be
406
+ 366 dealing with only the output layer, and so the $\phi ( x , \omega )$ will be written in short form as $\Phi$ from here on.
407
+ 367 Let $e _ { k }$ denoted the error of fitting in the $k$ -th iteration, and $g _ { k }$ denote the error gradient. This would
408
+ 368 mean that $g _ { k } = \Phi _ { k } e _ { k }$ .
409
+ 369 Then, given the regularization term in (6), let $\tilde { w }$ denote difference in weights, between the new
410
+ 370 training and the previous training. This would give the weight updation policy as,
411
+
412
+ $$
413
+ w _ { k + 1 } = w _ { k } - \eta g _ { k } - \beta \tilde { w } _ { k }
414
+ $$
415
+
416
+ If 371 $e _ { k } = w _ { k } ^ { T } \Phi _ { k } - Y$ , then the error $e _ { k + 1 }$ after the weight updation would equal,
417
+
418
+ $$
419
+ \begin{array} { r l } & { e _ { k + 1 } = w _ { k + 1 } ^ { T } \Phi _ { k + 1 } - Y } \\ & { \qquad = ( w _ { k } - \eta g _ { k } - \beta \tilde { w } _ { k } ) ^ { T } \Phi _ { k + 1 } - Y } \\ & { \qquad = w _ { k } ^ { T } \Phi _ { k + 1 } - \eta g _ { k } ^ { T } \Phi _ { k + 1 } - \beta \tilde { w } _ { k } ^ { T } \Phi _ { k + 1 } - Y } \end{array}
420
+ $$
421
+
422
+ 372 Asumming for simplicity sake that $\Phi _ { k + 1 } \approx \Phi _ { k } + \delta$ , then (9) can continue as,
423
+
424
+ $$
425
+ \begin{array} { c } { { e _ { k + 1 } \approx w _ { k } ^ { T } \Phi _ { k } - \eta g _ { k } ^ { T } \Phi _ { k } - \beta \tilde { w } _ { k } ^ { T } \Phi _ { k } - Y + \Delta } } \\ { { { } } } \\ { { \approx e _ { k } - \eta g _ { k } ^ { T } \Phi _ { k } - \beta \tilde { w } _ { k } ^ { T } \Phi _ { k } } } \end{array}
426
+ $$
427
+
428
+ 373 Taking the square norm of $e _ { k + 1 }$ in (10), would equate this to,
429
+
430
+ $$
431
+ \begin{array} { r l } & { | | e _ { k + 1 } | | ^ { 2 } = | | e _ { k } | | ^ { 2 } + \eta ^ { 2 } | | g _ { k } ^ { T } \Phi _ { k } | | ^ { 2 } + \beta ^ { 2 } | | \tilde { w } _ { k } ^ { T } \Phi _ { k } | | ^ { 2 } } \\ & { ~ - ~ 2 \eta e _ { k } ^ { T } \Phi _ { k } ^ { T } g _ { k } - 2 \beta e _ { k } ^ { T } \Phi _ { k } ^ { T } \tilde { w } _ { k } + 2 \eta \beta \tilde { w } _ { k } ^ { T } \Phi _ { k } \Phi _ { k } ^ { T } g _ { k } } \end{array}
432
+ $$
433
+
434
+ 374 We require that $| | e _ { k + 1 } | | ^ { 2 } < | | e _ { k } | | ^ { 2 }$ at all times, so that regularization does not affect the fit at any
435
+ 375 point during the training. Applying this condition in (11) would give,
436
+
437
+ $$
438
+ \eta ^ { 2 } | | g _ { k } ^ { T } \Phi _ { k } | | ^ { 2 } + \beta ^ { 2 } | | \tilde { w } _ { k } ^ { T } \Phi _ { k } | | ^ { 2 } - 2 \eta e _ { k } ^ { T } \Phi _ { k } ^ { T } g _ { k } - 2 \beta e _ { k } ^ { T } \Phi _ { k } ^ { T } \tilde { w } _ { k } + 2 \eta \beta \tilde { w } _ { k } ^ { T } \Phi _ { k } \Phi _ { k } ^ { T } g _ { k } < 0
439
+ $$
440
+
441
+ 376 Then, taking the partial derivatives of (12) w.r.t $\eta$ and $\beta$ would give the following equations to be
442
+ 377 satisfied:
443
+
444
+ $$
445
+ \eta | | g _ { k } ^ { T } \Phi _ { k } | | ^ { 2 } - e _ { k } ^ { T } \Phi _ { k } ^ { T } g _ { k } + \beta \tilde { w } _ { k } ^ { T } \Phi _ { k } \Phi _ { k } ^ { T } g _ { k } = 0
446
+ $$
447
+
448
+ $$
449
+ \beta | | \tilde { w } _ { k } ^ { T } \Phi _ { k } | | ^ { 2 } - e _ { k } ^ { T } \Phi _ { k } ^ { T } \tilde { w } _ { k } + \eta \tilde { w } _ { k } ^ { T } \Phi _ { k } \Phi _ { k } ^ { T } g _ { k } = 0
450
+ $$
451
+
452
+ 378 Solving, (13) and (14) can result in negative $\eta$ and $\beta$ , which is not acceptable, and so to simplify the
453
+ 379 solution, we neglect the $\beta$ -term in (13). Doing so we get,
454
+
455
+ $$
456
+ \begin{array} { r l } & { \eta = \frac { e _ { k } ^ { T } \Phi _ { k } ^ { T } g _ { k } } { \vert \vert g _ { k } ^ { T } \Phi _ { k } \vert \vert ^ { 2 } } , } \\ & { } \\ & { \beta = \frac { e _ { k } ^ { T } \Phi _ { k } ^ { T } \tilde { w } _ { k } - \eta \tilde { w } _ { k } ^ { T } \Phi _ { k } \Phi _ { k } ^ { T } g _ { k } } { \vert \vert \tilde { w } _ { k } ^ { T } \Phi _ { k } \vert \vert ^ { 2 } } } \end{array}
457
+ $$
458
+
459
+ 380 Then, substituting for $g _ { k }$ and openning up the norms, we get,
460
+
461
+ $$
462
+ \eta = \frac { e _ { k } ^ { T } \Phi _ { k } ^ { T } \Phi _ { k } e _ { k } } { e _ { k } ^ { T } ( \Phi _ { k } ^ { T } \Phi _ { k } ) ( \Phi _ { k } ^ { T } \Phi _ { k } ) e _ { k } } ,
463
+ $$
464
+
465
+ $$
466
+ \beta = \frac { e _ { k } ^ { T } \Phi _ { k } ^ { T } \tilde { w } _ { k } - \eta \tilde { w } _ { k } ^ { T } ( \Phi _ { k } \Phi _ { k } ^ { T } ) \Phi _ { k } e _ { k } } { \tilde { w } _ { k } ^ { T } ( \Phi _ { k } \Phi _ { k } ^ { T } ) \tilde { w } _ { k } }
467
+ $$
468
+
469
+ 381 Simplifying (16) gives,
470
+
471
+ $$
472
+ \eta = \frac { e _ { k } ^ { T } e _ { k } } { e _ { k } ^ { T } \Phi _ { k } ^ { T } \Phi _ { k } e _ { k } } ,
473
+ $$
474
+
475
+ $$
476
+ \beta = ( 1 - \eta ) \frac { \tilde { w } _ { k } ^ { T } \Phi _ { k } e _ { k } } { \tilde { w } _ { k } ^ { T } \tilde { w } _ { k } }
477
+ $$
478
+
479
+ 382 Equation (17) gives the raw form for both $\eta$ and $\beta$ to be regulated. However, this will be further
480
+ 383 simplified for computating purposes, but will be used as a basis.
481
+ 384 Since the errors $e _ { k }$ get smaller as the neural network fits the data, using them in learning constants
482
+ 385 will only slow down the fits. A common way to overcome this is by replacing $e _ { k }$ with all ones.
483
+ 386 Similarly, for the $\tilde { w } _ { k }$ , all weights that are to be regularized are replaced with ones. If we denote
484
+ 387 the weights to be regularized as $w _ { r }$ , and there are $m$ patterns in the dataset with $n$ weights to be
485
+ 388 regularized, the $\eta$ and $\beta$ computations become,
486
+
487
+ $$
488
+ \eta = \frac { 1 } { | | \Phi _ { k } | | ^ { 2 } } ,
489
+ $$
490
+
491
+ $$
492
+ \beta = \frac { \alpha } { m n } \sum _ { i : w \in w _ { r } } \Phi _ { i , k }
493
+ $$
494
+
495
+ 389 Here, $\alpha$ represents the $( 1 - \eta )$ -term in (17). This constant will not neccessarily take the computed $\eta$
496
+ 390 when being regulated. Instead, this constant will have to be adapted each time for every incremental
497
+ 391 batch applied to the neural network.
498
+ 392 The reason why the computed $\eta$ is not used for the $\alpha$ adaptation is because this $\eta$ can sometimes
499
+ 393 become too small in the adaptation, that the $1 - \eta$ would always tend towards 1. When this was
500
+ 394 empirically tested on the toy dataset, the regularization was found at times to have gone too strong
501
+ 395 that the fit never happened. ML-Ops on the $\alpha$ found that this constant is not always 1, and can be
502
+ 396 anywhere between 0 and 1, or higher in some cases.
503
+
504
+ 398 Additional examples on the regression problem with Fisher Shut-off. Fisher Shut-off could not be used completely, and regularization had to take over for some batches. Figures 5 and 6 show this.
505
+
506
+ ![](images/72e9762490cf8ee10f248a8d3a0d85b6b28ea32a596f13c1b194dc4898ba90c7.jpg)
507
+ Figure 5: Complete Fisher Shut-off is used in Batches #2 and #6. Batches #3, #4 and #5 are regularized.
508
+
509
+ ![](images/b70e35df8ae79c3da760bbd94c1191f3f81fda2aacf6961298510e013e24a3ed.jpg)
510
+ Figure 6: Complete Fisher Shut-off is used in Batches $\# 2$ and $\# 6$ . Batches $\# 3$ and $\# 4$ are regularized. Batch #5 is fine-tuned
511
+
512
+ 401 In this appendix, additional examples on the toy dataset classification is shown. Figures 7 and 8 show 402 the batch distributions considered. Among these, Figure 8 has more cases in which the farthest points 403 in Border Control can play a vital role in retaining previously learned knowledge. Tables 2 and 3 summarize their performances.
513
+
514
+ ![](images/df00e79da7646169cbe201b37f70a3bcbb78337b977ceaff9e318f5cd16ecc4a.jpg)
515
+ Figure 7: Another batch distribution on the toy dataset.
516
+
517
+ Table 2: Performance of proposed methods on the dataset of Figure 7
518
+
519
+ <table><tr><td rowspan="2">Method</td><td colspan="6">Sample accuracy on accumulated dataset after Batch</td></tr><tr><td>#1</td><td>#2</td><td>#3</td><td>#4</td><td>#5</td><td>#6</td></tr><tr><td>No Incremental Learning</td><td>100.0%</td><td>73.14%</td><td>92.07%</td><td>97.56%</td><td>88.33%</td><td>91.67%</td></tr><tr><td>Fisher Shut-off (FS)</td><td>100.0%</td><td>99.43%</td><td>98.26%</td><td>99.54%</td><td>92.85%</td><td>97.78%</td></tr><tr><td>Frac. Data Ret. (FDR)[10%]</td><td>100.0%</td><td>97.43%</td><td>96.13%</td><td>98.93%</td><td>98.75%</td><td>96.78%</td></tr><tr><td>FDR[20%]</td><td>100.0%</td><td>98.86%</td><td>98.84%</td><td>99.69%</td><td>99.75%</td><td>98.89%</td></tr><tr><td>Border Ctrl. (BC)[topk = 5]</td><td>100.0%</td><td>100.0%</td><td>100.0%</td><td>100.0%</td><td>100.0%</td><td>99.78%</td></tr><tr><td>BC[topk = 10]</td><td>100.0%</td><td>100.0%</td><td>100.0%</td><td>100.0%</td><td>100.0%</td><td>100.0%</td></tr><tr><td>FS + FDR[10%]</td><td>100.0%</td><td>99.71%</td><td>98.84%</td><td>99.54%</td><td>98.75%</td><td>98.33%</td></tr><tr><td>FS + FDR[20%]</td><td>100.0%</td><td>100.0%</td><td>99.23%</td><td>99.85%</td><td>99.87%</td><td>98.89%</td></tr><tr><td>FS +BC[topk = 5]</td><td>100.0%</td><td>100.0%</td><td>100.0%</td><td>100.0%</td><td>100.0%</td><td>100.0%</td></tr><tr><td>FS + BC[topk = 10]</td><td>100.0%</td><td>100.0%</td><td>100.0%</td><td>100.0%</td><td>100.0%</td><td>100.0%</td></tr></table>
520
+
521
+ ![](images/198dee612d5cdc63ee02fcb729ec0a2fd31f55ddf925d97353d37ff12ee507bd.jpg)
522
+ Figure 8: Yet another batch distribution on the toy dataset.
523
+
524
+ Table 3: Performance of proposed methods on the dataset of Figure 8
525
+
526
+ <table><tr><td rowspan="2">Method</td><td colspan="6">Sample accuracy on accumulated dataset after Batch</td></tr><tr><td>#1</td><td>#2</td><td>#3</td><td>#4</td><td>#5</td><td>#6</td></tr><tr><td>No Incremental Learning</td><td>100.0%</td><td>89.34%</td><td>93.80%</td><td>95.60%</td><td>97.81%</td><td>84.78%</td></tr><tr><td>Fisher Shut-off (FS)</td><td>100.0%</td><td>95.36%</td><td>99.59%</td><td>99.55%</td><td>99.36%</td><td>94.56%</td></tr><tr><td>Frac. Data Ret. (FDR)[10%]</td><td>100.0%</td><td>95.08%</td><td>96.07%</td><td>97.42%</td><td>99.61%</td><td>98.67%</td></tr><tr><td>FDR[20%]</td><td>100.0%</td><td>98.36%</td><td>98.97%</td><td>99.85%</td><td>100.0%</td><td>99.67%</td></tr><tr><td>Border Ctrl. (BC)[top k = 5]</td><td>100.0%</td><td>100.0%</td><td>99.79%</td><td>99.85%</td><td>100.0%</td><td>100.0%</td></tr><tr><td>BC[topk = 10]</td><td>100.0%</td><td>100.0%</td><td>100.0%</td><td>100.0%</td><td>99.74%</td><td>100.0%</td></tr><tr><td>FS + FDR[10%]</td><td>100.0%</td><td>95.36%</td><td>99.79%</td><td>98.48%</td><td>99.61%</td><td>98.89%</td></tr><tr><td>FS + FDR[20%]</td><td>100.0%</td><td>98.36%</td><td>99.79%</td><td>99.69%</td><td>100.0%</td><td>99.67%</td></tr><tr><td>FS+BC[topk = 5]</td><td>100.0%</td><td>100.0%</td><td>100.0%</td><td>100.0%</td><td>99.74%</td><td>100.0%</td></tr><tr><td>FS + BC[topk = 10]</td><td>100.0%</td><td>100.0%</td><td>100.0%</td><td>100.0%</td><td>100.0%</td><td>100.0%</td></tr></table>
md/dev/Rg1LG7wtd2D/Rg1LG7wtd2D.md ADDED
The diff for this file is too large to render. See raw diff
 
md/dev/S874XAIpkR-/S874XAIpkR-.md ADDED
@@ -0,0 +1,224 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # RVS: WHAT IS ESSENTIAL FOR OFFLINE RL VIA SUPERVISED LEARNING?
2
+
3
+ Scott Emmons1, Benjamin Eysenbach2, Ilya Kostrikov1, Sergey Levine1
4
+ 1UC Berkeley, 2Carnegie Mellon University
5
+ emmons@berkeley.edu
6
+
7
+ # ABSTRACT
8
+
9
+ Recent work has shown that supervised learning alone, without temporal difference (TD) learning, can be remarkably effective for offline RL. When does this hold true, and which algorithmic components are necessary? Through extensive experiments, we boil supervised learning for offline RL down to its essential elements. In every environment suite we consider, simply maximizing likelihood with a two-layer feedforward MLP is competitive with state-of-the-art results of substantially more complex methods based on TD learning or sequence modeling with Transformers. Carefully choosing model capacity (e.g., via regularization or architecture) and choosing which information to condition on (e.g., goals or rewards) are critical for performance. These insights serve as a field guide for practitioners doing Reinforcement Learning via Supervised Learning (which we coin $R \nu S$ learning). They also probe the limits of existing RvS methods, which are comparatively weak on random data, and suggest a number of open problems.
10
+
11
+ # 1 INTRODUCTION
12
+
13
+ Offline and off-policy reinforcement learning (RL) are typically addressed using value-based methods. While theoretically appealing because they include performance guarantees under certain assumptions [27], such methods can be difficult to apply in practice; they tend to require complex tricks to stabilize learning and delicate tuning of many hyperparameters. Recent work has explored an alternative approach: convert the RL problem into a conditional, filtered, or weighted imitation learning problem. This typically uses a simple insight: suboptimal experience for one task may be optimal for another task. By conditioning on some piece of information, such as a goal, reward function parameterization, or reward value, such experience can be used for simple behavior cloning [5, 6, 8, 10, 17, 23, 26, 29, 32, 34, 38]. We refer to this set of approaches as RL VIA SUPERVISED LEARNING (RVS). These approaches commonly condition on goals [6, 18, 29] or reward values [5, 26, 38], but they can also involve reweighting or filtering [10, 26, 32, 34].
14
+
15
+ ![](images/c1d0d10fe2666eeeb4f927243a778ca87037c3aa94769cc3ce70fc3673aba7c4.jpg)
16
+ Figure 1: RvS learning conditioned on goals (RvS-G) and on rewards (RvS-R) compared with prior approaches and baselines. Each bar is the average over many tasks in each suite. Using just supervised learning with a feedforward MLP, RvS matches the performance of methods employing TD learning and Transformer sequence models. https://github.com/scottemmons/rvs
17
+
18
+ ![](images/3849d7903901d5f95945ac57e24af43f29c62a2f7553f62c2f1f75ca87c436c0.jpg)
19
+ Figure 2: (a) As input, RvS takes a precollected replay buffer of experience. An outcome $\omega$ can be an arbitrary function of the trajectory, such as future states or rewards. (b) RvS uses hindsight relabeling of the replay buffer to construct a training dataset. The observed actions act as demonstrations for the observed outcomes. (c) Our implementation of RvS uses an MLP with two fully connected (fc) layers to predict actions. At test time, we can condition on arbitrary outcomes.
20
+
21
+ RvS methods are appealing because of their algorithmic simplicity. However, prior work has put forward conflicting hypotheses about which factors are essential for their good performance, including online data [18], advantage weighting [26], or large Transformer sequence models [5]. The first question we study is: what elements are essential for effective RvS learning? Beyond this, it also remains unclear on which tasks and datasets such methods work well. For example, prior work has argued that temporal compositionality (dubbed “subtrajectory stitching”) is an important component for solving offline RL when there are few near-optimal trajectories present in the data (e.g., the Franka Kitchen and AntMaze tasks in D4RL [12]). A priori, one might expect that dynamic programming via TD learning is needed for these tasks. So we also ask: what are the limits of $R \nu S$ learning, and does it scale to settings with few near-optimal trajectories?
22
+
23
+ The main contribution of this paper is a study of RvS methods on a wide range of offline RL problems, as well as a set of analyses about which design factors matter most for such methods. First, we show that pure supervised learning (maximizing the likelihood of actions observed in the data) performs as well as conservative TD learning across a diverse set of environments. Second, simple feedforward models can match the performance of more complex sequence models from prior work across a wide range of tasks. Finally, choosing to condition on reward values versus goals can have a large effect on performance, with different choices working better in different domains. These simple results contradict the narrative put forward in many prior works that argue for more complex design decisions [5, 26, 27]. To the best of our knowledge, our results match or exceed those reported by any prior RvS method. We believe that these findings will be useful to the RL community because they help to understand the essential ingredients and limitations of RvS methods, providing a foundation for future work on simple and performant offline RL algorithms.
24
+
25
+ # 2 RELATED WORK
26
+
27
+ Recent offline RL methods use many techniques, including value functions [15, 27], dynamics estimation alongisde value functions [24, 37, 42], dynamics estimation alone [3, 7, 39], and uncertainty quantification [1, 41, 42]. In this paper, we focus on offline RL methods based on conditional behavior cloning that avoid value functions. The most common instantiation of these methods are goal-conditioned behavior cloning [8, 18, 29] and reward-conditioned behavior cloning [26, 35, 38]. Prior work has also looked at conditioning on different information, such as many previous timesteps [5, 23], tasks inferred by inverse RL [10], and other task information [6, 21]. While these methods can be directly applied to the offline RL setting, some prior works combine these methods with iterative data collection [18, 38], which is not permitted in the typical offline RL setting. Kumar et al. [26] study reward-conditioned policies and do present experiments in the offline RL setting. However, in contrast with our work, the results from Kumar et al. [26] suggest that good performance cannot be achieved through RvS learning but only through additional advantageweighting [32, 34]. More recent work [5] presents a conditional imitation learning method for the offline RL setting that avoids advantage weighting by introducing a higher-capacity, autoregressive Transformer policy. In contrast to these prior works, we show that simple conditioning with standard feedforward networks can attain state-of-the-art results. While these results do not require advantage weighting or high-capacity sequence models, they do require careful tuning of the policy capacity.
28
+
29
+ # 3 REINFORCEMENT LEARNING VIA SUPERVISED LEARNING
30
+
31
+ In this section, we describe a formulation of Reinforcement Learning via Supervised Learning. We do not propose a new method but rather place many existing methods under a common framework. After this, we will investigate what design decisions are important to make such methods work well.
32
+
33
+ To formulate RvS methods in a general way, we assume an agent interacts with a Markov decision process with states $s _ { t }$ , actions $a _ { t }$ , initial state distribution $p _ { s } ( s _ { 1 } )$ , and dynamics $p ( s _ { t + 1 } \mid s _ { t } , a _ { t } )$ . The agent chooses actions using a policy $\pi _ { \boldsymbol { \theta } } { \left( a _ { t } \ \middle | \ s _ { t } \right) }$ parameterized by $\theta$ . We assume episodes have fixed length $H$ and use $\tau = ( s _ { 1 } , a _ { 1 } , r _ { 1 } , s _ { 2 } , a _ { 2 } , r _ { 2 } , \cdot \cdot \cdot )$ to denote a trajectory of experience. As some trajectories might be described using multiple outcomes, we use $f ( \omega \mid \tau )$ to denote the distribution over outcomes that occur in a trajectory. We study two types of outcomes. The first type of outcome is a state $( \omega \in S )$ that the agent visits in the future: $f ( \omega \mid \tau _ { t : H } ) = \operatorname { U n i f } ( s _ { t + 1 } , s _ { t + 2 } , \cdot \cdot \cdot , s _ { H } )$ . We refer to RvS methods that learn goal-conditioned policies as $R \nu S – G$ . The second type of outcome is the average return $( \omega \in \mathbb { R } )$ ) achieved over some future number of time steps: $f ( \omega \mid \tau _ { t : H } ) =$ 1H−t+1 PHt0=t r(st0 , at0 )). (Note that we found it important to use the max episode length as a constant $H$ in the denominator for all trajectories, treating early terminations as if they received 0 reward after they terminated.) We refer to RvS methods that learn reward-conditioned policies as $R \nu S – R$ . It is also possible to condition on other information, such as the parameters of a reward function inferred via inverse RL [10] or the parameters of a task, such as turning left or right [6]. We focus on RvS methods applied to the offline RL setting. These methods take as input a dataset of experience, $\mathcal { D } = \{ \tau \}$ and find the outcome-conditioned policy $\pi _ { \boldsymbol { \theta } } ( a _ { t } \mid s _ { t } , \omega )$ that optimizes
34
+
35
+ $$
36
+ \operatorname* { m a x } _ { \theta } \quad \sum _ { \tau \in \mathcal { D } }
37
+ $$
38
+
39
+ $$
40
+ \sum _ { 1 \leq t \leq \vert \tau \vert } \mathbb { E } _ { \omega \sim f ( \omega \vert \tau _ { t : H } ) } [ \log \pi _ { \theta } ( a _ { t } \mid s _ { t } , \omega ) ] .
41
+ $$
42
+
43
+ While the basic formulation of this conditional policy is simple, instantiating RvS methods that attain excellent results has proven challenging [26, 38]. In the remainder of this paper, we present an empirical analysis of the design choices in RvS methods. We aim to understand which design choices are needed to make RvS methods perform well on diverse benchmark tasks, including how two different choices for $\omega$ (goals and rewards) compare in practice.
44
+
45
+ # Algorithm 1 RvS-Learning
46
+
47
+ 1: Input: Dataset of trajectories, $\mathcal { D } = \{ \tau \}$
48
+ 2: Initialize policy $\pi _ { \boldsymbol { \theta } } ( a \mid s , \omega )$ .
49
+ 3: while not converged do
50
+ 4: Randomly sample trajectories: $\tau \sim \mathcal { D }$ .
51
+ 5: Sample time index for each trajetory, $t \sim [ 1 , H ]$ , and
52
+ sample a corresponding outcome: $\omega \sim f ( \omega \mid \tau _ { t : H } )$ .
53
+ 6: Compute loss: $\begin{array} { r } { \mathcal { L } ( \boldsymbol { \theta } ) \gets \sum _ { ( s _ { t } , a _ { t } , \omega ) } \log \pi _ { \boldsymbol { \theta } } ( a _ { t } \mid s _ { t } , \omega ) } \end{array}$
54
+ 7: Update policy parameters: $\theta \gets \theta + \eta \nabla _ { \theta } \mathcal { L } ( \theta )$
55
+ 8: end while
56
+ 9: return Conditional policy $\pi _ { \boldsymbol { \theta } } ( a \mid s , \omega )$
57
+
58
+ # 4 TASKS AND DATASETS
59
+
60
+ To provide a comprehensive empirical study of RvS methods, we selected a broad range of tasks; the state-based tasks in prior work on various types of RvS or conditional imitation methods typically include only a subset of the domains we consider [5, 18, 26]. Our goal will be to include: (1) domains and datasets that are appropriate for different types of conditioning, including goals and rewards; (2) datasets that include different proportions of near-optimal data, ranging from near-expert datasets to ones with very few or no optimal trajectories at all; (3) datasets that run the gamut in terms of task dimensionality; (4) domains that have been studied by prior value-based offline RL methods.
61
+
62
+ ![](images/d5604ba6becdf3b8c3c88dae916b6407faa643a09cb0597ccd1c4744d111d8ab.jpg)
63
+
64
+ GCSL is a suite of goal-conditioned environments used by Ghosh et al. [18] to evaluate GCSL, a goal-conditioned RvS method with online data collection. We adapt these tasks for offline RL by using a random policy to collect training data, which results in suboptimal trajectories. The tasks include 2D navigation with obstacles (FourRooms, Eysenbach et al. [9]); two end-effector controlled Sawyer robotic arm tasks (Door and Pusher, Nair et al. [31]); the Lunar Lander video game, which requires controlling thrusters to land a simulated Lunar Excursion Module (Lander); and a manipulation task that requires rotating a valve with a robotic claw (Claw, Ahn et al. [2]).
65
+
66
+ Gym Locomotion v2 tasks consist of the HalfCheetah, Hopper, and Walker datasets from the D4RL offline RL benchmark [12]. We use the random, medium, medium-expert, and medium-replay datasets in our evaluations, which consist of (a mixture of different) policies with varying levels of optimality. This requires learning from mixed and suboptimal data, and we will see that TD learning methods perform comparatively well on the random data.
67
+
68
+ ![](images/646ed5a2622b20b3acc6bfd532782ac2805ebb17d59898a72e3666da3c67d7f1.jpg)
69
+
70
+ Franka Kitchen v0 is a 9-DoF robotic manipulation task paired with datasets of human demonstrations. This task originates from Gupta et al. [19] and was formalized as an offline RL task in D4RL [12]. Solving this task requires composing multi-step behaviors (e.g., open the microwave, then flip a switch) from component skills. This task includes three datasets: complete, where all trajectories solve all tasks in sequence; partial, where only a subset of trajectories perform the desired tasks in sequence; and mixed, which contains various subtasks but never all in sequence, requiring generalization and temporal composition.
71
+
72
+ ![](images/76324f01b11cc7e721008b0c6546bc1380507804ae5ebb08f1d488b4449483a9.jpg)
73
+
74
+ AntMaze v2 involves controlling an 8-DoF quadruped to navigate to a particular goal state. This benchmark task, from D4RL [12], uses a non-Markovian demonstrator policy and was intended to test an agent’s ability to learn temporal compositionality by combining subtrajectories of different demonstrations. There are three mazes of increasing size: umaze, medium, and large, and there are two datasets types: diverse and $_ { \mathrm { p \perp a y } }$ . The D4RL paper [12] claims that “diverse” data navigates from random start locations to random goal locations while “play” navigates between hand-picked start-goal pairs. Prior work has proposed that, for tasks requiring temporal compositionality, dynamic programming with valuebased methods should be particularly important [12]. However, we find in AntMaze that RvS outperforms all the dynamic programming methods we consider.
75
+
76
+ ![](images/fcbbf308633f4079052f2363a60b38fbf367cd12e21a74686820276ab4aa0f1b.jpg)
77
+
78
+ When applying RvS learning methods, one must choose a type of outcome, such as rewards or goals. In Kitchen and AntMaze, the reward function is implemented in terms of goals. The kitchen reward is for completing multiple subtasks, so we condition RvS-G on a state in which all the subtasks have been achieved. For AntMaze, we condition RvS-G on the goal location in the maze. This choice makes the additional assumption that we know how the reward function is defined, rather than just receiving samples from the reward function. Because GCSL is inherently a multitask, goal-conditioned setup, we omit reward conditioning and only report RvS-G. Conversely, because there is no clear way to define performance in Gym w.r.t. a goal, we omit goal conditioning and only report RvS-R. For all tasks, we report scores in the range [0, 100]. For GCSL, the score corresponds to the percentage of episodes in which the agent achieves the goal. In the other environments, we follow Fu et al. [12] and normalize the score according to $1 0 0 \cdot { \frac { { \mathrm { r e t u r n } } - { \mathrm { r a n d o m } } } { \mathrm { e x p e r t } - { \mathrm { r a n d o m } } } }$ (Images from [12, 18].)
79
+
80
+ # 5 ARCHITECTURE, CAPACITY, AND REGULARIZATION
81
+
82
+ We instantiate the RvS framework in Section 3 using a simple feedforward, fully-connected neural network. We condition on either the reward-to-go [26, 38] or a goal state [18, 19, 29] by merely concatenating with the input state (see Figure 2). Our aim is to identify the essential components of such methods; we eschew more complex architectures such as Transformer sequence models [5]. On the tasks we consider, we show that our simple implementation achieves performance competitive with prior work that uses these more complex components. However, seemingly minor choices in the architecture do matter. These architectural choices include tuning capacity and regularization, suggesting that overfitting and underfitting are major challenges for RvS. Additionally, the choice of what to condition on (goals or rewards) also has important and domain-specific repercussions.
83
+
84
+ Capacity and regularization. In Figure 3, we compare different architecture sizes and regularization settings on a single task from each task suite. The best-performing architectures are generally larger than the architectures used in standard online RL [28] and imitation learning [11, 22]. This conclusion is intuitive, since RvS policies must represent both the optimal policy and policies for other conditioning values (e.g., other goals or suboptimal rewards). This result may help explain the contradictory conclusions from prior work regarding the importance of more complex design decisions [5, 26]. The results in Figure 3 also highlight the importance of regularization: while dropout sometimes has no effect (pusher), it improves performance in some tasks (kitchen-complete) and worsens performance in other tasks (hopper-medium-expert and antmaze-medium-play).
85
+
86
+ What can we say about these results on network capacity and regularization? The hopper-medium-expert dataset is large, and it contains only two modes: one from a mediumquality policy, and one from an expert policy. So, it is not surprising that this data doesn’t need regularization. In contrast, kitchen-complete is a small dataset of human demonstrations solving many different subtasks. Prior work has found that human demonstrations are harder to fit than artificial demonstrations [30], and this may explain why kitchen-complete generally benefits from dropout. In antmaze-medium-play, relatively few trajectories are successful, so we are surprised to see that the best-performing hyperparameter setting does not use regularization. In pusher, regularization neither helps nor hurts, underscoring that the (lack of) impact of regularization depends on the task at hand. Overall, we speculate that regularization balances a tension between two competing demands on the policy. First, even if the behavior policy is simple, the conditional action distribution may be complex. Second, the policy must be sufficiently well regularized to generalize well to new goals or conditioning variables.
87
+
88
+ Output distributions. The form of the policy’s output distribution also influences the policy’s capacity. While unimodal Gaussians are a common choice with continuous action spaces [14, 26, 27], a categorical distribution over a discretized action space allows the policy to represent more complex, multi-modal distributions [18, 29]. To study the importance of the policy output distribution, we use the low-dimensional GCSL environments, where we can discretize the full action space. Figure 4 (left) shows that across the GCSL suite, categorical distributions either match or outperform Gaussian distributions. Similar to the results from the previous section, these results highlight how increasing the policy’s model capacity can improve performance. Again, our finding stands in contrast to standard RL methods, which work well with unimodal Gaussians [20, 36] We conjecture that upweighting better data, as done by previous methods [26], may make it easier for low-capacity policies to fit the data. While both upweighting data and increasing model capacity allow the policy to better fit the data, increasing model capacity may be a simpler approach.
89
+
90
+ ![](images/d2a97e74b62ef13984b6d65babf9816d2656e7e434cddca84f0eaff3fd1e93ae.jpg)
91
+ Figure 3: Capacity and regularization: We vary capacity (via network width) and regularization (via dropout) on one environment from each task suite. Larger networks perform better on hopper-medium-expert and kitchen-complete, suggesting the importance of high-capacity policy networks. However, dropout also usually boosts performance in kitchen-complete, suggesting that a combination of high-capacity policies with effective regularization is important for achieving good results.
92
+
93
+ ![](images/59a08a26886fc40edc72359a195fdfc130ad46762be8c92de6e0770b9c56fd83.jpg)
94
+ Figure 4: (Left) In the GCSL suite, a categorical distribution in discretized action space generally outperforms a unimodal Gaussian distribution in continuous action space. This fits the broad pattern we observe that higher-capacity RvS models perform better. (Right) In D4RL Kitchen, validation loss is only loosely correlated with final performance.
95
+
96
+ Tuning with validation loss. Hyperparameter optimization is especially important in the offline RL setting, as evaluating different hyperparameter configurations requires interacting with the environment [33]. Since RvS methods reduce the RL problem to a supervised learning problem, we hypothesize that the validation loss of this supervised learning problem might be an effective metric for tuning important hyperparameters, such as policy capacity and regularization. To test this, we train models on $80 \%$ of each Franka Kitchen dataset with two different hyperparameter settings: a regularized setting with dropout $p = 0 . 1$ and small batch size 256; and an unregularized setting without dropout and a large batch size of 16, 384. We show results in Figure 4 (right). For all three datasets, validation set error does correlate with performance, but the strength of this correlation varies significantly. In general, the validation loss does not provide a reliable approach for hyperparameter tuning. Fully automated tuning of hyperparameters remains an open question [13, 33].
97
+
98
+ A recipe for practitioners. We suggest the following process for online hyperparameter tuning: incrementally increase network width until performance saturates, and then try adding a bit of dropout regularization (e.g., dropout $p = 0 . 1$ ). If validation loss indicates that under/overfitting is an issue, one can also try increasing/decreasing the batch size, respectively.
99
+
100
+ Table 2 in the Appendix summarizes the hyperparameters that we found to work best for each task.
101
+
102
+ # 6 COMPARING RVS WITH PRIOR OFFLINE RL METHODS
103
+
104
+ Having identified key design decisions for implementing RvS learning, we now compare RvS to prior offline RL methods. We evaluate both goal-conditioned behavioral cloning (RvS-G) and reward-conditioned behavioral cloning (RvS-R) using the domains in Section 4. We then discuss what these results imply about the performance, design parameters, and limitations of RvS methods.
105
+
106
+ Baselines and prior methods. On the D4RL benchmarks, we compare RvS learning to $( i )$ valuebased methods and $( i i )$ prior supervised learning methods and behavioral cloning baselines. For $( i )$ , we include CQL [27] as well as the more recent $\mathrm { T D } 3 { + } \mathrm { B C }$ [14] and Onestep RL [4] methods. $\mathrm { T D } 3 { + } \mathrm { B C }$ and Onestep RL both involve elements of behavior cloning. We use CQL-p to denote the CQL numbers published in [12] and CQL-r to denote our best attempt to replicate these results using open-source code and hyperparameters from the CQL authors. For $( i i )$ , we include behavioral cloning (BC), which does not perform any conditioning; Filtered (“Filt.”) BC, a baseline appearing in [5] which performs BC after filtering for the trajectories with highest cumulative reward; and Decision Transformer (DT) [5], which conditions on rewards and uses a large Transformer sequence model. Both BC and Filtered BC are our own optimized implementations [25], tuned thoroughly in a similar manner as RvS-R and RvS-G. In Kitchen and Gym locomotion, Filtered BC clones the top $10 \%$ of trajectories based on cumulative reward. In AntMaze, Filtered BC clones all successful trajectories (those with a reward of 1) and ignores the failing trajectories (those with a reward of 0). On the GCSL benchmarks, we compare to GCSL using numbers reported by the authors [18]. This gives the GCSL baseline the advantage of online data, whereas RvS uses only offline data. We do not run RvS-G on the Gym locomotion tasks, which are typically expressed as reward-maximization tasks, not goal-reaching tasks. For additional details about the baselines, see Appendix A.
107
+
108
+ Table 1 : Overall performance. RvS conditioned on goal states (RvS -G) is state-of-the-art in the AntMaze, Kitchen, and GCSL suites . RvS conditioned on rewards (RvS -R) performs worse at these tasks, highlighting the importance of the conditioning variable. In Gym, RvS -R matches the performance of Decision Transformer while only using an MLP. $\ast _ { \mathrm { F o r } }$ the sake of completeness, we include CQL-p, $\mathrm { T D } 3 { + } \mathrm { B C }$ , and Onestep numbers that use AntMaze version v0. See Appendix A for more discussion of this and other experiment details .
109
+
110
+ <table><tr><td>Suite</td><td>Environment</td><td>BC</td><td>Filt. BC</td><td>TD3+BC</td><td>Onestep</td><td>CQL-r</td><td>CQL-p</td><td>DT</td><td>RvS-R</td><td>RvS-G</td><td>GCSL</td></tr><tr><td rowspan="9">D4RL AntMaze</td><td>umaze-v2</td><td>54.6 45.6</td><td>60.0 46.5</td><td>78.6 71.4</td><td>64.3 60.7</td><td>44.8 23.4</td><td>74.0</td><td>65.6</td><td>64.4 70.1</td><td>65.4 60.9</td><td></td></tr><tr><td>umaze-diverse-v2</td><td></td><td></td><td></td><td></td><td></td><td>84.0</td><td>51.2</td><td></td><td></td><td></td></tr><tr><td>medium-play-v2</td><td>0.0</td><td>42.1</td><td>10.6</td><td>0.3</td><td>0.0</td><td>61.2</td><td>1.0</td><td>4.5</td><td>58.1</td><td></td></tr><tr><td>medium-diverse-v2</td><td>0.0</td><td>37.2</td><td>3.0</td><td>0.0</td><td>0.0</td><td>53.7</td><td>0.6</td><td>7.7</td><td>67.3</td><td></td></tr><tr><td>large-play-v2</td><td>0.0</td><td>28.0</td><td>0.2</td><td>0.0</td><td>0.0</td><td>15.8</td><td>0.0</td><td>3.5</td><td>32.4</td><td></td></tr><tr><td>large-diverse-v2</td><td>0.0</td><td>34.3</td><td>0.0</td><td>0.0</td><td>0.0</td><td>14.9</td><td>0.2</td><td>3.7</td><td>36.9</td><td></td></tr><tr><td>antmze-v2 average</td><td>16.7</td><td>41.4</td><td>27.3*</td><td>20.9*</td><td>11.4</td><td>50.6*</td><td>19.8</td><td>25.6</td><td>53.5</td><td></td></tr><tr><td>halfcheetah-random-v2 hopper-random-v2</td><td>2.3</td><td>2.0</td><td>11.0</td><td>6.9</td><td>18.6</td><td></td><td>2.2</td><td>3.9 7.7</td><td></td><td></td></tr><tr><td></td><td>4.8</td><td>4.1</td><td>8.5</td><td>7.8</td><td>9.3</td><td></td><td>7.5 2.0</td><td></td><td></td><td></td></tr><tr><td rowspan="10"></td><td>walker2d-random-v2</td><td>1.7</td><td>1.7</td><td>1.6</td><td>6.1</td><td>2.5</td><td></td><td></td><td>-0.2</td><td></td></tr><tr><td>random-v2 average</td><td>2.9</td><td>2.6</td><td></td><td>6.9</td><td></td><td>3.9</td><td>3.8</td><td></td><td></td></tr><tr><td>halfcheetah-medium-replay-v2</td><td>36.6</td><td>40.6</td><td>7.0 44.6</td><td>42.4</td><td>10.1 47.3</td><td>36.6</td><td></td><td>38.0</td><td></td></tr><tr><td>hopper-medium-replay-v2</td><td>18.1</td><td>75.9</td><td>60.9</td><td>71.0</td><td>97.8</td><td>82.7</td><td></td><td>73.5</td><td></td></tr><tr><td>walker2d-medium-replay-v2</td><td>26.0</td><td>62.5</td><td>81.8</td><td>71.6</td><td>86.1</td><td>66.6</td><td></td><td>60.6</td><td></td></tr><tr><td>medium-replay-v2 average</td><td>26.9</td><td>59.7</td><td>62.4</td><td>61.7</td><td>77.1</td><td>62.0</td><td></td><td></td><td></td></tr><tr><td>halfcheetah-medium-v2</td><td>42.6</td><td>42.5</td><td></td><td></td><td></td><td>42.6</td><td>57.4 41.6</td><td></td><td></td></tr><tr><td>hopper-medium-v2</td><td>52.9</td><td>56.9</td><td>48.3 59.3</td><td>55.6 83.3</td><td>49.1 64.6</td><td>67.6</td><td>60.2</td><td></td><td></td></tr><tr><td>walker2d-medium-v2</td><td>75.3</td><td>75.0</td><td>83.7</td><td>85.6</td><td>82.9</td><td>74.0</td><td></td><td>71.7</td><td></td></tr><tr><td>medium-v2 average</td><td>56.9</td><td>58.1</td><td></td><td>74.8</td><td>65.5</td><td>61.4</td><td></td><td>57.8</td><td></td></tr><tr><td>halfcheetah-medium-expert-v2</td><td>55.2</td><td>92.9</td><td>63.8 90.7</td><td>93.5</td><td>85.8</td><td></td><td>86.8</td><td>92.2</td><td></td><td></td></tr><tr><td>hopper-medium-expert-v2</td><td>52.5</td><td>110.9</td><td>98.0</td><td>102.1</td><td>102.0</td><td></td><td>107.6</td><td>101.7</td><td></td><td></td></tr><tr><td>walker2d-medium-expert-v2</td><td>107.5</td><td>109.0</td><td>110.1</td><td>110.9</td><td>109.5</td><td></td><td>108.1</td><td>106.0</td><td></td><td></td></tr><tr><td>medium-expert-v2average</td><td>71.7</td><td>104.3</td><td>99.6</td><td>102.2</td><td>99.1</td><td></td><td>100.8</td><td>100.0</td><td></td><td></td></tr><tr><td>gym-v2 average</td><td>39.6</td><td>56.2</td><td>58.2</td><td>61.4</td><td>63.0</td><td></td><td>57.0</td><td>54.7</td><td></td><td></td></tr><tr><td rowspan="5">D4RL Kitchen</td><td>kitchen-complete-v0</td><td>65.0</td><td>4.0</td><td></td><td></td><td>11.8</td><td>43.8</td><td></td><td>1.5</td><td></td><td></td></tr><tr><td>kitchen-mixed-v0</td><td>51.5</td><td>40.0</td><td></td><td></td><td>24.2</td><td>51.0</td><td></td><td>1.1</td><td>50.2 60.3</td><td></td></tr><tr><td>kitchen-partial-v0</td><td>38.0</td><td>66.0</td><td></td><td></td><td>20.8</td><td>49.8</td><td></td><td>0.5</td><td>51.4</td><td></td></tr><tr><td>kitchen-vO average</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>54.0</td><td></td></tr><tr><td></td><td>51.5</td><td>36.7</td><td></td><td></td><td>18.9</td><td>48.2</td><td></td><td>1.0</td><td>14.8</td><td>28.0</td></tr><tr><td rowspan="6">GCSL</td><td>claw door</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>28.0</td></tr><tr><td>four rooms</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>95.8 63.0</td><td>81.0</td></tr><tr><td>lunar</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>54.7</td><td>70.0</td></tr><tr><td>pusher</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>81.8</td><td>83.0</td></tr><tr><td>gcsl average</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>62.0</td><td>58.0</td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr></table>
111
+
112
+ Overall performance and comparison to prior methods. Table 1 shows the results of this comparison, leading to several conclusions about how our RvS implementations compare to prior valuebased and supervised methods. In all suites, either RvS-G or RvS-R attains results that are comparable to the best prior method. The finding that conditional imitation with standard fully connected networks attains competitive results stands in contrast to prior work, which emphasizes advantage weighting and Transformer sequence models [5, 26]. As we discussed in Section 5, good performance requires a careful combination of high capacity and regularization, and it may simply be that this seemingly contradictory combination of components was not adequately explored in prior work.
113
+
114
+ Subtrajectory stitching. The mixed dataset in Kitchen and all of the AntMaze tasks consist of suboptimal trajectories. Attaining expert performance requires recombining parts of these trajectories. Such stitching is usually viewed as a key benefit of dynamic programming methods, so it is surprising that RvS-G performs as well as prior methods based on dynamic programming $\mathrm { T D } 3 { + } \mathrm { B C }$ and CQL). In these same tasks, RvS-G outperforms RvS-R. We speculate that the spatial information encoded by goal information helps RvS-G generalize. BC works well in the Kitchen environment but poorly in the AntMaze tasks, perhaps becaue the Kitchen task contains experience that is easier to imitate. As a direction for future work, we propose studying if conditioning on goals can help provide compositionality in space just as the Bellman backup provides compositionality in time.
115
+
116
+ Reaching arbitrary goals. An important capability of RvS-G, compared with more standard offline RL methods, is that it learns a policy that can reach many goals. To test how well RvS-G can learn to reach arbitrary goals from random offline data, we compare to GCSL, an RvS learning method that performs iterative online data collection [18]. We use the same tasks used by GCSL. Each of the tasks in the GCSL suite requires that the agent reach a goal drawn uniformly at random from the set of possible goals. The results shown in Figure 5 indicate that RvS-G can successfully reach many different goals entirely from randomly collected offline data. Although it may still be that iterative online collection, as proposed in prior work [18, 38], may be helpful in some domains, in this case simple offline training appears to suffice.
117
+
118
+ ![](images/92e145f5739d9f48fa3ccc6ae0f8c1e024616f7c342d0b24403f094ece2fecba.jpg)
119
+ Figure 5: GCSL results.
120
+
121
+ Random datasets. While on average RvS-R is competitive with prior methods on the Gym Locomotion tasks, TD learning performs better on the random datasets; indeed, CQL performs especially well on halfcheetah-random (Table 1). This suggests that RvS methods may more generally perform worse on random datasets in comparison to TD learning methods.
122
+
123
+ Analysis of reward conditioning. Next, we analyze what RvS-R actually learns and how it uses the conditioning variable. First, we use the walker2d-medium-expert task to analyze the behavior of RvS-R for target rewards. The walker2d-medium-expert dataset contains two modes (“medium” and “expert”, as shown in Figure 6). Conditioning the network on a range of reward targets (Xaxis), Figure 6 shows that the policy’s achieved return (Y-axis) corresponds only to the two modes in the dataset. The policy cannot interpolate between the two modes. In effect, it appears that RvS is mimicking a subset of the demonstrations, but doing so without explicit filtering (as is done in Filtered BC).
124
+
125
+ ![](images/547117326dbff25394491b1a7cab47e199e5620938a2c959a5504e5a9a7ea669.jpg)
126
+ Figure 6: A failure to interpolate.
127
+
128
+ This analysis highlights the importance of the conditioning variable. It is not obvious a priori that a reward target of 100 will lead to a return of 70, whereas a reward target of 110 will lead to a return of 105. Following prior work [5], we tune the reward target for every task (see Table 2). Choosing this hyperparameter in a truly offline setting is an important problem for future work.
129
+
130
+ # 7 DISCUSSION AND FUTURE WORK
131
+
132
+ We presented an empirical study of offline RL via supervised learning (RvS) methods, which solve RL problems via conditional imitation learning. While prior work is divided on which elements of RvS are crucial for good performance, or even how well such methods actually work, our results provide three conclusions. First, if capacity and regularization are chosen correctly, RvS methods with simple fully connected architectures can match or outperform the best prior methods. Second, properly choosing the conditioning variable (e.g., goal or reward) is critical to the performance of RvS methods. Third, RvS methods remain competitive in tasks such as Franka Kitchen and AntMaze, where there is little optimal data. These conclusions suggest multiple directions for future work. Because policy capacity and regularization are critical to good performance, is there a method for automatically tuning these hyperparameters? Validation error is not a reliable metric. Also, the choice of conditioning variable is important: how might we automate this choice? Addressing these questions may increase the performance and applicability of RvS learning methods.
133
+
134
+ # ACKNOWLEDGMENTS
135
+
136
+ This work was supported in part by the DOE CSGF under grant number DE-SC0020347.
137
+
138
+ We thank Michael Janner for discussions about architectures, and we thank Aviral Kumar and Justin Fu for discussions about datasets. We thank Sam Toyer, Micah Carroll, and anonymous reviewers for giving feedback on initial drafts of this work.
139
+
140
+ # REFERENCES
141
+
142
+ [1] Rishabh Agarwal, Dale Schuurmans, and Mohammad Norouzi. An optimistic perspective on offline reinforcement learning. In International Conference on Machine Learning, 2020.
143
+ [2] Michael Ahn, Henry Zhu, Kristian Hartikainen, Hugo Ponte, Abhishek Gupta, Sergey Levine, and Vikash Kumar. ROBEL: RObotics BEnchmarks for Learning with low-cost robots. In Conference on Robot Learning (CoRL), 2019.
144
+ [3] Arthur Argenson and Gabriel Dulac-Arnold. Model-based offline planning. In International Conference on Learning Representations, 2021. URL https://openreview.net/forum?id= OMNB1G5xzd4.
145
+ [4] David Brandfonbrener, William F Whitney, Rajesh Ranganath, and Joan Bruna. Offline RL without offpolicy evaluation. In Thirty-Fifth Conference on Neural Information Processing Systems, 2021. URL https://openreview.net/forum?id $=$ LU687itn08w.
146
+ [5] Lili Chen, Kevin Lu, Aravind Rajeswaran, Kimin Lee, Aditya Grover, Michael Laskin, Pieter Abbeel, Aravind Srinivas, and Igor Mordatch. Decision transformer: Reinforcement learning via sequence modeling. In Thirty-Fifth Conference on Neural Information Processing Systems, 2021. URL https: //openreview.net/forum?id $=$ a7APmM4B9d.
147
+ [6] Felipe Codevilla, Matthias Muller, Antonio L ¨ opez, Vladlen Koltun, and Alexey Dosovitskiy. End-to- ´ end driving via conditional imitation learning. In 2018 IEEE International Conference on Robotics and Automation (ICRA), pp. 4693–4700. IEEE, 2018.
148
+ [7] Stefan Depeweg, Jose Miguel Hern ´ andez-Lobato, Finale Doshi-Velez, and Steffen Udluft. Learning and ´ policy search in stochastic dynamical systems with bayesian neural networks. In International Conference on Learning Representations (ICLR 2017), 2017.
149
+ [8] Yiming Ding, Carlos Florensa, Pieter Abbeel, and Mariano Phielipp. Goal-conditioned imitation learning. In Advances in Neural Information Processing Systems, pp. 15324–15335, 2019.
150
+ [9] Benjamin Eysenbach, Ruslan Salakhutdinov, and Sergey Levine. Search on the replay buffer: Bridging planning and reinforcement learning. In Advances in Neural Information Processing Systems, pp. 15246– 15257, 2019.
151
+ [10] Benjamin Eysenbach, Xinyang Geng, Sergey Levine, and Ruslan Salakhutdinov. Rewriting history with inverse RL: hindsight inference for policy improvement. In Advances in Neural Information Processing Systems, 2020.
152
+ [11] Justin Fu, Katie Luo, and Sergey Levine. Learning robust rewards with adverserial inverse reinforcement learning. In International Conference on Learning Representations, 2018. URL https: //openreview.net/forum?id $=$ rkHywl-A-.
153
+ [12] Justin Fu, Aviral Kumar, Ofir Nachum, George Tucker, and Sergey Levine. D4RL: Datasets for deep data-driven reinforcement learning. arXiv preprint arXiv:2004.07219, 2020.
154
+ [13] Justin Fu, Mohammad Norouzi, Ofir Nachum, George Tucker, ziyu wang, Alexander Novikov, Mengjiao Yang, Michael R Zhang, Yutian Chen, Aviral Kumar, Cosmin Paduraru, Sergey Levine, and Thomas Paine. Benchmarks for deep off-policy evaluation. In International Conference on Learning Representations, 2021. URL https://openreview.net/forum?id $=$ kWSeGEeHvF8.
155
+ [14] Scott Fujimoto and Shixiang Gu. A minimalist approach to offline reinforcement learning. In Thirty-Fifth Conference on Neural Information Processing Systems, 2021. URL https://openreview.net/ forum?id=Q32U7dzWXpc.
156
+ [15] 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.
157
+ [16] Behrooz Ghorbani, Orhan Firat, Markus Freitag, Ankur Bapna, Maxim Krikun, Xavier Garcia, Ciprian Chelba, and Colin Cherry. Scaling laws for neural machine translation. arXiv preprint arXiv:2109.07740, 2021.
158
+ [17] Dibya Ghosh, Abhishek Gupta, and Sergey Levine. Learning actionable representations with goal conditioned policies. In International Conference on Learning Representations, 2018.
159
+ [18] Dibya Ghosh, Abhishek Gupta, Ashwin Reddy, Justin Fu, Coline Manon Devin, Benjamin Eysenbach, and Sergey Levine. Learning to reach goals via iterated supervised learning. In International Conference on Learning Representations, 2021. URL https://openreview.net/forum?id $=$ rALA0Xo6yNJ.
160
+ [19] Abhishek Gupta, Vikash Kumar, Corey Lynch, Sergey Levine, and Karol Hausman. Relay policy learning: Solving long-horizon tasks via imitation and reinforcement learning. In Conference on Robot Learning, pp. 1025–1037, 2020.
161
+ [20] 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.
162
+ [21] Jeffrey Hawke, Richard Shen, Corina Gurau, Siddharth Sharma, Daniele Reda, Nikolay Nikolov, Przemysław Mazur, Sean Micklethwaite, Nicolas Griffiths, Amar Shah, et al. Urban driving with conditional imitation learning. In 2020 IEEE International Conference on Robotics and Automation (ICRA), pp. 251–257. IEEE, 2020.
163
+ [22] Jonathan Ho and Stefano Ermon. Generative adversarial imitation learning. Advances in neural information processing systems, 29:4565–4573, 2016.
164
+ [23] Michael Janner, Qiyang Li, and Sergey Levine. Offline reinforcement learning as one big sequence modeling problem. In Advances in Neural Information Processing Systems, 2021.
165
+ [24] Rahul Kidambi, Aravind Rajeswaran, Praneeth Netrapalli, and Thorsten Joachims. MOReL: ModelBased Offline Reinforcement Learning. In H. Larochelle, M. Ranzato, R. Hadsell, M. F. Balcan, and H. Lin (eds.), Advances in Neural Information Processing Systems, volume 33, pp. 21810–21823. Curran Associates, Inc., 2020. URL https://proceedings.neurips.cc/paper/2020/file/ f7efa4f864ae9b88d43527f4b14f750f-Paper.pdf.
166
+ [25] Ilya Kostrikov. JAXRL: Implementations of Reinforcement Learning algorithms in JAX, 10 2021. URL https://github.com/ikostrikov/jaxrl.
167
+ [26] Aviral Kumar, Xue Bin Peng, and Sergey Levine. Reward-conditioned policies. arXiv preprint arXiv:1912.13465, 2019.
168
+ [27] 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 (eds.), Advances in Neural Information Processing Systems, 2020.
169
+ [28] 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. In International Conference on Learning Representations, 2016.
170
+ [29] Corey Lynch, Mohi Khansari, Ted Xiao, Vikash Kumar, Jonathan Tompson, Sergey Levine, and Pierre Sermanet. Learning latent plans from play. In Conference on Robot Learning, pp. 1113–1132. PMLR, 2020.
171
+ [30] Ajay Mandlekar, Danfei Xu, Josiah Wong, Soroush Nasiriany, Chen Wang, Rohun Kulkarni, Li FeiFei, 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 $\underline { { \underline { { \mathbf { \Pi } } } } } =$ JrsfBJtDFdI.
172
+ [31] Ashvin V Nair, Vitchyr Pong, Murtaza Dalal, Shikhar Bahl, Steven Lin, and Sergey Levine. Visual reinforcement learning with imagined goals. Advances in Neural Information Processing Systems, 31: 9191–9200, 2018.
173
+ [32] Gerhard Neumann, Jan Peters, et al. Fitted Q-iteration by advantage weighted regression. In Advances in Neural Information Processing Systems 21-Proceedings of the 2008 Conference, pp. 1177–1184, 2009.
174
+ [33] Tom Le Paine, Cosmin Paduraru, Andrea Michi, Caglar Gulcehre, Konrad Zolna, Alexander Novikov, Ziyu Wang, and Nando de Freitas. Hyperparameter selection for offline reinforcement learning. arXiv preprint arXiv:2007.09055, 2020.
175
+ [34] 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.
176
+ [35] Juergen Schmidhuber. Reinforcement learning upside down: Don’t predict rewards–just map them to actions. arXiv preprint arXiv:1912.02875, 2019.
177
+ [36] John Schulman, Filip Wolski, Prafulla Dhariwal, Alec Radford, and Oleg Klimov. Proximal policy optimization algorithms. arXiv preprint arXiv:1707.06347, 2017.
178
+ [37] Jian Shen, Mingcheng Chen, Zhicheng Zhang, Zhengyu Yang, Weinan Zhang, and Yong Yu. Model-based offline policy optimization with distribution correcting regularization. In Joint European Conference on Machine Learning and Knowledge Discovery in Databases, pp. 174–189. Springer, 2021.
179
+ [38] Rupesh Kumar Srivastava, Pranav Shyam, Filipe Mutz, Wojciech Jaskowski, and J ´ urgen Schmidhuber. ¨ Training agents using upside-down reinforcement learning. arXiv preprint arXiv:1912.02877, 2019.
180
+ [39] Phillip Swazinna, Steffen Udluft, and Thomas Runkler. Overcoming model bias for robust offline deep reinforcement learning. Engineering Applications of Artificial Intelligence, 104:104366, 2021.
181
+ [40] Michael Tschannen, Josip Djolonga, Paul K. Rubenstein, Sylvain Gelly, and Mario Lucic. On mutual information maximization for representation learning. In International Conference on Learning Representations, 2020. URL https://openreview.net/forum?id=rkxoh24FPH.
182
+ [41] Yue Wu, Shuangfei Zhai, Nitish Srivastava, Joshua M Susskind, Jian Zhang, Ruslan Salakhutdinov, and Hanlin Goh. Uncertainty weighted actor-critic for offline reinforcement learning. 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. 11319–11328. PMLR, 18–24 Jul 2021. URL https: //proceedings.mlr.press/v139/wu21i.html.
183
+ [42] Tianhe Yu, Garrett Thomas, Lantao Yu, Stefano Ermon, James Y Zou, Sergey Levine, Chelsea Finn, and Tengyu Ma. MOPO: Model-based Offline Policy Optimization. Advances in Neural Information Processing Systems, 33:14129–14142, 2020.
184
+
185
+ Table 2: Hyperparameters. Architecture and design parameters that we found to work best in each domain. We define an epoch length to include all start-goal pairs in GCSL, i.e., to be $\mathinner { | { \mathcal { D } } | } \mathinner { | { H } \rangle }$ . I n D4RL, we set all epoch lengths at 2000 ${ \binom { 5 0 } { 2 } } = 2 4 5 0 0 0 0$ .
186
+
187
+ <table><tr><td>Hyperparameter</td><td>Value</td><td>Environment</td></tr><tr><td>Hidden layers</td><td>2</td><td>All</td></tr><tr><td>Layer width</td><td>1024</td><td>All</td></tr><tr><td>Nonlinearity</td><td>ReLU</td><td>All</td></tr><tr><td>Learning rate</td><td>1e-3</td><td>All</td></tr><tr><td>Epochs</td><td>10</td><td>GCSL</td></tr><tr><td></td><td>50</td><td>Kitchen</td></tr><tr><td></td><td>2000</td><td>Gym</td></tr><tr><td>Gradient steps</td><td>20000</td><td>AntMaze</td></tr><tr><td>Batch size</td><td>256</td><td>GCSL,Kitchen</td></tr><tr><td></td><td>16384</td><td>Gym,AntMaze</td></tr><tr><td>Dropout</td><td>0.1</td><td>GCSL,Kitchen</td></tr><tr><td></td><td>0</td><td>Gym,AntMaze</td></tr><tr><td>Goal state</td><td>Given</td><td>GCSL</td></tr><tr><td></td><td>All subtasks completed</td><td>Kitchen</td></tr><tr><td>Reward target</td><td>(x,y) location</td><td>AntMaze</td></tr><tr><td></td><td>110</td><td>Gym medium-expert,AntMaze,Kitchen</td></tr><tr><td></td><td>90</td><td>Gym {hopper,walker2d}-medium-replay,walker2d-medium</td></tr><tr><td></td><td>60</td><td>Gym hopper-medium</td></tr><tr><td>Policy output</td><td>40</td><td>Gym random,halfcheetah-{medium,medium-replay}</td></tr><tr><td></td><td>Discrete categorical</td><td>GCSL</td></tr><tr><td></td><td>Unimodal Gaussian</td><td>Kitchen, Gym,AntMaze</td></tr></table>
188
+
189
+ # A EXPERIMENT DETAILS
190
+
191
+ In this section, we provide more details about our experiments in each environment suite. For every task, we use 5 random training seeds and 200 evaluation rollouts for RvS.
192
+
193
+ GCSL Following the GCSL protocol [18], we collect offline data for RvS by performing random rollouts in each environment. As in GCSL, we set the environment time limit (i.e., max episode duration) to 50 actions, and the rollout policy uses a discretized action space. We collect 50,000 timesteps of experience in FourRooms, 100,000 timesteps of experience in Door and Lander, and 500,000 timesteps of experience in Pusher and Claw. We take our GCSL baseline numbers from those reported in the GCSL paper at the corresponding number of timesteps for each environment [18].
194
+
195
+ Gym Locomotion We use the v2 versions of the datasets for all algorithms. Because the v2 datasets fix issues with the v0 datasets, we omit the published CQL-p numbers, which use v0 and are no longer comparable. We instead report our replication of CQL, denoted CQL-r, using v2. We report the DT [27], $\mathrm { T D } 3 { + } \mathrm { B C }$ [14], and Onestep [4] numbers from the corresponding papers. We use the reverse KL regularization variant of Onestep because this variant attains the best performance. Because DT did not run experiments with the random datasets, we run them ourselves using the default hyperparameters in the open-source codebase released by the DT authors. We omit numbers for RvS-G because there is no clear way to define the Gym tasks in terms of goals.
196
+
197
+ Franka Kitchen We use the v0 versions of the datasets and omit $\mathrm { T D } 3 { + } \mathrm { B C }$ , Onestep, and DT numbers, which are not provided by the authors. We include the previously published CQL-p numbers from D4RL [12] as well as CQL-r, our own replication of CQL, and BC and Filtered BC, our own baselines.
198
+
199
+ AntMaze We use the v2 versions of the datasets for RvS, CQL-r, BC, Filtered BC, and DT. Because the DT authors do not test in AntMaze, we ran these experiments ourselves using the default hyperparameters in the open-source codebase released by the DT authors. We include previously published numbers for CQL-p [12] and $\mathrm { T D } 3 { + } \mathrm { B C }$ [14], as well as Onestep numbers we received via email correspondence with the Onestep authors. These numbers for CQL-p, $\mathrm { T D } 3 { + } \mathrm { B C }$ , and Onestep use the v0 versions of the datasets, which are the same as the v2 versions except that the v0 timeout flags indicating the ends of episodes contain errors. Because our initial experiments suggest that TD learning methods are fairly robust to errors in the timeout flags, we include these numbers for the sake of completeness.
200
+
201
+ ![](images/9d3f3dc3aa2020cfa968886a49dce459b8f6c37b972c085058148b0b1fd38942.jpg)
202
+ Figure 7: Validation mean-squared-error and evaluation return versus training gradient steps in Frank Kitchen. Each line includes 5 random seeds across each of the three datasets: complete, partial, and mixed. Surprisingly, we find that although each hyperparameter setting has nearly identical validation loss, the evaluation return varies by as much as $1 . 4 \mathbf { x }$ . This indicates that dropout and network capacity are having important effects on performance beyond validation loss.
203
+
204
+ Codebases Here are links to all of the codebases we use in our experiments:
205
+
206
+ 1. RvS: https://github.com/scottemmons/rvs
207
+ 2. CQL-r: https://github.com/scottemmons/youngs-cql
208
+ 3. DT: https://github.com/scottemmons/decision-transformer
209
+ 4. BC and Filtered BC: https://github.com/ikostrikov/jaxrl
210
+
211
+ # B THE IMPACT OF MODEL CAPACITY AND REGULARIZATION
212
+
213
+ As we find in Section 5 that model capacity and regularization are important for performance in seemingly contradictory ways, we hypothesize that this can be explained by validation loss. So, for 5 random seeds in each of the 3 Franka Kitchen datasets (complete, partial, and mixed), we measure validation loss and return throughout training for three different settings of policy hyperparameters: network width 1024 with dropout $\mathrm { p } = 0 . 1$ , network width 1024 with dropout $\boldsymbol { \mathrm { p } } = \boldsymbol { 0 }$ (no dropout), and network width 256 with dropout $\boldsymbol { \mathrm { p } } = \boldsymbol { 0 }$ (no dropout). We expect that a larger network width leads to better validation loss, explaining its better return. We expect adding regularization also has this pattern of better validation loss and therefore better return.
214
+
215
+ In Figure 7, we plot the results: validation loss is nearly identical across all of the hyperparameter settings, but return can vary by as much as $1 . 4 \mathrm { x }$ between different hyperparameter settings. We also observe that evaluation return steadily increases even after validation loss has mostly leveled off. This is surprising and refutes our hypothesis; furthermore, it provides the insight that model capacity and dropout are having effects beyond just the validation loss. A similar phenomenon occurs in Neural Machine Translation, where cross entropy loss can decline while the quality of the translation (measured by BLEU score) remains constant [16], and in contrastive representation learning, where lower capacity models have worse losses on the test set but still learn better representations for downstream tasks [40]. It is an important open problem for the field to understand why architecture decisions can impact performance beyond validation loss.
216
+
217
+ ![](images/ae19be2db8205f8fbf8a005e81802fbe2ac81887b2837755a0a1521ed589cc23.jpg)
218
+ Figure 8: (a) Different strategies for choosing goals in D4RL Gym. (b) Commanding the policy to complete different subtasks in kitchen-complete.
219
+
220
+ # C COMPARISON OF CONDITIONING STRATEGIES
221
+
222
+ To further study how different goal and reward conditioning strategies compare, in Figure 8a, we show the performance of four strategies: Reward Scalar, Reward Goal, Length Goal, and Optimized Goal. In Reward Scalar, we condition RvS-R on a return that is various fractions of expert performance. In Reward Goal, we condition RvS-G on states from randomly selected timesteps near the end of the highest-reward demonstration trajectories. In Length Goal, we condition RvS-G on states from randomly selected timesteps near the end of the longest demonstration trajectories. In Optimized Goal, we do a random search over 200 Length Goals and condition RvSG on the highest performing one. (Note that Optimized Goal requires access to the environment, so it is not strictly offline RL; we are including it here as an oracle experiment.) We see that across all the goal selection strategies we consider, the performance of RvS-G cannot match the performance of RvS-R, since the Gym tasks are not inherently goal-conditioned.
223
+
224
+ In Figure 8b, we compare the performance of RvS-G in kitchen-complete when commanded to reach different goal states. The kitchen-complete task requires the agent to open a microwave, move a kettle, flip a light switch, and slide open a cabinet. For “all,” we command the policy to reach a state where all the subtasks are achieved. For “random,” we randomly select one of the tasks and command the policy to reach a state where that task is complete. For “microwave,” “kettle,” “light switch,” and “slide cabinet,” we command the agent to reach a state where that one subtask is achieved. For “dynamic,” rather than leaving the goal fixed throughout the trajectory, we initially command the agent to complete the first subtask. Then, once the first subtask is complete, we update the command to include the second subtask (and so on for all remaining subtasks). As expected, we see that the oracle dynamic strategy, as well as conditioning on all subtasks completed, perform the best. Surprisingly, commanding the microwave to be opened outperforms commanding the other individual subtasks. We speculate that the microwave subtask might appear most often in the demonstrations.
md/dev/UYneFzXSJWh/UYneFzXSJWh.md ADDED
The diff for this file is too large to render. See raw diff
 
md/dev/VB75Pi89p7/VB75Pi89p7.md ADDED
@@ -0,0 +1,276 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # BEIT V2: MASKED IMAGE MODELING WITH VECTOR-QUANTIZED VISUAL TOKENIZERS
2
+
3
+ Anonymous authors Paper under double-blind review
4
+
5
+ # ABSTRACT
6
+
7
+ Masked image modeling (MIM) has demonstrated impressive results in selfsupervised representation learning by recovering corrupted image patches. However, most existing studies operate on low-level image pixels, which hinders the exploitation of high-level semantics for representation models. In this work, we propose to use a semantic-rich visual tokenizer as the reconstruction target for masked prediction, providing a systematic way to promote MIM from pixel-level to semantic-level. Specifically, we propose vector-quantized knowledge distillation to train the tokenizer, which discretizes a continuous semantic space to compact codes. We then pretrain vision Transformers by predicting the original visual tokens for the masked image patches. Furthermore, we introduce a patch aggregation strategy which associates discrete image patches to enhance global semantic representation. Experiments on image classification and semantic segmentation show that BEIT V2 outperforms all compared MIM methods. On ImageNet-1K (224 size), the base-size BEIT V2 achieves $8 5 . 5 \%$ top-1 accuracy for fine-tuning and $8 0 . 1 \%$ top-1 accuracy for linear probing. The large-size BEIT V2 obtains $8 7 . 3 \%$ top-1 accuracy for ImageNet-1K (224 size) fine-tuning, and $5 6 . 7 \%$ mIoU on ADE20K for semantic segmentation. The code can be found in the supplementary materials.
8
+
9
+ # 1 INTRODUCTION
10
+
11
+ Masked image modeling (MIM), which greatly relieves the annotation-hungry issue of vision Transformers, has demonstrated great potential in learning visual representations (Bao et al., 2022; He et al., 2022). Given an image, the pretraining objective of MIM is to recover the masked patches so that rich context information is captured by the representation model. Taking BEiT (Bao et al., 2022) as an example, each image has two views during pretraining, i.e., image patches, and visual tokens. The original image is first tokenized to discrete tokens. Randomly sampled image patches are then masked before being fed to vision Transformers. The pretraining objective is to recover the original visual tokens based on the corrupted image patches. The pretrained vision encoder can be deployed and finetuned on various downstream tasks by appending lightweight task layers.
12
+
13
+ Existing MIM approaches can be coarsely categorized to three according to the reconstruction targets: low-level image elements (e.g., raw pixels; He et al. 2022; Fang et al. 2022; Liu et al. 2022), handcrafted features (e.g., HOG features; Wei et al. 2021), and visual tokens; Bao et al. 2022; Wang et al. 2022; Dong et al. 2021; El-Nouby et al. 2021; Chen et al. 2022. However, all the reconstruction targets are about, explicitly or implicitly, low-level image elements while underestimating high-level semantics. In comparison, the masked words in language modeling (Devlin et al., 2019) are all about high-level semantics, which motivates us to tap the potential of MIM by exploiting semantic-aware supervision during pretraining.
14
+
15
+ In this work, we propose a self-supervised representation learning approach, termed BEIT V2, with the aim to improve MIM pretraining by constructing a semantic-aware visual tokenizer. Our approach is developed on the BEIT method which is simple yet effective. The novelty lies in introducing the Vector-Quantized Knowledge Distillation (VQ-KD) algorithm to discretize a semantic space. The VQ-KD encoder first converts the input image to discrete tokens according to a learnable codebook. The decoder then learns to reconstruct the semantic features encoded by a teacher model, conditioning on the discrete tokens. After training VQ-KD, its encoder is used as a semantic visual tokenizer for BEIT pretraining, where the discrete codes serve as supervision signals.
16
+
17
+ ![](images/6c7aa3ed835bae886efd50e91041fc62684c089925486c85c6784f9c4d8b7124.jpg)
18
+ Figure 1: Top-1 fine-tuning accuracy on ImageNet (224 size). Left: ViT-B/16. right: ViT-L/16.
19
+
20
+ Considering the discreteness of tokens, we further introduce a patch aggregation strategy which explicitly encourages the [CLS] token to associate all patches (Gao & Callan, 2021). Such a strategy resolves the issue that MIM put patch reconstruction the first place which diminishes learning global image representations. As a result, BEIT V2 improves the capacity of learned image representation, as supported by the linear probing experiments. Moreover, the enhanced representations also boosts the performance of other tasks.
21
+
22
+ We conduct self-supervised learning on ImageNet-1k for both base- and large-size vision Transformers, which are evaluated on downstream tasks, e.g., image classification, linear probing, and semantic segmentation. As shown in Figure 1, BEIT V2 outperforms previous self-supervised learning algorithms by a large margin on ImageNet fine-tuning, e.g., improving over BEIT (Bao et al., 2022) by about two points for both ViT-B/16 and ViT-L/16. BEIT V2 outperforms all compared MIM methods on ImageNet linear probing while achieving large performance gains on ADE20k for semantic segmentation.
23
+
24
+ The contributions of this work are summarized as follows:
25
+
26
+ • We propose vector-quantized knowledge distillation, promoting masked image modeling from pixel-level to semantic-level for self-supervised representation learning. • We introduce a patch aggregation strategy, which enforces global structure given discrete semantic tokens, and improves the performance of learned representations. • We conduct extensive experiments on downstream tasks including ImageNet fine-tuning, linear probing, and semantic segmentation. Experimental results show that the proposed approach significantly improves performance across model sizes, training steps, and downstream tasks.
27
+
28
+ # 2 METHODOLOGY
29
+
30
+ BEIT V2 inherits the masked image modeling framework defined by BEIT (Bao et al., 2022), which uses a visual tokenizer to convert each image to a set of discrete visual tokens. The training target is to recover the masked visual tokens, each of which corresponds to an image patch. In Section 2.2, we introduce a vector-quantized knowledge distillation algorithm, which is used to train a visual tokenizer. In Section 2.3, we employ the visual tokenizer for BEIT pretraining with the help of the patch aggregation strategy.
31
+
32
+ # 2.1 IMAGE REPRESENTATION
33
+
34
+ The vision Transformers (ViTs; Dosovitskiy et al. 2020) are employed as the backbone networks to obtain image representations. The input image $\pmb { x } \in \mathbb { R } ^ { H \times W \times C }$ is reshaped to $N = H W / P ^ { 2 }$ patches
35
+
36
+ ![](images/ae30dd1c1a463c2012c94bad578272a2db69efa4bb9976341ca57efcaf14137a.jpg)
37
+ Figure 2: Pipeline for visual tokenizer training. After training, each image is converted to discrete visual tokens.
38
+
39
+ $\{ \boldsymbol { x } _ { i } ^ { p } \} _ { i = 1 } ^ { N }$ , w a $\pmb { x } ^ { p } \in \mathbb { R } ^ { N \times ( P ^ { 2 } C ) }$ and patc $( P , P )$ is the patch size.here each patch is ments, each . The image $2 2 4 \times 2 2 4$ $1 4 \times 1 4$ $1 6 \times 1 6$ $\{ \pmb { x } _ { i } ^ { p } \} _ { i = 1 } ^ { N }$ are denoted as $\{ h _ { i } \} _ { i = 1 } ^ { N }$ , which corresponds to $N$ image patches.
40
+
41
+ # 2.2 TRAINING VISUAL TOKENIZER
42
+
43
+ We propose vector-quantized knowledge distillation (VQ-KD) to train the visual tokenizer, Figure 2, where the visual tokenizer and the decoder are two vital modules.
44
+
45
+ The visual tokenizer maps an image to a sequence of visual tokens, a.k.a., discrete codes. To be specific, an image $_ { \textbf { \em x } }$ is tokenized to $\underline { { z } } = [ z _ { 1 } , z _ { 2 } , \cdot \cdot \cdot , z _ { N } ] \in \mathcal { V } ^ { ( H / P ) \times ( W / P ) }$ , where the visual vocabulary (a.k.a., codebook) $\boldsymbol { \mathcal { V } } \in \mathbb { R } ^ { K \times D }$ contains $K$ discrete codebook embeddings.
46
+
47
+ The tokenizer is consist of a vision Transformer encoder, and a quantizer. The tokenizer first encodes the input image to vectors. Then, the vector quantizer looks up the nearest neighbor in the codebook for each patch representation $\boldsymbol { h } _ { i }$ . Let $\{ \pmb { v } _ { 1 } , \pmb { v } _ { 2 } , \pmb { \cdot } \cdot \pmb { \cdot } , \pmb { v } _ { K } \}$ denote the codebook embeddings. For the $i$ -th image patch, its quantized code is calculated as
48
+
49
+ $$
50
+ z _ { i } = \underset { j } { \arg \operatorname* { m i n } } \ \lvert \lvert \ell _ { 2 } ( \pmb { h } _ { i } ) - \ell _ { 2 } ( \pmb { v } _ { j } ) \rvert \rvert _ { 2 } ,
51
+ $$
52
+
53
+ where $j \in \{ 1 , 2 , \cdots , K \}$ and $\ell _ { 2 }$ normalization is used for codebook lookup (Yu et al., 2021). The above distance is equivalent to finding codes according to cosine similarity.
54
+
55
+ After quantizing the image to visual tokens, we feed the $\ell _ { 2 }$ -normalized codebook embeddings $\{ \ell _ { 2 } ( \pmb { v } _ { z _ { i } } ) \} _ { i = 1 } ^ { N }$ to the decoder. The decoder is also a multi-layer Transformer. The output vectors $\{ o _ { i } \} _ { i = 1 } ^ { N }$ aim at reconstructing the semantic features of a teacher model, e.g., DINO (Caron et al., 2021), and CLIP (Radford et al., 2021). Let $\mathbf { \Delta } _ { t _ { i } }$ denote the teacher model’s feature vector of the $i$ -th image patch. During training, we maximize the cosine similarity between the decoder output $\mathbf { o } _ { i }$ and the teacher guidance $\mathbf { \Delta } _ { t _ { i } }$ .
56
+
57
+ Because the quantization process (Equation 1) is non-differentiable, the gradients are directly copied from the decoder input to the encoder output (van den Oord et al., 2017), Figure 2, to back-propagate gradients to the encoder. Intuitively, the quantizer looks up the nearest code for each encoder output, while the gradients of codebook embeddings indicate useful optimization directions for the encoder.
58
+
59
+ The training objective of VQ-KD is defined as
60
+
61
+ $$
62
+ \operatorname* { m a x } \sum _ { x \in \mathcal { D } } \sum _ { i = 1 } ^ { N } \cos \left( \boldsymbol { o } _ { i } , t _ { i } \right) - | | \mathrm { s g } [ \ell _ { 2 } ( h _ { i } ) ] - \ell _ { 2 } ( \boldsymbol { v } _ { z _ { i } } ) | | _ { 2 } ^ { 2 } - | | \ell _ { 2 } ( h _ { i } ) - \mathrm { s g } [ \ell _ { 2 } ( \boldsymbol { v } _ { z _ { i } } ) ] | | _ { 2 } ^ { 2 } ,
63
+ $$
64
+
65
+ where $\mathrm { s g } [ \cdot ]$ stands for the stop-gradient operator which is an identity at the forward pass while having zero gradients during the backward pass. $\mathcal { D }$ represents the image data used for tokenizer training.
66
+
67
+ ![](images/2dadcf052d163431cd7abc25e7ef7bd1d8452054728c322f986f21031108fabc.jpg)
68
+ Figure 3: The MIM framework equipped with patch aggregation. The pretraining loss is the summation of ${ \mathcal { L } } _ { \mathrm { M I M } }$ and $\mathcal { L } _ { \mathrm { M I M } } ^ { c }$ . The loss term $\mathcal { L } _ { \mathrm { M I M } } ^ { c }$ explicitly encourages the [CLS] token to aggregate patch information to global representations.
69
+
70
+ Improving codebook utilization. A common issue of vector quantization training is codebook collapse. In other words, only a small proportion of codes are used. Empirical strategies (van den Oord et al., 2017; Yu et al., 2021) can be used to alleviate this issue. Equation 1 shows that we compute the $\ell _ { 2 }$ -normalized distance to find the nearest code while reducing the dimension of codebook embedding space to 32-d. The low-dimensional codebook embeddings are mapped back to higher-dimensional space before being fed to the decoder. Exponential moving average (van den Oord et al., 2017) is employed to update the codebook embeddings. Exponential moving average tends to be more stable for VQ-KD training.
71
+
72
+ # 2.3 PRETRAINING BEIT V2
73
+
74
+ We follow the MIM setup in BEIT (Bao et al., 2022) to pretrain vision Transformers for image representations. Given an input image $x$ , around $40 \%$ image patches are block-wisely chosen and masked. The masked position is termed as $\mathcal { M }$ . Then, a shared learnable embedding $e _ { [ \mathbf { M } ] }$ is used to replace the original image patch embeddings $e _ { i } ^ { p }$ if $i \in \mathcal { M }$ $\begin{array} { r } { \boldsymbol { \mathcal { A } } \colon \mathbf { x } _ { i } ^ { \mathcal { M } } = \delta ( i \in \mathcal { M } ) \odot \boldsymbol { e } _ { [ \mathrm { M } ] } + ( 1 - \delta ( i \in } \end{array}$ $\mathcal { M } ) ) \odot \pmb { x } _ { i } ^ { p }$ , where $\delta ( \cdot )$ is the indicator function. Subsequently, we prepend a learnable [CLS] token ito the input, i.e., $[ e _ { \mathrm { C L S } } , \{ \pmb { x } _ { i } ^ { \mathcal { M } } \} _ { i = 1 } ^ { N } ]$ , and feed them to the vision Transformer. The final encoding vectors are denoted as $\{ h _ { i } \} _ { i = 0 } ^ { N }$ , where $h _ { 0 }$ is for the [CLS] token.
75
+
76
+ Next, we instantiate the MIM head as a simple fully-connection layer, and then use it to predict the visual tokens of the masked positions based on the corrupted image $\pmb { x } ^ { \mathcal { M } }$ . For each masked position $\{ h _ { i } : i \in \mathcal { M } \} _ { i = 1 } ^ { N }$ , a softmax classifier predicts the visual tokens pectively mean weights and biases of the MIM $p ( \bar { z } _ { i } | \pmb { h } _ { i } ) = \mathrm { s o f t m a x } _ { z _ { i } } ( \pmb { W } _ { c } \hat { \pmb { h } } _ { i } + \pmb { b } _ { c } )$ $W _ { c } , b _ { c }$
77
+ by the tokenizer trained in Section 2.2, which provides supervisions for the MIM self-supervised learning procedure. The training loss of MIM is defined as
78
+
79
+ $$
80
+ \mathcal { L } _ { \mathrm { M I M } } = - \sum _ { \mathbf { x } \in \mathcal { D } } \sum _ { i \in \mathcal { M } } \log p ( z _ { i } | \mathbf { x } _ { i } ^ { \mathcal { M } } ) ,
81
+ $$
82
+
83
+ where $z _ { i }$ denotes the visual tokens of the original image, and $\mathcal { D }$ the pretraining images. Notice that the number of visual tokens is the same as the number of image patches in this work.
84
+
85
+ Pretraining global representation. Inspired by (Gao & Callan, 2021), we pretrain the [CLS] token for global image representation. The goal is to mitigate the discrepancy between patch-level pretraining and image-level representation aggregation. As illustrated in Figure 3, a representation bottleneck is constructed to encourage the [CLS] token to gather information as much as possible. For a $L$ -layer Transformer, let $\{ h _ { i } ^ { l } \} _ { i = 1 } ^ { N }$ denote the $l$ -th layer’s output vectors, where $l \in \{ 1 , 2 , \cdots , L \}$ To pretrain the last layer’s [CLS] token $h _ { \mathrm { C L S } } ^ { L }$ , we concatenate it with the intermediate $l$ -th layer’s patch vectors $\{ h _ { i } ^ { l } \} _ { i = 1 } ^ { N }$ , i.e., ${ \pmb S } = [ { \pmb h } _ { \mathrm { C L S } } ^ { L } , { \pmb h } _ { 1 } ^ { l } , \cdots , { \pmb h } _ { N } ^ { l } ]$ . We then feed $_ { s }$ to a shallow (e.g., two layers)
86
+
87
+ Transformer decoder and conduct masked prediction again, i.e., $p ( z | S ) = \mathrm { s o f t m a x } _ { z } ( W _ { c } S + b _ { c } )$ Notice that the parameters are shared for both MIM heads and the MIM loss is also computed at mask positions as in Equation 3. Accordingly, the final training loss is defined as the summation of two terms, i.e., the original loss at the $L$ -th layer, and the shallow Transformer decoder’s MIM loss. Overall framework refers to Appendix C.
88
+
89
+ Intuitively, the model favors pushing the global information to $h _ { \mathrm { C L S } } ^ { L }$ , because the model tends to fully utilize the parameters from $( l + 1 )$ -th layer to $L$ -th layer, to decrease the additional MIM loss. The information-flow bottleneck encourages the [CLS] token towards more reliable global representations than its untrained counterparts. Moreover, the enhanced representations also facilitate various downstream tasks. Notice that the newly added shallow decoder is only used to pretrain the [CLS] token, which is discarded after pretraining.
90
+
91
+ # 3 EXPERIMENTS
92
+
93
+ The pretrained models are evaluated on image classification and semantic segmentation tasks. For image classification, the models are trained on ImageNet-1K (Russakovsky et al., 2015) and evaluated by (1) top-1 accuracy about fine-tuning and (2) top-1 accuracy about linear probing (only fine-tuning the classification head). For semantic segmentation, experiments are conducted on the ADE20K dataset (Zhou et al., 2019) and the performance is evaluated using the mIoU protocol.
94
+
95
+ # 3.1 PRETRAINING SETUP
96
+
97
+ Visual tokenizer training. We instantiate the visual tokenizer of VQ-KD as ViT-B/16 for both base- and large-size BEIT V2 pretraining. The decoder network is a three-layer standard Transformer, which has the same dimension and number of attention heads as the tokenizer encoder. The OpenAI CLIP-B/16 (Radford et al., 2021) is employed as the teacher model and train VQ-KD on ImageNet-1k with $2 2 4 \times 2 2 4$ resolution. Notice that we use the same base-size teacher to train the visual tokenizer for both base- and large-size pretraining. The code size $K$ is set as 8192 and code dimension $D$ as 32 by default. Refer to Appendix D for more training details.
98
+
99
+ Masked image modeling. We follow the settings used in BEiT (Bao et al., 2022) pretraining and use ImageNet-1K without labels as the pretraining data for self-supervised learning. The input image resolution is set as $2 2 4 \mathbf { x } 2 2 4$ during pretraining. The pretrained base- and large-size vision Transformers (Dosovitskiy et al., 2020) with $1 6 \times 1 6$ patch size are denoted as ViT-B/16 and ViT-L/16, respectively. For the patch aggregation strategy, we set $l = 9$ for ViT-B/16, $l = 2 1$ for ViT-L/16, and the depth as 2 by default. A block-wise masking mechanism is adopted under the mask ratio of $40 \%$ (i.e., about 75 image patches). More pretraining details can be found in Appendix E.
100
+
101
+ # 3.2 IMAGE CLASSIFICATION
102
+
103
+ Both the fine-tuning accuracy and linear probing accuracy are evaluated on ImageNet-1k by default. The models are also evaluated on several ImageNet variants to demonstrate their favorable generalization ability.
104
+
105
+ Fine-tuning setup. We follow the protocol proposed in BEiT (Bao et al., 2022) to fine-tune the pretrained BEIT V2 model (see Appendix F for more details). In Table 1, we report the top-1 fine-tuning accuracy results and compare BEIT V2 with recent MIM methods.
106
+
107
+ From Table 1, base-size BEIT V2 with a 300-epoch pretraining schedule reaches $8 5 . 0 \%$ top-1 accuracy, which outperforms BEIT, CAE, SplitMask and $\mathrm { P e C o }$ by $2 . 1 \%$ , $1 . 4 \%$ , $1 . 4 \%$ and $0 . 9 \%$ respectively. Compared with masked distillation methods, like MVP, BEIT V2 also shows superiority. Furthermore, with a longer pretraining schedule, BEIT V2 achieves $8 5 . 5 \%$ top-1 accuracy, developing a new state of the art on ImageNet-1K among self-supervised methods. Meanwhile, BEIT V2 using ViT-L/16 with 300 epochs reaches $8 6 . 6 \%$ top-1 accuracy, which is comparable to data2vec with 1600 epochs. A longer pretraining schedule further boosts the performance to $8 7 . 3 \%$ .
108
+
109
+ Following BEIT, we add an intermediate fine-tuning phase between the pretraining stage and the fine-tuning stage. Only the intermediate fine-tuning phase uses the ImageNet-21k dataset. As shown in Table 1, we find that intermediate fine-tuning achieves about $1 \%$ performance gain on image classification for both base- and large-size models. Refer to Appendix B for more results of intermediate fine-tuning.
110
+
111
+ Table 1: Fine-tuning results of image classification and semantic segmentation on ImageNet-1K and ADE20k. UperNet (Xiao et al., 2018) is used as the task layer for semantic segmentation with single-scale (512 size) input.
112
+
113
+ <table><tr><td>Methods</td><td>Pretraining Epochs</td><td>ImageNet Top-1 Accuracy(%)</td><td>ADE20k mIoU(%)</td></tr><tr><td>Base-size models (ViT-B/16)</td><td></td><td></td><td></td></tr><tr><td>BEIT (Bao et al., 2022)</td><td>300</td><td>82.9</td><td>44.7</td></tr><tr><td>CAE (Chen et al., 2022)</td><td>300</td><td>83.6</td><td>48.3</td></tr><tr><td>SplitMask (El-Nouby et al., 2021)</td><td>300</td><td>83.6</td><td>45.7</td></tr><tr><td>MaskFeat (Wei et al., 2021)</td><td>300</td><td>83.6</td><td>N/A</td></tr><tr><td>PeCo (Dong et al., 2021)</td><td>300</td><td>84.1</td><td>46.7</td></tr><tr><td>MVP(Wei et al., 2022)</td><td>300</td><td>84.4</td><td>52.4</td></tr><tr><td>iBoT (Zhou et al., 2022)</td><td>400</td><td>83.8</td><td>50.0</td></tr><tr><td>BEIT v2 (ours)</td><td>300</td><td>85.0</td><td>52.7</td></tr><tr><td>Base-size models (ViT-B/16) + pretrain longer</td><td></td><td></td><td></td></tr><tr><td>BEIT (Bao et al., 2022)</td><td>800</td><td>83.2</td><td>45.6</td></tr><tr><td>PeCo (Dong et al., 2021)</td><td>800</td><td>84.5</td><td>48.5</td></tr><tr><td>data2vec (Baevski et al., 2022)</td><td>800</td><td>84.2</td><td>N/A</td></tr><tr><td>MAE (He et al., 2022)</td><td>1600</td><td>83.6</td><td>48.1</td></tr><tr><td>CAE (Chen et al.,2022)</td><td>1600</td><td>83.9</td><td>50.2</td></tr><tr><td>BEIT v2 (ours)</td><td>1600</td><td>85.5</td><td>53.1</td></tr><tr><td>+ Intermediate fine-tuning with ImageNet-21k</td><td></td><td>86.5</td><td>53.5</td></tr><tr><td>Large-size models (ViT-L/16)</td><td></td><td></td><td></td></tr><tr><td>iBoT (Zhou et al.,2022)</td><td>250</td><td>84.8</td><td>N/A</td></tr><tr><td>MaskFeat (Wei et al., 2021)</td><td>300</td><td>84.4</td><td>N/A</td></tr><tr><td>MVP (Wei et al., 2022)</td><td>300</td><td>86.3</td><td>54.3</td></tr><tr><td>BEIT V2 (ours)</td><td>300</td><td>86.6</td><td>55.0</td></tr><tr><td> Large-size models (ViT-L/16) + pretrain longer</td><td></td><td></td><td></td></tr><tr><td>BEIT (Bao et al., 2022)</td><td>800</td><td>85.2</td><td>53.3</td></tr><tr><td>MaskFeat (Wei et al., 2021)</td><td>1600</td><td>85.7</td><td>N/A</td></tr><tr><td>MAE (He et al., 2022)</td><td>1600</td><td>85.9</td><td>53.6</td></tr><tr><td>CAE (Chen et al., 2022)</td><td>1600</td><td>86.3</td><td>54.7</td></tr><tr><td>data2vec (Baevski et al.,2022)</td><td>1600</td><td>86.6</td><td>N/A</td></tr><tr><td>BEIT V2 (ours)</td><td>1600</td><td>87.3</td><td>56.7</td></tr><tr><td>+ Intermediate fine-tuning with ImageNet-21k</td><td></td><td>88.4</td><td>57.5</td></tr><tr><td colspan="2"></td><td></td><td></td></tr></table>
114
+
115
+ Table 2: Top-1 accuracy of linear probing on ImageNet-1k. All methods are based on ViTB/16 pretrained for 300 epochs except MAE for 1600 epochs.
116
+
117
+ <table><tr><td>Methods</td><td>Linear Probe</td></tr><tr><td>BEIT (Bao et al., 2022)</td><td>56.7</td></tr><tr><td>CAE (Chen et al., 2022)</td><td>64.1</td></tr><tr><td>MAE (He et al., 2022)</td><td>67.8</td></tr><tr><td>MVP(Wei et al., 2022)</td><td>75.4</td></tr><tr><td>MoCo v3 (Chen et al., 2021)</td><td>76.7</td></tr><tr><td>BEIT v2 (ours)</td><td>80.1</td></tr></table>
118
+
119
+ Table 3: Robustness evaluation on three ImageNet variants (Hendrycks et al., 2021b;a; Wang et al., 2019).
120
+
121
+ <table><tr><td>Methods</td><td>ImageNet Adversarial</td><td>ImageNet Rendition</td><td>ImageNet Sketch</td></tr><tr><td>ViT-B/16</td><td></td><td></td><td></td></tr><tr><td>MAE</td><td>35.9</td><td>48.3</td><td>34.5</td></tr><tr><td>BEIT V2</td><td>54.4</td><td>61.0</td><td>45.6</td></tr><tr><td>ViT-L/16</td><td></td><td></td><td></td></tr><tr><td>MAE</td><td>57.1</td><td>59.9</td><td>45.3</td></tr><tr><td>BEIT V2</td><td>69.0</td><td>69.9</td><td>53.5</td></tr></table>
122
+
123
+ Linear probing. Keeping the backbone model frozen and training a linear classification head atop the image-level representations, linear probing has been a widely considered measure for selfsupervised learning. We average the patch tokens as the global representation for the models without patch aggregation. Otherwise, we consider the [CLS] token as the global representation. Table 2 presents the top-1 accuracy for linear probing and compares BEIT V2 with recent methods including BEIT, CAE, MAE, MVP and MoCo v3. All the compared methods are based on ViT-B/16 and pretrained for 300 epochs except MAE for 1600 epochs. BEIT V2 respectively outperforms BEIT, CAE and MVP by $2 3 . 4 \%$ , $1 6 . 0 \%$ and $4 . 7 \%$ . BEIT V2 also outperforms MoCo v3, which learns a global representation through a contrastive learning fashion. The comparisons indicate that the representation models learned by BEIT V2 enjoy higher adaptation capability.
124
+
125
+ Table 4: Ablation studies under VQ-KD settings. “Base&1x768x12” denotes that the encoder network is ViT-Base while the decoder is a Transformer with depth 1, dimensions 768, and head 12. “Reconst. Loss” is the reconstruction loss of VQ-KD. Reconstruction loss and codebook usage are measured on the validation set. After 300 epochs of pretraining, our method reports the top-1 fine-tuning accuracy and linear probing accuracy on ImageNet-1k, and mIoU on ADE20k. The default setting is highlighted in gray .
126
+
127
+ <table><tr><td>VQ-KD Architecture</td><td>Codebook</td><td>Reconst. Loss</td><td>Codebook Usage</td><td>ImageNet Fine-tuning</td><td>ImageNet Linear Probe</td><td>ADE20k</td></tr><tr><td>Small &amp; 1x384x6</td><td rowspan="4">8192×32</td><td>0.183</td><td>100%</td><td>84.3</td><td>76.0</td><td>51.0</td></tr><tr><td>Base&amp;1x768x12</td><td>0.164</td><td>100%</td><td>84.7</td><td>78.5</td><td>51.8</td></tr><tr><td>Base&amp;3x768x12</td><td>0.145</td><td>95%</td><td>84.7</td><td>77.9</td><td>51.9</td></tr><tr><td>Base&amp; 6x768x12</td><td>0.136</td><td>77%</td><td>84.6</td><td>63.0</td><td>50.1</td></tr><tr><td rowspan="2">Base &amp;3x768x12</td><td>8192×16</td><td>0.145</td><td>100%</td><td>84.7</td><td>76.7</td><td>51.7</td></tr><tr><td>8192×64</td><td>0.148</td><td>67%</td><td>84.7</td><td>77.6</td><td>51.6</td></tr></table>
128
+
129
+ Robustness evaluation. We evaluate the robustness of BEIT V2 on various ImageNet validation sets, i.e., ImageNet-Adversarial (Hendrycks et al., 2021b), ImageNet-Rendition (Hendrycks et al., 2021a) and ImageNet-Sketch (Wang et al., 2019). As shown in Table 3, compared with MAE (He et al., 2022), BEIT V2 achieves dramatic gains across datasets, demonstrating the superiority of the proposed method in terms of model generalization.
130
+
131
+ # 3.3 SEMANTIC SEGMENTATION
132
+
133
+ Semantic segmentation is a dense prediction task, which generates class label for each pixel of the input image. Following the setting proposed in BEIT (Bao et al., 2022), we conduct experiments on ADE20K benchmark (Zhou et al., 2019), which includes 25K mages and 150 semantic categories. We use UperNet (Xiao et al., 2018) task layer and fine-tune the model for 160K iterations with the input resolution $5 1 2 \times 5 1 2$ . Refer to Appendix G for details. Table 1 shows that BEIT V2 significantly outperforms previous self-supervised methods. Moreover, using the ViT-L/16 model, the performance can reach 56.7, which builds a new state-of-the-art for masked image modeling on ADE20k.
134
+
135
+ # 3.4 ANALYSIS
136
+
137
+ Visual tokenizer training. We investigate the impact of VQ-KD on BEIT V2 in terms of the model architecture and codebook size and report the results in Table 4. ViT-B/16 without the patch aggregation strategy is used as the baseline model, which is pretrained for 300 epochs. As shown in Table 4, we find that a deeper decoder of VQ-KD obtains better reconstruction, but lower codebook usage and downstream task performance. Reducing dimension for codebook lookup improves codebook utilization (Yu et al., 2021).
138
+
139
+ Patch aggregation strategy. Table 5 presents the ablation studies of the patch aggregation strategy. The shallower head (i.e., 1/2-layer) performs better than the deeper head (i.e., 3-layer), suggesting the shallower head pays more attention to the input [CLS] token than the deeper head. Moreover, the proposed method outperforms the baseline variant without patch aggregation strategy. The improvement of linear probe indicates better image-level representations. In addition, the results indicate that sharing the MIM head improves downstream performance.
140
+
141
+ Table 5: Ablation studies for patch aggregation strategy. $l$ -th Layer denotes patch tokens from the $l$ -th layer of the backbone. Head Depth means the patch aggregation head depth. Shared MIM Head means whether we share the MIM head parameters or not. Default settings are in gray .
142
+
143
+ <table><tr><td>l-th Layer</td><td>Head Depth</td><td>Shared MIM Head</td><td>ImageNet Fine-tuning</td><td>ImageNet Linear Probe</td><td>ADE20k</td></tr><tr><td>1</td><td>=</td><td>Without patch aggregation =</td><td>84.7</td><td>77.9</td><td>51.9</td></tr><tr><td>With patch aggregation</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>9</td><td>2</td><td>√</td><td>85.0</td><td>80.1</td><td>52.7</td></tr><tr><td>9</td><td>2</td><td>X</td><td>84.8</td><td>79.5</td><td>51.9</td></tr><tr><td>9</td><td>1</td><td>√</td><td>84.8</td><td>78.9</td><td>51.7</td></tr><tr><td>9</td><td>3</td><td></td><td>84.7</td><td>78.1</td><td>52.0</td></tr><tr><td>6</td><td>2</td><td></td><td>84.9</td><td>77.5</td><td>53.1</td></tr><tr><td>11</td><td>2</td><td></td><td>84.5</td><td>69.4</td><td>51.8</td></tr></table>
144
+
145
+ Table 6: Comparisons between different VQ-KD targets. We also report the fine-tuning results of VQ-KD target models.
146
+
147
+ <table><tr><td>VQ-KD Targets</td><td>ImageNet</td><td>ADE20k</td></tr><tr><td>Pretrain 300 epochs</td><td></td><td></td></tr><tr><td>DINO</td><td>84.4</td><td>49.2</td></tr><tr><td>CLIP</td><td>85.0</td><td>52.7</td></tr><tr><td>Pretrain 1600 epochs</td><td></td><td></td></tr><tr><td>CLIP</td><td>85.5</td><td>53.1</td></tr><tr><td>Performance of VQ-KD target models</td><td></td><td></td></tr><tr><td>DINO</td><td>83.6</td><td>46.8</td></tr><tr><td>CLIP</td><td>84.9</td><td></td></tr><tr><td>Performance of VQ-KD encoder model</td><td></td><td></td></tr><tr><td>VQ-KD encoder (CLIP as target)</td><td>83.6</td><td></td></tr></table>
148
+
149
+ VQ-KD targets. In Table 6, we report the results about VQ-KDs are trained under the supervision of DINO (Caron et al., 2021) and CLIP (Radford et al., 2021). DINO is pretrained solely on ImageNet1k while CLIP is pretrained on 400M image-text pairs datasets in house. We also directly fine-tune the official base-size checkpoints and report the results in Table 6. One can see that when using DINO as the teacher model, BEIT V2 respectively reaches $8 4 . 4 \%$ and $4 9 . 2 \%$ on ImageNet and ADE20k, outperforming DINO itself by a large margin. When using CLIP as the teacher model, BEIT V2 can get consistent improvements, demonstrating the scalability of the proposed VQ-KD. In addition, we directly fine-tune the VQ-KD encoder on ImageNet. The results show that transfer performance of the VQ-KD encoder is lower than the teacher model. After performing masked image modeling, the pretrained model outperforms both the teacher model and the visual tokenizer encoder. It demonstrates the superiority of the proposed method for self-supervised learning.
150
+
151
+ Visualization of codebook. We utilize the proposed VQ-KD to calculate discrete codes about the ImageNet-1k validation set. Image patches are grouped according to their corresponding codes. Figure 4 shows that the grouped image patches represent explicit semantics. For instance, the image patches corresponding to code 7856 are about “eyes” of human, cat, dog, fish and snake. Refer to Appendix A) for more examples. The introduction of codebook and feature quantization reduces the sensitiveness to the change of image details while facilitates exploitation of high-level semantics for representation models. VQ-KD compresses and quantizes the continuous feature values to a codebook, which constructs a discrete semantic space. The dimensionality of such a semantic space is significantly lower than that of the original continuous feature space. This reduces difficulty of masked patch reconstruction and alleviates the curse of dimensionality in the pretraining phase.
152
+
153
+ ![](images/c9e69eb7bba48bcd175a31fbbb91b7a5f363e4b62b5885355c27126c5c52d8ef.jpg)
154
+ Figure 4: Visualization of semantic concepts corresponding to the learned codebook.
155
+
156
+ # 4 RELATED WORK
157
+
158
+ Visual tokenizer. VQ-VAE (van den Oord et al., 2017) converts an image into a sequence of discrete codes and then reconstructs the input image based on discrete codes. DALL-E (Ramesh et al., 2021) uses the Gumbel-softmax relaxation for quantization instead of the nearest neighbor lookup in VQ-VAE. VQGAN (Esser et al., 2021) and ViT-VQGAN (Yu et al., 2021) introduce Transformer block to train a better autoencoder to maintain fine details with adversarial and perceptual loss. Moreover, ViT-VQGAN proposes factorized and $\ell _ { 2 }$ -normalized code for codebook learning. In comparison, the proposed VQ-KD aims at reconstructing semantic knowledge from the teacher rather than original pixels. So we can construct a highly compact semantic codebook for MIM.
159
+
160
+ Masked image modeling. The MIM method has achieved great success in language task (Devlin et al., 2019). Motivated by it, BEIT (Bao et al., 2022) mitigated the MIM method to computer vision tasks by recovering discrete visual tokens (Ramesh et al., 2021). The prediction targets for MIM habe been explored by many recent works. MAE (He et al., 2022) treated MIM as a denoising pixel-level reconstruction task. Knowledge distillation (Wei et al., 2021; 2022) and self-distillation (Zhou et al., 2022; Baevski et al., 2022) proposed to mimic the features provided by the teacher at the masked positions. PeCo (Dong et al., 2021) regarded MoCo v3 (Chen et al., 2021) as the perceptual model in VQGAN training (Esser et al., 2021), to pursue a better tokenizer for BEIT pretraining. Despite of the progress, most existing studies remain operating on low-level image pixels, this work explores how to promote masked image modeling from pixel-level to semantic-level.
161
+
162
+ # 5 CONCLUSION
163
+
164
+ We proposed vector-quantized knowledge distillation (VQ-KD) to train a visual tokenizer for vision Transformer pretraining. VQ-KD discretized a continuous semantic space that provides supervision for masked image modeling rather than relying on image pixels. The semantic visual tokenizer greatly improved the BEIT pretraining and significantly boosted the transfer performance upon downstream tasks, such as image classification, and semantic segmentation. Moreover, a patch aggregation mechanism was introduced to explicitly encourage the model to produce global image representations, narrowing the gap between the patch-level pretraining and image-level representation aggregation. In the future, we would like to learn a universal tokenizer that projects words and images into the same vocabulary, so that we can conduct masked prediction for vision-language pretraining.
165
+
166
+ # REPRODUCIBILITY
167
+
168
+ Details of VQ-KD training, BEIT V2 pretraining, fine-tuning recipes are given in Appendix D, E, F and G. The models used for VQ-KD training are from the official repositories https:// github.com/facebookresearch/dino and https://github.com/openai/CLIP. The datasets (e.g., ImageNet, and ADE20k) are derived from publicly available data buckets. The code can be found in the supplementary materials. We will also provide pretrained checkpoints to reproduce the numbers.
169
+
170
+ # REFERENCES
171
+
172
+ Alexei Baevski, Wei-Ning Hsu, Qiantong Xu, Arun Babu, Jiatao Gu, and Michael Auli. Data2vec: A general framework for self-supervised learning in speech, vision and language. arXiv preprint arXiv:2202.03555, 2022.
173
+
174
+ Hangbo Bao, Li Dong, Songhao Piao, and Furu Wei. BEiT: BERT pre-training of image Transformers. In International Conference on Learning Representations, 2022.
175
+
176
+ Mathilde Caron, Hugo Touvron, Ishan Misra, Hervé Jégou, Julien Mairal, Piotr Bojanowski, and Armand Joulin. Emerging properties in self-supervised vision Transformers. arXiv preprint arXiv:2104.14294, 2021.
177
+
178
+ Xiaokang Chen, Mingyu Ding, Xiaodi Wang, Ying Xin, Shentong Mo, Yunhao Wang, Shumin Han, Ping Luo, Gang Zeng, and Jingdong Wang. Context autoencoder for self-supervised representation learning. arXiv preprint arXiv:2202.03026, 2022.
179
+
180
+ Xinlei Chen, Saining Xie, and Kaiming He. An empirical study of training self-supervised vision Transformers. ArXiv, abs/2104.02057, 2021.
181
+
182
+ 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, pp. 4171–4186. Association for Computational Linguistics, 2019.
183
+
184
+ Xiaoyi Dong, Jianmin Bao, Ting Zhang, Dongdong Chen, Weiming Zhang, Lu Yuan, Dong Chen, Fang Wen, and Nenghai Yu. PeCo: Perceptual codebook for bert pre-training of vision Transformers. arXiv preprint arXiv:2111.12710, 2021.
185
+
186
+ 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.
187
+
188
+ Alaaeldin El-Nouby, Gautier Izacard, Hugo Touvron, Ivan Laptev, Hervé Jegou, and Edouard Grave. Are large-scale datasets necessary for self-supervised pre-training? arXiv preprint arXiv:2112.10740, 2021.
189
+
190
+ Patrick Esser, Robin Rombach, and Bjorn Ommer. Taming Transformers for high-resolution image synthesis. In CVPR, pp. 12873–12883, 2021.
191
+
192
+ Yuxin Fang, Li Dong, Hangbo Bao, Xinggang Wang, and Furu Wei. Corrupted image modeling for self-supervised visual pre-training. ArXiv, abs/2202.03382, 2022.
193
+
194
+ Luyu Gao and Jamie Callan. Condenser: a pre-training architecture for dense retrieval. arXiv preprint arXiv:2104.08253, 2021.
195
+
196
+ Kaiming He, Xinlei Chen, Saining Xie, Yanghao Li, Piotr Dollár, and Ross Girshick. Masked autoencoders are scalable vision learners. In CVPR, 2022.
197
+
198
+ Dan Hendrycks, Steven Basart, Norman Mu, Saurav Kadavath, Frank Wang, Evan Dorundo, Rahul Desai, Tyler Zhu, Samyak Parajuli, Mike Guo, Dawn Song, Jacob Steinhardt, and Justin Gilmer. The many faces of robustness: A critical analysis of out-of-distribution generalization. In IEEE ICCV, 2021a.
199
+
200
+ Dan Hendrycks, Kevin Zhao, Steven Basart, Jacob Steinhardt, and Dawn Song. Natural adversarial examples. In IEEE CVPR, 2021b.
201
+
202
+ Ze Liu, Han Hu, Yutong Lin, Zhuliang Yao, Zhenda Xie, Yixuan Wei, Jia Ning, Yue Cao, Zheng Zhang, Li Dong, Furu Wei, and Baining Guo. Swin transformer v2: Scaling up capacity and resolution. In International Conference on Computer Vision and Pattern Recognition (CVPR), 2022.
203
+
204
+ Alec Radford, Jong Wook Kim, Chris Hallacy, Aditya Ramesh, Gabriel Goh, Sandhini Agarwal, Girish Sastry, Amanda Askell, Pamela Mishkin, Jack Clark, et al. Learning transferable visual models from natural language supervision. In ICML, pp. 8748–8763. PMLR, 2021.
205
+
206
+ A. Ramesh, Mikhail Pavlov, Gabriel Goh, Scott Gray, Chelsea Voss, Alec Radford, Mark Chen, and Ilya Sutskever. Zero-shot text-to-image generation. ArXiv, abs/2102.12092, 2021.
207
+
208
+ 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.
209
+
210
+ Aaron van den Oord, Oriol Vinyals, and Koray Kavukcuoglu. Neural discrete representation learning. In NeurIPS, NIPS’17, pp. 6309–6318, Red Hook, NY, USA, 2017. Curran Associates Inc. ISBN 9781510860964.
211
+
212
+ 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.
213
+
214
+ Wenhui Wang, Hangbo Bao, Li Dong, Johan Bjorck, Zhiliang Peng, Qiang Liu, Kriti Aggarwal, Owais Mohammed, Saksham Singhal, Subhojit Som, and Furu Wei. Image as a foreign language: BEiT pretraining for all vision and vision-language tasks. ArXiv, abs/2208.10442, 2022.
215
+
216
+ 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.
217
+
218
+ Longhui Wei, Lingxi Xie, Wengang Zhou, Houqiang Li, and Qi Tian. MVP: Multimodality-guided visual pre-training. arXiv preprint arXiv:2203.05175, 2022.
219
+
220
+ Tete Xiao, Yingcheng Liu, Bolei Zhou, Yuning Jiang, and Jian Sun. Unified perceptual parsing for scene understanding. In ECCV, 2018.
221
+
222
+ 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.
223
+
224
+ Xiaohua Zhai, Alexander Kolesnikov, Neil Houlsby, and Lucas Beyer. Scaling vision Transformers. arXiv preprint arXiv:2106.04560, 2021.
225
+
226
+ 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.
227
+
228
+ Jinghao Zhou, Chen Wei, Huiyu Wang, Wei Shen, Cihang Xie, Alan Yuille, and Tao Kong. Image BERT pre-training with online tokenizer. In International Conference on Learning Representations, 2022.
229
+
230
+ # A VISUALIZATION OF CODEBOOK
231
+
232
+ It is observed that a discrete code tends to represent explicit semantics (Section 3.4). In Figure 5(upper), we show image examples corresponding to a given discrete code. One can see that discrete codes ignore image details, such as color, illumination, rotation and scale.
233
+
234
+ In the lower part of Figure 5, we also show some patches that mismatch the semantic concepts. Taking the fish (the first image at the last row) as instance, VQ-KD misclassifies the spot on the fish body as the eye concept due to the local structure similarity.
235
+
236
+ ![](images/9349f26f06a59d420a53dbecc8d394059a22dcdd7b7065b9af2ea7af701f7791.jpg)
237
+ Figure 5: Visualization of image patches corresponding to discrete codes. Upper: examples matching the learned semantic concepts; Lower: patches mis-matching the semantic concepts. Corresponding patches are marked in red rectangle
238
+
239
+ # B COMPARISON WITH LARGE-SCALE SUPERVISED PRETRAINING
240
+
241
+ We report the performance by using the ImageNet-1k for pretraining in Table 1. To show the data scalability of BEIT V2, we conduct intermediate fine-tuning experiments on ImagNet-21k and final fine-tuning on ImageNet-1k, by using the 1600 epoch pretraining models in Table 1. From Table 7, BEIT V2 using ViT-L/16 with $3 8 4 \times 3 8 4$ input resolution, achieves $8 9 . 0 \%$ top-1 accuracy, which even outperforms ViT-H/14 using Google JFT-3B labeled dataset by $0 . 5 \%$ . This significant performance gain indicates the data efficiency and superiority of the proposed BEIT V2.
242
+
243
+ Table 7: Top-1 accuracy on ImageNet-1K fine-tuning. $2 2 4 ^ { 2 }$ and $3 8 4 ^ { 2 }$ denote model resolutions.
244
+
245
+ <table><tr><td>Models</td><td>Model Size</td><td>Labeled Data Size</td><td>ImageNet-1k 224²</td><td>384²</td></tr><tr><td>Supervised Pretraining on ImageNet-21K</td><td></td><td></td><td></td><td></td></tr><tr><td>ViT-B/16 (Dosovitskiy et al.,2020)</td><td>86M</td><td>14M</td><td></td><td>84.0</td></tr><tr><td>ViT-L/16 (Dosovitskiy et al., 2020)</td><td>307M</td><td>14M</td><td></td><td>85.2</td></tr><tr><td>ViT-H/14 (Dosovitskiy et al., 2020)</td><td>632M</td><td>14M</td><td></td><td>85.1</td></tr><tr><td>Supervised Pretraining on Google JFT-3OOM (using labeled data)</td><td></td><td></td><td></td><td></td></tr><tr><td>ViT-B/16 (Dosovitskiy et al., 2020)</td><td>86M</td><td>300M</td><td></td><td>84.2</td></tr><tr><td>ViT-L/16 (Dosovitskiy et al., 2020)</td><td>307M</td><td>300M</td><td></td><td>87.1</td></tr><tr><td>ViT-H/14 (Dosovitskiy et al., 2020)</td><td>632M</td><td>300M</td><td></td><td>88.0</td></tr><tr><td>Supervised Pretraining on Google JFT-3B</td><td></td><td></td><td></td><td></td></tr><tr><td>ViT-B/16 (Zhai et al., 2021)</td><td>86M</td><td>3000M</td><td></td><td>86.6</td></tr><tr><td>ViT-L/16 (Zhai et al., 2021)</td><td>307M</td><td>3000M</td><td></td><td>88.5</td></tr><tr><td colspan="5">BEIT Pretraining on ImageNet-21K, and Intermediate Fine-Tuning on ImageNet-21K</td></tr><tr><td>BEIT ViT-B/16 (Bao et al., 2022)</td><td>86M</td><td>14M</td><td>85.2</td><td>86.8</td></tr><tr><td>BEIT ViT-L/16 (Bao et al.,2022)</td><td>307M</td><td>14M</td><td>87.4</td><td>88.4</td></tr><tr><td>BEIT v2 Pretraining on ImageNet-1K, and Intermediate Fine-Tuning on ImageNet-21K</td><td></td><td></td><td></td><td></td></tr><tr><td>BEIT V2 ViT-B/16 (ours)</td><td>86M</td><td>14M</td><td>86.5</td><td>87.5</td></tr><tr><td>BEIT V2 ViT-L/16 (ours)</td><td>307M</td><td>14M</td><td>88.4</td><td>89.0</td></tr></table>
246
+
247
+ # C OVERALL FRAMEWORK FOR BEIT V2
248
+
249
+ We show the tokenizer training part and BEIT V2 pretraining part in Figure 2 and Figure 3, respectively. In addition, we present the whole pretraining process in Figure 6.
250
+
251
+ ![](images/f6cbe28a663368e427f2f3fe98bfefab5ceff46263372f3b12685cfa812fb8e2.jpg)
252
+ Figure 6: Overall framework for BEIT V2 pretraining.
253
+
254
+ # D HYPERPARAMETERS FOR VQ-KD TRAINING
255
+
256
+ Table 8: Hyperparameters for training VQ-KD on ImageNet-1K.
257
+
258
+ <table><tr><td rowspan=1 colspan=1>Hyperparameters</td><td rowspan=1 colspan=1>Values</td></tr><tr><td rowspan=1 colspan=1>Encoder layersDecoder layersHidden sizeFFN inner hidden sizeAttention headsAttention head sizePatch sizeCodebook size</td><td rowspan=1 colspan=1>12{1,3}7683072126416 ×168192 × 32</td></tr><tr><td rowspan=1 colspan=1>Training epochsBatch sizeAdam βPeak learning rateMinimal learning rateLearning rate scheduleWarmup epochs</td><td rowspan=1 colspan=1>100512(0.9, 0.99)2e-41e-5Cosine5</td></tr><tr><td rowspan=1 colspan=1>Gradient clippingDropoutStoch.depthWeight decay</td><td rowspan=1 colspan=1>×XX1e-4</td></tr><tr><td rowspan=1 colspan=1>Data AugmentInput resolution</td><td rowspan=1 colspan=1>RandomResizeAndCrop224× 224</td></tr></table>
259
+
260
+ # E HYPERPARAMETERS FOR BEIT V2 PRETRAINING
261
+
262
+ Table 9: Hyperparameters for BEIT V2 pretraining on ImageNet-1K. ∗ denotes that the hyperparame ters are adopted when the pretraining schedule is 300 epochs.
263
+
264
+ <table><tr><td>Hyperparameters</td><td>Base Size</td><td>Large Size</td></tr><tr><td>Layers Hidden size</td><td>12 768</td><td>24</td></tr><tr><td>FFN inner hidden size</td><td>3072</td><td>1024 4096</td></tr><tr><td>Attention heads</td><td></td><td></td></tr><tr><td></td><td>12</td><td>16</td></tr><tr><td>Layer scale Patch size</td><td>0.1</td><td>1e-5</td></tr><tr><td>Relative positional embeddings</td><td colspan="2">16 ×16</td></tr><tr><td>Shared relative positional embeddings</td><td colspan="2">√ √</td></tr><tr><td>Training epochs Batch size</td><td colspan="2">300*/1600 2048</td></tr><tr><td>Adam β</td><td colspan="2">(0.9, 0.98*/0.999)</td></tr><tr><td>Peak learning rate</td><td colspan="2"></td></tr><tr><td></td><td colspan="2">1.5e-3</td></tr><tr><td>Minimal learning rate</td><td colspan="2">1e-5</td></tr><tr><td>Learning rate schedule</td><td colspan="2">Cosine</td></tr><tr><td>Warmup epochs</td><td colspan="2">10</td></tr><tr><td>Gradient clipping</td><td colspan="2">3.0</td></tr><tr><td>Dropout</td><td colspan="2">X</td></tr><tr><td>Drop path</td><td colspan="2">0*/0.1</td></tr><tr><td>Weight decay</td><td colspan="2">0.05</td></tr><tr><td>Data Augment</td><td colspan="2">RandomResizeAndCrop</td></tr><tr><td>Input resolution Color jitter</td><td colspan="2">224× 224</td></tr></table>
265
+
266
+ # F HYPERPARAMETERS FOR IMAGE CLASSIFICATION FINE-TUNING
267
+
268
+ Table 10: Hyperparameters for fine-tuning BEIT V2 on ImageNet-1K.
269
+
270
+ <table><tr><td>Hyperparameters</td><td>ViT-B/16</td><td>ViT-L/16</td></tr><tr><td rowspan="2">Peak learning rate Fine-tuning epochs Warmup epochs</td><td>5e-4 100</td><td>5e-4</td></tr><tr><td>20 0.65</td><td>50 5</td></tr><tr><td>Layer-wise learning rate decay Batch size Adam e Adam β</td><td colspan="2">0.8 1024 1e-8 (0.9, 0.999)</td></tr><tr><td>Minimal learning rate Learning rate schedule Repeated Aug Weight decay Label smoothing ε</td><td colspan="2">1e-6 Cosine X 0.05 0.1</td></tr><tr><td>Stoch. depth Dropout Gradient clipping Erasing prob.</td><td>0.1 X X 0.25</td><td>0.2</td></tr><tr><td>Input resolution Rand Augment Mixup prob. Cutmix prob. Relative positional embeddings Shared relative positional embeddings</td><td>224 × 224 9/0.5 0.8 1.0 √ X</td><td></td></tr></table>
271
+
272
+ # G HYPERPARAMETERS FOR ADE20K SEMANTIC SEGMENTATIONFINE-TUNING
273
+
274
+ Table 11: Hyperparameters for fine-tuning BEIT V2 on ADE20K.
275
+
276
+ <table><tr><td rowspan=1 colspan=1>Hyperparameters</td><td rowspan=1 colspan=1>ViT-B/16 ViT-L/16</td></tr><tr><td rowspan=1 colspan=1>Input resolution</td><td rowspan=1 colspan=1>512 × 512</td></tr><tr><td rowspan=1 colspan=1>Peak learning rateFine-tuning stepsBatch sizeAdam eAdam βLayer-wise learning rate decayMinimal learning rateLearning rate scheduleWarmup steps</td><td rowspan=1 colspan=1>{0.5, 0.8, 1.0}e-4160K161e-8(0.9, 0.999){0.75, 0.8, 0.85}0Linear1500</td></tr><tr><td rowspan=1 colspan=1>DropoutStoch. depthWeight decay</td><td rowspan=1 colspan=1>X0.1 0.20.05</td></tr><tr><td rowspan=1 colspan=1>Relative positional embeddingsShared relative positional embeddings</td><td rowspan=1 colspan=1>√X</td></tr></table>
md/dev/WbxHAzkeQcn/WbxHAzkeQcn.md ADDED
The diff for this file is too large to render. See raw diff
 
md/dev/Y6A4-R_Hgsw/Y6A4-R_Hgsw.md ADDED
@@ -0,0 +1,321 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Toward a realistic model of speech processing in the brain with self-supervised learning
2
+
3
+ Juliette Millet∗ 1,2,3 Charlotte Caucheteux∗ 1,4 Pierre Orhan2 Yves Boubenec2
4
+ Alexandre Gramfort4 Ewan Dunbar2,5 Christophe Pallier6 Jean-Rémi King1,2
5
+
6
+ ∗These authors contributed equally 1Meta AI, Paris, France 2Ecole Normale Supérieure, PSL University, Paris, France 3LPI, Université de Paris cité, Paris, France 4Université Paris-Saclay, Inria, CEA, Palaiseau, France 5University of Toronto, Toronto, Canada 6Cognitive Neuroimaging Unit, INSERM, Gif-sur-Yvette, France
7
+
8
+ {jumi,ccaucheteux,jeanremi}@meta.com
9
+
10
+ # Abstract
11
+
12
+ Several deep neural networks have recently been shown to generate activations similar to those of the brain in response to the same input. These algorithms, however, remain largely implausible: they require (1) extraordinarily large amounts of data, (2) unobtainable supervised labels, (3) textual rather than raw sensory input, and / or (4) implausibly large memory (e.g. thousands of contextual words). These elements highlight the need to identify algorithms that, under these limitations, would suffice to account for both behavioral and brain responses. Focusing on speech processing, we here hypothesize that self-supervised algorithms trained on the raw waveform constitute a promising candidate. Specifically, we compare a recent self-supervised model, wav2vec 2.0, to the brain activity of 412 English, French, and Mandarin individuals recorded with functional Magnetic Resonance Imaging (fMRI), while they listened to approximately one hour of audio books. First, we show that this algorithm learns brain-like representations with as little as 600 hours of unlabelled speech – a quantity comparable to what infants can be exposed to during language acquisition. Second, its functional hierarchy aligns with the cortical hierarchy of speech processing. Third, different training regimes reveal a functional specialization akin to the cortex: wav2vec 2.0 learns sound-generic, speech-specific and language-specific representations similar to those of the prefrontal and temporal cortices. Fourth, we confirm the similarity of this specialization with the behavior of 386 additional participants. These elements, resulting from the largest neuroimaging benchmark to date, show how self-supervised learning can account for a rich organization of speech processing in the brain, and thus delineate a path to identify the laws of language acquisition which shape the human brain.
13
+
14
+ # 1 Introduction
15
+
16
+ The performance of deep neural networks has taken off over the past decade. Algorithms trained on object classification, text translation, and speech recognition are starting to reach human-level performance [Xu et al., 2020]. Furthermore, the representations generated by these algorithms have repeatedly been shown to correlate with those of the brain [Kriegeskorte, 2015, Yamins and DiCarlo, 2016, Kietzmann et al., 2018, Kell and McDermott, 2019, Cichy and Kaiser, 2019, Toneva and
17
+
18
+ Wehbe, 2019, Millet and King, 2021, Caucheteux and King, 2022], suggesting that these algorithms converge to brain-like computations.
19
+
20
+ Such convergence, however, should not obscure the major differences that remain between these deep learning models and the brain. In particular, the above comparisons derive from models trained with (1) extraordinarily large amounts of data (40GB for GPT-2 [Radford et al., 2019], the equivalent of multiple lifetimes of reading), (2) supervised labels, which is rarely the case for humans (e.g. [Yamins and DiCarlo, 2016]), (3) data in a textual rather than a raw sensory format, and/or (4) considerable memory (e.g., language models typically have parallel access to thousands of context words to process text). These differences highlight the pressing necessity to identify architectures and learning objectives which, subject to these four constraints, would be sufficient to account for both behavior and brain responses.
21
+
22
+ Here, we hypothesize that the latest self-supervised architectures trained on raw sensory data constitute promising candidates [Borgholt et al., 2022, Bardes et al., 2021, Baevski et al., 2020]. We focus on wav2vec 2.0 [Baevski et al., 2020], an architecture that stacks convolutional and transformer layers to predict a quantization of the latent representations of speech waveforms. We train wav2vec 2.0 on $6 0 0 \mathrm { h }$ of effective speech – a quantity roughly comparable to what infants are exposed to during early language acquisition (speech only makes up a small fraction of infants’ daily experience) [Dupoux, 2018, Hart and Risley, 1992, Gilkerson et al., 2017].
23
+
24
+ We use standard encoding analyses [Naselaris et al., 2011, Huth et al., 2016, Yamins and DiCarlo, 2016, Kell et al., 2018] (Figure 1) to compare this model to the brains of 412 healthy volunteers (351 English speakers, 28 French speakers, and 33 Mandarin speakers) recorded with functional magnetic resonance imaging (fMRI) while they passively listened to approximately one hour of audio books in their native language [Nastase et al., 2020, Li et al., 2021] (8.5 hours of distinct audio materials in total).
25
+
26
+ To better understand the similarities between wav2vec 2.0 and the brain, we compare brain activity to each layer of this model, as well as to several variants, namely (1) a random (untrained) wav2vec 2.0 model, (2) a model trained on $6 0 0 \mathrm { h }$ of non-speech sounds, (3) a model trained on $6 0 0 \mathrm { h }$ of nonnative speech (for example, a model trained on English speech and mapped onto the brain responses to French-speaking participants), (4) a model trained on $6 0 0 \mathrm { h }$ of native speech (for example, a model trained on English speech and mapped onto the brain responses to English participants), and (5) a model trained directly on speech-to-text (i.e., a supervised learning scheme) on the native language of the participants.
27
+
28
+ Our results provide four main contributions. First, self-supervised learning leads wav2vec 2.0 to learn latent representations of the speech waveform similar to those of the human brain. Second, the functional hierarchy of its transformer layers aligns with the cortical hierarchy of speech in the brain, and reveals the whole-brain organisation of speech processing with an unprecedented clarity. Third, the auditory-, speech-, and language-specific representations learned by the model converge to those of the human brain. Fourth, behavioral comparisons to 386 supplementary participants’ results on a speech sound discrimination task confirm this common language specialization.
29
+
30
+ # 2 Methods
31
+
32
+ # 2.1 Models
33
+
34
+ We train several variants of wav2vec 2.0 [Baevski et al., 2020] from scratch on different speech datasets using two different learning objectives (a self-supervised and a supervised objective).
35
+
36
+ # 2.1.1 Architecture
37
+
38
+ Wav2vec 2.0 consists of three main modules. First, a feature encoder composed of seven blocks of temporal convolutions (output dimension 512) transforms the speech input $S$ (raw mono waveform at $1 6 \mathrm { k H z } ,$ ) into a latent representation $z$ (output dimension of 512, frequency $4 9 \mathrm { H z }$ , stride of $2 0 \mathrm { m s }$ between each frame, receptive field of $2 5 \mathrm { m s }$ ). Second, a quantization module discretizes $z$ into $q$ , a dictionary of discrete and latent representations of sounds. Third, $z$ is input to a “context network” consisting of 12 transformer blocks (model dimension 768, inner dimension 3072, and 8 attention heads), which together yield a contextualized embedding $c$ , of the same dimensionality of $q$ .
39
+
40
+ ![](images/0108210fe7905a463adbe8dcaff036f14b22834823e153a0740726cd7ec51d03.jpg)
41
+ Figure 1: Comparing speech representations in brains and deep neural networks. A. We analyze the brain activity of 412 participants recorded with functional Magnetic Resonance Imaging (fMRI) while they passively listened to audio books in their native language (French, English or Mandarin). B. After training wav2vec 2.0 [Baevski et al., 2020] with self-supervised learning $( L )$ over $6 0 0 \mathrm { h }$ of unlabelled, effective speech, we extract its activations in response to the audio books that were presented to the participants. We assess the similarity between the activations of the model $X$ and brain activity $Y$ with a standard encoding model $W$ [Nastase et al., 2020] evaluated with a cross-validated Pearson correlation $R$ . C. Examples of the true BOLD response (black) and the predicted BOLD response (red) estimated from a linear projection of the model’s activations in three voxels randomly selected from the $1 0 ^ { t h }$ percentile of best voxels identified by the noise ceiling analysis for the first $2 0 0 \mathrm { s }$ of a representative story in the test set.
42
+
43
+ # 2.1.2 Learning objective
44
+
45
+ Self-supervised learning. In this training paradigm, the model optimizes two losses. The first loss is contrastive and requires the model to predict the quantized representation $q$ of some masked input using $c$ , from a finite set of quantized representations drawn from the input sample. The second loss ensures that the quantized representations are diverse. See Section A.2 and [Baevski et al., 2020] for details.
46
+
47
+ Supervised learning. In this training paradigm, the quantization module is discarded and a linear layer mapping $c$ to phonemes is added at the end of the pipeline. The model is randomly initialized and all layers (including the feature encoder) are trained using a Connectionist Temporal Classification (CTC) [Graves, 2012] loss to perform phone recognition. For both training paradigms, we extract the activations of each layer from both the feature encoder (outputting $z$ ) and the context network (outputting $c$ ). We extract the representations of the convolutional and transformer blocks using an input window of $1 0 \mathrm { s }$ of raw waveform (stride $= 5 \mathrm { s }$ ).
48
+
49
+ # 2.1.3 Training
50
+
51
+ Datasets. We successively train different wav2vec 2.0 models using each of four datasets: (i) the French and (ii) English CommonVoice corpora [Ardila et al., 2020], (iii) the MAGICDATA Mandarin Chinese Read Speech Corpus [Co., 2019], and (iv) a non-speech subset of the Audioset dataset [Gemmeke et al., 2017], which contains recordings of various acoustic scenes.
52
+
53
+ ![](images/a2c62bde7bf5a21d03ea09e776aa663813579eb4b66f32bdc7eb401f27369b53.jpg)
54
+ Figure 2: Self-supervised learning suffices for wav2vec 2.0 to generate brain-like representations of speech. A. Brain score $( R )$ assessed for each subject and voxel independently, and here averaged across subjects for clarity. Only scores significantly above chance level, as assessed using a two-sided Wilcoxon test across subjects after correction for multiple comparison are color-coded $( p < 1 0 ^ { - 1 0 } ,$ ). B. $R$ scores for the same wav2vec2 model, averaged across subjects and voxels in four brain areas typically involved during speech processing (the primary and secondary auditory cortices, the superior temporal gyrus, the superior temporal sulcus, and the infero-frontal gyrus). In grey, the brain score obtained with a randomly initialized wav2vec 2.0 architecture. Error bars are the standard errors of the mean (SEM) across subjects. The stars indicate a significant difference between the random and trained model (all $p < 1 0 ^ { \bar { - } 4 \cdot }$ ). C. $R$ scores of wav2vec 2.0 without training (top), trained with a supervised (middle) and self-supervised learning rule (bottom), on the same 600 hours of effective speech. Scores are averaged across subjects and voxels and error bars are SEM across subjects.
55
+
56
+ Preprocessing. All the audio datasets were randomly subsampled to have an approximate size of 600 hours, downsampled to $1 6 \mathrm { k H z }$ and converted to mono with the Sox software1. We randomly split the datasets into a training $( 8 0 \% )$ , a validation $( 1 0 \% )$ and a test set $( 1 0 \% )$ . The audio recordings we use from the Audioset dataset are filtered so that they do not contain speech or any sounds produced by humans, such as laughter or singing. For the speech datasets, we also use their corresponding annotations (in the supervised settings). We phonemize these annotations using eSpeakNG2. The number of different phoneme symbols in these annotations is similar for French (32), English (39), and Mandarin Chinese (33).
57
+
58
+ Implementation. We train all of our models using the fairseq implementation of wav2vec $2 . 0 ^ { 3 }$ using default hyperparameters. We also analyze a model whose parameters were randomly initialised (“untrained” model).
59
+
60
+ We use self-supervised learning to train four models: three on the speech datasets (French, English, and Mandarin) and one on the acoustic scenes dataset. In each case, the training was performed using the same configuration file (namely, the base configuration provided in the fairseq repository for pretraining wav2vec 2.0 on LibriSpeech [Panayotov et al., 2015]). We train the models for $4 0 0 \mathrm { k }$ updates and select the ones with the best validation loss.
61
+
62
+ We also use the supervised training paradigm to train three models, on the French, English, and Mandarin datasets, respectively. Each training was performed using the same configuration file, which was identical to the configuration provided in the fairseq repository for fine-tuning wav2vec 2.0 on the 960 hour Voxpopuli corpus [Wang et al., 2021], except that parameters were not frozen (freeze_finetune_updates $\ l = \ 0$ ) and learning was performed on all parameters of the models using the CTC loss (feature_grad $\mathtt { m u l t } = 0 . 1$ ). We train the models for $4 0 0 \mathrm { k }$ updates and we use the ones with the best word error rate (WER) on the validation set. The French model obtains 13.9 WER, the English model 28.6 WER, and the Mandarin model 4.6 WER, on their respective test sets.
63
+
64
+ ![](images/dd1bfac5692c34719c32080ed188f83def94de46fa168ed7f54764d58779f37c.jpg)
65
+ Figure 3: The functional hierarchy of wav2vec 2.0 maps onto the speech hierarchy in the brain. A. We compute the $R$ score for each layer of wav2vec 2.0 separately and estimate, for each voxel, the layer with highest brain score on average across subjects. Only the voxels with significant brain scores are displayed $( p < 1 0 ^ { - 1 8 } .$ ). While the first transformer layers (blue) map onto the low-level auditory cortices (A1 and A2), the deeper layers (orange and red) map onto brain regions associated with higher-level processes (e.g. STS and IFG). B. Layer-wise $R$ scores averaged across all voxels. Error bars are SEM across subjects. C. Proportion of voxels with most predictive layer $\mathbf { \dot { x } }$ -axis) in four regions typically involved in speech processing. While most voxels in the primary cortex are best predicted by the first layers of the transformer, higher-level brain areas are best predicted by deeper layers.
66
+
67
+ # 2.2 Functional MRI
68
+
69
+ We analyse a composite set of fMRI recordings aggregated from the Little Prince [Li et al., 2021] and the Narratives public datasets [Nastase et al., 2020].
70
+
71
+ Narratives. This dataset4 contains the fMRI recordings of 345 native English-speaking participants listening to English narratives (4.6 hours of unique audio in total). The participants listened to different stories varying from 7 to $9 8 \mathrm { { m i n } }$ (mean $= 2 6 \mathrm { m i n }$ ). Following [Nastase et al., 2020], we (1) focus on fifteen representative stories and ignore the narratives that have been modified by scrambling and (2) exclude eight participants because of noisy recordings. Overall, this selection results in a curated dataset of 303 participants listening to fifteen stories ranging from 3 min to $5 6 \mathrm { { m i n } }$ , for a total of 4 hours of unique audio (36,018 words from a vocabulary of 4,004 unique words).
72
+
73
+ The Little Prince. This dataset5 contains fMRI recordings of 48 English native speakers, 33 Mandarin native speakers, and 28 French native speakers listening to The Little Prince in their respective native language. The experiment itself was divided into nine runs of approximately $1 0 \mathrm { { m i n } }$ of passive listening. For each language condition, the story was read by a single native speaker. The English, Mandarin, and French audiobooks last 94, 90 and 97 minutes respectively.
74
+
75
+ ![](images/6e054a1d797bef13919978e0b331fba2e5de8e29aa26442c3280a7fa528d64ca.jpg)
76
+ Figure 4: The specialization of wav2vec 2.0’s representations follows and clarifies the acoustic, speech, and language regions in the brain. A. We first evaluate humans’ language specificity by quantifying their ability to perceive phonemes of their native or non-native languages (Section 2.4) in a ABX matching-to-sample task [Schatz, 2016] (higher is better). As expected, humans are better at matching phonemes of their native language. B. Then, we train four wav2vec 2.0 models with self-supervised learning on four datasets – non-speech acoustic scenes, English, and French, and compute their ABX accuracy on the same speech datasets as humans. The ‘random’ model is wav2vec 2.0 without any training. C. Brain score $( R )$ of each model (with an added model trained on Mandarin), averaged across voxels, in four regions of the brain (Section 2.2). D. Acoustic, speech and language specificity for each voxel. For instance, one voxel is considered specific to the ‘native’ model if its native $R$ score is higher than its ‘non-native’ $R$ score $( p < . 0 5 )$ . Only the voxels with significant $R$ scores for the untrained model are displayed $( p < 1 0 ^ { - 1 8 } ,$ ). Error bars are the SEM across phone pairs in A and B, and across subjects in C. The stars indicates a significant difference between two conditions (Section 2.3).
77
+
78
+ Preprocessing. For Narratives, we did not perform additional preprocessing: we use the public preprocessing of the dataset already projected on the surface space (“fsaverage6”) without spatial smoothing (labelled “afni-nosmooth” in the data repository). In contrast, the Little Prince dataset is only provided in a volumetric space. Consequently, for each language condition separately, we subselected the cortical voxels by computing a brain mask using the average of all participants’ fMRI data realigned onto a common template brain via Freesurfer [Fischl, 2012]. These voxels are then projected onto a brain surface using nilearn’s vol_to_surf function with defaults parameters [Abraham et al., 2014] and a ‘fsaverage6‘ template surface [Fischl, 2012]. For both Narratives and The Little Prince, fMRI signals are normalized across the time dimension to have a mean of 0 and a variance of 1, for each participant, surface voxel and session independently.
79
+
80
+ Brain parcellation. For the purposes of certain analyses, we group the fMRI voxels into regions of interest using the Destrieux Atlas [Destrieux et al., 2010]. This parcellation results in 75 brain regions in each hemisphere. For simplicity, we label the regions as follows: A1 and A2 represents Heschl gyrus, which is the anatomical location of the primary and secondary auditory cortices, STG and STS are the superior temporal gyrus and sulcus, and IFG is the inferior frontal gyrus.
81
+
82
+ # 2.3 Brain score (R)
83
+
84
+ To quantify the similarity between the network’s activations $X$ and the brain recordings $Y$ , we use a standard linear encoding model [Huth et al., 2016, Yamins and DiCarlo, 2016]. For each subject, we split the data into train and test sets using a five-fold cross-validation setting. For each train split, a linear mapping $W$ is fitted to predict the brain response $Y _ { \mathrm { t r a i n } }$ given $X _ { \mathrm { t r a i n } }$ . $W$ combines a temporal alignment function with fixed weight, and a trained penalized linear regression.
85
+
86
+ Temporal alignment. The sampling frequency of the model’s activations (between 49 and $2 0 0 \mathrm { H z }$ ) differs from the sampling frequency of fMRI BOLD signals $( 0 . 5 \mathrm { H z } )$ . Furthermore, the BOLD signals have delayed responses spanning over several seconds. Thus, we first convolve the model activations with a standard hemodynamic response function (HRF) using nistats [Abraham et al., 2014] compute_regressor function with the ‘glover’ model and default parameters. This results in the convolved activations $X _ { \mathrm { t r a i n } } ^ { \prime }$ with the same sampling frequency as the fMRI $Y _ { \mathrm { t r a i n } }$ (see A.3).
87
+
88
+ Penalised linear regression. Once temporally aligned, we fit an $\ell _ { 2 }$ -penalised linear regression that predicts the brain signals $Y _ { \mathrm { t r a i n } }$ given the activations $X _ { \mathrm { t r a i n } }$ . We use the RidgeCV function from scikit-learn [Pedregosa et al., 2011], with the penalization hyperparameter $\lambda$ varying between 10 and $1 0 ^ { 8 }$ (20 values scaled logarithmically) chosen independently for each dimension with a nested cross-validation over the training set (see A.4).
89
+
90
+ Evaluation. We evaluate the linear mapping $W$ on the held out sets by measuring Pearson’s correlation between predicted and actual brain responses: $R = \mathrm { c o r r } \big ( Y _ { \mathrm { t e s t } } , \mathbf { \bar { W } } \cdot X _ { \mathrm { t e s t } } \big )$ . Finally, we average the correlation scores across test splits to obtain the final “brain score”. To report the average layer $k ^ { * }$ with the highest brain score for each voxel (Figure 3), while being robust to regressionto-the-mean biases, we first find the best layer $k _ { s }$ for each participant $s$ and each voxel independently and then compute a circular mean across the $N = 4 1 2$ participants and the $K = 1 9$ layers: $\begin{array} { r } { k ^ { * } = \mathrm { a n g l e } \left( \frac { 1 } { N } \sum _ { s = 1 } ^ { N } \exp \left( \frac { 2 i \pi k _ { s } } { K + 1 } \right) \right) } \end{array}$
91
+
92
+ Statistics. We assess the reliability of brain scores with second-level analyses across participants thanks to a Wilcoxon signed-rank test across participants. Thus, the resulting p-values are not affected by fMRI auto-correlation within participants. We perform statistical correction for multiple comparisons with Benjamini–Hochberg False Discovery Rate (FDR) across voxels [Benjamini, 2010].
93
+
94
+ # 2.4 Behavioral experiment
95
+
96
+ To compare the phonetic representations of our models to those of humans, we compare the forcedchoice discrimination judgements of online participants6 to an analogous method applied to wav2vec 2.0 [Schatz, 2016]. Specifically, for each triplet of sound “ABX”, participants judged whether the stimulus X was more similar to A or B. Analogously, we computed the Euclidean distance in the most discriminative layer of wav2vec 2.0 (here transformer layer 5) to determine whether X was closer to A or B. Additional data, analyses and model-human comparison can be found in [Millet and Dunbar, 2022]. We focus on the French and English stimuli, which represent $\approx 6 { , } 0 0 0$ ABX triplets (testing 508 English and 524 French phone pairs), with 386 participants in total (193 from each language group).
97
+
98
+ In Figure 4-A, we report the ABX accuracy of English- and French-speaking participants in both their native and non-native language (either English or French). We first average results per phone pair, and then average over phone pairs to obtain the ABX discrimination accuracy. Similarly, in Figure 4-B, we compute the ABX accuracy of our wav2vec 2.0 models on the same evaluation sets as the participants, using the parameters described in [Millet and Dunbar, 2022]. English and French models are evaluated on the same (‘native’) or different (‘non-native’) language stimuli as their training. The random and non-speech models are evaluated on both French and English speech stimuli.
99
+
100
+ # 3 Results
101
+
102
+ Wav2vec 2.0 maps onto brain responses to speech. We estimate whether the activations of wav2vec 2.0 models linearly map onto the human brain activity of 412 individuals listening to audio books in the fMRI scanner. For this, we first independently train three models with $6 0 0 \mathrm { h }$ of
103
+
104
+ French, English, or Mandarin, respectively, and compute the brain scores $( R )$ with the corresponding participants. Specifically, we (1) convolve the activations $( X )$ of the model with a hemodynamic response function (HRF), (2) train a $\ell _ { 2 }$ -penalized linear regression on a training split to map them to brain activity $Y$ , and (3) compute the Pearson correlation coefficient between (i) the true fMRI activity and (ii) the predicted activations on a test split. The models’ activations significantly predict brain activity in nearly all cortical areas, reaching the highest $R$ scores in the primary and secondary auditory cortices (Figure 2-A B). These scores are significantly higher than those obtained with a randomly initialised model $( p < 1 0 ^ { - 5 0 }$ on average across voxels), and this comparison is robust across language groups (all $p < 1 0 ^ { - 5 } .$ ).
105
+
106
+ Comparison of self-supervised to supervised models. Does self-supervision reach representations that are as brain-like as those obtained with supervised learning? To address this issue, we trained wav2vec 2.0 with an alternative, supervised objective, namely, predicting phonetic annotations from the same 600 hours of effective speech sounds. We then implemented the $R$ score analyses described above. The results show that self-supervised learning in fact leads to modestly but significantly better $R$ scores than supervised learning (Figure 2-C): $\Delta R = 0 . 0 0 2 , p < 1 0 ^ { 6 }$ .
107
+
108
+ The hierarchy of wav2vec 2.0 maps onto the hierarchy of the cortex. To compare the speech hierarchy in the brain with the functional hierarchy learned by wav2vec 2.0, we evaluate the $R$ score of each layer of the model (Figure 3). First, we observe that convolutional layers are less predictive than transformer layers. Second, within the transformers, the hierarchy of representations aligns with the expected cortical hierarchy [Hickok and Poeppel, 2007]: while low-level areas (A1, A2) are best predicted by the first transformer layers, higher level areas (IFG, STS) are best predicted by deeper layers. Remarkably, this hierarchy extends to supplementary motor and motor areas in both hemispheres (Figure 3-A).
109
+
110
+ Language specificity in phone discrimination tasks. The acoustic features underlying speech (fricatives, vowels, and so on) may also characterize non-speech sounds (the sound of tree leaves in the wind, of a stone falling, and so on). Does the model show commonalities merely with general auditory processing in the brain, or does it capture speech-specific processing? If so, does it show commonalities with brain representations that are specific to the native language of the participants, or merely to general speech processing? We first evaluate the specialization of humans’ perception to their native language using an ABX behavioral task (Section 2.4). Specifically, we compare 386 French and English participants on their ability to distinguish native and non-native phones. As expected [Bohn, 2017, Kuhl et al., 2005], participants were better at discriminating native sounds than non-native ones (across phone pairs: $\dot { p } < 1 0 ^ { - 1 8 }$ , Figure 4-A). Second, applying the same test to our self-supervised French and English models shows that, like humans, models best discriminate sounds from their ‘native’ language (i.e., the French model better distinguishes French stimuli than English ones, across phone pairs, and vice versa: $p < 0 . 0 5 )$ . Interestingly, the ABX accuracy of the model is significantly higher than participants’. This quantitative difference may be partially explained by the fact that participants – and online participants in particular – undergo fluctuating attention, and adopt strategies which can negatively impact performance [Humphreys, 1939]. Finally, as expected, the random and acoustic models obtain the worst ABX accuracy. Overall, These results confirm that $6 0 0 \mathrm { h }$ of self-supervised learning on effective speech suffices for wav2vec 2.0 to learn language-specific representations (Figure 4-B).
111
+
112
+ Wav2vec 2.0 and the brain learn language specific representations. Next, we compare the brain scores of random, non-speech, non-native and native models (Figure 4-C D). First, our results show that the non-speech model attains higher $R$ scores than the random model (on average across voxels, $\Delta R = 0 . 0 0 6$ , $p = 1 0 ^ { - 3 1 }$ ) confirming the importance of learning to generate brainlike representations. Second, non-native models attain higher $R$ scores than the non-speech model $( \Delta R \bar { = } ~ 0 . 0 0 2 , p = 1 0 ^ { - 9 } )$ ), confirming that wav2vec 2.0 learns speech-specific representations of sounds when trained on speech. Finally, the native model attains higher $R$ scores than non-native models $( \Delta R = 0 . 0 0 2 , p \stackrel { - } { = } 1 0 ^ { - 1 5 } )$ .
113
+
114
+ # 4 Discussion
115
+
116
+ Human infants acquire language with little to no supervision: A few hundred hours of speech suffices for their young brain to learn to discretize phonemes, segment morphemes, and assemble words in the language(s) of their social group [Dupoux, 2018, Gilkerson et al., 2017]. However, the learning principle that allows this unique feat remains, to date, unknown.
117
+
118
+ Here, we test whether self-supervised learning applied to a limited amount of speech effectively accounts for the organization of speech processing in the human brain as measured with fMRI. For this, we train several variants of wav2vec 2.0 [Baevski et al., 2020] with three curated datasets of French, English, and Mandarin, and compare their activations to those of a large group of French, English, and Mandarin speakers recorded with fMRI while passively listening to audio stories. Our results show that this self-supervised model learns (i) representations that linearly map onto a remarkably distributed set of cortical regions (Figure 2), (ii) a computational hierarchy that aligns with the cortical hierarchy (Figure 3), and (iii) features specific to the language of the participants (Figure 4).
119
+
120
+ Towards a biologically-plausible learning principle. These results extend recent findings on the similarities between the brain and a variety of deep learning models trained with biologicallyimplausible objectives and data. First, fMRI [Kell et al., 2018, Millet and King, 2021, Thompson et al., 2021], electroencephalography [Huang et al., 2018], and multi- or single-unit responses to sounds [Koumura et al., 2019, Begus et al., 2022] have been shown to be linearly predicted by the activations of deep convolutional networks trained on supervised auditory tasks. For example, [Millet and King, 2021] showed that a supervised speech-to-text model better accounted for brain responses to speech in 102 individuals when it was trained on speech recognition rather than auditory scene classification. Similarly, [Kell et al., 2018] showed that eight participants listening to brief speech and non-speech sounds demonstrated fMRI responses in the temporal lobe that aligned with those of a deep convolutional neural network trained on a binary auditory classification task. Our results, based on up to 50 times more fMRI recordings of the entire cortex show that such representational similarities hold with a self-supervised objective [Lerner et al., 2011, Berezutskaya et al., 2017, Caucheteux et al., 2021c,b]. Second, a growing series of MEG [Toneva and Wehbe, 2019, Caucheteux and King, 2022], fMRI [Mitchell et al., 2008, Qian et al., 2016, Pereira et al., 2018, Schwartz et al., 2019, Antonello et al., 2021, Jain and Huth, 2018] and electro-physiology studies [Schrimpf et al., 2021, Goldstein et al., 2022] showed that text-based language models trained on very large corpora generate brain-like representations too. While these results suggest elements of convergence between language models and the brain [Caucheteux and King, 2022], they also remain biologically implausible: not only are these algorithms pre-equipped with abstract linguistic units such as characters and words, but they are trained on corpora that no one would ever be able to read in their lifetime. In contrast, wav2vec 2.0 is here trained with a reasonable amount of raw speech waveforms [Hart and Risley, 1992, Gilkerson et al., 2017, Dupoux, 2018]. The functional similarity between wav2vec 2.0 and the brain thus opens the way to clarify how humans learn to process speech.
121
+
122
+ The emergence of a brain-like hierarchy of speech processing. The present study reveals the hierarchical organization of speech processing with remarkable clarity. First, the functional hierarchy learnt by wav2vec 2.0 is aligned with the anatomy: e.g. the superior temporal sulcus and the temporal pole are known to project to the ventral and dorsal part of the inferofrontal gyrus, respectively [Petkov et al., 2015]. Second, the identification of functional gradients within the prefrontal cortex, and down to the motor areas typically associated with larynx and mouth control [Dichter et al., 2018] reinforces the relevance of motor processes to speech perception [Kellis et al., 2010, Mugler et al., 2014, Shamma et al., 2021]. Finally, the existence of multiple levels of representations around the inferofrontal cortex is consistent with the idea that Broca’s area may be responsible for merging linguistic units [Chomsky, 2000, Friederici, 1999, Hagoort, 2005, Poeppel et al., 2012]. It should be noted, however, that our results aggregate a large cohort of individuals which could mask a more modular organization at the individual level.
123
+
124
+ Interpreting the neural representations of speech. Interpreting neural representations is a notoriously difficult challenge to both AI and neuroscience. Here, we first investigate language specificity and show that the neural representations specific to the native models are primarily represented in the superior temporal sulcus and middle temporal gyrus (Figure 4D): areas known to represent phonetic features [Mesgarani et al., 2014]. However, these effect are relatively modest (Figure 4): the random model and the non-speech model reach, in STS and STG, $67 \%$ and $87 \%$ of the brain scores obtained by the “native” model, respectively. While this high baseline initially surprised us, this phenomenon could be explained by the fact that the auditory cortex is continuously bombarded by – and should thus be tuned to – non-speech input. Second, our probing analyses show that the models trained with self-supervised learning learn relevant acoustic and linguistic representations (Supplementary Figure S1). This result, consistent with Vaidya et al. [2022] and Stephenson et al. [2019], suggests that the difference of brain scores observed between the random, non-native and native models (Figure 4) may be partly driven by the corresponding spectro-temporal, phonetic, word and sentence-level representations, respectively. These elements of interpretation remain, however, scarce, and a systematic interpretation of the representations shared between wav2vec 2.0 and the brain remains necessary.
125
+
126
+ Scope of the study. It is important to stress that the scope of the present study could be broadened in several ways. First, our study focuses on adult speakers, whose cultural and educational background is not representative of the population [Henrich et al., 2010]. Second, we focus on the passive listening of three languages. Third, we focus on one self-supervised learning architecture [Baevski et al., 2020], and its functional alignment with fMRI, whose temporal resolution is notoriously limited. Generalizing the present approach to more languages [Malik-Moraleda et al., 2022], a larger spectrum of children and adult participants recorded with a variety of electrophysiological and neuroimaging devices will thus be essential to confirm, precise, and/or mitigate the present findings.
127
+
128
+ The remaining gap between brain and speech models. Several major gaps can be evidenced between wav2vec 2.0 and the brain. First, the transformer layers are not temporally constrained: each layer can access all elements within the contextual window. This differs from the necessarily recurrent nature of processing in the brain. Second, wav2vec 2.0 behaves differently to humans in specific tasks. In particular, it is overly-sensitive to band-pass filtering, non-robustly exploit fine temporal structures [Weerts et al., 2021] and fails to display the expected categorical responses [Millet et al., 2021]. Third, recent studies show that wav2vec 2.0 encodes significantly less semantic information than text-based models [Pasad et al., 2021, Vaidya et al., 2022]. While our analyses suggest that learning allows wav2vec 2.0 to capture some lexical features in its deep layers (Figure S1, Table S4), it remains unclear whether these layers also capture complex syntactic structures, such as recursive syntactic trees [Lakretz et al., 2021, Caucheteux et al., 2021a]. We speculate that these limitations may be due to the time scales of wav2vec 2.0 which, unlike humans, learns very short-term representations of speech. In any case, these differences likely explain why the brain scores of wav2vec 2.0 remain substantially lower than our noise-ceiling ( $1 9 \%$ on average, and up to $74 \%$ in Heschl’s gyrus and sulcus, Table S1, Figure S2).
129
+
130
+ Overall, the complexity of the human brain is often thought to be incompatible with a simple theory: “Even if there were enough data available about the contents of each brain area, there probably would not be a ready set of equations to describe them, their relationships, and the ways they change over time” [Gallant, 2013]. By showing how the equations of self-supervised learning give rise to brain-like processes, this work contributes to challenge this view.
131
+
132
+ # Acknowledgments
133
+
134
+ This project was funded, in part, by the Bettencourt-Schueller Foundation, the Philippe Foundation, and FrontCog grant ANR-17-EURE-0017 to JRK for his work at PSL.
135
+
136
+ # References
137
+
138
+ Alexandre Abraham, Fabian Pedregosa, Michael Eickenberg, Philippe Gervais, Andreas Mueller, Jean Kossaifi, Alexandre Gramfort, Bertrand Thirion, and Gaël Varoquaux. Machine learning for neuroimaging with scikit-learn. Frontiers in neuroinformatics, 8:14, 2014.
139
+
140
+ Richard Antonello, Javier S Turek, Vy Vo, and Alexander Huth. Low-dimensional structure in the space of language representations is reflected in brain responses. Advances in Neural Information Processing Systems, 34, 2021.
141
+
142
+ Rosana Ardila, Megan Branson, Kelly Davis, Michael Kohler, Josh Meyer, Michael Henretty, Reuben Morais, Lindsay Saunders, Francis M Tyers, and Gregor Weber. Common voice: A massively-multilingual speech corpus. In LREC, 2020.
143
+
144
+ Alexei Baevski, H. Zhou, Abdel rahman Mohamed, and Michael Auli. wav2vec 2.0: A framework for self-supervised learning of speech representations. ArXiv, abs/2006.11477, 2020.
145
+
146
+ Adrien Bardes, Jean Ponce, and Yann LeCun. Vicreg: Variance-invariance-covariance regularization for self-supervised learning. arXiv preprint arXiv:2105.04906, 2021.
147
+
148
+ Gasper Begus, Alan Zhou, and Christina Zhao. Encoding of speech in convolutional layers and the brain stem based on language experience. bioRxiv, 2022.
149
+
150
+ Yoav Benjamini. Discovering the false discovery rate. Journal of the Royal Statistical Society: series $B$ (statistical methodology), 72(4):405–416, 2010.
151
+
152
+ Julia Berezutskaya, Zachary V Freudenburg, Umut Güçlü, Marcel AJ van Gerven, and Nick F Ramsey. Neural tuning to low-level features of speech throughout the perisylvian cortex. Journal of Neuroscience, 37(33):7906–7920, 2017.
153
+
154
+ Ocke-Schwen Bohn. Cross-language and second language speech perception. The handbook of psycholinguistics, pages 213–239, 2017.
155
+
156
+ Lasse Borgholt, Jakob Drachmann Havtorn, Joakim Edin, Lars Maaløe, and Christian Igel. A brief overview of unsupervised neural speech representation learning. arXiv preprint arXiv:2203.01829, 2022.
157
+
158
+ Charlotte Caucheteux and Jean-Rémi King. Brains and algorithms partially converge in natural language processing. Communications Biology, 5(1):1–10, 2022.
159
+
160
+ Charlotte Caucheteux, Alexandre Gramfort, and Jean-Remi King. Disentangling syntax and semantics in the brain with deep networks. In Proceedings of the 38th International Conference on Machine Learning, pages 1336–1348. PMLR, July 2021a. ISSN: 2640-3498.
161
+
162
+ Charlotte Caucheteux, Alexandre Gramfort, and Jean-Remi King. Long-range and hierarchical language predictions in brains and algorithms. arXiv:2111.14232 [cs, q-bio], November 2021b. arXiv: 2111.14232.
163
+
164
+ Charlotte Caucheteux, Alexandre Gramfort, and Jean-Remi King. Model-based analysis of brain activity reveals the hierarchy of language in 305 subjects. In Findings of the Association for Computational Linguistics: EMNLP 2021, pages 3635–3644, Punta Cana, Dominican Republic, November 2021c. Association for Computational Linguistics.
165
+
166
+ Charlotte Caucheteux, Alexandre Gramfort, and Jean-Rémi King. Deep language algorithms predict semantic comprehension from brain activity. Scientific Reports, 12(1):16327, September 2022. ISSN 2045-2322. doi: 10.1038/s41598-022-20460-9. Number: 1 Publisher: Nature Publishing Group.
167
+
168
+ Noam Chomsky. Linguistics and brain science. Image, language, brain, pages 13–28, 2000.
169
+
170
+ Radoslaw M Cichy and Daniel Kaiser. Deep neural networks as scientific models. Trends in cognitive sciences, 23(4):305–317, 2019.
171
+
172
+ Beijing Magic Data Technology Co. Magic data chinese mandarin conversational speech. http://www.imagicdatatech.com/index.php/home/dataopensource/data_ info/id/101, 2019.
173
+
174
+ Christophe Destrieux, Bruce Fischl, Anders Dale, and Eric Halgren. Automatic parcellation of human cortical gyri and sulci using standard anatomical nomenclature. NeuroImage, 53(1):1–15, October 2010. ISSN 1053-8119. doi: 10.1016/j.neuroimage.2010.06.010.
175
+
176
+ Benjamin K Dichter, Jonathan D Breshears, Matthew K Leonard, and Edward F Chang. The control of vocal pitch in human laryngeal motor cortex. Cell, 174(1):21–31, 2018.
177
+
178
+ Emmanuel Dupoux. Cognitive science in the era of artificial intelligence: A roadmap for reverseengineering the infant language-learner. Cognition, 173:43–59, 2018.
179
+
180
+ Bruce Fischl. Freesurfer. Neuroimage, 62(2):774–781, 2012.
181
+
182
+ Angela D Friederici. The neurobiology of language comprehension. In Language comprehension: A biological perspective, pages 265–304. Springer, 1999.
183
+
184
+ Jack Gallant. in ’reading minds’. Nature, 502(7472):428, 2013.
185
+
186
+ Jort F Gemmeke, Daniel PW Ellis, Dylan Freedman, Aren Jansen, Wade Lawrence, R Channing Moore, Manoj Plakal, and Marvin Ritter. Audio set: An ontology and human-labeled dataset for audio events. In 2017 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP), pages 776–780. IEEE, 2017.
187
+
188
+ Jill Gilkerson, Jeffrey A Richards, Steven F Warren, Judith K Montgomery, Charles R Greenwood, D Kimbrough Oller, John HL Hansen, and Terrance D Paul. Mapping the early language environment using all-day recordings and automated analysis. American journal of speech-language pathology, 26(2):248–265, 2017.
189
+
190
+ Ariel Goldstein, Zaid Zada, Eliav Buchnik, Mariano Schain, Amy Price, Bobbi Aubrey, Samuel A Nastase, Amir Feder, Dotan Emanuel, Alon Cohen, et al. Shared computational principles for language processing in humans and deep language models. Nature neuroscience, 25(3):369–380, 2022.
191
+
192
+ Alex Graves. Connectionist temporal classification. In Supervised Sequence Labelling with Recurrent Neural Networks, pages 61–93. Springer, 2012.
193
+
194
+ Peter Hagoort. On broca, brain, and binding: a new framework. Trends in cognitive sciences, 9(9): 416–423, 2005.
195
+
196
+ Betty Hart and Todd R Risley. American parenting of language-learning children: Persisting differences in family-child interactions observed in natural home environments. Developmental psychology, 28(6):1096, 1992.
197
+
198
+ Joseph Henrich, Steven J. Heine, and Ara Norenzayan. The weirdest people in the world? Behavioral and Brain Sciences, 33(2-3):61–83, June 2010. ISSN 0140-525X, 1469-1825. doi: 10.1017/S0140525X0999152X.
199
+
200
+ Gregory Hickok and David Poeppel. The cortical organization of speech processing. Nature reviews neuroscience, 8(5):393–402, 2007.
201
+
202
+ Nicholas Huang, Malcolm Slaney, and Mounya Elhilali. Connecting deep neural networks to physical, perceptual, and electrophysiological auditory signals. Frontiers in neuroscience, 12:532, 2018.
203
+
204
+ L. G. Humphreys. Acquisition and extinction of verbal expectations in a situation analogous to conditioning. Journal of Experimental Psychology, 25:294–301, 1939. ISSN 0022-1015. doi: 10.1037/h0053555. Place: US Publisher: American Psychological Association.
205
+
206
+ Alexander G. Huth, Wendy A. de Heer, Thomas L. Griffiths, Frédéric E. Theunissen, and Jack L. Gallant. Natural speech reveals the semantic maps that tile human cerebral cortex. Nature, 532 (7600):453–458, April 2016. ISSN 0028-0836, 1476-4687. doi: 10.1038/nature17637.
207
+
208
+ Shailee Jain and Alexander Huth. Incorporating context into language encoding models for fmri. Advances in neural information processing systems, 31, 2018.
209
+
210
+ Alexander JE Kell and Josh H McDermott. Deep neural network models of sensory systems: windows onto the role of task constraints. Current opinion in neurobiology, 55:121–132, 2019.
211
+
212
+ Alexander JE Kell, Daniel LK Yamins, Erica N Shook, Sam V Norman-Haignere, and Josh H McDermott. A task-optimized neural network replicates human auditory behavior, predicts brain responses, and reveals a cortical processing hierarchy. Neuron, 98(3):630–644, 2018.
213
+
214
+ Spencer Kellis, Kai Miller, Kyle Thomson, Richard Brown, Paul House, and Bradley Greger. Decoding spoken words using local field potentials recorded from the cortical surface. Journal of neural engineering, 7(5):056007, 2010.
215
+
216
+ Tim C Kietzmann, Patrick McClure, and Nikolaus Kriegeskorte. Deep neural networks in computational neuroscience. BioRxiv, page 133504, 2018.
217
+
218
+ Takuya Koumura, Hiroki Terashima, and Shigeto Furukawa. Cascaded tuning to amplitude modulation for natural sound recognition. Journal of Neuroscience, 39(28):5517–5533, 2019.
219
+
220
+ Nikolaus Kriegeskorte. Deep neural networks: a new framework for modeling biological vision and brain information processing. Annual review of vision science, 1:417–446, 2015.
221
+
222
+ Patricia K Kuhl, Barbara T Conboy, Denise Padden, Tobey Nelson, and Jessica Pruitt. Early speech perception and later language development: Implications for the" critical period". Language learning and development, 1(3-4):237–264, 2005.
223
+
224
+ Yair Lakretz, Théo Desbordes, Jean-Rémi King, Benoît Crabbé, Maxime Oquab, and Stanislas Dehaene. Can RNNs learn Recursive Nested Subject-Verb Agreements? arXiv:2101.02258 [cs], January 2021. URL http://arxiv.org/abs/2101.02258. arXiv: 2101.02258.
225
+
226
+ Y. Lerner, C. J. Honey, L. J. Silbert, and U. Hasson. Topographic Mapping of a Hierarchy of Temporal Receptive Windows Using a Narrated Story. Journal of Neuroscience, 31(8):2906– 2915, February 2011. ISSN 0270-6474, 1529-2401. doi: 10.1523/JNEUROSCI.3684-10.2011.
227
+
228
+ Jixing Li, Shohini Bhattasali, Shulin Zhang, Berta Franzluebbers, Wen-Ming Luh, R Nathan Spreng, Jonathan R Brennan, Yiming Yang, Christophe Pallier, and John T Hale. Le petit prince: A multilingual fmri corpus using ecological stimuli. bioRxiv, 2021.
229
+
230
+ Saima Malik-Moraleda, Dima Ayyash, Jeanne Gallée, Josef Affourtit, Malte Hoffmann, Zachary Mineroff, Olessia Jouravlev, and Evelina Fedorenko. An investigation across 45 languages and 12 language families reveals a universal language network. Nature Neuroscience, 25(8):1014– 1019, August 2022. ISSN 1546-1726. doi: 10.1038/s41593-022-01114-5. Number: 8 Publisher: Nature Publishing Group.
231
+
232
+ Nima Mesgarani, Connie Cheung, Keith Johnson, and Edward F. Chang. Phonetic Feature Encoding in Human Superior Temporal Gyrus. Science, 343(6174):1006–1010, February 2014. ISSN 0036-8075, 1095-9203. doi: 10.1126/science.1245994. Publisher: American Association for the Advancement of Science Section: Report.
233
+
234
+ Juliette Millet and Ewan Dunbar. Do self-supervised speech models develop human-like perception biases? AAAI 2022 Workshop, Self-Supervised Learning for Audio and Speech Processing, 2022.
235
+
236
+ Juliette Millet and Jean-Remi King. Inductive biases, pretraining and fine-tuning jointly account for brain responses to speech. arXiv preprint arXiv:2103.01032, 2021.
237
+
238
+ Juliette Millet, Ioana Chitoran, and Ewan Dunbar. Predicting non-native speech perception using the perceptual assimilation model and state-of-the-art acoustic models. In Proceedings of the 25th Conference on Computational Natural Language Learning, pages 661–673, Online, November 2021. Association for Computational Linguistics. doi: 10.18653/v1/2021.conll-1.51.
239
+
240
+ Tom M Mitchell, Svetlana V Shinkareva, Andrew Carlson, Kai-Min Chang, Vicente L Malave, Robert A Mason, and Marcel Adam Just. Predicting human brain activity associated with the meanings of nouns. science, 320(5880):1191–1195, 2008.
241
+
242
+ Emily M Mugler, James L Patton, Robert D Flint, Zachary A Wright, Stephan U Schuele, Joshua Rosenow, Jerry J Shih, Dean J Krusienski, and Marc W Slutzky. Direct classification of all american english phonemes using signals from functional speech motor cortex. Journal of neural engineering, 11(3):035015, 2014.
243
+
244
+ Thomas Naselaris, Kendrick N Kay, Shinji Nishimoto, and Jack L Gallant. Encoding and decoding in fmri. Neuroimage, 56(2):400–410, 2011.
245
+
246
+ Samuel A Nastase, Yun-Fei Liu, Hanna Hillman, Asieh Zadbood, Liat Hasenfratz, Neggin Keshavarzian, Janice Chen, Christopher J Honey, Yaara Yeshurun, Mor Regev, et al. Narratives: fmri data for evaluating models of naturalistic language comprehension. preprint. Neuroscience, December, pages 2020–06, 2020.
247
+
248
+ Vassil Panayotov, Guoguo Chen, Daniel Povey, and Sanjeev Khudanpur. Librispeech: an asr corpus based on public domain audio books. In 2015 IEEE international conference on acoustics, speech and signal processing (ICASSP), pages 5206–5210. IEEE, 2015.
249
+
250
+ Ankita Pasad, Ju-Chieh Chou, and Karen Livescu. Layer-wise analysis of a self-supervised speech representation model. arXiv preprint arXiv:2107.04734, 2021.
251
+
252
+ Fabian Pedregosa, Gaël Varoquaux, Alexandre Gramfort, Vincent Michel, Bertrand Thirion, Olivier Grisel, Mathieu Blondel, Peter Prettenhofer, Ron Weiss, Vincent Dubourg, et al. Scikit-learn: Machine learning in python. the Journal of machine Learning research, 12:2825–2830, 2011.
253
+
254
+ Francisco Pereira, Bin Lou, Brianna Pritchett, Samuel Ritter, Samuel J Gershman, Nancy Kanwisher, Matthew Botvinick, and Evelina Fedorenko. Toward a universal decoder of linguistic meaning from brain activation. Nature communications, 9(1):1–13, 2018.
255
+
256
+ Christopher I. Petkov, Yukiko Kikuchi, Alice E. Milne, Mortimer Mishkin, Josef P. Rauschecker, and Nikos K. Logothetis. Different forms of effective connectivity in primate frontotemporal pathways. Nature Communications, 6(1):6000, January 2015. ISSN 2041-1723. doi: 10.1038/ ncomms7000. Number: 1 Publisher: Nature Publishing Group.
257
+
258
+ David Poeppel, Karen Emmorey, Gregory Hickok, and Liina Pylkkänen. Towards a new neurobiology of language. Journal of Neuroscience, 32(41):14125–14131, 2012.
259
+
260
+ Peng Qian, Xipeng Qiu, and Xuanjing Huang. Bridging lstm architecture and the neural dynamics during reading. arXiv preprint arXiv:1604.06635, 2016.
261
+
262
+ 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.
263
+
264
+ Thomas Schatz. ABX-discriminability measures and applications. PhD thesis, Université Paris 6 (UPMC), 2016.
265
+
266
+ Martin Schrimpf, Idan Asher Blank, Greta Tuckute, Carina Kauf, Eghbal A Hosseini, Nancy Kanwisher, Joshua B Tenenbaum, and Evelina Fedorenko. The neural architecture of language: Integrative modeling converges on predictive processing. Proceedings of the National Academy of Sciences, 118(45), 2021.
267
+
268
+ Dan Schwartz, Mariya Toneva, and Leila Wehbe. Inducing brain-relevant bias in natural language processing models. Advances in neural information processing systems, 32, 2019.
269
+
270
+ Shihab Shamma, Prachi Patel, Shoutik Mukherjee, Guilhem Marion, Bahar Khalighinejad, Cong Han, Jose Herrero, Stephan Bickel, Ashesh Mehta, and Nima Mesgarani. Learning speech production and perception through sensorimotor interactions. Cerebral cortex communications, 2(1): tgaa091, 2021.
271
+
272
+ Cory Stephenson, Jenelle Feather, Suchismita Padhy, Oguz Elibol, Hanlin Tang, Josh McDermott, and SueYeon Chung. Untangling in invariant speech recognition. Advances in neural information processing systems, 32, 2019.
273
+
274
+ Jessica AF Thompson, Yoshua Bengio, Elia Formisano, and Marc Schönwiesner. Training neural networks to recognize speech increased their correspondence to the human auditory pathway but did not yield a shared hierarchy of acoustic features. bioRxiv, 2021.
275
+
276
+ Mariya Toneva and Leila Wehbe. Interpreting and improving natural-language processing (in machines) with natural language-processing (in the brain). arXiv:1905.11833 [cs, q-bio], November 2019. arXiv: 1905.11833.
277
+
278
+ Aditya R Vaidya, Shailee Jain, and Alexander G Huth. Self-supervised models of audio effectively explain human cortical responses to speech. arXiv preprint arXiv:2205.14252, 2022.
279
+
280
+ Changhan Wang, Morgane Riviere, Ann Lee, Anne Wu, Chaitanya Talnikar, Daniel Haziza, Mary Williamson, Juan Pino, and Emmanuel Dupoux. Voxpopuli: A large-scale multilingual speech corpus for representation learning, semi-supervised learning and interpretation. arXiv preprint arXiv:2101.00390, 2021.
281
+
282
+ Lotte Weerts, Stuart Rosen, Claudia Clopath, and Dan FM Goodman. The psychometrics of automatic speech recognition. bioRxiv, 2021.
283
+
284
+ Qiantong Xu, Alexei Baevski, Tatiana Likhomanenko, Paden Tomasello, Alexis Conneau, Ronan Collobert, Gabriel Synnaeve, and Michael Auli. Self-training and Pre-training are Complementary for Speech Recognition, October 2020. arXiv:2010.11430 [cs, eess].
285
+
286
+ Daniel LK Yamins and James J DiCarlo. Using goal-driven deep learning models to understand sensory cortex. Nature neuroscience, 19(3):356–365, 2016.
287
+
288
+ # Checklist
289
+
290
+ 1. For all authors...
291
+
292
+ (a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes] See Section 3
293
+ (b) Did you describe the limitations of your work? [Yes] See Section 4
294
+ (c) Did you discuss any potential negative societal impacts of your work? [N/A]
295
+ (d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes] We have, and since we use results of human experiments that were previously made, and that respect these review guidelines, we conform to them.
296
+
297
+ 2. If you are including theoretical results...
298
+
299
+ (a) Did you state the full set of assumptions of all theoretical results? [N/A] No theoretical results (b) Did you include complete proofs of all theoretical results? [N/A] No theoretical results
300
+
301
+ 3. If you ran experiments...
302
+
303
+ (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 code will be provided upon request. Otherwise for the rest, see Section 2.2 and 2.1.3
304
+ (b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes] See Section 2.1.3.
305
+ (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [Yes] This is the case for all our figures, see Figure 2, 3 and 4
306
+ (d) Did you include the total amount of compute and the type of resources used (e.g., type of GPUs, internal cluster, or cloud provider)? [No] The models we train are not new: the original papers already give that type of information.
307
+
308
+ 4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
309
+
310
+ (a) If your work uses existing assets, did you cite the creators? [Yes] See Section 2.2, 2.1.3, and 2.4.
311
+ (b) Did you mention the license of the assets? [No] They are all under CC0 for the English and French training audio data, the Perceptimatic Benchmark, The Little Prince dataset and the Narratives dataset. Magic data is under CC BY-NC-ND 4.0, Audioset is under CC BY 4.0 for the audio recordings, and CC BY-SA 4.0 for the ontology, Narratives’ preprocessing code is under GNU GENERAL PUBLIC LICENSE and fairseq code is under MIT License.
312
+ (c) Did you include any new assets either in the supplemental material or as a URL? [No] The code will be given upon request
313
+ (d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [Yes] See Section 2.2 and 2.4. More details on the way they gave their consent can be seen in the original papers/websites that provided the experimental results.
314
+
315
+ (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [N/A] The data were anonymized before we used them.
316
+
317
+ 5. If you used crowdsourcing or conducted research with human subjects...
318
+
319
+ (a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A] We did not conduct the experiments ourselves
320
+ (b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A] We did not conduct the experiments ourselves
321
+ (c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A] We did not conduct the experiments ourselves
md/dev/YJ7o2wetJ2/YJ7o2wetJ2.md ADDED
The diff for this file is too large to render. See raw diff
 
md/dev/ZumkmSpY9G4/ZumkmSpY9G4.md ADDED
@@ -0,0 +1,444 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # BYPASSING LOGITS BIAS IN ONLINE CLASSINCREMENTAL LEARNING WITH A GENERATIVE FRAMEWORK
2
+
3
+ Anonymous authors Paper under double-blind review
4
+
5
+ # ABSTRACT
6
+
7
+ Continual learning requires the model to maintain the learned knowledge while learning from a non-i.i.d data stream continually. Due to the single-pass training setting, online continual learning is very challenging, but it is closer to the realworld scenarios where quick adaptation to new data is appealing. In this paper, we focus on online class-incremental learning setting in which new classes emerge over time. Almost all existing methods are replay-based with a softmax classifier. However, the inherent logits bias problem in the softmax classifier is a main cause of catastrophic forgetting while existing solutions are not applicable for online settings. To bypass this problem, we abandon the softmax classifier and propose a novel generative framework based on the feature space. In our framework, a generative classifier which utilizes replay memory is used for inference, and the training objective is a pair-based metric learning loss which is proven theoretically to optimize the feature space in a generative way. In order to improve the ability to learn new data, we further propose a hybrid of generative and discriminative loss to train the model. Extensive experiments on several benchmarks, including newly introduced task-free datasets, show that our method beats a series of state-of-the-art replay-based methods with discriminative classifiers, and reduces catastrophic forgetting consistently with a remarkable margin.
8
+
9
+ # 1 INTRODUCTION
10
+
11
+ Humans excel at continually learning new skills and accumulating knowledge throughout their lifespan. However, when learning a sequential of tasks emerging over time, neural networks notoriously suffer from catastrophic forgetting (McCloskey & Cohen, 1989) on old knowledge. This problem results from non-i.i.d distribution of data streams in such a scenario. To this end, continual learning (CL) (Parisi et al., 2019; Lange et al., 2019) has been proposed to bridge the above gap between intelligent agents and humans.
12
+
13
+ In common CL settings, there are clear boundaries between distinct tasks which are known during training. Within each task, a batch of data are accumulated and the model can be trained offline with the i.i.d data. Recently, online CL (Aljundi et al., 2019c;a) setting has received growing attention in which the model needs to learn from a non-i.i.d data stream in online settings. At each iteration, new data are fed into the model only once and then discarded. In this manner, task boundary is not informed, and thus online CL is compatible with task-free (Aljundi et al., 2019b; Lee et al., 2020) scenario. In real-world scenarios, the distribution of data stream changes over time gradually instead of switching between tasks suddenly. Moreover, the model is expected to quickly adapt to large amount of new data, e.g. user-generated content. Online CL meets these requirements, so it is more meaningful for practical applications. Many existing CL works deal with task-incremental learning (TIL) setting (Kirkpatrick et al., 2017; Li & Hoiem, 2018), in which task identity is informed during test and the model only needs to classify within a particular task. However, for online CL problem, TIL is not realistic because of the dependence on task boundary as discussed above and reduces the difficulty of online CL. In contrast, class-incremental learning (CIL) setting (Rebuffi et al., 2017) requires the model to learn new classes continually over time and classify samples over all seen classes during test. Thus, online CIL setting is more suitable for online data streams in real-world CL scenarios (Mai et al., 2021).
14
+
15
+ ![](images/b3a4214c1d95bdbe7e3c84b693f2792a9453482c6ed17c4c452535238c52acd6.jpg)
16
+ Figure 1: Logits bias phenomenon of softmax classifier (left) and accuracy & forgetting on different tasks using softmax vs. generative NCM classifier (right). The results are obtained with ER and 1k replay memory on 5-task Split CIFAR10.
17
+
18
+ Most existing online CIL methods are based on experience replay (ER) (Robins, 1995; Riemer et al., 2019) strategy which stores a subset of learned data in a replay memory and uses the data in memory to retrain model thus alleviating forgetting. Recently, in CIL setting logits bias problem in the last fully connected (FC) layer, i.e. softmax classifier, is revealed (Wu et al., 2019), which is a main cause of catastrophic forgetting. In Figure 1a, we show in online CIL, even if ER is used, logits bias towards newly learned classes in the softamx classifier is still serious and the forgetting on old tasks is dramatic (See Figure 1b). Although some works (Wu et al., 2019; Belouadah & Popescu, 2019; Zhao et al., 2020) propose different methods to reduce logits bias, they all depend on task boundaries and extra offline phases during training so that not applicable for online CIL setting.
19
+
20
+ In this paper, we propose to tackle the online CIL problem without the softmax classifier to avoid logits bias problem. Instead, we propose a new framework where training and inference are both in a generative way. We are motivated by the insight that generative classifier is more effective in low data regime than discriminative classifier which is demonstrated by $\mathrm { N g }$ & Jordan (2001). Although the conclusion is drawn on simple linear models (Ng & Jordan, 2001), similar results are also observed on deep neural networks (DNNs) (Yogatama et al., 2017; Ding et al., 2020) recently. It should be noticed that in online CIL setting the data is seen only once, not fully trained, so it is analogous to the low data regime in which the generative classifier is preferable. In contrast, the commonly used softmax classifier is a discriminative model.
21
+
22
+ Concretely, we abandon the softmax FC layer and introduce nearest-class-mean (NCM) classifier (Mensink et al., 2013) for inference, which can be interpreted as classifying in a generative way. The NCM classifier is built on the feature space on the top of previous network layers. Thanks to ER strategy, NCM classifier can utilize the replay memory for inference. As for training, inspired by a recent work (Boudiaf et al., 2020), which shows pair-based deep metric learning (DML) losses can be interpreted as optimizing the feature space from a generative perspective, we introduce MultiSimilarity (MS) loss (Wang et al., 2019) to obtain a good feature space for NCM classifier. Meanwhile, we prove theoretically that MS loss is an alternative to a training objective of the generative classifier. In this way, we can bypass logits bias.
23
+
24
+ To strengthen the model’s capable of learning from new data in complex data streams, we further introduce an auxiliary proxy-based DML loss (Movshovitz-Attias et al., 2017). Therefore, our whole training objective is a hybrid of generative and discriminative losses. During inference, we ignore the discriminative objective and classify with the generative NCM classifier. By tuning weight of the auxiliary loss, our method can work well in different data streams.
25
+
26
+ In summary, our contributions are as follows:
27
+
28
+ 1. We make the first attempt to avoid logits bias problem in online CIL setting. In our generative framework, a generative classifier is introduced to replace softmax classifier for inference and for training, we introduce MS loss which is proven theoretically to optimize the model in a generative way.
29
+
30
+ 2. In order to improve the ability of MS loss to learn from new data, we further introduce an auxiliary loss to achieve a good balance between retaining old knowledge and learning new knowledge.
31
+
32
+ 3. We conduct extensive experiments on four benchmarks in multiple online CIL settings, including a new task-free setting we design for simulating more realistic scenarios. Empirical results demonstrate our method outperforms a variety of state-of-the-art replay-based methods substantially, especially alleviating catastrophic forgetting significantly.
33
+
34
+ # 2 RELATED WORK
35
+
36
+ Current CL methods can be roughly divided into three categories: which are regularization, parameter isolation and replay-based respectively (Lange et al., 2019). Regularization methods retain the learned knowledge by imposing penalty constraints on model’s parameters (Kirkpatrick et al., 2017) or outputs (Li & Hoiem, 2018) when learning new data. They work well in TIL setting but poor in CIL setting (van de Ven & Tolias, 2018). Parameter isolation methods assign a specific subset of model parameters, such as network weights (Mallya & Lazebnik, 2018) and sub-networks (Fernando et al., 2017) to each task to avoid knowledge interference and thus the network may keep growing. This type of method is mainly designed for TIL as task identity is usually necessary during test. The mainstream of Replay-based methods is ER-like (Rebuffi et al., 2017), which stores a subset of old data and retrains it when learning new data to prevent forgetting of old knowledge. In addition, generative replay method trains a generator to replay old data approximately (Shin et al., 2017).
37
+
38
+ In the field of online CL, most of methods are on the basis of ER. Chaudhry et al. (2019b) first explored ER in online CL settings with different memory update strategies. Authors suggested ER method should be regarded as an important baseline as in this setting it is more effective than several existing CL methods, such as A-GEM (Chaudhry et al., 2019a). GSS (Aljundi et al., 2019c) designs a new memory update strategy by encouraging the divergence of gradients of samples in memory. MIR (Aljundi et al., 2019a) is proposed to select the maximally interfered samples from memory for replay. GMED (Jin et al., 2020) edits the replay samples with gradient information to obtain samples likely to be forgotten, which can benefit the replay in the future. Mai et al. (2021) focus on online CIL setting and adopt the notion of Shapley Value to improve the replay memory update and sampling. All of the above methods are replay-based with softmax classifier. A contemporary work (Lange & Tuytelaars, 2020) proposes CoPE, which is somewhat similar to our method. CoPE replaces softmax classifier with a prototype-based classifier which is non-parametric and updated using features of data samples. However, the loss function of CoPE is still discriminative and the way to classify is analogous to softmax classifier.
39
+
40
+ Apart from the above ER based methods, Zeno et al. (2018) propose an online regularization method, however it performs very badly in online CL settings (Jin et al., 2020). Lee et al. (2020) propose a parameter isolation method in which the network is dynamically expanded and a memory for storing data is still required. Therefore, the memory usage is not fixed and potentially unbounded.
41
+
42
+ A recent work (Yu et al., 2020) proposes SDC, a CIL method based on DML and NCM classifier. However, SDC requires an extra phase to correct semantic drift after training each task. This phase depends on task boundaries and the accumulated data of a task, which is not applicable for online CIL. In contrast, our method is based on ER and classifies with replay memory and thus need not correct the drift.
43
+
44
+ # 3 ONLINE CLASS-INCREMENTAL LEARNING WITH A GENERATIVE FRAMEWORK
45
+
46
+ 3.1 PRELIMINARIES AND MOTIVATIONS
47
+
48
+ 3.1.1 ONLINE CLASS-INCREMENTAL LEARNING
49
+
50
+ CIL setting has been widely used in online CL literature, e.g. (Aljundi et al., 2019a; Mai et al., 2021), and a softmax classifier is commonly used. A neural network $f ( \cdot ; \pmb \theta ) : \mathcal { X } \mathbb { R } ^ { d }$ parameterized by $\pmb \theta$ encodes data samples $\mathbf { \boldsymbol { x } } \in \mathcal { X }$ into a $d$ -dimension feature $f ( { \pmb x } )$ on which an FC layer $g$ outputs logits for classification: ${ \pmb o } = { \bf W } f ( { \pmb x } ) + { \bf b }$ . At each iteration, a minibatch of data $B _ { n }$ from a data stream $s$ arrives and the whole model $( f , g )$ is trained on $B _ { n }$ only once. The training objective is cross-entropy (CE) loss:
51
+
52
+ $$
53
+ \mathcal { L } _ { C E } = - \sum _ { c = 1 } ^ { \tilde { C } } t _ { : c } \log \hat { { \pmb y } } _ { : c } , \quad \hat { { \pmb y } } _ { : c } = \frac { e ^ { { \pmb o } _ { : c } } } { \sum _ { c = 1 } ^ { \tilde { C } } e ^ { { \pmb o } _ { : c } } }
54
+ $$
55
+
56
+ where $\tilde { C }$ is the number of classes seen so far. $\pmb { t }$ is one-hot label of $_ { \textbf { \em x } }$ and the subscript $: c$ denotes the $c$ -th component. The new classes from $s$ emerge over time. The output space of $g$ is the number of seen classes and thus keeps growing. At test time, the model should classify over all $C$ classes seen.
57
+
58
+ # 3.1.2 EXPERIENCE REPLAY FOR ONLINE CONTINUAL LEARNING
59
+
60
+ ER makes two modifications during online training: (1) It maintains a replay memory $\mathcal { M }$ with limited size which stores a subset of previously learned samples. (2) When a minibatch of new data $B _ { n }$ is coming, it samples a minibatch $B _ { r }$ from $\mathcal { M }$ and uses $B _ { n } \cup B _ { r }$ to optimize the model with one SGD-like step. Then it updates $\mathcal { M }$ with $B _ { n }$ . Recent works, e.g. (Aljundi et al., 2019a; Mai et al., 2021) regard ER-reservoir as a strong baseline, which combines ER with reservoir sampling (Vitter, 1985) for memory update and random sampling for $B _ { r }$ . See Chaudhry et al. (2019b) for more details about it.
61
+
62
+ # 3.1.3 LOGITS BIAS IN SOFTMAX CLASSIFIER
63
+
64
+ Some recent works (Wu et al., 2019; Belouadah & Popescu, 2019; Zhao et al., 2020) show in CIL scenarios, even with replay-based mechanism the logits outputted by model always have a strong bias towards the newly learned classes, which leads to catastrophic forgetting actually. In preliminary experiments, we also observe this phenomenon in online CIL setting. We run ER-reservoir baseline on 5-task Split CIFAR10 (each task has two disjoint classes) online CIL benchmark. In Figure 1a, we display the average logits of each already learned tasks over samples in test data after learning each task. The model outputs much higher logits on the new classes (of the task just learned) than old classes.
65
+
66
+ Following (Ahn & Moon, 2020), we examine the CE loss in Eq (1), the gradient of $\mathcal { L } _ { C E }$ w.r.t logit $\pmb { o } _ { : c }$ of class $c$ is $\hat { { \bf y } } _ { : c } - \mathbb { I } [ { \bf t } _ { : c } = 1 ]$ . Thus, if $c$ is the real label $y$ , i.e. $\pmb { t } _ { : c } = 1$ , the gradient is non-positive and model is trained to increase $\pmb { o } _ { : c }$ , otherwise the gradient is non-negative and model is trained to decrease $\pmb { o } _ { : c }$ . Therefore, logits bias problem is caused by the imbalance between the number of samples of the new classes and that of the old classes with a limited size of $\mathcal { M }$ . As mentioned in Section 1, existing solutions (Wu et al., 2019; Belouadah & Popescu, 2019; Zhao et al., 2020) designed for conventional CIL need task boundaries to conduct extra offline training phases and even depend on the accumulated data of one task. They are not applicable for online CIL setting where task boundaries are not informed or even do not exist in task-free scenario.
67
+
68
+ # 3.2 INFERENCE WITH A GENERATIVE CLASSIFIER
69
+
70
+ Proposed generative framework is based on ER strategy, and aims to avoid the intrinsic logits bias problem by removing the softmax FC layer $g$ and build a generative classifier on the feature space ${ \mathcal { Z } } : z = f ( { \pmb x } )$ . If the feature $_ z$ is well discriminative, we can conduct inference with samples in $\mathcal { M }$ instead of a parametric classifier which is prone to catastrophic forgetting (Rebuffi et al., 2017). We use NCM classifier firstly suggested by Rebuffi et al. (2017) for CL and show it is a generative model. We use $\mathcal { M } _ { c }$ to denote the subset of class $c$ of $\mathcal { M }$ . The class mean $\pmb { \mu } _ { c }$ is computed by $\begin{array} { r } { \pmb { \mu } _ { c } ^ { \mathcal { M } } = \frac { 1 } { | \mathcal { M } _ { c } | } \sum _ { \pmb { x } \in \mathcal { M } _ { c } } f ( \pmb { x } ) } \end{array}$ . During inference, the prediction for $\mathbf { \nabla } _ { \mathbf { \mathcal { X } } } \ast \mathbf { \ v { x } }$ is made by:
71
+
72
+ $$
73
+ { y ^ { * } } = \arg \operatorname* { m i n } _ { c } \| f ( { \pmb x } ^ { * } ) - { \pmb \mu } _ { c } ^ { \mathcal { M } } \| _ { 2 }
74
+ $$
75
+
76
+ In fact, the principle of prediction in $\operatorname { E q }$ (2) is to find a Gaussian distribution $\mathcal { N } ( f ( \pmb { x } ^ { * } ) | \pmb { \mu } _ { c } ^ { \mathcal { M } } , \mathbf { I } )$ with the maximal probability for $\pmb { x } ^ { * }$ . Therefore, assuming the conditional distribution $p ( z | y =$ $c ) = \mathcal { N } ( z | \mu _ { c } ^ { \mathcal { M } } , \mathbf { I } )$ and the prior distribution $p ( y )$ is uniform, NCM classifier virtually deals with $p ( y | z )$ by modeling $p ( z | y )$ in a generative way. The inference way is according to Bayes rule: arg ma $\mathrm { \Lambda } _ { \mathrm { C } } p ( y | \mathbf { x } ^ { * } ) = \arg \operatorname* { m a x } p ( f ( \mathbf { x } ^ { * } ) | y ) p ( y )$ . The assumption about $p ( y )$ simplifies the analysis and works well in practice. In contrast, softmax classifier models $p ( y | \mathbf { \boldsymbol { x } } ^ { * } )$ in a typical discriminative way.
77
+
78
+ As discussed above, online CIL is in a low data setting where generative classifiers are preferable compared to discriminative classifiers $\mathrm { N g }$ & Jordan, 2001). Moreover, generative classifiers are more robust to continual learning (Yogatama et al., 2017) and imbalanced data settings (Ding et al., 2020). At each iteration, $B _ { n } \cup B _ { r }$ is also highly imbalanced. Considering these results, we hypothesis generative classifiers are promising for online CIL problem. It should be noted our method only models a simple generative classifier $p ( z | y )$ on the feature space, instead of modeling $p ( { \pmb x } | { \pmb y } )$ on the input space using DNNs (Yogatama et al., 2017), which is time-consuming and thus is not suitable for online training.
79
+
80
+ 3.3 TRAINING WITH A PAIR-BASED METRIC LEARNING LOSS FROM A GENERATIVE PERPECTIVE
81
+
82
+ To train the feature extractor $f ( \pmb \theta )$ we resort to DML losses which aim to learn a feature space where the distances represent semantic dissimilarities between data samples. From the perspective of mutual information (MI), Boudiaf et al. (2020) theoretically show the equivalence between CE loss and several pair-based DML losses, such as contrast loss (Hadsell et al., 2006) and Multi-Similarity (MS) loss (Wang et al., 2019). The DML losses maximize MI between feature $_ z$ and label $y$ in a generative way while CE loss in a discriminative way, which motivates us to train $f ( \pmb \theta )$ with a pair-based DML loss to obtain a good feature space $\mathcal { Z }$ for the generative classifier.
83
+
84
+ Especially, we choose the MS loss as a training objective. MS loss is one of the state-of-the-art methods in the field of DML. Wang et al. (2019) point out pair-based DML losses can be seen as weighting each feature pair in the general pair weighting framework. As MS loss requires the feature $f ( { \pmb x } )$ to be $\ell _ { 2 }$ -normalized first, from now on, we use $z _ { i }$ to denote the $\ell _ { 2 }$ -normalized feature of $\mathbf { \Delta } _ { \mathbf { \mathcal { X } } _ { i } }$ and a feature pair is represented in the form of inner product $S _ { i j } : = z _ { i } ^ { \mathrm { T } } z _ { j }$ . To weight feature pairs better, MS loss is proposed to consider multiple types of similarity. MS loss on a dataset $\mathcal { D }$ is formulated as follows:
85
+
86
+ $$
87
+ \mathcal { L } _ { M S } ( \mathcal { D } ) = \frac { 1 } { | \mathcal { D } | } \sum _ { i = 1 } ^ { | \mathcal { D } | } \big \{ \frac { 1 } { \alpha } \log [ 1 + \sum _ { j \in \mathcal { P } _ { i } } e ^ { - \alpha ( S _ { i j } - \lambda ) } ] + \frac { 1 } { \beta } \log [ 1 + \sum _ { j \in \mathcal { N } _ { i } } e ^ { \beta ( S _ { i j } - \lambda ) } ] \big \}
88
+ $$
89
+
90
+ where $\alpha , ~ \beta$ and $\lambda$ are hyperparameters and $\mathcal { P } _ { i }$ and ${ \mathcal { N } } _ { i }$ represent the index set of positive and negative samples of ${ \pmb x } _ { i } ^ { 1 }$ respectively. MS loss also utilizes the hard mining strategy to filter out too uninformative feature pairs, i.e. too similar positive pairs and too dissimilar negative pairs:
91
+
92
+ $$
93
+ \mathcal { P } _ { i } = \{ j | S _ { i j } < \operatorname* { m a x } _ { y _ { k } \neq y _ { i } } S _ { i k } + \epsilon \} \quad \mathcal { N } _ { i } = \{ j | S _ { i j } > \operatorname* { m i n } _ { y _ { k } = y _ { i } } S _ { i k } - \epsilon \}
94
+ $$
95
+
96
+ where $\epsilon$ is another hyperparameter in MS loss. At each iteration we use MS loss on the union of new samples and replay samples $\mathcal { L } _ { M S } ( B _ { n } \cup B _ { r } )$ to train the model. The sampling of $\boldsymbol { B } _ { r }$ and update of $\mathcal { M }$ are the same as ER-reservoir.
97
+
98
+ To show the connection between $\mathcal { L } _ { M S }$ and the generative classifier in Eq (2), we conduct some theoretical analyses.
99
+
100
+ Proposition 1. Assume dataset $\mathbf { \mathcal { D } } = \{ ( \boldsymbol { { \bf x } } _ { i } , y _ { i } ) \} _ { i = 1 } ^ { n }$ is class-balanced and has $C$ classes each of which has $n _ { 0 }$ samples. For a generative model $p ( z , y )$ , assume $p ( y )$ actually obeys the uniform distribution and $p ( z | y = c ) = \bar { \mathcal { N } } ( z | \mu _ { c } ^ { D } , \mathbf { I } )$ where $\begin{array} { r } { \pmb { \mu } _ { c } ^ { D } = \frac { 1 } { n _ { 0 } } \sum _ { i = 1 } ^ { n } z _ { i } \mathbb { I } [ y _ { i } = c ] , } \end{array}$ . For MS loss assume hard mining in Eq (4) is not employed. Then we have:
101
+
102
+ $$
103
+ \mathcal { L } _ { M S } \stackrel { \mathrm { c } } { \geq } \mathcal { L } _ { G e n - B i n }
104
+ $$
105
+
106
+ where $\geq$ stands for upper than, up to an additive constant $c$ and $\mathcal { L } _ { G e n - B i n }$ is defined in the following:
107
+
108
+ $$
109
+ \mathcal { L } _ { G e n - B i n } = - \frac { 1 } { n } \sum _ { i = 1 } ^ { n } \log p ( z _ { i } | y = y _ { i } ) + \frac { 1 } { n C } \sum _ { i = 1 } ^ { n } \sum _ { c = 1 } ^ { C } \log p ( z _ { i } | y = c )
110
+ $$
111
+
112
+ 1The positive samples have the same labels as $\mathbf { \Delta } _ { \mathbf { \mathcal { X } } _ { i } }$ while the negative samples have different labels from $\mathbf { \Delta } _ { \mathbf { \mathcal { X } } _ { i } }$
113
+
114
+ The proof of Proposition 1 is in Appendix. Proposition 1 shows $\mathcal { L } _ { M S }$ is an upper bound of $\mathcal { L } _ { G e n - B i n }$ and thus is an alternative to minimizing $\mathcal { L } _ { G e n - B i n }$ . The first term of $\mathcal { L } _ { G e n - B i n }$ aims to minimize the negative log-likelihood of the class-conditional generative classifier, while the second term maximizes the conditional entropy $H ( Z | Y )$ of labels $Y$ and features $Z$ . It should be noticed $\mathcal { L } _ { G e n - B i n }$ depends on modeling $p ( z | y )$ . With uniform $p ( y )$ , classifying using $p ( z | y )$ equals to classifying using $p ( z , y )$ , and $H ( Z | Y )$ is equivalent to $H ( Z , Y )$ , which can be regarded as a regularizer against features collapsing. Thus, $\mathcal { L } _ { G e n - B i n }$ actually optimizes the model in a generative way. The assumptions in Proposition 1 are similar with those in Section 3.2 about NCM classifier. The difference lies in that NCM classifier uses $\{ \mu _ { c } ^ { \mathcal { M } } \}$ computed on replay memory $\mathcal { M }$ to approximate $\{ \mu _ { c } ^ { D } \}$ . Therefore, Proposition 1 reveals that MS loss optimizes the feature space in a generative way and it models $p ( z { \bar { | } } y )$ for classification which is consistent with the NCM classifier.
115
+
116
+ The real class means $\{ \mu _ { c } ^ { D } \}$ depend on all training data and change with the update of $f ( \pmb \theta )$ so that are intractable in online settings. MS loss can be efficiently computed as it does not depend on $\{ \mu _ { c } ^ { D } \}$ thus the model can be trained efficiently. During inference, we use approximate class means $\mu _ { c } ^ { \mathcal { M } }$ to classify. In Figure 1b, on 5-task Split CIFAR10 benchmark, we empirically show compared to softmax classifier, on old tasks, our method achieves much higher accuracy and much lower forgetting, which implies MS loss is an effective objective to train the model $f$ and class mean $\mu _ { c } ^ { \mathcal { M } }$ of replay memory is a good approximation of $\mu _ { c } ^ { \mathcal { D } }$ .
117
+
118
+ With discriminative loss like CE loss, the classifier models a discriminative model $p ( y | z )$ . Therefore, if training with discriminative loss and inference with NCM classifier based on the generative model $p ( z | y )$ , we can not expect to obtain good results. In the next section, experiments will verify this conjecture. In contrast, the way to train and inference are coincided in proposed generative framework.
119
+
120
+ # 3.4 A HYBRID GENERATIVE/DISCRIMINATIVE LOSS
121
+
122
+ However, when addressing classification tasks, generative classifier has natural weakness, since modeling joint distribution $p ( { \pmb x } , { \pmb y } )$ is much tougher than modeling conditional distribution $p ( y | \mathbf { \boldsymbol { x } } )$ for NNs. Moreover, in preliminary experiments, we found if only trained with MS loss, the NCM classifier’s performance degenerates as the expected number of classes in $B _ { n }$ at each iteration increases. This phenomenon is attributed to the inadequate ability to learn from new data, instead of catastrophic forgetting. We speculate because the size of $B _ { n }$ is always fixed to a small value (e.g. 10) in online CIL settings, the number of positive pairs in $B _ { n }$ decreases as the expected number of classes increases.
123
+
124
+ To remedy this problem, we take advantage of discriminative losses for fast adaptation in online setting. To this end, we introduce Proxy-NCA (PNCA) (Movshovitz-Attias et al., 2017), a proxybased DML loss, as an auxiliary loss. For each class, PNCA loss maintains “proxies” as the real feature to utilize the limited data in a minibatch better, which leads to convergence speed-up compared to pair-based DML losses. Concretely, when a new class $c$ emerges, we assign one trainable proxy $\pmb { p _ { c } } \in \mathbb { R } ^ { d }$ to it. PNCA loss is computed as:
125
+
126
+ $$
127
+ \mathcal { L } _ { P N C A } ( \mathcal { D } ) = - \frac { 1 } { | \mathcal { D } | } \sum _ { ( \boldsymbol { x } , \boldsymbol { y } ) \in \mathcal { D } } \log \frac { e ^ { - \| \boldsymbol { f } ( \boldsymbol { x } ) - \boldsymbol { p } _ { \boldsymbol { y } } \| _ { 2 } ^ { 2 } } } { \sum _ { c = 1 } ^ { \tilde { C } } e ^ { - \| \boldsymbol { f } ( \boldsymbol { x } ) - \boldsymbol { p } _ { c } \| _ { 2 } ^ { 2 } } }
128
+ $$
129
+
130
+ Movshovitz-Attias et al. (2017) suggest all proxies have the same norm $N _ { P }$ and all features have the norm $N _ { F }$ . The latter satisfies as in MS loss the feature is $\ell _ { 2 }$ -normalized, i.e. $N _ { F } = 1$ . We also set $N _ { P } = 1$ by normalizing all proxies after each SGD-like update. In this way, $\mathcal { L } _ { P N C A }$ is equivalent to a CE loss with $\ell _ { 2 }$ -normalized row vectors of W and without bias $\mathbf { b }$ , and thus we use PNCA instead of CE loss to keep utilizing the normalized features of MS loss. Our full training objective is a hybrid of generative and discriminative losses:
131
+
132
+ $$
133
+ \mathcal { L } _ { H y b r i d } = \mathcal { L } _ { M S } + \gamma \mathcal { L } _ { P N C A }
134
+ $$
135
+
136
+ where $\gamma$ is a hyperparameter to control the weight of $\mathcal { L } _ { P N C A }$ . In general, generative classifiers have a smaller variance but higher bias than discriminative classifiers, and using such a hybrid loss can achieve a better bias-variance tradeoff (Bouchard & Triggs, 2004). Thus we think introducing the discriminative loss $\mathcal { L } _ { P N C A }$ can reduce the bias of model so that boost the ability to learn from new data.
137
+
138
+ It should be noticed we train the model with $\mathcal { L } _ { H y b r i d } ( B _ { n } \cup B _ { r } )$ , while we only use NCM classifier in Eq (2) for inference. In all experiments, we set $\alpha = 2$ , $\beta = 5 0$ , $\epsilon = 0 . 1$ following Wang et al. (2019)
139
+
140
+ ![](images/7dd061d7ae86d979c9feb1fb2046756cbdaef7fad21de3a90f0540c73d93d91e.jpg)
141
+ Figure 2: The probability distribution on class of the sample at each time step on Split CIFAR10 (left) and Smooth CIFAR10 (right).
142
+
143
+ ![](images/14f0a42fd413f10fa45e0f1c18307ecee77f1f5030ffce5cb75a1edaddcc8d6d.jpg)
144
+ Figure 3: Average Accuracy on already learned task during training.
145
+
146
+ and $\lambda = 0 . 5$ which always works well in online CIL settings. We only need to tune hyperparemeters $\gamma$ in Eq (8) for different experiment settings.
147
+
148
+ # 4 EXPERIMENTS
149
+
150
+ # 4.1 EXPERIMENT SETUP
151
+
152
+ Datasets First, we conduct experiments on Split datasets which are commonly used in CIL and online CIL literature. On Split MNIST and CIFAR10, the datasets are split into 5 tasks each of which comprises 2 classes. On CIFAR100 and miniImageNet with 100 classes, we split them into 10 or 20 tasks. The number of classes in each task is 10 or 5 respectively. For MNIST we select 5k samples for training following Aljundi et al. (2019a) and we use full training data for other datasets. To simulate a task-free scenario, task boundaries are not informed during training (Jin et al., 2020).
153
+
154
+ To conduct a thorough evaluation in task-free scenarios, we design a new type of data streams. For a data stream with $C$ classes, we assume the length of stream is $n$ and $n _ { 0 } = n / C$ . We denote $p _ { c } ( t )$ as the occurrence probability of class $c$ at time step $t$ and assume $p _ { c } ( t ) \sim \mathcal { N } ( t | ( 2 c - 1 ) n _ { 0 } / 2 , n _ { 0 } / 2 )$ . At each time step $t$ , we calculate $\pmb { p } ( t ) = ( p _ { 1 } ( t ) , \allowbreak \dots , p _ { C } ( t ) )$ and normalize ${ \pmb p } ( t )$ as the parameters of a Categorical distribution from which a class index $c _ { t }$ is sampled. Then we sample one data of class $c _ { t }$ without replacement. In this setting, data distribution changes smoothly and there is no notion of task. We call such data streams as Smooth datasets. To build Smooth datasets, we set $n = 5 k$ on CIFAR10 and $n = 4 0 k$ on CIFAR100 and miniImageNet, using all classes in each dataset. For all datasets, the size of minibatch $B _ { n }$ is 10. In Figure 2 we plot the probability distribution on class at each time step in the data stream generation process for Split CIFAR10 and Smooth CIFAR10. For better comparison, we set the length of data stream of two datasets both 5k. Split CIFAR10 has clear task boundaries and within one task the distribution on class is unchanged and uniform. However, On Smooth CIFAR10, the distribution on class keeps changing and there is no notion of task.
155
+
156
+ Baselines We compare our method against a series of state-of-the-art online CIL methods, including: ER-reservoir, A-GEM, GSS, MIR, GMED, CoPE and ASER. We have briefly introduced them in Section 2. Specially, we use GSS-greedy and $\operatorname { A S E R } _ { \mu }$ which are the best variants in the corresponding paper. For GMED, we evaluate both GMED-ER and GMED-MIR. We also evaluate fine-tune baseline without any CL strategy. For all baselines and our method, the model is trained with 1 epoch, i.e. online CL setting. In addition, the performances of i.i.d online and i.i.d offline are also provided, by training the model 1 and 5 epochs respectively on i.i.d data streams. We reimplement all baselines except $\operatorname { A S E R } _ { \mu }$ , whose results are from the original paper. Model Following Aljundi et al. (2019a), the model $f$ is a 2-layer MLP with 400 hidden units for MNIST and a reduced ResNet18 for other datasets. For baselines with ER strategy, the size of replay minibatch $\boldsymbol { B } _ { r }$ is always 10. The budget of memory $\mathcal { M }$ is 500 on MNIST and 1000 on others. We use a relatively small budget $| { \mathcal { M } } |$ to mimic a practical setting. All models are optimized by SGD. The single-head evaluation is always used for CIL. More details about datasets, hyperparameter selection and evaluation metrics are in Appendix.
157
+
158
+ # 4.2 MAIN RESULTS ON Split DATASETS
159
+
160
+ On Split datasets, we use Average Accuracy and Average Forgetting after training all tasks (Chaudhry et al., 2019b) for evaluation, which are reported in Table 1 and Table 2 respectively. For each metric, we report the mean of 15 runs and the $9 5 \%$ confidence interval.
161
+
162
+ Table 1: Average Accuracy of 15 runs on Split datasets. Higher is better. ∗ indicates the results are from the original paper.
163
+
164
+ <table><tr><td>Methods</td><td>MNIST (5-task)</td><td>CIFAR10 (5-task)</td><td>CIFAR100 (10-task)</td><td>CIFAR100 (20-task)</td><td>miniImageNet (10-task)</td><td>miniImageNet (20-task)</td></tr><tr><td>fine-tune</td><td>19.66±0.05</td><td>18.40±0.17</td><td>6.26±0.30</td><td>3.61±0.24</td><td>4.43±0.19</td><td>3.12±0.15</td></tr><tr><td>ER-reservoir</td><td>82.34±2.48</td><td>39.88±1.52</td><td>11.59±0.26</td><td>8.95±0.26</td><td>10.24±0.41</td><td>8.33±0.66</td></tr><tr><td>A-GEM</td><td>25.99±1.62</td><td>18.01±0.17</td><td>6.48±0.18</td><td>3.66±0.09</td><td>4.68±0.11</td><td>3.37±0.13</td></tr><tr><td>GSS-Greedy</td><td>83.88±0.72</td><td>39.07±2.02</td><td>10.78±0.28</td><td>7.94±0.47</td><td>9.20±0.61</td><td>7.76±0.35</td></tr><tr><td>MIR</td><td>86.81±0.95</td><td>42.10±1.27</td><td>11.52±0.37</td><td>8.61±0.34</td><td>9.99±0.49</td><td>7.93±0.70</td></tr><tr><td>GMED-ER</td><td>81.71±1.87</td><td>42.65±1.27</td><td>11.86±0.36</td><td>9.16±0.47</td><td>9.53±0.66</td><td>8.14±0.58</td></tr><tr><td>GMED-MIR</td><td>88.70±0.81</td><td>44.53±2.23</td><td>11.58±0.51</td><td>8.48±0.37</td><td>9.24±0.53</td><td>7.75±0.80</td></tr><tr><td>CoPE</td><td>87.58±0.65</td><td>47.36±0.96</td><td>10.79±0.36</td><td>9.11±0.44</td><td>11.03±0.68</td><td>9.92±0.61</td></tr><tr><td>ASERμ* *</td><td>1</td><td>43.50±1.40</td><td>14.00±0.40</td><td>1</td><td>12.20±0.80</td><td>1</td></tr><tr><td>Ours</td><td>88.79±0.26</td><td>51.84±0.91</td><td>15.56±0.39</td><td>13.65±0.35</td><td>16.05±0.38</td><td>15.15±0.36</td></tr><tr><td>i.i.d. online</td><td>86.35±0.64</td><td>62.37±1.36</td><td>20.62±0.48</td><td>20.62±0.48</td><td>18.02±0.63</td><td>18.02±0.63</td></tr><tr><td>i.i.d. offline</td><td>92.44±0.61</td><td>79.90±0.51</td><td>45.59±0.29</td><td>45.59±0.29</td><td>38.63±0.59</td><td>38.63±0.59</td></tr></table>
165
+
166
+ Table 2: Average Forgetting of 15 runs on Split datasets. Lower is better. ∗ indicates the results are from the original paper.
167
+
168
+ <table><tr><td>Methods</td><td>MNIST (5-task)</td><td>CIFAR10 (5-task)</td><td>CIFAR100 (10-task)</td><td>CIFAR100 (20-task)</td><td>miniImageNet (10-task)</td><td>miniImageNet (20-task)</td></tr><tr><td>fine-tune</td><td>99.24±0.09</td><td>85.45±0.63</td><td>51.60±0.77</td><td>65.51±0.78</td><td>41.12±0.82</td><td>52.99±0.89</td></tr><tr><td>ER-reservoir</td><td>18.33±1.77</td><td>52.72±1.90</td><td>45.94±0.55</td><td>57.31±0.71</td><td>36.05±0.78</td><td>47.70±0.90</td></tr><tr><td>A-GEM</td><td>89.90±2.02</td><td>82.80±0.73</td><td>54.15±0.42</td><td>67.61±0.53</td><td>43.31±0.52</td><td>54.47±0.78</td></tr><tr><td>GSS-Greedy</td><td>15.13±0.99</td><td>49.96±2.82</td><td>44.30±0.57</td><td>53.87±0.54</td><td>36.17±0.58</td><td>45.91±0.79</td></tr><tr><td>MIR</td><td>9.71±1.39</td><td>44.34±2.65</td><td>46.52±0.52</td><td>56.58±0.62</td><td>36.98±0.78</td><td>45.84±1.11</td></tr><tr><td>GMED-ER</td><td>16.21±2.70</td><td>44.93±1.68</td><td>46.35±0.50</td><td>57.76±0.94</td><td>35.22±1.16</td><td>45.08±1.28</td></tr><tr><td>GMED-MIR</td><td>12.52±1.05</td><td>39.88±2.23</td><td>46.56±0.65</td><td>58.14±0.55</td><td>34.79±1.01</td><td>45.50±1.49</td></tr><tr><td>CoPE</td><td>9.51±1.15</td><td>40.01±1.80</td><td>36.51±0.86</td><td>43.82±0.62</td><td>29.43±0.98</td><td>40.99±1.02</td></tr><tr><td>ASERμ*</td><td>1</td><td>47.90±1.60</td><td>45.00±0.70</td><td>1</td><td>28.00±1.30</td><td>1</td></tr><tr><td>Ours</td><td>9.36±0.37</td><td>35.37±1.35</td><td>21.79±0.69</td><td>27.10±1.10</td><td>21.26±0.59</td><td>24.98±0.87</td></tr></table>
169
+
170
+ In Table 1, we can find our method outperforms all baselines on all 6 settings. The improvement of our method is significant except on MNIST, where GMED-MIR is competitive with our method. An interesting phenomenon is all existing methods do not have a substantial improvement over ER-reservoir on CIFAR100 and miniImageNet, except ASER. We argue for online CIL problem, we should pay more attention to complex settings. Nevertheless, our method is superior to ASER obviously, especially on CIFAR10 and miniImageNet. Table 2 shows the forgetting of our method is far lower than other methods based on the softmax classifier, except on MNIST. Figure 3 shows our method is almost consistently better than all baselines during the whole learning processes. More results with various memory sizes can be found in Appendix.
171
+
172
+ Ablation Study We also conduct ablation study about training objective and classifier in Table 4. The ER-reservoir corresponds to the first row and our method corresponds to the last row. Firstly, we find for ER-reservoir, replacing softmax classifier with NCM classifier makes a substantial improvement on CIFAR10. However, it has no effect on more complex CIFAR100 (row 1&2). Secondly, only using MS loss works very well on CIFAR10 while on CIFAR100 poor ability to learn from new data limits its performance (row 3&6). Lastly, when hybrid loss is used, the NCM classifier is much better than proxy-based classifier (row 5&6), and MS loss is critical for NCM classifier (row 4&6). Note that hybrid loss does not outperform MS loss much on Split-CIFAR10. This is because in Split-CIFAR10, a minibatch of new data contains a maximum of two classes, and thus the positive pairs are enough fo MS loss to learn new knowledge well. These results verify our statement in Section 3.2.
173
+
174
+ Comparison with Logits Bias Solutions for Conventional CIL Setting Although existing CIL methods to alleviate logits bias are not applicable for online CIL settings as task boundaries are necessary, after being modified in some ways they can be adapted to online CIL. To better reflect the contribution of our method, we adapt iCaRL (Rebuffi et al., 2017) and BiC (Wu et al., 2019) to online CIL and compare modified iCaRL and modified BiC with our method in Table 3. iCaRL replaces softmax classifier with NCM classifier and BiC uses a linear bias correction layer to reduce logits bias. and iCaRL is modified in the following way: at each iteration, we minimize binary CE loss used by iCaRL which encourages the model to mimic the outputs for all learned classes of the old model after the last iteration. We use reservoir sampling for memory update. NCM classifier is used for inference. For modified BiC, we use the linear bias correction layer of BiC to correct the logits for all learned classes only before test as task boundaries are unavailable in online CIL setting. As shown in Table 3, modified iCaRL performs very badly and the performances of modified BIC are much worse than our method. These results imply adapting existing methods to online setting can not alleviate logits bias effectively for online CIL. Therefore, our method makes a substantial contribution for online CIL.
175
+
176
+ Table 3: The comparison between modified iCaRL, modified BiC and our method (Ours) on Split datasets.
177
+
178
+ <table><tr><td>Methods</td><td>MNIST (5-task)</td><td>CIFAR10 (5-task)</td><td>CIFAR100 (20-task)</td><td>miniImageNet (20-task)</td></tr><tr><td>modified iCaRL</td><td>34.58</td><td>29.77</td><td>5.38 ±0.26</td><td>7.16</td></tr><tr><td>modified BiC</td><td>±1.18 83.33</td><td>±0.91 43.65</td><td>8.72</td><td>±0.33 7.91</td></tr><tr><td>Ours</td><td>±1.35 88.79 ±0.26</td><td>±2.50 51.84 ±0.91</td><td>±0.30 13.65 ±0.35</td><td>±0.55 15.15 ±0.36</td></tr></table>
179
+
180
+ ![](images/1a0db5ccaea95c33803559fd82b40d85abc7d7dc510597aed4dc362af581948f.jpg)
181
+ Figure 4: Comparison of training time (a) and test time (b) on Split CIFAR100 and miniImageNet. The number of tasks is 10.
182
+
183
+ Table 4: Ablation study on Split CIFAR10 and 20- task Split CIFAR100. We show the performances of different combinations of losses and inference ways. Dis: Discriminative, Gen: Generative.
184
+
185
+ <table><tr><td>Training</td><td>Inference</td><td>CIFAR10</td><td>CIFAR100</td></tr><tr><td>CEloss</td><td>Softmax (Dis)</td><td>39.88±1.52</td><td>8.95±0.26</td></tr><tr><td>CE loss</td><td>NCM(Gen)</td><td>44.46±0.95</td><td>8.96±0.38</td></tr><tr><td>MS loss</td><td>NCM (Gen)</td><td>51.72±1.02</td><td>9.99±0.32</td></tr><tr><td>PNCA loss</td><td>NCM (Gen)</td><td>41.91±1.78</td><td>9.31±0.58</td></tr><tr><td>Hybrid loss</td><td>Proxy (Dis)</td><td>48.16±1.21</td><td>7.02±0.75</td></tr><tr><td>Hybrid loss</td><td>NCM (Gen)</td><td>51.84±0.91</td><td>13.65±0.35</td></tr></table>
186
+
187
+ Table 5: Final accuracy of 15 runs on Smooth datasets.
188
+
189
+ <table><tr><td>Method</td><td>CIFAR10</td><td>CIFAR100</td><td>miniImageNet</td></tr><tr><td>fine-tune</td><td>10.02±0.03</td><td>1.02±0.03</td><td>1.02±0.04</td></tr><tr><td>ER-reservoir</td><td>20.89±2.07</td><td>3.84±0.42</td><td>6.85±0.70</td></tr><tr><td>MIR</td><td>18.75±2.53</td><td>4.35±0.53</td><td>6.09±1.04</td></tr><tr><td>GMED-MIR</td><td>18.78±2.31</td><td>3.68±0.48</td><td>7.22±0.81</td></tr><tr><td>Ours</td><td>34.18±0.81</td><td>10.54±0.38</td><td>12.24±0.19</td></tr><tr><td>i.i.d online</td><td>31.23±2.11</td><td>18.08±0.62</td><td>17.23±0.42</td></tr><tr><td>i.i.d offline</td><td>48.37±1.23</td><td>42.68±0.37</td><td>39.82±0.46</td></tr></table>
190
+
191
+ Time Comparison In Figure 4a, we report the training time of different methods. The training time of our method is only a bit higher than ER-reservoir.
192
+
193
+ Most baselines, such as GSS, MIR, and GMED, improve ER-reservoir by designing new memory update and sampling strategies which depend on extra gradient computations and thus are timeconsuming. The inference costs of softmax classifier and our NCM classifier are displayed in Figure 4b. We can find the extra time of NCM to compute the class means is (about $3 \%$ ) slight, as the size of memory is limited.
194
+
195
+ # 4.3 RESULTS ON TASK-FREE Smooth DATASETS
196
+
197
+ In newly designed task-free Smooth datasets, the new classes emerge irregularly and the distribution on class changes at each time step. In Table 5, we compare our method with several baselines on three smooth datasets. The metric is final accuracy after learning the whole data stream. We can find these datasets are indeed more complex as fine-tune can only classify correctly on the last class, which is due to the higher imbalance of data streams. For this reason, baselines such as ER-reservoir and MIR degrade obviously compared with split datsets. However, our method performs best consistently.
198
+
199
+ # 5 CONCLUSION
200
+
201
+ In this work, we tackle with online CIL problem from a generative perspective to bypass logits bias problem in commonly used softmax classifier. We first propose to replace softmax classifier with a generative classifier. Then we introduce MS loss for training and prove theoretically that it optimizes the feature space in a generative way. We further propose a hybrid loss to boost the model’s ability to learn from new data. Experimental results show the significant and consistent superiority of our method compared to existing state-of-the-art methods.
202
+
203
+ # REFERENCES
204
+
205
+ Hongjoon Ahn and Taesup Moon. A simple class decision balancing for incremental learning. CoRR, abs/2003.13947, 2020. URL https://arxiv.org/abs/2003.13947.
206
+
207
+ Rahaf Aljundi, Eugene Belilovsky, Tinne Tuytelaars, Laurent Charlin, Massimo Caccia, Min Lin, and Lucas Page-Caccia. Online continual learning with maximal interfered retrieval. In NeurIPS, 2019a. URL http://papers.nips.cc/paper/ 9357-online-continual-learning-with-maximal-interfered-retrieval.
208
+
209
+ Rahaf Aljundi, Klaas Kelchtermans, and Tinne Tuytelaars. Task-free continual learning. In CVPR, 2019b. doi: 10.1109/CVPR.2019.01151. URL http://openaccess.thecvf.com/content_CVPR_2019/ html/Aljundi_Task-Free_Continual_Learning_CVPR_2019_paper.html.
210
+
211
+ Rahaf Aljundi, Min Lin, Baptiste Goujaud, and Yoshua Bengio. Gradient based sample selection for online continual learning. In NeurIPS, 2019c. URL http://papers.nips.cc/paper/ 9354-gradient-based-sample-selection-for-online-continual-learning.
212
+
213
+ Eden Belouadah and Adrian Popescu. IL2M: class incremental learning with dual memory. In ICCV, 2019.
214
+
215
+ Guillaume Bouchard and Bill Triggs. The tradeoff between generative and discriminative classifiers. 2004.
216
+
217
+ Malik Boudiaf, Jérôme Rony, Imtiaz Masud Ziko, Eric Granger, Marco Pedersoli, Pablo Piantanida, and Ismail Ben Ayed. A unifying mutual information view of metric learning: Cross-entropy vs. pairwise losses. In ECCV, 2020. doi: 10.1007/978-3-030-58539-6\_33. URL https://doi.org/10. 1007/978-3-030-58539-6_33.
218
+
219
+ Arslan Chaudhry, Marc’Aurelio Ranzato, Marcus Rohrbach, and Mohamed Elhoseiny. Efficient lifelong learning with A-GEM. In ICLR, 2019a. URL https://openreview.net/forum?id=Hkf2_ sC5FX.
220
+
221
+ Arslan Chaudhry, Marcus Rohrbach, Mohamed Elhoseiny, Thalaiyasingam Ajanthan, Puneet K Dokania, Philip HS Torr, and Marc’Aurelio Ranzato. On tiny episodic memories in continual learning. arXiv preprint arXiv:1902.10486, 2019b.
222
+
223
+ Xiaoan Ding, Tianyu Liu, Baobao Chang, Zhifang Sui, and Kevin Gimpel. Discriminativelytuned generative classifiers for robust natural language inference. In EMNLP, 2020. URL https://www.aclweb.org/anthology/2020.emnlp-main.657/.
224
+
225
+ Chrisantha Fernando, Dylan Banarse, Charles Blundell, Yori Zwols, David Ha, Andrei A. Rusu, Alexander Pritzel, and Daan Wierstra. Pathnet: Evolution channels gradient descent in super neural networks. CoRR, abs/1701.08734, 2017.
226
+
227
+ Raia Hadsell, Sumit Chopra, and Yann LeCun. Dimensionality reduction by learning an invariant mapping. In CVPR, 2006.
228
+
229
+ Elad Hoffer and Nir Ailon. Deep metric learning using triplet network. In ICLR Workshop, 2015. URL http://arxiv.org/abs/1412.6622.
230
+
231
+ Xisen Jin, Junyi Du, and Xiang Ren. Gradient based memory editing for task-free continual learning. CoRR, abs/2006.15294, 2020. URL https://arxiv.org/abs/2006.15294.
232
+
233
+ James Kirkpatrick, Razvan Pascanu, Neil Rabinowitz, Joel Veness, Guillaume Desjardins, et al. Overcoming catastrophic forgetting in neural networks. PNAS, 2017.
234
+
235
+ Alex Krizhevsky, Geoffrey Hinton, et al. Learning multiple layers of features from tiny images. 2009.
236
+
237
+ Matthias De Lange and Tinne Tuytelaars. Continual prototype evolution: Learning online from non-stationary data streams. CoRR, abs/2009.00919, 2020. URL https://arxiv.org/abs/2009.00919.
238
+
239
+ Matthias De Lange, Rahaf Aljundi, Marc Masana, Sarah Parisot, Xu Jia, Ales Leonardis, Gregory G. Slabaugh, and Tinne Tuytelaars. Continual learning: A comparative study on how to defy forgetting in classification tasks. CoRR, abs/1909.08383, 2019. URL http://arxiv.org/abs/1909.08383.
240
+
241
+ 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.
242
+
243
+ Soochan Lee, Junsoo Ha, Dongsu Zhang, and Gunhee Kim. A neural dirichlet process mixture model for task-free continual learning. In ICLR, 2020. URL https://openreview.net/forum?id $\vDash$ SJxSOJStPr.
244
+
245
+ Zhizhong Li and Derek Hoiem. Learning without forgetting. TPAMI, 2018.
246
+
247
+ Zheda Mai, Dongsub Shim, Jihwan Jeong, Scott Sanner, Hyunwoo Kim, and Jongseong Jang. Online class-incremental continual learning with adversarial shapley value. AAAI, abs/2009.00093, 2021.
248
+
249
+ Arun Mallya and Svetlana Lazebnik. Packnet: Adding multiple tasks to a single network by iterative pruning. In CVPR, 2018.
250
+
251
+ Michael McCloskey and Neal J Cohen. Catastrophic interference in connectionist networks: The sequential learning problem. In Psychology of learning and motivation. Elsevier, 1989.
252
+
253
+ Thomas Mensink, Jakob J. Verbeek, Florent Perronnin, and Gabriela Csurka. Distance-based image classification: Generalizing to new classes at near-zero cost. TPAMI, 35, 2013. doi: 10.1109/TPAMI.2013.83. URL https://doi.org/10.1109/TPAMI.2013.83.
254
+
255
+ Yair Movshovitz-Attias, Alexander Toshev, Thomas K. Leung, Sergey Ioffe, and Saurabh Singh. No fuss distance metric learning using proxies. In ICCV, 2017.
256
+
257
+ Andrew Y. $\mathrm { N g }$ and Michael I. Jordan. On discriminative vs. generative classifiers: A comparison of logistic regression and naive bayes. In NIPS, 2001. URL http://papers.nips.cc/paper/ 2020-on-discriminative-vs-generative-classifiers-a-comparison-of-logistic-regression-and-naive-bayes.
258
+
259
+ German Ignacio Parisi, Ronald Kemker, Jose L. Part, Christopher Kanan, and Stefan Wermter. Continual lifelong learning with neural networks: A review. Neural Networks, 2019.
260
+
261
+ Sylvestre-Alvise Rebuffi, Alexander Kolesnikov, Georg Sperl, and Christoph H Lampert. icarl: Incremental classifier and representation learning. In CVPR, 2017.
262
+
263
+ Matthew Riemer, Ignacio Cases, Robert Ajemian, Miao Liu, Irina Rish, Yuhai Tu, and Gerald Tesauro. Learning to learn without forgetting by maximizing transfer and minimizing interference. In ICLR, 2019. URL https://openreview.net/forum?id $\ c =$ B1gTShAct7.
264
+
265
+ Anthony V. Robins. Catastrophic forgetting, rehearsal and pseudorehearsal. Connect. Sci., 7(2), 1995. doi: 10.1080/09540099550039318. URL https://doi.org/10.1080/09540099550039318.
266
+
267
+ Hanul Shin, Jung Kwon Lee, Jaehong Kim, and Jiwon Kim. Continual learning with deep generative replay. In NIPS, 2017.
268
+
269
+ Gido M. van de Ven and Andreas S. Tolias. Three scenarios for continual learning. In NeurIPS Continual Learning workshop, 2018.
270
+
271
+ Oriol Vinyals, Charles Blundell, Tim Lillicrap, Koray Kavukcuoglu, and Daan Wierstra. Matching networks for one shot learning. In Advances in Neural Information Processing Systems 29: Annual Conference on Neural Information Processing Systems 2016, December 5-10, 2016, Barcelona, Spain, pp. 3630–3638, 2016. URL http://papers.nips.cc/paper/ 6385-matching-networks-for-one-shot-learning.
272
+
273
+ Jeffrey S. Vitter. Random sampling with a reservoir. ACM Transactions on Mathematical Software (TOMS), 1985.
274
+
275
+ Xun Wang, Xintong Han, Weilin Huang, Dengke Dong, and Matthew R. Scott. Multi-similarity loss with general pair weighting for deep metric learning. In CVPR, 2019. doi: 10.1109/CVPR.2019. 00516. URL http://openaccess.thecvf.com/content_CVPR_2019/html/Wang_Multi-Similarity_ Loss_With_General_Pair_Weighting_for_Deep_Metric_Learning_CVPR_2019_paper.html.
276
+
277
+ Yue Wu, Yinpeng Chen, Lijuan Wang, Yuancheng Ye, Zicheng Liu, Yandong Guo, and Yun Fu. Large scale incremental learning. In CVPR, 2019.
278
+
279
+ Dani Yogatama, Chris Dyer, Wang Ling, and Phil Blunsom. Generative and discriminative text classification with recurrent neural networks. CoRR, abs/1703.01898, 2017. URL http://arxiv.org/ abs/1703.01898.
280
+
281
+ Lu Yu, Bartlomiej Twardowski, Xialei Liu, Luis Herranz, Kai Wang, Yongmei Cheng, Shangling Jui, and Joost van de Weijer. Semantic drift compensation for class-incremental learning. In CVPR, 2020.
282
+
283
+ Chen Zeno, Itay Golan, Elad Hoffer, and Daniel Soudry. Task agnostic continual learning using online variational bayes. arXiv preprint arXiv:1803.10123, 2018.
284
+
285
+ Bowen Zhao, Xi Xiao, Guojun Gan, Bin Zhang, and Shu-Tao Xia. Maintaining discrimination and fairness in class incremental learning. In CVPR, 2020.
286
+
287
+ A PROOFS
288
+
289
+ # A.1 PROPOSITION 1
290
+
291
+ Proof. For simplicity, we ignore the coefficient $\textstyle { \frac { 1 } { n } }$ both in $\mathcal { L } _ { M S }$ and $\mathcal { L } _ { G e n - B i n }$ in the proof. We denote the two parts in the summation of $\mathcal { L } _ { M S }$ as $\mathcal { L } _ { M S } ^ { + }$ and $\mathcal { L } _ { M S } ^ { - }$ respectively, i.e.:
292
+
293
+ $$
294
+ \begin{array} { l } { { \displaystyle { \mathcal L } _ { M S } ^ { + } = \sum _ { i = 1 } ^ { n } \frac { 1 } { \alpha } \log [ 1 + \sum _ { j \in { \mathcal P } _ { i } } e ^ { - \alpha ( S _ { i j } - \lambda ) } ] } } \\ { { \displaystyle { \mathcal L } _ { M S } ^ { - } = \sum _ { i = 1 } ^ { n } \frac { 1 } { \beta } \log [ 1 + \sum _ { j \in { \mathcal N } _ { i } } e ^ { \beta ( S _ { i j } - \lambda ) } ] } } \end{array}
295
+ $$
296
+
297
+ Without hard mining, for $\mathcal { L } _ { M S } ^ { + }$ we have:
298
+
299
+ $$
300
+ \begin{array} { l } { \displaystyle \mathcal { L } _ { M S } ^ { + } = \sum _ { i = 1 } ^ { n } \frac { 1 } { \alpha } \log [ 1 + \sum _ { j : y _ { j } = y _ { i } } e ^ { - \alpha ( S _ { i j } - \lambda ) } ] } \\ { \displaystyle \quad \geq \sum _ { i = 1 } ^ { n } \frac { 1 } { \alpha } \log [ \sum _ { j : y _ { j } = y _ { i } } e ^ { - \alpha ( S _ { i j } - \lambda ) } ] } \\ { \displaystyle \quad \sum _ { i = 1 } ^ { \mathtt { c } } \frac { n } { \alpha } \big [ \frac { 1 } { n _ { 0 } } \sum _ { j : y _ { j } = y _ { i } } \log e ^ { - \alpha ( S _ { i j } - \lambda ) } \big ] } \end{array}
301
+ $$
302
+
303
+ $$
304
+ \begin{array} { l } { { \displaystyle = \sum _ { i = 1 } ^ { n } \frac { 1 } { n _ { 0 } } [ \sum _ { j : y _ { j } = y _ { i } } - ( S _ { i j } - \lambda ) ] } } \\ { { \displaystyle \stackrel { \mathrm { c } } { = } - \sum _ { i = 1 } ^ { n } \frac { 1 } { n _ { 0 } } \sum _ { y _ { j } = y _ { i } } S _ { i j } } } \end{array}
305
+ $$
306
+
307
+ where $\underline { { \underline { { \mathbf { c } } } } }$ stands for equal to, up to an additive constant. For $\mathcal { L } _ { M S } ^ { - }$ we can write:
308
+
309
+ $$
310
+ \begin{array} { r l } { \mathcal { L } _ { M S } ^ { - } = } & { \displaystyle \sum _ { i = 1 } ^ { n } \frac { 1 } { \beta } \log [ 1 + \sum _ { j : \lambda _ { j } \neq j \neq \lambda _ { i } } e ^ { \beta ( S _ { i j } - \lambda ) } ] } \\ & { \ge \displaystyle \sum _ { i = 1 } ^ { n } \frac { 1 } { \beta } \log [ \sum _ { j : \geqslant j \neq j \neq i } e ^ { \beta ( S _ { i j } - \lambda ) } ] } \\ & { \stackrel { \mathrm { C } } { \ge } \displaystyle \sum _ { i = 1 } ^ { n } \frac { 1 } { \beta } \big [ \frac { 1 } { n _ { 0 } ( C - 1 ) } \sum _ { j : \geqslant j \neq j \neq i } \log e ^ { \beta ( S _ { i j } - \lambda ) } \big ] } \\ & { \quad \mathrm { ~ \ ~ \ } \mathrm { ~ \ ~ } \mathrm { ~ \ ~ } \mathrm { ~ \ ~ } \mathrm { ~ \ ~ } \mathrm { ~ \ ~ } \mathrm { ~ \ ~ } } \\ & { = \displaystyle \sum _ { i = 1 } ^ { n } \frac { 1 } { n _ { 0 } ( C - 1 ) } \sum _ { j : \in \lambda \neq j \neq i } S _ { i j } } \\ & { = \displaystyle \sum _ { i = 1 } ^ { n } \frac { 1 } { n _ { 0 } ( C - 1 ) } \sum _ { j : \in \lambda \neq j \neq i } \ S _ { i j } } \end{array}
311
+ $$
312
+
313
+ According to Eq (10) and Eq (11), we have:
314
+
315
+ $$
316
+ \mathcal { L } _ { M S } \overset { \mathrm { c } } { \geq } \sum _ { i = 1 } ^ { n } \big \{ - \frac { 1 } { n _ { 0 } } \sum _ { j : y _ { j } = y _ { i } } S _ { i j } + \frac { 1 } { ( C - 1 ) n _ { 0 } } \sum _ { j : y _ { j } \neq y _ { i } } S _ { i j } \big \}
317
+ $$
318
+
319
+ Now we consider $\mathcal { L } _ { G e n - B i n }$ . Firstly, it can be written:
320
+
321
+ $$
322
+ \begin{array} { l } { { \displaystyle { \mathcal { L } } _ { G e n - B i n } \ { \stackrel { \mathbb { C } } { = } } \ \sum _ { i = 1 } ^ { n } \big \{ \ - \log p ( z _ { i } | y = y _ { i } ) } \ ~ } \\ { { \displaystyle ~ + \ \frac { 1 } { C - 1 } \sum _ { c = 1 , c \neq y _ { i } } ^ { C } \log p ( z _ { i } | y = c ) \big \} } } \end{array}
323
+ $$
324
+
325
+ For convenience, we denote the features of data samples whose labels are $c$ as $\{ z _ { c _ { i } } \} _ { i = 1 } ^ { n _ { 0 } }$ . For the first part in the right hand of $\operatorname { E q }$ (13), we have:
326
+
327
+ $$
328
+ \begin{array} { r l } & { \frac { \sqrt { 2 } } { \pi } - \frac { 1 } { 4 } \eta \xi _ { 2 } ^ { 2 } \xi _ { 3 } - \frac { \pi } { 2 } \eta \xi _ { 3 } } \\ & { = \xi _ { 3 } ^ { 2 } \frac { \sqrt { 2 } } { \pi } \left( 1 - \frac { \pi } { 2 } \xi _ { 3 } ^ { 2 } \xi _ { 3 } - \frac { \pi } { 2 } \xi _ { 3 } ^ { 2 } \xi _ { 4 } \right) } \\ & { \quad + \frac { \pi } { 2 } \frac { \sqrt { 2 } } { \pi } \left[ 1 - \frac { \pi } { 2 } \xi _ { 3 } ^ { 2 } \xi _ { 4 } - \frac { \pi } { 2 } \xi _ { 3 } ^ { 2 } \xi _ { 4 } ^ { 2 } \right] } \\ & { \quad + \frac { \pi } { 2 } \frac { \sqrt { 2 } } { \pi } \sum _ { i = 1 } ^ { N } \xi _ { i } \xi _ { i } ^ { 2 } \xi _ { 1 } ^ { 2 } } \\ & { = \xi _ { 2 } \frac { \sqrt { 2 } } { \pi } \sum _ { i = 1 } ^ { N } \xi _ { i } \xi _ { i } ^ { 2 } \xi _ { 2 } ^ { 2 } \frac { \pi } { 2 } \xi _ { 3 } ^ { 2 } \xi _ { 3 } ^ { 2 } \frac { \pi } { 2 } \xi _ { 4 } ^ { 2 } \left| \xi _ { 2 } ^ { 2 } \right| ^ { 2 } } \\ & { \quad - \frac { \pi } { 2 } \sum _ { i = 1 } ^ { N } \frac { \pi } { 2 } \xi _ { i } ^ { 2 } \xi _ { 3 } ^ { 2 } \xi _ { 4 } ^ { 2 } \left| \xi _ { 2 } ^ { 2 } \xi _ { 3 } ^ { 2 } \xi _ { 4 } ^ { 2 } \right| ^ { 2 } } \\ & { \quad \le \frac { \pi } { 2 } \frac { \sqrt { 2 } } { \pi } \sum _ { i = 1 } ^ { N } \xi _ { i } ^ { 2 } \xi _ { 4 } ^ { 2 } \xi _ { 1 } ^ { 2 } \xi _ { 2 } ^ { 2 } \xi _ { 3 } ^ { 2 } \xi _ { 4 } ^ { 2 } \xi _ { 1 } ^ { 2 } \xi _ { 2 } ^ { 2 } \xi _ { 3 } ^ { 2 } } \\ & \quad - \frac { \pi } { 2 } \sum _ { i = 1 } ^ { N } \xi _ { i } ^ { 2 } \xi _ { i } ^ { 2 } \xi _ { 2 } ^ 2 \end{array}
329
+ $$
330
+
331
+ Keep in mind that the mean of class c $\begin{array} { r } { { \pmb \mu } _ { c } ^ { D } = \frac { 1 } { n _ { 0 } } \sum _ { i = 1 } ^ { n _ { 0 } } z _ { c _ { i } } } \end{array}$ . For the second part in the right hand of Eq (13), we have:
332
+
333
+ $$
334
+ \begin{array} { r l } & { \frac { \displaystyle Y } { \displaystyle c - 1 } \sum _ { i = 1 } ^ { N } \log ( \rho _ { i } | z _ { i } | y - c ) } \\ & { = \frac { 1 } { 2 } \sum _ { i = 1 , \ldots , i \neq j \in W } ^ { \infty } - \| z _ { i } - \mu _ { i } ^ { \mathrm { E } } \| _ { 2 } ^ { 2 } } \\ & { = \frac { 1 } { 2 } \sum _ { i = 1 , \ldots , i \neq j \in W } ^ { \infty } \left\{ - \| z _ { i } - \mu _ { i } ^ { \mathrm { E } } \| _ { 2 } ^ { 2 } + 2 \| z _ { i } ^ { \mathrm { E } } \| _ { 2 } ^ { 2 } - \| z _ { i } ^ { \mathrm { E } } \| _ { 2 } ^ { 2 } \right\} \frac { \displaystyle Y } { \displaystyle c - 1 } } \\ & { - \frac { 1 } { 2 } \sum _ { i = 1 , \ldots , i \neq j \in W } ^ { \infty } \Big \{ - \| z _ { i } \| _ { 2 } ^ { 2 } + 2 \| z _ { i } ^ { \mathrm { E } } \| _ { 2 } ^ { 2 } - \| z _ { i } ^ { \mathrm { E } } \| _ { 2 } ^ { 2 } \Big \} \frac { \displaystyle Y } { \displaystyle c - 1 } \Big [ \| z _ { i } ^ { \mathrm { E } } \| _ { 2 } ^ { 2 } \Big ] \frac { \displaystyle Y } { \displaystyle c - 1 } } \\ & { \frac { \displaystyle C } { \displaystyle c - 1 } \sum _ { i = 1 , \ldots , i \neq j \in W } ^ { \infty } \frac { C } { \displaystyle c - 1 } \sum _ { i = 1 } ^ { N } \frac { C } { \displaystyle c - 1 } \| z _ { i } ^ { \mathrm { E } } \| _ { 2 } ^ { 2 } \Big ] ^ { 2 } \frac { \displaystyle Y } { \displaystyle c - 1 } \| z _ { i } ^ { \mathrm { E } } \| _ { 2 } ^ { 2 } - | Y | } \\ & { = \frac { 1 } { 2 } \sum _ { i = 1 } ^ { N } \displaystyle \sum _ { j = 0 } ^ { C } \frac { 2 } { \displaystyle c - 1 } \sum _ { i = 1 } ^ { N } \frac { C - 1 } { \displaystyle c - 1 } \sum _ { i = 1 } ^ { N } \sum _ { j = 1 } ^ { N } \sum _ { i = 1 } ^ { N } \frac { C - 1 } { \displaystyle c - 1 } \sum _ { j = 1 } ^ { N } \sum _ { i = 1 } ^ { N } \frac { C - 1 } { \displaystyle c - 1 } } \\ & - \frac { 1 } \displaystyle c - \end{array}
335
+ $$
336
+
337
+ According to Eq (14) and Eq (15), we have:
338
+
339
+ $$
340
+ \mathcal { L } _ { G e n - B i n } \overset { \mathtt { C } } { = } \sum _ { i = 1 } ^ { n } \big \{ - \frac { 1 } { n _ { 0 } } \sum _ { j : y _ { j } = y _ { i } } S _ { i j } + \frac { 1 } { ( C - 1 ) n _ { 0 } } \sum _ { j : y _ { j } \neq y _ { i } } S _ { i j } \big \}
341
+ $$
342
+
343
+ According to Eq (12) and Eq (16), we can obtain:
344
+
345
+ $$
346
+ \mathcal { L } _ { M S } \stackrel { \mathrm { c } } { \geq } \mathcal { L } _ { G e n - B i n }
347
+ $$
348
+
349
+ # B DETAILS ABOUT EXPERIMENT SETUP
350
+
351
+ # B.1 SPLIT DATASETS
352
+
353
+ In Table 6 we show the detailed statistics about Split datasets. On MNIST (LeCun et al., 1998), we randomly select 500 samples of the original training data for each class as training data stream, following previous works (Aljundi et al., 2019a;c; Jin et al., 2020). On CIFAR10 and CIFAR100 (Krizhevsky et al., 2009), We use the full training data from which $5 \%$ samples are regarded as validation set. The original miniImageNet dataset is used for meta learning (Vinyals et al., 2016) and 100 classes are divided into 64 classes, 16 classes, 20 classes respectively for meta-training, meta-validation and meta-test respectively. We merge all 100 classes to conduct class-incremental learning. There are 600 samples per class in miniImageNet. We divide 600 samples into 456 samples, 24 samples and 120 samples for training, validation and test respectively. We do not adopt any data augmentation strategy.
354
+
355
+ # B.2 SMOOTH DATASETS
356
+
357
+ For a data stream with $C$ classes, we assume the length of stream is $N$ and $\begin{array} { r } { n _ { 0 } = \frac { N } { c } } \end{array}$ . We denote $p _ { c } ( t )$ as the occurrence probability of class $c$ at time step $t$ and assume $\begin{array} { r } { p _ { c } ( t ) \sim \mathcal { N } ( t | \frac { ( 2 c - 1 ) n _ { 0 } } { 2 } , \frac { n _ { 0 } } { c } ) } \end{array}$ . At each time step $t$ , we calculate $p ( t ) = ( p _ { 1 } ( t ) , . . . , p _ { C } ( t ) )$ and normalize $p ( t )$ as the parameters of a Categorical distribution from which a class index ct is sampled. Then we sample one data of class ct without replacement. In this setting, data distribution changes smoothly and there is no notion of task. We call such data streams as Smooth datasets.
358
+
359
+ Here we show the characteristics of Smooth datasets in detail. In Table 7, we list the detailed statistics of Smooth datasets. Due to the randomness in the data stream generation process, the number of samples of each class is slightly imbalanced. On CIFAR100 and miniImageNet we set the mean number of samples of each class $n _ { 0 } = 4 0 0$ to avoid invalid sampling when exceeding the maximum number of sample of one class in the original training set. The last rows of Table 7 show the range of number of samples of each classes in our experiments. For example, in 15 repeated runs, 15 different Smooth CIFAR10 data streams are established. The number of samples of each class is in the interval [464, 536]. It should be emphasized that in all experiments we use the same random seed to obtain the identical 15 data streams for fair comparison.
360
+
361
+ Table 6: Details about Split datasets.
362
+
363
+ <table><tr><td>Dataset</td><td>MNIST</td><td>CIFAR10</td><td>CIFAR100</td><td>miniImageNet</td></tr><tr><td>Image Size</td><td>(1,32,32)</td><td>(3,32,32)</td><td>(3,32,32)</td><td>(3,84,84)</td></tr><tr><td>#Classes</td><td>10</td><td>10</td><td>100</td><td>100</td></tr><tr><td>#Train Samples</td><td>5000</td><td>47500</td><td>47500</td><td>45600</td></tr><tr><td>#Valid Samples</td><td>10000</td><td>2500</td><td>2500</td><td>2400</td></tr><tr><td>#Test Samples</td><td>10000</td><td>10000</td><td>10000</td><td>12000</td></tr><tr><td>#Task</td><td>5</td><td>5</td><td>10 or 20</td><td>10 or 20</td></tr><tr><td>#Classes per Task</td><td>2</td><td>2</td><td>10 or 5</td><td>10 or 5</td></tr></table>
364
+
365
+ Some existing works (Zeno et al., 2018; Lee et al., 2020) also experiment on task-free datasets where a data stream is still divided into different tasks but the switch of task is gradual instead of abrupt. In fact, in their settings, task switching only occurs in a part of time, so that in the left time the distribution of data streams is still i.i.d. In contrast, in our Smooth datasets the distribution changes at the class level which simulates task-free class-incremental setting. In addition, the distribution of data streams is never i.i.d, which can reflect real-world CL scenarios better.
366
+
367
+ In Figure 5, we plot the curves of training loss of ER-reservoir on Split CIFAR10 and Smooth CIFAR10. When a new task emerges (each task consists of 100 iterations), the loss on Split CIFAR10 increases dramatically. Thus some methods can detect the change of loss to inference the task boundaries although they are not informed and conduct additional offline training phase (Aljundi et al., 2019b). However, such a trick is not applicable on Smooth datasets therefore only the real online CL methods can work.
368
+
369
+ Table 7: Details about Smooth datasets.
370
+
371
+ <table><tr><td>Dataset</td><td>CIFAR10</td><td>CIFAR100</td><td>miniImageNet</td></tr><tr><td>#Classes (C)</td><td>10</td><td>100</td><td>100</td></tr><tr><td>#Train Samples (length of data stream) (n)</td><td>5000</td><td>40000</td><td>40000</td></tr><tr><td>#Valid Samples</td><td>2500</td><td>2500</td><td>2400</td></tr><tr><td>#Test Samples</td><td>10000</td><td>10000</td><td>12000</td></tr><tr><td>Mean number of samples of one class (no)</td><td>500</td><td>400</td><td>400</td></tr><tr><td>Minimum number of samples of one class</td><td>464</td><td>357</td><td>354</td></tr><tr><td>Maximum number of samples of one class</td><td>536</td><td>450</td><td>446</td></tr></table>
372
+
373
+ # B.3 HYPERPARAMETER SELECTION
374
+
375
+ In our method, although there are several hyperparameters in $\mathcal { L } _ { M S }$ and $\mathcal { L } _ { P N C A }$ , we only need to tune $\gamma$ which is the weight of $\mathcal { L } _ { P N C A }$ in $\mathcal { L } _ { H y b r i d }$ . The value of other hyperparameters in $\mathcal { L } _ { H y b r i d }$ is fixed as stated in the main text. We select $\gamma$ from $[ 0 , 0 . 1 , 0 . 2 5 , 0 . 5 , 0 . 7 5 , 1 . 0 , 1 . 2 5 , 1 . 5 , 2 . 0 ]$ . Especially, $\gamma = 0$ makes $\mathcal { L } _ { H y b r i d }$ become $\mathcal { L } _ { M S }$ .
376
+
377
+ We follow previous works to use SGD optimizer in all experiments. However, we find compared to CE loss, a wider range of learning rate $\eta$ should be searched in for DML losses. Previous works are based on CE loss and always set $\eta = 0 . 0 5$ or $\eta = 0 . 1$ (Aljundi et al., $2 0 1 9 \mathrm { c ; a }$ ; Jin et al., 2020; Mai et al., 2021). We find the optimal $\eta$ for $\mathcal { L } _ { H y b r i d }$ is often larger than 0.1. However, when a larger $\eta$ (e.g. 0.2 on MNIST and CIFAR10) is used, baselines based on CE loss will degrade obviously because of the unstable results over multiple runs. Thus, for baselines we select $\eta$ from [0.05, 0.1, 0.15, 0.2]. For our method, we select $\eta$ from [0.05, 0.1, 0.15, 0.2, 0.25, 0.3, 0.35, 0.4, 0.45, 0.5]. The hyperparameters of our method are displayed in Table 8.
378
+
379
+ ![](images/79986763a8b551615b25098d5af4c5efcc9de4b970b524345bc2ff1b9b74353b.jpg)
380
+ Figure 5: The curves of training loss on Split CIFAR10 (left) and Smooth CIFAR10 (right). Split CIFAR10 comprises of 5 tasks, 100 iterations per task.
381
+
382
+ <table><tr><td></td><td colspan="4">Split Datasets</td><td colspan="3">Smooth Datasets</td></tr><tr><td></td><td>MNIST</td><td>CIFAR10</td><td>CIFAR100</td><td>miniImageNet</td><td>CIFAR10</td><td>CIFAR100</td><td>miniImageNet</td></tr><tr><td>Y</td><td>0.1</td><td>0.1</td><td>0.5</td><td>1</td><td>0.1</td><td>1.0</td><td>1.0</td></tr><tr><td>m</td><td>0.05</td><td>0.2</td><td>0.35</td><td>0.2</td><td>0.25</td><td>0.5</td><td>0.2</td></tr></table>
383
+
384
+ Table 8: Hyperparamters of PNCA loss weight $\gamma$ and learning rate $\eta$ for our method on different datasets.
385
+
386
+ # B.4 EVALUATION METRICS
387
+
388
+ Following previous online CL works (Aljundi et al., $2 0 1 9 \mathrm { a }$ ; Mai et al., 2021), we use Average Accuracy and Average Forgetting (Chaudhry et al., 2019b) on Split datasets after training all $T$ tasks. Average Accuracy evaluates the overall performance and Average Forgetting measures how much learned knowledge has been forgetten. Let $a _ { k , j }$ denote the accuracy on the held-out set of the $j$ -th task after training the model on the first $k$ tasks. For a dataset comprised of $T$ tasks, the Average Accuracy is defined as follows:
389
+
390
+ $$
391
+ A _ { T } = \frac { 1 } { T } \sum _ { j = 1 } ^ { T } a _ { T , j }
392
+ $$
393
+
394
+ and Average Forgetting can be written as:
395
+
396
+ $$
397
+ f _ { j } ^ { T } = \operatorname* { m a x } _ { l \in \{ 1 , \dots , T - 1 \} } a _ { l , j } - a _ { T , j } , \forall j < T
398
+ $$
399
+
400
+ $$
401
+ F _ { T } = \frac { 1 } { T - 1 } \sum _ { j = 1 } ^ { T - 1 } f _ { j } ^ { T }
402
+ $$
403
+
404
+ We report Average Accuracy and Average Forgetting in the form of percentage. It should be noted that a higher Average Accuracy is better while a lower Average Forgetting is better.
405
+
406
+ On Smooth datasets, as there is no notion of task, we evaluate the performance with the accuracy on the whole held-out set after finishing training the whole training set.
407
+
408
+ # B.5 CODE DEPENDENCIES AND HARDWARE
409
+
410
+ The Python version is 3.7.6. We use the PyTorch deep learning library to implement our method and baselines. The version of PyTorch is 1.7.0. Other dependent libraries include Numpy (1.17.3), torchvision (0.4.1), matplotlib (3.1.2) and scikit-learn (0.22). The CUDA version is 10.2. We run all experiments on 1 NVIDIA RTX 2080ti GPU. We will publish our codes once the paper is accepted.
411
+
412
+ # C MORE EXPERIMENTAL RESULTS
413
+
414
+ # C.1 EFFECT OF PROXY-NCA LOSS WEIGHT $\gamma$
415
+
416
+ In Table 6, we show the effect of Proxy-NCA loss weight $\gamma$ on split datasets. We can find on MNIST and CIFAR10 where the number of classes is relatively small, although the best results are obtained with $\gamma = 0 . 1$ , we can have competitive results with $\gamma = 0$ . In other words, only using MS loss is effective enough. However, on CIFAR100 and miniImageNet, as discussed in main text, the expected number of classes in each minibatch is larger which reduces the probability of occurrence of positive pair so that limits the learning ability of pair-based MS loss. At this time, it is necessary to introduce auxiliary PNCA loss. When $\gamma$ is larger than 1, the performance begins to degrade, which implies that excessively focusing on discriminative PNCA loss will affect the performance of the generative NCM classifier.
417
+
418
+ ![](images/73e0bfdae669eb3a8fdc6a4da88091a10616e7eec730c055c6a9000439944413.jpg)
419
+ Figure 6: Average Accuracy on valid set of our method with different Proxy-NCA loss weight $\gamma$ in the 6 Split datasets as reported in Table 1 of main text. We report the mean of 15 runs.
420
+
421
+ ![](images/ad19eaa851e98c5a9ac6c73289ee8b9d640018c7b812b5860b1aebbfec7a3804.jpg)
422
+ Figure 7: Average Accuracy on valid set of ER-reservoir and our method with different size of $\mathcal { M }$ .
423
+
424
+ # C.2 RESULTS WITH DIFFERENT MEMORY SIZES
425
+
426
+ In Table 9 and Table 10, we report the performance of our method and all baselines compared in main text on Split CIFAR100 and miniImageNet with $2 \mathrm { k }$ memory size. Our method performs best in all settings and the improvements are obvious, which is similar with the results in 1k memory size settings reported in Table 1-2 of main text. We also report Average Accuracy of ER-reservoir and our method on valid set with a various of memory sizes. Our method outperforms ER-reservoir consistently which shows broad applicability of our method. The improvements are relatively small when memory size is 500 on CIFAR100 and miniImageNet, which is due to the fact that when size of replay memory $\mathcal { M }$ is too small (5 samples per class on average), class mean $\mu _ { c } ^ { \mathcal { M } }$ cannot approximate the real class mean $\mu _ { c } ^ { \mathcal { D } }$ well and thus proposed NCM classifier degrades.
427
+
428
+ # C.3 COMPARISON WITH TRIPLET LOSS
429
+
430
+ Yu et al. (2020) proposes SDC method for conventional CIL based on NCM classifier and another pair-based DML loss, triplet loss (Hoffer & Ailon, 2015). As discussed in Related Work of main text, SDC is not applicable for online CIL. To further clarify our contribution given this work, we evaluate the performance of NCM classifier after training the model with the hybrid objective $\mathcal { L } _ { T r i p l e t } + \gamma \mathcal { L } _ { P N C A }$ , where $\mathcal { L } _ { T r i p l e t }$ represents triplet loss. Please see Hoffer & Ailon (2015) and (Yu et al., 2020) for details about $\mathcal { L } _ { T r i p l e t }$ .
431
+
432
+ We report the results of the hybrid objective involving triplet loss and compare it with our hybrid loss $( \mathcal { L } _ { M S } + \gamma \mathcal { L } _ { P N C A } )$ in Table 11. We can find our proposed loss is superior to $\mathcal { L } _ { T r i p l e t } + \gamma \mathcal { L } _ { P N C A }$ consistently. In addition to replace softmax classifier with NCM classifier for online CIL problem, our contributions mainly reflect in introducing a hybrid of MS loss and PNCA loss in the view of training the generative NCM classifier. We believe the above results show MS loss is critical for online CIL, and introducing MS loss is not a trivial contribution, even if given the SDC work (Yu et al., 2020).
433
+
434
+ <table><tr><td>Methods</td><td>CIFAR100 (10-task)</td><td>CIFAR100 (20-task)</td><td>miniImageNet (10-task)</td><td>miniImageNet (20-task)</td></tr><tr><td>fine-tune</td><td>6.26±0.30</td><td>3.61±0.24</td><td>4.43±0.19</td><td>3.12±0.15</td></tr><tr><td>ER-reservoir</td><td>15.15±0.37</td><td>12.76±0.69</td><td>13.88±0.68</td><td>11.76±0.88</td></tr><tr><td>A-GEM (Chaudhry et al., 2019a)</td><td>6.50±0.16</td><td>3.61±0.08</td><td>4.41±0.14</td><td>3.23±0.13</td></tr><tr><td>GSS-Greedy (Aljundi et al., 2019c)</td><td>12.66±0.67</td><td>11.62±0.61</td><td>13.95±0.40</td><td>11.70±0.55</td></tr><tr><td>MIR (Aljundi et al., 2019a)</td><td>15.11±0.63</td><td>12.45±0.54</td><td>14.22±0.93</td><td>12.35±1.08</td></tr><tr><td>GMED-ER (Jin et al., 2020)</td><td>14.93±0.39</td><td>11.97±0.60</td><td>12.10±1.29</td><td>9.90±0.95</td></tr><tr><td>GMED-MIR (Jin et al., 2020)</td><td>15.11±0.50</td><td>12.01±0.81</td><td>13.90±0.58</td><td>12.25±0.59</td></tr><tr><td>ASERμ (Mai et al.,2021)*</td><td>17.20±0.50</td><td></td><td>14.80±1.10</td><td>一</td></tr><tr><td>Ours</td><td>18.96±0.42</td><td>16.69±0.76</td><td>19.17±0.38</td><td>17.10±0.58</td></tr><tr><td>i.i.d. online</td><td>20.62±0.48</td><td>20.62±0.48</td><td>18.02±0.63</td><td>18.02±0.63</td></tr><tr><td>i.i.d. offline</td><td>45.59±0.29</td><td>45.59±0.29</td><td>38.63±0.59</td><td>38.63±0.59</td></tr></table>
435
+
436
+ Table 9: Average Accuracy of 15 runs on Split datasets. Higher is better. ∗ indicates the results are from the original paper. The size of memory $\mathcal { M }$ is 2k.
437
+
438
+ <table><tr><td>Methods</td><td>CIFAR100 (10-task)</td><td>CIFAR100 (20-task)</td><td>miniImageNet (10-task)</td><td>miniImageNet (20-task)</td></tr><tr><td>fine-tune</td><td>51.60±0.77</td><td>65.51±0.78</td><td>41.12±0.82</td><td>52.99±0.89</td></tr><tr><td>ER-reservoir</td><td>40.19±0.71</td><td>52.45±0.85</td><td>32.91±0.79</td><td>44.93±0.81</td></tr><tr><td>A-GEM (Chaudhry et al., 2019a)</td><td>51.45±0.68</td><td>67.13±0.55</td><td>40.49±0.43</td><td>51.45±0.68</td></tr><tr><td>GSS-Greedy (Aljundi et al., 2019c)</td><td>40.02±0.81</td><td>45.90±2.09</td><td>30.50±0.83</td><td>39.09±2.34</td></tr><tr><td>MIR (Aljundi et al., 2019a)</td><td>39.82±0.79</td><td>48.54±0.60</td><td>29.27±1.32</td><td>39.74±1.50</td></tr><tr><td>GMED-ER (Jin et al.,2020)</td><td>42.99±0.75</td><td>55.45±0.68</td><td>31.81±1.73</td><td>43.68±1.23</td></tr><tr><td>GMED-MIR (Jin et al., 2020)</td><td>43.78±0.93</td><td>55.15±0.71</td><td>29.67±0.58</td><td>41.16±0.95</td></tr><tr><td>ASERμ (Mai et al., 2021)*</td><td>38.60±0.60</td><td>1</td><td>22.20±1.60</td><td>1</td></tr><tr><td>Ours</td><td>26.59±0.58</td><td>29.53±0.94</td><td>17.82±0.36</td><td>24.10±0.71</td></tr></table>
439
+
440
+ Table 10: Average Forgetting of 15 runs on Split datasets. Lower is better. ∗ indicates the results are from the original paper. The size of memory $\mathcal { M }$ is 2k.
441
+
442
+ <table><tr><td>Loss</td><td>MNIST (5-task)</td><td>CIFAR10 (5-task)</td><td>CIFAR100 (10-task)</td><td>CIFAR100 (20-task)</td><td>miniImageNet (10-task)</td><td>miniImageNet (20-task)</td></tr><tr><td>LTriplet+γLPNCA LMS+γLPNCA(Ours)</td><td>87.06±0.52 88.79±0.26</td><td>43.56±1.63 51.84±0.91</td><td>13.21±0.28 15.56±0.39</td><td>10.93±0.34 13.65±0.35</td><td>14.31±0.33 16.05±0.38</td><td>13.55±0.22 15.15±0.36</td></tr></table>
443
+
444
+ Table 11: Comparison between MS loss and Triplet Loss. We report Average Accuracy of 15 runs on Split datasets. The size of memory $\mathcal { M }$ is 1k.
md/dev/_3ELRdg2sgI/_3ELRdg2sgI.md ADDED
@@ -0,0 +1,285 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # STaR: Self-Taught Reasoner Bootstrapping Reasoning With Reasoning
2
+
3
+ Eric Zelikman∗1, Yuhuai $\mathbf { W _ { u } } ^ { * 1 2 }$ , Jesse ${ { \bf { M } } { \bf { u } } ^ { 1 } }$ , Noah D. Goodman1 1Department of Computer Science, Stanford University 2 Google Research {ezelikman, yuhuai, muj, ngoodman}@stanford.edu
4
+
5
+ # Abstract
6
+
7
+ Generating step-by-step "chain-of-thought" rationales improves language model performance on complex reasoning tasks like mathematics or commonsense question-answering. However, inducing language model rationale generation currently requires either constructing massive rationale datasets or sacrificing accuracy by using only few-shot inference. We propose a technique to iteratively leverage a small number of rationale examples and a large dataset without rationales, to bootstrap the ability to perform successively more complex reasoning. This technique, the "Self-Taught Reasoner" (STaR), relies on a simple loop: generate rationales to answer many questions, prompted with a few rationale examples; if the generated answers are wrong, try again to generate a rationale given the correct answer; finetune on all the rationales that ultimately yielded correct answers; repeat. We show that STaR significantly improves performance on multiple datasets compared to a model fine-tuned to directly predict final answers, and performs comparably to finetuning a $3 0 \times$ larger state-of-the-art language model on CommensenseQA. Thus, STaR lets a model improve itself by learning from its own generated reasoning.1
8
+
9
+ # 1 Introduction
10
+
11
+ Human decision-making is often the result of extended chains of thought [1, 2]. Recent work has shown that explicit intermediate reasoning (“rationales”) can improve large language model (LLM) performance as well [3–8]. For example, [5] demonstrated that LLMs explicitly trained to use “scratchpads” for intermediate steps can attain perfect in-distribution performance on arithmetic, and strong out-of-distribution generalization, while models trained to predict answers directly fail to do either. These works suggest that generating explicit rationales before giving a final answer (“rationale generation”) is valuable for LLMs across diverse tasks including mathematical reasoning, commonsense reasoning, code evaluation, social bias inference, and natural language inference. However, the two primary methods for inducing rationale generation both have serious drawbacks.
12
+
13
+ One approach to rationale generation is the construction of a fine-tuning dataset of rationales, either manually by human annotators or automatically with hand-crafted templates [3–5, 9]. Manual methods are expensive, and it is infeasible to construct such a dataset for each interesting problem [3]. Meanwhile, template-based methods rely on automatically-generated rationales but only work when a general solution is already known [5] or reasonable hard-coded heuristics can be made [4].
14
+
15
+ An alternative is to leverage in-context learning by including only a few rationale examples in the language model prompt. This has been shown to improve accuracy on mathematical and symbolic reasoning tasks relative to prompting without rationales (“direct” prompting) [5, 6]. Yet, while fewshot techniques with rationales tend to outperform their non-reasoning counterparts, they generally substantially underperform models fine-tuned to directly predict answers using larger datasets [5, 6].
16
+
17
+ Q: What can be used
18
+ to carry a small dog?
19
+ Answer Choices:
20
+ (a) swimming pool
21
+ (b) basket
22
+ (c) dog show
23
+ (d) backyard
24
+ (e) own home
25
+ A: The answer must be
26
+ something that can be
27
+ used to carry a small
28
+ dog. Baskets are
29
+ designed to hold things. Therefore, the answer
30
+ is basket (b).
31
+
32
+ ![](images/09fd48ec300509762b051d59d09c6e06cc50c890525458ba646c5409dd839d35.jpg)
33
+ Figure 1: An overview of STaR and a STaR-generated rationale on CommonsenseQA. We indicate the fine-tuning outer loop with a dashed line. The questions and ground truth answers are expected to be present in the dataset, while the rationales are generated using STaR.
34
+
35
+ In this paper, we adopt a different approach: by leveraging the LLM’s pre-existing reasoning ability, we iteratively bootstrap the ability to generate high-quality rationales. Specifically, we few-shot prompt a large language model to self-generate rationales and refine the model’s ability further by fine-tuning on those rationales that lead to correct answers. We repeat this procedure, using the improved model to generate the next training set each time. This is a synergistic process, where improvements in rationale generation improve the training data, and improvements in training data further improve rationale generation.
36
+
37
+ However, we find this loop eventually fails to solve any new problems in the training set because it receives no direct training signal for problems it fails to solve. To overcome this issue, we propose rationalization: for each problem that the model fails to answer correctly, we generate a new rationale by providing the model with the correct answer. This lets the model reason backward—given the correct answer, the model can more easily generate a useful rationale. These rationales are then collected as part of the training data, which often improves overall accuracy.
38
+
39
+ We thus develop the Self-Taught Reasoner (STaR, Fig. 1) method, a scalable bootstrapping method allowing models to learn to generate their own rationales, while also learning to solve increasingly difficult problems. In our method, we repeat the following process: in each iteration, first construct a finetuning dataset by attempting to solve the dataset using the current model’s rationale generation ability; then, augment this dataset using rationalization, justifying ground-truth answers to problems the model failed to solve; finally, finetune the large language model on the combined dataset.
40
+
41
+ Applying STaR on arithmetic, math word problems, and commonsense reasoning, we observe it is able to effectively translate a small number of few-shot prompts into a large rationale dataset, yielding dramatic performance improvements. On CommonsenseQA [10], we find STaR improves over both a few-shot baseline $( + 3 5 . 9 \% )$ and a baseline fine-tuned to directly predict answers $( + 1 2 . 5 \% )$ , and performs comparably to a fine-tuned model that is $3 0 \times$ larger $7 2 . 5 \%$ vs. $7 3 . 0 \%$ ).
42
+
43
+ Thus, we make the following contributions:
44
+
45
+ 1. We propose a bootstrapping mechanism to iteratively generate a rationale dataset from a few initial examples with rationales—without needing to check new rationales’ correctness. 2. We complement rationale generation with rationalization, where a model is tasked with justifying an answer and then fine-tuned as if it had come up with the rationale without any hint. We show rationalization accelerates and improves the bootstrapping process. 3. We evaluate these techniques with a variety of ablations in both mathematical and commonsense reasoning domains. 4. We propose what is, to our knowledge, the first technique to allow a pre-trained large language model to iteratively use its language modeling capacity to improve itself.
46
+
47
+ # 2 Background and Related Work
48
+
49
+ In-context Learning Recently, a collection of works has emerged exploring the capacity for large language models to perform in-context learning [11, 12]. In essence, in-context learning treats few-shot learning as a language modeling problem, by showing a few examples in the context (i.e. prompt), and allowing the model to learn and identify the pattern to apply to new examples. Some have studied in-context learning based on the language modeling objective in terms of Bayesian inference [13] while others have attempted to describe the process more mechanistically in terms of “induction heads” [14]. Moreover, differences in prompt configurations have been known to have dramatic effects on few-shot performance. Some have even found that replacing few-shot prompts with a “soft prompt” which can be optimized in embedding space results in noticeable gains [15]. Instead of emphasizing the representation of the question, we focus on the model output; in particular, we focus on the model’s ability to reason through a problem before coming to a conclusion.
50
+
51
+ Rationales One initial work on the impact of rationales on language model performance was [3], showing that training a language model on a dataset with explicit rationales preceding the answer could improve a model’s ability to generate the final answer. However, this required many thousands of training examples to be manually annotated with human reasoning. Recently, [5] demonstrated that step-by-step “scratchpads” improve fine-tuned LLM performance and generalization on tasks such as arithmetic, polynomial evaluation, and program evaluation. Similarly, [6] used a single few-shot “chain-of-thought” reasoning prompt to improve model performance on tasks without fine-tuning. Finally, [16] showed that a curriculum learning approach could help solve formal math problems, if 1) they were translated into Lean (a theorem-proving language [17]), 2) one could directly evaluate the proofs’ validity, 3) one could sample many solutions per problem, 4) had trained a separate value function model, and 5) started with GPT-f (a model fine-tuned on a large math dataset [18]). We note there are many domains where these conditions do not all apply. In addition, works have aimed to explain why rationales help: some have analyzed their impact from the perspective of latent variable models [19] while others have provided formal proofs of the benefit of intermediate task supervision [20].
52
+
53
+ Iterated Learning A variety of iterated learning algorithms have been proposed, where solutions or successful methods which are found are in turn used to find additional solutions [21, 22, 16]. [21] introduced Expert Iteration (ExIt), a reinforcement learning technique serving as an inspiration for our approach. Essentially, it consists of a loop of self-play by an “apprentice,” followed by imitation learning with feedback from a slower “expert” and then the replacement of the expert with the now-improved apprentice. [16] builds off of ExIt for formal reasoning, while [22] applies iterated learning to visual question answering using modular networks which can be combined compositionally. There are further similarities between STaR and expert iteration methods [21]. For example, filtering generated examples based on whether their ultimate answer matches the target can be seen as expert feedback. However, we have a fixed “expert” and do not train a separate value function. The idea of alternating between filtering steps and training steps more broadly is also well-grounded in prior work in NLP such as [23] and in other weak supervision contexts [24, 25].
54
+
55
+ Natural Language Explanations Natural language explanations have also been discussed from the perspective of explainable machine learning, focusing on justification rather than reasoning [26, 27]. The motivation for this line of work is largely grounded in explainable decision making, and similarly to [3], generally does not find that requiring post-hoc explanations improves model performance.
56
+
57
+ # 3 Method
58
+
59
+ # 3.1 Rationale Generation Bootstrapping (STaR Without Rationalization)
60
+
61
+ We are given a pretrained LLM $M$ and an initial dataset of problems $x$ (including answer choices if applicable) with correct final answers $y$ : $\mathbfcal { D } = \{ ( x _ { i } , y _ { i } ) \} _ { i = 1 } ^ { \dot { D } }$ . Our technique starts with a small prompt set $\mathcal { P }$ of examples with intermediate rationales $r$ : $\mathcal { P } = \bar { \{ ( x _ { i } ^ { p } , r _ { i } ^ { p } , y _ { i } ^ { p } ) \} } _ { i = 1 } ^ { P }$ , where $P \ll D$ (e.g. $P = 1 0 ^ { \circ }$ ). Like standard few-shot prompting, we concatenate this prompt set to each example in $\mathcal { D }$ , i.e. $x _ { i } = ( x _ { 1 } ^ { p } , r _ { 1 } ^ { p } , y _ { 1 } ^ { p } , \ldots , x _ { P } ^ { p } , r _ { P } ^ { p } , y _ { P } ^ { p } , x _ { i } )$ , which encourages the model to produce a rationale $\hat { r } _ { i }$ for $x _ { i }$ followed by an answer $\hat { y } _ { i }$ . We assume that rationales that lead to correct answers are of better quality than those that lead to incorrect answers. Therefore, we filter the generated rationales to include only the ones which result in the correct answer $\hat { y } _ { i } = y _ { i } ,$ ). We fine-tune the base model $M$ on this filtered dataset, and then restart this process by generating the new rationales with the newly fine-tuned model. We keep repeating this process until the performance plateaus. Note that during this process, once we collect a new dataset, we train from the original pre-trained model $M$ instead of continually training one model to avoid overfitting. We provide an outline of this algorithm in Algorithm 1.
62
+
63
+ STaR can be seen as an approximation to an RL-style policy gradient objective. To see this, note that $M$ can be viewed as a discrete latent variable model $\begin{array} { r } { p _ { M } \tilde { ( { y } \mid { x } ) } = \tilde { \sum _ { r } } p ( r \mid { x } ) p ( y \mid { x } , r ) } \end{array}$ ; in other words, $M$ first samples a latent rationale $r$ before predicting $y$ . Now, given the indicator reward function $\mathbb { 1 } ( \hat { y } = y )$ , the total expected reward across the dataset is
64
+
65
+ $$
66
+ \begin{array} { l } { \displaystyle J ( \boldsymbol { M } , \boldsymbol { X } , Y ) = \sum _ { i } \mathbb { E } _ { \hat { r } _ { i } , \hat { y } _ { i } \sim p _ { \boldsymbol { M } } ( \cdot \vert \boldsymbol { x } _ { i } ) } \mathbb { 1 } ( \hat { y } _ { i } = y _ { i } ) , } \\ { \displaystyle \nabla J ( \boldsymbol { M } , \boldsymbol { X } , Y ) = \sum _ { i } \mathbb { E } _ { \hat { r } _ { i } , \hat { y } _ { i } \sim p _ { \boldsymbol { M } } ( \cdot \vert \boldsymbol { x } _ { i } ) } \left[ \mathbb { 1 } ( \hat { y } _ { i } = y _ { i } ) \cdot \nabla \log p _ { \boldsymbol { M } } ( \hat { y } _ { i } , \hat { r } _ { i } \mid \boldsymbol { x } _ { i } ) \right] , } \end{array}
67
+ $$
68
+
69
+ where the gradient is obtained via the standard log-derivative trick for policy gradients. Note that the indicator function discards the gradient for all sampled rationales that do not lead to the correct answer $y _ { i }$ : this is the filtering process in STaR (Line 5). Thus, STaR approximates $J$ by (1) greedily decoding samples of $( \hat { r } _ { i } , \hat { y } _ { i } )$ to reduce variance of this estimate (at the cost of potentially biased exploration of rationales), and (2) taking multiple gradient steps on the same batch of data (similar to some policy gradient algorithms [28]). These approximations make STaR a simple and broadly applicable method that can be implemented with standard LLM training machinery; future work should more closely investigate the link between STaR and the RL objective above.
70
+
71
+ # 3.2 Rationalization
72
+
73
+ The rationale generation bootstrapping algorithm carries a limitation. As the model is only trained on the examples which it answers correctly, improvement ends when the model fails to solve new problems in the training set. This is fundamentally due to the fact that the algorithm cannot obtain any training signal from failed examples. Inspired by [3], we propose a technique we call “rationalization”. Specifically, we provide the answer as a hint to the model and ask it to generate rationales in the same style as in the previous rationale generation step. Given the answer, the model is able to reason backwards, and hence more easily generate a rationale leading to the correct answer. Figure 2 provides an example of this format on CQA, also used in the few-shot rationalization prompt, indicating that ”(b) grocery cart” is the correct answer. We apply rationalization to problems which the model failed to solve with rationale genera
74
+
75
+ Q: Where do you put your grapes just before checking out?
76
+ Answer Choices:
77
+ (a) mouth
78
+ (b) grocery cart (CORRECT)
79
+ (c) super market
80
+ (d) fruit basket
81
+ (e) fruit market
82
+ A: The answer should be the place
83
+ where grocery items are placed before checking out. Of the above choices, grocery cart makes the most sense for holding grocery items. Therefore, the answer is grocery cart (b).
84
+
85
+ Figure 2: A few-shot prompt hint we use for rationalization (and not for rationale generation), using the rationale from [6], with its hint included in green, followed by the rationale and the answer generated by the model.
86
+
87
+ tion. When adding a rationalization-generated rationale to our dataset, we do not include the hint in its corresponding prompt, as if the model had come up with the rationale without the hint. After filtering, we fine-tune on the previously generated dataset combined with the rationalization-generated dataset.
88
+
89
+ # Algorithm 1 STaR
90
+
91
+ Input $M$ : a pretrained LLM; dataset $\mathcal { D } = \{ ( x _ { i } , y _ { i } ) \} _ { i = 1 } ^ { D }$ (w/ few-shot prompts)
92
+ 1: $M _ { 0 } \gets M$ # Copy the original model
93
+ 2: for $n$ in $1 . . . N$ do # Outer loop
94
+ 3: $\begin{array} { r l } { ( \hat { r } _ { i } , \hat { y } _ { i } ) M _ { n - 1 } ( x _ { i } ) } & { { } \forall i \in [ 1 , D ] \ : \# } \end{array}$ Perform rationale generation
95
+ 4: $( \hat { r } _ { i } ^ { \mathrm { r a t } } , \hat { y } _ { i } ^ { \mathrm { r a t } } ) \gets M _ { n - 1 } ( \mathrm { a d d } \_ { \mathrm { h i n t } } ( x _ { i } , y _ { i } ) ) \quad \forall i \in [ 1 , D ] \#$ Perform rationalization
96
+ 5: $D _ { n } \gets \{ ( x _ { i } , \hat { r } _ { i } , y _ { i } ) \ | \ i \in [ 1 , D ] \land \hat { y } _ { i } = y _ { i } \} \#$ Filter rationales using ground truth answers
97
+ 6: $\mathcal { D } _ { n } ^ { \mathrm { r a t } } \{ ( x _ { i } , \hat { r } _ { i } ^ { \mathrm { r a t } } , y _ { i } ) \mid i \in [ 1 , D ] \land \hat { y } _ { i } \neq y _ { i } \land \hat { y } _ { i } ^ { \mathrm { r a t } } = y _ { i } \}$ # Filter rationalized rationales
98
+ 7: $M _ { n } \gets \mathrm { t r a i n } ( M , \mathcal { D } _ { n } \cup \mathcal { D } _ { n } ^ { \mathrm { r a t } } )$ # Finetune the original model on correct solutions - inner loop
99
+ 8: end for
100
+
101
+ Algorithm 1 describes the full algorithm, with the parts in blue corresponding to rationalization. Without those parts, Algorithm 1 corresponds to STaR without rationalization. Figure 1 provides an overview diagram. Fine-tuning on the dataset generated by rationalization has a crucial benefit of exposing the model to difficult problems which otherwise would not have appeared in its finetuning dataset. This can be understood as challenging the model to “think outside the box” about problems on which it was unsuccessful. A secondary benefit of rationalization is an increase in dataset size.
102
+
103
+ # 4 Experiments
104
+
105
+ For our experiments, we focus on arithmetic, commonsense reasoning, and grade school math to demonstrate STaR’s breadth. In particular, for arithmetic, we follow a setup inspired by [5]. For commonsense question-answering we follow [13, 6] and use CommonsenseQA (CQA), a widely used multiple-choice dataset for this domain [10]. For grade school math, we use GSM8K from [9].
106
+
107
+ # 4.1 Experimental Protocol
108
+
109
+ We used GPT-J as our base language model, and the fine-tuning script from the GPT-J repository [29]. We chose GPT-J, a 6B-parameter model, because the checkpoint and fine-tuning code are publicly available [29], and the model is large enough to generate rationales of non-trivial quality to be bootstrapped from. More hyperparameter details about GPT-J and our fine-tuning are included in Appendix G. Following the default setting of [29], we perform a 100-step learning rate warmup, from which point we use a constant learning rate. Unless stated otherwise, we start with 40 training steps at the first outer loop, and increase the number of inner-loop fine-tuning training steps by $2 0 \%$ with each outer loop. In general, we found that training more slowly at the beginning ultimately benefits model performance. We expect that further improvement is possible via a thorough hyperparameter search—we leave this to future work due to computational constraints.
110
+
111
+ For arithmetic problems, we first generate a dataset of 50,000 randomly sampled questions (uniformly over the digit lengths) in the format introduced by [5]. For each outer loop iteration on arithmetic, we sample 10,000 problems from the dataset. We use 10 random few-shot rationale examples for each digit for its corresponding few-shot prompt. For each of the 9, 741 questions in the training set of CommonsenseQA, we add the question to the few-shot rationale prompt, and prompt the model to generate the rationale and answer for that question. For few shot prompting on CQA, we start with the same 10 questions as used in [6], with the rationales modified slightly to fix an incorrect answer and to more explicitly reference relevant knowledge. We include these modified prompts in Appendix $\mathbf { B } ^ { 2 }$ . These prompts serve as our complete set of explanations. We run STaR until we see performance saturate, and we report the best results.
112
+
113
+ When performing rationalization, we find that the choice to include or omit few-shot prompts on outer-loop iterations after the first iteration does not have a substantial impact on the method’s ultimate performance. However, there are some nuances which we discuss further in Section 5, leading us to use few-shot prompts unless stated otherwise.
114
+
115
+ # 4.2 Datasets
116
+
117
+ Arithmetic The arithmetic task is to calculate the sum of two $n$ digit integers. We generate the dataset based on the descriptions in [5] and visualize an example scratchpad in Figure 3. Everything up to and including “Target:” is given as part of a prompt, and the model is asked to generate the scratchpad (start/end indicated by “<scratch>”) and the final answer, as in [5]. Each line of the scratchpad corresponds to the summation of each pair of digits from the final digit to the first digit, the accumulating final digits of the answer, and a carry digit corresponding to whether the previous pair summed to at least 10. We include few-shot prompts for 1 to 5 digits. When performing rationalization, we include the correct answer after “Target” and query the model to produce the scratchpad and then reproduce the correct answer following the scratchpad.
118
+
119
+ Input:
120
+ $6 \dot { \textbf { 2 } } 4 + 2 \dot { \textbf { 5 } } 9$
121
+ Target:
122
+ <scratch>
123
+ 6 2 4 + 2 5 9 , C: 0
124
+ $\textit { 2 + 5 }$ , 3 C: 1
125
+ 6 + 2 , 8 3 C: 0
126
+ , 8 8 3 C: 0
127
+ 0 8 8 3
128
+ </scratch>
129
+ 8 8 3
130
+
131
+ CommonsenseQA The multiple-choice commonsense reasoning task, CommonsenseQA [10] (CQA), is constructed from ConceptNet, a semantic graph of concepts and their relationships with over a million nodes [31]. [10] identified a set of “target” concepts in ConceptNet for each question, where the target concepts share a semantic relationship to one “source” concept. Then each question is crowdsourced to allow a reader to identify one target concept, while mentioning the source concept. In addition, two distractor answers are added. The dataset has 12,247 questions, each with five choices, with 9,741 in the train set, 1,221 in the dev set, and 1,285 in the (withheld) test set.
132
+
133
+ ![](images/a67ddf3d7a276de1776a083b5e62778dd5d70fc5c42b09634b97a5045c0f26de.jpg)
134
+ Figure 4: A visualization of the accuracy of $n$ -digit summation with each iteration of STaR with and without rationalization. Each series corresponds to the accuracy of summing two $n$ -digit numbers.
135
+
136
+ Corresponding to the broad variety of ConceptNet, CQA contains a diverse set of questions which require commonsense reasoning ability building off of standard world knowledge, where human performance is $89 \%$ [10]. Many have pointed out that CQA contains a number of biases, along several dimensions including gender [3]. We discuss how this may impact our method in Section 6. There are also many typos and questions which are fundamentally ambiguous3. We use it despite these issues as it is a general question-answering dataset relying on both common world knowledge and simple reasoning, which serves as a good test-bed for our method.
137
+
138
+ Grade School Math (GSM8K) We also evaluate on the Grade School Math (GSM8K) dataset, containing 7,473 train and 1,319 test examples of grade-school-level word problems [9]. These math problems are posed in natural language and require two to eight calculation steps to arrive at a final answer. This dataset combines the skills needed for arithmetic and commonsense reasoning. For rationalization, we include the final answer in parentheses immediately after the question as a hint.
139
+
140
+ # 4.3 Symbolic Reasoning: Results on Arithmetic
141
+
142
+ The accuracies of the model across digits 1-5 over each iteration of the outer loop are plotted in Figure 4. After running STaR for 16 iterations, the overall accuracy is $8 9 . 5 \%$ . For reference, a baseline trained on 10,000 examples without rationales for 5,000 steps attains $7 6 . 3 \%$ accuracy. Notably, few-shot accuracy on arithmetic problems is very low, even with rationales: accuracy on 2-digit addition is less than $1 \%$ , and accuracy on more digits close to zero.
143
+
144
+ With rationalization, the accuracy is able to improve especially quickly. After one fine-tuning iteration on the model’s generated scratchpads, 2-digit addition improves to $3 2 \%$ from less than $1 \%$ . Without rationalization, the performance improvement is stagewise: the model generally has poor performance on the $n$ -digit sum until it has good performance on the $( n - 1 )$ -digit sum. With rationalization, the model can learn many lengths at once, though not with equal accuracy. Rationalization allows many problems to be solved few-shot, so we start STaR training with 300 steps (note, doing so without rationalization causes overfitting on 1-digit addition), and increase training by 20 steps per iteration.
145
+
146
+ ![](images/0e05b4a97ca8707ed64cf3d25351e06f1e0a263b024190aa8f15a1abf5ba7fb4.jpg)
147
+ Figure 5: We introduce additional digits to STaR with rationalization at the $2 0 ^ { t h }$ iteration.
148
+
149
+ We also perform an experiment where we continue pre-training STaR with rationalization with additional digits, starting before the 20th iteration, while keeping the total number of training examples fixed at each iteration. We find that not only does this appear to quickly improve performance on the initial set of digits, but when evaluated on 9 and 10 digit examples, never seen during training, the model successfully solves many of these out-of-distribution problems. As visualized in Figure 5, the introduction of these digits appears to make the training less stable, but the exact cause is unclear.
150
+
151
+ Table 1: We evaluate several baselines, including a few-shot GPT-J evaluation both with and without scratchpads, a GPT-J baseline finetuned to directly predict the answer, and STaR with and without rationalization applied to GPT-J. We use CoT to denote non-STaR models outputting rationales, and Direct to indicate those directly predicting the final answer. Note the final STaR model is trained on $7 8 . 2 \%$ of the training dataset with rationale generation, and an additional $8 . 5 \%$ from rationalization.
152
+
153
+ <table><tr><td rowspan="2">GPT-3DirectFinetuned[32]</td><td colspan="2">CQADevSetAccuracy(%) TrainDataUsed(%)</td></tr><tr><td>73.0</td><td>100</td></tr><tr><td>Few-shot Direct GPT-J</td><td>20.9</td><td>~0</td></tr><tr><td>Few-shot CoT GPT-J 4</td><td>36.6</td><td>~0</td></tr><tr><td>Few-shotCoTLaMDA137B [6]</td><td>55.6</td><td>~0</td></tr><tr><td>GPT-JDirectFinetuned</td><td>60.0</td><td>100</td></tr><tr><td>STaR without rationalization</td><td>68.8</td><td>69.7</td></tr><tr><td>STaR with rationalization</td><td>72.5</td><td>86.7</td></tr></table>
154
+
155
+ # 4.4 Natural Language Reasoning: Commonsense Question Answering
156
+
157
+ The CommonsesenseQA (CQA) setting introduces several new challenges. In the arithmetic task, an incorrect scratchpad in the reasoning step, and to a lesser degree in the rationalization step, was extremely likely to result in an incorrect answer. On the other hand, CQA problems are 5-way multiple choice questions. Thus, one will get the right answer at random approximately $20 \%$ of the time, regardless of the quality of reasoning. Moreover, some simple heuristics (e.g. semantic similarity) can meaningfully improve this to ${ \approx } 3 0 \%$ without any reasoning, as shown by [10].
158
+
159
+ We evaluate this dataset as described in the experimental protocol and compare to several baselines. The first baseline is to finetune GPT-J to directly output the final answer, which we call “GPT-J Finetuned”. We also compare to GPT-3 finetuned to directly predict the final answer from [32], and a 137B parameter Lambda model few-shot prompted with chain-of-thought (CoT) rationales from [6].
160
+
161
+ We found that, as shown in Table 1, STaR without rationalization outperformed GPT-J fine-tuned directly on the final answer for the entire dataset, despite training on less of the data. The inclusion of rationalization improved this performance to $7 2 . 5 \%$ , far closer to the $7 3 \%$ of the $3 0 \times$ larger GPT-3. As expected, we also see STaR surpassed the few-shot baselines, including the much-larger 137B LaMDA model [33, 6]. We expect accuracy would be further improved if we applied STaR to a model with higher few-shot performance. Note that substantially higher performance is possible: [32] demonstrated a custom 39-model ensemble which reached “super-human” performance on the CQA test set and $9 3 . 4 \%$ accuracy on the dev set - however, it relied on access to ConceptNet, on which CQA is built.
162
+
163
+ Case Study Note that it is harder to judge the rationale quality: for arithmetic, one can compare them to the ground truth rationales, but for CQA the evaluation is necessarily qualitative. For this reason, we include a case study in Figure 7. We observe that the rationales provided are generally coherent and of a similar structure to the few-shot rationales. We make the following two observations:
164
+
165
+ 1. After training with STaR, we see the model was able to generate reasonable rationales that solve new problems, which explains part of the observed performance gain. 2. We also see that there were many instances in which STaR improved the quality of rationales over those generated in a few-shot manner.
166
+
167
+ Human Evaluation Based on the observation that STaR may improve reasoning quality for problems even when they were initially answered correctly via few-shot prompting, we performed a preliminary qualitative analysis. We randomly selected 50 rationales generated from few-shot CoT and STaRgenerated rationales on questions which they both answered correctly, as well as human-generated rationales for these problems from [3]. We then presented a random subset of 10 questions and rationales to each of 20 crowdworkers on Prolific [34] with the rationales in a randomized order, asking them to rank the rationales based on which they felt best justified the answer. The participants were $30 \%$ more likely to rank the STaR-generated rationales higher than the few-shot rationales $\mathrm { \Delta } p = . 0 3 9 \mathrm { \Omega }$ ). This indicates that, as mentioned in the case study, STaR can improve the quality of rationale generation.
168
+
169
+ Table 2: We find that STaR substantially improves GSM8K performance over the baselines, despite training on only $2 5 . 0 \%$ of the data for the model without rationalization, and $3 0 . 3 \%$ of the dataset (with $1 . 2 \%$ from rationalization) for the model with rationalization.
170
+
171
+ <table><tr><td colspan="2">GSM8K Test Accuracy (%)</td><td>Train Data Used (%)</td></tr><tr><td>Few-shot Direct GPT-J</td><td>3.0</td><td>~0</td></tr><tr><td>Few-shot CoTGPT-J</td><td>3.1</td><td>~0</td></tr><tr><td>GPT-JDirect Finetuned</td><td>5.8</td><td>100</td></tr><tr><td>STaR without rationalization</td><td>10.1</td><td>25.0</td></tr><tr><td>STaR with rationalization</td><td>10.7</td><td>30.3</td></tr></table>
172
+
173
+ We also found that the participants were $74 \%$ more likely to prefer the STaR-generated rationales over the human-generated rationales $( p < . 0 0 1 )$ . To be clear, we do not believe that this indicates human-level rationale-generation performance. Instead, we feel that it speaks to the difficulty of eliciting high-quality rationales. We reproduce the test prompts in Appendix C and elaborate on the limitations of the crowdsourced explanations dataset.
174
+
175
+ Failure Cases Finally, we found a variety of interesting failure cases, many of which corresponded to standard logical fallacies. For example, the model often made statements related to the topic of the question but which were not actually arguments for why the answer should be true. Sometimes, the model claimed the question implied the answer as an argument, without explaining why. Other times, especially early in training, the model answered as if it has knowledge about a particular individual, instead of making a general statement - e.g. “the king’s castle is a place where he feels safe” instead of “castles are places where kings feel safe.” We provide examples and analyze errors in Appendix A.
176
+
177
+ Few-shot Prompt Training Using few-shot prompts during fine-tuning [12] appears to have a meaningful benefit $6 0 . 9 \% { } 6 8 . 8 \%$ without rationalization, $6 9 . 9 \% 7 2 . 5 \%$ with rationalization). Thus, we generally suggest its use for at least a portion of training, though we discuss caveats in Section 5.
178
+
179
+ # 4.5 Mathematical Reasoning in Language: Grade School Math
180
+
181
+ We again find on GSM8K that STaR substantially improves performance beyond few-shot with rationales or training to directly predict the answers (without rationales), shown in Table 2 and include the few-shot prompt in Appendix I. We observe that on this task, rationalization does not substantially improve performance. Note that, in training, it was necessary to cap the number of training steps at the 30th iterations (after 7912 steps), to prevent training from becoming prohibitively long. The results were reached after 36 iterations for STaR without rationalization and an additional 12 iterations with rationalization.
182
+
183
+ Usually, the number of calculation steps generated by the model matches the number of steps taken by humans (generally $5 3 \mathrm { - } 5 7 \%$ agreement across all iterations). We visualize this explicitly in Figure 6. We see that when the ground truth and model disagree on the number of calculation steps, the model typically uses fewer. Sometimes this is because the model skips steps, but occasionally it finds novel solutions, as in Appendix J, where the model disregards redundant details and solves a 7-step problem in one step.
184
+
185
+ ![](images/d33cffc019d60ec892585163c71b1390ff6556803ca94ed0e5228007e2ce112b.jpg)
186
+ Figure 6: A comparison of the number of calculator steps generated by the model to solve examples in the training set relative to the number of steps used in the ground truth.
187
+
188
+ # 5 Discussion and Challenges
189
+
190
+ The Impact of Rationalization An essential question is exactly what role rationalization plays. Intuitively, rationalization allows a model to reverse-engineer a solution, or provides a heuristic for identifying whether each step makes the conclusion more likely. This parallels real-world problems where the final result is known, but challenging to derive a good justification. From a mathematical perspective, while rationale generation samples rationales from the distribution $p ( r \mid x )$ provided by our model $M$ , rationalization conditions on the answer, letting us access an alternative distribution $p ( r \mid x , y )$ which may be a better search space for rationales. Then rationalization could be framed as an off-policy estimate of the objective in Equation 1, sampling from the hint-augmented model as a proposal distribution. Future work should establish more connections between rationalization and these RL objectives, and examine more generally when and why rationalization improves learning.
191
+
192
+ In addition, due to the low sampling temperature, outputs without rationalization correspond to examples where the model is most confident in its answer. This results in these examples providing a weaker gradient signal than the rationalization examples, at least in the first iteration. Since we retrain from the initial pre-trained model every time we run a fine-tuning iteration, the degree of this effect is also difficult to measure directly. Finally, we must point out that the method to add the “hint” does not follow immediately from the question and answer and in some contexts providing it may be nontrivial. Exploring the impacts of different hinting techniques and their generality is an avenue for future work.
193
+
194
+ Temperature One intuitive alternative to rationalization, if one seeks to expand the training dataset, is more and higher-temperature sampling. However, in practice, we found that this is counterproductive. In general, it substantially increases the likelihood of a correct answer despite incorrect reasoning, and training on bad or irrelevant reasoning prevents generalization. This is particularly clear in more structured tasks, like arithmetic, where the scratchpads that the model learns to produce with a higher-temperature sampling approach diverge into meaninglessness and cause the model to stagnate. Overall, we found that higher temperatures as an alternative to rationalization (e.g. 0.5 or 0.7) led to models worse than models with reasoning alone, discussed further in Appendix H.
195
+
196
+ Furthermore, as text generation by large language models is sequential (i.e. one cannot produce a token without producing the preceding token), generating text is a bottleneck and this is computationally far less efficient than rationalization. For example, generating 10 sample outputs is approximately 10 times slower than generating one sample output. However, one potentially valuable way to leverage multiple samples would be to use the method proposed in [35], using the majority-vote result of multiple high-temperature scratchpads as a ground truth against which we compare a low-temperature scratchpad. This allows one to apply STaR to a dataset of only questions, without answers. This significantly underperformed using ground truth, but we discuss this ablation in Appendix H.
197
+
198
+ Few-shot Prompting A noteworthy phenomenon is that the inclusion of few-shot prompting during sampling seems to dramatically reduce “drift” where later rationales become increasingly dissimilar from the initial few-shot set of rationales. One benefit of this is that the model may be less constrained by the quality and difficulty of the initial rationales, theoretically allowing it to generalize more. One potentially negative consequence is that the style of the rationales may less-closely match the original prompting style. Another benefit is in terms of computational resources - a shorter prompt length allows for a shorter sequence length when sampling. Technically, the point in training at which we “disable” few-shot prompts is another hyperparameter which we could tune, but we leave this to future work. In addition, by leaving prompts out after the initial outer-loop iteration, the model tends to perform gradually worse at rationalization as it trains for longer periods of time. As a result, it may be necessary to include some hints during training for long periods of time with this approach.
199
+
200
+ Ultimately, the choice to include few-shot prompts in later iterations of training appears to depend on the use-case: when the goal is consistent adherence to a particular prompt style, which may benefit explainability, include few-shot prompts in sampling; when the goal is a faster training loop, one may remove them. Moreover, it is possible that with other datasets or larger models there is an impact on performance, so we encourage this to be generally treated as a hyperparameter.
201
+
202
+ Incorrect Rationales with Correct Answers One limitation of STaR is that undesirable rationales (e.g. for the reasons discussed in Appendix A or later in this section) paired with correct answers will still be used for training. These examples may detract from the performance simply by providing unclean training data. In addition, it is possible that the ultimate performance of the model may be worsened by training on rationales which are useful in a limited context but fail to generalize, relative to training with non-generalizable rationales filtered out. How to identify correct and generalizable rationales beyond checking the final answer (e.g. by using token-level verifiers as in [9]) is a valuable direction for future study. Still, in real-world contexts there are significant consequences to user trust and risk from a model producing bad or unfaithful explanations [36], discussed also in Appendix 6.
203
+
204
+ # 6 Limitations and Impacts
205
+
206
+ Bias It is important to note that STaR is designed to amplify the reasoning leading to correct solutions on a dataset. Another implication is that if biases are “useful” in solving a dataset then they will be amplified. This is made worse by rationalization, as biased answers that the model may not naturally arrive at are, in a sense, pulled out of the model. The exact interaction between the bias in a dataset and the pre-existing bias learned by the model is unclear, and something to consider before real-world deployment of all large language models in general, but STaR-trained models in particular.
207
+
208
+ We find some encouraging initial results on this however: for questions where gender is not relevant, the model appears to disregard it in its explanation. For example: “Q: Where is a good place for a woman to store her sunglasses? $ \mathbf { A }$ : The answer must be a place where sunglasses are stored. Sunglasses are stored in purses. Therefore, the answer is purse (e).” or “Q: The only baggage the woman checked was a drawstring bag, where was she heading with it? $^ { \prime } \mathsf { A }$ : The answer must be a place where a drawstring bag is checked. The answer is airport (e).” We believe this question warrants a much more comprehensive study.
209
+
210
+ Faithfulness One important challenge with models which seek to be interpretable or provide explanations for their reasoning is that of faithfulness. While our primary emphasis is not on the explainability benefits that STaR may bring, there is a fundamental challenge around evaluating explanations and rationales: namely, faithfulness [37, 38]. [38] describe faithful explanations as those which “accurately [represent] the reasoning process behind the model’s prediction.” While STaR encourages the use of reasoning in rationales which leads the model to correct answers, it is difficult, if not impossible, to ensure that the rationales reflect the model’s internal processing. For example, it is straightforward to imagine the model implicitly selecting a particular answer immediately and then generating a rationale to justify that selected answer. This would allow a model to generate unbiased rationales while selecting answers in a biased way.
211
+
212
+ The fact that our model outperforms one fine-tuned to directly predict the answers, and ablation studies from papers such as [6] make it clear that the generation of a rationale before producing an answer non-trivially improves the model’s answer quality. However, it is difficult to evaluate the degree to which any particular answer’s rationale is faithful. However, we note that there problems are not unique to STaR, but are symptomatic of the difficulty of understanding large language models and in particular the rationales generated by large language models.
213
+
214
+ Scale Finally, we note there is no guarantee that our results would generalize to larger models. However, [39] and [40] suggest that the benefits of rationales increases with scale on numerous problems, which is perhaps reason for optimism. On the other hand, a limitation of STaR on small models is that in order for the first iteration of STaR to succeed, few-shot performance must be above chance. This implies that the initial model must be big enough to have some reasoning capabilities. For instance we found that GPT-2 was not able to bootstrap from few-shot reasoning in even the arithmetic domain. A further limitation is that settings with a high level of chance performance (e.g. binary decisions) yield many poor rationales, confounding the STaR approach. As discussed, filtering bad reasoning paired with correct answers remains an open question.
215
+
216
+ # 7 Conclusion
217
+
218
+ We present the Self-Taught Reasoner (STaR), which iteratively improves a model’s ability to generate rationales to solve problems. We few-shot prompt a model to solve many problems in a step-by-step manner by generating rationales, and then prompt it to rationalize the correct answer for problems it gets wrong. We finetune on both the initially correct solutions and rationalized correct solutions, and repeat the process. We find that this technique significantly improves the model’s generalization performance on both symbolic reasoning and natural language reasoning. There are several key limitations on STaR as discussed in Section 5 and Appendix 6. Nonetheless, we believe using examples without reasoning to bootstrap reasoning is a very general approach, and that STaR can serve as the basis of more sophisticated techniques across many domains.
219
+
220
+ # Acknowledgements
221
+
222
+ We thank Imanol Schlag for his detailed feedback about this work, as well as Rose E Wang, Markus Rabe, Aitor Lewkowycz, Rishi Bommasani, Allen Nie, Alex Tamkin, and Qian Huang. We thank Cem Anil for his very helpful insight that rationale finetuning performance can be improved if the training includes the few-shot rationales. We also thank Ben Prystawski for his suggestions on survey creation. We thank Google TPU Research Cloud for TPU access. This work was partially supported by SAIL, an Open Phil AI Fellowship (for JM), and an NSF Expeditions Grant, Award Number (FAIN) 1918771.
223
+
224
+ References
225
+ [1] William James, Frederick Burkhardt, Fredson Bowers, and Ignas K Skrupskelis. The principles of psychology, volume 1. Macmillan London, 1890.
226
+ [2] K Anders Ericsson and Herbert A Simon. Protocol analysis: Verbal reports as data. the MIT Press, 1984.
227
+ [3] Nazneen Fatema Rajani, Bryan McCann, Caiming Xiong, and Richard Socher. Explain yourself! leveraging language models for commonsense reasoning. ACL, 2019.
228
+ [4] Vered Shwartz, Peter West, Ronan Le Bras, Chandra Bhagavatula, and Yejin Choi. Unsupervised commonsense question answering with self-talk. EMNLP 2020, 2020.
229
+ [5] 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.
230
+ [6] 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.
231
+ [7] Ana Marasovic, Iz Beltagy, Doug Downey, and Matthew E Peters. Few-shot self-rationalization ´ with natural language prompts. arXiv preprint arXiv:2111.08284, 2021.
232
+ [8] Andrew K Lampinen, Ishita Dasgupta, Stephanie CY Chan, Kory Matthewson, Michael Henry Tessler, Antonia Creswell, James L McClelland, Jane X Wang, and Felix Hill. Can language models learn from explanations in context? arXiv preprint arXiv:2204.02329, 2022.
233
+ [9] 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.
234
+ [10] Alon Talmor, Jonathan Herzig, Nicholas Lourie, and Jonathan Berant. Commonsenseqa: A question answering challenge targeting commonsense knowledge. In Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long and Short Papers), pages 4149–4158, 2019.
235
+ [11] 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.
236
+ [12] 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. ICLR 2022, 2021.
237
+ [13] Sang Michael Xie, Aditi Raghunathan, Percy Liang, and Tengyu Ma. An explanation of in-context learning as implicit bayesian inference. arXiv preprint arXiv:2111.02080, 2021.
238
+ [14] Catherine Olsson, Nelson Elhage, Neel Nanda, Nicholas Joseph, Nova DasSarma, Tom Henighan, Ben Mann, Amanda Askell, Yuntao Bai, Anna Chen, and et al. In-context learning and induction heads. Transformer Circuits, Mar 2022.
239
+ [15] Brian Lester, Rami Al-Rfou, and Noah Constant. The power of scale for parameter-efficient prompt tuning. EMNLP 2021, 2021.
240
+ [16] Stanislas Polu, Jesse Michael Han, Kunhao Zheng, Mantas Baksys, Igor Babuschkin, and Ilya Sutskever. Formal mathematics statement curriculum learning. arXiv preprint arXiv:2202.01344, 2022.
241
+ [17] Leonardo de Moura, Soonho Kong, Jeremy Avigad, Floris van Doorn, and Jakob von Raumer. The lean theorem prover (system description). In International Conference on Automated Deduction, pages 378–388. Springer, 2015.
242
+
243
+ [18] Stanislas Polu and Ilya Sutskever. Generative language modeling for automated theorem proving. arXiv preprint arXiv:2009.03393, 2020.
244
+
245
+ [19] Wangchunshu Zhou, Jinyi Hu, Hanlin Zhang, Xiaodan Liang, Maosong Sun, Chenyan Xiong, and Jian Tang. Towards interpretable natural language understanding with explanations as latent variables. Advances in Neural Information Processing Systems, 33:6803–6814, 2020.
246
+
247
+ [20] Noam Wies, Yoav Levine, and Amnon Shashua. Sub-task decomposition enables learning in sequence to sequence tasks. arXiv preprint arXiv:2204.02892, 2022.
248
+
249
+ [21] Thomas Anthony, Zheng Tian, and David Barber. Thinking fast and slow with deep learning and tree search. Advances in Neural Information Processing Systems, 30, 2017.
250
+
251
+ [22] Ankit Vani, Max Schwarzer, Yuchen Lu, Eeshan Dhekane, and Aaron Courville. Iterated learning for emergent systematicity in vqa. ICLR 2021, 2021.
252
+
253
+ [23] Luke S Zettlemoyer and Michael Collins. Learning context-dependent mappings from sentences to logical form. 2009.
254
+
255
+ [24] Omer Goldman, Veronica Latcinnik, Ehud Nave, Amir Globerson, and Jonathan Berant. Weakly supervised semantic parsing with abstract examples. In Proceedings of the 56th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pages 1809–1819, 2018.
256
+
257
+ [25] Kelvin Guu, Panupong Pasupat, Evan Liu, and Percy Liang. From language to programs: Bridging reinforcement learning and maximum marginal likelihood. In Proceedings of the 55th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pages 1051–1062, 2017.
258
+
259
+ [26] Oana-Maria Camburu, Tim Rocktäschel, Thomas Lukasiewicz, and Phil Blunsom. e-snli: Natural language inference with natural language explanations. Advances in Neural Information Processing Systems, 31, 2018.
260
+
261
+ [27] Hanxiong Chen, Xu Chen, Shaoyun Shi, and Yongfeng Zhang. Generate natural language explanations for recommendation. arXiv preprint arXiv:2101.03392, 2021.
262
+
263
+ [28] John Schulman, Filip Wolski, Prafulla Dhariwal, Alec Radford, and Oleg Klimov. Proximal policy optimization algorithms. arXiv preprint arXiv:1707.06347, 2017.
264
+
265
+ [29] Ben Wang. Mesh-Transformer-JAX: Model-Parallel Implementation of Transformer Language Model with JAX. https://github.com/kingoflolz/mesh-transformer-jax, May 2021.
266
+
267
+ [30] Sewon Min, Xinxi Lyu, Ari Holtzman, Mikel Artetxe, Mike Lewis, Hannaneh Hajishirzi, and Luke Zettlemoyer. Rethinking the role of demonstrations: What makes in-context learning work? arXiv preprint arXiv:2202.12837, 2022.
268
+
269
+ [31] Robyn Speer, Joshua Chin, and Catherine Havasi. Conceptnet 5.5: An open multilingual graph of general knowledge. singh 2002 (2016). arXiv preprint arxiv:1612.03975, 2016.
270
+
271
+ [32] Yichong Xu, Chenguang Zhu, Shuohang Wang, Siqi Sun, Hao Cheng, Xiaodong Liu, Jianfeng Gao, Pengcheng He, Michael Zeng, and Xuedong Huang. Human parity on commonsenseqa: Augmenting self-attention with external attention. arXiv:2112.03254, December 2021. human parity result on CommonsenseQA.
272
+
273
+ [33] Romal Thoppilan, Daniel De Freitas, Jamie Hall, Noam Shazeer, Apoorv Kulshreshtha, HengTze Cheng, Alicia Jin, Taylor Bos, Leslie Baker, Yu Du, et al. Lamda: Language models for dialog applications. arXiv preprint arXiv:2201.08239, 2022.
274
+
275
+ [34] Stefan Palan and Christian Schitter. Prolific. ac—a subject pool for online experiments. Journal of Behavioral and Experimental Finance, 17:22–27, 2018.
276
+
277
+ [35] Xuezhi Wang, Jason Wei, Dale Schuurmans, Quoc Le, Ed Chi, and Denny Zhou. Selfconsistency improves chain of thought reasoning in language models, 2022.
278
+
279
+ [36] Tim Miller. Explanation in artificial intelligence: Insights from the social sciences. Artificial intelligence, 267:1–38, 2019.
280
+ [37] Bernease Herman. The promise and peril of human evaluation for model interpretability. arXiv preprint arXiv:1711.07414, 2017.
281
+ [38] Alon Jacovi and Yoav Goldberg. Towards faithfully interpretable nlp systems: How should we define and evaluate faithfulness? ACL 2020, 2020.
282
+ [39] 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.
283
+ [40] 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.
284
+ [41] Leo Gao, Stella Biderman, Sid Black, Laurence Golding, Travis Hoppe, Charles Foster, Jason Phang, Horace He, Anish Thite, Noa Nabeshima, et al. The pile: An 800gb dataset of diverse text for language modeling. arXiv preprint arXiv:2101.00027, 2020.
285
+ [42] Diederik P Kingma and Jimmy Ba. Adam: A method for stochastic optimization. arXiv preprint arXiv:1412.6980, 2014.
md/dev/_LceCyuVcH/_LceCyuVcH.md ADDED
@@ -0,0 +1,269 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Language Models with Image Descriptors are Strong Few-Shot Video-Language Learners
2
+
3
+ Zhenhailong Wang1∗, Manling $\mathbf { L i } ^ { 1 }$ ∗, Ruochen $\mathbf { X } \mathbf { u } ^ { 2 }$ , Luowei Zhou2†, Jie Lei3, Xudong Lin4, Shuohang $\mathbf { W a n g } ^ { 2 }$ , Ziyi $\mathbf { Y a n g } ^ { 2 }$ , Chenguang $\mathbf { Z } \mathbf { h } \mathbf { u } ^ { 2 }$ , Derek Hoiem1, Shih-Fu Chang4, Mohit Bansal3, Heng Ji1 1UIUC 2MSR 3UNC 4Columbia University {wangz3,hengji}@illinois.edu
4
+
5
+ # Abstract
6
+
7
+ The goal of this work is to build flexible video-language models that can generalize to various video-to-text tasks from few examples. Existing few-shot video-language learners focus exclusively on the encoder, resulting in the absence of a video-totext decoder to handle generative tasks. Video captioners have been pretrained on large-scale video-language datasets, but they rely heavily on finetuning and lack the ability to generate text for unseen tasks in a few-shot setting. We propose VidIL, a few-shot Video-language Learner via Image and Language models, which demonstrates strong performance on few-shot video-to-text tasks without the necessity of pretraining or finetuning on any video datasets. We use image-language models to translate the video content into frame captions, object, attribute, and event phrases, and compose them into a temporal-aware template. We then instruct a language model, with a prompt containing a few in-context examples, to generate a target output from the composed content. The flexibility of prompting allows the model to capture any form of text input, such as automatic speech recognition (ASR) transcripts. Our experiments demonstrate the power of language models in understanding videos on a wide variety of video-language tasks, including video captioning, video question answering, video caption retrieval, and video future event prediction. Especially, on video future event prediction, our few-shot model significantly outperforms state-of-the-art supervised models trained on large-scale video datasets. Code and processed data are publicly available for research purposes at https://github.com/MikeWangWZHL/VidIL.
8
+
9
+ # 1 Introduction
10
+
11
+ One major gap between artificial intelligence and human intelligence lies in their abilities to generalize and perform well on new tasks with limited annotations. Recent advances in large-scale pre-trained generative language models [45, 6, 71, 24] have shown promising few-shot capabilities [72, 43, 63] in understanding natural language. However, few-shot video-language understanding is still in its infancy. A particular limitation of most recent video-language frameworks [28, 21, 61, 68, 67, 25, 64, 34] is that they are encoder-only, which means they do not have the ability to generate text from videos for purposes such as captioning [62, 57], question answering [60], and future prediction [23]. Meanwhile, unified video-language models [36, 49] that are capable of language decoding still rely heavily on finetuning using a large number of manually annotated video-text pairs, therefore cannot adapt quickly to unseen tasks. Few-shot video-to-text decoding is challenging because the natural language supervision for learning video-language representation is typically based on subtitles and automatic speech recognition (ASR) transcripts [39, 68], which differ significantly from downstream tasks in terms of distribution and may have poor semantic alignment across vision and text modalities.
12
+
13
+ We propose to address this problem by harnessing the few-shot power of frozen large-scale language models, such as InstructGPT [40]. Our inspiration is derived from the fact that humans are excellent visual storytellers [15], with the ability to piece together a coherent story from a few isolated images. To mimic this, we propose VidIL, a few-shot Video-language Learner via Image and Language models, to use image models to provide information about the visual content in the video (as well as optionally use ASR to represent speech), and then we instruct language models to generate a video-based summary, answer, or other target output for diverse video-language tasks.
14
+
15
+ The main challenge of understanding videos is that, videos contain rich semantics and temporal content at multiple granularities. Unlike static images which depict objects, attributes and events in a snapshot, the temporal dimension of videos further conveys the state changes of the objects, actions, and events. For example, in Figure 1, the individual frame captions of the video clip only describe static visual features such as "a person holding a green object in hand". In contrast, a correct video-level description would be "a woman makes realistic looking leaves and flowers for a cake", which involves reasoning over a collection of objects and events that occur at different timestamps in the video clip, such as "cake decorating" and "flowered design". Hence, to inform video-level description and queries, we need to represent all of this information and its temporal ordering.
16
+
17
+ ![](images/b5f930daf9032229a0d0a4e399381948a20cacaccc02903750ded88494988f0e.jpg)
18
+ Figure 1: Multiple levels of information in videos.
19
+
20
+ To address the unique challenges of videos, we propose to decompose a video into three levels: the video output, frame captions, and visual tokens (including objects, events, attributes). One major benefit from this hierarchical video representation is that we can separate the visual and temporal dimensions of a video. We leverage frozen image-language foundational models at lower levels to collect salient visual features from the sparsely sampled frames. Specifically, we first leverage a pretrained image-language contrastive model CLIP [44] to perform visual tokenization, based on the similarity score between frames and tokens of objects, events and attributes. The tokenization is done under the guidance of semantics role labeling [14], which provides us with candidate events with involved objects and related attributes. Next, in order to capture the overall semantics at the frame level, we employ the pretrained image captioner in the image-language model BLIP [26] to obtain frame captions. Finally, we instruct a pretrained large language model using in-context learning [40, 13, 51, 48] to interpret visual tokens and frame captions into the target textual output. In detail, we temporally order visual tokens and frame captions using specially designed prompts such as “First...Then...Finally”, to instruct the pretrained language model to track the changes of objects, events, attributes and frame semantics along the temporal dimension.
21
+
22
+ Without pretraining or finetuning on any video datasets, we show that our approach outperforms both video-language and image-language state-of-the-art baselines on few-shot video captioning and question answering tasks. Moreover, on video-language event prediction, our approach significantly outperforms fully-supervised models while using only 10 labeled examples. We further demonstrate that our generative model can benefit broader video-language understanding tasks, such as text-video retrieval, via pseudo label generation. Additionally, we show that our model is highly flexible in adding new modalities, such as ASR transcripts.
23
+
24
+ # 2 Related Work
25
+
26
+ # 2.1 Image-Language Models and Their Applications on Video-Language Tasks
27
+
28
+ Large-scale image-language pretraining models optimize image-text matching through contrastive learning [44, 17] and multimodal fusion [65, 27, 58, 66, 35, 52, 8, 29, 73, 70, 18, 16]. Recently,
29
+
30
+ BLIP [26] proposes a bootstrapping image-language pretraining framework with a captioner and a filterer which has shown promising performance on various image-language tasks. However, video-language pretraining [25, 36, 28, 38, 3, 1, 42, 33] is still hindered by noisy and domain-specific video datasets [74, 22, 39]. Naturally, researchers start to explore transferring the rich knowledge from image models to videos. Different from the traditional way of representing videos by 3D dense features [12], recent work [21, 25] proves that sparse sampling is an effective way to represent videos, which facilitates applying pre-trained image-language models to video-language tasks [37, 11]. Specifically, the image-language model BLIP [26] sets new state-of-the-art on zero-shot retrieval-style video-language tasks, such as video retrieval and video question answering. However, for generationstyle tasks such as domain-specific video captioning, video-language model UniVL [36] still leads the performance but highly rely on fine-tuning. In this work, we extend the idea of leveraging image-language models to a wide variety of video-to-text generation tasks. We further connect imagelanguage models with language models which empowers our model with strong generalization ability. We show that the knowledge from both image-language pretraining and language-only pretraining can benefit video-language understanding in various aspects.
31
+
32
+ # 2.2 Unifying MultiModal Tasks with Language Models
33
+
34
+ The community has paid much attention to connecting different modalities with a unified representation recently. Text-only generation models, such as T5 [46], have been extended to vision-language tasks by text generation conditioned on visual features [9, 53, 50, 75, 55]. In order to fully leverage the generalization power from pretained language models, [63] represents images using text in a fully symbolic way. [32] includes more modalities such as video and audio, but requires annotated video-text data to jointly training the language model with the video and audio tokenizer. In this work, we propose a temporal-aware hierarchical representation for describing a video textually. To our knowledge, we are the first work to leverage prompting a frozen language model for tackling few-shot video-language tasks with a unified textual representation. Concurrent work Socratic [69] uses a zero-shot language-based world-state history to represent long videos with given time stamps, while our model can quickly adapt to different video and text distributions with few examples. Furthermore, we show that by injecting temporal markers to the prompt we can make a pre-trained language model understand fine-grained temporal dynamics in video events. Compared with the concurrent work Flamingo [2], which requires dedicated vision-language post-pretraining, our framework does not require to pretrain or finetune on any video data. Our framework is simple and highly modulated where all the components are publicly available. Additionally, our framework is more flexible on adding new modalities, e.g., automatic speech recognition, without the need for complex redesigning.
35
+
36
+ # 3 Method
37
+
38
+ We propose a hierarchical video representation framework which decomposes a video into three levels, i.e., visual token level, frame level and video level. The motivation is to separate the spatial and temporal dimension of a video in order to leverage image-language and language-only foundation models, such as CLIP [44] and GPT-3 [6]. All three levels use a unified textual representation which enables us to leverage the powerful few-shot ability from pretrained language models.
39
+
40
+ # 3.1 Frame Level: Image Captioning
41
+
42
+ Following [21] we first perform sparse sampling to obtain several video frames. Unless otherwise specified, we sample 4 frames for frame level and 8 frames for visual token level. We then feed each frame into a pre-trained image-language model to obtain frame level captions. An example can be found in the blue part of Figure 2. In our experiments, we use BLIP [26], a recent image-language framework containing both image-grounded encoder and decoder, for generating frame captions. We follow [26] to do both captioning and filtering on each frame. However, as mentioned in Section 1, videos contain rich semantics and temporal contents at multiple granularities. It is not enough to generate video-level target text such as video captions solely based on frame captions. Thus, we further perform visual tokenization for each frame to capture features at a finer granularity.
43
+
44
+ ![](images/c144de0cb595e241110b349a7da85b61029ef363498acc4c08b0c7647b08efae.jpg)
45
+ Figure 2: Overview of VidIL framework. We represent a video in a unified textural representation containing three semantic levels: visual token level, frame level, and video level. At visual token level, we extract salient objects, events, attributes for each sampled frame. At frame level, we perform image captioning and filtering. At video level, we construct video representation by aggregating the visual tokens, frame captions and other text modalities such as ASR, using a few-shot temporalaware prompt. We then feed the prompt to a pre-trained language model together with task-specific instructions to generate target text for a variety of video-language tasks. Examples of the full prompt for different tasks can be found in Appendix ??.
46
+
47
+ # 3.2 Visual Token Level: Structure-Aware Visual Tokenization
48
+
49
+ At this level, we aim to extract the textual representations of salient visual token types, such as objects, events and attributes. We found that pre-defined classes for classification, such as those in ImageNet [10], are far from enough for covering the rich semantics in open-domain videos. Thus, instead of using classification-based methods for visual tokenization as in previous work [32, 63], we adopt a retrieval-based visual tokenization approach by leveraging pre-trained contrastive imagelanguage models. Given a visual token vocabulary which contains all candidate object, event, and attribute text phrases, we compute the image embedding of a frame and the text embeddings of the candidate visual tokens using a contrastive multi-modal encoder, CLIP [44]. We then select top 5 visual tokens per frame based on the cosine similarity of the image and text embeddings. An example of the extracted object tokens can be found in the green part of Figure 2.
50
+
51
+ Unlike in images where objects and attributes already cover most visual features, events are more informative in videos. In order to discover events from video frames, we construct our own event vocabulary by extracting event structures from Visual Genome [19] synsets3 using Semantic Role Labeling. Specifically, we first select the phrases that contain at least one verb and one argument as events. Then we remove highly similar events based on their sentence similarity using SentenceBERT [47] embeddings. For object vocabulary, we adopt OpenImage [20] full classes $( { \sim } 2 0 \mathbf { k } )$ , instead of using the visually groundable subset $( \sim 6 0 0 )$ as in concurrent work [69]. We found that using large but noisy vocabulary is more effective than using small but clean vocabulary in our retrieval-based setting with CLIP. For attribute vocabulary, we adopt visual genome attribute synset. In Section 4.6, we provide ablation study on the impact of different types of visual tokens. The statistics of visual token vocabulary can be found in Appendix Table ??.
52
+
53
+ ![](images/331592c36e0944e6b5f6973236f3089e33d229d668d68f0224a0f67fdb784fba.jpg)
54
+ Figure 3: Temporal-aware prompt successfully distinguishes the Sunset and Sunrise scenarios based on the temporal ordering change of objects and frame captions, while the static prompt fails.
55
+
56
+ # 3.3 Video Level: Temporal-Aware Few-shot Prompting
57
+
58
+ Once we obtain the textual representation from frame level and visual token level, the final step is to put the pieces together to generate a video level target text. The goal is to build a model that can be quickly adapted to any video-to-text generation task with only a few examples. To this end, we propose to leverage large-scale pre-trained language models, such as GPT-3 [6], with a temporal-aware few-shot prompt. As shown in Figure 2, our framework can be readily applied to various video-to-text generation tasks, such as video captioning and video question answering, with a shared prompt template. The proposed prompting strategy enables a language model to attend to the lower level visual information as well as taking into account the temporal ordering.
59
+
60
+ Here, we use the video captioning task depicted in Figure 2 to illustrate the details. The few-shot prompt consists of three parts: instruction, few-shot context, and task query. The instruction is a concise description of the generation task, e.g., "Generate a video caption based on the objects, events, attributes and frame captions. Example:", which is proved to be effective in zero-shot and few-shot settings [6, 59]. The few-shot context contains the selected in-context examples as well as the test video instance. Each video instance is represented by the aggregated visual tokens4, e.g., "Objects: First, bath toy. Then,..." the frame captions, such as "Frame Captions: First, a toddler playing in a bathtub filled with toys. Then,...", and the ASR inputs if available, e.g., "Subtitle:<ASR Transcript>". Finally, the task query is a task-specific suffix indicating the target text format, e.g. "Video Caption:". For in-context examples (omitted here for simplicity), the task query is followed by ground truth annotation, while for the test instance, the generation starts at the end of the task query.
61
+
62
+ Formally, we denote the instruction line as $\mathbf { t }$ , few-shot context as c, the task query as q, and the target text as $\mathbf { y }$ , where $\mathbf { y } = ( y _ { 1 } , y _ { 2 } , . . . , y _ { L } )$ . The generation of the next target token $y _ { l }$ can be modeled as:
63
+
64
+ $$
65
+ y _ { l } = \mathop { \arg \operatorname* { m a x } } _ { y } p ( y | \mathbf { s } , \mathbf { c } , \mathbf { q } , y _ { < l } )
66
+ $$
67
+
68
+ In order to capture the temporal dynamics between frames and visual tokens, we further propose to inject temporal markers to the prompt. As shown in the few-shot context in Figure 2, each visual token and frame caption is prefixed with a natural language phrase indicating its temporal ordering, e.g., "First,","Then,", and "Finally,". We found adding the temporal marker can make the language model conditioned on not only literal but also temporal information of the context. We show an example in Figure 3, where we compare our temporal-aware prompt with a static prompt on video captioning using InstructGPT. Again, the in-context examples are omitted here, which can be found in Appendix ??. In this example, the only difference between these two contexts is the ordering of the visual tokens and the frame captions. For the context on the left, where "sun moving" appears before "night sky", we are expected to see a story talking about sunset, while for the context on the right, we are expected to see sunrise. We can see the static prompt generates captions about sunset for both contexts, while the temporal-aware prompt can capture temporal ordering correctly and generate sunrise for the context on the right.
69
+
70
+ # 4 Experiments
71
+
72
+ # 4.1 Experimental Setup
73
+
74
+ To comprehensively evaluate our model, we show results on four video-language understanding tasks in few-shot settings: video captioning, video question answering (QA), video-language event prediction, and text-video retrieval. We compare our approach with state-of-the-art approaches on five benchmarks, i.e, MSR-VTT [62], MSVD [7], VaTeX [57], YouCook2 [74], and VLEP [23]. The statistics of the datasets can be found in Table 1. For more details please refer to Appendix ??.
75
+
76
+ Implementation Details. We use CLIP-L/146 as our default encoder for visual tokenization. We adopt BLIP captioning checkpoint7 finetuned on COCO [31] for frame captioning. We use InstructGPT [40] as our default language model for generating text conditioned on the few-shot prompt. To construct event vocabulary, we use the semantic role labeling model from AllenNLP8. The experiments are conducted on 2 NVIDIA V100 (16GB) GPUs. All few-shot
77
+
78
+ Table 1: Statistics of datasets in our experiments
79
+
80
+ <table><tr><td>Dataset</td><td>Task</td><td>Split Count # train /#eval</td></tr><tr><td>MSR-VTT[62]</td><td>Captioning; QA</td><td>6,513 /2.990</td></tr><tr><td>MSR-VTT[62]</td><td>Retrieval</td><td>7,010 / 1,000</td></tr><tr><td>MSVD [7]</td><td>Question Answering</td><td>30,933 /13,157</td></tr><tr><td>VaTeX v1.15 [57]</td><td>Captioning; Retrieval</td><td>25,991/6.000</td></tr><tr><td>YouCook2[74]</td><td>Captioning</td><td>10,337 /3,492</td></tr><tr><td>VLEP [23]</td><td>Event Prediction</td><td>20,142/4,192</td></tr></table>
81
+
82
+ finetuning on baselines and semi-supervised training are performed on 2 Nvidia V100 16G GPUs.
83
+
84
+ In-context Example Selection. From our preliminary experiments, we find that the generation performance is sensitive to the quality of in-context examples. For example, for QA tasks such as MSVD-QA where the annotations are automatically generated, the <question, answer> pair in randomly selected in-context examples can be only weakly-correlated with the video context. Thus, instead of using a fixed prompt for each query, we dynamically filter out the irrelevant in-context examples. Specifically, given a randomly sampled $M .$ -shot support set from the training set, we select a subset of $N _ { ☉ }$ -shots as in-context examples based on their SentenceBERT [47] similarities with text queries. Furthermore, we reorder the selected examples in ascending order based on the similarity score to account for the recency bias [72] in large language models. For QA tasks, we choose the most relevant in-context examples by comparing with questions. While for captioning task, we compare with frame captions. If not otherwise specified, we use $M { = } I O$ and $N { = } 5$ , which we consider as 10-shot training.
85
+
86
+ # 4.2 Few-shot Video Captioning
87
+
88
+ We report BLEU-4 [41], ROUGE-L [30], METEOR [5], and CIDEr [54] scores on three video captioning benchmarks covering both open-domain (MSR-VTT, VaTeX) and domain-specific (YouCook2) videos. We compare with both state-of-the-art video captioner (UniVL [36]) and image captioner (BLIP [26]). In order to implement the BLIP baseline for few-shot video captioning, we extend the approach used for text-video retrieval evaluation in [26] to video-language training. Specifically, we concatenate the visual features of sampled frames and then feed them into the image-grounded text-encoder to compute the language modeling loss. This is equivalent to stitching the sampled frames into a large image and then feeding it to BLIP for image captioning. We found that this simple approach results in very strong baselines.
89
+
90
+ As shown in Table 2, existing methods have strong bias on certain datasets. For example, UniVL performs well on YouCook2 but fails on MSR-VTT and VaTeX, while BLIP performs the opposite. This is because UniVL is pretrained on HowTo100M which favors instructional videos, i.e., YouCook2, while BLIP is pre-training on image-caption pairs which favors description-style captions, i.e., MSR-VTT and VaTeX. On the contrary, our model performs competitively on both open-domain and instructional videos, and significantly outperforms the baselines on the average CIDEr score across all three benchmarks. This indicates that by leveraging language models, we can maintain strong few-shot ability regardless of the video domain or the target caption distribution.
91
+
92
+ Table 2: 10-shot video captioning results. ♠ indicates concurrent work. The reported Flamingo [2] results are using 16 shots. #VideoPT represents the number of videos used for pre-training. B-4, R-L, $M$ , $C$ represents BLEU-4, ROUGE-L, METEOR and CIDEr. Avg $C$ represents the average CIDEr score across all available benchmarks. ASR indicates whether the model has access to the ASR subtitles. $B L I P$ and $B L I P _ { c a p }$ use the pretrained checkpoint and the finetuned checkpoint on COCO captioning. All results are averaged over three random seeds.
93
+
94
+ <table><tr><td rowspan="2">Method</td><td rowspan="2">#VideOpr ASR</td><td rowspan="2"></td><td rowspan="2">B-4R-LM</td><td colspan="3">MSR-VTTCaption</td><td colspan="3">YouCook2 Caption C</td><td rowspan="2"></td><td colspan="3">VaTex Caption</td><td rowspan="2">Avg C</td></tr><tr><td></td><td></td><td>C</td><td>B-4R-LM</td><td></td><td></td><td>B-4 R-L M</td><td></td><td>C</td></tr><tr><td>Few-shot</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>UniVL</td><td>1.2M</td><td>No</td><td>2.1 22.5 9.5</td><td></td><td></td><td>3.6</td><td>3.3</td><td>25.3 11.6</td><td>34.1</td><td>1.7</td><td>15.7</td><td>8.0</td><td>2.1</td><td>13.3</td></tr><tr><td>BLIP</td><td>0</td><td>No</td><td>27.7 43.0 23.0 39.5</td><td></td><td></td><td></td><td>0.7</td><td>9.0 3.4</td><td>11.5</td><td>13.5</td><td>39.5</td><td>15.4</td><td>20.7</td><td>23.9</td></tr><tr><td>BLIPcap</td><td>0</td><td>No</td><td>21.648.022.7 30.2</td><td></td><td></td><td></td><td>3.7</td><td>8.6 3.8</td><td>9.4</td><td>20.7</td><td>41.5</td><td>17.4</td><td>28.9</td><td>22.8</td></tr><tr><td>VidIL(ours)</td><td>0</td><td>No</td><td>26.0 51.7 24.7 36.3</td><td></td><td></td><td></td><td>2.6</td><td>22.9 9.5</td><td>27.0</td><td>22.2</td><td></td><td>43.620.0</td><td>36.7</td><td>33.3</td></tr><tr><td>UniVL</td><td>1.2M</td><td>Yes</td><td>-</td><td></td><td>=</td><td>-</td><td>4.3</td><td>26.4 12.2</td><td>48.6</td><td>2.7</td><td>17.7</td><td>10.2</td><td>3.4</td><td>26.0</td></tr><tr><td>VidIL(ours)</td><td>0</td><td>Yes</td><td></td><td></td><td></td><td></td><td>10.7 35.9</td><td></td><td>19.4 111.6</td><td></td><td>23.2 44.2 20.6 38.9</td><td></td><td></td><td>75.3</td></tr><tr><td>Flamingo-3B(16)</td><td>27M</td><td>No</td><td></td><td></td><td></td><td></td><td></td><td></td><td>73.2</td><td></td><td></td><td></td><td>57.1</td><td></td></tr><tr><td>Flamingo-80B(16) 27M</td><td></td><td>No</td><td></td><td></td><td></td><td></td><td></td><td></td><td>84.2</td><td></td><td></td><td></td><td>62.8</td><td>=</td></tr><tr><td>Fine-tuning</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>UniVL</td><td>1.2M</td><td>No</td><td>42.0 61.0 29.0 50.1</td><td></td><td></td><td></td><td></td><td></td><td></td><td>[11.2 40.1 17.6 127.0|22.8 38.6 22.3 33.4</td><td></td><td></td><td></td><td>70.2</td></tr><tr><td>UniVL</td><td>1.2M</td><td>Yes</td><td>=</td><td></td><td></td><td></td><td></td><td></td><td></td><td>16.6 45.7 21.6176.823.7 39.3 22.7 35.6</td><td></td><td></td><td></td><td>106.2</td></tr></table>
95
+
96
+ As discussed in Section 1, video captions describe the content in various semantic levels. The N-gram based metric may not fairly reflect the models’ performance in capturing the video-caption alignment. We further verify this hypothesis in Section 4.5. Thus, in addition to automatic metrics, we include qualitative examples illustrated in Figure 4. More examples are in Appendix ??.
97
+
98
+ Additionally, for most existing methods and also concurrent work, e.g., Flamingo [2], adding a new modality often requires a dedicated model redesign or retraining. However, the nature of our framework, where we use a unified textual representation for each level, makes it highly flexible for incorporating new modalities. As shown in row 6 in Table, our model can effectively utilize extra information from ASR to obtain significantly better few-shot performance on certain datasets such as YouCook2.
99
+
100
+ ![](images/42488e5e146be037d7c57abcc48a78f8af1cf75e6517bc50d3e1b32bfd715b6a.jpg)
101
+
102
+ Figure 4: Qualitative examples on video captioning. Grey boxes contain part of the video representation from our model. Blue boxes contain caption generation from different models. Green boxes contain ground truth annotations. Bold green text highlights the correct information that is not captured in baseline outputs which can be reasoned from our visual tokens and frame captions.
103
+
104
+ # 4.3 Few-shot Video Question Answering
105
+
106
+ We compare the test accuracy of our approach with few-shot pretrained BLIP, $\mathsf { B L I P } _ { V Q A }$ [26], and concurrent work Flamingo [2] on two video question answering benchmarks, MSR-VTT_QA and MSVD_QA. $\mathsf { B L I P } _ { V Q A }$ represents finetuned BLIP on VQA [4] dataset, which is the previous SOTA on zero/few-shot video question answering. In order to have fairer comparison with $\mathsf { B L I P } _ { V Q A }$ , we reduce the shot number to 5 and report the average accuracy on three sets of randomly selected 5-shot examples. As shown in Table 3, our method outperforms previous SOTA by a large margin. Comparing with concurrent work Flamingo, which is post-pretrained on a large number of video-text data, our model is training-free and did not observe any video data. However, with only imagelanguage and language-only knowledge, our 5-shot model is able to outperform 8-shot Flamingo-3B and achieve on-par performance with 4-shot Flamingo-80B.
107
+
108
+ Table 3: Video QA results. $\mathsf { B L I P } _ { V Q A }$ is finetuned on VQA [4]. ♠ indicates concurrent work. PT, FT indicates pretraining and finetuning.
109
+
110
+ <table><tr><td>Method</td><td>#videoPT</td><td>#videoFT</td><td>MSR-VTT</td><td>MSVD</td></tr><tr><td>BLIP</td><td>0</td><td>O-shot</td><td>0.55</td><td>0.45</td></tr><tr><td>BLIP</td><td>0</td><td>5-shot</td><td>0.84</td><td>0.53</td></tr><tr><td>BLIPvQA [26]</td><td>0</td><td>O-shot</td><td>19.2</td><td>35.2</td></tr><tr><td>VidIL(ours)</td><td>0</td><td>5-shot</td><td>21.2</td><td>39.1</td></tr><tr><td>Flamingo-3B [2]</td><td>27M</td><td>4-shot</td><td>14.9</td><td>33.0</td></tr><tr><td>Flamingo-3B_[2]</td><td>27M</td><td>8-shot</td><td>19.6</td><td>37.0</td></tr><tr><td>Flamingo-80B [2]</td><td>27M</td><td>4-shot</td><td>23.9</td><td>41.7</td></tr><tr><td>Flamingo-80B [2]</td><td>27M</td><td>8-shot</td><td>27.6</td><td>45.5</td></tr><tr><td>ALPRO [25]</td><td>2M</td><td>full-shot</td><td>42.1</td><td>45.9</td></tr></table>
111
+
112
+ Table 4: Accuracy $( \% )$ on VLEP hidden test set.
113
+
114
+ <table><tr><td>Method</td><td>#videoFT</td><td>Acc</td></tr><tr><td>VLEP [23] MERLOT[68]</td><td>20142 20142</td><td>67.5 68.4</td></tr><tr><td>VidIL(ours)</td><td>10-shot</td><td>72.0</td></tr><tr><td>Human</td><td>-</td><td>90.5</td></tr></table>
115
+
116
+ # 4.4 Few-shot Video-Language Event Prediction
117
+
118
+ In this section, we show that our model not only can answer questions about the video visual features but also answering "What is more likely to happen next?". Given a video with associated subtitle transcript as premise, the video-language event prediction (VLEP) task is to predict the most likely future event. The original VLEP [23] paper formulates the problem as a binary classification problem where the model will be chosen from two possible future event candidates. Instead, we formulate this problem as another video-to-text generation problem to fit into our framework. Figure 5 depicts an example with the same format as in Figure 2. Similar to the evaluation setting in QA, the generated free-form text will first be mapped to one of the two candidate answers using SentenceBert [47], and then calculate the accuracy. In Table 4, we report accuracy on the hidden test set of VLEP [23]. To our surprise, our 10-shot model outperforms state-of-the-art fully-supervised baseline, i.e., MERLOT [68], by a large margin $( \sim 4 \% )$ . This shows that our model has strong few-shot ability not only on videolanguage understanding but also on prediction. Since event prediction tasks rely heavily on temporal ordering, we show that with the proposed temporal-aware prompting, language models can be guided to capture temporal dynamics between historical and future events.
119
+
120
+ ![](images/337717ccf8591fcb87cdc2bcb90b9982ea93bafdcb263be40f57ceb4066b57ea.jpg)
121
+ Figure 5: Prompt for VLEP task.
122
+
123
+ # 4.5 Semi-supervised Text-Video Retrieval
124
+
125
+ In addition to video-to-text generation tasks, we show that a broader range of video-language tasks can benefit from our few-shot video captioner from a data perspective. Here, we consider a lowbudget semi-supervised setting where we only have a few labeled video-caption pairs and a large amount of unlabeled videos. The idea is to leverage our video captioner to generate pseudo labels for training any given vision-language models. As a case study, we evaluate on two text-video retrieval benchmarks, i.e., MSR-VTT and VaTeX. We use greedy decoding to generate pseudo caption for each video in the training set. We then train an identical base model, i.e., BLIP, using different pseudo labeled data as well as ground truth annotations. We report Recall $@$ 1 and 5 for both video-to-text and text-to-video retrieval. Table 5 shows that through training on our pseudo labels, we can achieve significant improvements compared with zero-shot BLIP. We also show that the performance gain is not simply a result of training on more data, since finetuning on the pseudo labels generated by other baselines (UniVL, BLIP) is less effective and can even hurt the performance. Furthermore, on MSR-VTT Recall $@$ 5 we can even achieve comparable performance against BLIP model finetuned on full ground truth annotations.
126
+
127
+ Table 5: Semi-supervised text-video retrieval with 10 labeled examples. $\mathrm { V _ { l a b e l } }$ or $\mathrm { \Delta V _ { u n l a b e l } }$ are the number of labeled and unlabeled videos, respectively. $t \_ R I$ and $t \_ R$ denote video-to-text Recall $@ 1$ and 5. $\nu \_ R I$ and $\nu \_ R 5$ denote text-to-video Recall $@ 1$ and 5.
128
+
129
+ <table><tr><td rowspan="2">Model</td><td rowspan="2">Pseudo Label</td><td colspan="5">MSR-VTTRetrieval</td><td colspan="5">VaTexRetrieval</td></tr><tr><td>Vlabel/Vunlabel t_R1t_R5v_R1</td><td></td><td></td><td></td><td>v_R5</td><td>Vlabel/Vunlabel t_R1t_R5v_R1</td><td></td><td></td><td></td><td>v_R5</td></tr><tr><td>BLIP</td><td></td><td></td><td>33.2</td><td>57.2</td><td>40.5</td><td>62.8</td><td></td><td>28.2</td><td>53.4</td><td>34.0</td><td>58.6</td></tr><tr><td>BLIP</td><td>UniVL</td><td>10 /7010</td><td>33.1</td><td>57.3</td><td>33.6</td><td>57.7</td><td>10 /22685</td><td>25.5</td><td>47.7</td><td>26.1</td><td>49.1</td></tr><tr><td>BLIP</td><td>BLIP</td><td>10/7010</td><td>35.6</td><td>60.8</td><td>39.8</td><td>60.4</td><td>10/22685</td><td>26.3</td><td>50.5</td><td>29.3</td><td>53.6</td></tr><tr><td>BLIP</td><td>BLIPcap</td><td>10/7010</td><td>35.3</td><td>58.0</td><td>39.1</td><td>63.3</td><td>10/22685</td><td>23.9</td><td>46.8</td><td>27.5</td><td>49.7</td></tr><tr><td>BLIP</td><td>VidIL(ours)</td><td>10/7010</td><td>39.6</td><td>64.5</td><td>40.8</td><td>65.2</td><td>10 /22685</td><td>33.3</td><td>59.1</td><td>33.7</td><td>59.5</td></tr><tr><td>BLIP</td><td>Ground Truth</td><td>7010/0</td><td>43.6</td><td>66.2</td><td>43.1</td><td>67.2</td><td>22685/0</td><td>40.1</td><td>66.4</td><td>40.1</td><td>66.6</td></tr><tr><td>ALPRO [25]</td><td>Ground Truth</td><td>140200/0</td><td>32.0</td><td>60.6</td><td>33.9</td><td>60.7</td><td></td><td>-</td><td>-</td><td>-</td><td>-</td></tr><tr><td>DRL [56]</td><td>Ground Truth</td><td>180000/0</td><td>54.1</td><td>77.4</td><td>52.9</td><td>78.5</td><td>-</td><td>-</td><td>-</td><td>-</td><td>-</td></tr></table>
130
+
131
+ Another interesting observation is that, compared with the video captioning results in Table 2, we found that the gain of our model over baselines on text-video retrieval is more visible than on captioning. A key factor in performing well on text-video retrieval tasks is to learn a good video-text multi-modal alignment. This result shows that our pseudo labels capture richer video-text alignment that can benefit the retrieval-style downstream task. The N-gram based generation metrics, e.g., BLEU, may not be able to fully reflect the alignment information, due to the variety of semantic levels in video captions. Furthermore, from a data perspective, our video captioner can be viewed as a data augmentation tool which is capable of generating or augmenting any open-domain videolanguage pretraining datasets with minimal human effort. As a result, we can potentially improve video-language pretraining by constructing a cleaner and more diverse video-text corpus.
132
+
133
+ Table 6: Impact of visual tokens and temporal dimension.
134
+
135
+ <table><tr><td colspan="2">Video Representation</td><td>Avg↑ Std↓</td><td></td></tr><tr><td rowspan="3">Visual Token</td><td>Frame Frame+Object</td><td>39.6 40.3</td><td>3.7 2.9</td></tr><tr><td>Frame+Object+Event</td><td>39.9</td><td>2.8</td></tr><tr><td>Frame+Object+Attibute Frame+Object+Event+Attribute</td><td>40.9 40.8</td><td>2.9 2.4</td></tr><tr><td>Temporal</td><td></td><td>Reduce to one frame Reverse temporal order</td><td>38.5 40.7</td><td>2.4 1.7</td></tr></table>
136
+
137
+ Table 7: Impact of shot selection. #ICE indicates the number of in-context examples in the prompt. Details of in-context example selection are in the Appendix.
138
+
139
+ <table><tr><td>#shot</td><td colspan="3">w/o selection</td><td colspan="3">w/ selection</td></tr><tr><td></td><td>#ICE</td><td>Avg↑</td><td>Std</td><td>#ICE</td><td>Avg↑</td><td>Std↓</td></tr><tr><td>5</td><td>5</td><td>38.4</td><td>2.1</td><td>5</td><td>40.4</td><td>1.2</td></tr><tr><td>10</td><td>10</td><td>41.3</td><td>3.6</td><td>5</td><td>40.8</td><td>2.4</td></tr><tr><td>20</td><td>20</td><td>42.6</td><td>3.3</td><td>5</td><td>42.2</td><td>2.0</td></tr><tr><td>30</td><td>30</td><td>40.0</td><td>2.9</td><td>5</td><td>41.1</td><td>1.9</td></tr></table>
140
+
141
+ # 4.6 Ablation Studies
142
+
143
+ We perform comprehensive ablation studies on our few-shot prompt including the impact of different video representation, number of shots and in-context selection. All the ablation results are evaluated on MSVD_QA validation set, and we report the mean and standard deviation of each setting on three sets of randomly sampled shots. For the cases with in-context example selection, we further select 5 examples as in-context examples from the sampled shots, while for the cases without in-context selection, all shots will be feed into the prompt. In Table 6, we show adding visual tokens consistently improves not only the model accuracy but also the model variance. A lower standard deviation indicates that the model is less sensitive to the few-shot sampling.
144
+
145
+ To further demonstrate the impact of the additional temporal dimension of videos, we perform two ablations on the "Frame+Object+Event+Attribute" setting. First, we reduce the number of frame captions and visual tokens to be one9 for each video. We found that the performance drops significantly compared with using the default four frames, which indicates the model’s ability to incorporate information from multiple timestamps. Further, we found that fine-grained temporal modeling is rarely required for performing well on current video-language benchmarks. As shown in the ablation result where we reverse the order of all visual tokens and frame captions, the performance decreased only marginally, which indicates that current benchmarks may not be sufficient in reflecting the benefits from better temporal ordering.
146
+
147
+ In Table 7, we first show that, with the same context length, namely, 5 in-context examples, in-context example selection significantly increases the performance as well as the robustness. At 10-shot, and 20-shot, directly fitting more shots into the prompt results in better performance. In-context selection achieves slightly lower performance but with significantly better efficiency due to shorter context. Interestingly, at 30-shot, in-context selection with 5 examples outperforms directly adding all 30 shots into the prompt. This is showing that in-context selection can help the model utilize a larger number noisy video examples. Nevertheless, we still observe that the benefit of adding more shots saturated at around 20 to 30 shots, even if with in-context selection. we view this as a remaining challenging on how to make language models benefit from longer contexts.
148
+
149
+ # 5 Conclusions, Limitations and Future Work
150
+
151
+ This paper proposes VidIL, a few-shot Video-language Learner via Image and Language models. It demonstrates the strong ability of large-scale language models on performing video-to-text tasks when frame features are provided as unified text representations using image-language models. We propose a temporal order aware prompt by decomposing videos into a hierarchical structure, which is able to plug in multiple levels of frame features, along with speech transcripts. Without pretraining on videos, our model outperforms vision-language models learned from large-scale video datasets on a variety of few-shot tasks, such as domain-specific captioning, question answering, and future event prediction. One limitation of using unified textual representation is that we might lose low-level visual features which can be essential for some specific tasks, such as fine-grained spatial visual question answering. We also observe that current video-language benchmarks rarely require explicit temporal tracking on the frames and visual tokens. Future work will focus on leveraging large-scale language models for learning script knowledge from long videos where temporal dynamics are better emphasized.
152
+
153
+ # 6 Broader Impact
154
+
155
+ An open-domain few-shot video-language learner has a wide range of beneficial applications for society, such as automatically detecting violent or mature content in videos and helping people with vision impairment understand videos. However, since the language model is pretrained on massive internet-scale text data, there might be unexpected output that can have potential negative impact on the society, such as bias against people of a certain gender, race or sexuality. Future work and dedicated collaboration from the community are needed to alleviate the potential negative societal impact of large language models.
156
+
157
+ # Acknowledgements
158
+
159
+ We thank the anonymous reviewers helpful suggestions. This research is based upon work supported in part by U.S. DARPA AIDA Program No. FA8750-18-2-0014 and U.S. DARPA KAIROS Program Nos. FA8750-19-2-1004. The views and conclusions contained herein are those of the authors and should not be interpreted as necessarily representing the official policies, either expressed or implied, of DARPA, or the U.S. Government. The U.S. Government is authorized to reproduce and distribute reprints for governmental purposes notwithstanding any copyright annotation therein.
160
+
161
+ References
162
+ [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. 3
163
+ [2] Jean-Baptiste Alayrac, Jeff Donahue, Pauline Luc, Antoine Miech, Iain Barr, Yana Hasson, Karel Lenc, Arthur Mensch, Katie Millican, Malcolm Reynolds, et al. Flamingo: a visual language model for few-shot learning. ArXiv preprint, abs/2204.14198, 2022. 3, 7, 8
164
+ [3] Jean-Baptiste Alayrac, Adrià Recasens, Rosalia Schneider, Relja Arandjelovic, Jason Ramapuram, Jeffrey De Fauw, Lucas Smaira, Sander Dieleman, and Andrew Zisserman. Self-supervised multimodal versatile networks. 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. 3
165
+ [4] Stanislaw Antol, Aishwarya Agrawal, Jiasen Lu, Margaret Mitchell, Dhruv Batra, C. Lawrence Zitnick, and Devi Parikh. VQA: visual question answering. In 2015 IEEE International Conference on Computer Vision, ICCV 2015, Santiago, Chile, December 7-13, 2015, pages 2425–2433. IEEE Computer Society, 2015. 7, 8
166
+ [5] Satanjeev Banerjee and Alon Lavie. METEOR: An automatic metric for MT evaluation with improved correlation with human judgments. In Proceedings of the ACL Workshop on Intrinsic and Extrinsic Evaluation Measures for Machine Translation and/or Summarization, pages 65–72, Ann Arbor, Michigan, 2005. Association for Computational Linguistics. 6
167
+ [6] 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 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. 1, 3, 5
168
+ [7] David Chen and William Dolan. Collecting highly parallel data for paraphrase evaluation. In Proceedings of the 49th Annual Meeting of the Association for Computational Linguistics: Human Language Technologies, pages 190–200, Portland, Oregon, USA, 2011. Association for Computational Linguistics. 6
169
+ [8] 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 European conference on computer vision, pages 104–120. Springer, 2020. 2
170
+ [9] Jaemin Cho, Jie Lei, Hao Tan, and Mohit Bansal. Unifying vision-and-language tasks via text generation. 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 1931–1942. PMLR, 2021. 3
171
+ [10] Jia Deng, Wei Dong, Richard Socher, Li-Jia Li, Kai Li, and Fei-Fei Li. 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, pages 248–255. IEEE Computer Society, 2009. 4
172
+ [11] Han Fang, Pengfei Xiong, Luhui Xu, and Yu Chen. Clip2video: Mastering video-text retrieval via image clip. ArXiv preprint, abs/2106.11097, 2021. 3
173
+ [12] Christoph Feichtenhofer, Haoqi Fan, Jitendra Malik, and Kaiming He. Slowfast networks for video recognition. In 2019 IEEE/CVF International Conference on Computer Vision, ICCV 2019, Seoul, Korea (South), October 27 - November 2, 2019, pages 6201–6210. IEEE, 2019. 3
174
+ [13] Tianyu Gao, Adam Fisch, and Danqi Chen. Making pre-trained language models better few-shot learners. In Proceedings of the 59th Annual Meeting of the Association for Computational Linguistics and the 11th International Joint Conference on Natural Language Processing (Volume 1: Long Papers), pages 3816–3830, Online, 2021. Association for Computational Linguistics. 2
175
+ [14] Matt Gardner, Joel Grus, Mark Neumann, Oyvind Tafjord, Pradeep Dasigi, Nelson F. Liu, Matthew Peters, Michael Schmitz, and Luke Zettlemoyer. AllenNLP: A deep semantic natural language processing platform. In Proceedings of Workshop for NLP Open Source Software (NLP-OSS), pages 1–6, Melbourne, Australia, 2018. Association for Computational Linguistics. 2
176
+
177
+ [15] Ting-Hao Kenneth Huang, Francis Ferraro, Nasrin Mostafazadeh, Ishan Misra, Aishwarya Agrawal, Jacob Devlin, Ross Girshick, Xiaodong He, Pushmeet Kohli, Dhruv Batra, C. Lawrence Zitnick, Devi Parikh, Lucy Vanderwende, Michel Galley, and Margaret Mitchell. Visual storytelling. In Proceedings of the 2016 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, pages 1233–1239, San Diego, California, 2016. Association for Computational Linguistics. 2
178
+
179
+ [16] 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, pages 12976–12985, 2021. 2
180
+
181
+ [17] 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 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. 2
182
+
183
+ [18] 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. 2
184
+
185
+ [19] Ranjay Krishna, Yuke Zhu, Oliver Groth, Justin Johnson, Kenji Hata, Joshua Kravitz, Stephanie Chen, Yannis Kalantidis, Li-Jia Li, David A Shamma, et al. Visual genome: Connecting language and vision using crowdsourced dense image annotations. International journal of computer vision, 123(1):32–73, 2017. 4
186
+
187
+ [20] 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. 4
188
+
189
+ [21] Jie Lei, Linjie Li, Luowei Zhou, Zhe Gan, Tamara L. Berg, Mohit Bansal, and Jingjing Liu. Less is more: Clipbert for video-and-language learningvia sparse sampling. In CVPR, 2021. 1, 3
190
+
191
+ [22] Jie Lei, Licheng Yu, Mohit Bansal, and Tamara Berg. TVQA: Localized, compositional video question answering. In Proceedings of the 2018 Conference on Empirical Methods in Natural Language Processing, pages 1369–1379, Brussels, Belgium, 2018. Association for Computational Linguistics. 3
192
+
193
+ [23] Jie Lei, Licheng Yu, Tamara Berg, and Mohit Bansal. What is more likely to happen next? videoand-language future event prediction. In Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing (EMNLP), pages 8769–8784, Online, 2020. Association for Computational Linguistics. 1, 6, 8
194
+
195
+ [24] 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 Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics, pages 7871–7880, Online, 2020. Association for Computational Linguistics. 1
196
+
197
+ [25] Dongxu Li, Junnan Li, Hongdong Li, Juan Carlos Niebles, and Steven C.H. Hoi. Align and prompt: Video-and-language pre-training with entity prompts. In arxiv, 2021. 1, 3, 8, 9
198
+
199
+ [26] Junnan Li, Dongxu Li, Caiming Xiong, and Steven Hoi. Blip: Bootstrapping language-image pre-training for unified vision-language understanding and generation. ArXiv preprint, abs/2201.12086, 2022. 2, 3, 6, 7, 8
200
+
201
+ [27] Junnan Li, Ramprasaath Selvaraju, Akhilesh Gotmare, Shafiq Joty, Caiming Xiong, and Steven Chu Hong Hoi. Align before fuse: Vision and language representation learning with momentum distillation. Advances in Neural Information Processing Systems, 34, 2021. 2
202
+
203
+ [28] Linjie Li, Yen-Chun Chen, Yu Cheng, Zhe Gan, Licheng Yu, and Jingjing Liu. HERO: Hierarchical encoder for Video+Language omni-representation pre-training. In Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing (EMNLP), pages 2046–2065, Online, 2020. Association for Computational Linguistics. 1, 3
204
+
205
+ [29] Xiujun Li, Xi Yin, Chunyuan Li, Pengchuan Zhang, Xiaowei Hu, Lei Zhang, Lijuan Wang, Houdong Hu, Li Dong, Furu Wei, et al. Oscar: Object-semantics aligned pre-training for vision-language tasks. In European Conference on Computer Vision, pages 121–137. Springer, 2020. 2
206
+
207
+ [30] Chin-Yew Lin and Franz Josef Och. Automatic evaluation of machine translation quality using longest common subsequence and skip-bigram statistics. In Proceedings of the 42nd Annual Meeting of the Association for Computational Linguistics (ACL-04), pages 605–612, Barcelona, Spain, 2004. 6
208
+
209
+ [31] 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 European conference on computer vision, pages 740–755. Springer, 2014. 6
210
+
211
+ [32] Xudong Lin, Gedas Bertasius, Jue Wang, Shih-Fu Chang, Devi Parikh, and Lorenzo Torresani. Vx2text: End-to-end learning of video-based text generation from multimodal inputs. In 2021 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), pages 7001–7011. IEEE, 2021. 3, 4
212
+
213
+ [33] Xudong Lin, Fabio Petroni, Gedas Bertasius, Marcus Rohrbach, Shih-Fu Chang, and Lorenzo Torresani. Learning to recognize procedural activities with distant supervision. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 13853–13863, 2022. 3
214
+
215
+ [34] Xudong Lin, Simran Tiwari, Shiyuan Huang, Manling Li, Mike Zheng Shou, Heng Ji, and Shih-Fu Chang. Towards fast adaptation of pretrained contrastive models for multi-channel video-language retrieval. arXiv preprint arXiv:2206.02082, 2022. 1
216
+
217
+ [35] 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. 2
218
+
219
+ [36] Huaishao Luo, Lei Ji, Botian Shi, Haoyang Huang, Nan Duan, Tianrui Li, Jason Li, Taroon Bharti, and Ming Zhou. Univl: A unified video and language pre-training model for multimodal understanding and generation. ArXiv preprint, abs/2002.06353, 2020. 1, 3, 6
220
+
221
+ [37] Huaishao Luo, Lei Ji, Ming Zhong, Yang Chen, Wen Lei, Nan Duan, and Tianrui Li. CLIP4Clip: An empirical study of clip for end to end video clip retrieval. ArXiv preprint, abs/2104.08860, 2021. 3
222
+
223
+ [38] Antoine Miech, Jean-Baptiste Alayrac, Lucas Smaira, Ivan Laptev, Josef Sivic, and Andrew Zisserman. End-to-end learning of visual representations from uncurated instructional videos. In 2020 IEEE/CVF Conference on Computer Vision and Pattern Recognition, CVPR 2020, Seattle, WA, USA, June 13-19, 2020, pages 9876–9886. IEEE, 2020. 3
224
+
225
+ [39] Antoine Miech, Dimitri Zhukov, Jean-Baptiste Alayrac, Makarand Tapaswi, Ivan Laptev, and Josef Sivic. Howto100m: Learning a text-video embedding by watching hundred million narrated video clips. In 2019 IEEE/CVF International Conference on Computer Vision, ICCV 2019, Seoul, Korea (South), October 27 - November 2, 2019, pages 2630–2640. IEEE, 2019. 2, 3
226
+
227
+ [40] 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, abs/2203.02155, 2022. 2, 6
228
+
229
+ [41] Kishore Papineni, Salim Roukos, Todd Ward, and Wei-Jing 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, Philadelphia, Pennsylvania, USA, 2002. Association for Computational Linguistics. 6
230
+
231
+ [42] Mandela Patrick, Po-Yao Huang, Yuki Markus Asano, Florian Metze, Alexander G. Hauptmann, João F. Henriques, and Andrea Vedaldi. Support-set bottlenecks for video-text representation learning. In 9th International Conference on Learning Representations, ICLR 2021, Virtual Event, Austria, May 3-7, 2021. OpenReview.net, 2021. 3
232
+
233
+ [43] Baolin Peng, Chenguang Zhu, Chunyuan Li, Xiujun Li, Jinchao Li, Michael Zeng, and Jianfeng Gao. Fewshot natural language generation for task-oriented dialog. In Findings of the Association for Computational Linguistics: EMNLP 2020, pages 172–182, Online, 2020. Association for Computational Linguistics. 1 [44] 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. 2, 3, 4
234
+
235
+ [45] 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, abs/1910.10683, 2019. 1
236
+
237
+ [46] 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:1–67, 2020. 3
238
+
239
+ [47] Nils Reimers and Iryna Gurevych. Sentence-BERT: Sentence embeddings using Siamese BERT-networks. 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 3982–3992, Hong Kong, China, 2019. Association for Computational Linguistics. 4, 6, 8
240
+
241
+ [48] Timo Schick and Hinrich Schütze. 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, 2021. Association for Computational Linguistics. 2
242
+
243
+ [49] Paul Hongsuck Seo, Arsha Nagrani, Anurag Arnab, and Cordelia Schmid. End-to-end generative pretraining for multimodal video captioning. ArXiv preprint, abs/2201.08264, 2022. 1
244
+
245
+ [50] 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 preprint, abs/2205.02655, 2022. 3
246
+
247
+ [51] Derek Tam, Rakesh R. Menon, Mohit Bansal, Shashank Srivastava, and Colin Raffel. Improving and simplifying pattern exploiting training. In Proceedings of the 2021 Conference on Empirical Methods in Natural Language Processing, pages 4980–4991, Online and Punta Cana, Dominican Republic, 2021. Association for Computational Linguistics. 2
248
+
249
+ [52] 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), pages 5100–5111, Hong Kong, China, 2019. Association for Computational Linguistics. 2
250
+
251
+ [53] Maria Tsimpoukelli, Jacob L Menick, Serkan Cabi, SM Eslami, Oriol Vinyals, and Felix Hill. Multimodal few-shot learning with frozen language models. Advances in Neural Information Processing Systems, 34:200–212, 2021. 3
252
+
253
+ [54] Ramakrishna Vedantam, C. Lawrence Zitnick, and Devi Parikh. Cider: Consensus-based image description evaluation. In IEEE Conference on Computer Vision and Pattern Recognition, CVPR 2015, Boston, MA, USA, June 7-12, 2015, pages 4566–4575. IEEE Computer Society, 2015. 6
254
+
255
+ [55] Peng Wang, An Yang, Rui Men, Junyang Lin, Shuai Bai, Zhikang Li, Jianxin Ma, Chang Zhou, Jingren Zhou, and Hongxia Yang. Unifying architectures, tasks, and modalities through a simple sequence-tosequence learning framework. ArXiv preprint, abs/2202.03052, 2022. 3
256
+
257
+ [56] Qiang Wang, Yanhao Zhang, Yun Zheng, Pan Pan, and Xian-Sheng Hua. Disentangled representation learning for text-video retrieval. ArXiv preprint, abs/2203.07111, 2022. 9
258
+
259
+ [57] Xin Wang, Jiawei Wu, Junkun Chen, Lei Li, Yuan-Fang Wang, and William Yang Wang. Vatex: A largescale, high-quality multilingual dataset for video-and-language research. In 2019 IEEE/CVF International Conference on Computer Vision, ICCV 2019, Seoul, Korea (South), October 27 - November 2, 2019, pages 4580–4590. IEEE, 2019. 1, 6
260
+
261
+ [58] Zirui Wang, Jiahui Yu, Adams Wei Yu, Zihang Dai, Yulia Tsvetkov, and Yuan Cao. Simvlm: Simple visual language model pretraining with weak supervision. ArXiv preprint, abs/2108.10904, 2021. 2
262
+
263
+ [59] 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 preprint, abs/2109.01652, 2021. 5
264
+
265
+ [60] Dejing Xu, Zhou Zhao, Jun Xiao, Fei Wu, Hanwang Zhang, Xiangnan He, and Yueting Zhuang. Video question answering via gradually refined attention over appearance and motion. In Proceedings of the 2017 ACM on Multimedia Conference, MM 2017, Mountain View, CA, USA, October 23-27, 2017, pages 1645–1653, 2017. 1
266
+
267
+ [61] 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 Proceedings of the 2021 Conference on Empirical Methods in Natural Language Processing, pages 6787–6800, Online and Punta Cana, Dominican Republic, 2021. Association for Computational Linguistics. 1 [62] Jun Xu, Tao Mei, Ting Yao, and Yong Rui. MSR-VTT: A large video description dataset for bridging video and language. In 2016 IEEE Conference on Computer Vision and Pattern Recognition, CVPR 2016, Las Vegas, NV, USA, June 27-30, 2016, pages 5288–5296. IEEE Computer Society, 2016. 1, 6 [63] 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. ArXiv preprint, abs/2109.05014, 2021. 1, 3, 4 [64] Ziyi Yang, Yuwei Fang, Chenguang Zhu, Reid Pryzant, Dongdong Chen, Yu Shi, Yichong Xu, Yao Qian, Mei Gao, Yi-Ling Chen, et al. i-code: An integrative and composable multimodal learning framework. ArXiv preprint, abs/2205.01818, 2022. 1 [65] 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, pages 3208–3216, 2021. 2 [66] Lu Yuan, Dongdong Chen, Yi-Ling Chen, Noel Codella, Xiyang Dai, Jianfeng Gao, Houdong Hu, Xuedong Huang, Boxin Li, Chunyuan Li, et al. Florence: A new foundation model for computer vision. ArXiv preprint, abs/2111.11432, 2021. 2 [67] Rowan Zellers, Jiasen Lu, Ximing Lu, Youngjae Yu, Yanpeng Zhao, Mohammadreza Salehi, Aditya Kusupati, Jack Hessel, Ali Farhadi, and Yejin Choi. Merlot reserve: Neural script knowledge through vision and language and sound. ArXiv preprint, abs/2201.02639, 2022. 1 [68] Rowan Zellers, Ximing Lu, Jack Hessel, Youngjae Yu, Jae Sung Park, Jize Cao, Ali Farhadi, and Yejin Choi. Merlot: Multimodal neural script knowledge models. Advances in Neural Information Processing Systems, 34, 2021. 1, 2, 8 [69] Andy Zeng, Adrian Wong, Stefan Welker, Krzysztof Choromanski, Federico Tombari, Aveek Purohit, Michael Ryoo, Vikas Sindhwani, Johnny Lee, Vincent Vanhoucke, et al. Socratic models: Composing zero-shot multimodal reasoning with language. ArXiv preprint, abs/2204.00598, 2022. 3, 4 [70] 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, pages 5579–5588, 2021. 2 [71] Susan Zhang, Stephen Roller, Naman Goyal, Mikel Artetxe, Moya Chen, Shuohui Chen, Christopher Dewan, Mona Diab, Xian Li, Xi Victoria Lin, et al. Opt: Open pre-trained transformer language models. ArXiv preprint, abs/2205.01068, 2022. 1 [72] Zihao Zhao, Eric Wallace, Shi Feng, Dan Klein, and Sameer Singh. Calibrate before use: Improving few-shot performance of language models. In Marina Meila and Tong Zhang, editors, Proceedings of the
268
+ 38th International Conference on Machine Learning, ICML 2021, 18-24 July 2021, Virtual Event, volume
269
+ 139 of Proceedings of Machine Learning Research, pages 12697–12706. PMLR, 2021. 1, 6 [73] 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. 2 [74] Luowei Zhou, Chenliang Xu, and Jason J. Corso. Towards automatic learning of procedures from web instructional videos. In Sheila A. McIlraith and Kilian Q. Weinberger, editors, Proceedings of the ThirtySecond AAAI Conference on Artificial Intelligence, (AAAI-18), the 30th innovative Applications of Artificial Intelligence (IAAI-18), and the 8th AAAI Symposium on Educational Advances in Artificial Intelligence (EAAI-18), New Orleans, Louisiana, USA, February 2-7, 2018, pages 7590–7598. AAAI Press, 2018. 3, 6 [75] Xizhou Zhu, Jinguo Zhu, Hao Li, Xiaoshi Wu, Xiaogang Wang, Hongsheng Li, Xiaohua Wang, and Jifeng Dai. Uni-perceiver: Pre-training unified architecture for generic perception for zero-shot and few-shot tasks. ArXiv preprint, abs/2112.01522, 2021. 3
md/dev/_SJ-_yyes8/_SJ-_yyes8.md ADDED
@@ -0,0 +1,261 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # MASTERING VISUAL CONTINUOUS CONTROL: IMPROVED DATA-AUGMENTED REINFORCEMENT LEARNING
2
+
3
+ Anonymous authors Paper under double-blind review
4
+
5
+ # ABSTRACT
6
+
7
+ We present DrQ-v2, a model-free reinforcement learning (RL) algorithm for visual continuous control. DrQ-v2 builds on DrQ, an off-policy actor-critic approach that uses data augmentation to learn directly from pixels. We introduce several improvements that yield state-of-the-art results on the DeepMind Control Suite. Notably, DrQ-v2 is able to solve complex humanoid locomotion tasks directly from pixel observations, previously unattained by model-free RL. DrQ-v2 is conceptually simple, easy to implement, and provides significantly better computational footprint compared to prior work, with the majority of tasks taking just 8 hours to train on a single GPU. Finally, DrQ-v2’s implementation is publicly released to provide RL practitioners with a strong and computationally efficient baseline.
8
+
9
+ # 1 INTRODUCTION
10
+
11
+ Creating sample-efficient continuous control methods that observe high-dimensional images has been a long standing challenge in reinforcement learning (RL) . Over the last three years, the RL community has made significant headway on this problem, improving sample-efficiency significantly. The key insight to solving visual control is the learning of better low-dimensional representations, either through autoencoders (Yarats et al., 2019; Finn et al., 2015), variational inference (Hafner et al., 2018; 2019; Lee et al., 2019), contrastive learning (Srinivas et al., 2020; Yarats et al., 2021a), self-prediction (Schwarzer et al., 2020b), or data augmentations (Yarats et al., 2021b; Laskin et al., 2020). However, current state-of-the-art model-free methods are still limited in three ways. First, they are unable to solve the more challenging visual control problems such as quadruped and humanoid locomotion. Second, they often require significant computational resources, i.e. lengthy training times using distributed multi-GPU infrastructure. Lastly, it is often unclear how different design choices affect overall system performance.
12
+
13
+ ![](images/e84129af41009f6a5914fde2b150e79150a0bba702766235dd57287b087195b6.jpg)
14
+ Figure $1 : \mathrm { D r Q - v } 2$ demonstrates significantly better sample efficiency and computational footprint compared to state-of-the-art model-free methods for visual continuous control while being conceptually simple and easy to implement. (Left two) Average performance results across 12 challenging tasks from the DeepMind Control Suite (the set of tasks can be seen in Figure 8). (Right two) Performance on the Humanoid Walk task from visual input, previously unsolved by model-free methods. In both cases we report sample complexity and wall-clock time axes for evaluation, with time being measured on a single GPU machine and using official implementations for each method.
15
+
16
+ In this paper we present DrQ-v2, a simple model-free algorithm that builds on the idea of using data augmentations (Yarats et al., 2021b; Laskin et al., 2020) to solve hard visual control problems. Most notably, it is the first model-free method that solves complex humanoid tasks directly from pixels. Compared to previous state-of-the-art model-free methods, DrQ-v2 provides significant improvements in sample efficiency across tasks from the DeepMind Control Suite (Tassa et al., 2018). Conceptually simple, DrQ-v2 is also computationally efficient, which allows solving most tasks in DeepMind Control Suite in just 8 hours on a single GPU (see Figure 1). Recently, a model-based method, DreamerV2 (Hafner et al., 2020) was also shown to solve visual continuous control problems and it was first to solve the humanoid locomotion problem from pixels. While our model-free $\mathrm { D r Q - v } 2$ matches DreamerV2 in terms sample efficiency and performance, it does so $4 \times$ faster in terms of wall-clock time to train. We believe this makes DrQ-v2 a more accessible approach to support research in visual continuous control and it reinforces the question on whether model-free or model-based is the more suitable approach to solve this type of tasks.
17
+
18
+ $\mathrm { D r Q - v } 2$ , which is detailed in Section 3, improves upon DrQ (Yarats et al., 2021b) by making several algorithmic changes: (i) switching the base RL algorithm from SAC (Haarnoja et al., 2018a) to DDPG (Lillicrap et al., 2015a) with clipped double Q-learning from TD3 (Fujimoto et al., 2018), (ii) this allows us straightforwardly incorporating multi-step return, (iii) adding bilinear interpolation to the random shift image augmentation, (iv) introducing an exploration schedule, (v) selecting better hyper-parameters including a larger capacity of the replay buffer. A careful ablation study of these design choices is presented in Section 4.4. Furthermore, we re-examine the original implementation of DrQ and identify several computational bottlenecks such as replay buffer management, data augmentation processing, batch size, and frequency of learning updates (see Section 3.2). To remedy these, we have developed a new implementation that both achieves better performance and trains around 3.5 times faster with respect to wall-clock time than the previous implementation on the same hardware with an increase in environment frame throughput (FPS) from 28 to 96 (i.e., it takes $1 0 ^ { 6 } / 9 6 / 3 6 0 0 \approx 2 . 9$ hours to train for 1M environment steps). DrQ-v2’s implementation is available at https://anonymous.4open.science/r/drqv2.
19
+
20
+ # 2 BACKGROUND
21
+
22
+ # 2.1 REINFORCEMENT LEARNING FROM IMAGES
23
+
24
+ We formulate image-based control as an infinite-horizon Markov Decision Process (MDP) (Bellman, 1957). Generally, in such a setting, an image rendering of the system is not sufficient to perfectly describe the system’s underlying state. To this end and per common practice (Mnih et al., 2013), we approximate the current state of the system by stacking three consecutive prior observations. With this in mind, such MDP can be described as a tuple $( \mathcal { X } , \mathcal { A } , P , R , \gamma , d _ { 0 } )$ , where $\mathcal { X }$ is the state space (a three-stack of image observations), $\mathcal { A }$ is the action space, $P : \mathcal { X } \times \mathcal { A } \Delta ( \mathcal { X } )$ is the transition function1 that defines a probability distribution over the next state given the current state and action, $R : \mathcal { X } \times \mathcal { A } [ 0 , 1 ]$ is the reward function, $\gamma \in [ 0 , 1 )$ is a discount factor, and $d _ { 0 } \in \Delta ( { \mathcal { X } } )$ is the distribution of the initial state $\scriptstyle { \mathbf { { \mathit { x } } } } _ { 0 }$ . The goal is to find a policy $\pi : \mathcal { X } \Delta ( \mathcal { A } )$ that maximizes the expected discounted sum of rewards $\mathbb { E } _ { \pi } \big [ \sum _ { t = 0 } ^ { \infty } \gamma ^ { t } r _ { t } \big ]$ , where $\mathbf { x } _ { 0 } \sim d _ { 0 }$ , and $\forall t$ we have $\mathbf { \boldsymbol { a } } _ { t } \sim \pi ( \cdot | \mathbf { \boldsymbol { x } } _ { t } )$ $\mathbf { \boldsymbol { x } } _ { t + 1 } \sim P ( \cdot | \mathbf { \boldsymbol { x } } _ { t } , \mathbf { \boldsymbol { a } } _ { t } )$ , and $r _ { t } = R ( \pmb { x } _ { t } , \pmb { a } _ { t } ) \overline { { \mathbf { \phi } } }$ .
25
+
26
+ # 2.2 DEEP DETERMINISTIC POLICY GRADIENT
27
+
28
+ Deep Deterministic Policy Gradient (DDPG) (Lillicrap et al., 2015a) is an actor-critic algorithm for continuous control that concurrently learns a Q-function $Q _ { \theta }$ and a deterministic policy $\pi _ { \phi }$ . For this, DDPG uses Q-learning (Watkins and Dayan, 1992) to learn $Q _ { \theta }$ by minimizing the one-step Bellman residual $J _ { \theta } ( \mathcal { D } ) = \mathbb { E } _ { ( \pmb { x } _ { t } , \underline { { a } } _ { t } , r _ { t } , \pmb { x } _ { t + 1 } ) \sim \mathcal { D } } [ \big ( Q _ { \theta } ( \pmb { x } _ { t } , \underline { { a } } _ { t } ) _ { } r _ { t } - \underline { { \gamma Q _ { \theta } } } ( \pmb { x } _ { t + 1 } , \pi _ { \phi } ( \pmb { x } _ { t + 1 } ) ) ^ { 2 } \big ]$ . The policy $\pi _ { \phi }$ is learned by employing Deterministic Policy Gradient (DPG) (Silver et al., 2014) and maximizing $J _ { \phi } ( \mathcal { D } ) = \mathbb { E } _ { \pmb { x } _ { t } \sim \mathcal { D } } [ Q _ { \theta } ( \pmb { x } _ { t } , \pi _ { \phi } ( \pmb { x } _ { t } ) ) ]$ , so $\pi _ { \phi } ( \pmb { x } _ { t } )$ approximates argmax $\mathbf { \Sigma } _ { \alpha } Q _ { \theta } ( \pmb { x } _ { t } , \pmb { a } )$ . Here, $\mathcal { D }$ is a replay buffer of environment transitions and $\bar { \theta }$ is an exponential moving average of the weights. DDPG is amenable to incorporate $n$ -step returns (Watkins, 1989; eng and Williams, 1996) when estimating TD error beyond a single step (Barth-Maron et al., 2018). In practice, $n$ -step returns allow for faster reward propagation and has been previously used in policy gradient and Q-learning methods (Mnih et al., 2016b; Barth-Maron et al., 2018; Hessel et al., 2017).
29
+
30
+ ![](images/549fe695324b96cc93df2881f3296d0b6333a6e41e473a27a33b6bfc84cf2f08.jpg)
31
+ Figure 2: (Left): $\mathrm { D r Q - v } 2$ is an off-policy actor-critic algorithm for image-based RL. It alleviates encoder overfitting by applying random shift augmentation to pixel observations sampled from the replay buffer. (Right): Examples of walking and standing behaviors learned by $\mathrm { D r Q - v } 2$ for a complex humanoid agent from DMC (Tassa et al., 2018) with 21 and 54 dimensional action and state spaces, respectively. DrQ-v2 does not have access to the internal state of the environment, only observing three consecutive pixel frames at a time. Despite this imperfect observational channel, our agent still manages to solve the tasks. To the best of our knowledge, this is the first successful demonstration by a model-free method, using pixel-based inputs of these tasks.
32
+
33
+ # 2.3 DATA AUGMENTATION IN REINFORCEMENT LEARNING
34
+
35
+ Recently, it has been shown that data augmentation techniques, commonplace in Computer Vision, are also important for achieving the state-of-the-art performance in image-based RL (Yarats et al., 2021b; Laskin et al., 2020). For example, the state-of-the-art algorithm for visual RL, DrQ (Yarats et al., 2021b) builds on top of Soft Actor-Critic (Haarnoja et al., 2018a), a model-free actor-critic algorithm, by adding a convolutional encoder and data augmentation in the form of random shifts. The use of such data augmentations now forms an essential component of several recent visual RL algorithms (Srinivas et al., 2020; Raileanu et al., 2020; Yarats et al., 2021a; Stooke et al., 2020; Hansen and Wang, 2021; Schwarzer et al., 2020b).
36
+
37
+ # 3 DRQ-V2: IMPROVED DATA-AUGMENTED REINFORCEMENT LEARNING
38
+
39
+ In this section, we describe DrQ-v2, a simple model-free actor-critic RL algorithm for image-based continuous control, that builds upon DrQ.
40
+
41
+ # 3.1 ALGORITHMIC DETAILS
42
+
43
+ Image Augmentation As in DrQ we apply random shifts image augmentation to pixel observations of the environment. In the settings of visual continuous control by DMC, this augmentation can be instantiated by first padding each side of $8 4 \times 8 4$ observation rendering by 4 pixels (by repeating boundary pixels), and then selecting a random $8 4 \times 8 4$ crop, yielding the original image shifted by $\pm 4$ pixels. We also find it useful to apply bilinear interpolation on top of the shifted image (i.e, we replace each pixel value with the average of the four nearest pixel values). In our experiments, this modification provides an additional performance boost across the board.
44
+
45
+ Image Encoder The augmented image observation is then embedded into a low-dimensional latent vector by applying a convolutional encoder. We use the same encoder architecture as in DrQ, which first was introduced introduced in SAC-AE (Yarats et al., 2019). This process can be succinctly summarized as $\pmb { h } = f _ { \xi } ( \mathrm { a u g } ( \pmb { x } ) )$ , where $f _ { \xi }$ is the encoder, aug is the random shifts augmentation, and $_ { \textbf { \em x } }$ is the original image observation.
46
+
47
+ Actor-Critic Algorithm We use DDPG (Lillicrap et al., 2015a) as a backbone actor-critic RL algorithm and, similarly to Barth-Maron et al. (2018), augment it with $n$ -step returns to estimate TD error. This results into faster reward propagation and overall learning progress (Mnih et al., 2016a).
48
+
49
+ While some methods (Hafner et al., 2020) employ more sophisticated techniques such as $\mathrm { T D } ( \lambda )$ or Retrace $( \lambda )$ (Munos et al., 2016), they are often computationally demanding when $n$ is large. We find that using simple $n$ -step returns, without an importance sampling correction, strikes a good balance between performance and efficiency. We also employ clipped double Q-learning (Fujimoto et al., 2018) to reduce overestimation bias in the target value. Practically, this requires training two Qfunctions $Q _ { \theta _ { 1 } }$ and $Q _ { \theta _ { 2 } }$ . For this, we sample a mini-batch of transitions $\tau = ( \mathbf { x } _ { t } , \mathbf { a } _ { t } , r _ { t : t + n - 1 } , \mathbf { x } _ { t + n } )$ from the replay buffer $\mathcal { D }$ and compute the following two losses:
50
+
51
+ $$
52
+ \begin{array} { r } { \mathcal { L } _ { \boldsymbol { \theta } _ { k } , \boldsymbol { \xi } } ( \mathcal { D } ) = \mathbb { E } _ { \tau \sim \mathcal { D } } \big [ ( Q _ { \boldsymbol { \theta } _ { k } } ( h _ { t } , \boldsymbol { a } _ { t } ) - y ) ^ { 2 } \big ] \quad \forall k \in \{ 1 , 2 \} , } \end{array}
53
+ $$
54
+
55
+ with the TD target $y$ defined as:
56
+
57
+ $$
58
+ y = \sum _ { i = 0 } ^ { n - 1 } \gamma ^ { i } r _ { t + i } + \gamma ^ { n } \operatorname* { m i n } _ { k = 1 , 2 } Q _ { \bar { \theta } _ { k } } ( h _ { t + n } , \mathbf { a } _ { t + n } ) ,
59
+ $$
60
+
61
+ where $\pmb { h } _ { t } = f _ { \xi } ( \mathrm { a u g } ( \pmb { x } _ { t } ) )$ , ${ h _ { t + n } } = f _ { \xi } ( \mathrm { a u g } ( { { \bf x } _ { t + n } } ) )$ , $a _ { t + n } = \pi _ { \phi } ( h _ { t + n } ) + \epsilon , \bar { \theta } _ { 1 }$ and ${ \bar { \theta } _ { 2 } }$ are the slowmoving weights for the Q target networks. We note, that in contrast to DrQ, we do not employ a target network for the encoder $f _ { \xi }$ and always use the most recent weights $\xi$ to embed $\mathbf { \Delta } _ { \mathbf { \mathcal { X } } _ { t } }$ and $\mathbf { \Delta } _ { \mathbf { x } _ { t + n } }$ . The exploration noise $\epsilon$ is sampled from $\mathrm { c l i p } ( \mathcal { N } ( 0 , \sigma ^ { 2 } ) , - c , c )$ similar to TD3 (Fujimoto et al., 2018), with the exception of decaying $\sigma$ , which we describe below. Finally, we train the deterministic actor $\pi _ { \phi }$ using DPG with the following loss:
62
+
63
+ $$
64
+ \mathcal { L } _ { \phi } ( \mathcal { D } ) = - \mathbb { E } _ { x _ { t } \sim \mathcal { D } } \big [ \operatorname* { m i n } _ { k = 1 , 2 } Q _ { \theta _ { k } } ( h _ { t } , \pmb { a } _ { t } ) \big ] ,
65
+ $$
66
+
67
+ where $\pmb { h } _ { t } = f _ { \xi } ( \mathrm { a u g } ( \pmb { x } _ { t } ) )$ , ${ \pmb a } _ { t } = \pi _ { \phi } ( { \pmb h } _ { t } ) + \epsilon$ , and $\epsilon \sim \mathrm { c l i p } ( \mathcal { N } ( 0 , \sigma ^ { 2 } ) , - c , c )$ . Similar to $_ \mathrm { D r Q }$ , we do not use actor’s gradients to update the encoder’s parameters $\xi$ .
68
+
69
+ Scheduled Exploration Noise Empirically, we observe that it is helpful to have different levels of exploration at different stages of learning. At the beginning of training we want the agent to be more stochastic and explore the environment more effectively, while at the later stages of training, when the agent has already identified promising behaviors, it is better to be more deterministic and master those behaviors. Similar to Amos et al. (2020), we instantiate this idea by using linear decay $\sigma ( t )$ for the variance $\sigma ^ { 2 }$ of the exploration noise defined as:
70
+
71
+ $$
72
+ \sigma ( t ) = \sigma _ { \mathrm { i n i t } } + ( 1 - \mathrm { m i n } ( \frac { t } { T } , 1 ) ) ( \sigma _ { \mathrm { f i n a l } } - \sigma _ { \mathrm { i n i t } } ) ,
73
+ $$
74
+
75
+ where $\sigma _ { \mathrm { i n i t } }$ and $\sigma _ { \mathrm { f i n a l } }$ are the initial and final values for standard deviation, and $T$ is the decay horizon.
76
+
77
+ Key Hyper-Parameters We conduct an extensive hyper-parameter search and identify several hyper-parameter changes compared to DrQ. The three most important hyper-parameters are: (i) the size of the replay buffer, (ii) mini-batch size, and (iii) learning rate. Specifically, we use a 10 times larger replay buffer than DrQ. We also use a smaller mini-batch size of 256 without any noticeable performance degradation. This is in contrast to CURL (Srinivas et al., 2020) and $\mathrm { D r Q }$ (Yarats et al., 2021b) that both use a larger batch size of 512 to attain more stable training in the expense of computational efficiency. Finally, we find that using smaller learning rate of $1 \times 1 0 ^ { - 4 }$ , rather than DrQ’s learning rate of $\mathrm { i \times 1 0 ^ { - 3 } }$ , results into more stable training without any loss in learning speed.
78
+
79
+ # 3.2 IMPLEMENTATION DETAILS
80
+
81
+ Faster Image Augmentation We replace DrQ’s random shifts augmentation (i.e., kornia.augmentation.RandomCrop) by a custom implementation that uses flowfield image sampling provided in PyTorch (i.e., grid_sample). This is done for two reasons. First, we noticed that Kornia’s implementation does not fully utilize GPU pipelining since it has some intermediate CPU to GPU data transferring which breaks the computational flow. Second, using grid_sample allows straightforward addition of bilinear interpolation. Our custom random shifts augmentation improves training throughput by a factor of 2.
82
+
83
+ Faster Replay Buffer Another computational bottleneck of $\mathrm { D r Q }$ was the replay buffer. The specific implementation had poor memory management which resulted in slow CPU to GPU data transfer, which also restricted the number of image-based transitions that could be stored. We reimplemented the replay buffer to address these issues which led to a ten-fold increase in storage capacity and faster data transfer. More details are available in our open-source release. We note that the improved training speed of DrQ-v2 was key to solving humanoid tasks as it enabled much faster experimentation.
84
+
85
+ # 4 EXPERIMENTS
86
+
87
+ In this section we provide empirical evaluation of $\mathrm { D r Q - v } 2$ on an extensive set of visual continuous control tasks from DMC (Tassa et al., 2018). We first present comparison to prior methods, both model-free and model-based, in terms of sample efficiency and wall-clock time. We then present a large scale ablation study that guided the final version of DrQ-v2.
88
+
89
+ # 4.1 SETUP
90
+
91
+ Environments We consider a set of MuJoCo tasks (Todorov et al., 2012) provided by DMC (Tassa et al., 2018), a widely used benchmark for continous control. DMC offers environments of various difficulty, ranging from the simple control problems such as the single degree of freedom (DOF) pendulum and cartpool, to the control of complex multi-joint bodies such as the humanoid (21 DOF). We consider learning from pixels. In this setting, environment observations are stacks of 3 consecutive RGB images of size $8 4 \times 8 4$ , stacked along the channel dimension to enable inference of dynamic information like velocity and acceleration. In total, we consider 24 different tasks, which we group into three buckets, easy, medium, and hard, according to the sample complexity to reach near-optimal performance (see Appendix B). Our motivation for this is to encourage RL practitioners to focus on the medium and hard tasks and stop using the easy tasks for evaluation, as they are mostly solved at this point and may no longer provide any valuable signal in comparing different methods.
92
+
93
+ Training Details For all tasks in the suite an episode corresponds to 1000 steps, where a per-step reward is in the unit interval [0, 1]. This upper bounds the episode return to 1000 making it easier to compute aggregated performance measures across tasks. To facilitate fair wall-clock time comparison all algorithms are trained on the same hardware (i.e., a single NVIDIA V100 GPU machine) and evaluated with the same periodicity of 20000 environment steps. Each evaluation query averages episode returns over 10 episodes. Per common practice (Hafner et al., 2019), we employ action repeat of 2 and measure sample complexity in the environment steps, rather than the actor steps. In all the figures we plot the mean performance over 10 seeds together with the shaded regions which represent $9 \hat { 5 } \%$ confidence intervals. A full list of hyper-parameters can be found in Appendix E.
94
+
95
+ Comparison Axes In many real-world applications, taking a step in the environment incurs significant computational cost making sample efficiency a critical feature of an RL algorithm. It is hence important to compare RL algorithms in terms of their sample efficiency. We facilitate this comparison by computing an algorithm’s performance measured by episode return with respect to environment steps. On the other end, striving low sample complexity often comes at the cost of a poor computational efficiency. Unfortunately, recent deep RL literature has paid very little attention to this important axis, which has led to skyrocketing hardware requirements. Such a trend has made it virtually impossible for an RL practitioner with modest hardware capacity to contribute to advancements in image-based RL, leaving research in this area to a few well-equipped labs. To democratize research in visual RL, we additionally propose to compare the agents in terms of wall-clock training time given the same single GPU hardware. We note that it is possible to adapt DrQ-v2 to a distributed setup, as has been done for DDPG in prior work (Barth-Maron et al., 2018; Hoffman et al., 2020).
96
+
97
+ # 4.2 COMPARISON TO MODEL-FREE METHODS
98
+
99
+ Baselines We compare our method to several state-of-the-art model-free algorithms for visual RL including CURL (Srinivas et al., 2020), DrQ (Yarats et al., 2021b), and vanilla SAC (Haarnoja et al., 2018a) augmented with the convolutional encoder from SAC-AE (Yarats et al., 2019). Vanilla SAC is a weak baseline and only included as a ground point to showcase the recent progress in visual RL.
100
+
101
+ ![](images/ecbef5ca3f3d3542fd76d49b66dfb726dde336b060b81096054addb1a0048ea7.jpg)
102
+ Figure 3: We compare $\mathrm { D r Q - v } 2$ on a subset of continuous control tasks that offer various challenges, including complex dynamics, sparse rewards, hard exploration, and more. (a) $\mathrm { D r Q - v } 2$ demonstrates favorable sample efficiency and comfortably outperforms leading model-free baselines, as well as requiring less wall-clock training image (b).
103
+
104
+ Sample Efficiency Axis We present results on several medium and hard tasks in Figure 3a. Full results can be found in Appendix (Figure 6, Figure 8, and Figure 10). Our empirical study reveals that $\mathrm { D r Q - v } 2$ outperforms prior model-free methods in terms of sample efficiency across the three benchmarks with different levels of difficulty. Importantly, DrQ-v2’s advantage is more pronounced on harder tasks (i.e., acrobot, quadruped, and humanoid), where exploration is especially challenging. Finally, DrQ-v2 solves the DMC humanoid locomotion tasks directly from pixels, which, to the best of our knowledge, is the first successful demonstration of such feat by a model-free method.
105
+
106
+ Compute Efficiency Axis To facilitate a fair comparison in terms of sheer wall-clock training time, besides employee the identical training protocol (see Section 4.1), we also use the same mini-batch size of 256 for each agent. In Figure 13, we evaluate $\mathrm { D r Q - v } 2$ on a subset of DMC tasks for the sake of brevity only, and note that the demonstrated results can be easily extrapolated to the other tasks given the linear dependency between training time and sample complexity. In our benchmarks, $\mathrm { D r Q - v } 2$ is able to achieve a throughput of 96 FPS, which favorably compares to DrQ’s 28 FPS (a $3 . 4 \times$ increase), and CURL’s 16 FPS (a $6 \times$ increase) throughputs. Practically, $\mathrm { D r Q - v } 2$ solves easy, medium, and hard tasks within 2.9, 8.6, and 86 hours respectively. Full results can be found in Appendix (Figure 7, Figure 9, and Figure 11).
107
+
108
+ # 4.3 COMPARISON TO MODEL-BASED METHODS
109
+
110
+ Baseline To see how $\mathrm { D r Q - v } 2$ stacks up against model-based methods, which tend to achieve better sample complexity in expense of a larger computational footprint, we also compare to recent and unpublished2 improvements to Dreamer-v2 (Hafner et al., 2020), a leading model-based approach for visual continuous control. The recent update shows that the model-based approach can solve the DMC humanoid tasks directly from pixel inputs. The open-source implementation of Dreamer-v2 (https://github.com/danijar/dreamerv2) only provides learning curves for Humanoid Walk. For this reason we run their code to obtain results on other DMC tasks. To limit hardware requirements of compute-expensive Dreamer-v2, we only run it on a subset of 12 out of 24 considered tasks. This subset, however, overlaps with all the three (i.e. easy, medium, and hard) benchmarks.
111
+
112
+ ![](images/545d212f4784001ae204bbbd2da7b19024aaeec84e241d0466ac5d3246eb06bc.jpg)
113
+ Figure 4: Model-based Dreamer-v2 needs to train a world model and thus performs more computations during training than model-free DrQ-v2. Still, (a) $\mathrm { D r Q - v } 2$ is able to match Dreamer-v2’s sample efficiency, while $\mathbf { ( b ) }$ requiring much less wall-clock training time.
114
+
115
+ Sample Efficiency Axis Our empirical study in Figure 4a reveals that in many cases, DrQ-v2, despite being a model-free method, can rival sample efficiency of state-of-the-art model-based Dreamer-v2. We note, however, that on several tasks (for example Acrobot Swingup) Dreamer-v2 outperforms DrQ-v2. We leave investigation of such discrepancy for future work. Full results are provided in Appendix D (Figure 12).
116
+
117
+ Compute Efficiency Axis A different picture emerges if comparison is done with respect to wallclock training time. Dreamer-v2, being a model-based method, performs significantly more floating point operations to reach its sample efficiency. In our benchmarks, Dreamer-v2 records a throughput of 24 FPS, which is $4 \times$ less than DrQ-v2’s throughput of 96 FPS, measured on the same hardware. In Figure 4b we plot learning curves against wall-clock time and observe that $\mathrm { D r Q - v } 2$ takes less time to solve the tasks. Full results can be found in Appendix (Figure 13).
118
+
119
+ # 4.4 ABLATION STUDY
120
+
121
+ In this section we present an extensive ablation study that guided us to the final version of $\mathrm { D r Q - v } 2$ Here, for brevity we only discuss experiments that were most impactful and omit others that did not pan out. For computational reasons, we only ablate on 3 different control tasks of various difficulty levels. Our findings are summarized in Figure 5 and detailed below.
122
+
123
+ Switching from SAC to DDPG DrQ (Yarats et al., 2021b) leverages SAC (Haarnoja et al., 2018a) as the backbone RL algorithm. While it has been demonstrated by many works, including the original manuscripts (Haarnoja et al., 2018a;b) that SAC is superior to DDPG (Lillicrap et al., 2015b), our careful examination identifies two shortcomings that preclude SAC (within DrQ) to solve hard exploration-wise image-based tasks. First, the automatic entropy adjustment strategy, introduced in Haarnoja et al. (2018b), is inadequate and in some cases leads to a premature entropy collapse.
124
+
125
+ ![](images/ba1a4435887f6483f6e5539af32ee4c9abf61350f7e4d286d35d2b17585b6381.jpg)
126
+ (a) DrQ (dotted silver) relies on SAC as a base RL algorithm. Replacing SAC with DDPG results in a significant performance gain (blue).
127
+
128
+ ![](images/8cefa7b04095a5ad9cc5e618bf568a2e8cb599d743766c5d5f19dd90a7f61e8b.jpg)
129
+ (b) DDPG straightforwardly incorporates $n$ -step returns, a critical tool for exploration. We observe that the 3 (blue) and 5 (red) steps variants provide additional improvements to the previous version that uses single step TD-targets (silver). Going forward, we adopt 3-step returns (blue).
130
+
131
+ ![](images/7344d8d594db9770f16e401999ae3c88c9529605098182fbc253dd13972aed74.jpg)
132
+ (c) Increasing the size of the replay buffer (B) improves performance, over the original $1 0 ^ { 5 }$ used by DrQ (silver). Going forward, we use a buffer size of $1 \dot { 0 } ^ { 6 }$ (red).
133
+
134
+ (d) Finally, a decaying schedule for the variance of the exploration noise (blue) helps on hard exploration tasks, versus the fixed variance variant (silver).
135
+
136
+ ![](images/9ac2122386f89d3dc6ae3ea32bbd49484f830769555b1e994b96ad2c05cfd549.jpg)
137
+ Figure 5: An ablation study that led us to the final version of $\mathrm { D r Q - v } 2$ . We incrementally show each of the four key improvements to $\mathrm { D r Q }$ that collectively form DrQ-v2. The silver dotted curves in the first row show the original DrQ. In subsequent rows they show progressive improvements, using the optimal choice from the previous rows (i.e., the silver curve in the third row shows DrQ with a DDPG base RL algorithm and 3-step returns). The red and blue curves show the effect of individual modifications. In the last row the blue curve corresponds to DrQ-v2.
138
+
139
+ This prevents the agent from finding more optimal behaviors due to the insufficient exploration. In Figure 5a, we empirically verify our intuition and, indeed, observe that DDPG demonstrates better exploration properties than SAC. Here, DDPG uses constant $\sigma = 0 . 2$ for the exploration noise.
140
+
141
+ N-step Returns The second issue concerns the inability of soft Q-learning to incorporate $n$ -step returns to estimate TD error in a straightforward manner. The reason for this is that computing a target value for soft Q-function requires estimating per-step entropy of the policy, which is challenging to do for large $n$ in the off-policy regime. In contrast, DDPG does not require estimating per-step entropy to compute targets and is more amenable for $n$ -step returns. In Figure 5b we demonstrate that estimating TD error with $n$ -step returns improves sample efficiency over vanilla DDPG. We select 3-step returns as a sensible choice for our method.
142
+
143
+ Replay Buffer Size We hypothesize that a larger replay buffer plays an important role in circumventing the catastrophic forgetting problem (Fedus et al., 2020). This issue is especially prominent in tasks with more diverse initial state distributions (i.e., reacher or humanoid tasks), where the vast variety of possible behaviors requires significantly larger memory. We confirm this intuition by ablating the size of the replay buffer in Figure 5c, where we observe that a buffer size of 1M helps to improve performance on Reacher Hard considerably.
144
+
145
+ Scheduled Exploration Noise Finally, we demonstrate that it is useful to decay the variance of the exploration noise over the course of training according to Equation (3). In Figure 5d, we compare two versions of our algorithm, where the first variant uses a fixed standard deviation of $\sigma = 0 . 2$ , while the second variant employes the decaying schedule $\sigma ( t )$ , with parameters $\sigma _ { \mathrm { i n i t } } = 1 . 0$ , $\sigma _ { \mathrm { f i n a l } } = 0 . 1$ , and $T = 5 0 0 0 0 0$ . Having the exploration noise to decay linearly over time turns out to be helpful and provide an additional performance boost, which was especially useful for solving humanoid tasks.
146
+
147
+ # 5 RELATED WORK
148
+
149
+ Visual Reinforcement Learning Successes of visual representation learning in computer vision (Vincent et al., 2008; Doersch et al., 2015; Wang and Gupta, 2015; Noroozi and Favaro, 2016; Zhang et al., 2017; Gidaris et al., 2018) has inspired successes in visual RL, where coherent representations are learned alongside RL. Works such as SAC-AE (Yarats et al., 2019), PlaNet (Hafner et al., 2018), and SLAC (Lee et al., 2019), demonstrated how auto-encoders (Finn et al., 2015) could improve visual RL. Following this, other self-supervised objectives such as contrastive learning in CURL (Srinivas et al., 2020) and ATC (Stooke et al., 2020), self-prediction in SPR (Schwarzer et al., 2020a), contrastive cluster assignment in Proto-RL (Yarats et al., 2021a), and augmented data in DrQ (Yarats et al., 2021b) and RAD (Laskin et al., 2020), have significantly bridged the gap between state-based and image-based RL. Future prediction objectives (Hafner et al., 2018; 2019; Yan et al., 2020; Finn et al., 2015; Pinto et al., 2016; Agrawal et al., 2016) and other auxiliary objectives (Jaderberg et al., 2016; Zhan et al., 2020; Young et al., 2020; Chen et al., 2020) have shown improvements on a variety of problems ranging from gameplay, continuous control, and robotics. In the context of visual control settings, clever use of augmented data (Yarats et al., 2021b; Laskin et al., 2020) currently produces state-of-the-art results on visual tasks from DMC (Tassa et al., 2018).
150
+
151
+ Humanoid Control The humanoid control problem first presented in Tassa et al. (2012), has been studied as one of the hardest control problems due to its large state and action spaces. The earliest solutions to this problem use ideas in model-based optimal control to generate policies given an accurate model of the humanoid . Subsequent works in RL have shown that model-free policies can solve the humanoid control problem given access to proprioceptive state observations. However, solving such a problem from visual observations has been a challenging problem, with leading RL algorithms making little progress to solve the task (Tassa et al., 2018). Recently, Hafner et al. (2020) was able to solve this problem through a model-based technique in around 30M environment steps and 340 hours of training on a single GPU machine. DrQ-v2, presented in this paper, marks the first model-free RL method that can solve humanoid control from visual observations, taking also around 30M steps and 86 hours of training on the same hardware.
152
+
153
+ # 6 CONCLUSION
154
+
155
+ We have introduced a conceptually simple model-free actor-critic RL agent for image-based continuous control – DrQ-v2. Our method provides significantly better computational footprint and masters tasks from DMC directly from pixels, most notably the humanoid locomotion tasks that
156
+
157
+ were previously unsolved by model-free approaches. To support our empirical results and inspire further research in visual RL we provide an efficient PyTorch implementation of $\mathrm { D r Q - v } 2$ at https://anonymous.4open.science/r/drqv2.
158
+
159
+ # REFERENCES
160
+
161
+ Pulkit Agrawal, Ashvin Nair, Pieter Abbeel, Jitendra Malik, and Sergey Levine. Learning to poke by poking: experiential learning of intuitive physics. In Proceedings of the 30th International Conference on Neural Information Processing Systems, pages 5092–5100, 2016.
162
+
163
+ Brandon Amos, Samuel Stanton, Denis Yarats, and Andrew Gordon Wilson. On the model-based stochastic value gradient for continuous reinforcement learning. CoRR, 2020.
164
+
165
+ Gabriel Barth-Maron, Matthew W. Hoffman, David Budden, Will Dabney, Dan Horgan, Dhruva TB, Alistair Muldal, Nicolas Heess, and Timothy Lillicrap. Distributional policy gradients. In International Conference on Learning Representations, 2018.
166
+
167
+ Richard Bellman. A markovian decision process. Indiana Univ. Math. J., 1957.
168
+
169
+ Bryan Chen, Alexander Sax, Gene Lewis, Iro Armeni, Silvio Savarese, Amir Roshan Zamir, Jitendra Malik, and Lerrel Pinto. Robust policies via mid-level visual representations: An experimental study in manipulation and navigation. CoRR, 2020.
170
+
171
+ 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, pages 1422–1430, 2015.
172
+
173
+ Jing eng and Ronald J. Williams. Incremental multi-step q-learning. Machine Learning, 1996.
174
+
175
+ William Fedus, Prajit Ramachandran, Rishabh Agarwal, Yoshua Bengio, Hugo Larochelle, Mark Rowland, and Will Dabney. Revisiting fundamentals of experience replay. CoRR, 2020.
176
+
177
+ Chelsea Finn, Xin Yu Tan, Yan Duan, Trevor Darrell, Sergey Levine, and Pieter Abbeel. Learning visual feature spaces for robotic manipulation with deep spatial autoencoders. CoRR, 2015.
178
+
179
+ Scott Fujimoto, Herke van Hoof, and David Meger. Addressing function approximation error in actor-critic methods. In Proceedings of the 35th International Conference on Machine Learning, ICML 2018, Stockholmsmassan, Stockholm, Sweden, July 10-15, 2018, 2018.
180
+
181
+ Spyros Gidaris, Praveer Singh, and Nikos Komodakis. Unsupervised representation learning by predicting image rotations, 2018.
182
+
183
+ Tuomas Haarnoja, Aurick Zhou, Pieter Abbeel, and Sergey Levine. Soft actor-critic: Off-policy maximum entropy deep reinforcement learning with a stochastic actor. arXiv preprint arXiv:1801.01290, 2018a.
184
+
185
+ Tuomas Haarnoja, Aurick Zhou, Kristian Hartikainen, George Tucker, Sehoon Ha, Jie Tan, Vikash Kumar, Henry Zhu, Abhishek Gupta a nd Pieter Abbeel, and Sergey Levine. Soft actor-critic algorithms and applications. CoRR, 2018b.
186
+
187
+ Danijar Hafner, Timothy Lillicrap, Ian Fischer, Ruben Villegas, David Ha, Honglak Lee, and James Davidson. Learning latent dynamics for planning from pixels. arXiv preprint arXiv:1811.04551, 2018.
188
+
189
+ Danijar Hafner, Timothy Lillicrap, Jimmy Ba, and Mohammad Norouzi. Dream to control: Learning behaviors by latent imagination. arXiv preprint arXiv:1912.01603, 2019.
190
+
191
+ Danijar Hafner, Timothy P. Lillicrap, Mohammad Norouzi, and Jimmy Ba. Mastering atari with discrete world models. CoRR, 2020.
192
+
193
+ Nicklas Hansen and Xiaolong Wang. Generalization in reinforcement learning by soft data augmentation. In International Conference on Robotics and Automation, 2021.
194
+
195
+ Matteo Hessel, Joseph Modayil, Hado van Hasselt, Tom Schaul, Georg Ostrovski, Will Dabney, Daniel Horgan, Bilal Piot, Mohammad Gheshlaghi Azar, and David Silver. Rainbow: Combining improvements in deep reinforcement learning. arXiv preprint arXiv:1710.02298, 2017.
196
+
197
+ Matt Hoffman, Bobak Shahriari, John Aslanides, Gabriel Barth-Maron, Feryal Behbahani, Tamara Norman, Abbas Abdolmaleki, Albin Cassirer, Fan Yang, Kate Baumli, Sarah Henderson, Alex Novikov, Sergio Gómez Colmenarejo, Serkan Cabi, Caglar Gulcehre, Tom Le Paine, Andrew Cowie, Ziyu Wang, Bilal Piot, and Nando de Freitas. Acme: A research framework for distributed reinforcement learning, 2020.
198
+
199
+ Max Jaderberg, Volodymyr Mnih, Wojciech Marian Czarnecki, Tom Schaul, Joel Z Leibo, David Silver, and Koray Kavukcuoglu. Reinforcement learning with unsupervised auxiliary tasks, 2016.
200
+
201
+ Michael Laskin, Kimin Lee, Adam Stooke, Lerrel Pinto, Pieter Abbeel, and Aravind Srinivas. Reinforcement learning with augmented data, 2020.
202
+
203
+ A. X. Lee, A. Nagabandi, P. Abbeel, and S. Levine. Stochastic latent actor-critic: Deep reinforcement learning with a latent variable model. arXiv e-prints, 2019.
204
+
205
+ Alex X Lee, Anusha Nagabandi, Pieter Abbeel, and Sergey Levine. Stochastic latent actor-critic: Deep reinforcement learning with a latent variable model. arXiv preprint arXiv:1907.00953, 2019.
206
+
207
+ 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. CoRR, 2015a.
208
+
209
+ Timothy P. Lillicrap, Jonathan J. Hunt, Alexander Pritzel, Nicolas Manfred Otto Heess, Tom Erez, Yuval Tassa, David Silver, and Daan Wierstra. Continuous control with deep reinforcement learning. CoRR, abs/1509.02971, 2015b.
210
+
211
+ Volodymyr Mnih, Koray Kavukcuoglu, David Silver, Alex Graves, Ioannis Antonoglou, Daan Wierstra, and Martin Riedmiller. Playing atari with deep reinforcement learning. arXiv e-prints, 2013.
212
+
213
+ Volodymyr Mnih, Adria Puigdomenech Badia, Mehdi Mirza, Alex Graves, Timothy P. Lillicrap, Tim Harley, David Silver, and Koray Kavukcuoglu. Asynchronous methods for deep reinforcement learning. CoRR, 2016a.
214
+
215
+ Volodymyr Mnih, Adrià Puigdomènech Badia, Mehdi Mirza, Alex Graves, Timothy P. Lillicrap, Tim Harley, David Silver, and Koray Kavukcuoglu. Asynchronous methods for deep reinforcement learning, 2016b.
216
+
217
+ Rémi Munos, Tom Stepleton, Anna Harutyunyan, and Marc G. Bellemare. Safe and efficient off-policy reinforcement learning. CoRR, 2016.
218
+
219
+ Mehdi Noroozi and Paolo Favaro. Unsupervised learning of visual representations by solving jigsaw puzzles. In European Conference on Computer Vision, pages 69–84. Springer, 2016.
220
+
221
+ Lerrel Pinto, Dhiraj Gandhi, Yuanfeng Han, Yong-Lae Park, and Abhinav Gupta. The curious robot: Learning visual representations via physical interactions. CoRR, 2016.
222
+
223
+ Roberta Raileanu, Max Goldstein, Denis Yarats, Ilya Kostrikov, and Rob Fergus. Automatic data augmentation for generalization in deep reinforcement learning. CoRR, 2020.
224
+
225
+ Max Schwarzer, Ankesh Anand, Rishab Goel, R Devon Hjelm, Aaron Courville, and Philip Bachman. Data-efficient reinforcement learning with momentum predictive representations. arXiv preprint arXiv:2007.05929, 2020a.
226
+
227
+ Max Schwarzer, Ankesh Anand, Rishab Goel, R. Devon Hjelm, Aaron C. Courville, and Philip Bachman. Data-efficient reinforcement learning with momentum predictive representations. CoRR, 2020b.
228
+
229
+ David Silver, Guy Lever, Nicolas Heess, Thomas Degris, Daan Wierstra, and Martin Riedmiller. Deterministic policy gradient algorithms. In Proceedings of the 31st International Conference on Machine Learning, 2014.
230
+
231
+ Aravind Srinivas, Michael Laskin, and Pieter Abbeel. Curl: Contrastive unsupervised representations for reinforcement learning. arXiv preprint arXiv:2004.04136, 2020.
232
+
233
+ Adam Stooke, Kimin Lee, Pieter Abbeel, and Michael Laskin. Decoupling representation learning from reinforcement learning. arXiv preprint arXiv, 2020.
234
+
235
+ Yuval Tassa, Tom Erez, and Emanuel Todorov. Synthesis and stabilization of complex behaviors through online trajectory optimization. In 2012 IEEE/RSJ International Conference on Intelligent Robots and Systems, 2012.
236
+
237
+ 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.
238
+
239
+ Emanuel Todorov, Tom Erez, and Yuval Tassa. Mujoco: A physics engine for model-based control. In 2012 IEEE/RSJ International Conference on Intelligent Robots and Systems, 2012.
240
+
241
+ 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, pages 1096–1103. ACM, 2008.
242
+
243
+ Xiaolong Wang and Abhinav Gupta. Unsupervised learning of visual representations using videos. In ICCV, 2015.
244
+
245
+ Christopher J. C. H. Watkins and Peter Dayan. Q-learning. Machine Learning, 1992.
246
+
247
+ Christopher John Cornish Hellaby Watkins. Learning from Delayed Rewards. PhD thesis, King’s College, 1989.
248
+
249
+ Wilson Yan, Ashwin Vangipuram, Pieter Abbeel, and Lerrel Pinto. Learning predictive representations for deformable objects using contrastive estimation. arXiv preprint arXiv:2003.05436, 2020.
250
+
251
+ Denis Yarats, Amy Zhang, Ilya Kostrikov, Brandon Amos, Joelle Pineau, and Rob Fergus. Improving sample efficiency in model-free reinforcement learning from images. arXiv preprint arXiv:1910.01741, 2019.
252
+
253
+ Denis Yarats, Rob Fergus, Alessandro Lazaric, and Lerrel Pinto. Reinforcement learning with prototypical representations. CoRR, 2021a.
254
+
255
+ Denis Yarats, Ilya Kostrikov, and Rob Fergus. Image augmentation is all you need: Regularizing deep reinforcement learning from pixels. In 9th International Conference on Learning Representations, ICLR 2021, 2021b.
256
+
257
+ Sarah Young, Dhiraj Gandhi, Shubham Tulsiani, Abhinav Gupta, Pieter Abbeel, and Lerrel Pinto. Visual imitation made easy. CoRR, 2020.
258
+
259
+ Albert Zhan, Philip Zhao, Lerrel Pinto, Pieter Abbeel, and Michael Laskin. A framework for efficient robotic manipulation. CoRR, 2020.
260
+
261
+ Richard Zhang, Phillip Isola, and Alexei A Efros. Split-brain autoencoders: Unsupervised learning by cross-channel prediction. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pages 1058–1067, 2017.
md/dev/_VjQlMeSB_J/_VjQlMeSB_J.md ADDED
@@ -0,0 +1,295 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Chain-of-Thought Prompting Elicits Reasoning in Large Language Models
2
+
3
+ Jason Wei Xuezhi Wang Dale Schuurmans Maarten Bosma
4
+
5
+ Brian Ichter Fei Xia Ed H. Chi Quoc V. Le Denny Zhou
6
+
7
+ Google Research, Brain Team {jasonwei,dennyzhou}@google.com
8
+
9
+ # Abstract
10
+
11
+ We explore how generating a chain of thought—a series of intermediate reasoning steps—significantly improves the ability of large language models to perform complex reasoning. In particular, we show how such reasoning abilities emerge naturally in sufficiently large language models via a simple method called chain-ofthought prompting, where a few chain of thought demonstrations are provided as exemplars in prompting.
12
+
13
+ Experiments on three large language models show that chain-of-thought prompting improves performance on a range of arithmetic, commonsense, and symbolic reasoning tasks. The empirical gains can be striking. For instance, prompting a PaLM 540B with just eight chain-of-thought exemplars achieves state-of-the-art accuracy on the GSM8K benchmark of math word problems, surpassing even finetuned GPT-3 with a verifier.
14
+
15
+ ![](images/89ab3799d105e595086d7c7e3059c4c95016564718ada32028e60eef2d474c49.jpg)
16
+ Figure 1: Chain-of-thought prompting enables large language models to tackle complex arithmetic, commonsense, and symbolic reasoning tasks. Chain-of-thought reasoning processes are highlighted.
17
+
18
+ # 1 Introduction
19
+
20
+ The NLP landscape has recently been revolutionized by language models (Peters et al., 2018; Devlin et al., 2019; Brown et al., 2020, inter alia). Scaling up the size of language models has been shown to confer a range of benefits, such as improved performance and sample efficiency (Kaplan et al., 2020; Brown et al., 2020, inter alia). However, scaling up model size alone has not proved sufficient for achieving high performance on challenging tasks such as arithmetic, commonsense, and symbolic reasoning (Rae et al., 2021).
21
+
22
+ This work explores how the reasoning ability of large language models can be unlocked by a simple method motivated by two ideas. First, techniques for arithmetic reasoning can benefit from generating natural language rationales that lead to the final answer. Prior work has given models the ability to generate natural language intermediate steps by training from scratch (Ling et al., 2017) or finetuning a pretrained model (Cobbe et al., 2021), in addition to neuro-symbolic methods that use formal languages instead of natural language (Roy and Roth, 2015; Chiang and Chen, 2019; Amini et al., 2019; Chen et al., 2019). Second, large language models offer the exciting
23
+
24
+ Finetuned GPT-3 175B
25
+ Prior best PaLM 540B: standard prompting PaLM 540B: chain-of-thought prompting
26
+
27
+ ![](images/d7882b4649faefdd9a2b82d45815028e7e1d5a09149c74872bb38e2b8bb59569.jpg)
28
+ Figure 2: PaLM 540B uses chain-ofthought prompting to achieve new stateof-the-art performance on the GSM8K benchmark of math word problems. Finetuned GPT-3 and prior best are from Cobbe et al. (2021).
29
+
30
+ prospect of in-context few-shot learning via prompting. That is, instead of finetuning a separate language model checkpoint for each new task, one can simply “prompt” the model with a few input–output exemplars demonstrating the task. Remarkably, this has been successful for a range of simple question-answering tasks (Brown et al., 2020).
31
+
32
+ Both of the above ideas, however, have key limitations. For rationale-augmented training and finetuning methods, it is costly to create a large set of high quality rationales, which is much more complicated than simple input–output pairs used in normal machine learning. For the traditional fewshot prompting method used in Brown et al. (2020), it works poorly on tasks that require reasoning abilities, and often does not improve substantially with increasing language model scale (Rae et al., 2021). In this paper, we combine the strengths of these two ideas in a way that avoids their limitations. Specifically, we explore the ability of language models to perform few-shot prompting for reasoning tasks, given a prompt that consists of triples: hinput, chain of thought, outputi. A chain of thought is a series of intermediate natural language reasoning steps that lead to the final output, and we refer to this approach as chain-of-thought prompting. An example prompt is shown in Figure 1.
33
+
34
+ We present empirical evaluations on arithmetic, commonsense, and symbolic reasoning benchmarks, showing that chain-of-thought prompting outperforms standard prompting, sometimes to a striking degree. Figure 2 illustrates one such result—on the GSM8K benchmark of math word problems (Cobbe et al., 2021), chain-of-thought prompting with PaLM 540B outperforms standard prompting by a large margin and achieves new state-of-the-art performance. A prompting only approach is important because it does not require a large training dataset and because a single model checkpoint can perform many tasks without loss of generality. This work underscores how large language models can learn via a few examples with natural language data about the task (c.f. automatically learning the patterns underlying inputs and outputs via a large training dataset).
35
+
36
+ # 2 Chain-of-Thought Prompting
37
+
38
+ Consider one’s own thought process when solving a complicated reasoning task such as a multi-step math word problem. It is typical to decompose the problem into intermediate steps and solve each before giving the final answer: “After Jane gives 2 flowers to her mom she has 10 . . . then after she gives 3 to her dad she will have 7 . . . so the answer is 7.” The goal of this paper is to endow language models with the ability to generate a similar chain of thought—a coherent series of intermediate reasoning steps that lead to the final answer for a problem. We will show that sufficiently large language models can generate chains of thought if demonstrations of chain-of-thought reasoning are provided in the exemplars for few-shot prompting.
39
+
40
+ Figure 1 shows an example of a model producing a chain of thought to solve a math word problem that it would have otherwise gotten incorrect. The chain of thought in this case resembles a solution and can interpreted as one, but we still opt to call it a chain of thought to better capture the idea that it mimics a step-by-step thought process for arriving at the answer (and also, solutions/explanations typically come after the final answer (Narang et al., 2020; Wiegreffe et al., 2022; Lampinen et al., 2022, inter alia)).
41
+
42
+ Chain-of-thought prompting has several attractive properties as an approach for facilitating reasoning in language models.
43
+
44
+ 1. First, chain of thought, in principle, allows models to decompose multi-step problems into intermediate steps, which means that additional computation can be allocated to problems that require more reasoning steps.
45
+ 2. Second, a chain of thought provides an interpretable window into the behavior of the model, suggesting how it might have arrived at a particular answer and providing opportunities to debug where the reasoning path went wrong (although fully characterizing a model’s computations that support an answer remains an open question).
46
+ 3. Third, chain-of-thought reasoning can be used for tasks such as math word problems, commonsense reasoning, and symbolic manipulation, and is potentially applicable (at least in principle) to any task that humans can solve via language.
47
+ 4. Finally, chain-of-thought reasoning can be readily elicited in sufficiently large off-the-shelf language models simply by including examples of chain of thought sequences into the exemplars of few-shot prompting.
48
+
49
+ In empirical experiments, we will observe the utility of chain-of-thought prompting for arithmetic reasoning (Section 3), commonsense reasoning (Section 4), and symbolic reasoning (Section 5).
50
+
51
+ # 3 Arithmetic Reasoning
52
+
53
+ We begin by considering math word problems of the form in Figure 1, which measure the arithmetic reasoning ability of language models. Though simple for humans, arithmetic reasoning is a task where language models often struggle (Hendrycks et al., 2021; Patel et al., 2021, inter alia). Strikingly, chainof-thought prompting when used with the 540B parameter language model performs comparably with task-specific finetuned models on several tasks, even achieving new state of the art on the challenging GSM8K benchmark (Cobbe et al., 2021).
54
+
55
+ # 3.1 Experimental Setup
56
+
57
+ We explore chain-of-thought prompting for various language models on multiple benchmarks.
58
+
59
+ Benchmarks. We consider the following five math word problem benchmarks: (1) the GSM8K benchmark of math word problems (Cobbe et al., 2021), (2) the SVAMP dataset of math word problems with varying structures (Patel et al., 2021), (3) the ASDiv dataset of diverse math word problems (Miao et al., 2020), (4) the AQuA dataset of algebraic word problems, and (5) the MAWPS benchmark (Koncel-Kedziorski et al., 2016). Example problems are given in Appendix Table 12.
60
+
61
+ Standard prompting. For the baseline, we consider standard few-shot prompting, popularized by Brown et al. (2020), in which a language model is given in-context exemplars of input–output pairs before outputting a prediction for a test-time example. Exemplars are formatted as questions and answers. The model gives the answer directly, as shown in Figure 1 (left).
62
+
63
+ Chain-of-thought prompting. Our proposed approach is to augment each exemplar in few-shot prompting with a chain of thought for an associated answer, as illustrated in Figure 1 (right). As most of the datasets only have an evaluation split, we manually composed a set of eight few-shot exemplars with chains of thought for prompting—Figure 1 (right) shows one chain of thought exemplar, and the full set of exemplars is given in Appendix Table 20. (These particular exemplars did not undergo prompt engineering; robustness is studied in Section 3.4 and Appendix A.2.) To investigate whether chain-of-thought prompting in this form can successfully elicit successful reasoning across a range of math word problems, we used this single set of eight chain of thought exemplars for all benchmarks except AQuA, which is multiple choice instead of free response. For AQuA, we used four exemplars and solutions from the training set, as given in Appendix Table 21.
64
+
65
+ ![](images/89a5ee9245764678a62df985ae74ac1f355481b7fba3da340ff294060cdc69a1.jpg)
66
+ Figure 3: Examples of hinput, chain of thought, outputi triples for arithmetic, commonsense, and symbolic reasoning benchmarks. Chains of thought are highlighted. Full prompts in Appendix G.
67
+
68
+ Language models. We evaluate five large language models. The first is GPT-3 (Brown et al., 2020), for which we use text-ada-001, text-babbage-001, text-curie-001, and text-davinci-002, which presumably correspond to InstructGPT models of 350M, 1.3B, 6.7B, and 175B parameters (Ouyang et al., 2022).The second is LaMDA (Thoppilan et al., 2022), which has models of 422M, 2B, 8B, 68B, and 137B parameters. The third is PaLM, which has models of 8B, 62B, and 540B parameters. The fourth is UL2 20B (Tay et al., 2022), and the fifth is Codex (Chen et al., 2021, code-davinci-002 in the OpenAI API). We sample from the models via greedy decoding (though follow-up work shows chain-of-thought prompting can be improved by taking the majority final answer over many sampled generations (Wang et al., 2022a)). For LaMDA, we report averaged results over five random seeds, where each seed had a different randomly shuffled order of exemplars. As LaMDA experiments did not show large variance among different seeds, to save compute we report results for a single exemplar order for all other models.
69
+
70
+ # 3.2 Results
71
+
72
+ The strongest results of chain-of-thought prompting are summarized in Figure 4, with all experimental outputs for each model collection, model size, and benchmark shown in Table 2 in the Appendix. There are three key takeaways. First, Figure 4 shows that chain-of-thought prompting is an emergent ability of model scale (Wei et al., 2022b). That is, chain-of-thought prompting does not positively impact performance for small models, and only yields performance gains when used with models of ${ \sim } 1 0 0 \mathrm { B }$ parameters. We qualitatively found that models of smaller scale produced fluent but illogical chains of thought, leading to lower performance than standard prompting.
73
+
74
+ Second, chain-of-thought prompting has larger performance gains for more-complicated problems. For instance, for GSM8K (the dataset with the lowest baseline performance), performance more than doubled for the largest GPT and PaLM models. On the other hand, for SingleOp, the easiest subset of MAWPS which only requires a single step to solve, performance improvements were either negative or very small (see Appendix Table 3).
75
+
76
+ Third, chain-of-thought prompting via GPT-3 175B and PaLM 540B compares favorably to prior state of the art, which typically finetunes a task-specific model on a labeled training dataset. Figure 4 shows how PaLM 540B uses chain-ofthought prompting to achieve new state of the art on GSM8K, SVAMP, and MAWPS (though note that standard prompting already passed the prior best for SVAMP). On the other two datasets, AQuA and ASDiv, PaLM with chain-of-thought prompting reaches within $2 \%$ of the state of the art (Appendix Table 2).
77
+
78
+ To better understand why chain-of-thought prompting works, we manually examined modelgenerated chains of thought by LaMDA 137B for GSM8K. Of 50 random examples where the model returned the correct final answer, all of the generated chains of thought were also logically and mathematically correct except two that coincidentally arrived at the correct answer (see Appendix D.1, and Table 8 for examples of correct model-generated chains of thought). We also randomly examined 50 random samples for which the model gave the wrong answer. The summary of this analysis is that $46 \%$ of the chains of thought were almost correct, barring minor mistakes (calculator error, symbol map
79
+
80
+ ![](images/66c022898bff367d5860a3fc49e57a4fadc8dcb6199599bfe7c3100af93ef076.jpg)
81
+ Figure 4: Chain-of-thought prompting enables large language models to solve challenging math problems. Notably, chain-of-thought reasoning is an emergent ability of increasing model scale. Prior best numbers are from Cobbe et al. (2021) for GSM8K, Jie et al. (2022) for SVAMP, and Lan et al. (2021) for MAWPS.
82
+
83
+ ping error, or one reasoning step missing), and that the other $54 \%$ of the chains of thought had major errors in semantic understanding or coherence (see Appendix D.2). To provide a small insight into why scaling improves chain-of-thought reasoning ability, we performed a similar analysis of errors made by PaLM 62B and whether those errors were fixed by scaling to PaLM 540B. The summary is that scaling PaLM to 540B fixes a large portion of one-step missing and semantic understanding errors in the 62B model (see Appendix A.1).
84
+
85
+ # 3.3 Ablation Study
86
+
87
+ The observed benefits of using chain-of-thought prompting raises the natural question of whether the same performance improvements can be conferred via other types of prompting. Figure 5 shows an ablation study with three variations of chain of thought described below.
88
+
89
+ Equation only. One reason for why chain-of-thought prompting might help is that it produces the mathematical equation to be evaluated, and so we test a variation where the model is prompted to output only a mathematical equation before giving the answer. Figure 5 shows that equation only prompting does not help much for GSM8K, which implies that the semantics of the questions in GSM8K are too challenging to directly translate into an equation without the natural language reasoning steps in chain of thought. For datasets of one-step or two-step problems, however, we find that equation only prompting does improve performance, since the equation can be easily derived from the question (see Appendix Table 6).
90
+
91
+ Variable compute only. Another intuition is that chain of thought allows the model to spend more computation (i.e., intermediate tokens) on harder problems. To isolate the effect of variable computation from chain-of-thought reasoning, we test a configuration where the model is prompted to output a only sequence of dots $( \ldots )$ equal to the number of characters in the equation needed to solve the problem. This variant performs about the same as the baseline, which suggests that variable computation by itself is not the reason for the success of chainof-thought prompting, and that there appears to be utility from expressing intermediate steps via natural language.
92
+
93
+ Chain of thought after answer. Another potential benefit of chain-of-thought prompting could simply be that such prompts allow the model to better access relevant knowledge acquired during pretraining. Therefore, we test an alternative configuration where the chain of thought prompt is only given after the answer, isolating whether the model actually depends on the produced chain of thought to give the final answer. This variant performs about the same as the baseline, which suggests that the sequential reasoning embodied in the chain of thought is useful for reasons beyond just activating knowledge.
94
+
95
+ Standard prompting Z Equation only Variable compute only 用 Reasoning after answer Chain-of-thought prompting
96
+
97
+ ![](images/e6ae1dc967e810730fda1618d18b35c7fc13ce62af4bf30f06c19dc149050fe2.jpg)
98
+ Figure 5: Ablation study for different variations of prompting using LaMDA 137B and PaLM 540B. Results for other datasets are given in Appendix Table 6 and Table 7.
99
+
100
+ # 3.4 Robustness of Chain of Thought
101
+
102
+ Sensitivity to exemplars is a key consideration of prompting approaches—for instance, varying the permutation of few-shot exemplars can cause the accuracy of GPT-3 on SST-2 to range from near chance $( 5 4 . 3 \% )$ to near state of the art $( 9 3 . 4 \% )$ (Zhao et al., 2021). In this final subsection, we evaluate robustness to chains of thought written by different annotators. In addition to the results above, which used chains of thought written by an Annotator A, two other co-authors of this paper (Annotators B and C) independently wrote chains of thought for the same few-shot exemplars (shown in Appendix H). Annotator A also wrote another chain of thought that was more concise than the original, following the style of solutions given in Cobbe et al. (2021).1
103
+
104
+ Figure 6 shows these results for LaMDA 137B on GSM8K and MAWPS (ablation results for other datasets are given in Appendix Table 6 / Table 7). Although there is variance among different chain of thought annotations, as would be expected when using exemplar-based prompting (Le Scao and Rush, 2021; Reynolds and McDonell, 2021; Zhao et al., 2021), all sets of chain of thought prompts outperform the standard baseline by a large margin. This result implies that successful use of chain of thought does not depend on a particular linguistic style.
105
+
106
+ ![](images/4e11e7bcb919c728e67a6b419ec469fa86d0f95c703a30a4d57759b25ff7f940.jpg)
107
+ Figure 6: Chain-of-thought prompting has variance for different prompt examples (as expected) but outperforms standard prompting for various annotators as well as for different exemplars.
108
+
109
+ To confirm that successful chain-of-thought prompting works for other sets of exemplars, we also run experiments with three sets of eight exemplars randomly sampled from the GSM8K training set, an independent source (examples in this dataset already included reasoning steps like a chain of thought).2 Figure 6 shows that these prompts performed comparably with our manually written exemplars, also substantially outperforming standard prompting.
110
+
111
+ In addition to robustness to annotators, independently-written chains of thought, different exemplars, and various language models, we also find that chain-of-thought prompting for arithmetic reasoning is robust to different exemplar orders and varying numbers of exemplars (see Appendix A.2).
112
+
113
+ # 4 Commonsense Reasoning
114
+
115
+ Although chain of thought is particularly suitable for math word problems, the language-based nature of chain of thought actually makes it applicable to a broad class of commonsense reasoning problems, which involve reasoning about physical and human interactions under the presumption of general background knowledge. Commonsense reasoning is key for interacting with the world and is still beyond the reach of current natural language understanding systems (Talmor et al., 2021).
116
+
117
+ Benchmarks. We consider five datasets covering a diverse range of commonsense reasoning types. The popular CSQA (Talmor et al., 2019) asks commonsense questions about the world involving complex semantics that often require prior knowledge. StrategyQA (Geva et al., 2021) requires models to infer a multi-hop strategy to answer questions. We choose two specialized evaluation sets from the BIG-bench effort (BIG-bench collaboration, 2021): Date Understanding, which involves inferring a date from a given context, and Sports Understanding, which involves determining whether a sentence relating to sports is plausible or implausible. Finally, the SayCan dataset (Ahn et al., 2022) involves mapping a natural language instruction to a sequence of robot actions from a discrete set. Figure 3 shows examples with chain of thought annotations for all datasets.
118
+
119
+ Prompts. We follow the same experimental setup as the prior section. For CSQA and StrategyQA, we randomly selected examples from the training set and manually composed chains of thought for them to use as few-shot exemplars. The two BIG-bench tasks do not have training sets, so we selected the first ten examples as exemplars in the evaluation set as few-shot exemplars and report numbers on the rest of the evaluation set. For SayCan, we use six examples from the training set used in Ahn et al. (2022) and also manually composed chains of thought.
120
+
121
+ Results. Figure 7 highlights these results for PaLM (full results for LaMDA, GPT-3, and different model scales are shown in Table 4). For all tasks, scaling up model size improved the performance of standard prompting; chain-of-thought prompting led to further gains, with improvements appearing to be largest for PaLM 540B. With chain-of-thought prompting, PaLM 540B achieved strong performance relative to baselines, outperforming the prior state of the art on StrategyQA $7 5 . 6 \%$ vs $6 9 . 4 \%$ and outperforming an unaided sports enthusiast on sports understanding $9 5 . 4 \%$ vs $84 \%$ ). These results demonstrate that chain-of-thought prompting can also improve performance on tasks requiring a range of commonsense reasoning abilities (though note that gain was minimal on CSQA).
122
+
123
+ ![](images/314d6a9f471c937800bcc79eed382244c146f9aacc68828ea5e504cb8128e362.jpg)
124
+ Figure 7: Chain-of-thought prompting also improves the commonsense reasoning abilities of language models. The language model shown here is PaLM. Prior best numbers are from the leaderboards of CSQA (Talmor et al., 2019) and StrategyQA (Geva et al., 2021) (single-model only, as of May 5, 2022). Additional results using various sizes of LaMDA, GPT-3, and PaLM are shown in Table 4.
125
+
126
+ # 5 Symbolic Reasoning
127
+
128
+ Our final experimental evaluation considers symbolic reasoning, which is simple for humans but potentially challenging for language models. We show that chain-ofthought prompting not only enables language models to perform symbolic reasoning tasks that are challenging in the standard prompting setting, but also facilitates length generalization to inference-time inputs longer than those seen in the few-shot exemplars.
129
+
130
+ Tasks. We use the following two toy tasks.
131
+
132
+ • Last letter concatenation. This task asks the model to concatenate the last letters of words in a name (e.g., “Amy Brown” $ ^ { \ast } y n ^ { \prime \prime }$ ). It is a more challenging version of first letter concatenation, which language models can already perform without chain of thought.3 We generate full names by randomly concatenating names from the top one-thousand first and last names from name census data (https://namecensus.com/).
133
+
134
+ ![](images/e4f8153620820f36adc177bd4972c7b26a10341d1dec25b01e73852fd72bc7ae.jpg)
135
+ Figure 8: Using chain-of-thought prompting facilitates generalization to longer sequences in two symbolic reasoning tasks.
136
+
137
+ • Coin flip. This task asks the model to answer whether a coin is still heads up after people either flip or don’t flip the coin (e.g., “A coin is heads up. Phoebe flips the coin. Osvaldo does not flip the coin. Is the coin still heads up? $^ { \prime \prime } \right. ^ { \left. } n o ^ { \prime \prime }$ ).
138
+
139
+ As the construction of these symbolic reasoning tasks is well-defined, for each task we consider an in-domain test set for which examples had the same number of steps as the training/few-shot exemplars, as well as an out-of-domain (OOD) test set, for which evaluation examples had more steps than those in the exemplars. For last letter concatenation, the model only sees exemplars of names with two words, and then performs last letter concatenation on names with 3 and 4 words.4 We do the same for the number of potential flips in the coin flip task. Our experimental setup uses the same methods and models as in the prior two sections. We again manually compose chains of thought for the few-shot exemplars for each task, which are given in Figure 3.
140
+
141
+ Results. The results of these in-domain and OOD evaluations are shown in Figure 8 for PaLM, with results for LaMDA shown in Appendix Table 5. With PaLM 540B, chain-of-thought prompting leads to almost $100 \%$ solve rates (note that standard prompting already solves coin flip with PaLM 540, though not for LaMDA 137B). Note that these in-domain evaluations are “toy tasks” in the sense that perfect solution structures are already provided by the chains of thought in the few-shot exemplars; all the model has to do is repeat the same steps with the new symbols in the test-time example. And yet, small models still fail—the ability to perform abstract manipulations on unseen symbols for these three tasks only arises at the scale of 100B model parameters.
142
+
143
+ As for the OOD evaluations, standard prompting fails for both tasks. With chain-of-thought prompting, language models achieve upward scaling curves (though performance is lower than in the in-domain setting). Hence, chain-of-thought prompting facilitates length generalization beyond seen chains of thought for language models of sufficient scale.
144
+
145
+ # 6 Discussion
146
+
147
+ We have explored chain-of-thought prompting as a simple mechanism for eliciting multi-step reasoning behavior in large language models. We first saw that chain-of-thought prompting improves performance by a large margin on arithmetic reasoning, yielding improvements that are much stronger than ablations and robust to different annotators, exemplars, and language models (Section 3). Next, experiments on commonsense reasoning underscored how the linguistic nature of chain-of-thought reasoning makes it generally applicable (Section 4). Finally, we showed that for symbolic reasoning, chain-of-thought prompting facilitates OOD generalization to longer sequence lengths (Section 5). In all experiments, chain-of-thought reasoning is elicited simply by prompting an off-the-shelf language model. No language models were finetuned in the process of writing this paper.
148
+
149
+ The emergence of chain-of-thought reasoning as a result of model scale has been a prevailing theme (Wei et al., 2022b). For many reasoning tasks where standard prompting has a flat scaling curve, chainof-thought prompting leads to dramatically increasing scaling curves. Chain-of-thought prompting appears to expand the set of tasks that large language models can perform successfully—in other words, our work underscores that standard prompting only provides a lower bound on the capabilities of large language models. This observation likely raises more questions than it answers—for instance, how much more can we expect reasoning ability to improve with a further increase in model scale? What other prompting methods might expand the range of tasks that language models can solve?
150
+
151
+ As for limitations, we first qualify that although chain of thought emulates the thought processes of human reasoners, this does not answer whether the neural network is actually “reasoning,” which we leave as an open question. Second, although the cost of manually augmenting exemplars with chains of thought is minimal in the few-shot setting, such annotation costs could be prohibitive for finetuning (though this could potentially be surmounted with synthetic data generation, or zero-shot generalization). Third, there is no guarantee of correct reasoning paths, which can lead to both correct and incorrect answers; improving factual generations of language models is an open direction for future work (Rashkin et al., 2021; Ye and Durrett, 2022; Wiegreffe et al., 2022, inter alia). Finally, the emergence of chain-of-thought reasoning only at large model scales makes it costly to serve in real-world applications; further research could explore how to induce reasoning in smaller models.
152
+
153
+ # 7 Related Work
154
+
155
+ This work is inspired by many research areas, which we detail in an extended related work section (Appendix C). Here we describe two directions and associated papers that are perhaps most relevant.
156
+
157
+ The first relevant direction is using intermediate steps to solve reasoning problems. Ling et al. (2017) pioneer the idea of using natural language rationales to solve math word problems through a series of intermediate steps. Their work is a remarkable contrast to the literature using formal languages to reason (Roy et al., 2015; Chiang and Chen, 2019; Amini et al., 2019; Chen et al., 2019). Cobbe et al. (2021) extend Ling et al. (2017) by creating a larger dataset and using it to finetune a pretrained language model rather than training a model from scratch. In the domain of program synthesis, Nye et al. (2021) leverage language models to predict the final outputs of Python programs via first line-to-line predicting the intermediate computational results, and show that their step-by-step prediction method performs better than directly predicting the final outputs.
158
+
159
+ Naturally, this paper also relates closely to the large body of recent work on prompting. Since the popularization of few-shot prompting as given by Brown et al. (2020), several general approaches have improved the prompting ability of models, such as automatically learning prompts (Lester et al., 2021) or giving models instructions describing a task (Wei et al., 2022a; Sanh et al., 2022; Ouyang et al., 2022). Whereas these approaches improve or augment the input part of the prompt (e.g., instructions that are prepended to inputs), our work takes the orthogonal direction of augmenting the outputs of language models with a chain of thought.
160
+
161
+ # 8 Conclusions
162
+
163
+ We have explored chain-of-thought prompting as a simple and broadly applicable method for enhancing reasoning in language models. Through experiments on arithmetic, symbolic, and commonsense reasoning, we find that chain-of-thought reasoning is an emergent property of model scale that allows sufficiently large language models to perform reasoning tasks that otherwise have flat scaling curves. Broadening the range of reasoning tasks that language models can perform will hopefully inspire further work on language-based approaches to reasoning.
164
+
165
+ # Acknowledgements
166
+
167
+ We thank Jacob Devlin, Claire Cui, Andrew Dai, and Ellie Pavlick for providing feedback on the paper. We thank Jacob Austin, Yuhuai Wu, Henryk Michalewski, Aitor Lewkowycz, Charles Sutton, and Aakanksha Chowdhery for helpful discussions. We thank Sid Maxwell for notifying us about a mistake in the manual error analysis in the original manuscript.
168
+
169
+ References
170
+ Michael Ahn, Anthony Brohan, Noah Brown, Yevgen Chebotar, Omar Cortes, Byron David, Chelsea Finn, Keerthana Gopalakrishnan, Karol Hausman, Alex Herzog, et al. 2022. Do as I can, not as I say: Grounding language in robotic affordances. arXiv preprint arXiv:2204.01691.
171
+ Aida Amini, Saadia Gabriel, Shanchuan Lin, Rik Koncel-Kedziorski, Yejin Choi, and Hannaneh Hajishirzi. 2019. MathQA: Towards interpretable math word problem solving with operationbased formalisms. In Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long and Short Papers), Minneapolis, Minnesota. Association for Computational Linguistics.
172
+ Daniel Andor, Luheng He, Kenton Lee, and Emily Pitler. 2019. Giving BERT a calculator: Finding operations and arguments with reading comprehension. EMNLP.
173
+ Jacob Andreas, Dan Klein, and Sergey Levine. 2018. Learning with latent language. NAACL.
174
+ Jacob Austin, Augustus Odena, Maxwell Nye, Maarten Bosma, Henryk Michalewski, David Dohan, Ellen Jiang, Carrie Cai, Michael Terry, Quoc Le, et al. 2021. Program synthesis with large language models. arXiv preprint arXiv:2108.07732.
175
+ BIG-bench collaboration. 2021. Beyond the imitation game: Measuring and extrapolating the capabilities of language models. In preparation.
176
+ Kaj Bostrom, Xinyu Zhao, Swarat Chaudhuri, and Greg Durrett. 2021. Flexible generation of natural language deductions. EMNLP.
177
+ 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. NeurIPS.
178
+ Jonathon Cai, Richard Shin, and Dawn Song. 2017. Making neural programming architectures generalize via recursion. ICLR.
179
+ Oana-Maria Camburu, Tim Rocktäschel, Thomas Lukasiewicz, and Phil Blunsom. 2018. e-SNLI: Natural language inference with natural language explanations. NeurIPS.
180
+ Howard Chen, Jacqueline He, Karthik Narasimhan, and Danqi Chen. 2022. Can rationalization improve robustness? NAACL.
181
+ 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. 2021. Evaluating large language models trained on code. arXiv preprint arXiv:2107.03374.
182
+ Xinyun Chen, Chen Liang, Adams Wei Yu, Denny Zhou, Dawn Song, and Quoc V. Le. 2019. Neural symbolic reader: Scalable integration of distributed and symbolic representations for reading comprehension. ICLR.
183
+ Ting-Rui Chiang and Yun-Nung Chen. 2019. Semantically-aligned equation generation for solving and reasoning math word problems. 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 2656–2668, Minneapolis, Minnesota. Association for Computational Linguistics.
184
+
185
+ Peter Clark, Oyvind Tafjord, and Kyle Richardson. 2020. Transformers as soft reasoners over language. IJCAI.
186
+
187
+ Karl Cobbe, Vineet Kosaraju, Mohammad Bavarian, Jacob Hilton, Reiichiro Nakano, Christopher Hesse, and John Schulman. 2021. Training verifiers to solve math word problems. arXiv preprint arXiv:2110.14168.
188
+
189
+ Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. 2019. BERT: Pre-training of deep bidirectional transformers for language understanding. NAACL.
190
+
191
+ Honghua Dong, Jiayuan Mao, Tian Lin, Chong Wang, Lihong Li, and Denny Zhou. 2019. Neural logic machines. ICLR.
192
+
193
+ Dheeru Dua, Sameer Singh, and Matt Gardner. 2020. Benefits of intermediate annotations in reading comprehension. ACL.
194
+
195
+ Mor Geva, Daniel Khashabi, Elad Segal, Tushar Khot, Dan Roth, and Jonathan Berant. 2021. Did aristotle use a laptop? A question answering benchmark with implicit reasoning strategies. TACL.
196
+
197
+ Yuling Gu, Bhavana Dalvi Mishra, and Peter Clark. 2022. DREAM: Uncovering mental models behind language models. NAACL.
198
+
199
+ Braden Hancock, Paroma Varma, Stephanie Wang, Martin Bringmann, Percy Liang, and Christopher Ré. 2018. Training classifiers with natural language explanations. ACL.
200
+
201
+ Peter Hase and Mohit Bansal. 2022. When can models learn from explanations? a formal framework for understanding the roles of explanation data. ACL.
202
+
203
+ Dan Hendrycks, Collin Burns, Saurav Kadavath, Akul Arora, Steven Basart, Eric Tang, Dawn Song, and Jacob Steinhardt. 2021. Measuring mathematical problem solving with the math dataset. arXiv preprint arXiv:2103.03874.
204
+
205
+ Mohammad Javad Hosseini, Hannaneh Hajishirzi, Oren Etzioni, and Nate Kushman. 2014. Learning to solve arithmetic word problems with verb categorization. EMNLP.
206
+
207
+ Zhanming Jie, Jierui Li, and Wei Lu. 2022. Learning to reason deductively: Math word problem solving as complex relation extraction. arXiv preprint arXiv:2203.10316.
208
+
209
+ 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.
210
+
211
+ Rik Koncel-Kedziorski, Subhro Roy, Aida Amini, Nate Kushman, and Hannaneh Hajishirzi. 2016. MAWPS: A math word problem repository. NAACL.
212
+
213
+ Andrew K. Lampinen, Ishita Dasgupta, Stephanie C.Y. Chan, Kory Matthewson, Michael Henry Tessler, Antonia Creswell, James L. McClelland, Jane X. Wang, and Felix Hill. 2022. Can language models learn from explanations in context? arXiv preprint arXiv:2204.02329.
214
+
215
+ Yihuai Lan, Lei Wang, Qiyuan Zhang, Yunshi Lan, Bing Tian Dai, Yan Wang, Dongxiang Zhang, and Ee-Peng Lim. 2021. MWPToolkit: An open-source framework for deep learning-based math word problem solvers. arXiv preprint arXiv:2109.00799.
216
+
217
+ Teven Le Scao and Alexander Rush. 2021. How many data points is a prompt worth? NAACL.
218
+
219
+ Brian Lester, Rami Al-Rfou, and Noah Constant. 2021. The power of scale for parameter-efficient prompt tuning. EMNLP.
220
+
221
+ Iddo Lev, Bill MacCartney, Christopher Manning, and Roger Levy. 2004. Solving logic puzzles: From robust processing to precise semantics. Proceedings of the 2nd Workshop on Text Meaning and Interpretation.
222
+
223
+ Xiang Lisa Li and Percy Liang. 2021. Prefix-tuning: Optimizing continuous prompts for generation. ACL.
224
+
225
+ Zhengzhong Liang, Steven Bethard, and Mihai Surdeanu. 2021. Explainable multi-hop verbal reasoning through internal monologue. NAACL.
226
+ Wang Ling, Dani Yogatama, Chris Dyer, and Phil Blunsom. 2017. Program induction by rationale generation: Learning to solve and explain algebraic word problems. ACL.
227
+ Pengfei Liu, Weizhe Yuan, Jinlan Fu, Zhengbao Jiang, Hiroaki Hayashi, and Graham Neubig. 2021. Pre-train, prompt, and predict: A systematic survey of prompting methods in natural language processing. arXiv preprint arXiv:2107.13586.
228
+ Bodhisattwa Prasad Majumder, Oana-Maria Camburu, Thomas Lukasiewicz, and Julian McAuley. 2021. Rationale-inspired natural language explanations with commonsense. arXiv preprint arXiv:2106.13876.
229
+ Ana Marasovic, Iz Beltagy, Doug Downey, and Matthew E Peters. 2022. ´ Few-shot self-rationalization with natural language prompts. NAACL Findings.
230
+ Joshua Maynez, Shashi Narayan, Bernd Bohnet, and Ryan McDonald. 2020. On faithfulness and factuality in abstractive summarization. In ACL.
231
+ Shen Yun Miao, Chao Chun Liang, and Keh Yih Su. 2020. A diverse corpus for evaluating and developing English math word problem solvers. ACL.
232
+ Sewon Min, Xinxi Lyu, Ari Holtzman, Mikel Artetxe, Mike Lewis, Hannaneh Hajishirzi, and Luke Zettlemoyer. 2022. Rethinking the role of demonstrations: What makes in-context learning work? arXiv preprint arXiv:2202.12837.
233
+ Sharan Narang, Colin Raffel, Katherine Lee, Adam Roberts, Noah Fiedel, and Karishma Malkan. 2020. WT5?! Training text-to-text models to explain their predictions. arXiv preprint arXiv:2004.14546.
234
+ Maxwell Nye, Anders Johan Andreassen, Guy Gur-Ari, Henryk Michalewski, Jacob Austin, David Bieber, David Dohan, Aitor Lewkowycz, Maarten Bosma, David Luan, et al. 2021. Show your work: Scratchpads for intermediate computation with language models. arXiv preprint arXiv:2112.00114.
235
+ Long Ouyang, Jeff Wu, Xu Jiang, Diogo Almeida, Carroll L. Wainwright, Pamela Mishkin, Chong Zhang, Sandhini Agarwal, Katarina Slama, Alex Ray, et al. 2022. Training language models to follow instructions with human feedback. arXiv preprint arXiv:2203.02155.
236
+ Arkil Patel, Satwik Bhattamishra, and Navin Goyal. 2021. Are NLP models really able to solve simple math word problems? NAACL.
237
+ Matthew E. Peters, Mark Neumann, Mohit Iyyer, Matt Gardner, Christopher Clark, Kenton Lee, and Luke Zettlemoyer. 2018. Deep contextualized word representations. NAACL.
238
+ Xinyu Pi, Qian Liu, Bei Chen, Morteza Ziyadi, Zeqi Lin, Yan Gao, Qiang Fu, Jian-Guang Lou, and Weizhu Chen. 2022. Reasoning like program executors. arXiv preprint arXiv:2201.11473.
239
+ Piotr Pi˛ekos, Mateusz Malinowski, and Henryk Michalewski. 2021. Measuring and improving BERT’s mathematical abilities by predicting the order of reasoning. ACL.
240
+ 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.
241
+ Colin Raffel, Noam Shazeer, Adam Roberts, Katherine Lee, Sharan Narang, Michael Matena, Yanqi Zhou, Wei Li, and Peter J Liu. 2020. Exploring the limits of transfer learning with a unified text-to-text transformer. Journal of Machine Learning Research, 21:1–67.
242
+ Dheeraj Rajagopal, Vidhisha Balachandran, Eduard H. Hovy, and Yulia Tsvetkov. 2021. SelfExplain: A self-explaining architecture for neural text classifiers. EMNLP.
243
+ Nazneen Fatema Rajani, Bryan McCann, Caiming Xiong, and Richard Socher. 2019. Explain yourself! Leveraging language models for commonsense reasoning. ACL.
244
+
245
+ Qiu Ran, Yankai Lin, Peng Li, Jie Zhou, and Zhiyuan Liu. 2019. NumNet: Machine reading comprehension with numerical reasoning. EMNLP.
246
+
247
+ Hannah Rashkin, Vitaly Nikolaev, Matthew Lamm, Michael Collins, Dipanjan Das, Slav Petrov, Gaurav Singh Tomar, Iulia Turc, and David Reitter. 2021. Measuring attribution in natural language generation models. arXiv preprint arXiv:2112.12870.
248
+
249
+ Gabriel Recchia. 2021. Teaching autoregressive language models complex tasks by demonstration. arXiv preprint arXiv:2109.02102.
250
+
251
+ Emily Reif, Daphne Ippolito, Ann Yuan, Andy Coenen, Chris Callison-Burch, and Jason Wei. 2022. A recipe for arbitrary text style transfer with large language models. ACL.
252
+
253
+ Laria Reynolds and Kyle McDonell. 2021. Prompt programming for large language models: Beyond the few-shot paradigm. Extended Abstracts of the 2021 CHI Conference on Human Factors in Computing Systems.
254
+
255
+ Subhro Roy and Dan Roth. 2015. Solving general arithmetic word problems. EMNLP.
256
+
257
+ Subhro Roy, Tim Vieira, and Dan Roth. 2015. Reasoning about Quantities in Natural Language. TACL.
258
+
259
+ Mohammed Saeed, Naser Ahmadi, Preslav Nakov, and Paolo Papotti. 2021. RuleBERT: Teaching soft rules to pre-trained language models. EMNLP.
260
+
261
+ Victor Sanh, Albert Webson, Colin Raffel, Stephen H. Bach, Lintang Sutawika, Zaid Alyafeai, Antoine Chaffin, Arnaud Stiegler, Teven Le Scao, Arun Raja, et al. 2022. Multitask prompted training enables zero-shot task generalization. ICLR.
262
+
263
+ Jianhao Shen, Yichun Yin, Lin Li, Lifeng Shang, Xin Jiang, Ming Zhang, and Qun Liu. 2021. Generate & rank: A multi-task framework for math word problems. In Findings of the Association for Computational Linguistics: EMNLP 2021.
264
+
265
+ Alon Talmor, Jonathan Herzig, Nicholas Lourie, and Jonathan Berant. 2019. CommonsenseQA: A question answering challenge targeting commonsense knowledge. NAACL.
266
+
267
+ Alon Talmor, Oyvind Tafjord, Peter Clark, Yoav Goldberg, and Jonathan Berant. 2020. Leap-ofthought: Teaching pre-trained models to systematically reason over implicit knowledge. NeurIPS.
268
+
269
+ Alon Talmor, Ori Yoran, Ronan Le Bras, Chandra Bhagavatula, Yoav Goldberg, Yejin Choi, and Jonathan Berant. 2021. CommonsenseQA 2.0: Exposing the limits of ai through gamification. NeurIPS Track on Datasets and Benchmarks.
270
+
271
+ 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.
272
+
273
+ Romal Thoppilan, Daniel De Freitas, Jamie Hall, Noam Shazeer, Apoorv Kulshreshtha, Heng-Tze Cheng, Alicia Jin, Taylor Bos, Leslie Baker, Yu Du, et al. 2022. LaMDA: Language models for dialog applications. arXiv preprint arXiv:2201.08239.
274
+
275
+ Xuezhi Wang, Jason Wei, Dale Schuurmans, Quoc Le, Ed Chi, and Denny Zhou. 2022a. Self-consistency improves chain of thought reasoning in language models. arXiv preprint arXiv:2203.11171.
276
+
277
+ Yizhong Wang, Swaroop Mishra, Pegah Alipoormolabashi, Yeganeh Kordi, Amirreza Mirzaei, Anjana Arunkumar, Arjun Ashok, Arut Selvan Dhanasekaran, Atharva Naik, David Stap, et al. 2022b. Benchmarking generalization via in-context instructions on $1 { , } 6 0 0 { + }$ language tasks. arXiv preprint arXiv:2204.07705.
278
+
279
+ Jason Wei, Maarten Bosma, Vincent Y. Zhao, Kelvin Guu, Adams Wei Yu, Brian Lester, Nan Du, Andrew M. Dai, and Quoc V. Le. 2022a. Finetuned language models are zero-shot learners. ICLR.
280
+
281
+ Jason Wei, Yi Tay, Rishi Bommasani, Colin Raffel, Barret Zoph, Sebastian Borgeaud, Dani Yogatama, Maarten Bosma, Denny Zhou, Donald Metzler, et al. 2022b. Emergent abilities of large language models. Transactions on Machine Learning Research.
282
+ Sarah Wiegreffe, Jack Hessel, Swabha Swayamdipta, Mark Riedl, and Yejin Choi. 2022. Reframing human-AI collaboration for generating free-text explanations. NAACL.
283
+ Sarah Wiegreffe and Ana Marasovic. 2021. ´ Teach me to explain: A review of datasets for explainable NLP. NeurIPS.
284
+ Sarah Wiegreffe, Ana Marasovic, and Noah A. Smith. 2021. ´ Measuring association between labels and free-text rationales. EMNLP.
285
+ Tongshuang Wu, Ellen Jiang, Aaron Donsbach, Jeff Gray, Alejandra Molina, Michael Terry, and Carrie J Cai. 2022a. PromptChainer: Chaining large language model prompts through visual programming. CHI Extended Abstracts.
286
+ Tongshuang Wu, Michael Terry, and Carrie Jun Cai. 2022b. AI chains: Transparent and controllable human-AI interaction by chaining large language model prompts. CHI.
287
+ Yujun Yan, Kevin Swersky, Danai Koutra, Parthasarathy Ranganathan, and Milad Hashemi. 2020. Neural execution engines: Learning to execute subroutines. NeurIPS.
288
+ Huihan Yao, Ying Chen, Qinyuan Ye, Xisen Jin, and Xiang Ren. 2021. Refining language models with compositional explanations. NeurIPS.
289
+ Xi Ye and Greg Durrett. 2022. The unreliability of explanations in few-shot in-context learning. arXiv preprint arXiv:2205.03401.
290
+ Yordan Yordanov, Vid Kocijan, Thomas Lukasiewicz, and Oana-Maria Camburu. 2021. Few-shot out-of-domain transfer learning of natural language explanations. arXiv preprint arXiv:2112.06204.
291
+ Omar Zaidan, Jason Eisner, and Christine Piatko. 2007. Using “annotator rationales” to improve machine learning for text categorization. NAACL.
292
+ Wojciech Zaremba and Ilya Sutskever. 2014. Learning to execute. arXiv preprint arXiv:1410.4615.
293
+ Eric Zelikman, Yuhuai Wu, and Noah D. Goodman. 2022. STaR: Bootstrapping reasoning with reasoning. arXiv preprint arXiv:2203.14465.
294
+ Tony Z. Zhao, Eric Wallace, Shi Feng, Dan Klein, and Sameer Singh. 2021. Calibrate before use: Improving few-shot performance of language models. ICML.
295
+ Wangchunshu Zhou, Jinyi Hu, Hanlin Zhang, Xiaodan Liang, Maosong Sun, Chenyan Xiong, and Jian Tang. 2020. Towards interpretable natural language understanding with explanations as latent variables. NeurIPS.
md/dev/bZjxxYURKT/bZjxxYURKT.md ADDED
The diff for this file is too large to render. See raw diff
 
md/dev/cGDAkQo1C0p/cGDAkQo1C0p.md ADDED
The diff for this file is too large to render. See raw diff
 
md/dev/cOtBRgsf2fO/cOtBRgsf2fO.md ADDED
@@ -0,0 +1,546 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # LABEL LEAKAGE AND PROTECTION IN TWO-PARTY SPLIT LEARNING
2
+
3
+ Oscar $\mathbf { L i } ^ { 1 \dagger }$ ∗, Jiankai $\mathbf { S u n ^ { 2 \ S } }$ , $\mathbf { X i n \ Y a n g ^ { 2 } }$ , Weihao $\mathbf { G a o } ^ { 2 }$ , Hongyi Zhang2, Junyuan $\mathbf { X i e } ^ { 2 }$ , Virginia Smith1, Chong Wang2
4
+
5
+ 1Carnegie Mellon University
6
+ 2ByteDance Inc.
7
+
8
+ # ABSTRACT
9
+
10
+ Two-party split learning is a popular technique for learning a model across featurepartitioned data. In this work, we explore whether it is possible for one party to steal the private label information from the other party during split training, and whether there are methods that can protect against such attacks. Specifically, we first formulate a realistic threat model and propose a privacy loss metric to quantify label leakage in split learning. We then show that there exist two simple yet effective methods within the threat model that can allow one party to accurately recover private ground-truth labels owned by the other party. To combat these attacks, we propose several random perturbation techniques, including Marvell, an approach that strategically finds the structure of the noise perturbation by minimizing the amount of label leakage (measured through our quantification metric) of a worst-case adversary. We empirically1 demonstrate the effectiveness of our protection techniques against the identified attacks, and show that Marvell in particular has improved privacy-utility tradeoffs relative to baseline approaches.
11
+
12
+ # 1 INTRODUCTION
13
+
14
+ With increasing concerns over data privacy in machine learning, federated learning (FL) (McMahan et al., 2017) has become a promising direction of study. Based on how sensitive data are distributed among parties, FL can be classified into different categories, notable among which are horizontal $F L$ and vertical $F L$ (Yang et al., 2019). In contrast to horizontal FL where the data are partitioned by examples, vertical FL considers data partitioned by features (including labels). As a canonical example of vertical FL, consider an online media platform $A$ which displays advertisements from company $B$ to its users, and charges $B$ for each conversion (e.g., a user clicking the ad and buying the product). In this case, both parties have different features for each user: $A$ has features on the user’s media viewing records, while $B$ has the user’s conversion labels. $B$ ’s labels are not available to $A$ because each user’s purchase behaviors happen entirely on $B$ ’s website/app.
15
+
16
+ If both parties want to jointly learn a model to predict conversion without data sharing, split learning (Gupta & Raskar, 2018; Vepakomma et al., 2018) can be used to split the execution of a deep network between the parties on a layer-wise basis. In vanilla split learning, before training begins, both parties use Private Set Intersection (PSI) protocols (Kolesnikov et al., 2016; Pinkas et al., 2018) to find the intersection of their data records and achieve an example ID alignment. This alignment paves the way for the split training phase. During training (Figure 1), the party without labels (nonlabel party) sends the intermediate layer (cut layer) outputs rather than the raw data to the party with labels (label party), and the label party completes the rest of the forward computation to obtain the training loss. To compute the gradients with respect to model parameters, the label party initiates backpropagation from its training loss and computes its own parameters’ gradients. To allow the non-label party to also compute gradients of its parameters, the label party also computes the gradients with respect to the cut layer outputs and communicates this information back to the non-label party. As a result of the ID alignment, despite not knowing the label party’s raw label data, the non-label party can identify the gradient value returned by the label party for each example.
17
+
18
+ At first glance, the process of split learning appears privacy-preserving because only the intermediate computations of the cut layer—rather than raw features or labels—are communicated between the two parties. However, such “gradient sharing” schemes have been shown to be vulnerable to privacy leakage in horizontal FL settings (e.g., Zhu et al., 2019). In vertical FL (and specifically split learning), it remains unclear whether the raw data can similarly be leaked during communication. In particular, as the raw labels often contain highly sensitive information (e.g., what a user has purchased (in online advertising) or whether a user has a disease or not (in disease prediction) Vepakomma et al. (2018)), developing a rigorous understanding of the threat of label leakage and its protection is particularly important. Towards this goal, we make the following contributions:
19
+
20
+ ![](images/6d3962aa293ad26de1b3789a4155ec37fededb9027eaf28bf79d4454dafbce24.jpg)
21
+ Figure 1: Communication diagram of two-party split training for an example of online advertising. We study whether it is possible for the communicated gradient $g$ to leak private label information.
22
+
23
+ 1. We formalize a threat model for label leakage in two-party split learning in the context of binary classification (Section 3.1), and propose specific privacy quantification metrics to measure the severity of such threats (Section 3.2).
24
+ 2. We identify two simple and realistic methods within this threat model which can accurately recover the label party’s private label information (Section 3.3).
25
+ 3. We propose several random perturbation techniques to limit the label-stealing ability of the non-label party (Section 4). Among them, our principled approach Marvell directly searches for the optimal random perturbation noise structure to minimize label leakage (as measured via our quantification metric) against a worst-case adversarial non-label party.
26
+ 4. We experimentally demonstrate the effectiveness of our protection techniques and MARVELL’s improved privacy-utility tradeoffs compared to other protection baselines (Section 5).
27
+
28
+ # 2 RELATED WORK
29
+
30
+ Privacy leakage in split learning. Although raw data is not shared in federated learning, sensitive information may still be leaked when gradients and/or model parameters are communicated between parties. In horizontal FL, Zhu et al. (2019) showed that an honest-but-curious server can uncover the raw features and labels of a device by knowing the model architecture, parameters, and communicated gradient of the loss on the device’s data. Based on their techniques, Zhao et al. (2020) showed that the ground truth label of an example can be extracted by exploiting the directions of the gradients of the weights connected to the logits of different classes. Here we study a different setting—two-party split learning (in vertical FL) (Yang et al., 2019), where no party has access to the model architecture or model parameters of the other party. In this setting, Vepakomma et al. (2019) studied how the forward communication of feature representations can leak the non-label party’s raw data to the label party. We instead study whether label information may be leaked from the label party to the non-label party during the backward communication. Despite the importance of maintaining the privacy of these labels, we are unaware of prior work that has studied this problem.
31
+
32
+ Privacy protection and quantification. Techniques to protect communication privacy in FL generally fall into three categories: 1) cryptographic methods such as secure multi-party computation (e.g., Bonawitz et al., 2017); 2) system-based methods including trusted execution environments (Subramanyan et al., 2017); and 3) perturbation methods that shuffle or modify the communicated messages (e.g., Abadi et al., 2016; McMahan et al., 2018; Erlingsson et al., 2019; Cheu et al., 2019; Zhu et al., 2019). Our protection techniques belong to the third category, as we add random perturbations to the gradients to protect the labels. Many randomness-based protection methods have been proposed in the domain of horizontal FL. In this case, differential privacy (DP) (Dwork, 2006; Dwork et al., 2014) is commonly used to measure the proposed random mechanisms’ ability to anonymize the identity of any single participating example in the model iterates. However, in split learning, after PSI, both parties know exactly the identity of which example has participated in a given gradient update. As we explain in Section 3.1, the object we aim to protect (the communicated cut layer gradients), unlike the model iterates, is not an aggregate function of all the examples but are instead example-specific. As a result, DP and its variants (e.g. label DP (Chaudhuri & Hsu, 2011; Ghazi et al., 2021)) are not directly applicable metrics in our setting, and we instead propose a different metric (discussed in Section 3.2).
33
+
34
+ # 3 LABEL LEAKAGE IN SPLIT LEARNING
35
+
36
+ We first introduce the two-party split learning problem for binary classification, and then formally describe our threat model and privacy quantification metrics with two concrete attack examples.
37
+
38
+ # 3.1 TWO-PARTY SPLIT LEARNING IN BINARY CLASSIFICATION
39
+
40
+ Problem setup. Consider two parties learning a composition model $h \circ f$ jointly for a binary classification problem over the domain $\mathcal { X } \times \{ 0 , \bar { 1 } \}$ (Figure 1). The non-label party owns the representation function $f : \mathcal { X } \to \mathbb { R } ^ { d }$ and each example’s raw feature $X \in { \mathcal { X } }$ while the label party owns the logit function $h : \mathbb { R } ^ { d } \mathbb { R }$ and each example’s label $y \in \{ 0 , 1 \}$ . Let $\ell \ = \ h ( f ( X ) )$ be the logit of the positive class whose predicted probability is given through the sigmoid function: $\widetilde { p } _ { 1 } = 1 / ( 1 + \exp ( - \ell ) )$ . We measure the loss of such prediction through the cross entropy loss $L = \log ( 1 + \exp ( - \ell ) ) + ( 1 - y ) \ell$ . During model inference, the non-label party computes ${ \dot { \boldsymbol { f } } } ( { \boldsymbol { X } } )$ and sends it to the label party who will then execute the rest of forward computation in Figure 1.
41
+
42
+ Model training (Figure 1: backward gradient computation). To train the model using gradient descent, the label party starts by first computing the gradient of the loss $L$ with respect to the logit $\begin{array} { r } { \frac { d L } { d \ell } \ = \ ( \widetilde { p } _ { 1 } - y ) } \end{array}$ . Using the chain rule, the label party can then compute the gradient of $L$ with erespect to its function $h$ ’s parameters and perform the gradient updates. To also allow the non-label party to learn its function $f$ , the label party needs to additionally compute the gradient with respect to cut layer feature $f ( X )$ and communicate it to the non-label party. We denote this gradient by $g : = \nabla _ { f ( X ) } L = ( \widetilde { p } _ { 1 } - y ) \nabla _ { z } h ( z ) | _ { z = f ( X ) } \in \mathbb { R } ^ { d }$ (by chain rule). After receiving $g$ , the non-label eparty continues the backpropagation towards $f$ ’s parameters and also perform the gradient updates.
43
+
44
+ Why Not Differential Privacy? Note that for a given iteration, the non-label party randomly chooses $B$ example IDs to form a batch. Therefore, the identity of which examples are used is known to the non-label party by default. In addition, the communicated features $f ( X )$ and returned gradients $g$ will both be matrices in $\mathbb { R } ^ { B \times d }$ with each row belonging to a specific example in the batch. The different gradients (rows of the matrix) are not with respect to the same model parameters, but are instead with respect to different examples’ cut-layer features; thus, no averaging over or shuffling of the rows of the gradient matrix can be done prior to communication to ensure correct computation of $f$ ’s parameters on the non-label party side. This example-aware and example-specific nature of the communicated gradient matrix makes differential privacy (which focuses on anonymizing an example’s participation in an aggregate function) inapplicable for this problem (see also Section 2).
45
+
46
+ # 3.2 THREAT MODEL AND PRIVACY QUANTIFICATION
47
+
48
+ Below we specify several key aspects of our threat model, including the adversary’s objective and capabilities, our metric for quantifying privacy loss, and the possible inclusion of side information.
49
+
50
+ Adversary’s objective. At a given moment in time during training (with $f$ and $h$ fixed), since the communicated cut layer gradient $g$ is a deterministic function of $y$ (see Section 3.1), we consider an adversarial non-label party whose objective is to recover the label party’s hidden label $y$ based on the information contained in $g$ for every training example.
51
+
52
+ Adversary’s capability. We consider an honest-but-curious non-label party which cannot tamper with training by selecting which examples to include in a batch or sending incorrect features $f ( X )$ ; instead, we assume that the adversary follows the agreed-upon split training procedure while trying to guess the label $y$ . This can be viewed as a binary classification problem where the (input, output) distribution is the induced distribution of $( g , y )$ . We allow the adversary to use any binary classifier $q : \mathbb { R } ^ { d } \{ 0 , 1 \}$ to guess the labels. This classifier can be represented by a (scoring function $r$ , threshold $t$ ) tuple, where $r : \mathbb { R } ^ { d } \mathbb { R }$ maps an example’s cut layer gradient to a real-valued score and the threshold $t \in \mathbb { R }$ determines a cut-off so that $\bar { q ( g ) } = 1$ if $\overset { \cdot } { r } ( g ) > t$ and $q ( g ) = 0$ if $r ( g ) \leq t$ . Moving forward, we use this tuple representation to describe adversarial non-label party classifiers.
53
+
54
+ Privacy loss quantification. As we consider binary classification, a natural metric to quantify the performance of an adverary’s scoring function $r$ is the AUC of its ROC curve. Denote the unperturbed class-conditional distributions of the cut-layer gradients by $P ^ { ( 1 ) }$ and $P ^ { ( 0 ) }$ for the positive and negative class, respectively. The ROC curve of a scoring function $r$ is a parametric curve $t \mapsto \mathsf { \bar { ( F P R } } _ { r } ( t ) , \mathsf { T P R } _ { r } ( t ) ) \in \mathsf { [ 0 , 1 ] } ^ { 2 }$ which maps a threshold value $t \in \mathbb { R }$ to the corresponding (False Positive Rate, True Positive Rate) tuple of the classifier represented by $( r , t )$ , with $\mathrm { F P R } _ { r } ( t ) : = P ^ { ( 0 ) } ( \{ g : r ( g ) > t \} )$ and $\mathrm { T P R } _ { r } ( t ) : = P ^ { ( 1 ) } ( \{ g : r ( g ) > t \} )$ . The AUC of the ROC curve of a scoring function $r$ (denote by $\operatorname { A U C } ( r )$ ) can be expressed as an integral:
55
+
56
+ ![](images/abe502d96660f12b083760acfe08c4529f2a3f7382efbc95190a0a239c34db31.jpg)
57
+ Figure 2: Distributions of quantities discussed in Observations 1-4 after the first 100, 200, 300, 400, 500 steps of stochastic gradient descent training of the WDL model on Criteo (see experiments).
58
+
59
+ $$
60
+ \begin{array} { r } { \begin{array} { r l } { \mathrm { A U C } ( r ) = \int _ { \infty } ^ { - \infty } \mathrm { T P R } _ { r } ( t ) ~ d \mathrm { F P R } _ { r } ( t ) } & { \in [ 0 , 1 ] } \end{array} } \end{array}
61
+ $$
62
+
63
+ (Leak AUC)
64
+
65
+ (more details on this expression see Appendix A.1.) We use this value as the privacy loss quantification metric for a specific adversary scoring function $r$ and refer to it as the leak AUC. This metric summarizes the predictive performance of all classifiers that can be constructed through all threshold values $t$ and removes the need to tune this classifier-specific hyperparameter. The leak AUC being close to 1 implies that the corresponding scoring function $r$ can very accurately recover the private label, whereas a value of around 0.5 means $r$ is non-informative in predicting the labels. In practice, during batch training, the leak AUC of $r$ can be estimated at every gradient update iteration using the minibatch of cut-layer gradients together with their labels.
66
+
67
+ Side information. Among all the scoring functions within our threat model, it is conceivable that only some would recover the hidden labels accurately. Picking such effective ones would require the non-label party to have population-level side information specifically regarding the properties of (and distinction between) the positive and negative class’s cut-layer gradient distributions. Since we allow the adversary to pick any specific (measurable) scoring function, we implicitly allow for such population-level side information for the adversary. However, we assume the non-label party has no example-level side information that is different example by example. Thus we also don’t use local DP for privacy quantification (detailed explanation in Appendix A.8). Next we provide two example scoring functions which use population-level side-information to effectively recover the label.
68
+
69
+ # 3.3 PRACTICAL ATTACK METHODS
70
+
71
+ Attack 1: Norm-based scoring function. Note that $\| g \| _ { 2 } = | \widetilde p _ { 1 } - y | \cdot \| \nabla _ { a } h ( a ) | _ { a = \pmb { f } ( X ) } \| _ { 2 }$ . We make the following observations for $| \widetilde { p } _ { 1 } - y |$ and $\| \nabla _ { a } h ( a ) | _ { a = f ( X ) } \| _ { 2 }$ , which hold true for a wide range of real-world learning problems.
72
+
73
+ • Observation 1: Throughout training, the model tends to be less confident about a positive example being positive than a negative example being negative. In other words, the confidence gap of a positive example $1 - \widetilde { p } _ { 1 } = \left| \widetilde { p } _ { 1 } - y \right|$ (when $y = 1$ ) is typically larger than the confidence gap of a negative example $1 - \widetilde { p } _ { 0 } = \widetilde { p } _ { 1 } = | \widetilde { p } _ { 1 } - y |$ (when $y = 0$ ) (see Figure 2(a)). This observation e e eis particularly true for problems like advertising conversion prediction and disease prediction, where there is inherently more ambiguity for the positive class than the negative. For example, in advertising, uninterested users of a product will never click on its ad and convert, but those interested, even after clicking, might make the purchase only a fraction of the time depending on time/money constraints. (See A.2 for such an ambiguity even for a class-balanced setting.)
74
+
75
+ • Observation 2: Throughout training, the norm of the gradient vector $\| \nabla _ { z } h ( z ) \vert _ { z = f ( X ) } \| _ { 2 }$ is on the same order of magnitude (has similar distribution) for both the positive and negative examples (Figure 2(b)). This is natural because $\nabla _ { a } h ( a ) | _ { a = f ( X ) }$ is not a function of $y$ .
76
+
77
+ As a consequence of Observation 1 and 2, the gradient norm $\| g \| _ { 2 }$ of the positive instances are generally larger than that of the negative ones (Figure 2(c)). Thus, the scoring function $r _ { n } ( g ) =$ $\| g \| _ { 2 }$ is a strong predictor of the unseen label $y$ . We name the privacy loss (leak AUC) measured against the attack $r _ { n }$ the norm leak AUC. In Figure 2(c), the norm leak AUCs are consistently above 0.9, signaling a high level of label leakage throughout training.
78
+
79
+ Attack 2: Direction-based scoring function. We now show that the direction of $g$ (in addition to its magnitude) can also leak the label. For a pair of examples, $( X _ { a } , y _ { a } ) , ( X _ { b } , y _ { b } )$ , let their respective predicted positive class probability be $\widetilde { p } _ { 1 , a } , \widetilde { p } _ { 1 , b }$ and their communicated gradients be $g _ { a } , \ g _ { b }$ . Let co $\mathbf { \tau } _ { \mathrm { 3 } } : \mathbb { R } ^ { d } \times \mathbf { \bar { R } } ^ { d } \mathbb { R }$ e e denote the cosine similarity function $\cos ( g _ { a } , g _ { b } ) = g _ { a } ^ { T } g _ { b } \bar { / } ( \| g _ { a } \| _ { 2 } \| g _ { b } \| _ { 2 } )$ . It is easy to see that $\begin{array} { r } { \cos \bigl ( g _ { a } , g _ { b } \bigr ) = \mathrm { s g n } \bigl ( \widetilde { p } _ { 1 , a } - y _ { a } \bigr ) \cdot \mathrm { s g n } \bigl ( \widetilde { p } _ { 1 , a } - y _ { b } \bigr ) \cdot \cos \bigl ( \nabla _ { z } h ( z ) \bigr | _ { z = f ( X _ { a } ) } , \nabla _ { z } h ( z ) \bigr | _ { z = f ( X _ { b } ) } \bigr ) } \end{array}$ , where $\operatorname { s g n } ( \mathbf { x } )$ e e is the sign function which returns 1 if $x \geq 0$ , and $- 1$ if $x < 0$ . We highlight two additional observations that can allow us to use cosine similarity to recover the label.
80
+
81
+ • Observation 3: When the examples $a , b$ are of different classes, the term $\mathrm { s g n } ( \widetilde { p } _ { 1 , a } - y _ { a } ) ~ .$ · $\operatorname { s g n } ( \widetilde { p } _ { 1 , a } - y _ { b } ) = - 1$ is negative. On the other hand, when examples $a , b$ eare of the same eclass (both positive/both negative), this product will have a value of 1 and thus be positive. • Observation 4: Throughout training, for any two examples $a , b$ , their gradients of the function $h$ always form an acute angle, i.e. $\cos ( \nabla _ { z } h ( z ) | _ { z = \pmb { f } ( X _ { a } ) } , \nabla _ { z } h ( z ) | _ { z = \pmb { f } ( X _ { b } ) } ) > 0$ (Figure 2(d)). For neural networks that use monotonically increasing activation functions (such as ReLU, sigmoid, tanh), this is caused by the fact that the gradients of these activation functions with respect to its inputs are coordinatewise nonnegative and thus always lie in the first closed hyperorthant.
82
+
83
+ Since $\cos ( g _ { a } , g _ { b } )$ is the product of the terms from Observation 3 and 4, we see that for a given example, all the examples that are of the same class result in a positive cosine similarity, while all opposite class examples result in a negative cosine similarity. If the problem is class-imbalanced and the non-label party knows there are fewer positive examples than negative ones, it can thus determine the label of each example: the class is negative if more than half of the examples result in positive cosine similarity; otherwise it is positive. For many practical applications, the non-label party may reasonably guess which class has more examples in the dataset a priori without ever seeing any data—for example, in disease prediction, the percentage of the entire population having a certain disease is almost always much lower than $50 \%$ ; in online advertising conversion prediction, the conversion rate (fraction of positive examples) is rarely higher than $30 \%$ . Note that the non-label party doesn’t need knowledge of the exact sample proportion of each class for this method to work.
84
+
85
+ To simplify this attack for evaluation, we consider an even worse oracle scenario where the non-label party knows the clean gradient of one positive example $g _ { + }$ . Unlike the aforementioned practical majority counting attack which needs to first figure out the direction of one positive gradient, this oracle scenario assumes the non-label party is directly given this information. Thus, any protection method capable of defending this oracle attack would also protect against the more practical one. With $g _ { + }$ given, the direction-based scoring function $r _ { d }$ is simply $r _ { d } ( g ) = \cos ( g , g _ { + } )$ . We name the privacy loss (leak AUC) against this oracle attack $r _ { d }$ the cosine leak $A U C$ . In practice, we randomly choose a positive class clean gradient from each batch as $g _ { + }$ for evaluation. For iterations in Figure 2(e), the cosine leak AUC all have the highest value of 1 (complete label leakage).
86
+
87
+ # 4 LABEL LEAKAGE PROTECTION METHODS
88
+
89
+ In this section, we first introduce a heuristic random perturbation approach designed to prevent the practical attacks identified in Section 3.3. We then propose a theoretically justified method that aims to protect against the entire class of scoring functions considered in our threat model (Section 3.2).
90
+
91
+ # 4.1 A HEURISTIC PROTECTION APPROACH
92
+
93
+ Random perturbation and the isotropic Gaussian baseline. To protect against label leakage, the label party should ideally communicate essential information about the gradient without communicating its actual value. Random perturbation methods generally aim to achieve this goal. One obvious consideration for random perturbation is to keep the perturbed gradients unbiased. In other words, suppose $\tilde { g }$ is the perturbed version of an example’s true gradient $g$ , then we want $\mathbb { E } [ \tilde { g } \mid g ] = g$ . By chain rule and linearity of expectation, this ensures the computed gradients of the non-label party’s parameters $f$ will also be unbiased, a desirable property for stochastic optimization. Among unbiased perturbation methods, a simple approach is to add iid isotropic Gaussian noise to every gradient to mix the positive and negative gradient distribution before sending to the non-label party.
94
+
95
+ Although isotropic Gaussian noise is a valid option, it may not be optimal because 1) the gradients are vectors but not scalars, so the structure of the noise covariance matrix matters. Isotropic noise might neglect the direction information; 2) due to the asymmetry of the positive and negative gradient distribution, the label party could add noise with different distributions to each class’s gradients.
96
+
97
+ Norm-alignment heuristic. We now introduce an improved heuristic approach of adding zeromean Gaussian noise with non-isotropic and example-dependent covariance. [Magnitude choice] As we have seen that $\| g \| _ { 2 }$ can be different for positive and negative examples and thus leak label information, this heuristic first aims to make the norm of each perturbed gradient indistinguishable from one another. Specifically, we want to match the expected squared 2-norm of every perturbed gradient in a mini-batch to the largest squared 2-norm in this batch (denote by $\| g _ { \operatorname* { m a x } } \| _ { 2 } ^ { 2 } )$ . [Direction choice] In addition, as we have seen empirically from Figure 2(e), the positive and negative gradients lie close to a one-dimensional line in $\mathbb { R } ^ { d }$ , with positive examples pointing in one direction and negative examples in the other. Thus we consider only adding noise (roughly speaking) along “this line”. More concretely, for a gradient $g _ { j }$ in the batch, we add a zero-mean Gaussian noise vector $\eta _ { j }$ supported only on the one-dimensional space along the line of $g _ { j }$ . In other words, the noise’s covariance is the rank-1 matrix $\mathrm { C o v } [ \eta _ { j } ] = \sigma _ { j } ^ { 2 } g _ { j } g _ { j } ^ { T }$ . To calculate $\sigma _ { j }$ , we aim to match $\mathbb { E } [ \| g _ { j } + \eta _ { j } \| _ { 2 } ^ { 2 } ] =$ $\| g _ { \operatorname* { m a x } } \| _ { 2 } ^ { 2 }$ . A simple calculation gives $\sigma _ { j } = \sqrt { \| g _ { \mathrm { { m a x } } } \| _ { 2 } ^ { 2 } / \| g _ { j } \| _ { 2 } ^ { 2 } - 1 }$ . Since we align to the maximum norm, we name this heuristic protection method max norm. The advantage of max norm is that it has no parameter to tune. Unfortunately, it does not have a strong theoretical motivation, cannot flexibly trade-off between model utility and privacy, and may be broken by some unknown attacks.
98
+
99
+ # 4.2 OPTIMIZED PERTURBATION METHOD: MA R V E L L
100
+
101
+ Motivated by the above issues of max norm, we next study how to achieve a more principled trade-off between model performance (utility) and label protection (privacy). To do so, we directly minimize the worst-case adversarial scoring function’s leak AUC under a utility constraint. We name this protection method Marvell (optiMized perturbAtion to pReVEnt Label Leakage).
102
+
103
+ Noise perturbation structure. Due to the distribution difference between the positive and negative class’s cut layer gradients, we consider having the label party additively perturb the randomly sampled positive $\overset { \cdot } { g } ^ { ( 1 ) }$ and negative $g ^ { ( 0 ) }$ gradients with independent zero-mean random noise vectors $\eta ^ { ( 1 ) }$ and $\eta ^ { ( 0 ) }$ with possibly different distributions (denoted by $D ^ { ( 1 ) }$ and ${ \cal D } ^ { ( 0 ) }$ ). We use $\widetilde { P } ^ { ( 1 ) }$ and $\widetilde { P } ^ { ( 0 ) }$ to denote the induced perturbed positive and negative gradient distributions. Our goal is to find the optimal noise distributions $D ^ { ( 1 ) }$ and ${ \cal D } ^ { ( 0 ) }$ by optimizing our privacy objective described below.
104
+
105
+ Privacy protection optimization objective. As the adversarial non-label party in our threat model is allowed to use any measurable scoring function $r$ for label recovery, we aim to protect against all such scoring functions by minimizing the privacy loss of the worst case scoring function measured through our leak AUC metric. Formally, our optimization objective is $\begin{array} { r } { \operatorname* { m i n } _ { D ^ { ( 1 ) } , D ^ { ( 0 ) } } \operatorname* { m a x } _ { r } \mathrm { A U C } ( r ) } \end{array}$ . Here to compute $\operatorname { A U C } ( r )$ , the $\mathrm { F P R } _ { r } ( t )$ and $\mathrm { T P R } _ { r } ( t )$ needs to be computed using the perturbed distributions $\widetilde { P } ^ { ( 1 ) }$ and $\widetilde { P } ^ { ( 0 ) }$ instead of the unperturbed $P ^ { ( 1 ) }$ and $P ^ { ( 0 ) }$ (Section 3.2). Since AUC is difficult to directly optimize, we consider optimizing an upper bound through the following theorem:
106
+
107
+ Theorem 1. For $0 \leq \epsilon < 4$ and any perturbed gradient distributions $\widetilde { P } ^ { ( 1 ) }$ and $\widetilde { P } ^ { ( 0 ) }$ that are absolutely continuous with respect to each other,
108
+
109
+ $$
110
+ \begin{array} { r } { { \bf K L } ( \widetilde { P } ^ { ( 1 ) } \parallel \widetilde { P } ^ { ( 0 ) } ) + { \bf K L } ( \widetilde { P } ^ { ( 0 ) } \parallel \widetilde { P } ^ { ( 1 ) } ) \le \epsilon \quad i m p l i e s \quad \operatorname* { m a x } _ { r } { \bf A U C } ( r ) \le \frac { 1 } { 2 } + \frac { \sqrt { \epsilon } } { 2 } - \frac { \epsilon } { 8 } . } \end{array}
111
+ $$
112
+
113
+ From Theorem 1 (proof in Appendix A.3), we see that as long as the sum KL divergence is below 4,√ the smaller sumKL is, the smaller $\operatorname* { m a x } _ { r } \mathbf { A U C } ( r )$ is. $( 1 / 2 + \overline { { \sqrt { \epsilon } } } / 2 - \epsilon / 8 $ decreases as $\epsilon$ decreases.) Thus we can instead minimize the sum KL divergence between the perturbed gradient distributions:
114
+
115
+ $$
116
+ \begin{array} { r } { \operatorname { s u m K L } ^ { * } : = \operatorname* { m i n } _ { D ^ { ( 1 ) } , D ^ { ( 0 ) } } \operatorname { K L } ( \widetilde { P } ^ { ( 1 ) } \parallel \widetilde { P } ^ { ( 0 ) } ) + \operatorname { K L } ( \widetilde { P } ^ { ( 0 ) } \parallel \widetilde { P } ^ { ( 1 ) } ) . } \end{array}
117
+ $$
118
+
119
+ Utility constraint. In an extreme case, we could add infinite noise to both the negative and positive gradients. This would minimize (1) optimally to 0 and make the worst case leak AUC 0.5, which is equivalent to a random guess. However, stochastic gradient descent cannot converge under infinitely large noise, so it is necessary to control the variance of the added noise. We thus introduce the noise power constraint: $p \cdot \mathrm { t r } ( \mathrm { C o v } [ \eta ^ { ( 1 ) } ] ) + ( 1 - p ) \cdot \mathrm { t r } ( \mathrm { C o v } [ \eta ^ { ( 0 ) } ] ) \le ~ P$ , where $p$ is the fraction of positive examples (already known to the label party); $\mathrm { t r } ( \mathrm { C o v } [ \eta ^ { ( i ) } ] )$ denotes the trace of the covariance matrix of the random noise $\eta ^ { ( i ) }$ ; and the upper bound $P$ is a tunable hyperparameter to control the level of noise: larger $P$ would achieve a lower sumKL and thus lower worst-case leak AUC and better privacy; however, it would also add more noise to the gradients, leading to slower optimization convergence and possibly worse model utility. We weight each class’s noise level $\mathrm { t r } ( \mathrm { C o v } [ \eta ^ { ( i ) } ] )$ by its example proportion $\dot { p }$ or $1 - p )$ since, from an optimization perspective, we want to equally control every training example’s gradient noise. The constrained optimization problem becomes:
120
+
121
+ $$
122
+ \operatorname* { m i n } _ { D ^ { ( 1 ) } , D ^ { ( 0 ) } } \mathrm { K L } ( \widetilde P ^ { ( 1 ) } \parallel \widetilde P ^ { ( 0 ) } ) + \mathrm { K L } ( \widetilde P ^ { ( 0 ) } \parallel \widetilde P ^ { ( 1 ) } ) \mathrm { s . t . } p \cdot \mathrm { t r } ( \mathrm { C o v } [ \eta ^ { ( 1 ) } ] ) + ( 1 - p ) \cdot \mathrm { t r } ( \mathrm { C o v } [ \eta ^ { ( 0 ) } ] ) \le P .
123
+ $$
124
+
125
+ Optimizing the objective in practice. To solve the optimization problem we first introduce some modelling assumptions. We assume that the unperturbed gradient of each class follows a Gaussian distribution: $g ^ { ( 1 ) } \stackrel { \cdot } { \sim } \mathcal { N } ( \bar { g } ^ { ( 1 ) } , v I _ { d \times d } )$ and $g ^ { ( 0 ) } \sim \dot { \mathcal { N } } ( \bar { g } ^ { ( 0 ) } , u I _ { d \times d } )$ . Despite this being an approximation, as we see later in Section 5, it can achieve strong protection quality against our identified attacks. In addition, it makes the optimization easier (see below) and provides us with insight on the optimal noise structure. We also search for perturbation distributions that are Gaussian: $D ^ { \top } \ d _ { 1 } ) = \mathcal { N } ( 0 , \dot { \Sigma _ { 1 } } )$ and $D ^ { ( 0 ) } = \mathcal { N } ( 0 , \Sigma _ { 0 } )$ with commuting covariance matrices: $\Sigma _ { 1 } \Sigma _ { 0 } = \Sigma _ { 0 } \Sigma _ { 1 }$ . The commutative requirement slightly restricts our search space but also makes the optimization problem more tractable. Our goal is to solve for the optimal noise structure, i.e. the positive semidefinite covariance matrices $\Sigma _ { 0 }$ , $\Sigma _ { 1 }$ . Let $\Delta g : = \bar { g } ^ { ( 1 ) } - \bar { g } ^ { ( 0 ) }$ denote the difference between the positive and negative gradient’s mean vectors. We now have the following theorem (proof and interpretation in Appendix A.4):
126
+
127
+ Theorem 2. The optimal $\Sigma _ { 1 } ^ { * }$ and $\Sigma _ { 0 } ^ { * }$ to (2) with the above assumptions have the form:
128
+
129
+ $$
130
+ \Sigma _ { 1 } ^ { * } = \frac { \lambda _ { 1 } ^ { ( 1 ) * } - \lambda _ { 2 } ^ { ( 1 ) * } } { \| \Delta g \| _ { 2 } ^ { 2 } } ( \Delta g ) ( \Delta g ) ^ { \top } + \lambda _ { 2 } ^ { ( 1 ) * } I _ { d } , \quad \Sigma _ { 0 } ^ { * } = \frac { \lambda _ { 1 } ^ { ( 0 ) * } - \dot { \lambda } _ { 2 } ^ { ( 0 ) * } } { \| \Delta g \| _ { 2 } ^ { 2 } } ( \Delta g ) ( \Delta g ) ^ { \top } + \lambda _ { 2 } ^ { ( 0 ) * } I _ { d } ,
131
+ $$
132
+
133
+ $( \lambda _ { 1 } ^ { ( 0 ) * } , \lambda _ { 2 } ^ { ( 0 ) * } , \lambda _ { 1 } ^ { ( 1 ) * } , \lambda _ { 2 } ^ { ( 1 ) * } )$ is the solution to the following 4-variable optimization problem:
134
+
135
+ $$
136
+ \mathop { \operatorname* { m i n } } _ { \lambda _ { 1 } ^ { ( 0 ) } , \lambda _ { 1 } ^ { ( 0 ) } , \lambda _ { 2 } ^ { ( 1 ) } } ( d - 1 ) \frac { \lambda _ { 2 } ^ { ( 0 ) } + u } { \lambda _ { 2 } ^ { ( 1 ) } + v } + ( d - 1 ) \frac { \lambda _ { 2 } ^ { ( 1 ) } + v } { \lambda _ { 2 } ^ { ( 0 ) } + u } + \frac { \lambda _ { 1 } ^ { ( 0 ) } + u + \| \Delta g \| _ { 2 } ^ { 2 } } { \lambda _ { 1 } ^ { ( 1 ) } + v } + \frac { \lambda _ { 1 } ^ { ( 1 ) } + v + \| \Delta g \| _ { 2 } ^ { 2 } } { \lambda _ { 1 } ^ { ( 0 ) } + u }
137
+ $$
138
+
139
+ $$
140
+ \begin{array} { r l } { s . t . \quad p \lambda _ { 1 } ^ { ( 1 ) } + p ( d - 1 ) \lambda _ { 2 } ^ { ( 1 ) } + ( 1 - p ) \lambda _ { 1 } ^ { ( 0 ) } + ( 1 - p ) ( d - 1 ) \lambda _ { 2 } ^ { ( 0 ) } \leq { \cal P } , } & \\ { - \lambda _ { 1 } ^ { ( 1 ) } \leq 0 , \quad - \lambda _ { 1 } ^ { ( 0 ) } \leq 0 , \quad - \lambda _ { 2 } ^ { ( 1 ) } \leq 0 , \quad - \lambda _ { 2 } ^ { ( 0 ) } \leq 0 , \quad \lambda _ { 2 } ^ { ( 1 ) } - \lambda _ { 1 } ^ { ( 1 ) } \leq 0 , \quad \lambda _ { 2 } ^ { ( 0 ) } - \lambda _ { 1 } ^ { ( 0 ) } \leq 0 } \end{array}
141
+ $$
142
+
143
+ Additional details of Marvell. By Theorem 2, our optimization problem over two positive semidefinite matrices is reduced to a much simpler 4-variable optimization problem. We include a detailed description of how the constants in the problem are estimated in practice and what solver we use in a full description of the Marvell algorithm in Appendix A.5. Beyond optimization details, it is worth noting how to set the power constraint hyperparameter $P$ in Equation 2 in practice. As directly choosing $P$ requires knowledge of the scale of the gradients in the specific application and the scale could also shrink as the optimization converges, we instead express $P = s \| \Delta g \| _ { 2 } ^ { 2 }$ , and tune for a fixed hyperparameter $s > 0$ . This alleviates the need to know the scale of the gradients in advance, and the resulting value of $P$ can also dynamically change throughout training as the distance between the two gradient distributions’ mean $\| \Delta g \| _ { 2 }$ changes.
144
+
145
+ # 5 EXPERIMENTS
146
+
147
+ In this section, we first describe our experiment setup and then demonstrate the label protection quality of Marvell as well as its privacy-utility trade-off relative to baseline approaches.
148
+
149
+ Empirical Setup. We use three real-world binary classification datasets for evaluation: Criteo and Avazu, two online advertising prediction datasets with millions of examples; and ISIC, a healthcare image dataset for skin cancer prediction. All three datasets exhibit severe label leakage problem without protection. (see Appendix A.6.1 on dataset and preprocessing details). We defer similar results on Avazu to Appendix A.7 and focus on Criteo and ISIC in this section. For Criteo, we train a Wide&Deep model (Cheng et al., 2016) where the non-label party owns the embedding layers for input features and the first three 128-unit ReLU activated MLP layers (first half of the deep part) while the label party owns the remaining layers of the deep part and the entire wide part of the model3. For ISIC, we train a model with 6 convolutional layers each with 64 channels followed by a 64-unit ReLU MLP layer, and the cut layer is after the fourth convolutional layer. In this case, an example’s cut layer feature $f ( X )$ and gradient $g$ are both in $\mathbb { R } ^ { 5 \times 5 \times 6 4 }$ . We treat such tensors as vectors in $\mathbb { R } ^ { 1 6 0 0 }$ to fit into our analysis framework (for additional model architecture and training details see Appendix A.6.2, A.6.3).
150
+
151
+ ![](images/da7562e01beb63c35fea76cbea790a0088e2c1811a01fbe1e54c87a5bcc7c358.jpg)
152
+ Figure 3: Norm and cosine leak AUC (computed every batch) at the cut layer and at the first layer under no protection vs. Marvell with different scale hyperparameter $s$ throughout the ISIC training.
153
+
154
+ # 5.1 LABEL LEAKAGE AND MA R V E L L’S STRONG AND FLEXIBLE PROTECTION
155
+
156
+ We first evaluate the protection quality of Marvell against the norm and cosine attacks discussed in Section 3.3. We also compare against the leakage metrics when no protection is applied (no noise). As the results across the three datasets are highly similar, we use ISIC as an example (other datasets see Appendix A.7.1). We see in Figure 3(a)(b) that unlike no noise where the label information is completely leaked (leak $\mathbf { A U C } \approx 1$ ) throughout training, Marvell achieves a flexible degree of protection (by varying $s$ ) against both the norm 2(a) and direction attacks 2(b) on the cut layer gradients and has strong protection (leak AUC $\approx { \bf 0 . 5 }$ ) at $s = 4 . 0$ . Additionally, it is natural to ask whether the gradients of layers before the cut layer (on the non-label party side) can also leak the labels as the non-label party keeps back propagating towards the first layer. In Figure 3(c)(d), we compute the leak AUC values when using the non-label party’s first layer activation gradient as inputs to the scoring functions to predict $y$ . Without protection, the first layer gradient still leaks the label very consistently. In constrast, Marvell still achieves strong privacy protection at the first layer $s = 4 . 0$ ) despite the protection being analyzed at the cut layer.
157
+
158
+ # 5.2 PRIVACY-UTILITY TRADE-OFF COMPARISON
159
+
160
+ After showing Marvell can provide strong privacy protection against our identified attacks, we now see how well it can preserve utility by comparing its privacy-utility tradeoff against other protection baselines: no noise, isotropic Gaussian (iso), and our proposed heuristic max norm. Similar to how we allow Marvell to use a power constraint to depend on the current iteration’s gradient distribution through $P = s \| \Delta g \| _ { 2 } ^ { 2 }$ , we also allow iso to have such type of dependence— specifically, we add $\eta \sim \mathcal { N } ( \mathbf { 0 } , ( t / d ) \cdot \| g _ { \operatorname* { m a x } } \| _ { 2 } ^ { 2 } I _ { d \times d } )$ to every gradient in a batch with $t$ a tunable privacy hyperparameter to be fixed throughout training. To trace out the complete tradeoff curve for Marvell and iso, we conduct more than 20 training runs for each protection method with a different value of privacy hyperparameter $s$ for Marvell, $t$ for iso) in each run on every dataset. (Note that no noise and max norm do not have privacy hyperparameters.)
161
+
162
+ We present the tradeoffs between privacy (measured through norm and cosine leak AUC at cut layer/first layer) and utility (measured using test loss and test AUC) in Figure 4. To summarize the leak AUC over a given training run, we pick the $9 5 \%$ quantile over the batch-computed leak AUCs throughout all training iterations. This quantile is chosen instead of the mean because we want to measure the most-leaked iteration’s privacy leakage (highest leak AUC across iterations) to ensure the labels are not leaked at any points during training. $9 5 \%$ quantile is chosen instead of the max $( 1 0 0 \% )$ ) as we want this privacy leak estimate to be robust against randomness of the training process.
163
+
164
+ Privacy-Utility Tradeoff comparison results. In measuring the privacy-utility tradeoff, we aim to find a method that consistently achieves a lower leak AUC (better privacy) for the same utility value.
165
+
166
+ • [Marvell vs iso] As shown in Figure 4, Marvell almost always achieves a better tradeoff than iso against both of our proposed attacks at both the cut layer and the first layer on both the ISIC and Criteo datasets. It is important to note that although the utility constraint is in terms of training loss optimization, Marvell’s better tradeoff still translates to the generalization performance when the utility is measured through test loss or test AUC. Additionally, despite achieving reasonable (though still worse than Marvell) privacy-utility tradeoff against the norm-based attack, iso performs much worse against the direction-based attack: on ISIC, even after applying a significant amount of isotropic noise (with $t > 2 0$ ), iso’s cosine leak AUC is still higher than 0.9 at the cut layer (Figure 4(b,f)). In contrast, Marvell is effective against this direction-based attack with a much lower cosine leak AUC $\approx 0 . 6$ .
167
+
168
+ ![](images/48b9f068b52ed0c35fe5504d6d05601a466864114d83bc64d2db5cda6f53531e.jpg)
169
+ Figure 4: Privacy (norm & cosine leak AUC) vs Utility (test loss & test AUC) trade-off of protection methods (Marvell, iso, no noise, max norm) at the cut and first layer on ISIC and Criteo.
170
+
171
+ • [max norm heuristic] Beyond Marvell, we see that our heuristic approach max norm can match and sometimes achieve even lower (Figure 4(a,f,i)) leak AUC value than Marvell at the same utility level. We believe this specifically results from our norm and direction consideration when designing this heuristic. However, without a tunable hyperparameter, max norm cannot tradeoff between privacy and utility. Additionally, unlike Marvell which is designed to protect against the entire class of adversarial scoring functions, max norm might still fail to protect against other future attack methods beyond those considered here.
172
+
173
+ In summary, our principled method Marvell significantly outperforms the isotropic Gaussian baseline, and our proposed max norm heuristic can also work particularly well against the norm- and direction-based attacks which we identified in Section 3.3.
174
+
175
+ # 6 CONCLUSION
176
+
177
+ In this paper, we formulate a label leakage threat model in the two-party split learning binary classification problem through a novel privacy loss quantification metric (leak AUC). Within this threat model, we provide two simple yet effective attack methods that can accurately uncover the private labels of the label party. To counter such attacks, we propose a heuristic random perturbation method max norm as well as a theoretically principled method Marvell which searches for the optimal noise distributions to protect against the worst-case adversaries in the threat model. We have conducted extensive experiments to demonstrate the effectiveness of Marvell and max norm over the isotropic Gaussian perturbation baseline iso.
178
+
179
+ Open questions and future work. Our work is the first we are aware of to identify, rigorously quantify, and protect against the threat of label leakage in split-learning, and opens up a number of worthy directions of future study. In particular, as the model parameters are updated every batch in our problem setup, the true gradient of an example and the gradient distribution would both change. An interesting question is whether the adversarial non-label party can remember the stale gradient of the same example from past updates (possibly separated by hundreds of updates steps) in order to recover the label information in the current iteration in a more complex threat model. It would also be interesting to build on our results to study whether there exist attack methods when the classification problem is multiclass instead of binary, and when the split learning scenario involves more than two parties with possibly more complicated training communication protocols (e.g., Vepakomma et al., 2018).
180
+
181
+ Ethics Statement. In our paper, we have identified a realistic threat of label leakage in the twoparty split learning binary classification problem. We aim to raise awareness about potential privacy issues in this problem domain, where many industrial applications have been deployed. Beyond making such threats clear, we have taken the first steps towards protection—we have proposed both heuristic and principled methods that can preserve label privacy. We hope our work will pave the way for future analyses that make the two-party split learning framework more effective and secure.
182
+
183
+ Reproducibility Statement. To make our paper reproducible, we provide:
184
+
185
+ • Proofs of our Theorem 1 and Theorem 2 in Appendix A.3,A.4;
186
+ • Detailed experiment description including 1) data preprocessing, 2) model architecture, 3) training algorithm and hyperparameters in Appendix A.6.
187
+ • Source code with running instructions (in README.md) at https://github.com/OscarcarLi/label-protection.
188
+
189
+ # REFERENCES
190
+
191
+ Martin Abadi, Andy Chu, Ian Goodfellow, H Brendan McMahan, Ilya Mironov, Kunal Talwar, and Li Zhang. Deep learning with differential privacy. In Proceedings of the 2016 ACM SIGSAC Conference on Computer and Communications Security, pp. 308–318, 2016.
192
+
193
+ Avazu. Avazu click-through rate prediction, 2015. URL https://www.kaggle.com/c/ avazu-ctr-prediction/data.
194
+
195
+ Keith Bonawitz, Vladimir Ivanov, Ben Kreuter, Antonio Marcedone, H Brendan McMahan, Sarvar Patel, Daniel Ramage, Aaron Segal, and Karn Seth. Practical secure aggregation for privacypreserving machine learning. In Proceedings of the 2017 ACM SIGSAC Conference on Computer and Communications Security, pp. 1175–1191, 2017.
196
+
197
+ Kamalika Chaudhuri and Daniel Hsu. Sample complexity bounds for differentially private learning. In Proceedings of the 24th Annual Conference on Learning Theory, pp. 155–186. JMLR Workshop and Conference Proceedings, 2011.
198
+
199
+ Heng-Tze Cheng, Levent Koc, Jeremiah Harmsen, Tal Shaked, Tushar Chandra, Hrishi Aradhye, Glen Anderson, Greg Corrado, Wei Chai, Mustafa Ispir, et al. Wide & deep learning for recommender systems. In Proceedings of the 1st workshop on deep learning for recommender systems, pp. 7–10, 2016.
200
+
201
+ Albert Cheu, Adam Smith, Jonathan Ullman, David Zeber, and Maxim Zhilyaev. Distributed differential privacy via shuffling. In Annual International Conference on the Theory and Applications of Cryptographic Techniques, pp. 375–403. Springer, 2019.
202
+
203
+ Criteo. Criteo display advertising challenge, 2014. URL https://www.kaggle.com/c/ criteo-display-ad-challenge/data.
204
+
205
+ Cynthia Dwork. Differential privacy. In Michele Bugliesi, Bart Preneel, Vladimiro Sassone, and Ingo Wegener (eds.), Automata, Languages and Programming, pp. 1–12, Berlin, Heidelberg, 2006. Springer Berlin Heidelberg. ISBN 978-3-540-35908-1.
206
+
207
+ Cynthia Dwork, Aaron Roth, et al. The algorithmic foundations of differential privacy. Foundations and Trends in Theoretical Computer Science, 9(3-4):211–407, 2014.
208
+
209
+ Ulfar Erlingsson, Vitaly Feldman, Ilya Mironov, Ananth Raghunathan, Kunal Talwar, and ´ Abhradeep Thakurta. Amplification by shuffling: From local to central differential privacy via anonymity. In Proceedings of the Thirtieth Annual ACM-SIAM Symposium on Discrete Algorithms, pp. 2468–2479. SIAM, 2019.
210
+
211
+ Badih Ghazi, Noah Golowich, Ravi Kumar, Pasin Manurangsi, and Chiyuan Zhang. On deep learning with label differential privacy. arXiv preprint arXiv:2102.06062, 2021.
212
+
213
+ Otkrist Gupta and Ramesh Raskar. Distributed learning of deep neural network over multiple agents. Journal of Network and Computer Applications, 116:1–8, 2018.
214
+
215
+ ISIC. Siim-isic melanoma classification, 2020. URL https://www.kaggle.com/c/ siim-isic-melanoma-classification/data.
216
+ Vladimir Kolesnikov, Ranjit Kumaresan, Mike Rosulek, and Ni Trieu. Efficient batched oblivious prf with applications to private set intersection. In Proceedings of the 2016 ACM SIGSAC Conference on Computer and Communications Security, CCS ’16, pp. 818–829, 2016.
217
+ Brendan McMahan, Eider Moore, Daniel Ramage, Seth Hampson, and Blaise Aguera y Arcas. Communication-efficient learning of deep networks from decentralized data. In Artificial Intelligence and Statistics, pp. 1273–1282. PMLR, 2017.
218
+ H. Brendan McMahan, Daniel Ramage, Kunal Talwar, and Li Zhang. Learning differentially private recurrent language models. In International Conference on Learning Representations, 2018. URL https://openreview.net/forum?id=BJ0hF1Z0b.
219
+ Benny Pinkas, Thomas Schneider, and Michael Zohner. Scalable private set intersection based on ot extension. ACM Transactions on Privacy and Security (TOPS), 21(2):1–35, 2018.
220
+ Pramod Subramanyan, Rohit Sinha, Ilia Lebedev, Srinivas Devadas, and Sanjit A Seshia. A formal foundation for secure remote execution of enclaves. In Proceedings of the 2017 ACM SIGSAC Conference on Computer and Communications Security, pp. 2435–2450, 2017.
221
+ Praneeth Vepakomma, Otkrist Gupta, Tristan Swedish, and Ramesh Raskar. Split learning for health: Distributed deep learning without sharing raw patient data. arXiv preprint arXiv:1812.00564, 2018.
222
+ Praneeth Vepakomma, Otkrist Gupta, Abhimanyu Dubey, and Ramesh Raskar. Reducing leakage in distributed deep learning for sensitive health data. arXiv preprint arXiv:1812.00564, 2019.
223
+ Qiang Yang, Yang Liu, Tianjian Chen, and Yongxin Tong. Federated machine learning: Concept and applications. ACM Transactions on Intelligent Systems and Technology (TIST), 10(2):1–19, 2019.
224
+ Bo Zhao, Konda Reddy Mopuri, and Hakan Bilen. idlg: Improved deep leakage from gradients. arXiv preprint arXiv:2001.02610, 2020.
225
+ Ligeng Zhu, Zhijian Liu, and Song Han. Deep leakage from gradients. In Advances in Neural Information Processing Systems, pp. 14774–14784, 2019.
226
+
227
+ # A APPENDIX
228
+
229
+ # Appendix Outline
230
+
231
+ A.1 Expressing $\operatorname { A U C } ( r )$ as an integral
232
+ A.2 Toy Class-balanced Example of Positive Example Prediction Lacking Confidence
233
+ A.3 Proof of Theorem 1
234
+ A.4 Proof and Interpretation of Theorem 2
235
+ A.5 Marvell Algorithm Description A.5.1 Marvell Time Complexity A.5.2 Marvell Empirical Run Time
236
+ A.6 Data Setup and Experimental Details A.6.1 Dataset Preprocessing A.6.2 Model Architecture Details A.6.3 Model Training Details
237
+ A.7 Complete Experimental Results A.7.1 AUC Progression for Avazu and Criteo A.7.2 Complete Privacy-Utility Tradeoffs A.7.3 Impact of Activation Gradients’ Layer Location on the Corresponding Leak AUC
238
+ A.8 Reasons why we don’t use local DP in our setup
239
+
240
+ A.1 EXPRESSING $\operatorname { A U C } ( r )$ AS AN INTEGRAL
241
+
242
+ Recall that the ROC curve of a scoring function $r : \mathbb { R } ^ { d } \mathbb { R }$ is a parametric curve $c _ { r } : \mathbb { R } [ 0 , 1 ] ^ { 2 }$ such that $c _ { r } ( t ) = ( \mathrm { F P R } _ { r } ( t ) , \mathrm { T P R } _ { r } ( t ) )$ , with
243
+
244
+ $$
245
+ \begin{array} { r l } & { \mathrm { F P R } _ { r } : \mathbb { R } [ 0 , 1 ] , \mathrm { s u c h t h a t } \mathrm { F P R } _ { r } ( t ) : = P ^ { ( 0 ) } ( \{ g \in \mathbb { R } ^ { d } : r ( g ) > t \} ) } \\ & { \mathrm { T P R } _ { r } : \mathbb { R } [ 0 , 1 ] , \mathrm { s u c h t h a t } \mathrm { T P R } _ { r } ( t ) : = P ^ { ( 1 ) } ( \{ g \in \mathbb { R } ^ { d } : r ( g ) > t \} ) . } \end{array}
246
+ $$
247
+
248
+ We notice that $\mathrm { F P R } _ { r }$ and $\mathrm { T P R } _ { r }$ are both monotonically decreasing functions in $t$ with
249
+
250
+ $$
251
+ \begin{array} { r l r } & { \underset { t - \infty } { \operatorname* { l i m } } \mathrm { F P R } _ { r } ( t ) = 1 , \ \underset { t \infty } { \operatorname* { l i m } } \mathrm { F P R } _ { r } ( t ) = 0 } & \\ & { \underset { t - \infty } { \operatorname* { l i m } } \mathrm { T P R } _ { r } ( t ) = 1 , \ \underset { t \infty } { \operatorname* { l i m } } \mathrm { T P R } _ { r } ( t ) = 0 . } & \end{array}
252
+ $$
253
+
254
+ However, $\mathrm { F P R } _ { r }$ and $\mathrm { T P R } _ { r }$ does not need to be differentiable everywhere with respect to $t$ . Thus we cannot simply express the area under the curve using $\begin{array} { r } { \int _ { \infty } ^ { - \infty } \mathrm { T P R } _ { r } ( t ) \mathrm { F P R } _ { r } ^ { \prime } ( t ) d t } \end{array}$ . On the other hand, because both $\mathrm { F P R } _ { r }$ and $\mathrm { T P R } _ { r }$ are functions of bounded variations, we can express the area under the parametric curve $c _ { r }$ through the Riemann-Stieltjes integral which involves integrating the function $\mathrm { T P R } _ { r }$ with respect to the function $\mathrm { F P R } _ { r }$ :
255
+
256
+ $$
257
+ \operatorname { A U C } ( r ) = \int _ { t = \infty } ^ { t = - \infty } \operatorname { T P R } _ { r } ( t ) d \operatorname { F P R } _ { r } ( t )
258
+ $$
259
+
260
+ Here the integration boundary is from $\infty$ to $- \infty$ in order to ensure the integral evaluates to a positive value.
261
+
262
+ # A.2 TOY CLASS-BALANCED EXAMPLE OF POSITIVE EXAMPLE PREDICTION LACKINGCONFIDENCE
263
+
264
+ As mentioned in Observation 1 of norm-based attack in Section 3.3, for many practical applications, there is inherently more ambiguity for the positive class than the negative class. To make this more concrete, let’s consider a simple toy example.
265
+
266
+ Suppose the binary classification problem is over the real line. Here, $50 \%$ of the data is positive and lies uniformly in the interval [0, 1]. On the other hand, the remaining negative data (the other $50 \%$ of the total data) is a mixture distribution: $10 \%$ of the negative data also lies uniformly in [0, 1], while the rest $90 \%$ of the negative data lies uniformly in [1, 2].
267
+
268
+ $$
269
+ \begin{array} { r l r l } & { p ( x \mid y = 1 ) = \mathbb { 1 } ( x \in [ 0 , 1 ] ) , } & & { \qquad p ( y = 1 ) = 0 . 5 . } \\ & { p ( x \mid y = 0 ) = 0 . 1 \cdot \mathbb { 1 } ( x \in [ 0 , 1 ] ) + 0 . 9 \cdot \mathbb { 1 } ( x \in [ 1 , 2 ] ) , } & & { \qquad p ( y = 0 ) = 0 . 5 . } \end{array}
270
+ $$
271
+
272
+ This setup mirrors our online advertising example where for all the users interested in the product (with feature $x \in [ 0 , 1 ]$ ), only a part of them would actually make the purchase after clicking on its advertisement.
273
+
274
+ In this case, the best possible probabilistic classifiers $C ^ { \mathrm { { o p t } } }$ that can be ever learned, by Bayes Rule, would predict any example in $[ 0 , 1 ]$ to be of the positive class with probability $\frac { 1 0 } { 1 1 }$ , while it would predict any example in [1, 2] to be of the negative class with probability 1:
275
+
276
+ $$
277
+ C ^ { \mathrm { o p t } } ( y = 1 \mid x ) = { \left\{ \begin{array} { l l } { { \frac { 1 0 } { 1 1 } } } & { { \mathrm { ~ i f ~ } } x \in [ 0 , 1 ] } \\ { 0 } & { { \mathrm { ~ i f ~ } } x \in [ 1 , 2 ] } \end{array} \right. } .
278
+ $$
279
+
280
+ Thus even for this best possible classifier $C ^ { \mathrm { { o p t } } }$ , every positive example would have a confidence gap of $\scriptstyle { \frac { 1 } { 1 1 } }$ while $9 0 \%$ of the negative examples (the ones in [1, 2]) would have a confidence gap of 0. Hence we see that in this toy example, our empirical observation of the lack of prediction confidence for positive examples would still hold true.
281
+
282
+ Besides, it is important to notice that this lack of positive prediction confidence phenomenon happens even in this class-balanced toy example $( p ( y = 1 ) = p ( y = 0 ) = 0 . 5 )$ . Thus, Observation 1 does not require the data distribution to be class-imbalanced to hold, which further demonstrates the generality of our norm-based attack.
283
+
284
+ # A.3 PROOF OF THEOREM 1
285
+
286
+ (Theorem 1). For $0 \leq \epsilon < 4$ and any perturbed gradient distributions $\widetilde { P } ^ { ( 1 ) }$ and $\widetilde { P } ^ { ( 0 ) }$ that are absolutely continuous with respect to each other,
287
+
288
+ $$
289
+ \mathbf { K L } \big ( \widetilde { P } ^ { ( 1 ) } \mid \big | \widetilde { P } ^ { ( 0 ) } \big ) + \mathbf { K L } \big ( \widetilde { P } ^ { ( 0 ) } \mid \big | \widetilde { P } ^ { ( 1 ) } \big ) \leq \epsilon \quad i m p l i e s \quad \operatorname* { m a x } _ { r } \mathbf { A } \mathbf { U C } ( r ) \leq \frac { 1 } { 2 } + \frac { \sqrt { \epsilon } } { 2 } - \frac { \epsilon } { 8 } .
290
+ $$
291
+
292
+ Proof of Theorem 1. Combining Pinsker’s inequality with Jensen’s inequality, we can obtain an upper bound of total variation distance by the symmetrized KL divergence (sumKL) for a pair of distributions $( P , Q )$ that are absolutely continuous with respect to each other:
293
+
294
+ $$
295
+ \mathbf { T } \mathbf { V } ( P , Q ) \leq { \frac { 1 } { 2 } } ( { \sqrt { \mathbf { K L } ( P \parallel Q ) / 2 } } + { \sqrt { \mathbf { K L } ( Q \parallel P ) / 2 } } ) \leq { \frac { 1 } { 2 } } { \sqrt { \mathbf { K L } ( P \parallel Q ) + \mathbf { K L } ( Q \parallel P ) } } .
296
+ $$
297
+
298
+ By our assumption, this implies that $\begin{array} { r } { \mathrm { T V } ( \widetilde { P } ^ { ( 1 ) } , \widetilde { P } ^ { ( 0 ) } ) \le \frac { \sqrt { \epsilon } } { 2 } } \end{array}$ . By the equivalent definition of total variation distance $\begin{array} { r } { \mathrm { T V } ( \widetilde P ^ { ( 1 ) } , \widetilde P ^ { ( 0 ) } ) ) = \operatorname* { m a x } _ { A \subset \mathbb { R } ^ { d } } [ \widetilde P ^ { ( 1 ) } ( A ) - \widetilde P ^ { ( 0 ) } ( A ) ] } \end{array}$ , we know that for any $A \subset$ $\mathbb { R } ^ { d }$ , $\begin{array} { r } { \widetilde { P } ^ { ( 1 ) } ( A ) - \widetilde { P } ^ { ( 0 ) } ( A ) \le \frac { \sqrt { \epsilon } } { 2 } } \end{array}$ . For any scoring function $r$ and any threshold value $t$ , let $A =$ $\{ g : r ( g ) > t \}$ , then we have $\begin{array} { r } { \bar { \mathrm { T P R } } _ { r } ( t ) - \mathrm { F P R } _ { r } ( t ) = \widetilde { P } ^ { ( 1 ) } ( A ) - \widetilde { P } ^ { ( 0 ) } ( A ) \leq \frac { \sqrt { \epsilon } } { 2 } . } \end{array}$ .
299
+
300
+ Therefore, the AUC of the scoring function $r$ can be upper bounded in the following way:
301
+
302
+ $$
303
+ \begin{array} { l } { \displaystyle \mathrm { A U C } ( { \boldsymbol { r } } ) = \int _ { \infty } ^ { - \infty } { \mathrm { T P R } _ { r } ( t ) ~ d \mathrm { F P R } _ { r } ( t ) } } \\ { \displaystyle \leq \int _ { \infty } ^ { - \infty } \operatorname* { m i n } \bigg ( \mathrm { F P R } _ { r } ( t ) + \frac { \sqrt { \epsilon } } { 2 } , ~ 1 \bigg ) ~ d \mathrm { F P R } _ { r } ( t ) , } \end{array}
304
+ $$
305
+
306
+ where in (6) we use the additional fact that $\mathrm { T P R } _ { r } ( t ) \leq 1$ for all $t \in \mathbb { R }$ .
307
+
308
+ When $\epsilon \in \ [ 0 , 4 )$ , we have $1 ~ - ~ \frac { \sqrt { \epsilon } } { 2 } ~ \in ~ ( 0 , 1 ]$ . As $\mathrm { F P R } _ { r } ( t )$ is a monotonically nonincreasing function in $t$ with range in $[ 0 , 1 ]$ , the set $\begin{array} { r } { \left\{ t : \mathrm { F P R } _ { r } ( t ) \leq 1 - \frac { \sqrt { \epsilon } } { 2 } \right\} \ \neq \ \phi } \end{array}$ is not empty. Let $\begin{array} { r } { k : = \operatorname* { i n f } \left\{ t : \mathrm { F P R } _ { r } ( t ) \leq 1 - \frac { \sqrt { \epsilon } } { 2 } \right\} } \end{array}$ . Again by $\mathrm { F P R } _ { r } ( t )$ being a monotonically nonincreasing function in $t$ , we can break the integration in Equation (6) into two terms:
309
+
310
+ $$
311
+ \begin{array} { r l } & { \quad \mathrm { A U C } ( r ) } \\ & { = \displaystyle \int _ { - \infty } ^ { k } \operatorname* { m i n } \left( \mathrm { F P R } _ { \mathrm { v } } ( t ) + \frac { \sqrt { \epsilon } } { 2 } , \mathbf { \Phi } _ { 1 } \right) d \mathrm { F P R } _ { v } ( t ) + \displaystyle \int _ { k } ^ { - \infty } \operatorname* { m i n } \left( \mathrm { F P R } _ { v } ( t ) + \frac { \sqrt { \epsilon } } { 2 } , \mathbf { \Phi } _ { 1 } \right) d \mathrm { F P R } _ { v } ( t ) } \\ & { \le \displaystyle \int _ { \infty } ^ { k } \left( \mathrm { F P R } _ { v } ( t ) + \frac { \sqrt { \epsilon } } { 2 } \right) d \mathrm { F P R } _ { v } ( t ) + \displaystyle \int _ { k } ^ { - \infty } 1 d \mathrm { F P R } _ { v } ( t ) } \\ & { = \left[ \frac { \left[ \mathrm { F P R } _ { r } ( v ) \right] ^ { 2 } } { 2 } + \frac { \sqrt { \epsilon } } { 2 } \mathrm { F P R } _ { v } ( v ) \right] \displaystyle _ { t = \infty } ^ { t - k } + \mathrm { F P R } _ { v } ( t ) \displaystyle _ { t = k } ^ { t - \infty } } \\ & { \le \frac { ( 1 - \frac { v \epsilon } { 2 } ) ^ { 2 } } { 2 } + \frac { \sqrt { \epsilon } } { 2 } \left( 1 - \frac { \sqrt { \epsilon } } { 2 } \right) + \left[ 1 - \left( 1 - \frac { \sqrt { \epsilon } } { 2 } \right) \right] } \\ & { = \frac { 1 } { 2 } + \frac { \sqrt { \epsilon } } { 2 } - \frac { \epsilon } { 8 } } \end{array}
312
+ $$
313
+
314
+ Since this inequality is true for any scoring function $r$ , it is true for the maximum value. Thus the proof is complete. □
315
+
316
+ # A.4 PROOF AND INTERPRETATION OF THEOREM 2
317
+
318
+ (Theorem 2). The optimal $\Sigma _ { 1 } ^ { * }$ and $\Sigma _ { 0 } ^ { * }$ to the following problem
319
+
320
+ $\operatorname* { m i n } _ { \Sigma _ { 0 } , \Sigma _ { 1 } \in \mathbb S } K L ( \mathcal { N } ( \bar { g } ^ { ( 1 ) } , v I + \Sigma _ { 1 } ) \parallel \mathcal { N } ( \bar { g } ^ { ( 0 ) } , u I + \Sigma _ { 0 } ) ) + K L ( \mathcal { N } ( \bar { g } ^ { ( 0 ) } , u I + \Sigma _ { 0 } ) \parallel \mathcal { N } ( \bar { g } ^ { ( 1 ) } , v I + \Sigma _ { 1 } ) )$ subject to
321
+
322
+ $$
323
+ \begin{array} { c } { \Sigma _ { 0 } \Sigma _ { 1 } = \Sigma _ { 1 } \Sigma _ { 0 } , } \\ { p \cdot \operatorname { t r } ( \Sigma _ { 1 } ) + ( 1 - p ) \cdot \operatorname { t r } ( \Sigma _ { 0 } ) \leq P , } \\ { \Sigma _ { 1 } \succeq \mathbf { 0 } , } \\ { \Sigma _ { 0 } \succeq \mathbf { 0 } . } \end{array}
324
+ $$
325
+
326
+ have the form:
327
+
328
+ $$
329
+ \Sigma _ { 1 } ^ { * } = \frac { \tilde { \lambda } _ { 1 } ^ { ( 1 ) * } - \lambda _ { 2 } ^ { ( 1 ) * } } { \| \Delta g \| _ { 2 } ^ { 2 } } ( \Delta g ) ( \Delta g ) ^ { \top } + \lambda _ { 2 } ^ { ( 1 ) * } I _ { d } , \quad \Sigma _ { 0 } ^ { * } = \frac { \lambda _ { 1 } ^ { ( 0 ) * } - \lambda _ { 2 } ^ { ( 0 ) * } } { \| \Delta g \| _ { 2 } ^ { 2 } } ( \Delta g ) ( \Delta g ) ^ { \top } + \lambda _ { 2 } ^ { ( 0 ) * } I _ { d } ,
330
+ $$
331
+
332
+ where $( \lambda _ { 1 } ^ { ( 0 ) * } , \lambda _ { 2 } ^ { ( 0 ) * } , \lambda _ { 1 } ^ { ( 1 ) * } , \lambda _ { 2 } ^ { ( 1 ) * } )$ is the solution to the following 4-variable optimization problem:
333
+
334
+ $$
335
+ \begin{array} { r l } & { \underset { \lambda _ { 1 } ^ { ( 0 ) } , \lambda _ { 1 } ^ { ( 0 ) } , \lambda _ { 2 } ^ { ( 1 ) } } { \operatorname* { m i n } } ( d - 1 ) \frac { \lambda _ { 2 } ^ { ( 0 ) } + u } { \lambda _ { 2 } ^ { ( 1 ) } + v } + ( d - 1 ) \frac { \lambda _ { 2 } ^ { ( 1 ) } + v } { \lambda _ { 2 } ^ { ( 0 ) } + u } + \frac { \lambda _ { 1 } ^ { ( 0 ) } + u + \| \Delta g \| _ { 2 } ^ { 2 } } { \lambda _ { 1 } ^ { ( 1 ) } + v } + \frac { \lambda _ { 1 } ^ { ( 1 ) } + v + \| \Delta g \| _ { 2 } ^ { 2 } } { \lambda _ { 1 } ^ { ( 0 ) } + u } } \\ & { \mathrm { ~ s . t . ~ } p \lambda _ { 1 } ^ { ( 1 ) } + p ( d - 1 ) \lambda _ { 2 } ^ { ( 1 ) } + ( 1 - p ) \lambda _ { 1 } ^ { ( 0 ) } + ( 1 - p ) ( d - 1 ) \lambda _ { 2 } ^ { ( 0 ) } \leq P , } \\ & { \mathrm { ~ \ ~ - ~ } \lambda _ { 1 } ^ { ( 1 ) } \leq 0 , \mathrm { ~ \ ~ - ~ } \lambda _ { 1 } ^ { ( 0 ) } \leq ~ 0 , \mathrm { ~ \ ~ - ~ } \lambda _ { 2 } ^ { ( 1 ) } \leq ~ 0 , \mathrm { ~ \ ~ - ~ } \lambda _ { 2 } ^ { ( 0 ) } \leq ~ 0 , } \\ & { \quad \quad \quad \lambda _ { 2 } ^ { ( 1 ) } - \lambda _ { 1 } ^ { ( 1 ) } \leq ~ 0 , \lambda _ { 2 } ^ { ( 0 ) } - \lambda _ { 1 } ^ { ( 0 ) } \leq 0 } \end{array}
336
+ $$
337
+
338
+ Proof of Theorem 2. By writing out the analytical close-form of the KL divergence between two Gaussian distributions, the optimization can be written as:
339
+
340
+ $$
341
+ \begin{array} { c } { { \displaystyle \operatorname* { m i n } _ { \Sigma _ { 0 } , \Sigma _ { 1 } \in \mathbb S } \mathrm { t r } \big ( ( \Sigma _ { 1 } + v I ) ^ { - 1 } ( \Sigma _ { 0 } + u I ) \big ) + \mathrm { t r } \big ( ( \Sigma _ { 0 } + u I ) ^ { - 1 } ( \Sigma _ { 1 } + v I ) \big ) + } } \\ { { \displaystyle \big ( \bar { g } ^ { ( 1 ) } - \bar { g } ^ { ( 0 ) } \big ) ^ { \top } \left( ( \Sigma _ { 1 } + v I ) ^ { - 1 } + ( \Sigma _ { 0 } + u I ) ^ { - 1 } \right) \left( \bar { g } ^ { ( 1 ) } - \bar { g } ^ { ( 0 ) } \right) } } \end{array}
342
+ $$
343
+
344
+ subject to
345
+
346
+ $$
347
+ \begin{array} { c } { \Sigma _ { 0 } \Sigma _ { 1 } = \Sigma _ { 1 } \Sigma _ { 0 } , } \\ { p \cdot \operatorname { t r } ( \Sigma _ { 1 } ) + ( 1 - p ) \cdot \operatorname { t r } ( \Sigma _ { 0 } ) \leq P , } \\ { \Sigma _ { 1 } \succeq \mathbf { 0 } , } \\ { \Sigma _ { 0 } \succeq \mathbf { 0 } . } \end{array}
348
+ $$
349
+
350
+ By the commutative constraint on the two positive semidefinite matrices $\Sigma _ { 1 }$ and $\Sigma _ { 0 }$ , we know that we can factor these two matrices using the same set of eigenvectors. We thus write:
351
+
352
+ $$
353
+ \begin{array} { r } { \Sigma _ { 0 } = \boldsymbol { Q } ^ { \top } \mathrm { d i a g } ( \lambda _ { 1 } ^ { ( 0 ) } , \ldots , \lambda _ { d } ^ { ( 0 ) } ) \boldsymbol { Q } , } \\ { \Sigma _ { 1 } = \boldsymbol { Q } ^ { \top } \mathrm { d i a g } ( \lambda _ { 1 } ^ { ( 1 ) } , \ldots , \lambda _ { d } ^ { ( 1 ) } ) \boldsymbol { Q } , } \end{array}
354
+ $$
355
+
356
+ where $Q \in \mathbb { R } ^ { d \times d }$ is an orthogonal matrix and the eigenvalues $\lambda _ { i } ^ { ( 0 ) } , \lambda _ { i } ^ { ( 1 ) }$ are nonnegative and decreasing in value.
357
+
358
+ Using this alternative expression of $\Sigma _ { 1 }$ and $\Sigma _ { 0 }$ , we can express the optimization in terms of $\{ \lambda _ { i } ^ { ( 1 ) } \} , \{ \lambda _ { i } ^ { ( 0 ) } \} , Q$ :
359
+
360
+ $$
361
+ \begin{array} { r l } { \underset { \{ \lambda _ { i } ^ { ( 1 ) } \} , \{ \lambda _ { i } ^ { ( 0 ) } \} , Q } { \operatorname* { m i n } } } & { \displaystyle \sum _ { i = 1 } ^ { d } \frac { \lambda _ { i } ^ { ( 0 ) } + u } { \lambda _ { i } ^ { ( 1 ) } + v } + \sum _ { i = 1 } ^ { d } \frac { \lambda _ { i } ^ { ( 1 ) } + v } { \lambda _ { i } ^ { ( 0 ) } + u } + } \\ & { \displaystyle \left[ Q ( \bar { g } ^ { ( 1 ) } - \bar { g } ^ { ( 0 ) } ) \right] ^ { \top } \mathrm { d i a g } \left( \cdots , \frac { 1 } { \lambda _ { i } ^ { ( 0 ) } + u } + \frac { 1 } { \lambda _ { i } ^ { ( 1 ) } + v } , \ldots \right) Q ( \bar { g } ^ { ( 1 ) } - \bar { g } ^ { ( 0 ) } ) } \end{array}
362
+ $$
363
+
364
+ $$
365
+ \begin{array} { r l } { \mathrm { s u b j e c t ~ t o ~ } } & { p ( \displaystyle \sum _ { i = 1 } ^ { d } \lambda _ { i } ^ { ( 1 ) } ) + ( 1 - p ) ( \displaystyle \sum _ { i = 1 } ^ { d } \lambda _ { i } ^ { ( 0 ) } ) \le P } \\ & { - \lambda _ { i } ^ { ( 1 ) } \le 0 , \forall i \in [ d ] } \\ & { - \lambda _ { i } ^ { ( 0 ) } \le 0 , \forall i \in [ d ] . } \\ & { \lambda _ { i } ^ { ( 1 ) } \ge \lambda _ { j } ^ { ( 1 ) } , \forall i < j . } \\ & { \lambda _ { i } ^ { ( 0 ) } \ge \lambda _ { j } ^ { ( 0 ) } , \forall i < j . } \\ & { Q \ \mathrm { o r t h o g o n a l } . } \end{array}
366
+ $$
367
+
368
+ For any fixed feasible $\{ \lambda _ { i } ^ { ( 1 ) } \} , \{ \lambda _ { i } ^ { ( 0 ) } \}$ , we see that the corresponding minimizing $Q$ will set its first row to be the unit vector in the direction of $\Delta g$ . Thus by first minimizing $Q$ , the optimization objective reduces to:
369
+
370
+ $$
371
+ \begin{array} { c c l } { \displaystyle \sum _ { i = 1 } ^ { d } \frac { \lambda _ { i } ^ { ( 0 ) } + u } { \lambda _ { i } ^ { ( 1 ) } + v } + \displaystyle \sum _ { i = 1 } ^ { d } \frac { \lambda _ { i } ^ { ( 1 ) } + v } { \lambda _ { i } ^ { ( 0 ) } + u } + \frac { g } { \lambda _ { 1 } ^ { ( 0 ) } + u } + \frac { g } { \lambda _ { 1 } ^ { ( 1 ) } + v } } \\ { = \displaystyle \sum _ { i = 2 } ^ { d } \frac { \lambda _ { i } ^ { ( 0 ) } + u } { \lambda _ { i } ^ { ( 1 ) } + v } + \displaystyle \sum _ { i = 2 } ^ { d } \frac { \lambda _ { i } ^ { ( 1 ) } + v } { \lambda _ { i } ^ { ( 0 ) } + u } + \frac { \lambda _ { 1 } ^ { ( 1 ) } + v + \| \Delta g \| _ { 2 } ^ { 2 } } { \lambda _ { 1 } ^ { ( 0 ) } + u } + \frac { \lambda _ { 1 } ^ { ( 0 ) } + u + \| \Delta g \| _ { 2 } ^ { 2 } } { \lambda _ { 1 } ^ { ( 1 ) } + v } } \end{array}
372
+ $$
373
+
374
+ We see that for the pair of variable $( \lambda _ { i } ^ { ( 1 ) } , \lambda _ { i } ^ { ( 0 ) } )$ $( i ~ \geq ~ 2 )$ , the function $\begin{array} { r } { \frac { \lambda _ { i } ^ { ( 0 ) } + u } { \lambda _ { i } ^ { ( 1 ) } + v } + \frac { \lambda _ { i } ^ { ( 1 ) } + v } { \lambda _ { 1 } ^ { ( 0 ) } + u } } \end{array}$ is strictly convex over the line segment $p \lambda _ { i } ^ { ( 1 ) } + ( 1 - p ) \lambda _ { i } ^ { ( 0 ) } = c$ for any nonnegative $c$ and attains the the minimum value at $\lambda _ { i } ^ { ( 1 ) } = 0$ when $u \ : < \ : v$ and $\lambda _ { i } ^ { ( 0 ) } = 0$ when $u \geq v$ . Suppose without loss of generality $u \geq v$ , then for the optimal solution we must have $\lambda _ { i } ^ { ( 0 ) } = 0$ for all $i \geq 2$ . Under this Thus for all condition, we notice that the function m(x) = ux+v $\left\{ \lambda _ { i } ^ { \left( 1 \right) } \right\}$ that satisfies $\Sigma _ { i = 2 } ^ { d } \lambda _ { i } ^ { ( 1 ) } = c$ is strictly c nonnegative $c$ vex on the positive reals., by Jensen inequality, we have
375
+
376
+ $$
377
+ \begin{array} { l } { \displaystyle \frac { 1 } { d - 1 } \sum _ { i = 2 } ^ { d } \left( \frac { u } { \lambda _ { i } ^ { ( 1 ) } + v } + \frac { \lambda _ { i } ^ { ( 1 ) } + v } { u } \right) } \\ { \displaystyle = \frac { 1 } { d - 1 } \sum _ { i = 2 } ^ { d } m ( \lambda _ { i } ^ { ( 1 ) } ) } \\ { \displaystyle \geq m \left( \frac { 1 } { d - 1 } \sum _ { i = 2 } ^ { d } \lambda _ { i } ^ { ( 1 ) } \right) } \\ { \displaystyle = m \left( \frac { c } { d - 1 } \right) . } \end{array}
378
+ $$
379
+
380
+ From this, we see that the optimal solution’s variables $\{ \lambda _ { i } ^ { ( 1 ) } \}$ must take on the same value $\scriptstyle { \big ( } { \frac { c } { d - 1 } } { \big ) }$ for all $i \geq 2$ . The case when $u \leq v$ is similar. As a result, we have proved that at the optimal solution, we must have:
381
+
382
+ $$
383
+ \lambda _ { i } ^ { ( 0 ) } = \lambda _ { j } ^ { ( 0 ) } \mathrm { a n d } \lambda _ { i } ^ { ( 1 ) } = \lambda _ { j } ^ { ( 1 ) } , \mathrm { f o r } i , j \ge 2
384
+ $$
385
+
386
+ Hence, the optimization problem over the 2d variables nλ(1)i odi=1 $\left\{ \lambda _ { i } ^ { ( 1 ) } \right\} _ { i = 1 } ^ { d } \bigcup \left\{ \lambda _ { i } ^ { ( 0 ) } \right\} _ { i = 1 } ^ { d }$ can be reduced to an optimization problem over the four variables $\left\{ \lambda _ { 1 } ^ { ( 1 ) } , \lambda _ { 2 } ^ { ( 1 ) } , \lambda _ { 1 } ^ { ( 0 ) } , \lambda _ { 2 } ^ { ( 0 ) } \right\}$ :
387
+
388
+ $$
389
+ \operatorname* { m i n } _ { \lambda _ { 1 } ^ { ( 0 ) } , \lambda _ { 1 } ^ { ( 1 ) } , \lambda _ { 2 } ^ { ( 0 ) } , \lambda _ { 2 } ^ { ( 1 ) } } \left( d - 1 \right) \frac { \lambda _ { 2 } ^ { ( 0 ) } + u } { \lambda _ { 2 } ^ { ( 1 ) } + v } + ( d - 1 ) \frac { \lambda _ { 2 } ^ { ( 1 ) } + v } { \lambda _ { 2 } ^ { ( 0 ) } + u } + \frac { \lambda _ { 1 } ^ { ( 0 ) } + u + \| \Delta g \| _ { 2 } ^ { 2 } } { \lambda _ { 1 } ^ { ( 1 ) } + v } + \frac { \lambda _ { 1 } ^ { ( 1 ) } + v + \| \Delta g \| _ { 2 } ^ { 2 } } { \lambda _ { 1 } ^ { ( 0 ) } + u }
390
+ $$
391
+
392
+ $$
393
+ \begin{array} { r l } { \mathrm { s u b j e c t ~ t o ~ } } & { \ p \lambda _ { 1 } ^ { ( 1 ) } + p ( d - 1 ) \lambda _ { 2 } ^ { ( 1 ) } + ( 1 - p ) \lambda _ { 1 } ^ { ( 0 ) } + ( 1 - p ) ( d - 1 ) ( \lambda _ { 2 } ^ { ( 0 ) } ) \leq P } \\ & { \quad \quad \quad - \lambda _ { 1 } ^ { ( 1 ) } \leq 0 } \\ & { \quad \quad \quad - \lambda _ { 0 } ^ { ( 0 ) } \leq 0 } \\ & { \quad \quad \quad - \lambda _ { 2 } ^ { ( 1 ) } \leq 0 } \\ & { \quad \quad \quad - \lambda _ { 2 } ^ { ( 0 ) } \leq 0 } \\ & { \quad \quad \quad \lambda _ { 2 } ^ { ( 1 ) } - \lambda _ { 1 } ^ { ( 1 ) } \leq 0 } \\ & { \quad \quad \quad \lambda _ { 2 } ^ { ( 0 ) } - \lambda _ { 1 } ^ { ( 1 ) } \leq 0 } \\ & { \quad \quad \quad \lambda _ { 2 } ^ { ( 0 ) } - \lambda _ { 1 } ^ { ( 0 ) } \leq 0 . } \end{array}
394
+ $$
395
+
396
+ Given the optimal solution to the above 4-variable problem $( \lambda _ { 1 } ^ { ( 0 ) * } , \lambda _ { 2 } ^ { ( 0 ) * } , \lambda _ { 1 } ^ { ( 1 ) * } , \lambda _ { 2 } ^ { ( 1 ) * } )$ , we can set $Q$ to be any orthogonal matrix whose first row is the vector k∆gk2 . Plugging this back into the expression of $\Sigma _ { 1 }$ and $\Sigma _ { 0 }$ in Equation (14) gives us the final result.
397
+
398
+ Thus the proof is complete.
399
+
400
+ Remark (Interpreting the optimal $\Sigma _ { 1 } ^ { * }$ and $\Sigma _ { 0 } ^ { * }$ ). From the form of the optimal solution in (12), we see that the optimal covariance matrices are both linear combinations of two terms: a rank one matrix $( \Delta g ) ( \dot { \Delta } g ) ^ { \top }$ and the identity matrix $I _ { d }$ . Because a zero-mean Gaussian random vector with convariance matrix $( A + B )$ can be constructed as the sum of two independent zero-mean Gaussian random vectors with covariance matrices $A$ and $B$ respectively, we see that the optimal additive noise random variables $\eta ^ { ( 1 ) }$ and $\eta ^ { ( 0 ) }$ each consist of two independent components: one random component lies along the line that connects the positive and negative gradient mean vectors (whose covariance matrix is proportional to $\Delta g \Delta g ^ { \top } )$ ); the other component is sampled from an isotropic Gaussian. The use of the first random directional component and the fact that the isotropic Gaussian component have different variance scaling for the positive and negative class clearly distinguishes Marvell from the isotropic Gaussian baseline iso.
401
+
402
+ Remark (How to solve). By analyzing the KKT condition of this four variable problem we can find that the optimal solution must exactly lie on the hyperplane $p \lambda _ { 1 } ^ { ( 1 ) } + p ( d - 1 ) \bar { \lambda _ { 2 } ^ { ( 1 ) } } + ( 1 - p ) \lambda _ { 1 } ^ { ( 0 ) } +$ $( 1 - p ) ( d - 1 ) \lambda _ { 2 } ^ { ( 0 ) } = P$ . From the proof above we additionally know that $\lambda _ { 2 } ^ { ( 1 ) * } = 0$ if $u < v$ and $\lambda _ { 2 } ^ { ( 0 ) * } = 0$ if $u \geq v$ . Thus the problem is further reduced to a 3-variable problem. If we consider keeping one of the 3 remaining variables’ values fixed, then the feasible region becomes restricted to a line segment. We can simply perform a line search optimization of the convex objective and find the optimal values for the remaining two free variables. We can then alternate over which one of the three variables to fix and optimize over the other two. This optimization procedure would eventually converge and give us the optimal solution. This approach mimics the Sequential Minimal Optimization technique used to solve the dual of the support vector machine (SVM).
403
+
404
+ # A.5 MA R V E L L ALGORITHM DESCRIPTION
405
+
406
+ We use $\mathbf { 1 } \in \mathbb { R } ^ { d }$ to denote the vector with 1 in each coordinate. We use $g [ j ]$ to denote the $j$ -th row of the matrix $g$ and $y [ j ]$ to denote the $j$ -th coordinate of the vector $y$ .
407
+
408
+ Algorithm 1: Marvell algorithm input : g ∈ RB×d, a size- $. B$ batch of unperturbed gradients $y \in \left\{ 0 , 1 \right\} ^ { B }$ , the label for each example in the batch $s$ , privacy hyperparameter for the power constraint $P$ output: g˜ ∈ RB×d, batch of perturbed gradients // Step 1: estimate the optimization constants from the batch gradients using maximum likelihood estimation (MLE)
409
+ 1 $p \gets \frac { \mathbf { 1 } ^ { T } y } { d }$ 1 T y ; /\* positive fraction \*/
410
+ 2 g¯(1) $\begin{array} { r } { \bar { g } ^ { ( 1 ) } \frac { 1 } { \mathbf { 1 } ^ { T } y } g ^ { T } y } \end{array}$ ; $/ \star$ positive mean \*/
411
+ 3 $\begin{array} { r } { \bar { g } ^ { ( 0 ) } \frac { 1 } { B - \mathbf { 1 } ^ { T } y } g ^ { T } ( \mathbf { 1 } - y ) } \end{array}$ ; /\* negative mean \*/
412
+ 4 $\Delta g = \bar { g } ^ { ( 1 ) } - \bar { g } ^ { ( 0 ) }$ ;
413
+ 5 $\begin{array} { r } { v \frac { 1 } { d \cdot ( \mathbf { 1 } ^ { T } y ) } \sum _ { j = 1 } ^ { B } y [ j ] \cdot g [ j ] - \bar { g } ^ { ( 1 ) } _ { 2 } ^ { 2 } } \end{array}$ ; /\* positive convariance \*/
414
+ 6 $\begin{array} { r } { u \frac { 1 } { d \cdot ( B - \mathbf { 1 } ^ { T } y ) } \sum _ { j = 1 } ^ { B } ( 1 - y [ j ] ) \cdot g [ j ] - \bar { g } ^ { ( 0 ) } _ { 2 } ^ { 2 } } \end{array}$ ; /\* negative convariance $\star /$
415
+ 7 $P \gets s \cdot \| \Delta g \| _ { 2 } ^ { 2 }$ ; /\* power constraint hyperparameter $\star /$ // Step 2: optimize the four-variable problem
416
+ 8 if $u < v$ then
417
+ 9 $\lambda _ { 2 } ^ { ( 1 ) } 0$ ; /\* this variable is optimal at $0 ~ \star /$
418
+ 10 Randomly initialize the optimization variables $\lambda _ { 1 } ^ { ( 1 ) }$ , $\lambda _ { 1 } ^ { ( 0 ) }$ , $\lambda _ { 2 } ^ { ( 0 ) }$ in the feasible region in (15).
419
+ 11 else
420
+ 12 13 $\lambda _ { 2 } ^ { ( 0 ) } 0 \ : ;$ initialize the optimization varia $/ \star$ le is optimal at 0 in the feasible region in (1 $\star /$ $\lambda _ { 1 } ^ { ( 1 ) } , \lambda _ { 2 } ^ { ( 1 ) } , \lambda _ { 1 } ^ { ( 0 ) }$
421
+ 14 end
422
+ 15 while not converged do
423
+ 16 Fix one of the newly updated optimization variables; // The 4-variable optimal solution lies on a hyperplane in $\mathbb { R } ^ { 4 }$ (see Appendix A.4 Remark) so fixing two variables gives us a line-segment
424
+ 17 Update the remaining two optimization variables by performing 1-d line-search minimization of the convex function (15) while satisfying the constraints;
425
+
426
+ # 18 end
427
+
428
+ // Step 3: compute the optimal covariance matrices
429
+ 19 $\begin{array} { r } { \Sigma _ { 1 } ^ { * } \frac { \lambda _ { 1 } ^ { ( 1 ) } - \lambda _ { 2 } ^ { ( 1 ) } } { \| \Delta g \| _ { 2 } ^ { 2 } } ( \Delta g ) ( \Delta g ) ^ { \top } + \lambda _ { 2 } ^ { ( 1 ) } I _ { d } ; } \end{array}$ ;
430
+ 20 $\begin{array} { r } { \Sigma _ { 0 } ^ { * } \frac { \lambda _ { 1 } ^ { ( 0 ) } - \lambda _ { 2 } ^ { ( 0 ) } } { \| \Delta g \| _ { 2 } ^ { 2 } } ( \Delta g ) ( \Delta g ) ^ { \top } + \lambda _ { 2 } ^ { ( 0 ) } I _ { d } ; } \end{array}$ ;
431
+ // Step 4: perturb the gradients
432
+ 21 $\tilde { g } \mathbf { 0 } _ { B \times d }$ ; $/ \star$ an empty matrix to store the perturbed gradients \*/
433
+ 22 for $j 1$ to $B$ do
434
+ 23 if $y [ j ] = 1$ then
435
+ 24 $\tilde { g } [ j ] g [ j ] + \eta ^ { ( 1 ) }$ , where $\boldsymbol \eta ^ { ( 1 ) } \sim \mathcal { N } ( \mathbf 0 , \Sigma _ { 1 } ^ { * } )$ ;
436
+ 25 else $\begin{array} { r l } { \langle \mathscr { I } / } & { { } y [ j ] = 0 } \end{array}$
437
+ 26 $\begin{array} { r l } { \vert } & { { } \tilde { g } [ j ] g [ j ] + \eta ^ { ( 0 ) } } \end{array}$ , where $\boldsymbol \eta ^ { ( 0 ) } \sim \mathcal { N } ( \mathbf 0 , \Sigma _ { 0 } ^ { * } )$ ;
438
+ 27 end
439
+ 28 end
440
+
441
+ A.5.1 MA R V E L L TIME COMPLEXITY
442
+
443
+ The Marvell algorithm in 1 consists of the following steps:
444
+
445
+ Step 1. Compute the positive and negative gradient mean and their difference (line 1 - 4). This amounts to averaging over at most $B$ numbers over each of the d gradient dimensions. Thus would have a time complexity of $O ( B d )$ .
446
+ Step 2. Compute the positive and negative covariance constants $u$ and $v$ (line 5, 6). This operation also takes $O ( \bar { B } d )$ as it averages over squares of coordinate differences.
447
+ Step 3. Use the results from step 1 and 2, solve the 4-variable optimization problem (line 7-18). Here because the constant size of the number of optimization variables. Solving this problem up to a fixed precision takes constant time $O ( 1 )$ .
448
+ Step 4. Perform the actual random perturbation (line $1 9 - 2 8 $ ). Because of the additive structure of each class’s covariance matrix, for every example’s gradient in the batch, we can independently sample one random Gaussian vector with rank-1 covariance and also another spherical Gaussian random vector and add both vectors to this gradient for perturbation. This step would take $O ( d )$ for each example and thus takes $O ( B d )$ in total.
449
+
450
+ As a result, the entire Marvell algorithm has a time complexity of $O ( B d )$ . This can be further sped up through parallel computation using multi-threading/multi-core. Considering backpropagation through the cut layer would also require $O ( B d )$ time complexity, the Marvell algorithm would not slow down the split-learning process in any significant way at all.
451
+
452
+ # A.5.2 MA R V E L L EMPIRICAL RUN TIME
453
+
454
+ Empirically, in Table 1, we present the average amount of time it takes to run Marvell with the privacy hyperparameter value $s = 4$ for the three models (one for each dataset) we considered in our experiments (s value is chosen as it achieves good privacy protection as shown with purple line in Figure 3, 5, 6). We also compare it to the average time it takes to run one update iteration. We additionally include the $9 5 \%$ confidence interval for the mean estimator of the run time. Here we notice that the total run time of Marvell only takes up a very small amount of the total training time for each method, further corroborating our algorithm’s time efficiency advantage.
455
+
456
+ $$
457
+ \frac | \begin{array} { l c } { { \mathrm { b a t c h } } } \\ { { \mathrm { s i z e } } } \\ { { \frac { B } { 1 . 8 1 \times } } } \end{array} | \begin{array} { l c } { { \mathrm { c u t ~ l a y e r ~ f e a t u r e } } } \\ { { \mathrm { d i m e n s i o n } } } \\ { { \mathrm { ~ d i o n } } } \end{array} | \begin{array} { l l } { { \mathrm { ~ a n v e r ~ f e n ~ t i m e } } } \\ { { \mathrm { M a r v e l ~ r u n ~ t i m e } } } \\ { { \mathrm { ~ 1 . 7 9 \times ~ l 0 ^ { - 2 } ~ } } } \\ { { \mathrm { ~ 2 . 7 . 0 3 \times ~ 1 0 ^ { - 5 } ~ } } } \end{array} | \begin{array} { l l } { { \mathrm { ~ a v e r a g e } } } \\ { { \mathrm { ~ ( s e c o n d s / ~ t i m e ) } } } \\ { { \mathrm { ~ 3 . 9 4 \times ~ 1 0 ^ { - 1 } ~ } } } \\ { { \mathrm { ~ 4 . 0 5 \times ~ 1 0 ^ { - 3 } ~ } } } \\ { { \mathrm { ~ 1 . 6 8 \times ~ 1 0 ^ { - 2 } ~ } } } \end{array} | \begin{array} { l l } { { \mathrm { a v e r a g e } } } \\ { { \mathrm { ~ 4 . 2 8 \times ~ 1 0 ^ { - 1 } ~ } } } \\ { { \mathrm { ~ 4 . 8 4 ~ } } } \end{array}
458
+ $$
459
+
460
+ Table 1: Average run time of Marvell $s = 4$ ) and average total update time per iteration for models trained on ISIC, Criteo, and Avazu.
461
+
462
+ # A.6 DATA SETUP AND EXPERIMENTAL DETAILS
463
+
464
+ We first describe how we preprocess each of the datasets in A.6.1. We then describe the model architecture used for each dataset in A.6.2. Finally, we describe what the training hyperparameters are used for each dataset/model combination and the amount of compute used for the experiments in A.6.3.
465
+
466
+ # A.6.1 DATASET PREPROCESSING
467
+
468
+ [Criteo] Every record of Criteo has 27 categorical input features and 14 real-valued input features. We first replace all the NA values in categorical features with a single new category (which we represent using the empty string) and replace all the NA values in real-valued features with 0. For each categorical feature, we convert each of its possible value uniquely to an integer between 0 (inclusive) and the total number of unique categories (exclusive). For each real-valued feature, we linearly normalize it into [0, 1]. We then randomly sample $1 0 \%$ of the entire Criteo publicly provided training set as our entire dataset (for faster training to generate privacy-utility trade-off comparision) and further make the subsampled dataset into a $90 \%$ - $10 \%$ train-test split.
469
+
470
+ [Avazu] Unlike Criteo, each record in Avazu only has categorical input features. We similarly replace all NA value with a single new category (the empty string), and for each categorical feature, we convert each of its possible value uniquely to an integer between 0 (inclusive) and the total number of unique categories (exclusive). We use all the records in provided in Avazu and randomly split it into $90 \%$ for training and $10 \%$ for test.
471
+
472
+ [ISIC] The official SIIM-ISIC Melanoma Classification dataset has a total 33126 of skin lesion images with less than $2 \%$ positive examples. Because for image classification model training it is desirable to use a batch size of $\sim 1 0 ^ { 2 }$ , it is highly likely that there won’t be any positive examples sampled in a batch of such size. Thus to make the label leakage problem more severe, we modify the dataset by retaining all the 584 positive examples and randomly choosing $5 8 4 \times 9$ examples out of all the negative examples. By doing this, we enforce that there are $10 \%$ positive examples in this modified dataset. We randomly split these 5840 examples into a $80 \% - 2 0 \%$ training and test split. We also resize the images to size $8 4 \times 8 4$ for efficient model training.
473
+
474
+ # A.6.2 MODEL ARCHITECTURE DETAILS
475
+
476
+ [Criteo, Avazu] We use a popular deep learning model architecture WDL (Cheng et al., 2016) for online advertising. Here the deep and wide part each first processes the categorical features in a given record by applying an embedding lookup for every categorical feature’s value. We use an embedding dimension of 4 for the deep part and embedding dimension of 1 for the wide part. After the lookup, the deep/wide embeddings are then concatenated with the continuous features to form the raw input vectors for both the deep part and wide part respectively. (This step is skipped for Avazu as it has no continuous features.) Then the wide part computes the wide part logit value through a real-valued linear function (with bias) of its raw input vectors, while the deep part processes its raw input features using 6 ReLU-activated 128-unit MLP layers before producing a single deep part logit. The two logits are summed up to form the final logic value. The cut layer is after the output of the 3rd ReLU layer on the deep part.
477
+
478
+ [ISIC] Every input image after resizing is of size $8 4 \times 8 4 \times 3$ . We use a convolutional model with 6 convolutional layers each with 64 channels $3 \times 3$ filter size with $1 \times 1$ stride size. Each convolutional layer is followed by a ReLU activation function whose output is then max pooled with $2 \times 2$ window and stride size $2 \times 2$ . The max-pooled output of the 6th layer is then flattened and pass into a 64-unit ReLU-activated MLP layer before finally being linearly transformed into a single logit score. The cut layer is after the output of the 4th max pool layer. Thus the cut layer feature and gradient are both of shape $5 \times 5 \times 6 4$ .
479
+
480
+ # A.6.3 MODEL TRAINING DETAILS
481
+
482
+ Because the protection mechanism requires adding noise to the cut layer gradient, the induced variance of the gradients of non-label party’s $f$ -parameters becomes larger. Thus to ensure smooth optimization and sufficient training loss minimization, we use a slightly smaller learning rate than what is normally used.
483
+
484
+ [Criteo] We use the Adam optimizer with a batch size of 1024 and a learning rate of $1 e { - 4 }$ throughout the entire training of 5 epochs (approximately $2 0 \mathrm { k }$ stochastic gradient updates).
485
+
486
+ [ISIC] We use the Adam optimizer with a batch size of 128 and a learning rate of $1 e { - } 5$ throughout the entire training of 1000 epochs (approximately $3 5 \mathrm { k }$ stochastic gradient updates).
487
+
488
+ [Avazu] We use the Adam optimizer with a batch size of 32768 and a learning rate of $1 e { - 4 }$ throughout the entire training of 5 epochs (approximately $5 . 5 \mathrm { k }$ stochastic gradient updates).
489
+
490
+ We conduct our experiments over 16 Nvidia 1080Ti GPU card. Each run of Avazu takes about 11 hours to finish on a single GPU card occupying 8GB of GPU RAM. Each run of Criteo takes about 37 hours to finish on a single GPU card using 5 GB of GPU RAM. Each run of ISIC takes about 12 hours to finish on a single GPU card occupying 4GB of GPU RAM.
491
+
492
+ # A.7 COMPLETE EXPERIMENTAL RESULTS
493
+
494
+ # A.7.1 LEAK AUC PROGRESSION FOR AVAZU AND CRITEO
495
+
496
+ In addition to the leak AUC progression on ISIC shown in Figure 3 in the main paper, we also show the leak AUC progression on the Avazu and Criteo datasets throughout training here in Figure 5 and Figure 6. We similarly compare Marvell with different levels of protection strength (s values) against the no protection baseline no noise. As we can see, Marvell still achieves strong and flexible privacy protection on these two datasets against our label attacks at different model layers.
497
+
498
+ ![](images/fc64579aad78e2fa08ffb6045f49d1a0fde107f7a7dc254d23753e69f6c1753e.jpg)
499
+ Figure 5: Norm and cosine leak AUC (computed every batch) at the cut layer and at the first layer of no noise (no protection) vs. Marvell with different scale hyperparameter $s$ throughout the Avazu training.
500
+
501
+ ![](images/7998fbd902b18742af0791b87deac7e2a9cb14ec0faab7692e4248043d10fa75.jpg)
502
+ Figure 6: Norm and cosine leak AUC (computed every batch) at the cut layer and at the first layer of no noise (no protection) vs. Marvell with different scale hyperparameter s throughout the Criteo training.
503
+
504
+ # A.7.2 COMPLETE PRIVACY-UTILITY TRADEOFFS
505
+
506
+ We show additional Privacy-Utility tradeoff results for all three datasets considered in this paper. (Some of the plots have already been shown in the main paper but we still include them here for completeness and ease of reference.) For each dataset, we compare the privacy-utility tradeoff over multiple measures of privacy and utility:
507
+
508
+ # Privacy
509
+
510
+ We consider our introduced privacy metrics using the activation gradient from the cut layer and the first layer of the non-label party :
511
+
512
+ • $9 5 \%$ norm leak AUC at cut layer • $9 5 \%$ cosine leak AUC at cut layer • $9 5 \%$ norm leak AUC at first layer • $9 5 \%$ cosine leak AUC at first layer
513
+
514
+ #
515
+
516
+ We consider three metrics of utility:
517
+
518
+ • training loss (train loss): the lowest loss achieved on the training set throughout training. This directly measures how much the random protection perturbation influences the optimization. • test loss. Because we only control the training optimization stochastic gradient’s variance, measuring test loss directly tells us how much impact the training optimization random perturbation influences beyond optimization but on the learned model’s generalization ability. • test AUC. As we are dealing with binary classification problem (where performance is commonly measured through test AUC), we also naturally consider it as a utility metric.
519
+
520
+ As shown in Figure 7,8,9, Marvell consistently outperforms the isotropic Gaussian baseline over all the different privacy-utility definitions. In addition, our proposed heuristic max norm is also particularly effective against our identified norm and direction-based attacks.
521
+
522
+ ![](images/cfa83c054f2045646208abae64f5e5969c5183c3b6697991cd25d9d7634217b2.jpg)
523
+ Figure 7: Privacy (norm and cosine leak AUC) vs Utility (train loss, test loss, and test AUC) trade-off of protection methods (Marvell, iso, no noise, max norm) at the cut layer and first layer on Avazu.
524
+
525
+ ![](images/f9b37071e310cce66c89d73ed7335527adaa39502b1e85c60894e68a77ab15fc.jpg)
526
+ Figure 8: Privacy (norm and cosine leak AUC) vs Utility (train loss, test loss, and test AUC) trade-off of protection methods (Marvell, iso, no noise, max norm) at the cut layer and first layer on Criteo.
527
+
528
+ ![](images/6397972f53ef2b60ce1c15ca92d0c6d5017d66a8e99b3d79b27208a0b0d8b18f.jpg)
529
+ Figure 9: Privacy (norm and cosine leak AUC) vs Utility (train loss, test loss, and test AUC) trade-off of protection methods (Marvell, iso, no noise, max norm) at the cut layer and first layer on ISIC.
530
+
531
+ A.7.3 IMPACT OF ACTIVATION GRADIENTS’ LAYER LOCATION ON THE CORRESPONDINGLEAK AUC
532
+
533
+ In Section 5.1, we have shown that the activation gradients of not only the cut layer but also the first layer can leak the label if no protection is applied. In this section, we analyze the effect of this layer location on the degree of label leakage under our proposed attacks measured through leak AUC. Here, for the convolutional neural network trained on ISIC, we have allocated 4 Conv-ReLUMaxPool layers on the non-label party side. Here each of these 4 layers’ activation (from ReLU output) gradients can be used to infer the label. In Figure 10, we plot the progression of norm and cosine leak AUC for layer 2 and 3 in addition to the first layer (layer 1) and the cut layer (layer 4) when applying no protection or Marvell with $s = 4$ . We notice that when no protection is applied, the norm and cosine leak AUC are approximately the same across the layers and both at a very high level, indicating a strong degree of label leakage. In contrast, when Marvell is applied, the leak AUCs are much lowered to a reasonable level of around 0.6 throughout all the layers. Empirically, we notice that the leak AUCs for a given training iteration are close among all the layers with a maximum difference of around 0.05. Here it is unclear whether the earlier layers’ gradients would leak the labels more than the cut layer or not — for norm leak AUC, the earlier layers have a higher AUC values (more leakage) than the cut layer, while for cosine leak AUC, the earlier layers have a lower AUC values (less leakage) than the cut layer. Further understanding the relationship between these leak AUC values across different layers is an open question motivated by our observations here.
534
+
535
+ ![](images/56ed010866be0a341dc9aca02c15880bab8d679f13f2a8fb1257db4f8e6de8e9.jpg)
536
+ ISIC, non-label party's convolution network f with four Conv-ReLU-MaxPool layers
537
+ Figure 10: For a non-label party’s four-layer convolutional architecture trained on ISIC, we plot the progression of the norm or cosine leak AUC computed using the activation gradients from each of the four layers throughout training in (a), (b) when no random protection is applied and in (c), (d) when using Marvell with privacy hyperparameter $s = 4$ at the cut layer (layer 4). The four curves overlap in (b) at the value of 1.0. For each layer’s data in each figure, a 1-d Gaussian kernel with standard deviation of 5 is convolved with the raw 1-d array of leak AUC values to smooth out the fluctuations and make the different layers’ degree of leakage more visually distinct.
538
+
539
+ Beyond the four layer convolutional neural network trained on ISIC, we also train a new MLP model architecture on Criteo. Here instead of having 3 128-unit ReLU-activated MLP layers for the nonlabel party’s function $f$ as described in Section A.6.2, we use 8 such layers for $f$ while keeping every other architectural component the same. We plot the progression of leak AUC values on each of the eight layers in Figure 11. Here the observations are very similar to what we see in Figure 10, confirming our aforementioned conclusions in this section.
540
+
541
+ ![](images/02c92cdadf09570bf4017dec0ff34b8c73f98c3538f14856b782c4449ed8450b.jpg)
542
+ Figure 11: For a non-label party’s eight-layer MLP architecture trained on Criteo, we plot the progression of the norm or cosine leak AUC computed using the activation gradients from each of the eight layers throughout training in (a), (b) when no random protection is applied and in (c), (d) when using Marvell with privacy hyperparameter $s = 4$ at the cut layer (layer 4). The eight curves overlap in (b) at the value of 1.0. For each layer’s data in each figure, a 1-d Gaussian kernel with standard deviation of 100 is convolved with the raw 1-d array of leak AUC values to smooth out the fluctuations and make the different layers’ degree of leakage more visually distinct.
543
+
544
+ It is possible to use a local differential privacy definition to analyze our problem setup if we treat any single training example as a dataset and two examples (dataset) are adjacent if they share the same $X$ but have the opposite label $y$ . Then one can analyze the activation gradient computation function’s local DP properties. However, we choose not to use local DP in our setup for the following two reasons:
545
+
546
+ 1. We are not aware of any attacks associated with local DP that are suitable for practical use in our problem setup. In contrast, our leak AUC privacy quantification metrics have corresponding concrete, realistic attack methods that the non-label party can use in practice. 2. Even if there exists a practical attack associated with local DP, this attack would require example-level side information as the activation gradient distributions would be examplespecific. Distinguishing between such gradient distributions for a pair of adjacent examples (with same $X$ but opposite label $y$ ) would require knowledge about the two distributions specific to this example pair itself. As we have mentioned in Section 3.2, we do not assume the non-label party would realistically have access to such fine-grained knowledge. Instead, in our setup, the non-label party uses a scoring function that only takes in the communicated cut layer gradient without any additional information.
md/dev/edONMAnhLu-/edONMAnhLu-.md ADDED
@@ -0,0 +1,824 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # SURROGATE GAP MINIMIZATIONIMPROVES SHARPNESS-AWARE TRAINING
2
+
3
+ Juntang Zhuang1 ∗ j.zhuang@yale.edu
4
+
5
+ Boqing Gong2, Liangzhe Yuan2, Yin $\mathbf { C } \mathbf { u } \mathbf { i } ^ { 2 }$ , Hartwig Adam2 {bgong, lzyuan, yincui, hadam}@google.com
6
+
7
+ Nicha C. Dvornek1, Sekhar Tatikonda1, James S. Duncan1 {nicha.dvornek, sekhar.tatikonda, james.duncan}@yale.edu
8
+
9
+ Ting Liu2liuti@google.com
10
+
11
+ 1 Yale University, 2 Google Research
12
+
13
+ # ABSTRACT
14
+
15
+ The recently proposed Sharpness-Aware Minimization (SAM) improves generalization by minimizing a perturbed loss defined as the maximum loss within a neighborhood in the parameter space. However, we show that both sharp and flat minima can have a low perturbed loss, implying that SAM does not always prefer flat minima. Instead, we define a surrogate gap, a measure equivalent to the dominant eigenvalue of Hessian at a local minimum when the radius of neighborhood (to derive the perturbed loss) is small. The surrogate gap is easy to compute and feasible for direct minimization during training. Based on the above observations, we propose Surrogate Gap Guided Sharpness-Aware Minimization (GSAM), a novel improvement over SAM with negligible computation overhead. Conceptually, GSAM consists of two steps: 1) a gradient descent like SAM to minimize the perturbed loss, and 2) an ascent step in the orthogonal direction (after gradient decomposition) to minimize the surrogate gap and yet not affect the perturbed loss. GSAM seeks a region with both small loss (by step 1) and low sharpness (by step 2), giving rise to a model with high generalization capabilities. Theoretically, we show the convergence of GSAM and provably better generalization than SAM. Empirically, GSAM consistently improves generalization (e.g., $+ 3 . 2 \%$ over SAM and $+ 5 . 4 \%$ over AdamW on ImageNet top-1 accuracy for ViT-B/32). Code is released at https://sites.google.com/view/gsam-iclr22/home.
16
+
17
+ # 1 INTRODUCTION
18
+
19
+ Modern neural networks are typically highly over-parameterized and easy to overfit to training data, yet the generalization performances on unseen data (test set) often suffer a gap from the training performance (Zhang et al., 2017a). Many studies try to understand the generalization of machine learning models, including the Bayesian perspective (McAllester, 1999; Neyshabur et al., 2017), the information perspective (Liang et al., 2019), the loss surface geometry perspective (Hochreiter & Schmidhuber, 1995; Jiang et al., 2019) and the kernel perspective (Jacot et al., 2018; Wei et al., 2019). Besides analyzing the properties of a model after training, some works study the influence of training and the optimization process, such as the implicit regularization of stochastic gradient descent (SGD) (Bottou, 2010; Zhou et al., 2020), the learning rate’s regularization effect (Li et al., 2019), and the influence of the batch size (Keskar et al., 2016).
20
+
21
+ These studies have led to various modifications to the training process to improve generalization. Keskar & Socher (2017) proposed to use Adam in early training phases for fast convergence and then switch to SGD in late phases for better generalization. Izmailov et al. (2018) proposed to average weights to achieve a wider local minimum, which is expected to generalize better than sharp minima. A similar idea was later used in Lookahead (Zhang et al., 2019). Entropy-SGD (Chaudhari et al., 2019) derived the gradient of local entropy to avoid solutions in sharp valleys. Entropy-SGD has a nested Langevin iteration, inducing much higher computation costs than vanilla training.
22
+
23
+ The recently proposed Sharpness-Aware Minimization (SAM) (Foret et al., 2020) is a generic training scheme that improves generalization and has been shown especially effective for Vision Transformers (Dosovitskiy et al., 2020) when large-scale pre-training is unavailable (Chen et al., 2021). Suppose vanilla training minimizes loss $f ( w )$ (e.g., the cross-entropy loss for classification), where $w$ is the parameter. SAM minimizes a perturbed loss defined as $f _ { p } ( w ) \triangleq \operatorname* { m a x } _ { | | \delta | | \leq \rho } f ( w + \delta )$ , which is the maximum loss within radius $\rho$ centered at the model parameter $w$ . Intuitively, vanilla training seeks a single point with a low loss, while SAM searches for a neighborhood within which the maximum loss is low. However, we show that a low perturbed loss $f _ { p }$ could appear in both flat and sharp minima, implying that only minimizing $f _ { p }$ is not always sharpness-aware.
24
+
25
+ Although the perturbed loss $f _ { p } ( w )$ might disagree with sharpness, we find a surrogate gap defined as $h ( w ) \triangleq f _ { p } ( w ) - f ( w )$ agrees with sharpness — Lemma 3.3 shows that the surrogate gap $h$ is an equivalent measure of the dominant eigenvalue of Hessian at a local minimum. Inspired by this observation, we propose the Surrogate Gap Guided Sharpness Aware Minimization (GSAM) which jointly minimizes the perturbed loss $f _ { p }$ and the surrogate gap $h$ : a low perturbed loss $f _ { p }$ indicates a low training loss within the neighborhood, and a small surrogate gap $h$ avoids solutions in sharp valleys and hence narrows the generalization gap between training and test performances (Thm. 5.3). When both criteria are satisfied, we find a generalizable model with good performances.
26
+
27
+ GSAM consists of two steps for each update: 1) descend gradient $\nabla f _ { p } ( w )$ to minimize the perturbed loss $f _ { p }$ (this step is exactly the same as SAM), and 2) decompose gradient $\nabla f ( w )$ of the original loss $\bar { f } ( w )$ into components that are parallel and orthogonal to $\nabla f _ { p } ( w )$ , i.e., $\nabla f ( w ) = \nabla _ { \| } f ( w ) +$ $\nabla _ { \perp } f ( w )$ , and perform an ascent step in $\nabla _ { \perp } f ( w )$ to minimize the surrogate gap $h ( w )$ . Note that this ascent step does not change the perturbed loss $f _ { p }$ because $\nabla f _ { \perp } ( w ) \perp \mathbf { \bar { \nabla } } \nabla f _ { p } ( \bar { w } )$ by construction.
28
+
29
+ We summarize our contribution as follows:
30
+
31
+ • We define surrogate gap, which measures the sharpness at local minima and is easy to compute. • We propose the GSAM method to improve the generalization of neural networks. GSAM is widely applicable and incurs negligible computation overhead compared to SAM. • We demonstrate the convergence of GSAM and its provably better generalization than SAM. • We empirically validate GSAM over image classification tasks with various neural architectures, including ResNets (He et al., 2016), Vision Transformers (Dosovitskiy et al., 2020), and MLP-Mixers (Tolstikhin et al., 2021).
32
+
33
+ # 2 PRELIMINARIES
34
+
35
+ # 2.1 NOTATIONS
36
+
37
+ • $f ( w )$ : A loss function $f$ with parameter $w \in \mathbb { R } ^ { k }$ , where $k$ is the parameter dimension.
38
+
39
+ • $\rho _ { t } \in \mathbb { R }$ : A scalar value controlling the amplitude of perturbation at step $t$ • $\epsilon \in \mathbb { R }$ : A small positive constant (to avoid division by $) , \epsilon = 1 0 ^ { - 1 2 }$ by default).
40
+
41
+ • $\begin{array} { r } { w _ { t } ^ { a d v } \triangleq w _ { t } + \rho _ { t } \frac { \nabla f ( w _ { t } ) } { | | \nabla f ( w _ { t } ) | | + \epsilon } } \end{array}$ : The solution to $\operatorname* { m a x } _ { | | w ^ { \prime } - w _ { t } | | \leq \rho _ { t } } f ( w ^ { \prime } )$ when $\rho _ { t }$ is small.
42
+
43
+ • $\begin{array} { r } { f _ { p } ( w _ { t } ) \triangleq \operatorname* { m a x } _ { | | \delta | | \leq \rho _ { t } } f ( w _ { t } + \delta ) \approx f ( w _ { t } ^ { a d v } ) } \end{array}$ : The perturbed loss induced by $f ( w _ { t } )$ . For each $w _ { t }$ , $f _ { p } ( w _ { t } )$ returns the worst possible loss $f$ within a ball of radius $\rho _ { t }$ centered at $w _ { t }$ . When $\rho _ { t }$ is small, by Taylor expansion, the solution to the maximization problem is equivalent to a gradient ascent from $w _ { t }$ to $w _ { t } ^ { a d v }$ .
44
+
45
+ • $h ( w ) \triangleq f _ { p } ( w ) - f ( w )$ : The surrogate gap defined as the difference between $f _ { p } ( w )$ and $f ( w )$
46
+
47
+ • $\eta _ { t } \in \mathbb { R }$ : Learning rate at step $t$ .
48
+
49
+ • $\alpha \in \mathbb { R }$ : A constant value that controls the scaled learning rate of the ascent step in GSAM.
50
+
51
+ $g ^ { ( t ) } , g _ { p } ^ { ( t ) } \in \mathbb { R } ^ { k }$ : At the $t$ -th step, the noisy observation of the gradients $\nabla f ( w _ { t } )$ , $\nabla f _ { p } ( w _ { t } )$ of the original loss and perturbed loss, respectively.
52
+
53
+ ![](images/3396788a9126ef1da5043f16c4c9713656da2cf3b5a9e09a6b9971d5556bacff.jpg)
54
+
55
+ Figure 1: Consider original loss $f$ (solid line), perturbed loss $\begin{array} { r } { f _ { p } \triangleq \operatorname* { m a x } _ { | | \delta | | \leq \rho } f ( w + \delta ) } \end{array}$ (dashed line), and surrogate gap $h ( w ) \triangleq f _ { p } ( w ) - f ( w )$ . Intuitively, $f _ { p }$ is approximately a max-pooled version of $f$ with a pooling kernel of width $2 \rho$ , and SAM minimizes $f _ { p }$ . From left to right are the local minima centered at $w _ { 1 } , w _ { 2 } , w _ { 3 }$ , and the valleys become flatter. Since $f _ { p } ( w _ { 1 } ) = f _ { p } ( w _ { 3 } ) < f _ { p } ( w _ { 2 } )$ , SAM prefers $w _ { 1 }$ and $w _ { 3 }$ to $w _ { 2 }$ . However, a low $f _ { p }$ could appear in both sharp $( w _ { 1 } )$ and flat $( w _ { 3 } )$ minima, so $f _ { p }$ might disagree with sharpness. On the contrary, a smaller surrogate gap $h$ indicates a flatter loss surface (Lemma 3.3). From $w _ { 1 }$ to $w _ { 3 }$ , the loss surface is flatter, and $h$ is smaller.
56
+
57
+ • $\nabla f ( w _ { t } ) = \nabla f _ { \parallel } ( w _ { t } ) + \nabla f _ { \perp } ( w _ { t } )$ : Decompose $\nabla f ( w _ { t } )$ into parallel component $\nabla f _ { \parallel } ( \boldsymbol { w } _ { t } )$ and vertical component $\nabla f _ { \perp } ( w _ { t } )$ by projection $\nabla f ( w _ { t } )$ onto $\nabla f _ { p } ( w _ { t } )$ .
58
+
59
+ # 2.2 SHARPNESS-AWARE MINIMIZATION
60
+
61
+ Conventional optimization of neural networks typically minimizes the training loss $f ( w )$ by gradient descent w.r.t. $\nabla f ( w )$ and searches for a single point $w$ with a low loss. However, this vanilla training often falls into a sharp valley of the loss surface, resulting in inferior generalization performance (Chaudhari et al., 2019). Instead of searching for a single point solution, SAM seeks a region with low losses so that small perturbation to the model weights does not cause significant performance degradation. SAM formulates the problem as:
62
+
63
+ $$
64
+ \begin{array} { r } { \operatorname* { m i n } _ { w } f _ { p } ( w ) \mathrm { { w h e r e } } f _ { p } ( w ) \triangleq \operatorname* { m a x } _ { | | \delta | | \leq \rho } f ( w + \delta ) } \end{array}
65
+ $$
66
+
67
+ where $\rho$ is a predefined constant controlling the radius of a neighborhood. This perturbed loss $f _ { p }$ induced by $f ( w )$ is the maximum loss within the neighborhood. When the perturbed loss is minimized, the neighborhood corresponds to low losses (below the perturbed loss). For a small $\rho$ , using Taylor expansion around $w$ , the inner maximization in Eq. 1 turns into a linear constrained optimization with solution
68
+
69
+ $$
70
+ \arg \operatorname* { m a x } _ { | | \delta | | \leq \rho } f ( w + \delta ) = \arg \operatorname* { m a x } _ { | | \delta | | \leq \rho } f ( w ) + \delta ^ { \top } \nabla f ( w ) + O ( \rho ^ { 2 } ) = \rho \frac { \nabla f ( w ) } { | | \nabla f ( w ) | | }
71
+ $$
72
+
73
+ As a result, the optimization problem of SAM reduces to
74
+
75
+ $$
76
+ \operatorname* { m i n } _ { w } f _ { p } ( w ) \approx \operatorname* { m i n } _ { w } f ( w ^ { a d v } ) { \mathrm { ~ w h e r e ~ } } w ^ { a d v } \triangleq w + \rho { \frac { \nabla f ( w ) } { | | \nabla f ( w ) | | + \epsilon } }
77
+ $$
78
+
79
+ where $\epsilon$ is a scalar (default: 1e-12) to avoid division by 0, and $w ^ { a d v }$ is the “perturbed weight” with the highest loss within the neighborhood. Equivalently, SAM seeks a solution on the surface of the perturbed loss $f _ { p } ( w )$ rather than the original loss $f ( w )$ (Foret et al., 2020).
80
+
81
+ # 3 THE SURROGATE GAP MEASURES THE SHARPNESS AT A LOCAL MINIMUM
82
+
83
+ # 3.1 THE PERTURBED LOSS IS NOT ALWAYS SHARPNESS-AWARE
84
+
85
+ Despite that SAM searches for a region of low losses, we show that a solution by SAM is not guaranteed to be flat. Throughout this paper we measure the sharpness at a local minimum of loss $f ( w )$ by the dominant eigenvalue $\sigma _ { m a x }$ (eigenvalue with the largest absolute value) of Hessian. For simplicity, we do not consider the influence of reparameterization on the geometry of loss surfaces, which is thoroughly discussed in (Laurent & Massart, 2000; Kwon et al., 2021).
86
+
87
+ For $t = 1$ to $T$ 0) ρt schedule: ρt = ρmin + (ρmax−ρmin)(lr−lrmin)lr −lr ∇f (t) 1a) ∆wt = ρt ||∇f (t)||+ 1b) $w _ { t } ^ { a d v } = w _ { t } + \Delta w _ { t }$ 2) Get $\nabla f _ { p } ^ { ( t ) }$ by back-propagation at $w _ { t } ^ { a d v }$ . 3) $\begin{array} { r l r } { \mathrm { ~ } } & { { } } & { = \nabla f _ { \parallel } ^ { ( t ) } + \nabla f _ { \perp } ^ { ( t ) } } \end{array}$ Decompose $\nabla f ^ { ( t ) }$ into compo
88
+ nents that are parallel and orthogonal to $\nabla f _ { p } ^ { ( t ) }$ .
89
+
90
+ ![](images/872b59aec8a7a8aaa3e5f73fed10c4e224fe6b0af656dfe3a11efa43b6098e4f.jpg)
91
+ Figure 2: $\nabla f$ is decomposed into parallel and vertical $( \nabla f _ { \perp } )$ components by projection onto $\nabla f _ { p }$ . $\mathsf { \bar { V } } f ^ { G S A M } = \mathsf { \bar { V } } \bar { f } _ { p } - \alpha \nabla f _ { \perp }$
92
+
93
+ # Algorithm 1 GSAM Algorithm
94
+
95
+ 4) Update weights:
96
+
97
+ Vanilla $\begin{array} { r l } & { w _ { t + 1 } = w _ { t } - \eta _ { t } } \\ & { w _ { t + 1 } = w _ { t } - \eta _ { t } \nabla f _ { p } ^ { ( t ) } } \\ & { w _ { t + 1 } = w _ { t } - \eta _ { t } \big ( \nabla f _ { p } ^ { ( t ) } - \alpha \nabla f _ { \bot } ^ { ( t ) } \big ) } \end{array}$
98
+ SAM
99
+ GSAM
100
+
101
+ Lemma 3.1. For some fixed $\rho _ { ; }$ , consider two local minima $w _ { 1 }$ and $w _ { 2 }$ , $f _ { p } ( w _ { 1 } ) \leq f _ { p } ( w _ { 2 } ) \neq$ $\sigma _ { m a x } ( w _ { 1 } ) \leq \sigma _ { m a x } ( w _ { 2 } )$ , where $\sigma _ { m a x }$ is the dominant eigenvalue of the Hessian.
102
+
103
+ We leave the proof to Appendix. Fig. 1 illustrates Lemma 3.1 with an example. Consider three local minima denoted as $w _ { 1 }$ to $w _ { 3 }$ , and suppose the corresponding loss surfaces are flatter from $w _ { 1 }$ to $w _ { 3 }$ . For some fixed $\rho$ , we plot the perturbed loss $f _ { p }$ and surrogate gap $h \triangleq f _ { p } - f$ around each solution. Comparing $w _ { 2 }$ with $w _ { 3 }$ : Suppose their vanilla losses are equal, $f ( \tilde { w _ { 2 } } ) = f ( w _ { 3 } )$ , then $f _ { p } ( w _ { 2 } ) > f _ { p } ( \bar { w } _ { 3 } )$ because the loss surface is flatter around $w _ { 3 }$ , implying that SAM will prefer $w _ { 3 }$ to $w _ { 2 }$ . Comparing $w _ { 1 }$ and $w _ { 2 }$ : $f _ { p } ( w _ { 1 } ) < f _ { p } ( w _ { 2 } )$ , and SAM will favor $w _ { 1 }$ over $w _ { 2 }$ because it only cares about the perturbed loss $f _ { p }$ , even though the loss surface is sharper around $w _ { 1 }$ than $w _ { 2 }$ .
104
+
105
+ # 3.2 THE SURROGATE GAP AGREES WITH SHARPNESS
106
+
107
+ We introduce the surrogate gap that agrees with sharpness, defined as:
108
+
109
+ $$
110
+ \begin{array} { r } { h ( w ) \triangleq \operatorname* { m a x } _ { | | \delta | | \leq \rho } f ( w + \delta ) - f ( w ) \approx f ( w ^ { a d v } ) - f ( w ) } \end{array}
111
+ $$
112
+
113
+ Intuitively, the surrogate gap represents the difference between the maximum loss within the neighborhood and the loss at the center point. The surrogate gap has the following properties.
114
+
115
+ Lemma 3.2. Suppose the perturbation amplitude $\rho$ is sufficiently small, then the approximation to the surrogate gap in Eq. 4 is always non-negative, $h ( w ) \approx f ( w ^ { a d v } ) - f ( w ) \geq 0 , \forall w$ .
116
+
117
+ Lemma 3.3. For a local minimum $w ^ { * }$ , consider the dominate eigenvalue $\sigma _ { m a x }$ of the Hessian of loss $f$ as a measure of sharpness. Considering the neighborhood centered at $w ^ { * }$ with a small radius $\rho$ , the surrogate gap $h ( w ^ { * } )$ is an equivalent measure of the sharpness: $\sigma _ { m a x } \approx 2 h ( w ^ { * } ) / \rho ^ { 2 }$ .
118
+
119
+ The proof is in Appendix. Lemma 3.2 tells that the surrogate gap is non-negative, and Lemma 3.3 shows that the loss surface is flatter as $h$ gets closer to 0. The two lemmas together indicate that we can find a region with a flat loss surface by minimizing the surrogate gap $h ( w )$ .
120
+
121
+ # 4 SURROGATE GAP GUIDED SHARPNESS-AWARE MINIMIZATION
122
+
123
+ 4.1 GENERAL IDEA: SIMULTANEOUSLY MINIMIZE THE PERTURBED LOSS AND SURROGATE GAP
124
+
125
+ Inspired by the analysis in Section 3, we propose Surrogate Gap Guided Sharpness-Aware Minimzation (GSAM) to simultaneously minimize two objectives, the perturbed loss $f _ { p }$ and the surrogate gap $h$ :
126
+
127
+ $$
128
+ \operatorname* { m i n } _ { w } \left( f _ { p } ( w ) , h ( w ) \right)
129
+ $$
130
+
131
+ Intuitively, by minimizng $f _ { p }$ we search for a region with a low perturbed loss similar to SAM, and by minimizing $h$ we search for a local minimum with a flat surface. A low perturbed loss implies low training losses within the neighborhood, and a flat loss surface reduces the generalization gap between training and test performances (Chaudhari et al., 2019). When both are minimized, the solution gives rise to high accuracy and good generalization.
132
+
133
+ Potential caveat in optimization It is tempting and yet sub-optimal to combine the objectives in Eq. 5 to arrive at $\mathrm { m i n } _ { w }$ $f _ { p } ( w ) + \lambda h ( w )$ , where $\lambda$ is some positive scalar. One caveat when solving this weighted combination is the potential conflict between the gradients of the two terms, i.e., $\nabla f _ { p } ( w )$ and $\overline { { \nabla } h } ( \boldsymbol { w } )$ . We illustrate this conflict by Fig. 2, where $\bar { \nabla } h ( w ) = \nabla f _ { p } ( w ) - \nabla f ( w )$ (the grey dashed arrow) has a negative inner product with $\nabla f _ { p } ( w )$ and $\nabla f ( w )$ . Hence, the gradient descent for the surrogate gap could potentially increase the loss $f _ { p }$ , harming the model’s performance. We empirically validate this argument in Sec. 6.4.
134
+
135
+ # 4.2 GRADIENT DECOMPOSITION AND ASCENT FOR THE MULTI-OBJECTIVE OPTIMIZATION
136
+
137
+ Our primary goal is to minimize $f _ { p }$ because otherwise a flat solution of high loss is meaningless, and the minimization of $h$ should not increase $f _ { p }$ . We propose to decompose $\nabla f ( w _ { t } )$ and $\nabla h$ into components that are parallel and orthogonal to $\dot { \nabla } f _ { p } ( \boldsymbol { w } _ { t } )$ , respectively (see Fig. 2):
138
+
139
+ $$
140
+ \begin{array} { r l } & { \nabla f ( w _ { t } ) = \nabla f _ { \parallel } ( w _ { t } ) + \nabla f _ { \perp } ( w _ { t } ) } \\ & { \nabla h ( w _ { t } ) = \nabla h _ { \parallel } ( w _ { t } ) + \nabla h _ { \perp } ( w _ { t } ) } \\ & { \nabla h _ { \perp } ( w _ { t } ) = - \nabla f _ { \perp } ( w _ { t } ) } \end{array}
141
+ $$
142
+
143
+ The key is that updating in the direction of $\nabla h _ { \perp } ( w _ { t } )$ does not change the value of the perturbed loss $f _ { p } ( w _ { t } )$ because $\nabla h _ { \perp } \perp \nabla f _ { p }$ by construction. Therefore, we propose to perform a descent step in the $\nabla h _ { \perp } ( w _ { t } )$ direction, which is equivalent to an ascent step in the $\nabla f _ { \perp } ( w _ { t } )$ direction (because $\nabla h _ { \perp } = - \nabla f _ { \perp }$ by the definition of $h$ ), and achieve two goals simultaneously — it keeps the value of $f _ { p } ( w _ { t } )$ intact and meanwhile decreases the surrogate gap $h ( w _ { t } ) = f _ { p } ( w _ { t } ) - f ( w _ { t } )$ (by increasing $f ( w _ { t } )$ and not affect $f _ { p } ( w _ { t } ) )$ ).
144
+
145
+ The full GSAM Algorithm is shown in Algo. 1 and Fig. 2, where $g ^ { ( t ) } , g _ { p } ^ { ( t ) }$ are noisy observations of $\nabla f ( w _ { t } )$ and $\nabla f _ { p } ( w _ { t } )$ , respectively, and $g _ { \parallel } ^ { ( t ) } , g _ { \perp } ^ { ( t ) }$ are noisy observations of $\nabla f _ { \parallel } ( w _ { t } )$ and $\nabla f _ { \perp } ( w _ { t } )$ , respectively, by projecting $g ^ { ( t ) }$ onto $g _ { p } ^ { ( t ) }$ . We introduce a constant $\alpha$ to scale the stepsize of the ascent step. Steps 1) to 2) are the same as SAM: At current point $w _ { t }$ , step 1) takes a gradient ascent to $w _ { t } ^ { a d v }$ followed by step 2) evaluating the gradient $g _ { p } ^ { ( t ) }$ at $w _ { t } ^ { a d v }$ . Step 3) projects $g ^ { ( t ) }$ onto $g _ { p } ^ { ( t ) }$ , which requires negligible computation compared to the forward and backward passes. In step 4), $- \eta _ { t } g _ { p } ^ { ( t ) }$ is the same as in SAM and minimizes the perturbed loss $f _ { p } ( w _ { t } )$ with gradient descent, and αηtg(t)⊥ performs an ascent step in the orthogonal direction of $g _ { p } ^ { ( t ) }$ to minimize the surrogate gap $h ( w _ { t } )$ ( equivalently increase $f ( w _ { t } )$ and keep $f _ { p } ( w _ { t } )$ intact). In coding, GSAM feeds the “surrogate gradient” ∇fGSAMt , g $\nabla f _ { t } ^ { G S A M } \triangleq g _ { p } ^ { ( t ) } - \alpha g _ { \perp } ^ { ( t ) }$ to first-order gradient optimizers such as SGD and Adam.
146
+
147
+ The ascent step along $g _ { \perp } ^ { ( t ) }$ does not harm convergence SAM demonstrates that minimizing $f _ { p }$ makes the network generalize better than minimizing $f$ . Even though our ascent step along $g _ { \perp } ^ { ( t ) }$ increases $f ( w )$ , it does not affect $f _ { p } ( w )$ , so GSAM still decreases the perturbed loss $f _ { p }$ in a way similar to SAM. In Thm. 5.1, we formally prove the convergence of GSAM. In Sec. 6 and Appendix C, we empirically validate that the loss decreases and accuracy increases with training.
148
+
149
+ Illustration with a toy example We demonstrate different algorithms by a numerical toy example shown in Fig. 3. The trajectory of GSAM is closer to the ridge and tends to find a flat minimum. Intuitively, since the loss surface is smoother along the ridge than in sharp local minima, the surrogate gap $h ( w )$ is small near the ridge, and the ascent step in GSAM minimizes $h$ to pushes the trajectory closer to the ridge. More concretely, $\nabla f ( w _ { t } )$ points to a sharp local solution and deviates from the ridge; in contrast, $w _ { t } ^ { a d v }$ is closer to the ridge and $\nabla f ( w _ { t } ^ { a d v } )$ is closer to the ridge descent direction than $\nabla f ( w _ { t } )$ . Note that $\nabla f _ { t } ^ { G S A M }$ and $\nabla f ( w _ { t } )$ always lie at different sides of $\nabla f _ { p } ( w _ { t } )$ by construction (see Fig. 2), hence $\nabla f _ { t } ^ { G S A M }$ pushes the trajectory closer to the ridge than $\nabla f _ { p } ( w _ { t } )$ does. The trajectory of GSAM is like descent along the ridge and tends to find flat minima.
150
+
151
+ ![](images/64c1996c768babc0d124bb80d0862cf1e6d992f4b1b70cc711ed289334144e3d.jpg)
152
+ Figure 3: Consider the loss surface with a few sharp local minima. Left: Overview of the procedures of SGD, SAM and GSAM. SGD takes a descent step at $w _ { t }$ using $\nabla f ( w _ { t } )$ (orange), which points to a sharp local minima. SAM first performs gradient ascent in the direction of $\nabla f ( w _ { t } )$ to reach $w _ { t } ^ { a d v }$ with a higher loss, followed by descent with gradient $\nabla f ( w _ { t } ^ { a d v } )$ (green) at the perturbed weight. Based on $\nabla f ( w _ { t } )$ and $\nabla f ( w _ { t } ^ { a d v } )$ , GSAM updates in a new direction (red) that points to a flatter region. Right: Trajectories by different methods. SGD and SAM fall into different sharp local minima, while GSAM reaches a flat region. A video is in the supplement for better visualization.
153
+
154
+ # 5 THEORETICAL PROPERTIES OF GSAM
155
+
156
+ # 5.1 CONVERGENCE DURING TRAINING
157
+
158
+ Theorem 5.1. Consider a non-convex function $f ( w )$ with Lipschitz-smooth constant $L$ and lower bound $f _ { m i n }$ . Suppose we can access a noisy, bounded observation $g ^ { ( t ) } \ ( \vert \vert g ^ { ( t ) } \vert \vert _ { 2 } \leq G , \forall t )$ of the true gradient $\nabla f ( w _ { t } )$ at the $t$ -th step. For some constant $\alpha$ , with learning rate $\eta _ { t } = \eta _ { 0 } / \sqrt { t }$ , and perturbation amplitude $\rho _ { t }$ proportional to the learning rate, e.g., $\rho _ { t } = \rho _ { 0 } / \sqrt { t }$ , we have
159
+
160
+ $$
161
+ \frac { 1 } { T } \sum _ { t = 1 } ^ { T } \mathbb { E } \Big | \Big | \nabla f _ { p } ( w _ { t } ) \Big | \Big | _ { 2 } ^ { 2 } \leq \frac { C _ { 1 } + C _ { 2 } \log T } { \sqrt { T } } , \quad \frac { 1 } { T } \sum _ { t = 1 } ^ { T } \mathbb { E } \Big | \Big | \nabla f ( w _ { t } ) \Big | \Big | _ { 2 } ^ { 2 } \leq \frac { C _ { 3 } + C _ { 4 } \log T } { \sqrt { T } }
162
+ $$
163
+
164
+ where $C _ { 1 } , C _ { 2 } , C _ { 3 } , C _ { 4 }$ are some constants.
165
+
166
+ Thm. 5.1 implies both $f _ { p }$ and $f$ converge in GSAM at rate $O ( \log T / \sqrt { T } )$ for non-convex stochastic optimization, matching the convergence rate of first-order gradient optimizers like Adam.
167
+
168
+ # 5.2 GENERALIZATION OF GSAM
169
+
170
+ In this section, we show the surrogate gap in GSAM is provably lower than SAM’s, so GSAM is expected to find a smoother minimum with better generalization.
171
+
172
+ Theorem 5.2 (PAC-Bayesian Theorem (McAllester, 2003)). Suppose the training set has m elements drawn i.i.d. from the true distribution, and denote the loss on the training set as ${ \widehat { f } } ( w ) =$ Pmi=1 f (w, xi), where we use xi to denote the (input, target) pair of the i-th element. Let w be learned from the training set. Suppose $w$ is drawn from posterior distribution $\mathcal { Q } .$ Denote the prior distribution (independent of training) as $\mathcal { P }$ , then
173
+
174
+ $$
175
+ \mathbb { E } _ { w \sim Q } \mathbb { E } _ { x } f ( w , x ) \le \mathbb { E } _ { w \sim Q } \widehat { f } ( w ) + 4 \sqrt { \Big ( K L ( Q | | \mathcal { P } ) + \log \frac { 2 m } { a } \Big ) / m } w i t h \ p r o b a b i l i t y \ a t \ l e a s t 1 - a
176
+ $$
177
+
178
+ Corollary 5.2.1. Suppose perturbation $\delta$ is drawn from distribution $\delta \sim \mathcal { N } ( 0 , b ^ { 2 } I ^ { k } ) , \delta \in \mathbb { R } ^ { k }$ , $k$ is the dimension of $w$ , then with probability at least $\left( 1 - a \right) \left[ 1 - e ^ { - \left( \frac { \rho } { \sqrt { 2 } b } - \sqrt { k } \right) ^ { 2 } } \right]$
179
+
180
+ $$
181
+ \begin{array} { r l } & { \mathbb { E } _ { w \sim Q } \mathbb { E } _ { x } f ( w , x ) \le \widehat { h } + C + 4 \sqrt { \Big ( K L ( Q | \mathcal { P } ) + \log \frac { 2 m } { a } \Big ) / m } } \\ & { \widehat { h } \triangleq \operatorname* { m a x } _ { | | \delta | | _ { 2 } \le \rho } \widehat { f } ( w + \delta ) - \widehat { f } ( w ) = \displaystyle \frac { 1 } { m } \sum _ { i = 1 } ^ { m } \Big [ \operatorname* { m a x } _ { | | \delta | | _ { 2 } \le \rho } f ( w + \delta , x _ { i } ) - f ( w , x _ { i } ) \Big ] } \end{array}
182
+ $$
183
+
184
+ where $C = { \widehat { f } } ( w )$ is the empirical training loss, and $\widehat { h }$ is the surrogate gap evaluated on the training set.
185
+
186
+ Corollary 5.2.1 implies that minimizing $\widehat { h }$ (right hand side of Eq. 7) is expected to achieve a tighter upper bound of the generalization performance (left hand side of Eq. 7). The third term on the right of Eq. 7 is typically hard to analyze and often simplified to $L 2$ regularization (Foret et al., 2020). Note that $f _ { p } = C + \widehat { h }$ only holds when $\rho _ { t r a i n }$ (the perturbation amplitude specified by users during training) equals $\rho _ { t r u e }$ (the ground truth value determined by underlying data distribution); when $\rho _ { t r a i n } \neq \rho _ { t r u e }$ , $m i n ( f _ { p } , \widehat { h } )$ is more effective than $m i n ( f _ { p } )$ in terms of minimizing generalization loss. A detailed discussion is in Appendix A.7.
187
+
188
+ Theorem 5.3 (Unlike SAM, GSAM decreases the surrogate gap). Under the assumption in Thm. 5.1, Thm. 5.2 and Corollary 5.2.1, we assume the Hessian has a lower-bound $| \sigma | _ { m i n }$ on the absolute value of eigenvalue, and the variance of noisy observation $g ^ { ( t ) }$ is lower-bounded by $c ^ { 2 }$ . The surrogate gap h can be minimized by the ascent step along the orthogonal direction $g _ { \perp } ^ { ( t ) }$ . During training we minimize the sample estimate of $h$ . We use $\Delta \widehat { h } _ { t }$ to denote the amount that the ascent step in GSAM decreases $\widehat { h }$ for the $t$ -th step. Compared to SAM, the proposed method generates a total decrease in surrogate gap $\Sigma _ { t = 1 } ^ { T } \Delta \widehat { h } _ { t }$ , which is bounded by
189
+
190
+ $$
191
+ \frac { \alpha c ^ { 2 } \rho _ { 0 } ^ { 2 } \eta _ { 0 } | \sigma | _ { m i n } ^ { 2 } } { G ^ { 2 } } \le \operatorname* { l i m } _ { T \to \infty } \sum _ { t = 1 } ^ { T } \Delta \widehat { h } _ { t } \le 2 . 7 \alpha L ^ { 2 } \eta _ { 0 } \rho _ { 0 } ^ { 2 }
192
+ $$
193
+
194
+ We provide proof in the appendix. The lower-bound of provably non-trivial decrease in the surrogate gap. Com $\Sigma _ { t = 1 } ^ { T } \Delta \widehat { h } _ { t }$ indicates that GSAM achieves aCorollary 5.2.1, GSAM provably improves the generalization performance over SAM.
195
+
196
+ # 6 EXPERIMENTS
197
+
198
+ # 6.1 GSAM IMPROVES TEST PERFORMANCE ON VARIOUS MODEL ARCHITECTURES
199
+
200
+ We conduct experiments with ResNets (He et al., 2016), Vision Transformers (ViTs) (Dosovitskiy et al., 2020) and MLP-Mixers (Tolstikhin et al., 2021). Following the settings by Chen et al. (2021), we train on the ImageNet-1k (Deng et al., 2009) training set using the Inception-style (Szegedy et al., 2015) pre-processing without extra training data or strong augmentation. For all models, we search for the best learning rate and weight decay for vanilla training, and then use the same values for the experiments with SAM and GSAM. For ResNets, we search for $\rho$ from 0.01 to 0.05 with a stepsize 0.01. For ViTs and Mixers, we search for $\rho$ from 0.05 to 0.6 with a stepsize 0.05. In GSAM, we search for $\alpha$ in $\{ 0 . 0 1 , 0 . 0 2 , 0 . 0 3 \}$ for ResNets and $\alpha$ in $\{ 0 . 1 , 0 . 2 , 0 . 3 \}$ for ViTs and Mixers. Considering that each step in SAM and GSAM requires twice the computation of vanilla training, we experiment with the vanilla training for twice the epochs of SAM and GSAM, but we observe no significant improvements from the longer training (Table 5 in appendix). We summarize the best hyper-parameters for each model in Appendix B.
201
+
202
+ We report the performances on ImageNet (Deng et al., 2009), ImageNet-v2 (Recht et al., 2019) and ImageNet-Real (Beyer et al., 2020) in Table 1. GSAM consistently improves over SAM and vanilla training (with SGD or AdamW): on ViT-B/32, GSAM achieves $+ 5 . 4 \%$ improvement over AdamW and $+ 3 . 2 \%$ over SAM in top-1 accuracy; on Mixer-B/32, GSAM achieves $+ 1 1 . 1 \%$ over AdamW and $+ 1 . 2 \%$ over SAM. We ignore the standard deviation since it is typically negligible $( < 0 . 1 \% )$ compared to the improvements. We also test the generalization performance on out-of-distribution data (ImageNet-R and ImageNet-C), and the observation is consistent with that on ImageNet, e.g., $+ 5 . 1 \%$ on ImageNet-R and $+ 5 . 9 \%$ on ImageNet-C for Mixer-B/32.
203
+
204
+ # 6.2 GSAM FINDS A MINIMUM WHOSE HESSIAN HAS SMALL DOMINANT EIGENVALUES
205
+
206
+ Lemma 3.3 indicates that the surrogate gap $h$ is an equivalent measure of the dominant eigenvalue of the Hessian, and minimizing $h$ equivalently searches for a flat minimum. We empirically validate this in Fig. 4. As shown in the left subfigure, for some fixed $\rho$ , increasing $\alpha$ decreases the dominant value and improves generalization (test accuracy). In the middle subfigure, we plot the dominant eigenvalues estimated by the surrogate gap, $\sigma _ { m a x } \approx 2 h / \rho ^ { 2 }$ (Lemma 3.3). In the right subfigure, we directly calculate the dominant eigenvalues using the power-iteration (Mises & Pollaczek-Geiringer, 1929). The estimated dominant eigenvalues (middle) match the real eigenvalues $\sigma _ { m a x }$ (right) in terms of the trend that $\sigma _ { m a x }$ decreases with $\alpha$ and $\rho$ . Note that the surrogate gap $h$ is derived over the whole training set, while the measured eigenvalues are over a subset to save computation. These results show that the ascent step in GSAM minimizes the dominant eigenvalue by minimizing the surrogate loss, validating $\mathrm { T h m } 5 . 3$ .
207
+
208
+ Table 1: Top-1 Accuracy $( \% )$ on ImageNet datasets for ResNets, ViTs and MLP-Mixers trained with Vanilla SGD or AdamW, SAM, and GSAM optimizers.
209
+
210
+ <table><tr><td>Model</td><td>Training</td><td>ImageNet-v1</td><td>ImageNet-Real</td><td>ImageNet-V2</td><td>ImageNet-R</td><td>ImageNet-C</td></tr><tr><td colspan="7">ResNet</td></tr><tr><td rowspan="3">ResNet50</td><td>Vanilla (SGD)</td><td>76.0</td><td>82.4</td><td>63.6</td><td>22.2</td><td>44.6</td></tr><tr><td>SAM</td><td>76.9</td><td>83.3</td><td>64.4</td><td>23.8</td><td>46.5</td></tr><tr><td>GSAM</td><td>77.2</td><td>83.9</td><td>64.6</td><td>23.6</td><td>47.6</td></tr><tr><td rowspan="3">ResNet101</td><td>Vanilla (SGD)</td><td>77.8</td><td>83.9</td><td>65.3</td><td>24.4</td><td>48.5</td></tr><tr><td>SAM</td><td>78.6</td><td>84.8</td><td>66.7</td><td>25.9</td><td>51.3</td></tr><tr><td>GSAM</td><td>78.9</td><td>85.2</td><td>67.3</td><td>26.3</td><td>51.8</td></tr><tr><td rowspan="3">ResNet152</td><td>Vanilla (SGD)</td><td>78.5</td><td>84.2</td><td>66.3</td><td>25.3</td><td>50.0</td></tr><tr><td>SAM</td><td>79.3</td><td>84.9</td><td>67.3</td><td>25.7</td><td>52.2</td></tr><tr><td>GSAM</td><td>80.0</td><td>85.9</td><td>68.6</td><td>27.3</td><td>54.1</td></tr><tr><td colspan="7"></td></tr><tr><td rowspan="3">ViT-S/32</td><td>Vanilla (AdamW)</td><td>68.4</td><td>Vision Transformer 75.2</td><td>54.3</td><td></td><td></td></tr><tr><td>SAM</td><td>70.5</td><td>77.5</td><td>56.9</td><td>19.0 21.4</td><td>43.3</td></tr><tr><td>GSAM</td><td>73.8</td><td>80.4</td><td>60.4</td><td>22.5</td><td>46.2 48.2</td></tr><tr><td rowspan="3">ViT-S/16</td><td>Vanilla (AdamW)</td><td>74.4</td><td>80.4</td><td>61.7</td><td>20.0</td><td>46.5</td></tr><tr><td>SAM</td><td>78.1</td><td>84.1</td><td>65.6</td><td>24.7</td><td>53.0</td></tr><tr><td>GSAM</td><td>79.5</td><td>85.3</td><td>67.3</td><td>25.3</td><td>53.3</td></tr><tr><td rowspan="3">ViT-B/32</td><td>Vanilla (AdamW)</td><td>71.4</td><td>77.5</td><td>57.5</td><td>23.4</td><td>44.0</td></tr><tr><td>SAM</td><td>73.6</td><td>80.3</td><td>60.0</td><td>24.0</td><td>50.7</td></tr><tr><td>GSAM</td><td>76.8</td><td>82.7</td><td>63.0</td><td>25.1</td><td>51.7</td></tr><tr><td rowspan="3">ViT-B/16</td><td>Vanilla (AdamW)</td><td>74.6</td><td>79.8</td><td>61.3</td><td>20.1</td><td>46.6</td></tr><tr><td>SAM</td><td>79.9</td><td>85.2</td><td>67.5</td><td>26.4</td><td>56.5</td></tr><tr><td>GSAM</td><td>81.0</td><td>86.5</td><td>69.2</td><td>27.1</td><td>55.7</td></tr><tr><td colspan="7"></td></tr><tr><td rowspan="3">Mixer-S/32</td><td>Vanilla (AdamW)</td><td>63.9</td><td>MLP-Mixer 70.3</td><td>49.5</td><td>16.9</td><td>35.2</td></tr><tr><td>SAM</td><td>66.7</td><td>73.8</td><td>52.4</td><td>18.6</td><td>39.3</td></tr><tr><td>GSAM</td><td>68.6</td><td>75.8</td><td>55.0</td><td>22.6</td><td>44.6</td></tr><tr><td rowspan="3">Mixer-S/16</td><td>Vanilla (AdamW)</td><td>68.8</td><td>75.1</td><td>54.8</td><td>15.9</td><td>35.6</td></tr><tr><td>SAM</td><td>72.9</td><td>79.8</td><td>58.9</td><td>20.1</td><td>42.0</td></tr><tr><td>GSAM</td><td>75.0</td><td>81.7</td><td>61.9</td><td>23.7</td><td>48.5</td></tr><tr><td rowspan="3">Mixer-S/8</td><td>Vanilla (AdamW)</td><td>70.2</td><td>76.2</td><td>56.1</td><td>15.4</td><td>34.6</td></tr><tr><td>SAM</td><td>75.9</td><td>82.5</td><td>62.3</td><td>20.5</td><td>42.4</td></tr><tr><td>GSAM</td><td>76.8</td><td>83.4</td><td>64.0</td><td>24.6</td><td>47.8</td></tr><tr><td rowspan="3">Mixer-B/32</td><td>Vanilla (AdamW)</td><td>62.5</td><td>68.1</td><td>47.6</td><td>14.6</td><td>33.8</td></tr><tr><td>SAM</td><td>72.4</td><td>79.0</td><td>58.0</td><td>22.8</td><td>46.2</td></tr><tr><td>GSAM</td><td>73.6</td><td>80.2</td><td>59.9</td><td>27.9</td><td>52.1</td></tr><tr><td rowspan="3">Mixer-B/16</td><td>Vanilla (AdamW)</td><td>66.4</td><td>72.1</td><td>50.8</td><td>14.5</td><td>33.8</td></tr><tr><td>SAM</td><td>77.4</td><td>83.5</td><td>63.9</td><td>24.7</td><td>48.8</td></tr><tr><td>GSAM</td><td>77.8</td><td>84.0</td><td>64.9</td><td>28.3</td><td>54.4</td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr></table>
211
+
212
+ ![](images/0ab9a693376a9164b50af0714b51b883842522baa5f9217592cd485202ddf052.jpg)
213
+ Figure 4: Influence of $\rho$ (set as constant for ease of comparison, other experiments use decayed $\rho _ { t }$ schedule) and $\alpha$ on the training of ViT-B/32. Left: Top-1 accuracy on ImageNet. Middle: Estimation of the dominant eigenvalues from the surrogate gap, $\sigma _ { m a x } \approx 2 h / \rho ^ { 2 }$ . Right: Dominant eigenvalues of the Hessian calculated via the power iteration. Middle and right figures match in the trend of curves, validating that the surrogate gap can be viewed as a proxy of the dominant eigenvalue of Hessian.
214
+
215
+ ![](images/cd91a39c4fda1aa38347bb16bcf091af8803ccb572f7dae609b6c2bda9d3fc93.jpg)
216
+ Figure 5: Top-1 accuracy of Mixer-S/32 trained with different methods. “+ascent” represents applying the ascent step in Algo. 1 to an optimizer. Note that our GSAM is described as SAM+ascent $\mathbf { \Lambda } = \mathbf { G S A M } )$ for consistency.
217
+
218
+ Table 2: Results $( \% )$ of GSAM and $\operatorname* { m i n } ( f _ { p } + \lambda h )$ on ViT-B/32
219
+
220
+ <table><tr><td>Dataset</td><td>min(fp+Xh)</td><td>GSAM</td></tr><tr><td>ImageNet</td><td>75.4</td><td>76.8</td></tr><tr><td>ImageNet-Real</td><td>81.1</td><td>82.7</td></tr><tr><td>ImageNet-v2</td><td>60.9</td><td>63.0</td></tr><tr><td>ImageNet-R</td><td>23.9</td><td>25.1</td></tr></table>
221
+
222
+ Table 3: Transfer learning results (top-1 accuracy, $\%$ )
223
+
224
+ <table><tr><td></td><td colspan="3">ViT-B/16</td><td colspan="3">ViT-S/16</td></tr><tr><td></td><td>Vanilla</td><td>SAM</td><td>GSAM</td><td>Vanilla</td><td>SAM</td><td>GSAM</td></tr><tr><td>Cifar10</td><td>98.1</td><td>98.6</td><td>98.8</td><td>97.6</td><td>98.2</td><td>98.4</td></tr><tr><td>Cifar100</td><td>87.6</td><td>89.1</td><td>89.7</td><td>85.7</td><td>87.6</td><td>88.1</td></tr><tr><td>Flowers</td><td>88.5</td><td>91.8</td><td>91.2</td><td>86.4</td><td>91.5</td><td>90.3</td></tr><tr><td>Pets</td><td>91.9</td><td>93.1</td><td>94.4</td><td>90.4</td><td>92.9</td><td>93.5</td></tr><tr><td>mean</td><td>91.5</td><td>93.2</td><td>93.5</td><td>90.0</td><td>92.6</td><td>92.6</td></tr></table>
225
+
226
+ # 6.3 COMPARISON WITH METHODS IN THE LITERATURE
227
+
228
+ Section 6.1 compares GSAM to SAM and vanilla training. In this subsection, we further compare GSAM against Entropy-SGD (Chaudhari et al., 2019) and Adaptive-SAM (ASAM) (Kwon et al., 2021), which are designed to improve generalization. Note that Entropy-SGD uses SGD in the inner Langevin iteration and can be combined with other base optimizers such as AdamW as the outer loop. For Entropy-SGD, we find the hyper-parameter “scope” from 0.0 and 0.9, and search for the inner-loop iteration number between 1 and 14. For ASAM, we search for $\rho$ between 1 and 7 $( 1 0 \times$ larger than in SAM) as recommended by the ASAM authors. Note that the only difference between ASAM and SAM is the derivation of the perturbation, so both can be combined with the proposed ascent step. As shown in Fig. 5, the proposed ascent step increases test accuracy when combined with both SAM and ASAM and outperforms Entropy-SGD and vanilla training.
229
+
230
+ # 6.4 ADDITIONAL STUDIES
231
+
232
+ GSAM outperforms a weighted combination of the perturbed loss and surrogate gap With an example in Fig. 2, we demonstrate that directly minimizing $f _ { p } ( w ) + \lambda h ( w )$ as discussed in Sec. 4.1 is sub-optimal because $\nabla h ( w )$ could conflict with $\nabla f _ { p } ( w )$ and $\nabla f ( w )$ . We empirically validate this argument on ViT-B/32. We search for $\lambda$ between 0.0 and 0.5 with a step 0.1 and search for $\rho$ in the same grid as SAM and GSAM. We report the best accuracy of each method. Top-1 accuracy in Table 2 show the superior performance of GSAM, validating our analysis.
233
+
234
+ $\operatorname* { m i n } ( f _ { p } , h )$ vs. $\operatorname* { m i n } ( f , h )$ GSAM solves $\operatorname* { m i n } ( f _ { p } , h )$ by descent in $\nabla f _ { p }$ , decomposing $\nabla f$ onto $\nabla f _ { p }$ , and an ascent step in the orthogonal direction to increase $f$ while keep $f _ { p }$ intact. Alternatively, we can also optimize $\operatorname* { m i n } ( f , h )$ by descent in $\nabla f$ , decomposing $\nabla f _ { p }$ onto $\nabla f$ , and a descent step in the orthogonal direction to decrease $f _ { p }$ while keep $f$ intact. The two GSAM variations perform similarly (see Fig. 6, right). We choose $\operatorname* { m i n } ( f _ { p } , h )$ mainly to make the minimal change to SAM.
235
+
236
+ GSAM benefits transfer learning Using weights trained on ImageNet-1k, we finetune models with SGD on downstream tasks including the CIFAR10/CIFAR100 (Krizhevsky et al., 2009), Oxfordflowers (Nilsback & Zisserman, 2008) and Oxford-IITPets (Parkhi et al., 2012). Results in Table 3 shows that GSAM leads to better transfer performance than vanilla training and SAM.
237
+
238
+ ![](images/819890a555e7fa3dd273a452709db6a6112e787f55b5798c88bf87f762261419.jpg)
239
+ Figure 6: Top-1 accuracy of ViT-B/32 for the additional studies (Section 6.4). Left: from left to right are performances under different data augmentations (details in Appendix B.3) , where the vanilla method is trained for $2 \times$ the epochs. Middle: performance with different base optimizers. Right: Comparison between $\operatorname* { m i n } ( f _ { p } , h )$ and $\operatorname* { m i n } ( f , h )$ .
240
+
241
+ GSAM remains effective under various data augmentations We plot the top-1 accuracy of a ViT-B/32 model under various Mixup (Zhang et al., 2017b) augmentations in Fig. 6 (left subfigure). Under different augmentations, GSAM consistently outperforms SAM and vanilla training.
242
+
243
+ GSAM is compatible with different base optimizers GSAM is generic and applicable to various base optimizers. We compare vanilla training, SAM and GSAM using AdamW (Loshchilov & Hutter, 2017) and AdaBelief (Zhuang et al., 2020) with default hyper-parameters. Fig. 6 (middle subfigure) shows that GSAM performs the best, and SAM improves over vanilla training.
244
+
245
+ # 7 CONCLUSION
246
+
247
+ We propose the surrogate gap as an equivalent measure of sharpness which is easy to compute and feasible to optimize. We propose the GSAM method, which improves the generalization over SAM at negligible computation cost. We show the convergence and provably better generalization of GSAM compared to SAM, and validate the superior performance of GSAM on various models.
248
+
249
+ # ACKNOWLEDGEMENT
250
+
251
+ We would like to thank Xiangning Chen (UCLA) and Hossein Mobahi (Google) for discussions, Yi Tay (Google) for help with datasets, and Yeqing Li, Xianzhi Du, and Shawn Wang (Google) for help with TensorFlow implementation.
252
+
253
+ # ETHICS STATEMENT
254
+
255
+ This paper focuses on the development of optimization methodologies and can be applied to the training of different deep neural networks for a wide range of applications. Therefore, the ethical impact of our work would primarily be determined by the specific models that are trained using our new optimization strategy.
256
+
257
+ # REPRODUCIBILITY STATEMENT
258
+
259
+ We provide the detailed proof of theoretical results in Appendix A and provide the data preprocessing and hyper-parameter settings in Appendix B. Together with the references to existing works and public codebases, we believe the paper contains sufficient details to ensure reproducibility. We plan to release the models trained by using GSAM upon publication.
260
+
261
+ # REFERENCES
262
+
263
+ Randall Balestriero, Jerome Pesenti, and Yann LeCun. Learning in high dimension always amounts to extrapolation. arXiv preprint arXiv:2110.09485, 2021.
264
+
265
+ Lucas Beyer, Olivier J. Henaff, Alexander Kolesnikov, Xiaohua Zhai, and Aaron van den Oord. Are we done with imagenet? arXiv preprint arXiv:2002.05709, 2020.
266
+
267
+ Leon Bottou. Large-scale machine learning with stochastic gradient descent. In ´ Proceedings of COMPSTAT’2010, pp. 177–186. Springer, 2010.
268
+
269
+ Pratik Chaudhari, Anna Choromanska, Stefano Soatto, Yann LeCun, Carlo Baldassi, Christian Borgs, Jennifer Chayes, Levent Sagun, and Riccardo Zecchina. Entropy-sgd: Biasing gradient descent into wide valleys. Journal of Statistical Mechanics: Theory and Experiment, 2019(12): 124018, 2019.
270
+
271
+ Xiangning Chen, Cho-Jui Hsieh, and Boqing Gong. When vision transformers outperform resnets without pretraining or strong data augmentations, 2021.
272
+
273
+ Ekin D Cubuk, Barret Zoph, Dandelion Mane, Vijay Vasudevan, and Quoc V Le. Autoaugment: Learning augmentation policies from data. arXiv preprint arXiv:1805.09501, 2018.
274
+
275
+ Alex Damian, Tengyu Ma, and Jason Lee. Label noise sgd provably prefers flat global minimizers. arXiv preprint arXiv:2106.06530, 2021.
276
+
277
+ 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.
278
+
279
+ Terrance DeVries and Graham W Taylor. Improved regularization of convolutional neural networks with cutout. arXiv preprint arXiv:1708.04552, 2017.
280
+
281
+ 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.
282
+
283
+ John Duchi, Elad Hazan, and Yoram Singer. Adaptive subgradient methods for online learning and stochastic optimization. Journal of machine learning research, 12(Jul):2121–2159, 2011.
284
+
285
+ Pierre Foret, Ariel Kleiner, Hossein Mobahi, and Behnam Neyshabur. Sharpness-aware minimization for efficiently improving generalization. arXiv preprint arXiv:2010.01412, 2020.
286
+
287
+ Xavier Gastaldi. Shake-shake regularization. arXiv preprint arXiv:1705.07485, 2017.
288
+
289
+ 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.
290
+
291
+ Byeongho Heo, Sanghyuk Chun, Seong Joon Oh, Dongyoon Han, Sangdoo Yun, Gyuwan Kim, Youngjung Uh, and Jung-Woo Ha. Adamp: Slowing down the slowdown for momentum optimizers on scale-invariant weights. arXiv preprint arXiv:2006.08217, 2020.
292
+
293
+ Sepp Hochreiter and Jurgen Schmidhuber. Simplifying neural nets by discovering flat minima. In ¨ Advances in neural information processing systems, pp. 529–536, 1995.
294
+
295
+ Pavel Izmailov, Dmitrii Podoprikhin, Timur Garipov, Dmitry Vetrov, and Andrew Gordon Wilson. Averaging weights leads to wider optima and better generalization. arXiv preprint arXiv:1803.05407, 2018.
296
+
297
+ Arthur Jacot, Franck Gabriel, and Clement Hongler. Neural tangent kernel: Convergence and gen- ´ eralization in neural networks. arXiv preprint arXiv:1806.07572, 2018.
298
+
299
+ Yiding Jiang, Behnam Neyshabur, Hossein Mobahi, Dilip Krishnan, and Samy Bengio. Fantastic generalization measures and where to find them. arXiv preprint arXiv:1912.02178, 2019.
300
+
301
+ Nitish Shirish Keskar and Richard Socher. Improving generalization performance by switching from adam to sgd. arXiv preprint arXiv:1712.07628, 2017.
302
+
303
+ Nitish Shirish Keskar, Dheevatsa Mudigere, Jorge Nocedal, Mikhail Smelyanskiy, and Ping Tak Peter Tang. On large-batch training for deep learning: Generalization gap and sharp minima. arXiv preprint arXiv:1609.04836, 2016.
304
+
305
+ Alex Krizhevsky, Geoffrey Hinton, et al. Learning multiple layers of features from tiny images. 2009.
306
+
307
+ Jungmin Kwon, Jeongseop Kim, Hyunseo Park, and In Kwon Choi. Asam: Adaptive sharpnessaware minimization for scale-invariant learning of deep neural networks. arXiv preprint arXiv:2102.11600, 2021.
308
+
309
+ Beatrice Laurent and Pascal Massart. Adaptive estimation of a quadratic functional by model selection. Annals of Statistics, pp. 1302–1338, 2000.
310
+
311
+ Yuanzhi Li, Colin Wei, and Tengyu Ma. Towards explaining the regularization effect of initial large learning rate in training neural networks. arXiv preprint arXiv:1907.04595, 2019.
312
+
313
+ Tengyuan Liang, Tomaso Poggio, Alexander Rakhlin, and James Stokes. Fisher-rao metric, geometry, and complexity of neural networks. In The 22nd International Conference on Artificial Intelligence and Statistics, pp. 888–896. PMLR, 2019.
314
+
315
+ Tao Lin, Lingjing Kong, Sebastian Stich, and Martin Jaggi. Extrapolation for large-batch training in deep learning. In International Conference on Machine Learning, pp. 6094–6104. PMLR, 2020.
316
+
317
+ Liyuan Liu, Haoming Jiang, Pengcheng He, Weizhu Chen, Xiaodong Liu, Jianfeng Gao, and Jiawei Han. On the variance of the adaptive learning rate and beyond. arXiv preprint arXiv:1908.03265, 2019.
318
+
319
+ Ilya Loshchilov and Frank Hutter. Decoupled weight decay regularization. arXiv preprint arXiv:1711.05101, 2017.
320
+
321
+ Liangchen Luo, Yuanhao Xiong, Yan Liu, and Xu Sun. Adaptive gradient methods with dynamic bound of learning rate. arXiv preprint arXiv:1902.09843, 2019.
322
+
323
+ David McAllester. Simplified pac-bayesian margin bounds. In Learning theory and Kernel machines, pp. 203–215. Springer, 2003.
324
+
325
+ David A McAllester. Pac-bayesian model averaging. In Proceedings of the twelfth annual conference on Computational learning theory, pp. 164–170, 1999.
326
+
327
+ RV Mises and Hilda Pollaczek-Geiringer. Praktische verfahren der gleichungsauflosung. ¨ ZAMMJournal of Applied Mathematics and Mechanics/Zeitschrift fur Angewandte Mathematik und ¨ Mechanik, 9(1):58–77, 1929.
328
+
329
+ Rafael Muller, Simon Kornblith, and Geoffrey Hinton. When does label smoothing help? ¨ arXiv preprint arXiv:1906.02629, 2019.
330
+
331
+ Behnam Neyshabur, Srinadh Bhojanapalli, and Nathan Srebro. A pac-bayesian approach to spectrally-normalized margin bounds for neural networks. arXiv preprint arXiv:1707.09564, 2017.
332
+
333
+ 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.
334
+
335
+ 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.
336
+
337
+ Benjamin Recht, Rebecca Roelofs, Ludwig Schmidt, and Vaishaal Shankar. Do imagenet classifiers generalize to imagenet? In International Conference on Machine Learning, pp. 5389–5400, 2019.
338
+
339
+ Sashank J Reddi, Satyen Kale, and Sanjiv Kumar. On the convergence of adam and beyond. arXiv preprint arXiv:1904.09237, 2019.
340
+
341
+ David E Rumelhart, Geoffrey E Hinton, and Ronald J Williams. Learning internal representations by error propagation. Technical report, California Univ San Diego La Jolla Inst for Cognitive Science, 1985.
342
+
343
+ 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.
344
+
345
+ 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.
346
+
347
+ Ilya Tolstikhin, Neil Houlsby, Alexander Kolesnikov, Lucas Beyer, Xiaohua Zhai, Thomas Unterthiner, Jessica Yung, Daniel Keysers, Jakob Uszkoreit, Mario Lucic, et al. Mlp-mixer: An all-mlp architecture for vision. arXiv preprint arXiv:2105.01601, 2021.
348
+
349
+ Colin Wei, Jason Lee, Qiang Liu, and Tengyu Ma. Regularization matters: Generalization and optimization of neural nets vs their induced kernel. 2019.
350
+
351
+ Zeke Xie, Li Yuan, Zhanxing Zhu, and Masashi Sugiyama. Positive-negative momentum: Manipulating stochastic gradient noise to improve generalization. arXiv preprint arXiv:2103.17182, 2021.
352
+
353
+ Xubo Yue, Maher Nouiehed, and Raed Al Kontar. Salr: Sharpness-aware learning rates for improved generalization. arXiv preprint arXiv:2011.05348, 2020.
354
+
355
+ Manzil Zaheer, Sashank Reddi, Devendra Sachan, Satyen Kale, and Sanjiv Kumar. Adaptive methods for nonconvex optimization. In Advances in neural information processing systems, pp. 9793– 9803, 2018.
356
+
357
+ Matthew D Zeiler. Adadelta: an adaptive learning rate method. arXiv preprint arXiv:1212.5701, 2012.
358
+
359
+ Chiyuan Zhang, Samy Bengio, Moritz Hardt, Benjamin Recht, and Oriol Vinyals. Understanding deep learning requires rethinking generalization. 2017a.
360
+
361
+ Hongyi Zhang, Moustapha Cisse, Yann N Dauphin, and David Lopez-Paz. mixup: Beyond empirical risk minimization. arXiv preprint arXiv:1710.09412, 2017b.
362
+
363
+ Michael Zhang, James Lucas, Jimmy Ba, and Geoffrey E Hinton. Lookahead optimizer: k steps forward, 1 step back. In Advances in Neural Information Processing Systems, pp. 9593–9604, 2019.
364
+
365
+ Yaowei Zheng, Richong Zhang, and Yongyi Mao. Regularizing neural networks via adversarial model perturbation. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 8156–8165, 2021.
366
+
367
+ Pan Zhou, Jiashi Feng, Chao Ma, Caiming Xiong, Steven Hoi, et al. Towards theoretically understanding why sgd generalizes better than adam in deep learning. arXiv preprint arXiv:2010.05627, 2020.
368
+
369
+ Juntang Zhuang, Tommy Tang, Yifan Ding, Sekhar Tatikonda, Nicha Dvornek, Xenophon Papademetris, and James S Duncan. Adabelief optimizer: Adapting stepsizes by the belief in observed gradients. arXiv preprint arXiv:2010.07468, 2020.
370
+
371
+ # A PROOFS
372
+
373
+ A.1 PROOF OF LEMMA. 3.1
374
+
375
+ Suppose $\rho$ is small, perform Taylor expansion around the local minima $w$ , we have:
376
+
377
+ $$
378
+ \boldsymbol { f } ( \boldsymbol { w } + \delta ) = \boldsymbol { f } ( \boldsymbol { w } ) + \nabla \boldsymbol { f } ( \boldsymbol { w } ) ^ { \top } \delta + \frac { 1 } { 2 } \delta ^ { \top } \boldsymbol { H } \delta + O ( | | \delta | | ^ { 3 } )
379
+ $$
380
+
381
+ where $H$ is the Hessian, and is positive semidefinite at a local minima. At a local minima, $\nabla f ( w ) =$ 0, hence we have
382
+
383
+ $$
384
+ f ( w + \delta ) = f ( w ) + \frac { 1 } { 2 } \delta ^ { \top } H \delta + O ( | | \delta | | ^ { 3 } )
385
+ $$
386
+
387
+ and
388
+
389
+ $$
390
+ f _ { p } ( w ) = \operatorname* { m a x } _ { | | \delta | | \leq \rho } f ( w + \delta ) = f ( w ) + \frac { 1 } { 2 } \rho ^ { 2 } \sigma _ { m a x } ( H ) + O ( | | \delta | | ^ { 3 } )
391
+ $$
392
+
393
+ where $\sigma _ { m a x }$ is the dominate eigenvalue (eigenvalue with the largest absolute value). Now consider two local minima $w _ { 1 }$ and $w _ { 2 }$ with dominate eigenvalue $\sigma _ { 1 }$ and $\sigma _ { 2 }$ respectively, we have
394
+
395
+ $$
396
+ f _ { p } ( w _ { 1 } ) \approx f ( w _ { 1 } ) + \frac { 1 } { 2 } \rho ^ { 2 } \sigma _ { 1 } \qquad f _ { p } ( w _ { 2 } ) \approx f ( w _ { 2 } ) + \frac { 1 } { 2 } \rho ^ { 2 } \sigma _ { 2 }
397
+ $$
398
+
399
+ We have $f _ { p } ( w _ { 1 } ) > f _ { p } ( w _ { 2 } ) \implies \sigma _ { 1 } > \sigma _ { 2 }$ and $\sigma _ { 1 } > \sigma _ { 2 } \implies f _ { p } ( w _ { 1 } ) > f _ { p } ( w _ { 2 } )$ because the relation between $f ( w _ { 1 } )$ and $f ( w _ { 2 } )$ is undetermined. 
400
+
401
+ # A.2 PROOF OF LEMMA. 3.2
402
+
403
+ Since $\rho$ is small, we can perform Taylor expansion around $w$
404
+
405
+ $$
406
+ \begin{array} { r l } & { h ( w ) = f ( w + \delta ) - f ( w ) } \\ & { \qquad = \delta ^ { \top } \nabla f ( w ) + O ( \rho ^ { 2 } ) } \\ & { \qquad = \rho | | \nabla f ( w ) | | _ { 2 } + O ( \rho ^ { 2 } ) > 0 } \end{array}
407
+ $$
408
+
409
+ where the last line is because δ is approximated as δ = ρ ∇f(w)||∇f(w)||2+ , h ence has the same direction as $\nabla f ( w )$ . 
410
+
411
+ # A.3 PROOF OF LEMMA. 3.3
412
+
413
+ Since $\rho$ is small, we can approximate $f ( w )$ with a quadratic model around a local minima $w$ :
414
+
415
+ $$
416
+ f ( w + \delta ) = f ( w ) + \frac { 1 } { 2 } \delta ^ { \top } H \delta + O ( \rho ^ { 3 } )
417
+ $$
418
+
419
+ where $H$ is the Hessian at $w$ , assumed to be positive semidefinite at local minima. Normalize $\delta$ such that $| | \delta | | _ { 2 } = \rho$ , Hence we have:
420
+
421
+ $$
422
+ h ( w ) = f _ { p } ( w ) - f ( w ) = \operatorname* { m a x } _ { | | \delta | | _ { 2 } \leq \rho } f ( w + \delta ) - f ( w ) = \frac { 1 } { 2 } \sigma _ { m a x } \rho ^ { 2 } + O ( \rho ^ { 3 } )
423
+ $$
424
+
425
+ where $\sigma _ { m a x }$ is the dominate eigenvalue of the hessian $H$ , and first order term is 0 because the gradient is 0 at local minima. Therefore, we have $\sigma _ { m a x } \approx 2 h ( w ) / \rho ^ { 2 }$ . 
426
+
427
+ # A.4 PROOF OF THM. 5.1
428
+
429
+ For simplicity we consider the base optimizer is SGD. For other optimizers such as Adam, we can derive similar results by applying standard proof techniques in the literature to our proof.
430
+
431
+ STEP 1: CONVERGENCE W.R.T FUNCTION $f _ { p } ( w )$
432
+
433
+ For simplicity of notation, we denote the update at step $t$ as
434
+
435
+ $$
436
+ d _ { t } = - \eta _ { t } g _ { p } ^ { ( t ) } + \eta _ { t } \alpha g _ { \perp } ^ { ( t ) }
437
+ $$
438
+
439
+ By $L -$ smoothness of $f$ and the definition of $f _ { p } ( w _ { t } ) = f ( w _ { t } ^ { a d v } )$ , and definition of $d _ { t } = w _ { t + 1 } - w _ { t }$ and $w _ { t } ^ { a d v } = w _ { t } + \delta _ { t }$ we have
440
+
441
+ $$
442
+ \begin{array} { l } { \displaystyle f _ { p } ( w _ { t + 1 } ) = f ( w _ { t + 1 } ^ { a d v } ) \leq f ( w _ { t } ^ { a d v } ) + \langle \nabla f ( w _ { t } ^ { a d v } ) , w _ { t + 1 } ^ { a d v } - w _ { t } ^ { a d v } \rangle + \frac { L } { 2 } \Big \| | w _ { t + 1 } ^ { a d v } - w _ { t } ^ { a d v } \Big \| ^ { 2 } } \\ { \displaystyle \qquad = f ( w _ { t } ^ { a d v } ) + \langle \nabla f ( w _ { t } ^ { a d v } ) , w _ { t + 1 } + \delta _ { t + 1 } - w _ { t } - \delta _ { t } \rangle } \\ { \displaystyle \qquad + \frac { L } { 2 } \Big \| w _ { t + 1 } + \delta _ { t + 1 } - w _ { t } - \delta _ { t } \Big \| ^ { 2 } } \\ { \displaystyle \qquad \leq f ( w _ { t } ^ { a d v } ) + \langle \nabla f ( w _ { t } ^ { a d v } ) , d _ { t } \rangle + L \Big \| d _ { t } \Big \| ^ { 2 } } \\ { \displaystyle \qquad + \langle \nabla f ( w _ { t } ^ { a d v } ) , \delta _ { t + 1 } - \delta _ { t } \rangle + L \Big \| \delta _ { t + 1 } - \delta _ { t } \Big \| ^ { 2 } } \end{array}
443
+ $$
444
+
445
+ STEP 1.0: BOUND EQ. 18
446
+
447
+ We first bound Eq. 18. Take expectation conditioned on observation up to step $t$ (for simplicity of notation, we use $\mathbb { E }$ short for $\mathbb { E } _ { x }$ to denote expectation over all possible data points) conditioned on observations up to step $t$ , also by definition of $d _ { t }$ , we have
448
+
449
+ $$
450
+ \begin{array} { r l } & { \mathbb { E } f _ { p } ( w _ { t + 1 } ) - f _ { p } ( w _ { t } ) \leq - \eta _ { t } \langle \nabla f _ { p } ( w _ { t } ) , \mathbb { E } g _ { p } ^ { ( t ) } \rangle + \alpha \eta _ { t } \langle \nabla f _ { p } ( w _ { t } ) , \mathbb { E } g _ { \perp } ^ { ( t ) } \rangle } \\ & { \qquad + L \eta _ { t } ^ { 2 } \mathbb { E } \Big | \Big | - g _ { p } ^ { ( t ) } + \alpha g _ { \perp } ^ { ( t ) } \Big | \Big | _ { 2 } ^ { 2 } } \\ & { \qquad \leq - \eta _ { t } \mathbb { E } \Big | \Big | \nabla f _ { p } ( w _ { t } ) \Big | \Big | _ { 2 } ^ { 2 } + 0 + ( \alpha + 1 ) ^ { 2 } G ^ { 2 } \eta _ { t } ^ { 2 } } \end{array}
451
+ $$
452
+
453
+ Since $\mathbb { E } g _ { \perp } ^ { ( t ) }$ is orthogonal to $\nabla f _ { p } ( w _ { t } )$ by construction,
454
+
455
+ $$
456
+ \vert \vert g ^ { ( t ) } \vert \vert \le G \mathrm { b y } \mathrm { a s s u m p t i o n } \bigg )
457
+ $$
458
+
459
+ STEP 1.1: BOUND EQ. 19
460
+
461
+ By definition of $\delta _ { t }$ , we have
462
+
463
+ $$
464
+ \begin{array} { c } { \displaystyle \delta _ { t } = \rho _ { t } \frac { g ^ { ( t ) } } { | | g ^ { ( t ) } | | + \epsilon } } \\ { \displaystyle \delta _ { t + 1 } = \rho _ { t + 1 } \frac { g ^ { ( t + 1 ) } } { | | g ^ { ( t + 1 ) } | | + \epsilon } } \end{array}
465
+ $$
466
+
467
+ where $g ^ { ( t ) }$ is the gradient of $f$ at $w _ { t }$ evaluated with a noisy data sample. When learning rate $\eta _ { t }$ is small, the update in weight $d _ { t }$ is small, and expected gradient is
468
+
469
+ $$
470
+ \nabla f ( w _ { t + 1 } ) = \nabla f ( w _ { t } + d _ { t } ) = \nabla f ( w _ { t } ) + H d _ { t } + O ( | | d _ { t } | | ^ { 2 } )
471
+ $$
472
+
473
+ where $H$ is the Hessian at $w _ { t }$ . Therefore, we have
474
+
475
+ $$
476
+ \begin{array} { r l } & { \mathbb { E } \langle \nabla f ( w _ { t } ^ { a d v } ) , \delta _ { t + 1 } - \delta _ { t } \rangle = \langle \nabla f ( w _ { t } ^ { a d v } ) , \rho _ { t } \mathbb { E } \frac { g ^ { ( t ) } } { | | g ^ { ( t ) } | | + \epsilon } - \rho _ { t + 1 } \mathbb { E } \frac { g ^ { ( t + 1 ) } } { | | g ^ { ( t + 1 ) } | | + \epsilon } \rangle } \\ & { \qquad \leq | | \nabla f ( w _ { t } ^ { a d v } ) | | \rho _ { t } \Big | \Big | \mathbb { E } \frac { g ^ { ( t ) } } { | | g ^ { ( t ) } | | + \epsilon } - \mathbb { E } \frac { g ^ { ( t + 1 ) } } { | | g ^ { ( t + 1 ) } | | + \epsilon } \Big | \Big | } \\ & { \qquad \leq | | \nabla f ( w _ { t } ^ { a d v } ) | | \rho _ { t } \phi _ { t } } \end{array}
477
+ $$
478
+
479
+ where the first inequality is due to (1) $\rho _ { t }$ is monotonically decreasing with $t$ , and (2) triangle inequality that $\langle a , b \rangle \overset { \cdot } { \leq } | | \boldsymbol { \dot { a } } | | \cdot | | b | |$ . $\phi _ { t }$ is the angle between the unit vector in the direction of $\nabla f ( w _ { t } )$
480
+
481
+ and $\nabla f ( w _ { t + 1 } )$ . The second inequality comes from that (1) $\begin{array} { r } { \left\| \frac { g } { | | g | | + \epsilon } \right\| < 1 } \end{array}$ strictly, so we can replace $\delta _ { t }$ in Eq. 25 with a unit vector in corresponding directions multiplied by $\rho _ { t }$ and get the upper bound, (2) the norm of difference in unit vectors can be upper bounded by the arc length on a unit circle.
482
+
483
+ When learning rate $\eta _ { t }$ and update stepsize $d _ { t }$ is small, $\phi _ { t }$ is also small. Using the limit that
484
+
485
+ $$
486
+ \tan x = x + O ( x ^ { 2 } ) , \quad \sin x = x + O ( x ^ { 2 } ) , \quad x \to 0
487
+ $$
488
+
489
+ We have:
490
+
491
+ $$
492
+ \begin{array} { r l r } { { \tan \phi _ { t } = \frac { | | \nabla f ( w _ { t + 1 } ) - \nabla f ( w _ { t } ) | | } { | | \nabla f ( w _ { t } ) | | } + O ( \phi _ { t } ^ { 2 } ) } } \\ & { } & { = \frac { | | H d _ { t } + O ( | | d _ { t } | | ^ { 2 } ) | | } { | | \nabla f ( w _ { t } ) | | } + O ( \phi _ { t } ^ { 2 } ) } \\ & { } & { \leq \eta _ { t } L ( 1 + \alpha ) } \end{array}
493
+ $$
494
+
495
+ where the last inequality is due to (1) max eigenvalue of $H$ is upper bounded by $L$ because $f$ is $L -$ smooth, (2) $| | d _ { t } | | = | | \eta _ { t } ( g _ { \parallel } + \alpha g _ { \perp } ) | |$ and $\mathbb { E } g _ { t } = \nabla f ( w _ { t } )$ .
496
+
497
+ Plug into Eq. 27, also note that the perturbation amplitude $\rho _ { t }$ is small so $w _ { t }$ is close to $w _ { t } ^ { a d v }$ , then we have
498
+
499
+ $$
500
+ \mathbb { E } \langle \nabla f ( w _ { t } ^ { a d v } ) , \delta _ { t + 1 } - \delta _ { t } \rangle \leq L ( 1 + \alpha ) G \rho _ { t } \eta _ { t }
501
+ $$
502
+
503
+ Similarly, we have
504
+
505
+ $$
506
+ \begin{array} { r l } & { \mathbb { E } \Big \lvert \Big \lvert \delta _ { t + 1 } - \delta _ { t } \Big \rvert \Big \rvert ^ { 2 } \leq \rho _ { t } ^ { 2 } \mathbb { E } \Big \lvert \Big \lvert \frac { g ^ { ( t ) } } { \lvert | g ^ { ( t ) } \rvert \rvert + \epsilon } - \frac { g ^ { ( t + 1 ) } } { \lvert | g ^ { ( t + 1 ) } \rvert \rvert + \epsilon } \Big \rvert \Big \rvert ^ { 2 } } \\ & { \qquad \leq \rho _ { t } ^ { 2 } \phi _ { t } ^ { 2 } } \\ & { \qquad \leq \rho _ { t } ^ { 2 } \eta _ { t } ^ { 2 } L ^ { 2 } ( 1 + \alpha ) ^ { 2 } } \end{array}
507
+ $$
508
+
509
+ STEP 1.2: TOTAL BOUND
510
+
511
+ Reuse results from Eq. 21 (replace $L _ { p }$ with $2 L$ ) and plug into Eq. 18, and plug Eq. 31 and Eq. 34 into Eq. 19, we have
512
+
513
+ $$
514
+ \begin{array} { r l } & { \mathbb { E } f _ { p } ( w _ { t + 1 } ) - f _ { p } ( w _ { t } ) \leq - \eta _ { t } \mathbb { E } \Big | \Big | \nabla f _ { p } ( w _ { t } ) \Big | \Big | _ { 2 } ^ { 2 } + \frac { 2 L ( \alpha + 1 ) ^ { 2 } } { 2 } G ^ { 2 } \eta _ { t } ^ { 2 } } \\ & { \qquad + L ( 1 + \alpha ) G \rho _ { t } \eta _ { t } + \frac { 2 L ^ { 3 } ( 1 + \alpha ) ^ { 2 } } { 2 } \eta _ { t } ^ { 2 } \rho _ { t } ^ { 2 } } \end{array}
515
+ $$
516
+
517
+ Perform telescope sum, we have
518
+
519
+ $$
520
+ \begin{array} { l } { \displaystyle \mathbb { E } f _ { p } ( w _ { T } ) - f _ { p } ( w _ { 0 } ) \leq - \sum _ { t = 1 } ^ { T } \eta _ { t } \mathbb { E } | | \nabla f _ { p } ( w _ { t } ) | | ^ { 2 } + \left[ L ( 1 + \alpha ) ^ { 2 } G ^ { 2 } \eta _ { 0 } ^ { 2 } + L ( 1 + \alpha ) G \rho _ { 0 } \eta _ { 0 } \right] \sum _ { t = 1 } ^ { T } \frac { 1 } { t } } \\ { \displaystyle \qquad + L ^ { 3 } ( 1 + \alpha ) ^ { 2 } \eta _ { 0 } ^ { 2 } \rho _ { 0 } ^ { 2 } \sum _ { t = 1 } ^ { T } \frac { 1 } { t ^ { 2 } } } \end{array}
521
+ $$
522
+
523
+ Hence
524
+
525
+ $$
526
+ \eta _ { T } \sum _ { t = 1 } ^ { T } \mathbb { E } | | \nabla f _ { p } ( w _ { t } ) | | ^ { 2 } \leq \sum _ { t = 1 } ^ { T } \eta _ { t } \mathbb { E } | | \nabla f _ { p } ( w _ { t } ) | | ^ { 2 } \leq f _ { p } ( w _ { 0 } ) - \mathbb { E } f _ { p } ( w _ { T } ) + D \log T + \frac { \pi ^ { 2 } E } { 6 }
527
+ $$
528
+
529
+ where
530
+
531
+ $$
532
+ D = L ( 1 + \alpha ) ^ { 2 } G ^ { 2 } \eta _ { 0 } ^ { 2 } + L ( 1 + \alpha ) G \rho _ { 0 } \eta _ { 0 } , \quad E = L ^ { 3 } ( 1 + \alpha ) ^ { 2 } \eta _ { 0 } ^ { 2 } \rho _ { 0 } ^ { 2 }
533
+ $$
534
+
535
+ Note that $\begin{array} { r } { \eta _ { T } = \frac { \eta _ { 0 } } { \sqrt { T } } } \end{array}$ , we have
536
+
537
+ $$
538
+ \frac { 1 } { T } \sum _ { t = 1 } ^ { T } \mathbb { E } | | \nabla f _ { p } ( w _ { t } ) | | ^ { 2 } \leq \frac { f _ { p } ( w _ { 0 } ) - f _ { m i n } + \pi ^ { 2 } E / 6 } { \eta _ { 0 } } \frac { 1 } { \sqrt { T } } + \frac { D } { \eta _ { 0 } } \frac { \log T } { \sqrt { T } }
539
+ $$
540
+
541
+ which implies that GSAM enables $f _ { p }$ to converge at a rate of $O ( \log T / \sqrt { T } )$ , and all the constants here are well-bounded.
542
+
543
+ STEP 2: CONVERGENCE W.R.T. FUNCTION $f ( w )$
544
+
545
+ We prove the risk for $f ( w )$ convergences for non-convex stochastic optimization case using SGD. Denote the update at step $t$ as
546
+
547
+ $$
548
+ d _ { t } = - \eta _ { t } g _ { p } ^ { ( t ) } + \alpha \eta _ { t } g _ { \perp } ^ { ( t ) }
549
+ $$
550
+
551
+ By smoothness of $f$ , we have
552
+
553
+ $$
554
+ \begin{array} { l } { f ( w _ { t + 1 } ) \leq f ( w _ { t } ) + \langle \nabla f ( w _ { t } ) , d _ { t } \rangle + \displaystyle \frac { L } { 2 } \Big \lvert \Big \lvert d _ { t } \Big \rvert \Big \rvert _ { 2 } ^ { 2 } } \\ { = f ( w _ { t } ) + \langle \nabla f ( w _ { t } ) , - \eta _ { t } g _ { p } ^ { ( t ) } + \alpha \eta _ { t } g _ { \perp } ^ { ( t ) } \rangle + \displaystyle \frac { L } { 2 } \Big \lvert \Big \lvert d _ { t } \Big \rvert \Big \rvert _ { 2 } ^ { 2 } } \end{array}
555
+ $$
556
+
557
+ For simplicity, we introduce a scalar $\beta _ { t }$ such that
558
+
559
+ $$
560
+ \nabla f _ { \parallel } ( w _ { t } ) = \beta _ { t } \nabla f _ { p } ( w _ { t } )
561
+ $$
562
+
563
+ where $\nabla f _ { \parallel } ( w _ { t } )$ is the projection of $\nabla f ( w _ { t } )$ onto $\nabla f _ { p } ( w _ { t } )$ . When perturbation amplitude $\rho$ is small, we expect $\beta _ { t }$ to be very close to 1.
564
+
565
+ Take expectation conditioned on observations up to step $t$ for both sides of Eq. 42, we have:
566
+
567
+ $$
568
+ \begin{array} { l } { \displaystyle \mathbb { E } f ( w _ { t + 1 } ) \leq f ( w _ { t } ) + \left. \nabla f ( w _ { t } ) , - \frac { \eta _ { t } } { \beta _ { t } } \Big ( \nabla f ( w _ { t } ) - \nabla f _ { \perp } ( w _ { t } ) \Big ) + \alpha \eta _ { t } \mathbb { E } g _ { \perp } ^ { ( t ) } \right. + \displaystyle \frac { L } { 2 } \mathbb { E } \Big \| \boldsymbol { d } _ { t } \Big \| _ { 2 } ^ { 2 } } \\ { = f ( w _ { t } ) - \displaystyle \frac { \eta _ { t } } { \beta _ { t } } \Big \| \nabla f ( w _ { t } ) \Big \| _ { 2 } ^ { 2 } + \Big ( \frac { 1 } { \beta _ { t } } + \alpha \Big ) \eta _ { t } \Big \langle \nabla f ( w _ { t } ) , \nabla f _ { \perp } ( w _ { t } ) \Big \rangle + \displaystyle \frac { L } { 2 } \mathbb { E } \Big \| \boldsymbol { d } _ { t } \Big \| _ { 2 } ^ { 2 } } \\ { = f ( w _ { t } ) - \displaystyle \frac { \eta _ { t } } { \beta _ { t } } \Big \| \nabla f ( w _ { t } ) \Big \| _ { 2 } ^ { 2 } + \Big ( \frac { 1 } { \beta _ { t } } + \alpha \Big ) \eta _ { t } \Big \langle \nabla f ( w _ { t } ) , \nabla f ( w _ { t } ) \sin \theta _ { t } \Big \rangle + \displaystyle \frac { L } { 2 } \mathbb { E } \Big \| \boldsymbol { d } _ { t } \Big \| _ { 2 } ^ { 2 } } \end{array}
569
+ $$
570
+
571
+ $$
572
+ = f ( w _ { t } ) - \frac { \eta _ { t } } { \beta _ { t } } \Big \lvert \Big | \nabla f ( w _ { t } ) \Big \rvert \Big | _ { 2 } ^ { 2 } + \Big ( \frac { 1 } { \beta _ { t } } + \alpha \Big ) \eta _ { t } \Big \lvert \Big | \nabla f ( w _ { t } ) \Big \rvert \Big | _ { 2 } ^ { 2 } ( | \tan \theta _ { t } | + O ( \theta _ { t } ^ { 2 } ) ) + \frac { L } { 2 } \mathbb { E } \Big \lvert \Big | d _ { t } \Big \rvert \Big | _ { 2 } ^ { 2 }
573
+ $$
574
+
575
+ $$
576
+ \Big ( \sin x = x + O ( x ^ { 2 } ) , \tan x = x + O ( x ^ { 2 } ) \mathrm { w h e n } x 0 . \Big )
577
+ $$
578
+
579
+ Also note when perturbation amplitude $\rho _ { t }$ is small, we have
580
+
581
+ $$
582
+ \nabla f _ { p } ( w _ { t } ) = \nabla f ( w _ { t } + \delta _ { t } ) = \nabla f ( w _ { t } ) + \frac { \rho _ { t } } { | | \nabla f ( w _ { t } ) | | _ { 2 } + \epsilon } H ( w _ { t } ) \nabla f ( w _ { t } ) + O ( \rho _ { t } ^ { 2 } )
583
+ $$
584
+
585
+ where δt = ρt ∇f (wt)||∇f (wt)||2 by definition, $H ( w _ { t } )$ is the Hessian. Hence we have
586
+
587
+ $$
588
+ | \tan \theta _ { t } | \leq \frac { | | \nabla f _ { p } ( w _ { t } ) - \nabla f ( w _ { t } ) | | } { | | \nabla f ( w _ { t } ) | | } \leq \frac { \rho _ { t } L } { | | \nabla f ( w _ { t } ) | | }
589
+ $$
590
+
591
+ where $L$ is the Lipschitz constant of $f$ , and $L -$ smoothness of $f$ indicates the maximum absolute eigenvalue of $H$ is upper bounded by $L$ . Plug Eq. 49 into Eq. 47, we have
592
+
593
+ $$
594
+ \begin{array} { l } { \displaystyle \mathbb { E } f ( w _ { t + 1 } ) \leq f ( w _ { t } ) - \frac { \eta _ { t } } { \beta _ { t } } \Big \| \nabla f ( w _ { t } ) \Big \| _ { 2 } ^ { 2 } + \Big ( \frac { 1 } { \beta _ { t } } + \alpha \Big ) \eta _ { t } \Big \| \nabla f ( w _ { t } ) \Big \| _ { 2 } ^ { 2 } | \tan \theta _ { t } | + \frac { L } { 2 } \mathbb { E } \Big \| d t _ { t } \Big \| _ { 2 } ^ { 2 } } \\ { \displaystyle \leq f ( w _ { t } ) - \frac { \eta _ { t } } { \beta _ { t } } \Big \| \nabla f ( w _ { t } ) \Big \| _ { 2 } ^ { 2 } + \Big ( \frac { 1 } { \beta _ { t } } + \alpha \Big ) L \rho _ { t } \eta _ { t } \Big \| \nabla f ( w _ { t } ) \Big \| _ { 2 } + \frac { L } { 2 } \mathbb { E } \Big \| d t _ { t } \Big \| _ { 2 } ^ { 2 } } \\ { \displaystyle \leq f ( w _ { t } ) - \frac { \eta _ { t } } { \beta _ { t } } \Big \| \nabla f ( w _ { t } ) \Big \| _ { 2 } ^ { 2 } + \Big ( \frac { 1 } { \beta _ { t } } + \alpha \Big ) L \rho _ { t } \eta _ { t } G + \frac { L } { 2 } \mathbb { E } \Big \| d t _ { t } \Big \| _ { 2 } ^ { 2 } } \\ { \Big ( \mathrm { A s s u m e ~ g r a d i e n t ~ h a s ~ b o u n d e d ~ n o r m ~ } G _ { \cdot } \Big ) } \\ { \displaystyle \leq f ( w _ { t } ) - \frac { \eta _ { t } } { \beta _ { m a x } } \Big \| \nabla f ( w _ { t } ) \Big \| _ { 2 } ^ { 2 } + \Big ( \frac { 1 } { \beta _ { m i n } } + \alpha \Big ) L \rho _ { t } \eta _ { t } G + \frac { L } { 2 } \mathbb { E } ( \alpha + 1 ) ^ { 2 } G ^ { 2 } \eta _ { t } ^ { 2 } } \end{array}
595
+ $$
596
+
597
+  $\beta _ { t }$ is close to 1 assuming $\rho$ is small,
598
+
599
+ Re-arranging above formula, we have
600
+
601
+ $$
602
+ \frac { \eta _ { t } } { \beta _ { m a x } } \Big | \Big | \nabla f ( w _ { t } ) \Big | \Big | _ { 2 } ^ { 2 } \le f ( w _ { t } ) - \mathbb { E } f ( w _ { t + 1 } ) + \Big ( \frac { 1 } { \beta _ { m i n } } + \alpha \Big ) L G \eta _ { t } \rho _ { t } + \frac { L } { 2 } ( \alpha + 1 ) ^ { 2 } G ^ { 2 } \eta _ { t } ^ { 2 }
603
+ $$
604
+
605
+ perform telescope sum and taking expectations on each step, we have
606
+
607
+ $$
608
+ \frac { 1 } { \beta _ { m a x } } \sum _ { t = 1 } ^ { T } \eta _ { t } \Big | \Big | \nabla f ( w _ { t } ) \Big | \Big | _ { 2 } ^ { 2 } \le f ( w _ { 0 } ) - \mathbb { E } f ( w _ { T } ) + \Big ( \frac { 1 } { \beta _ { m i n } } + \alpha \Big ) L G \sum _ { t = 1 } ^ { T } \eta _ { t } \rho _ { t } + \frac { L } { 2 } ( \alpha + 1 ) ^ { 2 } G ^ { 2 } \sum _ { t = 1 } ^ { T } \eta _ { t } ^ { 2 }
609
+ $$
610
+
611
+ Take the schedule to be $\begin{array} { r } { \eta _ { t } = \frac { \eta _ { 0 } } { \sqrt { t } } } \end{array}$ and $\begin{array} { r } { \rho _ { t } = \frac { \rho _ { 0 } } { \sqrt { t } } } \end{array}$ , then we have
612
+
613
+ $$
614
+ \begin{array} { r l r } { { \frac { \eta _ { 0 } } { 3 m \alpha \lambda } \frac { 1 } { \sqrt { T } } \sum _ { t = 1 } ^ { T } \| \nabla f ( w _ { t } ) \| _ { 2 } ^ { 2 } \le L H S } } \\ & { } & { \le R H S } \\ & { } & { \le { \cal J } ( w _ { 0 } ) - { \cal J } _ { m i n } + \Big ( \frac { 1 } { \beta _ { m i n } } + \alpha \Big ) L G \eta _ { 0 } \rho _ { 0 } \sum _ { t = 1 } ^ { T } \frac { 1 } { t } + \frac { L } { 2 } ( \alpha + 1 ) ^ { 2 } G ^ { 2 } \eta _ { 0 } ^ { 2 } \frac { T } { t - 1 } ; } \\ & { } & { \overset { ( \mathrm { 5 9 } ) } { \le } ~ } \\ & { } & { \le f ( w _ { 0 } ) - f _ { m i n } + \Big ( \frac { 1 } { \beta _ { m i n } } + \alpha \Big ) L G \eta _ { 0 } \rho _ { 0 } ( 1 + \log T ) } \\ & { } & { ~ + \frac { L } { 2 } ( \alpha + 1 ) ^ { 2 } G ^ { 2 } \eta _ { 0 } ^ { 2 } ( 1 + \log T ) ~ ( 6 0 ) } \end{array}
615
+ $$
616
+
617
+ Hence
618
+
619
+ $$
620
+ \frac { 1 } { T } \sum _ { t = 1 } ^ { T } \Big | \Big | \nabla f ( w _ { t } ) \Big | \Big | _ { 2 } ^ { 2 } \le \frac { C _ { 3 } } { \sqrt { T } } + C _ { 4 } \frac { \log T } { \sqrt { T } }
621
+ $$
622
+
623
+ where $C _ { 1 } , C _ { 4 }$ are some constants. This implies the convergence rate w.r.t $f ( w )$ is $O ( \log T / \sqrt { T } )$
624
+
625
+ STEP 3: CONVERGENCE W.R.T. SURROGATE GAP $h ( w )$
626
+
627
+ Note that we have proved convergence for $f _ { p } ( w )$ in step 1, and convergence for $f ( w )$ in step 3. Also note that
628
+
629
+ $$
630
+ \Big | \Big | \nabla h ( w _ { t } ) \Big | \Big | _ { 2 } ^ { 2 } = \Big | \Big | \nabla f _ { p } ( w _ { t } ) - \nabla f ( w _ { t } ) \Big | \Big | _ { 2 } ^ { 2 } \leq 2 \Big | \Big | \nabla f _ { p } ( w _ { t } ) \Big | \Big | _ { 2 } ^ { 2 } + 2 \Big | \Big | \nabla f ( w _ { t } ) \Big | \Big | _ { 2 } ^ { 2 }
631
+ $$
632
+
633
+ Hence
634
+
635
+ $$
636
+ \frac { 1 } { T } \sum _ { t = 1 } ^ { T } \Big | \Big | \nabla h ( w _ { t } ) \Big | \Big | _ { 2 } ^ { 2 } \le \frac { 2 } { T } \sum _ { t = 1 } ^ { T } \Big | \Big | \nabla f _ { p } ( w _ { t } ) \Big | \Big | _ { 2 } ^ { 2 } + \frac { 2 } { T } \sum _ { t = 1 } ^ { T } \Big | \Big | \nabla f ( w _ { t } ) \Big | \Big | _ { 2 } ^ { 2 }
637
+ $$
638
+
639
+ also converges at rate $O ( \log T / \sqrt { T } )$ because each item in the RHS converges at rate $O ( \log T \sqrt { T } )$
640
+
641
+ # A.5 PROOF OF COROLLARY. 5.2.1
642
+
643
+ Using the results from Thm. 5.2, with probability at least $1 - a$ , we have
644
+
645
+ $$
646
+ \mathbb { E } _ { w \sim \mathcal { Q } } \mathbb { E } _ { { x } } f ( w , { x } ) \le \mathbb { E } _ { w \sim \mathcal { Q } } \widehat { f } ( w ) + 4 \sqrt { \frac { K L ( \mathcal { Q } | | \mathcal { P } ) + \log \frac { 2 m } { a } } { m } }
647
+ $$
648
+
649
+ Assume $\delta \sim \mathcal { N } ( 0 , b ^ { 2 } I _ { k } )$ where $k$ is the dimension of model parameters, hence $\delta ^ { 2 }$ (element-wise square) follows a a Chi-square distribution. By Lemma.1 in Laurent $\&$ Massart (2000), we have
650
+
651
+ $$
652
+ \mathbb { P } \big ( | | \delta | | _ { 2 } ^ { 2 } - k b ^ { 2 } \geq 2 b ^ { 2 } \sqrt { k t } + 2 t b ^ { 2 } \big ) \leq e x p ( - t )
653
+ $$
654
+
655
+ hence with probability at least $1 - 1 / \sqrt { n }$ , we have
656
+
657
+ $$
658
+ | | \delta | | _ { 2 } ^ { 2 } \leq b ^ { 2 } \Bigg ( 2 \log \sqrt { n } + k + 2 \sqrt { k \log \sqrt { n } } \Bigg ) \leq 2 b ^ { 2 } k \Bigg ( 1 + \sqrt { \frac { \log \sqrt { n } } { k } } \Bigg ) ^ { 2 } \leq \rho ^ { 2 }
659
+ $$
660
+
661
+ Therefore, with probability at least $\begin{array} { r } { 1 - 1 / \sqrt { n } = 1 - e x p \bigg ( - \big ( \frac { \rho } { \sqrt { 2 } b } - \sqrt { k } \big ) ^ { 2 } \bigg ) } \end{array}$
662
+
663
+ $$
664
+ \begin{array} { r } { \mathbb { E } _ { \delta } \widehat { f } ( w + \delta ) \leq \operatorname* { m a x } _ { | | \delta | | _ { 2 } \leq \rho } \widehat { f } ( w + \delta ) } \end{array}
665
+ $$
666
+
667
+ Combine Eq. 65 and Eq. 67, subtract the same constant $C$ on both sides, and under the same assumption as in (Foret et al., 2020) that $\begin{array} { r } { \mathbb { E } _ { w \sim \mathcal { Q } } \mathbb { E } _ { x } f ( w , x ) \le \mathbb { E } _ { \delta \sim \mathcal { N } ( 0 , b ^ { 2 } I ^ { k } ) } \mathbb { E } _ { w \sim \mathcal { Q } } \mathbb { E } _ { x } f ( w + \delta , x ) \mathrm { w e } } \end{array}$ finish the proof. 
668
+
669
+ # A.6 PROOF OF THM. 5.3
670
+
671
+ STEP 1: A SUFFICIENT CONDITION THAT THE LOSS GAP IS EXPECTED TO DECREASE FOR EACH STEP
672
+
673
+ Take Taylor expansion, then the expected change of loss gap caused by descent step is
674
+
675
+ $$
676
+ \begin{array} { r l } & { \mathbb { E } \langle \nabla f _ { p } ( w _ { t } ) - \nabla f ( w _ { t } ) , - \eta _ { t } \nabla f _ { p } ( w _ { t } ) \rangle } \\ & { \Big ( w h e r e \mathbb { E } g _ { \perp } = \nabla f _ { \perp } ( w _ { t } ) \Big ) } \\ & { = \eta _ { t } \Bigg [ - | | \nabla f _ { p } ( w _ { t } ) | | _ { 2 } ^ { 2 } + | | \nabla f _ { p } ( w _ { t } ) | | _ { 2 } \big | | \nabla f ( w _ { t } ) | | _ { 2 } \cos \theta _ { t } \Bigg ] } \end{array}
677
+ $$
678
+
679
+ where $\theta _ { t }$ is the angle between vector $\nabla f _ { p } ( w _ { t } )$ and $\nabla f ( w _ { t } )$ .
680
+
681
+ The expected change of loss gap caused by ascent step is
682
+
683
+ $$
684
+ \begin{array} { r } { \mathbb { E } \langle \nabla f _ { p } ( w _ { t } ) - \nabla f ( w _ { t } ) , \alpha \eta _ { t } \nabla f _ { \perp } ( w _ { t } ) \rangle = - \alpha \eta _ { t } \big \lvert \big \rvert \nabla f _ { \perp } ( w _ { t } ) \big \rvert \big \rvert _ { 2 } ^ { 2 } < 0 } \end{array}
685
+ $$
686
+
687
+ Above results demonstrate that ascent step decreases the loss gap, while descent step might increase the loss gap. A sufficient (but not necessary) condition for $\mathbb { E } \langle \nabla h ( w _ { t } ) , d t \rangle \leq 0$ requires $\alpha$ to be large or $| \big | \nabla f ( w _ { t } ) \big | \big | _ { 2 } \cos \theta _ { t } \leq \big | \big | \nabla f _ { p } ( w _ { t } ) \big | \big |$ . In practice, the perturbation amplitude $\rho$ is small and we can assume $\theta _ { t }$ is close to 0 and $\big | \big | \nabla f _ { p } ( w _ { t } ) \big | \big |$ is close to $\left| \left| \nabla f ( w _ { t } ) \right| \right|$ , we can also set the parameter $\alpha$ to be large in order to decrease the loss gap.
688
+
689
+ STEP 2: UPPER AND LOWER BOUND OF DECREASE IN LOSS GAP (BY THE ASCENT STEP IN ORTHOGONAL GRADIENT DIRECTION) COMPARED TO SAM.
690
+
691
+ Next we give an estimate of the decrease in $\widehat { h }$ caused by our ascent step. We refer to Eq. 69 and Eq. 70 to analyze the change in loss gap caused by the descent and ascent (orthogonally) respectively. It can be seen that gradient descent step might not decrease loss gap, in fact they often increase loss gap in practice; while the ascent step is guaranteed to decrease the loss gap.
692
+
693
+ The decrease in loss gap is:
694
+
695
+ $$
696
+ \begin{array} { r l r } & { } & { \Delta \widehat { h } _ { t } = - \langle \nabla \widehat { f } _ { p } ( w _ { t } ) - \nabla \widehat { f } ( w _ { t } ) , \alpha \eta _ { t } \nabla \widehat { f } _ { \bot } ( w _ { t } ) \rangle = \alpha \eta _ { t } \big \lvert \big \lvert \nabla \widehat { f } _ { \bot } ( w _ { t } ) \big \rvert \big \rvert _ { 2 } ^ { 2 } } \\ & { } & { = \alpha \eta _ { t } \big \lvert \big \lvert \nabla \widehat { f } ( w _ { t } ) \big \rvert \big \rvert _ { 2 } ^ { 2 } \big \lvert \tan \theta _ { t } \big \rvert ^ { 2 } } \end{array}
697
+ $$
698
+
699
+ $$
700
+ \begin{array} { r l r } { { \sum _ { t = 1 } ^ { T } \Delta \widehat { h } _ { t } \le \sum _ { t = 1 } ^ { T } \alpha L ^ { 2 } \eta _ { t } \rho _ { t } ^ { 2 } } } \\ & { } & { \Big ( \mathrm { B y ~ E q . ~ 4 9 } \Big ) } \\ & { } & { \le \displaystyle \sum _ { t = 1 } ^ { T } \alpha L ^ { 2 } \eta _ { 0 } \rho _ { 0 } ^ { 2 } \frac { 1 } { t ^ { 3 / 2 } } } \\ & { } & { \le 2 . 7 \alpha L ^ { 2 } \eta _ { 0 } \rho _ { 0 } ^ { 2 } } \end{array}
701
+ $$
702
+
703
+ Hence we derive an upper bound for $\Sigma _ { t = 1 } ^ { T } \Delta \widehat { h } _ { t }$
704
+
705
+ Next we derive a lower bound for $\Sigma _ { t = 1 } ^ { T } \Delta \widehat { h } _ { t }$ Note that when $\rho _ { t }$ is small, by Taylor expansion
706
+
707
+ $$
708
+ \nabla \widehat { f } _ { p } ( w _ { t } ) = \nabla \widehat { f } ( w _ { t } + \delta _ { t } ) = \nabla \widehat { f } ( w _ { t } ) + \frac { \rho _ { t } } { | | \nabla \widehat { f } ( w _ { t } ) | | } \widehat { H } ( w _ { t } ) \nabla \widehat { f } ( w _ { t } ) + O ( \rho _ { t } ^ { 2 } )
709
+ $$
710
+
711
+ where $\widehat { H } ( w _ { t } )$ is the Hessian evaluated on training samples. Also when $\rho _ { t }$ is small, the angle $\theta _ { t }$ between $\nabla \widehat { f } _ { p } ( w _ { t } )$ and $\nabla \widehat { f } ( \boldsymbol { w } _ { t } )$ is small, by the limit that
712
+
713
+ $$
714
+ \begin{array} { l } { \tan x = x + O ( x ^ { 2 } ) , x \to 0 } \\ { \sin x = x + O ( x ^ { 2 } ) , x \to 0 } \end{array}
715
+ $$
716
+
717
+ We have
718
+
719
+ $$
720
+ \left| \tan \theta _ { t } \right| = \left| \sin \theta _ { t } \right| + O ( \theta _ { t } ^ { 2 } ) = | \theta _ { t } | + O ( \theta _ { t } ^ { 2 } )
721
+ $$
722
+
723
+ Omitting high order term, we have
724
+
725
+ $$
726
+ | \tan \theta _ { t } | \approx | \theta _ { t } | = \frac { | | \nabla \widehat { f } _ { p } ( w _ { t } ) - \nabla \widehat { f } ( w _ { t } ) | | } { | | \widehat { f } ( w _ { t } ) | | } = \frac { | | \rho _ { t } \widehat { H } ( w _ { t } ) + O ( \rho _ { t } ^ { 2 } ) | | } { | | \nabla \widehat { f } ( w _ { t } ) | | } \geq \frac { \rho _ { t } | \sigma | _ { m i n } } { G }
727
+ $$
728
+
729
+ where $G$ is the upper-bound on norm of gradient, $| \sigma | _ { m i n }$ is the minimum absolute eigenvalue of the Hessian. The intuition is that as perturbation amplitude decreases, the angle $\theta _ { t }$ decreases at a similar rate, though the scale constant might be different. Hence we have
730
+
731
+ $$
732
+ \begin{array} { r l } { { \sum _ { t = 1 } ^ { T } \Delta \hat { h } _ { t } = \sum _ { t = 1 } ^ { T } \alpha \eta _ { t } \vert \big \vert \nabla \widehat { f } ( w _ { t } ) \big \vert \big \vert _ { 2 } ^ { 2 } \vert \tan \theta _ { t } \vert ^ { 2 } + O ( \theta _ { t } ^ { 4 } ) } \ ~ } \\ & { \geq \sum _ { t = 1 } ^ { T } \alpha \eta _ { t } c ^ { 2 } \Big ( \frac { \rho _ { t } \vert \sigma \vert _ { m i n } } { G } \Big ) ^ { 2 } } \\ & { = \frac { \alpha c ^ { 2 } \rho _ { 0 } ^ { 2 } \eta _ { 0 } \vert \sigma \vert _ { m i n } ^ { 2 } } { G ^ { 2 } } \sum _ { t = 1 } ^ { T } \frac { 1 } { t ^ { 3 / 2 } } } \\ & { \geq \frac { \alpha c ^ { 2 } \rho _ { 0 } ^ { 2 } \eta _ { 0 } \vert \sigma \vert _ { m i n } ^ { 2 } } { G ^ { 2 } } } \end{array}
733
+ $$
734
+
735
+ where $c ^ { 2 }$ is the lower bound of $| | \nabla \widehat { f } | | ^ { 2 }$ (e.g. due to noise in data and gradient observation). Results above indicate that the decrease in loss gap caused by the ascent step is non-trivial, hence our proposed method efficiently improves generalization compared with SAM. 
736
+
737
+ # A.7 DISCUSSION ON COROLLARY 5.2.1
738
+
739
+ The comment “‘The corollary gives a bound on the risk in terms of the perturbed training loss if one removes $C$ from both sides”’ is correct. But there is a misunderstanding in the statement “‘the perturbed training loss is small then the model has a small risk”’: it’s only true when $\rho _ { t r a i n }$ for training equals its real value $\rho _ { t r u e }$ determined by the data distribution; in practice, we never know $\rho _ { t r u e }$ . In the following we show that the minimization of both $h$ and $f _ { p }$ is better than simply minimizing $f _ { p }$ when $\rho _ { t r u e } \neq \rho _ { t r a i n }$ .
740
+
741
+ 1. First, we re-write the conclusion of Corollary 5.2.1 as
742
+
743
+ $$
744
+ \begin{array} { r } { \mathbb { E } _ { w } \mathbb { E } _ { x } f ( w , x ) \le f _ { p } + R = C + \widehat { h } + R = C + \rho ^ { 2 } \sigma / 2 + R + O ( \rho ^ { 3 } ) } \\ { w i t h p r o b a b i l i t y \left( 1 - a \right) [ 1 - e ^ { - ( \frac { \rho } { \sqrt { 2 } b } - \sqrt { k } ) ^ { 2 } } ] } \end{array}
745
+ $$
746
+
747
+ where $R$ is the regularization term, $C$ is the training loss, $\sigma$ is the dominant eigenvalue of Hessian. As in lemma 3.3, we perform Taylor-expansion and can ignore the high-order term $O ( \rho ^ { 3 } )$ . We focus on
748
+
749
+ $$
750
+ f _ { p } = C + \widehat { h } = C + \rho ^ { 2 } \sigma / 2
751
+ $$
752
+
753
+ 2. When $\rho _ { t r u e } \neq \rho _ { t r a i n }$ , minimizing $h$ achieves a lower risk than only minimizing $f _ { p }$ . (1) Note that after training, $C$ (training loss) is fixed, but $h$ could vary with $\rho$ (e.g. when training on dataset A and testing on an unrelated dataset B, the training loss remains unchanged, but the risk would be huge and a large $\rho$ is required for a valid bound). (2) With an example, we show a low $f _ { p }$ is insufficient for generalization, and a low $\sigma$ is necessary:
754
+
755
+ A Suppose we use $\rho _ { t r a i n }$ for training, and consider two solutions with $C _ { 1 } , \sigma _ { 1 }$ (SAM) and $C _ { 2 } , \sigma _ { 2 }$ (GSAM). Suppose they have the same $f _ { p }$ during training for some $\rho _ { t r a i n }$ , so $f _ { p 1 } = C _ { 1 } + \sigma _ { 1 } / 2 \times \rho _ { t r a i n } ^ { 2 } = C _ { 2 } + \sigma _ { 2 } / 2 \times \rho _ { t r a i n } ^ { 2 } = f _ { p 2 }$ Suppose $C _ { 1 } < C _ { 2 }$ so $\sigma _ { 1 } > \sigma _ { 2 }$ .
756
+ B When $\rho _ { t r u e } > \rho _ { t r a i n }$ , we have risk bound $\begin{array} { r } { - 1 = C _ { 1 } + \sigma _ { 1 } / 2 \times \rho _ { t r u e } ^ { 2 } + R > \mathrm { r i s k . b o u n d . } 2 = C _ { 2 } + \sigma _ { 2 } / 2 \times \rho _ { t r u e } ^ { 2 } + R } \end{array}$ This implies that a small $\sigma$ helps generalization, but only a low $f _ { p 1 }$ (caused by a low $C _ { 1 }$ and high $\sigma _ { 1 }$ ) is insufficient for a good generalization.
757
+ C Note that $\rho _ { t r a i n }$ is fixed during training, so minimizing $h _ { t r a i n }$ during training is equivalently minimizing $\sigma$ by Lemma 3.3
758
+
759
+ 3. Why we are often unlucky to have $\rho _ { t r u e } ~ > ~ \rho _ { t r a i n }$ (1) First, the test sets are almost surely outside the convex hull of the training set because “‘interpolation almost surely never occurs in high-dimensional $( > ~ 1 0 0 )$ cases”’ Balestriero et al. (2021). As a result, the variability of (train $^ +$ test) sets is almost surely larger than the variability of (train) set. Since $\rho$ increases with data variability (see point 4 below), we have $\rho _ { t r u e } > \rho _ { t r a i n - s e t }$ almost surely. (2) Second, we don’t know the value of $\rho _ { t r u e }$ and can only guess it. In practice, we often guess a small value because training often diverges with large $\rho$ (as observed in Foret et al. (2020); Chen et al. (2021)).
760
+
761
+ 4. Why $\rho$ increases with data variability. In Corollary 5.2.1, we assume weight perturbation $\delta \sim \mathcal { N } ( 0 , b ^ { 2 } I ^ { k } )$ . The meaning of $b$ is the following. If we can randomly sample a fixed number of samples from the underlying distribution, then training the model from scratch (with a fixed seed for random initialization) gives rise to a set of weights. Repeating this process, we get many sets of weights, and their standard deviation is $b$ . Since the number of training samples is limited and fixed, the more variability in data, the more variability in weights, and the larger $b$ . Note that Corollary stated that the bound holds with probability proportional to $[ 1 - e ^ { - ( \frac { \rho } { \sqrt { 2 } b } - \sqrt { k } ) ^ { 2 } } ]$ . In order for the result to hold with a fixed probability, $\rho$ must stay proportional to $b$ , hence $\rho$ also increases with the variability of data.
762
+
763
+ Table 4: Hyper-parameters to reproduce experimental results
764
+
765
+ <table><tr><td>Model</td><td>Pmax</td><td>Pmin</td><td>α</td><td>lrmax</td><td>lrmin</td><td>Weight Decay</td><td>Base Optimizer</td><td>Epochs</td><td>Warmup Steps</td><td>LR schedule</td></tr><tr><td>ResNet50</td><td>0.04</td><td>0.02</td><td>0.01</td><td>1.6</td><td>1.6e-2</td><td>0.3</td><td>SGD</td><td>90</td><td>5k</td><td>Linear</td></tr><tr><td>ResNet101</td><td>0.04</td><td>0.02</td><td>0.01</td><td>1.6</td><td>1.6e-2</td><td>0.3</td><td>SGD</td><td>90</td><td>5k</td><td>Linear</td></tr><tr><td>ResNet512</td><td>0.04</td><td>0.02</td><td>0.005</td><td>1.6</td><td>1.6e-2</td><td>0.3</td><td>SGD</td><td>90</td><td>5k</td><td>Linear</td></tr><tr><td>ViT-S/32</td><td>0.6</td><td>0.0</td><td>0.4</td><td>3e-3</td><td>3e-5</td><td>0.3</td><td>AdamW</td><td>300</td><td>10k</td><td>Linear</td></tr><tr><td>ViT-S/16</td><td>0.6</td><td>0.0</td><td>1.0</td><td>3e-3</td><td>3e-5</td><td>0.3</td><td>AdamW</td><td>300</td><td>10k</td><td>Linear</td></tr><tr><td>ViT-B/32</td><td>0.6</td><td>0.1</td><td>0.6</td><td>3e-3</td><td>3e-5</td><td>0.3</td><td>AdamW</td><td>300</td><td>10k</td><td>Linear</td></tr><tr><td>ViT-B/16</td><td>0.6</td><td>0.2</td><td>0.4</td><td>3e-3</td><td>3e-5</td><td>0.3</td><td>AdamW</td><td>300</td><td>10k</td><td>Linear</td></tr><tr><td>Mixer-S/32</td><td>0.5</td><td>0.0</td><td>0.2</td><td>3e-3</td><td>3e-5</td><td>0.3</td><td>AdamW</td><td>300</td><td>10k</td><td>Linear</td></tr><tr><td>Mixer-S/16</td><td>0.5</td><td>0.0</td><td>0.6</td><td>3e-3</td><td>3e-5</td><td>0.3</td><td>AdamW</td><td>300</td><td>10k</td><td>Linear</td></tr><tr><td>Mixer-S/8</td><td>0.5</td><td>0.1</td><td>0.1</td><td>3e-3</td><td>3e-5</td><td>0.3</td><td>AdamW</td><td>300</td><td>10k</td><td>Linear</td></tr><tr><td>Mixer-B/32</td><td>0.7</td><td>0.2</td><td>0.05</td><td>3e-3</td><td>3e-5</td><td>0.3</td><td>AdamW</td><td>300</td><td>10k</td><td>Linear</td></tr><tr><td>Mixer-B/16</td><td>0.5</td><td>0.2</td><td>0.01</td><td>3e-3</td><td>3e-5</td><td>0.3</td><td>AdamW</td><td>300</td><td>10k</td><td>Linear</td></tr></table>
766
+
767
+ # B EXPERIMENTAL DETAILS
768
+
769
+ # B.1 TRAINING DETAILS
770
+
771
+ For ViT and Mixer, we search the learning rate in $\{ 1 \mathrm { e } { - } 3 , 3 \mathrm { e } { - } 3 , 1 \mathrm { e } { - } 2 , 3 \mathrm { e } { - } 3 \}$ , and search weight decay in $\{ 0 . 0 0 3 , 0 . 0 3 , 0 . 3 \}$ . For ResNet, we search the learning rate in $\left. 1 . 6 , 0 . 1 6 , 0 . 0 1 6 \right.$ , and search the weight decay in $\{ 0 . 0 0 1 , 0 . 0 1 , 0 . 1 \}$ . For ViT and Mixer, we use the AdamW optimizer with $\beta _ { 1 } = 0 . 9 , \beta _ { 2 } = 0 . 9 9 $ ; for ResNet we use SGD with momentum $\ l = 0 . 9$ . We train ResNets for 90 epochs, and train ViTs and Mixers for 300 epochs following the settings in (Chen et al., 2021) and (Dosovitskiy et al., 2020). Considering that SAM and GSAM uses twice the computation of vanilla training for each step, for vanilla training we try $2 \times$ longer training, and does not find significant improvement as in Table. 5.
772
+
773
+ We first search the optimal learning rate and weight decay for vanilla training, and keep these two hyper-parameters fixed for SAM and GSAM. For ViT and Mixer, we search $\rho$ in $\{ 0 . 1 , \bar { 0 . 2 } , 0 . 3 , 0 . 4 ,$ $0 . 5 , 0 . 6 \}$ for SAM and GSAM; for ResNet, we search $\rho$ from 0.01 to 0.05 with a stepsize 0.01. For ASAM, we amplify $\rho$ by $1 0 \times$ compared to SAM, as recommended by Kwon et al. (2021). For GSAM, we search $\alpha$ in $\{ 0 . 1 , 0 . 2 , 0 . 3 \}$ throughout the paper. We report the best configuration of each individual model in Table. 4.
774
+
775
+ # B.2 TRANSFER LEARNING EXPERIMENTS
776
+
777
+ Using weights trained on ImageNet-1k, we finetune models with SGD on downstream tasks including the CIFAR10/CIFAR100 (Krizhevsky et al., 2009), Oxford-flowers (Nilsback & Zisserman, 2008) and Oxford-IITPets (Parkhi et al., 2012). For all experiments, we use the SGD optimizer with no weight decay under a linear learning rate schedule and gradient clipping with global norm 1. We search the maximum learning rate in $\left. 0 . 0 0 1 , 0 . 0 0 3 , 0 . 0 1 , 0 . 0 3 \right.$ . On Cifar datasets, we train models for 10k steps with a warmup step of 500; on Oxford datasets, we train models for 500 steps with a wamup step of 100.
778
+
779
+ # B.3 EXPERIMENTAL SETUP WITH ABLATION STUDIES ON DATA AUGMENTATION
780
+
781
+ We follow the settings in (Tolstikhin et al., 2021) to perform ablation studies on data augmentation. In the left subfigure of Fig. 6, “Light” refers to Inception-style data augmentation with random flip and crop of images, “Medium” refers to the mixup augmentation with probability 0.2 and RandAug magnitude 10; “Strong” refers to the mixup augmentation with probability 0.2 and RandAug magnitude 15.
782
+
783
+ # C ABLATION STUDIES AND DISCUSSIONS
784
+
785
+ # C.1 INFLUENCE OF $\rho$ AND $\alpha$
786
+
787
+ We plot the performance of a ViT-B/32 model varying with $\rho$ (Fig. 7a) and $\alpha$ (Fig. 7b). We empirically validate that fine-tuning $\rho$ in SAM can not achieve comparable performance with GSAM, as
788
+
789
+ ![](images/24eba187fef4c92575a570adcf3b277bd800c56050a22796582502f9883ba719.jpg)
790
+ Figure 7: Performance of GSAM varying with $\rho$ and $\alpha$
791
+
792
+ Table 5: Top-1 accuracy of ViT-B/32 on ImageNet with Inception-style data augmentation. For vanilla training we report results for training 300 epochs and 600 epochs, for GSAM we report the results for 300 epochs.
793
+
794
+ <table><tr><td>Method</td><td>Epochs</td><td>ImageNet</td><td>ImageNet-Real</td><td>ImageNet-v2</td><td>ImageNet-R</td></tr><tr><td rowspan="2">Vanilla</td><td>300</td><td>71.4</td><td>77.5</td><td>57.5</td><td>23.4</td></tr><tr><td>600</td><td>72.0</td><td>78.2</td><td>57.9</td><td>23.6</td></tr><tr><td>GSAM</td><td>300</td><td>76.8</td><td>82.7</td><td>63.0</td><td>25.1</td></tr></table>
795
+
796
+ shown in Fig. 7a. Considering that GSAM has one more parameter $\alpha$ , we plot the accuracy varying with $\alpha$ in Fig. 7b, and show that GSAM consistently outperforms SAM and vanilla training.
797
+
798
+ # C.2 CONSTANT $\rho$ V.S. DECAYED $\rho _ { t }$ SCHEDULE
799
+
800
+ Note that Thm. 5.1 assumes $\rho _ { t }$ to decay with $t$ in order to prove the convergence, while SAM uses a constant $\rho$ during training. To eliminate the influence of $\rho _ { t }$ schedule, we conduct ablation study as in Table. 6. The ascent step in GSAM can be applied to both constant $\rho$ or a decayed $\rho _ { t }$ schedule, and improves accuracy for both cases. Without ascent step, constant $\rho$ and decayed $\rho _ { t }$ achieve similar performance. Results in Table. 6 implies that the ascent step in GSAM is the main reason for improvement of generalization performance.
801
+
802
+ ![](images/9b390274fa28b5ba47c294dfef588e29c76201cc8670a2da5a44ef3d22931fcd.jpg)
803
+ Figure 8: The value of $\cos \theta _ { t }$ varying with training steps, where $\theta _ { t }$ is the angle between $\nabla f ( w _ { t } )$ and $\nabla f _ { p } ( w _ { t } )$ as in Fig. 2.
804
+
805
+ ![](images/c33dd62d4567c39ae55b11964e44b74a04f56f0f5e2ffdc6a47b45abc7f9be5f.jpg)
806
+ Figure 9: Surrogate gap curve under different $\alpha$ values.
807
+
808
+ Table 6: Top-1 Accuracy on ViT-B/32 on ImageNet. Ablation studies on constant $\rho$ or a decayed $\rho _ { t }$
809
+
810
+ <table><tr><td>Vanilla</td><td>Constant p (SAM)</td><td>Constant ρ+ascent</td><td>Decayed ptI</td><td>Decayed pt+ascent</td></tr><tr><td>72.0</td><td>75.8</td><td>76.2</td><td>75.8</td><td>76.8</td></tr></table>
811
+
812
+ # C.3 VISUALIZE THE TRAINING PROCESS
813
+
814
+ In the proof of Thm. 5.3, our analysis relies on assumption that $\theta _ { t }$ is small. We empirically validated this assumption by plotting $\cos \theta _ { t }$ in Fig. 8, where $\theta _ { t }$ is the angle between $\nabla f ( \bar { w } _ { t } )$ and $\nabla f _ { p } ( w _ { t } )$ . Note that the cosine value is calculated in the parameter space of dimension $8 . 8 \times 1 0 ^ { 7 }$ , and in high-dimensional space two random vectors are highly likely to be perpendicular. In Fig. 8 the cosine value is always above 0.9, indicating that $\nabla f ( w _ { t } )$ and $\nabla f _ { p } ( w _ { t } )$ point to very close directions considering the high dimension of parameters. This empirically validates our assumption that $\theta _ { t }$ is small during training.
815
+
816
+ We also plot the surrogate gap during training in Fig. 9. As $\alpha$ increases, the surrogate gap decreases, validating that the ascent step in GSAM efficiently minimizes the surrogate gap. Furthermore, the surrogate gap increases with training steps for any fixed $\alpha$ , indicating that the training process gradually falls into local minimum in order to minimize the training loss.
817
+
818
+ # D RELATED WORKS
819
+
820
+ Besides SAM and ASAM, other methods were proposed in the literature to improve generalization: Lin et al. (2020) proposed extrapolation of gradient, Xie et al. (2021) proposed to manipulate the noise in gradient, and Damian et al. (2021) proved label noise improves generalization, Yue et al. (2020) proposed to adjust learning rate according to sharpness, and Zheng et al. (2021) proposed model perturbation with similar idea to SAM. Izmailov et al. (2018) proposed averaging weights to improve generalization, and Heo et al. (2020) restricted the norm of updated weights to improve generalization. Many of aforementioned methods can be combined with GSAM to further improve generalization.
821
+
822
+ Besides modified training schemes, there are other two types of techniques to improve generalization: data augmentation and model regularization. Data augmentation typically generates new data from training samples; besides standard data augmentation such as flipping or rotation of images, recent data augmentations include label smoothing (Muller et al., 2019) and mixup (M ¨ uller et al., ¨ 2019) which trains on convex combinations of both inputs and labels, automatically learned augmentation (Cubuk et al., 2018), and cutout (DeVries & Taylor, 2017) which randomly masks out parts of an image. Model regularization typically applies auxiliary losses besides the training loss such as weight decay (Loshchilov & Hutter, 2017), other methods randomly modify the model architecture during training, such as dropout (Srivastava et al., 2014) and shake-shake regularization (Gastaldi, 2017). Note that the data augmentation and model regularization literature mentioned here typically train with the standard back-propagation (Rumelhart et al., 1985) and first-order gradient optimizers, and both techniques can be combined with GSAM.
823
+
824
+ Besides SGD, Adam and AdaBelief, GSAM can be combined with other first-order gradient optimizers, such as AdaBound (Luo et al., 2019), RAdam (Liu et al., 2019), Yogi (Zaheer et al., 2018), AdaGrad (Duchi et al., 2011), AMSGrad (Reddi et al., 2019) and AdaDelta (Zeiler, 2012).
md/dev/gJW8hSGBys8/gJW8hSGBys8.md ADDED
The diff for this file is too large to render. See raw diff
 
md/dev/gMS6FVZvmF/gMS6FVZvmF.md ADDED
The diff for this file is too large to render. See raw diff
 
md/dev/gtCPWaY5bNh/gtCPWaY5bNh.md ADDED
@@ -0,0 +1,305 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Deep Model Reassembly
2
+
3
+ Xingyi Yang1 Daquan Zhou1,2 Songhua Liu1 Jingwen Ye1 Xinchao Wang1 1National University of Singapore 2Bytedance {xyang,daquan.zhou,songhua.liu}@u.nus.edu, {jingweny,xinchao}@nus.edu.sg
4
+
5
+ # Abstract
6
+
7
+ In this paper, we explore a novel knowledge-transfer task, termed as Deep Model Reassembly (DeRy), for general-purpose model reuse. Given a collection of heterogeneous models pre-trained from distinct sources and with diverse architectures, the goal of DeRy, as its name implies, is to first dissect each model into distinctive building blocks, and then selectively reassemble the derived blocks to produce customized networks under both the hardware resource and performance constraints. Such ambitious nature of DeRy inevitably imposes significant challenges, including, in the first place, the feasibility of its solution. We strive to showcase that, through a dedicated paradigm proposed in this paper, DeRy can be made not only possibly but practically efficient. Specifically, we conduct the partitions of all pre-trained networks jointly via a cover set optimization, and derive a number of equivalence set, within each of which the network blocks are treated as functionally equivalent and hence interchangeable. The equivalence sets learned in this way, in turn, enable picking and assembling blocks to customize networks subject to certain constraints, which is achieved via solving an integer program backed up with a training-free proxy to estimate the task performance. The reassembled models, give rise to gratifying performances with the user-specified constraints satisfied. We demonstrate that on ImageNet, the best reassemble model achieves $7 8 . 6 \%$ top-1 accuracy without fine-tuning, which could be further elevated to $8 3 . 2 \%$ with end-to-end training. Our code is available at https://github.com/Adamdad/DeRy.
8
+
9
+ # 1 Introduction
10
+
11
+ The unprecedented advances of deep learning and its pervasive impact across various domains are partially attributed to, among many other factors, the numerous pre-trained models released online. Thanks to the generosity of our community, models of diverse architectures specializing in the same or distinct tasks can be readily downloaded and executed in a plug-and-play manner, which, in turn, largely alleviates the model reproducing effort. The sheer number of pre-trained models also enables extensive knowledge transfer tasks, such as knowledge distillation, in which the pre-trained models can be reused to produce lightweight or multi-task students.
12
+
13
+ In this paper, we explore a novel knowledge transfer task, which we coin as Deep Model Reassembly (DeRy). Unlike most prior tasks that largely focus on reusing pre-trained models as a whole, DeRy, as the name implies, goes deeper into the building blocks of pre-trained networks. Specifically, given a collection of such pre-trained heterogeneous models or Model Zoo, DeRy attempts to first dissect the pre-trained models into building blocks and then reassemble the building blocks to tailor models subject to users’ specifications, like the computational constraints of the derived network. As such, apart from the flexibility for model customization, DeRy is expected to aggregate knowledge from heterogeneous models without increasing computation cost, thereby preserving or even enhancing the downstream performances.
14
+
15
+ ![](images/71fb52f346489c984c58bc0d7a00109308d2eda3ec1035b68aa53adde8497cad.jpg)
16
+ Figure 1: Overall workflow of DeRy. It partitions pre-trained models into equivalent sets of neural blocks and then reassemble them for downstream transfer. Both steps are optimized through solving constrained programs.
17
+
18
+ Admittedly, the nature of DeRy per se makes it a highly challenging and ambitious task; in fact, it is even unclear whether a solution is feasible, given that no constraints are imposed over the model architectures in the model zoo. Besides, the reassembly process, which assumes the building blocks can be extracted in the first place, calls for a lightweight strategy to approximate the model performances without re-training, since the reassembled model, apart from the parametric constraints, is expected to behave reasonably well.
19
+
20
+ We demonstrate in this paper that, through a dedicated optimization paradigm, DeRy can be made not only possible by highly efficient. At the heart of our approach is a two-stage strategy that first partitions pre-trained networks into building blocks to form equivalence sets, and then selectively assemble building blocks to customize tailored models. Each equivalence set, specifically, comprises various building blocks extracted from heterogeneous pre-trained models, which are treated to be functionally equivalent and hence interchangeable. Moreover, the optimization of the two steps is purposely decoupled, so that once the equivalence sets are obtained and fixed, they can readily serve as the basis for future network customization.
21
+
22
+ We show the overall workflow of the proposed DeRy in Figure 1. It starts by dissecting pre-trained models into disjoint sets of neural blocks through solving a cover set optimization problem, and derives a number of equivalence sets, within each of which the neural blocks are treated as functionally swappable. In the second step, DeRy searches for the optimal block-wise reassembly in a training-free manner. Specifically, the transfer-ability of a candidate reassembly is estimated by counting the number of linear regions in feature representations [55], which reduces the searching cost by $1 0 ^ { 4 }$ times as compared to training all models exhaustively.
23
+
24
+ The reassembled networks, apart from satisfying the user-specified hard constraints, give rise to truly encouraging results. We demonstrate through experiments that, the reassembled model achieves $>$ $7 8 \%$ top-1 accuracy on Imagenet with all blocks frozen. If we allow for finetuning, the performances can be further elevated, sometimes even surpassing any pre-trained network in the model zoo. This phenomenon showcases that DeRy is indeed able to aggregate knowledge from various models and enhance the results. Besides, DeRy imposes no constraints on the network architectures in the model zoo, and may therefore readily handle various backbones such as CNN, transformers, and MLP.
25
+
26
+ Our contributions are thus summarized as follows.
27
+
28
+ 1. We explore a new knowledge transfer task termed Deep Model Reassembly (DeRy), which enables reassembling customized networks from a zoo of pre-trained models under user-specified constraints. 2. We introduce a novel two-stage strategy towards solving DeRy, by first partitioning the networks into equivalence sets and then reassembling neural blocks to customize networks. The two steps are modeled and solved using constrained programming, backed up with training-free performance approximations that significantly speed up the knowledge-transfer process. 3. The proposed approach achieves competitive performance on a series of transfer learning benckmarks, sometimes even surpassing than any candidate in the model zoo, which, in turn, sheds light on the the universal connectivity among pre-trained neural networks.
29
+
30
+ # 2 Related Work
31
+
32
+ Transfer learning from Model Zoo. A standard deep transfer learning paradigm is to leverage a single trained neural network and fine-tune the model on the target task [85, 87, 45, 35, 98, 96, 33] or impart the knowledge to other models [31, 88, 70, 90, 91, 89, 48]. The availability of large-scale model repositories brings about a new problem of transfer learning from a model zoo rather than with a single model. Currently, there are three major solutions. One line of works focuses on select one best model for deployment, either by exhaustive fine-tuning [39, 74, 87] or quantifying the model transferability [94, 92, 57, 76, 4, 73, 76, 6, 41] on the target task. However, due to the unreliable measurement of transferability, the best model selection may be inaccurate, possibly resulting in a suboptimal solution. The second idea was to apply ensemble methods [19, 99, 2, 97], which inevitably leads to prohibitive computational costs at test time. The third approach is to adaptively fuse multiple pre-trained models into a single target model. However, those methods can only combine identical [71, 18, 78] or homogeneous [72, 58] network structures, whereas most model zoo contains diverse architectures. In contrast to standard approaches in Table 1, DeRy dissects the pre-trained models into building blocks and rearranges them in order to reassemble new pre-trained models.
33
+
34
+ Table 1: Comparison of a series of transfer learning tasks and our proposed Deep Model Reassembly.
35
+
36
+ <table><tr><td rowspan=1 colspan=1>Problem</td><td rowspan=1 colspan=1>No need toretrain</td><td rowspan=1 colspan=1>AdaptiveArchitecture</td><td rowspan=1 colspan=1>No AdditionalComputation</td><td rowspan=1 colspan=1>Utilize AllModels</td><td rowspan=1 colspan=1>|HeterogeneousArchitecture</td></tr><tr><td rowspan=1 colspan=1>Single Model Transfer</td><td rowspan=1 colspan=1>√</td><td rowspan=1 colspan=1>X</td><td rowspan=1 colspan=1>√</td><td rowspan=1 colspan=1>X</td><td rowspan=1 colspan=1>X</td></tr><tr><td rowspan=1 colspan=1>Zoo Transfer by SelectionZoo Transfer by EnsembleZoo Transfer by Parameter Fusion</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>x×X</td><td rowspan=1 colspan=1>×</td><td rowspan=1 colspan=1>X</td><td rowspan=1 colspan=1>×</td></tr><tr><td rowspan=1 colspan=1>Neural Architecture Search</td><td rowspan=1 colspan=1>X</td><td rowspan=1 colspan=1>V</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>=</td><td rowspan=1 colspan=1>-</td></tr><tr><td rowspan=1 colspan=1>DeRy</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>√</td><td rowspan=1 colspan=1>Y</td><td rowspan=1 colspan=1>√</td><td rowspan=1 colspan=1>√</td></tr></table>
37
+
38
+ Neural Representation Similarity. Measuring similarities between deep neural network representations provide a practical tool to investigate the forward dynamics of deep models. Let $\mathbf { X } ^ { ' } \in \mathbb { R } ^ { n \times d _ { 1 } }$ and $\mathbf { Y } \in \mathbb { R } ^ { n \times d _ { 2 } }$ denote two activation matrices for the same $n$ examples. A neural similarity index $s ( X , Y )$ is a scalar to measure the representations similarity between $X$ and $Y$ , although they do not necessarily satisfy the triangle inequality required of a proper metric. Several methods including linear regression [86, 31], canonical correlation analysis (CCA) [65, 27, 64], centered kernel alignment (CKA) [40], generalized shape metrics [81]. In this study, we leverage the representations similarity towards function level to quantify the distance between two neural blocks.
39
+
40
+ Neural Architecture Search. Automatic neural archtecture search (NAS) has achieved promising performance-efficiency trade-offs as well as reducing human efforts. With a pre-defined search space [75, 47, 82, 69], the designing problem of the optimal architecture is formalized as a discrete optimization, where the best solution could be found with reinforcement learning (RL) [100], evolutionary algorithms (EA) [66] or gradient-based search [47]. Because it is costly to measure the performance of each candidate, several surogate methods like one-shot NAS [62, 5, 47], predictorbased NAS [46, 51, 80] and zero-shot NAS [55, 9, 1] are proposed to accelerate the evaluation process. In this paper, we similarly formalize the network reassembly as a search problem; However, compared with NAS that searches at random initialization, DeRy is searching the optimal structure combination along side with network weights. In addition, the search space of DeRy is not preset heuristically, but determined by the network partition results.
41
+
42
+ Network Stitching. Initially proposed by [44], model stitching aims to “plug-in” the bottom layers of one network into the top layers of another network, thus forming a stitched network [3, 16]. It provides an alliterative approach to investigate the representation similarity and invariance of neural networks. A recent line of work achieves competitive performance by stitching a visual transformer on top of the ResNet [74]. Instead of stitching two identical-structured networks in a bottom-top manner, in our study, we investigate to assemble arbitrary pre-trained networks by model stitching.
43
+
44
+ # 3 Deep Model Reassembly
45
+
46
+ In this section, we dive into the proposed DeRy. We first formulate DeRy, and then define the functional similarity and equivalent sets of neural blocks to partition networks by maximizing overall groupbility. The resulting neural blocks are then linked by solving an integer program.
47
+
48
+ ![](images/64ebcfcef54f14e50e95ffe791eaf0c092ecbc6fc36993ebe914de8bf5761d8e.jpg)
49
+ Figure 2: The top-1 accuracy difference between “off-theshelf” pre-trained models on 4 down-stream tasks.
50
+
51
+ Table 3: Accuracy on CIFAR-100 with the pretrained networks and their reassembled ones.
52
+
53
+ <table><tr><td>Backbone</td><td>Init.</td><td>#Params(M)Acc(%)</td><td></td></tr><tr><td>ResNet50</td><td>in1k sup inat2021 sup</td><td>23.71 23.71</td><td>84.67 82.57</td></tr><tr><td>ResNet50</td><td>inat2021(Stage 1&amp;2) inlk(Stage 3&amp;4)</td><td>23.98</td><td>85.30</td></tr><tr><td>ResNet50 Swin-T</td><td>in1k sup</td><td>23.71 27.60</td><td>84.67 85.56</td></tr><tr><td>ResNet50(Stage 1&amp;2)| Swin-T(Stage 3&amp;4)</td><td> in1k sup</td><td>27.94</td><td>85.77</td></tr></table>
54
+
55
+ # 3.1 Problem Formulation
56
+
57
+ composed of Assume we have a collection of $L _ { i } \in \mathbb { N }$ layers of operation pre-trained deep neural network models $\{ F _ { i } ^ { ( k ) } \} _ { l = 1 } ^ { L _ { i } }$ , therefore $\mathcal { M } _ { i } = F _ { i } ^ { ( 1 ) } \circ F _ { i } ^ { ( 2 ) } \cdot \cdot \cdot \circ F _ { i } ^ { ( L _ { i } ) }$ $Z = \{ \mathcal { M } _ { i } \} _ { i = 1 } ^ { N }$ 2) · · · ◦ F (Li)i . that each Each model can be trained on different tasks or with varied structures. We call $Z$ a Model Zoo. We define a learning task $T$ composed of a labeled training set $D _ { t r } = \{ \mathbf { x } _ { j } , y _ { j } \} _ { j = 1 } ^ { M }$ and a test set $D _ { t s } = \{ \mathbf { x } _ { j } \} _ { j = 1 } ^ { L }$
58
+
59
+ Definition 1 (Deep Model Reassembly) Given a task $T$ , our goal is to find the best-performed $L$ -layer compositional model $\mathcal { M } ^ { * }$ on $T$ , subject to hard computational or parametric constraints.
60
+
61
+ We therefore formulate it as an optimization problem
62
+
63
+ $$
64
+ \mathcal { M } ^ { * } = \operatorname* { m a x } _ { \mathcal { M } } P _ { T } ( \mathcal { M } ) , \quad s . t . \mathcal { M } = F _ { i _ { 1 } } ^ { ( l _ { 1 } ) } \circ F _ { i _ { 2 } } ^ { ( l _ { 2 } ) } \cdot \cdot \cdot \circ F _ { i _ { L } } ^ { ( l _ { L } ) } , | \mathcal { M } | \leq C
65
+ $$
66
+
67
+ where $F _ { i } ^ { ( l ) }$ is the $l$ -th layer of the $i$ -th model, $P _ { T } ( \mathcal { M } )$ indicates the performance on $T$ , and $| { \mathcal { M } } | \leq C$ denotes the constraints. For two consecutive layers with dimension mismatch, we add a single stitching layer with $1 \times 1$ convolution operation to adjust the feature size. The stitching layer structure is described in Supplementary.
68
+
69
+ No Single Wins For All. Figure 2 provides a preliminary experiment that 8 different pre-trained models are fine-tuned on 4 different image classification tasks. It is clear that no single model universally dominants in transfer evaluations. It builds up our primary motivation to reassemble trained models rather than trust the “best” candidate.
70
+
71
+ Reassembly Might Win. Table 3 compares the test performance between the reassembled model and its predecessors. The bottom two stages of the ResNet50 iNaturalist2021 (inat2021 sup) [77] are stitched with ResNet50 ImageNet-1k (in1k sup) stage $3 \& 4$ to form a new model for fine-tuning on CIFAR100. This reassembled model improves its predecessors by $0 . 6 3 \% / 2 . 7 3 \%$ accuracy respectively. Similar phenomenon is observed on the reassembled model between ResNet50 in1k and Swin-T in1k. Despite its simplicity, the experiment provides concrete evidence that the neural network reassembly could possibly lead to better model in knowledge transfer.
72
+
73
+ Reducing the Complexity. From the overall $\begin{array} { r } { \bar { M } = \sum _ { i = 1 } ^ { N } L _ { i } } \end{array}$ layers, the search space of $\mathrm { E q ~ } 1$ is of size L-permutations of M $P ( M , L )$ , which is undesirably large. To reduce the overall search cost, we intend to partition the networks into blocks rather than the layer-wise-divided setting. Moreover, it is time-consuming to evaluate each model on the target data through full-time fine-tuning. Therefore, we hope to accelerate the model evaluation, even without model training.
74
+
75
+ Based on the above discussion, the essence of DeRy lies in two steps (1) Partition the networks into blocks and (2) Reassemble the factorized neural blocks. In the following sections, we elaborate on “what is a good partition?” and “what is a good assembly?”.
76
+
77
+ # 3.2 Network Partition by Functional Equivalence
78
+
79
+ A network partition [21, 21] is a division of a neural network into disjoint sub-nets. In this study, we refer specifically to the partition of neural network $\mathcal { M } _ { i }$ along depth into $K$ blocks $\{ B _ { i } ^ { ( k ) } \} _ { k = 1 } ^ { K }$ so that each block is a stack of p layers B(k)i $B _ { i } ^ { ( k ) } = F _ { i } ^ { ( l ) } \circ F _ { i } ^ { ( l + 1 ) } \cdots \circ F _ { i } ^ { ( l + p ) }$ and $k$ is its stage index. Inspired by the hierarchical property of deep neural networks, we aim to partition the neural networks according to their function level, for example, dividing the network into a “low-level” block that identifies curves and a “high-level” block that recognizes semantics. Although we cannot strictly differentiate “low-level” from “high-level”, it is feasible to define functional equivalence.
80
+
81
+ Definition 2 (Functional Equivalence) Given two functions $B$ and $B ^ { \prime }$ with same input space $\mathcal { X }$ and output space $\mathcal { V }$ . $d : \mathcal { V } \times \mathcal { V } \to \mathbb { R }$ is the metric defined on $\mathcal { V }$ . For all inputs $\mathbf { x } \in \mathcal { X }$ , if the outputs are the equivalent $d ( B ( { \bf x } ) , B ^ { \prime } ( { \bf x } ) ) = 0$ , we say $B$ and $B ^ { \prime }$ are functional equivalent.
82
+
83
+ A function is then uniquely determined by its peers who generate the same output with the same input. However, we can no longer define functional equivalence among neural networks, since network blocks might have varied input-output dimensions. It is neither possible to feed the same input to intermediate blocks with different input dimensions, nor allow for a mathematically valid definition for metric space [13, 7] when the output dimensions are not identical. We therefore resort to recent measurements on neural representation similarity [27, 40] and define the functional similarity for neural networks. The intuition is simple: two networks are functionally similar when they produces similar outputs with similar inputs.
84
+
85
+ Definition 3 (Functional Similarity for Neural Networks) Assume we have a neural similarity index $s ( \cdot , \cdot )$ and two neural networks $B : \mathcal { X } \in \mathbb { R } ^ { n \times d _ { i n } } \mathcal { Y } \in \mathbb { R } ^ { n \times d _ { o u t } }$ and $B ^ { \prime } : \mathcal { X } ^ { \prime } \in \mathbb { R } ^ { n \times d _ { i n } ^ { \prime } } \to \mathcal { Y } ^ { \prime } \in$ $\mathbb { R } ^ { n \times d _ { o u t } ^ { \prime } }$ . For any two batches of inputs $\mathbf { X } \subseteq { \mathcal { X } }$ and $\mathbf { X } ^ { \prime } \subseteq { \mathcal { X } } ^ { \prime }$ with large similarity $s ( \mathbf { X } , \mathbf { X } ^ { \prime } ) > \epsilon ;$ the functional similarity between $B$ and $B ^ { \prime }$ are defined as their output similarity $s ( B ( { \bf X } ) , B ^ { \prime } ( { \bf X } ^ { \prime } ) )$ .
86
+
87
+ This definition generalizes well to typical knowledge distillation (KD) [31] when $d _ { i n } = d _ { i n } ^ { \prime }$ , which we will elaborate in the Appendix. We also show in Appendix that Def.3 provides a necessary and insufficient condition for two identical networks. Using the method of Lagrange multipliers, the conditional similarity in Def.3 can be further simplified to $\overset { \triangledown } { \boldsymbol { S } } ( B , B ^ { \prime } ) = s ( B ( \bar { \mathbf { X } } ) , B ^ { \bar { \prime } } ( \mathbf { X } ^ { \prime } ) ) + \bar { s } ( \mathbf { X } , \mathbf { X } ^ { \prime } )$ which is a summation of its input-output similarity. The full derivation is shown in the Appendix.
88
+
89
+ Finding the Equivalence Sets of Neural Blocks. With Def.3, we are equipped with the math tools to partition the networks into equivalent sets of blocks. Blocks in each set are expected to have high similarity, which are treated to be functionally equivalent and hence interchangeable.
90
+
91
+ With a graphical notion, we represent each neural network as a path graph $G ( V , E )$ [25] with two nodes of vertex degree 1, and the other $n - 2$ nodes of vertex degree 2. The ultimate goal is to find the best partition of each graph into $K$ disjoint sub-graphs along the depth, and the dissected sub-nets are concurrently grouped into $K$ functional equivalence sets, that sub-graph within each group has maximum internal functional similarity $S ( B , B ^ { \prime } )$ . In addition, we take a mild assumption that each sub-graph should have approximately similar size $\begin{array} { r } { | B _ { i } ^ { ( k ) } | < ( 1 + \epsilon ) \frac { | \mathcal { M } _ { i } | } { K } } \end{array}$ , where $| \cdot |$ indicates the model size and $\epsilon$ is coefficient controls size limit for each block. We solve the above problem by posing a tri-level constrained optimization with joint clustering and partitioning
92
+
93
+ $$
94
+ \begin{array} { r l } { \displaystyle \operatorname* { m a x } _ { B _ { a _ { j } } } } & { \displaystyle J ( A , \{ B _ { i } ^ { ( k ) } \} ) = \operatorname* { m a x } _ { A _ { ( i , b , p ) } \in \{ 0 , 1 \} } \sum _ { i = 1 } ^ { N } \sum _ { j = 1 } ^ { K } \sum _ { k = 1 } ^ { K } A _ { ( i k , j ) } S ( B _ { i } ^ { ( k ) * } , B _ { a _ { j } } ) } \\ { \displaystyle s . t . } & { \displaystyle \sum _ { j = 1 } ^ { K } A _ { ( i k , j ) } = 1 , \quad \{ B _ { i } ^ { ( k ) * } \} _ { k = 1 } ^ { K } = \arg \operatorname* { m a x } _ { B _ { i } ^ { ( k ) } } \sum _ { k = 1 } ^ { K } A _ { ( i k , j ) } S ( B _ { i } ^ { ( k ) } , B _ { a _ { j } } ) } \\ { \displaystyle s . t . } & { \displaystyle B _ { i } ^ { ( 1 ) } \circ B _ { i } ^ { ( 2 ) } \cdot \cdot \cdot \circ B _ { i } ^ { ( K ) } = \mathcal { M } _ { i } , B _ { i } ^ { ( k _ { 1 } ) } \cap B _ { j } ^ { ( k _ { 2 } ) } = \emptyset , \forall k _ { 1 } \neq k _ { 2 } } \\ & { \displaystyle | B _ { i } ^ { ( k ) } | < ( 1 + \epsilon ) \frac { | \mathcal { M } _ { i } | } { K } , k = 1 , \dots K } \end{array}
95
+ $$
96
+
97
+ Where $A \in \mathbb { N } ^ { K N \times K }$ is the 0-1 assignment matrix, where $\underset { . } { A } _ { ( i k , j ) } = 1$ denote the $B _ { i } ^ { ( k ) }$ block belongs to the -th equivalence set, otherwise 0. Note that each block only belongs to one equivalence set, thus each column sums up to $\begin{array} { r } { 1 , \sum _ { j = 1 } ^ { K } A _ { ( i k , j ) } = 1 . \ B _ { a _ { j } } } \end{array}$ is the anchor node for the $j$ -th equivalence set, which has the maximum summed similarly with all blocks in set $j$ . $B _ { i } ^ { ( k _ { 1 } ) } \cap B _ { j } ^ { ( k _ { 2 } ) } = \varnothing$ refers to the fact the no two blocks has overlapping nodes.
98
+
99
+ The inner optimization largely resembles the conventional set cover problem [32] or $( K , 1 + \epsilon )$ graph partition problem [36] that directly partition a graph into $k$ sets. Although the graph partition falls exactly in a NP-hard [28] problem, heuristic graph partitioning algorithms like Kernighan-Lin (KL) algorithm [38] and Fiduccia–Mattheyses (FM) algorithm [23] can be applied to solve our problem efficiently. In our implementation, we utilize a variant KL algorithm. With a random initialized network partition $\{ \bar { B ^ { ( k ) } } \} _ { k = 1 } ^ { K } | _ { t = 0 }$ for $\mathcal { M }$ at $t = 0$ , we iteratively find the optimal separation by swapping nodes (network layer). Given the two consecutive block B(k)|t = F (l)i · · · ◦ F (l+pk)i and
100
+
101
+ $B ^ { ( k + 1 ) } | _ { t } = F _ { i } ^ { ( l + p _ { k } + 1 ) } \cdot \cdot \cdot \circ F _ { i } ^ { ( l + p _ { k } + p _ { k + 1 } ) }$ at time $t$ , we conduct a forward and a backward neural network layer swap between successive blocks, whereas the partition achieving the largest objective value becomes the new partition
102
+
103
+ $$
104
+ \begin{array} { r } { ( B ^ { ( k ) } | _ { t + 1 } , B ^ { ( k + 1 ) } | _ { t + 1 } ) = \arg \operatorname* { m a x } \{ J ( B ^ { ( k ) } | _ { t } , B _ { i } ^ { ( k + 1 ) } | _ { t } ) , J ( B _ { i } ^ { ( k ) } | _ { t } ^ { \mathrm { f } } , B _ { i } ^ { ( k + 1 ) } | _ { t } ^ { \mathrm { f } } ) , J ( B _ { i } ^ { ( k ) } | _ { t } ^ { \mathrm { b } } , B _ { i } ^ { ( k + 1 ) } | _ { t } ^ { \mathrm { b } } ) \} } \end{array}
105
+ $$
106
+
107
+ $$
108
+ \begin{array} { r } { ( B _ { i } ^ { ( k ) } | _ { t } ^ { \mathsf { f } } , B _ { i } ^ { ( k + 1 ) } | _ { t } ^ { \mathsf { f } } ) = B ^ { ( k ) } | _ { t } \xrightarrow { F _ { i } ^ { l + p _ { k } } } B _ { i } ^ { ( k + 1 ) } , ( B _ { i } ^ { ( k ) } | _ { t } ^ { \mathsf { b } } , B _ { i } ^ { ( k + 1 ) } | _ { t } ^ { \mathsf { b } } ) = B ^ { ( k ) } | _ { t } \underbrace { F _ { i } ^ { l + p _ { k } + 1 } } _ { \qquad } B _ { i } ^ { ( k + 1 ) } } \end{array}
109
+ $$
110
+
111
+ For the outer optimization, we do a K-Means [52] style clustering. With the current network partition $\{ B ^ { ( k ) * } \} _ { k = 1 } ^ { K }$ , we alternate between assigning each block to a equivalence set $G _ { j }$ , and identifying the anchor block within each set $B _ { a _ { j } } \in G _ { j }$ . It has been proved that both $\mathrm { K L }$ and K-Means algorithms converge to a local minimum according to the initial partition and anchor selection. We repeat the optimization for $R = 2 0 0$ runs with different seeds and select the best partition as our final results.
112
+
113
+ # 3.3 Network Reassembly by Solving an Integer Program
114
+
115
+ As we have divided each deep network into $K$ partitions, each belongs to one of the $K$ equivalence sets, all we want now is to find the best combination of neural blocks as a new pre-trained model under certain computational constraints. Consider $K$ disjoint equivalence sets $G _ { 1 } , \ldots , G _ { K }$ of blocks to be reassembled into a new deep network of parameter constraint $C _ { \mathrm { p a r a m } }$ and computational constraint $C _ { \mathrm { F L O P s } }$ , the objective is to choose exactly one block from each group $G _ { j }$ as well as from each network stage index $j$ such that the reassembled model achieves optimal performance on the target task without exceeding the capacity. We introduce two the binary matrices $X _ { ( i k , j ) }$ and $Y _ { \left( i k , j \right) }$ to uniquely identity the reassembled model ${ \mathcal { M } } ( X , Y )$ . $X _ { ( i k , j ) }$ takes on value 1 if and only if $B _ { i } ^ { ( k ) }$ is chosen in group $G _ { j }$ , and $Y _ { ( i k , j ) } = 1$ if $B _ { i } ^ { ( k ) }$ comes from the $k$ -th block. The selected blocks are arranged by the block stage index. The problem is formulated as
116
+
117
+ $$
118
+ \begin{array} { l } { \displaystyle \operatorname* { m a x } _ { X , Y } P _ { T } \big ( \boldsymbol { \mathcal { M } } ( X , Y ) \big ) } \\ { \displaystyle \mathrm { ~ s . t . ~ } \big \vert \boldsymbol { \mathcal { M } } ( X , Y ) \big \vert \leq C _ { \mathrm { p a r a m } } , F L O P s ( \boldsymbol { \mathcal { M } } ( X , Y ) ) \leq C _ { \mathrm { F L O P s } } } \\ { \displaystyle ~ \sum _ { i = 1 } ^ { N } \sum _ { k = 1 } ^ { K } X _ { ( i k , j ) } = 1 , X _ { ( i k , j ) } \in \{ 0 , 1 \} , j = 1 , \dots , K } \\ { \displaystyle ~ \sum _ { i = 1 } ^ { N } \sum _ { j = 1 } ^ { K } Y _ { ( i k , j ) } = 1 , Y _ { ( i k , j ) } \in \{ 0 , 1 \} , k = 1 , \dots , K } \end{array}
119
+ $$
120
+
121
+ where $P _ { T }$ is again the task performance. Equation 10 and 11 indicates that each model only possesses a single block from each equivalence set and each stage index. As such, the reassembled blocks are automatically ordered through its stage index in their original model. The problem falls exactly into a $O$ -1 Integer Programming [60] problem with a non-linear objective. Conventional methods train each ${ \mathcal { M } } ( X , Y )$ to obtain $P _ { T }$ . Instead of training each candidate till convergence, we estimate the transfer-ability of a network by counting the linear regions in the network as a training-free proxy.
122
+
123
+ Estimating the Performance with Training-Free Proxy. The number of linear region [56, 26] is a theoretical-grounded tool to describe the expressivity of a neural network, which has been successfully applied on NAS without training [55, 10]. We, therefore, calculate the data-dependent linear region to estimate the transfer performance of each model-task combination. The intuition is straightforward: the network can hardly learn to distinguish inputs with similar binary codes.
124
+
125
+ We apply random search to get a generation of reassembly candidates. For a whole mini-batch of inputs, we feed them into each network and binarilize the features vectors using a sign function. Similar to NASWOT [55], we compute the kernel matrix K using Hamming distance $d ( \cdot , \cdot )$ and rank the models using $\log ( \operatorname* { d e t } \mathbf { K } )$ . Since the computation of $\mathbf { K }$ requires nothing more than a few batches of network forwarding, we replace $P _ { T }$ in Equation 8 with NASWOT score for fast model evaluation.
126
+
127
+ # 4 Experiments
128
+
129
+ In this section, we first explore some basic properties of the the proposed DeRy task, and then evaluate our solution on a series of transfer learning benchmarks to verify its efficiency.
130
+
131
+ ![](images/ec618e193fff618b3516676a9399cd67cfa7c784da456f6f8cc23d08d1ee8d6a.jpg)
132
+ Figure 4: FROZEN-TUNING accuracy on ImageNet by replacing the $3 ^ { \mathrm { n d } }$ and $4 ^ { \mathrm { t h } }$ stage of R50 to target blocks.
133
+
134
+ ![](images/574743455fc22564ea4840e2fda3fef0aa07566ea3d5b72a1abf61cdc4ad3924.jpg)
135
+ Figure 5: Pair-wise Linear CKA between pre-trained R50 and (1) R101 (2) RX50 and (3) Reg8G.
136
+
137
+ Model Zoo Setup. We construct our model zoo by collecting pre-trained weights from Torchvision 1, timm 2 and OpenMMlab 3. We includes a series of manually designed CNN models like ResNet [30] and ResNeXt[84], as well as NAS-based architectures like RegNetY [63] and MobileNetv3 [34]. Due to recent popularity of vision transformer, we also take several well-known attention-based architectures into consideration, including Vision Transformer (ViT) [20] and Swin-Transformer [49]. In addition to the differentiation of the network structure pre-trained on ImageNet, we include models with a variety of pre-trained strategies, including SimCLR [8], MoCov2 [11] and BYOL [24] for ResNet50, MoCov3 [12] and MAE [29] for ViT-B. Those models are pre-trained on ImageNet1k [68], ImageNet21K [67], Xrays [15] and iNaturalist2021 [77], Finally we result in 21 network architectures, with 30 pre-trained weights in total. We manually identify the atomic node to satisfy our line graph assumption. Each network is therefore a line graph composed of atomic nodes.
138
+
139
+ Implementation details. For all experiments, we set the partition number $K = 4$ and the block size coefficient $\epsilon = 0 . 2$ . We sample 1/20 samples from each train set to calculate the linear CKA representation similarity. The NASWOT [55] score is estimated with 5-batch average, where each mini-batch contains 32 samples. We set 5 levels of computational constraints, with $C _ { \mathrm { p a r a m } } \in$ $\{ 1 0 , 2 0 , 3 0 , 5 0 , 9 0 \}$ and $C _ { \mathrm { F L O P s } } \in \{ 3 , 5 , 6 , 1 0 , 2 0 \}$ , which is denoted as $\mathsf { D e R y } ( K , C _ { \mathrm { p a r a m } } , C _ { \mathrm { F L O P s } } )$ . For each setting, we randomly generated 500 candidates. Each reassembled model is evaluate under 2 protocols (1) FROZEN-TUNING. We freeze all trained blocks and only update the parameter for the stitching layer and the last linear classifier and (2) FULL-TURNING. All network parameter are updated. All experiments are conducted on a $8 \times$ GeForce RTX 3090 server. To reduce the feature similarity calculation cost, we construct the similarity table offline on ImageNet. The complexity analysis and full derivation are shown in the Appendix.
140
+
141
+ # 4.1 Exploring the Properties for Deep Reassembly
142
+
143
+ Similarity, Position and Reassembly-ability. Figure 4 validates our functional similarity, reassembled block selection, and its effect on the model performance. For the ResNet50 trained on ImageNet, we replace its $3 ^ { \mathrm { n d } }$ and $4 ^ { \mathrm { t h } }$ stage with a target block from another pre-trained network (ResNet101, ResNeXt50 and RegNetY8G), connected by a single stitching layer. Then, the reassembled networks are re-trained on ImageNet for a 20 epochs under FROZEN-TURNING protocol. The derived functional similarity in Section 3.2 is shown as the diameter of each circle. We observe that, the stitching position makes a substantial difference regarding the reassembled model performance. When replaced with a target block with the same stage index, the reassembled model performs surprisingly well, with $\ge 7 0 \%$ top-1 accuracy, even if its predecessors are trained with different architectures, seeds, and hyperparameters. It is also noted that, though function similarity is not numerically proportional to the target performance, it correctly reflects the performance ranking within the same target network. It suggests that our function similarity provides a reasonable criteria to identify equivalence set. In sum, the coupling between the similarity-position-performance explains our design to select one block from each equivalence set as well as the stage index. We also visualize the linear CKA [40] similarity between the R50 and the target networks in Figure 5. An interesting finding is that diagonal pattern for the feature similarity. The representation at the same stage is highly similar. More similarity visualizations are provided in the Appendix.
144
+
145
+ Partition Results. Due to the space limitation, the partition results of the model zoo are provided in the Appendix. Our observation is that, the equivalent sets tend to cluster the blocks by stage index.
146
+
147
+ ![](images/2faf5a95c2bddaa87dba5f9182157a07516429f5002229ebd1bc3d68fd519e4d.jpg)
148
+ Figure 6: Plots of NASWOT [55] score and test accuracy for (Left) 10 pre-trained model on 8 downstream tasks and (Right) timm model zoo on ImageNet. $\tau$ is the Kendall’s Tau correlation.
149
+
150
+ For example, all bottom layers of varied pre-trained networks are within the same equivalence set. It provides valuable insight that neural networks learns similar patterns at similar network stage.
151
+
152
+ Architecture or Pre-trained Weight. Since DeRy searches for the architecture and weights concurrently, a natural question arises that “Do both architecture and pre-trained weights lead to the final improvement? Or only architecture counts?” We provide the experiments in the Appendix that both factors contribute. It is observed that training the DeRy architecture from scratch leads to a substantial performance drop compared with DeRy model with both new structures and pre-trained weights. It validates our arguments that our reassembled models benefit from the pre-trained models for efficient transfer learning.
153
+
154
+ Verifying the training-free proxy. As the first attempt to apply the NASWOT to measure model transfer-ability, we verify its efficacy before applying it to DeRy task. We adopt the score to rank 10 pre-trained models on 8 image classification tasks, as well as the timm model zoo on ImageNet, shown in Figure 6. We also compute the Kendall’s Tau correlation [37] between the fine-tuned accuracy and the NASWOT score. It is observed that the NASWOT score provides a reasonable predictor for model transfer-ability with a high Kendall’s Tau correlation.
155
+
156
+ # 4.2 Transfer learning with Reassembled Model
157
+
158
+ Evaluation on ImageNet1k. We first compare the reassembled network on ImageNet [68] with current best-performed architectures. We train each model for either 100 epochs as SHORT-TRAINING or a 300 epochs as FULL-TRAINING. Except for DeRy, all models are trained from scratch. We optimize each network with AdamW [50] alongside a initial learning rate of $1 e - 3$ and cosine lr-decay, mini-batch of 1024 and weight decay of 0.05. We apply RandAug [17], Mixup [95] and CutMix [93] as data augmentation. All model are trained and tested on 224 image resolutions.
159
+
160
+ Table 7 provides the Top-1 accuracy comparison on Imagenet with various computational constraint. We underline the best-performed model in the model zoo. First, It is worth-noting that DeRy provide very competitive model, even under FROZEN-TURNING or SHORT-TRAINING protocol. DeRy(4,90,20) manages to reach $7 8 . 6 \%$ with 1.27M parameter trainable, which provides convincing clue that the heterogeneous trained model are largely graftable. With only SHORT-TRAINING, DeRy models also match up with the full-time trained model in the zoo. For example, DeRy(4,10,3) gets to $7 6 . 9 \%$ accuracy within 100 epochs’ training, surpassing all small-sized models. The performance can be further improved towards $7 8 . 4 \%$ with the standard 300-epoch training. Second, DeRy brings about faster convergence. We compare with ResNet-50 and Swin-T under the same SHORT-TRAINING setting in Table 9 and Figure 10. It is clear that, by assembling the off-the-self pre-trained blocks, the DeRy models can be optimized faster than the it competitors, achieving $0 . 9 \%$ and $0 . 2 \%$ accuracy improvement over the Swin-T model with less parameter and computational requirements. Third, as showcased in Figure 8, our DeRy is able to search for diverse and hybrid network structures. DeRy(4,10,3) learns to adopt light-weight blocks like MobileNetv3, while DeRy(4,90,20) gets to a large CNN-Swin hybrid architecture. Similar hybrid strategy has been proved to be efficient in manual network design [54, 83].
161
+
162
+ Transfer Image classification. We evaluate transfer learning performance on 9 natural image datasets. These datasets covered a wide range of image classification tasks, including 3 object classification
163
+
164
+ Table 7: Top-1 accuracy of models trained on ImageNet. † means the model is trained for 100 epochs. “FZ” and “FT” denote the reassembled blocks are frozen or fine-tuned. Trainable parameters are marked in red.
165
+
166
+ <table><tr><td colspan="4">Architecture #Train/All Params (M) FLOPs (G)</td></tr><tr><td>RSB-ResNet-18</td><td>11.69/11.69</td><td>1.82</td><td>Top-1 70.6</td></tr><tr><td>RegNetY-800M</td><td>6.30/6.30</td><td>0.8</td><td>76.3</td></tr><tr><td>ViT-T16</td><td>5.7/5.7</td><td>1.3</td><td>74.1</td></tr><tr><td>DeRy(4,10,3)-FZ</td><td>1.02/7.83</td><td>2.99</td><td>41.2</td></tr><tr><td>DeRy(4,10,3)-FTt</td><td>7.83/7.83</td><td>2.99</td><td>76.9</td></tr><tr><td>DeRy(4,10,3)-FT</td><td>7.83/7.83</td><td>2.99</td><td>78.4</td></tr><tr><td>RSB-ResNet-50</td><td>25.56/25.56</td><td>4.12</td><td>79.8</td></tr><tr><td>RegNetY-4GF</td><td>20.60/20.60</td><td>4.0</td><td>79.4</td></tr><tr><td>ViT-S16</td><td>22.0/22.0</td><td>4.6</td><td>79.6</td></tr><tr><td>Swin-T</td><td>28.29/28.29</td><td>4.36</td><td>81.2</td></tr><tr><td>DeRy(4,30,6)-FZt</td><td>1.57/24.89</td><td>4.47</td><td>60.5</td></tr><tr><td>DeRy(4,30,6)-FTt</td><td>24.89/24.89</td><td>4.47</td><td>79.6</td></tr><tr><td>DeRy(4,30,6)-FT</td><td>24.89/24.89</td><td>4.47</td><td>81.2</td></tr><tr><td>RSB-ResNet-101</td><td>44.55/44.55</td><td>7.85</td><td>81.3</td></tr><tr><td>RegNetY-8GF</td><td>39.20/39.20</td><td>8.1</td><td>81.7</td></tr><tr><td>Swin-S</td><td>49.61/49.61</td><td>8.52</td><td>82.8</td></tr><tr><td>DeRy(4,50,10)-FZ</td><td>3.92/40.41</td><td>6.43</td><td>72.0</td></tr><tr><td>DeRy(4,50,10)-FTt</td><td>40.41/40.41</td><td>6.43</td><td>81.3</td></tr><tr><td>DeRy(4,50,10)-FT</td><td>40.41/40.41</td><td>6.43</td><td>82.3</td></tr><tr><td>RegNetY-16GF</td><td>83.6/83.6</td><td></td><td></td></tr><tr><td>ViT-B16</td><td>86.86/86.86</td><td>16.0</td><td>82.9 79.8</td></tr><tr><td></td><td></td><td>33.03</td><td></td></tr><tr><td>Swin-B</td><td>87.77/87.77</td><td>15.14</td><td>83.1</td></tr><tr><td>DeRy(4,90,20)-FZt</td><td>1.27/ 80.66</td><td>13.29</td><td>78.6</td></tr><tr><td>DeRy(4,90,20)-FTt</td><td>80.66/ 80.66</td><td>13.29</td><td>82.4</td></tr><tr><td>DeRy(4,90,20)-FT</td><td>80.66/ 80.66</td><td>13.29</td><td>83.2</td></tr></table>
167
+
168
+ ![](images/d2bc2f5e7e383c032f4ec398019222f60fa5df7b4346a51cba5d6ba4e68c06df.jpg)
169
+ Figure 8: Reassembled structures on ImageNet.
170
+
171
+ <table><tr><td>Architecture</td><td>|Params (M)|FLOPs (G)|Top-1</td><td></td><td></td><td>Top-5</td></tr><tr><td>ResNet-50</td><td>25.56</td><td>4.12</td><td>76.8</td><td>93.3</td></tr><tr><td>Swin-T</td><td>28.29</td><td>4.36</td><td>78.3</td><td>94.6</td></tr><tr><td>DeRy(30,6)-FT</td><td>24.89</td><td>4.47</td><td>79.6</td><td>94.8</td></tr><tr><td>ResNet-101</td><td>44.55</td><td>7.85</td><td>79.0</td><td>94.5</td></tr><tr><td>Swin-S</td><td>49.61</td><td>8.52</td><td>80.8</td><td>95.7</td></tr><tr><td>DeRy(50,10)-FT</td><td>40.41</td><td>6.43</td><td>81.2</td><td>95.6</td></tr></table>
172
+
173
+ Table 9: Top-1 and Top-5 Accuracy for the ImageNet 100-epoch FULL-TUNING experiment.
174
+
175
+ ![](images/88f4a96ec645e6a3b9eab612935b5ae37deb643c5adf0a726acc8758195b47ef.jpg)
176
+ Table 10: (Left) Test accuracy and (Right) Train loss comparison under the 100-epoch training on ImageNet.
177
+
178
+ ![](images/aa1878ded045cc643622dc7cfd5a8752452527dba72dd3bdd7acee14cd3d98ca.jpg)
179
+ Figure 11: Transfer performance on 9 image classification tasks with the model zoo and our DeRy. Each blue or orange point refers to a single model trained from scratch or pre-trained weights.
180
+
181
+ tasks CIFAR-10 [43], CIFAR-100 [43] and Caltech-101 [22]; 5 fine-grained classification tasks Flower-102 [59], Stanford Cars [42], FGVC Aircraft[53], Oxford-IIIT Pets [61] and CUB-Bird [79] and 1 texture classification task DTD [14]. We FULL-TUNE all candidate networks in the model zoo and compare them with our DeRy model. Two model selection strategies LogME [92] and LEEP [57] are also taken as our baselines. For fair comparison, we further train the reassembled network on ImageNet for 100 epochs to further boost the transfer performance. Following [8, 41], we perform hyperparameter tuning for each model-task combination, which are elaborated in the Appendix.
182
+
183
+ Figure 11 compares the transfer performance between our proposed DeRy and all candidate models. By constructing models from building blocks, the DeRy generally surpasses all network trained from scratch within the same computational constraints, even beats pre-trained ones on Cars, Aircraft, and Flower. If allowing for pre-training on ImageNet (DeRy+In1k), we can further promote the test accuracy, even better than the best-performing candidate in the original model zoo (highlighted by $\times )$ . The performance improvement rises up as parameter constraints increase, which demonstrates the scalability of the proposed solution. Model selection approaches like LogME and LEEP may not necessarily get the optimal model, thus failing to release the full potential of the model zoo. These findings provide encouraging evidence that DeRy gives rise to an alternative approach to improve the performance when transferring from a zoo of models.
184
+
185
+ # 4.3 Ablation Study
186
+
187
+ To support the effectiveness of the DeRy pipeline, we further verify influence of each design in our solution through ablation studies.
188
+
189
+ Partition and Reassembly Strategy. First, we conduct experiments by replacing the (1) cover set partition and (2) training-free reassembly with random partition or search. For the partition ablation, we randomly dissect each network into $K$ partitions and reassemble the blocks in an order-less manner using our training-free proxy. For the reassembly ablation, we retain the cover set partition and fine-tune each randomly reassembled network for 100 epochs. Due to the computation limitation, we can only evaluate
190
+
191
+ <table><tr><td rowspan=1 colspan=1>Cover SetPartition</td><td rowspan=1 colspan=1>Train-FreeReassembly</td><td rowspan=1 colspan=1>Acc (%)</td><td rowspan=1 colspan=1>Search Cost(GPU days)</td></tr><tr><td rowspan=1 colspan=1>√</td><td rowspan=1 colspan=1>√</td><td rowspan=1 colspan=1>72.0</td><td rowspan=1 colspan=1>0.23</td></tr><tr><td rowspan=1 colspan=1>X</td><td rowspan=1 colspan=1>√</td><td rowspan=1 colspan=1>70.5</td><td rowspan=1 colspan=1>1.48</td></tr><tr><td rowspan=1 colspan=1>√</td><td rowspan=1 colspan=1>X</td><td rowspan=1 colspan=1>73.5</td><td rowspan=1 colspan=1>135</td></tr><tr><td rowspan=1 colspan=1>X</td><td rowspan=1 colspan=1>X</td><td rowspan=1 colspan=1>72.2</td><td rowspan=1 colspan=1>135</td></tr></table>
192
+
193
+ 25 candidates for reassembly ablation. We report the 100-epoch FROZEN-TUNING top-1 accuracy and the search time on ImageNet in Table 2 under the DeRy(4,50,10) setting. Note that we do not include the similarity computation time into our account since it is computed offline. We see that the majority of the search cost comes from the fine-tuning stage. The training-free proxy largely alleviates the tremendous computational cost by $1 0 ^ { 4 }$ times, with marginal performance degradation. On the other hand, the cover set model partition not only improves the transfer performance but also reduces the reassembly search space from $O ( \prod _ { i = 1 } ^ { N } \binom { L _ { i } - 1 } { K - 1 } )$ ) to $O ( 1 )$ . Both stages are crucial.
194
+
195
+ Granularity of Partition. To see the impact of partition number $K$ , here we show the experimental results with different $K \in \{ 4 , 5 , 6 \}$ . We set the configuration to DeRy(K, 30, 6). The reassembled network is trained with FULL-TUNING setting on ImageNet for 100 epochs. We report the parameter size, FLOPs as well as their top-1 and top-5 accuracy. As demonstrated in the Table 3, We notice that, as the partition number $K$ increases, the performance of the reassembled model remains quite stable or slightly increase. It suggest that DeRyis highly flexible with different granularity of partitioning.
196
+
197
+ <table><tr><td rowspan=1 colspan=1>Partition Number</td><td rowspan=1 colspan=1># Param</td><td rowspan=1 colspan=1>FLOPs</td><td rowspan=1 colspan=1>Top-1</td><td rowspan=1 colspan=1>Top-5</td></tr><tr><td rowspan=1 colspan=1>K=4</td><td rowspan=1 colspan=1>24.89</td><td rowspan=1 colspan=1>4.47</td><td rowspan=1 colspan=1>79.6</td><td rowspan=1 colspan=1>94.8</td></tr><tr><td rowspan=1 colspan=1>K=5</td><td rowspan=1 colspan=1>21.14</td><td rowspan=1 colspan=1>5.53</td><td rowspan=1 colspan=1>79.7</td><td rowspan=1 colspan=1>94.9</td></tr><tr><td rowspan=1 colspan=1>K=6</td><td rowspan=1 colspan=1>23.38</td><td rowspan=1 colspan=1>5.39</td><td rowspan=1 colspan=1>79.8</td><td rowspan=1 colspan=1>95.0</td></tr></table>
198
+
199
+ Table 3: Ablation study on partition granularity with $\overline { { K \in \{ 4 , 5 , 6 \} } }$
200
+
201
+ # 5 Conclusion
202
+
203
+ In this study, we explore a novel knowledge-transfer task called Deep Model Reassembly (DeRy). DeRy seeks to deconstruct heterogeneous pre-trained neural networks into building blocks and then reassemble them into models subject to user-defined constraints. We provide a proof-of-concept solution to show that DeRy can be made not only possible but practically efficient. Specifically, pretrained networks are partitioned jointly via a cover set optimization to form a series of equivalence sets. The learned equivalence sets enable choosing and assembling blocks to customize networks, which is accomplished by solving integer program with a training-free task-performance proxy. DeRy not only achieves gratifying performance on a series of transfer learning benchmarks, but also sheds light on the functional similarity between neural networks by stitching heterogeneous models.
204
+
205
+ # Acknowledgement
206
+
207
+ This research is supported by the National Research Foundation, Singapore under its AI Singapore Programme (AISG Award No: AISG2-RP-2021-023). Xinchao Wang is the corresponding author.
208
+
209
+ References [1] Mohamed S Abdelfattah, Abhinav Mehrotra, Łukasz Dudziak, and Nicholas Donald Lane. Zero-cost proxies for lightweight {nas}. In International Conference on Learning Representations, 2021.
210
+ [2] Andrea Agostinelli, Jasper Uijlings, Thomas Mensink, and Vittorio Ferrari. Transferability metrics for selecting source model ensembles. arXiv preprint arXiv:2111.13011, 2021. [3] Yamini Bansal, Preetum Nakkiran, and Boaz Barak. Revisiting model stitching to compare neural representations. Advances in Neural Information Processing Systems, 34, 2021.
211
+ [4] Yajie Bao, Yang Li, Shao-Lun Huang, Lin Zhang, Lizhong Zheng, Amir Zamir, and Leonidas Guibas. An information-theoretic approach to transferability in task transfer learning. In 2019 IEEE International Conference on Image Processing (ICIP), pages 2309–2313. IEEE, 2019.
212
+ [5] Gabriel Bender, Pieter-Jan Kindermans, Barret Zoph, Vijay Vasudevan, and Quoc Le. Understanding and simplifying one-shot architecture search. In Jennifer Dy and Andreas Krause, editors, Proceedings of the 35th International Conference on Machine Learning, volume 80 of Proceedings of Machine Learning Research, pages 550–559. PMLR, 10–15 Jul 2018.
213
+ [6] Daniel Bolya, Rohit Mittapalli, and Judy Hoffman. Scalable diverse model selection for accessible transfer learning. Advances in Neural Information Processing Systems, 34, 2021.
214
+ [7] Valeri˘ı Vladimirovich Buldygin and IU V Kozachenko. Metric characterization of random variables and random processes, volume 188. American Mathematical Soc., 2000. [8] Ting Chen, Simon Kornblith, Mohammad Norouzi, and Geoffrey Hinton. A simple framework for contrastive learning of visual representations. In International conference on machine learning, pages 1597–1607. PMLR, 2020. [9] W. Chen, X. Gong, and Z. Wang. Neural architecture search on imagenet in four gpu hours: A theoretically inspired perspective, 2021.
215
+ [10] Wuyang Chen, Xinyu Gong, and Zhangyang Wang. Neural architecture search on imagenet in four gpu hours: A theoretically inspired perspective. In International Conference on Learning Representations, 2021.
216
+ [11] Xinlei Chen, Haoqi Fan, Ross Girshick, and Kaiming He. Improved baselines with momentum contrastive learning. arXiv preprint arXiv:2003.04297, 2020.
217
+ [12] Xinlei Chen, Saining Xie, and Kaiming He. An empirical study of training self-supervised vision transformers. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 9640–9649, 2021.
218
+ [13] B. Choudhary. The Elements of Complex Analysis. New Age International Publishers, 1992.
219
+ [14] 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.
220
+ [15] Joseph Paul Cohen, Joseph D. Viviano, Paul Bertin, Paul Morrison, Parsa Torabian, Matteo Guarrera, Matthew P Lungren, Akshay Chaudhari, Rupert Brooks, Mohammad Hashir, and Hadrien Bertrand. TorchXRayVision: A library of chest X-ray datasets and models. In Medical Imaging with Deep Learning, 2022.
221
+ [16] Adrián Csiszárik, Péter Korösi-Szabó, Ákos Matszangosz, Gergely Papp, and Dániel Varga. Similarity ˝ and matching of neural network representations. Advances in Neural Information Processing Systems, 34, 2021.
222
+ [17] 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, pages 702–703, 2020.
223
+ [18] Dong Dai and Tong Zhang. Greedy model averaging. Advances in Neural Information Processing Systems, 24, 2011.
224
+ [19] Thomas G Dietterich. Ensemble methods in machine learning. In International workshop on multiple classifier systems, pages 1–15. Springer, 2000.
225
+ [20] 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.
226
+ [21] Tomas Feder, Pavol Hell, Sulamita Klein, and Rajeev Motwani. Complexity of graph partition problems. In Proceedings of the thirty-first annual ACM symposium on Theory of computing, pages 464–472, 1999.
227
+ [22] 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, pages 178–178. IEEE, 2004.
228
+ [23] Charles M Fiduccia and Robert M Mattheyses. A linear-time heuristic for improving network partitions. In 19th design automation conference, pages 175–181. IEEE, 1982.
229
+ [24] Jean-Bastien Grill, Florian Strub, Florent Altché, Corentin Tallec, Pierre Richemond, Elena Buchatskaya, Carl Doersch, Bernardo Avila Pires, Zhaohan Guo, Mohammad Gheshlaghi Azar, et al. Bootstrap your own latent-a new approach to self-supervised learning. Advances in Neural Information Processing Systems, 33:21271–21284, 2020.
230
+ [25] Jonathan L Gross, Jay Yellen, and Mark Anderson. Graph theory and its applications. Chapman and Hall/CRC, 2018.
231
+ [26] Boris Hanin and David Rolnick. Complexity of linear regions in deep networks. In International Conference on Machine Learning, pages 2596–2604. PMLR, 2019.
232
+ [27] David R Hardoon, Sandor Szedmak, and John Shawe-Taylor. Canonical correlation analysis: An overview with application to learning methods. Neural computation, 16(12):2639–2664, 2004.
233
+ [28] Juris Hartmanis. Computers and intractability: a guide to the theory of np-completeness (michael r. garey and david s. johnson). Siam Review, 24(1):90, 1982.
234
+ [29] Kaiming He, Xinlei Chen, Saining Xie, Yanghao Li, Piotr Dollár, and Ross Girshick. Masked autoencoders are scalable vision learners. arXiv:2111.06377, 2021.
235
+ [30] Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 770–778, 2016.
236
+ [31] Geoffrey Hinton, Oriol Vinyals, Jeff Dean, et al. Distilling the knowledge in a neural network. arXiv preprint arXiv:1503.02531, 2(7), 2015.
237
+ [32] Dorit S Hochba. Approximation algorithms for np-hard problems. ACM Sigact News, 28(2):40–52, 1997.
238
+ [33] Qibin Hou, Daquan Zhou, and Jiashi Feng. Coordinate attention for efficient mobile network design. In Proceedings of the IEEE/CVF conference on computer vision and pattern recognition, pages 13713–13722, 2021.
239
+ [34] Andrew Howard, Mark Sandler, Grace Chu, Liang-Chieh Chen, Bo Chen, Mingxing Tan, Weijun Wang, Yukun Zhu, Ruoming Pang, Vijay Vasudevan, et al. Searching for mobilenetv3. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 1314–1324, 2019.
240
+ [35] Jeremy Howard and Sebastian Ruder. Universal language model fine-tuning for text classification. arXiv preprint arXiv:1801.06146, 2018.
241
+ [36] George Karypis and Vipin Kumar. Multilevel k-way hypergraph partitioning. VLSI design, 11(3):285–300, 2000.
242
+ [37] Maurice G Kendall. A new measure of rank correlation. Biometrika, 30(1/2):81–93, 1938.
243
+ [38] Brian W Kernighan and Shen Lin. An efficient heuristic procedure for partitioning graphs. The Bell system technical journal, 49(2):291–307, 1970.
244
+ [39] Alexander Kolesnikov, Lucas Beyer, Xiaohua Zhai, Joan Puigcerver, Jessica Yung, Sylvain Gelly, and Neil Houlsby. Big transfer (bit): General visual representation learning. In European conference on computer vision, pages 491–507. Springer, 2020.
245
+ [40] Simon Kornblith, Mohammad Norouzi, Honglak Lee, and Geoffrey Hinton. Similarity of neural network representations revisited. In International Conference on Machine Learning, pages 3519–3529. PMLR, 2019.
246
+ [41] Simon Kornblith, Jonathon Shlens, and Quoc V Le. Do better imagenet models transfer better? In Proceedings of the IEEE/CVF conference on computer vision and pattern recognition, pages 2661–2671, 2019.
247
+ [42] 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.
248
+ [43] Alex Krizhevsky, Geoffrey Hinton, et al. Learning multiple layers of features from tiny images. 2009.
249
+ [44] Karel Lenc and Andrea Vedaldi. Understanding image representations by measuring their equivariance and equivalence. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 991–999, 2015.
250
+ [45] Xingjian Li, Haoyi Xiong, Hanchao Wang, Yuxuan Rao, Liping Liu, Zeyu Chen, and Jun Huan. Delta: Deep learning transfer using feature map with attention for convolutional networks. arXiv preprint arXiv:1901.09229, 2019.
251
+ [46] 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 Proceedings of the European Conference on Computer Vision (ECCV), September 2018.
252
+ [47] Hanxiao Liu, Karen Simonyan, and Yiming Yang. DARTS: Differentiable architecture search. In International Conference on Learning Representations, 2019.
253
+ [48] Huihui Liu, Yiding Yang, and Xinchao Wang. Overcoming catastrophic forgetting in graph neural networks. In Proceedings of the AAAI conference on artificial intelligence, 2021.
254
+ [49] 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. International Conference on Computer Vision (ICCV), 2021.
255
+ [50] Ilya Loshchilov and Frank Hutter. Decoupled weight decay regularization. arXiv preprint arXiv:1711.05101, 2017.
256
+ [51] Renqian Luo, Fei Tian, Tao Qin, Enhong Chen, and Tie-Yan Liu. Neural architecture optimization. In NIPS 2018. Microsoft, December 2018.
257
+ [52] James MacQueen et al. Some methods for classification and analysis of multivariate observations. In Proceedings of the fifth Berkeley symposium on mathematical statistics and probability, volume 1, pages 281–297. Oakland, CA, USA, 1967.
258
+ [53] S. Maji, J. Kannala, E. Rahtu, M. Blaschko, and A. Vedaldi. Fine-grained visual classification of aircraft. Technical report, 2013.
259
+ [54] Sachin Mehta and Mohammad Rastegari. Mobilevit: light-weight, general-purpose, and mobile-friendly vision transformer. arXiv preprint arXiv:2110.02178, 2021.
260
+ [55] Joe Mellor, Jack Turner, Amos Storkey, and Elliot J Crowley. Neural architecture search without training. In International Conference on Machine Learning, pages 7588–7598. PMLR, 2021.
261
+ [56] Guido F Montufar, Razvan Pascanu, Kyunghyun Cho, and Yoshua Bengio. On the number of linear regions of deep neural networks. Advances in neural information processing systems, 27, 2014.
262
+ [57] Cuong Nguyen, Tal Hassner, Matthias Seeger, and Cedric Archambeau. Leep: A new measure to evaluate transferability of learned representations. In International Conference on Machine Learning, pages 7294–7305. PMLR, 2020.
263
+ [58] Dang Nguyen, Khai Nguyen, Dinh Phung, Hung Bui, and Nhat Ho. Model fusion of heterogeneous neural networks via cross-layer alignment. arXiv preprint arXiv:2110.15538, 2021.
264
+ [59] 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, pages 722–729. IEEE, 2008.
265
+ [60] Christos H Papadimitriou and Kenneth Steiglitz. Combinatorial optimization: algorithms and complexity. Courier Corporation, 1998.
266
+ [61] O. M. Parkhi, A. Vedaldi, A. Zisserman, and C. V. Jawahar. Cats and dogs. In IEEE Conference on Computer Vision and Pattern Recognition, 2012.
267
+ [62] Hieu Pham, Melody Guan, Barret Zoph, Quoc Le, and Jeff Dean. Efficient neural architecture search via parameters sharing. In Jennifer Dy and Andreas Krause, editors, Proceedings of the 35th International Conference on Machine Learning, volume 80 of Proceedings of Machine Learning Research, pages 4095–4104. PMLR, 10–15 Jul 2018.
268
+ [63] Ilija Radosavovic, Raj Prateek Kosaraju, Ross Girshick, Kaiming He, and Piotr Dollár. Designing network design spaces. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 10428–10436, 2020.
269
+ [64] Maithra Raghu, Justin Gilmer, Jason Yosinski, and Jascha Sohl-Dickstein. Svcca: Singular vector canonical correlation analysis for deep learning dynamics and interpretability. Advances in neural information processing systems, 30, 2017.
270
+ [65] JO Ramsay, Jos ten Berge, and GPH Styan. Matrix correlation. Psychometrika, 49(3):403–423, 1984.
271
+ [66] Esteban Real, Sherry Moore, Andrew Selle, Saurabh Saxena, Yutaka Leon Suematsu, Jie Tan, Quoc V. Le, and Alexey Kurakin. Large-scale evolution of image classifiers. In Doina Precup and Yee Whye Teh, editors, Proceedings of the 34th International Conference on Machine Learning, volume 70 of Proceedings of Machine Learning Research, pages 2902–2911. PMLR, 06–11 Aug 2017.
272
+ [67] Tal Ridnik, Emanuel Ben-Baruch, Asaf Noy, and Lihi Zelnik-Manor. Imagenet-21k pretraining for the masses, 2021.
273
+ [68] 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.
274
+ [69] 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 (CVPR), June 2018.
275
+ [70] Victor Sanh, Lysandre Debut, Julien Chaumond, and Thomas Wolf. Distilbert, a distilled version of bert: smaller, faster, cheaper and lighter. arXiv preprint arXiv:1910.01108, 2019.
276
+ [71] Yang Shu, Zhi Kou, Zhangjie Cao, Jianmin Wang, and Mingsheng Long. Zoo-tuning: Adaptive transfer from a zoo of models. In International Conference on Machine Learning, pages 9626–9637. PMLR, 2021.
277
+ [72] Sidak Pal Singh and Martin Jaggi. Model fusion via optimal transport. Advances in Neural Information Processing Systems, 33:22045–22055, 2020.
278
+ [73] Jie Song, Yixin Chen, Xinchao Wang, Chengchao Shen, and Mingli Song. Deep model transferability from attribution maps. In Advances in Neural Information Processing Systems, 2019.
279
+ [74] Andreas Steiner, Alexander Kolesnikov, Xiaohua Zhai, Ross Wightman, Jakob Uszkoreit, and Lucas Beyer. How to train your vit? data, augmentation, and regularization in vision transformers. arXiv preprint arXiv:2106.10270, 2021.
280
+ [75] 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 (CVPR), June 2019.
281
+ [76] Anh T Tran, Cuong V Nguyen, and Tal Hassner. Transferability and hardness of supervised classification tasks. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 1395–1405, 2019.
282
+ [77] Grant Van Horn, Elijah Cole, Sara Beery, Kimberly Wilber, Serge Belongie, and Oisin Mac Aodha. Benchmarking representation learning for natural world image collections. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 12884–12893, 2021.
283
+ [78] Hongyi Wang, Mikhail Yurochkin, Yuekai Sun, Dimitris Papailiopoulos, and Yasaman Khazaeni. Federated learning with matched averaging. arXiv preprint arXiv:2002.06440, 2020.
284
+ [79] Peter Welinder, Steve Branson, Takeshi Mita, Catherine Wah, Florian Schroff, Serge Belongie, and Pietro Perona. Caltech-ucsd birds 200. Technical Report CNS-TR-201, Caltech, 2010.
285
+ [80] Wei Wen, Hanxiao Liu, Yiran Chen, Hai Li, Gabriel Bender, and Pieter-Jan Kindermans. Neural predictor for neural architecture search. In Andrea Vedaldi, Horst Bischof, Thomas Brox, and Jan-Michael Frahm, editors, Computer Vision – ECCV 2020, pages 660–676, Cham, 2020. Springer International Publishing.
286
+ [81] Alex Williams, Erin Kunz, Simon Kornblith, and Scott Linderman. Generalized shape metrics on neural representations. Advances in Neural Information Processing Systems, 34, 2021.
287
+ [82] Bichen Wu, Xiaoliang Dai, Peizhao Zhang, Yanghan Wang, Fei Sun, Yiming Wu, Yuandong Tian, Peter Vajda, Yangqing Jia, and Kurt Keutzer. Fbnet: Hardware-aware efficient convnet design via differentiable neural architecture search. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), June 2019.
288
+ [83] Tete Xiao, Mannat Singh, Eric Mintun, Trevor Darrell, Piotr Dollár, and Ross Girshick. Early convolutions help transformers see better. Advances in Neural Information Processing Systems, 34:30392–30400, 2021.
289
+ [84] Saining Xie, Ross Girshick, Piotr Dollár, Zhuowen Tu, and Kaiming He. Aggregated residual transformations for deep neural networks. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 1492–1500, 2017.
290
+ [85] LI Xuhong, Yves Grandvalet, and Franck Davoine. Explicit inductive bias for transfer learning with convolutional networks. In International Conference on Machine Learning, pages 2825–2834. PMLR, 2018.
291
+ [86] Daniel LK Yamins, Ha Hong, Charles F Cadieu, Ethan A Solomon, Darren Seibert, and James J DiCarlo. Performance-optimized hierarchical models predict neural responses in higher visual cortex. Proceedings of the national academy of sciences, 111(23):8619–8624, 2014.
292
+ [87] Xingyi Yang, Xuehai He, Yuxiao Liang, Yue Yang, Shanghang Zhang, and Pengtao Xie. Transfer learning or self-supervised learning? a tale of two pretraining paradigms. arXiv preprint arXiv:2007.04234, 2020.
293
+ [88] Xingyi Yang, Jingwen Ye, and Xinchao Wang. Factorizing knowledge in neural networks. European Conference on Computer Vision, 2022.
294
+ [89] Yiding Yang, Zunlei Feng, Mingli Song, and Xinchao Wang. Factorizable graph convolutional networks. Advances in Neural Information Processing Systems, 33:20286–20296, 2020.
295
+ [90] Yiding Yang, Jiayan Qiu, Mingli Song, Dacheng Tao, and Xinchao Wang. Distilling knowledge from graph convolutional networks. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), June 2020.
296
+ [91] Jingwen Ye, Yixin Ji, Xinchao Wang, Kairi Ou, Dapeng Tao, and Mingli Song. Student becoming the master: Knowledge amalgamation for joint scene parsing, depth estimation, and more. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 2829–2838, 2019.
297
+ [92] Kaichao You, Yong Liu, Jianmin Wang, and Mingsheng Long. Logme: Practical assessment of pre-trained models for transfer learning. In International Conference on Machine Learning, pages 12133–12143. PMLR, 2021.
298
+ [93] 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, pages 6023–6032, 2019.
299
+ [94] Guojun Zhang, Han Zhao, Yaoliang Yu, and Pascal Poupart. Quantifying and improving transferability in domain generalization. Advances in Neural Information Processing Systems, 34, 2021.
300
+ [95] Hongyi Zhang, Moustapha Cisse, Yann N Dauphin, and David Lopez-Paz. mixup: Beyond empirical risk minimization. arXiv preprint arXiv:1710.09412, 2017.
301
+ [96] Daquan Zhou, Qibin Hou, Yunpeng Chen, Jiashi Feng, and Shuicheng Yan. Rethinking bottleneck structure for efficient mobile network design. In European Conference on Computer Vision, pages 680–697. Springer, 2020.
302
+ [97] Daquan Zhou, Xiaojie Jin, Xiaochen Lian, Linjie Yang, Yujing Xue, Qibin Hou, and Jiashi Feng. Autospace: Neural architecture search with less human interference. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 337–346, 2021.
303
+ [98] Daquan Zhou, Bingyi Kang, Xiaojie Jin, Linjie Yang, Xiaochen Lian, Zihang Jiang, Qibin Hou, and Jiashi Feng. Deepvit: Towards deeper vision transformer. arXiv preprint arXiv:2103.11886, 2021.
304
+ [99] Zhi-Hua Zhou. Ensemble learning. In Machine learning, pages 181–210. Springer, 2021.
305
+ [100] Barret Zoph and Quoc Le. Neural architecture search with reinforcement learning. In International Conference on Learning Representations, 2017.
md/dev/hy0a5MMPUv/hy0a5MMPUv.md ADDED
@@ -0,0 +1,443 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # IN-CONTEXT REINFORCEMENT LEARNING WITH ALGORITHM DISTILLATION
2
+
3
+ Michael Laskin∗†, Luyu Wang∗, Junhyuk Oh, Emilio Parisotto, Stephen Spencer, Richie Steigerwald, DJ Strouse, Steven Hansen, Angelos Filos, Ethan Brooks, Maxime Gazeau, Himanshu Sahni, Satinder Singh, Volodymyr Mnih† DeepMind
4
+
5
+ # ABSTRACT
6
+
7
+ We propose Algorithm Distillation (AD), a method for distilling reinforcement learning (RL) algorithms into neural networks by modeling their training histories with a causal sequence model. Algorithm Distillation treats learning to reinforcement learn as an across-episode sequential prediction problem. A dataset of learning histories is generated by a source RL algorithm, and then a causal transformer is trained by autoregressively predicting actions given their preceding learning histories as context. Unlike sequential policy prediction architectures that distill post-learning or expert sequences, AD is able to improve its policy entirely in-context without updating its network parameters. We demonstrate that AD can reinforcement learn in-context in a variety of environments with sparse rewards, combinatorial task structure, and pixel-based observations, and find that AD learns a more data-efficient RL algorithm than the one that generated the source data.
8
+
9
+ ![](images/679c16b167e631679ba20610706e8543cd9d762d7dab80268efc9673f356c188.jpg)
10
+ Figure 1: Algorithm Distillation (AD) has two steps – (i) a dataset of learning histories is collected from individual single-task RL algorithms solving different tasks; (ii) a causal transformer predicts actions from these histories using across-episodic contexts. Since the RL policy improves throughout the learning histories, by predicting actions accurately AD learns to output an improved policy relative to the one seen in its context. AD models state-action-reward tokens, and does not condition on returns.
11
+
12
+ # 1 INTRODUCTION
13
+
14
+ Transformers have emerged as powerful neural network architectures for sequence modeling (Vaswani et al., 2017). A striking property of pre-trained transformers is their ability to adapt to downstream tasks through prompt conditioning or in-context learning. After pre-training on large offline datasets, large transformers have been shown to generalize to downstream tasks in text completion (Brown et al., 2020), language understanding (Devlin et al., 2018), and image generation (Yu et al., 2022).
15
+
16
+ Recent work demonstrated that transformers can also learn policies from offline data by treating offline Reinforcement Learning (RL) as a sequential prediction problem. While Chen et al. (2021) showed that transformers can learn single-task policies from offline RL data via imitation learning, subsequent work showed that transformers can also extract multi-task policies in both same-domain (Lee et al., 2022) and cross-domain settings (Reed et al., 2022). These works suggest a promising paradigm for extracting generalist multi-task policies – first collect a large and diverse dataset of environment interactions, then extract a policy from the data via sequential modeling. We refer to the family of approaches that learns policies from offline RL data via imitation learning as Offline Policy Distillation, or simply Policy Distillation1 (PD).
17
+
18
+ Despite its simplicity and scalability, a substantial drawback of PD is that the resulting policy does not improve incrementally from additional interaction with the environment. For instance, the MultiGame Decision Transformer (MGDT, Lee et al., 2022) learns a return-conditioned policy that plays many Atari games while Gato (Reed et al., 2022) learns a policy that solves tasks across diverse environments by inferring tasks through context, but neither method can improve its policy in-context through trial and error. MGDT adapts the transformer to new tasks by finetuning the model weights while Gato requires prompting with an expert demonstration to adapt to a new task. In short, Policy Distillation methods learn policies but not Reinforcement Learning algorithms.
19
+
20
+ We hypothesize that the reason Policy Distillation does not improve through trial and error is that it trains on data that does not show learning progress. Current methods either learn policies from data that contains no learning (e.g. by distilling fixed expert policies) or data with learning (e.g. the replay buffer of an RL agent) but with a context size that is too small to capture policy improvement.
21
+
22
+ Our key observation is that the sequential nature of learning within RL algorithm training could, in principle, make it possible to model the process of reinforcement learning itself as a causal sequence prediction problem. Specifically, if a transformer’s context is long enough to include policy improvement due to learning updates it should be able to represent not only a fixed policy but a policy improvement operator by attending to states, actions and rewards from previous episodes. This opens the possibility that any RL algorithm can be distilled into a sufficiently powerful sequence model such as a transformer via imitation learning, converting it into an in-context RL algorithm. By in-context RL we mean that the transformer should improve its policy through trial and error within the environment by attending to its context, without updating its parameters.
23
+
24
+ We present Algorithm Distillation (AD), a method that learns an in-context policy improvement operator by optimizing a causal sequence prediction loss on the learning histories of an RL algorithm. AD has two components. First, a large multi-task dataset is generated by saving the training histories of an RL algorithm on many individual tasks. Next, a transformer models actions causally using the preceding learning history as its context. Since the policy improves throughout the course of training of the source RL algorithm, AD is forced to learn the improvement operator in order to accurately model the actions at any given point in the training history. Crucially, the transformer context size must be sufficiently large (i.e. across-episodic) to capture improvement in the training data. The full method is shown in Fig. 1.
25
+
26
+ We show that by imitating gradient-based RL algorithms using a causal transformer with sufficiently large contexts, AD can reinforcement learn new tasks entirely in-context. We evaluate AD across a number of partially observed environments that require exploration, including the pixel-based Watermaze (Morris, 1981) from DMLab (Beattie et al., 2016). We show that AD is capable of in-context exploration, temporal credit assignment, and generalization. We also show that AD learns a more data-efficient algorithm than the one that generated the source data for transformer training. To the best of our knowledge, AD is the first method to demonstrate in-context reinforcement learning via sequential modeling of offline data with an imitation loss.
27
+
28
+ # 2 BACKGROUND
29
+
30
+ Partially Observable Markov Decision Processes: A Markov Decision Process (MDP) consists of states $s \in S$ , actions $a \in { \mathcal { A } }$ , rewards $r \in \mathcal { R }$ , a discount factor $\gamma$ , and a transition probability function $p ( s _ { t + 1 } | s _ { t } , a _ { t } )$ , where $t$ is an integer denoting the timestep and $( \cal { S } , \cal { A } )$ are state and action spaces. In environments described by an MDP, at each timestep $t$ the agent observes the state $s _ { t }$ , selects an action $a _ { t } \sim \pi ( \cdot | s _ { t } )$ from its policy, and then observes the next state $s _ { t + 1 } \sim p \big ( \cdot | s _ { t } , a _ { t } \big )$ sampled from the transition dynamics of the environment. In this work, we operate in the Partially Observable Markov Decision Process (POMDP) setting where instead of states $s \in S$ the agent receives observations $o \in \mathcal { O }$ that only have partial information about the true state of the environment. Full state information may be incomplete due to missing information about the goal in the environment, which the agent must instead infer through rewards with memory, or because the observations are pixel-based, or both.
31
+
32
+ Online and Offline Reinforcement Learning: Reinforcement Learning algorithms aim to maximize the return, defined as the cumulative sum of rewards $\textstyle \sum _ { t } \gamma ^ { t } r _ { t }$ , throughout an agent’s lifetime or episode of training. RL algorithms broadly fall into two categories: on-policy algorithms (Williams, 1992) where the agent directly maximizes a Monte-Carlo estimate of the total returns or off-policy (Mnih et al., 2013; 2015) where an agent learns and maximizes a value function that approximates the total future return. Most RL algorithms maximize returns through trial-and-error by directly interacting with the environment. However, offline RL (Levine et al., 2020) has recently emerged as an alternate and often complementary paradigm for RL where an agent aims to extract return maximizing policies from offline data gathered by another agent. The offline dataset consists of $( s , a , r )$ tuples which are often used to train an off-policy agent, though other algorithms for extracting return maximizing policies from offline data are also possible.
33
+
34
+ Self-Attention and Transformers The self-attention (Vaswani et al., 2017) operation begins by projecting input data $X$ with three separate matrices onto $D$ -dimensional vectors called queries $Q$ , keys $K$ , and values $V$ . These vectors are then passed through the attention function:
35
+
36
+ $$
37
+ \mathrm { A t t e n t i o n } ( Q , K , V ) = \mathrm { s o f t m a x } ( Q K ^ { T } / \sqrt { D } ) V .
38
+ $$
39
+
40
+ The $Q K ^ { T }$ term computes an inner product between two projections of the input data $X$ . The inner product is then normalized and projected back to a $D$ -dimensional vector with the scaling term $V$ . Transformers (Vaswani et al., 2017; Devlin et al., 2018; Brown et al., 2020) utilize self-attention as a core part of the architecture to process sequential data such as text sequences. Transformers are usually pre-trained with a self-supervised objective that predicts tokens within the sequential data. Common prediction tasks include predicting randomly masked out tokens (Devlin et al., 2018) or applying a causal mask and predicting the next token (Radford et al., 2018).
41
+
42
+ Offline Policy Distillation: We refer to the family of methods that treat offline Reinforcement Learning as a sequential prediction problem as Offline Policy Distillation, or Policy Distillation (PD) for brevity. Rather than learning a value function from offline data, PD extracts policies by predicting actions in the offline data (i.e. behavior cloning) with a sequence model and either return conditioning (Chen et al., 2021; Lee et al., 2022) or filtering out suboptimal data (Reed et al., 2022). Initially proposed to learn single-task policies (Chen et al., 2021; Janner et al., 2021), PD was recently extended to learn multi-task policies from diverse offline data (Lee et al., 2022; Reed et al., 2022).
43
+
44
+ In-Context Learning: In-context learning refers to the ability to infer tasks from context. For example, large language models like GPT-3 (Brown et al., 2020) or Gopher (Rae et al., 2021) can be directed at solving tasks such as text completion, code generation, and text summarization by specifying the task through language as a prompt. This ability to infer the task from prompt is often called in-context learning. We use the terms ‘in-weights learning’ and ‘in-context learning’ from prior work on sequence models (Brown et al., 2020; Chan et al., 2022) to distinguish between gradient-based learning with parameter updates and gradient-free learning from context, respectively.
45
+
46
+ # 3 METHOD
47
+
48
+ Over the course of its lifetime a capable reinforcement learning (RL) agent will exhibit complex behaviours, such as exploration, temporal credit assignment, and planning. Our key insight is that an agent’s actions, regardless of the environment it inhabits, its internal structure, and implementation, can be viewed as a function of its past experience, which we refer to as its history. Formally, we write:
49
+
50
+ $$
51
+ \mathcal { H } \ni h _ { t } : = \left( o _ { 0 } , a _ { 0 } , r _ { 0 } , \ldots , o _ { t - 1 } , a _ { t - 1 } , r _ { t - 1 } , o _ { t } , a _ { t } , r _ { t } \right) = \left( o _ { \leq t } , r _ { \leq t } , a _ { \leq t } \right)
52
+ $$
53
+
54
+ and we refer to a $l o n g ^ { 2 }$ history-conditioned policy as an algorithm:
55
+
56
+ $$
57
+ P : \mathcal { H } \cup \mathcal { O } \Delta ( \mathcal { A } ) ,
58
+ $$
59
+
60
+ where $\Delta ( \mathcal { A } )$ denotes the space of probability distributions over the action space $\mathcal { A }$ . Eqn. (3) suggests that, similar to a policy, an algorithm can be unrolled in an environment to generate sequences of observations, rewards, and actions. For brevity, we denote the algorithm as $P$ and environment (i.e. task) as $\mathcal { M }$ , such that the history of learning for any given task $\mathcal { M }$ is generated by the algorithm $P _ { \mathcal { M } }$ .
61
+
62
+ $$
63
+ ( O _ { 0 } , A _ { 0 } , R _ { 0 } , \ldots , O _ { T } , A _ { T } , R _ { T } ) \sim P _ { \mathcal { M } } .
64
+ $$
65
+
66
+ Here, we’re denoting random variables with uppercase Latin letters, e.g. $O , A , R$ , and their values with lowercase Latin letters, $e . g . \ o , a , r$ . By viewing algorithms as long history-conditioned policies, we hypothesize that any algorithm that generated a set of learning histories can be distilled into a neural network by performing behavioral cloning over actions. Next, we present a method that, provided agents’ lifetimes, learns a sequence model with behavioral cloning to map long histories to distributions over actions.
67
+
68
+ # 3.1 ALGORITHM DISTILLATION
69
+
70
+ Suppose the agents’ lifetimes, which we also call learning histories, are generated by the source algorithm $P ^ { \mathrm { s o u r c e } }$ for many individual tasks $\{ \mathcal { M } _ { n } \} _ { n = 1 } ^ { N }$ , producing the dataset $\mathcal { D }$ :
71
+
72
+ $$
73
+ \begin{array} { r } { \mathcal { D } : = \left\{ \left( o _ { 0 } ^ { ( n ) } , a _ { 0 } ^ { ( n ) } , r _ { 0 } ^ { ( n ) } , \ldots , o _ { T } ^ { ( n ) } , a _ { T } ^ { ( n ) } , r _ { T } ^ { ( n ) } \right) \sim P _ { \mathcal { M } _ { n } } ^ { \mathrm { s o u r c e } } \right\} _ { n = 1 } ^ { N } . } \end{array}
74
+ $$
75
+
76
+ Then we distill the source algorithm’s behaviour into a sequence model that maps long histories to probabilities over actions with a negative log likelihood (NLL) loss and refer to this process as algorithm distillation (AD). In this work, we consider neural network models $P _ { \theta }$ with parameters $\theta$ which we train by minimizing the following loss function:
77
+
78
+ $$
79
+ \mathcal { L } ( \theta ) : = - \sum _ { n = 1 } ^ { N } \sum _ { t = 1 } ^ { T - 1 } \log P _ { \theta } ( A = a _ { t } ^ { ( n ) } | h _ { t - 1 } ^ { ( n ) } , o _ { t } ^ { ( n ) } ) .
80
+ $$
81
+
82
+ Intuitively, a sequence model with fixed parameters that is trained with AD should amortise the source RL algorithm $P ^ { \mathrm { s o u r c e } }$ and by doing so exhibit similarly complex behaviours, such as exploration and temporal credit assignment. Since the RL policy improves throughout the learning history of the source algorithm, accurate action prediction requires the sequence model to not only infer the current policy from the preceding context but also infer the improved policy, therefore distilling the policy improvement operator.
83
+
84
+ # Algorithm 1 Algorithm Distillation
85
+
86
+ Require: Train $\{ \mathcal { M } ^ { \mathrm { t r a i n } } \}$ and test $\{ \mathcal { M } ^ { \mathrm { t e s t } } \}$ tasks, observations $o \in \mathcal { O }$ , actions $a \in { \mathcal { A } }$ , and rewards $r \in \mathcal { R }$ . Require: Network parameters $\phi _ { i }$ for $i = 1 , \ldots , N$ source RL algorithms.
87
+ Require: Network parameters $\theta$ for a causal transformer $P _ { \theta }$ that predicts actions.
88
+ Require: An empty buffer to store data $\mathcal { D }$ .
89
+ 1: for $i = 1 \dots N$ do ▷ Part 1: Dataset Generation 2: Sample a task $\mathcal { M } _ { i } ^ { \mathrm { t r a i n } }$ randomly from the train task distribution.
90
+ 3: Train the source RL algorithm $\phi _ { i }$ until it converges to the optimal policy.
91
+ 4: Save the learning history $h _ { T } ^ { ( i ) } = ( o _ { 0 } , a _ { 0 } , r _ { 0 } , \ldots , o _ { T } , a _ { T } , r _ { T } ) _ { i }$ to the dataset $\mathcal { D } \mathcal { D } \cup h _ { T } ^ { ( i ) }$ . 5: end for
92
+ 6: while $P _ { \theta }$ not converged do ▷ Part 2: Algorithm Distillation 7: Randomly sample a multi-episodic subsequence $\bar { h } _ { j } ^ { ( i ) } = \left( o _ { j } , a _ { j } , r _ { j } , \dotsc , o _ { j + c } , a _ { j + c } , r _ { j + c } \right) _ { i }$ of length $c$ 8: Autoregressively predict the actions with $P _ { \theta }$ and compute the NLL loss in Eq. 6.
93
+ 9: Backpropagate to update the transformer parameters.
94
+ 10: end while
95
+ 11: for $k = 1 \dots M _ { \mathrm { s e e d s } }$ do ▷ Part 3: Autoregressive Evaluation 12: Sample a task $\mathcal { M } _ { k } ^ { \mathrm { t e s t } }$ randomly from the test task distribution. Initialize empty context queue $C$ . 13: Unroll the transformer $P _ { \theta } ( \cdot | C )$ in the environment storing sequential transitions (i.e. histories) in $C$ . 14: Measure the return accumulated by the agent for each episode of evaluation.
96
+ 15: end for
97
+
98
+ # 3.2 PRACTICAL IMPLEMENTATION
99
+
100
+ In practice, we implement AD as a two-step procedure. First, a dataset of learning histories is collected by running an individual gradient-based RL algorithm on many different tasks. Next, a sequence model with multi-episodic context is trained to predict actions from the histories. We describe these two steps below and detail the full practical implementation in Algorithm 1.
101
+
102
+ Dataset Generation: A dataset of learning histories is collected by training $N$ individual single-task gradient-based RL algorithms. To prevent overfitting to any specific task during sequence model training, a task $\mathcal { M }$ is sampled randomly from a task distribution for each RL run. The data generation step is RL algorithm agnostic - any RL algorithm can be distilled. We show results distilling UCB exploration (Lai & Robbins, 1985), an on-policy actor-critic (Mnih et al., 2016), and an off-policy DQN (Mnih et al., 2013), in both distributed and single-stream settings. We denote the dataset of learning histories as $\mathcal { D }$ in Eq. 5.
103
+
104
+ Training the Sequence Model: Once a dataset of learning histories $\mathcal { D }$ is collected, a sequential prediction model is trained to predict actions given the preceding histories. We utilize the GPT (Radford et al., 2018) causal transformer model for sequential action prediction, but AD is compatible with any sequence model including RNNs (Williams & Zipser, 1989). For instance, we show in Appendix $\mathrm { L }$ that AD can also be achieved with an LSTM (Hochreiter & Schmidhuber, 1997), though less effectively than AD with causal transformers. Since causal transformer training and inference are quadratic in the sequence length, we sample across-episodic subsequences $\bar { h _ { j } } ^ { - } = \left( o _ { j } , r _ { j } , a _ { j } \ldots , o _ { j + c } , r _ { j + c } , a _ { j + c } \right)$ of length $c < T$ from $\mathcal { D }$ rather than training full histories.
105
+
106
+ # 4 EXPERIMENTAL SETUP
107
+
108
+ # 4.1 ENVIRONMENTS
109
+
110
+ To investigate the in-context RL capabilities of AD and the baselines (see next section), we focus on environments that cannot be solved through zero-shot generalization after pre-training. Specifically, we require that each environment supports many tasks, that the tasks cannot be inferred easily from the observation, and that episodes are short enough to feasibly train across-episodic causal transformers - for more details regarding environments see Appendix B. We list the evaluation environments below:
111
+
112
+ Adversarial Bandit: a multi-armed bandit with 10 arms and 100 trials similar to the environment considered in $\mathrm { { R L ^ { 2 } } }$ (Duan et al., 2016). However, during evaluation the reward is out of distribution. Reward is more likely distributed under odd arms $9 5 \%$ of the time during training. At evaluation, the opposite happens - reward appears more often under even arms $9 5 \%$ of the time.
113
+
114
+ ![](images/a3da0f2d56a2dea7e0ac773cbc4072974da4d3b19ed7b19d036e66b3977c8b9e.jpg)
115
+ Figure 2: Agent view from the DMLab Watermaze environment. The task is to find a hidden platform that elevates once found.
116
+
117
+ Dark Room: a 2D discrete POMDP where an agent spawns in a room and must find a goal location. The agent only knows its own $( x , y )$ coordinates but does not know the goal location and must infer it from the reward. The room size is $9 \times 9$ , the possible actions are one step left, right, up, down, and no-op, the episode length is 20, and the agent resets at the center of the map. We test two environment variants – Dark Room where the agent receives $r = 1$ every time the goal is reached and Dark Room Hard, a hard exploration variant with a $1 7 \times 1 7$ size and sparse reward $\mathbf { \boldsymbol { r } } = 1$ exactly once for reaching the goal). When not $r = 1$ , then $r = 0$ .
118
+
119
+ Dark Key-to-Door: similar to Dark Room but this environment requires an agent to first find an invisible key upon which it receives a reward of $r = 1$ once and then open an invisible door upon which it receives a reward of $r = 1$ once again. Otherwise, the reward is $r = 0$ . The room size is $9 \times 9$ making the task space combinatorial with $8 1 ^ { 2 } = 6 5 6 1$ possible tasks. This environment is similar to the one considered in Chen et al. (2021) except the key and door are invisible and the reward is semisparse $\boldsymbol { r } = 1$ for both key and the door). The agent is randomly reset. The episode length is 50 steps.
120
+
121
+ DMLab Watermaze: a partially observable 3D visual DMLab environment based on the classic Morris Watermaze (Morris, 1981). The task is to navigate the water maze to find a randomly spawned trap-door. The maze walls have color patterns that can be used to remember the goal location. Observations are pixel images of size $7 2 \times 9 6 \times 3$ . There are 8 possible actions in total, including going forward, backward, left, or right, rotating left or right, and rotating left or right while going forward. The episode length is 50, and the agent resets at the center of the map. Similar to Dark
122
+
123
+ ![](images/d5537f516f3e701ce2d1f385b3b62e3325664799bf1950f1bd449d7fede0b517.jpg)
124
+ Figure 3: Adversarial Bandit (Section 5): AD, $\mathrm { { R L } ^ { 2 } }$ , and ED evaluated on a 10-arm bandit with 100 trials. The source data for AD comes from learning histories from UCB (Lai & Robbins, 1985). During training, the reward is distributed under odd arms $9 5 \%$ of the time and under even arms $9 5 \%$ of the time during evaluation. Both AD and $\mathrm { { R L } ^ { 2 } }$ can in-context learn in-distribution tasks, but AD generalizes better out of distribution. Running $\mathrm { { R L } ^ { 2 } }$ with a transformer generally doesn’t offer an advantage over the original LSTM variant. ED performs poorly both in and out of distribution relative to AD and $\mathrm { { R L } ^ { 2 } }$ . Scores are normalized relative to UCB.
125
+
126
+ Room, the agent cannot see the location of the goal from the observations and must infer it through the reward of $r = 1$ if reached and $r = 0$ otherwise; however, the goal space is continuous and therefore there are an infinite number of goals.
127
+
128
+ # 4.2 BASELINES
129
+
130
+ The main aim of this work is to investigate to what extent AD reinforcement learns in-context relative to prior related work. AD is mostly closely related to Policy Distillation, where a policy is learned with a sequential model from offline interaction data. In-context online meta-RL is also related though not directly comparable to AD, since AD is an in-context offline meta-RL method. Still, we consider both types of baselines to better contextualize our work. For a more detailed discussion of these baseline choices we refer the reader to Appendix C. Our baselines include:
131
+
132
+ Expert Distillation $( E D )$ : this baseline is exactly the same as AD but the source data consists of expert trajectories only, rather than learning histories. ED is most similar to Gato (Reed et al., 2022) except ED models state-action-reward sequences like AD, while Gato models state-action sequences.
133
+
134
+ Source Algorithm: we compare AD to the gradient-based source RL algorithm that generates the training data for distillation. We include running the source algorithm from scratch as a baseline to compare the data-efficiency of in-context RL to the in-weights source algorithm.
135
+
136
+ $R L ^ { 2 }$ (Duan et al., 2016): an online meta-RL algorithm where exploration and fast in-context adaptation are learned jointly by maximizing a multi-episodic value function. $\mathrm { { R L } ^ { 2 } }$ is not directly comparable to AD for similar reasons to why online and offline RL algorithms are not directly comparable – RL2 gets to interact with the environment during training while AD does not. We use $\mathrm { { R L } ^ { 2 } }$ asymptotic performance as an approximate upper bound for AD.
137
+
138
+ # 4.3 EVALUATION
139
+
140
+ After pre-training, the AD transformer $P _ { \theta }$ can reinforcement learn in-context. Evaluation is exactly the same as with an in-weights RL algorithm except the learning happens entirely in-context without updating the transformer network parameters. Given an MDP (or POMDP), the transformer interacts with the environment and populates its own context (i.e. without demonstrations), where the context is a queue containing the last $c$ transitions. The transformer’s performance is then evaluated in terms of its ability to maximize return. For all evaluation runs, we average results across 5 training seeds with 20 evaluation seeds each for a total of 100 seeds. A task $\mathcal { M }$ is sampled uniformly from the test task distribution and fixed for each evaluation seed. The aggregate statistics reported reflect multi-task performance. We evaluate for 1000 and 160 episodes for the Dark and Watermaze environments respectively and plot performance as a function of total environment steps at test-time.
141
+
142
+ # 5 EXPERIMENTS
143
+
144
+ The main research question of this work is whether an in-weights RL algorithm can be amortized into an in-context one via Algorithm Distillation. The in-context RL algorithm should behave in a similar way as the in-weights one and exhibit exploration, credit assignment, and generalization capabilities. We begin our analysis in a clean and simple experimental setting where all three properties are required to solve the task - the Adversarial Bandit described in Sec. 4.
145
+
146
+ ![](images/9ee4c7c970fbe6d5f893cf896ce23072080991bcd6e0b43221766e63d5068738.jpg)
147
+ Figure 4: Main results: we evaluate AD, $\mathrm { { R L } ^ { 2 } }$ , ED, and the source algorithm on environments that require memory and exploration. In these environments, an agent must reach a goal location that can only be inferred through a binary reward. AD is consistently able to in-context reinforcement learn across all environments and is more data-efficient than the A3C (“Dark” environments) (Mnih et al., 2016) or DQN (Watermaze) (Mnih et al., 2013) source algorithm it distilled. We report the mean return $\pm \nobreakspace 1 \nobreakspace$ standard deviation over 5 training seeds with 20 test seeds each.
148
+
149
+ To generate the source data, we sample a set of training tasks Bound algorithm (Lai & Robbins, 1985), and save its learning $\{ \mathcal { M } _ { j } \} _ { j = 1 } ^ { N }$ , run the Upper Confidence We then train a transformer to predict actions as described in Alg. 1. We evaluate AD, ED, and $\mathrm { { R L } ^ { 2 } }$ and normalize their scores relative to UCB and a random policy $( r - r _ { r a n d . } ) / ( r _ { U C B } - r _ { r a n d . } )$ . The results are shown in Fig. 3. We find that both AD and $\mathtt { R L } ^ { 2 }$ can reliably in-context learn tasks sampled from the training distribution while ED cannot, though ED does do better than random guessing when evaluated in-distribution. However, AD can also in-context learn to solve out of distribution tasks whereas the other methods cannot. This experiment shows that AD can explore the bandit arms, can assign credit by exploiting an arm once reached, and can generalize well out of distribution nearly as well as UCB. We now move beyond the bandit setting and investigate similar research questions in more challenging RL environments and present our results as answers to a series of research questions.
150
+
151
+ Does Algorithm Distillation exhibit in-context reinforcement learning? To answer this question, we first generate source data for Algorithm Distillation. In the Dark Room and Dark Key-to-Door environments we collect 2000 learning histories with an Asynchronous Advantage Actor-Critic (A3C) (Mnih et al., 2016) with 100 actors, while in DMLab Watermaze we collect 4000 learning histories with a distributed DQN with 16 parallel actors (see Appendix F for asymptotic learning curves of the source algorithm and Appendix O for hyperparameters). Shown in Fig. 4, AD in-context reinforcement learns in all of the environments. In contrast, ED fails to explore and learn in-context in most settings. We use $\mathrm { { R L } ^ { 2 } }$ trained for 1 billion environment steps as a proxy for the upper bound of performance for a meta-RL method. $\mathrm { { R L ^ { 2 } } }$ achieves a near-optimal asymptotic score in all the environments except for Dark Room (Hard). Despite learning from offline data, AD matches asymptotic $\mathtt { R L } ^ { 2 }$ on the Dark environments and approaches it (within $1 3 \%$ ) on Watermaze.
152
+
153
+ Credit-assignment: In Dark Room, the agent receives $r = 1$ each time it visits the goal location. Even though AD is trained to condition only on single timestep reward and not episodic return tokens, it is still able to maximize the reward, which suggests that AD has learned to do credit assignment.
154
+
155
+ Exploration: Dark Room (Hard) tests the agents exploration capability. Since the reward is sparse $r = 1$ exactly once), most of the learning history has reward values of $r = 0$ . Nevertheless, AD infers the goal from previous episodes in its context which means it has learned to explore and exploit.
156
+
157
+ Generalization: Dark Key-to-Door tests in-distribution generalization with a combinatorial task space. While the environment has a total of $\sim 6 . 5 \mathrm { k }$ tasks, less than 2k were seen during training. During evaluation, AD both generalizes and achieves near-optimal performance on mostly unseen tasks.
158
+
159
+ Can Algorithm Distillation learn from pixel-based observations? DMLab Watermaze is a pixelbased environment that is larger than the Dark environments with tasks sampled from a continuous uniform distribution. The environment is partially observable in two ways - the goal is invisible until the agent has reached it and the first-person view limits the agent’s field of vision. Shown in Fig. 4, AD maximizes the episodic return with in-context RL while ED does not learn.
160
+
161
+ Can AD learn a more data-efficient RL algorithm than the one that produced the source data? In Fig. 4, AD is significantly more data-efficient than the source algorithm. This gain is a byproduct of distilling a multi-stream algorithm into a single-stream one. The source algorithms (A3C and DQN) are distributed, which means they run many actors in parallel to achieve good performance.3 A distributed RL algorithm may not be very data-efficient in aggregate but each individual actor can be data-efficient. Since the learning history for each actor is saved separately,
162
+
163
+ ![](images/e72730fa811ddedf85713313c74350731b168f42cfdbd85e088031cd6898d726.jpg)
164
+ Figure 5: $A D$ and $E D$ conditioned on partial demonstrations: We compare the performance of AD and ED when prompted with a demonstration from the source algorithm’s training history on Dark Room (semi-dense). While ED slightly improves and then maintains performance from the input policy, AD is able to improve it in-context until the policy is optimal or nearly optimal.
165
+
166
+ AD achieves similar performance to the multi-stream distributed RL algorithm, but is more data-efficient as a single-stream method.
167
+
168
+ These data-efficiency gains are also evident for distilling single-stream algorithms. In Fig 6 we show that by subsampling every $k$ -th episode (where $k = 1 0$ ) from a single stream A3C learning history, AD can still learn a more data-efficient in-context RL algorithm (for more detail, see Appendix J). Therefore, AD can be more data-efficient than both a multi and single-stream source RL algorithm.
169
+
170
+ ![](images/c652f1346777c272cd0157cbac3dddfaa6bac8bab0398dde13e052045c590f1e.jpg)
171
+ Figure 6: Single-stream Algorithm Distillation: AD trained on the learning history from an A3C agent with only one actor (i.e. single-stream). By training on subsampled learning histories (see Sec. 5), AD learns are more data-efficient in-context RL algorithm.
172
+
173
+ While AD is more data-efficient, the source algorithm achieves slightly higher asymptotic performance (see Appendix F). However, the source algorithm produces many single-task agents with a unique set of weights $\phi _ { n }$ per task $\mathcal { M } _ { n }$ , while AD produces a single generalist agent with weights $\theta$ that are fixed across all tasks.
174
+
175
+ Is it possible to accelerate AD by prompting it with demonstrations? Although AD can reinforcement learn without relying on demonstrations, it has the added benefit that, unlike the source algorithm, it can be conditioned on or prompted with external data. To answer the research question, we sample policies from the hold-out test-set data along different points of the source algorithm history - from a near-random policy to a near-expert policy. We then pre-fill the context for both AD and ED with this policy data, and run both methods in the environment in Dark Room (Fig. 5). While ED maintains the performance of the input policy, AD improves every policy in-context until it is near-optimal. Importantly, the more optimal the input policy the faster AD improves it until it is optimal.
176
+
177
+ ![](images/326a444f7a476152beb4d779e7e9c87e058d5d0329f877516a605551d10515aa.jpg)
178
+ Figure 7: Context size: AD in Dark Key-toDoor with different context sizes. In-context RL only emerges once the context size is large enough and across-episodic.
179
+
180
+ What context size is required for in-context RL to emerge? We’ve hypothesized that AD requires sufficiently long (i.e. across-episodic) contexts to in-context reinforcement learn. We test this hypothesis by training several AD variants with different context sizes on the Dark Room environment. We plot the learning curves of these different variants in Fig. 7 and find that multi-episodic contexts of 2-4 episodes are necessary to learn a near-optimal in-context RL algorithm. Initial signs of in-context RL begin to emerge when the context size is roughly the length of an episode. The reason for this is likely that the context is large enough to retrain across-episodic information – e.g., at the start of a new episode, the context will be filled with transitions from most of the previous episode.
181
+
182
+ # 6 RELATED WORK
183
+
184
+ Offline Policy Distillation: Most closely related to our work are the recent advances in learning policies from offline environment interaction data with transformers, which we have been referring to as Policy Distillation (PD). Initial PD architectures such as Decision Transformer (DT) (Chen et al., 2021) and Trajectory Transformer (Janner et al., 2021) showed that transformers can learn single-task policies from offline data. Subsequently the Multi-Game Decision Transformer (MGDT) (Lee et al., 2022) and Gato (Reed et al., 2022) showed that PD architectures can also learn multi-task same domain and cross-domain policies, respectively. Importantly, these prior methods use contexts substantially smaller than an episode length, which is likely the reason in-context RL was not observed in these works. Instead, they rely on alternate ways to adapt to new tasks - MGDT finetunes the model parameters while Gato gets prompted with expert demonstrations to adapt to downstream tasks. AD adapts in-context without finetuning and does not rely on demonstrations. A number of recent works have explored more generalized PD architectures (Furuta et al., 2021), prompt conditioning (Xu et al., 2022), and online gradient-based RL (Zheng et al., 2022). Some PD architectures such as DT and MGDT are instantiations of Upside Down RL (UDRL) Schmidhuber (2019); Srivastava et al. (2019) where rather than learning a value function, a policy is conditioned directly on the desired return. However, AD is not explicitly doing UDRL since it is not conditioned on returns. In fact, return maximization is not specified anywhere in the AD objective but rather emerges implicitly by modeling the learning histories of an RL algorithm.
185
+
186
+ Meta Reinforcement Learning: AD falls into the category of methods that learn to reinforcement learn, also known as meta-RL. Specifically, AD is an in-context offline meta-RL method. This general idea of learning the policy improvement process has a long history in reinforcement learning, but has been limited to meta-learning hyper-parameters4 until recently (Ishii et al., 2002). In-context deep meta-RL methods introduced by Wang et al. (2016) and Duan et al. (2016) are usually trained in the online setting by maximizing multi-episodic value functions with memory-based architectures through environment interactions (Ni et al., 2022). Meta-RL through multi-episodic value functions has been done in both on-policy (Duan et al., 2016) and off-policy (Rakelly et al., 2019; Fakoor et al., 2020) settings. Another common approach to online meta-RL includes optimization-based methods that find good network parameter initializations for meta-RL (Hochreiter et al., 2001; Finn et al., 2017; Nichol et al., 2018) and adapt by taking additional gradient steps. Like other in-context meta-RL approaches, AD is gradient-free - it adapts to downstream tasks without updating its network parameters. Recent works have proposed learning to reinforcement learn from offline datasets, or offline meta-RL, using Bayesian RL (Dorfman et al., 2021) and optimization-based meta-RL (Mitchell et al., 2021). Given the difficulty of offline meta-RL, Pong et al. (2022) proposed a hybrid offline-online strategy for meta-RL.
187
+
188
+ In-Context Learning with Transformers: In this work, we make the distinction between in-context learning and incremental or in-context learning. In-context learning involves learning from a provided prompt or demonstration while incremental in-context learning involves learning from one’s own behavior through trial and error. While many recent works have demonstrated the former, it is much less common to see methods that exhibit the latter. Arguably, the most impressive demonstrations of in-context learning to date have been shown in the text completion setting (Radford et al., 2018; Chen et al., 2020; Brown et al., 2020) through prompt conditioning. Similar methodology was recently extended to show powerful composability properties in text-conditioned image generation (Yu et al., 2022). Recent work showed that transformers can also learn simple algorithm classes, such as linear regression, in-context in a small-scale setting (Garg et al., 2022). Like prior in-context learning methods, Garg et al. (2022) required initializing the transformer prompt with expert examples. While the aforementioned approaches were examples of in-context learning, a recent work (Chen et al., 2022) demonstrated incremental in-context learning for hyperparameter optimization by treating hyperparameter optimization as a sequential prediction problem with a score function.
189
+
190
+ # 7 CONCLUSION
191
+
192
+ We have demonstrated that can distill RL algorithms by modeling their learning histories causally with imitation learning and that AD can learn more data-efficient algorithms than those that generated the source data. We hope that AD inspires further investigation into in-context reinforcement learning from the research community.
193
+
194
+ # REFERENCES
195
+
196
+ Charles Beattie, Joel Z. Leibo, Denis Teplyashin, Tom Ward, Marcus Wainwright, Heinrich Kuttler, ¨ Andrew Lefrancq, Simon Green, V´ıctor Valdes, Amir Sadik, Julian Schrittwieser, Keith Anderson, ´ Sarah York, Max Cant, Adam Cain, Adrian Bolton, Stephen Gaffney, Helen King, Demis Hassabis, Shane Legg, and Stig Petersen. DeepMind Lab. CoRR, abs/1612.03801, 2016.
197
+
198
+ 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.
199
+
200
+ Stephanie CY Chan, Adam Santoro, Andrew K Lampinen, Jane X Wang, Aaditya Singh, Pierre H Richemond, Jay McClelland, and Felix Hill. Data Distributional Properties Drive Emergent In-Context Learning in Transformers. arXiv preprint arXiv:2205.05055, 2022.
201
+
202
+ 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:15084–15097, 2021.
203
+
204
+ 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, pp. 1691– 1703. PMLR, 2020.
205
+
206
+ Yutian Chen, Xingyou Song, Chansoo Lee, Zi Wang, Qiuyi Zhang, David Dohan, Kazuya Kawakami, Greg Kochanski, Arnaud Doucet, Marc’aurelio Ranzato, Sagi Perel, and Nando de Freitas. Towards Learning Universal Hyperparameter Optimizers with Transformers, 2022.
207
+
208
+ 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.
209
+
210
+ Ron Dorfman, Idan Shenfeld, and Aviv Tamar. Offline Meta Reinforcement Learning–Identifiability Challenges and Effective Data Collection Strategies. Advances in Neural Information Processing Systems, 34:4607–4618, 2021.
211
+
212
+ Yan Duan, John Schulman, Xi Chen, Peter L. Bartlett, Ilya Sutskever, and Pieter Abbeel. RL2: Fast Reinforcement Learning via Slow Reinforcement Learning, 2016.
213
+
214
+ Rasool Fakoor, Pratik Chaudhari, Stefano Soatto, and Alexander J. Smola. Meta-q-learning. In International Conference on Learning Representations, 2020. URL https://openreview. net/forum?id=SJeD3CEFPH.
215
+
216
+ 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.
217
+
218
+ Sebastian Flennerhag, Yannick Schroecker, Tom Zahavy, Hado van Hasselt, David Silver, and Satinder Singh. Bootstrapped meta-learning. In International Conference on Learning Representations, 2022. URL https://openreview.net/forum?id=b-ny3x071E5.
219
+
220
+ Hiroki Furuta, Yutaka Matsuo, and Shixiang Shane Gu. Generalized decision transformer for offline hindsight information matching. arXiv preprint arXiv:2111.10364, 2021.
221
+
222
+ Shivam Garg, Dimitris Tsipras, Percy Liang, and Gregory Valiant. What Can Transformers Learn In-Context? A Case Study of Simple Function Classes, 2022.
223
+
224
+ Matteo Hessel, Ivo Danihelka, Fabio Viola, Arthur Guez, Simon Schmitt, Laurent Sifre, Theophane Weber, David Silver, and Hado van Hasselt. Muesli: Combining Improvements in Policy Optimization. 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. 4214–4226. PMLR, 2021.
225
+
226
+ Sepp Hochreiter and Jurgen Schmidhuber. ¨ Long Short-Term Memory. Neural Computation, 9(8): 1735–1780, 1997.
227
+
228
+ Sepp Hochreiter, A Steven Younger, and Peter R Conwell. Learning to learn using gradient descent. In International conference on artificial neural networks, pp. 87–94. Springer, 2001.
229
+
230
+ Shin Ishii, Wako Yoshida, and Junichiro Yoshimoto. Control of exploitation–exploration metaparameter in reinforcement learning. Neural networks, 15(4-6):665–687, 2002.
231
+
232
+ Michael Janner, Qiyang Li, and Sergey Levine. Reinforcement Learning as One Big Sequence Modeling Problem. arXiv preprint arXiv:2106.02039, 2021.
233
+
234
+ T.L Lai and Herbert Robbins. Asymptotically Efficient Adaptive Allocation Rules. Adv. Appl. Math., 6(1):4–22, mar 1985. ISSN 0196-8858. doi: 10.1016/0196-8858(85)90002-8.
235
+
236
+ Kuang-Huei Lee, Ofir Nachum, Mengjiao Yang, Lisa Lee, Daniel Freeman, Winnie Xu, Sergio Guadarrama, Ian Fischer, Eric Jang, Henryk Michalewski, and Igor Mordatch. Multi-Game Decision Transformers, 2022.
237
+
238
+ 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.
239
+
240
+ Eric Mitchell, Rafael Rafailov, Xue Bin Peng, Sergey Levine, and Chelsea Finn. Offline metareinforcement learning with advantage weighting. In International Conference on Machine Learning, pp. 7780–7791. PMLR, 2021.
241
+
242
+ 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.
243
+
244
+ Volodymyr Mnih, Koray Kavukcuoglu, David Silver, Andrei A Rusu, Joel Veness, Marc G Bellemare, Alex Graves, Martin Riedmiller, Andreas K Fidjeland, Georg Ostrovski, et al. Human-level control through deep reinforcement learning. nature, 518(7540):529–533, 2015.
245
+
246
+ Volodymyr Mnih, Adria Puigdom \` enech Badia, Mehdi Mirza, Alex Graves, Timothy P. Lillicrap, Tim \` Harley, David Silver, and Koray Kavukcuoglu. Asynchronous Methods for Deep Reinforcement Learning. In Maria-Florina Balcan and Kilian Q. Weinberger (eds.), Proceedings of the 33nd International Conference on Machine Learning, ICML 2016, New York City, NY, USA, June 19-24, 2016, volume 48 of JMLR Workshop and Conference Proceedings, pp. 1928–1937. JMLR.org, 2016.
247
+
248
+ Richard G.M. Morris. Spatial localization does not require the presence of local cues. Learning and Motivation, 12(2):239–260, 1981. doi: 10.1016/0023-9690(81)90020-5.
249
+
250
+ Rafael Muller, Simon Kornblith, and Geoffrey E Hinton.¨ When does label smoothing help? 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/ f1748d6b0fd9d439f71450117eba2725-Paper.pdf.
251
+
252
+ Tianwei Ni, Benjamin Eysenbach, and Ruslan Salakhutdinov. Recurrent model-free RL can be a strong baseline for many pomdps. In Kamalika Chaudhuri, Stefanie Jegelka, Le Song, Csaba Szepesvari, Gang Niu, and Sivan Sabato (eds.), ´ International Conference on Machine Learning, ICML 2022, 17-23 July 2022, Baltimore, Maryland, USA, volume 162 of Proceedings of Machine Learning Research, pp. 16691–16723. PMLR, 2022. URL https://proceedings.mlr. press/v162/ni22a.html.
253
+
254
+ Alex Nichol, Joshua Achiam, and John Schulman. On First-Order Meta-Learning Algorithms, 2018.
255
+
256
+ Vitchyr H Pong, Ashvin V Nair, Laura M Smith, Catherine Huang, and Sergey Levine. Offline meta-reinforcement learning with online self-supervision. In International Conference on Machine Learning, pp. 17811–17829. PMLR, 2022.
257
+
258
+ Alec Radford, Karthik Narasimhan, Tim Salimans, Ilya Sutskever, et al. Improving language understanding by generative pre-training, 2018.
259
+
260
+ ack W. Rae, Sebastian Borgeaud, Trevor Cai, Katie Millican, Jordan Hoffmann, Francis Song, John Aslanides, Sarah Henderson, Roman Ring, Susannah Young, Eliza Rutherford, Tom Hennigan, Jacob Menick, Albin Cassirer, Richard Powell, George van den Driessche, Lisa Anne Hendricks, Maribeth Rauh, Po-Sen Huang, Amelia Glaese, Johannes Welbl, Sumanth Dathathri, Saffron Huang, Jonathan Uesato, John Mellor, Irina Higgins, Antonia Creswell, Nat McAleese, Amy Wu, Erich Elsen, Siddhant Jayakumar, Elena Buchatskaya, David Budden, Esme Sutherland, Karen Simonyan, Michela Paganini, Laurent Sifre, Lena Martens, Xiang Lorraine Li, Adhiguna Kuncoro, Aida Nematzadeh, Elena Gribovskaya, Domenic Donato, Angeliki Lazaridou, Arthur Mensch, Jean-Baptiste Lespiau, Maria Tsimpoukelli, Nikolai Grigorev, Doug Fritz, Thibault Sottiaux, Mantas Pajarskas, Toby Pohlen, Zhitao Gong, Daniel Toyama, Cyprien de Masson d’Autume, Yujia Li, Tayfun Terzi, Vladimir Mikulik, Igor Babuschkin, Aidan Clark, Diego de Las Casas, Aurelia Guy, Chris Jones, James Bradbury, Matthew Johnson, Blake Hechtman, Laura Weidinger, Iason Gabriel, William Isaac, Ed Lockhart, Simon Osindero, Laura Rimell, Chris Dyer, Oriol Vinyals, Kareem Ayoub, Jeff Stanway, Lorrayne Bennett, Demis Hassabis, Koray Kavukcuoglu, and Geoffrey Irving. Scaling Language Models: Methods, Analysis & Insights from Training Gopher, 2021.
261
+
262
+ Kate Rakelly, Aurick Zhou, Chelsea Finn, Sergey Levine, and Deirdre Quillen. Efficient off-policy meta-reinforcement learning via probabilistic context variables. In Kamalika Chaudhuri and Ruslan Salakhutdinov (eds.), Proceedings of the 36th International Conference on Machine Learning, ICML 2019, 9-15 June 2019, Long Beach, California, USA, volume 97 of Proceedings of Machine Learning Research, pp. 5331–5340. PMLR, 2019. URL http://proceedings. mlr.press/v97/rakelly19a.html.
263
+
264
+ 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.
265
+
266
+ Andrei A. Rusu, Sergio Gomez Colmenarejo, C¸ aglar Gul¨ c¸ehre, Guillaume Desjardins, James Kirkpatrick, Razvan Pascanu, Volodymyr Mnih, Koray Kavukcuoglu, and Raia Hadsell. Policy distillation. In Yoshua Bengio and Yann LeCun (eds.), 4th International Conference on Learning Representations, ICLR 2016, San Juan, Puerto Rico, May 2-4, 2016, Conference Track Proceedings, 2016. URL http://arxiv.org/abs/1511.06295.
267
+
268
+ Jurgen Schmidhuber. Reinforcement learning upside down: Don’t predict rewards - just map them to ¨ actions. CoRR, abs/1912.02875, 2019. URL http://arxiv.org/abs/1912.02875.
269
+
270
+ Julian Schrittwieser, Ioannis Antonoglou, Thomas Hubert, Karen Simonyan, Laurent Sifre, Simon Schmitt, Arthur Guez, Edward Lockhart, Demis Hassabis, Thore Graepel, Timothy P. Lillicrap, and David Silver. Mastering Atari, Go, Chess and Shogi by Planning with a Learned Model. CoRR, abs/1911.08265, 2019.
271
+
272
+ Rupesh Kumar Srivastava, Pranav Shyam, Filipe Mutz, Wojciech Jaskowski, and J ´ urgen Schmidhuber. ¨ Training agents using upside-down reinforcement learning. arXiv preprint arXiv:1912.02877, 2019.
273
+
274
+ Christian Szegedy, Vincent Vanhoucke, Sergey Ioffe, Jon Shlens, and Zbigniew Wojna. Rethinking the inception architecture for computer vision. In 2016 IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pp. 2818–2826, 2016. doi: 10.1109/CVPR.2016.308.
275
+
276
+ Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Lukasz Kaiser, and Illia Polosukhin. Attention is all you need. In Advances in Neural Information Processing Systems, 2017.
277
+
278
+ Jane X Wang, Zeb Kurth-Nelson, Dhruva Tirumala, Hubert Soyer, Joel Z Leibo, Remi Munos, Charles Blundell, Dharshan Kumaran, and Matt Botvinick. Learning to reinforcement learn, 2016.
279
+
280
+ Ronald J. Williams. Simple Statistical Gradient-Following Algorithms for Connectionist Reinforcement Learning. Mach. Learn., 8:229–256, 1992. doi: 10.1007/BF00992696.
281
+
282
+ Ronald J Williams and David Zipser. A learning algorithm for continually running fully recurrent neural networks. Neural computation, 1(2):270–280, 1989.
283
+
284
+ Mengdi Xu, Yikang Shen, Shun Zhang, Yuchen Lu, Ding Zhao, Joshua Tenenbaum, and Chuang Gan. Prompting decision transformer for few-shot policy generalization. In International Conference on Machine Learning, pp. 24631–24645. PMLR, 2022.
285
+
286
+ Jiahui Yu, Yuanzhong Xu, Jing Yu Koh, Thang Luong, Gunjan Baid, Zirui Wang, Vijay Vasudevan, Alexander Ku, Yinfei Yang, Burcu Karagol Ayan, Ben Hutchinson, Wei Han, Zarana Parekh, Xin Li, Han Zhang, Jason Baldridge, and Yonghui Wu. Scaling Autoregressive Models for Content-Rich Text-to-Image Generation, 2022.
287
+
288
+ Qinqing Zheng, Amy Zhang, and Aditya Grover. Online decision transformer. arXiv preprint arXiv:2202.05607, 2022.
289
+
290
+ # A DISCUSSION AND LIMITATIONS
291
+
292
+ Discussion: While AD is more data-efficient than the source algorithm, we found that the source algorithm achieves a slightly higher asymptotic score in harder environments. This presents a tradeoff between data-efficiency and asymptotic optimality when using AD that should be taken into consideration when applying AD to a specific problem. In terms of long-term consequences, AD presents a path for converting narrow single-task RL agents into multi-task generalist ones. To date, deep RL research has mostly focused on powerful single-task agents Mnih et al. (2015); Schrittwieser et al. (2019); Hessel et al. (2021). These algorithms have produced powerful but data-inefficient agents, which has limited their applicability beyond narrow domains. AD offers a path toward training substantially more data-efficient, though perhaps less optimal, generalist agents by distilling narrow RL algorithms into sequence models like transformers.
293
+
294
+ Limitations: While AD is a general method, in this work we’ve shown that AD generalizes to new tasks within the same domain. Showing the ability to distill cross-domain RL algorithms and generalize to new domains would be an interesting line if inquiry for future work. AD also requires storing many learning histories which could take up significant memory, though this may not be too much of an issue since the learning histories can be stored on disk rather than RAM. Perhaps the main limitation of AD is that most RL environments of interest have long episodes and modeling multiepisodic context requires more powerful long-horizon sequential models than the ones considered in this work. We believe this is a promising direction for future research.
295
+
296
+ # B ENVIRONMENT CONSIDERATIONS
297
+
298
+ In this work, we consider environments where zero-shot generalization is difficult, so the agent must learn through trial and error. We also want environments where overfitting to any particular task is difficult to ensure our method is general. A final practical consideration is that we consider environments wher across-episodic histories can be feasibly modeled with a causal transformer. Given these considerations, our evaluation environments need to satisfy three criteria:
299
+
300
+ 1. Supports many tasks: The environments must be multi-task to ensure that our agent and the baselines do not overfit to any single task and instead is able to in-context reinforcement learn across many tasks within a given domain.
301
+ 2. Task must be hard to infer: To ensure that the downstream tasks are hard to generalize to in zero-shot, we use environments that require exploration. Namely, we require environments where either the task can only be inferred from the reward and not the observation, or tasks that are partially observable.
302
+ 3. Supports multi-episodic contexts: Lastly, we impose a practical constraint - the environment episodes must be short enough such that a normal GPT-like transformer can fit multiple episodes in its context. Since this work introduces AD as a method, we wish to investigate it in the cleanest possible setting using a canonical architecture. We leave investigating AD with more complex architectures that scale to longer sequences for future work.
303
+
304
+ Prior related works (Chen et al., 2021; Lee et al., 2022; Janner et al., 2021; Reed et al., 2022) evaluated on Atari, OpenAI gym, and as well as other environments. However, Atari and OpenAI gym don’t satisfy at least one of the above criteria. Atari and OpenAI gym episodes are often long and can contain thousands or more transitions per episode, so it’s technically challenging to populate a causal transformer’s context with across-episode histories. Indeed, the prior related works only considered within-episode context lengths. Additionally, it is often easy to infer the task from either the observation or the dense reward alone in both Atari and OpenAI gym, which reduces the need for exploration. For these reasons, we evaluate in environments that satisfy all three criteria instead.
305
+
306
+ # C CLOSELY RELATED PRIOR METHODS
307
+
308
+ In our main results we use Expert Distillation (ED) as a baseline. Here, we discuss how the most closely related methods differ from AD and why ED is sufficient to support the paper’s claims.
309
+
310
+ Expert Distillation (ED): ED is most similar to Gato (Reed et al., 2022), which models expert sequences from a converged RL policy using a causal transformer. ED also trains a causal transformer to predict actions using expert policy data. There are two key differences between ED and Gato. First, unlike Gato which utilizes small (relative to an episode length) within-episode contexts, ED is trained on the same across-episode contexts as AD, so the architectures used by ED and AD are the same. The benefits of AD cannot therefore be attributed to across-episode contexts alone but also learning progress in the offline data used to train AD. Second, ED models state-action-reward sequences while Gato models only state-action sequences. The main difference between ED and AD is that AD is trained on full multi-task learning histories rather than expert policy data.
311
+
312
+ Decision Transformer (DT) (Chen et al., 2021) and Multi-Game Decision Transformer (Lee et al., 2022): DTs learn return-conditioned policies from single-task offline data collected by an RL agent. While the training data itself (an RL agent’s replay buffer) contains learning, the context sizes used in DT are too small to capture any learning progress or identify the task using across-episode information. For instance, the Atari experiments use a context of length $3 0 - 5 0$ tokens, or $1 0 - 1 7$ transitions. Atari games can have hundreds or thousands of transitions in a single episode, which means these contexts capture mostly within-episode information. Additionally, very little learning progress happens in the underlying replay buffer data within that many transitions.
313
+
314
+ Another difference between DT and AD / ED is that DT learns a return-conditioned model whereas AD / ED are both reward-conditioned. In our setting return-conditioning alone cannot yield an optimal policy since the agent does not know the task until after it explores the environment and can identify it using across-episode contexts. Since (i) DT uses small within-episodic contexts and (ii) return-conditioning would not help in the environments considered, this baseline is similar to ED with a small within-episode context which is strictly weaker than the long across-episode context variant of ED we consider.
315
+
316
+ Trajectory Transformer (TTO) (Janner et al., 2021): Like AD, TTO also models state-action-reward tokens but in addition to predicting actions it also learns a world model by predicting states and rewards. To maximize return, TTO then uses beam search to select high-reward actions. However, in our setting, TTO will run into the same problem as DT. To model rewards accurately it will need longer across-episodic contexts since one environment supports many tasks. Similar to DT, MGDT, and Gato, TTO uses smaller within-episode contexts. For this reason, TTO will fare no better than DT, MGDT, or ED in the settings we consider. We also note that in contrast to TTO, AD is model-free. In AD, actions are sampled from the transformer history-conditioned predictions and return maximization emerges from modeling the learning histories of an RL algorithm.
317
+
318
+ To summarize, AD differs from prior methods mainly because its context is across-episodic and hence large enough to capture learning progress and task information. AD could further be augmented by learning world models like TTO or conditioning on returns like DT, but these investigations would be well suited for future work since they are tangential to the main research question addressed in this work – whether in-context RL can emerge by imitating the learning histories of an RL algorithm with long across-episodic contexts.
319
+
320
+ AD is also closely related to prior work in in-context meta-RL. While both AD and in-context meta-RL model across-episodic histories with memory-based architectures, prior in-context meta-RL algorithms, such as RL2 (Duan et al., 2016) are trained online and rely on learning multi-episodic value functions with TD learning while AD is trained offline and uses a supervised imitation learning objective.
321
+
322
+ # D EXPERT DISTILLATION MAIN RESULTS
323
+
324
+ We elaborate further on the main results in Fig. 4 and provide intuition regarding the behaviors of the ED baseline. In Dark Room, Dark Room (Hard), and Watermaze, ED performance is either flat or it degrades. The reason for this is that ED only saw expert trajectories during training, but during evaluation it needs to first explore (i.e. perform non-expert behavior) to identify the task. This required behavior is out-of-distribution for ED and for this reason it does not reinforcement learning in-context. In Dark Key-to-Door the agent is reset randomly at the beginning of each episode, whereas in all of the environments the agent’s starting position is fixed. Due to random resets, the ED agent is sometimes reset by the first goal in Dark Key-to-Door which allows it to occasionally identify the first goal of the task, which is why it shows slight improvement.
325
+
326
+ # E MODEL SIZE
327
+
328
+ We investigate how transformer capacity affects performance in Fig. 8. While in-context RL emerges across all model sizes investigated, we find that increasing the model depth, the model width in terms of embedding dimension, and (to a lesser extent) the number of attention heads improves performance on Dark Key-to-Door.
329
+
330
+ ![](images/7268b332c41895dedc19c08ef9b6099f4da74ea1f1754cc2dd5c84977a7dc825.jpg)
331
+ Figure 8: Model size investigations: We investigate how increasing model capacity affects AD. While in-context RL with AD emerges regardless of the model capacity, increasing the model depth and width helps improve AD until it achieves near-optimal performance.
332
+
333
+ ![](images/5225296573b7d46d8a1d9f73f0c47aa7acab27725bdc5f8cd9d76937d0d127b6.jpg)
334
+ Figure 9: Asymptotic performance of the A3C (Mnih et al., 2016) and a $\mathbf { Q - } \lambda$ variant of the DQN (Mnih et al., 2013) RL algorithms used to produce learning histories for the Dark and Watermaze environments. These curves show the learning histories AD is trained on. The source algorithms plotted in Fig. 4 are the same as in these plots.
335
+
336
+ # G LABEL SMOOTHING ABLATION
337
+
338
+ For the harder exploration task of Dark Room (Hard), we found that adding label smoothing regularization (Szegedy et al., 2016; Muller et al. ¨ , 2019) improved the in-context learning ability of AD . In Figure 10 we ablate the benefit of using label smoothing for 3 different $\alpha$ values as well as with it turned off. Each curve in the figure denotes average performance over 5 training seeds. We can see that adding label smoothing up to a point improves the in-context learning ability of Algorithm Distillation, with performance continually increasing with the number of evaluation episodes.
339
+
340
+ ![](images/e07003b625836d03f8abae3f9b6de0dbf38604250cecc84a2937ab5a8c642300.jpg)
341
+ Figure 10: AD trained with different amounts of label smoothing on Dark Room (Hard).
342
+
343
+ # H $\mathtt { R L } ^ { 2 }$ NETWORK ARCHITECTURE: TRANSFORMER VS LSTM
344
+
345
+ We compared using a transformer as the architecture for $\mathrm { { R L ^ { 2 } } }$ instead of an LSTM. In Figure 11, we ran both transformer and LSTM $\mathrm { { R L ^ { 2 } } }$ agents over the Dark Room environment. The curves shown are the best from a sweep over learning rate and unroll length hyperparameters. The transformer architecture is 4-layers with a model size of 256 and pre-norm layer normalization placement. While both agents reached a similar level of final performance, all $\mathtt { R L } ^ { \dot { 2 } }$ transformer models trained tended to be more unstable with the average return not as consistent as with an LSTM architecture. Given the poor performance of the transformer-based $\mathrm { { R L ^ { 2 } } }$ on the simpler Dark Room setting, our other experimental settings used the LSTM.
346
+
347
+ ![](images/d84a5680152d9b0d5a45f824e697e85bb345213b6f295d3072548835b0a69b86.jpg)
348
+ LSTM v.s. Transformer
349
+ Figure 11: Comparison of LSTM and Transformer architecture for $\mathtt { R L } ^ { 2 }$ agent on Dark Room. Each curve is averaged over 5 training seeds with the shaded area representing the standard error.
350
+
351
+ # I NUMBER OF TRAINING TASKS IN SOURCE DATA
352
+
353
+ ![](images/3f6801f52bcd71f0fcf1231b4856e8cbd97a9ff344198d24cc0710b9d3353f73.jpg)
354
+ Figure 12: Algorithm distillation trained on different numbers of training tasks on Dark Key-to-Door evaluated on a fixed set of test tasks for 300 episodes of evaluation.
355
+
356
+ One interesting question is how many tasks AD needs to be trained on to learn an algorithm that generalizes to held out tasks. We trained AD on different numbers of Dark Key-to-Door training tasks and evaluated the resulting models on the same set of test tasks. Figure 12 shows the incontext learning plots for the resulting AD models on the set of test tasks. As a reminder, there are $8 1 ^ { 2 } = 6 5 6 1$ unique Dark Key-to-Door tasks. Models trained on 1, 9 or 18 training tasks did not show any in-context learning on test tasks. While models trained on 37, 75 and 151 tasks did not achieve good performance overall, they did exhibit some in-context learning over the course of 300 episodes. The best models were trained on 1212 and 2424 tasks which corresponds to roughly $1 8 \%$ and $3 7 \%$ of the total number of tasks in the Dark Key-to-Door domain.
357
+
358
+ # J SINGLE-STREAM ALGORITHM DISTILLATION
359
+
360
+ We provide more details around the experimental setup for the single-stream result shown in Fig. 6. We showed in Fig. 4 that when AD is trained on data from a subset of the actors of a distributed source RL algorithm, the resulting model is more data efficient than the source algorithm. Here we confirm that AD can produce a faster algorithm than the one it was trained on in the single-stream setting. For this experiment we trained A3C on 2048 Dark Key-to-Door tasks for 2000 episodes each. We then trained AD on the resulting data while subsampling the learning histories by a factor of 10. More concretely, we took every 10th episode from each of the learning history, which resulted in a 200 episode compressed learning trajectory for each task. Figure 6 compares the resulting AD model evaluated on a set of test tasks to the performance of the source algorithm on these tasks. The model learned by AD learns much faster than the source algorithm confirming that Algorithm Distillation can turn a slow gradient-based algorithm into a much more data efficient in-context learning algorithm.
361
+
362
+ # K RANDOM MASK
363
+
364
+ ![](images/1038f6e9da6d542b87e80cfa6740b77180b4083883611e385d6a893aeadde962.jpg)
365
+ Figure 13: Downstream performance of Algorithm Distillation with different values of random masking during training in $9 \mathrm { { x 9 1 } }$ goal gridworld.
366
+
367
+ During training, input tokens were randomly masked to avoid overfitting to training data. This plot shows the downstreams results on a $9 \mathrm { x } 9$ Dark Key-to-Door domain with different values of this random masking. Values of $0 . 3 - 0 . 5$ perform the best with the value of 0.3 chosen for all experiments.
368
+
369
+ # L AD NETWORK ARCHITECTURE: TRANSFORMER VS LSTM
370
+
371
+ Here we consider the importance of the Transformer architecture to the success of algorithm distillation (AD) by comparing to AD based off of an LSTM (Hochreiter & Schmidhuber, 1997). Specifically, the LSTM receives the concatenated embeddings of $\left( o _ { i } , a _ { i } , r _ { i } \right)$ triplets up to the most recent time step $t - 1$ . The output of the LSTM is then concatenated with the current observation $o _ { t }$ embedding and both are then fed through a multi-layer perceptron (MLP) policy torso to produce a distribution over the present action $a _ { t }$ . The LSTM hidden size (512), MLP depth (2), and MLP width (256) were swept and tuned by grid search based on downstream reward attainment.
372
+
373
+ Comparing Transformer AD and LSTM AD on the Dark Key-to-Door task (Figure 14), we find that both agents are capable of in-context learning, demonstrating that the success of AD is not tied to the underlying network architecture. However, we also find that the Transformer variant consistently outperforms the LSTM variant, which is why all other experiments in this paper employ the Transformer variant. This finding is consistent with the recent wider success of Transformer-based architectures over recurrent neural network (RNN)-based architectures in sequence prediction tasks.
374
+
375
+ # M DISTILLING ACTIONS VS PROBABILITIES
376
+
377
+ In the rest of the paper, we use (one-hot) actions taken by the source policy as the prediction target for AD. Here, we compare that choice to predicting the source policy probabilities from which that action was sampled. In other words, is it better to distill actions or probabilities?
378
+
379
+ Figure 15 compares all combinations of: 1) distilling actions vs probabilities, and 2) conditioning those predictions on past actions, probabilities, or both. The plot labels represent various input/output combinations, e.g. $\mathtt { S a r - } > \mathtt { a }$ indicates observing states, actions, and rewards while predicting actions (i.e. the main variant of AD in the rest of the paper), sar $- > \mathrm { p }$ represents using the same observations but instead predicting probabilities, and $\tt S a p r - > a$ represents observing states, actions, probabilities, and rewards while predicting actions, etc.
380
+
381
+ Two conclusions stand out from this plot. First, the original action distillation variant of AD $( s \mathsf { a r } - \mathsf { > a } )$ performs best, followed closely by probability distillation $( \mathsf { s a r - > p } )$ . In the paragraphs and experiments below, we explore why action distillation outperforms probability distillation. Second, all variants that condition on past probabilities catastrophically fail. We speculate on two somewhat contradictory reasons why this might occur: 1) The AD prediction task involves a combination of inferring the current policy, as well as predicting when policy updates will occur. Since observing policy probabilities provides more information about the current policy than actions do, it is possible that this leads to AD fully focusing on inferring the current policy and ignoring the prediction of policy updates. In other words, observing only actions taken may act as a useful information bottleneck. 2) On the other hand, observing probabilities may inadvertently leak information about when policy updates occur. If the transformer context includes multiple visits to the same state, AD could learn to compare the policy probabilities to infer whether a policy update occurred in between the two visits. If AD learned during training to rely on this information, then during autoregressive evaluation, it may be “waiting“ for a policy update than never occurs. If this is the source of the issue, then a potential solution would be retraining with explicit policy update tokens and including them between evaluation episodes, however we leave this investigation to future work.
382
+
383
+ ![](images/454e8467c64103db58787ec5b2c5c859eefc5a040f070dda6d155b0f1e59d8e6.jpg)
384
+ Figure 14: Comparison between algorithm distillation with a Transformer and LSTM architecture on Dark Key-to-Door. Mean $\pm \nobreakspace 1 \nobreakspace$ standard deviation over 5 training seeds and 20 evaluation seeds. 300 episodes corresponds to $1 5 \mathrm { k }$ environment steps.
385
+
386
+ ![](images/a807c9a242becc876d7e1138b0bdc3096c70672568caf1845fcca6c88bec2352.jpg)
387
+ Figure 15: Comparison between algorithm distillation with various input/output combinations on Dark Key-to-Door. Mean $\pm \nobreakspace 1 \nobreakspace$ standard deviation over 5 training seeds and 20 evaluation seeds. 1000 episodes corresponds to $5 0 \mathrm { k }$ environment steps.
388
+
389
+ Now we return to the question of why action distillation $\left( s \mathsf { a r } - \mathsf { > a } \right)$ outperforms probability distillation $( s \mathsf { a r } \mathrm { - } \mathsf { > p } )$ . Intuitively, distilling one-hot actions will result in a more deterministic policy than distilling probabilities when training on finite data. Indeed, the red curves in the top two plots of Figure 16 show that probability distillation (top left) converges to a higher entropy ${ \sim } 1 . 2$ bits) policy than does action distillation (top right, ${ \sim } 1$ bit). Noting this discrepancy, we speculated that encouraging probability distillation towards a more deterministic policy might lead to increased performance. To do so, we experimented with an entropy penalty regularizer added to the AD loss from equation 6, leading to the modified objective:
390
+
391
+ $$
392
+ \tilde { \mathcal { L } } ( \theta , \alpha ) : = \sum _ { n = 1 } ^ { N } \sum _ { t = 1 } ^ { T - 1 } - \log P _ { \theta } ( A = a _ { t } ^ { ( n ) } | h _ { t - 1 } ^ { ( n ) } , o _ { t } ^ { ( n ) } ) + \alpha H \Big [ P _ { \theta } ( A | h _ { t - 1 } ^ { ( n ) } , o _ { t } ^ { ( n ) } ) \Big ] ,
393
+ $$
394
+
395
+ where $H [ \cdot ]$ is the Shannon entropy in bits, and $\alpha$ is a regularization weight. The top two panels of Figure 16 show the effect of increasing $\alpha$ on decreasing policy entropy for action distillation (top right) and probability distillation (top left), throughout training. The bottom two panels show the corresponding changes in evaluation returns. Notably, entropy penalization indeed improves performance for probability distillation (bottom left), with the best performing regularization value $\alpha = 0 . 1$ ) achieving a similar return to the original unregularized action distillation (bottom right, red). Interestingly, this is the amount of regularization that leads probability distillation to have the most similar entropy to the unregularized action distillation variant $_ { \sim 1 }$ bit) as well. Further entropy penalization for action distillation, on the other hand, does not lead to increased performance (bottom right). Together, these results suggest that action distillation naturally leads to the “optimal“ amount of entropy regularization on its own, at least in the environments we study.
396
+
397
+ ![](images/1193b4fb8b446f1e1eb9a0060b68dfb52c35743a1269cf2b5dabdd292afbbd8e.jpg)
398
+ Figure 16: Policy entropy during training and reward during evaluation for the action distillation $( s \mathsf { a r } - \mathsf { > a } )$ and probability distillation $( \mathsf { s a r - > p } )$ variants of AD on Dark Key-to-Door. Colors indicate the strength of the weight on the entropy penalty regularizer from equation 7. Mean $\pm \nobreakspace 1 \nobreakspace$ standard deviation over 5 training seeds and 20 evaluation seeds. 1000 episodes corresponds to $5 0 \mathrm { k }$ environment steps.
399
+
400
+ In addition to closing gap between probability and action distillation with an entropy penalty, we also explored retuning various hyperparameters for $\mathtt { S a r - > p }$ rather than reusing those tuned for $\mathtt { S a r - } > \mathtt { a }$ . We found that many hyperparameters, such as the dropout rate, attention dropout rate, and sequence mask probability, had similar optimal values in the two cases, and so retuning them did not help. However, one hyperparameter that did have an effect was the size of the transformer context window (Figure 17). While action distillation performance increased only up to a context window size of 200 steps (4 episodes) and then plateaued (Figure 17, right), probability distillation performance continued to increase up to a context window size of 300 steps (6 episodes) before plateauing (Figure 17, left). Thus, while a comparison at our default context window size of 200 steps favored action distillation, for larger context window sizes, action and probability distillation performed similarly. We leave any further explanation of why probability distillation requires larger context windows than action distillation to future work.
401
+
402
+ ![](images/5dfce0c0db48409f890ffe00174597da457e40c2ba659bd24f1e455836d5c726.jpg)
403
+ Figure 17: Context window size dependence for the action distillation $( s \mathsf { a r } - > \mathsf { a } )$ and probability distillation $( \mathsf { s a r - > p } )$ variants of AD on Dark Key-to-Door. Mean $\pm \nobreakspace 1 \nobreakspace$ standard deviation over 5 training seeds and 20 evaluation seeds. 1000 episodes corresponds to $5 0 \mathrm { k }$ environment steps.
404
+
405
+ N ALGORITHM DISTILLATION HYPERPARAMETERS
406
+
407
+ <table><tr><td>Hyperparameter</td><td>Dark Room</td><td>Dark Room (Hard)</td><td>Dark Key-to-Door</td><td>Watermaze</td></tr><tr><td>Embedding Dim.</td><td></td><td colspan="3">64</td></tr><tr><td>Number of Layers</td><td colspan="4"></td></tr><tr><td>Number of Heads</td><td colspan="4">4</td></tr><tr><td>Feedforward Dim.</td><td colspan="4">2048</td></tr><tr><td>Position Encodings</td><td colspan="4">Absolute</td></tr><tr><td>LayerNorm Placement</td><td colspan="4">Post Norm</td></tr><tr><td>Dropout Rate</td><td colspan="4">0.1</td></tr><tr><td>Context Window</td><td colspan="4">600 tokens (200 timesteps)</td></tr><tr><td>Attention Dropout Rate</td><td></td><td>0</td><td>0.5</td><td>0.5</td></tr><tr><td>Sequence Mask Prob</td><td>0.5 0.3</td><td>0.5</td><td>0.3</td><td>0.3</td></tr><tr><td>Label Smoothing α</td><td>0</td><td>0.2</td><td>0</td><td>0</td></tr></table>
408
+
409
+ Table 1: Algorithm Distillation Architecture Hyperparameters.
410
+
411
+ <table><tr><td>Hyperparameter</td><td>Value</td></tr><tr><td>Batch Size</td><td>128</td></tr><tr><td>Optimizer</td><td>Adam</td></tr><tr><td>β</td><td>0.9</td></tr><tr><td></td><td>0.99</td></tr><tr><td>Gradient Clip Norm Threshold</td><td>1</td></tr><tr><td>Learning Rate Schedule</td><td>Cosine Decay</td></tr><tr><td>Initial Value</td><td>2e-6</td></tr><tr><td>Peak Value</td><td>3e-4</td></tr></table>
412
+
413
+ Table 2: Algorithm Distillation Optimization Hyperparameters.
414
+ Table 3: Watermaze Image Encoder Hyperparameters.
415
+
416
+ <table><tr><td>Layer</td><td>Hyperparameter</td><td>Value</td></tr><tr><td>Conv Block</td><td></td><td></td></tr><tr><td rowspan="3">Conv</td><td>Channel</td><td>128</td></tr><tr><td>Kernel</td><td>5</td></tr><tr><td>Stride</td><td>2</td></tr><tr><td>BatchNorm</td><td>Decay Rate</td><td>0.999</td></tr><tr><td>Activation</td><td>eps</td><td>1e-5</td></tr><tr><td></td><td>-</td><td>ReLU</td></tr><tr><td rowspan="2">Max Pooling</td><td>Kernel</td><td>2</td></tr><tr><td>Stride</td><td>2</td></tr><tr><td>Dropout</td><td>Rate</td><td>0.2</td></tr><tr><td>Network</td><td></td><td></td></tr><tr><td>Conv Blocks</td><td>=</td><td>3</td></tr><tr><td>FinalLinearLayer</td><td>Units</td><td>256</td></tr></table>
417
+
418
+ # O SOURCE RL ALGORITHM HYPERPARAMETERS
419
+
420
+ # O.1 DARK ENVIRONMENTS
421
+
422
+ Table 4: Source A3C Algorithm Hyperparameters for Dark Environments.
423
+
424
+ <table><tr><td colspan="2">Hyperparameter Value</td></tr><tr><td>Batch Size (Num.Actors)</td><td>100</td></tr><tr><td>入</td><td>0.95</td></tr><tr><td>Agent Discount</td><td>0.99</td></tr><tr><td>Entropy Bonus Weight</td><td>0.01</td></tr><tr><td>MLPLayers</td><td>3</td></tr><tr><td>MLPHidden Dim</td><td>128</td></tr><tr><td>Optimizer</td><td>Adam</td></tr><tr><td>β</td><td>0.9</td></tr><tr><td>β2</td><td>0.999</td></tr><tr><td>E</td><td>1e-6</td></tr><tr><td>Learning Rate</td><td>1e-4</td></tr></table>
425
+
426
+ # O.2 DMLAB WATERMAZE
427
+
428
+ Table 5: Source $\mathrm { D Q N } ( \mathrm { Q } - \lambda )$ Algorithm Hyperparameters for Watermaze.
429
+
430
+ <table><tr><td>Hyperparameter</td><td>Value</td></tr><tr><td>Batch Size</td><td>8</td></tr><tr><td>Rollout Length</td><td>40</td></tr><tr><td>Rollout Overlap</td><td>31</td></tr><tr><td>Number of Actors</td><td>16</td></tr><tr><td>Reply Buffer Capacity</td><td>1e5</td></tr><tr><td>Offline Data Fraction</td><td>0.7</td></tr><tr><td>入</td><td>0.75</td></tr><tr><td>E</td><td>0.01</td></tr><tr><td>Agent Discount</td><td>0.9</td></tr><tr><td>Target Update Period</td><td>50</td></tr><tr><td>ResNet Channels</td><td>[32, 64, 64]</td></tr><tr><td>ResNetKernels</td><td>[3,3,3]</td></tr><tr><td>ResNet Strides</td><td>[1, 1, 1]</td></tr><tr><td>Pool Kernels</td><td>[3,3,3]</td></tr><tr><td>Pool Strides</td><td>[2,2,2]</td></tr><tr><td>Optimizer</td><td>Adam</td></tr><tr><td>β</td><td>0.9</td></tr><tr><td>阳</td><td>0.999</td></tr><tr><td>E</td><td>1e-6</td></tr><tr><td>Gradient Clip Norm Threshold</td><td>10</td></tr><tr><td>Learning Rate</td><td>1e-4</td></tr></table>
431
+
432
+ # P RL2 HYPERPARAMETERS
433
+
434
+ Table 6: RL2 Hyperparameters used in “Dark” Environments.
435
+
436
+ <table><tr><td>Hyperparameter</td><td>Value</td></tr><tr><td>RL Algorithm</td><td>A3C</td></tr><tr><td>Learning Rate</td><td>3e-4</td></tr><tr><td>Batch Size</td><td>256</td></tr><tr><td>Unroll Length</td><td>20</td></tr><tr><td>LSTM Hidden Dim. LSTMNumber ofLayers</td><td>256</td></tr><tr><td>Episodes Per Trial</td><td>2 10</td></tr></table>
437
+
438
+ <table><tr><td>Hyperparameter</td><td>Value</td></tr><tr><td>RL Algorithm</td><td>DQN(Q-入)</td></tr><tr><td>Learning Rate</td><td>1e-4</td></tr><tr><td>Batch Size</td><td>96</td></tr><tr><td>Unroll Length</td><td>40</td></tr><tr><td>LSTM Hidden Dim.</td><td>256</td></tr><tr><td>LSTMNumber of Layers</td><td>1</td></tr><tr><td>Episodes Per Trial</td><td>30</td></tr></table>
439
+
440
+ Table 7: RL2 Hyperparameters used in the Watermaze Environment.
441
+
442
+ ![](images/ea1fc762f193fd44d789c64e6914ec2d901af77612e21bb3dcbce6fbfe7da485.jpg)
443
+ 0 1700Figure 18: Attention maps for AD from five separate seeds. White and gray colors correspond to low and high attention. Red and blue colors indicate that those transitions correspond to an episode restart and a positive reward token, respectively. The left column plots attention for an AD transformer after 200 time-steps of evaluation (when the context is initially filled). The right column plots attention after 1900 steps (38 episodes) of evaluation. Each episode has a length of 50 steps. From these patterns, it is evident that AD attends to tokens across several episodes to predict its next action.
md/dev/ksVGCOlOEba/ksVGCOlOEba.md ADDED
@@ -0,0 +1,282 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Optimal Brain Compression: A Framework for Accurate Post-Training Quantization and Pruning
2
+
3
+ Elias Frantar ∗ IST Austria elias.frantar@ist.ac.at
4
+
5
+ Sidak Pal Singh ETH Zurich sidak.singh@inf.ethz.ch
6
+
7
+ Dan Alistarh IST Austria & Neural Magic dan.alistarh@ist.ac.at
8
+
9
+ # Abstract
10
+
11
+ We consider the problem of model compression for deep neural networks (DNNs) in the challenging one-shot/post-training setting, in which we are given an accurate trained model, and must compress it without any retraining, based only on a small amount of calibration input data. This problem has become popular in view of the emerging software and hardware support for executing models compressed via pruning and/or quantization with speedup, and well-performing solutions have been proposed independently for both compression approaches. In this paper, we introduce a new compression framework which covers both weight pruning and quantization in a unified setting, is time- and space-efficient, and considerably improves upon the practical performance of existing post-training methods. At the technical level, our approach is based on an exact and efficient realization of the classical Optimal Brain Surgeon (OBS) framework of [LeCun, Denker, and Solla, 1990] extended to also cover weight quantization at the scale of modern DNNs. From the practical perspective, our experimental results show that it can improve significantly upon the compression-accuracy trade-offs of existing post-training methods, and that it can enable the accurate compound application of both pruning and quantization in a post-training setting.
12
+
13
+ # 1 Introduction
14
+
15
+ The impressive recent progress of deep learning for solving challenging tasks across several domains has been accompanied by a significant increase in parameter counts and computational costs for executing such models. A natural consequence has been a growing effort to reduce such costs via model compression, and the two most popular approaches for model compression are pruning— removing neural network weights by setting them to zero—and quantization, reducing the precision at which neural network weights and activations are stored and manipulated. Hundreds of such pruning and quantization approaches have been proposed and analyzed [17, 11], with the general goal of obtaining efficient variants of deep neural nets (DNNs) which would preserve accuracy while maximizing compression. Despite impressive progress, compression is still a laborious process: the pruning and quantization stages are often done independently, and recovering model accuracy after compression often requires partial or even full retraining of the compressed model.
16
+
17
+ An alternative but challenging scenario is the post-training compression setup [31, 24, 19, 25], in which we are given a trained but uncompressed model, together with a small amount of calibration data, and must produce an accurate compressed model in one shot, i.e. a single compression step, without retraining, and with limited computational costs. This is motivated by practical scenarios such as the MLPerf Inference Benchmark [37], and is the setting we focus on in this paper.
18
+
19
+ Compression via weight pruning started with seminal work by LeCun et al. [23], complemented by Hassibi and Stork [13], who proposed a mathematical framework called the Optimal Brain Surgeon (OBS), for choosing the set of weights to remove from a trained neural network, by leveraging secondorder information. (We describe their approach in Section 3.) Recent advances, e.g. [6, 40, 39, 10] showed that OBS can lead to state-of-the-art compression at DNN scale, by introducing numerical methods which can approximate the second-order information needed by OBS at the massive parameter counts of modern models. However, these approaches do not apply to the post-training setting, as they require gradual pruning, as well as significant retraining, to recover good accuracy.
20
+
21
+ An alternative approach, which is standard in the context of post-training compression, has been to break the compression task into layer-wise sub-problems, identifying a compressed weight approximation for each layer, given a sub-sample of the layer’s inputs and outputs based on calibration data. This line of work, e.g. [42, 31, 19], introduced elegant solvers for the resulting layer-wise weight quantization problem, which achieve state-of-the-art results for post-training quantization. Recently, AdaPrune [18] showed that this approach can also be effective for post-training weight pruning.
22
+
23
+ In this context, a natural question is whether existing approaches for pruning and quantization can be unified in order to cover both types of compression in the post-training setting, thus making DNN compression simpler and, hopefully, more accurate. This question is also of practical importance, since both GPU and CPU platforms now jointly support sparse and quantized formats [30, 35], and, as we illustrate experimentally, the resulting models could be executed with compound speedups.
24
+
25
+ Contribution. In this paper, we provide a mathematical framework for compression via pruning or quantization, which leads to state-of-the-art accuracy-versus-compression trade-offs in the challenging post-training compression setup. Our framework starts from the layer-wise compression problem described above, by which the global compression task, defined either for pruning or quantization, is first split into layer-wise sub-problems, based on the layer behavior on the calibration data. Specifically, given a layer $\ell$ defined by weights $\mathbf { W } _ { \ell }$ , and layer inputs $\mathbf { X } _ { \ell }$ , we aim to find a compressed version of the weights $\widehat { \mathbf { W } } _ { \ell }$ which minimizes the output difference relative to the uncompressed layer, measured via the squared error between the original and compressed layer, acting on the sample input $\| { \mathbf { W } } _ { \ell } { \mathbf { X } } _ { \ell } - \widehat { { \mathbf { W } } } _ { \ell } { \mathbf { X } } _ { \ell } \| _ { 2 } ^ { 2 }$ , under a fixed compression constraint on $\widehat { \mathbf { W } } _ { \ell }$ .
26
+
27
+ Although solving this problem optimally for sparsity or quantization constraints is NP-hard [2, 31], it is a key step in all state-of-the-art post-training compression methods, both for pruning [18, 9] and for quantization [31, 18, 24]. Once this is solved per layer, a solution to the global problem can be obtained by combining layer-wise solutions, which is handy especially for non-uniform compression, e.g. [15, 9]. Thus, several approximations for this problem have been proposed [31, 19, 18].
28
+
29
+ We show that there still is significant room for improvement when solving the layer-wise compression problem. Roughly, our approach is to specialize the OBS framework to the squared error formulation above: in this case, the framework can in theory produce an exact greedy solution, but a direct implementation would have infeasible $\Theta ( d ^ { 4 } )$ computational cost, where $d$ is the layer dimension. Our main technical contribution is a series of algorithms which reduce this computational cost, without any approximations, to $O ( d \cdot d _ { c o l } ^ { 2 } )$ where $d _ { c o l }$ is the column dimension of the weight matrix. In practice, these improvements are significant enough to allow us to implement the exact OBS greedy solution, which prunes one weight at a time, and updates all remaining weights after each step, at the scale of modern DNNs with tens of millions of parameters, within reasonable time, on a single GPU. We provide efficient implementations of our methods at https://github.com/IST-DASLab/OBC.
30
+
31
+ In turn, this algorithmic development allows us to apply the OBS approach to quantization. The resulting algorithm, called the Optimal Brain Quantizer (OBQ), quantizes weights iteratively one-ata-time, depending on their impact on the loss increase, after which it applies a closed-form update to the remaining unquantized weights, further reducing the loss. This solves the two problems efficiently, and in a unified manner—we call the unified framework the Optimal Brain Compressor (OBC).
32
+
33
+ Experimental Results. We apply OBC to standard tasks and models covering image classification, object detection, and language modelling applications. We first show that our framework yields significantly better solutions for the layer-wise compression problem, which leads to higher-accuracy end-to-end compressed models for both pruning and quantization, relative to the corresponding stateof-the-art techniques, often by significant margins. Second, we show that our pruning and quantization approaches can be compounded, with surprisingly strong results: we obtain a $1 2 \times$ reduction in theoretical operations with a $2 \%$ accuracy drop for GPU-supported compound compression [30], and a $4 \times$ speedup in actual runtime with only $1 \%$ accuracy drop for a CPU-based sparsity-aware runtime [35]. Together, these results suggest for the first time that post-training compression can be competitive with full retraining.
34
+
35
+ # 2 Related Work
36
+
37
+ Optimal Brain Surgeon (OBS). The classic OBS framework [23, 13] was originally applied to networks with hundreds of weights; more recently, methods such as WoodFisher [39] rendered the approach computationally feasible for DNNs by using a block-diagonal Fisher approximation of the Hessian, while follow-up methods introduced more efficient and general algorithms for handling the inverse Fisher matrix, or customize this approximation to specific model families [21]. Earlier work called Layer-wise OBS (L-OBS) [6] was inspired by the K-FAC approximation [29, 12]: L-OBS approximates the OBS framework not for the global objective, but for a quadratic per-layer loss, while also pruning all weights based on a single Hessian computation. At a high level, our approach is similar, in that we apply OBS layer-wise; however, we apply OBS exactly, that is, pruning one weight at a time, and exactly recomputing the Hessian after every pruning step. This is made computationally tractable by several new algorithmic ideas, and yields significantly improved results relative to L-OBS. This prior work on pruning considered settings with extensive finetuning. By contrast, we will focus on the post-training setting, where only a small amount of calibration data is available.
38
+
39
+ Post-Training Quantization. This setting has been primarily considered for quantization, and most state-of-the-art methods work by performing layer-wise compression. Specifically, BitSplit [6] optimizes the quantized weights bit by bit, while AdaRound [31] finds a weight rounding policy through gradient based optimization with an annealed penalty term that encourages weights to move towards points on the quantization grid. AdaQuant [19] relaxes the AdaRound constraint, allowing weights to change during quantization-aware optimization, via straight-through estimation [33]. BRECQ [24] suggested that accuracy can be improved further by integrating second-order information into the layer-wise losses and by jointly optimizing hand-crafted blocks of related layers.
40
+
41
+ A key step of AdaRound, AdaQuant and BRECQ is to quantize layers incrementally, in sequential order, so that errors accumulated in earlier layers can be compensated by weight adjustments in later ones. This significantly improves performance, but reduces flexibility, as the entire process may need to be re-done whenever we wish to change compression parameters of one layer. We instead target independent compression of each layer, allowing the end model to be simply “stitched” together from layer-wise results. Despite operating independently on each layer, we find that, after correcting basic statistics such as batchnorm, our method performs on par to sequential ones for uniform quantization.
42
+
43
+ Post-Training Sparsification. The layer-wise approach was shown to also be effective for posttraining pruning by AdaPrune [18], which pruned weights to the GPU-supported N:M pattern [45]. AdaPrune first drops parameters according to their magnitude [46] and then reoptimizes the remaining weights to reconstruct the pre-compression calibration set output. This is similar to [16, 8] which also perform layer-wise reoptimization of the remaining weights. Follow-up work [10] noted that the results of AdaPrune can be improved further by performing more frequent pruning/optimization steps. Our algorithm pushes this idea to the limit, performing full reoptimization after every single pruned weight, while remaining computationally tractable. We further use a more sophisticated weight selection metric which incorporates second-order information. Finally, [10] also introduces global AdaPrune, a more expensive global optimization step applied on top of the layer-wise AdaPrune results, which can bring additional accuracy gains. This can also be applied to our pruned models.
44
+
45
+ Non-Uniform Compression. An orthogonal practical question is how to compress different layers to maximize accuracy under a given resource constraint, such as latency or energy consumption. Existing methods can be roughly categorized into search-based and solver-based approaches. The former, e.g. AMC [15] or HAQ [41], search for a layer-wise compression policy directly via, for example, reinforcement learning or genetic programming [43], whereas the latter, e.g. HAWQv3 [44] or AdaQuant [19], construct a relaxed version of the overall problem that is then solved exactly. We focus here on solver-based approaches, as they can rapidly adapt to different scenarios when combined with accurate independent layer-wise compression schemes; however, our techniques could be of interest for search-based methods as well. Concretely, we use the problem formulation of AdaQuant [19] to which we apply the DP algorithm of SPDY [10] to achieve fast solving times even with a large number of possible choices per layer.
46
+
47
+ # 3 Problem Definition and Background
48
+
49
+ The Layerwise Compression Problem. Following prior work on post-training compression, e.g. [31, 19], we define the problem as follows. Mathematically, we model a layer $\ell$ as a function $f _ { \ell } ( X _ { \ell } , W _ { \ell } )$ acting on inputs $X _ { \ell }$ , parametrized by weights $W _ { \ell }$ . The goal of layer-wise compression is to find a “compressed” version of $W _ { \ell }$ that performs as similarly as possible to the original weights. More formally, the compressed weights $\widehat { W } _ { \ell }$ should minimize the expected layer output change as measured by some loss $\mathcal { L }$ while at the same time satisfying a generic compression constraint, which we denote by ${ \mathcal { C } } ( \widehat { W } _ { \ell } ) > C$ , which will be customized depending on the compression type:
50
+
51
+ $$
52
+ \mathrm { a r g m i n } _ { \widehat { W } _ { \ell } } \quad \mathbb { E } _ { X _ { \ell } } \mathcal { L } \big ( f _ { \ell } ( X _ { \ell } , W _ { \ell } ) , f _ { \ell } ( X _ { \ell } , \widehat { W } _ { \ell } ) \big ) \quad \mathrm { s u b j e c t ~ t o } \quad \mathcal { C } ( \widehat { W } _ { \ell } ) > C .
53
+ $$
54
+
55
+ The expectation over the layer inputs $X _ { \ell }$ is usually approximated by taking the mean over a small set of $N$ input samples. This low-data setting is one of the primary applications of layer-wise compression. Further, most works [42, 31, 19] focus on compressing linear and convolutional layers, which can be unfolded into linear ones, as these are prevalent in practice, and use the squared loss to measure the approximation error. This definition of the loss can be motivated, via a sequence of approximations, from second-order information: please see [31] for a precise derivation. Furthermore, this approximation approach has been shown to work well in many applications [31, 19, 9].
56
+
57
+ We follow these conventions as well, and work with the specific layer-wise compression problem stated formally below, where the weights $\mathbf { W } _ { \ell }$ are a $d _ { \mathrm { r o w } } \times d _ { \mathrm { c o l } }$ matrix (for conv-layers $d _ { \mathrm { c o l } }$ corresponds to the total number of weights in a single filter), and the input $\mathbf { X } _ { \ell }$ has dimensions $d _ { \mathrm { c o l } } \times N$ .
58
+
59
+ $$
60
+ \operatorname { a r g m i n } _ { \widehat { \mathbf { W } } _ { \ell } } \quad | | \mathbf { W } _ { \ell } \mathbf { X } _ { \ell } - \widehat { \mathbf { W } } _ { \ell } \mathbf { X } _ { \ell } | | _ { 2 } ^ { 2 } \quad \mathrm { s . t . } \quad \mathcal { C } ( \widehat { \mathbf { W } } _ { \ell } ) > C .
61
+ $$
62
+
63
+ The Optimal Brain Surgeon (OBS) Framework. The OBS framework [23, 13] considers the problem of accurately pruning a trained dense neural network. It starts from the Taylor approximation at the given point (assumed to have negligible gradient), and provides explicit formulas for the optimal single weight to remove, as well as the optimal update of the remaining weights which would compensate for the removal. More precisely, let $\mathbf { H }$ denote the Hessian matrix of the loss at the given (dense) model. Then the weight to prune $w _ { p }$ which incurs the minimal increase in loss and the corresponding update of the remaining weights $\delta _ { p }$ can be calculated as follows:
64
+
65
+ $$
66
+ w _ { p } = \operatorname * { a r g m i n } _ { w _ { p } } \frac { w _ { p } ^ { 2 } } { [ \mathbf { H } ^ { - 1 } ] _ { p p } } , \quad \delta _ { p } = - \frac { w _ { p } } { [ \mathbf { H } ^ { - 1 } ] _ { p p } } \cdot \mathbf { H } _ { : , p } ^ { - 1 } ,
67
+ $$
68
+
69
+ where $[ \mathbf { H } ^ { - 1 } ] _ { p p }$ denotes the $p$ th diagonal entry of the inverse Hessian, and $\mathbf { H } _ { : , p } ^ { - 1 }$ is its $p$ th column.
70
+
71
+ OBS for Layer-Wise Pruning. We will now instantiate this framework for the layer-wise pruning problem, defined above. First, the loss in equation (2) is quadratic and since our starting point is given by the dense weights achieving the minimal loss of 0, the assumptions of the OBS framework are fully met, meaning that its formulas are exact for this specific problem formulation. Thus, iterating the OBS framework to remove one weight at a time would yield an exact greedy solution for the layer-wise pruning problem, as it takes the (locally) optimal decision at each step. While this greedy approach does not guarantee convergence to a global optimum, such approaches can be very effective for dealing with problem instances that are too large to be handled by exact methods.
72
+
73
+ # 4 An Optimal Greedy Solver for Sparsity
74
+
75
+ The obvious challenge is that applying the OBS framework in its true form, i.e. pruning a single weight at a time using the exact formulas in (3), is computationally very demanding. The Hessian $\mathbf { H }$ is a $d { \times } d$ matrix where $d = d _ { \mathrm { r o w } } \cdot d _ { \mathrm { c o l } }$ , which is already expensive to store and compute with. Additionally, this matrix needs to be updated and inverted at each of the $O ( d )$ steps with a computational complexity of $\Theta ( d ^ { 3 } )$ . Clearly, an $O ( d ^ { 4 } )$ total runtime is too inefficient for pruning most layers of modern neural networks, as $d$ is usually $\geq 1 0 ^ { 5 }$ or even $\geq 1 0 ^ { 6 }$ for several layers. However, as we will now show, it is actually possible to reduce the overall costs of this process to $O ( d _ { \mathrm { r o w } } \cdot d _ { \mathrm { c o l } } ^ { 3 } )$ time and $\Theta ( d _ { \mathrm { c o l } } ^ { 2 } )$ memory, making it efficient enough to prune e.g. all layers of a medium-sized model such as ResNet50 in a bit more than one hour on a single NVIDIA RTX 3090 GPU. We emphasize that the techniques we introduce are exact; unlike prior work [6, 39], we do not rely on any approximations.
76
+
77
+ The ExactOBS Algorithm. In the following, we introduce our efficient instantiation of the OBS framework, for the layer-wise compression problem, which we call ExactOBS, in step-by-step fashion. We start by rewriting the matrix squared error in (2) as the sum of the squared errors for each row in the weight matrix. As we are always dealing with a fixed layer $\ell .$ , we drop the subscript $\ell$ to simplify notation. The objective is then equivalent to $\begin{array} { r } { \sum _ { i = 1 } ^ { d _ { \mathrm { r o w } } } | | \mathbf { W } _ { \mathbf { i } , : } \mathbf { \widehat X } - \widehat { \mathbf { W } } _ { \mathbf { i } , : } \mathbf { X } | | _ { 2 } ^ { 2 } } \end{array}$ .
78
+
79
+ This way of writing the error makes it clear that removing a single weight $[ \mathbf { W } ] _ { i j }$ only affects the error of the corresponding output row $\mathbf { Y _ { i , : } } = \mathbf { W _ { i , : } } \mathbf { X }$ . Hence, there is no Hessian interaction between different rows and so it suffices to work only with the individual $d _ { \mathrm { c o l } } \times d _ { \mathrm { c o l } }$ Hessians corresponding to each of the $d _ { \mathrm { r o w } }$ rows. Further, as the dense layer output $\mathbf { Y } = \mathbf { W } \mathbf { X }$ is fixed, the objective for each row has standard least squares form and its Hessian is given by $\mathbf { H } = \mathbf { 2 } \mathbf { X } \mathbf { X } ^ { \top }$ .
80
+
81
+ Although this observation already reduces computational complexity, two key challenges remain: (a) applying OBS to each row still costs $O ( d _ { \mathrm { c o l } } \cdot \bar { d } _ { \mathrm { c o l } } ^ { 3 } )$ time, which is too slow for large layers, and (b) we need fast access to the Hessian inverses of all $d _ { \mathrm { r o w } }$ rows, since we want to prune the minimum score weight of the whole matrix rather than just per row in each step. In particular, (b) requires $O ( d _ { \mathrm { r o w } } \cdot \bar { d _ { \mathrm { c o l } } ^ { 2 } } )$ GPU memory, which is likely to be infeasible.
82
+
83
+ Step 1: Handling a Single Row. We first describe how to efficiently prune weights from a single row with $d _ { \mathrm { c o l } }$ parameters. For simplicity, we denote such a row by w with corresponding Hessian $\mathbf { H }$ . The full algorithm for this procedure is given in Algorithm 1; in the following, we provide a detailed description. The key idea is to avoid having to do the full $\Theta ( N \cdot d _ { \mathrm { c o l } } ^ { 2 } )$ calculation and $\Theta ( d _ { \mathrm { c o l } } ^ { 3 } )$ inversion of $\mathbf { H }$ in each step. The former is easy, as the weights themselves do not enter the calculation of $\mathbf { H } = 2 \mathbf { X } \mathbf { X } ^ { \top }$ , and the Hessian for the weights with pruning mask $M$ denoted by ${ \bf { H } } _ { M }$ is thus simply comprised of the corresponding rows and columns in the fully dense version $\mathbf { H }$ . Hence, we only have to compute $\mathbf { H }$ (which is actually the same for all rows) once, from which we can then extract the rows and columns corresponding to $M$ as needed.
84
+
85
+ Critically, this trick is not applicable to the inverse, as $( \mathbf { H } _ { M } ) ^ { - 1 } \neq ( \mathbf { H } ^ { - 1 } ) _ { M }$ . However, using the fact that the removal of one parameter $p$ simply drops the corresponding row and column from $\mathbf { H }$ , we can actually update the inverse to remove parameter $p$ directly using a single step of Gaussian elimination, with cost $\Theta ( d _ { c o l } ^ { 2 } )$ . The following result, whose proof is in the Appendix, formalizes this.
86
+
87
+ Lemma 1 (Row & Column Removal). Given an invertible $d _ { c o l } \times d _ { c o l }$ matrix $\mathbf { H }$ and its inverse ${ \bf H } ^ { - 1 }$ , we want to efficiently compute the inverse of $\mathbf { H }$ with row and column $p$ removed, which we denote by $\mathbf { H } _ { - p }$ . This can be accomplished through the following formula:
88
+
89
+ $$
90
+ { \bf H } _ { - p } ^ { - 1 } = \Big ( { \bf H } ^ { - 1 } - \frac { 1 } { [ { \bf H } ^ { - 1 } ] _ { p p } } { \bf H } _ { : , p } ^ { - 1 } { \bf H } _ { p , : } ^ { - 1 } \Big ) _ { - p } ,
91
+ $$
92
+
93
+ which corresponds to performing Gaussian elimination of row and column $p$ in ${ \bf H } ^ { - 1 }$ followed by dropping them completely. This has $\Theta ( d _ { c o l } ^ { 2 } )$ time complexity.
94
+
95
+ The resulting pseudocode is shown in Algorithm 1, where we avoid constantly resizing ${ \bf H } ^ { - 1 }$ (and correspondingly changing indices) by utilizing the fact that row and column $p$ have no effect on any future calculations after they have been eliminated by Lemma 1 as they are 0 (and the non-zero diagonal element is never accessed again). One can check that this algorithm applies OBS to a single row of W with a per-step cost of $\Theta ( \bar { d } _ { \mathrm { c o l } } ^ { 2 } )$ , and thus $\Theta ( k \cdot d _ { \mathrm { c o l } } ^ { 2 } )$ overall time for pruning $k$ weights.
96
+
97
+ <table><tr><td colspan="2">Algorithm1Prune k ≤ dcol weights from row w with inverse Hessian H-1 = (2XXT)-1 according to OBS in O(k · d²ol) time.</td><td rowspan="5"></td></tr><tr><td>M = {1,...,dco1} fori=1,...,k do</td><td></td></tr><tr><td>p ← argminp∈M 1 [H-1]</td><td></td></tr><tr><td>pp w←w-H-1 1 .Wp</td><td></td></tr><tr><td>:,p [H-1] pp H-1←H-1 1 H-11</td><td>H-1 p,</td></tr></table>
98
+
99
+ ![](images/420513c26a2b97b398b281b3e7ef3eb773ec0bd92c2b0cc71eac615d9769ed42.jpg)
100
+ Figure 1: Efficient global OBS using the rowwise results.
101
+
102
+ Step 2: Jointly Considering All Rows. Applying the OBS framework to the full weight matrix W rather than just to each row independently requires fast access to all $d _ { \mathrm { r o w } }$ row-wise inverse Hessians, in order to select the weight with the smallest overall pruning score in each step. However, storing $d _ { \mathrm { r o w } }$ matrices of size $d _ { \mathrm { c o l } } \times d _ { \mathrm { c o l } }$ each in GPU memory can be too expensive; while it would be possible to offload some Hessians to main memory, this could result in a large number of expensive memory transfers. However, since there is no Hessian interaction between rows, the final compressed weights of each row only depend on the total number of parameters that were pruned in it. Similarly, the change in loss incurred by pruning some weight only depends on the previously pruned weights in the same row, which also means that the order in which weights are pruned in each row is fixed.
103
+
104
+ The consequence of these insights is that we can process each row independently, pruning all weights in order while always recording the corresponding change in loss $\delta \bar { \mathcal { L } _ { p } } = w _ { p } ^ { 2 } \big / [ \bar { \mathbf { H } } ^ { - 1 } ] _ { p p }$ . At the end, we know $\delta { \mathcal { L } } _ { p }$ for all $d$ weights and can then simply determine the global mask that would be chosen by OBS on the full matrix by selecting the weights with the lowest values in order, requiring only $\Theta ( d )$ extra memory. We note that once the per-row masks $M _ { i }$ are known, we can directly solve for the optimal update of the remaining weights via the corresponding group OBS formula [21] $\delta _ { M _ { i } } = \bar { \mathbf { H } } _ { : , M _ { i } } ^ { - 1 } ( ( \bar { \mathbf { H } } ^ { - 1 } ) _ { M _ { i } } ) ^ { - 1 } \mathbf { w } _ { M _ { i } }$ . This will be considerably faster in practice than simply rerunning the iterative pruning process in Algorithm 1. Alternatively, if enough CPU memory is available, one can keep the full pruning trace of each row, that is, the full weight vector after every individual pruning step, in CPU memory and ultimately simply reload the entries corresponding to the global mask. This requires $O ( d _ { \mathrm { r o w } } \cdot d _ { \mathrm { c o l } } ^ { 2 } )$ extra CPU memory but avoids a second computation pass to reconstruct the not pruned weights and will therefore be faster. Figure 1 visualizes both options just discussed.
105
+
106
+ Implementation Details. In practice, the matrix $\mathbf { H }$ might not always be invertible for reasons such as using too few data samples or dead / linearly dependent inputs. The former can usually be addressed by extending the calibration dataset with augmentations (additional augmented samples only need to be accumulated into the Hessian once and are thus very cheap to include) and the latter can be prevented by adding a small diagonal dampening term to the Hessian before inverting it. Second, a direct GPU implementation of Algorithm 1 will perform a large number of small CUDA calls, which can be expensive. This overhead can be removed by using batch operations to process multiple matrix rows simultaneously—for more details please see our sample implementation. Finally, when applied to an already sparse weight matrix, the complexity of our algorithm can scale cubicly with the row-density by working with a dense version of the weights / Hessians consisting only of the non-zero elements and mapping the pruning result back at the end.
107
+
108
+ N:M Sparsity. Our method can be easily extended to various forms of semi-structured sparsity. This includes, for example, the N:M sparsity pattern [45], which enforces exactly $N$ non-zero values in each block of $M$ consecutive weights, and is becoming popular due to support on newer NVIDIA hardware [30]. Adapting our algorithm to this pattern requires only one simple change: instead of selecting the weight with the smallest change in loss, we select the weight with the smallest change in loss that is in a block with $< N$ pruned weights. We note that all rows have exactly the same sparsity $1 - N / M$ in the N:M pattern and so we can terminate per-row pruning as soon as this target sparsity value is reached. For the same reason, there is no need for the global mask selection step described earlier. Thus, our method will be even more efficient in this case.
109
+
110
+ Block-Sparsity. Another practically relevant pruning pattern, particularly in the context of CPU acceleration [7, 22], is block-pruning, where zeros appear only in consecutive blocks of size $c$ , which is typically a small number like 4 or 8. We follow recent work [21] that extends the OBS framework to pruning small groups of connected weights in order to account for the correlation between them, using the following formulas for the target block and weight update, respectively:
111
+
112
+ $$
113
+ \begin{array} { r } { { \bf w } _ { P } = \operatorname * { a r g m i n } _ { { \bf w } _ { P } } { \bf w } _ { P } ^ { \top } ( ( { \bf H } ^ { - 1 } ) _ { P } ) ^ { - 1 } { \bf w } _ { P } , \quad \delta _ { P } = - { \bf H } _ { : , P } ^ { - 1 } ( ( { \bf H } ^ { - 1 } ) _ { P } ) ^ { - 1 } { \bf w } _ { P } , } \end{array}
114
+ $$
115
+
116
+ where $P$ denotes the set of indices corresponding to one block. Algorithm 1 can easily be adapted to operate on blocks using the above equations and applying the update of ${ \bf H } ^ { - 1 }$ via Lemma 1 successively for all $p \in P$ . Although there are now only $d _ { c o l } / c$ steps per row, each update of ${ \bf H } ^ { - 1 }$ also takes ${ \dot { O } } ( c \cdot d _ { \mathrm { c o l } } ^ { 2 } )$ time and so the overall asymptotic runtime stays the same. Additional practical overhead only comes from the extra $O ( c ^ { 2 } \cdot d _ { \mathrm { c o l } } ^ { 2 } )$ terms that are the result of computing and multiplying with the $c \times c$ matrices $\big ( ( \mathbf { H } ^ { - 1 } \big ) _ { P } \big ) ^ { - 1 }$ .
117
+
118
+ # 5 The Optimal Brain Quantizer (OBQ)
119
+
120
+ Although the classical OBS framework [23, 13] has inspired a long line of work on pruning methods for DNNs [39, 10, 27], so far it has not been used for quantization. We now show that our results from the previous section can in fact be extended to quantization in an effective and accurate way, via a method which we call the Optimal Brain Quantizer (OBQ), in the spirit of [23, 13].
121
+
122
+ The Quantization Order and Update Derivations. Under the standard assumption that the gradient at the current point w is negligible, the OBS formulas for the optimal weight to be pruned $w _ { p }$ and the corresponding update $\delta _ { p }$ can be derived by writing the locally quadratic problem under the constraint that element $p$ of $\delta _ { p }$ is equal to $- w _ { p }$ , which means that $w _ { p }$ is zero after applying the update to w. This problem has the following Lagrangian:
123
+
124
+ $$
125
+ \begin{array} { r } { L ( \delta _ { p } , \lambda ) = \delta _ { \mathbf { p } } ^ { \top } \mathbf H \delta _ { p } + \lambda ( \mathbf e _ { \mathbf { p } } ^ { \top } \delta _ { p } - ( - w _ { p } ) ) , } \end{array}
126
+ $$
127
+
128
+ where $\mathbf { H }$ denotes the Hessian at w and $\mathbf { e _ { p } }$ is the pth canonical basis vector. The optimal solution is then derived by first finding the optimal solution to $\delta _ { p }$ via setting the derivative $\partial L / \partial \delta _ { p }$ to zero and then substituting this solution back into $L$ and solving for $\lambda$ ; please see e.g. [13, 39] for examples.
129
+
130
+ Assume a setting in which we are looking to quantize the weights in a layer on a fixed grid of width $\Delta$ while minimizing the loss. To map OBS to a quantized projection, we can set the target of the Lagrangian constraint in (6) to ( ${ \mathfrak { q u a n t } } ( w _ { p } ) - w _ { p } )$ , where quant $( w _ { p } )$ is the weight rounding given by quantization; then $w _ { p } = { \tt q u a n t } ( w _ { p } )$ after the update.
131
+
132
+ Assuming we wish to quantize weights iteratively, one-at-a-time, we can derive formulas for the “optimal” weight to quantize at a step, in terms of minimizing the loss increase, and for the corresponding optimal update to the unquantized weights, in similar fashion as discussed above:
133
+
134
+ $$
135
+ \begin{array} { r } { w _ { p } = \operatorname * { a r g m i n } _ { w _ { p } } \frac { ( \mathrm { q u a n t } ( w _ { p } ) - w _ { p } ) ^ { 2 } } { [ \mathbf { H } ^ { - 1 } ] _ { p p } } , \quad \delta _ { p } = - \frac { w _ { p } - \mathrm { q u a n t } ( w _ { p } ) } { [ \mathbf { H } ^ { - 1 } ] _ { p p } } \cdot \mathbf { H } _ { : , p } ^ { - 1 } . } \end{array}
136
+ $$
137
+
138
+ In fact, since $- w _ { p }$ is a constant during all derivations, we can just substitute it with $( \mathrm { q u a n t } ( w _ { p } ) - w _ { p } )$ in the final result. We note that the resulting formulas are a generalization of standard OBS for pruning, if quant $( \cdot )$ always “quantizes” a weight to 0, then we recover the original form.
139
+
140
+ Quantizing Full Layers. At first glance, OBQ might appear curious since one usually quantizes all weights in a layer, leaving no more weights to update. At the same time, the weight selection metric influences only the quantization order, but not the quantization value. However, this view changes when considering OBQ in the context of our efficient one-weight-at-a-time pruning algorithm described in the previous section. Specifically, using OBQ, we can greedily quantize the currently “easiest” weight by the above metric, and then adjust all the remaining unquantized weights to compensate for this loss of precision, thus changing their value. We then choose the next weight to quantize, and so on. This can result in quantization assignments that are different from the ones that would have been chosen by rounding initially, and in better overall quantization results. Concretely, to realize this, we can plug (7) into Algorithm 1 in order to iteratively quantize weights for a given layer, leading to the similar Algorithm in the Appendix, thus essentially unifying pruning and quantization.
141
+
142
+ Quantization Outliers. One practical issue with this greedy scheme can occur especially when applied to quantization grids that permit some outliers in order to achieve a lower error on the majority of weights, which are currently standard [4, 34]. Since these outliers can have high quantization error, they will usually be quantized last, when there are only few other unquantized weights available that may be adjusted to compensate for the large error incurred by quantizing the outliers. This effect can become worse when some weights are pushed even further outside the grid by intermediate updates. We prevent this with a simple but effective heuristic: we quantize outliers, e.g. weights with a quantization error $> \Delta / 2$ where $\Delta$ is the distance between quantized values, as soon as they appear (which typically happens only a few times per layer). With this heuristic, OBQ yields a highly effective layer-wise quantization scheme, as our experiments in the next section demonstrate. Finally, we note that the OBQ version of the techniques discussed in Section 4 has all the same runtime and memory characteristics (barring the global step in Figure 1, which is unnecessary for quantization).
143
+
144
+ # 6 Experiments
145
+
146
+ Objectives, Models & Datasets. To demonstrate the effectiveness and flexibility of our method, we consider several different standard post-training compression scenarios [31, 19, 18]. We begin with settings where only a single type of compression is applied: concretely, we consider unstructured pruning for given FLOP targets, global 2:4 and 4:8 pruning, as well as uniform weight quantization. Additionally, we also study two practical tasks that feature joint pruning and quantization: a GPU scenario where quantization and N:M pruning are combined, as well as a CPU scenario combining quantization and block pruning. We work with variants of the following models and tasks: ResNet [14] for image classification on Imagenet [38], YOLOv5 [20] for object detection on COCO [26] and BERT [5] for question answering on SQuAD [36]. Our smaller BERT models denoted by BERT3 and BERT6 correspond to the smaller 3 and 6 layer variants of BERT-base, respectively, trained by [21]. The Appendix contains additional experiments as well as runtime information of our algorithms.
147
+
148
+ Experimental Setup. All of our calibration datasets consist of 1024 random training samples. For ImageNet, where we use roughly $0 . 1 \%$ of the training data, we additionally apply standard flipping and cropping augmentations to artificially increase the size of this dataset by $1 0 \times$ ; other tasks do not use any augmentations. While the effect of augmentations is typically minor, they are very cheap to include for our method. For ResNet models, batchnorm statistics are reset using 100 batches of 128 samples from the calibration set with standard augmentations. For other models, we apply mean and variance correction [32, 1] after all normalization layers (so that the correction parameters can be easily merged and incur no extra cost) on a single batch of samples of size 128 (for YOLO) and 512 (for BERT). We found this to be more effective than batchnorm tuning for YOLO, and the BERT models have no batchnorm layers.
149
+
150
+ When compressing to a given FLOP or timing constraint, we need to solve the problem of identifying per-layer compression targets, which match the constraint, while maximizing accuracy. To identify these non-uniform targets, we follow the approach of [10]: we first collect a “model database” containing for each compression level (e.g. bit-width or sparsity setting) the corresponding (independently) compressed version of each layer. For building a joint sparse and quantized database we simply sparsify layers first and then apply quantization to the remaining weights. Next, similarly to [19], we compute the layer-wise calibration losses (without augmentations) for all compression levels, corresponding to the models with exactly one layer compressed to a certain level. Then, given layer-wise FLOP or timing information, we set up a constrained layer-wise compression problem of the form described in AdaQuant [19] and solve it with the dynamic programming algorithm of SPDY [10]. This returns an optimal per-layer assignment of compression levels, for which we can then easily produce the corresponding model, via a two-step process: we first stitch together layers at the corresponding compression levels from the database, and then perform the discussed statistics correction to recover some extra accuracy [19].
151
+
152
+ Unstructured Sparsity. We begin our experiments with unstructured sparsity, comparing against global magnitude pruning (GMP) [46], the approximate layer-wise OBS method L-OBS [6], and the post-training pruning state-of-the-art method AdaPrune [18]. As a sanity check, we examine in Figure 2 whether our method provides better results in terms of layer-wise squared error, pruning the first layer of a ResNet18 (RN18) model to several sparsities. In this metric, ExactOBS performs best by a wide margin ahead of AdaPrune, which significantly outperforms the other two methods.
153
+
154
+ Next, in Table 1, we turn our attention to the practical problem of pruning various models to achieve a given FLOP reduction of $2 \times - 4 \times$ , applying the per-layer target sparsity optimization technique described above. Our ExactOBS generally performs best (except for YOLOv5l $2 \times$ where all methods perform similarly in terms of mAP $@ 0 . 5$ ) and at $4 \times$ FLOP reduction even with a $> 1 \%$ gap to the next best method. Interestingly, on the hard-to-prune BERT model, ExactOBS appears to be the only method which still produces reasonable results at higher reduction targets. For BERT $3 \times$ and $4 \times$ , where the performance drop of all methods is $> 2 \%$ , we additionally assess the compatibility of our results with the more powerful (but also more expensive) post processing method global AdaPrune [10]. While this global optimization technique is able to recover lost accuracy, the ExactOBS models still maintain $a > 0 . { \bar { 5 } } \%$ and $> 2 \%$ F1 advantage, respectively (see Table 5).
155
+
156
+ N:M Sparsity. Next, we study the performance of our method for semi-structured sparsity via the N:M pattern. Specifically, we compare against the 4:8 results of AdaPrune with batchnorm tuning [18] on ResNet models (see Table 2) in addition to a 2:4 comparison on BERT models (see Table 3). We highlight that ExactOBS matches or even slightly exceeds the 4:8 results of AdaPrune with the considerably more stringent 2:4 pattern, which is already well supported on NVIDIA hardware. Furthermore, in a 2:4 comparison on BERT models, ExactOBS achieves $1 { - } 2 \%$ higher F1 scores.
157
+
158
+ ![](images/e63c4464a79a22fecd310d811360589f3a30affa49cccf71cee521d9e2137d65.jpg)
159
+
160
+ Table 1: Unstructured pruning for different FLOP reduction targets.
161
+
162
+ <table><tr><td rowspan="2">Method</td><td colspan="3">ResNet50 -76.13</td><td colspan="3">YOLOv5l-66.97</td><td colspan="3">BERT-88.53</td></tr><tr><td>2×</td><td>3×</td><td>4×</td><td>2×</td><td>3×</td><td>4×</td><td>2×</td><td>3×</td><td>4×</td></tr><tr><td>GMP</td><td>74.86</td><td>71.44</td><td>64.84</td><td>65.83</td><td>62.30</td><td>55.09</td><td>65.64</td><td>12.52</td><td>09.23</td></tr><tr><td>L-OBS</td><td>75.48</td><td>73.73</td><td>71.24</td><td>66.21</td><td>64.47</td><td>61.15</td><td>77.67</td><td>3.62</td><td>6.63</td></tr><tr><td>AdaPrune</td><td>75.53</td><td>74.47</td><td>72.39</td><td>66.00</td><td>64.88</td><td>62.71</td><td>87.12</td><td>70.32</td><td>18.75</td></tr><tr><td>ExactOBS</td><td>75.64</td><td>75.01</td><td>74.05</td><td>66.14</td><td>65.35</td><td>64.05</td><td>87.81</td><td>85.87</td><td>82.10</td></tr></table>
163
+
164
+ Figure 2: RN18 squared error.
165
+ Table 2: Semi-structured N:M pruning ( $^ +$ batchnorm tuning) of all layers except the first and the last.
166
+
167
+ <table><tr><td>Model</td><td>Dense</td><td>AdaPrune 4:8</td><td colspan="2">ExactOBS 2:4 4:8</td></tr><tr><td>ResNet18</td><td>69.76</td><td>68.63</td><td>68.81</td><td>69.18</td></tr><tr><td>ResNet34</td><td>73.31</td><td>72.36</td><td>72.66</td><td>72.95</td></tr><tr><td>ResNet50</td><td>76.13</td><td>74.75</td><td>74.71</td><td>75.20</td></tr></table>
168
+
169
+ Table 3: Semi-structured 2:4 pruning of all layers except the embeddings.
170
+
171
+ <table><tr><td>Model</td><td>Dense</td><td>AdaPrune</td><td>ExactOBS</td></tr><tr><td>BERT3</td><td>84.66</td><td>82.75</td><td>83.54</td></tr><tr><td>BERT6</td><td>88.33</td><td>85.02</td><td>86.97</td></tr><tr><td>BERT</td><td>88.53</td><td>85.24</td><td>86.77</td></tr></table>
172
+
173
+ Quantization. Additionally, we compare OBQ’s independent performance (after batchnorm tuning) with the state-of-the-art sequential post-training methods AdaQuant [19], AdaRound [31] and BRECQ [24]. We perform standard asymmetric per-channel quantization of all weights, using the authors’ implementations. We rerun all methods on Torchvision [28] ResNets to ensure a uniform baseline. The quantization grids for OBQ as well as AdaRound are determined with the same LAPQ [34] procedure that is used by BRECQ. Surprisingly, we find that, despite optimizing layers independently, OBQ achieves very similar (sometimes even slightly better) accuracies as existing non-independent methods for 4 and 3 bits. This suggests that it should be well-suited for mixed precision applications where one needs to quickly generate many non-uniform models optimized for different constraints. (However, we note that ExactOBS can also be applied sequentially; see Appendix.)
174
+
175
+ Table 5: Further improving results in Table 1 with $5 \ 3 \%$ performance drops through more expensive post-processing via global AdaPrune (gAP).
176
+
177
+ <table><tr><td>Methods</td><td colspan="2">BERT 3× 4×</td></tr><tr><td>gAP + AdaPrune</td><td>86.99</td><td>84.10</td></tr><tr><td>gAP +ExactOBS</td><td>87.57</td><td>86.42</td></tr></table>
178
+
179
+ Table 4: Comparison with state-of-the-art post-training methods for asymmetric per-channel weight quantization of all layers. We mark whether methods are Layer-wise (Lw.) or Independent (Ind.).
180
+
181
+ <table><tr><td rowspan="2">Method</td><td rowspan="2">Lw.</td><td rowspan="2">Ind.</td><td colspan="3">ResNet18-69.76</td><td colspan="3">ResNet50-76.13</td></tr><tr><td>4bit</td><td>3bit</td><td>2bit</td><td>4bit</td><td>3bit</td><td>2bit</td></tr><tr><td rowspan="3">AdaRound AdaQuant BRECQ</td><td>yes</td><td>no</td><td>69.34</td><td>68.37</td><td>63.37</td><td>75.84</td><td>75.14</td><td>71.58</td></tr><tr><td>yes</td><td>no</td><td>68.12</td><td>59.21</td><td>00.10</td><td>74.68</td><td>64.98</td><td>00.10</td></tr><tr><td>no</td><td>no</td><td>69.37</td><td>68.47</td><td>64.70</td><td>75.88</td><td>75.32</td><td>72.41</td></tr><tr><td rowspan="2">OBQ(ours)</td><td>yes</td><td>yes</td><td>69.56</td><td>68.69</td><td>64.04</td><td>75.72</td><td>75.24</td><td>70.71</td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr></table>
182
+
183
+ BOP-Constrained Mixed GPU Compression. We now consider a practical setting where we are given a trained model together with some calibration data and want to compress this model for efficient inference on an NVIDIA GPU which supports 8-bit and 4-bit arithmetic, also in combination with 2:4 sparsity. Thus, there are 4 possible compression choices per layer: 8bit weights $+ ~ 8 \mathrm { b i t }$ activations (8w8a), 4w4a, $8 \mathrm { w } 8 \mathrm { a } + 2 { : } 4$ and $4 \mathrm { w } 4 \mathrm { a } + 2 { : } 4$ . Unlike in the previous section, we do symmetric per-channel quantization of the weights as it has better hardware support; activations are quantized asymmetrically per-tensor. We then generate mixed precision configurations for various BOP (number of bits times FLOPs) reduction targets and visualize the resulting compression-accuracy trade-off curves in Figure 3. In summary, at the cost of a $\approx 2 . 5 \%$ relative performance drop, we can achieve a $1 2 - 1 4 \times$ BOP reduction for ResNets and a $7 - 8 \times$ reduction for the more challenging YOLO and BERT models (relative to the compute in compressible layers). To the best of our knowledge, we are the first to consider joint N:M pruning and quantization in a post-training setting. Recent work [3] also studies joint $4 \mathrm { w } 4 \mathrm { a } + 2 { : } 4$ compression for ResNet18 but with 90 epochs of (sparse) Quantization-Aware Training (QAT) on the full dataset and report $6 7 . 3 3 \%$ accuracy. Although not perfectly comparable (we keep the first layer dense and their dense baseline has $0 . 9 4 \%$ higher accuracy and uses 4:8 sparse activations), we achieve similar $6 7 . 2 0 \%$ accuracy for $4 \mathrm { w } 4 \mathrm { a } + 2 { : } 4$ post training, which emphasizes the effectiveness of our methods for joint sparsification and quantization.
184
+
185
+ Time-Constrained CPU Compression. Lastly, we explore a similar scenario, but targeting actual CPU inference speedup on a 12-core Intel Xeon Silver 4214 CPU using the DeepSparse inference engine [35, 22], which provides acceleration for joint 8-bit quantization and block-sparsity with blocksize 4. In this case, we work with real layer-wise timing data (for batchsize 64), as in [9]. There are 30 available block-sparsity targets per-layer, in steps of pruning $10 \%$ of the remaining weights, all of which are further quantized to 8 bits. The base acceleration of the dense 8 bit model is $\approx 2 . 7 \times$ on top of which sparsity speedup acts roughly multiplicatively. Figure 2d shows results for ResNet50 and several (real-time) speedup targets—we achieve $4 \times$ and $5 \times$ (actual) speedup with $1 \%$ and $2 \%$ accuracy loss, respectively. These are the first full post-training results in this setting (the authors of [10] only performed 4-block pruning post-training, followed by 5 epochs of QAT on the entire ImageNet dataset), and they show very encouraging accuracy-speedup trade-offs.
186
+
187
+ ![](images/48b7ae4ee49d35553186d141fe1a71bab7edce99ae5239859f187d9fe93726c1.jpg)
188
+ Mixed quantization pruning
189
+ Mixed quantization pruning
190
+ Figure 3: (a) to (c) Mixed quantization and 2:4 pruning for various BOP reduction targets. (d) Joint block-pruning and quantization for CPU inference time speedups.
191
+
192
+ # 7 Conclusions & Future Work
193
+
194
+ We have presented a new efficient and accurate approach for solving the layer-wise compression problem, and built on it to obtain state-of-the-art post-training compression solutions for both pruning and quantization. Our framework should be naturally extensible to structured pruning, which in fact should allow for further optimizations, and should also be compatible with further compression via unstructured pruning and quantization. Our results suggest that post-training compression may be able to reach comparable accuracies to much more expensive retraining methods. We plan to investigate this in future work, in particular in the context of more resource-intensive models, such as very large-scale language models.
195
+
196
+ # 8 Acknowledgements
197
+
198
+ We gratefully acknowledge funding from the European Research Council (ERC) under the European Union’s Horizon 2020 programme (grant agreement No 805223 ScaleML), as well as computational support from AWS EC2. We thank Eldar Kurtic for providing us BERT code and pretrained models, and the Neural Magic Team, notably Michael Goin and Mark Kurtz, for support with their software.
199
+
200
+ References
201
+ [1] Ron Banner, Yury Nahshan, and Daniel Soudry. Post training 4-bit quantization of convolutional networks for rapid-deployment. In Conference on Neural Information Processing Systems (NeurIPS), 2019.
202
+ [2] Thomas Blumensath and Mike E Davies. Iterative thresholding for sparse approximations. Journal of Fourier Analysis and Applications, 14(5-6):629–654, 2008.
203
+ [3] Brian Chmiel, Itay Hubara, Ron Banner, and Daniel Soudry. Optimal fine-grained N:M sparsity for activations and neural gradients. arXiv preprint arXiv:2203.10991, 2022.
204
+ [4] Yoni Choukroun, Eli Kravchik, Fan Yang, and Pavel Kisilev. Low-bit quantization of neural networks for efficient inference. In International Conference on Computer Vision Workshop (ICCVW), 2019.
205
+ [5] Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. BERT: Pre-training of deep bidirectional transformers for language understanding. In North American Chapter of the Association for Computational Linguistics (NAACL), 2019.
206
+ [6] Xin Dong, Shangyu Chen, and Sinno Jialin Pan. Learning to prune deep neural networks via layer-wise optimal brain surgeon. In Conference on Neural Information Processing Systems (NeurIPS), 2017.
207
+ [7] Erich Elsen, Marat Dukhan, Trevor Gale, and Karen Simonyan. Fast sparse convnets. In Conference on Computer Vision and Pattern Recognition (CVPR), 2020.
208
+ [8] Utku Evci, Nicolas Le Roux, Pablo Castro, and Leon Bottou. Mean replacement pruning. 2018.
209
+ [9] Elias Frantar and Dan Alistarh. SPDY: Accurate pruning with speedup guarantees. arXiv preprint arXiv:2201.13096, 2022.
210
+ [10] Elias Frantar, Eldar Kurtic, and Dan Alistarh. M-FAC: Efficient matrix-free approximations of second-order information. In Conference on Neural Information Processing Systems (NeurIPS), 2021.
211
+ [11] Amir Gholami, Sehoon Kim, Zhen Dong, Zhewei Yao, Michael W Mahoney, and Kurt Keutzer. A survey of quantization methods for efficient neural network inference. arXiv preprint arXiv:2103.13630, 2021.
212
+ [12] Roger Grosse and James Martens. A Kronecker-factored approximate Fisher matrix for convolution layers. In International Conference on Machine Learning (ICML), 2016.
213
+ [13] Babak Hassibi, David G Stork, and Gregory J Wolff. Optimal brain surgeon and general network pruning. In IEEE International Conference on Neural Networks, 1993.
214
+ [14] Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. In Conference on Computer Vision and Pattern Recognition (CVPR), 2016.
215
+ [15] Yihui He, Ji Lin, Zhijian Liu, Hanrui Wang, Li-Jia Li, and Song Han. AMC: AutoML for model compression and acceleration on mobile devices. In European Conference on Computer Vision (ECCV), 2018.
216
+ [16] Yihui He, Xiangyu Zhang, and Jian Sun. Channel pruning for accelerating very deep neural networks. In International Conference on Computer Vision (ICCV), 2017.
217
+ [17] Torsten Hoefler, Dan Alistarh, Tal Ben-Nun, Nikoli Dryden, and Alexandra Peste. Sparsity in deep learning: Pruning and growth for efficient inference and training in neural networks. arXiv preprint arXiv:2102.00554, 2021.
218
+ [18] Itay Hubara, Brian Chmiel, Moshe Island, Ron Banner, Seffi Naor, and Daniel Soudry. Accelerated sparse neural training: A provable and efficient method to find N:M transposable masks. In Conference on Neural Information Processing Systems (NeurIPS), 2021.
219
+
220
+ [19] Itay Hubara, Yury Nahshan, Yair Hanani, Ron Banner, and Daniel Soudry. Accurate post training quantization with small calibration sets. In International Conference on Machine Learning (ICML), 2021.
221
+
222
+ [20] Glenn Jocher. YOLOv5. https://github.com/ultralytics/yolov5, 2022.
223
+ [21] Eldar Kurtic, Daniel Campos, Tuan Nguyen, Elias Frantar, Mark Kurtz, Benjamin Fineran, Michael Goin, and Dan Alistarh. The Optimal BERT Surgeon: Scalable and accurate secondorder pruning for large language models. arXiv preprint arXiv:2203.07259, 2022.
224
+ [22] Mark Kurtz, Justin Kopinsky, Rati Gelashvili, Alexander Matveev, John Carr, Michael Goin, William Leiserson, Sage Moore, Bill Nell, Nir Shavit, and Dan Alistarh. Inducing and exploiting activation sparsity for fast inference on deep neural networks. In International Conference on Machine Learning (ICML), 2020.
225
+ [23] Yann LeCun, John S Denker, and Sara A Solla. Optimal brain damage. In Conference on Neural Information Processing Systems (NeurIPS), 1990.
226
+ [24] Yuhang Li, Ruihao Gong, Xu Tan, Yang Yang, Peng Hu, Qi Zhang, Fengwei Yu, Wei Wang, and Shi Gu. BRECQ: Pushing the limit of post-training quantization by block reconstruction. In International Conference on Learning Representations (ICLR), 2021.
227
+ [25] Tailin Liang, John Glossner, Lei Wang, Shaobo Shi, and Xiaotong Zhang. Pruning and quantization for deep neural network acceleration: A survey. Neurocomputing, 461:370–403, 2021.
228
+ [26] 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 European Conference on Computer Vision (ECCV), 2014.
229
+ [27] Liyang Liu, Shilong Zhang, Zhanghui Kuang, Aojun Zhou, Jing-Hao Xue, Xinjiang Wang, Yimin Chen, Wenming Yang, Qingmin Liao, and Wayne Zhang. Group fisher pruning for practical network compression. In International Conference on Machine Learning (ICML), 2021.
230
+ [28] Sébastien Marcel and Yann Rodriguez. Torchvision the machine-vision package of torch. In ACM International Conference on Multimedia, 2010.
231
+ [29] James Martens and Roger Grosse. Optimizing neural networks with kronecker-factored approximate curvature. In International Conference on Machine Learning (ICML), 2015.
232
+ [30] Asit Mishra, Jorge Albericio Latorre, Jeff Pool, Darko Stosic, Dusan Stosic, Ganesh Venkatesh, Chong Yu, and Paulius Micikevicius. Accelerating sparse deep neural networks. arXiv preprint arXiv:2104.08378, 2021.
233
+ [31] Markus Nagel, Rana Ali Amjad, Mart Van Baalen, Christos Louizos, and Tijmen Blankevoort. Up or down? Adaptive rounding for post-training quantization. In International Conference on Machine Learning (ICML), 2020.
234
+ [32] Markus Nagel, Mart van Baalen, Tijmen Blankevoort, and Max Welling. Data-free quantization through weight equalization and bias correction. In International Conference on Computer Vision (ICCV), 2019.
235
+ [33] Markus Nagel, Marios Fournarakis, Rana Ali Amjad, Yelysei Bondarenko, Mart van Baalen, and Tijmen Blankevoort. A white paper on neural network quantization. arXiv preprint arXiv:2106.08295, 2021.
236
+ [34] Yury Nahshan, Brian Chmiel, Chaim Baskin, Evgenii Zheltonozhskii, Ron Banner, Alex M Bronstein, and Avi Mendelson. Loss aware post-training quantization. Machine Learning, 110(11):3245–3262, 2021.
237
+ [35] NeuralMagic. The DeepSparse Inference Engine. https://github.com/neuralmagic/deepsparse, 2022.
238
+ [36] Pranav Rajpurkar, Jian Zhang, Konstantin Lopyrev, and Percy Liang. SQuAD: $^ { 1 0 0 , 0 0 0 + }$ questions for machine comprehension of text. In Conference on Empirical Methods in Natural Language Processing (EMNLP), 2016.
239
+ [37] Vijay Janapa Reddi, Christine Cheng, David Kanter, Peter Mattson, Guenther Schmuelling, Carole-Jean Wu, Brian Anderson, Maximilien Breughe, Mark Charlebois, William Chou, et al. Mlperf inference benchmark. In 2020 ACM/IEEE 47th Annual International Symposium on Computer Architecture (ISCA), pages 446–459. IEEE, 2020.
240
+ [38] 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.
241
+ [39] Sidak Pal Singh and Dan Alistarh. WoodFisher: Efficient second-order approximation for neural network compression. In Conference on Neural Information Processing Systems (NeurIPS), 2020.
242
+ [40] Chaoqi Wang, Roger Grosse, Sanja Fidler, and Guodong Zhang. Eigendamage: Structured pruning in the Kronecker-factored eigenbasis. In International Conference on Machine Learning (ICML), 2019.
243
+ [41] Kuan Wang, Zhijian Liu, Yujun Lin, Ji Lin, and Song Han. HAQ: Hardware-aware automated quantization with mixed precision. In Conference on Computer Vision and Pattern Recognition (CVPR), 2019.
244
+ [42] Peisong Wang, Qiang Chen, Xiangyu He, and Jian Cheng. Towards accurate post-training network quantization via bit-split and stitching. In International Conference on Machine Learning (ICML), 2020.
245
+ [43] Haichuan Yang, Shupeng Gui, Yuhao Zhu, and Ji Liu. Automatic neural network compression by sparsity-quantization joint learning: A constrained optimization-based approach. In Conference on Computer Vision and Pattern Recognition (CVPR), 2020.
246
+ [44] Zhewei Yao, Zhen Dong, Zhangcheng Zheng, Amir Gholami, Jiali Yu, Eric Tan, Leyuan Wang, Qijing Huang, Yida Wang, Michael Mahoney, et al. HAWQ-v3: Dyadic neural network quantization. In International Conference on Machine Learning (ICML), 2021.
247
+ [45] Aojun Zhou, Yukun Ma, Junnan Zhu, Jianbo Liu, Zhijie Zhang, Kun Yuan, Wenxiu Sun, and Hongsheng Li. Learning N:M fine-grained structured sparse neural networks from scratch. In International Conference on Learning Representations (ICLR), 2021.
248
+ [46] Michael Zhu and Suyog Gupta. To prune, or not to prune: exploring the efficacy of pruning for model compression. arXiv preprint arXiv:1710.01878, 2017.
249
+
250
+ # Checklist
251
+
252
+ 1. For all authors...
253
+
254
+ (a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes]
255
+ (b) Did you describe the limitations of your work? [Yes]
256
+ (c) Did you discuss any potential negative societal impacts of your work? [N/A]
257
+ (d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
258
+
259
+ 2. If you are including theoretical results...
260
+
261
+ (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]
262
+
263
+ 3. If you ran experiments...
264
+
265
+ (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]
266
+ (b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes]
267
+ (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [Yes]
268
+ (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]
269
+
270
+ 4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
271
+
272
+ (a) If your work uses existing assets, did you cite the creators? [Yes]
273
+ (b) Did you mention the license of the assets? [N/A]
274
+ (c) Did you include any new assets either in the supplemental material or as a URL? [No] Assets are open-source with standard permissive licenses.
275
+ (d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [N/A]
276
+ (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [N/A]
277
+
278
+ 5. If you used crowdsourcing or conducted research with human subjects...
279
+
280
+ (a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A]
281
+ (b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A]
282
+ (c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]
md/dev/nXmU89Rfmgg/nXmU89Rfmgg.md ADDED
@@ -0,0 +1,303 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # FEW-SHOT INCREMENTAL LEARNING USING HYPERTRANSFORMERS
2
+
3
+ Anonymous authors Paper under double-blind review
4
+
5
+ # ABSTRACT
6
+
7
+ Incremental few-shot learning methods make it possible to learn without forgetting from multiple few-shot tasks arriving sequentially. In this work we approach this problem using the recently published HyperTransformer (HT): a hypernetwork that generates task-specific CNN weights directly from the support set. We propose to re-use these generated weights as an input to the HT for the next task of the continual-learning sequence. Thus, the HT uses the weights themselves as the representation of the previously learned tasks. This approach is different from most continual learning algorithms that typically rely on using replay buffers, weight regularization or task-dependent architectural changes. Instead, we show that the HT works akin to a recurrent model, relying on the weights from the previous task and a support set from a new task. We demonstrate that a single HT equipped with a prototypical loss is capable of learning and retaining knowledge about past tasks for two continual learning scenarios: incremental-task learning and incremental-class learning.
8
+
9
+ # 1 INTRODUCTION
10
+
11
+ Incremental few-shot learning combines the challenges of both few-shot learning and continual learning together: it seeks a way to learn from very limited demonstrations presented continually to the learner. This combination is desirable since it represents a more genuine model of how biological systems including humans acquire new knowledge: we often do not need a large amount of information to learn a novel concept and after learning about it we retain that knowledge for a long time. In addition, achieving this would dramatically simplify learning of important practical applications, such as robots continually adapting to a novel environment layout from an incoming stream of demonstrations. Another example is privacy-preserving learning, where users run the model sequentially on their private data, sharing only the weights that are continually absorbing the data without ever exposing it.
12
+
13
+ We focus on a recently published few-shot learning method called HYPERTRANSFORMER (HT; Zhmoginov et al. 2022), which trains a large hypernetwork (Ha et al., 2016) by extracting knowledge from a set of training few-shot learning tasks. The HT is then able to directly generate weights of a much smaller Convolutional Neural Network (CNN) model focused on solving a particular task from just a few examples provided in the support set. It works by decoupling the task-domain knowledge (represented by a transformer; Vaswani et al. 2017) from the learner itself (a CNN), which only needs to know about the specific task that is being solved.
14
+
15
+ In this paper, we propose an INCREMENTAL HYPERTRANSFORMER (IHT) aimed at exploring the capability of the HT to update the CNN weights with information about new tasks, while retaining the knowledge about previously learned tasks. In other words, given the weights $\theta _ { t - 1 }$ generated after seeing some previous tasks $\{ \tau \} _ { \tau = 0 } ^ { t - 1 }$ and a new task $t$ , the IHT generates the weights $\theta _ { t }$ that are suited for all the tasks $\{ \tau \} _ { \tau = 0 } ^ { t }$ .
16
+
17
+ In order for the IHT to be able to absorb a continual stream of tasks, we modified the loss function from a cross-entropy that was used in the HT to a more flexible prototypical loss (Snell et al., 2017). As the tasks come along, we maintain and update a set of prototypes in the embedding space, one for each class of any given task. The prototypes are then used to predict the class and task attributes for a given input sample.
18
+
19
+ ![](images/cefcb0d2fe25a3dc0ca901fde957547cac00162199f40f04e2e2ba3b9c958af8.jpg)
20
+ Figure 1: The information flow of the IHT. In the original HT each of the input weight embeddings are initialized with an empty weight slice. Our proposal is to pass weight slice information from previously learned tasks as an input to the new iteration of the HT.
21
+
22
+ The IHT works in two different continual learning scenarios: task-incremental learning (predict class attribute using the task information) and class-incremental learning (predict both class and task attributes). Moreover, we show empirically that a model trained with the class-incremental learning objective is also suited for the task-incremental learning with performance comparable to the models specifically trained with a task-incremental objective.
23
+
24
+ We demonstrate that models learned by the IHT do not suffer from catastrophic forgetting. Moreover, in some smaller models we even see cases of positive backward transfer, where the performance on a given task actually improves for subsequently generated weights.
25
+
26
+ Since the IHT is trained to optimize all the generated weights $\{ \theta _ { \tau } \} _ { \tau = 0 } ^ { T }$ together, the model can be preempted at any point $\tau \leq T$ during the inference with weights $\theta _ { \tau }$ suited for any task $0 \leq p \leq \tau$ . Moreover, we show that the performance of the model improves for all the generated weights when the IHT is trained on more tasks $T$ . We also designed the IHT to work as a recurrent system and its parameters are independent from a given step. Therefore, it can be continued and applied beyond the number of tasks $T$ it was trained for.
27
+
28
+ # 2 RELATED WORK
29
+
30
+ Few-shot learning Many of few-shot learning methods fall into one of two categories: metricbased learning and optimization-based learning. First, metric-based learning methods (Vinyals et al., 2016; Snell et al., 2017; Sung et al., 2018; Oreshkin et al., 2018) train a fixed embedding network that works universally for any task. The prediction is then based on the distances between the labeled and query samples in that embedding space. These methods are not specifically tailored for the continual learning problem, since they treat every task independently and have no memory of the past tasks. In contrast to this method, our proposed IHT can be seen as an “adaptive” metric-based learner, where the weights $\theta _ { t }$ are changing to adapt better to the task $t$ and retain the knowledge of the past tasks.
31
+
32
+ Second, optimization-based methods (Finn et al., 2017; Nichol & Schulman, 2018; Antoniou et al., 2019; Rusu et al., 2019) consisting of variations of a seminal MAML paper propose to learn an initial fixed embedding, that is later adapted to a given task using few gradient-based steps. All by themselves these methods are not able to learn continually, since naively adapting for a new task will result in a catastrophic forgetting of the previously learned information.
33
+
34
+ Continual learning. We believe that compared to the related work (see Biesialska et al. 2020 for an overview), our approach requires the least conceptual overhead, since it does not add additional constraints to the method beyond the weights generated from the previous task. In particular, we do not inject replay data from past tasks (Lopez-Paz & Ranzato, 2017; Riemer et al., 2018; Rolnick et al., 2019; Wang et al., 2021a), do not explicitly regularize the weights (Kirkpatrick et al., 2017; Zenke et al., 2017) and do not introduce complex graph structures (Tao et al., 2020; Zhang et al., 2021), data routing or any other architectural changes to the inference model (Rusu et al., 2016). Instead, we reuse the same principle that made HYPERTRANSFORMER work in the first place: decouple a small CNN classification model re-generated for each incoming task from a large Transformer model that generates CNN weights, in effect learning how to adapt them to a new incoming task in a way that avoids forgetting prior knowledge. In this regard, the closest analogy to our approach would be slow and fast weights (Munkhdalai & Yu, 2017), with the IHT weights being analogous to the slow weights that accumulate the knowledge and generate CNN weights as fast weights.
35
+
36
+ ![](images/a72441dad22edef9d0216f6d269bd4fbec8603c35239b005c6c67ca849dad420.jpg)
37
+ Figure 2: The diagram of few-shot continual learning with INCREMENTAL HYPERTRANSFORMER. For each new task $t$ , the IHT uses the support set $\mathbf { \check { \boldsymbol { S } } } ^ { ( t ) }$ and previously generated weights $\theta _ { t - 1 }$ to generate new weights $\theta _ { t }$ . The support set is then passed through those weights to compute the prototypes $c _ { t }$ and update the set of prototypes for all the tasks $\{ c _ { p } \} _ { p = 0 } ^ { t }$ . Finally, we pass the query set of every task $\{ Q ^ { ( \tau ) } \} _ { \tau = 0 } ^ { t }$ to we evaluate the quality of the generated weights.
38
+
39
+ Incremental few-shot learning. Prior work on incremental few-shot learning frequently uses a similar fast/slow weight separation, but the fast weights are typically generated using some form of gradient-based optimization (Ren et al., 2019; Lee et al., 2021). Furthermore, many incremental few-shot learning techniques rely on frozen feature extractors (Ren et al., 2019; Perez-Rua et al., 2020; Wang et al., 2021b; Zhang et al., 2021), which could potentially hinder their performance in situations where the input domain changes considerably between tasks. Some of these techniques (Wang et al., 2021b) are attention-based and can be viewed as special cases of our approach, where most of the model layers are trained or pretrained instead of being generated.
40
+
41
+ Many methods exist that try to specifically address the catastrophic forgetting by regularizing either the weights directly by restricting the update of some of them (Mazumder et al., 2021; Chen & Lee, 2020) or by constrain the optimization procedure itself (Shi et al., 2021; Gupta et al., 2020).
42
+
43
+ # 3 HYPERTRANSFORMER ARCHITECTURE
44
+
45
+ We consider a few-shot learning scenario, where we are given a set of tasks $\{ t | t \in \mathcal T \}$ split into $\tau _ { \mathrm { t r a i n } }$ and y se $\mathcal { T } _ { \mathrm { t e s t } }$ $t$ ecified , where $K$ -way e num $N$ ort set s in th $S ^ { ( t ) } = ( x _ { i } ^ { ( t ) } , y _ { i } ^ { ( t ) } ) _ { i = 1 } ^ { N K }$ andmber $Q ^ { ( t ) } = ( \hat { x } _ { i } ^ { ( t ) } , \hat { y } _ { i } ^ { ( t ) } ) _ { i = 1 } ^ { \hat { N } K }$ $K$ $N$ of labeled demonstrations of each class, and $\hat { N }$ (typically $\hat { N } \gg N _ { \cdot }$ ) is the number of query samples to be classified.
46
+
47
+ At each training iteration, a new episode is sampled without replacement from $\tau _ { \mathrm { t r a i n } }$ . The support set from that episode is used by the HT (parameterized by $\psi$ ) to directly generate the weights of the CNN via $\theta _ { t } = \dot { a } _ { \psi } ( S ^ { ( t ) } )$ . The loss is computed by passing the query set $( \hat { x } , \hat { y } )$ from the same task through the generated CNN $f _ { \theta _ { t } } ( { \hat { x } } )$ and using a cross-entropy objective. After the weights $\psi$ of the HT are trained, the tasks are sampled from a separate set of $\mathcal { T } _ { \mathrm { t e s t } }$ to evaluate its performance.
48
+
49
+ At the core of the HT lies an attention mechanism that generates CNN weights for a given layer from the support set. The transformer receives the embedding of the support set and placeholders for weight embeddings initialized with zero weight slices (see Fig. 1). At the output the support set embedding is ignored and the generated weight slices are converted into weights of the CNN.
50
+
51
+ # 4 INCREMENTAL HYPERTRANSFORMER
52
+
53
+ The HT can naturally extended the HT architecture to a continual stream of tasks by passing the generated weights from already learned tasks as input weight embeddings into the weight generator for a new task (see Fig. 1). This way the learned weights themselves act as both the input and the output of the the IHT, performing a dual function: storing information about the previous tasks as well as serving as CNN weights for evaluation on already seen tasks.
54
+
55
+ Fig. 2 demonstrates the overall learning flow of the proposed algorithm. During the training, $T$ episodes are sampled sequentially at random without replacement. For each task $t$ , the IHT receives the support set of that task $S ^ { ( t ) }$ as well as the previous weights $\theta _ { t - 1 } { } ^ { 1 }$ and generates the weights
56
+
57
+ $$
58
+ \theta _ { t } = a _ { \psi } ( S ^ { ( t ) } , \theta _ { t - 1 } ) ,
59
+ $$
60
+
61
+ that are suited for all the tasks $\{ \tau \} _ { \tau = 1 } ^ { t }$ . Therefore, for each step $t$ we want to minimize the loss on the query sets of every task up to $t$ :
62
+
63
+ $$
64
+ J _ { t } ( \psi ) = \sum _ { \tau = 0 } ^ { t } \mathcal { L } _ { \psi } \left( f _ { \theta _ { t } } ( \hat { x } ^ { ( \tau ) } ) , \hat { y } ^ { ( \tau ) } \right) .
65
+ $$
66
+
67
+ The final loss function is given by the sum of the losses for all the tasks:
68
+
69
+ $$
70
+ \underset { \psi } { \arg \operatorname* { m i n } } \sum _ { t = 0 } ^ { T } J _ { t } ( \psi ) .
71
+ $$
72
+
73
+ The IHT sequentially generates a series of weights $\{ \theta _ { \tau } \} _ { \tau = 0 } ^ { t }$ , each of which are suited for all the tasks coming before it: $\theta _ { 0 }$ performs well only on the task $\mathcal { T } _ { 0 } , \theta _ { 1 }$ performs well on the tasks $\mathcal { T } _ { 0 }$ and $\mathcal { T } _ { 1 }$ , and so forth. This design choice allows us to have a “preemptive” continual learning setup, where the IHT trained for $T$ tasks can be stopped at any point at $\tau < T$ and still have well-performing weights $\theta _ { \tau }$ for all the tasks seen so far. An alternative would be a setup where a user knows the exact number of tasks in the sequence and only cares about the performance after the final task $T$ . This would correspond to minimizing only the last term $J _ { T }$ in (3). We have experimented with this version and did not observe a noticeable improvement over the one we propose above.
74
+
75
+ Another desirable property of the proposed IHT architecture is its recurrence. The HT parameters do not depend on the task information and simply take the $\theta$ and the support set as its input. Therefore, it is possible not only to preempt IHT by stopping early, but also extend the trained model to continue generating weights for more tasks that it has been trained on. We will demonstrate this ability in the experimental section.
76
+
77
+ # 4.1 PROTOTYPICAL LOSS
78
+
79
+ The last element of the algorithm that we have left to discuss is the exact form of loss function $\mathcal { L } _ { \psi } ( \ v u )$ · in (2). The original HT used the cross-entropy loss, which is not well suited for continual learning, since the number of labels that it predicts is tied to the number of parameters in the head layer of the $\theta$ . As the number of tasks increases, the architecture of CNN needs to be adjusted, which goes against our design principle of a recurrent IHT architecture. Another alternative would be to fix the head layer to the $K$ -way classification problem across all the tasks and predict only the class information, ignoring the task attributes (which is known as domain-incremental learning Hsu et al., 2018). However, in this case the classes with the same label attribute from different tasks would be minimized to the same spot in the embedding space, creating a collision. Moreover, since these label attributes do not carry any semantic meaning and are drawn at random for every episode, the collisions would happen at random and the IHT would not be able to adjust or learn from them. In the Appendix A.1, we show that the accuracy of this setup drops dramatically as the number of tasks increases and this method becomes impractical right away for as little as two tasks.
80
+
81
+ To make the method usable we need to decouple the class predictions of every task while keeping the overall dimensionality of the embedding space fixed. One way to solve this problem is to come up with a fixed arrangement of $T K$ points, but any kind of such arrangement is sub-optimal since it is impossible to place $T K$ points equidistant from each other in a fixed dimensional space for large enough $T$ . A much more elegant solution would be to learn the location of these class prototypes from the support set itself, e.g. with a prototypical loss (Snell et al., 2017). The prototypes are computed by averaging the embeddings of support samples from a given class $k$ and task $\tau$ :
82
+
83
+ $$
84
+ c _ { \tau k } = \frac { 1 } { N } \sum _ { ( x , y ) \in S ^ { ( \tau ) } } f _ { \theta _ { \tau } } ( x ) \mathbf { 1 } _ { y = k } .
85
+ $$
86
+
87
+ We can use the prototypes in two different continual learning scenarios. First, for the taskincremental learning, we are assumed to have access to the task we are solving and need to predict only the class information. The probability of the sample belonging to a class $k$ given the task $\tau$ is then equal to the softmax of the $l 2$ distance between the sample and the prototype normalized over the distances to the prototypes from all the classes from $\tau$ :
88
+
89
+ $$
90
+ p ( \hat { y } = k | \hat { x } , \tau ) = \frac { \exp ( - \| f _ { \theta _ { t } } ( \hat { x } ) - c _ { \tau k } \| ^ { 2 } ) } { \sum _ { k ^ { \prime } } \exp ( - \| f _ { \theta _ { t } } ( \hat { x } ) - c _ { \tau k ^ { \prime } } \| ^ { 2 } ) } .
91
+ $$
92
+
93
+ Second, for the more general class-incremental learning, we need to predict both task and class attributes. The probability of the sample belonging to class $k$ of task $\tau$ is equal to the softmax of the $L 2$ distance between the sample and the prototype normalized over the distances to the prototypes from all the classes and all the tasks:
94
+
95
+ $$
96
+ p ( \hat { y } = k , \tau | \hat { x } ) = \frac { \exp ( - \| f _ { \theta _ { t } } ( \hat { x } ) - c _ { \tau k } \| ^ { 2 } ) } { \sum _ { \tau ^ { \prime } k ^ { \prime } } \exp ( - \| f _ { \theta _ { t } } ( \hat { x } ) - c _ { \tau ^ { \prime } k ^ { \prime } } \| ^ { 2 } ) } .
97
+ $$
98
+
99
+ The final loss function is given by minimizing the negative log probability of the chosen softmax over the query set. Algorithm 1 describes the procedure to compute that loss value.
100
+
101
+ Empirically, we noticed that the IHT models trained with the class-incremental learning objective (6) are applied equally well to both class-incremental and task-incremental settings, while models trained with the task-incremental objective (5) work well only in the task-incremental setting and rarely better than the models trained using (6). In what follows we are going to focus only on the IHT trained with (6), but evaluate them for both task- and class-incremental learning scenarios.
102
+
103
+ Notice that the prototypes are computed with respect to the current weights $\theta _ { \tau }$ in (4) for the task $\tau$ , however they need to be used down the line to compare the embeddings produced by subsequent weights $\theta _ { t }$ in (6). Ideally, once the new weights $\theta _ { t }$ are generated, the prototypes need to be recomputed as well. However, in the true spirit of continual learning, we are not supposed to re-use the support samples after the task has been already processed. We found out that freezing the prototypes after they are computed provides a viable solution to this problem. We noticed that compared to recomputing the prototypes every step, this gives only a marginal difference in performance.
104
+
105
+ We do want to note an important use-case where recomputing the prototypes might still be possible and even desirable. Notice that the weights $\theta _ { t }$ are not affected by this issue and are computed in a continual learning manner from (1) without the use of the information from the previous task. The support set is needed only to update the prototypes through generated weights, which is a relatively cheap operation. Thus, we can envision a privacy-preserving scenario in which the weights are updated and passed from client to client in a continual learning way and the prototypes needed to “unlock” those weights belong to the clients that hold the actual data.
106
+
107
+ # 5 CONNECTION BETWEEN PROTOTYPICAL LOSS AND MAML
108
+
109
+ While the core idea behind the prototypical loss is very natural, this approach can also be viewed as a special case of a simple 1-step MAML-like learning algorithm. This can be demonstrated by considering a simple classification model ${ \pmb q } ( { \pmb x } ; \phi ) = s ( { \pmb W } f _ { \theta } ( { \pmb x } ) + { \pmb b } )$ with $\phi = \left( W , b , \theta \right)$ , where $f _ { \boldsymbol { \theta } } ( \boldsymbol { x } )$ is the embedding and $s ( \cdot )$ is a softmax function. MAML algorithm identifies such initial weights $\phi ^ { 0 }$ that any task $\tau$ with just a few gradient descent steps initialized at $\phi ^ { 0 }$ brings the model towards a task-specific local optimum of $\scriptstyle { \mathcal { L } } _ { \tau }$ .
110
+
111
+ Notice that if any label assignment in the training tasks is equally likely, it is natural for ${ \pmb q } ( x ; \phi ^ { 0 } )$ to not prefer any particular label over the others. Guided by this, let us choose $W ^ { 0 }$ and $b ^ { 0 }$ that are label-independent. Substituting $\phi = \phi ^ { 0 } + \delta \phi$ into $\pmb q ( x ; \phi )$ , we then obtain
112
+
113
+ $$
114
+ q _ { \ell } ( x ; \phi ) = q _ { \ell } ( x ; \phi ^ { 0 } ) + s _ { \ell } ^ { \prime } ( \cdot ) \left( \delta W _ { \ell } f _ { \theta ^ { 0 } } ( x ) + \delta b _ { \ell } + W _ { \ell } ^ { 0 } \frac { \partial f } { \partial \theta } ( x ; \theta ^ { 0 } ) \delta \theta \right) + O ( \delta \phi ^ { 2 } ) ,
115
+ $$
116
+
117
+ Input: $T$ randomly sampled $K$ -way $N$ -shot episodes: $\overline { { \{ S ^ { ( t ) } ; Q ^ { ( t ) } \} _ { t = 0 } ^ { T } } }$ .
118
+ Output: The loss value $J$ for the generated set of tasks.
119
+ 1: $J \gets 0$ $\triangleright$ Initialize the loss.
120
+ 2: $\theta _ { - 1 } 0$ $\triangleright$ Initialize the weights.
121
+ 3: for $t \gets 0$ to $T$ do
122
+ 4: $\theta _ { t } \gets a _ { \psi } ( S ^ { ( t ) } , \theta _ { t - 1 } )$ $\triangleright$ Generate weight for current task.
123
+ 5: for $k 0$ to $K$ do $\triangleright$ Compute prototypes for every class of the current task.
124
+ 6: $\begin{array} { r } { c _ { t k } \gets \frac { 1 } { N } \sum _ { ( x , y ) \in S ^ { ( t ) } } f _ { \theta _ { t } } ( x ) \mathbf { 1 } _ { y = k } } \end{array}$
125
+ 7: end for
126
+ 8: for $\tau 0$ to $t$ do $\triangleright$ Update the loss with query samples using (6).
127
+ 9: for $k 0$ to $K$ do
128
+ 10: $\begin{array} { r } { J \gets J - \sum _ { ( \hat { x } , \hat { y } ) \in Q ^ { ( \tau ) } } \log p ( \hat { y } = k , \tau | \hat { x } ) \mathbf { 1 } _ { \hat { y } = k } } \end{array}$
129
+ 11: end for
130
+ 12: end for
131
+ 13: end for
132
+
133
+ ![](images/6b230657cb6e2a2a5baa4d9e149cf36b56bfdf0fefaa3fca738f6750b68b0df0.jpg)
134
+ Figure 3: Task-incremental learning on OMNIGLOT and TIEREDIMAGENET. Each column represents a different IHT trained with $T = 2$ , 3, 4 or 5 tasks in total. The tasks with a bullet marker $( \bullet )$ correspond to the terms in the objective function (3) that are being minimized. The lines with the diamond marker $( \diamond )$ are the extrapolation of the trained IHT to a larger number of tasks.
135
+
136
+ where $\ell$ is the label index and $\delta \phi = ( \delta W , \delta b , \delta \theta )$ . The lowest-order label-dependent correction to $q _ { \ell } ( x ; \phi ^ { 0 } )$ is given simply by $s _ { \ell } ^ { \prime } ( \cdot ) ( \delta W _ { \ell } f _ { \theta ^ { 0 } } ( x ) + \delta b _ { \ell } )$ . In other words, in the lowest-order, the model only adjusts the final logits layer to adapt the pretrained embedding $f _ { \theta ^ { 0 } } ( x )$ to a new task.
137
+
138
+ For a simple softmax cross-entropy loss (between predictions $\pmb q ( x )$ and the groundtruth labels $y$ ), a single step of the gradient descent results in the following logits weight and bias updates:
139
+
140
+ $$
141
+ \delta W _ { i \cdot } = \frac { \gamma } { n } \sum _ { ( x , y ) \in S } \left( { \bf 1 } _ { y = k } - \frac { 1 } { | C | } \right) f _ { \theta ^ { 0 } } ( x ) , \qquad \delta b _ { k } = \frac { \gamma } { n } \sum _ { ( x , y ) \in S } \left( { \bf 1 } _ { y = k } - \frac { 1 } { | C | } \right) ,
142
+ $$
143
+
144
+ where the $1 / | C |$ term results from normalization in the softmax operation. Here $\gamma$ is the learning rate, $n$ is the total number of support-set samples, $| C |$ is the number of classes and $S$ is the support set. In other words, we see that the label assignment imposed by $\delta \mathbf { { W } }$ and $\delta \boldsymbol { b }$ from (7) effectively relies on computing a dot-product of $f _ { \theta ^ { 0 } } ( x )$ with “prototypes” $\begin{array} { r } { \dot { c _ { k } } : = N ^ { - 1 } \sum _ { ( x , y ) \in S } f _ { \theta ^ { 0 } } ( x ) \mathbf { 1 } _ { y = k } } \end{array}$ .
145
+
146
+ # 6 EXPERIMENTS
147
+
148
+ We evaluated the model on two standard benchmark problems: 1-shot, 20-way OMNIGLOT and 5-shot, 5-way TIEREDIMAGENET. The generated weights for each task $\theta _ { t }$ are composed of four convolutional blocks and a single dense layer. Each of the convolutional blocks consist of a $3 \times 3$ convolutional layer, batch norm layer, ReLU activation and a $2 \times 2$ max-pooling layer. For OMNIGLOT we used 8 filters for convolutional layers and 20-dim FC layer to demonstrate how the network works on small problems, and for TIEREDIMAGENET we used 64 filters for convolutional and 40-dim for the FC layer2 to show that the method works for large problems as well. The reported accuracy is computed for 1024 random episodic evaluations from $\mathcal { T } _ { \mathrm { t e s t } }$ with each episode run 16 times with different combinations of input samples.
149
+
150
+ ![](images/3c538a7fa3cd2a29eb09e33af9972c1e2c16b81ee8d03143a2757cebf61b83f6.jpg)
151
+ Figure 4: Class-incremental learning on OMNIGLOT and TIEREDIMAGENET. Each column represents a different IHT trained with $T = 2$ , 3, 4 or 5 tasks in total. The tasks with a bullet marker $( \bullet )$ correspond to the terms in the objective function (3) that are being minimized. The lines with the diamond marker $( \diamond )$ are the extrapolation of the trained IHT to a larger number of tasks.
152
+
153
+ For the HT architecture, we tried to replicate the same setup that the authors had for their original paper as closely as possible. We used a 4-layer convolutional network as a feature extractor and a 2-layer convolutional model for computing activation features. For OMNIGLOT we used a 3-layer 2-head transformer and for TIEREDIMAGENET, a simplified 1-layer transformer with 8 heads. In all our experiments we have trained the network on a single GPU for $4 M$ steps with SGD with exponential LR decay over 100 000 steps with a decay rate of 0.97. We noticed some stability issues with training as we increase the number of tasks and had to decrease the learning rate to adjust for it: for OMNIGLOT experiments we used a learning rate $1 0 ^ { - 4 }$ for learning up to 4 tasks and $5 \times 1 0 ^ { - 5 }$ for 5 tasks. For TIEREDIMAGENET we have used the same learning rate $5 ^ { - } \times 1 0 ^ { - 6 }$ for training with any $T$ . As we outline above, we train the IHT models with the class-incremental objective (6), but evaluate for both task-incremental and class-incremental scenarios.
154
+
155
+ We compare our performance to two baselines. The first is a CONSTANT PROTONET (CONSTPN), which represents a vanilla Prototypical Network, as described in Snell et al. (2017). There, a universal fixed CNN network is trained on episodes from $\tau _ { \mathrm { t r a i n } }$ . This constant network can be applied to every task separately by projecting the support set as prototypes for that task and computing the prediction with respect to these prototypes. Strictly speaking, this is not a continual learning method, since it treats every task independently and has no memory of the previous tasks. For best results on this baseline we had to increase the number of classes 5 times during the training (e.g. for 20-way OMNIGLOT evaluation we have trained it with 100-way problems).
156
+
157
+ The second baseline we used specifically for the class-incremental learning is a MERGED HYPERTRANSFORMER (MERGEDHT), where we combine all the tasks together and train a single original HT instance as a single task. This method is not a continual learning, since it has the information about all the tasks from the beginning, but it produces a solution for every class and task that we can still compare to the weights generated by the IHT.
158
+
159
+ In fig. 3 and 4 we present the main findings of our paper. In order to understand the effect of continual learning with multiple tasks, each column represents a separate run of the IHT trained on $T = 2 , 3 , 4$ or 5 tasks in total (for training a higher $T$ , please see results in the Appendix). To demonstrate the recurrence of the method, we have extended the number of tasks to 5 for the evaluation. Therefore each plot shows 5 curves that correspond to the IHT, split into two groups: bullet marker $\mathbf { \Pi } ^ { ( \bullet ) }$ for tasks that the model was trained for and diamond marker $( \diamond )$ for extrapolation to more tasks. Each trained model is applied to both task-incremental (fig. 3) and class-incremental (fig. 4) setting.
160
+
161
+ ![](images/a716cb5feedacb57a86ef956c9ddb3dd42ac01f95cc3c569b7f86981ac740a9d.jpg)
162
+ Figure 5: UMAP projection of the IHT prototypes and the query set embeddings. The query set points are connected with the corresponding prototypes. The top plot shows the embeddings of different weights from incremental IHT training, colored according to the task. Right plot: UMAP projection of the CONSTPN embedding for 25 different classes from TIEREDIMAGENET
163
+
164
+ For the class-incremental learning, the task name is given by two numbers indicating the range of tasks we used for evaluation (e.g. task name 0-3 corresponds to four tasks from 0 to 3).
165
+
166
+ The black constant dashed line is a baseline performance of the CONSTPN, which uses a fixed embedding and does not differentiate between the tasks. Starred blue markers represent a separate run of the HT for a particular configuration of merged tasks.
167
+
168
+ Task-incremental learning. We start by analysing the task-incremental learning results. For the OMNIGLOT dataset, we see no signs of catastrophic forgetting for the IHT, moreover, we observe a positive backward knowledge transfer. For a given IHT, the performance on the past tasks improves as more weights are being generated: e.g. for most cases the performance of $\theta _ { 1 }$ (green markers) is higher than $\theta _ { 0 }$ (orange markers), $\theta _ { 2 }$ is higher than both $\theta _ { 1 }$ and $\theta _ { 0 }$ and so forth. We also noticed that as we train the IHT with more tasks, the overall performance increases: the IHT trained for $T = 5$ tasks has better results than the one trained with $T = 2$ .
169
+
170
+ For the TIEREDIMAGENET the results are much better than the CONSTPN baseline, but the positive backward knowledge effect is not as pronounced as with the OMNIGLOT dataset. The performance for every training task stays roughly the same for all the generated weights. This is still a useful outcome, since it means that the model does not suffer from catastrophic forgetting.
171
+
172
+ Finally, for every trained IHT, the performance is always better than the CONSTPN baseline up to the number of tasks $T$ that it was trained for. Extrapolating the IHT to more tasks decreases the accuracy, but not significantly. Already for $T = 3$ tasks, generating 4 or 5 weights performs better than the CONSTPN.
173
+
174
+ Class-incremental learning. Switching to the class-incremental learning, the accuracy trends down across all the models as more and more tasks are included in the prediction. This is expected, because the size of the generated CNN does not change, but the number of overall classes that needs to be predicted is increasing. For OMNIGLOT we still observe the positive backwards transfer taking place: the IHT models trained with a higher $T$ perform better across the board. For a given model trained for a fixed $T$ the performance is comparable. This shows the preemptive property of the IHT: models trained for $T$ tasks can be still run for any number of tasks smaller than $T$ with a similar performance.
175
+
176
+ Comparing results to the baselines, the IHT has better results than the CONSTPN up to the number of tasks $T$ it was trained for, with extrapolation results improving as $T$ grows. Very surprising, for $T = 5$ the IHT was able to outperform even the MERGEDHT baseline for OMNIGLOT, which has all the information about the tasks from the beginning. We hypothesise that having more classes to classify makes the learning problem very hard for the original HT since the image embeddings are not able to learn good embeddings. This is specifically apparent for the TIEREDIMAGENET, where the numbers for the MERGEDHT are so low, they fall below the graph at $60 \%$ even for the 0-1 task.
177
+
178
+ Multi-Domain Episode Generators. In all of the experiments above, the support and query sets in different episodes were always sampled from the same general distribution of tasks. And even though the set of chosen image classes varied task-to-task, the overall image domain and typical image features remained consistent across all the tasks. If different tasks could be sampled from entirely different distributions and different image domains, we would expect task-agnostic CONSTPN approach to experience accuracy degradation because it would need to identify a universal representation suited for all of the image domains at once. The IHT approach, on the other hand, could in principle adapt sample representations differently for different detected image domains.
179
+
180
+ We verify this by creating a multi-domain episode generator including tasks from a variety of image datasets: OMNIGLOT, CALTECH101, CALTECHBIRDS2011, CARS196, OXFORDFLOWERS102 and STANFORDDOGS. We measured the accuracy of CONSTPN vs. the IHT on this multi-domain generator using episodes contained two tasks with 1-shot, 5-way problems. The generated CNN model used 16 channels with the 32 channels for the final layer. Other parameters matched those used in the TIEREDIMAGENET experiments. Measured the CONSTPN accuracies were $5 3 \%$ for task 0, $5 2 . 8 \%$ for task 1 and $5 0 . 8 \%$ for combined tasks. For IHT accuracies were $5 6 . 2 \%$ for task 0, $5 5 . 2 \%$ for task 1 and $5 3 . 8 \%$ for combined tasks. The accuracy gap of nearly $3 \%$ between these two methods (higher than that for OMNIGLOT and TIEREDIMAGENET) suggests that the IHT is better at adapting to a multi-domain task distribution, but additional experiments are needed to confirm that adding new image domains hurts the CONSTPN performance more than it does the IHT.
181
+
182
+ Analysis of prototypical loss. We want to take a closer look at prototypes and query set embeddings for generated weights. For a given IHT trained for $T = 5$ on TIEREDIMAGENET 5-way, 5-shot problem, we picked a random test of 5 tasks and ran them through the model, producing weights $\theta _ { 0 }$ to $\theta _ { 4 }$ along with prototypes for each class for every task. We then computed the logits of the query sets consisting of 20 samples per class for every task. The resulting 40-dim embeddings for prototypes and query sets are concatenated and projected to 2D using UMAP (fig. 5). Notice that the embeddings of the tasks are well separated in the logits space, which explains why the model performs well for both task- and class-incremental learning. Normalizing the softmax over the classes from the same tasks or across the classes for all the tasks makes little difference when the tasks
183
+
184
+ ![](images/0b1663f1a87a2bf9ff06d8d4d91f8f79cd34bdf5fb5765d73489dddda295b4ac.jpg)
185
+ Figure 6: IHT trained using task-incremental objective (5) vs. class-incremental objective (6).
186
+
187
+ are so far away from each other. On the right of fig. 5 we show the projection of the CONSTPN embedding of the same 25 classes. The CONSTPN does not make a distinction between tasks and treats every class separately. The fact that we see 3 clusters emerge has to do purely with the semantics of the chosen clusters and the way the CONSTPN decides to group them. This also sheds light on why the IHT performs better than the CONSTPN, since it separates the tasks first before separating the classes within each task.
188
+
189
+ Finally, in fig. 6 we show the accuracy of two different models trained with task-incremental (5) and class-incremental objectives (6). The performance of both models on task-incremental problems are comparable, while for class-incremental the model trained for that objective is better.
190
+
191
+ # 7 CONCLUSIONS
192
+
193
+ The presented INCREMENTAL HYPERTRANSFORMER model has several desirable properties. On one hand, as an efficient few-shot learner, it is able to generate CNN weights on the fly with no training required from a small set of labeled examples. On the other hand, as a continual learner, it is able to update the weights with information from a new task by piping them recursively through a new iteration of the HT. We showed empirically that the learning happens without the catastrophic forgetting and, in some cases, even with a positive backward transfer. By modifying the loss from cross-entropy to prototypes we were able to define a learning procedure that optimizes the location of the prototypes of every class for each task. A single trained IHT model works in both task- and class-incremental regimes.
194
+
195
+ # REFERENCES
196
+
197
+ Antreas Antoniou, Harrison Edwards, and Amos J. Storkey. How to train your MAML. In 7th International Conference on Learning Representations, ICLR 2019, New Orleans, LA, USA, May 6-9, 2019. OpenReview.net, 2019.
198
+
199
+ Magdalena Biesialska, Katarzyna Biesialska, and Marta R Costa-Jussa. Continual lifelong learning in natural language processing: A survey. arXiv preprint arXiv:2012.09823, 2020.
200
+
201
+ Kuilin Chen and Chi-Guhn Lee. Incremental few-shot learning via vector quantization in deep embedded space. In International Conference on Learning Representations, 2020.
202
+
203
+ Chelsea Finn, Pieter Abbeel, and Sergey Levine. Model-agnostic meta-learning for fast adaptation of deep networks. 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. 1126–1135. PMLR, 06–11 Aug 2017.
204
+
205
+ Gunshi Gupta, Karmesh Yadav, and Liam Paull. Look-ahead meta learning for continual learning. Advances in Neural Information Processing Systems, 33:11588–11598, 2020.
206
+
207
+ David Ha, Andrew Dai, and Quoc V Le. Hypernetworks. arXiv preprint arXiv:1609.09106, 2016.
208
+
209
+ Yen-Chang Hsu, Yen-Cheng Liu, Anita Ramasamy, and Zsolt Kira. Re-evaluating continual learning scenarios: A categorization and case for strong baselines. arXiv preprint arXiv:1810.12488, 2018.
210
+
211
+ James Kirkpatrick, Razvan Pascanu, Neil Rabinowitz, Joel Veness, Guillaume Desjardins, Andrei A Rusu, Kieran Milan, John Quan, Tiago Ramalho, Agnieszka Grabska-Barwinska, et al. Overcoming catastrophic forgetting in neural networks. Proceedings of the national academy of sciences, 114(13):3521–3526, 2017.
212
+
213
+ Eugene Lee, Cheng-Han Huang, and Chen-Yi Lee. Few-shot and continual learning with attentive independent mechanisms. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pp. 9455–9464, 2021.
214
+
215
+ David Lopez-Paz and Marc’Aurelio Ranzato. Gradient episodic memory for continual learning. Advances in neural information processing systems, 30, 2017.
216
+
217
+ Pratik Mazumder, Pravendra Singh, and Piyush Rai. Few-shot lifelong learning. arXiv preprint arXiv:2103.00991, 2021.
218
+
219
+ Tsendsuren Munkhdalai and Hong Yu. Meta networks. In International Conference on Machine Learning, pp. 2554–2563. PMLR, 2017.
220
+
221
+ Alex Nichol and John Schulman. Reptile: a scalable metalearning algorithm. arXiv preprint arXiv:1803.02999, 2(3):4, 2018.
222
+
223
+ Boris N. Oreshkin, Pau Rodr´ıguez Lopez, and Alexandre Lacoste. TADAM: task dependent adaptive ´ metric for improved few-shot learning. In Samy Bengio, Hanna M. Wallach, Hugo Larochelle, Kristen Grauman, Nicolo Cesa-Bianchi, and Roman Garnett (eds.), \` Advances in Neural Information Processing Systems 31: Annual Conference on Neural Information Processing Systems 2018, NeurIPS 2018, December 3-8, 2018, Montreal, Canada ´ , pp. 719–729, 2018.
224
+
225
+ Juan-Manuel Perez-Rua, Xiatian Zhu, Timothy M Hospedales, and Tao Xiang. Incremental few-shot object detection. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 13846–13855, 2020.
226
+
227
+ Mengye Ren, Renjie Liao, Ethan Fetaya, and Richard Zemel. Incremental few-shot learning with attention attractor networks. Advances in Neural Information Processing Systems, 32, 2019.
228
+
229
+ Matthew Riemer, Ignacio Cases, Robert Ajemian, Miao Liu, Irina Rish, Yuhai Tu, and Gerald Tesauro. Learning to learn without forgetting by maximizing transfer and minimizing interference. arXiv preprint arXiv:1810.11910, 2018.
230
+
231
+ David Rolnick, Arun Ahuja, Jonathan Schwarz, Timothy Lillicrap, and Gregory Wayne. Experience replay for continual learning. Advances in Neural Information Processing Systems, 32, 2019.
232
+
233
+ Andrei A Rusu, Neil C Rabinowitz, Guillaume Desjardins, Hubert Soyer, James Kirkpatrick, Koray Kavukcuoglu, Razvan Pascanu, and Raia Hadsell. Progressive neural networks. arXiv preprint arXiv:1606.04671, 2016.
234
+
235
+ Andrei A. Rusu, Dushyant Rao, Jakub Sygnowski, Oriol Vinyals, Razvan Pascanu, Simon Osindero, and Raia Hadsell. Meta-learning with latent embedding optimization. In 7th International Conference on Learning Representations, ICLR 2019, New Orleans, LA, USA, May 6-9, 2019, 2019.
236
+
237
+ Guangyuan Shi, Jiaxin Chen, Wenlong Zhang, Li-Ming Zhan, and Xiao-Ming Wu. Overcoming catastrophic forgetting in incremental few-shot learning by finding flat minima. Advances in Neural Information Processing Systems, 34:6747–6761, 2021.
238
+
239
+ Jake Snell, Kevin Swersky, and Richard Zemel. Prototypical networks for few-shot learning. Advances in neural information processing systems, 30, 2017.
240
+
241
+ Flood Sung, Yongxin Yang, Li Zhang, Tao Xiang, Philip H. S. Torr, and Timothy M. Hospedales. Learning to compare: Relation network for few-shot learning. In 2018 IEEE Conference on Computer Vision and Pattern Recognition, CVPR 2018, Salt Lake City, UT, USA, June 18-22, 2018, pp. 1199–1208. IEEE Computer Society, 2018. doi: 10.1109/CVPR.2018.00131.
242
+
243
+ Xiaoyu Tao, Xiaopeng Hong, Xinyuan Chang, Songlin Dong, Xing Wei, and Yihong Gong. Fewshot class-incremental learning. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 12183–12192, 2020.
244
+
245
+ 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 (eds.), Advances in Neural Information Processing Systems 30: Annual Conference on Neural Information Processing Systems 2017, December 4-9, 2017, Long Beach, CA, USA, pp. 5998–6008, 2017.
246
+
247
+ Oriol Vinyals, Charles Blundell, Tim Lillicrap, Koray Kavukcuoglu, and Daan Wierstra. Matching networks for one shot learning. In Daniel D. Lee, Masashi Sugiyama, Ulrike von Luxburg, Isabelle Guyon, and Roman Garnett (eds.), Advances in Neural Information Processing Systems 29: Annual Conference on Neural Information Processing Systems 2016, December 5-10, 2016, Barcelona, Spain, pp. 3630–3638, 2016.
248
+
249
+ Liyuan Wang, Qian Li, Yi Zhong, and Jun Zhu. Few-shot continual learning: a brain-inspired approach. arXiv preprint arXiv:2104.09034, 2021a.
250
+
251
+ Yu Wang, Nicholas J Bryan, Mark Cartwright, Juan Pablo Bello, and Justin Salamon. Few-shot continual learning for audio classification. In ICASSP 2021-2021 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP), pp. 321–325. IEEE, 2021b.
252
+
253
+ Friedemann Zenke, Ben Poole, and Surya Ganguli. Continual learning through synaptic intelligence. In International Conference on Machine Learning, pp. 3987–3995. PMLR, 2017.
254
+
255
+ Chi Zhang, Nan Song, Guosheng Lin, Yun Zheng, Pan Pan, and Yinghui Xu. Few-shot incremental learning with continually evolved classifiers. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 12455–12464, 2021.
256
+
257
+ Andrey Zhmoginov, Mark Sandler, and Max Vladymyrov. Hypertransformer: Model generation for supervised and semi-supervised few-shot learning. arXiv preprint arXiv:2201.04182, 2022.
258
+
259
+ ![](images/138d3d150409e056a12d52a5cf0c9bb56abecce3f777619e12727da4c49df701.jpg)
260
+ Figure 7: The accuracy of the HT trained for $T = 5$ using cross-entropy loss. While the accuracy of the first weight $\theta _ { 0 }$ is high and is better than the accuracy of the CONSTPN embedding, it drops dramatically when more tasks are added, because of collisions between the same classes for different tasks in the cross-entropy loss.
261
+
262
+ ![](images/a6dd01e4617cac5c0e1f7a26a206500932cf6a490a794a3d9f76b6b7c4ea0067.jpg)
263
+ Figure 8: 2-dim UMAP projection from 20-dim embedding of the support set (prototypes) and query set for different weights from incremental HT training. The query set points are connected with their corresponding prototypes with a line. The top and bottom plots are identical, but colored according to both their class and task (top plot), or just according to their task (bottom plot). Notice that the prototypes from the earlier tasks remain the same for the later task, however since UMAP projection is non-parametric and have to be re-run for every new $\theta _ { k }$ , the 2-dim projection of the prototypes is not the same. We tried our best to align the embedding using the Procrustes alignment.
264
+
265
+ # A ADDITIONAL FIGURES
266
+
267
+ # A.1 LEARNING WITH CROSS-ENTROPY LOSS
268
+
269
+ Figure 7 shows an attempt to do learn incrementally from multiple tasks using a HT with a crossentropy loss. Since we do not increase the size of the last layer’s embedding, we can predict only class and not task, which corresponds to the domain-incremental learning setup. Moreover, the same class from different tasks are mapped to the same location in the embedding space, thus creating collisions when more tasks are added. This is why the accuracy drops very dramatically when the number of tasks increase. On the other hand, CONSTPN is more flexible, since the prototypes for each tasks are computed from the support set of a given task and do not have to be fixed to the one-hot vector, as it done for the cross-entropy.
270
+
271
+ # A.2 UMAP PLOT OF THE MULTI-TASK PROTOTYPES
272
+
273
+ UMAP embedding for the OMNIGLOT embedding using ProtoNet (fig. 8) looks different from similar embedding projection of TIEREDIMAGENET. In particular, it looks like the embeddings from different tasks are overlapping, in contrast to the TIEREDIMAGENET embedding that are separated. We think this is because the classes in OMNIGLOT are much more closely connected than for TIEREDIMAGENET. Curiously, even though the classes between the tasks are overlapping, the final accuracy is still in the high $9 0 \%$ and barely degrades when more tasks are added.
274
+
275
+ ![](images/32375216fdb94854d9f8eee3ae00d551433966bc15e852a97d1281361c863e9e.jpg)
276
+ Figure 9: OMNIGLOT with 8 or 32 channels trained with a different number of tasks $T$
277
+
278
+ # A.3 LEARNING WITH MORE TASKS
279
+
280
+ Although, we mainly analysed the results of IHT for up to 5 tasks, we can run the IHT for much more than that. Fig. 9 shows the IHT run for a different number of total tasks $T$ for the OMNIGLOT dataset with 8 and 32 channels convolutional layers. Similar to the results in the main paper, the nearly overlapping curves mean that the model trained for $T$ tasks can generalize and run for up to that many tasks with the same accuracy as the model trained for a smaller number of tasks.
281
+
282
+ A.4 INCREMENTAL HYPERTRANSFORMER VS MERGEDHT FOR TIEREDIMAGENET
283
+
284
+ Fig. 10 shows the zoomed out view of the same figure presented in the main paper (fig. 4). Here, one can clearly see how much worse the MERGEDHT is compared to the IHT.
285
+
286
+ # A.5 ADDITIONAL FIGURES FOR OMNIGLOT TASK- AND CLASS-INCREMENTAL LEARNING
287
+
288
+ Fig. 11, 12, 13 and 14 show additional experiments with OMNIGLOT with different number of channels in the CNN.
289
+
290
+ ![](images/906e018236522518ba88836f7997db56fcf0f4263fb27890e764fb8622be97bd.jpg)
291
+ Figure 10: Zoomed out view of fig. 4 so that the results of the MERGEDHT is visible.
292
+
293
+ ![](images/844f9de147df524f1be59feb01aad6feb773ed2e1ec8891c0808b5c8581eea0c.jpg)
294
+ Figure 11: Task- and class-incremental learning on OMNIGLOT with 4-channels convolutions.
295
+
296
+ ![](images/9f62949f8d5cb96b632731c76cac1a7cc93d758e51622a59c1f211a519ffb22c.jpg)
297
+ Figure 12: Task- and class-incremental learning on OMNIGLOT with 6-channels convolutions.
298
+
299
+ ![](images/65ecea09d4bd9f986d71d8d3b7a73bf03f9d30e16d2646d8d1d01e2bf5b62d8c.jpg)
300
+ Figure 13: Task- and class-incremental learning on OMNIGLOT with 16-channels convolutions.
301
+
302
+ ![](images/b2f4289c01506697f6ade56b0afc6a69848773dc706ed9999090c2ea2ef7f6ff.jpg)
303
+ Figure 14: Task- and class-incremental learning on OMNIGLOT with 32-channels convolutions.
md/dev/shpkpVXzo3h/shpkpVXzo3h.md ADDED
@@ -0,0 +1,396 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 8-BIT OPTIMIZERS VIA BLOCK-WISE QUANTIZATION
2
+
3
+ Anonymous authors Paper under double-blind review
4
+
5
+ # ABSTRACT
6
+
7
+ Stateful optimizers maintain gradient statistics over time, e.g., the exponentially smoothed sum (SGD with momentum) or squared sum (Adam) of past gradient values. This state can be used to accelerate optimization compared to plain stochastic gradient descent but uses memory that might otherwise be allocated to model parameters, thereby limiting the maximum size of models trained in practice. In this paper, we develop the first optimizers that use 8-bit statistics while maintaining the performance levels of using 32-bit optimizer states. To overcome the resulting computational, quantization, and stability challenges, we develop block-wise dynamic quantization. Block-wise quantization divides input tensors into smaller blocks that are independently quantized. Each block is processed in parallel across cores, yielding faster optimization and high precision quantization. To maintain stability and performance, we combine block-wise quantization with two additional changes: (1) dynamic quantization, a form of non-linear optimization that is precise for both large and small magnitude values, and (2) a stable embedding layer to reduce gradient variance that comes from the highly non-uniform distribution of input tokens in language models. As a result, our 8-bit optimizers maintain 32-bit performance with a small fraction of the memory footprint on a range of tasks, including 1.5B parameter language modeling, GLUE finetuning, ImageNet classification, WMT’14 machine translation, MoCo v2 contrastive ImageNet pretraining+finetuning, and RoBERTa pretraining, without changes to the original optimizer hyperparameters. We open-sourceour 8-bit optimizers as a drop-in replacement that only requires a two-line code change.
8
+
9
+ Increasing model size is an effective way to achieve better performance for given resources (Kaplan et al., 2020; Henighan et al., 2020; Raffel et al., 2019; Lewis et al., 2021). However, training such large models requires storing the model, gradient, and state of the optimizer (e.g., exponentially smoothed sum and squared sum of previous gradients for Adam), all in a fixed amount of available memory. Although significant research has focused on enabling larger model training by reducing or efficiently distributing the memory required for the model parameters (Shoeybi et al., 2019; Lepikhin et al., 2020; Fedus et al., 2021; Brown et al., 2020; Rajbhandari et al., 2020), reducing the memory footprint of optimizer gradient statistics is much less studied. This is a significant missed opportunity since these optimizer states use $3 3 \mathrm { - } 7 5 \%$ of the total memory footprint during training. For example, the Adam optimizer states for the largest GPT-2 (Radford et al., 2019) and T5 (Raffel et al., 2019) models are 11 GB and 41 GB in size. In this paper, we develop a fast, high-precision non-linear quantization method – block-wise dynamic quantization – that enables stable 8-bit optimizers (e.g., Adam, AdamW, and Momentum) which maintain 32-bit performance at a fraction of the memory footprint and without any changes to the original hyperparameters.1
10
+
11
+ While most current work uses 32-bit optimizer states, recent high-profile efforts to use 16-bit optimizers report difficultly for large models with more than 1B parameters (Ramesh et al., 2021). Going from 16-bit optimizers to 8-bit optimizers reduces the range of possible values from $2 ^ { 1 6 } = 6 5 5 3 \bar { 6 }$ values to just $\bar { 2 } ^ { 8 } = 2 5 6$ . To our knowledge, this has not been attempted before.
12
+
13
+ Effectively using this very limited range is challenging for three reasons: quantization accuracy, computational efficiency, and large-scale stability. To maintain accuracy, it is critical to introduce some form of non-linear quantization to reduce errors for both common small magnitude values and rare large ones. However, to be practical, 8-bit optimizers need to be fast enough to not slow down training, which is especially difficult for non-linear methods that require more complex data structures to maintain the quantization buckets. Finally, to maintain stability with huge models beyond 1B parameters, a quantization method needs to not only have a good mean error but excellent worse case performance since a single large quantization error can cause the entire training run to diverge.
14
+
15
+ ![](images/48cb7db647012e734edb0dcae4a71dbc32cb6b6baab4efe52baf6bfa8d324e0c.jpg)
16
+ Figure 1: Schematic of 8-bit optimizers via block-wise dynamic quantization, see Section 2 for more details. After the optimizer update is performed in 32-bit, the state tensor is chunked into blocks, normalized by the absolute maximum value of each block. Then dynamic quantization is performed, and the index is stored. For dequantization, a lookup in the index is performed, with subsequent denormalization by multiplication with the block-wise absolute maximum value. Outliers are confined to a single block through block-wise quantization, and their effect on normalization is limited.
17
+
18
+ We introduce a new block-wise quantization approach that addresses all three of these challenges. Block-wise quantization splits input tensors into blocks and performs quantization on each block independently. This block-wise division reduces the effect of outliers on the quantization process since they are isolated to particular blocks, thereby improving stability and performance, especially for large-scale models. Block-wise processing also allows for high optimizer throughput since each normalization can be computed independently in each core. This contrasts with tensor-wide normalization, which requires slow cross-core synchronization that is highly dependent on task-core scheduling. We combine block-wise quantization with two novel methods for stable, high-performance 8-bit optimizers: dynamic quantization and a stable embedding layer. Dynamic quantization is an extension of dynamic tree quantization for unsigned input data. The stable embedding layer is a variation of a standard word embedding layer that supports more aggressive quantization by normalizing the highly non-uniform distribution of inputs to avoid extreme gradient variation.
19
+
20
+ Our 8-bit optimizers maintain 32-bit performance at a fraction of the original memory footprint. We show this for a broad range of tasks: 1.5B and $3 5 5 \mathrm { M }$ parameter language modeling, GLUE finetuning, ImageNet classification, WMT’ $^ { 1 4 + }$ WMT’16 machine translation, MoCo v2 contrastive image pretraining $^ +$ finetuning, and RoBERTa pretraining. We also report additional ablations and sensitivity analysis showing that all components – block-wise quantization, dynamic quantization, and stable embedding layer – are crucial for these results and that 8-bit Adam can be used as a simple drop-in replacement for 32-bit Adam, with no hyperparameter changes. We open-source our custom CUDA kernels and provide a PyTorch implementation that enables 8-bit optimization by changing two lines of code.
21
+
22
+ # 1 BACKGROUND
23
+
24
+ # 1.1 STATEFUL OPTIMIZERS
25
+
26
+ An optimizer updates the parameters w of a neural network by using the gradient of the loss with respect to the weight $\begin{array} { r } { \mathbf { g } _ { t } \doteq \frac { \partial \mathbf { L } } { \partial \mathbf { w } } } \end{array}$ at update iteration $t$ . Stateful optimizers compute statistics of the gradient with respect to each parameter over time for accelerated optimization. Two of the most commonly used stateful optimizers are Adam (Kingma and Ba, 2014), and SGD with momentum (Qian, 1999) – or Momentum for short. Without damping and scaling constants, the update rules of these optimizers are given by:
27
+
28
+ $$
29
+ \begin{array} { r } { \mathbf { M o m e n t u m } ( \mathbf { g } _ { t } , \mathbf { w } _ { t - 1 } , \mathbf { m } _ { t - 1 } ) = \left\{ \begin{array} { l l } { \mathbf { m } _ { 0 } = \mathbf { g } _ { 0 } } \\ { \mathbf { m } _ { t } = \beta _ { 1 } \mathbf { m } _ { t - 1 } + \mathbf { g } _ { t } } \\ { \mathbf { w } _ { t } = \mathbf { w } _ { t - 1 } - { \boldsymbol \alpha } \cdot \mathbf { m } _ { t } } \end{array} \right. } \end{array}
30
+ $$
31
+
32
+ $$
33
+ \mathrm { A d a m } ( \mathbf { g } _ { t } , \mathbf { w } _ { t - 1 } , \mathbf { m } _ { t - 1 } , \mathbf { r } _ { t - 1 } ) = \left\{ \begin{array} { l l } { \mathbf { r } _ { 0 } = \mathbf { m } _ { 0 } = \mathbf { 0 } } \\ { \mathbf { m } _ { t } = \beta _ { 1 } \mathbf { m } _ { t - 1 } + ( 1 - \beta _ { 1 } ) \mathbf { g } _ { t } } \\ { \mathbf { r } _ { t } = \beta _ { 2 } \mathbf { r } _ { t - 1 } + ( 1 - \beta _ { 2 } ) \mathbf { g } _ { t } ^ { 2 } } \\ { \mathbf { w } _ { t } = \mathbf { w } _ { t - 1 } - { \boldsymbol { \alpha } } \cdot \frac { \mathbf { m } _ { t } } { \sqrt { \mathbf { r } _ { t } } + \epsilon } } \end{array} \right.
34
+ $$
35
+
36
+ where $\beta _ { 1 }$ and $\beta _ { 2 }$ are smoothing constants, $\epsilon$ is a small constant, and $\alpha$ is the learning rate.
37
+
38
+ For 32-bit states, Momentum and Adam consume 4 and 8 bytes per parameter. That is $_ 4 \mathrm { G B }$ and 8 GB for a 1B parameter model. Our 8-bit non-linear quantization reduces these costs to 1 GB and 2 GB.
39
+
40
+ # 1.2 NON-LINEAR QUANTIZATION
41
+
42
+ Quantization compresses numeric representations to save space at the cost of precision. Quantization is the mapping of a $k$ -bit integer to a real element in $D$ , that is, $\mathbf { Q } ^ { \mathrm { m a p } } \colon [ 0 , 2 ^ { k } - 1 ] \stackrel { \cdot } { \mapsto } D$ . For example, the IEEE 32-bit floating point data type maps the indices $0 . . . 2 ^ { 3 2 } - 1$ to the domain $\left[ - 3 . 4 \mathrm { e } 3 8 , + 3 . 4 \mathrm { e } 3 8 \right]$ . We use the following notation: $\mathbf { Q } ^ { \mathrm { m a p } } ( i ) = \mathbf { Q } _ { i } ^ { \mathrm { m a p } } = q _ { i }$ , for example $\mathbf { Q } ^ { \mathrm { m a p } } ( 2 ^ { 3 1 } + 1 3 1 0 7 2 ) = 2 . 0 3 1 2 5$ , for the IEEE 32-bit floating point data type.
43
+
44
+ To perform general quantization from one data type into another we require three steps. (1) Compute a normalization constant $N$ that transforms the input tensor $\mathbf { T }$ into the range of the domain $D$ of the target quantization data type $\mathbf { Q } ^ { \mathrm { m a p } }$ , (2) for each element of $\mathbf { T } / N$ find the closest corresponding value $q _ { i }$ in the domain $D$ , (3) store the index $i$ corresponding to $q _ { i }$ in the quantized output tensor $\bar { \mathbf { T } } ^ { Q }$ . To receive the dequantized tensor $\mathbf { T } ^ { D }$ we look up the index and denormalize: $\mathbf { T } _ { i } ^ { D } = \mathbf { Q } ^ { \operatorname* { m a p } } ( \mathbf { T } _ { i } ^ { Q } ) \cdot N$ .
45
+
46
+ To perform this procedure for dynamic quantization we first normalize into the range [-1, 1] through division by the absolute maximum value: $N = \operatorname* { m a x } ( | \mathbf { T } | )$ .
47
+
48
+ Then we find the closest values via a binary search:
49
+
50
+ $$
51
+ \mathbf { T } _ { i } ^ { Q } = \underset { j = 0 } { \operatorname { a r g m i n } } | \mathbf { Q } _ { j } ^ { \operatorname* { m a p } } - \frac { \mathbf { T } _ { i } } { N } |
52
+ $$
53
+
54
+ # 1.3 DYNAMIC TREE QUANTIZATION
55
+
56
+ Dynamic Tree quantization (Dettmers, 2016) is a method that yields low quantization error for both small and large magnitude values. Unlike data types with fixed exponent and fraction, dynamic tree quantization uses a datatype with a dynamic exponent and fraction that can change with each number. It is made up of four parts, as seen in Figure 2: (1) The first bit of the data type is reserved for a sign. (2) The number of subsequent zero bits indicates the magnitude of the exponent. (3) The first bit that is set to one indicates that all following values are reserved for (4) linear quantization. By moving the indicator bit, numbers can have a large exponent $1 0 ^ { - 7 }$ or precision as high as $1 / 6 3$ . Compared to linear quantization, dynamic tree quantization has better absolute and relative quantization errors for non-uniform distributions. Dynamic tree quantization is strictly defined to quantize numbers in the range [-1.0, 1.0], which is ensured by performing tensor-level absolute max normalization.
57
+
58
+ ![](images/1addf759c0e839af608df6324e894dbd84d099a00efed1da1b91e3383e234c2d.jpg)
59
+ Figure 2: Dynamic tree quantization.
60
+
61
+ # 2 8-BIT OPTIMIZERS
62
+
63
+ Our 8-bit optimizers have three components: (1) block-wise quantization that isolates outliers and distributes the error more equally over all bits; (2) dynamic quantization, which quantizes both small and large values with high precision; and (3) a stable embedding layer to improve stability during optimization for models with word embeddings.
64
+
65
+ With these components, performing an optimizer update with 8-bit states is straightforward. We dequantize the 8-bit optimizer states to 32-bit, perform the update, and then quantize the states back to 8-bit for storage. We do this 8-bit to 32-bit conversion element-by-element in registers, which means no slow copies to GPU memory or additional temporary memory are needed to perform quantization and dequantization. For GPUs, this makes 8-bit optimizers faster than regular 32-bit optimizers, as we show in Section 3.
66
+
67
+ # 2.1 BLOCK-WISE QUANTIZATION
68
+
69
+ Our block-wise quantization reduces the cost of computing normalization and improves quantization precision by isolating outliers. In order to dynamically quantize a tensor, as defined in Section 1.2, we need to normalize the tensor into the range [-1, 1]. Such normalization requires a reduction over the entire tensor, which entails multiple synchronizations across GPU cores. Block-wise dynamic quantization reduces this cost by chunking an input tensor into small blocks of size $B = 2 0 4 8$ and performing normalization independently in each core across this block.
70
+
71
+ More formally, using the notation introduced in Section 1.2, in block-wise quantization, we treat $\mathbf { T }$ as a one-dimensional sequence of elements that we chunk in blocks of size $B$ . This means for an input tensor $\mathbf { T }$ with $n$ elements we have $n / B$ blocks. We proceed to compute a normalization constant for each block: $N _ { b } = \operatorname* { m a x } ( | \mathbf { T } _ { b } | )$ , where $b$ is the index of the block $0 . . n / B$ . With this block-wise normalization constant, each block can be quantized independently:
72
+
73
+ $$
74
+ \mathbf { T } _ { b i } ^ { Q } = \underset { j = 0 } { \arg \operatorname* { m i n } } | \mathbf { Q } _ { j } ^ { \operatorname* { m a p } } - \frac { \mathbf { T } _ { b i } } { N _ { b } } | \bigg | _ { 0 < i < B }
75
+ $$
76
+
77
+ This approach has several advantages, both for stability and efficiency. First, each block normalization can be computed independently. Thus no synchronization between cores is required, and throughput is enhanced.
78
+
79
+ Secondly, it is also much more robust to outliers in the input tensor. For example, to contrast blockwise and regular quantization, if we create an input tensor with one million elements sampled from the standard normal distribution, we expect less than $1 \%$ of elements of the tensor will be in the range $[ 3 , + \infty )$ . However, since we normalize the input tensor into the range [-1,1] this means the maximum values of the distribution determine the range of quantization buckets. This means if the input tensor contains an outlier with magnitude 5, the quantization buckets reserved for numbers between 3 and 5 will mostly go unused since less than $1 \%$ of numbers are in this range. With blockwise quantization, the effect of outliers is limited to a single block. As such, most bits are used effectively in other blocks.
80
+
81
+ Furthermore, because outliers represent the absolute maximum value in the input tensor, blockwise quantization approximates outlier values without any error. This guarantees that the largest optimizer states, arguably the most important, will always be quantized with full precision. This property makes block-wise dynamic quantization both robust and precise and is essential for good training performance in practice.
82
+
83
+ # 2.2 DYNAMIC QUANTIZATION
84
+
85
+ In this work, we extend dynamic tree quantization (Section 1.3) for non-signed input tensors by re-purposing the sign bit. Since the second Adam state is strictly positive, the sign bit is not needed. Instead of just removing the sign bit, we opt to extend dynamic tree quantization with a fixed bit for the fraction. This extension is motivated by the observation that the second Adam state varies around 3-5 orders of magnitude during the training of a language model. In comparison, dynamic tree quantization already has a range of 7 orders of magnitude. We refer to this quantization as dynamic quantization to distinguish it from dynamic tree quantization in our experiments. A study of additional quantization data types and their performance is detailed in Appendix E.
86
+
87
+ # 2.3 STABLE EMBEDDING LAYER
88
+
89
+ Our stable embedding layer is a standard word embedding layer variation (Devlin et al., 2019) designed to ensure stable training for NLP tasks. This embedding layer supports more aggressive quantization by normalizing the highly non-uniform distribution of inputs to avoid extreme gradient variation. See Appendix B for a discussion of why commonly adopted embedding layers (Ott et al., 2019) are so unstable.
90
+
91
+ We initialize the Stable Embedding layer with Xavier uniform initialization (Glorot and Bengio, 2010) and apply layer normalization (Ba et al., 2016) before adding position embeddings. This method maintains a variance of roughly one both at initialization and during training. Additionally, the uniform distribution initialization has less extreme values than a normal distribution, reducing maximum gradient size. Like Ramesh et al. (2021), we find that the stability of training improves significantly if we use 32-bit optimizer states for the embedding layers. This is the only layer that uses 32-bit optimizer states. We still use the standard precision for weights and gradients for the embedding layers – usually 16-bit. We show in our Ablation Analysis in Section 4 that this change is a necessary detail.
92
+
93
+ # 3 8-BIT VS 32-BIT OPTIMIZER PERFORMANCE FOR COMMON BENCHMARKS
94
+
95
+ Experimental Setup We compare the performance of 8-bit optimizers to their 32-bit counterparts on a range of challenging public benchmarks. These benchmarks either use Adam (Kingma and Ba, 2014), AdamW (Loshchilov and Hutter, 2018), or Momentum (Qian, 1999).
96
+
97
+ We do not change any hyperparameters or precision of weights, gradients, and activations/input gradients for each experimental setting compared to the public baseline– the only change is to replace 32-bit optimizers with 8-bit optimizers. This means that for most experiments, we train in 16-bit mixed-precision (Micikevicius et al., 2017). We also compare with Adafactor (Shazeer and Stern, 2018), with the time-independent formulation for $\beta _ { 2 }$ (Shazeer and Stern, 2018) – which is the same formulation used in Adam. We also do not change any hyperparameters for Adafactor.
98
+
99
+ We report on benchmarks in neural machine translation (Ott et al., 2018)2 trained on WMT’16 (Sennrich et al., 2016) and evaluated on en-de WMT’14 (Macha´cek and Bojar, 2014), large-scale ˇ language modeling (Lewis et al., 2021; Brown et al., 2020) and RoBERTa pretraining (Liu et al., 2019) on English CC- $1 0 0 +$ RoBERTa corpus (Nagel, 2016; Gokaslan and Cohen, 2019; Zhu et al., 2015; Wenzek et al., 2020), finetuning the pretrained masked language model RoBERTa (Liu et al., 2019)3 on GLUE (Wang et al., 2018a), ResNet-50 v1.5 image classification (He et al., 2016)4 on ImageNet-1k (Deng et al., 2009), and Moco v2 contrastive image pretraining and linear finetuning (Chen et al., $2 0 2 0 \mathrm { { b } } ) ^ { 5 }$ on ImageNet-1k (Deng et al., 2009).
100
+
101
+ We use the stable embedding layer for all NLP tasks except for finetuning on GLUE. Beyond this, we follow the exact experimental setup outlined in the referenced papers and codebases. We consistently report replication results for each benchmark with public codebases and report median accuracy, perplexity, or BLEU over ten random seeds for GLUE, three random seeds for others tasks, and a single random seed for large scale language modeling. While it is standard to report means and standard errors on some tasks, others use median performance. We opted to report medians for all tasks for consistency.
102
+
103
+ Results In Table 1, we see that 8-bit optimizers match replicated 32-bit performance for all tasks. While Adafactor is competitive with 8-bit Adam, 8-bit Adam uses less memory and provides faster optimization. Our 8-bit optimizers save up to $8 . 5 \mathrm { \ G B }$ of GPU memory for our largest 1.5B parameter language model and 2.0 GB for RoBERTa. Thus, 8-bit optimizers maintain performance and improve accessibility to the finetuning of large models for those that cannot afford GPUs with large memory buffers. We show models that are now accessible with smaller GPUs in Table 2. A breakdown of individual dataset results on GLUE can be found in Appendix A).
104
+
105
+ Table 1: Median performance on diverse NLP and computer vision tasks: GLUE, object classification with (Moco v2) and without pretraining (CLS), machine translation (MT), and large-scale language modeling (LM). While 32-bit Adafactor is competitive with 8-bit Adam, it uses almost twice as much memory and trains slower. 8-bit Optimizers match or exceed replicated 32-bit performance on all tasks. We observe no instabilities for 8-bit optimizers. Time is total GPU time on V100 GPUs, except for RoBERTa and GPT3 pretraining, which were done on A100 GPUs.
106
+
107
+ <table><tr><td>Optimizer</td><td>Task</td><td>Data</td><td>Model</td><td>Metrict</td><td>Time</td><td>Mem saved</td></tr><tr><td>32-bit AdamW</td><td>GLUE</td><td>Multiple</td><td>RoBERTa-Large</td><td>88.9</td><td>1</td><td>Reference</td></tr><tr><td>32-bit AdamW</td><td>GLUE</td><td>Multiple</td><td>RoBERTa-Large</td><td>88.6</td><td>17h</td><td>0.0 GB</td></tr><tr><td>32-bit Adafactor</td><td>GLUE</td><td>Multiple</td><td>RoBERTa-Large</td><td>88.7</td><td>24h</td><td>1.3 GB</td></tr><tr><td>8-bit AdamW</td><td>GLUE</td><td>Multiple</td><td>RoBERTa-Large</td><td>88.7</td><td>15h</td><td>2.0 GB</td></tr><tr><td>32-bit Momentum</td><td>CLS</td><td>ImageNet-1k</td><td>ResNet-50</td><td>77.1</td><td>1</td><td>Reference</td></tr><tr><td>32-bit Momentum</td><td>CLS</td><td>ImageNet-1k</td><td>ResNet-50</td><td>77.1</td><td>118h</td><td>0.0 GB</td></tr><tr><td>8-bit Momentum</td><td>CLS</td><td>ImageNet-1k</td><td>ResNet-50</td><td>77.2</td><td>116 h</td><td>0.1 GB</td></tr><tr><td>32-bit Adam</td><td>MT</td><td>WMT&#x27;14+16</td><td>Transformer</td><td>29.3</td><td></td><td>Reference</td></tr><tr><td>32-bit Adam</td><td>MT</td><td>WMT&#x27;14+16</td><td>Transformer</td><td>29.0</td><td>126h</td><td>0.0 GB</td></tr><tr><td>32-bit Adafactor</td><td>MT</td><td>WMT&#x27;14+16</td><td>Transformer</td><td>29.0</td><td>127h</td><td>0.3 GB</td></tr><tr><td>8-bit Adam</td><td>MT</td><td>WMT&#x27;14+16</td><td>Transformer</td><td>29.1</td><td>115h</td><td>1.1 GB</td></tr><tr><td>32-bit Momentum</td><td>MoCo v2</td><td>ImageNet-1k</td><td>ResNet-50</td><td>67.5</td><td>1</td><td>Reference</td></tr><tr><td>32-bit Momentum</td><td>MoCo v2</td><td>ImageNet-1k</td><td>ResNet-50</td><td>67.3</td><td>30 days</td><td>0.0 GB</td></tr><tr><td>8-bit Momentum</td><td>MoCo v2</td><td>ImageNet-1k</td><td>ResNet-50</td><td>67.4</td><td>28 days</td><td>0.1 GB</td></tr><tr><td>32-bit Adam</td><td>LM</td><td>Multiple</td><td>Transformer-1.5B</td><td>9.0</td><td>308 days</td><td>0.0 GB</td></tr><tr><td>32-bit Adafactor</td><td>LM</td><td>Multiple</td><td>Transformer-1.5B</td><td>8.9</td><td>316days</td><td>5.6 GB</td></tr><tr><td>8-bit Adam</td><td>LM</td><td>Multiple</td><td>Transformer-1.5B</td><td>9.0</td><td>297 days</td><td>8.5 GB</td></tr><tr><td>32-bit Adam</td><td>LM</td><td>Multiple</td><td>GPT3-Medium</td><td>10.62</td><td>795 days</td><td>0.0 GB</td></tr><tr><td>32-bit Adafactor</td><td>LM</td><td>Multiple</td><td>GPT3-Medium</td><td>10.68</td><td>816 days</td><td>1.5 GB</td></tr><tr><td>8-bit Adam</td><td>LM</td><td>Multiple</td><td>GPT3-Medium</td><td>10.62</td><td>761 days</td><td>1.7 GB</td></tr><tr><td>32-bit Adam</td><td>Masked-LM</td><td>Multiple</td><td>RoBERTa-Base</td><td>3.49</td><td>101 days</td><td>0.0 GB</td></tr><tr><td>32-bit Adafactor</td><td>Masked-LM</td><td>Multiple</td><td>RoBERTa-Base</td><td>3.59</td><td>112 days</td><td>0.7 GB</td></tr><tr><td>8-bit Adam</td><td>Masked-LM</td><td>Multiple</td><td>RoBERTa-Base</td><td>3.48</td><td>94 days</td><td>1.1 GB</td></tr></table>
108
+
109
+ †Metric: GLUE=Mean Accuracy/Correlation. CLS/MoCo $=$ Accuracy. MT $\sqsupseteq$ BLEU. LM=Perplexity.
110
+
111
+ The broad range of tasks and competitive results demonstrate that 8-bit optimizers are a robust and effective replacement for 32-bit optimizers, do not require any additional changes in hyperparameters, and save a significant amount of memory while speeding up training slightly.
112
+
113
+ Table 2: With 8-bit optimizers, larger models can be finetuned with the same GPU memory compared to standard 32-bit optimizer training. We use a batch size of one for this comparison.
114
+
115
+ <table><tr><td rowspan="2">GPU size in GB</td><td colspan="2">Largest finetunable Model (parameters)</td></tr><tr><td>32-bit Adam</td><td>8-bit Adam</td></tr><tr><td>6</td><td>RoBERTa-base (110M)</td><td>RoBERTa-large (355M)</td></tr><tr><td>11</td><td>MT5-small (300M)</td><td>MT5-base (580M)</td></tr><tr><td>24</td><td>MT5-base (580M)</td><td>MT5-large (1.2B)</td></tr><tr><td>24</td><td>GPT-2-medium (762M)</td><td>GPT-2-large (1.5B)</td></tr></table>
116
+
117
+ # 4 ANALYSIS
118
+
119
+ We analyze our method in two ways. First, we ablate all 8-bit optimizer components and show that they are necessary for good performance. Second, we look at the sensitivity to hyperparameters compared to 32-bit Adam and show that 8-bit Adam with block-wise dynamic quantization is a reliable replacement that does not require further hyperparameter tuning.
120
+
121
+ Experimental Setup We perform our analysis on a strong 32-bit Adam baseline for language modeling with transformers (Vaswani et al., 2017). We subsample from the RoBERTa corpus (Liu et al., 2019) which consists of the English sub-datasets: Books (Zhu et al., 2015), Stories (Trinh and Le, 2018), OpenWebText-1 (Gokaslan and Cohen, 2019), Wikipedia, and CC-News (Nagel, 2016). We use a 50k token BPE encoded vocabulary (Sennrich et al., 2015). We find the best 2-GPU-day transformer baseline for 32-bit Adam with multiple hyperparameter searches that take in a total of 440 GPU days. Key hyperparameters include 10 layers with a model dimension of 1024, a fully connected hidden dimension of 8192, 16 heads, and input sub-sequences with a length of 512 tokens each. The final model has $2 0 9 \mathrm { m }$ parameters.
122
+
123
+ Table 3: Ablation analysis of 8-bit Adam for small (2 GPU days) and large-scale ( ${ \approx } 1$ GPU year) transformer language models on the RoBERTa corpus. The runs without dynamic quantization use linear quantization. The percentage of unstable runs indicates either divergence or crashed training due to exploding gradients. We report median perplexity for successful runs. We can see that dynamic quantization is critical for general stability and block-wise quantization is critical for largescale stability. The stable embedding layer is useful for both 8-bit and 32-bit Adam and enhances stability to some degree.
124
+
125
+ <table><tr><td>Parameters</td><td>Optimizer</td><td>Dynamic</td><td>Block-wise</td><td>Stable Emb</td><td>Unstable (%)</td><td>Perplexity</td></tr><tr><td rowspan="8">209M</td><td>32-bit Adam</td><td></td><td></td><td></td><td>0</td><td>16.7</td></tr><tr><td>32-bit Adam</td><td></td><td></td><td>√</td><td>0</td><td>16.3</td></tr><tr><td>8-bit Adam</td><td></td><td></td><td></td><td>90</td><td>253.0</td></tr><tr><td>8-bit Adam</td><td></td><td></td><td>√</td><td>50</td><td>194.4</td></tr><tr><td>8-bit Adam</td><td></td><td></td><td></td><td>10</td><td>18.6</td></tr><tr><td>8-bit Adam</td><td>V</td><td></td><td>√</td><td>0</td><td>17.7</td></tr><tr><td>8-bit Adam</td><td>√</td><td>√</td><td></td><td>0</td><td>16.8</td></tr><tr><td>8-bit Adam</td><td>√</td><td>√</td><td>√</td><td>0</td><td>16.4</td></tr><tr><td>1.3B</td><td>32-bit Adam</td><td></td><td></td><td></td><td>0</td><td>10.4</td></tr><tr><td>1.3B</td><td>8-bit Adam</td><td>√</td><td></td><td></td><td>100</td><td>N/A</td></tr><tr><td>1.3B</td><td>8-bit Adam</td><td>√</td><td></td><td>√</td><td>80</td><td>10.9</td></tr><tr><td>1.5B</td><td>32-bit Adam</td><td></td><td></td><td></td><td>0</td><td>9.0</td></tr><tr><td>1.5B</td><td>8-bit Adam</td><td>√</td><td>一</td><td>√</td><td>0</td><td>9.0</td></tr></table>
126
+
127
+ Ablation Analysis For the ablation analysis, we compare small and large-scale language modeling perplexity and training stability against a 32-bit Adam baseline. We ablate components individually and include combinations of methods that highlight their interactions. The baseline method uses linear quantization, and we add dynamic quantization, block-wise quantization, and the stable embedding layer to demonstrate their effect. To test optimization stability for small-scale language modeling, we run each setting with different hyperparameters and report median performance across all successful runs. A successful run is a run that does not crash due to exploding gradients or diverges in the loss. We use the hyperparameters $\epsilon$ {1e-8, 1e-7, 1e-6}, $\beta _ { 1 }$ $\{ 0 . 9 0 , \ 0 . 8 7 , \ 0 . 9 3 \}$ , $\beta _ { 2 }$ $\{ 0 . 9 9 9 , 0 . 9 9 , 0 . 9 8 \}$ and small changes in learning rates. We also include some partial ablations for large-scale models beyond 1B parameters. In the large-scale setting, we run several seeds with the same hyperparameters. We use a single seed for 32-bit Adam, five seeds for 8-bit Adam at 1.3B parameters, and a single seed for 8-bit Adam at 1.5B parameters.6 Results are shown in Table 3.
128
+
129
+ The Ablations show that dynamic quantization, block-wise quantization, and the stable embedding layer are critical for either performance or stability. In addition, block-wise quantization is critical for large-scale language model stability.
130
+
131
+ Sensitivity Analysis We compare the perplexity of 32-bit Adam vs 8-bit Adam $^ +$ Stable Embedding as we change the optimizer hyperparameters: learning rate, betas, and $\epsilon$ . We change each hyperparameter individually from the baseline hyperparameters $\beta _ { 1 } { = } 0 . 9$ , $\beta _ { 2 } { = } 0 . 9 9 5$ , $\scriptstyle \epsilon = 1 \mathrm { e } - 7$ , and $_ { \mathrm { l r = 0 . 0 1 6 3 } }$ and run two random seeds for both 8-bit and 32-bit Adam for each setting. If 8-bit Adam is perfectly insensitive to hyperparameters compared to 32-bit Adam, we would expect the same constant offset in performance for any hyperparameter combination. The results can be seen in Figure 3. The results show a relatively steady gap between 8-bit and 32-bit Adam, suggesting that 8-bit Adam does not require any further hyperparameter tuning compared to 32-bit Adam.
132
+
133
+ ![](images/a491a7b429b46d1a19aa6395663d42a67478d9b6d41c62e20cb6b0a648a555f0.jpg)
134
+ Figure 3: Sensitivity analysis of 8-bit vs 32-bit Adam hyperparameters. We can see that there is little variance between 8 and 32-bit performance, which suggests that 8-bit Adam can be used as a drop-in replacement for 32-bit Adam without any further hyperparameter tuning.
135
+
136
+ # 5 RELATED WORK
137
+
138
+ Compressing & Distributing Optimizer States While 16-bit Adam has been used in several publications, the stability of 16-bit Adam was first explicitly studied for a text-to-image generation model DALL-E (Ramesh et al., 2021). They show that a stable embedding layer, tensor-wise scaling constants for both Adam states, and multiple loss scaling blocks are critical to achieving stability during training. Our work reduces the memory footprint of Adam further, from 16 to 8-bit. In addition, we achieve stability by developing new training procedures and non-linear quantization, both of which complement previous developments.
139
+
140
+ Adafactor (Shazeer and Stern, 2018) uses a different strategy to save memory. All optimizer states are still 32-bit, but the second Adam state is factorized by a row-column outer product resulting in a comparable memory footprint to 16-bit Adam. Alternatively, Adafactor can also be used without using the first moment $\beta _ { 1 } = 0 . 0$ ) (Lepikhin et al., 2020). This version is as memory efficient as 8-bit Adam, but unlike 8-bit Adam, hyperparameters for this Adafactor variant need to be re-tuned to achieve good performance. We compare 8-bit Adam with Adafactor $\beta _ { 1 } > 0 . 0$ in our experiments.
141
+
142
+ AdaGrad (Duchi et al., 2011) adapts the gradient with aggregate training statistics over the entire training run. AdaGrad that uses only the main diagonal as optimizer state and extensions of AdaGrad such as SM3 (Anil et al., 2019) and extreme tensoring (Chen et al., 2020a) can be more efficient than 8-bit Adam. We include some initial comparison with AdaGrad in Appendix G.
143
+
144
+ Optimizer sharding (Rajbhandari et al., 2020) splits optimizer states across multiple accelerators such as GPUs/TPUs. While very effective, it can only be used if multiple accelerators are available and data parallelism is used. Optimizer sharding can also have significant communication overhead (Rajbhandari et al., 2021). Our 8-bit optimizers work with all kinds of parallelism. They can also complement optimizer sharding, as they reduce communication overhead by $7 5 \%$ .
145
+
146
+ General Memory Reduction Techniques Other complementary methods for efficient training can be either distributed or local. Distributed approaches spread out the memory of a model across several accelerators such as GPUs/TPUs. Such approaches are model parallelism (Krizhevsky et al., 2009), pipeline parallelism (Krizhevsky et al., 2009; Huang et al., 2018; Harlap et al., 2018), and operator parallelism (Lepikhin et al., 2020). These approaches are useful if one has multiple accelerators available. Our 8-bit optimizers are useful for both single and multiple devices.
147
+
148
+ Local approaches work for a single accelerator. They include gradient checkpointing (Chen et al., 2016), reversible residual connections (Gomez et al., 2017), and offloading (Pudipeddi et al., 2020;
149
+
150
+ Rajbhandari et al., 2021). All these methods save memory at the cost of increased computational or communication costs. Our 8-bit optimizers reduce the memory footprint of the model while maintaining 32-bit training speed.
151
+
152
+ Quantization Methods and Data Types While our work is the first to apply 8-bit quantization to optimizer statistics, quantization for neural network model compression, training, and inference are well-studied problems. One of the most common formats of 8-bit quantization is to use data types composed of static sign, exponent, and fraction bits. The most common combination is 5 bits for the exponent and 2 bits for the fraction (Wang et al., 2018b; Sun et al., 2019; Cambier et al., 2020; Mellempudi et al., 2019) with either no normalization or min-max normalization. These data types offer high precision for small magnitude values but have large errors for large magnitude values since only 2 bits are assigned to the fraction. Other methods improve quantization through soft constraints (Li et al., 2021) or more general uniform affine quantizations (Pappalardo, 2021).
153
+
154
+ Data types lower than 8-bit are usually used to prepare a model for deployment, and the main focus is on improving network inference speed and memory footprint rather than maintaining accuracy. There are methods that use 1-bit (Courbariaux and Bengio, 2016; Rastegari et al., 2016; Courbariaux et al., 2015), 2-bit/3 values (Zhu et al., 2017; Choi et al., 2019), 4-bits (Li et al., 2019), more bits (Courbariaux et al., 2014), or a variable amount of bits (Gong et al., 2019). See also Qin et al. (2020) for a survey on binary neural networks. While these low-bit quantization techniques allow for efficient storage, they likely lead to instability when used for optimizer states.
155
+
156
+ The work most similar to our block-wise quantization is work on Hybrid Block Floating Point (HBFP) (Drumond et al., 2018) which uses a 24-bit fraction data type with a separate exponent for each tile in matrix multiplication to perform 24-bit matrix multiplication. However, unlike HBFP, block-wise dynamic quantization has the advantage of having both block-wise normalization and a dynamic exponent for each number. This allows for a much broader range of important values since optimizer state values vary by about 5 orders of magnitude. Furthermore, unlike HBFP, block-wise quantization approximates the maximum magnitude values within each block without any quantization error, which is critical for optimization stability, particularly for large networks.
157
+
158
+ # 6 DISCUSSION & LIMITATIONS
159
+
160
+ Here we have shown that high precision quantization can yield 8-bit optimizers that maintain 32-bit optimizer performance without requiring any change in hyperparameters. One of the main limitations of our work is that 8-bit optimizers for natural language tasks require a stable embedding layer to be trained to 32-bit performance. On the other hand, we show that 32-bit optimizers also benefit from a stable embedding layer. As such, the stable embedding layer could be seen as a general replacement for other embedding layers.
161
+
162
+ We show that 8-bit optimizers reduce the memory footprint and accelerate optimization on a wide range of tasks. However, since 8-bit optimizers reduce only the memory footprint proportional to the number of parameters, models that use large amounts of activation memory and little memory for parameters, such as convolutional networks, have few benefits from using 8-bit optimizers. Thus, 8- bit optimizers are most beneficial for training or finetuning models with many parameters on highly memory-constrained GPUs.
163
+
164
+ Furthermore, there remain sources of instability that, to our knowledge, are not well understood. For example, we observed that models with over 1B parameters often have hard systemic divergence, where many parameters simultaneously cause exploding gradients. In other cases, a single parameter among those 1B parameters assumed a value too large, caused an exploding gradient, and led to a cascade of instability. It might be that this rare, soft cascading instability is related to the phenomena where instability disappears after reloading a model checkpoint and rolling a new random seed – a method standard for training huge models. This cascading instability might also be related to the observation that the larger a model is, the more unstable it becomes. For our 8-bit optimizers, we primarily needed the stable embedding layer to avoid cascading instability. Thus the stable embedding layer could potentially be viewed as decreasing the probability of extreme outlier gradients. If such phenomena were better understood, it could lead to better 8-bit optimizers and more stable training in general.
165
+
166
+ # REFERENCES
167
+
168
+ Anil, R., Gupta, V., Koren, T., and Singer, Y. (2019). Memory efficient adaptive optimization. In Wallach, H. M., Larochelle, H., Beygelzimer, A., d’Alche-Buc, F., Fox, E. B., and Garnett, R., ´ 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 9746–9755.
169
+
170
+ Ba, J. L., Kiros, J. R., and Hinton, G. E. (2016). Layer normalization. arXiv preprint arXiv:1607.06450.
171
+
172
+ Brown, T. B., Mann, B., Ryder, N., Subbiah, M., Kaplan, J., Dhariwal, P., Neelakantan, A., Shyam, P., Sastry, G., Askell, A., et al. (2020). Language models are few-shot learners. arXiv preprint arXiv:2005.14165.
173
+
174
+ Cambier, L., Bhiwandiwalla, A., Gong, T., Elibol, O. H., Nekuii, M., and Tang, H. (2020). Shifted and squeezed 8-bit floating point format for low-precision training of deep neural networks. In 8th International Conference on Learning Representations, ICLR 2020, Addis Ababa, Ethiopia, April 26-30, 2020. OpenReview.net.
175
+
176
+ Chen, E. J. and Kelton, W. D. (2001). Quantile and histogram estimation. In Proceeding of the 2001 Winter Simulation Conference (Cat. No. 01CH37304), volume 1, pages 451–459. IEEE.
177
+
178
+ Chen, T., Xu, B., Zhang, C., and Guestrin, C. (2016). Training deep nets with sublinear memory cost. arXiv preprint arXiv:1604.06174.
179
+
180
+ Chen, X., Agarwal, N., Hazan, E., Zhang, C., and Zhang, Y. (2020a). Extreme tensoring for lowmemory preconditioning. In 8th International Conference on Learning Representations, ICLR 2020, Addis Ababa, Ethiopia, April 26-30, 2020. OpenReview.net.
181
+
182
+ Chen, X., Fan, H., Girshick, R., and He, K. (2020b). Improved baselines with momentum contrastive learning. arXiv preprint arXiv:2003.04297.
183
+
184
+ Choi, J., Venkataramani, S., Srinivasan, V., Gopalakrishnan, K., Wang, Z., and Chuang, P. (2019). Accurate and efficient 2-bit quantized neural networks. In Talwalkar, A., Smith, V., and Zaharia, M., editors, Proceedings of Machine Learning and Systems 2019, MLSys 2019, Stanford, CA, USA, March 31 - April 2, 2019. mlsys.org.
185
+
186
+ Courbariaux, M. and Bengio, Y. (2016). Binarynet: Training deep neural networks with weights and activations constrained to $+ 1$ or -1. CoRR, abs/1602.02830.
187
+
188
+ Courbariaux, M., Bengio, Y., and David, J. (2015). Binaryconnect: Training deep neural networks with binary weights during propagations. In Cortes, C., Lawrence, N. D., Lee, D. D., Sugiyama, M., and Garnett, R., editors, Advances in Neural Information Processing Systems 28: Annual Conference on Neural Information Processing Systems 2015, December 7-12, 2015, Montreal, Quebec, Canada, pages 3123–3131.
189
+
190
+ Courbariaux, M., Bengio, Y., and David, J.-P. (2014). Training deep neural networks with low precision multiplications. arXiv preprint arXiv:1412.7024.
191
+
192
+ Deng, J., Dong, W., Socher, R., Li, L.-J., Li, K., and Fei-Fei, L. (2009). Imagenet: A large-scale hierarchical image database. In 2009 IEEE conference on computer vision and pattern recognition, pages 248–255. Ieee.
193
+
194
+ Dettmers, T. (2016). 8-bit approximations for parallelism in deep learning. International Conference on Learning Representations (ICLR).
195
+
196
+ Devlin, J., Chang, M., Lee, K., and Toutanova, K. (2019). BERT: pre-training of deep bidirectional transformers for language understanding. In Burstein, J., Doran, C., and Solorio, T., 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.
197
+
198
+ Drumond, M., Lin, T., Jaggi, M., and Falsafi, B. (2018). Training dnns with hybrid block floating point. In Bengio, S., Wallach, H. M., Larochelle, H., Grauman, K., Cesa-Bianchi, N., and Garnett, R., editors, Advances in Neural Information Processing Systems 31: Annual Conference on Neural Information Processing Systems 2018, NeurIPS 2018, December 3-8, 2018, Montreal, ´ Canada, pages 451–461.
199
+
200
+ Duchi, J., Hazan, E., and Singer, Y. (2011). Adaptive subgradient methods for online learning and stochastic optimization. Journal of machine learning research, 12(7).
201
+
202
+ Dunning, T. and Ertl, O. (2019). Computing extremely accurate quantiles using t-digests. arXiv preprint arXiv:1902.04023.
203
+
204
+ Fedus, W., Zoph, B., and Shazeer, N. (2021). Switch transformers: Scaling to trillion parameter models with simple and efficient sparsity. arXiv preprint arXiv:2101.03961.
205
+
206
+ Glorot, X. and Bengio, Y. (2010). Understanding the difficulty of training deep feedforward neural networks. In Proceedings of the thirteenth international conference on artificial intelligence and statistics, pages 249–256. JMLR Workshop and Conference Proceedings.
207
+
208
+ Gokaslan, A. and Cohen, V. (2019). Openwebtext corpus.
209
+
210
+ Gomez, A. N., Ren, M., Urtasun, R., and Grosse, R. B. (2017). The reversible residual network: Backpropagation without storing activations. arXiv preprint arXiv:1707.04585.
211
+
212
+ Gong, R., Liu, X., Jiang, S., Li, T., Hu, P., Lin, J., Yu, F., and Yan, J. (2019). Differentiable soft quantization: Bridging full-precision and low-bit neural networks. In 2019 IEEE/CVF International Conference on Computer Vision, ICCV 2019, Seoul, Korea (South), October 27 - November 2, 2019, pages 4851–4860. IEEE.
213
+
214
+ Govindaraju, N. K., Raghuvanshi, N., and Manocha, D. (2005). Fast and approximate stream mining of quantiles and frequencies using graphics processors. In Proceedings of the 2005 ACM SIGMOD international conference on Management of data, pages 611–622.
215
+
216
+ Greenwald, M. and Khanna, S. (2001). Space-efficient online computation of quantile summaries. ACM SIGMOD Record, 30(2):58–66.
217
+
218
+ Harlap, A., Narayanan, D., Phanishayee, A., Seshadri, V., Devanur, N., Ganger, G., and Gibbons, P. (2018). Pipedream: Fast and efficient pipeline parallel dnn training. arXiv preprint arXiv:1806.03377.
219
+
220
+ 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.
221
+
222
+ Henighan, T., Kaplan, J., Katz, M., Chen, M., Hesse, C., Jackson, J., Jun, H., Brown, T. B., Dhariwal, P., Gray, S., et al. (2020). Scaling laws for autoregressive generative modeling. arXiv preprint arXiv:2010.14701.
223
+
224
+ Huang, Y., Cheng, Y., Bapna, A., Firat, O., Chen, M. X., Chen, D., Lee, H., Ngiam, J., Le, Q. V., Wu, Y., et al. (2018). Gpipe: Efficient training of giant neural networks using pipeline parallelism. arXiv preprint arXiv:1811.06965.
225
+
226
+ Kaplan, J., McCandlish, S., Henighan, T., Brown, T. B., Chess, B., Child, R., Gray, S., Radford, A., Wu, J., and Amodei, D. (2020). Scaling laws for neural language models. arXiv preprint arXiv:2001.08361.
227
+
228
+ Keskar, N. S., McCann, B., Varshney, L. R., Xiong, C., and Socher, R. (2019). CTRL: A conditional transformer language model for controllable generation. CoRR, abs/1909.05858.
229
+
230
+ Kingma, D. P. and Ba, J. (2014). Adam: A method for stochastic optimization. arXiv preprint arXiv:1412.6980.
231
+
232
+ Krizhevsky, A., Hinton, G., et al. (2009). Learning multiple layers of features from tiny images.
233
+
234
+ Lepikhin, D., Lee, H., Xu, Y., Chen, D., Firat, O., Huang, Y., Krikun, M., Shazeer, N., and Chen, Z. (2020). Gshard: Scaling giant models with conditional computation and automatic sharding. arXiv preprint arXiv:2006.16668.
235
+
236
+ Lewis, M., Bhosale, S., Dettmers, T., Goyal, N., and Zettlemoyer, L. (2021). Base layers: Simplifying training of large, sparse models. arXiv preprint arXiv:2103.16716.
237
+
238
+ Lewis, M., Liu, Y., Goyal, N., Ghazvininejad, M., Mohamed, A., Levy, O., Stoyanov, V., and Zettlemoyer, L. (2020). BART: denoising sequence-to-sequence pre-training for natural language generation, translation, and comprehension. In Jurafsky, D., Chai, J., Schluter, N., and Tetreault, J. R., editors, Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics, ACL 2020, Online, July 5-10, 2020, pages 7871–7880. Association for Computational Linguistics.
239
+
240
+ Li, J. B., Qu, S., Li, X., Strubell, E., and Metze, F. (2021). End-to-end quantized training via log-barrier extensions.
241
+
242
+ Li, R., Wang, Y., Liang, F., Qin, H., Yan, J., and Fan, R. (2019). Fully quantized network for object detection. In IEEE Conference on Computer Vision and Pattern Recognition, CVPR 2019, Long Beach, CA, USA, June 16-20, 2019, pages 2810–2819. Computer Vision Foundation / IEEE.
243
+
244
+ Liu, Y., Ott, M., Goyal, N., Du, J., Joshi, M., Chen, D., Levy, O., Lewis, M., Zettlemoyer, L., and Stoyanov, V. (2019). Roberta: A robustly optimized bert pretraining approach. arXiv preprint arXiv:1907.11692.
245
+
246
+ Loshchilov, I. and Hutter, F. (2018). Fixing weight decay regularization in adam.
247
+
248
+ Macha´cek, M. and Bojar, O. (2014). Results of the wmt14 metrics shared task. In ˇ Proceedings of the Ninth Workshop on Statistical Machine Translation, pages 293–301.
249
+
250
+ Mellempudi, N., Srinivasan, S., Das, D., and Kaul, B. (2019). Mixed precision training with 8-bit floating point. CoRR, abs/1905.12334.
251
+
252
+ Micikevicius, P., Narang, S., Alben, J., Diamos, G., Elsen, E., Garcia, D., Ginsburg, B., Houston, M., Kuchaiev, O., Venkatesh, G., et al. (2017). Mixed precision training. arXiv preprint arXiv:1710.03740.
253
+
254
+ Nagel, S. (2016). Cc-news.
255
+
256
+ Ott, M., Edunov, S., Baevski, A., Fan, A., Gross, S., Ng, N., Grangier, D., and Auli, M. (2019). fairseq: A fast, extensible toolkit for sequence modeling. arXiv preprint arXiv:1904.01038.
257
+
258
+ Ott, M., Edunov, S., Grangier, D., and Auli, M. (2018). Scaling neural machine translation. arXiv preprint arXiv:1806.00187.
259
+
260
+ Pappalardo, A. (2021). Xilinx/brevitas.
261
+
262
+ Pudipeddi, B., Mesmakhosroshahi, M., Xi, J., and Bharadwaj, S. (2020). Training large neural networks with constant memory using a new execution algorithm. arXiv preprint arXiv:2002.05645.
263
+
264
+ Qian, N. (1999). On the momentum term in gradient descent learning algorithms. Neural networks : the official journal of the International Neural Network Society, 12 1:145–151.
265
+
266
+ Qin, H., Gong, R., Liu, X., Bai, X., Song, J., and Sebe, N. (2020). Binary neural networks: A survey. CoRR, abs/2004.03333.
267
+
268
+ Radford, A., Wu, J., Child, R., Luan, D., Amodei, D., and Sutskever, I. (2019). Language models are unsupervised multitask learners. OpenAI blog, 1(8):9.
269
+
270
+ Raffel, C., Shazeer, N., Roberts, A., Lee, K., Narang, S., Matena, M., Zhou, Y., Li, W., and Liu, P. J. (2019). Exploring the limits of transfer learning with a unified text-to-text transformer. arXiv preprint arXiv:1910.10683.
271
+
272
+ Rajbhandari, S., Rasley, J., Ruwase, O., and He, Y. (2020). Zero: Memory optimizations toward training trillion parameter models. In SC20: International Conference for High Performance Computing, Networking, Storage and Analysis, pages 1–16. IEEE.
273
+ Rajbhandari, S., Ruwase, O., Rasley, J., Smith, S., and He, Y. (2021). Zero-infinity: Breaking the gpu memory wall for extreme scale deep learning. arXiv preprint arXiv:2104.07857.
274
+ Ramesh, A., Pavlov, M., Goh, G., Gray, S., Voss, C., Radford, A., Chen, M., and Sutskever, I. (2021). Zero-shot text-to-image generation. arXiv preprint arXiv:2102.12092.
275
+ Rastegari, M., Ordonez, V., Redmon, J., and Farhadi, A. (2016). Xnor-net: Imagenet classification using binary convolutional neural networks. In Leibe, B., Matas, J., Sebe, N., and Welling, M., editors, Computer Vision - ECCV 2016 - 14th European Conference, Amsterdam, The Netherlands, October 11-14, 2016, Proceedings, Part IV, volume 9908 of Lecture Notes in Computer Science, pages 525–542. Springer.
276
+ Sennrich, R., Haddow, B., and Birch, A. (2015). Neural machine translation of rare words with subword units. arXiv preprint arXiv:1508.07909.
277
+ Sennrich, R., Haddow, B., and Birch, A. (2016). Edinburgh neural machine translation systems for wmt 16. arXiv preprint arXiv:1606.02891.
278
+ Shazeer, N. and Stern, M. (2018). Adafactor: Adaptive learning rates with sublinear memory cost. In International Conference on Machine Learning, pages 4596–4604. PMLR.
279
+ Shoeybi, M., Patwary, M., Puri, R., LeGresley, P., Casper, J., and Catanzaro, B. (2019). Megatronlm: Training multi-billion parameter language models using model parallelism. arXiv preprint arXiv:1909.08053.
280
+ Sun, X., Choi, J., Chen, C., Wang, N., Venkataramani, S., Srinivasan, V., Cui, X., Zhang, W., and Gopalakrishnan, K. (2019). Hybrid 8-bit floating point (HFP8) training and inference for deep neural networks. In Wallach, H. M., Larochelle, H., Beygelzimer, A., d’Alche-Buc, F., Fox, ´ E. B., and Garnett, R., 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 4901–4910.
281
+ Trinh, T. H. and Le, Q. V. (2018). A simple method for commonsense reasoning. arXiv preprint arXiv:1806.02847.
282
+ Vaswani, A., Shazeer, N., Parmar, N., Uszkoreit, J., Jones, L., Gomez, A. N., Kaiser, L., and Polosukhin, I. (2017). Attention is all you need. arXiv preprint arXiv:1706.03762.
283
+ Wang, A., Singh, A., Michael, J., Hill, F., Levy, O., and Bowman, S. R. (2018a). Glue: A multi-task benchmark and analysis platform for natural language understanding. arXiv preprint arXiv:1804.07461.
284
+ Wang, N., Choi, J., Brand, D., Chen, C., and Gopalakrishnan, K. (2018b). Training deep neural networks with 8-bit floating point numbers. In Bengio, S., Wallach, H. M., Larochelle, H., Grauman, K., Cesa-Bianchi, N., and Garnett, R., editors, Advances in Neural Information Processing Systems 31: Annual Conference on Neural Information Processing Systems 2018, NeurIPS 2018, December 3-8, 2018, Montreal, Canada ´ , pages 7686–7695.
285
+ Wenzek, G., Lachaux, M.-A., Conneau, A., Chaudhary, V., Guzman, F., Joulin, A., and Grave, E. ´ (2020). CCNet: Extracting high quality monolingual datasets from web crawl data. In Proceedings of the 12th Language Resources and Evaluation Conference, pages 4003–4012, Marseille, France. European Language Resources Association.
286
+ Zhu, C., Han, S., Mao, H., and Dally, W. J. (2017). Trained ternary quantization. In 5th International Conference on Learning Representations, ICLR 2017, Toulon, France, April 24-26, 2017, Conference Track Proceedings. OpenReview.net.
287
+ Zhu, Y., Kiros, R., Zemel, R., Salakhutdinov, R., Urtasun, R., Torralba, A., and Fidler, S. (2015). Aligning books and movies: Towards story-like visual explanations by watching movies and reading books. In Proceedings of the IEEE international conference on computer vision, pages 19–27.
288
+
289
+ # A GLUE SCORE BREAKDOWN
290
+
291
+ Table 4 contains the breakdown of individual scores on the GLUE datasets.
292
+
293
+ Table 4: Breakdown of GLUE scores. Each column is the median of 10 random seeds. The mean is the mean over medians.
294
+
295
+ <table><tr><td>Model</td><td>MNLI</td><td>QNLI</td><td>QQP</td><td>RTE</td><td>SST-2</td><td>MRPC</td><td>CoLA</td><td>STS-B</td><td>Mean</td></tr><tr><td>32-bit Adam</td><td>90.40</td><td>94.85</td><td>92.2</td><td>84.5</td><td>96.40</td><td>90.1</td><td>67.41</td><td>93.03</td><td>88.61</td></tr><tr><td>32-bit Adafactor</td><td>90.35</td><td>94.70</td><td>92.2</td><td>85.4</td><td>96.45</td><td>90.0</td><td>67.63</td><td>92.91</td><td>88.71</td></tr><tr><td>8-bit Adam</td><td>90.30</td><td>94.70</td><td>92.2</td><td>85.9</td><td>96.40</td><td>90.3</td><td>67.20</td><td>92.87</td><td>88.73</td></tr></table>
296
+
297
+ # B STABILITY OF EMBEDDING LAYERS
298
+
299
+ Highly variable gradients can lead to unpredictable optimization behavior and instability that manifests as divergence or exploding gradients. Low precision optimziers can amplify variance of gradient updates due to the noise introduced during quantization. While our 8-bit optimizers appear to be stable for convolutional networks, similar to Ramesh et al. (2021), we find that word embedding layers are a major source of instability.
300
+
301
+ The main instability from the word embedding layer comes from the fact that it is a sparse layer with non-uniform distribution of inputs which can produce maximum gradient magnitudes $1 0 0 \mathrm { x }$ larger than other layers. For dense layers, if given $n$ samples arranged into $k$ mini-batches the sum of gradients of all mini-batches is always the same independent of how the $n$ samples are arranged into $k$ mini-batches. For embedding gradients, this depends on the arrangement of samples into mini-batches. This is because most deep learning frameworks normalize the gradient by the number of total tokens in the mini-batch, rather than the frequency of each individual token. This approximation allows stable learning with a single learning rate rather than variable learning rates that depend on token frequency in each individual mini-batch. However a side-effect of this method is that the magnitude of gradients for a particular token can vary widely with batch sizes and between different mini-batches.
302
+
303
+ There are multiple recipes for initialization word embedding layers. One of the most common recipes used in all models trained with fairseq (Ott et al., 2019) such as RoBERTa (Liu et al., 2019), BART (Lewis et al., 2020), large NMT models (Ott et al., 2018), and sparse expert models (Lewis√ et al., 2021), is the following: Initialize the word embedding layer with $N ( 0 , 1 / { \sqrt { k } } )$ where $k$ is the embedding size of the embedding layer and to scale the outputs by $\sqrt { k }$ . This scheme has a variance of one at the start of training for the output distribution to ensure good gradient flow.
304
+
305
+ We find this approach to induce some instability for 8-bit optimizers. We develop the stable embedding layer to solve this instability problem.
306
+
307
+ While the full recipe for our stable embedding layer is new, components of it has been used before. The layer norm after the embedding has been used before in work such as Devlin et al. (2019) and Radford et al. (2019) and enhanced precision for this particular layer was used in Ramesh et al. (2021). As pointed out above, these elements are not standard and the stable embedding layer combines three aspects that are all important: (1) enhanced precision, (2) layer norm, and (3) Xavier initialization.
308
+
309
+ # C QUANTIZATION ERROR ANALYSIS
310
+
311
+ To gain more insights into why block-wise dynamic quantization works so well and how it could be improved, we performed a quantization error analysis of Adam quantization errors during language model training. Adam quantization errors are the deviations between the quantized 8-bit Adam update and the 32-bit Adam updates: $\lvert \mathbf { u 8 } - \mathbf { u _ { 1 6 } } \rvert$ , where $\mathbf { u } _ { \mathbf { k } } = \mathbf { s _ { 1 } ^ { k } } / \mathbf { s _ { 2 } ^ { k } }$ for $k$ bits. See Background Section 1.1 for details on Adam.
312
+
313
+ A good 8-bit quantization has the property that, for a given input distribution, the inputs are only rarely quantized into intervals with high quantization error and most often quantized into intervals with low error.
314
+
315
+ In 8-bit, there are $2 5 5 \times 2 5 6$ possible 8-bit Adam updates, 256 possible values for the first and 256 for the second Adam state. We look at the average quantization error of each of these possible updates to see where the largest errors are and we plot histograms to see how often do these values with high error occur. Taken together, these two perspectives give a detailed view of the magnitude of deviations and how often large deviations occur.
316
+
317
+ We study these questions by looking at how often each of the 256 values for both Adam states are used during language model training. We also analyze the average error for each of the inputs quantized to each of the 256 values. With this analysis it is easy to find regions of high use and high error, and visualize their overlap. An overlap of these regions is associated with large frequent errors that cause unstable training. The quantization error analysis is shown in Figure 4.
318
+
319
+ The plots show two things: (1) The region of high usage (histogram) shows how often each combination of $2 5 6 \times 2 5 6$ bit values is used for the first Adam state $\mathbf { s _ { 1 } }$ (exponentially smoothed running sum) and the second Adam state $\mathbf { s _ { 2 } }$ (exponentially smoothed running squared sum). (2) The error plots show for $k$ -bit Adam updates $\mathbf { u _ { k } } = \mathbf { s _ { 1 } } / ( \sqrt { \mathbf { s _ { 2 } } } + \epsilon )$ the mean absolute Adam error $| u _ { 3 2 } - u _ { 8 } |$ and the relative Adam error $| \boldsymbol { u } _ { 3 2 } - \boldsymbol { u } _ { 8 } | / | \boldsymbol { u } _ { 3 2 } |$ averaged over each bit combination. In conjunction these plots show which bits have the highest error per use and how often each bit is used. The $\mathbf { X }$ - axis/y-axis represents the quantization type range which means the largest positive/negative Adam states per block/tensor take the values $1 . 0 / - 1 . 0 $ .
320
+
321
+ We can see that block-wise dynamic quantization has the smallest overlap between regions of high use and high error. While the absolute Adam quantization error of block-wise dynamic quantization is 0.0061, which is not much lower than that of dynamic quantization with 0.0067, the plots can also be interpreted as block-wise dynamic having rarer large errors that likely contribute to improved stability during optimization.
322
+
323
+ # D FINE-GRAINED OPTIMIZER RUNTIME PERFORMANCE
324
+
325
+ Table 5 shows optimizer performance that is benchmarked in isolation without any training. We use a large sample of a normal distribution and benchmark the average time to perform 100 optimizer updates per billion parameters in milliseconds.
326
+
327
+ Table 5: Runtime performance of 8-bit optimizers vs commonly used 32-bit optimizers in milliseconds per update per 1B parameters for 32-bit gradients. This comparision was run on a V100 GPU.
328
+
329
+ <table><tr><td></td><td colspan="3">Milliseconds per update per 1B param</td></tr><tr><td>Optimizer</td><td>32-bit PyTorch</td><td>32-bit Apex</td><td>8-bit (Ours)</td></tr><tr><td>Adam</td><td>145</td><td>63</td><td>47</td></tr><tr><td>Momentum</td><td>58</td><td>46</td><td>34</td></tr><tr><td>LAMB</td><td></td><td>91</td><td>65</td></tr><tr><td>LARS</td><td>1</td><td>119</td><td>43</td></tr></table>
330
+
331
+ # E ADDITIONAL QUANTIZATION DATA TYPES
332
+
333
+ This section describes additional quantization data types that we tried but which we found to perform poorly in quantization performance or stability. While quantile quantization has an average quantization twice as low as dynamic quantization for any normal distribution it has sporadic large errors that lead to large Adam errors and poor model performance (see Figure 5) and even with state-of-the-art quantile estimation algorithms (see Section F) quantile quantization is too slow to be practical. An overview of quantization performance of this additional quantization data types compared to dynamic quantization (without block-wise quantization) can be found in Table 6.
334
+
335
+ ![](images/eb34d99c35d797a1f3ec0e6b74881b63bc240858d5694fea2e006b563e0edd2a.jpg)
336
+ Figure 4: Good quantization methods do not have overlaps between regions of high use and high error. The plot shows that for linear quantization regions of high usage and high error overlap. For dynamic quantization regions with high relative error are used infrequently while only small regions have high usage and high absolute error. Block-wise dynamic quantization spreads out the usage over a large space and has the lowest overlap between regions of high use and errors. This means that not only is the overall error of block-wise dynamic quantization lower, but also that large errors for individual parameter updates are rarer compared to other methods, thus improving stability. See the main text for more details.
337
+
338
+ Table 6: Mean relative Adam and absolute quantization error for the first Adam state for different quantization methods. Results show mean±standard error. We can see that Dynamic Quantization has best relative error and that both Dynamic methods have the best absolute error.
339
+
340
+ <table><tr><td>Method</td><td>Relative Adam Error</td><td>Absolute Quantization Error</td></tr><tr><td>Linear</td><td>201% ±17%</td><td>41.2e-10±3.1e-10</td></tr><tr><td>Quantile</td><td>11.9% ± 0.3%</td><td>8.8e-10±0.9e-10</td></tr><tr><td>Inverse Dynamic</td><td>6.5%± 0.1%</td><td>4.6e-10±0.4e-10</td></tr><tr><td>Dynamic</td><td>4.8%± 0.4%</td><td>3.5e-10±1.1e-10</td></tr></table>
341
+
342
+ ![](images/1302c59d4d0e7dc6fd72b7500bf52e0c6114846c7c1b4c951a11a58a3bce8316.jpg)
343
+ Figure 5: Distribution of Adam error among each of the 256 8-bit values of the first Adam state. We normalize the values into the range [-1,1]. With this, -1 indicates the largest negative value, 0 the value that is closest to 0, and so forth. See Figure 6 for a visualization of this normalization. Quantile quantization has large errors for large values, while dynamic quantization has small errors for both small and large values while the bulk of the errors is concentrated in intermediate values.
344
+
345
+ # E.1 INVERSE DYNAMIC QUANTIZATION
346
+
347
+ Inverse Dynamic Quantization is motivated by the hypothesis that large Adam updates are more important than small updates. Since Adam is composed of a ratio of optimizer states $\mathbf { m } _ { t } / ( \sqrt { \mathbf { r } _ { t } } + \epsilon )$ , we expect that small values in the second state $\mathbf { r } _ { t }$ to produce large Adam updates. To get a better quantization error for small values we can switch the dynamic exponent and the base exponent. For regular dynamic quantization the base exponent is $1 0 ^ { 0 } \stackrel { } { = } 1$ and each zero bit decreases the exponent by a factor of 10 for a minimum value of $\mathrm { \dot { 1 } 0 ^ { - 7 } }$ . We invert this starting with base $1 0 ^ { - 7 }$ and each zero bit increases the exponent by 10 for a maximum value of 1. We denote this quantization as inverse dynamic quantization.
348
+
349
+ # E.2 QUANTILE QUANTIZATION: A LOSSY MINIMUM ENTROPY ENCODING
350
+
351
+ A lossy minimum entropy encoding with $k$ bits has the property that for any input data, the quantized outputs take the value of each of the $2 ^ { k }$ different bit representations equally often.
352
+
353
+ More formally, a lossy minimum entropy encoding can be described in the following way. Given an infinite stream of sampled real numbers $x _ { i }$ where $x _ { i }$ is distributed as $X$ , an arbitrary probability distribution, a lossy minimum entropy encoding is given by the $k$ -bit quantization map $\mathbf { Q } ^ { \mathrm { m a p } } \in \mathbb { R } ^ { 2 ^ { k } }$ which maps values $q \in \mathbb { R } ^ { 2 ^ { k } }$ to indices $0 , 1 , \ldots 2 ^ { k }$ which has the property that if any number of elements $x _ { i }$ from the stream are quantized to $x _ { i } ^ { q }$ we do not gain any information which is predictive of future x j>i.
354
+
355
+ One way to fulfill this property for arbitrary probability distributions $X$ , is to divide the probability distribution function $f _ { X }$ into $\bar { 2 } ^ { k }$ bins where each bin has equal area and the mid-points of these bins are values $q$ of the quantization map $\mathbf { Q } ^ { \mathrm { m a p } }$ . Empirically, this is equivalent to a histogram with $2 ^ { k }$ bins where each bin contains equal number of values.
356
+
357
+ How do we find the mid-points for each histogram bin? This is equivalent to finding the $2 ^ { k }$ nonoverlapping values $x$ for the cumulative distribution function $F _ { X }$ with equal probability mass. These values can most easily be found by using its inverse function, the quantile function $\dot { Q _ { X } } = F _ { X } ^ { - 1 }$ . We can find the mid-points of each of the histogram bins by using the mid-points between $2 ^ { k } + 1$ equally spaced quantiles over the range of probabilities $[ 0 , 1 ]$ :
358
+
359
+ $$
360
+ q _ { i } = \frac { Q _ { X } \left( \frac { i } { 2 ^ { k } + 1 } \right) + Q _ { X } \left( \frac { i + 1 } { 2 ^ { k } + 1 } \right) } { 2 } ,
361
+ $$
362
+
363
+ To find $q$ empirically, we can estimate sample quantiles for a tensor $\mathbf { T }$ with unknown distribution $X$ by finding the $2 ^ { k }$ equally spaced sample quantiles via $\mathbf { T }$ ’s empirical cumulative distribution function. We refer to this quantization as quantile quantization.
364
+
365
+ To estimate sample quantiles efficiently, we devise a specialized approximate quantile estimation algorithm, SRAM-Quantiles, which is more than $7 5 \mathrm { x }$ faster than other approximate quantile estimation approaches (Govindaraju et al., 2005; Dunning and Ertl, 2019). SRAM-Quantiles uses a divide-and-conquer strategy to perform sorting solely in fast SRAM. More details on this algorithm can be found in the Appendix Section F.
366
+
367
+ # E.3 VISUALIZATION: DYNAMIC VS LINEAR QUANTIZATION VS QUANTILE QUANTIZATION
368
+
369
+ Figure 6 shows the mapping from each to the 255 values of the 8-bit data types to their value normalized in the range [-1, 1]. We can see that most bits in dynamic quantization are allocated for large and small values. Quantile quantization is introduced in Appendix E.2.
370
+
371
+ ![](images/f0d98d3f97aad7ab5339ec027d769877c41d7f7028de27f5029c043996811292.jpg)
372
+ Figure 6: Visualization of the quantization maps for the linear, dynamic and quantile quantization. For quantile quantization we use values from the standard normal distribution and normalize them into the range [-1, 1].
373
+
374
+ # F SRAM-QUANTILES: A FAST QUANTILE ESTIMATION ALGORITHM
375
+
376
+ To estimate sample quantiles of a tensor one needs to determine the empirical cumulative distribution function (eCDF) of that tensor. The easiest way to find the eCDF is to sort a given tensor. Once sorted, the quantiles can be found by using the value at index $i = q \times n$ where $i$ is the index into the sorted array, $q$ is the desired quantile and $n$ is the total elements in the tensor. While simple, this process of estimating quantiles is computationally expensive and would render training with quantile quantization too slow to be useful.
377
+
378
+ Similar to other quantile estimation approaches, our GPU algorithm, SRAM-Quantiles, uses a sliding windows over the data for fast, approximate quantile estimation with minimal resources. Greenwald and Khanna (2001)’s quantile estimation algorithm uses dynamic bin histograms over sliding windows to estimate quantiles. Extensions of this algorithm accelerate estimation by using more efficient data structures and estimation algorithms (Dunning and Ertl, 2019) or by using GPUs (Govindaraju et al., 2005). The main difference between this work an ours is that we only compute a limit set of quantiles that are known a priori – 256, to be exact – while previous work focuses on general statistics which help to produce any quantile a posteriori. Thus we can devise a highly specialized algorithm which offers faster estimation.
379
+
380
+ The idea behind our algorithm comes from the fact that sorting is slow because it involves repeated loads and stores from main memory (DRAM) when executing divide-and-conquer sorting algorithms. We can significantly improve performance of quantile estimation if we restructure quantile estimation to respect memory hierarchies of the device on which the algorithm is executed.
381
+
382
+ On a GPU, programmable SRAM – known as shared memory – is $1 5 \mathrm { x }$ faster than DRAM but has a limit size of around $6 4 \mathrm { k b }$ per core. The SRAM-Quantiles algorithm is simple. Instead of finding the full eCDF we find the eCDF for a subset of values of the tensor that fits into SRAM (about 4096 32-bit values). Once we found the quantiles for each subset, we average the quantiles atomically in DRAM.
383
+
384
+ This algorithm works, because the arithmetic mean is an unbiased estimator for the population mean and samples quantiles estimated via eCDFs are asymptotically unbiased estimators of the population quantile (Chen and Kelton, 2001). Thus the more subset quantiles we average, the better the estimate of the tensor-wide quantiles.
385
+
386
+ For estimating 256 quantiles on a large stream of numbers, our algorithm takes on average 0.064 ns to process one element in the stream, whereas the fastest general algorithms take 300 ns (Govindaraju et al., 2005) and 5 ns (Dunning and Ertl, 2019).
387
+
388
+ # G ADAGRAD COMPARISONS
389
+
390
+ While the main aim in this work is to investigate how the most commonly used optimizers, such as Adam (Kingma and Ba, 2014) and Momentum (Qian, 1999), can be used as 8-bit variants without any further hyperparameter tuning, it can be of interest to consider the behavior of our 8-bit methods under different scenarios. For example, one difference between Adam/Momentum and AdaGrad (Duchi et al., 2011) is that AdaGrad accumulates gradients statistics over the entire course of training while Adam/Momentum use a smoothed exponential decay over time. As such, this could lead to very different 8-bit quantization behavior where there are large difference between the magnitude of different optimizer states. Such large differences could induce a large quantization error and degrade performance of 8-bit optimizers.
391
+
392
+ To investigate this, we train small 209M parameter language models on the RoBERTa corpus (Liu et al., 2019). We use the AdaGrad hyperparameters introduced by Keskar et al. (2019). Results are shown in Table 7. From the results we can see that our 8-bit methods do not work as well for AdaGrad. One hypothesis is that this is due to the the wide range of gradient statistics of AdaGrad which comes from averaging the gradient over the entire course of training. To prevent poor quantization in such scenarios, stochastic rounding proved to be very effective from our initial experiments with other 8-bit optimizer. While we abandoned stochastic rounding because we did not see any benefits for Adam and Momentum, it could be an effective solution for AdaGrad. We leave such improved 8-bit quantization methods for AdaGrad to future work.
393
+
394
+ Table 7: AdaGrad compared to Adam performance for a 209M parameter language model on the RoBERTa corpus. The 8-bit methods use stable embedding layer. AdaGrad hyperparamters are taken from (Keskar et al., 2019).
395
+
396
+ <table><tr><td>Optimizer</td><td>Valid Perplexity</td></tr><tr><td>32-bit Adam 8-bit Adam</td><td>16.7</td></tr><tr><td>32-bit AdaGrad</td><td>16.4 19.4</td></tr><tr><td>8-bit AdaGrad</td><td>19.7</td></tr><tr><td></td><td></td></tr></table>
md/dev/tHK5ntjp-5K/tHK5ntjp-5K.md ADDED
@@ -0,0 +1,445 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # LION: Latent Point Diffusion Models for 3D Shape Generation
2
+
3
+ Xiaohui Zeng1,2,3,∗ Arash Vahdat1 Francis Williams1
4
+
5
+ Zan Gojcic1 Or Litany1 Sanja Fidler1,2,3 Karsten Kreis1
6
+
7
+ 1NVIDIA 2University of Toronto 3Vector Institute {xzeng,avahdat,fwilliams,zgojcic,olitany,sfidler,kkreis}@nvidia.com
8
+
9
+ # Abstract
10
+
11
+ Denoising diffusion models (DDMs) have shown promising results in 3D point cloud synthesis. To advance 3D DDMs and make them useful for digital artists, we require (i) high generation quality, (ii) flexibility for manipulation and applications such as conditional synthesis and shape interpolation, and (iii) the ability to output smooth surfaces or meshes. To this end, we introduce the hierarchical Latent Point Diffusion Model (LION) for 3D shape generation. LION is set up as a variational autoencoder (VAE) with a hierarchical latent space that combines a global shape latent representation with a point-structured latent space. For generation, we train two hierarchical DDMs in these latent spaces. The hierarchical VAE approach boosts performance compared to DDMs that operate on point clouds directly, while the point-structured latents are still ideally suited for DDM-based modeling. Experimentally, LION achieves state-of-the-art generation performance on multiple ShapeNet benchmarks. Furthermore, our VAE framework allows us to easily use LION for different relevant tasks: LION excels at multimodal shape denoising and voxel-conditioned synthesis, and it can be adapted for text- and image-driven 3D generation. We also demonstrate shape autoencoding and latent shape interpolation, and we augment LION with modern surface reconstruction techniques to generate smooth 3D meshes. We hope that LION provides a powerful tool for artists working with 3D shapes due to its high-quality generation, flexibility, and surface reconstruction. Project page and code: https://nv-tlabs.github.io/LION.
12
+
13
+ # 1 Introduction
14
+
15
+ Generative modeling of 3D shapes has extensive applications in 3D content creation and has become an active area of research [1–52]. However, to be useful as a tool for digital artists, generative models of 3D shapes have to fulfill several criteria: (i) Generated shapes need to be realistic and of highquality without artifacts. (ii) The model should enable flexible and interactive use and refinement: For example, a user may want to refine a generated shape and synthesize versions with varying details. Or an artist may provide a coarse or noisy input shape, thereby guiding the model to produce multiple realistic high-quality outputs. Similarly, a user may want to interpolate different shapes. (iii) The model should output smooth meshes, which are the standard representation in most graphics software.
16
+
17
+ Existing 3D generative models build on various frameworks, including generative adversarial networks (GANs) [1–23], variational autoencoders (VAEs) [24–30], normalizing flows [31–34], autoregressive models [35–38], and more [39–44]. Most recently, denoising diffusion models (DDMs)
18
+
19
+ ![](images/a5ecbde7333db061775c6917bb95434b89bc4661fe3aa6fbf5e867c83ff8aba7.jpg)
20
+ Figure 1: LION is set up as a hierarchical point cloud VAE with denoising diffusion models over the shape latent and latent point distributions. PointVoxel CNNs (PVCNN) with adaptive Group Normalization (Ada. GN) are used as neural networks. The latent points can be interpreted as a smoothed version of the input point cloud. Shape As Points (SAP) is optionally used for mesh reconstruction.
21
+
22
+ have emerged as powerful generative models, achieving outstanding results not only on image synthesis [53–64] but also for point cloud-based 3D shape generation [45–47]. In DDMs, the data is gradually perturbed by a diffusion process, while a deep neural network is trained to denoise. This network can then be used to synthesize novel data in an iterative fashion when initialized from random noise [53, 65–67]. However, existing DDMs for 3D shape synthesis struggle with simultaneously satisfying all criteria discussed above for practically useful 3D generative models.
23
+
24
+ Here, we aim to develop a DDM-based generative model of 3D shapes overcoming these limitations. We introduce the Latent Point Diffusion Model (LION) for 3D shape generation (see Fig. 1). Similar to previous 3D DDMs, LION operates on point clouds, but it is constructed as a VAE with DDMs in latent space. LION comprises a hierarchical latent space with a vector-valued global shape latent and another point-structured latent space. The latent representations are predicted with point cloud processing encoders, and two latent DDMs are trained in these latent spaces. Synthesis in LION proceeds by drawing novel latent samples from the hierarchical latent DDMs and decoding back to the original point cloud space. Importantly, we also demonstrate how to augment LION with modern surface reconstruction methods [68] to synthesize smooth shapes as desired by artists. LION has multiple advantages:
25
+
26
+ Expressivity: By mapping point clouds into regularized latent spaces, the DDMs in latent space are effectively tasked with learning a smoothed distribution. This is easier than training on potentially complex point clouds directly [58], thereby improving expressivity. However, point clouds are, in principle, an ideal representation for DDMs. Because of that, we use latent points, this is, we keep a point cloud structure for our main latent representation. Augmenting the model with an additional global shape latent variable in a hierarchical manner further boosts expressivity. We validate LION on several popular ShapeNet benchmarks and achieve state-of-the-art synthesis performance.
27
+
28
+ Varying Output Types: Extending LION with Shape As Points (SAP) [68] geometry reconstruction allows us to also output smooth meshes. Fine-tuning SAP on data generated by LION’s autoencoder reduces synthesis noise and enables us to generate high-quality geometry. LION combines (latent) point cloud-based modeling, ideal for DDMs, with surface reconstruction, desired by artists.
29
+
30
+ Flexibility: Since LION is set up as a VAE, it can be easily adapted for different tasks without retraining the latent DDMs: We can efficiently fine-tune LION’s encoders on voxelized or noisy inputs, which a user can provide for guidance. This enables multimodal voxel-guided synthesis and shape denoising. We also leverage LION’s latent spaces for shape interpolation and autoencoding. Optionally training the DDMs conditioned on CLIP embeddings enables image- and text-driven 3D generation.
31
+
32
+ In summary, we make the following contributions: (i) We introduce LION, a novel generative model for 3D shape synthesis, which operates on point clouds and is built on a hierarchical VAE framework with two latent DDMs. (ii) We validate LION’s high synthesis quality by reaching state-of-the-art performance on widely used ShapeNet benchmarks. (iii) We achieve high-quality and diverse 3D shape synthesis with LION even when trained jointly over many classes without conditioning. (iv) We propose to combine LION with SAP-based surface reconstruction. (v) We demonstrate the flexibility of our framework by adapting it to relevant tasks such as multimodal voxel-guided synthesis.
33
+
34
+ # 2 Background
35
+
36
+ Traditionally, DDMs were introduced in a discrete-step fashion: Given samples $\mathbf { x } _ { 0 } \sim q ( \mathbf { x } _ { 0 } )$ from a data distribution, DDMs use a Markovian fixed forward diffusion process defined as [65, 53]
37
+
38
+ ![](images/50a69b4fae41081a6f71ae4fa30d4db630414574be115671a763f0682d5ca458.jpg)
39
+ Figure 2: Generated meshes with LION. Right: Synthesizing different details by diffuse-denoise (see Sec. 3.1) in latent space, while preserving overall shapes.
40
+
41
+ $$
42
+ q ( \mathbf { x } _ { 1 : T } | \mathbf { x } _ { 0 } ) : = \prod _ { t = 1 } ^ { T } q ( \mathbf { x } _ { t } | \mathbf { x } _ { t - 1 } ) , \qquad q ( \mathbf { x } _ { t } | \mathbf { x } _ { t - 1 } ) : = \mathcal { N } ( \mathbf { x } _ { t } ; \sqrt { 1 - \beta _ { t } } \mathbf { x } _ { t - 1 } , \beta _ { t } I ) ,
43
+ $$
44
+
45
+ where $T$ denotes the number of steps and $q \big ( \mathbf { x } _ { t } | \mathbf { x } _ { t - 1 } \big )$ is a Gaussian transition kernel, which gradually adds noise to the input with a variance schedule $\beta _ { 1 } , . . . , \beta _ { T }$ . The $\beta _ { t }$ are chosen such that the chain approximately converges to a standard Gaussian distribution after $T$ steps, $q ( \mathbf { x } _ { T } ) { \approx } { \mathcal { N } } ( \mathbf { x } _ { T } ; \mathbf { 0 } , I )$ . DDMs learn a parametrized reverse process (model parameters $\pmb \theta$ ) that inverts the forward diffusion:
46
+
47
+ $$
48
+ p _ { \theta } ( \mathbf { x } _ { 0 : T } ) : = p ( \mathbf { x } _ { T } ) \prod _ { t = 1 } ^ { T } p _ { \theta } ( \mathbf { x } _ { t - 1 } | \mathbf { x } _ { t } ) , \qquad p _ { \theta } ( \mathbf { x } _ { t - 1 } | \mathbf { x } _ { t } ) : = \mathcal { N } ( \mathbf { x } _ { t - 1 } ; \mu _ { \theta } ( \mathbf { x } _ { t } , t ) , \rho _ { t } ^ { 2 } I ) .
49
+ $$
50
+
51
+ This generative reverse process is also Markovian with Gaussian transition kernels, which use fixed variances $\rho _ { t } ^ { 2 }$ . DDMs can be interpreted as latent variable models, where $\mathbf { x } _ { 1 } , . . . , \mathbf { x } _ { T }$ are latents, and the forward process $q \big ( \mathbf { x } _ { 1 : T } | \mathbf { x } _ { 0 } \big )$ acts as a fixed approximate posterior, to which the generative $p _ { \pmb { \theta } } ( \mathbf { x } _ { 0 : T } )$ is fit. DDMs are trained by minimizing the variational upper bound on the negative log-likelihood of the data $\mathbf { x } _ { \mathrm { 0 } }$ under $p _ { \theta } ( \mathbf { x } _ { 0 : T } )$ . Up to irrelevant constant terms, this objective can be expressed as [53]
52
+
53
+ $$
54
+ \operatorname* { m i n } _ { \theta } \mathbb { E } _ { t \sim U \left\{ 1 , T \right\} , \mathbf { x } _ { 0 } \sim p \left( \mathbf { x } _ { 0 } \right) , \epsilon \sim \mathcal { N } ( \mathbf { 0 } , I ) } \left[ w ( t ) | | \epsilon - \epsilon _ { \theta } ( \alpha _ { t } \mathbf { x } _ { 0 } + \sigma _ { t } \epsilon , t ) | | _ { 2 } ^ { 2 } \right] , w ( t ) = \frac { \beta _ { t } ^ { 2 } } { 2 \rho _ { t } ^ { 2 } ( 1 - \beta _ { t } ) ( 1 - \alpha _ { t } ^ { 2 } ) } ,
55
+ $$
56
+
57
+ where $\alpha _ { t } = \sqrt { \prod _ { s = 1 } ^ { t } ( 1 - \beta _ { s } ) }$ and $\sigma _ { t } ~ = ~ \sqrt { 1 - \alpha _ { t } ^ { 2 } }$ are the parameters of the tractable diffused distribution after $t$ steps $q ( \mathbf { x } _ { t } | \mathbf { x } _ { 0 } ) = \mathcal { N } ( \mathbf { x } _ { t } ; \alpha _ { t } \mathbf { x } _ { 0 } , \sigma _ { t } ^ { 2 } I )$ . Furthermore, Eq. (3) employs the widely used parametrization µθ(xt, t) := √ 11−βt $\begin{array} { r } { \mu _ { \theta } ( \mathbf { x } _ { t } , t ) : = \frac { 1 } { \sqrt { 1 - \beta _ { t } } } \left( \mathbf { x } _ { t } - \frac { \beta _ { t } } { \sqrt { 1 - \alpha _ { t } ^ { 2 } } } \epsilon _ { \theta } ( \mathbf { x } _ { t } , t ) \right) } \end{array}$ . It is common practice to set $w ( t ) = 1$ , instead of the one in Eq. (3), which often promotes perceptual quality of the generated output. In the objective of Eq. (3), the model $\epsilon _ { \theta }$ is, for all possible steps $t$ along the diffusion process, effectively trained to predict the noise vector $\epsilon$ that is necessary to denoise an observed diffused sample $\mathbf { x } _ { t }$ . After training, the DDM can be sampled with ancestral sampling in an iterative fashion:
58
+
59
+ $$
60
+ \begin{array} { r } { \mathbf { x } _ { t - 1 } = \frac { 1 } { \sqrt { 1 - \beta _ { t } } } ( \mathbf { x } _ { t } - \frac { \beta _ { t } } { \sqrt { 1 - \alpha _ { t } ^ { 2 } } } \pmb { \epsilon } _ { \theta } ( \mathbf { x } _ { t } , t ) ) + \rho _ { t } \pmb { \eta } , } \end{array}
61
+ $$
62
+
63
+ where $\eta \sim \mathcal { N } ( \eta ; 0 , I )$ . This sampling chain is initialized from a random sample $\mathbf { x } _ { T } \sim \mathcal { N } ( \mathbf { x } _ { T } ; \mathbf { 0 } , I )$ .
64
+ Furthermore, the noise injection in Eq. 4 is usually omitted in the last sampling step.
65
+
66
+ DDMs can also be expressed with a continuous-time framework [67, 69]. In this formulation, the diffusion and reverse generative processes are described by differential equations. This approach allows for deterministic sampling and encoding schemes based on ordinary differential equations (ODEs). We make use of this framework in Sec. 3.1 and we review this approach in more detail in App. B.
67
+
68
+ # 3 Hierarchical Latent Point Diffusion Models
69
+
70
+ We first formally introduce LION, then discuss various applications and extensions in Sec. 3.1, and finally recapitulate its unique advantages in Sec. 3.2. See Fig. 1 for a visualization of LION.
71
+
72
+ We are modeling point clouds $\mathbf { x } \in \mathbb { R } ^ { 3 \times N }$ , consisting of $N$ points with xyz-coordinates in $\mathbb { R } ^ { 3 }$ . LION is set up as a hierarchical VAE with DDMs in latent space. It uses a vector-valued global shape latent $\mathbf { z } _ { 0 } \in \mathbb { R } ^ { D _ { \mathbf { z } } }$ and a point cloud-structured latent $\mathbf { h } _ { 0 } \in \mathbf { \bar { \mathbb { R } } } ^ { ( 3 + D _ { \mathbf { h } } ) \times N }$ . Specifically, $\mathbf { h } _ { 0 }$ is a latent point cloud consisting of $N$ points with $x y z$ -coordinates in $\mathbb { R } ^ { 3 }$ . In addition, each latent point can carry additional $D _ { \mathbf { h } }$ latent features. Training of LION is then performed in two stages—first, we train it as a regular VAE with standard Gaussian priors; then, we train the latent DDMs on the latent encodings.
73
+
74
+ First Stage Training. Initially, LION is trained by maximizing a modified variational lower bound on the data log-likelihood (ELBO) with respect to the encoder and decoder parameters $\phi$ and $\boldsymbol { \xi }$ [70, 71]:
75
+
76
+ $$
77
+ \begin{array} { r l } & { \mathcal { L } _ { \mathrm { E L B O } } ( \boldsymbol { \phi } , \boldsymbol { \xi } ) = \mathbb { E } _ { p ( \mathbf { x } ) , q _ { \phi } ( \mathbf { z } _ { 0 } | \mathbf { x } ) , q _ { \phi } ( \mathbf { h } _ { 0 } | \mathbf { x } , \mathbf { z } _ { 0 } ) } [ \log p _ { \xi } ( \mathbf { x } | \mathbf { h } _ { 0 } , \mathbf { z } _ { 0 } ) } \\ & { \qquad - \lambda _ { \mathbf { z } } D _ { \mathrm { K L } } ( q _ { \phi } ( \mathbf { z } _ { 0 } | \mathbf { x } ) \vert p ( \mathbf { z } _ { 0 } ) ) - \lambda _ { \mathbf { h } } D _ { \mathrm { K L } } ( q _ { \phi } ( \mathbf { h } _ { 0 } | \mathbf { x } , \mathbf { z } _ { 0 } ) \vert p ( \mathbf { h } _ { 0 } ) ) ] . } \end{array}
78
+ $$
79
+
80
+ ![](images/794b4b6104af7191905670a7a7a67c74af466190e3278dba537a59617fa285aa.jpg)
81
+ Figure 3: Generated shapes (top: point clouds, bottom: corresponding meshes) from LION trained jointly over 13 classes of ShapeNet-vol without conditioning (Sec. 5.2).
82
+
83
+ Here, the global shape latent $\mathbf { z } _ { 0 }$ is sampled from the posterior distribution $q _ { \phi } ( \mathbf { z } _ { 0 } | \mathbf { x } )$ , which is parametrized by factorial Gaussians, whose means and variances are predicted via an encoder network. The point cloud latent $\mathbf { h } _ { 0 }$ is sampled from a similarly parametrized posterior $q _ { \phi } ( \mathbf { h } _ { 0 } | \mathbf { x } , \mathbf { z } _ { 0 } )$ , while also conditioning on $\mathbf { z } _ { 0 }$ ( $\cdot \phi$ denotes the parameters of both encoders). Furthermore, $p _ { \pmb { \xi } } ( \mathbf { x } | \mathbf { h } _ { 0 } , \mathbf { z } _ { 0 } )$ denotes the decoder, parametrized as a factorial Laplace distribution with predicted means and fixed unit scale parameter (corresponding to an $L _ { 1 }$ reconstruction loss). $\lambda _ { \mathbf { z } }$ and $\lambda _ { \mathbf { h } }$ are hyperparameters balancing reconstruction accuracy and Kullback-Leibler regularization (note that only for $\lambda _ { \mathbf { z } } = \lambda _ { \mathbf { h } } = 1$ we are optimizing a rigorous ELBO). The priors $p ( \mathbf { z } _ { 0 } )$ and $p ( \mathbf { h } _ { 0 } )$ are $\mathcal { N } ( \mathbf { 0 } , \pmb { I } )$ . Also see Fig. 1 again.
84
+
85
+ Second Stage Training. In principle, we could use the VAE’s priors to sample encodings and generate new shapes. However, the simple Gaussian priors will not accurately match the encoding distribution from the training data and therefore produce poor samples (prior hole problem [58, 72–79]). This motivates training highly expressive latent DDMs. In particular, in the second stage we freeze the VAE’s encoder and decoder networks and train two latent DDMs on the encodings $\mathbf { z } _ { 0 }$ and $\mathbf { h } _ { 0 }$ sampled from $q _ { \phi } ( \mathbf { z } _ { 0 } | \mathbf { x } )$ and $q _ { \phi } ( \mathbf { h } _ { 0 } | \mathbf { x } , \mathbf { z } _ { 0 } )$ , minimizing score matching (SM) objectives similar to Eq. (2):
86
+
87
+ $$
88
+ \begin{array} { r l } & { \mathcal { L } _ { \mathrm { S M } ^ { \mathbf { z } } } ( \pmb { \theta } ) = \mathbb { E } _ { t \sim U \{ 1 , T \} , p ( \mathbf { x } ) , q _ { \phi } ( \mathbf { z } _ { 0 } | \mathbf { x } ) , \epsilon \sim \mathcal { N } ( \mathbf { 0 } , I ) } | | \epsilon - \epsilon _ { \theta } ( \mathbf { z } _ { t } , t ) | | _ { 2 } ^ { 2 } , } \\ & { \mathcal { L } _ { \mathrm { S M } ^ { \mathbf { h } } } ( \pmb { \psi } ) = \mathbb { E } _ { t \sim U \{ 1 , T \} , p ( \mathbf { x } ) , q _ { \phi } ( \mathbf { z } _ { 0 } | \mathbf { x } ) , q _ { \phi } ( \mathbf { h } _ { 0 } | \mathbf { x } , \mathbf { z } _ { 0 } ) , \epsilon \sim \mathcal { N } ( \mathbf { 0 } , I ) } | | \epsilon - \epsilon _ { \psi } ( \mathbf { h } _ { t } , \mathbf { z } _ { 0 } , t ) | | _ { 2 } ^ { 2 } , } \end{array}
89
+ $$
90
+
91
+ where ${ \bf z } _ { t } = \alpha _ { t } { \bf z } _ { 0 } + \sigma _ { t } \epsilon$ and $\mathbf { h } _ { t } = \alpha _ { t } \mathbf { h } _ { 0 } + \sigma _ { t } \mathbf { \epsilon } \epsilon$ are the diffused latent encodings. Furthermore, $\pmb \theta$ denotes the parameters of the global shape latent DDM $\boldsymbol { \epsilon } _ { \boldsymbol { \theta } } ( \mathbf { z } _ { t } , t )$ , and $\psi$ refers to the parameters of the conditional DDM $\mathbf { \epsilon } _ { \psi } ( \mathbf { h } _ { t } , \bar { \mathbf { z } _ { 0 } } , t )$ trained over the latent point cloud (note the conditioning on $\mathbf { z } _ { 0 }$ ).
92
+
93
+ Generation. With the latent DDMs, we can formally define a hierarchical generative model $\begin{array} { r } { p _ { \xi , \psi , \theta } ( \mathbf { x } , \mathbf { h } _ { 0 } , \mathbf { z } _ { 0 } ) = p _ { \xi } ( \mathbf { x } | \mathbf { h } _ { 0 } , \mathbf { z } _ { 0 } ) p _ { \psi } ( \mathbf { h } _ { 0 } | \mathbf { z } _ { 0 } ) p _ { \theta } ( \mathbf { z } _ { 0 } ) } \end{array}$ , where $p _ { \pmb { \theta } } ( \mathbf { z } _ { 0 } )$ denotes the distribution of the global shape latent DDM, $p _ { \psi } ( \mathbf { h } _ { 0 } | \mathbf { z } _ { 0 } )$ refers to the DDM modeling the point cloud-structured latents, and $p _ { \pmb { \xi } } ( \mathbf { x } | \mathbf { h } _ { 0 } , \mathbf { z } _ { 0 } )$ is LION’s decoder. We can hierarchically sample the latent DDMs following Eq. (4) and then translate the latent points back to the original point cloud space with the decoder.
94
+
95
+ Network Architectures and DDM Parametrization. Let us briefly summarize key implementation choices. The encoder networks, as well as the decoder and the latent point DDM, operating on point clouds $\mathbf { x }$ , are all implemented based on Point-Voxel CNNs (PVCNNs) [80], following Zhou et al. [46]. PVCNNs efficiently combine the point-based processing of PointNets [81, 82] with the strong spatial inductive bias of convolutions. The DDM modeling the global shape latent uses a ResNet [83] structure with fully-connected layers (implemented as $1 \times 1$ -convolutions). All conditionings on the global shape latent are implemented via adaptive Group Normalization [84] in the PVCNN layers. Furthermore, following Vahdat et al. [58] we use a mixed score parametrization in both latent DDMs. This means that the score models are parametrized to predict a residual correction to an analytic standard Gaussian score. This is beneficial since the latent encodings are regularized towards a standard Gaussian distribution during the first training stage (see App. D for all details).
96
+
97
+ # 3.1 Applications and Extensions
98
+
99
+ Here, we discuss how LION can be used and extended for different relevant applications.
100
+
101
+ Multimodal Generation. We can synthesize different variations of a given shape, enabling multimodal generation in a controlled manner: Given a shape, i.e., its point cloud $\mathbf { x }$ , we encode it into latent space. Then, we diffuse its encodings $\mathbf { z } _ { 0 }$ and $\mathbf { h } _ { 0 }$ for a small number of steps $\tau < T$ towards intermediate ${ \bf z } _ { \tau }$ and ${ \bf h } _ { \tau }$ along the diffusion process such that only local details are destroyed. Running the reverse generation process from this intermediate $\tau$ , starting at ${ \bf z } _ { \tau }$ and ${ \bf h } _ { \tau }$ , leads to variations of the original shape with different details (see, for instance, Fig. 2). We refer to this procedure as diffuse-denoise (details in App. C.1). Similar techniques have been used for image editing [85].
102
+
103
+ Encoder Fine-tuning for Voxel-Conditioned Synthesis and Denoising. In practice, an artist using a 3D generative model may have a rough idea of the desired shape. For instance, they may be able to quickly construct a coarse voxelized shape, to which the generative model then adds realistic details.
104
+
105
+ ![](images/85429d590b634ce75ac7892abdbde7713e22da5e9b4c3ea48ef5c5e6e54822dc.jpg)
106
+ Figure 4: Voxelguided synthesis with LION. We run diffuse-denoise in latent space (see Sec. 3.1) to generate diverse plausible clean shapes.
107
+
108
+ In LION, we can support such applications: using a similar ELBO as in Eq. (5), but with a frozen decoder, we can fine-tune LION’s encoder networks to take voxelized shapes as input (we simply place points at the voxelized shape’s surface) and map them to the corresponding latent encodings $\mathbf { z } _ { 0 }$ and $\mathbf { h } _ { 0 }$ that reconstruct the original non-voxelized point cloud. Now, a user can utilize the fine-tuned encoders to encode voxelized shapes and generate plausible detailed shapes. Importantly, this can be naturally combined with the diffuse-denoise procedure to clean up imperfect encodings and to generate different possible detailed shapes (see Fig. 4).
109
+
110
+ Furthermore, this approach is general. Instead of voxel-conditioned synthesis, we can also fine-tune the encoder networks on noisy shapes to perform multimodal shape denoising, also potentially combined with diffuse-denoise. LION supports these applications easily without re-training the latent DDMs due to its VAE framework with additional encoders and decoders, in contrast to previous works that train DDMs on point clouds directly [46, 47]. See App. C.2 for technical details.
111
+
112
+ Shape Interpolation. LION also enables shape interpolation: We can encode different point clouds into LION’s hierarchical latent space and use the probability flow ODE (see App. B) to further encode into the latent DDMs’ Gaussian priors, where we can safely perform spherical interpolation and expect valid shapes along the interpolation path. We can use the intermediate encodings to generate the interpolated shapes (see Fig. 7; details in App. C.3).
113
+
114
+ Surface Reconstruction. While point clouds are an ideal 3D representation for DDMs, artists may prefer meshed outputs. Hence, we propose to combine LION with modern geometry reconstruction methods (see Figs. 2, 4 and 5). We use Shape As Points (SAP) [68], which is based on differentiable Poisson surface reconstruction and can be trained to extract smooth meshes from noisy point clouds. Moreover, we fine-tune SAP on training data generated by LION’s autoencoder to better adjust SAP to the noise distribution in point clouds generated by LION. Specifically, we take clean shapes, encode them into latent space, run a few steps of diffuse-denoise that only slightly modify some details, and decode back. The diffuse-denoise in latent space results in noise in the generated point ated points. clouds similar to what is observed during unconditional synthesis (details in App. C.4).
115
+
116
+ ![](images/e8246239ce1cb83b69f6bfa0190e0a475971dd591c1a606190b19903eaf14fce.jpg)
117
+ Figure 5: Reconstructing a mesh from LION’s gener
118
+
119
+ # 3.2 LION’s Advantages
120
+
121
+ We now recapitulate LION’s unique advantages. LION’s structure as a hierarchical VAE with latent DDMs is inspired by latent DDMs on images [57, 58, 77]. This framework has key benefits:
122
+
123
+ (i) Expressivity: First training a VAE that regularizes the latent encodings to approximately fall under standard Gaussian distributions, which are also the DDMs’ equilibrium distributions towards which the diffusion processes converge, results in an easier modeling task for the DDMs: They have to model only the remaining mismatch between the actual encoding distributions and their own Gaussian priors [58]. This translates into improved expressivity, which is further enhanced by the additional decoder network. However, point clouds are, in principle, an ideal representation for the DDM framework, because they can be diffused and denoised easily and powerful point cloud processing architectures exist. Therefore, LION uses point cloud latents that combine the advantages of both latent DDMs and 3D point clouds. Our point cloud latents can be interpreted as smoothed versions of the original point clouds that are easier to model (see Fig. 1). Moreover, the hierarchical VAE setup with an additional global shape latent increases LION’s expressivity even further and results in natural disentanglement between overall shape and local details captured by the shape latents and latent points (Sec. 5.2).
124
+
125
+ (ii) Flexibility: Another advantage of LION’s VAE framework is that its encoders can be fine-tuned for various relevant tasks, as discussed previously, and it also enables easy shape interpolation. Other 3D point cloud DDMs operating on point clouds directly [47, 46] do not offer simultaneously as much flexibility and expressivity out-of-the-box (see quantitative comparisons in Secs. 5.1 and 5.4).
126
+
127
+ (iii) Mesh Reconstruction: As discussed, while point clouds are ideal for DDMs, artists likely prefer meshed outputs. As explained above, we propose to use LION together with modern surface reconstruction techniques [68], again combining the best of both worlds—a point cloud-based VAE backbone ideal for DDMs, and smooth geometry reconstruction methods operating on the synthesized point clouds to generate practically useful smooth surfaces, which can be easily transformed into meshes.
128
+
129
+ ![](images/3a7faca45d0a42a04bfe777486d20f82a5448e7fd0bfdf16d03a15e9ff8b2a17.jpg)
130
+ Figure 6: Unconditional shape generation with 2,048 points for airplane, car and chair classes (class-specific models trained on PointFlow’s ShapeNet data with global normalization).
131
+
132
+ # 4 Related Work
133
+
134
+ We are building on DDMs [53, 65–67], which have been used most prominently for image [53–63] and speech synthesis [86–91]. We train DDMs in latent space, an idea that has been explored for image [57, 58, 77] and music [92] generation, too. However, these works did not train separate conditional DDMs. Hierarchical DDM training has been used for generative image upsampling [54], text-to-image generation [63, 64], and semantic image modeling [60]. Most relevant among these works is Preechakul et al. [60], which extracts a high-level semantic representation of an image with an auxiliary encoder and then trains a DDM that adds details directly in image space. We are the first to explore related concepts for 3D shape synthesis and we also train both DDMs in latent space. Furthermore, DDMs and VAEs have also been combined in such a way that the DDM improves the output of the VAE [93].
135
+
136
+ Most related to LION are “Point-Voxel Diffusion” (PVD) [46] and “Diffusion Probabilistic Models for 3D Point Cloud Generation” (DPM) [47]. PVD trains a DDM directly on point clouds, and our decision to use PVCNNs is inspired by this work. DPM, like LION, uses a shape latent variable, but models its distribution with Normalizing Flows [94, 95], and then trains a weaker point-wise conditional DDM directly on the point cloud data (this allows DPM to learn useful representations in its latent variable, but sacrifices generation quality). As we show below, neither PVD nor DPM easily enables applications such as multimodal voxel-conditioned synthesis and denoising. Furthermore, LION achieves significantly stronger generation performance. Finally, neither PVD nor DPM reconstructs meshes from the generated point clouds. Point cloud and 3D shape generation have also been explored with other generative models: PointFlow [31], DPF-Net [33] and SoftFlow [32] rely on Normalizing Flows [94–97]. SetVAE [29] treats point cloud synthesis as set generation and uses VAEs. ShapeGF [45] learns distributions over gradient fields that model shape surfaces. Both IM-GAN [7], which models shapes as neural fields, and l-GAN [2] train GANs over latent variables that encode the shapes, similar to other works [3], while r-GAN [2] generates point clouds directly. PDGN [52] proposes progressive deconvolutional networks within a point cloud GAN. SP-GAN [19] uses a spherical point cloud prior. Other progressive [22, 37] and graph-based architectures [4, 6] have been used, too. Also generative cellular automata (GCAs) can be employed for voxel-based 3D shape generation [43]. In orthogonal work, point cloud DDMs have been used for generative shape completion [46, 98].
137
+
138
+ Recently, image-driven [8–16, 44] training of 3D generative models as well as text-driven 3D generation [34, 49–51] have received much attention. These are complementary directions to ours; in fact, augmenting LION with additional image-based training or including text-guidance are promising future directions. Finally, we are relying on SAP [68] for mesh generation. Strong alternative approaches for reconstructing smooth surfaces from point clouds exist [99–103].
139
+
140
+ ![](images/4415796a634b4f9ff0b2056e1bed79ad61f4bef0f5dc3c549987eef0c051b295.jpg)
141
+ Figure 7: Interpolating different shapes by interpolating their encodings in the standard Gaussian priors of LION’s latent DDMs (details in App. C.3).
142
+
143
+ Table 1: Generation metrics (1-NNA↓) on airplane, chair, car categories from ShapeNet dataset from PointFlow [31]. Training and test data normalized globally into [-1, 1].
144
+
145
+ <table><tr><td rowspan="2"></td><td>Airplane</td><td></td><td>Chair</td><td>Car</td></tr><tr><td>CD EMD</td><td>CD</td><td>EMD</td><td>CD</td><td>EMD</td></tr><tr><td>r-GAN[2]</td><td>98.40 96.79</td><td>83.69</td><td>99.70</td><td>94.46</td><td>599.01</td></tr><tr><td>1-GAN (CD) [2]</td><td>87.30 )93.95</td><td>68.58</td><td>83.84</td><td>66.49</td><td>88.78</td></tr><tr><td>1-GAN (EMD)[2]</td><td>89.49 76.91</td><td>71.90</td><td>64.65</td><td>71.16</td><td>66.19</td></tr><tr><td>PointFlow [31]</td><td>75.68 370.74</td><td>62.84</td><td>60.57</td><td>58.10</td><td>56.25</td></tr><tr><td>SoftFlow [32]</td><td>76.05 65.80</td><td>59.21</td><td>60.05</td><td>64.77</td><td>60.09</td></tr><tr><td>SetVAE [29]</td><td>76.54 67.65</td><td>58.84</td><td>60.57</td><td>59.94</td><td>59.94</td></tr><tr><td>DPF-Net [33]</td><td>75.18 65.55</td><td>62.00</td><td>58.53</td><td>62.35</td><td>54.48</td></tr><tr><td>DPM[47]</td><td>76.42 86.91</td><td>60.05</td><td>74.77</td><td>68.89</td><td>79.97</td></tr><tr><td>PVD [46]</td><td>73.82 64.81</td><td>56.26</td><td>53.32</td><td>54.55</td><td>53.83</td></tr><tr><td>LION (ours)</td><td>67.41 61.23</td><td>53.70</td><td>52.34</td><td></td><td>53.41 51.14</td></tr></table>
146
+
147
+ Table 2: Generation results (1-NNA↓) on ShapeNet dataset from PointFlow [31]. All data normalized individually into [-1, 1].
148
+
149
+ <table><tr><td rowspan="2"></td><td>Airplane</td><td></td><td>Chair</td><td>Car</td></tr><tr><td>CD</td><td>EMD</td><td>CD EMD</td><td>CD EMD</td></tr><tr><td>TreeGAN[ [6]</td><td></td><td>97.53 99.88 88.37</td><td>96.37 89.77</td><td>94.89</td></tr><tr><td>ShapeGF[ [45]</td><td>81.23 80.86</td><td>58.01</td><td>61.25 61.79</td><td>57.24</td></tr><tr><td>SP-GAN[19]</td><td>94.69 93.95</td><td>72.58</td><td>83.69</td><td>87.36 85.94</td></tr><tr><td>PDGN [52]</td><td>94.94 91.73</td><td>71.83</td><td></td><td>79.00 89.35 87.22</td></tr><tr><td>GCA [43]</td><td>88.15 85.93</td><td>64.27</td><td>64.50 70.45</td><td>64.20</td></tr><tr><td>LION(ours)</td><td></td><td></td><td>76.30 67.04 56.50 53.85 59.52 49.29</td><td></td></tr></table>
150
+
151
+ Table 3: Results (1-NNA↓) on ShapeNet-vol.
152
+
153
+ <table><tr><td rowspan="2"></td><td>Airplane</td><td>Chair</td><td>Car</td></tr><tr><td>CD EMD</td><td>CD EMD</td><td>CD EMD</td></tr><tr><td>IM-GAN[7]</td><td>79.70 77.85 57.09</td><td>58.20 88.92</td><td>84.58</td></tr><tr><td>DPM[47] PVD [46]</td><td>83.04 96.04 61.96 66.46 56.06 61.89</td><td>74.96 77.30 57.90 64.49</td><td>87.12 55.74</td></tr><tr><td></td><td></td><td></td><td></td></tr><tr><td colspan="2">LION (ours) 53.47 53.84 52.07</td><td>48.67</td><td>54.81 50.53</td></tr></table>
154
+
155
+ # 5 Experiments
156
+
157
+ We provide an overview of our most interesting experimental results in the main paper. All experiment details and extensive additional experiments can be found in App. E and App. F, respectively.
158
+
159
+ # 5.1 Single-Class 3D Shape Generation
160
+
161
+ Datasets. To compare LION against existing methods, we use ShapeNet [104], the most widely used dataset to benchmark 3D shape generative models. Following previous works [31, 46, 47], we train on three categories: airplane, chair, car. Also like previous methods, we primarily rely on PointFlow’s [31] dataset splits and preprocssing. It normalizes the data globally across the whole dataset. However, some baselines require per-shape normalization [19, 43, 45, 52]; hence, we also train on such data. Furthermore, training SAP requires signed distance fields (SDFs) for volumetric supervision, which the PointFlow data does not offer. Hence, for simplicity we follow Peng et al. [68, 101] and also use their data splits and preprocessing, which includes SDFs.We train LION, DPM, PVD, and IM-GAN (which synthesizes shapes as SDFs) also on as ShapeNet-vol here). This data is also per-shape normalized.
162
+
163
+ Evaluation. Model evaluation follows previous works [31, 46]. Various metrics to evaluate point cloud generative models exist, with different advantages and disadvantages, discussed in detail by Yang et al. [31]. Following recent works [31, 46], we use 1-NNA (with both Chamfer distance (CD) and earth mover distance (EMD)) as our main metric. It quantifies the distributional similarity between generated shapes and validation set and measures both quality and diversity [31]. For fair comparisons, all metrics are computed on point clouds, not meshed outputs (App. E.2 discusses different metrics; further results on coverage (COV) and minimum matching distance (MMD) in App. F.2).
164
+
165
+ ![](images/5b55e07dfb5406b0da8472c26a7620d4b2d2f093be889f901eda2c6ce9df0988.jpg)
166
+ Figure 8: Samples from our unconditional 13-class model: In each column, we use the same global shape latent $\mathbf { z } _ { 0 }$ .
167
+
168
+ this dataset version (denoted Dataset details in App. E.1.
169
+
170
+ Table 4: Generation results (1- NNA↓) of LION trained jointly on 13 classes of ShapeNet-vol.
171
+
172
+ <table><tr><td>Model</td><td>CD</td><td>EMD</td></tr><tr><td>TreeGAN [6]</td><td>96.80</td><td>96.60</td></tr><tr><td>PointFlow [31]</td><td>63.25</td><td>66.05</td></tr><tr><td>ShapeGF[45]</td><td>55.65</td><td>59.00</td></tr><tr><td>SetVAE [29]</td><td>79.25</td><td>95.25</td></tr><tr><td>PDGN [52]</td><td>71.05</td><td>86.00</td></tr><tr><td>DPF-Net [33]</td><td>67.10</td><td>64.75</td></tr><tr><td>DPM[47]</td><td>62.30</td><td>86.50</td></tr><tr><td>PVD [46]</td><td>58.65</td><td>57.85</td></tr><tr><td>LION (ours)</td><td>51.85</td><td>48.95</td></tr></table>
173
+
174
+ Results. Samples from LION are shown in Fig. 6 and quantitative results in Tabs. 1-3 (see Sec. 4 for details about baselines—to reduce the number of baselines to train, we are focusing on the most recent and competitive ones). LION outperforms all baselines and achieves state-of-the-art performance on all classes and dataset versions. Importantly, we outperform both PVD and DPM, which also leverage DDMs, by large margins. Our samples are diverse and appear visually pleasing.
175
+
176
+ ![](images/9b9618423aeeac129aa5e6e358feb49f5e1ebb18eaf986c614bfbfb4c5e35683.jpg)
177
+ Figure 9: Generated point clouds from LION trained jointly over 55 classes of ShapeNet-vol (no conditioning).
178
+
179
+ ![](images/7e583fae1e920eca77cfbcfa30b8e62210c56760f2035b8269f5be44b2ae0c30.jpg)
180
+ Figure 10: Samples from LION trained on ShapeNet’s Mug and Bottle classes, and on Turbosquid animals.
181
+
182
+ Mesh Reconstruction. As explained in Sec. 3.1, we combine LION with mesh reconstruction, to directly synthesize practically useful meshes. We show generated meshes in Fig. 2, which look smooth and of high quality. In Fig. 2, we also visually demonstrate how we can vary the local details of synthesized shapes while preserving the overall shape with our diffuse-denoise technique (Sec. 3.1). Details about the number of diffusion steps for all diffuse-denoise experiments are in App. E.
183
+
184
+ Shape Interpolation. As discussed in Sec. 3.1, LION also enables shape interpolation, potentially useful for shape editing applications. We show this in Fig. 7, combined with mesh reconstruction. The generated shapes are clean and semantically plausible along the entire interpolation path. In App. F.12.1, we also show interpolations from PVD [46] and DPM [47] for comparison.
185
+
186
+ # 5.2 Many-class Unconditional 3D Shape Generation
187
+
188
+ 13-Class LION Model. We train a LION model jointly without any class conditioning on 13 different categories (airplane, chair, car, lamp, table, sofa, cabinet, bench, telephone, loudspeaker, display, watercraft, rifle) from ShapeNet (ShapeNet-vol version). Training a single model without conditioning over such diverse shapes is challenging, as the data distribution is highly complex and multimodal. We show LION’s generated samples in Fig. 3, including meshes: LION synthesizes high-quality and diverse plausible shapes even when trained on such complex data. We report the model’s quantitative generation performance in Tab. 4, and we also trained various strong baseline methods under the same setting for comparison. We find that LION significantly outperforms all baselines by a large margin. We further observe that the hierarchical VAE architecture of LION becomes crucial: The shape latent variable $\mathbf { z } _ { 0 }$ captures global shape, while the latent points $\mathbf { h } _ { 0 }$ model details. This can be seen in Fig. 8: we show samples when fixing the global shape latent $\mathbf { z } _ { 0 }$ and only sample $\mathbf { h } _ { 0 }$ (details in App. F.3).
189
+
190
+ 55-Class LION Model. Encouraged by these results, we also trained a LION model again jointly without any class conditioning on all 55 different categories from ShapeNet. Note that we did on purpose not use class-conditioning in these experiments to create a difficult 3D generation task and thereby explore LION’s scalability to highly complex and multimodal datasets. We show generated point cloud samples in Fig. 9 (we did not train an SAP model on the 55 classes data): LION synthesizes high-quality and diverse shapes. It can even generate samples from the cap class, which contributes with only 39 training data samples, indicating that LION has an excellent mode coverage that even includes the very rare classes. To the best of our knowledge no previous 3D shape generative models have demonstrated satisfactory generation performance for such diverse and multimodal 3D data without relying on conditioning information (details in App. F.4). In conclusion, we observe that LION out-of-the-box easily scales to highly complex multi-category shape generation.
191
+
192
+ # 5.3 Training LION on Small Datasets
193
+
194
+ Next, we explore whether LION can also be trained successfully on very small datasets. To this end, we train models on the Mug and Bottle ShapeNet classes. The number of training samples is 149 and 340, respectively, which is much smaller than the common classes like chair, car and airplane. Furthermore, we also train LION on 553 animal assets from the TurboSquid data repository. Generated shapes from the three models are shown in Fig. 10. LION is able to generate correct mugs and bottles as well as diverse and high-quality animal shapes. We conclude that LION also performs well even when training in the challenging low-data setting (details in Apps. F.5 and F.6).
195
+
196
+ ![](images/2ade93952b2c1687a4aed247344a7e707a70e0829b0b8547f8b519ee299a389b.jpg)
197
+ Figure 11: Voxel-guided synthesis. We show different methods with 0 and 50 steps of diffuse-denoise. Voxelizations of generated points are also shown: Yellow boxes indicate generated points correctly fill input voxels, green boxes indicate voxels should be filled but are left empty, red boxes indicate extra voxels.
198
+
199
+ ![](images/a5ec7783f89ce350c646589554680fe14dc18d0cd5cd5692ac372dc06bdb76d5.jpg)
200
+ Figure 13: Voxel-guided generation. Quality metrics for output points (lower is better) and voxel IOU with respect to input (higher is better). $x -$ - axes denote diffuse-denoise steps.
201
+
202
+ ![](images/78f765294bdff9804bb3ae06cde9832dbc910c39d07cd4c4c2e5c738c6154ef6.jpg)
203
+ Figure 12: Reconstruction metrics with respect to clean inputs for airplane category (lower is better) when guiding synthesis with voxelized or noisy inputs (using uniform, outlier, and normal noise, see App. F.7). $_ x$ -axes denote number of diffuse-denoise steps.
204
+
205
+ # 5.4 Voxel-guided Shape Synthesis and Denoising with Fine-tuned Encoders
206
+
207
+ Next, we test our strategy for multimodal voxel-guided shape synthesis (see Sec. 3.1) using the airplane class LION model (experiment details in App. E, more experiments in App. F.7). We first voxelize our training set and fine-tune our encoder networks to produce the correct encodings to decode back the original shapes. When processing voxelized shapes with our point-cloud networks, we sample points on the surface of the voxels. As discussed, we can use different numbers of diffusedenoise steps in latent space to generate various plausible shapes and correct for poor encodings. Instead of voxelizations, we can also consider different noisy inputs (we use normal, uniform, and outlier noise, see App. F.7) and achieve multimodal denoising with the same approach. The same tasks can be attempted with the important DDM-based baselines PVD and DPM, by directly—not in a latent space—diffusing and denoising voxelized (converted to point clouds) or noisy point clouds.
208
+
209
+ Fig. 12 shows the reconstruction performance of LION, DPM and PVD for different numbers of diffuse-denoise steps (we voxelized or noised the validation set to measure this). We see that for almost all inputs—voxelized or different noises—LION performs best. PVD and DPM perform acceptably for normal and uniform noise, which is similar to the noise injected during training of their DDMs, but perform very poorly for outlier noise or voxel inputs, which is the most relevant case to us, because voxels can be easily placed by users. It is LION’s unique framework with additional fine-tuned encoders in its VAE and only latent DDMs that makes this possible. Performing more diffuse-denoise steps means that more independent, novel shapes are generated. These will be cleaner and of higher quality, but also correspond less to the noisy or voxel inputs used for guidance. In Fig. 13, we show this trade-off for the voxel-guidance experiment (other experiments in App. F.7), where (top) we measured the outputs’ synthesis quality by calculating 1-NNA with respect to the validation set, and (bottom) the average intersection over union (IOU) between the input voxels and the voxelized outputs. We generally see a trade-off: More diffuse-denoise steps result in lower 1-NNA (better quality), but also lower IOU. LION strikes the best balance by a large gap: Its additional encoder network directly generates plausible latent encodings from the perturbed inputs that are both high quality and also correspond well to the input. This trade-off is visualized in Fig. 11 for LION, DPM, and PVD, where we show generated point clouds and voxelizations (note that performing no diffuse-denoise at all for PVD and DPM corresponds to simply keeping the input, as these models’ DDMs operate directly on point clouds). We see that running 50 diffuse-denoise steps to generate diverse outputs for DPM and especially PVD results in a significant violation of the input voxelization. In contrast, LION generates realistic outputs that also obey the driving voxels. Overall, LION wins out both in this task and also in unconditional generation with large gaps over these previous DDM-based point cloud generative models. We conclude that LION does not only offer state-of-the-art 3D shape generation quality, but is also very versatile. Note that guided synthesis can also be combined with mesh reconstruction, as shown in Fig. 4.
210
+
211
+ ![](images/e439f9c4b4cd464eb59193841e41c04c3f2eabc99776306355fe2b44efd72e31.jpg)
212
+ Figure 14: We apply Text2Mesh [49] on meshes generated by LION. In Text2Mesh, textures are generated and meshes refined such that rendered images of the 3D objects are aligned with user-provided text prompts [105].
213
+
214
+ ![](images/81667f186ae68d9e39acfe123525b7508d90e9671430dcd91425046a6551bf91.jpg)
215
+ Figure 16: Text-driven shape generation of chairs and cars with LION. Bottom row is the text prompt used as input.
216
+
217
+ # 5.5 Sampling Time
218
+
219
+ While our main experiments use 1,000-step DDPM-based synthesis, which takes $\approx 2 7 . 1 2$ seconds, we can significantly accelerate generation without significant loss in quality. Using DDIM-based sampling [106], we can generate high quality shapes in under one second (Fig. 15), which would enable real-time interactive applications. More analyses in App. F.9.
220
+
221
+ ![](images/625795a9b501d90ded76d171008f1ad0b2a315ea890e5a177dc72ef8863de109.jpg)
222
+ Figure 15: 25-step DDIM [106] samples (0.89 seconds per shape).
223
+
224
+ # 5.6 Overview of Additional Experiments in Appendix
225
+
226
+ (i) In App. F.1, we perform various ablation studies. The experiments quantitatively validate LION’s architecture choices and the advantage of our hierarchical VAE setup with conditional latent DDMs. (ii) In App. F.8, we measure LION’s autoencoding performance. (iii) To demonstrate the value of directly outputting meshes, in App. F.10 we use Text2Mesh [49] to generate textures based on text prompts for synthesized LION samples (Fig. 14). This would not be possible, if we only generated point clouds. (iv) To qualitatively show that LION can be adapted easily to other relevant tasks, in App. F.11 we condition LION on CLIP embeddings of the shapes’ rendered images, following CLIP-Forge [34] (Fig. 16). This enables text-driven 3D shape generation and single view 3D reconstruction (Fig. 17). (v) We also show many more samples (Apps. F.2-F.6) and shape interpolations (App. F.12) from our models, more examples of voxel-guided and noise-guided synthesis (App. F.7), and we further analyze our 13-class LION model (App. F.3.2).
227
+
228
+ # 6 Conclusions
229
+
230
+ We introduced LION, a novel generative model of 3D shapes. LION uses a VAE framework with hierarchical DDMs in latent space and can be combined with SAP for mesh generation. LION achieves state-of-the-art shape generation performance and enables applications such as voxel-conditioned synthesis, multimodal shape denoising, and shape interpolation. LION is currently trained on 3D point clouds only and can not directly generate textured shapes. A promising extension would be to include image-based training by incorporating neural or differentiable rendering [17, 107–111] and to also synthesize textures [16, 112–114]. Furthermore, LION currently focuses on single object generation only. It would be interesting to extend it to full 3D scene synthesis. Moreover, synthesis could be further accelerated by building on works on accelerated sampling from DDMs [61, 62, 67, 106, 115–121].
231
+
232
+ Broader Impact. We believe that LION can potentially improve 3D content creation and assist the workflow of digital artists. We designed LION with such applications in mind and hope that it can grow into a practical tool enhancing artists’ creativity. Although we do not see any immediate negative use-cases for LION, it is important that practitioners apply an abundance of caution to mitigate impacts given generative modeling more generally can also be used for malicious purposes, discussed for instance in Vaccari and Chadwick [122], Nguyen et al. [123], Mirsky and Lee [124].
233
+
234
+ ![](images/2a8dd3f6899aade67630f04ae5ec6f0108def53fe8be061056ed6a9d207f21b7.jpg)
235
+ Figure 17: Single view 3D reconstructions of a car from an RGB image. LION can generate multiple plausible outputs using our diffuse-denoise technique.
236
+
237
+ References
238
+ [1] Jiajun Wu, Chengkai Zhang, Tianfan Xue, Bill Freeman, and Josh Tenenbaum. Learning a probabilistic latent space of object shapes via 3d generative-adversarial modeling. In Advances in Neural Information Processing Systems, 2016. [2] Panos Achlioptas, Olga Diamanti, Ioannis Mitliagkas, and Leonidas Guibas. Learning representations and generative models for 3D point clouds. In ICML, 2018.
239
+ [3] Chun-Liang Li, Manzil Zaheer, Yang Zhang, Barnabas Poczos, and Ruslan Salakhutdinov. Point cloud gan. arXiv preprint arXiv:1810.05795, 2018.
240
+ [4] Diego Valsesia, Giulia Fracastoro, and Enrico Magli. Learning localized generative models for 3d point clouds via graph convolution. In International Conference on Learning Representations (ICLR) 2019, 2019. [5] Wenlong Huang, Brian Lai, Weijian Xu, and Zhuowen Tu. 3d volumetric modeling with introspective neural networks. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 33(01), pages 8481–8488, 2019. [6] Dong Wook Shu, Sung Woo Park, and Junseok Kwon. 3d point cloud generative adversarial network based on tree structured graph convolutions. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 3859–3868, 2019.
241
+ [7] Zhiqin Chen and Hao Zhang. Learning implicit fields for generative shape modeling. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), 2019. [8] Michael Niemeyer and Andreas Geiger. Giraffe: Representing scenes as compositional generative neural feature fields. In Proc. IEEE Conf. on Computer Vision and Pattern Recognition (CVPR), 2021. [9] Katja Schwarz, Yiyi Liao, Michael Niemeyer, and Andreas Geiger. Graf: Generative radiance fields for 3d-aware image synthesis. In Advances in Neural Information Processing Systems (NeurIPS), 2020.
242
+ [10] Yiyi Liao, Katja Schwarz, Lars Mescheder, and Andreas Geiger. Towards unsupervised learning of generative models for 3d controllable image synthesis. In Proceedings IEEE Conf. on Computer Vision and Pattern Recognition (CVPR), 2020.
243
+ [11] Eric Chan, Marco Monteiro, Petr Kellnhofer, Jiajun Wu, and Gordon Wetzstein. pi-gan: Periodic implicit generative adversarial networks for 3d-aware image synthesis. In Proc. CVPR, 2021.
244
+ [12] Eric R. Chan, Connor Z. Lin, Matthew A. Chan, Koki Nagano, Boxiao Pan, Shalini De Mello, Orazio Gallo, Leonidas Guibas, Jonathan Tremblay, Sameh Khamis, Tero Karras, and Gordon Wetzstein. Efficient geometry-aware 3D generative adversarial networks. In arXiv, 2021.
245
+ [13] Roy Or-El, Xuan Luo, Mengyi Shan, Eli Shechtman, Jeong Joon Park, and Ira Kemelmacher-Shlizerman. Stylesdf: High-resolution 3d-consistent image and geometry generation. arXiv preprint arXiv:2112.11427, 2021.
246
+ [14] Jiatao Gu, Lingjie Liu, Peng Wang, and Christian Theobalt. Stylenerf: A style-based 3d aware generator for high-resolution image synthesis. In International Conference on Learning Representations, 2022.
247
+ [15] Peng Zhou, Lingxi Xie, Bingbing Ni, and Qi Tian. CIPS-3D: A 3D-Aware Generator of GANs Based on Conditionally-Independent Pixel Synthesis. arXiv preprint arXiv:2110.09788, 2021.
248
+ [16] Dario Pavllo, Jonas Kohler, Thomas Hofmann, and Aurelien Lucchi. Learning generative models of textured 3d meshes from real-world images. In IEEE/CVF International Conference on Computer Vision (ICCV), 2021.
249
+ [17] Yuxuan Zhang, Wenzheng Chen, Huan Ling, Jun Gao, Yinan Zhang, Antonio Torralba, and Sanja Fidler. Image {gan}s meet differentiable rendering for inverse graphics and interpretable 3d neural rendering. In International Conference on Learning Representations, 2021.
250
+ [18] Moritz Ibing, Isaak Lim, and Leif P. Kobbelt. 3d shape generation with grid-based implicit functions. In 2021 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), 2021.
251
+ [19] Ruihui Li, Xianzhi Li, Ke-Hei Hui, and Chi-Wing Fu. SP-GAN:sphere-guided 3d shape generation and manipulation. ACM Transactions on Graphics (Proc. SIGGRAPH), 40(4), 2021.
252
+ [20] A. Luo, T. Li, W. Zhang, and T. Lee. Surfgen: Adversarial 3d shape synthesis with explicit surface discriminators. In 2021 IEEE/CVF International Conference on Computer Vision (ICCV), 2021.
253
+ [21] Zhiqin Chen, Vladimir G. Kim, Matthew Fisher, Noam Aigerman, Hao Zhang, and Siddhartha Chaudhuri. Decor-gan: 3d shape detailization by conditional refinement. In Proceedings of IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 2021.
254
+ [22] Cheng Wen, Baosheng Yu, and Dacheng Tao. Learning progressive point embeddings for 3d point cloud generation. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 10266–10275, 2021.
255
+ [23] Zekun Hao, Arun Mallya, Serge Belongie, and Ming-Yu Liu. GANcraft: Unsupervised 3D Neural Rendering of Minecraft Worlds. In ICCV, 2021.
256
+ [24] Or Litany, Alex Bronstein, Michael Bronstein, and Ameesh Makadia. Deformable shape completion with graph convolutional autoencoders. CVPR, 2018.
257
+ [25] Qingyang Tan, Lin Gao, Yu-Kun Lai, and Shihong Xia. Variational autoencoders for deforming 3d mesh models. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 5841–5850, 2018.
258
+ [26] Kaichun Mo, Paul Guerrero, Li Yi, Hao Su, Peter Wonka, Niloy Mitra, and Leonidas J Guibas. Structurenet: Hierarchical graph networks for 3d shape generation. arXiv preprint arXiv:1908.00575, 2019.
259
+ [27] Lin Gao, Jie Yang, Tong Wu, Yu-Jie Yuan, Hongbo Fu, Yu-Kun Lai, and Hao(Richard) Zhang. SDM-NET: Deep generative network for structured deformable mesh. ACM Transactions on Graphics (Proceedings of ACM SIGGRAPH Asia 2019), 38(6):243:1–243:15, 2019.
260
+ [28] Lin Gao, Tong Wu, Yu-Jie Yuan, Ming-Xian Lin, Yu-Kun Lai, and Hao Zhang. Tm-net: Deep generative networks for textured meshes. ACM Transactions on Graphics (TOG), 40(6):263:1–263:15, 2021.
261
+ [29] Jinwoo Kim, Jaehoon Yoo, Juho Lee, and Seunghoon Hong. Setvae: Learning hierarchical composition for generative modeling of set-structured data. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), pages 15059–15068, June 2021.
262
+ [30] Paritosh Mittal, Yen-Chi Cheng, Maneesh Singh, and Shubham Tulsiani. AutoSDF: Shape priors for 3d completion, reconstruction and generation. In CVPR, 2022.
263
+ [31] Guandao Yang, Xun Huang, Zekun Hao, Ming-Yu Liu, Serge Belongie, and Bharath Hariharan. PointFlow: 3D point cloud generation with continuous normalizing flows. In ICCV, 2019.
264
+ [32] Hyeongju Kim, Hyeonseung Lee, Woo Hyun Kang, Joun Yeop Lee, and Nam Soo Kim. SoftFlow: Probabilistic framework for normalizing flow on manifolds. In NeurIPS, 2020.
265
+ [33] Roman Klokov, Edmond Boyer, and Jakob Verbeek. Discrete point flow networks for efficient point cloud generation. In ECCV, 2020.
266
+ [34] Aditya Sanghi, Hang Chu, Joseph G Lambourne, Ye Wang, Chin-Yi Cheng, and Marco Fumero. Clipforge: Towards zero-shot text-to-shape generation. arXiv preprint arXiv:2110.02624, 2021.
267
+ [35] Yongbin Sun, Yue Wang, Ziwei Liu, Joshua E Siegel, and Sanjay E Sarma. Pointgrow: Autoregressively learned point cloud generation with self-attention. In Winter Conference on Applications of Computer Vision, 2020.
268
+ [36] Charlie Nash, Yaroslav Ganin, S. M. Ali Eslami, and Peter W. Battaglia. Polygen: An autoregressive generative model of 3d meshes. ICML, 2020.
269
+ [37] Wei-Jan Ko, Hui-Yu Huang, Yu-Liang Kuo, Chen-Yi Chiu, Li-Heng Wang, and Wei-Chen Chiu. Rpg: Learning recursive point cloud generation. arXiv preprint arXiv:2105.14322, 2021.
270
+ [38] Moritz Ibing, Gregor Kobsik, and Leif Kobbelt. Octree transformer: Autoregressive 3d shape generation on hierarchically structured sequences. arXiv preprint arXiv:2111.12480, 2021.
271
+ [39] Jianwen Xie, Zilong Zheng, Ruiqi Gao, Wenguan Wang, Zhu Song-Chun, and Ying Nian Wu. Learning descriptor networks for 3d shape synthesis and analysis. In The IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 2018.
272
+ [40] Jianwen Xie, Yifei Xu, Zilong Zheng, Ruiqi Gao, Wenguan Wang, Zhu Song-Chun, and Ying Nian Wu. Generative pointnet: Deep energy-based learning on unordered point sets for 3d generation, reconstruction and classification. In The IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 2021.
273
+ [41] Tianchang Shen, Jun Gao, Kangxue Yin, Ming-Yu Liu, and Sanja Fidler. Deep marching tetrahedra: a hybrid representation for high-resolution 3d shape synthesis. In Advances in Neural Information Processing Systems (NeurIPS), 2021.
274
+ [42] Kangxue Yin, Jun Gao, Maria Shugrina, Sameh Khamis, and Sanja Fidler. 3dstylenet: Creating 3d shapes with geometric and texture style variations. In Proceedings of International Conference on Computer Vision (ICCV), 2021.
275
+ [43] Dongsu Zhang, Changwoon Choi, Jeonghwan Kim, and Young Min Kim. Learning to generate 3d shapes with generative cellular automata. In International Conference on Learning Representations, 2021.
276
+ [44] Chen Chao, Zhizhong Han, Yu-Shen Liu, and Matthias Zwicker. Unsupervised learning of fine structure generation for 3d point clouds by 2d projection matching. arXiv preprint arXiv:2108.03746, 2021.
277
+ [45] Ruojin Cai, Guandao Yang, Hadar Averbuch-Elor, Zekun Hao, Serge Belongie, Noah Snavely, and Bharath Hariharan. Learning gradient fields for shape generation. In Proceedings of the European Conference on Computer Vision (ECCV), 2020.
278
+ [46] Linqi Zhou, Yilun Du, and Jiajun Wu. 3d shape generation and completion through point-voxel diffusion. In Proceedings of the IEEE/CVF International Conference on Computer Vision (ICCV), 2021.
279
+ [47] 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 (CVPR), 2021.
280
+ [48] Yu Deng, Jiaolong Yang, and Xin Tong. Deformed implicit field: Modeling 3d shapes with learned dense correspondence. In IEEE Computer Vision and Pattern Recognition, 2021.
281
+ [49] Oscar Michel, Roi Bar-On, Richard Liu, Sagie Benaim, and Rana Hanocka. Text2mesh: Text-driven neural stylization for meshes. arXiv preprint arXiv:2112.03221, 2021.
282
+ [50] Ajay Jain, Ben Mildenhall, Jonathan T. Barron, Pieter Abbeel, and Ben Poole. Zero-shot text-guided object generation with dream fields. In IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 2022.
283
+ [51] Nasir Khalid, Tianhao Xie, Eugene Belilovsky, and Tiberiu Popa. Text to mesh without 3d supervision using limit subdivision. arXiv preprint arXiv:2203.13333, 2022.
284
+ [52] Le Hui, Rui Xu, Jin Xie, Jianjun Qian, and Jian Yang. Progressive point cloud deconvolution generation network. In ECCV, 2020.
285
+ [53] Jonathan Ho, Ajay Jain, and Pieter Abbeel. Denoising diffusion probabilistic models. In Advances in Neural Information Processing Systems, 2020.
286
+ [54] Jonathan Ho, Chitwan Saharia, William Chan, David J Fleet, Mohammad Norouzi, and Tim Salimans. Cascaded diffusion models for high fidelity image generation. arXiv preprint arXiv:2106.15282, 2021.
287
+ [55] Alexander Quinn Nichol and Prafulla Dhariwal. Improved denoising diffusion probabilistic models. In International Conference on Machine Learning, 2021.
288
+ [56] Prafulla Dhariwal and Alexander Quinn Nichol. Diffusion models beat GANs on image synthesis. In Advances in Neural Information Processing Systems, 2021.
289
+ [57] Robin Rombach, Andreas Blattmann, Dominik Lorenz, Patrick Esser, and Björn Ommer. High-resolution image synthesis with latent diffusion models. arXiv preprint arXiv:2112.10752, 2021.
290
+ [58] Arash Vahdat, Karsten Kreis, and Jan Kautz. Score-based generative modeling in latent space. In Advances in Neural Information Processing Systems, 2021.
291
+ [59] 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.
292
+ [60] Konpat Preechakul, Nattanat Chatthee, Suttisak Wizadwongsa, and Supasorn Suwajanakorn. Diffusion autoencoders: Toward a meaningful and decodable representation. In IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 2022.
293
+ [61] Tim Dockhorn, Arash Vahdat, and Karsten Kreis. Score-based generative modeling with critically-damped langevin diffusion. In International Conference on Learning Representations (ICLR), 2022.
294
+ [62] Zhisheng Xiao, Karsten Kreis, and Arash Vahdat. Tackling the generative learning trilemma with denoising diffusion GANs. In International Conference on Learning Representations (ICLR), 2022.
295
+ [63] 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.
296
+ [64] 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, Jonathan Ho, David J Fleet, and Mohammad Norouzi. Photorealistic text-to-image diffusion models with deep language understanding. arXiv preprint arXiv:2205.11487, 2022.
297
+ [65] Jascha Sohl-Dickstein, Eric Weiss, Niru Maheswaranathan, and Surya Ganguli. Deep unsupervised learning using nonequilibrium thermodynamics. In International Conference on Machine Learning, 2015.
298
+ [66] Yang Song and Stefano Ermon. Generative modeling by estimating gradients of the data distribution. In Proceedings of the 33rd Annual Conference on Neural Information Processing Systems, 2019.
299
+ [67] Yang Song, Jascha Sohl-Dickstein, Diederik P Kingma, Abhishek Kumar, Stefano Ermon, and Ben Poole. Score-based generative modeling through stochastic differential equations. In International Conference on Learning Representations, 2021.
300
+ [68] Songyou Peng, Chiyu "Max" Jiang, Yiyi Liao, Michael Niemeyer, Marc Pollefeys, and Andreas Geiger. Shape as points: A differentiable poisson solver. In Advances in Neural Information Processing Systems (NeurIPS), 2021.
301
+ [69] Diederik P Kingma, Tim Salimans, Ben Poole, and Jonathan Ho. Variational diffusion models. In Advances in Neural Information Processing Systems, 2021.
302
+ [70] Diederik P Kingma and Max Welling. Auto-encoding variational bayes. In The International Conference on Learning Representations, 2014.
303
+ [71] Danilo Jimenez Rezende, Shakir Mohamed, and Daan Wierstra. Stochastic backpropagation and approximate inference in deep generative models. In International Conference on Machine Learning, 2014.
304
+ [72] Jakub Tomczak and Max Welling. Vae with a vampprior. In International Conference on Artificial Intelligence and Statistics, pages 1214–1223, 2018.
305
+ [73] Hiroshi Takahashi, Tomoharu Iwata, Yuki Yamanaka, Masanori Yamada, and Satoshi Yagi. Variational autoencoder with implicit optimal priors. Proceedings of the AAAI Conference on Artificial Intelligence, 33(01):5066–5073, Jul. 2019.
306
+ [74] Matthias Bauer and Andriy Mnih. Resampled priors for variational autoencoders. In Kamalika Chaudhuri and Masashi Sugiyama, editors, Proceedings of the Twenty-Second International Conference on Artificial Intelligence and Statistics, volume 89 of Proceedings of Machine Learning Research, pages 66–75. PMLR, 16–18 Apr 2019.
307
+ [75] Arash Vahdat and Jan Kautz. NVAE: A deep hierarchical variational autoencoder. In Advances in Neural Information Processing Systems, 2020.
308
+ [76] Jyoti Aneja, Alexander Schwing, Jan Kautz, and Arash Vahdat. NCP-VAE: Variational autoencoders with noise contrastive priors. In Advances in Neural Information Processing Systems, 2021.
309
+ [77] Abhishek Sinha, Jiaming Song, Chenlin Meng, and Stefano Ermon. D2c: Diffusion-denoising models for few-shot conditional generation. In Advances in Neural Information Processing Systems, 2021.
310
+ [78] Mihaela Rosca, Balaji Lakshminarayanan, and Shakir Mohamed. Distribution matching in variational inference. arXiv preprint arXiv:1802.06847, 2018.
311
+ [79] Matthew D Hoffman and Matthew J Johnson. Elbo surgery: yet another way to carve up the variational evidence lower bound. In Workshop in Advances in Approximate Bayesian Inference, NeurIPS, 2016.
312
+ [80] Zhijian Liu, Haotian Tang, Yujun Lin, and Song Han. Point-voxel cnn for efficient 3d deep learning. In Advances in Neural Information Processing Systems, 2019.
313
+ [81] Charles R Qi, Hao Su, Kaichun Mo, and Leonidas J Guibas. Pointnet: Deep learning on point sets for 3d classification and segmentation. In IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 2017.
314
+ [82] Charles R Qi, Li Yi, Hao Su, and Leonidas J Guibas. Pointnet++: Deep hierarchical feature learning on point sets in a metric space. In Advances in Neural Information Processing Systems, 2017.
315
+ [83] Kaiming He, X. Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. In 2016 IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 2016.
316
+ [84] Yuxin Wu and Kaiming He. Group normalization. In Proceedings of the European Conference on Computer Vision (ECCV), 2018.
317
+ [85] 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, 2022.
318
+ [86] Nanxin Chen, Yu Zhang, Heiga Zen, Ron J Weiss, Mohammad Norouzi, and William Chan. Wavegrad: Estimating gradients for waveform generation. In International Conference on Learning Representations (ICLR), 2021.
319
+ [87] Zhifeng Kong, Wei Ping, Jiaji Huang, Kexin Zhao, and Bryan Catanzaro. DiffWave: A Versatile Diffusion Model for Audio Synthesis. In International Conference on Learning Representations, 2021.
320
+ [88] Myeonghun Jeong, Hyeongju Kim, Sung Jun Cheon, Byoung Jin Choi, and Nam Soo Kim. Diff-tts: A denoising diffusion model for text-to-speech. arXiv preprint arXiv:2104.01409, 2021.
321
+ [89] Nanxin Chen, Yu Zhang, Heiga Zen, Ron J. Weiss, Mohammad Norouzi, Najim Dehak, and William Chan. Wavegrad 2: Iterative refinement for text-to-speech synthesis. arXiv preprint arXiv:2106.09660, 2021.
322
+ [90] Vadim Popov, Ivan Vovk, Vladimir Gogoryan, Tasnima Sadekova, and Mikhail Kudinov. Grad-tts: A diffusion probabilistic model for text-to-speech. In International Conference on Machine Learning, 2021.
323
+ [91] Songxiang Liu, Dan Su, and Dong Yu. Diffgan-tts: High-fidelity and efficient text-to-speech with denoising diffusion gans. arXiv preprint arXiv:2201.11972, 2022.
324
+ [92] Gautam Mittal, Jesse Engel, Curtis Hawthorne, and Ian Simon. Symbolic music generation with diffusion models. In Proceedings of the 22nd International Society for Music Information Retrieval Conference, 2021.
325
+ [93] Kushagra Pandey, Avideep Mukherjee, Piyush Rai, and Abhishek Kumar. Diffusevae: Efficient, controllable and high-fidelity generation from low-dimensional latents. arXiv preprint arXiv:2201.00308, 2022.
326
+ [94] Danilo Jimenez Rezende and Shakir Mohamed. Variational inference with normalizing flows. In International Conference on Machine Learning, 2015.
327
+ [95] Laurent Dinh, Jascha Sohl-Dickstein, and Samy Bengio. Density estimation using real NVP. In International Conference on Learning Representations ICLR, 2017.
328
+ [96] Ricky T. Q. Chen, Yulia Rubanova, Jesse Bettencourt, and David Duvenaud. Neural ordinary differential equations. Advances in Neural Information Processing Systems, 2018.
329
+ [97] Will Grathwohl, Ricky T. Q. Chen, Jesse Bettencourt, Ilya Sutskever, and David Duvenaud. FFJORD: Free-form continuous dynamics for scalable reversible generative models. In International Conference on Learning Representations, 2019.
330
+ [98] Zhaoyang Lyu, Zhifeng Kong, Xudong XU, Liang Pan, and Dahua Lin. A conditional point diffusionrefinement paradigm for 3d point cloud completion. In International Conference on Learning Representations (ICLR), 2022.
331
+ [99] Thibault Groueix, Matthew Fisher, Vladimir G. Kim, Bryan Russell, and Mathieu Aubry. AtlasNet: A Papier-Mâché Approach to Learning 3D Surface Generation. In Proceedings IEEE Conf. on Computer Vision and Pattern Recognition (CVPR), 2018.
332
+ [100] Lars Mescheder, Michael Oechsle, Michael Niemeyer, Sebastian Nowozin, and Andreas Geiger. Occupancy networks: Learning 3d reconstruction in function space. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 4460–4470, 2019.
333
+ [101] Songyou Peng, Michael Niemeyer, Lars Mescheder, and Andreas Geiger Marc Pollefeys. Convolutional occupancy networks. In European Conference on Computer Vision (ECCV), 2020.
334
+
335
+ [102] Francis Williams, Matthew Trager, Joan Bruna, and Denis Zorin. Neural splines: Fitting 3d surfaces with infinitely-wide neural networks. In 2021 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), 2021.
336
+
337
+ [103] Francis Williams, Zan Gojcic, Sameh Khamis, Denis Zorin, Joan Bruna, Sanja Fidler, and Or Litany. Neural fields as learnable kernels for 3d reconstruction. arXiv preprint arXiv:2111.13674, 2021.
338
+
339
+ [104] Angel X. Chang, Thomas Funkhouser, Leonidas Guibas, Pat Hanrahan, Qixing Huang, Zimo Li, Silvio Savarese, Manolis Savva, Shuran Song, Hao Su, Jianxiong Xiao, Li Yi, and Fisher Yu. ShapeNet: An Information-Rich 3D Model Repository. Technical Report arXiv:1512.03012 [cs.GR], Stanford University — Princeton University — Toyota Technological Institute at Chicago, 2015.
340
+
341
+ [105] 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 International Conference on Machine Learning, ICML, 2021.
342
+
343
+ [106] Jiaming Song, Chenlin Meng, and Stefano Ermon. Denoising diffusion implicit models. In International Conference on Learning Representations, 2021.
344
+
345
+ [107] Wenzheng Chen, Huan Ling, Jun Gao, Edward Smith, Jaakko Lehtinen, Alec Jacobson, and Sanja Fidler. Learning to predict 3d objects with an interpolation-based differentiable renderer. In Advances in Neural Information Processing Systems, 2019.
346
+
347
+ [108] Samuli Laine, Janne Hellsten, Tero Karras, Yeongho Seol, Jaakko Lehtinen, and Timo Aila. Modular primitives for high-performance differentiable rendering. ACM Transactions on Graphics, 2020.
348
+
349
+ [109] Ben Mildenhall, Pratul P. Srinivasan, Matthew Tancik, Jonathan T. Barron, Ravi Ramamoorthi, and Ren Ng. Nerf: Representing scenes as neural radiance fields for view synthesis. In ECCV, 2020.
350
+
351
+ [110] Wenzheng Chen, Joey Litalien, Jun Gao, Zian Wang, Clement Fuji Tsang, Sameh Khamis, Or Litany, and Sanja Fidler. DIB- $\mathbf { \cdot R } { + + }$ : Learning to predict lighting and material with a hybrid differentiable renderer. In Advances in Neural Information Processing Systems (NeurIPS), 2021.
352
+
353
+ [111] Ayush Tewari, Justus Thies, Ben Mildenhall, Pratul Srinivasan, Edgar Tretschk, Yifan Wang, Christoph Lassner, Vincent Sitzmann, Ricardo Martin-Brualla, Stephen Lombardi, Tomas Simon, Christian Theobalt, Matthias Niessner, Jonathan T. Barron, Gordon Wetzstein, Michael Zollhoefer, and Vladislav Golyanik. Advances in neural rendering. arXiv preprint arXiv:2111.05849, 2021.
354
+
355
+ [112] Michael Oechsle, Lars Mescheder, Michael Niemeyer, Thilo Strauss, and Andreas Geiger. Texture fields: Learning texture representations in function space. In Proceedings IEEE International Conf. on Computer Vision (ICCV), 2019.
356
+
357
+ [113] Zhiqin Chen, Kangxue Yin, and Sanja Fidler. Auv-net: Learning aligned uv maps for texture transfer and synthesis. In The Conference on Computer Vision and Pattern Recognition (CVPR), 2022.
358
+
359
+ [114] Yawar Siddiqui, Justus Thies, Fangchang Ma, Qi Shan, Matthias Nießner, and Angela Dai. Texturify: Generating textures on 3d shape surfaces. arXiv preprint arXiv:2204.02411, 2022.
360
+
361
+ [115] Daniel Watson, Jonathan Ho, Mohammad Norouzi, and William Chan. Learning to efficiently sample from diffusion probabilistic models. arXiv preprint arXiv:2106.03802, 2021.
362
+
363
+ [116] Zhifeng Kong and Wei Ping. On fast sampling of diffusion probabilistic models. arXiv preprint arXiv:2106.00132, 2021.
364
+
365
+ [117] Alexia Jolicoeur-Martineau, Ke Li, Rémi Piché-Taillefer, Tal Kachman, and Ioannis Mitliagkas. Gotta Go Fast When Generating Data with Score-Based Models. arXiv preprint arXiv:2105.14080, 2021.
366
+
367
+ [118] Daniel Watson, William Chan, Jonathan Ho, and Mohammad Norouzi. Learning Fast Samplers for Diffusion Models by Differentiating Through Sample Quality. In International Conference on Learning Representations, 2022.
368
+
369
+ [119] Luping Liu, Yi Ren, Zhijie Lin, and Zhou Zhao. Pseudo numerical methods for diffusion models on manifolds. In International Conference on Learning Representations (ICLR), 2022.
370
+
371
+ [120] Tim Salimans and Jonathan Ho. Progressive distillation for fast sampling of diffusion models. In International Conference on Learning Representations (ICLR), 2022.
372
+
373
+ [121] Fan Bao, Chongxuan Li, Jun Zhu, and Bo Zhang. Analytic-DPM: an Analytic Estimate of the Optimal Reverse Variance in Diffusion Probabilistic Models. In International Conference on Learning Representations, 2022.
374
+ [122] Cristian Vaccari and Andrew Chadwick. Deepfakes and disinformation: Exploring the impact of synthetic political video on deception, uncertainty, and trust in news. Social Media $^ +$ Society, 6(1): 2056305120903408, 2020.
375
+ [123] Thanh Thi Nguyen, Quoc Viet Hung Nguyen, Cuong M. Nguyen, Dung Nguyen, Duc Thanh Nguyen, and Saeid Nahavandi. Deep learning for deepfakes creation and detection: A survey. arXiv preprint arXiv:1909.11573, 2021.
376
+ [124] Yisroel Mirsky and Wenke Lee. The creation and detection of deepfakes: A survey. ACM Comput. Surv., 54(1), 2021.
377
+ [125] Merlin Nimier-David, Delio Vicini, Tizian Zeltner, and Wenzel Jakob. Mitsuba 2: a retargetable forward and inverse renderer. ACM Transactions on Graphics, 38:1–17, 11 2019. doi: 10.1145/3355089.3356498.
378
+ [126] 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.
379
+ [127] Sungjoon Choi, Qian-Yi Zhou, Stephen Miller, and Vladlen Koltun. A large dataset of object scans. arXiv:1602.02481, 2016.
380
+ [128] Xingyuan Sun, Jiajun Wu, Xiuming Zhang, Zhoutong Zhang, Chengkai Zhang, Tianfan Xue, Joshua B Tenenbaum, and William T Freeman. Pix3d: Dataset and methods for single-image 3d shape modeling. In IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 2018.
381
+ [129] Brian DO Anderson. Reverse-time diffusion equation models. Stochastic Processes and their Applications, 12(3):313–326, 1982.
382
+ [130] Ulrich G Haussmann and Etienne Pardoux. Time reversal of diffusions. The Annals of Probability, pages 1188–1205, 1986.
383
+ [131] Pascal Vincent. A connection between score matching and denoising autoencoders. Neural Computation, 23(7):1661–1674, 2011.
384
+ [132] Radford M Neal and Geoffrey E Hinton. A view of the em algorithm that justifies incremental, sparse, and other variants. In Learning in graphical models, pages 355–368. Springer, 1998.
385
+ [133] Diederik P. Kingma and Max Welling. An introduction to variational autoencoders. Foundations and Trends in Machine Learning, 12(4):307–392, 2019.
386
+ [134] 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.
387
+ [135] Michael Kazhdan, Matthew Bolitho, and Hugues Hoppe. Poisson surface reconstruction. In Proceedings of the fourth Eurographics symposium on Geometry processing, volume 7, 2006.
388
+ [136] William E. Lorensen and Harvey E. Cline. Marching cubes: A high resolution 3d surface construction algorithm. In Proceedings of the 14th Annual Conference on Computer Graphics and Interactive Techniques, SIGGRAPH ’87, page 163–169, New York, NY, USA, 1987. Association for Computing Machinery.
389
+ [137] Jie Hu, Li Shen, and Gang Sun. Squeeze-and-excitation networks. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 7132–7141, 2018.
390
+ [138] Takeru Miyato, Toshiki Kataoka, Masanori Koyama, and Yuichi Yoshida. Spectral normalization for generative adversarial networks. In International Conference on Learning Representations, 2018.
391
+ [139] Laurens Van der Maaten and Geoffrey Hinton. Visualizing data using t-sne. Journal of machine learning research, 9(11), 2008.
392
+ [140] 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), 2019.
393
+ [141] Hengshuang Zhao, Li Jiang, Jiaya Jia, Philip HS Torr, and Vladlen Koltun. Point transformer. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 16259–16268, 2021.
394
+
395
+ # Checklist
396
+
397
+ 1. For all authors...
398
+
399
+ (a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes]
400
+ (b) Did you describe the limitations of your work? [Yes] Please see Sec. 6.
401
+ (c) Did you discuss any potential negative societal impacts of your work? [Yes] Please see Sec. 6.
402
+ (d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
403
+
404
+ 2. If you are including theoretical results...
405
+
406
+ (a) Did you state the full set of assumptions of all theoretical results? [N/A] We did not derive novel theoretical results. We rather propose a novel generative model of 3D shapes.
407
+ (b) Did you include complete proofs of all theoretical results? [N/A]
408
+
409
+ 3. If you ran experiments...
410
+
411
+ (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 release code and instructions to reproduce all experiments upon acceptance of the manuscript. The internal guidelines of our institution prevent us from releasing code at this stage.
412
+ (b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes] We provide all model training and evaluation details in the App. D, including all hyperparameters.
413
+ (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [No] Following standard conventions in the related 3D generative modeling literature, we do not report error bars. Furthermore, we avoid running similar setups repeatedly to save computational resources (our main models are quite large and require substantial GPU resources for training, see App. E.9).
414
+ (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] Please see App. E.9.
415
+
416
+ 4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
417
+
418
+ (a) If your work uses existing assets, did you cite the creators? [Yes] For baseline comparisons we run publicly available code from previous, publicly available papers, which we cite. We also use various datasets. Here, we present a summary. To compare to baselines, we use the following codes: • r-GAN, l-GAN [2]: https://github.com/optas/latent_3d_points (MIT License) • PointFlow [31]: https://github.com/stevenygd/PointFlow (MIT License) • SoftFlow [32]: https://github.com/ANLGBOY/SoftFlow • Set-VAE [29]: https://github.com/jw9730/setvae (MIT License) • DPF-NET [33]: https://github.com/Regenerator/dpf-nets • DPM [47]: https://github.com/luost26/diffusion-point-cloud (MIT License) • PVD [46]: https://github.com/alexzhou907/PVD (MIT License) • ShapeGF [45]: https://github.com/RuojinCai/ShapeGF (MIT License) • SP-GAN [19]: https://github.com/liruihui/sp-gan (MIT License) • PDGN [52]: https://github.com/fpthink/PDGN (MIT License) • IM-GAN [7]: https://github.com/czq142857/implicit-decoder (MIT license) and https://github.com/czq142857/IM-NET-pytorch (MIT license) • GCA [43]: https://github.com/96lives/gca (MIT license)
419
+
420
+ We use further codebases in other places:
421
+
422
+ • We use the MitSuba renderer for visualizations [125]: https: //github.com/mitsuba-renderer/mitsuba2 (License: https: //github.com/mitsuba-renderer/mitsuba2/blob/master/LICENSE),
423
+
424
+ and the code to generate the scene discription files for MitSuba [31]: https://github.com/zekunhao1995/PointFlowRenderer.
425
+ • We rely on SAP [68] for mesh generation with the code at https://github.com/ autonomousvision/shape_as_points (MIT License).
426
+ • For calculating the evaluation metrics, we use the implementation for CD at https: //github.com/ThibaultGROUEIX/ChamferDistancePytorch (MIT License) and for EMD at https://github.com/daerduoCarey/PyTorchEMD.
427
+ • We use Text2Mesh [49] for per-sample text-driven texture synthesis: https:// github.com/threedle/text2mesh (MIT License)
428
+
429
+ We also rely on the following datasets:
430
+
431
+ • ShapeNet [104]. Its terms of use can be found at https://shapenet.org/ terms.
432
+ • The Cars dataset [126] from http://ai.stanford.edu/\~jkrause/cars/car_ dataset.html with ImageNet License: https://image-net.org/download. php.
433
+ • The TurboSquid data repository, https://www.turbosquid.com. We obtained a custom license from TurboSquid.
434
+ • Redwood 3DScan Dataset [127]: https://github.com/isl-org/ redwood-3dscan (Public Domain)
435
+ • Pix3D [128]: https://github.com/xingyuansun/pix3d. (Creative Commons Attribution 4.0 International License).
436
+ (b) Did you mention the license of the assets? [Yes] In App. E.8, we mention the licenses of the codes and other assets we are using.
437
+ (c) Did you include any new assets either in the supplemental material or as a URL? [No]
438
+ (d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [N/A]
439
+ (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [No] We are primarily using the publicly available ShapeNet [104] dataset, which has been widely used in the generative modeling literature as standard benchmark. It only consists of simple 3D models of shapes such as airplanes, chairs, cars, etc.
440
+
441
+ 5. If you used crowdsourcing or conducted research with human subjects...
442
+
443
+ (a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A]
444
+ (b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A]
445
+ (c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]
md/dev/u03xn1COsO/u03xn1COsO.md ADDED
The diff for this file is too large to render. See raw diff
 
md/dev/uCXNOeL0TG/uCXNOeL0TG.md ADDED
@@ -0,0 +1,444 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Fairness for Workers Who Pull the Arms: An Index Based Policy for Allocation of Restless Bandit Tasks
2
+
3
+ Anonymous Author(s)
4
+ Affiliation
5
+ Address
6
+ email
7
+
8
+ # Abstract
9
+
10
+ 1 Motivated by applications such as machine repair, project monitoring, and anti
11
+ 2 poaching patrol scheduling, we study intervention planning of stochastic processes
12
+ 3 under resource constraints. This planning problem has previously been modeled as
13
+ 4 restless multi-armed bandits (RMAB), where each arm is an intervention-dependent
14
+ 5 Markov Decision Process. However, the existing literature assumes all intervention
15
+ 6 resources belong to a single uniform pool, limiting their applicability to real-world
16
+ 7 settings where interventions are carried out by a set of workers, each with their own
17
+ 8 costs, budgets, and intervention effects. In this work, we consider a novel RMAB
18
+ 9 setting, called multi-worker restless bandits (MWRMAB) with heterogeneous
19
+ 10 workers. The goal is to plan an intervention schedule that maximizes the expected
20
+ 11 reward while satisfying budget constraints on each worker as well as fairness in
21
+ 12 terms of the load assigned to each worker. Our contributions are two-fold: (1) we
22
+ 13 provide a multi-worker extension of the Whittle index to tackle heterogeneous
23
+ 14 costs and per-worker budget and (2) we develop an index-based scheduling policy
24
+ 15 to achieve fairness. Further, we evaluate our method on various cost structures and
25
+ 16 show that our method significantly outperforms other baselines in terms of fairness
26
+ 17 without sacrificing much in reward accumulated.
27
+
28
+ # 18 1 Introduction
29
+
30
+ 19 Restless multi-armed bandits (RMABs) Whittle [1988] have been used for sequential planning, where
31
+ 20 a planner allocates a limited set of $M$ intervention resources across $N$ independent heterogeneous
32
+ 21 arms (Markov Decision processes) at each time step in order to maximize the long-term expected
33
+ 22 reward. The term restless denotes that the arms undergo state-transitions even when they are not
34
+ 23 acted upon (with a different probability than when they are acted upon). RMABs have been receiving
35
+ 24 increasing attention across a wide range of applications such as maintenance [Abbou and Makis,
36
+ 25 2019], recommendation systems Meshram et al. [2015], anti-poaching patrolling [Qian et al., 2016b],
37
+ 26 and adherence monitoring [Akbarzadeh and Mahajan, 2019; Mate et al., 2020]. Although, rangers
38
+ 27 in anti-poaching, healthcare workers in health intervention planning, and supervisors in machine
39
+ 28 maintenance are all commonly cited examples of human workforce used as intervention resources, the
40
+ 29 literature has so far ignored one key reality that the human workforce is heterogeneous—each worker
41
+ 30 has their own workload constraints and needs to commit a dedicated time duration for intervening on
42
+ 31 an arm. Thus, it is critical to restrict intervention workload for each worker and balance the workload
43
+ 32 across them, while also ensuring high effectiveness (reward) of the planning policy.
44
+ 33 RMAB literature does not consider this heterogeneity and mostly focuses on selecting best arms
45
+ 34 assuming that all intervention resources (workers) are interchangeable, i.e., as from a single pool
46
+ 35 (homogeneous). However, planning with human workforce requires more expressiveness in the
47
+ 36 model, including heterogeneity in costs and intervention effects, worker-specific load constraints, and
48
+ 37 balanced work allocation. One concrete example is anti-poaching intervention planning Qian et al.
49
+ 38 $\pm \pm { \sqrt { 2 0 1 6 \mathrm { a } } } ]$ with $N$ areas in a national park where timely interventions (patrols) are required to detect as
50
+ 39 many snares as possible across all the areas. These interventions are carried out by a small set of $M$
51
+ 40 ranger. The problem of selecting a subset of areas at each time step (say, daily) has been modeled as
52
+ 41 an RMAB problem. However, each ranger may incur heterogeneous cost (e.g., distance travelled,
53
+ 42 when assigned to intervene on a particular area) and the total cost incurred by any ranger (e.g., total
54
+ 43 distance traveled) must not exceed a given budget. Additionally, it is important to ensure that tasks
55
+ 44 are allocated fairly across rangers so that, for e.g., some rangers are not required to walk far greater
56
+ 45 distances than others. Adding this level of expressiveness to existing RMAB models is non-trivial.
57
+ 46 To address this, we introduce the multi-worker restless multi-armed bandits (MWRMAB) problem.
58
+ 47 Since MWRMABs are more general than the classical RMABs, they are at least PSPACE hard to
59
+ 48 solve optimally [Papadimitriou and Tsitsiklis, 1994]. RMABs with $k$ -state arms require solving a
60
+ 49 combined MDP with $\overline { { k ^ { N } } }$ states and $| M + 1 | ^ { N }$ actions constrained by a budget, and thus suffers from
61
+ 50 the curse of dimensionality. A typical approach is to compute Whittle indices [Whittle, 1988] for
62
+ 51 each arm and choose $M$ arms with highest index values—an asymptotically optimal solution under
63
+ 52 the technical condition indexability [Weber and Weiss, 1990]. However, this approach is limited to
64
+ 53 instances a single type of intervention resource incurring one unit cost upon intervention. A few papers
65
+ 54 on RMABs [Glazebrook et al., 2011; Meshram and Kaza, $\boxed { 2 0 2 0 }$ study multiple interventions and
66
+ 55 non-unitary costs but assumes one global budget (instead of per-worker budget). Existing solutions
67
+ 56 aim at maximizing reward by selecting arms with highest index values that may not guarantee fairness
68
+ 57 towards the workers who are in charge of providing interventions.
69
+ 58 To the best of our knowledge, we are the first to introduce and formalize the multi-worker restless
70
+ 59 multi-armed bandit (MWRMAB) problem and a related worker-centric fairness constraint. We
71
+ 60 develop a novel framework for solving the MWRMAB problem. Further, we empirically evaluate our
72
+ 61 algorithm to show that it is fair and scalable across a range of experimental settings.
73
+
74
+ # 62 2 Related Work
75
+
76
+ 63 Multi-Action RMABs and Weakly Coupled MDPs Glazebrook et al. [2011] develop closed-form
77
+ 64 solutions for multi-action RMABs using Lagrangian relaxation. Meshram and Kaza [2020] build
78
+ 65 simulation-based policies that rely on monte-carlo estimation of state-action values. However,
79
+ 66 critically, these approaches rely on actions being constrained by a single budget, failing to capture the
80
+ 67 heterogeneity of workforce. On the other hand, weakly coupled MDPs (WCMDPs) Hawkins [2003]
81
+ 68 allow for such multiple budget constraints; this is the baseline we compare against. Other theoretical
82
+ 69 works Adelman and Mersereau $\mathbb { \underline { { \left. 2 0 0 8 \right. } } }$ ; Gocgun and Ghate $\mathbb { \underline { { \left. 2 0 1 2 \right. } } }$ have developed solutions in terms
83
+ 70 of the reward accumulated, but may not scale well with increasing problem size. These papers do not
84
+ 71 consider fairness, a crucial component of MWRMABs, which our algorithm addresses.
85
+ 72 Fairness in stochastic and contextual multi-armed bandits (MABs) [Patil et al., 2020; Joseph et al.,
86
+ 73 2016; Chen et al., 2020] has been receiving significant attention. However, fairness in RMABs has
87
+ 74 been less explored. Recent work by Herlihy et al. [2021] considered quota-based fairness of RMAB
88
+ 75 arms assuming that arms correspond to human beneficiaries (for example, patients). However, in our
89
+ 76 work, we consider an orthogonal problem of satisfying the fairness among intervention resources
90
+ 77 (workers) instead of arms (tasks).
91
+ 78 Fair allocation of discrete items among a set of agents has been a well studied topic [Brandt et al.,
92
+ 79 2016]. Fairness notions such as envy-freeness up to one item [Budish, 2011] and their budgeted
93
+ 80 settings [Wu et al., 2021; Biswas and Barman, 2018] align with the fairness notion we consider.
94
+ 81 However, these papers do not consider non-stationary (MDP) items. Moreover, these papers assume
95
+ 82 that each agent has a value for every item; both fairness and efficiency are defined with respect to this
96
+ 83 valuation. In contrast, in MWRMAB, efficiency is defined based on reward accumulated and fairness
97
+ 84 and budget feasibility are defined based on the cost incurred.
98
+
99
+ # 85 3 The Model
100
+
101
+ 86 There are $M$ workers for providing interventions on $N$ independent arms that follow Markov Decision
102
+ 87 Processes (MDPs). Each MDP $i \in [ N ]$ is a tuple $\langle S _ { i } , A _ { i } , C _ { i } , P _ { i } , R _ { i } \rangle$ , where $S _ { i }$ is a finite set of states.
103
+ 88 We represent each worker as an action, along with an additional action called no-intervention. Thus,
104
+
105
+ action set is 89 $A _ { i } \subseteq [ M ] \cup \{ 0 \}$ . $C _ { i }$ is a vector of costs $c _ { i j }$ incurred when an action $j \in [ A _ { i } ]$ is taken on an arm 90 $i \in [ N ]$ , and $c _ { i j } = 0$ when $j = 0$ . $P _ { i j } ^ { s s ^ { \prime } }$ is the probability of transitioning from state $s$ to state 91 $s ^ { \prime }$ when arm $i$ is allocated to worker $j$ . $R _ { i } ( s )$ is the reward obtained in state $s \in S _ { i }$ .
106
+
107
+ 92 The goal $( \mathrm { E q . } \bigcirc \bigcirc )$ is to allocate a subset of arms to each worker such that the expected reward is
108
+ 93 maximized while ensuring that each worker incurs a cost of at most a fixed value $B$ . Additionally,
109
+ 94 the disparity in the costs incurred between any pair of workers does not exceed a fairness threshold $\epsilon$
110
+ 95 at a given time step. Let us denote a policy $\pi : \times _ { i } S _ { i } \mapsto \times _ { i } A _ { i }$ that maps the current state profile of
111
+ 96 arms to an action profile. $x _ { i j } ^ { \pi } ( s ) \in \{ 0 , 1 \}$ indicates whether worker $j$ intervenes on arm $i$ at state $s$
112
+ 97 under policy $\pi$ . The total cost incurred by $j$ at a time step $t$ is given by $\begin{array} { r } { \overline { { C } } _ { j } ^ { \pi } ( t ) : = \sum _ { i \in N } c _ { i j } x _ { i j } ^ { \pi } ( s _ { i } ( t ) ) } \end{array}$
113
+ 98 where $s _ { i } ( t )$ is the current state. $\epsilon \geq c ^ { m } : = \operatorname* { m a x } _ { i j } c _ { i j }$ ensures feasibility of the fairness constraints.
114
+
115
+ $$
116
+ \begin{array} { l } { \displaystyle \operatorname* { m a x } _ { \pi } \displaystyle \operatorname* { l i m s u p } _ { T \infty } \frac { 1 } { T } \sum _ { i \in [ N ] } \mathbb { E } [ \sum _ { t = 1 } ^ { T } R _ { i } ( s _ { i } ( t ) ) x _ { i j } ^ { \pi } ( s _ { i } ( t ) ) ] } \\ { \mathrm { s . t . } \displaystyle \sum _ { i \in N } x _ { i j } ^ { \pi } ( s _ { i } ( t ) ) c _ { i j } \leq B , \quad \quad \forall j \in [ M ] , \forall t \in \{ 1 , 2 , \ldots \} } \\ { \displaystyle \sum _ { j \in A _ { i } } x _ { i j } ^ { \pi } ( s _ { i } ( t ) ) = 1 , \quad \quad \forall i \in [ N ] , \forall t \in \{ 1 , 2 , \ldots \} } \\ { \displaystyle \operatorname* { m a x } _ { j } \overline { { C } } _ { j } ^ { \pi } ( t ) - \operatorname* { m i n } \overline { { C } } _ { j } ^ { \pi } ( t ) \leq \epsilon , \quad \forall t \in \{ 1 , 2 , \ldots \} } \\ { \displaystyle x _ { i j } ^ { \pi } ( s _ { i } ( t ) ) \in \{ 0 , 1 \} , \quad \quad \forall i , \forall j , \forall t . } \end{array}
117
+ $$
118
+
119
+ 99 When $M = 1$ and $c _ { i 1 } = 1$ , Problem $\mathbb { \underline { { ( 1 ) } } }$ becomes classical RMAB problem (with two actions,
120
+ 100 active and passive) that can be solved via Whittle Index method [Whittle, 1988] by considering a
121
+ 101 time-averaged relaxed version of the budget constraint and then decomposing the problem into $N$
122
+ 102 subproblems—each subproblem finds a charge $\lambda _ { i } ( s )$ on active action that makes passive action as
123
+ 103 valuable as the active action at state $s$ . It then selects top $B$ arms according to $\lambda _ { i }$ values at their
124
+ 104 current states. However, the challenges involved in solving a general MWRMAB (Eq. 1) are (i) index
125
+ 105 computation becomes non-trivial with $M > 1$ workers and (ii) selecting top arms based on indices
126
+ 106 may not satisfy fairness. To tackle these challenges, we propose a framework in the next section.
127
+
128
+ # 107 4 Methodology
129
+
130
+ 108 Step 1: Decompose the combinatorial MWRMAB problem to $N \times M$ subproblems, and compute
131
+ 109 Whittle indices ${ \lambda } _ { i j } ^ { \star }$ for each subproblem. We tackle this in Sec. 4.1.This step assumes that, for each
132
+ 110 arm $i$ , MDPs corresponding to any pair of workers are mutually independent. However, the expected
133
+ 111 value of each arm may depend on interventions taken by multiple workers at different timesteps.
134
+
135
+ Step 2: Adjust the decoupled indices ${ \lambda } _ { i j } ^ { * }$ to create $\lambda _ { i j } ^ { a d j , * }$ , detailed in Sec. 4.2.
136
+
137
+ Step 3: The adjusted indices are used for allocating the arms to workers while ensuring fairness and per-timestep budget feasibility among workers, detailed in Sec. 4.3.
138
+
139
+ # 15 4.1 Identifying subproblem structure
140
+
141
+ 116 To arrive at a solution strategy, we relax the per-timestep budget constraints of Eq. $\perp$ to time
142
+ 117 averaged constraints, as follows: $\begin{array} { r } { \frac { 1 } { T } \sum _ { i \in [ N ] } \mathbb { E } \sum _ { t = 1 } ^ { \hat { T } } x _ { i j } ^ { \pi } \big ( s _ { i } ( t ) \big ) c _ { i j } \leq B , \forall j \in [ M ] . } \end{array}$ The optimization
143
+ 118 problem $\mathbb { D }$ can be rewritten as:
144
+
145
+ $$
146
+ \begin{array} { r l } { \displaystyle \underset { \{ \lambda _ { j } \geq 0 \} } { \operatorname* { m i n } } \underset { \pi } { \operatorname* { m a x } } } & { \displaystyle \operatorname* { l i m } _ { T \to \infty } \frac { 1 } { T } \underset { i \in [ N ] } { \sum } \mathbb { E } \left[ \underset { t = 1 } { \overset { T } { \sum } } \left( R _ { i } ( s _ { i } ( t ) ) x _ { i j } ^ { \pi } ( s _ { i } ( t ) ) + \underset { j \in [ M ] } { \sum } \lambda _ { j } ( B - c _ { i j } x _ { i j } ^ { \pi } ( s _ { i } ( t ) ) \right) \right] } \\ & { \mathrm { s . t . } \displaystyle \sum _ { j \in A _ { i } } x _ { i j } ^ { \pi } ( s _ { i } ( t ) ) = 1 , } \\ & { \displaystyle \underset { j } { \operatorname* { m a x } } \widetilde { C } _ { j } ^ { \pi } ( t ) - \underset { j } { \operatorname* { m i n } } \overline { { C } } _ { j } ^ { \pi } ( t ) \leq \epsilon , } \\ & { \displaystyle x _ { i j } ^ { \pi } ( s _ { i } ( t ) ) \in \{ 0 , 1 \} , \forall i , \forall t } \end{array}
147
+ $$
148
+
149
+ 119 Here, $\lambda _ { j } \mathbf { s }$ are Lagrangian multipliers corresponding to each relaxed budget constraint $j \in [ M ]$ .
150
+ 120 Furthermore, as mentioned in $\boxed { \mathrm { G l a z e b r o o k } \ e t a \dot { l } . } \boxed { 2 0 1 1 }$ , if an arm $i$ is indexable, then the optimization
151
+ 121 objective $( 2 )$ can be decomposed into $N$ independent subproblems, and separate index functions can
152
+ 122 be defined for each arm $i$ . Leveraging this, we decompose our problem to $N \times M$ subproblems, each
153
+ 123 finding the minimum $\lambda _ { i j }$ that maximizes the following:
154
+
155
+ $$
156
+ \operatorname* { l i m } _ { T \to \infty } \frac { 1 } { T } \mathbb { E } \biggl [ \sum _ { t = 1 } ^ { T } \left( R _ { i } ( s _ { i } ( t ) ) - \lambda _ { i j } c _ { i j } \right) x _ { i j } ^ { \pi } ( s _ { i } ( t ) ) \biggr ]
157
+ $$
158
+
159
+ 124 Note that, the maximization subproblem $\underline { { \mathbb { ( 3 ) } } }$ does not have the term $\lambda _ { i j } B$ since the term does not
160
+ 125 depend on the decision $x _ { i j } ^ { \pi } ( s _ { i } ( t ) )$ . Considering a 2-action MDP with action space $\mathcal { A } _ { i j } = \{ 0 , j \}$ for
161
+ 126 an arm-worker pair, the maximization problem $\textcircled { 3 }$ can be solved by dynamic programming methods
162
+ 127 using Bellman’s equations for each state to decide whether to take an active action $( x _ { i j } ( s ) = 1 )$ when
163
+ 128 the arm is currently at state $s$ :
164
+
165
+ $$
166
+ V _ { i , j } ^ { t } ( s , \lambda _ { i j } , x _ { i j } ( t ) ) = \left\{ \begin{array} { l l } { { R _ { i } ( s ) - \lambda _ { i j } c _ { i j } \displaystyle + \sum _ { s ^ { \prime } \in S _ { i } } P _ { s s ^ { \prime } } ^ { i j } V _ { i , j } ^ { t + 1 } ( s ^ { \prime } , \lambda _ { i j } ) \mathrm { , ~ i f ~ } x _ { i j } ( t ) = 1 } } \\ { { \displaystyle R _ { i } ( s ) + \sum _ { s ^ { \prime } \in S _ { i } } P _ { s s ^ { \prime } } ^ { i 0 } V _ { i , j } ^ { t + 1 } ( s ^ { \prime } , \lambda _ { i j } ) \mathrm { , ~ i f ~ } x _ { i j } ( t ) = 0 } } \end{array} \right.
167
+ $$
168
+
169
+ 129
170
+
171
+ $$
172
+ \lambda _ { i j } ^ { \star } ( s ) = \arg \operatorname* { m i n } \{ \lambda : V _ { i , j } ^ { t } ( s , \lambda , j ) = = V _ { i , j } ^ { t } ( s , \lambda , 0 ) \}
173
+ $$
174
+
175
+ We compute the Whittle indices 130 ${ \lambda } _ { i j } ^ { \star }$ (Eq. 5) [Qian et al., 2016b] (the algorithm is in Appendix $\mathbf { A } )$
176
+
177
+ 131 Additionally, we establish that the Whittle indices of multiple workers are related when the costs
178
+ 132 and transition probabilities possess certain characteristics, enabling simplification of Whittle Index
179
+ 133 computation for multiple workers when there are certain structures in the MWRMAB problem.
180
+
181
+ Theorem 1. For an arm 34 $i$ , and a pair of workers $j$ and $j ^ { \prime }$ such that $c _ { i j } \neq c _ { i j ^ { \prime } }$ and $P _ { s s ^ { \prime } } ^ { i j } = P _ { s s ^ { \prime } } ^ { i j ^ { \prime } }$ P ij0ss0 for every 35 $s , s ^ { \prime } \in S _ { i }$ , then their Whittle Indices are inversely proportional to their costs.
182
+
183
+ $$
184
+ \frac { { \lambda } _ { i j } ^ { \star } ( s ) } { { \lambda } _ { i j ^ { \prime } } ^ { \star } ( s ) } = \frac { c _ { i j ^ { \prime } } } { c _ { i j } } f o r e a c h s t a t e s \in \mathcal { S } _ { i }
185
+ $$
186
+
187
+ 136 Proof. Let us consider an arm $i$ and a pair of workers $j$ and $j ^ { \prime }$ such that $P _ { s s ^ { \prime } } ^ { i j } = P _ { s s ^ { \prime } } ^ { i j ^ { \prime } }$ . By definition
188
+ 137 of Whittle Index $\lambda _ { j } ( s )$ for a worker $j$ , it is the minimum value at a state $s$ such that,
189
+
190
+ $$
191
+ V _ { i j } ( s , \lambda _ { j } ( s ) , j ) - V _ { i j } ( s , \lambda _ { j } ( s ) , 0 ) = 0
192
+ $$
193
+
194
+ 138 Eq. $\boxed { 6 }$ can be rewritten by expanding the value functions as:
195
+
196
+ $$
197
+ \begin{array} { r l } & { R _ { i } ( s ) - \lambda _ { j } ( s ) c _ { i j } + \displaystyle \sum _ { s ^ { \prime } \in S _ { i } } P _ { s s ^ { \prime } } ^ { i j } V _ { i } ( s ^ { \prime } , \lambda _ { j } ( s ) ) - R _ { i } ( s ) + \displaystyle \sum _ { s ^ { \prime } \in S _ { i } } P _ { s s ^ { \prime } } ^ { i 0 } V _ { i } ( s ^ { \prime } , \lambda _ { j } ( s ) ) = 0 } \\ { \Longrightarrow \quad } & { - \lambda _ { j } ( s ) c _ { i j } + \displaystyle \sum _ { s ^ { \prime } \in S _ { i } } P _ { s s ^ { \prime } } ^ { i j } V _ { i } ( s ^ { \prime } , \lambda _ { j } ( s ) ) - \displaystyle \sum _ { s ^ { \prime } \in S _ { i } } P _ { s s ^ { \prime } } ^ { i 0 } V _ { i } ( s ^ { \prime } , \lambda _ { j } ( s ) ) = 0 } \\ { , V _ { i } ( s ^ { \prime } , \lambda _ { j } ( s ^ { \prime } ) ) = \displaystyle \operatorname* { m a x } _ { a = \{ 0 , j \} } R _ { i } ( s ) - a \lambda _ { j } ( s ) c _ { i j } + \mathbb { E } _ { s ^ { \prime \prime } } [ V _ { i } ( s ^ { \prime \prime } , \lambda ( s ) ) ] . } \end{array}
198
+ $$
199
+
200
+ Next, we substitute all 140 $\lambda _ { j } ( s )$ terms by $\frac { x } { c _ { i j } }$ . After substitution, Eq. $^ { 7 }$ is a function of $x$ only, i.e., no 141 $\lambda ( s )$ or $c _ { i j }$ terms remain after substitution. We can rewrite Eq. 7 as:
201
+
202
+ $$
203
+ - x + \sum _ { s ^ { \prime } \in S _ { i } } P _ { s s ^ { \prime } } ^ { i j } V _ { i } ( s ^ { \prime } , x ) - \sum _ { s ^ { \prime } \in S _ { i } } P _ { s s ^ { \prime } } ^ { i 0 } V _ { i } ( s ^ { \prime } , x ) = 0
204
+ $$
205
+
206
+ 142 Note that $x ^ { * }$ that minimizes Eq. $8$ corresponds to $\lambda _ { j } ( s ) c _ { i j }$ for any $j$ , where $\lambda _ { j } ( s )$ is the Whittle index 143 for worker $j$ . Therefore, for any two workers $j$ and $j ^ { \prime }$ with corresponding Whittle Indices as $\lambda _ { j } ( s )$ and 144 $\lambda _ { j ^ { \prime } } ( s )$ , we obtain $\lambda _ { j } ( s ) c _ { i j } = \lambda _ { j ^ { \prime } } ( s ) c _ { i j ^ { \prime } }$ whenever $P _ { s s ^ { \prime } } ^ { i j } = P _ { s s ^ { \prime } } ^ { i j ^ { \prime } }$ . This completes the proof.
207
+
208
+ 45 Theorem $\mathbb { L }$ also implies that, when the costs and effectiveness of two workers are equal, then their
209
+ 46 Whittle indices are also equal, stated formally in Corollary 1.
210
+ 147 Corollary 1. For an arm $i$ , and a pair of workers $j$ and $j ^ { \prime }$ such that $c _ { i j } = c _ { i j { ' } }$ and $P _ { s s ^ { \prime } } ^ { i j } = P _ { s s ^ { \prime } } ^ { i j ^ { \prime } }$ P ij0ss0 for
211
+ 148 every $s , s ^ { \prime } \in S _ { i }$ , then their Whittle Indices are the same.
212
+
213
+ The indices obtained using Alg. $\begin{array} { l } { 3 } \\ { . } \end{array}$ are not indicative of the true long-term value of taking that action in the MWRMAB problem. This is because, for a given arm, the value of an intervention by worker $j$ in general depends on interventions by other workers $j ^ { \prime }$ at different timesteps.
214
+
215
+ 53 Consider a 2-worker MWRMAB corresponding to an anti-poaching patrol planning problem, where
216
+ 154 each worker is a type of “specialist” with different equipment (detailed in Fig. 1).
217
+
218
+ The first ranger (worker), $a _ { 1 }$ , has special equipment for clearing overgrown brush, and the second ranger, $a _ { 2 }$ , has specialized equipment for detecting snares, e.g., a metal detector. Assume 3 states for each patrol area $i$ as “overgrown and snared” $( s = 0$ ), “clear and snared” $( s = 1 )$ ), and “clear and not snared” $s = 2 ,$ ). Assume that reward is received only for arms in state $s = 2$ , and that snares cannot be cleared from areas with overgrown brush, i.e., $P _ { i j } ^ { 0 2 } = 0 \forall j \in$ $[ M ]$ . If we assume that each worker is a “true” specialist— so, ranger 1’s equipment is ineffective at detecting snares, i.e., $\mathbf { \dot { P } } _ { i 1 } ^ { 1 2 } = 0$ , and ranger 2’s equipment is ineffective at clearing overgrown brush, i.e., $P _ { i 2 } ^ { 0 1 } = 0$ — then the opti
219
+
220
+ ![](images/a24623791768a5062d60b45e6d4024cb0789c90dc56b044e61a1bc1ea7f9687f.jpg)
221
+ Figure 1: Specialist domain: where specific actions are required in each state to advance to the rewardgiving state. Decoupled indices lead to sub-optimal policies, whereas adjusted indices perform well.
222
+
223
+ 170 mal policy is for ranger 1 to act on the arm in state “overgrown and snared” and ranger 2 to act on the
224
+ 171 arm in state “clear and snared”. However, the fully decoupled index computation for each ranger $j$
225
+ 172 would reason about restricted MDPs that only have passive action and ranger type $j$ available. So
226
+ 173 when computing, e.g., the index for ranger 1 in $s = 0$ , the restricted MDP would have 0 probability
227
+ 174 of reaching state “clear and not snared”, since it does not include ranger 2 in its restricted MDP. This
228
+ 175 would correspond to an MDP that always gives 0 reward, and thus would artificially force the index
229
+ 176 for ranger 1 to be 0, despite ranger 1 being the optimal action for $s = 0$ .
230
+ 177 To address this, we define a new index notion that accounts for such inter-action effects. The key idea
231
+ 178 is that, when computing the index for a given worker, we will consider actions of all other workers
232
+ 179 in future time steps. So in our poaching example, the new index value for ranger 1 in $s = 0$ will
233
+ 180 increase compared to its decoupled index value, because the new index will take into account the
234
+ 181 value of ranger 2’s actions when the system progresses to $s = 1$ in the future. Note that the methods
235
+ 182 we build generalize to any number of workers $M$ . However, the manner in which we incorporate the
236
+ 183 actions of other workers must be done carefully, We propose an approach and provide theoretical
237
+ 184 results explaining why. Finally, we give the full algorithm for computing the new indices.
238
+ 185 New index notion: For a given arm, to account for the inter-worker action effects, we define the
239
+ 186 new index for an action $j$ as the minimum charge that makes an intervention by $j$ on that arm
240
+ 187 as valuable as any other worker $j ^ { \prime }$ in the combined MDP, with $M + 1$ actions. That is, we seek
241
+ 188 the minimum charge for action $j$ that makes us indifferent between taking action $j$ and not taking
242
+ 189 action $j$ , a multi-worker extension Whittle’s index notion. To capture this, we define an augmented
243
+ 190 reward function $R _ { \lambda } ^ { \dagger } ( s , j ) = R ( s ) - \lambda _ { j } c _ { j }$ . Let $\lambda$ is the vector of $\{ \lambda _ { j } \} _ { j \in [ M ] }$ charges. We define this
244
+ 191 expanded MDP as $\mathcal { M } _ { \lambda } ^ { \dagger }$ and the corresponding value function as $V _ { \lambda } ^ { \dagger }$ . We now find adjusted index
245
+ 192 $\lambda _ { j , \lambda _ { - j } } ^ { a d j , \ast }$ using the following expression:
246
+
247
+ $$
248
+ \operatorname* { m i n } _ { j ^ { \prime } \in [ M ] \setminus \{ j \} } \arg \operatorname* { m i n } _ { \lambda _ { j } } \{ \lambda _ { j } \colon V _ { \lambda _ { - j } } ^ { \dagger } ( s , \lambda _ { j } , j ) = V _ { \lambda _ { - j } } ^ { \dagger } ( s , \lambda _ { j } , j ^ { \prime } ) \}
249
+ $$
250
+
251
+ 193 where $\lambda _ { - j }$ is a vector of fixed charges for all $j ^ { \prime } \ne j$ , and the outer min over $j ^ { \prime }$ simply captures the
252
+ 194 specific action $j ^ { \prime }$ that the optimal planner is indifferent to taking over action $j$ at the new index value.
253
+ 195 Note, this is the natural extension of the decoupled two-action index definition, Eq. $( 5 )$ , which defines
254
+ 196 the index as the charge on $j$ that makes the planner indifferent between acting and, the only other
255
+ 197 option, being passive. Our new adjusted index algorithm is given in Alg. 1.
256
+ 198 We use a binary search procedure to compute the adjusted indices since $V _ { \lambda _ { - j } } ^ { \dagger } ( s , \lambda _ { j } , j )$ is convex in
257
+ 199 $\lambda _ { j }$ . The most important consideration of the adjusted index computation is how to set the charges
258
+ 200 $\lambda _ { j ^ { \prime } }$ of the other action types $j ^ { \prime }$ when computing the index for action $j$ . We show that a reasonable
259
+
260
+ # Algorithm 1 Adjusted Index Computation
261
+
262
+ Input: An arm: MDP $\mathcal { M } ^ { \dagger }$ , costs $c _ { j }$ , state $s$ , and indices $\lambda _ { j } ^ { * } ( s )$
263
+
264
+ 1: for $j = 1$ to $M$ do
265
+ 2: $\lambda _ { j } = \lambda _ { j } ^ { * } ( s ) \left\{ { \mathrm { i n i t } } \lambda \right\} .$ }
266
+ 3: for 4: $j = 1$ to te $M$ {via binary search on Eq. 9}
267
+ $\lambda _ { j , \lambda _ { - j } } ^ { a d j , * } ( s )$
268
+ 5: return $\lambda _ { j , \lambda _ { - j } } ^ { a d j , * } ( s )$ for all workers $j \in [ M ]$
269
+
270
+ choice for $\lambda _ { j ^ { \prime } }$ is the Whittle Indices $\lambda _ { j ^ { \prime } } ^ { * } ( s )$ which were pre-computed using Alg. $\bigstar$ The intuition is that $\lambda _ { j ^ { \prime } } ^ { * } ( s )$ provides a lower bound on how valuable the given action $j ^ { \prime }$ is, since it was computed against no-action in the restricted two-action MDP. In Observation $\bigstar$ and Theorem $\bigtriangledown$ we describe the problem’s structure to motivate these choices.
271
+
272
+ The following observation explicitly connects decoupled indices and adjusted indices.
273
+
274
+ holds: Observation 1. For each worker $\lambda _ { j , \lambda _ { - j } } ^ { a d j , * } \to \lambda _ { j } ^ { * }$ . $j$ , when $\lambda _ { - j } \to \infty$ , i.e., $\lambda _ { j ^ { \prime } } \infty \ \forall j ^ { \prime } \neq j$ , then the following
275
+
276
+ This can be seen by considering the rewards $R _ { \lambda } ^ { \dagger } ( s , j ^ { \prime } ) = R ( s ) - \lambda _ { j ^ { \prime } } c _ { j ^ { \prime } }$ for taking action $j ^ { \prime }$ in any state $s$ . As the charge $\lambda _ { j ^ { \prime } } \to \infty$ , $R _ { \lambda } ^ { \dagger } ( s , j ^ { \prime } ) \ - \infty$ , making it undesirable to take action $j ^ { \prime }$ in the optimal policy. Thus, the optimal policy would only consider actions $\{ 0 , j \}$ , which reduces to the restricted MDP of the decoupled index computation.
277
+
278
+ Next we analyze a potential naive choice for $\lambda _ { - j }$ when computing the indices for each $j$ , namely, $\lambda _ { - j } = 0$ . Though it may seem a natural heuristic, this corresponds to planning without considering the costs of other actions, which we show below can lead to arbitrarily low values of the indices, which subsequently can lead to poorly performing policies.
279
+
280
+ Theorem 2. As $\lambda _ { j ^ { \prime } } 0 \forall j ^ { \prime } \neq j$ , $\lambda _ { j } ^ { a d j , * }$ will monotonically decrease, $i f ( l ) \ V _ { \lambda _ { j ^ { \prime } } } ^ { \dagger } ( s , \lambda _ { j } , j ^ { \prime } ) \ \geq$ $V _ { \lambda _ { j ^ { \prime } } } ^ { \dagger } ( s , \lambda _ { j } , 0 )$ for $O \le \lambda _ { j ^ { \prime } } \le \epsilon$ and (2) if the average cost of worker $j ^ { \prime }$ under the optimal policy starting with action $j ^ { \prime }$ is greater than the average cost of worker $j ^ { \prime }$ under the optimal policy starting with action $j$ .
281
+
282
+ Thm. $2$ (proof in Appendix $\boxed { \mathbf { B } }$ confirms that, although setting $\lambda _ { j ^ { \prime } } = 0$ for all $j ^ { \prime }$ may seem like a natural option, in many cases it will artificially reduce the index value for action $j$ . This is because $\lambda _ { j ^ { \prime } } = 0$ corresponds to planning as if action $j ^ { \prime }$ comes with no charge. Naturally then, as we try to determine the non-zero charge $\lambda _ { j }$ we are willing to pay for action $j$ , i.e., the index of action $j$ , we will be less willing to pay higher charges, since there are free actions $j ^ { \prime }$ . Note that conditions (1) and (2) of the above proof are not restrictive. The first is a common epsilon-neighborhood condition, which requires that value functions do not change in arbitrarily non-smooth ways with $\lambda$ values near 0. The second requires that a policy’s accumulated costs of action $j ^ { \prime }$ are greater when starting with action $j ^ { \prime }$ , than starting from any other action— this is same as assuming that the MDPs do not have arbitrarily long mixing times. That is to say that Thm. $2$ applies to a wide range of problems that we care about.
283
+
284
+ The key question then is: what are reasonable values of charges for other actions $\lambda _ { - j }$ , when computing the index for action $j ^ { \check { \mathbf { \ell } } }$ ? We propose that a good choice is to set each $\lambda _ { j ^ { \prime } } \in \lambda _ { - j }$ to its corresponding decoupled index value for the current state, i.e., $\lambda _ { j ^ { \prime } } ^ { * } ( s )$ . The reason relies on the following key idea: we know that at charge $\lambda _ { j ^ { \prime } } ^ { * } ( s )$ , the optimal policy is indifferent between choosing that action $j ^ { \prime }$ and the passive action, at least when $j ^ { \prime }$ is the only action available. Now, assume we are computing the new adjusted index for action $j$ , when combined in planning with the aforementioned action $j ^ { \prime }$ at charge $\lambda _ { j ^ { \prime } } ^ { * } ( s )$ . Since the charge for $j ^ { \prime }$ is already set at a level that makes the planner indifferent between $j ^ { \prime }$ and being passive, if adding $j ^ { \prime }$ to the planning space with $j$ does not provide any additional benefit over the passive action, then the new adjusted index for $j$ will be the same as the decoupled index for $j$ , which only planned with $j$ and the passive action. This avoids the undesirable effect of getting artificially reduced indices due to under-charging for other actions $j ^ { \prime }$ , i.e., Thm. $2 .$ The ideas follow similarly for whether the adjusted index for $j$ should increase or decrease relative to its decoupled index value. I.e., if higher reward can be achieved when planning with $j$ and $j ^ { \prime }$ together compared to planning with either action alone, as in the specialist anti-poaching example
285
+
286
+ 244 then we will become more willing to pay a charge $\lambda _ { j }$ now to help reach states where the action $j ^ { \prime }$ will
287
+ 245 let us achieve that higher reward. On the other hand, if $j ^ { \prime }$ dominates $j$ in terms of intervention effect,
288
+ 246 then even at a reasonable charge for $j ^ { \prime }$ , we will be less willing to pay for action $j$ when both options
289
+ 247 are available, and so the adjusted index will decrease. We give our new adjusted index algorithm in
290
+ 248 Alg. 1, and provide experimental results demonstrating its effectiveness.
291
+
292
+ # 4.3 Allocation Algorithm
293
+
294
+ We provide a method called Balanced Allocation $( \operatorname { A l g } . 2 )$ to tackle the problem of allocating intervention tasks to each worker in a balanced way. At each time step, given the current states of all the arms $\{ s _ { i } ^ { t } \} _ { i \in [ N ] }$ , Alg. $2$ creates an ordered list $\sigma$ among workers based on their highest Whittle Indices $\operatorname* { m a x } _ { i } \lambda _ { i j } ( s _ { i } ^ { t } )$ . It then allocates the best possible (in terms of Whittle Indices) available arm to each worker according to the order $\sigma$ in a round-robin way (allocate one arm to a worker and move on to the next worker until the stopping criterion is met). Note that this satisfies the constraint that the same arm cannot be allocated to more than one worker. In situations where the best possible available arm leads to the budget violation $B$ , an attempt is made to allocate the next best. This process is repeated until there are no more arms left to be allocated. If no available arms could be allocated to a worker $j$ because of budget violation, then worker $j$ is removed from the future round-robin allocations and are allocated all the arms in their bundle $D _ { j }$ . Thus, the budget constraints are always satisfied. Moreover, in the simple setting, when costs and transition probabilities of all workers are equal, this heuristic obtain optimal reward and perfect fairness.
295
+
296
+ # Algorithm 2 Balanced Allocation
297
+
298
+ Input: Current states of each arm $\{ s _ { i } \} _ { i \in [ N ] }$ , index values for each arm-worker $( i , j )$ pair $\lambda _ { i j } ( s _ { i } )$ , costs $\overline { { \{ c _ { i j } \} } }$
299
+ budget $B$ , fairness threshold $\epsilon = c _ { m a x }$ .
300
+ Output: balanced allocation $\{ D _ { j } \} _ { j \in [ M ] }$ where $D _ { j } \subseteq [ N ]$ $. D _ { j } \cap D _ { j ^ { \prime } } = \emptyset \forall j , j ^ { \prime } \in [ M ] .$
301
+ 1: Initiate allocation $D _ { j } \emptyset$ for all $j \in [ M ]$
302
+ 2: Let $L \gets \{ 1 , \ldots , N \}$ be the set of all unallocated arms
303
+ 3: while true do
304
+ 4: Let $\tau _ { j }$ be the ordering over $\lambda _ { i j }$ values from highest to lowest: $\lambda [ \tau _ { j } [ 1 ] ] [ j ] \ge \dots \ge \lambda [ \tau _ { j } [ N ] ] [ j ] \ge 0$
305
+ 5: Let $\sigma$ be the ordering over workers based on their highest indices: $\lambda [ \tau _ { 1 } [ 1 ] ] [ 1 ] \ge \lambda [ \tau _ { 2 } [ 1 ] ) ] [ 2 ]$ ] and so on
306
+ 6: for $j = 1$ to $M$ do
307
+ 7: if $\tau _ { \sigma _ { j } } \cap L \neq \emptyset$ then
308
+ 8: $x ^ { ' } \mathrm { t o p } ( \tau _ { j } ) \cap L$
309
+ 9: while cxj + P h2D chj > B do
310
+ 10: ⌧j ⌧j \ {x}
311
+ 11: if ⌧j \ L = ; then
312
+ 12: break
313
+ 13: else
314
+ 14 $\begin{array} { r l r } { } & { \colon { \mathrm { t o p } } ( \tau _ { \sigma _ { j } } ) \cap L } & \\ { \vdots } & { \quad { \mathrm { i f } } \tau _ { \sigma _ { j } } \cap L \neq \emptyset { \mathrm { t h e n } } } \\ { } & { \quad \quad D _ { \sigma _ { j } } D _ { \sigma _ { j } } \cup \{ x \} ; } & { L L \setminus \{ x \} ; } & { \tau _ { \sigma _ { j } } \tau _ { \sigma _ { j } } \setminus \{ x \} } \\ { } & { \colon { \mathrm { r e t u r n } } \{ D _ { j } \} _ { j \in [ M ] } } & \end{array}$
315
+ 15
316
+ 16
317
+ 263 Theorem 3. When all workers are homogeneous (same costs and transition probabilities on arms
318
+ 264 after intervention) and satisfy indexability, then our framework outputs the optimal policy while being
319
+ 265 exactly fair to the workers.
320
+
321
+ Proof sketch. The proof consists of two components: (1) optimality, which can be proved using Corollary 1 (Whittle Indices for homogeneous workers are the same), and the fact that the same costs lead to considering all workers from the same pool of actions, and (2) perfect fairness, using the fact that, when costs are equal, Step 3 of our algorithm divides the arms among workers in a way such that the difference between the number of allocations between two workers differs by at most 1 (see complete proof in Appendix D).
322
+
323
+ # 5 Empirical Evaluation
324
+
325
+ 273 We evaluate our framework on three domains, namely constant unitary costs, ordered workers,
326
+ 274 and specialist domain, each highlighting various challenging dimensions of the MWRMAB problem
327
+ 275 (detailed in Appendix $\mathbf { C } )$ . In the first domain, the cost associated with all worker-arm pairs is the
328
+ 276 same, but transition probabilities differ; the main challenge is in finding optimal assignments, though
329
+ 277 fairness is still considered. In the second domain, there exists an ordering among the workers such
330
+ 278 that the highest (or lowest) ranked worker has the highest (or lowest) probability of transitioning any
331
+ 279 arm to “good” state; which makes balancing optimal assignments with fair assignments challenging.
332
+ 280 The final domain highlights the need to consider inter-action effects via Step 2.
333
+ 281 We run experiments by varying the number of arms for each domain. For the first and third domains
334
+ 282 that consider unit costs, we use $B = 4$ budget per worker, and for the second domain where costs are
335
+ 283 in the range [1, 10], we use budget $B = 1 8$ . We ran all the experiments on Apple M1 with $3 . 2 \mathrm { G H z }$
336
+ 284 Processor and 16 GB RAM. We evaluate the average reward per arm over a fixed time horizon of
337
+ 285 100 steps and averaged over 50 epochs with random or fixed transition probabilities that follow the
338
+ 286 characteristics of each domain.
339
+
340
+ Baselines We compare our approach, $\mathbf { C W I + B A }$ (Combined Whittle Index with Balanced Alloca8 tion), against:
341
+
342
+ • $\mathbf { P W I + B A }$ (Per arm-worker Whittle Index with Balanced Allocation) that combines Steps 1 and 3 of our approach, skipping Step 2 (adjusted index algorithm)
343
+
344
+ • $\mathbf { C W I + G A }$ (Combined arm-worker Whittle Index with Greedy Allocation) that combines Steps 1 and 2 and, instead of Step 3 (balanced allocation), the highest values of indices are used for allocating arms to workers while ensuring budget constraint per timestep
345
+
346
+ • Hawkins $\underline { { \| 2 0 0 3 \| } }$ solves a discounted version of Eq. $2$ without the fairness constraint, to compute values of $\lambda _ { j }$ , then solves a knapsack over $\lambda _ { j }$ -adjusted Q-values
347
+
348
+ • OPT computes optimal solutions by running value iteration over the combinatorially-sized exact problem $( \bar { 1 } )$ without The fairness constraint.
349
+
350
+ • OPT-fair follows OPT, but adds the fairness constraints. These optimal algorithms are exponential in the number of arms, states, and workers, and thus, could only be executed on small instances.
351
+
352
+ • Random takes random actions $j \in [ M ] \cup \{ 0 \}$ on every arm while maintaining budget feasibility for every worker at each timestep
353
+
354
+ 302 Results Figure $2$ shows that reward obtained using our framework $\mathrm { ( C W I + B A ) }$ is comparable to that
355
+ 303 of the reward maximizing baselines (Hawkins and OPT) across all the domains. We observe at most
356
+ 304 $1 8 . 9 5 \%$ reduction in reward compared to OPT, where the highest reduction occurs for ordered workers
357
+ 305 in Fig. 2(b). In terms of fairness, Figs. $2 ( \mathbf { a } )$ and (c) show that $\mathrm { C W I + B A }$ achieves fair allocation among
358
+ 306 workers at all timesteps. In Figure $\boxed { 2 } ( 6 )$ $\mathbf { C W I + B A }$ achieves fair allocation in almost all timesteps. The
359
+ 307 fraction of timesteps where fairness is attained by $\mathrm { C W I + B A }$ is significantly higher than Hawkins and
360
+ 308 OPT. In fact, $\mathrm { F i g } \bigstar \bigstar ( \mathsf { b } )$ also shows that Hawkins obtains unfair solutions at every timesteps (0 fairness)
361
+ 309 when ${ \Nu } { = } 5$ and $_ { \mathrm { B = } 1 8 }$ , and, when ${ \Nu } { = } 1 0$ and $_ { \mathrm { N = 1 5 } }$ , Hawkins is fair only 0.41 and 0.67 fractions of
362
+ 310 the time, respectively. Thus, compared to reward maximizing baselines (Hawkins and OPT),
363
+ 311 $\mathbf { C W I + B A }$ achieves the highest fairness. We also compare against two versions of our solution
364
+ 312 approach, namely, $\mathrm { P W I + B A }$ and $\mathrm { C W I + G A }$ . We observe that $\mathrm { P W I + B A }$ accumulates marginally lower
365
+ 313 reward while $\mathrm { C W I + G A }$ performs poorly in terms of fairness, hence asserting the importance of using
366
+ 314 $\mathrm { C W I + B A }$ for the MWRAMB problem.
367
+
368
+ Fig 3 shows that $\mathbf { C W I + B A }$ is significantly faster than OPT-fair (the optimal MWRMAB solution), with an execution time improvement of $3 3 \%$ , $7 8 \%$ and $8 3 \%$ for the three domains, respectively, when ${ \Nu } { = } 5$ . Moreover, for instances with ${ \Nu } { = } 1 0$ onwards, both OPT and OPT-fair ran out of memory because the execution of the optimal algorithms required exponentially larger memory. However, we observe that $\mathrm { C W I + B A }$ scales well even for $N = 1 0$ and $N = 1 5$ and runs within a few seconds, on an average.
369
+
370
+ Fig. 4 further demonstrates that our $\mathbf { C W I + B A }$ scales well and consistently outputs fair solution for higher values of $N$ and $B$ . On larger instances, with $N \in \{ 5 0 , 1 0 0 , 1 5 0 \}$ , our approach achieves up to $3 7 4 . 9 2 \%$ improvement in fairness with only $6 . 0 6 \%$ reduction in reward, when compared against the reward-maximizing solution $\widetilde { \mathbb { H } \mathrm { a w k i n s } } \mathbb { | } \widetilde { \underline { { 2 0 0 3 } } } \mathbb { | }$
371
+
372
+ 325 In summary, $\mathbf { C W I + B A }$ is fairer than reward-maximizing algorithms (Hawkins and OPT) and
373
+ 326 much faster and scalable compared to the optimal fair solution (OPT fair), while accumulating
374
+ 327 reward comparable to Hawkins and OPT across all domains. Therefore, $\mathrm { C W I + B A }$ is shown to
375
+ 328 be a fair and efficient solution for the MWRMAB problem.
376
+
377
+ ![](images/7d0e06b80e19d1832713231c50c9f65bf1660f3e6efeea441b0b45f9fc91412f.jpg)
378
+ Figure 2: Mean reward (top row) and fraction of time steps with fair allocation (bottom row) for $N = 5$ , 10, 15 arms. $\mathrm { C W I + B A }$ (blue) achieves highest fraction of fair allocations than Hawkins (white) algorithm while attaining almost similar reward as the reward-maximizing baselines.
379
+
380
+ ![](images/313b805bb2e410f7ee9707a61db08d281f3e38ce187ebdc6beacd8f79e2bc621.jpg)
381
+ Figure 3: Execution time averaged over 50 epochs for $N = 5 , 1 0 , 1 5$ . For a fixed time horizon of 100 steps, $\mathrm { C W I + B A }$ run faster than Hawkins (white), OPT (dark gray), and OPT fair (light gray) for all instances in each of the three domains evaluated.
382
+
383
+ ![](images/fd4c0fe3b3465f19f16cf148169e2e44ee0a908d2190da7dba241e7a8a41be72.jpg)
384
+ Figure 4: The plot shows mean reward (left), fairness (middle), and run time (right) for $N =$ 50, 100, 150 arms on constant unitary costs domain. $\mathrm { C W I + G A }$ scales well for larger instances, and even for $\mathrm { N } { = } 1 5 0$ arms, the average runtime is 10 seconds.
385
+
386
+ # 6 Conclusion
387
+
388
+ We are the first to introduce multi-worker restless multi-armed bandit (MWRMAB) problem with worker-centric fairness. Our approach provides a scalable solution for the computationally hard MWRMAB problem. On comparing our approach against the (non-scalable) optimal fair policy on smaller instances, we find almost similar reward and fairness.
389
+
390
+ 334 Our problem formulation provides a more general model for the intervention planning problem
391
+ 335 capturing heterogeneity of intervention resources, and thus it is useful to appropriately model real
392
+ 336 world domains such as anti-poaching patrolling and machine maintenance, where the interventions
393
+ 337 are provided by a human workforce.
394
+
395
+ 338 References
396
+ 339 Abderrahmane Abbou and Viliam Makis. Group maintenance: A restless bandits approach. INFORMS Journal on Computing, 31(4):719–731, 2019.
397
+ 341 Daniel Adelman and Adam J. Mersereau. Relaxations of weakly coupled stochastic dynamic programs. Operations Research, 56(3):712–727, 2008.
398
+ 343 N. Akbarzadeh and A. Mahajan. Restless bandits with controlled restarts: Indexability and computation of whittle index. In 2019 IEEE Conference on Decision and Control. IEEE, 2019.
399
+ 345 Arpita Biswas and Siddharth Barman. Fair division under cardinality constraints. In Proceedings of the 27th International Joint Conference on Artificial Intelligence, pages 91–97, 2018.
400
+ 347 Felix Brandt, Vincent Conitzer, Ulle Endriss, Jérôme Lang, and Ariel D Procaccia. Handbook of computational social choice, Chapter 12. Cambridge University Press, 2016. Eric Budish. The combinatorial assignment problem: Approximate competitive equilibrium from equal incomes. Journal of Political Economy, 119(6):1061–1103, 2011. Yifang Chen, Alex Cuellar, Haipeng Luo, Jignesh Modi, Heramb Nemlekar, and Stefanos Nikolaidis. Fair contextual multi-armed bandits: Theory and experiments. In Conference on Uncertainty in Artificial Intelligence, pages 181–190. PMLR, 2020. Kevin D. Glazebrook, David J. Hodge, and Christopher Kirkbride. General notions of indexability for queueing control and asset management. The Annals of Applied Probability, 21(3):876–907, 2011.
401
+ Yasin Gocgun and Archis Ghate. Lagrangian relaxation and constraint generation for allocation and advanced scheduling. Computers & Operations Research, 39(10):2323–2336, 2012.
402
+ 358 Jeffrey Thomas Hawkins. A Langrangian decomposition approach to weakly coupled dynamic optimization problems and its applications. PhD thesis, Massachusetts Institute of Technology, 2003.
403
+ 361 Christine Herlihy, Aviva Prins, Aravind Srinivasan, and John Dickerson. Planning to fairly allocate: Probabilistic fairness in the restless bandit setting. arXiv preprint arXiv:2106.07677, 2021.
404
+ 63 Matthew Joseph, Michael Kearns, Jamie H Morgenstern, and Aaron Roth. Fairness in learning: Classic and contextual bandits. Advances in Neural Information Processing Systems, 29:325–333, 2016. Aditya Mate, Jackson A Killian, Haifeng Xu, Andrew Perrault, and Milind Tambe. Collapsing bandits and their application to public health interventions. In Advances in Neural Information Processing Systems, 2020.
405
+ 369 Rahul Meshram and Kesav Kaza. Simulation based algorithms for markov decision processes and multi-action restless bandits. arXiv preprint arXiv:2007.12933, 2020. Rahul Meshram, D Manjunath, and Aditya Gopalan. A restless bandit with no observable states for recommendation systems and communication link scheduling. In 2015 54th IEEE Conference on Decision and Control (CDC), pages 7820–7825. IEEE, 2015. Christos H Papadimitriou and John N Tsitsiklis. The complexity of optimal queueing network control. In Proceedings of IEEE 9th Annual Conference on Structure in Complexity Theory, pages 318–322. IEEE, 1994. Vishakha Patil, Ganesh Ghalme, Vineet Nair, and Y Narahari. Achieving fairness in the stochastic multi-armed bandit problem. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 34, pages 5379–5386, 2020.
406
+ 380 Y. Qian, C. Zhang, B. Krishnamachari, and B. Tambe. Restless poachers: Handling explorationexploitation tradeoffs in security domains. In International Joint Conference on Autonomous Agents and Multi-Agent Systems, AAMAS. IFAAMAS, 2016.
407
+ Yundi Qian, Chao Zhang, Bhaskar Krishnamachari, and Milind Tambe. Restless poachers: Handling exploration-exploitation tradeoffs in security domains. In Proceedings of the 2016 International Conference on Autonomous Agents & Multiagent Systems, pages 123–131, 2016.
408
+ Richard R Weber and Gideon Weiss. On an index policy for restless bandits. J. Appl. Probab., 27(3):637–648, 1990.
409
+ Peter Whittle. Restless bandits: Activity allocation in a changing world. Journal of applied probability, pages 287–298, 1988.
410
+ Xiaowei Wu, Bo Li, and Jiarui Gan. Budget-feasible maximum nash social welfare is almost envyfree. In The 30th International Joint Conference on Artificial Intelligence (IJCAI 2021), pages 1–16, 2021.
411
+
412
+ # Checklist
413
+
414
+ 1. For all authors...
415
+
416
+ (a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes]
417
+ (b) Did you describe the limitations of your work? [Yes] (see Appendix E)
418
+ (c) Did you discuss any potential negative societal impacts of your work? [Yes] (see Appendix E)
419
+ (d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
420
+
421
+ 2. If you are including theoretical results...
422
+
423
+ (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]
424
+
425
+ 3. If you ran experiments...
426
+
427
+ (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]
428
+ (b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes]
429
+ (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [Yes]
430
+ (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]
431
+
432
+ 4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
433
+
434
+ (a) If your work uses existing assets, did you cite the creators? [Yes]
435
+ (b) Did you mention the license of the assets? [N/A]
436
+ (c) Did you include any new assets either in the supplemental material or as a URL? [Yes]
437
+ (d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [N/A]
438
+ (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [N/A]
439
+
440
+ 5. If you used crowdsourcing or conducted research with human subjects...
441
+
442
+ (a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A]
443
+ (b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A]
444
+ (c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]
md/dev/uloenYmLCAo/uloenYmLCAo.md ADDED
@@ -0,0 +1,305 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Block-Recurrent Transformers
2
+
3
+ DeLesley Hutchins∗1, Imanol Schlag∗3†, Yuhuai $\mathbf { W } \mathbf { u } ^ { 1 }$ , Ethan Dyer2, Behnam Neyshabur2
4
+
5
+ 1 Google Research 2 Google Research, Blueshift Team 3 The Swiss AI Lab IDSIA, SUPSI & USI {delesley, yuhuai, edyer, neyshabur}@google.com imanol@idsia.ch
6
+
7
+ # Abstract
8
+
9
+ We introduce the Block-Recurrent Transformer, which applies a transformer layer in a recurrent fashion along a sequence, and has linear complexity with respect to sequence length. Our recurrent cell operates on blocks of tokens rather than single tokens during training, and leverages parallel computation within a block in order to make efficient use of accelerator hardware. The cell itself is strikingly simple. It is merely a transformer layer: it uses self-attention and cross-attention to efficiently compute a recurrent function over a large set of state vectors and tokens. Our design was inspired in part by LSTM cells, and it uses LSTM-style gates, but it scales the typical LSTM cell up by several orders of magnitude. Our implementation of recurrence has the same cost in both computation time and parameter count as a conventional transformer layer, but offers dramatically improved perplexity in language modeling tasks over very long sequences. Our model out-performs a long-range Transformer XL baseline by a wide margin, while running twice as fast. We demonstrate its effectiveness on PG19 (books), arXiv papers, and GitHub source code. Our code has been released as open source [1].
10
+
11
+ # 1 Introduction
12
+
13
+ Transformers have mostly replaced recurrent neural networks (RNNs), such as LSTMs [2], on tasks that involve sequential data, especially natural language. There are several reasons for their success. First, transformers process all elements of the sequence in parallel, and are thus faster to train on modern accelerator hardware. In contrast, an RNN must process tokens sequentially, which leads to slow step times during training, and large batch sizes in order to fully saturate GPUs or TPUs.
14
+
15
+ Second, an RNN must summarize and compress the entire previous sequence into a single state vector which is passed from one token to the next. The size of the state vector limits the amount of information that the RNN can encode about the previous tokens in the sequence. In contrast, a transformer can attend directly to past tokens, and does not suffer from this limitation.
16
+
17
+ Third, attention operates effectively over longer distances. The forget gate in an LSTM discards information moving forward, and causes vanishing gradients during backpropagation. In practice, this means that LSTMs struggle to send a clear signal over more than a few hundred tokens, far less than the typical size of the attention window in a transformer [3].
18
+
19
+ Despite these advantages, transformers also have a disadvantage. The computational complexity of self-attention is quadratic with respect to the sequence length, which is a limiting factor when attempting to process long documents, such as books, technical articles, or source code repositories. Moreover, a transformer has no memory of past context; any tokens that it cannot attend to are “invisible” to the model.
20
+
21
+ ![](images/005193c9c3eacb159c19fd30d604c15a45f6c6e0a5d99832a50f1397a4f2b6d3.jpg)
22
+ Figure 1: Illustration of our recurrent cell. The left side depicts the vertical direction (layers stacked in the usual way) and the right side depicts the horizontal direction (recurrence). Notice that the horizontal direction merely rotates a conventional transformer layer by $9 0 ^ { \circ }$ , and replaces the residual connections with gates.
23
+
24
+ In this work, we describe an architecture which combines the benefits of attention and recurrence. Like previous implementations of recurrence, our architecture constructs and maintains a fixed-size state, which summarizes the sequence that the model has seen thus far. However, our implementation of recurrence differs from previous work in several important aspects which together address the three limitations mentioned above.
25
+
26
+ Instead of processing the sequence one token at a time, our recurrent cell operates on blocks of tokens; see Figure 1. Within a block, all tokens are processed in parallel, at least during training. The recurrent cell likewise operates on a block of state vectors rather than a single vector. This means that the size of the recurrent state is orders of magnitude larger than in an LSTM, which dramatically improves the model’s capacity to capture the past. Processing the sequence in blocks also helps propagate information and gradients over longer distances, because the number of recurrent steps (and thus the number of times that the forget gate is applied) is orders of magnitude smaller. We show that the Block-Recurrent Transformer can remember information over distances of $6 0 \mathrm { k }$ tokens or more.
27
+
28
+ The recurrent cell itself is strikingly simple. For the most part, it consists of an ordinary transformer layer applied in a recurrent fashion along the sequence length. There are a few tricks that are necessary to stabilize training; see Sections 3.2 and 3.4 for details. The cost of recurrence, in terms of both computation time and parameter count, is essentially the same as simply adding one more layer to our transformer baseline. We demonstrate empirically that adding a single recurrent layer results in a much larger improvement in perplexity on multiple datasets than adding a conventional transformer layer, while training time and memory use are equivalent. Moreover, our recurrent cell is very easy to implement because it largely makes use of existing transformer code. Thus, our technique is a cheap and cheerful way to improve language modeling perplexity on long sequences.
29
+
30
+ # 2 Related Work
31
+
32
+ The quadratic cost of attention is well known in the literature, and a great deal of work has been done on efficient long-range attention mechanisms; see [4, 5] for recent surveys. Sparse strategies such as Big Bird [6], Routing Transformers [7], and Reformer [8] select only a subset of tokens to attend to. Hierarchical mechanisms [9] combine multiple tokens into phrases or sentences to reduce sequence length. Expire-span [10] learns to prune far-away tokens that the model has labelled as “unimportant”. Memorizing transformers [11] replace dense attention with $k$ -nearest-neighbor lookup.
33
+
34
+ Yet another approach is to reduce the sequence length by pooling, averaging, or compressing it in some way. Hierarchical 1D attention [12], and Combiner [13] apply pooling or averaging over tokens at longer distances. Linformer [14] applies a linear transformation to the key and value matrices to reduce the sequence length. Compressive transformers [15] and funnel transformers [16] apply additional learned compression layers to compress the sequence.
35
+
36
+ ![](images/98180423d7393c279a434e7f8239927601f13a8ac193a26b22b30bd0869e938a.jpg)
37
+ keys, values to be cached
38
+ Figure 2: Sliding window, where segment length $N = 1 6$ , window/block size $W = 8$ . Keys and values for the first $W$ shaded tokens were computed and cached on the previous training step; the remaining $N$ unshaded tokens are the segment for the current training step. Instead of a single $N \times ( W + N )$ attention matrix, attention is done in two tiles of size $W \times 2 W$ .
39
+
40
+ The equation for attention is (roughly) softmax $( Q K ^ { T } ) V$ where $Q , \pmb { K }$ , and $V$ are the query, key, and value matrices of the attention layer. If the softmax operation is removed from this equation or somehow “linearized”, the equation can be rearranged as $\dot { Q ( K ^ { T } V ) }$ , where $( K ^ { T } V )$ can be computed incrementally (i.e., in a recurrent fashion) as a cumulative sum over the sequence [17]. Linearized attention thus has linear rather than quadratic complexity with respect to sequence length. Following this line of reasoning, there have been several proposals that approximate the softmax [18, 19] or replace it [20, 21]. Linear transformers are related to earlier work on fast weight programmers [20] [22], and can be extended with other forms of recurrence [23].
41
+
42
+ Our work differs from all of the above mechanisms, because we rely only on standard dense attention with softmax.
43
+
44
+ A few other lines of research have combined the transformer architecture with recurrence in some way. The feedback transformer [24] allows lower layers to attend to the output of the topmost layer. Feedback has minimal cost at inference time, but it is unfortunately very slow to train because tokens must be processed sequentially. Simple Recurrent Units [25, 26] use a recurrence function that does not involve matrix multiplication, and is consequently much faster. $\mathbf { R N M T + }$ combines RNNs and transformers in an encoder/decoder architecture to improve on translation tasks [27]. “Sandwich models” alternate between transformer and RNN layers and out-perform both transformers and RNNs on tasks involving source code [28]. The R-Transformer introduces an additional local RNN which can be computed in parallel in order to better model sequential structure [29]. The Perceiver architecture [30] is somewhat similar to ours; it also applies a transformer layer in an iterative fashion.
45
+
46
+ To the best of our knowledge, the idea of performing recurrence on blocks of tokens is underexplored. In the context of translation, [31] operates on sentences rather than tokens. Staircase Attention [32] also operates on blocks of tokens; each layer takes, as input, the outputs of the same layer from the previous block.
47
+
48
+ # 3 Method
49
+
50
+ The Block-Recurrent Transformer is based on sliding-window attention [33], which is an extension of ideas from Transformer-XL [34].
51
+
52
+ A long document, such as a book, consists of a sequence of tokens. Due to memory limitations, it is usually not possible to fit the entire sequence into device memory. Thus, the sequence is divided into segments of length $N$ $N = 4 0 9 6$ in our experiments), which are processed sequentially over a number of training steps. Each training step processes one segment.
53
+
54
+ The sliding window attention pattern is illustrated in Figure 2. Given a segment of $N$ tokens, the sliding window applies a causal mask in which each token can only attend to the $W$ previous tokens, where $W$ is the window size ( $W = 5 1 2$ in our experiments). Because of the causal mask, most entries of the $N \times N$ attention matrix are masked out (assuming that $W < < N$ ). Thus, the attention computation can be optimized by breaking it into smaller tiles along the diagonal. The segment of $N$ tokens is subdivided into blocks of size $W$ , and each block attends locally to itself and to the previous block, so the size of each local attention matrix is $W \times 2 W$ . Using this mechanism, attention is quadratic with respect to the window size $W$ , but linear with respect to the segment length $N$ .
55
+
56
+ Borrowing an idea from Transformer-XL, the keys and values from the last block in each segment are stored in a non-differentiable cache for use on the next training step. By using the cache, the first block in the next segment can attend to the last block in the previous segment, which extends the sliding window to cover the entire (book-length) sequence. The cache implements a form of truncated backpropagation through time [35] over long documents.
57
+
58
+ Note that if $N = W$ , then sliding window attention will behave exactly like Transformer-XL; it will process and cache one segment (i.e. one block) per training step. Setting $N > > W$ does not change the context length of attention, but it allows gradients to backpropagate across multiple blocks during training; we show that the improved differentiability provides a modest benefit to perplexity over Transformer-XL. See Appendix A for more details.
59
+
60
+ # 3.1 Recurrent Cell
61
+
62
+ A Block-Recurrent Transformer layer extends the sliding-window attention mechanism by adding a set of recurrent states, which are updated at the end of each block of $W$ tokens. Our design for the recurrent cell is illustrated in Figure 1, which depicts the operations done within a single block of the input sequence.
63
+
64
+ The recurrent cell receives two tensors as inputs: a set of $W$ token embeddings, where $W$ is the block/window size, and a set of $S$ “current state” vectors. The cell produces two tensors as outputs: a set of $W$ output embeddings, as well as a set of $S$ “next state” vectors. We denote the function going from input token embeddings to output token embeddings as the vertical direction, and the function going from the current state vectors to the next state vectors as the horizontal direction. The number of state vectors $S$ and the window size $W$ are independent hyperparameters, but we set $S = W = 5 1 2$ in our experiments to simplify comparisons against baselines.
65
+
66
+ The vertical direction of the cell is an ordinary transformer layer with an additional cross-attention operation, much like a decoder layer in a standard encoder-decoder architecture [36]. It does selfattention over the input tokens, and cross-attends to the recurrent states. Unlike a typical decoder layer, we do self-attention and cross-attention in parallel. The results of both forms of attention are concatenated together and fed into a linear projection.
67
+
68
+ The horizontal direction of the cell mirrors the forward direction, except that it performs selfattention over the current state vectors, and cross-attends to the input tokens. The recurrent direction also replaces the residual connections with gates, which allows the model to “forget”, an ability that is important for algorithmic tasks [37], or when processing long documents, where it has been central to the success of LSTMs [38].
69
+
70
+ Note that the presence of gates is the reason why self-attention and cross-attention are done in parallel. Doing them sequentially, as is standard practice, would introduce a third gate in the horizontal direction, which led to worse perplexity in our experiments.
71
+
72
+ Recurrence is integrated with the sliding window attention mechanism. Although not shown in Figure 1, each cell also receives keys and values from the previous block as input, these are concatenated with $( K _ { e } , V _ { e } )$ from the current block in order to implement sliding-window attention.
73
+
74
+ A Block-Recurrent Transformer layer processes the blocks within a segment sequentially by stacking recurrent cells horizontally, with the “next states” output of the previous cell feeding into the “current states” input of the next cell. In code, this is implemented as a simple for-loop over blocks. Multiple layers can also be stacked vertically in the usual fashion. Our experiments use a single recurrent layer, sandwiched between a number of non-recurrent layers that use sliding-window attention.
75
+
76
+ The final set of state vectors from the last block in the segment are cached, along with the keys and values, and used as the initial state for the first block on the next training step. Every layer in the stack (both recurrent and non-recurrent) has its own cache.
77
+
78
+ Sharing of keys and values. Keys and values are shared between the vertical and horizontal directions. One set of keys and values $( \pmb { K _ { e } } , \pmb { V _ { e } } )$ are computed from the input token embeddings, and another set of keys and values $( K _ { s } , V _ { s } )$ are computed from the recurrent state vectors. Queries are not shared, so there are four separate sets of queries: $Q _ { e } ^ { v }$ and $Q _ { s } ^ { v }$ in the vertical direction, and $\pmb { Q } _ { s } ^ { h }$ and $Q _ { e } ^ { h }$ in the horizontal direction.
79
+
80
+ # 3.2 State IDs and Position Bias
81
+
82
+ With a large number of state vectors, the total size of the recurrent state is far larger than that of an LSTM. However, the same weights (projection matrices and MLP) are applied to each state vector. Without some way to differentiate the states, the model will compute the same result for each state vector, thus negating any advantage from having multiple states. To prevent this failure mode, we add a set of learned “state IDs” to the state vectors before computing the keys, values, and queries. These “state IDs” allow each state vector to consistently issue different queries against the input sequence, and against other states. State IDs are identical to learned position embeddings; we use a different name because there’s no notion of “position” between states.
83
+
84
+ We do not add global position embeddings to the tokens, because global position embeddings don’t work well for long sequences [34]. Instead, we add a T5-style relative position bias [39] to the selfattention matrix in the vertical direction. (Although similar, T5 relative positions differ slightly from the relative positions used in the Transformer-XL paper [34].) When the recurrent states cross-attend to input tokens, there is no position bias, because the relative distance between “state” and “token” is undefined.
85
+
86
+ We also normalize queries and keys as described in [40]; we found that normalization improved the stability of Transformer-XL when used with a relative position bias.
87
+
88
+ # 3.3 Gate Type
89
+
90
+ We experimented with two different gating mechanisms for the recurrent cell. Each state vector has its own gate, but all state vectors are updated in parallel, using the equations below.
91
+
92
+ Fixed gate. The fixed gate uses a learned convex combination, similar to highway networks [41].
93
+
94
+ $$
95
+ \begin{array} { r } { z _ { t } = W _ { z } h _ { t } + b _ { z } \qquad } \\ { \pmb { g } = \sigma ( \pmb { b } _ { g } ) \qquad } \\ { \pmb { c } _ { t + 1 } = \pmb { c } _ { t } \odot \pmb { g } + \pmb { z } _ { t } \odot ( 1 - \pmb { g } ) } \end{array}
96
+ $$
97
+
98
+ where $W _ { z }$ is a trainable weight matrix, $b _ { z }$ and $b _ { g }$ are trainable bias vectors, $\sigma$ is the sigmoid function, $\mathbf { } _ { c _ { t } }$ is the cell state for the current block (i.e., the state for the block at index $t$ in the sequence of blocks), $\odot$ is the element-wise multiplication, and $h _ { t }$ is the current input to the gate. In our model, $h _ { t }$ is either the output of attention, in which case $W _ { z }$ is the linear projection that feeds into the gate, or $\boldsymbol { h } _ { t }$ is the output of the hidden layer of the MLP, in which case $W _ { z }$ is the final layer of the MLP.
99
+
100
+ Unlike highway networks, the bias $b _ { g }$ is a simple learned vector of shape $\mathbb { R } ^ { d }$ , which is broadcast over all state vectors, where $d$ is the state embedding dimension. The value of $\textbf { { g } }$ does not depend on either the current value of the state vector $c _ { t }$ , or on the current input $h _ { t }$ , and thus remains constant (i.e., fixed) after training. The fixed gate essentially implements an exponential moving average over previous blocks.
101
+
102
+ LSTM gate. The LSTM gate uses the standard combination of input and forget gates:
103
+
104
+ $$
105
+ \begin{array} { r l } & { z _ { t } = \operatorname { t a n h } ( W _ { z } h _ { t } + b _ { z } ) } \\ & { ~ i _ { t } = \sigma ( W _ { i } h _ { t } + b _ { i } - 1 ) } \\ & { ~ { f _ { t } = \sigma ( W _ { f } h _ { t } + b _ { f } + 1 ) } } \\ & { c _ { t + 1 } = c _ { t } \odot f _ { t } + z _ { t } \odot i _ { t } } \end{array}
106
+ $$
107
+
108
+ where $W _ { z } , W _ { i } , W _ { f }$ are trainable weight matrices, and $b _ { z } , b _ { i } , b _ { f }$ are trainable bias vectors. The LSTM gate is strictly more expressive, because the values of $\pmb { f } _ { t }$ and $i _ { t }$ depend on the current input $h _ { t }$ . In our model, $h _ { t }$ depends on $c _ { t }$ , so the LSTM gate also depends indirectly on $c _ { t }$ . LSTM gate values are thus different for each state vector, and for each block index $t$ .
109
+
110
+ # 3.4 Gate Initialization and Training Stability
111
+
112
+ We observed that training stability is quite sensitive to how the gates are initialized. Recurrence has a failure mode where the model learns to completely ignore the recurrent state, in which case its performance reverts to that of the non-recurrent transformer. Moreover, this situation appears to be a local optimum; once the model has reached this point, it does not recover. We stabilize training by initializing the weights and bias to small but non-zero values, and adding a constant -1 and $+ 1$ to the input and forget gates to bias them to “remember”. See Appendix B for details.
113
+
114
+ # 3.5 Gate Configuration
115
+
116
+ We experimented with three different gate configurations.
117
+
118
+ Dual. The dual gate configuration is the one shown in Figure 1, in which both of the residual connections in the cell are replaced with gates. The disadvantage of this configuration is that there are two gates, both of which can forget.
119
+
120
+ Single. The single gate configuration removes the linear projection and the gate that is attached to it. Instead, the concatenation of self-attention and cross-attention is fed directly into the MLP.
121
+
122
+ Skip. The skip configuration removes the MLP and the gate that is attached to it. This configuration is similar to the single-gate version, except that it is strictly weaker. Instead of a two layer MLP with a very large hidden layer, it uses a linear projection with no nonlinearity.
123
+
124
+ # 3.6 Placement of Recurrence and Computation Cost
125
+
126
+ Single recurrent layer. The basic version of the Block-Recurrent Transformer uses a single recurrent layer sandwiched between a number of non-recurrent transformer layers with sliding attention. We use a 12-layer model with recurrence on layer 10. All layers have a Transformer-XL-style cache.
127
+
128
+ Cost of recurrence. During training, the 12-layer Block-Recurrent Transformer has almost exactly the same computation cost, in both parameters and FLOPS, as a 13-layer Transformer-XL model without recurrence. The two are equivalent because the recurrent cell does almost the same operations as a conventional transformer layer, merely in the horizontal instead of the vertical direction.
129
+
130
+ The inference cost for autoregressive decoding is also nearly identical, for the same reason. Recurrence adds an additional attention operation per token, the cost of which is the same as self-attention in a 13th layer.
131
+
132
+ # 4 Results
133
+
134
+ We tested the Block-Recurrent Transformer on three different data sets of long documents: PG19, arXiv, and GitHub. The PG19 dataset [42] contains full-length books written prior to 1919 from project Gutenberg. The arXiv dataset [11] is a corpus of technical papers downloaded via the arXiv Bulk Data Access1, and filtered to include only articles labeled as “Mathematics” and whose LATEX source is available. The GitHub dataset [11] is a corpus of source code from different GitHub repositories with open-source licenses. All of the files in each GitHub repository are concatenated together to make one long document.
135
+
136
+ The task is auto-regressive language modeling, where the goal is to predict the next token in the sequence. We report bits-per-token numbers (i.e. $\log _ { 2 }$ perplexity; lower is better) for all models. Further training details for each dataset can be found in Appendix C.
137
+
138
+ # 4.1 Baselines
139
+
140
+ We compare the Block-Recurrent Transformer to five different baselines. The first baseline, XL:512, establishes a reference point against which various other improvements can be compared. It’s a
141
+
142
+ Table 1: Average bits-per-token ( $\mathrm { { l o g } _ { 2 } }$ perplexity) of each model. The recurrent models (named Rec:gate:config) have the same computational cost as the Slide:13L baseline, but much better perplexity. They even outperform the XL:2048 baseline, while running more than twice as fast. Measured error bars on PG19 are low, between 0.002 and 0.007, but are rounded up to 0.01 to match the precision of results in the table. Step time is for a single training step (lower is better). For PG19, we train both character-level (bytes) and token-level models.
143
+
144
+ <table><tr><td>Model</td><td>segment length</td><td>window length</td><td>step time (relative)</td><td>bytes</td><td>PG19 tokens</td><td>arXiv tokens</td><td>GitHub tokens</td></tr><tr><td>XL:512</td><td>512</td><td>512</td><td>0.88</td><td>1.01</td><td>3.62 ± 0.01</td><td>1.45</td><td>1.21</td></tr><tr><td>XL:1024</td><td>1024</td><td>1024</td><td>1.20</td><td>0.997</td><td>3.59 ± 0.01</td><td>1.37</td><td>1.08</td></tr><tr><td>XL: 2048</td><td>2048</td><td>2048</td><td>2.11</td><td>0.990</td><td>3.58 ± 0.01</td><td>1.31</td><td>1.01</td></tr><tr><td>Slide:12L</td><td>4096</td><td>512</td><td>0.93</td><td>0.989</td><td>3.60</td><td>1.43</td><td>1.19</td></tr><tr><td>Slide:13L</td><td></td><td></td><td>1.00</td><td>0.989</td><td>3.58 ± 0.01</td><td>1.42</td><td>1.17</td></tr><tr><td>Rec:lstm:dual</td><td>4096</td><td>512</td><td>1.06</td><td>0.985</td><td>3.54 ± 0.01</td><td>1.26</td><td>1.01</td></tr><tr><td>Rec:lstm:single</td><td></td><td></td><td>1.05</td><td>0.962</td><td>3.54± 0.01</td><td>1.29</td><td>1.03</td></tr><tr><td>Rec:lstm:skip</td><td></td><td></td><td>1.00</td><td>0.969</td><td>3.56 ± 0.01</td><td>1.31</td><td>1.10</td></tr><tr><td>Rec:fixed:dual</td><td></td><td></td><td>1.01</td><td>0.957</td><td>3.52 ± 0.01</td><td>1.27</td><td>0.991</td></tr><tr><td>Rec:fixed:single</td><td></td><td></td><td>1.02</td><td>0.966</td><td>3.58± 0.01</td><td>1.25</td><td>1.00</td></tr><tr><td>Rec:fixed:skip</td><td></td><td></td><td>0.99</td><td>0.952</td><td>3.53 ± 0.01</td><td>1.24</td><td>0.976</td></tr><tr><td>Feedback:lstm:single</td><td>4096</td><td>512</td><td>1.40</td><td>0.977</td><td>3.50</td><td>1.22</td><td>=</td></tr><tr><td>Feedback:fixed:skip</td><td></td><td></td><td>1.35</td><td>0.935</td><td>3.49</td><td>1.24</td><td>=</td></tr><tr><td>Memorizing Trans. 64k</td><td>512</td><td>512</td><td>1.94</td><td>0.950</td><td>3.53</td><td>1.22</td><td>1</td></tr></table>
145
+
146
+ 12-layer Transformer-XL model with a window size of 512, and 150 million parameters. It has 8 heads of size 128, embedding vectors of size 1024, an MLP with a hidden layer of size 4096, and the relu nonlinearity. It uses a Transformer-XL style cache, but no sliding window, so the segment length is the same as the window size, i.e., it is trained on segments of 512 tokens.
147
+
148
+ XL:1024 and XL:2048 are similar, but have window sizes of 1024 and 2048, respectively. As expected, increasing the window size improves perplexity, especially on the arXiv data set. However, these two models still have worse perplexity than the recurrent model, as well as being much slower.
149
+
150
+ Slide:12L is a 12-layer transformer with a window size of 512, but uses a sliding window over a segment of 4096 tokens. This model is almost identical to XL:512; the only difference is that the sliding window is differentiable over multiple blocks, while the Transformer-XL cache is not.
151
+
152
+ Slide:13L adds a 13th layer, and is directly comparable to the recurrent models in terms of both computation cost (FLOPS or step-time), number of parameters, and segment length. Notice that adding another layer with more parameters yields a much smaller improvement than adding recurrence.
153
+
154
+ Relative cost. All five baselines, and all 6 recurrent models, have roughly the same number of parameters: between 151 million (12 layer) and 164 million (13 layer or recurrent). The training speed (i.e. step time) of each model is shown in Table 1 (lower is better). Because the raw step time depends on hardware and compiler, we report numbers relative to the Slide:13L baseline.
155
+
156
+ Batch Size. We adjust the batch size so that each model processes the same number of tokens (and thus the same amount of training data) per training step. Thus, XL:512 (segment length 512) runs at a batch size of 256 (8 per replica), while Slide:12L (segment length 4096) runs at a batch size of 32 (1 per replica) on PG19.
157
+
158
+ # 4.2 Benefit of Recurrence
159
+
160
+ We compare the 5 baselines to all six gate configurations for the Block-Recurrent Transformer. The recurrent model reliably outperforms all five baselines. The best overall configuration is Rec:fixed:skip, which outperforms the others in 3 out of 4 cases, and comes within the margin of error in the remaining case. This is especially notable because it is also the fastest configuration, having a slightly lower step time and fewer parameters than Slide:13L, because it does not have the MLP. It is better than the 13-layer baseline by a wide margin, and it is even better than the Transformer-XL model with a window size of 2048, which runs over 2 times slower.
161
+
162
+ ![](images/b1ee718855245e4d6f3180c148df54dbc11d5dd55497a6b0fe16e283cf17d6ef.jpg)
163
+ Figure 3: Scaling of the 12-layer Block-Recurrent Transformer vs 13-layer Transformer-XL on PG19. FLOPs are the same between the two models at a given parameter count. At larger sizes, adding recurrence is equivalent to doubling the number of parameters. Details in Appendix F.
164
+
165
+ The other gate configurations also outperform the 13-layer baseline, but their relative ranking varies according to the dataset. Despite being theoretically more powerful, the LSTM gate tends to lag behind the fixed gate in all of our experiments.
166
+
167
+ Scaling up. Figure 3 shows the effect of adding recurrence as the transformer model is scaled up and down in size. We trained six different models on PG19, ranging in size from 40M parameters to 1.3B parameters. For the four smaller models, we compare a 12-layer Block-Recurrent Transformer against a 13-layer Transformer-XL baseline, while for the two larger models, we compare a 24-layer Block-Recurrent Transformer, with recurrence at layers 10 and 20, against a 26-layer Transformer-XL baseline. This experiment used a cosine-decay learning rate as described in [43], and a custom 32k SentencePiece vocabulary [44]. More details are in Appendix F.
168
+
169
+ Our experiments show that recurrence provides a consistent benefit across all scales. The relative improvement actually seems to increase with the number of parameters; at larger sizes recurrence provides a benefit which is greater than doubling the number of parameters.
170
+
171
+ # 4.3 Ablations
172
+
173
+ Multiple recurrent layers. Adding two recurrent layers right next to each other in the stack (layers 9 and 10) did not improve model perplexity. Adding two layers widely separated in the stack (layers 4 and 10) did provide an improvement, but the improvement was no better than simply adding another non-recurrent layer to the stack. Previous work on Memorizing Transformers [11] showed a similar effect. In our qualitative study, we saw that the model seems to use recurrence primary for long-range name lookups, much like memory. We conclude that one layer of recurrence is sufficient for the model to extract most of the benefits, although we did use two layers for our largest models.
174
+
175
+ Number of recurrent state vectors. We trained the model with differing numbers of state vectors, from 128 to 2048. Increasing the number of states makes a small but measurable improvement up to 1024, but the model does worse with 2048 (see Appendix D). We hypothesize that the model has trouble learning to use the recurrent state effectively if the state space grows too large.
176
+
177
+ Reducing window size. Reducing the size of the sliding window makes the perplexity significantly worse for Transformer-XL, because it reduces the amount of context that the transformer is able to attend to. Reducing the size of the window in a recurrent transformer has a smaller effect, because the model can use recurrence to compensate (see Appendix D).
178
+
179
+ # 4.4 Block feedback
180
+
181
+ Inspired by the feedback transformer [24], which allows all layers to attend to the topmost layer, we implemented a variation in which every layer of the transformer (not just the recurrent one) can cross-attend to the state vectors in the recurrent layer. This variation further improves perplexity, but
182
+
183
+ Table 2: Comparison with other published work on PG19. Fields marked - are unknown.
184
+
185
+ <table><tr><td>Model</td><td>Layers</td><td>perplexity word-level</td><td>parameters</td><td>vocabulary size</td></tr><tr><td>Compressive Transformer[15]</td><td>36</td><td>33.6</td><td></td><td>32k</td></tr><tr><td>Routing Transformer [7]</td><td>22</td><td>33.2</td><td>490M1</td><td>98k</td></tr><tr><td>Perceiver AR [45]</td><td>60</td><td>28.9</td><td>974.6M1</td><td>32k</td></tr><tr><td>Block-Recurrent Transformer</td><td>24</td><td>28.46</td><td>650M</td><td>32k</td></tr><tr><td>Block-Recurrent Transformer</td><td>24</td><td>26.50</td><td>1.3B</td><td>32k</td></tr></table>
186
+
187
+ at a cost; step time increased by approximately $3 5 \mathrm { - } 4 0 \%$ , and the additional queries also increase the number of parameters. Results are shown in Table 1, and further described in Appendix E.
188
+
189
+ # 4.5 Comparisons against prior published work
190
+
191
+ The PG19 test set contains 6,966,499 words [15], which are broken into 10,229,476 tokens using a SentencePiece vocabulary, trained on PG19. Our 24-layer 1.3B parameter model achieves 3.22 bits per token, and thus achieves a new state of the art word-level perplexity of 26.50 (Table 2). However, we note that raw perplexity numbers are not necessarily a meaningful way to compare architectures, because they depend on numerous other factors, such as the number of parameters, vocabulary, learning rate schedule, batch size, etc.; a more detailed discussion is in Appendix C.3.
192
+
193
+ We were able to run a fair comparison (identical vocabulary, configuration, and hyperparameters) of the Block-Recurrent Transformer against the Memorizing Transformer [11], with a memory of size $6 4 \mathrm { k }$ (Table 1). The memorizing transformer is constructed similarly to our model; it has one layer which has been augmented with a mechanism that gives it the ability to attend over much longer distances. We find that Block-Recurrence does almost as well as the Memorizing Transformer on arXiv, and does just as well on PG19, but trains almost twice as fast. However, there are many ways of implementing approximate $k$ -nearest-neighbor lookup, so relative speed will be highly implementation-dependent; our implementation runs on TPU, and does not use custom CUDA kernels.
194
+
195
+ # 4.6 Qualitative analysis
196
+
197
+ Prior work on long-context transformers [42, 11] has found that attention at long ranges is typically used to look up proper names, such as characters or places. We performed a qualitative analysis in an attempt to determine whether our model is using recurrence in the same way. We selected 5 books at random from the PG19 test set, ran both the Block-Recurrent Transformer and the 13-layer Transformer-XL on each book, and then compared the cross-entropy loss for all tokens. We sorted the results, and examined the top 4 tokens from each book with the greatest difference: the tokens for which the predictions of the recurrent model have the largest improvement over the baseline.
198
+
199
+ In 17/20 cases, the recurrent model predicted a proper name, usually with relatively high probability, that Transformer-XL was unable to predict. In 2 cases it predicted a chapter title (having previously seen the table of contents), and in the last case, it predicted a foreign-language word that was unique to that book. In 19/20 cases, the predicted word was nowhere within the attention window, so it must have been stored within the recurrent state (details in the appendix, Section G).
200
+
201
+ In a second study, we compared the recurrent model, running normally, against a variation in which the recurrent state is cleared at the end of each 4096-token segment, instead of being cached. Clearing the state degrades the model’s ability to predict dependencies at a longer range than the segment length; typical mispredictions once again included proper names and chapter titles. Interestingly, this study also showed that the recurrent model is able to remember the title and author of a book (which is part of the Gutenberg boilerplate at the beginning and end of each book) across the entire length of the book – more than 60,000 tokens. See Appendix G.1.
202
+
203
+ A further quantitative comparison of the per-token cross-entropy between Transformer-XL and the Block-Recurrent Transformer is given in Appendix H.
204
+
205
+ # 5 Discussion
206
+
207
+ Our implementation of recurrence was inspired by the way that humans seem to process long sequences. When a human reads a novel, they do not attempt to remember every single word in the book. Instead, a human reader will construct a mental model, or knowledge graph, which summarizes the story thus far, i.e., the names of the main characters, the relationships between them, and any major plot points. When a human reads a paragraph of text, they will parse the information in the paragraph, process and interpret the information using background knowledge from their mental model, and finally update their mental model with new information. Our recurrent architecture loosely mimics this process. It takes a block of text, and parses it by running it through a conventional transformer stack. Tokens in the text attend to the recurrent states (i.e. the mental model), and the states, in turn, are updated by attending to the text.
208
+
209
+ Based on our qualitative analysis, it seems that the model is, in fact, using the recurrent state to summarize some of the information about frequently occurring characters and places. However, it does not seem to be doing much complex reasoning, as evidenced by the fact that our best performing model is the fixed:skip configuration. This configuration does not use a complex LSTM-style gate, which chooses to remember or forget based on its current state and inputs; instead, it simply computes an exponential moving average, not unlike some other forms of long-range approximate attention.
210
+
211
+ Moreover, the skip configuration cuts out the large MLP from the recurrent transformer layer. In a vanilla transformer, removing the MLP from all layers would severely degrade the model [46]; those large MLPs are computing something important. In a recurrent layer, removing the MLP makes little difference; it does not seem to be computing anything useful. We conclude that training the recurrent layer to make full use of its capabilities for knowledge extraction and summarization will require further advances.
212
+
213
+ # 5.1 Ethics
214
+
215
+ The potential negative social impacts from this work are similar to any other advance in language modelling. Large language models could potentially be used to create disinformation and fake news, power malicious chatbots, or generate spam. The Block-Recurrent Transformer can potentially create longer documents than was previously feasible, thus expanding the range of applications in which these negative impacts could occur. The best way to mitigate these risks is to train models that can reason about text, and flag misinformation or malicious content.
216
+
217
+ # 6 Conclusion
218
+
219
+ We have shown that when training language models on long documents, the Block-Recurrent Transformer provides a greater benefit at lower cost than scaling up the transformer model in other ways. Adding recurrence to a single layer has roughly the same cost as adding an additional non-recurrent layer, but results in a much larger improvement to perplexity. We have also shown that recurrence provides a larger benefit than simply increasing the window size of attention, or increasing the number of parameters. Our medium-sized model has lower perplexity than a Transformer-XL model with 4 times the window size, but runs twice as fast, and our larger model outperforms a Transformer-XL model with twice the number of parameters.
220
+
221
+ Furthermore, in contrast to some other recently proposed transformer variants, the Recurrent Transformer is very easy to implement, since it consists mostly of ordinary transformer components and RNN gates. No custom CUDA kernels are required. Our code has been released as open source [1].
222
+
223
+ Evaluating block-recurrent transformers on downstream tasks is an important direction for future work. We believe that the Block-Recurrent Transformer will be most useful in situations that require long-range context; examples of potential applications include writing book reports, summarizing long news articles, code completion, or question/answering over book-length works. There are are a number of new and emerging benchmarks that test long-range performance [47, 48, 4]. Previous studies have found a strong correlation between language modeling and diverse downstream tasks [49, 50].
224
+
225
+ Despite our initial successes, we also believe that the recurrent architecture that we present here has not yet achieved its full potential, and there are opportunities for future research and further improvements in this area.
226
+
227
+ References
228
+ [1] D. Hutchins, M. Rabe, Y. Wu, I. Schlag, and C. Staats, “Meliad.” Github source code repository. https://github.com/google-research/meliad, 2022.
229
+ [2] S. Hochreiter and J. Schmidhuber, “Long short-term memory,” Neural Computation, vol. 9, no. 8, 1997.
230
+ [3] U. Khandelwal, H. He, P. Qi, and D. Jurafsky, “Sharp nearby, fuzzy far away: How neural language models use context,” in Association for Computational Linguistics, 2018.
231
+ [4] Y. Tay, M. Dehghani, S. Abnar, Y. Shen, D. Bahri, P. Pham, J. Rao, L. Yang, S. Ruder, and D. Metzler, “Long range arena : A benchmark for efficient transformers,” in International Conference on Learning Representations, 2021.
232
+ [5] Y. Tay, M. Dehghani, D. Bahri, and D. Metzler, “Efficient transformers: A survey,” arXiv preprint arXiv:2009.06732, 2020.
233
+ [6] M. Zaheer, G. Guruganesh, K. A. Dubey, J. Ainslie, C. Alberti, S. Ontañón, P. Pham, A. Ravula, Q. Wang, L. Yang, and A. Ahmed, “Big bird: Transformers for longer sequences,” in NeurIPS, 2020.
234
+ [7] A. Roy, M. Saffar, A. Vaswani, and D. Grangier, “Efficient content-based sparse attention with routing transformers,” Transactions of the Association for Computational Linguistics, vol. 9, pp. 53–68, 2021.
235
+ [8] N. Kitaev, L. Kaiser, and A. Levskaya, “Reformer: The efficient transformer,” in International Conference on Learning Representations, 2020.
236
+ [9] J. Ainslie, S. Ontañón, C. Alberti, V. Cvicek, Z. Fisher, P. Pham, A. Ravula, S. Sanghai, Q. Wang, and L. Yang, “ETC: encoding long and structured inputs in transformers,” in EMNLP, 2020.
237
+ [10] S. Sukhbaatar, D. Ju, S. Poff, S. Roller, A. Szlam, J. Weston, and A. Fan, “Not all memories are created equal: Learning to forget by expiring,” in ICML, 2021.
238
+ [11] Y. Wu, M. Rabe, D. Hutchins, and C. Szegedy, “Memorizing transformers,” in ICLR, 2022.
239
+ [12] Z. Zhu and R. Soricut, “H-transformer-1d: Fast one-dimensional hierarchical attention for sequences,” in ACL (C. Zong, F. Xia, W. Li, and R. Navigli, eds.), 2021.
240
+ [13] H. Ren, H. Dai, Z. Dai, M. Yang, J. Leskovec, D. Schuurmans, and B. Dai, “Combiner: Full attention transformer with sparse computation cost,” in Advances in Neural Information Processing Systems (A. Beygelzimer, Y. Dauphin, P. Liang, and J. W. Vaughan, eds.), 2021.
241
+ [14] S. Wang, B. Z. Li, M. Khabsa, H. Fang, and H. Ma, “Linformer: Self-attention with linear complexity,” CoRR, vol. abs/2006.04768, 2020.
242
+ [15] J. W. Rae, A. Potapenko, S. M. Jayakumar, C. Hillier, and T. P. Lillicrap, “Compressive transformers for long-range sequence modelling,” in ICLR, 2020.
243
+ [16] Z. Dai, G. Lai, Y. Yang, and Q. Le, “Funnel-transformer: Filtering out sequential redundancy for efficient language processing,” in NeurIPS, 2020.
244
+ [17] A. Katharopoulos, A. Vyas, N. Pappas, and F. Fleuret, “Transformers are RNNs: Fast autoregressive transformers with linear attention,” in ICML, 2020.
245
+ [18] K. M. Choromanski, V. Likhosherstov, D. Dohan, X. Song, A. Gane, T. Sarlós, P. Hawkins, J. Q. Davis, A. Mohiuddin, L. Kaiser, D. B. Belanger, L. J. Colwell, and A. Weller, “Rethinking attention with performers,” in ICLR, 2021.
246
+ [19] H. Peng, N. Pappas, D. Yogatama, R. Schwartz, N. A. Smith, and L. Kong, “Random feature attention,” in ICLR, 2021.
247
+ [20] I. Schlag, K. Irie, and J. Schmidhuber, “Linear Transformers are secretly fast weight programmers,” in ICML, 2021.
248
+ [21] W. Hua, Z. Dai, H. Liu, and Q. V. Le, “Transformer quality in linear time,” arXiv preprint arXiv:2202.10447, 2022.
249
+ [22] J. Schmidhuber, “Reducing the ratio between learning complexity and number of time varying variables in fully recurrent nets,” in International Conference on Artificial Neural Networks (ICANN), 1993.
250
+ [23] K. Irie, I. Schlag, R. Csordás, and J. Schmidhuber, “Going beyond linear transformers with recurrent fast weight programmers,” in confNEU, 2021.
251
+ [24] A. Fan, T. Lavril, E. Grave, A. Joulin, and S. Sukhbaatar, “Addressing some limitations of transformers with feedback memory,” arXiv preprint arXiv:2002.09402, 2020.
252
+ [25] T. Lei, Y. Zhang, S. I. Wang, H. Dai, and Y. Artzi, “Simple recurrent units for highly parallelizable recurrence,” in EMNLP, 2018.
253
+ [26] T. Lei, “When attention meets fast recurrence: Training language models with reduced compute,” in EMNLP, 2021.
254
+ [27] M. X. Chen, O. Firat, A. Bapna, M. Johnson, W. Macherey, G. F. Foster, L. Jones, M. Schuster, N. Shazeer, N. Parmar, A. Vaswani, J. Uszkoreit, L. Kaiser, Z. Chen, Y. Wu, and M. Hughes, “The best of both worlds: Combining recent advances in neural machine translation,” in ACL, 2018.
255
+ [28] V. J. Hellendoorn, P. Maniatis, R. Singh, C. Sutton, and D. Bieber, “Global relational models of source code,” in ICLR, 2020.
256
+ [29] Z. Wang, Y. Ma, Z. Liu, and J. Tang, “R-transformer: Recurrent neural network enhanced transformer,” arXiv preprint arXiv:1907.05572, 2019.
257
+ [30] A. Jaegle, F. Gimeno, A. Brock, O. Vinyals, A. Zisserman, and J. Carreira, “Perceiver: General perception with iterative attention,” in icml, 2021.
258
+ [31] A. Al Adel and M. S. Burtsev, “Memory transformer with hierarchical attention for long document processing,” in 2021 International Conference Engineering and Telecommunication (En T), 2021.
259
+ [32] D. Ju, S. Roller, S. Sukhbaatar, and J. Weston, “Staircase attention for recurrent processing of sequences,” arXiv preprint arXiv:2106.04279, 2021.
260
+ [33] I. Beltagy, M. E. Peters, and A. Cohan, “Longformer: The long-document transformer,” arXiv preprint arXiv:2004.05150, 2020.
261
+ [34] Z. Dai, Z. Yang, Y. Yang, J. G. Carbonell, Q. V. Le, and R. Salakhutdinov, “Transformer-XL: Attentive language models beyond a fixed-length context,” in ACL, 2019.
262
+ [35] R. J. Williams and J. Peng, “An efficient gradient-based algorithm for on-line training of recurrent network trajectories,” Neural Computation, 1990.
263
+ [36] A. Vaswani, N. Shazeer, N. Parmar, J. Uszkoreit, L. Jones, A. N. Gomez, Ł. Kaiser, and I. Polosukhin, “Attention is all you need,” in Advances in neural information processing systems, 2017.
264
+ [37] R. Csordás, K. Irie, and J. Schmidhuber, “The neural data router: Adaptive control flow in transformers improves systematic generalization,” in International Conference on Learning Representations, 2022.
265
+ [38] K. Greff, R. K. Srivastava, J. Koutník, B. R. Steunebrink, and J. Schmidhuber, “LSTM: A search space odyssey,” IEEE transactions on neural networks and learning systems, vol. 28, no. 10, 2016.
266
+ [39] C. Raffel, N. Shazeer, A. Roberts, K. Lee, S. Narang, M. Matena, Y. Zhou, W. Li, and P. J. Liu, “Exploring the limits of transfer learning with a unified text-to-text transformer,” Journal of Machine Learning Research, 2020.
267
+ [40] A. Henry, P. R. Dachapally, S. S. Pawar, and Y. Chen, “Query-key normalization for transformers,” in EMNLP, 2020.
268
+ [41] R. K. Srivastava, K. Greff, and J. Schmidhuber, “Training very deep networks,” in NIPS (C. Cortes, N. D. Lawrence, D. D. Lee, M. Sugiyama, and R. Garnett, eds.), 2015.
269
+ [42] S. Sun, K. Krishna, A. Mattarella-Micke, and M. Iyyer, “Do long-range language models actually use long-range context?,” in Proceedings of the 2021 Conference on Empirical Methods in Natural Language Processing, pp. 807–822, Association for Computational Linguistics, Nov. 2021.
270
+ [43] J. Hoffmann, S. Borgeaud, A. Mensch, E. Buchatskaya, T. Cai, E. Rutherford, D. d. L. Casas, L. A. Hendricks, J. Welbl, A. Clark, et al., “Training compute-optimal large language models,” arXiv preprint arXiv:2203.15556, 2022.
271
+ [44] T. Kudo and J. Richardson, “Sentencepiece: A simple and language independent subword tokenizer and detokenizer for neural text processing,” in EMNLP, 2018.
272
+ [45] C. Hawthorne, A. Jaegle, C. Cangea, S. Borgeaud, C. Nash, M. Malinowski, S. Dieleman, O. Vinyals, M. Botvinick, I. Simon, et al., “General-purpose, long-context autoregressive modeling with perceiver ar,” arXiv preprint arXiv:2202.07765, 2022.
273
+ [46] Y. Dong, J. Cordonnier, and A. Loukas, “Attention is not all you need: pure attention loses rank doubly exponentially with depth,” in ICML (M. Meila and T. Zhang, eds.), 2021.
274
+ [47] U. Shaham, E. Segal, M. Ivgi, A. Efrat, O. Yoran, A. Haviv, A. Gupta, W. Xiong, M. Geva, J. Berant, and O. Levy, “Scrolls: Standardized comparison over long language sequences,” 2022.
275
+ [48] A. Wang, R. Y. Pang, A. Chen, J. Phang, and S. R. Bowman, “Squality: Building a longdocument summarization dataset the hard way,” arXiv preprint arXiv:2205.11465, 2022.
276
+ [49] 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. 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,” in NeurIPS, 2020.
277
+ [50] A. Srivastava, A. Rastogi, A. Rao, A. A. M. Shoeb, A. Abid, A. Fisch, A. R. Brown, A. Santoro, A. Gupta, A. Garriga-Alonso, et al., “Beyond the imitation game: Quantifying and extrapolating the capabilities of language models,” arXiv preprint arXiv:2206.04615, 2022.
278
+ [51] N. Shazeer and M. Stern, “Adafactor: Adaptive learning rates with sublinear memory cost,” in ICML, 2018.
279
+ [52] R. Thoppilan, D. De Freitas, J. Hall, N. Shazeer, A. Kulshreshtha, H.-T. Cheng, A. Jin, T. Bos, L. Baker, Y. Du, et al., “Lamda: Language models for dialog applications,” arXiv preprint arXiv:2201.08239, 2022.
280
+ [53] O. Press, N. Smith, and M. Lewis, “Train short, test long: Attention with linear biases enables input length extrapolation,” in International Conference on Learning Representations, 2022.
281
+ [54] D. Adiwardana, M.-T. Luong, D. R. So, J. Hall, N. Fiedel, R. Thoppilan, Z. Yang, A. Kulshreshtha, G. Nemade, Y. Lu, et al., “Towards a human-like open-domain chatbot,” arXiv preprint arXiv:2001.09977, 2020.
282
+
283
+ # 7 Checklist
284
+
285
+ 1. For all authors...
286
+
287
+ (a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes]
288
+ (b) Did you describe the limitations of your work? [Yes]
289
+ (c) Did you discuss any potential negative societal impacts of your work? [Yes] See Section 5.1.
290
+ (d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
291
+
292
+ 2. If you ran experiments...
293
+
294
+ (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 plan to open-source the code itself, although we have not yet done so. We have given a detailed description of architecture, hyper-parameters, and training methodology. Our main results are for PG19, which is a publicly available dataset.
295
+ (b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes] See Appendix C.
296
+ (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [Yes] Given the large number of experiments, we did not have the computational resources to run every experiment multiple times, but we do run experiments over multiple datasets. For the main headline numbers on PG19-tokens, we ran the primary experiments three times each with different initial seeds and with dataset shuffling. Error bars are given in Table 1. Note that actual measured error bars are somewhat lower than reported in Table 1; we round results to the nearest 0.01, and thus round the error $u p$ to match the precision of the reported results. See Appendix C for details.
297
+ (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.
298
+
299
+ 3. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
300
+
301
+ (a) If your work uses existing assets, did you cite the creators? [Yes]
302
+ (b) Did you mention the license of the assets? [Yes] See Appendix C.1.
303
+ (c) Did you include any new assets either in the supplemental material or as a URL? [N/A]
304
+ (d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [Yes] See Appendix C.1.
305
+ (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [Yes] See Appendix C.1.
md/dev/xDaoT2zlJ0r/xDaoT2zlJ0r.md ADDED
@@ -0,0 +1,506 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # FINDE: Neural Differential Equations for Finding and Preserving Invariant Quantities
2
+
3
+ Anonymous Author(s)
4
+ Affiliation
5
+ Address
6
+ email
7
+
8
+ # Abstract
9
+
10
+ 1 Neural networks have shown promise for modeling dynamical systems from data.
11
+ 2 Recent models, such as Hamiltonian neural networks, have been designed to
12
+ 3 ensure known geometric structures of target systems and have shown excellent
13
+ 4 modeling accuracy. However, in most situations where neural networks learn
14
+ 5 unknown systems, their underlying structures are also unknown. Even in such
15
+ 6 cases, one can expect that target systems are associated with first integrals (a.k.a. in
16
+ 7 variant quantities), which are quantities remaining unchanged over time. First
17
+ 8 integrals come from the conservation laws of system energy, momentum, and mass,
18
+ 9 from constraints on states, and from other features of governing equations. By
19
+ 10 leveraging projection methods and discrete gradient methods, we propose first
20
+ 11 integral-preserving neural differential equations (FINDE). The proposed FINDE
21
+ 12 finds and preserves first integrals from data, even in the absence of prior knowl
22
+ 13 edge about the underlying structures. Experimental results demonstrate that the
23
+ 14 proposed FINDE is able to predict future states of given systems much longer and
24
+ 15 find various quantities consistent with well-known first integrals of the systems in
25
+ 16 a unified manner.
26
+
27
+ # 17 1 Introduction
28
+
29
+ 18 Although neural networks have achieved remarkable results in image and natural language pro
30
+ 19 cessing [17, 28], they have also been actively investigated for modeling dynamical systems [41].
31
+ 20 Target systems include the chemical dynamics to accelerate computer simulations [46], the climate
32
+ 21 dynamics for climate change prediction and weather forecasting [47, 52], and the physical dynamics
33
+ 22 of vehicles and robots for optimal control [41]. Their history dates back to at least the 1990s, and
34
+ 23 many approaches have been proposed so far (see [7, 12, 35, 40, 49, 55] for example). Recently,
35
+ 24 neural ordinary differential equation (NODE) has redefined neural networks for continuous-time
36
+ 25 dynamics [8]. A target system is described by an ordinary differential equation (ODE) $\begin{array} { r } { \frac { \mathrm { d } } { \mathrm { d } t } \pmb { u } = \pmb { f } ( t , \pmb { u } ) } \end{array}$
37
+ 26 where $\textbf { \em u }$ denotes the system state. Then, a NODE replaces the vector field $f$ with a neural network
38
+ 27 and employs a numerical integrator to obtain a solution ${ \mathbf { } } { \mathbf { } } { \mathbf { } } { \mathbf { } } { \mathbf { } } { \mathbf { } } { \mathbf { } } { \mathbf { } } { \mathbf { } } { \mathbf { } } { \mathbf { } } \mathbf { } { \mathbf { } } \mathbf { } { \mathbf { } } \mathbf { } { \mathbf { } } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf \Psi \mathbf { } \Psi \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf \Psi { } \mathbf \Psi \mathbf { } \mathbf { } \mathbf \Psi \Psi \mathbf { } \mathbf { } \mathbf \Psi \mathbf { } \mathbf \Psi \mathbf { } \mathbf \Psi \Psi \mathbf { } \mathbf \mathbf { } \mathbf \Psi \mathbf { } \mathbf \mathbf { } \mathbf \mathbf \Psi \Psi \mathbf { } \mathbf \mathbf \Psi \Psi \mathbf { } \mathbf \mathbf \Psi \mathbf { } \mathbf \mathbf \Psi \mathbf \Psi \Psi \mathbf \Psi \mathbf { \mathbf } \mathbf \mathbf \Psi \mathbf \Psi \mathbf \Psi \mathbf \mathbf \mathbf \Psi \mathbf \Psi \mathbf \Psi \mathbf \mathbf \Psi \mathbf \Psi \mathbf \mathbf \Psi \mathbf \Psi \mathbf \mathbf \Psi \mathbf \mathbf \Psi \mathbf \mathbf \mathbf \Psi \mathbf \mathbf \mathbf \Psi \mathbf \mathbf \mathbf \Psi \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \Psi \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \Psi \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf $ .
39
+ 28 Most real-world systems are associated with first integrals (a.k.a. invariant quantities), which are
40
+ 29 quantities remaining unchanged over time [27]. If a system has a first integral $V ( { \pmb u } )$ , the solution
41
+ 30 ${ \mathbf { } } { \mathbf { } } { \mathbf { } } { \mathbf { } } { \mathbf { } } { \mathbf { } } { \mathbf { } } { \mathbf { } } { \mathbf { } } { \mathbf { } } { \mathbf { } } \mathbf { } { \mathbf { } } \mathbf { } { \mathbf { } } \mathbf { } { \mathbf { } } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf \Psi { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf \Psi { } \mathbf \Psi { } \mathbf { } \mathbf \Psi \mathbf { } \mathbf { } \mathbf { } \mathbf \Psi \mathbf { } \mathbf { } \mathbf \Psi \mathbf { } \mathbf { } \mathbf \Psi \mathbf { } \mathbf \Psi \mathbf { } \mathbf \Psi \mathbf { } \mathbf \Psi \mathbf { } \mathbf \mathbf { } \mathbf \mathbf { \Psi } \mathbf \mathbf \Psi \mathbf { } \mathbf \mathbf \Psi \Psi \mathbf { } \mathbf \mathbf \mathbf { \Psi \mathbf } \mathbf \mathbf \Psi \Psi \mathbf \Psi \mathbf { \mathbf } \mathbf \mathbf \mathbf \Psi \mathbf \mathbf \Psi \mathbf \mathbf \Psi \mathbf \Psi \mathbf \Psi \mathbf \Psi \mathbf \Psi \mathbf \mathbf \Psi \mathbf \mathbf \Psi \mathbf \mathbf \Psi \mathbf \mathbf \Psi \mathbf \mathbf \mathbf \Psi \mathbf \mathbf \mathbf \Psi \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \Psi \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \Psi \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf $ for the initial condition $\pmb { u } ( 0 )$ remains at a contour line $V ( \mathbf { \boldsymbol { u } } ( t ) ) = V ( \mathbf { \boldsymbol { u } } ( 0 ) )$ over time. Many
42
+ 31 previous studies have attempted to learn a target system accurately by incorporating prior knowledge
43
+ 32 about first integrals. Greydanus et al. [26] proposed Hamiltonian neural network (HNN), which
44
+ 33 employs a neural network to approximate Hamilton’s equation, thereby conserving the system energy
45
+ 34 called the Hamiltonian. Finzi et al. [19] proposed neural network architectures that conserve linear
46
+ 35 and angular momenta by utilizing the graph structure. Finzi et al. [20] also extended HNN to a system
47
+ 36 with holonomic constraints, which lead to first integrals such as a pendulum length. Matsubara et al.
48
+ 37 [38] proposed a model that preserves the total mass of a discretized partial differential equation
49
+ 38 (PDE). These studies have demonstrated that a neural network with more prior knowledge about first
50
+ 39 integrals predicts the dynamics of the target system more accurately. See Table 1 for comparison.
51
+ 40 Previous studies have mainly attempted to preserve known first integrals. However, in situations
52
+ 41 where a neural network learns an unknown target system, it is naturally expected that first integrals
53
+ 42 associated with the target system are also unknown, and it is not clear which of the above methods are
54
+ 43 available. Given the above, this study proposes First Integral-preserving Neural Differential Equation
55
+ 44 (FINDE) to find and preserve first integrals from data. FINDE has the following advantages.
56
+ 45 Learning First Integrals For modeling continuous-time dynamics with known first integrals, many
57
+ 46 studies have designed architectures or operations of neural networks [13, 19, 20, 26, 38]. For each
58
+ 47 type of first integral, one dedicated method was proposed. However, the properties of a target system
59
+ 48 are generally unknown in practice. In contrast, the proposed FINDE finds various kinds of first
60
+ 49 integrals from data in a unified manner and preserves them in predictions. A symbolic regression
61
+ 50 confirms that the learned first integrals are consistent with well-known first integrals of target systems.
62
+
63
+ Table 1: Comparison between Related Studies on Preservation of First Integrals.
64
+
65
+ <table><tr><td colspan="7"></td></tr><tr><td></td><td>energy</td><td colspan="3">monentum mass</td><td colspan="3">constraint learning invariants exact conservation</td></tr><tr><td>NODE [8]</td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>HNN [26]</td><td>√</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>LieConv [19]</td><td>√</td><td>厂</td><td></td><td></td><td></td><td></td></tr><tr><td>DGNet [38]</td><td>√</td><td></td><td>√</td><td></td><td></td><td></td></tr><tr><td>CHNN [20]</td><td>√</td><td></td><td></td><td>√</td><td></td><td></td></tr><tr><td>continuous FINDE (proposed)</td><td>√</td><td>√</td><td>√</td><td>√</td><td>√</td><td></td></tr><tr><td>discrete FINDE (proposed)</td><td>√</td><td>厂</td><td>厂</td><td>丁</td><td></td><td></td></tr></table>
66
+
67
+ Combination with Known First Integrals The proposed FINDE can be combined with previously proposed neural networks designed to preserve known first integrals, such as HNN. Therefore, FINDE is available in various situations.
68
+
69
+ 54 Exact Preservation of First Integrals Even if a first integral is associated with a continuous-time
70
+ 55 system, it is destroyed after the system is discretized in time for computer simulations. This is true
71
+ 56 even when using a symplectic integrator, which preserves the system energy only approximately [27].
72
+ 57 By leveraging discrete gradients [38], the discrete-time version of FINDE preserves first integrals
73
+ 58 exactly (up to rounding errors) in discrete time and further improves the prediction performance.
74
+
75
+ # 59 2 Background and Related Work
76
+
77
+ 60 First Integrals Let us consider a time-invariant differential system $\begin{array} { r } { \frac { \mathrm { d } } { \mathrm { d } t } \pmb { u } \ = \ f ( \pmb { u } ) } \end{array}$ on an $N$ -
78
+ 61 dimensional manifold $\mathcal { M }$ , where $\textbf { \em u }$ denotes the system state and $f : \mathcal { M } ^ { } \to \mathcal { T } _ { u } \mathcal { M }$ represents a
79
+ 62 vector field on the manifold $\mathcal { M }$ . The manifold $\mathcal { M }$ can be $\mathcal { M } = S ^ { 1 } \times \mathbb { R } ^ { 1 }$ for a pendulum. In this
80
+ 63 paper, we suppose the manifold $\mathcal { M }$ be a Eucleadian space $\mathbb { R } ^ { N }$ for simplicity.
81
+ 64 Definition 1 (first integral). $A$ quantity $V : { \mathcal { M } } \mathbb { R }$ is referred to as a first integral of a system
82
+ 65 $\begin{array} { r } { \frac { \mathrm { d } } { \mathrm { d } t } \pmb { u } = f ( \pmb { u } ) } \end{array}$ if it remains constant along with any solution ${ \mathbf { } } { \mathbf { } } { \mathbf { } } { \mathbf { } } { \mathbf { } } { \mathbf { } } { \mathbf { } } { \mathbf { } } { \mathbf { } } { \mathbf { } } \mathbf { } { \mathbf { } } \mathbf { } { \mathbf { } } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf \Psi \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf \mathbf { } \mathbf { } \mathbf { } \mathbf \Psi { } \mathbf \mathbf { } \mathbf { } \mathbf \Psi \mathbf { } \mathbf { } \mathbf \mathbf { } \mathbf \Psi { } \mathbf \mathbf { } \mathbf \mathbf { } \mathbf \mathbf { } \mathbf \Psi \mathbf { } \mathbf \mathbf { } \mathbf \mathbf { } \mathbf \mathbf { } \mathbf \mathbf \Psi \mathbf { } \mathbf \mathbf { } \mathbf \mathbf \mathbf { } \mathbf \mathbf \mathbf { } \mathbf \mathbf \mathbf { \mathbf } \mathbf \mathbf \mathbf \mathbf \Psi \mathbf \Psi \mathbf { } \mathbf \mathbf \mathbf \mathbf \mathbf { } \mathbf \mathbf \mathbf \mathbf \mathbf \Psi \mathbf \mathbf { } \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \Psi \mathbf \mathbf \mathbf \mathbf \mathbf \Psi \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf$ , i.e., $\begin{array} { r } { \frac { \mathrm { d } } { \mathrm { d } t } V ( \pmb { u } ) = 0 } \end{array}$ .
83
+
84
+ ntial system $\begin{array} { r } { \frac { \mathrm { d } } { \mathrm { d } t } { \pmb u } = f ( { \pmb u } ) } \end{array}$ is associate ith $K$ functionally independent first integrals $V _ { 1 } , \dots , V _ { K }$ ${ \bf \ddot { u } } ( t )$ given an initial value $\mathbf { \delta } \mathbf { u } _ { 0 }$ stays at the
85
+
86
+ $$
87
+ \mathcal { M } ^ { \prime } = \{ \pmb { u } \in \mathcal { M } : V _ { 1 } ( \pmb { u } ) = V _ { 1 } ( \pmb { u } _ { 0 } ) , \allowbreak \dots , V _ { K } ( \pmb { u } ) = V _ { K } ( \pmb { u } _ { 0 } ) \} .
88
+ $$
89
+
90
+ 69 The tangent space $\mathcal { T } _ { u } \mathcal { M } ^ { \prime } \subset \mathcal { T } _ { u } \mathcal { M }$ of the submanifold $\mathcal { M } ^ { \prime } \subset \mathcal { M }$ at a point $\textbf { \em u }$ is the orthogonal
91
+ 70 complement to the space spanned by the gradients $\nabla V _ { k } ( { \boldsymbol { \mathbf { \mathit { u } } } } )$ of the first integrals $V _ { k }$ for $k = 1 , \ldots , K$ ,
92
+ 71 that is,
93
+
94
+ $$
95
+ \mathcal { T } _ { \boldsymbol { u } } \mathcal { M } ^ { \prime } = \{ \pmb { w } \in \mathcal { T } _ { \boldsymbol { u } } \mathcal { M } : \nabla V _ { k } ( \boldsymbol { u } ) ^ { \top } \pmb { w } = 0 \mathrm { ~ f o r ~ } k = 1 , \dots , K \}
96
+ $$
97
+
98
+ If a quantity 72 $V _ { k }$ is a first integral of the system $\begin{array} { r } { \frac { \mathrm { d } } { \mathrm { d } t } \pmb { u } = f ( \pmb { u } ) } \end{array}$ , the time-derivative $f$ at point $\textbf { \em u }$ is on the 73 tangent space $\mathcal { T } _ { u } \mathcal { M } ^ { \prime }$ , being orthogonal to the gradient $\nabla V _ { k }$ of the first integral $V _ { k }$ . Then, it holds that 74 $\begin{array} { r } { \frac { \mathrm { d } } { \mathrm { d } t } \dot { V _ { k } ( \pmb { u } ) } = \nabla V _ { k } ( \pmb { u } ) ^ { \top } \frac { \mathrm { d } } { \mathrm { d } t } \pmb { u } = \bar { \nabla } V _ { k } ( \pmb { u } ) ^ { \top } \pmb { f } ( \bar { \pmb { u } } ) = 0 } \end{array}$ .
99
+
100
+ 75 One of the most well-known first integrals is the Hamiltonian $H$ , which represents the system energy
101
+ 76 of a Hamiltonian system. Noether’s theorem states that a continuous symmetry of a system leads to a
102
+ 77 conservation law (and hence a first integral) [27]; a Hamiltonian system is symmetric to translation
103
+ 78 in time and conserves the Hamiltonian. Symmetries to translation and rotation in space lead to the
104
+ 79 conservation of linear and angular momenta. Not all first integrals are related to symmetries. A
105
+ 80 pendulum can be expressed in Cartesian coordinates, and then the rod length constrains the mass
106
+ 81 position. This kind of constraint is called a holonomic constraint and leads to a first integral. A model
107
+ 82 for disease spreading called an susceptible-infected-recovered (SIR) model and the dynamics of
108
+ 83 chemical reactions have the total mass (population) as a first integral. Also for a system described by
109
+ 84 a PDE, the total mass is sometimes a first integral [23]. See Appendix A for theoretical classification
110
+ 85 of dynamics.
111
+ 86 First Integrals in Numerical Analysis For computer simulations, a differential system is dis
112
+ 87 cretized in time and solved by numerical integration. Then, the geometric structures of the system
113
+ 88 are often destroyed, and most first integrals are no longer preserved. A common remedy is a sym
114
+ 89 plectic integrator, which preserves the symplectic structure and integrates a Hamiltonian system
115
+ 90 accurately [27]. However, Ge–Marsden theorem states that a symplectic integrator conserves the
116
+ 91 Hamiltonian only approximately [56]. Hence, many numerical schemes have also been investigated
117
+ 92 for preserving first integrals exactly, while they cannot preserve the symplectic structure.
118
+ 93 Let a superscript $s$ denote the state $\pmb { u } ^ { s }$ or time $t ^ { s }$ at $s$ -th time step, and $\Delta t ^ { s } = t ^ { s + 1 } - t ^ { s }$ denote a
119
+ 94 time step size. A projection method predicts a next state $\tilde { \pmb u } ^ { s + 1 }$ from the current state $\pmb { u } ^ { s }$ using a
120
+ 95 numerical integrator and projects it onto the submanifold $\mathcal { M } ^ { \prime }$ , obtaining the projected state $\pmb { u } ^ { s + 1 }$ that
121
+ 96 preserves the first integrals $V _ { k }$ [24] (see also [27, Section IV.4]). In particular, the projected state
122
+ 97 $\mathbf { \Delta } _ { \mathbf { u } } { } ^ { s + 1 }$ is obtained by solving the optimization problem
123
+
124
+ $$
125
+ \boldsymbol { u } ^ { s + 1 } = \operatorname * { a r g m i n } _ { \boldsymbol { u } ^ { \prime } ^ { s + 1 } } | | \boldsymbol { u } ^ { \prime * s + 1 } - \tilde { \boldsymbol { u } } ^ { s + 1 } | | \operatorname * { s u b j e c t } \operatorname { t o } V _ { k } ( \boldsymbol { u } ^ { \prime * s + 1 } ) = V _ { k } ( \boldsymbol { u } ^ { s } ) \operatorname { f o r } k = 1 , \dots , K .
126
+ $$
127
+
128
+ 98 A local coordinate method defines a coordinate system to the neighborhood of the current state $\pmb { u } ^ { s }$
129
+ 99 and integrates a differential equation on it [43] (see also [27, Section IV.5]). A discrete gradient
130
+ 100 method defines a discrete analogue to a given differential system and integrates it in discrete time [6,
131
+ 101 23, 25, 29, 44, 45]. This method eliminates numerical errors caused by temporal discretization and is
132
+ 102 used to preserve the Hamiltonian exactly (up to rounding errors) in discrete time.
133
+ 103 Except for DGNet, which used discrete gradients to preserve the Hamiltonian [38], all the above
134
+ 104 methods have never been applied to neural networks due to difficulties that we will introduce later. To
135
+ 105 our best knowledge, the discrete-time version of FINDE is the first projection method for dynamical
136
+ 106 systems modeled using neural networks.
137
+ 107 Preservation of First Integrals by Neural Networks NODE defines an ODE using a neural net
138
+ 108 work in the most general way with no associated first integrals [8]. NODE is a universal approximator
139
+ 109 to ODEs [51], and it can approximate any ODE with arbitrary accuracy if there is an infinite amount
140
+ 110 of training data. In practice, the amount of training data is limited, and prior knowledge about the
141
+ 111 target system is helpful for learning (see [48] for the case with convolutional neural networks). HNN
142
+ 112 assumes the target system to be a Hamiltonian system in the canonical form [26]. HNN guarantees
143
+ 113 various properties of Hamiltonian systems by definition, including the conservation of the energy
144
+ 114 and the preservation of the symplectic structure in continuous time [27]. Some studies employed a
145
+ 115 symplectic integrator for HNN to preserve the energy and symplectic structure with smaller numerical
146
+ 116 errors [10]. LieConv and EMLP-HNN employed neural network architectures with translational
147
+ 117 and rotational symmetries to preserve momenta [19, 21]. CHNN incorporates a known holonomic
148
+ 118 constraint in the dynamics [20]. Deep conservation extracts latent dynamics of a PDE system and
149
+ 119 preserves a quantity of interest by forcing its flux to be zero [34]. $\mathrm { H N N + + }$ also guarantees the
150
+ 120 conservation of the mass in PDE systems by using a coefficient matrix derived from differential
151
+ 121 operators [38].
152
+ 122 Several studies proposed neural networks to learn Lyapunov functions, which are expected to be
153
+ 123 non-increasing over time, in contrast to first integrals [37, 50]. If the state moves in the direction of
154
+ 124 increasing the function, it is projected onto or moved inside the counter line of the gradient of the
155
+ 125 Lyapunov function. Their idea is similar to the continuous-time version of FINDE but limited to a
156
+ 126 single non-increasing quantity in continuous time. On the other hand, our proposed FINDE preserves
157
+ 127 multiple quantities in both continuous and discrete time.
158
+ 28 Previous studies aimed to preserve known first integrals. Moreover, except for DGNet [38], all
159
+ 29 the above methods suffer from numerical errors caused by temporal discretization. In contrast, our
160
+ 30 proposed FINDE learns first integrals from data and can eliminate discretization errors.
161
+
162
+ # 131 3 First Integral-Preserving Neural Differential Equation
163
+
164
+ 132 The main purpose is to find and preserve first integrals from data by neural networks. We suppose
165
+ 133 that a target system has at least $K$ unknown functionally independent first integrals. Even when
166
+ 134 a NODE learns the target system, it is not guaranteed to learn these first integrals. Hence, we
167
+ 135 introduce a neural network with $K$ outputs, each of which is expected to learn one of first integrals
168
+ 136 expressed as $V _ { k } : \mathbb { R } ^ { N } \mathbb { R }$ for $k = 1 , \dots , K$ . We denote the set of first integrals by a vector
169
+ 137 $\pmb { V } ( \pmb { u } ) = ( V _ { 1 } ( \pmb { u } ) V _ { 2 } ( \pmb { u } ) \dotsm V _ { K } ( \pmb { u } ) ) ^ { \top }$ . Then, the submanifold $\mathcal { M } ^ { \prime }$ is defined using the neural
170
+ 138 network $V$ as in Eq. (1).
171
+ 139 Because there is no way to define local coordinates on such submanifolds, a local coordinate method
172
+ 140 is not applicable. When using a projection method, the optimization problem in Eq. (3) should
173
+ 141 be solved at every training iteration as well as in the prediction phase. Optimization problems are
174
+ 142 computationally expensive, and common libraries for neural networks do not provide backpropagation
175
+ 143 algorithms for optimization problems [1, 42].1 Until a recent study has proposed an algorithm [38],
176
+ 144 there was no way to obtain discrete gradients of neural networks. Because of these difficulties,
177
+ 145 no methods for preserving first integrals have been applied to neural networks. By leveraging a
178
+ 146 projection method and a discrete gradient method, we propose FINDE as follows.
179
+
180
+ # 3.1 Continuous FINDE: Time-Derivative Projection Method
181
+
182
+ First, we propose a time-derivative projection method called continuous FINDE (cFINDE) for neural networks, which projects the time-derivative onto the tangent space $\mathcal { T } _ { u } \mathcal { M } ^ { \prime }$ . While it still suffers from numerical errors, it is sufficient to find first integrals from data.
183
+
184
+ We suppose that a neural network called a base model defines the time-derivative $\hat { f } : \mathbb { R } ^ { N } \to \mathbb { R } ^ { N }$ Then, we define the time-derivative $f$ of the cFINDE $\begin{array} { r } { \frac { \mathrm { d } } { \mathrm { d } t } \pmb { u } = f ( \pmb { u } ) } \end{array}$ as
185
+
186
+ $$
187
+ \begin{array} { r } \boldsymbol { f } ( \boldsymbol { \mathbf { \rho } } \boldsymbol { \mathbf { \rho } } \boldsymbol { \mathbf { \rho } } \boldsymbol { \mathbf { \rho } } \boldsymbol { \mathbf { \rho } } \boldsymbol { \mathbf { \rho } } \boldsymbol { \mathbf { \rho } } \boldsymbol { \mathbf { \rho } } \boldsymbol { \mathbf { \rho } } \boldsymbol { \mathbf { \rho } } \boldsymbol { \mathbf { \rho } } \boldsymbol { \mathbf { \rho } } \boldsymbol { \mathbf { \rho } } \boldsymbol { \mathbf { \rho } } \boldsymbol { \mathbf { \rho } } \boldsymbol { \mathbf { \rho } } \boldsymbol { \mathbf { \rho } } \boldsymbol { \mathbf { \rho } } \boldsymbol { \mathbf { \rho } } \boldsymbol { \mathbf { \rho } } \boldsymbol { \mathbf { \rho } } \boldsymbol { \mathbf { \rho } } \boldsymbol { \mathbf { \rho } } \boldsymbol { \mathbf { \rho } } \boldsymbol { \mathbf { \rho } } \boldsymbol { \mathbf { \rho } } \boldsymbol { \mathbf { \rho } } \boldsymbol { \mathbf { \rho } } \boldsymbol { \mathbf { \rho } } \boldsymbol { \mathbf { \rho } } \boldsymbol { \mathbf { \rho } } \boldsymbol { \mathbf { \rho } } \boldsymbol { \mathbf { \rho } } \boldsymbol { \mathbf { \rho } } \boldsymbol { \mathbf { \rho } } \boldsymbol { \mathbf { \rho } } \boldsymbol { \mathbf { \rho } } \boldsymbol { \mathbf { \rho } } \boldsymbol { \mathbf { \rho } } \boldsymbol { \mathbf { \rho } } \boldsymbol { \mathbf { \rho } } \boldsymbol { \mathbf { \rho } } \boldsymbol { \mathbf { \rho } } \boldsymbol { \mathbf { \rho } } \boldsymbol { \mathbf { \rho } } \boldsymbol { \mathbf { \rho } } \boldsymbol { \mathbf { \rho } } \boldsymbol { \mathbf { \rho } } \boldsymbol { \mathbf { \rho } } \boldsymbol { \mathbf { \rho } } \boldsymbol { \mathbf { \rho } } \boldsymbol { \mathbf { \rho } } \boldsymbol { \mathbf { \rho } } \boldsymbol { \mathbf { \rho } } \boldsymbol { \mathbf { \rho } } \boldsymbol { \mathbf { \rho } } \boldsymbol { \mathbf { \rho } } \boldsymbol { \mathbf { \rho } } \boldsymbol { \mathbf { \rho } } \boldsymbol { \mathbf { \rho } } \boldsymbol { \mathbf { \rho } } \boldsymbol { \mathbf { \rho } } \boldsymbol { \mathbf { \rho } } \boldsymbol { \mathbf { \rho } } \boldsymbol { \mathbf { \rho } } \boldsymbol { \mathbf { \rho } } \boldsymbol { \mathbf { \rho } } \boldsymbol { \mathbf { \rho } } \boldsymbol { \mathbf { \rho } } \boldsymbol { \mathbf { \rho } } \boldsymbol { \mathbf { \rho } } \boldsymbol { \mathbf { \rho } } \boldsymbol { \mathbf { \rho } } \boldsymbol { \mathbf { \rho } } \boldsymbol { \mathbf { \rho } } \boldsymbol { \mathbf { \rho } } \boldsymbol \mathbf { \rho } \boldsymbol { \rho } \boldsymbol \end{array}
188
+ $$
189
+
190
+ where 153 $\lambda _ { k }$ is a Lagrange multiplier, $\begin{array} { r } { M \mathrm { ~ = ~ } \frac { \partial V } { \partial \mathbf { u } } } \end{array}$ , and $\lambda ( { \pmb u } ) = ( \lambda _ { 1 } ( { \pmb u } ) \lambda _ { 2 } ( { \pmb u } ) \dots \lambda _ { K } ( { \pmb u } ) ) ^ { \top }$ . If $V _ { k }$
191
+
192
+ $$
193
+ \begin{array} { r } { \mathbf { 0 } = \frac { \mathrm { d } } { \mathrm { d } t } { \pmb V } ( { \pmb u } ( t ) ) = M ( \pmb { u } ) \frac { \mathrm { d } } { \mathrm { d } t } { \pmb u } = M ( \pmb { u } ) f ( \pmb { u } ) = M ( \pmb { u } ) ( \hat { f } ( \pmb { u } ) - M ( \pmb { u } ) ^ { \top } \pmb { \lambda } ( \pmb { u } ) ) , } \end{array}
194
+ $$
195
+
196
+ where 155 $\mathbf { 0 } = ( 0 \ldots 0 ) ^ { \top }$ . By transforming Eq. (5), we obtain the Lagrange multiplier $\lambda ( { \pmb u } ) =$ 156 $( M ( \pmb { \mathscr { u } } ) M ( \pmb { \mathscr { u } } ) ^ { \top } ) ^ { - 1 } M ( \pmb { \mathscr { u } } ) \hat { f } ( \pmb { \mathscr { u } } )$ . By eliminating it, the cFINDE $\begin{array} { r } { \frac { \mathrm { d } } { \mathrm { d } t } \pmb { u } = f ( \pmb { u } ) } \end{array}$ is given by
197
+
198
+ Remark 1 (continuous-time first integral preservation). The cFINDE 57 $\begin{array} { r } { \frac { \mathrm { d } } { \mathrm { d } t } \pmb { u } = f ( \pmb { u } ) } \end{array}$ preserves all first integrals 58 $V _ { k }$ for $k = 1 , \ldots , K$ in continuous time, i.e., $\begin{array} { r } { { \frac { \mathrm { d } } { \mathrm { d } t } } V _ { k } = 0 } \end{array}$ .
199
+
200
+ 159 The base model $\hat { f }$ can be a NODE, an HNN, or other models depending on available prior knowledge.
201
+ 160 Also, if a first integral is already known, one can use it directly as one of first integrals $V _ { k }$ instead
202
+ 161 of learning it using a neural network. Note that even though the base model $\hat { f }$ is an HNN, due to
203
+ 162 projection, the cFINDE $f$ is no longer a Hamiltonian system in the strict sense.
204
+
205
+ Compared to the base model $\hat { f }$ , the cFINDE requires the additional computation of the neural network $V$ , several matrix multiplications, and an inverse operation. The inverse operation needs a computational cost of $O ( K ^ { 3 } )$ , which is not costly if the number $K$ of first integrals is small. For satisfying the constraints and geometric structures, many previous models also need the inverse operation, such as Lagrangian neural network (LNN) [13], neural symplectic form [9], and CHNN [20].
206
+
207
+ 69 To eliminate numerical errors caused by temporal discretization, we employ discrete gradients and
208
+ 70 propose a projection method called discrete FINDE (dFINDE).
209
+
210
+ A discrete gradient $\overline { { \nabla } } V$ is a discrete analogue to a gradient $\nabla V$ [6, 23, 25, 29, 44, 45]. Recall that a gradient $\nabla V$ of a function $V : \mathbb { R } ^ { N } \mathbb { R }$ can be regarded as a function $\mathbb { R } ^ { N } \to \mathbb { R } ^ { N }$ that satisfies the chain rule $\begin{array} { r } { \frac { \mathrm { d } } { \mathrm { d } t } V ( \pmb { u } ) = \nabla V ( \pmb { u } ) ^ { \top } \frac { \mathrm { d } } { \mathrm { d } t } \pmb { u } } \end{array}$ . Analogously, a discrete gradient $\overline { \nabla }$ is defined as follows.
211
+
212
+ Definition 2 (discrete gradient). A discrete gradient $\overline { { \nabla } } V$ of a function $V : \mathbb { R } ^ { N } \mathbb { R }$ is a function $\mathbb { R } ^ { N } \times \mathbb { R } ^ { N } \xrightarrow [ ] { } \mathbb { R } ^ { N }$ that satisfies
213
+
214
+ $$
215
+ V ( \pmb { v } ) - V ( \pmb { u } ) = \overline { { \nabla } } V ( \pmb { v } , \pmb { u } ) ^ { \top } ( \pmb { v } - \pmb { u } ) ~ a n d ~ \overline { { \nabla } } V ( \pmb { u } , \pmb { u } ) = \nabla V ( \pmb { u } ) .
216
+ $$
217
+
218
+ 176 The first condition is a discrete analogue to the chain rule when replacing the time-derivatives ${ \frac { \mathrm { d } } { \mathrm { d } t } } V$
219
+ 177 and ${ \frac { \mathrm { d } } { \mathrm { d } t } } { \pmb u }$ with finite differences $( V ( \pmb { v } ) - V ( \pmb { u } ) )$ and $( { \pmb v } - { \pmb u } )$ , respectively, and the second condition
220
+ 178 ensures the consistency with the ordinary gradient $\nabla V$ . A discrete gradient $\overline { { \nabla } } V$ is not uniquely
221
+ 179 determined and has been obtained manually. Recently, the automatic discrete differentiation algorithm
222
+ 180 (ADDA) has been proposed in [38], which obtains a discrete gradient of a neural network in a similar
223
+ 181 way to the automatic differentiation algorithm [1, 42]. The discrete gradient is defined in discrete
224
+ 182 time, and hence a numerical integration using the discrete gradient is free from numerical errors
225
+ 183 caused by temporal discretization. See Appendix $\mathbf { B }$ and the references [6, 23, 38] for more details.
226
+
227
+ Following [11, 15], we introduce a discrete analogue to the tangent space 184 $\mathcal { T } _ { \mathbf { \ b { u } } } \mathcal { M } ^ { \prime }$ called the discrete tangent space 185 $\mathcal { T } _ { ( \pmb { v } , \pmb { u } ) } \mathcal { M } ^ { \prime }$ . In particular, for a pair $( \pmb { v } , \pmb { u } ) \in \mathcal { M } ^ { \prime }$ of points, it is defined as
228
+
229
+ $$
230
+ \mathcal { T } _ { ( v , u ) } \mathcal { M } ^ { \prime } = \{ \pmb { w } \in \mathbb { R } ^ { N } : \overline { { \nabla } } V _ { k } ( \pmb { v } , \pmb { u } ) ^ { \top } \pmb { w } = 0 \mathrm { ~ f o r ~ } k = 1 , \ldots , K \} .
231
+ $$
232
+
233
+ 186 If the finite difference $( \pmb { u } ^ { s + 1 } - \pmb { u } ^ { s } )$ between the predicted and current states is on the discrete
234
+ 187 tangent space $\mathcal { T } _ { \left( \pmb { u } ^ { s + 1 } , \pmb { u } ^ { s } \right) } \mathcal { M } ^ { \prime }$ , the first integrals $V _ { k }$ are preserved because $V _ { k } ( { \pmb u } ^ { s + 1 } ) - V _ { k } ( { \pmb u } ^ { s } ) =$
235
+ 188 $\overline { { \nabla } } V _ { k } ( \pmb { u } ^ { s + 1 } , \pmb { u } ^ { s } ) ^ { \top } ( \pmb { u } ^ { s + 1 } - \pmb { u } ^ { s } ) = 0$ . Note that similar concepts defined in different ways are also
236
+ 189 referred to as discrete tangent spaces [14, 16].
237
+
238
+ Let ψˆ denote a discrete-time base model that satisfies u˜s+1−us∆ts 190 $\begin{array} { r } { \frac { \tilde { \mathbf { u } } ^ { s + 1 } - \mathbf { u } ^ { s } } { \Delta t ^ { s } } = \hat { \psi } ( \mathbf { u } ^ { s } ; \Delta t ^ { s } ) } \end{array}$ , where $\tilde { { \pmb u } } ^ { s + 1 }$ denotes 191 the predicted state. We assume that the base model $\hat { \psi }$ is composed of a continuous-time base model 192 ˆf and a numerical integrator. Then, the dFINDE us+1−∆ts $\begin{array} { r } { \frac { { \pmb u } ^ { s + 1 } - { \pmb u } ^ { s } } { \Delta t ^ { s } } = \psi ( { \pmb u } ^ { s + 1 } , { \pmb u } ^ { s } ; \Delta t ^ { s } ) } \end{array}$ is given by
239
+
240
+ $$
241
+ \psi ( \pmb { u } ^ { s + 1 } , \pmb { u } ^ { s } ; \Delta t ^ { s } ) = \hat { \psi } ( \pmb { u } ^ { s } ; \Delta t ^ { s } ) - \overline { { M } } ( \pmb { u } ^ { s + 1 } , \pmb { u } ^ { s } ) ^ { \top } \lambda ( \pmb { u } ^ { s + 1 } , \pmb { u } ^ { s } ) ,
242
+ $$
243
+
244
+ where 193 $\overline { { M } } ( { \pmb u } ^ { s + 1 } , { \pmb u } ^ { s } ) = ( \overline { { \nabla } } V _ { 1 } ( { \pmb u } ^ { s + 1 } , { \pmb u } ^ { s } )$ . . . $\overline { { \nabla } } V _ { K } ( \pmb { u } ^ { s + 1 } , \pmb { u } ^ { s } ) ) ^ { \top }$ . As is the case in continuous time, 194 the preservation of the first integrals $V _ { k }$ leads to
245
+
246
+ $$
247
+ \begin{array} { r } { \mathbf { 0 } = \frac { V ( u ^ { s + 1 } ) - V ( u ^ { s } ) } { \Delta t ^ { s } } = \overline { { M } } ( u ^ { s + 1 } , u ^ { s } ) \frac { u ^ { s + 1 } - u ^ { s } } { \Delta t ^ { s } } = \overline { { M } } ( u ^ { s + 1 } , u ^ { s } ) \psi ( u ^ { s + 1 } , u ^ { s } ; \Delta t ^ { s } ) . } \end{array}
248
+ $$
249
+
250
+ 195 Substituting Eq. (9) and eliminating the Lagrange multiplier $\boldsymbol { \lambda }$ , we obtain
251
+
252
+ $$
253
+ \psi ( \pmb { u } ^ { s + 1 } , \pmb { u } ^ { s } ; \Delta t ^ { s } ) = ( I - \overline { { Y } } ( \pmb { u } ^ { s + 1 } , \pmb { u } ^ { s } ) ) \hat { \psi } ( \pmb { u } ^ { s } ; \Delta t ^ { s } )
254
+ $$
255
+
256
+ Remark 2 (discrete-time first integral preservation). The dFINDE us+1−us∆ts preserves all first integrals $V _ { k }$ for $k = 1 , \ldots , K$ in discrete time, i.e., $V _ { k } ( { \pmb u } ^ { s + 1 } ) - V _ { k } ( { \pmb u } ^ { s } ) = 0$ $\begin{array} { r } { \frac { { \pmb u } ^ { s + 1 } - { \pmb u } ^ { s } } { \Delta t ^ { s } } = \psi ( { \pmb u } ^ { s + 1 } , { \pmb u } ^ { s } ; \Delta t ^ { s } ) } \end{array}$
257
+
258
+ 198 Due to projection, dFINDE can be regarded as a projection method using discrete gradients. For the
259
+ 199 base model $\hat { \psi }$ , the continuous-time base model $\hat { f }$ can be a NODE, an HNN, or other models, and the
260
+ 200 numerical integrator can be a Runge–Kutta method, the leapfrog integrator, or others.
261
+ 201 Because dFINDE is an implicit method, it is computationally expensive for prediction. However, the
262
+ 202 next state $\boldsymbol { u } ^ { s + 1 }$ is given for training, and the ADDA can explicitly obtain the discrete gradient w.r.t. the
263
+ 203 pair $( { \pmb u } ^ { s + 1 } , { \pmb u } ^ { s } )$ as well as its computational graph. Thus, dFINDE can be computed explicitly and
264
+ 204 optimized by standard backpropagation algorithms. Moreover, we suppose that dFINDE projects
265
+ 205 the finite difference $\hat { \psi }$ only at every time step, whereas cFINDE projects the time-derivative $\hat { f }$ at
266
+ 206 every substep inside a numerical integrator. Therefore, dFINDE is less computationally expensive
267
+ 207 than cFINDE for training. In contrast, a typical projection method requires much computational
268
+ 208 cost to solve an optimization problem for training, and standard backpropagation algorithms are not
269
+ 209 applicable to it.
270
+ 10 Remark 3 (trainability). The dFINDE can be trained using the standard backpropagation algorithm,
271
+ 211 whereas a straightforward application of a projection method cannot.
272
+
273
+ Table 2: Datasets, Dynamics, and First Integrals.
274
+
275
+ <table><tr><td rowspan="2">Dataset</td><td rowspan="2">Dynamics</td><td rowspan="2">N</td><td colspan="4">First Integrals</td></tr><tr><td>Energy</td><td>Momentum</td><td>Mass</td><td>Constraint</td></tr><tr><td>Two-body problem</td><td>Canonical Hamiltonian</td><td>8</td><td></td><td>1</td><td></td><td></td></tr><tr><td>Discretized KdV equation</td><td>Non-canonical Hamiltonian</td><td>50</td><td>广</td><td></td><td>1</td><td></td></tr><tr><td>Double pendulum</td><td>Poisson</td><td>8</td><td>√</td><td></td><td></td><td>√</td></tr><tr><td>FitzHugh-Nagumo model</td><td>Dirac</td><td>4</td><td></td><td></td><td></td><td>√</td></tr></table>
276
+
277
+ # 4 Experiments
278
+
279
+ # 4.1 Experimental Settings
280
+
281
+ Target Systems We evaluated FINDE and base models using datasets associated with first integrals, summarized in Table 2. A gravitational two-body problem (2-body) on a 2-dimensional configuration space is a typical Hamiltonian system in the canonical form. In addition to the total energy, it has first integrals related to symmetries in space, namely, the linear and angular momenta. The Korteweg–De Vries (KdV) equation is a PDE model of shallow water waves. This is a Hamiltonian system in a non-canonical form and has the Hamiltonian, total mass, and many other quantities as first integrals. A double pendulum (2-pend) is a Hamiltonian system in polar coordinates. However, we transformed it to Cartesian coordinates; it was no longer a Hamiltonian system but a Poisson system. The lengths of two rods work as holonomic constraints and lead to four first integrals. The FitzHugh–Nagumo model is a biological neuron model as an electric circuit, which exhibits a rapid and transient change of voltage called a spike. As an electric circuit, the currents through and voltages applied to the inductor and capacitor can be regarded as system states, and the states are constrained by the circuit topology and Kirchhoff’s current and voltage laws. Then, this system has a state of four elements and two first integrals. Due to energy dissipation in the resistor, the model is not a Poisson system, but one can find a Dirac structure [53]. See Appendix C for more details.
282
+
283
+ Implementation We implemented the proposed FINDE and evaluated it under the following settings. We implemented all codes by modifying the officially released codes of HNN [26] 2 and DGNet $[ 3 8 ] ^ { 3 }$ . We used Python v3.8.12 with packages scipy v1.7.3, pytorch v1.10.2, torchdiffeq v0.1.1, functorch v1.10 preview, and gplearn v0.4.2. We used the Dormand–Prince method (dopri5) [18] as the numerical integrator, unless otherwise stated. All experiments were performed on a single NVIDIA A100 provided by (ANONYMOUS PROVIDER).
284
+
285
+ Following HNN [26] and DGNet [38], we represented the first integrals $V$ , NODE, and HNN $H$ using fully-connected neural networks with two hidden layers. Each hidden layer had 200 units and preceded a hyperbolic tangent activation function. Each weight matrix was initialized as an orthogonal matrix. The input was the state $\textbf { \em u }$ , and the output represented the first integrals $V$ for FINDE, time-derivative $\hat { f }$ for NODE, and the Hamiltonian $H$ for HNN. For the KdV dataset, we used a 1-dimensional convolutional neural network (CNN), each of whose layers had a kernel size of 3. The double pendulum is a second–order system, implying that the time-derivative ddt q of the position $\pmb q$ is known as the velocity $\textbf { { v } }$ . Hence, we treated only the acceleration $\begin{array} { r } { \frac { \mathrm { d } } { \mathrm { d } t } \pmb { v } } \end{array}$ as the output to learn. This assumption slightly improved the absolute performances but did not change the relative trends.
286
+
287
+ We used the $I$ -step error as the loss function to be minimized. In particular, it is the mean squared error (MSE) between the ground truth state $\pmb { u } _ { \mathrm { G T } } ^ { s }$ and the state $\pmb { u } _ { \mathrm { p r e d . } } ^ { s }$ . predicted from the previous step $u _ { \mathrm { G T } } ^ { s - 1 }$ . The base model and FINDE were jointly trained using the Adam optimizer [33] with the parameters $( \beta _ { 1 } , \beta _ { 2 } ) = ( 0 . 9 , 0 . 9 9 9 )$ and a batch size of 200. The learning rate was initialized to $1 0 ^ { - 3 }$ and decayed to zero with a cosine annealing [36].
288
+
289
+ 249 Evaluation Metric As an evaluation metric, we used the 1-step error, which is identical to the loss
290
+ 250 function. We displayed it at the scale of $\times 1 0 ^ { - 9 }$ . The lower this indicator, the better, as emphasized
291
+ 251 by $\downarrow$ . While several studies used the MSEs of the state or system energy over the whole time
292
+ 252 series [26, 38], we consider these indicators are misleading, as pointed in several studies [4]. For
293
+ 253 example, in the case of a periodic orbit, an orbit that is correctly learned except for a slight difference
294
+ 254 in angular velocity will have the same MSE as an orbit that never moves from its initial position.
295
+ 255 Instead, we used the valid prediction time $( V P T )$ [4, 32, 54]. VPT denotes the time point $s$ divided by
296
+ 256 the length $S$ of time series at which the MSE of the predicted state $\pmb { u } _ { \mathrm { p r e d . } } ^ { s }$ . exceeds a given threshold $\theta$
297
+ 257 for the first time in an initial value problem, that is,
298
+
299
+ $$
300
+ \begin{array} { r } { V P T ( u _ { \mathrm { p r e d . } } ; u _ { \mathrm { G T } } ) = \frac { 1 } { S } \arg \operatorname* { m a x } _ { s _ { f } } \{ s _ { f } | \mathrm { M S E } ( u _ { \mathrm { p r e d . } } ^ { s } , u _ { \mathrm { G T } } ^ { s } ) < \theta \mathrm { f o r } \mathrm { a l l } s \leq s _ { f } \} . } \end{array}
301
+ $$
302
+
303
+ 258 To obtain VPTs, we normalized each element of state to have zero mean and unit variance in the
304
+ 259 training data and set $\theta$ to 0.01. The higher this indicator, the better, as emphasized by $\uparrow$ . Because of
305
+ 260 the “spiking” behavior of the FitzHugh–Nagumo model, a small error in phase is regarded as a large
306
+ 261 error in state. To measure the qualitative performance, we calculated VPTs by allowing for a delay
307
+ 262 and advance of up to 5 steps.
308
+
309
+ # 4.2 First Integral Preservation for Hamiltonian System
310
+
311
+ Before learning first integrals from data, we first evaluated FINDE as a numerical integrator using a known mass-spring system. The system has the state $\mathbf { \boldsymbol { \mathscr { u } } } \doteq ( q v ) ^ { \top }$ , the dynamics ddt q = v and d $\begin{array} { r } { { \frac { \mathrm { d } } { \mathrm { d } t } } v \ = - q } \end{array}$ , and the system energy $E ( q , v ) =$ ${ \scriptstyle { \frac { 1 } { 2 } } } ( q ^ { 2 } + v ^ { 2 } )$ . Using the initial value $( 1 . 0 \ 0 . 0 ) ^ { \top }$ and the time step size $\Delta t = 0 . 2$ , we solved the initial value problem of the true ODE using the leapfrog integrator. We applied FINDE with the true system energy $E$ as the first integral $V$ . Note that no neural networks nor training were involved.
312
+
313
+ ![](images/e62087da4d5eea6ebb9b01535f06401e481e011b62a41af256ef1f7e2091ccfd.jpg)
314
+ Figure 1: Integration of a known mass-spring system.
315
+
316
+ 273 The results with the analytical solution are shown in Fig. 1. The upper panel shows that the time series
317
+ 274 predicted by comparison methods overlap each other and are apparently almost identical. However,
318
+ 275 the lower panel shows that the energy obtained from the states predicted by the leapfrog integrator is
319
+ 276 fluctuating. The same is true for the case with the cFINDE. This is because the symplectic integrator
320
+ 277 and the cFINDE suffer from numerical errors caused by temporal discretization. In contrast, the
321
+ 278 dFINDE preserves the energy accurately. This is because, at every step, the dFINDE projects the state
322
+ 279 $( q v ) ^ { \top }$ onto the discrete tangent space $\mathcal { T } _ { ( \pmb { v } , \pmb { u } ) } \mathcal { M } ^ { \prime }$ . Although a smaller step size reduces numerical
323
+ 280 errors, this result demonstrates the advantage of dFINDE.
324
+
325
+ # 281 4.3 Learning First Integrals from Data of Hamiltonian System
326
+
327
+ 82 We evaluated FINDE on learning from the 2-body dataset. We used HNN as the base model $\hat { f }$ . We
328
+ 83 found that the FINDE got better performances if it did not treat the Hamiltonian $H$ of the HNN
329
+ 84 as one of first integrals $V _ { k }$ . The medians and standard deviations of 5 trials are summarized in the
330
+ 85 leftmost column of Table 3. The cFINDE achieved better VPTs than the vanilla HNN with $K = 1$
331
+ 86 to 2, and the performance was suddenly degraded for $K = 3$ . The dFINDE showed a similar trend
332
+ 7 with slightly better performances. The HNN with FINDE found two first integrals in addition to the
333
+ 88 Hamiltonian $H$ of the HNN. Even though a two-body problem is a Hamiltonian system that HNN
334
+ 89 can learn, the prior knowledge that there exist first integrals other than the Hamiltonian $H$ can be
335
+ 90 a clue to better learning. The HNN with FINDE got worse 1-step errors, suggesting that without
336
+ FINDE, HNN overfitted short-term change and had difficulty predicting long-term dynamics.
337
+
338
+ We performed a symbolic regression of first integrals $V$ learned by the neural network. For $K = 2$ , the learned first integrals $V$ were identical to the linear momenta in the $x$ - and $y$ -directions up to affine transformation in most cases. See Appendix D.1 for more details.
339
+
340
+ We depict example results in Fig. 2. In the absence of FINDE, the mass positions $( x _ { 1 } , y _ { 1 } ) , ( x _ { 2 } , y _ { 2 } )$ became inaccurate in a short time and the center-of-gravity position $\textstyle ( x _ { c } , y _ { c } ) = ( { \frac { x _ { 1 } + x _ { 2 } } { 2 } } , { \frac { y _ { 1 } + y _ { 2 } } { 2 } } )$ deviated rapidly. The HNN with cFINDE accurately predicted the state for a longer period. Even after errors in the mass positions became non-negligible, errors in the center-of-gravity position were still small. We show the absolute errors averaged over all trials in Fig. 3. In each of $x$ - and $y$ -directions,
341
+
342
+ Table 3: Results of FINDE.
343
+
344
+ <table><tr><td colspan="2"></td><td colspan="2">2-body + HNN</td><td colspan="2">KdV</td><td colspan="2">2-pend</td><td colspan="2">FitzHugh-Nagumo</td></tr><tr><td>Model</td><td>K</td><td>1-step↓</td><td>VPT个</td><td>1-step↓</td><td>VPT个</td><td>1-step↓</td><td>VPT个</td><td>1-step↓</td><td>VPT个</td></tr><tr><td>base model -</td><td></td><td></td><td>5.17 ±0.57 0.362 ±0.026</td><td>5.59 ±0.30</td><td>0.339 ±0.038</td><td>0.82 ±0.02</td><td>0.110±0.035</td><td></td><td>73.66 ±12.59 0.236 ±0.053</td></tr><tr><td rowspan="6">+ cFINDE</td><td>1</td><td>7.10 ±1.25</td><td>0.374 ±0.036</td><td>6.24 ±0.44</td><td>0.371 ±0.088</td><td>0.75 ±0.04</td><td>0.156±0.042</td><td>54.18 ±8.12</td><td>0.127 ±0.148</td></tr><tr><td>2</td><td>7.78 ±1.39</td><td>0.450 ±0.052</td><td>2.59 ±0.11</td><td>0.608 ±0.085</td><td>0.73±0.05</td><td>0.198 ±0.088</td><td>37.03 ±3.81</td><td>0.437 ±0.084</td></tr><tr><td>3</td><td>&gt;103</td><td>0.147 ±0.146*</td><td>3.19 ±0.37</td><td>0.730 ±0.091</td><td>0.69 ±0.03</td><td>0.411 ±0.093</td><td>&gt;106</td><td>0.007 ±0.007*</td></tr><tr><td>4</td><td>&gt;103</td><td>0.101 ±0.005</td><td>3.65 ±0.30</td><td>0.641 ±0.071</td><td>0.77 ±0.07</td><td>0.395 ±0.083</td><td>一</td><td></td></tr><tr><td>5</td><td>&gt;103</td><td>0.080±0.014</td><td>4.68 ±0.43</td><td>0.601 ±0.069</td><td>0.80±0.07</td><td>0.585 ±0.097</td><td></td><td></td></tr><tr><td>6</td><td>&gt;10³</td><td>0.070 ±0.019</td><td>7.79 ±0.51</td><td>0.425 ±0.067</td><td>12.53±0.00</td><td>0.005 ±0.000*</td><td></td><td></td></tr><tr><td rowspan="5">+ dFINDE</td><td>1</td><td>7.01 ±1.06</td><td>0.379 ±0.040</td><td>11.61 ±6.60</td><td>0.288 ±0.083</td><td>0.75 ±0.10</td><td>0.152 ±0.017</td><td>47.07 ±8.03</td><td>0.117 ±0.122</td></tr><tr><td>2</td><td>7.03 ±1.00</td><td>0.475 ±0.022</td><td>2.70 ±0.26</td><td>0.598 ±0.059</td><td>0.74±0.05</td><td>0.271 ±0.111</td><td>33.24 ±3.40</td><td>0.455 ±0.032</td></tr><tr><td></td><td></td><td>3 54.78 ±36.39 0.309 ±0.024</td><td>3.78±0.27</td><td>0.636 ±0.024</td><td>0.69±0.05</td><td>0.447 ±0.081</td><td></td><td>319.70 ±91.11 0.049 ±0.007</td></tr><tr><td>4</td><td>&gt;10</td><td>0.102 ±0.015</td><td>3.48±0.32</td><td>0.780 ±0.059</td><td>0.71 ±0.03</td><td>0.454 ±0.060</td><td></td><td></td></tr><tr><td>5</td><td>&gt;103</td><td>0.086±0.011*</td><td>5.26 ±0.15</td><td>0.718±0.038</td><td>0.86 ±0.09</td><td>0.591 ±0.087</td><td></td><td></td></tr><tr><td></td><td>6</td><td>&gt;103</td><td>0.059 ±0.017</td><td>9.60 ±3.61</td><td></td><td></td><td>0.573 ±0.121 58.88 ±22.98 0.037 ±0.039</td><td></td><td></td></tr></table>
345
+
346
+ A standard deviation follows $\pm$ symbol. Underlines indicate results better than the base models’ results, and bolded fonts indicate the best results. ∗ denotes that some trials failed in training because of the underflow of the step size. A dash denotes a case we did not try.
347
+
348
+ ![](images/89d03c9a7890406db2fbecc814f8b6b34cdc584df01fb3eb8c8146f7deede677.jpg)
349
+ Figure 2: Example results of the 2-body dataset.
350
+
351
+ ![](images/468b3482f1aadb8120b8263d0dcca0d63d619e797bf1f63eb5d4a25bb716d4d7.jpg)
352
+ Figure 3: Mean absolute errors of states for the 2-body dataset with or without cFINDE.
353
+
354
+ 300 the HNN without FINDE produced errors in the center-of-gravity position $x _ { c }$ (or $y _ { c }$ ) and those in the
355
+ 301 mass positions $x _ { 1 } , x _ { 2 }$ (or $y _ { 1 } , y _ { 2 } )$ at almost the same level. In contrast, when the cFINDE is present,
356
+ 302 errors in the center-of-gravity position were much smaller than those in the mass positions, implying
357
+ 303 that errors in one mass position canceled out errors in the other mass position.
358
+
359
+ Therefore, we conclude that FINDE not only had better prediction accuracy but also found and preserved linear momenta (which are related to symmetries in space) more accurately despite not having prior knowledge about symmetries.
360
+
361
+ # 307 4.4 Learning First Integrals from Data of Unknown Systems
362
+
363
+ 308 It is often unclear whether a target system is a Hamiltonian system or not, but one can expect that the
364
+ 309 target system has several first integrals. We evaluated FINDE using NODE as the base model. We
365
+ 310 summarized the results in Table 3.
366
+ 311 For the KdV dataset, the NODE with FINDE got much better 1-step errors and VPTs for a wide
367
+ 312 range of $K$ . Figure 4 shows an example result. The top panels show that the prediction results were
368
+ 313 apparently similar. The bottom panels summarize mean absolute errors in states $\textbf { \em u }$ , total mass $\textstyle \sum _ { k } u _ { k }$
369
+ 314 and energy. In the absence of FINDE, the NODE increased all of its errors in proportion to time. With
370
+ 315 the cFINDE, the error in total mass increased at the point where the two solitons collided but then
371
+ 316 returned to the original level. Although the calculation is slightly inaccurate, the cFINDE learned
372
+ 317 to preserve the total mass. The rightmost panel shows that the error in energy continued to increase
373
+ 318 for $K = 2$ , but it stayed within a small range for $K = 3$ . These results suggest that the first or
374
+ 319 second quantity learned by the cFINDE was total mass, the third quantity was system energy, and the
375
+ 320 remaining quantity may correspond to one of the many first integrals of the KdV equation.
376
+ 321 For the 2-pend dataset, the NODE with FINDE got better 1-step errors and VPTs for $K = 1$ to 5
377
+ 322 except for the 1-step error of the dFINDE with $K = 5$ . In addition to the system energy, the double
378
+ 323 pendulum has two holonomic constraints on the position, which lead to two additional constraints
379
+ 324 involving the velocity (see Appendix C for details). Thus, it is reasonable that the NODE with FINDE
380
+ 325 got the best VPTs for $K = 5$ first integrals and totally failed when assuming $K > 5$ first integrals.
381
+ 326 As exemplified in Fig. 5, the NODE without FINDE did not preserve the lengths of rods, making
382
+ 327 the states deviate gradually. See Appendix D.2 for the case when actual constraints are known. For
383
+ 328 the FitzHugh–Nagumo dataset, the NODE with FINDE got much better 1-step errors and VPTs for
384
+ 329 $K = 2$ . As exemplified in Fig. 6, the ground truth state converged to a periodic orbit, and only the
385
+ 330 NODE with cFINDE for $K = 2$ reproduced such dynamics. On the other hand, the state did not
386
+ 331 stay at a limited region without FINDE and converged to a wrong equilibrium with the cFINDE for
387
+ 332 $K = 1$ . For $K = 1$ , the sole quantity $V _ { 1 }$ may have tried to learn both of the two first integrals and
388
+ 333 remained under-trained. In these two cases, FINDE found all first integrals; $K = 5$ for the 2-pend
389
+ 334 dataset and $K = 2$ for the FitzHugh–Nagumo dataset.
390
+
391
+ ![](images/be5e28ffd5b113697cd23b60e955f60ccb12a63a936fb9ef9c08be823a75a887.jpg)
392
+ Figure 4: Example results of the KdV dataset. (top) Predicted states. Red belts denote moving solitons. (bottom) Mean absolute errors.
393
+
394
+ ![](images/8556882ad46dc0590252f5c7531273f1da140556e98cc6d80d3d2b4923a070e9.jpg)
395
+ Figure 5: Example results of the 2-pend dataset for 2,000 steps.
396
+
397
+ ![](images/7787089d38eb6cba10618809e53bcab45a879c57163f3cfcbb6474ad1a9cd456.jpg)
398
+ Figure 6: Example results of the FitzHugh–Nagumo dataset.
399
+
400
+ # 335 5 Conclusion
401
+
402
+ This study proposed first integral-preserving neural differential equation (FINDE). FINDE projects the time evolution onto the submanifold defined using the (discrete) gradients of first integrals represented by a neural network. With an appropriate number of assumed first integrals, FINDE predicted future states more accurately than base models. Not only that, FINDE found and preserved the system energy and the total mass as first integrals, first integrals related to symmetries in space, and first integrals led by constraints in a unified manner. Therefore, FINDE has the potential to make a scientific discovery by revealing unknown properties of target dynamical systems.
403
+
404
+ The 1-step errors were on the order of $1 0 ^ { - 5 }$ to $1 0 ^ { - 4 }$ in absolute error, being much larger than the numerical error tolerance of $1 0 ^ { - 9 }$ used in the experiments; numerical errors were negligible compared to modeling errors. However, the dFINDE tended to get VPTs better than the cFINDE despite the fact that its advantage is to eliminate numerical errors caused by temporal discretization. This result suggests that a method leading to smaller numerical errors results in a model with smaller modeling errors. Similar tendencies have been observed in previous works [10, 38], and these results may form a new frontier for integrating numerical and modeling errors.
405
+
406
+ # References
407
+
408
+ [1] Abadi, M., Agarwal, A., Barham, P., Brevdo, E., Chen, Z., Citro, C., Corrado, G. S., Davis, A., Dean, J., Devin, M., Ghemawat, S., Goodfellow, I., Harp, A., Irving, G., Isard, M., Jozefowicz, R., Jia, Y., Kaiser, L., Kudlur, M., Levenberg, J., Mané, D., Schuster, M., Monga, R., Moore, S., Murray, D., Olah, C., Shlens, J., Steiner, B., Sutskever, I., Talwar, K., Tucker, P., Vanhoucke, V., Vasudevan, V., Viégas, F., Vinyals, O., Warden, P., Wattenberg, M., Wicke, M., Yu, Y., and Zheng, X. (2016). TensorFlow: Large-scale machine learning on heterogeneous systems. USENIX Symposium on Operating Systems Design and Implementation (OSDI).
409
+ 58 [2] Bai, S., Kolter, J. Z., and Koltun, V. (2019). Deep Equilibrium Models. In Advances in Neural Information Processing Systems (NeurIPS).
410
+ 60 [3] Barrett, D. G. T. and Dherin, B. (2021). Implicit Gradient Regularization. In International Conference on Learning Representations (ICLR).
411
+ [4] Botev, A., Jaegle, A., Wirnsberger, P., Hennes, D., and Higgins, I. (2021). Which priors matter? Benchmarking models for learning latent dynamics. In Advances in Neural Information Processing Systems (NeurIPS) Track on Datasets and Benchmarks. [5] Cao, Y., Fang, Z., Wu, Y., Zhou, D. X., and Gu, Q. (2021). Towards Understanding the Spectral Bias of Deep Learning. International Joint Conference on Artificial Intelligence (IJCAI), pages 2205–2211.
412
+ 7 [6] Celledoni, E., Grimm, V., McLachlan, R., McLaren, D., O’Neale, D., Owren, B., and Quispel, G. (2012). Preserving energy resp. dissipation in numerical PDEs using the “Average Vector Field” method. Journal of Computational Physics, 231(20):6770–6789. [7] Chen, S., Billings, S. A., and Grant, P. M. (1990). Non-linear system identification using neural networks. International Journal of Control, 51(6):1191–1214. [8] Chen, T. Q., Rubanova, Y., Bettencourt, J., Duvenaud, D., Chen, R. T. Q., Rubanova, Y., Bettencourt, J., and Duvenaud, D. (2018). Neural Ordinary Differential Equations. In Advances in Neural Information Processing Systems (NeurIPS), pages 1–19. [9] Chen, Y., Matsubara, T., and Yaguchi, T. (2021). Neural Symplectic Form $:$ Learning Hamiltonian Equations on General Coordinate Systems. In Advances in Neural Information Processing Systems (NeurIPS). [10] Chen, Z., Zhang, J., Arjovsky, M., and Bottou, L. (2020). Symplectic Recurrent Neural Networks. In International Conference on Learning Representations (ICLR), pages 1–23. [11] Christiansen, S. H., Munthe-Kaas, H. Z., and Owren, B. (2011). Topics in structure-preserving discretization. Acta Numerica, 20:1–119. [12] Clouse, D. S., Giles, C. L., Horne, B. G., and Cottrell, G. W. (1997). Time-delay neural networks: representation and induction of finite-state machines. IEEE Transactions on Neural Networks, 8(5):1065–70. [13] Cranmer, M., Greydanus, S., Hoyer, S., Battaglia, P., Spergel, D., and Ho, S. (2020). Lagrangian Neural Networks. In ICLR Deep Differential Equations Workshop, pages 1–9. [14] Cuell, C. and Patrick, G. W. (2009). Geometric discrete analogues of tangent bundles and constrained Lagrangian systems. Journal of Geometry and Physics, 59(7):976–997. [15] Dahlby, M., Owren, B., and Yaguchi, T. (2011). Preserving multiple first integrals by discrete gradients. Journal of Physics A: Mathematical and Theoretical, 44(30). [16] Dehmamy, N., Walters, R., Liu, Y., Wang, D., and Yu, R. (2021). Automatic Symmetry Discovery with Lie Algebra Convolutional Network. In Advances in Neural Information Processing Systems (NeurIPS), number 2018, pages 1–30. [17] Devlin, J., Chang, M.-W., Lee, K., and Toutanova, K. (2018). BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding. arXiv, pages 1–15. [18] Dormand, J. R. and Prince, P. J. (1986). A reconsideration of some embedded Runge-Kutta formulae. Journal of Computational and Applied Mathematics, 15(2):203–211. [19] Finzi, M., Stanton, S., Izmailov, P., and Wilson, A. G. (2020a). Generalizing Convolutional Neural Networks for Equivariance to Lie Groups on Arbitrary Continuous Data. In International Conference on Machine Learning (ICML), pages 3146–3157.
413
+ [20] Finzi, M., Wang, K. A., and Wilson, A. G. (2020b). Simplifying Hamiltonian and Lagrangian Neural Networks via Explicit Constraints. In Advances in Neural Information Processing Systems (NeurIPS).
414
+ [21] Finzi, M., Welling, M., and Wilson, A. G. (2021). A Practical Method for Constructing Equivariant Multilayer Perceptrons for Arbitrary Matrix Groups. In International Conference on Machine Learning (ICML).
415
+ [22] Furihata, D. (2001). A stable and conservative finite difference scheme for the Cahn-Hilliard equation. Numerische Mathematik, 87(4):675–699.
416
+ [23] Furihata, D. and Matsuo, T. (2010). Discrete Variational Derivative Method: A Structure-Preserving Numerical Method for Partial Differential Equations. Chapman and Hall/CRC.
417
+ [24] Gear, C. W. (1986). Maintaining Solution Invariants in the Numerical Solution of ODE s. SIAM Journal on Scientific and Statistical Computing, 7(3):734–743.
418
+ [25] Gonzalez, O. (1996). Time integration and discrete Hamiltonian systems. Journal of Nonlinear Science, 6(5):449–467.
419
+ [26] Greydanus, S., Dzamba, M., and Yosinski, J. (2019). Hamiltonian Neural Networks. In Advances in Neural Information Processing Systems (NeurIPS), pages 1–16.
420
+ [27] Hairer, E., Lubich, C., and Wanner, G. (2006). Geometric Numerical Integration: Structure-Preserving Algorithms for Ordinary Differential Equations, volume 31 of Springer Series in Computational Mathematics. Springer-Verlag, Berlin/Heidelberg.
421
+ [28] He, K., Zhang, X., Ren, S., and Sun, J. (2016). Deep Residual Learning for Image Recognition. In IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pages 1–9.
422
+ [29] Hong, J., Zhai, S., and Zhang, J. (2011). Discrete Gradient Approach to Stochastic Differential Equations with a Conserved Quantity. SIAM Journal on Numerical Analysis, 49(5):2017–2038.
423
+ [30] Izhikevich, E. M. and FitzHugh, R. (2006). FitzHugh-Nagumo model.
424
+ [31] Jin, P., Zhang, Z., Kevrekidis, I. G., and Karniadakis, G. E. (2020a). Learning Poisson systems and trajectories of autonomous systems via Poisson neural networks. pages 1–12.
425
+ [32] Jin, P., Zhu, A., Karniadakis, G. E., and Tang, Y. (2020b). Symplectic networks: Intrinsic structurepreserving networks for identifying Hamiltonian systems. Neural Networks, 132:166–179.
426
+ [33] Kingma, D. P. and Ba, J. (2015). Adam: A Method for Stochastic Optimization. In International Conference on Learning Representations (ICLR), pages 1–15.
427
+ [34] Lee, K. and Carlberg, K. (2021). Deep Conservation: A latent-dynamics model for exact satisfaction of physical conservation laws. In AAAI Conference on Artificial Intelligence (AAAI).
428
+ [35] Levin, A. U. and Narendra, K. S. (1995). Recursive identification using feedforward neural networks. International Journal of Control, 61(3):533–547.
429
+ [36] Loshchilov, I. and Hutter, F. (2017). SGDR: Stochastic gradient descent with warm restarts. In International Conference on Learning Representations (ICLR), pages 1–16.
430
+ [37] Manek, G. and Kolter, J. Z. (2019). Learning Stable Deep Dynamics Models. In Advances in Neural Information Processing Systems (NeurIPS), pages 1–9.
431
+ [38] Matsubara, T., Ishikawa, A., and Yaguchi, T. (2020). Deep Energy-Based Modeling of Discrete-Time Physics. In Advances in Neural Information Processing Systems (NeurIPS).
432
+ [39] Miura, R. M., Gardner, C. S., and Kruskal, M. D. (1968). Korteweg-de Vries equation and generalizations. II. Existence of conservation laws and constants of motion. Journal of Mathematical Physics, 9(8):1204–1209.
433
+ [40] Narendra, K. S. and Parthasarathy, K. (1990). Identification and Control of Dynamical Systems Using Neural Networks. IEEE Transactions on Neural Networks, 1(1):4–27.
434
+ [41] Nelles, O. (2001). Nonlinear System Identification. Springer Berlin Heidelberg, Berlin, Heidelberg.
435
+ [42] Paszke, A., Chanan, G., Lin, Z., Gross, S., Yang, E., Antiga, L., and Devito, Z. (2017). Automatic differentiation in PyTorch. In Autodiff Workshop on Advances in Neural Information Processing Systems, pages 1–4.
436
+
437
+ 446 [43] Potra, F. A. and Yen, J. (1991). Implicit numerical integration for euler-lagrange equations via tangent
438
+ 447 space parametrization. Mechanics of Structures and Machines, 19(1):77–98.
439
+ 448 [44] Quispel, G. R. and Capel, H. W. (1996). Solving ODEs numerically while preserving a first integral.
440
+ 449 Physics Letters, Section A: General, Atomic and Solid State Physics, 218(3-6):223–228.
441
+ 450 [45] Quispel, G. R. and Turner, G. S. (1996). Discrete gradient methods for solving ODEs numerically while
442
+ 451 preserving a first integral. Journal of Physics A: Mathematical and General, 29(13).
443
+ 452 [46] Raff, L., Komanduri, R., Hagan, M., and Bukkapatnam, S. (2012). Neural Networks in Chemical Reaction
444
+ 453 Dynamics.
445
+ 454 [47] Rasp, S., Dueben, P. D., Scher, S., Weyn, J. A., Mouatadid, S., and Thuerey, N. (2020). WeatherBench: A
446
+ 455 Benchmark Data Set for Data-Driven Weather Forecasting. Journal of Advances in Modeling Earth Systems,
447
+ 456 12(11).
448
+ 457 [48] Sannai, A., Imaizumi, M., and Kawano, M. (2021). Improved Generalization Bounds of Group Invariant
449
+ 458 / Equivariant Deep Networks via Quotient Feature Spaces. In Conference on Uncertainty in Artificial
450
+ 459 Intelligence (UAI).
451
+ 460 [49] Sjöberg, J., Hjalmarsson, H., and Ljung, L. (1994). Neural Networks in System Identification. IFAC
452
+ 461 Proceedings Volumes, 27(8):359–382.
453
+ 462 [50] Takeishi, N. and Kawahara, Y. (2020). Learning dynamics models with stable invariant sets. In AAAI
454
+ 463 Conference on Artificial Intelligence (AAAI).
455
+ 464 [51] Teshima, T., Tojo, K., Ikeda, M., Ishikawa, I., and Oono, K. (2020). Universal Approximation Property
456
+ 465 of Neural Ordinary Differential Equations. In NeurIPS Workshop on Differential Geometry meets Deep
457
+ 466 Learning (DiffGeo4DL).
458
+ 467 [52] Trigo, R. M. and Palutikof, J. P. (1999). Simulation of daily temperatures for climate change scenarios
459
+ 468 over Portugal: A neural network model approach. Climate Research, 13(1):45–59.
460
+ 469 [53] van der Schaft, A. and Jeltsema, D. (2014). Port-Hamiltonian Systems Theory: An Introductory Overview.
461
+ 470 Foundations and Trends® in Systems and Control, 1(2):173–378.
462
+ 471 [54] Vlachas, P. R., Pathak, J., Hunt, B. R., Sapsis, T. P., Girvan, M., Ott, E., and Koumoutsakos, P. (2020).
463
+ 472 Backpropagation algorithms and Reservoir Computing in Recurrent Neural Networks for the forecasting of
464
+ 473 complex spatiotemporal dynamics. Neural Networks, 126:191–217.
465
+ 474 [55] Wang, Y. J. and Lin, C. T. (1998). Runge-Kutta neural network for identification of dynamical systems in
466
+ 475 high accuracy. IEEE Transactions on Neural Networks, 9(2):294–307.
467
+ 476 [56] Zhong, G. and Marsden, J. E. (1988). Lie-Poisson Hamilton-Jacobi Theory and Lie-Poisson Integrators.
468
+ 477 Physics Letters A, 133(3):3–8.
469
+ 478 [57] Zhong, Y. D., Dey, B., and Chakraborty, A. (2020). Dissipative SymODEN: Encoding Hamiltonian
470
+ 479 Dynamics with Dissipation and Control into Deep Learning. arXiv, pages 1–6.
471
+
472
+ 1. For all authors...
473
+
474
+ (a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes] The theoretical contributions are summarized in Remarks 1 and 2. The performance improvements were validated numerically in Table 3 and visually in Figs. 1–6.
475
+ (b) Did you describe the limitations of your work? [Yes] We have discussed an increase in computational complexity at the bottoms of Sections 3.1 and 3.2. We also presented the limitations in Appendix D.2 while their situations were originally outside the scope of the proposed method.
476
+ (c) Did you discuss any potential negative societal impacts of your work? [N/A] No societal impact is supposed.
477
+ (d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [N/A] We have read the guidelines carefully, but no ethical impact is supposed.
478
+
479
+ 2. If you are including theoretical results...
480
+
481
+ (a) Did you state the full set of assumptions of all theoretical results? [Yes] We have introduced the background of the proposed method and provided the full set of assumptions in Section 2. Even though a slight modification may make the proposed method available on a general manifold, we have clearly stated that our theoretical and experimental results were limited to the finite-dimensional Eucleadian spaces.
482
+ (b) Did you include complete proofs of all theoretical results? [Yes] We have provided a proof just before each of Remarks 1 and 2.
483
+
484
+ 3. If you ran experiments...
485
+
486
+ (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 have enclosed the source code to reproduce all experiments in supplemental materials.
487
+ (b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes] We have provided the software and hardware environment, network architectures, and hyperparameters in Section 4.1. We have also provided detailed hyperparameters to generate datasets in Appendix C.
488
+ (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [Yes] We have summarized the standard deviations over five trials in Table 3.
489
+ (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 have provided the hardware environment in Section 4.1, but we have anonymized the cloud service providers to avoid a potential violation of the double-blind policy.
490
+
491
+ 4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
492
+
493
+ (a) If your work uses existing assets, did you cite the creators? [Yes] We have made the source code for all experiments by modifying the source codes of HNN [26] and DGNet [38]. We have cited these references and added links to respective repositories in the footnotes.
494
+ (b) Did you mention the license of the assets? [Yes] We have verified that the source codes of HNN [26] and DGNet [38] are provided in Apache-2.0 License and MIT License, respectively. We have clearly stated these facts in the footnotes.
495
+ (c) Did you include any new assets either in the supplemental material or as a URL? [Yes] We have enclosed the source code to generate datasets in supplemental materials.
496
+ (d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [N/A]
497
+ (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [N/A]
498
+
499
+ 5. If you used crowdsourcing or conducted research with human subjects...
500
+
501
+ (a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A]
502
+
503
+ 534 (b) Did you describe any potential participant risks, with links to Institutional Review
504
+ 535 Board (IRB) approvals, if applicable? [N/A]
505
+ 536 (c) Did you include the estimated hourly wage paid to participants and the total amount
506
+ 537 spent on participant compensation? [N/A]
md/dev/xMJWUKJnFSw/xMJWUKJnFSw.md ADDED
The diff for this file is too large to render. See raw diff
 
md/dev/xijYyYFlRIf/xijYyYFlRIf.md ADDED
@@ -0,0 +1,296 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # GAUDI: A Neural Architect for Immersive 3D Scene Generation
2
+
3
+ Miguel Angel Bautista⇤ Pengsheng Guo⇤ Samira Abnar Walter Talbott
4
+
5
+ # Alexander Toshev Zhuoyuan Chen Laurent Dinh Shuangfei Zhai Hanlin Goh
6
+
7
+ Daniel Ulbricht
8
+
9
+ Afshin Dehghan
10
+
11
+ Josh Susskind
12
+
13
+ Apple https://github.com/apple/ml-gaudi
14
+
15
+ # Abstract
16
+
17
+ We introduce GAUDI, a generative model capable of capturing the distribution of complex and realistic 3D scenes that can be rendered immersively from a moving camera. We tackle this challenging problem with a scalable yet powerful approach, where we first optimize a latent representation that disentangles radiance fields and camera poses. This latent representation is then used to learn a generative model that enables both unconditional and conditional generation of 3D scenes. Our model generalizes previous works that focus on single objects by removing the assumption that the camera pose distribution can be shared across samples. We show that GAUDI obtains state-of-the-art performance in the unconditional generative setting across multiple datasets and allows for conditional generation of 3D scenes given conditioning variables like sparse image observations or text that describes the scene.
18
+
19
+ # 1 Introduction
20
+
21
+ In order for learning systems to be able to understand and create 3D spaces, progress in generative models for 3D is sorely needed. The quote "The creation continues incessantly through the media of man." is often attributed to Antoni Gaudí, who we pay homage to with our method’s name. In this paper we ask the question: can creation continue through the media of learning machines? We are interested in generative models that can capture the distribution of 3D scenes and then render views from scenes sampled from the learned distribution. Extensions of such generative models to conditional inference problems could have tremendous impact in a wide range of tasks in machine learning and computer vision. For example, one could sample plausible scene completions that are consistent with an image observation, or a text description (see Fig. 1 for 3D scenes sampled from GAUDI). In addition, such models would be of great practical use in model-based reinforcement learning and planning [14], SLAM [43], or 3D content creation.
22
+
23
+ Recent works on generative modeling for 3D objects or scenes [60, 6, 8] employ a Generative Adversarial Network (GAN) where the generator explicitly encodes radiance fields — a parametric function that takes as input the coordinates of a point in 3D space and camera pose, and outputs a density scalar and RGB value for that 3D point. Images can be rendered from the radiance field generated by the model by passing the queried 3D points through the volume rendering equation to project onto any 2D camera view. While compelling on small or simple 3D datasets (e.g. single objects or a small number of indoor scenes), GANs suffer from training pathologies including mode collapse $\pm \pm \pm \pm \pm \pm \pm \pm \pm$ and are difficult to train on data for which a canonical coordinate system does not exist, as is the case for 3D scenes $\left[ \left[ 6 1 \right] \right]$ . In addition, one key difference between modeling distributions of 3D objects vs. scenes is that when modeling objects, the distribution of valid camera poses does not depend on each object and is defined per dataset (i.e. typically as $S O ( 3 )$ ), which is not true for scenes. See Fig. $\bar { \bigtriangledown ( \mathfrak { b } ) }$ and note how the two scene layouts define different areas of navigable space (different dark grey shaded areas) where valid camera poses can be placed, revealing a strong dependency between scenes and their camera pose distributions. GAUDI captures this dependency by modeling the joint distribution of scenes and camera poses.
24
+
25
+ ![](images/817e9e0b07bda48800f0017cb652036d1cffe99dbb4fab43512b87d33c1bfd6f.jpg)
26
+ Figure 1: GAUDI allows to model both conditional and unconditional distributions over complex 3D scenes. Sampled scenes and poses from (left) the unconditional distribution, and (right) a distribution conditioned on an image observation or a text prompt.
27
+
28
+ In GAUDI, we map each trajectory (i.e. a sequence of posed images from a 3D scene) into a latent representation that encodes a radiance field (e.g. the 3D scene) and camera path in a completely disentangled way. We find these latent representations by interpreting them as free parameters and formulating an optimization problem where the latent representation for each trajectory is optimized via a reconstruction objective. This simple training process is scalable to thousands of trajectories. Interpreting the latent representation of each trajectory as a free parameter also makes it simple to handle a large and variable number of views for each trajectory rather than requiring a sophisticated encoder architecture to pool across a large number of views. After optimizing latent representations for an observed empirical distribution of trajectories, we learn a generative model over the set of latent representations. In the unconditional case, the model can sample radiance fields entirely from the prior distribution learned by the model, allowing it to synthesize scenes by interpolating within the latent space. In the conditional case, conditional variables available to the model at training time (e.g. images, text prompts, etc.) can be used to generate radiance fields consistent with those variables. Our contributions can be summarized as:
29
+
30
+ We scale 3D scene generation to thousands of indoor scenes containing hundreds of thousands of images, without suffering from mode collapse or canonical orientation issues during training.
31
+
32
+ • We introduce a novel denoising optimization objective to find latent representations that jointly model a radiance field and the camera poses in a disentangled manner.
33
+
34
+ • Our approach obtains state-of-the-art generation performance across multiple datasets.
35
+
36
+ • Our approach allows for various generative setups: unconditional generation as well as conditional on images or text.
37
+
38
+ # 2 Related Work
39
+
40
+ In recent years the field has witnessed outstanding progress in generative modeling for the 2D image domain, with most approaches focusing either on adversarial $\mathbb { \left[ \left[ 2 1 \right] , \left[ 2 2 \right] \right] }$ or auto-regressive models [69, 46, 11]. More recently, score matching based approaches [18, 62] have gained popularity. In particular, Denoising Diffusion Probabilistic Models (DDPMs) [ $\boxed { 1 7 } \boxed { 3 7 } \boxed { 5 2 } \boxed { 6 8 }$ have emerged as strong contenders to both adversarial and auto-regressive approaches. In DDPMs, the goal is to learn a step-by-step inversion of a fixed diffusion Markov Chain that gradually transforms an empirical data distribution to a fixed posterior, which typically takes the form of an isotropic Gaussian distribution. In parallel, the last couple of years have seen a revolution in how 3D data is represented within neural networks. By representing a 3D scene as a radiance field, NeRF $[ \left| 3 3 \right| ]$ introduces an approach to optimize the weights of a MLP to represent the radiance of 3D points that fall inside the field-of-view of a given set of posed RGB images. Given the radiance for a set of 3D points that lie on a ray shot from a given camera pose, NeRF $\mathbb { B } 3 \mathbb { I }$ uses volumetric rendering to compute the color for the corresponding pixel and optimizes the MLP weights via a reconstruction loss in image space.
41
+
42
+ A few attempts have also been made at incorporating a radiance field representation within generative models. Most approaches have focused on the problem of single objects with known canonical orientations like faces or Shapenet objects with shared camera pose distributions across samples in a dataset [60, 6, 38, 25, 5, 12, 75, 47, 10]. Extending these approaches from single objects to completely unconstrained 3D scenes is an unsolved problem. One paper worth mentioning in this space is GSN $\textcircled { 8 }$ , which breaks the radiance field into a grid of local radiance fields that collectively represent a scene. While this decomposition of radiance fields endows the model with high representational capacity, GSN still suffers from the standard training pathologies of GANs, like mode collapse $\mathbb { \lVert \rVert }$ , which are exacerbated by the fact that unconstrained 3D scenes do not have a canonical orientation. As we show in our experiments (cf. Sect. 4), these issues become prominent as the training set size increases, impacting the capacity of the generative model to capture complex distributions. Separately, a line of recent approaches have also studied the problem of learning generative models of scenes without employing radiance fields [40, 70, 51]. These works assume that the model has access to room layouts and a database of object CAD models during training, simplifying the problem of scene generation to a selection of objects from the database and pose predictions for each object.
43
+
44
+ Finally, approaches that learn to predict a target view given a single (or multiple) source view and relative pose transformation have been recently proposed [27, 74, 57, 9, 13]. The pure reconstruction objective employed by these approaches forces them to learn a deterministic conditional function that maps a source image and a relative camera transformation to a target image. The first is that this scene completion problem is ill-posed (e.g. given a single source view of a scene there are multiple target completions that are equally likely). Attempts at modeling the problem in a probabilistic manner have been proposed $\underline { { \lVert 5 3 \rVert } } , \boxed { 4 9 }$ . However, these approaches suffer from inconsistency in predicted scenes because they do not explicitly model a 3D consistent representation like a radiance field.
45
+
46
+ # 3 GAUDI
47
+
48
+ Our goal is to learn a generative model given an empirical distribution of trajectories over 3D scenes. Let $X = \{ x _ { i \in \{ 0 , . . . , n \} } \}$ denote a collection of examples defining an empirical distribution, where each example $x _ { i }$ is a trajectory. Every trajectory $x _ { i }$ is defined as a variable length sequence of corresponding RGB, depth images and 6DOF camera poses (see Fig. 3).
49
+
50
+ We decompose the task of learning a generative model in two stages. First, we obtain a latent representation $\mathbf { z } = [ \mathbf { z } _ { \mathrm { s c e n e } } , \mathbf { z } _ { \mathrm { p o s e } } ]$ for each example $x \in X$ that represents the scene radiance field and pose in separate disentangled vectors. Second, given a set of latents $Z = \{ \mathbf { z } _ { i \in \{ 0 , \dots , n \} } \}$ we learn the distribution $p ( Z )$ .
51
+
52
+ # 3.1 Optimizing latent representations for radiance fields and camera poses
53
+
54
+ We now turn to the task of finding a latent representation $\mathbf { z } \in Z$ for each example $x \in X$ (i.e. for each trajectory in the empirical distribution). To obtain this latent representation we take an encoder-less view and interpret $\mathbf { z }$ ’s as free parameters to be found via an optimization problem $\mathbb { D } \mathbb { B }$ . To map latents $\mathbf { z }$ to trajectories $x$ , we design a network architecture (i.e. a decoder) that disentangles camera poses and radiance field parameterization. Our decoder architecture is composed of 3 networks (shown in Fig. 2):
55
+
56
+ • The camera pose decoder network $c$ (parameterized by $\theta _ { c . }$ ), is responsible for predicting camera poses $\hat { \mathbf { T } } _ { s } \in S E ( 3 )$ at the normalized temporal position $s \in [ - 1 , 1 ]$ in the trajectory, conditioned on $\mathbf { z } _ { \mathrm { p o s e } }$ which represents the camera poses for the whole trajectory. To ensure that the output of $c$ is a valid camera pose (e.g. an element of $S E ( 3 )$ ), we output a 3D vector representing a normalized quaternion $\mathbf { q } _ { s }$ for the orientation and a 3D translation vector $\mathbf { t } _ { s }$ .
57
+
58
+ ![](images/e4bad21ddfcad7a7125072fe03e7aa0257fb5650fce1690227c0a92664eaf018.jpg)
59
+ Figure 2: Architecture of the decoder model that disentangles camera poses from 3D geometry and appearance of the scene. Our decoder is composed by 3 submodules. A decoder $d$ that takes as input a latent code representing the scene $\mathbf { z } _ { \mathrm { s c e n e } }$ and produces a factorized representation of 3D space via a tri-plane latent encoding $\mathbf { W }$ . A radiance field network $f$ that takes as input points $ { \mathbf { p } } \in { \mathbf { R } } ^ { 3 }$ and is conditioned on W to predict a density $\sigma$ and a signal a to be rendered via volumetric rendering (Eq. 1). Finally, we decode the camera poses through a network $c$ that takes as input a normalized temporal position $s \in [ - 1 , 1 ]$ and is conditioned on $\mathbf { z } _ { \mathrm { p o s e } }$ which represents camera poses for the whole trajectory $x$ to predict the camera pose $\hat { \mathbf { T } } _ { s } \in S E ( 3 )$ .
60
+
61
+ • The scene decoder network $d$ (parameterized by $\theta _ { d }$ ), is responsible for predicting a conditioning variable for the radiance field network $f$ . This network takes as input a latent code that represents the scene $\mathbf { z } _ { \mathrm { s c e n e } }$ and predicts an axis-aligned tri-plane representation $[ \mathbb { A } 1 ] , \bigstar ]$ $\mathbf { W } \in \mathbb { R } ^ { 3 \times S \times S ^ { \star } \times F }$ . Which correspond to 3 feature maps $[ \mathbf { W } _ { x y } , \mathbf { \bar { W } } _ { x z } , \mathbf { \bar { W } } _ { y z } ]$ of spatial dimension $S \times S$ and $F$ channels, one for each axis aligned plane: $x y$ , $x z$ and $y z$ .
62
+
63
+ • The radiance field decoder network $f$ (parameterized by $\theta _ { f }$ ), is tasked with reconstructing image level targets using the volumetric rendering equation in Eq. $^ { 1 }$ . The input to $f$ is $ { \mathbf { p } } \in \mathbb { R } ^ { 3 }$ and the tri-plane representation $\mathbf { W } = [ \mathbf { W } _ { x y } , \mathbf { W } _ { x z } , \mathbf { \bar { W } } _ { y z } ]$ (we do not condition on the camera orientation to improve consistency $\pmb { \mathbb { I } } \mathbf { \varOmega }$ ). Given a 3D point $\overset { \circ } { \mathbf { p } } = [ i , j , k ]$ for which radiance is to be predicted, we orthogonally project $\mathbf { p }$ into each plane in W and perform bi-linear sampling. We concatenate the 3 bi-linearly sampled vectors into $\mathbf { \bar { w } } _ { x y z } = [ \mathbf { W } _ { x y } ( i , j ) , \mathbf { W } _ { x z } ( j , k ) , \mathbf { W } _ { y z } ( i , k ) ] \in \mathbb { R } ^ { 3 F }$ , which is used to condition the radiance field function $f$ . We implement $f$ as a MLP that outputs a density value $\sigma$ and a signal a. To predict the value $\mathbf { v }$ of a pixel, the volumetric rendering equation is used (cf. Eq. 1) where a 3D point is expressed as ray direction $\mathbf { r }$ (corresponding with the pixel location) at particular depth $u$ .
64
+
65
+ $$
66
+ \begin{array} { r l r } & { } & { { \bf v } ( { \bf r } , { \bf W } ) = \int _ { u _ { n } } ^ { u _ { f } } T r ( u ) \sigma \left( { \bf r } ( u ) , { \bf w } _ { x y z } \right) { \bf a } \left( { \bf r } ( u ) , { \bf w } _ { x y z } \right) d u } \\ & { } & { T r ( u ) = \exp \left( - \int _ { u _ { n } } ^ { u } \sigma ( { \bf r } ( u ) , { \bf w } _ { x y z } ) d u \right) . } \end{array}
67
+ $$
68
+
69
+ We formulate a reconstruction objective to jointly optimize for $\theta _ { d } , \theta _ { c } , \theta _ { f }$ and $\{ \mathbf { z } \} _ { i = \{ 0 , \ldots , n \} }$ , shown in Eq. 2. Note that while latents $\mathbf { z }$ are optimized for each example $x$ independently, the parameters of the networks $\theta _ { d } , \theta _ { c } , \theta _ { f }$ are amortized across all examples $x \in X$ . As opposed to previous auto-decoding approaches $\textcircled { 1 2 } , \textcircled { 3 9 } \textcircled { 1 }$ , each latent $\mathbf { z }$ is perturbed during training with additive noise that is proportional to the empirical standard deviation across all latents, $\mathbf { z } = \mathbf { z } + \beta \mathcal { N } ( 0 , \mathrm { s t d } ( Z ) )$ , inducing a contractive representation $\left[ \left[ 5 0 \right] \right]$ . In this setting, $\beta$ controls the trade-off between the entropy of the distribution of latents $\mathbf { z } \in Z$ and the reconstruction quality. With $\beta = 0$ the distribution of $\mathbf { z }$ ’s becomes a set of indicator functions (i.e. similar as one would get from a vanilla auto-encoder). For large $\beta > 0$ the structure in distribution of $\mathbf { z }$ ’s is destroyed, as latents are perturbed with large magnitudes of noise. We use a small $\beta > 0$ value to enforce a latent space in which interpolated samples (or samples that contain small deviations from the empirical distribution, as the ones that one might get from sampling a subsequent generative model) are included in the support of the decoder function, sacrificing a small cost in reconstruction fidelity.
70
+
71
+ $$
72
+ \operatorname* { m i n } _ { \theta _ { d } , \theta _ { f } , \theta _ { c } , Z } \mathbb { E } _ { x \sim X } \left[ \mathcal { L } _ { \mathrm { s c e n e } } ( \mathbf { x } _ { s } ^ { \mathrm { i m } } , \mathbf { z } _ { \mathrm { s c e n e } } , \mathbf { T } _ { s } ) + \lambda \mathcal { L } _ { \mathrm { p o s e } } ( \mathbf { T } _ { s } , \mathbf { z } _ { \mathrm { p o s e } } , s ) \right]
73
+ $$
74
+
75
+ We optimize parameters $\theta _ { d } , \theta _ { f } , \theta _ { c }$ and latents $\mathbf { z } \in Z$ with two different losses. The first loss function $\mathcal { L } _ { \mathrm { s c e n e } }$ measures the reconstruction between the radiance field encoded in $\mathbf { z } _ { \mathrm { s c e n e } }$ and the images in the trajectory $\mathbf { x } _ { s } ^ { \mathrm { { i m } } }$ (where $s$ denotes the normalized temporal position of the frame in the trajectory), given ground-truth camera poses $\mathbf { T } _ { s }$ required for rendering. We use an $l _ { 2 }$ loss for RGB and $l _ { 1 }$ for depth 1. The second loss function $\mathcal { L } _ { \mathrm { p o s e } }$ measures the camera pose reconstruction error between the poses $\hat { \mathbf { T } } _ { s }$ encoded in $\mathbf { z } _ { \mathrm { p o s e } }$ and the ground-truth poses. We employ an $l _ { 2 }$ loss on translation and $l _ { 1 }$ loss for the normalized quaternion part of the camera pose. Although theoretically normalized quaternions are not necessarily unique (e.g. q and $- \mathbf { q } )$ we do not observe any issues empirically during training.
76
+
77
+ # 3.2 Prior Learning
78
+
79
+ Given a set of latents $\mathbf { z } \in Z$ resulting from minimizing the objective in Eq. $2 ,$ our goal is to learn a generative model $p ( Z )$ that captures their distribution (i.e. after minimizing the objective in Eq. $2$ we interpret $\mathbf { z } \in Z$ as examples from an empirical distribution in latent space). In order to model $p ( Z )$ we employ a Denoising Diffusion Probabilistic Model (DDPM) [17], a recent score-matching $[ \overline { { 1 8 } } ]$ based model that learns to reverse a diffusion Markov Chain with a large but finite number of timesteps. In DDPMs $\mathbb { \lVert 1 7 \rVert }$ it is shown that this reverse process is equivalent to learning a sequence of denoising auto-encoders with tied weights. The supervised denoising objective in DDPMs makes learning $p ( Z )$ simple and scalable. This allows us to learn a powerful generative model that enables both unconditional and conditional generation of 3D scenes. For training our prior $p _ { \theta _ { p } } ( Z )$ we take the objective function in $ { \mathbb { I } } ^ { [ 1 2 ] }$ defined in Eq. $\textcircled { 3 }$ In Eq. $\sum t$ denotes the timestep, $\epsilon \sim \mathcal { N } ( 0 , \mathbf { I } )$ is the noise and $\bar { \alpha } _ { t }$ is a noise magnitude parameter with a fixed scheduling. Finally, $\epsilon _ { \theta _ { p } }$ denotes the denoising model.
80
+
81
+ $$
82
+ \operatorname* { m i n } _ { \theta _ { p } } \mathbb { E } _ { t , \mathbf { z } \sim Z , \epsilon \sim \mathcal { N } ( 0 , \mathbf { I } ) } \left[ \| \epsilon - \epsilon _ { \theta _ { p } } \big ( \sqrt { \bar { \alpha } _ { t } } \mathbf { z } + \sqrt { 1 - \bar { \alpha } _ { t } } \epsilon , t \big ) \| ^ { 2 } \right]
83
+ $$
84
+
85
+ At inference time, we sample $\mathbf { z } \sim p _ { \theta _ { p } } ( Z )$ by following the inference process in DDPMs. We start by sampling $\mathbf { z } _ { T } \sim \mathcal { N } ( 0 , \mathbf { I } )$ and iteratively apply $\epsilon _ { \theta _ { p } }$ to gradually denoise $\mathbf { z } _ { T }$ , thus reversing the diffusion Markov Chain to obtain $\mathbf { z } _ { 0 }$ . We then feed $\mathbf { z } _ { 0 }$ as input to the decoder architecture (cf. Fig. $2 )$ and reconstruct a radiance field and a camera path.
86
+
87
+ If the goal is to learn a conditional distribution of the latents $p ( Z | Y )$ , given paired data $\{ \mathbf { z } \in Z , y \in$ $Y \}$ , the denoising model $\epsilon _ { \theta }$ is augmented with a conditioning variable $y$ , resulting in $\epsilon _ { \theta _ { p } } ( \mathbf { z } , t , y )$ , implementation details about how the conditioning variable is used in the denoising architecture can be found in the appendix C.
88
+
89
+ # 4 Experiments
90
+
91
+ In this section we show the applicability of GAUDI to multiple problems. First, we evaluate reconstruction quality and performance of the reconstruction stage. Then, we evaluate the performance of our model in generative tasks including unconditional and conditional inference, in which radiance fields are generated from conditioning variables corresponding to images or text prompts. Full experimental settings and details can be found in the appendix B
92
+
93
+ # 4.1 Data
94
+
95
+ We report results on 4 datasets: Vizdoom $\mathbb { \left| \left[ 2 . 3 \right] \right| }$ , Replica [64], VLN-CE [26] and ARKit Scenes [1], which vary in number of scenes and complexity (see Fig. 3 and Tab. 1).
96
+
97
+ Vizdoom $\pmb { \mathbb { Z } 3 } \|$ : Vizdoom is a synthetic simulated environment with simple texture and geometry. We use the data provided by $\pmb { \mathbb { B } } ] \mathbf { l }$ to train our model. It is the simplest dataset in terms of number of scenes and trajectories, as well as texture, serving as a test bed to examine GAUDI in the simplest setting.
98
+
99
+ Replica $\pmb { \mathbb { \lVert 6 4 \rVert } }$ : Replica is a dataset comprised of 18 realistic scenes from which trajectories are rendered via Habitat $\mathbb { \boldsymbol { 9 } }$ . We used the data provided by $\textcircled { 8 }$ to train our model.
100
+
101
+ VLN-CE $\left[ \left[ 2 6 \right] \right]$ : VLN-CE is a dataset originally designed for vision and language navigation in continuous environments. This dataset is composed of 3.6K trajectories of an agent navigating between two points in a 3D scene from the Matterport 3D dataset $\mathbb { H }$ . We render observations via
102
+
103
+ ![](images/7097bcaa55df2e214b67e47ccadd3bb523e55c7c711e34fc104dfcb75226e874.jpg)
104
+ Figure 3: (a) Examples of the 4 datasets we use in this paper (from left to right): Vizdoom $[ [ 2 3 ] ]$ , Replica $\pmb { \| 6 4 \| }$ , VLN-CE $\left[ \left[ 2 6 \right] \right]$ , ARKitScenes [1]. (b) Layouts for two scenes in VLN-CE $\pmb { \Vert 2 6 \Vert }$ , where navigable areas are shaded in dark gray. Blue and red dots represent start-end positions and the camera path is highlighted in blue.
105
+
106
+ Habitat $\mathbb { \left[ \left. 5 9 \right. \right. }$ . Notably, this dataset contains also textual descriptions of the trajectories taken by an agent. In Sect. 4.5 we train GAUDI in a conditional manner to generate 3D scenes given a description.
107
+
108
+ ARKitScenes [1]: ARKitScenes is a dataset of scans of indoor spaces. This dataset contains more than 5K scans of about 1.6K different indoor spaces. As opposed to the previous datasets where RGB, depth and camera poses are obtained via rendering in a simulation (i.e. either Vizdoom $\mathbb { \left[ \left. 2 3 \right] \right. }$ or Habitat [59]), ARKitScenes provides raw RGB and depth of the scans and camera poses estimated using ARKit SLAM. In addition, whereas trajectories from the previous datasets are point-to-point, as typically done in navigation, the camera trajectories for ARKitScenes resembles a natural scan a of full indoor space. In our experiments we use a subset of 1K scans from ARKitScenes to train our models.
109
+
110
+ # 4.2 Reconstruction
111
+
112
+ We first validate the hypothesis that the optimization problem described in Eq. $2$ can find latent codes $\mathbf { z }$ that are able reconstruct the trajectories in the empirical distribution in a satisfactory way. In Tab. 1 we report reconstruction performance of our model across all datasets. Fig. $\sharp$ shows reconstructions of random trajectories for each dataset. For all our experiments we set the dimension of $\mathbf { z } _ { \mathrm { s c e n e } }$ and $\mathbf { z } _ { \mathrm { p o s e } }$ to 2048 and $\beta = 0 . 1$ unless otherwise stated. During training, we normalize camera poses for each trajectory so that the middle frame in a trajectory becomes the origin of the coordinate system. See appendix $\boxed { \ E }$ for ablation experiments.
113
+
114
+ ![](images/2a55d72050e7abf5dc63fe3d29bdd1e15b96487d65ea03ab1a1bcf5616c9bcc1.jpg)
115
+ Figure 4: Qualitative reconstruction results of random trajectories on different datasets (one for each column): Vizdoom $\pmb { \left. \pmb { \left. \bar { 2 3 } \right. } \right. }$ , Replica $\pmb { \mathbb { \lVert 6 4 \rVert } }$ , VLN-CE $\left[ \left[ 2 6 \right] \right]$ and ARKitScenes [1]. For each pair of images the left is ground-truth and right is reconstruction.
116
+
117
+ <table><tr><td></td><td>#sc-#tr-#im</td><td>11↓</td><td>PSNR↑</td><td>SSIM个</td><td>Rot Err. ↓</td><td>Trans. Err ↓</td></tr><tr><td>Vizdoom 2</td><td>1-32-1k</td><td>0.004</td><td>44.42</td><td>0.98</td><td>0.01</td><td>1.26</td></tr><tr><td>Replica √</td><td>18-100-1k</td><td>0.006</td><td>38.86</td><td>0.99</td><td>0.03</td><td>0.01</td></tr><tr><td>VLN-CE [26</td><td>90-3.6k-600k</td><td>0.031</td><td>25.17</td><td>0.73</td><td>0.30</td><td>0.02</td></tr><tr><td>ARKitScenes</td><td>300-1k-600k</td><td>0.039</td><td>24.51</td><td>0.76</td><td>0.16</td><td>0.04</td></tr></table>
118
+
119
+ Table 1: Reconstruction results of the optimization process described in Eq. 2. The first column shows the number of scenes (#sc), trajectories (#tr) and images (#im) per dataset. Due to the large number of images on VLN-CE $\mathbb { \left[ \left[ 2 6 \right] \right] }$ and ARKitScenes $\mathbb { I I }$ datasets we sample 10 random images per trajectory to compute the reconstruction metrics.
120
+
121
+ # 4.3 Interpolation
122
+
123
+ In addition, to evaluate the structure of the latent representation obtained from minimizing the optimization problem in Eq. $\bigstar ,$ we show interpolation results between pairs of latents $( \mathbf { z } _ { i } , \mathbf { z } _ { j } )$ in
124
+
125
+ ![](images/6cddcf51ce96aa1d9d58ca018cda77b4d7a30a8b1859865add9ed9c19a2902b3.jpg)
126
+ Fig. $\boxed { 5 }$ To render images while interpolating the scene we place a fixed camera at the origin of the coordinate system. We observe a smooth transition of scenes in both geometry (walls, ceilings) and texture (stairs, carpets). More visualizations are included in the appendix H.
127
+ Figure 5: Interpolation of 3D scenes in latent space (e.g. interpolating the encoded radiance field) for the VLN-CE dataset $\pmb { \mathbb { Z } } 6 \|$ . Each row corresponds to a different interpolation path.
128
+
129
+ # 4.4 Unconditional generative modeling
130
+
131
+ Given latent representations $\textbf { z } \in \ Z$ that can reconstruct samples $x \in X$ with high accuracy as shown in Sect. $\boxed { 4 . 2 }$ we now evaluate the capacity of the prior $p _ { \theta _ { p } } ( Z )$ to capture the empirical distribution $x \in \mathcal { X }$ by learning the distribution of latents $\mathbf { z } _ { i } \in Z$ . To do so we sample $\mathbf { z } \sim p _ { \theta _ { p } } ( Z )$ by following the inference process in DDPMs, and then feed $\mathbf { z }$ through the decoder network, which results in trajectories of RGB images that are then used for evaluation. We compare our approach with the following baselines: GRAF $\pmb { \| 6 0 \| }$ , $\pi$ -GAN $\pmb { \mathbb { H } }$ and GSN $\textcircled { 8 }$ , where all models have access to ground-truth depth information during training. We sample 5k images from predicted and target distributions for each model and dataset and report both FID $\mathbb { \left[ \left[ 1 6 \right] \right] }$ and SwAV-FID $\begin{array} { r l } { { \bigl [ \bigl | 3 5 \bigr | \bigr ] } } \end{array}$ scores. We report quantitative results in Tab. $^ { 2 , }$ where we can see that GAUDI obtains state-of-the-art performance across all datasets and metrics. We attribute this performance improvement to the fact that GAUDI learns disentangled yet corresponding latents for radiance fields and camera poses, which is key when modeling scenes (see ablations in the appendix $\mathbf { E } )$ . We note that to obtain these great empirical results GAUDI needs to simultaneously find latents with high reconstruction fidelity while also efficiently learning their distribution.
132
+
133
+ <table><tr><td rowspan="2"></td><td colspan="2">VizDoom 因</td><td colspan="2">Replica 国</td><td colspan="2">VLN-CE 回</td><td colspan="2">ARKitScenes</td></tr><tr><td>FID↓</td><td>SwAV-FID↓</td><td>FID↓</td><td>SwAV-FID↓</td><td>FID↓</td><td>SwAV-FID↓</td><td>FID↓</td><td>SwAV-FID↓</td></tr><tr><td>GRAF60</td><td>47.50 ± 2.13</td><td>5.44 ± 0.43</td><td>65.37 ± 1.64</td><td>5.76 ± 0.14</td><td>90.43±4.83</td><td>8.65±0.27</td><td>87.06±9.99</td><td>13.44±0.26</td></tr><tr><td>π-GAN</td><td>143.55 ± 4.81</td><td>15.26 ±0.15</td><td>166.55 ± 3.61</td><td>13.17 ±0.20</td><td>151.26 ± 4.19674 14.07 ±0.56</td><td></td><td>134.80±10.60</td><td>15.58 ±0.13</td></tr><tr><td>GSN</td><td>37.21 ± 1.17</td><td>4.56±0.19</td><td>41.75 ±1.33</td><td>4.14±0.02</td><td>43.32 ±8.86</td><td>6.19±0.49</td><td>79.54 ± 2.60</td><td>10.21 ± 0.15</td></tr><tr><td>GAUDI</td><td>33.70±1.27</td><td>3.24±0.12</td><td>18.75±0.63</td><td>1.76 ±0.05</td><td>18.52 ±0.11</td><td>3.63±0.65</td><td>37.35 ±0.38</td><td>4.14±0.03</td></tr></table>
134
+
135
+ Table 2: Generative performance of state-of-the-art approaches for generative modelling of radiance fields on 4 scene datasets: Vizdoom $\mathbb { \left[ \left. 2 3 \right\| \right. }$ , Replica $\textcircled { 6 4 } \textcircled { 1 6 }$ , VLN-CE $\dot { \left\| 2 6 \right\| }$ and ARKitScenes [1], according to FID [16] and SwAV-FID $\pmb { \Vert 3 5 \Vert }$ metrics.
136
+
137
+ In Fig. $\boxed { 6 }$ we show samples from the unconditional distribution learnt by GAUDI for different datasets. We observe that GAUDI is able to generate diverse and realistic 3D scenes from the empirical distribution which can be rendered from the sampled camera poses.
138
+
139
+ # 4.5 Conditional Generative Modeling
140
+
141
+ GAUDI can also tackle conditional generative problems of the form $p ( Z | Y )$ , where a conditioning variable $y \in Y$ is given to condition $p ( Z )$ . For a given conditional inference problem we assume the existence of paired data [46, 11, 45]. As an example, for training a text-conditional model we assume the existence of pairs $\left\{ \mathbf { z } _ { i } , y _ { i } \right\}$ , where $\mathbf { z } _ { i }$ is a latent scene representation and $y _ { i }$ is its corresponding text prompt. In this section we show both quantitative and qualitative results for conditional inference problems. The first conditioning variable we consider are textual descriptions of trajectories. Second, we consider a model where randomly sampled RGB images in a trajectory act as conditioning. Finally, we use a categorical variable that indicates the 3D environment (i.e. the particular indoor space) from which each trajectory was obtained. Tab. $3$ shows quantitative results for the different conditional inference problems. Details on the implementation of the conditional DDPM are given in Sect. D
142
+
143
+ ![](images/824f78214958dbf2b3c9b035017c70eb707ec7077e5001af194aaa5e4f2fdd8b.jpg)
144
+
145
+ <table><tr><td>Avg.△Per-Environment</td><td></td></tr><tr><td>FID↓</td><td>SwAV-FID↓</td></tr><tr><td>-50.79</td><td>-4.10</td></tr></table>
146
+
147
+ Table 3: Quantitative results of Conditional Generative Modeling on VLN-CE [26] dataset. GAUDI is able to produce high-quality scene renderings with low FID and SwAV-FID scores. In the right table we show the difference in average per-environment FID score between the conditional and unconditional models.
148
+
149
+ <table><tr><td colspan="2">Text Conditioning</td><td colspan="2">Image Conditioning</td><td colspan="2">Categorical Conditioning</td></tr><tr><td>FID↓</td><td>SwAV-FID↓</td><td>FID↓</td><td>SwAV-FID↓</td><td>FID↓</td><td>SwAV-FID↓</td></tr><tr><td>18.50</td><td>3.75</td><td>19.51</td><td>3.93</td><td>18.74</td><td>3.61</td></tr></table>
150
+
151
+ # 4.5.1 Text Conditioning
152
+
153
+ We tackle the challenging task of training a text conditional model for 3D scene generation. We use the navigation text descriptions provided in VLN-CE $\left[ \left[ 2 6 \right] \right]$ to condition our model. These text descriptions contain high level information about the scene as well as the navigation path (i.e. "Walk out of the bedroom and into the living room", "Exit the room through the swinging doors and then enter the bedroom"). We employ a pre-trained RoBERTa-base $\dot { \left\| 2 9 \right\| }$ text encoder and use its intermediate representation to condition the diffusion model. Fig. $^ { 7 }$ shows qualitative results of GAUDI for this task. To the best of our knowledge, this is the first model that allows for conditional 3D scene generation from text in an amortized manner (i.e. without distilling CLIP $\mathbb { \lVert H \ 4 \rVert }$ through a costly optimization problem [19, 32]).
154
+
155
+ ![](images/6a315b5a6d145501104248636bd4e02075a4f7ce8251740624ef11afacfcd0e1.jpg)
156
+ Figure 7: Text conditional 3D scene generation using GAUDI (one sample per row). Our model is able to capture the conditional distributions of scenes by generating multiple plausible scenes and camera paths that match the given text prompts.
157
+
158
+ # 4.5.2 Image Conditioning
159
+
160
+ We now analyze whether GAUDI is able to pick up information from the RGB images to predict a distribution over $Z$ . In this experiment we randomly pick images in a trajectory $x \in X$ and use it as a conditioning variable $y$ . For this experiment we use trajectories in the VLN-CE dataset $\pmb { \left. 2 6 \right. }$ . During each training iteration we sample a random image for each trajectory $x$ and use it as a conditioning variable. We employ a pre-trained ResNet-18 [15] as an image encoder. During inference, the resulting conditional GAUDI model is able to sample radiance fields where the given image is observed from a stochastic viewpoint. In Fig. $\textcircled { 8 }$ we show samples from the model conditioned on different RGB images.
161
+
162
+ ![](images/1bff990965fcbaf030c03ad42819efa0570a7bd8ebecadef306163172b4e5182.jpg)
163
+ Figure 8: Image conditional 3D scene generation using GAUDI (one sample per row). Given a conditioned image (top row), our model is able to sample scenes where the same or contextually similar view is observed from a stochastic viewpoint.
164
+
165
+ ![](images/c2a11d158e4378324735e7e1ea88f9415e6b1d9a49b5ed5bd6e2557b410a5e3c.jpg)
166
+ Figure 9: Samples from the GAUDI model conditioned on a categorical variable denoting the indoor scene (one sample per row).
167
+
168
+ # 4.5.3 Categorical Conditioning
169
+
170
+ Finally, we analyze how GAUDI performs when conditioned on a categorical variable that indicates the underlying 3D indoor environment in which each trajectory was recorded. We perform experiments in the VLN-CE $[ \overline { { 2 6 } } ]$ dataset, where we employ a trainable embedding layer to learn a representation for categorical variables indicating each environment. We compare the per-environment FID score of conditional model with its unconditional counterpart. This per-enviroment FID score is computed only on real images of the same indoor environment that the model is conditioned on. Our hypothesis is that if the model efficiently captures the information in the conditioning variable it should capture the environment specific distribution better than its unconditional counterpart trained on the same data. In Tab. $\textcircled { 3 }$ the last column shows difference (e.g. the $\Delta$ ) on the average per-environment FID score between the conditional and unconditional model on VLN-CE dataset. We observe that the conditional model consistently obtains a better FID score than the unconditional model across all indoor environments, resulting in a sharp reduction of average FID and SwAV-FID scores. In addition, in Fig. 9 we show samples from the model conditioned on a given categorical variable.
171
+
172
+ # 5 Conclusion
173
+
174
+ We have introduced GAUDI, a generative model that captures distributions of complex and realistic 3D scenes. GAUDI uses a scalable two-stage approach which first involves learning a latent representation that disentangles radiance fields and camera poses. The distribution of disentangled latent representations is then modeled with a powerful prior. Our model obtains state-of-the-art performance when compared with recent baselines across multiple 3D datasets and metrics. GAUDI can be used both for conditional and unconditional problems, and enabling new tasks like generating 3D scenes from text descriptions.
175
+
176
+ # References
177
+
178
+ [1] Gilad Baruch, Zhuoyuan Chen, Afshin Dehghan, Yuri Feigin, Peter Fu, Thomas Gebauer, Daniel Kurz, Tal Dimry, Brandon Joffe, Arik Schwartz, et al. Arkitscenes: A diverse real-world dataset for 3d indoor scene understanding using mobile rgb-d data. In Thirty-fifth Conference on Neural Information Processing Systems Datasets and Benchmarks Track (Round 1), 2021.
179
+ [2] Piotr Bojanowski, Armand Joulin, David Lopez-Paz, and Arthur Szlam. Optimizing the latent space of generative networks. arXiv preprint arXiv:1707.05776, 2017.
180
+ [3] Marcus Carter and Ben Egliston. Ethical implications of emerging mixed reality technologies. 2020.
181
+ [4] Lluis Castrejon, Nicolas Ballas, and Aaron Courville. Improved conditional vrnns for video prediction. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 7608–7617, 2019.
182
+ [5] Eric R Chan, Connor Z Lin, Matthew A Chan, Koki Nagano, Boxiao Pan, Shalini De Mello, Orazio Gallo, Leonidas Guibas, Jonathan Tremblay, Sameh Khamis, et al. Efficient geometry-aware 3d generative adversarial networks. arXiv preprint arXiv:2112.07945, 2021.
183
+ [6] Eric R Chan, Marco Monteiro, Petr Kellnhofer, Jiajun Wu, and Gordon Wetzstein. pi-GAN: Periodic implicit generative adversarial networks for 3d-aware image synthesis. arXiv preprint arXiv:2012.00926, 2020.
184
+ [7] Angel Chang, Angela Dai, Thomas Funkhouser, Maciej Halber, Matthias Niessner, Manolis Savva, Shuran Song, Andy Zeng, and Yinda Zhang. Matterport3d: Learning from rgb-d data in indoor environments. arXiv preprint arXiv:1709.06158, 2017.
185
+ [8] Terrance DeVries, Miguel Angel Bautista, Nitish Srivastava, Graham W Taylor, and Joshua M Susskind. Unconstrained scene generation with locally conditioned radiance fields. ICCV, 2021.
186
+ [9] Emilien Dupont, Miguel Angel Bautista, Alex Colburn, Aditya Sankar, Carlos Guestrin, Josh Susskind, and Qi Shan. Equivariant neural rendering. In International Conference on Machine Learning, pages 2761–2770. PMLR, 2020.
187
+ [10] Emilien Dupont, Hyunjik Kim, SM Ali Eslami, Danilo Jimenez Rezende, and Dan Rosenbaum. From data to functa: Your data point is a function and you can treat it like one. In International Conference on Machine Learning, pages 5694–5725. PMLR, 2022.
188
+ [11] Patrick Esser, Robin Rombach, and Bjorn Ommer. Taming transformers for high-resolution image synthesis. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 12873–12883, 2021.
189
+ [12] Jiatao Gu, Lingjie Liu, Peng Wang, and Christian Theobalt. Stylenerf: A style-based 3d-aware generator for high-resolution image synthesis. arXiv preprint arXiv:2110.08985, 2021.
190
+ [13] Pengsheng Guo, Miguel Angel Bautista, Alex Colburn, Liang Yang, Daniel Ulbricht, Joshua M Susskind, and Qi Shan. Fast and explicit neural view synthesis. In Proceedings of the IEEE/CVF Winter Conference on Applications of Computer Vision, pages 3791–3800, 2022.
191
+ [14] David Ha and Jürgen Schmidhuber. World models. arXiv preprint arXiv:1803.10122, 2018.
192
+ [15] Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 770–778, 2016.
193
+ [16] Martin Heusel, Hubert Ramsauer, Thomas Unterthiner, Bernhard Nessler, and Sepp Hochreiter. Gans trained by a two time-scale update rule converge to a local nash equilibrium. arXiv preprint arXiv:1706.08500, 2017.
194
+ [17] Jonathan Ho, Ajay Jain, and Pieter Abbeel. Denoising diffusion probabilistic models. Advances in Neural Information Processing Systems, 33:6840–6851, 2020.
195
+ [18] Aapo Hyvärinen and Peter Dayan. Estimation of non-normalized statistical models by score matching. Journal of Machine Learning Research, 6(4), 2005.
196
+ [19] Ajay Jain, Ben Mildenhall, Jonathan T Barron, Pieter Abbeel, and Ben Poole. Zero-shot text-guided object generation with dream fields. arXiv preprint arXiv:2112.01455, 2021.
197
+ [20] Niharika Jain, Alberto Olmo, Sailik Sengupta, Lydia Manikonda, and Subbarao Kambhampati. Imperfect imaganation: Implications of gans exacerbating biases on facial data augmentation and snapchat selfie lenses. arXiv preprint arXiv:2001.09528, 2020.
198
+ [21] 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, pages 4401–4410, 2019.
199
+ [22] 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.
200
+ [23] Michał Kempka, Marek Wydmuch, Grzegorz Runc, Jakub Toczek, and Wojciech Jaskowski. Vizdoom: ´ A doom-based ai research platform for visual reinforcement learning. In 2016 IEEE Conference on Computational Intelligence and Games (CIG), pages 1–8. IEEE, 2016.
201
+ [24] Seung Wook Kim, Jonah Philion, Antonio Torralba, and Sanja Fidler. Drivegan: Towards a controllable high-quality neural simulation. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 5820–5829, 2021.
202
+ [25] Adam R Kosiorek, Heiko Strathmann, Daniel Zoran, Pol Moreno, Rosalia Schneider, Sona Mokrá, and Danilo Jimenez Rezende. Nerf-vae: A geometry aware 3d scene generative model. In International Conference on Machine Learning, pages 5742–5752. PMLR, 2021.
203
+ [26] Jacob Krantz, Erik Wijmans, Arjun Majundar, Dhruv Batra, and Stefan Lee. Beyond the nav-graph: Vision and language navigation in continuous environments. In European Conference on Computer Vision (ECCV), 2020.
204
+ [27] Zihang Lai, Sifei Liu, Alexei A Efros, and Xiaolong Wang. Video autoencoder: self-supervised disentanglement of static 3d structure and motion. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 9730–9740, 2021.
205
+ [28] Lingjie Liu, Jiatao Gu, Kyaw Zaw Lin, Tat-Seng Chua, and Christian Theobalt. Neural sparse voxel fields. arXiv preprint arXiv:2007.11571, 2020.
206
+ [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. arXiv preprint arXiv:1907.11692, 2019.
207
+ [30] Willi Menapace, Stéphane Lathuilière, Sergey Tulyakov, Aliaksandr Siarohin, and Elisa Ricci. Playable video generation. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 10061–10070, 2021.
208
+ [31] Lars Mescheder, Michael Oechsle, Michael Niemeyer, Sebastian Nowozin, and Andreas Geiger. Occupancy networks: Learning 3d reconstruction in function space. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pages 4460–4470, 2019.
209
+ [32] Oscar Michel, Roi Bar-On, Richard Liu, Sagie Benaim, and Rana Hanocka. Text2mesh: Text-driven neural stylization for meshes. arXiv preprint arXiv:2112.03221, 2021.
210
+ [33] Ben Mildenhall, Pratul P Srinivasan, Matthew Tancik, Jonathan T Barron, Ravi Ramamoorthi, and Ren Ng. Nerf: Representing scenes as neural radiance fields for view synthesis. arXiv preprint arXiv:2003.08934, 2020.
211
+ [34] Yisroel Mirsky and Wenke Lee. The creation and detection of deepfakes: A survey. ACM Computing Surveys (CSUR), 54(1):1–41, 2021.
212
+ [35] Stanislav Morozov, Andrey Voynov, and Artem Babenko. On self-supervised image representations for GAN evaluation. In International Conference on Learning Representations, 2021.
213
+ [36] Alex Nichol, Prafulla Dhariwal, Aditya Ramesh, Pranav Shyam, Pamela Mishkin, Bob McGrew, Ilya Sutskever, and Mark Chen. Glide: Towards photorealistic image generation and editing with text-guided diffusion models. arXiv preprint arXiv:2112.10741, 2021.
214
+ [37] Alexander Quinn Nichol and Prafulla Dhariwal. Improved denoising diffusion probabilistic models. In International Conference on Machine Learning, pages 8162–8171. PMLR, 2021.
215
+ [38] Michael Niemeyer and Andreas Geiger. Giraffe: Representing scenes as compositional generative neural feature fields. arXiv preprint arXiv:2011.12100, 2020.
216
+ [39] Jeong Joon Park, Peter Florence, Julian Straub, Richard Newcombe, and Steven Lovegrove. Deepsdf: Learning continuous signed distance functions for shape representation. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 165–174, 2019.
217
+ [40] Despoina Paschalidou, Amlan Kar, Maria Shugrina, Karsten Kreis, Andreas Geiger, and Sanja Fidler. Atiss: Autoregressive transformers for indoor scene synthesis. Advances in Neural Information Processing Systems, 34, 2021.
218
+ [41] Songyou Peng, Michael Niemeyer, Lars Mescheder, Marc Pollefeys, and Andreas Geiger. Convolutional occupancy networks. arXiv preprint arXiv:2003.04618, 2, 2020.
219
+ [42] Ethan Perez, Florian Strub, Harm De Vries, Vincent Dumoulin, and Aaron Courville. Film: Visual reasoning with a general conditioning layer. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 32, 2018.
220
+ [43] Benjamin Planche, Xuejian Rong, Ziyan Wu, Srikrishna Karanam, Harald Kosch, YingLi Tian, Jan Ernst, and Andreas Hutter. Incremental scene synthesis. In Advances in Neural Information Processing Systems, pages 1668–1678, 2019.
221
+ [44] 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.
222
+ [45] 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.
223
+ [46] 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.
224
+ [47] Daniel Rebain, Mark Matthews, Kwang Moo Yi, Dmitry Lagun, and Andrea Tagliasacchi. Lolnerf: Learn from one look. arXiv preprint arXiv:2111.09996, 2021.
225
+ [48] Christian Reiser, Songyou Peng, Yiyi Liao, and Andreas Geiger. Kilonerf: Speeding up neural radiance fields with thousands of tiny mlps. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 14335–14345, 2021.
226
+ [49] Xuanchi Ren and Xiaolong Wang. Look outside the room: Synthesizing a consistent long-term 3d scene video from a single image. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), 2022.
227
+ [50] Salah Rifai, Grégoire Mesnil, Pascal Vincent, Xavier Muller, Yoshua Bengio, Yann Dauphin, and Xavier Glorot. Higher order contractive auto-encoder. In Joint European conference on machine learning and knowledge discovery in databases, pages 645–660. Springer, 2011.
228
+ [51] Daniel Ritchie, Kai Wang, and Yu-an Lin. Fast and flexible indoor scene synthesis via deep convolutional generative models. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 6182–6190, 2019.
229
+ [52] Robin Rombach, Andreas Blattmann, Dominik Lorenz, Patrick Esser, and Björn Ommer. High-resolution image synthesis with latent diffusion models. arXiv preprint arXiv:2112.10752, 2021.
230
+ [53] Robin Rombach, Patrick Esser, and Björn Ommer. Geometry-free view synthesis: Transformers and no 3d priors, 2021.
231
+ [54] Olaf Ronneberger, Philipp Fischer, and Thomas Brox. U-net: Convolutional networks for biomedical image segmentation. In International Conference on Medical image computing and computer-assisted intervention, pages 234–241. Springer, 2015.
232
+ [55] Negar Rostamzadeh, Emily Denton, and Linda Petrini. Ethics and creativity in computer vision. arXiv preprint arXiv:2112.03111, 2021.
233
+ [56] 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, Jonathan Ho, David J Fleet, and Mohammad Norouzi. Photorealistic text-to-image diffusion models with deep language understanding, 2022.
234
+ [57] Mehdi S. M. Sajjadi, Henning Meyer, Etienne Pot, Urs Bergmann, Klaus Greff, Noha Radwan, Suhani Vora, Mario Lucic, Daniel Duckworth, Alexey Dosovitskiy, Jakob Uszkoreit, Thomas Funkhouser, and Andrea Tagliasacchi. Scene Representation Transformer: Geometry-Free Novel View Synthesis Through Set-Latent Scene Representations. CVPR, 2022.
235
+ [58] Tim Salimans, Ian Goodfellow, Wojciech Zaremba, Vicki Cheung, Alec Radford, and Xi Chen. Improved techniques for training gans. NeurIPS’16, page 2234–2242, Red Hook, NY, USA, 2016. Curran Associates Inc.
236
+ [59] Manolis Savva, Abhishek Kadian, Oleksandr Maksymets, Yili Zhao, Erik Wijmans, Bhavana Jain, Julian Straub, Jia Liu, Vladlen Koltun, Jitendra Malik, et al. Habitat: A platform for embodied ai research. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 9339–9347, 2019.
237
+ [60] Katja Schwarz, Yiyi Liao, Michael Niemeyer, and Andreas Geiger. GRAF: Generative radiance fields for 3d-aware image synthesis. arXiv preprint arXiv:2007.02442, 2020.
238
+ [61] Edward J Smith and David Meger. Improved adversarial systems for 3d object generation and reconstruction. In Conference on Robot Learning, pages 87–96. PMLR, 2017.
239
+ [62] Jascha Sohl-Dickstein, Eric Weiss, Niru Maheswaranathan, and Surya Ganguli. Deep unsupervised learning using nonequilibrium thermodynamics. In International Conference on Machine Learning, pages 2256–2265. PMLR, 2015.
240
+ [63] Jiaming Song, Chenlin Meng, and Stefano Ermon. Denoising diffusion implicit models. arXiv preprint arXiv:2010.02502, 2020.
241
+ [64] Julian Straub, Thomas Whelan, Lingni Ma, Yufan Chen, Erik Wijmans, Simon Green, Jakob J Engel, Raul Mur-Artal, Carl Ren, Shobhit Verma, et al. The replica dataset: A digital replica of indoor spaces. arXiv preprint arXiv:1906.05797, 2019.
242
+ [65] Hoang Thanh-Tung and Truyen Tran. Catastrophic forgetting and mode collapse in gans. In 2020 International Joint Conference on Neural Networks (IJCNN), pages 1–10. IEEE, 2020.
243
+ [66] Patrick Tinsley, Adam Czajka, and Patrick Flynn. This face does not exist... but it might be yours! identity leakage in generative models. In Proceedings of the IEEE/CVF Winter Conference on Applications of Computer Vision, pages 1320–1328, 2021.
244
+ [67] Thomas Unterthiner, Sjoerd van Steenkiste, Karol Kurach, Raphael Marinier, Marcin Michalski, and Sylvain Gelly. Towards accurate generative models of video: A new metric & challenges. arXiv preprint arXiv:1812.01717, 2018.
245
+ [68] Arash Vahdat, Karsten Kreis, and Jan Kautz. Score-based generative modeling in latent space. Advances in Neural Information Processing Systems, 34:11287–11302, 2021.
246
+ [69] Aaron Van Den Oord, Oriol Vinyals, et al. Neural discrete representation learning. Advances in neural information processing systems, 30, 2017.
247
+ [70] Xinpeng Wang, Chandan Yeshwanth, and Matthias Nießner. Sceneformer: Indoor scene generation with transformers. In 2021 International Conference on 3D Vision (3DV), pages 106–115. IEEE, 2021.
248
+ [71] Daniel Watson, William Chan, Jonathan Ho, and Mohammad Norouzi. Learning fast samplers for diffusion models by differentiating through sample quality. In International Conference on Learning Representations, 2021.
249
+ [72] Daniel Watson, Jonathan Ho, Mohammad Norouzi, and William Chan. Learning to efficiently sample from diffusion probabilistic models. arXiv preprint arXiv:2106.03802, 2021.
250
+ [73] Alex Yu, Sara Fridovich-Keil, Matthew Tancik, Qinhong Chen, Benjamin Recht, and Angjoo Kanazawa. Plenoxels: Radiance fields without neural networks. arXiv preprint arXiv:2112.05131, 2021.
251
+
252
+ [74] Alex Yu, Vickie Ye, Matthew Tancik, and Angjoo Kanazawa. pixelnerf: Neural radiance fields from one or few images. arXiv preprint arXiv:2012.02190, 2020.
253
+
254
+ [75] Peng Zhou, Lingxi Xie, Bingbing Ni, and Qi Tian. Cips-3d: A 3d-aware generator of gans based on conditionally-independent pixel synthesis. arXiv preprint arXiv:2110.09788, 2021.
255
+
256
+ # Checklist
257
+
258
+ 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:
259
+
260
+ • Did you include the license to the code and datasets? [Yes] See Section ??.
261
+ • Did you include the license to the code and datasets? [No] The code and the data are proprietary.
262
+ • Did you include the license to the code and datasets? [N/A]
263
+
264
+ 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.
265
+
266
+ 1. For all authors...
267
+
268
+ (a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes]
269
+ (b) Did you describe the limitations of your work? [Yes] These will be discussed in appendix A
270
+ (c) Did you discuss any potential negative societal impacts of your work? [Yes] These will be discussed in appendix A
271
+ (d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
272
+
273
+ 2. If you are including theoretical results...
274
+
275
+ (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]
276
+
277
+ 3. If you ran experiments...
278
+
279
+ (a) Did you include the code, data, and instructions needed to reproduce the main experimental results (either in the supplemental material or as a URL)? [Yes] We will release code publicly upon acceptance.
280
+ (b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes] These details will be clarified in B
281
+ (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [Yes]
282
+ (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] These details will be clarified in B
283
+
284
+ 4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
285
+
286
+ (a) If your work uses existing assets, did you cite the creators? [Yes] See Sect. 4
287
+ (b) Did you mention the license of the assets? [Yes]
288
+ (c) Did you include any new assets either in the supplemental material or as a URL? [N/A]
289
+ (d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [N/A]
290
+ (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [N/A]
291
+
292
+ 5. If you used crowdsourcing or conducted research with human subjects...
293
+
294
+ (a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A]
295
+ (b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A]
296
+ (c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]
md/dev/z7p2V6KROOV/z7p2V6KROOV.md ADDED
The diff for this file is too large to render. See raw diff
 
md/dev/zkk_7sV6gm8/zkk_7sV6gm8.md ADDED
@@ -0,0 +1,458 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Timing is Everything: Learning to Act Selectively with Costly Actions and Budgetary Constraints
2
+
3
+ Anonymous Author(s)
4
+
5
+ # Abstract
6
+
7
+ 1 Many real-world settings involve costs for performing actions; transaction costs
8
+ 2 in financial systems and fuel costs being common examples. In these settings,
9
+ 3 performing actions at each time step quickly accumulates costs leading to vastly
10
+ 4 suboptimal outcomes. Additionally, repeatedly acting produces wear and tear and
11
+ 5 ultimately, damage. Determining when to act is crucial for achieving successful
12
+ 6 outcomes and yet, the challenge of efficiently learning to behave optimally when
13
+ 7 actions incur minimally bounded costs remains unresolved. In this paper, we intro
14
+ 8 duce a reinforcement learning (RL) framework named Learnable Impulse Control
15
+ 9 Reinforcement Algorithm (LICRA), for learning to optimally select both when
16
+ 10 to act and which actions to take when actions incur costs. At the core of LICRA
17
+ 11 is a nested structure that combines RL and a form of policy known as impulse
18
+ 12 control which learns to maximise objectives when actions incur costs. We prove
19
+ 13 that LICRA, which seamlessly adopts any RL method, converges to policies that
20
+ 14 optimally select when to perform actions and their optimal magnitudes. We then
21
+ 15 augment LICRA to handle problems in which the agent can perform at most $k < \infty$
22
+ 16 actions and more generally, faces a budget constraint. We show LICRA learns the
23
+ 17 optimal value function and ensures budget constraints are satisfied almost surely.
24
+ 18 We demonstrate empirically LICRA’s superior performance against benchmark
25
+ 19 RL methods in OpenAI gym’s Lunar Lander and in Highway environments and a
26
+ 20 variant of the Merton portfolio problem within finance.
27
+
28
+ # 21 1 Introduction
29
+
30
+ 22 There are many settings in which agents incur costs each time they perform an action. Transaction
31
+ 23 costs in financial settings [19], fuel expenditure [32], toxicity as a side effect of controlling bacte
32
+ 24 ria [29] and physical damage produced by repeated action that produces wear and tear are just a
33
+ 25 few among many examples [13]. In these settings, performing actions at each time step is vastly
34
+ 26 suboptimal since acting in this way results in prohibitively high costs and undermines the service life
35
+ 27 of machinery. Minimising wear and tear is an essential attribute to safeguard against failures that can
36
+ 28 result in catastrophic losses [13].
37
+ 29 Reinforcement learning (RL) is a framework that enables autonomous agents to learn complex
38
+ 30 behaviours from interactions with the environment [30, 11]. Within the standard RL paradigm,
39
+ 31 determining optimal actions involves making a selection from among many (possibly infinite) actions;
40
+ 32 a procedure that must be performed at each time-step as the agent decides on an action. In unknown
41
+ 33 settings, the agent cannot immediately exploit any topological structure of the action set (if any
42
+ 34 exists). Consequently, learning not to take an action i.e performing a zero or null action, involves
43
+ 35 expensive optimisation procedures over the entire action set. Since this must be done at each state,
44
+ 36 this process is vastly inefficient for learning optimal policies when the agent incurs costs for acting.
45
+ 37 In this paper, we tackle this problem by developing an RL framework for finding both an optimal
46
+ 38 criterion to determine whether or not to execute actions as well as learning optimal actions. A key
47
+ 39 component of our framework is a novel combination of RL with a form of policy known as impulse
48
+ 40 control [22, 19]. This enables the agent to determine the appropriate points to perform an action as
49
+ 41 well as the optimal action itself. Despite its fundamental importance as a tool for tackling decision
50
+ 42 problems with costly actions, presently, the use of impulse control within learning contexts (and
51
+ 43 unknown environments) is unaddressed.
52
+ 44 We present an RL impulse control framework called LICRA, which, to our knowledge, is the first
53
+ 45 learning framework for impulse control. To enable learning optimal impulse control policies in
54
+ 46 unknown environments, we devise a framework that consists of separate RL components for learning
55
+ 47 when to act and how to act optimally. The resulting framework is a structured two-part learning
56
+ 48 process which differs from current RL protocols. In LICRA, at each time step, the agent firstly makes
57
+ 49 a decision whether to act or not leading to a binary decision space $\{ 0 , 1 \}$ (we later show that this
58
+ 50 is determined by evaluating an easy-to-evaluate criterion which has the value function as its input).
59
+ 51 The second decision part determines the best action to take. This generates a subdivision of the state
60
+ 52 space into two regions; one in which the agent performs actions and another in which it does not act
61
+ 53 at all. This is extremely useful since the agent quickly determines the set of states to not take actions
62
+ 54 while performing actions only at the subset of states where actions are to be executed.
63
+ 55 We then establish theory that ensures convergence of LICRA to an optimal policy for such settings.
64
+ 56 To do this, we give a series of results namely:
65
+ 57 i) We establish a dynamic programming principle (DPP) for impulse control and show that the optimal
66
+ 58 value function can be obtained as a limit of a value iterative procedure (Theorem 1) which lays the
67
+ 59 foundation for an RL approach to impulse control.
68
+ 60 ii) We extend result i) to a new variant of Q learning which enables the impulse control problem to be
69
+ 61 solved using our RL method (Theorem 2).
70
+ 62 iii) We characterise the optimal conditions for performing an action which we reveal to be a simple
71
+ 63 ‘obstacle condition’ involving the agent’s value function (Prop. 1). Using this, the agent can quickly
72
+ 64 determine whether or not it should act and if so, then learn what the optimal action is.
73
+ 65 iv) We then extend the result i) to (linear) function approximators enabling the value function to be
74
+ 66 parameterised (Theorem 3).
75
+ 67 iv) In Sec. 6, we extend LICRA to include budgetary constraints so that each action draws from a
76
+ 68 fixed budget which the agent must stay within. Analogous to the development of i), we establish
77
+ 69 another DPP from which we derive a Q-learning variant for tackling impulse control with budgetary
78
+ 70 constraints (Theorem 4). A particular case of a budget constraint is when the number of actions the
79
+ 71 agent can take over the horizon is capped.
80
+ 72 Lastly, we perform a set of experiments to validate our theory within the Highway driving simulator
81
+ 73 and OpenAI’s LunarLander [7].
82
+ 74 LICRA confers a series of advantages. As we demonstrate in our experiments, LICRA learns to
83
+ 75 compute the optimal problems in which the agent faces costs for acting in an efficient way which
84
+ 76 outperforms leading RL baselines. Second, as demonstrated in Sec. 6 LICRA handles settings in
85
+ 77 which the agent has a cap the total number of actions it is allowed to execute and more generally,
86
+ 78 generic budgetary constraints. LICRA is able to accommodate any RL base algorithm unlike various
87
+ 79 RL methods designed to handle budgetary constraints.
88
+
89
+ # 80 2 Related Work
90
+
91
+ 81 In continuous-time optimal control theory [24], problems in which the agent faces a cost for each
92
+ 82 action are tackled with a form of policy known as impulse control [22, 19, 2]. In impulse control
93
+ 83 frameworks, the dynamics of the system are modified through a sequence of discrete actions or bursts
94
+ 84 chosen at times that the agent chooses to apply the control policy. This distinguishes impulse control
95
+ 85 models from classical decision methods in which an agent takes actions at each time step while being
96
+ 86 tasked with the decision of only which action to take. Impulse control models represent appropriate
97
+ 87 modelling frameworks for financial environments with transaction costs, liquidity risks and economic
98
+ 88 environments in which players face fixed adjustment costs (e.g. menu costs) [16, 20].
99
+ 89 The current setting is intimately related to the optimal stopping problem which widely occurs in
100
+ 90 finance, economics and computer science [23, 31]. In the optimal stopping problem, the task is to
101
+ 91 determine a criterion that determines when to arrest the system and receive a terminal reward. In this
102
+ 92 case, standard RL methods are unsuitable since they require an expensive sweep (through the set
103
+ 93 of states) to determine the optimal point to arrest the system. The current problem can be viewed
104
+ 94 as an augmented problem of optimal stopping since the agent must now determine both a sequence
105
+ 95 of points to perform an action or intervene and their optimal magnitudes — only acting when the
106
+ 96 cost of action is justified [25]. Adapting RL to tackle optimal stopping problems has been widely
107
+ 97 studied [31, 4, 9] and applied to a variety of real-world settings within finance [12], radiation therapy
108
+ 98 [1] and network operating systems [3]. Our work serves as a natural extenstion to RL approaches to
109
+ 99 optimal stopping to the case in which the agent must decide at which points to take many actions. As
110
+ 100 with optimal stopping, standard RL methods cannot efficiently tackle this problem since determining
111
+ 101 whether to perform a 0 action requires a costly sweep through the action space at every state [31]. In
112
+ 102 [26] the authors introduce “sparse action” with a similar motivation as impulse control. However,
113
+ 103 the authors treat only the discrete action space case. The authors in [26] do not discuss a broader
114
+ 104 theoretical framework of dealing with “sparse actions”, and develop purely algorithmic solutions.
115
+ 105 Additionally, unlike the approach taken in [26], the problem setting we consider is one in which the
116
+ 106 agent faces a cost for each action - the produces a need for the agent to be selective about where it
117
+ 107 performs actions (but does not necessarily constrain the magnitude or choice of those actions).
118
+
119
+ # 108 3 Preliminaries
120
+
121
+ 109 Reinforcement Learning (RL). In RL, an agent sequentially selects actions to maximise its expected
122
+ 110 returns. The underlying problem is typically formalised as an MDP $\langle S , \mathcal { A } , P , R , \gamma \rangle$ where $S \subset \mathbb { R } ^ { p }$
123
+ 111 is the set of states, $\mathcal { A } \subset \mathbb { R } ^ { k }$ is the set of actions, $P : \mathcal { S } \times \mathcal { A } \times \mathcal { S } [ 0 , 1 ]$ is a transition probability
124
+ 112 function describing the system’s dynamics, $R : S \times \mathcal { A } \mathbb { R }$ is the reward function measuring the
125
+ 113 agent’s performance and the factor $\gamma \in [ 0 , 1 )$ specifies the degree to which the agent’s rewards are
126
+ 114 discounted over time [30]. At time $t \in { 0 , 1 , \ldots }$ , the system is in state $s _ { t } \in S$ and the agent must
127
+ 115 choose an action $a _ { t } \in \mathcal A$ which transitions the system to a new state $s _ { t + 1 } \sim P ( \cdot | s _ { t } , a _ { t } )$ and produces
128
+ 116 a reward $R ( s _ { t } , a _ { t } )$ . A policy $\pi : S \times A \to [ 0 , 1 ]$ is a probability distribution over state-action pairs
129
+ 117 where $\pi ( a | s )$ represents the probability of selecting action $a \in { \mathcal { A } }$ in state $s \in S$ . The goal of an
130
+ 118 RL agent is to find a policy ${ \hat { \pi } } \in \Pi$ that maximises its expected returns given by the value function:
131
+ 119 $\begin{array} { r } { v ^ { \pi } ( s ) = \mathbb { E } [ \sum _ { t = 0 } ^ { \infty } \gamma ^ { t } \bar { R } ( s _ { t } , a _ { t } ) | a _ { t } \sim \pi ( \cdot | s _ { t } ) , s _ { 0 } = s ] } \end{array}$ $\begin{array} { r } { Q ( s , a ) = \mathbb { E } [ \sum _ { t = 0 } ^ { \infty } R ( s _ { t } , a _ { t } ) | a _ { 0 } = a , s _ { 0 } = s ] } \end{array}$ $\Pi$ ent’s policy set. The action.
132
+ 121 We consider a setting in which the agent faces at least some minimal cost for each action it performs.
133
+ 122 With this, the agent’s task is to maximise:
134
+
135
+ $$
136
+ v ^ { \pi } ( s ) = \mathbb { E } \left[ \sum _ { t = 0 } ^ { \infty } \gamma ^ { t } \left\{ \mathcal { R } ( s _ { t } , a _ { t } ) - \mathcal { C } ( s _ { t } , a _ { t } ) \right\} \Big | s _ { 0 } = s \right] ,
137
+ $$
138
+
139
+ 123 where for any state $s \in S$ and any action $a \in { \mathcal { A } }$ , the functions $\mathcal { R }$ and $\mathcal { C }$ are given by $\textstyle { \mathcal { R } } ( s , a ) =$
140
+ 124 $R ( s , a ) \mathbf { 1 } _ { a \in \mathcal { A } } + R ( s , 0 ) ( 1 - \mathbf { 1 } _ { a \in \mathcal { A } } )$ where $\mathbf { 1 } _ { a \in \mathcal { A } }$ is the indicator function which is 1 when $a \in { \mathcal { A } }$ and 0
141
+ 125 otherwise and ${ \mathcal { C } } ( s , a ) : = c ( s , a ) \mathbf { 1 } _ { a \in { \mathcal { A } } }$ where $c : S \times \mathcal { A } \mathbb { R }$ is a minimally bounded (cost) function1
142
+ 126 that introduces a cost each time the agent performs an action. Examples of the cost function is a
143
+ 127 quasi-linear function of the form $c ( s _ { t } , \bar { a } _ { t } ) \stackrel { } { = } \kappa + f ( a _ { t } )$ where $f : \mathcal { A } \mathbb { R } _ { > 0 }$ and $\kappa$ is a positive real
144
+ 128 valued constant. Since acting at each time step would incur prohibitively high costs, the agent must
145
+ 129 be selective when to perform an action. Therefore, in this setting, the agent’s problem is augmented to
146
+ 130 learning both an optimal policy for its actions and, learning at which states to apply its action policy.
147
+ 131 Example: Merton Portfolio Problem with Transaction Costs [10]. An investor performs a series
148
+ 132 of costly portfolio adjustments by buying and selling amounts of different assets within their portfolio.
149
+ 133 Each investment incurs a fixed minimal cost (also known as transaction costs) which is deducted
150
+ 134 from the investor’s available cash-flow. The investor’s aim is to maximise their total wealth (the value
151
+ 135 of the sum of their assets) at some time horizon by adjusting their portfolio of investments. Problems
152
+ 136 of this kind, portfolio investment problems are of fundamental importance within finance [18].
153
+ 37 Example 2. An autonomous vehicle must perform a series of actions to perform a task. Each action
154
+ 38 draws from its fuel budget. In order to complete its task successfully, during the task, the vehicle
155
+ 139 must ensure it maintains an available supply.
156
+ 141 In RL, the agent’s problem involves learning to act at every state including those in which actions do
157
+ 142 not significantly impact on its total return. While we can add a zero action to the action set $\mathcal { A }$ and
158
+ 143 apply standard methods, we argue that this may not be the best solution in many situations. We argue
159
+ 144 the optimal policy has the following form:
160
+
161
+ $$
162
+ \begin{array} { r } { \widetilde { \pi } ( \cdot | s ) = \left\{ \begin{array} { l l } { a _ { t } } & { s \in S _ { I } , } \\ { 0 } & { s \notin S _ { I } , } \end{array} \right. } \end{array}
163
+ $$
164
+
165
+ 145 which implies that we simplify policy learning by determining the set $ { \boldsymbol { S } } _ { I }$ first — the set where we
166
+ 146 actually need to learn the policy.
167
+ 147 We now introduce a learning method for producing impulse controls. This enables the agent to learn
168
+ 148 to select states to perform actions. Therefore, now agent is tasked with learning to act at states that
169
+ 149 are most important for maximising its total return given the presence of the cost for each action. Now
170
+ 150 at each state the agent first makes a binary decision to decide to perform an action.
171
+ 151 Our framework, LICRA consists of two core components: firstly a RL process $\mathfrak { g } : \mathcal { S } \times \{ 0 , 1 \} [ 0 , 1 ]$
172
+ 152 and a second RL process $\pi : S \times A \to [ 0 , 1 ]$ . The role of $\mathfrak { g }$ is to determine whether or not an action
173
+ 153 is to be performed by the policy $\pi$ at a given state $s$ . If activated, the policy $\pi$ determines the action
174
+ 154 to be selected. Prior to decisions being made, the policy $\pi$ communicates to $\mathfrak { g }$ the action it would
175
+ 155 take. An important feature of our LICRA is the sequential decision process. In LICRA, the policy
176
+ 156 $\pi$ first proposes an action $a \in { \mathcal { A } }$ which is observed by the policy $\mathfrak { g }$ . Therefore, the role of $\mathfrak { g }$ is to
177
+ 157 prevent actions for which the change in expected future rewards does not exceed the costs incurred
178
+ 158 for taking such actions. By isolating a decision policy over whether an action should be taken or not,
179
+ 159 the impulse controls mechanism results in a framework in which the problem facing the agent has a
180
+ 160 markedly reduced decision space (in comparison to a standard RL method). Crucially, the agent must
181
+ 161 compute optimal actions at only a subset of states which are chosen by the policy g. Below is the
182
+ 162 pseudocode for LICRA, we provide full details of the code in Sec. 9 of the Appendix.
183
+
184
+ # Algorithm 1: Learnable Impulse Control Reinforcement Algorithm (LICRA)
185
+
186
+ 1: Input: Stepsize $\alpha$ , batch size $B$ , episodes $K$ , steps per episode $T$ , mini-epochs $e$
187
+ 2: Initialise: Policy network (acting) $\pi$ , Policy network (switching) $\mathfrak { g }$ ,
188
+ Critic network (acting $) V _ { \pi }$ ,Critic network (switching $) V _ { { \mathfrak { g } } }$
189
+ 3: Given reward objective function, $R$ , initialise Rollout Buffers $B _ { \pi }$ , $B _ { \mathfrak { g } }$ (use Replay Buffer for
190
+ SAC)
191
+ 4: for $N _ { e p i s o d e s }$ do
192
+ 5: Reset state $s _ { 0 }$ , Reset Rollout Buffers $B _ { \pi }$ , $B _ { \mathfrak { g } }$
193
+ 6: for $t = 0 , 1 , \ldots$ do
194
+ 7: Sample $a _ { t } \sim \pi ( \cdot | s _ { t } )$
195
+ 8: Sample $g _ { t } \sim \mathfrak { g } ( \cdot | s _ { t } )$
196
+ 9: if $g _ { t } = 0$ then
197
+ 10: Apply $a _ { t }$ so $s _ { t + 1 } \sim P ( \cdot | a _ { t } , s _ { t } ) .$ ,
198
+ 11: Receive rewards $r _ { t } = \mathcal { R } ( s _ { t } , a _ { t } )$
199
+ 12: Store $( s _ { t } , a _ { t } , s _ { t + 1 } , r _ { t } )$ in $B _ { \pi }$
200
+ 13: else
201
+ 14: Apply the null action so $s _ { t + 1 } \sim P ( \cdot | 0 , s _ { t } )$ ,
202
+ 15: Receive rewards $r _ { t } = \mathcal { R } ( s _ { t } , 0 )$ .
203
+ 16: end if
204
+ 17: Store $( s _ { t } , g _ { t } , s _ { t + 1 } , r _ { t } )$ in $B _ { \mathfrak { g } }$
205
+ 18: end for
206
+ 19: // Learn the individual policies
207
+ 20: Update policy $\pi$ and critic $V _ { \pi }$ networks using $\mathfrak { B } _ { \pi }$
208
+ 21: Update policy $\mathfrak { g }$ and critic $V _ { \mathfrak { g } }$ networks using ${ \mathfrak { B } } _ { { \mathfrak { g } } }$
209
+ 22: end for
210
+ 165 Although action space cardinality does not change there are still benefits of using impulse control
211
+ 166 mechanism. This mechanism forces the agent to first determine the set of states to perform actions
212
+ 167 only then determine the optimal actions at these states. An important fact to note is that the decision
213
+ 168 space for the determining whether or not to execute an action is $S \times \{ 0 , 1 \}$ i.e at each state it makes a
214
+ 169 binary decision. Consequently, the learning process for aspect is much quicker than a policy which
215
+ 170 must optimise over a decision space which is $| { \cal S } | | { \cal A } |$ (choosing an action from its action space at
216
+ 171 every state). This results in the agent rapidly learning which states to focus on to learn which actions
217
+ 172 to perform. In the case of $\pi$ with a continuous action space again the impulse control mechanism
218
+ 173 does not change the cardinality of the action space. However, if the set ${ \cal S } / { \cal S } _ { I }$ , where the optimal
219
+ 174 policy chooses 0, is large enough, then again it can be more efficient to learn $\mathfrak { g }$ first and only then
220
+ 175 learn $\pi$ (we later validate this claim empirically, see Sec. 11.2),
221
+ 176 In Sec. 5, we prove the convergence properties of LICRA. LICRA consists of two independent
222
+ 177 procedures: a learning process for the policy $\pi$ and simultaneously, a learning process for the impulse
223
+ 178 policy $\mathfrak { g }$ which determines at which states to perform an action. In our implementation, we used
224
+ 179 proximal policy optimisation (PPO) [27] for the policy $\pi$ and for the impulse policy $\mathfrak { g }$ , whose action
225
+ 180 set consists of two actions (intervene or do not intervene) we used a soft actor critic (SAC) process
226
+ 181 [14] LICRA is a plug $\&$ play framework which enables these RL components to be replaced with any
227
+ 182 RL algorithm of choice.
228
+
229
+ # 183 5 Convergence and Optimality of LICRA
230
+
231
+ 184 A key aspect of our framework is the presence of two RL processes that make decisions in a sequential
232
+ 185 order. In order to determine when to act the policy $\mathfrak { g }$ must learn the states to allow the policy $\pi$ to
233
+ 186 perform an action which the policy $\pi$ must learn to select optimal actions whenever it is allowed to
234
+ 187 execute an action.
235
+ 188 In this section, we prove that LICRA converges to an optimal solution of the system. Central to
236
+ 189 LICRA is a Q-learning type method which is adapted to handle RL settings in which the agent must
237
+ 190 also learn when to act. We then extend the result to allow for (linear) function approximators. We
238
+ 191 provide a result that shows the optimal intervention times are characterised by an ‘obstacle condition’
239
+ 192 which can be evaluated online therefore allowing the $\mathfrak { g }$ .
240
+
241
+ Given a function $Q \because S \times \mathcal { A } \to \mathbb { R } , \quad \forall \pi , \pi ^ { \prime } \in \Pi$ and $\forall \ S , \ S ^ { \prime } , \quad \forall s _ { \tau _ { k } } \quad \in \quad S$ , we define the intervention operator $\mathcal { M } ^ { \pi , { \mathfrak { g } } }$ by $\begin{array} { r } { \mathcal { M } ( ^ { \pi , \oplus } Q ^ { \pi ^ { \prime } , \oplus ^ { \prime } } ( s _ { \pi _ { k } } , a _ { \pi _ { k } } ) : = { \mathcal R } ( s _ { \pi _ { k } } , a _ { \pi _ { k } } ) - c ( s _ { \pi _ { k } } , a _ { \pi _ { k } } ) + } \end{array}$ $\begin{array} { r } { \gamma \sum _ { s ^ { \prime } \in S } P ( s ^ { \prime } ; a _ { \tau _ { k } } , s ) v ^ { \pi ^ { \prime } , \mathfrak { g ^ { \prime } } } ( s ^ { \prime } ) \| a _ { \tau _ { k } } \sim \pi ( \cdot | s _ { \tau _ { k } } ) , } \end{array}$ , where $\tau _ { k }$ is an intervention time.
242
+
243
+ 196 The interpretation of $\mathcal { M }$ is the following: suppose that the agent is using the policy $\pi$ and at time $\tau _ { k }$
244
+ 197 the system is at a state $s _ { \tau _ { k } }$ and the agent performs an action $a _ { \tau _ { k } } \sim \pi ( \cdot | s _ { \tau _ { k } } )$ . A cost of $c ( s _ { \tau _ { k } } , a _ { \tau _ { k } } )$
245
+ 198 is then incurred by the agent and the system transitions to $s ^ { \prime } \sim P ( \cdot ; a _ { \tau _ { k } } , s _ { \tau _ { k } } )$ . Lastly, recall $v ^ { \pi , { \mathfrak { g } } }$ is
246
+ 199 the agent value function under the policy pair $( \pi , g )$ . Therefore, the quantity ${ \mathcal { M } } Q ^ { \pi , { \mathfrak { g } } }$ measures the
247
+ 200 expected future stream of rewards after an immediate intervention minus the cost of intervention.
248
+ 201 This object plays a crucial role in the LICRA framework which as we later discuss, exploits the cost
249
+ 202 structure of the problem to determine when the agent should perform an intervention.
250
+
251
+ Given a function 203 $v ^ { n , \ell } : S \mathbb { \quad }$ , we define the Bellman operator $\boldsymbol { \cdot }$ , by:
252
+
253
+ 204
254
+
255
+ $$
256
+ T v ^ { \pi , \theta } ( s ) : = \operatorname* { m a x } \Big \{ \mathcal { N } ^ { ( \pi , \theta ) } Q ^ { \pi , \theta } ( s , a ) , \mathcal { R } ( s , 0 ) + \gamma \sum _ { s ^ { \prime } \in S } P ( s ^ { \prime } ; 0 , s ) v ^ { \pi , \theta } ( s ^ { \prime } ) \Big \} , \qquad \forall s \in \mathcal { S } .
257
+ $$
258
+
259
+ 205
260
+
261
+ 206 The Bellman operator captures the nested sequential structure of the LICRA algorithm. In particular,
262
+ 207 the structure in (3) consists of an inner structure which consists of two terms: the first term is the
263
+ 208 expected future return given an action is taken at the current state under the policy $\pi$ . The second term
264
+ 209 is the expected future return given no action is taken at the current state. Lastly, the outer structure is
265
+ 210 an optimisation which compares the expected return of the two possibilities and selects the maximum.
266
+
267
+ 11 Our first result proves $T$ is a contraction operator in particular, the following bound holds:
268
+
269
+ 212 Lemma 1 The Bellman operator $T$ is a contraction, that is the following bound holds:
270
+
271
+ $$
272
+ \begin{array} { r } { \| T v - T v ^ { \prime } \| \leq \gamma \left. v - v ^ { \prime } \right. , } \end{array}
273
+ $$
274
+
275
+ where 13 $v , v ^ { \prime }$ are elements of a finite normed vector space. We can now state our first main result:
276
+
277
+ Theorem 1 Given any $v ^ { \pi , \mathfrak { g } } : \mathcal { S } \times \mathcal { A } \mathbb { R } ,$ , the optimal value function is given by $\operatorname* { l i m } _ { k \to \infty } T ^ { k } v ^ { \pi , \mathfrak { g } } =$ $\operatorname* { m a x } _ { \hat { \pi } , \hat { g } \in \Pi } v ^ { \hat { \pi } , \hat { g } } = v ^ { \pi ^ { \star } , g ^ { \star } }$ where $( \pi ^ { \star } , g ^ { \star } )$ is the optimal policy pair.
278
+
279
+ The result of Theorem 1 enables the solution to the agent’s impulse control problem to be determined using a value iteration procedure. Moreover, Theorem 1 enables a Q-learning approach [6] for finding the solution to the agent’s problem.
280
+
281
+ 219 Theorem 2 Consider the following $Q$ learning variant:
282
+
283
+ $$
284
+ + \alpha _ { t } ( s _ { t } , a _ { t } ) \left[ \operatorname* { m a x } \left\{ \mathcal { M } ^ { \pi , \mathfrak { g } } Q _ { t } ( s _ { t } , a _ { t } ) , \mathcal { R } ( s _ { t } , 0 ) + \gamma _ { a ^ { \prime } \in A } ^ { \operatorname* { m a x } } Q _ { t } ( s _ { t + 1 } , a ^ { \prime } ) \right\} - Q _ { t } ( s _ { t } , a _ { t } ) \right] ,
285
+ $$
286
+
287
+ then 220 $Q _ { t }$ converges to $Q ^ { \star }$ with probability 1, where $s _ { t } , s _ { t + 1 } \in S$ and $a _ { t } \in \mathcal A$ .
288
+
289
+ 21 We now extend the result to (linear) function approximators:
290
+
291
+ Theorem 3 Given a set of linearly independent basis functions $\Phi = \{ \phi _ { 1 } , \ldots , \phi _ { p } \}$ with $\phi _ { k } \in L _ { 2 } , \forall k$ . LICRA converges to a limit point $r ^ { \star } \in \mathbb { R } ^ { p }$ which is the unique solution to $\Pi \mathfrak { F } ( \Phi r ^ { \star } ) = \Phi r ^ { \star }$ where $\mathfrak { F } v : = \mathcal { R } + \gamma P \operatorname* { m a x } \{ \mathcal { M } v , v \}$ . Moreover, $r ^ { \star }$ satisfies: $\| \Phi r ^ { \star } - Q ^ { \star } \| \leq ( 1 - \gamma ^ { 2 } ) ^ { - 1 / 2 } \| \Pi Q ^ { \star } - Q ^ { \star } \|$ .
292
+
293
+ The theorem establishes the convergence of LICRA to a stable point with the use of linear function approximators. The second statement bounds the proximity of the convergence point by the smallest approximation error that can be achieved given the choice of basis functions.
294
+
295
+ Having constructed a procedure to find the optimal agent’s optimal value function, we now seek to determine the conditions when an intervention should be performed. Let us denote by $\{ \tau _ { k } \} _ { k \ge 0 }$ the points at which the agent decides to act or intervention times, so for example if the agent chooses to perform an action at state $s _ { 6 }$ and again at state $s _ { 8 }$ , then $\tau _ { 1 } = 6$ and $\tau _ { 2 } = 8$ . The following result characterises the optimal intervention policy $\mathfrak { g }$ and the optimal times $\{ \tau _ { k } \} _ { k \ge 0 }$ .
296
+
297
+ Proposition 1 The policy g is given by: $\mathfrak { g } ( s _ { t } ) = H ( \mathcal { M } ^ { \pi , \mathfrak { g } } Q ^ { \pi , \mathfrak { g } } - Q ^ { \pi , \mathfrak { g } } ) ( s _ { t } , a _ { t } ) , \forall s _ { t } \in \mathcal { S } _ { \mathrm { ~ \Gamma ~ } }$ , where $Q ^ { \pi , { \mathfrak { g } } }$ is the solution in Theorem $\cdot$ , $\mathcal { M }$ is the intervention operator and $H$ is the Heaviside function, moreover the intervention times are $\tau _ { k } = \operatorname* { i n f } \{ \tau > \tau _ { k - 1 } | \mathcal { M } ^ { \pi , { \mathfrak { g } } } Q ^ { \pi , { \mathfrak { g } } } = Q ^ { \pi , { \mathfrak { g } } } \}$ .
298
+
299
+ Prop. 1 characterises the (categorical) distribution $\mathfrak { g }$ . Moreover, given the function $Q$ , the times $\{ \tau _ { k } \}$ can be determined by evaluating if $\mathcal { M } Q = Q$ holds.
300
+
301
+ A key aspect of Prop. 1 is that it exploits the cost structure of the problem to determine when the agent should perform an intervention. In particular, the equality $\mathcal { M } Q = Q$ implies that performing an action and incurring a cost for doing so is optimal.
302
+
303
+ # 6 Budget Augmented LICRA via State Augmentation
304
+
305
+ We now tackle the problem of RL with a budget. To do this, we combine the above impulse control technology with state augmentation technique proposed in [28] The mathematical formulation of the problem is now given by the following for any $s \in S$ :
306
+
307
+ $$
308
+ \operatorname* { m a x } _ { \pi \in \Pi , g } ~ \upsilon ^ { \pi , \mathfrak { g } } ( s ) \ \mathrm { ~ s . ~ t . ~ } n - \sum _ { t = 0 } ^ { \infty } \sum _ { k \geq 1 } \delta _ { \tau _ { k } } ^ { t } \geq 0 ,
309
+ $$
310
+
311
+ where $n \in \mathbb N$ is a fixed value that represents the maximum number of allowed interventions and $\sum k > 1 8 _ { T k } ^ { t }$ is equal to one if an impulse was applied at time $t$ and zero if it was not. In order to avoid dealing with a constrained MDP, we propose to introduce a new variable $z _ { t }$ tracking the remaining number of impulses: $\begin{array} { r } { z _ { t } = n - \sum _ { i = 0 } ^ { t - 1 } \sum _ { k \geq 1 } \delta _ { \tau _ { k } } ^ { i } } \end{array}$ . We treat $z _ { t }$ as another state and augment the state-space resulting in the transition $\widetilde { \mathcal P }$ :
312
+
313
+ $$
314
+ s _ { t + 1 } \sim P ( \cdot | s _ { t } , a _ { t } ) , \qquad z _ { t + 1 } = z _ { t } - \sum _ { k \geq 1 } \delta _ { \tau _ { k } } ^ { t } , \quad z _ { 0 } = n .
315
+ $$
316
+
317
+ In order to avoid violations, we reshape the reward as follows: 252 $\begin{array} { r } { \widetilde { \mathcal { R } } ( s _ { t } , z _ { t } , a _ { t } ) = \left\{ \begin{array} { l l } { \mathcal { R } ( s _ { t } , a _ { t } ) } & { z _ { t } \ge 0 } \\ { - \Delta } & { z _ { t } < 0 } \end{array} \right. } \end{array}$ ,, 253 where $\Delta > 0$ is a large enough hyper-parameter ensuring that there are no safety violations. To 254 summarise we aim to solve the following problem:
318
+
319
+ $$
320
+ v ^ { \pi , \mathfrak { g } } ( s , z ) = \mathbb { E } \left[ \sum _ { t = 0 } ^ { \infty } \gamma ^ { t } \widetilde { \mathcal { R } } ( s _ { t } , z _ { t } , a _ { t } ) | a _ { t } \sim \pi ( \cdot | s _ { t } , z _ { t } ) \right] ,
321
+ $$
322
+
323
+ where the policy now depends on the variable $z _ { t }$ . Note that $\widetilde { \mathcal P }$ in Equation 6 is a Markov process and, the rewards $\widetilde { \mathcal { R } }$ are bounded, as long as the rewards $\mathcal { R }$ are bounded. Therefore, we can apply directly the results for impulse control to this case as well. We denote the augmented MDP by $\widetilde { \mathcal { M } } = \langle \overset { \cdot } { S } \times \mathcal { Z } , \overset { \cdot } { A } , \widetilde { \mathcal { P } } , \widetilde { R } , \gamma \rangle$ , where $\mathcal { Z }$ is the space of the augmented state. We have the following.
324
+
325
+ Theorem 4 Consider the MDP $\widetilde { \mathcal { M } }$ for the problem 7, then:
326
+
327
+ a) The Bellman equation holds, i.e. there exists a function $\tilde { v } ^ { * , \pi , 9 }$ s.th. $\begin{array} { r l } { \tilde { v } ^ { * , \pi , \mathfrak { g } } ( s , z ) } & { { } = } \end{array}$ $\operatorname* { m a x } _ { \mathbf { a } \in \mathcal { A } } \Big ( \widetilde { \mathcal { R } } ( s , z , \pmb { a } ) + \gamma \mathbb { E } _ { s ^ { \prime } , z ^ { \prime } \sim \mathcal { P } } \left[ \widetilde { v } ^ { * , \pi , \mathfrak { g } } ( s ^ { \prime } , z ^ { \prime } ) \right] \Big )$ , where the optimal policy for $\widetilde { \mathcal { M } }$ has the form $\pi ^ { * } ( \cdot | s , z )$ ;
328
+
329
+ $b$ ) Given a ${ \widetilde { v } } : { \mathcal { S } } \times { \mathcal { Z } } \to \mathbb { R } ,$ , the stable point solution for $\widetilde { \mathcal { M } }$ is a given by $\operatorname* { l i m } _ { k \infty } \tilde { T } ^ { k } \widetilde { v } ^ { \pi , g } = \operatorname* { m a x } _ { \hat { \pi } \in \Pi , \hat { g } } \hat { \pi } ^ { \hat { \pi } , \hat { g } } =$ $\widetilde { v } ^ { * , \pi , { \mathfrak { g } } ^ { * } }$ , where $( \pi ^ { * } , { \mathfrak { g } } ^ { * } )$ is an optimal policy of $\widetilde { \mathcal { M } }$ and $\tilde { T }$ is the Bellman operator of $\widetilde { \mathcal { M } }$ .
330
+
331
+ The result has several important implications. The first is that we can use a modified version of LICRA to obtain the solution of the problem while guaranteeing convergence (under standard assumptions). Secondly, our state augmentation procedure admits a Markovian representation of the optimal policy.
332
+
333
+ # 69 7 Experiments
334
+
335
+ 270 We will now study empirically the performance of the LICRA framework. In experiments, we use
336
+ 271 different instances of LICRA, one where both policies are trained using PPO update (referred to
337
+ 272 as LICRA_PPO) and one where the policy deciding whether to act is trained using SAC and the
338
+ 273 other policy trained with PPO (referred to as LICRA_SAC). We have benchmarked both of these
339
+ 274 algorithms together with common baselines on environments, where it would be natural to introduce
340
+ 275 the concept of the cost associated with actions. We lastly performed a series of ablation studies which
341
+ 276 test LICRA’s ability to handle different cost functions including the case when $c ( s , a ) \equiv 0$ which we
342
+ 277 defer to the Appendix which also contains further experiment details.
343
+ 278 Merton’s Portfolio Problem with Transaction Costs. Merton Investment Problem in which the
344
+ 279 investor faces transaction costs [10] is a well-known problem within finance. In our environment, the
345
+ 280 agent can decide to move its wealth between a risky asset and a risk-free asset. The agent receives a
346
+ 281 reward only at the final step, equal to the utility of the portfolio with a risk aversion factor equal to
347
+ 282 0.5. If the final wealth of risky asset is $s _ { T }$ and final wealth of risk-free asset is $c _ { T }$ , then the agent will
348
+ 283 receive a reward of $u ( x ) = \hat { 2 \sqrt { s _ { T } + c _ { T } } }$ . The wealth evolves according to the following SDE:
349
+
350
+ ![](images/c36f4d4fc355a612aa0817f310a3b877c4df8280a953e0bbdade420829da0b36.jpg)
351
+ Figure 1: Training results in Merton investment problem for PPO style algorithms.
352
+
353
+ $$
354
+ d W _ { t } = ( r + p _ { t } ( \mu - r ) ) W _ { t } + W _ { t } p _ { t } \sigma d B _ { t }
355
+ $$
356
+
357
+ ![](images/e4f0e42faa34e8a85dc4690b08f54b2a9dca40e02107c30188aa1c25e63de654.jpg)
358
+ Figure 2: a) Drive Environment. b) Training results in drive environment.
359
+
360
+ 284 where $W _ { t }$ is the current wealth and the state variable, $d B _ { t }$ is an increment of Brownian motion and $p _ { t }$
361
+ 285 is the proportion of wealth invested in the risky asset. We set the risk-free return $r = 0 . 0 1$ , risky asset
362
+ 286 return $\mu = 0 . 0 5$ and volatility $\sigma = 1$ . We discretise the action space so that at each step the agent has
363
+ 287 three actions available: move $10 \%$ of risky asset wealth to the risk-free asset, move $10 \%$ of risk-free
364
+ 288 asset wealth to the risky asset or do nothing. Each time the agent moves the assets, it incurs a cost
365
+ 289 of 1 i.e. a transaction fee. The agent can act after a time interval of 0.01 seconds and the episode
366
+ 290 ends after 75 steps. The results of training are shown in Fig. 1 which clearly demonstrates that
367
+ 291 LICRA_PPO finds a better policy than standard PPO. Also comparing the variance among different
368
+ 292 seeds, we can see that LICRA_PPO is a much more stable algorithm than the other two.
369
+ 293 Driving Environment Fuel Rationing. We studied an autonomous driving scenario where fuel
370
+ 294 efficient driving is a priority. One of the main components of fuel-efficient driving is controlled usage
371
+ 295 of acceleration and braking, in the sense that 1) the amount of acceleration and braking should be
372
+ 296 limited 2) if accelerations should be performed slowly and gently. We believe this is a problem where
373
+ 297 LICRA should thrive as the impulse control agent can learn to restrict the amount of acceleration
374
+ 298 and braking in the presence of other cars and choose when to allow the car to decelerate naturally.
375
+ 299 We used the highway-env [17] environment on a highway task (see Fig (2. a)) where the green
376
+ 300 vehicle is our controlled vehicle and the goal is to avoid crashing into other vehicles whilst driving
377
+ 301 at a reasonable speed. We add a cost function into the reward term dependent on the continuous
378
+ 302 acceleration action, $C ( a _ { t } ) = K + a _ { t } ^ { 2 }$ , where $K > 0$ is a fixed constant cost of taking any action,
379
+ 303 and $a _ { t } \in [ - 1 , 1 ]$ , with larger values of acceleration or braking being penalised more. The results are
380
+ 304 presented in Fig. (2.b). Notably, LICRA is able to massively outperform the baselines, especially our
381
+ 305 safety specific baselines which struggle to deal with the cost function associated with the environment.
382
+ 306 We believe one reason for the success of LICRA is that it is far easier for it to utilise the null action
383
+ 307 of zero acceleration/braking than the other algorithms, whilst all the algorithms have a guaranteed
384
+ 308 cost at every time step whilst not gaining a sizeable reward to counter the cost.
385
+
386
+ ![](images/5bec575b374d2d9a07b6663aca5f30e26bc81290ee187b6eb4033c9c9f99603c.jpg)
387
+ Figure 3: a) The lander must land on the pad between two flags. . b) Training results in Lunar Lander. Lunar Lander Environment. We tested the ability of LICRA to perform in environment that simulate real-world physical dynamics. We tested LICRA’s performance the Lunar Lander environment in OpenAI gym [7] which we adjusted to incorporate minimal bounded costs in the reward definition. In this environment, the agent is required to maintain both a good posture mid-air and reach the landing pad as quickly as possible. The reward function is given by:
388
+
389
+ $$
390
+ \begin{array} { r } { \mathrm { R e w a r d } \left( s _ { t } \right) = 3 * \left( 1 - \mathbf { 1 } _ { d _ { t } - d _ { t - 1 } = 0 } \right) - 3 * \left( 1 - \mathbf { 1 } _ { v _ { t } - v _ { t - 1 } = 0 } \right) - 3 * \left( 1 - \mathbf { 1 } _ { \omega _ { t } - \omega _ { t - 1 } = 0 } \right) } \\ { - 0 . 0 3 * \mathrm { F u e l S p e n t } ( s _ { t } ) - 1 0 * \left( v _ { t } - v _ { t - 1 } \right) - 1 0 * \left( \omega _ { t } - \omega _ { t - 1 } \right) + 1 0 0 * \mathrm { h a s L a n d e d } \left( s _ { t } \right) } \end{array}
391
+ $$
392
+
393
+ 309 where $d _ { t }$ is the distance to the landing pad, $v _ { t }$ is the velocity of the agent, and $\omega _ { t }$ is the angular
394
+ 310 velocity of the agent at time $t$ . $\mathbf { 1 } _ { X }$ is the indicator function of taking actions, which is 1 when the
395
+ 311 statement $X$ is true and 0 when $X$ is false. Considering the limited fuel budget, we assume that
396
+ 312 we have a fixed cost for each action taken by the agent here, and doing nothing brings no cost. Then,
397
+ 313 to describe the goal of the game, we define the function of the final status by hasLanded(), which is
398
+ 314 0 when not landing; 1 when the agent has landed softly on the landing pad; and $- 1$ when the lander
399
+ 315 runs out of fuel or loses contact with the pad on landing. The reward function rewards the agent
400
+ 316 for reducing its distance to the landing pad, decreasing its speed to land smoothly and keeping the
401
+ 317 angular speed at a minimum to prevent rolling. Additionally, it penalises the agent for running out
402
+ 318 of fuel and deters the agent from taking off again after landing.
403
+ 319 By introducing a reward function with minimally bounded costs, our goal was to test if LICRA can
404
+ 320 exploit the optimal policy. In Fig. 3, we observe that the LICRA agent outperforms all the baselines,
405
+ 321 both in terms of sample efficiency and average test return (total rewards at each timestep). We also
406
+ 322 observe that LICRA enables more stable training than PPO, PPO-Lagrangian and CPO.
407
+ 323 Ablation Study 1. Prioritisation of Most Important Actions. We next tested LICRA’s ability to
408
+ 324 prioritise where it performs actions when the necessity to act varies significantly between states. To
409
+ 325 test this, we modified the Drive Environment to now consist of a single lane, a start state and a goal
410
+ 326 state start (at the end) where there is a reward. With no acceleration, the vehicle decreases velocity.
411
+ 327 To reach the goal, the agent must apply an acceleration $a _ { t } \in [ - 1 , 1 ]$ . Each acceleration $a _ { t }$ incurs
412
+ 328 a cost $C ( \boldsymbol { a } _ { t } )$ as defined above. At zones $k = 1 , 2 , 3$ of the lane, if the vehicle is travelling below a
413
+ 329 velocity $v _ { m i n }$ , it is penalised by a strictly negative cost $c _ { k }$ where $c _ { 1 } < c _ { 2 } < c _ { 3 }$ . As shown in Fig. 4,
414
+ 330 when the intervention cost increases i.e. when $K \infty$ , LICRA successfully prioritises the highest
415
+ penalty zones to avoid incurring large costs.
416
+
417
+ ![](images/2ba4542911b4913c1e9265c3276b917ff90a5a40da65ab950216d84702acce94.jpg)
418
+ Figure 4: Results for Ablation Study 1. Heatmaps display the number of times the agent drives below $v _ { m i n }$ in the penalty zones. Violation 1 refers to the lowest cost zone, whilst Violation 3 refers to the largest cost zone. $K$ refers to the fixed cost for taking an action.
419
+
420
+ # 8 Conclusion
421
+
422
+ We presented a novel method to tackle the problem of learning how to select when to act in addition to learning which actions to execute. Our framework, which is a general tool for tackling problems of this kind seamlessly adopts RL algorithms enabling them to efficiently tackle problems in which the agent must be selective about when it executes actions. This is of fundamental importance in practical settings where performing many actions over the horizon can lead to costs and undermine the service life of machinery. We demonstrated that our solution, LICRA which at its core has a sequential decision structure that first decides whether or not an action ought to be taken under the action policy can solve tasks where the agent faces costs with extreme efficiency as compared to leading reinforcement learning methods. In some tasks, we showed that LICRA is able to solve problems that are unsolvable using current reinforcement learning machinery. We envisge that this framework can serve as the basis extensions to different settings including adversarial training for solving a variety of problems within RL.
423
+
424
+ # References
425
+
426
+ [1] Ali Ajdari, Maximilian Niyazi, Nils Henrik Nicolay, Christian Thieke, Robert Jeraj, and Thomas Bortfeld. Towards optimal stopping in radiation therapy. Radiotherapy and Oncology, 134:96–
427
+
428
+ [2] Luluwah Al-Fagih. The british knock-out put option. International Journal of Theoretical and Applied Finance, 18(02):1550008, 2015.
429
+ [3] Juan J Alcaraz, Jose A Ayala-Romero, Javier Vales-Alonso, and Fernando Losilla-López. Online reinforcement learning for adaptive interference coordination. Transactions on Emerging Telecommunications Technologies, 31(10):e4087, 2020.
430
+ [4] Sebastian Becker, Patrick Cheridito, and Arnulf Jentzen. Deep optimal stopping. arXiv preprint arXiv:1804.05394, 2018.
431
+ [5] Albert Benveniste, Michel Métivier, and Pierre Priouret. Adaptive algorithms and stochastic approximations, volume 22. Springer Science & Business Media, 2012.
432
+ [6] Dimitri P Bertsekas. Approximate dynamic programming. Athena scientific Belmont, 2012.
433
+ [7] Greg Brockman, Vicki Cheung, Ludwig Pettersson, Jonas Schneider, John Schulman, Jie Tang, and Wojciech Zaremba. Openai gym. arXiv preprint arXiv:1606.01540, 2016.
434
+ [8] Andrew S Caplin and Daniel F Spulber. Menu costs and the neutrality of money. The Quarterly Journal of Economics, 102(4):703–725, 1987.
435
+ [9] Shuhang Chen, Adithya M Devraj, Ana Bušic, and Sean Meyn. Zap q-learning for´ optimal ´ stopping. In 2020 American Control Conference (ACC), pages 3920–3925. IEEE, 2020.
436
+ [10] Mark HA Davis and Andrew R Norman. Portfolio selection with transaction costs. Mathematics of operations research, 15(4):676–713, 1990.
437
+ [11] Marc Deisenroth and Carl E Rasmussen. Pilco: A model-based and data-efficient approach to policy search. In Proceedings of the 28th International Conference on machine learning (ICML-11), pages 465–472. Citeseer, 2011.
438
+ [12] Abderrahim Fathan and Erick Delage. Deep reinforcement learning for optimal stopping with application in financial engineering. arXiv preprint arXiv:2105.08877, 2021.
439
+ [13] F Grandt Jr. Damage tolerant design and nondestructive inspection-keys to aircraft airworthiness. Procedia Engineering, 17:236–246, 2011.
440
+ [14] Tuomas Haarnoja, Aurick Zhou, Kristian Hartikainen, George Tucker, Sehoon Ha, Jie Tan, Vikash Kumar, Henry Zhu, Abhishek Gupta, Pieter Abbeel, et al. Soft actor-critic algorithms and applications. arXiv preprint arXiv:1812.05905, 2018.
441
+ [15] Tommi Jaakkola, Michael I Jordan, and Satinder P Singh. Convergence of stochastic iterative dynamic programming algorithms. In Advances in neural information processing systems, pages 703–710, 1994.
442
+ [16] Ralf Korn. Some applications of impulse control in mathematical finance. Mathematical Methods of Operations Research, 50(3):493–518, 1999.
443
+ [17] Edouard Leurent. An environment for autonomous driving decision-making. https://github. com/eleurent/highway-env, 2018.
444
+ [18] Harry M Markowitz. Foundations of portfolio theory. The journal of finance, 46(2):469–477, 1991.
445
+ [19] David Mguni. Duopoly investment problems with minimally bounded adjustment costs. arXiv preprint arXiv:1805.11974, 2018.
446
+ [20] David Mguni. Optimal capital injections with the risk of ruin: A stochastic differential game of impulse control and stopping approach. arXiv preprint arXiv:1805.01578, 2018.
447
+ [21] David Mguni. Optimal selection of transaction costs in a dynamic principal-agent problem. arXiv preprint arXiv:1805.01062, 2018.
448
+ [22] David Mguni. A viscosity approach to stochastic differential games of control and stopping involving impulsive control. arXiv preprint arXiv:1803.11432, 2018.
449
+ [23] David Mguni. Cutting your losses: Learning fault-tolerant control and optimal stopping under adverse risk. arXiv preprint arXiv:1902.05045, 2019.
450
+ [24] Bernt Øksendal. Stochastic differential equations. In Stochastic differential equations, pages 65–84. Springer, 2003.
451
+ [25] Bernt Øksendal and Agnès Sulem. Approximating impulse control by iterated optimal stopping. In Applied Stochastic Control of Jump Diffusions, pages 255–272. Springer, 2019.
452
+ [26] Jing-Cheng Pang, Tian Xu, Sheng-Yi Jiang, Yu-Ren Liu, and Yang Yu. Sparsity prior regularized q-learning for sparse action tasks. arXiv preprint arXiv:2105.08666, 2021.
453
+ [27] John Schulman, Filip Wolski, Prafulla Dhariwal, Alec Radford, and Oleg Klimov. Proximal policy optimization algorithms. CoRR, abs/1707.06347, 2017.
454
+ [28] Aivar Sootla, Alexander I. Cowen-Rivers, Taher Jafferjee, Ziyan Wang, David Mguni, Jun Wang, and Haitham Bou-Ammar. Sauté RL: Almost surely safe reinforcement learning using state augmentation. arXiv preprint arXiv:2202.06558, 2022.
455
+ [29] Aivar Sootla, Diego Oyarzún, David Angeli, and Guy-Bart Stan. Shaping pulses to control bistable systems: Analysis, computation and counterexamples. Automatica, 63:254–264, 2016.
456
+ [30] Richard S Sutton and Andrew G Barto. Reinforcement learning: An introduction. MIT press, 2018.
457
+ [31] John N Tsitsiklis and Benjamin Van Roy. Optimal stopping of markov processes: Hilbert space theory, approximation algorithms, and an application to pricing high-dimensional financial derivatives. IEEE Transactions on Automatic Control, 44(10):1840–1851, 1999.
458
+ [32] Pu Zhao, Yanzhi Wang, Naehyuck Chang, Qi Zhu, and Xue Lin. A deep reinforcement learning framework for optimizing fuel economy of hybrid electric vehicles. In 2018 23rd Asia and South Pacific design automation conference (ASP-DAC), pages 196–202. IEEE, 2018.